opnet 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/browser/index.js CHANGED
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see index.js.LICENSE.txt */
2
- var t,e,r={3513:(t,e,r)=>{var n=r(8287).Buffer,i=r(9598),o=r(9615),s=r(2623);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var u=a(i);const c="Expected Private",l="Expected Point",f="Expected Tweak",h="Expected Signature",p="Expected Extra Data (32 bytes)",d="Expected Scalar";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const y=u.utils._normalizePrivateKey,g=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),b=new Uint8Array(32),w=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function m(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function v(t){return 0===m(t,b)}function E(t){return t instanceof Uint8Array&&32===t.length&&!(m(t,g)>=0)}function A(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),g)<0&&m(t.subarray(32,64),g)<0}function S(t){return t instanceof Uint8Array&&32===t.length}function _(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function k(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function T(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=k(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");r=t,e=k(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error("Expected private scalar >= 0");return e}const P=(t,e,r)=>{const n=u.Point.fromHex(t),i=T(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)};function I(t,e){return void 0===t?void 0===e||R(e):!!t}function O(t){try{return t()}catch(t){return null}}function x(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function B(t){return x(t,!1)}function R(t){return x(t,!1)&&33===t.length}function N(t){return u.utils.isValidPrivateKey(t)}function U(t){return x(t,!0)}function C(t){if(!B(t))throw new Error(l);return t.slice(1,33)}function L(t,e){if(!N(t))throw new Error(c);return O((()=>u.getPublicKey(t,I(e))))}e.isPoint=B,e.isPointCompressed=R,e.isPrivate=N,e.isXOnlyPoint=U,e.pointAdd=function(t,e,r){if(!B(t)||!B(e))throw new Error(l);return O((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(I(r,t))}))},e.pointAddScalar=function(t,e,r){if(!B(t))throw new Error(l);if(!E(e))throw new Error(f);return O((()=>P(t,e,I(r,t))))},e.pointCompress=function(t,e){if(!B(t))throw new Error(l);return u.Point.fromHex(t).toRawBytes(I(e,t))},e.pointFromScalar=L,e.pointMultiply=function(t,e,r){if(!B(t))throw new Error(l);if(!E(e))throw new Error(f);return O((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i="string"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,I(r,t))))},e.privateAdd=function(t,e){if(!1===N(t))throw new Error(c);if(!1===E(e))throw new Error(f);return O((()=>((t,e)=>{const r=y(t),n=T(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===N(t))throw new Error(c);return(t=>{const e=y(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===N(t))throw new Error(c);if(!1===E(e))throw new Error(f);return O((()=>((t,e)=>{const r=y(t),n=T(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!S(t))throw new Error("Expected Hash");if(!A(e)||!function(t){return!(v(t.subarray(0,32))||v(t.subarray(32,64)))}(e))throw new Error(h);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),w)<0}(e))throw new Error("Bad Recovery Id");if(!U(e.subarray(0,32)))throw new Error(h);return u.recoverPublicKey(t,e,r,I(n))},e.sign=function(t,e,r){if(!N(e))throw new Error(c);if(!S(t))throw new Error(d);if(!_(r))throw new Error(p);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!N(e))throw new Error(c);if(!S(t))throw new Error(d);if(!_(r))throw new Error(p);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!N(e))throw new Error(c);if(!S(t))throw new Error(d);if(!_(r))throw new Error(p);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!B(e))throw new Error(l);if(!A(r))throw new Error(h);if(!S(t))throw new Error(d);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!U(e))throw new Error(l);if(!A(r))throw new Error(h);if(!S(t))throw new Error(d);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!U(t))throw new Error(l);if(!E(e))throw new Error(f);return O((()=>{const r=P(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=C,e.xOnlyPointFromScalar=function(t){if(!N(t))throw new Error(c);return C(L(t))}},7557:(t,e)=>{function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function a(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 u(t,e){o(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=e.isBytes=void 0,e.number=r,e.bool=n,e.isBytes=i,e.bytes=o,e.hash=s,e.exists=a,e.output=u;const c={number:r,bool:n,bytes:o,hash:s,exists:a,output:u};e.default=c},7202:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(7557),i=r(9175);e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;n<s;){const a=Math.min(o-this.pos,s-n);if(a!==o)r.set(t.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=s-n;n+=o)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.exists)(this),(0,n.output)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const u=(0,i.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)u.setUint32(4*t,f[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=o},5145:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},9615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(7557),i=r(9175);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),s.fill(0)}update(t){return(0,n.exists)(this),this.iHash.update(t),this}digestInto(t){(0,n.exists)(this),(0,n.bytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o,e.hmac=(t,e,r)=>new o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},3238:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7202),i=r(9175),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e)));let a=[s],u=[s.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let e of[a,u])e.push(e[t].map((t=>o[t])));const c=[[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))),l=a.map(((t,e)=>t.map((t=>c[e][t])))),f=u.map(((t,e)=>t.map((t=>c[e][t])))),h=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),p=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function d(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const y=new Uint32Array(16);class g extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)y[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,c=0|this.h2,g=c,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=h[t],A=p[t],S=a[t],_=u[t],k=l[t],T=f[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+d(t,o,c,b)+y[S[e]]+E,k[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(c,10),c=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+d(e,s,g,w)+y[_[t]]+A,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(g,10),g=s,s=r}}this.set(this.h1+c+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+g|0)}roundClean(){y.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=g,e.ripemd160=(0,i.wrapConstructor)((()=>new g))},1549:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha1=void 0;const n=r(7202),i=r(9175),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:u,E:c}=this;for(let t=0;t<80;t++){let e,l;t<20?(e=(0,n.Chi)(o,a,u),l=1518500249):t<40?(e=o^a^u,l=1859775393):t<60?(e=(0,n.Maj)(o,a,u),l=2400959708):(e=o^a^u,l=3395469782);const f=(0,i.rotl)(r,5)+e+c+l+s[t]|0;c=u,u=a,a=(0,i.rotl)(o,30),o=r,r=f}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,u=u+this.D|0,c=c+this.E|0,this.set(r,o,a,u,c)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},2623:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7202),i=r(9175),o=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]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:u,D:c,E:l,F:f,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(l,6)^(0,i.rotr)(l,11)^(0,i.rotr)(l,25))+(0,n.Chi)(l,f,h)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,u)|0;p=h,h=f,f=l,l=c+e|0,c=u,u=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,u=u+this.C|0,c=c+this.D|0,l=l+this.E|0,f=f+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,s,u,c,l,f,h,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class c extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new c))},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(5145),i=r(7557);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.rotl=(t,e)=>t<<e|t>>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])};const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));e.bytesToHex=function(t){(0,i.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e};const s=48,a=57,u=65,c=70,l=97,f=102;function h(t){return t>=s&&t<=a?t-s:t>=u&&t<=c?t-(u-10):t>=l&&t<=f?t-(l-10):void 0}function p(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function d(t){return"string"==typeof t&&(t=p(t)),(0,i.bytes)(t),t}e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.nextTick=async()=>{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=p,e.toBytes=d,e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];(0,i.bytes)(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.Hash=class{clone(){return this._cloneInto()}};const y={}.toString;e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==y.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(d(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}},9598:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(4923),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),u=BigInt(8),c=Object.freeze({a:i,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:o,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=c;const l=(t,e)=>(t+e/s)/e,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),u=l(s*t,e),f=l(-n*t,e);let h=F(t-u*r-f*i,e),p=F(-u*n-f*s,e);const d=h>a,y=p>a;if(d&&(h=e-h),y&&(p=e-p),h>a||p>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:d,k1:h,k2neg:y,k2:p}}},h=32,p=32,d=h+1,y=2*h+1;function g(t){const{a:e,b:r}=c,n=F(t*t),i=F(n*t);return F(i+e*t+r)}const b=c.a===i;class w extends Error{constructor(t){super(t)}}function m(t){if(!(t instanceof v))throw new TypeError("JacobianPoint expected")}class v{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(S.ZERO)?v.ZERO:new v(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=c.P){const r=new Array(t.length),n=j(t.reduce(((t,n,o)=>n===i?t:(r[o]=t,F(t*n,e))),o),e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=F(t*r[o],e),F(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return v.toAffineBatch(t).map(v.fromAffine)}equals(t){m(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=F(n*n),u=F(s*s),c=F(e*u),l=F(i*a),f=F(F(r*s)*u),h=F(F(o*n)*a);return c===l&&f===h}negate(){return new v(this.x,F(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=F(t*t),i=F(e*e),o=F(i*i),c=t+i,l=F(s*(F(c*c)-n-o)),f=F(a*n),h=F(f*f),p=F(h-s*l),d=F(f*(l-p)-u*o),y=F(s*e*r);return new v(p,d,y)}add(t){m(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:u}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const c=F(n*n),l=F(u*u),f=F(e*l),h=F(o*c),p=F(F(r*u)*l),d=F(F(a*n)*c),y=F(h-f),g=F(d-p);if(y===i)return g===i?this.double():v.ZERO;const b=F(y*y),w=F(y*b),E=F(f*b),A=F(g*g-w-s*E),S=F(g*(E-A)-p*w),_=F(n*u*y);return new v(A,S,_)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=v.ZERO;if("bigint"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!b){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:u}=f.splitScalar(r),c=e,l=e,h=this;for(;s>i||u>i;)s&o&&(c=c.add(h)),u&o&&(l=l.add(h)),h=h.double(),s>>=o,u>>=o;return n&&(c=c.negate()),a&&(l=l.negate()),l=new v(F(l.x*f.beta),l.y,l.z),c.add(l)}precomputeWindow(t){const e=b?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(v.BASE)&&(e=S.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&A.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=v.normalizeZ(n),A.set(e,n)));let i=v.ZERO,s=v.BASE;const a=1+(b?128/r:256/r),u=2**(r-1),c=BigInt(2**r-1),l=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*u;let a=Number(t&c);t>>=f,a>u&&(a-=l,t+=o);const h=r,p=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[h])):i=i.add(E(y,n[p]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(b){const{k1neg:t,k1:o,k2neg:s,k2:a}=f.splitScalar(i);let{p:u,f:c}=this.wNAF(o,e),{p:l,f:h}=this.wNAF(a,e);u=E(t,u),l=E(s,l),l=new v(F(l.x*f.beta),l.y,l.z),r=u.add(l),n=c.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return v.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(v.ZERO);null==t&&(t=i?u:j(n));const s=t,a=F(s*s),c=F(a*s),l=F(e*a),f=F(r*c),h=F(n*s);if(i)return S.ZERO;if(h!==o)throw new Error("invZ was invalid");return new S(l,f)}}function E(t,e){const r=e.negate();return t?r:e}v.BASE=new v(c.Gx,c.Gy,o),v.ZERO=new v(i,o,i);const A=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,A.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=L(e?t:t.subarray(1));if(!q(r))throw new Error("Point is not on curve");let n=function(t){const{P:e}=c,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),l=BigInt(88),f=t*t*t%e,h=f*f*t%e,p=H(h,a)*h%e,d=H(p,a)*h%e,y=H(d,s)*f%e,g=H(y,n)*y%e,b=H(g,i)*g%e,w=H(b,u)*b%e,m=H(w,l)*w%e,v=H(m,u)*b%e,E=H(v,a)*h%e,A=H(E,o)*g%e,S=H(A,r)*f%e,_=H(S,s);if(_*_%e!==t)throw new Error("Cannot find square root");return _}(g(r));const i=(n&o)===o;e?i&&(n=F(-n)):!(1&~t[0])!==i&&(n=F(-n));const u=new S(r,n);return u.assertValidity(),u}static fromUncompressedHex(t){const e=L(t.subarray(1,h+1)),r=L(t.subarray(h+1,2*h+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=D(t),r=e.length,n=e[0];if(r===h)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(J(t))}static fromSignature(t,e,r){const{r:n,s:i}=Y(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=G(D(t)),{n:s}=c,a=2===r||3===r?n+s:n,u=j(a,s),l=F(-o*u,s),f=F(i*u,s),h=1&r?"03":"02",p=S.fromHex(h+B(a)),d=S.BASE.multiplyAndAddUnsafe(p,l,f);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return C(this.toHex(t))}toHex(t=!1){const e=B(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${B(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:r}=this;if(!q(e)||!q(r))throw new Error(t);const n=F(r*r);if(F(n-g(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,F(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(t){return v.fromAffine(this).add(v.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return v.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=v.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=v.fromAffine(t).multiplyUnsafe(r),u=s.add(a);return u.equals(v.ZERO)?void 0:u.toAffine()}}function _(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function k(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${O(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:L(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(c.Gx,c.Gy),S.ZERO=new S(i,i);class T{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?O(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(U(n.slice(0,64)),U(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${O(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=k(t.subarray(2)),{data:n,left:i}=k(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${O(i)}`);return{r:e,s:n}}(e?t:C(t));return new T(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!z(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!z(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=c.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new T(this.r,F(-this.s,c.n)):this}toDERRawBytes(){return C(this.toDERHex())}toDERHex(){const t=_(N(this.s)),e=_(N(this.r)),r=t.length/2,n=e.length/2,i=N(r),o=N(n);return`30${N(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return C(this.toCompactHex())}toCompactHex(){return B(this.r)+B(this.s)}}function P(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}e.Signature=T;const I=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function O(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=I[t[r]];return e}const x=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function B(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(i<=t&&t<x))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function R(t){const e=C(B(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function N(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function U(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function C(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function L(t){return U(O(t))}function D(t){return t instanceof Uint8Array?Uint8Array.from(t):C(t)}function M(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&z(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function F(t,e=c.P){const r=t%e;return r>=i?r:e+r}function H(t,e){const{P:r}=c;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function j(t,e=c.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=F(t,e),n=e,s=i,a=o,u=o,l=i;for(;r!==i;){const t=n/r,e=n%r,i=s-u*t,o=a-l*t;n=r,r=e,s=u,a=l,u=i,l=o}if(n!==o)throw new Error("invert: does not exist");return F(s,e)}function G(t,e=!1){const r=function(t){const e=8*t.length-8*p,r=L(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=c;return r>=n?r-n:r}let V,K;class W{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,"number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return K(this.k,...t)}checkSync(){if("function"!=typeof K)throw new w("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=await this.hmac(this.v);const r=this.v.slice();e.push(r),t+=this.v.length}return P(...e)}generateSync(){this.checkSync(),this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=this.hmacSync(this.v);const r=this.v.slice();e.push(r),t+=this.v.length}return P(...e)}}function z(t){return i<t&&t<c.n}function q(t){return i<t&&t<c.P}function Q(t,e,r,n=!0){const{n:s}=c,a=G(t,!0);if(!z(a))return;const u=j(a,s),l=S.BASE.multiply(a),f=F(l.x,s);if(f===i)return;const h=F(u*F(e+r*f,s),s);if(h===i)return;let p=new T(f,h),d=(l.x===p.r?0:2)|Number(l.y&o);return n&&p.hasHighS()&&(p=p.normalizeS(),d^=1),{sig:p,recovery:d}}function J(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if("string"==typeof t){if(t.length!==2*p)throw new Error("Expected 32 bytes of private key");e=U(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(t.length!==p)throw new Error("Expected 32 bytes of private key");e=L(t)}if(!z(e))throw new Error("Expected private key: 0 < key < n");return e}function X(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function Y(t){if(t instanceof T)return t.assertValidity(),t;try{return T.fromDER(t)}catch(e){return T.fromCompact(t)}}function Z(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function $(t){return L(t.length>h?t.slice(0,h):t)}function tt(t){const e=$(t),r=F(e,c.n);return et(r<i?e:r)}function et(t){return R(t)}function rt(t,r,n){if(null==t)throw new Error(`sign: expected valid message hash, not "${t}"`);const i=D(t),o=J(r),s=[et(o),tt(i)];if(null!=n){!0===n&&(n=e.utils.randomBytes(h));const t=D(n);if(t.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);s.push(t)}return{seed:P(...s),m:$(i),d:o}}function nt(t,e){const{sig:r,recovery:n}=t,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},e),s=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[s,n]:s}e.getPublicKey=function(t,e=!1){return S.fromPrivateKey(t).toRawBytes(e)},e.recoverPublicKey=function(t,e,r,n=!1){return S.fromSignature(t,e,r).toRawBytes(n)},e.getSharedSecret=function(t,e,r=!1){if(Z(t))throw new TypeError("getSharedSecret: first arg must be private key");if(!Z(e))throw new TypeError("getSharedSecret: second arg must be public key");const n=X(e);return n.assertValidity(),n.multiply(J(t)).toRawBytes(r)},e.sign=async function(t,e,r={}){const{seed:n,m:i,d:o}=rt(t,e,r.extraEntropy),s=new W(32,p);let a;for(await s.reseed(n);!(a=Q(await s.generate(),i,o,r.canonical));)await s.reseed();return nt(a,r)},e.signSync=function(t,e,r={}){const{seed:n,m:i,d:o}=rt(t,e,r.extraEntropy),s=new W(32,p);let a;for(s.reseedSync(n);!(a=Q(s.generateSync(),i,o,r.canonical));)s.reseedSync();return nt(a,r)};const it={strict:!0};function ot(t){return F(L(t),c.n)}e.verify=function(t,e,r,n=it){let i;try{i=Y(t),e=D(e)}catch(t){return!1}const{r:o,s}=i;if(n.strict&&i.hasHighS())return!1;const a=G(e);let u;try{u=X(r)}catch(t){return!1}const{n:l}=c,f=j(s,l),h=F(a*f,l),p=F(o*f,l),d=S.BASE.multiplyAndAddUnsafe(u,h,p);return!!d&&F(d.x,l)===o};class st{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=D(t);if(64!==e.length)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${e.length}`);const r=L(e.subarray(0,32)),n=L(e.subarray(32,64));return new st(r,n)}assertValidity(){const{r:t,s:e}=this;if(!q(t)||!z(e))throw new Error("Invalid signature")}toHex(){return B(this.r)+B(this.s)}toRawBytes(){return C(this.toHex())}}class at{constructor(t,r,n=e.utils.randomBytes()){if(null==t)throw new TypeError(`sign: Expected valid message, not "${t}"`);this.m=D(t);const{x:i,scalar:o}=this.getScalar(J(r));if(this.px=i,this.d=o,this.rand=D(n),32!==this.rand.length)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(t){const e=S.fromPrivateKey(t),r=e.hasEvenY()?t:c.n-t;return{point:e,scalar:r,x:e.toRawX()}}initNonce(t,e){return R(t^L(e))}finalizeNonce(t){const e=F(L(t),c.n);if(e===i)throw new Error("sign: Creation of signature failed. k is zero");const{point:r,x:n,scalar:o}=this.getScalar(e);return{R:r,rx:n,k:o}}finalizeSig(t,e,r,n){return new st(t.x,F(e+r*n,c.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:t,d:r,px:n,rand:i}=this,o=e.utils.taggedHash,s=this.initNonce(r,await o(pt.aux,i)),{R:a,rx:u,k:c}=this.finalizeNonce(await o(pt.nonce,s,n,t)),l=ot(await o(pt.challenge,u,n,t)),f=this.finalizeSig(a,c,l,r);return await lt(f,t,n)||this.error(),f}calcSync(){const{m:t,d:r,px:n,rand:i}=this,o=e.utils.taggedHashSync,s=this.initNonce(r,o(pt.aux,i)),{R:a,rx:u,k:c}=this.finalizeNonce(o(pt.nonce,s,n,t)),l=ot(o(pt.challenge,u,n,t)),f=this.finalizeSig(a,c,l,r);return ft(f,t,n)||this.error(),f}}function ut(t,e,r){const n=t instanceof st,i=n?t:st.fromHex(t);return n&&i.assertValidity(),{...i,m:D(e),P:X(r)}}function ct(t,e,r,n){const i=S.BASE.multiplyAndAddUnsafe(e,J(r),F(-n,c.n));return!(!i||!i.hasEvenY()||i.x!==t)}async function lt(t,r,n){try{const{r:i,s:o,m:s,P:a}=ut(t,r,n),u=ot(await e.utils.taggedHash(pt.challenge,R(i),a.toRawX(),s));return ct(i,a,o,u)}catch(t){return!1}}function ft(t,r,n){try{const{r:i,s:o,m:s,P:a}=ut(t,r,n),u=ot(e.utils.taggedHashSync(pt.challenge,R(i),a.toRawX(),s));return ct(i,a,o,u)}catch(t){if(t instanceof w)throw t;return!1}}e.schnorr={Signature:st,getPublicKey:function(t){return S.fromPrivateKey(t).toRawX()},sign:async function(t,e,r){return new at(t,e,r).calc()},verify:lt,signSync:function(t,e,r){return new at(t,e,r).calcSync()},verifySync:ft},S.BASE._setWindowSize(8);const ht={node:n,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},dt={};e.utils={bytesToHex:O,hexToBytes:C,concatBytes:P,mod:F,invert:j,isValidPrivateKey(t){try{return J(t),!0}catch(t){return!1}},_bigintTo32Bytes:R,_normalizePrivateKey:J,hashToPrivateKey:t=>{t=D(t);const e=p+8;if(t.length<e||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return R(F(L(t),c.n-o)+o)},randomBytes:(t=32)=>{if(ht.web)return ht.web.getRandomValues(new Uint8Array(t));if(ht.node){const{randomBytes:e}=ht.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(p+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(ht.web){const e=await ht.web.subtle.digest("SHA-256",P(...t));return new Uint8Array(e)}if(ht.node){const{createHash:e}=ht.node,r=e("sha256");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(ht.web){const r=await ht.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=P(...e),i=await ht.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(ht.node){const{createHmac:r}=ht.node,n=r("sha256",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=P(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if("function"!=typeof V)throw new w("sha256Sync is undefined, you need to set it");let r=dt[t];if(void 0===r){const e=V(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=P(e,e),dt[t]=r}return V(r,...e)},_JacobianPoint:v},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}},hmacSha256Sync:{configurable:!1,get:()=>K,set(t){K||(K=t)}}})},5364:t=>{t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var f=0,h=o-1;(0!==l||f<i)&&-1!==h;h--,f++)l+=s*c[h]>>>0,c[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,r++}for(var p=o-i;p!==o&&0===c[p];)p++;for(var d=new Uint8Array(n+(o-p)),y=n;p!==o;)d[y++]=c[p++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,l=new Uint8Array(u);i!==o;){for(var f=e[i],h=0,p=u-1;(0!==f||h<n)&&-1!==p;p--,h++)f+=256*l[p]>>>0,l[p]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===l[d];)d++;for(var y=a.repeat(r);d<u;++d)y+=t.charAt(l[d]);return y},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},7526:(t,e)=>{e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),l=0,f=u>0?s-4:s;for(r=0;r<f;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[l++]=e>>16&255,c[l++]=e>>8&255,c[l++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[l++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,c=n-i;a<c;a+=s)o.push(u(t,a,a+s>c?c:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,s=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2343:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function s(t,e,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=e)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function a(t){return s(t,8,5,!0)}function u(t){const e=s(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=s(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function l(t){let e;function s(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return"Mixed-case string "+t;const u=(t=s).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const c=t.slice(0,u),l=t.slice(u+1);if(l.length<6)return"Data too short";let f=o(c);if("string"==typeof f)return f;const h=[];for(let t=0;t<l.length;++t){const e=l.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;f=i(f)^r,t+6>=l.length||h.push(r)}return f!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=s(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError("Exceeds length limit");let a=o(t=t.toLowerCase());if("string"==typeof a)throw new Error(a);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");a=i(a)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t)u+=r.charAt(a>>5*(5-t)&31);return u},toWords:a,fromWordsUnsafe:u,fromWords:c}}e.bech32=l("bech32"),e.bech32m=l("bech32m")},4863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(1457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString("hex")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error("Combine: Nothing to combine");const u=o(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const c=s(r.globalKeyVals),l=r.inputKeyVals.map(s),f=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(c,r.globalKeyVals,a.globalKeyVals)),a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(l[e],r.inputKeyVals[e],a.inputKeyVals[e])))),a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(f[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},4834:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},4213:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},2706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(9080),i=r(4834),o=r(4213),s=r(6605),a=r(1795),u=r(4431),c=r(6907),l=r(5949),f=r(9344),h=r(2760),p=r(1695),d=r(8454),y=r(9034),g=r(2926),b=r(7851),w=r(7545),m=r(2412),v=r(4307),E=r(7636),A=r(2223),S=r(5578),_={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};e.globals=_;const k={nonWitnessUtxo:u,partialSig:c,sighashType:f,finalScriptSig:s,finalScriptWitness:a,porCommitment:l,witnessUtxo:g,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:A.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=k;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:A.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},6605:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1795:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},4431:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},6907:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},5949:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9344:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},2760:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},1695:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},8454:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},9034:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},2926:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),o=r(8133),s=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),u=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(u,r,0),s.encode(e.length,u,8),e.copy(u,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:u}},e.expected="{ script: Buffer; value: number; }",e.check=function(t){return n.isBuffer(t.script)&&"number"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},7851:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e<t.value.length;){const n=t.value[e++],i=t.value[e++],s=o.decode(t.value,e);e+=o.encodingLength(s),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+s)}),e+=s}return{leaves:r}},e.encode=function(t){const e=n.from([i.OutputTypes.TAP_TREE]),r=[].concat(...t.leaves.map((t=>[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},7545:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+r.key.toString("hex"));const n=r.key.slice(1);if(!e(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+r.key.toString("hex"));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},2412:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},4307:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode redeemScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},7636:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(7545),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)s[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:s})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),s=n.allocUnsafe(o);i.encode(t.leafHashes.length,s);const a=n.concat([s,...t.leafHashes,r.value]);return Object.assign({},r,{value:a})},check:function(t){return Array.isArray(t.leafHashes)&&t.leafHashes.every((t=>n.isBuffer(t)&&32===t.length))&&e.check(t)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:e.canAddToArray}}},2223:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+e.key.toString("hex"));if(32!==e.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},5578:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode witnessScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},8133:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.keyValsToBuffer=function(t){const e=t.map(o);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=o,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,s(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return s(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},394:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},6263:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133),s=r(394),a=r(9080);function u(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function c(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,a.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const l=r.length,f=n.length,h=[],p=[];for(const t of o.range(l)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(u("input",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(u("input",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:u("input",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:u("input",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}h.push(e)}for(const t of o.range(f)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:u("output",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:s,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function u(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const l=[],f={};for(;!u();){const t=i(),e=t.key.toString("hex");if(f[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);f[e]=1,l.push(t)}const h=l.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==h.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const p=e(h[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}b.push(r)}return c(p,{globalMapKeyVals:l,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=u,e.psbtFromKeyVals=c},1457:(t,e,r)=>{function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(6263)),n(r(238))},238:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=u({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),l=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),f=l(s),h=l(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(f,h))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString("hex"))).forEach((t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(s)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=u},1614:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(4863),o=r(1457),s=r(9080),a=r(5080);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9080:(t,e)=>{var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},5080:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function u(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:u,check:c,expected:l}=i[t+"s"][n]||{};if(c)if(u){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(c)||a(t,n,l,o);const e=r[n]||[],i=new Set;if(!o.every((t=>u(e,t,i))))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(c(o)||a(t,n,l,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(e&&0!==e.filter((e=>e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=u("global"),e.updateInput=u("input"),e.updateOutput=u("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},57:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(622),o=r(885),s=r(7038),a=r(8116),u=r(2343),c=r(1889),l="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function f(t){const e=n.from(c.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function h(t){let e,r;try{e=u.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+" uses wrong encoding")}else if(e=u.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+" uses wrong encoding");const i=u.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function p(t,e,r){const n=u.bech32.toWords(t);return n.unshift(e),0===e?u.bech32.encode(r,n):u.bech32m.encode(r,n)}e.fromBase58Check=f,e.fromBech32=h,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),c.encode(r)},e.toBech32=p,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=t[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(l),p(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+" has no matching Address")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=f(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=h(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(l),s.compile([n.version+80,n.data])}}throw new Error(t+" has no matching Script")}},3966:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},e.decode=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");const e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");const r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1696:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Block=void 0;const i=r(606),o=r(1944),s=r(1015),a=r(2021),u=r(8116),{typeforce:c}=u,l=new TypeError("Cannot compute merkle root for zero transactions"),f=new TypeError("Cannot compute witness commit for non-segwit block");class h{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");const e=new i.BufferReader(t),r=new h;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t<o;++t){const t=n();r.transactions.push(t)}const s=r.getWitnessCommit();return s&&(r.witnessCommit=s),r}static fromHex(t){return h.fromBuffer(n.from(t,"hex"))}static calculateTarget(t){const e=((4278190080&t)>>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(c([{getHash:u.Function}],t),0===t.length)throw l;if(e&&!p(t))throw f;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from("6a24aa21a9ed","hex")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>"object"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>"object"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString("hex")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=h.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw l;const t=h.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw l;if(!this.hasWitnessCommit())throw f;const t=h.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=h},606:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(8116),{typeforce:o}=i,s=r(8469);function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}function u(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function c(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=u,e.writeUInt64LE=c,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.cloneBuffer=function(t){const e=n.allocUnsafe(t.length);return t.copy(e),e};class l{static withCapacity(t){return new l(n.alloc(t))}constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}writeUInt8(t){this.offset=this.buffer.writeUInt8(t,this.offset)}writeInt32(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}writeUInt32(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}writeUInt64(t){this.offset=c(this.buffer,t,this.offset)}writeVarInt(t){s.encode(t,this.buffer,this.offset),this.offset+=s.encode.bytes}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach((t=>this.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=l,e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=u(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");const e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),e=[];for(let r=0;r<t;r++)e.push(this.readVarSlice());return e}}},1944:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(3238),o=r(1549),s=r(2623);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},916:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(s("function"==typeof(e=t).isXOnlyPoint),s(e.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),s(e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),s(e.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),s(e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),s(!e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),s(!e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),s("function"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const o=t=>n.from(t,"hex");function s(t){if(!t)throw new Error("ecc library invalid")}const a=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},1757:(t,e,r)=>{e.f0=e.K$=e.KT=e.o8=e.hl=void 0;const n=r(57);e.hl=n,r(1944);const i=r(622);e.o8=i;const o=r(885);e.KT=o;const s=r(7038);e.K$=s;r(1696),r(9646),r(8417),r(2021);var a=r(916);Object.defineProperty(e,"f0",{enumerable:!0,get:function(){return a.initEccLib}})},1015:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o<r;o+=2,++t){const s=i[o],a=o+1===r?s:i[o+1],u=n.concat([s,a]);i[t]=e(u)}r=t}return i[0]}},622:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8417:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r))n[r[t]]=t},2218:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(8287),i=r(916),o=r(1944),s=r(606),a=r(8116);function u(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),f(t.output)]))}function c(t,e){return o.taggedHash("TapTweak",n.Buffer.concat(e?[t,e]:[t]))}function l(t,e){return o.taggedHash("TapBranch",n.Buffer.concat([t,e]))}function f(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128,e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;e<r;e++){const r=t.slice(33+32*e,65+32*e);n=n.compare(r)<0?l(n,r):l(r,n)}return n},e.toHashTree=function t(e){if((0,a.isTapleaf)(e))return{hash:u(e)};const r=[t(e[0]),t(e[1])];r.sort(((t,e)=>t.hash.compare(e.hash)));const[n,i]=r;return{hash:l(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if("left"in(n=e)&&"right"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=u,e.tapTweakHash=c,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=c(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},5472:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2data=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:"embed",network:t.network||n.bitcoin};if(s.prop(r,"output",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,"data",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError("Output is invalid");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError("Output is invalid");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)}},885:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(5472);Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(1395);Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const o=r(4930);Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return o.p2pk}});const s=r(3504);Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(8368);Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return a.p2sh}});const u=r(7027);Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return u.p2wpkh}});const c=r(9041);Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return c.p2wsh}});const l=r(5501);Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return l.p2tr}})},7883:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},1395:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2ms=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS,u=a.OP_RESERVED;function c(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const l={network:t.network||n.bitcoin};let f=[],h=!1;function p(t){h||(h=!0,f=i.decompile(t),l.m=f[0]-u,l.n=f[f.length-2]-u,l.pubkeys=f.slice(1,-2))}if(s.prop(l,"output",(()=>{if(t.m&&l.n&&t.pubkeys)return i.compile([].concat(u+t.m,t.pubkeys,u+l.n,a.OP_CHECKMULTISIG))})),s.prop(l,"m",(()=>{if(l.output)return p(l.output),l.m})),s.prop(l,"n",(()=>{if(l.pubkeys)return l.pubkeys.length})),s.prop(l,"pubkeys",(()=>{if(t.output)return p(t.output),l.pubkeys})),s.prop(l,"signatures",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(l,"input",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(l,"witness",(()=>{if(l.input)return[]})),s.prop(l,"name",(()=>{if(l.m&&l.n)return`p2ms(${l.m} of ${l.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(f[0]))throw new TypeError("Output is invalid");if(!o.typeforce.Number(f[f.length-2]))throw new TypeError("Output is invalid");if(f[f.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(l.m<=0||l.n>16||l.m>l.n||l.n!==f.length-3)throw new TypeError("Output is invalid");if(!l.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==l.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==l.n)throw new TypeError("n mismatch");if(t.pubkeys&&!c(t.pubkeys,l.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(l.n=t.pubkeys.length,l.n<l.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<l.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>l.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===l.signatures.length||!l.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!c(t.signatures,l.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(l,t)}},4930:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2pk=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),u={name:"p2pk",network:t.network||n.bitcoin};if(s.prop(u,"output",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(u,"pubkey",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(u,"signature",(()=>{if(t.input)return r()[0]})),s.prop(u,"input",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(u,"witness",(()=>{if(u.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,o.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(u.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,t)}},3504:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2pkh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(1889),l=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),f=u.value((()=>s.decompile(t.input))),h=t.network||o.bitcoin,p={name:"p2pkh",network:h};if(u.prop(p,"address",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.pubKeyHash,0),p.hash.copy(t,1),c.encode(t)})),u.prop(p,"hash",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),u.prop(p,"output",(()=>{if(p.hash)return s.compile([l.OP_DUP,l.OP_HASH160,p.hash,l.OP_EQUALVERIFY,l.OP_CHECKSIG])})),u.prop(p,"pubkey",(()=>{if(t.input)return f()[1]})),u.prop(p,"signature",(()=>{if(t.input)return f()[0]})),u.prop(p,"input",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),u.prop(p,"witness",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==l.OP_DUP||t.output[1]!==l.OP_HASH160||20!==t.output[2]||t.output[23]!==l.OP_EQUALVERIFY||t.output[24]!==l.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.input){const r=f();if(2!==r.length)throw new TypeError("Input is invalid");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,a.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}},8368:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2sh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(1889),l=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const f={network:r},h=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=u.value((()=>s.decompile(t.input))),d=u.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===l.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(u.prop(f,"address",(()=>{if(!f.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(f.network.scriptHash,0),f.hash.copy(t,1),c.encode(t)})),u.prop(f,"hash",(()=>t.output?t.output.slice(2,22):t.address?h().hash:f.redeem&&f.redeem.output?i.hash160(f.redeem.output):void 0)),u.prop(f,"output",(()=>{if(f.hash)return s.compile([l.OP_HASH160,f.hash,l.OP_EQUAL])})),u.prop(f,"redeem",(()=>{if(t.input)return d()})),u.prop(f,"input",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),u.prop(f,"witness",(()=>f.redeem&&f.redeem.witness?f.redeem.witness:f.input?[]:void 0)),u.prop(f,"name",(()=>{const t=["p2sh"];return void 0!==f.redeem&&void 0!==f.redeem.name&&t.push(f.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(h().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==h().hash.length)throw new TypeError("Invalid address");e=h().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==l.OP_HASH160||20!==t.output[1]||t.output[22]!==l.OP_EQUAL)throw new TypeError("Output is invalid");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError("Empty input");if(e&&r)throw new TypeError("Input and witness provided");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError("Non push-only scriptSig")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError("Input too short");if(!n.isBuffer(d().output))throw new TypeError("Input is invalid");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(f,t)}},5501:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=void 0;const n=r(8287),i=r(622),o=r(7038),s=r(8116),a=r(916),u=r(2218),c=r(7883),l=r(2343),f=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=c.value((()=>{const e=l.bech32m.decode(t.address),r=e.words.shift(),i=l.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),h=c.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=c.value((()=>t.scriptTree?(0,u.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,y={name:"p2tr",network:d};if(c.prop(y,"address",(()=>{if(!y.pubkey)return;const t=l.bech32m.toWords(y.pubkey);return t.unshift(1),l.bech32m.encode(d.bech32,t)})),c.prop(y,"hash",(()=>{const t=p();if(t)return t.hash;const e=h();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,u.tapleafHash)({output:n,version:r});return(0,u.rootHashFromPath)(t,i)}return null})),c.prop(y,"output",(()=>{if(y.pubkey)return o.compile([f.OP_1,y.pubkey])})),c.prop(y,"redeemVersion",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:u.LEAF_VERSION_TAPSCRIPT)),c.prop(y,"redeem",(()=>{const t=h();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),c.prop(y,"pubkey",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(y.internalPubkey){const t=(0,u.tweakKey)(y.internalPubkey,y.hash);if(t)return t.x}})),c.prop(y,"internalPubkey",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=h();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),c.prop(y,"signature",(()=>{if(t.signature)return t.signature;const e=h();return e&&1===e.length?e[0]:void 0})),c.prop(y,"witness",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,u.tapleafHash)({output:t.redeem.output,version:y.redeemVersion}),i=(0,u.findScriptPath)(e,r);if(!i)return;const o=(0,u.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError("Pubkey mismatch");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,u.tweakKey)(t.internalPubkey,y.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError("Pubkey mismatch");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError("Invalid pubkey for p2tr");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&i){const e=(0,u.tapleafHash)({output:t.redeem.output,version:y.redeemVersion});if(!(0,u.findScriptPath)(i,e))throw new TypeError("Redeem script not in tree")}const c=h();if(t.redeem&&y.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(y.redeem.output&&!t.redeem.output.equals(y.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&y.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,y.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(c&&c.length)if(1===c.length){if(t.signature&&!t.signature.equals(c[0]))throw new TypeError("Signature mismatch")}else{const r=c[c.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&s.TAPLEAF_VERSION_MASK,l=c[c.length-2],f=(0,u.tapleafHash)({output:l,version:o}),h=(0,u.rootHashFromPath)(r,f),p=(0,u.tweakKey)(i,h);if(!p)throw new TypeError("Invalid outputKey for p2tr witness");if(e.length&&!e.equals(p.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(p.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(y,t)}},7027:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wpkh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(2343),l=s.OPS,f=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=c.bech32.decode(t.address),r=e.words.shift(),i=c.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),h=t.network||o.bitcoin,p={name:"p2wpkh",network:h};if(u.prop(p,"address",(()=>{if(!p.hash)return;const t=c.bech32.toWords(p.hash);return t.unshift(0),c.bech32.encode(h.bech32,t)})),u.prop(p,"hash",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),u.prop(p,"output",(()=>{if(p.hash)return s.compile([l.OP_0,p.hash])})),u.prop(p,"pubkey",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),u.prop(p,"signature",(()=>{if(t.witness)return t.witness[0]})),u.prop(p,"input",(()=>{if(p.witness)return f})),u.prop(p,"witness",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(h&&h.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==l.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}},9041:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wsh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(2343),l=s.OPS,f=n.alloc(0);function h(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=c.bech32.decode(t.address),r=e.words.shift(),i=c.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=u.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(u.prop(y,"address",(()=>{if(!y.hash)return;const t=c.bech32.toWords(y.hash);return t.unshift(0),c.bech32.encode(d.bech32,t)})),u.prop(y,"hash",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),u.prop(y,"output",(()=>{if(y.hash)return s.compile([l.OP_0,y.hash])})),u.prop(y,"redeem",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:f,witness:t.witness.slice(0,-1)}})),u.prop(y,"input",(()=>{if(y.witness)return f})),u.prop(y,"witness",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=f,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),u.prop(y,"name",(()=>{const t=["p2wsh"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==l.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.redeem.input&&!s.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&p().some(h)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(h))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(h)||(s.decompile(e)||[]).some(h))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,t)}},9646:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Psbt=void 0;const i=r(1614),o=r(394),s=r(5080),a=r(57),u=r(606),c=r(622),l=r(885),f=r(2218),h=r(7038),p=r(2021),d=r(477),y=r(4929),g={network:c.bitcoin,maximumFeeRate:5e3};class b{static fromBase64(t,e={}){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,w),n=new b(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{P(s,t)})),n}constructor(t={},e=new i.Psbt(new m)){this.data=e,this.opts=Object.assign({},g,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,u.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,u.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=b.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){_(t),this.opts.maximumFeeRate=t}setVersion(t){_(t),k(this.data.inputs,"setVersion");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){_(t),k(this.data.inputs,"setLocktime");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){_(e),k(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");(0,d.checkTaprootInputFields)(t,t,"addInput"),k(this.data.inputs,"addInput"),t.witnessScript&&Q(t.witnessScript);const e=this.__CACHE;this.data.addInput(t),P(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&j(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");k(this.data.inputs,"addOutput");const{address:e}=t;if("string"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,"addOutput");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(A))throw new Error("Not finalized");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return G(this.data.inputs,r,e,!0),r}getFeeRate(){return B("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return B("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),X(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=R){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=V(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);return(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=h.signature.decode(t.signature);if(r!==e)throw new Error("Signature sighash does not match input sighash type")}))}(e);const{finalScriptSig:a,finalScriptWitness:u}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),u&&this.data.updateInput(t,{finalScriptWitness:u}),!a&&!u)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=l.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=q(K(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(!t)return;const e=h.decompile(t);if(!e)return;const r=e[e.length-1];var i;if(n.isBuffer(r)&&!z(r)&&(i=r,!h.isCanonicalScriptSignature(i))&&h.decompile(r))return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=H(t),r=e[e.length-1];return!z(r)&&h.decompile(r)?r:void 0}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+J(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=K(r,e,n),{meaningfulScript:o}=q(i,r,"input",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=q(i,r,"output",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){return(0,s.checkForInput)(this.data.inputs,0),X(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error("No signatures for this pubkey");const s=[];let a,u,c;for(const r of o){const i=h.signature.decode(r.signature),{hash:o,script:l}=c!==i.hashType?U(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};c=i.hashType,a=o,u=l,T(r.pubkey,l,"verify"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const s=(r=r&&(0,d.toXOnly)(r))?D(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=C(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}return i.map((i=>D(t,e,r,i,n))).flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error("No signatures for this pubkey");const a=s.find((t=>!t.leafHash));let u=0;if(i&&a){if(!e(a.pubkey,a.hash,L(i)))return!1;u++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,L(t.signature)))return!1;u++}}return u>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of X(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of X(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return F(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=F(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of X(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=N(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:h.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=N(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:h.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const u=o.filter((t=>!!t.leafHash));if(u.length){const t=u.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=D(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString("hex")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&Q(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&j(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,"updateOutput"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=b;const w=t=>new m(t);class m{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");const e="string"==typeof t.hash?(0,u.reverseBuffer)(n.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function v(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error("Too many signatures");return n.length===t}function A(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function _(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function k(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error("Can not modify transaction, signatures exist.")}))}function T(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString("hex")}`)}function P(t,e){const r=(0,u.reverseBuffer)(n.from(e.hash)).toString("hex")+":"+e.index;if(t.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[r]=1}function I(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const O=I(l.p2sh,"Redeem script"),x=I(l.p2wsh,"Witness script");function B(t,e,r,n){if(!r.every(A))throw new Error(`PSBT must be finalized to calculate ${e}`);if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),G(r,i,n,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function R(t,e,r,n,i,o){const s=J(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return E(1,t.partialSig);case"multisig":const r=l.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const u=function(t,e,r){let n;switch(e){case"multisig":const e=function(t,e){return l.p2ms({output:t}).pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=l.p2ms({output:t,signatures:e});break;case"pubkey":n=l.p2pk({output:t,signature:r[0].signature});break;case"pubkeyhash":n=l.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=l.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?l.p2wsh({redeem:u}):null,f=i?l.p2sh({redeem:c||u}):null;return n?(a=c?(0,y.witnessStackToScriptWitness)(c.witness):(0,y.witnessStackToScriptWitness)(u.witness),f&&(s=f.input)):s=f?f.input:u.input,{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function N(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:u,script:c}=U(e,o,n,!1,i);return T(r,c,"sign"),{hash:a,sighashType:u}}function U(t,e,r,n,i){const o=r.__TX,s=e.sighashType||p.Transaction.SIGHASH_ALL;let a,u;if(M(s,i),e.nonWitnessUtxo){const n=V(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;u=n.outs[a]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=e.witnessUtxo}const{meaningfulScript:c,type:f}=q(u.script,t,"input",e.redeemScript,e.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)a=o.hashForWitnessV0(t,c,u.value,s);else if((0,y.isP2WPKH)(c)){const e=l.p2pkh({hash:c.slice(2)}).output;a=o.hashForWitnessV0(t,e,u.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${c.toString("hex")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),a=o.hashForSignature(t,c,s)}return{script:c,sighashType:s,hash:a}}function C(t,e,r){const{script:n}=W(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function L(t){return 64===t.length?t:t.subarray(0,64)}function D(t,e,r,i,o,s,a){const u=o.__TX,c=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(c,a);const l=r.map(((t,e)=>W(e,t,o))),h=l.map((t=>t.script)),g=l.map((t=>t.value)),b=[];if(e.tapInternalKey&&!s){const r=C(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=u.hashForWitnessV1(t,h,g,c);b.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,f.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=u.hashForWitnessV1(t,h,g,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return b.concat(w)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case p.Transaction.SIGHASH_ALL:e+="SIGHASH_ALL";break;case p.Transaction.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case p.Transaction.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function F(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e}))}function H(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}return function(){const n=r(),i=[];for(let s=0;s<n;s++)i.push((o=void 0,o=r(),e+=o,t.slice(e-o,e)));var o;return i}()}function j(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo;const n=p.Transaction.fromBuffer(e.nonWitnessUtxo);t.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=t,o=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get(){const t=i.__NON_WITNESS_UTXO_BUF_CACHE[o],e=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==t)return t;{const t=e.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=t,t}},set(t){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=t}})}function G(t,e,r,n){let i=0;t.forEach(((t,o)=>{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=H(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=V(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function V(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||j(t,e,r),n[r]}function K(t,e,r){const{script:n}=W(t,e,r);return n}function W(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=V(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function z(t){return 33===t.length&&h.isCanonicalPubKey(t)}function q(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,O(e,t,n,r),x(e,n,i,r),Q(u)):a?(u=i,x(e,t,i,r),Q(u)):o?(u=n,O(e,t,n,r)):u=t,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Q(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function J(t){return(0,y.isP2WPKH)(t)?"witnesspubkeyhash":(0,y.isP2PKH)(t)?"pubkeyhash":(0,y.isP2MS)(t)?"multisig":(0,y.isP2PK)(t)?"pubkey":"nonstandard"}function X(t){return[...Array(t).keys()]}},477:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(8116),o=r(2021),s=r(4929),a=r(2218),u=r(885),c=r(4929);function l(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function f(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function h(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error("No room left to insert tapleaf in tree");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function g(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function b(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=l,e.isTaprootOutput=f,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=l(t)&&b(e),i=b(t)&&l(e),o=t===e&&l(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every((e=>g(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&b(e),i=b(t)&&f(e),o=t===e&&f(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&h(e.leaves),{output:n}=(0,u.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error("Error adding output. Script or address missmatch.")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString("hex")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return d(t)},e.tapTreeFromList=h,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];if(t.tapKeySig&&e.push(t.tapKeySig),t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature))),!e.length){const r=function(t){if(!t)return;const e=t.slice(2);return 64===e.length||65===e.length?e:void 0}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,c.signatureBlocksAction)(t,p,e)))}},4929:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(394),o=r(7038),s=r(2021),a=r(1944),u=r(885);function c(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function l(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex((e=>"number"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function f(t,e,r){const{hashType:n}=e(t),i=[];switch(n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}e.isP2MS=c(u.p2ms),e.isP2PK=c(u.p2pk),e.isP2PKH=c(u.p2pkh),e.isP2WPKH=c(u.p2wpkh),e.isP2WSHScript=c(u.p2wsh),e.isP2SHScript=c(u.p2sh),e.isP2TR=c(u.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}var o;return r((o=t).length),o.forEach((function(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)})),e},e.pubkeyPositionInScript=l,e.pubkeyInScript=function(t,e){return-1!==l(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>f(t,o.signature.decode,e)))},e.signatureBlocksAction=f},4344:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8417);function i(t){return t<n.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}e.encodingLength=i,e.encode=function(t,e,r){const o=i(e);return 1===o?t.writeUInt8(e,r):2===o?(t.writeUInt8(n.OPS.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===o?(t.writeUInt8(n.OPS.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(n.OPS.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),o},e.decode=function(t,e){const r=t.readUInt8(e);let i,o;if(r<n.OPS.OP_PUSHDATA1)i=r,o=1;else if(r===n.OPS.OP_PUSHDATA1){if(e+2>t.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},7038:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(3966),o=r(8417);Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return o.OPS}});const s=r(4344),a=r(9464),u=r(1043),c=r(8116),{typeforce:l}=c,f=o.OPS.OP_RESERVED;function h(t){return c.Buffer(t)||function(t){return c.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function p(t){return c.Array(t)&&t.every(h)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function g(t){return n.isBuffer(t)}function b(t){if(y(t))return t;l(c.Array,t);const e=t.reduce(((t,e)=>g(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(g(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error("Could not decode chunks");return r}function w(t){if(e=t,c.Array(e))return t;var e;l(c.Buffer,t);const r=[];let n=0;for(;n<t.length;){const e=t[n];if(e>o.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function m(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(h).length},e.compile=b,e.decompile=w,e.toASM=function(t){return y(t)&&(t=w(t)),t.map((t=>{if(g(t)){const e=d(t);if(void 0===e)return t.toString("hex");t=e}return o.REVERSE_OPS[t]})).join(" ")},e.fromASM=function(t){return l(c.String,t),b(t.split(" ").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(l(c.Hex,t),n.from(t,"hex")))))},e.toStack=function(t){return t=w(t),l(p,t),t.map((t=>g(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-f)))},e.isCanonicalPubKey=function(t){return c.isPoint(t)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&!!m(t[t.length-1])&&i.check(t.slice(0,-1))},e.number=a,e.signature=u},9464:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e<n;++e)i|=t[e]<<8*e;return 128&t[n-1]?-(i&~(128<<8*(n-1))):i},e.encode=function(t){let e=Math.abs(t);const r=(i=e)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=n.allocUnsafe(r),s=t<0;for(let t=0;t<r;++t)o.writeUInt8(255&e,t),e>>=8;return 128&o[r-1]?o.writeUInt8(s?128:0,r-1):s&&(o[r-1]|=128),o}},1043:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0;const i=r(3966),o=r(8116),{typeforce:s}=o,a=n.alloc(1,0);function u(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function c(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);const o=i.decode(t.slice(0,-1)),s=c(o.r),a=c(o.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){s({signature:o.BufferN(64),hashType:o.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const c=u(t.slice(0,32)),l=u(t.slice(32,64));return n.concat([i.encode(c,l),a])}},2021:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Transaction=void 0;const i=r(606),o=r(1944),s=r(7038),a=r(7038),u=r(8116),{typeforce:c}=u;function l(t){const e=t.length;return i.varuint.encodingLength(e)+e}const f=n.allocUnsafe(0),h=[],p=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),g={script:f,valueBuffer:y};class b{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new b;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===b.ADVANCED_TRANSACTION_MARKER&&s===b.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const u=r.readVarInt();for(let t=0;t<u;++t)n.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:h});const c=r.readVarInt();for(let t=0;t<c;++t)n.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(a){for(let t=0;t<u;++t)n.ins[t].witness=r.readVector();if(!n.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(n.locktime=r.readUInt32(),e)return n;if(r.offset!==t.length)throw new Error("Transaction has unexpected data");return n}static fromHex(t){return b.fromBuffer(n.from(t,"hex"),!1)}static isCoinbaseHash(t){c(u.Hash256bit,t);for(let e=0;e<32;++e)if(0!==t[e])return!1;return!0}isCoinbase(){return 1===this.ins.length&&b.isCoinbaseHash(this.ins[0].hash)}addInput(t,e,r,n){return c(u.tuple(u.Hash256bit,u.UInt32,u.maybe(u.UInt32),u.maybe(u.Buffer)),arguments),u.Null(r)&&(r=b.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:e,script:n||f,sequence:r,witness:h})-1}addOutput(t,e){return c(u.tuple(u.Buffer,u.Satoshi),arguments),this.outs.push({script:t,value:e})-1}hasWitnesses(){return this.ins.some((t=>0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+l(e.script)),0)+this.outs.reduce(((t,e)=>t+8+l(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+l(e)),0)}(e.witness)),0):0)}clone(){const t=new b;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(c(u.tuple(u.UInt32,u.Buffer,u.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),l=this.clone();if((31&r)===b.SIGHASH_NONE)l.outs=[],l.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===b.SIGHASH_SINGLE){if(t>=this.outs.length)return d;l.outs.length=t+1;for(let e=0;e<t;e++)l.outs[e]=g;l.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}))}r&b.SIGHASH_ANYONECANPAY?(l.ins=[l.ins[t]],l.ins[0].script=i):(l.ins.forEach((t=>{t.script=f})),l.ins[t].script=i);const h=n.allocUnsafe(l.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),l.__toBuffer(h,0,!1),o.hash256(h)}hashForWitnessV1(t,e,r,s,a,h){if(c(u.tuple(u.UInt32,c.arrayOf(u.Buffer),c.arrayOf(u.Satoshi),u.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const p=s===b.SIGHASH_DEFAULT?b.SIGHASH_ALL:s&b.SIGHASH_OUTPUT_MASK,d=(s&b.SIGHASH_INPUT_MASK)===b.SIGHASH_ANYONECANPAY,y=p===b.SIGHASH_NONE,g=p===b.SIGHASH_SINGLE;let w=f,m=f,v=f,E=f,A=f;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),w=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(l).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||g){if(g&&t<this.outs.length){const e=this.outs[t],r=i.BufferWriter.withCapacity(8+l(e.script));r.writeUInt64(e.value),r.writeVarSlice(e.script),A=o.sha256(r.end())}}else{const t=this.outs.map((t=>8+l(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),A=o.sha256(e.end())}const S=(a?2:0)+(h?1:0),_=174-(d?49:0)-(y?32:0)+(h?32:0)+(a?37:0),k=i.BufferWriter.withCapacity(_);if(k.writeUInt8(s),k.writeInt32(this.version),k.writeUInt32(this.locktime),k.writeSlice(w),k.writeSlice(m),k.writeSlice(v),k.writeSlice(E),y||g||k.writeSlice(A),k.writeUInt8(S),d){const n=this.ins[t];k.writeSlice(n.hash),k.writeUInt32(n.index),k.writeUInt64(r[t]),k.writeVarSlice(e[t]),k.writeUInt32(n.sequence)}else k.writeUInt32(t);if(h){const t=i.BufferWriter.withCapacity(l(h));t.writeVarSlice(h),k.writeSlice(o.sha256(t.end()))}return g&&k.writeSlice(A),a&&(k.writeSlice(a),k.writeUInt8(0),k.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),k.end()]))}hashForWitnessV0(t,e,r,s){c(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let a,f=n.from([]),h=p,d=p,y=p;if(s&b.SIGHASH_ANYONECANPAY||(f=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(f,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(f)),s&b.SIGHASH_ANYONECANPAY||(31&s)===b.SIGHASH_SINGLE||(31&s)===b.SIGHASH_NONE||(f=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(f,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(f)),(31&s)!==b.SIGHASH_SINGLE&&(31&s)!==b.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+l(e.script)),0);f=n.allocUnsafe(t),a=new i.BufferWriter(f,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),h=o.hash256(f)}else if((31&s)===b.SIGHASH_SINGLE&&t<this.outs.length){const e=this.outs[t];f=n.allocUnsafe(8+l(e.script)),a=new i.BufferWriter(f,0),a.writeUInt64(e.value),a.writeVarSlice(e.script),h=o.hash256(f)}f=n.allocUnsafe(156+l(e)),a=new i.BufferWriter(f,0);const g=this.ins[t];return a.writeInt32(this.version),a.writeSlice(d),a.writeSlice(y),a.writeSlice(g.hash),a.writeUInt32(g.index),a.writeVarSlice(e),a.writeUInt64(r),a.writeUInt32(g.sequence),a.writeSlice(h),a.writeUInt32(this.locktime),a.writeUInt32(s),o.hash256(f)}getHash(t){return t&&this.isCoinbase()?n.alloc(32,0):o.hash256(this.__toBuffer(void 0,void 0,t))}getId(){return(0,i.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(t,e){return this.__toBuffer(t,e,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(t,e){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[t].script=e}setWitness(t,e){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[t].witness=e}__toBuffer(t,e,r=!1){t||(t=n.allocUnsafe(this.byteLength(r)));const o=new i.BufferWriter(t,e||0);o.writeInt32(this.version);const s=r&&this.hasWitnesses();return s&&(o.writeUInt8(b.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(b.ADVANCED_TRANSACTION_FLAG)),o.writeVarInt(this.ins.length),this.ins.forEach((t=>{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=b,b.DEFAULT_SEQUENCE=4294967295,b.SIGHASH_DEFAULT=0,b.SIGHASH_ALL=1,b.SIGHASH_NONE=2,b.SIGHASH_SINGLE=3,b.SIGHASH_ANYONECANPAY=128,b.SIGHASH_OUTPUT_MASK=3,b.SIGHASH_INPUT_MASK=128,b.ADVANCED_TRANSACTION_MARKER=0,b.ADVANCED_TRANSACTION_FLAG=1},8116:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(8287);e.typeforce=r(8676);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&!(s.compare(o)>=0)&&4===e&&65===t.length};const s=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function u(t){return!(!t||!("output"in t)||!n.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&e.TAPLEAF_VERSION_MASK)!==t.version)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=s},e.BIP32Path=a,a.toJSON=()=>"BIP32 derivation path",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign},e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike("Point"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=u,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):u(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},6763:(t,e,r)=>{const n=r(5364);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},9204:(t,e,r)=>{var n=r(6763);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},1889:(t,e,r)=>{var{sha256:n}=r(2623),i=r(9204);t.exports=i((function(t){return n(n(t))}))},8287:(t,e,r)=>{const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||X(t.length)?a(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),a(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(i)return n?-1:z(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),X(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(X(n))return s;t[r+s]=n}return s}function E(t,e,r,n){return Q(z(e,t.length-r),t,r,n)}function A(t,e,r,n){return Q(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function S(t,e,r,n){return Q(q(e),t,r,n)}function _(t,e,r,n){return Q(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=P)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=P));return r}(n)}e.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},u.allocUnsafe=function(t){return f(t)},u.allocUnsafeSlow=function(t){return f(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(J(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.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 e=0;e<t;e+=2)b(this,e,e+1);return this},u.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 e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},u.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 e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),c=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<a;++t)if(c[t]!==l[t]){o=c[t],s=l[t];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return A(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const P=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Y[t[n]];return i}function B(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function U(t,e,r,n,i){G(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function C(t,e,r,n,i){G(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};const F={};function H(t,e,r){F[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function j(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}H("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),H("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),H("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=j(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=j(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function z(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Q(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function X(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Z(t){return"undefined"==typeof BigInt?$:t}function $(){throw new Error("BigInt not supported")}},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(3141).I;function s(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(s,i),s.prototype.update=function(t,e,r){"string"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),s=r(2802),a=r(6168);function u(t){a.call(this,"digest"),this._hash=t}n(u,a),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(s(t))}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},5170:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),s=r(3209),a=r(7513),u=r(709),c=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(c,r),new l(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new l(void 0,e,r)}(0,u.testEcc)(t);class l{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error("Unknown network version")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(c,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},8700:(t,e,r)=>{e.dg=void 0;var n=r(5170);Object.defineProperty(e,"dg",{enumerable:!0,get:function(){return n.ECPairFactory}})},5249:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(8676),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},7007:t=>{var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var i,o,s,c;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=u(t))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,c=l,console&&console.warn&&console.warn(c)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function h(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,l=d(u,c);for(r=0;r<c;++r)n(l[r],this,e)}return!0},o.prototype.addListener=function(t,e){return c(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return c(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,f(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,f(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,s;if(a(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},4729:(t,e,r)=>{var n=r(7417).Buffer,i=r(1603).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t,e){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)r[this._blockOffset++]=t[i++];for(var s=0,a=8*t.length;a>0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},2260:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,s,a,u;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(a=t).length||-1===a.indexOf(".",u)?"argument":"property");s='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2818:(t,e,r)=>{var n=r(3184),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=l;var o=r(6736),s=r(2192);r(6698)(l,o);for(var a=i(s.prototype),u=0;u<a.length;u++){var c=a[u];l.prototype[c]||(l.prototype[c]=s.prototype[c])}function l(t){if(!(this instanceof l))return new l(t);o.call(this,t),s.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",f)))}function f(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},5860:(t,e,r)=>{t.exports=i;var n=r(3054);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6736:(t,e,r)=>{var n,i=r(3184);t.exports=k,k.ReadableState=_,r(7007).EventEmitter;var o,s=function(t,e){return t.listeners(e).length},a=r(1181),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(2382);o=l&&l.debuglog?l.debuglog("stream"):function(){};var f,h,p,d=r(2389),y=r(1468),g=r(8775).getHighWaterMark,b=r(2260).F,w=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,E=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(k,a);var A=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function _(t,e,i){n=n||r(2818),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(3141).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function k(t){if(n=n||r(2818),!(this instanceof k))return new k(t);var e=this instanceof n;this._readableState=new _(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var s,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,a);else if(i||(s=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new w("chunk",["string","Buffer","Uint8Array"],e)),r}(a,e)),s)A(t,s);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)a.endEmitted?A(t,new E):P(t,a,e,!0);else if(a.ended)A(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(e=a.decoder.write(e),a.objectMode||0!==e.length?P(t,a,e,!1):R(t,a)):P(t,a,e,!1)}else n||(a.reading=!1,R(t,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function P(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),k.prototype.destroy=y.destroy,k.prototype._undestroy=y.undestroy,k.prototype._destroy=function(t,e){e(t)},k.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},k.prototype.unshift=function(t){return T(this,t,null,!0,!1)},k.prototype.isPaused=function(){return!1===this._readableState.flowing},k.prototype.setEncoding=function(t){f||(f=r(3141).I);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function O(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,D(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function U(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function C(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),D(t),e.flowing&&!e.reading&&t.read(0)}function D(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function M(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function F(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function j(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}k.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):x(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&F(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=O(r,e))),null===(n=t>0?M(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&F(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){A(this,new v("_read()"))},k.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){o("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",f),l=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,D(t))}}(r);t.on("drain",c);var l=!1;function f(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==j(n.pipes,t))&&!l&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===s(t,"error")&&A(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",f),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=j(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},k.prototype.on=function(t,e){var r=a.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(C,this))),r},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(U,this),r},k.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(U,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var s=0;s<S.length;s++)t.on(S[s],this.emit.bind(this,S[s]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(k.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),k._fromList=M,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(k.from=function(t,e){return void 0===p&&(p=r(5049)),p(k,t,e)})},3054:(t,e,r)=>{t.exports=l;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(2818);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(t){if(!(this instanceof l))return new l(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new s;return t.push(null)}r(6698)(l,u),l.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},l.prototype._transform=function(t,e,r){r(new i("_transform()"))},l.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},l.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},2192:(t,e,r)=>{var n,i=r(3184);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(undefined),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=k,k.WritableState=_;var s,a={deprecate:r(4643)},u=r(1181),c=r(8287).Buffer,l=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,E=p.ERR_UNKNOWN_ENCODING,A=f.errorOrDestroy;function S(){}function _(t,e,s){n=n||r(2818),t=t||{},"boolean"!=typeof s&&(s=e instanceof n),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,A(t,n)):(o(n),t._writableState.errorEmitted=!0,A(t,n),B(t,e))}(t,r,n,e,o);else{var s=O(r)||t.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(P,t,r,s,o):P(t,r,s,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function k(t){var e=this instanceof(n=n||r(2818));if(!e&&!s.call(k,this))return new k(t);this._writableState=new _(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new w("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function P(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final((function(r){e.pendingcb--,r&&A(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)}))}function B(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(k,u),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===k&&t&&t._writableState instanceof _}})):s=function(t){return t instanceof this},k.prototype.pipe=function(){A(this,new b)},k.prototype.write=function(t,e,r){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof l);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new v;A(t,r),i.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var o;return null===r?o=new m:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(A(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,a,n,i,o);return u}(this,o,a,t,e,r)),s},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},k.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new E(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new y("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}},4743:(t,e,r)=>{var n,i=r(3184);function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=r(5826),a=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var r=t[p].read();null!==r&&(t[f]=null,t[a]=null,t[u]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),w=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[l])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[l]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,l,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[f]=null,r[a]=null,r[u]=null,t(d(n,!1))):(r[a]=t,r[u]=e)},writable:!0}),e));return r[f]=null,s(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[f]=null,r[a]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[a];null!==n&&(r[f]=null,r[a]=null,r[u]=null,n(d(void 0,!0))),r[l]=!0})),t.on("readable",g.bind(null,r)),r}},2389:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=a(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}function a(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(8460).inspect,l=c&&c.custom||"inspect";t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,(r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e,r,n,i=u.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,u.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:l,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}])&&s(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1468:(t,e,r)=>{var n=r(3184);function i(t,e){s(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(s,this,t)):n.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},5826:(t,e,r)=>{var n=r(2260).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var s=r.readable||!1!==r.readable&&e.readable,a=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||l()},c=e._writableState&&e._writableState.finished,l=function(){a=!1,c=!0,s||o.call(e)},f=e._readableState&&e._readableState.endEmitted,h=function(){s=!1,f=!0,a||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return s&&!f?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):a&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",l)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",l),e.on("abort",d),e.req?y():e.on("request",y)):a&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",l),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",l),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},5049:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9434:(t,e,r)=>{var n,i=r(2260).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var l,f=function(t){return t.length?"function"!=typeof t[t.length-1]?a:t.pop():a}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var a=!1;t.on("close",(function(){a=!0})),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);a=!0,o()}));var u=!1;return function(e){if(!a&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new s("pipe"))}}(t,o,i>0,(function(t){l||(l=t),t&&h.forEach(u),o||(h.forEach(u),f(l))}))}));return e.reduce(c)}},8775:(t,e,r)=>{var n=r(2260).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1181:(t,e,r)=>{t.exports=r(7007).EventEmitter},1603:(t,e,r)=>{(e=t.exports=r(6736)).Stream=e,e.Readable=e,e.Writable=r(2192),e.Duplex=r(2818),e.Transform=r(3054),e.PassThrough=r(5860),e.finished=r(5826),e.pipeline=r(9434)},7417:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*y}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3209:(t,e,r)=>{var n=r(3184),i=65536,o=r(2861).Buffer,s=r.g.crypto||r.g.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;a<t;a+=i)s.getRandomValues(r.slice(a,a+i));else s.getRandomValues(r);return"function"==typeof e?n.nextTick((function(){e(null,r)})):r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},6011:(t,e,r)=>{var n=r(8287).Buffer,i=r(6698),o=r(4729),s=new Array(16),a=[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],u=[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],c=[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],l=[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],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<<e|t>>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,v=0|this._a,E=0|this._b,A=0|this._c,S=0|this._d,_=0|this._e,k=0;k<80;k+=1){var T,P;k<16?(T=y(r,n,i,o,p,t[a[k]],f[0],c[k]),P=m(v,E,A,S,_,t[u[k]],h[0],l[k])):k<32?(T=g(r,n,i,o,p,t[a[k]],f[1],c[k]),P=w(v,E,A,S,_,t[u[k]],h[1],l[k])):k<48?(T=b(r,n,i,o,p,t[a[k]],f[2],c[k]),P=b(v,E,A,S,_,t[u[k]],h[2],l[k])):k<64?(T=w(r,n,i,o,p,t[a[k]],f[3],c[k]),P=g(v,E,A,S,_,t[u[k]],h[3],l[k])):(T=m(r,n,i,o,p,t[a[k]],f[4],c[k]),P=y(v,E,A,S,_,t[u[k]],h[4],l[k])),r=p,p=o,o=d(i,10),i=n,n=T,v=_,_=S,S=d(A,10),A=E,E=P}var I=this._b+i+S|0;this._b=this._c+o+_|0,this._c=this._d+p+v|0,this._d=this._e+r+E|0,this._e=this._a+n+A|0,this._a=I},p.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 t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},392:(t,e,r)=>{var n=r(2861).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a<o;){for(var u=s%i,c=Math.min(o-a,i-u),l=0;l<c;l++)r[u+l]=t[a+l];a+=c,(s+=c)%i==0&&this._update(r)}return this._len+=o,this},i.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},2802:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};n.sha=r(7816),n.sha1=r(3737),n.sha224=r(6710),n.sha256=r(4107),n.sha384=r(2827),n.sha512=r(2890)},7816:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=t.readInt32BE(4*f);for(;f<80;++f)r[f]=r[f-3]^r[f-8]^r[f-14]^r[f-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+l(p,i,o,a)+u+r[h]+s[p];u=a,a=o,o=c(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},3737:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=(e=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=c(n)+f(d,i,o,a)+u+r[p]+s[d]|0;u=a,a=o,o=l(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},6710:(t,e,r)=>{var n=r(6698),i=r(4107),o=r(392),s=r(2861).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}n(u,i),u.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},u.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},4107:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[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],a=new Array(64);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(u,i),u.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},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,d=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var w=0;w<64;++w){var m=g+h(u)+c(u,d,y)+s[w]+r[w]|0,v=f(n)+l(n,i,o)|0;g=y,y=d,d=u,u=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},2827:(t,e,r)=>{var n=r(6698),i=r(2890),o=r(392),s=r(2861).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}n(u,i),u.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},u.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},2890:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[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],a=new Array(160);function u(){this.init(),this._w=a,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0<e>>>0?1:0}n(u,i),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,u=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,E=0|this._bl,A=0|this._cl,S=0|this._dl,_=0|this._el,k=0|this._fl,T=0|this._gl,P=0|this._hl,I=0;I<32;I+=2)e[I]=t.readInt32BE(4*I),e[I+1]=t.readInt32BE(4*I+4);for(;I<160;I+=2){var O=e[I-30],x=e[I-30+1],B=p(O,x),R=d(x,O),N=y(O=e[I-4],x=e[I-4+1]),U=g(x,O),C=e[I-14],L=e[I-14+1],D=e[I-32],M=e[I-32+1],F=R+L|0,H=B+C+b(F,R)|0;H=(H=H+N+b(F=F+U|0,U)|0)+D+b(F=F+M|0,M)|0,e[I]=H,e[I+1]=F}for(var j=0;j<160;j+=2){H=e[j],F=e[j+1];var G=l(r,n,i),V=l(v,E,A),K=f(r,v),W=f(v,r),z=h(a,_),q=h(_,a),Q=s[j],J=s[j+1],X=c(a,u,w),Y=c(_,k,T),Z=P+q|0,$=m+z+b(Z,P)|0;$=($=($=$+X+b(Z=Z+Y|0,Y)|0)+Q+b(Z=Z+J|0,J)|0)+H+b(Z=Z+F|0,F)|0;var tt=W+V|0,et=K+G+b(tt,W)|0;m=w,P=T,w=u,T=k,u=a,k=_,a=o+$+b(_=S+Z|0,S)|0,o=i,S=A,i=n,A=E,n=r,E=v,r=$+et+b(v=Z+tt|0,Z)|0}this._al=this._al+v|0,this._bl=this._bl+E|0,this._cl=this._cl+A|0,this._dl=this._dl+S|0,this._el=this._el+_|0,this._fl=this._fl+k|0,this._gl=this._gl+T|0,this._hl=this._hl+P|0,this._ah=this._ah+r+b(this._al,v)|0,this._bh=this._bh+n+b(this._bl,E)|0,this._ch=this._ch+i+b(this._cl,A)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,_)|0,this._fh=this._fh+u+b(this._fl,k)|0,this._gh=this._gh+w+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,P)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},8310:(t,e,r)=>{t.exports=i;var n=r(7007).EventEmitter;function i(){n.call(this)}r(6698)(i,n),i.Readable=r(6891),i.Writable=r(1999),i.Duplex=r(8101),i.Transform=r(9083),i.PassThrough=r(3681),i.finished=r(4257),i.pipeline=r(5267),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),t.removeListener("close",l)}return r.on("error",c),t.on("error",c),r.on("end",l),r.on("close",l),t.on("close",l),t.emit("pipe",r),t}},2463:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,s,a,u;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(a=t).length||-1===a.indexOf(".",u)?"argument":"property");s='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},8101:(t,e,r)=>{var n=r(3184),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=l;var o=r(6891),s=r(1999);r(6698)(l,o);for(var a=i(s.prototype),u=0;u<a.length;u++){var c=a[u];l.prototype[c]||(l.prototype[c]=s.prototype[c])}function l(t){if(!(this instanceof l))return new l(t);o.call(this,t),s.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",f)))}function f(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},3681:(t,e,r)=>{t.exports=i;var n=r(9083);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6891:(t,e,r)=>{var n,i=r(3184);t.exports=k,k.ReadableState=_,r(7007).EventEmitter;var o,s=function(t,e){return t.listeners(e).length},a=r(1396),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(7199);o=l&&l.debuglog?l.debuglog("stream"):function(){};var f,h,p,d=r(1766),y=r(4347),g=r(6644).getHighWaterMark,b=r(2463).F,w=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,E=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(k,a);var A=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function _(t,e,i){n=n||r(8101),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(3141).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function k(t){if(n=n||r(8101),!(this instanceof k))return new k(t);var e=this instanceof n;this._readableState=new _(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var s,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,a);else if(i||(s=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new w("chunk",["string","Buffer","Uint8Array"],e)),r}(a,e)),s)A(t,s);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)a.endEmitted?A(t,new E):P(t,a,e,!0);else if(a.ended)A(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(e=a.decoder.write(e),a.objectMode||0!==e.length?P(t,a,e,!1):R(t,a)):P(t,a,e,!1)}else n||(a.reading=!1,R(t,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function P(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),k.prototype.destroy=y.destroy,k.prototype._undestroy=y.undestroy,k.prototype._destroy=function(t,e){e(t)},k.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},k.prototype.unshift=function(t){return T(this,t,null,!0,!1)},k.prototype.isPaused=function(){return!1===this._readableState.flowing},k.prototype.setEncoding=function(t){f||(f=r(3141).I);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function O(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,D(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function U(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function C(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),D(t),e.flowing&&!e.reading&&t.read(0)}function D(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function M(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function F(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function j(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}k.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):x(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&F(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=O(r,e))),null===(n=t>0?M(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&F(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){A(this,new v("_read()"))},k.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){o("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",f),l=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,D(t))}}(r);t.on("drain",c);var l=!1;function f(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==j(n.pipes,t))&&!l&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===s(t,"error")&&A(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",f),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=j(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},k.prototype.on=function(t,e){var r=a.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(C,this))),r},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(U,this),r},k.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(U,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var s=0;s<S.length;s++)t.on(S[s],this.emit.bind(this,S[s]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(k.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),k._fromList=M,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(k.from=function(t,e){return void 0===p&&(p=r(968)),p(k,t,e)})},9083:(t,e,r)=>{t.exports=l;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(8101);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(t){if(!(this instanceof l))return new l(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new s;return t.push(null)}r(6698)(l,u),l.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},l.prototype._transform=function(t,e,r){r(new i("_transform()"))},l.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},l.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},1999:(t,e,r)=>{var n,i=r(3184);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(undefined),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=k,k.WritableState=_;var s,a={deprecate:r(4643)},u=r(1396),c=r(8287).Buffer,l=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,E=p.ERR_UNKNOWN_ENCODING,A=f.errorOrDestroy;function S(){}function _(t,e,s){n=n||r(8101),t=t||{},"boolean"!=typeof s&&(s=e instanceof n),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,A(t,n)):(o(n),t._writableState.errorEmitted=!0,A(t,n),B(t,e))}(t,r,n,e,o);else{var s=O(r)||t.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(P,t,r,s,o):P(t,r,s,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function k(t){var e=this instanceof(n=n||r(8101));if(!e&&!s.call(k,this))return new k(t);this._writableState=new _(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new w("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function P(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final((function(r){e.pendingcb--,r&&A(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)}))}function B(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(k,u),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===k&&t&&t._writableState instanceof _}})):s=function(t){return t instanceof this},k.prototype.pipe=function(){A(this,new b)},k.prototype.write=function(t,e,r){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof l);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new v;A(t,r),i.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var o;return null===r?o=new m:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(A(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,a,n,i,o);return u}(this,o,a,t,e,r)),s},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},k.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new E(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new y("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}},5034:(t,e,r)=>{var n,i=r(3184);function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=r(4257),a=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var r=t[p].read();null!==r&&(t[f]=null,t[a]=null,t[u]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),w=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[l])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[l]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,l,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[f]=null,r[a]=null,r[u]=null,t(d(n,!1))):(r[a]=t,r[u]=e)},writable:!0}),e));return r[f]=null,s(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[f]=null,r[a]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[a];null!==n&&(r[f]=null,r[a]=null,r[u]=null,n(d(void 0,!0))),r[l]=!0})),t.on("readable",g.bind(null,r)),r}},1766:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=a(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}function a(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(3779).inspect,l=c&&c.custom||"inspect";t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,(r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e,r,n,i=u.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,u.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:l,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}])&&s(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4347:(t,e,r)=>{var n=r(3184);function i(t,e){s(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(s,this,t)):n.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4257:(t,e,r)=>{var n=r(2463).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var s=r.readable||!1!==r.readable&&e.readable,a=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||l()},c=e._writableState&&e._writableState.finished,l=function(){a=!1,c=!0,s||o.call(e)},f=e._readableState&&e._readableState.endEmitted,h=function(){s=!1,f=!0,a||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return s&&!f?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):a&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",l)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",l),e.on("abort",d),e.req?y():e.on("request",y)):a&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",l),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",l),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},968:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},5267:(t,e,r)=>{var n,i=r(2463).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var l,f=function(t){return t.length?"function"!=typeof t[t.length-1]?a:t.pop():a}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var a=!1;t.on("close",(function(){a=!0})),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);a=!0,o()}));var u=!1;return function(e){if(!a&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new s("pipe"))}}(t,o,i>0,(function(t){l||(l=t),t&&h.forEach(u),o||(h.forEach(u),f(l))}))}));return e.reduce(c)}},6644:(t,e,r)=>{var n=r(2463).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1396:(t,e,r)=>{t.exports=r(7007).EventEmitter},3141:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.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 o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){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 t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=f,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function l(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=s(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=s(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=s(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),s(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function l(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',s(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,l.prototype=Object.create(Error.prototype),l.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:l,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof l?(e=e+"."+t.__property,t=new l(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new l(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function s(t){return n.isBuffer(t)}function a(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),l=u.bind(null,s),f=u.bind(null,a),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:s,BufferN:l,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:a,HexN:f,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},8676:(t,e,r)=>{var n=r(1061),i=r(2113),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,l={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}}))}return t=f(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=f(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];h(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=f(t),e&&(e=f(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=f(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(f);function e(e,r){return t.some((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(f);function e(e,r){return t.every((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(f);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function f(t){if(i.String(t))return"?"===t[0]?l.maybe(t.slice(1)):i[t]||l.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return l.arrayOf(t[0])}return l.object(t)}return i.Function(t)?t:l.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return h(f(t),e,r)}for(var p in l.oneOf=l.anyOf,i)h[p]=i[p];for(p in l)h[p]=l[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=f,h.TfTypeError=s,h.TfPropertyTypeError=a,t.exports=h},2113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},4643:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},8469:(t,e,r)=>{var n=r(2861).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},7513:(t,e,r)=>{var n=r(8287).Buffer,i=r(7701);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},1448:(t,e,r)=>{var n=r(2861).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(255!==e[s])throw new TypeError(o+" is ambiguous");e[s]=i}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===u;)i++,r++;for(var s=(t.length-r)*c+1>>>0,l=new Uint8Array(s);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,p=s-1;(0!==f||h<o)&&-1!==p;p--,h++)f+=a*l[p]>>>0,l[p]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,r++}for(var d=s-o;d!==s&&0===l[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=l[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*l+1>>>0,f=new Uint8Array(c);o!==s;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*f[d]>>>0,f[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===f[y];)y++;for(var g=u.repeat(r);y<c;++y)g+=t.charAt(f[y]);return g},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},3119:(t,e,r)=>{var n=r(1448);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8016:(t,e,r)=>{var n=r(3119),i=r(2861).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7701:(t,e,r)=>{var n=r(7108),i=r(8016);t.exports=i((function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}))},3184:t=>{var e,r,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var a,u=[],c=!1,l=-1;function f(){c&&a&&(c=!1,a.length?u=a.concat(u):l=-1,u.length&&h())}function h(){if(!c){var t=s(f);c=!0;for(var e=u.length;e;){for(a=u,u=[];++l<e;)a&&a[l].run();l=-1,e=u.length}a=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function d(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new p(t,e)),1!==u.length||c||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},4923:()=>{},8460:()=>{},2382:()=>{},3779:()=>{},7199:()=>{}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&n&&r;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((t=>s[t]=()=>r[t]));return s.default=()=>r,i.d(o,s),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{i.d(o,{y3:()=>Wc,Lk:()=>Wl,Uq:()=>Gf,EI:()=>bf,JL:()=>Oh,M7:()=>Af,G7:()=>ph,eB:()=>ll,Q9:()=>bl,rO:()=>_l,qT:()=>U,Yy:()=>H,JV:()=>jf,Bc:()=>J,r:()=>tf,W4:()=>r,rs:()=>xl,OB:()=>k,PN:()=>f,Mw:()=>w,GE:()=>il,z5:()=>Dl,XV:()=>$c,Wj:()=>wf,PF:()=>Vf,$7:()=>e,rE:()=>n});var t={};i.r(t),i.d(t,{OG:()=>ha,My:()=>na,bytesToNumberBE:()=>sa,lX:()=>aa,Id:()=>fa,fg:()=>ya,qj:()=>la,hexToBytes:()=>oa,lq:()=>ua,z:()=>ca,Q5:()=>ba});var e={};i.r(e),i.d(e,{ABIDataTypes:()=>Wc,AbstractRpcProvider:()=>Wl,BaseContract:()=>Gf,BitcoinAbiTypes:()=>bf,BitcoinAddress:()=>Oh,BitcoinInterface:()=>Af,BitcoinUtils:()=>ph,Block:()=>ll,CallResult:()=>bl,ContractData:()=>_l,DeploymentTransaction:()=>U,GenericTransaction:()=>H,IBaseContract:()=>jf,InteractionTransaction:()=>J,JSONRpcProvider:()=>tf,OPNetTransactionTypes:()=>r,StoredValue:()=>xl,TransactionBase:()=>k,TransactionInput:()=>f,TransactionOutput:()=>w,TransactionParser:()=>il,TransactionReceipt:()=>Dl,UTXO:()=>$c,WebSocketRpcProvider:()=>wf,getContract:()=>Vf,version:()=>n});var r,n="1.0.15";function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function u(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t){var e=function(t,e){if("object"!=s(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(e)?e:e+""}!function(t){t.Generic="Generic",t.Deployment="Deployment",t.Interaction="Interaction"}(r||(r={}));var f=u((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,"originalTransactionId",void 0),c(this,"outputTransactionIndex",void 0),c(this,"scriptSignature",void 0),c(this,"sequenceId",void 0),c(this,"transactionInWitness",[]),this.originalTransactionId=e.originalTransactionId,this.outputTransactionIndex=e.outputTransactionIndex,this.scriptSignature=e.scriptSignature,this.sequenceId=e.sequenceId,this.transactionInWitness=e.transactionInWitness||[]})),h=i(1757),p=i(8287).Buffer;function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,b(n.key),n)}}function g(t,e,r){return(e=b(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function b(t){var e=function(t,e){if("object"!=d(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==d(e)?e:e+""}var w=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),g(this,"value",void 0),g(this,"index",void 0),g(this,"scriptPubKey",void 0),g(this,"script",void 0),this.value=this.convertValue(e.value),this.index=e.index,this.scriptPubKey=e.scriptPubKey,this.script=h.K$.decompile(p.from(this.scriptPubKey.hex,"hex"))},(e=[{key:"convertValue",value:function(t){return BigInt(t)}}])&&y(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),m=i(8287).Buffer;function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function E(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}function A(t,e,r){return e&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function S(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){var e=function(t,e){if("object"!=v(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}var k=A((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),S(this,"id",void 0),S(this,"hash",void 0),S(this,"index",void 0),S(this,"burnedBitcoin",void 0),S(this,"revert",void 0),S(this,"inputs",void 0),S(this,"outputs",void 0),S(this,"OPNetType",void 0),this.id=e.id,this.hash=e.hash,this.index=e.index,this.burnedBitcoin=BigInt(e.burnedBitcoin)||0n,this.inputs=e.inputs.map((function(t){return new f(t)})),this.outputs=e.outputs.map((function(t){return new w(t)})),this.revert=e.revert?m.from(e.revert,"base64"):void 0,this.OPNetType=e.OPNetType})),T=i(8287).Buffer;function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function I(t,e,r){return e=x(e),function(t,e){if(e&&("object"===P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,O()?Reflect.construct(e,r||[],x(t).constructor):e.apply(t,r))}function O(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(O=function(){return!!t})()}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}function B(t,e){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},B(t,e)}function R(t,e,r){return(e=N(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function N(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var U=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),R(r=I(this,e,[t]),"contractAddress",void 0),R(r,"virtualAddress",void 0),R(r,"bytecode",void 0),R(r,"wasCompressed",void 0),R(r,"deployerPubKey",void 0),R(r,"deployerAddress",void 0),R(r,"contractSeed",void 0),R(r,"contractSaltHash",void 0),r.contractAddress=t.contractAddress,r.virtualAddress=t.virtualAddress,r.bytecode=T.from(t.bytecode,"base64"),r.wasCompressed=t.wasCompressed,r.deployerPubKey=T.from(t.deployerPubKey,"base64"),r.deployerAddress=t.deployerAddress,r.contractSeed=T.from(t.contractSeed,"base64"),r.contractSaltHash=T.from(t.contractSaltHash,"base64"),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&B(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(k);function C(t){return C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C(t)}function L(t,e,r){return e=M(e),function(t,e){if(e&&("object"===C(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function F(t,e){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},F(t,e)}var H=function(t){function e(t){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),L(this,e,[t])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(k),j=i(8287);function G(t){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(t)}function V(t,e,r){return e=W(e),function(t,e){if(e&&("object"===G(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,K()?Reflect.construct(e,r||[],W(t).constructor):e.apply(t,r))}function K(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(K=function(){return!!t})()}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function z(t,e){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},z(t,e)}function q(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q(t){var e=function(t,e){if("object"!=G(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}var J=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),q(r=V(this,e,[t]),"calldata",void 0),q(r,"senderPubKeyHash",void 0),q(r,"contractSecret",void 0),q(r,"interactionPubKey",void 0),q(r,"wasCompressed",void 0),q(r,"events",void 0),q(r,"receipt",void 0),q(r,"receiptProofs",void 0),r.calldata=j.Buffer.from(t.calldata,"base64"),r.senderPubKeyHash=j.Buffer.from(t.senderPubKeyHash,"base64"),r.contractSecret=j.Buffer.from(t.contractSecret,"base64"),r.interactionPubKey=j.Buffer.from(t.interactionPubKey,"base64"),r.wasCompressed=t.wasCompressed,r.events=t.events,r.receipt=t.receipt?j.Buffer.from(t.receipt,"base64"):void 0,r.receiptProofs=t.receiptProofs,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&z(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(k);const X="6.12.1";function Y(t,e,r){const n=e.split("|").map((t=>t.trim()));for(let r=0;r<n.length;r++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${r}`,i.value=t,i}async function Z(t){const e=Object.keys(t);return(await Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}function $(t,e,r){for(let n in e){let i=e[n];const o=r?r[n]:null;o&&Y(i,o,n),Object.defineProperty(t,n,{enumerable:!0,value:i,writable:!1})}}function tt(t){if(null==t)return"null";if(Array.isArray(t))return"[ "+t.map(tt).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let r="0x";for(let n=0;n<t.length;n++)r+=e[t[n]>>4],r+=e[15&t[n]];return r}if("object"==typeof t&&"function"==typeof t.toJSON)return tt(t.toJSON());switch(typeof t){case"boolean":case"symbol":case"number":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map((e=>`${tt(e)}: ${tt(t[e])}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function et(t,e){return t&&t.code===e}function rt(t){return et(t,"CALL_EXCEPTION")}function nt(t,e,r){let n,i=t;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${tt(r)}`);for(const t in r){if("shortMessage"===t)continue;const e=r[t];n.push(t+"="+tt(e))}}n.push(`code=${e}`),n.push(`version=${X}`),n.length&&(t+=" ("+n.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":n=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(t);break;default:n=new Error(t)}return $(n,{code:e}),r&&Object.assign(n,r),null==n.shortMessage&&$(n,{shortMessage:i}),n}function it(t,e,r,n){if(!t)throw nt(e,r,n)}function ot(t,e,r,n){it(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function st(t,e,r){null==r&&(r=""),r&&(r=": "+r),it(t>=e,"missing arguemnt"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),it(t<=e,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const at=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(t){}return t}),[]);function ut(t,e,r){if(null==r&&(r=""),t!==e){let t=r,e="new";r&&(t+=".",e+=" "+r),it(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function ct(t,e,r){if(t instanceof Uint8Array)return r?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x([0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let r=2;for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(r,r+2),16),r+=2;return e}ot(!1,"invalid BytesLike value",e||"value",t)}function lt(t,e){return ct(t,e,!1)}function ft(t,e){return ct(t,e,!0)}function ht(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||"number"==typeof e&&t.length!==2+2*e||!0===e&&t.length%2!=0)}function pt(t){return ht(t,!0)||t instanceof Uint8Array}const dt="0123456789abcdef";function yt(t){const e=lt(t);let r="0x";for(let t=0;t<e.length;t++){const n=e[t];r+=dt[(240&n)>>4]+dt[15&n]}return r}function gt(t){return"0x"+t.map((t=>yt(t).substring(2))).join("")}function bt(t){return ht(t,!0)?(t.length-2)/2:lt(t).length}function wt(t,e,r){const n=lt(t);return null!=r&&r>n.length&&it(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),yt(n.slice(null==e?0:e,null==r?n.length:r))}function mt(t,e,r){const n=lt(t);it(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),r?i.set(n,e-n.length):i.set(n,0),yt(i)}function vt(t,e){return mt(t,e,!0)}const Et=BigInt(0),At=BigInt(1),St=9007199254740991;function _t(t,e){let r=Tt(t,"value");const n=BigInt(xt(e,"width")),i=At<<n-At;return r<Et?(r=-r,it(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),(~r&(At<<n)-At)+At):(it(r<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),r)}function kt(t,e){const r=Pt(t,"value"),n=BigInt(xt(e,"bits"));return r&(At<<n)-At}function Tt(t,e){switch(typeof t){case"bigint":return t;case"number":return ot(Number.isInteger(t),"underflow",e||"value",t),ot(t>=-St&&t<=St,"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(r){ot(!1,`invalid BigNumberish string: ${r.message}`,e||"value",t)}}ot(!1,"invalid BigNumberish value",e||"value",t)}function Pt(t,e){const r=Tt(t,e);return it(r>=Et,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),r}const It="0123456789abcdef";function Ot(t){if(t instanceof Uint8Array){let e="0x0";for(const r of t)e+=It[r>>4],e+=It[15&r];return BigInt(e)}return Tt(t)}function xt(t,e){switch(typeof t){case"bigint":return ot(t>=-St&&t<=St,"overflow",e||"value",t),Number(t);case"number":return ot(Number.isInteger(t),"underflow",e||"value",t),ot(t>=-St&&t<=St,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return xt(BigInt(t),e)}catch(r){ot(!1,`invalid numeric string: ${r.message}`,e||"value",t)}}ot(!1,"invalid numeric value",e||"value",t)}function Bt(t,e){let r=Pt(t,"value").toString(16);if(null==e)r.length%2&&(r="0"+r);else{const n=xt(e,"width");for(it(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*n;)r="0"+r}return"0x"+r}function Rt(t){const e=Pt(t,"value");if(e===Et)return new Uint8Array([]);let r=e.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let t=0;t<n.length;t++){const e=2*t;n[t]=parseInt(r.substring(e,e+2),16)}return n}function Nt(t){let e=yt(pt(t)?t:Rt(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const Ut=32,Ct=new Uint8Array(Ut),Lt=["then"],Dt={};function Mt(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw r.error=e,r}class Ft extends Array{#t;constructor(...t){const e=t[0];let r=t[1],n=(t[2]||[]).slice(),i=!0;e!==Dt&&(r=t,n=[],i=!1),super(r.length),r.forEach(((t,e)=>{this[e]=t}));const o=n.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(this.#t=Object.freeze(r.map(((t,e)=>{const r=n[e];return null!=r&&1===o.get(r)?r:null}))),i)return Object.freeze(this),new Proxy(this,{get:(t,e,r)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const r=xt(e,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=t[r];return n instanceof Error&&Mt(`index ${r}`,n),n}if(Lt.indexOf(e)>=0)return Reflect.get(t,e,r);const n=t[e];if(n instanceof Function)return function(...e){return n.apply(this===r?t:this,e)};if(!(e in t))return t.getValue.apply(this===r?t:this,[e])}return Reflect.get(t,e,r)}})}toArray(t){const e=[];return this.forEach(((r,n)=>{r instanceof Error&&Mt(`index ${n}`,r),t&&r instanceof Ft&&(r=r.toArray(t)),e.push(r)})),e}toObject(t){return this.#t.reduce(((e,r,n)=>{if(it(null!=r,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),!(r in e)){let n=this.getValue(r);t&&n instanceof Ft&&(n=n.toObject(t)),e[r]=n}return e}),{})}slice(t,e){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==e&&(e=this.length),e<0&&(e+=this.length)<0&&(e=0),e>this.length&&(e=this.length);const r=[],n=[];for(let i=t;i<e;i++)r.push(this[i]),n.push(this.#t[i]);return new Ft(Dt,r,n)}filter(t,e){const r=[],n=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&Mt(`index ${i}`,o),t.call(e,o,i,this)&&(r.push(o),n.push(this.#t[i]))}return new Ft(Dt,r,n)}map(t,e){const r=[];for(let n=0;n<this.length;n++){const i=this[n];i instanceof Error&&Mt(`index ${n}`,i),r.push(t.call(e,i,n,this))}return r}getValue(t){const e=this.#t.indexOf(t);if(-1===e)return;const r=this[e];return r instanceof Error&&Mt(`property ${JSON.stringify(t)}`,r.error),r}static fromItems(t,e){return new Ft(Dt,t,e)}}function Ht(t){let e=Rt(t);return it(e.length<=Ut,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Ut,offset:e.length}),e.length!==Ut&&(e=ft(gt([Ct.slice(e.length%Ut),e]))),e}class jt{name;type;localName;dynamic;constructor(t,e,r,n){$(this,{name:t,type:e,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){ot(!1,t,this.localName,e)}}class Gt{#e;#r;constructor(){this.#e=[],this.#r=0}get data(){return gt(this.#e)}get length(){return this.#r}#n(t){return this.#e.push(t),this.#r+=t.length,t.length}appendWriter(t){return this.#n(ft(t.data))}writeBytes(t){let e=ft(t);const r=e.length%Ut;return r&&(e=ft(gt([e,Ct.slice(r)]))),this.#n(e)}writeValue(t){return this.#n(Ht(t))}writeUpdatableValue(){const t=this.#e.length;return this.#e.push(Ct),this.#r+=Ut,e=>{this.#e[t]=Ht(e)}}}class Vt{allowLoose;#e;#i;#o;#s;#a;constructor(t,e,r){$(this,{allowLoose:!!e}),this.#e=ft(t),this.#o=0,this.#s=null,this.#a=null!=r?r:1024,this.#i=0}get data(){return yt(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#i}get bytes(){return new Uint8Array(this.#e)}#u(t){if(this.#s)return this.#s.#u(t);this.#o+=t,it(this.#a<1||this.#o<=this.#a*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#a} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:ft(this.#e),offset:this.#i,length:t,info:{bytesRead:this.#o,dataLength:this.dataLength}})}#c(t,e,r){let n=Math.ceil(e/Ut)*Ut;return this.#i+n>this.#e.length&&(this.allowLoose&&r&&this.#i+e<=this.#e.length?n=e:it(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:ft(this.#e),length:this.#e.length,offset:this.#i+n})),this.#e.slice(this.#i,this.#i+n)}subReader(t){const e=new Vt(this.#e.slice(this.#i+t),this.allowLoose,this.#a);return e.#s=this,e}readBytes(t,e){let r=this.#c(0,t,!!e);return this.#u(t),this.#i+=r.length,r.slice(0,t)}readValue(){return Ot(this.readBytes(Ut))}readIndex(){return xt(Ot(this.readBytes(Ut)))}}function Kt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Wt(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 zt(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 qt(t,e){Wt(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const Qt=BigInt(2**32-1),Jt=BigInt(32);function Xt(t,e=!1){return e?{h:Number(t&Qt),l:Number(t>>Jt&Qt)}:{h:0|Number(t>>Jt&Qt),l:0|Number(t&Qt)}}function Yt(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=Xt(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}const Zt=(t,e,r)=>t<<r|e>>>32-r,$t=(t,e,r)=>e<<r|t>>>32-r,te=(t,e,r)=>e<<r-32|t>>>64-r,ee=(t,e,r)=>t<<r-32|e>>>64-r,re={fromBig:Xt,split:Yt,toBig:(t,e)=>BigInt(t>>>0)<<Jt|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Zt,rotlSL:$t,rotlBH:te,rotlBL:ee,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},ne=t=>t instanceof Uint8Array,ie=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),oe=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function se(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!ne(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class ae{clone(){return this._cloneInto()}}function ue(t){const e=e=>t().update(se(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}const[ce,le,fe]=[[],[],[]],he=BigInt(0),pe=BigInt(1),de=BigInt(2),ye=BigInt(7),ge=BigInt(256),be=BigInt(113);for(let t=0,e=pe,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],ce.push(2*(5*n+r)),le.push((t+1)*(t+2)/2%64);let i=he;for(let t=0;t<7;t++)e=(e<<pe^(e>>ye)*be)%ge,e&de&&(i^=pe<<(pe<<BigInt(t))-pe);fe.push(i)}const[we,me]=Yt(fe,!0),ve=(t,e,r)=>r>32?te(t,e,r):Zt(t,e,r),Ee=(t,e,r)=>r>32?ee(t,e,r):$t(t,e,r);class Ae extends ae{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Kt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=ve(o,s,1)^r[n],u=Ee(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=u}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=le[r],o=ve(e,i,n),s=Ee(e,i,n),a=ce[r];e=t[a],i=t[a+1],t[a]=o,t[a+1]=s}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=we[n],t[1]^=me[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){zt(this);const{blockLen:e,state:r}=this,n=(t=se(t)).length;for(let i=0;i<n;){const o=Math.min(e-this.pos,n-i);for(let e=0;e<o;e++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,128&e&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){zt(this,!1),Wt(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Kt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(qt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new Ae(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Se=((t,e,r)=>ue((()=>new Ae(e,t,r))))(1,136,32);let _e=!1;const ke=function(t){return Se(t)};let Te=ke;function Pe(t){const e=lt(t,"data");return yt(Te(e))}Pe._=ke,Pe.lock=function(){_e=!0},Pe.register=function(t){if(_e)throw new TypeError("keccak256 is locked");Te=t},Object.freeze(Pe);const Ie=BigInt(0),Oe=BigInt(36);function xe(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=lt(Pe(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Be={};for(let t=0;t<10;t++)Be[String(t)]=String(t);for(let t=0;t<26;t++)Be[String.fromCharCode(65+t)]=String(10+t);const Re=15;const Ne=function(){const t={};for(let e=0;e<36;e++)t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e);return t}();function Ue(t){if(ot("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=xe(t);return ot(!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}$/)){ot(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Be[t])).join("");for(;e.length>=Re;){let t=e.substring(0,Re);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Ie;for(let r=0;r<t.length;r++)e=e*Oe+Ne[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return xe("0x"+e)}ot(!1,"invalid address","address",t)}const Ce={};function Le(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new Fe(Ce,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function De(t,e){return new Fe(Ce,`bytes${e||""}`,t,{size:e})}const Me=Symbol.for("_ethers_typed");class Fe{type;value;#l;_typedSymbol;constructor(t,e,r,n){null==n&&(n=null),ut(Ce,t,"Typed"),$(this,{_typedSymbol:Me,type:e,value:r}),this.#l=n,this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.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"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return this.#l}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===this.#l?-1:!1===this.#l?this.value.length:null}static from(t,e){return new Fe(Ce,t,e)}static uint8(t){return Le(t,8)}static uint16(t){return Le(t,16)}static uint24(t){return Le(t,24)}static uint32(t){return Le(t,32)}static uint40(t){return Le(t,40)}static uint48(t){return Le(t,48)}static uint56(t){return Le(t,56)}static uint64(t){return Le(t,64)}static uint72(t){return Le(t,72)}static uint80(t){return Le(t,80)}static uint88(t){return Le(t,88)}static uint96(t){return Le(t,96)}static uint104(t){return Le(t,104)}static uint112(t){return Le(t,112)}static uint120(t){return Le(t,120)}static uint128(t){return Le(t,128)}static uint136(t){return Le(t,136)}static uint144(t){return Le(t,144)}static uint152(t){return Le(t,152)}static uint160(t){return Le(t,160)}static uint168(t){return Le(t,168)}static uint176(t){return Le(t,176)}static uint184(t){return Le(t,184)}static uint192(t){return Le(t,192)}static uint200(t){return Le(t,200)}static uint208(t){return Le(t,208)}static uint216(t){return Le(t,216)}static uint224(t){return Le(t,224)}static uint232(t){return Le(t,232)}static uint240(t){return Le(t,240)}static uint248(t){return Le(t,248)}static uint256(t){return Le(t,256)}static uint(t){return Le(t,256)}static int8(t){return Le(t,-8)}static int16(t){return Le(t,-16)}static int24(t){return Le(t,-24)}static int32(t){return Le(t,-32)}static int40(t){return Le(t,-40)}static int48(t){return Le(t,-48)}static int56(t){return Le(t,-56)}static int64(t){return Le(t,-64)}static int72(t){return Le(t,-72)}static int80(t){return Le(t,-80)}static int88(t){return Le(t,-88)}static int96(t){return Le(t,-96)}static int104(t){return Le(t,-104)}static int112(t){return Le(t,-112)}static int120(t){return Le(t,-120)}static int128(t){return Le(t,-128)}static int136(t){return Le(t,-136)}static int144(t){return Le(t,-144)}static int152(t){return Le(t,-152)}static int160(t){return Le(t,-160)}static int168(t){return Le(t,-168)}static int176(t){return Le(t,-176)}static int184(t){return Le(t,-184)}static int192(t){return Le(t,-192)}static int200(t){return Le(t,-200)}static int208(t){return Le(t,-208)}static int216(t){return Le(t,-216)}static int224(t){return Le(t,-224)}static int232(t){return Le(t,-232)}static int240(t){return Le(t,-240)}static int248(t){return Le(t,-248)}static int256(t){return Le(t,-256)}static int(t){return Le(t,-256)}static bytes1(t){return De(t,1)}static bytes2(t){return De(t,2)}static bytes3(t){return De(t,3)}static bytes4(t){return De(t,4)}static bytes5(t){return De(t,5)}static bytes6(t){return De(t,6)}static bytes7(t){return De(t,7)}static bytes8(t){return De(t,8)}static bytes9(t){return De(t,9)}static bytes10(t){return De(t,10)}static bytes11(t){return De(t,11)}static bytes12(t){return De(t,12)}static bytes13(t){return De(t,13)}static bytes14(t){return De(t,14)}static bytes15(t){return De(t,15)}static bytes16(t){return De(t,16)}static bytes17(t){return De(t,17)}static bytes18(t){return De(t,18)}static bytes19(t){return De(t,19)}static bytes20(t){return De(t,20)}static bytes21(t){return De(t,21)}static bytes22(t){return De(t,22)}static bytes23(t){return De(t,23)}static bytes24(t){return De(t,24)}static bytes25(t){return De(t,25)}static bytes26(t){return De(t,26)}static bytes27(t){return De(t,27)}static bytes28(t){return De(t,28)}static bytes29(t){return De(t,29)}static bytes30(t){return De(t,30)}static bytes31(t){return De(t,31)}static bytes32(t){return De(t,32)}static address(t){return new Fe(Ce,"address",t)}static bool(t){return new Fe(Ce,"bool",!!t)}static bytes(t){return new Fe(Ce,"bytes",t)}static string(t){return new Fe(Ce,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new Fe(Ce,"overrides",Object.assign({},t))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===Me}static dereference(t,e){if(Fe.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class He extends jt{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=Fe.dereference(e,"string");try{r=Ue(r)}catch(t){return this._throwError(t.message,e)}return t.writeValue(r)}decode(t){return Ue(Bt(t.readValue(),20))}}class je extends jt{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function Ge(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return it(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),it(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else ot(!1,"invalid tuple value","tuple",r);ot(e.length===n.length,"types/value length mismatch","tuple",r);let i=new Gt,o=new Gt,s=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=o.length;t.encode(o,r);let n=i.writeUpdatableValue();s.push((t=>{n(t+e)}))}else t.encode(i,r)})),s.forEach((t=>{t(i.length)}));let a=t.appendWriter(i);return a+=t.appendWriter(o),a}function Ve(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let o=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{o=e.decode(n)}catch(t){if(et(t,"BUFFER_OVERRUN"))throw t;o=t,o.baseType=e.name,o.name=e.localName,o.type=e.type}}else try{o=e.decode(t)}catch(t){if(et(t,"BUFFER_OVERRUN"))throw t;o=t,o.baseType=e.name,o.name=e.localName,o.type=e.type}if(null==o)throw new Error("investigate");r.push(o),n.push(e.localName||null)})),Ft.fromItems(r,n)}class Ke extends jt{coder;length;constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),$(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=Fe.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),st(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let t=0;t<r.length;t++)i.push(this.coder);return Ge(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),it(e*Ut<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*Ut,length:t.dataLength}));let r=[];for(let t=0;t<e;t++)r.push(new je(this.coder));return Ve(t,r)}}class We extends jt{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=Fe.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class ze extends jt{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=ft(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class qe extends ze{constructor(t){super("bytes",t)}decode(t){return yt(super.decode(t))}}class Qe extends jt{size;constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),$(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=ft(Fe.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return yt(t.readBytes(this.size))}}const Je=new Uint8Array([]);class Xe extends jt{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(Je)}decode(t){return t.readBytes(0),null}}const Ye=BigInt(0),Ze=BigInt(1),$e=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class tr extends jt{size;signed;constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),$(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=Tt(Fe.dereference(e,this.type)),n=kt($e,256);if(this.signed){let t=kt(n,8*this.size-1);(r>t||r<-(t+Ze))&&this._throwError("value out-of-bounds",e),r=_t(r,256)}else(r<Ye||r>kt(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=kt(t.readValue(),8*this.size);return this.signed&&(e=function(t,e){const r=Pt(t,"value"),n=BigInt(xt(e,"width"));return it(r>>n===Et,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),r>>n-At?-((~r&(At<<n)-At)+At):r}(e,8*this.size)),e}}function er(t,e,r,n,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return"OVERRUN"===t?r.length-e-1:0}const rr=Object.freeze({error:function(t,e,r,n,i){ot(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:er,replace:function(t,e,r,n,i){return"OVERLONG"===t?(ot("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),er(t,e,r))}});function nr(t,e){ot("string"==typeof t,"invalid string value","str",t),null!=e&&(function(t){it(at.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);ot(e<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return new Uint8Array(r)}function ir(t,e){return function(t,e){null==e&&(e=rr.error);const r=lt(t,"bytes"),n=[];let i=0;for(;i<r.length;){const t=r[i++];if(!(t>>7)){n.push(t);continue}let o=null,s=null;if(192==(224&t))o=1,s=127;else if(224==(240&t))o=2,s=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,r,n);continue}o=3,s=65535}if(i-1+o>=r.length){i+=e("OVERRUN",i-1,r,n);continue}let a=t&(1<<8-o-1)-1;for(let t=0;t<o;t++){let t=r[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,r,n),a=null;break}a=a<<6|63&t,i++}null!==a&&(a>1114111?i+=e("OUT_OF_RANGE",i-1-o,r,n,a):a>=55296&&a<=57343?i+=e("UTF16_SURROGATE",i-1-o,r,n,a):a<=s?i+=e("OVERLONG",i-1-o,r,n,a):n.push(a))}return n}(t,e).map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}class or extends ze{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,nr(Fe.dereference(e,"string")))}decode(t){return ir(super.decode(t))}}class sr extends jt{coders;constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)})),super("tuple","tuple("+n.join(",")+")",e,r),$(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=Fe.dereference(e,"tuple");return Ge(t,this.coders,r)}decode(t){return Ve(t,this.coders)}}function ar(t){return Pe(nr(t))}function ur(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const cr=ur("external public payable override".split(" ")),lr="constant external internal payable private public pure view override",fr=ur(lr.split(" ")),hr="constructor error event fallback function receive struct",pr=ur(hr.split(" ")),dr="calldata memory storage payable indexed",yr=ur(dr.split(" ")),gr=ur([hr,dr,"tuple returns",lr].join(" ").split(" ")),br={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},wr=new RegExp("^(\\s*)"),mr=new RegExp("^([0-9]+)"),vr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Er=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Ar=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class Sr{#i;#f;get offset(){return this.#i}get length(){return this.#f.length-this.#i}constructor(t){this.#i=0,this.#f=t.slice()}clone(){return new Sr(this.#f)}reset(){this.#i=0}#h(t=0,e=0){return new Sr(this.#f.slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=this.#h(this.#i+1,t.match+1);return this.#i=t.match+1,e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;this.#i<t.match-1;){const t=this.peek().linkNext;e.push(this.#h(this.#i+1,t)),this.#i=t}return this.#i=t.match+1,e}peek(){if(this.#i>=this.#f.length)throw new Error("out-of-bounds");return this.#f[this.#i]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#i++,t}toString(){const t=[];for(let e=this.#i;e<this.#f.length;e++){const r=this.#f[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}}function _r(t){const e=[],r=e=>{const r=o<t.length?JSON.stringify(t[o]):"$EOI";throw new Error(`invalid token ${r} at ${o}: ${e}`)};let n=[],i=[],o=0;for(;o<t.length;){let s=t.substring(o),a=s.match(wr);a&&(o+=a[1].length,s=t.substring(o));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:o,value:-1};e.push(u);let c=br[s[0]]||"";if(c){if(u.type=c,u.text=s[0],o++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("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("COMMA"===c)u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)u.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const r=e.pop().text;t=r+t,e[e.length-1].value=xt(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(a=s.match(vr),a){if(u.text=a[1],o+=u.text.length,gr.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(Ar)){u.type="TYPE";continue}u.type="ID"}else{if(a=s.match(mr),!a)throw new Error(`unexpected token ${JSON.stringify(s[0])} at position ${o}`);u.text=a[1],u.type="NUMBER",o+=u.text.length}}return new Sr(e.map((t=>Object.freeze(t))))}function kr(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Tr(t,e){if(e.peekKeyword(pr)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function Pr(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Ir(t){let e=Pr(t,fr);return kr(e,ur("constant payable nonpayable".split(" "))),kr(e,ur("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 Or(t,e){return t.popParams().map((t=>Vr.from(t,e)))}function xr(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return Tt(t.pop().text);throw new Error("invalid gas")}return null}function Br(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Rr=new RegExp(/^(.*)\[([0-9]*)\]$/);function Nr(t){const e=t.match(Ar);if(ot(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);ot(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);ot(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Ur={},Cr=Symbol.for("_ethers_internal"),Lr="_ParamTypeInternal",Dr="_ErrorInternal",Mr="_EventInternal",Fr="_ConstructorInternal",Hr="_FallbackInternal",jr="_FunctionInternal",Gr="_StructInternal";class Vr{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,r,n,i,o,s,a){if(ut(t,Ur,"ParamType"),Object.defineProperty(this,Cr,{value:Lr}),o&&(o=Object.freeze(o.slice())),"array"===n){if(null==s||null==a)throw new Error("")}else if(null!=s||null!=a)throw new Error("");if("tuple"===n){if(null==o)throw new Error("")}else if(null!=o)throw new Error("");$(this,{name:e,type:r,baseType:n,indexed:i,components:o,arrayLength:s,arrayChildren:a})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map((t=>r.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}#p(t,e,r,n){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,o=e.slice();return o.forEach(((e,n)=>{i.#p(t,e,r,(t=>{o[n]=t}))})),void n(o)}if(this.isTuple()){const i=this.components;let o;if(Array.isArray(e))o=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");o=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(o.length!==this.components.length)throw new Error("array is wrong length");return o.forEach(((e,n)=>{i[n].#p(t,e,r,(t=>{o[n]=t}))})),void n(o)}const i=r(this.type,e);i.then?t.push(async function(){n(await i)}()):n(i)}async walkAsync(t,e){const r=[],n=[t];return this.#p(r,t,e,(t=>{n[0]=t})),r.length&&await Promise.all(r),n[0]}static from(t,e){if(Vr.isParamType(t))return t;if("string"==typeof t)try{return Vr.from(_r(t),e)}catch(e){ot(!1,"invalid param type","obj",t)}else if(t instanceof Sr){let r="",n="",i=null;Pr(t,ur(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(n="tuple",i=t.popParams().map((t=>Vr.from(t))),r=`tuple(${i.map((t=>t.format())).join(",")})`):(r=Nr(t.popType("TYPE")),n=r);let o=null,s=null;for(;t.length&&t.peekType("BRACKET");){const e=t.pop();o=new Vr(Ur,"",r,n,null,i,s,o),s=e.value,r+=e.text,n="array",i=null}let a=null;if(Pr(t,yr).has("indexed")){if(!e)throw new Error("");a=!0}const u=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new Vr(Ur,u,r,n,a,i,s,o)}const r=t.name;ot(!r||"string"==typeof r&&r.match(Er),"invalid name","obj.name",r);let n=t.indexed;null!=n&&(ot(e,"parameter cannot be indexed","obj.indexed",t.indexed),n=!!n);let i=t.type,o=i.match(Rr);if(o){const e=parseInt(o[2]||"-1"),s=Vr.from({type:o[1],components:t.components});return new Vr(Ur,r||"",i,"array",n,null,e,s)}if("tuple"===i||i.startsWith("tuple(")||i.startsWith("(")){const e=null!=t.components?t.components.map((t=>Vr.from(t))):null;return new Vr(Ur,r||"",i,"tuple",n,e,null,null)}return i=Nr(t.type),new Vr(Ur,r||"",i,i,n,null,null,null)}static isParamType(t){return t&&t[Cr]===Lr}}class Kr{type;inputs;constructor(t,e,r){ut(t,Ur,"Fragment"),$(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Kr.from(JSON.parse(t))}catch(t){}return Kr.from(_r(t))}if(t instanceof Sr)switch(t.peekKeyword(pr)){case"constructor":return Jr.from(t);case"error":return qr.from(t);case"event":return Qr.from(t);case"fallback":case"receive":return Xr.from(t);case"function":return Yr.from(t);case"struct":return Zr.from(t)}else if("object"==typeof t){switch(t.type){case"constructor":return Jr.from(t);case"error":return qr.from(t);case"event":return Qr.from(t);case"fallback":case"receive":return Xr.from(t);case"function":return Yr.from(t);case"struct":return Zr.from(t)}it(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}ot(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Jr.isFragment(t)}static isError(t){return qr.isFragment(t)}static isEvent(t){return Qr.isFragment(t)}static isFunction(t){return Yr.isFragment(t)}static isStruct(t){return Zr.isFragment(t)}}class Wr extends Kr{name;constructor(t,e,r,n){super(t,e,n),ot("string"==typeof r&&r.match(Er),"invalid identifier","name",r),n=Object.freeze(n.slice()),$(this,{name:r})}}function zr(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class qr extends Wr{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Cr,{value:Dr})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+zr(t,this.inputs)),e.join(" ")}static from(t){if(qr.isFragment(t))return t;if("string"==typeof t)return qr.from(_r(t));if(t instanceof Sr){const e=Tr("error",t),r=Or(t);return Br(t),new qr(Ur,e,r)}return new qr(Ur,t.name,t.inputs?t.inputs.map(Vr.from):[])}static isFragment(t){return t&&t[Cr]===Dr}}class Qr extends Wr{anonymous;constructor(t,e,r,n){super(t,"event",e,r),Object.defineProperty(this,Cr,{value:Mr}),$(this,{anonymous:n})}get topicHash(){return ar(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+zr(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){return e=(e||[]).map((t=>Vr.from(t))),new Qr(Ur,t,e,!1).topicHash}static from(t){if(Qr.isFragment(t))return t;if("string"==typeof t)try{return Qr.from(_r(t))}catch(e){ot(!1,"invalid event fragment","obj",t)}else if(t instanceof Sr){const e=Tr("event",t),r=Or(t,!0),n=!!Pr(t,ur(["anonymous"])).has("anonymous");return Br(t),new Qr(Ur,e,r,n)}return new Qr(Ur,t.name,t.inputs?t.inputs.map((t=>Vr.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Cr]===Mr}}class Jr extends Kr{payable;gas;constructor(t,e,r,n,i){super(t,e,r),Object.defineProperty(this,Cr,{value:Fr}),$(this,{payable:n,gas:i})}format(t){if(it(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${zr(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(Jr.isFragment(t))return t;if("string"==typeof t)try{return Jr.from(_r(t))}catch(e){ot(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Sr){Pr(t,ur(["constructor"]));const e=Or(t),r=!!Pr(t,cr).has("payable"),n=xr(t);return Br(t),new Jr(Ur,"constructor",e,r,n)}return new Jr(Ur,"constructor",t.inputs?t.inputs.map(Vr.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Cr]===Fr}}class Xr extends Kr{payable;constructor(t,e,r){super(t,"fallback",e),Object.defineProperty(this,Cr,{value:Hr}),$(this,{payable:r})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if(Xr.isFragment(t))return t;if("string"==typeof t)try{return Xr.from(_r(t))}catch(e){ot(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Sr){const e=t.toString();if(ot(t.peekKeyword(ur(["fallback","receive"])),"type must be fallback or receive","obj",e),"receive"===t.popKeyword(ur(["fallback","receive"]))){const e=Or(t);return ot(0===e.length,"receive cannot have arguments","obj.inputs",e),Pr(t,ur(["payable"])),Br(t),new Xr(Ur,[],!0)}let r=Or(t);r.length?ot(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Vr.from("bytes")];const n=Ir(t);if(ot("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Pr(t,ur(["returns"])).has("returns")){const e=Or(t);ot(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Br(t),new Xr(Ur,r,"payable"===n)}if("receive"===t.type)return new Xr(Ur,[],!0);if("fallback"===t.type){const e=[Vr.from("bytes")],r="payable"===t.stateMutability;return new Xr(Ur,e,r)}ot(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Cr]===Hr}}class Yr extends Wr{constant;outputs;stateMutability;payable;gas;constructor(t,e,r,n,i,o){super(t,"function",e,n),Object.defineProperty(this,Cr,{value:jr}),$(this,{constant:"view"===r||"pure"===r,gas:o,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+zr(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(zr(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){return e=(e||[]).map((t=>Vr.from(t))),new Yr(Ur,t,"view",e,[],null).selector}static from(t){if(Yr.isFragment(t))return t;if("string"==typeof t)try{return Yr.from(_r(t))}catch(e){ot(!1,"invalid function fragment","obj",t)}else if(t instanceof Sr){const e=Tr("function",t),r=Or(t),n=Ir(t);let i=[];Pr(t,ur(["returns"])).has("returns")&&(i=Or(t));const o=xr(t);return Br(t),new Yr(Ur,e,n,r,i,o)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new Yr(Ur,t.name,e,t.inputs?t.inputs.map(Vr.from):[],t.outputs?t.outputs.map(Vr.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Cr]===jr}}class Zr extends Wr{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Cr,{value:Gr})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return Zr.from(_r(t))}catch(e){ot(!1,"invalid struct fragment","obj",t)}else if(t instanceof Sr){const e=Tr("struct",t),r=Or(t);return Br(t),new Zr(Ur,e,r)}return new Zr(Ur,t.name,t.inputs?t.inputs.map(Vr.from):[])}static isFragment(t){return t&&t[Cr]===Gr}}const $r=new Map;$r.set(0,"GENERIC_PANIC"),$r.set(1,"ASSERT_FALSE"),$r.set(17,"OVERFLOW"),$r.set(18,"DIVIDE_BY_ZERO"),$r.set(33,"ENUM_RANGE_ERROR"),$r.set(34,"BAD_STORAGE_DATA"),$r.set(49,"STACK_UNDERFLOW"),$r.set(50,"ARRAY_RANGE_ERROR"),$r.set(65,"OUT_OF_MEMORY"),$r.set(81,"UNINITIALIZED_FUNCTION_CALL");const tn=new RegExp(/^bytes([0-9]*)$/),en=new RegExp(/^(u?int)([0-9]*)$/);let rn=null,nn=1024;class on{#d(t){if(t.isArray())return new Ke(this.#d(t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new sr(t.components.map((t=>this.#d(t))),t.name);switch(t.baseType){case"address":return new He(t.name);case"bool":return new We(t.name);case"string":return new or(t.name);case"bytes":return new qe(t.name);case"":return new Xe(t.name)}let e=t.type.match(en);if(e){let r=parseInt(e[2]||"256");return ot(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new tr(r/8,"int"===e[1],t.name)}if(e=t.type.match(tn),e){let r=parseInt(e[1]);return ot(0!==r&&r<=32,"invalid bytes length","param",t),new Qe(r,t.name)}ot(!1,"invalid type","type",t.type)}getDefaultValue(t){const e=t.map((t=>this.#d(Vr.from(t))));return new sr(e,"_").defaultValue()}encode(t,e){st(e.length,t.length,"types/values length mismatch");const r=t.map((t=>this.#d(Vr.from(t)))),n=new sr(r,"_"),i=new Gt;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>this.#d(Vr.from(t))));return new sr(n,"_").decode(new Vt(e,r,nn))}static _setDefaultMaxInflation(t){ot("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),nn=t}static defaultAbiCoder(){return null==rn&&(rn=new on),rn}static getBuiltinCallException(t,e,r){return function(t,e,r,n){let i="missing revert data",o=null,s=null;if(r){i="execution reverted";const t=lt(r);if(r=yt(r),0===t.length)i+=" (no data present; likely require(false) occurred",o="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===yt(t.slice(0,4)))try{o=n.decode(["string"],t.slice(4))[0],s={signature:"Error(string)",name:"Error",args:[o]},i+=`: ${JSON.stringify(o)}`}catch(t){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===yt(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);s={signature:"Panic(uint256)",name:"Panic",args:[e]},o=`Panic due to ${$r.get(e)||"UNKNOWN"}(${e})`,i+=`: ${o}`}catch(t){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const a={to:e.to?Ue(e.to):null,data:e.data||"0x"};return e.from&&(a.from=Ue(e.from)),nt(i,"CALL_EXCEPTION",{action:t,data:r,reason:o,transaction:a,invocation:null,revert:s})}(t,e,r,on.defaultAbiCoder())}}function sn(t){return t&&"function"==typeof t.getAddress}async function an(t,e){const r=await e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(it("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),ot(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Ue(r)}function un(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Ue(t):(it(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),an(t,e.resolveName(t))):sn(t)?an(t,t.getAddress()):t&&"function"==typeof t.then?an(t,t):void ot(!1,"unsupported addressable value","target",t)}const cn=new Uint8Array(32);cn.fill(0);const ln=BigInt(-1),fn=BigInt(0),hn=BigInt(1),pn=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),dn=Bt(hn,32),yn=Bt(fn,32),gn={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},bn=["name","version","chainId","verifyingContract","salt"];function wn(t){return function(e){return ot("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const mn={name:wn("name"),version:wn("version"),chainId:function(t){const e=Tt(t,"domain.chainId");return ot(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):Nt(e)},verifyingContract:function(t){try{return Ue(t).toLowerCase()}catch(t){}ot(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=lt(t,"domain.salt");return ot(32===e.length,'invalid domain value "salt"',"domain.salt",t),yt(e)}};function vn(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);ot(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=kt(pn,r?n-1:n),o=r?(i+hn)*ln:fn;return function(e){const n=Tt(e,"value");return ot(n>=o&&n<=i,`value out-of-bounds for ${t}`,"value",n),Bt(r?_t(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return ot(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return ot(lt(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=lt(t),r=e.length%32;return r?gt([e,cn.slice(r)]):yt(e)}(e)}}}switch(t){case"address":return function(t){return vt(Ue(t),32)};case"bool":return function(t){return t?dn:yn};case"bytes":return function(t){return Pe(t)};case"string":return function(t){return ar(t)}}return null}function En(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function An(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}}class Sn{primaryType;#y;get types(){return JSON.parse(this.#y)}#g;#b;constructor(t){this.#g=new Map,this.#b=new Map;const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((o=>{i[o]=t[o].map((({name:e,type:r})=>{let{base:n,index:i}=An(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(o,new Set),r.set(o,[]),n.set(o,new Set)})),this.#y=JSON.stringify(i);for(const n in i){const o=new Set;for(const s of i[n]){ot(!o.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(n)}`,"types",t),o.add(s.name);const i=An(s.type).base;ot(i!==n,`circular type reference to ${JSON.stringify(i)}`,"types",t),vn(i)||(ot(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(n),e.get(n).add(i))}}const o=Array.from(r.keys()).filter((t=>0===r.get(t).length));ot(0!==o.length,"missing primary type","types",t),ot(1===o.length,`ambiguous primary types or unused types: ${o.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),$(this,{primaryType:o[0]}),function i(o,s){ot(!s.has(o),`circular type reference to ${JSON.stringify(o)}`,"types",t),s.add(o);for(const t of e.get(o))if(r.has(t)){i(t,s);for(const e of s)n.get(e).add(t)}s.delete(o)}(this.primaryType,new Set);for(const[t,e]of n){const r=Array.from(e);r.sort(),this.#g.set(t,En(t,i[t])+r.map((t=>En(t,i[t]))).join(""))}}getEncoder(t){let e=this.#b.get(t);return e||(e=this.#w(t),this.#b.set(t,e)),e}#w(t){{const e=vn(t);if(e)return e}const e=An(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{ot(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return this.#g.has(t)&&(i=i.map(Pe)),Pe(gt(i))}}const r=this.types[t];if(r){const e=ar(this.#g.get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this.#g.has(r)?Pe(n):n}));return n.unshift(e),gt(n)}}ot(!1,`unknown type: ${t}`,"type",t)}encodeType(t){const e=this.#g.get(t);return ot(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Pe(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(vn(t))return r(t,e);const n=An(t).array;if(n)return ot(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});ot(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Sn(t)}static getPrimaryType(t){return Sn.from(t).primaryType}static hashStruct(t,e,r){return Sn.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(null==t[r])continue;const n=gn[r];ot(n,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>bn.indexOf(t.name)-bn.indexOf(e.name))),Sn.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return gt(["0x1901",Sn.hashDomain(t),Sn.from(e).hash(r)])}static hash(t,e,r){return Pe(Sn.encode(t,e,r))}static async resolveNames(t,e,r,n){t=Object.assign({},t);for(const e in t)null==t[e]&&delete t[e];const i={};t.verifyingContract&&!ht(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=Sn.from(e);o.visit(r,((t,e)=>("address"!==t||ht(e,20)||(i[e]="0x"),e)));for(const t in i)i[t]=await n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),{domain:t,value:r=o.visit(r,((t,e)=>"address"===t&&i[e]?i[e]:e))}}static getPayload(t,e,r){Sn.hashDomain(t);const n={},i=[];bn.forEach((e=>{const r=t[e];null!=r&&(n[e]=mn[e](r),i.push({name:e,type:gn[e]}))}));const o=Sn.from(e);e=o.types;const s=Object.assign({},e);return ot(null==s.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",e),s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return yt(lt(e));if(t.match(/^u?int/))return Tt(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return ot("string"==typeof e,"invalid string","value",e),e}ot(!1,"unsupported type","type",t)}))}}}function _n(t,e){return{address:Ue(t),storageKeys:e.map(((t,e)=>(ot(ht(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function kn(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(ot(2===e.length,"invalid slot set",`value[${r}]`,e),_n(e[0],e[1])):(ot(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),_n(e.address,e.storageKeys))));ot(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return _n(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function Tn(t){return async function(t,e){const r=t.url.split(":")[0].toLowerCase();let n;if(it("http"===r||"https"===r,`unsupported protocol ${r}`,"UNSUPPORTED_OPERATION",{info:{protocol:r},operation:"request"}),it("https"===r||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"}),e){const t=new AbortController;n=t.signal,e.addListener((()=>{t.abort()}))}const i={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:n},o=await fetch(t.url,i),s={};o.headers.forEach(((t,e)=>{s[e.toLowerCase()]=t}));const a=await o.arrayBuffer(),u=null==a?null:new Uint8Array(a);return{statusCode:o.status,statusMessage:o.statusText,headers:s,body:u}}}Tn();let Pn=Tn();const In=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),On=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xn=!1;async function Bn(t,e){try{const e=t.match(In);if(!e)throw new Error("invalid data");return new Mn(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return lt(e)}(e[3]):nr(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new Mn(599,"BAD REQUEST (invalid data: URI)",{},null,new Dn(t))}}function Rn(t){return async function(e,r){try{const r=e.match(On);if(!r)throw new Error("invalid link");return new Dn(`${t}${r[2]}`)}catch(t){return new Mn(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Dn(e))}}}const Nn={data:Bn,ipfs:Rn("https://gateway.ipfs.io/ipfs/")},Un=new WeakMap;class Cn{#m;#v;constructor(t){this.#m=[],this.#v=!1,Un.set(t,(()=>{if(!this.#v){this.#v=!0;for(const t of this.#m)setTimeout((()=>{t()}),0);this.#m=[]}}))}addListener(t){it(!this.#v,"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),this.#m.push(t)}get cancelled(){return this.#v}checkSignal(){it(!this.cancelled,"cancelled","CANCELLED",{})}}function Ln(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}class Dn{#E;#A;#S;#_;#k;#T;#P;#I;#O;#x;#B;#R;#N;#U;#C;get url(){return this.#T}set url(t){this.#T=String(t)}get body(){return null==this.#P?null:new Uint8Array(this.#P)}set body(t){if(null==t)this.#P=void 0,this.#I=void 0;else if("string"==typeof t)this.#P=nr(t),this.#I="text/plain";else if(t instanceof Uint8Array)this.#P=t,this.#I="application/octet-stream";else{if("object"!=typeof t)throw new Error("invalid body");this.#P=nr(JSON.stringify(t)),this.#I="application/json"}}hasBody(){return null!=this.#P}get method(){return this.#_?this.#_:this.hasBody()?"POST":"GET"}set method(t){null==t&&(t=""),this.#_=String(t).toUpperCase()}get headers(){const t=Object.assign({},this.#S);return this.#O&&(t.authorization=`Basic ${function(t){const e=lt(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return btoa(r)}(nr(this.#O))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),null==t["content-type"]&&this.#I&&(t["content-type"]=this.#I),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){this.#S[String(t).toLowerCase()]=String(e)}clearHeaders(){this.#S={}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#O||null}setCredentials(t,e){ot(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),this.#O=`${t}:${e}`}get allowGzip(){return this.#A}set allowGzip(t){this.#A=!!t}get allowInsecureAuthentication(){return!!this.#E}set allowInsecureAuthentication(t){this.#E=!!t}get timeout(){return this.#k}set timeout(t){ot(t>=0,"timeout must be non-zero","timeout",t),this.#k=t}get preflightFunc(){return this.#x||null}set preflightFunc(t){this.#x=t}get processFunc(){return this.#B||null}set processFunc(t){this.#B=t}get retryFunc(){return this.#R||null}set retryFunc(t){this.#R=t}get getUrlFunc(){return this.#C||Pn}set getUrlFunc(t){this.#C=t}constructor(t){this.#T=String(t),this.#E=!1,this.#A=!0,this.#S={},this.#_="",this.#k=3e5,this.#U={slotInterval:250,maxAttempts:12},this.#C=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#P?yt(this.#P):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(this.#U.slotInterval=t.slotInterval),null!=t.maxAttempts&&(this.#U.maxAttempts=t.maxAttempts)}async#L(t,e,r,n,i){if(t>=this.#U.maxAttempts)return i.makeServerError("exceeded maximum retry limit");it(Fn()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:n}),r>0&&await function(t){return new Promise((e=>setTimeout(e,t)))}(r);let o=this.clone();const s=(o.url.split(":")[0]||"").toLowerCase();if(s in Nn){const t=await Nn[s](o.url,Ln(n.#N));if(t instanceof Mn){let e=t;if(this.processFunc){Ln(n.#N);try{e=await this.processFunc(o,e)}catch(t){null!=t.throttle&&"number"==typeof t.stall||e.makeServerError("error in post-processing function",t).assertOk()}}return e}o=t}this.preflightFunc&&(o=await this.preflightFunc(o));const a=await this.getUrlFunc(o,Ln(n.#N));let u=new Mn(a.statusCode,a.statusMessage,a.headers,a.body,n);if(301===u.statusCode||302===u.statusCode){try{const r=u.headers.location||"";return o.redirect(r).#L(t+1,e,0,n,u)}catch(t){}return u}if(429===u.statusCode&&(null==this.retryFunc||await this.retryFunc(o,u,t))){const r=u.headers["retry-after"];let i=this.#U.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof r&&r.match(/^[1-9][0-9]*$/)&&(i=parseInt(r)),o.clone().#L(t+1,e,i,n,u)}if(this.processFunc){Ln(n.#N);try{u=await this.processFunc(o,u)}catch(r){null!=r.throttle&&"number"==typeof r.stall||u.makeServerError("error in post-processing function",r).assertOk();let i=this.#U.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return r.stall>=0&&(i=r.stall),o.clone().#L(t+1,e,i,n,u)}}return u}send(){return it(null==this.#N,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),this.#N=new Cn(this),this.#L(0,Fn()+this.timeout,0,this,new Mn(0,"",{},null,this))}cancel(){it(null!=this.#N,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Un.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();it("GET"===this.method&&("https"!==e||"http"!==r)&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const n=new Dn(t);return n.method="GET",n.allowGzip=this.allowGzip,n.timeout=this.timeout,n.#S=Object.assign({},this.#S),this.#P&&(n.#P=new Uint8Array(this.#P)),n.#I=this.#I,n}clone(){const t=new Dn(this.url);return t.#_=this.#_,this.#P&&(t.#P=this.#P),t.#I=this.#I,t.#S=Object.assign({},this.#S),t.#O=this.#O,this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),t.#x=this.#x,t.#B=this.#B,t.#R=this.#R,t.#U=Object.assign({},this.#U),t.#C=this.#C,t}static lockConfig(){xn=!0}static getGateway(t){return Nn[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xn)throw new Error("gateways locked");Nn[t]=e}static registerGetUrl(t){if(xn)throw new Error("gateways locked");Pn=t}static createGetUrlFunc(t){return Tn()}static createDataGateway(){return Bn}static createIpfsGatewayFunc(t){return Rn(t)}}class Mn{#D;#M;#S;#P;#F;#H;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#P?yt(this.#P):"null"}>`}get statusCode(){return this.#D}get statusMessage(){return this.#M}get headers(){return Object.assign({},this.#S)}get body(){return null==this.#P?null:new Uint8Array(this.#P)}get bodyText(){try{return null==this.#P?"":ir(this.#P)}catch(t){it(!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(t){it(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}constructor(t,e,r,n,i){this.#D=t,this.#M=e,this.#S=Object.keys(r).reduce(((t,e)=>(t[e.toLowerCase()]=String(r[e]),t)),{}),this.#P=null==n?null:new Uint8Array(n),this.#F=i||null,this.#H={message:""}}makeServerError(t,e){let r;r=t?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:`CLIENT ESCALATED SERVER ERROR (${t=`${this.statusCode} ${this.statusMessage}`})`;const n=new Mn(599,r,this.headers,this.body,this.#F||void 0);return n.#H={message:t,error:e},n}throwThrottleError(t,e){null==e?e=-1:ot(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw $(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return null!=this.#P}get request(){return this.#F}ok(){return""===this.#H.message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=this.#H;""===t&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let n=null;try{this.#P&&(n=ir(this.#P))}catch(t){}it(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}}function Fn(){return(new Date).getTime()}const Hn="0x0000000000000000000000000000000000000000";class jn{fragment;name;signature;topic;args;constructor(t,e,r){const n=t.name,i=t.format();$(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class Gn{fragment;name;args;signature;selector;value;constructor(t,e,r,n){const i=t.name,o=t.format();$(this,{fragment:t,name:i,args:r,signature:o,selector:e,value:n})}}class Vn{fragment;name;args;signature;selector;constructor(t,e,r){const n=t.name,i=t.format();$(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class Kn{hash;_isIndexed;static isIndexed(t){return!(!t||!t._isIndexed)}constructor(t){$(this,{hash:t,_isIndexed:!0})}}const Wn={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"},zn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&Wn[t.toString()]&&(e=Wn[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};class qn{fragments;deploy;fallback;receive;#j;#G;#V;#K;constructor(t){let e=[];e="string"==typeof t?JSON.parse(t):t,this.#V=new Map,this.#j=new Map,this.#G=new Map;const r=[];for(const t of e)try{r.push(Kr.from(t))}catch(e){console.log(`[Warning] Invalid Fragment ${JSON.stringify(t)}:`,e.message)}$(this,{fragments:Object.freeze(r)});let n=null,i=!1;this.#K=this.getAbiCoder(),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void $(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(ot(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=this.#V;break;case"event":r=this.#G;break;case"error":r=this.#j;break;default:return}const o=t.format();r.has(o)||r.set(o,t)})),this.deploy||$(this,{deploy:Jr.from("constructor()")}),$(this,{fallback:n,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return on.defaultAbiCoder()}#W(t,e,r){if(ht(t)){const e=t.toLowerCase();for(const t of this.#V.values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of this.#V)e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;Fe.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let t=n.length-1;t>=0;t--){const e=n[t].inputs.length;e===r||i&&e===r-1||n.splice(t,1)}for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(Fe.isTyped(e[i])){if(i>=r.length){if("overrides"===e[i].type)continue;n.splice(t,1);break}if(e[i].type!==r[i].baseType){n.splice(t,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}return 0===n.length?null:(n.length>1&&r&&ot(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t),n[0])}return this.#V.get(Yr.from(t).format())||null}getFunctionName(t){const e=this.#W(t,null,!1);return ot(e,"no matching function","key",t),e.name}hasFunction(t){return!!this.#W(t,null,!1)}getFunction(t,e){return this.#W(t,e||null,!0)}forEachFunction(t){const e=Array.from(this.#V.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#V.get(n),r)}}#z(t,e,r){if(ht(t)){const e=t.toLowerCase();for(const t of this.#G.values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of this.#G)e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(Fe.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}return 0===n.length?null:(n.length>1&&r&&ot(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t),n[0])}return this.#G.get(Qr.from(t).format())||null}getEventName(t){const e=this.#z(t,null,!1);return ot(e,"no matching event","key",t),e.name}hasEvent(t){return!!this.#z(t,null,!1)}getEvent(t,e){return this.#z(t,e||null,!0)}forEachEvent(t){const e=Array.from(this.#G.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#G.get(n),r)}}getError(t,e){if(ht(t)){const e=t.toLowerCase();if(zn[e])return qr.from(zn[e].signature);for(const t of this.#j.values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[r,n]of this.#j)r.split("(")[0]===t&&e.push(n);return 0===e.length?"Error"===t?qr.from("error Error(string)"):"Panic"===t?qr.from("error Panic(uint256)"):null:(e.length>1&&ot(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t),e[0])}if("Error(string)"===(t=qr.from(t).format()))return qr.from("error Error(string)");if("Panic(uint256)"===t)return qr.from("error Panic(uint256)");return this.#j.get(t)||null}forEachError(t){const e=Array.from(this.#j.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#j.get(n),r)}}_decodeParams(t,e){return this.#K.decode(t,e)}_encodeParams(t,e){return this.#K.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);ot(e,"unknown error","fragment",t),t=e}return ot(wt(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,wt(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);ot(e,"unknown error","fragment",t),t=e}return gt([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}return ot(wt(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,wt(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}return gt([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=ft(e);if(n.length%32==0)try{return this.#K.decode(t.outputs,n)}catch(t){r="could not decode result data"}it(!1,r,"BAD_DATA",{value:yt(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=lt(t,"data"),n=on.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=yt(r.slice(0,4)),e=this.getError(t);if(e)try{const t=this.#K.decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(t){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}return yt(this.#K.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);ot(e,"unknown event","eventFragment",t),t=e}it(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?ar(e):"bytes"===t.type?Pe(yt(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=Bt(e):t.type.match(/^bytes/)?e=mt(e,32,!1):"address"===t.type&&this.#K.encode(["address"],[e]),vt(yt(e),32));for(e.forEach(((e,i)=>{const o=t.inputs[i];o.indexed?null==e?r.push(null):"array"===o.baseType||"tuple"===o.baseType?ot(!1,"filtering with tuples or arrays not supported","contract."+o.name,e):Array.isArray(e)?r.push(e.map((t=>n(o,t)))):r.push(n(o,e)):ot(null==e,"cannot filter non-indexed parameters; must be null","contract."+o.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);ot(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),ot(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,o)=>{const s=e[o];if(t.indexed)if("string"===t.type)r.push(ar(s));else if("bytes"===t.type)r.push(Pe(s));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this.#K.encode([t.type],[s]))}else n.push(t),i.push(s)})),{data:this.#K.encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);ot(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;ot(ht(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],o=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Vr.from({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))}));const s=null!=r?this.#K.decode(n,gt(r)):null,a=this.#K.decode(i,e,!0),u=[],c=[];let l=0,f=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==s)r=new Kn(null);else if(o[e])r=new Kn(s[f++]);else try{r=s[f++]}catch(t){r=t}else try{r=a[l++]}catch(t){r=t}u.push(r),c.push(t.name||null)})),Ft.fromItems(u,c)}parseTransaction(t){const e=lt(t.data,"tx.data"),r=Tt(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(yt(e.slice(0,4)));if(!n)return null;const i=this.#K.decode(n.inputs,e.slice(4));return new Gn(n,n.selector,i,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new jn(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=yt(t),r=this.getError(wt(e,0,4));if(!r)return null;const n=this.#K.decode(r.inputs,wt(e,4));return new Vn(r,r.selector,n)}static from(t){return t instanceof qn?t:"string"==typeof t?new qn(JSON.parse(t)):"function"==typeof t.formatJson?new qn(t.formatJson()):"function"==typeof t.format?new qn(t.format("json")):new qn(t)}}const Qn=BigInt(0);function Jn(t){return null==t?null:t}function Xn(t){return null==t?null:t.toString()}class Yn{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(t,e,r){$(this,{gasPrice:Jn(t),maxFeePerGas:Jn(e),maxPriorityFeePerGas:Jn(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Xn(t),maxFeePerGas:Xn(e),maxPriorityFeePerGas:Xn(r)}}}function Zn(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=yt(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const n of r)n in t&&null!=t[n]&&(e[n]=Tt(t[n],`request.${n}`));const n="type,nonce".split(/,/);for(const r of n)r in t&&null!=t[r]&&(e[r]=xt(t[r],`request.${r}`));return t.accessList&&(e.accessList=kn(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((t=>pt(t)?yt(t):Object.assign({},t)))),e}class $n{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#q;constructor(t,e){this.#q=t.transactions.map((t=>"string"!=typeof t?new ri(t,e):t)),$(this,{provider:e,hash:Jn(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:Jn(t.prevRandao),extraData:t.extraData,baseFeePerGas:Jn(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return this.#q.map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=this.#q.slice();return 0===t.length?[]:(it("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:o,miner:s,prevRandao:a,nonce:u,number:c,parentHash:l,parentBeaconBlockRoot:f,stateRoot:h,receiptsRoot:p,timestamp:d,transactions:y}=this;return{_type:"Block",baseFeePerGas:Xn(t),difficulty:Xn(e),extraData:r,gasLimit:Xn(n),gasUsed:Xn(i),blobGasUsed:Xn(this.blobGasUsed),excessBlobGas:Xn(this.excessBlobGas),hash:o,miner:s,prevRandao:a,nonce:u,number:c,parentHash:l,timestamp:d,parentBeaconBlockRoot:f,stateRoot:h,receiptsRoot:p,transactions:y}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#q.length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}async getTransaction(t){let e;if("number"==typeof t)e=this.#q[t];else{const r=t.toLowerCase();for(const t of this.#q){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash!==r){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;ot(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:this.hash,number:this.number}}}class ti{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(t,e){this.provider=e;const r=Object.freeze(t.topics.slice());$(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:o,topics:s,transactionHash:a,transactionIndex:u}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:o,topics:s,transactionHash:a,transactionIndex:u}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return it(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return it(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return it(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class ei{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#Q;constructor(t,e){this.#Q=Object.freeze(t.logs.map((t=>new ti(t,e))));let r=Qn;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),$(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return this.#Q}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:o,blockNumber:s,logsBloom:a,logs:u,status:c,root:l}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:s,contractAddress:r,cumulativeGasUsed:Xn(this.cumulativeGasUsed),from:e,gasPrice:Xn(this.gasPrice),blobGasUsed:Xn(this.blobGasUsed),blobGasPrice:Xn(this.blobGasPrice),gasUsed:Xn(this.gasUsed),hash:n,index:i,logs:u,logsBloom:a,root:l,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return ii(this)}reorderedEvent(t){return it(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ni(this,t)}}class ri{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;#J;constructor(t,e){this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.#J=-1}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:o,from:s,nonce:a,data:u,signature:c,accessList:l,blobVersionedHashes:f}=this;return{_type:"TransactionResponse",accessList:l,blockNumber:t,blockHash:e,blobVersionedHashes:f,chainId:Xn(this.chainId),data:u,from:s,gasLimit:Xn(this.gasLimit),gasPrice:Xn(this.gasPrice),hash:n,maxFeePerGas:Xn(this.maxFeePerGas),maxPriorityFeePerGas:Xn(this.maxPriorityFeePerGas),maxFeePerBlobGas:Xn(this.maxFeePerBlobGas),nonce:a,signature:c,to:o,index:r,type:i,value:Xn(this.value)}}async getBlock(){let t=this.blockNumber;if(null==t){const e=await this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=await Z({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=null==t?1:t,n=null==e?0:e;let i=this.#J,o=-1,s=-1===i;const a=async()=>{if(s)return null;const{blockNumber:t,nonce:e}=await Z({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(s)return null;const n=await this.getTransaction();if(!n||null==n.blockNumber)for(-1===o&&(o=i-3,o<this.#J&&(o=this.#J));o<=t;){if(s)return null;const e=await this.provider.getBlock(o,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let n=0;n<e.length;n++){const o=await e.getTransaction(n);if(o.from===this.from&&o.nonce===this.nonce){if(s)return null;const e=await this.provider.getTransactionReceipt(o.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";o.data===this.data&&o.to===this.to&&o.value===this.value?n="repriced":"0x"===o.data&&o.from===o.to&&o.value===Qn&&(n="cancelled"),it(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:o.replaceableTransaction(i),hash:o.hash,receipt:e})}}o++}},u=t=>{if(null==t||0!==t.status)return t;it(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=await this.provider.getTransactionReceipt(this.hash);if(0===r)return u(c);if(c){if(await c.confirmations()>=r)return u(c)}else if(await a(),0===r)return null;const l=new Promise(((t,e)=>{const o=[],c=()=>{o.forEach((t=>t()))};if(o.push((()=>{s=!0})),n>0){const t=setTimeout((()=>{c(),e(nt("wait for transaction timeout","TIMEOUT"))}),n);o.push((()=>{clearTimeout(t)}))}const l=async n=>{if(await n.confirmations()>=r){c();try{t(u(n))}catch(t){e(t)}}};if(o.push((()=>{this.provider.off(this.hash,l)})),this.provider.on(this.hash,l),i>=0){const t=async()=>{try{await a()}catch(t){if(et(t,"TRANSACTION_REPLACED"))return c(),void e(t)}s||this.provider.once("block",t)};o.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return await l}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return it(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ii(this)}reorderedEvent(t){return it(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),it(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ni(this,t)}replaceableTransaction(t){ot(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new ri(this,this.provider);return e.#J=t,e}}function ni(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function ii(t){return{orphan:"drop-transaction",tx:t}}class oi{filter;emitter;#X;constructor(t,e,r){this.#X=e,$(this,{emitter:t,filter:r})}async removeListener(){null!=this.#X&&await this.emitter.off(this.filter,this.#X)}}class si extends ti{interface;fragment;args;constructor(t,e,r){super(t,t.provider),$(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class ai extends ti{error;constructor(t,e){super(t,t.provider),$(this,{error:e})}}class ui extends ei{#Y;constructor(t,e,r){super(r,e),this.#Y=t}get logs(){return super.logs.map((t=>{const e=t.topics.length?this.#Y.getEvent(t.topics[0]):null;if(e)try{return new si(t,this.#Y,e)}catch(e){return new ai(t,e)}return t}))}}class ci extends ri{#Y;constructor(t,e,r){super(r,e),this.#Y=t}async wait(t,e){const r=await super.wait(t,e);return null==r?null:new ui(this.#Y,this.provider,r)}}class li extends oi{log;constructor(t,e,r,n){super(t,e,r),$(this,{log:n})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class fi extends li{constructor(t,e,r,n,i){super(t,e,r,new si(i,t.interface,n)),$(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const hi=BigInt(0);function pi(t){return t&&"function"==typeof t.call}function di(t){return t&&"function"==typeof t.estimateGas}function yi(t){return t&&"function"==typeof t.resolveName}function gi(t){return t&&"function"==typeof t.sendTransaction}function bi(t){if(null!=t){if(yi(t))return t;if(t.provider)return t.provider}}class wi{#Z;fragment;constructor(t,e,r){if($(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=mi(t.runner,"resolveName"),i=yi(n)?n:null;this.#Z=async function(){const n=await Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>un(t,i)))):un(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}()}getTopicFilter(){return this.#Z}}function mi(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function vi(t){return null==t?null:t.provider||null}async function Ei(t,e){const r=Fe.dereference(t,"overrides");ot("object"==typeof r,"invalid overrides parameter","overrides",t);const n=Zn(r);return ot(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),ot(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}function Ai(t){const e=async function(e){const r=await Ei(e,["data"]);r.to=await t.getAddress(),r.from&&(r.from=await un(r.from,bi(t.runner)));const n=t.interface,i=Tt(r.value||hi,"overrides.value")===hi,o="0x"===(r.data||"0x");return!n.fallback||n.fallback.payable||!n.receive||o||i||ot(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),ot(n.fallback||o,"cannot send data to receive-only contract","overrides.data",r.data),ot(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),ot(n.fallback||o,"cannot send data to receive-only contract","overrides.data",r.data),r},r=async function(r){const n=t.runner;it(gi(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=await n.sendTransaction(await e(r)),o=vi(t.runner);return new ci(t.interface,o,i)},n=async t=>await r(t);return $(n,{_contract:t,estimateGas:async function(r){const n=mi(t.runner,"estimateGas");return it(di(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await n.estimateGas(await e(r))},populateTransaction:e,send:r,staticCall:async function(r){const n=mi(t.runner,"call");it(pi(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=await e(r);try{return await n.call(i)}catch(e){if(rt(e)&&e.data)throw t.interface.makeError(e.data,i);throw e}}}),n}const Si=Symbol.for("_ethersInternal_contract"),_i=new WeakMap;function ki(t){return _i.get(t[Si])}async function Ti(t,e){let r,n=null;if(Array.isArray(e)){const n=function(e){if(ht(e,32))return e;const r=t.interface.getEvent(e);return ot(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?ht(e,32)?r=[e]:(n=t.interface.getEvent(e),ot(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=await e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):ot(!1,"unknown event name","event",e);var i;return r=r.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()})),{fragment:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}async function Pi(t,e){const{subs:r}=ki(t);return r.get((await Ti(t,e)).tag)||null}async function Ii(t,e,r){const n=vi(t.runner);it(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:o,topics:s}=await Ti(t,r),{addr:a,subs:u}=ki(t);let c=u.get(o);if(!c){const e={address:a||t,topics:s},l=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(t){}if(n){const o=n,s=i?t.interface.decodeEventLog(i,e.data,e.topics):[];xi(t,r,s,(n=>new fi(t,n,r,o,e)))}else xi(t,r,[],(n=>new li(t,n,r,e)))};let f=[];c={tag:o,listeners:[],start:()=>{f.length||f.push(n.on(e,l))},stop:async()=>{if(0==f.length)return;let t=f;f=[],await Promise.all(t),n.off(e,l)}},u.set(o,c)}return c}let Oi=Promise.resolve();async function xi(t,e,r,n){try{await Oi}catch(t){}const i=async function(t,e,r,n){await Oi;const i=await Pi(t,e);if(!i)return!1;const o=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const o=Array.from(r);n&&o.push(n(i?null:e));try{e.call(t,...o)}catch(t){}return!i})),0===i.listeners.length&&(i.stop(),ki(t).subs.delete(i.tag)),o>0}(t,e,r,n);return Oi=i,await i}const Bi=["then"];class Ri{target;interface;runner;filters;[Si];fallback;constructor(t,e,r,n){ot("string"==typeof t||sn(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=qn.from(e);let o;$(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,Si,{value:{}});let s=null,a=null;if(n){const t=vi(r);a=new ci(this.interface,t,n)}let u=new Map;if("string"==typeof t)if(ht(t))s=t,o=Promise.resolve(t);else{const e=mi(r,"resolveName");if(!yi(e))throw nt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=e.resolveName(t).then((e=>{if(null==e)throw nt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return ki(this).addr=e,e}))}else o=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return ki(this).addr=t,t}));var c;c={addrPromise:o,addr:s,deployTx:a,subs:u},_i.set(this[Si],c);const l=new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||Bi.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(t){if(!et(t,"INVALID_ARGUMENT")||"key"!==t.argument)throw t}},has:(t,e)=>Bi.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))});return $(this,{filters:l}),$(this,{fallback:i.receive||i.fallback?Ai(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||Bi.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(t){if(!et(t,"INVALID_ARGUMENT")||"key"!==t.argument)throw t}},has:(t,e)=>"symbol"==typeof e||e in t||Bi.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(t){return new Ri(this.target,this.interface,t)}attach(t){return new Ri(t,this.interface,this.runner)}async getAddress(){return await ki(this).addrPromise}async getDeployedCode(){const t=vi(this.runner);it(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return"0x"===e?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(null!=await this.getDeployedCode())return this;const e=vi(this.runner);return it(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=async()=>{try{if(null!=await this.getDeployedCode())return t(this);e.once("block",n)}catch(t){r(t)}};n()}))}deploymentTransaction(){return ki(this).deployTx}getFunction(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return it(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=async function(...e){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=await Ei(e.pop()),i.from&&(i.from=await un(i.from,bi(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const o=await async function(t,e,r){const n=mi(t,"resolveName"),i=yi(n)?n:null;return await Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=Fe.dereference(e,t),"address"===t?un(e,i):e))))))}(t.runner,n.inputs,e);return Object.assign({},i,await Z({to:t.getAddress(),data:t.interface.encodeFunctionData(n,o)}))},i=async function(...t){const e=await s(...t);return 1===e.length?e[0]:e},o=async function(...e){const r=t.runner;it(gi(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=await r.sendTransaction(await n(...e)),o=vi(t.runner);return new ci(t.interface,o,i)},s=async function(...e){const i=mi(t.runner,"call");it(pi(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const o=await n(...e);let s="0x";try{s=await i.call(o)}catch(e){if(rt(e)&&e.data)throw t.interface.makeError(e.data,o);throw e}const a=r(...e);return t.interface.decodeFunctionResult(a,s)},a=async(...t)=>r(...t).constant?await i(...t):await o(...t);return $(a,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:async function(...e){const r=mi(t.runner,"estimateGas");return it(di(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await n(...e))},populateTransaction:n,send:o,staticCall:i,staticCallResult:s}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return it(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),a}(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getEvent(e,r);return it(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new wi(t,r(...e),e)};return $(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return it(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=ki(this),o=n||await i,{fragment:s,topics:a}=await Ti(this,t),u={address:o,topics:a,fromBlock:e,toBlock:r},c=vi(this.runner);return it(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await c.getLogs(u)).map((t=>{let e=s;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(t){}if(e)try{return new si(t,this.interface,e)}catch(e){return new ai(t,e)}return new ti(t,c)}))}async on(t,e){const r=await Ii(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await Ii(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await xi(this,t,e,null)}async listenerCount(t){if(t){const e=await Pi(this,t);return e?e.listeners.length:0}const{subs:e}=ki(this);let r=0;for(const{listeners:t}of e.values())r+=t.length;return r}async listeners(t){if(t){const e=await Pi(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=ki(this);let r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}async off(t,e){const r=await Pi(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),ki(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await Pi(this,t);if(!e)return this;e.stop(),ki(this).subs.delete(e.tag)}else{const{subs:t}=ki(this);for(const{tag:e,stop:r}of t.values())r(),t.delete(e)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){return class extends Ri{constructor(e,r=null){super(e,t,r)}}}static from(t,e,r){return null==r&&(r=null),new this(t,e,r)}}class Ni extends(function(){return Ri}()){}var Ui="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";const Ci=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Li=4;function Di(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,o=[0,1];for(let t=1;t<n;t++)o.push(i+=r());let s=r(),a=e;e+=s;let u=0,c=0;function l(){return 0==u&&(c=c<<8|t[e++],u=8),c>>--u&1}const f=2**31,h=f>>>1,p=h>>1,d=f-1;let y=0;for(let t=0;t<31;t++)y=y<<1|l();let g=[],b=0,w=f;for(;;){let t=Math.floor(((y-b+1)*i-1)/w),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<o[n]?r=n:e=n}if(0==e)break;g.push(e);let s=b+Math.floor(w*o[e]/i),a=b+Math.floor(w*o[e+1]/i)-1;for(;!((s^a)&h);)y=y<<1&d|l(),s=s<<1&d,a=a<<1&d|1;for(;s&~a&p;)y=y&h|y<<1&d>>>1|l(),s=s<<1^h,a=(a^h)<<1|h|1;b=s,w=1+a-s}let m=n-4;return g.map((e=>{switch(e-m){case 3:return m+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return m+256+(t[a++]<<8|t[a++]);case 1:return m+t[a++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,o=0,s=0,a=0;i<r;i++)a=a<<6|e[t.charCodeAt(i)],s+=6,s>=8&&(n[o++]=a>>(s-=8));return n}(t)))}function Mi(t){return 1&t?~t>>1:t>>1}function Fi(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=Mi(e());return r}function Hi(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function ji(t){return Vi((()=>{let e=Hi(t);if(e.length)return e}))}function Gi(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Wi(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(zi(r,t))}return e.flat()}function Vi(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function Ki(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)Fi(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Wi(t,e){let r=1+e(),n=e(),i=Vi(e);return Ki(i.length,1+t,e).flatMap(((t,e)=>{let[o,...s]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[o+e*r,s.map((t=>t+i))]}))}))}function zi(t,e){return Ki(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function qi(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function Qi(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function Ji(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}var Xi="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";const Yi=44032,Zi=4352,$i=4449,to=4519,eo=28,ro=21*eo,no=Yi+19*ro,io=Zi+19,oo=$i+21,so=to+eo;function ao(t){return t>>24&255}function uo(t){return 16777215&t}let co,lo,fo,ho;function po(t){return t>=Yi&&t<no}function yo(t,e){if(t>=Zi&&t<io&&e>=$i&&e<oo)return Yi+(t-Zi)*ro+(e-$i)*eo;if(po(t)&&e>to&&e<so&&(t-Yi)%eo==0)return t+(e-to);{let r=ho.get(t);return r&&(r=r.get(e),r)?r:-1}}function go(t){co||function(){let t=Di(Xi);co=new Map(ji(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),lo=new Set(Hi(t)),fo=new Map,ho=new Map;for(let[e,r]of Gi(t)){if(!lo.has(e)&&2==r.length){let[t,n]=r,i=ho.get(t);i||(i=new Map,ho.set(t,i)),i.set(n,e)}fo.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=co.get(t);r&&(n=!0,t|=r),e.push(t)}for(let n of t)for(;;){if(n<128)e.push(n);else if(po(n)){let t=n-Yi,e=t%ro/eo|0,r=t%eo;i(Zi+(t/ro|0)),i($i+e),r>0&&i(to+r)}else{let t=fo.get(n);t?r.push(...t):i(n)}if(!r.length)break;n=r.pop()}if(n&&e.length>1){let t=ao(e[0]);for(let r=1;r<e.length;r++){let n=ao(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=ao(e[--i]),t<=n)break}t=ao(e[r])}}return e}function bo(t){return go(t).map(uo)}function wo(t){return function(t){let e=[],r=[],n=-1,i=0;for(let o of t){let t=ao(o),s=uo(o);if(-1==n)0==t?n=s:e.push(s);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=s):r.push(s),i=t;else{let o=yo(n,s);o>=0?n=o:0==i&&0==t?(e.push(n),n=s):(r.push(s),i=t)}}return n>=0&&e.push(n,...r),e}(go(t))}const mo=45,vo=".",Eo=65039,Ao=1,So=t=>Array.from(t);function _o(t,e){return t.P.has(e)||t.Q.has(e)}class ko extends Array{get is_emoji(){return!0}}let To,Po,Io,Oo,xo,Bo,Ro,No,Uo,Co,Lo,Do;function Mo(){if(To)return;let t=Di(Ui);const e=()=>Hi(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));To=new Map(Gi(t)),Po=r(),Io=e(),Oo=new Set(e().map((t=>Io[t]))),Io=new Set(Io),xo=r(),Bo=r();let i=ji(t),o=t();const s=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Ro=Vi((e=>{let r=Vi(t).map((t=>t+96));if(r.length){let n=e>=o;return r[0]-=32,r=Qi(r),n&&(r=`Restricted[${r}]`),{N:r,P:s(),Q:s(),M:!t(),R:n}}})),No=r(),Uo=new Map;let a=e().concat(So(No)).sort(((t,e)=>t-e));a.forEach(((e,r)=>{let n=t(),i=a[r]=n?a[r-n]:{V:[],M:new Map};i.V.push(e),No.has(e)||Uo.set(e,i)}));for(let{V:t,M:e}of new Set(Uo.values())){let r=[];for(let e of t){let t=Ro.filter((t=>_o(t,e))),i=r.find((({G:e})=>t.some((t=>e.has(t)))));i||(i={G:new Set,V:[]},r.push(i)),i.V.push(e),n(i.G,t)}let i=r.flatMap((t=>So(t.G)));for(let{G:t,V:n}of r){let r=new Set(i.filter((e=>!t.has(e))));for(let t of n)e.set(t,r)}}Co=new Set;let u=new Set;const c=t=>Co.has(t)?u.add(t):Co.add(t);for(let t of Ro){for(let e of t.P)c(e);for(let e of t.Q)c(e)}for(let t of Co)Uo.has(t)||u.has(t)||Uo.set(t,Ao);n(Co,bo(Co)),Lo=function(t){let e=[],r=Hi(t);return function t({S:r,B:n},i,o){if(!(4&r&&o===i[i.length-1])){2&r&&(o=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],o)}}(function e(n){return{S:t(),B:Vi((()=>{let n=Hi(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>ko.from(t))).sort(Ji),Do=new Map;for(let t of Lo){let e=[Do];for(let r of t){let t=e.map((t=>{let e=t.get(r);return e||(e=new Map,t.set(r,e)),e}));r===Eo?e.push(...t):e=t}for(let r of e)r.V=t}}function Fo(t){return(Go(t)?"":`${Ho(jo([t]))} `)+qi(t)}function Ho(t){return`"${t}"‎`}function jo(t,e=1/0,r=qi){let n=[];var i;i=t[0],Mo(),Io.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let o=0,s=t.length;for(let e=0;e<s;e++){let i=t[e];Go(i)&&(n.push(Qi(t.slice(o,e))),n.push(r(i)),o=e+1)}return n.push(Qi(t.slice(o,s))),n.join("")}function Go(t){return Mo(),xo.has(t)}function Vo(t,e,r){if(!t)return[];Mo();let n=0;return t.split(vo).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),o={input:i,offset:n};n+=i.length+1;try{let t,n=o.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let o=Qo(t);if(o)i.length&&(n.push(e(i)),i=[]),n.push(r(o));else{let e=t.pop();if(Co.has(e))i.push(e);else{let t=To.get(e);if(t)i.push(...t);else if(!Po.has(e))throw Ko(e)}}}return i.length&&n.push(e(i)),n}(i,e,r),s=n.length;if(!s)throw new Error("empty label");let a=o.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(a),!(o.emoji=s>1||n[0].is_emoji)&&a.every((t=>t<128)))!function(t){if(t.length>=4&&t[2]==mo&&t[3]==mo)throw new Error(`invalid label extension: "${Qi(t.slice(0,4))}"`)}(a),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(Io.has(a[0]))throw zo("leading combining mark");for(let t=1;t<s;t++){let e=n[t];if(!e.is_emoji&&Io.has(e[0]))throw zo(`emoji + combining mark: "${Qi(n[t-1])} + ${jo([e[0]])}"`)}!function(t){let e=t[0],r=Ci.get(e);if(r)throw zo(`leading ${r}`);let n=t.length,i=-1;for(let o=1;o<n;o++){e=t[o];let n=Ci.get(e);if(n){if(i==o)throw zo(`${r} + ${n}`);i=o+1,r=n}}if(i==n)throw zo(`trailing ${r}`)}(a);let r=So(new Set(e)),[i]=function(t){let e=Ro;for(let r of t){let t=e.filter((t=>_o(t,r)));if(!t.length)throw Ro.some((t=>_o(t,r)))?Wo(e[0],r):Ko(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!_o(t,r))throw Wo(t,r);if(t.M){let t=bo(e);for(let e=1,r=t.length;e<r;e++)if(Oo.has(t[e])){let n=e+1;for(let i;n<r&&Oo.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${Fo(i)}`);if(n-e>Li)throw new Error(`excessive non-spacing marks: ${Ho(jo(t.slice(e-1,n)))} (${n-e}/${Li})`);e=n}}}(i,e),function(t,e){let r,n=[];for(let t of e){let e=Uo.get(t);if(e===Ao)return;if(e){let n=e.M.get(t);if(r=r?r.filter((t=>n.has(t))):So(n),!r.length)return}else n.push(t)}if(r)for(let e of r)if(n.every((t=>_o(e,t))))throw new Error(`whole-script confusable: ${t.N}/${e.N}`)}(i,r),t=i.N}else t="Emoji"}o.type=t}catch(t){o.error=t}return o}))}function Ko(t){return new Error(`disallowed character: ${Fo(t)}`)}function Wo(t,e){let r=Fo(e),n=Ro.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function zo(t){return new Error(`illegal placement: ${t}`)}function qo(t){return t.filter((t=>t!=Eo))}function Qo(t,e){let r,n=Do,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:o}=n;o&&(r=o,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const Jo=new Uint8Array(32);function Xo(t){return ot(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Yo(t){const e=nr(function(t){try{if(0===t.length)throw new Error("empty label");return function(t){return function(t){return t.map((({input:e,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==t.length?n:`Invalid label ${Ho(jo(e,63))}: ${n}`)}return Qi(n)})).join(vo)}(Vo(t,wo,qo))}(t)}catch(e){ot(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let t=0;t<e.length;t++)46===e[t]&&(r.push(Xo(e.slice(n,t))),n=t+1);return ot(n<e.length,"invalid ENS name; empty component","name",t),r.push(Xo(e.slice(n))),r}function Zo(t){ot("string"==typeof t,"invalid ENS name; not a string","name",t),ot(t.length,"invalid ENS name (empty label)","name",t);let e=Jo;const r=Yo(t);for(;r.length;)e=Pe(gt([e,Pe(r.pop())]));return yt(e)}function $o(t,e){const r=null!=e?e:63;return ot(r<=255,"DNS encoded label cannot exceed 255","length",r),yt(gt(Yo(t).map((e=>{ot(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}Jo.fill(0);class ts extends ae{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ie(this.buffer)}update(t){zt(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=se(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=ie(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){zt(this),qt(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=ie(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const es=(t,e,r)=>t&e^~t&r,rs=(t,e,r)=>t&e^t&r^e&r,ns=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]),is=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),os=new Uint32Array(64);class ss extends ts{constructor(){super(64,32,8,!1),this.A=0|is[0],this.B=0|is[1],this.C=0|is[2],this.D=0|is[3],this.E=0|is[4],this.F=0|is[5],this.G=0|is[6],this.H=0|is[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)os[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=os[t-15],r=os[t-2],n=oe(e,7)^oe(e,18)^e>>>3,i=oe(r,17)^oe(r,19)^r>>>10;os[t]=i+os[t-7]+n+os[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(oe(s,6)^oe(s,11)^oe(s,25))+es(s,a,u)+ns[t]+os[t]|0,l=(oe(r,2)^oe(r,13)^oe(r,22))+rs(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){os.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const as=ue((()=>new ss)),[us,cs]=(()=>re.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)))))(),ls=new Uint32Array(80),fs=new Uint32Array(80);class hs extends ts{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:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:l,Fl:f,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,s,a,u,c,l,f,h,p,d,y]}set(t,e,r,n,i,o,s,a,u,c,l,f,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|l,this.Fl=0|f,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)ls[r]=t.getUint32(e),fs[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|ls[t-15],r=0|fs[t-15],n=re.rotrSH(e,r,1)^re.rotrSH(e,r,8)^re.shrSH(e,r,7),i=re.rotrSL(e,r,1)^re.rotrSL(e,r,8)^re.shrSL(e,r,7),o=0|ls[t-2],s=0|fs[t-2],a=re.rotrSH(o,s,19)^re.rotrBH(o,s,61)^re.shrSH(o,s,6),u=re.rotrSL(o,s,19)^re.rotrBL(o,s,61)^re.shrSL(o,s,6),c=re.add4L(i,u,fs[t-7],fs[t-16]),l=re.add4H(c,n,a,ls[t-7],ls[t-16]);ls[t]=0|l,fs[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:l,El:f,Fh:h,Fl:p,Gh:d,Gl:y,Hh:g,Hl:b}=this;for(let t=0;t<80;t++){const e=re.rotrSH(l,f,14)^re.rotrSH(l,f,18)^re.rotrBH(l,f,41),w=re.rotrSL(l,f,14)^re.rotrSL(l,f,18)^re.rotrBL(l,f,41),m=l&h^~l&d,v=f&p^~f&y,E=re.add5L(b,w,v,cs[t],fs[t]),A=re.add5H(E,g,e,m,us[t],ls[t]),S=0|E,_=re.rotrSH(r,n,28)^re.rotrBH(r,n,34)^re.rotrBH(r,n,39),k=re.rotrSL(r,n,28)^re.rotrBL(r,n,34)^re.rotrBL(r,n,39),T=r&i^r&s^i&s,P=n&o^n&a^o&a;g=0|d,b=0|y,d=0|h,y=0|p,h=0|l,p=0|f,({h:l,l:f}=re.add(0|u,0|c,0|A,0|S)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const I=re.add3L(S,k,P);r=re.add3H(I,A,_,T),n=0|I}({h:r,l:n}=re.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=re.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=re.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=re.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:l,l:f}=re.add(0|this.Eh,0|this.El,0|l,0|f)),({h,l:p}=re.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=re.add(0|this.Gh,0|this.Gl,0|d,0|y)),({h:g,l:b}=re.add(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(r,n,i,o,s,a,u,c,l,f,h,p,d,y,g,b)}roundClean(){ls.fill(0),fs.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 ps=ue((()=>new hs)),ds=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function ys(t){switch(t){case"sha256":return as.create();case"sha512":return ps.create()}ot(!1,"invalid hashing algorithm name","algorithm",t)}ds.crypto||ds.msCrypto;const gs=function(t){return ys("sha256").update(t).digest()},bs=function(t){return ys("sha512").update(t).digest()};let ws=gs,ms=bs,vs=!1,Es=!1;function As(t){const e=lt(t,"data");return yt(ws(e))}function Ss(t){const e=lt(t,"data");return yt(ms(e))}As._=gs,As.lock=function(){vs=!0},As.register=function(t){if(vs)throw new Error("sha256 is locked");ws=t},Object.freeze(As),Ss._=bs,Ss.lock=function(){Es=!0},Ss.register=function(t){if(Es)throw new Error("sha512 is locked");ms=t},Object.freeze(As);const _s="0x0000000000000000000000000000000000000000000000000000000000000000",ks=BigInt(0),Ts=BigInt(1),Ps=BigInt(2),Is=BigInt(27),Os=BigInt(28),xs=BigInt(35),Bs={};function Rs(t){return vt(Rt(t),32)}class Ns{#$;#tt;#et;#rt;get r(){return this.#$}set r(t){ot(32===bt(t),"invalid r","value",t),this.#$=yt(t)}get s(){return this.#tt}set s(t){ot(32===bt(t),"invalid s","value",t);const e=yt(t);ot(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),this.#tt=e}get v(){return this.#et}set v(t){const e=xt(t,"value");ot(27===e||28===e,"invalid v","v",t),this.#et=e}get networkV(){return this.#rt}get legacyChainId(){const t=this.networkV;return null==t?null:Ns.getChainId(t)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=lt(this.s);return this.yParity&&(t[0]|=128),yt(t)}get compactSerialized(){return gt([this.r,this.yParityAndS])}get serialized(){return gt([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(t,e,r,n){ut(t,Bs,"Signature"),this.#$=e,this.#tt=r,this.#et=n,this.#rt=null}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new Ns(Bs,this.r,this.s,this.v);return this.networkV&&(t.#rt=this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Tt(t,"v");return e==Is||e==Os?ks:(ot(e>=xs,"invalid EIP-155 v","v",t),(e-xs)/Ps)}static getChainIdV(t,e){return Tt(t)*Ps+BigInt(35+e-27)}static getNormalizedV(t){const e=Tt(t);return e===ks||e===Is?27:e===Ts||e===Os?28:(ot(e>=xs,"invalid v","v",t),e&Ts?27:28)}static from(t){function e(e,r){ot(e,r,"signature",t)}if(null==t)return new Ns(Bs,_s,_s,27);if("string"==typeof t){const r=lt(t,"signature");if(64===r.length){const t=yt(r.slice(0,32)),e=r.slice(32,64),n=128&e[0]?28:27;return e[0]&=127,new Ns(Bs,t,yt(e),n)}if(65===r.length){const t=yt(r.slice(0,32)),n=r.slice(32,64);e(!(128&n[0]),"non-canonical s");const i=Ns.getNormalizedV(r[64]);return new Ns(Bs,t,yt(n),i)}e(!1,"invalid raw signature length")}if(t instanceof Ns)return t.clone();const r=t.r;e(null!=r,"missing r");const n=Rs(r),i=function(t,r){if(null!=t)return Rs(t);if(null!=r){e(ht(r,32),"invalid yParityAndS");const t=lt(r);return t[0]&=127,yt(t)}e(!1,"missing s")}(t.s,t.yParityAndS);e(!(128&lt(i)[0]),"non-canonical s");const{networkV:o,v:s}=function(t,r,n){if(null!=t){const e=Tt(t);return{networkV:e>=xs?e:void 0,v:Ns.getNormalizedV(e)}}if(null!=r)return e(ht(r,32),"invalid yParityAndS"),{v:128&lt(r)[0]?28:27};if(null!=n){switch(xt(n,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),a=new Ns(Bs,n,i,s);return o&&(a.#rt=o),e(null==t.yParity||xt(t.yParity,"sig.yParity")===a.yParity,"yParity mismatch"),e(null==t.yParityAndS||t.yParityAndS===a.yParityAndS,"yParityAndS mismatch"),a}}function Us(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Cs(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 Ls(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")}const Ds="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Ms=t=>t instanceof Uint8Array,Fs=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Hs=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function js(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!Ms(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Gs{clone(){return this._cloneInto()}}function Vs(t){const e=e=>t().update(js(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ks(t=32){if(Ds&&"function"==typeof Ds.getRandomValues)return Ds.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Ws extends Gs{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Fs(this.buffer)}update(t){Ls(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=js(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=Fs(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ls(this),function(t,e){Cs(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=Fs(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const zs=(t,e,r)=>t&e^~t&r,qs=(t,e,r)=>t&e^t&r^e&r,Qs=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]),Js=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xs=new Uint32Array(64);class Ys extends Ws{constructor(){super(64,32,8,!1),this.A=0|Js[0],this.B=0|Js[1],this.C=0|Js[2],this.D=0|Js[3],this.E=0|Js[4],this.F=0|Js[5],this.G=0|Js[6],this.H=0|Js[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)Xs[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Xs[t-15],r=Xs[t-2],n=Hs(e,7)^Hs(e,18)^e>>>3,i=Hs(r,17)^Hs(r,19)^r>>>10;Xs[t]=i+Xs[t-7]+n+Xs[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(Hs(s,6)^Hs(s,11)^Hs(s,25))+zs(s,a,u)+Qs[t]+Xs[t]|0,l=(Hs(r,2)^Hs(r,13)^Hs(r,22))+qs(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){Xs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Zs=Vs((()=>new Ys)),$s=(BigInt(0),BigInt(1)),ta=BigInt(2),ea=t=>t instanceof Uint8Array,ra=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function na(t){if(!ea(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=ra[t[r]];return e}function ia(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function oa(t){if("string"!=typeof t)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 r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");r[e]=o}return r}function sa(t){return ia(na(t))}function aa(t){if(!ea(t))throw new Error("Uint8Array expected");return ia(na(Uint8Array.from(t).reverse()))}function ua(t,e){return oa(t.toString(16).padStart(2*e,"0"))}function ca(t,e){return ua(t,e).reverse()}function la(t,e,r){let n;if("string"==typeof e)try{n=oa(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!ea(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function fa(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!ea(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}const ha=t=>(ta<<BigInt(t-1))-$s,pa=t=>new Uint8Array(t),da=t=>Uint8Array.from(t);function ya(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=pa(t),i=pa(t),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...t)=>r(i,n,...t),u=(t=pa())=>{i=a(da([0]),t),n=a(),0!==t.length&&(i=a(da([1]),t),n=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=a();const e=n.slice();r.push(e),t+=n.length}return fa(...r)};return(t,e)=>{let r;for(s(),u(t);!(r=e(c()));)u();return s(),r}}const ga={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function ba(t,e,r={}){const n=(e,r,n)=>{const i=ga[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}const wa=BigInt(0),ma=BigInt(1),va=BigInt(2),Ea=BigInt(3),Aa=BigInt(4),Sa=BigInt(5),_a=BigInt(8);function ka(t,e){const r=t%e;return r>=wa?r:e+r}function Ta(t,e,r){if(r<=wa||e<wa)throw new Error("Expected power/modulo > 0");if(r===ma)return wa;let n=ma;for(;e>wa;)e&ma&&(n=n*t%r),t=t*t%r,e>>=ma;return n}function Pa(t,e,r){let n=t;for(;e-- >wa;)n*=n,n%=r;return n}function Ia(t,e){if(t===wa||e<=wa)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ka(t,e),n=e,i=wa,o=ma,s=ma,a=wa;for(;r!==wa;){const t=n/r,e=n%r,u=i-s*t,c=o-a*t;n=r,r=e,i=s,o=a,s=u,a=c}if(n!==ma)throw new Error("invert: does not exist");return ka(i,e)}BigInt(9),BigInt(16);const Oa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xa(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Ba(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ra(t){const e=Ba(t);return e+Math.ceil(e/2)}class Na extends Gs{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Us(t.outputLen),Us(t.blockLen)}(t);const r=js(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ls(this),this.iHash.update(t),this}digestInto(t){Ls(this),Cs(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ua=(t,e,r)=>new Na(t,e).update(r).digest();Ua.create=(t,e)=>new Na(t,e);const Ca=BigInt(0),La=BigInt(1);function Da(t){return ba(t.Fp,Oa.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),ba(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xa(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const{bytesToNumberBE:Ma,hexToBytes:Fa}=t,Ha={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=Ha;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Ma(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=Ha,r="string"==typeof t?Fa(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=Ha._parseInt(r.subarray(2)),{d:s,l:a}=Ha._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),u=r(s);return`30${r(s+o+4)}02${u}${i}02${a}${n}`}},ja=BigInt(0),Ga=BigInt(1),Va=(BigInt(2),BigInt(3));function Ka(t){const e=function(t){const e=Da(t);return ba(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return ka(t,n)}function a(t){return Ia(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:l,isWithinCurveOrder:f}=function(t){const e=function(t){const e=Da(t);ba(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return fa(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&ja<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=na(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:sa(la("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=ka(s,o)),a(s),s}const c=new Map;function l(t){if(!(t instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof f)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?f.ZERO:new f(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(f.fromAffine)}static fromHex(t){const e=f.fromAffine(i(la("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return f.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){l(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new f(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,Va),{px:o,py:s,pz:a}=this;let u=r.ZERO,c=r.ZERO,l=r.ZERO,h=r.mul(o,o),p=r.mul(s,s),d=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),l=r.mul(o,a),l=r.add(l,l),u=r.mul(t,l),c=r.mul(i,d),c=r.add(u,c),u=r.sub(p,c),c=r.add(p,c),c=r.mul(u,c),u=r.mul(y,u),l=r.mul(i,l),d=r.mul(t,d),y=r.sub(h,d),y=r.mul(t,y),y=r.add(y,l),l=r.add(h,h),h=r.add(l,h),h=r.add(h,d),h=r.mul(h,y),c=r.add(c,h),d=r.mul(s,a),d=r.add(d,d),h=r.mul(d,y),u=r.sub(u,h),l=r.mul(d,p),l=r.add(l,l),l=r.add(l,l),new f(u,c,l)}add(t){l(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=r.ZERO,h=r.ZERO,p=r.ZERO;const d=e.a,y=r.mul(e.b,Va);let g=r.mul(n,s),b=r.mul(i,a),w=r.mul(o,u),m=r.add(n,i),v=r.add(s,a);m=r.mul(m,v),v=r.add(g,b),m=r.sub(m,v),v=r.add(n,o);let E=r.add(s,u);return v=r.mul(v,E),E=r.add(g,w),v=r.sub(v,E),E=r.add(i,o),c=r.add(a,u),E=r.mul(E,c),c=r.add(b,w),E=r.sub(E,c),p=r.mul(d,v),c=r.mul(y,w),p=r.add(c,p),c=r.sub(b,p),p=r.add(b,p),h=r.mul(c,p),b=r.add(g,g),b=r.add(b,g),w=r.mul(d,w),v=r.mul(y,v),b=r.add(b,w),w=r.sub(g,w),w=r.mul(d,w),v=r.add(v,w),g=r.mul(b,v),h=r.add(h,g),g=r.mul(E,v),c=r.mul(m,c),c=r.sub(c,g),g=r.mul(m,b),p=r.mul(E,p),p=r.add(p,g),new f(c,h,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(f.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(f.fromAffine)}))}multiplyUnsafe(t){const n=f.ZERO;if(t===ja)return n;if(a(t),t===Ga)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:u,k2:c}=i.splitScalar(t),l=n,h=n,d=this;for(;s>ja||c>ja;)s&Ga&&(l=l.add(d)),c&Ga&&(h=h.add(d)),d=d.double(),s>>=Ga,c>>=Ga;return o&&(l=l.negate()),u&&(h=h.negate()),h=new f(r.mul(h.px,i.beta),h.py,h.pz),l.add(h)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:u}=s.splitScalar(o);let{p:c,f:l}=this.wNAF(e),{p:h,f:d}=this.wNAF(u);c=p.constTimeNegate(t,c),h=p.constTimeNegate(a,h),h=new f(r.mul(h.px,s.beta),h.py,h.pz),n=c.add(h),i=l.add(d)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return f.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=f.BASE,i=(t,e)=>e!==ja&&e!==Ga&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===Ga)return!0;if(r)return r(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===Ga?this:r?r(f,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(f,this,t)}toHex(t=!0){return na(this.toRawBytes(t))}}f.BASE=new f(e.Gx,e.Gy,r.ONE),f.ZERO=new f(r.ZERO,r.ONE,r.ZERO);const h=e.nBitLength,p=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>Ca;)r&La&&(n=n.add(i)),i=i.double(),r>>=La;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,i,o){const{windows:s,windowSize:a}=n(e);let u=t.ZERO,c=t.BASE;const l=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let n=Number(o&l);o>>=h,n>a&&(n-=f,o+=La);const s=e,p=e+Math.abs(n)-1,d=t%2!=0,y=n<0;0===n?c=c.add(r(d,i[s])):u=u.add(r(y,i[p]))}return{p:u,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,i),1!==i&&e.set(t,n(o))),this.wNAF(i,o,r)}}}(f,e.endo?Math.ceil(h/2):h);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:s}}({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=fa;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===o&&4===n)return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=sa(s);if(!(ja<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=l(t);let i=r.sqrt(e);return!(1&~n)!=((i&Ga)===Ga)&&(i=r.neg(i)),{x:t,y:i}}var a}}),h=t=>na(ua(t,e.nByteLength));function p(t){return t>n>>Ga}const d=(t,e,r)=>sa(t.slice(e,r));class y{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=la("compactSignature",t,2*r),new y(d(t,0,r),d(t,r,2*r))}static fromDER(t){const{r:e,s:r}=Ha.toSig(la("DER",t));return new y(e,r)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new y(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,c=m(la("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const l=2===o||3===o?n+e.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&o?"03":"02",p=u.fromHex(f+h(l)),d=a(l),y=s(-c*d),g=s(i*d),b=u.BASE.multiplyAndAddUnsafe(p,y,g);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return oa(this.toDERHex())}toDERHex(){return Ha.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return oa(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const g={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=Ra(e.n);return function(t,e,r=!1){const n=t.length,i=Ba(e),o=Ra(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=ka(r?sa(t):aa(t),e-ma)+ma;return r?ca(s,i):ua(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function b(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof u}const w=e.bits2int||function(t){const r=sa(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},m=e.bits2int_modN||function(t){return s(w(t))},v=ha(e.nBitLength);function E(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(ja<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return ua(t,e.nByteLength)}const A={lowS:e.lowS,prehash:!1},S={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(b(t))throw new Error("first arg must be private key");if(!b(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,n,i=A){const{seed:o,k2sig:l}=function(t,n,i=A){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=e;let{lowS:h,prehash:d,extraEntropy:g}=i;null==h&&(h=!0),t=la("msgHash",t),d&&(t=la("prehashed msgHash",o(t)));const b=m(t),v=c(n),S=[E(v),E(b)];if(null!=g){const t=!0===g?l(r.BYTES):g;S.push(la("extraEntropy",t))}const _=fa(...S),k=b;return{seed:_,k2sig:function(t){const e=w(t);if(!f(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=s(n.x);if(i===ja)return;const o=s(r*s(k+i*v));if(o===ja)return;let c=(n.x===i?0:2)|Number(n.y&Ga),l=o;return h&&p(o)&&(l=function(t){return p(t)?s(-t):t}(o),c^=1),new y(i,l,c)}}}(t,n,i),h=e;return ya(h.hash.outputLen,h.nByteLength,h.hmac)(o,l)},verify:function(t,r,n,i=S){const o=t;if(r=la("msgHash",r),n=la("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:l}=i;let f,h;try{if("string"==typeof o||o instanceof Uint8Array)try{f=y.fromDER(o)}catch(t){if(!(t instanceof Ha.Err))throw t;f=y.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;f=new y(t,e)}}h=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&f.hasHighS())return!1;l&&(r=e.hash(r));const{r:p,s:d}=f,g=m(r),b=a(d),w=s(g*b),v=s(p*b),E=u.BASE.multiplyAndAddUnsafe(h,w,v)?.toAffine();return!!E&&s(E.x)===p},ProjectivePoint:u,Signature:y,utils:g}}function Wa(t){return{hash:t,hmac:(e,...r)=>Ua(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Ms(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:Ks}}BigInt(4);const za=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),qa=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qa=BigInt(1),Ja=BigInt(2),Xa=(t,e)=>(t+e/Ja)/e;const Ya=function(t,e,r=!1,n={}){if(t<=wa)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=xa(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=function(t){if(t%Aa===Ea){const e=(t+ma)/Aa;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%_a===Sa){const e=(t-Sa)/_a;return function(t,r){const n=t.mul(r,va),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,va),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-ma)/va;let r,n,i;for(r=t-ma,n=0;r%va===wa;r/=va,n++);for(i=va;i<t&&Ta(i,e,t)!==t-ma;i++);if(1===n){const e=(t+ma)/Aa;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const o=(r+ma)/va;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,i),r),c=t.pow(s,o),l=t.pow(s,r);for(;!t.eql(l,t.ONE);){if(t.eql(l,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(l);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,ma<<BigInt(a-e-1));u=t.sqr(r),c=t.mul(c,r),l=t.mul(l,u),a=e}return c}}(t)}(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:ha(i),ZERO:wa,ONE:ma,create:e=>ka(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return wa<=e&&e<t},is0:t=>t===wa,isOdd:t=>(t&ma)===ma,neg:e=>ka(-e,t),eql:(t,e)=>t===e,sqr:e=>ka(e*e,t),add:(e,r)=>ka(e+r,t),sub:(e,r)=>ka(e-r,t),mul:(e,r)=>ka(e*r,t),pow:(t,e)=>function(t,e,r){if(r<wa)throw new Error("Expected power > 0");if(r===wa)return t.ONE;if(r===ma)return e;let n=t.ONE,i=e;for(;r>wa;)r&ma&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ma;return n}(a,t,e),div:(e,r)=>ka(e*Ia(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Ia(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?ca(t,o):ua(t,o),fromBytes:t=>{if(t.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return r?aa(t):sa(t)}});return Object.freeze(a)}(za,void 0,void 0,{sqrt:function(t){const e=za,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,l=c*c*t%e,f=Pa(l,r,e)*l%e,h=Pa(f,r,e)*l%e,p=Pa(h,Ja,e)*c%e,d=Pa(p,i,e)*p%e,y=Pa(d,o,e)*d%e,g=Pa(y,a,e)*y%e,b=Pa(g,u,e)*g%e,w=Pa(b,a,e)*y%e,m=Pa(w,r,e)*l%e,v=Pa(m,s,e)*d%e,E=Pa(v,n,e)*c%e,A=Pa(E,Ja,e);if(!Ya.eql(Ya.sqr(A),t))throw new Error("Cannot find square root");return A}}),Za=function(t,e){const r=e=>Ka({...t,...Wa(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:Ya,n:qa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=qa,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Qa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=Xa(o*t,e),u=Xa(-n*t,e);let c=ka(t-a*r-u*i,e),l=ka(-a*n-u*o,e);const f=c>s,h=l>s;if(f&&(c=e-c),h&&(l=e-l),c>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:c,k2neg:h,k2:l}}}},Zs);BigInt(0),Za.ProjectivePoint;class $a{#nt;constructor(t){ot(32===bt(t),"invalid private key","privateKey","[REDACTED]"),this.#nt=yt(t)}get privateKey(){return this.#nt}get publicKey(){return $a.computePublicKey(this.#nt)}get compressedPublicKey(){return $a.computePublicKey(this.#nt,!0)}sign(t){ot(32===bt(t),"invalid digest length","digest",t);const e=Za.sign(ft(t),ft(this.#nt),{lowS:!0});return Ns.from({r:Bt(e.r,32),s:Bt(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=$a.computePublicKey(t);return yt(Za.getSharedSecret(ft(this.#nt),lt(e),!1))}static computePublicKey(t,e){let r=lt(t,"key");if(32===r.length)return yt(Za.getPublicKey(r,!!e));if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return yt(Za.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){ot(32===bt(t),"invalid digest length","digest",t);const r=Ns.from(e);let n=Za.Signature.fromCompact(ft(gt([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(ft(t));return ot(null!=i,"invalid signautre for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(t,e,r){const n=Za.ProjectivePoint.fromHex($a.computePublicKey(t).substring(2)),i=Za.ProjectivePoint.fromHex($a.computePublicKey(e).substring(2));return"0x"+n.add(i).toHex(!!r)}}function tu(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function eu(t,e,r){let n=0;for(let i=0;i<r;i++)n=256*n+t[e+i];return n}function ru(t,e,r,n){const i=[];for(;r<e+1+n;){const o=nu(t,r);i.push(o.result),it((r+=o.consumed)<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:t,length:n,offset:e})}return{consumed:1+n,result:i}}function nu(t,e){it(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{it(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const n=t[e]-247;r(e+1+n);const i=eu(t,e+1,n);return r(e+1+n+i),ru(t,e,e+1+n,n+i)}if(t[e]>=192){const n=t[e]-192;return r(e+1+n),ru(t,e,e+1,n)}if(t[e]>=184){const n=t[e]-183;r(e+1+n);const i=eu(t,e+1,n);return r(e+1+n+i),{consumed:1+n+i,result:yt(t.slice(e+1+n,e+1+n+i))}}if(t[e]>=128){const n=t[e]-128;return r(e+1+n),{consumed:1+n,result:yt(t.slice(e+1,e+1+n))}}return{consumed:1,result:tu(t[e])}}function iu(t){const e=lt(t,"data"),r=nu(e,0);return ot(r.consumed===e.length,"unexpected junk after rlp payload","data",t),r.result}function ou(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function su(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat(su(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=ou(e.length);return r.unshift(247+r.length),r.concat(e)}const e=Array.prototype.slice.call(lt(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=ou(e.length);return r.unshift(183+r.length),r.concat(e)}const au="0123456789abcdef";function uu(t){let e="0x";for(const r of su(t))e+=au[r>>4],e+=au[15&r];return e}const cu=BigInt(0),lu=BigInt(2),fu=BigInt(27),hu=BigInt(28),pu=BigInt(35),du=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),yu=131072;function gu(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=As(e).substring(4),"0x"+r}function bu(t){return"0x"===t?null:Ue(t)}function wu(t,e){try{return kn(t)}catch(r){ot(!1,r.message,e,t)}}function mu(t,e){return"0x"===t?0:xt(t,e)}function vu(t,e){if("0x"===t)return cu;const r=Tt(t,e);return ot(r<=du,"value exceeds uint size",e,r),r}function Eu(t,e){const r=Tt(t,"value"),n=Rt(r);return ot(n.length<=32,"value too large",`tx.${e}`,r),n}function Au(t){return kn(t).map((t=>[t.address,t.storageKeys]))}function Su(t,e){ot(Array.isArray(t),`invalid ${e}`,"value",t);for(let e=0;e<t.length;e++)ot(ht(t[e],32),"invalid ${ param } hash",`value[${e}]`,t[e]);return t}function _u(t,e){let r;try{if(r=mu(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(t){ot(!1,"invalid yParity","yParity",e[0])}const n=vt(e[1],32),i=vt(e[2],32),o=Ns.from({r:n,s:i,yParity:r});t.signature=o}class ku{#it;#ot;#e;#st;#at;#ut;#ct;#lt;#ft;#ht;#pt;#dt;#yt;#gt;#bt;#wt;get type(){return this.#it}set type(t){switch(t){case null:this.#it=null;break;case 0:case"legacy":this.#it=0;break;case 1:case"berlin":case"eip-2930":this.#it=1;break;case 2:case"london":case"eip-1559":this.#it=2;break;case 3:case"cancun":case"eip-4844":this.#it=3;break;default:ot(!1,"unsupported transaction type","type",t)}}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 t=this.#ot;return null==t&&3===this.type?Hn:t}set to(t){this.#ot=null==t?null:Ue(t)}get nonce(){return this.#st}set nonce(t){this.#st=xt(t,"value")}get gasLimit(){return this.#at}set gasLimit(t){this.#at=Tt(t)}get gasPrice(){const t=this.#ut;return null!=t||0!==this.type&&1!==this.type?t:cu}set gasPrice(t){this.#ut=null==t?null:Tt(t,"gasPrice")}get maxPriorityFeePerGas(){const t=this.#ct;return null==t?2===this.type||3===this.type?cu:null:t}set maxPriorityFeePerGas(t){this.#ct=null==t?null:Tt(t,"maxPriorityFeePerGas")}get maxFeePerGas(){const t=this.#lt;return null==t?2===this.type||3===this.type?cu:null:t}set maxFeePerGas(t){this.#lt=null==t?null:Tt(t,"maxFeePerGas")}get data(){return this.#e}set data(t){this.#e=yt(t)}get value(){return this.#ft}set value(t){this.#ft=Tt(t,"value")}get chainId(){return this.#ht}set chainId(t){this.#ht=Tt(t)}get signature(){return this.#pt||null}set signature(t){this.#pt=null==t?null:Ns.from(t)}get accessList(){const t=this.#dt||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){this.#dt=null==t?null:kn(t)}get maxFeePerBlobGas(){const t=this.#yt;return null==t&&3===this.type?cu:t}set maxFeePerBlobGas(t){this.#yt=null==t?null:Tt(t,"maxFeePerBlobGas")}get blobVersionedHashes(){let t=this.#gt;return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){ot(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)ot(ht(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}this.#gt=t}get blobs(){return null==this.#wt?null:this.#wt.map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void(this.#wt=null);const e=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(pt(i)){it(this.#bt,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=lt(i);if(ot(t.length<=yu,"blob is too large",`blobs[${n}]`,i),t.length!==yu){const e=new Uint8Array(yu);e.set(t),t=e}const o=this.#bt.blobToKzgCommitment(t),s=yt(this.#bt.computeBlobKzgProof(t,o));e.push({data:yt(t),commitment:yt(o),proof:s}),r.push(gu(1,o))}else{const t=yt(i.commitment);e.push({data:yt(i.data),commitment:t,proof:yt(i.proof)}),r.push(gu(1,t))}}this.#wt=e,this.#gt=r}get kzg(){return this.#bt}set kzg(t){this.#bt=t}constructor(){this.#it=null,this.#ot=null,this.#st=0,this.#at=cu,this.#ut=null,this.#ct=null,this.#lt=null,this.#e="0x",this.#ft=cu,this.#ht=cu,this.#pt=null,this.#dt=null,this.#yt=null,this.#gt=null,this.#wt=null,this.#bt=null}get hash(){return null==this.signature?null:Pe(this.#mt(!0,!1))}get unsignedHash(){return Pe(this.unsignedSerialized)}get from(){return null==this.signature?null:(t=this.unsignedHash,e=this.signature,function(t){let e;return e="string"==typeof t?$a.computePublicKey(t,!1):t.publicKey,Ue(Pe("0x"+e.substring(4)).substring(26))}($a.recoverPublicKey(t,e)));var t,e}get fromPublicKey(){return null==this.signature?null:$a.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}#mt(t,e){it(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[Eu(t.nonce,"nonce"),Eu(t.gasPrice||0,"gasPrice"),Eu(t.gasLimit,"gasLimit"),t.to||"0x",Eu(t.value,"value"),t.data];let n=cu;if(t.chainId!=cu)n=Tt(t.chainId,"tx.chainId"),ot(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==cu&&(r.push(Rt(n)),r.push("0x"),r.push("0x")),uu(r);let i=BigInt(27+e.yParity);return n!==cu?i=Ns.getChainIdV(n,e.v):BigInt(e.v)!==i&&ot(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(Rt(i)),r.push(Rt(e.r)),r.push(Rt(e.s)),uu(r)}(this,r);case 1:return function(t,e){const r=[Eu(t.chainId,"chainId"),Eu(t.nonce,"nonce"),Eu(t.gasPrice||0,"gasPrice"),Eu(t.gasLimit,"gasLimit"),t.to||"0x",Eu(t.value,"value"),t.data,Au(t.accessList||[])];return e&&(r.push(Eu(e.yParity,"recoveryParam")),r.push(Rt(e.r)),r.push(Rt(e.s))),gt(["0x01",uu(r)])}(this,r);case 2:return function(t,e){const r=[Eu(t.chainId,"chainId"),Eu(t.nonce,"nonce"),Eu(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Eu(t.maxFeePerGas||0,"maxFeePerGas"),Eu(t.gasLimit,"gasLimit"),t.to||"0x",Eu(t.value,"value"),t.data,Au(t.accessList||[])];return e&&(r.push(Eu(e.yParity,"yParity")),r.push(Rt(e.r)),r.push(Rt(e.s))),gt(["0x02",uu(r)])}(this,r);case 3:return function(t,e,r){const n=[Eu(t.chainId,"chainId"),Eu(t.nonce,"nonce"),Eu(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Eu(t.maxFeePerGas||0,"maxFeePerGas"),Eu(t.gasLimit,"gasLimit"),t.to||Hn,Eu(t.value,"value"),t.data,Au(t.accessList||[]),Eu(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Su(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(Eu(e.yParity,"yParity")),n.push(Rt(e.r)),n.push(Rt(e.s)),r)?gt(["0x03",uu([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):gt(["0x03",uu(n)])}(this,r,e?this.blobs:null)}it(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#mt(!0,!0)}get unsignedSerialized(){return this.#mt(!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,r=null!=this.accessList,n=null!=this.#yt||this.#gt;null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&it(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),it(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),it(0!==this.type||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):e?i.push(2):t?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return ku.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(null==t)return new ku;if("string"==typeof t){const e=lt(t);if(e[0]>=127)return ku.from(function(t){const e=iu(t);ot(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:mu(e[0],"nonce"),gasPrice:vu(e[1],"gasPrice"),gasLimit:vu(e[2],"gasLimit"),to:bu(e[3]),value:vu(e[4],"value"),data:yt(e[5]),chainId:cu};if(6===e.length)return r;const n=vu(e[6],"v"),i=vu(e[7],"r"),o=vu(e[8],"s");if(i===cu&&o===cu)r.chainId=n;else{let t=(n-pu)/lu;t<cu&&(t=cu),r.chainId=t,ot(t!==cu||n===fu||n===hu,"non-canonical legacy v","v",e[6]),r.signature=Ns.from({r:vt(e[7],32),s:vt(e[8],32),v:n})}return r}(e));switch(e[0]){case 1:return ku.from(function(t){const e=iu(lt(t).slice(1));ot(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",yt(t));const r={type:1,chainId:vu(e[0],"chainId"),nonce:mu(e[1],"nonce"),gasPrice:vu(e[2],"gasPrice"),gasLimit:vu(e[3],"gasLimit"),to:bu(e[4]),value:vu(e[5],"value"),data:yt(e[6]),accessList:wu(e[7],"accessList")};return 8===e.length||_u(r,e.slice(8)),r}(e));case 2:return ku.from(function(t){const e=iu(lt(t).slice(1));ot(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",yt(t));const r={type:2,chainId:vu(e[0],"chainId"),nonce:mu(e[1],"nonce"),maxPriorityFeePerGas:vu(e[2],"maxPriorityFeePerGas"),maxFeePerGas:vu(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:vu(e[4],"gasLimit"),to:bu(e[5]),value:vu(e[6],"value"),data:yt(e[7]),accessList:wu(e[8],"accessList")};return 9===e.length||_u(r,e.slice(9)),r}(e));case 3:return ku.from(function(t){let e=iu(lt(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],o=e[3];ot(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),ot(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),ot(Array.isArray(o),"invalid network format: proofs not an array","fields[3]",o),ot(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),ot(t.length===o.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:o[r]});e=e[0]}ot(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",yt(t));const i={type:3,chainId:vu(e[0],"chainId"),nonce:mu(e[1],"nonce"),maxPriorityFeePerGas:vu(e[2],"maxPriorityFeePerGas"),maxFeePerGas:vu(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:vu(e[4],"gasLimit"),to:bu(e[5]),value:vu(e[6],"value"),data:yt(e[7]),accessList:wu(e[8],"accessList"),maxFeePerBlobGas:vu(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),ot(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),ot(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let e=0;e<i.blobVersionedHashes.length;e++)ot(ht(i.blobVersionedHashes[e],32),`invalid blobVersionedHash at index ${e}: must be length 32`,"data",t);return 11===e.length||_u(i,e.slice(11)),i}(e))}it(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new ku;return null!=t.type&&(e.type=t.type),null!=t.to&&(e.to=t.to),null!=t.nonce&&(e.nonce=t.nonce),null!=t.gasLimit&&(e.gasLimit=t.gasLimit),null!=t.gasPrice&&(e.gasPrice=t.gasPrice),null!=t.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),null!=t.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null!=t.maxFeePerBlobGas&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),null!=t.data&&(e.data=t.data),null!=t.value&&(e.value=t.value),null!=t.chainId&&(e.chainId=t.chainId),null!=t.signature&&(e.signature=Ns.from(t.signature)),null!=t.accessList&&(e.accessList=t.accessList),null!=t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes),null!=t.kzg&&(e.kzg=t.kzg),null!=t.blobs&&(e.blobs=t.blobs),null!=t.hash&&(ot(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),ot(e.hash===t.hash,"hash mismatch","tx",t)),null!=t.from&&(ot(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),ot(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}}const Tu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const Pu=BigInt(58);function Iu(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):ot(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class Ou{name;constructor(t){$(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const xu=new RegExp("^(ipfs)://(.*)$","i"),Bu=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),xu,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class Ru{provider;address;name;#vt;#Et;constructor(t,e,r){$(this,{provider:t,address:e,name:r}),this.#vt=null,this.#Et=new Ni(e,["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)"],t)}async supportsWildcard(){return null==this.#vt&&(this.#vt=(async()=>{try{return await this.#Et.supportsInterface("0x9061b923")}catch(t){if(et(t,"CALL_EXCEPTION"))return!1;throw this.#vt=null,t}})()),await this.#vt}async#At(t,e){e=(e||[]).slice();const r=this.#Et.interface;e.unshift(Zo(this.name));let n=null;await this.supportsWildcard()&&(n=r.getFunction(t),it(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[$o(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=await this.#Et[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(t){if(!et(t,"CALL_EXCEPTION"))throw t}return null}async getAddress(t){if(null==t&&(t=60),60===t)try{const t=await this.#At("addr(bytes32)");return null==t||t===Hn?null:t}catch(t){if(et(t,"CALL_EXCEPTION"))return null;throw t}if(t>=0&&t<2147483648){let e=t+2147483648;const r=await this.#At("addr(bytes32,uint)",[e]);if(ht(r,20))return Ue(r)}let e=null;for(const r of this.provider.plugins)if(r instanceof Ou&&r.supportsCoinType(t)){e=r;break}if(null==e)return null;const r=await this.#At("addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=await e.decodeAddress(t,r);if(null!=n)return n;it(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await this.#At("text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}async getContentHash(){const t=await this.#At("contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=lt(t);let r=Ot(e),n="";for(;r;)n=Tu[Number(r%Pu)]+n,r/=Pu;for(let t=0;t<e.length&&!e[t];t++)n=Tu[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;it(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(null==e)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<Bu.length;r++){const n=e.match(Bu[r]);if(null==n)continue;const i=n[1].toLowerCase();switch(i){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const r=Iu(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:r}),{linkage:t,url:r}}case"erc721":case"erc1155":{const r="erc721"===i?"tokenURI(uint256)":"uri(uint256)";t.push({type:i,value:e});const o=await this.getAddress();if(null==o)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const s=(n[2]||"").split("/");if(2!==s.length)return t.push({type:`!${i}caip`,value:n[2]||""}),{url:null,linkage:t};const a=s[1],u=new Ni(s[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("erc721"===i){const e=await u.ownerOf(a);if(o!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===i){const e=await u.balanceOf(o,a);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let c=await u[r](a);if(null==c||"0x"===c)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:c}),"erc1155"===i&&(c=c.replace("{id}",Bt(a,32).substring(2)),t.push({type:"metadata-url-expanded",value:c})),c.match(/^ipfs:/i)&&(c=Iu(c)),t.push({type:"metadata-url",value:c});let l={};const f=await new Dn(c).send();f.assertOk();try{l=f.bodyJson}catch(e){try{t.push({type:"!metadata",value:f.bodyText})}catch(e){const r=f.body;return r&&t.push({type:"!metadata",value:yt(r)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!l)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(l)});let h=l.image;if("string"!=typeof h)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(h.match(/^(https:\/\/|data:)/i));else{if(null==h.match(xu))return t.push({type:"!imageUrl-ipfs",value:h}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:h}),h=Iu(h)}return t.push({type:"url",value:h}),{linkage:t,url:h}}}}}catch(t){}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return it(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async#St(t,e){const r=await Ru.getEnsAddress(t);try{const n=new Ni(r,["function resolver(bytes32) view returns (address)"],t),i=await n.resolver(Zo(e),{enableCcipRead:!0});return i===Hn?null:i}catch(t){throw t}return null}static async fromName(t,e){let r=e;for(;;){if(""===r||"."===r)return null;if("eth"!==e&&"eth"===r)return null;const n=await Ru.#St(t,r);if(null!=n){const i=new Ru(t,n,e);return r===e||await i.supportsWildcard()?i:null}r=r.split(".").slice(1).join(".")}}}const Nu=BigInt(0);function Uu(t,e){return function(r){return null==r?e:t(r)}}function Cu(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function Lu(t,e){return r=>{const n={};for(const i in t){let o=i;if(e&&i in e&&!(o in r))for(const t of e[i])if(t in r){o=t;break}try{const e=t[i](r[o]);void 0!==e&&(n[i]=e)}catch(t){it(!1,`invalid value for value.${i} (${t instanceof Error?t.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function Du(t){return ot(ht(t,!0),"invalid data","value",t),t}function Mu(t){return ot(ht(t,32),"invalid hash","value",t),t}const Fu=Lu({address:Ue,blockHash:Mu,blockNumber:xt,data:Du,index:xt,removed:Uu((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}ot(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:Cu(Mu),transactionHash:Mu,transactionIndex:xt},{index:["logIndex"]}),Hu=Lu({hash:Uu(Mu),parentHash:Mu,parentBeaconBlockRoot:Uu(Mu,null),number:xt,timestamp:xt,nonce:Uu(Du),difficulty:Tt,gasLimit:Tt,gasUsed:Tt,stateRoot:Uu(Mu,null),receiptsRoot:Uu(Mu,null),blobGasUsed:Uu(Tt,null),excessBlobGas:Uu(Tt,null),miner:Uu(Ue),prevRandao:Uu(Mu,null),extraData:Du,baseFeePerGas:Uu(Tt)},{prevRandao:["mixHash"]}),ju=Lu({transactionIndex:xt,blockNumber:xt,transactionHash:Mu,address:Ue,topics:Cu(Mu),data:Du,index:xt,blockHash:Mu},{index:["logIndex"]}),Gu=Lu({to:Uu(Ue,null),from:Uu(Ue,null),contractAddress:Uu(Ue,null),index:xt,root:Uu(yt),gasUsed:Tt,blobGasUsed:Uu(Tt,null),logsBloom:Uu(Du),blockHash:Mu,hash:Mu,logs:Cu((function(t){return ju(t)})),blockNumber:xt,cumulativeGasUsed:Tt,effectiveGasPrice:Uu(Tt),blobGasPrice:Uu(Tt,null),status:Uu(xt),type:Uu(xt,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Vu(t){t.to&&Tt(t.to)===Nu&&(t.to="0x0000000000000000000000000000000000000000");const e=Lu({hash:Mu,index:Uu(xt,void 0),type:t=>"0x"===t||null==t?0:xt(t),accessList:Uu(kn,null),blobVersionedHashes:Uu(Cu(Mu,!0),null),blockHash:Uu(Mu,null),blockNumber:Uu(xt,null),transactionIndex:Uu(xt,null),from:Ue,gasPrice:Uu(Tt),maxPriorityFeePerGas:Uu(Tt),maxFeePerGas:Uu(Tt),maxFeePerBlobGas:Uu(Tt,null),gasLimit:Tt,to:Uu(Ue,null),value:Tt,nonce:xt,data:Du,creates:Uu(Ue,null),chainId:Uu(Tt,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Ue(t.from);let r=Tt(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,Ue(wt(Pe(uu([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Ns.from(t.signature):e.signature=Ns.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&Tt(e.blockHash)===Nu&&(e.blockHash=null),e}class Ku{name;constructor(t){$(this,{name:t})}clone(){return new Ku(this.name)}}class Wu extends Ku{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`);const r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),ot("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),$(this,r)}clone(){return new Wu(this.effectiveBlock,this)}}class zu extends Ku{address;targetNetwork;constructor(t,e){super("org.ethers.plugins.network.Ens"),$(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new zu(this.address,this.targetNetwork)}}class qu extends Ku{#T;#_t;get url(){return this.#T}get processFunc(){return this.#_t}constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),this.#T=t,this.#_t=e}clone(){return this}}const Qu=new Map;class Ju{#kt;#ht;#Tt;constructor(t,e){this.#kt=t,this.#ht=Tt(e),this.#Tt=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#kt}set name(t){this.#kt=t}get chainId(){return this.#ht}set chainId(t){this.#ht=Tt(t,"chainId")}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===Tt(t)}catch(t){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===Tt(t)}catch(t){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===Tt(t.chainId)}catch(t){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(this.#Tt.values())}attachPlugin(t){if(this.#Tt.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#Tt.set(t.name,t.clone()),this}getPlugin(t){return this.#Tt.get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const t=new Ju(this.name,this.chainId);return this.plugins.forEach((e=>{t.attachPlugin(e.clone())})),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new Wu;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=kn(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(t){if(function(){function t(t,e,r){const n=function(){const n=new Ju(t,e);return null!=r.ensNetwork&&n.attachPlugin(new zu(null,r.ensNetwork)),n.attachPlugin(new Wu),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};Ju.register(t,n),Ju.register(e,n),r.altNames&&r.altNames.forEach((t=>{Ju.register(t,n)}))}Zu||(Zu=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[Yu("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Yu("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1}))}(),null==t)return Ju.from("mainnet");if("number"==typeof t&&(t=BigInt(t)),"string"==typeof t||"bigint"==typeof t){const e=Qu.get(t);if(e)return e();if("bigint"==typeof t)return new Ju("unknown",t);ot(!1,"unknown network","network",t)}if("function"==typeof t.clone)return t.clone();if("object"==typeof t){ot("string"==typeof t.name&&"number"==typeof t.chainId,"invalid network object name or chainId","network",t);const e=new Ju(t.name,t.chainId);return(t.ensAddress||null!=t.ensNetwork)&&e.attachPlugin(new zu(t.ensAddress,t.ensNetwork)),e}ot(!1,"invalid network","network",t)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Qu.get(t);r&&ot(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Qu.set(t,e)}}function Xu(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function Yu(t){return new qu(t,(async(t,e,r)=>{let n;r.setHeader("User-Agent","ethers");try{const[e,i]=await Promise.all([r.send(),t()]);n=e;const o=n.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:Xu(o.maxFee,9),maxPriorityFeePerGas:Xu(o.maxPriorityFee,9)}}catch(t){it(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:n,error:t})}}))}let Zu=!1;function $u(t){return JSON.parse(JSON.stringify(t))}class tc{#Pt;#It;#Ot;#xt;constructor(t){this.#Pt=t,this.#It=null,this.#Ot=4e3,this.#xt=-2}get pollingInterval(){return this.#Ot}set pollingInterval(t){this.#Ot=t}async#Bt(){try{const t=await this.#Pt.getBlockNumber();if(-2===this.#xt)return void(this.#xt=t);if(t!==this.#xt){for(let e=this.#xt+1;e<=t;e++){if(null==this.#It)return;await this.#Pt.emit("block",e)}this.#xt=t}}catch(t){}null!=this.#It&&(this.#It=this.#Pt._setTimeout(this.#Bt.bind(this),this.#Ot))}start(){this.#It||(this.#It=this.#Pt._setTimeout(this.#Bt.bind(this),this.#Ot),this.#Bt())}stop(){this.#It&&(this.#Pt._clearTimeout(this.#It),this.#It=null)}pause(t){this.stop(),t&&(this.#xt=-2)}resume(){this.start()}}class ec{#Pt;#Bt;#Rt;constructor(t){this.#Pt=t,this.#Rt=!1,this.#Bt=t=>{this._poll(t,this.#Pt)}}async _poll(t,e){throw new Error("sub-classes must override this")}start(){this.#Rt||(this.#Rt=!0,this.#Bt(-2),this.#Pt.on("block",this.#Bt))}stop(){this.#Rt&&(this.#Rt=!1,this.#Pt.off("block",this.#Bt))}pause(t){this.stop()}resume(){this.start()}}class rc extends ec{#Nt;#Ut;constructor(t,e){super(t),this.#Nt=e,this.#Ut=-2}pause(t){t&&(this.#Ut=-2),super.pause(t)}async _poll(t,e){const r=await e.getBlock(this.#Nt);null!=r&&(-2===this.#Ut?this.#Ut=r.number:r.number>this.#Ut&&(e.emit(this.#Nt,r.number),this.#Ut=r.number))}}class nc extends ec{#Z;constructor(t,e){super(t),this.#Z=$u(e)}async _poll(t,e){throw new Error("@TODO")}}class ic extends ec{#Ct;constructor(t,e){super(t),this.#Ct=e}async _poll(t,e){const r=await e.getTransactionReceipt(this.#Ct);r&&e.emit(this.#Ct,r)}}class oc{#Pt;#Z;#It;#Rt;#xt;constructor(t,e){this.#Pt=t,this.#Z=$u(e),this.#It=this.#Bt.bind(this),this.#Rt=!1,this.#xt=-2}async#Bt(t){if(-2===this.#xt)return;const e=$u(this.#Z);e.fromBlock=this.#xt+1,e.toBlock=t;const r=await this.#Pt.getLogs(e);if(0!==r.length)for(const t of r)this.#Pt.emit(this.#Z,t),this.#xt=t.blockNumber;else this.#xt<t-60&&(this.#xt=t-60)}start(){this.#Rt||(this.#Rt=!0,-2===this.#xt&&this.#Pt.getBlockNumber().then((t=>{this.#xt=t})),this.#Pt.on("block",this.#It))}stop(){this.#Rt&&(this.#Rt=!1,this.#Pt.off("block",this.#It))}pause(t){this.stop(),t&&(this.#xt=-2)}resume(){this.start()}}const sc=BigInt(2);function ac(t){return t&&"function"==typeof t.then}function uc(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,r)=>(t[r]=e[r],t)),{})}return e}))}class cc{name;constructor(t){$(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function lc(t){return(t=Array.from(new Set(t).values())).sort(),t}async function fc(t,e){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(ht(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:uc("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:uc("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?lc(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],o=r=>{ht(r)?t.push(r):i.push((async()=>{t.push(await un(r,e))})())};Array.isArray(r.address)?r.address.forEach(o):o(r.address),i.length&&await Promise.all(i),n.address=lc(t.map((t=>t.toLowerCase())))}return{filter:n,tag:uc("event",n),type:"event"}}ot(!1,"unknown ProviderEvent","event",t)}function hc(){return(new Date).getTime()}const pc={cacheTimeout:250,pollingInterval:4e3};class dc{#Lt;#Tt;#Dt;#Mt;#Ft;#Ht;#jt;#Gt;#Vt;#Kt;#Wt;#l;constructor(t,e){if(this.#l=Object.assign({},pc,e||{}),"any"===t)this.#Ht=!0,this.#Ft=null;else if(t){const e=Ju.from(t);this.#Ht=!1,this.#Ft=Promise.resolve(e),setTimeout((()=>{this.emit("network",e,null)}),0)}else this.#Ht=!1,this.#Ft=null;this.#Gt=-1,this.#jt=new Map,this.#Lt=new Map,this.#Tt=new Map,this.#Dt=null,this.#Mt=!1,this.#Vt=1,this.#Kt=new Map,this.#Wt=!1}get pollingInterval(){return this.#l.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#Tt.values())}attachPlugin(t){if(this.#Tt.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#Tt.set(t.name,t.connect(this)),this}getPlugin(t){return this.#Tt.get(t)||null}get disableCcipRead(){return this.#Wt}set disableCcipRead(t){this.#Wt=!!t}async#zt(t){const e=this.#l.cacheTimeout;if(e<0)return await this._perform(t);const r=uc(t.method,t);let n=this.#jt.get(r);return n||(n=this._perform(t),this.#jt.set(r,n),setTimeout((()=>{this.#jt.get(r)===n&&this.#jt.delete(r)}),e)),await n}async ccipReadFetch(t,e,r){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),o=[];for(let e=0;e<r.length;e++){const s=r[e],a=s.replace("{sender}",n).replace("{data}",i),u=new Dn(a);-1===s.indexOf("{data}")&&(u.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:e,urls:r});let c="unknown error";const l=await u.send();try{const t=l.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:t}),t.data;t.message&&(c=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:t})}catch(t){}it(l.statusCode<400||l.statusCode>=500,`response not found during CCIP fetch: ${c}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:s,errorMessage:c}}),o.push(c)}it(!1,`error encountered during CCIP fetch: ${o.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:o}})}_wrapBlock(t,e){return new $n(function(t){const e=Hu(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:Vu(t))),e}(t),this)}_wrapLog(t,e){return new ti(function(t){return Fu(t)}(t),this)}_wrapTransactionReceipt(t,e){return new ei(function(t){return Gu(t)}(t),this)}_wrapTransactionResponse(t,e){return new ri(Vu(t),this)}_detectNetwork(){it(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){it(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=xt(await this.#zt({method:"getBlockNumber"}),"%response");return this.#Gt>=0&&(this.#Gt=t),t}_getAddress(t){return un(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return ht(t)?ht(t,32)?t:Nt(t):("bigint"==typeof t&&(t=xt(t,"blockTag")),"number"==typeof t?t>=0?Nt(t):this.#Gt>=0?Nt(this.#Gt+t):this.getBlockNumber().then((e=>Nt(e+t))):void ot(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?lc(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let o;switch(t.length){case 0:break;case 1:o=t[0];break;default:t.sort(),o=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const s={};return o&&(s.address=o),e.length&&(s.topics=e),n&&(s.fromBlock=n),i&&(s.toBlock=i),r&&(s.blockHash=r),s};let i,o,s=[];if(t.address)if(Array.isArray(t.address))for(const e of t.address)s.push(this._getAddress(e));else s.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(o=this._getBlockTag(t.toBlock)),s.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=o&&"string"!=typeof o?Promise.all([Promise.all(s),i,o]).then((t=>n(t[0],t[1],t[2]))):n(s,i,o)}_getTransactionRequest(t){const e=Zn(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=un(e[t],this);ac(n)?r.push(async function(){e[t]=await n}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);ac(t)?r.push(async function(){e.blockTag=await t}()):e.blockTag=t}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(null==this.#Ft){const t=(async()=>{try{const t=await this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw this.#Ft===t&&(this.#Ft=null),e}})();return this.#Ft=t,(await t).clone()}const t=this.#Ft,[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(this.#Ht?(this.emit("network",r,e),this.#Ft===t&&(this.#Ft=Promise.resolve(r))):it(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:e,gasPrice:r,priorityFee:n}=await Z({_block:this.#qt("latest",!1),gasPrice:(async()=>{try{return Tt(await this.#zt({method:"getGasPrice"}),"%response")}catch(t){}return null})(),priorityFee:(async()=>{try{return Tt(await this.#zt({method:"getPriorityFee"}),"%response")}catch(t){}return null})()});let i=null,o=null;const s=this._wrapBlock(e,t);return s&&s.baseFeePerGas&&(o=null!=n?n:BigInt("1000000000"),i=s.baseFeePerGas*sc+o),new Yn(r,i,o)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Dn(r.url),n=await r.processFunc(e,this,t);return new Yn(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return ac(e)&&(e=await e),Tt(await this.#zt({method:"estimateGas",transaction:e}),"%response")}async#Qt(t,e,r){it(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=Zn(t);try{return yt(await this._perform({method:"call",transaction:n,blockTag:e}))}catch(t){if(!this.disableCcipRead&&rt(t)&&t.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===wt(t.data,0,4)){const i=t.data,o=await un(n.to,this);let s;try{s=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};it(bt(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=wt(t,0,32);it(wt(r,0,12)===wt(Ec,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=wt(r,12);try{const r=[],n=xt(wt(t,32,64)),i=xt(wt(t,n,n+32)),o=wt(t,n+32);for(let t=0;t<i;t++){const e=yc(o,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(t){it(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=gc(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(t){it(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}it(wt(t,100,128)===wt(Ec,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=wt(t,96,100);try{const r=gc(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(t){it(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(wt(t.data,4))}catch(t){it(!1,t.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:i}})}it(s.sender.toLowerCase()===o.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:i,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:s.errorArgs}});const a=await this.ccipReadFetch(n,s.calldata,s.urls);it(null!=a,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:t.data,errorArgs:s.errorArgs}});const u={to:o,data:gt([s.selector,vc([a,s.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const t=await this.#Qt(u,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:t}),t}catch(t){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:t}),t}}throw t}}async#Jt(t){const{value:e}=await Z({network:this.getNetwork(),value:t});return e}async call(t){const{tx:e,blockTag:r}=await Z({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await this.#Jt(this.#Qt(e,r,t.enableCcipRead?0:-1))}async#Xt(t,e,r){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=await Promise.all([n,i])),await this.#Jt(this.#zt(Object.assign(t,{address:n,blockTag:i})))}async getBalance(t,e){return Tt(await this.#Xt({method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return xt(await this.#Xt({method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return yt(await this.#Xt({method:"getCode"},t,e))}async getStorage(t,e,r){const n=Tt(e,"position");return yt(await this.#Xt({method:"getStorage",position:n},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:n}=await Z({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=ku.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}async#qt(t,e){if(ht(t,32))return await this.#zt({method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=await r),await this.#zt({method:"getBlock",blockTag:r,includeTransactions:e})}async getBlock(t,e){const{network:r,params:n}=await Z({network:this.getNetwork(),params:this.#qt(t,!!e)});return null==n?null:this._wrapBlock(n,r)}async getTransaction(t){const{network:e,params:r}=await Z({network:this.getNetwork(),params:this.#zt({method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await Z({network:this.getNetwork(),params:this.#zt({method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.effectiveGasPrice){const e=await this.#zt({method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await Z({network:this.getNetwork(),result:this.#zt({method:"getTransactionResult",hash:t})});return null==e?null:yt(e)}async getLogs(t){let e=this._getFilter(t);ac(e)&&(e=await e);const{network:r,params:n}=await Z({network:this.getNetwork(),params:this.#zt({method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}_getProvider(t){it(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await Ru.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){const e=Zo((t=Ue(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=await Ru.getEnsAddress(this),n=new Ni(r,["function resolver(bytes32) view returns (address)"],this),i=await n.resolver(e);if(null==i||i===Hn)return null;const o=new Ni(i,["function name(bytes32) view returns (string)"],this),s=await o.name(e);return await this.resolveName(s)!==t?null:s}catch(t){if(et(t,"BAD_DATA")&&"0x"===t.value)return null;if(et(t,"CALL_EXCEPTION"))return null;throw t}return null}async waitForTransaction(t,e,r){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise((async(e,i)=>{let o=null;const s=async r=>{try{const i=await this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(o&&(clearTimeout(o),o=null))}catch(t){console.log("EEE",t)}this.once("block",s)};null!=r&&(o=setTimeout((()=>{null!=o&&(o=null,this.off("block",s),i(nt("timeout","TIMEOUT",{reason:"timeout"})))}),r)),s(await this.getBlockNumber())}))}async waitForBlock(t){it(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=this.#Kt.get(t);e&&(e.timer&&clearTimeout(e.timer),this.#Kt.delete(t))}_setTimeout(t,e){null==e&&(e=0);const r=this.#Vt++,n=()=>{this.#Kt.delete(r),t()};if(this.paused)this.#Kt.set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);this.#Kt.set(r,{timer:t,func:n,time:hc()})}return r}_forEachSubscriber(t){for(const e of this.#Lt.values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new cc(t.type);case"block":{const t=new tc(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new rc(this,t.type);case"event":return new oc(this,t.filter);case"transaction":return new ic(this,t.hash);case"orphan":return new nc(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of this.#Lt.values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=this.#Dt&&e.pause(this.#Dt);break}}async#Yt(t,e){let r=await fc(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=await fc({orphan:"drop-log",log:e[0]},this)),this.#Lt.get(r.tag)||null}async#Zt(t){const e=await fc(t,this),r=e.tag;let n=this.#Lt.get(r);return n||(n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#Lt.set(r,n)),n}async on(t,e){const r=await this.#Zt(t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=this.#Dt&&r.subscriber.pause(this.#Dt)),this}async once(t,e){const r=await this.#Zt(t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=this.#Dt&&r.subscriber.pause(this.#Dt)),this}async emit(t,...e){const r=await this.#Yt(t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new oi(this,n?null:r,t);try{r.call(this,...e,i)}catch(t){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),this.#Lt.delete(r.tag)),n>0}async listenerCount(t){if(t){const e=await this.#Yt(t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of this.#Lt.values())e+=t.length;return e}async listeners(t){if(t){const e=await this.#Yt(t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of this.#Lt.values())e=e.concat(t.map((({listener:t})=>t)));return e}async off(t,e){const r=await this.#Yt(t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),this.#Lt.delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:n}=await this.#Zt(t);r&&n.stop(),this.#Lt.delete(e)}else for(const[t,{started:e,subscriber:r}]of this.#Lt)e&&r.stop(),this.#Lt.delete(t);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return this.#Mt}destroy(){this.removeAllListeners();for(const t of this.#Kt.keys())this._clearTimeout(t);this.#Mt=!0}get paused(){return null!=this.#Dt}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(this.#Gt=-1,null!=this.#Dt){if(this.#Dt==!!t)return;it(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),this.#Dt=!!t;for(const t of this.#Kt.values())t.timer&&clearTimeout(t.timer),t.time=hc()-t.time}resume(){if(null!=this.#Dt){this._forEachSubscriber((t=>t.resume())),this.#Dt=null;for(const t of this.#Kt.values()){let e=t.time;e<0&&(e=0),t.time=hc(),setTimeout(t.func,e)}}}}function yc(t,e){try{const r=gc(t,e);if(r)return ir(r)}catch(t){}return null}function gc(t,e){if("0x"===t)return null;try{const r=xt(wt(t,e,e+32)),n=xt(wt(t,r,r+32));return wt(t,r+32,r+32+n)}catch(t){}return null}function bc(t){const e=Rt(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function wc(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}const mc=new Uint8Array([]);function vc(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(mc),r+=32;for(let n=0;n<t.length;n++){const i=lt(t[n]);e[n]=bc(r),e.push(bc(i.length)),e.push(wc(i)),r+=32+32*Math.ceil(i.length/32)}return gt(e)}const Ec="0x0000000000000000000000000000000000000000000000000000000000000000";function Ac(t,e){if(t.provider)return t.provider;it(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function Sc(t,e){let r=Zn(e);if(null!=r.to&&(r.to=un(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),un(e,t)]).then((([t,e])=>(ot(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return await Z(r)}class _c{provider;constructor(t){$(this,{provider:t||null})}async getNonce(t){return Ac(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await Sc(this,t)}async populateTransaction(t){const e=Ac(this,"populateTransaction"),r=await Sc(this,t);null==r.nonce&&(r.nonce=await this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=await this.estimateGas(r));const n=await this.provider.getNetwork();null!=r.chainId?ot(Tt(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId):r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||ot(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):ot(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=await e.getFeeData();it(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=await e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(it(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):it(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return await Z(r)}async estimateGas(t){return Ac(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return Ac(this,"call").call(await this.populateCall(t))}async resolveName(t){const e=Ac(this,"resolveName");return await e.resolveName(t)}async sendTransaction(t){const e=Ac(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const n=ku.from(r);return await e.broadcastTransaction(await this.signTransaction(n))}}class kc{#Pt;#$t;#It;#Rt;#te;#ee;constructor(t){this.#Pt=t,this.#$t=null,this.#It=this.#Bt.bind(this),this.#Rt=!1,this.#te=null,this.#ee=!1}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}async#Bt(t){try{null==this.#$t&&(this.#$t=this._subscribe(this.#Pt));let t=null;try{t=await this.#$t}catch(t){if(!et(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==t)return this.#$t=null,void this.#Pt._recoverSubscriber(this,this._recover(this.#Pt));const e=await this.#Pt.getNetwork();if(this.#te||(this.#te=e),this.#te.chainId!==e.chainId)throw new Error("chaid changed");if(this.#ee)return;const r=await this.#Pt.send("eth_getFilterChanges",[t]);await this._emitResults(this.#Pt,r)}catch(t){console.log("@TODO",t)}this.#Pt.once("block",this.#It)}#re(){const t=this.#$t;t&&(this.#$t=null,t.then((t=>{this.#Pt.destroyed||this.#Pt.send("eth_uninstallFilter",[t])})))}start(){this.#Rt||(this.#Rt=!0,this.#Bt(-2))}stop(){this.#Rt&&(this.#Rt=!1,this.#ee=!0,this.#re(),this.#Pt.off("block",this.#It))}pause(t){t&&this.#re(),this.#Pt.off("block",this.#It)}resume(){this.start()}}class Tc extends kc{#ne;constructor(t,e){var r;super(t),this.#ne=(r=e,JSON.parse(JSON.stringify(r)))}_recover(t){return new oc(t,this.#ne)}async _subscribe(t){return await t.send("eth_newFilter",[this.#ne])}async _emitResults(t,e){for(const r of e)t.emit(this.#ne,t._wrapLog(r,t._network))}}class Pc extends kc{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const Ic="bigint,boolean,function,number,string,symbol".split(/,/g);function Oc(t){if(null==t||Ic.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(Oc);if("object"==typeof t)return Object.keys(t).reduce(((e,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function xc(t){return new Promise((e=>{setTimeout(e,t)}))}function Bc(t){return t?t.toLowerCase():t}function Rc(t){return t&&"number"==typeof t.pollingInterval}const Nc={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Uc extends _c{address;constructor(t,e){super(t),$(this,{address:e=Ue(e)})}connect(t){it(!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 e=Oc(t),r=[];if(e.from){const n=e.from;r.push((async()=>{const r=await un(n,this.provider);ot(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})())}else e.from=this.address;if(null==e.gasLimit&&r.push((async()=>{e.gasLimit=await this.provider.estimateGas({...e,from:this.address})})()),null!=e.to){const t=e.to;r.push((async()=>{e.to=await un(t,this.provider)})())}r.length&&await Promise.all(r);const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}async sendTransaction(t){const e=await this.provider.getBlockNumber(),r=await this.sendUncheckedTransaction(t);return await new Promise(((t,n)=>{const i=[1e3,100];let o=0;const s=async()=>{try{const n=await this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(t){if(et(t,"CANCELLED")||et(t,"BAD_DATA")||et(t,"NETWORK_ERROR"))return null==t.info&&(t.info={}),t.info.sendTransactionHash=r,void n(t);if(et(t,"INVALID_ARGUMENT")&&(o++,null==t.info&&(t.info={}),t.info.sendTransactionHash=r,o>10))return void n(t);this.provider.emit("error",nt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:t}))}this.provider._setTimeout((()=>{s()}),i.pop()||4e3)};s()}))}async signTransaction(t){const e=Oc(t);if(e.from){const r=await un(e.from,this.provider);ot(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return await this.provider.send("eth_signTransaction",[r])}async signMessage(t){const e="string"==typeof t?nr(t):t;return await this.provider.send("personal_sign",[yt(e),this.address.toLowerCase()])}async signTypedData(t,e,r){const n=Oc(r),i=await Sn.resolveNames(t,e,n,(async t=>{const e=await un(t);return ot(null!=e,"TypedData does not support null address","value",t),e}));return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Sn.getPayload(i.domain,e,i.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const e="string"==typeof t?nr(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),yt(e)])}}class Cc extends dc{#l;#ie;#oe;#se;#ae;#te;#ue;#ce(){if(this.#se)return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");this.#se=setTimeout((()=>{this.#se=null;const t=this.#oe;for(this.#oe=[];t.length;){const e=[t.shift()];for(;t.length&&e.length!==this.#l.batchMaxCount;)if(e.push(t.shift()),JSON.stringify(e.map((t=>t.payload))).length>this.#l.batchMaxSize){t.unshift(e.pop());break}(async()=>{const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const r=await this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=nt("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(t){this.emit("debug",{action:"receiveRpcError",error:t});for(const{reject:r}of e)r(t)}})()}}),t)}constructor(t,e){super(t,e),this.#ie=1,this.#l=Object.assign({},Nc,e||{}),this.#oe=[],this.#se=null,this.#te=null,this.#ue=null;{let t=null;const e=new Promise((e=>{t=e}));this.#ae={promise:e,resolve:t}}const r=this._getOption("staticNetwork");"boolean"==typeof r?(ot(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&(this.#te=Ju.from(t))):r&&(ot(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),this.#te=r)}_getOption(t){return this.#l[t]}get _network(){return it(this.#te,"network is not available yet","NETWORK_ERROR"),this.#te}async _perform(t){if("call"===t.method||"estimateGas"===t.method){let e=t.transaction;if(e&&null!=e.type&&Tt(e.type)&&null==e.maxFeePerGas&&null==e.maxPriorityFeePerGas){const r=await this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(t=Object.assign({},t,{transaction:Object.assign({},e,{type:void 0})}))}}const e=this.getRpcRequest(t);return null!=e?await this.send(e.method,e.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(this.#te)return this.#te}return this.#ue?await this.#ue:this.ready?(this.#ue=(async()=>{try{const t=Ju.from(Tt(await this.send("eth_chainId",[])));return this.#ue=null,t}catch(t){throw this.#ue=null,t}})(),await this.#ue):(this.#ue=(async()=>{const t={id:this.#ie++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(await this._send(t))[0],this.#ue=null}catch(t){throw this.#ue=null,this.emit("debug",{action:"receiveRpcError",error:t}),t}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return Ju.from(Tt(e.result));throw this.getRpcError(t,e)})(),await this.#ue)}_start(){null!=this.#ae&&null!=this.#ae.resolve&&(this.#ae.resolve(),this.#ae=null,(async()=>{for(;null==this.#te&&!this.destroyed;)try{this.#te=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",nt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await xc(1e3)}this.#ce()})())}async _waitUntilReady(){if(null!=this.#ae)return await this.#ae.promise}_getSubscriber(t){return"pending"===t.type?new Pc(this):"event"===t.type?this._getOption("polling")?new oc(this,t.filter):new Tc(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new cc("orphan"):super._getSubscriber(t)}get ready(){return null==this.#ae}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=Nt(Tt(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=yt(t[r]))})),t.accessList&&(e.accessList=kn(t.accessList)),e}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:[Bc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Bc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Bc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Bc(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&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Bc):t.filter.address=Bc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return nt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=Mc(n),i=on.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return Fc(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i))return nt("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"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}});if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return nt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return nt("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return nt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return nt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let o=!!i.match(/the method .* does not exist/i);return o||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(o=!0),o?nt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):nt("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=this.#ie++,n=new Promise(((n,i)=>{this.#oe.push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return this.#ce(),n}async getSigner(t){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=await e;if(t>=r.length)throw new Error("no such account");return new Uc(this,r[t])}const{accounts:r}=await Z({network:this.getNetwork(),accounts:e});t=Ue(t);for(const e of r)if(Ue(e)===t)return new Uc(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map((t=>new Uc(this,t)))}destroy(){this.#se&&(clearTimeout(this.#se),this.#se=null);for(const{payload:t,reject:e}of this.#oe)e(nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));this.#oe=[],super.destroy()}}class Lc extends Cc{#le;constructor(t,e){super(t,e);let r=this._getOption("pollingInterval");null==r&&(r=Nc.pollingInterval),this.#le=r}_getSubscriber(t){const e=super._getSubscriber(t);return Rc(e)&&(e.pollingInterval=this.#le),e}get pollingInterval(){return this.#le}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");this.#le=t,this._forEachSubscriber((t=>{Rc(t)&&(t.pollingInterval=this.#le)}))}}class Dc extends Lc{#fe;constructor(t,e,r){null==t&&(t="http://localhost:8545"),super(e,r),this.#fe="string"==typeof t?new Dn(t):t.clone()}_getConnection(){return this.#fe.clone()}async send(t,e){return await this._start(),await super.send(t,e)}async _send(t){const e=this._getConnection();e.body=JSON.stringify(t),e.setHeader("content-type","application/json");const r=await e.send();r.assertOk();let n=r.bodyJson;return Array.isArray(n)||(n=[n]),n}}function Mc(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&ht(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=Mc(t[e]);if(r)return r}return null}if("string"==typeof t)try{return Mc(JSON.parse(t))}catch(t){}return null}function Fc(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const r in t)Fc(t[r],e);if("string"==typeof t)try{return Fc(JSON.parse(t),e)}catch(t){}}}BigInt.prototype.toJSON=function(){return this.toString()};var Hc=i(8287).Buffer;class jc{static EXPECTED_BUFFER_LENGTH=32;static bufferToUint8Array(t){if(Hc.isBuffer(t)){const e=t.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r);for(let r=0;r<e;++r)n[r]=t[r];return n}return t}static uint8ArrayToHex(t){return Hc.from(t,0,t.byteLength).toString("hex")}static hexToUint8Array(t){t.startsWith("0x")&&(t=t.substr(2)),t.length%2!=0&&(t="0"+t);const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=parseInt(t.substr(2*n,2),16);return r}static pointerToUint8Array(t){const e=t.toString(16).padStart(64,"0");return jc.hexToUint8Array(e)}static uint8ArrayToPointer(t){const e=jc.uint8ArrayToHex(t);return BigInt("0x"+e)}static valueToUint8Array(t){const e=t.toString(16).padStart(64,"0");return jc.hexToUint8Array(e)}static uint8ArrayToValue(t){const e=jc.uint8ArrayToHex(t);return e?BigInt("0x"+e):BigInt(0)}}class Gc{eventType;eventData;constructor(t,e){this.eventType=t,this.eventData=e}}class Vc{buffer;currentOffset=0;constructor(t){this.buffer=new DataView(t.buffer)}setBuffer(t){this.buffer=new DataView(t.buffer),this.currentOffset=0}readEvents(){const t=[],e=this.readU32();for(let r=0;r<e;r++){const e=this.readEvent();t.push(e)}return t}readEvent(){const t=this.readStringWithLength(),e=this.readBytesWithLength();return new Gc(t,e)}readBytesWithLength(){const t=this.readU32();return this.readBytes(t)}readSelectors(){const t=new Map,e=this.readU16();for(let r=0;r<e;r++){const e=this.readABISelector();t.set(e.name,e.selector)}return t}readABISelector(){return{name:this.readStringWithLength(),selector:this.readSelector()}}readViewSelectorsMap(){const t=new Map,e=this.readU16();for(let r=0;r<e;r++){const e=this.readAddress(),r=this.readSelectors();t.set(e,r)}return t}readMethodSelectorsMap(){const t=new Map,e=this.readU16();for(let r=0;r<e;r++){const e=this.readAddress(),r=this.readMethodSelectors();t.set(e,r)}return t}readMethodSelectors(){const t=new Set,e=this.readU16();for(let r=0;r<e;r++)t.add(this.readSelector());return t}readTuple(){const t=this.readU32(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU256();return e}readU8(){return this.verifyEnd(this.currentOffset+1),this.buffer.getUint8(this.currentOffset++)}readU16(){this.verifyEnd(this.currentOffset+2);const t=this.buffer.getUint16(this.currentOffset,!0);return this.currentOffset+=2,t}readU32(t=!0){this.verifyEnd(this.currentOffset+4);const e=this.buffer.getUint32(this.currentOffset,t);return this.currentOffset+=4,e}readU64(){const t=BigInt(this.readU32()),e=BigInt(this.readU32());return BigInt(e)<<32n|t}readStorage(){const t=this.readU32(),e=new Map;for(let r=0;r<t;r++){const t=this.readAddress(),r=this.readU32(),n=new Map;for(let t=0;t<r;t++){const t=this.readU256(),e=this.readU256();n.set(t,e)}e.set(t,n)}return e}readU256(){const t=this.readBytes(32);return BigInt("0x"+t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),""))}readBytes(t,e=!1){let r=new Uint8Array(t);this.verifyEnd(this.currentOffset+t);for(let n=0;n<t;n++){const i=this.readU8();if(e&&0===i){r=r.slice(0,n),this.currentOffset+=t-(n+1);break}r[n]=i}return r}readString(t){const e=new TextDecoder,r=this.readBytes(t,!0);return e.decode(r)}readSelector(){return this.readU32(!1)}readStringWithLength(){const t=this.readU16();return this.readString(t)}readBoolean(){return 0!==this.readU8()}readFloat(){const t=this.buffer.getFloat32(this.currentOffset,!0);return this.currentOffset+=4,t}readDouble(){const t=this.buffer.getFloat64(this.currentOffset,!0);return this.currentOffset+=8,t}readAddress(){return this.readString(64)}getOffset(){return this.currentOffset}setOffset(t){this.currentOffset=t}verifyEnd(t){if(this.currentOffset>this.buffer.byteLength)throw new Error(`Expected to read ${t} bytes but read ${this.currentOffset} bytes`)}verifyChecksum(){const t=this.readU32();let e=0;for(let t=0;t<this.buffer.byteLength;t++)e+=this.buffer.getUint8(t);if(e%=2**32,e!==t)throw new Error("Invalid checksum for buffer")}}class Kc{currentOffset=0;buffer=new DataView(new ArrayBuffer(64));constructor(){}writeU8(t){this.allocSafe(1),this.buffer.setUint8(this.currentOffset++,t)}writeU16(t){this.allocSafe(2),this.buffer.setUint16(this.currentOffset,t,!0),this.currentOffset+=2}writeU32(t,e=!0){this.allocSafe(4),this.buffer.setUint32(this.currentOffset,t,e),this.currentOffset+=4}writeU64(t){this.writeU32(Number(t)),this.writeU32(Number(t>>32n))}writeSelector(t){this.writeU32(t,!1)}writeBoolean(t){this.writeU8(t?1:0)}writeU256(t){const e=jc.valueToUint8Array(t);if(32!==e.byteLength)throw console.log("Invalid u256 value:",e),new Error(`Invalid u256 value: ${t}`);for(let t=0;t<e.byteLength;t++)this.writeU8(e[t])}writeBytes(t){for(let e=0;e<t.byteLength;e++)this.writeU8(t[e])}writeString(t){for(let e=0;e<t.length;e++)this.writeU8(t.charCodeAt(e))}writeAddress(t){const e=this.fromAddress(t);this.writeBytes(e)}writeStringWithLength(t){this.writeU16(t.length),this.writeString(t)}writeViewSelectorMap(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeAddress(e),this.writeSelectors(t)}))}writeMethodSelectorsMap(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeAddress(e),this.writeMethodSelectorMap(t)}))}getBuffer(){const t=new Uint8Array(this.buffer.byteLength);for(let e=0;e<this.buffer.byteLength;e++)t[e]=this.buffer.getUint8(e);return this.clear(),t}reset(){this.currentOffset=0,this.buffer=new DataView(new ArrayBuffer(4))}writeStorage(t){this.reset(),this.writeU32(t.size);const e=Array.from(t.keys()),r=Array.from(t.values());for(let t=0;t<e.length;t++){const n=e[t],i=r[t];this.writeAddress(n),this.writeU32(i.size);const o=Array.from(i.keys());for(let t=0;t<o.length;t++){const e=o[t];this.writeU256(e);const r=i.get(e);if(null==r)throw new Error("Slot value not found.");this.writeU256(r)}}}writeTuple(t){this.writeU32(t.length);for(let e=0;e<t.length;e++)this.writeU256(t[e])}toBytesReader(){return new Vc(this.getBuffer())}getOffset(){return this.currentOffset}setOffset(t){this.currentOffset=t}clear(){this.currentOffset=0,this.buffer=new DataView(new ArrayBuffer(4))}allocSafe(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}writeABISelector(t,e){this.writeStringWithLength(t),this.writeSelector(e)}getChecksum(){let t=0;for(let e=0;e<this.buffer.byteLength;e++)t+=this.buffer.getUint8(e);return t%2**32}writeMethodSelectorMap(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeSelector(t)}))}writeSelectors(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeABISelector(e,t)}))}fromAddress(t){if(t.length>64)throw new Error("Address is too long");const e=new Uint8Array(64);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);for(let r=t.length;r<64;r++)e[r]=0;return e}resize(t){const e=new Uint8Array(this.buffer.byteLength+t);for(let t=0;t<this.buffer.byteLength;t++)e[t]=this.buffer.getUint8(t);this.buffer=new DataView(e.buffer)}}var Wc,zc=i(2802),qc=i(8287).Buffer;function Qc(t){return Qc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qc(t)}function Jc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zc(n.key),n)}}function Xc(t,e,r){return e&&Jc(t.prototype,e),r&&Jc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yc(t,e,r){return(e=Zc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zc(t){var e=function(t,e){if("object"!=Qc(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Qc(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qc(e)?e:e+""}!function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES32="BYTES32",t.UINT256="UINT256",t.TUPLE="TUPLE"}(Wc||(Wc={}));var $c=Xc((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Yc(this,"transactionId",void 0),Yc(this,"outputIndex",void 0),Yc(this,"value",void 0),Yc(this,"scriptPubKey",void 0),this.transactionId=e.transactionId,this.outputIndex=e.outputIndex,this.value=BigInt(e.value),this.scriptPubKey=e.scriptPubKey}));function tl(t){return tl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tl(t)}function el(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function rl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nl(n.key),n)}}function nl(t){var e=function(t,e){if("object"!=tl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=tl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tl(e)?e:e+""}var il=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"parseTransactions",value:function(t){if(!t)return[];var e,r=[],n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return el(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?el(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r.push(this.parseTransaction(i))}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"parseTransaction",value:function(t){switch(t.OPNetType){case r.Generic:return new H(t);case r.Interaction:return new J(t);case r.Deployment:return new U(t);default:throw new Error("Unknown transaction type")}}}],null&&rl(t.prototype,null),e&&rl(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ol(t){return ol="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ol(t)}function sl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,cl(n.key),n)}}function al(t,e,r){return e&&sl(t.prototype,e),r&&sl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ul(t,e,r){return(e=cl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cl(t){var e=function(t,e){if("object"!=ol(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ol(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ol(e)?e:e+""}var ll=al((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ul(this,"height",void 0),ul(this,"hash",void 0),ul(this,"previousBlockHash",void 0),ul(this,"previousBlockChecksum",void 0),ul(this,"bits",void 0),ul(this,"nonce",void 0),ul(this,"version",void 0),ul(this,"size",void 0),ul(this,"txCount",void 0),ul(this,"weight",void 0),ul(this,"strippedSize",void 0),ul(this,"time",void 0),ul(this,"medianTime",void 0),ul(this,"checksumRoot",void 0),ul(this,"merkleRoot",void 0),ul(this,"storageRoot",void 0),ul(this,"receiptRoot",void 0),ul(this,"checksumProofs",void 0),ul(this,"transactions",[]),this.height=BigInt(e.height.toString()),this.hash=e.hash,this.previousBlockHash=e.previousBlockHash,this.previousBlockChecksum=e.previousBlockChecksum,this.bits=e.bits,this.nonce=e.nonce,this.version=e.version,this.size=e.size,this.txCount=e.txCount,this.weight=e.weight,this.strippedSize=e.strippedSize,this.time=e.time,this.medianTime=e.medianTime,this.checksumRoot=e.checksumRoot,this.merkleRoot=e.merkleRoot,this.storageRoot=e.storageRoot,this.receiptRoot=e.receiptRoot,this.checksumProofs=e.checksumProofs,this.transactions=il.parseTransactions(e.transactions)})),fl=i(8287).Buffer;function hl(t){return hl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hl(t)}function pl(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function dl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gl(n.key),n)}}function yl(t,e,r){return(e=gl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gl(t){var e=function(t,e){if("object"!=hl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=hl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hl(e)?e:e+""}var bl=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yl(this,"result",void 0),yl(this,"events",void 0),yl(this,"accessList",void 0),yl(this,"decoded",[]),this.events=e.events,this.accessList=e.accessList,this.result="string"==typeof e.result?new Vc(this.base64ToUint8Array(e.result)):e.result},(e=[{key:"setDecoded",value:function(t){var e,r;(e=this.decoded).push.apply(e,function(t){if(Array.isArray(t))return pl(t)}(r=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return pl(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pl(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}},{key:"base64ToUint8Array",value:function(t){return jc.bufferToUint8Array(fl.from(t,"base64"))}}])&&dl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),wl=i(8287).Buffer;function ml(t){return ml="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ml(t)}function vl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sl(n.key),n)}}function El(t,e,r){return e&&vl(t.prototype,e),r&&vl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Al(t,e,r){return(e=Sl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sl(t){var e=function(t,e){if("object"!=ml(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ml(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ml(e)?e:e+""}var _l=El((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Al(this,"contractAddress",void 0),Al(this,"virtualAddress",void 0),Al(this,"bytecode",void 0),Al(this,"wasCompressed",void 0),Al(this,"deployedTransactionId",void 0),Al(this,"deployedTransactionHash",void 0),Al(this,"deployerPubKey",void 0),Al(this,"contractSeed",void 0),Al(this,"contractSaltHash",void 0),Al(this,"deployerAddress",void 0),this.contractAddress=e.contractAddress,this.virtualAddress=e.virtualAddress,this.bytecode=wl.isBuffer(e.bytecode)?e.bytecode:wl.from(e.bytecode,"base64"),this.wasCompressed=e.wasCompressed,this.deployedTransactionId=e.deployedTransactionId,this.deployedTransactionHash=e.deployedTransactionHash,this.deployerPubKey=wl.isBuffer(e.deployerPubKey)?e.deployerPubKey:wl.from(e.deployerPubKey,"base64"),this.contractSeed=wl.isBuffer(e.contractSeed)?e.contractSeed:wl.from(e.contractSeed,"base64"),this.contractSaltHash=wl.isBuffer(e.contractSaltHash)?e.contractSaltHash:wl.from(e.contractSaltHash,"base64"),this.deployerAddress=e.deployerAddress})),kl=i(8287).Buffer;function Tl(t){return Tl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tl(t)}function Pl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ol(n.key),n)}}function Il(t,e,r){return(e=Ol(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ol(t){var e=function(t,e){if("object"!=Tl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Tl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tl(e)?e:e+""}var xl=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Il(this,"pointer",void 0),Il(this,"value",void 0),Il(this,"height",void 0),Il(this,"proofs",void 0),this.pointer="string"==typeof e.pointer?this.base64ToBigInt(e.pointer):e.pointer,e.value instanceof kl?this.value=e.value:this.value=kl.from(e.value,"base64"),this.height=BigInt(e.height),this.proofs=e.proofs||[]},(e=[{key:"base64ToBigInt",value:function(t){return jc.uint8ArrayToPointer(kl.from(t,"base64"))}}])&&Pl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Bl=i(8287).Buffer;function Rl(t){return Rl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rl(t)}function Nl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ll(n.key),n)}}function Ul(t,e,r){return e&&Nl(t.prototype,e),r&&Nl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Cl(t,e,r){return(e=Ll(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ll(t){var e=function(t,e){if("object"!=Rl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Rl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Rl(e)?e:e+""}var Dl=Ul((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Cl(this,"receipt",void 0),Cl(this,"receiptProofs",void 0),Cl(this,"events",void 0),Cl(this,"revert",void 0),this.receipt=e.receipt?Bl.from(e.receipt,"base64"):null,this.receiptProofs=e.receiptProofs||[],this.events=e.events||[],this.revert=e.revert?Bl.from(e.revert,"base64"):void 0})),Ml=i(8287).Buffer;function Fl(t){return Fl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fl(t)}function Hl(){Hl=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,s=Object.create(o.prototype),a=new x(n||[]);return i(s,"_invoke",{value:T(t,r,a)}),s}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function w(){}function m(){}var v={};c(v,s,(function(){return this}));var E=Object.getPrototypeOf,A=E&&E(E(B([])));A&&A!==r&&n.call(A,s)&&(v=A);var S=m.prototype=b.prototype=Object.create(v);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(i,o,s,a){var u=f(t[i],t,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==Fl(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,s){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var u=P(a,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=f(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function B(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(Fl(e)+" is not iterable")}return w.prototype=m,i(S,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:w,configurable:!0}),w.displayName=c(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},_(k.prototype),c(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new k(l(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},_(S),c(S,u,"Generator"),c(S,s,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=B,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function jl(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}function Gl(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){jl(o,n,i,s,a,"next",t)}function a(t){jl(o,n,i,s,a,"throw",t)}s(void 0)}))}}function Vl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Kl(n.key),n)}}function Kl(t){var e=function(t,e){if("object"!=Fl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Fl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fl(e)?e:e+""}var Wl=function(){return t=function t(){var e,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,(r=Kl(r="nextId"))in e?Object.defineProperty(e,r,{value:0,enumerable:!0,configurable:!0,writable:!0}):e[r]=0},e=[{key:"getBlockNumber",value:(d=Gl(Hl().mark((function t(){return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider.getBlockNumber();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return d.apply(this,arguments)})},{key:"getBlock",value:(p=Gl(Hl().mark((function t(e){var r,n,i,o,s,a=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],n="string"==typeof e?"btc_getBlockByHash":"btc_getBlockByNumber",i=this.buildJsonRpcPayload(n,[e,r]),t.next=5,this.callPayloadSingle(i);case 5:return o=t.sent,s=o.result,t.abrupt("return",new ll(s));case 8:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"getBlockByHash",value:(f=Gl(Hl().mark((function t(e){return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBlock(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"getBalance",value:(l=Gl(Hl().mark((function t(e){var r,n,i,o;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.toString(),n=this.buildJsonRpcPayload("btc_getBalance",[r]),t.next=4,this.callPayloadSingle(n);case 4:if(i=t.sent,(o=i.result)&&(!o||o.startsWith("0x"))){t.next=8;break}throw new Error("Invalid balance returned from provider: ".concat(o));case 8:return t.abrupt("return",BigInt(o));case 9:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"getUXTOs",value:(c=Gl(Hl().mark((function t(e){var r,n,i,o,s,a=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],n=e.toString(),i=this.buildJsonRpcPayload("btc_getUTXOs",[n,r]),t.next=5,this.callPayloadSingle(i);case 5:return o=t.sent,s=o.result||[],t.abrupt("return",s.map((function(t){return new $c(t)})));case 8:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"getTransaction",value:(u=Gl(Hl().mark((function t(e){var r,n,i;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.buildJsonRpcPayload("btc_getTransactionByHash",[e]),t.next=3,this.callPayloadSingle(r);case 3:return n=t.sent,i=n.result,t.abrupt("return",il.parseTransaction(i));case 6:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"getTransactionReceipt",value:(a=Gl(Hl().mark((function t(e){var r,n;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.buildJsonRpcPayload("btc_getTransactionReceipt",[e]),t.next=3,this.callPayloadSingle(r);case 3:return n=t.sent,t.abrupt("return",new Dl(n.result));case 5:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"getNetwork",value:(s=Gl(Hl().mark((function t(){var e;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider.getNetwork();case 2:e=t.sent,t.t0=e.chainId,t.next=1n===t.t0?6:2n===t.t0?7:3n===t.t0?8:9;break;case 6:return t.abrupt("return",h.o8.bitcoin);case 7:return t.abrupt("return",h.o8.testnet);case 8:return t.abrupt("return",h.o8.regtest);case 9:throw new Error("Invalid chain id: ".concat(e.chainId));case 10:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"getCode",value:(o=Gl(Hl().mark((function t(e){var r,n,i,o,s,a=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],n=e.toString(),i=this.buildJsonRpcPayload("btc_getCode",[n,r]),t.next=5,this.callPayloadSingle(i);case 5:if(o=t.sent,!("contractAddress"in(s=o.result))){t.next=11;break}return t.abrupt("return",new _l(s));case 11:return t.abrupt("return",Ml.from(s.bytecode,"base64"));case 12:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"getStorageAt",value:(i=Gl(Hl().mark((function t(e,r){var n,i,o,s,a,u,c,l,f=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=!(f.length>2&&void 0!==f[2])||f[2],i=f.length>3?f[3]:void 0,o=e.toString(),s="string"==typeof r?r:this.bigintToBase64(r),a=[o,s,n],i&&a.push(i.toString()),u=this.buildJsonRpcPayload("btc_getStorageAt",a),t.next=9,this.callPayloadSingle(u);case 9:return c=t.sent,l=c.result,t.abrupt("return",new xl(l));case 12:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"call",value:(n=Gl(Hl().mark((function t(e,r,n,i){var o,s,a,u,c,l,f;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.toString(),s=n?n.toString():null,(a=Ml.isBuffer(r)?this.bufferToHex(r):r).startsWith("0x")&&(a=a.slice(2)),u=[o,a],s&&u.push(s),i&&u.push(i.toString()),c=this.buildJsonRpcPayload("btc_call",u),t.next=10,this.callPayloadSingle(c);case 10:if(l=t.sent,!("error"in(f=l.result))){t.next=14;break}return t.abrupt("return",f);case 14:return t.abrupt("return",new bl(f));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,r,i){return n.apply(this,arguments)})},{key:"bufferToHex",value:function(t){return t.toString("hex")}},{key:"bigintToBase64",value:function(t){return Ml.from(jc.pointerToUint8Array(t)).toString("base64")}},{key:"callPayloadSingle",value:(r=Gl(Hl().mark((function t(e){var r,n;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider._send(e);case 2:if(1===(r=t.sent).length){t.next=5;break}throw new Error("Unexpected response length for get block request: ".concat(r.length));case 5:if(n=r.shift()){t.next=8;break}throw new Error("Block not found");case 8:if(!("error"in n)){t.next=10;break}throw new Error("Something went wrong while fetching: ".concat(n.error.message));case 10:return t.abrupt("return",n);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"buildJsonRpcPayload",value:function(t,e){return{method:t,params:e,id:this.nextId++,jsonrpc:"2.0"}}}],e&&Vl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i,o,s,a,u,c,l,f,p,d}();function zl(t){return zl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zl(t)}function ql(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$l(n.key),n)}}function Ql(t,e,r){return e=Xl(e),function(t,e){if(e&&("object"===zl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Jl()?Reflect.construct(e,r||[],Xl(t).constructor):e.apply(t,r))}function Jl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Jl=function(){return!!t})()}function Xl(t){return Xl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xl(t)}function Yl(t,e){return Yl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Yl(t,e)}function Zl(t,e,r){return(e=$l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $l(t){var e=function(t,e){if("object"!=zl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=zl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zl(e)?e:e+""}var tf=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Zl(r=Ql(this,e),"url",void 0),Zl(r,"provider",void 0),r.url=r.providerUrl(t),r.provider=new Dc(r.url),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Yl(t,e)}(e,t),r=e,(n=[{key:"providerUrl",value:function(t){return(t=t.trim()).endsWith("/")?t.slice(0,-1):t.includes("api/v1/json-rpc")?t:"".concat(t,"/api/v1/json-rpc")}}])&&ql(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Wl);const ef=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}().WebSocket;class rf{#Pt;#Z;get filter(){return JSON.parse(this.#Z)}#he;#pe;#de;constructor(t,e){this.#Pt=t,this.#Z=JSON.stringify(e),this.#he=null,this.#pe=null,this.#de=null}start(){this.#he=this.#Pt.send("eth_subscribe",this.filter).then((t=>(this.#Pt._register(t,this),t)))}stop(){this.#he.then((t=>{this.#Pt.destroyed||this.#Pt.send("eth_unsubscribe",[t])})),this.#he=null}pause(t){it(t,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),this.#pe=!!t}resume(){this.#pe=null}_handleMessage(t){if(null!=this.#he&&null===this.#pe){let e=this.#de;e=null==e?this._emit(this.#Pt,t):e.then((async()=>{await this._emit(this.#Pt,t)})),this.#de=e.then((()=>{this.#de===e&&(this.#de=null)}))}}async _emit(t,e){throw new Error("sub-classes must implemente this; _emit")}}class nf extends rf{constructor(t){super(t,["newHeads"])}async _emit(t,e){t.emit("block",parseInt(e.number))}}class of extends rf{constructor(t){super(t,["newPendingTransactions"])}async _emit(t,e){t.emit("pending",e)}}class sf extends rf{#ye;get logFilter(){return JSON.parse(this.#ye)}constructor(t,e){super(t,["logs",e]),this.#ye=JSON.stringify(e)}async _emit(t,e){t.emit(this.logFilter,t._wrapLog(e,t._network))}}class af extends Cc{#ge;#Lt;#be;constructor(t,e){const r=Object.assign({},null!=e?e:{});ot(null==r.batchMaxCount||1===r.batchMaxCount,"sockets-based providers do not support batches","options.batchMaxCount",e),r.batchMaxCount=1,null==r.staticNetwork&&(r.staticNetwork=!0),super(t,r),this.#ge=new Map,this.#Lt=new Map,this.#be=new Map}_getSubscriber(t){switch(t.type){case"close":return new cc("close");case"block":return new nf(this);case"pending":return new of(this);case"event":return new sf(this,t.filter);case"orphan":if("drop-log"===t.filter.orphan)return new cc("drop-log")}return super._getSubscriber(t)}_register(t,e){this.#Lt.set(t,e);const r=this.#be.get(t);if(r){for(const t of r)e._handleMessage(t);this.#be.delete(t)}}async _send(t){ot(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const e=new Promise(((e,r)=>{this.#ge.set(t.id,{payload:t,resolve:e,reject:r})}));return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await e]}async _processMessage(t){const e=JSON.parse(t);if(e&&"object"==typeof e&&"id"in e){const t=this.#ge.get(e.id);if(null==t)return void this.emit("error",nt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:e}));this.#ge.delete(e.id),t.resolve(e)}else{if(!e||"eth_subscription"!==e.method)return void this.emit("error",nt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:e}));{const t=e.params.subscription,r=this.#Lt.get(t);if(r)r._handleMessage(e.params.result);else{let r=this.#be.get(t);null==r&&(r=[],this.#be.set(t,r)),r.push(e.params.result)}}}}async _write(t){throw new Error("sub-classes must override this")}}class uf extends af{#fe;#we;get websocket(){if(null==this.#we)throw new Error("websocket closed");return this.#we}constructor(t,e,r){super(e,r),"string"==typeof t?(this.#fe=()=>new ef(t),this.#we=this.#fe()):"function"==typeof t?(this.#fe=t,this.#we=t()):(this.#fe=null,this.#we=t),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(t){console.log("failed to start WebsocketProvider",t)}},this.websocket.onmessage=t=>{this._processMessage(t.data)}}async _write(t){this.websocket.send(t)}async destroy(){null!=this.#we&&(this.#we.close(),this.#we=null),super.destroy()}}function cf(t){return cf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cf(t)}function lf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gf(n.key),n)}}function ff(t,e,r){return e=pf(e),function(t,e){if(e&&("object"===cf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,hf()?Reflect.construct(e,r||[],pf(t).constructor):e.apply(t,r))}function hf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(hf=function(){return!!t})()}function pf(t){return pf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pf(t)}function df(t,e){return df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},df(t,e)}function yf(t,e,r){return(e=gf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gf(t){var e=function(t,e){if("object"!=cf(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=cf(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cf(e)?e:e+""}var bf,wf=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),yf(r=ff(this,e),"wsUrl",void 0),yf(r,"provider",void 0),r.wsUrl=r.providerUrl(t),r.provider=new uf(r.wsUrl),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&df(t,e)}(e,t),r=e,(n=[{key:"providerUrl",value:function(t){return(t=t.trim()).endsWith("/")?t.slice(0,-1):t.includes("api/v1/json-rpc-ws")?t:"".concat(t,"/api/v1/json-rpc-ws")}}])&&lf(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Wl);function mf(t){return mf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mf(t)}function vf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ef(n.key),n)}}function Ef(t){var e=function(t,e){if("object"!=mf(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=mf(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mf(e)?e:e+""}!function(t){t.Function="function",t.Event="event"}(bf||(bf={}));var Af=function(){function t(e){var r,n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r=this,i=void 0,(n=Ef(n="abi"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,this.verifyAbi(e),this.abi=e}return e=t,n=[{key:"from",value:function(e){return e instanceof t?e:new t(e)}}],(r=[{key:"hasFunction",value:function(t){return this.abi.some((function(e){return e.name===t&&"function"===e.type}))}},{key:"verifyAbi",value:function(t){if(0===t.length)throw new Error("The ABI provided is empty.");for(var e=0;e<t.length;e++){var r=t[e];if(!r.name)throw new Error("The ABI provided is missing a name.");if(!r.type)throw new Error("The ABI provided is missing a type.");r.inputs&&r.inputs.length&&this.verifyAbiValues(r.inputs),r.outputs&&r.outputs.length&&this.verifyAbiValues(r.outputs)}}},{key:"verifyAbiValues",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(!r.name)throw new Error("The ABI provided is missing an input name.");if(!r.type)throw new Error("The ABI provided is missing an input type.")}}}])&&vf(e.prototype,r),n&&vf(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}(),Sf=i(8287).Buffer;function _f(t){return _f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_f(t)}function kf(t,e,r){return e=If(e),Tf(t,Pf()?Reflect.construct(e,r||[],If(t).constructor):e.apply(t,r))}function Tf(t,e){if(e&&("object"===_f(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Pf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Pf=function(){return!!t})()}function If(t){return If=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},If(t)}function Of(t,e){return Of=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Of(t,e)}function xf(){xf=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,s=Object.create(o.prototype),a=new x(n||[]);return i(s,"_invoke",{value:T(t,r,a)}),s}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function w(){}function m(){}var v={};c(v,s,(function(){return this}));var E=Object.getPrototypeOf,A=E&&E(E(B([])));A&&A!==r&&n.call(A,s)&&(v=A);var S=m.prototype=b.prototype=Object.create(v);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(i,o,s,a){var u=f(t[i],t,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==_f(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,s){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var u=P(a,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=f(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function B(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_f(e)+" is not iterable")}return w.prototype=m,i(S,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:w,configurable:!0}),w.displayName=c(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},_(k.prototype),c(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new k(l(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},_(S),c(S,u,"Generator"),c(S,s,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=B,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Bf(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}function Rf(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){Bf(o,n,i,s,a,"next",t)}function a(t){Bf(o,n,i,s,a,"throw",t)}s(void 0)}))}}function Nf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Uf(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Cf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Mf(n.key),n)}}function Lf(t,e,r){return e&&Cf(t.prototype,e),r&&Cf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Df(t,e,r){return(e=Mf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mf(t){var e=function(t,e){if("object"!=_f(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_f(e)?e:e+""}var Ff=Symbol.for("_btc_internal"),Hf=new class{constructor(){}decodeData(t,e){const r=new Vc(t),n=[];for(let t=0;t<e.length;t++)switch(e[t]){case Wc.UINT8:n.push(r.readU8());break;case Wc.UINT16:n.push(r.readU16());break;case Wc.UINT32:n.push(r.readU32());break;case Wc.BYTES32:n.push(r.readBytes(32));break;case Wc.BOOL:n.push(r.readBoolean());break;case Wc.ADDRESS:n.push(r.readAddress());break;case Wc.STRING:n.push(r.readStringWithLength());break;case Wc.UINT256:n.push(r.readU256());break;case Wc.TUPLE:n.push(r.readTuple())}return n}encodePointer(t){const e=this.sha256(t),r=qc.alloc(jc.EXPECTED_BUFFER_LENGTH),n=e.slice(0,jc.EXPECTED_BUFFER_LENGTH);for(let t=0;t<jc.EXPECTED_BUFFER_LENGTH;t++)r[t]=n[t];return BigInt("0x"+r.toString("hex"))}encodePointerHash(t,e){const r=new Uint8Array(jc.EXPECTED_BUFFER_LENGTH+2);r[0]=255&t,r[1]=t>>8&255;const n=this.bigIntToUint8Array(e,jc.EXPECTED_BUFFER_LENGTH);r.set(n,2);const i=this.sha256(r);if(i.byteLength!==jc.EXPECTED_BUFFER_LENGTH)throw new Error("Invalid hash length");return i}encodeSelector(t){return this.sha256(t).slice(0,4).toString("hex")}numericSelectorToHex(t){return t.toString(16)}bigIntToUint8Array(t,e){const r=new Uint8Array(e),n=jc.valueToUint8Array(t);for(let t=0;t<e;t++)r[t]=n[t]||0;return r}sha256(t){return(new zc.sha256).update(t).digest()}},jf=function(){return Lf((function t(e,r,n){Uf(this,t),Df(this,"address",void 0),Df(this,"interface",void 0),Df(this,"provider",void 0),Df(this,Ff,void 0),Df(this,"events",[]),this.address=e,this.provider=n,this.interface=Af.from(r),Object.defineProperty(this,Ff,{value:{}}),this.defineInternalFunctions()}),[{key:"getFunction",value:function(t){return this[t]}},{key:"defineInternalFunctions",value:function(){var t,e=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Nf(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nf(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(this.interface.abi);try{for(e.s();!(t=e.n()).done;){var r=t.value;switch(r.type){case bf.Function:Object.defineProperty(this,r.name,{value:this.callFunction(r).bind(this)});break;case bf.Event:this.events.push(r)}}}catch(t){e.e(t)}finally{e.f()}}},{key:"encodeFunctionData",value:function(t,e){var r=new Kc,n=Number("0x"+Hf.encodeSelector(t.name));if(r.writeSelector(n),e.length!==t.inputs.length)throw new Error("Invalid number of arguments provided");if(!t.inputs||t.inputs&&0===t.inputs.length)return r;for(var i=0;i<t.inputs.length;i++)this.encodeInput(r,t.inputs[i],e[i]);return r}},{key:"encodeInput",value:function(t,e,r){var n=e.type,i=e.name;switch(n){case Wc.UINT256:if("bigint"!=typeof r)throw new Error("Expected value to be of type bigint (".concat(i,")"));t.writeU256(r);break;case Wc.BOOL:if("boolean"!=typeof r)throw new Error("Expected value to be of type boolean (".concat(i,")"));t.writeBoolean(r);break;case Wc.STRING:if("string"!=typeof r)throw new Error("Expected value to be of type string (".concat(i,")"));t.writeStringWithLength(r);break;case Wc.ADDRESS:var o=r;t.writeAddress(o.toString());break;case Wc.TUPLE:if(!(r instanceof Array))throw new Error("Expected value to be of type Array (".concat(i,")"));t.writeTuple(r);break;case Wc.UINT8:if("number"!=typeof r)throw new Error("Expected value to be of type number (".concat(i,")"));t.writeU8(r);break;case Wc.UINT16:if("number"!=typeof r)throw new Error("Expected value to be of type number (".concat(i,")"));t.writeU16(r);break;case Wc.UINT32:if("number"!=typeof r)throw new Error("Expected value to be of type number (".concat(i,")"));t.writeU32(r);break;case Wc.BYTES32:if(!(r instanceof Uint8Array))throw new Error("Expected value to be of type Uint8Array (".concat(i,")"));t.writeBytes(r);break;default:throw new Error("Unsupported type: ".concat(n," (").concat(i,")"))}}},{key:"decodeOutput",value:function(t,e){for(var r=[],n=0;n<t.length;n++){var i=t[n].type,o=t[n].name;switch(i){case Wc.UINT256:r.push(e.readU256());break;case Wc.BOOL:r.push(e.readBoolean());break;case Wc.STRING:r.push(e.readStringWithLength());break;case Wc.ADDRESS:r.push(e.readAddress());break;case Wc.TUPLE:r.push(e.readTuple());break;case Wc.UINT8:r.push(e.readU8());break;case Wc.UINT16:r.push(e.readU16());break;case Wc.UINT32:r.push(e.readU32());break;case Wc.BYTES32:r.push(e.readBytes(32));break;default:throw new Error("Unsupported type: ".concat(i," (").concat(o,")"))}}return r}},{key:"callFunction",value:function(t){var e=this;return Rf(xf().mark((function r(){var n,i,o,s,a,u,c=arguments;return xf().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(n=c.length,i=new Array(n),o=0;o<n;o++)i[o]=c[o];return s=e.encodeFunctionData(t,i),r.next=4,e.provider.call(e.address,Sf.from(s.getBuffer()));case 4:if(!("error"in(a=r.sent))){r.next=7;break}return r.abrupt("return",a);case 7:return u=t.outputs?e.decodeOutput(t.outputs,a.result):[],a.setDecoded(u),r.abrupt("return",a);case 10:case"end":return r.stop()}}),r)})))}}])}(),Gf=function(t){function e(t,r,n){var i;return Uf(this,e),Tf(i=kf(this,e,[t,r,n]),i.proxify())}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Of(t,e)}(e,t),Lf(e,[{key:"proxify",value:function(){var t=this;return new Proxy(this,{get:function(e,r,n){if("symbol"===_f(r)||r in e)return Reflect.get(e,r,n);try{return t.getFunction(r)}catch(t){throw t instanceof Error?t:new Error("Something went wrong when trying to get the function: ".concat(t))}},has:function(t,e){return"symbol"===_f(e)||e in t?Reflect.has(t,e):t.interface.hasFunction(e)}})}}])}(jf);function Vf(t,e,r){return new Gf(t,e,r)}var Kf=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Wf=Math.ceil,zf=Math.floor,qf="[BigNumber Error] ",Qf=qf+"Number primitive has more than 15 significant digits: ",Jf=1e14,Xf=14,Yf=9007199254740991,Zf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],$f=1e7,th=1e9;function eh(t){var e=0|t;return t>0||t===e?e:e-1}function rh(t){for(var e,r,n=1,i=t.length,o=t[0]+"";n<i;){for(e=t[n++]+"",r=Xf-e.length;r--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function nh(t,e){var r,n,i=t.c,o=e.c,s=t.s,a=e.s,u=t.e,c=e.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function ih(t,e,r,n){if(t<e||t>r||t!==zf(t))throw Error(qf+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function oh(t){var e=t.c.length-1;return eh(t.e/Xf)==e&&t.c[e]%2!=0}function sh(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function ah(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}var uh=function t(e){var r,n,i,o,s,a,u,c,l,f,h=T.prototype={constructor:T,toString:null,valueOf:null},p=new T(1),d=20,y=4,g=-7,b=21,w=-1e7,m=1e7,v=!1,E=1,A=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},_="0123456789abcdefghijklmnopqrstuvwxyz",k=!0;function T(t,e){var r,o,s,a,u,c,l,f,h=this;if(!(h instanceof T))return new T(t,e);if(null==e){if(t&&!0===t._isBigNumber)return h.s=t.s,void(!t.c||t.e>m?h.c=h.e=null:t.e<w?h.c=[h.e=0]:(h.e=t.e,h.c=t.c.slice()));if((c="number"==typeof t)&&0*t==0){if(h.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,u=t;u>=10;u/=10,a++);return void(a>m?h.c=h.e=null:(h.e=a,h.c=[t]))}f=String(t)}else{if(!Kf.test(f=String(t)))return i(h,f,c);h.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(a=f.indexOf("."))>-1&&(f=f.replace(".","")),(u=f.search(/e/i))>0?(a<0&&(a=u),a+=+f.slice(u+1),f=f.substring(0,u)):a<0&&(a=f.length)}else{if(ih(e,2,_.length,"Base"),10==e&&k)return x(h=new T(t),d+h.e+1,y);if(f=String(t),c="number"==typeof t){if(0*t!=0)return i(h,f,c,e);if(h.s=1/t<0?(f=f.slice(1),-1):1,T.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(Qf+t)}else h.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(r=_.slice(0,e),a=u=0,l=f.length;u<l;u++)if(r.indexOf(o=f.charAt(u))<0){if("."==o){if(u>a){a=l;continue}}else if(!s&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){s=!0,u=-1,a=0;continue}return i(h,String(t),c,e)}c=!1,(a=(f=n(f,e,10,h.s)).indexOf("."))>-1?f=f.replace(".",""):a=f.length}for(u=0;48===f.charCodeAt(u);u++);for(l=f.length;48===f.charCodeAt(--l););if(f=f.slice(u,++l)){if(l-=u,c&&T.DEBUG&&l>15&&(t>Yf||t!==zf(t)))throw Error(Qf+h.s*t);if((a=a-u-1)>m)h.c=h.e=null;else if(a<w)h.c=[h.e=0];else{if(h.e=a,h.c=[],u=(a+1)%Xf,a<0&&(u+=Xf),u<l){for(u&&h.c.push(+f.slice(0,u)),l-=Xf;u<l;)h.c.push(+f.slice(u,u+=Xf));u=Xf-(f=f.slice(u)).length}else u-=l;for(;u--;f+="0");h.c.push(+f)}}else h.c=[h.e=0]}function P(t,e,r,n){var i,o,s,a,u;if(null==r?r=y:ih(r,0,8),!t.c)return t.toString();if(i=t.c[0],s=t.e,null==e)u=rh(t.c),u=1==n||2==n&&(s<=g||s>=b)?sh(u,s):ah(u,s,"0");else if(o=(t=x(new T(t),e,r)).e,a=(u=rh(t.c)).length,1==n||2==n&&(e<=o||o<=g)){for(;a<e;u+="0",a++);u=sh(u,o)}else if(e-=s,u=ah(u,o,"0"),o+1>a){if(--e>0)for(u+=".";e--;u+="0");}else if((e+=o-a)>0)for(o+1==a&&(u+=".");e--;u+="0");return t.s<0&&i?"-"+u:u}function I(t,e){for(var r,n,i=1,o=new T(t[0]);i<t.length;i++)(!(n=new T(t[i])).s||(r=nh(o,n))===e||0===r&&o.s===e)&&(o=n);return o}function O(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*Xf-1)>m?t.c=t.e=null:r<w?t.c=[t.e=0]:(t.e=r,t.c=e),t}function x(t,e,r,n){var i,o,s,a,u,c,l,f=t.c,h=Zf;if(f){t:{for(i=1,a=f[0];a>=10;a/=10,i++);if((o=e-i)<0)o+=Xf,s=e,u=f[c=0],l=zf(u/h[i-s-1]%10);else if((c=Wf((o+1)/Xf))>=f.length){if(!n)break t;for(;f.length<=c;f.push(0));u=l=0,i=1,s=(o%=Xf)-Xf+1}else{for(u=a=f[c],i=1;a>=10;a/=10,i++);l=(s=(o%=Xf)-Xf+i)<0?0:zf(u/h[i-s-1]%10)}if(n=n||e<0||null!=f[c+1]||(s<0?u:u%h[i-s-1]),n=r<4?(l||n)&&(0==r||r==(t.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(o>0?s>0?u/h[i-s]:0:f[c-1])%10&1||r==(t.s<0?8:7)),e<1||!f[0])return f.length=0,n?(e-=t.e+1,f[0]=h[(Xf-e%Xf)%Xf],t.e=-e||0):f[0]=t.e=0,t;if(0==o?(f.length=c,a=1,c--):(f.length=c+1,a=h[Xf-o],f[c]=s>0?zf(u/h[i-s]%h[s])*a:0),n)for(;;){if(0==c){for(o=1,s=f[0];s>=10;s/=10,o++);for(s=f[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(t.e++,f[0]==Jf&&(f[0]=1));break}if(f[c]+=a,f[c]!=Jf)break;f[c--]=0,a=1}for(o=f.length;0===f[--o];f.pop());}t.e>m?t.c=t.e=null:t.e<w&&(t.c=[t.e=0])}return t}function B(t){var e,r=t.e;return null===r?t.toString():(e=rh(t.c),e=r<=g||r>=b?sh(e,r):ah(e,r,"0"),t.s<0?"-"+e:e)}return T.clone=t,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(qf+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(ih(r=t[e],0,th,e),d=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(ih(r=t[e],0,8,e),y=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(ih(r[0],-th,0,e),ih(r[1],0,th,e),g=r[0],b=r[1]):(ih(r,-th,th,e),g=-(b=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)ih(r[0],-th,-1,e),ih(r[1],1,th,e),w=r[0],m=r[1];else{if(ih(r,-th,th,e),!r)throw Error(qf+e+" cannot be zero: "+r);w=-(m=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(qf+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw v=!r,Error(qf+"crypto unavailable");v=r}else v=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(ih(r=t[e],0,9,e),E=r),t.hasOwnProperty(e="POW_PRECISION")&&(ih(r=t[e],0,th,e),A=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(qf+e+" not an object: "+r);S=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(qf+e+" invalid: "+r);k="0123456789"==r.slice(0,10),_=r}}return{DECIMAL_PLACES:d,ROUNDING_MODE:y,EXPONENTIAL_AT:[g,b],RANGE:[w,m],CRYPTO:v,MODULO_MODE:E,POW_PRECISION:A,FORMAT:S,ALPHABET:_}},T.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!T.DEBUG)return!0;var e,r,n=t.c,i=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-th&&i<=th&&i===zf(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break t}if((e=(i+1)%Xf)<1&&(e+=Xf),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||r>=Jf||r!==zf(r))break t;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(qf+"Invalid BigNumber: "+t)},T.maximum=T.max=function(){return I(arguments,-1)},T.minimum=T.min=function(){return I(arguments,1)},T.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return zf(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,i,o,a=0,u=[],c=new T(p);if(null==t?t=d:ih(t,0,th),i=Wf(t/Xf),v)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));a<i;)(o=131072*e[a]+(e[a+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[a]=r[0],e[a+1]=r[1]):(u.push(o%1e14),a+=2);a=i/2}else{if(!crypto.randomBytes)throw v=!1,Error(qf+"crypto unavailable");for(e=crypto.randomBytes(i*=7);a<i;)(o=281474976710656*(31&e[a])+1099511627776*e[a+1]+4294967296*e[a+2]+16777216*e[a+3]+(e[a+4]<<16)+(e[a+5]<<8)+e[a+6])>=9e15?crypto.randomBytes(7).copy(e,a):(u.push(o%1e14),a+=7);a=i/7}if(!v)for(;a<i;)(o=s())<9e15&&(u[a++]=o%1e14);for(i=u[--a],t%=Xf,i&&t&&(o=Zf[Xf-t],u[a]=zf(i/o)*o);0===u[a];u.pop(),a--);if(a<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=Xf);for(a=1,o=u[0];o>=10;o/=10,a++);a<Xf&&(n-=Xf-a)}return c.e=n,c.c=u,c}),T.sum=function(){for(var t=1,e=arguments,r=new T(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,o,s=[0],a=0,u=t.length;a<u;){for(o=s.length;o--;s[o]*=e);for(s[0]+=n.indexOf(t.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var u,c,l,f,h,p,g,b,w=n.indexOf("."),m=d,v=y;for(w>=0&&(f=A,A=0,n=n.replace(".",""),p=(b=new T(i)).pow(n.length-w),A=f,b.c=e(ah(rh(p.c),p.e,"0"),10,o,t),b.e=b.c.length),l=f=(g=e(n,i,o,a?(u=_,t):(u=t,_))).length;0==g[--f];g.pop());if(!g[0])return u.charAt(0);if(w<0?--l:(p.c=g,p.e=l,p.s=s,g=(p=r(p,b,m,v,o)).c,h=p.r,l=p.e),w=g[c=l+m+1],f=o/2,h=h||c<0||null!=g[c+1],h=v<4?(null!=w||h)&&(0==v||v==(p.s<0?3:2)):w>f||w==f&&(4==v||h||6==v&&1&g[c-1]||v==(p.s<0?8:7)),c<1||!g[0])n=h?ah(u.charAt(1),-m,u.charAt(0)):u.charAt(0);else{if(g.length=c,h)for(--o;++g[--c]>o;)g[c]=0,c||(++l,g=[1].concat(g));for(f=g.length;!g[--f];);for(w=0,n="";w<=f;n+=u.charAt(g[w++]));n=ah(n,l,u.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,o,s,a=0,u=t.length,c=e%$f,l=e/$f|0;for(t=t.slice();u--;)a=((i=c*(o=t[u]%$f)+(n=l*o+(s=t[u]/$f|0)*c)%$f*$f+a)/r|0)+(n/$f|0)+l*s,t[u]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,o,s,a){var u,c,l,f,h,p,d,y,g,b,w,m,v,E,A,S,_,k=n.s==i.s?1:-1,P=n.c,I=i.c;if(!(P&&P[0]&&I&&I[0]))return new T(n.s&&i.s&&(P?!I||P[0]!=I[0]:I)?P&&0==P[0]||!I?0*k:k/0:NaN);for(g=(y=new T(k)).c=[],k=o+(c=n.e-i.e)+1,a||(a=Jf,c=eh(n.e/Xf)-eh(i.e/Xf),k=k/Xf|0),l=0;I[l]==(P[l]||0);l++);if(I[l]>(P[l]||0)&&c--,k<0)g.push(1),f=!0;else{for(E=P.length,S=I.length,l=0,k+=2,(h=zf(a/(I[0]+1)))>1&&(I=t(I,h,a),P=t(P,h,a),S=I.length,E=P.length),v=S,w=(b=P.slice(0,S)).length;w<S;b[w++]=0);_=I.slice(),_=[0].concat(_),A=I[0],I[1]>=a/2&&A++;do{if(h=0,(u=e(I,b,S,w))<0){if(m=b[0],S!=w&&(m=m*a+(b[1]||0)),(h=zf(m/A))>1)for(h>=a&&(h=a-1),d=(p=t(I,h,a)).length,w=b.length;1==e(p,b,d,w);)h--,r(p,S<d?_:I,d,a),d=p.length,u=1;else 0==h&&(u=h=1),d=(p=I.slice()).length;if(d<w&&(p=[0].concat(p)),r(b,p,w,a),w=b.length,-1==u)for(;e(I,b,S,w)<1;)h++,r(b,S<w?_:I,w,a),w=b.length}else 0===u&&(h++,b=[0]);g[l++]=h,b[0]?b[w++]=P[v]||0:(b=[P[v]],w=1)}while((v++<E||null!=b[0])&&k--);f=null!=b[0],g[0]||g.splice(0,1)}if(a==Jf){for(l=1,k=g[0];k>=10;k/=10,l++);x(y,o+(y.e=l+c*Xf-1)+1,s,f)}else y.e=c,y.r=+f;return y}}(),a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,c=/^\.([^.]+)$/,l=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,r,n){var i,o=r?e:e.replace(f,"");if(l.test(o))t.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(a,(function(t,e,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?t:e})),n&&(i=n,o=o.replace(u,"$1").replace(c,"0.$1")),e!=o))return new T(o,i);if(T.DEBUG)throw Error(qf+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},h.absoluteValue=h.abs=function(){var t=new T(this);return t.s<0&&(t.s=1),t},h.comparedTo=function(t,e){return nh(this,new T(t,e))},h.decimalPlaces=h.dp=function(t,e){var r,n,i,o=this;if(null!=t)return ih(t,0,th),null==e?e=y:ih(e,0,8),x(new T(o),t+o.e+1,e);if(!(r=o.c))return null;if(n=((i=r.length-1)-eh(this.e/Xf))*Xf,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},h.dividedBy=h.div=function(t,e){return r(this,new T(t,e),d,y)},h.dividedToIntegerBy=h.idiv=function(t,e){return r(this,new T(t,e),0,1)},h.exponentiatedBy=h.pow=function(t,e){var r,n,i,o,s,a,u,c,l=this;if((t=new T(t)).c&&!t.isInteger())throw Error(qf+"Exponent not an integer: "+B(t));if(null!=e&&(e=new T(e)),s=t.e>14,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!t.c||!t.c[0])return c=new T(Math.pow(+B(l),s?t.s*(2-oh(t)):+B(t))),e?c.mod(e):c;if(a=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new T(NaN);(n=!a&&l.isInteger()&&e.isInteger())&&(l=l.mod(e))}else{if(t.e>9&&(l.e>0||l.e<-1||(0==l.e?l.c[0]>1||s&&l.c[1]>=24e7:l.c[0]<8e13||s&&l.c[0]<=9999975e7)))return o=l.s<0&&oh(t)?-0:0,l.e>-1&&(o=1/o),new T(a?1/o:o);A&&(o=Wf(A/Xf+2))}for(s?(r=new T(.5),a&&(t.s=1),u=oh(t)):u=(i=Math.abs(+B(t)))%2,c=new T(p);;){if(u){if(!(c=c.times(l)).c)break;o?c.c.length>o&&(c.c.length=o):n&&(c=c.mod(e))}if(i){if(0===(i=zf(i/2)))break;u=i%2}else if(x(t=t.times(r),t.e+1,1),t.e>14)u=oh(t);else{if(0==(i=+B(t)))break;u=i%2}l=l.times(l),o?l.c&&l.c.length>o&&(l.c.length=o):n&&(l=l.mod(e))}return n?c:(a&&(c=p.div(c)),e?c.mod(e):o?x(c,A,y,void 0):c)},h.integerValue=function(t){var e=new T(this);return null==t?t=y:ih(t,0,8),x(e,e.e+1,t)},h.isEqualTo=h.eq=function(t,e){return 0===nh(this,new T(t,e))},h.isFinite=function(){return!!this.c},h.isGreaterThan=h.gt=function(t,e){return nh(this,new T(t,e))>0},h.isGreaterThanOrEqualTo=h.gte=function(t,e){return 1===(e=nh(this,new T(t,e)))||0===e},h.isInteger=function(){return!!this.c&&eh(this.e/Xf)>this.c.length-2},h.isLessThan=h.lt=function(t,e){return nh(this,new T(t,e))<0},h.isLessThanOrEqualTo=h.lte=function(t,e){return-1===(e=nh(this,new T(t,e)))||0===e},h.isNaN=function(){return!this.s},h.isNegative=function(){return this.s<0},h.isPositive=function(){return this.s>0},h.isZero=function(){return!!this.c&&0==this.c[0]},h.minus=function(t,e){var r,n,i,o,s=this,a=s.s;if(e=(t=new T(t,e)).s,!a||!e)return new T(NaN);if(a!=e)return t.s=-e,s.plus(t);var u=s.e/Xf,c=t.e/Xf,l=s.c,f=t.c;if(!u||!c){if(!l||!f)return l?(t.s=-e,t):new T(f?s:NaN);if(!l[0]||!f[0])return f[0]?(t.s=-e,t):new T(l[0]?s:3==y?-0:0)}if(u=eh(u),c=eh(c),l=l.slice(),a=u-c){for((o=a<0)?(a=-a,i=l):(c=u,i=f),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(o=(a=l.length)<(e=f.length))?a:e,a=e=0;e<n;e++)if(l[e]!=f[e]){o=l[e]<f[e];break}if(o&&(i=l,l=f,f=i,t.s=-t.s),(e=(n=f.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=Jf-1;n>a;){if(l[--n]<f[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=Jf}l[n]-=f[n]}for(;0==l[0];l.splice(0,1),--c);return l[0]?O(t,l,c):(t.s=3==y?-1:1,t.c=[t.e=0],t)},h.modulo=h.mod=function(t,e){var n,i,o=this;return t=new T(t,e),!o.c||!t.s||t.c&&!t.c[0]?new T(NaN):!t.c||o.c&&!o.c[0]?new T(o):(9==E?(i=t.s,t.s=1,n=r(o,t,0,3),t.s=i,n.s*=i):n=r(o,t,0,E),(t=o.minus(n.times(t))).c[0]||1!=E||(t.s=o.s),t)},h.multipliedBy=h.times=function(t,e){var r,n,i,o,s,a,u,c,l,f,h,p,d,y,g,b=this,w=b.c,m=(t=new T(t,e)).c;if(!(w&&m&&w[0]&&m[0]))return!b.s||!t.s||w&&!w[0]&&!m||m&&!m[0]&&!w?t.c=t.e=t.s=null:(t.s*=b.s,w&&m?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=eh(b.e/Xf)+eh(t.e/Xf),t.s*=b.s,(u=w.length)<(f=m.length)&&(d=w,w=m,m=d,i=u,u=f,f=i),i=u+f,d=[];i--;d.push(0));for(y=Jf,g=$f,i=f;--i>=0;){for(r=0,h=m[i]%g,p=m[i]/g|0,o=i+(s=u);o>i;)r=((c=h*(c=w[--s]%g)+(a=p*c+(l=w[s]/g|0)*h)%g*g+d[o]+r)/y|0)+(a/g|0)+p*l,d[o--]=c%y;d[o]=r}return r?++n:d.splice(0,1),O(t,d,n)},h.negated=function(){var t=new T(this);return t.s=-t.s||null,t},h.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new T(t,e)).s,!i||!e)return new T(NaN);if(i!=e)return t.s=-e,n.minus(t);var o=n.e/Xf,s=t.e/Xf,a=n.c,u=t.c;if(!o||!s){if(!a||!u)return new T(i/0);if(!a[0]||!u[0])return u[0]?t:new T(a[0]?n:0*i)}if(o=eh(o),s=eh(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=u):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=u.length)<0&&(r=u,u=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+u[e]+i)/Jf|0,a[e]=Jf===a[e]?0:a[e]%Jf;return i&&(a=[i].concat(a),++s),O(t,a,s)},h.precision=h.sd=function(t,e){var r,n,i,o=this;if(null!=t&&t!==!!t)return ih(t,1,th),null==e?e=y:ih(e,0,8),x(new T(o),t,e);if(!(r=o.c))return null;if(n=(i=r.length-1)*Xf+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&o.e+1>n&&(n=o.e+1),n},h.shiftedBy=function(t){return ih(t,-9007199254740991,Yf),this.times("1e"+t)},h.squareRoot=h.sqrt=function(){var t,e,n,i,o,s=this,a=s.c,u=s.s,c=s.e,l=d+4,f=new T("0.5");if(1!==u||!a||!a[0])return new T(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+B(s)))||u==1/0?(((e=rh(a)).length+c)%2==0&&(e+="0"),u=Math.sqrt(+e),c=eh((c+1)/2)-(c<0||c%2),n=new T(e=u==1/0?"5e"+c:(e=u.toExponential()).slice(0,e.indexOf("e")+1)+c)):n=new T(u+""),n.c[0])for((u=(c=n.e)+l)<3&&(u=0);;)if(o=n,n=f.times(o.plus(r(s,o,l,1))),rh(o.c).slice(0,u)===(e=rh(n.c)).slice(0,u)){if(n.e<c&&--u,"9999"!=(e=e.slice(u-3,u+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(x(n,n.e+d+2,1),t=!n.times(n).eq(s));break}if(!i&&(x(o,o.e+d+2,0),o.times(o).eq(s))){n=o;break}l+=4,u+=4,i=1}return x(n,n.e+d+1,y,t)},h.toExponential=function(t,e){return null!=t&&(ih(t,0,th),t++),P(this,t,e,1)},h.toFixed=function(t,e){return null!=t&&(ih(t,0,th),t=t+this.e+1),P(this,t,e)},h.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=S;else if("object"!=typeof r)throw Error(qf+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var o,s=n.split("."),a=+r.groupSize,u=+r.secondaryGroupSize,c=r.groupSeparator||"",l=s[0],f=s[1],h=i.s<0,p=h?l.slice(1):l,d=p.length;if(u&&(o=a,a=u,u=o,d-=o),a>0&&d>0){for(o=d%a||a,l=p.substr(0,o);o<d;o+=a)l+=c+p.substr(o,a);u>0&&(l+=c+p.slice(o)),h&&(l="-"+l)}n=f?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):l}return(r.prefix||"")+n+(r.suffix||"")},h.toFraction=function(t){var e,n,i,o,s,a,u,c,l,f,h,d,g=this,b=g.c;if(null!=t&&(!(u=new T(t)).isInteger()&&(u.c||1!==u.s)||u.lt(p)))throw Error(qf+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+B(u));if(!b)return new T(g);for(e=new T(p),l=n=new T(p),i=c=new T(p),d=rh(b),s=e.e=d.length-g.e-1,e.c[0]=Zf[(a=s%Xf)<0?Xf+a:a],t=!t||u.comparedTo(e)>0?s>0?e:l:u,a=m,m=1/0,u=new T(d),c.c[0]=0;f=r(u,e,0,1),1!=(o=n.plus(f.times(i))).comparedTo(t);)n=i,i=o,l=c.plus(f.times(o=l)),c=o,e=u.minus(f.times(o=e)),u=o;return o=r(t.minus(n),i,0,1),c=c.plus(o.times(l)),n=n.plus(o.times(i)),c.s=l.s=g.s,h=r(l,i,s*=2,y).minus(g).abs().comparedTo(r(c,n,s,y).minus(g).abs())<1?[l,i]:[c,n],m=a,h},h.toNumber=function(){return+B(this)},h.toPrecision=function(t,e){return null!=t&&ih(t,1,th),P(this,t,e,2)},h.toString=function(t){var e,r=this,i=r.s,o=r.e;return null===o?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=o<=g||o>=b?sh(rh(r.c),o):ah(rh(r.c),o,"0"):10===t&&k?e=ah(rh((r=x(new T(r),d+o+1,y)).c),r.e,"0"):(ih(t,2,_.length,"Base"),e=n(ah(rh(r.c),o,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},h.valueOf=h.toJSON=function(){return B(this)},h._isBigNumber=!0,h[Symbol.toStringTag]="BigNumber",h[Symbol.for("nodejs.util.inspect.custom")]=h.valueOf,null!=e&&T.set(e),T}();const ch=uh;function lh(t){return lh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lh(t)}function fh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,hh(n.key),n)}}function hh(t){var e=function(t,e){if("object"!=lh(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=lh(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lh(e)?e:e+""}var ph=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"formatUnits",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return new ch(t.toString()).dividedBy(new ch(10).pow(e)).toString()}}],null&&fh(t.prototype,null),e&&fh(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),dh=i(3513),yh=i.t(dh,2),gh=i(8700),bh=i(8287).Buffer;function wh(t){return wh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wh(t)}function mh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vh(n.key),n)}}function vh(t){var e=function(t,e){if("object"!=wh(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=wh(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wh(e)?e:e+""}function Eh(t,e,r){!function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}(t,e),e.set(t,r)}function Ah(t,e){return t.get(_h(t,e))}function Sh(t,e,r){return t.set(_h(t,e),r),r}function _h(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(0,h.f0)(yh);var kh=(0,gh.dg)(yh),Th=new WeakMap,Ph=new WeakMap,Ih=new WeakMap,Oh=function(){function t(e){var r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Eh(this,Th,void 0),Eh(this,Ph,void 0),Eh(this,Ih,void 0),r=this,i=void 0,(n=vh(n="network"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,Sh(Th,this,e),this.network=o,Sh(Ph,this,this.getTaprootAddress()),Sh(Ih,this,this.getP2WPKHAddress())}return e=t,r=[{key:"taprootAddress",get:function(){if(!Ah(Ph,this))throw new Error("Address not set");return Ah(Ph,this)}},{key:"p2wpkhAddress",get:function(){if(!Ah(Ih,this))throw new Error("Address not set");return Ah(Ih,this)}},{key:"publicKey",get:function(){if(!Ah(Th,this))throw new Error("KeyPair not set");return Ah(Th,this).publicKey}},{key:"privateKey",get:function(){if(!Ah(Th,this))throw new Error("KeyPair not set");return Ah(Th,this).privateKey}},{key:Symbol.toStringTag,value:function(){return this.taprootAddress}},{key:"getP2WPKHAddress",value:function(){var t=h.KT.p2wpkh({pubkey:Ah(Th,this).publicKey,network:this.network});if(!t.address)throw new Error("Failed to generate wallet");return t.address}},{key:"getTaprootAddress",value:function(){if(!Ah(Th,this))throw new Error("KeyPair not set");var t=Ah(Th,this).publicKey.slice(1,33),e=bh.concat([bh.from([81,32]),t]);return h.hl.fromOutputScript(e,this.network)}}],n=[{key:"isValidTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;try{var r;return r="string"==typeof t?t:t.taprootAddress,!!h.hl.toOutputScript(r,e)}catch(t){return!1}}},{key:"fromPublicKey",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;return new t(kh.fromPublicKey(e,{network:r}),r)}},{key:"fromPrivateKey",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;return new t(kh.fromPrivateKey(e,{network:r}),r)}},{key:"fromWif",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;return new t(kh.fromWIF(e,r),r)}}],r&&mh(e.prototype,r),n&&mh(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}()})();var s=o.y3,a=o.Lk,u=o.Uq,c=o.EI,l=o.JL,f=o.M7,h=o.G7,p=o.eB,d=o.Q9,y=o.rO,g=o.qT,b=o.Yy,w=o.JV,m=o.Bc,v=o.r,E=o.W4,A=o.rs,S=o.OB,_=o.PN,k=o.Mw,T=o.GE,P=o.z5,I=o.XV,O=o.Wj,x=o.PF,B=o.$7,R=o.rE;export{s as ABIDataTypes,a as AbstractRpcProvider,u as BaseContract,c as BitcoinAbiTypes,l as BitcoinAddress,f as BitcoinInterface,h as BitcoinUtils,p as Block,d as CallResult,y as ContractData,g as DeploymentTransaction,b as GenericTransaction,w as IBaseContract,m as InteractionTransaction,v as JSONRpcProvider,E as OPNetTransactionTypes,A as StoredValue,S as TransactionBase,_ as TransactionInput,k as TransactionOutput,T as TransactionParser,P as TransactionReceipt,I as UTXO,O as WebSocketRpcProvider,x as getContract,B as opnet,R as version};
2
+ var t,e,r={3513:(t,e,r)=>{var n=r(8287).Buffer,i=r(9598),o=r(9615),s=r(2623);function a(t){var e=Object.create(null);return t&&Object.keys(t).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(e,r,n.get?n:{enumerable:!0,get:function(){return t[r]}})}})),e.default=t,Object.freeze(e)}var u=a(i);const c="Expected Private",l="Expected Point",f="Expected Tweak",h="Expected Signature",p="Expected Extra Data (32 bytes)",d="Expected Scalar";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(s.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>s.sha256(u.utils.concatBytes(...t));const y=u.utils._normalizePrivateKey,g=new Uint8Array([255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,254,186,174,220,230,175,72,160,59,191,210,94,140,208,54,65,65]),b=new Uint8Array(32),w=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,69,81,35,25,80,183,95,196,64,45,161,114,47,201,186,238]);function m(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function v(t){return 0===m(t,b)}function E(t){return t instanceof Uint8Array&&32===t.length&&!(m(t,g)>=0)}function A(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),g)<0&&m(t.subarray(32,64),g)<0}function S(t){return t instanceof Uint8Array&&32===t.length}function _(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function k(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function T(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>=0)e=BigInt(t);else if("string"==typeof t){if(64!==t.length)throw new Error("Expected 32 bytes of private scalar");e=k(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private scalar");if(32!==t.length)throw new Error("Expected 32 bytes of private scalar");r=t,e=k(u.utils.bytesToHex(r))}var r;if(e<0)throw new Error("Expected private scalar >= 0");return e}const P=(t,e,r)=>{const n=u.Point.fromHex(t),i=T(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)};function I(t,e){return void 0===t?void 0===e||R(e):!!t}function O(t){try{return t()}catch(t){return null}}function x(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function B(t){return x(t,!1)}function R(t){return x(t,!1)&&33===t.length}function N(t){return u.utils.isValidPrivateKey(t)}function U(t){return x(t,!0)}function C(t){if(!B(t))throw new Error(l);return t.slice(1,33)}function L(t,e){if(!N(t))throw new Error(c);return O((()=>u.getPublicKey(t,I(e))))}e.isPoint=B,e.isPointCompressed=R,e.isPrivate=N,e.isXOnlyPoint=U,e.pointAdd=function(t,e,r){if(!B(t)||!B(e))throw new Error(l);return O((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(I(r,t))}))},e.pointAddScalar=function(t,e,r){if(!B(t))throw new Error(l);if(!E(e))throw new Error(f);return O((()=>P(t,e,I(r,t))))},e.pointCompress=function(t,e){if(!B(t))throw new Error(l);return u.Point.fromHex(t).toRawBytes(I(e,t))},e.pointFromScalar=L,e.pointMultiply=function(t,e,r){if(!B(t))throw new Error(l);if(!E(e))throw new Error(f);return O((()=>((t,e,r)=>{const n=u.Point.fromHex(t),i="string"==typeof e?e:u.utils.bytesToHex(e),o=BigInt(`0x${i}`);return n.multiply(o).toRawBytes(r)})(t,e,I(r,t))))},e.privateAdd=function(t,e){if(!1===N(t))throw new Error(c);if(!1===E(e))throw new Error(f);return O((()=>((t,e)=>{const r=y(t),n=T(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r+n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.privateNegate=function(t){if(!1===N(t))throw new Error(c);return(t=>{const e=y(t),r=u.utils._bigintTo32Bytes(u.CURVE.n-e);return u.utils.isValidPrivateKey(r)?r:null})(t)},e.privateSub=function(t,e){if(!1===N(t))throw new Error(c);if(!1===E(e))throw new Error(f);return O((()=>((t,e)=>{const r=y(t),n=T(e),i=u.utils._bigintTo32Bytes(u.utils.mod(r-n,u.CURVE.n));return u.utils.isValidPrivateKey(i)?i:null})(t,e)))},e.recover=function(t,e,r,n){if(!S(t))throw new Error("Expected Hash");if(!A(e)||!function(t){return!(v(t.subarray(0,32))||v(t.subarray(32,64)))}(e))throw new Error(h);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&m(t.subarray(0,32),w)<0}(e))throw new Error("Bad Recovery Id");if(!U(e.subarray(0,32)))throw new Error(h);return u.recoverPublicKey(t,e,r,I(n))},e.sign=function(t,e,r){if(!N(e))throw new Error(c);if(!S(t))throw new Error(d);if(!_(r))throw new Error(p);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!N(e))throw new Error(c);if(!S(t))throw new Error(d);if(!_(r))throw new Error(p);const[n,i]=u.signSync(t,e,{der:!1,extraEntropy:r,recovered:!0});return{signature:n,recoveryId:i}},e.signSchnorr=function(t,e,r=n.alloc(32,0)){if(!N(e))throw new Error(c);if(!S(t))throw new Error(d);if(!_(r))throw new Error(p);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!B(e))throw new Error(l);if(!A(r))throw new Error(h);if(!S(t))throw new Error(d);return u.verify(r,t,e,{strict:n})},e.verifySchnorr=function(t,e,r){if(!U(e))throw new Error(l);if(!A(r))throw new Error(h);if(!S(t))throw new Error(d);return u.schnorr.verifySync(r,t,e)},e.xOnlyPointAddTweak=function(t,e){if(!U(t))throw new Error(l);if(!E(e))throw new Error(f);return O((()=>{const r=P(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=C,e.xOnlyPointFromScalar=function(t){if(!N(t))throw new Error(c);return C(L(t))}},7557:(t,e)=>{function r(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function n(t){if("boolean"!=typeof t)throw new Error(`boolean expected, not ${t}`)}function i(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function o(t,...e){if(!i(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error(`Uint8Array expected of length ${e}, not of length=${t.length}`)}function s(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");r(t.outputLen),r(t.blockLen)}function a(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 u(t,e){o(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}Object.defineProperty(e,"__esModule",{value:!0}),e.output=e.exists=e.hash=e.bytes=e.bool=e.number=e.isBytes=void 0,e.number=r,e.bool=n,e.isBytes=i,e.bytes=o,e.hash=s,e.exists=a,e.output=u;const c={number:r,bool:n,bytes:o,hash:s,exists:a,output:u};e.default=c},7202:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.HashMD=e.Maj=e.Chi=void 0;const n=r(7557),i=r(9175);e.Chi=(t,e,r)=>t&e^~t&r,e.Maj=(t,e,r)=>t&e^t&r^e&r;class o extends i.Hash{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=(0,i.createView)(this.buffer)}update(t){(0,n.exists)(this);const{view:e,buffer:r,blockLen:o}=this,s=(t=(0,i.toBytes)(t)).length;for(let n=0;n<s;){const a=Math.min(o-this.pos,s-n);if(a!==o)r.set(t.subarray(n,n+a),this.pos),this.pos+=a,n+=a,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=s-n;n+=o)this.process(e,n)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){(0,n.exists)(this),(0,n.output)(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:o,isLE:s}=this;let{pos:a}=this;e[a++]=128,this.buffer.subarray(a).fill(0),this.padOffset>o-a&&(this.process(r,0),a=0);for(let t=a;t<o;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,o-8,BigInt(8*this.length),s),this.process(r,0);const u=(0,i.createView)(t),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,f=this.get();if(l>f.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<l;t++)u.setUint32(4*t,f[t],s)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=o},5145:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.crypto=void 0,e.crypto="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0},9615:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.hmac=e.HMAC=void 0;const n=r(7557),i=r(9175);class o extends i.Hash{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,(0,n.hash)(t);const r=(0,i.toBytes)(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<s.length;t++)s[t]^=54;this.iHash.update(s),this.oHash=t.create();for(let t=0;t<s.length;t++)s[t]^=106;this.oHash.update(s),s.fill(0)}update(t){return(0,n.exists)(this),this.iHash.update(t),this}digestInto(t){(0,n.exists)(this),(0,n.bytes)(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}e.HMAC=o,e.hmac=(t,e,r)=>new o(t,e).update(r).digest(),e.hmac.create=(t,e)=>new o(t,e)},3238:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.ripemd160=e.RIPEMD160=void 0;const n=r(7202),i=r(9175),o=new Uint8Array([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),s=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e)));let a=[s],u=[s.map((t=>(9*t+5)%16))];for(let t=0;t<4;t++)for(let e of[a,u])e.push(e[t].map((t=>o[t])));const c=[[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))),l=a.map(((t,e)=>t.map((t=>c[e][t])))),f=u.map(((t,e)=>t.map((t=>c[e][t])))),h=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),p=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function d(t,e,r,n){return 0===t?e^r^n:1===t?e&r|~e&n:2===t?(e|~r)^n:3===t?e&n|r&~n:e^(r|~n)}const y=new Uint32Array(16);class g extends n.HashMD{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:e,h2:r,h3:n,h4:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.h0=0|t,this.h1=0|e,this.h2=0|r,this.h3=0|n,this.h4=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)y[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,s=o,c=0|this.h2,g=c,b=0|this.h3,w=b,m=0|this.h4,v=m;for(let t=0;t<5;t++){const e=4-t,E=h[t],A=p[t],S=a[t],_=u[t],k=l[t],T=f[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+d(t,o,c,b)+y[S[e]]+E,k[e])+m|0;r=m,m=b,b=0|(0,i.rotl)(c,10),c=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+d(e,s,g,w)+y[_[t]]+A,T[t])+v|0;n=v,v=w,w=0|(0,i.rotl)(g,10),g=s,s=r}}this.set(this.h1+c+w|0,this.h2+b+v|0,this.h3+m+n|0,this.h4+r+s|0,this.h0+o+g|0)}roundClean(){y.fill(0)}destroy(){this.destroyed=!0,this.buffer.fill(0),this.set(0,0,0,0,0)}}e.RIPEMD160=g,e.ripemd160=(0,i.wrapConstructor)((()=>new g))},1549:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha1=void 0;const n=r(7202),i=r(9175),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),s=new Uint32Array(80);class a extends n.HashMD{constructor(){super(64,20,8,!1),this.A=0|o[0],this.B=0|o[1],this.C=0|o[2],this.D=0|o[3],this.E=0|o[4]}get(){const{A:t,B:e,C:r,D:n,E:i}=this;return[t,e,r,n,i]}set(t,e,r,n,i){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)s[t]=(0,i.rotl)(s[t-3]^s[t-8]^s[t-14]^s[t-16],1);let{A:r,B:o,C:a,D:u,E:c}=this;for(let t=0;t<80;t++){let e,l;t<20?(e=(0,n.Chi)(o,a,u),l=1518500249):t<40?(e=o^a^u,l=1859775393):t<60?(e=(0,n.Maj)(o,a,u),l=2400959708):(e=o^a^u,l=3395469782);const f=(0,i.rotl)(r,5)+e+c+l+s[t]|0;c=u,u=a,a=(0,i.rotl)(o,30),o=r,r=f}r=r+this.A|0,o=o+this.B|0,a=a+this.C|0,u=u+this.D|0,c=c+this.E|0,this.set(r,o,a,u,c)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.sha1=(0,i.wrapConstructor)((()=>new a))},2623:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=void 0;const n=r(7202),i=r(9175),o=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]),s=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),a=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|s[0],this.B=0|s[1],this.C=0|s[2],this.D=0|s[3],this.E=0|s[4],this.F=0|s[5],this.G=0|s[6],this.H=0|s[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)a[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=a[t-15],r=a[t-2],n=(0,i.rotr)(e,7)^(0,i.rotr)(e,18)^e>>>3,o=(0,i.rotr)(r,17)^(0,i.rotr)(r,19)^r>>>10;a[t]=o+a[t-7]+n+a[t-16]|0}let{A:r,B:s,C:u,D:c,E:l,F:f,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(l,6)^(0,i.rotr)(l,11)^(0,i.rotr)(l,25))+(0,n.Chi)(l,f,h)+o[t]+a[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,s,u)|0;p=h,h=f,f=l,l=c+e|0,c=u,u=s,s=r,r=e+d|0}r=r+this.A|0,s=s+this.B|0,u=u+this.C|0,c=c+this.D|0,l=l+this.E|0,f=f+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,s,u,c,l,f,h,p)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}class c extends u{constructor(){super(),this.A=-1056596264,this.B=914150663,this.C=812702999,this.D=-150054599,this.E=-4191439,this.F=1750603025,this.G=1694076839,this.H=-1090891868,this.outputLen=28}}e.sha256=(0,i.wrapConstructor)((()=>new u)),e.sha224=(0,i.wrapConstructor)((()=>new c))},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.randomBytes=e.wrapXOFConstructorWithOpts=e.wrapConstructorWithOpts=e.wrapConstructor=e.checkOpts=e.Hash=e.concatBytes=e.toBytes=e.utf8ToBytes=e.asyncLoop=e.nextTick=e.hexToBytes=e.bytesToHex=e.byteSwap32=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=e.isBytes=void 0;const n=r(5145),i=r(7557);e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.u8=t=>new Uint8Array(t.buffer,t.byteOffset,t.byteLength),e.u32=t=>new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4)),e.createView=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),e.rotr=(t,e)=>t<<32-e|t>>>e,e.rotl=(t,e)=>t<<e|t>>>32-e>>>0,e.isLE=68===new Uint8Array(new Uint32Array([287454020]).buffer)[0],e.byteSwap=t=>t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255,e.byteSwapIfBE=e.isLE?t=>t:t=>(0,e.byteSwap)(t),e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])};const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));e.bytesToHex=function(t){(0,i.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e};const s=48,a=57,u=65,c=70,l=97,f=102;function h(t){return t>=s&&t<=a?t-s:t>=u&&t<=c?t-(u-10):t>=l&&t<=f?t-(l-10):void 0}function p(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function d(t){return"string"==typeof t&&(t=p(t)),(0,i.bytes)(t),t}e.hexToBytes=function(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);const e=t.length,r=e/2;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(r);for(let e=0,i=0;e<r;e++,i+=2){const r=h(t.charCodeAt(i)),o=h(t.charCodeAt(i+1));if(void 0===r||void 0===o){const e=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+e+'" at index '+i)}n[e]=16*r+o}return n},e.nextTick=async()=>{},e.asyncLoop=async function(t,r,n){let i=Date.now();for(let o=0;o<t;o++){n(o);const t=Date.now()-i;t>=0&&t<r||(await(0,e.nextTick)(),i+=t)}},e.utf8ToBytes=p,e.toBytes=d,e.concatBytes=function(...t){let e=0;for(let r=0;r<t.length;r++){const n=t[r];(0,i.bytes)(n),e+=n.length}const r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r},e.Hash=class{clone(){return this._cloneInto()}};const y={}.toString;e.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==y.call(e))throw new Error("Options should be object or undefined");return Object.assign(t,e)},e.wrapConstructor=function(t){const e=e=>t().update(d(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e},e.wrapConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.wrapXOFConstructorWithOpts=function(t){const e=(e,r)=>t(r).update(d(e)).digest(),r=t({});return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=e=>t(e),e},e.randomBytes=function(t=32){if(n.crypto&&"function"==typeof n.crypto.getRandomValues)return n.crypto.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}},9598:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.utils=e.schnorr=e.verify=e.signSync=e.sign=e.getSharedSecret=e.recoverPublicKey=e.getPublicKey=e.Signature=e.Point=e.CURVE=void 0;const n=r(4923),i=BigInt(0),o=BigInt(1),s=BigInt(2),a=BigInt(3),u=BigInt(8),c=Object.freeze({a:i,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:o,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")});e.CURVE=c;const l=(t,e)=>(t+e/s)/e,f={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),s=r,a=BigInt("0x100000000000000000000000000000000"),u=l(s*t,e),f=l(-n*t,e);let h=F(t-u*r-f*i,e),p=F(-u*n-f*s,e);const d=h>a,y=p>a;if(d&&(h=e-h),y&&(p=e-p),h>a||p>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:d,k1:h,k2neg:y,k2:p}}},h=32,p=32,d=h+1,y=2*h+1;function g(t){const{a:e,b:r}=c,n=F(t*t),i=F(n*t);return F(i+e*t+r)}const b=c.a===i;class w extends Error{constructor(t){super(t)}}function m(t){if(!(t instanceof v))throw new TypeError("JacobianPoint expected")}class v{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof S))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(S.ZERO)?v.ZERO:new v(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=c.P){const r=new Array(t.length),n=j(t.reduce(((t,n,o)=>n===i?t:(r[o]=t,F(t*n,e))),o),e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=F(t*r[o],e),F(t*n,e))),n),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return v.toAffineBatch(t).map(v.fromAffine)}equals(t){m(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:s}=t,a=F(n*n),u=F(s*s),c=F(e*u),l=F(i*a),f=F(F(r*s)*u),h=F(F(o*n)*a);return c===l&&f===h}negate(){return new v(this.x,F(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=F(t*t),i=F(e*e),o=F(i*i),c=t+i,l=F(s*(F(c*c)-n-o)),f=F(a*n),h=F(f*f),p=F(h-s*l),d=F(f*(l-p)-u*o),y=F(s*e*r);return new v(p,d,y)}add(t){m(t);const{x:e,y:r,z:n}=this,{x:o,y:a,z:u}=t;if(o===i||a===i)return this;if(e===i||r===i)return t;const c=F(n*n),l=F(u*u),f=F(e*l),h=F(o*c),p=F(F(r*u)*l),d=F(F(a*n)*c),y=F(h-f),g=F(d-p);if(y===i)return g===i?this.double():v.ZERO;const b=F(y*y),w=F(y*b),E=F(f*b),A=F(g*g-w-s*E),S=F(g*(E-A)-p*w),_=F(n*u*y);return new v(A,S,_)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=v.ZERO;if("bigint"==typeof t&&t===i)return e;let r=M(t);if(r===o)return this;if(!b){let t=e,n=this;for(;r>i;)r&o&&(t=t.add(n)),n=n.double(),r>>=o;return t}let{k1neg:n,k1:s,k2neg:a,k2:u}=f.splitScalar(r),c=e,l=e,h=this;for(;s>i||u>i;)s&o&&(c=c.add(h)),u&o&&(l=l.add(h)),h=h.double(),s>>=o,u>>=o;return n&&(c=c.negate()),a&&(l=l.negate()),l=new v(F(l.x*f.beta),l.y,l.z),c.add(l)}precomputeWindow(t){const e=b?128/t+1:256/t+1,r=[];let n=this,i=n;for(let o=0;o<e;o++){i=n,r.push(i);for(let e=1;e<2**(t-1);e++)i=i.add(n),r.push(i);n=i.double()}return r}wNAF(t,e){!e&&this.equals(v.BASE)&&(e=S.BASE);const r=e&&e._WINDOW_SIZE||1;if(256%r)throw new Error("Point#wNAF: Invalid precomputation window, must be power of 2");let n=e&&A.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=v.normalizeZ(n),A.set(e,n)));let i=v.ZERO,s=v.BASE;const a=1+(b?128/r:256/r),u=2**(r-1),c=BigInt(2**r-1),l=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*u;let a=Number(t&c);t>>=f,a>u&&(a-=l,t+=o);const h=r,p=r+Math.abs(a)-1,d=e%2!=0,y=a<0;0===a?s=s.add(E(d,n[h])):i=i.add(E(y,n[p]))}return{p:i,f:s}}multiply(t,e){let r,n,i=M(t);if(b){const{k1neg:t,k1:o,k2neg:s,k2:a}=f.splitScalar(i);let{p:u,f:c}=this.wNAF(o,e),{p:l,f:h}=this.wNAF(a,e);u=E(t,u),l=E(s,l),l=new v(F(l.x*f.beta),l.y,l.z),r=u.add(l),n=c.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return v.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(v.ZERO);null==t&&(t=i?u:j(n));const s=t,a=F(s*s),c=F(a*s),l=F(e*a),f=F(r*c),h=F(n*s);if(i)return S.ZERO;if(h!==o)throw new Error("invZ was invalid");return new S(l,f)}}function E(t,e){const r=e.negate();return t?r:e}v.BASE=new v(c.Gx,c.Gy,o),v.ZERO=new v(i,o,i);const A=new WeakMap;class S{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,A.delete(this)}hasEvenY(){return this.y%s===i}static fromCompressedHex(t){const e=32===t.length,r=L(e?t:t.subarray(1));if(!q(r))throw new Error("Point is not on curve");let n=function(t){const{P:e}=c,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),u=BigInt(44),l=BigInt(88),f=t*t*t%e,h=f*f*t%e,p=H(h,a)*h%e,d=H(p,a)*h%e,y=H(d,s)*f%e,g=H(y,n)*y%e,b=H(g,i)*g%e,w=H(b,u)*b%e,m=H(w,l)*w%e,v=H(m,u)*b%e,E=H(v,a)*h%e,A=H(E,o)*g%e,S=H(A,r)*f%e,_=H(S,s);if(_*_%e!==t)throw new Error("Cannot find square root");return _}(g(r));const i=(n&o)===o;e?i&&(n=F(-n)):!(1&~t[0])!==i&&(n=F(-n));const u=new S(r,n);return u.assertValidity(),u}static fromUncompressedHex(t){const e=L(t.subarray(1,h+1)),r=L(t.subarray(h+1,2*h+1)),n=new S(e,r);return n.assertValidity(),n}static fromHex(t){const e=D(t),r=e.length,n=e[0];if(r===h)return this.fromCompressedHex(e);if(r===d&&(2===n||3===n))return this.fromCompressedHex(e);if(r===y&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-${d} compressed bytes or ${y} uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return S.BASE.multiply(J(t))}static fromSignature(t,e,r){const{r:n,s:i}=Y(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=G(D(t)),{n:s}=c,a=2===r||3===r?n+s:n,u=j(a,s),l=F(-o*u,s),f=F(i*u,s),h=1&r?"03":"02",p=S.fromHex(h+B(a)),d=S.BASE.multiplyAndAddUnsafe(p,l,f);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return C(this.toHex(t))}toHex(t=!1){const e=B(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${B(this.y)}`}toHexX(){return this.toHex(!0).slice(2)}toRawX(){return this.toRawBytes(!0).slice(1)}assertValidity(){const t="Point is not on elliptic curve",{x:e,y:r}=this;if(!q(e)||!q(r))throw new Error(t);const n=F(r*r);if(F(n-g(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new S(this.x,F(-this.y))}double(){return v.fromAffine(this).double().toAffine()}add(t){return v.fromAffine(this).add(v.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return v.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=v.fromAffine(this),s=e===i||e===o||this!==S.BASE?n.multiplyUnsafe(e):n.multiply(e),a=v.fromAffine(t).multiplyUnsafe(r),u=s.add(a);return u.equals(v.ZERO)?void 0:u.toAffine()}}function _(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function k(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${O(t)}`);const e=t[1],r=t.subarray(2,e+2);if(!e||r.length!==e)throw new Error("Invalid signature integer: wrong length");if(0===r[0]&&r[1]<=127)throw new Error("Invalid signature integer: trailing length");return{data:L(r),left:t.subarray(e+2)}}e.Point=S,S.BASE=new S(c.Gx,c.Gy),S.ZERO=new S(i,i);class T{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromCompact(t){const e=t instanceof Uint8Array,r="Signature.fromCompact";if("string"!=typeof t&&!e)throw new TypeError(`${r}: Expected string or Uint8Array`);const n=e?O(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new T(U(n.slice(0,64)),U(n.slice(64,128)))}static fromDER(t){const e=t instanceof Uint8Array;if("string"!=typeof t&&!e)throw new TypeError("Signature.fromDER: Expected string or Uint8Array");const{r,s:n}=function(t){if(t.length<2||48!=t[0])throw new Error(`Invalid signature tag: ${O(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=k(t.subarray(2)),{data:n,left:i}=k(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${O(i)}`);return{r:e,s:n}}(e?t:C(t));return new T(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!z(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!z(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=c.n>>o;return this.s>t}normalizeS(){return this.hasHighS()?new T(this.r,F(-this.s,c.n)):this}toDERRawBytes(){return C(this.toDERHex())}toDERHex(){const t=_(N(this.s)),e=_(N(this.r)),r=t.length/2,n=e.length/2,i=N(r),o=N(n);return`30${N(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return C(this.toCompactHex())}toCompactHex(){return B(this.r)+B(this.s)}}function P(...t){if(!t.every((t=>t instanceof Uint8Array)))throw new Error("Uint8Array list expected");if(1===t.length)return t[0];const e=t.reduce(((t,e)=>t+e.length),0),r=new Uint8Array(e);for(let e=0,n=0;e<t.length;e++){const i=t[e];r.set(i,n),n+=i.length}return r}e.Signature=T;const I=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function O(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=I[t[r]];return e}const x=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function B(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(i<=t&&t<x))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function R(t){const e=C(B(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function N(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function U(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function C(t){if("string"!=typeof t)throw new TypeError("hexToBytes: expected string, got "+typeof t);if(t.length%2)throw new Error("hexToBytes: received invalid unpadded hex"+t.length);const e=new Uint8Array(t.length/2);for(let r=0;r<e.length;r++){const n=2*r,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");e[r]=o}return e}function L(t){return U(O(t))}function D(t){return t instanceof Uint8Array?Uint8Array.from(t):C(t)}function M(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&z(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function F(t,e=c.P){const r=t%e;return r>=i?r:e+r}function H(t,e){const{P:r}=c;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function j(t,e=c.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=F(t,e),n=e,s=i,a=o,u=o,l=i;for(;r!==i;){const t=n/r,e=n%r,i=s-u*t,o=a-l*t;n=r,r=e,s=u,a=l,u=i,l=o}if(n!==o)throw new Error("invert: does not exist");return F(s,e)}function G(t,e=!1){const r=function(t){const e=8*t.length-8*p,r=L(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=c;return r>=n?r-n:r}let V,K;class W{constructor(t,e){if(this.hashLen=t,this.qByteLen=e,"number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");this.v=new Uint8Array(t).fill(1),this.k=new Uint8Array(t).fill(0),this.counter=0}hmac(...t){return e.utils.hmacSha256(this.k,...t)}hmacSync(...t){return K(this.k,...t)}checkSync(){if("function"!=typeof K)throw new w("hmacSha256Sync needs to be set")}incr(){if(this.counter>=1e3)throw new Error("Tried 1,000 k values for sign(), all were invalid");this.counter+=1}async reseed(t=new Uint8Array){this.k=await this.hmac(this.v,Uint8Array.from([0]),t),this.v=await this.hmac(this.v),0!==t.length&&(this.k=await this.hmac(this.v,Uint8Array.from([1]),t),this.v=await this.hmac(this.v))}reseedSync(t=new Uint8Array){this.checkSync(),this.k=this.hmacSync(this.v,Uint8Array.from([0]),t),this.v=this.hmacSync(this.v),0!==t.length&&(this.k=this.hmacSync(this.v,Uint8Array.from([1]),t),this.v=this.hmacSync(this.v))}async generate(){this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=await this.hmac(this.v);const r=this.v.slice();e.push(r),t+=this.v.length}return P(...e)}generateSync(){this.checkSync(),this.incr();let t=0;const e=[];for(;t<this.qByteLen;){this.v=this.hmacSync(this.v);const r=this.v.slice();e.push(r),t+=this.v.length}return P(...e)}}function z(t){return i<t&&t<c.n}function q(t){return i<t&&t<c.P}function Q(t,e,r,n=!0){const{n:s}=c,a=G(t,!0);if(!z(a))return;const u=j(a,s),l=S.BASE.multiply(a),f=F(l.x,s);if(f===i)return;const h=F(u*F(e+r*f,s),s);if(h===i)return;let p=new T(f,h),d=(l.x===p.r?0:2)|Number(l.y&o);return n&&p.hasHighS()&&(p=p.normalizeS(),d^=1),{sig:p,recovery:d}}function J(t){let e;if("bigint"==typeof t)e=t;else if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)e=BigInt(t);else if("string"==typeof t){if(t.length!==2*p)throw new Error("Expected 32 bytes of private key");e=U(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(t.length!==p)throw new Error("Expected 32 bytes of private key");e=L(t)}if(!z(e))throw new Error("Expected private key: 0 < key < n");return e}function X(t){return t instanceof S?(t.assertValidity(),t):S.fromHex(t)}function Y(t){if(t instanceof T)return t.assertValidity(),t;try{return T.fromDER(t)}catch(e){return T.fromCompact(t)}}function Z(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===d||n===y:r?n===2*d||n===2*y:t instanceof S}function $(t){return L(t.length>h?t.slice(0,h):t)}function tt(t){const e=$(t),r=F(e,c.n);return et(r<i?e:r)}function et(t){return R(t)}function rt(t,r,n){if(null==t)throw new Error(`sign: expected valid message hash, not "${t}"`);const i=D(t),o=J(r),s=[et(o),tt(i)];if(null!=n){!0===n&&(n=e.utils.randomBytes(h));const t=D(n);if(t.length!==h)throw new Error(`sign: Expected ${h} bytes of extra data`);s.push(t)}return{seed:P(...s),m:$(i),d:o}}function nt(t,e){const{sig:r,recovery:n}=t,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},e),s=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[s,n]:s}e.getPublicKey=function(t,e=!1){return S.fromPrivateKey(t).toRawBytes(e)},e.recoverPublicKey=function(t,e,r,n=!1){return S.fromSignature(t,e,r).toRawBytes(n)},e.getSharedSecret=function(t,e,r=!1){if(Z(t))throw new TypeError("getSharedSecret: first arg must be private key");if(!Z(e))throw new TypeError("getSharedSecret: second arg must be public key");const n=X(e);return n.assertValidity(),n.multiply(J(t)).toRawBytes(r)},e.sign=async function(t,e,r={}){const{seed:n,m:i,d:o}=rt(t,e,r.extraEntropy),s=new W(32,p);let a;for(await s.reseed(n);!(a=Q(await s.generate(),i,o,r.canonical));)await s.reseed();return nt(a,r)},e.signSync=function(t,e,r={}){const{seed:n,m:i,d:o}=rt(t,e,r.extraEntropy),s=new W(32,p);let a;for(s.reseedSync(n);!(a=Q(s.generateSync(),i,o,r.canonical));)s.reseedSync();return nt(a,r)};const it={strict:!0};function ot(t){return F(L(t),c.n)}e.verify=function(t,e,r,n=it){let i;try{i=Y(t),e=D(e)}catch(t){return!1}const{r:o,s}=i;if(n.strict&&i.hasHighS())return!1;const a=G(e);let u;try{u=X(r)}catch(t){return!1}const{n:l}=c,f=j(s,l),h=F(a*f,l),p=F(o*f,l),d=S.BASE.multiplyAndAddUnsafe(u,h,p);return!!d&&F(d.x,l)===o};class st{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=D(t);if(64!==e.length)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${e.length}`);const r=L(e.subarray(0,32)),n=L(e.subarray(32,64));return new st(r,n)}assertValidity(){const{r:t,s:e}=this;if(!q(t)||!z(e))throw new Error("Invalid signature")}toHex(){return B(this.r)+B(this.s)}toRawBytes(){return C(this.toHex())}}class at{constructor(t,r,n=e.utils.randomBytes()){if(null==t)throw new TypeError(`sign: Expected valid message, not "${t}"`);this.m=D(t);const{x:i,scalar:o}=this.getScalar(J(r));if(this.px=i,this.d=o,this.rand=D(n),32!==this.rand.length)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(t){const e=S.fromPrivateKey(t),r=e.hasEvenY()?t:c.n-t;return{point:e,scalar:r,x:e.toRawX()}}initNonce(t,e){return R(t^L(e))}finalizeNonce(t){const e=F(L(t),c.n);if(e===i)throw new Error("sign: Creation of signature failed. k is zero");const{point:r,x:n,scalar:o}=this.getScalar(e);return{R:r,rx:n,k:o}}finalizeSig(t,e,r,n){return new st(t.x,F(e+r*n,c.n)).toRawBytes()}error(){throw new Error("sign: Invalid signature produced")}async calc(){const{m:t,d:r,px:n,rand:i}=this,o=e.utils.taggedHash,s=this.initNonce(r,await o(pt.aux,i)),{R:a,rx:u,k:c}=this.finalizeNonce(await o(pt.nonce,s,n,t)),l=ot(await o(pt.challenge,u,n,t)),f=this.finalizeSig(a,c,l,r);return await lt(f,t,n)||this.error(),f}calcSync(){const{m:t,d:r,px:n,rand:i}=this,o=e.utils.taggedHashSync,s=this.initNonce(r,o(pt.aux,i)),{R:a,rx:u,k:c}=this.finalizeNonce(o(pt.nonce,s,n,t)),l=ot(o(pt.challenge,u,n,t)),f=this.finalizeSig(a,c,l,r);return ft(f,t,n)||this.error(),f}}function ut(t,e,r){const n=t instanceof st,i=n?t:st.fromHex(t);return n&&i.assertValidity(),{...i,m:D(e),P:X(r)}}function ct(t,e,r,n){const i=S.BASE.multiplyAndAddUnsafe(e,J(r),F(-n,c.n));return!(!i||!i.hasEvenY()||i.x!==t)}async function lt(t,r,n){try{const{r:i,s:o,m:s,P:a}=ut(t,r,n),u=ot(await e.utils.taggedHash(pt.challenge,R(i),a.toRawX(),s));return ct(i,a,o,u)}catch(t){return!1}}function ft(t,r,n){try{const{r:i,s:o,m:s,P:a}=ut(t,r,n),u=ot(e.utils.taggedHashSync(pt.challenge,R(i),a.toRawX(),s));return ct(i,a,o,u)}catch(t){if(t instanceof w)throw t;return!1}}e.schnorr={Signature:st,getPublicKey:function(t){return S.fromPrivateKey(t).toRawX()},sign:async function(t,e,r){return new at(t,e,r).calc()},verify:lt,signSync:function(t,e,r){return new at(t,e,r).calcSync()},verifySync:ft},S.BASE._setWindowSize(8);const ht={node:n,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},pt={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},dt={};e.utils={bytesToHex:O,hexToBytes:C,concatBytes:P,mod:F,invert:j,isValidPrivateKey(t){try{return J(t),!0}catch(t){return!1}},_bigintTo32Bytes:R,_normalizePrivateKey:J,hashToPrivateKey:t=>{t=D(t);const e=p+8;if(t.length<e||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return R(F(L(t),c.n-o)+o)},randomBytes:(t=32)=>{if(ht.web)return ht.web.getRandomValues(new Uint8Array(t));if(ht.node){const{randomBytes:e}=ht.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(p+8)),precompute(t=8,e=S.BASE){const r=e===S.BASE?e:new S(e.x,e.y);return r._setWindowSize(t),r.multiply(a),r},sha256:async(...t)=>{if(ht.web){const e=await ht.web.subtle.digest("SHA-256",P(...t));return new Uint8Array(e)}if(ht.node){const{createHash:e}=ht.node,r=e("sha256");return t.forEach((t=>r.update(t))),Uint8Array.from(r.digest())}throw new Error("The environment doesn't have sha256 function")},hmacSha256:async(t,...e)=>{if(ht.web){const r=await ht.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=P(...e),i=await ht.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(ht.node){const{createHmac:r}=ht.node,n=r("sha256",t);return e.forEach((t=>n.update(t))),Uint8Array.from(n.digest())}throw new Error("The environment doesn't have hmac-sha256 function")},sha256Sync:void 0,hmacSha256Sync:void 0,taggedHash:async(t,...r)=>{let n=dt[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=P(r,r),dt[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if("function"!=typeof V)throw new w("sha256Sync is undefined, you need to set it");let r=dt[t];if(void 0===r){const e=V(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=P(e,e),dt[t]=r}return V(r,...e)},_JacobianPoint:v},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>V,set(t){V||(V=t)}},hmacSha256Sync:{configurable:!1,get:()=>K,set(t){K||(K=t)}}})},5364:t=>{t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var n=0;n<t.length;n++){var i=t.charAt(n),o=i.charCodeAt(0);if(255!==e[o])throw new TypeError(i+" is ambiguous");e[o]=n}var s=t.length,a=t.charAt(0),u=Math.log(s)/Math.log(256),c=Math.log(256)/Math.log(s);function l(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return new Uint8Array;for(var r=0,n=0,i=0;t[r]===a;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var l=e[t.charCodeAt(r)];if(255===l)return;for(var f=0,h=o-1;(0!==l||f<i)&&-1!==h;h--,f++)l+=s*c[h]>>>0,c[h]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");i=f,r++}for(var p=o-i;p!==o&&0===c[p];)p++;for(var d=new Uint8Array(n+(o-p)),y=n;p!==o;)d[y++]=c[p++];return d}return{encode:function(e){if(e instanceof Uint8Array||(ArrayBuffer.isView(e)?e=new Uint8Array(e.buffer,e.byteOffset,e.byteLength):Array.isArray(e)&&(e=Uint8Array.from(e))),!(e instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(0===e.length)return"";for(var r=0,n=0,i=0,o=e.length;i!==o&&0===e[i];)i++,r++;for(var u=(o-i)*c+1>>>0,l=new Uint8Array(u);i!==o;){for(var f=e[i],h=0,p=u-1;(0!==f||h<n)&&-1!==p;p--,h++)f+=256*l[p]>>>0,l[p]=f%s>>>0,f=f/s>>>0;if(0!==f)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===l[d];)d++;for(var y=a.repeat(r);d<u;++d)y+=t.charAt(l[d]);return y},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" character")}}}},7526:(t,e)=>{e.byteLength=function(t){var e=a(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=a(t),s=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,s,u)),l=0,f=u>0?s-4:s;for(r=0;r<f;r+=4)e=n[t.charCodeAt(r)]<<18|n[t.charCodeAt(r+1)]<<12|n[t.charCodeAt(r+2)]<<6|n[t.charCodeAt(r+3)],c[l++]=e>>16&255,c[l++]=e>>8&255,c[l++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[l++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[l++]=e>>8&255,c[l++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],s=16383,a=0,c=n-i;a<c;a+=s)o.push(u(t,a,a+s>c?c:a+s));return 1===i?(e=t[n-1],o.push(r[e>>2]+r[e<<4&63]+"==")):2===i&&(e=(t[n-2]<<8)+t[n-1],o.push(r[e>>10]+r[e>>4&63]+r[e<<2&63]+"=")),o.join("")};for(var r=[],n=[],i="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)r[s]=o[s],n[o.charCodeAt(s)]=s;function a(t){var e=t.length;if(e%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=t.indexOf("=");return-1===r&&(r=e),[r,r===e?0:4-r%4]}function u(t,e,n){for(var i,o,s=[],a=e;a<n;a+=3)i=(t[a]<<16&16711680)+(t[a+1]<<8&65280)+(255&t[a+2]),s.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return s.join("")}n["-".charCodeAt(0)]=62,n["_".charCodeAt(0)]=63},2343:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.bech32m=e.bech32=void 0;const r="qpzry9x8gf2tvdw0s3jn54khce6mua7l",n={};for(let t=0;t<32;t++){const e=r.charAt(t);n[e]=t}function i(t){const e=t>>25;return(33554431&t)<<5^996825010&-(1&e)^642813549&-(e>>1&1)^513874426&-(e>>2&1)^1027748829&-(e>>3&1)^705979059&-(e>>4&1)}function o(t){let e=1;for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);if(n<33||n>126)return"Invalid prefix ("+t+")";e=i(e)^n>>5}e=i(e);for(let r=0;r<t.length;++r){const n=t.charCodeAt(r);e=i(e)^31&n}return e}function s(t,e,r,n){let i=0,o=0;const s=(1<<r)-1,a=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,a.push(i>>o&s);if(n)o>0&&a.push(i<<r-o&s);else{if(o>=e)return"Excess padding";if(i<<r-o&s)return"Non-zero padding"}return a}function a(t){return s(t,8,5,!0)}function u(t){const e=s(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=s(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function l(t){let e;function s(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const s=t.toLowerCase(),a=t.toUpperCase();if(t!==s&&t!==a)return"Mixed-case string "+t;const u=(t=s).lastIndexOf("1");if(-1===u)return"No separator character for "+t;if(0===u)return"Missing prefix for "+t;const c=t.slice(0,u),l=t.slice(u+1);if(l.length<6)return"Data too short";let f=o(c);if("string"==typeof f)return f;const h=[];for(let t=0;t<l.length;++t){const e=l.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;f=i(f)^r,t+6>=l.length||h.push(r)}return f!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=s(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=s(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,s){if(s=s||90,t.length+7+n.length>s)throw new TypeError("Exceeds length limit");let a=o(t=t.toLowerCase());if("string"==typeof a)throw new Error(a);let u=t+"1";for(let t=0;t<n.length;++t){const e=n[t];if(e>>5)throw new Error("Non 5-bit word");a=i(a)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)a=i(a);a^=e;for(let t=0;t<6;++t)u+=r.charAt(a>>5*(5-t)&31);return u},toWords:a,fromWordsUnsafe:u,fromWords:c}}e.bech32=l("bech32"),e.bech32m=l("bech32m")},4863:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(1457);function i(t,e,r){return n=>{if(t.has(n))return;const i=r.filter((t=>t.key.toString("hex")===n))[0];e.push(i),t.add(n)}}function o(t){return t.globalMap.unsignedTx}function s(t){const e=new Set;return t.forEach((t=>{const r=t.key.toString("hex");if(e.has(r))throw new Error("Combine: KeyValue Map keys should be unique");e.add(r)})),e}e.combine=function(t){const e=t[0],r=n.psbtToKeyVals(e),a=t.slice(1);if(0===a.length)throw new Error("Combine: Nothing to combine");const u=o(e);if(void 0===u)throw new Error("Combine: Self missing transaction");const c=s(r.globalKeyVals),l=r.inputKeyVals.map(s),f=r.outputKeyVals.map(s);for(const t of a){const e=o(t);if(void 0===e||!e.toBuffer().equals(u.toBuffer()))throw new Error("Combine: One of the Psbts does not have the same transaction.");const a=n.psbtToKeyVals(t);s(a.globalKeyVals).forEach(i(c,r.globalKeyVals,a.globalKeyVals)),a.inputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(l[e],r.inputKeyVals[e],a.inputKeyVals[e])))),a.outputKeyVals.map(s).forEach(((t,e)=>t.forEach(i(f[e],r.outputKeyVals[e],a.outputKeyVals[e]))))}return n.psbtFromKeyVals(u,{globalMapKeyVals:r.globalKeyVals,inputKeyVals:r.inputKeyVals,outputKeyVals:r.outputKeyVals})}},4834:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.GlobalTypes.GLOBAL_XPUB)throw new Error("Decode Error: could not decode globalXpub with key 0x"+t.key.toString("hex"));if(79!==t.key.length||![2,3].includes(t.key[46]))throw new Error("Decode Error: globalXpub has invalid extended pubkey in key 0x"+t.key.toString("hex"));if(t.value.length/4%1!=0)throw new Error("Decode Error: Global GLOBAL_XPUB value length should be multiple of 4");const e=t.key.slice(1),r={masterFingerprint:t.value.slice(0,4),extendedPubkey:e,path:"m"};for(const e of(n=t.value.length/4-1,[...Array(n).keys()])){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}var n;return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),s=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:r,value:s}},e.expected="{ masterFingerprint: Buffer; extendedPubkey: Buffer; path: string; }",e.check=function(t){const e=t.extendedPubkey,r=t.masterFingerprint,i=t.path;return n.isBuffer(e)&&78===e.length&&[2,3].indexOf(e[45])>-1&&n.isBuffer(r)&&4===r.length&&"string"==typeof i&&!!i.match(/^m(\/\d+'?)*$/)},e.canAddToArray=function(t,e,r){const n=e.extendedPubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.extendedPubkey.equals(e.extendedPubkey))).length)}},4213:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.encode=function(t){return{key:n.from([i.GlobalTypes.UNSIGNED_TX]),value:t.toBuffer()}}},2706:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0});const n=r(9080),i=r(4834),o=r(4213),s=r(6605),a=r(1795),u=r(4431),c=r(6907),l=r(5949),f=r(9344),h=r(2760),p=r(1695),d=r(8454),y=r(9034),g=r(2926),b=r(7851),w=r(7545),m=r(2412),v=r(4307),E=r(7636),A=r(2223),S=r(5578),_={unsignedTx:o,globalXpub:i,checkPubkey:m.makeChecker([])};e.globals=_;const k={nonWitnessUtxo:u,partialSig:c,sighashType:f,finalScriptSig:s,finalScriptWitness:a,porCommitment:l,witnessUtxo:g,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:E.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:A.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=k;const T={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:v.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:m.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:E.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:b,tapInternalKey:A.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=T},6605:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTSIG)throw new Error("Decode Error: could not decode finalScriptSig with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTSIG]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptSig}},1795:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.FINAL_SCRIPTWITNESS)throw new Error("Decode Error: could not decode finalScriptWitness with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.FINAL_SCRIPTWITNESS]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.finalScriptWitness}},4431:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.NON_WITNESS_UTXO)throw new Error("Decode Error: could not decode nonWitnessUtxo with key 0x"+t.key.toString("hex"));return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.NON_WITNESS_UTXO]),value:t}},e.expected="Buffer",e.check=function(t){return n.isBuffer(t)},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.nonWitnessUtxo}},6907:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.PARTIAL_SIG)throw new Error("Decode Error: could not decode partialSig with key 0x"+t.key.toString("hex"));if(34!==t.key.length&&66!==t.key.length||![2,3,4].includes(t.key[1]))throw new Error("Decode Error: partialSig has invalid pubkey in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.PARTIAL_SIG]);return{key:n.concat([e,t.pubkey]),value:t.signature}},e.expected="{ pubkey: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.signature)&&[33,65].includes(t.pubkey.length)&&[2,3,4].includes(t.pubkey[0])&&function(t){if(!n.isBuffer(t)||t.length<9)return!1;if(48!==t[0])return!1;if(t.length!==t[1]+3)return!1;if(2!==t[2])return!1;const e=t[3];if(e>33||e<1)return!1;if(2!==t[3+e+1])return!1;const r=t[3+e+2];return!(r>33||r<1)&&t.length===3+e+2+r+2}(t.signature)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}},5949:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.POR_COMMITMENT)throw new Error("Decode Error: could not decode porCommitment with key 0x"+t.key.toString("hex"));return t.value.toString("utf8")},e.encode=function(t){return{key:n.from([i.InputTypes.POR_COMMITMENT]),value:n.from(t,"utf8")}},e.expected="string",e.check=function(t){return"string"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.porCommitment}},9344:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.SIGHASH_TYPE)throw new Error("Decode Error: could not decode sighashType with key 0x"+t.key.toString("hex"));return t.value.readUInt32LE(0)},e.encode=function(t){const e=n.from([i.InputTypes.SIGHASH_TYPE]),r=n.allocUnsafe(4);return r.writeUInt32LE(t,0),{key:e,value:r}},e.expected="number",e.check=function(t){return"number"==typeof t},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.sighashType}},2760:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function o(t){return n.isBuffer(t)&&(64===t.length||65===t.length)}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_KEY_SIG||1!==t.key.length)throw new Error("Decode Error: could not decode tapKeySig with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapKeySig not a valid 64-65-byte BIP340 signature");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_KEY_SIG]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapKeySig}},1695:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_LEAF_SCRIPT)throw new Error("Decode Error: could not decode tapLeafScript with key 0x"+t.key.toString("hex"));if((t.key.length-2)%32!=0)throw new Error("Decode Error: tapLeafScript has invalid control block in key 0x"+t.key.toString("hex"));const e=t.value[t.value.length-1];if((254&t.key[1])!==e)throw new Error("Decode Error: tapLeafScript bad leaf version in key 0x"+t.key.toString("hex"));const r=t.value.slice(0,-1);return{controlBlock:t.key.slice(1),script:r,leafVersion:e}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_LEAF_SCRIPT]),r=n.from([t.leafVersion]);return{key:n.concat([e,t.controlBlock]),value:n.concat([t.script,r])}},e.expected="{ controlBlock: Buffer; leafVersion: number, script: Buffer; }",e.check=function(t){return n.isBuffer(t.controlBlock)&&(t.controlBlock.length-1)%32==0&&(254&t.controlBlock[0])===t.leafVersion&&n.isBuffer(t.script)},e.canAddToArray=function(t,e,r){const n=e.controlBlock.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.controlBlock.equals(e.controlBlock))).length)}},8454:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);function o(t){return n.isBuffer(t)&&32===t.length}e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_MERKLE_ROOT||1!==t.key.length)throw new Error("Decode Error: could not decode tapMerkleRoot with key 0x"+t.key.toString("hex"));if(!o(t.value))throw new Error("Decode Error: tapMerkleRoot not a 32-byte hash");return t.value},e.encode=function(t){return{key:n.from([i.InputTypes.TAP_MERKLE_ROOT]),value:t}},e.expected="Buffer",e.check=o,e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapMerkleRoot}},9034:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080);e.decode=function(t){if(t.key[0]!==i.InputTypes.TAP_SCRIPT_SIG)throw new Error("Decode Error: could not decode tapScriptSig with key 0x"+t.key.toString("hex"));if(65!==t.key.length)throw new Error("Decode Error: tapScriptSig has invalid key 0x"+t.key.toString("hex"));if(64!==t.value.length&&65!==t.value.length)throw new Error("Decode Error: tapScriptSig has invalid signature in key 0x"+t.key.toString("hex"));return{pubkey:t.key.slice(1,33),leafHash:t.key.slice(33),signature:t.value}},e.encode=function(t){const e=n.from([i.InputTypes.TAP_SCRIPT_SIG]);return{key:n.concat([e,t.pubkey,t.leafHash]),value:t.signature}},e.expected="{ pubkey: Buffer; leafHash: Buffer; signature: Buffer; }",e.check=function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.leafHash)&&n.isBuffer(t.signature)&&32===t.pubkey.length&&32===t.leafHash.length&&(64===t.signature.length||65===t.signature.length)},e.canAddToArray=function(t,e,r){const n=e.pubkey.toString("hex")+e.leafHash.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey)&&t.leafHash.equals(e.leafHash))).length)}},2926:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),o=r(8133),s=r(394);e.decode=function(t){if(t.key[0]!==i.InputTypes.WITNESS_UTXO)throw new Error("Decode Error: could not decode witnessUtxo with key 0x"+t.key.toString("hex"));const e=o.readUInt64LE(t.value,0);let r=8;const n=s.decode(t.value,r);r+=s.encodingLength(n);const a=t.value.slice(r);if(a.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:a,value:e}},e.encode=function(t){const{script:e,value:r}=t,a=s.encodingLength(e.length),u=n.allocUnsafe(8+a+e.length);return o.writeUInt64LE(u,r,0),s.encode(e.length,u,8),e.copy(u,8+a),{key:n.from([i.InputTypes.WITNESS_UTXO]),value:u}},e.expected="{ script: Buffer; value: number; }",e.check=function(t){return n.isBuffer(t.script)&&"number"==typeof t.value},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.witnessUtxo}},7851:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(9080),o=r(394);e.decode=function(t){if(t.key[0]!==i.OutputTypes.TAP_TREE||1!==t.key.length)throw new Error("Decode Error: could not decode tapTree with key 0x"+t.key.toString("hex"));let e=0;const r=[];for(;e<t.value.length;){const n=t.value[e++],i=t.value[e++],s=o.decode(t.value,e);e+=o.encodingLength(s),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+s)}),e+=s}return{leaves:r}},e.encode=function(t){const e=n.from([i.OutputTypes.TAP_TREE]),r=[].concat(...t.leaves.map((t=>[n.of(t.depth,t.leafVersion),o.encode(t.script.length),t.script])));return{key:e,value:n.concat(r)}},e.expected="{ leaves: [{ depth: number; leafVersion: number, script: Buffer; }] }",e.check=function(t){return Array.isArray(t.leaves)&&t.leaves.every((t=>t.depth>=0&&t.depth<=128&&(254&t.leafVersion)===t.leafVersion&&n.isBuffer(t.script)))},e.canAdd=function(t,e){return!!t&&!!e&&void 0===t.tapTree}},7545:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=t=>33===t.length&&[2,3].includes(t[0])||65===t.length&&4===t[0];e.makeConverter=function(t,e=i){return{decode:function(r){if(r.key[0]!==t)throw new Error("Decode Error: could not decode bip32Derivation with key 0x"+r.key.toString("hex"));const n=r.key.slice(1);if(!e(n))throw new Error("Decode Error: bip32Derivation has invalid pubkey in key 0x"+r.key.toString("hex"));if(r.value.length/4%1!=0)throw new Error("Decode Error: Input BIP32_DERIVATION value length should be multiple of 4");const i={masterFingerprint:r.value.slice(0,4),pubkey:n,path:"m"};for(const t of(o=r.value.length/4-1,[...Array(o).keys()])){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}var o;return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),s=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(s,0);let a=4;return o.slice(1).forEach((t=>{const e="'"===t.slice(-1);let r=2147483647&parseInt(e?t.slice(0,-1):t,10);e&&(r+=2147483648),s.writeUInt32LE(r,a),a+=4})),{key:i,value:s}},check:function(t){return n.isBuffer(t.pubkey)&&n.isBuffer(t.masterFingerprint)&&"string"==typeof t.path&&e(t.pubkey)&&4===t.masterFingerprint.length},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; }",canAddToArray:function(t,e,r){const n=e.pubkey.toString("hex");return!r.has(n)&&(r.add(n),0===t.filter((t=>t.pubkey.equals(e.pubkey))).length)}}}},2412:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.makeChecker=function(t){return function(e){let r;if(t.includes(e.key[0])&&(r=e.key.slice(1),33!==r.length&&65!==r.length||![2,3,4].includes(r[0])))throw new Error("Format Error: invalid pubkey in key 0x"+e.key.toString("hex"));return r}}},4307:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode redeemScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.redeemScript}}}},7636:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394),o=r(7545),s=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,s);return{decode:function(t){const r=i.decode(t.value),n=i.encodingLength(r),o=e.decode({key:t.key,value:t.value.slice(n+32*r)}),s=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)s[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:s})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),s=n.allocUnsafe(o);i.encode(t.leafHashes.length,s);const a=n.concat([s,...t.leafHashes,r.value]);return Object.assign({},r,{value:a})},check:function(t){return Array.isArray(t.leafHashes)&&t.leafHashes.every((t=>n.isBuffer(t)&&32===t.length))&&e.check(t)},expected:"{ masterFingerprint: Buffer; pubkey: Buffer; path: string; leafHashes: Buffer[]; }",canAddToArray:e.canAddToArray}}},2223:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t||1!==e.key.length)throw new Error("Decode Error: could not decode tapInternalKey with key 0x"+e.key.toString("hex"));if(32!==e.value.length)throw new Error("Decode Error: tapInternalKey not a 32-byte x-only pubkey");return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)&&32===t.length},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.tapInternalKey}}}},5578:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.makeConverter=function(t){return{decode:function(e){if(e.key[0]!==t)throw new Error("Decode Error: could not decode witnessScript with key 0x"+e.key.toString("hex"));return e.value},encode:function(e){return{key:n.from([t]),value:e}},check:function(t){return n.isBuffer(t)},expected:"Buffer",canAdd:function(t,e){return!!t&&!!e&&void 0===t.witnessScript}}}},8133:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(394);function o(t){const e=t.key.length,r=t.value.length,o=i.encodingLength(e),s=i.encodingLength(r),a=n.allocUnsafe(o+e+s+r);return i.encode(e,a,0),t.key.copy(a,o),i.encode(r,a,o+e),t.value.copy(a,o+e+s),a}function s(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}e.range=t=>[...Array(t).keys()],e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.keyValsToBuffer=function(t){const e=t.map(o);return e.push(n.from([0])),n.concat(e)},e.keyValToBuffer=o,e.readUInt64LE=function(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,s(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return s(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}},394:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}e.encode=function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),Object.assign(t,{bytes:9})),r},e.decode=function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);const i=e.readUInt8(r);if(i<253)return Object.assign(t,{bytes:1}),i;if(253===i)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===i)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),i=4294967296*e.readUInt32LE(r+5)+n;return o(i),i}},e.encodingLength=s},6263:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133),s=r(394),a=r(9080);function u(t,e,r){if(!e.equals(n.from([r])))throw new Error(`Format Error: Invalid ${t} key: ${e.toString("hex")}`)}function c(t,{globalMapKeyVals:e,inputKeyVals:r,outputKeyVals:n}){const s={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case a.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,a.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case a.GlobalTypes.GLOBAL_XPUB:void 0===s.globalXpub&&(s.globalXpub=[]),s.globalXpub.push(i.globals.globalXpub.decode(t));break;default:s.unknownKeyVals||(s.unknownKeyVals=[]),s.unknownKeyVals.push(t)}const l=r.length,f=n.length,h=[],p=[];for(const t of o.range(l)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case a.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,a.InputTypes.NON_WITNESS_UTXO),void 0!==e.nonWitnessUtxo)throw new Error("Format Error: Input has multiple NON_WITNESS_UTXO");e.nonWitnessUtxo=i.inputs.nonWitnessUtxo.decode(n);break;case a.InputTypes.WITNESS_UTXO:if(u("input",n.key,a.InputTypes.WITNESS_UTXO),void 0!==e.witnessUtxo)throw new Error("Format Error: Input has multiple WITNESS_UTXO");e.witnessUtxo=i.inputs.witnessUtxo.decode(n);break;case a.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case a.InputTypes.SIGHASH_TYPE:if(u("input",n.key,a.InputTypes.SIGHASH_TYPE),void 0!==e.sighashType)throw new Error("Format Error: Input has multiple SIGHASH_TYPE");e.sighashType=i.inputs.sighashType.decode(n);break;case a.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,a.InputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Input has multiple REDEEM_SCRIPT");e.redeemScript=i.inputs.redeemScript.decode(n);break;case a.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,a.InputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Input has multiple WITNESS_SCRIPT");e.witnessScript=i.inputs.witnessScript.decode(n);break;case a.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case a.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,a.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case a.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,a.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case a.InputTypes.POR_COMMITMENT:u("input",n.key,a.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case a.InputTypes.TAP_KEY_SIG:u("input",n.key,a.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case a.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case a.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case a.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case a.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,a.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case a.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,a.InputTypes.TAP_MERKLE_ROOT),e.tapMerkleRoot=i.inputs.tapMerkleRoot.decode(n);break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(n)}h.push(e)}for(const t of o.range(f)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case a.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,a.OutputTypes.REDEEM_SCRIPT),void 0!==e.redeemScript)throw new Error("Format Error: Output has multiple REDEEM_SCRIPT");e.redeemScript=i.outputs.redeemScript.decode(r);break;case a.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,a.OutputTypes.WITNESS_SCRIPT),void 0!==e.witnessScript)throw new Error("Format Error: Output has multiple WITNESS_SCRIPT");e.witnessScript=i.outputs.witnessScript.decode(r);break;case a.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case a.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,a.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case a.OutputTypes.TAP_TREE:u("output",r.key,a.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case a.OutputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.outputs.tapBip32Derivation.decode(r));break;default:e.unknownKeyVals||(e.unknownKeyVals=[]),e.unknownKeyVals.push(r)}p.push(e)}return{globalMap:s,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=s.decode(t,r);r+=s.encodingLength(e);const n=t.slice(r,r+e);return r+=e,n}function i(){return{key:n(),value:n()}}function u(){if(r>=t.length)throw new Error("Format Error: Unexpected End of PSBT");const e=0===t.readUInt8(r);return e&&r++,e}if(1886610036!==function(){const e=t.readUInt32BE(r);return r+=4,e}())throw new Error("Format Error: Invalid Magic Number");if(255!==function(){const e=t.readUInt8(r);return r+=1,e}())throw new Error("Format Error: Magic Number must be followed by 0xff separator");const l=[],f={};for(;!u();){const t=i(),e=t.key.toString("hex");if(f[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);f[e]=1,l.push(t)}const h=l.filter((t=>t.key[0]===a.GlobalTypes.UNSIGNED_TX));if(1!==h.length)throw new Error("Format Error: Only one UNSIGNED_TX allowed");const p=e(h[0].value),{inputCount:d,outputCount:y}=p.getInputOutputCounts(),g=[],b=[];for(const t of o.range(d)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each input: input index "+t+" key "+o);e[o]=1,r.push(n)}g.push(r)}for(const t of o.range(y)){const e={},r=[];for(;!u();){const n=i(),o=n.key.toString("hex");if(e[o])throw new Error("Format Error: Keys must be unique for each output: output index "+t+" key "+o);e[o]=1,r.push(n)}b.push(r)}return c(p,{globalMapKeyVals:l,inputKeyVals:g,outputKeyVals:b})},e.checkKeyBuffer=u,e.psbtFromKeyVals=c},1457:(t,e,r)=>{function n(t){for(var r in t)e.hasOwnProperty(r)||(e[r]=t[r])}Object.defineProperty(e,"__esModule",{value:!0}),n(r(6263)),n(r(238))},238:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133);e.psbtToBuffer=function({globalMap:t,inputs:e,outputs:r}){const{globalKeyVals:i,inputKeyVals:s,outputKeyVals:a}=u({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),l=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),f=l(s),h=l(a),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(f,h))};const s=(t,e)=>t.key.compare(e.key);function a(t,e){const r=new Set,n=Object.entries(t).reduce(((t,[n,i])=>{if("unknownKeyVals"===n)return t;const o=e[n];if(void 0===o)return t;const s=(Array.isArray(i)?i:[i]).map(o.encode);return s.map((t=>t.key.toString("hex"))).forEach((t=>{if(r.has(t))throw new Error("Serialize Error: Duplicate key: "+t);r.add(t)})),t.concat(s)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(s)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:a(t,i.globals),inputKeyVals:e.map((t=>a(t,i.inputs))),outputKeyVals:r.map((t=>a(t,i.outputs)))}}e.psbtToKeyVals=u},1614:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(4863),o=r(1457),s=r(9080),a=r(5080);e.Psbt=class{constructor(t){this.inputs=[],this.outputs=[],this.globalMap={unsignedTx:t}}static fromBase64(t,e){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e){const r=o.psbtFromBuffer(t,e),n=new this(r.globalMap.unsignedTx);return Object.assign(n,r),n}toBase64(){return this.toBuffer().toString("base64")}toHex(){return this.toBuffer().toString("hex")}toBuffer(){return o.psbtToBuffer(this)}updateGlobal(t){return a.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=a.checkForInput(this.inputs,t);return a.updateInput(e,r),this}updateOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return a.checkHasKey(t,this.globalMap.unknownKeyVals,a.getEnumLength(s.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=a.checkForInput(this.inputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=a.checkForOutput(this.outputs,t);return a.checkHasKey(e,r.unknownKeyVals,a.getEnumLength(s.OutputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addInput(t){this.globalMap.unsignedTx.addInput(t),this.inputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.inputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToInput(r,t))),a.addInputAttributes(this.inputs,t),this}addOutput(t){this.globalMap.unsignedTx.addOutput(t),this.outputs.push({unknownKeyVals:[]});const e=t.unknownKeyVals||[],r=this.outputs.length-1;if(!Array.isArray(e))throw new Error("unknownKeyVals must be an Array");return e.forEach((t=>this.addUnknownKeyValToOutput(r,t))),a.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=a.checkForInput(this.inputs,t);a.inputCheckUncleanFinalized(t,e);for(const t of Object.keys(e))["witnessUtxo","nonWitnessUtxo","finalScriptSig","finalScriptWitness","unknownKeyVals"].includes(t)||delete e[t];return this}combine(...t){const e=i.combine([this].concat(t));return Object.assign(this,e),this}getTransaction(){return this.globalMap.unsignedTx.toBuffer()}}},9080:(t,e)=>{var r,n,i;Object.defineProperty(e,"__esModule",{value:!0}),(i=e.GlobalTypes||(e.GlobalTypes={}))[i.UNSIGNED_TX=0]="UNSIGNED_TX",i[i.GLOBAL_XPUB=1]="GLOBAL_XPUB",e.GLOBAL_TYPE_NAMES=["unsignedTx","globalXpub"],(n=e.InputTypes||(e.InputTypes={}))[n.NON_WITNESS_UTXO=0]="NON_WITNESS_UTXO",n[n.WITNESS_UTXO=1]="WITNESS_UTXO",n[n.PARTIAL_SIG=2]="PARTIAL_SIG",n[n.SIGHASH_TYPE=3]="SIGHASH_TYPE",n[n.REDEEM_SCRIPT=4]="REDEEM_SCRIPT",n[n.WITNESS_SCRIPT=5]="WITNESS_SCRIPT",n[n.BIP32_DERIVATION=6]="BIP32_DERIVATION",n[n.FINAL_SCRIPTSIG=7]="FINAL_SCRIPTSIG",n[n.FINAL_SCRIPTWITNESS=8]="FINAL_SCRIPTWITNESS",n[n.POR_COMMITMENT=9]="POR_COMMITMENT",n[n.TAP_KEY_SIG=19]="TAP_KEY_SIG",n[n.TAP_SCRIPT_SIG=20]="TAP_SCRIPT_SIG",n[n.TAP_LEAF_SCRIPT=21]="TAP_LEAF_SCRIPT",n[n.TAP_BIP32_DERIVATION=22]="TAP_BIP32_DERIVATION",n[n.TAP_INTERNAL_KEY=23]="TAP_INTERNAL_KEY",n[n.TAP_MERKLE_ROOT=24]="TAP_MERKLE_ROOT",e.INPUT_TYPE_NAMES=["nonWitnessUtxo","witnessUtxo","partialSig","sighashType","redeemScript","witnessScript","bip32Derivation","finalScriptSig","finalScriptWitness","porCommitment","tapKeySig","tapScriptSig","tapLeafScript","tapBip32Derivation","tapInternalKey","tapMerkleRoot"],(r=e.OutputTypes||(e.OutputTypes={}))[r.REDEEM_SCRIPT=0]="REDEEM_SCRIPT",r[r.WITNESS_SCRIPT=1]="WITNESS_SCRIPT",r[r.BIP32_DERIVATION=2]="BIP32_DERIVATION",r[r.TAP_INTERNAL_KEY=5]="TAP_INTERNAL_KEY",r[r.TAP_TREE=6]="TAP_TREE",r[r.TAP_BIP32_DERIVATION=7]="TAP_BIP32_DERIVATION",e.OUTPUT_TYPE_NAMES=["redeemScript","witnessScript","bip32Derivation","tapInternalKey","tapTree","tapBip32Derivation"]},5080:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706);function o(t,e){const r=t[e];if(void 0===r)throw new Error(`No input #${e}`);return r}function s(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function a(t,e,r,n){throw new Error(`Data for ${t} key ${e} is incorrect: Expected ${r} and got ${JSON.stringify(n)}`)}function u(t){return(e,r)=>{for(const n of Object.keys(e)){const o=e[n],{canAdd:s,canAddToArray:u,check:c,expected:l}=i[t+"s"][n]||{};if(c)if(u){if(!Array.isArray(o)||r[n]&&!Array.isArray(r[n]))throw new Error(`Key type ${n} must be an array`);o.every(c)||a(t,n,l,o);const e=r[n]||[],i=new Set;if(!o.every((t=>u(e,t,i))))throw new Error("Can not add duplicate data to array");r[n]=e.concat(o)}else{if(c(o)||a(t,n,l,o),!s(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=s,e.checkHasKey=function(t,e,r){if(t.key[0]<r)throw new Error("Use the method for your specific key instead of addUnknownKeyVal*");if(e&&0!==e.filter((e=>e.key.equals(t.key))).length)throw new Error(`Duplicate Key: ${t.key.toString("hex")}`)},e.getEnumLength=function(t){let e=0;return Object.keys(t).forEach((t=>{Number(isNaN(Number(t)))&&e++})),e},e.inputCheckUncleanFinalized=function(t,e){let r=!1;if(e.nonWitnessUtxo||e.witnessUtxo){const t=!!e.redeemScript,n=!!e.witnessScript,i=!t||!!e.finalScriptSig,o=!n||!!e.finalScriptWitness,s=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&s}if(!1===r)throw new Error(`Input #${t} has too much or too little data to clean`)},e.updateGlobal=u("global"),e.updateInput=u("input"),e.updateOutput=u("output"),e.addInputAttributes=function(t,r){const n=o(t,t.length-1);e.updateInput(r,n)},e.addOutputAttributes=function(t,r){const n=s(t,t.length-1);e.updateOutput(r,n)},e.defaultVersionSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Version: Invalid Transaction");return e.writeUInt32LE(t,0),e},e.defaultLocktimeSetter=function(t,e){if(!n.isBuffer(e)||e.length<4)throw new Error("Set Locktime: Invalid Transaction");return e.writeUInt32LE(t,e.length-4),e}},57:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.toOutputScript=e.fromOutputScript=e.toBech32=e.toBase58Check=e.fromBech32=e.fromBase58Check=void 0;const i=r(622),o=r(885),s=r(7038),a=r(8116),u=r(2343),c=r(1889),l="WARNING: Sending to a future segwit version address can lead to loss of funds. End users MUST be warned carefully in the GUI and asked if they wish to proceed with caution. Wallets should verify the segwit version from the output of fromBech32, then decide when it is safe to use which version of segwit.";function f(t){const e=n.from(c.decode(t));if(e.length<21)throw new TypeError(t+" is too short");if(e.length>21)throw new TypeError(t+" is too long");return{version:e.readUInt8(0),hash:e.slice(1)}}function h(t){let e,r;try{e=u.bech32.decode(t)}catch(t){}if(e){if(r=e.words[0],0!==r)throw new TypeError(t+" uses wrong encoding")}else if(e=u.bech32m.decode(t),r=e.words[0],0===r)throw new TypeError(t+" uses wrong encoding");const i=u.bech32.fromWords(e.words.slice(1));return{version:r,prefix:e.prefix,data:n.from(i)}}function p(t,e,r){const n=u.bech32.toWords(t);return n.unshift(e),0===e?u.bech32.encode(r,n):u.bech32m.encode(r,n)}e.fromBase58Check=f,e.fromBech32=h,e.toBase58Check=function(t,e){(0,a.typeforce)((0,a.tuple)(a.Hash160bit,a.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),c.encode(r)},e.toBech32=p,e.fromOutputScript=function(t,e){e=e||i.bitcoin;try{return o.p2pkh({output:t,network:e}).address}catch(t){}try{return o.p2sh({output:t,network:e}).address}catch(t){}try{return o.p2wpkh({output:t,network:e}).address}catch(t){}try{return o.p2wsh({output:t,network:e}).address}catch(t){}try{return o.p2tr({output:t,network:e}).address}catch(t){}try{return function(t,e){const r=t.slice(2);if(r.length<2||r.length>40)throw new TypeError("Invalid program length for segwit address");const n=t[0]-80;if(n<2||n>16)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(l),p(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(s.toASM(t)+" has no matching Address")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=f(t)}catch(t){}if(r){if(r.version===e.pubKeyHash)return o.p2pkh({hash:r.hash}).output;if(r.version===e.scriptHash)return o.p2sh({hash:r.hash}).output}else{try{n=h(t)}catch(t){}if(n){if(n.prefix!==e.bech32)throw new Error(t+" has an invalid prefix");if(0===n.version){if(20===n.data.length)return o.p2wpkh({hash:n.data}).output;if(32===n.data.length)return o.p2wsh({hash:n.data}).output}else if(1===n.version){if(32===n.data.length)return o.p2tr({pubkey:n.data}).output}else if(n.version>=2&&n.version<=16&&n.data.length>=2&&n.data.length<=40)return console.warn(l),s.compile([n.version+80,n.data])}}throw new Error(t+" has no matching Script")}},3966:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=e.check=void 0,e.check=function(t){if(t.length<8)return!1;if(t.length>72)return!1;if(48!==t[0])return!1;if(t[1]!==t.length-2)return!1;if(2!==t[2])return!1;const e=t[3];if(0===e)return!1;if(5+e>=t.length)return!1;if(2!==t[4+e])return!1;const r=t[5+e];return!(0===r||6+e+r!==t.length||128&t[4]||e>1&&0===t[4]&&!(128&t[5])||128&t[e+6]||r>1&&0===t[e+6]&&!(128&t[e+7]))},e.decode=function(t){if(t.length<8)throw new Error("DER sequence length is too short");if(t.length>72)throw new Error("DER sequence length is too long");if(48!==t[0])throw new Error("Expected DER sequence");if(t[1]!==t.length-2)throw new Error("DER sequence length is invalid");if(2!==t[2])throw new Error("Expected DER integer");const e=t[3];if(0===e)throw new Error("R length is zero");if(5+e>=t.length)throw new Error("R length is too long");if(2!==t[4+e])throw new Error("Expected DER integer (2)");const r=t[5+e];if(0===r)throw new Error("S length is zero");if(6+e+r!==t.length)throw new Error("S length is invalid");if(128&t[4])throw new Error("R value is negative");if(e>1&&0===t[4]&&!(128&t[5]))throw new Error("R value excessively padded");if(128&t[e+6])throw new Error("S value is negative");if(r>1&&0===t[e+6]&&!(128&t[e+7]))throw new Error("S value excessively padded");return{r:t.slice(4,4+e),s:t.slice(6+e)}},e.encode=function(t,e){const r=t.length,i=e.length;if(0===r)throw new Error("R length is zero");if(0===i)throw new Error("S length is zero");if(r>33)throw new Error("R length is too long");if(i>33)throw new Error("S length is too long");if(128&t[0])throw new Error("R value is negative");if(128&e[0])throw new Error("S value is negative");if(r>1&&0===t[0]&&!(128&t[1]))throw new Error("R value excessively padded");if(i>1&&0===e[0]&&!(128&e[1]))throw new Error("S value excessively padded");const o=n.allocUnsafe(6+r+i);return o[0]=48,o[1]=o.length-2,o[2]=2,o[3]=t.length,t.copy(o,4),o[4+r]=2,o[5+r]=e.length,e.copy(o,6+r),o}},1696:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Block=void 0;const i=r(606),o=r(1944),s=r(1015),a=r(2021),u=r(8116),{typeforce:c}=u,l=new TypeError("Cannot compute merkle root for zero transactions"),f=new TypeError("Cannot compute witness commit for non-segwit block");class h{constructor(){this.version=1,this.prevHash=void 0,this.merkleRoot=void 0,this.timestamp=0,this.witnessCommit=void 0,this.bits=0,this.nonce=0,this.transactions=void 0}static fromBuffer(t){if(t.length<80)throw new Error("Buffer too small (< 80 bytes)");const e=new i.BufferReader(t),r=new h;if(r.version=e.readInt32(),r.prevHash=e.readSlice(32),r.merkleRoot=e.readSlice(32),r.timestamp=e.readUInt32(),r.bits=e.readUInt32(),r.nonce=e.readUInt32(),80===t.length)return r;const n=()=>{const t=a.Transaction.fromBuffer(e.buffer.slice(e.offset),!0);return e.offset+=t.byteLength(),t},o=e.readVarInt();r.transactions=[];for(let t=0;t<o;++t){const t=n();r.transactions.push(t)}const s=r.getWitnessCommit();return s&&(r.witnessCommit=s),r}static fromHex(t){return h.fromBuffer(n.from(t,"hex"))}static calculateTarget(t){const e=((4278190080&t)>>24)-3,r=8388607&t,i=n.alloc(32,0);return i.writeUIntBE(r,29-e,3),i}static calculateMerkleRoot(t,e){if(c([{getHash:u.Function}],t),0===t.length)throw l;if(e&&!p(t))throw f;const r=t.map((t=>t.getHash(e))),i=(0,s.fastMerkleRoot)(r,o.hash256);return e?o.hash256(n.concat([i,t[0].ins[0].witness[0]])):i}getWitnessCommit(){if(!p(this.transactions))return null;const t=this.transactions[0].outs.filter((t=>t.script.slice(0,6).equals(n.from("6a24aa21a9ed","hex")))).map((t=>t.script.slice(6,38)));if(0===t.length)return null;const e=t[t.length-1];return e instanceof n&&32===e.length?e:null}hasWitnessCommit(){return this.witnessCommit instanceof n&&32===this.witnessCommit.length||null!==this.getWitnessCommit()}hasWitness(){return(t=this.transactions)instanceof Array&&t.some((t=>"object"==typeof t&&t.ins instanceof Array&&t.ins.some((t=>"object"==typeof t&&t.witness instanceof Array&&t.witness.length>0))));var t}weight(){return 3*this.byteLength(!1,!1)+this.byteLength(!1,!0)}byteLength(t,e=!0){return t||!this.transactions?80:80+i.varuint.encodingLength(this.transactions.length)+this.transactions.reduce(((t,r)=>t+r.byteLength(e)),0)}getHash(){return o.hash256(this.toBuffer(!0))}getId(){return(0,i.reverseBuffer)(this.getHash()).toString("hex")}getUTCDate(){const t=new Date(0);return t.setUTCSeconds(this.timestamp),t}toBuffer(t){const e=n.allocUnsafe(this.byteLength(t)),r=new i.BufferWriter(e);return r.writeInt32(this.version),r.writeSlice(this.prevHash),r.writeSlice(this.merkleRoot),r.writeUInt32(this.timestamp),r.writeUInt32(this.bits),r.writeUInt32(this.nonce),t||!this.transactions||(i.varuint.encode(this.transactions.length,e,r.offset),r.offset+=i.varuint.encode.bytes,this.transactions.forEach((t=>{const n=t.byteLength();t.toBuffer(e,r.offset),r.offset+=n}))),e}toHex(t){return this.toBuffer(t).toString("hex")}checkTxRoots(){const t=this.hasWitnessCommit();return!(!t&&this.hasWitness())&&this.__checkMerkleRoot()&&(!t||this.__checkWitnessCommit())}checkProofOfWork(){const t=(0,i.reverseBuffer)(this.getHash()),e=h.calculateTarget(this.bits);return t.compare(e)<=0}__checkMerkleRoot(){if(!this.transactions)throw l;const t=h.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw l;if(!this.hasWitnessCommit())throw f;const t=h.calculateMerkleRoot(this.transactions,!0);return 0===this.witnessCommit.compare(t)}}function p(t){return t instanceof Array&&t[0]&&t[0].ins&&t[0].ins instanceof Array&&t[0].ins[0]&&t[0].ins[0].witness&&t[0].ins[0].witness instanceof Array&&t[0].ins[0].witness.length>0}e.Block=h},606:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.BufferReader=e.BufferWriter=e.cloneBuffer=e.reverseBuffer=e.writeUInt64LE=e.readUInt64LE=e.varuint=void 0;const i=r(8116),{typeforce:o}=i,s=r(8469);function a(t,e){if("number"!=typeof t)throw new Error("cannot write a non-number as a number");if(t<0)throw new Error("specified a negative value for writing an unsigned value");if(t>e)throw new Error("RangeError: value out of range");if(Math.floor(t)!==t)throw new Error("value has a fractional component")}function u(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,a(n+r,9007199254740991),n+r}function c(t,e,r){return a(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}e.varuint=s,e.readUInt64LE=u,e.writeUInt64LE=c,e.reverseBuffer=function(t){if(t.length<1)return t;let e=t.length-1,r=0;for(let n=0;n<t.length/2;n++)r=t[n],t[n]=t[e],t[e]=r,e--;return t},e.cloneBuffer=function(t){const e=n.allocUnsafe(t.length);return t.copy(e),e};class l{static withCapacity(t){return new l(n.alloc(t))}constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}writeUInt8(t){this.offset=this.buffer.writeUInt8(t,this.offset)}writeInt32(t){this.offset=this.buffer.writeInt32LE(t,this.offset)}writeUInt32(t){this.offset=this.buffer.writeUInt32LE(t,this.offset)}writeUInt64(t){this.offset=c(this.buffer,t,this.offset)}writeVarInt(t){s.encode(t,this.buffer,this.offset),this.offset+=s.encode.bytes}writeSlice(t){if(this.buffer.length<this.offset+t.length)throw new Error("Cannot write slice out of bounds");this.offset+=t.copy(this.buffer,this.offset)}writeVarSlice(t){this.writeVarInt(t.length),this.writeSlice(t)}writeVector(t){this.writeVarInt(t.length),t.forEach((t=>this.writeVarSlice(t)))}end(){if(this.buffer.length===this.offset)return this.buffer;throw new Error(`buffer size ${this.buffer.length}, offset ${this.offset}`)}}e.BufferWriter=l,e.BufferReader=class{constructor(t,e=0){this.buffer=t,this.offset=e,o(i.tuple(i.Buffer,i.UInt32),[t,e])}readUInt8(){const t=this.buffer.readUInt8(this.offset);return this.offset++,t}readInt32(){const t=this.buffer.readInt32LE(this.offset);return this.offset+=4,t}readUInt32(){const t=this.buffer.readUInt32LE(this.offset);return this.offset+=4,t}readUInt64(){const t=u(this.buffer,this.offset);return this.offset+=8,t}readVarInt(){const t=s.decode(this.buffer,this.offset);return this.offset+=s.decode.bytes,t}readSlice(t){if(this.buffer.length<this.offset+t)throw new Error("Cannot read slice out of bounds");const e=this.buffer.slice(this.offset,this.offset+t);return this.offset+=t,e}readVarSlice(){return this.readSlice(this.readVarInt())}readVector(){const t=this.readVarInt(),e=[];for(let r=0;r<t;r++)e.push(this.readVarSlice());return e}}},1944:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.taggedHash=e.TAGGED_HASH_PREFIXES=e.TAGS=e.hash256=e.hash160=e.sha256=e.sha1=e.ripemd160=void 0;const i=r(3238),o=r(1549),s=r(2623);function a(t){return n.from((0,s.sha256)(Uint8Array.from(t)))}e.ripemd160=function(t){return n.from((0,i.ripemd160)(Uint8Array.from(t)))},e.sha1=function(t){return n.from((0,o.sha1)(Uint8Array.from(t)))},e.sha256=a,e.hash160=function(t){return n.from((0,i.ripemd160)((0,s.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,s.sha256)((0,s.sha256)(Uint8Array.from(t))))},e.TAGS=["BIP0340/challenge","BIP0340/aux","BIP0340/nonce","TapLeaf","TapBranch","TapSighash","TapTweak","KeyAgg list","KeyAgg coefficient"],e.TAGGED_HASH_PREFIXES={"BIP0340/challenge":n.from([123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124,123,181,45,122,159,239,88,50,62,177,191,122,64,125,179,130,210,243,242,216,27,177,34,79,73,254,81,143,109,72,211,124]),"BIP0340/aux":n.from([241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144,241,239,78,94,192,99,202,218,109,148,202,250,157,152,126,160,105,38,88,57,236,193,31,151,45,119,165,46,216,193,204,144]),"BIP0340/nonce":n.from([7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47,7,73,119,52,167,155,203,53,91,155,140,125,3,79,18,28,244,52,215,62,247,45,218,25,135,0,97,251,82,191,235,47]),TapLeaf:n.from([174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238,174,234,143,220,66,8,152,49,5,115,75,88,8,29,30,38,56,211,95,28,181,64,8,212,211,87,202,3,190,120,233,238]),TapBranch:n.from([25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21,25,65,161,242,229,110,185,95,162,169,241,148,190,92,1,247,33,111,51,237,130,176,145,70,52,144,208,91,245,22,160,21]),TapSighash:n.from([244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49,244,10,72,223,75,42,112,200,180,146,75,242,101,70,97,237,61,149,253,102,163,19,235,135,35,117,151,198,40,228,160,49]),TapTweak:n.from([232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233,232,15,225,99,156,156,160,80,227,175,27,57,193,67,198,62,66,156,188,235,21,217,64,251,181,197,161,244,175,87,197,233]),"KeyAgg list":n.from([72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240,72,28,151,28,60,11,70,215,240,178,117,174,89,141,78,44,126,215,49,156,89,74,92,110,199,158,160,212,153,2,148,240]),"KeyAgg coefficient":n.from([191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129,191,201,4,3,77,28,136,232,200,14,34,229,61,36,86,109,100,130,78,214,66,114,129,192,145,0,249,77,205,82,201,129])},e.taggedHash=function(t,r){return a(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))}},916:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.getEccLib=e.initEccLib=void 0;const i={};e.initEccLib=function(t){var e;t?t!==i.eccLib&&(s("function"==typeof(e=t).isXOnlyPoint),s(e.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),s(e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),s(e.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),s(e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),s(!e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),s(!e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),s("function"==typeof e.xOnlyPointAddTweak),a.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?s(null===r):(s(null!==r),s(r.parity===t.parity),s(n.from(r.xOnlyPubkey).equals(o(t.result))))})),i.eccLib=t):i.eccLib=t},e.getEccLib=function(){if(!i.eccLib)throw new Error("No ECC Library provided. You must call initEccLib() with a valid TinySecp256k1Interface instance");return i.eccLib};const o=t=>n.from(t,"hex");function s(t){if(!t)throw new Error("ecc library invalid")}const a=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},1757:(t,e,r)=>{e.f0=e.K$=e.KT=e.o8=e.hl=void 0;const n=r(57);e.hl=n,r(1944);const i=r(622);e.o8=i;const o=r(885);e.KT=o;const s=r(7038);e.K$=s;r(1696),r(9646),r(8417),r(2021);var a=r(916);Object.defineProperty(e,"f0",{enumerable:!0,get:function(){return a.initEccLib}})},1015:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.fastMerkleRoot=void 0,e.fastMerkleRoot=function(t,e){if(!Array.isArray(t))throw TypeError("Expected values Array");if("function"!=typeof e)throw TypeError("Expected digest Function");let r=t.length;const i=t.concat();for(;r>1;){let t=0;for(let o=0;o<r;o+=2,++t){const s=i[o],a=o+1===r?s:i[o+1],u=n.concat([s,a]);i[t]=e(u)}r=t}return i[0]}},622:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.regtest=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.regtest={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bcrt",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},8417:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.REVERSE_OPS=e.OPS=void 0;const r={OP_FALSE:0,OP_0:0,OP_PUSHDATA1:76,OP_PUSHDATA2:77,OP_PUSHDATA4:78,OP_1NEGATE:79,OP_RESERVED:80,OP_TRUE:81,OP_1:81,OP_2:82,OP_3:83,OP_4:84,OP_5:85,OP_6:86,OP_7:87,OP_8:88,OP_9:89,OP_10:90,OP_11:91,OP_12:92,OP_13:93,OP_14:94,OP_15:95,OP_16:96,OP_NOP:97,OP_VER:98,OP_IF:99,OP_NOTIF:100,OP_VERIF:101,OP_VERNOTIF:102,OP_ELSE:103,OP_ENDIF:104,OP_VERIFY:105,OP_RETURN:106,OP_TOALTSTACK:107,OP_FROMALTSTACK:108,OP_2DROP:109,OP_2DUP:110,OP_3DUP:111,OP_2OVER:112,OP_2ROT:113,OP_2SWAP:114,OP_IFDUP:115,OP_DEPTH:116,OP_DROP:117,OP_DUP:118,OP_NIP:119,OP_OVER:120,OP_PICK:121,OP_ROLL:122,OP_ROT:123,OP_SWAP:124,OP_TUCK:125,OP_CAT:126,OP_SUBSTR:127,OP_LEFT:128,OP_RIGHT:129,OP_SIZE:130,OP_INVERT:131,OP_AND:132,OP_OR:133,OP_XOR:134,OP_EQUAL:135,OP_EQUALVERIFY:136,OP_RESERVED1:137,OP_RESERVED2:138,OP_1ADD:139,OP_1SUB:140,OP_2MUL:141,OP_2DIV:142,OP_NEGATE:143,OP_ABS:144,OP_NOT:145,OP_0NOTEQUAL:146,OP_ADD:147,OP_SUB:148,OP_MUL:149,OP_DIV:150,OP_MOD:151,OP_LSHIFT:152,OP_RSHIFT:153,OP_BOOLAND:154,OP_BOOLOR:155,OP_NUMEQUAL:156,OP_NUMEQUALVERIFY:157,OP_NUMNOTEQUAL:158,OP_LESSTHAN:159,OP_GREATERTHAN:160,OP_LESSTHANOREQUAL:161,OP_GREATERTHANOREQUAL:162,OP_MIN:163,OP_MAX:164,OP_WITHIN:165,OP_RIPEMD160:166,OP_SHA1:167,OP_SHA256:168,OP_HASH160:169,OP_HASH256:170,OP_CODESEPARATOR:171,OP_CHECKSIG:172,OP_CHECKSIGVERIFY:173,OP_CHECKMULTISIG:174,OP_CHECKMULTISIGVERIFY:175,OP_NOP1:176,OP_NOP2:177,OP_CHECKLOCKTIMEVERIFY:177,OP_NOP3:178,OP_CHECKSEQUENCEVERIFY:178,OP_NOP4:179,OP_NOP5:180,OP_NOP6:181,OP_NOP7:182,OP_NOP8:183,OP_NOP9:184,OP_NOP10:185,OP_CHECKSIGADD:186,OP_PUBKEYHASH:253,OP_PUBKEY:254,OP_INVALIDOPCODE:255};e.OPS=r;const n={};e.REVERSE_OPS=n;for(const t of Object.keys(r))n[r[t]]=t},2218:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.tweakKey=e.tapTweakHash=e.tapleafHash=e.findScriptPath=e.toHashTree=e.rootHashFromPath=e.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0;const n=r(8287),i=r(916),o=r(1944),s=r(606),a=r(8116);function u(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),f(t.output)]))}function c(t,e){return o.taggedHash("TapTweak",n.Buffer.concat(e?[t,e]:[t]))}function l(t,e){return o.taggedHash("TapBranch",n.Buffer.concat([t,e]))}function f(t){const e=s.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return s.varuint.encode(t.length,r),n.Buffer.concat([r,t])}e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128,e.rootHashFromPath=function(t,e){if(t.length<33)throw new TypeError(`The control-block length is too small. Got ${t.length}, expected min 33.`);const r=(t.length-33)/32;let n=e;for(let e=0;e<r;e++){const r=t.slice(33+32*e,65+32*e);n=n.compare(r)<0?l(n,r):l(r,n)}return n},e.toHashTree=function t(e){if((0,a.isTapleaf)(e))return{hash:u(e)};const r=[t(e[0]),t(e[1])];r.sort(((t,e)=>t.hash.compare(e.hash)));const[n,i]=r;return{hash:l(n.hash,i.hash),left:n,right:i}},e.findScriptPath=function t(e,r){if("left"in(n=e)&&"right"in n){const n=t(e.left,r);if(void 0!==n)return[...n,e.right.hash];const i=t(e.right,r);if(void 0!==i)return[...i,e.left.hash]}else if(e.hash.equals(r))return[];var n},e.tapleafHash=u,e.tapTweakHash=c,e.tweakKey=function(t,e){if(!n.Buffer.isBuffer(t))return null;if(32!==t.length)return null;if(e&&32!==e.length)return null;const r=c(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null}},5472:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2data=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS;e.p2data=function(t,e){if(!t.data&&!t.output)throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),data:o.typeforce.maybe(o.typeforce.arrayOf(o.typeforce.Buffer))},t);const r={name:"embed",network:t.network||n.bitcoin};if(s.prop(r,"output",(()=>{if(t.data)return i.compile([a.OP_RETURN].concat(t.data))})),s.prop(r,"data",(()=>{if(t.output)return i.decompile(t.output).slice(1)})),e.validate&&t.output){const e=i.decompile(t.output);if(e[0]!==a.OP_RETURN)throw new TypeError("Output is invalid");if(!e.slice(1).every(o.typeforce.Buffer))throw new TypeError("Output is invalid");if(t.data&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)}},885:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=e.p2wsh=e.p2wpkh=e.p2sh=e.p2pkh=e.p2pk=e.p2ms=e.embed=void 0;const n=r(5472);Object.defineProperty(e,"embed",{enumerable:!0,get:function(){return n.p2data}});const i=r(1395);Object.defineProperty(e,"p2ms",{enumerable:!0,get:function(){return i.p2ms}});const o=r(4930);Object.defineProperty(e,"p2pk",{enumerable:!0,get:function(){return o.p2pk}});const s=r(3504);Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return s.p2pkh}});const a=r(8368);Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return a.p2sh}});const u=r(7027);Object.defineProperty(e,"p2wpkh",{enumerable:!0,get:function(){return u.p2wpkh}});const c=r(9041);Object.defineProperty(e,"p2wsh",{enumerable:!0,get:function(){return c.p2wsh}});const l=r(5501);Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return l.p2tr}})},7883:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.value=e.prop=void 0,e.prop=function(t,e,r){Object.defineProperty(t,e,{configurable:!0,enumerable:!0,get(){const t=r.call(this);return this[e]=t,t},set(t){Object.defineProperty(this,e,{configurable:!0,enumerable:!0,value:t,writable:!0})}})},e.value=function(t){let e;return()=>(void 0!==e||(e=t()),e)}},1395:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2ms=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS,u=a.OP_RESERVED;function c(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}e.p2ms=function(t,e){if(!(t.input||t.output||t.pubkeys&&void 0!==t.m||t.signatures))throw new TypeError("Not enough data");function r(t){return i.isCanonicalScriptSignature(t)||void 0!==(e.allowIncomplete&&t===a.OP_0)}e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),m:o.typeforce.maybe(o.typeforce.Number),n:o.typeforce.maybe(o.typeforce.Number),output:o.typeforce.maybe(o.typeforce.Buffer),pubkeys:o.typeforce.maybe(o.typeforce.arrayOf(o.isPoint)),signatures:o.typeforce.maybe(o.typeforce.arrayOf(r)),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const l={network:t.network||n.bitcoin};let f=[],h=!1;function p(t){h||(h=!0,f=i.decompile(t),l.m=f[0]-u,l.n=f[f.length-2]-u,l.pubkeys=f.slice(1,-2))}if(s.prop(l,"output",(()=>{if(t.m&&l.n&&t.pubkeys)return i.compile([].concat(u+t.m,t.pubkeys,u+l.n,a.OP_CHECKMULTISIG))})),s.prop(l,"m",(()=>{if(l.output)return p(l.output),l.m})),s.prop(l,"n",(()=>{if(l.pubkeys)return l.pubkeys.length})),s.prop(l,"pubkeys",(()=>{if(t.output)return p(t.output),l.pubkeys})),s.prop(l,"signatures",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),s.prop(l,"input",(()=>{if(t.signatures)return i.compile([a.OP_0].concat(t.signatures))})),s.prop(l,"witness",(()=>{if(l.input)return[]})),s.prop(l,"name",(()=>{if(l.m&&l.n)return`p2ms(${l.m} of ${l.n})`})),e.validate){if(t.output){if(p(t.output),!o.typeforce.Number(f[0]))throw new TypeError("Output is invalid");if(!o.typeforce.Number(f[f.length-2]))throw new TypeError("Output is invalid");if(f[f.length-1]!==a.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(l.m<=0||l.n>16||l.m>l.n||l.n!==f.length-3)throw new TypeError("Output is invalid");if(!l.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==l.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==l.n)throw new TypeError("n mismatch");if(t.pubkeys&&!c(t.pubkeys,l.pubkeys))throw new TypeError("Pubkeys mismatch")}if(t.pubkeys){if(void 0!==t.n&&t.n!==t.pubkeys.length)throw new TypeError("Pubkey count mismatch");if(l.n=t.pubkeys.length,l.n<l.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<l.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>l.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==a.OP_0)throw new TypeError("Input is invalid");if(0===l.signatures.length||!l.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!c(t.signatures,l.signatures))throw new TypeError("Signature mismatch");if(void 0!==t.m&&t.m!==t.signatures.length)throw new TypeError("Signature count mismatch")}}return Object.assign(l,t)}},4930:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2pk=void 0;const n=r(622),i=r(7038),o=r(8116),s=r(7883),a=i.OPS;e.p2pk=function(t,e){if(!(t.input||t.output||t.pubkey||t.input||t.signature))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,o.typeforce)({network:o.typeforce.maybe(o.typeforce.Object),output:o.typeforce.maybe(o.typeforce.Buffer),pubkey:o.typeforce.maybe(o.isPoint),signature:o.typeforce.maybe(i.isCanonicalScriptSignature),input:o.typeforce.maybe(o.typeforce.Buffer)},t);const r=s.value((()=>i.decompile(t.input))),u={name:"p2pk",network:t.network||n.bitcoin};if(s.prop(u,"output",(()=>{if(t.pubkey)return i.compile([t.pubkey,a.OP_CHECKSIG])})),s.prop(u,"pubkey",(()=>{if(t.output)return t.output.slice(1,-1)})),s.prop(u,"signature",(()=>{if(t.input)return r()[0]})),s.prop(u,"input",(()=>{if(t.signature)return i.compile([t.signature])})),s.prop(u,"witness",(()=>{if(u.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==a.OP_CHECKSIG)throw new TypeError("Output is invalid");if(!(0,o.isPoint)(u.pubkey))throw new TypeError("Output pubkey is invalid");if(t.pubkey&&!t.pubkey.equals(u.pubkey))throw new TypeError("Pubkey mismatch")}if(t.signature&&t.input&&!t.input.equals(u.input))throw new TypeError("Signature mismatch");if(t.input){if(1!==r().length)throw new TypeError("Input is invalid");if(!i.isCanonicalScriptSignature(u.signature))throw new TypeError("Input has invalid signature")}}return Object.assign(u,t)}},3504:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2pkh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(1889),l=s.OPS;e.p2pkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(25)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),input:a.typeforce.maybe(a.typeforce.Buffer)},t);const r=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),f=u.value((()=>s.decompile(t.input))),h=t.network||o.bitcoin,p={name:"p2pkh",network:h};if(u.prop(p,"address",(()=>{if(!p.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(h.pubKeyHash,0),p.hash.copy(t,1),c.encode(t)})),u.prop(p,"hash",(()=>t.output?t.output.slice(3,23):t.address?r().hash:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),u.prop(p,"output",(()=>{if(p.hash)return s.compile([l.OP_DUP,l.OP_HASH160,p.hash,l.OP_EQUALVERIFY,l.OP_CHECKSIG])})),u.prop(p,"pubkey",(()=>{if(t.input)return f()[1]})),u.prop(p,"signature",(()=>{if(t.input)return f()[0]})),u.prop(p,"input",(()=>{if(t.pubkey&&t.signature)return s.compile([t.signature,t.pubkey])})),u.prop(p,"witness",(()=>{if(p.input)return[]})),e.validate){let e=n.from([]);if(t.address){if(r().version!==h.pubKeyHash)throw new TypeError("Invalid version or Network mismatch");if(20!==r().hash.length)throw new TypeError("Invalid address");e=r().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(25!==t.output.length||t.output[0]!==l.OP_DUP||t.output[1]!==l.OP_HASH160||20!==t.output[2]||t.output[23]!==l.OP_EQUALVERIFY||t.output[24]!==l.OP_CHECKSIG)throw new TypeError("Output is invalid");const r=t.output.slice(3,23);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.input){const r=f();if(2!==r.length)throw new TypeError("Input is invalid");if(!s.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,a.isPoint)(r[1]))throw new TypeError("Input has invalid pubkey");if(t.signature&&!t.signature.equals(r[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(r[1]))throw new TypeError("Pubkey mismatch");const n=i.hash160(r[1]);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}},8368:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2sh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(1889),l=s.OPS;e.p2sh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.input))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),output:a.typeforce.maybe(a.typeforce.BufferN(23)),redeem:a.typeforce.maybe({network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const f={network:r},h=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),p=u.value((()=>s.decompile(t.input))),d=u.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===l.OP_FALSE?n.from([]):i,input:s.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(u.prop(f,"address",(()=>{if(!f.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(f.network.scriptHash,0),f.hash.copy(t,1),c.encode(t)})),u.prop(f,"hash",(()=>t.output?t.output.slice(2,22):t.address?h().hash:f.redeem&&f.redeem.output?i.hash160(f.redeem.output):void 0)),u.prop(f,"output",(()=>{if(f.hash)return s.compile([l.OP_HASH160,f.hash,l.OP_EQUAL])})),u.prop(f,"redeem",(()=>{if(t.input)return d()})),u.prop(f,"input",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return s.compile([].concat(s.decompile(t.redeem.input),t.redeem.output))})),u.prop(f,"witness",(()=>f.redeem&&f.redeem.witness?f.redeem.witness:f.input?[]:void 0)),u.prop(f,"name",(()=>{const t=["p2sh"];return void 0!==f.redeem&&void 0!==f.redeem.name&&t.push(f.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(h().version!==r.scriptHash)throw new TypeError("Invalid version or Network mismatch");if(20!==h().hash.length)throw new TypeError("Invalid address");e=h().hash}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(23!==t.output.length||t.output[0]!==l.OP_HASH160||20!==t.output[1]||t.output[22]!==l.OP_EQUAL)throw new TypeError("Output is invalid");const r=t.output.slice(2,22);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}const o=t=>{if(t.output){const r=s.decompile(t.output);if(!r||r.length<1)throw new TypeError("Redeem.output too short");if(t.output.byteLength>520)throw new TypeError("Redeem.output unspendable if larger than 520 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.hash160(t.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.input){const e=t.input.length>0,r=t.witness&&t.witness.length>0;if(!e&&!r)throw new TypeError("Empty input");if(e&&r)throw new TypeError("Input and witness provided");if(e){const e=s.decompile(t.input);if(!s.isPushOnly(e))throw new TypeError("Non push-only scriptSig")}}};if(t.input){const t=p();if(!t||t.length<1)throw new TypeError("Input too short");if(!n.isBuffer(d().output))throw new TypeError("Input is invalid");o(d())}if(t.redeem){if(t.redeem.network&&t.redeem.network!==r)throw new TypeError("Network mismatch");if(t.input){const e=d();if(t.redeem.output&&!t.redeem.output.equals(e.output))throw new TypeError("Redeem.output mismatch");if(t.redeem.input&&!t.redeem.input.equals(e.input))throw new TypeError("Redeem.input mismatch")}o(t.redeem)}if(t.witness&&t.redeem&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(f,t)}},5501:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.p2tr=void 0;const n=r(8287),i=r(622),o=r(7038),s=r(8116),a=r(916),u=r(2218),c=r(7883),l=r(2343),f=o.OPS;e.p2tr=function(t,e){if(!(t.address||t.output||t.pubkey||t.internalPubkey||t.witness&&t.witness.length>1))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(34)),internalPubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),pubkey:s.typeforce.maybe(s.typeforce.BufferN(32)),signature:s.typeforce.maybe(s.typeforce.anyOf(s.typeforce.BufferN(64),s.typeforce.BufferN(65))),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer)),scriptTree:s.typeforce.maybe(s.isTaptree),redeem:s.typeforce.maybe({output:s.typeforce.maybe(s.typeforce.Buffer),redeemVersion:s.typeforce.maybe(s.typeforce.Number),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),redeemVersion:s.typeforce.maybe(s.typeforce.Number)},t);const r=c.value((()=>{const e=l.bech32m.decode(t.address),r=e.words.shift(),i=l.bech32m.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.Buffer.from(i)}})),h=c.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&80===t.witness[t.witness.length-1][0]?t.witness.slice(0,-1):t.witness.slice()})),p=c.value((()=>t.scriptTree?(0,u.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),d=t.network||i.bitcoin,y={name:"p2tr",network:d};if(c.prop(y,"address",(()=>{if(!y.pubkey)return;const t=l.bech32m.toWords(y.pubkey);return t.unshift(1),l.bech32m.encode(d.bech32,t)})),c.prop(y,"hash",(()=>{const t=p();if(t)return t.hash;const e=h();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&s.TAPLEAF_VERSION_MASK,n=e[e.length-2],i=(0,u.tapleafHash)({output:n,version:r});return(0,u.rootHashFromPath)(t,i)}return null})),c.prop(y,"output",(()=>{if(y.pubkey)return o.compile([f.OP_1,y.pubkey])})),c.prop(y,"redeemVersion",(()=>t.redeemVersion?t.redeemVersion:t.redeem&&void 0!==t.redeem.redeemVersion&&null!==t.redeem.redeemVersion?t.redeem.redeemVersion:u.LEAF_VERSION_TAPSCRIPT)),c.prop(y,"redeem",(()=>{const t=h();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&s.TAPLEAF_VERSION_MASK}})),c.prop(y,"pubkey",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(y.internalPubkey){const t=(0,u.tweakKey)(y.internalPubkey,y.hash);if(t)return t.x}})),c.prop(y,"internalPubkey",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=h();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),c.prop(y,"signature",(()=>{if(t.signature)return t.signature;const e=h();return e&&1===e.length?e[0]:void 0})),c.prop(y,"witness",(()=>{if(t.witness)return t.witness;const e=p();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,u.tapleafHash)({output:t.redeem.output,version:y.redeemVersion}),i=(0,u.findScriptPath)(e,r);if(!i)return;const o=(0,u.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const s=n.Buffer.concat([n.Buffer.from([y.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,s]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(d&&d.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(1!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.pubkey){if(e.length>0&&!e.equals(t.pubkey))throw new TypeError("Pubkey mismatch");e=t.pubkey}if(t.output){if(34!==t.output.length||t.output[0]!==f.OP_1||32!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Pubkey mismatch");e=t.output.slice(2)}if(t.internalPubkey){const r=(0,u.tweakKey)(t.internalPubkey,y.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError("Pubkey mismatch");e=r.x}if(e&&e.length&&!(0,a.getEccLib)().isXOnlyPoint(e))throw new TypeError("Invalid pubkey for p2tr");const i=p();if(t.hash&&i&&!t.hash.equals(i.hash))throw new TypeError("Hash mismatch");if(t.redeem&&t.redeem.output&&i){const e=(0,u.tapleafHash)({output:t.redeem.output,version:y.redeemVersion});if(!(0,u.findScriptPath)(i,e))throw new TypeError("Redeem script not in tree")}const c=h();if(t.redeem&&y.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==y.redeem.redeemVersion)throw new TypeError("Redeem.redeemVersion and witness mismatch");if(t.redeem.output){if(0===o.decompile(t.redeem.output).length)throw new TypeError("Redeem.output is invalid");if(y.redeem.output&&!t.redeem.output.equals(y.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&y.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.redeem.witness,y.redeem.witness))throw new TypeError("Redeem.witness and witness mismatch")}if(c&&c.length)if(1===c.length){if(t.signature&&!t.signature.equals(c[0]))throw new TypeError("Signature mismatch")}else{const r=c[c.length-1];if(r.length<33)throw new TypeError(`The control-block length is too small. Got ${r.length}, expected min 33.`);if((r.length-33)%32!=0)throw new TypeError(`The control-block length of ${r.length} is incorrect!`);const n=(r.length-33)/32;if(n>128)throw new TypeError(`The script path is too long. Got ${n}, expected max 128.`);const i=r.slice(1,33);if(t.internalPubkey&&!t.internalPubkey.equals(i))throw new TypeError("Internal pubkey mismatch");if(!(0,a.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&s.TAPLEAF_VERSION_MASK,l=c[c.length-2],f=(0,u.tapleafHash)({output:l,version:o}),h=(0,u.rootHashFromPath)(r,f),p=(0,u.tweakKey)(i,h);if(!p)throw new TypeError("Invalid outputKey for p2tr witness");if(e.length&&!e.equals(p.x))throw new TypeError("Pubkey mismatch for p2tr witness");if(p.parity!==(1&r[0]))throw new Error("Incorrect parity")}}return Object.assign(y,t)}},7027:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wpkh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(2343),l=s.OPS,f=n.alloc(0);e.p2wpkh=function(t,e){if(!(t.address||t.hash||t.output||t.pubkey||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(20)),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(22)),pubkey:a.typeforce.maybe(a.isPoint),signature:a.typeforce.maybe(s.isCanonicalScriptSignature),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=c.bech32.decode(t.address),r=e.words.shift(),i=c.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),h=t.network||o.bitcoin,p={name:"p2wpkh",network:h};if(u.prop(p,"address",(()=>{if(!p.hash)return;const t=c.bech32.toWords(p.hash);return t.unshift(0),c.bech32.encode(h.bech32,t)})),u.prop(p,"hash",(()=>t.output?t.output.slice(2,22):t.address?r().data:t.pubkey||p.pubkey?i.hash160(t.pubkey||p.pubkey):void 0)),u.prop(p,"output",(()=>{if(p.hash)return s.compile([l.OP_0,p.hash])})),u.prop(p,"pubkey",(()=>t.pubkey?t.pubkey:t.witness?t.witness[1]:void 0)),u.prop(p,"signature",(()=>{if(t.witness)return t.witness[0]})),u.prop(p,"input",(()=>{if(p.witness)return f})),u.prop(p,"witness",(()=>{if(t.pubkey&&t.signature)return[t.signature,t.pubkey]})),e.validate){let e=n.from([]);if(t.address){if(h&&h.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(20!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(22!==t.output.length||t.output[0]!==l.OP_0||20!==t.output[1])throw new TypeError("Output is invalid");if(e.length>0&&!e.equals(t.output.slice(2)))throw new TypeError("Hash mismatch");e=t.output.slice(2)}if(t.pubkey){const r=i.hash160(t.pubkey);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");if(e=r,!(0,a.isPoint)(t.pubkey)||33!==t.pubkey.length)throw new TypeError("Invalid pubkey for p2wpkh")}if(t.witness){if(2!==t.witness.length)throw new TypeError("Witness is invalid");if(!s.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,a.isPoint)(t.witness[1])||33!==t.witness[1].length)throw new TypeError("Witness has invalid pubkey");if(t.signature&&!t.signature.equals(t.witness[0]))throw new TypeError("Signature mismatch");if(t.pubkey&&!t.pubkey.equals(t.witness[1]))throw new TypeError("Pubkey mismatch");const r=i.hash160(t.witness[1]);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch")}}return Object.assign(p,t)}},9041:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.p2wsh=void 0;const i=r(1944),o=r(622),s=r(7038),a=r(8116),u=r(7883),c=r(2343),l=s.OPS,f=n.alloc(0);function h(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,a.isPoint)(t))}e.p2wsh=function(t,e){if(!(t.address||t.hash||t.output||t.redeem||t.witness))throw new TypeError("Not enough data");e=Object.assign({validate:!0},e||{}),(0,a.typeforce)({network:a.typeforce.maybe(a.typeforce.Object),address:a.typeforce.maybe(a.typeforce.String),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),output:a.typeforce.maybe(a.typeforce.BufferN(34)),redeem:a.typeforce.maybe({input:a.typeforce.maybe(a.typeforce.Buffer),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.Buffer),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),input:a.typeforce.maybe(a.typeforce.BufferN(0)),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))},t);const r=u.value((()=>{const e=c.bech32.decode(t.address),r=e.words.shift(),i=c.bech32.fromWords(e.words);return{version:r,prefix:e.prefix,data:n.from(i)}})),p=u.value((()=>s.decompile(t.redeem.input)));let d=t.network;d||(d=t.redeem&&t.redeem.network||o.bitcoin);const y={network:d};if(u.prop(y,"address",(()=>{if(!y.hash)return;const t=c.bech32.toWords(y.hash);return t.unshift(0),c.bech32.encode(d.bech32,t)})),u.prop(y,"hash",(()=>t.output?t.output.slice(2):t.address?r().data:y.redeem&&y.redeem.output?i.sha256(y.redeem.output):void 0)),u.prop(y,"output",(()=>{if(y.hash)return s.compile([l.OP_0,y.hash])})),u.prop(y,"redeem",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:f,witness:t.witness.slice(0,-1)}})),u.prop(y,"input",(()=>{if(y.witness)return f})),u.prop(y,"witness",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.input.length>0&&t.redeem.output&&t.redeem.output.length>0){const e=s.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=f,[].concat(e,t.redeem.output)}if(t.redeem&&t.redeem.output&&t.redeem.witness)return[].concat(t.redeem.witness,t.redeem.output)})),u.prop(y,"name",(()=>{const t=["p2wsh"];return void 0!==y.redeem&&void 0!==y.redeem.name&&t.push(y.redeem.name),t.join("-")})),e.validate){let e=n.from([]);if(t.address){if(r().prefix!==d.bech32)throw new TypeError("Invalid prefix or Network mismatch");if(0!==r().version)throw new TypeError("Invalid address version");if(32!==r().data.length)throw new TypeError("Invalid address data");e=r().data}if(t.hash){if(e.length>0&&!e.equals(t.hash))throw new TypeError("Hash mismatch");e=t.hash}if(t.output){if(34!==t.output.length||t.output[0]!==l.OP_0||32!==t.output[1])throw new TypeError("Output is invalid");const r=t.output.slice(2);if(e.length>0&&!e.equals(r))throw new TypeError("Hash mismatch");e=r}if(t.redeem){if(t.redeem.network&&t.redeem.network!==d)throw new TypeError("Network mismatch");if(t.redeem.input&&t.redeem.input.length>0&&t.redeem.witness&&t.redeem.witness.length>0)throw new TypeError("Ambiguous witness source");if(t.redeem.output){const r=s.decompile(t.redeem.output);if(!r||r.length<1)throw new TypeError("Redeem.output is invalid");if(t.redeem.output.byteLength>3600)throw new TypeError("Redeem.output unspendable if larger than 3600 bytes");if(s.countNonPushOnlyOPs(r)>201)throw new TypeError("Redeem.output unspendable with more than 201 non-push ops");const n=i.sha256(t.redeem.output);if(e.length>0&&!e.equals(n))throw new TypeError("Hash mismatch");e=n}if(t.redeem.input&&!s.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))}(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&p().some(h)||t.redeem.output&&(s.decompile(t.redeem.output)||[]).some(h))throw new TypeError("redeem.input or redeem.output contains uncompressed pubkey")}if(t.witness&&t.witness.length>0){const e=t.witness[t.witness.length-1];if(t.redeem&&t.redeem.output&&!t.redeem.output.equals(e))throw new TypeError("Witness and redeem.output mismatch");if(t.witness.some(h)||(s.decompile(e)||[]).some(h))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,t)}},9646:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Psbt=void 0;const i=r(1614),o=r(394),s=r(5080),a=r(57),u=r(606),c=r(622),l=r(885),f=r(2218),h=r(7038),p=r(2021),d=r(477),y=r(4929),g={network:c.bitcoin,maximumFeeRate:5e3};class b{static fromBase64(t,e={}){const r=n.from(t,"base64");return this.fromBuffer(r,e)}static fromHex(t,e={}){const r=n.from(t,"hex");return this.fromBuffer(r,e)}static fromBuffer(t,e={}){const r=i.Psbt.fromBuffer(t,w),n=new b(e,r);var o,s;return o=n.__CACHE.__TX,s=n.__CACHE,o.ins.forEach((t=>{P(s,t)})),n}constructor(t={},e=new i.Psbt(new m)){this.data=e,this.opts=Object.assign({},g,t),this.__CACHE={__NON_WITNESS_UTXO_TX_CACHE:[],__NON_WITNESS_UTXO_BUF_CACHE:[],__TX_IN_CACHE:{},__TX:this.data.globalMap.unsignedTx.tx,__UNSAFE_SIGN_NONSEGWIT:!1},0===this.data.inputs.length&&this.setVersion(2);const r=(t,e,r,n)=>Object.defineProperty(t,e,{enumerable:r,writable:n});r(this,"__CACHE",!1,!0),r(this,"opts",!1,!0)}get inputCount(){return this.data.inputs.length}get version(){return this.__CACHE.__TX.version}set version(t){this.setVersion(t)}get locktime(){return this.__CACHE.__TX.locktime}set locktime(t){this.setLocktime(t)}get txInputs(){return this.__CACHE.__TX.ins.map((t=>({hash:(0,u.cloneBuffer)(t.hash),index:t.index,sequence:t.sequence})))}get txOutputs(){return this.__CACHE.__TX.outs.map((t=>{let e;try{e=(0,a.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,u.cloneBuffer)(t.script),value:t.value,address:e}}))}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){const t=b.fromBuffer(this.data.toBuffer());return t.opts=JSON.parse(JSON.stringify(this.opts)),t}setMaximumFeeRate(t){_(t),this.opts.maximumFeeRate=t}setVersion(t){_(t),k(this.data.inputs,"setVersion");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){_(t),k(this.data.inputs,"setLocktime");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){_(e),k(this.data.inputs,"setInputSequence");const r=this.__CACHE;if(r.__TX.ins.length<=t)throw new Error("Input index too high");return r.__TX.ins[t].sequence=e,r.__EXTRACTED_TX=void 0,this}addInputs(t){return t.forEach((t=>this.addInput(t))),this}addInput(t){if(arguments.length>1||!t||void 0===t.hash||void 0===t.index)throw new Error("Invalid arguments for Psbt.addInput. Requires single object with at least [hash] and [index]");(0,d.checkTaprootInputFields)(t,t,"addInput"),k(this.data.inputs,"addInput"),t.witnessScript&&Q(t.witnessScript);const e=this.__CACHE;this.data.addInput(t),P(e,e.__TX.ins[e.__TX.ins.length-1]);const r=this.data.inputs.length-1,n=this.data.inputs[r];return n.nonWitnessUtxo&&j(this.__CACHE,n,r),e.__FEE=void 0,e.__FEE_RATE=void 0,e.__EXTRACTED_TX=void 0,this}addOutputs(t){return t.forEach((t=>this.addOutput(t))),this}addOutput(t){if(arguments.length>1||!t||void 0===t.value||void 0===t.address&&void 0===t.script)throw new Error("Invalid arguments for Psbt.addOutput. Requires single object with at least [script or address] and [value]");k(this.data.inputs,"addOutput");const{address:e}=t;if("string"==typeof e){const{network:r}=this.opts,n=(0,a.toOutputScript)(e,r);t=Object.assign(t,{script:n})}(0,d.checkTaprootOutputFields)(t,t,"addOutput");const r=this.__CACHE;return this.data.addOutput(t),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__EXTRACTED_TX=void 0,this}extractTransaction(t){if(!this.data.inputs.every(A))throw new Error("Not finalized");const e=this.__CACHE;if(t||function(t,e,r){const n=e.__FEE_RATE||t.getFeeRate(),i=e.__EXTRACTED_TX.virtualSize(),o=n*i;if(n>=r.maximumFeeRate)throw new Error(`Warning: You are paying around ${(o/1e8).toFixed(8)} in fees, which is ${n} satoshi per byte for a transaction with a VSize of ${i} bytes (segwit counted as 0.25 byte per byte). Use setMaximumFeeRate method to raise your threshold, or pass true to the first arg of extractTransaction.`)}(this,e,this.opts),e.__EXTRACTED_TX)return e.__EXTRACTED_TX;const r=e.__TX.clone();return G(this.data.inputs,r,e,!0),r}getFeeRate(){return B("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE)}getFee(){return B("__FEE","fee",this.data.inputs,this.__CACHE)}finalizeAllInputs(){return(0,s.checkForInput)(this.data.inputs,0),X(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(r)?this._finalizeTaprootInput(t,r,void 0,e):this._finalizeInput(t,r,e)}finalizeTaprootInput(t,e,r=d.tapScriptFinalizer){const n=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(n))return this._finalizeTaprootInput(t,n,e,r);throw new Error(`Cannot finalize input #${t}. Not Taproot.`)}_finalizeInput(t,e,r=R){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:s}=function(t,e,r){const n=r.__TX,i={script:null,isSegwit:!1,isP2SH:!1,isP2WSH:!1};if(i.isP2SH=!!e.redeemScript,i.isP2WSH=!!e.witnessScript,e.witnessScript)i.script=e.witnessScript;else if(e.redeemScript)i.script=e.redeemScript;else if(e.nonWitnessUtxo){const o=V(r,e,t),s=n.ins[t].index;i.script=o.outs[s].script}else e.witnessUtxo&&(i.script=e.witnessUtxo.script);return(e.witnessScript||(0,y.isP2WPKH)(i.script))&&(i.isSegwit=!0),i}(t,e,this.__CACHE);if(!n)throw new Error(`No script found for input #${t}`);!function(t){if(!t.sighashType||!t.partialSig)return;const{partialSig:e,sighashType:r}=t;e.forEach((t=>{const{hashType:e}=h.signature.decode(t.signature);if(r!==e)throw new Error("Signature sighash does not match input sighash type")}))}(e);const{finalScriptSig:a,finalScriptWitness:u}=r(t,e,n,s,i,o);if(a&&this.data.updateInput(t,{finalScriptSig:a}),u&&this.data.updateInput(t,{finalScriptWitness:u}),!a&&!u)throw new Error(`Unknown error finalizing input #${t}`);return this.data.clearFinalizedInput(t),this}_finalizeTaprootInput(t,e,r,n=d.tapScriptFinalizer){if(!e.witnessUtxo)throw new Error(`Cannot finalize input #${t}. Missing withness utxo.`);if(e.tapKeySig){const r=l.p2tr({output:e.witnessUtxo.script,signature:e.tapKeySig}),n=(0,y.witnessStackToScriptWitness)(r.witness);this.data.updateInput(t,{finalScriptWitness:n})}else{const{finalScriptWitness:i}=n(t,e,r);this.data.updateInput(t,{finalScriptWitness:i})}return this.data.clearFinalizedInput(t),this}getInputType(t){const e=(0,s.checkForInput)(this.data.inputs,t),r=q(K(t,e,this.__CACHE),t,"input",e.redeemScript||function(t){if(!t)return;const e=h.decompile(t);if(!e)return;const r=e[e.length-1];var i;if(n.isBuffer(r)&&!z(r)&&(i=r,!h.isCanonicalScriptSignature(i))&&h.decompile(r))return r}(e.finalScriptSig),e.witnessScript||function(t){if(!t)return;const e=H(t),r=e[e.length-1];return!z(r)&&h.decompile(r)?r:void 0}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+J(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=K(r,e,n),{meaningfulScript:o}=q(i,r,"input",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,s.checkForInput)(this.data.inputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}outputHasPubkey(t,e){return function(t,e,r,n){const i=n.__TX.outs[r].script,{meaningfulScript:o}=q(i,r,"output",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,s.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,s.checkForOutput)(this.data.outputs,t),n=S(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){return(0,s.checkForInput)(this.data.inputs,0),X(this.data.inputs.length).map((e=>this.validateSignaturesOfInput(e,t))).reduce(((t,e)=>!0===e&&t),!0)}validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t];return(0,d.isTaprootInput)(n)?this.validateSignaturesOfTaprootInput(t,e,r):this._validateSignaturesOfInput(t,e,r)}_validateSignaturesOfInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).partialSig;if(!n||!i||i.length<1)throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const o=r?i.filter((t=>t.pubkey.equals(r))):i;if(o.length<1)throw new Error("No signatures for this pubkey");const s=[];let a,u,c;for(const r of o){const i=h.signature.decode(r.signature),{hash:o,script:l}=c!==i.hashType?U(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:a,script:u};c=i.hashType,a=o,u=l,T(r.pubkey,l,"verify"),s.push(e(r.pubkey,o,i.signature))}return s.every((t=>!0===t))}validateSignaturesOfTaprootInput(t,e,r){const n=this.data.inputs[t],i=(n||{}).tapKeySig,o=(n||{}).tapScriptSig;if(!n&&!i&&(!o||o.length))throw new Error("No signatures to validate");if("function"!=typeof e)throw new Error("Need validator function to validate signatures");const s=(r=r&&(0,d.toXOnly)(r))?D(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=C(t,e,n);r&&i.push(r)}if(e.tapScriptSig){const t=e.tapScriptSig.map((t=>t.pubkey));i.push(...t)}return i.map((i=>D(t,e,r,i,n))).flat()}(t,n,this.data.inputs,this.__CACHE);if(!s.length)throw new Error("No signatures for this pubkey");const a=s.find((t=>!t.leafHash));let u=0;if(i&&a){if(!e(a.pubkey,a.hash,L(i)))return!1;u++}if(o)for(const t of o){const r=s.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,L(t.signature)))return!1;u++}}return u>0}signAllInputsHD(t,e=[p.Transaction.SIGHASH_ALL]){if(!t||!t.publicKey||!t.fingerprint)throw new Error("Need HDSigner to sign input");const r=[];for(const n of X(this.data.inputs.length))try{this.signInputHD(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsHDAsync(t,e=[p.Transaction.SIGHASH_ALL]){return new Promise(((r,n)=>{if(!t||!t.publicKey||!t.fingerprint)return n(new Error("Need HDSigner to sign input"));const i=[],o=[];for(const r of X(this.data.inputs.length))o.push(this.signInputHDAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInputHD(t,e,r=[p.Transaction.SIGHASH_ALL]){if(!e||!e.publicKey||!e.fingerprint)throw new Error("Need HDSigner to sign input");return F(t,this.data.inputs,e).forEach((e=>this.signInput(t,e,r))),this}signInputHDAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){return new Promise(((n,i)=>{if(!e||!e.publicKey||!e.fingerprint)return i(new Error("Need HDSigner to sign input"));const o=F(t,this.data.inputs,e).map((e=>this.signInputAsync(t,e,r)));return Promise.all(o).then((()=>{n()})).catch(i)}))}signAllInputs(t,e){if(!t||!t.publicKey)throw new Error("Need Signer to sign input");const r=[];for(const n of X(this.data.inputs.length))try{this.signInput(n,t,e),r.push(!0)}catch(t){r.push(!1)}if(r.every((t=>!1===t)))throw new Error("No inputs were signed");return this}signAllInputsAsync(t,e){return new Promise(((r,n)=>{if(!t||!t.publicKey)return n(new Error("Need Signer to sign input"));const i=[],o=[];for(const[r]of this.data.inputs.entries())o.push(this.signInputAsync(r,t,e).then((()=>{i.push(!0)}),(()=>{i.push(!1)})));return Promise.all(o).then((()=>{if(i.every((t=>!1===t)))return n(new Error("No inputs were signed"));r()}))}))}signInput(t,e,r){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInput(t,n,e,void 0,r):this._signInput(t,e,r)}signTaprootInput(t,e,r,n){if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInput(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=N(this.data.inputs,t,e.publicKey,this.__CACHE,r),o=[{pubkey:e.publicKey,signature:h.signature.encode(e.sign(n),i)}];return this.data.updateInput(t,{partialSig:o}),this}_signTaprootInput(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],a=o.filter((t=>!!t.leafHash)).map((t=>({pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType),leafHash:t.leafHash})));return s&&this.data.updateInput(t,{tapKeySig:s}),a.length&&this.data.updateInput(t,{tapScriptSig:a}),this}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,s.checkForInput)(this.data.inputs,t);return(0,d.isTaprootInput)(n)?this._signTaprootInputAsync(t,n,e,void 0,r):this._signInputAsync(t,e,r)}))}signTaprootInputAsync(t,e,r,n){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const i=(0,s.checkForInput)(this.data.inputs,t);if((0,d.isTaprootInput)(i))return this._signTaprootInputAsync(t,i,e,r,n);throw new Error(`Input #${t} is not of type Taproot.`)}))}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){const{hash:n,sighashType:i}=N(this.data.inputs,t,e.publicKey,this.__CACHE,r);return Promise.resolve(e.sign(n)).then((r=>{const n=[{pubkey:e.publicKey,signature:h.signature.encode(r,i)}];this.data.updateInput(t,{partialSig:n})}))}async _signTaprootInputAsync(t,e,r,n,i=[p.Transaction.SIGHASH_DEFAULT]){const o=this.checkTaprootHashesForSig(t,e,r,n,i),s=[],a=o.filter((t=>!t.leafHash))[0];if(a){const t=Promise.resolve(r.signSchnorr(a.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));s.push(t)}const u=o.filter((t=>!!t.leafHash));if(u.length){const t=u.map((t=>Promise.resolve(r.signSchnorr(t.hash)).then((n=>({tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]})))));s.push(...t)}return Promise.all(s).then((e=>{e.forEach((e=>this.data.updateInput(t,e)))}))}checkTaprootHashesForSig(t,e,r,n,i){if("function"!=typeof r.signSchnorr)throw new Error(`Need Schnorr Signer to sign taproot input #${t}.`);const o=D(t,e,this.data.inputs,r.publicKey,this.__CACHE,n,i);if(!o||!o.length)throw new Error(`Can not sign for input #${t} with the key ${r.publicKey.toString("hex")}`);return o}toBuffer(){return v(this.__CACHE),this.data.toBuffer()}toHex(){return v(this.__CACHE),this.data.toHex()}toBase64(){return v(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&Q(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&j(this.__CACHE,this.data.inputs[t],t),this}updateOutput(t,e){const r=this.data.outputs[t];return(0,d.checkTaprootOutputFields)(r,e,"updateOutput"),this.data.updateOutput(t,e),this}addUnknownKeyValToGlobal(t){return this.data.addUnknownKeyValToGlobal(t),this}addUnknownKeyValToInput(t,e){return this.data.addUnknownKeyValToInput(t,e),this}addUnknownKeyValToOutput(t,e){return this.data.addUnknownKeyValToOutput(t,e),this}clearFinalizedInput(t){return this.data.clearFinalizedInput(t),this}}e.Psbt=b;const w=t=>new m(t);class m{constructor(t=n.from([2,0,0,0,0,0,0,0,0,0])){this.tx=p.Transaction.fromBuffer(t),function(t){if(!t.ins.every((t=>t.script&&0===t.script.length&&t.witness&&0===t.witness.length)))throw new Error("Format Error: Transaction ScriptSigs are not empty")}(this.tx),Object.defineProperty(this,"tx",{enumerable:!1,writable:!0})}getInputOutputCounts(){return{inputCount:this.tx.ins.length,outputCount:this.tx.outs.length}}addInput(t){if(void 0===t.hash||void 0===t.index||!n.isBuffer(t.hash)&&"string"!=typeof t.hash||"number"!=typeof t.index)throw new Error("Error adding input.");const e="string"==typeof t.hash?(0,u.reverseBuffer)(n.from(t.hash,"hex")):t.hash;this.tx.addInput(e,t.index,t.sequence)}addOutput(t){if(void 0===t.script||void 0===t.value||!n.isBuffer(t.script)||"number"!=typeof t.value)throw new Error("Error adding output.");this.tx.addOutput(t.script,t.value)}toBuffer(){return this.tx.toBuffer()}}function v(t){if(!1!==t.__UNSAFE_SIGN_NONSEGWIT)throw new Error("Not BIP174 compliant, can not export")}function E(t,e,r){if(!e)return!1;let n;if(n=r?r.map((t=>{const r=function(t){if(65===t.length){const e=1&t[64],r=t.slice(0,33);return r[0]=2|e,r}return t.slice()}(t);return e.find((t=>t.pubkey.equals(r)))})).filter((t=>!!t)):e,n.length>t)throw new Error("Too many signatures");return n.length===t}function A(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function S(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function _(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function k(t,e){t.forEach((t=>{if((0,d.isTaprootInput)(t)?(0,d.checkTaprootInputForSigs)(t,e):(0,y.checkInputForSig)(t,e))throw new Error("Can not modify transaction, signatures exist.")}))}function T(t,e,r){if(!(0,y.pubkeyInScript)(t,e))throw new Error(`Can not ${r} for this input with the key ${t.toString("hex")}`)}function P(t,e){const r=(0,u.reverseBuffer)(n.from(e.hash)).toString("hex")+":"+e.index;if(t.__TX_IN_CACHE[r])throw new Error("Duplicate input detected.");t.__TX_IN_CACHE[r]=1}function I(t,e){return(r,n,i,o)=>{const s=t({redeem:{output:i}}).output;if(!n.equals(s))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const O=I(l.p2sh,"Redeem script"),x=I(l.p2wsh,"Witness script");function B(t,e,r,n){if(!r.every(A))throw new Error(`PSBT must be finalized to calculate ${e}`);if("__FEE_RATE"===t&&n.__FEE_RATE)return n.__FEE_RATE;if("__FEE"===t&&n.__FEE)return n.__FEE;let i,o=!0;return n.__EXTRACTED_TX?(i=n.__EXTRACTED_TX,o=!1):i=n.__TX.clone(),G(r,i,n,o),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function R(t,e,r,n,i,o){const s=J(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return E(1,t.partialSig);case"multisig":const r=l.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,s))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let s,a;const u=function(t,e,r){let n;switch(e){case"multisig":const e=function(t,e){return l.p2ms({output:t}).pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=l.p2ms({output:t,signatures:e});break;case"pubkey":n=l.p2pk({output:t,signature:r[0].signature});break;case"pubkeyhash":n=l.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=l.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?l.p2wsh({redeem:u}):null,f=i?l.p2sh({redeem:c||u}):null;return n?(a=c?(0,y.witnessStackToScriptWitness)(c.witness):(0,y.witnessStackToScriptWitness)(u.witness),f&&(s=f.input)):s=f?f.input:u.input,{finalScriptSig:s,finalScriptWitness:a}}(r,s,e.partialSig,n,i,o)}function N(t,e,r,n,i){const o=(0,s.checkForInput)(t,e),{hash:a,sighashType:u,script:c}=U(e,o,n,!1,i);return T(r,c,"sign"),{hash:a,sighashType:u}}function U(t,e,r,n,i){const o=r.__TX,s=e.sighashType||p.Transaction.SIGHASH_ALL;let a,u;if(M(s,i),e.nonWitnessUtxo){const n=V(r,e,t),i=o.ins[t].hash,s=n.getHash();if(!i.equals(s))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const a=o.ins[t].index;u=n.outs[a]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=e.witnessUtxo}const{meaningfulScript:c,type:f}=q(u.script,t,"input",e.redeemScript,e.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(f)>=0)a=o.hashForWitnessV0(t,c,u.value,s);else if((0,y.isP2WPKH)(c)){const e=l.p2pkh({hash:c.slice(2)}).output;a=o.hashForWitnessV0(t,e,u.value,s)}else{if(void 0===e.nonWitnessUtxo&&!1===r.__UNSAFE_SIGN_NONSEGWIT)throw new Error(`Input #${t} has witnessUtxo but non-segwit script: ${c.toString("hex")}`);n||!1===r.__UNSAFE_SIGN_NONSEGWIT||console.warn("Warning: Signing non-segwit inputs without the full parent transaction means there is a chance that a miner could feed you incorrect information to trick you into paying large fees. This behavior is the same as Psbt's predecesor (TransactionBuilder - now removed) when signing non-segwit scripts. You are not able to export this Psbt with toBuffer|toBase64|toHex since it is not BIP174 compliant.\n*********************\nPROCEED WITH CAUTION!\n*********************"),a=o.hashForSignature(t,c,s)}return{script:c,sighashType:s,hash:a}}function C(t,e,r){const{script:n}=W(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function L(t){return 64===t.length?t:t.subarray(0,64)}function D(t,e,r,i,o,s,a){const u=o.__TX,c=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(c,a);const l=r.map(((t,e)=>W(e,t,o))),h=l.map((t=>t.script)),g=l.map((t=>t.value)),b=[];if(e.tapInternalKey&&!s){const r=C(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=u.hashForWitnessV1(t,h,g,c);b.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,f.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!s||s.equals(t.hash))).map((e=>{const r=u.hashForWitnessV1(t,h,g,p.Transaction.SIGHASH_DEFAULT,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return b.concat(w)}function M(t,e){if(e&&e.indexOf(t)<0){const e=function(t){let e=t&p.Transaction.SIGHASH_ANYONECANPAY?"SIGHASH_ANYONECANPAY | ":"";switch(31&t){case p.Transaction.SIGHASH_ALL:e+="SIGHASH_ALL";break;case p.Transaction.SIGHASH_SINGLE:e+="SIGHASH_SINGLE";break;case p.Transaction.SIGHASH_NONE:e+="SIGHASH_NONE"}return e}(t);throw new Error(`Sighash type is not allowed. Retry the sign method passing the sighashTypes array of whitelisted types. Sighash type: ${e}`)}}function F(t,e,r){const n=(0,s.checkForInput)(e,t);if(!n.bip32Derivation||0===n.bip32Derivation.length)throw new Error("Need bip32Derivation to sign with HD");const i=n.bip32Derivation.map((t=>t.masterFingerprint.equals(r.fingerprint)?t:void 0)).filter((t=>!!t));if(0===i.length)throw new Error("Need one bip32Derivation masterFingerprint to match the HDSigner fingerprint");return i.map((t=>{const e=r.derivePath(t.path);if(!t.pubkey.equals(e.publicKey))throw new Error("pubkey did not match bip32Derivation");return e}))}function H(t){let e=0;function r(){const r=o.decode(t,e);return e+=o.decode.bytes,r}return function(){const n=r(),i=[];for(let s=0;s<n;s++)i.push((o=void 0,o=r(),e+=o,t.slice(e-o,e)));var o;return i}()}function j(t,e,r){t.__NON_WITNESS_UTXO_BUF_CACHE[r]=e.nonWitnessUtxo;const n=p.Transaction.fromBuffer(e.nonWitnessUtxo);t.__NON_WITNESS_UTXO_TX_CACHE[r]=n;const i=t,o=r;delete e.nonWitnessUtxo,Object.defineProperty(e,"nonWitnessUtxo",{enumerable:!0,get(){const t=i.__NON_WITNESS_UTXO_BUF_CACHE[o],e=i.__NON_WITNESS_UTXO_TX_CACHE[o];if(void 0!==t)return t;{const t=e.toBuffer();return i.__NON_WITNESS_UTXO_BUF_CACHE[o]=t,t}},set(t){i.__NON_WITNESS_UTXO_BUF_CACHE[o]=t}})}function G(t,e,r,n){let i=0;t.forEach(((t,o)=>{if(n&&t.finalScriptSig&&(e.ins[o].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[o].witness=H(t.finalScriptWitness)),t.witnessUtxo)i+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=V(r,t,o),s=e.ins[o].index,a=n.outs[s];i+=a.value}}));const o=e.outs.reduce(((t,e)=>t+e.value),0),s=i-o;if(s<0)throw new Error("Outputs are spending more than Inputs");const a=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/a)}function V(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||j(t,e,r),n[r]}function K(t,e,r){const{script:n}=W(t,e,r);return n}function W(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=V(r,e,t).outs[r.__TX.ins[t].index];return{script:n.script,value:n.value}}throw new Error("Can't find pubkey in input without Utxo data")}function z(t){return 33===t.length&&h.isCanonicalPubKey(t)}function q(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),s=o&&n&&(0,y.isP2WSHScript)(n),a=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((a||s)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return s?(u=i,O(e,t,n,r),x(e,n,i,r),Q(u)):a?(u=i,x(e,t,i,r),Q(u)):o?(u=n,O(e,t,n,r)):u=t,{meaningfulScript:u,type:s?"p2sh-p2wsh":o?"p2sh":a?"p2wsh":"raw"}}function Q(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function J(t){return(0,y.isP2WPKH)(t)?"witnesspubkeyhash":(0,y.isP2PKH)(t)?"pubkeyhash":(0,y.isP2MS)(t)?"multisig":(0,y.isP2PK)(t)?"pubkey":"nonstandard"}function X(t){return[...Array(t).keys()]}},477:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.checkTaprootInputForSigs=e.tapTreeFromList=e.tapTreeToList=e.tweakInternalPubKey=e.checkTaprootOutputFields=e.checkTaprootInputFields=e.isTaprootOutput=e.isTaprootInput=e.serializeTaprootSignature=e.tapScriptFinalizer=e.toXOnly=void 0;const i=r(8116),o=r(2021),s=r(4929),a=r(2218),u=r(885),c=r(4929);function l(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,s.isP2TR)(t.witnessUtxo.script))}function f(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,s.isP2TR)(e))}function h(t=[]){return 1===t.length&&0===t[0].depth?{output:t[0].script,version:t[0].leafVersion}:function(t){let e;for(const r of t)if(e=y(r,e),!e)throw new Error("No room left to insert tapleaf in tree");return e}(t)}function p(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function d(t,e=[],r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||a.LEAF_VERSION_TAPSCRIPT,script:t.output}),e):(t[0]&&d(t[0],e,r+1),t[1]&&d(t[1],e,r+1),e):[]}function y(t,e,r=0){if(r>a.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");if(t.depth===r)return e?void 0:{output:t.script,version:t.leafVersion};if((0,i.isTapleaf)(e))return;const n=y(t,e&&e[0],r+1);if(n)return[n,e&&e[1]];const o=y(t,e&&e[1],r+1);return o?[e&&e[0],o]:void 0}function g(t,e){if(!e)return!0;const r=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(0,a.rootHashFromPath)(t.controlBlock,r).equals(e)}function b(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33),e.tapScriptFinalizer=function(t,e,r){const n=function(t,e,r){if(!t.tapScriptSig||!t.tapScriptSig.length)throw new Error(`Can not finalize taproot input #${e}. No tapleaf script signature provided.`);const n=(t.tapLeafScript||[]).sort(((t,e)=>t.controlBlock.length-e.controlBlock.length)).find((e=>function(t,e,r){const n=(0,a.tapleafHash)({output:t.script,version:t.leafVersion});return(!r||r.equals(n))&&void 0!==e.find((t=>t.leafHash.equals(n)))}(e,t.tapScriptSig,r)));if(!n)throw new Error(`Can not finalize taproot input #${e}. Signature for tapleaf script not found.`);return n}(e,t,r);try{const t=function(t,e){const r=(0,a.tapleafHash)({output:e.script,version:e.leafVersion});return(t.tapScriptSig||[]).filter((t=>t.leafHash.equals(r))).map((t=>function(t,e){return Object.assign({positionInScript:(0,s.pubkeyPositionInScript)(e.pubkey,t)},e)}(e.script,t))).sort(((t,e)=>e.positionInScript-t.positionInScript)).map((t=>t.signature))}(e,n),r=t.concat(n.script).concat(n.controlBlock);return{finalScriptWitness:(0,s.witnessStackToScriptWitness)(r)}}catch(e){throw new Error(`Can not finalize taproot input #${t}: ${e}`)}},e.serializeTaprootSignature=function(t,e){const r=e?n.from([e]):n.from([]);return n.concat([t,r])},e.isTaprootInput=l,e.isTaprootOutput=f,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=l(t)&&b(e),i=b(t)&&l(e),o=t===e&&l(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e,r){if(e.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>g(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot&&!(e.tapLeafScript||[]).every((e=>g(e,t.tapMerkleRoot))))throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}(t,e,r)},e.checkTaprootOutputFields=function(t,e,r){!function(t,e,r){const n=f(t)&&b(e),i=b(t)&&f(e),o=t===e&&f(e)&&b(e);if(n||i||o)throw new Error(`Invalid arguments for Psbt.${r}. Cannot use both taproot and non-taproot fields.`)}(t,e,r),function(t,e){if(!e.tapTree&&!e.tapInternalKey)return;const r=e.tapInternalKey||t.tapInternalKey,n=e.tapTree||t.tapTree;if(r){const{script:e}=t,i=function(t,e){const r=e&&h(e.leaves),{output:n}=(0,u.p2tr)({internalPubkey:t,scriptTree:r});return n}(r,n);if(e&&!e.equals(i))throw new Error("Error adding output. Script or address missmatch.")}}(t,e)},e.tweakInternalPubKey=function(t,e){const r=e.tapInternalKey,n=r&&(0,a.tweakKey)(r,e.tapMerkleRoot);if(!n)throw new Error(`Cannot tweak tap internal key for input #${t}. Public key: ${r&&r.toString("hex")}`);return n.x},e.tapTreeToList=function(t){if(!(0,i.isTaptree)(t))throw new Error("Cannot convert taptree to tapleaf list. Expecting a tapree structure.");return d(t)},e.tapTreeFromList=h,e.checkTaprootInputForSigs=function(t,e){return function(t){const e=[];if(t.tapKeySig&&e.push(t.tapKeySig),t.tapScriptSig&&e.push(...t.tapScriptSig.map((t=>t.signature))),!e.length){const r=function(t){if(!t)return;const e=t.slice(2);return 64===e.length||65===e.length?e:void 0}(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,c.signatureBlocksAction)(t,p,e)))}},4929:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signatureBlocksAction=e.checkInputForSig=e.pubkeyInScript=e.pubkeyPositionInScript=e.witnessStackToScriptWitness=e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0;const i=r(394),o=r(7038),s=r(2021),a=r(1944),u=r(885);function c(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function l(t,e){const r=(0,a.hash160)(t),n=t.slice(1,33),i=o.decompile(e);if(null===i)throw new Error("Unknown script error");return i.findIndex((e=>"number"!=typeof e&&(e.equals(t)||e.equals(r)||e.equals(n))))}function f(t,e,r){const{hashType:n}=e(t),i=[];switch(n&s.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case s.Transaction.SIGHASH_ALL:break;case s.Transaction.SIGHASH_SINGLE:case s.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}e.isP2MS=c(u.p2ms),e.isP2PK=c(u.p2pk),e.isP2PKH=c(u.p2pkh),e.isP2WPKH=c(u.p2wpkh),e.isP2WSHScript=c(u.p2wsh),e.isP2SHScript=c(u.p2sh),e.isP2TR=c(u.p2tr),e.witnessStackToScriptWitness=function(t){let e=n.allocUnsafe(0);function r(t){const r=e.length,o=i.encodingLength(t);e=n.concat([e,n.allocUnsafe(o)]),i.encode(t,e,r)}var o;return r((o=t).length),o.forEach((function(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)})),e},e.pubkeyPositionInScript=l,e.pubkeyInScript=function(t,e){return-1!==l(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=function(t){const e=t.finalScriptSig&&o.decompile(t.finalScriptSig)||[],r=t.finalScriptWitness&&o.decompile(t.finalScriptWitness)||[];return e.concat(r).filter((t=>n.isBuffer(t)&&o.isCanonicalScriptSignature(t))).map((t=>({signature:t})))}(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>f(t,o.signature.decode,e)))},e.signatureBlocksAction=f},4344:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.decode=e.encode=e.encodingLength=void 0;const n=r(8417);function i(t){return t<n.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}e.encodingLength=i,e.encode=function(t,e,r){const o=i(e);return 1===o?t.writeUInt8(e,r):2===o?(t.writeUInt8(n.OPS.OP_PUSHDATA1,r),t.writeUInt8(e,r+1)):3===o?(t.writeUInt8(n.OPS.OP_PUSHDATA2,r),t.writeUInt16LE(e,r+1)):(t.writeUInt8(n.OPS.OP_PUSHDATA4,r),t.writeUInt32LE(e,r+1)),o},e.decode=function(t,e){const r=t.readUInt8(e);let i,o;if(r<n.OPS.OP_PUSHDATA1)i=r,o=1;else if(r===n.OPS.OP_PUSHDATA1){if(e+2>t.length)return null;i=t.readUInt8(e+1),o=2}else if(r===n.OPS.OP_PUSHDATA2){if(e+3>t.length)return null;i=t.readUInt16LE(e+1),o=3}else{if(e+5>t.length)return null;if(r!==n.OPS.OP_PUSHDATA4)throw new Error("Unexpected opcode");i=t.readUInt32LE(e+1),o=5}return{opcode:r,number:i,size:o}}},7038:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.isCanonicalScriptSignature=e.isDefinedHashType=e.isCanonicalPubKey=e.toStack=e.fromASM=e.toASM=e.decompile=e.compile=e.countNonPushOnlyOPs=e.isPushOnly=e.OPS=void 0;const i=r(3966),o=r(8417);Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return o.OPS}});const s=r(4344),a=r(9464),u=r(1043),c=r(8116),{typeforce:l}=c,f=o.OPS.OP_RESERVED;function h(t){return c.Buffer(t)||function(t){return c.Number(t)&&(t===o.OPS.OP_0||t>=o.OPS.OP_1&&t<=o.OPS.OP_16||t===o.OPS.OP_1NEGATE)}(t)}function p(t){return c.Array(t)&&t.every(h)}function d(t){return 0===t.length?o.OPS.OP_0:1===t.length?t[0]>=1&&t[0]<=16?f+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function g(t){return n.isBuffer(t)}function b(t){if(y(t))return t;l(c.Array,t);const e=t.reduce(((t,e)=>g(e)?1===e.length&&void 0!==d(e)?t+1:t+s.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(g(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=s.encode(r,t.length,i),t.copy(r,i),i+=t.length}else r.writeUInt8(t,i),i+=1})),i!==r.length)throw new Error("Could not decode chunks");return r}function w(t){if(e=t,c.Array(e))return t;var e;l(c.Buffer,t);const r=[];let n=0;for(;n<t.length;){const e=t[n];if(e>o.OPS.OP_0&&e<=o.OPS.OP_PUSHDATA4){const e=s.decode(t,n);if(null===e)return null;if(n+=e.size,n+e.number>t.length)return null;const i=t.slice(n,n+e.number);n+=e.number;const o=d(i);void 0!==o?r.push(o):r.push(i)}else r.push(e),n+=1}return r}function m(t){const e=-129&t;return e>0&&e<4}e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(h).length},e.compile=b,e.decompile=w,e.toASM=function(t){return y(t)&&(t=w(t)),t.map((t=>{if(g(t)){const e=d(t);if(void 0===e)return t.toString("hex");t=e}return o.REVERSE_OPS[t]})).join(" ")},e.fromASM=function(t){return l(c.String,t),b(t.split(" ").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(l(c.Hex,t),n.from(t,"hex")))))},e.toStack=function(t){return t=w(t),l(p,t),t.map((t=>g(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):a.encode(t-f)))},e.isCanonicalPubKey=function(t){return c.isPoint(t)},e.isDefinedHashType=m,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&!!m(t[t.length-1])&&i.check(t.slice(0,-1))},e.number=a,e.signature=u},9464:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0,e.decode=function(t,e,r){e=e||4,r=void 0===r||r;const n=t.length;if(0===n)return 0;if(n>e)throw new TypeError("Script number overflow");if(r&&!(127&t[n-1]||!(n<=1)&&128&t[n-2]))throw new Error("Non-minimally encoded script number");if(5===n){const e=t.readUInt32LE(0),r=t.readUInt8(4);return 128&r?-(4294967296*(-129&r)+e):4294967296*r+e}let i=0;for(let e=0;e<n;++e)i|=t[e]<<8*e;return 128&t[n-1]?-(i&~(128<<8*(n-1))):i},e.encode=function(t){let e=Math.abs(t);const r=(i=e)>2147483647?5:i>8388607?4:i>32767?3:i>127?2:i>0?1:0;var i;const o=n.allocUnsafe(r),s=t<0;for(let t=0;t<r;++t)o.writeUInt8(255&e,t),e>>=8;return 128&o[r-1]?o.writeUInt8(s?128:0,r-1):s&&(o[r-1]|=128),o}},1043:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.encode=e.decode=void 0;const i=r(3966),o=r(8116),{typeforce:s}=o,a=n.alloc(1,0);function u(t){let e=0;for(;0===t[e];)++e;return e===t.length?a:128&(t=t.slice(e))[0]?n.concat([a,t],1+t.length):t}function c(t){0===t[0]&&(t=t.slice(1));const e=n.alloc(32,0),r=Math.max(0,32-t.length);return t.copy(e,r),e}e.decode=function(t){const e=t.readUInt8(t.length-1),r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);const o=i.decode(t.slice(0,-1)),s=c(o.r),a=c(o.s);return{signature:n.concat([s,a],64),hashType:e}},e.encode=function(t,e){s({signature:o.BufferN(64),hashType:o.UInt8},{signature:t,hashType:e});const r=-129&e;if(r<=0||r>=4)throw new Error("Invalid hashType "+e);const a=n.allocUnsafe(1);a.writeUInt8(e,0);const c=u(t.slice(0,32)),l=u(t.slice(32,64));return n.concat([i.encode(c,l),a])}},2021:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.Transaction=void 0;const i=r(606),o=r(1944),s=r(7038),a=r(7038),u=r(8116),{typeforce:c}=u;function l(t){const e=t.length;return i.varuint.encodingLength(e)+e}const f=n.allocUnsafe(0),h=[],p=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),g={script:f,valueBuffer:y};class b{constructor(){this.version=1,this.locktime=0,this.ins=[],this.outs=[]}static fromBuffer(t,e){const r=new i.BufferReader(t),n=new b;n.version=r.readInt32();const o=r.readUInt8(),s=r.readUInt8();let a=!1;o===b.ADVANCED_TRANSACTION_MARKER&&s===b.ADVANCED_TRANSACTION_FLAG?a=!0:r.offset-=2;const u=r.readVarInt();for(let t=0;t<u;++t)n.ins.push({hash:r.readSlice(32),index:r.readUInt32(),script:r.readVarSlice(),sequence:r.readUInt32(),witness:h});const c=r.readVarInt();for(let t=0;t<c;++t)n.outs.push({value:r.readUInt64(),script:r.readVarSlice()});if(a){for(let t=0;t<u;++t)n.ins[t].witness=r.readVector();if(!n.hasWitnesses())throw new Error("Transaction has superfluous witness data")}if(n.locktime=r.readUInt32(),e)return n;if(r.offset!==t.length)throw new Error("Transaction has unexpected data");return n}static fromHex(t){return b.fromBuffer(n.from(t,"hex"),!1)}static isCoinbaseHash(t){c(u.Hash256bit,t);for(let e=0;e<32;++e)if(0!==t[e])return!1;return!0}isCoinbase(){return 1===this.ins.length&&b.isCoinbaseHash(this.ins[0].hash)}addInput(t,e,r,n){return c(u.tuple(u.Hash256bit,u.UInt32,u.maybe(u.UInt32),u.maybe(u.Buffer)),arguments),u.Null(r)&&(r=b.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:e,script:n||f,sequence:r,witness:h})-1}addOutput(t,e){return c(u.tuple(u.Buffer,u.Satoshi),arguments),this.outs.push({script:t,value:e})-1}hasWitnesses(){return this.ins.some((t=>0!==t.witness.length))}weight(){return 3*this.byteLength(!1)+this.byteLength(!0)}virtualSize(){return Math.ceil(this.weight()/4)}byteLength(t=!0){const e=t&&this.hasWitnesses();return(e?10:8)+i.varuint.encodingLength(this.ins.length)+i.varuint.encodingLength(this.outs.length)+this.ins.reduce(((t,e)=>t+40+l(e.script)),0)+this.outs.reduce(((t,e)=>t+8+l(e.script)),0)+(e?this.ins.reduce(((t,e)=>t+function(t){const e=t.length;return i.varuint.encodingLength(e)+t.reduce(((t,e)=>t+l(e)),0)}(e.witness)),0):0)}clone(){const t=new b;return t.version=this.version,t.locktime=this.locktime,t.ins=this.ins.map((t=>({hash:t.hash,index:t.index,script:t.script,sequence:t.sequence,witness:t.witness}))),t.outs=this.outs.map((t=>({script:t.script,value:t.value}))),t}hashForSignature(t,e,r){if(c(u.tuple(u.UInt32,u.Buffer,u.Number),arguments),t>=this.ins.length)return d;const i=s.compile(s.decompile(e).filter((t=>t!==a.OPS.OP_CODESEPARATOR))),l=this.clone();if((31&r)===b.SIGHASH_NONE)l.outs=[],l.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===b.SIGHASH_SINGLE){if(t>=this.outs.length)return d;l.outs.length=t+1;for(let e=0;e<t;e++)l.outs[e]=g;l.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}))}r&b.SIGHASH_ANYONECANPAY?(l.ins=[l.ins[t]],l.ins[0].script=i):(l.ins.forEach((t=>{t.script=f})),l.ins[t].script=i);const h=n.allocUnsafe(l.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),l.__toBuffer(h,0,!1),o.hash256(h)}hashForWitnessV1(t,e,r,s,a,h){if(c(u.tuple(u.UInt32,c.arrayOf(u.Buffer),c.arrayOf(u.Satoshi),u.UInt32),arguments),r.length!==this.ins.length||e.length!==this.ins.length)throw new Error("Must supply prevout script and value for all inputs");const p=s===b.SIGHASH_DEFAULT?b.SIGHASH_ALL:s&b.SIGHASH_OUTPUT_MASK,d=(s&b.SIGHASH_INPUT_MASK)===b.SIGHASH_ANYONECANPAY,y=p===b.SIGHASH_NONE,g=p===b.SIGHASH_SINGLE;let w=f,m=f,v=f,E=f,A=f;if(!d){let t=i.BufferWriter.withCapacity(36*this.ins.length);this.ins.forEach((e=>{t.writeSlice(e.hash),t.writeUInt32(e.index)})),w=o.sha256(t.end()),t=i.BufferWriter.withCapacity(8*this.ins.length),r.forEach((e=>t.writeUInt64(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(l).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),E=o.sha256(t.end())}if(y||g){if(g&&t<this.outs.length){const e=this.outs[t],r=i.BufferWriter.withCapacity(8+l(e.script));r.writeUInt64(e.value),r.writeVarSlice(e.script),A=o.sha256(r.end())}}else{const t=this.outs.map((t=>8+l(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),A=o.sha256(e.end())}const S=(a?2:0)+(h?1:0),_=174-(d?49:0)-(y?32:0)+(h?32:0)+(a?37:0),k=i.BufferWriter.withCapacity(_);if(k.writeUInt8(s),k.writeInt32(this.version),k.writeUInt32(this.locktime),k.writeSlice(w),k.writeSlice(m),k.writeSlice(v),k.writeSlice(E),y||g||k.writeSlice(A),k.writeUInt8(S),d){const n=this.ins[t];k.writeSlice(n.hash),k.writeUInt32(n.index),k.writeUInt64(r[t]),k.writeVarSlice(e[t]),k.writeUInt32(n.sequence)}else k.writeUInt32(t);if(h){const t=i.BufferWriter.withCapacity(l(h));t.writeVarSlice(h),k.writeSlice(o.sha256(t.end()))}return g&&k.writeSlice(A),a&&(k.writeSlice(a),k.writeUInt8(0),k.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),k.end()]))}hashForWitnessV0(t,e,r,s){c(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let a,f=n.from([]),h=p,d=p,y=p;if(s&b.SIGHASH_ANYONECANPAY||(f=n.allocUnsafe(36*this.ins.length),a=new i.BufferWriter(f,0),this.ins.forEach((t=>{a.writeSlice(t.hash),a.writeUInt32(t.index)})),d=o.hash256(f)),s&b.SIGHASH_ANYONECANPAY||(31&s)===b.SIGHASH_SINGLE||(31&s)===b.SIGHASH_NONE||(f=n.allocUnsafe(4*this.ins.length),a=new i.BufferWriter(f,0),this.ins.forEach((t=>{a.writeUInt32(t.sequence)})),y=o.hash256(f)),(31&s)!==b.SIGHASH_SINGLE&&(31&s)!==b.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+l(e.script)),0);f=n.allocUnsafe(t),a=new i.BufferWriter(f,0),this.outs.forEach((t=>{a.writeUInt64(t.value),a.writeVarSlice(t.script)})),h=o.hash256(f)}else if((31&s)===b.SIGHASH_SINGLE&&t<this.outs.length){const e=this.outs[t];f=n.allocUnsafe(8+l(e.script)),a=new i.BufferWriter(f,0),a.writeUInt64(e.value),a.writeVarSlice(e.script),h=o.hash256(f)}f=n.allocUnsafe(156+l(e)),a=new i.BufferWriter(f,0);const g=this.ins[t];return a.writeInt32(this.version),a.writeSlice(d),a.writeSlice(y),a.writeSlice(g.hash),a.writeUInt32(g.index),a.writeVarSlice(e),a.writeUInt64(r),a.writeUInt32(g.sequence),a.writeSlice(h),a.writeUInt32(this.locktime),a.writeUInt32(s),o.hash256(f)}getHash(t){return t&&this.isCoinbase()?n.alloc(32,0):o.hash256(this.__toBuffer(void 0,void 0,t))}getId(){return(0,i.reverseBuffer)(this.getHash(!1)).toString("hex")}toBuffer(t,e){return this.__toBuffer(t,e,!0)}toHex(){return this.toBuffer(void 0,void 0).toString("hex")}setInputScript(t,e){c(u.tuple(u.Number,u.Buffer),arguments),this.ins[t].script=e}setWitness(t,e){c(u.tuple(u.Number,[u.Buffer]),arguments),this.ins[t].witness=e}__toBuffer(t,e,r=!1){t||(t=n.allocUnsafe(this.byteLength(r)));const o=new i.BufferWriter(t,e||0);o.writeInt32(this.version);const s=r&&this.hasWitnesses();return s&&(o.writeUInt8(b.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(b.ADVANCED_TRANSACTION_FLAG)),o.writeVarInt(this.ins.length),this.ins.forEach((t=>{o.writeSlice(t.hash),o.writeUInt32(t.index),o.writeVarSlice(t.script),o.writeUInt32(t.sequence)})),o.writeVarInt(this.outs.length),this.outs.forEach((t=>{void 0!==t.value?o.writeUInt64(t.value):o.writeSlice(t.valueBuffer),o.writeVarSlice(t.script)})),s&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=b,b.DEFAULT_SEQUENCE=4294967295,b.SIGHASH_DEFAULT=0,b.SIGHASH_ALL=1,b.SIGHASH_NONE=2,b.SIGHASH_SINGLE=3,b.SIGHASH_ANYONECANPAY=128,b.SIGHASH_OUTPUT_MASK=3,b.SIGHASH_INPUT_MASK=128,b.ADVANCED_TRANSACTION_MARKER=0,b.ADVANCED_TRANSACTION_FLAG=1},8116:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.oneOf=e.Null=e.BufferN=e.Function=e.UInt32=e.UInt8=e.tuple=e.maybe=e.Hex=e.Buffer=e.String=e.Boolean=e.Array=e.Number=e.Hash256bit=e.Hash160bit=e.Buffer256bit=e.isTaptree=e.isTapleaf=e.TAPLEAF_VERSION_MASK=e.Network=e.ECPoint=e.Satoshi=e.Signer=e.BIP32Path=e.UInt31=e.isPoint=e.typeforce=void 0;const n=r(8287);e.typeforce=r(8676);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex");e.isPoint=function(t){if(!n.Buffer.isBuffer(t))return!1;if(t.length<33)return!1;const e=t[0],r=t.slice(1,33);if(0===r.compare(i))return!1;if(r.compare(o)>=0)return!1;if((2===e||3===e)&&33===t.length)return!0;const s=t.slice(33);return 0!==s.compare(i)&&!(s.compare(o)>=0)&&4===e&&65===t.length};const s=Math.pow(2,31)-1;function a(t){return e.typeforce.String(t)&&!!t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function u(t){return!(!t||!("output"in t)||!n.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&e.TAPLEAF_VERSION_MASK)!==t.version)}e.UInt31=function(t){return e.typeforce.UInt32(t)&&t<=s},e.BIP32Path=a,a.toJSON=()=>"BIP32 derivation path",e.Signer=function(t){return(e.typeforce.Buffer(t.publicKey)||"function"==typeof t.getPublicKey)&&"function"==typeof t.sign},e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.ECPoint=e.typeforce.quacksLike("Point"),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=u,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):u(r)},e.Buffer256bit=e.typeforce.BufferN(32),e.Hash160bit=e.typeforce.BufferN(20),e.Hash256bit=e.typeforce.BufferN(32),e.Number=e.typeforce.Number,e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.String=e.typeforce.String,e.Buffer=e.typeforce.Buffer,e.Hex=e.typeforce.Hex,e.maybe=e.typeforce.maybe,e.tuple=e.typeforce.tuple,e.UInt8=e.typeforce.UInt8,e.UInt32=e.typeforce.UInt32,e.Function=e.typeforce.Function,e.BufferN=e.typeforce.BufferN,e.Null=e.typeforce.Null,e.oneOf=e.typeforce.oneOf},6763:(t,e,r)=>{const n=r(5364);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},9204:(t,e,r)=>{var n=r(6763);t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=Uint8Array.from(e),i=t(r),o=r.length+4,s=new Uint8Array(o);return s.set(r,0),s.set(i.subarray(0,4),r.length),n.encode(s,o)},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},1889:(t,e,r)=>{var{sha256:n}=r(2623),i=r(9204);t.exports=i((function(t){return n(n(t))}))},8287:(t,e,r)=>{const n=r(7526),i=r(251),o="function"==typeof Symbol&&"function"==typeof Symbol.for?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=function(t){return+t!=t&&(t=0),u.alloc(+t)},e.INSPECT_MAX_BYTES=50;const s=2147483647;function a(t){if(t>s)throw new RangeError('The value "'+t+'" is invalid for option "size"');const e=new Uint8Array(t);return Object.setPrototypeOf(e,u.prototype),e}function u(t,e,r){if("number"==typeof t){if("string"==typeof e)throw new TypeError('The "string" argument must be of type string. Received type number');return f(t)}return c(t,e,r)}function c(t,e,r){if("string"==typeof t)return function(t,e){if("string"==typeof e&&""!==e||(e="utf8"),!u.isEncoding(e))throw new TypeError("Unknown encoding: "+e);const r=0|y(t,e);let n=a(r);const i=n.write(t,e);return i!==r&&(n=n.slice(0,i)),n}(t,e);if(ArrayBuffer.isView(t))return function(t){if(J(t,Uint8Array)){const e=new Uint8Array(t);return p(e.buffer,e.byteOffset,e.byteLength)}return h(t)}(t);if(null==t)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t);if(J(t,ArrayBuffer)||t&&J(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&(J(t,SharedArrayBuffer)||t&&J(t.buffer,SharedArrayBuffer)))return p(t,e,r);if("number"==typeof t)throw new TypeError('The "value" argument must not be of type number. Received type number');const n=t.valueOf&&t.valueOf();if(null!=n&&n!==t)return u.from(n,e,r);const i=function(t){if(u.isBuffer(t)){const e=0|d(t.length),r=a(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||X(t.length)?a(0):h(t):"Buffer"===t.type&&Array.isArray(t.data)?h(t.data):void 0}(t);if(i)return i;if("undefined"!=typeof Symbol&&null!=Symbol.toPrimitive&&"function"==typeof t[Symbol.toPrimitive])return u.from(t[Symbol.toPrimitive]("string"),e,r);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof t)}function l(t){if("number"!=typeof t)throw new TypeError('"size" argument must be of type number');if(t<0)throw new RangeError('The value "'+t+'" is invalid for option "size"')}function f(t){return l(t),a(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=a(e);for(let n=0;n<e;n+=1)r[n]=255&t[n];return r}function p(t,e,r){if(e<0||t.byteLength<e)throw new RangeError('"offset" is outside of buffer bounds');if(t.byteLength<e+(r||0))throw new RangeError('"length" is outside of buffer bounds');let n;return n=void 0===e&&void 0===r?new Uint8Array(t):void 0===r?new Uint8Array(t,e):new Uint8Array(t,e,r),Object.setPrototypeOf(n,u.prototype),n}function d(t){if(t>=s)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+s.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||J(t,ArrayBuffer))return t.byteLength;if("string"!=typeof t)throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof t);const r=t.length,n=arguments.length>2&&!0===arguments[2];if(!n&&0===r)return 0;let i=!1;for(;;)switch(e){case"ascii":case"latin1":case"binary":return r;case"utf8":case"utf-8":return z(t).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*r;case"hex":return r>>>1;case"base64":return q(t).length;default:if(i)return n?-1:z(t).length;e=(""+e).toLowerCase(),i=!0}}function g(t,e,r){let n=!1;if((void 0===e||e<0)&&(e=0),e>this.length)return"";if((void 0===r||r>this.length)&&(r=this.length),r<=0)return"";if((r>>>=0)<=(e>>>=0))return"";for(t||(t="utf8");;)switch(t){case"hex":return x(this,e,r);case"utf8":case"utf-8":return T(this,e,r);case"ascii":return I(this,e,r);case"latin1":case"binary":return O(this,e,r);case"base64":return k(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return B(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function b(t,e,r){const n=t[e];t[e]=t[r],t[r]=n}function w(t,e,r,n,i){if(0===t.length)return-1;if("string"==typeof r?(n=r,r=0):r>2147483647?r=2147483647:r<-2147483648&&(r=-2147483648),X(r=+r)&&(r=i?0:t.length-1),r<0&&(r=t.length+r),r>=t.length){if(i)return-1;r=t.length-1}else if(r<0){if(!i)return-1;r=0}if("string"==typeof e&&(e=u.from(e,n)),u.isBuffer(e))return 0===e.length?-1:m(t,e,r,n,i);if("number"==typeof e)return e&=255,"function"==typeof Uint8Array.prototype.indexOf?i?Uint8Array.prototype.indexOf.call(t,e,r):Uint8Array.prototype.lastIndexOf.call(t,e,r):m(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function m(t,e,r,n,i){let o,s=1,a=t.length,u=e.length;if(void 0!==n&&("ucs2"===(n=String(n).toLowerCase())||"ucs-2"===n||"utf16le"===n||"utf-16le"===n)){if(t.length<2||e.length<2)return-1;s=2,a/=2,u/=2,r/=2}function c(t,e){return 1===s?t[e]:t.readUInt16BE(e*s)}if(i){let n=-1;for(o=r;o<a;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*s}else-1!==n&&(o-=o-n),n=-1}else for(r+u>a&&(r=a-u),o=r;o>=0;o--){let r=!0;for(let n=0;n<u;n++)if(c(t,o+n)!==c(e,n)){r=!1;break}if(r)return o}return-1}function v(t,e,r,n){r=Number(r)||0;const i=t.length-r;n?(n=Number(n))>i&&(n=i):n=i;const o=e.length;let s;for(n>o/2&&(n=o/2),s=0;s<n;++s){const n=parseInt(e.substr(2*s,2),16);if(X(n))return s;t[r+s]=n}return s}function E(t,e,r,n){return Q(z(e,t.length-r),t,r,n)}function A(t,e,r,n){return Q(function(t){const e=[];for(let r=0;r<t.length;++r)e.push(255&t.charCodeAt(r));return e}(e),t,r,n)}function S(t,e,r,n){return Q(q(e),t,r,n)}function _(t,e,r,n){return Q(function(t,e){let r,n,i;const o=[];for(let s=0;s<t.length&&!((e-=2)<0);++s)r=t.charCodeAt(s),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function k(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function T(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,s=e>239?4:e>223?3:e>191?2:1;if(i+s<=r){let r,n,a,u;switch(s){case 1:e<128&&(o=e);break;case 2:r=t[i+1],128==(192&r)&&(u=(31&e)<<6|63&r,u>127&&(o=u));break;case 3:r=t[i+1],n=t[i+2],128==(192&r)&&128==(192&n)&&(u=(15&e)<<12|(63&r)<<6|63&n,u>2047&&(u<55296||u>57343)&&(o=u));break;case 4:r=t[i+1],n=t[i+2],a=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&a)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&a,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,s=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=s}return function(t){const e=t.length;if(e<=P)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=P));return r}(n)}e.kMaxLength=s,u.TYPED_ARRAY_SUPPORT=function(){try{const t=new Uint8Array(1),e={foo:function(){return 42}};return Object.setPrototypeOf(e,Uint8Array.prototype),Object.setPrototypeOf(t,e),42===t.foo()}catch(t){return!1}}(),u.TYPED_ARRAY_SUPPORT||"undefined"==typeof console||"function"!=typeof console.error||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."),Object.defineProperty(u.prototype,"parent",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.buffer}}),Object.defineProperty(u.prototype,"offset",{enumerable:!0,get:function(){if(u.isBuffer(this))return this.byteOffset}}),u.poolSize=8192,u.from=function(t,e,r){return c(t,e,r)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array),u.alloc=function(t,e,r){return function(t,e,r){return l(t),t<=0?a(t):void 0!==e?"string"==typeof r?a(t).fill(e,r):a(t).fill(e):a(t)}(t,e,r)},u.allocUnsafe=function(t){return f(t)},u.allocUnsafeSlow=function(t){return f(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),J(e,Uint8Array)&&(e=u.from(e,e.offset,e.byteLength)),!u.isBuffer(t)||!u.isBuffer(e))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(t===e)return 0;let r=t.length,n=e.length;for(let i=0,o=Math.min(r,n);i<o;++i)if(t[i]!==e[i]){r=t[i],n=e[i];break}return r<n?-1:n<r?1:0},u.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}},u.concat=function(t,e){if(!Array.isArray(t))throw new TypeError('"list" argument must be an Array of Buffers');if(0===t.length)return u.alloc(0);let r;if(void 0===e)for(e=0,r=0;r<t.length;++r)e+=t[r].length;const n=u.allocUnsafe(e);let i=0;for(r=0;r<t.length;++r){let e=t[r];if(J(e,Uint8Array))i+e.length>n.length?(u.isBuffer(e)||(e=u.from(e)),e.copy(n,i)):Uint8Array.prototype.set.call(n,e,i);else{if(!u.isBuffer(e))throw new TypeError('"list" argument must be an Array of Buffers');e.copy(n,i)}i+=e.length}return n},u.byteLength=y,u.prototype._isBuffer=!0,u.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 e=0;e<t;e+=2)b(this,e,e+1);return this},u.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 e=0;e<t;e+=4)b(this,e,e+3),b(this,e+1,e+2);return this},u.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 e=0;e<t;e+=8)b(this,e,e+7),b(this,e+1,e+6),b(this,e+2,e+5),b(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?T(this,0,t):g.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(t){if(!u.isBuffer(t))throw new TypeError("Argument must be a Buffer");return this===t||0===u.compare(this,t)},u.prototype.inspect=function(){let t="";const r=e.INSPECT_MAX_BYTES;return t=this.toString("hex",0,r).replace(/(.{2})/g,"$1 ").trim(),this.length>r&&(t+=" ... "),"<Buffer "+t+">"},o&&(u.prototype[o]=u.prototype.inspect),u.prototype.compare=function(t,e,r,n,i){if(J(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),!u.isBuffer(t))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof t);if(void 0===e&&(e=0),void 0===r&&(r=t?t.length:0),void 0===n&&(n=0),void 0===i&&(i=this.length),e<0||r>t.length||n<0||i>this.length)throw new RangeError("out of range index");if(n>=i&&e>=r)return 0;if(n>=i)return-1;if(e>=r)return 1;if(this===t)return 0;let o=(i>>>=0)-(n>>>=0),s=(r>>>=0)-(e>>>=0);const a=Math.min(o,s),c=this.slice(n,i),l=t.slice(e,r);for(let t=0;t<a;++t)if(c[t]!==l[t]){o=c[t],s=l[t];break}return o<s?-1:s<o?1:0},u.prototype.includes=function(t,e,r){return-1!==this.indexOf(t,e,r)},u.prototype.indexOf=function(t,e,r){return w(this,t,e,r,!0)},u.prototype.lastIndexOf=function(t,e,r){return w(this,t,e,r,!1)},u.prototype.write=function(t,e,r,n){if(void 0===e)n="utf8",r=this.length,e=0;else if(void 0===r&&"string"==typeof e)n=e,r=this.length,e=0;else{if(!isFinite(e))throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");e>>>=0,isFinite(r)?(r>>>=0,void 0===n&&(n="utf8")):(n=r,r=void 0)}const i=this.length-e;if((void 0===r||r>i)&&(r=i),t.length>0&&(r<0||e<0)||e>this.length)throw new RangeError("Attempt to write outside buffer bounds");n||(n="utf8");let o=!1;for(;;)switch(n){case"hex":return v(this,t,e,r);case"utf8":case"utf-8":return E(this,t,e,r);case"ascii":case"latin1":case"binary":return A(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return _(this,t,e,r);default:if(o)throw new TypeError("Unknown encoding: "+n);n=(""+n).toLowerCase(),o=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};const P=4096;function I(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(127&t[i]);return n}function O(t,e,r){let n="";r=Math.min(t.length,r);for(let i=e;i<r;++i)n+=String.fromCharCode(t[i]);return n}function x(t,e,r){const n=t.length;(!e||e<0)&&(e=0),(!r||r<0||r>n)&&(r=n);let i="";for(let n=e;n<r;++n)i+=Y[t[n]];return i}function B(t,e,r){const n=t.slice(e,r);let i="";for(let t=0;t<n.length-1;t+=2)i+=String.fromCharCode(n[t]+256*n[t+1]);return i}function R(t,e,r){if(t%1!=0||t<0)throw new RangeError("offset is not uint");if(t+e>r)throw new RangeError("Trying to access beyond buffer length")}function N(t,e,r,n,i,o){if(!u.isBuffer(t))throw new TypeError('"buffer" argument must be a Buffer instance');if(e>i||e<o)throw new RangeError('"value" argument is out of bounds');if(r+n>t.length)throw new RangeError("Index out of range")}function U(t,e,r,n,i){G(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o,o>>=8,t[r++]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,s>>=8,t[r++]=s,r}function C(t,e,r,n,i){G(e,n,i,t,r,7);let o=Number(e&BigInt(4294967295));t[r+7]=o,o>>=8,t[r+6]=o,o>>=8,t[r+5]=o,o>>=8,t[r+4]=o;let s=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=s,s>>=8,t[r+2]=s,s>>=8,t[r+1]=s,s>>=8,t[r]=s,r+8}function L(t,e,r,n,i,o){if(r+n>t.length)throw new RangeError("Index out of range");if(r<0)throw new RangeError("Index out of range")}function D(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function M(t,e,r,n,o){return e=+e,r>>>=0,o||L(t,0,r,8),i.write(t,e,r,n,52,8),r+8}u.prototype.slice=function(t,e){const r=this.length;(t=~~t)<0?(t+=r)<0&&(t=0):t>r&&(t=r),(e=void 0===e?r:~~e)<0?(e+=r)<0&&(e=0):e>r&&(e=r),e<t&&(e=t);const n=this.subarray(t,e);return Object.setPrototypeOf(n,u.prototype),n},u.prototype.readUintLE=u.prototype.readUIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return n},u.prototype.readUintBE=u.prototype.readUIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t+--e],i=1;for(;e>0&&(i*=256);)n+=this[t+--e]*i;return n},u.prototype.readUint8=u.prototype.readUInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||R(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),(this[t]|this[t+1]<<8|this[t+2]<<16)+16777216*this[t+3]},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e+256*this[++t]+65536*this[++t]+this[++t]*2**24,i=this[++t]+256*this[++t]+65536*this[++t]+r*2**24;return BigInt(n)+(BigInt(i)<<BigInt(32))})),u.prototype.readBigUInt64BE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=e*2**24+65536*this[++t]+256*this[++t]+this[++t],i=this[++t]*2**24+65536*this[++t]+256*this[++t]+r;return(BigInt(n)<<BigInt(32))+BigInt(i)})),u.prototype.readIntLE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=this[t],i=1,o=0;for(;++o<e&&(i*=256);)n+=this[t+o]*i;return i*=128,n>=i&&(n-=Math.pow(2,8*e)),n},u.prototype.readIntBE=function(t,e,r){t>>>=0,e>>>=0,r||R(t,e,this.length);let n=e,i=1,o=this[t+--n];for(;n>0&&(i*=256);)o+=this[t+--n]*i;return i*=128,o>=i&&(o-=Math.pow(2,8*e)),o},u.prototype.readInt8=function(t,e){return t>>>=0,e||R(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t]|this[t+1]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt16BE=function(t,e){t>>>=0,e||R(t,2,this.length);const r=this[t+1]|this[t]<<8;return 32768&r?4294901760|r:r},u.prototype.readInt32LE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]|this[t+1]<<8|this[t+2]<<16|this[t+3]<<24},u.prototype.readInt32BE=function(t,e){return t>>>=0,e||R(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=this[t+4]+256*this[t+5]+65536*this[t+6]+(r<<24);return(BigInt(n)<<BigInt(32))+BigInt(e+256*this[++t]+65536*this[++t]+this[++t]*2**24)})),u.prototype.readBigInt64BE=Z((function(t){V(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||K(t,this.length-8);const n=(e<<24)+65536*this[++t]+256*this[++t]+this[++t];return(BigInt(n)<<BigInt(32))+BigInt(this[++t]*2**24+65536*this[++t]+256*this[++t]+r)})),u.prototype.readFloatLE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||R(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||R(t,8,this.length),i.read(this,t,!1,52,8)},u.prototype.writeUintLE=u.prototype.writeUIntLE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);let i=1,o=0;for(this[e]=255&t;++o<r&&(i*=256);)this[e+o]=t/i&255;return e+r},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(t,e,r,n){t=+t,e>>>=0,r>>>=0,n||N(this,t,e,r,Math.pow(2,8*r)-1,0);let i=r-1,o=1;for(this[e+i]=255&t;--i>=0&&(o*=256);)this[e+i]=t/o&255;return e+r},u.prototype.writeUint8=u.prototype.writeUInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,255,0),this[e]=255&t,e+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,65535,0),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e+3]=t>>>24,this[e+2]=t>>>16,this[e+1]=t>>>8,this[e]=255&t,e+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,4294967295,0),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigUInt64LE=Z((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=Z((function(t,e=0){return C(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeIntLE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}let i=0,o=1,s=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===s&&0!==this[e+i-1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+r},u.prototype.writeIntBE=function(t,e,r,n){if(t=+t,e>>>=0,!n){const n=Math.pow(2,8*r-1);N(this,t,e,r,n-1,-n)}let i=r-1,o=1,s=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===s&&0!==this[e+i+1]&&(s=1),this[e+i]=(t/o|0)-s&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,1,127,-128),t<0&&(t=255+t+1),this[e]=255&t,e+1},u.prototype.writeInt16LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=255&t,this[e+1]=t>>>8,e+2},u.prototype.writeInt16BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,2,32767,-32768),this[e]=t>>>8,this[e+1]=255&t,e+2},u.prototype.writeInt32LE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),this[e]=255&t,this[e+1]=t>>>8,this[e+2]=t>>>16,this[e+3]=t>>>24,e+4},u.prototype.writeInt32BE=function(t,e,r){return t=+t,e>>>=0,r||N(this,t,e,4,2147483647,-2147483648),t<0&&(t=4294967295+t+1),this[e]=t>>>24,this[e+1]=t>>>16,this[e+2]=t>>>8,this[e+3]=255&t,e+4},u.prototype.writeBigInt64LE=Z((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=Z((function(t,e=0){return C(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return D(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return D(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return M(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return M(this,t,e,!1,r)},u.prototype.copy=function(t,e,r,n){if(!u.isBuffer(t))throw new TypeError("argument should be a Buffer");if(r||(r=0),n||0===n||(n=this.length),e>=t.length&&(e=t.length),e||(e=0),n>0&&n<r&&(n=r),n===r)return 0;if(0===t.length||0===this.length)return 0;if(e<0)throw new RangeError("targetStart out of bounds");if(r<0||r>=this.length)throw new RangeError("Index out of range");if(n<0)throw new RangeError("sourceEnd out of bounds");n>this.length&&(n=this.length),t.length-e<n-r&&(n=t.length-e+r);const i=n-r;return this===t&&"function"==typeof Uint8Array.prototype.copyWithin?this.copyWithin(e,r,n):Uint8Array.prototype.set.call(t,this.subarray(r,n),e),i},u.prototype.fill=function(t,e,r,n){if("string"==typeof t){if("string"==typeof e?(n=e,e=0,r=this.length):"string"==typeof r&&(n=r,r=this.length),void 0!==n&&"string"!=typeof n)throw new TypeError("encoding must be a string");if("string"==typeof n&&!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);if(1===t.length){const e=t.charCodeAt(0);("utf8"===n&&e<128||"latin1"===n)&&(t=e)}}else"number"==typeof t?t&=255:"boolean"==typeof t&&(t=Number(t));if(e<0||this.length<e||this.length<r)throw new RangeError("Out of range index");if(r<=e)return this;let i;if(e>>>=0,r=void 0===r?this.length:r>>>0,t||(t=0),"number"==typeof t)for(i=e;i<r;++i)this[i]=t;else{const o=u.isBuffer(t)?t:u.from(t,n),s=o.length;if(0===s)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%s]}return this};const F={};function H(t,e,r){F[t]=class extends r{constructor(){super(),Object.defineProperty(this,"message",{value:e.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${t}]`,this.stack,delete this.name}get code(){return t}set code(t){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:t,writable:!0})}toString(){return`${this.name} [${t}]: ${this.message}`}}}function j(t){let e="",r=t.length;const n="-"===t[0]?1:0;for(;r>=n+4;r-=3)e=`_${t.slice(r-3,r)}${e}`;return`${t.slice(0,r)}${e}`}function G(t,e,r,n,i,o){if(t>r||t<e){const n="bigint"==typeof e?"n":"";let i;throw i=o>3?0===e||e===BigInt(0)?`>= 0${n} and < 2${n} ** ${8*(o+1)}${n}`:`>= -(2${n} ** ${8*(o+1)-1}${n}) and < 2 ** ${8*(o+1)-1}${n}`:`>= ${e}${n} and <= ${r}${n}`,new F.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){V(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||K(e,t.length-(r+1))}(n,i,o)}function V(t,e){if("number"!=typeof t)throw new F.ERR_INVALID_ARG_TYPE(e,"number",t)}function K(t,e,r){if(Math.floor(t)!==t)throw V(t,r),new F.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new F.ERR_BUFFER_OUT_OF_BOUNDS;throw new F.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}H("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),H("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),H("ERR_OUT_OF_RANGE",(function(t,e,r){let n=`The value of "${t}" is out of range.`,i=r;return Number.isInteger(r)&&Math.abs(r)>2**32?i=j(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=j(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const W=/[^+/0-9A-Za-z-_]/g;function z(t,e){let r;e=e||1/0;const n=t.length;let i=null;const o=[];for(let s=0;s<n;++s){if(r=t.charCodeAt(s),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(s+1===n){(e-=3)>-1&&o.push(239,191,189);continue}i=r;continue}if(r<56320){(e-=3)>-1&&o.push(239,191,189),i=r;continue}r=65536+(i-55296<<10|r-56320)}else i&&(e-=3)>-1&&o.push(239,191,189);if(i=null,r<128){if((e-=1)<0)break;o.push(r)}else if(r<2048){if((e-=2)<0)break;o.push(r>>6|192,63&r|128)}else if(r<65536){if((e-=3)<0)break;o.push(r>>12|224,r>>6&63|128,63&r|128)}else{if(!(r<1114112))throw new Error("Invalid code point");if((e-=4)<0)break;o.push(r>>18|240,r>>12&63|128,r>>6&63|128,63&r|128)}}return o}function q(t){return n.toByteArray(function(t){if((t=(t=t.split("=")[0]).trim().replace(W,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function Q(t,e,r,n){let i;for(i=0;i<n&&!(i+r>=e.length||i>=t.length);++i)e[i+r]=t[i];return i}function J(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function X(t){return t!=t}const Y=function(){const t="0123456789abcdef",e=new Array(256);for(let r=0;r<16;++r){const n=16*r;for(let i=0;i<16;++i)e[n+i]=t[r]+t[i]}return e}();function Z(t){return"undefined"==typeof BigInt?$:t}function $(){throw new Error("BigInt not supported")}},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(3141).I;function s(t){i.call(this),this.hashMode="string"==typeof t,this.hashMode?this[t]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}r(6698)(s,i),s.prototype.update=function(t,e,r){"string"==typeof t&&(t=n.from(t,e));var i=this._update(t);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)},s.prototype.setAutoPadding=function(){},s.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},s.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},s.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},s.prototype._transform=function(t,e,r){var n;try{this.hashMode?this._update(t):this.push(this._update(t))}catch(t){n=t}finally{r(n)}},s.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},s.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},s.prototype._toString=function(t,e,r){if(this._decoder||(this._decoder=new o(e),this._encoding=e),this._encoding!==e)throw new Error("can't switch encodings");var n=this._decoder.write(t);return r&&(n+=this._decoder.end()),n},t.exports=s},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),s=r(2802),a=r(6168);function u(t){a.call(this,"digest"),this._hash=t}n(u,a),u.prototype._update=function(t){this._hash.update(t)},u.prototype._final=function(){return this._hash.digest()},t.exports=function(t){return"md5"===(t=t.toLowerCase())?new i:"rmd160"===t||"ripemd160"===t?new o:new u(s(t))}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},5170:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.ECPairFactory=e.networks=void 0;const i=r(5249);e.networks=i;const o=r(953),s=r(3209),a=r(7513),u=r(709),c=o.typeforce.maybe(o.typeforce.compile({compressed:o.maybe(o.Boolean),network:o.maybe(o.Network)}));e.ECPairFactory=function(t){function e(e,r){if(o.typeforce(o.Buffer256bit,e),!t.isPrivate(e))throw new TypeError("Private key not in range [1, n)");return o.typeforce(c,r),new l(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new l(void 0,e,r)}(0,u.testEcc)(t);class l{__D;__Q;compressed;network;lowR;constructor(e,r,o){this.__D=e,this.__Q=r,this.lowR=!1,void 0===o&&(o={}),this.compressed=void 0===o.compressed||o.compressed,this.network=o.network||i.bitcoin,void 0!==r&&(this.__Q=n.from(t.pointCompress(r,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const e=t.pointFromScalar(this.__D,this.compressed);this.__Q=n.from(e)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return a.encode(this.network.wif,this.__D,this.compressed)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}sign(e,r){if(!this.__D)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.__D));{let r=t.sign(e,this.__D);const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=t.sign(e,this.__D,i);return n.from(r)}}signSchnorr(e){if(!this.privateKey)throw new Error("Missing private key");if(!t.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return n.from(t.signSchnorr(e,this.privateKey))}verify(e,r){return t.verify(e,this.publicKey,r)}verifySchnorr(e,r){if(!t.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return t.verifySchnorr(e,this.publicKey.subarray(1,33),r)}tweakFromPublicKey(e){const i=32===(o=this.publicKey).length?o:o.slice(1,33);var o;const s=t.xOnlyPointAddTweak(i,e);if(!s||null===s.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=n.from([0===s.parity?2:3]);return r(n.concat([a,s.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(r){const i=3!==this.publicKey[0]&&(4!==this.publicKey[0]||1&~this.publicKey[64])?this.privateKey:t.privateNegate(this.privateKey),o=t.privateAdd(i,r);if(!o)throw new Error("Invalid tweaked private key!");return e(n.from(o),{network:this.network,compressed:this.compressed})}}return{isPoint:function(e){return t.isPoint(e)},fromPrivateKey:e,fromPublicKey:r,fromWIF:function(t,r){const n=a.decode(t),s=n.version;if(o.Array(r)){if(!(r=r.filter((t=>s===t.wif)).pop()))throw new Error("Unknown network version")}else if(r=r||i.bitcoin,s!==r.wif)throw new Error("Invalid network version");return e(n.privateKey,{compressed:n.compressed,network:r})},makeRandom:function(r){o.typeforce(c,r),void 0===r&&(r={});const n=r.rng||s;let i;do{i=n(32),o.typeforce(o.Buffer256bit,i)}while(!t.isPrivate(i));return e(i,r)}}}},8700:(t,e,r)=>{e.dg=void 0;var n=r(5170);Object.defineProperty(e,"dg",{enumerable:!0,get:function(){return n.ECPairFactory}})},5249:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.testnet=e.bitcoin=void 0,e.bitcoin={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},e.testnet={messagePrefix:"Bitcoin Signed Message:\n",bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239}},709:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.testEcc=void 0;const i=t=>n.from(t,"hex");function o(t){if(!t)throw new Error("ecc library invalid")}e.testEcc=function(t){o(t.isPoint(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(!t.isPoint(i("030000000000000000000000000000000000000000000000000000000000000005"))),o(t.isPrivate(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(!t.isPrivate(i("0000000000000000000000000000000000000000000000000000000000000000"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),o(!t.isPrivate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),o(n.from(t.privateAdd(i("0000000000000000000000000000000000000000000000000000000000000001"),i("0000000000000000000000000000000000000000000000000000000000000000"))).equals(i("0000000000000000000000000000000000000000000000000000000000000001"))),o(null===t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateAdd(i("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),i("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(i("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),o(n.from(t.privateNegate(i("0000000000000000000000000000000000000000000000000000000000000001"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),o(n.from(t.privateNegate(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(i("0000000000000000000000000000000000000000000000000000000000000003"))),o(n.from(t.privateNegate(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),o(n.from(t.pointCompress(i("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(i("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),o(n.from(t.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),o(null===t.xOnlyPointAddTweak(i("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140")));let e=t.xOnlyPointAddTweak(i("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),i("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));o(n.from(e.xOnlyPubkey).equals(i("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&1===e.parity),e=t.xOnlyPointAddTweak(i("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),i("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),o(n.from(e.xOnlyPubkey).equals(i("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&0===e.parity),o(n.from(t.sign(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),o(t.verify(i("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),t.signSchnorr&&o(n.from(t.signSchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),i("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),t.verifySchnorr&&o(t.verifySchnorr(i("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),i("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),i("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}},953:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=r(8676),e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe},7007:t=>{var e,r="object"==typeof Reflect?Reflect:null,n=r&&"function"==typeof r.apply?r.apply:function(t,e,r){return Function.prototype.apply.call(t,e,r)};e=r&&"function"==typeof r.ownKeys?r.ownKeys:Object.getOwnPropertySymbols?function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:function(t){return Object.getOwnPropertyNames(t)};var i=Number.isNaN||function(t){return t!=t};function o(){o.init.call(this)}t.exports=o,t.exports.once=function(t,e){return new Promise((function(r,n){function i(r){t.removeListener(e,o),n(r)}function o(){"function"==typeof t.removeListener&&t.removeListener("error",i),r([].slice.call(arguments))}y(t,e,o,{once:!0}),"error"!==e&&function(t,e,r){"function"==typeof t.on&&y(t,"error",e,{once:!0})}(t,i)}))},o.EventEmitter=o,o.prototype._events=void 0,o.prototype._eventsCount=0,o.prototype._maxListeners=void 0;var s=10;function a(t){if("function"!=typeof t)throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof t)}function u(t){return void 0===t._maxListeners?o.defaultMaxListeners:t._maxListeners}function c(t,e,r,n){var i,o,s,c;if(a(r),void 0===(o=t._events)?(o=t._events=Object.create(null),t._eventsCount=0):(void 0!==o.newListener&&(t.emit("newListener",e,r.listener?r.listener:r),o=t._events),s=o[e]),void 0===s)s=o[e]=r,++t._eventsCount;else if("function"==typeof s?s=o[e]=n?[r,s]:[s,r]:n?s.unshift(r):s.push(r),(i=u(t))>0&&s.length>i&&!s.warned){s.warned=!0;var l=new Error("Possible EventEmitter memory leak detected. "+s.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");l.name="MaxListenersExceededWarning",l.emitter=t,l.type=e,l.count=s.length,c=l,console&&console.warn&&console.warn(c)}return t}function l(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,0===arguments.length?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function f(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=l.bind(n);return i.listener=r,n.wrapFn=i,i}function h(t,e,r){var n=t._events;if(void 0===n)return[];var i=n[e];return void 0===i?[]:"function"==typeof i?r?[i.listener||i]:[i]:r?function(t){for(var e=new Array(t.length),r=0;r<e.length;++r)e[r]=t[r].listener||t[r];return e}(i):d(i,i.length)}function p(t){var e=this._events;if(void 0!==e){var r=e[t];if("function"==typeof r)return 1;if(void 0!==r)return r.length}return 0}function d(t,e){for(var r=new Array(e),n=0;n<e;++n)r[n]=t[n];return r}function y(t,e,r,n){if("function"==typeof t.on)n.once?t.once(e,r):t.on(e,r);else{if("function"!=typeof t.addEventListener)throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof t);t.addEventListener(e,(function i(o){n.once&&t.removeEventListener(e,i),r(o)}))}}Object.defineProperty(o,"defaultMaxListeners",{enumerable:!0,get:function(){return s},set:function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+t+".");s=t}}),o.init=function(){void 0!==this._events&&this._events!==Object.getPrototypeOf(this)._events||(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},o.prototype.setMaxListeners=function(t){if("number"!=typeof t||t<0||i(t))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+t+".");return this._maxListeners=t,this},o.prototype.getMaxListeners=function(){return u(this)},o.prototype.emit=function(t){for(var e=[],r=1;r<arguments.length;r++)e.push(arguments[r]);var i="error"===t,o=this._events;if(void 0!==o)i=i&&void 0===o.error;else if(!i)return!1;if(i){var s;if(e.length>0&&(s=e[0]),s instanceof Error)throw s;var a=new Error("Unhandled error."+(s?" ("+s.message+")":""));throw a.context=s,a}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,l=d(u,c);for(r=0;r<c;++r)n(l[r],this,e)}return!0},o.prototype.addListener=function(t,e){return c(this,t,e,!1)},o.prototype.on=o.prototype.addListener,o.prototype.prependListener=function(t,e){return c(this,t,e,!0)},o.prototype.once=function(t,e){return a(e),this.on(t,f(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return a(e),this.prependListener(t,f(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,s;if(a(e),void 0===(n=this._events))return this;if(void 0===(r=n[t]))return this;if(r===e||r.listener===e)0==--this._eventsCount?this._events=Object.create(null):(delete n[t],n.removeListener&&this.emit("removeListener",t,r.listener||e));else if("function"!=typeof r){for(i=-1,o=r.length-1;o>=0;o--)if(r[o]===e||r[o].listener===e){s=r[o].listener,i=o;break}if(i<0)return this;0===i?r.shift():function(t,e){for(;e+1<t.length;e++)t[e]=t[e+1];t.pop()}(r,i),1===r.length&&(n[t]=r[0]),void 0!==n.removeListener&&this.emit("removeListener",t,s||e)}return this},o.prototype.off=o.prototype.removeListener,o.prototype.removeAllListeners=function(t){var e,r,n;if(void 0===(r=this._events))return this;if(void 0===r.removeListener)return 0===arguments.length?(this._events=Object.create(null),this._eventsCount=0):void 0!==r[t]&&(0==--this._eventsCount?this._events=Object.create(null):delete r[t]),this;if(0===arguments.length){var i,o=Object.keys(r);for(n=0;n<o.length;++n)"removeListener"!==(i=o[n])&&this.removeAllListeners(i);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if("function"==typeof(e=r[t]))this.removeListener(t,e);else if(void 0!==e)for(n=e.length-1;n>=0;n--)this.removeListener(t,e[n]);return this},o.prototype.listeners=function(t){return h(this,t,!0)},o.prototype.rawListeners=function(t){return h(this,t,!1)},o.listenerCount=function(t,e){return"function"==typeof t.listenerCount?t.listenerCount(e):p.call(t,e)},o.prototype.listenerCount=p,o.prototype.eventNames=function(){return this._eventsCount>0?e(this._events):[]}},4729:(t,e,r)=>{var n=r(7417).Buffer,i=r(1603).Transform;function o(t){i.call(this),this._block=n.allocUnsafe(t),this._blockSize=t,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}r(6698)(o,i),o.prototype._transform=function(t,e,r){var n=null;try{this.update(t,e)}catch(t){n=t}r(n)},o.prototype._flush=function(t){var e=null;try{this.push(this.digest())}catch(t){e=t}t(e)},o.prototype.update=function(t,e){if(function(t,e){if(!n.isBuffer(t)&&"string"!=typeof t)throw new TypeError("Data must be a string or a buffer")}(t),this._finalized)throw new Error("Digest already called");n.isBuffer(t)||(t=n.from(t,e));for(var r=this._block,i=0;this._blockOffset+t.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=t[i++];this._update(),this._blockOffset=0}for(;i<t.length;)r[this._blockOffset++]=t[i++];for(var s=0,a=8*t.length;a>0;++s)this._length[s]+=a,(a=this._length[s]/4294967296|0)>0&&(this._length[s]-=4294967296*a);return this},o.prototype._update=function(){throw new Error("_update is not implemented")},o.prototype.digest=function(t){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var e=this._digest();void 0!==t&&(e=e.toString(t)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return e},o.prototype._digest=function(){throw new Error("_digest is not implemented")},t.exports=o},2260:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,s,a,u;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(a=t).length||-1===a.indexOf(".",u)?"argument":"property");s='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},2818:(t,e,r)=>{var n=r(3184),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=l;var o=r(6736),s=r(2192);r(6698)(l,o);for(var a=i(s.prototype),u=0;u<a.length;u++){var c=a[u];l.prototype[c]||(l.prototype[c]=s.prototype[c])}function l(t){if(!(this instanceof l))return new l(t);o.call(this,t),s.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",f)))}function f(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},5860:(t,e,r)=>{t.exports=i;var n=r(3054);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6736:(t,e,r)=>{var n,i=r(3184);t.exports=k,k.ReadableState=_,r(7007).EventEmitter;var o,s=function(t,e){return t.listeners(e).length},a=r(1181),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(2382);o=l&&l.debuglog?l.debuglog("stream"):function(){};var f,h,p,d=r(2389),y=r(1468),g=r(8775).getHighWaterMark,b=r(2260).F,w=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,E=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(k,a);var A=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function _(t,e,i){n=n||r(2818),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(3141).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function k(t){if(n=n||r(2818),!(this instanceof k))return new k(t);var e=this instanceof n;this._readableState=new _(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var s,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,a);else if(i||(s=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new w("chunk",["string","Buffer","Uint8Array"],e)),r}(a,e)),s)A(t,s);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)a.endEmitted?A(t,new E):P(t,a,e,!0);else if(a.ended)A(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(e=a.decoder.write(e),a.objectMode||0!==e.length?P(t,a,e,!1):R(t,a)):P(t,a,e,!1)}else n||(a.reading=!1,R(t,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function P(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),k.prototype.destroy=y.destroy,k.prototype._undestroy=y.undestroy,k.prototype._destroy=function(t,e){e(t)},k.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},k.prototype.unshift=function(t){return T(this,t,null,!0,!1)},k.prototype.isPaused=function(){return!1===this._readableState.flowing},k.prototype.setEncoding=function(t){f||(f=r(3141).I);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function O(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,D(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function U(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function C(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),D(t),e.flowing&&!e.reading&&t.read(0)}function D(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function M(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function F(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function j(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}k.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):x(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&F(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=O(r,e))),null===(n=t>0?M(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&F(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){A(this,new v("_read()"))},k.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){o("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",f),l=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,D(t))}}(r);t.on("drain",c);var l=!1;function f(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==j(n.pipes,t))&&!l&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===s(t,"error")&&A(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",f),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=j(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},k.prototype.on=function(t,e){var r=a.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(C,this))),r},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(U,this),r},k.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(U,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var s=0;s<S.length;s++)t.on(S[s],this.emit.bind(this,S[s]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(k.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),k._fromList=M,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(k.from=function(t,e){return void 0===p&&(p=r(5049)),p(k,t,e)})},3054:(t,e,r)=>{t.exports=l;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(2818);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(t){if(!(this instanceof l))return new l(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new s;return t.push(null)}r(6698)(l,u),l.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},l.prototype._transform=function(t,e,r){r(new i("_transform()"))},l.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},l.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},2192:(t,e,r)=>{var n,i=r(3184);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(undefined),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=k,k.WritableState=_;var s,a={deprecate:r(4643)},u=r(1181),c=r(8287).Buffer,l=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,E=p.ERR_UNKNOWN_ENCODING,A=f.errorOrDestroy;function S(){}function _(t,e,s){n=n||r(2818),t=t||{},"boolean"!=typeof s&&(s=e instanceof n),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,A(t,n)):(o(n),t._writableState.errorEmitted=!0,A(t,n),B(t,e))}(t,r,n,e,o);else{var s=O(r)||t.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(P,t,r,s,o):P(t,r,s,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function k(t){var e=this instanceof(n=n||r(2818));if(!e&&!s.call(k,this))return new k(t);this._writableState=new _(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new w("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function P(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final((function(r){e.pendingcb--,r&&A(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)}))}function B(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(k,u),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===k&&t&&t._writableState instanceof _}})):s=function(t){return t instanceof this},k.prototype.pipe=function(){A(this,new b)},k.prototype.write=function(t,e,r){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof l);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new v;A(t,r),i.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var o;return null===r?o=new m:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(A(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,a,n,i,o);return u}(this,o,a,t,e,r)),s},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},k.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new E(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new y("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}},4743:(t,e,r)=>{var n,i=r(3184);function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=r(5826),a=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var r=t[p].read();null!==r&&(t[f]=null,t[a]=null,t[u]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),w=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[l])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[l]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,l,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[f]=null,r[a]=null,r[u]=null,t(d(n,!1))):(r[a]=t,r[u]=e)},writable:!0}),e));return r[f]=null,s(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[f]=null,r[a]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[a];null!==n&&(r[f]=null,r[a]=null,r[u]=null,n(d(void 0,!0))),r[l]=!0})),t.on("readable",g.bind(null,r)),r}},2389:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=a(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}function a(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(8460).inspect,l=c&&c.custom||"inspect";t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,(r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e,r,n,i=u.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,u.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:l,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}])&&s(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1468:(t,e,r)=>{var n=r(3184);function i(t,e){s(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(s,this,t)):n.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},5826:(t,e,r)=>{var n=r(2260).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var s=r.readable||!1!==r.readable&&e.readable,a=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||l()},c=e._writableState&&e._writableState.finished,l=function(){a=!1,c=!0,s||o.call(e)},f=e._readableState&&e._readableState.endEmitted,h=function(){s=!1,f=!0,a||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return s&&!f?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):a&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",l)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",l),e.on("abort",d),e.req?y():e.on("request",y)):a&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",l),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",l),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},5049:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},9434:(t,e,r)=>{var n,i=r(2260).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var l,f=function(t){return t.length?"function"!=typeof t[t.length-1]?a:t.pop():a}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var a=!1;t.on("close",(function(){a=!0})),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);a=!0,o()}));var u=!1;return function(e){if(!a&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new s("pipe"))}}(t,o,i>0,(function(t){l||(l=t),t&&h.forEach(u),o||(h.forEach(u),f(l))}))}));return e.reduce(c)}},8775:(t,e,r)=>{var n=r(2260).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1181:(t,e,r)=>{t.exports=r(7007).EventEmitter},1603:(t,e,r)=>{(e=t.exports=r(6736)).Stream=e,e.Readable=e,e.Writable=r(2192),e.Duplex=r(2818),e.Transform=r(3054),e.PassThrough=r(5860),e.finished=r(5826),e.pipeline=r(9434)},7417:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),s.prototype=Object.create(i.prototype),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,s,a=8*i-n-1,u=(1<<a)-1,c=u>>1,l=-7,f=r?i-1:0,h=r?-1:1,p=t[e+f];for(f+=h,o=p&(1<<-l)-1,p>>=-l,l+=a;l>0;o=256*o+t[e+f],f+=h,l-=8);for(s=o&(1<<-l)-1,o>>=-l,l+=n;l>0;s=256*s+t[e+f],f+=h,l-=8);if(0===o)o=1-c;else{if(o===u)return s?NaN:1/0*(p?-1:1);s+=Math.pow(2,n),o-=c}return(p?-1:1)*s*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var s,a,u,c=8*o-i-1,l=(1<<c)-1,f=l>>1,h=23===i?Math.pow(2,-24)-Math.pow(2,-77):0,p=n?0:o-1,d=n?1:-1,y=e<0||0===e&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,s=l):(s=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-s))<1&&(s--,u*=2),(e+=s+f>=1?h/u:h*Math.pow(2,1-f))*u>=2&&(s++,u/=2),s+f>=l?(a=0,s=l):s+f>=1?(a=(e*u-1)*Math.pow(2,i),s+=f):(a=e*Math.pow(2,f-1)*Math.pow(2,i),s=0));i>=8;t[r+p]=255&a,p+=d,a/=256,i-=8);for(s=s<<i|a,c+=i;c>0;t[r+p]=255&s,p+=d,s/=256,c-=8);t[r+p-d]|=128*y}},6698:t=>{"function"==typeof Object.create?t.exports=function(t,e){e&&(t.super_=e,t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:t.exports=function(t,e){if(e){t.super_=e;var r=function(){};r.prototype=e.prototype,t.prototype=new r,t.prototype.constructor=t}}},3209:(t,e,r)=>{var n=r(3184),i=65536,o=r(2861).Buffer,s=r.g.crypto||r.g.msCrypto;s&&s.getRandomValues?t.exports=function(t,e){if(t>4294967295)throw new RangeError("requested too many random bytes");var r=o.allocUnsafe(t);if(t>0)if(t>i)for(var a=0;a<t;a+=i)s.getRandomValues(r.slice(a,a+i));else s.getRandomValues(r);return"function"==typeof e?n.nextTick((function(){e(null,r)})):r}:t.exports=function(){throw new Error("Secure random number generation is not supported by this browser.\nUse Chrome, Firefox or Internet Explorer 11")}},6011:(t,e,r)=>{var n=r(8287).Buffer,i=r(6698),o=r(4729),s=new Array(16),a=[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],u=[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],c=[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],l=[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],f=[0,1518500249,1859775393,2400959708,2840853838],h=[1352829926,1548603684,1836072691,2053994217,0];function p(){o.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}function d(t,e){return t<<e|t>>>32-e}function y(t,e,r,n,i,o,s,a){return d(t+(e^r^n)+o+s|0,a)+i|0}function g(t,e,r,n,i,o,s,a){return d(t+(e&r|~e&n)+o+s|0,a)+i|0}function b(t,e,r,n,i,o,s,a){return d(t+((e|~r)^n)+o+s|0,a)+i|0}function w(t,e,r,n,i,o,s,a){return d(t+(e&n|r&~n)+o+s|0,a)+i|0}function m(t,e,r,n,i,o,s,a){return d(t+(e^(r|~n))+o+s|0,a)+i|0}i(p,o),p.prototype._update=function(){for(var t=s,e=0;e<16;++e)t[e]=this._block.readInt32LE(4*e);for(var r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,p=0|this._e,v=0|this._a,E=0|this._b,A=0|this._c,S=0|this._d,_=0|this._e,k=0;k<80;k+=1){var T,P;k<16?(T=y(r,n,i,o,p,t[a[k]],f[0],c[k]),P=m(v,E,A,S,_,t[u[k]],h[0],l[k])):k<32?(T=g(r,n,i,o,p,t[a[k]],f[1],c[k]),P=w(v,E,A,S,_,t[u[k]],h[1],l[k])):k<48?(T=b(r,n,i,o,p,t[a[k]],f[2],c[k]),P=b(v,E,A,S,_,t[u[k]],h[2],l[k])):k<64?(T=w(r,n,i,o,p,t[a[k]],f[3],c[k]),P=g(v,E,A,S,_,t[u[k]],h[3],l[k])):(T=m(r,n,i,o,p,t[a[k]],f[4],c[k]),P=y(v,E,A,S,_,t[u[k]],h[4],l[k])),r=p,p=o,o=d(i,10),i=n,n=T,v=_,_=S,S=d(A,10),A=E,E=P}var I=this._b+i+S|0;this._b=this._c+o+_|0,this._c=this._d+p+v|0,this._d=this._e+r+E|0,this._e=this._a+n+A|0,this._a=I},p.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 t=n.alloc?n.alloc(20):new n(20);return t.writeInt32LE(this._a,0),t.writeInt32LE(this._b,4),t.writeInt32LE(this._c,8),t.writeInt32LE(this._d,12),t.writeInt32LE(this._e,16),t},t.exports=p},2861:(t,e,r)=>{var n=r(8287),i=n.Buffer;function o(t,e){for(var r in t)e[r]=t[r]}function s(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=s),o(i,s),s.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},s.alloc=function(t,e,r){if("number"!=typeof t)throw new TypeError("Argument must be a number");var n=i(t);return void 0!==e?"string"==typeof r?n.fill(e,r):n.fill(e):n.fill(0),n},s.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},s.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},392:(t,e,r)=>{var n=r(2861).Buffer;function i(t,e){this._block=n.alloc(t),this._finalSize=e,this._blockSize=t,this._len=0}i.prototype.update=function(t,e){"string"==typeof t&&(e=e||"utf8",t=n.from(t,e));for(var r=this._block,i=this._blockSize,o=t.length,s=this._len,a=0;a<o;){for(var u=s%i,c=Math.min(o-a,i-u),l=0;l<c;l++)r[u+l]=t[a+l];a+=c,(s+=c)%i==0&&this._update(r)}return this._len+=o,this},i.prototype.digest=function(t){var e=this._len%this._blockSize;this._block[e]=128,this._block.fill(0,e+1),e>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=8*this._len;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(4294967295&r)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var o=this._hash();return t?o.toString(t):o},i.prototype._update=function(){throw new Error("_update must be implemented by subclass")},t.exports=i},2802:(t,e,r)=>{var n=t.exports=function(t){t=t.toLowerCase();var e=n[t];if(!e)throw new Error(t+" is not supported (we accept pull requests)");return new e};n.sha=r(7816),n.sha1=r(3737),n.sha224=r(6710),n.sha256=r(4107),n.sha384=r(2827),n.sha512=r(2890)},7816:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t){return t<<30|t>>>2}function l(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,f=0;f<16;++f)r[f]=t.readInt32BE(4*f);for(;f<80;++f)r[f]=r[f-3]^r[f-8]^r[f-14]^r[f-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+l(p,i,o,a)+u+r[h]+s[p];u=a,a=o,o=c(i),i=n,n=d}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},3737:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[1518500249,1859775393,-1894007588,-899497514],a=new Array(80);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function l(t){return t<<30|t>>>2}function f(t,e,r,n){return 0===t?e&r|~e&n:2===t?e&r|e&n|r&n:e^r^n}n(u,i),u.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,h=0;h<16;++h)r[h]=t.readInt32BE(4*h);for(;h<80;++h)r[h]=(e=r[h-3]^r[h-8]^r[h-14]^r[h-16])<<1|e>>>31;for(var p=0;p<80;++p){var d=~~(p/20),y=c(n)+f(d,i,o,a)+u+r[p]+s[d]|0;u=a,a=o,o=l(i),i=n,n=y}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0},u.prototype._hash=function(){var t=o.allocUnsafe(20);return t.writeInt32BE(0|this._a,0),t.writeInt32BE(0|this._b,4),t.writeInt32BE(0|this._c,8),t.writeInt32BE(0|this._d,12),t.writeInt32BE(0|this._e,16),t},t.exports=u},6710:(t,e,r)=>{var n=r(6698),i=r(4107),o=r(392),s=r(2861).Buffer,a=new Array(64);function u(){this.init(),this._w=a,o.call(this,64,56)}n(u,i),u.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},u.prototype._hash=function(){var t=s.allocUnsafe(28);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t},t.exports=u},4107:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[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],a=new Array(64);function u(){this.init(),this._w=a,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function f(t){return(t>>>2|t<<30)^(t>>>13|t<<19)^(t>>>22|t<<10)}function h(t){return(t>>>6|t<<26)^(t>>>11|t<<21)^(t>>>25|t<<7)}function p(t){return(t>>>7|t<<25)^(t>>>18|t<<14)^t>>>3}n(u,i),u.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},u.prototype._update=function(t){for(var e,r=this._w,n=0|this._a,i=0|this._b,o=0|this._c,a=0|this._d,u=0|this._e,d=0|this._f,y=0|this._g,g=0|this._h,b=0;b<16;++b)r[b]=t.readInt32BE(4*b);for(;b<64;++b)r[b]=0|(((e=r[b-2])>>>17|e<<15)^(e>>>19|e<<13)^e>>>10)+r[b-7]+p(r[b-15])+r[b-16];for(var w=0;w<64;++w){var m=g+h(u)+c(u,d,y)+s[w]+r[w]|0,v=f(n)+l(n,i,o)|0;g=y,y=d,d=u,u=a+m|0,a=o,o=i,i=n,n=m+v|0}this._a=n+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=a+this._d|0,this._e=u+this._e|0,this._f=d+this._f|0,this._g=y+this._g|0,this._h=g+this._h|0},u.prototype._hash=function(){var t=o.allocUnsafe(32);return t.writeInt32BE(this._a,0),t.writeInt32BE(this._b,4),t.writeInt32BE(this._c,8),t.writeInt32BE(this._d,12),t.writeInt32BE(this._e,16),t.writeInt32BE(this._f,20),t.writeInt32BE(this._g,24),t.writeInt32BE(this._h,28),t},t.exports=u},2827:(t,e,r)=>{var n=r(6698),i=r(2890),o=r(392),s=r(2861).Buffer,a=new Array(160);function u(){this.init(),this._w=a,o.call(this,128,112)}n(u,i),u.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},u.prototype._hash=function(){var t=s.allocUnsafe(48);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),t},t.exports=u},2890:(t,e,r)=>{var n=r(6698),i=r(392),o=r(2861).Buffer,s=[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],a=new Array(160);function u(){this.init(),this._w=a,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function l(t,e,r){return t&e|r&(t|e)}function f(t,e){return(t>>>28|e<<4)^(e>>>2|t<<30)^(e>>>7|t<<25)}function h(t,e){return(t>>>14|e<<18)^(t>>>18|e<<14)^(e>>>9|t<<23)}function p(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^t>>>7}function d(t,e){return(t>>>1|e<<31)^(t>>>8|e<<24)^(t>>>7|e<<25)}function y(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^t>>>6}function g(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function b(t,e){return t>>>0<e>>>0?1:0}n(u,i),u.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},u.prototype._update=function(t){for(var e=this._w,r=0|this._ah,n=0|this._bh,i=0|this._ch,o=0|this._dh,a=0|this._eh,u=0|this._fh,w=0|this._gh,m=0|this._hh,v=0|this._al,E=0|this._bl,A=0|this._cl,S=0|this._dl,_=0|this._el,k=0|this._fl,T=0|this._gl,P=0|this._hl,I=0;I<32;I+=2)e[I]=t.readInt32BE(4*I),e[I+1]=t.readInt32BE(4*I+4);for(;I<160;I+=2){var O=e[I-30],x=e[I-30+1],B=p(O,x),R=d(x,O),N=y(O=e[I-4],x=e[I-4+1]),U=g(x,O),C=e[I-14],L=e[I-14+1],D=e[I-32],M=e[I-32+1],F=R+L|0,H=B+C+b(F,R)|0;H=(H=H+N+b(F=F+U|0,U)|0)+D+b(F=F+M|0,M)|0,e[I]=H,e[I+1]=F}for(var j=0;j<160;j+=2){H=e[j],F=e[j+1];var G=l(r,n,i),V=l(v,E,A),K=f(r,v),W=f(v,r),z=h(a,_),q=h(_,a),Q=s[j],J=s[j+1],X=c(a,u,w),Y=c(_,k,T),Z=P+q|0,$=m+z+b(Z,P)|0;$=($=($=$+X+b(Z=Z+Y|0,Y)|0)+Q+b(Z=Z+J|0,J)|0)+H+b(Z=Z+F|0,F)|0;var tt=W+V|0,et=K+G+b(tt,W)|0;m=w,P=T,w=u,T=k,u=a,k=_,a=o+$+b(_=S+Z|0,S)|0,o=i,S=A,i=n,A=E,n=r,E=v,r=$+et+b(v=Z+tt|0,Z)|0}this._al=this._al+v|0,this._bl=this._bl+E|0,this._cl=this._cl+A|0,this._dl=this._dl+S|0,this._el=this._el+_|0,this._fl=this._fl+k|0,this._gl=this._gl+T|0,this._hl=this._hl+P|0,this._ah=this._ah+r+b(this._al,v)|0,this._bh=this._bh+n+b(this._bl,E)|0,this._ch=this._ch+i+b(this._cl,A)|0,this._dh=this._dh+o+b(this._dl,S)|0,this._eh=this._eh+a+b(this._el,_)|0,this._fh=this._fh+u+b(this._fl,k)|0,this._gh=this._gh+w+b(this._gl,T)|0,this._hh=this._hh+m+b(this._hl,P)|0},u.prototype._hash=function(){var t=o.allocUnsafe(64);function e(e,r,n){t.writeInt32BE(e,n),t.writeInt32BE(r,n+4)}return e(this._ah,this._al,0),e(this._bh,this._bl,8),e(this._ch,this._cl,16),e(this._dh,this._dl,24),e(this._eh,this._el,32),e(this._fh,this._fl,40),e(this._gh,this._gl,48),e(this._hh,this._hl,56),t},t.exports=u},8310:(t,e,r)=>{t.exports=i;var n=r(7007).EventEmitter;function i(){n.call(this)}r(6698)(i,n),i.Readable=r(6891),i.Writable=r(1999),i.Duplex=r(8101),i.Transform=r(9083),i.PassThrough=r(3681),i.finished=r(4257),i.pipeline=r(5267),i.Stream=i,i.prototype.pipe=function(t,e){var r=this;function i(e){t.writable&&!1===t.write(e)&&r.pause&&r.pause()}function o(){r.readable&&r.resume&&r.resume()}r.on("data",i),t.on("drain",o),t._isStdio||e&&!1===e.end||(r.on("end",a),r.on("close",u));var s=!1;function a(){s||(s=!0,t.end())}function u(){s||(s=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(l(),0===n.listenerCount(this,"error"))throw t}function l(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",a),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",l),r.removeListener("close",l),t.removeListener("close",l)}return r.on("error",c),t.on("error",c),r.on("end",l),r.on("close",l),t.on("close",l),t.emit("pipe",r),t}},2463:t=>{var e={};function r(t,r,n){n||(n=Error);var i=function(t){var e,n;function i(e,n,i){return t.call(this,function(t,e,n){return"string"==typeof r?r:r(t,e,n)}(e,n,i))||this}return n=t,(e=i).prototype=Object.create(n.prototype),e.prototype.constructor=e,e.__proto__=n,i}(n);i.prototype.name=n.name,i.prototype.code=t,e[t]=i}function n(t,e){if(Array.isArray(t)){var r=t.length;return t=t.map((function(t){return String(t)})),r>2?"one of ".concat(e," ").concat(t.slice(0,r-1).join(", "),", or ")+t[r-1]:2===r?"one of ".concat(e," ").concat(t[0]," or ").concat(t[1]):"of ".concat(e," ").concat(t[0])}return"of ".concat(e," ").concat(String(t))}r("ERR_INVALID_OPT_VALUE",(function(t,e){return'The value "'+e+'" is invalid for option "'+t+'"'}),TypeError),r("ERR_INVALID_ARG_TYPE",(function(t,e,r){var i,o,s,a,u;if("string"==typeof e&&(o="not ",e.substr(0,4)===o)?(i="must not be",e=e.replace(/^not /,"")):i="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))s="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(a=t).length||-1===a.indexOf(".",u)?"argument":"property");s='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return s+". Received type ".concat(typeof r)}),TypeError),r("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),r("ERR_METHOD_NOT_IMPLEMENTED",(function(t){return"The "+t+" method is not implemented"})),r("ERR_STREAM_PREMATURE_CLOSE","Premature close"),r("ERR_STREAM_DESTROYED",(function(t){return"Cannot call "+t+" after a stream was destroyed"})),r("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),r("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),r("ERR_STREAM_WRITE_AFTER_END","write after end"),r("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),r("ERR_UNKNOWN_ENCODING",(function(t){return"Unknown encoding: "+t}),TypeError),r("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),t.exports.F=e},8101:(t,e,r)=>{var n=r(3184),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=l;var o=r(6891),s=r(1999);r(6698)(l,o);for(var a=i(s.prototype),u=0;u<a.length;u++){var c=a[u];l.prototype[c]||(l.prototype[c]=s.prototype[c])}function l(t){if(!(this instanceof l))return new l(t);o.call(this,t),s.call(this,t),this.allowHalfOpen=!0,t&&(!1===t.readable&&(this.readable=!1),!1===t.writable&&(this.writable=!1),!1===t.allowHalfOpen&&(this.allowHalfOpen=!1,this.once("end",f)))}function f(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&void 0!==this._writableState&&this._readableState.destroyed&&this._writableState.destroyed},set:function(t){void 0!==this._readableState&&void 0!==this._writableState&&(this._readableState.destroyed=t,this._writableState.destroyed=t)}})},3681:(t,e,r)=>{t.exports=i;var n=r(9083);function i(t){if(!(this instanceof i))return new i(t);n.call(this,t)}r(6698)(i,n),i.prototype._transform=function(t,e,r){r(null,t)}},6891:(t,e,r)=>{var n,i=r(3184);t.exports=k,k.ReadableState=_,r(7007).EventEmitter;var o,s=function(t,e){return t.listeners(e).length},a=r(1396),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(7199);o=l&&l.debuglog?l.debuglog("stream"):function(){};var f,h,p,d=r(1766),y=r(4347),g=r(6644).getHighWaterMark,b=r(2463).F,w=b.ERR_INVALID_ARG_TYPE,m=b.ERR_STREAM_PUSH_AFTER_EOF,v=b.ERR_METHOD_NOT_IMPLEMENTED,E=b.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(k,a);var A=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function _(t,e,i){n=n||r(8101),t=t||{},"boolean"!=typeof i&&(i=e instanceof n),this.objectMode=!!t.objectMode,i&&(this.objectMode=this.objectMode||!!t.readableObjectMode),this.highWaterMark=g(this,t,"readableHighWaterMark",i),this.buffer=new d,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=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.destroyed=!1,this.defaultEncoding=t.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,t.encoding&&(f||(f=r(3141).I),this.decoder=new f(t.encoding),this.encoding=t.encoding)}function k(t){if(n=n||r(8101),!(this instanceof k))return new k(t);var e=this instanceof n;this._readableState=new _(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),a.call(this)}function T(t,e,r,n,i){o("readableAddChunk",e);var s,a=t._readableState;if(null===e)a.reading=!1,function(t,e){if(o("onEofChunk"),!e.ended){if(e.decoder){var r=e.decoder.end();r&&r.length&&(e.buffer.push(r),e.length+=e.objectMode?1:r.length)}e.ended=!0,e.sync?x(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,B(t)))}}(t,a);else if(i||(s=function(t,e){var r,n;return n=e,u.isBuffer(n)||n instanceof c||"string"==typeof e||void 0===e||t.objectMode||(r=new w("chunk",["string","Buffer","Uint8Array"],e)),r}(a,e)),s)A(t,s);else if(a.objectMode||e&&e.length>0)if("string"==typeof e||a.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)a.endEmitted?A(t,new E):P(t,a,e,!0);else if(a.ended)A(t,new m);else{if(a.destroyed)return!1;a.reading=!1,a.decoder&&!r?(e=a.decoder.write(e),a.objectMode||0!==e.length?P(t,a,e,!1):R(t,a)):P(t,a,e,!1)}else n||(a.reading=!1,R(t,a));return!a.ended&&(a.length<a.highWaterMark||0===a.length)}function P(t,e,r,n){e.flowing&&0===e.length&&!e.sync?(e.awaitDrain=0,t.emit("data",r)):(e.length+=e.objectMode?1:r.length,n?e.buffer.unshift(r):e.buffer.push(r),e.needReadable&&x(t)),R(t,e)}Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),k.prototype.destroy=y.destroy,k.prototype._undestroy=y.undestroy,k.prototype._destroy=function(t,e){e(t)},k.prototype.push=function(t,e){var r,n=this._readableState;return n.objectMode?r=!0:"string"==typeof t&&((e=e||n.defaultEncoding)!==n.encoding&&(t=u.from(t,e),e=""),r=!0),T(this,t,e,!1,r)},k.prototype.unshift=function(t){return T(this,t,null,!0,!1)},k.prototype.isPaused=function(){return!1===this._readableState.flowing},k.prototype.setEncoding=function(t){f||(f=r(3141).I);var e=new f(t);this._readableState.decoder=e,this._readableState.encoding=this._readableState.decoder.encoding;for(var n=this._readableState.buffer.head,i="";null!==n;)i+=e.write(n.data),n=n.next;return this._readableState.buffer.clear(),""!==i&&this._readableState.buffer.push(i),this._readableState.length=i.length,this};var I=1073741824;function O(t,e){return t<=0||0===e.length&&e.ended?0:e.objectMode?1:t!=t?e.flowing&&e.length?e.buffer.head.data.length:e.length:(t>e.highWaterMark&&(e.highWaterMark=function(t){return t>=I?t=I:(t--,t|=t>>>1,t|=t>>>2,t|=t>>>4,t|=t>>>8,t|=t>>>16,t++),t}(t)),t<=e.length?t:e.ended?e.length:(e.needReadable=!0,0))}function x(t){var e=t._readableState;o("emitReadable",e.needReadable,e.emittedReadable),e.needReadable=!1,e.emittedReadable||(o("emitReadable",e.flowing),e.emittedReadable=!0,i.nextTick(B,t))}function B(t){var e=t._readableState;o("emitReadable_",e.destroyed,e.length,e.ended),e.destroyed||!e.length&&!e.ended||(t.emit("readable"),e.emittedReadable=!1),e.needReadable=!e.flowing&&!e.ended&&e.length<=e.highWaterMark,D(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(N,t,e))}function N(t,e){for(;!e.reading&&!e.ended&&(e.length<e.highWaterMark||e.flowing&&0===e.length);){var r=e.length;if(o("maybeReadMore read 0"),t.read(0),r===e.length)break}e.readingMore=!1}function U(t){var e=t._readableState;e.readableListening=t.listenerCount("readable")>0,e.resumeScheduled&&!e.paused?e.flowing=!0:t.listenerCount("data")>0&&t.resume()}function C(t){o("readable nexttick read 0"),t.read(0)}function L(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),D(t),e.flowing&&!e.reading&&t.read(0)}function D(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function M(t,e){return 0===e.length?null:(e.objectMode?r=e.buffer.shift():!t||t>=e.length?(r=e.decoder?e.buffer.join(""):1===e.buffer.length?e.buffer.first():e.buffer.concat(e.length),e.buffer.clear()):r=e.buffer.consume(t,e.decoder),r);var r}function F(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(H,e,t))}function H(t,e){if(o("endReadableNT",t.endEmitted,t.length),!t.endEmitted&&0===t.length&&(t.endEmitted=!0,e.readable=!1,e.emit("end"),t.autoDestroy)){var r=e._writableState;(!r||r.autoDestroy&&r.finished)&&e.destroy()}}function j(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}k.prototype.read=function(t){o("read",t),t=parseInt(t,10);var e=this._readableState,r=t;if(0!==t&&(e.emittedReadable=!1),0===t&&e.needReadable&&((0!==e.highWaterMark?e.length>=e.highWaterMark:e.length>0)||e.ended))return o("read: emitReadable",e.length,e.ended),0===e.length&&e.ended?F(this):x(this),null;if(0===(t=O(t,e))&&e.ended)return 0===e.length&&F(this),null;var n,i=e.needReadable;return o("need readable",i),(0===e.length||e.length-t<e.highWaterMark)&&o("length less than watermark",i=!0),e.ended||e.reading?o("reading or ended",i=!1):i&&(o("do read"),e.reading=!0,e.sync=!0,0===e.length&&(e.needReadable=!0),this._read(e.highWaterMark),e.sync=!1,e.reading||(t=O(r,e))),null===(n=t>0?M(t,e):null)?(e.needReadable=e.length<=e.highWaterMark,t=0):(e.length-=t,e.awaitDrain=0),0===e.length&&(e.ended||(e.needReadable=!0),r!==t&&e.ended&&F(this)),null!==n&&this.emit("data",n),n},k.prototype._read=function(t){A(this,new v("_read()"))},k.prototype.pipe=function(t,e){var r=this,n=this._readableState;switch(n.pipesCount){case 0:n.pipes=t;break;case 1:n.pipes=[n.pipes,t];break;default:n.pipes.push(t)}n.pipesCount+=1,o("pipe count=%d opts=%j",n.pipesCount,e);var a=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(a):r.once("end",a),t.on("unpipe",(function e(i,s){o("onunpipe"),i===r&&s&&!1===s.hasUnpiped&&(s.hasUnpiped=!0,o("cleanup"),t.removeListener("close",p),t.removeListener("finish",d),t.removeListener("drain",c),t.removeListener("error",h),t.removeListener("unpipe",e),r.removeListener("end",u),r.removeListener("end",y),r.removeListener("data",f),l=!0,!n.awaitDrain||t._writableState&&!t._writableState.needDrain||c())}));var c=function(t){return function(){var e=t._readableState;o("pipeOnDrain",e.awaitDrain),e.awaitDrain&&e.awaitDrain--,0===e.awaitDrain&&s(t,"data")&&(e.flowing=!0,D(t))}}(r);t.on("drain",c);var l=!1;function f(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==j(n.pipes,t))&&!l&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===s(t,"error")&&A(t,e)}function p(){t.removeListener("finish",d),y()}function d(){o("onfinish"),t.removeListener("close",p),y()}function y(){o("unpipe"),r.unpipe(t)}return r.on("data",f),function(t,e,r){if("function"==typeof t.prependListener)return t.prependListener(e,r);t._events&&t._events[e]?Array.isArray(t._events[e])?t._events[e].unshift(r):t._events[e]=[r,t._events[e]]:t.on(e,r)}(t,"error",h),t.once("close",p),t.once("finish",d),t.emit("pipe",r),n.flowing||(o("pipe resume"),r.resume()),t},k.prototype.unpipe=function(t){var e=this._readableState,r={hasUnpiped:!1};if(0===e.pipesCount)return this;if(1===e.pipesCount)return t&&t!==e.pipes||(t||(t=e.pipes),e.pipes=null,e.pipesCount=0,e.flowing=!1,t&&t.emit("unpipe",this,r)),this;if(!t){var n=e.pipes,i=e.pipesCount;e.pipes=null,e.pipesCount=0,e.flowing=!1;for(var o=0;o<i;o++)n[o].emit("unpipe",this,{hasUnpiped:!1});return this}var s=j(e.pipes,t);return-1===s||(e.pipes.splice(s,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},k.prototype.on=function(t,e){var r=a.prototype.on.call(this,t,e),n=this._readableState;return"data"===t?(n.readableListening=this.listenerCount("readable")>0,!1!==n.flowing&&this.resume()):"readable"===t&&(n.endEmitted||n.readableListening||(n.readableListening=n.needReadable=!0,n.flowing=!1,n.emittedReadable=!1,o("on readable",n.length,n.reading),n.length?x(this):n.reading||i.nextTick(C,this))),r},k.prototype.addListener=k.prototype.on,k.prototype.removeListener=function(t,e){var r=a.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(U,this),r},k.prototype.removeAllListeners=function(t){var e=a.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(U,this),e},k.prototype.resume=function(){var t=this._readableState;return t.flowing||(o("resume"),t.flowing=!t.readableListening,function(t,e){e.resumeScheduled||(e.resumeScheduled=!0,i.nextTick(L,t,e))}(this,t)),t.paused=!1,this},k.prototype.pause=function(){return o("call pause flowing=%j",this._readableState.flowing),!1!==this._readableState.flowing&&(o("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},k.prototype.wrap=function(t){var e=this,r=this._readableState,n=!1;for(var i in t.on("end",(function(){if(o("wrapped end"),r.decoder&&!r.ended){var t=r.decoder.end();t&&t.length&&e.push(t)}e.push(null)})),t.on("data",(function(i){o("wrapped data"),r.decoder&&(i=r.decoder.write(i)),r.objectMode&&null==i||(r.objectMode||i&&i.length)&&(e.push(i)||(n=!0,t.pause()))})),t)void 0===this[i]&&"function"==typeof t[i]&&(this[i]=function(e){return function(){return t[e].apply(t,arguments)}}(i));for(var s=0;s<S.length;s++)t.on(S[s],this.emit.bind(this,S[s]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(k.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(k.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(k.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(k.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),k._fromList=M,Object.defineProperty(k.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(k.from=function(t,e){return void 0===p&&(p=r(968)),p(k,t,e)})},9083:(t,e,r)=>{t.exports=l;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,s=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,a=n.ERR_TRANSFORM_WITH_LENGTH_0,u=r(8101);function c(t,e){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(null===n)return this.emit("error",new o);r.writechunk=null,r.writecb=null,null!=e&&this.push(e),n(t);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function l(t){if(!(this instanceof l))return new l(t);u.call(this,t),this._transformState={afterTransform:c.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,t&&("function"==typeof t.transform&&(this._transform=t.transform),"function"==typeof t.flush&&(this._flush=t.flush)),this.on("prefinish",f)}function f(){var t=this;"function"!=typeof this._flush||this._readableState.destroyed?h(this,null,null):this._flush((function(e,r){h(t,e,r)}))}function h(t,e,r){if(e)return t.emit("error",e);if(null!=r&&t.push(r),t._writableState.length)throw new a;if(t._transformState.transforming)throw new s;return t.push(null)}r(6698)(l,u),l.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},l.prototype._transform=function(t,e,r){r(new i("_transform()"))},l.prototype._write=function(t,e,r){var n=this._transformState;if(n.writecb=r,n.writechunk=t,n.writeencoding=e,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}},l.prototype._read=function(t){var e=this._transformState;null===e.writechunk||e.transforming?e.needTransform=!0:(e.transforming=!0,this._transform(e.writechunk,e.writeencoding,e.afterTransform))},l.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},1999:(t,e,r)=>{var n,i=r(3184);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e,r){var n=t.entry;for(t.entry=null;n;){var i=n.callback;e.pendingcb--,i(undefined),n=n.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=k,k.WritableState=_;var s,a={deprecate:r(4643)},u=r(1396),c=r(8287).Buffer,l=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,g=p.ERR_MULTIPLE_CALLBACK,b=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,m=p.ERR_STREAM_NULL_VALUES,v=p.ERR_STREAM_WRITE_AFTER_END,E=p.ERR_UNKNOWN_ENCODING,A=f.errorOrDestroy;function S(){}function _(t,e,s){n=n||r(8101),t=t||{},"boolean"!=typeof s&&(s=e instanceof n),this.objectMode=!!t.objectMode,s&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",s),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var a=!1===t.decodeStrings;this.decodeStrings=!a,this.defaultEncoding=t.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(t){!function(t,e){var r=t._writableState,n=r.sync,o=r.writecb;if("function"!=typeof o)throw new g;if(function(t){t.writing=!1,t.writecb=null,t.length-=t.writelen,t.writelen=0}(r),e)!function(t,e,r,n,o){--e.pendingcb,r?(i.nextTick(o,n),i.nextTick(B,t,e),t._writableState.errorEmitted=!0,A(t,n)):(o(n),t._writableState.errorEmitted=!0,A(t,n),B(t,e))}(t,r,n,e,o);else{var s=O(r)||t.destroyed;s||r.corked||r.bufferProcessing||!r.bufferedRequest||I(t,r),n?i.nextTick(P,t,r,s,o):P(t,r,s,o)}}(e,t)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=!1!==t.emitClose,this.autoDestroy=!!t.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new o(this)}function k(t){var e=this instanceof(n=n||r(8101));if(!e&&!s.call(k,this))return new k(t);this._writableState=new _(t,this,e),this.writable=!0,t&&("function"==typeof t.write&&(this._write=t.write),"function"==typeof t.writev&&(this._writev=t.writev),"function"==typeof t.destroy&&(this._destroy=t.destroy),"function"==typeof t.final&&(this._final=t.final)),u.call(this)}function T(t,e,r,n,i,o,s){e.writelen=n,e.writecb=s,e.writing=!0,e.sync=!0,e.destroyed?e.onwrite(new w("write")):r?t._writev(i,e.onwrite):t._write(i,o,e.onwrite),e.sync=!1}function P(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),B(t,e)}function I(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),s=e.corkedRequestsFree;s.entry=r;for(var a=0,u=!0;r;)i[a]=r,r.isBuf||(u=!1),r=r.next,a+=1;i.allBuffers=u,T(t,e,!0,e.length,i,"",s.finish),e.pendingcb++,e.lastBufferedRequest=null,s.next?(e.corkedRequestsFree=s.next,s.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,l=r.encoding,f=r.callback;if(T(t,e,!1,e.objectMode?1:c.length,c,l,f),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function O(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function x(t,e){t._final((function(r){e.pendingcb--,r&&A(t,r),e.prefinished=!0,t.emit("prefinish"),B(t,e)}))}function B(t,e){var r=O(e);if(r&&(function(t,e){e.prefinished||e.finalCalled||("function"!=typeof t._final||e.destroyed?(e.prefinished=!0,t.emit("prefinish")):(e.pendingcb++,e.finalCalled=!0,i.nextTick(x,t,e)))}(t,e),0===e.pendingcb&&(e.finished=!0,t.emit("finish"),e.autoDestroy))){var n=t._readableState;(!n||n.autoDestroy&&n.endEmitted)&&t.destroy()}return r}r(6698)(k,u),_.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(_.prototype,"buffer",{get:a.deprecate((function(){return this.getBuffer()}),"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch(t){}}(),"function"==typeof Symbol&&Symbol.hasInstance&&"function"==typeof Function.prototype[Symbol.hasInstance]?(s=Function.prototype[Symbol.hasInstance],Object.defineProperty(k,Symbol.hasInstance,{value:function(t){return!!s.call(this,t)||this===k&&t&&t._writableState instanceof _}})):s=function(t){return t instanceof this},k.prototype.pipe=function(){A(this,new b)},k.prototype.write=function(t,e,r){var n,o=this._writableState,s=!1,a=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof l);return a&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),a?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new v;A(t,r),i.nextTick(e,r)}(this,r):(a||function(t,e,r,n){var o;return null===r?o=new m:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(A(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,s=function(t,e,r,n,i,o){if(!r){var s=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==s&&(r=!0,i="buffer",n=s)}var a=e.objectMode?1:n.length;e.length+=a;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var l=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},l?l.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else T(t,e,!1,a,n,i,o);return u}(this,o,a,t,e,r)),s},k.prototype.cork=function(){this._writableState.corked++},k.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||I(this,t))},k.prototype.setDefaultEncoding=function(t){if("string"==typeof t&&(t=t.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((t+"").toLowerCase())>-1))throw new E(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(k.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(k.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),k.prototype._write=function(t,e,r){r(new y("_write()"))},k.prototype._writev=null,k.prototype.end=function(t,e,r){var n=this._writableState;return"function"==typeof t?(r=t,t=null,e=null):"function"==typeof e&&(r=e,e=null),null!=t&&this.write(t,e),n.corked&&(n.corked=1,this.uncork()),n.ending||function(t,e,r){e.ending=!0,B(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(k.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(k.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),k.prototype.destroy=f.destroy,k.prototype._undestroy=f.undestroy,k.prototype._destroy=function(t,e){e(t)}},5034:(t,e,r)=>{var n,i=r(3184);function o(t,e,r){return(e=function(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}var s=r(4257),a=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),l=Symbol("ended"),f=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[a];if(null!==e){var r=t[p].read();null!==r&&(t[f]=null,t[a]=null,t[u]=null,e(d(r,!1)))}}function g(t){i.nextTick(y,t)}var b=Object.getPrototypeOf((function(){})),w=Object.setPrototypeOf((o(n={get stream(){return this[p]},next:function(){var t=this,e=this[c];if(null!==e)return Promise.reject(e);if(this[l])return Promise.resolve(d(void 0,!0));if(this[p].destroyed)return new Promise((function(e,r){i.nextTick((function(){t[c]?r(t[c]):e(d(void 0,!0))}))}));var r,n=this[f];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[l]?r(d(void 0,!0)):e[h](r,n)}),n)}}(n,this));else{var o=this[p].read();if(null!==o)return Promise.resolve(d(o,!1));r=new Promise(this[h])}return this[f]=r,r}},Symbol.asyncIterator,(function(){return this})),o(n,"return",(function(){var t=this;return new Promise((function(e,r){t[p].destroy(null,(function(t){t?r(t):e(d(void 0,!0))}))}))})),n),b);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,a,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,l,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[f]=null,r[a]=null,r[u]=null,t(d(n,!1))):(r[a]=t,r[u]=e)},writable:!0}),e));return r[f]=null,s(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[f]=null,r[a]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[a];null!==n&&(r[f]=null,r[a]=null,r[u]=null,n(d(void 0,!0))),r[l]=!0})),t.on("readable",g.bind(null,r)),r}},1766:(t,e,r)=>{function n(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function i(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?n(Object(r),!0).forEach((function(e){o(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):n(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function o(t,e,r){return(e=a(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function s(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,a(n.key),n)}}function a(t){var e=function(t,e){if("object"!=typeof t||null===t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==typeof e?e:String(e)}var u=r(8287).Buffer,c=r(3779).inspect,l=c&&c.custom||"inspect";t.exports=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.head=null,this.tail=null,this.length=0}var e,r;return e=t,(r=[{key:"push",value:function(t){var e={data:t,next:null};this.length>0?this.tail.next=e:this.head=e,this.tail=e,++this.length}},{key:"unshift",value:function(t){var e={data:t,next:this.head};0===this.length&&(this.tail=e),this.head=e,++this.length}},{key:"shift",value:function(){if(0!==this.length){var t=this.head.data;return 1===this.length?this.head=this.tail=null:this.head=this.head.next,--this.length,t}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(t){if(0===this.length)return"";for(var e=this.head,r=""+e.data;e=e.next;)r+=t+e.data;return r}},{key:"concat",value:function(t){if(0===this.length)return u.alloc(0);for(var e,r,n,i=u.allocUnsafe(t>>>0),o=this.head,s=0;o;)e=o.data,r=i,n=s,u.prototype.copy.call(e,r,n),s+=o.data.length,o=o.next;return i}},{key:"consume",value:function(t,e){var r;return t<this.head.data.length?(r=this.head.data.slice(0,t),this.head.data=this.head.data.slice(t)):r=t===this.head.data.length?this.shift():e?this._getString(t):this._getBuffer(t),r}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(t){var e=this.head,r=1,n=e.data;for(t-=n.length;e=e.next;){var i=e.data,o=t>i.length?i.length:t;if(o===i.length?n+=i:n+=i.slice(0,t),0==(t-=o)){o===i.length?(++r,e.next?this.head=e.next:this.head=this.tail=null):(this.head=e,e.data=i.slice(o));break}++r}return this.length-=r,n}},{key:"_getBuffer",value:function(t){var e=u.allocUnsafe(t),r=this.head,n=1;for(r.data.copy(e),t-=r.data.length;r=r.next;){var i=r.data,o=t>i.length?i.length:t;if(i.copy(e,e.length-t,0,o),0==(t-=o)){o===i.length?(++n,r.next?this.head=r.next:this.head=this.tail=null):(this.head=r,r.data=i.slice(o));break}++n}return this.length-=n,e}},{key:l,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}])&&s(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4347:(t,e,r)=>{var n=r(3184);function i(t,e){s(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function s(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,a=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return a||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(s,this,t)):n.nextTick(s,this,t)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(t||null,(function(t){!e&&t?r._writableState?r._writableState.errorEmitted?n.nextTick(o,r):(r._writableState.errorEmitted=!0,n.nextTick(i,r,t)):n.nextTick(i,r,t):e?(n.nextTick(o,r),e(t)):n.nextTick(o,r)})),this)},undestroy:function(){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)},errorOrDestroy:function(t,e){var r=t._readableState,n=t._writableState;r&&r.autoDestroy||n&&n.autoDestroy?t.destroy(e):t.emit("error",e)}}},4257:(t,e,r)=>{var n=r(2463).F.ERR_STREAM_PREMATURE_CLOSE;function i(){}t.exports=function t(e,r,o){if("function"==typeof r)return t(e,null,r);r||(r={}),o=function(t){var e=!1;return function(){if(!e){e=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];t.apply(this,n)}}}(o||i);var s=r.readable||!1!==r.readable&&e.readable,a=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||l()},c=e._writableState&&e._writableState.finished,l=function(){a=!1,c=!0,s||o.call(e)},f=e._readableState&&e._readableState.endEmitted,h=function(){s=!1,f=!0,a||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return s&&!f?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):a&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",l)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",l),e.on("abort",d),e.req?y():e.on("request",y)):a&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",l),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",l),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",l),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",l),e.removeListener("end",h),e.removeListener("error",p),e.removeListener("close",d)}}},968:t=>{t.exports=function(){throw new Error("Readable.from is not available in the browser")}},5267:(t,e,r)=>{var n,i=r(2463).F,o=i.ERR_MISSING_ARGS,s=i.ERR_STREAM_DESTROYED;function a(t){if(t)throw t}function u(t){t()}function c(t,e){return t.pipe(e)}t.exports=function(){for(var t=arguments.length,e=new Array(t),i=0;i<t;i++)e[i]=arguments[i];var l,f=function(t){return t.length?"function"!=typeof t[t.length-1]?a:t.pop():a}(e);if(Array.isArray(e[0])&&(e=e[0]),e.length<2)throw new o("streams");var h=e.map((function(t,i){var o=i<e.length-1;return function(t,e,i,o){o=function(t){var e=!1;return function(){e||(e=!0,t.apply(void 0,arguments))}}(o);var a=!1;t.on("close",(function(){a=!0})),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);a=!0,o()}));var u=!1;return function(e){if(!a&&!u)return u=!0,function(t){return t.setHeader&&"function"==typeof t.abort}(t)?t.abort():"function"==typeof t.destroy?t.destroy():void o(e||new s("pipe"))}}(t,o,i>0,(function(t){l||(l=t),t&&h.forEach(u),o||(h.forEach(u),f(l))}))}));return e.reduce(c)}},6644:(t,e,r)=>{var n=r(2463).F.ERR_INVALID_OPT_VALUE;t.exports={getHighWaterMark:function(t,e,r,i){var o=function(t,e,r){return null!=t.highWaterMark?t.highWaterMark:e?t[r]:null}(e,i,r);if(null!=o){if(!isFinite(o)||Math.floor(o)!==o||o<0)throw new n(i?r:"highWaterMark",o);return Math.floor(o)}return t.objectMode?16:16384}}},1396:(t,e,r)=>{t.exports=r(7007).EventEmitter},3141:(t,e,r)=>{var n=r(2861).Buffer,i=n.isEncoding||function(t){switch((t=""+t)&&t.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 o(t){var e;switch(this.encoding=function(t){var e=function(t){if(!t)return"utf8";for(var e;;)switch(t){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 t;default:if(e)return;t=(""+t).toLowerCase(),e=!0}}(t);if("string"!=typeof e&&(n.isEncoding===i||!i(t)))throw new Error("Unknown encoding: "+t);return e||t}(t),this.encoding){case"utf16le":this.text=u,this.end=c,e=4;break;case"utf8":this.fillLast=a,e=4;break;case"base64":this.text=l,this.end=f,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function s(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function a(t){var e=this.lastTotal-this.lastNeed,r=function(t,e,r){if(128!=(192&e[0]))return t.lastNeed=0,"�";if(t.lastNeed>1&&e.length>1){if(128!=(192&e[1]))return t.lastNeed=1,"�";if(t.lastNeed>2&&e.length>2&&128!=(192&e[2]))return t.lastNeed=2,"�"}}(this,t);return void 0!==r?r:this.lastNeed<=t.length?(t.copy(this.lastChar,e,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(t.copy(this.lastChar,e,0,t.length),void(this.lastNeed-=t.length))}function u(t,e){if((t.length-e)%2==0){var r=t.toString("utf16le",e);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=t[t.length-1],t.toString("utf16le",e,t.length-1)}function c(t){var e=t&&t.length?this.write(t):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return e+this.lastChar.toString("utf16le",0,r)}return e}function l(t,e){var r=(t.length-e)%3;return 0===r?t.toString("base64",e):(this.lastNeed=3-r,this.lastTotal=3,1===r?this.lastChar[0]=t[t.length-1]:(this.lastChar[0]=t[t.length-2],this.lastChar[1]=t[t.length-1]),t.toString("base64",e,t.length-r))}function f(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+this.lastChar.toString("base64",0,3-this.lastNeed):e}function h(t){return t.toString(this.encoding)}function p(t){return t&&t.length?this.write(t):""}e.I=o,o.prototype.write=function(t){if(0===t.length)return"";var e,r;if(this.lastNeed){if(void 0===(e=this.fillLast(t)))return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<t.length?e?e+this.text(t,r):this.text(t,r):e||""},o.prototype.end=function(t){var e=t&&t.length?this.write(t):"";return this.lastNeed?e+"�":e},o.prototype.text=function(t,e){var r=function(t,e,r){var n=e.length-1;if(n<r)return 0;var i=s(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=s(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=s(e[n]))>=0?(i>0&&(2===i?i=0:t.lastNeed=i-3),i):0}(this,t,e);if(!this.lastNeed)return t.toString("utf8",e);this.lastTotal=r;var n=t.length-(r-this.lastNeed);return t.copy(this.lastChar,0,n),t.toString("utf8",e,n)},o.prototype.fillLast=function(t){if(this.lastNeed<=t.length)return t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);t.copy(this.lastChar,this.lastTotal-this.lastNeed,0,t.length),this.lastNeed-=t.length}},1061:(t,e,r)=>{var n=r(2113);function i(t){return t.name||t.toString().match(/function (.*?)\s*\(/)[1]}function o(t){return n.Nil(t)?"":i(t.constructor)}function s(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function a(t){return n.Function(t)?t.toJSON?t.toJSON():i(t):n.Array(t)?"Array":t&&n.Object(t)?"Object":void 0!==t?t:""}function u(t,e,r){var i=function(t){return n.Function(t)?"":n.String(t)?JSON.stringify(t):t&&n.Object(t)?"":t}(e);return"Expected "+a(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),s(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function l(t,e,r,n,i){t?(i=i||o(n),this.message=function(t,e,r,n,i){var o='" of type ';return"key"===e&&(o='" with key type '),u('property "'+a(r)+o+a(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',s(this,c),this.__label=r,this.__property=e,this.__type=t,this.__value=n,this.__valueTypeName=i}c.prototype=Object.create(Error.prototype),c.prototype.constructor=c,l.prototype=Object.create(Error.prototype),l.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:l,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof l?(e=e+"."+t.__property,t=new l(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new l(t.__type,e,r,t.__value,t.__valueTypeName)),s(t),t},tfJSON:a,getValueTypeName:o}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function s(t){return n.isBuffer(t)}function a(t){return"string"==typeof t&&/^([0-9a-f]{2})+$/i.test(t)}function u(t,e){var r=t.toJSON();function n(n){if(!t(n))return!1;if(n.length===e)return!0;throw o.tfCustomError(r+"(Length: "+e+")",r+"(Length: "+n.length+")")}return n.toJSON=function(){return r},n}var c=u.bind(null,i.Array),l=u.bind(null,s),f=u.bind(null,a),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:s,BufferN:l,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:a,HexN:f,Int8:function(t){return t<<24>>24===t},Int16:function(t){return t<<16>>16===t},Int32:function(t){return(0|t)===t},Int53:function(t){return"number"==typeof t&&t>=-p&&t<=p&&Math.floor(t)===t},Range:function(t,e,r){function n(n,i){return r(n,i)&&n>t&&n<e}return r=r||i.Number,n.toJSON=function(){return`${r.toJSON()} between [${t}, ${e}]`},n},StringN:h,UInt8:function(t){return(255&t)===t},UInt16:function(t){return(65535&t)===t},UInt32:function(t){return t>>>0===t},UInt53:function(t){return"number"==typeof t&&t>=0&&t<=p&&Math.floor(t)===t}};for(var y in d)d[y].toJSON=function(t){return t}.bind(null,y);t.exports=d},8676:(t,e,r)=>{var n=r(1061),i=r(2113),o=n.tfJSON,s=n.TfTypeError,a=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,l={arrayOf:function(t,e){function r(r,n){return!!i.Array(r)&&!i.Nil(r)&&!(void 0!==e.minLength&&r.length<e.minLength)&&!(void 0!==e.maxLength&&r.length>e.maxLength)&&(void 0===e.length||r.length===e.length)&&r.every((function(e,r){try{return h(t,e,n)}catch(t){throw u(t,r)}}))}return t=f(t),e=e||{},r.toJSON=function(){var r="["+o(t)+"]";return void 0!==e.length?r+="{"+e.length+"}":void 0===e.minLength&&void 0===e.maxLength||(r+="{"+(void 0===e.minLength?0:e.minLength)+","+(void 0===e.maxLength?1/0:e.maxLength)+"}"),r},r},maybe:function t(e){function r(r,n){return i.Nil(r)||e(r,n,t)}return e=f(e),r.toJSON=function(){return"?"+o(e)},r},map:function(t,e){function r(r,n){if(!i.Object(r))return!1;if(i.Nil(r))return!1;for(var o in r){try{e&&h(e,o,n)}catch(t){throw u(t,o,"key")}try{var s=r[o];h(t,s,n)}catch(t){throw u(t,o)}}return!0}return t=f(t),e&&(e=f(e)),r.toJSON=e?function(){return"{"+o(e)+": "+o(t)+"}"}:function(){return"{"+o(t)+"}"},r},object:function(t){var e={};for(var r in t)e[r]=f(t[r]);function n(t,r){if(!i.Object(t))return!1;if(i.Nil(t))return!1;var n;try{for(n in e)h(e[n],t[n],r)}catch(t){throw u(t,n)}if(r)for(n in t)if(!e[n])throw new a(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(f);function e(e,r){return t.some((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join("|")},e},allOf:function(){var t=[].slice.call(arguments).map(f);function e(e,r){return t.every((function(t){try{return h(t,e,r)}catch(t){return!1}}))}return e.toJSON=function(){return t.map(o).join(" & ")},e},quacksLike:function(t){function e(e){return t===c(e)}return e.toJSON=function(){return t},e},tuple:function(){var t=[].slice.call(arguments).map(f);function e(e,r){return!i.Nil(e)&&!i.Nil(e.length)&&(!r||e.length===t.length)&&t.every((function(t,n){try{return h(t,e[n],r)}catch(t){throw u(t,n)}}))}return e.toJSON=function(){return"("+t.map(o).join(", ")+")"},e},value:function(t){function e(e){return e===t}return e.toJSON=function(){return t},e}};function f(t){if(i.String(t))return"?"===t[0]?l.maybe(t.slice(1)):i[t]||l.quacksLike(t);if(t&&i.Object(t)){if(i.Array(t)){if(1!==t.length)throw new TypeError("Expected compile() parameter of type Array of length 1");return l.arrayOf(t[0])}return l.object(t)}return i.Function(t)?t:l.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new s(n||t,e)}return h(f(t),e,r)}for(var p in l.oneOf=l.anyOf,i)h[p]=i[p];for(p in l)h[p]=l[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=f,h.TfTypeError=s,h.TfPropertyTypeError=a,t.exports=h},2113:t=>{var e={Array:function(t){return null!=t&&t.constructor===Array},Boolean:function(t){return"boolean"==typeof t},Function:function(t){return"function"==typeof t},Nil:function(t){return null==t},Number:function(t){return"number"==typeof t},Object:function(t){return"object"==typeof t},String:function(t){return"string"==typeof t},"":function(){return!0}};for(var r in e.Null=e.Nil,e)e[r].toJSON=function(t){return t}.bind(null,r);t.exports=e},4643:(t,e,r)=>{function n(t){try{if(!r.g.localStorage)return!1}catch(t){return!1}var e=r.g.localStorage[t];return null!=e&&"true"===String(e).toLowerCase()}t.exports=function(t,e){if(n("noDeprecation"))return t;var r=!1;return function(){if(!r){if(n("throwDeprecation"))throw new Error(e);n("traceDeprecation")?console.trace(e):console.warn(e),r=!0}return t.apply(this,arguments)}}},8469:(t,e,r)=>{var n=r(2861).Buffer,i=9007199254740991;function o(t){if(t<0||t>i||t%1!=0)throw new RangeError("value out of range")}function s(t){return o(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,i){if(o(e),r||(r=n.allocUnsafe(s(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return i||(i=0),e<253?(r.writeUInt8(e,i),t.bytes=1):e<=65535?(r.writeUInt8(253,i),r.writeUInt16LE(e,i+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,i),r.writeUInt32LE(e,i+1),t.bytes=5):(r.writeUInt8(255,i),r.writeUInt32LE(e>>>0,i+1),r.writeUInt32LE(e/4294967296|0,i+5),t.bytes=9),r},decode:function t(e,r){if(!n.isBuffer(e))throw new TypeError("buffer must be a Buffer instance");r||(r=0);var i=e.readUInt8(r);if(i<253)return t.bytes=1,i;if(253===i)return t.bytes=3,e.readUInt16LE(r+1);if(254===i)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var s=e.readUInt32LE(r+1),a=4294967296*e.readUInt32LE(r+5)+s;return o(a),a},encodingLength:s}},7513:(t,e,r)=>{var n=r(8287).Buffer,i=r(7701);function o(t,e){if(void 0!==e&&t[0]!==e)throw new Error("Invalid network version");if(33===t.length)return{version:t[0],privateKey:t.slice(1,33),compressed:!1};if(34!==t.length)throw new Error("Invalid WIF length");if(1!==t[33])throw new Error("Invalid compression flag");return{version:t[0],privateKey:t.slice(1,33),compressed:!0}}function s(t,e,r){var i=new n(r?34:33);return i.writeUInt8(t,0),e.copy(i,1),r&&(i[33]=1),i}t.exports={decode:function(t,e){return o(i.decode(t),e)},decodeRaw:o,encode:function(t,e,r){return"number"==typeof t?i.encode(s(t,e,r)):i.encode(s(t.version,t.privateKey,t.compressed))},encodeRaw:s}},1448:(t,e,r)=>{var n=r(2861).Buffer;t.exports=function(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var e=new Uint8Array(256),r=0;r<e.length;r++)e[r]=255;for(var i=0;i<t.length;i++){var o=t.charAt(i),s=o.charCodeAt(0);if(255!==e[s])throw new TypeError(o+" is ambiguous");e[s]=i}var a=t.length,u=t.charAt(0),c=Math.log(a)/Math.log(256),l=Math.log(256)/Math.log(a);function f(t){if("string"!=typeof t)throw new TypeError("Expected String");if(0===t.length)return n.alloc(0);for(var r=0,i=0,o=0;t[r]===u;)i++,r++;for(var s=(t.length-r)*c+1>>>0,l=new Uint8Array(s);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var h=0,p=s-1;(0!==f||h<o)&&-1!==p;p--,h++)f+=a*l[p]>>>0,l[p]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");o=h,r++}for(var d=s-o;d!==s&&0===l[d];)d++;var y=n.allocUnsafe(i+(s-d));y.fill(0,0,i);for(var g=i;d!==s;)y[g++]=l[d++];return y}return{encode:function(e){if((Array.isArray(e)||e instanceof Uint8Array)&&(e=n.from(e)),!n.isBuffer(e))throw new TypeError("Expected Buffer");if(0===e.length)return"";for(var r=0,i=0,o=0,s=e.length;o!==s&&0===e[o];)o++,r++;for(var c=(s-o)*l+1>>>0,f=new Uint8Array(c);o!==s;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*f[d]>>>0,f[d]=h%a>>>0,h=h/a>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===f[y];)y++;for(var g=u.repeat(r);y<c;++y)g+=t.charAt(f[y]);return g},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},3119:(t,e,r)=>{var n=r(1448);t.exports=n("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz")},8016:(t,e,r)=>{var n=r(3119),i=r(2861).Buffer;t.exports=function(t){function e(e){var r=e.slice(0,-4),n=e.slice(-4),i=t(r);if(!(n[0]^i[0]|n[1]^i[1]|n[2]^i[2]|n[3]^i[3]))return r}return{encode:function(e){var r=t(e);return n.encode(i.concat([e,r],e.length+4))},decode:function(t){var r=e(n.decode(t));if(!r)throw new Error("Invalid checksum");return r},decodeUnsafe:function(t){var r=n.decodeUnsafe(t);if(r)return e(r)}}}},7701:(t,e,r)=>{var n=r(7108),i=r(8016);t.exports=i((function(t){var e=n("sha256").update(t).digest();return n("sha256").update(e).digest()}))},3184:t=>{var e,r,n=t.exports={};function i(){throw new Error("setTimeout has not been defined")}function o(){throw new Error("clearTimeout has not been defined")}function s(t){if(e===setTimeout)return setTimeout(t,0);if((e===i||!e)&&setTimeout)return e=setTimeout,setTimeout(t,0);try{return e(t,0)}catch(r){try{return e.call(null,t,0)}catch(r){return e.call(this,t,0)}}}!function(){try{e="function"==typeof setTimeout?setTimeout:i}catch(t){e=i}try{r="function"==typeof clearTimeout?clearTimeout:o}catch(t){r=o}}();var a,u=[],c=!1,l=-1;function f(){c&&a&&(c=!1,a.length?u=a.concat(u):l=-1,u.length&&h())}function h(){if(!c){var t=s(f);c=!0;for(var e=u.length;e;){for(a=u,u=[];++l<e;)a&&a[l].run();l=-1,e=u.length}a=null,c=!1,function(t){if(r===clearTimeout)return clearTimeout(t);if((r===o||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(t);try{return r(t)}catch(e){try{return r.call(null,t)}catch(e){return r.call(this,t)}}}(t)}}function p(t,e){this.fun=t,this.array=e}function d(){}n.nextTick=function(t){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];u.push(new p(t,e)),1!==u.length||c||s(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},n.title="browser",n.browser=!0,n.env={},n.argv=[],n.version="",n.versions={},n.on=d,n.addListener=d,n.once=d,n.off=d,n.removeListener=d,n.removeAllListeners=d,n.emit=d,n.prependListener=d,n.prependOnceListener=d,n.listeners=function(t){return[]},n.binding=function(t){throw new Error("process.binding is not supported")},n.cwd=function(){return"/"},n.chdir=function(t){throw new Error("process.chdir is not supported")},n.umask=function(){return 0}},4923:()=>{},8460:()=>{},2382:()=>{},3779:()=>{},7199:()=>{}},n={};function i(t){var e=n[t];if(void 0!==e)return e.exports;var o=n[t]={exports:{}};return r[t](o,o.exports,i),o.exports}e=Object.getPrototypeOf?t=>Object.getPrototypeOf(t):t=>t.__proto__,i.t=function(r,n){if(1&n&&(r=this(r)),8&n)return r;if("object"==typeof r&&r){if(4&n&&r.__esModule)return r;if(16&n&&"function"==typeof r.then)return r}var o=Object.create(null);i.r(o);var s={};t=t||[null,e({}),e([]),e(e)];for(var a=2&n&&r;"object"==typeof a&&!~t.indexOf(a);a=e(a))Object.getOwnPropertyNames(a).forEach((t=>s[t]=()=>r[t]));return s.default=()=>r,i.d(o,s),o},i.d=(t,e)=>{for(var r in e)i.o(e,r)&&!i.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},i.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var o={};(()=>{i.d(o,{y3:()=>Wc,Lk:()=>Wl,Uq:()=>Gf,EI:()=>bf,JL:()=>Oh,M7:()=>Af,G7:()=>ph,eB:()=>ll,Q9:()=>bl,rO:()=>_l,qT:()=>U,Yy:()=>H,JV:()=>jf,Bc:()=>J,r:()=>tf,W4:()=>r,rs:()=>xl,OB:()=>k,PN:()=>f,Mw:()=>w,GE:()=>il,z5:()=>Dl,XV:()=>$c,Wj:()=>wf,PF:()=>Vf,$7:()=>e,rE:()=>n});var t={};i.r(t),i.d(t,{OG:()=>ha,My:()=>na,bytesToNumberBE:()=>sa,lX:()=>aa,Id:()=>fa,fg:()=>ya,qj:()=>la,hexToBytes:()=>oa,lq:()=>ua,z:()=>ca,Q5:()=>ba});var e={};i.r(e),i.d(e,{ABIDataTypes:()=>Wc,AbstractRpcProvider:()=>Wl,BaseContract:()=>Gf,BitcoinAbiTypes:()=>bf,BitcoinAddress:()=>Oh,BitcoinInterface:()=>Af,BitcoinUtils:()=>ph,Block:()=>ll,CallResult:()=>bl,ContractData:()=>_l,DeploymentTransaction:()=>U,GenericTransaction:()=>H,IBaseContract:()=>jf,InteractionTransaction:()=>J,JSONRpcProvider:()=>tf,OPNetTransactionTypes:()=>r,StoredValue:()=>xl,TransactionBase:()=>k,TransactionInput:()=>f,TransactionOutput:()=>w,TransactionParser:()=>il,TransactionReceipt:()=>Dl,UTXO:()=>$c,WebSocketRpcProvider:()=>wf,getContract:()=>Vf,version:()=>n});var r,n="1.0.15";function s(t){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},s(t)}function a(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,l(n.key),n)}}function u(t,e,r){return e&&a(t.prototype,e),r&&a(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function c(t,e,r){return(e=l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function l(t){var e=function(t,e){if("object"!=s(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=s(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==s(e)?e:e+""}!function(t){t.Generic="Generic",t.Deployment="Deployment",t.Interaction="Interaction"}(r||(r={}));var f=u((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),c(this,"originalTransactionId",void 0),c(this,"outputTransactionIndex",void 0),c(this,"scriptSignature",void 0),c(this,"sequenceId",void 0),c(this,"transactionInWitness",[]),this.originalTransactionId=e.originalTransactionId,this.outputTransactionIndex=e.outputTransactionIndex,this.scriptSignature=e.scriptSignature,this.sequenceId=e.sequenceId,this.transactionInWitness=e.transactionInWitness||[]})),h=i(1757),p=i(8287).Buffer;function d(t){return d="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},d(t)}function y(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,b(n.key),n)}}function g(t,e,r){return(e=b(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function b(t){var e=function(t,e){if("object"!=d(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=d(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==d(e)?e:e+""}var w=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),g(this,"value",void 0),g(this,"index",void 0),g(this,"scriptPubKey",void 0),g(this,"script",void 0),this.value=this.convertValue(e.value),this.index=e.index,this.scriptPubKey=e.scriptPubKey,this.script=h.K$.decompile(p.from(this.scriptPubKey.hex,"hex"))},(e=[{key:"convertValue",value:function(t){return BigInt(t)}}])&&y(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),m=i(8287).Buffer;function v(t){return v="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},v(t)}function E(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,_(n.key),n)}}function A(t,e,r){return e&&E(t.prototype,e),r&&E(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function S(t,e,r){return(e=_(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _(t){var e=function(t,e){if("object"!=v(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=v(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==v(e)?e:e+""}var k=A((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),S(this,"id",void 0),S(this,"hash",void 0),S(this,"index",void 0),S(this,"burnedBitcoin",void 0),S(this,"revert",void 0),S(this,"inputs",void 0),S(this,"outputs",void 0),S(this,"OPNetType",void 0),this.id=e.id,this.hash=e.hash,this.index=e.index,this.burnedBitcoin=BigInt(e.burnedBitcoin)||0n,this.inputs=e.inputs.map((function(t){return new f(t)})),this.outputs=e.outputs.map((function(t){return new w(t)})),this.revert=e.revert?m.from(e.revert,"base64"):void 0,this.OPNetType=e.OPNetType})),T=i(8287).Buffer;function P(t){return P="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},P(t)}function I(t,e,r){return e=x(e),function(t,e){if(e&&("object"===P(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,O()?Reflect.construct(e,r||[],x(t).constructor):e.apply(t,r))}function O(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(O=function(){return!!t})()}function x(t){return x=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},x(t)}function B(t,e){return B=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},B(t,e)}function R(t,e,r){return(e=N(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function N(t){var e=function(t,e){if("object"!=P(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=P(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==P(e)?e:e+""}var U=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),R(r=I(this,e,[t]),"contractAddress",void 0),R(r,"virtualAddress",void 0),R(r,"bytecode",void 0),R(r,"wasCompressed",void 0),R(r,"deployerPubKey",void 0),R(r,"deployerAddress",void 0),R(r,"contractSeed",void 0),R(r,"contractSaltHash",void 0),r.contractAddress=t.contractAddress,r.virtualAddress=t.virtualAddress,r.bytecode=T.from(t.bytecode,"base64"),r.wasCompressed=t.wasCompressed,r.deployerPubKey=T.from(t.deployerPubKey,"base64"),r.deployerAddress=t.deployerAddress,r.contractSeed=T.from(t.contractSeed,"base64"),r.contractSaltHash=T.from(t.contractSaltHash,"base64"),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&B(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(k);function C(t){return C="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},C(t)}function L(t,e,r){return e=M(e),function(t,e){if(e&&("object"===C(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,D()?Reflect.construct(e,r||[],M(t).constructor):e.apply(t,r))}function D(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(D=function(){return!!t})()}function M(t){return M=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},M(t)}function F(t,e){return F=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},F(t,e)}var H=function(t){function e(t){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),L(this,e,[t])}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&F(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(k),j=i(8287);function G(t){return G="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},G(t)}function V(t,e,r){return e=W(e),function(t,e){if(e&&("object"===G(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,K()?Reflect.construct(e,r||[],W(t).constructor):e.apply(t,r))}function K(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(K=function(){return!!t})()}function W(t){return W=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},W(t)}function z(t,e){return z=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},z(t,e)}function q(t,e,r){return(e=Q(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Q(t){var e=function(t,e){if("object"!=G(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=G(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==G(e)?e:e+""}var J=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),q(r=V(this,e,[t]),"calldata",void 0),q(r,"senderPubKeyHash",void 0),q(r,"contractSecret",void 0),q(r,"interactionPubKey",void 0),q(r,"wasCompressed",void 0),q(r,"events",void 0),q(r,"receipt",void 0),q(r,"receiptProofs",void 0),r.calldata=j.Buffer.from(t.calldata,"base64"),r.senderPubKeyHash=j.Buffer.from(t.senderPubKeyHash,"base64"),r.contractSecret=j.Buffer.from(t.contractSecret,"base64"),r.interactionPubKey=j.Buffer.from(t.interactionPubKey,"base64"),r.wasCompressed=t.wasCompressed,r.events=t.events,r.receipt=t.receipt?j.Buffer.from(t.receipt,"base64"):void 0,r.receiptProofs=t.receiptProofs,r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&z(t,e)}(e,t),r=e,Object.defineProperty(r,"prototype",{writable:!1}),r;var r}(k);const X="6.12.1";function Y(t,e,r){const n=e.split("|").map((t=>t.trim()));for(let r=0;r<n.length;r++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof t===e)return}const i=new Error(`invalid value for type ${e}`);throw i.code="INVALID_ARGUMENT",i.argument=`value.${r}`,i.value=t,i}async function Z(t){const e=Object.keys(t);return(await Promise.all(e.map((e=>Promise.resolve(t[e]))))).reduce(((t,r,n)=>(t[e[n]]=r,t)),{})}function $(t,e,r){for(let n in e){let i=e[n];const o=r?r[n]:null;o&&Y(i,o,n),Object.defineProperty(t,n,{enumerable:!0,value:i,writable:!1})}}function tt(t){if(null==t)return"null";if(Array.isArray(t))return"[ "+t.map(tt).join(", ")+" ]";if(t instanceof Uint8Array){const e="0123456789abcdef";let r="0x";for(let n=0;n<t.length;n++)r+=e[t[n]>>4],r+=e[15&t[n]];return r}if("object"==typeof t&&"function"==typeof t.toJSON)return tt(t.toJSON());switch(typeof t){case"boolean":case"symbol":case"number":return t.toString();case"bigint":return BigInt(t).toString();case"string":return JSON.stringify(t);case"object":{const e=Object.keys(t);return e.sort(),"{ "+e.map((e=>`${tt(e)}: ${tt(t[e])}`)).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function et(t,e){return t&&t.code===e}function rt(t){return et(t,"CALL_EXCEPTION")}function nt(t,e,r){let n,i=t;{const n=[];if(r){if("message"in r||"code"in r||"name"in r)throw new Error(`value will overwrite populated values: ${tt(r)}`);for(const t in r){if("shortMessage"===t)continue;const e=r[t];n.push(t+"="+tt(e))}}n.push(`code=${e}`),n.push(`version=${X}`),n.length&&(t+=" ("+n.join(", ")+")")}switch(e){case"INVALID_ARGUMENT":n=new TypeError(t);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":n=new RangeError(t);break;default:n=new Error(t)}return $(n,{code:e}),r&&Object.assign(n,r),null==n.shortMessage&&$(n,{shortMessage:i}),n}function it(t,e,r,n){if(!t)throw nt(e,r,n)}function ot(t,e,r,n){it(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}function st(t,e,r){null==r&&(r=""),r&&(r=": "+r),it(t>=e,"missing arguemnt"+r,"MISSING_ARGUMENT",{count:t,expectedCount:e}),it(t<=e,"too many arguments"+r,"UNEXPECTED_ARGUMENT",{count:t,expectedCount:e})}const at=["NFD","NFC","NFKD","NFKC"].reduce(((t,e)=>{try{if("test"!=="test".normalize(e))throw new Error("bad");if("NFD"===e){if(String.fromCharCode(233).normalize("NFD")!==String.fromCharCode(101,769))throw new Error("broken")}t.push(e)}catch(t){}return t}),[]);function ut(t,e,r){if(null==r&&(r=""),t!==e){let t=r,e="new";r&&(t+=".",e+=" "+r),it(!1,`private constructor; use ${t}from* methods`,"UNSUPPORTED_OPERATION",{operation:e})}}function ct(t,e,r){if(t instanceof Uint8Array)return r?new Uint8Array(t):t;if("string"==typeof t&&t.match(/^0x([0-9a-f][0-9a-f])*$/i)){const e=new Uint8Array((t.length-2)/2);let r=2;for(let n=0;n<e.length;n++)e[n]=parseInt(t.substring(r,r+2),16),r+=2;return e}ot(!1,"invalid BytesLike value",e||"value",t)}function lt(t,e){return ct(t,e,!1)}function ft(t,e){return ct(t,e,!0)}function ht(t,e){return!("string"!=typeof t||!t.match(/^0x[0-9A-Fa-f]*$/)||"number"==typeof e&&t.length!==2+2*e||!0===e&&t.length%2!=0)}function pt(t){return ht(t,!0)||t instanceof Uint8Array}const dt="0123456789abcdef";function yt(t){const e=lt(t);let r="0x";for(let t=0;t<e.length;t++){const n=e[t];r+=dt[(240&n)>>4]+dt[15&n]}return r}function gt(t){return"0x"+t.map((t=>yt(t).substring(2))).join("")}function bt(t){return ht(t,!0)?(t.length-2)/2:lt(t).length}function wt(t,e,r){const n=lt(t);return null!=r&&r>n.length&&it(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r}),yt(n.slice(null==e?0:e,null==r?n.length:r))}function mt(t,e,r){const n=lt(t);it(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),r?i.set(n,e-n.length):i.set(n,0),yt(i)}function vt(t,e){return mt(t,e,!0)}const Et=BigInt(0),At=BigInt(1),St=9007199254740991;function _t(t,e){let r=Tt(t,"value");const n=BigInt(xt(e,"width")),i=At<<n-At;return r<Et?(r=-r,it(r<=i,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),(~r&(At<<n)-At)+At):(it(r<i,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:t}),r)}function kt(t,e){const r=Pt(t,"value"),n=BigInt(xt(e,"bits"));return r&(At<<n)-At}function Tt(t,e){switch(typeof t){case"bigint":return t;case"number":return ot(Number.isInteger(t),"underflow",e||"value",t),ot(t>=-St&&t<=St,"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(r){ot(!1,`invalid BigNumberish string: ${r.message}`,e||"value",t)}}ot(!1,"invalid BigNumberish value",e||"value",t)}function Pt(t,e){const r=Tt(t,e);return it(r>=Et,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:t}),r}const It="0123456789abcdef";function Ot(t){if(t instanceof Uint8Array){let e="0x0";for(const r of t)e+=It[r>>4],e+=It[15&r];return BigInt(e)}return Tt(t)}function xt(t,e){switch(typeof t){case"bigint":return ot(t>=-St&&t<=St,"overflow",e||"value",t),Number(t);case"number":return ot(Number.isInteger(t),"underflow",e||"value",t),ot(t>=-St&&t<=St,"overflow",e||"value",t),t;case"string":try{if(""===t)throw new Error("empty string");return xt(BigInt(t),e)}catch(r){ot(!1,`invalid numeric string: ${r.message}`,e||"value",t)}}ot(!1,"invalid numeric value",e||"value",t)}function Bt(t,e){let r=Pt(t,"value").toString(16);if(null==e)r.length%2&&(r="0"+r);else{const n=xt(e,"width");for(it(2*n>=r.length,`value exceeds width (${n} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:t});r.length<2*n;)r="0"+r}return"0x"+r}function Rt(t){const e=Pt(t,"value");if(e===Et)return new Uint8Array([]);let r=e.toString(16);r.length%2&&(r="0"+r);const n=new Uint8Array(r.length/2);for(let t=0;t<n.length;t++){const e=2*t;n[t]=parseInt(r.substring(e,e+2),16)}return n}function Nt(t){let e=yt(pt(t)?t:Rt(t)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return""===e&&(e="0"),"0x"+e}const Ut=32,Ct=new Uint8Array(Ut),Lt=["then"],Dt={};function Mt(t,e){const r=new Error(`deferred error during ABI decoding triggered accessing ${t}`);throw r.error=e,r}class Ft extends Array{#t;constructor(...t){const e=t[0];let r=t[1],n=(t[2]||[]).slice(),i=!0;e!==Dt&&(r=t,n=[],i=!1),super(r.length),r.forEach(((t,e)=>{this[e]=t}));const o=n.reduce(((t,e)=>("string"==typeof e&&t.set(e,(t.get(e)||0)+1),t)),new Map);if(this.#t=Object.freeze(r.map(((t,e)=>{const r=n[e];return null!=r&&1===o.get(r)?r:null}))),i)return Object.freeze(this),new Proxy(this,{get:(t,e,r)=>{if("string"==typeof e){if(e.match(/^[0-9]+$/)){const r=xt(e,"%index");if(r<0||r>=this.length)throw new RangeError("out of result range");const n=t[r];return n instanceof Error&&Mt(`index ${r}`,n),n}if(Lt.indexOf(e)>=0)return Reflect.get(t,e,r);const n=t[e];if(n instanceof Function)return function(...e){return n.apply(this===r?t:this,e)};if(!(e in t))return t.getValue.apply(this===r?t:this,[e])}return Reflect.get(t,e,r)}})}toArray(t){const e=[];return this.forEach(((r,n)=>{r instanceof Error&&Mt(`index ${n}`,r),t&&r instanceof Ft&&(r=r.toArray(t)),e.push(r)})),e}toObject(t){return this.#t.reduce(((e,r,n)=>{if(it(null!=r,"value at index ${ index } unnamed","UNSUPPORTED_OPERATION",{operation:"toObject()"}),!(r in e)){let n=this.getValue(r);t&&n instanceof Ft&&(n=n.toObject(t)),e[r]=n}return e}),{})}slice(t,e){null==t&&(t=0),t<0&&(t+=this.length)<0&&(t=0),null==e&&(e=this.length),e<0&&(e+=this.length)<0&&(e=0),e>this.length&&(e=this.length);const r=[],n=[];for(let i=t;i<e;i++)r.push(this[i]),n.push(this.#t[i]);return new Ft(Dt,r,n)}filter(t,e){const r=[],n=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&Mt(`index ${i}`,o),t.call(e,o,i,this)&&(r.push(o),n.push(this.#t[i]))}return new Ft(Dt,r,n)}map(t,e){const r=[];for(let n=0;n<this.length;n++){const i=this[n];i instanceof Error&&Mt(`index ${n}`,i),r.push(t.call(e,i,n,this))}return r}getValue(t){const e=this.#t.indexOf(t);if(-1===e)return;const r=this[e];return r instanceof Error&&Mt(`property ${JSON.stringify(t)}`,r.error),r}static fromItems(t,e){return new Ft(Dt,t,e)}}function Ht(t){let e=Rt(t);return it(e.length<=Ut,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:Ut,offset:e.length}),e.length!==Ut&&(e=ft(gt([Ct.slice(e.length%Ut),e]))),e}class jt{name;type;localName;dynamic;constructor(t,e,r,n){$(this,{name:t,type:e,localName:r,dynamic:n},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(t,e){ot(!1,t,this.localName,e)}}class Gt{#e;#r;constructor(){this.#e=[],this.#r=0}get data(){return gt(this.#e)}get length(){return this.#r}#n(t){return this.#e.push(t),this.#r+=t.length,t.length}appendWriter(t){return this.#n(ft(t.data))}writeBytes(t){let e=ft(t);const r=e.length%Ut;return r&&(e=ft(gt([e,Ct.slice(r)]))),this.#n(e)}writeValue(t){return this.#n(Ht(t))}writeUpdatableValue(){const t=this.#e.length;return this.#e.push(Ct),this.#r+=Ut,e=>{this.#e[t]=Ht(e)}}}class Vt{allowLoose;#e;#i;#o;#s;#a;constructor(t,e,r){$(this,{allowLoose:!!e}),this.#e=ft(t),this.#o=0,this.#s=null,this.#a=null!=r?r:1024,this.#i=0}get data(){return yt(this.#e)}get dataLength(){return this.#e.length}get consumed(){return this.#i}get bytes(){return new Uint8Array(this.#e)}#u(t){if(this.#s)return this.#s.#u(t);this.#o+=t,it(this.#a<1||this.#o<=this.#a*this.dataLength,`compressed ABI data exceeds inflation ratio of ${this.#a} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:ft(this.#e),offset:this.#i,length:t,info:{bytesRead:this.#o,dataLength:this.dataLength}})}#c(t,e,r){let n=Math.ceil(e/Ut)*Ut;return this.#i+n>this.#e.length&&(this.allowLoose&&r&&this.#i+e<=this.#e.length?n=e:it(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:ft(this.#e),length:this.#e.length,offset:this.#i+n})),this.#e.slice(this.#i,this.#i+n)}subReader(t){const e=new Vt(this.#e.slice(this.#i+t),this.allowLoose,this.#a);return e.#s=this,e}readBytes(t,e){let r=this.#c(0,t,!!e);return this.#u(t),this.#i+=r.length,r.slice(0,t)}readValue(){return Ot(this.readBytes(Ut))}readIndex(){return xt(Ot(this.readBytes(Ut)))}}function Kt(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Wt(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 zt(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 qt(t,e){Wt(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}const Qt=BigInt(2**32-1),Jt=BigInt(32);function Xt(t,e=!1){return e?{h:Number(t&Qt),l:Number(t>>Jt&Qt)}:{h:0|Number(t>>Jt&Qt),l:0|Number(t&Qt)}}function Yt(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let i=0;i<t.length;i++){const{h:o,l:s}=Xt(t[i],e);[r[i],n[i]]=[o,s]}return[r,n]}const Zt=(t,e,r)=>t<<r|e>>>32-r,$t=(t,e,r)=>e<<r|t>>>32-r,te=(t,e,r)=>e<<r-32|t>>>64-r,ee=(t,e,r)=>t<<r-32|e>>>64-r,re={fromBig:Xt,split:Yt,toBig:(t,e)=>BigInt(t>>>0)<<Jt|BigInt(e>>>0),shrSH:(t,e,r)=>t>>>r,shrSL:(t,e,r)=>t<<32-r|e>>>r,rotrSH:(t,e,r)=>t>>>r|e<<32-r,rotrSL:(t,e,r)=>t<<32-r|e>>>r,rotrBH:(t,e,r)=>t<<64-r|e>>>r-32,rotrBL:(t,e,r)=>t>>>r-32|e<<64-r,rotr32H:(t,e)=>e,rotr32L:(t,e)=>t,rotlSH:Zt,rotlSL:$t,rotlBH:te,rotlBL:ee,add:function(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}},add3L:(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0),add3H:(t,e,r,n)=>e+r+n+(t/2**32|0)|0,add4L:(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0),add4H:(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0,add5H:(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0,add5L:(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0)},ne=t=>t instanceof Uint8Array,ie=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),oe=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function se(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!ne(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class ae{clone(){return this._cloneInto()}}function ue(t){const e=e=>t().update(se(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}const[ce,le,fe]=[[],[],[]],he=BigInt(0),pe=BigInt(1),de=BigInt(2),ye=BigInt(7),ge=BigInt(256),be=BigInt(113);for(let t=0,e=pe,r=1,n=0;t<24;t++){[r,n]=[n,(2*r+3*n)%5],ce.push(2*(5*n+r)),le.push((t+1)*(t+2)/2%64);let i=he;for(let t=0;t<7;t++)e=(e<<pe^(e>>ye)*be)%ge,e&de&&(i^=pe<<(pe<<BigInt(t))-pe);fe.push(i)}const[we,me]=Yt(fe,!0),ve=(t,e,r)=>r>32?te(t,e,r):Zt(t,e,r),Ee=(t,e,r)=>r>32?ee(t,e,r):$t(t,e,r);class Ae extends ae{constructor(t,e,r,n=!1,i=24){if(super(),this.blockLen=t,this.suffix=e,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Kt(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");var o;this.state=new Uint8Array(200),this.state32=(o=this.state,new Uint32Array(o.buffer,o.byteOffset,Math.floor(o.byteLength/4)))}keccak(){!function(t,e=24){const r=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let e=0;e<10;e++)r[e]=t[e]^t[e+10]^t[e+20]^t[e+30]^t[e+40];for(let e=0;e<10;e+=2){const n=(e+8)%10,i=(e+2)%10,o=r[i],s=r[i+1],a=ve(o,s,1)^r[n],u=Ee(o,s,1)^r[n+1];for(let r=0;r<50;r+=10)t[e+r]^=a,t[e+r+1]^=u}let e=t[2],i=t[3];for(let r=0;r<24;r++){const n=le[r],o=ve(e,i,n),s=Ee(e,i,n),a=ce[r];e=t[a],i=t[a+1],t[a]=o,t[a+1]=s}for(let e=0;e<50;e+=10){for(let n=0;n<10;n++)r[n]=t[e+n];for(let n=0;n<10;n++)t[e+n]^=~r[(n+2)%10]&r[(n+4)%10]}t[0]^=we[n],t[1]^=me[n]}r.fill(0)}(this.state32,this.rounds),this.posOut=0,this.pos=0}update(t){zt(this);const{blockLen:e,state:r}=this,n=(t=se(t)).length;for(let i=0;i<n;){const o=Math.min(e-this.pos,n-i);for(let e=0;e<o;e++)r[this.pos++]^=t[i++];this.pos===e&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:e,pos:r,blockLen:n}=this;t[r]^=e,128&e&&r===n-1&&this.keccak(),t[n-1]^=128,this.keccak()}writeInto(t){zt(this,!1),Wt(t),this.finish();const e=this.state,{blockLen:r}=this;for(let n=0,i=t.length;n<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-n);t.set(e.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return Kt(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(qt(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:e,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return t||(t=new Ae(e,r,n,o,i)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=i,t.suffix=r,t.outputLen=n,t.enableXOF=o,t.destroyed=this.destroyed,t}}const Se=((t,e,r)=>ue((()=>new Ae(e,t,r))))(1,136,32);let _e=!1;const ke=function(t){return Se(t)};let Te=ke;function Pe(t){const e=lt(t,"data");return yt(Te(e))}Pe._=ke,Pe.lock=function(){_e=!0},Pe.register=function(t){if(_e)throw new TypeError("keccak256 is locked");Te=t},Object.freeze(Pe);const Ie=BigInt(0),Oe=BigInt(36);function xe(t){const e=(t=t.toLowerCase()).substring(2).split(""),r=new Uint8Array(40);for(let t=0;t<40;t++)r[t]=e[t].charCodeAt(0);const n=lt(Pe(r));for(let t=0;t<40;t+=2)n[t>>1]>>4>=8&&(e[t]=e[t].toUpperCase()),(15&n[t>>1])>=8&&(e[t+1]=e[t+1].toUpperCase());return"0x"+e.join("")}const Be={};for(let t=0;t<10;t++)Be[String(t)]=String(t);for(let t=0;t<26;t++)Be[String.fromCharCode(65+t)]=String(10+t);const Re=15;const Ne=function(){const t={};for(let e=0;e<36;e++)t["0123456789abcdefghijklmnopqrstuvwxyz"[e]]=BigInt(e);return t}();function Ue(t){if(ot("string"==typeof t,"invalid address","address",t),t.match(/^(0x)?[0-9a-fA-F]{40}$/)){t.startsWith("0x")||(t="0x"+t);const e=xe(t);return ot(!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}$/)){ot(t.substring(2,4)===function(t){let e=(t=(t=t.toUpperCase()).substring(4)+t.substring(0,2)+"00").split("").map((t=>Be[t])).join("");for(;e.length>=Re;){let t=e.substring(0,Re);e=parseInt(t,10)%97+e.substring(t.length)}let r=String(98-parseInt(e,10)%97);for(;r.length<2;)r="0"+r;return r}(t),"bad icap checksum","address",t);let e=function(t){t=t.toLowerCase();let e=Ie;for(let r=0;r<t.length;r++)e=e*Oe+Ne[t[r]];return e}(t.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return xe("0x"+e)}ot(!1,"invalid address","address",t)}const Ce={};function Le(t,e){let r=!1;return e<0&&(r=!0,e*=-1),new Fe(Ce,`${r?"":"u"}int${e}`,t,{signed:r,width:e})}function De(t,e){return new Fe(Ce,`bytes${e||""}`,t,{size:e})}const Me=Symbol.for("_ethers_typed");class Fe{type;value;#l;_typedSymbol;constructor(t,e,r,n){null==n&&(n=null),ut(Ce,t,"Typed"),$(this,{_typedSymbol:Me,type:e,value:r}),this.#l=n,this.format()}format(){if("array"===this.type)throw new Error("");if("dynamicArray"===this.type)throw new Error("");return"tuple"===this.type?`tuple(${this.value.map((t=>t.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"string"===this.type}get tupleName(){if("tuple"!==this.type)throw TypeError("not a tuple");return this.#l}get arrayLength(){if("array"!==this.type)throw TypeError("not an array");return!0===this.#l?-1:!1===this.#l?this.value.length:null}static from(t,e){return new Fe(Ce,t,e)}static uint8(t){return Le(t,8)}static uint16(t){return Le(t,16)}static uint24(t){return Le(t,24)}static uint32(t){return Le(t,32)}static uint40(t){return Le(t,40)}static uint48(t){return Le(t,48)}static uint56(t){return Le(t,56)}static uint64(t){return Le(t,64)}static uint72(t){return Le(t,72)}static uint80(t){return Le(t,80)}static uint88(t){return Le(t,88)}static uint96(t){return Le(t,96)}static uint104(t){return Le(t,104)}static uint112(t){return Le(t,112)}static uint120(t){return Le(t,120)}static uint128(t){return Le(t,128)}static uint136(t){return Le(t,136)}static uint144(t){return Le(t,144)}static uint152(t){return Le(t,152)}static uint160(t){return Le(t,160)}static uint168(t){return Le(t,168)}static uint176(t){return Le(t,176)}static uint184(t){return Le(t,184)}static uint192(t){return Le(t,192)}static uint200(t){return Le(t,200)}static uint208(t){return Le(t,208)}static uint216(t){return Le(t,216)}static uint224(t){return Le(t,224)}static uint232(t){return Le(t,232)}static uint240(t){return Le(t,240)}static uint248(t){return Le(t,248)}static uint256(t){return Le(t,256)}static uint(t){return Le(t,256)}static int8(t){return Le(t,-8)}static int16(t){return Le(t,-16)}static int24(t){return Le(t,-24)}static int32(t){return Le(t,-32)}static int40(t){return Le(t,-40)}static int48(t){return Le(t,-48)}static int56(t){return Le(t,-56)}static int64(t){return Le(t,-64)}static int72(t){return Le(t,-72)}static int80(t){return Le(t,-80)}static int88(t){return Le(t,-88)}static int96(t){return Le(t,-96)}static int104(t){return Le(t,-104)}static int112(t){return Le(t,-112)}static int120(t){return Le(t,-120)}static int128(t){return Le(t,-128)}static int136(t){return Le(t,-136)}static int144(t){return Le(t,-144)}static int152(t){return Le(t,-152)}static int160(t){return Le(t,-160)}static int168(t){return Le(t,-168)}static int176(t){return Le(t,-176)}static int184(t){return Le(t,-184)}static int192(t){return Le(t,-192)}static int200(t){return Le(t,-200)}static int208(t){return Le(t,-208)}static int216(t){return Le(t,-216)}static int224(t){return Le(t,-224)}static int232(t){return Le(t,-232)}static int240(t){return Le(t,-240)}static int248(t){return Le(t,-248)}static int256(t){return Le(t,-256)}static int(t){return Le(t,-256)}static bytes1(t){return De(t,1)}static bytes2(t){return De(t,2)}static bytes3(t){return De(t,3)}static bytes4(t){return De(t,4)}static bytes5(t){return De(t,5)}static bytes6(t){return De(t,6)}static bytes7(t){return De(t,7)}static bytes8(t){return De(t,8)}static bytes9(t){return De(t,9)}static bytes10(t){return De(t,10)}static bytes11(t){return De(t,11)}static bytes12(t){return De(t,12)}static bytes13(t){return De(t,13)}static bytes14(t){return De(t,14)}static bytes15(t){return De(t,15)}static bytes16(t){return De(t,16)}static bytes17(t){return De(t,17)}static bytes18(t){return De(t,18)}static bytes19(t){return De(t,19)}static bytes20(t){return De(t,20)}static bytes21(t){return De(t,21)}static bytes22(t){return De(t,22)}static bytes23(t){return De(t,23)}static bytes24(t){return De(t,24)}static bytes25(t){return De(t,25)}static bytes26(t){return De(t,26)}static bytes27(t){return De(t,27)}static bytes28(t){return De(t,28)}static bytes29(t){return De(t,29)}static bytes30(t){return De(t,30)}static bytes31(t){return De(t,31)}static bytes32(t){return De(t,32)}static address(t){return new Fe(Ce,"address",t)}static bool(t){return new Fe(Ce,"bool",!!t)}static bytes(t){return new Fe(Ce,"bytes",t)}static string(t){return new Fe(Ce,"string",t)}static array(t,e){throw new Error("not implemented yet")}static tuple(t,e){throw new Error("not implemented yet")}static overrides(t){return new Fe(Ce,"overrides",Object.assign({},t))}static isTyped(t){return t&&"object"==typeof t&&"_typedSymbol"in t&&t._typedSymbol===Me}static dereference(t,e){if(Fe.isTyped(t)){if(t.type!==e)throw new Error(`invalid type: expecetd ${e}, got ${t.type}`);return t.value}return t}}class He extends jt{constructor(t){super("address","address",t,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(t,e){let r=Fe.dereference(e,"string");try{r=Ue(r)}catch(t){return this._throwError(t.message,e)}return t.writeValue(r)}decode(t){return Ue(Bt(t.readValue(),20))}}class je extends jt{coder;constructor(t){super(t.name,t.type,"_",t.dynamic),this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,e){return this.coder.encode(t,e)}decode(t){return this.coder.decode(t)}}function Ge(t,e,r){let n=[];if(Array.isArray(r))n=r;else if(r&&"object"==typeof r){let t={};n=e.map((e=>{const n=e.localName;return it(n,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),it(!t[n],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:e},value:r}),t[n]=!0,r[n]}))}else ot(!1,"invalid tuple value","tuple",r);ot(e.length===n.length,"types/value length mismatch","tuple",r);let i=new Gt,o=new Gt,s=[];e.forEach(((t,e)=>{let r=n[e];if(t.dynamic){let e=o.length;t.encode(o,r);let n=i.writeUpdatableValue();s.push((t=>{n(t+e)}))}else t.encode(i,r)})),s.forEach((t=>{t(i.length)}));let a=t.appendWriter(i);return a+=t.appendWriter(o),a}function Ve(t,e){let r=[],n=[],i=t.subReader(0);return e.forEach((e=>{let o=null;if(e.dynamic){let r=t.readIndex(),n=i.subReader(r);try{o=e.decode(n)}catch(t){if(et(t,"BUFFER_OVERRUN"))throw t;o=t,o.baseType=e.name,o.name=e.localName,o.type=e.type}}else try{o=e.decode(t)}catch(t){if(et(t,"BUFFER_OVERRUN"))throw t;o=t,o.baseType=e.name,o.name=e.localName,o.type=e.type}if(null==o)throw new Error("investigate");r.push(o),n.push(e.localName||null)})),Ft.fromItems(r,n)}class Ke extends jt{coder;length;constructor(t,e,r){super("array",t.type+"["+(e>=0?e:"")+"]",r,-1===e||t.dynamic),$(this,{coder:t,length:e})}defaultValue(){const t=this.coder.defaultValue(),e=[];for(let r=0;r<this.length;r++)e.push(t);return e}encode(t,e){const r=Fe.dereference(e,"array");Array.isArray(r)||this._throwError("expected array value",r);let n=this.length;-1===n&&(n=r.length,t.writeValue(r.length)),st(r.length,n,"coder array"+(this.localName?" "+this.localName:""));let i=[];for(let t=0;t<r.length;t++)i.push(this.coder);return Ge(t,i,r)}decode(t){let e=this.length;-1===e&&(e=t.readIndex(),it(e*Ut<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:e*Ut,length:t.dataLength}));let r=[];for(let t=0;t<e;t++)r.push(new je(this.coder));return Ve(t,r)}}class We extends jt{constructor(t){super("bool","bool",t,!1)}defaultValue(){return!1}encode(t,e){const r=Fe.dereference(e,"bool");return t.writeValue(r?1:0)}decode(t){return!!t.readValue()}}class ze extends jt{constructor(t,e){super(t,t,e,!0)}defaultValue(){return"0x"}encode(t,e){e=ft(e);let r=t.writeValue(e.length);return r+=t.writeBytes(e),r}decode(t){return t.readBytes(t.readIndex(),!0)}}class qe extends ze{constructor(t){super("bytes",t)}decode(t){return yt(super.decode(t))}}class Qe extends jt{size;constructor(t,e){let r="bytes"+String(t);super(r,r,e,!1),$(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+2*this.size)}encode(t,e){let r=ft(Fe.dereference(e,this.type));return r.length!==this.size&&this._throwError("incorrect data length",e),t.writeBytes(r)}decode(t){return yt(t.readBytes(this.size))}}const Je=new Uint8Array([]);class Xe extends jt{constructor(t){super("null","",t,!1)}defaultValue(){return null}encode(t,e){return null!=e&&this._throwError("not null",e),t.writeBytes(Je)}decode(t){return t.readBytes(0),null}}const Ye=BigInt(0),Ze=BigInt(1),$e=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class tr extends jt{size;signed;constructor(t,e,r){const n=(e?"int":"uint")+8*t;super(n,n,r,!1),$(this,{size:t,signed:e},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,e){let r=Tt(Fe.dereference(e,this.type)),n=kt($e,256);if(this.signed){let t=kt(n,8*this.size-1);(r>t||r<-(t+Ze))&&this._throwError("value out-of-bounds",e),r=_t(r,256)}else(r<Ye||r>kt(n,8*this.size))&&this._throwError("value out-of-bounds",e);return t.writeValue(r)}decode(t){let e=kt(t.readValue(),8*this.size);return this.signed&&(e=function(t,e){const r=Pt(t,"value"),n=BigInt(xt(e,"width"));return it(r>>n===Et,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:t}),r>>n-At?-((~r&(At<<n)-At)+At):r}(e,8*this.size)),e}}function er(t,e,r,n,i){if("BAD_PREFIX"===t||"UNEXPECTED_CONTINUE"===t){let t=0;for(let n=e+1;n<r.length&&r[n]>>6==2;n++)t++;return t}return"OVERRUN"===t?r.length-e-1:0}const rr=Object.freeze({error:function(t,e,r,n,i){ot(!1,`invalid codepoint at offset ${e}; ${t}`,"bytes",r)},ignore:er,replace:function(t,e,r,n,i){return"OVERLONG"===t?(ot("number"==typeof i,"invalid bad code point for replacement","badCodepoint",i),n.push(i),0):(n.push(65533),er(t,e,r))}});function nr(t,e){ot("string"==typeof t,"invalid string value","str",t),null!=e&&(function(t){it(at.indexOf(t)>=0,"platform missing String.prototype.normalize","UNSUPPORTED_OPERATION",{operation:"String.prototype.normalize",info:{form:t}})}(e),t=t.normalize(e));let r=[];for(let e=0;e<t.length;e++){const n=t.charCodeAt(e);if(n<128)r.push(n);else if(n<2048)r.push(n>>6|192),r.push(63&n|128);else if(55296==(64512&n)){e++;const i=t.charCodeAt(e);ot(e<t.length&&56320==(64512&i),"invalid surrogate pair","str",t);const o=65536+((1023&n)<<10)+(1023&i);r.push(o>>18|240),r.push(o>>12&63|128),r.push(o>>6&63|128),r.push(63&o|128)}else r.push(n>>12|224),r.push(n>>6&63|128),r.push(63&n|128)}return new Uint8Array(r)}function ir(t,e){return function(t,e){null==e&&(e=rr.error);const r=lt(t,"bytes"),n=[];let i=0;for(;i<r.length;){const t=r[i++];if(!(t>>7)){n.push(t);continue}let o=null,s=null;if(192==(224&t))o=1,s=127;else if(224==(240&t))o=2,s=2047;else{if(240!=(248&t)){i+=e(128==(192&t)?"UNEXPECTED_CONTINUE":"BAD_PREFIX",i-1,r,n);continue}o=3,s=65535}if(i-1+o>=r.length){i+=e("OVERRUN",i-1,r,n);continue}let a=t&(1<<8-o-1)-1;for(let t=0;t<o;t++){let t=r[i];if(128!=(192&t)){i+=e("MISSING_CONTINUE",i,r,n),a=null;break}a=a<<6|63&t,i++}null!==a&&(a>1114111?i+=e("OUT_OF_RANGE",i-1-o,r,n,a):a>=55296&&a<=57343?i+=e("UTF16_SURROGATE",i-1-o,r,n,a):a<=s?i+=e("OVERLONG",i-1-o,r,n,a):n.push(a))}return n}(t,e).map((t=>t<=65535?String.fromCharCode(t):(t-=65536,String.fromCharCode(55296+(t>>10&1023),56320+(1023&t))))).join("")}class or extends ze{constructor(t){super("string",t)}defaultValue(){return""}encode(t,e){return super.encode(t,nr(Fe.dereference(e,"string")))}decode(t){return ir(super.decode(t))}}class sr extends jt{coders;constructor(t,e){let r=!1;const n=[];t.forEach((t=>{t.dynamic&&(r=!0),n.push(t.type)})),super("tuple","tuple("+n.join(",")+")",e,r),$(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach((e=>{t.push(e.defaultValue())}));const e=this.coders.reduce(((t,e)=>{const r=e.localName;return r&&(t[r]||(t[r]=0),t[r]++),t}),{});return this.coders.forEach(((r,n)=>{let i=r.localName;i&&1===e[i]&&("length"===i&&(i="_length"),null==t[i]&&(t[i]=t[n]))})),Object.freeze(t)}encode(t,e){const r=Fe.dereference(e,"tuple");return Ge(t,this.coders,r)}decode(t){return Ve(t,this.coders)}}function ar(t){return Pe(nr(t))}function ur(t){const e=new Set;return t.forEach((t=>e.add(t))),Object.freeze(e)}const cr=ur("external public payable override".split(" ")),lr="constant external internal payable private public pure view override",fr=ur(lr.split(" ")),hr="constructor error event fallback function receive struct",pr=ur(hr.split(" ")),dr="calldata memory storage payable indexed",yr=ur(dr.split(" ")),gr=ur([hr,dr,"tuple returns",lr].join(" ").split(" ")),br={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},wr=new RegExp("^(\\s*)"),mr=new RegExp("^([0-9]+)"),vr=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),Er=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),Ar=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$");class Sr{#i;#f;get offset(){return this.#i}get length(){return this.#f.length-this.#i}constructor(t){this.#i=0,this.#f=t.slice()}clone(){return new Sr(this.#f)}reset(){this.#i=0}#h(t=0,e=0){return new Sr(this.#f.slice(t,e).map((e=>Object.freeze(Object.assign({},e,{match:e.match-t,linkBack:e.linkBack-t,linkNext:e.linkNext-t})))))}popKeyword(t){const e=this.peek();if("KEYWORD"!==e.type||!t.has(e.text))throw new Error(`expected keyword ${e.text}`);return this.pop().text}popType(t){if(this.peek().type!==t){const e=this.peek();throw new Error(`expected ${t}; got ${e.type} ${JSON.stringify(e.text)}`)}return this.pop().text}popParen(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=this.#h(this.#i+1,t.match+1);return this.#i=t.match+1,e}popParams(){const t=this.peek();if("OPEN_PAREN"!==t.type)throw new Error("bad start");const e=[];for(;this.#i<t.match-1;){const t=this.peek().linkNext;e.push(this.#h(this.#i+1,t)),this.#i=t}return this.#i=t.match+1,e}peek(){if(this.#i>=this.#f.length)throw new Error("out-of-bounds");return this.#f[this.#i]}peekKeyword(t){const e=this.peekType("KEYWORD");return null!=e&&t.has(e)?e:null}peekType(t){if(0===this.length)return null;const e=this.peek();return e.type===t?e.text:null}pop(){const t=this.peek();return this.#i++,t}toString(){const t=[];for(let e=this.#i;e<this.#f.length;e++){const r=this.#f[e];t.push(`${r.type}:${r.text}`)}return`<TokenString ${t.join(" ")}>`}}function _r(t){const e=[],r=e=>{const r=o<t.length?JSON.stringify(t[o]):"$EOI";throw new Error(`invalid token ${r} at ${o}: ${e}`)};let n=[],i=[],o=0;for(;o<t.length;){let s=t.substring(o),a=s.match(wr);a&&(o+=a[1].length,s=t.substring(o));const u={depth:n.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:o,value:-1};e.push(u);let c=br[s[0]]||"";if(c){if(u.type=c,u.text=s[0],o++,"OPEN_PAREN"===c)n.push(e.length-1),i.push(e.length-1);else if("CLOSE_PAREN"==c)0===n.length&&r("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("COMMA"===c)u.linkBack=i.pop(),e[u.linkBack].linkNext=e.length-1,i.push(e.length-1);else if("OPEN_BRACKET"===c)u.type="BRACKET";else if("CLOSE_BRACKET"===c){let t=e.pop().text;if(e.length>0&&"NUMBER"===e[e.length-1].type){const r=e.pop().text;t=r+t,e[e.length-1].value=xt(r)}if(0===e.length||"BRACKET"!==e[e.length-1].type)throw new Error("missing opening bracket");e[e.length-1].text+=t}}else if(a=s.match(vr),a){if(u.text=a[1],o+=u.text.length,gr.has(u.text)){u.type="KEYWORD";continue}if(u.text.match(Ar)){u.type="TYPE";continue}u.type="ID"}else{if(a=s.match(mr),!a)throw new Error(`unexpected token ${JSON.stringify(s[0])} at position ${o}`);u.text=a[1],u.type="NUMBER",o+=u.text.length}}return new Sr(e.map((t=>Object.freeze(t))))}function kr(t,e){let r=[];for(const n in e.keys())t.has(n)&&r.push(n);if(r.length>1)throw new Error(`conflicting types: ${r.join(", ")}`)}function Tr(t,e){if(e.peekKeyword(pr)){const r=e.pop().text;if(r!==t)throw new Error(`expected ${t}, got ${r}`)}return e.popType("ID")}function Pr(t,e){const r=new Set;for(;;){const n=t.peekType("KEYWORD");if(null==n||e&&!e.has(n))break;if(t.pop(),r.has(n))throw new Error(`duplicate keywords: ${JSON.stringify(n)}`);r.add(n)}return Object.freeze(r)}function Ir(t){let e=Pr(t,fr);return kr(e,ur("constant payable nonpayable".split(" "))),kr(e,ur("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 Or(t,e){return t.popParams().map((t=>Vr.from(t,e)))}function xr(t){if(t.peekType("AT")){if(t.pop(),t.peekType("NUMBER"))return Tt(t.pop().text);throw new Error("invalid gas")}return null}function Br(t){if(t.length)throw new Error(`unexpected tokens at offset ${t.offset}: ${t.toString()}`)}const Rr=new RegExp(/^(.*)\[([0-9]*)\]$/);function Nr(t){const e=t.match(Ar);if(ot(e,"invalid type","type",t),"uint"===t)return"uint256";if("int"===t)return"int256";if(e[2]){const r=parseInt(e[2]);ot(0!==r&&r<=32,"invalid bytes length","type",t)}else if(e[3]){const r=parseInt(e[3]);ot(0!==r&&r<=256&&r%8==0,"invalid numeric width","type",t)}return t}const Ur={},Cr=Symbol.for("_ethers_internal"),Lr="_ParamTypeInternal",Dr="_ErrorInternal",Mr="_EventInternal",Fr="_ConstructorInternal",Hr="_FallbackInternal",jr="_FunctionInternal",Gr="_StructInternal";class Vr{name;type;baseType;indexed;components;arrayLength;arrayChildren;constructor(t,e,r,n,i,o,s,a){if(ut(t,Ur,"ParamType"),Object.defineProperty(this,Cr,{value:Lr}),o&&(o=Object.freeze(o.slice())),"array"===n){if(null==s||null==a)throw new Error("")}else if(null!=s||null!=a)throw new Error("");if("tuple"===n){if(null==o)throw new Error("")}else if(null!=o)throw new Error("");$(this,{name:e,type:r,baseType:n,indexed:i,components:o,arrayLength:s,arrayChildren:a})}format(t){if(null==t&&(t="sighash"),"json"===t){const e=this.name||"";if(this.isArray()){const t=JSON.parse(this.arrayChildren.format("json"));return t.name=e,t.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(t)}const r={type:"tuple"===this.baseType?"tuple":this.type,name:e};return"boolean"==typeof this.indexed&&(r.indexed=this.indexed),this.isTuple()&&(r.components=this.components.map((e=>JSON.parse(e.format(t))))),JSON.stringify(r)}let e="";return this.isArray()?(e+=this.arrayChildren.format(t),e+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?e+="("+this.components.map((e=>e.format(t))).join("full"===t?", ":",")+")":e+=this.type,"sighash"!==t&&(!0===this.indexed&&(e+=" indexed"),"full"===t&&this.name&&(e+=" "+this.name)),e}isArray(){return"array"===this.baseType}isTuple(){return"tuple"===this.baseType}isIndexable(){return null!=this.indexed}walk(t,e){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(-1!==this.arrayLength&&t.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return t.map((t=>r.arrayChildren.walk(t,e)))}if(this.isTuple()){if(!Array.isArray(t))throw new Error("invalid tuple value");if(t.length!==this.components.length)throw new Error("array is wrong length");const r=this;return t.map(((t,n)=>r.components[n].walk(t,e)))}return e(this.type,t)}#p(t,e,r,n){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(-1!==this.arrayLength&&e.length!==this.arrayLength)throw new Error("array is wrong length");const i=this.arrayChildren,o=e.slice();return o.forEach(((e,n)=>{i.#p(t,e,r,(t=>{o[n]=t}))})),void n(o)}if(this.isTuple()){const i=this.components;let o;if(Array.isArray(e))o=e.slice();else{if(null==e||"object"!=typeof e)throw new Error("invalid tuple value");o=i.map((t=>{if(!t.name)throw new Error("cannot use object value with unnamed components");if(!(t.name in e))throw new Error(`missing value for component ${t.name}`);return e[t.name]}))}if(o.length!==this.components.length)throw new Error("array is wrong length");return o.forEach(((e,n)=>{i[n].#p(t,e,r,(t=>{o[n]=t}))})),void n(o)}const i=r(this.type,e);i.then?t.push(async function(){n(await i)}()):n(i)}async walkAsync(t,e){const r=[],n=[t];return this.#p(r,t,e,(t=>{n[0]=t})),r.length&&await Promise.all(r),n[0]}static from(t,e){if(Vr.isParamType(t))return t;if("string"==typeof t)try{return Vr.from(_r(t),e)}catch(e){ot(!1,"invalid param type","obj",t)}else if(t instanceof Sr){let r="",n="",i=null;Pr(t,ur(["tuple"])).has("tuple")||t.peekType("OPEN_PAREN")?(n="tuple",i=t.popParams().map((t=>Vr.from(t))),r=`tuple(${i.map((t=>t.format())).join(",")})`):(r=Nr(t.popType("TYPE")),n=r);let o=null,s=null;for(;t.length&&t.peekType("BRACKET");){const e=t.pop();o=new Vr(Ur,"",r,n,null,i,s,o),s=e.value,r+=e.text,n="array",i=null}let a=null;if(Pr(t,yr).has("indexed")){if(!e)throw new Error("");a=!0}const u=t.peekType("ID")?t.pop().text:"";if(t.length)throw new Error("leftover tokens");return new Vr(Ur,u,r,n,a,i,s,o)}const r=t.name;ot(!r||"string"==typeof r&&r.match(Er),"invalid name","obj.name",r);let n=t.indexed;null!=n&&(ot(e,"parameter cannot be indexed","obj.indexed",t.indexed),n=!!n);let i=t.type,o=i.match(Rr);if(o){const e=parseInt(o[2]||"-1"),s=Vr.from({type:o[1],components:t.components});return new Vr(Ur,r||"",i,"array",n,null,e,s)}if("tuple"===i||i.startsWith("tuple(")||i.startsWith("(")){const e=null!=t.components?t.components.map((t=>Vr.from(t))):null;return new Vr(Ur,r||"",i,"tuple",n,e,null,null)}return i=Nr(t.type),new Vr(Ur,r||"",i,i,n,null,null,null)}static isParamType(t){return t&&t[Cr]===Lr}}class Kr{type;inputs;constructor(t,e,r){ut(t,Ur,"Fragment"),$(this,{type:e,inputs:r=Object.freeze(r.slice())})}static from(t){if("string"==typeof t){try{Kr.from(JSON.parse(t))}catch(t){}return Kr.from(_r(t))}if(t instanceof Sr)switch(t.peekKeyword(pr)){case"constructor":return Jr.from(t);case"error":return qr.from(t);case"event":return Qr.from(t);case"fallback":case"receive":return Xr.from(t);case"function":return Yr.from(t);case"struct":return Zr.from(t)}else if("object"==typeof t){switch(t.type){case"constructor":return Jr.from(t);case"error":return qr.from(t);case"event":return Qr.from(t);case"fallback":case"receive":return Xr.from(t);case"function":return Yr.from(t);case"struct":return Zr.from(t)}it(!1,`unsupported type: ${t.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}ot(!1,"unsupported frgament object","obj",t)}static isConstructor(t){return Jr.isFragment(t)}static isError(t){return qr.isFragment(t)}static isEvent(t){return Qr.isFragment(t)}static isFunction(t){return Yr.isFragment(t)}static isStruct(t){return Zr.isFragment(t)}}class Wr extends Kr{name;constructor(t,e,r,n){super(t,e,n),ot("string"==typeof r&&r.match(Er),"invalid identifier","name",r),n=Object.freeze(n.slice()),$(this,{name:r})}}function zr(t,e){return"("+e.map((e=>e.format(t))).join("full"===t?", ":",")+")"}class qr extends Wr{constructor(t,e,r){super(t,"error",e,r),Object.defineProperty(this,Cr,{value:Dr})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("error"),e.push(this.name+zr(t,this.inputs)),e.join(" ")}static from(t){if(qr.isFragment(t))return t;if("string"==typeof t)return qr.from(_r(t));if(t instanceof Sr){const e=Tr("error",t),r=Or(t);return Br(t),new qr(Ur,e,r)}return new qr(Ur,t.name,t.inputs?t.inputs.map(Vr.from):[])}static isFragment(t){return t&&t[Cr]===Dr}}class Qr extends Wr{anonymous;constructor(t,e,r,n){super(t,"event",e,r),Object.defineProperty(this,Cr,{value:Mr}),$(this,{anonymous:n})}get topicHash(){return ar(this.format("sighash"))}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("event"),e.push(this.name+zr(t,this.inputs)),"sighash"!==t&&this.anonymous&&e.push("anonymous"),e.join(" ")}static getTopicHash(t,e){return e=(e||[]).map((t=>Vr.from(t))),new Qr(Ur,t,e,!1).topicHash}static from(t){if(Qr.isFragment(t))return t;if("string"==typeof t)try{return Qr.from(_r(t))}catch(e){ot(!1,"invalid event fragment","obj",t)}else if(t instanceof Sr){const e=Tr("event",t),r=Or(t,!0),n=!!Pr(t,ur(["anonymous"])).has("anonymous");return Br(t),new Qr(Ur,e,r,n)}return new Qr(Ur,t.name,t.inputs?t.inputs.map((t=>Vr.from(t,!0))):[],!!t.anonymous)}static isFragment(t){return t&&t[Cr]===Mr}}class Jr extends Kr{payable;gas;constructor(t,e,r,n,i){super(t,e,r),Object.defineProperty(this,Cr,{value:Fr}),$(this,{payable:n,gas:i})}format(t){if(it(null!=t&&"sighash"!==t,"cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),"json"===t)return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t))))});const e=[`constructor${zr(t,this.inputs)}`];return this.payable&&e.push("payable"),null!=this.gas&&e.push(`@${this.gas.toString()}`),e.join(" ")}static from(t){if(Jr.isFragment(t))return t;if("string"==typeof t)try{return Jr.from(_r(t))}catch(e){ot(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Sr){Pr(t,ur(["constructor"]));const e=Or(t),r=!!Pr(t,cr).has("payable"),n=xr(t);return Br(t),new Jr(Ur,"constructor",e,r,n)}return new Jr(Ur,"constructor",t.inputs?t.inputs.map(Vr.from):[],!!t.payable,null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Cr]===Fr}}class Xr extends Kr{payable;constructor(t,e,r){super(t,"fallback",e),Object.defineProperty(this,Cr,{value:Hr}),$(this,{payable:r})}format(t){const e=0===this.inputs.length?"receive":"fallback";if("json"===t){const t=this.payable?"payable":"nonpayable";return JSON.stringify({type:e,stateMutability:t})}return`${e}()${this.payable?" payable":""}`}static from(t){if(Xr.isFragment(t))return t;if("string"==typeof t)try{return Xr.from(_r(t))}catch(e){ot(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Sr){const e=t.toString();if(ot(t.peekKeyword(ur(["fallback","receive"])),"type must be fallback or receive","obj",e),"receive"===t.popKeyword(ur(["fallback","receive"]))){const e=Or(t);return ot(0===e.length,"receive cannot have arguments","obj.inputs",e),Pr(t,ur(["payable"])),Br(t),new Xr(Ur,[],!0)}let r=Or(t);r.length?ot(1===r.length&&"bytes"===r[0].type,"invalid fallback inputs","obj.inputs",r.map((t=>t.format("minimal"))).join(", ")):r=[Vr.from("bytes")];const n=Ir(t);if(ot("nonpayable"===n||"payable"===n,"fallback cannot be constants","obj.stateMutability",n),Pr(t,ur(["returns"])).has("returns")){const e=Or(t);ot(1===e.length&&"bytes"===e[0].type,"invalid fallback outputs","obj.outputs",e.map((t=>t.format("minimal"))).join(", "))}return Br(t),new Xr(Ur,r,"payable"===n)}if("receive"===t.type)return new Xr(Ur,[],!0);if("fallback"===t.type){const e=[Vr.from("bytes")],r="payable"===t.stateMutability;return new Xr(Ur,e,r)}ot(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Cr]===Hr}}class Yr extends Wr{constant;outputs;stateMutability;payable;gas;constructor(t,e,r,n,i,o){super(t,"function",e,n),Object.defineProperty(this,Cr,{value:jr}),$(this,{constant:"view"===r||"pure"===r,gas:o,outputs:i=Object.freeze(i.slice()),payable:"payable"===r,stateMutability:r})}get selector(){return ar(this.format("sighash")).substring(0,10)}format(t){if(null==t&&(t="sighash"),"json"===t)return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:"nonpayable"!==this.stateMutability?this.stateMutability:void 0,payable:this.payable,gas:null!=this.gas?this.gas:void 0,inputs:this.inputs.map((e=>JSON.parse(e.format(t)))),outputs:this.outputs.map((e=>JSON.parse(e.format(t))))});const e=[];return"sighash"!==t&&e.push("function"),e.push(this.name+zr(t,this.inputs)),"sighash"!==t&&("nonpayable"!==this.stateMutability&&e.push(this.stateMutability),this.outputs&&this.outputs.length&&(e.push("returns"),e.push(zr(t,this.outputs))),null!=this.gas&&e.push(`@${this.gas.toString()}`)),e.join(" ")}static getSelector(t,e){return e=(e||[]).map((t=>Vr.from(t))),new Yr(Ur,t,"view",e,[],null).selector}static from(t){if(Yr.isFragment(t))return t;if("string"==typeof t)try{return Yr.from(_r(t))}catch(e){ot(!1,"invalid function fragment","obj",t)}else if(t instanceof Sr){const e=Tr("function",t),r=Or(t),n=Ir(t);let i=[];Pr(t,ur(["returns"])).has("returns")&&(i=Or(t));const o=xr(t);return Br(t),new Yr(Ur,e,n,r,i,o)}let e=t.stateMutability;return null==e&&(e="payable","boolean"==typeof t.constant?(e="view",t.constant||(e="payable","boolean"!=typeof t.payable||t.payable||(e="nonpayable"))):"boolean"!=typeof t.payable||t.payable||(e="nonpayable")),new Yr(Ur,t.name,e,t.inputs?t.inputs.map(Vr.from):[],t.outputs?t.outputs.map(Vr.from):[],null!=t.gas?t.gas:null)}static isFragment(t){return t&&t[Cr]===jr}}class Zr extends Wr{constructor(t,e,r){super(t,"struct",e,r),Object.defineProperty(this,Cr,{value:Gr})}format(){throw new Error("@TODO")}static from(t){if("string"==typeof t)try{return Zr.from(_r(t))}catch(e){ot(!1,"invalid struct fragment","obj",t)}else if(t instanceof Sr){const e=Tr("struct",t),r=Or(t);return Br(t),new Zr(Ur,e,r)}return new Zr(Ur,t.name,t.inputs?t.inputs.map(Vr.from):[])}static isFragment(t){return t&&t[Cr]===Gr}}const $r=new Map;$r.set(0,"GENERIC_PANIC"),$r.set(1,"ASSERT_FALSE"),$r.set(17,"OVERFLOW"),$r.set(18,"DIVIDE_BY_ZERO"),$r.set(33,"ENUM_RANGE_ERROR"),$r.set(34,"BAD_STORAGE_DATA"),$r.set(49,"STACK_UNDERFLOW"),$r.set(50,"ARRAY_RANGE_ERROR"),$r.set(65,"OUT_OF_MEMORY"),$r.set(81,"UNINITIALIZED_FUNCTION_CALL");const tn=new RegExp(/^bytes([0-9]*)$/),en=new RegExp(/^(u?int)([0-9]*)$/);let rn=null,nn=1024;class on{#d(t){if(t.isArray())return new Ke(this.#d(t.arrayChildren),t.arrayLength,t.name);if(t.isTuple())return new sr(t.components.map((t=>this.#d(t))),t.name);switch(t.baseType){case"address":return new He(t.name);case"bool":return new We(t.name);case"string":return new or(t.name);case"bytes":return new qe(t.name);case"":return new Xe(t.name)}let e=t.type.match(en);if(e){let r=parseInt(e[2]||"256");return ot(0!==r&&r<=256&&r%8==0,"invalid "+e[1]+" bit length","param",t),new tr(r/8,"int"===e[1],t.name)}if(e=t.type.match(tn),e){let r=parseInt(e[1]);return ot(0!==r&&r<=32,"invalid bytes length","param",t),new Qe(r,t.name)}ot(!1,"invalid type","type",t.type)}getDefaultValue(t){const e=t.map((t=>this.#d(Vr.from(t))));return new sr(e,"_").defaultValue()}encode(t,e){st(e.length,t.length,"types/values length mismatch");const r=t.map((t=>this.#d(Vr.from(t)))),n=new sr(r,"_"),i=new Gt;return n.encode(i,e),i.data}decode(t,e,r){const n=t.map((t=>this.#d(Vr.from(t))));return new sr(n,"_").decode(new Vt(e,r,nn))}static _setDefaultMaxInflation(t){ot("number"==typeof t&&Number.isInteger(t),"invalid defaultMaxInflation factor","value",t),nn=t}static defaultAbiCoder(){return null==rn&&(rn=new on),rn}static getBuiltinCallException(t,e,r){return function(t,e,r,n){let i="missing revert data",o=null,s=null;if(r){i="execution reverted";const t=lt(r);if(r=yt(r),0===t.length)i+=" (no data present; likely require(false) occurred",o="require(false)";else if(t.length%32!=4)i+=" (could not decode reason; invalid data length)";else if("0x08c379a0"===yt(t.slice(0,4)))try{o=n.decode(["string"],t.slice(4))[0],s={signature:"Error(string)",name:"Error",args:[o]},i+=`: ${JSON.stringify(o)}`}catch(t){i+=" (could not decode reason; invalid string data)"}else if("0x4e487b71"===yt(t.slice(0,4)))try{const e=Number(n.decode(["uint256"],t.slice(4))[0]);s={signature:"Panic(uint256)",name:"Panic",args:[e]},o=`Panic due to ${$r.get(e)||"UNKNOWN"}(${e})`,i+=`: ${o}`}catch(t){i+=" (could not decode panic code)"}else i+=" (unknown custom error)"}const a={to:e.to?Ue(e.to):null,data:e.data||"0x"};return e.from&&(a.from=Ue(e.from)),nt(i,"CALL_EXCEPTION",{action:t,data:r,reason:o,transaction:a,invocation:null,revert:s})}(t,e,r,on.defaultAbiCoder())}}function sn(t){return t&&"function"==typeof t.getAddress}async function an(t,e){const r=await e;return null!=r&&"0x0000000000000000000000000000000000000000"!==r||(it("string"!=typeof t,"unconfigured name","UNCONFIGURED_NAME",{value:t}),ot(!1,"invalid AddressLike value; did not resolve to a value address","target",t)),Ue(r)}function un(t,e){return"string"==typeof t?t.match(/^0x[0-9a-f]{40}$/i)?Ue(t):(it(null!=e,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),an(t,e.resolveName(t))):sn(t)?an(t,t.getAddress()):t&&"function"==typeof t.then?an(t,t):void ot(!1,"unsupported addressable value","target",t)}const cn=new Uint8Array(32);cn.fill(0);const ln=BigInt(-1),fn=BigInt(0),hn=BigInt(1),pn=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),dn=Bt(hn,32),yn=Bt(fn,32),gn={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},bn=["name","version","chainId","verifyingContract","salt"];function wn(t){return function(e){return ot("string"==typeof e,`invalid domain value for ${JSON.stringify(t)}`,`domain.${t}`,e),e}}const mn={name:wn("name"),version:wn("version"),chainId:function(t){const e=Tt(t,"domain.chainId");return ot(e>=0,"invalid chain ID","domain.chainId",t),Number.isSafeInteger(e)?Number(e):Nt(e)},verifyingContract:function(t){try{return Ue(t).toLowerCase()}catch(t){}ot(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",t)},salt:function(t){const e=lt(t,"domain.salt");return ot(32===e.length,'invalid domain value "salt"',"domain.salt",t),yt(e)}};function vn(t){{const e=t.match(/^(u?)int(\d+)$/);if(e){const r=""===e[1],n=parseInt(e[2]);ot(n%8==0&&0!==n&&n<=256&&e[2]===String(n),"invalid numeric width","type",t);const i=kt(pn,r?n-1:n),o=r?(i+hn)*ln:fn;return function(e){const n=Tt(e,"value");return ot(n>=o&&n<=i,`value out-of-bounds for ${t}`,"value",n),Bt(r?_t(n,256):n,32)}}}{const e=t.match(/^bytes(\d+)$/);if(e){const r=parseInt(e[1]);return ot(0!==r&&r<=32&&e[1]===String(r),"invalid bytes width","type",t),function(e){return ot(lt(e).length===r,`invalid length for ${t}`,"value",e),function(t){const e=lt(t),r=e.length%32;return r?gt([e,cn.slice(r)]):yt(e)}(e)}}}switch(t){case"address":return function(t){return vt(Ue(t),32)};case"bool":return function(t){return t?dn:yn};case"bytes":return function(t){return Pe(t)};case"string":return function(t){return ar(t)}}return null}function En(t,e){return`${t}(${e.map((({name:t,type:e})=>e+" "+t)).join(",")})`}function An(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}}class Sn{primaryType;#y;get types(){return JSON.parse(this.#y)}#g;#b;constructor(t){this.#g=new Map,this.#b=new Map;const e=new Map,r=new Map,n=new Map,i={};Object.keys(t).forEach((o=>{i[o]=t[o].map((({name:e,type:r})=>{let{base:n,index:i}=An(r);return"int"!==n||t.int||(n="int256"),"uint"!==n||t.uint||(n="uint256"),{name:e,type:n+(i||"")}})),e.set(o,new Set),r.set(o,[]),n.set(o,new Set)})),this.#y=JSON.stringify(i);for(const n in i){const o=new Set;for(const s of i[n]){ot(!o.has(s.name),`duplicate variable name ${JSON.stringify(s.name)} in ${JSON.stringify(n)}`,"types",t),o.add(s.name);const i=An(s.type).base;ot(i!==n,`circular type reference to ${JSON.stringify(i)}`,"types",t),vn(i)||(ot(r.has(i),`unknown type ${JSON.stringify(i)}`,"types",t),r.get(i).push(n),e.get(n).add(i))}}const o=Array.from(r.keys()).filter((t=>0===r.get(t).length));ot(0!==o.length,"missing primary type","types",t),ot(1===o.length,`ambiguous primary types or unused types: ${o.map((t=>JSON.stringify(t))).join(", ")}`,"types",t),$(this,{primaryType:o[0]}),function i(o,s){ot(!s.has(o),`circular type reference to ${JSON.stringify(o)}`,"types",t),s.add(o);for(const t of e.get(o))if(r.has(t)){i(t,s);for(const e of s)n.get(e).add(t)}s.delete(o)}(this.primaryType,new Set);for(const[t,e]of n){const r=Array.from(e);r.sort(),this.#g.set(t,En(t,i[t])+r.map((t=>En(t,i[t]))).join(""))}}getEncoder(t){let e=this.#b.get(t);return e||(e=this.#w(t),this.#b.set(t,e)),e}#w(t){{const e=vn(t);if(e)return e}const e=An(t).array;if(e){const t=e.prefix,r=this.getEncoder(t);return n=>{ot(-1===e.count||e.count===n.length,`array length mismatch; expected length ${e.count}`,"value",n);let i=n.map(r);return this.#g.has(t)&&(i=i.map(Pe)),Pe(gt(i))}}const r=this.types[t];if(r){const e=ar(this.#g.get(t));return t=>{const n=r.map((({name:e,type:r})=>{const n=this.getEncoder(r)(t[e]);return this.#g.has(r)?Pe(n):n}));return n.unshift(e),gt(n)}}ot(!1,`unknown type: ${t}`,"type",t)}encodeType(t){const e=this.#g.get(t);return ot(e,`unknown type: ${JSON.stringify(t)}`,"name",t),e}encodeData(t,e){return this.getEncoder(t)(e)}hashStruct(t,e){return Pe(this.encodeData(t,e))}encode(t){return this.encodeData(this.primaryType,t)}hash(t){return this.hashStruct(this.primaryType,t)}_visit(t,e,r){if(vn(t))return r(t,e);const n=An(t).array;if(n)return ot(-1===n.count||n.count===e.length,`array length mismatch; expected length ${n.count}`,"value",e),e.map((t=>this._visit(n.prefix,t,r)));const i=this.types[t];if(i)return i.reduce(((t,{name:n,type:i})=>(t[n]=this._visit(i,e[n],r),t)),{});ot(!1,`unknown type: ${t}`,"type",t)}visit(t,e){return this._visit(this.primaryType,t,e)}static from(t){return new Sn(t)}static getPrimaryType(t){return Sn.from(t).primaryType}static hashStruct(t,e,r){return Sn.from(e).hashStruct(t,r)}static hashDomain(t){const e=[];for(const r in t){if(null==t[r])continue;const n=gn[r];ot(n,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",t),e.push({name:r,type:n})}return e.sort(((t,e)=>bn.indexOf(t.name)-bn.indexOf(e.name))),Sn.hashStruct("EIP712Domain",{EIP712Domain:e},t)}static encode(t,e,r){return gt(["0x1901",Sn.hashDomain(t),Sn.from(e).hash(r)])}static hash(t,e,r){return Pe(Sn.encode(t,e,r))}static async resolveNames(t,e,r,n){t=Object.assign({},t);for(const e in t)null==t[e]&&delete t[e];const i={};t.verifyingContract&&!ht(t.verifyingContract,20)&&(i[t.verifyingContract]="0x");const o=Sn.from(e);o.visit(r,((t,e)=>("address"!==t||ht(e,20)||(i[e]="0x"),e)));for(const t in i)i[t]=await n(t);return t.verifyingContract&&i[t.verifyingContract]&&(t.verifyingContract=i[t.verifyingContract]),{domain:t,value:r=o.visit(r,((t,e)=>"address"===t&&i[e]?i[e]:e))}}static getPayload(t,e,r){Sn.hashDomain(t);const n={},i=[];bn.forEach((e=>{const r=t[e];null!=r&&(n[e]=mn[e](r),i.push({name:e,type:gn[e]}))}));const o=Sn.from(e);e=o.types;const s=Object.assign({},e);return ot(null==s.EIP712Domain,"types must not contain EIP712Domain type","types.EIP712Domain",e),s.EIP712Domain=i,o.encode(r),{types:s,domain:n,primaryType:o.primaryType,message:o.visit(r,((t,e)=>{if(t.match(/^bytes(\d*)/))return yt(lt(e));if(t.match(/^u?int/))return Tt(e).toString();switch(t){case"address":return e.toLowerCase();case"bool":return!!e;case"string":return ot("string"==typeof e,"invalid string","value",e),e}ot(!1,"unsupported type","type",t)}))}}}function _n(t,e){return{address:Ue(t),storageKeys:e.map(((t,e)=>(ot(ht(t,32),"invalid slot",`storageKeys[${e}]`,t),t.toLowerCase())))}}function kn(t){if(Array.isArray(t))return t.map(((e,r)=>Array.isArray(e)?(ot(2===e.length,"invalid slot set",`value[${r}]`,e),_n(e[0],e[1])):(ot(null!=e&&"object"==typeof e,"invalid address-slot set","value",t),_n(e.address,e.storageKeys))));ot(null!=t&&"object"==typeof t,"invalid access list","value",t);const e=Object.keys(t).map((e=>{const r=t[e].reduce(((t,e)=>(t[e]=!0,t)),{});return _n(e,Object.keys(r).sort())}));return e.sort(((t,e)=>t.address.localeCompare(e.address))),e}function Tn(t){return async function(t,e){const r=t.url.split(":")[0].toLowerCase();let n;if(it("http"===r||"https"===r,`unsupported protocol ${r}`,"UNSUPPORTED_OPERATION",{info:{protocol:r},operation:"request"}),it("https"===r||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"}),e){const t=new AbortController;n=t.signal,e.addListener((()=>{t.abort()}))}const i={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:n},o=await fetch(t.url,i),s={};o.headers.forEach(((t,e)=>{s[e.toLowerCase()]=t}));const a=await o.arrayBuffer(),u=null==a?null:new Uint8Array(a);return{statusCode:o.status,statusMessage:o.statusText,headers:s,body:u}}}Tn();let Pn=Tn();const In=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),On=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let xn=!1;async function Bn(t,e){try{const e=t.match(In);if(!e)throw new Error("invalid data");return new Mn(200,"OK",{"content-type":e[1]||"text/plain"},e[2]?function(t){t=atob(t);const e=new Uint8Array(t.length);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return lt(e)}(e[3]):nr(e[3].replace(/%([0-9a-f][0-9a-f])/gi,((t,e)=>String.fromCharCode(parseInt(e,16))))))}catch(e){return new Mn(599,"BAD REQUEST (invalid data: URI)",{},null,new Dn(t))}}function Rn(t){return async function(e,r){try{const r=e.match(On);if(!r)throw new Error("invalid link");return new Dn(`${t}${r[2]}`)}catch(t){return new Mn(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Dn(e))}}}const Nn={data:Bn,ipfs:Rn("https://gateway.ipfs.io/ipfs/")},Un=new WeakMap;class Cn{#m;#v;constructor(t){this.#m=[],this.#v=!1,Un.set(t,(()=>{if(!this.#v){this.#v=!0;for(const t of this.#m)setTimeout((()=>{t()}),0);this.#m=[]}}))}addListener(t){it(!this.#v,"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),this.#m.push(t)}get cancelled(){return this.#v}checkSignal(){it(!this.cancelled,"cancelled","CANCELLED",{})}}function Ln(t){if(null==t)throw new Error("missing signal; should not happen");return t.checkSignal(),t}class Dn{#E;#A;#S;#_;#k;#T;#P;#I;#O;#x;#B;#R;#N;#U;#C;get url(){return this.#T}set url(t){this.#T=String(t)}get body(){return null==this.#P?null:new Uint8Array(this.#P)}set body(t){if(null==t)this.#P=void 0,this.#I=void 0;else if("string"==typeof t)this.#P=nr(t),this.#I="text/plain";else if(t instanceof Uint8Array)this.#P=t,this.#I="application/octet-stream";else{if("object"!=typeof t)throw new Error("invalid body");this.#P=nr(JSON.stringify(t)),this.#I="application/json"}}hasBody(){return null!=this.#P}get method(){return this.#_?this.#_:this.hasBody()?"POST":"GET"}set method(t){null==t&&(t=""),this.#_=String(t).toUpperCase()}get headers(){const t=Object.assign({},this.#S);return this.#O&&(t.authorization=`Basic ${function(t){const e=lt(t);let r="";for(let t=0;t<e.length;t++)r+=String.fromCharCode(e[t]);return btoa(r)}(nr(this.#O))}`),this.allowGzip&&(t["accept-encoding"]="gzip"),null==t["content-type"]&&this.#I&&(t["content-type"]=this.#I),this.body&&(t["content-length"]=String(this.body.length)),t}getHeader(t){return this.headers[t.toLowerCase()]}setHeader(t,e){this.#S[String(t).toLowerCase()]=String(e)}clearHeaders(){this.#S={}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return this.#O||null}setCredentials(t,e){ot(!t.match(/:/),"invalid basic authentication username","username","[REDACTED]"),this.#O=`${t}:${e}`}get allowGzip(){return this.#A}set allowGzip(t){this.#A=!!t}get allowInsecureAuthentication(){return!!this.#E}set allowInsecureAuthentication(t){this.#E=!!t}get timeout(){return this.#k}set timeout(t){ot(t>=0,"timeout must be non-zero","timeout",t),this.#k=t}get preflightFunc(){return this.#x||null}set preflightFunc(t){this.#x=t}get processFunc(){return this.#B||null}set processFunc(t){this.#B=t}get retryFunc(){return this.#R||null}set retryFunc(t){this.#R=t}get getUrlFunc(){return this.#C||Pn}set getUrlFunc(t){this.#C=t}constructor(t){this.#T=String(t),this.#E=!1,this.#A=!0,this.#S={},this.#_="",this.#k=3e5,this.#U={slotInterval:250,maxAttempts:12},this.#C=null}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${this.#P?yt(this.#P):"null"}>`}setThrottleParams(t){null!=t.slotInterval&&(this.#U.slotInterval=t.slotInterval),null!=t.maxAttempts&&(this.#U.maxAttempts=t.maxAttempts)}async#L(t,e,r,n,i){if(t>=this.#U.maxAttempts)return i.makeServerError("exceeded maximum retry limit");it(Fn()<=e,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:n}),r>0&&await function(t){return new Promise((e=>setTimeout(e,t)))}(r);let o=this.clone();const s=(o.url.split(":")[0]||"").toLowerCase();if(s in Nn){const t=await Nn[s](o.url,Ln(n.#N));if(t instanceof Mn){let e=t;if(this.processFunc){Ln(n.#N);try{e=await this.processFunc(o,e)}catch(t){null!=t.throttle&&"number"==typeof t.stall||e.makeServerError("error in post-processing function",t).assertOk()}}return e}o=t}this.preflightFunc&&(o=await this.preflightFunc(o));const a=await this.getUrlFunc(o,Ln(n.#N));let u=new Mn(a.statusCode,a.statusMessage,a.headers,a.body,n);if(301===u.statusCode||302===u.statusCode){try{const r=u.headers.location||"";return o.redirect(r).#L(t+1,e,0,n,u)}catch(t){}return u}if(429===u.statusCode&&(null==this.retryFunc||await this.retryFunc(o,u,t))){const r=u.headers["retry-after"];let i=this.#U.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return"string"==typeof r&&r.match(/^[1-9][0-9]*$/)&&(i=parseInt(r)),o.clone().#L(t+1,e,i,n,u)}if(this.processFunc){Ln(n.#N);try{u=await this.processFunc(o,u)}catch(r){null!=r.throttle&&"number"==typeof r.stall||u.makeServerError("error in post-processing function",r).assertOk();let i=this.#U.slotInterval*Math.trunc(Math.random()*Math.pow(2,t));return r.stall>=0&&(i=r.stall),o.clone().#L(t+1,e,i,n,u)}}return u}send(){return it(null==this.#N,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),this.#N=new Cn(this),this.#L(0,Fn()+this.timeout,0,this,new Mn(0,"",{},null,this))}cancel(){it(null!=this.#N,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const t=Un.get(this);if(!t)throw new Error("missing signal; should not happen");t()}redirect(t){const e=this.url.split(":")[0].toLowerCase(),r=t.split(":")[0].toLowerCase();it("GET"===this.method&&("https"!==e||"http"!==r)&&t.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(t)})`});const n=new Dn(t);return n.method="GET",n.allowGzip=this.allowGzip,n.timeout=this.timeout,n.#S=Object.assign({},this.#S),this.#P&&(n.#P=new Uint8Array(this.#P)),n.#I=this.#I,n}clone(){const t=new Dn(this.url);return t.#_=this.#_,this.#P&&(t.#P=this.#P),t.#I=this.#I,t.#S=Object.assign({},this.#S),t.#O=this.#O,this.allowGzip&&(t.allowGzip=!0),t.timeout=this.timeout,this.allowInsecureAuthentication&&(t.allowInsecureAuthentication=!0),t.#x=this.#x,t.#B=this.#B,t.#R=this.#R,t.#U=Object.assign({},this.#U),t.#C=this.#C,t}static lockConfig(){xn=!0}static getGateway(t){return Nn[t.toLowerCase()]||null}static registerGateway(t,e){if("http"===(t=t.toLowerCase())||"https"===t)throw new Error(`cannot intercept ${t}; use registerGetUrl`);if(xn)throw new Error("gateways locked");Nn[t]=e}static registerGetUrl(t){if(xn)throw new Error("gateways locked");Pn=t}static createGetUrlFunc(t){return Tn()}static createDataGateway(){return Bn}static createIpfsGatewayFunc(t){return Rn(t)}}class Mn{#D;#M;#S;#P;#F;#H;toString(){return`<FetchResponse status=${this.statusCode} body=${this.#P?yt(this.#P):"null"}>`}get statusCode(){return this.#D}get statusMessage(){return this.#M}get headers(){return Object.assign({},this.#S)}get body(){return null==this.#P?null:new Uint8Array(this.#P)}get bodyText(){try{return null==this.#P?"":ir(this.#P)}catch(t){it(!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(t){it(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const t=this.headers,e=Object.keys(t);let r=0;return{next:()=>{if(r<e.length){const n=e[r++];return{value:[n,t[n]],done:!1}}return{value:void 0,done:!0}}}}constructor(t,e,r,n,i){this.#D=t,this.#M=e,this.#S=Object.keys(r).reduce(((t,e)=>(t[e.toLowerCase()]=String(r[e]),t)),{}),this.#P=null==n?null:new Uint8Array(n),this.#F=i||null,this.#H={message:""}}makeServerError(t,e){let r;r=t?`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${t})`:`CLIENT ESCALATED SERVER ERROR (${t=`${this.statusCode} ${this.statusMessage}`})`;const n=new Mn(599,r,this.headers,this.body,this.#F||void 0);return n.#H={message:t,error:e},n}throwThrottleError(t,e){null==e?e=-1:ot(Number.isInteger(e)&&e>=0,"invalid stall timeout","stall",e);const r=new Error(t||"throttling requests");throw $(r,{stall:e,throttle:!0}),r}getHeader(t){return this.headers[t.toLowerCase()]}hasBody(){return null!=this.#P}get request(){return this.#F}ok(){return""===this.#H.message&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:t,error:e}=this.#H;""===t&&(t=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let n=null;try{this.#P&&(n=ir(this.#P))}catch(t){}it(!1,t,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:e,info:{requestUrl:r,responseBody:n,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}}function Fn(){return(new Date).getTime()}const Hn="0x0000000000000000000000000000000000000000";class jn{fragment;name;signature;topic;args;constructor(t,e,r){const n=t.name,i=t.format();$(this,{fragment:t,name:n,signature:i,topic:e,args:r})}}class Gn{fragment;name;args;signature;selector;value;constructor(t,e,r,n){const i=t.name,o=t.format();$(this,{fragment:t,name:i,args:r,signature:o,selector:e,value:n})}}class Vn{fragment;name;args;signature;selector;constructor(t,e,r){const n=t.name,i=t.format();$(this,{fragment:t,name:n,args:r,signature:i,selector:e})}}class Kn{hash;_isIndexed;static isIndexed(t){return!(!t||!t._isIndexed)}constructor(t){$(this,{hash:t,_isIndexed:!0})}}const Wn={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"},zn={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:t=>`reverted with reason string ${JSON.stringify(t)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:t=>{let e="unknown panic code";return t>=0&&t<=255&&Wn[t.toString()]&&(e=Wn[t.toString()]),`reverted with panic code 0x${t.toString(16)} (${e})`}}};class qn{fragments;deploy;fallback;receive;#j;#G;#V;#K;constructor(t){let e=[];e="string"==typeof t?JSON.parse(t):t,this.#V=new Map,this.#j=new Map,this.#G=new Map;const r=[];for(const t of e)try{r.push(Kr.from(t))}catch(e){console.log(`[Warning] Invalid Fragment ${JSON.stringify(t)}:`,e.message)}$(this,{fragments:Object.freeze(r)});let n=null,i=!1;this.#K=this.getAbiCoder(),this.fragments.forEach(((t,e)=>{let r;switch(t.type){case"constructor":return this.deploy?void console.log("duplicate definition - constructor"):void $(this,{deploy:t});case"fallback":return void(0===t.inputs.length?i=!0:(ot(!n||t.payable!==n.payable,"conflicting fallback fragments",`fragments[${e}]`,t),n=t,i=n.payable));case"function":r=this.#V;break;case"event":r=this.#G;break;case"error":r=this.#j;break;default:return}const o=t.format();r.has(o)||r.set(o,t)})),this.deploy||$(this,{deploy:Jr.from("constructor()")}),$(this,{fallback:n,receive:i})}format(t){const e=t?"minimal":"full";return this.fragments.map((t=>t.format(e)))}formatJson(){const t=this.fragments.map((t=>t.format("json")));return JSON.stringify(t.map((t=>JSON.parse(t))))}getAbiCoder(){return on.defaultAbiCoder()}#W(t,e,r){if(ht(t)){const e=t.toLowerCase();for(const t of this.#V.values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of this.#V)e.split("(")[0]===t&&n.push(r);if(e){const t=e.length>0?e[e.length-1]:null;let r=e.length,i=!0;Fe.isTyped(t)&&"overrides"===t.type&&(i=!1,r--);for(let t=n.length-1;t>=0;t--){const e=n[t].inputs.length;e===r||i&&e===r-1||n.splice(t,1)}for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(Fe.isTyped(e[i])){if(i>=r.length){if("overrides"===e[i].type)continue;n.splice(t,1);break}if(e[i].type!==r[i].baseType){n.splice(t,1);break}}}}if(1===n.length&&e&&e.length!==n[0].inputs.length){const t=e[e.length-1];(null==t||Array.isArray(t)||"object"!=typeof t)&&n.splice(0,1)}return 0===n.length?null:(n.length>1&&r&&ot(!1,`ambiguous function description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t),n[0])}return this.#V.get(Yr.from(t).format())||null}getFunctionName(t){const e=this.#W(t,null,!1);return ot(e,"no matching function","key",t),e.name}hasFunction(t){return!!this.#W(t,null,!1)}getFunction(t,e){return this.#W(t,e||null,!0)}forEachFunction(t){const e=Array.from(this.#V.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#V.get(n),r)}}#z(t,e,r){if(ht(t)){const e=t.toLowerCase();for(const t of this.#G.values())if(e===t.topicHash)return t;return null}if(-1===t.indexOf("(")){const n=[];for(const[e,r]of this.#G)e.split("(")[0]===t&&n.push(r);if(e){for(let t=n.length-1;t>=0;t--)n[t].inputs.length<e.length&&n.splice(t,1);for(let t=n.length-1;t>=0;t--){const r=n[t].inputs;for(let i=0;i<e.length;i++)if(Fe.isTyped(e[i])&&e[i].type!==r[i].baseType){n.splice(t,1);break}}}return 0===n.length?null:(n.length>1&&r&&ot(!1,`ambiguous event description (i.e. matches ${n.map((t=>JSON.stringify(t.format()))).join(", ")})`,"key",t),n[0])}return this.#G.get(Qr.from(t).format())||null}getEventName(t){const e=this.#z(t,null,!1);return ot(e,"no matching event","key",t),e.name}hasEvent(t){return!!this.#z(t,null,!1)}getEvent(t,e){return this.#z(t,e||null,!0)}forEachEvent(t){const e=Array.from(this.#G.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#G.get(n),r)}}getError(t,e){if(ht(t)){const e=t.toLowerCase();if(zn[e])return qr.from(zn[e].signature);for(const t of this.#j.values())if(e===t.selector)return t;return null}if(-1===t.indexOf("(")){const e=[];for(const[r,n]of this.#j)r.split("(")[0]===t&&e.push(n);return 0===e.length?"Error"===t?qr.from("error Error(string)"):"Panic"===t?qr.from("error Panic(uint256)"):null:(e.length>1&&ot(!1,`ambiguous error description (i.e. ${e.map((t=>JSON.stringify(t.format()))).join(", ")})`,"name",t),e[0])}if("Error(string)"===(t=qr.from(t).format()))return qr.from("error Error(string)");if("Panic(uint256)"===t)return qr.from("error Panic(uint256)");return this.#j.get(t)||null}forEachError(t){const e=Array.from(this.#j.keys());e.sort(((t,e)=>t.localeCompare(e)));for(let r=0;r<e.length;r++){const n=e[r];t(this.#j.get(n),r)}}_decodeParams(t,e){return this.#K.decode(t,e)}_encodeParams(t,e){return this.#K.encode(t,e)}encodeDeploy(t){return this._encodeParams(this.deploy.inputs,t||[])}decodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);ot(e,"unknown error","fragment",t),t=e}return ot(wt(e,0,4)===t.selector,`data signature does not match error ${t.name}.`,"data",e),this._decodeParams(t.inputs,wt(e,4))}encodeErrorResult(t,e){if("string"==typeof t){const e=this.getError(t);ot(e,"unknown error","fragment",t),t=e}return gt([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}return ot(wt(e,0,4)===t.selector,`data signature does not match function ${t.name}.`,"data",e),this._decodeParams(t.inputs,wt(e,4))}encodeFunctionData(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}return gt([t.selector,this._encodeParams(t.inputs,e||[])])}decodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}let r="invalid length for result data";const n=ft(e);if(n.length%32==0)try{return this.#K.decode(t.outputs,n)}catch(t){r="could not decode result data"}it(!1,r,"BAD_DATA",{value:yt(n),info:{method:t.name,signature:t.format()}})}makeError(t,e){const r=lt(t,"data"),n=on.getBuiltinCallException("call",e,r);if(n.message.startsWith("execution reverted (unknown custom error)")){const t=yt(r.slice(0,4)),e=this.getError(t);if(e)try{const t=this.#K.decode(e.inputs,r.slice(4));n.revert={name:e.name,signature:e.format(),args:t},n.reason=n.revert.signature,n.message=`execution reverted: ${n.reason}`}catch(t){n.message="execution reverted (coult not decode custom error)"}}const i=this.parseTransaction(e);return i&&(n.invocation={method:i.name,signature:i.signature,args:i.args}),n}encodeFunctionResult(t,e){if("string"==typeof t){const e=this.getFunction(t);ot(e,"unknown function","fragment",t),t=e}return yt(this.#K.encode(t.outputs,e||[]))}encodeFilterTopics(t,e){if("string"==typeof t){const e=this.getEvent(t);ot(e,"unknown event","eventFragment",t),t=e}it(e.length<=t.inputs.length,`too many arguments for ${t.format()}`,"UNEXPECTED_ARGUMENT",{count:e.length,expectedCount:t.inputs.length});const r=[];t.anonymous||r.push(t.topicHash);const n=(t,e)=>"string"===t.type?ar(e):"bytes"===t.type?Pe(yt(e)):("bool"===t.type&&"boolean"==typeof e?e=e?"0x01":"0x00":t.type.match(/^u?int/)?e=Bt(e):t.type.match(/^bytes/)?e=mt(e,32,!1):"address"===t.type&&this.#K.encode(["address"],[e]),vt(yt(e),32));for(e.forEach(((e,i)=>{const o=t.inputs[i];o.indexed?null==e?r.push(null):"array"===o.baseType||"tuple"===o.baseType?ot(!1,"filtering with tuples or arrays not supported","contract."+o.name,e):Array.isArray(e)?r.push(e.map((t=>n(o,t)))):r.push(n(o,e)):ot(null==e,"cannot filter non-indexed parameters; must be null","contract."+o.name,e)}));r.length&&null===r[r.length-1];)r.pop();return r}encodeEventLog(t,e){if("string"==typeof t){const e=this.getEvent(t);ot(e,"unknown event","eventFragment",t),t=e}const r=[],n=[],i=[];return t.anonymous||r.push(t.topicHash),ot(e.length===t.inputs.length,"event arguments/values mismatch","values",e),t.inputs.forEach(((t,o)=>{const s=e[o];if(t.indexed)if("string"===t.type)r.push(ar(s));else if("bytes"===t.type)r.push(Pe(s));else{if("tuple"===t.baseType||"array"===t.baseType)throw new Error("not implemented");r.push(this.#K.encode([t.type],[s]))}else n.push(t),i.push(s)})),{data:this.#K.encode(n,i),topics:r}}decodeEventLog(t,e,r){if("string"==typeof t){const e=this.getEvent(t);ot(e,"unknown event","eventFragment",t),t=e}if(null!=r&&!t.anonymous){const e=t.topicHash;ot(ht(r[0],32)&&r[0].toLowerCase()===e,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const n=[],i=[],o=[];t.inputs.forEach(((t,e)=>{t.indexed?"string"===t.type||"bytes"===t.type||"tuple"===t.baseType||"array"===t.baseType?(n.push(Vr.from({type:"bytes32",name:t.name})),o.push(!0)):(n.push(t),o.push(!1)):(i.push(t),o.push(!1))}));const s=null!=r?this.#K.decode(n,gt(r)):null,a=this.#K.decode(i,e,!0),u=[],c=[];let l=0,f=0;return t.inputs.forEach(((t,e)=>{let r=null;if(t.indexed)if(null==s)r=new Kn(null);else if(o[e])r=new Kn(s[f++]);else try{r=s[f++]}catch(t){r=t}else try{r=a[l++]}catch(t){r=t}u.push(r),c.push(t.name||null)})),Ft.fromItems(u,c)}parseTransaction(t){const e=lt(t.data,"tx.data"),r=Tt(null!=t.value?t.value:0,"tx.value"),n=this.getFunction(yt(e.slice(0,4)));if(!n)return null;const i=this.#K.decode(n.inputs,e.slice(4));return new Gn(n,n.selector,i,r)}parseCallResult(t){throw new Error("@TODO")}parseLog(t){const e=this.getEvent(t.topics[0]);return!e||e.anonymous?null:new jn(e,e.topicHash,this.decodeEventLog(e,t.data,t.topics))}parseError(t){const e=yt(t),r=this.getError(wt(e,0,4));if(!r)return null;const n=this.#K.decode(r.inputs,wt(e,4));return new Vn(r,r.selector,n)}static from(t){return t instanceof qn?t:"string"==typeof t?new qn(JSON.parse(t)):"function"==typeof t.formatJson?new qn(t.formatJson()):"function"==typeof t.format?new qn(t.format("json")):new qn(t)}}const Qn=BigInt(0);function Jn(t){return null==t?null:t}function Xn(t){return null==t?null:t.toString()}class Yn{gasPrice;maxFeePerGas;maxPriorityFeePerGas;constructor(t,e,r){$(this,{gasPrice:Jn(t),maxFeePerGas:Jn(e),maxPriorityFeePerGas:Jn(r)})}toJSON(){const{gasPrice:t,maxFeePerGas:e,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:Xn(t),maxFeePerGas:Xn(e),maxPriorityFeePerGas:Xn(r)}}}function Zn(t){const e={};t.to&&(e.to=t.to),t.from&&(e.from=t.from),t.data&&(e.data=yt(t.data));const r="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const n of r)n in t&&null!=t[n]&&(e[n]=Tt(t[n],`request.${n}`));const n="type,nonce".split(/,/);for(const r of n)r in t&&null!=t[r]&&(e[r]=xt(t[r],`request.${r}`));return t.accessList&&(e.accessList=kn(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((t=>pt(t)?yt(t):Object.assign({},t)))),e}class $n{provider;number;hash;timestamp;parentHash;parentBeaconBlockRoot;nonce;difficulty;gasLimit;gasUsed;stateRoot;receiptsRoot;blobGasUsed;excessBlobGas;miner;prevRandao;extraData;baseFeePerGas;#q;constructor(t,e){this.#q=t.transactions.map((t=>"string"!=typeof t?new ri(t,e):t)),$(this,{provider:e,hash:Jn(t.hash),number:t.number,timestamp:t.timestamp,parentHash:t.parentHash,parentBeaconBlockRoot:t.parentBeaconBlockRoot,nonce:t.nonce,difficulty:t.difficulty,gasLimit:t.gasLimit,gasUsed:t.gasUsed,blobGasUsed:t.blobGasUsed,excessBlobGas:t.excessBlobGas,miner:t.miner,prevRandao:Jn(t.prevRandao),extraData:t.extraData,baseFeePerGas:Jn(t.baseFeePerGas),stateRoot:t.stateRoot,receiptsRoot:t.receiptsRoot})}get transactions(){return this.#q.map((t=>"string"==typeof t?t:t.hash))}get prefetchedTransactions(){const t=this.#q.slice();return 0===t.length?[]:(it("object"==typeof t[0],"transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),t)}toJSON(){const{baseFeePerGas:t,difficulty:e,extraData:r,gasLimit:n,gasUsed:i,hash:o,miner:s,prevRandao:a,nonce:u,number:c,parentHash:l,parentBeaconBlockRoot:f,stateRoot:h,receiptsRoot:p,timestamp:d,transactions:y}=this;return{_type:"Block",baseFeePerGas:Xn(t),difficulty:Xn(e),extraData:r,gasLimit:Xn(n),gasUsed:Xn(i),blobGasUsed:Xn(this.blobGasUsed),excessBlobGas:Xn(this.excessBlobGas),hash:o,miner:s,prevRandao:a,nonce:u,number:c,parentHash:l,timestamp:d,parentBeaconBlockRoot:f,stateRoot:h,receiptsRoot:p,transactions:y}}[Symbol.iterator](){let t=0;const e=this.transactions;return{next:()=>t<this.length?{value:e[t++],done:!1}:{value:void 0,done:!0}}}get length(){return this.#q.length}get date(){return null==this.timestamp?null:new Date(1e3*this.timestamp)}async getTransaction(t){let e;if("number"==typeof t)e=this.#q[t];else{const r=t.toLowerCase();for(const t of this.#q){if("string"==typeof t){if(t!==r)continue;e=t;break}if(t.hash!==r){e=t;break}}}if(null==e)throw new Error("no such tx");return"string"==typeof e?await this.provider.getTransaction(e):e}getPrefetchedTransaction(t){const e=this.prefetchedTransactions;if("number"==typeof t)return e[t];t=t.toLowerCase();for(const r of e)if(r.hash===t)return r;ot(!1,"no matching transaction","indexOrHash",t)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return{orphan:"drop-block",hash:this.hash,number:this.number}}}class ti{provider;transactionHash;blockHash;blockNumber;removed;address;data;topics;index;transactionIndex;constructor(t,e){this.provider=e;const r=Object.freeze(t.topics.slice());$(this,{transactionHash:t.transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,removed:t.removed,address:t.address,data:t.data,topics:r,index:t.index,transactionIndex:t.transactionIndex})}toJSON(){const{address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:o,topics:s,transactionHash:a,transactionIndex:u}=this;return{_type:"log",address:t,blockHash:e,blockNumber:r,data:n,index:i,removed:o,topics:s,transactionHash:a,transactionIndex:u}}async getBlock(){const t=await this.provider.getBlock(this.blockHash);return it(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransaction(){const t=await this.provider.getTransaction(this.transactionHash);return it(!!t,"failed to find transaction","UNKNOWN_ERROR",{}),t}async getTransactionReceipt(){const t=await this.provider.getTransactionReceipt(this.transactionHash);return it(!!t,"failed to find transaction receipt","UNKNOWN_ERROR",{}),t}removedEvent(){return{orphan:"drop-log",log:{transactionHash:(t=this).transactionHash,blockHash:t.blockHash,blockNumber:t.blockNumber,address:t.address,data:t.data,topics:Object.freeze(t.topics.slice()),index:t.index}};var t}}class ei{provider;to;from;contractAddress;hash;index;blockHash;blockNumber;logsBloom;gasUsed;blobGasUsed;cumulativeGasUsed;gasPrice;blobGasPrice;type;status;root;#Q;constructor(t,e){this.#Q=Object.freeze(t.logs.map((t=>new ti(t,e))));let r=Qn;null!=t.effectiveGasPrice?r=t.effectiveGasPrice:null!=t.gasPrice&&(r=t.gasPrice),$(this,{provider:e,to:t.to,from:t.from,contractAddress:t.contractAddress,hash:t.hash,index:t.index,blockHash:t.blockHash,blockNumber:t.blockNumber,logsBloom:t.logsBloom,gasUsed:t.gasUsed,cumulativeGasUsed:t.cumulativeGasUsed,blobGasUsed:t.blobGasUsed,gasPrice:r,blobGasPrice:t.blobGasPrice,type:t.type,status:t.status,root:t.root})}get logs(){return this.#Q}toJSON(){const{to:t,from:e,contractAddress:r,hash:n,index:i,blockHash:o,blockNumber:s,logsBloom:a,logs:u,status:c,root:l}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:s,contractAddress:r,cumulativeGasUsed:Xn(this.cumulativeGasUsed),from:e,gasPrice:Xn(this.gasPrice),blobGasUsed:Xn(this.blobGasUsed),blobGasPrice:Xn(this.blobGasPrice),gasUsed:Xn(this.gasUsed),hash:n,index:i,logs:u,logsBloom:a,root:l,status:c,to:t}}get length(){return this.logs.length}[Symbol.iterator](){let t=0;return{next:()=>t<this.length?{value:this.logs[t++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const t=await this.provider.getBlock(this.blockHash);if(null==t)throw new Error("TODO");return t}async getTransaction(){const t=await this.provider.getTransaction(this.hash);if(null==t)throw new Error("TODO");return t}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return ii(this)}reorderedEvent(t){return it(!t||t.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),ni(this,t)}}class ri{provider;blockNumber;blockHash;index;hash;type;to;from;nonce;gasLimit;gasPrice;maxPriorityFeePerGas;maxFeePerGas;maxFeePerBlobGas;data;value;chainId;signature;accessList;blobVersionedHashes;#J;constructor(t,e){this.provider=e,this.blockNumber=null!=t.blockNumber?t.blockNumber:null,this.blockHash=null!=t.blockHash?t.blockHash:null,this.hash=t.hash,this.index=t.index,this.type=t.type,this.from=t.from,this.to=t.to||null,this.gasLimit=t.gasLimit,this.nonce=t.nonce,this.data=t.data,this.value=t.value,this.gasPrice=t.gasPrice,this.maxPriorityFeePerGas=null!=t.maxPriorityFeePerGas?t.maxPriorityFeePerGas:null,this.maxFeePerGas=null!=t.maxFeePerGas?t.maxFeePerGas:null,this.maxFeePerBlobGas=null!=t.maxFeePerBlobGas?t.maxFeePerBlobGas:null,this.chainId=t.chainId,this.signature=t.signature,this.accessList=null!=t.accessList?t.accessList:null,this.blobVersionedHashes=null!=t.blobVersionedHashes?t.blobVersionedHashes:null,this.#J=-1}toJSON(){const{blockNumber:t,blockHash:e,index:r,hash:n,type:i,to:o,from:s,nonce:a,data:u,signature:c,accessList:l,blobVersionedHashes:f}=this;return{_type:"TransactionResponse",accessList:l,blockNumber:t,blockHash:e,blobVersionedHashes:f,chainId:Xn(this.chainId),data:u,from:s,gasLimit:Xn(this.gasLimit),gasPrice:Xn(this.gasPrice),hash:n,maxFeePerGas:Xn(this.maxFeePerGas),maxPriorityFeePerGas:Xn(this.maxPriorityFeePerGas),maxFeePerBlobGas:Xn(this.maxFeePerBlobGas),nonce:a,signature:c,to:o,index:r,type:i,value:Xn(this.value)}}async getBlock(){let t=this.blockNumber;if(null==t){const e=await this.getTransaction();e&&(t=e.blockNumber)}if(null==t)return null;const e=this.provider.getBlock(t);if(null==e)throw new Error("TODO");return e}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(null==this.blockNumber){const{tx:t,blockNumber:e}=await Z({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return null==t||null==t.blockNumber?0:e-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(t,e){const r=null==t?1:t,n=null==e?0:e;let i=this.#J,o=-1,s=-1===i;const a=async()=>{if(s)return null;const{blockNumber:t,nonce:e}=await Z({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(e<this.nonce)return void(i=t);if(s)return null;const n=await this.getTransaction();if(!n||null==n.blockNumber)for(-1===o&&(o=i-3,o<this.#J&&(o=this.#J));o<=t;){if(s)return null;const e=await this.provider.getBlock(o,!0);if(null==e)return;for(const t of e)if(t===this.hash)return;for(let n=0;n<e.length;n++){const o=await e.getTransaction(n);if(o.from===this.from&&o.nonce===this.nonce){if(s)return null;const e=await this.provider.getTransactionReceipt(o.hash);if(null==e)return;if(t-e.blockNumber+1<r)return;let n="replaced";o.data===this.data&&o.to===this.to&&o.value===this.value?n="repriced":"0x"===o.data&&o.from===o.to&&o.value===Qn&&(n="cancelled"),it(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:"replaced"===n||"cancelled"===n,reason:n,replacement:o.replaceableTransaction(i),hash:o.hash,receipt:e})}}o++}},u=t=>{if(null==t||0!==t.status)return t;it(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:t.to,from:t.from,data:""},receipt:t})},c=await this.provider.getTransactionReceipt(this.hash);if(0===r)return u(c);if(c){if(await c.confirmations()>=r)return u(c)}else if(await a(),0===r)return null;const l=new Promise(((t,e)=>{const o=[],c=()=>{o.forEach((t=>t()))};if(o.push((()=>{s=!0})),n>0){const t=setTimeout((()=>{c(),e(nt("wait for transaction timeout","TIMEOUT"))}),n);o.push((()=>{clearTimeout(t)}))}const l=async n=>{if(await n.confirmations()>=r){c();try{t(u(n))}catch(t){e(t)}}};if(o.push((()=>{this.provider.off(this.hash,l)})),this.provider.on(this.hash,l),i>=0){const t=async()=>{try{await a()}catch(t){if(et(t,"TRANSACTION_REPLACED"))return c(),void e(t)}s||this.provider.once("block",t)};o.push((()=>{this.provider.off("block",t)})),this.provider.once("block",t)}}));return await l}isMined(){return null!=this.blockHash}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}removedEvent(){return it(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ii(this)}reorderedEvent(t){return it(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),it(!t||t.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),ni(this,t)}replaceableTransaction(t){ot(Number.isInteger(t)&&t>=0,"invalid startBlock","startBlock",t);const e=new ri(this,this.provider);return e.#J=t,e}}function ni(t,e){return{orphan:"reorder-transaction",tx:t,other:e}}function ii(t){return{orphan:"drop-transaction",tx:t}}class oi{filter;emitter;#X;constructor(t,e,r){this.#X=e,$(this,{emitter:t,filter:r})}async removeListener(){null!=this.#X&&await this.emitter.off(this.filter,this.#X)}}class si extends ti{interface;fragment;args;constructor(t,e,r){super(t,t.provider),$(this,{args:e.decodeEventLog(r,t.data,t.topics),fragment:r,interface:e})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class ai extends ti{error;constructor(t,e){super(t,t.provider),$(this,{error:e})}}class ui extends ei{#Y;constructor(t,e,r){super(r,e),this.#Y=t}get logs(){return super.logs.map((t=>{const e=t.topics.length?this.#Y.getEvent(t.topics[0]):null;if(e)try{return new si(t,this.#Y,e)}catch(e){return new ai(t,e)}return t}))}}class ci extends ri{#Y;constructor(t,e,r){super(r,e),this.#Y=t}async wait(t,e){const r=await super.wait(t,e);return null==r?null:new ui(this.#Y,this.provider,r)}}class li extends oi{log;constructor(t,e,r,n){super(t,e,r),$(this,{log:n})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class fi extends li{constructor(t,e,r,n,i){super(t,e,r,new si(i,t.interface,n)),$(this,{args:t.interface.decodeEventLog(n,this.log.data,this.log.topics),fragment:n})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const hi=BigInt(0);function pi(t){return t&&"function"==typeof t.call}function di(t){return t&&"function"==typeof t.estimateGas}function yi(t){return t&&"function"==typeof t.resolveName}function gi(t){return t&&"function"==typeof t.sendTransaction}function bi(t){if(null!=t){if(yi(t))return t;if(t.provider)return t.provider}}class wi{#Z;fragment;constructor(t,e,r){if($(this,{fragment:e}),e.inputs.length<r.length)throw new Error("too many arguments");const n=mi(t.runner,"resolveName"),i=yi(n)?n:null;this.#Z=async function(){const n=await Promise.all(e.inputs.map(((t,e)=>null==r[e]?null:t.walkAsync(r[e],((t,e)=>"address"===t?Array.isArray(e)?Promise.all(e.map((t=>un(t,i)))):un(e,i):e)))));return t.interface.encodeFilterTopics(e,n)}()}getTopicFilter(){return this.#Z}}function mi(t,e){return null==t?null:"function"==typeof t[e]?t:t.provider&&"function"==typeof t.provider[e]?t.provider:null}function vi(t){return null==t?null:t.provider||null}async function Ei(t,e){const r=Fe.dereference(t,"overrides");ot("object"==typeof r,"invalid overrides parameter","overrides",t);const n=Zn(r);return ot(null==n.to||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",n.to),ot(null==n.data||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",n.data),n.from&&(n.from=n.from),n}function Ai(t){const e=async function(e){const r=await Ei(e,["data"]);r.to=await t.getAddress(),r.from&&(r.from=await un(r.from,bi(t.runner)));const n=t.interface,i=Tt(r.value||hi,"overrides.value")===hi,o="0x"===(r.data||"0x");return!n.fallback||n.fallback.payable||!n.receive||o||i||ot(!1,"cannot send data to receive or send value to non-payable fallback","overrides",e),ot(n.fallback||o,"cannot send data to receive-only contract","overrides.data",r.data),ot(n.receive||n.fallback&&n.fallback.payable||i,"cannot send value to non-payable fallback","overrides.value",r.value),ot(n.fallback||o,"cannot send data to receive-only contract","overrides.data",r.data),r},r=async function(r){const n=t.runner;it(gi(n),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=await n.sendTransaction(await e(r)),o=vi(t.runner);return new ci(t.interface,o,i)},n=async t=>await r(t);return $(n,{_contract:t,estimateGas:async function(r){const n=mi(t.runner,"estimateGas");return it(di(n),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await n.estimateGas(await e(r))},populateTransaction:e,send:r,staticCall:async function(r){const n=mi(t.runner,"call");it(pi(n),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const i=await e(r);try{return await n.call(i)}catch(e){if(rt(e)&&e.data)throw t.interface.makeError(e.data,i);throw e}}}),n}const Si=Symbol.for("_ethersInternal_contract"),_i=new WeakMap;function ki(t){return _i.get(t[Si])}async function Ti(t,e){let r,n=null;if(Array.isArray(e)){const n=function(e){if(ht(e,32))return e;const r=t.interface.getEvent(e);return ot(r,"unknown fragment","name",e),r.topicHash};r=e.map((t=>null==t?null:Array.isArray(t)?t.map(n):n(t)))}else"*"===e?r=[null]:"string"==typeof e?ht(e,32)?r=[e]:(n=t.interface.getEvent(e),ot(n,"unknown fragment","event",e),r=[n.topicHash]):(i=e)&&"object"==typeof i&&"getTopicFilter"in i&&"function"==typeof i.getTopicFilter&&i.fragment?r=await e.getTopicFilter():"fragment"in e?(n=e.fragment,r=[n.topicHash]):ot(!1,"unknown event name","event",e);var i;return r=r.map((t=>{if(null==t)return null;if(Array.isArray(t)){const e=Array.from(new Set(t.map((t=>t.toLowerCase()))).values());return 1===e.length?e[0]:(e.sort(),e)}return t.toLowerCase()})),{fragment:n,tag:r.map((t=>null==t?"null":Array.isArray(t)?t.join("|"):t)).join("&"),topics:r}}async function Pi(t,e){const{subs:r}=ki(t);return r.get((await Ti(t,e)).tag)||null}async function Ii(t,e,r){const n=vi(t.runner);it(n,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:i,tag:o,topics:s}=await Ti(t,r),{addr:a,subs:u}=ki(t);let c=u.get(o);if(!c){const e={address:a||t,topics:s},l=e=>{let n=i;if(null==n)try{n=t.interface.getEvent(e.topics[0])}catch(t){}if(n){const o=n,s=i?t.interface.decodeEventLog(i,e.data,e.topics):[];xi(t,r,s,(n=>new fi(t,n,r,o,e)))}else xi(t,r,[],(n=>new li(t,n,r,e)))};let f=[];c={tag:o,listeners:[],start:()=>{f.length||f.push(n.on(e,l))},stop:async()=>{if(0==f.length)return;let t=f;f=[],await Promise.all(t),n.off(e,l)}},u.set(o,c)}return c}let Oi=Promise.resolve();async function xi(t,e,r,n){try{await Oi}catch(t){}const i=async function(t,e,r,n){await Oi;const i=await Pi(t,e);if(!i)return!1;const o=i.listeners.length;return i.listeners=i.listeners.filter((({listener:e,once:i})=>{const o=Array.from(r);n&&o.push(n(i?null:e));try{e.call(t,...o)}catch(t){}return!i})),0===i.listeners.length&&(i.stop(),ki(t).subs.delete(i.tag)),o>0}(t,e,r,n);return Oi=i,await i}const Bi=["then"];class Ri{target;interface;runner;filters;[Si];fallback;constructor(t,e,r,n){ot("string"==typeof t||sn(t),"invalid value for Contract target","target",t),null==r&&(r=null);const i=qn.from(e);let o;$(this,{target:t,runner:r,interface:i}),Object.defineProperty(this,Si,{value:{}});let s=null,a=null;if(n){const t=vi(r);a=new ci(this.interface,t,n)}let u=new Map;if("string"==typeof t)if(ht(t))s=t,o=Promise.resolve(t);else{const e=mi(r,"resolveName");if(!yi(e))throw nt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=e.resolveName(t).then((e=>{if(null==e)throw nt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:t});return ki(this).addr=e,e}))}else o=t.getAddress().then((t=>{if(null==t)throw new Error("TODO");return ki(this).addr=t,t}));var c;c={addrPromise:o,addr:s,deployTx:a,subs:u},_i.set(this[Si],c);const l=new Proxy({},{get:(t,e,r)=>{if("symbol"==typeof e||Bi.indexOf(e)>=0)return Reflect.get(t,e,r);try{return this.getEvent(e)}catch(t){if(!et(t,"INVALID_ARGUMENT")||"key"!==t.argument)throw t}},has:(t,e)=>Bi.indexOf(e)>=0?Reflect.has(t,e):Reflect.has(t,e)||this.interface.hasEvent(String(e))});return $(this,{filters:l}),$(this,{fallback:i.receive||i.fallback?Ai(this):null}),new Proxy(this,{get:(t,e,r)=>{if("symbol"==typeof e||e in t||Bi.indexOf(e)>=0)return Reflect.get(t,e,r);try{return t.getFunction(e)}catch(t){if(!et(t,"INVALID_ARGUMENT")||"key"!==t.argument)throw t}},has:(t,e)=>"symbol"==typeof e||e in t||Bi.indexOf(e)>=0?Reflect.has(t,e):t.interface.hasFunction(e)})}connect(t){return new Ri(this.target,this.interface,t)}attach(t){return new Ri(t,this.interface,this.runner)}async getAddress(){return await ki(this).addrPromise}async getDeployedCode(){const t=vi(this.runner);it(t,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const e=await t.getCode(await this.getAddress());return"0x"===e?null:e}async waitForDeployment(){const t=this.deploymentTransaction();if(t)return await t.wait(),this;if(null!=await this.getDeployedCode())return this;const e=vi(this.runner);return it(null!=e,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise(((t,r)=>{const n=async()=>{try{if(null!=await this.getDeployedCode())return t(this);e.once("block",n)}catch(t){r(t)}};n()}))}deploymentTransaction(){return ki(this).deployTx}getFunction(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getFunction(e,r);return it(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=async function(...e){const n=r(...e);let i={};if(n.inputs.length+1===e.length&&(i=await Ei(e.pop()),i.from&&(i.from=await un(i.from,bi(t.runner)))),n.inputs.length!==e.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const o=await async function(t,e,r){const n=mi(t,"resolveName"),i=yi(n)?n:null;return await Promise.all(e.map(((t,e)=>t.walkAsync(r[e],((t,e)=>(e=Fe.dereference(e,t),"address"===t?un(e,i):e))))))}(t.runner,n.inputs,e);return Object.assign({},i,await Z({to:t.getAddress(),data:t.interface.encodeFunctionData(n,o)}))},i=async function(...t){const e=await s(...t);return 1===e.length?e[0]:e},o=async function(...e){const r=t.runner;it(gi(r),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const i=await r.sendTransaction(await n(...e)),o=vi(t.runner);return new ci(t.interface,o,i)},s=async function(...e){const i=mi(t.runner,"call");it(pi(i),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const o=await n(...e);let s="0x";try{s=await i.call(o)}catch(e){if(rt(e)&&e.data)throw t.interface.makeError(e.data,o);throw e}const a=r(...e);return t.interface.decodeFunctionResult(a,s)},a=async(...t)=>r(...t).constant?await i(...t):await o(...t);return $(a,{name:t.interface.getFunctionName(e),_contract:t,_key:e,getFragment:r,estimateGas:async function(...e){const r=mi(t.runner,"estimateGas");return it(di(r),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await r.estimateGas(await n(...e))},populateTransaction:n,send:o,staticCall:i,staticCallResult:s}),Object.defineProperty(a,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getFunction(e);return it(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),a}(this,t)}getEvent(t){return"string"!=typeof t&&(t=t.format()),function(t,e){const r=function(...r){const n=t.interface.getEvent(e,r);return it(n,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:r}}),n},n=function(...e){return new wi(t,r(...e),e)};return $(n,{name:t.interface.getEventName(e),_contract:t,_key:e,getFragment:r}),Object.defineProperty(n,"fragment",{configurable:!1,enumerable:!0,get:()=>{const r=t.interface.getEvent(e);return it(r,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),r}}),n}(this,t)}async queryTransaction(t){throw new Error("@TODO")}async queryFilter(t,e,r){null==e&&(e=0),null==r&&(r="latest");const{addr:n,addrPromise:i}=ki(this),o=n||await i,{fragment:s,topics:a}=await Ti(this,t),u={address:o,topics:a,fromBlock:e,toBlock:r},c=vi(this.runner);return it(c,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await c.getLogs(u)).map((t=>{let e=s;if(null==e)try{e=this.interface.getEvent(t.topics[0])}catch(t){}if(e)try{return new si(t,this.interface,e)}catch(e){return new ai(t,e)}return new ti(t,c)}))}async on(t,e){const r=await Ii(this,"on",t);return r.listeners.push({listener:e,once:!1}),r.start(),this}async once(t,e){const r=await Ii(this,"once",t);return r.listeners.push({listener:e,once:!0}),r.start(),this}async emit(t,...e){return await xi(this,t,e,null)}async listenerCount(t){if(t){const e=await Pi(this,t);return e?e.listeners.length:0}const{subs:e}=ki(this);let r=0;for(const{listeners:t}of e.values())r+=t.length;return r}async listeners(t){if(t){const e=await Pi(this,t);return e?e.listeners.map((({listener:t})=>t)):[]}const{subs:e}=ki(this);let r=[];for(const{listeners:t}of e.values())r=r.concat(t.map((({listener:t})=>t)));return r}async off(t,e){const r=await Pi(this,t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return null!=e&&0!==r.listeners.length||(r.stop(),ki(this).subs.delete(r.tag)),this}async removeAllListeners(t){if(t){const e=await Pi(this,t);if(!e)return this;e.stop(),ki(this).subs.delete(e.tag)}else{const{subs:t}=ki(this);for(const{tag:e,stop:r}of t.values())r(),t.delete(e)}return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return await this.off(t,e)}static buildClass(t){return class extends Ri{constructor(e,r=null){super(e,t,r)}}}static from(t,e,r){return null==r&&(r=null),new this(t,e,r)}}class Ni extends(function(){return Ri}()){}var Ui="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";const Ci=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),Li=4;function Di(t){return function(t){let e=0;return()=>t[e++]}(function(t){let e=0;function r(){return t[e++]<<8|t[e++]}let n=r(),i=1,o=[0,1];for(let t=1;t<n;t++)o.push(i+=r());let s=r(),a=e;e+=s;let u=0,c=0;function l(){return 0==u&&(c=c<<8|t[e++],u=8),c>>--u&1}const f=2**31,h=f>>>1,p=h>>1,d=f-1;let y=0;for(let t=0;t<31;t++)y=y<<1|l();let g=[],b=0,w=f;for(;;){let t=Math.floor(((y-b+1)*i-1)/w),e=0,r=n;for(;r-e>1;){let n=e+r>>>1;t<o[n]?r=n:e=n}if(0==e)break;g.push(e);let s=b+Math.floor(w*o[e]/i),a=b+Math.floor(w*o[e+1]/i)-1;for(;!((s^a)&h);)y=y<<1&d|l(),s=s<<1&d,a=a<<1&d|1;for(;s&~a&p;)y=y&h|y<<1&d>>>1|l(),s=s<<1^h,a=(a^h)<<1|h|1;b=s,w=1+a-s}let m=n-4;return g.map((e=>{switch(e-m){case 3:return m+65792+(t[a++]<<16|t[a++]<<8|t[a++]);case 2:return m+256+(t[a++]<<8|t[a++]);case 1:return m+t[a++];default:return e-1}}))}(function(t){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach(((t,r)=>e[t.charCodeAt(0)]=r));let r=t.length,n=new Uint8Array(6*r>>3);for(let i=0,o=0,s=0,a=0;i<r;i++)a=a<<6|e[t.charCodeAt(i)],s+=6,s>=8&&(n[o++]=a>>(s-=8));return n}(t)))}function Mi(t){return 1&t?~t>>1:t>>1}function Fi(t,e){let r=Array(t);for(let n=0,i=0;n<t;n++)r[n]=i+=Mi(e());return r}function Hi(t,e=0){let r=[];for(;;){let n=t(),i=t();if(!i)break;e+=n;for(let t=0;t<i;t++)r.push(e+t);e+=i+1}return r}function ji(t){return Vi((()=>{let e=Hi(t);if(e.length)return e}))}function Gi(t){let e=[];for(;;){let r=t();if(0==r)break;e.push(Wi(r,t))}for(;;){let r=t()-1;if(r<0)break;e.push(zi(r,t))}return e.flat()}function Vi(t){let e=[];for(;;){let r=t(e.length);if(!r)break;e.push(r)}return e}function Ki(t,e,r){let n=Array(t).fill().map((()=>[]));for(let i=0;i<e;i++)Fi(t,r).forEach(((t,e)=>n[e].push(t)));return n}function Wi(t,e){let r=1+e(),n=e(),i=Vi(e);return Ki(i.length,1+t,e).flatMap(((t,e)=>{let[o,...s]=t;return Array(i[e]).fill().map(((t,e)=>{let i=e*n;return[o+e*r,s.map((t=>t+i))]}))}))}function zi(t,e){return Ki(1+e(),1+t,e).map((t=>[t[0],t.slice(1)]))}function qi(t){return`{${function(t){return t.toString(16).toUpperCase().padStart(2,"0")}(t)}}`}function Qi(t){let e=t.length;if(e<4096)return String.fromCodePoint(...t);let r=[];for(let n=0;n<e;)r.push(String.fromCodePoint(...t.slice(n,n+=4096)));return r.join("")}function Ji(t,e){let r=t.length,n=r-e.length;for(let i=0;0==n&&i<r;i++)n=t[i]-e[i];return n}var Xi="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";const Yi=44032,Zi=4352,$i=4449,to=4519,eo=28,ro=21*eo,no=Yi+19*ro,io=Zi+19,oo=$i+21,so=to+eo;function ao(t){return t>>24&255}function uo(t){return 16777215&t}let co,lo,fo,ho;function po(t){return t>=Yi&&t<no}function yo(t,e){if(t>=Zi&&t<io&&e>=$i&&e<oo)return Yi+(t-Zi)*ro+(e-$i)*eo;if(po(t)&&e>to&&e<so&&(t-Yi)%eo==0)return t+(e-to);{let r=ho.get(t);return r&&(r=r.get(e),r)?r:-1}}function go(t){co||function(){let t=Di(Xi);co=new Map(ji(t).flatMap(((t,e)=>t.map((t=>[t,e+1<<24]))))),lo=new Set(Hi(t)),fo=new Map,ho=new Map;for(let[e,r]of Gi(t)){if(!lo.has(e)&&2==r.length){let[t,n]=r,i=ho.get(t);i||(i=new Map,ho.set(t,i)),i.set(n,e)}fo.set(e,r.reverse())}}();let e=[],r=[],n=!1;function i(t){let r=co.get(t);r&&(n=!0,t|=r),e.push(t)}for(let n of t)for(;;){if(n<128)e.push(n);else if(po(n)){let t=n-Yi,e=t%ro/eo|0,r=t%eo;i(Zi+(t/ro|0)),i($i+e),r>0&&i(to+r)}else{let t=fo.get(n);t?r.push(...t):i(n)}if(!r.length)break;n=r.pop()}if(n&&e.length>1){let t=ao(e[0]);for(let r=1;r<e.length;r++){let n=ao(e[r]);if(0==n||t<=n){t=n;continue}let i=r-1;for(;;){let r=e[i+1];if(e[i+1]=e[i],e[i]=r,!i)break;if(t=ao(e[--i]),t<=n)break}t=ao(e[r])}}return e}function bo(t){return go(t).map(uo)}function wo(t){return function(t){let e=[],r=[],n=-1,i=0;for(let o of t){let t=ao(o),s=uo(o);if(-1==n)0==t?n=s:e.push(s);else if(i>0&&i>=t)0==t?(e.push(n,...r),r.length=0,n=s):r.push(s),i=t;else{let o=yo(n,s);o>=0?n=o:0==i&&0==t?(e.push(n),n=s):(r.push(s),i=t)}}return n>=0&&e.push(n,...r),e}(go(t))}const mo=45,vo=".",Eo=65039,Ao=1,So=t=>Array.from(t);function _o(t,e){return t.P.has(e)||t.Q.has(e)}class ko extends Array{get is_emoji(){return!0}}let To,Po,Io,Oo,xo,Bo,Ro,No,Uo,Co,Lo,Do;function Mo(){if(To)return;let t=Di(Ui);const e=()=>Hi(t),r=()=>new Set(e()),n=(t,e)=>e.forEach((e=>t.add(e)));To=new Map(Gi(t)),Po=r(),Io=e(),Oo=new Set(e().map((t=>Io[t]))),Io=new Set(Io),xo=r(),Bo=r();let i=ji(t),o=t();const s=()=>{let t=new Set;return e().forEach((e=>n(t,i[e]))),n(t,e()),t};Ro=Vi((e=>{let r=Vi(t).map((t=>t+96));if(r.length){let n=e>=o;return r[0]-=32,r=Qi(r),n&&(r=`Restricted[${r}]`),{N:r,P:s(),Q:s(),M:!t(),R:n}}})),No=r(),Uo=new Map;let a=e().concat(So(No)).sort(((t,e)=>t-e));a.forEach(((e,r)=>{let n=t(),i=a[r]=n?a[r-n]:{V:[],M:new Map};i.V.push(e),No.has(e)||Uo.set(e,i)}));for(let{V:t,M:e}of new Set(Uo.values())){let r=[];for(let e of t){let t=Ro.filter((t=>_o(t,e))),i=r.find((({G:e})=>t.some((t=>e.has(t)))));i||(i={G:new Set,V:[]},r.push(i)),i.V.push(e),n(i.G,t)}let i=r.flatMap((t=>So(t.G)));for(let{G:t,V:n}of r){let r=new Set(i.filter((e=>!t.has(e))));for(let t of n)e.set(t,r)}}Co=new Set;let u=new Set;const c=t=>Co.has(t)?u.add(t):Co.add(t);for(let t of Ro){for(let e of t.P)c(e);for(let e of t.Q)c(e)}for(let t of Co)Uo.has(t)||u.has(t)||Uo.set(t,Ao);n(Co,bo(Co)),Lo=function(t){let e=[],r=Hi(t);return function t({S:r,B:n},i,o){if(!(4&r&&o===i[i.length-1])){2&r&&(o=i[i.length-1]),1&r&&e.push(i);for(let e of n)for(let r of e.Q)t(e,[...i,r],o)}}(function e(n){return{S:t(),B:Vi((()=>{let n=Hi(t).map((t=>r[t]));if(n.length)return e(n)})),Q:n}}([]),[]),e}(t).map((t=>ko.from(t))).sort(Ji),Do=new Map;for(let t of Lo){let e=[Do];for(let r of t){let t=e.map((t=>{let e=t.get(r);return e||(e=new Map,t.set(r,e)),e}));r===Eo?e.push(...t):e=t}for(let r of e)r.V=t}}function Fo(t){return(Go(t)?"":`${Ho(jo([t]))} `)+qi(t)}function Ho(t){return`"${t}"‎`}function jo(t,e=1/0,r=qi){let n=[];var i;i=t[0],Mo(),Io.has(i)&&n.push("◌"),t.length>e&&(e>>=1,t=[...t.slice(0,e),8230,...t.slice(-e)]);let o=0,s=t.length;for(let e=0;e<s;e++){let i=t[e];Go(i)&&(n.push(Qi(t.slice(o,e))),n.push(r(i)),o=e+1)}return n.push(Qi(t.slice(o,s))),n.join("")}function Go(t){return Mo(),xo.has(t)}function Vo(t,e,r){if(!t)return[];Mo();let n=0;return t.split(vo).map((t=>{let i=function(t){let e=[];for(let r=0,n=t.length;r<n;){let n=t.codePointAt(r);r+=n<65536?1:2,e.push(n)}return e}(t),o={input:i,offset:n};n+=i.length+1;try{let t,n=o.tokens=function(t,e,r){let n=[],i=[];for(t=t.slice().reverse();t.length;){let o=Qo(t);if(o)i.length&&(n.push(e(i)),i=[]),n.push(r(o));else{let e=t.pop();if(Co.has(e))i.push(e);else{let t=To.get(e);if(t)i.push(...t);else if(!Po.has(e))throw Ko(e)}}}return i.length&&n.push(e(i)),n}(i,e,r),s=n.length;if(!s)throw new Error("empty label");let a=o.output=n.flat();if(function(t){for(let e=t.lastIndexOf(95);e>0;)if(95!==t[--e])throw new Error("underscore allowed only at start")}(a),!(o.emoji=s>1||n[0].is_emoji)&&a.every((t=>t<128)))!function(t){if(t.length>=4&&t[2]==mo&&t[3]==mo)throw new Error(`invalid label extension: "${Qi(t.slice(0,4))}"`)}(a),t="ASCII";else{let e=n.flatMap((t=>t.is_emoji?[]:t));if(e.length){if(Io.has(a[0]))throw zo("leading combining mark");for(let t=1;t<s;t++){let e=n[t];if(!e.is_emoji&&Io.has(e[0]))throw zo(`emoji + combining mark: "${Qi(n[t-1])} + ${jo([e[0]])}"`)}!function(t){let e=t[0],r=Ci.get(e);if(r)throw zo(`leading ${r}`);let n=t.length,i=-1;for(let o=1;o<n;o++){e=t[o];let n=Ci.get(e);if(n){if(i==o)throw zo(`${r} + ${n}`);i=o+1,r=n}}if(i==n)throw zo(`trailing ${r}`)}(a);let r=So(new Set(e)),[i]=function(t){let e=Ro;for(let r of t){let t=e.filter((t=>_o(t,r)));if(!t.length)throw Ro.some((t=>_o(t,r)))?Wo(e[0],r):Ko(r);if(e=t,1==t.length)break}return e}(r);!function(t,e){for(let r of e)if(!_o(t,r))throw Wo(t,r);if(t.M){let t=bo(e);for(let e=1,r=t.length;e<r;e++)if(Oo.has(t[e])){let n=e+1;for(let i;n<r&&Oo.has(i=t[n]);n++)for(let r=e;r<n;r++)if(t[r]==i)throw new Error(`duplicate non-spacing marks: ${Fo(i)}`);if(n-e>Li)throw new Error(`excessive non-spacing marks: ${Ho(jo(t.slice(e-1,n)))} (${n-e}/${Li})`);e=n}}}(i,e),function(t,e){let r,n=[];for(let t of e){let e=Uo.get(t);if(e===Ao)return;if(e){let n=e.M.get(t);if(r=r?r.filter((t=>n.has(t))):So(n),!r.length)return}else n.push(t)}if(r)for(let e of r)if(n.every((t=>_o(e,t))))throw new Error(`whole-script confusable: ${t.N}/${e.N}`)}(i,r),t=i.N}else t="Emoji"}o.type=t}catch(t){o.error=t}return o}))}function Ko(t){return new Error(`disallowed character: ${Fo(t)}`)}function Wo(t,e){let r=Fo(e),n=Ro.find((t=>t.P.has(e)));return n&&(r=`${n.N} ${r}`),new Error(`illegal mixture: ${t.N} + ${r}`)}function zo(t){return new Error(`illegal placement: ${t}`)}function qo(t){return t.filter((t=>t!=Eo))}function Qo(t,e){let r,n=Do,i=t.length;for(;i&&(n=n.get(t[--i]),n);){let{V:o}=n;o&&(r=o,e&&e.push(...t.slice(i).reverse()),t.length=i)}return r}const Jo=new Uint8Array(32);function Xo(t){return ot(0!==t.length,"invalid ENS name; empty component","comp",t),t}function Yo(t){const e=nr(function(t){try{if(0===t.length)throw new Error("empty label");return function(t){return function(t){return t.map((({input:e,error:r,output:n})=>{if(r){let n=r.message;throw new Error(1==t.length?n:`Invalid label ${Ho(jo(e,63))}: ${n}`)}return Qi(n)})).join(vo)}(Vo(t,wo,qo))}(t)}catch(e){ot(!1,`invalid ENS name (${e.message})`,"name",t)}}(t)),r=[];if(0===t.length)return r;let n=0;for(let t=0;t<e.length;t++)46===e[t]&&(r.push(Xo(e.slice(n,t))),n=t+1);return ot(n<e.length,"invalid ENS name; empty component","name",t),r.push(Xo(e.slice(n))),r}function Zo(t){ot("string"==typeof t,"invalid ENS name; not a string","name",t),ot(t.length,"invalid ENS name (empty label)","name",t);let e=Jo;const r=Yo(t);for(;r.length;)e=Pe(gt([e,Pe(r.pop())]));return yt(e)}function $o(t,e){const r=null!=e?e:63;return ot(r<=255,"DNS encoded label cannot exceed 255","length",r),yt(gt(Yo(t).map((e=>{ot(e.length<=r,`label ${JSON.stringify(t)} exceeds ${r} bytes`,"name",t);const n=new Uint8Array(e.length+1);return n.set(e,1),n[0]=n.length-1,n}))))+"00"}Jo.fill(0);class ts extends ae{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=ie(this.buffer)}update(t){zt(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=se(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=ie(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){zt(this),qt(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=ie(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const es=(t,e,r)=>t&e^~t&r,rs=(t,e,r)=>t&e^t&r^e&r,ns=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]),is=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),os=new Uint32Array(64);class ss extends ts{constructor(){super(64,32,8,!1),this.A=0|is[0],this.B=0|is[1],this.C=0|is[2],this.D=0|is[3],this.E=0|is[4],this.F=0|is[5],this.G=0|is[6],this.H=0|is[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)os[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=os[t-15],r=os[t-2],n=oe(e,7)^oe(e,18)^e>>>3,i=oe(r,17)^oe(r,19)^r>>>10;os[t]=i+os[t-7]+n+os[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(oe(s,6)^oe(s,11)^oe(s,25))+es(s,a,u)+ns[t]+os[t]|0,l=(oe(r,2)^oe(r,13)^oe(r,22))+rs(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){os.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const as=ue((()=>new ss)),[us,cs]=(()=>re.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)))))(),ls=new Uint32Array(80),fs=new Uint32Array(80);class hs extends ts{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:t,Al:e,Bh:r,Bl:n,Ch:i,Cl:o,Dh:s,Dl:a,Eh:u,El:c,Fh:l,Fl:f,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,s,a,u,c,l,f,h,p,d,y]}set(t,e,r,n,i,o,s,a,u,c,l,f,h,p,d,y){this.Ah=0|t,this.Al=0|e,this.Bh=0|r,this.Bl=0|n,this.Ch=0|i,this.Cl=0|o,this.Dh=0|s,this.Dl=0|a,this.Eh=0|u,this.El=0|c,this.Fh=0|l,this.Fl=0|f,this.Gh=0|h,this.Gl=0|p,this.Hh=0|d,this.Hl=0|y}process(t,e){for(let r=0;r<16;r++,e+=4)ls[r]=t.getUint32(e),fs[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|ls[t-15],r=0|fs[t-15],n=re.rotrSH(e,r,1)^re.rotrSH(e,r,8)^re.shrSH(e,r,7),i=re.rotrSL(e,r,1)^re.rotrSL(e,r,8)^re.shrSL(e,r,7),o=0|ls[t-2],s=0|fs[t-2],a=re.rotrSH(o,s,19)^re.rotrBH(o,s,61)^re.shrSH(o,s,6),u=re.rotrSL(o,s,19)^re.rotrBL(o,s,61)^re.shrSL(o,s,6),c=re.add4L(i,u,fs[t-7],fs[t-16]),l=re.add4H(c,n,a,ls[t-7],ls[t-16]);ls[t]=0|l,fs[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:s,Cl:a,Dh:u,Dl:c,Eh:l,El:f,Fh:h,Fl:p,Gh:d,Gl:y,Hh:g,Hl:b}=this;for(let t=0;t<80;t++){const e=re.rotrSH(l,f,14)^re.rotrSH(l,f,18)^re.rotrBH(l,f,41),w=re.rotrSL(l,f,14)^re.rotrSL(l,f,18)^re.rotrBL(l,f,41),m=l&h^~l&d,v=f&p^~f&y,E=re.add5L(b,w,v,cs[t],fs[t]),A=re.add5H(E,g,e,m,us[t],ls[t]),S=0|E,_=re.rotrSH(r,n,28)^re.rotrBH(r,n,34)^re.rotrBH(r,n,39),k=re.rotrSL(r,n,28)^re.rotrBL(r,n,34)^re.rotrBL(r,n,39),T=r&i^r&s^i&s,P=n&o^n&a^o&a;g=0|d,b=0|y,d=0|h,y=0|p,h=0|l,p=0|f,({h:l,l:f}=re.add(0|u,0|c,0|A,0|S)),u=0|s,c=0|a,s=0|i,a=0|o,i=0|r,o=0|n;const I=re.add3L(S,k,P);r=re.add3H(I,A,_,T),n=0|I}({h:r,l:n}=re.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=re.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:s,l:a}=re.add(0|this.Ch,0|this.Cl,0|s,0|a)),({h:u,l:c}=re.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:l,l:f}=re.add(0|this.Eh,0|this.El,0|l,0|f)),({h,l:p}=re.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=re.add(0|this.Gh,0|this.Gl,0|d,0|y)),({h:g,l:b}=re.add(0|this.Hh,0|this.Hl,0|g,0|b)),this.set(r,n,i,o,s,a,u,c,l,f,h,p,d,y,g,b)}roundClean(){ls.fill(0),fs.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 ps=ue((()=>new hs)),ds=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}();function ys(t){switch(t){case"sha256":return as.create();case"sha512":return ps.create()}ot(!1,"invalid hashing algorithm name","algorithm",t)}ds.crypto||ds.msCrypto;const gs=function(t){return ys("sha256").update(t).digest()},bs=function(t){return ys("sha512").update(t).digest()};let ws=gs,ms=bs,vs=!1,Es=!1;function As(t){const e=lt(t,"data");return yt(ws(e))}function Ss(t){const e=lt(t,"data");return yt(ms(e))}As._=gs,As.lock=function(){vs=!0},As.register=function(t){if(vs)throw new Error("sha256 is locked");ws=t},Object.freeze(As),Ss._=bs,Ss.lock=function(){Es=!0},Ss.register=function(t){if(Es)throw new Error("sha512 is locked");ms=t},Object.freeze(As);const _s="0x0000000000000000000000000000000000000000000000000000000000000000",ks=BigInt(0),Ts=BigInt(1),Ps=BigInt(2),Is=BigInt(27),Os=BigInt(28),xs=BigInt(35),Bs={};function Rs(t){return vt(Rt(t),32)}class Ns{#$;#tt;#et;#rt;get r(){return this.#$}set r(t){ot(32===bt(t),"invalid r","value",t),this.#$=yt(t)}get s(){return this.#tt}set s(t){ot(32===bt(t),"invalid s","value",t);const e=yt(t);ot(parseInt(e.substring(0,3))<8,"non-canonical s","value",e),this.#tt=e}get v(){return this.#et}set v(t){const e=xt(t,"value");ot(27===e||28===e,"invalid v","v",t),this.#et=e}get networkV(){return this.#rt}get legacyChainId(){const t=this.networkV;return null==t?null:Ns.getChainId(t)}get yParity(){return 27===this.v?0:1}get yParityAndS(){const t=lt(this.s);return this.yParity&&(t[0]|=128),yt(t)}get compactSerialized(){return gt([this.r,this.yParityAndS])}get serialized(){return gt([this.r,this.s,this.yParity?"0x1c":"0x1b"])}constructor(t,e,r,n){ut(t,Bs,"Signature"),this.#$=e,this.#tt=r,this.#et=n,this.#rt=null}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const t=new Ns(Bs,this.r,this.s,this.v);return this.networkV&&(t.#rt=this.networkV),t}toJSON(){const t=this.networkV;return{_type:"signature",networkV:null!=t?t.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(t){const e=Tt(t,"v");return e==Is||e==Os?ks:(ot(e>=xs,"invalid EIP-155 v","v",t),(e-xs)/Ps)}static getChainIdV(t,e){return Tt(t)*Ps+BigInt(35+e-27)}static getNormalizedV(t){const e=Tt(t);return e===ks||e===Is?27:e===Ts||e===Os?28:(ot(e>=xs,"invalid v","v",t),e&Ts?27:28)}static from(t){function e(e,r){ot(e,r,"signature",t)}if(null==t)return new Ns(Bs,_s,_s,27);if("string"==typeof t){const r=lt(t,"signature");if(64===r.length){const t=yt(r.slice(0,32)),e=r.slice(32,64),n=128&e[0]?28:27;return e[0]&=127,new Ns(Bs,t,yt(e),n)}if(65===r.length){const t=yt(r.slice(0,32)),n=r.slice(32,64);e(!(128&n[0]),"non-canonical s");const i=Ns.getNormalizedV(r[64]);return new Ns(Bs,t,yt(n),i)}e(!1,"invalid raw signature length")}if(t instanceof Ns)return t.clone();const r=t.r;e(null!=r,"missing r");const n=Rs(r),i=function(t,r){if(null!=t)return Rs(t);if(null!=r){e(ht(r,32),"invalid yParityAndS");const t=lt(r);return t[0]&=127,yt(t)}e(!1,"missing s")}(t.s,t.yParityAndS);e(!(128&lt(i)[0]),"non-canonical s");const{networkV:o,v:s}=function(t,r,n){if(null!=t){const e=Tt(t);return{networkV:e>=xs?e:void 0,v:Ns.getNormalizedV(e)}}if(null!=r)return e(ht(r,32),"invalid yParityAndS"),{v:128&lt(r)[0]?28:27};if(null!=n){switch(xt(n,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}e(!1,"invalid yParity")}e(!1,"missing v")}(t.v,t.yParityAndS,t.yParity),a=new Ns(Bs,n,i,s);return o&&(a.#rt=o),e(null==t.yParity||xt(t.yParity,"sig.yParity")===a.yParity,"yParity mismatch"),e(null==t.yParityAndS||t.yParityAndS===a.yParityAndS,"yParityAndS mismatch"),a}}function Us(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`Wrong positive integer: ${t}`)}function Cs(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 Ls(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")}const Ds="object"==typeof globalThis&&"crypto"in globalThis?globalThis.crypto:void 0,Ms=t=>t instanceof Uint8Array,Fs=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),Hs=(t,e)=>t<<32-e|t>>>e;if(68!==new Uint8Array(new Uint32Array([287454020]).buffer)[0])throw new Error("Non little-endian hardware is not supported");function js(t){if("string"==typeof t&&(t=function(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}(t)),!Ms(t))throw new Error("expected Uint8Array, got "+typeof t);return t}class Gs{clone(){return this._cloneInto()}}function Vs(t){const e=e=>t().update(js(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}function Ks(t=32){if(Ds&&"function"==typeof Ds.getRandomValues)return Ds.getRandomValues(new Uint8Array(t));throw new Error("crypto.getRandomValues must be defined")}class Ws extends Gs{constructor(t,e,r,n){super(),this.blockLen=t,this.outputLen=e,this.padOffset=r,this.isLE=n,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Fs(this.buffer)}update(t){Ls(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=js(t)).length;for(let o=0;o<i;){const s=Math.min(n-this.pos,i-o);if(s!==n)r.set(t.subarray(o,o+s),this.pos),this.pos+=s,o+=s,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=Fs(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ls(this),function(t,e){Cs(t);const r=e.outputLen;if(t.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}(t,this),this.finished=!0;const{buffer:e,view:r,blockLen:n,isLE:i}=this;let{pos:o}=this;e[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>n-o&&(this.process(r,0),o=0);for(let t=o;t<n;t++)e[t]=0;!function(t,e,r,n){if("function"==typeof t.setBigUint64)return t.setBigUint64(e,r,n);const i=BigInt(32),o=BigInt(4294967295),s=Number(r>>i&o),a=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,s,n),t.setUint32(e+c,a,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const s=Fs(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=a/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)s.setUint32(4*t,c[t],i)}digest(){const{buffer:t,outputLen:e}=this;this.digestInto(t);const r=t.slice(0,e);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:e,buffer:r,length:n,finished:i,destroyed:o,pos:s}=this;return t.length=n,t.pos=s,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const zs=(t,e,r)=>t&e^~t&r,qs=(t,e,r)=>t&e^t&r^e&r,Qs=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]),Js=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Xs=new Uint32Array(64);class Ys extends Ws{constructor(){super(64,32,8,!1),this.A=0|Js[0],this.B=0|Js[1],this.C=0|Js[2],this.D=0|Js[3],this.E=0|Js[4],this.F=0|Js[5],this.G=0|Js[6],this.H=0|Js[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:s,H:a}=this;return[t,e,r,n,i,o,s,a]}set(t,e,r,n,i,o,s,a){this.A=0|t,this.B=0|e,this.C=0|r,this.D=0|n,this.E=0|i,this.F=0|o,this.G=0|s,this.H=0|a}process(t,e){for(let r=0;r<16;r++,e+=4)Xs[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Xs[t-15],r=Xs[t-2],n=Hs(e,7)^Hs(e,18)^e>>>3,i=Hs(r,17)^Hs(r,19)^r>>>10;Xs[t]=i+Xs[t-7]+n+Xs[t-16]|0}let{A:r,B:n,C:i,D:o,E:s,F:a,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(Hs(s,6)^Hs(s,11)^Hs(s,25))+zs(s,a,u)+Qs[t]+Xs[t]|0,l=(Hs(r,2)^Hs(r,13)^Hs(r,22))+qs(r,n,i)|0;c=u,u=a,a=s,s=o+e|0,o=i,i=n,n=r,r=e+l|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,s=s+this.E|0,a=a+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,s,a,u,c)}roundClean(){Xs.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Zs=Vs((()=>new Ys)),$s=(BigInt(0),BigInt(1)),ta=BigInt(2),ea=t=>t instanceof Uint8Array,ra=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function na(t){if(!ea(t))throw new Error("Uint8Array expected");let e="";for(let r=0;r<t.length;r++)e+=ra[t[r]];return e}function ia(t){if("string"!=typeof t)throw new Error("hex string expected, got "+typeof t);return BigInt(""===t?"0":`0x${t}`)}function oa(t){if("string"!=typeof t)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 r=new Uint8Array(e/2);for(let e=0;e<r.length;e++){const n=2*e,i=t.slice(n,n+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");r[e]=o}return r}function sa(t){return ia(na(t))}function aa(t){if(!ea(t))throw new Error("Uint8Array expected");return ia(na(Uint8Array.from(t).reverse()))}function ua(t,e){return oa(t.toString(16).padStart(2*e,"0"))}function ca(t,e){return ua(t,e).reverse()}function la(t,e,r){let n;if("string"==typeof e)try{n=oa(e)}catch(r){throw new Error(`${t} must be valid hex string, got "${e}". Cause: ${r}`)}else{if(!ea(e))throw new Error(`${t} must be hex string or Uint8Array`);n=Uint8Array.from(e)}const i=n.length;if("number"==typeof r&&i!==r)throw new Error(`${t} expected ${r} bytes, got ${i}`);return n}function fa(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!ea(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}const ha=t=>(ta<<BigInt(t-1))-$s,pa=t=>new Uint8Array(t),da=t=>Uint8Array.from(t);function ya(t,e,r){if("number"!=typeof t||t<2)throw new Error("hashLen must be a number");if("number"!=typeof e||e<2)throw new Error("qByteLen must be a number");if("function"!=typeof r)throw new Error("hmacFn must be a function");let n=pa(t),i=pa(t),o=0;const s=()=>{n.fill(1),i.fill(0),o=0},a=(...t)=>r(i,n,...t),u=(t=pa())=>{i=a(da([0]),t),n=a(),0!==t.length&&(i=a(da([1]),t),n=a())},c=()=>{if(o++>=1e3)throw new Error("drbg: tried 1000 values");let t=0;const r=[];for(;t<e;){n=a();const e=n.slice();r.push(e),t+=n.length}return fa(...r)};return(t,e)=>{let r;for(s(),u(t);!(r=e(c()));)u();return s(),r}}const ga={bigint:t=>"bigint"==typeof t,function:t=>"function"==typeof t,boolean:t=>"boolean"==typeof t,string:t=>"string"==typeof t,stringOrUint8Array:t=>"string"==typeof t||t instanceof Uint8Array,isSafeInteger:t=>Number.isSafeInteger(t),array:t=>Array.isArray(t),field:(t,e)=>e.Fp.isValid(t),hash:t=>"function"==typeof t&&Number.isSafeInteger(t.outputLen)};function ba(t,e,r={}){const n=(e,r,n)=>{const i=ga[r];if("function"!=typeof i)throw new Error(`Invalid validator "${r}", expected function`);const o=t[e];if(!(n&&void 0===o||i(o,t)))throw new Error(`Invalid param ${String(e)}=${o} (${typeof o}), expected ${r}`)};for(const[t,r]of Object.entries(e))n(t,r,!1);for(const[t,e]of Object.entries(r))n(t,e,!0);return t}const wa=BigInt(0),ma=BigInt(1),va=BigInt(2),Ea=BigInt(3),Aa=BigInt(4),Sa=BigInt(5),_a=BigInt(8);function ka(t,e){const r=t%e;return r>=wa?r:e+r}function Ta(t,e,r){if(r<=wa||e<wa)throw new Error("Expected power/modulo > 0");if(r===ma)return wa;let n=ma;for(;e>wa;)e&ma&&(n=n*t%r),t=t*t%r,e>>=ma;return n}function Pa(t,e,r){let n=t;for(;e-- >wa;)n*=n,n%=r;return n}function Ia(t,e){if(t===wa||e<=wa)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ka(t,e),n=e,i=wa,o=ma,s=ma,a=wa;for(;r!==wa;){const t=n/r,e=n%r,u=i-s*t,c=o-a*t;n=r,r=e,i=s,o=a,s=u,a=c}if(n!==ma)throw new Error("invert: does not exist");return ka(i,e)}BigInt(9),BigInt(16);const Oa=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function xa(t,e){const r=void 0!==e?e:t.toString(2).length;return{nBitLength:r,nByteLength:Math.ceil(r/8)}}function Ba(t){if("bigint"!=typeof t)throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function Ra(t){const e=Ba(t);return e+Math.ceil(e/2)}class Na extends Gs{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,function(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");Us(t.outputLen),Us(t.blockLen)}(t);const r=js(e);if(this.iHash=t.create(),"function"!=typeof this.iHash.update)throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const n=this.blockLen,i=new Uint8Array(n);i.set(r.length>n?t.create().update(r).digest():r);for(let t=0;t<i.length;t++)i[t]^=54;this.iHash.update(i),this.oHash=t.create();for(let t=0;t<i.length;t++)i[t]^=106;this.oHash.update(i),i.fill(0)}update(t){return Ls(this),this.iHash.update(t),this}digestInto(t){Ls(this),Cs(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:e,iHash:r,finished:n,destroyed:i,blockLen:o,outputLen:s}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=s,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Ua=(t,e,r)=>new Na(t,e).update(r).digest();Ua.create=(t,e)=>new Na(t,e);const Ca=BigInt(0),La=BigInt(1);function Da(t){return ba(t.Fp,Oa.reduce(((t,e)=>(t[e]="function",t)),{ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"})),ba(t,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...xa(t.n,t.nBitLength),...t,p:t.Fp.ORDER})}const{bytesToNumberBE:Ma,hexToBytes:Fa}=t,Ha={Err:class extends Error{constructor(t=""){super(t)}},_parseInt(t){const{Err:e}=Ha;if(t.length<2||2!==t[0])throw new e("Invalid signature integer tag");const r=t[1],n=t.subarray(2,r+2);if(!r||n.length!==r)throw new e("Invalid signature integer: wrong length");if(128&n[0])throw new e("Invalid signature integer: negative");if(0===n[0]&&!(128&n[1]))throw new e("Invalid signature integer: unnecessary leading zero");return{d:Ma(n),l:t.subarray(r+2)}},toSig(t){const{Err:e}=Ha,r="string"==typeof t?Fa(t):t;if(!(r instanceof Uint8Array))throw new Error("ui8a expected");let n=r.length;if(n<2||48!=r[0])throw new e("Invalid signature tag");if(r[1]!==n-2)throw new e("Invalid signature: incorrect length");const{d:i,l:o}=Ha._parseInt(r.subarray(2)),{d:s,l:a}=Ha._parseInt(o);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:i,s}},hexFromSig(t){const e=t=>8&Number.parseInt(t[0],16)?"00"+t:t,r=t=>{const e=t.toString(16);return 1&e.length?`0${e}`:e},n=e(r(t.s)),i=e(r(t.r)),o=n.length/2,s=i.length/2,a=r(o),u=r(s);return`30${r(s+o+4)}02${u}${i}02${a}${n}`}},ja=BigInt(0),Ga=BigInt(1),Va=(BigInt(2),BigInt(3));function Ka(t){const e=function(t){const e=Da(t);return ba(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}(t),{Fp:r,n}=e,i=r.BYTES+1,o=2*r.BYTES+1;function s(t){return ka(t,n)}function a(t){return Ia(t,n)}const{ProjectivePoint:u,normPrivateKeyToScalar:c,weierstrassEquation:l,isWithinCurveOrder:f}=function(t){const e=function(t){const e=Da(t);ba(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:r,Fp:n,a:i}=e;if(r){if(!n.eql(i,n.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if("object"!=typeof r||"bigint"!=typeof r.beta||"function"!=typeof r.splitScalar)throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}(t),{Fp:r}=e,n=e.toBytes||((t,e,n)=>{const i=e.toAffine();return fa(Uint8Array.from([4]),r.toBytes(i.x),r.toBytes(i.y))}),i=e.fromBytes||(t=>{const e=t.subarray(1);return{x:r.fromBytes(e.subarray(0,r.BYTES)),y:r.fromBytes(e.subarray(r.BYTES,2*r.BYTES))}});function o(t){const{a:n,b:i}=e,o=r.sqr(t),s=r.mul(o,t);return r.add(r.add(s,r.mul(t,n)),i)}if(!r.eql(r.sqr(e.Gy),o(e.Gx)))throw new Error("bad generator point: equation left != right");function s(t){return"bigint"==typeof t&&ja<t&&t<e.n}function a(t){if(!s(t))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function u(t){const{allowedPrivateKeyLengths:r,nByteLength:n,wrapPrivateKey:i,n:o}=e;if(r&&"bigint"!=typeof t){if(t instanceof Uint8Array&&(t=na(t)),"string"!=typeof t||!r.includes(t.length))throw new Error("Invalid key");t=t.padStart(2*n,"0")}let s;try{s="bigint"==typeof t?t:sa(la("private key",t,n))}catch(e){throw new Error(`private key must be ${n} bytes, hex or bigint, not ${typeof t}`)}return i&&(s=ka(s,o)),a(s),s}const c=new Map;function l(t){if(!(t instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(t,e,n){if(this.px=t,this.py=e,this.pz=n,null==t||!r.isValid(t))throw new Error("x required");if(null==e||!r.isValid(e))throw new Error("y required");if(null==n||!r.isValid(n))throw new Error("z required")}static fromAffine(t){const{x:e,y:n}=t||{};if(!t||!r.isValid(e)||!r.isValid(n))throw new Error("invalid affine point");if(t instanceof f)throw new Error("projective point not allowed");const i=t=>r.eql(t,r.ZERO);return i(e)&&i(n)?f.ZERO:new f(e,n,r.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(t){const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(f.fromAffine)}static fromHex(t){const e=f.fromAffine(i(la("pointHex",t)));return e.assertValidity(),e}static fromPrivateKey(t){return f.BASE.multiply(u(t))}_setWindowSize(t){this._WINDOW_SIZE=t,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!r.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:t,y:n}=this.toAffine();if(!r.isValid(t)||!r.isValid(n))throw new Error("bad point: x or y not FE");const i=r.sqr(n),s=o(t);if(!r.eql(i,s))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:t}=this.toAffine();if(r.isOdd)return!r.isOdd(t);throw new Error("Field doesn't support isOdd")}equals(t){l(t);const{px:e,py:n,pz:i}=this,{px:o,py:s,pz:a}=t,u=r.eql(r.mul(e,a),r.mul(o,i)),c=r.eql(r.mul(n,a),r.mul(s,i));return u&&c}negate(){return new f(this.px,r.neg(this.py),this.pz)}double(){const{a:t,b:n}=e,i=r.mul(n,Va),{px:o,py:s,pz:a}=this;let u=r.ZERO,c=r.ZERO,l=r.ZERO,h=r.mul(o,o),p=r.mul(s,s),d=r.mul(a,a),y=r.mul(o,s);return y=r.add(y,y),l=r.mul(o,a),l=r.add(l,l),u=r.mul(t,l),c=r.mul(i,d),c=r.add(u,c),u=r.sub(p,c),c=r.add(p,c),c=r.mul(u,c),u=r.mul(y,u),l=r.mul(i,l),d=r.mul(t,d),y=r.sub(h,d),y=r.mul(t,y),y=r.add(y,l),l=r.add(h,h),h=r.add(l,h),h=r.add(h,d),h=r.mul(h,y),c=r.add(c,h),d=r.mul(s,a),d=r.add(d,d),h=r.mul(d,y),u=r.sub(u,h),l=r.mul(d,p),l=r.add(l,l),l=r.add(l,l),new f(u,c,l)}add(t){l(t);const{px:n,py:i,pz:o}=this,{px:s,py:a,pz:u}=t;let c=r.ZERO,h=r.ZERO,p=r.ZERO;const d=e.a,y=r.mul(e.b,Va);let g=r.mul(n,s),b=r.mul(i,a),w=r.mul(o,u),m=r.add(n,i),v=r.add(s,a);m=r.mul(m,v),v=r.add(g,b),m=r.sub(m,v),v=r.add(n,o);let E=r.add(s,u);return v=r.mul(v,E),E=r.add(g,w),v=r.sub(v,E),E=r.add(i,o),c=r.add(a,u),E=r.mul(E,c),c=r.add(b,w),E=r.sub(E,c),p=r.mul(d,v),c=r.mul(y,w),p=r.add(c,p),c=r.sub(b,p),p=r.add(b,p),h=r.mul(c,p),b=r.add(g,g),b=r.add(b,g),w=r.mul(d,w),v=r.mul(y,v),b=r.add(b,w),w=r.sub(g,w),w=r.mul(d,w),v=r.add(v,w),g=r.mul(b,v),h=r.add(h,g),g=r.mul(E,v),c=r.mul(m,c),c=r.sub(c,g),g=r.mul(m,b),p=r.mul(E,p),p=r.add(p,g),new f(c,h,p)}subtract(t){return this.add(t.negate())}is0(){return this.equals(f.ZERO)}wNAF(t){return p.wNAFCached(this,c,t,(t=>{const e=r.invertBatch(t.map((t=>t.pz)));return t.map(((t,r)=>t.toAffine(e[r]))).map(f.fromAffine)}))}multiplyUnsafe(t){const n=f.ZERO;if(t===ja)return n;if(a(t),t===Ga)return this;const{endo:i}=e;if(!i)return p.unsafeLadder(this,t);let{k1neg:o,k1:s,k2neg:u,k2:c}=i.splitScalar(t),l=n,h=n,d=this;for(;s>ja||c>ja;)s&Ga&&(l=l.add(d)),c&Ga&&(h=h.add(d)),d=d.double(),s>>=Ga,c>>=Ga;return o&&(l=l.negate()),u&&(h=h.negate()),h=new f(r.mul(h.px,i.beta),h.py,h.pz),l.add(h)}multiply(t){a(t);let n,i,o=t;const{endo:s}=e;if(s){const{k1neg:t,k1:e,k2neg:a,k2:u}=s.splitScalar(o);let{p:c,f:l}=this.wNAF(e),{p:h,f:d}=this.wNAF(u);c=p.constTimeNegate(t,c),h=p.constTimeNegate(a,h),h=new f(r.mul(h.px,s.beta),h.py,h.pz),n=c.add(h),i=l.add(d)}else{const{p:t,f:e}=this.wNAF(o);n=t,i=e}return f.normalizeZ([n,i])[0]}multiplyAndAddUnsafe(t,e,r){const n=f.BASE,i=(t,e)=>e!==ja&&e!==Ga&&t.equals(n)?t.multiply(e):t.multiplyUnsafe(e),o=i(this,e).add(i(t,r));return o.is0()?void 0:o}toAffine(t){const{px:e,py:n,pz:i}=this,o=this.is0();null==t&&(t=o?r.ONE:r.inv(i));const s=r.mul(e,t),a=r.mul(n,t),u=r.mul(i,t);if(o)return{x:r.ZERO,y:r.ZERO};if(!r.eql(u,r.ONE))throw new Error("invZ was invalid");return{x:s,y:a}}isTorsionFree(){const{h:t,isTorsionFree:r}=e;if(t===Ga)return!0;if(r)return r(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:t,clearCofactor:r}=e;return t===Ga?this:r?r(f,this):this.multiplyUnsafe(e.h)}toRawBytes(t=!0){return this.assertValidity(),n(f,this,t)}toHex(t=!0){return na(this.toRawBytes(t))}}f.BASE=new f(e.Gx,e.Gy,r.ONE),f.ZERO=new f(r.ZERO,r.ONE,r.ZERO);const h=e.nBitLength,p=function(t,e){const r=(t,e)=>{const r=e.negate();return t?r:e},n=t=>({windows:Math.ceil(e/t)+1,windowSize:2**(t-1)});return{constTimeNegate:r,unsafeLadder(e,r){let n=t.ZERO,i=e;for(;r>Ca;)r&La&&(n=n.add(i)),i=i.double(),r>>=La;return n},precomputeWindow(t,e){const{windows:r,windowSize:i}=n(e),o=[];let s=t,a=s;for(let t=0;t<r;t++){a=s,o.push(a);for(let t=1;t<i;t++)a=a.add(s),o.push(a);s=a.double()}return o},wNAF(e,i,o){const{windows:s,windowSize:a}=n(e);let u=t.ZERO,c=t.BASE;const l=BigInt(2**e-1),f=2**e,h=BigInt(e);for(let t=0;t<s;t++){const e=t*a;let n=Number(o&l);o>>=h,n>a&&(n-=f,o+=La);const s=e,p=e+Math.abs(n)-1,d=t%2!=0,y=n<0;0===n?c=c.add(r(d,i[s])):u=u.add(r(y,i[p]))}return{p:u,f:c}},wNAFCached(t,e,r,n){const i=t._WINDOW_SIZE||1;let o=e.get(t);return o||(o=this.precomputeWindow(t,i),1!==i&&e.set(t,n(o))),this.wNAF(i,o,r)}}}(f,e.endo?Math.ceil(h/2):h);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:u,weierstrassEquation:o,isWithinCurveOrder:s}}({...e,toBytes(t,e,n){const i=e.toAffine(),o=r.toBytes(i.x),s=fa;return n?s(Uint8Array.from([e.hasEvenY()?2:3]),o):s(Uint8Array.from([4]),o,r.toBytes(i.y))},fromBytes(t){const e=t.length,n=t[0],s=t.subarray(1);if(e!==i||2!==n&&3!==n){if(e===o&&4===n)return{x:r.fromBytes(s.subarray(0,r.BYTES)),y:r.fromBytes(s.subarray(r.BYTES,2*r.BYTES))};throw new Error(`Point of length ${e} was invalid. Expected ${i} compressed bytes or ${o} uncompressed bytes`)}{const t=sa(s);if(!(ja<(a=t)&&a<r.ORDER))throw new Error("Point is not on curve");const e=l(t);let i=r.sqrt(e);return!(1&~n)!=((i&Ga)===Ga)&&(i=r.neg(i)),{x:t,y:i}}var a}}),h=t=>na(ua(t,e.nByteLength));function p(t){return t>n>>Ga}const d=(t,e,r)=>sa(t.slice(e,r));class y{constructor(t,e,r){this.r=t,this.s=e,this.recovery=r,this.assertValidity()}static fromCompact(t){const r=e.nByteLength;return t=la("compactSignature",t,2*r),new y(d(t,0,r),d(t,r,2*r))}static fromDER(t){const{r:e,s:r}=Ha.toSig(la("DER",t));return new y(e,r)}assertValidity(){if(!f(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!f(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(t){return new y(this.r,this.s,t)}recoverPublicKey(t){const{r:n,s:i,recovery:o}=this,c=m(la("msgHash",t));if(null==o||![0,1,2,3].includes(o))throw new Error("recovery id invalid");const l=2===o||3===o?n+e.n:n;if(l>=r.ORDER)throw new Error("recovery id 2 or 3 invalid");const f=1&o?"03":"02",p=u.fromHex(f+h(l)),d=a(l),y=s(-c*d),g=s(i*d),b=u.BASE.multiplyAndAddUnsafe(p,y,g);if(!b)throw new Error("point at infinify");return b.assertValidity(),b}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new y(this.r,s(-this.s),this.recovery):this}toDERRawBytes(){return oa(this.toDERHex())}toDERHex(){return Ha.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return oa(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const g={isValidPrivateKey(t){try{return c(t),!0}catch(t){return!1}},normPrivateKeyToScalar:c,randomPrivateKey:()=>{const t=Ra(e.n);return function(t,e,r=!1){const n=t.length,i=Ba(e),o=Ra(e);if(n<16||n<o||n>1024)throw new Error(`expected ${o}-1024 bytes of input, got ${n}`);const s=ka(r?sa(t):aa(t),e-ma)+ma;return r?ca(s,i):ua(s,i)}(e.randomBytes(t),e.n)},precompute:(t=8,e=u.BASE)=>(e._setWindowSize(t),e.multiply(BigInt(3)),e)};function b(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?n===i||n===o:r?n===2*i||n===2*o:t instanceof u}const w=e.bits2int||function(t){const r=sa(t),n=8*t.length-e.nBitLength;return n>0?r>>BigInt(n):r},m=e.bits2int_modN||function(t){return s(w(t))},v=ha(e.nBitLength);function E(t){if("bigint"!=typeof t)throw new Error("bigint expected");if(!(ja<=t&&t<v))throw new Error(`bigint expected < 2^${e.nBitLength}`);return ua(t,e.nByteLength)}const A={lowS:e.lowS,prehash:!1},S={lowS:e.lowS,prehash:!1};return u.BASE._setWindowSize(8),{CURVE:e,getPublicKey:function(t,e=!0){return u.fromPrivateKey(t).toRawBytes(e)},getSharedSecret:function(t,e,r=!0){if(b(t))throw new Error("first arg must be private key");if(!b(e))throw new Error("second arg must be public key");return u.fromHex(e).multiply(c(t)).toRawBytes(r)},sign:function(t,n,i=A){const{seed:o,k2sig:l}=function(t,n,i=A){if(["recovered","canonical"].some((t=>t in i)))throw new Error("sign() legacy options not supported");const{hash:o,randomBytes:l}=e;let{lowS:h,prehash:d,extraEntropy:g}=i;null==h&&(h=!0),t=la("msgHash",t),d&&(t=la("prehashed msgHash",o(t)));const b=m(t),v=c(n),S=[E(v),E(b)];if(null!=g){const t=!0===g?l(r.BYTES):g;S.push(la("extraEntropy",t))}const _=fa(...S),k=b;return{seed:_,k2sig:function(t){const e=w(t);if(!f(e))return;const r=a(e),n=u.BASE.multiply(e).toAffine(),i=s(n.x);if(i===ja)return;const o=s(r*s(k+i*v));if(o===ja)return;let c=(n.x===i?0:2)|Number(n.y&Ga),l=o;return h&&p(o)&&(l=function(t){return p(t)?s(-t):t}(o),c^=1),new y(i,l,c)}}}(t,n,i),h=e;return ya(h.hash.outputLen,h.nByteLength,h.hmac)(o,l)},verify:function(t,r,n,i=S){const o=t;if(r=la("msgHash",r),n=la("publicKey",n),"strict"in i)throw new Error("options.strict was renamed to lowS");const{lowS:c,prehash:l}=i;let f,h;try{if("string"==typeof o||o instanceof Uint8Array)try{f=y.fromDER(o)}catch(t){if(!(t instanceof Ha.Err))throw t;f=y.fromCompact(o)}else{if("object"!=typeof o||"bigint"!=typeof o.r||"bigint"!=typeof o.s)throw new Error("PARSE");{const{r:t,s:e}=o;f=new y(t,e)}}h=u.fromHex(n)}catch(t){if("PARSE"===t.message)throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(c&&f.hasHighS())return!1;l&&(r=e.hash(r));const{r:p,s:d}=f,g=m(r),b=a(d),w=s(g*b),v=s(p*b),E=u.BASE.multiplyAndAddUnsafe(h,w,v)?.toAffine();return!!E&&s(E.x)===p},ProjectivePoint:u,Signature:y,utils:g}}function Wa(t){return{hash:t,hmac:(e,...r)=>Ua(t,e,function(...t){const e=new Uint8Array(t.reduce(((t,e)=>t+e.length),0));let r=0;return t.forEach((t=>{if(!Ms(t))throw new Error("Uint8Array expected");e.set(t,r),r+=t.length})),e}(...r)),randomBytes:Ks}}BigInt(4);const za=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),qa=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),Qa=BigInt(1),Ja=BigInt(2),Xa=(t,e)=>(t+e/Ja)/e;const Ya=function(t,e,r=!1,n={}){if(t<=wa)throw new Error(`Expected Field ORDER > 0, got ${t}`);const{nBitLength:i,nByteLength:o}=xa(t,e);if(o>2048)throw new Error("Field lengths over 2048 bytes are not supported");const s=function(t){if(t%Aa===Ea){const e=(t+ma)/Aa;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}if(t%_a===Sa){const e=(t-Sa)/_a;return function(t,r){const n=t.mul(r,va),i=t.pow(n,e),o=t.mul(r,i),s=t.mul(t.mul(o,va),i),a=t.mul(o,t.sub(s,t.ONE));if(!t.eql(t.sqr(a),r))throw new Error("Cannot find square root");return a}}return function(t){const e=(t-ma)/va;let r,n,i;for(r=t-ma,n=0;r%va===wa;r/=va,n++);for(i=va;i<t&&Ta(i,e,t)!==t-ma;i++);if(1===n){const e=(t+ma)/Aa;return function(t,r){const n=t.pow(r,e);if(!t.eql(t.sqr(n),r))throw new Error("Cannot find square root");return n}}const o=(r+ma)/va;return function(t,s){if(t.pow(s,e)===t.neg(t.ONE))throw new Error("Cannot find square root");let a=n,u=t.pow(t.mul(t.ONE,i),r),c=t.pow(s,o),l=t.pow(s,r);for(;!t.eql(l,t.ONE);){if(t.eql(l,t.ZERO))return t.ZERO;let e=1;for(let r=t.sqr(l);e<a&&!t.eql(r,t.ONE);e++)r=t.sqr(r);const r=t.pow(u,ma<<BigInt(a-e-1));u=t.sqr(r),c=t.mul(c,r),l=t.mul(l,u),a=e}return c}}(t)}(t),a=Object.freeze({ORDER:t,BITS:i,BYTES:o,MASK:ha(i),ZERO:wa,ONE:ma,create:e=>ka(e,t),isValid:e=>{if("bigint"!=typeof e)throw new Error("Invalid field element: expected bigint, got "+typeof e);return wa<=e&&e<t},is0:t=>t===wa,isOdd:t=>(t&ma)===ma,neg:e=>ka(-e,t),eql:(t,e)=>t===e,sqr:e=>ka(e*e,t),add:(e,r)=>ka(e+r,t),sub:(e,r)=>ka(e-r,t),mul:(e,r)=>ka(e*r,t),pow:(t,e)=>function(t,e,r){if(r<wa)throw new Error("Expected power > 0");if(r===wa)return t.ONE;if(r===ma)return e;let n=t.ONE,i=e;for(;r>wa;)r&ma&&(n=t.mul(n,i)),i=t.sqr(i),r>>=ma;return n}(a,t,e),div:(e,r)=>ka(e*Ia(r,t),t),sqrN:t=>t*t,addN:(t,e)=>t+e,subN:(t,e)=>t-e,mulN:(t,e)=>t*e,inv:e=>Ia(e,t),sqrt:n.sqrt||(t=>s(a,t)),invertBatch:t=>function(t,e){const r=new Array(e.length),n=e.reduce(((e,n,i)=>t.is0(n)?e:(r[i]=e,t.mul(e,n))),t.ONE),i=t.inv(n);return e.reduceRight(((e,n,i)=>t.is0(n)?e:(r[i]=t.mul(e,r[i]),t.mul(e,n))),i),r}(a,t),cmov:(t,e,r)=>r?e:t,toBytes:t=>r?ca(t,o):ua(t,o),fromBytes:t=>{if(t.length!==o)throw new Error(`Fp.fromBytes: expected ${o}, got ${t.length}`);return r?aa(t):sa(t)}});return Object.freeze(a)}(za,void 0,void 0,{sqrt:function(t){const e=za,r=BigInt(3),n=BigInt(6),i=BigInt(11),o=BigInt(22),s=BigInt(23),a=BigInt(44),u=BigInt(88),c=t*t*t%e,l=c*c*t%e,f=Pa(l,r,e)*l%e,h=Pa(f,r,e)*l%e,p=Pa(h,Ja,e)*c%e,d=Pa(p,i,e)*p%e,y=Pa(d,o,e)*d%e,g=Pa(y,a,e)*y%e,b=Pa(g,u,e)*g%e,w=Pa(b,a,e)*y%e,m=Pa(w,r,e)*l%e,v=Pa(m,s,e)*d%e,E=Pa(v,n,e)*c%e,A=Pa(E,Ja,e);if(!Ya.eql(Ya.sqr(A),t))throw new Error("Cannot find square root");return A}}),Za=function(t,e){const r=e=>Ka({...t,...Wa(e)});return Object.freeze({...r(e),create:r})}({a:BigInt(0),b:BigInt(7),Fp:Ya,n:qa,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:t=>{const e=qa,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-Qa*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,s=BigInt("0x100000000000000000000000000000000"),a=Xa(o*t,e),u=Xa(-n*t,e);let c=ka(t-a*r-u*i,e),l=ka(-a*n-u*o,e);const f=c>s,h=l>s;if(f&&(c=e-c),h&&(l=e-l),c>s||l>s)throw new Error("splitScalar: Endomorphism failed, k="+t);return{k1neg:f,k1:c,k2neg:h,k2:l}}}},Zs);BigInt(0),Za.ProjectivePoint;class $a{#nt;constructor(t){ot(32===bt(t),"invalid private key","privateKey","[REDACTED]"),this.#nt=yt(t)}get privateKey(){return this.#nt}get publicKey(){return $a.computePublicKey(this.#nt)}get compressedPublicKey(){return $a.computePublicKey(this.#nt,!0)}sign(t){ot(32===bt(t),"invalid digest length","digest",t);const e=Za.sign(ft(t),ft(this.#nt),{lowS:!0});return Ns.from({r:Bt(e.r,32),s:Bt(e.s,32),v:e.recovery?28:27})}computeSharedSecret(t){const e=$a.computePublicKey(t);return yt(Za.getSharedSecret(ft(this.#nt),lt(e),!1))}static computePublicKey(t,e){let r=lt(t,"key");if(32===r.length)return yt(Za.getPublicKey(r,!!e));if(64===r.length){const t=new Uint8Array(65);t[0]=4,t.set(r,1),r=t}return yt(Za.ProjectivePoint.fromHex(r).toRawBytes(e))}static recoverPublicKey(t,e){ot(32===bt(t),"invalid digest length","digest",t);const r=Ns.from(e);let n=Za.Signature.fromCompact(ft(gt([r.r,r.s])));n=n.addRecoveryBit(r.yParity);const i=n.recoverPublicKey(ft(t));return ot(null!=i,"invalid signautre for digest","signature",e),"0x"+i.toHex(!1)}static addPoints(t,e,r){const n=Za.ProjectivePoint.fromHex($a.computePublicKey(t).substring(2)),i=Za.ProjectivePoint.fromHex($a.computePublicKey(e).substring(2));return"0x"+n.add(i).toHex(!!r)}}function tu(t){let e=t.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function eu(t,e,r){let n=0;for(let i=0;i<r;i++)n=256*n+t[e+i];return n}function ru(t,e,r,n){const i=[];for(;r<e+1+n;){const o=nu(t,r);i.push(o.result),it((r+=o.consumed)<=e+1+n,"child data too short","BUFFER_OVERRUN",{buffer:t,length:n,offset:e})}return{consumed:1+n,result:i}}function nu(t,e){it(0!==t.length,"data too short","BUFFER_OVERRUN",{buffer:t,length:0,offset:1});const r=e=>{it(e<=t.length,"data short segment too short","BUFFER_OVERRUN",{buffer:t,length:t.length,offset:e})};if(t[e]>=248){const n=t[e]-247;r(e+1+n);const i=eu(t,e+1,n);return r(e+1+n+i),ru(t,e,e+1+n,n+i)}if(t[e]>=192){const n=t[e]-192;return r(e+1+n),ru(t,e,e+1,n)}if(t[e]>=184){const n=t[e]-183;r(e+1+n);const i=eu(t,e+1,n);return r(e+1+n+i),{consumed:1+n+i,result:yt(t.slice(e+1+n,e+1+n+i))}}if(t[e]>=128){const n=t[e]-128;return r(e+1+n),{consumed:1+n,result:yt(t.slice(e+1,e+1+n))}}return{consumed:1,result:tu(t[e])}}function iu(t){const e=lt(t,"data"),r=nu(e,0);return ot(r.consumed===e.length,"unexpected junk after rlp payload","data",t),r.result}function ou(t){const e=[];for(;t;)e.unshift(255&t),t>>=8;return e}function su(t){if(Array.isArray(t)){let e=[];if(t.forEach((function(t){e=e.concat(su(t))})),e.length<=55)return e.unshift(192+e.length),e;const r=ou(e.length);return r.unshift(247+r.length),r.concat(e)}const e=Array.prototype.slice.call(lt(t,"object"));if(1===e.length&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const r=ou(e.length);return r.unshift(183+r.length),r.concat(e)}const au="0123456789abcdef";function uu(t){let e="0x";for(const r of su(t))e+=au[r>>4],e+=au[15&r];return e}const cu=BigInt(0),lu=BigInt(2),fu=BigInt(27),hu=BigInt(28),pu=BigInt(35),du=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),yu=131072;function gu(t,e){let r=t.toString(16);for(;r.length<2;)r="0"+r;return r+=As(e).substring(4),"0x"+r}function bu(t){return"0x"===t?null:Ue(t)}function wu(t,e){try{return kn(t)}catch(r){ot(!1,r.message,e,t)}}function mu(t,e){return"0x"===t?0:xt(t,e)}function vu(t,e){if("0x"===t)return cu;const r=Tt(t,e);return ot(r<=du,"value exceeds uint size",e,r),r}function Eu(t,e){const r=Tt(t,"value"),n=Rt(r);return ot(n.length<=32,"value too large",`tx.${e}`,r),n}function Au(t){return kn(t).map((t=>[t.address,t.storageKeys]))}function Su(t,e){ot(Array.isArray(t),`invalid ${e}`,"value",t);for(let e=0;e<t.length;e++)ot(ht(t[e],32),"invalid ${ param } hash",`value[${e}]`,t[e]);return t}function _u(t,e){let r;try{if(r=mu(e[0],"yParity"),0!==r&&1!==r)throw new Error("bad yParity")}catch(t){ot(!1,"invalid yParity","yParity",e[0])}const n=vt(e[1],32),i=vt(e[2],32),o=Ns.from({r:n,s:i,yParity:r});t.signature=o}class ku{#it;#ot;#e;#st;#at;#ut;#ct;#lt;#ft;#ht;#pt;#dt;#yt;#gt;#bt;#wt;get type(){return this.#it}set type(t){switch(t){case null:this.#it=null;break;case 0:case"legacy":this.#it=0;break;case 1:case"berlin":case"eip-2930":this.#it=1;break;case 2:case"london":case"eip-1559":this.#it=2;break;case 3:case"cancun":case"eip-4844":this.#it=3;break;default:ot(!1,"unsupported transaction type","type",t)}}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 t=this.#ot;return null==t&&3===this.type?Hn:t}set to(t){this.#ot=null==t?null:Ue(t)}get nonce(){return this.#st}set nonce(t){this.#st=xt(t,"value")}get gasLimit(){return this.#at}set gasLimit(t){this.#at=Tt(t)}get gasPrice(){const t=this.#ut;return null!=t||0!==this.type&&1!==this.type?t:cu}set gasPrice(t){this.#ut=null==t?null:Tt(t,"gasPrice")}get maxPriorityFeePerGas(){const t=this.#ct;return null==t?2===this.type||3===this.type?cu:null:t}set maxPriorityFeePerGas(t){this.#ct=null==t?null:Tt(t,"maxPriorityFeePerGas")}get maxFeePerGas(){const t=this.#lt;return null==t?2===this.type||3===this.type?cu:null:t}set maxFeePerGas(t){this.#lt=null==t?null:Tt(t,"maxFeePerGas")}get data(){return this.#e}set data(t){this.#e=yt(t)}get value(){return this.#ft}set value(t){this.#ft=Tt(t,"value")}get chainId(){return this.#ht}set chainId(t){this.#ht=Tt(t)}get signature(){return this.#pt||null}set signature(t){this.#pt=null==t?null:Ns.from(t)}get accessList(){const t=this.#dt||null;return null==t?1===this.type||2===this.type||3===this.type?[]:null:t}set accessList(t){this.#dt=null==t?null:kn(t)}get maxFeePerBlobGas(){const t=this.#yt;return null==t&&3===this.type?cu:t}set maxFeePerBlobGas(t){this.#yt=null==t?null:Tt(t,"maxFeePerBlobGas")}get blobVersionedHashes(){let t=this.#gt;return null==t&&3===this.type?[]:t}set blobVersionedHashes(t){if(null!=t){ot(Array.isArray(t),"blobVersionedHashes must be an Array","value",t),t=t.slice();for(let e=0;e<t.length;e++)ot(ht(t[e],32),"invalid blobVersionedHash",`value[${e}]`,t[e])}this.#gt=t}get blobs(){return null==this.#wt?null:this.#wt.map((t=>Object.assign({},t)))}set blobs(t){if(null==t)return void(this.#wt=null);const e=[],r=[];for(let n=0;n<t.length;n++){const i=t[n];if(pt(i)){it(this.#bt,"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let t=lt(i);if(ot(t.length<=yu,"blob is too large",`blobs[${n}]`,i),t.length!==yu){const e=new Uint8Array(yu);e.set(t),t=e}const o=this.#bt.blobToKzgCommitment(t),s=yt(this.#bt.computeBlobKzgProof(t,o));e.push({data:yt(t),commitment:yt(o),proof:s}),r.push(gu(1,o))}else{const t=yt(i.commitment);e.push({data:yt(i.data),commitment:t,proof:yt(i.proof)}),r.push(gu(1,t))}}this.#wt=e,this.#gt=r}get kzg(){return this.#bt}set kzg(t){this.#bt=t}constructor(){this.#it=null,this.#ot=null,this.#st=0,this.#at=cu,this.#ut=null,this.#ct=null,this.#lt=null,this.#e="0x",this.#ft=cu,this.#ht=cu,this.#pt=null,this.#dt=null,this.#yt=null,this.#gt=null,this.#wt=null,this.#bt=null}get hash(){return null==this.signature?null:Pe(this.#mt(!0,!1))}get unsignedHash(){return Pe(this.unsignedSerialized)}get from(){return null==this.signature?null:(t=this.unsignedHash,e=this.signature,function(t){let e;return e="string"==typeof t?$a.computePublicKey(t,!1):t.publicKey,Ue(Pe("0x"+e.substring(4)).substring(26))}($a.recoverPublicKey(t,e)));var t,e}get fromPublicKey(){return null==this.signature?null:$a.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return null!=this.signature}#mt(t,e){it(!t||null!=this.signature,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=t?this.signature:null;switch(this.inferType()){case 0:return function(t,e){const r=[Eu(t.nonce,"nonce"),Eu(t.gasPrice||0,"gasPrice"),Eu(t.gasLimit,"gasLimit"),t.to||"0x",Eu(t.value,"value"),t.data];let n=cu;if(t.chainId!=cu)n=Tt(t.chainId,"tx.chainId"),ot(!e||null==e.networkV||e.legacyChainId===n,"tx.chainId/sig.v mismatch","sig",e);else if(t.signature){const e=t.signature.legacyChainId;null!=e&&(n=e)}if(!e)return n!==cu&&(r.push(Rt(n)),r.push("0x"),r.push("0x")),uu(r);let i=BigInt(27+e.yParity);return n!==cu?i=Ns.getChainIdV(n,e.v):BigInt(e.v)!==i&&ot(!1,"tx.chainId/sig.v mismatch","sig",e),r.push(Rt(i)),r.push(Rt(e.r)),r.push(Rt(e.s)),uu(r)}(this,r);case 1:return function(t,e){const r=[Eu(t.chainId,"chainId"),Eu(t.nonce,"nonce"),Eu(t.gasPrice||0,"gasPrice"),Eu(t.gasLimit,"gasLimit"),t.to||"0x",Eu(t.value,"value"),t.data,Au(t.accessList||[])];return e&&(r.push(Eu(e.yParity,"recoveryParam")),r.push(Rt(e.r)),r.push(Rt(e.s))),gt(["0x01",uu(r)])}(this,r);case 2:return function(t,e){const r=[Eu(t.chainId,"chainId"),Eu(t.nonce,"nonce"),Eu(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Eu(t.maxFeePerGas||0,"maxFeePerGas"),Eu(t.gasLimit,"gasLimit"),t.to||"0x",Eu(t.value,"value"),t.data,Au(t.accessList||[])];return e&&(r.push(Eu(e.yParity,"yParity")),r.push(Rt(e.r)),r.push(Rt(e.s))),gt(["0x02",uu(r)])}(this,r);case 3:return function(t,e,r){const n=[Eu(t.chainId,"chainId"),Eu(t.nonce,"nonce"),Eu(t.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),Eu(t.maxFeePerGas||0,"maxFeePerGas"),Eu(t.gasLimit,"gasLimit"),t.to||Hn,Eu(t.value,"value"),t.data,Au(t.accessList||[]),Eu(t.maxFeePerBlobGas||0,"maxFeePerBlobGas"),Su(t.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(n.push(Eu(e.yParity,"yParity")),n.push(Rt(e.r)),n.push(Rt(e.s)),r)?gt(["0x03",uu([n,r.map((t=>t.data)),r.map((t=>t.commitment)),r.map((t=>t.proof))])]):gt(["0x03",uu(n)])}(this,r,e?this.blobs:null)}it(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})}get serialized(){return this.#mt(!0,!0)}get unsignedSerialized(){return this.#mt(!1,!1)}inferType(){const t=this.inferTypes();return t.indexOf(2)>=0?2:t.pop()}inferTypes(){const t=null!=this.gasPrice,e=null!=this.maxFeePerGas||null!=this.maxPriorityFeePerGas,r=null!=this.accessList,n=null!=this.#yt||this.#gt;null!=this.maxFeePerGas&&null!=this.maxPriorityFeePerGas&&it(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),it(!e||0!==this.type&&1!==this.type,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),it(0!==this.type||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return null!=this.type?i.push(this.type):e?i.push(2):t?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(n&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return 0===this.type}isBerlin(){return 1===this.type}isLondon(){return 2===this.type}isCancun(){return 3===this.type}clone(){return ku.from(this)}toJSON(){const t=t=>null==t?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:t(this.gasLimit),gasPrice:t(this.gasPrice),maxPriorityFeePerGas:t(this.maxPriorityFeePerGas),maxFeePerGas:t(this.maxFeePerGas),value:t(this.value),chainId:t(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(t){if(null==t)return new ku;if("string"==typeof t){const e=lt(t);if(e[0]>=127)return ku.from(function(t){const e=iu(t);ot(Array.isArray(e)&&(9===e.length||6===e.length),"invalid field count for legacy transaction","data",t);const r={type:0,nonce:mu(e[0],"nonce"),gasPrice:vu(e[1],"gasPrice"),gasLimit:vu(e[2],"gasLimit"),to:bu(e[3]),value:vu(e[4],"value"),data:yt(e[5]),chainId:cu};if(6===e.length)return r;const n=vu(e[6],"v"),i=vu(e[7],"r"),o=vu(e[8],"s");if(i===cu&&o===cu)r.chainId=n;else{let t=(n-pu)/lu;t<cu&&(t=cu),r.chainId=t,ot(t!==cu||n===fu||n===hu,"non-canonical legacy v","v",e[6]),r.signature=Ns.from({r:vt(e[7],32),s:vt(e[8],32),v:n})}return r}(e));switch(e[0]){case 1:return ku.from(function(t){const e=iu(lt(t).slice(1));ot(Array.isArray(e)&&(8===e.length||11===e.length),"invalid field count for transaction type: 1","data",yt(t));const r={type:1,chainId:vu(e[0],"chainId"),nonce:mu(e[1],"nonce"),gasPrice:vu(e[2],"gasPrice"),gasLimit:vu(e[3],"gasLimit"),to:bu(e[4]),value:vu(e[5],"value"),data:yt(e[6]),accessList:wu(e[7],"accessList")};return 8===e.length||_u(r,e.slice(8)),r}(e));case 2:return ku.from(function(t){const e=iu(lt(t).slice(1));ot(Array.isArray(e)&&(9===e.length||12===e.length),"invalid field count for transaction type: 2","data",yt(t));const r={type:2,chainId:vu(e[0],"chainId"),nonce:mu(e[1],"nonce"),maxPriorityFeePerGas:vu(e[2],"maxPriorityFeePerGas"),maxFeePerGas:vu(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:vu(e[4],"gasLimit"),to:bu(e[5]),value:vu(e[6],"value"),data:yt(e[7]),accessList:wu(e[8],"accessList")};return 9===e.length||_u(r,e.slice(9)),r}(e));case 3:return ku.from(function(t){let e=iu(lt(t).slice(1)),r="3",n=null;if(4===e.length&&Array.isArray(e[0])){r="3 (network format)";const t=e[1],i=e[2],o=e[3];ot(Array.isArray(t),"invalid network format: blobs not an array","fields[1]",t),ot(Array.isArray(i),"invalid network format: commitments not an array","fields[2]",i),ot(Array.isArray(o),"invalid network format: proofs not an array","fields[3]",o),ot(t.length===i.length,"invalid network format: blobs/commitments length mismatch","fields",e),ot(t.length===o.length,"invalid network format: blobs/proofs length mismatch","fields",e),n=[];for(let r=0;r<e[1].length;r++)n.push({data:t[r],commitment:i[r],proof:o[r]});e=e[0]}ot(Array.isArray(e)&&(11===e.length||14===e.length),`invalid field count for transaction type: ${r}`,"data",yt(t));const i={type:3,chainId:vu(e[0],"chainId"),nonce:mu(e[1],"nonce"),maxPriorityFeePerGas:vu(e[2],"maxPriorityFeePerGas"),maxFeePerGas:vu(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:vu(e[4],"gasLimit"),to:bu(e[5]),value:vu(e[6],"value"),data:yt(e[7]),accessList:wu(e[8],"accessList"),maxFeePerBlobGas:vu(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};n&&(i.blobs=n),ot(null!=i.to,`invalid address for transaction type: ${r}`,"data",t),ot(Array.isArray(i.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",t);for(let e=0;e<i.blobVersionedHashes.length;e++)ot(ht(i.blobVersionedHashes[e],32),`invalid blobVersionedHash at index ${e}: must be length 32`,"data",t);return 11===e.length||_u(i,e.slice(11)),i}(e))}it(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const e=new ku;return null!=t.type&&(e.type=t.type),null!=t.to&&(e.to=t.to),null!=t.nonce&&(e.nonce=t.nonce),null!=t.gasLimit&&(e.gasLimit=t.gasLimit),null!=t.gasPrice&&(e.gasPrice=t.gasPrice),null!=t.maxPriorityFeePerGas&&(e.maxPriorityFeePerGas=t.maxPriorityFeePerGas),null!=t.maxFeePerGas&&(e.maxFeePerGas=t.maxFeePerGas),null!=t.maxFeePerBlobGas&&(e.maxFeePerBlobGas=t.maxFeePerBlobGas),null!=t.data&&(e.data=t.data),null!=t.value&&(e.value=t.value),null!=t.chainId&&(e.chainId=t.chainId),null!=t.signature&&(e.signature=Ns.from(t.signature)),null!=t.accessList&&(e.accessList=t.accessList),null!=t.blobVersionedHashes&&(e.blobVersionedHashes=t.blobVersionedHashes),null!=t.kzg&&(e.kzg=t.kzg),null!=t.blobs&&(e.blobs=t.blobs),null!=t.hash&&(ot(e.isSigned(),"unsigned transaction cannot define '.hash'","tx",t),ot(e.hash===t.hash,"hash mismatch","tx",t)),null!=t.from&&(ot(e.isSigned(),"unsigned transaction cannot define '.from'","tx",t),ot(e.from.toLowerCase()===(t.from||"").toLowerCase(),"from mismatch","tx",t)),e}}const Tu="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const Pu=BigInt(58);function Iu(t){return t.match(/^ipfs:\/\/ipfs\//i)?t=t.substring(12):t.match(/^ipfs:\/\//i)?t=t.substring(7):ot(!1,"unsupported IPFS format","link",t),`https://gateway.ipfs.io/ipfs/${t}`}class Ou{name;constructor(t){$(this,{name:t})}connect(t){return this}supportsCoinType(t){return!1}async encodeAddress(t,e){throw new Error("unsupported coin")}async decodeAddress(t,e){throw new Error("unsupported coin")}}const xu=new RegExp("^(ipfs)://(.*)$","i"),Bu=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),xu,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")];class Ru{provider;address;name;#vt;#Et;constructor(t,e,r){$(this,{provider:t,address:e,name:r}),this.#vt=null,this.#Et=new Ni(e,["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)"],t)}async supportsWildcard(){return null==this.#vt&&(this.#vt=(async()=>{try{return await this.#Et.supportsInterface("0x9061b923")}catch(t){if(et(t,"CALL_EXCEPTION"))return!1;throw this.#vt=null,t}})()),await this.#vt}async#At(t,e){e=(e||[]).slice();const r=this.#Et.interface;e.unshift(Zo(this.name));let n=null;await this.supportsWildcard()&&(n=r.getFunction(t),it(n,"missing fragment","UNKNOWN_ERROR",{info:{funcName:t}}),e=[$o(this.name,255),r.encodeFunctionData(n,e)],t="resolve(bytes,bytes)"),e.push({enableCcipRead:!0});try{const i=await this.#Et[t](...e);return n?r.decodeFunctionResult(n,i)[0]:i}catch(t){if(!et(t,"CALL_EXCEPTION"))throw t}return null}async getAddress(t){if(null==t&&(t=60),60===t)try{const t=await this.#At("addr(bytes32)");return null==t||t===Hn?null:t}catch(t){if(et(t,"CALL_EXCEPTION"))return null;throw t}if(t>=0&&t<2147483648){let e=t+2147483648;const r=await this.#At("addr(bytes32,uint)",[e]);if(ht(r,20))return Ue(r)}let e=null;for(const r of this.provider.plugins)if(r instanceof Ou&&r.supportsCoinType(t)){e=r;break}if(null==e)return null;const r=await this.#At("addr(bytes32,uint)",[t]);if(null==r||"0x"===r)return null;const n=await e.decodeAddress(t,r);if(null!=n)return n;it(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${t})`,info:{coinType:t,data:r}})}async getText(t){const e=await this.#At("text(bytes32,string)",[t]);return null==e||"0x"===e?null:e}async getContentHash(){const t=await this.#At("contenthash(bytes32)");if(null==t||"0x"===t)return null;const e=t.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(e){const t="e3010170"===e[1]?"ipfs":"ipns",r=parseInt(e[4],16);if(e[5].length===2*r)return`${t}://${function(t){const e=lt(t);let r=Ot(e),n="";for(;r;)n=Tu[Number(r%Pu)]+n,r/=Pu;for(let t=0;t<e.length&&!e[t];t++)n=Tu[0]+n;return n}("0x"+e[2])}`}const r=t.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&64===r[1].length)return`bzz://${r[1]}`;it(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:t}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const t=[{type:"name",value:this.name}];try{const e=await this.getText("avatar");if(null==e)return t.push({type:"!avatar",value:""}),{url:null,linkage:t};t.push({type:"avatar",value:e});for(let r=0;r<Bu.length;r++){const n=e.match(Bu[r]);if(null==n)continue;const i=n[1].toLowerCase();switch(i){case"https":case"data":return t.push({type:"url",value:e}),{linkage:t,url:e};case"ipfs":{const r=Iu(e);return t.push({type:"ipfs",value:e}),t.push({type:"url",value:r}),{linkage:t,url:r}}case"erc721":case"erc1155":{const r="erc721"===i?"tokenURI(uint256)":"uri(uint256)";t.push({type:i,value:e});const o=await this.getAddress();if(null==o)return t.push({type:"!owner",value:""}),{url:null,linkage:t};const s=(n[2]||"").split("/");if(2!==s.length)return t.push({type:`!${i}caip`,value:n[2]||""}),{url:null,linkage:t};const a=s[1],u=new Ni(s[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("erc721"===i){const e=await u.ownerOf(a);if(o!==e)return t.push({type:"!owner",value:e}),{url:null,linkage:t};t.push({type:"owner",value:e})}else if("erc1155"===i){const e=await u.balanceOf(o,a);if(!e)return t.push({type:"!balance",value:"0"}),{url:null,linkage:t};t.push({type:"balance",value:e.toString()})}let c=await u[r](a);if(null==c||"0x"===c)return t.push({type:"!metadata-url",value:""}),{url:null,linkage:t};t.push({type:"metadata-url-base",value:c}),"erc1155"===i&&(c=c.replace("{id}",Bt(a,32).substring(2)),t.push({type:"metadata-url-expanded",value:c})),c.match(/^ipfs:/i)&&(c=Iu(c)),t.push({type:"metadata-url",value:c});let l={};const f=await new Dn(c).send();f.assertOk();try{l=f.bodyJson}catch(e){try{t.push({type:"!metadata",value:f.bodyText})}catch(e){const r=f.body;return r&&t.push({type:"!metadata",value:yt(r)}),{url:null,linkage:t}}return{url:null,linkage:t}}if(!l)return t.push({type:"!metadata",value:""}),{url:null,linkage:t};t.push({type:"metadata",value:JSON.stringify(l)});let h=l.image;if("string"!=typeof h)return t.push({type:"!imageUrl",value:""}),{url:null,linkage:t};if(h.match(/^(https:\/\/|data:)/i));else{if(null==h.match(xu))return t.push({type:"!imageUrl-ipfs",value:h}),{url:null,linkage:t};t.push({type:"imageUrl-ipfs",value:h}),h=Iu(h)}return t.push({type:"url",value:h}),{linkage:t,url:h}}}}}catch(t){}return{linkage:t,url:null}}static async getEnsAddress(t){const e=await t.getNetwork(),r=e.getPlugin("org.ethers.plugins.network.Ens");return it(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:e}}),r.address}static async#St(t,e){const r=await Ru.getEnsAddress(t);try{const n=new Ni(r,["function resolver(bytes32) view returns (address)"],t),i=await n.resolver(Zo(e),{enableCcipRead:!0});return i===Hn?null:i}catch(t){throw t}return null}static async fromName(t,e){let r=e;for(;;){if(""===r||"."===r)return null;if("eth"!==e&&"eth"===r)return null;const n=await Ru.#St(t,r);if(null!=n){const i=new Ru(t,n,e);return r===e||await i.supportsWildcard()?i:null}r=r.split(".").slice(1).join(".")}}}const Nu=BigInt(0);function Uu(t,e){return function(r){return null==r?e:t(r)}}function Cu(t,e){return r=>{if(e&&null==r)return null;if(!Array.isArray(r))throw new Error("not an array");return r.map((e=>t(e)))}}function Lu(t,e){return r=>{const n={};for(const i in t){let o=i;if(e&&i in e&&!(o in r))for(const t of e[i])if(t in r){o=t;break}try{const e=t[i](r[o]);void 0!==e&&(n[i]=e)}catch(t){it(!1,`invalid value for value.${i} (${t instanceof Error?t.message:"not-an-error"})`,"BAD_DATA",{value:r})}}return n}}function Du(t){return ot(ht(t,!0),"invalid data","value",t),t}function Mu(t){return ot(ht(t,32),"invalid hash","value",t),t}const Fu=Lu({address:Ue,blockHash:Mu,blockNumber:xt,data:Du,index:xt,removed:Uu((function(t){switch(t){case!0:case"true":return!0;case!1:case"false":return!1}ot(!1,`invalid boolean; ${JSON.stringify(t)}`,"value",t)}),!1),topics:Cu(Mu),transactionHash:Mu,transactionIndex:xt},{index:["logIndex"]}),Hu=Lu({hash:Uu(Mu),parentHash:Mu,parentBeaconBlockRoot:Uu(Mu,null),number:xt,timestamp:xt,nonce:Uu(Du),difficulty:Tt,gasLimit:Tt,gasUsed:Tt,stateRoot:Uu(Mu,null),receiptsRoot:Uu(Mu,null),blobGasUsed:Uu(Tt,null),excessBlobGas:Uu(Tt,null),miner:Uu(Ue),prevRandao:Uu(Mu,null),extraData:Du,baseFeePerGas:Uu(Tt)},{prevRandao:["mixHash"]}),ju=Lu({transactionIndex:xt,blockNumber:xt,transactionHash:Mu,address:Ue,topics:Cu(Mu),data:Du,index:xt,blockHash:Mu},{index:["logIndex"]}),Gu=Lu({to:Uu(Ue,null),from:Uu(Ue,null),contractAddress:Uu(Ue,null),index:xt,root:Uu(yt),gasUsed:Tt,blobGasUsed:Uu(Tt,null),logsBloom:Uu(Du),blockHash:Mu,hash:Mu,logs:Cu((function(t){return ju(t)})),blockNumber:xt,cumulativeGasUsed:Tt,effectiveGasPrice:Uu(Tt),blobGasPrice:Uu(Tt,null),status:Uu(xt),type:Uu(xt,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function Vu(t){t.to&&Tt(t.to)===Nu&&(t.to="0x0000000000000000000000000000000000000000");const e=Lu({hash:Mu,index:Uu(xt,void 0),type:t=>"0x"===t||null==t?0:xt(t),accessList:Uu(kn,null),blobVersionedHashes:Uu(Cu(Mu,!0),null),blockHash:Uu(Mu,null),blockNumber:Uu(xt,null),transactionIndex:Uu(xt,null),from:Ue,gasPrice:Uu(Tt),maxPriorityFeePerGas:Uu(Tt),maxFeePerGas:Uu(Tt),maxFeePerBlobGas:Uu(Tt,null),gasLimit:Tt,to:Uu(Ue,null),value:Tt,nonce:xt,data:Du,creates:Uu(Ue,null),chainId:Uu(Tt,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(t);if(null==e.to&&null==e.creates&&(e.creates=function(t){const e=Ue(t.from);let r=Tt(t.nonce,"tx.nonce").toString(16);return r="0"===r?"0x":r.length%2?"0x0"+r:"0x"+r,Ue(wt(Pe(uu([e,r])),12))}(e)),1!==t.type&&2!==t.type||null!=t.accessList||(e.accessList=[]),t.signature?e.signature=Ns.from(t.signature):e.signature=Ns.from(t),null==e.chainId){const t=e.signature.legacyChainId;null!=t&&(e.chainId=t)}return e.blockHash&&Tt(e.blockHash)===Nu&&(e.blockHash=null),e}class Ku{name;constructor(t){$(this,{name:t})}clone(){return new Ku(this.name)}}class Wu extends Ku{effectiveBlock;txBase;txCreate;txDataZero;txDataNonzero;txAccessListStorageKey;txAccessListAddress;constructor(t,e){null==t&&(t=0),super(`org.ethers.network.plugins.GasCost#${t||0}`);const r={effectiveBlock:t};function n(t,n){let i=(e||{})[t];null==i&&(i=n),ot("number"==typeof i,`invalud value for ${t}`,"costs",e),r[t]=i}n("txBase",21e3),n("txCreate",32e3),n("txDataZero",4),n("txDataNonzero",16),n("txAccessListStorageKey",1900),n("txAccessListAddress",2400),$(this,r)}clone(){return new Wu(this.effectiveBlock,this)}}class zu extends Ku{address;targetNetwork;constructor(t,e){super("org.ethers.plugins.network.Ens"),$(this,{address:t||"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e",targetNetwork:null==e?1:e})}clone(){return new zu(this.address,this.targetNetwork)}}class qu extends Ku{#T;#_t;get url(){return this.#T}get processFunc(){return this.#_t}constructor(t,e){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin"),this.#T=t,this.#_t=e}clone(){return this}}const Qu=new Map;class Ju{#kt;#ht;#Tt;constructor(t,e){this.#kt=t,this.#ht=Tt(e),this.#Tt=new Map}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return this.#kt}set name(t){this.#kt=t}get chainId(){return this.#ht}set chainId(t){this.#ht=Tt(t,"chainId")}matches(t){if(null==t)return!1;if("string"==typeof t){try{return this.chainId===Tt(t)}catch(t){}return this.name===t}if("number"==typeof t||"bigint"==typeof t){try{return this.chainId===Tt(t)}catch(t){}return!1}if("object"==typeof t){if(null!=t.chainId){try{return this.chainId===Tt(t.chainId)}catch(t){}return!1}return null!=t.name&&this.name===t.name}return!1}get plugins(){return Array.from(this.#Tt.values())}attachPlugin(t){if(this.#Tt.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#Tt.set(t.name,t.clone()),this}getPlugin(t){return this.#Tt.get(t)||null}getPlugins(t){return this.plugins.filter((e=>e.name.split("#")[0]===t))}clone(){const t=new Ju(this.name,this.chainId);return this.plugins.forEach((e=>{t.attachPlugin(e.clone())})),t}computeIntrinsicGas(t){const e=this.getPlugin("org.ethers.plugins.network.GasCost")||new Wu;let r=e.txBase;if(null==t.to&&(r+=e.txCreate),t.data)for(let n=2;n<t.data.length;n+=2)"00"===t.data.substring(n,n+2)?r+=e.txDataZero:r+=e.txDataNonzero;if(t.accessList){const n=kn(t.accessList);for(const t in n)r+=e.txAccessListAddress+e.txAccessListStorageKey*n[t].storageKeys.length}return r}static from(t){if(function(){function t(t,e,r){const n=function(){const n=new Ju(t,e);return null!=r.ensNetwork&&n.attachPlugin(new zu(null,r.ensNetwork)),n.attachPlugin(new Wu),(r.plugins||[]).forEach((t=>{n.attachPlugin(t)})),n};Ju.register(t,n),Ju.register(e,n),r.altNames&&r.altNames.forEach((t=>{Ju.register(t,n)}))}Zu||(Zu=!0,t("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),t("ropsten",3,{ensNetwork:3}),t("rinkeby",4,{ensNetwork:4}),t("goerli",5,{ensNetwork:5}),t("kovan",42,{ensNetwork:42}),t("sepolia",11155111,{ensNetwork:11155111}),t("holesky",17e3,{ensNetwork:17e3}),t("classic",61,{}),t("classicKotti",6,{}),t("arbitrum",42161,{ensNetwork:1}),t("arbitrum-goerli",421613,{}),t("arbitrum-sepolia",421614,{}),t("base",8453,{ensNetwork:1}),t("base-goerli",84531,{}),t("base-sepolia",84532,{}),t("bnb",56,{ensNetwork:1}),t("bnbt",97,{}),t("linea",59144,{ensNetwork:1}),t("linea-goerli",59140,{}),t("linea-sepolia",59141,{}),t("matic",137,{ensNetwork:1,plugins:[Yu("https://gasstation.polygon.technology/v2")]}),t("matic-amoy",80002,{}),t("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[Yu("https://gasstation-testnet.polygon.technology/v2")]}),t("optimism",10,{ensNetwork:1,plugins:[]}),t("optimism-goerli",420,{}),t("optimism-sepolia",11155420,{}),t("xdai",100,{ensNetwork:1}))}(),null==t)return Ju.from("mainnet");if("number"==typeof t&&(t=BigInt(t)),"string"==typeof t||"bigint"==typeof t){const e=Qu.get(t);if(e)return e();if("bigint"==typeof t)return new Ju("unknown",t);ot(!1,"unknown network","network",t)}if("function"==typeof t.clone)return t.clone();if("object"==typeof t){ot("string"==typeof t.name&&"number"==typeof t.chainId,"invalid network object name or chainId","network",t);const e=new Ju(t.name,t.chainId);return(t.ensAddress||null!=t.ensNetwork)&&e.attachPlugin(new zu(t.ensAddress,t.ensNetwork)),e}ot(!1,"invalid network","network",t)}static register(t,e){"number"==typeof t&&(t=BigInt(t));const r=Qu.get(t);r&&ot(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",t),Qu.set(t,e)}}function Xu(t,e){const r=String(t);if(!r.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${t}`);const n=r.split(".");if(1===n.length&&n.push(""),2!==n.length)throw new Error(`invalid gwei value: ${t}`);for(;n[1].length<e;)n[1]+="0";if(n[1].length>9){let t=BigInt(n[1].substring(0,9));n[1].substring(9).match(/^0+$/)||t++,n[1]=t.toString()}return BigInt(n[0]+n[1])}function Yu(t){return new qu(t,(async(t,e,r)=>{let n;r.setHeader("User-Agent","ethers");try{const[e,i]=await Promise.all([r.send(),t()]);n=e;const o=n.bodyJson.standard;return{gasPrice:i.gasPrice,maxFeePerGas:Xu(o.maxFee,9),maxPriorityFeePerGas:Xu(o.maxPriorityFee,9)}}catch(t){it(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:n,error:t})}}))}let Zu=!1;function $u(t){return JSON.parse(JSON.stringify(t))}class tc{#Pt;#It;#Ot;#xt;constructor(t){this.#Pt=t,this.#It=null,this.#Ot=4e3,this.#xt=-2}get pollingInterval(){return this.#Ot}set pollingInterval(t){this.#Ot=t}async#Bt(){try{const t=await this.#Pt.getBlockNumber();if(-2===this.#xt)return void(this.#xt=t);if(t!==this.#xt){for(let e=this.#xt+1;e<=t;e++){if(null==this.#It)return;await this.#Pt.emit("block",e)}this.#xt=t}}catch(t){}null!=this.#It&&(this.#It=this.#Pt._setTimeout(this.#Bt.bind(this),this.#Ot))}start(){this.#It||(this.#It=this.#Pt._setTimeout(this.#Bt.bind(this),this.#Ot),this.#Bt())}stop(){this.#It&&(this.#Pt._clearTimeout(this.#It),this.#It=null)}pause(t){this.stop(),t&&(this.#xt=-2)}resume(){this.start()}}class ec{#Pt;#Bt;#Rt;constructor(t){this.#Pt=t,this.#Rt=!1,this.#Bt=t=>{this._poll(t,this.#Pt)}}async _poll(t,e){throw new Error("sub-classes must override this")}start(){this.#Rt||(this.#Rt=!0,this.#Bt(-2),this.#Pt.on("block",this.#Bt))}stop(){this.#Rt&&(this.#Rt=!1,this.#Pt.off("block",this.#Bt))}pause(t){this.stop()}resume(){this.start()}}class rc extends ec{#Nt;#Ut;constructor(t,e){super(t),this.#Nt=e,this.#Ut=-2}pause(t){t&&(this.#Ut=-2),super.pause(t)}async _poll(t,e){const r=await e.getBlock(this.#Nt);null!=r&&(-2===this.#Ut?this.#Ut=r.number:r.number>this.#Ut&&(e.emit(this.#Nt,r.number),this.#Ut=r.number))}}class nc extends ec{#Z;constructor(t,e){super(t),this.#Z=$u(e)}async _poll(t,e){throw new Error("@TODO")}}class ic extends ec{#Ct;constructor(t,e){super(t),this.#Ct=e}async _poll(t,e){const r=await e.getTransactionReceipt(this.#Ct);r&&e.emit(this.#Ct,r)}}class oc{#Pt;#Z;#It;#Rt;#xt;constructor(t,e){this.#Pt=t,this.#Z=$u(e),this.#It=this.#Bt.bind(this),this.#Rt=!1,this.#xt=-2}async#Bt(t){if(-2===this.#xt)return;const e=$u(this.#Z);e.fromBlock=this.#xt+1,e.toBlock=t;const r=await this.#Pt.getLogs(e);if(0!==r.length)for(const t of r)this.#Pt.emit(this.#Z,t),this.#xt=t.blockNumber;else this.#xt<t-60&&(this.#xt=t-60)}start(){this.#Rt||(this.#Rt=!0,-2===this.#xt&&this.#Pt.getBlockNumber().then((t=>{this.#xt=t})),this.#Pt.on("block",this.#It))}stop(){this.#Rt&&(this.#Rt=!1,this.#Pt.off("block",this.#It))}pause(t){this.stop(),t&&(this.#xt=-2)}resume(){this.start()}}const sc=BigInt(2);function ac(t){return t&&"function"==typeof t.then}function uc(t,e){return t+":"+JSON.stringify(e,((t,e)=>{if(null==e)return"null";if("bigint"==typeof e)return`bigint:${e.toString()}`;if("string"==typeof e)return e.toLowerCase();if("object"==typeof e&&!Array.isArray(e)){const t=Object.keys(e);return t.sort(),t.reduce(((t,r)=>(t[r]=e[r],t)),{})}return e}))}class cc{name;constructor(t){$(this,{name:t})}start(){}stop(){}pause(t){}resume(){}}function lc(t){return(t=Array.from(new Set(t).values())).sort(),t}async function fc(t,e){if(null==t)throw new Error("invalid event");if(Array.isArray(t)&&(t={topics:t}),"string"==typeof t)switch(t){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:t,tag:t}}if(ht(t,32)){const e=t.toLowerCase();return{type:"transaction",tag:uc("tx",{hash:e}),hash:e}}if(t.orphan){const e=t;return{type:"orphan",tag:uc("orphan",e),filter:(r=e,JSON.parse(JSON.stringify(r)))}}var r;if(t.address||t.topics){const r=t,n={topics:(r.topics||[]).map((t=>null==t?null:Array.isArray(t)?lc(t.map((t=>t.toLowerCase()))):t.toLowerCase()))};if(r.address){const t=[],i=[],o=r=>{ht(r)?t.push(r):i.push((async()=>{t.push(await un(r,e))})())};Array.isArray(r.address)?r.address.forEach(o):o(r.address),i.length&&await Promise.all(i),n.address=lc(t.map((t=>t.toLowerCase())))}return{filter:n,tag:uc("event",n),type:"event"}}ot(!1,"unknown ProviderEvent","event",t)}function hc(){return(new Date).getTime()}const pc={cacheTimeout:250,pollingInterval:4e3};class dc{#Lt;#Tt;#Dt;#Mt;#Ft;#Ht;#jt;#Gt;#Vt;#Kt;#Wt;#l;constructor(t,e){if(this.#l=Object.assign({},pc,e||{}),"any"===t)this.#Ht=!0,this.#Ft=null;else if(t){const e=Ju.from(t);this.#Ht=!1,this.#Ft=Promise.resolve(e),setTimeout((()=>{this.emit("network",e,null)}),0)}else this.#Ht=!1,this.#Ft=null;this.#Gt=-1,this.#jt=new Map,this.#Lt=new Map,this.#Tt=new Map,this.#Dt=null,this.#Mt=!1,this.#Vt=1,this.#Kt=new Map,this.#Wt=!1}get pollingInterval(){return this.#l.pollingInterval}get provider(){return this}get plugins(){return Array.from(this.#Tt.values())}attachPlugin(t){if(this.#Tt.get(t.name))throw new Error(`cannot replace existing plugin: ${t.name} `);return this.#Tt.set(t.name,t.connect(this)),this}getPlugin(t){return this.#Tt.get(t)||null}get disableCcipRead(){return this.#Wt}set disableCcipRead(t){this.#Wt=!!t}async#zt(t){const e=this.#l.cacheTimeout;if(e<0)return await this._perform(t);const r=uc(t.method,t);let n=this.#jt.get(r);return n||(n=this._perform(t),this.#jt.set(r,n),setTimeout((()=>{this.#jt.get(r)===n&&this.#jt.delete(r)}),e)),await n}async ccipReadFetch(t,e,r){if(this.disableCcipRead||0===r.length||null==t.to)return null;const n=t.to.toLowerCase(),i=e.toLowerCase(),o=[];for(let e=0;e<r.length;e++){const s=r[e],a=s.replace("{sender}",n).replace("{data}",i),u=new Dn(a);-1===s.indexOf("{data}")&&(u.body={data:i,sender:n}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:e,urls:r});let c="unknown error";const l=await u.send();try{const t=l.bodyJson;if(t.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:t}),t.data;t.message&&(c=t.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:t})}catch(t){}it(l.statusCode<400||l.statusCode>=500,`response not found during CCIP fetch: ${c}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:t,info:{url:s,errorMessage:c}}),o.push(c)}it(!1,`error encountered during CCIP fetch: ${o.map((t=>JSON.stringify(t))).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:t,info:{urls:r,errorMessages:o}})}_wrapBlock(t,e){return new $n(function(t){const e=Hu(t);return e.transactions=t.transactions.map((t=>"string"==typeof t?t:Vu(t))),e}(t),this)}_wrapLog(t,e){return new ti(function(t){return Fu(t)}(t),this)}_wrapTransactionReceipt(t,e){return new ei(function(t){return Gu(t)}(t),this)}_wrapTransactionResponse(t,e){return new ri(Vu(t),this)}_detectNetwork(){it(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(t){it(!1,`unsupported method: ${t.method}`,"UNSUPPORTED_OPERATION",{operation:t.method,info:t})}async getBlockNumber(){const t=xt(await this.#zt({method:"getBlockNumber"}),"%response");return this.#Gt>=0&&(this.#Gt=t),t}_getAddress(t){return un(t,this)}_getBlockTag(t){if(null==t)return"latest";switch(t){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return t}return ht(t)?ht(t,32)?t:Nt(t):("bigint"==typeof t&&(t=xt(t,"blockTag")),"number"==typeof t?t>=0?Nt(t):this.#Gt>=0?Nt(this.#Gt+t):this.getBlockNumber().then((e=>Nt(e+t))):void ot(!1,"invalid blockTag","blockTag",t))}_getFilter(t){const e=(t.topics||[]).map((t=>null==t?null:Array.isArray(t)?lc(t.map((t=>t.toLowerCase()))):t.toLowerCase())),r="blockHash"in t?t.blockHash:void 0,n=(t,n,i)=>{let o;switch(t.length){case 0:break;case 1:o=t[0];break;default:t.sort(),o=t}if(r&&(null!=n||null!=i))throw new Error("invalid filter");const s={};return o&&(s.address=o),e.length&&(s.topics=e),n&&(s.fromBlock=n),i&&(s.toBlock=i),r&&(s.blockHash=r),s};let i,o,s=[];if(t.address)if(Array.isArray(t.address))for(const e of t.address)s.push(this._getAddress(e));else s.push(this._getAddress(t.address));return"fromBlock"in t&&(i=this._getBlockTag(t.fromBlock)),"toBlock"in t&&(o=this._getBlockTag(t.toBlock)),s.filter((t=>"string"!=typeof t)).length||null!=i&&"string"!=typeof i||null!=o&&"string"!=typeof o?Promise.all([Promise.all(s),i,o]).then((t=>n(t[0],t[1],t[2]))):n(s,i,o)}_getTransactionRequest(t){const e=Zn(t),r=[];if(["to","from"].forEach((t=>{if(null==e[t])return;const n=un(e[t],this);ac(n)?r.push(async function(){e[t]=await n}()):e[t]=n})),null!=e.blockTag){const t=this._getBlockTag(e.blockTag);ac(t)?r.push(async function(){e.blockTag=await t}()):e.blockTag=t}return r.length?async function(){return await Promise.all(r),e}():e}async getNetwork(){if(null==this.#Ft){const t=(async()=>{try{const t=await this._detectNetwork();return this.emit("network",t,null),t}catch(e){throw this.#Ft===t&&(this.#Ft=null),e}})();return this.#Ft=t,(await t).clone()}const t=this.#Ft,[e,r]=await Promise.all([t,this._detectNetwork()]);return e.chainId!==r.chainId&&(this.#Ht?(this.emit("network",r,e),this.#Ft===t&&(this.#Ft=Promise.resolve(r))):it(!1,`network changed: ${e.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),e.clone()}async getFeeData(){const t=await this.getNetwork(),e=async()=>{const{_block:e,gasPrice:r,priorityFee:n}=await Z({_block:this.#qt("latest",!1),gasPrice:(async()=>{try{return Tt(await this.#zt({method:"getGasPrice"}),"%response")}catch(t){}return null})(),priorityFee:(async()=>{try{return Tt(await this.#zt({method:"getPriorityFee"}),"%response")}catch(t){}return null})()});let i=null,o=null;const s=this._wrapBlock(e,t);return s&&s.baseFeePerGas&&(o=null!=n?n:BigInt("1000000000"),i=s.baseFeePerGas*sc+o),new Yn(r,i,o)},r=t.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const t=new Dn(r.url),n=await r.processFunc(e,this,t);return new Yn(n.gasPrice,n.maxFeePerGas,n.maxPriorityFeePerGas)}return await e()}async estimateGas(t){let e=this._getTransactionRequest(t);return ac(e)&&(e=await e),Tt(await this.#zt({method:"estimateGas",transaction:e}),"%response")}async#Qt(t,e,r){it(r<10,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},t,{blockTag:e,enableCcipRead:!0})});const n=Zn(t);try{return yt(await this._perform({method:"call",transaction:n,blockTag:e}))}catch(t){if(!this.disableCcipRead&&rt(t)&&t.data&&r>=0&&"latest"===e&&null!=n.to&&"0x556f1830"===wt(t.data,0,4)){const i=t.data,o=await un(n.to,this);let s;try{s=function(t){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};it(bt(t)>=160,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const r=wt(t,0,32);it(wt(r,0,12)===wt(Ec,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=wt(r,12);try{const r=[],n=xt(wt(t,32,64)),i=xt(wt(t,n,n+32)),o=wt(t,n+32);for(let t=0;t<i;t++){const e=yc(o,32*t);if(null==e)throw new Error("abort");r.push(e)}e.urls=r}catch(t){it(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=gc(t,64);if(null==r)throw new Error("abort");e.calldata=r}catch(t){it(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}it(wt(t,100,128)===wt(Ec,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=wt(t,96,100);try{const r=gc(t,128);if(null==r)throw new Error("abort");e.extraData=r}catch(t){it(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map((t=>e[t])),e}(wt(t.data,4))}catch(t){it(!1,t.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:n,info:{data:i}})}it(s.sender.toLowerCase()===o.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:i,reason:"OffchainLookup",transaction:n,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:s.errorArgs}});const a=await this.ccipReadFetch(n,s.calldata,s.urls);it(null!=a,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:n,info:{data:t.data,errorArgs:s.errorArgs}});const u={to:o,data:gt([s.selector,vc([a,s.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const t=await this.#Qt(u,e,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:t}),t}catch(t){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:t}),t}}throw t}}async#Jt(t){const{value:e}=await Z({network:this.getNetwork(),value:t});return e}async call(t){const{tx:e,blockTag:r}=await Z({tx:this._getTransactionRequest(t),blockTag:this._getBlockTag(t.blockTag)});return await this.#Jt(this.#Qt(e,r,t.enableCcipRead?0:-1))}async#Xt(t,e,r){let n=this._getAddress(e),i=this._getBlockTag(r);return"string"==typeof n&&"string"==typeof i||([n,i]=await Promise.all([n,i])),await this.#Jt(this.#zt(Object.assign(t,{address:n,blockTag:i})))}async getBalance(t,e){return Tt(await this.#Xt({method:"getBalance"},t,e),"%response")}async getTransactionCount(t,e){return xt(await this.#Xt({method:"getTransactionCount"},t,e),"%response")}async getCode(t,e){return yt(await this.#Xt({method:"getCode"},t,e))}async getStorage(t,e,r){const n=Tt(e,"position");return yt(await this.#Xt({method:"getStorage",position:n},t,r))}async broadcastTransaction(t){const{blockNumber:e,hash:r,network:n}=await Z({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:t}),network:this.getNetwork()}),i=ku.from(t);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,n).replaceableTransaction(e)}async#qt(t,e){if(ht(t,32))return await this.#zt({method:"getBlock",blockHash:t,includeTransactions:e});let r=this._getBlockTag(t);return"string"!=typeof r&&(r=await r),await this.#zt({method:"getBlock",blockTag:r,includeTransactions:e})}async getBlock(t,e){const{network:r,params:n}=await Z({network:this.getNetwork(),params:this.#qt(t,!!e)});return null==n?null:this._wrapBlock(n,r)}async getTransaction(t){const{network:e,params:r}=await Z({network:this.getNetwork(),params:this.#zt({method:"getTransaction",hash:t})});return null==r?null:this._wrapTransactionResponse(r,e)}async getTransactionReceipt(t){const{network:e,params:r}=await Z({network:this.getNetwork(),params:this.#zt({method:"getTransactionReceipt",hash:t})});if(null==r)return null;if(null==r.gasPrice&&null==r.effectiveGasPrice){const e=await this.#zt({method:"getTransaction",hash:t});if(null==e)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=e.gasPrice}return this._wrapTransactionReceipt(r,e)}async getTransactionResult(t){const{result:e}=await Z({network:this.getNetwork(),result:this.#zt({method:"getTransactionResult",hash:t})});return null==e?null:yt(e)}async getLogs(t){let e=this._getFilter(t);ac(e)&&(e=await e);const{network:r,params:n}=await Z({network:this.getNetwork(),params:this.#zt({method:"getLogs",filter:e})});return n.map((t=>this._wrapLog(t,r)))}_getProvider(t){it(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(t){return await Ru.fromName(this,t)}async getAvatar(t){const e=await this.getResolver(t);return e?await e.getAvatar():null}async resolveName(t){const e=await this.getResolver(t);return e?await e.getAddress():null}async lookupAddress(t){const e=Zo((t=Ue(t)).substring(2).toLowerCase()+".addr.reverse");try{const r=await Ru.getEnsAddress(this),n=new Ni(r,["function resolver(bytes32) view returns (address)"],this),i=await n.resolver(e);if(null==i||i===Hn)return null;const o=new Ni(i,["function name(bytes32) view returns (string)"],this),s=await o.name(e);return await this.resolveName(s)!==t?null:s}catch(t){if(et(t,"BAD_DATA")&&"0x"===t.value)return null;if(et(t,"CALL_EXCEPTION"))return null;throw t}return null}async waitForTransaction(t,e,r){const n=null!=e?e:1;return 0===n?this.getTransactionReceipt(t):new Promise((async(e,i)=>{let o=null;const s=async r=>{try{const i=await this.getTransactionReceipt(t);if(null!=i&&r-i.blockNumber+1>=n)return e(i),void(o&&(clearTimeout(o),o=null))}catch(t){console.log("EEE",t)}this.once("block",s)};null!=r&&(o=setTimeout((()=>{null!=o&&(o=null,this.off("block",s),i(nt("timeout","TIMEOUT",{reason:"timeout"})))}),r)),s(await this.getBlockNumber())}))}async waitForBlock(t){it(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(t){const e=this.#Kt.get(t);e&&(e.timer&&clearTimeout(e.timer),this.#Kt.delete(t))}_setTimeout(t,e){null==e&&(e=0);const r=this.#Vt++,n=()=>{this.#Kt.delete(r),t()};if(this.paused)this.#Kt.set(r,{timer:null,func:n,time:e});else{const t=setTimeout(n,e);this.#Kt.set(r,{timer:t,func:n,time:hc()})}return r}_forEachSubscriber(t){for(const e of this.#Lt.values())t(e.subscriber)}_getSubscriber(t){switch(t.type){case"debug":case"error":case"network":return new cc(t.type);case"block":{const t=new tc(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new rc(this,t.type);case"event":return new oc(this,t.filter);case"transaction":return new ic(this,t.hash);case"orphan":return new nc(this,t.filter)}throw new Error(`unsupported event: ${t.type}`)}_recoverSubscriber(t,e){for(const r of this.#Lt.values())if(r.subscriber===t){r.started&&r.subscriber.stop(),r.subscriber=e,r.started&&e.start(),null!=this.#Dt&&e.pause(this.#Dt);break}}async#Yt(t,e){let r=await fc(t,this);return"event"===r.type&&e&&e.length>0&&!0===e[0].removed&&(r=await fc({orphan:"drop-log",log:e[0]},this)),this.#Lt.get(r.tag)||null}async#Zt(t){const e=await fc(t,this),r=e.tag;let n=this.#Lt.get(r);return n||(n={subscriber:this._getSubscriber(e),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},this.#Lt.set(r,n)),n}async on(t,e){const r=await this.#Zt(t);return r.listeners.push({listener:e,once:!1}),r.started||(r.subscriber.start(),r.started=!0,null!=this.#Dt&&r.subscriber.pause(this.#Dt)),this}async once(t,e){const r=await this.#Zt(t);return r.listeners.push({listener:e,once:!0}),r.started||(r.subscriber.start(),r.started=!0,null!=this.#Dt&&r.subscriber.pause(this.#Dt)),this}async emit(t,...e){const r=await this.#Yt(t,e);if(!r||0===r.listeners.length)return!1;const n=r.listeners.length;return r.listeners=r.listeners.filter((({listener:r,once:n})=>{const i=new oi(this,n?null:r,t);try{r.call(this,...e,i)}catch(t){}return!n})),0===r.listeners.length&&(r.started&&r.subscriber.stop(),this.#Lt.delete(r.tag)),n>0}async listenerCount(t){if(t){const e=await this.#Yt(t);return e?e.listeners.length:0}let e=0;for(const{listeners:t}of this.#Lt.values())e+=t.length;return e}async listeners(t){if(t){const e=await this.#Yt(t);return e?e.listeners.map((({listener:t})=>t)):[]}let e=[];for(const{listeners:t}of this.#Lt.values())e=e.concat(t.map((({listener:t})=>t)));return e}async off(t,e){const r=await this.#Yt(t);if(!r)return this;if(e){const t=r.listeners.map((({listener:t})=>t)).indexOf(e);t>=0&&r.listeners.splice(t,1)}return e&&0!==r.listeners.length||(r.started&&r.subscriber.stop(),this.#Lt.delete(r.tag)),this}async removeAllListeners(t){if(t){const{tag:e,started:r,subscriber:n}=await this.#Zt(t);r&&n.stop(),this.#Lt.delete(e)}else for(const[t,{started:e,subscriber:r}]of this.#Lt)e&&r.stop(),this.#Lt.delete(t);return this}async addListener(t,e){return await this.on(t,e)}async removeListener(t,e){return this.off(t,e)}get destroyed(){return this.#Mt}destroy(){this.removeAllListeners();for(const t of this.#Kt.keys())this._clearTimeout(t);this.#Mt=!0}get paused(){return null!=this.#Dt}set paused(t){!!t!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(t){if(this.#Gt=-1,null!=this.#Dt){if(this.#Dt==!!t)return;it(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber((e=>e.pause(t))),this.#Dt=!!t;for(const t of this.#Kt.values())t.timer&&clearTimeout(t.timer),t.time=hc()-t.time}resume(){if(null!=this.#Dt){this._forEachSubscriber((t=>t.resume())),this.#Dt=null;for(const t of this.#Kt.values()){let e=t.time;e<0&&(e=0),t.time=hc(),setTimeout(t.func,e)}}}}function yc(t,e){try{const r=gc(t,e);if(r)return ir(r)}catch(t){}return null}function gc(t,e){if("0x"===t)return null;try{const r=xt(wt(t,e,e+32)),n=xt(wt(t,r,r+32));return wt(t,r+32,r+32+n)}catch(t){}return null}function bc(t){const e=Rt(t);if(e.length>32)throw new Error("internal; should not happen");const r=new Uint8Array(32);return r.set(e,32-e.length),r}function wc(t){if(t.length%32==0)return t;const e=new Uint8Array(32*Math.ceil(t.length/32));return e.set(t),e}const mc=new Uint8Array([]);function vc(t){const e=[];let r=0;for(let n=0;n<t.length;n++)e.push(mc),r+=32;for(let n=0;n<t.length;n++){const i=lt(t[n]);e[n]=bc(r),e.push(bc(i.length)),e.push(wc(i)),r+=32+32*Math.ceil(i.length/32)}return gt(e)}const Ec="0x0000000000000000000000000000000000000000000000000000000000000000";function Ac(t,e){if(t.provider)return t.provider;it(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function Sc(t,e){let r=Zn(e);if(null!=r.to&&(r.to=un(r.to,t)),null!=r.from){const e=r.from;r.from=Promise.all([t.getAddress(),un(e,t)]).then((([t,e])=>(ot(t.toLowerCase()===e.toLowerCase(),"transaction from mismatch","tx.from",e),t)))}else r.from=t.getAddress();return await Z(r)}class _c{provider;constructor(t){$(this,{provider:t||null})}async getNonce(t){return Ac(this,"getTransactionCount").getTransactionCount(await this.getAddress(),t)}async populateCall(t){return await Sc(this,t)}async populateTransaction(t){const e=Ac(this,"populateTransaction"),r=await Sc(this,t);null==r.nonce&&(r.nonce=await this.getNonce("pending")),null==r.gasLimit&&(r.gasLimit=await this.estimateGas(r));const n=await this.provider.getNetwork();null!=r.chainId?ot(Tt(r.chainId)===n.chainId,"transaction chainId mismatch","tx.chainId",t.chainId):r.chainId=n.chainId;const i=null!=r.maxFeePerGas||null!=r.maxPriorityFeePerGas;if(null==r.gasPrice||2!==r.type&&!i?0!==r.type&&1!==r.type||!i||ot(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",t):ot(!1,"eip-1559 transaction do not support gasPrice","tx",t),2!==r.type&&null!=r.type||null==r.maxFeePerGas||null==r.maxPriorityFeePerGas)if(0===r.type||1===r.type){const t=await e.getFeeData();it(null!=t.gasPrice,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice)}else{const t=await e.getFeeData();if(null==r.type)if(null!=t.maxFeePerGas&&null!=t.maxPriorityFeePerGas)if(r.type=2,null!=r.gasPrice){const t=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=t,r.maxPriorityFeePerGas=t}else null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas);else null!=t.gasPrice?(it(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),null==r.gasPrice&&(r.gasPrice=t.gasPrice),r.type=0):it(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else 2!==r.type&&3!==r.type||(null==r.maxFeePerGas&&(r.maxFeePerGas=t.maxFeePerGas),null==r.maxPriorityFeePerGas&&(r.maxPriorityFeePerGas=t.maxPriorityFeePerGas))}else r.type=2;return await Z(r)}async estimateGas(t){return Ac(this,"estimateGas").estimateGas(await this.populateCall(t))}async call(t){return Ac(this,"call").call(await this.populateCall(t))}async resolveName(t){const e=Ac(this,"resolveName");return await e.resolveName(t)}async sendTransaction(t){const e=Ac(this,"sendTransaction"),r=await this.populateTransaction(t);delete r.from;const n=ku.from(r);return await e.broadcastTransaction(await this.signTransaction(n))}}class kc{#Pt;#$t;#It;#Rt;#te;#ee;constructor(t){this.#Pt=t,this.#$t=null,this.#It=this.#Bt.bind(this),this.#Rt=!1,this.#te=null,this.#ee=!1}_subscribe(t){throw new Error("subclasses must override this")}_emitResults(t,e){throw new Error("subclasses must override this")}_recover(t){throw new Error("subclasses must override this")}async#Bt(t){try{null==this.#$t&&(this.#$t=this._subscribe(this.#Pt));let t=null;try{t=await this.#$t}catch(t){if(!et(t,"UNSUPPORTED_OPERATION")||"eth_newFilter"!==t.operation)throw t}if(null==t)return this.#$t=null,void this.#Pt._recoverSubscriber(this,this._recover(this.#Pt));const e=await this.#Pt.getNetwork();if(this.#te||(this.#te=e),this.#te.chainId!==e.chainId)throw new Error("chaid changed");if(this.#ee)return;const r=await this.#Pt.send("eth_getFilterChanges",[t]);await this._emitResults(this.#Pt,r)}catch(t){console.log("@TODO",t)}this.#Pt.once("block",this.#It)}#re(){const t=this.#$t;t&&(this.#$t=null,t.then((t=>{this.#Pt.destroyed||this.#Pt.send("eth_uninstallFilter",[t])})))}start(){this.#Rt||(this.#Rt=!0,this.#Bt(-2))}stop(){this.#Rt&&(this.#Rt=!1,this.#ee=!0,this.#re(),this.#Pt.off("block",this.#It))}pause(t){t&&this.#re(),this.#Pt.off("block",this.#It)}resume(){this.start()}}class Tc extends kc{#ne;constructor(t,e){var r;super(t),this.#ne=(r=e,JSON.parse(JSON.stringify(r)))}_recover(t){return new oc(t,this.#ne)}async _subscribe(t){return await t.send("eth_newFilter",[this.#ne])}async _emitResults(t,e){for(const r of e)t.emit(this.#ne,t._wrapLog(r,t._network))}}class Pc extends kc{async _subscribe(t){return await t.send("eth_newPendingTransactionFilter",[])}async _emitResults(t,e){for(const r of e)t.emit("pending",r)}}const Ic="bigint,boolean,function,number,string,symbol".split(/,/g);function Oc(t){if(null==t||Ic.indexOf(typeof t)>=0)return t;if("function"==typeof t.getAddress)return t;if(Array.isArray(t))return t.map(Oc);if("object"==typeof t)return Object.keys(t).reduce(((e,r)=>(e[r]=t[r],e)),{});throw new Error(`should not happen: ${t} (${typeof t})`)}function xc(t){return new Promise((e=>{setTimeout(e,t)}))}function Bc(t){return t?t.toLowerCase():t}function Rc(t){return t&&"number"==typeof t.pollingInterval}const Nc={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Uc extends _c{address;constructor(t,e){super(t),$(this,{address:e=Ue(e)})}connect(t){it(!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 e=Oc(t),r=[];if(e.from){const n=e.from;r.push((async()=>{const r=await un(n,this.provider);ot(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r})())}else e.from=this.address;if(null==e.gasLimit&&r.push((async()=>{e.gasLimit=await this.provider.estimateGas({...e,from:this.address})})()),null!=e.to){const t=e.to;r.push((async()=>{e.to=await un(t,this.provider)})())}r.length&&await Promise.all(r);const n=this.provider.getRpcTransaction(e);return this.provider.send("eth_sendTransaction",[n])}async sendTransaction(t){const e=await this.provider.getBlockNumber(),r=await this.sendUncheckedTransaction(t);return await new Promise(((t,n)=>{const i=[1e3,100];let o=0;const s=async()=>{try{const n=await this.provider.getTransaction(r);if(null!=n)return void t(n.replaceableTransaction(e))}catch(t){if(et(t,"CANCELLED")||et(t,"BAD_DATA")||et(t,"NETWORK_ERROR"))return null==t.info&&(t.info={}),t.info.sendTransactionHash=r,void n(t);if(et(t,"INVALID_ARGUMENT")&&(o++,null==t.info&&(t.info={}),t.info.sendTransactionHash=r,o>10))return void n(t);this.provider.emit("error",nt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:t}))}this.provider._setTimeout((()=>{s()}),i.pop()||4e3)};s()}))}async signTransaction(t){const e=Oc(t);if(e.from){const r=await un(e.from,this.provider);ot(null!=r&&r.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),e.from=r}else e.from=this.address;const r=this.provider.getRpcTransaction(e);return await this.provider.send("eth_signTransaction",[r])}async signMessage(t){const e="string"==typeof t?nr(t):t;return await this.provider.send("personal_sign",[yt(e),this.address.toLowerCase()])}async signTypedData(t,e,r){const n=Oc(r),i=await Sn.resolveNames(t,e,n,(async t=>{const e=await un(t);return ot(null!=e,"TypedData does not support null address","value",t),e}));return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Sn.getPayload(i.domain,e,i.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const e="string"==typeof t?nr(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),yt(e)])}}class Cc extends dc{#l;#ie;#oe;#se;#ae;#te;#ue;#ce(){if(this.#se)return;const t=1===this._getOption("batchMaxCount")?0:this._getOption("batchStallTime");this.#se=setTimeout((()=>{this.#se=null;const t=this.#oe;for(this.#oe=[];t.length;){const e=[t.shift()];for(;t.length&&e.length!==this.#l.batchMaxCount;)if(e.push(t.shift()),JSON.stringify(e.map((t=>t.payload))).length>this.#l.batchMaxSize){t.unshift(e.pop());break}(async()=>{const t=1===e.length?e[0].payload:e.map((t=>t.payload));this.emit("debug",{action:"sendRpcPayload",payload:t});try{const r=await this._send(t);this.emit("debug",{action:"receiveRpcResult",result:r});for(const{resolve:t,reject:n,payload:i}of e){if(this.destroyed){n(nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:i.method}));continue}const e=r.filter((t=>t.id===i.id))[0];if(null!=e)"error"in e?n(this.getRpcError(i,e)):t(e.result);else{const t=nt("missing response for request","BAD_DATA",{value:r,info:{payload:i}});this.emit("error",t),n(t)}}}catch(t){this.emit("debug",{action:"receiveRpcError",error:t});for(const{reject:r}of e)r(t)}})()}}),t)}constructor(t,e){super(t,e),this.#ie=1,this.#l=Object.assign({},Nc,e||{}),this.#oe=[],this.#se=null,this.#te=null,this.#ue=null;{let t=null;const e=new Promise((e=>{t=e}));this.#ae={promise:e,resolve:t}}const r=this._getOption("staticNetwork");"boolean"==typeof r?(ot(!r||"any"!==t,"staticNetwork cannot be used on special network 'any'","options",e),r&&null!=t&&(this.#te=Ju.from(t))):r&&(ot(null==t||r.matches(t),"staticNetwork MUST match network object","options",e),this.#te=r)}_getOption(t){return this.#l[t]}get _network(){return it(this.#te,"network is not available yet","NETWORK_ERROR"),this.#te}async _perform(t){if("call"===t.method||"estimateGas"===t.method){let e=t.transaction;if(e&&null!=e.type&&Tt(e.type)&&null==e.maxFeePerGas&&null==e.maxPriorityFeePerGas){const r=await this.getFeeData();null==r.maxFeePerGas&&null==r.maxPriorityFeePerGas&&(t=Object.assign({},t,{transaction:Object.assign({},e,{type:void 0})}))}}const e=this.getRpcRequest(t);return null!=e?await this.send(e.method,e.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t){if(!0!==t)return t;if(this.#te)return this.#te}return this.#ue?await this.#ue:this.ready?(this.#ue=(async()=>{try{const t=Ju.from(Tt(await this.send("eth_chainId",[])));return this.#ue=null,t}catch(t){throw this.#ue=null,t}})(),await this.#ue):(this.#ue=(async()=>{const t={id:this.#ie++,method:"eth_chainId",params:[],jsonrpc:"2.0"};let e;this.emit("debug",{action:"sendRpcPayload",payload:t});try{e=(await this._send(t))[0],this.#ue=null}catch(t){throw this.#ue=null,this.emit("debug",{action:"receiveRpcError",error:t}),t}if(this.emit("debug",{action:"receiveRpcResult",result:e}),"result"in e)return Ju.from(Tt(e.result));throw this.getRpcError(t,e)})(),await this.#ue)}_start(){null!=this.#ae&&null!=this.#ae.resolve&&(this.#ae.resolve(),this.#ae=null,(async()=>{for(;null==this.#te&&!this.destroyed;)try{this.#te=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",nt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await xc(1e3)}this.#ce()})())}async _waitUntilReady(){if(null!=this.#ae)return await this.#ae.promise}_getSubscriber(t){return"pending"===t.type?new Pc(this):"event"===t.type?this._getOption("polling")?new oc(this,t.filter):new Tc(this,t.filter):"orphan"===t.type&&"drop-log"===t.filter.orphan?new cc("orphan"):super._getSubscriber(t)}get ready(){return null==this.#ae}getRpcTransaction(t){const e={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach((r=>{if(null==t[r])return;let n=r;"gasLimit"===r&&(n="gas"),e[n]=Nt(Tt(t[r],`tx.${r}`))})),["from","to","data"].forEach((r=>{null!=t[r]&&(e[r]=yt(t[r]))})),t.accessList&&(e.accessList=kn(t.accessList)),e}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:[Bc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Bc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Bc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Bc(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&&null!=t.filter.address&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Bc):t.filter.address=Bc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,e){const{method:r}=t,{error:n}=e;if("eth_estimateGas"===r&&n.message){const e=n.message;if(!e.match(/revert/i)&&e.match(/insufficient funds/i))return nt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:n}})}if("eth_call"===r||"eth_estimateGas"===r){const e=Mc(n),i=on.getBuiltinCallException("eth_call"===r?"call":"estimateGas",t.params[0],e?e.data:null);return i.info={error:n,payload:t},i}const i=JSON.stringify(function(t){const e=[];return Fc(t,e),e}(n));if("string"==typeof n.message&&n.message.match(/user denied|ethers-user-denied/i))return nt("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"}[r]||"unknown",reason:"rejected",info:{payload:t,error:n}});if("eth_sendRawTransaction"===r||"eth_sendTransaction"===r){const e=t.params[0];if(i.match(/insufficient funds|base fee exceeds gas limit/i))return nt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:e,info:{error:n}});if(i.match(/nonce/i)&&i.match(/too low/i))return nt("nonce has already been used","NONCE_EXPIRED",{transaction:e,info:{error:n}});if(i.match(/replacement transaction/i)&&i.match(/underpriced/i))return nt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:e,info:{error:n}});if(i.match(/only replay-protected/i))return nt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:r,info:{transaction:e,info:{error:n}}})}let o=!!i.match(/the method .* does not exist/i);return o||n&&n.details&&n.details.startsWith("Unauthorized method:")&&(o=!0),o?nt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:n,payload:t}}):nt("could not coalesce error","UNKNOWN_ERROR",{error:n,payload:t})}send(t,e){if(this.destroyed)return Promise.reject(nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const r=this.#ie++,n=new Promise(((n,i)=>{this.#oe.push({resolve:n,reject:i,payload:{method:t,params:e,id:r,jsonrpc:"2.0"}})}));return this.#ce(),n}async getSigner(t){null==t&&(t=0);const e=this.send("eth_accounts",[]);if("number"==typeof t){const r=await e;if(t>=r.length)throw new Error("no such account");return new Uc(this,r[t])}const{accounts:r}=await Z({network:this.getNetwork(),accounts:e});t=Ue(t);for(const e of r)if(Ue(e)===t)return new Uc(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map((t=>new Uc(this,t)))}destroy(){this.#se&&(clearTimeout(this.#se),this.#se=null);for(const{payload:t,reject:e}of this.#oe)e(nt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));this.#oe=[],super.destroy()}}class Lc extends Cc{#le;constructor(t,e){super(t,e);let r=this._getOption("pollingInterval");null==r&&(r=Nc.pollingInterval),this.#le=r}_getSubscriber(t){const e=super._getSubscriber(t);return Rc(e)&&(e.pollingInterval=this.#le),e}get pollingInterval(){return this.#le}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");this.#le=t,this._forEachSubscriber((t=>{Rc(t)&&(t.pollingInterval=this.#le)}))}}class Dc extends Lc{#fe;constructor(t,e,r){null==t&&(t="http://localhost:8545"),super(e,r),this.#fe="string"==typeof t?new Dn(t):t.clone()}_getConnection(){return this.#fe.clone()}async send(t,e){return await this._start(),await super.send(t,e)}async _send(t){const e=this._getConnection();e.body=JSON.stringify(t),e.setHeader("content-type","application/json");const r=await e.send();r.assertOk();let n=r.bodyJson;return Array.isArray(n)||(n=[n]),n}}function Mc(t){if(null==t)return null;if("string"==typeof t.message&&t.message.match(/revert/i)&&ht(t.data))return{message:t.message,data:t.data};if("object"==typeof t){for(const e in t){const r=Mc(t[e]);if(r)return r}return null}if("string"==typeof t)try{return Mc(JSON.parse(t))}catch(t){}return null}function Fc(t,e){if(null!=t){if("string"==typeof t.message&&e.push(t.message),"object"==typeof t)for(const r in t)Fc(t[r],e);if("string"==typeof t)try{return Fc(JSON.parse(t),e)}catch(t){}}}BigInt.prototype.toJSON=function(){return this.toString()};var Hc=i(8287).Buffer;class jc{static EXPECTED_BUFFER_LENGTH=32;static bufferToUint8Array(t){if(Hc.isBuffer(t)){const e=t.byteLength,r=new ArrayBuffer(e),n=new Uint8Array(r);for(let r=0;r<e;++r)n[r]=t[r];return n}return t}static uint8ArrayToHex(t){return Hc.from(t,0,t.byteLength).toString("hex")}static hexToUint8Array(t){t.startsWith("0x")&&(t=t.substr(2)),t.length%2!=0&&(t="0"+t);const e=t.length/2,r=new Uint8Array(e);for(let n=0;n<e;n++)r[n]=parseInt(t.substr(2*n,2),16);return r}static pointerToUint8Array(t){const e=t.toString(16).padStart(64,"0");return jc.hexToUint8Array(e)}static uint8ArrayToPointer(t){const e=jc.uint8ArrayToHex(t);return BigInt("0x"+e)}static valueToUint8Array(t){const e=t.toString(16).padStart(64,"0");return jc.hexToUint8Array(e)}static uint8ArrayToValue(t){const e=jc.uint8ArrayToHex(t);return e?BigInt("0x"+e):BigInt(0)}}class Gc{eventType;eventData;constructor(t,e){this.eventType=t,this.eventData=e}}class Vc{buffer;currentOffset=0;constructor(t){this.buffer=new DataView(t.buffer)}setBuffer(t){this.buffer=new DataView(t.buffer),this.currentOffset=0}readEvents(){const t=[],e=this.readU32();for(let r=0;r<e;r++){const e=this.readEvent();t.push(e)}return t}readEvent(){const t=this.readStringWithLength(),e=this.readBytesWithLength();return new Gc(t,e)}readBytesWithLength(){const t=this.readU32();return this.readBytes(t)}readSelectors(){const t=new Map,e=this.readU16();for(let r=0;r<e;r++){const e=this.readABISelector();t.set(e.name,e.selector)}return t}readABISelector(){return{name:this.readStringWithLength(),selector:this.readSelector()}}readViewSelectorsMap(){const t=new Map,e=this.readU16();for(let r=0;r<e;r++){const e=this.readAddress(),r=this.readSelectors();t.set(e,r)}return t}readMethodSelectorsMap(){const t=new Map,e=this.readU16();for(let r=0;r<e;r++){const e=this.readAddress(),r=this.readMethodSelectors();t.set(e,r)}return t}readMethodSelectors(){const t=new Set,e=this.readU16();for(let r=0;r<e;r++)t.add(this.readSelector());return t}readTuple(){const t=this.readU32(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU256();return e}readU8(){return this.verifyEnd(this.currentOffset+1),this.buffer.getUint8(this.currentOffset++)}readU16(){this.verifyEnd(this.currentOffset+2);const t=this.buffer.getUint16(this.currentOffset,!0);return this.currentOffset+=2,t}readU32(t=!0){this.verifyEnd(this.currentOffset+4);const e=this.buffer.getUint32(this.currentOffset,t);return this.currentOffset+=4,e}readU64(){const t=BigInt(this.readU32()),e=BigInt(this.readU32());return BigInt(e)<<32n|t}readStorage(){const t=this.readU32(),e=new Map;for(let r=0;r<t;r++){const t=this.readAddress(),r=this.readU32(),n=new Map;for(let t=0;t<r;t++){const t=this.readU256(),e=this.readU256();n.set(t,e)}e.set(t,n)}return e}readU256(){const t=this.readBytes(32);return BigInt("0x"+t.reduce(((t,e)=>t+e.toString(16).padStart(2,"0")),""))}readBytes(t,e=!1){let r=new Uint8Array(t);this.verifyEnd(this.currentOffset+t);for(let n=0;n<t;n++){const i=this.readU8();if(e&&0===i){r=r.slice(0,n),this.currentOffset+=t-(n+1);break}r[n]=i}return r}readString(t){const e=new TextDecoder,r=this.readBytes(t,!0);return e.decode(r)}readSelector(){return this.readU32(!1)}readStringWithLength(){const t=this.readU16();return this.readString(t)}readBoolean(){return 0!==this.readU8()}readFloat(){const t=this.buffer.getFloat32(this.currentOffset,!0);return this.currentOffset+=4,t}readDouble(){const t=this.buffer.getFloat64(this.currentOffset,!0);return this.currentOffset+=8,t}readAddress(){return this.readString(64)}getOffset(){return this.currentOffset}setOffset(t){this.currentOffset=t}verifyEnd(t){if(this.currentOffset>this.buffer.byteLength)throw new Error(`Expected to read ${t} bytes but read ${this.currentOffset} bytes`)}verifyChecksum(){const t=this.readU32();let e=0;for(let t=0;t<this.buffer.byteLength;t++)e+=this.buffer.getUint8(t);if(e%=2**32,e!==t)throw new Error("Invalid checksum for buffer")}}class Kc{currentOffset=0;buffer=new DataView(new ArrayBuffer(64));constructor(){}writeU8(t){this.allocSafe(1),this.buffer.setUint8(this.currentOffset++,t)}writeU16(t){this.allocSafe(2),this.buffer.setUint16(this.currentOffset,t,!0),this.currentOffset+=2}writeU32(t,e=!0){this.allocSafe(4),this.buffer.setUint32(this.currentOffset,t,e),this.currentOffset+=4}writeU64(t){this.writeU32(Number(t)),this.writeU32(Number(t>>32n))}writeSelector(t){this.writeU32(t,!1)}writeBoolean(t){this.writeU8(t?1:0)}writeU256(t){const e=jc.valueToUint8Array(t);if(32!==e.byteLength)throw console.log("Invalid u256 value:",e),new Error(`Invalid u256 value: ${t}`);for(let t=0;t<e.byteLength;t++)this.writeU8(e[t])}writeBytes(t){for(let e=0;e<t.byteLength;e++)this.writeU8(t[e])}writeString(t){for(let e=0;e<t.length;e++)this.writeU8(t.charCodeAt(e))}writeAddress(t){const e=this.fromAddress(t);this.writeBytes(e)}writeStringWithLength(t){this.writeU16(t.length),this.writeString(t)}writeViewSelectorMap(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeAddress(e),this.writeSelectors(t)}))}writeMethodSelectorsMap(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeAddress(e),this.writeMethodSelectorMap(t)}))}getBuffer(){const t=new Uint8Array(this.buffer.byteLength);for(let e=0;e<this.buffer.byteLength;e++)t[e]=this.buffer.getUint8(e);return this.clear(),t}reset(){this.currentOffset=0,this.buffer=new DataView(new ArrayBuffer(4))}writeStorage(t){this.reset(),this.writeU32(t.size);const e=Array.from(t.keys()),r=Array.from(t.values());for(let t=0;t<e.length;t++){const n=e[t],i=r[t];this.writeAddress(n),this.writeU32(i.size);const o=Array.from(i.keys());for(let t=0;t<o.length;t++){const e=o[t];this.writeU256(e);const r=i.get(e);if(null==r)throw new Error("Slot value not found.");this.writeU256(r)}}}writeTuple(t){this.writeU32(t.length);for(let e=0;e<t.length;e++)this.writeU256(t[e])}toBytesReader(){return new Vc(this.getBuffer())}getOffset(){return this.currentOffset}setOffset(t){this.currentOffset=t}clear(){this.currentOffset=0,this.buffer=new DataView(new ArrayBuffer(4))}allocSafe(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}writeABISelector(t,e){this.writeStringWithLength(t),this.writeSelector(e)}getChecksum(){let t=0;for(let e=0;e<this.buffer.byteLength;e++)t+=this.buffer.getUint8(e);return t%2**32}writeMethodSelectorMap(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeSelector(t)}))}writeSelectors(t){this.writeU16(t.size),t.forEach(((t,e,r)=>{this.writeABISelector(e,t)}))}fromAddress(t){if(t.length>64)throw new Error("Address is too long");const e=new Uint8Array(64);for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);for(let r=t.length;r<64;r++)e[r]=0;return e}resize(t){const e=new Uint8Array(this.buffer.byteLength+t);for(let t=0;t<this.buffer.byteLength;t++)e[t]=this.buffer.getUint8(t);this.buffer=new DataView(e.buffer)}}var Wc,zc=i(2802),qc=i(8287).Buffer;function Qc(t){return Qc="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Qc(t)}function Jc(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Zc(n.key),n)}}function Xc(t,e,r){return e&&Jc(t.prototype,e),r&&Jc(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Yc(t,e,r){return(e=Zc(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zc(t){var e=function(t,e){if("object"!=Qc(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Qc(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qc(e)?e:e+""}!function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES32="BYTES32",t.UINT256="UINT256",t.TUPLE="TUPLE"}(Wc||(Wc={}));var $c=Xc((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Yc(this,"transactionId",void 0),Yc(this,"outputIndex",void 0),Yc(this,"value",void 0),Yc(this,"scriptPubKey",void 0),this.transactionId=e.transactionId,this.outputIndex=e.outputIndex,this.value=BigInt(e.value),this.scriptPubKey=e.scriptPubKey}));function tl(t){return tl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},tl(t)}function el(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function rl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,nl(n.key),n)}}function nl(t){var e=function(t,e){if("object"!=tl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=tl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==tl(e)?e:e+""}var il=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"parseTransactions",value:function(t){if(!t)return[];var e,r=[],n=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return el(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?el(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r.push(this.parseTransaction(i))}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"parseTransaction",value:function(t){switch(t.OPNetType){case r.Generic:return new H(t);case r.Interaction:return new J(t);case r.Deployment:return new U(t);default:throw new Error("Unknown transaction type")}}}],null&&rl(t.prototype,null),e&&rl(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ol(t){return ol="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ol(t)}function sl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,cl(n.key),n)}}function al(t,e,r){return e&&sl(t.prototype,e),r&&sl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ul(t,e,r){return(e=cl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function cl(t){var e=function(t,e){if("object"!=ol(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ol(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ol(e)?e:e+""}var ll=al((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ul(this,"height",void 0),ul(this,"hash",void 0),ul(this,"previousBlockHash",void 0),ul(this,"previousBlockChecksum",void 0),ul(this,"bits",void 0),ul(this,"nonce",void 0),ul(this,"version",void 0),ul(this,"size",void 0),ul(this,"txCount",void 0),ul(this,"weight",void 0),ul(this,"strippedSize",void 0),ul(this,"time",void 0),ul(this,"medianTime",void 0),ul(this,"checksumRoot",void 0),ul(this,"merkleRoot",void 0),ul(this,"storageRoot",void 0),ul(this,"receiptRoot",void 0),ul(this,"checksumProofs",void 0),ul(this,"transactions",[]),this.height=BigInt(e.height.toString()),this.hash=e.hash,this.previousBlockHash=e.previousBlockHash,this.previousBlockChecksum=e.previousBlockChecksum,this.bits=e.bits,this.nonce=e.nonce,this.version=e.version,this.size=e.size,this.txCount=e.txCount,this.weight=e.weight,this.strippedSize=e.strippedSize,this.time=e.time,this.medianTime=e.medianTime,this.checksumRoot=e.checksumRoot,this.merkleRoot=e.merkleRoot,this.storageRoot=e.storageRoot,this.receiptRoot=e.receiptRoot,this.checksumProofs=e.checksumProofs,this.transactions=il.parseTransactions(e.transactions)})),fl=i(8287).Buffer;function hl(t){return hl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},hl(t)}function pl(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function dl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gl(n.key),n)}}function yl(t,e,r){return(e=gl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gl(t){var e=function(t,e){if("object"!=hl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=hl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==hl(e)?e:e+""}var bl=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),yl(this,"result",void 0),yl(this,"events",void 0),yl(this,"accessList",void 0),yl(this,"decoded",[]),this.events=e.events,this.accessList=e.accessList,this.result="string"==typeof e.result?new Vc(this.base64ToUint8Array(e.result)):e.result},(e=[{key:"setDecoded",value:function(t){var e,r;(e=this.decoded).push.apply(e,function(t){if(Array.isArray(t))return pl(t)}(r=t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(r)||function(t,e){if(t){if("string"==typeof t)return pl(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?pl(t,e):void 0}}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}},{key:"base64ToUint8Array",value:function(t){return jc.bufferToUint8Array(fl.from(t,"base64"))}}])&&dl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),wl=i(8287).Buffer;function ml(t){return ml="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},ml(t)}function vl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Sl(n.key),n)}}function El(t,e,r){return e&&vl(t.prototype,e),r&&vl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Al(t,e,r){return(e=Sl(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Sl(t){var e=function(t,e){if("object"!=ml(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=ml(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ml(e)?e:e+""}var _l=El((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Al(this,"contractAddress",void 0),Al(this,"virtualAddress",void 0),Al(this,"bytecode",void 0),Al(this,"wasCompressed",void 0),Al(this,"deployedTransactionId",void 0),Al(this,"deployedTransactionHash",void 0),Al(this,"deployerPubKey",void 0),Al(this,"contractSeed",void 0),Al(this,"contractSaltHash",void 0),Al(this,"deployerAddress",void 0),this.contractAddress=e.contractAddress,this.virtualAddress=e.virtualAddress,this.bytecode=wl.isBuffer(e.bytecode)?e.bytecode:wl.from(e.bytecode,"base64"),this.wasCompressed=e.wasCompressed,this.deployedTransactionId=e.deployedTransactionId,this.deployedTransactionHash=e.deployedTransactionHash,this.deployerPubKey=wl.isBuffer(e.deployerPubKey)?e.deployerPubKey:wl.from(e.deployerPubKey,"base64"),this.contractSeed=wl.isBuffer(e.contractSeed)?e.contractSeed:wl.from(e.contractSeed,"base64"),this.contractSaltHash=wl.isBuffer(e.contractSaltHash)?e.contractSaltHash:wl.from(e.contractSaltHash,"base64"),this.deployerAddress=e.deployerAddress})),kl=i(8287).Buffer;function Tl(t){return Tl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Tl(t)}function Pl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ol(n.key),n)}}function Il(t,e,r){return(e=Ol(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ol(t){var e=function(t,e){if("object"!=Tl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Tl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tl(e)?e:e+""}var xl=function(){return t=function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Il(this,"pointer",void 0),Il(this,"value",void 0),Il(this,"height",void 0),Il(this,"proofs",void 0),this.pointer="string"==typeof e.pointer?this.base64ToBigInt(e.pointer):e.pointer,e.value instanceof kl?this.value=e.value:this.value=kl.from(e.value,"base64"),this.height=BigInt(e.height),this.proofs=e.proofs||[]},(e=[{key:"base64ToBigInt",value:function(t){return jc.uint8ArrayToPointer(kl.from(t,"base64"))}}])&&Pl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),Bl=i(8287).Buffer;function Rl(t){return Rl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Rl(t)}function Nl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ll(n.key),n)}}function Ul(t,e,r){return e&&Nl(t.prototype,e),r&&Nl(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Cl(t,e,r){return(e=Ll(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ll(t){var e=function(t,e){if("object"!=Rl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Rl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Rl(e)?e:e+""}var Dl=Ul((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Cl(this,"receipt",void 0),Cl(this,"receiptProofs",void 0),Cl(this,"events",void 0),Cl(this,"revert",void 0),this.receipt=e.receipt?Bl.from(e.receipt,"base64"):null,this.receiptProofs=e.receiptProofs||[],this.events=e.events||[],this.revert=e.revert?Bl.from(e.revert,"base64"):void 0})),Ml=i(8287).Buffer;function Fl(t){return Fl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},Fl(t)}function Hl(){Hl=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,s=Object.create(o.prototype),a=new x(n||[]);return i(s,"_invoke",{value:T(t,r,a)}),s}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function w(){}function m(){}var v={};c(v,s,(function(){return this}));var E=Object.getPrototypeOf,A=E&&E(E(B([])));A&&A!==r&&n.call(A,s)&&(v=A);var S=m.prototype=b.prototype=Object.create(v);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(i,o,s,a){var u=f(t[i],t,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==Fl(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,s){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var u=P(a,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=f(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function B(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(Fl(e)+" is not iterable")}return w.prototype=m,i(S,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:w,configurable:!0}),w.displayName=c(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},_(k.prototype),c(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new k(l(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},_(S),c(S,u,"Generator"),c(S,s,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=B,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function jl(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}function Gl(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){jl(o,n,i,s,a,"next",t)}function a(t){jl(o,n,i,s,a,"throw",t)}s(void 0)}))}}function Vl(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Kl(n.key),n)}}function Kl(t){var e=function(t,e){if("object"!=Fl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=Fl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Fl(e)?e:e+""}var Wl=function(){return t=function t(){var e,r;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e=this,(r=Kl(r="nextId"))in e?Object.defineProperty(e,r,{value:0,enumerable:!0,configurable:!0,writable:!0}):e[r]=0},e=[{key:"getBlockNumber",value:(d=Gl(Hl().mark((function t(){return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider.getBlockNumber();case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(){return d.apply(this,arguments)})},{key:"getBlock",value:(p=Gl(Hl().mark((function t(e){var r,n,i,o,s,a=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],n="string"==typeof e?"btc_getBlockByHash":"btc_getBlockByNumber",i=this.buildJsonRpcPayload(n,[e,r]),t.next=5,this.callPayloadSingle(i);case 5:return o=t.sent,s=o.result,t.abrupt("return",new ll(s));case 8:case"end":return t.stop()}}),t,this)}))),function(t){return p.apply(this,arguments)})},{key:"getBlockByHash",value:(f=Gl(Hl().mark((function t(e){return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.getBlock(e);case 2:return t.abrupt("return",t.sent);case 3:case"end":return t.stop()}}),t,this)}))),function(t){return f.apply(this,arguments)})},{key:"getBalance",value:(l=Gl(Hl().mark((function t(e){var r,n,i,o;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=e.toString(),n=this.buildJsonRpcPayload("btc_getBalance",[r]),t.next=4,this.callPayloadSingle(n);case 4:if(i=t.sent,(o=i.result)&&(!o||o.startsWith("0x"))){t.next=8;break}throw new Error("Invalid balance returned from provider: ".concat(o));case 8:return t.abrupt("return",BigInt(o));case 9:case"end":return t.stop()}}),t,this)}))),function(t){return l.apply(this,arguments)})},{key:"getUXTOs",value:(c=Gl(Hl().mark((function t(e){var r,n,i,o,s,a=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],n=e.toString(),i=this.buildJsonRpcPayload("btc_getUTXOs",[n,r]),t.next=5,this.callPayloadSingle(i);case 5:return o=t.sent,s=o.result||[],t.abrupt("return",s.map((function(t){return new $c(t)})));case 8:case"end":return t.stop()}}),t,this)}))),function(t){return c.apply(this,arguments)})},{key:"getTransaction",value:(u=Gl(Hl().mark((function t(e){var r,n,i;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.buildJsonRpcPayload("btc_getTransactionByHash",[e]),t.next=3,this.callPayloadSingle(r);case 3:return n=t.sent,i=n.result,t.abrupt("return",il.parseTransaction(i));case 6:case"end":return t.stop()}}),t,this)}))),function(t){return u.apply(this,arguments)})},{key:"getTransactionReceipt",value:(a=Gl(Hl().mark((function t(e){var r,n;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=this.buildJsonRpcPayload("btc_getTransactionReceipt",[e]),t.next=3,this.callPayloadSingle(r);case 3:return n=t.sent,t.abrupt("return",new Dl(n.result));case 5:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"getNetwork",value:(s=Gl(Hl().mark((function t(){var e;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider.getNetwork();case 2:e=t.sent,t.t0=e.chainId,t.next=1n===t.t0?6:2n===t.t0?7:3n===t.t0?8:9;break;case 6:return t.abrupt("return",h.o8.bitcoin);case 7:return t.abrupt("return",h.o8.testnet);case 8:return t.abrupt("return",h.o8.regtest);case 9:throw new Error("Invalid chain id: ".concat(e.chainId));case 10:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"getCode",value:(o=Gl(Hl().mark((function t(e){var r,n,i,o,s,a=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=a.length>1&&void 0!==a[1]&&a[1],n=e.toString(),i=this.buildJsonRpcPayload("btc_getCode",[n,r]),t.next=5,this.callPayloadSingle(i);case 5:if(o=t.sent,!("contractAddress"in(s=o.result))){t.next=11;break}return t.abrupt("return",new _l(s));case 11:return t.abrupt("return",Ml.from(s.bytecode,"base64"));case 12:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"getStorageAt",value:(i=Gl(Hl().mark((function t(e,r){var n,i,o,s,a,u,c,l,f=arguments;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=!(f.length>2&&void 0!==f[2])||f[2],i=f.length>3?f[3]:void 0,o=e.toString(),s="string"==typeof r?r:this.bigintToBase64(r),a=[o,s,n],i&&a.push(i.toString()),u=this.buildJsonRpcPayload("btc_getStorageAt",a),t.next=9,this.callPayloadSingle(u);case 9:return c=t.sent,l=c.result,t.abrupt("return",new xl(l));case 12:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"call",value:(n=Gl(Hl().mark((function t(e,r,n,i){var o,s,a,u,c,l,f;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o=e.toString(),s=n?n.toString():null,(a=Ml.isBuffer(r)?this.bufferToHex(r):r).startsWith("0x")&&(a=a.slice(2)),u=[o,a],s&&u.push(s),i&&u.push(i.toString()),c=this.buildJsonRpcPayload("btc_call",u),t.next=10,this.callPayloadSingle(c);case 10:if(l=t.sent,!("error"in(f=l.result))){t.next=14;break}return t.abrupt("return",f);case 14:return t.abrupt("return",new bl(f));case 15:case"end":return t.stop()}}),t,this)}))),function(t,e,r,i){return n.apply(this,arguments)})},{key:"bufferToHex",value:function(t){return t.toString("hex")}},{key:"bigintToBase64",value:function(t){return Ml.from(jc.pointerToUint8Array(t)).toString("base64")}},{key:"callPayloadSingle",value:(r=Gl(Hl().mark((function t(e){var r,n;return Hl().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.provider._send(e);case 2:if(1===(r=t.sent).length){t.next=5;break}throw new Error("Unexpected response length for get block request: ".concat(r.length));case 5:if(n=r.shift()){t.next=8;break}throw new Error("Block not found");case 8:if(!("error"in n)){t.next=10;break}throw new Error("Something went wrong while fetching: ".concat(n.error.message));case 10:return t.abrupt("return",n);case 11:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"buildJsonRpcPayload",value:function(t,e){return{method:t,params:e,id:this.nextId++,jsonrpc:"2.0"}}}],e&&Vl(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e,r,n,i,o,s,a,u,c,l,f,p,d}();function zl(t){return zl="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},zl(t)}function ql(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,$l(n.key),n)}}function Ql(t,e,r){return e=Xl(e),function(t,e){if(e&&("object"===zl(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,Jl()?Reflect.construct(e,r||[],Xl(t).constructor):e.apply(t,r))}function Jl(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Jl=function(){return!!t})()}function Xl(t){return Xl=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xl(t)}function Yl(t,e){return Yl=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Yl(t,e)}function Zl(t,e,r){return(e=$l(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function $l(t){var e=function(t,e){if("object"!=zl(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=zl(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zl(e)?e:e+""}var tf=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),Zl(r=Ql(this,e),"url",void 0),Zl(r,"provider",void 0),r.url=r.providerUrl(t),r.provider=new Dc(r.url),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Yl(t,e)}(e,t),r=e,(n=[{key:"providerUrl",value:function(t){return(t=t.trim()).endsWith("/")?t.slice(0,-1):t.includes("api/v1/json-rpc")?t:"".concat(t,"/api/v1/json-rpc")}}])&&ql(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Wl);const ef=function(){if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if("undefined"!=typeof global)return global;throw new Error("unable to locate global object")}().WebSocket;class rf{#Pt;#Z;get filter(){return JSON.parse(this.#Z)}#he;#pe;#de;constructor(t,e){this.#Pt=t,this.#Z=JSON.stringify(e),this.#he=null,this.#pe=null,this.#de=null}start(){this.#he=this.#Pt.send("eth_subscribe",this.filter).then((t=>(this.#Pt._register(t,this),t)))}stop(){this.#he.then((t=>{this.#Pt.destroyed||this.#Pt.send("eth_unsubscribe",[t])})),this.#he=null}pause(t){it(t,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),this.#pe=!!t}resume(){this.#pe=null}_handleMessage(t){if(null!=this.#he&&null===this.#pe){let e=this.#de;e=null==e?this._emit(this.#Pt,t):e.then((async()=>{await this._emit(this.#Pt,t)})),this.#de=e.then((()=>{this.#de===e&&(this.#de=null)}))}}async _emit(t,e){throw new Error("sub-classes must implemente this; _emit")}}class nf extends rf{constructor(t){super(t,["newHeads"])}async _emit(t,e){t.emit("block",parseInt(e.number))}}class of extends rf{constructor(t){super(t,["newPendingTransactions"])}async _emit(t,e){t.emit("pending",e)}}class sf extends rf{#ye;get logFilter(){return JSON.parse(this.#ye)}constructor(t,e){super(t,["logs",e]),this.#ye=JSON.stringify(e)}async _emit(t,e){t.emit(this.logFilter,t._wrapLog(e,t._network))}}class af extends Cc{#ge;#Lt;#be;constructor(t,e){const r=Object.assign({},null!=e?e:{});ot(null==r.batchMaxCount||1===r.batchMaxCount,"sockets-based providers do not support batches","options.batchMaxCount",e),r.batchMaxCount=1,null==r.staticNetwork&&(r.staticNetwork=!0),super(t,r),this.#ge=new Map,this.#Lt=new Map,this.#be=new Map}_getSubscriber(t){switch(t.type){case"close":return new cc("close");case"block":return new nf(this);case"pending":return new of(this);case"event":return new sf(this,t.filter);case"orphan":if("drop-log"===t.filter.orphan)return new cc("drop-log")}return super._getSubscriber(t)}_register(t,e){this.#Lt.set(t,e);const r=this.#be.get(t);if(r){for(const t of r)e._handleMessage(t);this.#be.delete(t)}}async _send(t){ot(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const e=new Promise(((e,r)=>{this.#ge.set(t.id,{payload:t,resolve:e,reject:r})}));return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await e]}async _processMessage(t){const e=JSON.parse(t);if(e&&"object"==typeof e&&"id"in e){const t=this.#ge.get(e.id);if(null==t)return void this.emit("error",nt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:e}));this.#ge.delete(e.id),t.resolve(e)}else{if(!e||"eth_subscription"!==e.method)return void this.emit("error",nt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:e}));{const t=e.params.subscription,r=this.#Lt.get(t);if(r)r._handleMessage(e.params.result);else{let r=this.#be.get(t);null==r&&(r=[],this.#be.set(t,r)),r.push(e.params.result)}}}}async _write(t){throw new Error("sub-classes must override this")}}class uf extends af{#fe;#we;get websocket(){if(null==this.#we)throw new Error("websocket closed");return this.#we}constructor(t,e,r){super(e,r),"string"==typeof t?(this.#fe=()=>new ef(t),this.#we=this.#fe()):"function"==typeof t?(this.#fe=t,this.#we=t()):(this.#fe=null,this.#we=t),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(t){console.log("failed to start WebsocketProvider",t)}},this.websocket.onmessage=t=>{this._processMessage(t.data)}}async _write(t){this.websocket.send(t)}async destroy(){null!=this.#we&&(this.#we.close(),this.#we=null),super.destroy()}}function cf(t){return cf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},cf(t)}function lf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,gf(n.key),n)}}function ff(t,e,r){return e=pf(e),function(t,e){if(e&&("object"===cf(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}(t,hf()?Reflect.construct(e,r||[],pf(t).constructor):e.apply(t,r))}function hf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(hf=function(){return!!t})()}function pf(t){return pf=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},pf(t)}function df(t,e){return df=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},df(t,e)}function yf(t,e,r){return(e=gf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function gf(t){var e=function(t,e){if("object"!=cf(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=cf(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cf(e)?e:e+""}var bf,wf=function(t){function e(t){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,e),yf(r=ff(this,e),"wsUrl",void 0),yf(r,"provider",void 0),r.wsUrl=r.providerUrl(t),r.provider=new uf(r.wsUrl),r}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&df(t,e)}(e,t),r=e,(n=[{key:"providerUrl",value:function(t){return(t=t.trim()).endsWith("/")?t.slice(0,-1):t.includes("api/v1/json-rpc-ws")?t:"".concat(t,"/api/v1/json-rpc-ws")}}])&&lf(r.prototype,n),Object.defineProperty(r,"prototype",{writable:!1}),r;var r,n}(Wl);function mf(t){return mf="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},mf(t)}function vf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Ef(n.key),n)}}function Ef(t){var e=function(t,e){if("object"!=mf(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=mf(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mf(e)?e:e+""}!function(t){t.Function="function",t.Event="event"}(bf||(bf={}));var Af=function(){function t(e){var r,n,i;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r=this,i=void 0,(n=Ef(n="abi"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,this.verifyAbi(e),this.abi=e}return e=t,n=[{key:"from",value:function(e){return e instanceof t?e:new t(e)}}],(r=[{key:"hasFunction",value:function(t){return this.abi.some((function(e){return e.name===t&&"function"===e.type}))}},{key:"verifyAbi",value:function(t){if(0===t.length)throw new Error("The ABI provided is empty.");for(var e=0;e<t.length;e++){var r=t[e];if(!r.name)throw new Error("The ABI provided is missing a name.");if(!r.type)throw new Error("The ABI provided is missing a type.");r.inputs&&r.inputs.length&&this.verifyAbiValues(r.inputs),r.outputs&&r.outputs.length&&this.verifyAbiValues(r.outputs)}}},{key:"verifyAbiValues",value:function(t){for(var e=0;e<t.length;e++){var r=t[e];if(!r.name)throw new Error("The ABI provided is missing an input name.");if(!r.type)throw new Error("The ABI provided is missing an input type.")}}}])&&vf(e.prototype,r),n&&vf(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}(),Sf=i(8287).Buffer;function _f(t){return _f="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},_f(t)}function kf(t,e,r){return e=If(e),Tf(t,Pf()?Reflect.construct(e,r||[],If(t).constructor):e.apply(t,r))}function Tf(t,e){if(e&&("object"===_f(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return function(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}(t)}function Pf(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Pf=function(){return!!t})()}function If(t){return If=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},If(t)}function Of(t,e){return Of=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Of(t,e)}function xf(){xf=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},o="function"==typeof Symbol?Symbol:{},s=o.iterator||"@@iterator",a=o.asyncIterator||"@@asyncIterator",u=o.toStringTag||"@@toStringTag";function c(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{c({},"")}catch(t){c=function(t,e,r){return t[e]=r}}function l(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,s=Object.create(o.prototype),a=new x(n||[]);return i(s,"_invoke",{value:T(t,r,a)}),s}function f(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=l;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",g={};function b(){}function w(){}function m(){}var v={};c(v,s,(function(){return this}));var E=Object.getPrototypeOf,A=E&&E(E(B([])));A&&A!==r&&n.call(A,s)&&(v=A);var S=m.prototype=b.prototype=Object.create(v);function _(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function k(t,e){function r(i,o,s,a){var u=f(t[i],t,o);if("throw"!==u.type){var c=u.arg,l=c.value;return l&&"object"==_f(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,s,a)}),(function(t){r("throw",t,s,a)})):e.resolve(l).then((function(t){c.value=t,s(c)}),(function(t){return r("throw",t,s,a)}))}a(u.arg)}var o;i(this,"_invoke",{value:function(t,n){function i(){return new e((function(e,i){r(t,n,e,i)}))}return o=o?o.then(i,i):i()}})}function T(e,r,n){var i=h;return function(o,s){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw s;return{value:t,done:!0}}for(n.method=o,n.arg=s;;){var a=n.delegate;if(a){var u=P(a,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(i===h)throw i=y,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);i=d;var c=f(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===g)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function P(e,r){var n=r.method,i=e.iterator[n];if(i===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,P(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var o=f(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,g;var s=o.arg;return s?s.done?(r[e.resultName]=s.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):s:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function I(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function O(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function x(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(I,this),this.reset(!0)}function B(e){if(e||""===e){var r=e[s];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var i=-1,o=function r(){for(;++i<e.length;)if(n.call(e,i))return r.value=e[i],r.done=!1,r;return r.value=t,r.done=!0,r};return o.next=o}}throw new TypeError(_f(e)+" is not iterable")}return w.prototype=m,i(S,"constructor",{value:m,configurable:!0}),i(m,"constructor",{value:w,configurable:!0}),w.displayName=c(m,u,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,m):(t.__proto__=m,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},_(k.prototype),c(k.prototype,a,(function(){return this})),e.AsyncIterator=k,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var s=new k(l(t,r,n,i),o);return e.isGeneratorFunction(r)?s:s.next().then((function(t){return t.done?t.value:s.next()}))},_(S),c(S,u,"Generator"),c(S,s,(function(){return this})),c(S,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=B,x.prototype={constructor:x,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(O),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function i(n,i){return a.type="throw",a.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var s=this.tryEntries[o],a=s.completion;if("root"===s.tryLoc)return i("end");if(s.tryLoc<=this.prev){var u=n.call(s,"catchLoc"),c=n.call(s,"finallyLoc");if(u&&c){if(this.prev<s.catchLoc)return i(s.catchLoc,!0);if(this.prev<s.finallyLoc)return i(s.finallyLoc)}else if(u){if(this.prev<s.catchLoc)return i(s.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<s.finallyLoc)return i(s.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var i=this.tryEntries[r];if(i.tryLoc<=this.prev&&n.call(i,"finallyLoc")&&this.prev<i.finallyLoc){var o=i;break}}o&&("break"===t||"continue"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var s=o?o.completion:{};return s.type=t,s.arg=e,o?(this.method="next",this.next=o.finallyLoc,g):this.complete(s)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),O(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var i=n.arg;O(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:B(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function Bf(t,e,r,n,i,o,s){try{var a=t[o](s),u=a.value}catch(t){return void r(t)}a.done?e(u):Promise.resolve(u).then(n,i)}function Rf(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function s(t){Bf(o,n,i,s,a,"next",t)}function a(t){Bf(o,n,i,s,a,"throw",t)}s(void 0)}))}}function Nf(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=new Array(e);r<e;r++)n[r]=t[r];return n}function Uf(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function Cf(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,Mf(n.key),n)}}function Lf(t,e,r){return e&&Cf(t.prototype,e),r&&Cf(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Df(t,e,r){return(e=Mf(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mf(t){var e=function(t,e){if("object"!=_f(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=_f(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_f(e)?e:e+""}var Ff=Symbol.for("_btc_internal"),Hf=new class{constructor(){}decodeData(t,e){const r=new Vc(t),n=[];for(let t=0;t<e.length;t++)switch(e[t]){case Wc.UINT8:n.push(r.readU8());break;case Wc.UINT16:n.push(r.readU16());break;case Wc.UINT32:n.push(r.readU32());break;case Wc.BYTES32:n.push(r.readBytes(32));break;case Wc.BOOL:n.push(r.readBoolean());break;case Wc.ADDRESS:n.push(r.readAddress());break;case Wc.STRING:n.push(r.readStringWithLength());break;case Wc.UINT256:n.push(r.readU256());break;case Wc.TUPLE:n.push(r.readTuple())}return n}encodePointer(t){const e=this.sha256(t),r=qc.alloc(jc.EXPECTED_BUFFER_LENGTH),n=e.slice(0,jc.EXPECTED_BUFFER_LENGTH);for(let t=0;t<jc.EXPECTED_BUFFER_LENGTH;t++)r[t]=n[t];return BigInt("0x"+r.toString("hex"))}encodePointerHash(t,e){const r=new Uint8Array(jc.EXPECTED_BUFFER_LENGTH+2);r[0]=255&t,r[1]=t>>8&255;const n=this.bigIntToUint8Array(e,jc.EXPECTED_BUFFER_LENGTH);r.set(n,2);const i=this.sha256(r);if(i.byteLength!==jc.EXPECTED_BUFFER_LENGTH)throw new Error("Invalid hash length");return i}encodeSelector(t){return this.sha256(t).slice(0,4).toString("hex")}numericSelectorToHex(t){return t.toString(16)}bigIntToUint8Array(t,e){const r=new Uint8Array(e),n=jc.valueToUint8Array(t);for(let t=0;t<e;t++)r[t]=n[t]||0;return r}sha256(t){return(new zc.sha256).update(t).digest()}},jf=function(){return Lf((function t(e,r,n){Uf(this,t),Df(this,"address",void 0),Df(this,"interface",void 0),Df(this,"provider",void 0),Df(this,Ff,void 0),Df(this,"events",[]),this.address=e,this.provider=n,this.interface=Af.from(r),Object.defineProperty(this,Ff,{value:{}}),this.defineInternalFunctions()}),[{key:"getFunction",value:function(t){return this[t]}},{key:"defineInternalFunctions",value:function(){var t,e=function(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=function(t,e){if(t){if("string"==typeof t)return Nf(t,e);var r=Object.prototype.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?Nf(t,e):void 0}}(t))||e&&t&&"number"==typeof t.length){r&&(t=r);var n=0,i=function(){};return{s:i,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:i}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,s=!0,a=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return s=t.done,t},e:function(t){a=!0,o=t},f:function(){try{s||null==r.return||r.return()}finally{if(a)throw o}}}}(this.interface.abi);try{for(e.s();!(t=e.n()).done;){var r=t.value;switch(r.type){case bf.Function:Object.defineProperty(this,r.name,{value:this.callFunction(r).bind(this)});break;case bf.Event:this.events.push(r)}}}catch(t){e.e(t)}finally{e.f()}}},{key:"encodeFunctionData",value:function(t,e){var r,n,i=new Kc,o=Number("0x"+Hf.encodeSelector(t.name));if(i.writeSelector(o),e.length!==(null!==(r=null===(n=t.inputs)||void 0===n?void 0:n.length)&&void 0!==r?r:0))throw new Error("Invalid number of arguments provided");if(!t.inputs||t.inputs&&0===t.inputs.length)return i;for(var s=0;s<t.inputs.length;s++)this.encodeInput(i,t.inputs[s],e[s]);return i}},{key:"encodeInput",value:function(t,e,r){var n=e.type,i=e.name;switch(n){case Wc.UINT256:if("bigint"!=typeof r)throw new Error("Expected value to be of type bigint (".concat(i,")"));t.writeU256(r);break;case Wc.BOOL:if("boolean"!=typeof r)throw new Error("Expected value to be of type boolean (".concat(i,")"));t.writeBoolean(r);break;case Wc.STRING:if("string"!=typeof r)throw new Error("Expected value to be of type string (".concat(i,")"));t.writeStringWithLength(r);break;case Wc.ADDRESS:var o=r;t.writeAddress(o.toString());break;case Wc.TUPLE:if(!(r instanceof Array))throw new Error("Expected value to be of type Array (".concat(i,")"));t.writeTuple(r);break;case Wc.UINT8:if("number"!=typeof r)throw new Error("Expected value to be of type number (".concat(i,")"));t.writeU8(r);break;case Wc.UINT16:if("number"!=typeof r)throw new Error("Expected value to be of type number (".concat(i,")"));t.writeU16(r);break;case Wc.UINT32:if("number"!=typeof r)throw new Error("Expected value to be of type number (".concat(i,")"));t.writeU32(r);break;case Wc.BYTES32:if(!(r instanceof Uint8Array))throw new Error("Expected value to be of type Uint8Array (".concat(i,")"));t.writeBytes(r);break;default:throw new Error("Unsupported type: ".concat(n," (").concat(i,")"))}}},{key:"decodeOutput",value:function(t,e){for(var r=[],n=0;n<t.length;n++){var i=t[n].type,o=t[n].name;switch(i){case Wc.UINT256:r.push(e.readU256());break;case Wc.BOOL:r.push(e.readBoolean());break;case Wc.STRING:r.push(e.readStringWithLength());break;case Wc.ADDRESS:r.push(e.readAddress());break;case Wc.TUPLE:r.push(e.readTuple());break;case Wc.UINT8:r.push(e.readU8());break;case Wc.UINT16:r.push(e.readU16());break;case Wc.UINT32:r.push(e.readU32());break;case Wc.BYTES32:r.push(e.readBytes(32));break;default:throw new Error("Unsupported type: ".concat(i," (").concat(o,")"))}}return r}},{key:"callFunction",value:function(t){var e=this;return Rf(xf().mark((function r(){var n,i,o,s,a,u,c=arguments;return xf().wrap((function(r){for(;;)switch(r.prev=r.next){case 0:for(n=c.length,i=new Array(n),o=0;o<n;o++)i[o]=c[o];return s=e.encodeFunctionData(t,i),r.next=4,e.provider.call(e.address,Sf.from(s.getBuffer()));case 4:if(!("error"in(a=r.sent))){r.next=7;break}return r.abrupt("return",a);case 7:return u=t.outputs?e.decodeOutput(t.outputs,a.result):[],a.setDecoded(u),r.abrupt("return",a);case 10:case"end":return r.stop()}}),r)})))}}])}(),Gf=function(t){function e(t,r,n){var i;return Uf(this,e),Tf(i=kf(this,e,[t,r,n]),i.proxify())}return function(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&Of(t,e)}(e,t),Lf(e,[{key:"proxify",value:function(){var t=this;return new Proxy(this,{get:function(e,r,n){if("symbol"===_f(r)||r in e)return Reflect.get(e,r,n);try{return t.getFunction(r)}catch(t){throw t instanceof Error?t:new Error("Something went wrong when trying to get the function: ".concat(t))}},has:function(t,e){return"symbol"===_f(e)||e in t?Reflect.has(t,e):t.interface.hasFunction(e)}})}}])}(jf);function Vf(t,e,r){return new Gf(t,e,r)}var Kf=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,Wf=Math.ceil,zf=Math.floor,qf="[BigNumber Error] ",Qf=qf+"Number primitive has more than 15 significant digits: ",Jf=1e14,Xf=14,Yf=9007199254740991,Zf=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],$f=1e7,th=1e9;function eh(t){var e=0|t;return t>0||t===e?e:e-1}function rh(t){for(var e,r,n=1,i=t.length,o=t[0]+"";n<i;){for(e=t[n++]+"",r=Xf-e.length;r--;e="0"+e);o+=e}for(i=o.length;48===o.charCodeAt(--i););return o.slice(0,i+1||1)}function nh(t,e){var r,n,i=t.c,o=e.c,s=t.s,a=e.s,u=t.e,c=e.e;if(!s||!a)return null;if(r=i&&!i[0],n=o&&!o[0],r||n)return r?n?0:-a:s;if(s!=a)return s;if(r=s<0,n=u==c,!i||!o)return n?0:!i^r?1:-1;if(!n)return u>c^r?1:-1;for(a=(u=i.length)<(c=o.length)?u:c,s=0;s<a;s++)if(i[s]!=o[s])return i[s]>o[s]^r?1:-1;return u==c?0:u>c^r?1:-1}function ih(t,e,r,n){if(t<e||t>r||t!==zf(t))throw Error(qf+(n||"Argument")+("number"==typeof t?t<e||t>r?" out of range: ":" not an integer: ":" not a primitive number: ")+String(t))}function oh(t){var e=t.c.length-1;return eh(t.e/Xf)==e&&t.c[e]%2!=0}function sh(t,e){return(t.length>1?t.charAt(0)+"."+t.slice(1):t)+(e<0?"e":"e+")+e}function ah(t,e,r){var n,i;if(e<0){for(i=r+".";++e;i+=r);t=i+t}else if(++e>(n=t.length)){for(i=r,e-=n;--e;i+=r);t+=i}else e<n&&(t=t.slice(0,e)+"."+t.slice(e));return t}var uh=function t(e){var r,n,i,o,s,a,u,c,l,f,h=T.prototype={constructor:T,toString:null,valueOf:null},p=new T(1),d=20,y=4,g=-7,b=21,w=-1e7,m=1e7,v=!1,E=1,A=0,S={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:" ",suffix:""},_="0123456789abcdefghijklmnopqrstuvwxyz",k=!0;function T(t,e){var r,o,s,a,u,c,l,f,h=this;if(!(h instanceof T))return new T(t,e);if(null==e){if(t&&!0===t._isBigNumber)return h.s=t.s,void(!t.c||t.e>m?h.c=h.e=null:t.e<w?h.c=[h.e=0]:(h.e=t.e,h.c=t.c.slice()));if((c="number"==typeof t)&&0*t==0){if(h.s=1/t<0?(t=-t,-1):1,t===~~t){for(a=0,u=t;u>=10;u/=10,a++);return void(a>m?h.c=h.e=null:(h.e=a,h.c=[t]))}f=String(t)}else{if(!Kf.test(f=String(t)))return i(h,f,c);h.s=45==f.charCodeAt(0)?(f=f.slice(1),-1):1}(a=f.indexOf("."))>-1&&(f=f.replace(".","")),(u=f.search(/e/i))>0?(a<0&&(a=u),a+=+f.slice(u+1),f=f.substring(0,u)):a<0&&(a=f.length)}else{if(ih(e,2,_.length,"Base"),10==e&&k)return x(h=new T(t),d+h.e+1,y);if(f=String(t),c="number"==typeof t){if(0*t!=0)return i(h,f,c,e);if(h.s=1/t<0?(f=f.slice(1),-1):1,T.DEBUG&&f.replace(/^0\.0*|\./,"").length>15)throw Error(Qf+t)}else h.s=45===f.charCodeAt(0)?(f=f.slice(1),-1):1;for(r=_.slice(0,e),a=u=0,l=f.length;u<l;u++)if(r.indexOf(o=f.charAt(u))<0){if("."==o){if(u>a){a=l;continue}}else if(!s&&(f==f.toUpperCase()&&(f=f.toLowerCase())||f==f.toLowerCase()&&(f=f.toUpperCase()))){s=!0,u=-1,a=0;continue}return i(h,String(t),c,e)}c=!1,(a=(f=n(f,e,10,h.s)).indexOf("."))>-1?f=f.replace(".",""):a=f.length}for(u=0;48===f.charCodeAt(u);u++);for(l=f.length;48===f.charCodeAt(--l););if(f=f.slice(u,++l)){if(l-=u,c&&T.DEBUG&&l>15&&(t>Yf||t!==zf(t)))throw Error(Qf+h.s*t);if((a=a-u-1)>m)h.c=h.e=null;else if(a<w)h.c=[h.e=0];else{if(h.e=a,h.c=[],u=(a+1)%Xf,a<0&&(u+=Xf),u<l){for(u&&h.c.push(+f.slice(0,u)),l-=Xf;u<l;)h.c.push(+f.slice(u,u+=Xf));u=Xf-(f=f.slice(u)).length}else u-=l;for(;u--;f+="0");h.c.push(+f)}}else h.c=[h.e=0]}function P(t,e,r,n){var i,o,s,a,u;if(null==r?r=y:ih(r,0,8),!t.c)return t.toString();if(i=t.c[0],s=t.e,null==e)u=rh(t.c),u=1==n||2==n&&(s<=g||s>=b)?sh(u,s):ah(u,s,"0");else if(o=(t=x(new T(t),e,r)).e,a=(u=rh(t.c)).length,1==n||2==n&&(e<=o||o<=g)){for(;a<e;u+="0",a++);u=sh(u,o)}else if(e-=s,u=ah(u,o,"0"),o+1>a){if(--e>0)for(u+=".";e--;u+="0");}else if((e+=o-a)>0)for(o+1==a&&(u+=".");e--;u+="0");return t.s<0&&i?"-"+u:u}function I(t,e){for(var r,n,i=1,o=new T(t[0]);i<t.length;i++)(!(n=new T(t[i])).s||(r=nh(o,n))===e||0===r&&o.s===e)&&(o=n);return o}function O(t,e,r){for(var n=1,i=e.length;!e[--i];e.pop());for(i=e[0];i>=10;i/=10,n++);return(r=n+r*Xf-1)>m?t.c=t.e=null:r<w?t.c=[t.e=0]:(t.e=r,t.c=e),t}function x(t,e,r,n){var i,o,s,a,u,c,l,f=t.c,h=Zf;if(f){t:{for(i=1,a=f[0];a>=10;a/=10,i++);if((o=e-i)<0)o+=Xf,s=e,u=f[c=0],l=zf(u/h[i-s-1]%10);else if((c=Wf((o+1)/Xf))>=f.length){if(!n)break t;for(;f.length<=c;f.push(0));u=l=0,i=1,s=(o%=Xf)-Xf+1}else{for(u=a=f[c],i=1;a>=10;a/=10,i++);l=(s=(o%=Xf)-Xf+i)<0?0:zf(u/h[i-s-1]%10)}if(n=n||e<0||null!=f[c+1]||(s<0?u:u%h[i-s-1]),n=r<4?(l||n)&&(0==r||r==(t.s<0?3:2)):l>5||5==l&&(4==r||n||6==r&&(o>0?s>0?u/h[i-s]:0:f[c-1])%10&1||r==(t.s<0?8:7)),e<1||!f[0])return f.length=0,n?(e-=t.e+1,f[0]=h[(Xf-e%Xf)%Xf],t.e=-e||0):f[0]=t.e=0,t;if(0==o?(f.length=c,a=1,c--):(f.length=c+1,a=h[Xf-o],f[c]=s>0?zf(u/h[i-s]%h[s])*a:0),n)for(;;){if(0==c){for(o=1,s=f[0];s>=10;s/=10,o++);for(s=f[0]+=a,a=1;s>=10;s/=10,a++);o!=a&&(t.e++,f[0]==Jf&&(f[0]=1));break}if(f[c]+=a,f[c]!=Jf)break;f[c--]=0,a=1}for(o=f.length;0===f[--o];f.pop());}t.e>m?t.c=t.e=null:t.e<w&&(t.c=[t.e=0])}return t}function B(t){var e,r=t.e;return null===r?t.toString():(e=rh(t.c),e=r<=g||r>=b?sh(e,r):ah(e,r,"0"),t.s<0?"-"+e:e)}return T.clone=t,T.ROUND_UP=0,T.ROUND_DOWN=1,T.ROUND_CEIL=2,T.ROUND_FLOOR=3,T.ROUND_HALF_UP=4,T.ROUND_HALF_DOWN=5,T.ROUND_HALF_EVEN=6,T.ROUND_HALF_CEIL=7,T.ROUND_HALF_FLOOR=8,T.EUCLID=9,T.config=T.set=function(t){var e,r;if(null!=t){if("object"!=typeof t)throw Error(qf+"Object expected: "+t);if(t.hasOwnProperty(e="DECIMAL_PLACES")&&(ih(r=t[e],0,th,e),d=r),t.hasOwnProperty(e="ROUNDING_MODE")&&(ih(r=t[e],0,8,e),y=r),t.hasOwnProperty(e="EXPONENTIAL_AT")&&((r=t[e])&&r.pop?(ih(r[0],-th,0,e),ih(r[1],0,th,e),g=r[0],b=r[1]):(ih(r,-th,th,e),g=-(b=r<0?-r:r))),t.hasOwnProperty(e="RANGE"))if((r=t[e])&&r.pop)ih(r[0],-th,-1,e),ih(r[1],1,th,e),w=r[0],m=r[1];else{if(ih(r,-th,th,e),!r)throw Error(qf+e+" cannot be zero: "+r);w=-(m=r<0?-r:r)}if(t.hasOwnProperty(e="CRYPTO")){if((r=t[e])!==!!r)throw Error(qf+e+" not true or false: "+r);if(r){if("undefined"==typeof crypto||!crypto||!crypto.getRandomValues&&!crypto.randomBytes)throw v=!r,Error(qf+"crypto unavailable");v=r}else v=r}if(t.hasOwnProperty(e="MODULO_MODE")&&(ih(r=t[e],0,9,e),E=r),t.hasOwnProperty(e="POW_PRECISION")&&(ih(r=t[e],0,th,e),A=r),t.hasOwnProperty(e="FORMAT")){if("object"!=typeof(r=t[e]))throw Error(qf+e+" not an object: "+r);S=r}if(t.hasOwnProperty(e="ALPHABET")){if("string"!=typeof(r=t[e])||/^.?$|[+\-.\s]|(.).*\1/.test(r))throw Error(qf+e+" invalid: "+r);k="0123456789"==r.slice(0,10),_=r}}return{DECIMAL_PLACES:d,ROUNDING_MODE:y,EXPONENTIAL_AT:[g,b],RANGE:[w,m],CRYPTO:v,MODULO_MODE:E,POW_PRECISION:A,FORMAT:S,ALPHABET:_}},T.isBigNumber=function(t){if(!t||!0!==t._isBigNumber)return!1;if(!T.DEBUG)return!0;var e,r,n=t.c,i=t.e,o=t.s;t:if("[object Array]"=={}.toString.call(n)){if((1===o||-1===o)&&i>=-th&&i<=th&&i===zf(i)){if(0===n[0]){if(0===i&&1===n.length)return!0;break t}if((e=(i+1)%Xf)<1&&(e+=Xf),String(n[0]).length==e){for(e=0;e<n.length;e++)if((r=n[e])<0||r>=Jf||r!==zf(r))break t;if(0!==r)return!0}}}else if(null===n&&null===i&&(null===o||1===o||-1===o))return!0;throw Error(qf+"Invalid BigNumber: "+t)},T.maximum=T.max=function(){return I(arguments,-1)},T.minimum=T.min=function(){return I(arguments,1)},T.random=(o=9007199254740992,s=Math.random()*o&2097151?function(){return zf(Math.random()*o)}:function(){return 8388608*(1073741824*Math.random()|0)+(8388608*Math.random()|0)},function(t){var e,r,n,i,o,a=0,u=[],c=new T(p);if(null==t?t=d:ih(t,0,th),i=Wf(t/Xf),v)if(crypto.getRandomValues){for(e=crypto.getRandomValues(new Uint32Array(i*=2));a<i;)(o=131072*e[a]+(e[a+1]>>>11))>=9e15?(r=crypto.getRandomValues(new Uint32Array(2)),e[a]=r[0],e[a+1]=r[1]):(u.push(o%1e14),a+=2);a=i/2}else{if(!crypto.randomBytes)throw v=!1,Error(qf+"crypto unavailable");for(e=crypto.randomBytes(i*=7);a<i;)(o=281474976710656*(31&e[a])+1099511627776*e[a+1]+4294967296*e[a+2]+16777216*e[a+3]+(e[a+4]<<16)+(e[a+5]<<8)+e[a+6])>=9e15?crypto.randomBytes(7).copy(e,a):(u.push(o%1e14),a+=7);a=i/7}if(!v)for(;a<i;)(o=s())<9e15&&(u[a++]=o%1e14);for(i=u[--a],t%=Xf,i&&t&&(o=Zf[Xf-t],u[a]=zf(i/o)*o);0===u[a];u.pop(),a--);if(a<0)u=[n=0];else{for(n=-1;0===u[0];u.splice(0,1),n-=Xf);for(a=1,o=u[0];o>=10;o/=10,a++);a<Xf&&(n-=Xf-a)}return c.e=n,c.c=u,c}),T.sum=function(){for(var t=1,e=arguments,r=new T(e[0]);t<e.length;)r=r.plus(e[t++]);return r},n=function(){var t="0123456789";function e(t,e,r,n){for(var i,o,s=[0],a=0,u=t.length;a<u;){for(o=s.length;o--;s[o]*=e);for(s[0]+=n.indexOf(t.charAt(a++)),i=0;i<s.length;i++)s[i]>r-1&&(null==s[i+1]&&(s[i+1]=0),s[i+1]+=s[i]/r|0,s[i]%=r)}return s.reverse()}return function(n,i,o,s,a){var u,c,l,f,h,p,g,b,w=n.indexOf("."),m=d,v=y;for(w>=0&&(f=A,A=0,n=n.replace(".",""),p=(b=new T(i)).pow(n.length-w),A=f,b.c=e(ah(rh(p.c),p.e,"0"),10,o,t),b.e=b.c.length),l=f=(g=e(n,i,o,a?(u=_,t):(u=t,_))).length;0==g[--f];g.pop());if(!g[0])return u.charAt(0);if(w<0?--l:(p.c=g,p.e=l,p.s=s,g=(p=r(p,b,m,v,o)).c,h=p.r,l=p.e),w=g[c=l+m+1],f=o/2,h=h||c<0||null!=g[c+1],h=v<4?(null!=w||h)&&(0==v||v==(p.s<0?3:2)):w>f||w==f&&(4==v||h||6==v&&1&g[c-1]||v==(p.s<0?8:7)),c<1||!g[0])n=h?ah(u.charAt(1),-m,u.charAt(0)):u.charAt(0);else{if(g.length=c,h)for(--o;++g[--c]>o;)g[c]=0,c||(++l,g=[1].concat(g));for(f=g.length;!g[--f];);for(w=0,n="";w<=f;n+=u.charAt(g[w++]));n=ah(n,l,u.charAt(0))}return n}}(),r=function(){function t(t,e,r){var n,i,o,s,a=0,u=t.length,c=e%$f,l=e/$f|0;for(t=t.slice();u--;)a=((i=c*(o=t[u]%$f)+(n=l*o+(s=t[u]/$f|0)*c)%$f*$f+a)/r|0)+(n/$f|0)+l*s,t[u]=i%r;return a&&(t=[a].concat(t)),t}function e(t,e,r,n){var i,o;if(r!=n)o=r>n?1:-1;else for(i=o=0;i<r;i++)if(t[i]!=e[i]){o=t[i]>e[i]?1:-1;break}return o}function r(t,e,r,n){for(var i=0;r--;)t[r]-=i,i=t[r]<e[r]?1:0,t[r]=i*n+t[r]-e[r];for(;!t[0]&&t.length>1;t.splice(0,1));}return function(n,i,o,s,a){var u,c,l,f,h,p,d,y,g,b,w,m,v,E,A,S,_,k=n.s==i.s?1:-1,P=n.c,I=i.c;if(!(P&&P[0]&&I&&I[0]))return new T(n.s&&i.s&&(P?!I||P[0]!=I[0]:I)?P&&0==P[0]||!I?0*k:k/0:NaN);for(g=(y=new T(k)).c=[],k=o+(c=n.e-i.e)+1,a||(a=Jf,c=eh(n.e/Xf)-eh(i.e/Xf),k=k/Xf|0),l=0;I[l]==(P[l]||0);l++);if(I[l]>(P[l]||0)&&c--,k<0)g.push(1),f=!0;else{for(E=P.length,S=I.length,l=0,k+=2,(h=zf(a/(I[0]+1)))>1&&(I=t(I,h,a),P=t(P,h,a),S=I.length,E=P.length),v=S,w=(b=P.slice(0,S)).length;w<S;b[w++]=0);_=I.slice(),_=[0].concat(_),A=I[0],I[1]>=a/2&&A++;do{if(h=0,(u=e(I,b,S,w))<0){if(m=b[0],S!=w&&(m=m*a+(b[1]||0)),(h=zf(m/A))>1)for(h>=a&&(h=a-1),d=(p=t(I,h,a)).length,w=b.length;1==e(p,b,d,w);)h--,r(p,S<d?_:I,d,a),d=p.length,u=1;else 0==h&&(u=h=1),d=(p=I.slice()).length;if(d<w&&(p=[0].concat(p)),r(b,p,w,a),w=b.length,-1==u)for(;e(I,b,S,w)<1;)h++,r(b,S<w?_:I,w,a),w=b.length}else 0===u&&(h++,b=[0]);g[l++]=h,b[0]?b[w++]=P[v]||0:(b=[P[v]],w=1)}while((v++<E||null!=b[0])&&k--);f=null!=b[0],g[0]||g.splice(0,1)}if(a==Jf){for(l=1,k=g[0];k>=10;k/=10,l++);x(y,o+(y.e=l+c*Xf-1)+1,s,f)}else y.e=c,y.r=+f;return y}}(),a=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,c=/^\.([^.]+)$/,l=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g,i=function(t,e,r,n){var i,o=r?e:e.replace(f,"");if(l.test(o))t.s=isNaN(o)?null:o<0?-1:1;else{if(!r&&(o=o.replace(a,(function(t,e,r){return i="x"==(r=r.toLowerCase())?16:"b"==r?2:8,n&&n!=i?t:e})),n&&(i=n,o=o.replace(u,"$1").replace(c,"0.$1")),e!=o))return new T(o,i);if(T.DEBUG)throw Error(qf+"Not a"+(n?" base "+n:"")+" number: "+e);t.s=null}t.c=t.e=null},h.absoluteValue=h.abs=function(){var t=new T(this);return t.s<0&&(t.s=1),t},h.comparedTo=function(t,e){return nh(this,new T(t,e))},h.decimalPlaces=h.dp=function(t,e){var r,n,i,o=this;if(null!=t)return ih(t,0,th),null==e?e=y:ih(e,0,8),x(new T(o),t+o.e+1,e);if(!(r=o.c))return null;if(n=((i=r.length-1)-eh(this.e/Xf))*Xf,i=r[i])for(;i%10==0;i/=10,n--);return n<0&&(n=0),n},h.dividedBy=h.div=function(t,e){return r(this,new T(t,e),d,y)},h.dividedToIntegerBy=h.idiv=function(t,e){return r(this,new T(t,e),0,1)},h.exponentiatedBy=h.pow=function(t,e){var r,n,i,o,s,a,u,c,l=this;if((t=new T(t)).c&&!t.isInteger())throw Error(qf+"Exponent not an integer: "+B(t));if(null!=e&&(e=new T(e)),s=t.e>14,!l.c||!l.c[0]||1==l.c[0]&&!l.e&&1==l.c.length||!t.c||!t.c[0])return c=new T(Math.pow(+B(l),s?t.s*(2-oh(t)):+B(t))),e?c.mod(e):c;if(a=t.s<0,e){if(e.c?!e.c[0]:!e.s)return new T(NaN);(n=!a&&l.isInteger()&&e.isInteger())&&(l=l.mod(e))}else{if(t.e>9&&(l.e>0||l.e<-1||(0==l.e?l.c[0]>1||s&&l.c[1]>=24e7:l.c[0]<8e13||s&&l.c[0]<=9999975e7)))return o=l.s<0&&oh(t)?-0:0,l.e>-1&&(o=1/o),new T(a?1/o:o);A&&(o=Wf(A/Xf+2))}for(s?(r=new T(.5),a&&(t.s=1),u=oh(t)):u=(i=Math.abs(+B(t)))%2,c=new T(p);;){if(u){if(!(c=c.times(l)).c)break;o?c.c.length>o&&(c.c.length=o):n&&(c=c.mod(e))}if(i){if(0===(i=zf(i/2)))break;u=i%2}else if(x(t=t.times(r),t.e+1,1),t.e>14)u=oh(t);else{if(0==(i=+B(t)))break;u=i%2}l=l.times(l),o?l.c&&l.c.length>o&&(l.c.length=o):n&&(l=l.mod(e))}return n?c:(a&&(c=p.div(c)),e?c.mod(e):o?x(c,A,y,void 0):c)},h.integerValue=function(t){var e=new T(this);return null==t?t=y:ih(t,0,8),x(e,e.e+1,t)},h.isEqualTo=h.eq=function(t,e){return 0===nh(this,new T(t,e))},h.isFinite=function(){return!!this.c},h.isGreaterThan=h.gt=function(t,e){return nh(this,new T(t,e))>0},h.isGreaterThanOrEqualTo=h.gte=function(t,e){return 1===(e=nh(this,new T(t,e)))||0===e},h.isInteger=function(){return!!this.c&&eh(this.e/Xf)>this.c.length-2},h.isLessThan=h.lt=function(t,e){return nh(this,new T(t,e))<0},h.isLessThanOrEqualTo=h.lte=function(t,e){return-1===(e=nh(this,new T(t,e)))||0===e},h.isNaN=function(){return!this.s},h.isNegative=function(){return this.s<0},h.isPositive=function(){return this.s>0},h.isZero=function(){return!!this.c&&0==this.c[0]},h.minus=function(t,e){var r,n,i,o,s=this,a=s.s;if(e=(t=new T(t,e)).s,!a||!e)return new T(NaN);if(a!=e)return t.s=-e,s.plus(t);var u=s.e/Xf,c=t.e/Xf,l=s.c,f=t.c;if(!u||!c){if(!l||!f)return l?(t.s=-e,t):new T(f?s:NaN);if(!l[0]||!f[0])return f[0]?(t.s=-e,t):new T(l[0]?s:3==y?-0:0)}if(u=eh(u),c=eh(c),l=l.slice(),a=u-c){for((o=a<0)?(a=-a,i=l):(c=u,i=f),i.reverse(),e=a;e--;i.push(0));i.reverse()}else for(n=(o=(a=l.length)<(e=f.length))?a:e,a=e=0;e<n;e++)if(l[e]!=f[e]){o=l[e]<f[e];break}if(o&&(i=l,l=f,f=i,t.s=-t.s),(e=(n=f.length)-(r=l.length))>0)for(;e--;l[r++]=0);for(e=Jf-1;n>a;){if(l[--n]<f[n]){for(r=n;r&&!l[--r];l[r]=e);--l[r],l[n]+=Jf}l[n]-=f[n]}for(;0==l[0];l.splice(0,1),--c);return l[0]?O(t,l,c):(t.s=3==y?-1:1,t.c=[t.e=0],t)},h.modulo=h.mod=function(t,e){var n,i,o=this;return t=new T(t,e),!o.c||!t.s||t.c&&!t.c[0]?new T(NaN):!t.c||o.c&&!o.c[0]?new T(o):(9==E?(i=t.s,t.s=1,n=r(o,t,0,3),t.s=i,n.s*=i):n=r(o,t,0,E),(t=o.minus(n.times(t))).c[0]||1!=E||(t.s=o.s),t)},h.multipliedBy=h.times=function(t,e){var r,n,i,o,s,a,u,c,l,f,h,p,d,y,g,b=this,w=b.c,m=(t=new T(t,e)).c;if(!(w&&m&&w[0]&&m[0]))return!b.s||!t.s||w&&!w[0]&&!m||m&&!m[0]&&!w?t.c=t.e=t.s=null:(t.s*=b.s,w&&m?(t.c=[0],t.e=0):t.c=t.e=null),t;for(n=eh(b.e/Xf)+eh(t.e/Xf),t.s*=b.s,(u=w.length)<(f=m.length)&&(d=w,w=m,m=d,i=u,u=f,f=i),i=u+f,d=[];i--;d.push(0));for(y=Jf,g=$f,i=f;--i>=0;){for(r=0,h=m[i]%g,p=m[i]/g|0,o=i+(s=u);o>i;)r=((c=h*(c=w[--s]%g)+(a=p*c+(l=w[s]/g|0)*h)%g*g+d[o]+r)/y|0)+(a/g|0)+p*l,d[o--]=c%y;d[o]=r}return r?++n:d.splice(0,1),O(t,d,n)},h.negated=function(){var t=new T(this);return t.s=-t.s||null,t},h.plus=function(t,e){var r,n=this,i=n.s;if(e=(t=new T(t,e)).s,!i||!e)return new T(NaN);if(i!=e)return t.s=-e,n.minus(t);var o=n.e/Xf,s=t.e/Xf,a=n.c,u=t.c;if(!o||!s){if(!a||!u)return new T(i/0);if(!a[0]||!u[0])return u[0]?t:new T(a[0]?n:0*i)}if(o=eh(o),s=eh(s),a=a.slice(),i=o-s){for(i>0?(s=o,r=u):(i=-i,r=a),r.reverse();i--;r.push(0));r.reverse()}for((i=a.length)-(e=u.length)<0&&(r=u,u=a,a=r,e=i),i=0;e;)i=(a[--e]=a[e]+u[e]+i)/Jf|0,a[e]=Jf===a[e]?0:a[e]%Jf;return i&&(a=[i].concat(a),++s),O(t,a,s)},h.precision=h.sd=function(t,e){var r,n,i,o=this;if(null!=t&&t!==!!t)return ih(t,1,th),null==e?e=y:ih(e,0,8),x(new T(o),t,e);if(!(r=o.c))return null;if(n=(i=r.length-1)*Xf+1,i=r[i]){for(;i%10==0;i/=10,n--);for(i=r[0];i>=10;i/=10,n++);}return t&&o.e+1>n&&(n=o.e+1),n},h.shiftedBy=function(t){return ih(t,-9007199254740991,Yf),this.times("1e"+t)},h.squareRoot=h.sqrt=function(){var t,e,n,i,o,s=this,a=s.c,u=s.s,c=s.e,l=d+4,f=new T("0.5");if(1!==u||!a||!a[0])return new T(!u||u<0&&(!a||a[0])?NaN:a?s:1/0);if(0==(u=Math.sqrt(+B(s)))||u==1/0?(((e=rh(a)).length+c)%2==0&&(e+="0"),u=Math.sqrt(+e),c=eh((c+1)/2)-(c<0||c%2),n=new T(e=u==1/0?"5e"+c:(e=u.toExponential()).slice(0,e.indexOf("e")+1)+c)):n=new T(u+""),n.c[0])for((u=(c=n.e)+l)<3&&(u=0);;)if(o=n,n=f.times(o.plus(r(s,o,l,1))),rh(o.c).slice(0,u)===(e=rh(n.c)).slice(0,u)){if(n.e<c&&--u,"9999"!=(e=e.slice(u-3,u+1))&&(i||"4999"!=e)){+e&&(+e.slice(1)||"5"!=e.charAt(0))||(x(n,n.e+d+2,1),t=!n.times(n).eq(s));break}if(!i&&(x(o,o.e+d+2,0),o.times(o).eq(s))){n=o;break}l+=4,u+=4,i=1}return x(n,n.e+d+1,y,t)},h.toExponential=function(t,e){return null!=t&&(ih(t,0,th),t++),P(this,t,e,1)},h.toFixed=function(t,e){return null!=t&&(ih(t,0,th),t=t+this.e+1),P(this,t,e)},h.toFormat=function(t,e,r){var n,i=this;if(null==r)null!=t&&e&&"object"==typeof e?(r=e,e=null):t&&"object"==typeof t?(r=t,t=e=null):r=S;else if("object"!=typeof r)throw Error(qf+"Argument not an object: "+r);if(n=i.toFixed(t,e),i.c){var o,s=n.split("."),a=+r.groupSize,u=+r.secondaryGroupSize,c=r.groupSeparator||"",l=s[0],f=s[1],h=i.s<0,p=h?l.slice(1):l,d=p.length;if(u&&(o=a,a=u,u=o,d-=o),a>0&&d>0){for(o=d%a||a,l=p.substr(0,o);o<d;o+=a)l+=c+p.substr(o,a);u>0&&(l+=c+p.slice(o)),h&&(l="-"+l)}n=f?l+(r.decimalSeparator||"")+((u=+r.fractionGroupSize)?f.replace(new RegExp("\\d{"+u+"}\\B","g"),"$&"+(r.fractionGroupSeparator||"")):f):l}return(r.prefix||"")+n+(r.suffix||"")},h.toFraction=function(t){var e,n,i,o,s,a,u,c,l,f,h,d,g=this,b=g.c;if(null!=t&&(!(u=new T(t)).isInteger()&&(u.c||1!==u.s)||u.lt(p)))throw Error(qf+"Argument "+(u.isInteger()?"out of range: ":"not an integer: ")+B(u));if(!b)return new T(g);for(e=new T(p),l=n=new T(p),i=c=new T(p),d=rh(b),s=e.e=d.length-g.e-1,e.c[0]=Zf[(a=s%Xf)<0?Xf+a:a],t=!t||u.comparedTo(e)>0?s>0?e:l:u,a=m,m=1/0,u=new T(d),c.c[0]=0;f=r(u,e,0,1),1!=(o=n.plus(f.times(i))).comparedTo(t);)n=i,i=o,l=c.plus(f.times(o=l)),c=o,e=u.minus(f.times(o=e)),u=o;return o=r(t.minus(n),i,0,1),c=c.plus(o.times(l)),n=n.plus(o.times(i)),c.s=l.s=g.s,h=r(l,i,s*=2,y).minus(g).abs().comparedTo(r(c,n,s,y).minus(g).abs())<1?[l,i]:[c,n],m=a,h},h.toNumber=function(){return+B(this)},h.toPrecision=function(t,e){return null!=t&&ih(t,1,th),P(this,t,e,2)},h.toString=function(t){var e,r=this,i=r.s,o=r.e;return null===o?i?(e="Infinity",i<0&&(e="-"+e)):e="NaN":(null==t?e=o<=g||o>=b?sh(rh(r.c),o):ah(rh(r.c),o,"0"):10===t&&k?e=ah(rh((r=x(new T(r),d+o+1,y)).c),r.e,"0"):(ih(t,2,_.length,"Base"),e=n(ah(rh(r.c),o,"0"),10,t,i,!0)),i<0&&r.c[0]&&(e="-"+e)),e},h.valueOf=h.toJSON=function(){return B(this)},h._isBigNumber=!0,h[Symbol.toStringTag]="BigNumber",h[Symbol.for("nodejs.util.inspect.custom")]=h.valueOf,null!=e&&T.set(e),T}();const ch=uh;function lh(t){return lh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},lh(t)}function fh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,hh(n.key),n)}}function hh(t){var e=function(t,e){if("object"!=lh(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=lh(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==lh(e)?e:e+""}var ph=function(){return t=function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)},e=[{key:"formatUnits",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:8;return new ch(t.toString()).dividedBy(new ch(10).pow(e)).toString()}}],null&&fh(t.prototype,null),e&&fh(t,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}(),dh=i(3513),yh=i.t(dh,2),gh=i(8700),bh=i(8287).Buffer;function wh(t){return wh="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},wh(t)}function mh(t,e){for(var r=0;r<e.length;r++){var n=e[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(t,vh(n.key),n)}}function vh(t){var e=function(t,e){if("object"!=wh(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var n=r.call(t,"string");if("object"!=wh(n))return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wh(e)?e:e+""}function Eh(t,e,r){!function(t,e){if(e.has(t))throw new TypeError("Cannot initialize the same private elements twice on an object")}(t,e),e.set(t,r)}function Ah(t,e){return t.get(_h(t,e))}function Sh(t,e,r){return t.set(_h(t,e),r),r}function _h(t,e,r){if("function"==typeof t?t===e:t.has(e))return arguments.length<3?e:r;throw new TypeError("Private element is not present on this object")}(0,h.f0)(yh);var kh=(0,gh.dg)(yh),Th=new WeakMap,Ph=new WeakMap,Ih=new WeakMap,Oh=function(){function t(e){var r,n,i,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Eh(this,Th,void 0),Eh(this,Ph,void 0),Eh(this,Ih,void 0),r=this,i=void 0,(n=vh(n="network"))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,Sh(Th,this,e),this.network=o,Sh(Ph,this,this.getTaprootAddress()),Sh(Ih,this,this.getP2WPKHAddress())}return e=t,r=[{key:"taprootAddress",get:function(){if(!Ah(Ph,this))throw new Error("Address not set");return Ah(Ph,this)}},{key:"p2wpkhAddress",get:function(){if(!Ah(Ih,this))throw new Error("Address not set");return Ah(Ih,this)}},{key:"publicKey",get:function(){if(!Ah(Th,this))throw new Error("KeyPair not set");return Ah(Th,this).publicKey}},{key:"privateKey",get:function(){if(!Ah(Th,this))throw new Error("KeyPair not set");return Ah(Th,this).privateKey}},{key:Symbol.toStringTag,value:function(){return this.taprootAddress}},{key:"getP2WPKHAddress",value:function(){var t=h.KT.p2wpkh({pubkey:Ah(Th,this).publicKey,network:this.network});if(!t.address)throw new Error("Failed to generate wallet");return t.address}},{key:"getTaprootAddress",value:function(){if(!Ah(Th,this))throw new Error("KeyPair not set");var t=Ah(Th,this).publicKey.slice(1,33),e=bh.concat([bh.from([81,32]),t]);return h.hl.fromOutputScript(e,this.network)}}],n=[{key:"isValidTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;try{var r;return r="string"==typeof t?t:t.taprootAddress,!!h.hl.toOutputScript(r,e)}catch(t){return!1}}},{key:"fromPublicKey",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;return new t(kh.fromPublicKey(e,{network:r}),r)}},{key:"fromPrivateKey",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;return new t(kh.fromPrivateKey(e,{network:r}),r)}},{key:"fromWif",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:h.o8.bitcoin;return new t(kh.fromWIF(e,r),r)}}],r&&mh(e.prototype,r),n&&mh(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e;var e,r,n}()})();var s=o.y3,a=o.Lk,u=o.Uq,c=o.EI,l=o.JL,f=o.M7,h=o.G7,p=o.eB,d=o.Q9,y=o.rO,g=o.qT,b=o.Yy,w=o.JV,m=o.Bc,v=o.r,E=o.W4,A=o.rs,S=o.OB,_=o.PN,k=o.Mw,T=o.GE,P=o.z5,I=o.XV,O=o.Wj,x=o.PF,B=o.$7,R=o.rE;export{s as ABIDataTypes,a as AbstractRpcProvider,u as BaseContract,c as BitcoinAbiTypes,l as BitcoinAddress,f as BitcoinInterface,h as BitcoinUtils,p as Block,d as CallResult,y as ContractData,g as DeploymentTransaction,b as GenericTransaction,w as IBaseContract,m as InteractionTransaction,v as JSONRpcProvider,E as OPNetTransactionTypes,A as StoredValue,S as TransactionBase,_ as TransactionInput,k as TransactionOutput,T as TransactionParser,P as TransactionReceipt,I as UTXO,O as WebSocketRpcProvider,x as getContract,B as opnet,R as version};