@btc-vision/transaction 1.0.111 → 1.0.113
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/_version.d.ts +1 -1
- package/browser/generators/Generator.d.ts +2 -0
- package/browser/index.js +1 -1
- package/browser/keypair/AddressVerificator.d.ts +15 -3
- package/browser/keypair/EcKeyPair.d.ts +9 -4
- package/browser/keypair/Wallet.d.ts +1 -0
- package/browser/signer/TweakedSigner.d.ts +2 -2
- package/browser/transaction/builders/FundingTransaction.d.ts +2 -1
- package/browser/transaction/builders/MultiSignTransaction.d.ts +2 -1
- package/browser/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
- package/browser/transaction/builders/TransactionBuilder.d.ts +3 -2
- package/browser/transaction/shared/TweakedTransaction.d.ts +8 -7
- package/browser/verification/TapscriptVerificator.d.ts +1 -1
- package/build/_version.d.ts +1 -1
- package/build/_version.js +1 -1
- package/build/generators/Generator.d.ts +2 -0
- package/build/generators/Generator.js +5 -0
- package/build/generators/builders/CalldataGenerator.js +4 -2
- package/build/generators/builders/DeploymentGenerator.js +7 -4
- package/build/keypair/AddressVerificator.d.ts +15 -3
- package/build/keypair/AddressVerificator.js +74 -3
- package/build/keypair/EcKeyPair.d.ts +9 -4
- package/build/keypair/EcKeyPair.js +69 -7
- package/build/keypair/Wallet.d.ts +1 -0
- package/build/keypair/Wallet.js +5 -4
- package/build/signer/TweakedSigner.d.ts +2 -2
- package/build/signer/TweakedSigner.js +1 -1
- package/build/transaction/builders/CustomScriptTransaction.js +3 -3
- package/build/transaction/builders/DeploymentTransaction.js +4 -4
- package/build/transaction/builders/FundingTransaction.d.ts +2 -1
- package/build/transaction/builders/FundingTransaction.js +18 -4
- package/build/transaction/builders/MultiSignTransaction.d.ts +2 -1
- package/build/transaction/builders/SharedInteractionTransaction.d.ts +1 -1
- package/build/transaction/builders/SharedInteractionTransaction.js +4 -4
- package/build/transaction/builders/TransactionBuilder.d.ts +3 -2
- package/build/transaction/builders/TransactionBuilder.js +7 -2
- package/build/transaction/builders/UnwrapTransaction.js +2 -2
- package/build/transaction/shared/TweakedTransaction.d.ts +8 -7
- package/build/transaction/shared/TweakedTransaction.js +1 -1
- package/build/verification/TapscriptVerificator.d.ts +1 -1
- package/build/verification/TapscriptVerificator.js +2 -2
- package/package.json +2 -1
- package/src/_version.ts +1 -1
- package/src/generators/Generator.ts +12 -0
- package/src/generators/builders/CalldataGenerator.ts +6 -3
- package/src/generators/builders/DeploymentGenerator.ts +9 -4
- package/src/keypair/AddressVerificator.ts +144 -5
- package/src/keypair/EcKeyPair.ts +149 -13
- package/src/keypair/Wallet.ts +11 -3
- package/src/signer/TweakedSigner.ts +3 -2
- package/src/transaction/builders/CustomScriptTransaction.ts +6 -5
- package/src/transaction/builders/DeploymentTransaction.ts +6 -5
- package/src/transaction/builders/FundingTransaction.ts +18 -5
- package/src/transaction/builders/MultiSignTransaction.ts +6 -2
- package/src/transaction/builders/SharedInteractionTransaction.ts +5 -5
- package/src/transaction/builders/TransactionBuilder.ts +36 -10
- package/src/transaction/builders/UnwrapSegwitTransaction.ts +7 -3
- package/src/transaction/builders/UnwrapTransaction.ts +2 -2
- package/src/transaction/builders/WrapTransaction.ts +1 -6
- package/src/transaction/shared/TweakedTransaction.ts +12 -12
- package/src/verification/TapscriptVerificator.ts +3 -3
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),a=r(2623);function s(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=s(i);const c="Expected Private",f="Expected Point",l="Expected Tweak",h="Expected Signature",p="Expected Extra Data (32 bytes)",d="Expected Scalar";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(a.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>a.sha256(u.utils.concatBytes(...t));const y=u.utils._normalizePrivateKey,b=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]),g=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 v(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function m(t){return 0===v(t,g)}function _(t){return t instanceof Uint8Array&&32===t.length&&!(v(t,b)>=0)}function E(t){return t instanceof Uint8Array&&64===t.length&&v(t.subarray(0,32),b)<0&&v(t.subarray(32,64),b)<0}function S(t){return t instanceof Uint8Array&&32===t.length}function k(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function T(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function O(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=T(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");e=function(t){return T(u.utils.bytesToHex(t))}(t)}if(e<0)throw new Error("Expected private scalar >= 0");return e}const A=(t,e,r)=>{const n=u.Point.fromHex(t),i=O(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)};function x(t,e){return void 0===t?void 0===e||R(e):!!t}function P(t){try{return t()}catch(t){return null}}function I(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function L(t){return I(t,!1)}function R(t){return I(t,!1)&&33===t.length}function B(t){return u.utils.isValidPrivateKey(t)}function N(t){return I(t,!0)}function U(t){if(!L(t))throw new Error(f);return t.slice(1,33)}function j(t,e){if(!B(t))throw new Error(c);return P((()=>u.getPublicKey(t,x(e))))}e.isPoint=L,e.isPointCompressed=R,e.isPrivate=B,e.isXOnlyPoint=N,e.pointAdd=function(t,e,r){if(!L(t)||!L(e))throw new Error(f);return P((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(x(r,t))}))},e.pointAddScalar=function(t,e,r){if(!L(t))throw new Error(f);if(!_(e))throw new Error(l);return P((()=>A(t,e,x(r,t))))},e.pointCompress=function(t,e){if(!L(t))throw new Error(f);return u.Point.fromHex(t).toRawBytes(x(e,t))},e.pointFromScalar=j,e.pointMultiply=function(t,e,r){if(!L(t))throw new Error(f);if(!_(e))throw new Error(l);return P((()=>((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,x(r,t))))},e.privateAdd=function(t,e){if(!1===B(t))throw new Error(c);if(!1===_(e))throw new Error(l);return P((()=>((t,e)=>{const r=y(t),n=O(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===B(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===B(t))throw new Error(c);if(!1===_(e))throw new Error(l);return P((()=>((t,e)=>{const r=y(t),n=O(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(!E(e)||!function(t){return!(m(t.subarray(0,32))||m(t.subarray(32,64)))}(e))throw new Error(h);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&v(t.subarray(0,32),w)<0}(e))throw new Error("Bad Recovery Id");if(!N(e.subarray(0,32)))throw new Error(h);return u.recoverPublicKey(t,e,r,x(n))},e.sign=function(t,e,r){if(!B(e))throw new Error(c);if(!S(t))throw new Error(d);if(!k(r))throw new Error(p);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!B(e))throw new Error(c);if(!S(t))throw new Error(d);if(!k(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(!B(e))throw new Error(c);if(!S(t))throw new Error(d);if(!k(r))throw new Error(p);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!L(e))throw new Error(f);if(!E(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(!N(e))throw new Error(f);if(!E(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(!N(t))throw new Error(f);if(!_(e))throw new Error(l);return P((()=>{const r=A(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=U,e.xOnlyPointFromScalar=function(t){if(!B(t))throw new Error(c);return U(j(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 a(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 s(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.isBytes=i,e.number=r,e.bool=n,e.bytes=o,e.hash=a,e.exists=s,e.output=u;const c={number:r,bool:n,bytes:o,hash:a,exists:s,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,a=(t=(0,i.toBytes)(t)).length;for(let n=0;n<a;){const s=Math.min(o-this.pos,a-n);if(s!==o)r.set(t.subarray(n,n+s),this.pos),this.pos+=s,n+=s,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=a-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:a}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let t=s;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),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,o-8,BigInt(8*this.length),a),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 f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,l[t],a)}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:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=o},2318:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=void 0,e.fromBig=i,e.split=o,e.add=v;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:a,l:s}=i(t[o],e);[r[o],n[o]]=[a,s]}return[r,n]}const a=(t,e)=>BigInt(t>>>0)<<n|BigInt(e>>>0);e.toBig=a;const s=(t,e,r)=>t>>>r;e.shrSH=s;const u=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=u;const c=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=c;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const l=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=l;const h=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=h;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<<r|e>>>32-r;e.rotlSH=y;const b=(t,e,r)=>e<<r|t>>>32-r;e.rotlSL=b;const g=(t,e,r)=>e<<r-32|t>>>64-r;e.rotlBH=g;const w=(t,e,r)=>t<<r-32|e>>>64-r;function v(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w;const m=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=m;const _=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=_;const E=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=E;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const k=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=k;const T=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=T;const O={fromBig:i,split:o,toBig:a,shrSH:s,shrSL:u,rotrSH:c,rotrSL:f,rotrBH:l,rotrBL:h,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:w,add:v,add3L:m,add3H:_,add4L:E,add4H:S,add5H:T,add5L:k};e.default=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,a=new Uint8Array(o);a.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<a.length;t++)a[t]^=54;this.iHash.update(a),this.oHash=t.create();for(let t=0;t<a.length;t++)a[t]^=106;this.oHash.update(a),a.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:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,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]),a=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),s=a.map((t=>(9*t+5)%16));let u=[a],c=[s];for(let t=0;t<4;t++)for(let e of[u,c])e.push(e[t].map((t=>o[t])));const f=[[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=u.map(((t,e)=>t.map((t=>f[e][t])))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(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 b=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)b[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,a=o,s=0|this.h2,f=s,g=0|this.h3,w=g,v=0|this.h4,m=v;for(let t=0;t<5;t++){const e=4-t,_=p[t],E=d[t],S=u[t],k=c[t],T=l[t],O=h[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,s,g)+b[S[e]]+_,T[e])+v|0;r=v,v=g,g=0|(0,i.rotl)(s,10),s=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,a,f,w)+b[k[t]]+E,O[t])+m|0;n=m,m=w,w=0|(0,i.rotl)(f,10),f=a,a=r}}this.set(this.h1+s+w|0,this.h2+g+m|0,this.h3+v+n|0,this.h4+r+a|0,this.h0+o+f|0)}roundClean(){b.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=e.SHA1=void 0;const n=r(7202),i=r(9175),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),a=new Uint32Array(80);class s 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)a[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)a[t]=(0,i.rotl)(a[t-3]^a[t-8]^a[t-14]^a[t-16],1);let{A:r,B:o,C:s,D:u,E:c}=this;for(let t=0;t<80;t++){let e,f;t<20?(e=(0,n.Chi)(o,s,u),f=1518500249):t<40?(e=o^s^u,f=1859775393):t<60?(e=(0,n.Maj)(o,s,u),f=2400959708):(e=o^s^u,f=3395469782);const l=(0,i.rotl)(r,5)+e+c+f+a[t]|0;c=u,u=s,s=(0,i.rotl)(o,30),o=r,r=l}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,u=u+this.D|0,c=c+this.E|0,this.set(r,o,s,u,c)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.SHA1=s,e.sha1=(0,i.wrapConstructor)((()=>new s))},2623:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){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|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=s[t-15],r=s[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;s[t]=o+s[t-7]+n+s[t-16]|0}let{A:r,B:a,C:u,D:c,E:f,F:l,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,l,h)+o[t]+s[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,a,u)|0;p=h,h=l,l=f,f=c+e|0,c=u,u=a,a=r,r=e+d|0}r=r+this.A|0,a=a+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,a,u,c,f,l,h,p)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=u;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))},102:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA384=e.SHA512_256=e.SHA512_224=e.SHA512=void 0;const n=r(7202),i=r(2318),o=r(9175),[a,s]=(()=>i.default.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)))))(),u=new Uint32Array(80),c=new Uint32Array(80);class f extends n.HashMD{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:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,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|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,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)u[r]=t.getUint32(e),c[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|u[t-15],r=0|c[t-15],n=i.default.rotrSH(e,r,1)^i.default.rotrSH(e,r,8)^i.default.shrSH(e,r,7),o=i.default.rotrSL(e,r,1)^i.default.rotrSL(e,r,8)^i.default.shrSL(e,r,7),a=0|u[t-2],s=0|c[t-2],f=i.default.rotrSH(a,s,19)^i.default.rotrBH(a,s,61)^i.default.shrSH(a,s,6),l=i.default.rotrSL(a,s,19)^i.default.rotrBL(a,s,61)^i.default.shrSL(a,s,6),h=i.default.add4L(o,l,c[t-7],c[t-16]),p=i.default.add4H(h,n,f,u[t-7],u[t-16]);u[t]=0|p,c[t]=0|h}let{Ah:r,Al:n,Bh:o,Bl:f,Ch:l,Cl:h,Dh:p,Dl:d,Eh:y,El:b,Fh:g,Fl:w,Gh:v,Gl:m,Hh:_,Hl:E}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,b,14)^i.default.rotrSH(y,b,18)^i.default.rotrBH(y,b,41),S=i.default.rotrSL(y,b,14)^i.default.rotrSL(y,b,18)^i.default.rotrBL(y,b,41),k=y&g^~y&v,T=b&w^~b&m,O=i.default.add5L(E,S,T,s[t],c[t]),A=i.default.add5H(O,_,e,k,a[t],u[t]),x=0|O,P=i.default.rotrSH(r,n,28)^i.default.rotrBH(r,n,34)^i.default.rotrBH(r,n,39),I=i.default.rotrSL(r,n,28)^i.default.rotrBL(r,n,34)^i.default.rotrBL(r,n,39),L=r&o^r&l^o&l,R=n&f^n&h^f&h;_=0|v,E=0|m,v=0|g,m=0|w,g=0|y,w=0|b,({h:y,l:b}=i.default.add(0|p,0|d,0|A,0|x)),p=0|l,d=0|h,l=0|o,h=0|f,o=0|r,f=0|n;const B=i.default.add3L(x,I,R);r=i.default.add3H(B,A,P,L),n=0|B}({h:r,l:n}=i.default.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h:l,l:h}=i.default.add(0|this.Ch,0|this.Cl,0|l,0|h)),({h:p,l:d}=i.default.add(0|this.Dh,0|this.Dl,0|p,0|d)),({h:y,l:b}=i.default.add(0|this.Eh,0|this.El,0|y,0|b)),({h:g,l:w}=i.default.add(0|this.Fh,0|this.Fl,0|g,0|w)),({h:v,l:m}=i.default.add(0|this.Gh,0|this.Gl,0|v,0|m)),({h:_,l:E}=i.default.add(0|this.Hh,0|this.Hl,0|_,0|E)),this.set(r,n,o,f,l,h,p,d,y,b,g,w,v,m,_,E)}roundClean(){u.fill(0),c.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)}}e.SHA512=f;class l extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}e.SHA512_224=l;class h extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}e.SHA512_256=h;class p extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.SHA384=p,e.sha512=(0,o.wrapConstructor)((()=>new f)),e.sha512_224=(0,o.wrapConstructor)((()=>new l)),e.sha512_256=(0,o.wrapConstructor)((()=>new h)),e.sha384=(0,o.wrapConstructor)((()=>new p))},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])},e.bytesToHex=function(t){(0,i.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e},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=s(t.charCodeAt(i)),o=s(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.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=u,e.toBytes=c,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.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==f.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(c(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(c(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(c(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));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const n=r(5145),i=r(7557);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);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),a={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function s(t){return t>=a._0&&t<=a._9?t-a._0:t>=a._A&&t<=a._F?t-(a._A-10):t>=a._a&&t<=a._f?t-(a._a-10):void 0}function u(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function c(t){return"string"==typeof t&&(t=u(t)),(0,i.bytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const f={}.toString},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),a=BigInt(2),s=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 f=(t,e)=>(t+e/a)/e,l={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,s=BigInt("0x100000000000000000000000000000000"),u=f(a*t,e),l=f(-n*t,e);let h=U(t-u*r-l*i,e),p=U(-u*n-l*a,e);const d=h>s,y=p>s;if(d&&(h=e-h),y&&(p=e-p),h>s||p>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:d,k1:h,k2neg:y,k2:p}}};function h(t){const{a:e,b:r}=c,n=U(t*t),i=U(n*t);return U(i+e*t+r)}const p=c.a===i;class d extends Error{constructor(t){super(t)}}function y(t){if(!(t instanceof b))throw new TypeError("JacobianPoint expected")}class b{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof v))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(v.ZERO)?b.ZERO:new b(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=c.P){const r=new Array(t.length),n=t.reduce(((t,n,o)=>n===i?t:(r[o]=t,U(t*n,e))),o),a=C(n,e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=U(t*r[o],e),U(t*n,e))),a),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return b.toAffineBatch(t).map(b.fromAffine)}equals(t){y(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,s=U(n*n),u=U(a*a),c=U(e*u),f=U(i*s),l=U(U(r*a)*u),h=U(U(o*n)*s);return c===f&&l===h}negate(){return new b(this.x,U(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=U(t*t),i=U(e*e),o=U(i*i),c=t+i,f=U(a*(U(c*c)-n-o)),l=U(s*n),h=U(l*l),p=U(h-a*f),d=U(l*(f-p)-u*o),y=U(a*e*r);return new b(p,d,y)}add(t){y(t);const{x:e,y:r,z:n}=this,{x:o,y:s,z:u}=t;if(o===i||s===i)return this;if(e===i||r===i)return t;const c=U(n*n),f=U(u*u),l=U(e*f),h=U(o*c),p=U(U(r*u)*f),d=U(U(s*n)*c),g=U(h-l),w=U(d-p);if(g===i)return w===i?this.double():b.ZERO;const v=U(g*g),m=U(g*v),_=U(l*v),E=U(w*w-m-a*_),S=U(w*(_-E)-p*m),k=U(n*u*g);return new b(E,S,k)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=b.ZERO;if("bigint"==typeof t&&t===i)return e;let r=N(t);if(r===o)return this;if(!p){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:a,k2neg:s,k2:u}=l.splitScalar(r),c=e,f=e,h=this;for(;a>i||u>i;)a&o&&(c=c.add(h)),u&o&&(f=f.add(h)),h=h.double(),a>>=o,u>>=o;return n&&(c=c.negate()),s&&(f=f.negate()),f=new b(U(f.x*l.beta),f.y,f.z),c.add(f)}precomputeWindow(t){const e=p?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(b.BASE)&&(e=v.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&&w.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=b.normalizeZ(n),w.set(e,n)));let i=b.ZERO,a=b.BASE;const s=1+(p?128/r:256/r),u=2**(r-1),c=BigInt(2**r-1),f=2**r,l=BigInt(r);for(let e=0;e<s;e++){const r=e*u;let s=Number(t&c);t>>=l,s>u&&(s-=f,t+=o);const h=r,p=r+Math.abs(s)-1,d=e%2!=0,y=s<0;0===s?a=a.add(g(d,n[h])):i=i.add(g(y,n[p]))}return{p:i,f:a}}multiply(t,e){let r,n,i=N(t);if(p){const{k1neg:t,k1:o,k2neg:a,k2:s}=l.splitScalar(i);let{p:u,f:c}=this.wNAF(o,e),{p:f,f:h}=this.wNAF(s,e);u=g(t,u),f=g(a,f),f=new b(U(f.x*l.beta),f.y,f.z),r=u.add(f),n=c.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return b.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(b.ZERO);null==t&&(t=i?u:C(n));const a=t,s=U(a*a),c=U(s*a),f=U(e*s),l=U(r*c),h=U(n*a);if(i)return v.ZERO;if(h!==o)throw new Error("invZ was invalid");return new v(f,l)}}function g(t,e){const r=e.negate();return t?r:e}b.BASE=new b(c.Gx,c.Gy,o),b.ZERO=new b(i,o,i);const w=new WeakMap;class v{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,w.delete(this)}hasEvenY(){return this.y%a===i}static fromCompressedHex(t){const e=32===t.length,r=R(e?t:t.subarray(1));if(!W(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),f=BigInt(88),l=t*t*t%e,h=l*l*t%e,p=j(h,s)*h%e,d=j(p,s)*h%e,y=j(d,a)*l%e,b=j(y,n)*y%e,g=j(b,i)*b%e,w=j(g,u)*g%e,v=j(w,f)*w%e,m=j(v,u)*g%e,_=j(m,s)*h%e,E=j(_,o)*b%e,S=j(E,r)*l%e,k=j(S,a);if(k*k%e!==t)throw new Error("Cannot find square root");return k}(h(r));const i=(n&o)===o;e?i&&(n=U(-n)):!(1&~t[0])!==i&&(n=U(-n));const u=new v(r,n);return u.assertValidity(),u}static fromUncompressedHex(t){const e=R(t.subarray(1,33)),r=R(t.subarray(33,65)),n=new v(e,r);return n.assertValidity(),n}static fromHex(t){const e=B(t),r=e.length,n=e[0];if(32===r)return this.fromCompressedHex(e);if(33===r&&(2===n||3===n))return this.fromCompressedHex(e);if(65===r&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return v.BASE.multiply(V(t))}static fromSignature(t,e,r){const{r:n,s:i}=q(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=F(B(t)),{n:a}=c,s=2===r||3===r?n+a:n,u=C(s,a),f=U(-o*u,a),l=U(i*u,a),h=1&r?"03":"02",p=v.fromHex(h+A(s)),d=v.BASE.multiplyAndAddUnsafe(p,f,l);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return L(this.toHex(t))}toHex(t=!1){const e=A(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${A(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(!W(e)||!W(r))throw new Error(t);const n=U(r*r);if(U(n-h(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new v(this.x,U(-this.y))}double(){return b.fromAffine(this).double().toAffine()}add(t){return b.fromAffine(this).add(b.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return b.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=b.fromAffine(this),a=e===i||e===o||this!==v.BASE?n.multiplyUnsafe(e):n.multiply(e),s=b.fromAffine(t).multiplyUnsafe(r),u=a.add(s);return u.equals(b.ZERO)?void 0:u.toAffine()}}function m(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function _(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${T(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:R(r),left:t.subarray(e+2)}}e.Point=v,v.BASE=new v(c.Gx,c.Gy),v.ZERO=new v(i,i);class E{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?T(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new E(I(n.slice(0,64)),I(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: ${T(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=_(t.subarray(2)),{data:n,left:i}=_(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${T(i)}`);return{r:e,s:n}}(e?t:L(t));return new E(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!K(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!K(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 E(this.r,U(-this.s,c.n)):this}toDERRawBytes(){return L(this.toDERHex())}toDERHex(){const t=m(P(this.s)),e=m(P(this.r)),r=t.length/2,n=e.length/2,i=P(r),o=P(n);return`30${P(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return L(this.toCompactHex())}toCompactHex(){return A(this.r)+A(this.s)}}function S(...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=E;const k=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function T(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=k[t[r]];return e}const O=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function A(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(i<=t&&t<O))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function x(t){const e=L(A(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function P(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function I(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function L(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 R(t){return I(T(t))}function B(t){return t instanceof Uint8Array?Uint8Array.from(t):L(t)}function N(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&K(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function U(t,e=c.P){const r=t%e;return r>=i?r:e+r}function j(t,e){const{P:r}=c;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function C(t,e=c.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=U(t,e),n=e,a=i,s=o,u=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=a-u*t,o=s-f*t;n=r,r=e,a=u,s=f,u=i,f=o}if(n!==o)throw new Error("invert: does not exist");return U(a,e)}function F(t,e=!1){const r=function(t){const e=8*t.length-256,r=R(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=c;return r>=n?r-n:r}let M,D;class H{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 D(this.k,...t)}checkSync(){if("function"!=typeof D)throw new d("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 S(...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 S(...e)}}function K(t){return i<t&&t<c.n}function W(t){return i<t&&t<c.P}function G(t,e,r,n=!0){const{n:a}=c,s=F(t,!0);if(!K(s))return;const u=C(s,a),f=v.BASE.multiply(s),l=U(f.x,a);if(l===i)return;const h=U(u*U(e+r*l,a),a);if(h===i)return;let p=new E(l,h),d=(f.x===p.r?0:2)|Number(f.y&o);return n&&p.hasHighS()&&(p=p.normalizeS(),d^=1),{sig:p,recovery:d}}function V(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 key");e=I(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==t.length)throw new Error("Expected 32 bytes of private key");e=R(t)}if(!K(e))throw new Error("Expected private key: 0 < key < n");return e}function z(t){return t instanceof v?(t.assertValidity(),t):v.fromHex(t)}function q(t){if(t instanceof E)return t.assertValidity(),t;try{return E.fromDER(t)}catch(e){return E.fromCompact(t)}}function X(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?33===n||65===n:r?66===n||130===n:t instanceof v}function $(t){return R(t.length>32?t.slice(0,32):t)}function Y(t){const e=$(t),r=U(e,c.n);return Z(r<i?e:r)}function Z(t){return x(t)}function J(t,r,n){if(null==t)throw new Error(`sign: expected valid message hash, not "${t}"`);const i=B(t),o=V(r),a=[Z(o),Y(i)];if(null!=n){!0===n&&(n=e.utils.randomBytes(32));const t=B(n);if(32!==t.length)throw new Error("sign: Expected 32 bytes of extra data");a.push(t)}return{seed:S(...a),m:$(i),d:o}}function Q(t,e){const{sig:r,recovery:n}=t,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},e),a=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[a,n]:a}e.getPublicKey=function(t,e=!1){return v.fromPrivateKey(t).toRawBytes(e)},e.recoverPublicKey=function(t,e,r,n=!1){return v.fromSignature(t,e,r).toRawBytes(n)},e.getSharedSecret=function(t,e,r=!1){if(X(t))throw new TypeError("getSharedSecret: first arg must be private key");if(!X(e))throw new TypeError("getSharedSecret: second arg must be public key");const n=z(e);return n.assertValidity(),n.multiply(V(t)).toRawBytes(r)},e.sign=async function(t,e,r={}){const{seed:n,m:i,d:o}=J(t,e,r.extraEntropy),a=new H(32,32);let s;for(await a.reseed(n);!(s=G(await a.generate(),i,o,r.canonical));)await a.reseed();return Q(s,r)},e.signSync=function(t,e,r={}){const{seed:n,m:i,d:o}=J(t,e,r.extraEntropy),a=new H(32,32);let s;for(a.reseedSync(n);!(s=G(a.generateSync(),i,o,r.canonical));)a.reseedSync();return Q(s,r)};const tt={strict:!0};function et(t){return U(R(t),c.n)}e.verify=function(t,e,r,n=tt){let i;try{i=q(t),e=B(e)}catch(t){return!1}const{r:o,s:a}=i;if(n.strict&&i.hasHighS())return!1;const s=F(e);let u;try{u=z(r)}catch(t){return!1}const{n:f}=c,l=C(a,f),h=U(s*l,f),p=U(o*l,f),d=v.BASE.multiplyAndAddUnsafe(u,h,p);return!!d&&U(d.x,f)===o};class rt{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=B(t);if(64!==e.length)throw new TypeError(`SchnorrSignature.fromHex: expected 64 bytes, not ${e.length}`);const r=R(e.subarray(0,32)),n=R(e.subarray(32,64));return new rt(r,n)}assertValidity(){const{r:t,s:e}=this;if(!W(t)||!K(e))throw new Error("Invalid signature")}toHex(){return A(this.r)+A(this.s)}toRawBytes(){return L(this.toHex())}}class nt{constructor(t,r,n=e.utils.randomBytes()){if(null==t)throw new TypeError(`sign: Expected valid message, not "${t}"`);this.m=B(t);const{x:i,scalar:o}=this.getScalar(V(r));if(this.px=i,this.d=o,this.rand=B(n),32!==this.rand.length)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(t){const e=v.fromPrivateKey(t),r=e.hasEvenY()?t:c.n-t;return{point:e,scalar:r,x:e.toRawX()}}initNonce(t,e){return x(t^R(e))}finalizeNonce(t){const e=U(R(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 rt(t.x,U(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,a=this.initNonce(r,await o(ct.aux,i)),{R:s,rx:u,k:c}=this.finalizeNonce(await o(ct.nonce,a,n,t)),f=et(await o(ct.challenge,u,n,t)),l=this.finalizeSig(s,c,f,r);return await at(l,t,n)||this.error(),l}calcSync(){const{m:t,d:r,px:n,rand:i}=this,o=e.utils.taggedHashSync,a=this.initNonce(r,o(ct.aux,i)),{R:s,rx:u,k:c}=this.finalizeNonce(o(ct.nonce,a,n,t)),f=et(o(ct.challenge,u,n,t)),l=this.finalizeSig(s,c,f,r);return st(l,t,n)||this.error(),l}}function it(t,e,r){const n=t instanceof rt,i=n?t:rt.fromHex(t);return n&&i.assertValidity(),{...i,m:B(e),P:z(r)}}function ot(t,e,r,n){const i=v.BASE.multiplyAndAddUnsafe(e,V(r),U(-n,c.n));return!(!i||!i.hasEvenY()||i.x!==t)}async function at(t,r,n){try{const{r:i,s:o,m:a,P:s}=it(t,r,n),u=et(await e.utils.taggedHash(ct.challenge,x(i),s.toRawX(),a));return ot(i,s,o,u)}catch(t){return!1}}function st(t,r,n){try{const{r:i,s:o,m:a,P:s}=it(t,r,n),u=et(e.utils.taggedHashSync(ct.challenge,x(i),s.toRawX(),a));return ot(i,s,o,u)}catch(t){if(t instanceof d)throw t;return!1}}e.schnorr={Signature:rt,getPublicKey:function(t){return v.fromPrivateKey(t).toRawX()},sign:async function(t,e,r){return new nt(t,e,r).calc()},verify:at,signSync:function(t,e,r){return new nt(t,e,r).calcSync()},verifySync:st},v.BASE._setWindowSize(8);const ut={node:n,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},ft={};e.utils={bytesToHex:T,hexToBytes:L,concatBytes:S,mod:U,invert:C,isValidPrivateKey(t){try{return V(t),!0}catch(t){return!1}},_bigintTo32Bytes:x,_normalizePrivateKey:V,hashToPrivateKey:t=>{if((t=B(t)).length<40||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return x(U(R(t),c.n-o)+o)},randomBytes:(t=32)=>{if(ut.web)return ut.web.getRandomValues(new Uint8Array(t));if(ut.node){const{randomBytes:e}=ut.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(40)),precompute(t=8,e=v.BASE){const r=e===v.BASE?e:new v(e.x,e.y);return r._setWindowSize(t),r.multiply(s),r},sha256:async(...t)=>{if(ut.web){const e=await ut.web.subtle.digest("SHA-256",S(...t));return new Uint8Array(e)}if(ut.node){const{createHash:e}=ut.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(ut.web){const r=await ut.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=S(...e),i=await ut.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(ut.node){const{createHmac:r}=ut.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=ft[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=S(r,r),ft[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if("function"!=typeof M)throw new d("sha256Sync is undefined, you need to set it");let r=ft[t];if(void 0===r){const e=M(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=S(e,e),ft[t]=r}return M(r,...e)},_JacobianPoint:b},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>M,set(t){M||(M=t)}},hmacSha256Sync:{configurable:!1,get:()=>D,set(t){D||(D=t)}}})},3203:(t,e)=>{function r(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function n(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function i(...t){const e=t=>t,r=(t,e)=>r=>t(e(r)),n=t.map((t=>t.encode)).reduceRight(r,e),i=t.map((t=>t.decode)).reduce(r,e);return{encode:n,decode:i}}function o(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(r(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}}}function a(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function s(t,e="="){if(r(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function u(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let i=0;const o=[],a=Array.from(t);for(a.forEach((t=>{if(r(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,r=!0;for(let o=i;o<a.length;o++){const s=a[o],u=e*t+s;if(!Number.isSafeInteger(u)||e*t/e!==t||u-s!=e*t)throw new Error("convertRadix: carry overflow");t=u%n;const c=Math.floor(u/n);if(a[o]=c,!Number.isSafeInteger(c)||c*n+t!==u)throw new Error("convertRadix: carry overflow");r&&(c?r=!1:i=o)}if(o.push(t),r)break}for(let e=0;e<t.length-1&&0===t[e];e++)o.push(0);return o.reverse()}Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.createBase58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64urlnopad=e.base64url=e.base64nopad=e.base64=e.base32crockford=e.base32hexnopad=e.base32hex=e.base32nopad=e.base32=e.base16=e.utils=void 0,e.assertNumber=r;const f=(t,e)=>e?f(e,t%e):t,l=(t,e)=>t+(e-f(t,e));function h(t,e,n,i){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(l(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${l(e,n)}`);let o=0,a=0;const s=2**n-1,u=[];for(const i of t){if(r(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<<e|i,a+e>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${e}`);for(a+=e;a>=n;a-=n)u.push((o>>a-n&s)>>>0);o&=2**a-1}if(o=o<<n-a&s,!i&&a>=e)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&a>0&&u.push(o>>>0),u}function p(t){return r(t),{encode:e=>{if(!n(e))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(c(e,t,256))}}}function d(t,e=!1){if(r(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,t)>32||l(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!n(r))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(h(r,t,8,e))}}}function y(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}function b(t,e){if(r(t),"function"!=typeof e)throw new Error("checksum fn should be function");return{encode(r){if(!n(r))throw new Error("checksum.encode: input should be Uint8Array");const i=e(r).slice(0,t),o=new Uint8Array(r.length+t);return o.set(r),o.set(i,r.length),o},decode(r){if(!n(r))throw new Error("checksum.decode: input should be Uint8Array");const i=r.slice(0,-t),o=e(i).slice(0,t),a=r.slice(-t);for(let e=0;e<t;e++)if(o[e]!==a[e])throw new Error("Invalid checksum");return i}}}e.utils={alphabet:o,chain:i,checksum:b,convertRadix:c,convertRadix2:h,radix:p,radix2:d,join:a,padding:s},e.base16=i(d(4),o("0123456789ABCDEF"),a("")),e.base32=i(d(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),a("")),e.base32nopad=i(d(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),a("")),e.base32hex=i(d(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),a("")),e.base32hexnopad=i(d(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),a("")),e.base32crockford=i(d(5),o("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),a(""),u((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),e.base64=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),a("")),e.base64nopad=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),a("")),e.base64url=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),a("")),e.base64urlnopad=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),a(""));const g=t=>i(p(58),o(t),a(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const w=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r="";for(let n=0;n<t.length;n+=8){const i=t.subarray(n,n+8);r+=e.base58.encode(i).padStart(w[i.length],"1")}return r},decode(t){let r=[];for(let n=0;n<t.length;n+=11){const i=t.slice(n,n+11),o=w.indexOf(i.length),a=e.base58.decode(i);for(let t=0;t<a.length-o;t++)if(0!==a[t])throw new Error("base58xmr: wrong padding");r=r.concat(Array.from(a.slice(a.length-o)))}return Uint8Array.from(r)}},e.createBase58check=t=>i(b(4,(e=>t(t(e)))),e.base58),e.base58check=e.createBase58check;const v=i(o("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),a("")),m=[996825010,642813549,513874426,1027748829,705979059];function _(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<m.length;t++)1==(e>>t&1)&&(r^=m[t]);return r}function E(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=_(i)^r>>5}i=_(i);for(let e=0;e<n;e++)i=_(i)^31&t.charCodeAt(e);for(let t of e)i=_(i)^t;for(let t=0;t<6;t++)i=_(i);return i^=r,v.encode(h([i%2**30],30,5,!1))}function S(t){const e="bech32"===t?1:734539939,r=d(5),n=r.decode,i=r.encode,o=y(n);function a(t,r,n=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(r instanceof Uint8Array&&(r=Array.from(r)),!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof r);if(0===t.length)throw new TypeError(`Invalid prefix length ${t.length}`);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),a=E(o,r,e);return`${o}1${v.encode(r)}${a}`}function s(t,r=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==r&&t.length>r)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=n.lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=n.slice(0,i),a=n.slice(i+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const s=v.decode(a).slice(0,-6),u=E(o,s,e);if(!a.endsWith(u))throw new Error(`Invalid checksum in ${t}: expected "${u}"`);return{prefix:o,words:s}}return{encode:a,decode:s,encodeFromBytes:function(t,e){return a(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:y(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=S("bech32"),e.bech32m=S("bech32m"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=i(d(4),o("0123456789abcdef"),a(""),u((t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},T="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr";e.bytesToString=(t,e)=>{if("string"!=typeof t||!k.hasOwnProperty(t))throw new TypeError(T);if(!n(e))throw new TypeError("bytesToString() expects Uint8Array");return k[t].encode(e)},e.str=e.bytesToString,e.stringToBytes=(t,e)=>{if(!k.hasOwnProperty(t))throw new TypeError(T);if("string"!=typeof e)throw new TypeError("stringToBytes() expects string");return k[t].decode(e)},e.bytes=e.stringToBytes},4148:(t,e,r)=>{var n=r(5606);function i(t){return i="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},i(t)}function o(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,(void 0,o=function(t){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key),"symbol"===i(o)?o:String(o)),n)}var o}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var s,u,c=r(9597).codes,f=c.ERR_AMBIGUOUS_ARGUMENT,l=c.ERR_INVALID_ARG_TYPE,h=c.ERR_INVALID_ARG_VALUE,p=c.ERR_INVALID_RETURN_VALUE,d=c.ERR_MISSING_ARGS,y=r(3918),b=r(537).inspect,g=r(537).types,w=g.isPromise,v=g.isRegExp,m=r(1514)(),_=r(9394)(),E=r(8075)("RegExp.prototype.test");function S(){var t=r(2299);s=t.isDeepEqual,u=t.isDeepStrictEqual}new Map;var k=!1,T=t.exports=P,O={};function A(t){if(t.message instanceof Error)throw t.message;throw new y(t)}function x(t,e,r,n){if(!r){var i=!1;if(0===e)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new y({actual:r,expected:!0,message:n,operator:"==",stackStartFn:t});throw o.generatedMessage=i,o}}function P(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];x.apply(void 0,[P,e.length].concat(e))}T.fail=function t(e,r,i,o,a){var s,u=arguments.length;if(0===u?s="Failed":1===u?(i=e,e=void 0):(!1===k&&(k=!0,(n.emitWarning?n.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),2===u&&(o="!=")),i instanceof Error)throw i;var c={actual:e,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||t};void 0!==i&&(c.message=i);var f=new y(c);throw s&&(f.message=s,f.generatedMessage=!0),f},T.AssertionError=y,T.ok=P,T.equal=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e!=r&&A({actual:e,expected:r,message:n,operator:"==",stackStartFn:t})},T.notEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e==r&&A({actual:e,expected:r,message:n,operator:"!=",stackStartFn:t})},T.deepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),s(e,r)||A({actual:e,expected:r,message:n,operator:"deepEqual",stackStartFn:t})},T.notDeepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),s(e,r)&&A({actual:e,expected:r,message:n,operator:"notDeepEqual",stackStartFn:t})},T.deepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),u(e,r)||A({actual:e,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:t})},T.notDeepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),u(e,r)&&A({actual:e,expected:r,message:n,operator:"notDeepStrictEqual",stackStartFn:t})},T.strictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)||A({actual:e,expected:r,message:n,operator:"strictEqual",stackStartFn:t})},T.notStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)&&A({actual:e,expected:r,message:n,operator:"notStrictEqual",stackStartFn:t})};var I=a((function t(e,r,n){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r.forEach((function(t){t in e&&(void 0!==n&&"string"==typeof n[t]&&v(e[t])&&E(e[t],n[t])?i[t]=n[t]:i[t]=e[t])}))}));function L(t,e,r,n){if("function"!=typeof e){if(v(e))return E(e,t);if(2===arguments.length)throw new l("expected",["Function","RegExp"],e);if("object"!==i(t)||null===t){var o=new y({actual:t,expected:e,message:r,operator:"deepStrictEqual",stackStartFn:n});throw o.operator=n.name,o}var a=Object.keys(e);if(e instanceof Error)a.push("name","message");else if(0===a.length)throw new h("error",e,"may not be an empty object");return void 0===s&&S(),a.forEach((function(i){"string"==typeof t[i]&&v(e[i])&&E(e[i],t[i])||function(t,e,r,n,i,o){if(!(r in t)||!u(t[r],e[r])){if(!n){var a=new I(t,i),s=new I(e,i,t),c=new y({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=t,c.expected=e,c.operator=o.name,c}A({actual:t,expected:e,message:n,operator:o.name,stackStartFn:o})}}(t,e,i,r,a,n)})),!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function R(t){if("function"!=typeof t)throw new l("fn","Function",t);try{t()}catch(t){return t}return O}function B(t){return w(t)||null!==t&&"object"===i(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function N(t){return Promise.resolve().then((function(){var e;if("function"==typeof t){if(!B(e=t()))throw new p("instance of Promise","promiseFn",e)}else{if(!B(t))throw new l("promiseFn",["Function","Promise"],t);e=t}return Promise.resolve().then((function(){return e})).then((function(){return O})).catch((function(t){return t}))}))}function U(t,e,r,n){if("string"==typeof r){if(4===arguments.length)throw new l("error",["Object","Error","Function","RegExp"],r);if("object"===i(e)&&null!==e){if(e.message===r)throw new f("error/message",'The error message "'.concat(e.message,'" is identical to the message.'))}else if(e===r)throw new f("error/message",'The error "'.concat(e,'" is identical to the message.'));n=r,r=void 0}else if(null!=r&&"object"!==i(r)&&"function"!=typeof r)throw new l("error",["Object","Error","Function","RegExp"],r);if(e===O){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=n?": ".concat(n):".";var a="rejects"===t.name?"rejection":"exception";A({actual:void 0,expected:r,operator:t.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:t})}if(r&&!L(e,r,n,t))throw e}function j(t,e,r,n){if(e!==O){if("string"==typeof r&&(n=r,r=void 0),!r||L(e,r)){var i=n?": ".concat(n):".",o="doesNotReject"===t.name?"rejection":"exception";A({actual:e,expected:r,operator:t.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(e&&e.message,'"'),stackStartFn:t})}throw e}}function C(t,e,r,n,o){if(!v(e))throw new l("regexp","RegExp",e);var a="match"===o;if("string"!=typeof t||E(e,t)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(i(t)," (").concat(b(t),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(b(e),". Input:\n\n").concat(b(t),"\n"));var u=new y({actual:t,expected:e,message:r,operator:o,stackStartFn:n});throw u.generatedMessage=s,u}}function F(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];x.apply(void 0,[F,e.length].concat(e))}T.throws=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];U.apply(void 0,[t,R(e)].concat(n))},T.rejects=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return N(e).then((function(e){return U.apply(void 0,[t,e].concat(n))}))},T.doesNotThrow=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];j.apply(void 0,[t,R(e)].concat(n))},T.doesNotReject=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return N(e).then((function(e){return j.apply(void 0,[t,e].concat(n))}))},T.ifError=function t(e){if(null!=e){var r="ifError got unwanted exception: ";"object"===i(e)&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=b(e);var n=new y({actual:e,expected:null,operator:"ifError",message:r,stackStartFn:t}),o=e.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=n.stack.split("\n"),u=0;u<a.length;u++){var c=s.indexOf(a[u]);if(-1!==c){s=s.slice(0,c);break}}n.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw n}},T.match=function t(e,r,n){C(e,r,n,t,"match")},T.doesNotMatch=function t(e,r,n){C(e,r,n,t,"doesNotMatch")},T.strict=m(F,T,{equal:T.strictEqual,deepEqual:T.deepStrictEqual,notEqual:T.notStrictEqual,notDeepEqual:T.notDeepStrictEqual}),T.strict.strict=T.strict},3918:(t,e,r)=>{var n=r(5606);function i(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 o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){var n,i,o;n=t,i=e,o=r[e],(i=s(i))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return 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,s(n.key),n)}}function s(t){var e=function(t){if("object"!==y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===y(e)?e:String(e)}function u(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return l(t,arguments,d(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)},f(t)}function l(t,e,r){return l=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i},l.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function y(t){return y="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},y(t)}var b=r(537).inspect,g=r(9597).codes.ERR_INVALID_ARG_TYPE;function w(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}var v="",m="",_="",E="",S={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function k(t){var e=Object.keys(t),r=Object.create(Object.getPrototypeOf(t));return e.forEach((function(e){r[e]=t[e]})),Object.defineProperty(r,"message",{value:t.message}),r}function T(t){return b(t,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var O=function(t,e){!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&&p(t,e)}(O,t);var r,i,s,f,l=(r=O,i=h(),function(){var t,e=d(r);if(i){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function O(t){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,O),"object"!==y(t)||null===t)throw new g("options","Object",t);var r=t.message,i=t.operator,o=t.stackStartFn,a=t.actual,s=t.expected,f=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)e=l.call(this,String(r));else if(n.stderr&&n.stderr.isTTY&&(n.stderr&&n.stderr.getColorDepth&&1!==n.stderr.getColorDepth()?(v="[34m",m="[32m",E="[39m",_="[31m"):(v="",m="",E="",_="")),"object"===y(a)&&null!==a&&"object"===y(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=k(a),s=k(s)),"deepStrictEqual"===i||"strictEqual"===i)e=l.call(this,function(t,e,r){var i="",o="",a=0,s="",u=!1,c=T(t),f=c.split("\n"),l=T(e).split("\n"),h=0,p="";if("strictEqual"===r&&"object"===y(t)&&"object"===y(e)&&null!==t&&null!==e&&(r="strictEqualObject"),1===f.length&&1===l.length&&f[0]!==l[0]){var d=f[0].length+l[0].length;if(d<=10){if(!("object"===y(t)&&null!==t||"object"===y(e)&&null!==e||0===t&&0===e))return"".concat(S[r],"\n\n")+"".concat(f[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r&&d<(n.stderr&&n.stderr.isTTY?n.stderr.columns:80)){for(;f[0][h]===l[0][h];)h++;h>2&&(p="\n ".concat(function(t,e){if(e=Math.floor(e),0==t.length||0==e)return"";var r=t.length*e;for(e=Math.floor(Math.log(e)/Math.log(2));e;)t+=t,e--;return t+t.substring(0,r-t.length)}(" ",h),"^"),h=0)}}for(var b=f[f.length-1],g=l[l.length-1];b===g&&(h++<2?s="\n ".concat(b).concat(s):i=b,f.pop(),l.pop(),0!==f.length&&0!==l.length);)b=f[f.length-1],g=l[l.length-1];var k=Math.max(f.length,l.length);if(0===k){var O=c.split("\n");if(O.length>30)for(O[26]="".concat(v,"...").concat(E);O.length>27;)O.pop();return"".concat(S.notIdentical,"\n\n").concat(O.join("\n"),"\n")}h>3&&(s="\n".concat(v,"...").concat(E).concat(s),u=!0),""!==i&&(s="\n ".concat(i).concat(s),i="");var A=0,x=S[r]+"\n".concat(m,"+ actual").concat(E," ").concat(_,"- expected").concat(E),P=" ".concat(v,"...").concat(E," Lines skipped");for(h=0;h<k;h++){var I=h-a;if(f.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(v,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(l[h-2]),A++),o+="\n ".concat(l[h-1]),A++),a=h,i+="\n".concat(_,"-").concat(E," ").concat(l[h]),A++;else if(l.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(v,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(f[h-2]),A++),o+="\n ".concat(f[h-1]),A++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(f[h]),A++;else{var L=l[h],R=f[h],B=R!==L&&(!w(R,",")||R.slice(0,-1)!==L);B&&w(L,",")&&L.slice(0,-1)===R&&(B=!1,R+=","),B?(I>1&&h>2&&(I>4?(o+="\n".concat(v,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(f[h-2]),A++),o+="\n ".concat(f[h-1]),A++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(R),i+="\n".concat(_,"-").concat(E," ").concat(L),A+=2):(o+=i,i="",1!==I&&0!==h||(o+="\n ".concat(R),A++))}if(A>20&&h<k-2)return"".concat(x).concat(P,"\n").concat(o,"\n").concat(v,"...").concat(E).concat(i,"\n")+"".concat(v,"...").concat(E)}return"".concat(x).concat(u?P:"","\n").concat(o).concat(i).concat(s).concat(p)}(a,s,i));else if("notDeepStrictEqual"===i||"notStrictEqual"===i){var h=S[i],p=T(a).split("\n");if("notStrictEqual"===i&&"object"===y(a)&&null!==a&&(h=S.notStrictEqualObject),p.length>30)for(p[26]="".concat(v,"...").concat(E);p.length>27;)p.pop();e=1===p.length?l.call(this,"".concat(h," ").concat(p[0])):l.call(this,"".concat(h,"\n\n").concat(p.join("\n"),"\n"))}else{var d=T(a),b="",A=S[i];"notDeepEqual"===i||"notEqual"===i?(d="".concat(S[i],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(b="".concat(T(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),b.length>512&&(b="".concat(b.slice(0,509),"...")),"deepEqual"===i||"equal"===i?d="".concat(A,"\n\n").concat(d,"\n\nshould equal\n\n"):b=" ".concat(i," ").concat(b)),e=l.call(this,"".concat(d).concat(b))}return Error.stackTraceLimit=f,e.generatedMessage=!r,Object.defineProperty(c(e),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),e.code="ERR_ASSERTION",e.actual=a,e.expected=s,e.operator=i,Error.captureStackTrace&&Error.captureStackTrace(c(e),o),e.stack,e.name="AssertionError",u(e)}return s=O,(f=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:e,value:function(t,e){return b(this,o(o({},e),{},{customInspect:!1,depth:0}))}}])&&a(s.prototype,f),Object.defineProperty(s,"prototype",{writable:!1}),O}(f(Error),b.custom);t.exports=O},9597:(t,e,r)=>{function n(t){return n="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},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}var a,s,u={};function c(t,e,r){r||(r=Error);var a=function(r){!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&&i(t,e)}(f,r);var a,s,u,c=(s=f,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=o(s);if(u){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(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)}(this,t)});function f(r,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),o=c.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i)),o.code=t,o}return a=f,Object.defineProperty(a,"prototype",{writable:!1}),a}(r);u[t]=a}function f(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))}c("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),c("ERR_INVALID_ARG_TYPE",(function(t,e,i){var o,s,u,c,l;if(void 0===a&&(a=r(4148)),a("string"==typeof t,"'name' must be a string"),"string"==typeof e&&(s="not ",e.substr(0,4)===s)?(o="must not be",e=e.replace(/^not /,"")):o="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))u="The ".concat(t," ").concat(o," ").concat(f(e,"type"));else{var h=("number"!=typeof l&&(l=0),l+1>(c=t).length||-1===c.indexOf(".",l)?"argument":"property");u='The "'.concat(t,'" ').concat(h," ").concat(o," ").concat(f(e,"type"))}return u+". Received type ".concat(n(i))}),TypeError),c("ERR_INVALID_ARG_VALUE",(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===s&&(s=r(537));var i=s.inspect(e);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(t,"' ").concat(n,". Received ").concat(i)}),TypeError,RangeError),c("ERR_INVALID_RETURN_VALUE",(function(t,e,r){var i;return i=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(n(r)),"Expected ".concat(t,' to be returned from the "').concat(e,'"')+" function but got ".concat(i,".")}),TypeError),c("ERR_MISSING_ARGS",(function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];void 0===a&&(a=r(4148)),a(e.length>0,"At least one arg needs to be specified");var i="The ",o=e.length;switch(e=e.map((function(t){return'"'.concat(t,'"')})),o){case 1:i+="".concat(e[0]," argument");break;case 2:i+="".concat(e[0]," and ").concat(e[1]," arguments");break;default:i+=e.slice(0,o-1).join(", "),i+=", and ".concat(e[o-1]," arguments")}return"".concat(i," must be specified")}),TypeError),t.exports.codes=u},2299:(t,e,r)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(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)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(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 o(t){return o="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},o(t)}var a=void 0!==/a/g.flags,s=function(t){var e=[];return t.forEach((function(t){return e.push(t)})),e},u=function(t){var e=[];return t.forEach((function(t,r){return e.push([r,t])})),e},c=Object.is?Object.is:r(7653),f=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function h(t){return t.call.bind(t)}var p=h(Object.prototype.hasOwnProperty),d=h(Object.prototype.propertyIsEnumerable),y=h(Object.prototype.toString),b=r(537).types,g=b.isAnyArrayBuffer,w=b.isArrayBufferView,v=b.isDate,m=b.isMap,_=b.isRegExp,E=b.isSet,S=b.isNativeError,k=b.isBoxedPrimitive,T=b.isNumberObject,O=b.isStringObject,A=b.isBooleanObject,x=b.isBigIntObject,P=b.isSymbolObject,I=b.isFloat32Array,L=b.isFloat64Array;function R(t){if(0===t.length||t.length>10)return!0;for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r<48||r>57)return!0}return 10===t.length&&t>=Math.pow(2,32)}function B(t){return Object.keys(t).filter(R).concat(f(t).filter(Object.prototype.propertyIsEnumerable.bind(t)))}function N(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,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}function U(t,e,r,n){if(t===e)return 0!==t||!r||c(t,e);if(r){if("object"!==o(t))return"number"==typeof t&&l(t)&&l(e);if("object"!==o(e)||null===t||null===e)return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1}else{if(null===t||"object"!==o(t))return(null===e||"object"!==o(e))&&t==e;if(null===e||"object"!==o(e))return!1}var i,s,u=y(t);if(u!==y(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;var f=B(t),h=B(e);return f.length===h.length&&C(t,e,r,n,1,f)}if("[object Object]"===u&&(!m(t)&&m(e)||!E(t)&&E(e)))return!1;if(v(t)){if(!v(e)||Date.prototype.getTime.call(t)!==Date.prototype.getTime.call(e))return!1}else if(_(t)){if(!_(e)||!function(t,e){return a?t.source===e.source&&t.flags===e.flags:RegExp.prototype.toString.call(t)===RegExp.prototype.toString.call(e)}(t,e))return!1}else if(S(t)||t instanceof Error){if(t.message!==e.message||t.name!==e.name)return!1}else{if(w(t)){if(r||!I(t)&&!L(t)){if(!function(t,e){return t.byteLength===e.byteLength&&0===N(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}(t,e))return!1}else if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(var r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}(t,e))return!1;var p=B(t),d=B(e);return p.length===d.length&&C(t,e,r,n,0,p)}if(E(t))return!(!E(e)||t.size!==e.size)&&C(t,e,r,n,2);if(m(t))return!(!m(e)||t.size!==e.size)&&C(t,e,r,n,3);if(g(t)){if(s=e,(i=t).byteLength!==s.byteLength||0!==N(new Uint8Array(i),new Uint8Array(s)))return!1}else if(k(t)&&!function(t,e){return T(t)?T(e)&&c(Number.prototype.valueOf.call(t),Number.prototype.valueOf.call(e)):O(t)?O(e)&&String.prototype.valueOf.call(t)===String.prototype.valueOf.call(e):A(t)?A(e)&&Boolean.prototype.valueOf.call(t)===Boolean.prototype.valueOf.call(e):x(t)?x(e)&&BigInt.prototype.valueOf.call(t)===BigInt.prototype.valueOf.call(e):P(e)&&Symbol.prototype.valueOf.call(t)===Symbol.prototype.valueOf.call(e)}(t,e))return!1}return C(t,e,r,n,0)}function j(t,e){return e.filter((function(e){return d(t,e)}))}function C(t,e,r,i,a,c){if(5===arguments.length){c=Object.keys(t);var l=Object.keys(e);if(c.length!==l.length)return!1}for(var h=0;h<c.length;h++)if(!p(e,c[h]))return!1;if(r&&5===arguments.length){var y=f(t);if(0!==y.length){var b=0;for(h=0;h<y.length;h++){var g=y[h];if(d(t,g)){if(!d(e,g))return!1;c.push(g),b++}else if(d(e,g))return!1}var w=f(e);if(y.length!==w.length&&j(e,w).length!==b)return!1}else{var v=f(e);if(0!==v.length&&0!==j(e,v).length)return!1}}if(0===c.length&&(0===a||1===a&&0===t.length||0===t.size))return!0;if(void 0===i)i={val1:new Map,val2:new Map,position:0};else{var m=i.val1.get(t);if(void 0!==m){var _=i.val2.get(e);if(void 0!==_)return m===_}i.position++}i.val1.set(t,i.position),i.val2.set(e,i.position);var E=function(t,e,r,i,a,c){var f=0;if(2===c){if(!function(t,e,r,n){for(var i=null,a=s(t),u=0;u<a.length;u++){var c=a[u];if("object"===o(c)&&null!==c)null===i&&(i=new Set),i.add(c);else if(!e.has(c)){if(r)return!1;if(!D(t,e,c))return!1;null===i&&(i=new Set),i.add(c)}}if(null!==i){for(var f=s(e),l=0;l<f.length;l++){var h=f[l];if("object"===o(h)&&null!==h){if(!F(i,h,r,n))return!1}else if(!r&&!t.has(h)&&!F(i,h,r,n))return!1}return 0===i.size}return!0}(t,e,r,a))return!1}else if(3===c){if(!function(t,e,r,i){for(var a=null,s=u(t),c=0;c<s.length;c++){var f=n(s[c],2),l=f[0],h=f[1];if("object"===o(l)&&null!==l)null===a&&(a=new Set),a.add(l);else{var p=e.get(l);if(void 0===p&&!e.has(l)||!U(h,p,r,i)){if(r)return!1;if(!H(t,e,l,h,i))return!1;null===a&&(a=new Set),a.add(l)}}}if(null!==a){for(var d=u(e),y=0;y<d.length;y++){var b=n(d[y],2),g=b[0],w=b[1];if("object"===o(g)&&null!==g){if(!K(a,t,g,w,r,i))return!1}else if(!(r||t.has(g)&&U(t.get(g),w,!1,i)||K(a,t,g,w,!1,i)))return!1}return 0===a.size}return!0}(t,e,r,a))return!1}else if(1===c)for(;f<t.length;f++){if(!p(t,f)){if(p(e,f))return!1;for(var l=Object.keys(t);f<l.length;f++){var h=l[f];if(!p(e,h)||!U(t[h],e[h],r,a))return!1}return l.length===Object.keys(e).length}if(!p(e,f)||!U(t[f],e[f],r,a))return!1}for(f=0;f<i.length;f++){var d=i[f];if(!U(t[d],e[d],r,a))return!1}return!0}(t,e,r,c,i,a);return i.val1.delete(t),i.val2.delete(e),E}function F(t,e,r,n){for(var i=s(t),o=0;o<i.length;o++){var a=i[o];if(U(e,a,r,n))return t.delete(a),!0}return!1}function M(t){switch(o(t)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":t=+t;case"number":if(l(t))return!1}return!0}function D(t,e,r){var n=M(r);return null!=n?n:e.has(n)&&!t.has(n)}function H(t,e,r,n,i){var o=M(r);if(null!=o)return o;var a=e.get(o);return!(void 0===a&&!e.has(o)||!U(n,a,!1,i))&&!t.has(o)&&U(n,a,!1,i)}function K(t,e,r,n,i,o){for(var a=s(t),u=0;u<a.length;u++){var c=a[u];if(U(r,c,i,o)&&U(n,e.get(c),i,o))return t.delete(c),!0}return!1}t.exports={isDeepEqual:function(t,e){return U(t,e,!1)},isDeepStrictEqual:function(t,e){return U(t,e,!0)}}},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 a=t.length,s=t.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function f(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]===s;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var l=0,h=o-1;(0!==f||l<i)&&-1!==h;h--,l++)f+=a*c[h]>>>0,c[h]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=l,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,f=new Uint8Array(u);i!==o;){for(var l=e[i],h=0,p=u-1;(0!==l||h<n)&&-1!==p;p--,h++)l+=256*f[p]>>>0,f[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===f[d];)d++;for(var y=s.repeat(r);d<u;++d)y+=t.charAt(f[d]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},7526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),f=0,l=u>0?a-4:a;for(r=0;r<l;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[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,c=n-i;s<c;s+=a)o.push(u(t,s,s+a>c?c:s+a));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+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(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,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.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 a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).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),f=t.slice(u+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);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");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:c}}e.bech32=f("bech32"),e.bech32m=f("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 a(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),s=t.slice(1);if(0===s.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=a(r.globalKeyVals),f=r.inputKeyVals.map(a),l=r.outputKeyVals.map(a);for(const t of s){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 s=n.psbtToKeyVals(t);a(s.globalKeyVals).forEach(i(c,r.globalKeyVals,s.globalKeyVals)),s.inputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],s.inputKeyVals[e])))),s.outputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(l[e],r.outputKeyVals[e],s.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(t=>[...Array(t).keys()])(t.value.length/4-1)){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),a=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(a,0);let s=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),a.writeUInt32LE(r,s),s+=4})),{key:r,value:a}},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),a=r(6605),s=r(1795),u=r(4431),c=r(6907),f=r(5949),l=r(9344),h=r(2760),p=r(1695),d=r(8454),y=r(9034),b=r(2926),g=r(7851),w=r(7545),v=r(2412),m=r(4307),_=r(7636),E=r(2223),S=r(5578),k={unsignedTx:o,globalXpub:i,checkPubkey:v.makeChecker([])};e.globals=k;const T={nonWitnessUtxo:u,partialSig:c,sighashType:l,finalScriptSig:a,finalScriptWitness:s,porCommitment:f,witnessUtxo:b,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:v.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:_.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:E.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=T;const O={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:v.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:_.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:g,tapInternalKey:E.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=O},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),a=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=a.decode(t.value,r);r+=a.encodingLength(n);const s=t.value.slice(r);if(s.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:s,value:e}},e.encode=function(t){const{script:e,value:r}=t,s=a.encodingLength(e.length),u=n.allocUnsafe(8+s+e.length);return o.writeUInt64LE(u,r,0),a.encode(e.length,u,8),e.copy(u,8+s),{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++],a=o.decode(t.value,e);e+=o.encodingLength(a),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+a)}),e+=a}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(t=>[...Array(t).keys()])(r.value.length/4-1)){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),a=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(a,0);let s=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),a.writeUInt32LE(r,s),s+=4})),{key:i,value:a}},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),a=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,a);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)}),a=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)a[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:a})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),a=n.allocUnsafe(o);i.encode(t.leafHashes.length,a);const s=n.concat([a,...t.leafHashes,r.value]);return Object.assign({},r,{value:s})},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),a=i.encodingLength(r),s=n.allocUnsafe(o+e+a+r);return i.encode(e,s,0),t.key.copy(s,o),i.encode(r,s,o+e),t.value.copy(s,o+e+a),s}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")}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,a(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return a(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;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+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 o=e.readUInt8(r);if(o<253)return Object.assign(t,{bytes:1}),o;if(253===o)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===o)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),o=4294967296*e.readUInt32LE(r+5)+n;return i(o),o}},e.encodingLength=o},6263:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133),a=r(394),s=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 a={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case s.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,s.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case s.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(i.globals.globalXpub.decode(t));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(t)}const f=r.length,l=n.length,h=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case s.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,s.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 s.InputTypes.WITNESS_UTXO:if(u("input",n.key,s.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 s.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case s.InputTypes.SIGHASH_TYPE:if(u("input",n.key,s.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 s.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,s.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 s.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,s.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 s.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case s.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,s.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case s.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,s.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case s.InputTypes.POR_COMMITMENT:u("input",n.key,s.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case s.InputTypes.TAP_KEY_SIG:u("input",n.key,s.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case s.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case s.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case s.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case s.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,s.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case s.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,s.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(l)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case s.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,s.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 s.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,s.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 s.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case s.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,s.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case s.OutputTypes.TAP_TREE:u("output",r.key,s.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case s.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:a,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=a.decode(t,r);r+=a.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 f=[],l={};for(;!u();){const t=i(),e=t.key.toString("hex");if(l[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);l[e]=1,f.push(t)}const h=f.filter((t=>t.key[0]===s.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(),b=[],g=[];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)}b.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)}g.push(r)}return c(p,{globalMapKeyVals:f,inputKeyVals:b,outputKeyVals:g})},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:a,outputKeyVals:s}=u({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),l=f(a),h=f(s),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(l,h))};const a=(t,e)=>t.key.compare(e.key);function s(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 a=(Array.isArray(i)?i:[i]).map(o.encode);return a.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(a)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(a)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:s(t,i.globals),inputKeyVals:e.map((t=>s(t,i.inputs))),outputKeyVals:r.map((t=>s(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),a=r(9080),s=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 s.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=s.checkForInput(this.inputs,t);return s.updateInput(e,r),this}updateOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return s.checkHasKey(t,this.globalMap.unknownKeyVals,s.getEnumLength(a.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=s.checkForInput(this.inputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.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))),s.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))),s.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=s.checkForInput(this.inputs,t);s.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 a(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function s(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:a,canAddToArray:u,check:c,expected:f}=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)||s(t,n,f,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)||s(t,n,f,o),!a(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=a,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,a=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&a}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=a(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}},4642:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.BIP32Factory=void 0;const i=r(9571),o=r(7757),a=r(3203),s=r(2623),u=r(8676),c=r(7513),f=(0,a.base58check)(s.sha256);e.BIP32Factory=function(t){(0,o.testEcc)(t);const e=u.BufferN(32),r=u.compile({wif:u.UInt8,bip32:{public:u.UInt32,private:u.UInt32}}),a={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},s=2147483648,l=Math.pow(2,31)-1;function h(t){return u.String(t)&&null!==t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function p(t){return u.UInt32(t)&&t<=l}class d{constructor(t,e){this.__D=t,this.__Q=e,this.lowR=!1}get publicKey(){return void 0===this.__Q&&(this.__Q=n.from(t.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.privateKey));{let r=n.from(t.sign(e,this.privateKey));const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=n.from(t.sign(e,this.privateKey,i));return 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)}}class y extends d{constructor(t,e,n,i,o=0,a=0,s=0){super(t,e),this.chainCode=n,this.network=i,this.__DEPTH=o,this.__INDEX=a,this.__PARENT_FINGERPRINT=s,u(r,i)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return i.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return w(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=n.allocUnsafe(78);return r.writeUInt32BE(e,0),r.writeUInt8(this.depth,4),r.writeUInt32BE(this.parentFingerprint,5),r.writeUInt32BE(this.index,9),this.chainCode.copy(r,13),this.isNeutered()?this.publicKey.copy(r,45):(r.writeUInt8(0,45),this.privateKey.copy(r,46)),i=r,f.encode(Uint8Array.from(i));var i}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return c.encode(this.network.wif,this.privateKey,!0)}derive(e){u(u.UInt32,e);const r=e>=s,o=n.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");o[0]=0,this.privateKey.copy(o,1),o.writeUInt32BE(e,33)}else this.publicKey.copy(o,0),o.writeUInt32BE(e,33);const a=i.hmacSHA512(this.chainCode,o),c=a.slice(0,32),f=a.slice(32);if(!t.isPrivate(c))return this.derive(e+1);let l;if(this.isNeutered()){const r=n.from(t.pointAddScalar(this.publicKey,c,!0));if(null===r)return this.derive(e+1);l=w(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const r=n.from(t.privateAdd(this.privateKey,c));if(null==r)return this.derive(e+1);l=g(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return l}deriveHardened(t){return u(p,t),this.derive(t+s)}derivePath(t){u(h,t);let e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=n.from([0===o.parity?2:3]),s=n.concat([a,o.xOnlyPubkey]);return new d(void 0,s)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&!(1&~this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error("Invalid tweaked private key!");return new d(n.from(o),void 0)}}function b(t,e,r){return g(t,e,r)}function g(r,n,i,o,s,c){if(u({privateKey:e,chainCode:e},{privateKey:r,chainCode:n}),i=i||a,!t.isPrivate(r))throw new TypeError("Private key not in range [1, n)");return new y(r,void 0,n,i,o,s,c)}function w(r,n,i,o,s,c){if(u({publicKey:u.BufferN(33),chainCode:e},{publicKey:r,chainCode:n}),i=i||a,!t.isPoint(r))throw new TypeError("Point is not on the curve");return new y(void 0,r,n,i,o,s,c)}return{fromSeed:function(t,e){if(u(u.Buffer,t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");e=e||a;const r=i.hmacSHA512(n.from("Bitcoin seed","utf8"),t);return b(r.slice(0,32),r.slice(32),e)},fromBase58:function(t,e){const r=(i=t,n.from(f.decode(i)));var i;if(78!==r.length)throw new TypeError("Invalid buffer length");e=e||a;const o=r.readUInt32BE(0);if(o!==e.bip32.private&&o!==e.bip32.public)throw new TypeError("Invalid network version");const s=r[4],u=r.readUInt32BE(5);if(0===s&&0!==u)throw new TypeError("Invalid parent fingerprint");const c=r.readUInt32BE(9);if(0===s&&0!==c)throw new TypeError("Invalid index");const l=r.slice(13,45);let h;if(o===e.bip32.private){if(0!==r.readUInt8(45))throw new TypeError("Invalid private key");h=g(r.slice(46,78),l,e,s,c,u)}else h=w(r.slice(45,78),l,e,s,c,u);return h},fromPublicKey:function(t,e,r){return w(t,e,r)},fromPrivateKey:b}}},9571:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.hmacSHA512=e.hash160=void 0;const i=r(9615),o=r(3238),a=r(2623),s=r(102);e.hash160=function(t){const e=(0,a.sha256)(Uint8Array.from(t));return n.from((0,o.ripemd160)(e))},e.hmacSHA512=function(t,e){return n.from((0,i.hmac)(s.sha512,t,e))}},852:(t,e,r)=>{e.Pr=e.Ay=void 0;var n=r(4642);Object.defineProperty(e,"Ay",{enumerable:!0,get:function(){return n.BIP32Factory}}),Object.defineProperty(e,"Pr",{enumerable:!0,get:function(){return n.BIP32Factory}})},7757:(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){if(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.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),t.xOnlyPointAddTweak){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(t.pointAddScalar(i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("0000000000000000000000000000000000000000000000000000000000000003"))).equals(i("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),o(n.from(t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000002"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),t.privateNegate&&(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.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")))}},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),a=r(7038),s=r(8116),u=r(2343),c=r(1889),f="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 l(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=l,e.fromBech32=h,e.toBase58Check=function(t,e){(0,s.typeforce)((0,s.tuple)(s.Hash160bit,s.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(f),p(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(a.toASM(t)+" has no matching Address")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=l(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(f),a.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),a=r(1015),s=r(2021),u=r(8116),{typeforce:c}=u,f=new TypeError("Cannot compute merkle root for zero transactions"),l=new TypeError("Cannot compute witness commit for non-segwit block");class h{version=1;prevHash=void 0;merkleRoot=void 0;timestamp=0;witnessCommit=void 0;bits=0;nonce=0;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=s.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 a=r.getWitnessCommit();return a&&(r.witnessCommit=a),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 f;if(e&&!p(t))throw l;const r=t.map((t=>t.getHash(e))),i=(0,a.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 f;const t=h.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw l;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),o=r(8469);e.varuint=o;const{typeforce:a}=i;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")}function u(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,s(n+r,9007199254740991),n+r}function c(t,e,r){return s(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}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 f{buffer;offset;constructor(t,e=0){this.buffer=t,this.offset=e,a(i.tuple(i.Buffer,i.UInt32),[t,e])}static withCapacity(t){return new f(n.alloc(t))}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){o.encode(t,this.buffer,this.offset),this.offset+=o.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=f,e.BufferReader=class{buffer;offset;constructor(t,e=0){this.buffer=t,this.offset=e,a(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=o.decode(this.buffer,this.offset);return this.offset+=o.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),a=r(2623);function s(t){return n.from((0,a.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=s,e.hash160=function(t){return n.from((0,i.ripemd160)((0,a.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,a.sha256)((0,a.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 s(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&&(a("function"==typeof(e=t).isXOnlyPoint),a(e.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),a(e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),a(e.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),a(e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),a(!e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),a(!e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),a("function"==typeof e.xOnlyPointAddTweak),s.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?a(null===r):(a(null!==r),a(r.parity===t.parity),a(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 a(t){if(!t)throw new Error("ecc library invalid")}const s=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},2035:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AdvancedSignatureManager=void 0;class r{static instance;cacheBySigner=new Map;registry;constructor(){this.registry=new FinalizationRegistry((t=>{const e=this.cacheBySigner.get(t.pubKey);e&&(e.delete(t),0===e.size&&this.cacheBySigner.delete(t.pubKey))}))}static getInstance(){return r.instance||(r.instance=new r),r.instance}addSignature(t,e,r){const n={pubKey:t,dataRef:new WeakRef(e),signature:r};return this.cacheBySigner.has(t)||this.cacheBySigner.set(t,new Set),this.cacheBySigner.get(t).add(n),this.registry.register(e,n),r}getSignature(t,e){const r=this.cacheBySigner.get(t);if(r)for(const t of r){const r=t.dataRef.deref();if(r&&r.equals(e))return t.signature}}clearCache(){this.cacheBySigner.clear()}clearCacheForSigner(t){this.cacheBySigner.delete(t)}}e.AdvancedSignatureManager=r},3352:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.hookSigner=void 0;const i=r(7585),o=r(2035).AdvancedSignatureManager.getInstance();function a(t){if(t.publicKey&&n.isBuffer(t.publicKey))return t.publicKey.toString("hex")}e.hookSigner=function(t){const e=t;e.hasHook||(e.hasHook=!0,e.signatureManager=new i.SignatureManager,function(t){const e=t.sign;e&&(t.sign=new Proxy(e,{apply:function(e,r,n){const i=a(t),s=n[0];if(i){let t=o.getSignature(i,s);return t||(t=o.addSignature(i,s,Reflect.apply(e,r,n))),t}{let i=t.signatureManager.getSignature(s);return i||(i=t.signatureManager.addSignature(s,Reflect.apply(e,r,n))),i}}}));const r=t.signSchnorr;r&&(t.signSchnorr=new Proxy(r,{apply:function(e,r,n){const i=a(t),s=n[0];if(i){let t=o.getSignature(i,s);return t||(t=o.addSignature(i,s,Reflect.apply(e,r,n))),t}{let i=t.signatureManager.getSignature(s);return i||(i=t.signatureManager.addSignature(s,Reflect.apply(e,r,n))),i}}}))}(e))}},7585:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignatureManager=void 0,e.SignatureManager=class{cacheByLength=new Map;registry;constructor(){this.registry=new FinalizationRegistry((t=>{const e=this.cacheByLength.get(t.length);e&&(e.delete(t),0===e.size&&this.cacheByLength.delete(t.length))}))}addSignature(t,e){const r=t.length,n={length:r,dataRef:new WeakRef(t),signature:e};return this.cacheByLength.has(r)||this.cacheByLength.set(r,new Set),this.cacheByLength.get(r).add(n),this.registry.register(t,n),e}getSignature(t){const e=t.length,r=this.cacheByLength.get(e);if(r)for(const e of r){const r=e.dataRef.deref();if(r&&r.equals(t))return e.signature}}clearCache(){this.cacheByLength.clear()}}},1757:(t,e,r)=>{e.f0=e.ZX=e.Ez=e.iL=e.K$=e.KT=e.o8=e.Et=e.hl=void 0;const n=r(57);e.hl=n;const i=r(1944);e.Et=i;const o=r(622);e.o8=o;const a=r(885);e.KT=a;const s=r(7038);e.K$=s;r(1696);var u=r(9646);Object.defineProperty(e,"iL",{enumerable:!0,get:function(){return u.Psbt}});var c=r(8417);Object.defineProperty(e,"Ez",{enumerable:!0,get:function(){return c.OPS}});var f=r(2021);Object.defineProperty(e,"ZX",{enumerable:!0,get:function(){return f.Transaction}});var l=r(916);Object.defineProperty(e,"f0",{enumerable:!0,get:function(){return l.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 a=i[o],s=o+1===r?a:i[o+1],u=n.concat([a,s]);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),a=r(606),s=r(8116);function u(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),l(t.output)]))}function c(t,e){return o.taggedHash("TapTweak",n.Buffer.concat(e?[t,e]:[t]))}function f(t,e){return o.taggedHash("TapBranch",n.Buffer.concat([t,e]))}function l(t){const e=a.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return a.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?f(n,r):f(r,n)}return n},e.toHashTree=function t(e){if((0,s.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:f(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),a=r(7883),s=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(a.prop(r,"output",(()=>{if(t.data)return i.compile([s.OP_RETURN].concat(t.data))})),a.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]!==s.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&&!(0,o.stacksEqual)(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 a=r(3504);Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return a.p2pkh}});const s=r(8368);Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return s.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 f=r(5501);Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return f.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),a=r(7883),s=i.OPS,u=s.OP_RESERVED;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===s.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 c={network:t.network||n.bitcoin};let f=[],l=!1;function h(t){l||(l=!0,f=i.decompile(t),c.m=f[0]-u,c.n=f[f.length-2]-u,c.pubkeys=f.slice(1,-2))}if(a.prop(c,"output",(()=>{if(t.m&&c.n&&t.pubkeys)return i.compile([].concat(u+t.m,t.pubkeys,u+c.n,s.OP_CHECKMULTISIG))})),a.prop(c,"m",(()=>{if(c.output)return h(c.output),c.m})),a.prop(c,"n",(()=>{if(c.pubkeys)return c.pubkeys.length})),a.prop(c,"pubkeys",(()=>{if(t.output)return h(t.output),c.pubkeys})),a.prop(c,"signatures",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),a.prop(c,"input",(()=>{if(t.signatures)return i.compile([s.OP_0].concat(t.signatures))})),a.prop(c,"witness",(()=>{if(c.input)return[]})),a.prop(c,"name",(()=>{if(c.m&&c.n)return`p2ms(${c.m} of ${c.n})`})),e.validate){if(t.output){if(h(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]!==s.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(c.m<=0||c.n>16||c.m>c.n||c.n!==f.length-3)throw new TypeError("Output is invalid");if(!c.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==c.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==c.n)throw new TypeError("n mismatch");if(t.pubkeys&&!(0,o.stacksEqual)(t.pubkeys,c.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(c.n=t.pubkeys.length,c.n<c.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<c.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>c.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==s.OP_0)throw new TypeError("Input is invalid");if(0===c.signatures.length||!c.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!(0,o.stacksEqual)(t.signatures,c.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(c,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),a=r(7883),s=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=a.value((()=>i.decompile(t.input))),u={name:"p2pk",network:t.network||n.bitcoin};if(a.prop(u,"output",(()=>{if(t.pubkey)return i.compile([t.pubkey,s.OP_CHECKSIG])})),a.prop(u,"pubkey",(()=>{if(t.output)return t.output.slice(1,-1)})),a.prop(u,"signature",(()=>{if(t.input)return r()[0]})),a.prop(u,"input",(()=>{if(t.signature)return i.compile([t.signature])})),a.prop(u,"witness",(()=>{if(u.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==s.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),a=r(7038),s=r(8116),u=r(7883),c=r(1889),f=a.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,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(20)),output:s.typeforce.maybe(s.typeforce.BufferN(25)),pubkey:s.typeforce.maybe(s.isPoint),signature:s.typeforce.maybe(a.isCanonicalScriptSignature),input:s.typeforce.maybe(s.typeforce.Buffer)},t);const r=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),l=u.value((()=>a.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 a.compile([f.OP_DUP,f.OP_HASH160,p.hash,f.OP_EQUALVERIFY,f.OP_CHECKSIG])})),u.prop(p,"pubkey",(()=>{if(t.input)return l()[1]})),u.prop(p,"signature",(()=>{if(t.input)return l()[0]})),u.prop(p,"input",(()=>{if(t.pubkey&&t.signature)return a.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]!==f.OP_DUP||t.output[1]!==f.OP_HASH160||20!==t.output[2]||t.output[23]!==f.OP_EQUALVERIFY||t.output[24]!==f.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=l();if(2!==r.length)throw new TypeError("Input is invalid");if(!a.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,s.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),a=r(7038),s=r(8116),u=r(7883),c=r(1889),f=a.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,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(20)),output:s.typeforce.maybe(s.typeforce.BufferN(23)),redeem:s.typeforce.maybe({network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.Buffer),input:s.typeforce.maybe(s.typeforce.Buffer),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),input:s.typeforce.maybe(s.typeforce.Buffer),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const l={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((()=>a.decompile(t.input))),d=u.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===f.OP_FALSE?n.from([]):i,input:a.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(u.prop(l,"address",(()=>{if(!l.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(l.network.scriptHash,0),l.hash.copy(t,1),c.encode(t)})),u.prop(l,"hash",(()=>t.output?t.output.slice(2,22):t.address?h().hash:l.redeem&&l.redeem.output?i.hash160(l.redeem.output):void 0)),u.prop(l,"output",(()=>{if(l.hash)return a.compile([f.OP_HASH160,l.hash,f.OP_EQUAL])})),u.prop(l,"redeem",(()=>{if(t.input)return d()})),u.prop(l,"input",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return a.compile([].concat(a.decompile(t.redeem.input),t.redeem.output))})),u.prop(l,"witness",(()=>l.redeem&&l.redeem.witness?l.redeem.witness:l.input?[]:void 0)),u.prop(l,"name",(()=>{const t=["p2sh"];return void 0!==l.redeem&&void 0!==l.redeem.name&&t.push(l.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]!==f.OP_HASH160||20!==t.output[1]||t.output[22]!==f.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=a.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(a.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=a.decompile(t.input);if(!a.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&&!(0,s.stacksEqual)(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(l,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),a=r(8116),s=r(916),u=r(2218),c=r(7883),f=r(2343),l=r(57),h=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,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(34)),internalPubkey:a.typeforce.maybe(a.typeforce.BufferN(32)),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),pubkey:a.typeforce.maybe(a.typeforce.BufferN(32)),signature:a.typeforce.maybe(a.typeforce.anyOf(a.typeforce.BufferN(64),a.typeforce.BufferN(65))),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer)),scriptTree:a.typeforce.maybe(a.isTaptree),redeem:a.typeforce.maybe({output:a.typeforce.maybe(a.typeforce.Buffer),redeemVersion:a.typeforce.maybe(a.typeforce.Number),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),redeemVersion:a.typeforce.maybe(a.typeforce.Number)},t);const r=c.value((()=>(0,l.fromBech32)(t.address))),p=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()})),d=c.value((()=>t.scriptTree?(0,u.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),y=t.network||i.bitcoin,b={name:"p2tr",network:y};if(c.prop(b,"address",(()=>{if(!b.pubkey)return;const t=f.bech32m.toWords(b.pubkey);return t.unshift(1),f.bech32m.encode(y.bech32,t)})),c.prop(b,"hash",(()=>{const t=d();if(t)return t.hash;const e=p();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&a.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(b,"output",(()=>{if(b.pubkey)return o.compile([h.OP_1,b.pubkey])})),c.prop(b,"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(b,"redeem",(()=>{const t=p();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&a.TAPLEAF_VERSION_MASK}})),c.prop(b,"pubkey",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(b.internalPubkey){const t=(0,u.tweakKey)(b.internalPubkey,b.hash);if(t)return t.x}})),c.prop(b,"internalPubkey",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=p();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),c.prop(b,"signature",(()=>{if(t.signature)return t.signature;const e=p();return e&&1===e.length?e[0]:void 0})),c.prop(b,"witness",(()=>{if(t.witness)return t.witness;const e=d();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,u.tapleafHash)({output:t.redeem.output,version:b.redeemVersion}),i=(0,u.findScriptPath)(e,r);if(!i)return;const o=(0,u.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const a=n.Buffer.concat([n.Buffer.from([b.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,a]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(y&&y.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]!==h.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,b.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError("Pubkey mismatch");e=r.x}if(e&&e.length&&!(0,s.getEccLib)().isXOnlyPoint(e))throw new TypeError("Invalid pubkey for p2tr");const i=d();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:b.redeemVersion});if(!(0,u.findScriptPath)(i,e))throw new TypeError("Redeem script not in tree")}const c=p();if(t.redeem&&b.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==b.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(b.redeem.output&&!t.redeem.output.equals(b.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&b.redeem.witness&&!(0,a.stacksEqual)(t.redeem.witness,b.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,s.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&a.TAPLEAF_VERSION_MASK,f=c[c.length-2],l=(0,u.tapleafHash)({output:f,version:o}),h=(0,u.rootHashFromPath)(r,l),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(b,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),a=r(7038),s=r(8116),u=r(7883),c=r(2343),f=a.OPS,l=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,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(20)),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(22)),pubkey:s.typeforce.maybe(s.isPoint),signature:s.typeforce.maybe(a.isCanonicalScriptSignature),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.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 a.compile([f.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 l})),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]!==f.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,s.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(!a.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,s.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),a=r(7038),s=r(8116),u=r(7883),c=r(2343),f=a.OPS,l=n.alloc(0);function h(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,s.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,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),output:s.typeforce.maybe(s.typeforce.BufferN(34)),redeem:s.typeforce.maybe({input:s.typeforce.maybe(s.typeforce.Buffer),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.Buffer),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),input:s.typeforce.maybe(s.typeforce.BufferN(0)),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.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((()=>a.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 a.compile([f.OP_0,y.hash])})),u.prop(y,"redeem",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:l,witness:t.witness.slice(0,-1)}})),u.prop(y,"input",(()=>{if(y.witness)return l})),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=a.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=l,[].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]!==f.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=a.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(a.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&&!a.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!(0,s.stacksEqual)(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&p().some(h)||t.redeem.output&&(a.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)||(a.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),a=r(5080),s=r(57),u=r(606),c=r(622),f=r(885),l=r(2218),h=r(7038),p=r(2021),d=r(477),y=r(4929),b=r(3352),g={network:c.bitcoin,maximumFeeRate:5e3};class w{data;__CACHE;opts;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,s.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,u.cloneBuffer)(t.script),value:t.value,address:e}}))}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,v),n=new w(e,r);var o,a;return o=n.__CACHE.__TX,a=n.__CACHE,o.ins.forEach((t=>{x(a,t)})),n}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){return w.fromBuffer(this.data.toBuffer(),JSON.parse(JSON.stringify(this.opts)))}setMaximumFeeRate(t){T(t),this.opts.maximumFeeRate=t}setVersion(t){T(t),O(this.data.inputs,"setVersion");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){T(t),O(this.data.inputs,"setLocktime");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){T(e),O(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,e=!0){return t.forEach((t=>this.addInput(t,e))),this}addInput(t,e=!0){if(!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"),e&&O(this.data.inputs,"addInput"),t.witnessScript&&$(t.witnessScript);const r=this.__CACHE;this.data.addInput(t),x(r,r.__TX.ins[r.__TX.ins.length-1]);const n=this.data.inputs.length-1,i=this.data.inputs[n];return i.nonWitnessUtxo&&K(this.__CACHE,i,n),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__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]");O(this.data.inputs,"addOutput");const{address:e}=t;if("string"==typeof e){const{network:r}=this.opts,n=(0,s.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,e){if(e&&(this.data.inputs=this.data.inputs.filter((t=>!t.partialSig))),!this.data.inputs.every(S))throw new Error("Not finalized");const r=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,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return W(this.data.inputs,n,r,!0,e),n}getFeeRate(t=!1){return R("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE,t)}getFee(t=!1){return R("__FEE","fee",this.data.inputs,this.__CACHE,t)}finalizeAllInputs(){return(0,a.checkForInput)(this.data.inputs,0),Z(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,a.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,a.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.`)}getInputType(t){const e=(0,a.checkForInput)(this.data.inputs,t),r=X(V(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)&&!q(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!q(r)&&h.decompile(r)?r:void 0}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+Y(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=V(r,e,n),{meaningfulScript:o}=X(i,r,"input",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,a.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,a.checkForInput)(this.data.inputs,t),n=k(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}=X(i,r,"output",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,a.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,a.checkForOutput)(this.data.outputs,t),n=k(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){return(0,a.checkForInput)(this.data.inputs,0),Z(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)}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 Z(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 Z(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 D(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=D(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 Z(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,a.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,a.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.`)}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,a.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,a.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.`)}))}toBuffer(){return _(this.__CACHE),this.data.toBuffer()}toHex(){return _(this.__CACHE),this.data.toHex()}toBase64(){return _(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&$(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&K(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}_finalizeInput(t,e,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:a}=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=G(r,e,t),a=n.ins[t].index;i.script=o.outs[a].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:s,finalScriptWitness:u}=r(t,e,n,a,i,o);if(s&&this.data.updateInput(t,{finalScriptSig:s}),u&&this.data.updateInput(t,{finalScriptWitness:u}),!s&&!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=f.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}_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 a=[];let s,u,c;for(const r of o){const i=h.signature.decode(r.signature),{hash:o,script:f}=c!==i.hashType?U(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:s,script:u};c=i.hashType,s=o,u=f,A(r.pubkey,f,"verify"),a.push(e(r.pubkey,o,i.signature))}return a.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 a=(r=r&&(0,d.toXOnly)(r))?F(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=j(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=>F(t,e,r,i,n))).flat()}(t,n,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const s=a.find((t=>!t.leafHash));let u=0;if(i&&s){if(!e(s.pubkey,s.hash,C(i)))return!1;u++}if(o)for(const t of o){const r=a.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,C(t.signature)))return!1;u++}}return u>0}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){(0,b.hookSigner)(e);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]){(0,b.hookSigner)(r);const o=this.checkTaprootHashesForSig(t,e,r,n,i),a=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],s=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 a&&this.data.updateInput(t,{tapKeySig:a}),s.length&&this.data.updateInput(t,{tapScriptSig:s}),this}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){(0,b.hookSigner)(e);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]){(0,b.hookSigner)(r);const o=this.checkTaprootHashesForSig(t,e,r,n,i),a=[],s=o.filter((t=>!t.leafHash))[0];if(s){const t=Promise.resolve(r.signSchnorr(s.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));a.push(t)}const u=o.filter((t=>!!t.leafHash));if(u.length){const t=u.map((async t=>{const n=await r.signSchnorr(t.hash);return{tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]}}));a.push(...t)}const c=await Promise.all(a);for(const e of c)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=F(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}}e.Psbt=w;const v=t=>new m(t);class m{tx;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 _(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 S(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function k(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function T(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function O(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 A(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 x(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 P(t,e){return(r,n,i,o)=>{const a=t({redeem:{output:i}}).output;if(!n.equals(a))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const I=P(f.p2sh,"Redeem script"),L=P(f.p2wsh,"Witness script");function R(t,e,r,n,i=!1){if(!r.every(S))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 o,a=!0;return n.__EXTRACTED_TX?(o=n.__EXTRACTED_TX,a=!1):o=n.__TX.clone(),W(r,o,n,a,i),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function B(t,e,r,n,i,o){const a=Y(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return E(1,t.partialSig);case"multisig":const r=f.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,a))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let a,s;const u=function(t,e,r){let n;switch(e){case"multisig":const e=function(t,e){return f.p2ms({output:t}).pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=f.p2ms({output:t,signatures:e});break;case"pubkey":n=f.p2pk({output:t,signature:r[0].signature});break;case"pubkeyhash":n=f.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=f.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?f.p2wsh({redeem:u}):null,l=i?f.p2sh({redeem:c||u}):null;return n?(s=c?(0,y.witnessStackToScriptWitness)(c.witness):(0,y.witnessStackToScriptWitness)(u.witness),l&&(a=l.input)):a=l?l.input:u.input,{finalScriptSig:a,finalScriptWitness:s}}(r,a,e.partialSig,n,i,o)}function N(t,e,r,n,i){const o=(0,a.checkForInput)(t,e),{hash:s,sighashType:u,script:c}=U(e,o,n,!1,i);return A(r,c,"sign"),{hash:s,sighashType:u}}function U(t,e,r,n,i){const o=r.__TX,a=e.sighashType||p.Transaction.SIGHASH_ALL;let s,u;if(M(a,i),e.nonWitnessUtxo){const n=G(r,e,t),i=o.ins[t].hash,a=n.getHash();if(!i.equals(a))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const s=o.ins[t].index;u=n.outs[s]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=e.witnessUtxo}const{meaningfulScript:c,type:l}=X(u.script,t,"input",e.redeemScript,e.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(l)>=0)s=o.hashForWitnessV0(t,c,u.value,a);else if((0,y.isP2WPKH)(c)){const e=f.p2pkh({hash:c.slice(2)}).output;s=o.hashForWitnessV0(t,e,u.value,a)}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 predecessor (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*********************"),s=o.hashForSignature(t,c,a)}return{script:c,sighashType:a,hash:s}}function j(t,e,r){const{script:n}=z(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function C(t){return 64===t.length?t:t.subarray(0,64)}function F(t,e,r,i,o,a,s){const u=o.__TX,c=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(c,s);const f=r.map(((t,e)=>z(e,t,o))),h=f.map((t=>t.script)),b=f.map((t=>t.value)),g=[];if(e.tapInternalKey&&!a){const r=j(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=u.hashForWitnessV1(t,h,b,c);g.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,l.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!a||a.equals(t.hash))).map((e=>{const r=u.hashForWitnessV1(t,h,b,c,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return g.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 D(t,e,r){const n=(0,a.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 o=0;o<n;o++)i.push(function(r){return e+=r,t.slice(e-r,e)}(r()));return i}()}function K(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 W(t,e,r,n,i){let o=0;t.forEach(((t,i)=>{if(n&&t.finalScriptSig&&(e.ins[i].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[i].witness=H(t.finalScriptWitness)),t.witnessUtxo)o+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=G(r,t,i),a=e.ins[i].index,s=n.outs[a];o+=s.value}}));const a=e.outs.reduce(((t,e)=>t+e.value),0),s=o-a;if(!i&&s<0)throw new Error("Outputs are spending more than Inputs");const u=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/u)}function G(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||K(t,e,r),n[r]}function V(t,e,r){const{script:n}=z(t,e,r);return n}function z(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=G(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 q(t){return 33===t.length&&h.isCanonicalPubKey(t)}function X(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),a=o&&n&&(0,y.isP2WSHScript)(n),s=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((s||a)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return a?(u=i,I(e,t,n,r),L(e,n,i,r),$(u)):s?(u=i,L(e,t,i,r),$(u)):o?(u=n,I(e,t,n,r)):u=t,{meaningfulScript:u,type:a?"p2sh-p2wsh":o?"p2sh":s?"p2wsh":"raw"}}function $(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Y(t){return(0,y.isP2WPKH)(t)?"witnesspubkeyhash":(0,y.isP2PKH)(t)?"pubkeyhash":(0,y.isP2MS)(t)?"multisig":(0,y.isP2PK)(t)?"pubkey":"nonstandard"}function Z(t){return[...Array(t).keys()]}},477:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.getTapKeySigFromWithness=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),a=r(4929),s=r(2218),u=r(885);function c(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,a.isP2TR)(t.witnessUtxo.script))}function f(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,a.isP2TR)(e))}function l(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 h(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function p(t){if(!t)return;const e=t.slice(2);return 64===e.length||65===e.length?e:void 0}function d(t,e=[],r=0){if(r>s.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||s.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>s.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 b(t,e){if(!e)return!0;const r=(0,s.tapleafHash)({output:t.script,version:t.leafVersion});return(0,s.rootHashFromPath)(t.controlBlock,r).equals(e)}function g(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,s.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,s.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,a.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,a.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=c,e.isTaprootOutput=f,e.checkTaprootInputFields=function(t,e,r){!function(t,e,r){const n=c(t)&&g(e),i=g(t)&&c(e),o=t===e&&c(e)&&g(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=>b(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>b(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((e=>b(e,t.tapMerkleRoot)));if(!n)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)&&g(e),i=g(t)&&f(e),o=t===e&&f(e)&&g(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&&l(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,s.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=l,e.checkTaprootInputForSigs=function(t,e){const r=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=p(t.finalScriptWitness);r&&e.push(r)}return e}(t);return r.some((t=>(0,a.signatureBlocksAction)(t,h,e)))},e.getTapKeySigFromWithness=p},4929:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.getPsigsFromInputFinalScripts=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),a=r(2021),s=r(1944),u=r(885);function c(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function f(t,e){const r=(0,s.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 l(t,e,r){const{hashType:n}=e(t),i=[];switch(n&a.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case a.Transaction.SIGHASH_ALL:break;case a.Transaction.SIGHASH_SINGLE:case a.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}function h(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})))}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=f,e.pubkeyInScript=function(t,e){return-1!==f(t,e)},e.checkInputForSig=function(t,e){const r=function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=h(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t);return r.some((t=>l(t,o.signature.decode,e)))},e.signatureBlocksAction=l,e.getPsigsFromInputFinalScripts=h},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 a=r(4344),s=r(9464),u=r(1043),c=r(8116),{typeforce:f}=c,l=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?l+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function b(t){return n.isBuffer(t)}function g(t){if(y(t))return t;f(c.Array,t);const e=t.reduce(((t,e)=>b(e)?1===e.length&&void 0!==d(e)?t+1:t+a.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(b(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=a.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;f(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=a.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 v(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=g,e.decompile=w,e.toASM=function(t){if(y(t)&&(t=w(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map((t=>{if(b(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 f(c.String,t),g(t.split(" ").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(f(c.Hex,t),n.from(t,"hex")))))},e.toStack=function(t){return t=w(t),f(p,t),t.map((t=>b(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):s.encode(t-l)))},e.isCanonicalPubKey=function(t){return c.isPoint(t)},e.isDefinedHashType=v,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&!!v(t[t.length-1])&&i.check(t.slice(0,-1))},e.number=s,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=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),i=n.allocUnsafe(r),o=t<0;for(let t=0;t<r;++t)i.writeUInt8(255&e,t),e>>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}},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(7038),a=r(8116),{typeforce:s}=a,u=n.alloc(1,0);function c(t){let e=0;for(;0===t[e];)++e;return e===t.length?u:128&(t=t.slice(e))[0]?n.concat([u,t],1+t.length):t}function f(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);if(!(0,o.isDefinedHashType)(e))throw new Error("Invalid hashType "+e);const r=i.decode(t.slice(0,-1)),a=f(r.r),s=f(r.s);return{signature:n.concat([a,s],64),hashType:e}},e.encode=function(t,e){if(s({signature:a.BufferN(64),hashType:a.UInt8},{signature:t,hashType:e}),!(0,o.isDefinedHashType)(e))throw new Error("Invalid hashType "+e);const r=n.allocUnsafe(1);r.writeUInt8(e,0);const u=c(t.slice(0,32)),f=c(t.slice(32,64));return n.concat([i.encode(u,f),r])}},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),a=r(7038),s=r(7038),u=r(8116),{typeforce:c}=u;function f(t){const e=t.length;return i.varuint.encodingLength(e)+e}const l=n.allocUnsafe(0),h=[],p=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),b={script:l,valueBuffer:y};class g{static DEFAULT_SEQUENCE=4294967295;static SIGHASH_DEFAULT=0;static SIGHASH_ALL=1;static SIGHASH_NONE=2;static SIGHASH_SINGLE=3;static SIGHASH_ANYONECANPAY=128;static SIGHASH_OUTPUT_MASK=3;static SIGHASH_INPUT_MASK=128;static ADVANCED_TRANSACTION_MARKER=0;static ADVANCED_TRANSACTION_FLAG=1;version=1;locktime=0;ins=[];outs=[];static fromBuffer(t,e){const r=new i.BufferReader(t),n=new g;n.version=r.readInt32();const o=r.readUInt8(),a=r.readUInt8();let s=!1;o===g.ADVANCED_TRANSACTION_MARKER&&a===g.ADVANCED_TRANSACTION_FLAG?s=!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(s){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 g.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&&g.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=g.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:e,script:n||l,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+f(e.script)),0)+this.outs.reduce(((t,e)=>t+8+f(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+f(e)),0)}(e.witness)),0):0)}clone(){const t=new g;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=a.compile(a.decompile(e).filter((t=>t!==s.OPS.OP_CODESEPARATOR))),f=this.clone();if((31&r)===g.SIGHASH_NONE)f.outs=[],f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===g.SIGHASH_SINGLE){if(t>=this.outs.length)return d;f.outs.length=t+1;for(let e=0;e<t;e++)f.outs[e]=b;f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}))}r&g.SIGHASH_ANYONECANPAY?(f.ins=[f.ins[t]],f.ins[0].script=i):(f.ins.forEach((t=>{t.script=l})),f.ins[t].script=i);const h=n.allocUnsafe(f.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),f.__toBuffer(h,0,!1),o.hash256(h)}hashForWitnessV1(t,e,r,a,s,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=a===g.SIGHASH_DEFAULT?g.SIGHASH_ALL:a&g.SIGHASH_OUTPUT_MASK,d=(a&g.SIGHASH_INPUT_MASK)===g.SIGHASH_ANYONECANPAY,y=p===g.SIGHASH_NONE,b=p===g.SIGHASH_SINGLE;let w=l,v=l,m=l,_=l,E=l;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))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(f).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),_=o.sha256(t.end())}if(y||b){if(b&&t<this.outs.length){const e=this.outs[t],r=i.BufferWriter.withCapacity(8+f(e.script));r.writeUInt64(e.value),r.writeVarSlice(e.script),E=o.sha256(r.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const t=this.outs.map((t=>8+f(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),E=o.sha256(e.end())}const S=(s?2:0)+(h?1:0),k=174-(d?49:0)-(y?32:0)+(h?32:0)+(s?37:0),T=i.BufferWriter.withCapacity(k);if(T.writeUInt8(a),T.writeInt32(this.version),T.writeUInt32(this.locktime),T.writeSlice(w),T.writeSlice(v),T.writeSlice(m),T.writeSlice(_),y||b||T.writeSlice(E),T.writeUInt8(S),d){const n=this.ins[t];T.writeSlice(n.hash),T.writeUInt32(n.index),T.writeUInt64(r[t]),T.writeVarSlice(e[t]),T.writeUInt32(n.sequence)}else T.writeUInt32(t);if(h){const t=i.BufferWriter.withCapacity(f(h));t.writeVarSlice(h),T.writeSlice(o.sha256(t.end()))}return b&&T.writeSlice(E),s&&(T.writeSlice(s),T.writeUInt8(0),T.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),T.end()]))}hashForWitnessV0(t,e,r,a){c(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let s,l=n.from([]),h=p,d=p,y=p;if(a&g.SIGHASH_ANYONECANPAY||(l=n.allocUnsafe(36*this.ins.length),s=new i.BufferWriter(l,0),this.ins.forEach((t=>{s.writeSlice(t.hash),s.writeUInt32(t.index)})),d=o.hash256(l)),a&g.SIGHASH_ANYONECANPAY||(31&a)===g.SIGHASH_SINGLE||(31&a)===g.SIGHASH_NONE||(l=n.allocUnsafe(4*this.ins.length),s=new i.BufferWriter(l,0),this.ins.forEach((t=>{s.writeUInt32(t.sequence)})),y=o.hash256(l)),(31&a)!==g.SIGHASH_SINGLE&&(31&a)!==g.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+f(e.script)),0);l=n.allocUnsafe(t),s=new i.BufferWriter(l,0),this.outs.forEach((t=>{s.writeUInt64(t.value),s.writeVarSlice(t.script)})),h=o.hash256(l)}else if((31&a)===g.SIGHASH_SINGLE&&t<this.outs.length){const e=this.outs[t];l=n.allocUnsafe(8+f(e.script)),s=new i.BufferWriter(l,0),s.writeUInt64(e.value),s.writeVarSlice(e.script),h=o.hash256(l)}l=n.allocUnsafe(156+f(e)),s=new i.BufferWriter(l,0);const b=this.ins[t];return s.writeInt32(this.version),s.writeSlice(d),s.writeSlice(y),s.writeSlice(b.hash),s.writeUInt32(b.index),s.writeVarSlice(e),s.writeUInt64(r),s.writeUInt32(b.sequence),s.writeSlice(h),s.writeUInt32(this.locktime),s.writeUInt32(a),o.hash256(l)}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 a=r&&this.hasWitnesses();return a&&(o.writeUInt8(g.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(g.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)})),a&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=g},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.Satoshi=e.isPoint=e.stacksEqual=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");function a(t){return!(!t||!("output"in t)||!n.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&e.TAPLEAF_VERSION_MASK)!==t.version)}e.stacksEqual=function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))},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 a=t.slice(33);return 0!==a.compare(i)&&!(a.compare(o)>=0)&&4===e&&65===t.length},e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=21e14},e.TAPLEAF_VERSION_MASK=254,e.isTapleaf=a,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):a(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},5974:(t,e,r)=>{var n=r(8287).Buffer,i=r(5606),o=r(4148),a=r(4442),s=r(8411),u=r(1447),c=r(9681);for(var f in c)e[f]=c[f];function l(t){if("number"!=typeof t||t<e.DEFLATE||t>e.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}e.NONE=0,e.DEFLATE=1,e.INFLATE=2,e.GZIP=3,e.GUNZIP=4,e.DEFLATERAW=5,e.INFLATERAW=6,e.UNZIP=7,l.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,o(this.init_done,"close before init"),o(this.mode<=e.UNZIP),this.mode===e.DEFLATE||this.mode===e.GZIP||this.mode===e.DEFLATERAW?s.deflateEnd(this.strm):this.mode!==e.INFLATE&&this.mode!==e.GUNZIP&&this.mode!==e.INFLATERAW&&this.mode!==e.UNZIP||u.inflateEnd(this.strm),this.mode=e.NONE,this.dictionary=null)},l.prototype.write=function(t,e,r,n,i,o,a){return this._write(!0,t,e,r,n,i,o,a)},l.prototype.writeSync=function(t,e,r,n,i,o,a){return this._write(!1,t,e,r,n,i,o,a)},l.prototype._write=function(t,r,a,s,u,c,f,l){if(o.equal(arguments.length,8),o(this.init_done,"write before init"),o(this.mode!==e.NONE,"already finalized"),o.equal(!1,this.write_in_progress,"write already in progress"),o.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,o.equal(!1,void 0===r,"must provide flush value"),this.write_in_progress=!0,r!==e.Z_NO_FLUSH&&r!==e.Z_PARTIAL_FLUSH&&r!==e.Z_SYNC_FLUSH&&r!==e.Z_FULL_FLUSH&&r!==e.Z_FINISH&&r!==e.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=n.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=a,this.strm.next_in=s,this.strm.avail_out=l,this.strm.output=c,this.strm.next_out=f,this.flush=r,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return i.nextTick((function(){h._process(),h._after()})),this},l.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},l.prototype._process=function(){var t=null;switch(this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflate(this.strm,this.flush);break;case e.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=e.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=e.GUNZIP):this.mode=e.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:for(this.err=u.inflate(this.strm,this.flush),this.err===e.Z_NEED_DICT&&this.dictionary&&(this.err=u.inflateSetDictionary(this.strm,this.dictionary),this.err===e.Z_OK?this.err=u.inflate(this.strm,this.flush):this.err===e.Z_DATA_ERROR&&(this.err=e.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===e.GUNZIP&&this.err===e.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=u.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},l.prototype._checkError=function(){switch(this.err){case e.Z_OK:case e.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===e.Z_FINISH)return this._error("unexpected end of file"),!1;break;case e.Z_STREAM_END:break;case e.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},l.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},l.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},l.prototype.init=function(t,r,n,i,a){o(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),o(t>=8&&t<=15,"invalid windowBits"),o(r>=-1&&r<=9,"invalid compression level"),o(n>=1&&n<=9,"invalid memlevel"),o(i===e.Z_FILTERED||i===e.Z_HUFFMAN_ONLY||i===e.Z_RLE||i===e.Z_FIXED||i===e.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(r,t,n,i,a),this._setDictionary()},l.prototype.params=function(){throw new Error("deflateParams Not supported")},l.prototype.reset=function(){this._reset(),this._setDictionary()},l.prototype._init=function(t,r,n,i,o){switch(this.level=t,this.windowBits=r,this.memLevel=n,this.strategy=i,this.flush=e.Z_NO_FLUSH,this.err=e.Z_OK,this.mode!==e.GZIP&&this.mode!==e.GUNZIP||(this.windowBits+=16),this.mode===e.UNZIP&&(this.windowBits+=32),this.mode!==e.DEFLATERAW&&this.mode!==e.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflateInit2(this.strm,this.level,e.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:case e.UNZIP:this.err=u.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==e.Z_OK&&this._error("Init error"),this.dictionary=o,this.write_in_progress=!1,this.init_done=!0},l.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:this.err=s.deflateSetDictionary(this.strm,this.dictionary)}this.err!==e.Z_OK&&this._error("Failed to set dictionary")}},l.prototype._reset=function(){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:case e.GZIP:this.err=s.deflateReset(this.strm);break;case e.INFLATE:case e.INFLATERAW:case e.GUNZIP:this.err=u.inflateReset(this.strm)}this.err!==e.Z_OK&&this._error("Failed to reset stream")},e.Zlib=l},8559:(t,e,r)=>{var n=r(5606),i=r(8287).Buffer,o=r(8310).Transform,a=r(5974),s=r(537),u=r(4148).ok,c=r(8287).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+c.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var l=Object.keys(a),h=0;h<l.length;h++){var p=l[h];p.match(/^Z/)&&Object.defineProperty(e,p,{enumerable:!0,value:a[p],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},y=Object.keys(d),b=0;b<y.length;b++){var g=y[b];d[d[g]]=g}function w(t,e,r){var n=[],o=0;function a(){for(var e;null!==(e=t.read());)n.push(e),o+=e.length;t.once("readable",a)}function s(){var e,a=null;o>=c?a=new RangeError(f):e=i.concat(n,o),n=[],t.close(),r(a,e)}t.on("error",(function(e){t.removeListener("end",s),t.removeListener("readable",a),r(e)})),t.on("end",s),t.end(e),a()}function v(t,e){if("string"==typeof e&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Not a string or buffer");var r=t._finishFlushFlag;return t._processChunk(e,r)}function m(t){if(!(this instanceof m))return new m(t);x.call(this,t,a.DEFLATE)}function _(t){if(!(this instanceof _))return new _(t);x.call(this,t,a.INFLATE)}function E(t){if(!(this instanceof E))return new E(t);x.call(this,t,a.GZIP)}function S(t){if(!(this instanceof S))return new S(t);x.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);x.call(this,t,a.DEFLATERAW)}function T(t){if(!(this instanceof T))return new T(t);x.call(this,t,a.INFLATERAW)}function O(t){if(!(this instanceof O))return new O(t);x.call(this,t,a.UNZIP)}function A(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function x(t,r){var n=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||e.Z_DEFAULT_CHUNK,o.call(this,t),t.flush&&!A(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!A(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSize<e.Z_MIN_CHUNK||t.chunkSize>e.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBits<e.Z_MIN_WINDOWBITS||t.windowBits>e.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.level<e.Z_MIN_LEVEL||t.level>e.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLevel<e.Z_MIN_MEMLEVEL||t.memLevel>e.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=e.Z_FILTERED&&t.strategy!=e.Z_HUFFMAN_ONLY&&t.strategy!=e.Z_RLE&&t.strategy!=e.Z_FIXED&&t.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!i.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(r);var s=this;this._hadError=!1,this._handle.onerror=function(t,r){P(s),s._hadError=!0;var n=new Error(t);n.errno=r,n.code=e.codes[r],s.emit("error",n)};var u=e.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var c=e.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(c=t.strategy),this._handle.init(t.windowBits||e.Z_DEFAULT_WINDOWBITS,u,t.memLevel||e.Z_DEFAULT_MEMLEVEL,c,t.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=c,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!n._handle},configurable:!0,enumerable:!0})}function P(t,e){e&&n.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function I(t){t.emit("close")}Object.defineProperty(e,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),e.Deflate=m,e.Inflate=_,e.Gzip=E,e.Gunzip=S,e.DeflateRaw=k,e.InflateRaw=T,e.Unzip=O,e.createDeflate=function(t){return new m(t)},e.createInflate=function(t){return new _(t)},e.createDeflateRaw=function(t){return new k(t)},e.createInflateRaw=function(t){return new T(t)},e.createGzip=function(t){return new E(t)},e.createGunzip=function(t){return new S(t)},e.createUnzip=function(t){return new O(t)},e.deflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new m(e),t,r)},e.deflateSync=function(t,e){return v(new m(e),t)},e.gzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new E(e),t,r)},e.gzipSync=function(t,e){return v(new E(e),t)},e.deflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new k(e),t,r)},e.deflateRawSync=function(t,e){return v(new k(e),t)},e.unzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new O(e),t,r)},e.unzipSync=function(t,e){return v(new O(e),t)},e.inflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new _(e),t,r)},e.inflateSync=function(t,e){return v(new _(e),t)},e.gunzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new S(e),t,r)},e.gunzipSync=function(t,e){return v(new S(e),t)},e.inflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new T(e),t,r)},e.inflateRawSync=function(t,e){return v(new T(e),t)},s.inherits(x,o),x.prototype.params=function(t,r,i){if(t<e.Z_MIN_LEVEL||t>e.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=e.Z_FILTERED&&r!=e.Z_HUFFMAN_ONLY&&r!=e.Z_RLE&&r!=e.Z_FIXED&&r!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,(function(){u(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())}))}else n.nextTick(i)},x.prototype.reset=function(){return u(this._handle,"zlib binding closed"),this._handle.reset()},x.prototype._flush=function(t){this._transform(i.alloc(0),"",t)},x.prototype.flush=function(t,e){var r=this,o=this._writableState;("function"==typeof t||void 0===t&&!e)&&(e=t,t=a.Z_FULL_FLUSH),o.ended?e&&n.nextTick(e):o.ending?e&&this.once("end",e):o.needDrain?e&&this.once("drain",(function(){return r.flush(t,e)})):(this._flushFlag=t,this.write(i.alloc(0),"",e))},x.prototype.close=function(t){P(this,t),n.nextTick(I,this)},x.prototype._transform=function(t,e,r){var n,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||i.isBuffer(t)?this._handle?(s?n=this._finishFlushFlag:(n=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,n,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},x.prototype._processChunk=function(t,e,r){var n=t&&t.length,o=this._chunkSize-this._offset,a=0,s=this,l="function"==typeof r;if(!l){var h,p=[],d=0;this.on("error",(function(t){h=t})),u(this._handle,"zlib binding closed");do{var y=this._handle.writeSync(e,t,a,n,this._buffer,this._offset,o)}while(!this._hadError&&w(y[0],y[1]));if(this._hadError)throw h;if(d>=c)throw P(this),new RangeError(f);var b=i.concat(p,d);return P(this),b}u(this._handle,"zlib binding closed");var g=this._handle.write(e,t,a,n,this._buffer,this._offset,o);function w(c,f){if(this&&(this.buffer=null,this.callback=null),!s._hadError){var h=o-f;if(u(h>=0,"have should not go down"),h>0){var y=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,l?s.push(y):(p.push(y),d+=y.length)}if((0===f||s._offset>=s._chunkSize)&&(o=s._chunkSize,s._offset=0,s._buffer=i.allocUnsafe(s._chunkSize)),0===f){if(a+=n-c,n=c,!l)return!0;var b=s._handle.write(e,t,a,n,s._buffer,s._offset,s._chunkSize);return b.callback=w,void(b.buffer=t)}if(!l)return!1;r()}}g.buffer=t,g.callback=w},s.inherits(m,x),s.inherits(_,x),s.inherits(E,x),s.inherits(S,x),s.inherits(k,x),s.inherits(T,x),s.inherits(O,x)},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,a=new Uint8Array(o);return a.set(r,0),a.set(i.subarray(0,4),r.length),n.encode(a,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 a=2147483647;function s(t){if(t>a)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 l(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=s(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($(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($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&($(t,SharedArrayBuffer)||t&&$(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=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?s(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 f(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 l(t){return f(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(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>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(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 b(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 I(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return x(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return L(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(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),Y(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:v(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):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){let o,a=1,s=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;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-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 m(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 a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Y(n))return a;t[r+a]=n}return a}function _(t,e,r,n){return X(z(e,t.length-r),t,r,n)}function E(t,e,r,n){return X(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 X(q(e),t,r,n)}function k(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){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],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=A)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=A));return r}(n)}e.kMaxLength=a,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 f(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if($(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),$(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($(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)g(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)g(this,e,e+3),g(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)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):b.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($(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),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<s;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<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 m(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(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 A=4096;function x(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 P(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 I(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+=Z[t[n]];return i}function L(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 B(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 N(t,e,r,n,i){K(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 a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function U(t,e,r,n,i){K(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 a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function j(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 C(t,e,r,n,o){return e=+e,r>>>=0,o||j(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||j(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=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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||B(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||B(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||B(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||B(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||B(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||B(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||B(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=J((function(t,e=0){return N(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(t,e=0){return U(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);B(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&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);B(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||B(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||B(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||B(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||B(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||B(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=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(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),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const M={};function D(t,e,r){M[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 H(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 K(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 M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,i,o)}function W(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw W(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("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=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/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 a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+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(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(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 $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const Z=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 J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},8075:(t,e,r)=>{var n=r(453),i=r(487),o=i(n("String.prototype.indexOf"));t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i(r):r}},487:(t,e,r)=>{var n=r(6743),i=r(453),o=r(6897),a=r(9675),s=i("%Function.prototype.apply%"),u=i("%Function.prototype.call%"),c=i("%Reflect.apply%",!0)||n.call(u,s),f=r(655),l=i("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new a("a function is required");var e=c(n,u,arguments);return o(e,1+l(0,t.length-(arguments.length-1)),!0)};var h=function(){return c(n,s,arguments)};f?f(t.exports,"apply",{value:h}):t.exports.apply=h},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(9579).I;function a(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)(a,i),a.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)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.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)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.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=a},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),a=r(2802),s=r(6168);function u(t){s.call(this,"digest"),this._hash=t}n(u,s),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(a(t))}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},41:(t,e,r)=>{var n=r(655),i=r(8068),o=r(9675),a=r(5795);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],l=!!a&&a(t,e);if(n)n(t,e,{configurable:null===c&&l?l.configurable:!c,enumerable:null===s&&l?l.enumerable:!s,value:r,writable:null===u&&l?l.writable:!u});else{if(!f&&(s||u||c))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},8452:(t,e,r)=>{var n=r(1189),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=r(41),u=r(592)(),c=function(t,e,r,n){if(e in t)if(!0===n){if(t[e]===r)return}else if("function"!=typeof(i=n)||"[object Function]"!==o.call(i)||!n())return;var i;u?s(t,e,r,!0):s(t,e,r)},f=function(t,e){var r=arguments.length>2?arguments[2]:{},o=n(e);i&&(o=a.call(o,Object.getOwnPropertySymbols(e)));for(var s=0;s<o.length;s+=1)c(t,o[s],e[o[s]],r[o[s]])};f.supportsDescriptors=!!u,t.exports=f},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),a=r(3209),s=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 f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new f(void 0,e,r)}(0,u.testEcc)(t);class f{__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 s.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 a=t.xOnlyPointAddTweak(i,e);if(!a||null===a.xOnlyPubkey)throw new Error("Cannot tweak public key!");const s=n.from([0===a.parity?2:3]);return r(n.concat([s,a.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=s.decode(t),a=n.version;if(o.Array(r)){if(r=r.filter((t=>a===t.wif)).pop(),!r)throw new Error("Unknown network version")}else if(r=r||i.bitcoin,a!==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||a;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},655:(t,e,r)=>{var n=r(453)("%Object.defineProperty%",!0)||!1;if(n)try{n({},"a",{value:1})}catch(t){n=!1}t.exports=n},1237:t=>{t.exports=EvalError},9383:t=>{t.exports=Error},9290:t=>{t.exports=RangeError},9538:t=>{t.exports=ReferenceError},8068:t=>{t.exports=SyntaxError},9675:t=>{t.exports=TypeError},5345:t=>{t.exports=URIError},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){"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 a=10;function s(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,a,c;if(s(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),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=a.length,c=f,console&&console.warn&&console.warn(c)}return t}function f(){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 l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.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 a},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+".");a=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 a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,f=d(u,c);for(r=0;r<c;++r)n(f[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 s(e),this.on(t,l(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return s(e),this.prependListener(t,l(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(s(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){a=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,a||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):[]}},2682:(t,e,r)=>{var n=r(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(t)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,a):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a)}},9353:t=>{var e=Object.prototype.toString,r=Math.max,n=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};t.exports=function(t){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t){for(var e=[],r=1,n=0;r<t.length;r+=1,n+=1)e[n]=t[r];return e}(arguments),s=r(0,i.length-a.length),u=[],c=0;c<s;c++)u[c]="$"+c;if(o=Function("binder","return function ("+function(t){for(var e="",r=0;r<t.length;r+=1)e+=t[r],r+1<t.length&&(e+=",");return e}(u)+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof o){var e=i.apply(this,n(a,arguments));return Object(e)===e?e:this}return i.apply(t,n(a,arguments))})),i.prototype){var f=function(){};f.prototype=i.prototype,o.prototype=new f,f.prototype=null}return o}},6743:(t,e,r)=>{var n=r(9353);t.exports=Function.prototype.bind||n},453:(t,e,r)=>{var n,i=r(9383),o=r(1237),a=r(9290),s=r(9538),u=r(8068),c=r(9675),f=r(5345),l=Function,h=function(t){try{return l('"use strict"; return ('+t+").constructor;")()}catch(t){}},p=Object.getOwnPropertyDescriptor;if(p)try{p({},"")}catch(t){p=null}var d=function(){throw new c},y=p?function(){try{return d}catch(t){try{return p(arguments,"callee").get}catch(t){return d}}}():d,b=r(4039)(),g=r(24)(),w=Object.getPrototypeOf||(g?function(t){return t.__proto__}:null),v={},m="undefined"!=typeof Uint8Array&&w?w(Uint8Array):n,_={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":b&&w?w([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":v,"%AsyncGenerator%":v,"%AsyncGeneratorFunction%":v,"%AsyncIteratorPrototype%":v,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":o,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":v,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":b&&w?w(w([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&b&&w?w((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":a,"%ReferenceError%":s,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&b&&w?w((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":b&&w?w(""[Symbol.iterator]()):n,"%Symbol%":b?Symbol:n,"%SyntaxError%":u,"%ThrowTypeError%":y,"%TypedArray%":m,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":f,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet};if(w)try{null.error}catch(t){var E=w(w(t));_["%Error.prototype%"]=E}var S=function t(e){var r;if("%AsyncFunction%"===e)r=h("async function () {}");else if("%GeneratorFunction%"===e)r=h("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=h("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&w&&(r=w(i.prototype))}return _[e]=r,r},k={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},T=r(6743),O=r(9957),A=T.call(Function.call,Array.prototype.concat),x=T.call(Function.apply,Array.prototype.splice),P=T.call(Function.call,String.prototype.replace),I=T.call(Function.call,String.prototype.slice),L=T.call(Function.call,RegExp.prototype.exec),R=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,B=/\\(\\)?/g,N=function(t,e){var r,n=t;if(O(k,n)&&(n="%"+(r=k[n])[0]+"%"),O(_,n)){var i=_[n];if(i===v&&(i=S(n)),void 0===i&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new u("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===L(/^%?[^%]*%?$/,t))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=I(t,0,1),r=I(t,-1);if("%"===e&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new u("invalid intrinsic syntax, expected opening `%`");var n=[];return P(t,R,(function(t,e,r,i){n[n.length]=r?P(i,B,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=N("%"+n+"%",e),o=i.name,a=i.value,s=!1,f=i.alias;f&&(n=f[0],x(r,A([0,1],f)));for(var l=1,h=!0;l<r.length;l+=1){var d=r[l],y=I(d,0,1),b=I(d,-1);if(('"'===y||"'"===y||"`"===y||'"'===b||"'"===b||"`"===b)&&y!==b)throw new u("property names with quotes must have matching quotes");if("constructor"!==d&&h||(s=!0),O(_,o="%"+(n+="."+d)+"%"))a=_[o];else if(null!=a){if(!(d in a)){if(!e)throw new c("base intrinsic for "+t+" exists, but the property is not available.");return}if(p&&l+1>=r.length){var g=p(a,d);a=(h=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:a[d]}else h=O(a,d),a=a[d];h&&!s&&(_[o]=a)}}return a}},5795:(t,e,r)=>{var n=r(453)("%Object.getOwnPropertyDescriptor%",!0);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},592:(t,e,r)=>{var n=r(655),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},24:t=>{var e={__proto__:null,foo:{}},r=Object;t.exports=function(){return{__proto__:e}.foo===e.foo&&!(e instanceof r)}},4039:(t,e,r)=>{var n="undefined"!=typeof Symbol&&Symbol,i=r(1333);t.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},1333:t=>{t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},9092:(t,e,r)=>{var n=r(1333);t.exports=function(){return n()&&!!Symbol.toStringTag}},4729:(t,e,r)=>{var n=r(2861).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){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 a=0,s=8*t.length;s>0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);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,a,s,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"))a="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(s=t).length||-1===s.indexOf(".",u)?"argument":"property");a='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return a+". 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(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6736),a=r(2192);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.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",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.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(5606);t.exports=T,T.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1181),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(2382);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(2389),y=r(1468),b=r(8775).getHighWaterMark,g=r(2260).F,w=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(T,s);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(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=b(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&&(l||(l=r(7137).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(2818),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.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?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,L(t)))}}(t,s);else if(i||(a=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}(s,e)),a)E(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?E(t,new _):A(t,s,e,!0);else if(s.ended)E(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):R(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,R(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(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&&I(t)),R(t,e)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.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),O(this,t,e,!1,r)},T.prototype.unshift=function(t){return O(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){l||(l=r(7137).I);var e=new l(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 x=1073741824;function P(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>=x?t=x:(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 I(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(L,t))}function L(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,C(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(B,t,e))}function B(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 N(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 U(t){o("readable nexttick read 0"),t.read(0)}function j(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(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 M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(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 H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}T.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?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(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=P(r,e))),null===(n=t>0?F(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&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new m("_read()"))},T.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 s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.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",l),f=!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&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(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",l),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},T.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 a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var r=s.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?I(this):n.reading||i.nextTick(U,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(N,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(N,this),e},T.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(j,t,e))}(this,t)),t.paused=!1,this},T.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},T.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 a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=F,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,e){return void 0===p&&(p=r(5049)),p(T,t,e)})},3054:(t,e,r)=>{t.exports=f;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=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 f(t){if(!(this instanceof f))return new f(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",l)}function l(){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 s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.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)}},f.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))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},2192:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=T,T.WritableState=k;var a,s={deprecate:r(4643)},u=r(1181),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,v=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(2818),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,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 b;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(L,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),L(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||x(t,r),n?i.nextTick(A,t,r,a,o):A(t,r,a,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 T(t){var e=this instanceof(n=n||r(2818));if(!e&&!a.call(T,this))return new T(t);this._writableState=new k(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 O(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,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 A(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),L(t,e)}function x(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,O(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),L(t,e)}))}function L(t,e){var r=P(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(I,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)(T,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.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]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===T&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new g)},T.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new v:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else O(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},T.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 _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.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,L(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}},4743:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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 a=r(5826),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=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[f])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[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?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[l]=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),g);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",b.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=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,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,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}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=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{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:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1468:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,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 a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),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,a=i.ERR_STREAM_DESTROYED;function s(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 f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(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 s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!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 a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))}))}));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)},7137:(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=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){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 f(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 l(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=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(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}},9957:(t,e,r)=>{var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(6743);t.exports=o.call(n,i)},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<<c)-1,l=f>>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?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;t[r+p]=255&a,p+=d,a/=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}}},7244:(t,e,r)=>{var n=r(9092)(),i=r(8075)("Object.prototype.toString"),o=function(t){return!(n&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===i(t)},a=function(t){return!!o(t)||null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==i(t)&&"[object Function]"===i(t.callee)},s=function(){return o(arguments)}();o.isLegacyArguments=a,t.exports=s?o:a},9600:t=>{var e,r,n=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},i((function(){throw 42}),null,e)}catch(t){t!==r&&(i=null)}else i=null;var o=/^\s*class\b/,a=function(t){try{var e=n.call(t);return o.test(e)}catch(t){return!1}},s=function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var h=document.all;u.call(h)===u.call(document.all)&&(l=function(t){if((f||!t)&&(void 0===t||"object"==typeof t))try{var e=u.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=i?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{i(t,null,e)}catch(t){if(t!==r)return!1}return!a(t)&&s(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(c)return s(t);if(a(t))return!1;var e=u.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&s(t)}},8184:(t,e,r)=>{var n,i=Object.prototype.toString,o=Function.prototype.toString,a=/^\s*(?:function)?\*/,s=r(9092)(),u=Object.getPrototypeOf;t.exports=function(t){if("function"!=typeof t)return!1;if(a.test(o.call(t)))return!0;if(!s)return"[object GeneratorFunction]"===i.call(t);if(!u)return!1;if(void 0===n){var e=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(t){}}();n=!!e&&u(e)}return u(t)===n}},3003:t=>{t.exports=function(t){return t!=t}},4133:(t,e,r)=>{var n=r(487),i=r(8452),o=r(3003),a=r(6642),s=r(2464),u=n(a(),Number);i(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},6642:(t,e,r)=>{var n=r(3003);t.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},2464:(t,e,r)=>{var n=r(8452),i=r(6642);t.exports=function(){var t=i();return n(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},5680:(t,e,r)=>{var n=r(5767);t.exports=function(t){return!!n(t)}},9211:t=>{var e=function(t){return t!=t};t.exports=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}},7653:(t,e,r)=>{var n=r(8452),i=r(487),o=r(9211),a=r(9394),s=r(6576),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},9394:(t,e,r)=>{var n=r(9211);t.exports=function(){return"function"==typeof Object.is?Object.is:n}},6576:(t,e,r)=>{var n=r(9394),i=r(8452);t.exports=function(){var t=n();return i(Object,{is:t},{is:function(){return Object.is!==t}}),t}},8875:(t,e,r)=>{var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(1093),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),c=s.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=a(t),s=e&&"[object String]"===o.call(t),h=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=c&&r;if(s&&t.length>0&&!i.call(t,0))for(var y=0;y<t.length;++y)h.push(String(y));if(n&&t.length>0)for(var b=0;b<t.length;++b)h.push(String(b));else for(var g in t)d&&"prototype"===g||!i.call(t,g)||h.push(String(g));if(u)for(var w=function(t){if("undefined"==typeof window||!p)return l(t);try{return l(t)}catch(t){return!1}}(t),v=0;v<f.length;++v)w&&"constructor"===f[v]||!i.call(t,f[v])||h.push(f[v]);return h}}t.exports=n},1189:(t,e,r)=>{var n=Array.prototype.slice,i=r(1093),o=Object.keys,a=o?function(t){return o(t)}:r(8875),s=Object.keys;a.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return i(t)?s(n.call(t)):s(t)})}else Object.keys=a;return Object.keys||a},t.exports=a},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},8403:(t,e,r)=>{var n=r(1189),i=r(1333)(),o=r(8075),a=Object,s=o("Array.prototype.push"),u=o("Object.prototype.propertyIsEnumerable"),c=i?Object.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=a(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=a(arguments[o]),l=n(f),h=i&&(Object.getOwnPropertySymbols||c);if(h)for(var p=h(f),d=0;d<p.length;++d){var y=p[d];u(f,y)&&s(l,y)}for(var b=0;b<l.length;++b){var g=l[b];if(u(f,g)){var w=f[g];r[g]=w}}}return r}},1514:(t,e,r)=>{var n=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},9805:(t,e)=>{var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(t[i]=r[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){var e,r,n,i,o,a;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)o=t[e],a.set(o,i),i+=o.length;return a}},o={arraySet:function(t,e,r,n,i){for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,i)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(r)},3269:t=>{t.exports=function(t,e,r,n){for(var i=65535&t,o=t>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+e[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16}},9681:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:t=>{var e=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,r,n,i){var o=e,a=i+n;t^=-1;for(var s=i;s<a;s++)t=t>>>8^o[255&(t^r[s])];return~t}},8411:(t,e,r)=>{var n,i=r(9805),o=r(3665),a=r(3269),s=r(4823),u=r(4674),c=-2,f=258,l=262,h=103,p=113,d=666;function y(t,e){return t.msg=u[e],e}function b(t){return(t<<1)-(t>4?9:0)}function g(t){for(var e=t.length;--e>=0;)t[e]=0}function w(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(i.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function v(t,e){o._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,w(t.strm)}function m(t,e){t.pending_buf[t.pending++]=e}function _(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function E(t,e){var r,n,i=t.max_chain_length,o=t.strstart,a=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-l?t.strstart-(t.w_size-l):0,c=t.window,h=t.w_mask,p=t.prev,d=t.strstart+f,y=c[o+a-1],b=c[o+a];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(c[(r=e)+a]===b&&c[r+a-1]===y&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<d);if(n=f-(d-o),o=d-f,n>a){if(t.match_start=e,a=n,n>=s)break;y=c[o+a-1],b=c[o+a]}}}while((e=p[e&h])>u&&0!=--i);return a<=t.lookahead?a:t.lookahead}function S(t){var e,r,n,o,u,c,f,h,p,d,y=t.w_size;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=y+(y-l)){i.arraySet(t.window,t.window,y,y,0),t.match_start-=y,t.strstart-=y,t.block_start-=y,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=y?n-y:0}while(--r);e=r=y;do{n=t.prev[--e],t.prev[e]=n>=y?n-y:0}while(--r);o+=y}if(0===t.strm.avail_in)break;if(c=t.strm,f=t.window,h=t.strstart+t.lookahead,p=o,d=void 0,(d=c.avail_in)>p&&(d=p),r=0===d?0:(c.avail_in-=d,i.arraySet(f,c.input,c.next_in,d,h),1===c.state.wrap?c.adler=a(c.adler,f,d,h):2===c.state.wrap&&(c.adler=s(c.adler,f,d,h)),c.next_in+=d,c.total_in+=d,d),t.lookahead+=r,t.lookahead+t.insert>=3)for(u=t.strstart-t.insert,t.ins_h=t.window[u],t.ins_h=(t.ins_h<<t.hash_shift^t.window[u+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[u+3-1])&t.hash_mask,t.prev[u&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=u,u++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<l&&0!==t.strm.avail_in)}function k(t,e){for(var r,n;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r)),t.match_length>=3)if(n=o._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}function T(t,e){for(var r,n,i;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=o._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(v(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=o._tr_tally(t,0,t.window[t.strstart-1]))&&v(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=o._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}function O(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}function A(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function x(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:p,t.adler=2===e.wrap?0:1,e.last_flush=0,o._tr_init(e),0):y(t,c)}function P(t){var e=x(t);return 0===e&&function(t){t.window_size=2*t.w_size,g(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function I(t,e,r,n,o,a){if(!t)return c;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),o<1||o>9||8!==r||n<8||n>15||e<0||e>9||a<0||a>4)return y(t,c);8===n&&(n=9);var u=new A;return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=o+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new i.Buf8(2*u.w_size),u.head=new i.Buf16(u.hash_size),u.prev=new i.Buf16(u.w_size),u.lit_bufsize=1<<o+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new i.Buf8(u.pending_buf_size),u.d_buf=1*u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=e,u.strategy=a,u.method=r,P(t)}n=[new O(0,0,0,0,(function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(S(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,v(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-l&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(v(t,!1),t.strm.avail_out),1)})),new O(4,4,8,4,k),new O(4,5,16,8,k),new O(4,6,32,32,k),new O(4,4,16,16,T),new O(8,16,32,32,T),new O(8,16,128,128,T),new O(8,32,128,256,T),new O(32,128,258,1024,T),new O(32,258,258,4096,T)],e.deflateInit=function(t,e){return I(t,e,8,15,8,0)},e.deflateInit2=I,e.deflateReset=P,e.deflateResetKeep=x,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?c:(t.state.gzhead=e,0):c},e.deflate=function(t,e){var r,i,a,u;if(!t||!t.state||e>5||e<0)return t?y(t,c):c;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===d&&4!==e)return y(t,0===t.avail_out?-5:c);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,m(i,31),m(i,139),m(i,8),i.gzhead?(m(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),m(i,255&i.gzhead.time),m(i,i.gzhead.time>>8&255),m(i,i.gzhead.time>>16&255),m(i,i.gzhead.time>>24&255),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(m(i,255&i.gzhead.extra.length),m(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(m(i,0),m(i,0),m(i,0),m(i,0),m(i,0),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,3),i.status=p);else{var l=8+(i.w_bits-8<<4)<<8;l|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(l|=32),l+=31-l%31,i.status=p,_(i,l),0!==i.strstart&&(_(i,t.adler>>>16),_(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),w(t),a=i.pending,i.pending!==i.pending_buf_size));)m(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),w(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),w(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.status=h)}else i.status=h;if(i.status===h&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&w(t),i.pending+2<=i.pending_buf_size&&(m(i,255&t.adler),m(i,t.adler>>8&255),t.adler=0,i.status=p)):i.status=p),0!==i.pending){if(w(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&b(e)<=b(r)&&4!==e)return y(t,-5);if(i.status===d&&0!==t.avail_in)return y(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==d){var E=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(S(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,n,i,a,s=t.window;;){if(t.lookahead<=f){if(S(t),t.lookahead<=f&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[i=t.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=t.strstart+f;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);t.match_length=f-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=o._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(i,e):n[i.level].func(i,e);if(3!==E&&4!==E||(i.status=d),1===E||3===E)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===E&&(1===e?o._tr_align(i):5!==e&&(o._tr_stored_block(i,0,0,!1),3===e&&(g(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),w(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(m(i,255&t.adler),m(i,t.adler>>8&255),m(i,t.adler>>16&255),m(i,t.adler>>24&255),m(i,255&t.total_in),m(i,t.total_in>>8&255),m(i,t.total_in>>16&255),m(i,t.total_in>>24&255)):(_(i,t.adler>>>16),_(i,65535&t.adler)),w(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==h&&e!==p&&e!==d?y(t,c):(t.state=null,e===p?y(t,-3):0):c},e.deflateSetDictionary=function(t,e){var r,n,o,s,u,f,l,h,p=e.length;if(!t||!t.state)return c;if(2===(s=(r=t.state).wrap)||1===s&&42!==r.status||r.lookahead)return c;for(1===s&&(t.adler=a(t.adler,e,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(g(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new i.Buf8(r.w_size),i.arraySet(h,e,p-r.w_size,r.w_size,0),e=h,p=r.w_size),u=t.avail_in,f=t.next_in,l=t.input,t.avail_in=p,t.next_in=0,t.input=e,S(r);r.lookahead>=3;){n=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--o);r.strstart=n,r.lookahead=2,S(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=f,t.input=l,t.avail_in=u,r.wrap=s,0},e.deflateInfo="pako deflate (from Nodeca project)"},7293:t=>{t.exports=function(t,e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,w,v,m,_,E,S,k,T,O;r=t.state,n=t.next_in,T=t.input,i=n+(t.avail_in-5),o=t.next_out,O=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),u=r.dmax,c=r.wsize,f=r.whave,l=r.wnext,h=r.window,p=r.hold,d=r.bits,y=r.lencode,b=r.distcode,g=(1<<r.lenbits)-1,w=(1<<r.distbits)-1;t:do{d<15&&(p+=T[n++]<<d,d+=8,p+=T[n++]<<d,d+=8),v=y[p&g];e:for(;;){if(p>>>=m=v>>>24,d-=m,0==(m=v>>>16&255))O[o++]=65535&v;else{if(!(16&m)){if(64&m){if(32&m){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}v=y[(65535&v)+(p&(1<<m)-1)];continue e}for(_=65535&v,(m&=15)&&(d<m&&(p+=T[n++]<<d,d+=8),_+=p&(1<<m)-1,p>>>=m,d-=m),d<15&&(p+=T[n++]<<d,d+=8,p+=T[n++]<<d,d+=8),v=b[p&w];;){if(p>>>=m=v>>>24,d-=m,16&(m=v>>>16&255)){if(E=65535&v,d<(m&=15)&&(p+=T[n++]<<d,(d+=8)<m&&(p+=T[n++]<<d,d+=8)),(E+=p&(1<<m)-1)>u){t.msg="invalid distance too far back",r.mode=30;break t}if(p>>>=m,d-=m,E>(m=o-a)){if((m=E-m)>f&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(S=0,k=h,0===l){if(S+=c-m,m<_){_-=m;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}}else if(l<m){if(S+=c+l-m,(m-=l)<_){_-=m;do{O[o++]=h[S++]}while(--m);if(S=0,l<_){_-=m=l;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}}}else if(S+=l-m,m<_){_-=m;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}for(;_>2;)O[o++]=k[S++],O[o++]=k[S++],O[o++]=k[S++],_-=3;_&&(O[o++]=k[S++],_>1&&(O[o++]=k[S++]))}else{S=o-E;do{O[o++]=O[S++],O[o++]=O[S++],O[o++]=O[S++],_-=3}while(_>2);_&&(O[o++]=O[S++],_>1&&(O[o++]=O[S++]))}break}if(64&m){t.msg="invalid distance code",r.mode=30;break t}v=b[(65535&v)+(p&(1<<m)-1)]}}break}}while(n<i&&o<s);n-=_=d>>3,p&=(1<<(d-=_<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=d}},1447:(t,e,r)=>{var n=r(9805),i=r(3269),o=r(4823),a=r(7293),s=r(1998),u=-2,c=12,f=30;function l(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):u}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,p(t)):u}function y(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?u:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,d(t))):u}function b(t,e){var r,n;return t?(n=new h,t.state=n,n.window=null,0!==(r=y(t,e))&&(t.state=null),r):u}var g,w,v=!0;function m(t){if(v){var e;for(g=new n.Buf32(512),w=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,g,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,w,0,t.work,{bits:5}),v=!1}t.lencode=g,t.lenbits=9,t.distcode=w,t.distbits=5}function _(t,e,r,i){var o,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),i>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>i&&(o=i),n.arraySet(a.window,e,r-i,o,a.wnext),(i-=o)?(n.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0}e.inflateReset=d,e.inflateReset2=y,e.inflateResetKeep=p,e.inflateInit=function(t){return b(t,15)},e.inflateInit2=b,e.inflate=function(t,e){var r,h,p,d,y,b,g,w,v,E,S,k,T,O,A,x,P,I,L,R,B,N,U,j,C=0,F=new n.Buf8(4),M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return u;(r=t.state).mode===c&&(r.mode=13),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,w=r.hold,v=r.bits,E=b,S=g,N=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(2&r.wrap&&35615===w){r.check=0,F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0),w=0,v=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&w)<<8)+(w>>8))%31){t.msg="incorrect header check",r.mode=f;break}if(8!=(15&w)){t.msg="unknown compression method",r.mode=f;break}if(v-=4,B=8+(15&(w>>>=4)),0===r.wbits)r.wbits=B;else if(B>r.wbits){t.msg="invalid window size",r.mode=f;break}r.dmax=1<<B,t.adler=r.check=1,r.mode=512&w?10:c,w=0,v=0;break;case 2:for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(r.flags=w,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=f;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=f;break}r.head&&(r.head.text=w>>8&1),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0)),w=0,v=0,r.mode=3;case 3:for(;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.head&&(r.head.time=w),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,F[2]=w>>>16&255,F[3]=w>>>24&255,r.check=o(r.check,F,4,0)),w=0,v=0,r.mode=4;case 4:for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.head&&(r.head.xflags=255&w,r.head.os=w>>8),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0)),w=0,v=0,r.mode=5;case 5:if(1024&r.flags){for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.length=w,r.head&&(r.head.extra_len=w),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0)),w=0,v=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>b&&(k=b),k&&(r.head&&(B=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,h,d,k,B)),512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===b)break t;k=0;do{B=h[d+k++],r.head&&B&&r.length<65536&&(r.head.name+=String.fromCharCode(B))}while(B&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,B)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===b)break t;k=0;do{B=h[d+k++],r.head&&B&&r.length<65536&&(r.head.comment+=String.fromCharCode(B))}while(B&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,B)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(w!==(65535&r.check)){t.msg="header crc mismatch",r.mode=f;break}w=0,v=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=c;break;case 10:for(;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}t.adler=r.check=l(w),w=0,v=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=w,r.bits=v,2;t.adler=r.check=1,r.mode=c;case c:if(5===e||6===e)break t;case 13:if(r.last){w>>>=7&v,v-=7&v,r.mode=27;break}for(;v<3;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}switch(r.last=1&w,v-=1,3&(w>>>=1)){case 0:r.mode=14;break;case 1:if(m(r),r.mode=20,6===e){w>>>=2,v-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=f}w>>>=2,v-=2;break;case 14:for(w>>>=7&v,v-=7&v;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if((65535&w)!=(w>>>16^65535)){t.msg="invalid stored block lengths",r.mode=f;break}if(r.length=65535&w,w=0,v=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(k>b&&(k=b),k>g&&(k=g),0===k)break t;n.arraySet(p,h,d,k,y),b-=k,d+=k,g-=k,y+=k,r.length-=k;break}r.mode=c;break;case 17:for(;v<14;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(r.nlen=257+(31&w),w>>>=5,v-=5,r.ndist=1+(31&w),w>>>=5,v-=5,r.ncode=4+(15&w),w>>>=4,v-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=f;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;v<3;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.lens[M[r.have++]]=7&w,w>>>=3,v-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,U={bits:r.lenbits},N=s(0,r.lens,0,19,r.lencode,0,r.work,U),r.lenbits=U.bits,N){t.msg="invalid code lengths set",r.mode=f;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;x=(C=r.lencode[w&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(P<16)w>>>=A,v-=A,r.lens[r.have++]=P;else{if(16===P){for(j=A+2;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(w>>>=A,v-=A,0===r.have){t.msg="invalid bit length repeat",r.mode=f;break}B=r.lens[r.have-1],k=3+(3&w),w>>>=2,v-=2}else if(17===P){for(j=A+3;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}v-=A,B=0,k=3+(7&(w>>>=A)),w>>>=3,v-=3}else{for(j=A+7;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}v-=A,B=0,k=11+(127&(w>>>=A)),w>>>=7,v-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=f;break}for(;k--;)r.lens[r.have++]=B}}if(r.mode===f)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=f;break}if(r.lenbits=9,U={bits:r.lenbits},N=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,U),r.lenbits=U.bits,N){t.msg="invalid literal/lengths set",r.mode=f;break}if(r.distbits=6,r.distcode=r.distdyn,U={bits:r.distbits},N=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,U),r.distbits=U.bits,N){t.msg="invalid distances set",r.mode=f;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(b>=6&&g>=258){t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=w,r.bits=v,a(t,S),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,w=r.hold,v=r.bits,r.mode===c&&(r.back=-1);break}for(r.back=0;x=(C=r.lencode[w&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(x&&!(240&x)){for(I=A,L=x,R=P;x=(C=r.lencode[R+((w&(1<<I+L)-1)>>I)])>>>16&255,P=65535&C,!(I+(A=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}w>>>=I,v-=I,r.back+=I}if(w>>>=A,v-=A,r.back+=A,r.length=P,0===x){r.mode=26;break}if(32&x){r.back=-1,r.mode=c;break}if(64&x){t.msg="invalid literal/length code",r.mode=f;break}r.extra=15&x,r.mode=22;case 22:if(r.extra){for(j=r.extra;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.length+=w&(1<<r.extra)-1,w>>>=r.extra,v-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;x=(C=r.distcode[w&(1<<r.distbits)-1])>>>16&255,P=65535&C,!((A=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(!(240&x)){for(I=A,L=x,R=P;x=(C=r.distcode[R+((w&(1<<I+L)-1)>>I)])>>>16&255,P=65535&C,!(I+(A=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}w>>>=I,v-=I,r.back+=I}if(w>>>=A,v-=A,r.back+=A,64&x){t.msg="invalid distance code",r.mode=f;break}r.offset=P,r.extra=15&x,r.mode=24;case 24:if(r.extra){for(j=r.extra;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.offset+=w&(1<<r.extra)-1,w>>>=r.extra,v-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=f;break}r.mode=25;case 25:if(0===g)break t;if(k=S-g,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=f;break}k>r.wnext?(k-=r.wnext,T=r.wsize-k):T=r.wnext-k,k>r.length&&(k=r.length),O=r.window}else O=p,T=y-r.offset,k=r.length;k>g&&(k=g),g-=k,r.length-=k;do{p[y++]=O[T++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===g)break t;p[y++]=r.length,g--,r.mode=21;break;case 27:if(r.wrap){for(;v<32;){if(0===b)break t;b--,w|=h[d++]<<v,v+=8}if(S-=g,t.total_out+=S,r.total+=S,S&&(t.adler=r.check=r.flags?o(r.check,p,S,y-S):i(r.check,p,S,y-S)),S=g,(r.flags?w:l(w))!==r.check){t.msg="incorrect data check",r.mode=f;break}w=0,v=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(w!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=f;break}w=0,v=0}r.mode=29;case 29:N=1;break t;case f:N=-3;break t;case 31:return-4;default:return u}return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=w,r.bits=v,(r.wsize||S!==t.avail_out&&r.mode<f&&(r.mode<27||4!==e))&&_(t,t.output,t.next_out,S-t.avail_out)?(r.mode=31,-4):(E-=t.avail_in,S-=t.avail_out,t.total_in+=E,t.total_out+=S,r.total+=S,r.wrap&&S&&(t.adler=r.check=r.flags?o(r.check,p,S,t.next_out-S):i(r.check,p,S,t.next_out-S)),t.data_type=r.bits+(r.last?64:0)+(r.mode===c?128:0)+(20===r.mode||15===r.mode?256:0),(0===E&&0===S||4===e)&&0===N&&(N=-5),N)},e.inflateEnd=function(t){if(!t||!t.state)return u;var e=t.state;return e.window&&(e.window=null),t.state=null,0},e.inflateGetHeader=function(t,e){var r;return t&&t.state&&2&(r=t.state).wrap?(r.head=e,e.done=!1,0):u},e.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?u:11===r.mode&&i(1,e,n,0)!==r.check?-3:_(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):u},e.inflateInfo="pako inflate (from Nodeca project)"},1998:(t,e,r)=>{var n=r(9805),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,r,u,c,f,l,h){var p,d,y,b,g,w,v,m,_,E=h.bits,S=0,k=0,T=0,O=0,A=0,x=0,P=0,I=0,L=0,R=0,B=null,N=0,U=new n.Buf16(16),j=new n.Buf16(16),C=null,F=0;for(S=0;S<=15;S++)U[S]=0;for(k=0;k<u;k++)U[e[r+k]]++;for(A=E,O=15;O>=1&&0===U[O];O--);if(A>O&&(A=O),0===O)return c[f++]=20971520,c[f++]=20971520,h.bits=1,0;for(T=1;T<O&&0===U[T];T++);for(A<T&&(A=T),I=1,S=1;S<=15;S++)if(I<<=1,(I-=U[S])<0)return-1;if(I>0&&(0===t||1!==O))return-1;for(j[1]=0,S=1;S<15;S++)j[S+1]=j[S]+U[S];for(k=0;k<u;k++)0!==e[r+k]&&(l[j[e[r+k]]++]=k);if(0===t?(B=C=l,w=19):1===t?(B=i,N-=257,C=o,F-=257,w=256):(B=a,C=s,w=-1),R=0,k=0,S=T,g=f,x=A,P=0,y=-1,b=(L=1<<A)-1,1===t&&L>852||2===t&&L>592)return 1;for(;;){v=S-P,l[k]<w?(m=0,_=l[k]):l[k]>w?(m=C[F+l[k]],_=B[N+l[k]]):(m=96,_=0),p=1<<S-P,T=d=1<<x;do{c[g+(R>>P)+(d-=p)]=v<<24|m<<16|_}while(0!==d);for(p=1<<S-1;R&p;)p>>=1;if(0!==p?(R&=p-1,R+=p):R=0,k++,0==--U[S]){if(S===O)break;S=e[r+l[k]]}if(S>A&&(R&b)!==y){for(0===P&&(P=A),g+=T,I=1<<(x=S-P);x+P<O&&!((I-=U[x+P])<=0);)x++,I<<=1;if(L+=1<<x,1===t&&L>852||2===t&&L>592)return 1;c[y=R&b]=A<<24|x<<16|g-f}}return 0!==R&&(c[g+R]=S-P<<24|64<<16),h.bits=A,0}},4674:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},3665:(t,e,r)=>{var n=r(9805);function i(t){for(var e=t.length;--e>=0;)t[e]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],c=new Array(576);i(c);var f=new Array(60);i(f);var l=new Array(512);i(l);var h=new Array(256);i(h);var p=new Array(29);i(p);var d,y,b,g=new Array(30);function w(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function v(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function m(t){return t<256?l[t]:l[256+(t>>>7)]}function _(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function E(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,_(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function S(t,e,r){E(t,r[2*e],r[2*e+1])}function k(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function T(t,e,r){var n,i,o=new Array(16),a=0;for(n=1;n<=15;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=k(o[s]++,s))}}function O(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function A(t){t.bi_valid>8?_(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function x(t,e,r,n){var i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]}function P(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&x(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!x(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function I(t,e,r){var n,i,s,u,c=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],i=t.pending_buf[t.l_buf+c],c++,0===n?S(t,i,e):(S(t,(s=h[i])+256+1,e),0!==(u=o[s])&&E(t,i-=p[s],u),S(t,s=m(--n),r),0!==(u=a[s])&&E(t,n-=g[s],u))}while(c<t.last_lit);S(t,256,e)}function L(t,e){var r,n,i,o=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,u=e.stat_desc.elems,c=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(t.heap[++t.heap_len]=c=r,t.depth[r]=0):o[2*r+1]=0;for(;t.heap_len<2;)o[2*(i=t.heap[++t.heap_len]=c<2?++c:0)]=1,t.depth[i]=0,t.opt_len--,s&&(t.static_len-=a[2*i+1]);for(e.max_code=c,r=t.heap_len>>1;r>=1;r--)P(t,o,r);i=u;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,o,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,o[2*i]=o[2*r]+o[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,o[2*r+1]=o[2*n+1]=i,t.heap[1]=i++,P(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,o,a,s,u=e.dyn_tree,c=e.max_code,f=e.stat_desc.static_tree,l=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,y=0;for(o=0;o<=15;o++)t.bl_count[o]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(o=u[2*u[2*(n=t.heap[r])+1]+1]+1)>d&&(o=d,y++),u[2*n+1]=o,n>c||(t.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=u[2*n],t.opt_len+=s*(o+a),l&&(t.static_len+=s*(f[2*n+1]+a)));if(0!==y){do{for(o=d-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(o=d;0!==o;o--)for(n=t.bl_count[o];0!==n;)(i=t.heap[--r])>c||(u[2*i+1]!==o&&(t.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(t,e),T(o,c,t.bl_count)}function R(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=e[2*(n+1)+1],++s<u&&i===a||(s<c?t.bl_tree[2*i]+=s:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function B(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=e[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{S(t,i,t.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(S(t,i,t.bl_tree),s--),S(t,16,t.bl_tree),E(t,s-3,2)):s<=10?(S(t,17,t.bl_tree),E(t,s-3,3)):(S(t,18,t.bl_tree),E(t,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}i(g);var N=!1;function U(t,e,r,i){E(t,0+(i?1:0),3),function(t,e,r){A(t),_(t,r),_(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}e._tr_init=function(t){N||(function(){var t,e,r,n,i,u=new Array(16);for(r=0,n=0;n<28;n++)for(p[n]=r,t=0;t<1<<o[n];t++)h[r++]=n;for(h[r-1]=n,i=0,n=0;n<16;n++)for(g[n]=i,t=0;t<1<<a[n];t++)l[i++]=n;for(i>>=7;n<30;n++)for(g[n]=i<<7,t=0;t<1<<a[n]-7;t++)l[256+i++]=n;for(e=0;e<=15;e++)u[e]=0;for(t=0;t<=143;)c[2*t+1]=8,t++,u[8]++;for(;t<=255;)c[2*t+1]=9,t++,u[9]++;for(;t<=279;)c[2*t+1]=7,t++,u[7]++;for(;t<=287;)c[2*t+1]=8,t++,u[8]++;for(T(c,287,u),t=0;t<30;t++)f[2*t+1]=5,f[2*t]=k(t,5);d=new w(c,o,257,286,15),y=new w(f,a,0,30,15),b=new w(new Array(0),s,0,19,7)}(),N=!0),t.l_desc=new v(t.dyn_ltree,d),t.d_desc=new v(t.dyn_dtree,y),t.bl_desc=new v(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,O(t)},e._tr_stored_block=U,e._tr_flush_block=function(t,e,r,n){var i,o,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),L(t,t.l_desc),L(t,t.d_desc),a=function(t){var e;for(R(t,t.dyn_ltree,t.l_desc.max_code),R(t,t.dyn_dtree,t.d_desc.max_code),L(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*u[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?U(t,e,r,n):4===t.strategy||o===i?(E(t,2+(n?1:0),3),I(t,c,f)):(E(t,4+(n?1:0),3),function(t,e,r,n){var i;for(E(t,e-257,5),E(t,r-1,5),E(t,n-4,4),i=0;i<n;i++)E(t,t.bl_tree[2*u[i]+1],3);B(t,t.dyn_ltree,e-1),B(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),I(t,t.dyn_ltree,t.dyn_dtree)),O(t),n&&A(t)},e._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){E(t,2,3),S(t,256,c),function(t){16===t.bi_valid?(_(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},4442:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},6578:t=>{t.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},5606: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 a(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 s,u=[],c=!1,f=-1;function l(){c&&s&&(c=!1,s.length?u=s.concat(u):f=-1,u.length&&h())}function h(){if(!c){var t=a(l);c=!0;for(var e=u.length;e;){for(s=u,u=[];++f<e;)s&&s[f].run();f=-1,e=u.length}s=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||a(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}},3209:(t,e,r)=>{var n=r(5606),i=65536,o=r(2861).Buffer,a=r.g.crypto||r.g.msCrypto;a&&a.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 s=0;s<t;s+=i)a.getRandomValues(r.slice(s,s+i));else a.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),a=new Array(16),s=[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],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],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,a,s){return d(t+(e^r^n)+o+a|0,s)+i|0}function b(t,e,r,n,i,o,a,s){return d(t+(e&r|~e&n)+o+a|0,s)+i|0}function g(t,e,r,n,i,o,a,s){return d(t+((e|~r)^n)+o+a|0,s)+i|0}function w(t,e,r,n,i,o,a,s){return d(t+(e&n|r&~n)+o+a|0,s)+i|0}function v(t,e,r,n,i,o,a,s){return d(t+(e^(r|~n))+o+a|0,s)+i|0}i(p,o),p.prototype._update=function(){for(var t=a,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,m=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,T=0;T<80;T+=1){var O,A;T<16?(O=y(r,n,i,o,p,t[s[T]],l[0],c[T]),A=v(m,_,E,S,k,t[u[T]],h[0],f[T])):T<32?(O=b(r,n,i,o,p,t[s[T]],l[1],c[T]),A=w(m,_,E,S,k,t[u[T]],h[1],f[T])):T<48?(O=g(r,n,i,o,p,t[s[T]],l[2],c[T]),A=g(m,_,E,S,k,t[u[T]],h[2],f[T])):T<64?(O=w(r,n,i,o,p,t[s[T]],l[3],c[T]),A=b(m,_,E,S,k,t[u[T]],h[3],f[T])):(O=v(r,n,i,o,p,t[s[T]],l[4],c[T]),A=y(m,_,E,S,k,t[u[T]],h[4],f[T])),r=p,p=o,o=d(i,10),i=n,n=O,m=k,k=S,S=d(E,10),E=_,_=A}var x=this._b+i+S|0;this._b=this._c+o+k|0,this._c=this._d+p+m|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=x},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 a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.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},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},6897:(t,e,r)=>{var n=r(453),i=r(41),o=r(592)(),a=r(5795),s=r(9675),u=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new s("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||u(e)!==e)throw new s("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,c=!0;if("length"in t&&a){var f=a(t,"length");f&&!f.configurable&&(n=!1),f&&!f.writable&&(c=!1)}return(n||c||!r)&&(o?i(t,"length",e,!0,!0):i(t,"length",e)),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,a=this._len,s=0;s<o;){for(var u=a%i,c=Math.min(o-s,i-u),f=0;f<c;f++)r[u+f]=t[s+f];s+=c,(a+=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,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(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,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,s)+u+r[h]+a[p];u=s,s=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=s+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,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function f(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,s=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)+l(d,i,o,s)+u+r[p]+a[d]|0;u=s,s=o,o=f(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=s+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),a=r(2861).Buffer,s=new Array(64);function u(){this.init(),this._w=s,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=a.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,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(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}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}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=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0|this._f,y=0|this._g,b=0|this._h,g=0;g<16;++g)e[g]=t.readInt32BE(4*g);for(;g<64;++g)e[g]=d(e[g-2])+e[g-7]+p(e[g-15])+e[g-16]|0;for(var w=0;w<64;++w){var v=b+h(s)+c(s,u,y)+a[w]+e[w]|0,m=l(r)+f(r,n,i)|0;b=y,y=u,u=s,s=o+v|0,o=i,i=n,n=r,r=v+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=b+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),a=r(2861).Buffer,s=new Array(160);function u(){this.init(),this._w=s,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=a.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,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(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 b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(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,s=0|this._eh,u=0|this._fh,w=0|this._gh,v=0|this._hh,m=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,T=0|this._fl,O=0|this._gl,A=0|this._hl,x=0;x<32;x+=2)e[x]=t.readInt32BE(4*x),e[x+1]=t.readInt32BE(4*x+4);for(;x<160;x+=2){var P=e[x-30],I=e[x-30+1],L=p(P,I),R=d(I,P),B=y(P=e[x-4],I=e[x-4+1]),N=b(I,P),U=e[x-14],j=e[x-14+1],C=e[x-32],F=e[x-32+1],M=R+j|0,D=L+U+g(M,R)|0;D=(D=D+B+g(M=M+N|0,N)|0)+C+g(M=M+F|0,F)|0,e[x]=D,e[x+1]=M}for(var H=0;H<160;H+=2){D=e[H],M=e[H+1];var K=f(r,n,i),W=f(m,_,E),G=l(r,m),V=l(m,r),z=h(s,k),q=h(k,s),X=a[H],$=a[H+1],Y=c(s,u,w),Z=c(k,T,O),J=A+q|0,Q=v+z+g(J,A)|0;Q=(Q=(Q=Q+Y+g(J=J+Z|0,Z)|0)+X+g(J=J+$|0,$)|0)+D+g(J=J+M|0,M)|0;var tt=V+W|0,et=G+K+g(tt,V)|0;v=w,A=O,w=u,O=T,u=s,T=k,s=o+Q+g(k=S+J|0,S)|0,o=i,S=E,i=n,E=_,n=r,_=m,r=Q+et+g(m=J+tt|0,J)|0}this._al=this._al+m|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+T|0,this._gl=this._gl+O|0,this._hl=this._hl+A|0,this._ah=this._ah+r+g(this._al,m)|0,this._bh=this._bh+n+g(this._bl,_)|0,this._ch=this._ch+i+g(this._cl,E)|0,this._dh=this._dh+o+g(this._dl,S)|0,this._eh=this._eh+s+g(this._el,k)|0,this._fh=this._fh+u+g(this._fl,T)|0,this._gh=this._gh+w+g(this._gl,O)|0,this._hh=this._hh+v+g(this._hl,A)|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",s),r.on("close",u));var a=!1;function s(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),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,a,s,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"))a="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(s=t).length||-1===s.indexOf(".",u)?"argument":"property");a='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return a+". 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(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6891),a=r(1999);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.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",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.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(5606);t.exports=T,T.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1396),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(7199);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(1766),y=r(4347),b=r(6644).getHighWaterMark,g=r(2463).F,w=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(T,s);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(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=b(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&&(l||(l=r(3516).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(8101),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.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?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,L(t)))}}(t,s);else if(i||(a=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}(s,e)),a)E(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?E(t,new _):A(t,s,e,!0);else if(s.ended)E(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?A(t,s,e,!1):R(t,s)):A(t,s,e,!1)}else n||(s.reading=!1,R(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function A(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&&I(t)),R(t,e)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.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),O(this,t,e,!1,r)},T.prototype.unshift=function(t){return O(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){l||(l=r(3516).I);var e=new l(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 x=1073741824;function P(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>=x?t=x:(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 I(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(L,t))}function L(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,C(t)}function R(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(B,t,e))}function B(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 N(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 U(t){o("readable nexttick read 0"),t.read(0)}function j(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(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 M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(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 H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}T.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?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(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=P(r,e))),null===(n=t>0?F(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&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new m("_read()"))},T.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 s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.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",l),f=!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&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(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",l),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},T.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 a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var r=s.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?I(this):n.reading||i.nextTick(U,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(N,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(N,this),e},T.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(j,t,e))}(this,t)),t.paused=!1,this},T.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},T.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 a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=F,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,e){return void 0===p&&(p=r(968)),p(T,t,e)})},9083:(t,e,r)=>{t.exports=f;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=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 f(t){if(!(this instanceof f))return new f(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",l)}function l(){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 s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.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)}},f.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))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},1999:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=T,T.WritableState=k;var a,s={deprecate:r(4643)},u=r(1396),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,v=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(8101),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,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 b;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(L,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),L(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||x(t,r),n?i.nextTick(A,t,r,a,o):A(t,r,a,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 T(t){var e=this instanceof(n=n||r(8101));if(!e&&!a.call(T,this))return new T(t);this._writableState=new k(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 O(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,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 A(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),L(t,e)}function x(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,O(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),L(t,e)}))}function L(t,e){var r=P(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(I,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)(T,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.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]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===T&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new g)},T.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new v:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else O(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||x(this,t))},T.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 _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.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,L(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}},5034:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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 a=r(4257),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=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[f])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[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?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[l]=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),g);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",b.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=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,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,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}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=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{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:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4347:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,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 a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),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,a=i.ERR_STREAM_DESTROYED;function s(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 f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(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 s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!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 a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))}))}));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},3516:(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=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){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 f(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 l(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=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(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}},9579:(t,e,r)=>{var n=r(8287).Buffer,i=n.isEncoding||function(t){switch(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}},o=e.I=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!i(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new n(6),this.charReceived=0,this.charLength=0};function a(t){return t.toString(this.encoding)}function s(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function u(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},o.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},o.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},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 a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(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 "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(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 "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(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,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function a(t){return n.isBuffer(t)}function s(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),f=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,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,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={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=l(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=l(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 a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(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]=l(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 s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);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(l);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(l);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 l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.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 f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,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)}}},1135:t=>{t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},9032:(t,e,r)=>{var n=r(7244),i=r(8184),o=r(5767),a=r(5680);function s(t){return t.call.bind(t)}var u="undefined"!=typeof BigInt,c="undefined"!=typeof Symbol,f=s(Object.prototype.toString),l=s(Number.prototype.valueOf),h=s(String.prototype.valueOf),p=s(Boolean.prototype.valueOf);if(u)var d=s(BigInt.prototype.valueOf);if(c)var y=s(Symbol.prototype.valueOf);function b(t,e){if("object"!=typeof t)return!1;try{return e(t),!0}catch(t){return!1}}function g(t){return"[object Map]"===f(t)}function w(t){return"[object Set]"===f(t)}function v(t){return"[object WeakMap]"===f(t)}function m(t){return"[object WeakSet]"===f(t)}function _(t){return"[object ArrayBuffer]"===f(t)}function E(t){return"undefined"!=typeof ArrayBuffer&&(_.working?_(t):t instanceof ArrayBuffer)}function S(t){return"[object DataView]"===f(t)}function k(t){return"undefined"!=typeof DataView&&(S.working?S(t):t instanceof DataView)}e.isArgumentsObject=n,e.isGeneratorFunction=i,e.isTypedArray=a,e.isPromise=function(t){return"undefined"!=typeof Promise&&t instanceof Promise||null!==t&&"object"==typeof t&&"function"==typeof t.then&&"function"==typeof t.catch},e.isArrayBufferView=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):a(t)||k(t)},e.isUint8Array=function(t){return"Uint8Array"===o(t)},e.isUint8ClampedArray=function(t){return"Uint8ClampedArray"===o(t)},e.isUint16Array=function(t){return"Uint16Array"===o(t)},e.isUint32Array=function(t){return"Uint32Array"===o(t)},e.isInt8Array=function(t){return"Int8Array"===o(t)},e.isInt16Array=function(t){return"Int16Array"===o(t)},e.isInt32Array=function(t){return"Int32Array"===o(t)},e.isFloat32Array=function(t){return"Float32Array"===o(t)},e.isFloat64Array=function(t){return"Float64Array"===o(t)},e.isBigInt64Array=function(t){return"BigInt64Array"===o(t)},e.isBigUint64Array=function(t){return"BigUint64Array"===o(t)},g.working="undefined"!=typeof Map&&g(new Map),e.isMap=function(t){return"undefined"!=typeof Map&&(g.working?g(t):t instanceof Map)},w.working="undefined"!=typeof Set&&w(new Set),e.isSet=function(t){return"undefined"!=typeof Set&&(w.working?w(t):t instanceof Set)},v.working="undefined"!=typeof WeakMap&&v(new WeakMap),e.isWeakMap=function(t){return"undefined"!=typeof WeakMap&&(v.working?v(t):t instanceof WeakMap)},m.working="undefined"!=typeof WeakSet&&m(new WeakSet),e.isWeakSet=function(t){return m(t)},_.working="undefined"!=typeof ArrayBuffer&&_(new ArrayBuffer),e.isArrayBuffer=E,S.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&S(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=k;var T="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function O(t){return"[object SharedArrayBuffer]"===f(t)}function A(t){return void 0!==T&&(void 0===O.working&&(O.working=O(new T)),O.working?O(t):t instanceof T)}function x(t){return b(t,l)}function P(t){return b(t,h)}function I(t){return b(t,p)}function L(t){return u&&b(t,d)}function R(t){return c&&b(t,y)}e.isSharedArrayBuffer=A,e.isAsyncFunction=function(t){return"[object AsyncFunction]"===f(t)},e.isMapIterator=function(t){return"[object Map Iterator]"===f(t)},e.isSetIterator=function(t){return"[object Set Iterator]"===f(t)},e.isGeneratorObject=function(t){return"[object Generator]"===f(t)},e.isWebAssemblyCompiledModule=function(t){return"[object WebAssembly.Module]"===f(t)},e.isNumberObject=x,e.isStringObject=P,e.isBooleanObject=I,e.isBigIntObject=L,e.isSymbolObject=R,e.isBoxedPrimitive=function(t){return x(t)||P(t)||I(t)||L(t)||R(t)},e.isAnyArrayBuffer=function(t){return"undefined"!=typeof Uint8Array&&(E(t)||A(t))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})}))},537:(t,e,r)=>{var n=r(5606),i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},o=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(c(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(t).replace(o,(function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),s=n[r];r<i;s=n[++r])g(s)||!E(s)?a+=" "+s:a+=" "+c(s);return a},e.deprecate=function(t,r){if(void 0!==n&&!0===n.noDeprecation)return t;if(void 0===n)return function(){return e.deprecate(t,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return t.apply(this,arguments)}};var a={},s=/^$/;if(n.env.NODE_DEBUG){var u=n.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}function c(t,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=f),h(n,t,n.depth)}function f(t,e){var r=c.styles[e];return r?"["+c.colors[r][0]+"m"+t+"["+c.colors[r][1]+"m":t}function l(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return v(i)||(i=h(t,i,n)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return w(e)?t.stylize(""+e,"number"):b(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}(t,r);if(o)return o;var a=Object.keys(r),s=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),k(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(r);if(0===a.length){if(T(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return t.stylize(Date.prototype.toString.call(r),"date");if(k(r))return p(r)}var c,f="",l=!1,E=["{","}"];return y(r)&&(l=!0,E=["[","]"]),T(r)&&(f=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(f=" "+RegExp.prototype.toString.call(r)),S(r)&&(f=" "+Date.prototype.toUTCString.call(r)),k(r)&&(f=" "+p(r)),0!==a.length||l&&0!=r.length?n<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=l?function(t,e,r,n,i){for(var o=[],a=0,s=e.length;a<s;++a)P(e,String(a))?o.push(d(t,e,r,n,String(a),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))})),o}(t,r,n,s,a):a.map((function(e){return d(t,r,n,s,e,l)})),t.seen.pop(),function(t,e,r){return t.reduce((function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,f,E)):E[0]+f+E[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=g(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(t){return" "+t})).join("\n").slice(2):"\n"+s.split("\n").map((function(t){return" "+t})).join("\n")):s=t.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function y(t){return Array.isArray(t)}function b(t){return"boolean"==typeof t}function g(t){return null===t}function w(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function _(t){return E(t)&&"[object RegExp]"===O(t)}function E(t){return"object"==typeof t&&null!==t}function S(t){return E(t)&&"[object Date]"===O(t)}function k(t){return E(t)&&("[object Error]"===O(t)||t instanceof Error)}function T(t){return"function"==typeof t}function O(t){return Object.prototype.toString.call(t)}function A(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t])if(s.test(t)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=r(9032),e.isArray=y,e.isBoolean=b,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=w,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=_,e.types.isRegExp=_,e.isObject=E,e.isDate=S,e.types.isDate=S,e.isError=k,e.types.isNativeError=k,e.isFunction=T,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(1135);var x=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[A(t.getHours()),A(t.getMinutes()),A(t.getSeconds())].join(":");return[t.getDate(),x[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(6698),e._extend=function(t,e){if(!e||!E(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var I="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function L(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(I&&t[I]){var e;if("function"!=typeof(e=t[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(t,n){t?r(t):e(n)}));try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),I&&Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=I,e.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function e(){for(var e=[],r=0;r<arguments.length;r++)e.push(arguments[r]);var i=e.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,e).then((function(t){n.nextTick(a.bind(null,null,t))}),(function(t){n.nextTick(L.bind(null,t,a))}))}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,i(t)),e}},8469:(t,e,r)=>{var n=r(2861).Buffer;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),t.bytes=1):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),t.bytes=5):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+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 o=e.readUInt8(r);if(o<253)return t.bytes=1,o;if(253===o)return t.bytes=3,e.readUInt16LE(r+1);if(254===o)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var a=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+a;return i(s),s},encodingLength:o}},5767:(t,e,r)=>{var n=r(2682),i=r(9209),o=r(487),a=r(8075),s=r(5795),u=a("Object.prototype.toString"),c=r(9092)(),f="undefined"==typeof globalThis?r.g:globalThis,l=i(),h=a("String.prototype.slice"),p=Object.getPrototypeOf,d=a("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},y={__proto__:null};n(l,c&&s&&p?function(t){var e=new f[t];if(Symbol.toStringTag in e){var r=p(e),n=s(r,Symbol.toStringTag);if(!n){var i=p(r);n=s(i,Symbol.toStringTag)}y["$"+t]=o(n.get)}}:function(t){var e=new f[t],r=e.slice||e.set;r&&(y["$"+t]=o(r))}),t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!c){var e=h(u(t),8,-1);return d(l,e)>-1?e:"Object"===e&&function(t){var e=!1;return n(y,(function(r,n){if(!e)try{r(t),e=h(n,1)}catch(t){}})),e}(t)}return s?function(t){var e=!1;return n(y,(function(r,n){if(!e)try{"$"+r(t)===n&&(e=h(n,1))}catch(t){}})),e}(t):null}},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 a(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(a(t,e,r)):i.encode(a(t.version,t.privateKey,t.compressed))},encodeRaw:a}},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),a=o.charCodeAt(0);if(255!==e[a])throw new TypeError(o+" is ambiguous");e[a]=i}var s=t.length,u=t.charAt(0),c=Math.log(s)/Math.log(256),f=Math.log(256)/Math.log(s);function l(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 a=(t.length-r)*c+1>>>0,f=new Uint8Array(a);r<t.length;){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=a-1;(0!==l||h<o)&&-1!==p;p--,h++)l+=s*f[p]>>>0,f[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}for(var d=a-o;d!==a&&0===f[d];)d++;var y=n.allocUnsafe(i+(a-d));y.fill(0,0,i);for(var b=i;d!==a;)y[b++]=f[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,a=e.length;o!==a&&0===e[o];)o++,r++;for(var c=(a-o)*f+1>>>0,l=new Uint8Array(c);o!==a;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*l[d]>>>0,l[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===l[y];)y++;for(var b=u.repeat(r);y<c;++y)b+=t.charAt(l[y]);return b},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" 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()}))},4923:()=>{},8460:()=>{},2382:()=>{},3779:()=>{},7199:()=>{},9209:(t,e,r)=>{var n=r(6578),i="undefined"==typeof globalThis?r.g:globalThis;t.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t}}},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}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},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 a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&r;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach((t=>a[t]=()=>r[t]));return a.default=()=>r,i.d(o,a),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,{iy:()=>vt,z2:()=>kt,G7:()=>ti,GF:()=>V,nU:()=>Er,wf:()=>p,gf:()=>nn,P8:()=>Ar,vg:()=>st,nr:()=>Us,ry:()=>pi,z4:()=>tt,qT:()=>Di,kd:()=>R,eA:()=>Wr,no:()=>Br,o4:()=>Fr,YV:()=>N,O5:()=>L,cC:()=>$i,Wj:()=>m,Bc:()=>ro,LL:()=>zr,gK:()=>jr,PE:()=>Hr,Go:()=>Ns,IB:()=>pt,rl:()=>ua,Y_:()=>cn,yo:()=>As,Ko:()=>$r,pe:()=>Rr,ho:()=>Xr,_l:()=>xa,QS:()=>Gr,Bm:()=>Nr,W_:()=>Mr,Hu:()=>Ha,Mg:()=>Lo,$v:()=>qr,mt:()=>Cr,lJ:()=>Kr,ih:()=>an,aw:()=>Oi,tm:()=>wr,Qc:()=>pr,dF:()=>is,Wb:()=>je,D_:()=>un,aS:()=>Ce,_3:()=>Ze,A9:()=>Bs,V$:()=>Rs,xc:()=>zs,S2:()=>ys,qn:()=>ka,Gc:()=>Vr,zM:()=>Ur,c:()=>Dr,uW:()=>Sr,FV:()=>Wa,UB:()=>fs,jz:()=>fn,hL:()=>ln,$7:()=>a,rE:()=>s,rR:()=>on});var a={};i.r(a),i.d(a,{AddressGenerator:()=>vt,AddressVerificator:()=>kt,BitcoinUtils:()=>ti,CalldataGenerator:()=>V,ChainId:()=>Er,Compressor:()=>p,Consensus:()=>nn,ContractBaseMetadata:()=>Ar,CustomGenerator:()=>st,CustomKeypair:()=>Us,CustomScriptTransaction:()=>pi,DeploymentGenerator:()=>tt,DeploymentTransaction:()=>Di,EcKeyPair:()=>R,FACTORY_ADDRESS_FRACTAL:()=>Wr,FACTORY_ADDRESS_REGTEST:()=>Br,FACTORY_ADDRESS_TESTNET:()=>Fr,FeatureOpCodes:()=>N,Features:()=>L,FundingTransaction:()=>$i,Generator:()=>m,InteractionTransaction:()=>ro,MOTO_ADDRESS_FRACTAL:()=>zr,MOTO_ADDRESS_REGTEST:()=>jr,MOTO_ADDRESS_TESTNET:()=>Hr,MessageType:()=>Ns,MultiSignGenerator:()=>pt,MultiSignTransaction:()=>ua,OPNetConsensusConfig:()=>cn,OPNetLimitedProvider:()=>As,OPNetMetadata:()=>$r,OPNetNetwork:()=>Rr,OPNetTokenAddressManager:()=>Xr,P2TR_MS:()=>xa,POOL_ADDRESS_FRACTAL:()=>Gr,POOL_ADDRESS_REGTEST:()=>Nr,POOL_ADDRESS_TESTNET:()=>Mr,PSBTTypes:()=>Ha,PsbtTransaction:()=>Lo,ROUTER_ADDRESS_FRACTAL:()=>qr,ROUTER_ADDRESS_REGTEST:()=>Cr,ROUTER_ADDRESS_TESTNET:()=>Kr,RoswellConsensus:()=>an,SharedInteractionTransaction:()=>Oi,TapscriptVerificator:()=>wr,TransactionBuilder:()=>pr,TransactionFactory:()=>is,TransactionSequence:()=>je,TransactionType:()=>un,TweakedSigner:()=>Ce,TweakedTransaction:()=>Ze,UnisatChainType:()=>Bs,UnisatNetwork:()=>Rs,UnisatSigner:()=>zs,UnwrapGeneration:()=>ys,UnwrapTransaction:()=>ka,WBTC_ADDRESS_FRACTAL:()=>Vr,WBTC_ADDRESS_REGTEST:()=>Ur,WBTC_ADDRESS_TESTNET:()=>Dr,Wallet:()=>Sr,WrapTransaction:()=>Wa,WrappedGeneration:()=>fs,currentConsensus:()=>fn,currentConsensusConfig:()=>ln,version:()=>s,wBTC:()=>on});var s="1.0.111",u=i(8559),c=i.n(u);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 l(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,h(n.key),n)}}function h(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}var p=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compress",value:function(e){return c().gzipSync(e,t.zlibOptions)}},{key:"decompress",value:function(e){return c().gunzipSync(e,t.zlibOptions)}}])}();!function(t,e,r){(e=h(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(p,"zlibOptions",{level:9,maxOutputLength:16777216});var d=i(1757),y=i(8287).Buffer;function b(t){return b="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},b(t)}function g(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,v(n.key),n)}}function w(t,e,r){return(e=v(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function v(t){var e=function(t){if("object"!=b(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=b(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==b(e)?e:e+""}var m=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),w(this,"network",d.o8.bitcoin),this.senderPubKey=e,this.contractSaltPubKey=r,this.network=n}return function(t,e){return e&&g(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"splitBufferIntoChunks",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DATA_CHUNK_SIZE,n=[],i=0;i<e.length;i+=r){for(var o=Math.min(r,e.length-i),a=y.alloc(o),s=0;s<o;s++)a.writeUInt8(e[i+s],s);n.push([a])}return n}}])}();w(m,"DATA_CHUNK_SIZE",512),w(m,"MAGIC",y.from("bsi","utf-8"));var _=i(3513),E=i.t(_,2),S=i(852),k=i(477),T=i(8700);function O(t){return O="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},O(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,P(n.key),n)}}function x(t,e,r){return(e=P(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function P(t){var e=function(t){if("object"!=O(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=O(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==O(e)?e:e+""}(0,d.f0)(E);var I="function"==typeof S.Ay?S.Ay:S.Pr;if(!I)throw new Error("Failed to load BIP32 library");var L,R=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&A(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"fromWIF",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.ECPair.fromWIF(t,e)}},{key:"fromPrivateKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.ECPair.fromPrivateKey(t,{network:e})}},{key:"fromPublicKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.ECPair.fromPublicKey(t,{network:e})}},{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin,n=this.verifyPubKeys(t,r);if(n.length!==t.length)throw new Error("Contains invalid public keys");var i=d.KT.p2ms({m:e,pubkeys:n,network:r}),o=d.KT.p2wsh({redeem:i,network:r}).address;if(!o)throw new Error("Failed to generate address");return o}},{key:"verifyPubKeys",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return e.map((function(e){var n=t.fromPublicKey(e,r);if(!n)throw new Error("Failed to regenerate key");return n.publicKey}))}},{key:"getP2WPKHAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2wpkh({pubkey:t.publicKey,network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"generateWallet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin,e=this.ECPair.makeRandom({network:t}),r=this.getP2WPKHAddress(e,t);if(!r)throw new Error("Failed to generate wallet");return{address:r,privateKey:e.toWIF(),publicKey:e.publicKey.toString("hex")}}},{key:"verifyContractAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return!!d.hl.toOutputScript(t,e)}},{key:"getLegacyAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2pkh({pubkey:t.publicKey,network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"generateRandomKeyPair",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin;return this.ECPair.makeRandom({network:t})}},{key:"fromSeed",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.BIP32.fromSeed(t,e)}},{key:"getTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2tr({internalPubkey:(0,k.toXOnly)(t.publicKey),network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"getTaprootAddressFromAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2tr({address:t,network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"fromSeedKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=this.BIP32.fromSeed(t,e).privateKey;if(!r)throw new Error("Failed to generate key pair");return this.ECPair.fromPrivateKey(r,{network:e})}}])}();function B(t){return B="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},B(t)}x(R,"BIP32",I(E)),x(R,"ECPair",(0,T.dg)(E)),function(t){t[t.UNWRAP=0]="UNWRAP"}(L||(L={}));var N=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=B(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=B(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==B(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},L.UNWRAP,d.Ez.OP_16),U=i(8287).Buffer;function j(t){return j="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},j(t)}function C(t){return function(t){if(Array.isArray(t))return M(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||F(t)||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.")}()}function F(t,e){if(t){if("string"==typeof t)return M(t,e);var r={}.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)?M(t,e):void 0}}function M(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function D(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,H(n.key),n)}}function H(t){var e=function(t){if("object"!=j(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=j(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==j(e)?e:e+""}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 G(t,e){return G=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},G(t,e)}var V=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=W(e),function(t,e){if(e&&("object"==j(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))}(this,t,[e,r,n])}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&&G(t,e)}(t,m),function(t,e,r){return e&&D(t.prototype,e),r&&D(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var s=this.splitBufferIntoChunks(e);if(!s.length)throw new Error("No data chunks found");var u=[this.senderPubKey,d.Ez.OP_CHECKSIGVERIFY,this.contractSaltPubKey,d.Ez.OP_CHECKSIGVERIFY,d.Ez.OP_HASH160,d.Et.hash160(this.senderPubKey),d.Ez.OP_EQUALVERIFY,d.Ez.OP_HASH160,d.Et.hash160(r),d.Ez.OP_EQUALVERIFY,d.Ez.OP_DEPTH,d.Ez.OP_1,d.Ez.OP_NUMEQUAL,d.Ez.OP_IF,m.MAGIC];if(o.length>0){var c,f,l=t.getPubKeyAsBuffer(o,this.network),h=this.splitBufferIntoChunks(l);if(u=(c=u).concat.apply(c,[d.Ez.OP_0].concat(C(h))),!a)throw new Error("Minimum signatures must be provided");if(a>255)throw new Error("Minimum signatures cannot exceed 255");var p=U.alloc(2);p.writeUint16LE(a,0),u=(f=u).concat.apply(f,[d.Ez.OP_1,p])}var y=i.map((function(t){return N[t]})),b=(u=(n=u).concat.apply(n,C(y).concat([d.Ez.OP_1NEGATE].concat(C(s),[d.Ez.OP_ELSE,d.Ez.OP_1,d.Ez.OP_ENDIF])))).flat(),g=d.K$.compile(b);if(!d.K$.decompile(g))throw new Error("Failed to decompile script??");return g}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=U.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=F(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}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 i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!R.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=U.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=p.compress(n);return a.byteLength>=n.byteLength?n:a}}])}();function z(t){return z="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},z(t)}function q(t){return function(t){if(Array.isArray(t))return X(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return X(t,e);var r={}.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)?X(t,e):void 0}}(t)||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.")}()}function X(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function $(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,Y(n.key),n)}}function Y(t){var e=function(t){if("object"!=z(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=z(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==z(e)?e:e+""}function Z(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Z=function(){return!!t})()}function J(t){return J=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},J(t)}function Q(t,e){return Q=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Q(t,e)}var tt=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=J(e),function(t,e){if(e&&("object"==z(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,Z()?Reflect.construct(e,r||[],J(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}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&&Q(t,e)}(t,m),function(t,e){return e&&$(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r){var n=this.getAsm(t,e,r),i=d.K$.compile(n);if(!d.K$.decompile(i))throw new Error("Failed to decompile script??");return i}},{key:"getAsm",value:function(t,e,r){if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var n=this.splitBufferIntoChunks(t),i=r?this.splitBufferIntoChunks(r):[];return[this.senderPubKey,d.Ez.OP_CHECKSIGVERIFY,this.contractSaltPubKey,d.Ez.OP_CHECKSIGVERIFY,d.Ez.OP_HASH160,d.Et.hash160(this.senderPubKey),d.Ez.OP_EQUALVERIFY,d.Ez.OP_HASH256,d.Et.hash256(e),d.Ez.OP_EQUALVERIFY,d.Ez.OP_DEPTH,d.Ez.OP_1,d.Ez.OP_NUMEQUAL,d.Ez.OP_IF,m.MAGIC,d.Ez.OP_0].concat(q(i),[d.Ez.OP_1NEGATE],q(n),[d.Ez.OP_ELSE,d.Ez.OP_1,d.Ez.OP_ENDIF]).flat()}}])}();function et(t){return et="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},et(t)}function rt(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,nt(n.key),n)}}function nt(t){var e=function(t){if("object"!=et(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=et(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==et(e)?e:e+""}function it(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(it=function(){return!!t})()}function ot(t){return ot=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ot(t)}function at(t,e){return at=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},at(t,e)}var st=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=ot(e),function(t,e){if(e&&("object"==et(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,it()?Reflect.construct(e,r||[],ot(t).constructor):e.apply(t,r))}(this,t,[e,void 0,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&&at(t,e)}(t,m),function(t,e){return e&&rt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=t.flat(),r=d.K$.compile(e);if(!d.K$.decompile(r))throw new Error("Failed to decompile script??");return r}}])}(),ut=i(8287).Buffer;function ct(t){return ct="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},ct(t)}function ft(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function lt(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,ht(n.key),n)}}function ht(t){var e=function(t){if("object"!=ct(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ct(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ct(e)?e:e+""}var pt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&<(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compile",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;if(r<2)throw new Error("Minimum signatures must be greater than 1");if(e.length<r)throw new Error("The amount of public keys is lower than the minimum required");if(r>t.MAXIMUM_SUPPORTED_SIGNATURE)throw new Error("The maximum amount of signatures is ".concat(t.MAXIMUM_SUPPORTED_SIGNATURE));var i=ut.alloc(1);i.writeUInt8(r),e=(e=e.filter((function(t,e,r){return e===r.findIndex((function(e){return t.equals(e)}))}))).sort((function(t,e){return t.compare(e)}));var o=!1,a=e.map((function(t){var e=(0,k.toXOnly)(t);return n&&!o&&(o=n.equals(e)),e}));n&&!o&&a.push(n);var s=[d.Ez.OP_0].concat(function(t){return function(t){if(Array.isArray(t))return ft(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return ft(t,e);var r={}.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)?ft(t,e):void 0}}(t)||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.")}()}(a.flatMap((function(t){return[t,d.Ez.OP_CHECKSIGADD]}))),[i,d.Ez.OP_NUMEQUAL]).flat(),u=d.K$.compile(s);if(!d.K$.decompile(u))throw new Error("Failed to decompile script.");return u}}])}();!function(t,e){(e=ht(e))in t?Object.defineProperty(t,e,{value:255,enumerable:!0,configurable:!0,writable:!0}):t[e]=255}(pt,"MAXIMUM_SUPPORTED_SIGNATURE");var dt=i(2343),yt=i(1944);function bt(t){return bt="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},bt(t)}function gt(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,wt(n.key),n)}}function wt(t){var e=function(t){if("object"!=bt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bt(e)?e:e+""}(0,d.f0)(E);var vt=function(){return function(t,e,r){return r&>(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generatePKSH",value:function(t,e){if(32!==t.length)throw new Error("Invalid hash length");var r=(0,yt.ripemd160)(t);return this.toSegwitAddress(r,e)}},{key:"toSegwitAddress",value:function(t,e){var r=dt.bech32.toWords(t);return r.unshift(0),dt.bech32.encode(e.bech32,r)}}])}(),mt=i(606);function _t(t){return _t="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},_t(t)}function Et(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,St(n.key),n)}}function St(t){var e=function(t){if("object"!=_t(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=_t(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==_t(e)?e:e+""}(0,d.f0)(E);var kt=function(){return function(t,e,r){return r&&Et(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"isValidP2TRAddress",value:function(t,e){if(!t||t.length<50)return!1;var r=!1;try{d.hl.toOutputScript(t,e),r=1===d.hl.fromBech32(t).version}catch(t){}return r}},{key:"validatePKHAddress",value:function(t,e){if(!t||t.length<20||t.length>50)return!1;var r=!1;try{var n=d.hl.fromBech32(t);d.hl.toOutputScript(t,e),r=0===n.version&&20===n.data.length}catch(t){}return r}}])}(),Tt={d:(t,e)=>{for(var r in e)Tt.o(e,r)&&!Tt.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},Ot={};Tt.d(Ot,{q$:()=>xe,Vy:()=>Pe,$7:()=>At,rE:()=>xt});var At={};Tt.r(At),Tt.d(At,{DebugLevel:()=>xe,Logger:()=>Pe,version:()=>xt});var xt="1.0.2";function Pt(t,e){t=t.replace("#","");var r=parseInt(t,16),n=Math.round(2.55*e),i=(r>>16)+n,o=(r>>8&255)+n,a=(255&r)+n;return(16777216+65536*(i<255?i<1?0:i:255)+256*(o<255?o<1?0:o:255)+(a<255?a<1?0:a:255)).toString(16).slice(1)}const It=(t=0)=>e=>`[${e+t}m`,Lt=(t=0)=>e=>`[${38+t};5;${e}m`,Rt=(t=0)=>(e,r,n)=>`[${38+t};2;${e};${r};${n}m`,Bt={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(Bt.modifier),Object.keys(Bt.color),Object.keys(Bt.bgColor);const Nt=function(){const t=new Map;for(const[e,r]of Object.entries(Bt)){for(const[e,n]of Object.entries(r))Bt[e]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[e]=Bt[e],t.set(n[0],n[1]);Object.defineProperty(Bt,e,{value:r,enumerable:!1})}return Object.defineProperty(Bt,"codes",{value:t,enumerable:!1}),Bt.color.close="[39m",Bt.bgColor.close="[49m",Bt.color.ansi=It(),Bt.color.ansi256=Lt(),Bt.color.ansi16m=Rt(),Bt.bgColor.ansi=It(10),Bt.bgColor.ansi256=Lt(10),Bt.bgColor.ansi16m=Rt(10),Object.defineProperties(Bt,{rgbToAnsi256:{value:(t,e,r)=>t===e&&e===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[r]=e;3===r.length&&(r=[...r].map((t=>t+t)).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:t=>Bt.rgbToAnsi256(...Bt.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,r,n;if(t>=232)e=(10*(t-232)+8)/255,r=e,n=e;else{const i=(t-=16)%36;e=Math.floor(t/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(e,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(e));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,r)=>Bt.ansi256ToAnsi(Bt.rgbToAnsi256(t,e,r)),enumerable:!1},hexToAnsi:{value:t=>Bt.ansi256ToAnsi(Bt.hexToAnsi256(t)),enumerable:!1}}),Bt}(),Ut=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find((({brand:t})=>"Chromium"===t));if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),jt=0!==Ut&&{level:Ut,hasBasic:!0,has256:Ut>=2,has16m:Ut>=3},Ct={stdout:jt,stderr:jt};function Ft(t,e,r){let n=t.indexOf(e);if(-1===n)return t;const i=e.length;let o=0,a="";do{a+=t.slice(o,n)+e+r,o=n+i,n=t.indexOf(e,o)}while(-1!==n);return a+=t.slice(o),a}const{stdout:Mt,stderr:Dt}=Ct,Ht=Symbol("GENERATOR"),Kt=Symbol("STYLER"),Wt=Symbol("IS_EMPTY"),Gt=["ansi","ansi","ansi256","ansi16m"],Vt=Object.create(null);class zt{constructor(t){return qt(t)}}const qt=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=Mt?Mt.level:0;t.level=void 0===e.level?r:e.level})(e,t),Object.setPrototypeOf(e,Xt.prototype),e};function Xt(t){return qt(t)}Object.setPrototypeOf(Xt.prototype,Function.prototype);for(const[t,e]of Object.entries(Nt))Vt[t]={get(){const r=Qt(this,Jt(e.open,e.close,this[Kt]),this[Wt]);return Object.defineProperty(this,t,{value:r}),r}};Vt.visible={get(){const t=Qt(this,this[Kt],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const $t=(t,e,r,...n)=>"rgb"===t?"ansi16m"===e?Nt[r].ansi16m(...n):"ansi256"===e?Nt[r].ansi256(Nt.rgbToAnsi256(...n)):Nt[r].ansi(Nt.rgbToAnsi(...n)):"hex"===t?$t("rgb",e,r,...Nt.hexToRgb(...n)):Nt[r][t](...n),Yt=["rgb","hex","ansi256"];for(const t of Yt)Vt[t]={get(){const{level:e}=this;return function(...r){const n=Jt($t(t,Gt[e],"color",...r),Nt.color.close,this[Kt]);return Qt(this,n,this[Wt])}}},Vt["bg"+t[0].toUpperCase()+t.slice(1)]={get(){const{level:e}=this;return function(...r){const n=Jt($t(t,Gt[e],"bgColor",...r),Nt.bgColor.close,this[Kt]);return Qt(this,n,this[Wt])}}};const Zt=Object.defineProperties((()=>{}),{...Vt,level:{enumerable:!0,get(){return this[Ht].level},set(t){this[Ht].level=t}}}),Jt=(t,e,r)=>{let n,i;return void 0===r?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},Qt=(t,e,r)=>{const n=(...t)=>te(n,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(n,Zt),n[Ht]=t,n[Kt]=e,n[Wt]=r,n},te=(t,e)=>{if(t.level<=0||!e)return t[Wt]?"":e;let r=t[Kt];if(void 0===r)return e;const{openAll:n,closeAll:i}=r;if(e.includes(""))for(;void 0!==r;)e=Ft(e,r.close,r.open),r=r.parent;const o=e.indexOf("\n");return-1!==o&&(e=function(t,e,r,n){let i=0,o="";do{const a="\r"===t[n-1];o+=t.slice(i,a?n-1:n)+e+(a?"\r\n":"\n")+r,i=n+1,n=t.indexOf("\n",i)}while(-1!==n);return o+=t.slice(i),o}(e,i,n,o)),n+e+i};function ee(t){return ee="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},ee(t)}function re(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 ne(t,e,r){return(e=ie(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ie(t){var e=function(t){if("object"!=ee(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ee(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ee(e)?e:e+""}function oe(t,e){return t.get(function(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")}(t,e))}Object.defineProperties(Xt.prototype,Vt),Xt(),Xt({level:Dt?Dt.level:0});var ae=new WeakMap,se=new WeakMap,ue=new WeakMap,ce=new WeakMap,fe=new WeakMap,le=new WeakMap,he=new WeakMap,pe=new WeakMap,de=new WeakMap,ye=new WeakMap,be=new WeakMap,ge=new WeakMap,we=new WeakMap,ve=new WeakMap,me=new WeakMap,_e=new WeakMap,Ee=new WeakMap,Se=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new zt;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ne(this,"moduleName",""),ne(this,"logColor","#00bfff"),ne(this,"enableLogs",!0),ne(this,"hideLogs",!1),re(this,ae,"#ff00ff"),re(this,se,Pt(oe(ae,this),75)),re(this,ue,"#9400d3"),re(this,ce,Pt(oe(ue,this),15)),re(this,fe,Pt(oe(ce,this),15)),re(this,le,"#7cfc00"),re(this,he,Pt(oe(le,this),15)),re(this,pe,"#ffdead"),re(this,de,Pt(oe(pe,this),15)),re(this,ye,"#ff8c00"),re(this,be,Pt(oe(ye,this),15)),re(this,ge,"#ff4500"),re(this,we,Pt(oe(ge,this),15)),re(this,ve,"#ffffff"),re(this,me,Pt(oe(ve,this),15)),re(this,_e,"#8b0000"),re(this,Ee,Pt(oe(_e,this),15)),ne(this,"prefix",""),this.chalk=e,this.moduleName=this.constructor.name},e=[{key:"setLogPrefix",value:function(t){this.prefix=t}},{key:"getStartPrefix",value:function(){return this.prefix}},{key:"disable",value:function(){this.enableLogs=!1}},{key:"enable",value:function(){this.enableLogs=!0}},{key:"fancyLog",value:function(t,e,r,n,i){this.enableLogs&&console.log(this.chalk.hex(oe(ae,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(oe(ve,this))(t)+" "+this.chalk.hex(oe(be,this))(e)+" "+this.chalk.hex(oe(ve,this))(r)+" "+this.chalk.hex(oe(fe,this))(n)+" "+this.chalk.hex(oe(ve,this))(i))}},{key:"log",value:function(){if(this.enableLogs&&!this.hideLogs){var t=Pt(this.logColor,15);console.log(this.chalk.hex(this.logColor)("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(t).apply(void 0,arguments))}}},{key:"lightOrangeLog",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(oe(be,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(oe(ve,this)).apply(void 0,arguments)))}},{key:"error",value:function(){this.enableLogs&&console.log(this.chalk.hex(oe(ge,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," ERROR]: "))+this.chalk.hex(oe(we,this)).apply(void 0,arguments))}},{key:"warn",value:function(){this.enableLogs&&console.log(this.chalk.hex(oe(ye,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," WARN]: "))+this.chalk.hex(oe(be,this)).apply(void 0,arguments))}},{key:"debug",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(oe(pe,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(oe(de,this)).apply(void 0,arguments)))}},{key:"success",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(oe(le,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SUCCESS]: "))+this.chalk.hex(oe(he,this)).apply(void 0,arguments)))}},{key:"fail",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(oe(ge,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," FAIL]: "))+this.chalk.hex(oe(we,this)).apply(void 0,arguments)))}},{key:"debugBright",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(oe(ue,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(oe(ce,this)).apply(void 0,arguments)))}},{key:"important",value:function(){this.enableLogs&&console.log(this.chalk.hex(oe(ae,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," IMPORTANT]: "))+this.chalk.hex(oe(se,this)).apply(void 0,arguments))}},{key:"panic",value:function(){this.enableLogs&&console.log(this.chalk.hex(oe(_e,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," HELP PANIC]: "))+this.chalk.hex(oe(Ee,this)).apply(void 0,arguments))}},{key:"info",value:function(){this.enableLogs&&console.log(this.chalk.hex(oe(ae,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(oe(ve,this)).apply(void 0,arguments))}},{key:"securityNotice",value:function(){this.enableLogs&&console.log(this.chalk.hex("#22d8e6")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SECURITY NOTICE]: "))+this.chalk.hex("#22e3e6").apply(void 0,arguments))}},{key:"traceLog",value:function(){this.enableLogs&&console.log(this.chalk.hex("#ffffff")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," TRACE LOG]: "))+this.chalk.hex(oe(me,this)).apply(void 0,arguments))}}],e&&function(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,ie(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function ke(t){return ke="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},ke(t)}function Te(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Te=function(){return!!t})()}function Oe(t){return Oe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Oe(t)}function Ae(t,e){return Ae=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ae(t,e)}var xe,Pe=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){return e=Oe(e),function(t,e){if(e&&("object"==ke(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,Te()?Reflect.construct(e,[],Oe(t).constructor):e.apply(t,void 0))}(this,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&&Ae(t,e)}(t,Se),e=t,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}();!function(t){t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t[t.ALL=6]="ALL"}(xe||(xe={}));var Ie=Ot.Vy,Le=i(2218),Re=i(8287).Buffer;function Be(t){return Be="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},Be(t)}function Ne(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,Ue(n.key),n)}}function Ue(t){var e=function(t){if("object"!=Be(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Be(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Be(e)?e:e+""}(0,d.f0)(E);var je,Ce=function(){return function(t,e,r){return r&&Ne(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"tweakSigner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.privateKey;if(!r)throw new Error("Private key is required for tweaking signer!");3===t.publicKey[0]&&(r=_.privateNegate(r));var n=_.privateAdd(r,(0,Le.tapTweakHash)((0,k.toXOnly)(t.publicKey),e.tweakHash));if(!n)throw new Error("Invalid tweaked private key!");return R.fromPrivateKey(Re.from(n),e.network)}}])}(),Fe=i(8287).Buffer;function Me(t){return Me="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},Me(t)}function De(){De=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Me(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Me(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function He(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ke(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){He(o,n,i,a,s,"next",t)}function s(t){He(o,n,i,a,s,"throw",t)}a(void 0)}))}}function We(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 Ge(t,e);var r={}.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)?Ge(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Ge(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ve(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,Ye(n.key),n)}}function ze(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ze=function(){return!!t})()}function qe(t){return qe=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},qe(t)}function Xe(t,e){return Xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Xe(t,e)}function $e(t,e,r){return(e=Ye(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ye(t){var e=function(t){if("object"!=Me(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Me(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Me(e)?e:e+""}!function(t){t[t.REPLACE_BY_FEE=4294967293]="REPLACE_BY_FEE",t[t.FINAL=4294967295]="FINAL"}(je||(je={}));var Ze=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),$e(r=function(t,e,r){return e=qe(e),function(t,e){if(e&&("object"==Me(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,ze()?Reflect.construct(e,r||[],qe(t).constructor):e.apply(t,r))}(this,t),"logColor","#00ffe1"),$e(r,"finalized",!1),$e(r,"signed",!1),$e(r,"scriptData",null),$e(r,"tapData",null),$e(r,"inputs",[]),$e(r,"sequence",je.REPLACE_BY_FEE),$e(r,"tapLeafScript",null),$e(r,"isBrowser",!1),$e(r,"regenerated",!1),$e(r,"ignoreSignatureErrors",!1),r.signer=e.signer,r.network=e.network,r.nonWitnessUtxo=e.nonWitnessUtxo,r.isBrowser="undefined"!=typeof window,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&&Xe(t,e)}(t,Ie),function(t,e,r){return e&&Ve(t.prototype,e),r&&Ve(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"ignoreSignatureError",value:function(){this.ignoreSignatureErrors=!0}},{key:"getScriptAddress",value:function(){if(!this.scriptData||!this.scriptData.address)throw new Error("Tap data is required");return this.scriptData.address}},{key:"getTransaction",value:function(){return this.transaction.extractTransaction(!1)}},{key:"getTapAddress",value:function(){if(!this.tapData||!this.tapData.address)throw new Error("Tap data is required");return this.tapData.address}},{key:"disableRBF",value:function(){if(this.signed)throw new Error("Transaction is already signed");this.sequence=je.FINAL;var t,e=We(this.inputs);try{for(e.s();!(t=e.n()).done;)t.value.sequence=je.FINAL}catch(t){e.e(t)}finally{e.f()}}},{key:"getTweakerHash",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.hash}},{key:"preEstimateTransactionFees",value:function(t,e,r,n,i){var o=10n+41n*e+68n*r;return(3n*o+(o+(144n*n+34n*i+(1n+35n*i+1n+n))))/4n*t}},{key:"generateTapData",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"getSignerKey",value:function(){return this.signer}},{key:"signInput",value:(r=Ke(De().mark((function e(r,n,i,o){var a,s,u;return De().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this.sighashTypes&&this.sighashTypes.length?[t.calculateSignHash(this.sighashTypes)]:void 0,o=o||this.getSignerKey(),s=!1,!n.tapInternalKey){e.next=21;break}if(this.tweakedSigner||this.tweakSigner(),!(u=o!==this.signer?this.getTweakedSigner(!0,o):this.tweakedSigner)){e.next=21;break}if(s=!0,e.prev=8,!("signTaprootInput"in o)){e.next=15;break}return e.next=12,o.signTaprootInput(r,i,a);case 12:return e.abrupt("return",e.sent);case 15:r.signTaprootInput(i,u,void 0,a);case 16:return e.abrupt("return");case 19:e.prev=19,e.t0=e.catch(8);case 21:if(e.prev=21,!("signInput"in o)){e.next=28;break}return e.next=25,o.signInput(r,i,a);case 25:return e.abrupt("return",e.sent);case 28:r.signInput(i,o,a);case 29:e.next=45;break;case 31:if(e.prev=31,e.t1=e.catch(21),s){e.next=45;break}if(!("signTaprootInput"in o)){e.next=40;break}return e.next=37,o.signTaprootInput(r,i,a);case 37:return e.abrupt("return",e.sent);case 40:if(!this.tweakedSigner){e.next=44;break}r.signTaprootInput(i,this.tweakedSigner,void 0,a),e.next=45;break;case 44:throw e.t1;case 45:case"end":return e.stop()}}),e,this,[[8,19],[21,31]])}))),function(t,e,n,i){return r.apply(this,arguments)})},{key:"splitArray",value:function(t,e){if(e<=0)throw new Error("Chunk size must be greater than 0.");for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}},{key:"signInputs",value:(e=Ke(De().mark((function t(e){var r,n,i,o,a,s,u,c,f,l;return De().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.data.inputs,n=20,i=this.splitArray(r,n),o=0;case 4:if(!(o<i.length)){t.next=14;break}for(a=i[o],s=[],u=o*n,c=0;c<a.length;c++){f=u+c,l=a[c];try{s.push(this.signInput(e,l,f))}catch(t){this.log("Failed to sign input ".concat(f,": ").concat(t.stack))}}return t.next=11,Promise.all(s);case 11:o++,t.next=4;break;case 14:try{e.finalizeAllInputs(),this.finalized=!0}catch(t){this.finalized=!1}case 15:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"internalPubKeyToXOnly",value:function(){return(0,k.toXOnly)(this.signer.publicKey)}},{key:"internalInit",value:function(){this.scriptData=d.KT.p2tr(this.generateScriptAddress()),this.tapData=d.KT.p2tr(this.generateTapData())}},{key:"tweakSigner",value:function(){this.tweakedSigner||(this.tweakedSigner=this.getTweakedSigner(!0))}},{key:"getTweakedSigner",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.signer,r={network:this.network};if(t&&(r.tweakHash=this.getTweakerHash()),"privateKey"in e)return Ce.tweakSigner(e,r)}},{key:"generatePsbtInputExtended",value:function(e,r){var n={hash:e.transactionId,index:e.outputIndex,witnessUtxo:{value:Number(e.value),script:Fe.from(e.scriptPubKey.hex,"hex")},sequence:this.sequence};if(this.sighashTypes){var i=t.calculateSignHash(this.sighashTypes);i&&(n.sighashType=i)}return this.tapLeafScript&&(n.tapLeafScript=[this.tapLeafScript]),0===r&&this.nonWitnessUtxo&&(n.nonWitnessUtxo=this.nonWitnessUtxo,this.log("Using non-witness utxo for input ".concat(r))),e.scriptPubKey.address&&kt.isValidP2TRAddress(e.scriptPubKey.address,this.network)&&(this.tweakSigner(),n.tapInternalKey=this.internalPubKeyToXOnly()),n}}],[{key:"readScriptWitnessToWitnessStack",value:function(t){var e=0;function r(){var r=mt.varuint.decode(t,e);return e+=mt.varuint.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push(function(r){var n=t.subarray(e,e+r);return e+=r,n}(r()));return i}()}},{key:"preEstimateTaprootTransactionFees",value:function(t,e,r,n,i,o){var a=10n+41n*e+68n*r;return(3n*a+(a+(1n*e+n*i+(arguments.length>6&&void 0!==arguments[6]?arguments[6]:32n)*e+(arguments.length>7&&void 0!==arguments[7]?arguments[7]:139n)*e+o)))/4n*t}},{key:"signInput",value:function(t,e,r,n,i){i&&i[0]&&(e.sighashType=i[0]),t.signInput(r,n,i.length?i:void 0)}},{key:"calculateSignHash",value:function(t){if(!t)throw new Error("Sighash types are required");var e,r=0,n=We(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}return r||0}}]);var e,r}(),Je=i(8287).Buffer;function Qe(t){return Qe="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},Qe(t)}function tr(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=er(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function er(t,e){if(t){if("string"==typeof t)return rr(t,e);var r={}.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)?rr(t,e):void 0}}function rr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function nr(){nr=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Qe(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Qe(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function ir(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function or(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ir(o,n,i,a,s,"next",t)}function s(t){ir(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ar(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,hr(n.key),n)}}function sr(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(sr=function(){return!!t})()}function ur(){return ur="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=cr(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},ur.apply(null,arguments)}function cr(t){return cr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},cr(t)}function fr(t,e){return fr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},fr(t,e)}function lr(t,e,r){return(e=hr(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hr(t){var e=function(t){if("object"!=Qe(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Qe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Qe(e)?e:e+""}(0,d.f0)(E);var pr=function(){function t(e){var r,n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),lr(n=function(t,e,r){return e=cr(e),function(t,e){if(e&&("object"==Qe(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,sr()?Reflect.construct(e,r||[],cr(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#785def"),lr(n,"overflowFees",0n),lr(n,"transactionFee",0n),lr(n,"estimatedFees",0n),lr(n,"updateInputs",[]),lr(n,"outputs",[]),lr(n,"feeOutput",null),lr(n,"_maximumFeeRate",1e8),e.estimatedFees&&(n.estimatedFees=e.estimatedFees),n.signer=e.signer,n.network=e.network,n.feeRate=e.feeRate,n.priorityFee=null!==(r=e.priorityFee)&&void 0!==r?r:0n,n.utxos=e.utxos,n.to=e.to||void 0,n.optionalOutputs=e.optionalOutputs,n.from=t.getFrom(e.from,n.signer,n.network),n.totalInputAmount=n.calculateTotalUTXOAmount(),n.calculateTotalVOutAmount()<n.totalInputAmount)throw new Error("Vout value is less than the value to send");return n.transaction=new d.iL({network:n.network}),n}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&&fr(t,e)}(t,Ze),function(t,e,r){return e&&ar(t.prototype,e),r&&ar(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getFundingTransactionParameters",value:(c=or(nr().mark((function t(){var e;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.estimatedFees){t.next=4;break}return t.next=3,this.estimateTransactionFees();case 3:this.estimatedFees=t.sent;case 4:return t.abrupt("return",{utxos:this.utxos,to:this.getScriptAddress(),signer:this.signer,network:this.network,feeRate:this.feeRate,priorityFee:null!==(e=this.priorityFee)&&void 0!==e?e:0n,from:this.from,amount:this.estimatedFees,optionalOutputs:this.optionalOutputs});case 5:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"setDestinationAddress",value:function(t){this.to=t}},{key:"setMaximumFeeRate",value:function(t){this._maximumFeeRate=t}},{key:"signTransaction",value:(u=or(nr().mark((function t(){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.to||R.verifyContractAddress(this.to,this.network)){t.next=4;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 4:if(!this.signed){t.next=6;break}throw new Error("Transaction is already signed");case 6:return this.signed=!0,t.next=9,this.buildTransaction();case 9:return t.next=11,this.internalBuildTransaction(this.transaction);case 11:if(!t.sent){t.next=16;break}if(!this.regenerated){t.next=15;break}throw new Error("Transaction was regenerated");case 15:return t.abrupt("return",this.transaction.extractTransaction(!0,!0));case 16:throw new Error("Could not sign transaction");case 17:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"generateTransactionMinimalSignatures",value:(s=or(nr().mark((function t(){var e,r,n,i,o=arguments;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=o.length>0&&void 0!==o[0]&&o[0],!this.to||R.verifyContractAddress(this.to,this.network)){t.next=3;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 3:return t.next=5,this.buildTransaction();case 5:if(0===this.transaction.data.inputs.length){for(r=this.getInputs(),n=this.getOutputs(),this.transaction.setMaximumFeeRate(this._maximumFeeRate),this.transaction.addInputs(r,e),i=0;i<this.updateInputs.length;i++)this.transaction.updateInput(i,this.updateInputs[i]);this.transaction.addOutputs(n)}case 6:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"signPSBT",value:(a=or(nr().mark((function t(){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"addInput",value:function(t){this.inputs.push(t)}},{key:"addOutput",value:function(e){if(0!==e.value){if(e.value<t.MINIMUM_DUST)throw new Error("Output value is less than the minimum dust ".concat(e.value," < ").concat(t.MINIMUM_DUST));this.outputs.push(e)}}},{key:"toAddress",value:function(){return this.to}},{key:"address",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.address}},{key:"estimateTransactionFees",value:(o=or(nr().mark((function t(){var e,r,n,i;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.estimatedFees){t.next=4;break}return t.abrupt("return",this.estimatedFees);case 4:return e=new d.iL({network:this.network}),t.next=7,this.internalBuildTransaction(e);case 7:if(!t.sent){t.next=16;break}return r=e.extractTransaction(!0,!0),n=r.virtualSize(),i=this.feeRate*n,this.estimatedFees=BigInt(Math.ceil(i)+1),t.abrupt("return",this.estimatedFees);case 16:throw new Error("Could not build transaction to estimate fee. Something went wrong while building the transaction.");case 17:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"rebuildFromBase64",value:(i=or(nr().mark((function t(e){return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.transaction=d.iL.fromBase64(e,{network:this.network}),this.signed=!1,this.sighashTypes=[d.ZX.SIGHASH_ANYONECANPAY,d.ZX.SIGHASH_ALL],t.next=5,this.signPSBT();case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"setPSBT",value:function(t){this.transaction=t}},{key:"getInputs",value:function(){return this.inputs}},{key:"getOutputs",value:function(){var t=function(t){return function(t){if(Array.isArray(t))return rr(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||er(t)||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.")}()}(this.outputs);return this.feeOutput&&t.push(this.feeOutput),t}},{key:"addRefundOutput",value:(n=or(nr().mark((function e(r){var n;return nr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this.totalInputAmount-r-this.addOptionalOutputsAndGetAmount())>=t.MINIMUM_DUST)){e.next=10;break}if(!kt.isValidP2TRAddress(this.from,this.network)){e.next=7;break}return e.next=5,this.setFeeOutput({value:Number(n),address:this.from,tapInternalKey:this.internalPubKeyToXOnly()});case 5:e.next=9;break;case 7:return e.next=9,this.setFeeOutput({value:Number(n),address:this.from});case 9:return e.abrupt("return");case 10:this.warn("Amount to send back (".concat(n," sat) is less than the minimum dust (").concat(t.MINIMUM_DUST," sat), it will be consumed in fees instead."));case 11:case"end":return e.stop()}}),e,this)}))),function(t){return n.apply(this,arguments)})},{key:"addValueToToOutput",value:function(e){if(e<t.MINIMUM_DUST)throw new Error("Value to send is less than the minimum dust ".concat(e," < ").concat(t.MINIMUM_DUST));var r,n=tr(this.outputs);try{for(n.s();!(r=n.n()).done;){var i=r.value;if("address"in i&&i.address===this.to)return void(i.value+=Number(e))}}catch(t){n.e(t)}finally{n.f()}throw new Error("Output not found")}},{key:"getTransactionOPNetFee",value:function(){return this.priorityFee>t.MINIMUM_DUST?this.priorityFee:t.MINIMUM_DUST}},{key:"calculateTotalUTXOAmount",value:function(){var t,e=0n,r=tr(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"calculateTotalVOutAmount",value:function(){var t,e=0n,r=tr(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"addOptionalOutputsAndGetAmount",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)this.addOutput(this.optionalOutputs[e]),t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addInputsFromUTXO",value:function(){if(this.utxos.length){if(this.totalInputAmount<t.MINIMUM_DUST)throw new Error("Total input amount is ".concat(this.totalInputAmount," sat which is less than the minimum dust ").concat(t.MINIMUM_DUST," sat."));for(var e=0;e<this.utxos.length;e++){var r=this.utxos[e],n=this.generatePsbtInputExtended(r,e);this.addInput(n)}}}},{key:"internalInit",value:function(){this.verifyUTXOValidity(),function(t,e,r){var n=ur(cr(t.prototype),"internalInit",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([])}},{key:"updateInput",value:function(t){this.updateInputs.push(t)}},{key:"getWitness",value:function(){if(!this.tapData||!this.tapData.witness)throw new Error("Witness is required");if(0===this.tapData.witness.length)throw new Error("Witness is empty");return this.tapData.witness[this.tapData.witness.length-1]}},{key:"getTapOutput",value:function(){if(!this.tapData||!this.tapData.output)throw new Error("Tap data is required");return this.tapData.output}},{key:"verifyUTXOValidity",value:function(){var t,e=tr(this.utxos);try{for(e.s();!(t=e.n()).done;)if(!t.value.scriptPubKey)throw new Error("Address is required")}catch(t){e.e(t)}finally{e.f()}}},{key:"setFeeOutput",value:(r=or(nr().mark((function e(r){var n,i,o,a;return nr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.value,e.next=3,this.estimateTransactionFees();case 3:if(i=e.sent,r.value=n-Number(i),!(r.value<t.MINIMUM_DUST)){e.next=11;break}if(this.feeOutput=null,!(r.value<0)){e.next=9;break}throw new Error("setFeeOutput: Insufficient funds to pay the fees. Fee: ".concat(i," < Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 9:e.next=20;break;case 11:return this.feeOutput=r,e.next=14,this.estimateTransactionFees();case 14:if(!((o=e.sent)>BigInt(n))){e.next=17;break}throw new Error("estimateTransactionFees: Insufficient funds to pay the fees. Fee: ".concat(o," > Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 17:(a=n-Number(o))<t.MINIMUM_DUST?this.feeOutput=null:this.feeOutput.value=a,this.overflowFees=BigInt(a);case 20:case"end":return e.stop()}}),e,this)}))),function(t){return r.apply(this,arguments)})},{key:"internalBuildTransaction",value:(e=or(nr().mark((function t(e){var r,n,i,o,a,s=arguments;return nr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.next=5,this.signInputs(e);case 5:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 9:t.prev=9,t.t0=t.catch(2),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 13:return t.abrupt("return",!1);case 14:case"end":return t.stop()}}),t,this,[[2,9]])}))),function(t){return e.apply(this,arguments)})}],[{key:"getFrom",value:function(t,e,r){return t||R.getTaprootAddress(e,r)}},{key:"witnessStackToScriptWitness",value:function(t){var e,r=Je.allocUnsafe(0);function n(t){var e=r.length,n=mt.varuint.encodingLength(t);r=Je.concat([r,Je.allocUnsafe(n)]),mt.varuint.encode(t,r,e)}return n((e=t).length),e.forEach((function(t){n(t.length),function(t){r=Je.concat([r,Je.from(t)])}(t)})),r}}]);var e,r,n,i,o,a,s,u,c}();lr(pr,"LOCK_LEAF_SCRIPT",d.K$.compile([d.Ez.OP_0])),lr(pr,"MINIMUM_DUST",330n);var dr=i(8287).Buffer;function yr(t){return yr="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},yr(t)}function br(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,gr(n.key),n)}}function gr(t){var e=function(t){if("object"!=yr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=yr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==yr(e)?e:e+""}var wr=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&br(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getContractAddress",value:function(e){var r=e.network||d.o8.bitcoin,n=[{output:new tt(e.deployerPubKeyXOnly,(0,k.toXOnly)(e.contractSaltPubKey),r).compile(e.bytecode,e.originalSalt,e.calldata),version:t.TAP_SCRIPT_VERSION},{output:pr.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}];return t.generateAddressFromScript(e,n)}},{key:"getContractSeed",value:function(t,e,r){var n=d.Et.hash256(e),i=dr.concat([t,r,n]);return d.Et.hash256(i)}},{key:"generateContractVirtualAddress",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:d.o8.bitcoin,o=t.getContractSeed(e,r,n);return vt.generatePKSH(o,i)}},{key:"generateAddressFromScript",value:function(t,e){var r=t.network||d.o8.bitcoin,n={internalPubkey:t.deployerPubKeyXOnly,network:r,scriptTree:e};return d.KT.p2tr(n).address}}])}();function vr(t){return vr="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},vr(t)}function mr(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,_r(n.key),n)}}function _r(t){var e=function(t){if("object"!=vr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vr(e)?e:e+""}!function(t,e){(e=gr(e))in t?Object.defineProperty(t,e,{value:192,enumerable:!0,configurable:!0,writable:!0}):t[e]=192}(wr,"TAP_SCRIPT_VERSION");var Er,Sr=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=r,this._keypair=R.fromWIF(e.privateKey,this.network),this._p2wpkh=R.getP2WPKHAddress(this._keypair,this.network),this._p2tr=R.getTaprootAddress(this._keypair,this.network),this._legacy=R.getLegacyAddress(this._keypair,this.network)}return function(t,e,r){return e&&mr(t.prototype,e),r&&mr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"keypair",get:function(){if(!this._keypair)throw new Error("Keypair not set");return this._keypair}},{key:"p2wpkh",get:function(){return this._p2wpkh}},{key:"p2tr",get:function(){return this._p2tr}},{key:"legacy",get:function(){return this._legacy}},{key:"addresses",get:function(){return[this.p2wpkh,this.p2tr,this.legacy]}},{key:"publicKey",get:function(){if(!this.keypair)throw new Error("Keypair not set");return this.keypair.publicKey}},{key:"xOnly",get:function(){if(!this.keypair)throw new Error("Keypair not set");return(0,k.toXOnly)(this.keypair.publicKey)}}],[{key:"fromWif",value:function(e){return new t({privateKey:e,address:"",publicKey:""},arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin)}}])}();function kr(t){return kr="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},kr(t)}function Tr(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,Or(n.key),n)}}function Or(t){var e=function(t){if("object"!=kr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=kr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==kr(e)?e:e+""}!function(t){t[t.Bitcoin=0]="Bitcoin",t[t.Fractal=1]="Fractal"}(Er||(Er={}));var Ar=function(){return function(t,e,r){return e&&Tr(t.prototype,e),r&&Tr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=e}),[{key:"getAddress",value:function(){return this.address}}],[{key:"getAddress",value:function(){throw arguments.length>0&&void 0!==arguments[0]||d.o8.bitcoin,new Error("Method not implemented.")}}])}();function xr(t){return xr="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},xr(t)}function Pr(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,Lr(n.key),n)}}function Ir(t,e,r){return(e=Lr(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Lr(t){var e=function(t){if("object"!=xr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xr(e)?e:e+""}var Rr,Br="bcrt1q9pf9fnpch9z2qrp5e3dgr2avzu3mypq3km2k40",Nr="bcrt1qg87nx9v9ln3qyadcn0llekzjn0hx8js46ztwky",Ur="bcrt1qamv2ejattjgsc6k3yf3zqrp0wpuyedqgjmwx0v",jr="bcrt1qw8w4ejas2k22y54avv7hgrslg3cd0hme58h28r",Cr="bcrt1q9yd6mk324k0q4krmlxjky0pk65ul6hkf4u35e6",Fr="tb1qgev5kldhp5zvg6j8t9vl6x4phkrwn8nk9felxh",Mr="tb1q6a7yw353hjmresphupytw5vczpqxtg4yrupayk",Dr="tb1qp28xna6pv47x6wflcplhu0a9hkld5shtvjx6xv",Hr="tb1q4tyhf8hpu04qjj3qaag20knun0spctultxzakw",Kr="tb1qnh9mj95nnej25dwhjvvsppwmdm0myhxv7tllgt",Wr="bc1qr4g85824m58wu0zffjtnf56n425fp0e8azhc7q",Gr="bc1qv55cht4zzlt29ea7vdgwsedsn63a2sxtkgpv6h",Vr="bc1qdtzlucslvrvu4useyh9r69supqrw3w4xn9t4yv",zr="bc1qfzq6w5uvgg5489egv0lj4shlqx4dagqt0ewdnu",qr="bc1q9w2zvmkzlezt2fu34u57y9vuw6rll5sp2090kn";!function(t){t.Mainnet="mainnet",t.Testnet="testnet",t.Regtest="regtest"}(Rr||(Rr={}));var Xr=function(){return function(t,e){return e&&Pr(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ir(this,"metadata",Ir(Ir({},Er.Bitcoin,Ir(Ir({},Rr.Testnet,{factory:Fr,pool:Mr,wbtc:Dr,moto:Hr,router:Kr}),Rr.Regtest,{factory:Br,pool:Nr,wbtc:Ur,moto:jr,router:Cr})),Er.Fractal,Ir({},Rr.Mainnet,{factory:Wr,pool:Gr,wbtc:Vr,moto:zr,router:qr})))}),[{key:"getFactoryAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.factory;if(!n)throw new Error("Factory address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getPoolAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.pool;if(!n)throw new Error("Pool address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getWBTCAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.wbtc;if(!n)throw new Error("WBTC address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getMOTOAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.moto;if(!n)throw new Error("MOTO address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getRouterAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.router;if(!n)throw new Error("Router address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getAddresses",value:function(t,e){var r=this.metadata[e][t];if(!r)throw new Error("Metadata not found for network ".concat(t," and chainId ").concat(e));return r}}])}(),$r=new Xr;function Yr(t){return Yr="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},Yr(t)}function Zr(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,rn(n.key),n)}}function Jr(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Jr=function(){return!!t})()}function Qr(t){return Qr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Qr(t)}function tn(t,e){return tn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},tn(t,e)}function en(t,e,r){return(e=rn(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function rn(t){var e=function(t){if("object"!=Yr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Yr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yr(e)?e:e+""}var nn,on=function(){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:Er.Bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),en(e=function(t,e,r){return e=Qr(e),function(t,e){if(e&&("object"==Yr(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,Jr()?Reflect.construct(e,r||[],Qr(t).constructor):e.apply(t,r))}(this,t,[r]),"tokenName","Wrapped Bitcoin"),en(e,"tokenSymbol","wBTC"),en(e,"decimals",8),e.network=r,e.address=t.getAddress(r,n),e}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&&tn(t,e)}(t,Ar),function(t,e,r){return r&&Zr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getAddress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin,e=arguments.length>1?arguments[1]:void 0;switch(t.bech32){case d.o8.bitcoin.bech32:return this.getWBTCAddressForChain(null!=e?e:Er.Bitcoin);case d.o8.regtest.bech32:return Ur;case d.o8.testnet.bech32:return Dr;default:throw new Error("Invalid network: ".concat(t.bech32))}}},{key:"getWBTCAddressForChain",value:function(t){switch(t){case Er.Bitcoin:return"unknown";case Er.Fractal:return Vr;default:throw new Error("Invalid chainId: ".concat(t))}}}])}();!function(t){t[t.Roswell=0]="Roswell",t[t.Rachel=1]="Rachel",t[t.Kecksburg=2]="Kecksburg",t[t.Phoenix=3]="Phoenix",t[t.Aurora=4]="Aurora",t[t.Rendlesham=5]="Rendlesham",t[t.Lazar=6]="Lazar",t[t.ShagHarbor=7]="ShagHarbor",t[t.Exeter=8]="Exeter",t[t.Stephenville=9]="Stephenville",t[t.Valensole=10]="Valensole",t[t.Socorro=11]="Socorro",t[t.Pascagoula=12]="Pascagoula",t[t.Tehran=13]="Tehran",t[t.Westall=14]="Westall",t[t.Hopkinsville=15]="Hopkinsville",t[t.Belgium=16]="Belgium",t[t.Breeze=17]="Breeze",t[t.Flatwoods=18]="Flatwoods",t[t.Maury=20]="Maury",t[t.Varginha=21]="Varginha",t[t.Trindade=22]="Trindade",t[t.Levelland=23]="Levelland",t[t.Wanaque=24]="Wanaque",t[t.Coyame=25]="Coyame",t[t.Delphos=26]="Delphos"}(nn||(nn={}));var an={CONSENSUS:nn.Roswell,CONSENSUS_NAME:"Roswell",ENABLED_AT_BLOCK:0n,VAULT_MINIMUM_AMOUNT:200000n,VAULT_NETWORK_CONSOLIDATION_ACCEPTANCE:400000n,UNWRAP_CONSOLIDATION_PREPAID_FEES:250n,UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT:56500n};function sn(t){return sn="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},sn(t)}var un,cn=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=sn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==sn(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},nn.Roswell,an),fn=nn.Roswell,ln=cn[fn];function hn(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function pn(t,...e){if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(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 dn(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");hn(t.outputLen),hn(t.blockLen)}function yn(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(t){t[t.GENERIC=0]="GENERIC",t[t.FUNDING=1]="FUNDING",t[t.DEPLOYMENT=2]="DEPLOYMENT",t[t.INTERACTION=3]="INTERACTION",t[t.WBTC_WRAP=4]="WBTC_WRAP",t[t.WBTC_UNWRAP=5]="WBTC_UNWRAP",t[t.MULTI_SIG=6]="MULTI_SIG",t[t.CUSTOM_CODE=7]="CUSTOM_CODE"}(un||(un={}));const bn=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),gn=(t,e)=>t<<32-e|t>>>e;function wn(t){return"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)),pn(t),t}new Uint8Array(new Uint32Array([287454020]).buffer)[0];class vn{clone(){return this._cloneInto()}}const mn={}.toString;function _n(t){const e=e=>t().update(wn(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class En extends vn{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,dn(t);const r=wn(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 yn(this),this.iHash.update(t),this}digestInto(t){yn(this),pn(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:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const Sn=(t,e,r)=>new En(t,e).update(r).digest();Sn.create=(t,e)=>new En(t,e);const kn=(t,e,r)=>t&e^~t&r,Tn=(t,e,r)=>t&e^t&r^e&r;class On extends vn{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=bn(this.buffer)}update(t){yn(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=wn(t)).length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=bn(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){yn(this),function(t,e){pn(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),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=bn(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.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:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const An=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]),xn=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Pn=new Uint32Array(64);class In extends On{constructor(){super(64,32,8,!1),this.A=0|xn[0],this.B=0|xn[1],this.C=0|xn[2],this.D=0|xn[3],this.E=0|xn[4],this.F=0|xn[5],this.G=0|xn[6],this.H=0|xn[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){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|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)Pn[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Pn[t-15],r=Pn[t-2],n=gn(e,7)^gn(e,18)^e>>>3,i=gn(r,17)^gn(r,19)^r>>>10;Pn[t]=i+Pn[t-7]+n+Pn[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(gn(a,6)^gn(a,11)^gn(a,25))+kn(a,s,u)+An[t]+Pn[t]|0,f=(gn(r,2)^gn(r,13)^gn(r,22))+Tn(r,n,i)|0;c=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,s,u,c)}roundClean(){Pn.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ln=_n((()=>new In)),Rn=BigInt(2**32-1),Bn=BigInt(32);function Nn(t,e=!1){return e?{h:Number(t&Rn),l:Number(t>>Bn&Rn)}:{h:0|Number(t>>Bn&Rn),l:0|Number(t&Rn)}}const Un={fromBig:Nn,split:function(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:a}=Nn(t[i],e);[r[i],n[i]]=[o,a]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<Bn|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:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,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)},jn=Un,[Cn,Fn]=(()=>jn.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)))))(),Mn=new Uint32Array(80),Dn=new Uint32Array(80);class Hn extends On{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:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,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|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,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)Mn[r]=t.getUint32(e),Dn[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Mn[t-15],r=0|Dn[t-15],n=jn.rotrSH(e,r,1)^jn.rotrSH(e,r,8)^jn.shrSH(e,r,7),i=jn.rotrSL(e,r,1)^jn.rotrSL(e,r,8)^jn.shrSL(e,r,7),o=0|Mn[t-2],a=0|Dn[t-2],s=jn.rotrSH(o,a,19)^jn.rotrBH(o,a,61)^jn.shrSH(o,a,6),u=jn.rotrSL(o,a,19)^jn.rotrBL(o,a,61)^jn.shrSL(o,a,6),c=jn.add4L(i,u,Dn[t-7],Dn[t-16]),f=jn.add4H(c,n,s,Mn[t-7],Mn[t-16]);Mn[t]=0|f,Dn[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:f,El:l,Fh:h,Fl:p,Gh:d,Gl:y,Hh:b,Hl:g}=this;for(let t=0;t<80;t++){const e=jn.rotrSH(f,l,14)^jn.rotrSH(f,l,18)^jn.rotrBH(f,l,41),w=jn.rotrSL(f,l,14)^jn.rotrSL(f,l,18)^jn.rotrBL(f,l,41),v=f&h^~f&d,m=l&p^~l&y,_=jn.add5L(g,w,m,Fn[t],Dn[t]),E=jn.add5H(_,b,e,v,Cn[t],Mn[t]),S=0|_,k=jn.rotrSH(r,n,28)^jn.rotrBH(r,n,34)^jn.rotrBH(r,n,39),T=jn.rotrSL(r,n,28)^jn.rotrBL(r,n,34)^jn.rotrBL(r,n,39),O=r&i^r&a^i&a,A=n&o^n&s^o&s;b=0|d,g=0|y,d=0|h,y=0|p,h=0|f,p=0|l,({h:f,l}=jn.add(0|u,0|c,0|E,0|S)),u=0|a,c=0|s,a=0|i,s=0|o,i=0|r,o=0|n;const x=jn.add3L(S,T,A);r=jn.add3H(x,E,k,O),n=0|x}({h:r,l:n}=jn.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=jn.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:a,l:s}=jn.add(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:c}=jn.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:f,l}=jn.add(0|this.Eh,0|this.El,0|f,0|l)),({h,l:p}=jn.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=jn.add(0|this.Gh,0|this.Gl,0|d,0|y)),({h:b,l:g}=jn.add(0|this.Hh,0|this.Hl,0|b,0|g)),this.set(r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g)}roundClean(){Mn.fill(0),Dn.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 Kn=_n((()=>new Hn));var Wn=i(4148);function Gn(t,e,r,n){Wn(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}var Vn=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")}(),zn=Vn.crypto||Vn.msCrypto;function qn(t){switch(t){case"sha256":return Ln.create();case"sha512":return Kn.create()}Gn(!1,"invalid hashing algorithm name","algorithm",t)}const Xn={createHash:qn,createHmac:function(t,e){var r={sha256:Ln,sha512:Kn}[t];return Gn(null!=r,"invalid hmac algorithm","algorithm",t),Sn.create(r,e)},pbkdf2Sync:function(t,e,r,n,i){var o={sha256:Ln,sha512:Kn}[i];return Gn(null!=o,"invalid pbkdf2 algorithm","algorithm",i),function(t,e,r,n){const{c:i,dkLen:o,DK:a,PRF:s,PRFSalt:u}=function(t,e,r,n){dn(t);const i=function(t,e){if(void 0!==e&&"[object Object]"!==mn.call(e))throw new Error("Options should be object or undefined");return Object.assign({dkLen:32,asyncTick:10},e)}(0,n),{c:o,dkLen:a,asyncTick:s}=i;if(hn(o),hn(a),hn(s),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const u=wn(e),c=wn(r),f=new Uint8Array(a),l=Sn.create(t,u),h=l._cloneInto().update(c);return{c:o,dkLen:a,asyncTick:s,DK:f,PRF:l,PRFSalt:h}}(t,e,r,n);let c;const f=new Uint8Array(4),l=bn(f),h=new Uint8Array(s.outputLen);for(let t=1,e=0;e<o;t++,e+=s.outputLen){const r=a.subarray(e,e+s.outputLen);l.setInt32(0,t,!1),(c=u._cloneInto(c)).update(f).digestInto(h),r.set(h.subarray(0,r.length));for(let t=1;t<i;t++){s._cloneInto(c).update(h).digestInto(h);for(let t=0;t<r.length;t++)r[t]^=h[t]}}return function(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),i.fill(0),r}(s,u,a,c,h)}(o,t,e,{c:r,dkLen:n})},randomBytes:function(t){Wn(null!=zn,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),Gn(Number.isInteger(t)&&t>0&&t<=1024,"invalid length","length",t);var e=new Uint8Array(t);return zn.getRandomValues(e),e}};var $n=i(8287).Buffer;function Yn(t){return Yn="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},Yn(t)}function Zn(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Jn(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,Qn(n.key),n)}}function Qn(t){var e=function(t){if("object"!=Yn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Yn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yn(e)?e:e+""}var ti=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&Jn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"btcToSatoshi",value:function(t){return BigInt(1e8*t)}},{key:"rndBytes",value:function(){var e=t.getUnsafeRandomValues(64);return $n.from(e)}},{key:"getUnsafeRandomValues",value:function(t){if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),$n.from(e)}if(Xn&&"function"==typeof Xn.getRandomValues){var r=new Uint8Array(t);return Xn.getRandomValues(r),$n.from(r)}for(var n=[],i=0;i<t;i++)n.push(Math.floor(256*Math.random()));return $n.from(n)}},{key:"opnetHash",value:function(t){var e=qn("sha512");e.update(t);var r=e.digest();return"0x".concat($n.from(r).toString("hex"))}},{key:"orderVaultsByAddress",value:function(t){return t.sort((function(t,e){return t.vault.localeCompare(e.vault)}))}},{key:"findVaultWithMostPublicKeys",value:function(e){var r,n,i=0,o=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 Zn(t,e);var r={}.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)?Zn(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(e=t.orderVaultsByAddress(e));try{for(o.s();!(n=o.n()).done;){var a=n.value;a.publicKeys.length>i&&(i=a.publicKeys.length,r=a)}}catch(t){o.e(t)}finally{o.f()}if(!r)throw new Error("No vault with public keys found.");return r}}])}();function ei(t){return ei="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},ei(t)}function ri(){ri=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==ei(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(ei(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function ni(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function ii(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ni(o,n,i,a,s,"next",t)}function s(t){ni(o,n,i,a,s,"throw",t)}a(void 0)}))}}function oi(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,hi(n.key),n)}}function ai(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ai=function(){return!!t})()}function si(t,e,r,n){var i=ui(ci(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function ui(){return ui="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=ci(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},ui.apply(null,arguments)}function ci(t){return ci=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ci(t)}function fi(t,e){return fi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},fi(t,e)}function li(t,e,r){return(e=hi(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function hi(t){var e=function(t){if("object"!=ei(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ei(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ei(e)?e:e+""}var pi=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),li(r=function(t,e,r){return e=ci(e),function(t,e){if(e&&("object"==ei(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,ai()?Reflect.construct(e,r||[],ci(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.CUSTOM_CODE),li(r,"tapLeafScript",null),li(r,"targetScriptRedeem",null),li(r,"leftOverFundsScriptRedeem",null),li(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.witnesses.concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:pr.witnessStackToScriptWitness(n)}})),!e.script)throw new Error("Bitcoin script is required");if(!e.witnesses)throw new Error("Witness(es) are required");return r.witnesses=e.witnesses,r.randomBytes=e.randomBytes||ti.rndBytes(),r.scriptSeed=r.getContractSeed(),r.contractSigner=R.fromSeedKeyPair(r.scriptSeed,r.network),r.generator=new st(r.internalPubKeyToXOnly(),r.network),r.compiledTargetScript=r.generator.compile(e.script),r.scriptTree=r.getScriptTree(),r.internalInit(),r._scriptAddress=vt.generatePKSH(r.scriptSeed,r.network),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&&fi(t,e)}(t,pr),function(t,e){return e&&oi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"scriptAddress",get:function(){return this._scriptAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return(0,k.toXOnly)(this.contractSigner.publicKey)}},{key:"buildTransaction",value:(r=ii(ri().mark((function t(){var e,r;return ri().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.next=14,this.addRefundOutput(r);case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=ii(ri().mark((function e(r){var n;return ri().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,si(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getContractSeed",value:function(){return d.Et.hash256(this.randomBytes)}},{key:"getPubKeys",value:function(){var t=[this.signer.publicKey];return this.contractSigner&&t.push(this.contractSigner.publicKey),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return pr.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}();function di(t){return di="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},di(t)}function yi(){yi=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==di(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(di(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function bi(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function gi(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){bi(o,n,i,a,s,"next",t)}function s(t){bi(o,n,i,a,s,"throw",t)}a(void 0)}))}}function wi(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,Ti(n.key),n)}}function vi(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(vi=function(){return!!t})()}function mi(t,e,r,n){var i=_i(Ei(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function _i(){return _i="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Ei(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},_i.apply(null,arguments)}function Ei(t){return Ei=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ei(t)}function Si(t,e){return Si=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Si(t,e)}function ki(t,e,r){return(e=Ti(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ti(t){var e=function(t){if("object"!=di(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=di(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==di(e)?e:e+""}var Oi=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ki(r=function(t,e,r){return e=Ei(e),function(t,e){if(e&&("object"==di(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,vi()?Reflect.construct(e,r||[],Ei(t).constructor):e.apply(t,r))}(this,t,[e]),"targetScriptRedeem",null),ki(r,"leftOverFundsScriptRedeem",null),ki(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!r.contractSecret)throw new Error("Contract secret is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:pr.witnessStackToScriptWitness(n)}})),!e.calldata)throw new Error("Calldata is required");return r.disableAutoRefund=e.disableAutoRefund||!1,r.calldata=p.compress(e.calldata),r.randomBytes=e.randomBytes||ti.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.calldataGenerator=new V(r.internalPubKeyToXOnly(),r.scriptSignerXOnlyPubKey(),r.network),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&&Si(t,e)}(t,pr),function(t,e){return e&&wi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"generateSecret",value:function(){if(!this.to)throw new Error("To address is required");return d.hl.fromBech32(this.to).data}},{key:"scriptSignerXOnlyPubKey",value:function(){return(0,k.toXOnly)(this.scriptSigner.publicKey)}},{key:"generateKeyPairFromSeed",value:function(){return R.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"buildTransaction",value:(n=gi(yi().mark((function t(){var e,r;return yi().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("To address is required");case 2:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=5;break}throw new Error("Left over funds script redeem is required");case 5:if(e.redeemVersion){t.next=7;break}throw new Error("Left over funds script redeem version is required");case 7:if(e.output){t.next=9;break}throw new Error("Left over funds script redeem output is required");case 9:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.regenerated||this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),this.disableAutoRefund){t.next=16;break}return t.next=16,this.addRefundOutput(r);case 16:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"signInputs",value:(r=gi(yi().mark((function e(r){var n,i,o,a,s,u,c,f;return yi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.scriptSigner){e.next=4;break}return e.next=3,mi(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:n=r.data.inputs,i=0;case 6:if(!(i<n.length)){e.next=15;break}for(o=n.slice(i,i+20),a=[],s=0;s<o.length;s++)u=20*i+s,c=o[s],a.push(this.signIndividualInputs(r,c,u));return e.next=12,Promise.all(a).catch((function(t){throw t}));case 12:i+=20,e.next=6;break;case 15:try{r.finalizeInput(0,this.customFinalizer)}catch(t){this.error("Failed to finalize input 0: ".concat(t.stack))}for(f=0;f<n.length;f++)try{r.finalizeInput(f),this.log("Finalized input ".concat(f,"!"))}catch(t){}case 17:case"end":return e.stop()}}),e,this)}))),function(t){return r.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,this.internalPubKeyToXOnly(),t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"getScriptTree",value:function(){if(!this.calldata)throw new Error("Calldata is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"signIndividualInputs",value:(e=gi(yi().mark((function t(e,r,n){var i;return yi().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=!1,t.prev=1,t.next=4,this.signInput(e,r,n,this.scriptSigner);case 4:i=!0,t.next=9;break;case 7:t.prev=7,t.t0=t.catch(1);case 9:return t.prev=9,t.next=12,this.signInput(e,r,n);case 12:i=!0,t.next=17;break;case 15:t.prev=15,t.t1=t.catch(9);case 17:if(!i){t.next=20;break}return this.log("Signed input #".concat(n," out of ").concat(e.data.inputs.length,"! {Signed: ").concat(i,"}")),t.abrupt("return");case 20:if(!this.regenerated&&!this.ignoreSignatureErrors){t.next=22;break}return t.abrupt("return");case 22:throw new Error("Failed to sign input");case 23:case"end":return t.stop()}}),t,this,[[1,7],[9,15]])}))),function(t,r,n){return e.apply(this,arguments)})},{key:"getPubKeys",value:function(){var t=[this.signer.publicKey];return this.scriptSigner&&t.push(this.scriptSigner.publicKey),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}]);var e,r,n}();ki(Oi,"MAXIMUM_CALLDATA_SIZE",1048576);var Ai=i(8287).Buffer;function xi(t){return xi="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},xi(t)}function Pi(){Pi=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==xi(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(xi(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Ii(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Li(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ii(o,n,i,a,s,"next",t)}function s(t){Ii(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Ri(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,Mi(n.key),n)}}function Bi(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Bi=function(){return!!t})()}function Ni(t,e,r,n){var i=Ui(ji(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Ui(){return Ui="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=ji(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Ui.apply(null,arguments)}function ji(t){return ji=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ji(t)}function Ci(t,e){return Ci=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ci(t,e)}function Fi(t,e,r){return(e=Mi(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Mi(t){var e=function(t){if("object"!=xi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xi(e)?e:e+""}var Di=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Fi(r=function(t,e,r){return e=ji(e),function(t,e){if(e&&("object"==xi(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,Bi()?Reflect.construct(e,r||[],ji(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.DEPLOYMENT),Fi(r,"tapLeafScript",null),Fi(r,"targetScriptRedeem",null),Fi(r,"leftOverFundsScriptRedeem",null),Fi(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("Tap script signature is required");var n=[r.randomBytes,r.internalPubKeyToXOnly(),e.tapScriptSig[0].signature,e.tapScriptSig[1].signature].concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:pr.witnessStackToScriptWitness(n)}})),r.bytecode=p.compress(e.bytecode),r.verifyBytecode(),e.calldata&&(r.calldata=e.calldata,r.verifyCalldata()),r.randomBytes=e.randomBytes||ti.rndBytes(),r.contractSeed=r.getContractSeed(),r.contractSigner=R.fromSeedKeyPair(r.contractSeed,r.network),r.deploymentGenerator=new tt(r.internalPubKeyToXOnly(),r.contractSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.deploymentGenerator.compile(r.bytecode,r.randomBytes,r.calldata),r.scriptTree=r.getScriptTree(),r.internalInit(),r._contractAddress=vt.generatePKSH(r.contractSeed,r.network),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&&Ci(t,e)}(t,pr),function(t,e){return e&&Ri(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"contractAddress",get:function(){return this._contractAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return(0,k.toXOnly)(this.contractSigner.publicKey)}},{key:"buildTransaction",value:(r=Li(Pi().mark((function t(){var e,r;return Pi().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.next=14,this.addRefundOutput(r);case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Li(Pi().mark((function e(r){var n;return Pi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,Ni(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"verifyCalldata",value:function(){if(this.calldata&&this.calldata.length>Oi.MAXIMUM_CALLDATA_SIZE)throw new Error("Calldata size overflow.")}},{key:"verifyBytecode",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");if(this.bytecode.length>t.MAXIMUM_CONTRACT_SIZE)throw new Error("Contract size overflow.")}},{key:"getContractSeed",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");var t=this.internalPubKeyToXOnly(),e=d.Et.hash256(this.randomBytes),r=d.Et.hash256(this.bytecode),n=Ai.concat([t,e,r]);return d.Et.hash256(n)}},{key:"getPubKeys",value:function(){var t=[this.signer.publicKey];return this.contractSigner&&t.push(this.contractSigner.publicKey),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return pr.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){if(!this.bytecode)throw new Error("Contract bytecode is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}();function Hi(t){return Hi="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},Hi(t)}function Ki(){Ki=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Hi(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Hi(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Wi(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Gi(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,Xi(n.key),n)}}function Vi(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Vi=function(){return!!t})()}function zi(t){return zi=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},zi(t)}function qi(t,e){return qi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},qi(t,e)}function Xi(t){var e=function(t){if("object"!=Hi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Hi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Hi(e)?e:e+""}Fi(Di,"MAXIMUM_CONTRACT_SIZE",131072);var $i=function(){function t(e){var r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Xi(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=function(t,e,r){return e=zi(e),function(t,e){if(e&&("object"==Hi(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,Vi()?Reflect.construct(e,r||[],zi(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.FUNDING),n.amount=e.amount,n.splitInputsInto=null!==(r=e.splitInputsInto)&&void 0!==r?r:1,n.internalInit(),n}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&&qi(t,e)}(t,pr),function(t,e){return e&&Gi(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Wi(o,n,i,a,s,"next",t)}function s(t){Wi(o,n,i,a,s,"throw",t)}a(void 0)}))}}(Ki().mark((function t(){return Ki().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("Recipient address is required");case 2:return this.addInputsFromUTXO(),this.splitInputsInto>1?this.splitInputs(this.amount):this.addOutput({value:Number(this.amount),address:this.to}),t.next=6,this.addRefundOutput(this.amount);case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"splitInputs",value:function(t){if(!this.to)throw new Error("Recipient address is required");for(var e=t/BigInt(this.splitInputsInto),r=0;r<this.splitInputsInto;r++)this.addOutput({value:Number(e),address:this.to})}},{key:"getSignerKey",value:function(){return this.signer}}]);var e}();function Yi(t){return Yi="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},Yi(t)}function Zi(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Zi=function(){return!!t})()}function Ji(t){return Ji=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ji(t)}function Qi(t,e){return Qi=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Qi(t,e)}function to(t,e,r){return(e=eo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function eo(t){var e=function(t){if("object"!=Yi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Yi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yi(e)?e:e+""}var ro=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),to(r=function(t,e,r){return e=Ji(e),function(t,e){if(e&&("object"==Yi(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,Zi()?Reflect.construct(e,r||[],Ji(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.INTERACTION),to(r,"tapLeafScript",null),r.contractSecret=r.generateSecret(),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&Qi(t,e)}(t,Oi),function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(t)}(),no=i(8287).Buffer;class io{static bufferToUint8Array(t){if(no.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 no.from(t,0,t.byteLength).toString("hex")}static hexToUint8Array(t){t.startsWith("0x")&&(t=t.substring(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.substring(2*n,2*n+2),16);return r}static pointerToUint8Array(t){const e=t.toString(16).padStart(64,"0");return io.hexToUint8Array(e)}static uint8ArrayToPointer(t){const e=io.uint8ArrayToHex(t);return BigInt("0x"+e)}static valueToUint8Array(t){const e=t.toString(16).padStart(64,"0");return io.hexToUint8Array(e)}static uint8ArrayToValue(t){const e=io.uint8ArrayToHex(t);return e?BigInt("0x"+e):BigInt(0)}}function oo(t,e){const r=BigInt.asUintN(32,t),n=t>>32n,i=BigInt.asUintN(32,e),o=e>>32n;return r*i+(n*i<<32n)+(r*o<<32n)+(n*o<<64n)}io.EXPECTED_BUFFER_LENGTH=32;class ao{constructor(t){this.compareFn=t,this.elements=[]}add(t){this.elements.includes(t)||(this.elements.push(t),this.elements.sort(this.compareFn))}delete(t){const e=this.elements.indexOf(t);return-1!==e&&(this.elements.splice(e,1),!0)}has(t){return this.elements.includes(t)}clear(){this.elements=[]}forEach(t){for(const e of this.elements)t(e,this)}static fromSet(t,e){const r=new ao(e);for(const e of t)r.add(e);return r}get size(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)yield t}}var so,uo,co=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},fo=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class lo{constructor(t){this.compareFn=t,so.set(this,void 0),this.map=new Map,co(this,so,[],"f")}set(t,e){this.map.has(t)||(fo(this,so,"f").push(t),fo(this,so,"f").sort(this.compareFn)),this.map.set(t,e)}get(t){return this.map.get(t)}keys(){return fo(this,so,"f").values()}values(){const t=[];for(let e=0;e<fo(this,so,"f").length;e++){const r=fo(this,so,"f")[e],n=this.map.get(r);if(!n)throw new Error("Value not found");t.push(n)}return t.values()}has(t){return this.map.has(t)}delete(t){return!!this.map.has(t)&&(this.map.delete(t),co(this,so,fo(this,so,"f").filter((e=>e!==t)),"f"),!0)}clear(){this.map.clear(),co(this,so,[],"f")}static fromMap(t,e){const r=new lo(e);for(const[e,n]of t)r.set(e,n);return r}forEach(t){for(const e of fo(this,so,"f"))t(this.map.get(e),e,this)}get size(){return this.map.size}*[(so=new WeakMap,Symbol.iterator)](){for(const t of fo(this,so,"f"))yield[t,this.map.get(t)]}}class ho{constructor(t,e,r){this.eventType=t,this.eventDataSelector=e,this.eventData=r}}class po{constructor(t){this.currentOffset=0,this.buffer=new DataView(t.buffer)}static stringCompare(t,e){return t.localeCompare(e)}static bigintCompare(t,e){return t<e?-1:t>e?1:0}static numberCompare(t,e){return t<e?-1:t>e?1:0}setBuffer(t){this.buffer=new DataView(t.buffer),this.currentOffset=0}readEvents(){const t=[],e=this.readU16();if(e>1e3)throw new Error("Too many events to decode.");for(let r=0;r<e;r++){const e=this.readEvent();t.push(e)}return t}readAddressArray(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readAddress();return e}readU256Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU256();return e}readU64Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU64();return e}readU32Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU32();return e}readU16Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU16();return e}readU8Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU8();return e}readStringArray(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readStringWithLength();return e}readBytesArray(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readBytesWithLength();return e}readEvent(){const t=this.readStringWithLength(),e=this.readU64(),r=this.readBytesWithLength(352);return new ho(t,e,r)}readBytesWithLength(t=0){const e=this.readU32();if(t>0&&e>t)throw new Error("Data length exceeds maximum length.");return this.readBytes(e)}readABISelector(){return{name:this.readStringWithLength(),selector:this.readSelector()}}readViewSelectorsMap(){const t=new lo(((t,e)=>po.stringCompare(t,e))),e=this.readU16();for(let r=0;r<e;r++){const e=this.readStringWithLength(),r=this.readSelector();t.set(e,r)}return t}readMethodSelectorsMap(){const t=new ao(((t,e)=>po.numberCompare(t,e))),e=this.readU16();for(let r=0;r<e;r++)t.add(this.readSelector());return t}readMethodSelectors(){const t=new ao(((t,e)=>po.numberCompare(t,e))),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(){this.verifyEnd(this.currentOffset+8);const t=this.buffer.getBigUint64(this.currentOffset,!0);return this.currentOffset+=8,t}readMultiBytesAddressMap(){const t=new Map,e=this.readU8();if(e>8)throw new Error("Too many contract called.");for(let r=0;r<e;r++){const e=this.readAddress(),r=this.readU8();if(r>10)throw new Error("Too many calls.");const n=[];for(let t=0;t<r;t++){const t=this.readBytesWithLength();n.push(t)}t.set(e,n)}return t}readAddressValueTuple(){const t=this.readU16(),e=new Map;for(let r=0;r<t;r++){const t=this.readAddress(),r=this.readU256();if(e.has(t))throw new Error("Duplicate address found in map");e.set(t,r)}return e}readStorage(){const t=this.readU32(),e=new lo(((t,e)=>po.stringCompare(t,e)));for(let r=0;r<t;r++){const t=this.readAddress(),r=this.readU32(),n=new lo(((t,e)=>po.bigintCompare(t,e)));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);for(let n=0;n<t;n++){const t=this.readU8();if(e&&0===t){r=r.slice(0,n);break}r[n]=t}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()}readAddress(){return this.readString(66)}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")}}!function(t){t[t.U8=0]="U8",t[t.U16=1]="U16",t[t.U32=2]="U32",t[t.U64=3]="U64",t[t.U256=4]="U256",t[t.ADDRESS=5]="ADDRESS",t[t.STRING=6]="STRING",t[t.BOOLEAN=7]="BOOLEAN"}(uo||(uo={}));class yo{constructor(t=0,e=!1){this.trackDataTypes=e,this.currentOffset=0,this.selectorDatatype=[],this.buffer=this.getDefaultBuffer(t)}writeU8(t){if(t>255)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(uo.U8),this.allocSafe(1),this.buffer.setUint8(this.currentOffset++,t)}writeU16(t){if(t>65535)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(uo.U16),this.allocSafe(2),this.buffer.setUint16(this.currentOffset,t,!0),this.currentOffset+=2}writeU32(t,e=!0){if(t>4294967295)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(uo.U32),this.allocSafe(4),this.buffer.setUint32(this.currentOffset,t,e),this.currentOffset+=4}writeU64(t){if(t>18446744073709551615n)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(uo.U64),this.allocSafe(8),this.buffer.setBigUint64(this.currentOffset,t,!0),this.currentOffset+=8}writeSelector(t){this.writeU32(t,!1)}writeBoolean(t){this.trackDataTypes&&this.selectorDatatype.push(uo.BOOLEAN),this.writeU8(t?1:0)}writeU256(t){if(t>115792089237316195423570985008687907853269984665640564039457584007913129639935n)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(uo.U256),this.allocSafe(32);const e=io.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){this.allocSafe(t.byteLength);for(let e=0;e<t.byteLength;e++)this.writeU8(t[e])}writeString(t){this.trackDataTypes&&this.selectorDatatype.push(uo.STRING),this.allocSafe(t.length);for(let e=0;e<t.length;e++)this.writeU8(t.charCodeAt(e))}writeAddress(t){this.trackDataTypes&&this.selectorDatatype.push(uo.ADDRESS);const e=this.fromAddress(t);this.writeBytes(e)}writeStringWithLength(t){this.allocSafe(t.length+2),this.writeU16(t.length),this.writeString(t)}getBuffer(t=!0){const e=new Uint8Array(this.buffer.byteLength);for(let t=0;t<this.buffer.byteLength;t++)e[t]=this.buffer.getUint8(t);return t&&this.clear(),e}reset(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(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.allocSafe(4+32*t.length),this.writeU32(t.length);for(let e=0;e<t.length;e++)this.writeU256(t[e])}toBytesReader(){return new po(this.getBuffer())}getOffset(){return this.currentOffset}setOffset(t){this.currentOffset=t}clear(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(),this.selectorDatatype=[]}allocSafe(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}writeABISelector(t,e){this.writeStringWithLength(t),this.writeSelector(e)}getSelectorDataType(){return 0===this.selectorDatatype.length?0n:function(t,e=0){let r=BigInt(3735928559^e),n=BigInt(1103547991^e);for(let e,i=0;i<t.length;i++)e=BigInt(t[i]),r=oo(r^e,0x85ebca77n),n=oo(n^e,0xc2b2ae3dn);return r^=oo(r^n>>15n,0x735a2d97n),n^=oo(n^r>>15n,0xcaf649a9n),r^=n>>16n,n^=r>>16n,2097152n*(0xffffffffffffffffn&n)+(r>>11n)&0xffffffffffffffffn}(this.selectorDatatype)}writeAddressValueTupleMap(t){if(t.size>65535)throw new Error("Map size is too large");this.writeU16(t.size);const e=Array.from(t.keys());for(let r=0;r<e.length;r++){const n=e[r],i=t.get(n);if(null==i)throw new Error("Value not found");this.writeAddress(n),this.writeU256(i)}}writeLimitedAddressBytesMap(t){if(t.size>8)throw new Error("Too many contract calls");this.writeU8(t.size);const e=Array.from(t.keys());for(let r=0;r<e.length;r++){const n=e[r],i=t.get(n);if(!i)throw new Error("Calls not found");if(i.length>10)throw new Error("Too many calls.");this.writeAddress(n),this.writeU8(i.length);for(let t=0;t<i.length;t++)this.writeBytesWithLength(i[t])}}writeBytesWithLength(t){this.writeU32(t.length),this.writeBytes(t)}writeAddressArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeAddress(t[e])}writeU32Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU32(t[e])}writeU256Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU256(t[e])}writeStringArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeStringWithLength(t[e])}writeU16Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU16(t[e])}writeU8Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU8(t[e])}writeU64Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU64(t[e])}writeBytesArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeBytesWithLength(t[e])}writeSelectorArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeSelector(t[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)}))}fromAddress(t){if(t.length>66)throw new Error("Address is too long");const e=new Uint8Array(Math.min(t.length+1,66));for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return t.length<66&&(e[t.length]=0),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)}getDefaultBuffer(t=0){return new DataView(new ArrayBuffer(t))}}var bo,go=i(2802),wo=i(8287).Buffer;!function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.UINT64="UINT64",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES32="BYTES32",t.UINT256="UINT256",t.TUPLE="TUPLE",t.BYTES="BYTES",t.ADDRESS_UINT256_TUPLE="ADDRESS_UINT256_TUPLE",t.ARRAY_OF_ADDRESSES="ARRAY_OF_ADDRESSES",t.ARRAY_OF_UINT256="ARRAY_OF_UINT256",t.ARRAY_OF_UINT64="ARRAY_OF_UINT64",t.ARRAY_OF_UINT32="ARRAY_OF_UINT32",t.ARRAY_OF_UINT16="ARRAY_OF_UINT16",t.ARRAY_OF_UINT8="ARRAY_OF_UINT8",t.ARRAY_OF_STRING="ARRAY_OF_STRING",t.ARRAY_OF_BYTES="ARRAY_OF_BYTES"}(bo||(bo={}));class vo{decodeData(t,e){const r=new po(t),n=[];for(let t=0;t<e.length;t++)switch(e[t]){case bo.UINT8:n.push(r.readU8());break;case bo.UINT16:n.push(r.readU16());break;case bo.UINT32:n.push(r.readU32());break;case bo.BYTES32:n.push(r.readBytes(32));break;case bo.BOOL:n.push(r.readBoolean());break;case bo.ADDRESS:n.push(r.readAddress());break;case bo.STRING:n.push(r.readStringWithLength());break;case bo.UINT256:n.push(r.readU256());break;case bo.TUPLE:n.push(r.readTuple());break;case bo.ADDRESS_UINT256_TUPLE:n.push(r.readAddressValueTuple());break;case bo.BYTES:n.push(r.readBytesWithLength());break;case bo.UINT64:n.push(r.readU64());break;case bo.ARRAY_OF_ADDRESSES:n.push(r.readAddressArray());break;case bo.ARRAY_OF_UINT256:n.push(r.readU256Array());break;case bo.ARRAY_OF_UINT64:n.push(r.readU64Array());break;case bo.ARRAY_OF_UINT32:n.push(r.readU32Array());break;case bo.ARRAY_OF_UINT16:n.push(r.readU16Array());break;case bo.ARRAY_OF_UINT8:n.push(r.readU8Array());break;case bo.ARRAY_OF_STRING:n.push(r.readStringArray());break;case bo.ARRAY_OF_BYTES:n.push(r.readBytesArray())}return n}encodePointer(t){const e=this.sha256(t),r=wo.alloc(io.EXPECTED_BUFFER_LENGTH),n=e.subarray(0,io.EXPECTED_BUFFER_LENGTH);for(let t=0;t<io.EXPECTED_BUFFER_LENGTH;t++)r[t]=n[t];return BigInt("0x"+r.toString("hex"))}encodePointerHash(t,e){const r=new Uint8Array(io.EXPECTED_BUFFER_LENGTH+2);r[0]=255&t,r[1]=t>>8&255;const n=this.bigIntToUint8Array(e,io.EXPECTED_BUFFER_LENGTH);r.set(n,2);const i=this.sha256(r);if(i.byteLength!==io.EXPECTED_BUFFER_LENGTH)throw new Error("Invalid hash length");return i}encodeSelector(t){return this.sha256(t).subarray(0,4).toString("hex")}numericSelectorToHex(t){return t.toString(16)}bigIntToUint8Array(t,e){const r=new Uint8Array(e),n=io.valueToUint8Array(t);for(let t=0;t<e;t++)r[t]=n[t]||0;return r}sha256(t){return(new go.sha256).update(t).digest()}}function mo(t){return mo="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},mo(t)}function _o(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 Eo(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?_o(Object(r),!0).forEach((function(e){Po(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):_o(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function So(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 ko(t,e);var r={}.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)?ko(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function ko(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function To(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,Io(n.key),n)}}function Oo(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Oo=function(){return!!t})()}function Ao(t){return Ao=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ao(t)}function xo(t,e){return xo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},xo(t,e)}function Po(t,e,r){return(e=Io(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Io(t){var e=function(t){if("object"!=mo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=mo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==mo(e)?e:e+""}var Lo=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Po(r=function(t,e,r){return e=Ao(e),function(t,e){if(e&&("object"==mo(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,Oo()?Reflect.construct(e,r||[],Ao(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#00ffe1"),Po(r,"feesAddition",10000n),Po(r,"sighashTypes",[]),r.signer=e.signer,r.network=e.network,r.transaction=e.psbt,r.ignoreSignatureError(),r.tweakSigner(),r.internalInit(),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&&xo(t,e)}(t,Ze),function(t,e,r){return e&&To(t.prototype,e),r&&To(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"extractTransaction",value:function(){return this.transaction.extractTransaction()}},{key:"final",value:function(){return this.extractTransaction().toHex()}},{key:"toHex",value:function(){return this.transaction.toHex()}},{key:"addInput",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.transaction.addInput(t,e)}},{key:"addOutput",value:function(t){t.value&&this.transaction.addOutput(t)}},{key:"attemptFinalizeInputs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{for(var e=this.transaction.data.inputs,r=t;r<e.length;r++){var n=e[r];n.finalScriptWitness?this.transaction.finalizeTaprootInput(r,n.finalScriptWitness):this.transaction.finalizeInput(r)}return!0}catch(t){return this.warn(t.stack||"Couldn't finalize inputs"),!1}}},{key:"getPSBT",value:function(){return this.transaction}},{key:"getTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=So(t);try{for(n.s();!(e=n.n()).done;){var i,o=So(e.value.utxos);try{for(o.s();!(i=o.n()).done;){var a=i.value;r+=BigInt(a.value)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}return r}}],[{key:"fromBase64",value:function(e,r){var n=d.iL.fromBase64(e,{network:r.network});return new t(Eo(Eo({},r),{},{psbt:n}))}},{key:"fromHex",value:function(e,r){var n=d.iL.fromHex(e,{network:r.network});return new t(Eo(Eo({},r),{},{psbt:n}))}},{key:"from",value:function(e){var r=new d.iL({network:e.network});return new t(Eo(Eo({},e),{},{psbt:r}))}}])}(),Ro=i(8287).Buffer;function Bo(t){return Bo="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},Bo(t)}function No(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 Uo(t,e);var r={}.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)?Uo(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Uo(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function jo(){jo=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Bo(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Bo(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Co(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Fo(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Co(o,n,i,a,s,"next",t)}function s(t){Co(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Mo(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,Go(n.key),n)}}function Do(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Do=function(){return!!t})()}function Ho(t){return Ho=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ho(t)}function Ko(t,e){return Ko=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ko(t,e)}function Wo(t,e,r){return(e=Go(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Go(t){var e=function(t){if("object"!=Bo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Bo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Bo(e)?e:e+""}var Vo=new vo,zo=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.amount<pr.MINIMUM_DUST)throw new Error("Amount is below dust limit");return e.disableAutoRefund=!0,e.calldata=t.generateBurnCalldata(e.amount),Wo(r=function(t,e,r){return e=Ho(e),function(t,e){if(e&&("object"==Bo(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,Do()?Reflect.construct(e,r||[],Ho(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.WBTC_UNWRAP),Wo(r,"sighashTypes",[]),Wo(r,"calculatedSignHash",Lo.calculateSignHash(r.sighashTypes)),r.wbtc=new on(e.network,e.chainId),r.to=r.wbtc.getAddress(),r.vaultUTXOs=e.unwrapUTXOs,r.amount=e.amount,r.contractSecret=r.generateSecret(),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&Ko(t,e)}(t,Oi),function(t,e,r){return e&&Mo(t.prototype,e),r&&Mo(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"signPSBT",value:(i=Fo(jo().mark((function t(){return jo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.to||R.verifyContractAddress(this.to,this.network)){t.next=2;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 2:if(this.vaultUTXOs.length){t.next=4;break}throw new Error("No vault UTXOs provided");case 4:if(!this.signed){t.next=6;break}throw new Error("Transaction is already signed");case 6:return this.signed=!0,t.next=9,this.buildTransaction();case 9:return this.ignoreSignatureError(),t.next=12,this.mergeVaults(this.vaultUTXOs);case 12:return t.next=14,this.internalBuildTransaction(this.transaction);case 14:if(!t.sent){t.next=17;break}return t.abrupt("return",this.transaction);case 17:throw new Error("Could not sign transaction");case 18:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"mergeVaults",value:(n=Fo(jo().mark((function t(e){var r,n,i,o,a,s;return jo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e[0]){t.next=3;break}throw new Error("No vaults provided");case 3:if(!((n=this.getVaultTotalOutputAmount(e))<this.amount)){t.next=6;break}throw new Error("Total vault amount (".concat(n," sat) is less than the amount to unwrap (").concat(this.amount," sat)"));case 6:if(!((i=this.calculateOutputLeftAmountFromVaults(e))<ln.VAULT_MINIMUM_AMOUNT&&i!==ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT)){t.next=9;break}throw new Error("Output left amount is below minimum consolidation (".concat(ln.VAULT_MINIMUM_AMOUNT," sat) amount ").concat(i," for vault ").concat(r.vault));case 9:this.addOutput({address:r.vault,value:Number(i)}),this.addOutput({address:this.from,value:Number(this.amount)}),o=No(e),t.prev=12,o.s();case 14:if((a=o.n()).done){t.next=20;break}return s=a.value,t.next=18,this.addVaultInputs(s);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(12),o.e(t.t0);case 25:return t.prev=25,o.f(),t.finish(25);case 28:case"end":return t.stop()}}),t,this,[[12,22,25,28]])}))),function(t){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=Fo(jo().mark((function t(e){var r,n,i,o,a,s=arguments;return jo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.next=5,this.signInputs(e);case 5:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 9:t.prev=9,t.t0=t.catch(2),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 13:return t.abrupt("return",!1);case 14:case"end":return t.stop()}}),t,this,[[2,9]])}))),function(t){return r.apply(this,arguments)})},{key:"generateMultiSignRedeemScript",value:function(t,e){var r,n=d.KT.p2ms({m:e,pubkeys:t.map((function(t){return Ro.from(t,"base64")})),network:this.network}),i=d.KT.p2wsh({redeem:n,network:this.network}),o=i.output,a=null===(r=i.redeem)||void 0===r?void 0:r.output,s=n.output;if(!o||!a||!s)throw new Error("Failed to generate redeem script");return{witnessUtxo:o,redeemScript:a,witnessScript:s}}},{key:"addVaultUTXO",value:function(t,e){var r={hash:t.hash,index:t.outputIndex,witnessUtxo:{script:Ro.from(t.output,"base64"),value:Number(t.value)},witnessScript:e.witnessScript,sequence:this.sequence};this.calculatedSignHash&&(r.sighashType=this.calculatedSignHash),this.addInput(r)}},{key:"addVaultInputs",value:(e=Fo(jo().mark((function t(e){var r,n,i,o,a,s,u=arguments;return jo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=u.length>1&&void 0!==u[1]?u[1]:this.signer,n=this.generateMultiSignRedeemScript(e.publicKeys,e.minimum),i=No(e.utxos),t.prev=3,i.s();case 5:if((o=i.n()).done){t.next=21;break}if(a=o.value,s=this.transaction.inputCount,this.addVaultUTXO(a,n),!r){t.next=19;break}return t.prev=10,t.next=13,this.signInput(this.transaction,this.transaction.data.inputs[s],s,this.signer);case 13:this.log("Signed input ".concat(s," with ").concat(r.publicKey.toString("hex"))),t.next=19;break;case 16:t.prev=16,t.t0=t.catch(10),this.ignoreSignatureErrors||this.warn("Failed to sign input ".concat(s," with ").concat(r.publicKey.toString("hex")," ").concat(t.t0.message));case 19:t.next=5;break;case 21:t.next=26;break;case 23:t.prev=23,t.t1=t.catch(3),i.e(t.t1);case 26:return t.prev=26,i.f(),t.finish(26);case 29:case"end":return t.stop()}}),t,this,[[3,23,26,29],[10,16]])}))),function(t){return e.apply(this,arguments)})},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getVaultTotalOutputAmount(t)-this.amount}},{key:"getVaultTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=No(t);try{for(n.s();!(e=n.n()).done;){var i,o=No(e.value.utxos);try{for(o.s();!(i=o.n()).done;){var a=i.value;r+=BigInt(a.value)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}return r}}],[{key:"generateBurnCalldata",value:function(e){if(!e)throw new Error("Amount is required");var r=new yo;return r.writeSelector(t.UNWRAP_SELECTOR),r.writeU256(e),Ro.from(r.getBuffer())}}]);var e,r,n,i}();Wo(zo,"UNWRAP_SELECTOR",Number("0x"+Vo.encodeSelector("burn")));var qo=i(8287).Buffer;function Xo(t){return Xo="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},Xo(t)}function $o(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 Yo(t,e);var r={}.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)?Yo(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Yo(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Zo(){Zo=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Xo(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Xo(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Jo(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Qo(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Jo(o,n,i,a,s,"next",t)}function s(t){Jo(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ta(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 ea(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?ta(Object(r),!0).forEach((function(e){aa(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):ta(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ra(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,sa(n.key),n)}}function na(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(na=function(){return!!t})()}function ia(t){return ia=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ia(t)}function oa(t,e){return oa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},oa(t,e)}function aa(t,e,r){return(e=sa(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function sa(t){var e=function(t){if("object"!=Xo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xo(e)?e:e+""}var ua=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e.refundVault)throw new Error("Refund vault is required");if(!e.requestedAmount)throw new Error("Requested amount is required");if(!e.receiver)throw new Error("Receiver is required");if(aa(r=function(t,e,r){return e=ia(e),function(t,e){if(e&&("object"==Xo(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,na()?Reflect.construct(e,r||[],ia(t).constructor):e.apply(t,r))}(this,t,[ea(ea({},e),{},{signer:R.fromPrivateKey(d.Et.sha256(qo.from("aaaaaaaa","utf-8"))),priorityFee:0n})]),"type",un.MULTI_SIG),aa(r,"targetScriptRedeem",null),aa(r,"leftOverFundsScriptRedeem",null),aa(r,"originalInputCount",0),aa(r,"sighashTypes",t.signHashTypesArray),aa(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:pr.witnessStackToScriptWitness(n)}})),!e.pubkeys)throw new Error("Pubkeys are required");return e.psbt&&(r.log("Using provided PSBT."),r.transaction=e.psbt,r.originalInputCount=r.transaction.data.inputs.length),r.refundVault=e.refundVault,r.requestedAmount=e.requestedAmount,r.receiver=e.receiver,r.publicKeys=e.pubkeys,r.minimumSignatures=e.minimumSignatures,r.compiledTargetScript=pt.compile(e.pubkeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&oa(t,e)}(t,pr),function(t,e,r){return e&&ra(t.prototype,e),r&&ra(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"finalizeTransactionInputs",value:function(){var t=!1;try{for(var e=this.originalInputCount;e<this.transaction.data.inputs.length;e++)this.transaction.finalizeInput(e,this.customFinalizer.bind(this));t=!0}catch(t){this.error("Error finalizing transaction inputs: ".concat(t.stack))}return t}},{key:"signPSBT",value:(i=Qo(Zo().mark((function t(){return Zo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"buildTransaction",value:(n=Qo(Zo().mark((function t(){var e,r;return Zo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.targetScriptRedeem){t.next=3;break}throw new Error("Left over funds script redeem is required");case 3:if(e.redeemVersion){t.next=5;break}throw new Error("Left over funds script redeem version is required");case 5:if(e.output){t.next=7;break}throw new Error("Left over funds script redeem output is required");case 7:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),!((r=this.calculateOutputLeftAmountFromVaults(this.utxos))<0)){t.next=12;break}throw new Error("Output value left is negative ".concat(r,"."));case 12:this.addOutput({address:this.refundVault,value:Number(r)}),this.addOutput({address:this.receiver,value:Number(this.requestedAmount)});case 14:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=Qo(Zo().mark((function t(e){var r,n,i,o,a,s=arguments;return Zo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=s.length>1&&void 0!==s[1]&&s[1],n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);return e.addOutputs(i),t.prev=7,t.next=10,this.signInputs(e);case 10:return t.abrupt("return",this.finalizeTransactionInputs());case 13:t.prev=13,t.t0=t.catch(7),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 17:return t.abrupt("return",!1);case 18:case"end":return t.stop()}}),t,this,[[7,13]])}))),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Qo(Zo().mark((function t(e){return Zo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:(0,k.toXOnly)(t.numsPoint),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var e=this.targetScriptRedeem;if(!e)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:(0,k.toXOnly)(t.numsPoint),network:this.network,scriptTree:this.scriptTree,redeem:e}}},{key:"getScriptSolution",value:function(t){return t.tapScriptSig?t.tapScriptSig.map((function(t){return t.signature})):[]}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"getTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=$o(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.value)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getTotalOutputAmount(t)-this.requestedAmount}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}],[{key:"fromBase64",value:function(e){var r=d.iL.fromBase64(e.psbt,{network:e.network});return new t(ea(ea({},e),{},{psbt:r}))}},{key:"verifyIfSigned",value:function(t,e){for(var r=!1,n=1;n<t.data.inputs.length;n++){var i=t.data.inputs[n];if(i.finalScriptWitness){var o=pr.readScriptWitnessToWitnessStack(i.finalScriptWitness);if(!(o.length<3))for(var a=0;a<o.length-2;a+=3)if(o[a+2].equals(e)){r=!0;break}}}return r}},{key:"signPartial",value:function(e,r,n,i){for(var o=!1,a=!0,s=n;s<e.data.inputs.length;s++){var u=e.data.inputs[s];u.tapInternalKey||(u.tapInternalKey=(0,k.toXOnly)(t.numsPoint));var c=[];if(u.finalScriptWitness){var f=pr.readScriptWitnessToWitnessStack(u.finalScriptWitness);u.tapLeafScript=[{leafVersion:192,script:f[f.length-2],controlBlock:f[f.length-1]}];for(var l=0;l<f.length-2;l+=3)c.push({signature:f[l],leafHash:f[l+1],pubkey:f[l+2]});u.tapScriptSig=(u.tapScriptSig||[]).concat(c)}delete u.finalScriptWitness;var h=t.signHashTypesArray?[t.calculateSignHash(t.signHashTypesArray)]:[];try{t.signInput(e,u,s,r,h),o=!0}catch(t){console.log(t)}if(o){if(!u.tapScriptSig)throw new Error("No new signatures for input");u.tapScriptSig.length!==i[s-n]&&(a=!1)}}return{signed:o,final:!!o&&a}}},{key:"dedupeSignatures",value:function(t,e){var r,n=new Map,i=$o(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.set(o.pubkey.toString("hex"),o)}}catch(t){i.e(t)}finally{i.f()}var a,s=$o(e);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.has(u.pubkey.toString("hex"))||n.set(u.pubkey.toString("hex"),u)}}catch(t){s.e(t)}finally{s.f()}return Array.from(n.values())}},{key:"attemptFinalizeInputs",value:function(e,r,n,i){for(var o=0,a=function(a){try{var s=e.data.inputs[a];s.tapInternalKey||(s.tapInternalKey=(0,k.toXOnly)(t.numsPoint));var u=[];if(s.finalScriptWitness){for(var c=pr.readScriptWitnessToWitnessStack(s.finalScriptWitness),f=0;f<c.length-2;f+=3)u.push({signature:c[f],leafHash:c[f+1],pubkey:c[f+2]});s.tapLeafScript=[{leafVersion:192,script:c[c.length-2],controlBlock:c[c.length-1]}],s.tapScriptSig=t.dedupeSignatures(s.tapScriptSig||[],u)}delete s.finalScriptWitness,e.finalizeInput(a,(function(e,o){return t.partialFinalizer(e,o,[],n[a-r],i)})),o++}catch(t){}},s=r;s<e.data.inputs.length;s++)a(s);return o===e.data.inputs.length-r}}]);var e,r,n,i}();aa(ua,"LOCK_LEAF_SCRIPT",d.K$.compile([d.Ez.OP_XOR,d.Ez.OP_NOP,d.Ez.OP_CODESEPARATOR])),aa(ua,"signHashTypesArray",[]),aa(ua,"numsPoint",qo.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex")),aa(ua,"partialFinalizer",(function(t,e,r,n,i){if(!e.tapLeafScript||!e.tapLeafScript[0].script||!e.tapLeafScript[0].controlBlock)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("No new signatures for input ".concat(t,"."));var o=[];if(i){var a,s=$o(n);try{for(s.s();!(a=s.n()).done;){var u,c=a.value,f=!1,l=$o(e.tapScriptSig);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.pubkey.equals((0,k.toXOnly)(c))&&(o.push(h.signature),f=!0)}}catch(t){l.e(t)}finally{l.f()}f||o.push(qo.alloc(0))}}catch(t){s.e(t)}finally{s.f()}o=o.reverse()}else o=e.tapScriptSig.map((function(t){return[t.signature,t.leafHash,t.pubkey]})).flat();r.length>0&&(o=o.concat(r));var p=o.concat(e.tapLeafScript[0].script).concat(e.tapLeafScript[0].controlBlock);return{finalScriptWitness:pr.witnessStackToScriptWitness(p)}}));var ca=i(8287).Buffer;function fa(t){return fa="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},fa(t)}function la(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 ha(t,e);var r={}.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)?ha(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function ha(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function pa(){pa=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==fa(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(fa(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function da(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function ya(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){da(o,n,i,a,s,"next",t)}function s(t){da(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ba(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 ga(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ga=function(){return!!t})()}function wa(t){return wa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},wa(t)}function va(t,e){return va=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},va(t,e)}function ma(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 _a(t){var e=function(t){if("object"!=fa(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fa(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fa(e)?e:e+""}var Ea=new vo,Sa=ca.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),ka=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.amount<pr.MINIMUM_DUST)throw new Error("Amount is below dust limit");return e.disableAutoRefund=!0,e.calldata=t.generateBurnCalldata(e.amount),ma(r=function(t,e,r){return e=wa(e),function(t,e){if(e&&("object"==fa(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,ga()?Reflect.construct(e,r||[],wa(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.WBTC_UNWRAP),ma(r,"sighashTypes",[]),ma(r,"estimatedFeeLoss",0n),ma(r,"calculatedSignHash",Lo.calculateSignHash(r.sighashTypes)),r.wbtc=new on(e.network,e.chainId),r.to=r.wbtc.getAddress(),r.vaultUTXOs=e.unwrapUTXOs,r.estimatedFeeLoss=t.preEstimateTaprootTransactionFees(BigInt(r.feeRate),r.calculateNumInputs(r.vaultUTXOs),2n,r.calculateNumSignatures(r.vaultUTXOs),65n,r.calculateNumEmptyWitnesses(r.vaultUTXOs)),r.amount=e.amount,r.contractSecret=r.generateSecret(),r.calldataGenerator=new V((0,k.toXOnly)(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,[L.UNWRAP]),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&va(t,e)}(t,Oi),function(t,e,r){return e&&ba(t.prototype,e),r&&ba(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"signPSBT",value:(r=ya(pa().mark((function t(){return pa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.to||R.verifyContractAddress(this.to,this.network)){t.next=2;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 2:if(this.vaultUTXOs.length){t.next=4;break}throw new Error("No vault UTXOs provided");case 4:return t.next=6,this.buildTransaction();case 6:return this.ignoreSignatureError(),this.mergeVaults(),t.next=10,this.internalBuildTransaction(this.transaction);case 10:if(!t.sent){t.next=13;break}return t.abrupt("return",this.transaction);case 13:throw new Error("Could not sign transaction");case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"getRefund",value:function(){var t,e=-ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT,r=la(this.vaultUTXOs);try{for(r.s();!(t=r.n()).done;)for(var n=t.value,i=0;i<n.utxos.length;i++)e+=ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT}catch(t){r.e(t)}finally{r.f()}return e}},{key:"getFeeLossOrRefund",value:function(){return this.getRefund()-this.estimatedFeeLoss}},{key:"mergeVaults",value:function(){var t=this.getVaultTotalOutputAmount(this.vaultUTXOs),e=this.getRefund(),r=t-e-this.amount;if(r===ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT)e+=ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT;else if(r<ln.VAULT_MINIMUM_AMOUNT)throw new Error("Output left amount is below the minimum amount: ".concat(r," below ").concat(ln.VAULT_MINIMUM_AMOUNT));var n=this.amount+e-this.estimatedFeeLoss,i=ti.findVaultWithMostPublicKeys(this.vaultUTXOs);if(!i)throw new Error("No vaults provided");if(r>ln.VAULT_MINIMUM_AMOUNT&&r-ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT!==0n?this.success("Consolidating output with ".concat(r," sat.")):this.warn("No consolidation in this transaction."),r-ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT!==0n&&this.addOutput({address:i.vault,value:Number(r)}),n<pr.MINIMUM_DUST)throw new Error("Amount is below dust limit. The requested amount can not be unwrapped since, after fees, it is below the dust limit. Dust: ".concat(n," sat. Are your bitcoin fees too high?"));var o=100n*n/this.amount;if(o<=60n)throw new Error("For user safety, OPNet will decline this transaction since you will lose ".concat(100n-o,"% of your btc by doing this transaction due to bitcoin fees. Are your bitcoin fees too high?"));this.addOutput({address:this.from,value:Number(n)});var a,s=la(this.vaultUTXOs);try{for(s.s();!(a=s.n()).done;){var u=a.value;this.addVaultInputs(u)}}catch(t){s.e(t)}finally{s.f()}}},{key:"calculateNumEmptyWitnesses",value:function(t){var e,r=0n,n=la(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.publicKeys.length-i.minimum)*BigInt(i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateNumSignatures",value:function(t){var e,r=0n,n=la(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.minimum*i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateNumInputs",value:function(t){var e,r=0n,n=la(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"internalPubKeyToXOnly",value:function(){return(0,k.toXOnly)(Sa)}},{key:"generateTapDataForInput",value:function(t,e){var r=pt.compile(t,e),n=[{output:r,version:192},{output:ua.LOCK_LEAF_SCRIPT,version:192}],i={output:r,redeemVersion:192};return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:n,redeem:i}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,(0,k.toXOnly)(this.signer.publicKey),t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"internalBuildTransaction",value:(e=ya(pa().mark((function t(e){var r,n,i,o,a,s=arguments;return pa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.prev=3,t.next=6,this.signInputs(e);case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(3),console.log(t.t0);case 11:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 15:t.prev=15,t.t1=t.catch(2),a=t.t1,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 19:return t.abrupt("return",!1);case 20:case"end":return t.stop()}}),t,this,[[2,15],[3,8]])}))),function(t){return e.apply(this,arguments)})},{key:"addVaultUTXO",value:function(t,e,r){var n=this.generateTapDataForInput(e,r),i=d.KT.p2tr(n);if(!i.witness)throw new Error("Failed to generate taproot witness");var o=i.witness[i.witness.length-1],a={hash:t.hash,index:t.outputIndex,witnessUtxo:{script:ca.from(t.output,"base64"),value:Number(t.value)},sequence:this.sequence,tapLeafScript:[{leafVersion:n.redeem.redeemVersion,script:n.redeem.output,controlBlock:o}]};this.calculatedSignHash&&(a.sighashType=this.calculatedSignHash),this.addInput(a)}},{key:"addVaultInputs",value:function(t){var e,r=t.publicKeys.map((function(t){return ca.from(t,"base64")})),n=la(t.utxos);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.addVaultUTXO(i,r,t.minimum)}}catch(t){n.e(t)}finally{n.f()}}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getVaultTotalOutputAmount(t)-this.amount}},{key:"getVaultTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=la(t);try{for(n.s();!(e=n.n()).done;){var i,o=la(e.value.utxos);try{for(o.s();!(i=o.n()).done;){var a=i.value;r+=BigInt(a.value)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}return r}}],[{key:"generateBurnCalldata",value:function(e){if(!e)throw new Error("Amount is required");var r=new yo;return r.writeSelector(t.UNWRAP_SELECTOR),r.writeU256(e),ca.from(r.getBuffer())}}]);var e,r}();function Ta(t){return Ta="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},Ta(t)}function Oa(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,Aa(n.key),n)}}function Aa(t){var e=function(t){if("object"!=Ta(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ta(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ta(e)?e:e+""}ma(ka,"UNWRAP_SELECTOR",Number("0x"+Ea.encodeSelector("burn")));var xa=function(){return function(t,e,r){return r&&Oa(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;if(R.verifyPubKeys(t,r).length!==t.length)throw new Error("Contains invalid public keys");var n=new ua({network:r,utxos:[],pubkeys:t,minimumSignatures:e,feeRate:100,receiver:"a",requestedAmount:1n,refundVault:"a"}).getScriptAddress();if(!n)throw new Error("Failed to generate address");return n}}])}(),Pa=i(8287).Buffer;function Ia(t){return Ia="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},Ia(t)}function La(t){return function(t){if(Array.isArray(t))return Ra(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ra(t,e);var r={}.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)?Ra(t,e):void 0}}(t)||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.")}()}function Ra(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ba(){Ba=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Ia(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Ia(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Na(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ua(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,Da(n.key),n)}}function ja(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ja=function(){return!!t})()}function Ca(t){return Ca=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ca(t)}function Fa(t,e){return Fa=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Fa(t,e)}function Ma(t,e,r){return(e=Da(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Da(t){var e=function(t){if("object"!=Ia(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ia(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ia(e)?e:e+""}var Ha,Ka=new vo,Wa=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.amount<ln.VAULT_MINIMUM_AMOUNT)throw new Error("Amount is below the minimum required of ".concat(ln.VAULT_MINIMUM_AMOUNT," sat."));var n=e.receiver||pr.getFrom(e.from,e.signer,e.network);if(e.calldata=t.generateMintCalldata(e.amount,n,e.network),Ma(r=function(t,e,r){return e=Ca(e),function(t,e){if(e&&("object"==Ia(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,ja()?Reflect.construct(e,r||[],Ca(t).constructor):e.apply(t,r))}(this,t,[e]),"type",un.WBTC_WRAP),Ma(r,"tapLeafScript",null),Ma(r,"interactionPubKeys",[]),Ma(r,"minimumSignatures",0),r.wbtc=new on(e.network,e.chainId),r.vault=e.generationParameters.vault,r.to=r.wbtc.getAddress(),r.receiver=n,r.amount=e.amount,r.verifyRequiredValue(),r.interactionPubKeys=e.generationParameters.pubKeys,r.minimumSignatures=e.generationParameters.constraints.minimum,r.contractSecret=r.generateSecret(),!r.verifyPublicKeysConstraints(e.generationParameters))throw new Error("Oops. Your wrapping request have been decline! It failed security checks!");return r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,[],r.interactionPubKeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&Fa(t,e)}(t,Oi),function(t,e,r){return e&&Ua(t.prototype,e),r&&Ua(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"verifyPublicKeysConstraints",value:function(t){if(t.constraints.minimum<2)throw new Error("Minimum signatures must be at least 2");if(t.keys.length<t.constraints.transactionMinimum||t.keys.length<t.constraints.minimum)throw new Error("Not enough pub keys");if(t.keys.length>255)throw new Error("Too many pub keys");var e=this.generateVaultAddress(t.pubKeys,t.constraints.minimum);if(e!==t.vault)throw new Error("Invalid vault address. Expected: ".concat(e," Got: ").concat(t.vault));var r=this.generateChecksumSalt(t,this.amount,t.vault),n=ti.opnetHash(r);if(n!==t.signature)throw new Error("Invalid checksum. Expected: ".concat(n," Got: ").concat(t.signature));return!0}},{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Na(o,n,i,a,s,"next",t)}function s(t){Na(o,n,i,a,s,"throw",t)}a(void 0)}))}}(Ba().mark((function t(){var e,r;return Ba().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("To address is required");case 2:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=5;break}throw new Error("Left over funds script redeem is required");case 5:if(e.redeemVersion){t.next=7;break}throw new Error("Left over funds script redeem version is required");case 7:if(e.output){t.next=9;break}throw new Error("Left over funds script redeem output is required");case 9:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),this.addVaultOutput(),t.next=16,this.addRefundOutput(r+this.amount+ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT);case 16:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"verifyRequiredValue",value:function(){if(this.totalInputAmount<this.amount)throw new Error("Not enough funds to wrap the amount specified. ".concat(this.totalInputAmount," < ").concat(this.amount));var t=this.amount+ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT;if(this.totalInputAmount<t)throw new Error("Not enough funds to wrap the amount specified. ".concat(this.totalInputAmount," < ").concat(t,". Make sure that your inputs cover the amount to wrap, the priority fee and the unwrap prepaid fees."))}},{key:"addVaultOutput",value:function(){if(!this.vault)throw new Error("No vault address provided");var t=this.amount+ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT,e={address:this.vault,value:Number(t)};this.addOutput(e)}},{key:"generateVaultAddress",value:function(t,e){return xa.generateMultiSigAddress(t,e,this.network)}},{key:"generateChecksumSalt",value:function(t,e,r){var n=t.constraints.version,i=t.constraints.timestamp,o=Pa.alloc(12+n.length);return o.writeBigInt64BE(BigInt(i),0),o.writeInt16BE(t.constraints.minimum,8),o.writeInt16BE(t.constraints.transactionMinimum,10),o.write(n,12,n.length,"utf-8"),Pa.concat([].concat(La(t.pubKeys),La(t.entities.map((function(t){return Pa.from(t,"utf-8")}))),[o,Pa.from(e.toString(),"utf-8"),Pa.from(r,"utf-8")]))}}],[{key:"generateMintCalldata",value:function(e,r,n){if(!e)throw new Error("Amount is required");if(!r)throw new Error("To address is required");if(!kt.isValidP2TRAddress(r,n))throw new Error("Oops! The address ".concat(r," is not a valid P2TR address! If you wrap at this address, your funds will be lost!"));var i=new yo;return i.writeSelector(t.WRAP_SELECTOR),i.writeAddress(r),i.writeU256(e),Pa.from(i.getBuffer())}}]);var e}();Ma(Wa,"WRAP_SELECTOR",Number("0x"+Ka.encodeSelector("mint"))),function(t){t[t.UNWRAP=0]="UNWRAP"}(Ha||(Ha={}));var Ga=i(8287).Buffer;function Va(t){return Va="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},Va(t)}function za(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Xa(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function qa(t){return function(t){if(Array.isArray(t))return $a(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Xa(t)||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.")}()}function Xa(t,e){if(t){if("string"==typeof t)return $a(t,e);var r={}.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)?$a(t,e):void 0}}function $a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ya(){Ya=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Va(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Va(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Za(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 Ja(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Za(Object(r),!0).forEach((function(e){Qa(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Za(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Qa(t,e,r){return(e=ns(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ts(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function es(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ts(o,n,i,a,s,"next",t)}function s(t){ts(o,n,i,a,s,"throw",t)}a(void 0)}))}}function rs(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,ns(n.key),n)}}function ns(t){var e=function(t){if("object"!=Va(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Va(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Va(e)?e:e+""}var is=function(){return function(t,e){return e&&rs(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"createCustomScriptTransaction",value:(s=es(Ya().mark((function t(e){var r,n,i,o,a,s,u;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:return r=new pi(Ja(Ja({},e),{},{utxos:[e.utxos[0]]})),t.next=7,r.generateTransactionMinimalSignatures();case 7:return t.next=9,r.getFundingTransactionParameters();case 9:return(n=t.sent).utxos=e.utxos,t.next=13,r.estimateTransactionFees();case 13:return t.t0=t.sent,t.t1=this.getPriorityFee(e),n.amount=t.t0+t.t1,t.next=18,this.createFundTransaction(Ja({},n));case 18:if(i=t.sent){t.next=21;break}throw new Error("Could not sign funding transaction.");case 21:return n.estimatedFees=i.estimatedFees,t.next=24,this.createFundTransaction(n);case 24:if(o=t.sent){t.next=27;break}throw new Error("Could not sign funding transaction.");case 27:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=Ja(Ja({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),s=new pi(a),t.next=32,s.signTransaction();case 32:return u=t.sent,t.abrupt("return",[o.tx.toHex(),u.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 34:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"signInteraction",value:(a=es(Ya().mark((function t(e){var r,n,i,o,a,s,u;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:return r=new ro(Ja(Ja({},e),{},{utxos:[e.utxos[0]]})),t.next=7,r.generateTransactionMinimalSignatures();case 7:return t.next=9,r.getFundingTransactionParameters();case 9:return(n=t.sent).utxos=e.utxos,t.next=13,r.estimateTransactionFees();case 13:return t.t0=t.sent,t.t1=this.getPriorityFee(e),n.amount=t.t0+t.t1,t.next=18,this.createFundTransaction(Ja({},n));case 18:if(i=t.sent){t.next=21;break}throw new Error("Could not sign funding transaction.");case 21:return n.estimatedFees=i.estimatedFees,t.next=24,this.createFundTransaction(n);case 24:if(o=t.sent){t.next=27;break}throw new Error("Could not sign funding transaction.");case 27:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=Ja(Ja({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),s=new ro(a),t.next=32,s.signTransaction();case 32:return u=t.sent,t.abrupt("return",[o.tx.toHex(),u.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 34:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"signDeployment",value:(o=es(Ya().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Di(e),t.next=3,r.signTransaction();case 3:return t.next=5,r.getFundingTransactionParameters();case 5:return n=t.sent,t.next=8,r.estimateTransactionFees();case 8:return t.t0=t.sent,t.t1=this.getPriorityFee(e),n.amount=t.t0+t.t1,i=new $i(n),t.next=14,i.signTransaction();case 14:if(o=t.sent){t.next=17;break}throw new Error("Could not sign funding transaction.");case 17:return a=o.outs[0],s={transactionId:o.getId(),outputIndex:0,scriptPubKey:{hex:a.script.toString("hex"),address:r.getScriptAddress()},value:BigInt(a.value)},u=Ja(Ja({},e),{},{utxos:[s],randomBytes:r.getRndBytes(),nonWitnessUtxo:o.toBuffer(),optionalOutputs:[]}),c=new Di(u),t.next=23,c.signTransaction();case 23:return f=t.sent,l=o.outs[1],h={transactionId:o.getId(),outputIndex:1,scriptPubKey:{hex:l.script.toString("hex"),address:e.from},value:BigInt(l.value)},t.abrupt("return",{transaction:[o.toHex(),f.toHex()],contractAddress:c.contractAddress,p2trAddress:c.p2trAddress,utxos:[h]});case 27:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"wrap",value:(i=es(Ya().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.amount<ln.VAULT_MINIMUM_AMOUNT)){t.next=2;break}throw new Error("Amount is too low. Minimum consolidation is ".concat(ln.VAULT_MINIMUM_AMOUNT," sat. Received ").concat(e.amount," sat. Make sure that you cover the unwrap consolidation fees of ").concat(ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT,"sat."));case 2:return n=e.amount+ln.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT+this.getPriorityFee(e),i=new on(e.network,e.chainId),o=i.getAddress(),a=Ja(Ja({},e),{},{amount:n,to:null!==(r=e.to)&&void 0!==r?r:o}),t.next=8,this.createFundTransaction(a);case 8:return s=t.sent,e.utxos=this.getUTXOAsTransaction(s.tx,o,0),u=new Wa(e),t.next=13,u.signTransaction();case 13:return t.next=15,u.getFundingTransactionParameters();case 15:return(c=t.sent).amount+=n,c.utxos=a.utxos,t.next=20,this.createFundTransaction(c);case 20:if(f=t.sent){t.next=23;break}throw new Error("Could not sign funding transaction.");case 23:return l=Ja(Ja({},e),{},{utxos:this.getUTXOAsTransaction(f.tx,o,0),randomBytes:u.getRndBytes(),nonWitnessUtxo:f.tx.toBuffer()}),h=new Wa(l),t.next=27,h.signTransaction();case 27:return p=t.sent,t.abrupt("return",{transaction:[f.tx.toHex(),p.toHex()],vaultAddress:h.vault,amount:h.amount,receiverAddress:h.receiver,utxos:this.getUTXOAsTransaction(f.tx,e.from,1)});case 29:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"unwrapSegwit",value:(n=es(Ya().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.error('The "unwrap" method is deprecated. Use unwrapTap instead.'),r=new zo(e),t.next=4,r.signTransaction();case 4:if(n=r.toAddress()){t.next=7;break}throw new Error("To address is required");case 7:return t.next=9,r.estimateTransactionFees();case 9:return i=t.sent,o=r.preEstimateTransactionFees(BigInt(e.feeRate),this.calculateNumInputs(e.unwrapUTXOs),2n,this.calculateNumSignatures(e.unwrapUTXOs),this.maxPubKeySize(e.unwrapUTXOs)),a=Ja(Ja({},e),{},{amount:i+o,to:n}),t.next=14,this.createFundTransaction(a);case 14:return s=t.sent,e.utxos=this.getUTXOAsTransaction(s.tx,n,0),u=new zo(Ja(Ja({},e),{},{randomBytes:r.getRndBytes()})),t.next=19,u.signTransaction();case 19:return t.next=21,u.getFundingTransactionParameters();case 21:return(c=t.sent).utxos=a.utxos,t.next=25,u.estimateTransactionFees();case 25:return t.t0=t.sent,t.t1=o,c.amount=t.t0+t.t1,t.next=30,this.createFundTransaction(c);case 30:if(f=t.sent){t.next=33;break}throw new Error("Could not sign funding transaction.");case 33:return l=Ja(Ja({},e),{},{utxos:this.getUTXOAsTransaction(f.tx,n,0),randomBytes:u.getRndBytes(),nonWitnessUtxo:f.tx.toBuffer()}),h=new zo(l),t.next=37,h.signPSBT();case 37:return p=t.sent,d=p.toBase64(),y=this.writePSBTHeader(Ha.UNWRAP,d),t.abrupt("return",{fundingTransaction:f.tx.toHex(),psbt:y,feeRefundOrLoss:o,utxos:[]});case 41:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"unwrap",value:(r=es(Ya().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return r=new ka(e),t.next=5,r.signTransaction();case 5:if(n=r.toAddress()){t.next=8;break}throw new Error("To address is required");case 8:return t.next=10,r.estimateTransactionFees();case 10:return i=t.sent,o=Ja(Ja({},e),{},{amount:i,to:n}),t.next=14,this.createFundTransaction(o);case 14:return a=t.sent,e.utxos=this.getUTXOAsTransaction(a.tx,n,0),s=new ka(Ja(Ja({},e),{},{randomBytes:r.getRndBytes()})),t.next=19,s.signTransaction();case 19:return t.next=21,s.getFundingTransactionParameters();case 21:return(u=t.sent).utxos=o.utxos,t.next=25,s.estimateTransactionFees();case 25:return t.t0=t.sent,t.t1=this.getPriorityFee(e),u.amount=t.t0+t.t1,t.next=30,this.createFundTransaction(u);case 30:if(c=t.sent){t.next=33;break}throw new Error("Could not sign funding transaction.");case 33:return f=Ja(Ja({},e),{},{utxos:this.getUTXOAsTransaction(c.tx,n,0),randomBytes:s.getRndBytes(),nonWitnessUtxo:c.tx.toBuffer()}),l=new ka(f),t.next=37,l.signPSBT();case 37:return h=t.sent,p=h.toBase64(),d=this.writePSBTHeader(Ha.UNWRAP,p),t.abrupt("return",{fundingTransaction:c.tx.toHex(),psbt:d,feeRefundOrLoss:l.getFeeLossOrRefund(),utxos:this.getUTXOAsTransaction(c.tx,e.from,1)});case 41:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"createBTCTransfer",value:(e=es(Ya().mark((function t(e){var r;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return t.next=4,this.createFundTransaction(e);case 4:return r=t.sent,t.abrupt("return",{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)});case 6:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"getAllNewUTXOs",value:function(t,e,r){for(var n=t.getOutputs(),i=[],o=0;o<e.outs.length;o++){var a=n[o];"address"in a&&a.address===r&&i.push.apply(i,qa(this.getUTXOAsTransaction(e,r,o)))}return i}},{key:"createFundTransaction",value:(t=es(Ya().mark((function t(e){var r,n;return Ya().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:return r=new $i(e),t.next=5,r.signTransaction();case 5:if(n=t.sent){t.next=8;break}throw new Error("Could not sign funding transaction.");case 8:return t.abrupt("return",{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)});case 9:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})},{key:"calculateNumSignatures",value:function(t){var e,r=0n,n=za(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.minimum*i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateNumInputs",value:function(t){var e,r=0n,n=za(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"maxPubKeySize",value:function(t){var e,r=0,n=za(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=Math.max(r,i.publicKeys.length)}}catch(t){n.e(t)}finally{n.f()}return BigInt(r)}},{key:"writePSBTHeader",value:function(t,e){var r=Ga.from(e,"base64"),n=Ga.alloc(2);return n.writeUInt8(t,0),n.writeUInt8(fn,1),Ga.concat([n,r]).toString("hex")}},{key:"getPriorityFee",value:function(t){return t.priorityFee<pr.MINIMUM_DUST?pr.MINIMUM_DUST:t.priorityFee}},{key:"getUTXOAsTransaction",value:function(t,e,r){if(!t.outs[r])return[];var n=t.outs[r];return[{transactionId:t.getId(),outputIndex:r,scriptPubKey:{hex:n.script.toString("hex"),address:e},value:BigInt(n.value)}]}}]);var t,e,r,n,i,o,a,s}(),os=i(8287).Buffer;function as(t){return as="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},as(t)}function ss(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,cs(n.key),n)}}function us(t,e,r){return e&&ss(t.prototype,e),r&&ss(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function cs(t){var e=function(t){if("object"!=as(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=as(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==as(e)?e:e+""}var fs=us((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.constraints=e.constraints,this.entities=e.entities,this.keys=e.keys,this.signature=e.signature,this.vault=e.vault,this.pubKeys=this.keys.map((function(t){return os.from(t,"base64")}))}));function ls(t){return ls="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},ls(t)}function hs(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,ds(n.key),n)}}function ps(t,e,r){return e&&hs(t.prototype,e),r&&hs(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function ds(t){var e=function(t){if("object"!=ls(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ls(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ls(e)?e:e+""}var ys=ps((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.vaultUTXOs=e.vaultUTXOs,this.balance=BigInt(e.balance)}));function bs(t){return bs="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},bs(t)}function gs(){gs=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==bs(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(bs(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function ws(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=ms(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function vs(t){return function(t){if(Array.isArray(t))return _s(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||ms(t)||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.")}()}function ms(t,e){if(t){if("string"==typeof t)return _s(t,e);var r={}.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)?_s(t,e):void 0}}function _s(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Es(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ss(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Es(o,n,i,a,s,"next",t)}function s(t){Es(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ks(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,Os(n.key),n)}}function Ts(t,e,r){return(e=Os(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Os(t){var e=function(t){if("object"!=bs(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=bs(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==bs(e)?e:e+""}var As=function(){return function(t,e){return e&&ks(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ts(this,"utxoPath","address/utxos"),Ts(this,"rpc","json-rpc"),this.opnetAPIUrl=e}),[{key:"fetchUTXO",value:(a=Ss(gs().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,w,v;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e.usePendingUTXO&&(e.usePendingUTXO=!0),void 0===e.optimized&&(e.optimized=!0),n={method:"GET",headers:{"Content-Type":"application/json"}},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.utxoPath,"?address=").concat(e.address,"&optimize=").concat(null!==(r=e.optimized)&&void 0!==r&&r),t.next=6,fetch(i,n);case 6:if((o=t.sent).ok){t.next=9;break}throw new Error("Failed to fetch UTXO data: ".concat(o.statusText));case 9:return t.next=11,o.json();case 11:a=t.sent,s=e.usePendingUTXO?[].concat(vs(a.confirmed),vs(a.pending)):a.confirmed,u=[],c=ws(s),t.prev=15,l=gs().mark((function t(){var e;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=f.value,!a.spentTransactions.some((function(t){return t.transactionId===e.transactionId&&t.outputIndex===e.outputIndex}))){t.next=3;break}return t.abrupt("return",1);case 3:u.push(e);case 4:case"end":return t.stop()}}),t)})),c.s();case 18:if((f=c.n()).done){t.next=24;break}return t.delegateYield(l(),"t0",20);case 20:if(!t.t0){t.next=22;break}return t.abrupt("continue",22);case 22:t.next=18;break;case 24:t.next=29;break;case 26:t.prev=26,t.t1=t.catch(15),c.e(t.t1);case 29:return t.prev=29,c.f(),t.finish(29);case 32:if(0!==u.length){t.next=34;break}throw new Error("No UTXO found");case 34:if(h=u.filter((function(t){return BigInt(t.value)>=e.minAmount})),0!==h.length){t.next=37;break}throw new Error("No UTXO found (minAmount)");case 37:p=[],d=0n,y=e.requestedAmount,b=ws(h),t.prev=41,b.s();case 43:if((g=b.n()).done){t.next=54;break}if(w=g.value,!((v=BigInt(w.value))<=0n)){t.next=48;break}return t.abrupt("continue",52);case 48:if(d+=v,p.push({transactionId:w.transactionId,outputIndex:w.outputIndex,value:v,scriptPubKey:w.scriptPubKey}),!(d>y)){t.next=52;break}return t.abrupt("break",54);case 52:t.next=43;break;case 54:t.next=59;break;case 56:t.prev=56,t.t2=t.catch(41),b.e(t.t2);case 59:return t.prev=59,b.f(),t.finish(59);case 62:return t.abrupt("return",p);case 63:case"end":return t.stop()}}),t,this,[[15,26,29,32],[41,56,59,62]])}))),function(t){return a.apply(this,arguments)})},{key:"fetchUTXOMultiAddr",value:(o=Ss(gs().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=ws(e.addresses);try{for(n.s();!(i=n.n()).done;)o=i.value,a={address:o,minAmount:e.minAmount,requestedAmount:e.requestedAmount,optimized:e.optimized,usePendingUTXO:e.usePendingUTXO},s=this.fetchUTXO(a).catch((function(){return[]})),r.push(s)}catch(t){n.e(t)}finally{n.f()}return t.next=5,Promise.all(r);case 5:u=t.sent,c=u.flat(),f=[],l=0n,h=0;case 10:if(!(h<c.length)){t.next=19;break}if(p=c[h],!(l>=e.requestedAmount)){t.next=14;break}return t.abrupt("break",19);case 14:l+=p.value,f.push(p);case 16:h++,t.next=10;break;case 19:return t.abrupt("return",f);case 20:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"broadcastTransaction",value:(i=Ss(gs().mark((function t(e,r){var n,i;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[e,r],t.next=3,this.rpcMethod("btc_sendRawTransaction",n);case 3:if(i=t.sent){t.next=6;break}return t.abrupt("return");case 6:return t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"splitUTXOs",value:(n=Ss(gs().mark((function t(e,r,n,i){var o,a,s,u,c,f,l;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={addresses:[e.p2wpkh,e.p2tr],minAmount:330n,requestedAmount:1000000000000000n},t.next=3,this.fetchUTXOMultiAddr(o);case 3:if((a=t.sent)&&a.length){t.next=6;break}return t.abrupt("return",{error:"No UTXOs found"});case 6:return s=BigInt(n)*i,u={amount:s,feeRate:500,from:e.p2tr,utxos:a,signer:e.keypair,network:r,to:e.p2tr,splitInputsInto:n,priorityFee:330n},c=new is,t.next=11,c.createBTCTransfer(u);case 11:return f=t.sent,t.next=14,this.broadcastTransaction(f.tx,!1);case 14:if(l=t.sent){t.next=17;break}return t.abrupt("return",{error:"Could not broadcast transaction"});case 17:return t.abrupt("return",l);case 18:case"end":return t.stop()}}),t,this)}))),function(t,e,r,i){return n.apply(this,arguments)})},{key:"rpcMethod",value:(r=Ss(gs().mark((function t(e,r){var n,i,o,a,s;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,params:r,id:1})},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.rpc),t.next=4,fetch(i,n);case 4:if((o=t.sent).ok){t.next=7;break}throw new Error("Failed to fetch to rpc: ".concat(o.statusText));case 7:return t.next=9,o.json();case 9:if(a=t.sent){t.next=12;break}throw new Error("No data fetched");case 12:if(s=a.result){t.next=15;break}throw new Error("No rpc parameters found");case 15:if(!("error"in s)){t.next=17;break}throw new Error("Error in fetching to rpc ".concat(s.error));case 17:return t.abrupt("return",s);case 18:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"fetchWrapParameters",value:(e=Ss(gs().mark((function t(e){var r,n;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<ln.VAULT_MINIMUM_AMOUNT)){t.next=2;break}throw new Error("Amount must be greater than the minimum consolidation amount ".concat(ln.VAULT_MINIMUM_AMOUNT,"sat."));case 2:return r=[0,e.toString()],t.next=5,this.rpcMethod("btc_generate",r);case 5:if(n=t.sent){t.next=8;break}return t.abrupt("return");case 8:return t.abrupt("return",new fs(n));case 9:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"fetchUnWrapParameters",value:(t=Ss(gs().mark((function t(e,r){var n,i;return gs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<330n)){t.next=2;break}throw new Error("Amount must be greater than the minimum consolidation amount ".concat(ln.VAULT_MINIMUM_AMOUNT,"sat."));case 2:if(!(r.length<50)){t.next=4;break}throw new Error("Invalid receiver address");case 4:return n=[1,e.toString(),r],t.next=7,this.rpcMethod("btc_generate",n);case 7:if(i=t.sent){t.next=10;break}return t.abrupt("return");case 10:return t.abrupt("return",new ys(i));case 11:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i,o,a}();function xs(t){return xs="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},xs(t)}function Ps(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,Ls(n.key),n)}}function Is(t,e,r){return e&&Ps(t.prototype,e),r&&Ps(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Ls(t){var e=function(t){if("object"!=xs(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xs(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xs(e)?e:e+""}var Rs,Bs,Ns,Us=Is((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}));!function(t){t.testnet="testnet",t.mainnet="livenet",t.regtest="regtest"}(Rs||(Rs={})),function(t){t.BITCOIN_MAINNET="BITCOIN_MAINNET",t.BITCOIN_TESTNET="BITCOIN_TESTNET",t.BITCOIN_TESTNET4="BITCOIN_TESTNET4",t.BITCOIN_REGTEST="BITCOIN_REGTEST",t.BITCOIN_SIGNET="BITCOIN_SIGNET",t.FRACTAL_BITCOIN_MAINNET="FRACTAL_BITCOIN_MAINNET",t.FRACTAL_BITCOIN_TESTNET="FRACTAL_BITCOIN_TESTNET"}(Bs||(Bs={})),function(t){t.ecdsa="ecdsa",t.bip322="bip322-simple"}(Ns||(Ns={}));var js=i(8287).Buffer;function Cs(t){return Cs="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},Cs(t)}function Fs(){Fs=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(L([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Cs(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=A(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function A(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,A(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function x(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(x,this),this.reset(!0)}function L(e){if(e||""===e){var r=e[a];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(Cs(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=L,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:L(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Ms(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ds(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ms(o,n,i,a,s,"next",t)}function s(t){Ms(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Hs(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,Vs(n.key),n)}}function Ks(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ks=function(){return!!t})()}function Ws(t){return Ws=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Ws(t)}function Gs(t,e){return Gs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Gs(t,e)}function Vs(t){var e=function(t){if("object"!=Cs(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Cs(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Cs(e)?e:e+""}var zs=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Vs(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=Ws(e),function(t,e){if(e&&("object"==Cs(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,Ks()?Reflect.construct(e,r||[],Ws(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("UnisatSigner can only be used in a browser environment");return e}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&&Gs(t,e)}(t,Us),function(t,e){return e&&Hs(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"unisat",get:function(){var t=window.opnet||window.unisat;if(!t)throw new Error("OPWallet extension not found");return t}},{key:"init",value:(i=Ds(Fs().mark((function t(){var e,r;return Fs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isInitialized){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.unisat.getNetwork();case 4:e=t.sent,t.t0=e,t.next=t.t0===Rs.mainnet?8:t.t0===Rs.testnet?10:t.t0===Rs.regtest?12:14;break;case 8:return this._network=d.o8.bitcoin,t.abrupt("break",15);case 10:return this._network=d.o8.testnet,t.abrupt("break",15);case 12:return this._network=d.o8.regtest,t.abrupt("break",15);case 14:throw new Error("Invalid network: ".concat(e));case 15:return t.next=17,this.unisat.getPublicKey();case 17:r=t.sent,this._publicKey=js.from(r,"hex"),this._p2wpkh=R.getP2WPKHAddress(this,this.network),this._p2tr=R.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 23:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(n=Ds(Fs().mark((function t(e,r,n){var i;return Fs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTweaked(e,r,n,!1);case 2:i=t.sent,this.combine(e,i,r);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"signInput",value:(r=Ds(Fs().mark((function t(e,r,n){var i;return Fs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTweaked(e,r,n,!0);case 2:i=t.sent,this.combine(e,i,r);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return r.apply(this,arguments)})},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signTweaked",value:(e=Ds(Fs().mark((function t(e,r,n){var i,o,a,s,u=arguments;return Fs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=u.length>3&&void 0!==u[3]&&u[3],o={autoFinalized:!1,toSignInputs:[{index:r,publicKey:this.publicKey.toString("hex"),sighashTypes:n,disableTweakSigner:i}]},a=e.toHex(),t.next=5,this.unisat.signPsbt(a,o);case 5:return s=t.sent,t.abrupt("return",d.iL.fromHex(s));case 7:case"end":return t.stop()}}),t,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find((function(t){return t.pubkey.equals(e[n].pubkey)}))||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i}(),qs=o.iy,Xs=o.z2,$s=o.G7,Ys=o.GF,Zs=o.nU,Js=o.wf,Qs=o.gf,tu=o.P8,eu=o.vg,ru=o.nr,nu=o.ry,iu=o.z4,ou=o.qT,au=o.kd,su=o.eA,uu=o.no,cu=o.o4,fu=o.YV,lu=o.O5,hu=o.cC,pu=o.Wj,du=o.Bc,yu=o.LL,bu=o.gK,gu=o.PE,wu=o.Go,vu=o.IB,mu=o.rl,_u=o.Y_,Eu=o.yo,Su=o.Ko,ku=o.pe,Tu=o.ho,Ou=o._l,Au=o.QS,xu=o.Bm,Pu=o.W_,Iu=o.Hu,Lu=o.Mg,Ru=o.$v,Bu=o.mt,Nu=o.lJ,Uu=o.ih,ju=o.aw,Cu=o.tm,Fu=o.Qc,Mu=o.dF,Du=o.Wb,Hu=o.D_,Ku=o.aS,Wu=o._3,Gu=o.A9,Vu=o.V$,zu=o.xc,qu=o.S2,Xu=o.qn,$u=o.Gc,Yu=o.zM,Zu=o.c,Ju=o.uW,Qu=o.FV,tc=o.UB,ec=o.jz,rc=o.hL,nc=o.$7,ic=o.rE,oc=o.rR;export{qs as AddressGenerator,Xs as AddressVerificator,$s as BitcoinUtils,Ys as CalldataGenerator,Zs as ChainId,Js as Compressor,Qs as Consensus,tu as ContractBaseMetadata,eu as CustomGenerator,ru as CustomKeypair,nu as CustomScriptTransaction,iu as DeploymentGenerator,ou as DeploymentTransaction,au as EcKeyPair,su as FACTORY_ADDRESS_FRACTAL,uu as FACTORY_ADDRESS_REGTEST,cu as FACTORY_ADDRESS_TESTNET,fu as FeatureOpCodes,lu as Features,hu as FundingTransaction,pu as Generator,du as InteractionTransaction,yu as MOTO_ADDRESS_FRACTAL,bu as MOTO_ADDRESS_REGTEST,gu as MOTO_ADDRESS_TESTNET,wu as MessageType,vu as MultiSignGenerator,mu as MultiSignTransaction,_u as OPNetConsensusConfig,Eu as OPNetLimitedProvider,Su as OPNetMetadata,ku as OPNetNetwork,Tu as OPNetTokenAddressManager,Ou as P2TR_MS,Au as POOL_ADDRESS_FRACTAL,xu as POOL_ADDRESS_REGTEST,Pu as POOL_ADDRESS_TESTNET,Iu as PSBTTypes,Lu as PsbtTransaction,Ru as ROUTER_ADDRESS_FRACTAL,Bu as ROUTER_ADDRESS_REGTEST,Nu as ROUTER_ADDRESS_TESTNET,Uu as RoswellConsensus,ju as SharedInteractionTransaction,Cu as TapscriptVerificator,Fu as TransactionBuilder,Mu as TransactionFactory,Du as TransactionSequence,Hu as TransactionType,Ku as TweakedSigner,Wu as TweakedTransaction,Gu as UnisatChainType,Vu as UnisatNetwork,zu as UnisatSigner,qu as UnwrapGeneration,Xu as UnwrapTransaction,$u as WBTC_ADDRESS_FRACTAL,Yu as WBTC_ADDRESS_REGTEST,Zu as WBTC_ADDRESS_TESTNET,Ju as Wallet,Qu as WrapTransaction,tc as WrappedGeneration,ec as currentConsensus,rc as currentConsensusConfig,nc as opnet,ic as version,oc as wBTC};
|
|
2
|
+
var t,e,r={3513:(t,e,r)=>{var n=r(8287).Buffer,i=r(9598),o=r(9615),a=r(2623);function s(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=s(i);const c="Expected Private",f="Expected Point",l="Expected Tweak",h="Expected Signature",p="Expected Extra Data (32 bytes)",d="Expected Scalar";u.utils.hmacSha256Sync=(t,...e)=>o.hmac(a.sha256,t,u.utils.concatBytes(...e)),u.utils.sha256Sync=(...t)=>a.sha256(u.utils.concatBytes(...t));const y=u.utils._normalizePrivateKey,b=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]),g=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 v(t,e){for(let r=0;r<32;++r)if(t[r]!==e[r])return t[r]<e[r]?-1:1;return 0}function m(t){return 0===v(t,g)}function _(t){return t instanceof Uint8Array&&32===t.length&&!(v(t,b)>=0)}function E(t){return t instanceof Uint8Array&&64===t.length&&v(t.subarray(0,32),b)<0&&v(t.subarray(32,64),b)<0}function S(t){return t instanceof Uint8Array&&32===t.length}function k(t){return void 0===t||t instanceof Uint8Array&&32===t.length}function T(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function O(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=T(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");e=function(t){return T(u.utils.bytesToHex(t))}(t)}if(e<0)throw new Error("Expected private scalar >= 0");return e}const x=(t,e,r)=>{const n=u.Point.fromHex(t),i=O(e),o=u.Point.BASE.multiplyAndAddUnsafe(n,i,BigInt(1));if(!o)throw new Error("Tweaked point at infinity");return o.toRawBytes(r)};function A(t,e){return void 0===t?void 0===e||L(e):!!t}function P(t){try{return t()}catch(t){return null}}function I(t,e){if(32===t.length!==e)return!1;try{return!!u.Point.fromHex(t)}catch(t){return!1}}function R(t){return I(t,!1)}function L(t){return I(t,!1)&&33===t.length}function B(t){return u.utils.isValidPrivateKey(t)}function U(t){return I(t,!0)}function N(t){if(!R(t))throw new Error(f);return t.slice(1,33)}function j(t,e){if(!B(t))throw new Error(c);return P((()=>u.getPublicKey(t,A(e))))}e.isPoint=R,e.isPointCompressed=L,e.isPrivate=B,e.isXOnlyPoint=U,e.pointAdd=function(t,e,r){if(!R(t)||!R(e))throw new Error(f);return P((()=>{const n=u.Point.fromHex(t),i=u.Point.fromHex(e);return n.equals(i.negate())?null:n.add(i).toRawBytes(A(r,t))}))},e.pointAddScalar=function(t,e,r){if(!R(t))throw new Error(f);if(!_(e))throw new Error(l);return P((()=>x(t,e,A(r,t))))},e.pointCompress=function(t,e){if(!R(t))throw new Error(f);return u.Point.fromHex(t).toRawBytes(A(e,t))},e.pointFromScalar=j,e.pointMultiply=function(t,e,r){if(!R(t))throw new Error(f);if(!_(e))throw new Error(l);return P((()=>((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,A(r,t))))},e.privateAdd=function(t,e){if(!1===B(t))throw new Error(c);if(!1===_(e))throw new Error(l);return P((()=>((t,e)=>{const r=y(t),n=O(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===B(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===B(t))throw new Error(c);if(!1===_(e))throw new Error(l);return P((()=>((t,e)=>{const r=y(t),n=O(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(!E(e)||!function(t){return!(m(t.subarray(0,32))||m(t.subarray(32,64)))}(e))throw new Error(h);if(2&r&&!function(t){return t instanceof Uint8Array&&64===t.length&&v(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,A(n))},e.sign=function(t,e,r){if(!B(e))throw new Error(c);if(!S(t))throw new Error(d);if(!k(r))throw new Error(p);return u.signSync(t,e,{der:!1,extraEntropy:r})},e.signRecoverable=function(t,e,r){if(!B(e))throw new Error(c);if(!S(t))throw new Error(d);if(!k(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(!B(e))throw new Error(c);if(!S(t))throw new Error(d);if(!k(r))throw new Error(p);return u.schnorr.signSync(t,e,r)},e.verify=function(t,e,r,n){if(!R(e))throw new Error(f);if(!E(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(f);if(!E(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(f);if(!_(e))throw new Error(l);return P((()=>{const r=x(t,e,!0);return{parity:r[0]%2==1?1:0,xOnlyPubkey:r.slice(1)}}))},e.xOnlyPointFromPoint=N,e.xOnlyPointFromScalar=function(t){if(!B(t))throw new Error(c);return N(j(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 a(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 s(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.isBytes=i,e.number=r,e.bool=n,e.bytes=o,e.hash=a,e.exists=s,e.output=u;const c={number:r,bool:n,bytes:o,hash:a,exists:s,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,a=(t=(0,i.toBytes)(t)).length;for(let n=0;n<a;){const s=Math.min(o-this.pos,a-n);if(s!==o)r.set(t.subarray(n,n+s),this.pos),this.pos+=s,n+=s,this.pos===o&&(this.process(e,0),this.pos=0);else{const e=(0,i.createView)(t);for(;o<=a-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:a}=this;let{pos:s}=this;e[s++]=128,this.buffer.subarray(s).fill(0),this.padOffset>o-s&&(this.process(r,0),s=0);for(let t=s;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),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,o-8,BigInt(8*this.length),a),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 f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<f;t++)u.setUint32(4*t,l[t],a)}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:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}e.HashMD=o},2318:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.add5L=e.add5H=e.add4H=e.add4L=e.add3H=e.add3L=e.rotlBL=e.rotlBH=e.rotlSL=e.rotlSH=e.rotr32L=e.rotr32H=e.rotrBL=e.rotrBH=e.rotrSL=e.rotrSH=e.shrSL=e.shrSH=e.toBig=void 0,e.fromBig=i,e.split=o,e.add=v;const r=BigInt(2**32-1),n=BigInt(32);function i(t,e=!1){return e?{h:Number(t&r),l:Number(t>>n&r)}:{h:0|Number(t>>n&r),l:0|Number(t&r)}}function o(t,e=!1){let r=new Uint32Array(t.length),n=new Uint32Array(t.length);for(let o=0;o<t.length;o++){const{h:a,l:s}=i(t[o],e);[r[o],n[o]]=[a,s]}return[r,n]}const a=(t,e)=>BigInt(t>>>0)<<n|BigInt(e>>>0);e.toBig=a;const s=(t,e,r)=>t>>>r;e.shrSH=s;const u=(t,e,r)=>t<<32-r|e>>>r;e.shrSL=u;const c=(t,e,r)=>t>>>r|e<<32-r;e.rotrSH=c;const f=(t,e,r)=>t<<32-r|e>>>r;e.rotrSL=f;const l=(t,e,r)=>t<<64-r|e>>>r-32;e.rotrBH=l;const h=(t,e,r)=>t>>>r-32|e<<64-r;e.rotrBL=h;const p=(t,e)=>e;e.rotr32H=p;const d=(t,e)=>t;e.rotr32L=d;const y=(t,e,r)=>t<<r|e>>>32-r;e.rotlSH=y;const b=(t,e,r)=>e<<r|t>>>32-r;e.rotlSL=b;const g=(t,e,r)=>e<<r-32|t>>>64-r;e.rotlBH=g;const w=(t,e,r)=>t<<r-32|e>>>64-r;function v(t,e,r,n){const i=(e>>>0)+(n>>>0);return{h:t+r+(i/2**32|0)|0,l:0|i}}e.rotlBL=w;const m=(t,e,r)=>(t>>>0)+(e>>>0)+(r>>>0);e.add3L=m;const _=(t,e,r,n)=>e+r+n+(t/2**32|0)|0;e.add3H=_;const E=(t,e,r,n)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0);e.add4L=E;const S=(t,e,r,n,i)=>e+r+n+i+(t/2**32|0)|0;e.add4H=S;const k=(t,e,r,n,i)=>(t>>>0)+(e>>>0)+(r>>>0)+(n>>>0)+(i>>>0);e.add5L=k;const T=(t,e,r,n,i,o)=>e+r+n+i+o+(t/2**32|0)|0;e.add5H=T;const O={fromBig:i,split:o,toBig:a,shrSH:s,shrSL:u,rotrSH:c,rotrSL:f,rotrBH:l,rotrBL:h,rotr32H:p,rotr32L:d,rotlSH:y,rotlSL:b,rotlBH:g,rotlBL:w,add:v,add3L:m,add3H:_,add4L:E,add4H:S,add5H:T,add5L:k};e.default=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,a=new Uint8Array(o);a.set(r.length>o?t.create().update(r).digest():r);for(let t=0;t<a.length;t++)a[t]^=54;this.iHash.update(a),this.oHash=t.create();for(let t=0;t<a.length;t++)a[t]^=106;this.oHash.update(a),a.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:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,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]),a=new Uint8Array(new Array(16).fill(0).map(((t,e)=>e))),s=a.map((t=>(9*t+5)%16));let u=[a],c=[s];for(let t=0;t<4;t++)for(let e of[u,c])e.push(e[t].map((t=>o[t])));const f=[[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=u.map(((t,e)=>t.map((t=>f[e][t])))),h=c.map(((t,e)=>t.map((t=>f[e][t])))),p=new Uint32Array([0,1518500249,1859775393,2400959708,2840853838]),d=new Uint32Array([1352829926,1548603684,1836072691,2053994217,0]);function y(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 b=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)b[r]=t.getUint32(e,!0);let r=0|this.h0,n=r,o=0|this.h1,a=o,s=0|this.h2,f=s,g=0|this.h3,w=g,v=0|this.h4,m=v;for(let t=0;t<5;t++){const e=4-t,_=p[t],E=d[t],S=u[t],k=c[t],T=l[t],O=h[t];for(let e=0;e<16;e++){const n=(0,i.rotl)(r+y(t,o,s,g)+b[S[e]]+_,T[e])+v|0;r=v,v=g,g=0|(0,i.rotl)(s,10),s=o,o=n}for(let t=0;t<16;t++){const r=(0,i.rotl)(n+y(e,a,f,w)+b[k[t]]+E,O[t])+m|0;n=m,m=w,w=0|(0,i.rotl)(f,10),f=a,a=r}}this.set(this.h1+s+w|0,this.h2+g+m|0,this.h3+v+n|0,this.h4+r+a|0,this.h0+o+f|0)}roundClean(){b.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=e.SHA1=void 0;const n=r(7202),i=r(9175),o=new Uint32Array([1732584193,4023233417,2562383102,271733878,3285377520]),a=new Uint32Array(80);class s 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)a[r]=t.getUint32(e,!1);for(let t=16;t<80;t++)a[t]=(0,i.rotl)(a[t-3]^a[t-8]^a[t-14]^a[t-16],1);let{A:r,B:o,C:s,D:u,E:c}=this;for(let t=0;t<80;t++){let e,f;t<20?(e=(0,n.Chi)(o,s,u),f=1518500249):t<40?(e=o^s^u,f=1859775393):t<60?(e=(0,n.Maj)(o,s,u),f=2400959708):(e=o^s^u,f=3395469782);const l=(0,i.rotl)(r,5)+e+c+f+a[t]|0;c=u,u=s,s=(0,i.rotl)(o,30),o=r,r=l}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,u=u+this.D|0,c=c+this.E|0,this.set(r,o,s,u,c)}roundClean(){a.fill(0)}destroy(){this.set(0,0,0,0,0),this.buffer.fill(0)}}e.SHA1=s,e.sha1=(0,i.wrapConstructor)((()=>new s))},2623:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha224=e.sha256=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]),a=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),s=new Uint32Array(64);class u extends n.HashMD{constructor(){super(64,32,8,!1),this.A=0|a[0],this.B=0|a[1],this.C=0|a[2],this.D=0|a[3],this.E=0|a[4],this.F=0|a[5],this.G=0|a[6],this.H=0|a[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){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|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)s[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=s[t-15],r=s[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;s[t]=o+s[t-7]+n+s[t-16]|0}let{A:r,B:a,C:u,D:c,E:f,F:l,G:h,H:p}=this;for(let t=0;t<64;t++){const e=p+((0,i.rotr)(f,6)^(0,i.rotr)(f,11)^(0,i.rotr)(f,25))+(0,n.Chi)(f,l,h)+o[t]+s[t]|0,d=((0,i.rotr)(r,2)^(0,i.rotr)(r,13)^(0,i.rotr)(r,22))+(0,n.Maj)(r,a,u)|0;p=h,h=l,l=f,f=c+e|0,c=u,u=a,a=r,r=e+d|0}r=r+this.A|0,a=a+this.B|0,u=u+this.C|0,c=c+this.D|0,f=f+this.E|0,l=l+this.F|0,h=h+this.G|0,p=p+this.H|0,this.set(r,a,u,c,f,l,h,p)}roundClean(){s.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}e.SHA256=u;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))},102:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.sha384=e.sha512_256=e.sha512_224=e.sha512=e.SHA384=e.SHA512_256=e.SHA512_224=e.SHA512=void 0;const n=r(7202),i=r(2318),o=r(9175),[a,s]=(()=>i.default.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)))))(),u=new Uint32Array(80),c=new Uint32Array(80);class f extends n.HashMD{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:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,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|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,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)u[r]=t.getUint32(e),c[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|u[t-15],r=0|c[t-15],n=i.default.rotrSH(e,r,1)^i.default.rotrSH(e,r,8)^i.default.shrSH(e,r,7),o=i.default.rotrSL(e,r,1)^i.default.rotrSL(e,r,8)^i.default.shrSL(e,r,7),a=0|u[t-2],s=0|c[t-2],f=i.default.rotrSH(a,s,19)^i.default.rotrBH(a,s,61)^i.default.shrSH(a,s,6),l=i.default.rotrSL(a,s,19)^i.default.rotrBL(a,s,61)^i.default.shrSL(a,s,6),h=i.default.add4L(o,l,c[t-7],c[t-16]),p=i.default.add4H(h,n,f,u[t-7],u[t-16]);u[t]=0|p,c[t]=0|h}let{Ah:r,Al:n,Bh:o,Bl:f,Ch:l,Cl:h,Dh:p,Dl:d,Eh:y,El:b,Fh:g,Fl:w,Gh:v,Gl:m,Hh:_,Hl:E}=this;for(let t=0;t<80;t++){const e=i.default.rotrSH(y,b,14)^i.default.rotrSH(y,b,18)^i.default.rotrBH(y,b,41),S=i.default.rotrSL(y,b,14)^i.default.rotrSL(y,b,18)^i.default.rotrBL(y,b,41),k=y&g^~y&v,T=b&w^~b&m,O=i.default.add5L(E,S,T,s[t],c[t]),x=i.default.add5H(O,_,e,k,a[t],u[t]),A=0|O,P=i.default.rotrSH(r,n,28)^i.default.rotrBH(r,n,34)^i.default.rotrBH(r,n,39),I=i.default.rotrSL(r,n,28)^i.default.rotrBL(r,n,34)^i.default.rotrBL(r,n,39),R=r&o^r&l^o&l,L=n&f^n&h^f&h;_=0|v,E=0|m,v=0|g,m=0|w,g=0|y,w=0|b,({h:y,l:b}=i.default.add(0|p,0|d,0|x,0|A)),p=0|l,d=0|h,l=0|o,h=0|f,o=0|r,f=0|n;const B=i.default.add3L(A,I,L);r=i.default.add3H(B,x,P,R),n=0|B}({h:r,l:n}=i.default.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:o,l:f}=i.default.add(0|this.Bh,0|this.Bl,0|o,0|f)),({h:l,l:h}=i.default.add(0|this.Ch,0|this.Cl,0|l,0|h)),({h:p,l:d}=i.default.add(0|this.Dh,0|this.Dl,0|p,0|d)),({h:y,l:b}=i.default.add(0|this.Eh,0|this.El,0|y,0|b)),({h:g,l:w}=i.default.add(0|this.Fh,0|this.Fl,0|g,0|w)),({h:v,l:m}=i.default.add(0|this.Gh,0|this.Gl,0|v,0|m)),({h:_,l:E}=i.default.add(0|this.Hh,0|this.Hl,0|_,0|E)),this.set(r,n,o,f,l,h,p,d,y,b,g,w,v,m,_,E)}roundClean(){u.fill(0),c.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)}}e.SHA512=f;class l extends f{constructor(){super(),this.Ah=-1942145080,this.Al=424955298,this.Bh=1944164710,this.Bl=-1982016298,this.Ch=502970286,this.Cl=855612546,this.Dh=1738396948,this.Dl=1479516111,this.Eh=258812777,this.El=2077511080,this.Fh=2011393907,this.Fl=79989058,this.Gh=1067287976,this.Gl=1780299464,this.Hh=286451373,this.Hl=-1848208735,this.outputLen=28}}e.SHA512_224=l;class h extends f{constructor(){super(),this.Ah=573645204,this.Al=-64227540,this.Bh=-1621794909,this.Bl=-934517566,this.Ch=596883563,this.Cl=1867755857,this.Dh=-1774684391,this.Dl=1497426621,this.Eh=-1775747358,this.El=-1467023389,this.Fh=-1101128155,this.Fl=1401305490,this.Gh=721525244,this.Gl=746961066,this.Hh=246885852,this.Hl=-2117784414,this.outputLen=32}}e.SHA512_256=h;class p extends f{constructor(){super(),this.Ah=-876896931,this.Al=-1056596264,this.Bh=1654270250,this.Bl=914150663,this.Ch=-1856437926,this.Cl=812702999,this.Dh=355462360,this.Dl=-150054599,this.Eh=1731405415,this.El=-4191439,this.Fh=-1900787065,this.Fl=1750603025,this.Gh=-619958771,this.Gl=1694076839,this.Hh=1203062813,this.Hl=-1090891868,this.outputLen=48}}e.SHA384=p,e.sha512=(0,o.wrapConstructor)((()=>new f)),e.sha512_224=(0,o.wrapConstructor)((()=>new l)),e.sha512_256=(0,o.wrapConstructor)((()=>new h)),e.sha384=(0,o.wrapConstructor)((()=>new p))},9175:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.Hash=e.nextTick=e.byteSwapIfBE=e.byteSwap=e.isLE=e.rotl=e.rotr=e.createView=e.u32=e.u8=void 0,e.isBytes=function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name},e.byteSwap32=function(t){for(let r=0;r<t.length;r++)t[r]=(0,e.byteSwap)(t[r])},e.bytesToHex=function(t){(0,i.bytes)(t);let e="";for(let r=0;r<t.length;r++)e+=o[t[r]];return e},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=s(t.charCodeAt(i)),o=s(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.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=u,e.toBytes=c,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.checkOpts=function(t,e){if(void 0!==e&&"[object Object]"!==f.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(c(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(c(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(c(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));if(n.crypto&&"function"==typeof n.crypto.randomBytes)return n.crypto.randomBytes(t);throw new Error("crypto.getRandomValues must be defined")};const n=r(5145),i=r(7557);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);const o=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0"))),a={_0:48,_9:57,_A:65,_F:70,_a:97,_f:102};function s(t){return t>=a._0&&t<=a._9?t-a._0:t>=a._A&&t<=a._F?t-(a._A-10):t>=a._a&&t<=a._f?t-(a._a-10):void 0}function u(t){if("string"!=typeof t)throw new Error("utf8ToBytes expected string, got "+typeof t);return new Uint8Array((new TextEncoder).encode(t))}function c(t){return"string"==typeof t&&(t=u(t)),(0,i.bytes)(t),t}e.nextTick=async()=>{},e.Hash=class{clone(){return this._cloneInto()}};const f={}.toString},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),a=BigInt(2),s=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 f=(t,e)=>(t+e/a)/e,l={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=c,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-o*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),a=r,s=BigInt("0x100000000000000000000000000000000"),u=f(a*t,e),l=f(-n*t,e);let h=N(t-u*r-l*i,e),p=N(-u*n-l*a,e);const d=h>s,y=p>s;if(d&&(h=e-h),y&&(p=e-p),h>s||p>s)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:d,k1:h,k2neg:y,k2:p}}};function h(t){const{a:e,b:r}=c,n=N(t*t),i=N(n*t);return N(i+e*t+r)}const p=c.a===i;class d extends Error{constructor(t){super(t)}}function y(t){if(!(t instanceof b))throw new TypeError("JacobianPoint expected")}class b{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof v))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(v.ZERO)?b.ZERO:new b(t.x,t.y,o)}static toAffineBatch(t){const e=function(t,e=c.P){const r=new Array(t.length),n=t.reduce(((t,n,o)=>n===i?t:(r[o]=t,N(t*n,e))),o),a=C(n,e);return t.reduceRight(((t,n,o)=>n===i?t:(r[o]=N(t*r[o],e),N(t*n,e))),a),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return b.toAffineBatch(t).map(b.fromAffine)}equals(t){y(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,s=N(n*n),u=N(a*a),c=N(e*u),f=N(i*s),l=N(N(r*a)*u),h=N(N(o*n)*s);return c===f&&l===h}negate(){return new b(this.x,N(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=N(t*t),i=N(e*e),o=N(i*i),c=t+i,f=N(a*(N(c*c)-n-o)),l=N(s*n),h=N(l*l),p=N(h-a*f),d=N(l*(f-p)-u*o),y=N(a*e*r);return new b(p,d,y)}add(t){y(t);const{x:e,y:r,z:n}=this,{x:o,y:s,z:u}=t;if(o===i||s===i)return this;if(e===i||r===i)return t;const c=N(n*n),f=N(u*u),l=N(e*f),h=N(o*c),p=N(N(r*u)*f),d=N(N(s*n)*c),g=N(h-l),w=N(d-p);if(g===i)return w===i?this.double():b.ZERO;const v=N(g*g),m=N(g*v),_=N(l*v),E=N(w*w-m-a*_),S=N(w*(_-E)-p*m),k=N(n*u*g);return new b(E,S,k)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=b.ZERO;if("bigint"==typeof t&&t===i)return e;let r=U(t);if(r===o)return this;if(!p){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:a,k2neg:s,k2:u}=l.splitScalar(r),c=e,f=e,h=this;for(;a>i||u>i;)a&o&&(c=c.add(h)),u&o&&(f=f.add(h)),h=h.double(),a>>=o,u>>=o;return n&&(c=c.negate()),s&&(f=f.negate()),f=new b(N(f.x*l.beta),f.y,f.z),c.add(f)}precomputeWindow(t){const e=p?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(b.BASE)&&(e=v.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&&w.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=b.normalizeZ(n),w.set(e,n)));let i=b.ZERO,a=b.BASE;const s=1+(p?128/r:256/r),u=2**(r-1),c=BigInt(2**r-1),f=2**r,l=BigInt(r);for(let e=0;e<s;e++){const r=e*u;let s=Number(t&c);t>>=l,s>u&&(s-=f,t+=o);const h=r,p=r+Math.abs(s)-1,d=e%2!=0,y=s<0;0===s?a=a.add(g(d,n[h])):i=i.add(g(y,n[p]))}return{p:i,f:a}}multiply(t,e){let r,n,i=U(t);if(p){const{k1neg:t,k1:o,k2neg:a,k2:s}=l.splitScalar(i);let{p:u,f:c}=this.wNAF(o,e),{p:f,f:h}=this.wNAF(s,e);u=g(t,u),f=g(a,f),f=new b(N(f.x*l.beta),f.y,f.z),r=u.add(f),n=c.add(h)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return b.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(b.ZERO);null==t&&(t=i?u:C(n));const a=t,s=N(a*a),c=N(s*a),f=N(e*s),l=N(r*c),h=N(n*a);if(i)return v.ZERO;if(h!==o)throw new Error("invZ was invalid");return new v(f,l)}}function g(t,e){const r=e.negate();return t?r:e}b.BASE=new b(c.Gx,c.Gy,o),b.ZERO=new b(i,o,i);const w=new WeakMap;class v{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,w.delete(this)}hasEvenY(){return this.y%a===i}static fromCompressedHex(t){const e=32===t.length,r=L(e?t:t.subarray(1));if(!W(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),f=BigInt(88),l=t*t*t%e,h=l*l*t%e,p=j(h,s)*h%e,d=j(p,s)*h%e,y=j(d,a)*l%e,b=j(y,n)*y%e,g=j(b,i)*b%e,w=j(g,u)*g%e,v=j(w,f)*w%e,m=j(v,u)*g%e,_=j(m,s)*h%e,E=j(_,o)*b%e,S=j(E,r)*l%e,k=j(S,a);if(k*k%e!==t)throw new Error("Cannot find square root");return k}(h(r));const i=(n&o)===o;e?i&&(n=N(-n)):!(1&~t[0])!==i&&(n=N(-n));const u=new v(r,n);return u.assertValidity(),u}static fromUncompressedHex(t){const e=L(t.subarray(1,33)),r=L(t.subarray(33,65)),n=new v(e,r);return n.assertValidity(),n}static fromHex(t){const e=B(t),r=e.length,n=e[0];if(32===r)return this.fromCompressedHex(e);if(33===r&&(2===n||3===n))return this.fromCompressedHex(e);if(65===r&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return v.BASE.multiply(V(t))}static fromSignature(t,e,r){const{r:n,s:i}=q(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=F(B(t)),{n:a}=c,s=2===r||3===r?n+a:n,u=C(s,a),f=N(-o*u,a),l=N(i*u,a),h=1&r?"03":"02",p=v.fromHex(h+x(s)),d=v.BASE.multiplyAndAddUnsafe(p,f,l);if(!d)throw new Error("Cannot recover signature: point at infinify");return d.assertValidity(),d}toRawBytes(t=!1){return R(this.toHex(t))}toHex(t=!1){const e=x(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${x(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(!W(e)||!W(r))throw new Error(t);const n=N(r*r);if(N(n-h(e))!==i)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new v(this.x,N(-this.y))}double(){return b.fromAffine(this).double().toAffine()}add(t){return b.fromAffine(this).add(b.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return b.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=b.fromAffine(this),a=e===i||e===o||this!==v.BASE?n.multiplyUnsafe(e):n.multiply(e),s=b.fromAffine(t).multiplyUnsafe(r),u=a.add(s);return u.equals(b.ZERO)?void 0:u.toAffine()}}function m(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function _(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${T(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=v,v.BASE=new v(c.Gx,c.Gy),v.ZERO=new v(i,i);class E{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?T(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new E(I(n.slice(0,64)),I(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: ${T(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=_(t.subarray(2)),{data:n,left:i}=_(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${T(i)}`);return{r:e,s:n}}(e?t:R(t));return new E(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!K(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!K(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 E(this.r,N(-this.s,c.n)):this}toDERRawBytes(){return R(this.toDERHex())}toDERHex(){const t=m(P(this.s)),e=m(P(this.r)),r=t.length/2,n=e.length/2,i=P(r),o=P(n);return`30${P(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return R(this.toCompactHex())}toCompactHex(){return x(this.r)+x(this.s)}}function S(...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=E;const k=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function T(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=k[t[r]];return e}const O=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function x(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(i<=t&&t<O))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function A(t){const e=R(x(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function P(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function I(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function R(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 I(T(t))}function B(t){return t instanceof Uint8Array?Uint8Array.from(t):R(t)}function U(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&K(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function N(t,e=c.P){const r=t%e;return r>=i?r:e+r}function j(t,e){const{P:r}=c;let n=t;for(;e-- >i;)n*=n,n%=r;return n}function C(t,e=c.P){if(t===i||e<=i)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=N(t,e),n=e,a=i,s=o,u=o,f=i;for(;r!==i;){const t=n/r,e=n%r,i=a-u*t,o=s-f*t;n=r,r=e,a=u,s=f,u=i,f=o}if(n!==o)throw new Error("invert: does not exist");return N(a,e)}function F(t,e=!1){const r=function(t){const e=8*t.length-256,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 M,D;class H{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 D(this.k,...t)}checkSync(){if("function"!=typeof D)throw new d("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 S(...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 S(...e)}}function K(t){return i<t&&t<c.n}function W(t){return i<t&&t<c.P}function G(t,e,r,n=!0){const{n:a}=c,s=F(t,!0);if(!K(s))return;const u=C(s,a),f=v.BASE.multiply(s),l=N(f.x,a);if(l===i)return;const h=N(u*N(e+r*l,a),a);if(h===i)return;let p=new E(l,h),d=(f.x===p.r?0:2)|Number(f.y&o);return n&&p.hasHighS()&&(p=p.normalizeS(),d^=1),{sig:p,recovery:d}}function V(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 key");e=I(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==t.length)throw new Error("Expected 32 bytes of private key");e=L(t)}if(!K(e))throw new Error("Expected private key: 0 < key < n");return e}function z(t){return t instanceof v?(t.assertValidity(),t):v.fromHex(t)}function q(t){if(t instanceof E)return t.assertValidity(),t;try{return E.fromDER(t)}catch(e){return E.fromCompact(t)}}function X(t){const e=t instanceof Uint8Array,r="string"==typeof t,n=(e||r)&&t.length;return e?33===n||65===n:r?66===n||130===n:t instanceof v}function $(t){return L(t.length>32?t.slice(0,32):t)}function Y(t){const e=$(t),r=N(e,c.n);return Z(r<i?e:r)}function Z(t){return A(t)}function J(t,r,n){if(null==t)throw new Error(`sign: expected valid message hash, not "${t}"`);const i=B(t),o=V(r),a=[Z(o),Y(i)];if(null!=n){!0===n&&(n=e.utils.randomBytes(32));const t=B(n);if(32!==t.length)throw new Error("sign: Expected 32 bytes of extra data");a.push(t)}return{seed:S(...a),m:$(i),d:o}}function Q(t,e){const{sig:r,recovery:n}=t,{der:i,recovered:o}=Object.assign({canonical:!0,der:!0},e),a=i?r.toDERRawBytes():r.toCompactRawBytes();return o?[a,n]:a}e.getPublicKey=function(t,e=!1){return v.fromPrivateKey(t).toRawBytes(e)},e.recoverPublicKey=function(t,e,r,n=!1){return v.fromSignature(t,e,r).toRawBytes(n)},e.getSharedSecret=function(t,e,r=!1){if(X(t))throw new TypeError("getSharedSecret: first arg must be private key");if(!X(e))throw new TypeError("getSharedSecret: second arg must be public key");const n=z(e);return n.assertValidity(),n.multiply(V(t)).toRawBytes(r)},e.sign=async function(t,e,r={}){const{seed:n,m:i,d:o}=J(t,e,r.extraEntropy),a=new H(32,32);let s;for(await a.reseed(n);!(s=G(await a.generate(),i,o,r.canonical));)await a.reseed();return Q(s,r)},e.signSync=function(t,e,r={}){const{seed:n,m:i,d:o}=J(t,e,r.extraEntropy),a=new H(32,32);let s;for(a.reseedSync(n);!(s=G(a.generateSync(),i,o,r.canonical));)a.reseedSync();return Q(s,r)};const tt={strict:!0};function et(t){return N(L(t),c.n)}e.verify=function(t,e,r,n=tt){let i;try{i=q(t),e=B(e)}catch(t){return!1}const{r:o,s:a}=i;if(n.strict&&i.hasHighS())return!1;const s=F(e);let u;try{u=z(r)}catch(t){return!1}const{n:f}=c,l=C(a,f),h=N(s*l,f),p=N(o*l,f),d=v.BASE.multiplyAndAddUnsafe(u,h,p);return!!d&&N(d.x,f)===o};class rt{constructor(t,e){this.r=t,this.s=e,this.assertValidity()}static fromHex(t){const e=B(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 rt(r,n)}assertValidity(){const{r:t,s:e}=this;if(!W(t)||!K(e))throw new Error("Invalid signature")}toHex(){return x(this.r)+x(this.s)}toRawBytes(){return R(this.toHex())}}class nt{constructor(t,r,n=e.utils.randomBytes()){if(null==t)throw new TypeError(`sign: Expected valid message, not "${t}"`);this.m=B(t);const{x:i,scalar:o}=this.getScalar(V(r));if(this.px=i,this.d=o,this.rand=B(n),32!==this.rand.length)throw new TypeError("sign: Expected 32 bytes of aux randomness")}getScalar(t){const e=v.fromPrivateKey(t),r=e.hasEvenY()?t:c.n-t;return{point:e,scalar:r,x:e.toRawX()}}initNonce(t,e){return A(t^L(e))}finalizeNonce(t){const e=N(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 rt(t.x,N(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,a=this.initNonce(r,await o(ct.aux,i)),{R:s,rx:u,k:c}=this.finalizeNonce(await o(ct.nonce,a,n,t)),f=et(await o(ct.challenge,u,n,t)),l=this.finalizeSig(s,c,f,r);return await at(l,t,n)||this.error(),l}calcSync(){const{m:t,d:r,px:n,rand:i}=this,o=e.utils.taggedHashSync,a=this.initNonce(r,o(ct.aux,i)),{R:s,rx:u,k:c}=this.finalizeNonce(o(ct.nonce,a,n,t)),f=et(o(ct.challenge,u,n,t)),l=this.finalizeSig(s,c,f,r);return st(l,t,n)||this.error(),l}}function it(t,e,r){const n=t instanceof rt,i=n?t:rt.fromHex(t);return n&&i.assertValidity(),{...i,m:B(e),P:z(r)}}function ot(t,e,r,n){const i=v.BASE.multiplyAndAddUnsafe(e,V(r),N(-n,c.n));return!(!i||!i.hasEvenY()||i.x!==t)}async function at(t,r,n){try{const{r:i,s:o,m:a,P:s}=it(t,r,n),u=et(await e.utils.taggedHash(ct.challenge,A(i),s.toRawX(),a));return ot(i,s,o,u)}catch(t){return!1}}function st(t,r,n){try{const{r:i,s:o,m:a,P:s}=it(t,r,n),u=et(e.utils.taggedHashSync(ct.challenge,A(i),s.toRawX(),a));return ot(i,s,o,u)}catch(t){if(t instanceof d)throw t;return!1}}e.schnorr={Signature:rt,getPublicKey:function(t){return v.fromPrivateKey(t).toRawX()},sign:async function(t,e,r){return new nt(t,e,r).calc()},verify:at,signSync:function(t,e,r){return new nt(t,e,r).calcSync()},verifySync:st},v.BASE._setWindowSize(8);const ut={node:n,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},ct={challenge:"BIP0340/challenge",aux:"BIP0340/aux",nonce:"BIP0340/nonce"},ft={};e.utils={bytesToHex:T,hexToBytes:R,concatBytes:S,mod:N,invert:C,isValidPrivateKey(t){try{return V(t),!0}catch(t){return!1}},_bigintTo32Bytes:A,_normalizePrivateKey:V,hashToPrivateKey:t=>{if((t=B(t)).length<40||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return A(N(L(t),c.n-o)+o)},randomBytes:(t=32)=>{if(ut.web)return ut.web.getRandomValues(new Uint8Array(t));if(ut.node){const{randomBytes:e}=ut.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>e.utils.hashToPrivateKey(e.utils.randomBytes(40)),precompute(t=8,e=v.BASE){const r=e===v.BASE?e:new v(e.x,e.y);return r._setWindowSize(t),r.multiply(s),r},sha256:async(...t)=>{if(ut.web){const e=await ut.web.subtle.digest("SHA-256",S(...t));return new Uint8Array(e)}if(ut.node){const{createHash:e}=ut.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(ut.web){const r=await ut.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=S(...e),i=await ut.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(ut.node){const{createHmac:r}=ut.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=ft[t];if(void 0===n){const r=await e.utils.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));n=S(r,r),ft[t]=n}return e.utils.sha256(n,...r)},taggedHashSync:(t,...e)=>{if("function"!=typeof M)throw new d("sha256Sync is undefined, you need to set it");let r=ft[t];if(void 0===r){const e=M(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=S(e,e),ft[t]=r}return M(r,...e)},_JacobianPoint:b},Object.defineProperties(e.utils,{sha256Sync:{configurable:!1,get:()=>M,set(t){M||(M=t)}},hmacSha256Sync:{configurable:!1,get:()=>D,set(t){D||(D=t)}}})},3203:(t,e)=>{function r(t){if(!Number.isSafeInteger(t))throw new Error(`Wrong integer: ${t}`)}function n(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}function i(...t){const e=t=>t,r=(t,e)=>r=>t(e(r)),n=t.map((t=>t.encode)).reduceRight(r,e),i=t.map((t=>t.decode)).reduce(r,e);return{encode:n,decode:i}}function o(t){return{encode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("alphabet.encode input should be an array of numbers");return e.map((e=>{if(r(e),e<0||e>=t.length)throw new Error(`Digit index outside alphabet: ${e} (alphabet: ${t.length})`);return t[e]}))},decode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("alphabet.decode input should be array of strings");return e.map((e=>{if("string"!=typeof e)throw new Error(`alphabet.decode: not string element=${e}`);const r=t.indexOf(e);if(-1===r)throw new Error(`Unknown letter: "${e}". Allowed: ${t}`);return r}))}}}function a(t=""){if("string"!=typeof t)throw new Error("join separator should be string");return{encode:e=>{if(!Array.isArray(e)||e.length&&"string"!=typeof e[0])throw new Error("join.encode input should be array of strings");for(let t of e)if("string"!=typeof t)throw new Error(`join.encode: non-string input=${t}`);return e.join(t)},decode:e=>{if("string"!=typeof e)throw new Error("join.decode input should be string");return e.split(t)}}}function s(t,e="="){if(r(t),"string"!=typeof e)throw new Error("padding chr should be string");return{encode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.encode: non-string input=${t}`);for(;r.length*t%8;)r.push(e);return r},decode(r){if(!Array.isArray(r)||r.length&&"string"!=typeof r[0])throw new Error("padding.encode input should be array of strings");for(let t of r)if("string"!=typeof t)throw new Error(`padding.decode: non-string input=${t}`);let n=r.length;if(n*t%8)throw new Error("Invalid padding: string should have whole number of bytes");for(;n>0&&r[n-1]===e;n--)if(!((n-1)*t%8))throw new Error("Invalid padding: string has too much padding");return r.slice(0,n)}}}function u(t){if("function"!=typeof t)throw new Error("normalize fn should be function");return{encode:t=>t,decode:e=>t(e)}}function c(t,e,n){if(e<2)throw new Error(`convertRadix: wrong from=${e}, base cannot be less than 2`);if(n<2)throw new Error(`convertRadix: wrong to=${n}, base cannot be less than 2`);if(!Array.isArray(t))throw new Error("convertRadix: data should be array");if(!t.length)return[];let i=0;const o=[],a=Array.from(t);for(a.forEach((t=>{if(r(t),t<0||t>=e)throw new Error(`Wrong integer: ${t}`)}));;){let t=0,r=!0;for(let o=i;o<a.length;o++){const s=a[o],u=e*t+s;if(!Number.isSafeInteger(u)||e*t/e!==t||u-s!=e*t)throw new Error("convertRadix: carry overflow");t=u%n;const c=Math.floor(u/n);if(a[o]=c,!Number.isSafeInteger(c)||c*n+t!==u)throw new Error("convertRadix: carry overflow");r&&(c?r=!1:i=o)}if(o.push(t),r)break}for(let e=0;e<t.length-1&&0===t[e];e++)o.push(0);return o.reverse()}Object.defineProperty(e,"__esModule",{value:!0}),e.bytes=e.stringToBytes=e.str=e.bytesToString=e.hex=e.utf8=e.bech32m=e.bech32=e.base58check=e.createBase58check=e.base58xmr=e.base58xrp=e.base58flickr=e.base58=e.base64urlnopad=e.base64url=e.base64nopad=e.base64=e.base32crockford=e.base32hexnopad=e.base32hex=e.base32nopad=e.base32=e.base16=e.utils=void 0,e.assertNumber=r;const f=(t,e)=>e?f(e,t%e):t,l=(t,e)=>t+(e-f(t,e));function h(t,e,n,i){if(!Array.isArray(t))throw new Error("convertRadix2: data should be array");if(e<=0||e>32)throw new Error(`convertRadix2: wrong from=${e}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(l(e,n)>32)throw new Error(`convertRadix2: carry overflow from=${e} to=${n} carryBits=${l(e,n)}`);let o=0,a=0;const s=2**n-1,u=[];for(const i of t){if(r(i),i>=2**e)throw new Error(`convertRadix2: invalid data word=${i} from=${e}`);if(o=o<<e|i,a+e>32)throw new Error(`convertRadix2: carry overflow pos=${a} from=${e}`);for(a+=e;a>=n;a-=n)u.push((o>>a-n&s)>>>0);o&=2**a-1}if(o=o<<n-a&s,!i&&a>=e)throw new Error("Excess padding");if(!i&&o)throw new Error(`Non-zero padding: ${o}`);return i&&a>0&&u.push(o>>>0),u}function p(t){return r(t),{encode:e=>{if(!n(e))throw new Error("radix.encode input should be Uint8Array");return c(Array.from(e),256,t)},decode:e=>{if(!Array.isArray(e)||e.length&&"number"!=typeof e[0])throw new Error("radix.decode input should be array of numbers");return Uint8Array.from(c(e,t,256))}}}function d(t,e=!1){if(r(t),t<=0||t>32)throw new Error("radix2: bits should be in (0..32]");if(l(8,t)>32||l(t,8)>32)throw new Error("radix2: carry overflow");return{encode:r=>{if(!n(r))throw new Error("radix2.encode input should be Uint8Array");return h(Array.from(r),8,t,!e)},decode:r=>{if(!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("radix2.decode input should be array of numbers");return Uint8Array.from(h(r,t,8,e))}}}function y(t){if("function"!=typeof t)throw new Error("unsafeWrapper fn should be function");return function(...e){try{return t.apply(null,e)}catch(t){}}}function b(t,e){if(r(t),"function"!=typeof e)throw new Error("checksum fn should be function");return{encode(r){if(!n(r))throw new Error("checksum.encode: input should be Uint8Array");const i=e(r).slice(0,t),o=new Uint8Array(r.length+t);return o.set(r),o.set(i,r.length),o},decode(r){if(!n(r))throw new Error("checksum.decode: input should be Uint8Array");const i=r.slice(0,-t),o=e(i).slice(0,t),a=r.slice(-t);for(let e=0;e<t;e++)if(o[e]!==a[e])throw new Error("Invalid checksum");return i}}}e.utils={alphabet:o,chain:i,checksum:b,convertRadix:c,convertRadix2:h,radix:p,radix2:d,join:a,padding:s},e.base16=i(d(4),o("0123456789ABCDEF"),a("")),e.base32=i(d(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),s(5),a("")),e.base32nopad=i(d(5),o("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"),a("")),e.base32hex=i(d(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),s(5),a("")),e.base32hexnopad=i(d(5),o("0123456789ABCDEFGHIJKLMNOPQRSTUV"),a("")),e.base32crockford=i(d(5),o("0123456789ABCDEFGHJKMNPQRSTVWXYZ"),a(""),u((t=>t.toUpperCase().replace(/O/g,"0").replace(/[IL]/g,"1")))),e.base64=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),s(6),a("")),e.base64nopad=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"),a("")),e.base64url=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),s(6),a("")),e.base64urlnopad=i(d(6),o("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"),a(""));const g=t=>i(p(58),o(t),a(""));e.base58=g("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"),e.base58flickr=g("123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"),e.base58xrp=g("rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz");const w=[0,2,3,5,6,7,9,10,11];e.base58xmr={encode(t){let r="";for(let n=0;n<t.length;n+=8){const i=t.subarray(n,n+8);r+=e.base58.encode(i).padStart(w[i.length],"1")}return r},decode(t){let r=[];for(let n=0;n<t.length;n+=11){const i=t.slice(n,n+11),o=w.indexOf(i.length),a=e.base58.decode(i);for(let t=0;t<a.length-o;t++)if(0!==a[t])throw new Error("base58xmr: wrong padding");r=r.concat(Array.from(a.slice(a.length-o)))}return Uint8Array.from(r)}},e.createBase58check=t=>i(b(4,(e=>t(t(e)))),e.base58),e.base58check=e.createBase58check;const v=i(o("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),a("")),m=[996825010,642813549,513874426,1027748829,705979059];function _(t){const e=t>>25;let r=(33554431&t)<<5;for(let t=0;t<m.length;t++)1==(e>>t&1)&&(r^=m[t]);return r}function E(t,e,r=1){const n=t.length;let i=1;for(let e=0;e<n;e++){const r=t.charCodeAt(e);if(r<33||r>126)throw new Error(`Invalid prefix (${t})`);i=_(i)^r>>5}i=_(i);for(let e=0;e<n;e++)i=_(i)^31&t.charCodeAt(e);for(let t of e)i=_(i)^t;for(let t=0;t<6;t++)i=_(i);return i^=r,v.encode(h([i%2**30],30,5,!1))}function S(t){const e="bech32"===t?1:734539939,r=d(5),n=r.decode,i=r.encode,o=y(n);function a(t,r,n=90){if("string"!=typeof t)throw new Error("bech32.encode prefix should be string, not "+typeof t);if(r instanceof Uint8Array&&(r=Array.from(r)),!Array.isArray(r)||r.length&&"number"!=typeof r[0])throw new Error("bech32.encode words should be array of numbers, not "+typeof r);if(0===t.length)throw new TypeError(`Invalid prefix length ${t.length}`);const i=t.length+7+r.length;if(!1!==n&&i>n)throw new TypeError(`Length ${i} exceeds limit ${n}`);const o=t.toLowerCase(),a=E(o,r,e);return`${o}1${v.encode(r)}${a}`}function s(t,r=90){if("string"!=typeof t)throw new Error("bech32.decode input should be string, not "+typeof t);if(t.length<8||!1!==r&&t.length>r)throw new TypeError(`Wrong string length: ${t.length} (${t}). Expected (8..${r})`);const n=t.toLowerCase();if(t!==n&&t!==t.toUpperCase())throw new Error("String must be lowercase or uppercase");const i=n.lastIndexOf("1");if(0===i||-1===i)throw new Error('Letter "1" must be present between prefix and data only');const o=n.slice(0,i),a=n.slice(i+1);if(a.length<6)throw new Error("Data must be at least 6 characters long");const s=v.decode(a).slice(0,-6),u=E(o,s,e);if(!a.endsWith(u))throw new Error(`Invalid checksum in ${t}: expected "${u}"`);return{prefix:o,words:s}}return{encode:a,decode:s,encodeFromBytes:function(t,e){return a(t,i(e))},decodeToBytes:function(t){const{prefix:e,words:r}=s(t,!1);return{prefix:e,words:r,bytes:n(r)}},decodeUnsafe:y(s),fromWords:n,fromWordsUnsafe:o,toWords:i}}e.bech32=S("bech32"),e.bech32m=S("bech32m"),e.utf8={encode:t=>(new TextDecoder).decode(t),decode:t=>(new TextEncoder).encode(t)},e.hex=i(d(4),o("0123456789abcdef"),a(""),u((t=>{if("string"!=typeof t||t.length%2)throw new TypeError(`hex.decode: expected string, got ${typeof t} with length ${t.length}`);return t.toLowerCase()})));const k={utf8:e.utf8,hex:e.hex,base16:e.base16,base32:e.base32,base64:e.base64,base64url:e.base64url,base58:e.base58,base58xmr:e.base58xmr},T="Invalid encoding type. Available types: utf8, hex, base16, base32, base64, base64url, base58, base58xmr";e.bytesToString=(t,e)=>{if("string"!=typeof t||!k.hasOwnProperty(t))throw new TypeError(T);if(!n(e))throw new TypeError("bytesToString() expects Uint8Array");return k[t].encode(e)},e.str=e.bytesToString,e.stringToBytes=(t,e)=>{if(!k.hasOwnProperty(t))throw new TypeError(T);if("string"!=typeof e)throw new TypeError("stringToBytes() expects string");return k[t].decode(e)},e.bytes=e.stringToBytes},4148:(t,e,r)=>{var n=r(5606);function i(t){return i="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},i(t)}function o(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,(void 0,o=function(t){if("object"!==i(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==i(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(n.key),"symbol"===i(o)?o:String(o)),n)}var o}function a(t,e,r){return e&&o(t.prototype,e),r&&o(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}var s,u,c=r(9597).codes,f=c.ERR_AMBIGUOUS_ARGUMENT,l=c.ERR_INVALID_ARG_TYPE,h=c.ERR_INVALID_ARG_VALUE,p=c.ERR_INVALID_RETURN_VALUE,d=c.ERR_MISSING_ARGS,y=r(3918),b=r(537).inspect,g=r(537).types,w=g.isPromise,v=g.isRegExp,m=r(1514)(),_=r(9394)(),E=r(8075)("RegExp.prototype.test");function S(){var t=r(2299);s=t.isDeepEqual,u=t.isDeepStrictEqual}new Map;var k=!1,T=t.exports=P,O={};function x(t){if(t.message instanceof Error)throw t.message;throw new y(t)}function A(t,e,r,n){if(!r){var i=!1;if(0===e)i=!0,n="No value argument passed to `assert.ok()`";else if(n instanceof Error)throw n;var o=new y({actual:r,expected:!0,message:n,operator:"==",stackStartFn:t});throw o.generatedMessage=i,o}}function P(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];A.apply(void 0,[P,e.length].concat(e))}T.fail=function t(e,r,i,o,a){var s,u=arguments.length;if(0===u?s="Failed":1===u?(i=e,e=void 0):(!1===k&&(k=!0,(n.emitWarning?n.emitWarning:console.warn.bind(console))("assert.fail() with more than one argument is deprecated. Please use assert.strictEqual() instead or only pass a message.","DeprecationWarning","DEP0094")),2===u&&(o="!=")),i instanceof Error)throw i;var c={actual:e,expected:r,operator:void 0===o?"fail":o,stackStartFn:a||t};void 0!==i&&(c.message=i);var f=new y(c);throw s&&(f.message=s,f.generatedMessage=!0),f},T.AssertionError=y,T.ok=P,T.equal=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e!=r&&x({actual:e,expected:r,message:n,operator:"==",stackStartFn:t})},T.notEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");e==r&&x({actual:e,expected:r,message:n,operator:"!=",stackStartFn:t})},T.deepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),s(e,r)||x({actual:e,expected:r,message:n,operator:"deepEqual",stackStartFn:t})},T.notDeepEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),s(e,r)&&x({actual:e,expected:r,message:n,operator:"notDeepEqual",stackStartFn:t})},T.deepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),u(e,r)||x({actual:e,expected:r,message:n,operator:"deepStrictEqual",stackStartFn:t})},T.notDeepStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");void 0===s&&S(),u(e,r)&&x({actual:e,expected:r,message:n,operator:"notDeepStrictEqual",stackStartFn:t})},T.strictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)||x({actual:e,expected:r,message:n,operator:"strictEqual",stackStartFn:t})},T.notStrictEqual=function t(e,r,n){if(arguments.length<2)throw new d("actual","expected");_(e,r)&&x({actual:e,expected:r,message:n,operator:"notStrictEqual",stackStartFn:t})};var I=a((function t(e,r,n){var i=this;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),r.forEach((function(t){t in e&&(void 0!==n&&"string"==typeof n[t]&&v(e[t])&&E(e[t],n[t])?i[t]=n[t]:i[t]=e[t])}))}));function R(t,e,r,n){if("function"!=typeof e){if(v(e))return E(e,t);if(2===arguments.length)throw new l("expected",["Function","RegExp"],e);if("object"!==i(t)||null===t){var o=new y({actual:t,expected:e,message:r,operator:"deepStrictEqual",stackStartFn:n});throw o.operator=n.name,o}var a=Object.keys(e);if(e instanceof Error)a.push("name","message");else if(0===a.length)throw new h("error",e,"may not be an empty object");return void 0===s&&S(),a.forEach((function(i){"string"==typeof t[i]&&v(e[i])&&E(e[i],t[i])||function(t,e,r,n,i,o){if(!(r in t)||!u(t[r],e[r])){if(!n){var a=new I(t,i),s=new I(e,i,t),c=new y({actual:a,expected:s,operator:"deepStrictEqual",stackStartFn:o});throw c.actual=t,c.expected=e,c.operator=o.name,c}x({actual:t,expected:e,message:n,operator:o.name,stackStartFn:o})}}(t,e,i,r,a,n)})),!0}return void 0!==e.prototype&&t instanceof e||!Error.isPrototypeOf(e)&&!0===e.call({},t)}function L(t){if("function"!=typeof t)throw new l("fn","Function",t);try{t()}catch(t){return t}return O}function B(t){return w(t)||null!==t&&"object"===i(t)&&"function"==typeof t.then&&"function"==typeof t.catch}function U(t){return Promise.resolve().then((function(){var e;if("function"==typeof t){if(!B(e=t()))throw new p("instance of Promise","promiseFn",e)}else{if(!B(t))throw new l("promiseFn",["Function","Promise"],t);e=t}return Promise.resolve().then((function(){return e})).then((function(){return O})).catch((function(t){return t}))}))}function N(t,e,r,n){if("string"==typeof r){if(4===arguments.length)throw new l("error",["Object","Error","Function","RegExp"],r);if("object"===i(e)&&null!==e){if(e.message===r)throw new f("error/message",'The error message "'.concat(e.message,'" is identical to the message.'))}else if(e===r)throw new f("error/message",'The error "'.concat(e,'" is identical to the message.'));n=r,r=void 0}else if(null!=r&&"object"!==i(r)&&"function"!=typeof r)throw new l("error",["Object","Error","Function","RegExp"],r);if(e===O){var o="";r&&r.name&&(o+=" (".concat(r.name,")")),o+=n?": ".concat(n):".";var a="rejects"===t.name?"rejection":"exception";x({actual:void 0,expected:r,operator:t.name,message:"Missing expected ".concat(a).concat(o),stackStartFn:t})}if(r&&!R(e,r,n,t))throw e}function j(t,e,r,n){if(e!==O){if("string"==typeof r&&(n=r,r=void 0),!r||R(e,r)){var i=n?": ".concat(n):".",o="doesNotReject"===t.name?"rejection":"exception";x({actual:e,expected:r,operator:t.name,message:"Got unwanted ".concat(o).concat(i,"\n")+'Actual message: "'.concat(e&&e.message,'"'),stackStartFn:t})}throw e}}function C(t,e,r,n,o){if(!v(e))throw new l("regexp","RegExp",e);var a="match"===o;if("string"!=typeof t||E(e,t)!==a){if(r instanceof Error)throw r;var s=!r;r=r||("string"!=typeof t?'The "string" argument must be of type string. Received type '+"".concat(i(t)," (").concat(b(t),")"):(a?"The input did not match the regular expression ":"The input was expected to not match the regular expression ")+"".concat(b(e),". Input:\n\n").concat(b(t),"\n"));var u=new y({actual:t,expected:e,message:r,operator:o,stackStartFn:n});throw u.generatedMessage=s,u}}function F(){for(var t=arguments.length,e=new Array(t),r=0;r<t;r++)e[r]=arguments[r];A.apply(void 0,[F,e.length].concat(e))}T.throws=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];N.apply(void 0,[t,L(e)].concat(n))},T.rejects=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return U(e).then((function(e){return N.apply(void 0,[t,e].concat(n))}))},T.doesNotThrow=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];j.apply(void 0,[t,L(e)].concat(n))},T.doesNotReject=function t(e){for(var r=arguments.length,n=new Array(r>1?r-1:0),i=1;i<r;i++)n[i-1]=arguments[i];return U(e).then((function(e){return j.apply(void 0,[t,e].concat(n))}))},T.ifError=function t(e){if(null!=e){var r="ifError got unwanted exception: ";"object"===i(e)&&"string"==typeof e.message?0===e.message.length&&e.constructor?r+=e.constructor.name:r+=e.message:r+=b(e);var n=new y({actual:e,expected:null,operator:"ifError",message:r,stackStartFn:t}),o=e.stack;if("string"==typeof o){var a=o.split("\n");a.shift();for(var s=n.stack.split("\n"),u=0;u<a.length;u++){var c=s.indexOf(a[u]);if(-1!==c){s=s.slice(0,c);break}}n.stack="".concat(s.join("\n"),"\n").concat(a.join("\n"))}throw n}},T.match=function t(e,r,n){C(e,r,n,t,"match")},T.doesNotMatch=function t(e,r,n){C(e,r,n,t,"doesNotMatch")},T.strict=m(F,T,{equal:T.strictEqual,deepEqual:T.deepStrictEqual,notEqual:T.notStrictEqual,notDeepEqual:T.notDeepStrictEqual}),T.strict.strict=T.strict},3918:(t,e,r)=>{var n=r(5606);function i(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 o(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?i(Object(r),!0).forEach((function(e){var n,i,o;n=t,i=e,o=r[e],(i=s(i))in n?Object.defineProperty(n,i,{value:o,enumerable:!0,configurable:!0,writable:!0}):n[i]=o})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):i(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return 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,s(n.key),n)}}function s(t){var e=function(t){if("object"!==y(t)||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!==y(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"===y(e)?e:String(e)}function u(t,e){if(e&&("object"===y(e)||"function"==typeof e))return e;if(void 0!==e)throw new TypeError("Derived constructors may only return object or undefined");return c(t)}function c(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function f(t){var e="function"==typeof Map?new Map:void 0;return f=function(t){if(null===t||(r=t,-1===Function.toString.call(r).indexOf("[native code]")))return t;var r;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return l(t,arguments,d(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),p(n,t)},f(t)}function l(t,e,r){return l=h()?Reflect.construct.bind():function(t,e,r){var n=[null];n.push.apply(n,e);var i=new(Function.bind.apply(t,n));return r&&p(i,r.prototype),i},l.apply(null,arguments)}function h(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}function p(t,e){return p=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},p(t,e)}function d(t){return d=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},d(t)}function y(t){return y="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},y(t)}var b=r(537).inspect,g=r(9597).codes.ERR_INVALID_ARG_TYPE;function w(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-e.length,r)===e}var v="",m="",_="",E="",S={deepStrictEqual:"Expected values to be strictly deep-equal:",strictEqual:"Expected values to be strictly equal:",strictEqualObject:'Expected "actual" to be reference-equal to "expected":',deepEqual:"Expected values to be loosely deep-equal:",equal:"Expected values to be loosely equal:",notDeepStrictEqual:'Expected "actual" not to be strictly deep-equal to:',notStrictEqual:'Expected "actual" to be strictly unequal to:',notStrictEqualObject:'Expected "actual" not to be reference-equal to "expected":',notDeepEqual:'Expected "actual" not to be loosely deep-equal to:',notEqual:'Expected "actual" to be loosely unequal to:',notIdentical:"Values identical but not reference-equal:"};function k(t){var e=Object.keys(t),r=Object.create(Object.getPrototypeOf(t));return e.forEach((function(e){r[e]=t[e]})),Object.defineProperty(r,"message",{value:t.message}),r}function T(t){return b(t,{compact:!1,customInspect:!1,depth:1e3,maxArrayLength:1/0,showHidden:!1,breakLength:1/0,showProxy:!1,sorted:!0,getters:!0})}var O=function(t,e){!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&&p(t,e)}(O,t);var r,i,s,f,l=(r=O,i=h(),function(){var t,e=d(r);if(i){var n=d(this).constructor;t=Reflect.construct(e,arguments,n)}else t=e.apply(this,arguments);return u(this,t)});function O(t){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,O),"object"!==y(t)||null===t)throw new g("options","Object",t);var r=t.message,i=t.operator,o=t.stackStartFn,a=t.actual,s=t.expected,f=Error.stackTraceLimit;if(Error.stackTraceLimit=0,null!=r)e=l.call(this,String(r));else if(n.stderr&&n.stderr.isTTY&&(n.stderr&&n.stderr.getColorDepth&&1!==n.stderr.getColorDepth()?(v="[34m",m="[32m",E="[39m",_="[31m"):(v="",m="",E="",_="")),"object"===y(a)&&null!==a&&"object"===y(s)&&null!==s&&"stack"in a&&a instanceof Error&&"stack"in s&&s instanceof Error&&(a=k(a),s=k(s)),"deepStrictEqual"===i||"strictEqual"===i)e=l.call(this,function(t,e,r){var i="",o="",a=0,s="",u=!1,c=T(t),f=c.split("\n"),l=T(e).split("\n"),h=0,p="";if("strictEqual"===r&&"object"===y(t)&&"object"===y(e)&&null!==t&&null!==e&&(r="strictEqualObject"),1===f.length&&1===l.length&&f[0]!==l[0]){var d=f[0].length+l[0].length;if(d<=10){if(!("object"===y(t)&&null!==t||"object"===y(e)&&null!==e||0===t&&0===e))return"".concat(S[r],"\n\n")+"".concat(f[0]," !== ").concat(l[0],"\n")}else if("strictEqualObject"!==r&&d<(n.stderr&&n.stderr.isTTY?n.stderr.columns:80)){for(;f[0][h]===l[0][h];)h++;h>2&&(p="\n ".concat(function(t,e){if(e=Math.floor(e),0==t.length||0==e)return"";var r=t.length*e;for(e=Math.floor(Math.log(e)/Math.log(2));e;)t+=t,e--;return t+t.substring(0,r-t.length)}(" ",h),"^"),h=0)}}for(var b=f[f.length-1],g=l[l.length-1];b===g&&(h++<2?s="\n ".concat(b).concat(s):i=b,f.pop(),l.pop(),0!==f.length&&0!==l.length);)b=f[f.length-1],g=l[l.length-1];var k=Math.max(f.length,l.length);if(0===k){var O=c.split("\n");if(O.length>30)for(O[26]="".concat(v,"...").concat(E);O.length>27;)O.pop();return"".concat(S.notIdentical,"\n\n").concat(O.join("\n"),"\n")}h>3&&(s="\n".concat(v,"...").concat(E).concat(s),u=!0),""!==i&&(s="\n ".concat(i).concat(s),i="");var x=0,A=S[r]+"\n".concat(m,"+ actual").concat(E," ").concat(_,"- expected").concat(E),P=" ".concat(v,"...").concat(E," Lines skipped");for(h=0;h<k;h++){var I=h-a;if(f.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(v,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(l[h-2]),x++),o+="\n ".concat(l[h-1]),x++),a=h,i+="\n".concat(_,"-").concat(E," ").concat(l[h]),x++;else if(l.length<h+1)I>1&&h>2&&(I>4?(o+="\n".concat(v,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(f[h-2]),x++),o+="\n ".concat(f[h-1]),x++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(f[h]),x++;else{var R=l[h],L=f[h],B=L!==R&&(!w(L,",")||L.slice(0,-1)!==R);B&&w(R,",")&&R.slice(0,-1)===L&&(B=!1,L+=","),B?(I>1&&h>2&&(I>4?(o+="\n".concat(v,"...").concat(E),u=!0):I>3&&(o+="\n ".concat(f[h-2]),x++),o+="\n ".concat(f[h-1]),x++),a=h,o+="\n".concat(m,"+").concat(E," ").concat(L),i+="\n".concat(_,"-").concat(E," ").concat(R),x+=2):(o+=i,i="",1!==I&&0!==h||(o+="\n ".concat(L),x++))}if(x>20&&h<k-2)return"".concat(A).concat(P,"\n").concat(o,"\n").concat(v,"...").concat(E).concat(i,"\n")+"".concat(v,"...").concat(E)}return"".concat(A).concat(u?P:"","\n").concat(o).concat(i).concat(s).concat(p)}(a,s,i));else if("notDeepStrictEqual"===i||"notStrictEqual"===i){var h=S[i],p=T(a).split("\n");if("notStrictEqual"===i&&"object"===y(a)&&null!==a&&(h=S.notStrictEqualObject),p.length>30)for(p[26]="".concat(v,"...").concat(E);p.length>27;)p.pop();e=1===p.length?l.call(this,"".concat(h," ").concat(p[0])):l.call(this,"".concat(h,"\n\n").concat(p.join("\n"),"\n"))}else{var d=T(a),b="",x=S[i];"notDeepEqual"===i||"notEqual"===i?(d="".concat(S[i],"\n\n").concat(d)).length>1024&&(d="".concat(d.slice(0,1021),"...")):(b="".concat(T(s)),d.length>512&&(d="".concat(d.slice(0,509),"...")),b.length>512&&(b="".concat(b.slice(0,509),"...")),"deepEqual"===i||"equal"===i?d="".concat(x,"\n\n").concat(d,"\n\nshould equal\n\n"):b=" ".concat(i," ").concat(b)),e=l.call(this,"".concat(d).concat(b))}return Error.stackTraceLimit=f,e.generatedMessage=!r,Object.defineProperty(c(e),"name",{value:"AssertionError [ERR_ASSERTION]",enumerable:!1,writable:!0,configurable:!0}),e.code="ERR_ASSERTION",e.actual=a,e.expected=s,e.operator=i,Error.captureStackTrace&&Error.captureStackTrace(c(e),o),e.stack,e.name="AssertionError",u(e)}return s=O,(f=[{key:"toString",value:function(){return"".concat(this.name," [").concat(this.code,"]: ").concat(this.message)}},{key:e,value:function(t,e){return b(this,o(o({},e),{},{customInspect:!1,depth:0}))}}])&&a(s.prototype,f),Object.defineProperty(s,"prototype",{writable:!1}),O}(f(Error),b.custom);t.exports=O},9597:(t,e,r)=>{function n(t){return n="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},n(t)}function i(t,e){return i=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},i(t,e)}function o(t){return o=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},o(t)}var a,s,u={};function c(t,e,r){r||(r=Error);var a=function(r){!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&&i(t,e)}(f,r);var a,s,u,c=(s=f,u=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(t){return!1}}(),function(){var t,e=o(s);if(u){var r=o(this).constructor;t=Reflect.construct(e,arguments,r)}else t=e.apply(this,arguments);return function(t,e){if(e&&("object"===n(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)}(this,t)});function f(r,n,i){var o;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,f),o=c.call(this,function(t,r,n){return"string"==typeof e?e:e(t,r,n)}(r,n,i)),o.code=t,o}return a=f,Object.defineProperty(a,"prototype",{writable:!1}),a}(r);u[t]=a}function f(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))}c("ERR_AMBIGUOUS_ARGUMENT",'The "%s" argument is ambiguous. %s',TypeError),c("ERR_INVALID_ARG_TYPE",(function(t,e,i){var o,s,u,c,l;if(void 0===a&&(a=r(4148)),a("string"==typeof t,"'name' must be a string"),"string"==typeof e&&(s="not ",e.substr(0,4)===s)?(o="must not be",e=e.replace(/^not /,"")):o="must be",function(t,e,r){return(void 0===r||r>t.length)&&(r=t.length),t.substring(r-9,r)===e}(t," argument"))u="The ".concat(t," ").concat(o," ").concat(f(e,"type"));else{var h=("number"!=typeof l&&(l=0),l+1>(c=t).length||-1===c.indexOf(".",l)?"argument":"property");u='The "'.concat(t,'" ').concat(h," ").concat(o," ").concat(f(e,"type"))}return u+". Received type ".concat(n(i))}),TypeError),c("ERR_INVALID_ARG_VALUE",(function(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"is invalid";void 0===s&&(s=r(537));var i=s.inspect(e);return i.length>128&&(i="".concat(i.slice(0,128),"...")),"The argument '".concat(t,"' ").concat(n,". Received ").concat(i)}),TypeError,RangeError),c("ERR_INVALID_RETURN_VALUE",(function(t,e,r){var i;return i=r&&r.constructor&&r.constructor.name?"instance of ".concat(r.constructor.name):"type ".concat(n(r)),"Expected ".concat(t,' to be returned from the "').concat(e,'"')+" function but got ".concat(i,".")}),TypeError),c("ERR_MISSING_ARGS",(function(){for(var t=arguments.length,e=new Array(t),n=0;n<t;n++)e[n]=arguments[n];void 0===a&&(a=r(4148)),a(e.length>0,"At least one arg needs to be specified");var i="The ",o=e.length;switch(e=e.map((function(t){return'"'.concat(t,'"')})),o){case 1:i+="".concat(e[0]," argument");break;case 2:i+="".concat(e[0]," and ").concat(e[1]," arguments");break;default:i+=e.slice(0,o-1).join(", "),i+=", and ".concat(e[o-1]," arguments")}return"".concat(i," must be specified")}),TypeError),t.exports.codes=u},2299:(t,e,r)=>{function n(t,e){return function(t){if(Array.isArray(t))return t}(t)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,i,o,a,s=[],u=!0,c=!1;try{if(o=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=o.call(r)).done)&&(s.push(n.value),s.length!==e);u=!0);}catch(t){c=!0,i=t}finally{try{if(!u&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw i}}return s}}(t,e)||function(t,e){if(t){if("string"==typeof t)return i(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)?i(t,e):void 0}}(t,e)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(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 o(t){return o="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},o(t)}var a=void 0!==/a/g.flags,s=function(t){var e=[];return t.forEach((function(t){return e.push(t)})),e},u=function(t){var e=[];return t.forEach((function(t,r){return e.push([r,t])})),e},c=Object.is?Object.is:r(7653),f=Object.getOwnPropertySymbols?Object.getOwnPropertySymbols:function(){return[]},l=Number.isNaN?Number.isNaN:r(4133);function h(t){return t.call.bind(t)}var p=h(Object.prototype.hasOwnProperty),d=h(Object.prototype.propertyIsEnumerable),y=h(Object.prototype.toString),b=r(537).types,g=b.isAnyArrayBuffer,w=b.isArrayBufferView,v=b.isDate,m=b.isMap,_=b.isRegExp,E=b.isSet,S=b.isNativeError,k=b.isBoxedPrimitive,T=b.isNumberObject,O=b.isStringObject,x=b.isBooleanObject,A=b.isBigIntObject,P=b.isSymbolObject,I=b.isFloat32Array,R=b.isFloat64Array;function L(t){if(0===t.length||t.length>10)return!0;for(var e=0;e<t.length;e++){var r=t.charCodeAt(e);if(r<48||r>57)return!0}return 10===t.length&&t>=Math.pow(2,32)}function B(t){return Object.keys(t).filter(L).concat(f(t).filter(Object.prototype.propertyIsEnumerable.bind(t)))}function U(t,e){if(t===e)return 0;for(var r=t.length,n=e.length,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}function N(t,e,r,n){if(t===e)return 0!==t||!r||c(t,e);if(r){if("object"!==o(t))return"number"==typeof t&&l(t)&&l(e);if("object"!==o(e)||null===t||null===e)return!1;if(Object.getPrototypeOf(t)!==Object.getPrototypeOf(e))return!1}else{if(null===t||"object"!==o(t))return(null===e||"object"!==o(e))&&t==e;if(null===e||"object"!==o(e))return!1}var i,s,u=y(t);if(u!==y(e))return!1;if(Array.isArray(t)){if(t.length!==e.length)return!1;var f=B(t),h=B(e);return f.length===h.length&&C(t,e,r,n,1,f)}if("[object Object]"===u&&(!m(t)&&m(e)||!E(t)&&E(e)))return!1;if(v(t)){if(!v(e)||Date.prototype.getTime.call(t)!==Date.prototype.getTime.call(e))return!1}else if(_(t)){if(!_(e)||!function(t,e){return a?t.source===e.source&&t.flags===e.flags:RegExp.prototype.toString.call(t)===RegExp.prototype.toString.call(e)}(t,e))return!1}else if(S(t)||t instanceof Error){if(t.message!==e.message||t.name!==e.name)return!1}else{if(w(t)){if(r||!I(t)&&!R(t)){if(!function(t,e){return t.byteLength===e.byteLength&&0===U(new Uint8Array(t.buffer,t.byteOffset,t.byteLength),new Uint8Array(e.buffer,e.byteOffset,e.byteLength))}(t,e))return!1}else if(!function(t,e){if(t.byteLength!==e.byteLength)return!1;for(var r=0;r<t.byteLength;r++)if(t[r]!==e[r])return!1;return!0}(t,e))return!1;var p=B(t),d=B(e);return p.length===d.length&&C(t,e,r,n,0,p)}if(E(t))return!(!E(e)||t.size!==e.size)&&C(t,e,r,n,2);if(m(t))return!(!m(e)||t.size!==e.size)&&C(t,e,r,n,3);if(g(t)){if(s=e,(i=t).byteLength!==s.byteLength||0!==U(new Uint8Array(i),new Uint8Array(s)))return!1}else if(k(t)&&!function(t,e){return T(t)?T(e)&&c(Number.prototype.valueOf.call(t),Number.prototype.valueOf.call(e)):O(t)?O(e)&&String.prototype.valueOf.call(t)===String.prototype.valueOf.call(e):x(t)?x(e)&&Boolean.prototype.valueOf.call(t)===Boolean.prototype.valueOf.call(e):A(t)?A(e)&&BigInt.prototype.valueOf.call(t)===BigInt.prototype.valueOf.call(e):P(e)&&Symbol.prototype.valueOf.call(t)===Symbol.prototype.valueOf.call(e)}(t,e))return!1}return C(t,e,r,n,0)}function j(t,e){return e.filter((function(e){return d(t,e)}))}function C(t,e,r,i,a,c){if(5===arguments.length){c=Object.keys(t);var l=Object.keys(e);if(c.length!==l.length)return!1}for(var h=0;h<c.length;h++)if(!p(e,c[h]))return!1;if(r&&5===arguments.length){var y=f(t);if(0!==y.length){var b=0;for(h=0;h<y.length;h++){var g=y[h];if(d(t,g)){if(!d(e,g))return!1;c.push(g),b++}else if(d(e,g))return!1}var w=f(e);if(y.length!==w.length&&j(e,w).length!==b)return!1}else{var v=f(e);if(0!==v.length&&0!==j(e,v).length)return!1}}if(0===c.length&&(0===a||1===a&&0===t.length||0===t.size))return!0;if(void 0===i)i={val1:new Map,val2:new Map,position:0};else{var m=i.val1.get(t);if(void 0!==m){var _=i.val2.get(e);if(void 0!==_)return m===_}i.position++}i.val1.set(t,i.position),i.val2.set(e,i.position);var E=function(t,e,r,i,a,c){var f=0;if(2===c){if(!function(t,e,r,n){for(var i=null,a=s(t),u=0;u<a.length;u++){var c=a[u];if("object"===o(c)&&null!==c)null===i&&(i=new Set),i.add(c);else if(!e.has(c)){if(r)return!1;if(!D(t,e,c))return!1;null===i&&(i=new Set),i.add(c)}}if(null!==i){for(var f=s(e),l=0;l<f.length;l++){var h=f[l];if("object"===o(h)&&null!==h){if(!F(i,h,r,n))return!1}else if(!r&&!t.has(h)&&!F(i,h,r,n))return!1}return 0===i.size}return!0}(t,e,r,a))return!1}else if(3===c){if(!function(t,e,r,i){for(var a=null,s=u(t),c=0;c<s.length;c++){var f=n(s[c],2),l=f[0],h=f[1];if("object"===o(l)&&null!==l)null===a&&(a=new Set),a.add(l);else{var p=e.get(l);if(void 0===p&&!e.has(l)||!N(h,p,r,i)){if(r)return!1;if(!H(t,e,l,h,i))return!1;null===a&&(a=new Set),a.add(l)}}}if(null!==a){for(var d=u(e),y=0;y<d.length;y++){var b=n(d[y],2),g=b[0],w=b[1];if("object"===o(g)&&null!==g){if(!K(a,t,g,w,r,i))return!1}else if(!(r||t.has(g)&&N(t.get(g),w,!1,i)||K(a,t,g,w,!1,i)))return!1}return 0===a.size}return!0}(t,e,r,a))return!1}else if(1===c)for(;f<t.length;f++){if(!p(t,f)){if(p(e,f))return!1;for(var l=Object.keys(t);f<l.length;f++){var h=l[f];if(!p(e,h)||!N(t[h],e[h],r,a))return!1}return l.length===Object.keys(e).length}if(!p(e,f)||!N(t[f],e[f],r,a))return!1}for(f=0;f<i.length;f++){var d=i[f];if(!N(t[d],e[d],r,a))return!1}return!0}(t,e,r,c,i,a);return i.val1.delete(t),i.val2.delete(e),E}function F(t,e,r,n){for(var i=s(t),o=0;o<i.length;o++){var a=i[o];if(N(e,a,r,n))return t.delete(a),!0}return!1}function M(t){switch(o(t)){case"undefined":return null;case"object":return;case"symbol":return!1;case"string":t=+t;case"number":if(l(t))return!1}return!0}function D(t,e,r){var n=M(r);return null!=n?n:e.has(n)&&!t.has(n)}function H(t,e,r,n,i){var o=M(r);if(null!=o)return o;var a=e.get(o);return!(void 0===a&&!e.has(o)||!N(n,a,!1,i))&&!t.has(o)&&N(n,a,!1,i)}function K(t,e,r,n,i,o){for(var a=s(t),u=0;u<a.length;u++){var c=a[u];if(N(r,c,i,o)&&N(n,e.get(c),i,o))return t.delete(c),!0}return!1}t.exports={isDeepEqual:function(t,e){return N(t,e,!1)},isDeepStrictEqual:function(t,e){return N(t,e,!0)}}},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 a=t.length,s=t.charAt(0),u=Math.log(a)/Math.log(256),c=Math.log(256)/Math.log(a);function f(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]===s;)n++,r++;for(var o=(t.length-r)*u+1>>>0,c=new Uint8Array(o);t[r];){var f=e[t.charCodeAt(r)];if(255===f)return;for(var l=0,h=o-1;(0!==f||l<i)&&-1!==h;h--,l++)f+=a*c[h]>>>0,c[h]=f%256>>>0,f=f/256>>>0;if(0!==f)throw new Error("Non-zero carry");i=l,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,f=new Uint8Array(u);i!==o;){for(var l=e[i],h=0,p=u-1;(0!==l||h<n)&&-1!==p;p--,h++)l+=256*f[p]>>>0,f[p]=l%a>>>0,l=l/a>>>0;if(0!==l)throw new Error("Non-zero carry");n=h,i++}for(var d=u-n;d!==u&&0===f[d];)d++;for(var y=s.repeat(r);d<u;++d)y+=t.charAt(f[d]);return y},decodeUnsafe:f,decode:function(t){var e=f(t);if(e)return e;throw new Error("Non-base"+a+" character")}}}},7526:(t,e)=>{e.byteLength=function(t){var e=s(t),r=e[0],n=e[1];return 3*(r+n)/4-n},e.toByteArray=function(t){var e,r,o=s(t),a=o[0],u=o[1],c=new i(function(t,e,r){return 3*(e+r)/4-r}(0,a,u)),f=0,l=u>0?a-4:a;for(r=0;r<l;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[f++]=e>>16&255,c[f++]=e>>8&255,c[f++]=255&e;return 2===u&&(e=n[t.charCodeAt(r)]<<2|n[t.charCodeAt(r+1)]>>4,c[f++]=255&e),1===u&&(e=n[t.charCodeAt(r)]<<10|n[t.charCodeAt(r+1)]<<4|n[t.charCodeAt(r+2)]>>2,c[f++]=e>>8&255,c[f++]=255&e),c},e.fromByteArray=function(t){for(var e,n=t.length,i=n%3,o=[],a=16383,s=0,c=n-i;s<c;s+=a)o.push(u(t,s,s+a>c?c:s+a));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+/",a=0;a<64;++a)r[a]=o[a],n[o.charCodeAt(a)]=a;function s(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,a=[],s=e;s<n;s+=3)i=(t[s]<<16&16711680)+(t[s+1]<<8&65280)+(255&t[s+2]),a.push(r[(o=i)>>18&63]+r[o>>12&63]+r[o>>6&63]+r[63&o]);return a.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 a(t,e,r,n){let i=0,o=0;const a=(1<<r)-1,s=[];for(let n=0;n<t.length;++n)for(i=i<<e|t[n],o+=e;o>=r;)o-=r,s.push(i>>o&a);if(n)o>0&&s.push(i<<r-o&a);else{if(o>=e)return"Excess padding";if(i<<r-o&a)return"Non-zero padding"}return s}function s(t){return a(t,8,5,!0)}function u(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e}function c(t){const e=a(t,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function f(t){let e;function a(t,r){if(r=r||90,t.length<8)return t+" too short";if(t.length>r)return"Exceeds length limit";const a=t.toLowerCase(),s=t.toUpperCase();if(t!==a&&t!==s)return"Mixed-case string "+t;const u=(t=a).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),f=t.slice(u+1);if(f.length<6)return"Data too short";let l=o(c);if("string"==typeof l)return l;const h=[];for(let t=0;t<f.length;++t){const e=f.charAt(t),r=n[e];if(void 0===r)return"Unknown character "+e;l=i(l)^r,t+6>=f.length||h.push(r)}return l!==e?"Invalid checksum for "+t:{prefix:c,words:h}}return e="bech32"===t?1:734539939,{decodeUnsafe:function(t,e){const r=a(t,e);if("object"==typeof r)return r},decode:function(t,e){const r=a(t,e);if("object"==typeof r)return r;throw new Error(r)},encode:function(t,n,a){if(a=a||90,t.length+7+n.length>a)throw new TypeError("Exceeds length limit");let s=o(t=t.toLowerCase());if("string"==typeof s)throw new Error(s);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");s=i(s)^e,u+=r.charAt(e)}for(let t=0;t<6;++t)s=i(s);s^=e;for(let t=0;t<6;++t)u+=r.charAt(s>>5*(5-t)&31);return u},toWords:s,fromWordsUnsafe:u,fromWords:c}}e.bech32=f("bech32"),e.bech32m=f("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 a(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),s=t.slice(1);if(0===s.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=a(r.globalKeyVals),f=r.inputKeyVals.map(a),l=r.outputKeyVals.map(a);for(const t of s){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 s=n.psbtToKeyVals(t);a(s.globalKeyVals).forEach(i(c,r.globalKeyVals,s.globalKeyVals)),s.inputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(f[e],r.inputKeyVals[e],s.inputKeyVals[e])))),s.outputKeyVals.map(a).forEach(((t,e)=>t.forEach(i(l[e],r.outputKeyVals[e],s.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(t=>[...Array(t).keys()])(t.value.length/4-1)){const n=t.value.readUInt32LE(4*e+4),i=!!(2147483648&n),o=2147483647&n;r.path+="/"+o.toString(10)+(i?"'":"")}return r},e.encode=function(t){const e=n.from([i.GlobalTypes.GLOBAL_XPUB]),r=n.concat([e,t.extendedPubkey]),o=t.path.split("/"),a=n.allocUnsafe(4*o.length);t.masterFingerprint.copy(a,0);let s=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),a.writeUInt32LE(r,s),s+=4})),{key:r,value:a}},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),a=r(6605),s=r(1795),u=r(4431),c=r(6907),f=r(5949),l=r(9344),h=r(2760),p=r(1695),d=r(8454),y=r(9034),b=r(2926),g=r(7851),w=r(7545),v=r(2412),m=r(4307),_=r(7636),E=r(2223),S=r(5578),k={unsignedTx:o,globalXpub:i,checkPubkey:v.makeChecker([])};e.globals=k;const T={nonWitnessUtxo:u,partialSig:c,sighashType:l,finalScriptSig:a,finalScriptWitness:s,porCommitment:f,witnessUtxo:b,bip32Derivation:w.makeConverter(n.InputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.InputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.InputTypes.WITNESS_SCRIPT),checkPubkey:v.makeChecker([n.InputTypes.PARTIAL_SIG,n.InputTypes.BIP32_DERIVATION]),tapKeySig:h,tapScriptSig:y,tapLeafScript:p,tapBip32Derivation:_.makeConverter(n.InputTypes.TAP_BIP32_DERIVATION),tapInternalKey:E.makeConverter(n.InputTypes.TAP_INTERNAL_KEY),tapMerkleRoot:d};e.inputs=T;const O={bip32Derivation:w.makeConverter(n.OutputTypes.BIP32_DERIVATION),redeemScript:m.makeConverter(n.OutputTypes.REDEEM_SCRIPT),witnessScript:S.makeConverter(n.OutputTypes.WITNESS_SCRIPT),checkPubkey:v.makeChecker([n.OutputTypes.BIP32_DERIVATION]),tapBip32Derivation:_.makeConverter(n.OutputTypes.TAP_BIP32_DERIVATION),tapTree:g,tapInternalKey:E.makeConverter(n.OutputTypes.TAP_INTERNAL_KEY)};e.outputs=O},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),a=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=a.decode(t.value,r);r+=a.encodingLength(n);const s=t.value.slice(r);if(s.length!==n)throw new Error("Decode Error: WITNESS_UTXO script is not proper length");return{script:s,value:e}},e.encode=function(t){const{script:e,value:r}=t,s=a.encodingLength(e.length),u=n.allocUnsafe(8+s+e.length);return o.writeUInt64LE(u,r,0),a.encode(e.length,u,8),e.copy(u,8+s),{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++],a=o.decode(t.value,e);e+=o.encodingLength(a),r.push({depth:n,leafVersion:i,script:t.value.slice(e,e+a)}),e+=a}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(t=>[...Array(t).keys()])(r.value.length/4-1)){const e=r.value.readUInt32LE(4*t+4),n=!!(2147483648&e),o=2147483647&e;i.path+="/"+o.toString(10)+(n?"'":"")}return i},encode:function(e){const r=n.from([t]),i=n.concat([r,e.pubkey]),o=e.path.split("/"),a=n.allocUnsafe(4*o.length);e.masterFingerprint.copy(a,0);let s=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),a.writeUInt32LE(r,s),s+=4})),{key:i,value:a}},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),a=t=>32===t.length;e.makeConverter=function(t){const e=o.makeConverter(t,a);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)}),a=new Array(r);for(let e=0,i=n;e<r;e++,i+=32)a[e]=t.value.slice(i,i+32);return Object.assign({},o,{leafHashes:a})},encode:function(t){const r=e.encode(t),o=i.encodingLength(t.leafHashes.length),a=n.allocUnsafe(o);i.encode(t.leafHashes.length,a);const s=n.concat([a,...t.leafHashes,r.value]);return Object.assign({},r,{value:s})},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),a=i.encodingLength(r),s=n.allocUnsafe(o+e+a+r);return i.encode(e,s,0),t.key.copy(s,o),i.encode(r,s,o+e),t.value.copy(s,o+e+a),s}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")}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,a(n+r,9007199254740991),n+r},e.writeUInt64LE=function(t,e,r){return a(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;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}Object.defineProperty(e,"__esModule",{value:!0}),e.encode=function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),Object.assign(t,{bytes:1})):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),Object.assign(t,{bytes:3})):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),Object.assign(t,{bytes:5})):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+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 o=e.readUInt8(r);if(o<253)return Object.assign(t,{bytes:1}),o;if(253===o)return Object.assign(t,{bytes:3}),e.readUInt16LE(r+1);if(254===o)return Object.assign(t,{bytes:5}),e.readUInt32LE(r+1);{Object.assign(t,{bytes:9});const n=e.readUInt32LE(r+1),o=4294967296*e.readUInt32LE(r+5)+n;return i(o),o}},e.encodingLength=o},6263:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0});const i=r(2706),o=r(8133),a=r(394),s=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 a={unsignedTx:t};let c=0;for(const t of e)switch(t.key[0]){case s.GlobalTypes.UNSIGNED_TX:if(u("global",t.key,s.GlobalTypes.UNSIGNED_TX),c>0)throw new Error("Format Error: GlobalMap has multiple UNSIGNED_TX");c++;break;case s.GlobalTypes.GLOBAL_XPUB:void 0===a.globalXpub&&(a.globalXpub=[]),a.globalXpub.push(i.globals.globalXpub.decode(t));break;default:a.unknownKeyVals||(a.unknownKeyVals=[]),a.unknownKeyVals.push(t)}const f=r.length,l=n.length,h=[],p=[];for(const t of o.range(f)){const e={};for(const n of r[t])switch(i.inputs.checkPubkey(n),n.key[0]){case s.InputTypes.NON_WITNESS_UTXO:if(u("input",n.key,s.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 s.InputTypes.WITNESS_UTXO:if(u("input",n.key,s.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 s.InputTypes.PARTIAL_SIG:void 0===e.partialSig&&(e.partialSig=[]),e.partialSig.push(i.inputs.partialSig.decode(n));break;case s.InputTypes.SIGHASH_TYPE:if(u("input",n.key,s.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 s.InputTypes.REDEEM_SCRIPT:if(u("input",n.key,s.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 s.InputTypes.WITNESS_SCRIPT:if(u("input",n.key,s.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 s.InputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.inputs.bip32Derivation.decode(n));break;case s.InputTypes.FINAL_SCRIPTSIG:u("input",n.key,s.InputTypes.FINAL_SCRIPTSIG),e.finalScriptSig=i.inputs.finalScriptSig.decode(n);break;case s.InputTypes.FINAL_SCRIPTWITNESS:u("input",n.key,s.InputTypes.FINAL_SCRIPTWITNESS),e.finalScriptWitness=i.inputs.finalScriptWitness.decode(n);break;case s.InputTypes.POR_COMMITMENT:u("input",n.key,s.InputTypes.POR_COMMITMENT),e.porCommitment=i.inputs.porCommitment.decode(n);break;case s.InputTypes.TAP_KEY_SIG:u("input",n.key,s.InputTypes.TAP_KEY_SIG),e.tapKeySig=i.inputs.tapKeySig.decode(n);break;case s.InputTypes.TAP_SCRIPT_SIG:void 0===e.tapScriptSig&&(e.tapScriptSig=[]),e.tapScriptSig.push(i.inputs.tapScriptSig.decode(n));break;case s.InputTypes.TAP_LEAF_SCRIPT:void 0===e.tapLeafScript&&(e.tapLeafScript=[]),e.tapLeafScript.push(i.inputs.tapLeafScript.decode(n));break;case s.InputTypes.TAP_BIP32_DERIVATION:void 0===e.tapBip32Derivation&&(e.tapBip32Derivation=[]),e.tapBip32Derivation.push(i.inputs.tapBip32Derivation.decode(n));break;case s.InputTypes.TAP_INTERNAL_KEY:u("input",n.key,s.InputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.inputs.tapInternalKey.decode(n);break;case s.InputTypes.TAP_MERKLE_ROOT:u("input",n.key,s.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(l)){const e={};for(const r of n[t])switch(i.outputs.checkPubkey(r),r.key[0]){case s.OutputTypes.REDEEM_SCRIPT:if(u("output",r.key,s.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 s.OutputTypes.WITNESS_SCRIPT:if(u("output",r.key,s.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 s.OutputTypes.BIP32_DERIVATION:void 0===e.bip32Derivation&&(e.bip32Derivation=[]),e.bip32Derivation.push(i.outputs.bip32Derivation.decode(r));break;case s.OutputTypes.TAP_INTERNAL_KEY:u("output",r.key,s.OutputTypes.TAP_INTERNAL_KEY),e.tapInternalKey=i.outputs.tapInternalKey.decode(r);break;case s.OutputTypes.TAP_TREE:u("output",r.key,s.OutputTypes.TAP_TREE),e.tapTree=i.outputs.tapTree.decode(r);break;case s.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:a,inputs:h,outputs:p}}e.psbtFromBuffer=function(t,e){let r=0;function n(){const e=a.decode(t,r);r+=a.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 f=[],l={};for(;!u();){const t=i(),e=t.key.toString("hex");if(l[e])throw new Error("Format Error: Keys must be unique for global keymap: key "+e);l[e]=1,f.push(t)}const h=f.filter((t=>t.key[0]===s.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(),b=[],g=[];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)}b.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)}g.push(r)}return c(p,{globalMapKeyVals:f,inputKeyVals:b,outputKeyVals:g})},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:a,outputKeyVals:s}=u({globalMap:t,inputs:e,outputs:r}),c=o.keyValsToBuffer(i),f=t=>0===t.length?[n.from([0])]:t.map(o.keyValsToBuffer),l=f(a),h=f(s),p=n.allocUnsafe(5);return p.writeUIntBE(482972169471,0,5),n.concat([p,c].concat(l,h))};const a=(t,e)=>t.key.compare(e.key);function s(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 a=(Array.isArray(i)?i:[i]).map(o.encode);return a.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(a)}),[]),i=t.unknownKeyVals?t.unknownKeyVals.filter((t=>!r.has(t.key.toString("hex")))):[];return n.concat(i).sort(a)}function u({globalMap:t,inputs:e,outputs:r}){return{globalKeyVals:s(t,i.globals),inputKeyVals:e.map((t=>s(t,i.inputs))),outputKeyVals:r.map((t=>s(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),a=r(9080),s=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 s.updateGlobal(t,this.globalMap),this}updateInput(t,e){const r=s.checkForInput(this.inputs,t);return s.updateInput(e,r),this}updateOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.updateOutput(e,r),this}addUnknownKeyValToGlobal(t){return s.checkHasKey(t,this.globalMap.unknownKeyVals,s.getEnumLength(a.GlobalTypes)),this.globalMap.unknownKeyVals||(this.globalMap.unknownKeyVals=[]),this.globalMap.unknownKeyVals.push(t),this}addUnknownKeyValToInput(t,e){const r=s.checkForInput(this.inputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.InputTypes)),r.unknownKeyVals||(r.unknownKeyVals=[]),r.unknownKeyVals.push(e),this}addUnknownKeyValToOutput(t,e){const r=s.checkForOutput(this.outputs,t);return s.checkHasKey(e,r.unknownKeyVals,s.getEnumLength(a.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))),s.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))),s.addOutputAttributes(this.outputs,t),this}clearFinalizedInput(t){const e=s.checkForInput(this.inputs,t);s.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 a(t,e){const r=t[e];if(void 0===r)throw new Error(`No output #${e}`);return r}function s(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:a,canAddToArray:u,check:c,expected:f}=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)||s(t,n,f,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)||s(t,n,f,o),!a(r,o))throw new Error(`Can not add duplicate data to ${t}`);r[n]=o}}}}e.checkForInput=o,e.checkForOutput=a,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,a=!!e.finalScriptSig||!!e.finalScriptWitness;r=i&&o&&a}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=a(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}},4642:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.BIP32Factory=void 0;const i=r(9571),o=r(7757),a=r(3203),s=r(2623),u=r(8676),c=r(7513),f=(0,a.base58check)(s.sha256);e.BIP32Factory=function(t){(0,o.testEcc)(t);const e=u.BufferN(32),r=u.compile({wif:u.UInt8,bip32:{public:u.UInt32,private:u.UInt32}}),a={messagePrefix:"Bitcoin Signed Message:\n",bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128},s=2147483648,l=Math.pow(2,31)-1;function h(t){return u.String(t)&&null!==t.match(/^(m\/)?(\d+'?\/)*\d+'?$/)}function p(t){return u.UInt32(t)&&t<=l}class d{constructor(t,e){this.__D=t,this.__Q=e,this.lowR=!1}get publicKey(){return void 0===this.__Q&&(this.__Q=n.from(t.pointFromScalar(this.__D,!0))),this.__Q}get privateKey(){return this.__D}sign(e,r){if(!this.privateKey)throw new Error("Missing private key");if(void 0===r&&(r=this.lowR),!1===r)return n.from(t.sign(e,this.privateKey));{let r=n.from(t.sign(e,this.privateKey));const i=n.alloc(32,0);let o=0;for(;r[0]>127;)o++,i.writeUIntLE(o,0,6),r=n.from(t.sign(e,this.privateKey,i));return 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)}}class y extends d{constructor(t,e,n,i,o=0,a=0,s=0){super(t,e),this.chainCode=n,this.network=i,this.__DEPTH=o,this.__INDEX=a,this.__PARENT_FINGERPRINT=s,u(r,i)}get depth(){return this.__DEPTH}get index(){return this.__INDEX}get parentFingerprint(){return this.__PARENT_FINGERPRINT}get identifier(){return i.hash160(this.publicKey)}get fingerprint(){return this.identifier.slice(0,4)}get compressed(){return!0}isNeutered(){return void 0===this.__D}neutered(){return w(this.publicKey,this.chainCode,this.network,this.depth,this.index,this.parentFingerprint)}toBase58(){const t=this.network,e=this.isNeutered()?t.bip32.public:t.bip32.private,r=n.allocUnsafe(78);return r.writeUInt32BE(e,0),r.writeUInt8(this.depth,4),r.writeUInt32BE(this.parentFingerprint,5),r.writeUInt32BE(this.index,9),this.chainCode.copy(r,13),this.isNeutered()?this.publicKey.copy(r,45):(r.writeUInt8(0,45),this.privateKey.copy(r,46)),i=r,f.encode(Uint8Array.from(i));var i}toWIF(){if(!this.privateKey)throw new TypeError("Missing private key");return c.encode(this.network.wif,this.privateKey,!0)}derive(e){u(u.UInt32,e);const r=e>=s,o=n.allocUnsafe(37);if(r){if(this.isNeutered())throw new TypeError("Missing private key for hardened child key");o[0]=0,this.privateKey.copy(o,1),o.writeUInt32BE(e,33)}else this.publicKey.copy(o,0),o.writeUInt32BE(e,33);const a=i.hmacSHA512(this.chainCode,o),c=a.slice(0,32),f=a.slice(32);if(!t.isPrivate(c))return this.derive(e+1);let l;if(this.isNeutered()){const r=n.from(t.pointAddScalar(this.publicKey,c,!0));if(null===r)return this.derive(e+1);l=w(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}else{const r=n.from(t.privateAdd(this.privateKey,c));if(null==r)return this.derive(e+1);l=g(r,f,this.network,this.depth+1,e,this.fingerprint.readUInt32BE(0))}return l}deriveHardened(t){return u(p,t),this.derive(t+s)}derivePath(t){u(h,t);let e=t.split("/");if("m"===e[0]){if(this.parentFingerprint)throw new TypeError("Expected master, got child");e=e.slice(1)}return e.reduce(((t,e)=>{let r;return"'"===e.slice(-1)?(r=parseInt(e.slice(0,-1),10),t.deriveHardened(r)):(r=parseInt(e,10),t.derive(r))}),this)}tweak(t){return this.privateKey?this.tweakFromPrivateKey(t):this.tweakFromPublicKey(t)}tweakFromPublicKey(e){const r=32===(i=this.publicKey).length?i:i.slice(1,33);var i;if(!t.xOnlyPointAddTweak)throw new Error("xOnlyPointAddTweak not supported by ecc library");const o=t.xOnlyPointAddTweak(r,e);if(!o||null===o.xOnlyPubkey)throw new Error("Cannot tweak public key!");const a=n.from([0===o.parity?2:3]),s=n.concat([a,o.xOnlyPubkey]);return new d(void 0,s)}tweakFromPrivateKey(e){const r=3===this.publicKey[0]||4===this.publicKey[0]&&!(1&~this.publicKey[64]),i=(()=>{if(r){if(t.privateNegate)return t.privateNegate(this.privateKey);throw new Error("privateNegate not supported by ecc library")}return this.privateKey})(),o=t.privateAdd(i,e);if(!o)throw new Error("Invalid tweaked private key!");return new d(n.from(o),void 0)}}function b(t,e,r){return g(t,e,r)}function g(r,n,i,o,s,c){if(u({privateKey:e,chainCode:e},{privateKey:r,chainCode:n}),i=i||a,!t.isPrivate(r))throw new TypeError("Private key not in range [1, n)");return new y(r,void 0,n,i,o,s,c)}function w(r,n,i,o,s,c){if(u({publicKey:u.BufferN(33),chainCode:e},{publicKey:r,chainCode:n}),i=i||a,!t.isPoint(r))throw new TypeError("Point is not on the curve");return new y(void 0,r,n,i,o,s,c)}return{fromSeed:function(t,e){if(u(u.Buffer,t),t.length<16)throw new TypeError("Seed should be at least 128 bits");if(t.length>64)throw new TypeError("Seed should be at most 512 bits");e=e||a;const r=i.hmacSHA512(n.from("Bitcoin seed","utf8"),t);return b(r.slice(0,32),r.slice(32),e)},fromBase58:function(t,e){const r=(i=t,n.from(f.decode(i)));var i;if(78!==r.length)throw new TypeError("Invalid buffer length");e=e||a;const o=r.readUInt32BE(0);if(o!==e.bip32.private&&o!==e.bip32.public)throw new TypeError("Invalid network version");const s=r[4],u=r.readUInt32BE(5);if(0===s&&0!==u)throw new TypeError("Invalid parent fingerprint");const c=r.readUInt32BE(9);if(0===s&&0!==c)throw new TypeError("Invalid index");const l=r.slice(13,45);let h;if(o===e.bip32.private){if(0!==r.readUInt8(45))throw new TypeError("Invalid private key");h=g(r.slice(46,78),l,e,s,c,u)}else h=w(r.slice(45,78),l,e,s,c,u);return h},fromPublicKey:function(t,e,r){return w(t,e,r)},fromPrivateKey:b}}},9571:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.hmacSHA512=e.hash160=void 0;const i=r(9615),o=r(3238),a=r(2623),s=r(102);e.hash160=function(t){const e=(0,a.sha256)(Uint8Array.from(t));return n.from((0,o.ripemd160)(e))},e.hmacSHA512=function(t,e){return n.from((0,i.hmac)(s.sha512,t,e))}},852:(t,e,r)=>{e.Pr=e.Ay=void 0;var n=r(4642);Object.defineProperty(e,"Ay",{enumerable:!0,get:function(){return n.BIP32Factory}}),Object.defineProperty(e,"Pr",{enumerable:!0,get:function(){return n.BIP32Factory}})},7757:(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){if(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.pointFromScalar(i("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(i("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),t.xOnlyPointAddTweak){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(t.pointAddScalar(i("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),i("0000000000000000000000000000000000000000000000000000000000000003"))).equals(i("02c6047f9441ed7d6d3045406e95c07cd85c778e4b8cef3ca7abac09b95c709ee5"))),o(n.from(t.privateAdd(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),i("0000000000000000000000000000000000000000000000000000000000000002"))).equals(i("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),t.privateNegate&&(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.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")))}},57:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.fromBase58Check=b,e.fromBech32=g,e.toBase58Check=function(t,e){(0,s.typeforce)((0,s.tuple)(s.Hash160bit,s.UInt8),arguments);const r=n.allocUnsafe(21);return r.writeUInt8(e,0),t.copy(r,1),c.encode(r)},e.toBech32=w,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<l||r.length>f)throw new TypeError("Invalid program length for segwit address");const n=t[0]-d;if(n<p||n>h)throw new TypeError("Invalid version for segwit address");if(t[1]!==r.length)throw new TypeError("Invalid script for segwit address");return console.warn(y),w(r,n,e.bech32)}(t,e)}catch(t){}throw new Error(a.toASM(t)+" has no matching Address")},e.toOutputScript=function(t,e){let r,n;e=e||i.bitcoin;try{r=b(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=g(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>=p&&n.version<=h&&n.data.length>=l&&n.data.length<=f)return console.warn(y),a.compile([n.version+d,n.data])}}throw new Error(t+" has no matching Script")};const i=r(622),o=r(885),a=r(7038),s=r(8116),u=r(2343),c=r(1889),f=40,l=2,h=16,p=2,d=80,y="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 b(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 g(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 w(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)}},3966:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!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),a=r(1015),s=r(2021),u=r(8116),{typeforce:c}=u,f=new TypeError("Cannot compute merkle root for zero transactions"),l=new TypeError("Cannot compute witness commit for non-segwit block");class h{version=1;prevHash=void 0;merkleRoot=void 0;timestamp=0;witnessCommit=void 0;bits=0;nonce=0;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=s.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 a=r.getWitnessCommit();return a&&(r.witnessCommit=a),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 f;if(e&&!p(t))throw l;const r=t.map((t=>t.getHash(e))),i=(0,a.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 f;const t=h.calculateMerkleRoot(this.transactions);return 0===this.merkleRoot.compare(t)}__checkWitnessCommit(){if(!this.transactions)throw f;if(!this.hasWitnessCommit())throw l;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.varuint=void 0,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};const i=r(8116),o=r(8469);e.varuint=o;const{typeforce:a}=i;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")}function u(t,e){const r=t.readUInt32LE(e);let n=t.readUInt32LE(e+4);return n*=4294967296,s(n+r,9007199254740991),n+r}function c(t,e,r){return s(e,9007199254740991),t.writeInt32LE(-1&e,r),t.writeUInt32LE(Math.floor(e/4294967296),r+4),r+8}class f{buffer;offset;constructor(t,e=0){this.buffer=t,this.offset=e,a(i.tuple(i.Buffer,i.UInt32),[t,e])}static withCapacity(t){return new f(n.alloc(t))}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){o.encode(t,this.buffer,this.offset),this.offset+=o.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=f,e.BufferReader=class{buffer;offset;constructor(t,e=0){this.buffer=t,this.offset=e,a(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=o.decode(this.buffer,this.offset);return this.offset+=o.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.TAGGED_HASH_PREFIXES=e.TAGS=void 0,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=s,e.hash160=function(t){return n.from((0,i.ripemd160)((0,a.sha256)(Uint8Array.from(t))))},e.hash256=function(t){return n.from((0,a.sha256)((0,a.sha256)(Uint8Array.from(t))))},e.taggedHash=function(t,r){return s(n.concat([e.TAGGED_HASH_PREFIXES[t],r]))};const i=r(3238),o=r(1549),a=r(2623);function s(t){return n.from((0,a.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])}},916:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.initEccLib=function(t){var e;t?t!==i.eccLib&&(a("function"==typeof(e=t).isXOnlyPoint),a(e.isXOnlyPoint(o("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),a(e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffeeffffc2e"))),a(e.isXOnlyPoint(o("f9308a019258c31049344f85f89d5229b531c845836f99b08601f113bce036f9"))),a(e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000001"))),a(!e.isXOnlyPoint(o("0000000000000000000000000000000000000000000000000000000000000000"))),a(!e.isXOnlyPoint(o("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"))),a("function"==typeof e.xOnlyPointAddTweak),s.forEach((t=>{const r=e.xOnlyPointAddTweak(o(t.pubkey),o(t.tweak));null===t.result?a(null===r):(a(null!==r),a(r.parity===t.parity),a(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 i={},o=t=>n.from(t,"hex");function a(t){if(!t)throw new Error("ecc library invalid")}const s=[{pubkey:"79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798",tweak:"fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140",parity:-1,result:null},{pubkey:"1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b",tweak:"a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac",parity:1,result:"e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"},{pubkey:"2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991",tweak:"823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47",parity:0,result:"9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"}]},2035:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.AdvancedSignatureManager=void 0;class r{static instance;cacheBySigner=new Map;registry;constructor(){this.registry=new FinalizationRegistry((t=>{const e=this.cacheBySigner.get(t.pubKey);e&&(e.delete(t),0===e.size&&this.cacheBySigner.delete(t.pubKey))}))}static getInstance(){return r.instance||(r.instance=new r),r.instance}addSignature(t,e,r){const n={pubKey:t,dataRef:new WeakRef(e),signature:r};return this.cacheBySigner.has(t)||this.cacheBySigner.set(t,new Set),this.cacheBySigner.get(t).add(n),this.registry.register(e,n),r}getSignature(t,e){const r=this.cacheBySigner.get(t);if(r)for(const t of r){const r=t.dataRef.deref();if(r&&r.equals(e))return t.signature}}clearCache(){this.cacheBySigner.clear()}clearCacheForSigner(t){this.cacheBySigner.delete(t)}}e.AdvancedSignatureManager=r},3352:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.hookSigner=function(t){const e=t;e.hasHook||(e.hasHook=!0,e.signatureManager=new i.SignatureManager,function(t){const e=t.sign;e&&(t.sign=new Proxy(e,{apply:function(e,r,n){const i=a(t),s=n[0];if(i){let t=o.getSignature(i,s);return t||(t=o.addSignature(i,s,Reflect.apply(e,r,n))),t}{let i=t.signatureManager.getSignature(s);return i||(i=t.signatureManager.addSignature(s,Reflect.apply(e,r,n))),i}}}));const r=t.signSchnorr;r&&(t.signSchnorr=new Proxy(r,{apply:function(e,r,n){const i=a(t),s=n[0];if(i){let t=o.getSignature(i,s);return t||(t=o.addSignature(i,s,Reflect.apply(e,r,n))),t}{let i=t.signatureManager.getSignature(s);return i||(i=t.signatureManager.addSignature(s,Reflect.apply(e,r,n))),i}}}))}(e))};const i=r(7585),o=r(2035).AdvancedSignatureManager.getInstance();function a(t){if(t.publicKey&&n.isBuffer(t.publicKey))return t.publicKey.toString("hex")}},7585:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!0}),e.SignatureManager=void 0,e.SignatureManager=class{cacheByLength=new Map;registry;constructor(){this.registry=new FinalizationRegistry((t=>{const e=this.cacheByLength.get(t.length);e&&(e.delete(t),0===e.size&&this.cacheByLength.delete(t.length))}))}addSignature(t,e){const r=t.length,n={length:r,dataRef:new WeakRef(t),signature:e};return this.cacheByLength.has(r)||this.cacheByLength.set(r,new Set),this.cacheByLength.get(r).add(n),this.registry.register(t,n),e}getSignature(t){const e=t.length,r=this.cacheByLength.get(e);if(r)for(const e of r){const r=e.dataRef.deref();if(r&&r.equals(t))return e.signature}}clearCache(){this.cacheByLength.clear()}}},1757:(t,e,r)=>{e.f0=e.ZX=e.Ez=e.iL=e.K$=e.KT=e.o8=e.Et=e.hl=void 0;const n=r(57);e.hl=n;const i=r(1944);e.Et=i;const o=r(622);e.o8=o;const a=r(885);e.KT=a;const s=r(7038);e.K$=s;r(1696);var u=r(9646);Object.defineProperty(e,"iL",{enumerable:!0,get:function(){return u.Psbt}});var c=r(8417);Object.defineProperty(e,"Ez",{enumerable:!0,get:function(){return c.OPS}});var f=r(2021);Object.defineProperty(e,"ZX",{enumerable:!0,get:function(){return f.Transaction}});var l=r(916);Object.defineProperty(e,"f0",{enumerable:!0,get:function(){return l.initEccLib}})},1015:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!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 a=i[o],s=o+1===r?a:i[o+1],u=n.concat([a,s]);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.MAX_TAPTREE_DEPTH=e.LEAF_VERSION_TAPSCRIPT=void 0,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,s.isTapleaf)(e))return{hash:c(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(u(e)){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[]},e.tapleafHash=c,e.tapTweakHash=f,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=f(t,e),o=(0,i.getEccLib)().xOnlyPointAddTweak(t,r);return o&&null!==o.xOnlyPubkey?{parity:o.parity,x:n.Buffer.from(o.xOnlyPubkey)}:null};const n=r(8287),i=r(916),o=r(1944),a=r(606),s=r(8116);e.LEAF_VERSION_TAPSCRIPT=192,e.MAX_TAPTREE_DEPTH=128;const u=t=>"left"in t&&"right"in t;function c(t){const r=t.version||e.LEAF_VERSION_TAPSCRIPT;return o.taggedHash("TapLeaf",n.Buffer.concat([n.Buffer.from([r]),h(t.output)]))}function f(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 h(t){const e=a.varuint.encodingLength(t.length),r=n.Buffer.allocUnsafe(e);return a.varuint.encode(t.length,r),n.Buffer.concat([r,t])}},5472:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),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(a.prop(r,"output",(()=>{if(t.data)return i.compile([s.OP_RETURN].concat(t.data))})),a.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]!==s.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&&!(0,o.stacksEqual)(t.data,r.data))throw new TypeError("Data mismatch")}return Object.assign(r,t)};const n=r(622),i=r(7038),o=r(8116),a=r(7883),s=i.OPS},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 a=r(3504);Object.defineProperty(e,"p2pkh",{enumerable:!0,get:function(){return a.p2pkh}});const s=r(8368);Object.defineProperty(e,"p2sh",{enumerable:!0,get:function(){return s.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 f=r(5501);Object.defineProperty(e,"p2tr",{enumerable:!0,get:function(){return f.p2tr}})},7883:(t,e)=>{Object.defineProperty(e,"__esModule",{value:!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=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===s.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 c={network:t.network||n.bitcoin};let f=[],l=!1;function h(t){l||(l=!0,f=i.decompile(t),c.m=f[0]-u,c.n=f[f.length-2]-u,c.pubkeys=f.slice(1,-2))}if(a.prop(c,"output",(()=>{if(t.m&&c.n&&t.pubkeys)return i.compile([].concat(u+t.m,t.pubkeys,u+c.n,s.OP_CHECKMULTISIG))})),a.prop(c,"m",(()=>{if(c.output)return h(c.output),c.m})),a.prop(c,"n",(()=>{if(c.pubkeys)return c.pubkeys.length})),a.prop(c,"pubkeys",(()=>{if(t.output)return h(t.output),c.pubkeys})),a.prop(c,"signatures",(()=>{if(t.input)return i.decompile(t.input).slice(1)})),a.prop(c,"input",(()=>{if(t.signatures)return i.compile([s.OP_0].concat(t.signatures))})),a.prop(c,"witness",(()=>{if(c.input)return[]})),a.prop(c,"name",(()=>{if(c.m&&c.n)return`p2ms(${c.m} of ${c.n})`})),e.validate){if(t.output){if(h(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]!==s.OP_CHECKMULTISIG)throw new TypeError("Output is invalid");if(c.m<=0||c.n>16||c.m>c.n||c.n!==f.length-3)throw new TypeError("Output is invalid");if(!c.pubkeys.every((t=>(0,o.isPoint)(t))))throw new TypeError("Output is invalid");if(void 0!==t.m&&t.m!==c.m)throw new TypeError("m mismatch");if(void 0!==t.n&&t.n!==c.n)throw new TypeError("n mismatch");if(t.pubkeys&&!(0,o.stacksEqual)(t.pubkeys,c.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(c.n=t.pubkeys.length,c.n<c.m)throw new TypeError("Pubkey count cannot be less than m")}if(t.signatures){if(t.signatures.length<c.m)throw new TypeError("Not enough signatures provided");if(t.signatures.length>c.m)throw new TypeError("Too many signatures provided")}if(t.input){if(t.input[0]!==s.OP_0)throw new TypeError("Input is invalid");if(0===c.signatures.length||!c.signatures.every(r))throw new TypeError("Input has invalid signature(s)");if(t.signatures&&!(0,o.stacksEqual)(t.signatures,c.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(c,t)};const n=r(622),i=r(7038),o=r(8116),a=r(7883),s=i.OPS,u=s.OP_RESERVED},4930:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),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=a.value((()=>i.decompile(t.input))),u={name:"p2pk",network:t.network||n.bitcoin};if(a.prop(u,"output",(()=>{if(t.pubkey)return i.compile([t.pubkey,s.OP_CHECKSIG])})),a.prop(u,"pubkey",(()=>{if(t.output)return t.output.slice(1,-1)})),a.prop(u,"signature",(()=>{if(t.input)return r()[0]})),a.prop(u,"input",(()=>{if(t.signature)return i.compile([t.signature])})),a.prop(u,"witness",(()=>{if(u.input)return[]})),e.validate){if(t.output){if(t.output[t.output.length-1]!==s.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)};const n=r(622),i=r(7038),o=r(8116),a=r(7883),s=i.OPS},3504:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),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,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(20)),output:s.typeforce.maybe(s.typeforce.BufferN(25)),pubkey:s.typeforce.maybe(s.isPoint),signature:s.typeforce.maybe(a.isCanonicalScriptSignature),input:s.typeforce.maybe(s.typeforce.Buffer)},t);const r=u.value((()=>{const e=n.from(c.decode(t.address));return{version:e.readUInt8(0),hash:e.slice(1)}})),l=u.value((()=>a.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 a.compile([f.OP_DUP,f.OP_HASH160,p.hash,f.OP_EQUALVERIFY,f.OP_CHECKSIG])})),u.prop(p,"pubkey",(()=>{if(t.input)return l()[1]})),u.prop(p,"signature",(()=>{if(t.input)return l()[0]})),u.prop(p,"input",(()=>{if(t.pubkey&&t.signature)return a.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]!==f.OP_DUP||t.output[1]!==f.OP_HASH160||20!==t.output[2]||t.output[23]!==f.OP_EQUALVERIFY||t.output[24]!==f.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=l();if(2!==r.length)throw new TypeError("Input is invalid");if(!a.isCanonicalScriptSignature(r[0]))throw new TypeError("Input has invalid signature");if(!(0,s.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)};const i=r(1944),o=r(622),a=r(7038),s=r(8116),u=r(7883),c=r(1889),f=a.OPS},8368:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),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,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(20)),output:s.typeforce.maybe(s.typeforce.BufferN(23)),redeem:s.typeforce.maybe({network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.Buffer),input:s.typeforce.maybe(s.typeforce.Buffer),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),input:s.typeforce.maybe(s.typeforce.Buffer),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))},t);let r=t.network;r||(r=t.redeem&&t.redeem.network||o.bitcoin);const l={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((()=>a.decompile(t.input))),d=u.value((()=>{const e=p(),i=e[e.length-1];return{network:r,output:i===f.OP_FALSE?n.from([]):i,input:a.compile(e.slice(0,-1)),witness:t.witness||[]}}));if(u.prop(l,"address",(()=>{if(!l.hash)return;const t=n.allocUnsafe(21);return t.writeUInt8(l.network.scriptHash,0),l.hash.copy(t,1),c.encode(t)})),u.prop(l,"hash",(()=>t.output?t.output.slice(2,22):t.address?h().hash:l.redeem&&l.redeem.output?i.hash160(l.redeem.output):void 0)),u.prop(l,"output",(()=>{if(l.hash)return a.compile([f.OP_HASH160,l.hash,f.OP_EQUAL])})),u.prop(l,"redeem",(()=>{if(t.input)return d()})),u.prop(l,"input",(()=>{if(t.redeem&&t.redeem.input&&t.redeem.output)return a.compile([].concat(a.decompile(t.redeem.input),t.redeem.output))})),u.prop(l,"witness",(()=>l.redeem&&l.redeem.witness?l.redeem.witness:l.input?[]:void 0)),u.prop(l,"name",(()=>{const t=["p2sh"];return void 0!==l.redeem&&void 0!==l.redeem.name&&t.push(l.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]!==f.OP_HASH160||20!==t.output[1]||t.output[22]!==f.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=a.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(a.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=a.decompile(t.input);if(!a.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&&!(0,s.stacksEqual)(t.redeem.witness,t.witness))throw new TypeError("Witness and redeem.witness mismatch")}return Object.assign(l,t)};const i=r(1944),o=r(622),a=r(7038),s=r(8116),u=r(7883),c=r(1889),f=a.OPS},5501:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),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,a.typeforce)({address:a.typeforce.maybe(a.typeforce.String),input:a.typeforce.maybe(a.typeforce.BufferN(0)),network:a.typeforce.maybe(a.typeforce.Object),output:a.typeforce.maybe(a.typeforce.BufferN(34)),internalPubkey:a.typeforce.maybe(a.typeforce.BufferN(32)),hash:a.typeforce.maybe(a.typeforce.BufferN(32)),pubkey:a.typeforce.maybe(a.typeforce.BufferN(32)),signature:a.typeforce.maybe(a.typeforce.anyOf(a.typeforce.BufferN(64),a.typeforce.BufferN(65))),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer)),scriptTree:a.typeforce.maybe(a.isTaptree),redeem:a.typeforce.maybe({output:a.typeforce.maybe(a.typeforce.Buffer),redeemVersion:a.typeforce.maybe(a.typeforce.Number),witness:a.typeforce.maybe(a.typeforce.arrayOf(a.typeforce.Buffer))}),redeemVersion:a.typeforce.maybe(a.typeforce.Number)},t);const r=c.value((()=>(0,l.fromBech32)(t.address))),y=c.value((()=>{if(t.witness&&t.witness.length)return t.witness.length>=2&&t.witness[t.witness.length-1][0]===d?t.witness.slice(0,-1):t.witness.slice()})),b=c.value((()=>t.scriptTree?(0,u.toHashTree)(t.scriptTree):t.hash?{hash:t.hash}:void 0)),g=t.network||i.bitcoin,w={name:"p2tr",network:g};if(c.prop(w,"address",(()=>{if(!w.pubkey)return;const t=f.bech32m.toWords(w.pubkey);return t.unshift(p),f.bech32m.encode(g.bech32,t)})),c.prop(w,"hash",(()=>{const t=b();if(t)return t.hash;const e=y();if(e&&e.length>1){const t=e[e.length-1],r=t[0]&a.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(w,"output",(()=>{if(w.pubkey)return o.compile([h.OP_1,w.pubkey])})),c.prop(w,"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(w,"redeem",(()=>{const t=y();if(t&&!(t.length<2))return{output:t[t.length-2],witness:t.slice(0,-2),redeemVersion:t[t.length-1][0]&a.TAPLEAF_VERSION_MASK}})),c.prop(w,"pubkey",(()=>{if(t.pubkey)return t.pubkey;if(t.output)return t.output.slice(2);if(t.address)return r().data;if(w.internalPubkey){const t=(0,u.tweakKey)(w.internalPubkey,w.hash);if(t)return t.x}})),c.prop(w,"internalPubkey",(()=>{if(t.internalPubkey)return t.internalPubkey;const e=y();return e&&e.length>1?e[e.length-1].slice(1,33):void 0})),c.prop(w,"signature",(()=>{if(t.signature)return t.signature;const e=y();return e&&1===e.length?e[0]:void 0})),c.prop(w,"witness",(()=>{if(t.witness)return t.witness;const e=b();if(e&&t.redeem&&t.redeem.output&&t.internalPubkey){const r=(0,u.tapleafHash)({output:t.redeem.output,version:w.redeemVersion}),i=(0,u.findScriptPath)(e,r);if(!i)return;const o=(0,u.tweakKey)(t.internalPubkey,e.hash);if(!o)return;const a=n.Buffer.concat([n.Buffer.from([w.redeemVersion|o.parity]),t.internalPubkey].concat(i));return[t.redeem.output,a]}return t.signature?[t.signature]:void 0})),e.validate){let e=n.Buffer.from([]);if(t.address){if(g&&g.bech32!==r().prefix)throw new TypeError("Invalid prefix or Network mismatch");if(r().version!==p)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]!==h.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,w.hash);if(e.length>0&&!e.equals(r.x))throw new TypeError("Pubkey mismatch");e=r.x}if(e&&e.length&&!(0,s.getEccLib)().isXOnlyPoint(e))throw new TypeError("Invalid pubkey for p2tr");const i=b();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:w.redeemVersion});if(!(0,u.findScriptPath)(i,e))throw new TypeError("Redeem script not in tree")}const c=y();if(t.redeem&&w.redeem){if(t.redeem.redeemVersion&&t.redeem.redeemVersion!==w.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(w.redeem.output&&!t.redeem.output.equals(w.redeem.output))throw new TypeError("Redeem.output and witness mismatch")}if(t.redeem.witness&&w.redeem.witness&&!(0,a.stacksEqual)(t.redeem.witness,w.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,s.getEccLib)().isXOnlyPoint(i))throw new TypeError("Invalid internalPubkey for p2tr witness");const o=r[0]&a.TAPLEAF_VERSION_MASK,f=c[c.length-2],l=(0,u.tapleafHash)({output:f,version:o}),h=(0,u.rootHashFromPath)(r,l),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(w,t)};const n=r(8287),i=r(622),o=r(7038),a=r(8116),s=r(916),u=r(2218),c=r(7883),f=r(2343),l=r(57),h=o.OPS,p=1,d=80},7027:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!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,s.typeforce)({address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(20)),input:s.typeforce.maybe(s.typeforce.BufferN(0)),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.BufferN(22)),pubkey:s.typeforce.maybe(s.isPoint),signature:s.typeforce.maybe(a.isCanonicalScriptSignature),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.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 a.compile([f.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 l})),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]!==f.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,s.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(!a.isCanonicalScriptSignature(t.witness[0]))throw new TypeError("Witness has invalid signature");if(!(0,s.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)};const i=r(1944),o=r(622),a=r(7038),s=r(8116),u=r(7883),c=r(2343),f=a.OPS,l=n.alloc(0)},9041:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),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,s.typeforce)({network:s.typeforce.maybe(s.typeforce.Object),address:s.typeforce.maybe(s.typeforce.String),hash:s.typeforce.maybe(s.typeforce.BufferN(32)),output:s.typeforce.maybe(s.typeforce.BufferN(34)),redeem:s.typeforce.maybe({input:s.typeforce.maybe(s.typeforce.Buffer),network:s.typeforce.maybe(s.typeforce.Object),output:s.typeforce.maybe(s.typeforce.Buffer),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.typeforce.Buffer))}),input:s.typeforce.maybe(s.typeforce.BufferN(0)),witness:s.typeforce.maybe(s.typeforce.arrayOf(s.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((()=>a.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 a.compile([f.OP_0,y.hash])})),u.prop(y,"redeem",(()=>{if(t.witness)return{output:t.witness[t.witness.length-1],input:l,witness:t.witness.slice(0,-1)}})),u.prop(y,"input",(()=>{if(y.witness)return l})),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=a.toStack(p());return y.redeem=Object.assign({witness:e},t.redeem),y.redeem.input=l,[].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]!==f.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=a.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(a.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&&!a.isPushOnly(p()))throw new TypeError("Non push-only scriptSig");if(t.witness&&t.redeem.witness&&!(0,s.stacksEqual)(t.witness,t.redeem.witness))throw new TypeError("Witness and redeem.witness mismatch");if(t.redeem.input&&p().some(h)||t.redeem.output&&(a.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)||(a.decompile(e)||[]).some(h))throw new TypeError("Witness contains uncompressed pubkey")}}return Object.assign(y,t)};const i=r(1944),o=r(622),a=r(7038),s=r(8116),u=r(7883),c=r(2343),f=a.OPS,l=n.alloc(0);function h(t){return!(!n.isBuffer(t)||65!==t.length||4!==t[0]||!(0,s.isPoint)(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),a=r(5080),s=r(57),u=r(606),c=r(622),f=r(885),l=r(2218),h=r(7038),p=r(2021),d=r(477),y=r(4929),b=r(3352),g={network:c.bitcoin,maximumFeeRate:5e3};class w{data;__CACHE;opts;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,s.fromOutputScript)(t.script,this.opts.network)}catch(t){}return{script:(0,u.cloneBuffer)(t.script),value:t.value,address:e}}))}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,v),n=new w(e,r);var o,a;return o=n.__CACHE.__TX,a=n.__CACHE,o.ins.forEach((t=>{A(a,t)})),n}combine(...t){return this.data.combine(...t.map((t=>t.data))),this}clone(){return w.fromBuffer(this.data.toBuffer(),JSON.parse(JSON.stringify(this.opts)))}setMaximumFeeRate(t){T(t),this.opts.maximumFeeRate=t}setVersion(t){T(t),O(this.data.inputs,"setVersion");const e=this.__CACHE;return e.__TX.version=t,e.__EXTRACTED_TX=void 0,this}setLocktime(t){T(t),O(this.data.inputs,"setLocktime");const e=this.__CACHE;return e.__TX.locktime=t,e.__EXTRACTED_TX=void 0,this}setInputSequence(t,e){T(e),O(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,e=!0){return t.forEach((t=>this.addInput(t,e))),this}addInput(t,e=!0){if(!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"),e&&O(this.data.inputs,"addInput"),t.witnessScript&&$(t.witnessScript);const r=this.__CACHE;this.data.addInput(t),A(r,r.__TX.ins[r.__TX.ins.length-1]);const n=this.data.inputs.length-1,i=this.data.inputs[n];return i.nonWitnessUtxo&&K(this.__CACHE,i,n),r.__FEE=void 0,r.__FEE_RATE=void 0,r.__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]");O(this.data.inputs,"addOutput");const{address:e}=t;if("string"==typeof e){const{network:r}=this.opts,n=(0,s.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,e){if(e&&(this.data.inputs=this.data.inputs.filter((t=>!t.partialSig))),!this.data.inputs.every(S))throw new Error("Not finalized");const r=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,r,this.opts),r.__EXTRACTED_TX)return r.__EXTRACTED_TX;const n=r.__TX.clone();return W(this.data.inputs,n,r,!0,e),n}getFeeRate(t=!1){return L("__FEE_RATE","fee rate",this.data.inputs,this.__CACHE,t)}getFee(t=!1){return L("__FEE","fee",this.data.inputs,this.__CACHE,t)}finalizeAllInputs(){return(0,a.checkForInput)(this.data.inputs,0),Z(this.data.inputs.length).forEach((t=>this.finalizeInput(t))),this}finalizeInput(t,e){const r=(0,a.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,a.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.`)}getInputType(t){const e=(0,a.checkForInput)(this.data.inputs,t),r=X(V(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)&&!q(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!q(r)&&h.decompile(r)?r:void 0}(e.finalScriptWitness));return("raw"===r.type?"":r.type+"-")+Y(r.meaningfulScript)}inputHasPubkey(t,e){return function(t,e,r,n){const i=V(r,e,n),{meaningfulScript:o}=X(i,r,"input",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,a.checkForInput)(this.data.inputs,t),t,this.__CACHE)}inputHasHDKey(t,e){const r=(0,a.checkForInput)(this.data.inputs,t),n=k(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}=X(i,r,"output",e.redeemScript,e.witnessScript);return(0,y.pubkeyInScript)(t,o)}(e,(0,a.checkForOutput)(this.data.outputs,t),t,this.__CACHE)}outputHasHDKey(t,e){const r=(0,a.checkForOutput)(this.data.outputs,t),n=k(e);return!!r.bip32Derivation&&r.bip32Derivation.some(n)}validateSignaturesOfAllInputs(t){return(0,a.checkForInput)(this.data.inputs,0),Z(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)}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 Z(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 Z(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 D(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=D(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 Z(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,a.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,a.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.`)}signInputAsync(t,e,r){return Promise.resolve().then((()=>{if(!e||!e.publicKey)throw new Error("Need Signer to sign input");const n=(0,a.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,a.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.`)}))}toBuffer(){return _(this.__CACHE),this.data.toBuffer()}toHex(){return _(this.__CACHE),this.data.toHex()}toBase64(){return _(this.__CACHE),this.data.toBase64()}updateGlobal(t){return this.data.updateGlobal(t),this}updateInput(t,e){return e.witnessScript&&$(e.witnessScript),(0,d.checkTaprootInputFields)(this.data.inputs[t],e,"updateInput"),this.data.updateInput(t,e),e.nonWitnessUtxo&&K(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}_finalizeInput(t,e,r=B){const{script:n,isP2SH:i,isP2WSH:o,isSegwit:a}=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=G(r,e,t),a=n.ins[t].index;i.script=o.outs[a].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:s,finalScriptWitness:u}=r(t,e,n,a,i,o);if(s&&this.data.updateInput(t,{finalScriptSig:s}),u&&this.data.updateInput(t,{finalScriptWitness:u}),!s&&!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=f.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}_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 a=[];let s,u,c;for(const r of o){const i=h.signature.decode(r.signature),{hash:o,script:f}=c!==i.hashType?N(t,Object.assign({},n,{sighashType:i.hashType}),this.__CACHE,!0):{hash:s,script:u};c=i.hashType,s=o,u=f,x(r.pubkey,f,"verify"),a.push(e(r.pubkey,o,i.signature))}return a.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 a=(r=r&&(0,d.toXOnly)(r))?F(t,n,this.data.inputs,r,this.__CACHE):function(t,e,r,n){const i=[];if(e.tapInternalKey){const r=j(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=>F(t,e,r,i,n))).flat()}(t,n,this.data.inputs,this.__CACHE);if(!a.length)throw new Error("No signatures for this pubkey");const s=a.find((t=>!t.leafHash));let u=0;if(i&&s){if(!e(s.pubkey,s.hash,C(i)))return!1;u++}if(o)for(const t of o){const r=a.find((e=>t.pubkey.equals(e.pubkey)));if(r){if(!e(t.pubkey,r.hash,C(t.signature)))return!1;u++}}return u>0}_signInput(t,e,r=[p.Transaction.SIGHASH_ALL]){(0,b.hookSigner)(e);const{hash:n,sighashType:i}=U(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]){(0,b.hookSigner)(r);const o=this.checkTaprootHashesForSig(t,e,r,n,i),a=o.filter((t=>!t.leafHash)).map((t=>(0,d.serializeTaprootSignature)(r.signSchnorr(t.hash),e.sighashType)))[0],s=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 a&&this.data.updateInput(t,{tapKeySig:a}),s.length&&this.data.updateInput(t,{tapScriptSig:s}),this}_signInputAsync(t,e,r=[p.Transaction.SIGHASH_ALL]){(0,b.hookSigner)(e);const{hash:n,sighashType:i}=U(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]){(0,b.hookSigner)(r);const o=this.checkTaprootHashesForSig(t,e,r,n,i),a=[],s=o.filter((t=>!t.leafHash))[0];if(s){const t=Promise.resolve(r.signSchnorr(s.hash)).then((t=>({tapKeySig:(0,d.serializeTaprootSignature)(t,e.sighashType)})));a.push(t)}const u=o.filter((t=>!!t.leafHash));if(u.length){const t=u.map((async t=>{const n=await r.signSchnorr(t.hash);return{tapScriptSig:[{pubkey:(0,d.toXOnly)(r.publicKey),signature:(0,d.serializeTaprootSignature)(n,e.sighashType),leafHash:t.leafHash}]}}));a.push(...t)}const c=await Promise.all(a);for(const e of c)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=F(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}}e.Psbt=w;const v=t=>new m(t);class m{tx;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 _(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 S(t){return!!t.finalScriptSig||!!t.finalScriptWitness}function k(t){return e=>!!e.masterFingerprint.equals(t.fingerprint)&&!!t.derivePath(e.path).publicKey.equals(e.pubkey)}function T(t){if("number"!=typeof t||t!==Math.floor(t)||t>4294967295||t<0)throw new Error("Invalid 32 bit integer")}function O(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 x(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 A(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 P(t,e){return(r,n,i,o)=>{const a=t({redeem:{output:i}}).output;if(!n.equals(a))throw new Error(`${e} for ${o} #${r} doesn't match the scriptPubKey in the prevout`)}}const I=P(f.p2sh,"Redeem script"),R=P(f.p2wsh,"Witness script");function L(t,e,r,n,i=!1){if(!r.every(S))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 o,a=!0;return n.__EXTRACTED_TX?(o=n.__EXTRACTED_TX,a=!1):o=n.__TX.clone(),W(r,o,n,a,i),"__FEE_RATE"===t?n.__FEE_RATE:"__FEE"===t?n.__FEE:void 0}function B(t,e,r,n,i,o){const a=Y(r);if(!function(t,e,r){switch(r){case"pubkey":case"pubkeyhash":case"witnesspubkeyhash":return E(1,t.partialSig);case"multisig":const r=f.p2ms({output:e});return E(r.m,t.partialSig,r.pubkeys);default:return!1}}(e,r,a))throw new Error(`Can not finalize input #${t}`);return function(t,e,r,n,i,o){let a,s;const u=function(t,e,r){let n;switch(e){case"multisig":const e=function(t,e){return f.p2ms({output:t}).pubkeys.map((t=>(e.filter((e=>e.pubkey.equals(t)))[0]||{}).signature)).filter((t=>!!t))}(t,r);n=f.p2ms({output:t,signatures:e});break;case"pubkey":n=f.p2pk({output:t,signature:r[0].signature});break;case"pubkeyhash":n=f.p2pkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature});break;case"witnesspubkeyhash":n=f.p2wpkh({output:t,pubkey:r[0].pubkey,signature:r[0].signature})}return n}(t,e,r),c=o?f.p2wsh({redeem:u}):null,l=i?f.p2sh({redeem:c||u}):null;return n?(s=c?(0,y.witnessStackToScriptWitness)(c.witness):(0,y.witnessStackToScriptWitness)(u.witness),l&&(a=l.input)):a=l?l.input:u.input,{finalScriptSig:a,finalScriptWitness:s}}(r,a,e.partialSig,n,i,o)}function U(t,e,r,n,i){const o=(0,a.checkForInput)(t,e),{hash:s,sighashType:u,script:c}=N(e,o,n,!1,i);return x(r,c,"sign"),{hash:s,sighashType:u}}function N(t,e,r,n,i){const o=r.__TX,a=e.sighashType||p.Transaction.SIGHASH_ALL;let s,u;if(M(a,i),e.nonWitnessUtxo){const n=G(r,e,t),i=o.ins[t].hash,a=n.getHash();if(!i.equals(a))throw new Error(`Non-witness UTXO hash for input #${t} doesn't match the hash specified in the prevout`);const s=o.ins[t].index;u=n.outs[s]}else{if(!e.witnessUtxo)throw new Error("Need a Utxo input item for signing");u=e.witnessUtxo}const{meaningfulScript:c,type:l}=X(u.script,t,"input",e.redeemScript,e.witnessScript);if(["p2sh-p2wsh","p2wsh"].indexOf(l)>=0)s=o.hashForWitnessV0(t,c,u.value,a);else if((0,y.isP2WPKH)(c)){const e=f.p2pkh({hash:c.slice(2)}).output;s=o.hashForWitnessV0(t,e,u.value,a)}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 predecessor (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*********************"),s=o.hashForSignature(t,c,a)}return{script:c,sighashType:a,hash:s}}function j(t,e,r){const{script:n}=z(t,e,r);return(0,y.isP2TR)(n)?n.subarray(2,34):null}function C(t){return 64===t.length?t:t.subarray(0,64)}function F(t,e,r,i,o,a,s){const u=o.__TX,c=e.sighashType||p.Transaction.SIGHASH_DEFAULT;M(c,s);const f=r.map(((t,e)=>z(e,t,o))),h=f.map((t=>t.script)),b=f.map((t=>t.value)),g=[];if(e.tapInternalKey&&!a){const r=j(t,e,o)||n.from([]);if((0,d.toXOnly)(i).equals(r)){const e=u.hashForWitnessV1(t,h,b,c);g.push({pubkey:i,hash:e})}}const w=(e.tapLeafScript||[]).filter((t=>(0,y.pubkeyInScript)(i,t.script))).map((t=>{const e=(0,l.tapleafHash)({output:t.script,version:t.leafVersion});return Object.assign({hash:e},t)})).filter((t=>!a||a.equals(t.hash))).map((e=>{const r=u.hashForWitnessV1(t,h,b,c,e.hash);return{pubkey:i,hash:r,leafHash:e.hash}}));return g.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 D(t,e,r){const n=(0,a.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 o=0;o<n;o++)i.push(function(r){return e+=r,t.slice(e-r,e)}(r()));return i}()}function K(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 W(t,e,r,n,i){let o=0;t.forEach(((t,i)=>{if(n&&t.finalScriptSig&&(e.ins[i].script=t.finalScriptSig),n&&t.finalScriptWitness&&(e.ins[i].witness=H(t.finalScriptWitness)),t.witnessUtxo)o+=t.witnessUtxo.value;else if(t.nonWitnessUtxo){const n=G(r,t,i),a=e.ins[i].index,s=n.outs[a];o+=s.value}}));const a=e.outs.reduce(((t,e)=>t+e.value),0),s=o-a;if(!i&&s<0)throw new Error("Outputs are spending more than Inputs");const u=e.virtualSize();r.__FEE=s,r.__EXTRACTED_TX=e,r.__FEE_RATE=Math.floor(s/u)}function G(t,e,r){const n=t.__NON_WITNESS_UTXO_TX_CACHE;return n[r]||K(t,e,r),n[r]}function V(t,e,r){const{script:n}=z(t,e,r);return n}function z(t,e,r){if(void 0!==e.witnessUtxo)return{script:e.witnessUtxo.script,value:e.witnessUtxo.value};if(void 0!==e.nonWitnessUtxo){const n=G(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 q(t){return 33===t.length&&h.isCanonicalPubKey(t)}function X(t,e,r,n,i){const o=(0,y.isP2SHScript)(t),a=o&&n&&(0,y.isP2WSHScript)(n),s=(0,y.isP2WSHScript)(t);if(o&&void 0===n)throw new Error("scriptPubkey is P2SH but redeemScript missing");if((s||a)&&void 0===i)throw new Error("scriptPubkey or redeemScript is P2WSH but witnessScript missing");let u;return a?(u=i,I(e,t,n,r),R(e,n,i,r),$(u)):s?(u=i,R(e,t,i,r),$(u)):o?(u=n,I(e,t,n,r)):u=t,{meaningfulScript:u,type:a?"p2sh-p2wsh":o?"p2sh":s?"p2wsh":"raw"}}function $(t){if((0,y.isP2WPKH)(t)||(0,y.isP2SHScript)(t))throw new Error("P2WPKH or P2SH can not be contained within P2WSH")}function Y(t){return(0,y.isP2WPKH)(t)?"witnesspubkeyhash":(0,y.isP2PKH)(t)?"pubkeyhash":(0,y.isP2MS)(t)?"multisig":(0,y.isP2PK)(t)?"pubkey":"nonstandard"}function Z(t){return[...Array(t).keys()]}},477:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.toXOnly=void 0,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,s.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,s.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,a.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,a.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=c,e.isTaprootOutput=f,e.checkTaprootInputFields=function(t,e,r){(function(t,e,r){const n=c(t)&&g(e),i=g(t)&&c(e),o=t===e&&c(e)&&g(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=>b(t,e.tapMerkleRoot))),i=(t.tapLeafScript||[]).every((t=>b(t,e.tapMerkleRoot)));if(!n||!i)throw new Error(`Invalid arguments for Psbt.${r}. Tapleaf not part of taptree.`)}else if(t.tapMerkleRoot){const n=(e.tapLeafScript||[]).every((e=>b(e,t.tapMerkleRoot)));if(!n)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)&&g(e),i=g(t)&&f(e),o=t===e&&f(e)&&g(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&&l(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,s.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=l,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=p(t.finalScriptWitness);r&&e.push(r)}return e}(t).some((t=>(0,a.signatureBlocksAction)(t,h,e)))},e.getTapKeySigFromWithness=p;const i=r(8116),o=r(2021),a=r(4929),s=r(2218),u=r(885);function c(t){return t&&!!(t.tapInternalKey||t.tapMerkleRoot||t.tapLeafScript&&t.tapLeafScript.length||t.tapBip32Derivation&&t.tapBip32Derivation.length||t.witnessUtxo&&(0,a.isP2TR)(t.witnessUtxo.script))}function f(t,e){return t&&!!(t.tapInternalKey||t.tapTree||t.tapBip32Derivation&&t.tapBip32Derivation.length||e&&(0,a.isP2TR)(e))}function l(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 h(t){return{signature:t.slice(0,64),hashType:t.slice(64)[0]||o.Transaction.SIGHASH_DEFAULT}}function p(t){if(!t)return;const e=t.slice(2);return 64===e.length||65===e.length?e:void 0}function d(t,e=[],r=0){if(r>s.MAX_TAPTREE_DEPTH)throw new Error("Max taptree depth exceeded.");return t?(0,i.isTapleaf)(t)?(e.push({depth:r,leafVersion:t.version||s.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>s.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 b(t,e){if(!e)return!0;const r=(0,s.tapleafHash)({output:t.script,version:t.leafVersion});return(0,s.rootHashFromPath)(t.controlBlock,r).equals(e)}function g(t){return t&&!!(t.redeemScript||t.witnessScript||t.bip32Derivation&&t.bip32Derivation.length)}e.toXOnly=t=>32===t.length?t:t.slice(1,33)},4929:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.isP2TR=e.isP2SHScript=e.isP2WSHScript=e.isP2WPKH=e.isP2PKH=e.isP2PK=e.isP2MS=void 0,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)}function o(t){r(t.length),function(t){e=n.concat([e,n.from(t)])}(t)}return r((a=t).length),a.forEach(o),e;var a},e.pubkeyPositionInScript=f,e.pubkeyInScript=function(t,e){return-1!==f(t,e)},e.checkInputForSig=function(t,e){return function(t){let e=[];if(0===(t.partialSig||[]).length){if(!t.finalScriptSig&&!t.finalScriptWitness)return[];e=h(t)}else e=t.partialSig;return e.map((t=>t.signature))}(t).some((t=>l(t,o.signature.decode,e)))},e.signatureBlocksAction=l,e.getPsigsFromInputFinalScripts=h;const i=r(394),o=r(7038),a=r(2021),s=r(1944),u=r(885);function c(t){return e=>{try{return t({output:e}),!0}catch(t){return!1}}}function f(t,e){const r=(0,s.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 l(t,e,r){const{hashType:n}=e(t),i=[];switch(n&a.Transaction.SIGHASH_ANYONECANPAY&&i.push("addInput"),31&n){case a.Transaction.SIGHASH_ALL:break;case a.Transaction.SIGHASH_SINGLE:case a.Transaction.SIGHASH_NONE:i.push("addOutput"),i.push("setInputSequence")}return-1===i.indexOf(r)}function h(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})))}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)},4344:(t,e,r)=>{Object.defineProperty(e,"__esModule",{value:!0}),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}};const n=r(8417);function i(t){return t<n.OPS.OP_PUSHDATA1?1:t<=255?2:t<=65535?3:5}},7038:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.signature=e.number=e.OPS=void 0,e.isPushOnly=p,e.countNonPushOnlyOPs=function(t){return t.length-t.filter(h).length},e.compile=g,e.decompile=w,e.toASM=function(t){if(y(t)&&(t=w(t)),!t)throw new Error("Could not convert invalid chunks to ASM");return t.map((t=>{if(b(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 f(c.String,t),g(t.split(" ").map((t=>void 0!==o.OPS[t]?o.OPS[t]:(f(c.Hex,t),n.from(t,"hex")))))},e.toStack=function(t){return t=w(t),f(p,t),t.map((t=>b(t)?t:t===o.OPS.OP_0?n.allocUnsafe(0):s.encode(t-l)))},e.isCanonicalPubKey=function(t){return c.isPoint(t)},e.isDefinedHashType=v,e.isCanonicalScriptSignature=function(t){return!!n.isBuffer(t)&&!!v(t[t.length-1])&&i.check(t.slice(0,-1))};const i=r(3966),o=r(8417);Object.defineProperty(e,"OPS",{enumerable:!0,get:function(){return o.OPS}});const a=r(4344),s=r(9464),u=r(1043),c=r(8116),{typeforce:f}=c,l=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?l+t[0]:129===t[0]?o.OPS.OP_1NEGATE:void 0:void 0}function y(t){return n.isBuffer(t)}function b(t){return n.isBuffer(t)}function g(t){if(y(t))return t;f(c.Array,t);const e=t.reduce(((t,e)=>b(e)?1===e.length&&void 0!==d(e)?t+1:t+a.encodingLength(e.length)+e.length:t+1),0),r=n.allocUnsafe(e);let i=0;if(t.forEach((t=>{if(b(t)){const e=d(t);if(void 0!==e)return r.writeUInt8(e,i),void(i+=1);i+=a.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;f(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=a.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 v(t){const e=-129&t;return e>0&&e<4}e.number=s,e.signature=u},9464:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!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=function(t){return t>2147483647?5:t>8388607?4:t>32767?3:t>127?2:t>0?1:0}(e),i=n.allocUnsafe(r),o=t<0;for(let t=0;t<r;++t)i.writeUInt8(255&e,t),e>>=8;return 128&i[r-1]?i.writeUInt8(o?128:0,r-1):o&&(i[r-1]|=128),i}},1043:(t,e,r)=>{var n=r(8287).Buffer;Object.defineProperty(e,"__esModule",{value:!0}),e.decode=function(t){const e=t.readUInt8(t.length-1);if(!(0,o.isDefinedHashType)(e))throw new Error("Invalid hashType "+e);const r=i.decode(t.slice(0,-1)),a=f(r.r),s=f(r.s);return{signature:n.concat([a,s],64),hashType:e}},e.encode=function(t,e){if(s({signature:a.BufferN(64),hashType:a.UInt8},{signature:t,hashType:e}),!(0,o.isDefinedHashType)(e))throw new Error("Invalid hashType "+e);const r=n.allocUnsafe(1);r.writeUInt8(e,0);const u=c(t.slice(0,32)),f=c(t.slice(32,64));return n.concat([i.encode(u,f),r])};const i=r(3966),o=r(7038),a=r(8116),{typeforce:s}=a,u=n.alloc(1,0);function c(t){let e=0;for(;0===t[e];)++e;return e===t.length?u:128&(t=t.slice(e))[0]?n.concat([u,t],1+t.length):t}function f(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}},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),a=r(7038),s=r(7038),u=r(8116),{typeforce:c}=u;function f(t){const e=t.length;return i.varuint.encodingLength(e)+e}const l=n.allocUnsafe(0),h=[],p=n.from("0000000000000000000000000000000000000000000000000000000000000000","hex"),d=n.from("0000000000000000000000000000000000000000000000000000000000000001","hex"),y=n.from("ffffffffffffffff","hex"),b={script:l,valueBuffer:y};class g{static DEFAULT_SEQUENCE=4294967295;static SIGHASH_DEFAULT=0;static SIGHASH_ALL=1;static SIGHASH_NONE=2;static SIGHASH_SINGLE=3;static SIGHASH_ANYONECANPAY=128;static SIGHASH_OUTPUT_MASK=3;static SIGHASH_INPUT_MASK=128;static ADVANCED_TRANSACTION_MARKER=0;static ADVANCED_TRANSACTION_FLAG=1;version=1;locktime=0;ins=[];outs=[];static fromBuffer(t,e){const r=new i.BufferReader(t),n=new g;n.version=r.readInt32();const o=r.readUInt8(),a=r.readUInt8();let s=!1;o===g.ADVANCED_TRANSACTION_MARKER&&a===g.ADVANCED_TRANSACTION_FLAG?s=!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(s){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 g.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&&g.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=g.DEFAULT_SEQUENCE),this.ins.push({hash:t,index:e,script:n||l,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+f(e.script)),0)+this.outs.reduce(((t,e)=>t+8+f(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+f(e)),0)}(e.witness)),0):0)}clone(){const t=new g;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=a.compile(a.decompile(e).filter((t=>t!==s.OPS.OP_CODESEPARATOR))),f=this.clone();if((31&r)===g.SIGHASH_NONE)f.outs=[],f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}));else if((31&r)===g.SIGHASH_SINGLE){if(t>=this.outs.length)return d;f.outs.length=t+1;for(let e=0;e<t;e++)f.outs[e]=b;f.ins.forEach(((e,r)=>{r!==t&&(e.sequence=0)}))}r&g.SIGHASH_ANYONECANPAY?(f.ins=[f.ins[t]],f.ins[0].script=i):(f.ins.forEach((t=>{t.script=l})),f.ins[t].script=i);const h=n.allocUnsafe(f.byteLength(!1)+4);return h.writeInt32LE(r,h.length-4),f.__toBuffer(h,0,!1),o.hash256(h)}hashForWitnessV1(t,e,r,a,s,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=a===g.SIGHASH_DEFAULT?g.SIGHASH_ALL:a&g.SIGHASH_OUTPUT_MASK,d=(a&g.SIGHASH_INPUT_MASK)===g.SIGHASH_ANYONECANPAY,y=p===g.SIGHASH_NONE,b=p===g.SIGHASH_SINGLE;let w=l,v=l,m=l,_=l,E=l;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))),v=o.sha256(t.end()),t=i.BufferWriter.withCapacity(e.map(f).reduce(((t,e)=>t+e))),e.forEach((e=>t.writeVarSlice(e))),m=o.sha256(t.end()),t=i.BufferWriter.withCapacity(4*this.ins.length),this.ins.forEach((e=>t.writeUInt32(e.sequence))),_=o.sha256(t.end())}if(y||b){if(b&&t<this.outs.length){const e=this.outs[t],r=i.BufferWriter.withCapacity(8+f(e.script));r.writeUInt64(e.value),r.writeVarSlice(e.script),E=o.sha256(r.end())}}else{if(!this.outs.length)throw new Error("Add outputs to the transaction before signing.");const t=this.outs.map((t=>8+f(t.script))).reduce(((t,e)=>t+e)),e=i.BufferWriter.withCapacity(t);this.outs.forEach((t=>{e.writeUInt64(t.value),e.writeVarSlice(t.script)})),E=o.sha256(e.end())}const S=(s?2:0)+(h?1:0),k=174-(d?49:0)-(y?32:0)+(h?32:0)+(s?37:0),T=i.BufferWriter.withCapacity(k);if(T.writeUInt8(a),T.writeInt32(this.version),T.writeUInt32(this.locktime),T.writeSlice(w),T.writeSlice(v),T.writeSlice(m),T.writeSlice(_),y||b||T.writeSlice(E),T.writeUInt8(S),d){const n=this.ins[t];T.writeSlice(n.hash),T.writeUInt32(n.index),T.writeUInt64(r[t]),T.writeVarSlice(e[t]),T.writeUInt32(n.sequence)}else T.writeUInt32(t);if(h){const t=i.BufferWriter.withCapacity(f(h));t.writeVarSlice(h),T.writeSlice(o.sha256(t.end()))}return b&&T.writeSlice(E),s&&(T.writeSlice(s),T.writeUInt8(0),T.writeUInt32(4294967295)),o.taggedHash("TapSighash",n.concat([n.from([0]),T.end()]))}hashForWitnessV0(t,e,r,a){c(u.tuple(u.UInt32,u.Buffer,u.Satoshi,u.UInt32),arguments);let s,l=n.from([]),h=p,d=p,y=p;if(a&g.SIGHASH_ANYONECANPAY||(l=n.allocUnsafe(36*this.ins.length),s=new i.BufferWriter(l,0),this.ins.forEach((t=>{s.writeSlice(t.hash),s.writeUInt32(t.index)})),d=o.hash256(l)),a&g.SIGHASH_ANYONECANPAY||(31&a)===g.SIGHASH_SINGLE||(31&a)===g.SIGHASH_NONE||(l=n.allocUnsafe(4*this.ins.length),s=new i.BufferWriter(l,0),this.ins.forEach((t=>{s.writeUInt32(t.sequence)})),y=o.hash256(l)),(31&a)!==g.SIGHASH_SINGLE&&(31&a)!==g.SIGHASH_NONE){const t=this.outs.reduce(((t,e)=>t+8+f(e.script)),0);l=n.allocUnsafe(t),s=new i.BufferWriter(l,0),this.outs.forEach((t=>{s.writeUInt64(t.value),s.writeVarSlice(t.script)})),h=o.hash256(l)}else if((31&a)===g.SIGHASH_SINGLE&&t<this.outs.length){const e=this.outs[t];l=n.allocUnsafe(8+f(e.script)),s=new i.BufferWriter(l,0),s.writeUInt64(e.value),s.writeVarSlice(e.script),h=o.hash256(l)}l=n.allocUnsafe(156+f(e)),s=new i.BufferWriter(l,0);const b=this.ins[t];return s.writeInt32(this.version),s.writeSlice(d),s.writeSlice(y),s.writeSlice(b.hash),s.writeUInt32(b.index),s.writeVarSlice(e),s.writeUInt64(r),s.writeUInt32(b.sequence),s.writeSlice(h),s.writeUInt32(this.locktime),s.writeUInt32(a),o.hash256(l)}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 a=r&&this.hasWitnesses();return a&&(o.writeUInt8(g.ADVANCED_TRANSACTION_MARKER),o.writeUInt8(g.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)})),a&&this.ins.forEach((t=>{o.writeVector(t.witness)})),o.writeUInt32(this.locktime),void 0!==e?t.slice(e,o.offset):t}}e.Transaction=g},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.TAPLEAF_VERSION_MASK=e.typeforce=void 0,e.stacksEqual=function(t,e){return t.length===e.length&&t.every(((t,r)=>t.equals(e[r])))},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 a=t.slice(33);return 0!==a.compare(i)&&!(a.compare(o)>=0)&&4===e&&65===t.length},e.Satoshi=function(t){return e.typeforce.UInt53(t)&&t<=a},e.isTapleaf=s,e.isTaptree=function t(r){return(0,e.Array)(r)?2===r.length&&r.every((e=>t(e))):s(r)};const n=r(8287);e.typeforce=r(8676);const i=n.Buffer.alloc(32,0),o=n.Buffer.from("fffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f","hex"),a=21e14;function s(t){return!(!t||!("output"in t)||!n.Buffer.isBuffer(t.output)||void 0!==t.version&&(t.version&e.TAPLEAF_VERSION_MASK)!==t.version)}e.TAPLEAF_VERSION_MASK=254,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},5974:(t,e,r)=>{var n=r(8287).Buffer,i=r(5606),o=r(4148),a=r(4442),s=r(8411),u=r(1447),c=r(9681);for(var f in c)e[f]=c[f];function l(t){if("number"!=typeof t||t<e.DEFLATE||t>e.UNZIP)throw new TypeError("Bad argument");this.dictionary=null,this.err=0,this.flush=0,this.init_done=!1,this.level=0,this.memLevel=0,this.mode=t,this.strategy=0,this.windowBits=0,this.write_in_progress=!1,this.pending_close=!1,this.gzip_id_bytes_read=0}e.NONE=0,e.DEFLATE=1,e.INFLATE=2,e.GZIP=3,e.GUNZIP=4,e.DEFLATERAW=5,e.INFLATERAW=6,e.UNZIP=7,l.prototype.close=function(){this.write_in_progress?this.pending_close=!0:(this.pending_close=!1,o(this.init_done,"close before init"),o(this.mode<=e.UNZIP),this.mode===e.DEFLATE||this.mode===e.GZIP||this.mode===e.DEFLATERAW?s.deflateEnd(this.strm):this.mode!==e.INFLATE&&this.mode!==e.GUNZIP&&this.mode!==e.INFLATERAW&&this.mode!==e.UNZIP||u.inflateEnd(this.strm),this.mode=e.NONE,this.dictionary=null)},l.prototype.write=function(t,e,r,n,i,o,a){return this._write(!0,t,e,r,n,i,o,a)},l.prototype.writeSync=function(t,e,r,n,i,o,a){return this._write(!1,t,e,r,n,i,o,a)},l.prototype._write=function(t,r,a,s,u,c,f,l){if(o.equal(arguments.length,8),o(this.init_done,"write before init"),o(this.mode!==e.NONE,"already finalized"),o.equal(!1,this.write_in_progress,"write already in progress"),o.equal(!1,this.pending_close,"close is pending"),this.write_in_progress=!0,o.equal(!1,void 0===r,"must provide flush value"),this.write_in_progress=!0,r!==e.Z_NO_FLUSH&&r!==e.Z_PARTIAL_FLUSH&&r!==e.Z_SYNC_FLUSH&&r!==e.Z_FULL_FLUSH&&r!==e.Z_FINISH&&r!==e.Z_BLOCK)throw new Error("Invalid flush value");if(null==a&&(a=n.alloc(0),u=0,s=0),this.strm.avail_in=u,this.strm.input=a,this.strm.next_in=s,this.strm.avail_out=l,this.strm.output=c,this.strm.next_out=f,this.flush=r,!t)return this._process(),this._checkError()?this._afterSync():void 0;var h=this;return i.nextTick((function(){h._process(),h._after()})),this},l.prototype._afterSync=function(){var t=this.strm.avail_out,e=this.strm.avail_in;return this.write_in_progress=!1,[e,t]},l.prototype._process=function(){var t=null;switch(this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflate(this.strm,this.flush);break;case e.UNZIP:switch(this.strm.avail_in>0&&(t=this.strm.next_in),this.gzip_id_bytes_read){case 0:if(null===t)break;if(31!==this.strm.input[t]){this.mode=e.INFLATE;break}if(this.gzip_id_bytes_read=1,t++,1===this.strm.avail_in)break;case 1:if(null===t)break;139===this.strm.input[t]?(this.gzip_id_bytes_read=2,this.mode=e.GUNZIP):this.mode=e.INFLATE;break;default:throw new Error("invalid number of gzip magic number bytes read")}case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:for(this.err=u.inflate(this.strm,this.flush),this.err===e.Z_NEED_DICT&&this.dictionary&&(this.err=u.inflateSetDictionary(this.strm,this.dictionary),this.err===e.Z_OK?this.err=u.inflate(this.strm,this.flush):this.err===e.Z_DATA_ERROR&&(this.err=e.Z_NEED_DICT));this.strm.avail_in>0&&this.mode===e.GUNZIP&&this.err===e.Z_STREAM_END&&0!==this.strm.next_in[0];)this.reset(),this.err=u.inflate(this.strm,this.flush);break;default:throw new Error("Unknown mode "+this.mode)}},l.prototype._checkError=function(){switch(this.err){case e.Z_OK:case e.Z_BUF_ERROR:if(0!==this.strm.avail_out&&this.flush===e.Z_FINISH)return this._error("unexpected end of file"),!1;break;case e.Z_STREAM_END:break;case e.Z_NEED_DICT:return null==this.dictionary?this._error("Missing dictionary"):this._error("Bad dictionary"),!1;default:return this._error("Zlib error"),!1}return!0},l.prototype._after=function(){if(this._checkError()){var t=this.strm.avail_out,e=this.strm.avail_in;this.write_in_progress=!1,this.callback(e,t),this.pending_close&&this.close()}},l.prototype._error=function(t){this.strm.msg&&(t=this.strm.msg),this.onerror(t,this.err),this.write_in_progress=!1,this.pending_close&&this.close()},l.prototype.init=function(t,r,n,i,a){o(4===arguments.length||5===arguments.length,"init(windowBits, level, memLevel, strategy, [dictionary])"),o(t>=8&&t<=15,"invalid windowBits"),o(r>=-1&&r<=9,"invalid compression level"),o(n>=1&&n<=9,"invalid memlevel"),o(i===e.Z_FILTERED||i===e.Z_HUFFMAN_ONLY||i===e.Z_RLE||i===e.Z_FIXED||i===e.Z_DEFAULT_STRATEGY,"invalid strategy"),this._init(r,t,n,i,a),this._setDictionary()},l.prototype.params=function(){throw new Error("deflateParams Not supported")},l.prototype.reset=function(){this._reset(),this._setDictionary()},l.prototype._init=function(t,r,n,i,o){switch(this.level=t,this.windowBits=r,this.memLevel=n,this.strategy=i,this.flush=e.Z_NO_FLUSH,this.err=e.Z_OK,this.mode!==e.GZIP&&this.mode!==e.GUNZIP||(this.windowBits+=16),this.mode===e.UNZIP&&(this.windowBits+=32),this.mode!==e.DEFLATERAW&&this.mode!==e.INFLATERAW||(this.windowBits=-1*this.windowBits),this.strm=new a,this.mode){case e.DEFLATE:case e.GZIP:case e.DEFLATERAW:this.err=s.deflateInit2(this.strm,this.level,e.Z_DEFLATED,this.windowBits,this.memLevel,this.strategy);break;case e.INFLATE:case e.GUNZIP:case e.INFLATERAW:case e.UNZIP:this.err=u.inflateInit2(this.strm,this.windowBits);break;default:throw new Error("Unknown mode "+this.mode)}this.err!==e.Z_OK&&this._error("Init error"),this.dictionary=o,this.write_in_progress=!1,this.init_done=!0},l.prototype._setDictionary=function(){if(null!=this.dictionary){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:this.err=s.deflateSetDictionary(this.strm,this.dictionary)}this.err!==e.Z_OK&&this._error("Failed to set dictionary")}},l.prototype._reset=function(){switch(this.err=e.Z_OK,this.mode){case e.DEFLATE:case e.DEFLATERAW:case e.GZIP:this.err=s.deflateReset(this.strm);break;case e.INFLATE:case e.INFLATERAW:case e.GUNZIP:this.err=u.inflateReset(this.strm)}this.err!==e.Z_OK&&this._error("Failed to reset stream")},e.Zlib=l},8559:(t,e,r)=>{var n=r(5606),i=r(8287).Buffer,o=r(8310).Transform,a=r(5974),s=r(537),u=r(4148).ok,c=r(8287).kMaxLength,f="Cannot create final Buffer. It would be larger than 0x"+c.toString(16)+" bytes";a.Z_MIN_WINDOWBITS=8,a.Z_MAX_WINDOWBITS=15,a.Z_DEFAULT_WINDOWBITS=15,a.Z_MIN_CHUNK=64,a.Z_MAX_CHUNK=1/0,a.Z_DEFAULT_CHUNK=16384,a.Z_MIN_MEMLEVEL=1,a.Z_MAX_MEMLEVEL=9,a.Z_DEFAULT_MEMLEVEL=8,a.Z_MIN_LEVEL=-1,a.Z_MAX_LEVEL=9,a.Z_DEFAULT_LEVEL=a.Z_DEFAULT_COMPRESSION;for(var l=Object.keys(a),h=0;h<l.length;h++){var p=l[h];p.match(/^Z/)&&Object.defineProperty(e,p,{enumerable:!0,value:a[p],writable:!1})}for(var d={Z_OK:a.Z_OK,Z_STREAM_END:a.Z_STREAM_END,Z_NEED_DICT:a.Z_NEED_DICT,Z_ERRNO:a.Z_ERRNO,Z_STREAM_ERROR:a.Z_STREAM_ERROR,Z_DATA_ERROR:a.Z_DATA_ERROR,Z_MEM_ERROR:a.Z_MEM_ERROR,Z_BUF_ERROR:a.Z_BUF_ERROR,Z_VERSION_ERROR:a.Z_VERSION_ERROR},y=Object.keys(d),b=0;b<y.length;b++){var g=y[b];d[d[g]]=g}function w(t,e,r){var n=[],o=0;function a(){for(var e;null!==(e=t.read());)n.push(e),o+=e.length;t.once("readable",a)}function s(){var e,a=null;o>=c?a=new RangeError(f):e=i.concat(n,o),n=[],t.close(),r(a,e)}t.on("error",(function(e){t.removeListener("end",s),t.removeListener("readable",a),r(e)})),t.on("end",s),t.end(e),a()}function v(t,e){if("string"==typeof e&&(e=i.from(e)),!i.isBuffer(e))throw new TypeError("Not a string or buffer");var r=t._finishFlushFlag;return t._processChunk(e,r)}function m(t){if(!(this instanceof m))return new m(t);A.call(this,t,a.DEFLATE)}function _(t){if(!(this instanceof _))return new _(t);A.call(this,t,a.INFLATE)}function E(t){if(!(this instanceof E))return new E(t);A.call(this,t,a.GZIP)}function S(t){if(!(this instanceof S))return new S(t);A.call(this,t,a.GUNZIP)}function k(t){if(!(this instanceof k))return new k(t);A.call(this,t,a.DEFLATERAW)}function T(t){if(!(this instanceof T))return new T(t);A.call(this,t,a.INFLATERAW)}function O(t){if(!(this instanceof O))return new O(t);A.call(this,t,a.UNZIP)}function x(t){return t===a.Z_NO_FLUSH||t===a.Z_PARTIAL_FLUSH||t===a.Z_SYNC_FLUSH||t===a.Z_FULL_FLUSH||t===a.Z_FINISH||t===a.Z_BLOCK}function A(t,r){var n=this;if(this._opts=t=t||{},this._chunkSize=t.chunkSize||e.Z_DEFAULT_CHUNK,o.call(this,t),t.flush&&!x(t.flush))throw new Error("Invalid flush flag: "+t.flush);if(t.finishFlush&&!x(t.finishFlush))throw new Error("Invalid flush flag: "+t.finishFlush);if(this._flushFlag=t.flush||a.Z_NO_FLUSH,this._finishFlushFlag=void 0!==t.finishFlush?t.finishFlush:a.Z_FINISH,t.chunkSize&&(t.chunkSize<e.Z_MIN_CHUNK||t.chunkSize>e.Z_MAX_CHUNK))throw new Error("Invalid chunk size: "+t.chunkSize);if(t.windowBits&&(t.windowBits<e.Z_MIN_WINDOWBITS||t.windowBits>e.Z_MAX_WINDOWBITS))throw new Error("Invalid windowBits: "+t.windowBits);if(t.level&&(t.level<e.Z_MIN_LEVEL||t.level>e.Z_MAX_LEVEL))throw new Error("Invalid compression level: "+t.level);if(t.memLevel&&(t.memLevel<e.Z_MIN_MEMLEVEL||t.memLevel>e.Z_MAX_MEMLEVEL))throw new Error("Invalid memLevel: "+t.memLevel);if(t.strategy&&t.strategy!=e.Z_FILTERED&&t.strategy!=e.Z_HUFFMAN_ONLY&&t.strategy!=e.Z_RLE&&t.strategy!=e.Z_FIXED&&t.strategy!=e.Z_DEFAULT_STRATEGY)throw new Error("Invalid strategy: "+t.strategy);if(t.dictionary&&!i.isBuffer(t.dictionary))throw new Error("Invalid dictionary: it should be a Buffer instance");this._handle=new a.Zlib(r);var s=this;this._hadError=!1,this._handle.onerror=function(t,r){P(s),s._hadError=!0;var n=new Error(t);n.errno=r,n.code=e.codes[r],s.emit("error",n)};var u=e.Z_DEFAULT_COMPRESSION;"number"==typeof t.level&&(u=t.level);var c=e.Z_DEFAULT_STRATEGY;"number"==typeof t.strategy&&(c=t.strategy),this._handle.init(t.windowBits||e.Z_DEFAULT_WINDOWBITS,u,t.memLevel||e.Z_DEFAULT_MEMLEVEL,c,t.dictionary),this._buffer=i.allocUnsafe(this._chunkSize),this._offset=0,this._level=u,this._strategy=c,this.once("end",this.close),Object.defineProperty(this,"_closed",{get:function(){return!n._handle},configurable:!0,enumerable:!0})}function P(t,e){e&&n.nextTick(e),t._handle&&(t._handle.close(),t._handle=null)}function I(t){t.emit("close")}Object.defineProperty(e,"codes",{enumerable:!0,value:Object.freeze(d),writable:!1}),e.Deflate=m,e.Inflate=_,e.Gzip=E,e.Gunzip=S,e.DeflateRaw=k,e.InflateRaw=T,e.Unzip=O,e.createDeflate=function(t){return new m(t)},e.createInflate=function(t){return new _(t)},e.createDeflateRaw=function(t){return new k(t)},e.createInflateRaw=function(t){return new T(t)},e.createGzip=function(t){return new E(t)},e.createGunzip=function(t){return new S(t)},e.createUnzip=function(t){return new O(t)},e.deflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new m(e),t,r)},e.deflateSync=function(t,e){return v(new m(e),t)},e.gzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new E(e),t,r)},e.gzipSync=function(t,e){return v(new E(e),t)},e.deflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new k(e),t,r)},e.deflateRawSync=function(t,e){return v(new k(e),t)},e.unzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new O(e),t,r)},e.unzipSync=function(t,e){return v(new O(e),t)},e.inflate=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new _(e),t,r)},e.inflateSync=function(t,e){return v(new _(e),t)},e.gunzip=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new S(e),t,r)},e.gunzipSync=function(t,e){return v(new S(e),t)},e.inflateRaw=function(t,e,r){return"function"==typeof e&&(r=e,e={}),w(new T(e),t,r)},e.inflateRawSync=function(t,e){return v(new T(e),t)},s.inherits(A,o),A.prototype.params=function(t,r,i){if(t<e.Z_MIN_LEVEL||t>e.Z_MAX_LEVEL)throw new RangeError("Invalid compression level: "+t);if(r!=e.Z_FILTERED&&r!=e.Z_HUFFMAN_ONLY&&r!=e.Z_RLE&&r!=e.Z_FIXED&&r!=e.Z_DEFAULT_STRATEGY)throw new TypeError("Invalid strategy: "+r);if(this._level!==t||this._strategy!==r){var o=this;this.flush(a.Z_SYNC_FLUSH,(function(){u(o._handle,"zlib binding closed"),o._handle.params(t,r),o._hadError||(o._level=t,o._strategy=r,i&&i())}))}else n.nextTick(i)},A.prototype.reset=function(){return u(this._handle,"zlib binding closed"),this._handle.reset()},A.prototype._flush=function(t){this._transform(i.alloc(0),"",t)},A.prototype.flush=function(t,e){var r=this,o=this._writableState;("function"==typeof t||void 0===t&&!e)&&(e=t,t=a.Z_FULL_FLUSH),o.ended?e&&n.nextTick(e):o.ending?e&&this.once("end",e):o.needDrain?e&&this.once("drain",(function(){return r.flush(t,e)})):(this._flushFlag=t,this.write(i.alloc(0),"",e))},A.prototype.close=function(t){P(this,t),n.nextTick(I,this)},A.prototype._transform=function(t,e,r){var n,o=this._writableState,s=(o.ending||o.ended)&&(!t||o.length===t.length);return null===t||i.isBuffer(t)?this._handle?(s?n=this._finishFlushFlag:(n=this._flushFlag,t.length>=o.length&&(this._flushFlag=this._opts.flush||a.Z_NO_FLUSH)),void this._processChunk(t,n,r)):r(new Error("zlib binding closed")):r(new Error("invalid input"))},A.prototype._processChunk=function(t,e,r){var n=t&&t.length,o=this._chunkSize-this._offset,a=0,s=this,l="function"==typeof r;if(!l){var h,p=[],d=0;this.on("error",(function(t){h=t})),u(this._handle,"zlib binding closed");do{var y=this._handle.writeSync(e,t,a,n,this._buffer,this._offset,o)}while(!this._hadError&&w(y[0],y[1]));if(this._hadError)throw h;if(d>=c)throw P(this),new RangeError(f);var b=i.concat(p,d);return P(this),b}u(this._handle,"zlib binding closed");var g=this._handle.write(e,t,a,n,this._buffer,this._offset,o);function w(c,f){if(this&&(this.buffer=null,this.callback=null),!s._hadError){var h=o-f;if(u(h>=0,"have should not go down"),h>0){var y=s._buffer.slice(s._offset,s._offset+h);s._offset+=h,l?s.push(y):(p.push(y),d+=y.length)}if((0===f||s._offset>=s._chunkSize)&&(o=s._chunkSize,s._offset=0,s._buffer=i.allocUnsafe(s._chunkSize)),0===f){if(a+=n-c,n=c,!l)return!0;var b=s._handle.write(e,t,a,n,s._buffer,s._offset,s._chunkSize);return b.callback=w,void(b.buffer=t)}if(!l)return!1;r()}}g.buffer=t,g.callback=w},s.inherits(m,A),s.inherits(_,A),s.inherits(E,A),s.inherits(S,A),s.inherits(k,A),s.inherits(T,A),s.inherits(O,A)},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,a=new Uint8Array(o);return a.set(r,0),a.set(i.subarray(0,4),r.length),n.encode(a,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 a=2147483647;function s(t){if(t>a)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 l(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=s(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($(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($(t,ArrayBuffer)||t&&$(t.buffer,ArrayBuffer))return p(t,e,r);if("undefined"!=typeof SharedArrayBuffer&&($(t,SharedArrayBuffer)||t&&$(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=s(e);return 0===r.length||t.copy(r,0,0,e),r}return void 0!==t.length?"number"!=typeof t.length||Y(t.length)?s(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 f(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 l(t){return f(t),s(t<0?0:0|d(t))}function h(t){const e=t.length<0?0:0|d(t.length),r=s(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>=a)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+a.toString(16)+" bytes");return 0|t}function y(t,e){if(u.isBuffer(t))return t.length;if(ArrayBuffer.isView(t)||$(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 b(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 I(this,e,r);case"utf8":case"utf-8":return O(this,e,r);case"ascii":return A(this,e,r);case"latin1":case"binary":return P(this,e,r);case"base64":return T(this,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return R(this,e,r);default:if(n)throw new TypeError("Unknown encoding: "+t);t=(t+"").toLowerCase(),n=!0}}function g(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),Y(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:v(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):v(t,[e],r,n,i);throw new TypeError("val must be string, number or Buffer")}function v(t,e,r,n,i){let o,a=1,s=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;a=2,s/=2,u/=2,r/=2}function c(t,e){return 1===a?t[e]:t.readUInt16BE(e*a)}if(i){let n=-1;for(o=r;o<s;o++)if(c(t,o)===c(e,-1===n?0:o-n)){if(-1===n&&(n=o),o-n+1===u)return n*a}else-1!==n&&(o-=o-n),n=-1}else for(r+u>s&&(r=s-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 m(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 a;for(n>o/2&&(n=o/2),a=0;a<n;++a){const n=parseInt(e.substr(2*a,2),16);if(Y(n))return a;t[r+a]=n}return a}function _(t,e,r,n){return X(z(e,t.length-r),t,r,n)}function E(t,e,r,n){return X(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 X(q(e),t,r,n)}function k(t,e,r,n){return X(function(t,e){let r,n,i;const o=[];for(let a=0;a<t.length&&!((e-=2)<0);++a)r=t.charCodeAt(a),n=r>>8,i=r%256,o.push(i),o.push(n);return o}(e,t.length-r),t,r,n)}function T(t,e,r){return 0===e&&r===t.length?n.fromByteArray(t):n.fromByteArray(t.slice(e,r))}function O(t,e,r){r=Math.min(t.length,r);const n=[];let i=e;for(;i<r;){const e=t[i];let o=null,a=e>239?4:e>223?3:e>191?2:1;if(i+a<=r){let r,n,s,u;switch(a){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],s=t[i+3],128==(192&r)&&128==(192&n)&&128==(192&s)&&(u=(15&e)<<18|(63&r)<<12|(63&n)<<6|63&s,u>65535&&u<1114112&&(o=u))}}null===o?(o=65533,a=1):o>65535&&(o-=65536,n.push(o>>>10&1023|55296),o=56320|1023&o),n.push(o),i+=a}return function(t){const e=t.length;if(e<=x)return String.fromCharCode.apply(String,t);let r="",n=0;for(;n<e;)r+=String.fromCharCode.apply(String,t.slice(n,n+=x));return r}(n)}e.kMaxLength=a,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 f(t),t<=0?s(t):void 0!==e?"string"==typeof r?s(t).fill(e,r):s(t).fill(e):s(t)}(t,e,r)},u.allocUnsafe=function(t){return l(t)},u.allocUnsafeSlow=function(t){return l(t)},u.isBuffer=function(t){return null!=t&&!0===t._isBuffer&&t!==u.prototype},u.compare=function(t,e){if($(t,Uint8Array)&&(t=u.from(t,t.offset,t.byteLength)),$(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($(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)g(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)g(this,e,e+3),g(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)g(this,e,e+7),g(this,e+1,e+6),g(this,e+2,e+5),g(this,e+3,e+4);return this},u.prototype.toString=function(){const t=this.length;return 0===t?"":0===arguments.length?O(this,0,t):b.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($(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),a=(r>>>=0)-(e>>>=0);const s=Math.min(o,a),c=this.slice(n,i),f=t.slice(e,r);for(let t=0;t<s;++t)if(c[t]!==f[t]){o=c[t],a=f[t];break}return o<a?-1:a<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 m(this,t,e,r);case"utf8":case"utf-8":return _(this,t,e,r);case"ascii":case"latin1":case"binary":return E(this,t,e,r);case"base64":return S(this,t,e,r);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return k(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 x=4096;function A(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 P(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 I(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+=Z[t[n]];return i}function R(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 L(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 B(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){K(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 a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,a>>=8,t[r++]=a,r}function N(t,e,r,n,i){K(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 a=Number(e>>BigInt(32)&BigInt(4294967295));return t[r+3]=a,a>>=8,t[r+2]=a,a>>=8,t[r+1]=a,a>>=8,t[r]=a,r+8}function j(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 C(t,e,r,n,o){return e=+e,r>>>=0,o||j(t,0,r,4),i.write(t,e,r,n,23,4),r+4}function F(t,e,r,n,o){return e=+e,r>>>=0,o||j(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||L(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||L(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||L(t,1,this.length),this[t]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]|this[t+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(t,e){return t>>>=0,e||L(t,2,this.length),this[t]<<8|this[t+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(t,e){return t>>>=0,e||L(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||L(t,4,this.length),16777216*this[t]+(this[t+1]<<16|this[t+2]<<8|this[t+3])},u.prototype.readBigUInt64LE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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||L(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||L(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||L(t,1,this.length),128&this[t]?-1*(255-this[t]+1):this[t]},u.prototype.readInt16LE=function(t,e){t>>>=0,e||L(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||L(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||L(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||L(t,4,this.length),this[t]<<24|this[t+1]<<16|this[t+2]<<8|this[t+3]},u.prototype.readBigInt64LE=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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=J((function(t){W(t>>>=0,"offset");const e=this[t],r=this[t+7];void 0!==e&&void 0!==r||G(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||L(t,4,this.length),i.read(this,t,!0,23,4)},u.prototype.readFloatBE=function(t,e){return t>>>=0,e||L(t,4,this.length),i.read(this,t,!1,23,4)},u.prototype.readDoubleLE=function(t,e){return t>>>=0,e||L(t,8,this.length),i.read(this,t,!0,52,8)},u.prototype.readDoubleBE=function(t,e){return t>>>=0,e||L(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||B(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||B(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||B(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||B(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||B(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||B(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||B(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=J((function(t,e=0){return U(this,t,e,BigInt(0),BigInt("0xffffffffffffffff"))})),u.prototype.writeBigUInt64BE=J((function(t,e=0){return N(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);B(this,t,e,r,n-1,-n)}let i=0,o=1,a=0;for(this[e]=255&t;++i<r&&(o*=256);)t<0&&0===a&&0!==this[e+i-1]&&(a=1),this[e+i]=(t/o|0)-a&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);B(this,t,e,r,n-1,-n)}let i=r-1,o=1,a=0;for(this[e+i]=255&t;--i>=0&&(o*=256);)t<0&&0===a&&0!==this[e+i+1]&&(a=1),this[e+i]=(t/o|0)-a&255;return e+r},u.prototype.writeInt8=function(t,e,r){return t=+t,e>>>=0,r||B(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||B(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||B(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||B(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||B(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=J((function(t,e=0){return U(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeBigInt64BE=J((function(t,e=0){return N(this,t,e,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))})),u.prototype.writeFloatLE=function(t,e,r){return C(this,t,e,!0,r)},u.prototype.writeFloatBE=function(t,e,r){return C(this,t,e,!1,r)},u.prototype.writeDoubleLE=function(t,e,r){return F(this,t,e,!0,r)},u.prototype.writeDoubleBE=function(t,e,r){return F(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),a=o.length;if(0===a)throw new TypeError('The value "'+t+'" is invalid for argument "value"');for(i=0;i<r-e;++i)this[i+e]=o[i%a]}return this};const M={};function D(t,e,r){M[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 H(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 K(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 M.ERR_OUT_OF_RANGE("value",i,t)}!function(t,e,r){W(e,"offset"),void 0!==t[e]&&void 0!==t[e+r]||G(e,t.length-(r+1))}(n,i,o)}function W(t,e){if("number"!=typeof t)throw new M.ERR_INVALID_ARG_TYPE(e,"number",t)}function G(t,e,r){if(Math.floor(t)!==t)throw W(t,r),new M.ERR_OUT_OF_RANGE(r||"offset","an integer",t);if(e<0)throw new M.ERR_BUFFER_OUT_OF_BOUNDS;throw new M.ERR_OUT_OF_RANGE(r||"offset",`>= ${r?1:0} and <= ${e}`,t)}D("ERR_BUFFER_OUT_OF_BOUNDS",(function(t){return t?`${t} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"}),RangeError),D("ERR_INVALID_ARG_TYPE",(function(t,e){return`The "${t}" argument must be of type number. Received type ${typeof e}`}),TypeError),D("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=H(String(r)):"bigint"==typeof r&&(i=String(r),(r>BigInt(2)**BigInt(32)||r<-(BigInt(2)**BigInt(32)))&&(i=H(i)),i+="n"),n+=` It must be ${e}. Received ${i}`,n}),RangeError);const V=/[^+/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 a=0;a<n;++a){if(r=t.charCodeAt(a),r>55295&&r<57344){if(!i){if(r>56319){(e-=3)>-1&&o.push(239,191,189);continue}if(a+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(V,"")).length<2)return"";for(;t.length%4!=0;)t+="=";return t}(t))}function X(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 $(t,e){return t instanceof e||null!=t&&null!=t.constructor&&null!=t.constructor.name&&t.constructor.name===e.name}function Y(t){return t!=t}const Z=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 J(t){return"undefined"==typeof BigInt?Q:t}function Q(){throw new Error("BigInt not supported")}},8075:(t,e,r)=>{var n=r(453),i=r(487),o=i(n("String.prototype.indexOf"));t.exports=function(t,e){var r=n(t,!!e);return"function"==typeof r&&o(t,".prototype.")>-1?i(r):r}},487:(t,e,r)=>{var n=r(6743),i=r(453),o=r(6897),a=r(9675),s=i("%Function.prototype.apply%"),u=i("%Function.prototype.call%"),c=i("%Reflect.apply%",!0)||n.call(u,s),f=r(655),l=i("%Math.max%");t.exports=function(t){if("function"!=typeof t)throw new a("a function is required");var e=c(n,u,arguments);return o(e,1+l(0,t.length-(arguments.length-1)),!0)};var h=function(){return c(n,s,arguments)};f?f(t.exports,"apply",{value:h}):t.exports.apply=h},6168:(t,e,r)=>{var n=r(2861).Buffer,i=r(8310).Transform,o=r(9579).I;function a(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)(a,i),a.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)},a.prototype.setAutoPadding=function(){},a.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")},a.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")},a.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")},a.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)}},a.prototype._flush=function(t){var e;try{this.push(this.__final())}catch(t){e=t}t(e)},a.prototype._finalOrDigest=function(t){var e=this.__final()||n.alloc(0);return t&&(e=this._toString(e,t,!0)),e},a.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=a},7108:(t,e,r)=>{var n=r(6698),i=r(320),o=r(6011),a=r(2802),s=r(6168);function u(t){s.call(this,"digest"),this._hash=t}n(u,s),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(a(t))}},320:(t,e,r)=>{var n=r(320);t.exports=function(t){return(new n).update(t).digest()}},41:(t,e,r)=>{var n=r(655),i=r(8068),o=r(9675),a=r(5795);t.exports=function(t,e,r){if(!t||"object"!=typeof t&&"function"!=typeof t)throw new o("`obj` must be an object or a function`");if("string"!=typeof e&&"symbol"!=typeof e)throw new o("`property` must be a string or a symbol`");if(arguments.length>3&&"boolean"!=typeof arguments[3]&&null!==arguments[3])throw new o("`nonEnumerable`, if provided, must be a boolean or null");if(arguments.length>4&&"boolean"!=typeof arguments[4]&&null!==arguments[4])throw new o("`nonWritable`, if provided, must be a boolean or null");if(arguments.length>5&&"boolean"!=typeof arguments[5]&&null!==arguments[5])throw new o("`nonConfigurable`, if provided, must be a boolean or null");if(arguments.length>6&&"boolean"!=typeof arguments[6])throw new o("`loose`, if provided, must be a boolean");var s=arguments.length>3?arguments[3]:null,u=arguments.length>4?arguments[4]:null,c=arguments.length>5?arguments[5]:null,f=arguments.length>6&&arguments[6],l=!!a&&a(t,e);if(n)n(t,e,{configurable:null===c&&l?l.configurable:!c,enumerable:null===s&&l?l.enumerable:!s,value:r,writable:null===u&&l?l.writable:!u});else{if(!f&&(s||u||c))throw new i("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");t[e]=r}}},8452:(t,e,r)=>{var n=r(1189),i="function"==typeof Symbol&&"symbol"==typeof Symbol("foo"),o=Object.prototype.toString,a=Array.prototype.concat,s=r(41),u=r(592)(),c=function(t,e,r,n){if(e in t)if(!0===n){if(t[e]===r)return}else if("function"!=typeof(i=n)||"[object Function]"!==o.call(i)||!n())return;var i;u?s(t,e,r,!0):s(t,e,r)},f=function(t,e){var r=arguments.length>2?arguments[2]:{},o=n(e);i&&(o=a.call(o,Object.getOwnPropertySymbols(e)));for(var s=0;s<o.length;s+=1)c(t,o[s],e[o[s]],r[o[s]])};f.supportsDescriptors=!!u,t.exports=f},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),a=r(3209),s=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 f(e,void 0,r)}function r(e,r){return o.typeforce(t.isPoint,e),o.typeforce(c,r),new f(void 0,e,r)}(0,u.testEcc)(t);class f{__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 s.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 a=t.xOnlyPointAddTweak(i,e);if(!a||null===a.xOnlyPubkey)throw new Error("Cannot tweak public key!");const s=n.from([0===a.parity?2:3]);return r(n.concat([s,a.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=s.decode(t),a=n.version;if(o.Array(r)){if(r=r.filter((t=>a===t.wif)).pop(),!r)throw new Error("Unknown network version")}else if(r=r||i.bitcoin,a!==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||a;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},655:(t,e,r)=>{var n=r(453)("%Object.defineProperty%",!0)||!1;if(n)try{n({},"a",{value:1})}catch(t){n=!1}t.exports=n},1237:t=>{t.exports=EvalError},9383:t=>{t.exports=Error},9290:t=>{t.exports=RangeError},9538:t=>{t.exports=ReferenceError},8068:t=>{t.exports=SyntaxError},9675:t=>{t.exports=TypeError},5345:t=>{t.exports=URIError},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){"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 a=10;function s(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,a,c;if(s(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),a=o[e]),void 0===a)a=o[e]=r,++t._eventsCount;else if("function"==typeof a?a=o[e]=n?[r,a]:[a,r]:n?a.unshift(r):a.push(r),(i=u(t))>0&&a.length>i&&!a.warned){a.warned=!0;var f=new Error("Possible EventEmitter memory leak detected. "+a.length+" "+String(e)+" listeners added. Use emitter.setMaxListeners() to increase limit");f.name="MaxListenersExceededWarning",f.emitter=t,f.type=e,f.count=a.length,c=f,console&&console.warn&&console.warn(c)}return t}function f(){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 l(t,e,r){var n={fired:!1,wrapFn:void 0,target:t,type:e,listener:r},i=f.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 a},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+".");a=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 a;if(e.length>0&&(a=e[0]),a instanceof Error)throw a;var s=new Error("Unhandled error."+(a?" ("+a.message+")":""));throw s.context=a,s}var u=o[t];if(void 0===u)return!1;if("function"==typeof u)n(u,this,e);else{var c=u.length,f=d(u,c);for(r=0;r<c;++r)n(f[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 s(e),this.on(t,l(this,t,e)),this},o.prototype.prependOnceListener=function(t,e){return s(e),this.prependListener(t,l(this,t,e)),this},o.prototype.removeListener=function(t,e){var r,n,i,o,a;if(s(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){a=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,a||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):[]}},2682:(t,e,r)=>{var n=r(9600),i=Object.prototype.toString,o=Object.prototype.hasOwnProperty;t.exports=function(t,e,r){if(!n(e))throw new TypeError("iterator must be a function");var a;arguments.length>=3&&(a=r),"[object Array]"===i.call(t)?function(t,e,r){for(var n=0,i=t.length;n<i;n++)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a):"string"==typeof t?function(t,e,r){for(var n=0,i=t.length;n<i;n++)null==r?e(t.charAt(n),n,t):e.call(r,t.charAt(n),n,t)}(t,e,a):function(t,e,r){for(var n in t)o.call(t,n)&&(null==r?e(t[n],n,t):e.call(r,t[n],n,t))}(t,e,a)}},9353:t=>{var e=Object.prototype.toString,r=Math.max,n=function(t,e){for(var r=[],n=0;n<t.length;n+=1)r[n]=t[n];for(var i=0;i<e.length;i+=1)r[i+t.length]=e[i];return r};t.exports=function(t){var i=this;if("function"!=typeof i||"[object Function]"!==e.apply(i))throw new TypeError("Function.prototype.bind called on incompatible "+i);for(var o,a=function(t){for(var e=[],r=1,n=0;r<t.length;r+=1,n+=1)e[n]=t[r];return e}(arguments),s=r(0,i.length-a.length),u=[],c=0;c<s;c++)u[c]="$"+c;if(o=Function("binder","return function ("+function(t){for(var e="",r=0;r<t.length;r+=1)e+=t[r],r+1<t.length&&(e+=",");return e}(u)+"){ return binder.apply(this,arguments); }")((function(){if(this instanceof o){var e=i.apply(this,n(a,arguments));return Object(e)===e?e:this}return i.apply(t,n(a,arguments))})),i.prototype){var f=function(){};f.prototype=i.prototype,o.prototype=new f,f.prototype=null}return o}},6743:(t,e,r)=>{var n=r(9353);t.exports=Function.prototype.bind||n},453:(t,e,r)=>{var n,i=r(9383),o=r(1237),a=r(9290),s=r(9538),u=r(8068),c=r(9675),f=r(5345),l=Function,h=function(t){try{return l('"use strict"; return ('+t+").constructor;")()}catch(t){}},p=Object.getOwnPropertyDescriptor;if(p)try{p({},"")}catch(t){p=null}var d=function(){throw new c},y=p?function(){try{return d}catch(t){try{return p(arguments,"callee").get}catch(t){return d}}}():d,b=r(4039)(),g=r(24)(),w=Object.getPrototypeOf||(g?function(t){return t.__proto__}:null),v={},m="undefined"!=typeof Uint8Array&&w?w(Uint8Array):n,_={__proto__:null,"%AggregateError%":"undefined"==typeof AggregateError?n:AggregateError,"%Array%":Array,"%ArrayBuffer%":"undefined"==typeof ArrayBuffer?n:ArrayBuffer,"%ArrayIteratorPrototype%":b&&w?w([][Symbol.iterator]()):n,"%AsyncFromSyncIteratorPrototype%":n,"%AsyncFunction%":v,"%AsyncGenerator%":v,"%AsyncGeneratorFunction%":v,"%AsyncIteratorPrototype%":v,"%Atomics%":"undefined"==typeof Atomics?n:Atomics,"%BigInt%":"undefined"==typeof BigInt?n:BigInt,"%BigInt64Array%":"undefined"==typeof BigInt64Array?n:BigInt64Array,"%BigUint64Array%":"undefined"==typeof BigUint64Array?n:BigUint64Array,"%Boolean%":Boolean,"%DataView%":"undefined"==typeof DataView?n:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":i,"%eval%":eval,"%EvalError%":o,"%Float32Array%":"undefined"==typeof Float32Array?n:Float32Array,"%Float64Array%":"undefined"==typeof Float64Array?n:Float64Array,"%FinalizationRegistry%":"undefined"==typeof FinalizationRegistry?n:FinalizationRegistry,"%Function%":l,"%GeneratorFunction%":v,"%Int8Array%":"undefined"==typeof Int8Array?n:Int8Array,"%Int16Array%":"undefined"==typeof Int16Array?n:Int16Array,"%Int32Array%":"undefined"==typeof Int32Array?n:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":b&&w?w(w([][Symbol.iterator]())):n,"%JSON%":"object"==typeof JSON?JSON:n,"%Map%":"undefined"==typeof Map?n:Map,"%MapIteratorPrototype%":"undefined"!=typeof Map&&b&&w?w((new Map)[Symbol.iterator]()):n,"%Math%":Math,"%Number%":Number,"%Object%":Object,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":"undefined"==typeof Promise?n:Promise,"%Proxy%":"undefined"==typeof Proxy?n:Proxy,"%RangeError%":a,"%ReferenceError%":s,"%Reflect%":"undefined"==typeof Reflect?n:Reflect,"%RegExp%":RegExp,"%Set%":"undefined"==typeof Set?n:Set,"%SetIteratorPrototype%":"undefined"!=typeof Set&&b&&w?w((new Set)[Symbol.iterator]()):n,"%SharedArrayBuffer%":"undefined"==typeof SharedArrayBuffer?n:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":b&&w?w(""[Symbol.iterator]()):n,"%Symbol%":b?Symbol:n,"%SyntaxError%":u,"%ThrowTypeError%":y,"%TypedArray%":m,"%TypeError%":c,"%Uint8Array%":"undefined"==typeof Uint8Array?n:Uint8Array,"%Uint8ClampedArray%":"undefined"==typeof Uint8ClampedArray?n:Uint8ClampedArray,"%Uint16Array%":"undefined"==typeof Uint16Array?n:Uint16Array,"%Uint32Array%":"undefined"==typeof Uint32Array?n:Uint32Array,"%URIError%":f,"%WeakMap%":"undefined"==typeof WeakMap?n:WeakMap,"%WeakRef%":"undefined"==typeof WeakRef?n:WeakRef,"%WeakSet%":"undefined"==typeof WeakSet?n:WeakSet};if(w)try{null.error}catch(t){var E=w(w(t));_["%Error.prototype%"]=E}var S=function t(e){var r;if("%AsyncFunction%"===e)r=h("async function () {}");else if("%GeneratorFunction%"===e)r=h("function* () {}");else if("%AsyncGeneratorFunction%"===e)r=h("async function* () {}");else if("%AsyncGenerator%"===e){var n=t("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if("%AsyncIteratorPrototype%"===e){var i=t("%AsyncGenerator%");i&&w&&(r=w(i.prototype))}return _[e]=r,r},k={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},T=r(6743),O=r(9957),x=T.call(Function.call,Array.prototype.concat),A=T.call(Function.apply,Array.prototype.splice),P=T.call(Function.call,String.prototype.replace),I=T.call(Function.call,String.prototype.slice),R=T.call(Function.call,RegExp.prototype.exec),L=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,B=/\\(\\)?/g,U=function(t,e){var r,n=t;if(O(k,n)&&(n="%"+(r=k[n])[0]+"%"),O(_,n)){var i=_[n];if(i===v&&(i=S(n)),void 0===i&&!e)throw new c("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:r,name:n,value:i}}throw new u("intrinsic "+t+" does not exist!")};t.exports=function(t,e){if("string"!=typeof t||0===t.length)throw new c("intrinsic name must be a non-empty string");if(arguments.length>1&&"boolean"!=typeof e)throw new c('"allowMissing" argument must be a boolean');if(null===R(/^%?[^%]*%?$/,t))throw new u("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var r=function(t){var e=I(t,0,1),r=I(t,-1);if("%"===e&&"%"!==r)throw new u("invalid intrinsic syntax, expected closing `%`");if("%"===r&&"%"!==e)throw new u("invalid intrinsic syntax, expected opening `%`");var n=[];return P(t,L,(function(t,e,r,i){n[n.length]=r?P(i,B,"$1"):e||t})),n}(t),n=r.length>0?r[0]:"",i=U("%"+n+"%",e),o=i.name,a=i.value,s=!1,f=i.alias;f&&(n=f[0],A(r,x([0,1],f)));for(var l=1,h=!0;l<r.length;l+=1){var d=r[l],y=I(d,0,1),b=I(d,-1);if(('"'===y||"'"===y||"`"===y||'"'===b||"'"===b||"`"===b)&&y!==b)throw new u("property names with quotes must have matching quotes");if("constructor"!==d&&h||(s=!0),O(_,o="%"+(n+="."+d)+"%"))a=_[o];else if(null!=a){if(!(d in a)){if(!e)throw new c("base intrinsic for "+t+" exists, but the property is not available.");return}if(p&&l+1>=r.length){var g=p(a,d);a=(h=!!g)&&"get"in g&&!("originalValue"in g.get)?g.get:a[d]}else h=O(a,d),a=a[d];h&&!s&&(_[o]=a)}}return a}},5795:(t,e,r)=>{var n=r(453)("%Object.getOwnPropertyDescriptor%",!0);if(n)try{n([],"length")}catch(t){n=null}t.exports=n},592:(t,e,r)=>{var n=r(655),i=function(){return!!n};i.hasArrayLengthDefineBug=function(){if(!n)return null;try{return 1!==n([],"length",{value:1}).length}catch(t){return!0}},t.exports=i},24:t=>{var e={__proto__:null,foo:{}},r=Object;t.exports=function(){return{__proto__:e}.foo===e.foo&&!(e instanceof r)}},4039:(t,e,r)=>{var n="undefined"!=typeof Symbol&&Symbol,i=r(1333);t.exports=function(){return"function"==typeof n&&"function"==typeof Symbol&&"symbol"==typeof n("foo")&&"symbol"==typeof Symbol("bar")&&i()}},1333:t=>{t.exports=function(){if("function"!=typeof Symbol||"function"!=typeof Object.getOwnPropertySymbols)return!1;if("symbol"==typeof Symbol.iterator)return!0;var t={},e=Symbol("test"),r=Object(e);if("string"==typeof e)return!1;if("[object Symbol]"!==Object.prototype.toString.call(e))return!1;if("[object Symbol]"!==Object.prototype.toString.call(r))return!1;for(e in t[e]=42,t)return!1;if("function"==typeof Object.keys&&0!==Object.keys(t).length)return!1;if("function"==typeof Object.getOwnPropertyNames&&0!==Object.getOwnPropertyNames(t).length)return!1;var n=Object.getOwnPropertySymbols(t);if(1!==n.length||n[0]!==e)return!1;if(!Object.prototype.propertyIsEnumerable.call(t,e))return!1;if("function"==typeof Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);if(42!==i.value||!0!==i.enumerable)return!1}return!0}},9092:(t,e,r)=>{var n=r(1333);t.exports=function(){return n()&&!!Symbol.toStringTag}},4729:(t,e,r)=>{var n=r(2861).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){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 a=0,s=8*t.length;s>0;++a)this._length[a]+=s,(s=this._length[a]/4294967296|0)>0&&(this._length[a]-=4294967296*s);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,a,s,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"))a="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(s=t).length||-1===s.indexOf(".",u)?"argument":"property");a='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return a+". 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(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6736),a=r(2192);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.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",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.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(5606);t.exports=T,T.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1181),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(2382);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(2389),y=r(1468),b=r(8775).getHighWaterMark,g=r(2260).F,w=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(T,s);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(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=b(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&&(l||(l=r(7137).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(2818),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.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?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,R(t)))}}(t,s);else if(i||(a=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}(s,e)),a)E(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?E(t,new _):x(t,s,e,!0);else if(s.ended)E(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):L(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,L(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function x(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&&I(t)),L(t,e)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.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),O(this,t,e,!1,r)},T.prototype.unshift=function(t){return O(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){l||(l=r(7137).I);var e=new l(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 A=1073741824;function P(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>=A?t=A:(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 I(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(R,t))}function R(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,C(t)}function L(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(B,t,e))}function B(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 N(t){o("readable nexttick read 0"),t.read(0)}function j(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(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 M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(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 H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}T.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?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(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=P(r,e))),null===(n=t>0?F(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&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new m("_read()"))},T.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 s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.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",l),f=!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&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(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",l),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},T.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 a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var r=s.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?I(this):n.reading||i.nextTick(N,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(U,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(U,this),e},T.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(j,t,e))}(this,t)),t.paused=!1,this},T.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},T.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 a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(4743)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=F,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,e){return void 0===p&&(p=r(5049)),p(T,t,e)})},3054:(t,e,r)=>{t.exports=f;var n=r(2260).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=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 f(t){if(!(this instanceof f))return new f(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",l)}function l(){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 s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.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)}},f.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))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},2192:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=T,T.WritableState=k;var a,s={deprecate:r(4643)},u=r(1181),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(1468),h=r(8775).getHighWaterMark,p=r(2260).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,v=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(2818),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,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 b;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(R,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),R(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||A(t,r),n?i.nextTick(x,t,r,a,o):x(t,r,a,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 T(t){var e=this instanceof(n=n||r(2818));if(!e&&!a.call(T,this))return new T(t);this._writableState=new k(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 O(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,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 x(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),R(t,e)}function A(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,O(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),R(t,e)}))}function R(t,e){var r=P(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(I,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)(T,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.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]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===T&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new g)},T.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new v:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else O(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||A(this,t))},T.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 _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.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,R(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}},4743:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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 a=r(5826),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=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[f])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[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?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[l]=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),g);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",b.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=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,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,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}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=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{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:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},1468:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,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 a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),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,a=i.ERR_STREAM_DESTROYED;function s(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 f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(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 s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(5826)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!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 a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))}))}));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)},7137:(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=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){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 f(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 l(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=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(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}},9957:(t,e,r)=>{var n=Function.prototype.call,i=Object.prototype.hasOwnProperty,o=r(6743);t.exports=o.call(n,i)},251:(t,e)=>{e.read=function(t,e,r,n,i){var o,a,s=8*i-n-1,u=(1<<s)-1,c=u>>1,f=-7,l=r?i-1:0,h=r?-1:1,p=t[e+l];for(l+=h,o=p&(1<<-f)-1,p>>=-f,f+=s;f>0;o=256*o+t[e+l],l+=h,f-=8);for(a=o&(1<<-f)-1,o>>=-f,f+=n;f>0;a=256*a+t[e+l],l+=h,f-=8);if(0===o)o=1-c;else{if(o===u)return a?NaN:1/0*(p?-1:1);a+=Math.pow(2,n),o-=c}return(p?-1:1)*a*Math.pow(2,o-n)},e.write=function(t,e,r,n,i,o){var a,s,u,c=8*o-i-1,f=(1<<c)-1,l=f>>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?(s=isNaN(e)?1:0,a=f):(a=Math.floor(Math.log(e)/Math.LN2),e*(u=Math.pow(2,-a))<1&&(a--,u*=2),(e+=a+l>=1?h/u:h*Math.pow(2,1-l))*u>=2&&(a++,u/=2),a+l>=f?(s=0,a=f):a+l>=1?(s=(e*u-1)*Math.pow(2,i),a+=l):(s=e*Math.pow(2,l-1)*Math.pow(2,i),a=0));i>=8;t[r+p]=255&s,p+=d,s/=256,i-=8);for(a=a<<i|s,c+=i;c>0;t[r+p]=255&a,p+=d,a/=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}}},7244:(t,e,r)=>{var n=r(9092)(),i=r(8075)("Object.prototype.toString"),o=function(t){return!(n&&t&&"object"==typeof t&&Symbol.toStringTag in t)&&"[object Arguments]"===i(t)},a=function(t){return!!o(t)||null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Array]"!==i(t)&&"[object Function]"===i(t.callee)},s=function(){return o(arguments)}();o.isLegacyArguments=a,t.exports=s?o:a},9600:t=>{var e,r,n=Function.prototype.toString,i="object"==typeof Reflect&&null!==Reflect&&Reflect.apply;if("function"==typeof i&&"function"==typeof Object.defineProperty)try{e=Object.defineProperty({},"length",{get:function(){throw r}}),r={},i((function(){throw 42}),null,e)}catch(t){t!==r&&(i=null)}else i=null;var o=/^\s*class\b/,a=function(t){try{var e=n.call(t);return o.test(e)}catch(t){return!1}},s=function(t){try{return!a(t)&&(n.call(t),!0)}catch(t){return!1}},u=Object.prototype.toString,c="function"==typeof Symbol&&!!Symbol.toStringTag,f=!(0 in[,]),l=function(){return!1};if("object"==typeof document){var h=document.all;u.call(h)===u.call(document.all)&&(l=function(t){if((f||!t)&&(void 0===t||"object"==typeof t))try{var e=u.call(t);return("[object HTMLAllCollection]"===e||"[object HTML document.all class]"===e||"[object HTMLCollection]"===e||"[object Object]"===e)&&null==t("")}catch(t){}return!1})}t.exports=i?function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;try{i(t,null,e)}catch(t){if(t!==r)return!1}return!a(t)&&s(t)}:function(t){if(l(t))return!0;if(!t)return!1;if("function"!=typeof t&&"object"!=typeof t)return!1;if(c)return s(t);if(a(t))return!1;var e=u.call(t);return!("[object Function]"!==e&&"[object GeneratorFunction]"!==e&&!/^\[object HTML/.test(e))&&s(t)}},8184:(t,e,r)=>{var n,i=Object.prototype.toString,o=Function.prototype.toString,a=/^\s*(?:function)?\*/,s=r(9092)(),u=Object.getPrototypeOf;t.exports=function(t){if("function"!=typeof t)return!1;if(a.test(o.call(t)))return!0;if(!s)return"[object GeneratorFunction]"===i.call(t);if(!u)return!1;if(void 0===n){var e=function(){if(!s)return!1;try{return Function("return function*() {}")()}catch(t){}}();n=!!e&&u(e)}return u(t)===n}},3003:t=>{t.exports=function(t){return t!=t}},4133:(t,e,r)=>{var n=r(487),i=r(8452),o=r(3003),a=r(6642),s=r(2464),u=n(a(),Number);i(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},6642:(t,e,r)=>{var n=r(3003);t.exports=function(){return Number.isNaN&&Number.isNaN(NaN)&&!Number.isNaN("a")?Number.isNaN:n}},2464:(t,e,r)=>{var n=r(8452),i=r(6642);t.exports=function(){var t=i();return n(Number,{isNaN:t},{isNaN:function(){return Number.isNaN!==t}}),t}},5680:(t,e,r)=>{var n=r(5767);t.exports=function(t){return!!n(t)}},9211:t=>{var e=function(t){return t!=t};t.exports=function(t,r){return 0===t&&0===r?1/t==1/r:t===r||!(!e(t)||!e(r))}},7653:(t,e,r)=>{var n=r(8452),i=r(487),o=r(9211),a=r(9394),s=r(6576),u=i(a(),Object);n(u,{getPolyfill:a,implementation:o,shim:s}),t.exports=u},9394:(t,e,r)=>{var n=r(9211);t.exports=function(){return"function"==typeof Object.is?Object.is:n}},6576:(t,e,r)=>{var n=r(9394),i=r(8452);t.exports=function(){var t=n();return i(Object,{is:t},{is:function(){return Object.is!==t}}),t}},8875:(t,e,r)=>{var n;if(!Object.keys){var i=Object.prototype.hasOwnProperty,o=Object.prototype.toString,a=r(1093),s=Object.prototype.propertyIsEnumerable,u=!s.call({toString:null},"toString"),c=s.call((function(){}),"prototype"),f=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],l=function(t){var e=t.constructor;return e&&e.prototype===t},h={$applicationCache:!0,$console:!0,$external:!0,$frame:!0,$frameElement:!0,$frames:!0,$innerHeight:!0,$innerWidth:!0,$onmozfullscreenchange:!0,$onmozfullscreenerror:!0,$outerHeight:!0,$outerWidth:!0,$pageXOffset:!0,$pageYOffset:!0,$parent:!0,$scrollLeft:!0,$scrollTop:!0,$scrollX:!0,$scrollY:!0,$self:!0,$webkitIndexedDB:!0,$webkitStorageInfo:!0,$window:!0},p=function(){if("undefined"==typeof window)return!1;for(var t in window)try{if(!h["$"+t]&&i.call(window,t)&&null!==window[t]&&"object"==typeof window[t])try{l(window[t])}catch(t){return!0}}catch(t){return!0}return!1}();n=function(t){var e=null!==t&&"object"==typeof t,r="[object Function]"===o.call(t),n=a(t),s=e&&"[object String]"===o.call(t),h=[];if(!e&&!r&&!n)throw new TypeError("Object.keys called on a non-object");var d=c&&r;if(s&&t.length>0&&!i.call(t,0))for(var y=0;y<t.length;++y)h.push(String(y));if(n&&t.length>0)for(var b=0;b<t.length;++b)h.push(String(b));else for(var g in t)d&&"prototype"===g||!i.call(t,g)||h.push(String(g));if(u)for(var w=function(t){if("undefined"==typeof window||!p)return l(t);try{return l(t)}catch(t){return!1}}(t),v=0;v<f.length;++v)w&&"constructor"===f[v]||!i.call(t,f[v])||h.push(f[v]);return h}}t.exports=n},1189:(t,e,r)=>{var n=Array.prototype.slice,i=r(1093),o=Object.keys,a=o?function(t){return o(t)}:r(8875),s=Object.keys;a.shim=function(){if(Object.keys){var t=function(){var t=Object.keys(arguments);return t&&t.length===arguments.length}(1,2);t||(Object.keys=function(t){return i(t)?s(n.call(t)):s(t)})}else Object.keys=a;return Object.keys||a},t.exports=a},1093:t=>{var e=Object.prototype.toString;t.exports=function(t){var r=e.call(t),n="[object Arguments]"===r;return n||(n="[object Array]"!==r&&null!==t&&"object"==typeof t&&"number"==typeof t.length&&t.length>=0&&"[object Function]"===e.call(t.callee)),n}},8403:(t,e,r)=>{var n=r(1189),i=r(1333)(),o=r(8075),a=Object,s=o("Array.prototype.push"),u=o("Object.prototype.propertyIsEnumerable"),c=i?Object.getOwnPropertySymbols:null;t.exports=function(t,e){if(null==t)throw new TypeError("target must be an object");var r=a(t);if(1===arguments.length)return r;for(var o=1;o<arguments.length;++o){var f=a(arguments[o]),l=n(f),h=i&&(Object.getOwnPropertySymbols||c);if(h)for(var p=h(f),d=0;d<p.length;++d){var y=p[d];u(f,y)&&s(l,y)}for(var b=0;b<l.length;++b){var g=l[b];if(u(f,g)){var w=f[g];r[g]=w}}}return r}},1514:(t,e,r)=>{var n=r(8403);t.exports=function(){return Object.assign?function(){if(!Object.assign)return!1;for(var t="abcdefghijklmnopqrst",e=t.split(""),r={},n=0;n<e.length;++n)r[e[n]]=e[n];var i=Object.assign({},r),o="";for(var a in i)o+=a;return t!==o}()||function(){if(!Object.assign||!Object.preventExtensions)return!1;var t=Object.preventExtensions({1:2});try{Object.assign(t,"xy")}catch(e){return"y"===t[1]}return!1}()?n:Object.assign:n}},9805:(t,e)=>{var r="undefined"!=typeof Uint8Array&&"undefined"!=typeof Uint16Array&&"undefined"!=typeof Int32Array;function n(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.assign=function(t){for(var e=Array.prototype.slice.call(arguments,1);e.length;){var r=e.shift();if(r){if("object"!=typeof r)throw new TypeError(r+"must be non-object");for(var i in r)n(r,i)&&(t[i]=r[i])}}return t},e.shrinkBuf=function(t,e){return t.length===e?t:t.subarray?t.subarray(0,e):(t.length=e,t)};var i={arraySet:function(t,e,r,n,i){if(e.subarray&&t.subarray)t.set(e.subarray(r,r+n),i);else for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){var e,r,n,i,o,a;for(n=0,e=0,r=t.length;e<r;e++)n+=t[e].length;for(a=new Uint8Array(n),i=0,e=0,r=t.length;e<r;e++)o=t[e],a.set(o,i),i+=o.length;return a}},o={arraySet:function(t,e,r,n,i){for(var o=0;o<n;o++)t[i+o]=e[r+o]},flattenChunks:function(t){return[].concat.apply([],t)}};e.setTyped=function(t){t?(e.Buf8=Uint8Array,e.Buf16=Uint16Array,e.Buf32=Int32Array,e.assign(e,i)):(e.Buf8=Array,e.Buf16=Array,e.Buf32=Array,e.assign(e,o))},e.setTyped(r)},3269:t=>{t.exports=function(t,e,r,n){for(var i=65535&t,o=t>>>16&65535,a=0;0!==r;){r-=a=r>2e3?2e3:r;do{o=o+(i=i+e[n++]|0)|0}while(--a);i%=65521,o%=65521}return i|o<<16}},9681:t=>{t.exports={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8}},4823:t=>{var e=function(){for(var t,e=[],r=0;r<256;r++){t=r;for(var n=0;n<8;n++)t=1&t?3988292384^t>>>1:t>>>1;e[r]=t}return e}();t.exports=function(t,r,n,i){var o=e,a=i+n;t^=-1;for(var s=i;s<a;s++)t=t>>>8^o[255&(t^r[s])];return~t}},8411:(t,e,r)=>{var n,i=r(9805),o=r(3665),a=r(3269),s=r(4823),u=r(4674),c=-2,f=258,l=262,h=103,p=113,d=666;function y(t,e){return t.msg=u[e],e}function b(t){return(t<<1)-(t>4?9:0)}function g(t){for(var e=t.length;--e>=0;)t[e]=0}function w(t){var e=t.state,r=e.pending;r>t.avail_out&&(r=t.avail_out),0!==r&&(i.arraySet(t.output,e.pending_buf,e.pending_out,r,t.next_out),t.next_out+=r,e.pending_out+=r,t.total_out+=r,t.avail_out-=r,e.pending-=r,0===e.pending&&(e.pending_out=0))}function v(t,e){o._tr_flush_block(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,w(t.strm)}function m(t,e){t.pending_buf[t.pending++]=e}function _(t,e){t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e}function E(t,e){var r,n,i=t.max_chain_length,o=t.strstart,a=t.prev_length,s=t.nice_match,u=t.strstart>t.w_size-l?t.strstart-(t.w_size-l):0,c=t.window,h=t.w_mask,p=t.prev,d=t.strstart+f,y=c[o+a-1],b=c[o+a];t.prev_length>=t.good_match&&(i>>=2),s>t.lookahead&&(s=t.lookahead);do{if(c[(r=e)+a]===b&&c[r+a-1]===y&&c[r]===c[o]&&c[++r]===c[o+1]){o+=2,r++;do{}while(c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&c[++o]===c[++r]&&o<d);if(n=f-(d-o),o=d-f,n>a){if(t.match_start=e,a=n,n>=s)break;y=c[o+a-1],b=c[o+a]}}}while((e=p[e&h])>u&&0!=--i);return a<=t.lookahead?a:t.lookahead}function S(t){var e,r,n,o,u,c,f,h,p,d,y=t.w_size;do{if(o=t.window_size-t.lookahead-t.strstart,t.strstart>=y+(y-l)){i.arraySet(t.window,t.window,y,y,0),t.match_start-=y,t.strstart-=y,t.block_start-=y,e=r=t.hash_size;do{n=t.head[--e],t.head[e]=n>=y?n-y:0}while(--r);e=r=y;do{n=t.prev[--e],t.prev[e]=n>=y?n-y:0}while(--r);o+=y}if(0===t.strm.avail_in)break;if(c=t.strm,f=t.window,h=t.strstart+t.lookahead,p=o,d=void 0,(d=c.avail_in)>p&&(d=p),r=0===d?0:(c.avail_in-=d,i.arraySet(f,c.input,c.next_in,d,h),1===c.state.wrap?c.adler=a(c.adler,f,d,h):2===c.state.wrap&&(c.adler=s(c.adler,f,d,h)),c.next_in+=d,c.total_in+=d,d),t.lookahead+=r,t.lookahead+t.insert>=3)for(u=t.strstart-t.insert,t.ins_h=t.window[u],t.ins_h=(t.ins_h<<t.hash_shift^t.window[u+1])&t.hash_mask;t.insert&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[u+3-1])&t.hash_mask,t.prev[u&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=u,u++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<l&&0!==t.strm.avail_in)}function k(t,e){for(var r,n;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==r&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r)),t.match_length>=3)if(n=o._tr_tally(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!=--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+1])&t.hash_mask;else n=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(n&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}function T(t,e){for(var r,n,i;;){if(t.lookahead<l){if(S(t),t.lookahead<l&&0===e)return 1;if(0===t.lookahead)break}if(r=0,t.lookahead>=3&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==r&&t.prev_length<t.max_lazy_match&&t.strstart-r<=t.w_size-l&&(t.match_length=E(t,r),t.match_length<=5&&(1===t.strategy||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){i=t.strstart+t.lookahead-3,n=o._tr_tally(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=i&&(t.ins_h=(t.ins_h<<t.hash_shift^t.window[t.strstart+3-1])&t.hash_mask,r=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!=--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,n&&(v(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if((n=o._tr_tally(t,0,t.window[t.strstart-1]))&&v(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(n=o._tr_tally(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}function O(t,e,r,n,i){this.good_length=t,this.max_lazy=e,this.nice_length=r,this.max_chain=n,this.func=i}function x(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=8,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new i.Buf16(1146),this.dyn_dtree=new i.Buf16(122),this.bl_tree=new i.Buf16(78),g(this.dyn_ltree),g(this.dyn_dtree),g(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new i.Buf16(16),this.heap=new i.Buf16(573),g(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new i.Buf16(573),g(this.depth),this.l_buf=0,this.lit_bufsize=0,this.last_lit=0,this.d_buf=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}function A(t){var e;return t&&t.state?(t.total_in=t.total_out=0,t.data_type=2,(e=t.state).pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=e.wrap?42:p,t.adler=2===e.wrap?0:1,e.last_flush=0,o._tr_init(e),0):y(t,c)}function P(t){var e=A(t);return 0===e&&function(t){t.window_size=2*t.w_size,g(t.head),t.max_lazy_match=n[t.level].max_lazy,t.good_match=n[t.level].good_length,t.nice_match=n[t.level].nice_length,t.max_chain_length=n[t.level].max_chain,t.strstart=0,t.block_start=0,t.lookahead=0,t.insert=0,t.match_length=t.prev_length=2,t.match_available=0,t.ins_h=0}(t.state),e}function I(t,e,r,n,o,a){if(!t)return c;var s=1;if(-1===e&&(e=6),n<0?(s=0,n=-n):n>15&&(s=2,n-=16),o<1||o>9||8!==r||n<8||n>15||e<0||e>9||a<0||a>4)return y(t,c);8===n&&(n=9);var u=new x;return t.state=u,u.strm=t,u.wrap=s,u.gzhead=null,u.w_bits=n,u.w_size=1<<u.w_bits,u.w_mask=u.w_size-1,u.hash_bits=o+7,u.hash_size=1<<u.hash_bits,u.hash_mask=u.hash_size-1,u.hash_shift=~~((u.hash_bits+3-1)/3),u.window=new i.Buf8(2*u.w_size),u.head=new i.Buf16(u.hash_size),u.prev=new i.Buf16(u.w_size),u.lit_bufsize=1<<o+6,u.pending_buf_size=4*u.lit_bufsize,u.pending_buf=new i.Buf8(u.pending_buf_size),u.d_buf=1*u.lit_bufsize,u.l_buf=3*u.lit_bufsize,u.level=e,u.strategy=a,u.method=r,P(t)}n=[new O(0,0,0,0,(function(t,e){var r=65535;for(r>t.pending_buf_size-5&&(r=t.pending_buf_size-5);;){if(t.lookahead<=1){if(S(t),0===t.lookahead&&0===e)return 1;if(0===t.lookahead)break}t.strstart+=t.lookahead,t.lookahead=0;var n=t.block_start+r;if((0===t.strstart||t.strstart>=n)&&(t.lookahead=t.strstart-n,t.strstart=n,v(t,!1),0===t.strm.avail_out))return 1;if(t.strstart-t.block_start>=t.w_size-l&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):(t.strstart>t.block_start&&(v(t,!1),t.strm.avail_out),1)})),new O(4,4,8,4,k),new O(4,5,16,8,k),new O(4,6,32,32,k),new O(4,4,16,16,T),new O(8,16,32,32,T),new O(8,16,128,128,T),new O(8,32,128,256,T),new O(32,128,258,1024,T),new O(32,258,258,4096,T)],e.deflateInit=function(t,e){return I(t,e,8,15,8,0)},e.deflateInit2=I,e.deflateReset=P,e.deflateResetKeep=A,e.deflateSetHeader=function(t,e){return t&&t.state?2!==t.state.wrap?c:(t.state.gzhead=e,0):c},e.deflate=function(t,e){var r,i,a,u;if(!t||!t.state||e>5||e<0)return t?y(t,c):c;if(i=t.state,!t.output||!t.input&&0!==t.avail_in||i.status===d&&4!==e)return y(t,0===t.avail_out?-5:c);if(i.strm=t,r=i.last_flush,i.last_flush=e,42===i.status)if(2===i.wrap)t.adler=0,m(i,31),m(i,139),m(i,8),i.gzhead?(m(i,(i.gzhead.text?1:0)+(i.gzhead.hcrc?2:0)+(i.gzhead.extra?4:0)+(i.gzhead.name?8:0)+(i.gzhead.comment?16:0)),m(i,255&i.gzhead.time),m(i,i.gzhead.time>>8&255),m(i,i.gzhead.time>>16&255),m(i,i.gzhead.time>>24&255),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,255&i.gzhead.os),i.gzhead.extra&&i.gzhead.extra.length&&(m(i,255&i.gzhead.extra.length),m(i,i.gzhead.extra.length>>8&255)),i.gzhead.hcrc&&(t.adler=s(t.adler,i.pending_buf,i.pending,0)),i.gzindex=0,i.status=69):(m(i,0),m(i,0),m(i,0),m(i,0),m(i,0),m(i,9===i.level?2:i.strategy>=2||i.level<2?4:0),m(i,3),i.status=p);else{var l=8+(i.w_bits-8<<4)<<8;l|=(i.strategy>=2||i.level<2?0:i.level<6?1:6===i.level?2:3)<<6,0!==i.strstart&&(l|=32),l+=31-l%31,i.status=p,_(i,l),0!==i.strstart&&(_(i,t.adler>>>16),_(i,65535&t.adler)),t.adler=1}if(69===i.status)if(i.gzhead.extra){for(a=i.pending;i.gzindex<(65535&i.gzhead.extra.length)&&(i.pending!==i.pending_buf_size||(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),w(t),a=i.pending,i.pending!==i.pending_buf_size));)m(i,255&i.gzhead.extra[i.gzindex]),i.gzindex++;i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),i.gzindex===i.gzhead.extra.length&&(i.gzindex=0,i.status=73)}else i.status=73;if(73===i.status)if(i.gzhead.name){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),w(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.name.length?255&i.gzhead.name.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.gzindex=0,i.status=91)}else i.status=91;if(91===i.status)if(i.gzhead.comment){a=i.pending;do{if(i.pending===i.pending_buf_size&&(i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),w(t),a=i.pending,i.pending===i.pending_buf_size)){u=1;break}u=i.gzindex<i.gzhead.comment.length?255&i.gzhead.comment.charCodeAt(i.gzindex++):0,m(i,u)}while(0!==u);i.gzhead.hcrc&&i.pending>a&&(t.adler=s(t.adler,i.pending_buf,i.pending-a,a)),0===u&&(i.status=h)}else i.status=h;if(i.status===h&&(i.gzhead.hcrc?(i.pending+2>i.pending_buf_size&&w(t),i.pending+2<=i.pending_buf_size&&(m(i,255&t.adler),m(i,t.adler>>8&255),t.adler=0,i.status=p)):i.status=p),0!==i.pending){if(w(t),0===t.avail_out)return i.last_flush=-1,0}else if(0===t.avail_in&&b(e)<=b(r)&&4!==e)return y(t,-5);if(i.status===d&&0!==t.avail_in)return y(t,-5);if(0!==t.avail_in||0!==i.lookahead||0!==e&&i.status!==d){var E=2===i.strategy?function(t,e){for(var r;;){if(0===t.lookahead&&(S(t),0===t.lookahead)){if(0===e)return 1;break}if(t.match_length=0,r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,r&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(i,e):3===i.strategy?function(t,e){for(var r,n,i,a,s=t.window;;){if(t.lookahead<=f){if(S(t),t.lookahead<=f&&0===e)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(n=s[i=t.strstart-1])===s[++i]&&n===s[++i]&&n===s[++i]){a=t.strstart+f;do{}while(n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&n===s[++i]&&i<a);t.match_length=f-(a-i),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(r=o._tr_tally(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(r=o._tr_tally(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),r&&(v(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,4===e?(v(t,!0),0===t.strm.avail_out?3:4):t.last_lit&&(v(t,!1),0===t.strm.avail_out)?1:2}(i,e):n[i.level].func(i,e);if(3!==E&&4!==E||(i.status=d),1===E||3===E)return 0===t.avail_out&&(i.last_flush=-1),0;if(2===E&&(1===e?o._tr_align(i):5!==e&&(o._tr_stored_block(i,0,0,!1),3===e&&(g(i.head),0===i.lookahead&&(i.strstart=0,i.block_start=0,i.insert=0))),w(t),0===t.avail_out))return i.last_flush=-1,0}return 4!==e?0:i.wrap<=0?1:(2===i.wrap?(m(i,255&t.adler),m(i,t.adler>>8&255),m(i,t.adler>>16&255),m(i,t.adler>>24&255),m(i,255&t.total_in),m(i,t.total_in>>8&255),m(i,t.total_in>>16&255),m(i,t.total_in>>24&255)):(_(i,t.adler>>>16),_(i,65535&t.adler)),w(t),i.wrap>0&&(i.wrap=-i.wrap),0!==i.pending?0:1)},e.deflateEnd=function(t){var e;return t&&t.state?42!==(e=t.state.status)&&69!==e&&73!==e&&91!==e&&e!==h&&e!==p&&e!==d?y(t,c):(t.state=null,e===p?y(t,-3):0):c},e.deflateSetDictionary=function(t,e){var r,n,o,s,u,f,l,h,p=e.length;if(!t||!t.state)return c;if(2===(s=(r=t.state).wrap)||1===s&&42!==r.status||r.lookahead)return c;for(1===s&&(t.adler=a(t.adler,e,p,0)),r.wrap=0,p>=r.w_size&&(0===s&&(g(r.head),r.strstart=0,r.block_start=0,r.insert=0),h=new i.Buf8(r.w_size),i.arraySet(h,e,p-r.w_size,r.w_size,0),e=h,p=r.w_size),u=t.avail_in,f=t.next_in,l=t.input,t.avail_in=p,t.next_in=0,t.input=e,S(r);r.lookahead>=3;){n=r.strstart,o=r.lookahead-2;do{r.ins_h=(r.ins_h<<r.hash_shift^r.window[n+3-1])&r.hash_mask,r.prev[n&r.w_mask]=r.head[r.ins_h],r.head[r.ins_h]=n,n++}while(--o);r.strstart=n,r.lookahead=2,S(r)}return r.strstart+=r.lookahead,r.block_start=r.strstart,r.insert=r.lookahead,r.lookahead=0,r.match_length=r.prev_length=2,r.match_available=0,t.next_in=f,t.input=l,t.avail_in=u,r.wrap=s,0},e.deflateInfo="pako deflate (from Nodeca project)"},7293:t=>{t.exports=function(t,e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,w,v,m,_,E,S,k,T,O;r=t.state,n=t.next_in,T=t.input,i=n+(t.avail_in-5),o=t.next_out,O=t.output,a=o-(e-t.avail_out),s=o+(t.avail_out-257),u=r.dmax,c=r.wsize,f=r.whave,l=r.wnext,h=r.window,p=r.hold,d=r.bits,y=r.lencode,b=r.distcode,g=(1<<r.lenbits)-1,w=(1<<r.distbits)-1;t:do{d<15&&(p+=T[n++]<<d,d+=8,p+=T[n++]<<d,d+=8),v=y[p&g];e:for(;;){if(p>>>=m=v>>>24,d-=m,0==(m=v>>>16&255))O[o++]=65535&v;else{if(!(16&m)){if(64&m){if(32&m){r.mode=12;break t}t.msg="invalid literal/length code",r.mode=30;break t}v=y[(65535&v)+(p&(1<<m)-1)];continue e}for(_=65535&v,(m&=15)&&(d<m&&(p+=T[n++]<<d,d+=8),_+=p&(1<<m)-1,p>>>=m,d-=m),d<15&&(p+=T[n++]<<d,d+=8,p+=T[n++]<<d,d+=8),v=b[p&w];;){if(p>>>=m=v>>>24,d-=m,16&(m=v>>>16&255)){if(E=65535&v,d<(m&=15)&&(p+=T[n++]<<d,(d+=8)<m&&(p+=T[n++]<<d,d+=8)),(E+=p&(1<<m)-1)>u){t.msg="invalid distance too far back",r.mode=30;break t}if(p>>>=m,d-=m,E>(m=o-a)){if((m=E-m)>f&&r.sane){t.msg="invalid distance too far back",r.mode=30;break t}if(S=0,k=h,0===l){if(S+=c-m,m<_){_-=m;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}}else if(l<m){if(S+=c+l-m,(m-=l)<_){_-=m;do{O[o++]=h[S++]}while(--m);if(S=0,l<_){_-=m=l;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}}}else if(S+=l-m,m<_){_-=m;do{O[o++]=h[S++]}while(--m);S=o-E,k=O}for(;_>2;)O[o++]=k[S++],O[o++]=k[S++],O[o++]=k[S++],_-=3;_&&(O[o++]=k[S++],_>1&&(O[o++]=k[S++]))}else{S=o-E;do{O[o++]=O[S++],O[o++]=O[S++],O[o++]=O[S++],_-=3}while(_>2);_&&(O[o++]=O[S++],_>1&&(O[o++]=O[S++]))}break}if(64&m){t.msg="invalid distance code",r.mode=30;break t}v=b[(65535&v)+(p&(1<<m)-1)]}}break}}while(n<i&&o<s);n-=_=d>>3,p&=(1<<(d-=_<<3))-1,t.next_in=n,t.next_out=o,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=o<s?s-o+257:257-(o-s),r.hold=p,r.bits=d}},1447:(t,e,r)=>{var n=r(9805),i=r(3269),o=r(4823),a=r(7293),s=r(1998),u=-2,c=12,f=30;function l(t){return(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24)}function h(){this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new n.Buf16(320),this.work=new n.Buf16(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}function p(t){var e;return t&&t.state?(e=t.state,t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=1,e.last=0,e.havedict=0,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new n.Buf32(852),e.distcode=e.distdyn=new n.Buf32(592),e.sane=1,e.back=-1,0):u}function d(t){var e;return t&&t.state?((e=t.state).wsize=0,e.whave=0,e.wnext=0,p(t)):u}function y(t,e){var r,n;return t&&t.state?(n=t.state,e<0?(r=0,e=-e):(r=1+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?u:(null!==n.window&&n.wbits!==e&&(n.window=null),n.wrap=r,n.wbits=e,d(t))):u}function b(t,e){var r,n;return t?(n=new h,t.state=n,n.window=null,0!==(r=y(t,e))&&(t.state=null),r):u}var g,w,v=!0;function m(t){if(v){var e;for(g=new n.Buf32(512),w=new n.Buf32(32),e=0;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(s(1,t.lens,0,288,g,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;s(2,t.lens,0,32,w,0,t.work,{bits:5}),v=!1}t.lencode=g,t.lenbits=9,t.distcode=w,t.distbits=5}function _(t,e,r,i){var o,a=t.state;return null===a.window&&(a.wsize=1<<a.wbits,a.wnext=0,a.whave=0,a.window=new n.Buf8(a.wsize)),i>=a.wsize?(n.arraySet(a.window,e,r-a.wsize,a.wsize,0),a.wnext=0,a.whave=a.wsize):((o=a.wsize-a.wnext)>i&&(o=i),n.arraySet(a.window,e,r-i,o,a.wnext),(i-=o)?(n.arraySet(a.window,e,r-i,i,0),a.wnext=i,a.whave=a.wsize):(a.wnext+=o,a.wnext===a.wsize&&(a.wnext=0),a.whave<a.wsize&&(a.whave+=o))),0}e.inflateReset=d,e.inflateReset2=y,e.inflateResetKeep=p,e.inflateInit=function(t){return b(t,15)},e.inflateInit2=b,e.inflate=function(t,e){var r,h,p,d,y,b,g,w,v,E,S,k,T,O,x,A,P,I,R,L,B,U,N,j,C=0,F=new n.Buf8(4),M=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15];if(!t||!t.state||!t.output||!t.input&&0!==t.avail_in)return u;(r=t.state).mode===c&&(r.mode=13),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,w=r.hold,v=r.bits,E=b,S=g,U=0;t:for(;;)switch(r.mode){case 1:if(0===r.wrap){r.mode=13;break}for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(2&r.wrap&&35615===w){r.check=0,F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0),w=0,v=0,r.mode=2;break}if(r.flags=0,r.head&&(r.head.done=!1),!(1&r.wrap)||(((255&w)<<8)+(w>>8))%31){t.msg="incorrect header check",r.mode=f;break}if(8!=(15&w)){t.msg="unknown compression method",r.mode=f;break}if(v-=4,B=8+(15&(w>>>=4)),0===r.wbits)r.wbits=B;else if(B>r.wbits){t.msg="invalid window size",r.mode=f;break}r.dmax=1<<B,t.adler=r.check=1,r.mode=512&w?10:c,w=0,v=0;break;case 2:for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(r.flags=w,8!=(255&r.flags)){t.msg="unknown compression method",r.mode=f;break}if(57344&r.flags){t.msg="unknown header flags set",r.mode=f;break}r.head&&(r.head.text=w>>8&1),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0)),w=0,v=0,r.mode=3;case 3:for(;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.head&&(r.head.time=w),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,F[2]=w>>>16&255,F[3]=w>>>24&255,r.check=o(r.check,F,4,0)),w=0,v=0,r.mode=4;case 4:for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.head&&(r.head.xflags=255&w,r.head.os=w>>8),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0)),w=0,v=0,r.mode=5;case 5:if(1024&r.flags){for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.length=w,r.head&&(r.head.extra_len=w),512&r.flags&&(F[0]=255&w,F[1]=w>>>8&255,r.check=o(r.check,F,2,0)),w=0,v=0}else r.head&&(r.head.extra=null);r.mode=6;case 6:if(1024&r.flags&&((k=r.length)>b&&(k=b),k&&(r.head&&(B=r.head.extra_len-r.length,r.head.extra||(r.head.extra=new Array(r.head.extra_len)),n.arraySet(r.head.extra,h,d,k,B)),512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,r.length-=k),r.length))break t;r.length=0,r.mode=7;case 7:if(2048&r.flags){if(0===b)break t;k=0;do{B=h[d+k++],r.head&&B&&r.length<65536&&(r.head.name+=String.fromCharCode(B))}while(B&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,B)break t}else r.head&&(r.head.name=null);r.length=0,r.mode=8;case 8:if(4096&r.flags){if(0===b)break t;k=0;do{B=h[d+k++],r.head&&B&&r.length<65536&&(r.head.comment+=String.fromCharCode(B))}while(B&&k<b);if(512&r.flags&&(r.check=o(r.check,h,k,d)),b-=k,d+=k,B)break t}else r.head&&(r.head.comment=null);r.mode=9;case 9:if(512&r.flags){for(;v<16;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(w!==(65535&r.check)){t.msg="header crc mismatch",r.mode=f;break}w=0,v=0}r.head&&(r.head.hcrc=r.flags>>9&1,r.head.done=!0),t.adler=r.check=0,r.mode=c;break;case 10:for(;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}t.adler=r.check=l(w),w=0,v=0,r.mode=11;case 11:if(0===r.havedict)return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=w,r.bits=v,2;t.adler=r.check=1,r.mode=c;case c:if(5===e||6===e)break t;case 13:if(r.last){w>>>=7&v,v-=7&v,r.mode=27;break}for(;v<3;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}switch(r.last=1&w,v-=1,3&(w>>>=1)){case 0:r.mode=14;break;case 1:if(m(r),r.mode=20,6===e){w>>>=2,v-=2;break t}break;case 2:r.mode=17;break;case 3:t.msg="invalid block type",r.mode=f}w>>>=2,v-=2;break;case 14:for(w>>>=7&v,v-=7&v;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if((65535&w)!=(w>>>16^65535)){t.msg="invalid stored block lengths",r.mode=f;break}if(r.length=65535&w,w=0,v=0,r.mode=15,6===e)break t;case 15:r.mode=16;case 16:if(k=r.length){if(k>b&&(k=b),k>g&&(k=g),0===k)break t;n.arraySet(p,h,d,k,y),b-=k,d+=k,g-=k,y+=k,r.length-=k;break}r.mode=c;break;case 17:for(;v<14;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(r.nlen=257+(31&w),w>>>=5,v-=5,r.ndist=1+(31&w),w>>>=5,v-=5,r.ncode=4+(15&w),w>>>=4,v-=4,r.nlen>286||r.ndist>30){t.msg="too many length or distance symbols",r.mode=f;break}r.have=0,r.mode=18;case 18:for(;r.have<r.ncode;){for(;v<3;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.lens[M[r.have++]]=7&w,w>>>=3,v-=3}for(;r.have<19;)r.lens[M[r.have++]]=0;if(r.lencode=r.lendyn,r.lenbits=7,N={bits:r.lenbits},U=s(0,r.lens,0,19,r.lencode,0,r.work,N),r.lenbits=N.bits,U){t.msg="invalid code lengths set",r.mode=f;break}r.have=0,r.mode=19;case 19:for(;r.have<r.nlen+r.ndist;){for(;A=(C=r.lencode[w&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(P<16)w>>>=x,v-=x,r.lens[r.have++]=P;else{if(16===P){for(j=x+2;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(w>>>=x,v-=x,0===r.have){t.msg="invalid bit length repeat",r.mode=f;break}B=r.lens[r.have-1],k=3+(3&w),w>>>=2,v-=2}else if(17===P){for(j=x+3;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}v-=x,B=0,k=3+(7&(w>>>=x)),w>>>=3,v-=3}else{for(j=x+7;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}v-=x,B=0,k=11+(127&(w>>>=x)),w>>>=7,v-=7}if(r.have+k>r.nlen+r.ndist){t.msg="invalid bit length repeat",r.mode=f;break}for(;k--;)r.lens[r.have++]=B}}if(r.mode===f)break;if(0===r.lens[256]){t.msg="invalid code -- missing end-of-block",r.mode=f;break}if(r.lenbits=9,N={bits:r.lenbits},U=s(1,r.lens,0,r.nlen,r.lencode,0,r.work,N),r.lenbits=N.bits,U){t.msg="invalid literal/lengths set",r.mode=f;break}if(r.distbits=6,r.distcode=r.distdyn,N={bits:r.distbits},U=s(2,r.lens,r.nlen,r.ndist,r.distcode,0,r.work,N),r.distbits=N.bits,U){t.msg="invalid distances set",r.mode=f;break}if(r.mode=20,6===e)break t;case 20:r.mode=21;case 21:if(b>=6&&g>=258){t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=w,r.bits=v,a(t,S),y=t.next_out,p=t.output,g=t.avail_out,d=t.next_in,h=t.input,b=t.avail_in,w=r.hold,v=r.bits,r.mode===c&&(r.back=-1);break}for(r.back=0;A=(C=r.lencode[w&(1<<r.lenbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(A&&!(240&A)){for(I=x,R=A,L=P;A=(C=r.lencode[L+((w&(1<<I+R)-1)>>I)])>>>16&255,P=65535&C,!(I+(x=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}w>>>=I,v-=I,r.back+=I}if(w>>>=x,v-=x,r.back+=x,r.length=P,0===A){r.mode=26;break}if(32&A){r.back=-1,r.mode=c;break}if(64&A){t.msg="invalid literal/length code",r.mode=f;break}r.extra=15&A,r.mode=22;case 22:if(r.extra){for(j=r.extra;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.length+=w&(1<<r.extra)-1,w>>>=r.extra,v-=r.extra,r.back+=r.extra}r.was=r.length,r.mode=23;case 23:for(;A=(C=r.distcode[w&(1<<r.distbits)-1])>>>16&255,P=65535&C,!((x=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(!(240&A)){for(I=x,R=A,L=P;A=(C=r.distcode[L+((w&(1<<I+R)-1)>>I)])>>>16&255,P=65535&C,!(I+(x=C>>>24)<=v);){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}w>>>=I,v-=I,r.back+=I}if(w>>>=x,v-=x,r.back+=x,64&A){t.msg="invalid distance code",r.mode=f;break}r.offset=P,r.extra=15&A,r.mode=24;case 24:if(r.extra){for(j=r.extra;v<j;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}r.offset+=w&(1<<r.extra)-1,w>>>=r.extra,v-=r.extra,r.back+=r.extra}if(r.offset>r.dmax){t.msg="invalid distance too far back",r.mode=f;break}r.mode=25;case 25:if(0===g)break t;if(k=S-g,r.offset>k){if((k=r.offset-k)>r.whave&&r.sane){t.msg="invalid distance too far back",r.mode=f;break}k>r.wnext?(k-=r.wnext,T=r.wsize-k):T=r.wnext-k,k>r.length&&(k=r.length),O=r.window}else O=p,T=y-r.offset,k=r.length;k>g&&(k=g),g-=k,r.length-=k;do{p[y++]=O[T++]}while(--k);0===r.length&&(r.mode=21);break;case 26:if(0===g)break t;p[y++]=r.length,g--,r.mode=21;break;case 27:if(r.wrap){for(;v<32;){if(0===b)break t;b--,w|=h[d++]<<v,v+=8}if(S-=g,t.total_out+=S,r.total+=S,S&&(t.adler=r.check=r.flags?o(r.check,p,S,y-S):i(r.check,p,S,y-S)),S=g,(r.flags?w:l(w))!==r.check){t.msg="incorrect data check",r.mode=f;break}w=0,v=0}r.mode=28;case 28:if(r.wrap&&r.flags){for(;v<32;){if(0===b)break t;b--,w+=h[d++]<<v,v+=8}if(w!==(4294967295&r.total)){t.msg="incorrect length check",r.mode=f;break}w=0,v=0}r.mode=29;case 29:U=1;break t;case f:U=-3;break t;case 31:return-4;default:return u}return t.next_out=y,t.avail_out=g,t.next_in=d,t.avail_in=b,r.hold=w,r.bits=v,(r.wsize||S!==t.avail_out&&r.mode<f&&(r.mode<27||4!==e))&&_(t,t.output,t.next_out,S-t.avail_out)?(r.mode=31,-4):(E-=t.avail_in,S-=t.avail_out,t.total_in+=E,t.total_out+=S,r.total+=S,r.wrap&&S&&(t.adler=r.check=r.flags?o(r.check,p,S,t.next_out-S):i(r.check,p,S,t.next_out-S)),t.data_type=r.bits+(r.last?64:0)+(r.mode===c?128:0)+(20===r.mode||15===r.mode?256:0),(0===E&&0===S||4===e)&&0===U&&(U=-5),U)},e.inflateEnd=function(t){if(!t||!t.state)return u;var e=t.state;return e.window&&(e.window=null),t.state=null,0},e.inflateGetHeader=function(t,e){var r;return t&&t.state&&2&(r=t.state).wrap?(r.head=e,e.done=!1,0):u},e.inflateSetDictionary=function(t,e){var r,n=e.length;return t&&t.state?0!==(r=t.state).wrap&&11!==r.mode?u:11===r.mode&&i(1,e,n,0)!==r.check?-3:_(t,e,n,n)?(r.mode=31,-4):(r.havedict=1,0):u},e.inflateInfo="pako inflate (from Nodeca project)"},1998:(t,e,r)=>{var n=r(9805),i=[3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0],o=[16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78],a=[1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0],s=[16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64];t.exports=function(t,e,r,u,c,f,l,h){var p,d,y,b,g,w,v,m,_,E=h.bits,S=0,k=0,T=0,O=0,x=0,A=0,P=0,I=0,R=0,L=0,B=null,U=0,N=new n.Buf16(16),j=new n.Buf16(16),C=null,F=0;for(S=0;S<=15;S++)N[S]=0;for(k=0;k<u;k++)N[e[r+k]]++;for(x=E,O=15;O>=1&&0===N[O];O--);if(x>O&&(x=O),0===O)return c[f++]=20971520,c[f++]=20971520,h.bits=1,0;for(T=1;T<O&&0===N[T];T++);for(x<T&&(x=T),I=1,S=1;S<=15;S++)if(I<<=1,(I-=N[S])<0)return-1;if(I>0&&(0===t||1!==O))return-1;for(j[1]=0,S=1;S<15;S++)j[S+1]=j[S]+N[S];for(k=0;k<u;k++)0!==e[r+k]&&(l[j[e[r+k]]++]=k);if(0===t?(B=C=l,w=19):1===t?(B=i,U-=257,C=o,F-=257,w=256):(B=a,C=s,w=-1),L=0,k=0,S=T,g=f,A=x,P=0,y=-1,b=(R=1<<x)-1,1===t&&R>852||2===t&&R>592)return 1;for(;;){v=S-P,l[k]<w?(m=0,_=l[k]):l[k]>w?(m=C[F+l[k]],_=B[U+l[k]]):(m=96,_=0),p=1<<S-P,T=d=1<<A;do{c[g+(L>>P)+(d-=p)]=v<<24|m<<16|_}while(0!==d);for(p=1<<S-1;L&p;)p>>=1;if(0!==p?(L&=p-1,L+=p):L=0,k++,0==--N[S]){if(S===O)break;S=e[r+l[k]]}if(S>x&&(L&b)!==y){for(0===P&&(P=x),g+=T,I=1<<(A=S-P);A+P<O&&!((I-=N[A+P])<=0);)A++,I<<=1;if(R+=1<<A,1===t&&R>852||2===t&&R>592)return 1;c[y=L&b]=x<<24|A<<16|g-f}}return 0!==L&&(c[g+L]=S-P<<24|64<<16),h.bits=x,0}},4674:t=>{t.exports={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"}},3665:(t,e,r)=>{var n=r(9805);function i(t){for(var e=t.length;--e>=0;)t[e]=0}var o=[0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0],a=[0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13],s=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7],u=[16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15],c=new Array(576);i(c);var f=new Array(60);i(f);var l=new Array(512);i(l);var h=new Array(256);i(h);var p=new Array(29);i(p);var d,y,b,g=new Array(30);function w(t,e,r,n,i){this.static_tree=t,this.extra_bits=e,this.extra_base=r,this.elems=n,this.max_length=i,this.has_stree=t&&t.length}function v(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}function m(t){return t<256?l[t]:l[256+(t>>>7)]}function _(t,e){t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255}function E(t,e,r){t.bi_valid>16-r?(t.bi_buf|=e<<t.bi_valid&65535,_(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=r-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=r)}function S(t,e,r){E(t,r[2*e],r[2*e+1])}function k(t,e){var r=0;do{r|=1&t,t>>>=1,r<<=1}while(--e>0);return r>>>1}function T(t,e,r){var n,i,o=new Array(16),a=0;for(n=1;n<=15;n++)o[n]=a=a+r[n-1]<<1;for(i=0;i<=e;i++){var s=t[2*i+1];0!==s&&(t[2*i]=k(o[s]++,s))}}function O(t){var e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.last_lit=t.matches=0}function x(t){t.bi_valid>8?_(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0}function A(t,e,r,n){var i=2*e,o=2*r;return t[i]<t[o]||t[i]===t[o]&&n[e]<=n[r]}function P(t,e,r){for(var n=t.heap[r],i=r<<1;i<=t.heap_len&&(i<t.heap_len&&A(e,t.heap[i+1],t.heap[i],t.depth)&&i++,!A(e,n,t.heap[i],t.depth));)t.heap[r]=t.heap[i],r=i,i<<=1;t.heap[r]=n}function I(t,e,r){var n,i,s,u,c=0;if(0!==t.last_lit)do{n=t.pending_buf[t.d_buf+2*c]<<8|t.pending_buf[t.d_buf+2*c+1],i=t.pending_buf[t.l_buf+c],c++,0===n?S(t,i,e):(S(t,(s=h[i])+256+1,e),0!==(u=o[s])&&E(t,i-=p[s],u),S(t,s=m(--n),r),0!==(u=a[s])&&E(t,n-=g[s],u))}while(c<t.last_lit);S(t,256,e)}function R(t,e){var r,n,i,o=e.dyn_tree,a=e.stat_desc.static_tree,s=e.stat_desc.has_stree,u=e.stat_desc.elems,c=-1;for(t.heap_len=0,t.heap_max=573,r=0;r<u;r++)0!==o[2*r]?(t.heap[++t.heap_len]=c=r,t.depth[r]=0):o[2*r+1]=0;for(;t.heap_len<2;)o[2*(i=t.heap[++t.heap_len]=c<2?++c:0)]=1,t.depth[i]=0,t.opt_len--,s&&(t.static_len-=a[2*i+1]);for(e.max_code=c,r=t.heap_len>>1;r>=1;r--)P(t,o,r);i=u;do{r=t.heap[1],t.heap[1]=t.heap[t.heap_len--],P(t,o,1),n=t.heap[1],t.heap[--t.heap_max]=r,t.heap[--t.heap_max]=n,o[2*i]=o[2*r]+o[2*n],t.depth[i]=(t.depth[r]>=t.depth[n]?t.depth[r]:t.depth[n])+1,o[2*r+1]=o[2*n+1]=i,t.heap[1]=i++,P(t,o,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],function(t,e){var r,n,i,o,a,s,u=e.dyn_tree,c=e.max_code,f=e.stat_desc.static_tree,l=e.stat_desc.has_stree,h=e.stat_desc.extra_bits,p=e.stat_desc.extra_base,d=e.stat_desc.max_length,y=0;for(o=0;o<=15;o++)t.bl_count[o]=0;for(u[2*t.heap[t.heap_max]+1]=0,r=t.heap_max+1;r<573;r++)(o=u[2*u[2*(n=t.heap[r])+1]+1]+1)>d&&(o=d,y++),u[2*n+1]=o,n>c||(t.bl_count[o]++,a=0,n>=p&&(a=h[n-p]),s=u[2*n],t.opt_len+=s*(o+a),l&&(t.static_len+=s*(f[2*n+1]+a)));if(0!==y){do{for(o=d-1;0===t.bl_count[o];)o--;t.bl_count[o]--,t.bl_count[o+1]+=2,t.bl_count[d]--,y-=2}while(y>0);for(o=d;0!==o;o--)for(n=t.bl_count[o];0!==n;)(i=t.heap[--r])>c||(u[2*i+1]!==o&&(t.opt_len+=(o-u[2*i+1])*u[2*i],u[2*i+1]=o),n--)}}(t,e),T(o,c,t.bl_count)}function L(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),e[2*(r+1)+1]=65535,n=0;n<=r;n++)i=a,a=e[2*(n+1)+1],++s<u&&i===a||(s<c?t.bl_tree[2*i]+=s:0!==i?(i!==o&&t.bl_tree[2*i]++,t.bl_tree[32]++):s<=10?t.bl_tree[34]++:t.bl_tree[36]++,s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4))}function B(t,e,r){var n,i,o=-1,a=e[1],s=0,u=7,c=4;for(0===a&&(u=138,c=3),n=0;n<=r;n++)if(i=a,a=e[2*(n+1)+1],!(++s<u&&i===a)){if(s<c)do{S(t,i,t.bl_tree)}while(0!=--s);else 0!==i?(i!==o&&(S(t,i,t.bl_tree),s--),S(t,16,t.bl_tree),E(t,s-3,2)):s<=10?(S(t,17,t.bl_tree),E(t,s-3,3)):(S(t,18,t.bl_tree),E(t,s-11,7));s=0,o=i,0===a?(u=138,c=3):i===a?(u=6,c=3):(u=7,c=4)}}i(g);var U=!1;function N(t,e,r,i){E(t,0+(i?1:0),3),function(t,e,r){x(t),_(t,r),_(t,~r),n.arraySet(t.pending_buf,t.window,e,r,t.pending),t.pending+=r}(t,e,r)}e._tr_init=function(t){U||(function(){var t,e,r,n,i,u=new Array(16);for(r=0,n=0;n<28;n++)for(p[n]=r,t=0;t<1<<o[n];t++)h[r++]=n;for(h[r-1]=n,i=0,n=0;n<16;n++)for(g[n]=i,t=0;t<1<<a[n];t++)l[i++]=n;for(i>>=7;n<30;n++)for(g[n]=i<<7,t=0;t<1<<a[n]-7;t++)l[256+i++]=n;for(e=0;e<=15;e++)u[e]=0;for(t=0;t<=143;)c[2*t+1]=8,t++,u[8]++;for(;t<=255;)c[2*t+1]=9,t++,u[9]++;for(;t<=279;)c[2*t+1]=7,t++,u[7]++;for(;t<=287;)c[2*t+1]=8,t++,u[8]++;for(T(c,287,u),t=0;t<30;t++)f[2*t+1]=5,f[2*t]=k(t,5);d=new w(c,o,257,286,15),y=new w(f,a,0,30,15),b=new w(new Array(0),s,0,19,7)}(),U=!0),t.l_desc=new v(t.dyn_ltree,d),t.d_desc=new v(t.dyn_dtree,y),t.bl_desc=new v(t.bl_tree,b),t.bi_buf=0,t.bi_valid=0,O(t)},e._tr_stored_block=N,e._tr_flush_block=function(t,e,r,n){var i,o,a=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=function(t){var e,r=4093624447;for(e=0;e<=31;e++,r>>>=1)if(1&r&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0}(t)),R(t,t.l_desc),R(t,t.d_desc),a=function(t){var e;for(L(t,t.dyn_ltree,t.l_desc.max_code),L(t,t.dyn_dtree,t.d_desc.max_code),R(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*u[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e}(t),i=t.opt_len+3+7>>>3,(o=t.static_len+3+7>>>3)<=i&&(i=o)):i=o=r+5,r+4<=i&&-1!==e?N(t,e,r,n):4===t.strategy||o===i?(E(t,2+(n?1:0),3),I(t,c,f)):(E(t,4+(n?1:0),3),function(t,e,r,n){var i;for(E(t,e-257,5),E(t,r-1,5),E(t,n-4,4),i=0;i<n;i++)E(t,t.bl_tree[2*u[i]+1],3);B(t,t.dyn_ltree,e-1),B(t,t.dyn_dtree,r-1)}(t,t.l_desc.max_code+1,t.d_desc.max_code+1,a+1),I(t,t.dyn_ltree,t.dyn_dtree)),O(t),n&&x(t)},e._tr_tally=function(t,e,r){return t.pending_buf[t.d_buf+2*t.last_lit]=e>>>8&255,t.pending_buf[t.d_buf+2*t.last_lit+1]=255&e,t.pending_buf[t.l_buf+t.last_lit]=255&r,t.last_lit++,0===e?t.dyn_ltree[2*r]++:(t.matches++,e--,t.dyn_ltree[2*(h[r]+256+1)]++,t.dyn_dtree[2*m(e)]++),t.last_lit===t.lit_bufsize-1},e._tr_align=function(t){E(t,2,3),S(t,256,c),function(t){16===t.bi_valid?(_(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)}(t)}},4442:t=>{t.exports=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0}},6578:t=>{t.exports=["Float32Array","Float64Array","Int8Array","Int16Array","Int32Array","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","BigInt64Array","BigUint64Array"]},5606: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 a(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 s,u=[],c=!1,f=-1;function l(){c&&s&&(c=!1,s.length?u=s.concat(u):f=-1,u.length&&h())}function h(){if(!c){var t=a(l);c=!0;for(var e=u.length;e;){for(s=u,u=[];++f<e;)s&&s[f].run();f=-1,e=u.length}s=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||a(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}},3209:(t,e,r)=>{var n=r(5606),i=65536,o=r(2861).Buffer,a=r.g.crypto||r.g.msCrypto;a&&a.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 s=0;s<t;s+=i)a.getRandomValues(r.slice(s,s+i));else a.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),a=new Array(16),s=[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],f=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],l=[0,1518500249,1859775393,2400959708,2840853838],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,a,s){return d(t+(e^r^n)+o+a|0,s)+i|0}function b(t,e,r,n,i,o,a,s){return d(t+(e&r|~e&n)+o+a|0,s)+i|0}function g(t,e,r,n,i,o,a,s){return d(t+((e|~r)^n)+o+a|0,s)+i|0}function w(t,e,r,n,i,o,a,s){return d(t+(e&n|r&~n)+o+a|0,s)+i|0}function v(t,e,r,n,i,o,a,s){return d(t+(e^(r|~n))+o+a|0,s)+i|0}i(p,o),p.prototype._update=function(){for(var t=a,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,m=0|this._a,_=0|this._b,E=0|this._c,S=0|this._d,k=0|this._e,T=0;T<80;T+=1){var O,x;T<16?(O=y(r,n,i,o,p,t[s[T]],l[0],c[T]),x=v(m,_,E,S,k,t[u[T]],h[0],f[T])):T<32?(O=b(r,n,i,o,p,t[s[T]],l[1],c[T]),x=w(m,_,E,S,k,t[u[T]],h[1],f[T])):T<48?(O=g(r,n,i,o,p,t[s[T]],l[2],c[T]),x=g(m,_,E,S,k,t[u[T]],h[2],f[T])):T<64?(O=w(r,n,i,o,p,t[s[T]],l[3],c[T]),x=b(m,_,E,S,k,t[u[T]],h[3],f[T])):(O=v(r,n,i,o,p,t[s[T]],l[4],c[T]),x=y(m,_,E,S,k,t[u[T]],h[4],f[T])),r=p,p=o,o=d(i,10),i=n,n=O,m=k,k=S,S=d(E,10),E=_,_=x}var A=this._b+i+S|0;this._b=this._c+o+k|0,this._c=this._d+p+m|0,this._d=this._e+r+_|0,this._e=this._a+n+E|0,this._a=A},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 a(t,e,r){return i(t,e,r)}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?t.exports=n:(o(n,e),e.Buffer=a),a.prototype=Object.create(i.prototype),o(i,a),a.from=function(t,e,r){if("number"==typeof t)throw new TypeError("Argument must not be a number");return i(t,e,r)},a.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},a.allocUnsafe=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return i(t)},a.allocUnsafeSlow=function(t){if("number"!=typeof t)throw new TypeError("Argument must be a number");return n.SlowBuffer(t)}},6897:(t,e,r)=>{var n=r(453),i=r(41),o=r(592)(),a=r(5795),s=r(9675),u=n("%Math.floor%");t.exports=function(t,e){if("function"!=typeof t)throw new s("`fn` is not a function");if("number"!=typeof e||e<0||e>4294967295||u(e)!==e)throw new s("`length` must be a positive 32-bit integer");var r=arguments.length>2&&!!arguments[2],n=!0,c=!0;if("length"in t&&a){var f=a(t,"length");f&&!f.configurable&&(n=!1),f&&!f.writable&&(c=!1)}return(n||c||!r)&&(o?i(t,"length",e,!0,!0):i(t,"length",e)),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,a=this._len,s=0;s<o;){for(var u=a%i,c=Math.min(o-s,i-u),f=0;f<c;f++)r[u+f]=t[s+f];s+=c,(a+=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,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(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,s=0|this._d,u=0|this._e,l=0;l<16;++l)r[l]=t.readInt32BE(4*l);for(;l<80;++l)r[l]=r[l-3]^r[l-8]^r[l-14]^r[l-16];for(var h=0;h<80;++h){var p=~~(h/20),d=0|((e=n)<<5|e>>>27)+f(p,i,o,s)+u+r[h]+a[p];u=s,s=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=s+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,a=[1518500249,1859775393,-1894007588,-899497514],s=new Array(80);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t){return t<<5|t>>>27}function f(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,s=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)+l(d,i,o,s)+u+r[p]+a[d]|0;u=s,s=o,o=f(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=s+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),a=r(2861).Buffer,s=new Array(64);function u(){this.init(),this._w=s,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=a.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,a=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],s=new Array(64);function u(){this.init(),this._w=s,i.call(this,64,56)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(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}function d(t){return(t>>>17|t<<15)^(t>>>19|t<<13)^t>>>10}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=this._w,r=0|this._a,n=0|this._b,i=0|this._c,o=0|this._d,s=0|this._e,u=0|this._f,y=0|this._g,b=0|this._h,g=0;g<16;++g)e[g]=t.readInt32BE(4*g);for(;g<64;++g)e[g]=d(e[g-2])+e[g-7]+p(e[g-15])+e[g-16]|0;for(var w=0;w<64;++w){var v=b+h(s)+c(s,u,y)+a[w]+e[w]|0,m=l(r)+f(r,n,i)|0;b=y,y=u,u=s,s=o+v|0,o=i,i=n,n=r,r=v+m|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=o+this._d|0,this._e=s+this._e|0,this._f=u+this._f|0,this._g=y+this._g|0,this._h=b+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),a=r(2861).Buffer,s=new Array(160);function u(){this.init(),this._w=s,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=a.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,a=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],s=new Array(160);function u(){this.init(),this._w=s,i.call(this,128,112)}function c(t,e,r){return r^t&(e^r)}function f(t,e,r){return t&e|r&(t|e)}function l(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 b(t,e){return(t>>>19|e<<13)^(e>>>29|t<<3)^(t>>>6|e<<26)}function g(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,s=0|this._eh,u=0|this._fh,w=0|this._gh,v=0|this._hh,m=0|this._al,_=0|this._bl,E=0|this._cl,S=0|this._dl,k=0|this._el,T=0|this._fl,O=0|this._gl,x=0|this._hl,A=0;A<32;A+=2)e[A]=t.readInt32BE(4*A),e[A+1]=t.readInt32BE(4*A+4);for(;A<160;A+=2){var P=e[A-30],I=e[A-30+1],R=p(P,I),L=d(I,P),B=y(P=e[A-4],I=e[A-4+1]),U=b(I,P),N=e[A-14],j=e[A-14+1],C=e[A-32],F=e[A-32+1],M=L+j|0,D=R+N+g(M,L)|0;D=(D=D+B+g(M=M+U|0,U)|0)+C+g(M=M+F|0,F)|0,e[A]=D,e[A+1]=M}for(var H=0;H<160;H+=2){D=e[H],M=e[H+1];var K=f(r,n,i),W=f(m,_,E),G=l(r,m),V=l(m,r),z=h(s,k),q=h(k,s),X=a[H],$=a[H+1],Y=c(s,u,w),Z=c(k,T,O),J=x+q|0,Q=v+z+g(J,x)|0;Q=(Q=(Q=Q+Y+g(J=J+Z|0,Z)|0)+X+g(J=J+$|0,$)|0)+D+g(J=J+M|0,M)|0;var tt=V+W|0,et=G+K+g(tt,V)|0;v=w,x=O,w=u,O=T,u=s,T=k,s=o+Q+g(k=S+J|0,S)|0,o=i,S=E,i=n,E=_,n=r,_=m,r=Q+et+g(m=J+tt|0,J)|0}this._al=this._al+m|0,this._bl=this._bl+_|0,this._cl=this._cl+E|0,this._dl=this._dl+S|0,this._el=this._el+k|0,this._fl=this._fl+T|0,this._gl=this._gl+O|0,this._hl=this._hl+x|0,this._ah=this._ah+r+g(this._al,m)|0,this._bh=this._bh+n+g(this._bl,_)|0,this._ch=this._ch+i+g(this._cl,E)|0,this._dh=this._dh+o+g(this._dl,S)|0,this._eh=this._eh+s+g(this._el,k)|0,this._fh=this._fh+u+g(this._fl,T)|0,this._gh=this._gh+w+g(this._gl,O)|0,this._hh=this._hh+v+g(this._hl,x)|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",s),r.on("close",u));var a=!1;function s(){a||(a=!0,t.end())}function u(){a||(a=!0,"function"==typeof t.destroy&&t.destroy())}function c(t){if(f(),0===n.listenerCount(this,"error"))throw t}function f(){r.removeListener("data",i),t.removeListener("drain",o),r.removeListener("end",s),r.removeListener("close",u),r.removeListener("error",c),t.removeListener("error",c),r.removeListener("end",f),r.removeListener("close",f),t.removeListener("close",f)}return r.on("error",c),t.on("error",c),r.on("end",f),r.on("close",f),t.on("close",f),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,a,s,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"))a="The ".concat(t," ").concat(i," ").concat(n(e,"type"));else{var c=("number"!=typeof u&&(u=0),u+1>(s=t).length||-1===s.indexOf(".",u)?"argument":"property");a='The "'.concat(t,'" ').concat(c," ").concat(i," ").concat(n(e,"type"))}return a+". 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(5606),i=Object.keys||function(t){var e=[];for(var r in t)e.push(r);return e};t.exports=f;var o=r(6891),a=r(1999);r(6698)(f,o);for(var s=i(a.prototype),u=0;u<s.length;u++){var c=s[u];f.prototype[c]||(f.prototype[c]=a.prototype[c])}function f(t){if(!(this instanceof f))return new f(t);o.call(this,t),a.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",l)))}function l(){this._writableState.ended||n.nextTick(h,this)}function h(t){t.end()}Object.defineProperty(f.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(f.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(f.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(f.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(5606);t.exports=T,T.ReadableState=k,r(7007).EventEmitter;var o,a=function(t,e){return t.listeners(e).length},s=r(1396),u=r(8287).Buffer,c=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},f=r(7199);o=f&&f.debuglog?f.debuglog("stream"):function(){};var l,h,p,d=r(1766),y=r(4347),b=r(6644).getHighWaterMark,g=r(2463).F,w=g.ERR_INVALID_ARG_TYPE,v=g.ERR_STREAM_PUSH_AFTER_EOF,m=g.ERR_METHOD_NOT_IMPLEMENTED,_=g.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;r(6698)(T,s);var E=y.errorOrDestroy,S=["error","close","destroy","pause","resume"];function k(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=b(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&&(l||(l=r(3516).I),this.decoder=new l(t.encoding),this.encoding=t.encoding)}function T(t){if(n=n||r(8101),!(this instanceof T))return new T(t);var e=this instanceof n;this._readableState=new k(t,this,e),this.readable=!0,t&&("function"==typeof t.read&&(this._read=t.read),"function"==typeof t.destroy&&(this._destroy=t.destroy)),s.call(this)}function O(t,e,r,n,i){o("readableAddChunk",e);var a,s=t._readableState;if(null===e)s.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?I(t):(e.needReadable=!1,e.emittedReadable||(e.emittedReadable=!0,R(t)))}}(t,s);else if(i||(a=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}(s,e)),a)E(t,a);else if(s.objectMode||e&&e.length>0)if("string"==typeof e||s.objectMode||Object.getPrototypeOf(e)===u.prototype||(e=function(t){return u.from(t)}(e)),n)s.endEmitted?E(t,new _):x(t,s,e,!0);else if(s.ended)E(t,new v);else{if(s.destroyed)return!1;s.reading=!1,s.decoder&&!r?(e=s.decoder.write(e),s.objectMode||0!==e.length?x(t,s,e,!1):L(t,s)):x(t,s,e,!1)}else n||(s.reading=!1,L(t,s));return!s.ended&&(s.length<s.highWaterMark||0===s.length)}function x(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&&I(t)),L(t,e)}Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._readableState&&this._readableState.destroyed},set:function(t){this._readableState&&(this._readableState.destroyed=t)}}),T.prototype.destroy=y.destroy,T.prototype._undestroy=y.undestroy,T.prototype._destroy=function(t,e){e(t)},T.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),O(this,t,e,!1,r)},T.prototype.unshift=function(t){return O(this,t,null,!0,!1)},T.prototype.isPaused=function(){return!1===this._readableState.flowing},T.prototype.setEncoding=function(t){l||(l=r(3516).I);var e=new l(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 A=1073741824;function P(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>=A?t=A:(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 I(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(R,t))}function R(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,C(t)}function L(t,e){e.readingMore||(e.readingMore=!0,i.nextTick(B,t,e))}function B(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 N(t){o("readable nexttick read 0"),t.read(0)}function j(t,e){o("resume",e.reading),e.reading||t.read(0),e.resumeScheduled=!1,t.emit("resume"),C(t),e.flowing&&!e.reading&&t.read(0)}function C(t){var e=t._readableState;for(o("flow",e.flowing);e.flowing&&null!==t.read(););}function F(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 M(t){var e=t._readableState;o("endReadable",e.endEmitted),e.endEmitted||(e.ended=!0,i.nextTick(D,e,t))}function D(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 H(t,e){for(var r=0,n=t.length;r<n;r++)if(t[r]===e)return r;return-1}T.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?M(this):I(this),null;if(0===(t=P(t,e))&&e.ended)return 0===e.length&&M(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=P(r,e))),null===(n=t>0?F(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&&M(this)),null!==n&&this.emit("data",n),n},T.prototype._read=function(t){E(this,new m("_read()"))},T.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 s=e&&!1===e.end||t===i.stdout||t===i.stderr?y:u;function u(){o("onend"),t.end()}n.endEmitted?i.nextTick(s):r.once("end",s),t.on("unpipe",(function e(i,a){o("onunpipe"),i===r&&a&&!1===a.hasUnpiped&&(a.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",l),f=!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&&a(t,"data")&&(e.flowing=!0,C(t))}}(r);t.on("drain",c);var f=!1;function l(e){o("ondata");var i=t.write(e);o("dest.write",i),!1===i&&((1===n.pipesCount&&n.pipes===t||n.pipesCount>1&&-1!==H(n.pipes,t))&&!f&&(o("false write response, pause",n.awaitDrain),n.awaitDrain++),r.pause())}function h(e){o("onerror",e),y(),t.removeListener("error",h),0===a(t,"error")&&E(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",l),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},T.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 a=H(e.pipes,t);return-1===a||(e.pipes.splice(a,1),e.pipesCount-=1,1===e.pipesCount&&(e.pipes=e.pipes[0]),t.emit("unpipe",this,r)),this},T.prototype.on=function(t,e){var r=s.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?I(this):n.reading||i.nextTick(N,this))),r},T.prototype.addListener=T.prototype.on,T.prototype.removeListener=function(t,e){var r=s.prototype.removeListener.call(this,t,e);return"readable"===t&&i.nextTick(U,this),r},T.prototype.removeAllListeners=function(t){var e=s.prototype.removeAllListeners.apply(this,arguments);return"readable"!==t&&void 0!==t||i.nextTick(U,this),e},T.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(j,t,e))}(this,t)),t.paused=!1,this},T.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},T.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 a=0;a<S.length;a++)t.on(S[a],this.emit.bind(this,S[a]));return this._read=function(e){o("wrapped _read",e),n&&(n=!1,t.resume())},this},"function"==typeof Symbol&&(T.prototype[Symbol.asyncIterator]=function(){return void 0===h&&(h=r(5034)),h(this)}),Object.defineProperty(T.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(T.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(T.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(t){this._readableState&&(this._readableState.flowing=t)}}),T._fromList=F,Object.defineProperty(T.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),"function"==typeof Symbol&&(T.from=function(t,e){return void 0===p&&(p=r(968)),p(T,t,e)})},9083:(t,e,r)=>{t.exports=f;var n=r(2463).F,i=n.ERR_METHOD_NOT_IMPLEMENTED,o=n.ERR_MULTIPLE_CALLBACK,a=n.ERR_TRANSFORM_ALREADY_TRANSFORMING,s=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 f(t){if(!(this instanceof f))return new f(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",l)}function l(){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 s;if(t._transformState.transforming)throw new a;return t.push(null)}r(6698)(f,u),f.prototype.push=function(t,e){return this._transformState.needTransform=!1,u.prototype.push.call(this,t,e)},f.prototype._transform=function(t,e,r){r(new i("_transform()"))},f.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)}},f.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))},f.prototype._destroy=function(t,e){u.prototype._destroy.call(this,t,(function(t){e(t)}))}},1999:(t,e,r)=>{var n,i=r(5606);function o(t){var e=this;this.next=null,this.entry=null,this.finish=function(){!function(t,e){var r=t.entry;for(t.entry=null;r;){var n=r.callback;e.pendingcb--,n(undefined),r=r.next}e.corkedRequestsFree.next=t}(e,t)}}t.exports=T,T.WritableState=k;var a,s={deprecate:r(4643)},u=r(1396),c=r(8287).Buffer,f=(void 0!==r.g?r.g:"undefined"!=typeof window?window:"undefined"!=typeof self?self:{}).Uint8Array||function(){},l=r(4347),h=r(6644).getHighWaterMark,p=r(2463).F,d=p.ERR_INVALID_ARG_TYPE,y=p.ERR_METHOD_NOT_IMPLEMENTED,b=p.ERR_MULTIPLE_CALLBACK,g=p.ERR_STREAM_CANNOT_PIPE,w=p.ERR_STREAM_DESTROYED,v=p.ERR_STREAM_NULL_VALUES,m=p.ERR_STREAM_WRITE_AFTER_END,_=p.ERR_UNKNOWN_ENCODING,E=l.errorOrDestroy;function S(){}function k(t,e,a){n=n||r(8101),t=t||{},"boolean"!=typeof a&&(a=e instanceof n),this.objectMode=!!t.objectMode,a&&(this.objectMode=this.objectMode||!!t.writableObjectMode),this.highWaterMark=h(this,t,"writableHighWaterMark",a),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var s=!1===t.decodeStrings;this.decodeStrings=!s,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 b;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(R,t,e),t._writableState.errorEmitted=!0,E(t,n)):(o(n),t._writableState.errorEmitted=!0,E(t,n),R(t,e))}(t,r,n,e,o);else{var a=P(r)||t.destroyed;a||r.corked||r.bufferProcessing||!r.bufferedRequest||A(t,r),n?i.nextTick(x,t,r,a,o):x(t,r,a,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 T(t){var e=this instanceof(n=n||r(8101));if(!e&&!a.call(T,this))return new T(t);this._writableState=new k(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 O(t,e,r,n,i,o,a){e.writelen=n,e.writecb=a,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 x(t,e,r,n){r||function(t,e){0===e.length&&e.needDrain&&(e.needDrain=!1,t.emit("drain"))}(t,e),e.pendingcb--,n(),R(t,e)}function A(t,e){e.bufferProcessing=!0;var r=e.bufferedRequest;if(t._writev&&r&&r.next){var n=e.bufferedRequestCount,i=new Array(n),a=e.corkedRequestsFree;a.entry=r;for(var s=0,u=!0;r;)i[s]=r,r.isBuf||(u=!1),r=r.next,s+=1;i.allBuffers=u,O(t,e,!0,e.length,i,"",a.finish),e.pendingcb++,e.lastBufferedRequest=null,a.next?(e.corkedRequestsFree=a.next,a.next=null):e.corkedRequestsFree=new o(e),e.bufferedRequestCount=0}else{for(;r;){var c=r.chunk,f=r.encoding,l=r.callback;if(O(t,e,!1,e.objectMode?1:c.length,c,f,l),r=r.next,e.bufferedRequestCount--,e.writing)break}null===r&&(e.lastBufferedRequest=null)}e.bufferedRequest=r,e.bufferProcessing=!1}function P(t){return t.ending&&0===t.length&&null===t.bufferedRequest&&!t.finished&&!t.writing}function I(t,e){t._final((function(r){e.pendingcb--,r&&E(t,r),e.prefinished=!0,t.emit("prefinish"),R(t,e)}))}function R(t,e){var r=P(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(I,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)(T,u),k.prototype.getBuffer=function(){for(var t=this.bufferedRequest,e=[];t;)e.push(t),t=t.next;return e},function(){try{Object.defineProperty(k.prototype,"buffer",{get:s.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]?(a=Function.prototype[Symbol.hasInstance],Object.defineProperty(T,Symbol.hasInstance,{value:function(t){return!!a.call(this,t)||this===T&&t&&t._writableState instanceof k}})):a=function(t){return t instanceof this},T.prototype.pipe=function(){E(this,new g)},T.prototype.write=function(t,e,r){var n,o=this._writableState,a=!1,s=!o.objectMode&&(n=t,c.isBuffer(n)||n instanceof f);return s&&!c.isBuffer(t)&&(t=function(t){return c.from(t)}(t)),"function"==typeof e&&(r=e,e=null),s?e="buffer":e||(e=o.defaultEncoding),"function"!=typeof r&&(r=S),o.ending?function(t,e){var r=new m;E(t,r),i.nextTick(e,r)}(this,r):(s||function(t,e,r,n){var o;return null===r?o=new v:"string"==typeof r||e.objectMode||(o=new d("chunk",["string","Buffer"],r)),!o||(E(t,o),i.nextTick(n,o),!1)}(this,o,t,r))&&(o.pendingcb++,a=function(t,e,r,n,i,o){if(!r){var a=function(t,e,r){return t.objectMode||!1===t.decodeStrings||"string"!=typeof e||(e=c.from(e,r)),e}(e,n,i);n!==a&&(r=!0,i="buffer",n=a)}var s=e.objectMode?1:n.length;e.length+=s;var u=e.length<e.highWaterMark;if(u||(e.needDrain=!0),e.writing||e.corked){var f=e.lastBufferedRequest;e.lastBufferedRequest={chunk:n,encoding:i,isBuf:r,callback:o,next:null},f?f.next=e.lastBufferedRequest:e.bufferedRequest=e.lastBufferedRequest,e.bufferedRequestCount+=1}else O(t,e,!1,s,n,i,o);return u}(this,o,s,t,e,r)),a},T.prototype.cork=function(){this._writableState.corked++},T.prototype.uncork=function(){var t=this._writableState;t.corked&&(t.corked--,t.writing||t.corked||t.bufferProcessing||!t.bufferedRequest||A(this,t))},T.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 _(t);return this._writableState.defaultEncoding=t,this},Object.defineProperty(T.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(T.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),T.prototype._write=function(t,e,r){r(new y("_write()"))},T.prototype._writev=null,T.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,R(t,e),r&&(e.finished?i.nextTick(r):t.once("finish",r)),e.ended=!0,t.writable=!1}(this,n,r),this},Object.defineProperty(T.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(T.prototype,"destroyed",{enumerable:!1,get:function(){return void 0!==this._writableState&&this._writableState.destroyed},set:function(t){this._writableState&&(this._writableState.destroyed=t)}}),T.prototype.destroy=l.destroy,T.prototype._undestroy=l.undestroy,T.prototype._destroy=function(t,e){e(t)}},5034:(t,e,r)=>{var n,i=r(5606);function o(t,e,r){return(e=function(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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 a=r(4257),s=Symbol("lastResolve"),u=Symbol("lastReject"),c=Symbol("error"),f=Symbol("ended"),l=Symbol("lastPromise"),h=Symbol("handlePromise"),p=Symbol("stream");function d(t,e){return{value:t,done:e}}function y(t){var e=t[s];if(null!==e){var r=t[p].read();null!==r&&(t[l]=null,t[s]=null,t[u]=null,e(d(r,!1)))}}function b(t){i.nextTick(y,t)}var g=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[f])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[l];if(n)r=new Promise(function(t,e){return function(r,n){t.then((function(){e[f]?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[l]=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),g);t.exports=function(t){var e,r=Object.create(w,(o(e={},p,{value:t,writable:!0}),o(e,s,{value:null,writable:!0}),o(e,u,{value:null,writable:!0}),o(e,c,{value:null,writable:!0}),o(e,f,{value:t._readableState.endEmitted,writable:!0}),o(e,h,{value:function(t,e){var n=r[p].read();n?(r[l]=null,r[s]=null,r[u]=null,t(d(n,!1))):(r[s]=t,r[u]=e)},writable:!0}),e));return r[l]=null,a(t,(function(t){if(t&&"ERR_STREAM_PREMATURE_CLOSE"!==t.code){var e=r[u];return null!==e&&(r[l]=null,r[s]=null,r[u]=null,e(t)),void(r[c]=t)}var n=r[s];null!==n&&(r[l]=null,r[s]=null,r[u]=null,n(d(void 0,!0))),r[f]=!0})),t.on("readable",b.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=s(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,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,s(n.key),n)}}function s(t){var e=function(t){if("object"!=typeof t||null===t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=typeof r)return r;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,f=c&&c.custom||"inspect";function l(t,e,r){u.prototype.copy.call(t,e,r)}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=u.allocUnsafe(t>>>0),r=this.head,n=0;r;)l(r.data,e,n),n+=r.data.length,r=r.next;return e}},{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:f,value:function(t,e){return c(this,i(i({},e),{},{depth:0,customInspect:!1}))}}],r&&a(e.prototype,r),Object.defineProperty(e,"prototype",{writable:!1}),t}()},4347:(t,e,r)=>{var n=r(5606);function i(t,e){a(t,e),o(t)}function o(t){t._writableState&&!t._writableState.emitClose||t._readableState&&!t._readableState.emitClose||t.emit("close")}function a(t,e){t.emit("error",e)}t.exports={destroy:function(t,e){var r=this,s=this._readableState&&this._readableState.destroyed,u=this._writableState&&this._writableState.destroyed;return s||u?(e?e(t):t&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,n.nextTick(a,this,t)):n.nextTick(a,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 a=r.readable||!1!==r.readable&&e.readable,s=r.writable||!1!==r.writable&&e.writable,u=function(){e.writable||f()},c=e._writableState&&e._writableState.finished,f=function(){s=!1,c=!0,a||o.call(e)},l=e._readableState&&e._readableState.endEmitted,h=function(){a=!1,l=!0,s||o.call(e)},p=function(t){o.call(e,t)},d=function(){var t;return a&&!l?(e._readableState&&e._readableState.ended||(t=new n),o.call(e,t)):s&&!c?(e._writableState&&e._writableState.ended||(t=new n),o.call(e,t)):void 0},y=function(){e.req.on("finish",f)};return function(t){return t.setHeader&&"function"==typeof t.abort}(e)?(e.on("complete",f),e.on("abort",d),e.req?y():e.on("request",y)):s&&!e._writableState&&(e.on("end",u),e.on("close",u)),e.on("end",h),e.on("finish",f),!1!==r.error&&e.on("error",p),e.on("close",d),function(){e.removeListener("complete",f),e.removeListener("abort",d),e.removeListener("request",y),e.req&&e.req.removeListener("finish",f),e.removeListener("end",u),e.removeListener("close",u),e.removeListener("finish",f),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,a=i.ERR_STREAM_DESTROYED;function s(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 f,l=function(t){return t.length?"function"!=typeof t[t.length-1]?s:t.pop():s}(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 s=!1;t.on("close",(function(){s=!0})),void 0===n&&(n=r(4257)),n(t,{readable:e,writable:i},(function(t){if(t)return o(t);s=!0,o()}));var u=!1;return function(e){if(!s&&!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 a("pipe"))}}(t,o,i>0,(function(t){f||(f=t),t&&h.forEach(u),o||(h.forEach(u),l(f))}))}));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},3516:(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=s,e=4;break;case"base64":this.text=f,this.end=l,e=3;break;default:return this.write=h,void(this.end=p)}this.lastNeed=0,this.lastTotal=0,this.lastChar=n.allocUnsafe(e)}function a(t){return t<=127?0:t>>5==6?2:t>>4==14?3:t>>3==30?4:t>>6==2?-1:-2}function s(t){var e=this.lastTotal-this.lastNeed,r=function(t,e){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 f(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 l(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=a(e[n]);return i>=0?(i>0&&(t.lastNeed=i-1),i):--n<r||-2===i?0:(i=a(e[n]))>=0?(i>0&&(t.lastNeed=i-2),i):--n<r||-2===i?0:(i=a(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}},9579:(t,e,r)=>{var n=r(8287).Buffer,i=n.isEncoding||function(t){switch(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}},o=e.I=function(t){switch(this.encoding=(t||"utf8").toLowerCase().replace(/[-_]/,""),function(t){if(t&&!i(t))throw new Error("Unknown encoding: "+t)}(t),this.encoding){case"utf8":this.surrogateSize=3;break;case"ucs2":case"utf16le":this.surrogateSize=2,this.detectIncompleteChar=s;break;case"base64":this.surrogateSize=3,this.detectIncompleteChar=u;break;default:return void(this.write=a)}this.charBuffer=new n(6),this.charReceived=0,this.charLength=0};function a(t){return t.toString(this.encoding)}function s(t){this.charReceived=t.length%2,this.charLength=this.charReceived?2:0}function u(t){this.charReceived=t.length%3,this.charLength=this.charReceived?3:0}o.prototype.write=function(t){for(var e="";this.charLength;){var r=t.length>=this.charLength-this.charReceived?this.charLength-this.charReceived:t.length;if(t.copy(this.charBuffer,this.charReceived,0,r),this.charReceived+=r,this.charReceived<this.charLength)return"";if(t=t.slice(r,t.length),!((n=(e=this.charBuffer.slice(0,this.charLength).toString(this.encoding)).charCodeAt(e.length-1))>=55296&&n<=56319)){if(this.charReceived=this.charLength=0,0===t.length)return e;break}this.charLength+=this.surrogateSize,e=""}this.detectIncompleteChar(t);var n,i=t.length;if(this.charLength&&(t.copy(this.charBuffer,0,t.length-this.charReceived,i),i-=this.charReceived),i=(e+=t.toString(this.encoding,0,i)).length-1,(n=e.charCodeAt(i))>=55296&&n<=56319){var o=this.surrogateSize;return this.charLength+=o,this.charReceived+=o,this.charBuffer.copy(this.charBuffer,o,0,o),t.copy(this.charBuffer,0,0,o),e.substring(0,i)}return e},o.prototype.detectIncompleteChar=function(t){for(var e=t.length>=3?3:t.length;e>0;e--){var r=t[t.length-e];if(1==e&&r>>5==6){this.charLength=2;break}if(e<=2&&r>>4==14){this.charLength=3;break}if(e<=3&&r>>3==30){this.charLength=4;break}}this.charReceived=e},o.prototype.end=function(t){var e="";if(t&&t.length&&(e=this.write(t)),this.charReceived){var r=this.charReceived,n=this.charBuffer,i=this.encoding;e+=n.slice(0,r).toString(i)}return e}},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 a(t,e){Error.captureStackTrace&&Error.captureStackTrace(t,e)}function s(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 "+s(t)+", got"+(""!==r?" "+r:"")+(""!==i?" "+i:"")}function c(t,e,r){r=r||o(e),this.message=u(t,e,r),a(this,c),this.__type=t,this.__value=e,this.__valueTypeName=r}function f(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 "'+s(r)+o+s(t),n,i)}(t,r,e,n,i)):this.message='Unexpected property "'+e+'"',a(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,f.prototype=Object.create(Error.prototype),f.prototype.constructor=c,t.exports={TfTypeError:c,TfPropertyTypeError:f,tfCustomError:function(t,e){return new c(t,{},e)},tfSubError:function(t,e,r){return t instanceof f?(e=e+"."+t.__property,t=new f(t.__type,e,t.__label,t.__value,t.__valueTypeName)):t instanceof c&&(t=new f(t.__type,e,r,t.__value,t.__valueTypeName)),a(t),t},tfJSON:s,getValueTypeName:o}},9542:(t,e,r)=>{var n=r(8287).Buffer,i=r(2113),o=r(1061);function a(t){return n.isBuffer(t)}function s(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),f=u.bind(null,a),l=u.bind(null,s),h=u.bind(null,i.String),p=Math.pow(2,53)-1,d={ArrayN:c,Buffer:a,BufferN:f,Finite:function(t){return"number"==typeof t&&isFinite(t)},Hex:s,HexN:l,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,a=n.TfTypeError,s=n.TfPropertyTypeError,u=n.tfSubError,c=n.getValueTypeName,f={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=l(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=l(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 a=r[o];h(t,a,n)}catch(t){throw u(t,o)}}return!0}return t=l(t),e&&(e=l(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]=l(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 s(void 0,n);return!0}return n.toJSON=function(){return o(e)},n},anyOf:function(){var t=[].slice.call(arguments).map(l);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(l);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(l);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 l(t){if(i.String(t))return"?"===t[0]?f.maybe(t.slice(1)):i[t]||f.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 f.arrayOf(t[0])}return f.object(t)}return i.Function(t)?t:f.value(t)}function h(t,e,r,n){if(i.Function(t)){if(t(e,r))return!0;throw new a(n||t,e)}return h(l(t),e,r)}for(var p in f.oneOf=f.anyOf,i)h[p]=i[p];for(p in f)h[p]=f[p];var d=r(9542);for(p in d)h[p]=d[p];h.compile=l,h.TfTypeError=a,h.TfPropertyTypeError=s,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)}}},1135:t=>{t.exports=function(t){return t&&"object"==typeof t&&"function"==typeof t.copy&&"function"==typeof t.fill&&"function"==typeof t.readUInt8}},9032:(t,e,r)=>{var n=r(7244),i=r(8184),o=r(5767),a=r(5680);function s(t){return t.call.bind(t)}var u="undefined"!=typeof BigInt,c="undefined"!=typeof Symbol,f=s(Object.prototype.toString),l=s(Number.prototype.valueOf),h=s(String.prototype.valueOf),p=s(Boolean.prototype.valueOf);if(u)var d=s(BigInt.prototype.valueOf);if(c)var y=s(Symbol.prototype.valueOf);function b(t,e){if("object"!=typeof t)return!1;try{return e(t),!0}catch(t){return!1}}function g(t){return"[object Map]"===f(t)}function w(t){return"[object Set]"===f(t)}function v(t){return"[object WeakMap]"===f(t)}function m(t){return"[object WeakSet]"===f(t)}function _(t){return"[object ArrayBuffer]"===f(t)}function E(t){return"undefined"!=typeof ArrayBuffer&&(_.working?_(t):t instanceof ArrayBuffer)}function S(t){return"[object DataView]"===f(t)}function k(t){return"undefined"!=typeof DataView&&(S.working?S(t):t instanceof DataView)}e.isArgumentsObject=n,e.isGeneratorFunction=i,e.isTypedArray=a,e.isPromise=function(t){return"undefined"!=typeof Promise&&t instanceof Promise||null!==t&&"object"==typeof t&&"function"==typeof t.then&&"function"==typeof t.catch},e.isArrayBufferView=function(t){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(t):a(t)||k(t)},e.isUint8Array=function(t){return"Uint8Array"===o(t)},e.isUint8ClampedArray=function(t){return"Uint8ClampedArray"===o(t)},e.isUint16Array=function(t){return"Uint16Array"===o(t)},e.isUint32Array=function(t){return"Uint32Array"===o(t)},e.isInt8Array=function(t){return"Int8Array"===o(t)},e.isInt16Array=function(t){return"Int16Array"===o(t)},e.isInt32Array=function(t){return"Int32Array"===o(t)},e.isFloat32Array=function(t){return"Float32Array"===o(t)},e.isFloat64Array=function(t){return"Float64Array"===o(t)},e.isBigInt64Array=function(t){return"BigInt64Array"===o(t)},e.isBigUint64Array=function(t){return"BigUint64Array"===o(t)},g.working="undefined"!=typeof Map&&g(new Map),e.isMap=function(t){return"undefined"!=typeof Map&&(g.working?g(t):t instanceof Map)},w.working="undefined"!=typeof Set&&w(new Set),e.isSet=function(t){return"undefined"!=typeof Set&&(w.working?w(t):t instanceof Set)},v.working="undefined"!=typeof WeakMap&&v(new WeakMap),e.isWeakMap=function(t){return"undefined"!=typeof WeakMap&&(v.working?v(t):t instanceof WeakMap)},m.working="undefined"!=typeof WeakSet&&m(new WeakSet),e.isWeakSet=function(t){return m(t)},_.working="undefined"!=typeof ArrayBuffer&&_(new ArrayBuffer),e.isArrayBuffer=E,S.working="undefined"!=typeof ArrayBuffer&&"undefined"!=typeof DataView&&S(new DataView(new ArrayBuffer(1),0,1)),e.isDataView=k;var T="undefined"!=typeof SharedArrayBuffer?SharedArrayBuffer:void 0;function O(t){return"[object SharedArrayBuffer]"===f(t)}function x(t){return void 0!==T&&(void 0===O.working&&(O.working=O(new T)),O.working?O(t):t instanceof T)}function A(t){return b(t,l)}function P(t){return b(t,h)}function I(t){return b(t,p)}function R(t){return u&&b(t,d)}function L(t){return c&&b(t,y)}e.isSharedArrayBuffer=x,e.isAsyncFunction=function(t){return"[object AsyncFunction]"===f(t)},e.isMapIterator=function(t){return"[object Map Iterator]"===f(t)},e.isSetIterator=function(t){return"[object Set Iterator]"===f(t)},e.isGeneratorObject=function(t){return"[object Generator]"===f(t)},e.isWebAssemblyCompiledModule=function(t){return"[object WebAssembly.Module]"===f(t)},e.isNumberObject=A,e.isStringObject=P,e.isBooleanObject=I,e.isBigIntObject=R,e.isSymbolObject=L,e.isBoxedPrimitive=function(t){return A(t)||P(t)||I(t)||R(t)||L(t)},e.isAnyArrayBuffer=function(t){return"undefined"!=typeof Uint8Array&&(E(t)||x(t))},["isProxy","isExternal","isModuleNamespaceObject"].forEach((function(t){Object.defineProperty(e,t,{enumerable:!1,value:function(){throw new Error(t+" is not supported in userland")}})}))},537:(t,e,r)=>{var n=r(5606),i=Object.getOwnPropertyDescriptors||function(t){for(var e=Object.keys(t),r={},n=0;n<e.length;n++)r[e[n]]=Object.getOwnPropertyDescriptor(t,e[n]);return r},o=/%[sdj%]/g;e.format=function(t){if(!v(t)){for(var e=[],r=0;r<arguments.length;r++)e.push(c(arguments[r]));return e.join(" ")}r=1;for(var n=arguments,i=n.length,a=String(t).replace(o,(function(t){if("%%"===t)return"%";if(r>=i)return t;switch(t){case"%s":return String(n[r++]);case"%d":return Number(n[r++]);case"%j":try{return JSON.stringify(n[r++])}catch(t){return"[Circular]"}default:return t}})),s=n[r];r<i;s=n[++r])g(s)||!E(s)?a+=" "+s:a+=" "+c(s);return a},e.deprecate=function(t,r){if(void 0!==n&&!0===n.noDeprecation)return t;if(void 0===n)return function(){return e.deprecate(t,r).apply(this,arguments)};var i=!1;return function(){if(!i){if(n.throwDeprecation)throw new Error(r);n.traceDeprecation?console.trace(r):console.error(r),i=!0}return t.apply(this,arguments)}};var a={},s=/^$/;if(n.env.NODE_DEBUG){var u=n.env.NODE_DEBUG;u=u.replace(/[|\\{}()[\]^$+?.]/g,"\\$&").replace(/\*/g,".*").replace(/,/g,"$|^").toUpperCase(),s=new RegExp("^"+u+"$","i")}function c(t,r){var n={seen:[],stylize:l};return arguments.length>=3&&(n.depth=arguments[2]),arguments.length>=4&&(n.colors=arguments[3]),b(r)?n.showHidden=r:r&&e._extend(n,r),m(n.showHidden)&&(n.showHidden=!1),m(n.depth)&&(n.depth=2),m(n.colors)&&(n.colors=!1),m(n.customInspect)&&(n.customInspect=!0),n.colors&&(n.stylize=f),h(n,t,n.depth)}function f(t,e){var r=c.styles[e];return r?"["+c.colors[r][0]+"m"+t+"["+c.colors[r][1]+"m":t}function l(t,e){return t}function h(t,r,n){if(t.customInspect&&r&&T(r.inspect)&&r.inspect!==e.inspect&&(!r.constructor||r.constructor.prototype!==r)){var i=r.inspect(n,t);return v(i)||(i=h(t,i,n)),i}var o=function(t,e){if(m(e))return t.stylize("undefined","undefined");if(v(e)){var r="'"+JSON.stringify(e).replace(/^"|"$/g,"").replace(/'/g,"\\'").replace(/\\"/g,'"')+"'";return t.stylize(r,"string")}return w(e)?t.stylize(""+e,"number"):b(e)?t.stylize(""+e,"boolean"):g(e)?t.stylize("null","null"):void 0}(t,r);if(o)return o;var a=Object.keys(r),s=function(t){var e={};return t.forEach((function(t,r){e[t]=!0})),e}(a);if(t.showHidden&&(a=Object.getOwnPropertyNames(r)),k(r)&&(a.indexOf("message")>=0||a.indexOf("description")>=0))return p(r);if(0===a.length){if(T(r)){var u=r.name?": "+r.name:"";return t.stylize("[Function"+u+"]","special")}if(_(r))return t.stylize(RegExp.prototype.toString.call(r),"regexp");if(S(r))return t.stylize(Date.prototype.toString.call(r),"date");if(k(r))return p(r)}var c,f="",l=!1,E=["{","}"];return y(r)&&(l=!0,E=["[","]"]),T(r)&&(f=" [Function"+(r.name?": "+r.name:"")+"]"),_(r)&&(f=" "+RegExp.prototype.toString.call(r)),S(r)&&(f=" "+Date.prototype.toUTCString.call(r)),k(r)&&(f=" "+p(r)),0!==a.length||l&&0!=r.length?n<0?_(r)?t.stylize(RegExp.prototype.toString.call(r),"regexp"):t.stylize("[Object]","special"):(t.seen.push(r),c=l?function(t,e,r,n,i){for(var o=[],a=0,s=e.length;a<s;++a)P(e,String(a))?o.push(d(t,e,r,n,String(a),!0)):o.push("");return i.forEach((function(i){i.match(/^\d+$/)||o.push(d(t,e,r,n,i,!0))})),o}(t,r,n,s,a):a.map((function(e){return d(t,r,n,s,e,l)})),t.seen.pop(),function(t,e,r){return t.reduce((function(t,e){return e.indexOf("\n"),t+e.replace(/\u001b\[\d\d?m/g,"").length+1}),0)>60?r[0]+(""===e?"":e+"\n ")+" "+t.join(",\n ")+" "+r[1]:r[0]+e+" "+t.join(", ")+" "+r[1]}(c,f,E)):E[0]+f+E[1]}function p(t){return"["+Error.prototype.toString.call(t)+"]"}function d(t,e,r,n,i,o){var a,s,u;if((u=Object.getOwnPropertyDescriptor(e,i)||{value:e[i]}).get?s=u.set?t.stylize("[Getter/Setter]","special"):t.stylize("[Getter]","special"):u.set&&(s=t.stylize("[Setter]","special")),P(n,i)||(a="["+i+"]"),s||(t.seen.indexOf(u.value)<0?(s=g(r)?h(t,u.value,null):h(t,u.value,r-1)).indexOf("\n")>-1&&(s=o?s.split("\n").map((function(t){return" "+t})).join("\n").slice(2):"\n"+s.split("\n").map((function(t){return" "+t})).join("\n")):s=t.stylize("[Circular]","special")),m(a)){if(o&&i.match(/^\d+$/))return s;(a=JSON.stringify(""+i)).match(/^"([a-zA-Z_][a-zA-Z_0-9]*)"$/)?(a=a.slice(1,-1),a=t.stylize(a,"name")):(a=a.replace(/'/g,"\\'").replace(/\\"/g,'"').replace(/(^"|"$)/g,"'"),a=t.stylize(a,"string"))}return a+": "+s}function y(t){return Array.isArray(t)}function b(t){return"boolean"==typeof t}function g(t){return null===t}function w(t){return"number"==typeof t}function v(t){return"string"==typeof t}function m(t){return void 0===t}function _(t){return E(t)&&"[object RegExp]"===O(t)}function E(t){return"object"==typeof t&&null!==t}function S(t){return E(t)&&"[object Date]"===O(t)}function k(t){return E(t)&&("[object Error]"===O(t)||t instanceof Error)}function T(t){return"function"==typeof t}function O(t){return Object.prototype.toString.call(t)}function x(t){return t<10?"0"+t.toString(10):t.toString(10)}e.debuglog=function(t){if(t=t.toUpperCase(),!a[t])if(s.test(t)){var r=n.pid;a[t]=function(){var n=e.format.apply(e,arguments);console.error("%s %d: %s",t,r,n)}}else a[t]=function(){};return a[t]},e.inspect=c,c.colors={bold:[1,22],italic:[3,23],underline:[4,24],inverse:[7,27],white:[37,39],grey:[90,39],black:[30,39],blue:[34,39],cyan:[36,39],green:[32,39],magenta:[35,39],red:[31,39],yellow:[33,39]},c.styles={special:"cyan",number:"yellow",boolean:"yellow",undefined:"grey",null:"bold",string:"green",date:"magenta",regexp:"red"},e.types=r(9032),e.isArray=y,e.isBoolean=b,e.isNull=g,e.isNullOrUndefined=function(t){return null==t},e.isNumber=w,e.isString=v,e.isSymbol=function(t){return"symbol"==typeof t},e.isUndefined=m,e.isRegExp=_,e.types.isRegExp=_,e.isObject=E,e.isDate=S,e.types.isDate=S,e.isError=k,e.types.isNativeError=k,e.isFunction=T,e.isPrimitive=function(t){return null===t||"boolean"==typeof t||"number"==typeof t||"string"==typeof t||"symbol"==typeof t||void 0===t},e.isBuffer=r(1135);var A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"];function P(t,e){return Object.prototype.hasOwnProperty.call(t,e)}e.log=function(){console.log("%s - %s",function(){var t=new Date,e=[x(t.getHours()),x(t.getMinutes()),x(t.getSeconds())].join(":");return[t.getDate(),A[t.getMonth()],e].join(" ")}(),e.format.apply(e,arguments))},e.inherits=r(6698),e._extend=function(t,e){if(!e||!E(e))return t;for(var r=Object.keys(e),n=r.length;n--;)t[r[n]]=e[r[n]];return t};var I="undefined"!=typeof Symbol?Symbol("util.promisify.custom"):void 0;function R(t,e){if(!t){var r=new Error("Promise was rejected with a falsy value");r.reason=t,t=r}return e(t)}e.promisify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');if(I&&t[I]){var e;if("function"!=typeof(e=t[I]))throw new TypeError('The "util.promisify.custom" argument must be of type Function');return Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),e}function e(){for(var e,r,n=new Promise((function(t,n){e=t,r=n})),i=[],o=0;o<arguments.length;o++)i.push(arguments[o]);i.push((function(t,n){t?r(t):e(n)}));try{t.apply(this,i)}catch(t){r(t)}return n}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),I&&Object.defineProperty(e,I,{value:e,enumerable:!1,writable:!1,configurable:!0}),Object.defineProperties(e,i(t))},e.promisify.custom=I,e.callbackify=function(t){if("function"!=typeof t)throw new TypeError('The "original" argument must be of type Function');function e(){for(var e=[],r=0;r<arguments.length;r++)e.push(arguments[r]);var i=e.pop();if("function"!=typeof i)throw new TypeError("The last argument must be of type Function");var o=this,a=function(){return i.apply(o,arguments)};t.apply(this,e).then((function(t){n.nextTick(a.bind(null,null,t))}),(function(t){n.nextTick(R.bind(null,t,a))}))}return Object.setPrototypeOf(e,Object.getPrototypeOf(t)),Object.defineProperties(e,i(t)),e}},8469:(t,e,r)=>{var n=r(2861).Buffer;function i(t){if(t<0||t>9007199254740991||t%1!=0)throw new RangeError("value out of range")}function o(t){return i(t),t<253?1:t<=65535?3:t<=4294967295?5:9}t.exports={encode:function t(e,r,a){if(i(e),r||(r=n.allocUnsafe(o(e))),!n.isBuffer(r))throw new TypeError("buffer must be a Buffer instance");return a||(a=0),e<253?(r.writeUInt8(e,a),t.bytes=1):e<=65535?(r.writeUInt8(253,a),r.writeUInt16LE(e,a+1),t.bytes=3):e<=4294967295?(r.writeUInt8(254,a),r.writeUInt32LE(e,a+1),t.bytes=5):(r.writeUInt8(255,a),r.writeUInt32LE(e>>>0,a+1),r.writeUInt32LE(e/4294967296|0,a+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 o=e.readUInt8(r);if(o<253)return t.bytes=1,o;if(253===o)return t.bytes=3,e.readUInt16LE(r+1);if(254===o)return t.bytes=5,e.readUInt32LE(r+1);t.bytes=9;var a=e.readUInt32LE(r+1),s=4294967296*e.readUInt32LE(r+5)+a;return i(s),s},encodingLength:o}},5767:(t,e,r)=>{var n=r(2682),i=r(9209),o=r(487),a=r(8075),s=r(5795),u=a("Object.prototype.toString"),c=r(9092)(),f="undefined"==typeof globalThis?r.g:globalThis,l=i(),h=a("String.prototype.slice"),p=Object.getPrototypeOf,d=a("Array.prototype.indexOf",!0)||function(t,e){for(var r=0;r<t.length;r+=1)if(t[r]===e)return r;return-1},y={__proto__:null};n(l,c&&s&&p?function(t){var e=new f[t];if(Symbol.toStringTag in e){var r=p(e),n=s(r,Symbol.toStringTag);if(!n){var i=p(r);n=s(i,Symbol.toStringTag)}y["$"+t]=o(n.get)}}:function(t){var e=new f[t],r=e.slice||e.set;r&&(y["$"+t]=o(r))}),t.exports=function(t){if(!t||"object"!=typeof t)return!1;if(!c){var e=h(u(t),8,-1);return d(l,e)>-1?e:"Object"===e&&function(t){var e=!1;return n(y,(function(r,n){if(!e)try{r(t),e=h(n,1)}catch(t){}})),e}(t)}return s?function(t){var e=!1;return n(y,(function(r,n){if(!e)try{"$"+r(t)===n&&(e=h(n,1))}catch(t){}})),e}(t):null}},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 a(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(a(t,e,r)):i.encode(a(t.version,t.privateKey,t.compressed))},encodeRaw:a}},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),a=o.charCodeAt(0);if(255!==e[a])throw new TypeError(o+" is ambiguous");e[a]=i}var s=t.length,u=t.charAt(0),c=Math.log(s)/Math.log(256),f=Math.log(256)/Math.log(s);function l(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 a=(t.length-r)*c+1>>>0,f=new Uint8Array(a);r<t.length;){var l=e[t.charCodeAt(r)];if(255===l)return;for(var h=0,p=a-1;(0!==l||h<o)&&-1!==p;p--,h++)l+=s*f[p]>>>0,f[p]=l%256>>>0,l=l/256>>>0;if(0!==l)throw new Error("Non-zero carry");o=h,r++}for(var d=a-o;d!==a&&0===f[d];)d++;var y=n.allocUnsafe(i+(a-d));y.fill(0,0,i);for(var b=i;d!==a;)y[b++]=f[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,a=e.length;o!==a&&0===e[o];)o++,r++;for(var c=(a-o)*f+1>>>0,l=new Uint8Array(c);o!==a;){for(var h=e[o],p=0,d=c-1;(0!==h||p<i)&&-1!==d;d--,p++)h+=256*l[d]>>>0,l[d]=h%s>>>0,h=h/s>>>0;if(0!==h)throw new Error("Non-zero carry");i=p,o++}for(var y=c-i;y!==c&&0===l[y];)y++;for(var b=u.repeat(r);y<c;++y)b+=t.charAt(l[y]);return b},decodeUnsafe:l,decode:function(t){var e=l(t);if(e)return e;throw new Error("Non-base"+s+" 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()}))},495:()=>{},4923:()=>{},8460:()=>{},2382:()=>{},3779:()=>{},7199:()=>{},9209:(t,e,r)=>{var n=r(6578),i="undefined"==typeof globalThis?r.g:globalThis;t.exports=function(){for(var t=[],e=0;e<n.length;e++)"function"==typeof i[n[e]]&&(t[t.length]=n[e]);return t}}},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}i.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return i.d(e,{a:e}),e},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 a={};t=t||[null,e({}),e([]),e(e)];for(var s=2&n&&r;"object"==typeof s&&!~t.indexOf(s);s=e(s))Object.getOwnPropertyNames(s).forEach((t=>a[t]=()=>r[t]));return a.default=()=>r,i.d(o,a),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,{iy:()=>le,gd:()=>fe,z2:()=>ge,G7:()=>Xi,GF:()=>Ct,nU:()=>gn,wf:()=>p,gf:()=>Jn,P8:()=>En,vg:()=>Qt,nr:()=>Lu,ry:()=>uo,z4:()=>zt,qT:()=>Co,kd:()=>kt,eA:()=>Fn,no:()=>An,o4:()=>Bn,YV:()=>Ot,O5:()=>St,cC:()=>qo,Wj:()=>_,Bc:()=>ta,LL:()=>Hn,gK:()=>Rn,PE:()=>jn,Go:()=>Ru,IB:()=>oe,rl:()=>os,Y_:()=>ni,yo:()=>ku,Ko:()=>Gn,pe:()=>xn,ho:()=>Wn,_l:()=>Ts,QS:()=>Mn,Bm:()=>Pn,W_:()=>Un,Hu:()=>Fs,Mg:()=>Aa,$v:()=>Kn,mt:()=>Ln,lJ:()=>Cn,ih:()=>ti,aw:()=>So,tm:()=>hn,Qc:()=>sn,dF:()=>eu,Wb:()=>Pr,D_:()=>ri,aS:()=>Ir,_3:()=>Gr,A9:()=>Iu,V$:()=>Pu,xc:()=>Wu,S2:()=>hu,qn:()=>_s,Gc:()=>Dn,zM:()=>In,c:()=>Nn,uW:()=>wn,FV:()=>Ds,UB:()=>su,jz:()=>ii,hL:()=>oi,$7:()=>a,rE:()=>s,rR:()=>Qn});var a={};i.r(a),i.d(a,{AddressGenerator:()=>le,AddressTypes:()=>fe,AddressVerificator:()=>ge,BitcoinUtils:()=>Xi,CalldataGenerator:()=>Ct,ChainId:()=>gn,Compressor:()=>p,Consensus:()=>Jn,ContractBaseMetadata:()=>En,CustomGenerator:()=>Qt,CustomKeypair:()=>Lu,CustomScriptTransaction:()=>uo,DeploymentGenerator:()=>zt,DeploymentTransaction:()=>Co,EcKeyPair:()=>kt,FACTORY_ADDRESS_FRACTAL:()=>Fn,FACTORY_ADDRESS_REGTEST:()=>An,FACTORY_ADDRESS_TESTNET:()=>Bn,FeatureOpCodes:()=>Ot,Features:()=>St,FundingTransaction:()=>qo,Generator:()=>_,InteractionTransaction:()=>ta,MOTO_ADDRESS_FRACTAL:()=>Hn,MOTO_ADDRESS_REGTEST:()=>Rn,MOTO_ADDRESS_TESTNET:()=>jn,MessageType:()=>Ru,MultiSignGenerator:()=>oe,MultiSignTransaction:()=>os,OPNetConsensusConfig:()=>ni,OPNetLimitedProvider:()=>ku,OPNetMetadata:()=>Gn,OPNetNetwork:()=>xn,OPNetTokenAddressManager:()=>Wn,P2TR_MS:()=>Ts,POOL_ADDRESS_FRACTAL:()=>Mn,POOL_ADDRESS_REGTEST:()=>Pn,POOL_ADDRESS_TESTNET:()=>Un,PSBTTypes:()=>Fs,PsbtTransaction:()=>Aa,ROUTER_ADDRESS_FRACTAL:()=>Kn,ROUTER_ADDRESS_REGTEST:()=>Ln,ROUTER_ADDRESS_TESTNET:()=>Cn,RoswellConsensus:()=>ti,SharedInteractionTransaction:()=>So,TapscriptVerificator:()=>hn,TransactionBuilder:()=>sn,TransactionFactory:()=>eu,TransactionSequence:()=>Pr,TransactionType:()=>ri,TweakedSigner:()=>Ir,TweakedTransaction:()=>Gr,UnisatChainType:()=>Iu,UnisatNetwork:()=>Pu,UnisatSigner:()=>Wu,UnwrapGeneration:()=>hu,UnwrapTransaction:()=>_s,WBTC_ADDRESS_FRACTAL:()=>Dn,WBTC_ADDRESS_REGTEST:()=>In,WBTC_ADDRESS_TESTNET:()=>Nn,Wallet:()=>wn,WrapTransaction:()=>Ds,WrappedGeneration:()=>su,currentConsensus:()=>ii,currentConsensusConfig:()=>oi,version:()=>s,wBTC:()=>Qn});var s="1.0.113",u=i(8559),c=i.n(u);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 l(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,h(n.key),n)}}function h(t){var e=function(t){if("object"!=f(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=f(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==f(e)?e:e+""}var p=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&l(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compress",value:function(e){return c().gzipSync(e,t.zlibOptions)}},{key:"decompress",value:function(e){return c().gunzipSync(e,t.zlibOptions)}}])}();!function(t,e,r){(e=h(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(p,"zlibOptions",{level:9,maxOutputLength:16777216});var d=i(1757),y=i(477),b=i(8287).Buffer;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 w(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,m(n.key),n)}}function v(t,e,r){return(e=m(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function m(t){var e=function(t){if("object"!=g(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=g(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==g(e)?e:e+""}var _=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),v(this,"network",d.o8.bitcoin),this.senderPubKey=e,this.contractSaltPubKey=r,this.network=n,this.xSenderPubKey=(0,y.toXOnly)(e)}return function(t,e){return e&&w(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"senderFirstByte",get:function(){return b.from([this.senderPubKey[0],0,0,0])}},{key:"splitBufferIntoChunks",value:function(e){for(var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:t.DATA_CHUNK_SIZE,n=[],i=0;i<e.length;i+=r){for(var o=Math.min(r,e.length-i),a=b.alloc(o),s=0;s<o;s++)a.writeUInt8(e[i+s],s);n.push([a])}return n}}])}();v(_,"DATA_CHUNK_SIZE",512),v(_,"MAGIC",b.from("bsi","utf-8"));var E=i(3513),S=i.t(E,2),k=i(852),T=i(8700),O=i(495),x=i.t(O,2);const A=BigInt(0),P=BigInt(1),I=BigInt(2),R=BigInt(3),L=BigInt(8),B=Object.freeze({a:A,b:BigInt(7),P:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:P,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee")}),U=(t,e)=>(t+e/I)/e,N={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar(t){const{n:e}=B,r=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),n=-P*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),i=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),o=r,a=BigInt("0x100000000000000000000000000000000"),s=U(o*t,e),u=U(-n*t,e);let c=ot(t-s*r-u*i,e),f=ot(-s*n-u*o,e);const l=c>a,h=f>a;if(l&&(c=e-c),h&&(f=e-f),c>a||f>a)throw new Error("splitScalarEndo: Endomorphism failed, k="+t);return{k1neg:l,k1:c,k2neg:h,k2:f}}};function j(t){const{a:e,b:r}=B,n=ot(t*t),i=ot(n*t);return ot(i+e*t+r)}const C=B.a===A;class F extends Error{constructor(t){super(t)}}function M(t){if(!(t instanceof D))throw new TypeError("JacobianPoint expected")}class D{constructor(t,e,r){this.x=t,this.y=e,this.z=r}static fromAffine(t){if(!(t instanceof W))throw new TypeError("JacobianPoint#fromAffine: expected Point");return t.equals(W.ZERO)?D.ZERO:new D(t.x,t.y,P)}static toAffineBatch(t){const e=function(t,e=B.P){const r=new Array(t.length),n=t.reduce(((t,n,i)=>n===A?t:(r[i]=t,ot(t*n,e))),P),i=st(n,e);return t.reduceRight(((t,n,i)=>n===A?t:(r[i]=ot(t*r[i],e),ot(t*n,e))),i),r}(t.map((t=>t.z)));return t.map(((t,r)=>t.toAffine(e[r])))}static normalizeZ(t){return D.toAffineBatch(t).map(D.fromAffine)}equals(t){M(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t,s=ot(n*n),u=ot(a*a),c=ot(e*u),f=ot(i*s),l=ot(ot(r*a)*u),h=ot(ot(o*n)*s);return c===f&&l===h}negate(){return new D(this.x,ot(-this.y),this.z)}double(){const{x:t,y:e,z:r}=this,n=ot(t*t),i=ot(e*e),o=ot(i*i),a=t+i,s=ot(I*(ot(a*a)-n-o)),u=ot(R*n),c=ot(u*u),f=ot(c-I*s),l=ot(u*(s-f)-L*o),h=ot(I*e*r);return new D(f,l,h)}add(t){M(t);const{x:e,y:r,z:n}=this,{x:i,y:o,z:a}=t;if(i===A||o===A)return this;if(e===A||r===A)return t;const s=ot(n*n),u=ot(a*a),c=ot(e*u),f=ot(i*s),l=ot(ot(r*a)*u),h=ot(ot(o*n)*s),p=ot(f-c),d=ot(h-l);if(p===A)return d===A?this.double():D.ZERO;const y=ot(p*p),b=ot(p*y),g=ot(c*y),w=ot(d*d-b-I*g),v=ot(d*(g-w)-l*b),m=ot(n*a*p);return new D(w,v,m)}subtract(t){return this.add(t.negate())}multiplyUnsafe(t){const e=D.ZERO;if("bigint"==typeof t&&t===A)return e;let r=it(t);if(r===P)return this;if(!C){let t=e,n=this;for(;r>A;)r&P&&(t=t.add(n)),n=n.double(),r>>=P;return t}let{k1neg:n,k1:i,k2neg:o,k2:a}=N.splitScalar(r),s=e,u=e,c=this;for(;i>A||a>A;)i&P&&(s=s.add(c)),a&P&&(u=u.add(c)),c=c.double(),i>>=P,a>>=P;return n&&(s=s.negate()),o&&(u=u.negate()),u=new D(ot(u.x*N.beta),u.y,u.z),s.add(u)}precomputeWindow(t){const e=C?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(D.BASE)&&(e=W.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&&K.get(e);n||(n=this.precomputeWindow(r),e&&1!==r&&(n=D.normalizeZ(n),K.set(e,n)));let i=D.ZERO,o=D.BASE;const a=1+(C?128/r:256/r),s=2**(r-1),u=BigInt(2**r-1),c=2**r,f=BigInt(r);for(let e=0;e<a;e++){const r=e*s;let a=Number(t&u);t>>=f,a>s&&(a-=c,t+=P);const l=r,h=r+Math.abs(a)-1,p=e%2!=0,d=a<0;0===a?o=o.add(H(p,n[l])):i=i.add(H(d,n[h]))}return{p:i,f:o}}multiply(t,e){let r,n,i=it(t);if(C){const{k1neg:t,k1:o,k2neg:a,k2:s}=N.splitScalar(i);let{p:u,f:c}=this.wNAF(o,e),{p:f,f:l}=this.wNAF(s,e);u=H(t,u),f=H(a,f),f=new D(ot(f.x*N.beta),f.y,f.z),r=u.add(f),n=c.add(l)}else{const{p:t,f:o}=this.wNAF(i,e);r=t,n=o}return D.normalizeZ([r,n])[0]}toAffine(t){const{x:e,y:r,z:n}=this,i=this.equals(D.ZERO);null==t&&(t=i?L:st(n));const o=t,a=ot(o*o),s=ot(a*o),u=ot(e*a),c=ot(r*s),f=ot(n*o);if(i)return W.ZERO;if(f!==P)throw new Error("invZ was invalid");return new W(u,c)}}function H(t,e){const r=e.negate();return t?r:e}D.BASE=new D(B.Gx,B.Gy,P),D.ZERO=new D(A,P,A);const K=new WeakMap;class W{constructor(t,e){this.x=t,this.y=e}_setWindowSize(t){this._WINDOW_SIZE=t,K.delete(this)}hasEvenY(){return this.y%I===A}static fromCompressedHex(t){const e=32===t.length,r=rt(e?t:t.subarray(1));if(!lt(r))throw new Error("Point is not on curve");let n=function(t){const{P:e}=B,r=BigInt(6),n=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),s=BigInt(88),u=t*t*t%e,c=u*u*t%e,f=at(c,R)*c%e,l=at(f,R)*c%e,h=at(l,I)*u%e,p=at(h,n)*h%e,d=at(p,i)*p%e,y=at(d,a)*d%e,b=at(y,s)*y%e,g=at(b,a)*d%e,w=at(g,R)*c%e,v=at(w,o)*p%e,m=at(v,r)*u%e,_=at(m,I);if(_*_%e!==t)throw new Error("Cannot find square root");return _}(j(r));const i=(n&P)===P;e?i&&(n=ot(-n)):!(1&~t[0])!==i&&(n=ot(-n));const o=new W(r,n);return o.assertValidity(),o}static fromUncompressedHex(t){const e=rt(t.subarray(1,33)),r=rt(t.subarray(33,65)),n=new W(e,r);return n.assertValidity(),n}static fromHex(t){const e=nt(t),r=e.length,n=e[0];if(32===r)return this.fromCompressedHex(e);if(33===r&&(2===n||3===n))return this.fromCompressedHex(e);if(65===r&&4===n)return this.fromUncompressedHex(e);throw new Error(`Point.fromHex: received invalid point. Expected 32-33 compressed bytes or 65 uncompressed bytes, not ${r}`)}static fromPrivateKey(t){return W.BASE.multiply(ht(t))}static fromSignature(t,e,r){const{r:n,s:i}=function(t){if(t instanceof z)return t.assertValidity(),t;try{return z.fromDER(t)}catch(e){return z.fromCompact(t)}}(e);if(![0,1,2,3].includes(r))throw new Error("Cannot recover: invalid recovery bit");const o=function(t,e=!1){const r=function(t){const e=8*t.length-256,r=rt(t);return e>0?r>>BigInt(e):r}(t);if(e)return r;const{n}=B;return r>=n?r-n:r}(nt(t)),{n:a}=B,s=2===r||3===r?n+a:n,u=st(s,a),c=ot(-o*u,a),f=ot(i*u,a),l=1&r?"03":"02",h=W.fromHex(l+Z(s)),p=W.BASE.multiplyAndAddUnsafe(h,c,f);if(!p)throw new Error("Cannot recover signature: point at infinify");return p.assertValidity(),p}toRawBytes(t=!1){return et(this.toHex(t))}toHex(t=!1){const e=Z(this.x);return t?`${this.hasEvenY()?"02":"03"}${e}`:`04${e}${Z(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(!lt(e)||!lt(r))throw new Error(t);const n=ot(r*r);if(ot(n-j(e))!==A)throw new Error(t)}equals(t){return this.x===t.x&&this.y===t.y}negate(){return new W(this.x,ot(-this.y))}double(){return D.fromAffine(this).double().toAffine()}add(t){return D.fromAffine(this).add(D.fromAffine(t)).toAffine()}subtract(t){return this.add(t.negate())}multiply(t){return D.fromAffine(this).multiply(t,this).toAffine()}multiplyAndAddUnsafe(t,e,r){const n=D.fromAffine(this),i=e===A||e===P||this!==W.BASE?n.multiplyUnsafe(e):n.multiply(e),o=D.fromAffine(t).multiplyUnsafe(r),a=i.add(o);return a.equals(D.ZERO)?void 0:a.toAffine()}}function G(t){return Number.parseInt(t[0],16)>=8?"00"+t:t}function V(t){if(t.length<2||2!==t[0])throw new Error(`Invalid signature integer tag: ${$(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:rt(r),left:t.subarray(e+2)}}W.BASE=new W(B.Gx,B.Gy),W.ZERO=new W(A,A);class z{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?$(t):t;if(128!==n.length)throw new Error(`${r}: Expected 64-byte hex`);return new z(tt(n.slice(0,64)),tt(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: ${$(t)}`);if(t[1]!==t.length-2)throw new Error("Invalid signature: incorrect length");const{data:e,left:r}=V(t.subarray(2)),{data:n,left:i}=V(r);if(i.length)throw new Error(`Invalid signature: left bytes after parsing: ${$(i)}`);return{r:e,s:n}}(e?t:et(t));return new z(r,n)}static fromHex(t){return this.fromDER(t)}assertValidity(){const{r:t,s:e}=this;if(!ft(t))throw new Error("Invalid Signature: r must be 0 < r < n");if(!ft(e))throw new Error("Invalid Signature: s must be 0 < s < n")}hasHighS(){const t=B.n>>P;return this.s>t}normalizeS(){return this.hasHighS()?new z(this.r,ot(-this.s,B.n)):this}toDERRawBytes(){return et(this.toDERHex())}toDERHex(){const t=G(Q(this.s)),e=G(Q(this.r)),r=t.length/2,n=e.length/2,i=Q(r),o=Q(n);return`30${Q(n+r+4)}02${o}${e}02${i}${t}`}toRawBytes(){return this.toDERRawBytes()}toHex(){return this.toDERHex()}toCompactRawBytes(){return et(this.toCompactHex())}toCompactHex(){return Z(this.r)+Z(this.s)}}function q(...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}const X=Array.from({length:256},((t,e)=>e.toString(16).padStart(2,"0")));function $(t){if(!(t instanceof Uint8Array))throw new Error("Expected Uint8Array");let e="";for(let r=0;r<t.length;r++)e+=X[t[r]];return e}const Y=BigInt("0x10000000000000000000000000000000000000000000000000000000000000000");function Z(t){if("bigint"!=typeof t)throw new Error("Expected bigint");if(!(A<=t&&t<Y))throw new Error("Expected number 0 <= n < 2^256");return t.toString(16).padStart(64,"0")}function J(t){const e=et(Z(t));if(32!==e.length)throw new Error("Error: expected 32 bytes");return e}function Q(t){const e=t.toString(16);return 1&e.length?`0${e}`:e}function tt(t){if("string"!=typeof t)throw new TypeError("hexToNumber: expected string, got "+typeof t);return BigInt(`0x${t}`)}function et(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 rt(t){return tt($(t))}function nt(t){return t instanceof Uint8Array?Uint8Array.from(t):et(t)}function it(t){if("number"==typeof t&&Number.isSafeInteger(t)&&t>0)return BigInt(t);if("bigint"==typeof t&&ft(t))return t;throw new TypeError("Expected valid private scalar: 0 < scalar < curve.n")}function ot(t,e=B.P){const r=t%e;return r>=A?r:e+r}function at(t,e){const{P:r}=B;let n=t;for(;e-- >A;)n*=n,n%=r;return n}function st(t,e=B.P){if(t===A||e<=A)throw new Error(`invert: expected positive integers, got n=${t} mod=${e}`);let r=ot(t,e),n=e,i=A,o=P,a=P,s=A;for(;r!==A;){const t=n/r,e=n%r,u=i-a*t,c=o-s*t;n=r,r=e,i=a,o=s,a=u,s=c}if(n!==P)throw new Error("invert: does not exist");return ot(i,e)}let ut,ct;function ft(t){return A<t&&t<B.n}function lt(t){return A<t&&t<B.P}function ht(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 key");e=tt(t)}else{if(!(t instanceof Uint8Array))throw new TypeError("Expected valid private key");if(32!==t.length)throw new Error("Expected 32 bytes of private key");e=rt(t)}if(!ft(e))throw new Error("Expected private key: 0 < key < n");return e}W.BASE._setWindowSize(8);const pt={node:x,web:"object"==typeof self&&"crypto"in self?self.crypto:void 0},dt={},yt={bytesToHex:$,hexToBytes:et,concatBytes:q,mod:ot,invert:st,isValidPrivateKey(t){try{return ht(t),!0}catch(t){return!1}},_bigintTo32Bytes:J,_normalizePrivateKey:ht,hashToPrivateKey:t=>{if((t=nt(t)).length<40||t.length>1024)throw new Error("Expected valid bytes of private key as per FIPS 186");return J(ot(rt(t),B.n-P)+P)},randomBytes:(t=32)=>{if(pt.web)return pt.web.getRandomValues(new Uint8Array(t));if(pt.node){const{randomBytes:e}=pt.node;return Uint8Array.from(e(t))}throw new Error("The environment doesn't have randomBytes function")},randomPrivateKey:()=>yt.hashToPrivateKey(yt.randomBytes(40)),precompute(t=8,e=W.BASE){const r=e===W.BASE?e:new W(e.x,e.y);return r._setWindowSize(t),r.multiply(R),r},sha256:async(...t)=>{if(pt.web){const e=await pt.web.subtle.digest("SHA-256",q(...t));return new Uint8Array(e)}if(pt.node){const{createHash:e}=pt.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(pt.web){const r=await pt.web.subtle.importKey("raw",t,{name:"HMAC",hash:{name:"SHA-256"}},!1,["sign"]),n=q(...e),i=await pt.web.subtle.sign("HMAC",r,n);return new Uint8Array(i)}if(pt.node){const{createHmac:r}=pt.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,...e)=>{let r=dt[t];if(void 0===r){const e=await yt.sha256(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=q(e,e),dt[t]=r}return yt.sha256(r,...e)},taggedHashSync:(t,...e)=>{if("function"!=typeof ut)throw new F("sha256Sync is undefined, you need to set it");let r=dt[t];if(void 0===r){const e=ut(Uint8Array.from(t,(t=>t.charCodeAt(0))));r=q(e,e),dt[t]=r}return ut(r,...e)},_JacobianPoint:D};Object.defineProperties(yt,{sha256Sync:{configurable:!1,get:()=>ut,set(t){ut||(ut=t)}},hmacSha256Sync:{configurable:!1,get:()=>ct,set(t){ct||(ct=t)}}});var bt=i(1944),gt=i(8287).Buffer;function wt(t){return wt="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},wt(t)}function vt(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,_t(n.key),n)}}function mt(t,e,r){return(e=_t(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function _t(t){var e=function(t){if("object"!=wt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=wt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==wt(e)?e:e+""}(0,d.f0)(S);var Et="function"==typeof k.Ay?k.Ay:k.Pr;if(!Et)throw new Error("Failed to load BIP32 library");var St,kt=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&vt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"fromWIF",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.ECPair.fromWIF(t,e)}},{key:"fromPrivateKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.ECPair.fromPrivateKey(gt.isBuffer(t)?t:gt.from(t),{network:e})}},{key:"fromPublicKey",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=gt.isBuffer(t)?t:gt.from(t);return this.ECPair.fromPublicKey(r,{network:e})}},{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin,n=this.verifyPubKeys(t,r);if(n.length!==t.length)throw new Error("Contains invalid public keys");var i=d.KT.p2ms({m:e,pubkeys:n,network:r}),o=d.KT.p2wsh({redeem:i,network:r}).address;if(!o)throw new Error("Failed to generate address");return o}},{key:"verifyPubKeys",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return e.map((function(e){var n=t.fromPublicKey(e,r);if(!n)throw new Error("Failed to regenerate key");return gt.from(n.publicKey)}))}},{key:"getP2WPKHAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2wpkh({pubkey:gt.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"tweakedPubKeyToAddress",value:function(t,e){t.startsWith("0x")&&(t=t.slice(2));var r=gt.from(t,"hex"),n=d.KT.p2tr({pubkey:(0,y.toXOnly)(r),network:e}).address;if(!n)throw new Error("Failed to generate Taproot address");return n}},{key:"xOnlyTweakedPubKeyToAddress",value:function(t,e){t.startsWith("0x")&&(t=t.slice(2));var r=gt.from(t,"hex"),n=d.KT.p2tr({pubkey:r,network:e}).address;if(!n)throw new Error("Failed to generate Taproot address");return n}},{key:"tweakPublicKey",value:function(t){t.startsWith("0x")&&(t=t.slice(2));var e=W.fromHex(t);e.hasEvenY()||(e=e.negate());var r=e.toRawBytes(!0).slice(1),n=(0,bt.taggedHash)("TapTweak",gt.from(r)),i=yt.mod(BigInt("0x"+gt.from(n).toString("hex")),B.n);return e.add(W.BASE.multiply(i)).toHex(!0)}},{key:"generateWallet",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin,e=this.ECPair.makeRandom({network:t}),r=this.getP2WPKHAddress(e,t);if(!r)throw new Error("Failed to generate wallet");return{address:r,privateKey:e.toWIF(),publicKey:gt.from(e.publicKey).toString("hex")}}},{key:"verifyContractAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return!!d.hl.toOutputScript(t,e)}},{key:"getLegacySegwitAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2sh({redeem:d.KT.p2wpkh({pubkey:gt.from(t.publicKey),network:e}),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getLegacyAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2pkh({pubkey:gt.from(t.publicKey),network:e});if(!r.address)throw new Error("Failed to generate wallet");return r.address}},{key:"getP2PKAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2pk({pubkey:gt.from(t.publicKey),network:e});if(!r.output)throw new Error("Failed to generate wallet");return"0x"+r.output.toString("hex")}},{key:"generateRandomKeyPair",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin;return this.ECPair.makeRandom({network:t})}},{key:"fromSeed",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return this.BIP32.fromSeed(t,e)}},{key:"getTaprootAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2tr({internalPubkey:(0,y.toXOnly)(gt.from(t.publicKey)),network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"getTaprootAddressFromAddress",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=d.KT.p2tr({address:t,network:e}).address;if(!r)throw new Error("Failed to generate sender address for transaction");return r}},{key:"fromSeedKeyPair",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin,r=this.BIP32.fromSeed(t,e).privateKey;if(!r)throw new Error("Failed to generate key pair");return this.ECPair.fromPrivateKey(r,{network:e})}}])}();function Tt(t){return Tt="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},Tt(t)}mt(kt,"BIP32",Et(S)),mt(kt,"ECPair",(0,T.dg)(S)),function(t){t[t.UNWRAP=0]="UNWRAP"}(St||(St={}));var Ot=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=Tt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tt(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},St.UNWRAP,d.Ez.OP_16),xt=i(8287).Buffer;function At(t){return At="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},At(t)}function Pt(t){return function(t){if(Array.isArray(t))return Rt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||It(t)||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.")}()}function It(t,e){if(t){if("string"==typeof t)return Rt(t,e);var r={}.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)?Rt(t,e):void 0}}function Rt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Lt(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,Bt(n.key),n)}}function Bt(t){var e=function(t){if("object"!=At(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=At(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==At(e)?e:e+""}function Ut(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ut=function(){return!!t})()}function Nt(t){return Nt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Nt(t)}function jt(t,e){return jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},jt(t,e)}var Ct=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Nt(e),function(t,e){if(e&&("object"==At(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,Ut()?Reflect.construct(e,r||[],Nt(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}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&&jt(t,e)}(t,_),function(t,e,r){return e&&Lt(t.prototype,e),r&&Lt(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(e,r){var n,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:[],o=arguments.length>3&&void 0!==arguments[3]?arguments[3]:[],a=arguments.length>4&&void 0!==arguments[4]?arguments[4]:0;if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var s=this.splitBufferIntoChunks(e);if(!s.length)throw new Error("No data chunks found");var u=[this.senderFirstByte,d.Ez.OP_TOALTSTACK,this.xSenderPubKey,d.Ez.OP_CHECKSIGVERIFY,this.contractSaltPubKey,d.Ez.OP_CHECKSIGVERIFY,d.Ez.OP_HASH160,d.Et.hash160(this.xSenderPubKey),d.Ez.OP_EQUALVERIFY,d.Ez.OP_HASH160,d.Et.hash160(r),d.Ez.OP_EQUALVERIFY,d.Ez.OP_DEPTH,d.Ez.OP_1,d.Ez.OP_NUMEQUAL,d.Ez.OP_IF,_.MAGIC];if(o.length>0){var c,f,l=t.getPubKeyAsBuffer(o,this.network),h=this.splitBufferIntoChunks(l);if(u=(c=u).concat.apply(c,[d.Ez.OP_0].concat(Pt(h))),!a)throw new Error("Minimum signatures must be provided");if(a>255)throw new Error("Minimum signatures cannot exceed 255");var p=xt.alloc(2);p.writeUint16LE(a,0),u=(f=u).concat.apply(f,[d.Ez.OP_1,p])}var y=i.map((function(t){return Ot[t]})),b=(u=(n=u).concat.apply(n,Pt(y).concat([d.Ez.OP_1NEGATE].concat(Pt(s),[d.Ez.OP_ELSE,d.Ez.OP_1,d.Ez.OP_ENDIF])))).flat(),g=d.K$.compile(b);if(!d.K$.decompile(g))throw new Error("Failed to decompile script??");return g}}],[{key:"getPubKeyAsBuffer",value:function(t,e){var r,n=xt.alloc(0),i=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=It(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}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 i,o=!0,a=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return o=t.done,t},e:function(t){a=!0,i=t},f:function(){try{o||null==e.return||e.return()}finally{if(a)throw i}}}}(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;if(!kt.fromPublicKey(o,e).compressed)throw new Error("Public key must be compressed");if(33!==o.byteLength)throw new Error("Public key must be 33 bytes, got ".concat(o.byteLength," bytes."));n=xt.concat([n,o])}}catch(t){i.e(t)}finally{i.f()}var a=p.compress(n);return a.byteLength>=n.byteLength?n:a}}])}();function Ft(t){return Ft="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},Ft(t)}function Mt(t){return function(t){if(Array.isArray(t))return Dt(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Dt(t,e);var r={}.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)?Dt(t,e):void 0}}(t)||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.")}()}function Dt(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ht(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,Kt(n.key),n)}}function Kt(t){var e=function(t){if("object"!=Ft(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ft(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ft(e)?e:e+""}function Wt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Wt=function(){return!!t})()}function Gt(t){return Gt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Gt(t)}function Vt(t,e){return Vt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Vt(t,e)}var zt=function(){function t(e,r){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Gt(e),function(t,e){if(e&&("object"==Ft(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,Wt()?Reflect.construct(e,r||[],Gt(t).constructor):e.apply(t,r))}(this,t,[e,r,n])}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&&Vt(t,e)}(t,_),function(t,e){return e&&Ht(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t,e,r){var n=this.getAsm(t,e,r),i=d.K$.compile(n);if(!d.K$.decompile(i))throw new Error("Failed to decompile script??");return i}},{key:"getAsm",value:function(t,e,r){if(!this.contractSaltPubKey)throw new Error("Contract salt public key not set");var n=this.splitBufferIntoChunks(t),i=r?this.splitBufferIntoChunks(r):[];return[this.senderFirstByte,d.Ez.OP_TOALTSTACK,this.xSenderPubKey,d.Ez.OP_CHECKSIGVERIFY,this.contractSaltPubKey,d.Ez.OP_CHECKSIGVERIFY,d.Ez.OP_HASH160,d.Et.hash160(this.xSenderPubKey),d.Ez.OP_EQUALVERIFY,d.Ez.OP_HASH256,d.Et.hash256(e),d.Ez.OP_EQUALVERIFY,d.Ez.OP_DEPTH,d.Ez.OP_1,d.Ez.OP_NUMEQUAL,d.Ez.OP_IF,_.MAGIC,d.Ez.OP_0].concat(Mt(i),[d.Ez.OP_1NEGATE],Mt(n),[d.Ez.OP_ELSE,d.Ez.OP_1,d.Ez.OP_ENDIF]).flat()}}])}();function qt(t){return qt="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},qt(t)}function Xt(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,$t(n.key),n)}}function $t(t){var e=function(t){if("object"!=qt(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=qt(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==qt(e)?e:e+""}function Yt(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Yt=function(){return!!t})()}function Zt(t){return Zt=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Zt(t)}function Jt(t,e){return Jt=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Jt(t,e)}var Qt=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){return e=Zt(e),function(t,e){if(e&&("object"==qt(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,Yt()?Reflect.construct(e,r||[],Zt(t).constructor):e.apply(t,r))}(this,t,[e,void 0,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&&Jt(t,e)}(t,_),function(t,e){return e&&Xt(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"compile",value:function(t){var e=t.flat(),r=d.K$.compile(e);if(!d.K$.decompile(r))throw new Error("Failed to decompile script??");return r}}])}(),te=i(8287).Buffer;function ee(t){return ee="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},ee(t)}function re(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function ne(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,ie(n.key),n)}}function ie(t){var e=function(t){if("object"!=ee(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ee(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ee(e)?e:e+""}var oe=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&ne(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"compile",value:function(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0,n=arguments.length>2?arguments[2]:void 0;if(r<2)throw new Error("Minimum signatures must be greater than 1");if(e.length<r)throw new Error("The amount of public keys is lower than the minimum required");if(r>t.MAXIMUM_SUPPORTED_SIGNATURE)throw new Error("The maximum amount of signatures is ".concat(t.MAXIMUM_SUPPORTED_SIGNATURE));var i=te.alloc(1);i.writeUInt8(r),e=(e=e.filter((function(t,e,r){return e===r.findIndex((function(e){return t.equals(e)}))}))).sort((function(t,e){return t.compare(e)}));var o=!1,a=e.map((function(t){var e=(0,y.toXOnly)(t);return n&&!o&&(o=n.equals(e)),e}));n&&!o&&a.push(n);var s=[d.Ez.OP_0].concat(function(t){return function(t){if(Array.isArray(t))return re(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return re(t,e);var r={}.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)?re(t,e):void 0}}(t)||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.")}()}(a.flatMap((function(t){return[t,d.Ez.OP_CHECKSIGADD]}))),[i,d.Ez.OP_NUMEQUAL]).flat(),u=d.K$.compile(s);if(!d.K$.decompile(u))throw new Error("Failed to decompile script.");return u}}])}();!function(t,e){(e=ie(e))in t?Object.defineProperty(t,e,{value:255,enumerable:!0,configurable:!0,writable:!0}):t[e]=255}(oe,"MAXIMUM_SUPPORTED_SIGNATURE");var ae=i(2343);function se(t){return se="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},se(t)}function ue(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,ce(n.key),n)}}function ce(t){var e=function(t){if("object"!=se(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=se(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==se(e)?e:e+""}(0,d.f0)(S);var fe,le=function(){return function(t,e,r){return r&&ue(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generatePKSH",value:function(t,e){if(32!==t.length)throw new Error("Invalid hash length");var r=(0,bt.ripemd160)(t);return this.toSegwitAddress(r,e)}},{key:"toSegwitAddress",value:function(t,e){var r=ae.bech32.toWords(t);return r.unshift(0),ae.bech32.encode(e.bech32,r)}}])}(),he=i(606),pe=i(8287).Buffer;function de(t){return de="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},de(t)}function ye(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,be(n.key),n)}}function be(t){var e=function(t){if("object"!=de(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=de(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==de(e)?e:e+""}(0,d.f0)(S),function(t){t.P2PKH="P2PKH",t.P2SH="P2SH",t.P2SH_P2WPKH="P2SH-P2WPKH",t.P2SH_OR_P2SH_P2WPKH="P2SH_OR_P2SH-P2WPKH",t.P2PK="P2PK",t.P2TR="P2TR",t.P2WPKH="P2WPKH"}(fe||(fe={}));var ge=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&ye(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"isValidP2TRAddress",value:function(t,e){if(!t||t.length<50)return!1;var r=!1;try{d.hl.toOutputScript(t,e),r=1===d.hl.fromBech32(t).version}catch(t){}return r}},{key:"isP2WPKHAddress",value:function(t,e){if(!t||t.length<20||t.length>50)return!1;var r=!1;try{var n=d.hl.fromBech32(t);d.hl.toOutputScript(t,e),r=0===n.version&&20===n.data.length}catch(t){}return r}},{key:"isP2PKHOrP2SH",value:function(t,e){try{var r=d.hl.fromBase58Check(t);return r.version===e.pubKeyHash||r.version===e.scriptHash}catch(t){return!1}}},{key:"isValidPublicKey",value:function(t,e){try{if(t.startsWith("0x")&&(t=t.slice(2)),(66===t.length||130===t.length)&&/^[0-9a-fA-F]+$/.test(t)){var r=pe.from(t,"hex");return kt.fromPublicKey(r,e),!0}}catch(t){return console.log(t),!1}return!1}},{key:"validateBitcoinAddress",value:function(e,r){if(t.isValidPublicKey(e,r))return fe.P2PK;try{var n=d.hl.fromBase58Check(e);if(n.version===r.pubKeyHash)return fe.P2PKH;if(n.version===r.scriptHash)return fe.P2SH_OR_P2SH_P2WPKH}catch(t){}try{var i=d.hl.fromBech32(e);if(i.prefix===r.bech32){if(0===i.version&&20===i.data.length)return fe.P2WPKH;if(1===i.version&&32===i.data.length)return fe.P2TR}}catch(t){}return null}}])}(),we={d:(t,e)=>{for(var r in e)we.o(e,r)&&!we.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r:t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})}},ve={};we.d(ve,{q$:()=>_r,Vy:()=>Er,$7:()=>me,rE:()=>_e});var me={};we.r(me),we.d(me,{DebugLevel:()=>_r,Logger:()=>Er,version:()=>_e});var _e="1.0.2";function Ee(t,e){t=t.replace("#","");var r=parseInt(t,16),n=Math.round(2.55*e),i=(r>>16)+n,o=(r>>8&255)+n,a=(255&r)+n;return(16777216+65536*(i<255?i<1?0:i:255)+256*(o<255?o<1?0:o:255)+(a<255?a<1?0:a:255)).toString(16).slice(1)}const Se=(t=0)=>e=>`[${e+t}m`,ke=(t=0)=>e=>`[${38+t};5;${e}m`,Te=(t=0)=>(e,r,n)=>`[${38+t};2;${e};${r};${n}m`,Oe={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(Oe.modifier),Object.keys(Oe.color),Object.keys(Oe.bgColor);const xe=function(){const t=new Map;for(const[e,r]of Object.entries(Oe)){for(const[e,n]of Object.entries(r))Oe[e]={open:`[${n[0]}m`,close:`[${n[1]}m`},r[e]=Oe[e],t.set(n[0],n[1]);Object.defineProperty(Oe,e,{value:r,enumerable:!1})}return Object.defineProperty(Oe,"codes",{value:t,enumerable:!1}),Oe.color.close="[39m",Oe.bgColor.close="[49m",Oe.color.ansi=Se(),Oe.color.ansi256=ke(),Oe.color.ansi16m=Te(),Oe.bgColor.ansi=Se(10),Oe.bgColor.ansi256=ke(10),Oe.bgColor.ansi16m=Te(10),Object.defineProperties(Oe,{rgbToAnsi256:{value:(t,e,r)=>t===e&&e===r?t<8?16:t>248?231:Math.round((t-8)/247*24)+232:16+36*Math.round(t/255*5)+6*Math.round(e/255*5)+Math.round(r/255*5),enumerable:!1},hexToRgb:{value(t){const e=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!e)return[0,0,0];let[r]=e;3===r.length&&(r=[...r].map((t=>t+t)).join(""));const n=Number.parseInt(r,16);return[n>>16&255,n>>8&255,255&n]},enumerable:!1},hexToAnsi256:{value:t=>Oe.rgbToAnsi256(...Oe.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return t-8+90;let e,r,n;if(t>=232)e=(10*(t-232)+8)/255,r=e,n=e;else{const i=(t-=16)%36;e=Math.floor(t/36)/5,r=Math.floor(i/6)/5,n=i%6/5}const i=2*Math.max(e,r,n);if(0===i)return 30;let o=30+(Math.round(n)<<2|Math.round(r)<<1|Math.round(e));return 2===i&&(o+=60),o},enumerable:!1},rgbToAnsi:{value:(t,e,r)=>Oe.ansi256ToAnsi(Oe.rgbToAnsi256(t,e,r)),enumerable:!1},hexToAnsi:{value:t=>Oe.ansi256ToAnsi(Oe.hexToAnsi256(t)),enumerable:!1}}),Oe}(),Ae=(()=>{if(navigator.userAgentData){const t=navigator.userAgentData.brands.find((({brand:t})=>"Chromium"===t));if(t&&t.version>93)return 3}return/\b(Chrome|Chromium)\//.test(navigator.userAgent)?1:0})(),Pe=0!==Ae&&{level:Ae,hasBasic:!0,has256:Ae>=2,has16m:Ae>=3},Ie={stdout:Pe,stderr:Pe};function Re(t,e,r){let n=t.indexOf(e);if(-1===n)return t;const i=e.length;let o=0,a="";do{a+=t.slice(o,n)+e+r,o=n+i,n=t.indexOf(e,o)}while(-1!==n);return a+=t.slice(o),a}const{stdout:Le,stderr:Be}=Ie,Ue=Symbol("GENERATOR"),Ne=Symbol("STYLER"),je=Symbol("IS_EMPTY"),Ce=["ansi","ansi","ansi256","ansi16m"],Fe=Object.create(null);class Me{constructor(t){return De(t)}}const De=t=>{const e=(...t)=>t.join(" ");return((t,e={})=>{if(e.level&&!(Number.isInteger(e.level)&&e.level>=0&&e.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const r=Le?Le.level:0;t.level=void 0===e.level?r:e.level})(e,t),Object.setPrototypeOf(e,He.prototype),e};function He(t){return De(t)}Object.setPrototypeOf(He.prototype,Function.prototype);for(const[t,e]of Object.entries(xe))Fe[t]={get(){const r=ze(this,Ve(e.open,e.close,this[Ne]),this[je]);return Object.defineProperty(this,t,{value:r}),r}};Fe.visible={get(){const t=ze(this,this[Ne],!0);return Object.defineProperty(this,"visible",{value:t}),t}};const Ke=(t,e,r,...n)=>"rgb"===t?"ansi16m"===e?xe[r].ansi16m(...n):"ansi256"===e?xe[r].ansi256(xe.rgbToAnsi256(...n)):xe[r].ansi(xe.rgbToAnsi(...n)):"hex"===t?Ke("rgb",e,r,...xe.hexToRgb(...n)):xe[r][t](...n),We=["rgb","hex","ansi256"];for(const t of We)Fe[t]={get(){const{level:e}=this;return function(...r){const n=Ve(Ke(t,Ce[e],"color",...r),xe.color.close,this[Ne]);return ze(this,n,this[je])}}},Fe["bg"+t[0].toUpperCase()+t.slice(1)]={get(){const{level:e}=this;return function(...r){const n=Ve(Ke(t,Ce[e],"bgColor",...r),xe.bgColor.close,this[Ne]);return ze(this,n,this[je])}}};const Ge=Object.defineProperties((()=>{}),{...Fe,level:{enumerable:!0,get(){return this[Ue].level},set(t){this[Ue].level=t}}}),Ve=(t,e,r)=>{let n,i;return void 0===r?(n=t,i=e):(n=r.openAll+t,i=e+r.closeAll),{open:t,close:e,openAll:n,closeAll:i,parent:r}},ze=(t,e,r)=>{const n=(...t)=>qe(n,1===t.length?""+t[0]:t.join(" "));return Object.setPrototypeOf(n,Ge),n[Ue]=t,n[Ne]=e,n[je]=r,n},qe=(t,e)=>{if(t.level<=0||!e)return t[je]?"":e;let r=t[Ne];if(void 0===r)return e;const{openAll:n,closeAll:i}=r;if(e.includes(""))for(;void 0!==r;)e=Re(e,r.close,r.open),r=r.parent;const o=e.indexOf("\n");return-1!==o&&(e=function(t,e,r,n){let i=0,o="";do{const a="\r"===t[n-1];o+=t.slice(i,a?n-1:n)+e+(a?"\r\n":"\n")+r,i=n+1,n=t.indexOf("\n",i)}while(-1!==n);return o+=t.slice(i),o}(e,i,n,o)),n+e+i};function Xe(t){return Xe="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},Xe(t)}function $e(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 Ye(t,e,r){return(e=Ze(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ze(t){var e=function(t){if("object"!=Xe(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xe(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xe(e)?e:e+""}function Je(t,e){return t.get(function(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")}(t,e))}Object.defineProperties(He.prototype,Fe),He(),He({level:Be?Be.level:0});var Qe=new WeakMap,tr=new WeakMap,er=new WeakMap,rr=new WeakMap,nr=new WeakMap,ir=new WeakMap,or=new WeakMap,ar=new WeakMap,sr=new WeakMap,ur=new WeakMap,cr=new WeakMap,fr=new WeakMap,lr=new WeakMap,hr=new WeakMap,pr=new WeakMap,dr=new WeakMap,yr=new WeakMap,br=function(){return t=function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:new Me;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Ye(this,"moduleName",""),Ye(this,"logColor","#00bfff"),Ye(this,"enableLogs",!0),Ye(this,"hideLogs",!1),$e(this,Qe,"#ff00ff"),$e(this,tr,Ee(Je(Qe,this),75)),$e(this,er,"#9400d3"),$e(this,rr,Ee(Je(er,this),15)),$e(this,nr,Ee(Je(rr,this),15)),$e(this,ir,"#7cfc00"),$e(this,or,Ee(Je(ir,this),15)),$e(this,ar,"#ffdead"),$e(this,sr,Ee(Je(ar,this),15)),$e(this,ur,"#ff8c00"),$e(this,cr,Ee(Je(ur,this),15)),$e(this,fr,"#ff4500"),$e(this,lr,Ee(Je(fr,this),15)),$e(this,hr,"#ffffff"),$e(this,pr,Ee(Je(hr,this),15)),$e(this,dr,"#8b0000"),$e(this,yr,Ee(Je(dr,this),15)),Ye(this,"prefix",""),this.chalk=e,this.moduleName=this.constructor.name},e=[{key:"setLogPrefix",value:function(t){this.prefix=t}},{key:"getStartPrefix",value:function(){return this.prefix}},{key:"disable",value:function(){this.enableLogs=!1}},{key:"enable",value:function(){this.enableLogs=!0}},{key:"fancyLog",value:function(t,e,r,n,i){this.enableLogs&&console.log(this.chalk.hex(Je(Qe,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(Je(hr,this))(t)+" "+this.chalk.hex(Je(cr,this))(e)+" "+this.chalk.hex(Je(hr,this))(r)+" "+this.chalk.hex(Je(nr,this))(n)+" "+this.chalk.hex(Je(hr,this))(i))}},{key:"log",value:function(){if(this.enableLogs&&!this.hideLogs){var t=Ee(this.logColor,15);console.log(this.chalk.hex(this.logColor)("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(t).apply(void 0,arguments))}}},{key:"lightOrangeLog",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Je(cr,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," LOG]: "))+this.chalk.hex(Je(hr,this)).apply(void 0,arguments)))}},{key:"error",value:function(){this.enableLogs&&console.log(this.chalk.hex(Je(fr,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," ERROR]: "))+this.chalk.hex(Je(lr,this)).apply(void 0,arguments))}},{key:"warn",value:function(){this.enableLogs&&console.log(this.chalk.hex(Je(ur,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," WARN]: "))+this.chalk.hex(Je(cr,this)).apply(void 0,arguments))}},{key:"debug",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Je(ar,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(Je(sr,this)).apply(void 0,arguments)))}},{key:"success",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Je(ir,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SUCCESS]: "))+this.chalk.hex(Je(or,this)).apply(void 0,arguments)))}},{key:"fail",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Je(fr,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," FAIL]: "))+this.chalk.hex(Je(lr,this)).apply(void 0,arguments)))}},{key:"debugBright",value:function(){this.enableLogs&&(this.hideLogs||console.log(this.chalk.hex(Je(er,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," DEBUG]: "))+this.chalk.hex(Je(rr,this)).apply(void 0,arguments)))}},{key:"important",value:function(){this.enableLogs&&console.log(this.chalk.hex(Je(Qe,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," IMPORTANT]: "))+this.chalk.hex(Je(tr,this)).apply(void 0,arguments))}},{key:"panic",value:function(){this.enableLogs&&console.log(this.chalk.hex(Je(dr,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," HELP PANIC]: "))+this.chalk.hex(Je(yr,this)).apply(void 0,arguments))}},{key:"info",value:function(){this.enableLogs&&console.log(this.chalk.hex(Je(Qe,this))("".concat(this.getStartPrefix(),"[").concat(this.moduleName," INFO]: "))+this.chalk.hex(Je(hr,this)).apply(void 0,arguments))}},{key:"securityNotice",value:function(){this.enableLogs&&console.log(this.chalk.hex("#22d8e6")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," SECURITY NOTICE]: "))+this.chalk.hex("#22e3e6").apply(void 0,arguments))}},{key:"traceLog",value:function(){this.enableLogs&&console.log(this.chalk.hex("#ffffff")("".concat(this.getStartPrefix(),"[").concat(this.moduleName," TRACE LOG]: "))+this.chalk.hex(Je(pr,this)).apply(void 0,arguments))}}],e&&function(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,Ze(n.key),n)}}(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t;var t,e}();function gr(t){return gr="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},gr(t)}function wr(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(wr=function(){return!!t})()}function vr(t){return vr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vr(t)}function mr(t,e){return mr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},mr(t,e)}var _r,Er=function(){function t(){return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e){return e=vr(e),function(t,e){if(e&&("object"==gr(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,wr()?Reflect.construct(e,[],vr(t).constructor):e.apply(t,void 0))}(this,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&&mr(t,e)}(t,br),e=t,Object.defineProperty(e,"prototype",{writable:!1}),e;var e}();!function(t){t[t.NONE=0]="NONE",t[t.ERROR=1]="ERROR",t[t.WARN=2]="WARN",t[t.INFO=3]="INFO",t[t.DEBUG=4]="DEBUG",t[t.TRACE=5]="TRACE",t[t.ALL=6]="ALL"}(_r||(_r={}));var Sr=ve.Vy,kr=i(2218),Tr=i(8287).Buffer;function Or(t){return Or="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},Or(t)}function xr(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,Ar(n.key),n)}}function Ar(t){var e=function(t){if("object"!=Or(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Or(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Or(e)?e:e+""}(0,d.f0)(S);var Pr,Ir=function(){return function(t,e,r){return r&&xr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"tweakSigner",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},r=t.privateKey;if(!r)throw new Error("Private key is required for tweaking signer!");3===t.publicKey[0]&&(r=E.privateNegate(r));var n=E.privateAdd(r,(0,kr.tapTweakHash)((0,y.toXOnly)(Tr.from(t.publicKey)),e.tweakHash));if(!n)throw new Error("Invalid tweaked private key!");return kt.fromPrivateKey(Tr.from(n),e.network)}}])}(),Rr=i(8287).Buffer;function Lr(t){return Lr="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},Lr(t)}function Br(){Br=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Lr(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Lr(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Ur(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Nr(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ur(o,n,i,a,s,"next",t)}function s(t){Ur(o,n,i,a,s,"throw",t)}a(void 0)}))}}function jr(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 Cr(t,e);var r={}.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)?Cr(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Cr(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Fr(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,Wr(n.key),n)}}function Mr(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Mr=function(){return!!t})()}function Dr(t){return Dr=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Dr(t)}function Hr(t,e){return Hr=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Hr(t,e)}function Kr(t,e,r){return(e=Wr(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Wr(t){var e=function(t){if("object"!=Lr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Lr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Lr(e)?e:e+""}!function(t){t[t.REPLACE_BY_FEE=4294967293]="REPLACE_BY_FEE",t[t.FINAL=4294967295]="FINAL"}(Pr||(Pr={}));var Gr=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Kr(r=function(t,e,r){return e=Dr(e),function(t,e){if(e&&("object"==Lr(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,Mr()?Reflect.construct(e,r||[],Dr(t).constructor):e.apply(t,r))}(this,t),"logColor","#00ffe1"),Kr(r,"finalized",!1),Kr(r,"signed",!1),Kr(r,"scriptData",null),Kr(r,"tapData",null),Kr(r,"inputs",[]),Kr(r,"sequence",Pr.REPLACE_BY_FEE),Kr(r,"tapLeafScript",null),Kr(r,"isBrowser",!1),Kr(r,"regenerated",!1),Kr(r,"ignoreSignatureErrors",!1),r.signer=e.signer,r.network=e.network,r.nonWitnessUtxo=e.nonWitnessUtxo,r.isBrowser="undefined"!=typeof window,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&&Hr(t,e)}(t,Sr),function(t,e,r){return e&&Fr(t.prototype,e),r&&Fr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"ignoreSignatureError",value:function(){this.ignoreSignatureErrors=!0}},{key:"getScriptAddress",value:function(){if(!this.scriptData||!this.scriptData.address)throw new Error("Tap data is required");return this.scriptData.address}},{key:"getTransaction",value:function(){return this.transaction.extractTransaction(!1)}},{key:"getTapAddress",value:function(){if(!this.tapData||!this.tapData.address)throw new Error("Tap data is required");return this.tapData.address}},{key:"disableRBF",value:function(){if(this.signed)throw new Error("Transaction is already signed");this.sequence=Pr.FINAL;var t,e=jr(this.inputs);try{for(e.s();!(t=e.n()).done;)t.value.sequence=Pr.FINAL}catch(t){e.e(t)}finally{e.f()}}},{key:"getTweakerHash",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.hash}},{key:"preEstimateTransactionFees",value:function(t,e,r,n,i){var o=10n+41n*e+68n*r;return(3n*o+(o+(144n*n+34n*i+(1n+35n*i+1n+n))))/4n*t}},{key:"generateTapData",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network}}},{key:"getSignerKey",value:function(){return this.signer}},{key:"signInput",value:(r=Nr(Br().mark((function e(r,n,i,o){var a,s,u;return Br().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(a=this.sighashTypes&&this.sighashTypes.length?[t.calculateSignHash(this.sighashTypes)]:void 0,o=o||this.getSignerKey(),s=!1,!n.tapInternalKey){e.next=21;break}if(this.tweakedSigner||this.tweakSigner(),!(u=o!==this.signer?this.getTweakedSigner(!0,o):this.tweakedSigner)){e.next=21;break}if(s=!0,e.prev=8,!("signTaprootInput"in o)){e.next=15;break}return e.next=12,o.signTaprootInput(r,i,a);case 12:return e.abrupt("return",e.sent);case 15:r.signTaprootInput(i,u,void 0,a);case 16:return e.abrupt("return");case 19:e.prev=19,e.t0=e.catch(8);case 21:if(e.prev=21,!("signInput"in o)){e.next=28;break}return e.next=25,o.signInput(r,i,a);case 25:return e.abrupt("return",e.sent);case 28:r.signInput(i,o,a);case 29:e.next=45;break;case 31:if(e.prev=31,e.t1=e.catch(21),s){e.next=45;break}if(!("signTaprootInput"in o)){e.next=40;break}return e.next=37,o.signTaprootInput(r,i,a);case 37:return e.abrupt("return",e.sent);case 40:if(!this.tweakedSigner){e.next=44;break}r.signTaprootInput(i,this.tweakedSigner,void 0,a),e.next=45;break;case 44:throw e.t1;case 45:case"end":return e.stop()}}),e,this,[[8,19],[21,31]])}))),function(t,e,n,i){return r.apply(this,arguments)})},{key:"splitArray",value:function(t,e){if(e<=0)throw new Error("Chunk size must be greater than 0.");for(var r=[],n=0;n<t.length;n+=e)r.push(t.slice(n,n+e));return r}},{key:"signInputs",value:(e=Nr(Br().mark((function t(e){var r,n,i,o,a,s,u,c,f,l;return Br().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.data.inputs,n=20,i=this.splitArray(r,n),o=0;case 4:if(!(o<i.length)){t.next=14;break}for(a=i[o],s=[],u=o*n,c=0;c<a.length;c++){f=u+c,l=a[c];try{s.push(this.signInput(e,l,f))}catch(t){this.log("Failed to sign input ".concat(f,": ").concat(t.stack))}}return t.next=11,Promise.all(s);case 11:o++,t.next=4;break;case 14:try{e.finalizeAllInputs(),this.finalized=!0}catch(t){this.finalized=!1}case 15:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"internalPubKeyToXOnly",value:function(){return(0,y.toXOnly)(Rr.from(this.signer.publicKey))}},{key:"internalInit",value:function(){this.scriptData=d.KT.p2tr(this.generateScriptAddress()),this.tapData=d.KT.p2tr(this.generateTapData())}},{key:"tweakSigner",value:function(){this.tweakedSigner||(this.tweakedSigner=this.getTweakedSigner(!0))}},{key:"getTweakedSigner",value:function(){var t=arguments.length>0&&void 0!==arguments[0]&&arguments[0],e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:this.signer,r={network:this.network};if(t&&(r.tweakHash=this.getTweakerHash()),"privateKey"in e)return Ir.tweakSigner(e,r)}},{key:"generatePsbtInputExtended",value:function(e,r){var n={hash:e.transactionId,index:e.outputIndex,witnessUtxo:{value:Number(e.value),script:Rr.from(e.scriptPubKey.hex,"hex")},sequence:this.sequence};if(this.sighashTypes){var i=t.calculateSignHash(this.sighashTypes);i&&(n.sighashType=i)}return this.tapLeafScript&&(n.tapLeafScript=[this.tapLeafScript]),0===r&&this.nonWitnessUtxo&&(n.nonWitnessUtxo=this.nonWitnessUtxo,this.log("Using non-witness utxo for input ".concat(r))),e.scriptPubKey.address&&ge.isValidP2TRAddress(e.scriptPubKey.address,this.network)&&(this.tweakSigner(),n.tapInternalKey=this.internalPubKeyToXOnly()),n}}],[{key:"readScriptWitnessToWitnessStack",value:function(t){var e=0;function r(){var r=he.varuint.decode(t,e);return e+=he.varuint.decode.bytes,r}return function(){for(var n=r(),i=[],o=0;o<n;o++)i.push(function(r){var n=t.subarray(e,e+r);return e+=r,n}(r()));return i}()}},{key:"preEstimateTaprootTransactionFees",value:function(t,e,r,n,i,o){var a=10n+41n*e+68n*r;return(3n*a+(a+(1n*e+n*i+(arguments.length>6&&void 0!==arguments[6]?arguments[6]:32n)*e+(arguments.length>7&&void 0!==arguments[7]?arguments[7]:139n)*e+o)))/4n*t}},{key:"signInput",value:function(t,e,r,n,i){i&&i[0]&&(e.sighashType=i[0]),t.signInput(r,n,i.length?i:void 0)}},{key:"calculateSignHash",value:function(t){if(!t)throw new Error("Sighash types are required");var e,r=0,n=jr(t);try{for(n.s();!(e=n.n()).done;)r|=e.value}catch(t){n.e(t)}finally{n.f()}return r||0}}]);var e,r}(),Vr=i(8287).Buffer;function zr(t){return zr="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},zr(t)}function qr(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Xr(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Xr(t,e){if(t){if("string"==typeof t)return $r(t,e);var r={}.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)?$r(t,e):void 0}}function $r(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Yr(){Yr=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==zr(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(zr(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Zr(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Jr(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Zr(o,n,i,a,s,"next",t)}function s(t){Zr(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Qr(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,an(n.key),n)}}function tn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(tn=function(){return!!t})()}function en(){return en="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=rn(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},en.apply(null,arguments)}function rn(t){return rn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},rn(t)}function nn(t,e){return nn=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},nn(t,e)}function on(t,e,r){return(e=an(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function an(t){var e=function(t){if("object"!=zr(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=zr(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==zr(e)?e:e+""}(0,d.f0)(S);var sn=function(){function t(e){var r,n;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),on(n=function(t,e,r){return e=rn(e),function(t,e){if(e&&("object"==zr(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,tn()?Reflect.construct(e,r||[],rn(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#785def"),on(n,"overflowFees",0n),on(n,"transactionFee",0n),on(n,"estimatedFees",0n),on(n,"updateInputs",[]),on(n,"outputs",[]),on(n,"feeOutput",null),on(n,"_maximumFeeRate",1e8),e.estimatedFees&&(n.estimatedFees=e.estimatedFees),n.signer=e.signer,n.network=e.network,n.feeRate=e.feeRate,n.priorityFee=null!==(r=e.priorityFee)&&void 0!==r?r:0n,n.utxos=e.utxos,n.to=e.to||void 0,n.isPubKeyDestination=!!n.to&&n.to.startsWith("0x"),n.optionalOutputs=e.optionalOutputs,n.from=t.getFrom(e.from,n.signer,n.network),n.totalInputAmount=n.calculateTotalUTXOAmount(),n.calculateTotalVOutAmount()<n.totalInputAmount)throw new Error("Vout value is less than the value to send");return n.transaction=new d.iL({network:n.network}),n}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&&nn(t,e)}(t,Gr),function(t,e,r){return e&&Qr(t.prototype,e),r&&Qr(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getFundingTransactionParameters",value:(c=Jr(Yr().mark((function t(){var e;return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.estimatedFees){t.next=4;break}return t.next=3,this.estimateTransactionFees();case 3:this.estimatedFees=t.sent;case 4:return t.abrupt("return",{utxos:this.utxos,to:this.getScriptAddress(),signer:this.signer,network:this.network,feeRate:this.feeRate,priorityFee:null!==(e=this.priorityFee)&&void 0!==e?e:0n,from:this.from,amount:this.estimatedFees,optionalOutputs:this.optionalOutputs});case 5:case"end":return t.stop()}}),t,this)}))),function(){return c.apply(this,arguments)})},{key:"setDestinationAddress",value:function(t){this.to=t}},{key:"setMaximumFeeRate",value:function(t){this._maximumFeeRate=t}},{key:"signTransaction",value:(u=Jr(Yr().mark((function t(){return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.to||this.isPubKeyDestination||kt.verifyContractAddress(this.to,this.network)){t.next=4;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 4:if(!this.signed){t.next=6;break}throw new Error("Transaction is already signed");case 6:return this.signed=!0,t.next=9,this.buildTransaction();case 9:return t.next=11,this.internalBuildTransaction(this.transaction);case 11:if(!t.sent){t.next=16;break}if(!this.regenerated){t.next=15;break}throw new Error("Transaction was regenerated");case 15:return t.abrupt("return",this.transaction.extractTransaction(!0,!0));case 16:throw new Error("Could not sign transaction");case 17:case"end":return t.stop()}}),t,this)}))),function(){return u.apply(this,arguments)})},{key:"generateTransactionMinimalSignatures",value:(s=Jr(Yr().mark((function t(){var e,r,n,i,o=arguments;return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=o.length>0&&void 0!==o[0]&&o[0],!this.to||this.isPubKeyDestination||kt.verifyContractAddress(this.to,this.network)){t.next=3;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 3:return t.next=5,this.buildTransaction();case 5:if(0===this.transaction.data.inputs.length){for(r=this.getInputs(),n=this.getOutputs(),this.transaction.setMaximumFeeRate(this._maximumFeeRate),this.transaction.addInputs(r,e),i=0;i<this.updateInputs.length;i++)this.transaction.updateInput(i,this.updateInputs[i]);this.transaction.addOutputs(n)}case 6:case"end":return t.stop()}}),t,this)}))),function(){return s.apply(this,arguments)})},{key:"signPSBT",value:(a=Jr(Yr().mark((function t(){return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return a.apply(this,arguments)})},{key:"addInput",value:function(t){this.inputs.push(t)}},{key:"addOutput",value:function(e){if(0!==e.value){if(e.value<t.MINIMUM_DUST)throw new Error("Output value is less than the minimum dust ".concat(e.value," < ").concat(t.MINIMUM_DUST));this.outputs.push(e)}}},{key:"toAddress",value:function(){return this.to}},{key:"address",value:function(){var t;return null===(t=this.tapData)||void 0===t?void 0:t.address}},{key:"estimateTransactionFees",value:(o=Jr(Yr().mark((function t(){var e,r,n,i;return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.utxos.length){t.next=2;break}throw new Error("No UTXOs specified");case 2:if(!this.estimatedFees){t.next=4;break}return t.abrupt("return",this.estimatedFees);case 4:return e=new d.iL({network:this.network}),t.next=7,this.internalBuildTransaction(e);case 7:if(!t.sent){t.next=16;break}return r=e.extractTransaction(!0,!0),n=r.virtualSize(),i=this.feeRate*n,this.estimatedFees=BigInt(Math.ceil(i)+1),t.abrupt("return",this.estimatedFees);case 16:throw new Error("Could not build transaction to estimate fee. Something went wrong while building the transaction.");case 17:case"end":return t.stop()}}),t,this)}))),function(){return o.apply(this,arguments)})},{key:"rebuildFromBase64",value:(i=Jr(Yr().mark((function t(e){return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return this.transaction=d.iL.fromBase64(e,{network:this.network}),this.signed=!1,this.sighashTypes=[d.ZX.SIGHASH_ANYONECANPAY,d.ZX.SIGHASH_ALL],t.next=5,this.signPSBT();case 5:return t.abrupt("return",t.sent);case 6:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"setPSBT",value:function(t){this.transaction=t}},{key:"getInputs",value:function(){return this.inputs}},{key:"getOutputs",value:function(){var t=function(t){return function(t){if(Array.isArray(t))return $r(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Xr(t)||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.")}()}(this.outputs);return this.feeOutput&&t.push(this.feeOutput),t}},{key:"addRefundOutput",value:(n=Jr(Yr().mark((function e(r){var n;return Yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(!((n=this.totalInputAmount-r-this.addOptionalOutputsAndGetAmount())>=t.MINIMUM_DUST)){e.next=10;break}if(!ge.isValidP2TRAddress(this.from,this.network)){e.next=7;break}return e.next=5,this.setFeeOutput({value:Number(n),address:this.from,tapInternalKey:this.internalPubKeyToXOnly()});case 5:e.next=9;break;case 7:return e.next=9,this.setFeeOutput({value:Number(n),address:this.from});case 9:return e.abrupt("return");case 10:this.warn("Amount to send back (".concat(n," sat) is less than the minimum dust (").concat(t.MINIMUM_DUST," sat), it will be consumed in fees instead."));case 11:case"end":return e.stop()}}),e,this)}))),function(t){return n.apply(this,arguments)})},{key:"addValueToToOutput",value:function(e){if(e<t.MINIMUM_DUST)throw new Error("Value to send is less than the minimum dust ".concat(e," < ").concat(t.MINIMUM_DUST));var r,n=qr(this.outputs);try{for(n.s();!(r=n.n()).done;){var i=r.value;if("address"in i&&i.address===this.to)return void(i.value+=Number(e))}}catch(t){n.e(t)}finally{n.f()}throw new Error("Output not found")}},{key:"getTransactionOPNetFee",value:function(){return this.priorityFee>t.MINIMUM_DUST?this.priorityFee:t.MINIMUM_DUST}},{key:"calculateTotalUTXOAmount",value:function(){var t,e=0n,r=qr(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"calculateTotalVOutAmount",value:function(){var t,e=0n,r=qr(this.utxos);try{for(r.s();!(t=r.n()).done;)e+=t.value.value}catch(t){r.e(t)}finally{r.f()}return e}},{key:"addOptionalOutputsAndGetAmount",value:function(){if(!this.optionalOutputs)return 0n;for(var t=0n,e=0;e<this.optionalOutputs.length;e++)this.addOutput(this.optionalOutputs[e]),t+=BigInt(this.optionalOutputs[e].value);return t}},{key:"addInputsFromUTXO",value:function(){if(this.utxos.length){if(this.totalInputAmount<t.MINIMUM_DUST)throw new Error("Total input amount is ".concat(this.totalInputAmount," sat which is less than the minimum dust ").concat(t.MINIMUM_DUST," sat."));for(var e=0;e<this.utxos.length;e++){var r=this.utxos[e],n=this.generatePsbtInputExtended(r,e);this.addInput(n)}}}},{key:"internalInit",value:function(){this.verifyUTXOValidity(),function(t,e,r){var n=en(rn(t.prototype),"internalInit",r);return"function"==typeof n?function(t){return n.apply(r,t)}:n}(t,0,this)([])}},{key:"updateInput",value:function(t){this.updateInputs.push(t)}},{key:"getWitness",value:function(){if(!this.tapData||!this.tapData.witness)throw new Error("Witness is required");if(0===this.tapData.witness.length)throw new Error("Witness is empty");return this.tapData.witness[this.tapData.witness.length-1]}},{key:"getTapOutput",value:function(){if(!this.tapData||!this.tapData.output)throw new Error("Tap data is required");return this.tapData.output}},{key:"verifyUTXOValidity",value:function(){var t,e=qr(this.utxos);try{for(e.s();!(t=e.n()).done;)if(!t.value.scriptPubKey)throw new Error("Address is required")}catch(t){e.e(t)}finally{e.f()}}},{key:"setFeeOutput",value:(r=Jr(Yr().mark((function e(r){var n,i,o,a;return Yr().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=r.value,e.next=3,this.estimateTransactionFees();case 3:if(i=e.sent,r.value=n-Number(i),!(r.value<t.MINIMUM_DUST)){e.next=11;break}if(this.feeOutput=null,!(r.value<0)){e.next=9;break}throw new Error("setFeeOutput: Insufficient funds to pay the fees. Fee: ".concat(i," < Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 9:e.next=20;break;case 11:return this.feeOutput=r,e.next=14,this.estimateTransactionFees();case 14:if(!((o=e.sent)>BigInt(n))){e.next=17;break}throw new Error("estimateTransactionFees: Insufficient funds to pay the fees. Fee: ".concat(o," > Value: ").concat(n,". Total input: ").concat(this.totalInputAmount," sat"));case 17:(a=n-Number(o))<t.MINIMUM_DUST?this.feeOutput=null:this.feeOutput.value=a,this.overflowFees=BigInt(a);case 20:case"end":return e.stop()}}),e,this)}))),function(t){return r.apply(this,arguments)})},{key:"internalBuildTransaction",value:(e=Jr(Yr().mark((function t(e){var r,n,i,o,a,s=arguments;return Yr().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.next=5,this.signInputs(e);case 5:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 9:t.prev=9,t.t0=t.catch(2),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 13:return t.abrupt("return",!1);case 14:case"end":return t.stop()}}),t,this,[[2,9]])}))),function(t){return e.apply(this,arguments)})}],[{key:"getFrom",value:function(t,e,r){return t||kt.getTaprootAddress(e,r)}},{key:"witnessStackToScriptWitness",value:function(t){var e,r=Vr.allocUnsafe(0);function n(t){var e=r.length,n=he.varuint.encodingLength(t);r=Vr.concat([r,Vr.allocUnsafe(n)]),he.varuint.encode(t,r,e)}return n((e=t).length),e.forEach((function(t){n(t.length),function(t){r=Vr.concat([r,Vr.from(t)])}(t)})),r}}]);var e,r,n,i,o,a,s,u,c}();on(sn,"LOCK_LEAF_SCRIPT",d.K$.compile([d.Ez.OP_0])),on(sn,"MINIMUM_DUST",330n);var un=i(8287).Buffer;function cn(t){return cn="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},cn(t)}function fn(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,ln(n.key),n)}}function ln(t){var e=function(t){if("object"!=cn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=cn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==cn(e)?e:e+""}var hn=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&fn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getContractAddress",value:function(e){var r=e.network||d.o8.bitcoin,n=[{output:new zt(e.deployerPubKey,(0,y.toXOnly)(e.contractSaltPubKey),r).compile(e.bytecode,e.originalSalt,e.calldata),version:t.TAP_SCRIPT_VERSION},{output:sn.LOCK_LEAF_SCRIPT,version:t.TAP_SCRIPT_VERSION}];return t.generateAddressFromScript(e,n)}},{key:"getContractSeed",value:function(t,e,r){var n=d.Et.hash256(e),i=un.concat([t,r,n]);return d.Et.hash256(i)}},{key:"generateContractVirtualAddress",value:function(e,r,n){var i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:d.o8.bitcoin,o=t.getContractSeed(e,r,n);return le.generatePKSH(o,i)}},{key:"generateAddressFromScript",value:function(t,e){var r=t.network||d.o8.bitcoin,n={internalPubkey:(0,y.toXOnly)(t.deployerPubKey),network:r,scriptTree:e};return d.KT.p2tr(n).address}}])}();!function(t,e){(e=ln(e))in t?Object.defineProperty(t,e,{value:192,enumerable:!0,configurable:!0,writable:!0}):t[e]=192}(hn,"TAP_SCRIPT_VERSION");var pn=i(8287).Buffer;function dn(t){return dn="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},dn(t)}function yn(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,bn(n.key),n)}}function bn(t){var e=function(t){if("object"!=dn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=dn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==dn(e)?e:e+""}var gn,wn=function(){function t(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=r,this._keypair=kt.fromWIF(e.privateKey,this.network),this._p2wpkh=kt.getP2WPKHAddress(this._keypair,this.network),this._p2tr=kt.getTaprootAddress(this._keypair,this.network),this._legacy=kt.getLegacyAddress(this._keypair,this.network),this._bufferPubKey=pn.from(e.publicKey,"hex")}return function(t,e,r){return e&&yn(t.prototype,e),r&&yn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"keypair",get:function(){if(!this._keypair)throw new Error("Keypair not set");return this._keypair}},{key:"p2wpkh",get:function(){return this._p2wpkh}},{key:"p2tr",get:function(){return this._p2tr}},{key:"legacy",get:function(){return this._legacy}},{key:"addresses",get:function(){return[this.p2wpkh,this.p2tr,this.legacy]}},{key:"publicKey",get:function(){if(!this._bufferPubKey)throw new Error("Public key not set");return this._bufferPubKey}},{key:"xOnly",get:function(){if(!this.keypair)throw new Error("Keypair not set");return(0,y.toXOnly)(this._bufferPubKey)}}],[{key:"fromWif",value:function(e){return new t({privateKey:e,address:"",publicKey:""},arguments.length>1&&void 0!==arguments[1]?arguments[1]:d.o8.bitcoin)}}])}();function vn(t){return vn="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},vn(t)}function mn(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(n.key),n)}}function _n(t){var e=function(t){if("object"!=vn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=vn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==vn(e)?e:e+""}!function(t){t[t.Bitcoin=0]="Bitcoin",t[t.Fractal=1]="Fractal"}(gn||(gn={}));var En=function(){return function(t,e,r){return e&&mn(t.prototype,e),r&&mn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin;!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.network=e}),[{key:"getAddress",value:function(){return this.address}}],[{key:"getAddress",value:function(){throw arguments.length>0&&void 0!==arguments[0]||d.o8.bitcoin,new Error("Method not implemented.")}}])}();function Sn(t){return Sn="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},Sn(t)}function kn(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,On(n.key),n)}}function Tn(t,e,r){return(e=On(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function On(t){var e=function(t){if("object"!=Sn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Sn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Sn(e)?e:e+""}var xn,An="bcrt1q9pf9fnpch9z2qrp5e3dgr2avzu3mypq3km2k40",Pn="bcrt1qg87nx9v9ln3qyadcn0llekzjn0hx8js46ztwky",In="bcrt1qamv2ejattjgsc6k3yf3zqrp0wpuyedqgjmwx0v",Rn="bcrt1qw8w4ejas2k22y54avv7hgrslg3cd0hme58h28r",Ln="bcrt1q9yd6mk324k0q4krmlxjky0pk65ul6hkf4u35e6",Bn="tb1qgev5kldhp5zvg6j8t9vl6x4phkrwn8nk9felxh",Un="tb1q6a7yw353hjmresphupytw5vczpqxtg4yrupayk",Nn="tb1qp28xna6pv47x6wflcplhu0a9hkld5shtvjx6xv",jn="tb1q4tyhf8hpu04qjj3qaag20knun0spctultxzakw",Cn="tb1qnh9mj95nnej25dwhjvvsppwmdm0myhxv7tllgt",Fn="bc1qr4g85824m58wu0zffjtnf56n425fp0e8azhc7q",Mn="bc1qv55cht4zzlt29ea7vdgwsedsn63a2sxtkgpv6h",Dn="bc1qdtzlucslvrvu4useyh9r69supqrw3w4xn9t4yv",Hn="bc1qfzq6w5uvgg5489egv0lj4shlqx4dagqt0ewdnu",Kn="bc1q9w2zvmkzlezt2fu34u57y9vuw6rll5sp2090kn";!function(t){t.Mainnet="mainnet",t.Testnet="testnet",t.Regtest="regtest"}(xn||(xn={}));var Wn=function(){return function(t,e){return e&&kn(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Tn(this,"metadata",Tn(Tn({},gn.Bitcoin,Tn(Tn({},xn.Testnet,{factory:Bn,pool:Un,wbtc:Nn,moto:jn,router:Cn}),xn.Regtest,{factory:An,pool:Pn,wbtc:In,moto:Rn,router:Ln})),gn.Fractal,Tn({},xn.Mainnet,{factory:Fn,pool:Mn,wbtc:Dn,moto:Hn,router:Kn})))}),[{key:"getFactoryAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.factory;if(!n)throw new Error("Factory address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getPoolAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.pool;if(!n)throw new Error("Pool address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getWBTCAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.wbtc;if(!n)throw new Error("WBTC address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getMOTOAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.moto;if(!n)throw new Error("MOTO address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getRouterAddress",value:function(t,e){var r,n=null===(r=this.metadata[e][t])||void 0===r?void 0:r.router;if(!n)throw new Error("Router address not found for network ".concat(t," and chainId ").concat(e));return n}},{key:"getAddresses",value:function(t,e){var r=this.metadata[e][t];if(!r)throw new Error("Metadata not found for network ".concat(t," and chainId ").concat(e));return r}}])}(),Gn=new Wn;function Vn(t){return Vn="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},Vn(t)}function zn(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,Zn(n.key),n)}}function qn(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(qn=function(){return!!t})()}function Xn(t){return Xn=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Xn(t)}function $n(t,e){return $n=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},$n(t,e)}function Yn(t,e,r){return(e=Zn(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zn(t){var e=function(t){if("object"!=Vn(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Vn(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Vn(e)?e:e+""}var Jn,Qn=function(){function t(){var e,r=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin,n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:gn.Bitcoin;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Yn(e=function(t,e,r){return e=Xn(e),function(t,e){if(e&&("object"==Vn(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,qn()?Reflect.construct(e,r||[],Xn(t).constructor):e.apply(t,r))}(this,t,[r]),"tokenName","Wrapped Bitcoin"),Yn(e,"tokenSymbol","wBTC"),Yn(e,"decimals",8),e.network=r,e.address=t.getAddress(r,n),e}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&&$n(t,e)}(t,En),function(t,e,r){return r&&zn(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"getAddress",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:d.o8.bitcoin,e=arguments.length>1?arguments[1]:void 0;switch(t.bech32){case d.o8.bitcoin.bech32:return this.getWBTCAddressForChain(null!=e?e:gn.Bitcoin);case d.o8.regtest.bech32:return In;case d.o8.testnet.bech32:return Nn;default:throw new Error("Invalid network: ".concat(t.bech32))}}},{key:"getWBTCAddressForChain",value:function(t){switch(t){case gn.Bitcoin:return"unknown";case gn.Fractal:return Dn;default:throw new Error("Invalid chainId: ".concat(t))}}}])}();!function(t){t[t.Roswell=0]="Roswell",t[t.Rachel=1]="Rachel",t[t.Kecksburg=2]="Kecksburg",t[t.Phoenix=3]="Phoenix",t[t.Aurora=4]="Aurora",t[t.Rendlesham=5]="Rendlesham",t[t.Lazar=6]="Lazar",t[t.ShagHarbor=7]="ShagHarbor",t[t.Exeter=8]="Exeter",t[t.Stephenville=9]="Stephenville",t[t.Valensole=10]="Valensole",t[t.Socorro=11]="Socorro",t[t.Pascagoula=12]="Pascagoula",t[t.Tehran=13]="Tehran",t[t.Westall=14]="Westall",t[t.Hopkinsville=15]="Hopkinsville",t[t.Belgium=16]="Belgium",t[t.Breeze=17]="Breeze",t[t.Flatwoods=18]="Flatwoods",t[t.Maury=20]="Maury",t[t.Varginha=21]="Varginha",t[t.Trindade=22]="Trindade",t[t.Levelland=23]="Levelland",t[t.Wanaque=24]="Wanaque",t[t.Coyame=25]="Coyame",t[t.Delphos=26]="Delphos"}(Jn||(Jn={}));var ti={CONSENSUS:Jn.Roswell,CONSENSUS_NAME:"Roswell",ENABLED_AT_BLOCK:0n,VAULT_MINIMUM_AMOUNT:200000n,VAULT_NETWORK_CONSOLIDATION_ACCEPTANCE:400000n,UNWRAP_CONSOLIDATION_PREPAID_FEES:250n,UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT:56500n};function ei(t){return ei="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},ei(t)}var ri,ni=function(t,e,r){return(e=function(t){var e=function(t){if("object"!=ei(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ei(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ei(e)?e:e+""}(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}({},Jn.Roswell,ti),ii=Jn.Roswell,oi=ni[ii];function ai(t){if(!Number.isSafeInteger(t)||t<0)throw new Error(`positive integer expected, not ${t}`)}function si(t,...e){if(!function(t){return t instanceof Uint8Array||null!=t&&"object"==typeof t&&"Uint8Array"===t.constructor.name}(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 ui(t){if("function"!=typeof t||"function"!=typeof t.create)throw new Error("Hash should be wrapped by utils.wrapConstructor");ai(t.outputLen),ai(t.blockLen)}function ci(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(t){t[t.GENERIC=0]="GENERIC",t[t.FUNDING=1]="FUNDING",t[t.DEPLOYMENT=2]="DEPLOYMENT",t[t.INTERACTION=3]="INTERACTION",t[t.WBTC_WRAP=4]="WBTC_WRAP",t[t.WBTC_UNWRAP=5]="WBTC_UNWRAP",t[t.MULTI_SIG=6]="MULTI_SIG",t[t.CUSTOM_CODE=7]="CUSTOM_CODE"}(ri||(ri={}));const fi=t=>new DataView(t.buffer,t.byteOffset,t.byteLength),li=(t,e)=>t<<32-e|t>>>e;function hi(t){return"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)),si(t),t}new Uint8Array(new Uint32Array([287454020]).buffer)[0];class pi{clone(){return this._cloneInto()}}const di={}.toString;function yi(t){const e=e=>t().update(hi(e)).digest(),r=t();return e.outputLen=r.outputLen,e.blockLen=r.blockLen,e.create=()=>t(),e}class bi extends pi{constructor(t,e){super(),this.finished=!1,this.destroyed=!1,ui(t);const r=hi(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 ci(this),this.iHash.update(t),this}digestInto(t){ci(this),si(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:a}=this;return t.finished=n,t.destroyed=i,t.blockLen=o,t.outputLen=a,t.oHash=e._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const gi=(t,e,r)=>new bi(t,e).update(r).digest();gi.create=(t,e)=>new bi(t,e);const wi=(t,e,r)=>t&e^~t&r,vi=(t,e,r)=>t&e^t&r^e&r;class mi extends pi{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=fi(this.buffer)}update(t){ci(this);const{view:e,buffer:r,blockLen:n}=this,i=(t=hi(t)).length;for(let o=0;o<i;){const a=Math.min(n-this.pos,i-o);if(a!==n)r.set(t.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===n&&(this.process(e,0),this.pos=0);else{const e=fi(t);for(;n<=i-o;o+=n)this.process(e,o)}}return this.length+=t.length,this.roundClean(),this}digestInto(t){ci(this),function(t,e){si(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),a=Number(r>>i&o),s=Number(r&o),u=n?4:0,c=n?0:4;t.setUint32(e+u,a,n),t.setUint32(e+c,s,n)}(r,n-8,BigInt(8*this.length),i),this.process(r,0);const a=fi(t),s=this.outputLen;if(s%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const u=s/4,c=this.get();if(u>c.length)throw new Error("_sha2: outputLen bigger than state");for(let t=0;t<u;t++)a.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:a}=this;return t.length=n,t.pos=a,t.finished=i,t.destroyed=o,n%e&&t.buffer.set(r),t}}const _i=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]),Ei=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Si=new Uint32Array(64);class ki extends mi{constructor(){super(64,32,8,!1),this.A=0|Ei[0],this.B=0|Ei[1],this.C=0|Ei[2],this.D=0|Ei[3],this.E=0|Ei[4],this.F=0|Ei[5],this.G=0|Ei[6],this.H=0|Ei[7]}get(){const{A:t,B:e,C:r,D:n,E:i,F:o,G:a,H:s}=this;return[t,e,r,n,i,o,a,s]}set(t,e,r,n,i,o,a,s){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|a,this.H=0|s}process(t,e){for(let r=0;r<16;r++,e+=4)Si[r]=t.getUint32(e,!1);for(let t=16;t<64;t++){const e=Si[t-15],r=Si[t-2],n=li(e,7)^li(e,18)^e>>>3,i=li(r,17)^li(r,19)^r>>>10;Si[t]=i+Si[t-7]+n+Si[t-16]|0}let{A:r,B:n,C:i,D:o,E:a,F:s,G:u,H:c}=this;for(let t=0;t<64;t++){const e=c+(li(a,6)^li(a,11)^li(a,25))+wi(a,s,u)+_i[t]+Si[t]|0,f=(li(r,2)^li(r,13)^li(r,22))+vi(r,n,i)|0;c=u,u=s,s=a,a=o+e|0,o=i,i=n,n=r,r=e+f|0}r=r+this.A|0,n=n+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,s=s+this.F|0,u=u+this.G|0,c=c+this.H|0,this.set(r,n,i,o,a,s,u,c)}roundClean(){Si.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ti=yi((()=>new ki)),Oi=BigInt(2**32-1),xi=BigInt(32);function Ai(t,e=!1){return e?{h:Number(t&Oi),l:Number(t>>xi&Oi)}:{h:0|Number(t>>xi&Oi),l:0|Number(t&Oi)}}const Pi={fromBig:Ai,split:function(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:a}=Ai(t[i],e);[r[i],n[i]]=[o,a]}return[r,n]},toBig:(t,e)=>BigInt(t>>>0)<<xi|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:(t,e,r)=>t<<r|e>>>32-r,rotlSL:(t,e,r)=>e<<r|t>>>32-r,rotlBH:(t,e,r)=>e<<r-32|t>>>64-r,rotlBL:(t,e,r)=>t<<r-32|e>>>64-r,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)},Ii=Pi,[Ri,Li]=(()=>Ii.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)))))(),Bi=new Uint32Array(80),Ui=new Uint32Array(80);class Ni extends mi{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:a,Dl:s,Eh:u,El:c,Fh:f,Fl:l,Gh:h,Gl:p,Hh:d,Hl:y}=this;return[t,e,r,n,i,o,a,s,u,c,f,l,h,p,d,y]}set(t,e,r,n,i,o,a,s,u,c,f,l,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|a,this.Dl=0|s,this.Eh=0|u,this.El=0|c,this.Fh=0|f,this.Fl=0|l,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)Bi[r]=t.getUint32(e),Ui[r]=t.getUint32(e+=4);for(let t=16;t<80;t++){const e=0|Bi[t-15],r=0|Ui[t-15],n=Ii.rotrSH(e,r,1)^Ii.rotrSH(e,r,8)^Ii.shrSH(e,r,7),i=Ii.rotrSL(e,r,1)^Ii.rotrSL(e,r,8)^Ii.shrSL(e,r,7),o=0|Bi[t-2],a=0|Ui[t-2],s=Ii.rotrSH(o,a,19)^Ii.rotrBH(o,a,61)^Ii.shrSH(o,a,6),u=Ii.rotrSL(o,a,19)^Ii.rotrBL(o,a,61)^Ii.shrSL(o,a,6),c=Ii.add4L(i,u,Ui[t-7],Ui[t-16]),f=Ii.add4H(c,n,s,Bi[t-7],Bi[t-16]);Bi[t]=0|f,Ui[t]=0|c}let{Ah:r,Al:n,Bh:i,Bl:o,Ch:a,Cl:s,Dh:u,Dl:c,Eh:f,El:l,Fh:h,Fl:p,Gh:d,Gl:y,Hh:b,Hl:g}=this;for(let t=0;t<80;t++){const e=Ii.rotrSH(f,l,14)^Ii.rotrSH(f,l,18)^Ii.rotrBH(f,l,41),w=Ii.rotrSL(f,l,14)^Ii.rotrSL(f,l,18)^Ii.rotrBL(f,l,41),v=f&h^~f&d,m=l&p^~l&y,_=Ii.add5L(g,w,m,Li[t],Ui[t]),E=Ii.add5H(_,b,e,v,Ri[t],Bi[t]),S=0|_,k=Ii.rotrSH(r,n,28)^Ii.rotrBH(r,n,34)^Ii.rotrBH(r,n,39),T=Ii.rotrSL(r,n,28)^Ii.rotrBL(r,n,34)^Ii.rotrBL(r,n,39),O=r&i^r&a^i&a,x=n&o^n&s^o&s;b=0|d,g=0|y,d=0|h,y=0|p,h=0|f,p=0|l,({h:f,l}=Ii.add(0|u,0|c,0|E,0|S)),u=0|a,c=0|s,a=0|i,s=0|o,i=0|r,o=0|n;const A=Ii.add3L(S,T,x);r=Ii.add3H(A,E,k,O),n=0|A}({h:r,l:n}=Ii.add(0|this.Ah,0|this.Al,0|r,0|n)),({h:i,l:o}=Ii.add(0|this.Bh,0|this.Bl,0|i,0|o)),({h:a,l:s}=Ii.add(0|this.Ch,0|this.Cl,0|a,0|s)),({h:u,l:c}=Ii.add(0|this.Dh,0|this.Dl,0|u,0|c)),({h:f,l}=Ii.add(0|this.Eh,0|this.El,0|f,0|l)),({h,l:p}=Ii.add(0|this.Fh,0|this.Fl,0|h,0|p)),({h:d,l:y}=Ii.add(0|this.Gh,0|this.Gl,0|d,0|y)),({h:b,l:g}=Ii.add(0|this.Hh,0|this.Hl,0|b,0|g)),this.set(r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g)}roundClean(){Bi.fill(0),Ui.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 ji=yi((()=>new Ni));var Ci=i(4148);function Fi(t,e,r,n){Ci(t,e,"INVALID_ARGUMENT",{argument:r,value:n})}var Mi=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")}(),Di=Mi.crypto||Mi.msCrypto;function Hi(t){switch(t){case"sha256":return Ti.create();case"sha512":return ji.create()}Fi(!1,"invalid hashing algorithm name","algorithm",t)}const Ki={createHash:Hi,createHmac:function(t,e){var r={sha256:Ti,sha512:ji}[t];return Fi(null!=r,"invalid hmac algorithm","algorithm",t),gi.create(r,e)},pbkdf2Sync:function(t,e,r,n,i){var o={sha256:Ti,sha512:ji}[i];return Fi(null!=o,"invalid pbkdf2 algorithm","algorithm",i),function(t,e,r,n){const{c:i,dkLen:o,DK:a,PRF:s,PRFSalt:u}=function(t,e,r,n){ui(t);const i=function(t,e){if(void 0!==e&&"[object Object]"!==di.call(e))throw new Error("Options should be object or undefined");return Object.assign({dkLen:32,asyncTick:10},e)}(0,n),{c:o,dkLen:a,asyncTick:s}=i;if(ai(o),ai(a),ai(s),o<1)throw new Error("PBKDF2: iterations (c) should be >= 1");const u=hi(e),c=hi(r),f=new Uint8Array(a),l=gi.create(t,u),h=l._cloneInto().update(c);return{c:o,dkLen:a,asyncTick:s,DK:f,PRF:l,PRFSalt:h}}(t,e,r,n);let c;const f=new Uint8Array(4),l=fi(f),h=new Uint8Array(s.outputLen);for(let t=1,e=0;e<o;t++,e+=s.outputLen){const r=a.subarray(e,e+s.outputLen);l.setInt32(0,t,!1),(c=u._cloneInto(c)).update(f).digestInto(h),r.set(h.subarray(0,r.length));for(let t=1;t<i;t++){s._cloneInto(c).update(h).digestInto(h);for(let t=0;t<r.length;t++)r[t]^=h[t]}}return function(t,e,r,n,i){return t.destroy(),e.destroy(),n&&n.destroy(),i.fill(0),r}(s,u,a,c,h)}(o,t,e,{c:r,dkLen:n})},randomBytes:function(t){Ci(null!=Di,"platform does not support secure random numbers","UNSUPPORTED_OPERATION",{operation:"randomBytes"}),Fi(Number.isInteger(t)&&t>0&&t<=1024,"invalid length","length",t);var e=new Uint8Array(t);return Di.getRandomValues(e),e}};var Wi=i(8287).Buffer;function Gi(t){return Gi="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},Gi(t)}function Vi(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function zi(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,qi(n.key),n)}}function qi(t){var e=function(t){if("object"!=Gi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Gi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Gi(e)?e:e+""}var Xi=function(){function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}return function(t,e,r){return r&&zi(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,0,[{key:"btcToSatoshi",value:function(t){return BigInt(1e8*t)}},{key:"rndBytes",value:function(){var e=t.getUnsafeRandomValues(64);return Wi.from(e)}},{key:"getUnsafeRandomValues",value:function(t){if("undefined"!=typeof window&&window.crypto&&window.crypto.getRandomValues){var e=new Uint8Array(t);return window.crypto.getRandomValues(e),Wi.from(e)}if(Ki&&"function"==typeof Ki.getRandomValues){var r=new Uint8Array(t);return Ki.getRandomValues(r),Wi.from(r)}for(var n=[],i=0;i<t;i++)n.push(Math.floor(256*Math.random()));return Wi.from(n)}},{key:"opnetHash",value:function(t){var e=Hi("sha512");e.update(t);var r=e.digest();return"0x".concat(Wi.from(r).toString("hex"))}},{key:"orderVaultsByAddress",value:function(t){return t.sort((function(t,e){return t.vault.localeCompare(e.vault)}))}},{key:"findVaultWithMostPublicKeys",value:function(e){var r,n,i=0,o=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 Vi(t,e);var r={}.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)?Vi(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}(e=t.orderVaultsByAddress(e));try{for(o.s();!(n=o.n()).done;){var a=n.value;a.publicKeys.length>i&&(i=a.publicKeys.length,r=a)}}catch(t){o.e(t)}finally{o.f()}if(!r)throw new Error("No vault with public keys found.");return r}}])}(),$i=i(8287).Buffer;function Yi(t){return Yi="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},Yi(t)}function Zi(){Zi=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Yi(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Yi(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Ji(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Qi(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ji(o,n,i,a,s,"next",t)}function s(t){Ji(o,n,i,a,s,"throw",t)}a(void 0)}))}}function to(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,so(n.key),n)}}function eo(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(eo=function(){return!!t})()}function ro(t,e,r,n){var i=no(io(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function no(){return no="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=io(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},no.apply(null,arguments)}function io(t){return io=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},io(t)}function oo(t,e){return oo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},oo(t,e)}function ao(t,e,r){return(e=so(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function so(t){var e=function(t){if("object"!=Yi(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Yi(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Yi(e)?e:e+""}var uo=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),ao(r=function(t,e,r){return e=io(e),function(t,e){if(e&&("object"==Yi(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,eo()?Reflect.construct(e,r||[],io(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.CUSTOM_CODE),ao(r,"tapLeafScript",null),ao(r,"targetScriptRedeem",null),ao(r,"leftOverFundsScriptRedeem",null),ao(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.witnesses.concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:sn.witnessStackToScriptWitness(n)}})),!e.script)throw new Error("Bitcoin script is required");if(!e.witnesses)throw new Error("Witness(es) are required");return r.witnesses=e.witnesses,r.randomBytes=e.randomBytes||Xi.rndBytes(),r.scriptSeed=r.getContractSeed(),r.contractSigner=kt.fromSeedKeyPair(r.scriptSeed,r.network),r.generator=new Qt(r.internalPubKeyToXOnly(),r.network),r.compiledTargetScript=r.generator.compile(e.script),r.scriptTree=r.getScriptTree(),r.internalInit(),r._scriptAddress=le.generatePKSH(r.scriptSeed,r.network),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&&oo(t,e)}(t,sn),function(t,e){return e&&to(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"scriptAddress",get:function(){return this._scriptAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return(0,y.toXOnly)($i.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(r=Qi(Zi().mark((function t(){var e,r;return Zi().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.next=14,this.addRefundOutput(r);case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Qi(Zi().mark((function e(r){var n;return Zi().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,ro(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getContractSeed",value:function(){return d.Et.hash256(this.randomBytes)}},{key:"getPubKeys",value:function(){var t=[$i.from(this.signer.publicKey)];return this.contractSigner&&t.push($i.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return sn.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}(),co=i(8287).Buffer;function fo(t){return fo="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},fo(t)}function lo(){lo=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==fo(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(fo(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function ho(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function po(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ho(o,n,i,a,s,"next",t)}function s(t){ho(o,n,i,a,s,"throw",t)}a(void 0)}))}}function yo(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,Eo(n.key),n)}}function bo(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(bo=function(){return!!t})()}function go(t,e,r,n){var i=wo(vo(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function wo(){return wo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=vo(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},wo.apply(null,arguments)}function vo(t){return vo=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},vo(t)}function mo(t,e){return mo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},mo(t,e)}function _o(t,e,r){return(e=Eo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Eo(t){var e=function(t){if("object"!=fo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=fo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==fo(e)?e:e+""}var So=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),_o(r=function(t,e,r){return e=vo(e),function(t,e){if(e&&("object"==fo(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,bo()?Reflect.construct(e,r||[],vo(t).constructor):e.apply(t,r))}(this,t,[e]),"targetScriptRedeem",null),_o(r,"leftOverFundsScriptRedeem",null),_o(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!r.contractSecret)throw new Error("Contract secret is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:sn.witnessStackToScriptWitness(n)}})),!e.calldata)throw new Error("Calldata is required");return r.disableAutoRefund=e.disableAutoRefund||!1,r.calldata=p.compress(e.calldata),r.randomBytes=e.randomBytes||Xi.rndBytes(),r.scriptSigner=r.generateKeyPairFromSeed(),r.calldataGenerator=new Ct(co.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),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&&mo(t,e)}(t,sn),function(t,e){return e&&yo(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"getContractSecret",value:function(){return this.contractSecret}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"generateSecret",value:function(){if(!this.to)throw new Error("To address is required");return d.hl.fromBech32(this.to).data}},{key:"scriptSignerXOnlyPubKey",value:function(){return(0,y.toXOnly)(co.from(this.scriptSigner.publicKey))}},{key:"generateKeyPairFromSeed",value:function(){return kt.fromSeedKeyPair(this.randomBytes,this.network)}},{key:"buildTransaction",value:(n=po(lo().mark((function t(){var e,r;return lo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("To address is required");case 2:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=5;break}throw new Error("Left over funds script redeem is required");case 5:if(e.redeemVersion){t.next=7;break}throw new Error("Left over funds script redeem version is required");case 7:if(e.output){t.next=9;break}throw new Error("Left over funds script redeem output is required");case 9:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.regenerated||this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),this.disableAutoRefund){t.next=16;break}return t.next=16,this.addRefundOutput(r);case 16:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"signInputs",value:(r=po(lo().mark((function e(r){var n,i,o,a,s,u,c,f;return lo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.scriptSigner){e.next=4;break}return e.next=3,go(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:n=r.data.inputs,i=0;case 6:if(!(i<n.length)){e.next=15;break}for(o=n.slice(i,i+20),a=[],s=0;s<o.length;s++)u=20*i+s,c=o[s],a.push(this.signIndividualInputs(r,c,u));return e.next=12,Promise.all(a).catch((function(t){throw t}));case 12:i+=20,e.next=6;break;case 15:try{r.finalizeInput(0,this.customFinalizer)}catch(t){this.error("Failed to finalize input 0: ".concat(t.stack))}for(f=0;f<n.length;f++)try{r.finalizeInput(f),this.log("Finalized input ".concat(f,"!"))}catch(t){}case 17:case"end":return e.stop()}}),e,this)}))),function(t){return r.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,this.internalPubKeyToXOnly(),t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"getScriptTree",value:function(){if(!this.calldata)throw new Error("Calldata is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"signIndividualInputs",value:(e=po(lo().mark((function t(e,r,n){var i;return lo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=!1,t.prev=1,t.next=4,this.signInput(e,r,n,this.scriptSigner);case 4:i=!0,t.next=9;break;case 7:t.prev=7,t.t0=t.catch(1);case 9:return t.prev=9,t.next=12,this.signInput(e,r,n);case 12:i=!0,t.next=17;break;case 15:t.prev=15,t.t1=t.catch(9);case 17:if(!i){t.next=20;break}return this.log("Signed input #".concat(n," out of ").concat(e.data.inputs.length,"! {Signed: ").concat(i,"}")),t.abrupt("return");case 20:if(!this.regenerated&&!this.ignoreSignatureErrors){t.next=22;break}return t.abrupt("return");case 22:throw new Error("Failed to sign input");case 23:case"end":return t.stop()}}),t,this,[[1,7],[9,15]])}))),function(t,r,n){return e.apply(this,arguments)})},{key:"getPubKeys",value:function(){var t=[co.from(this.signer.publicKey)];return this.scriptSigner&&t.push(co.from(this.scriptSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}]);var e,r,n}();_o(So,"MAXIMUM_CALLDATA_SIZE",1048576);var ko=i(8287).Buffer;function To(t){return To="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},To(t)}function Oo(){Oo=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==To(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(To(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function xo(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ao(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){xo(o,n,i,a,s,"next",t)}function s(t){xo(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Po(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,jo(n.key),n)}}function Io(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Io=function(){return!!t})()}function Ro(t,e,r,n){var i=Lo(Bo(1&n?t.prototype:t),e,r);return 2&n&&"function"==typeof i?function(t){return i.apply(r,t)}:i}function Lo(){return Lo="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,r){var n=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=Bo(t)););return t}(t,e);if(n){var i=Object.getOwnPropertyDescriptor(n,e);return i.get?i.get.call(arguments.length<3?t:r):i.value}},Lo.apply(null,arguments)}function Bo(t){return Bo=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Bo(t)}function Uo(t,e){return Uo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Uo(t,e)}function No(t,e,r){return(e=jo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function jo(t){var e=function(t){if("object"!=To(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=To(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==To(e)?e:e+""}var Co=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),No(r=function(t,e,r){return e=Bo(e),function(t,e){if(e&&("object"==To(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,Io()?Reflect.construct(e,r||[],Bo(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.DEPLOYMENT),No(r,"tapLeafScript",null),No(r,"targetScriptRedeem",null),No(r,"leftOverFundsScriptRedeem",null),No(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("Tap script signature is required");var n=[r.randomBytes,r.internalPubKeyToXOnly(),e.tapScriptSig[0].signature,e.tapScriptSig[1].signature].concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:sn.witnessStackToScriptWitness(n)}})),r.bytecode=p.compress(e.bytecode),r.verifyBytecode(),e.calldata&&(r.calldata=e.calldata,r.verifyCalldata()),r.randomBytes=e.randomBytes||Xi.rndBytes(),r.contractSeed=r.getContractSeed(),r.contractSigner=kt.fromSeedKeyPair(r.contractSeed,r.network),r.deploymentGenerator=new zt(ko.from(r.signer.publicKey),r.contractSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.deploymentGenerator.compile(r.bytecode,r.randomBytes,r.calldata),r.scriptTree=r.getScriptTree(),r.internalInit(),r._contractAddress=le.generatePKSH(r.contractSeed,r.network),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&&Uo(t,e)}(t,sn),function(t,e){return e&&Po(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"contractAddress",get:function(){return this._contractAddress}},{key:"p2trAddress",get:function(){return this.to||this.getScriptAddress()}},{key:"getRndBytes",value:function(){return this.randomBytes}},{key:"contractSignerXOnlyPubKey",value:function(){return(0,y.toXOnly)(ko.from(this.contractSigner.publicKey))}},{key:"buildTransaction",value:(r=Ao(Oo().mark((function t(){var e,r;return Oo().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to||(this.to=this.getScriptAddress()),e=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=4;break}throw new Error("Left over funds script redeem is required");case 4:if(e.redeemVersion){t.next=6;break}throw new Error("Left over funds script redeem version is required");case 6:if(e.output){t.next=8;break}throw new Error("Left over funds script redeem output is required");case 8:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),t.next=14,this.addRefundOutput(r);case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Ao(Oo().mark((function e(r){var n;return Oo().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.contractSigner){e.next=4;break}return e.next=3,Ro(t,"signInputs",this,3)([r]);case 3:return e.abrupt("return");case 4:for(n=0;n<r.data.inputs.length;n++)0===n?(r.signInput(0,this.contractSigner),r.signInput(0,this.getSignerKey()),r.finalizeInput(0,this.customFinalizer)):(r.signInput(n,this.getSignerKey()),r.finalizeInput(n));case 5:case"end":return e.stop()}}),e,this)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var t=this.contractSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem;if(!t)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:this.scriptTree,redeem:t}}},{key:"verifyCalldata",value:function(){if(this.calldata&&this.calldata.length>So.MAXIMUM_CALLDATA_SIZE)throw new Error("Calldata size overflow.")}},{key:"verifyBytecode",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");if(this.bytecode.length>t.MAXIMUM_CONTRACT_SIZE)throw new Error("Contract size overflow.")}},{key:"getContractSeed",value:function(){if(!this.bytecode)throw new Error("Bytecode is required");var t=this.internalPubKeyToXOnly(),e=d.Et.hash256(this.randomBytes),r=d.Et.hash256(this.bytecode),n=ko.concat([t,e,r]);return d.Et.hash256(n)}},{key:"getPubKeys",value:function(){var t=[ko.from(this.signer.publicKey)];return this.contractSigner&&t.push(ko.from(this.contractSigner.publicKey)),t}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={pubkeys:this.getPubKeys(),output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={pubkeys:this.getPubKeys(),output:this.getLeafScript(),redeemVersion:192}}},{key:"getLeafScript",value:function(){return sn.LOCK_LEAF_SCRIPT}},{key:"getScriptTree",value:function(){if(!this.bytecode)throw new Error("Contract bytecode is required");return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:this.getLeafScript(),version:192}]}}]);var e,r}();No(Co,"MAXIMUM_CONTRACT_SIZE",131072);var Fo=i(8287).Buffer;function Mo(t){return Mo="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},Mo(t)}function Do(){Do=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Mo(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Mo(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Ho(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ko(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,zo(n.key),n)}}function Wo(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Wo=function(){return!!t})()}function Go(t){return Go=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Go(t)}function Vo(t,e){return Vo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Vo(t,e)}function zo(t){var e=function(t){if("object"!=Mo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Mo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Mo(e)?e:e+""}var qo=function(){function t(e){var r,n;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=zo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(n=function(t,e,r){return e=Go(e),function(t,e){if(e&&("object"==Mo(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,Wo()?Reflect.construct(e,r||[],Go(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.FUNDING),n.amount=e.amount,n.splitInputsInto=null!==(r=e.splitInputsInto)&&void 0!==r?r:1,n.internalInit(),n}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&&Vo(t,e)}(t,sn),function(t,e){return e&&Ko(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ho(o,n,i,a,s,"next",t)}function s(t){Ho(o,n,i,a,s,"throw",t)}a(void 0)}))}}(Do().mark((function t(){return Do().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("Recipient address is required");case 2:return this.addInputsFromUTXO(),this.splitInputsInto>1?this.splitInputs(this.amount):this.isPubKeyDestination?this.addOutput({value:Number(this.amount),script:Fo.from(this.to.slice(2),"hex")}):this.addOutput({value:Number(this.amount),address:this.to}),t.next=6,this.addRefundOutput(this.amount);case 6:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"splitInputs",value:function(t){if(!this.to)throw new Error("Recipient address is required");for(var e=t/BigInt(this.splitInputsInto),r=0;r<this.splitInputsInto;r++)this.isPubKeyDestination?this.addOutput({value:Number(e),script:Fo.from(this.to.slice(2),"hex")}):this.addOutput({value:Number(e),address:this.to})}},{key:"getSignerKey",value:function(){return this.signer}}]);var e}();function Xo(t){return Xo="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},Xo(t)}function $o(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return($o=function(){return!!t})()}function Yo(t){return Yo=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Yo(t)}function Zo(t,e){return Zo=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Zo(t,e)}function Jo(t,e,r){return(e=Qo(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Qo(t){var e=function(t){if("object"!=Xo(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Xo(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Xo(e)?e:e+""}var ta=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Jo(r=function(t,e,r){return e=Yo(e),function(t,e){if(e&&("object"==Xo(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||[],Yo(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.INTERACTION),Jo(r,"tapLeafScript",null),r.contractSecret=r.generateSecret(),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&Zo(t,e)}(t,So),function(t){return Object.defineProperty(t,"prototype",{writable:!1}),t}(t)}(),ea=i(8287).Buffer;class ra{static bufferToUint8Array(t){if(ea.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 ea.from(t,0,t.byteLength).toString("hex")}static hexToUint8Array(t){t.startsWith("0x")&&(t=t.substring(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.substring(2*n,2*n+2),16);return r}static pointerToUint8Array(t){const e=t.toString(16).padStart(64,"0");return ra.hexToUint8Array(e)}static uint8ArrayToPointer(t){const e=ra.uint8ArrayToHex(t);return BigInt("0x"+e)}static valueToUint8Array(t){const e=t.toString(16).padStart(64,"0");return ra.hexToUint8Array(e)}static uint8ArrayToValue(t){const e=ra.uint8ArrayToHex(t);return e?BigInt("0x"+e):BigInt(0)}}function na(t,e){const r=BigInt.asUintN(32,t),n=t>>32n,i=BigInt.asUintN(32,e),o=e>>32n;return r*i+(n*i<<32n)+(r*o<<32n)+(n*o<<64n)}ra.EXPECTED_BUFFER_LENGTH=32;class ia{constructor(t){this.compareFn=t,this.elements=[]}add(t){this.elements.includes(t)||(this.elements.push(t),this.elements.sort(this.compareFn))}delete(t){const e=this.elements.indexOf(t);return-1!==e&&(this.elements.splice(e,1),!0)}has(t){return this.elements.includes(t)}clear(){this.elements=[]}forEach(t){for(const e of this.elements)t(e,this)}static fromSet(t,e){const r=new ia(e);for(const e of t)r.add(e);return r}get size(){return this.elements.length}*[Symbol.iterator](){for(const t of this.elements)yield t}}var oa,aa,sa=function(t,e,r,n,i){if("m"===n)throw new TypeError("Private method is not writable");if("a"===n&&!i)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===n?i.call(t,r):i?i.value=r:e.set(t,r),r},ua=function(t,e,r,n){if("a"===r&&!n)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===r?n:"a"===r?n.call(t):n?n.value:e.get(t)};class ca{constructor(t){this.compareFn=t,oa.set(this,void 0),this.map=new Map,sa(this,oa,[],"f")}set(t,e){this.map.has(t)||(ua(this,oa,"f").push(t),ua(this,oa,"f").sort(this.compareFn)),this.map.set(t,e)}get(t){return this.map.get(t)}keys(){return ua(this,oa,"f").values()}values(){const t=[];for(let e=0;e<ua(this,oa,"f").length;e++){const r=ua(this,oa,"f")[e],n=this.map.get(r);if(!n)throw new Error("Value not found");t.push(n)}return t.values()}has(t){return this.map.has(t)}delete(t){return!!this.map.has(t)&&(this.map.delete(t),sa(this,oa,ua(this,oa,"f").filter((e=>e!==t)),"f"),!0)}clear(){this.map.clear(),sa(this,oa,[],"f")}static fromMap(t,e){const r=new ca(e);for(const[e,n]of t)r.set(e,n);return r}forEach(t){for(const e of ua(this,oa,"f"))t(this.map.get(e),e,this)}get size(){return this.map.size}*[(oa=new WeakMap,Symbol.iterator)](){for(const t of ua(this,oa,"f"))yield[t,this.map.get(t)]}}class fa{constructor(t,e,r){this.eventType=t,this.eventDataSelector=e,this.eventData=r}}class la{constructor(t){this.currentOffset=0,this.buffer=new DataView(t.buffer)}static stringCompare(t,e){return t.localeCompare(e)}static bigintCompare(t,e){return t<e?-1:t>e?1:0}static numberCompare(t,e){return t<e?-1:t>e?1:0}setBuffer(t){this.buffer=new DataView(t.buffer),this.currentOffset=0}readEvents(){const t=[],e=this.readU16();if(e>1e3)throw new Error("Too many events to decode.");for(let r=0;r<e;r++){const e=this.readEvent();t.push(e)}return t}readAddressArray(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readAddress();return e}readU256Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU256();return e}readU64Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU64();return e}readU32Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU32();return e}readU16Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU16();return e}readU8Array(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readU8();return e}readStringArray(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readStringWithLength();return e}readBytesArray(){const t=this.readU16(),e=new Array(t);for(let r=0;r<t;r++)e[r]=this.readBytesWithLength();return e}readEvent(){const t=this.readStringWithLength(),e=this.readU64(),r=this.readBytesWithLength(352);return new fa(t,e,r)}readBytesWithLength(t=0){const e=this.readU32();if(t>0&&e>t)throw new Error("Data length exceeds maximum length.");return this.readBytes(e)}readABISelector(){return{name:this.readStringWithLength(),selector:this.readSelector()}}readViewSelectorsMap(){const t=new ca(((t,e)=>la.stringCompare(t,e))),e=this.readU16();for(let r=0;r<e;r++){const e=this.readStringWithLength(),r=this.readSelector();t.set(e,r)}return t}readMethodSelectorsMap(){const t=new ia(((t,e)=>la.numberCompare(t,e))),e=this.readU16();for(let r=0;r<e;r++)t.add(this.readSelector());return t}readMethodSelectors(){const t=new ia(((t,e)=>la.numberCompare(t,e))),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(){this.verifyEnd(this.currentOffset+8);const t=this.buffer.getBigUint64(this.currentOffset,!0);return this.currentOffset+=8,t}readMultiBytesAddressMap(){const t=new Map,e=this.readU8();if(e>8)throw new Error("Too many contract called.");for(let r=0;r<e;r++){const e=this.readAddress(),r=this.readU8();if(r>10)throw new Error("Too many calls.");const n=[];for(let t=0;t<r;t++){const t=this.readBytesWithLength();n.push(t)}t.set(e,n)}return t}readAddressValueTuple(){const t=this.readU16(),e=new Map;for(let r=0;r<t;r++){const t=this.readAddress(),r=this.readU256();if(e.has(t))throw new Error("Duplicate address found in map");e.set(t,r)}return e}readStorage(){const t=this.readU32(),e=new ca(((t,e)=>la.stringCompare(t,e)));for(let r=0;r<t;r++){const t=this.readAddress(),r=this.readU32(),n=new ca(((t,e)=>la.bigintCompare(t,e)));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);for(let n=0;n<t;n++){const t=this.readU8();if(e&&0===t){r=r.slice(0,n);break}r[n]=t}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()}readAddress(){return this.readString(66)}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")}}!function(t){t[t.U8=0]="U8",t[t.U16=1]="U16",t[t.U32=2]="U32",t[t.U64=3]="U64",t[t.U256=4]="U256",t[t.ADDRESS=5]="ADDRESS",t[t.STRING=6]="STRING",t[t.BOOLEAN=7]="BOOLEAN"}(aa||(aa={}));class ha{constructor(t=0,e=!1){this.trackDataTypes=e,this.currentOffset=0,this.selectorDatatype=[],this.buffer=this.getDefaultBuffer(t)}writeU8(t){if(t>255)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(aa.U8),this.allocSafe(1),this.buffer.setUint8(this.currentOffset++,t)}writeU16(t){if(t>65535)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(aa.U16),this.allocSafe(2),this.buffer.setUint16(this.currentOffset,t,!0),this.currentOffset+=2}writeU32(t,e=!0){if(t>4294967295)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(aa.U32),this.allocSafe(4),this.buffer.setUint32(this.currentOffset,t,e),this.currentOffset+=4}writeU64(t){if(t>18446744073709551615n)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(aa.U64),this.allocSafe(8),this.buffer.setBigUint64(this.currentOffset,t,!0),this.currentOffset+=8}writeSelector(t){this.writeU32(t,!1)}writeBoolean(t){this.trackDataTypes&&this.selectorDatatype.push(aa.BOOLEAN),this.writeU8(t?1:0)}writeU256(t){if(t>115792089237316195423570985008687907853269984665640564039457584007913129639935n)throw new Error("Value is too large.");this.trackDataTypes&&this.selectorDatatype.push(aa.U256),this.allocSafe(32);const e=ra.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){this.allocSafe(t.byteLength);for(let e=0;e<t.byteLength;e++)this.writeU8(t[e])}writeString(t){this.trackDataTypes&&this.selectorDatatype.push(aa.STRING),this.allocSafe(t.length);for(let e=0;e<t.length;e++)this.writeU8(t.charCodeAt(e))}writeAddress(t){this.trackDataTypes&&this.selectorDatatype.push(aa.ADDRESS);const e=this.fromAddress(t);this.writeBytes(e)}writeStringWithLength(t){this.allocSafe(t.length+2),this.writeU16(t.length),this.writeString(t)}getBuffer(t=!0){const e=new Uint8Array(this.buffer.byteLength);for(let t=0;t<this.buffer.byteLength;t++)e[t]=this.buffer.getUint8(t);return t&&this.clear(),e}reset(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(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.allocSafe(4+32*t.length),this.writeU32(t.length);for(let e=0;e<t.length;e++)this.writeU256(t[e])}toBytesReader(){return new la(this.getBuffer())}getOffset(){return this.currentOffset}setOffset(t){this.currentOffset=t}clear(){this.currentOffset=0,this.buffer=this.getDefaultBuffer(),this.selectorDatatype=[]}allocSafe(t){this.currentOffset+t>this.buffer.byteLength&&this.resize(t)}writeABISelector(t,e){this.writeStringWithLength(t),this.writeSelector(e)}getSelectorDataType(){return 0===this.selectorDatatype.length?0n:function(t,e=0){let r=BigInt(3735928559^e),n=BigInt(1103547991^e);for(let e,i=0;i<t.length;i++)e=BigInt(t[i]),r=na(r^e,0x85ebca77n),n=na(n^e,0xc2b2ae3dn);return r^=na(r^n>>15n,0x735a2d97n),n^=na(n^r>>15n,0xcaf649a9n),r^=n>>16n,n^=r>>16n,2097152n*(0xffffffffffffffffn&n)+(r>>11n)&0xffffffffffffffffn}(this.selectorDatatype)}writeAddressValueTupleMap(t){if(t.size>65535)throw new Error("Map size is too large");this.writeU16(t.size);const e=Array.from(t.keys());for(let r=0;r<e.length;r++){const n=e[r],i=t.get(n);if(null==i)throw new Error("Value not found");this.writeAddress(n),this.writeU256(i)}}writeLimitedAddressBytesMap(t){if(t.size>8)throw new Error("Too many contract calls");this.writeU8(t.size);const e=Array.from(t.keys());for(let r=0;r<e.length;r++){const n=e[r],i=t.get(n);if(!i)throw new Error("Calls not found");if(i.length>10)throw new Error("Too many calls.");this.writeAddress(n),this.writeU8(i.length);for(let t=0;t<i.length;t++)this.writeBytesWithLength(i[t])}}writeBytesWithLength(t){this.writeU32(t.length),this.writeBytes(t)}writeAddressArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeAddress(t[e])}writeU32Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU32(t[e])}writeU256Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU256(t[e])}writeStringArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeStringWithLength(t[e])}writeU16Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU16(t[e])}writeU8Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU8(t[e])}writeU64Array(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeU64(t[e])}writeBytesArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeBytesWithLength(t[e])}writeSelectorArray(t){if(t.length>65535)throw new Error("Array size is too large");this.writeU16(t.length);for(let e=0;e<t.length;e++)this.writeSelector(t[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)}))}fromAddress(t){if(t.length>66)throw new Error("Address is too long");const e=new Uint8Array(Math.min(t.length+1,66));for(let r=0;r<t.length;r++)e[r]=t.charCodeAt(r);return t.length<66&&(e[t.length]=0),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)}getDefaultBuffer(t=0){return new DataView(new ArrayBuffer(t))}}var pa,da=i(2802),ya=i(8287).Buffer;!function(t){t.UINT8="UINT8",t.UINT16="UINT16",t.UINT32="UINT32",t.UINT64="UINT64",t.BOOL="BOOL",t.ADDRESS="ADDRESS",t.STRING="STRING",t.BYTES32="BYTES32",t.UINT256="UINT256",t.TUPLE="TUPLE",t.BYTES="BYTES",t.ADDRESS_UINT256_TUPLE="ADDRESS_UINT256_TUPLE",t.ARRAY_OF_ADDRESSES="ARRAY_OF_ADDRESSES",t.ARRAY_OF_UINT256="ARRAY_OF_UINT256",t.ARRAY_OF_UINT64="ARRAY_OF_UINT64",t.ARRAY_OF_UINT32="ARRAY_OF_UINT32",t.ARRAY_OF_UINT16="ARRAY_OF_UINT16",t.ARRAY_OF_UINT8="ARRAY_OF_UINT8",t.ARRAY_OF_STRING="ARRAY_OF_STRING",t.ARRAY_OF_BYTES="ARRAY_OF_BYTES"}(pa||(pa={}));class ba{decodeData(t,e){const r=new la(t),n=[];for(let t=0;t<e.length;t++)switch(e[t]){case pa.UINT8:n.push(r.readU8());break;case pa.UINT16:n.push(r.readU16());break;case pa.UINT32:n.push(r.readU32());break;case pa.BYTES32:n.push(r.readBytes(32));break;case pa.BOOL:n.push(r.readBoolean());break;case pa.ADDRESS:n.push(r.readAddress());break;case pa.STRING:n.push(r.readStringWithLength());break;case pa.UINT256:n.push(r.readU256());break;case pa.TUPLE:n.push(r.readTuple());break;case pa.ADDRESS_UINT256_TUPLE:n.push(r.readAddressValueTuple());break;case pa.BYTES:n.push(r.readBytesWithLength());break;case pa.UINT64:n.push(r.readU64());break;case pa.ARRAY_OF_ADDRESSES:n.push(r.readAddressArray());break;case pa.ARRAY_OF_UINT256:n.push(r.readU256Array());break;case pa.ARRAY_OF_UINT64:n.push(r.readU64Array());break;case pa.ARRAY_OF_UINT32:n.push(r.readU32Array());break;case pa.ARRAY_OF_UINT16:n.push(r.readU16Array());break;case pa.ARRAY_OF_UINT8:n.push(r.readU8Array());break;case pa.ARRAY_OF_STRING:n.push(r.readStringArray());break;case pa.ARRAY_OF_BYTES:n.push(r.readBytesArray())}return n}encodePointer(t){const e=this.sha256(t),r=ya.alloc(ra.EXPECTED_BUFFER_LENGTH),n=e.subarray(0,ra.EXPECTED_BUFFER_LENGTH);for(let t=0;t<ra.EXPECTED_BUFFER_LENGTH;t++)r[t]=n[t];return BigInt("0x"+r.toString("hex"))}encodePointerHash(t,e){const r=new Uint8Array(ra.EXPECTED_BUFFER_LENGTH+2);r[0]=255&t,r[1]=t>>8&255;const n=this.bigIntToUint8Array(e,ra.EXPECTED_BUFFER_LENGTH);r.set(n,2);const i=this.sha256(r);if(i.byteLength!==ra.EXPECTED_BUFFER_LENGTH)throw new Error("Invalid hash length");return i}encodeSelector(t){return this.sha256(t).subarray(0,4).toString("hex")}numericSelectorToHex(t){return t.toString(16)}bigIntToUint8Array(t,e){const r=new Uint8Array(e),n=ra.valueToUint8Array(t);for(let t=0;t<e;t++)r[t]=n[t]||0;return r}sha256(t){return(new da.sha256).update(t).digest()}}function ga(t){return ga="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},ga(t)}function wa(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 va(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?wa(Object(r),!0).forEach((function(e){Oa(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):wa(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function ma(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 _a(t,e);var r={}.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)?_a(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function _a(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ea(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,xa(n.key),n)}}function Sa(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Sa=function(){return!!t})()}function ka(t){return ka=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ka(t)}function Ta(t,e){return Ta=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ta(t,e)}function Oa(t,e,r){return(e=xa(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function xa(t){var e=function(t){if("object"!=ga(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ga(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ga(e)?e:e+""}var Aa=function(){function t(e){var r;return function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Oa(r=function(t,e,r){return e=ka(e),function(t,e){if(e&&("object"==ga(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,Sa()?Reflect.construct(e,r||[],ka(t).constructor):e.apply(t,r))}(this,t,[e]),"logColor","#00ffe1"),Oa(r,"feesAddition",10000n),Oa(r,"sighashTypes",[]),r.signer=e.signer,r.network=e.network,r.transaction=e.psbt,r.ignoreSignatureError(),r.tweakSigner(),r.internalInit(),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&&Ta(t,e)}(t,Gr),function(t,e,r){return e&&Ea(t.prototype,e),r&&Ea(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"extractTransaction",value:function(){return this.transaction.extractTransaction()}},{key:"final",value:function(){return this.extractTransaction().toHex()}},{key:"toHex",value:function(){return this.transaction.toHex()}},{key:"addInput",value:function(t){var e=arguments.length>1&&void 0!==arguments[1]&&arguments[1];this.transaction.addInput(t,e)}},{key:"addOutput",value:function(t){t.value&&this.transaction.addOutput(t)}},{key:"attemptFinalizeInputs",value:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:1;try{for(var e=this.transaction.data.inputs,r=t;r<e.length;r++){var n=e[r];n.finalScriptWitness?this.transaction.finalizeTaprootInput(r,n.finalScriptWitness):this.transaction.finalizeInput(r)}return!0}catch(t){return this.warn(t.stack||"Couldn't finalize inputs"),!1}}},{key:"getPSBT",value:function(){return this.transaction}},{key:"getTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=ma(t);try{for(n.s();!(e=n.n()).done;){var i,o=ma(e.value.utxos);try{for(o.s();!(i=o.n()).done;){var a=i.value;r+=BigInt(a.value)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}return r}}],[{key:"fromBase64",value:function(e,r){var n=d.iL.fromBase64(e,{network:r.network});return new t(va(va({},r),{},{psbt:n}))}},{key:"fromHex",value:function(e,r){var n=d.iL.fromHex(e,{network:r.network});return new t(va(va({},r),{},{psbt:n}))}},{key:"from",value:function(e){var r=new d.iL({network:e.network});return new t(va(va({},e),{},{psbt:r}))}}])}(),Pa=i(8287).Buffer;function Ia(t){return Ia="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},Ia(t)}function Ra(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 La(t,e);var r={}.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)?La(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function La(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Ba(){Ba=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Ia(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Ia(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Ua(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Na(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Ua(o,n,i,a,s,"next",t)}function s(t){Ua(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ja(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,Ha(n.key),n)}}function Ca(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Ca=function(){return!!t})()}function Fa(t){return Fa=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Fa(t)}function Ma(t,e){return Ma=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ma(t,e)}function Da(t,e,r){return(e=Ha(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ha(t){var e=function(t){if("object"!=Ia(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ia(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ia(e)?e:e+""}var Ka=new ba,Wa=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.amount<sn.MINIMUM_DUST)throw new Error("Amount is below dust limit");return e.disableAutoRefund=!0,e.calldata=t.generateBurnCalldata(e.amount),Da(r=function(t,e,r){return e=Fa(e),function(t,e){if(e&&("object"==Ia(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,Ca()?Reflect.construct(e,r||[],Fa(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.WBTC_UNWRAP),Da(r,"sighashTypes",[]),Da(r,"calculatedSignHash",Aa.calculateSignHash(r.sighashTypes)),r.wbtc=new Qn(e.network,e.chainId),r.to=r.wbtc.getAddress(),r.vaultUTXOs=e.unwrapUTXOs,r.amount=e.amount,r.contractSecret=r.generateSecret(),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&Ma(t,e)}(t,So),function(t,e,r){return e&&ja(t.prototype,e),r&&ja(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"signPSBT",value:(i=Na(Ba().mark((function t(){return Ba().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.to||kt.verifyContractAddress(this.to,this.network)){t.next=2;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 2:if(this.vaultUTXOs.length){t.next=4;break}throw new Error("No vault UTXOs provided");case 4:if(!this.signed){t.next=6;break}throw new Error("Transaction is already signed");case 6:return this.signed=!0,t.next=9,this.buildTransaction();case 9:return this.ignoreSignatureError(),t.next=12,this.mergeVaults(this.vaultUTXOs);case 12:return t.next=14,this.internalBuildTransaction(this.transaction);case 14:if(!t.sent){t.next=17;break}return t.abrupt("return",this.transaction);case 17:throw new Error("Could not sign transaction");case 18:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"mergeVaults",value:(n=Na(Ba().mark((function t(e){var r,n,i,o,a,s;return Ba().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=e[0]){t.next=3;break}throw new Error("No vaults provided");case 3:if(!((n=this.getVaultTotalOutputAmount(e))<this.amount)){t.next=6;break}throw new Error("Total vault amount (".concat(n," sat) is less than the amount to unwrap (").concat(this.amount," sat)"));case 6:if(!((i=this.calculateOutputLeftAmountFromVaults(e))<oi.VAULT_MINIMUM_AMOUNT&&i!==oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT)){t.next=9;break}throw new Error("Output left amount is below minimum consolidation (".concat(oi.VAULT_MINIMUM_AMOUNT," sat) amount ").concat(i," for vault ").concat(r.vault));case 9:this.addOutput({address:r.vault,value:Number(i)}),this.addOutput({address:this.from,value:Number(this.amount)}),o=Ra(e),t.prev=12,o.s();case 14:if((a=o.n()).done){t.next=20;break}return s=a.value,t.next=18,this.addVaultInputs(s);case 18:t.next=14;break;case 20:t.next=25;break;case 22:t.prev=22,t.t0=t.catch(12),o.e(t.t0);case 25:return t.prev=25,o.f(),t.finish(25);case 28:case"end":return t.stop()}}),t,this,[[12,22,25,28]])}))),function(t){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=Na(Ba().mark((function t(e){var r,n,i,o,a,s=arguments;return Ba().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.next=5,this.signInputs(e);case 5:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 9:t.prev=9,t.t0=t.catch(2),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 13:return t.abrupt("return",!1);case 14:case"end":return t.stop()}}),t,this,[[2,9]])}))),function(t){return r.apply(this,arguments)})},{key:"generateMultiSignRedeemScript",value:function(t,e){var r,n=d.KT.p2ms({m:e,pubkeys:t.map((function(t){return Pa.from(t,"base64")})),network:this.network}),i=d.KT.p2wsh({redeem:n,network:this.network}),o=i.output,a=null===(r=i.redeem)||void 0===r?void 0:r.output,s=n.output;if(!o||!a||!s)throw new Error("Failed to generate redeem script");return{witnessUtxo:o,redeemScript:a,witnessScript:s}}},{key:"addVaultUTXO",value:function(t,e){var r={hash:t.hash,index:t.outputIndex,witnessUtxo:{script:Pa.from(t.output,"base64"),value:Number(t.value)},witnessScript:e.witnessScript,sequence:this.sequence};this.calculatedSignHash&&(r.sighashType=this.calculatedSignHash),this.addInput(r)}},{key:"addVaultInputs",value:(e=Na(Ba().mark((function t(e){var r,n,i,o,a,s,u=arguments;return Ba().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=u.length>1&&void 0!==u[1]?u[1]:this.signer,n=this.generateMultiSignRedeemScript(e.publicKeys,e.minimum),i=Ra(e.utxos),t.prev=3,i.s();case 5:if((o=i.n()).done){t.next=21;break}if(a=o.value,s=this.transaction.inputCount,this.addVaultUTXO(a,n),!r){t.next=19;break}return t.prev=10,t.next=13,this.signInput(this.transaction,this.transaction.data.inputs[s],s,this.signer);case 13:this.log("Signed input ".concat(s," with ").concat(r.publicKey.toString("hex"))),t.next=19;break;case 16:t.prev=16,t.t0=t.catch(10),this.ignoreSignatureErrors||this.warn("Failed to sign input ".concat(s," with ").concat(r.publicKey.toString("hex")," ").concat(t.t0.message));case 19:t.next=5;break;case 21:t.next=26;break;case 23:t.prev=23,t.t1=t.catch(3),i.e(t.t1);case 26:return t.prev=26,i.f(),t.finish(26);case 29:case"end":return t.stop()}}),t,this,[[3,23,26,29],[10,16]])}))),function(t){return e.apply(this,arguments)})},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getVaultTotalOutputAmount(t)-this.amount}},{key:"getVaultTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=Ra(t);try{for(n.s();!(e=n.n()).done;){var i,o=Ra(e.value.utxos);try{for(o.s();!(i=o.n()).done;){var a=i.value;r+=BigInt(a.value)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}return r}}],[{key:"generateBurnCalldata",value:function(e){if(!e)throw new Error("Amount is required");var r=new ha;return r.writeSelector(t.UNWRAP_SELECTOR),r.writeU256(e),Pa.from(r.getBuffer())}}]);var e,r,n,i}();Da(Wa,"UNWRAP_SELECTOR",Number("0x"+Ka.encodeSelector("burn")));var Ga=i(8287).Buffer;function Va(t){return Va="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},Va(t)}function za(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 qa(t,e);var r={}.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)?qa(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function qa(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Xa(){Xa=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Va(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Va(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function $a(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ya(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){$a(o,n,i,a,s,"next",t)}function s(t){$a(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Za(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 Ja(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Za(Object(r),!0).forEach((function(e){ns(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Za(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Qa(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,is(n.key),n)}}function ts(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ts=function(){return!!t})()}function es(t){return es=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},es(t)}function rs(t,e){return rs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},rs(t,e)}function ns(t,e,r){return(e=is(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function is(t){var e=function(t){if("object"!=Va(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Va(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Va(e)?e:e+""}var os=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),!e.refundVault)throw new Error("Refund vault is required");if(!e.requestedAmount)throw new Error("Requested amount is required");if(!e.receiver)throw new Error("Receiver is required");if(ns(r=function(t,e,r){return e=es(e),function(t,e){if(e&&("object"==Va(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,ts()?Reflect.construct(e,r||[],es(t).constructor):e.apply(t,r))}(this,t,[Ja(Ja({},e),{},{signer:kt.fromPrivateKey(d.Et.sha256(Ga.from("aaaaaaaa","utf-8"))),priorityFee:0n})]),"type",ri.MULTI_SIG),ns(r,"targetScriptRedeem",null),ns(r,"leftOverFundsScriptRedeem",null),ns(r,"originalInputCount",0),ns(r,"sighashTypes",t.signHashTypesArray),ns(r,"customFinalizer",(function(t,e){if(!r.tapLeafScript)throw new Error("Tap leaf script is required");var n=r.getScriptSolution(e).concat(r.tapLeafScript.script).concat(r.tapLeafScript.controlBlock);return{finalScriptWitness:sn.witnessStackToScriptWitness(n)}})),!e.pubkeys)throw new Error("Pubkeys are required");return e.psbt&&(r.log("Using provided PSBT."),r.transaction=e.psbt,r.originalInputCount=r.transaction.data.inputs.length),r.refundVault=e.refundVault,r.requestedAmount=e.requestedAmount,r.receiver=e.receiver,r.publicKeys=e.pubkeys,r.minimumSignatures=e.minimumSignatures,r.compiledTargetScript=oe.compile(e.pubkeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&rs(t,e)}(t,sn),function(t,e,r){return e&&Qa(t.prototype,e),r&&Qa(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"finalizeTransactionInputs",value:function(){var t=!1;try{for(var e=this.originalInputCount;e<this.transaction.data.inputs.length;e++)this.transaction.finalizeInput(e,this.customFinalizer.bind(this));t=!0}catch(t){this.error("Error finalizing transaction inputs: ".concat(t.stack))}return t}},{key:"signPSBT",value:(i=Ya(Xa().mark((function t(){return Xa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTransaction();case 2:if(!t.sent){t.next=4;break}return t.abrupt("return",this.transaction);case 4:throw new Error("Could not sign transaction");case 5:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"buildTransaction",value:(n=Ya(Xa().mark((function t(){var e,r;return Xa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=this.targetScriptRedeem){t.next=3;break}throw new Error("Left over funds script redeem is required");case 3:if(e.redeemVersion){t.next=5;break}throw new Error("Left over funds script redeem version is required");case 5:if(e.output){t.next=7;break}throw new Error("Left over funds script redeem output is required");case 7:if(this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),!((r=this.calculateOutputLeftAmountFromVaults(this.utxos))<0)){t.next=12;break}throw new Error("Output value left is negative ".concat(r,"."));case 12:this.addOutput({address:this.refundVault,value:Number(r)}),this.addOutput({address:this.receiver,value:Number(this.requestedAmount)});case 14:case"end":return t.stop()}}),t,this)}))),function(){return n.apply(this,arguments)})},{key:"internalBuildTransaction",value:(r=Ya(Xa().mark((function t(e){var r,n,i,o,a,s=arguments;return Xa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:for(r=s.length>1&&void 0!==s[1]&&s[1],n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);return e.addOutputs(i),t.prev=7,t.next=10,this.signInputs(e);case 10:return t.abrupt("return",this.finalizeTransactionInputs());case 13:t.prev=13,t.t0=t.catch(7),a=t.t0,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 17:return t.abrupt("return",!1);case 18:case"end":return t.stop()}}),t,this,[[7,13]])}))),function(t){return r.apply(this,arguments)})},{key:"signInputs",value:(e=Ya(Xa().mark((function t(e){return Xa().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:case"end":return t.stop()}}),t)}))),function(t){return e.apply(this,arguments)})},{key:"generateScriptAddress",value:function(){return{internalPubkey:(0,y.toXOnly)(t.numsPoint),network:this.network,scriptTree:this.scriptTree}}},{key:"generateTapData",value:function(){var e=this.targetScriptRedeem;if(!e)throw new Error("Left over funds script redeem is required");if(!this.scriptTree)throw new Error("Script tree is required");return{internalPubkey:(0,y.toXOnly)(t.numsPoint),network:this.network,scriptTree:this.scriptTree,redeem:e}}},{key:"getScriptSolution",value:function(t){return t.tapScriptSig?t.tapScriptSig.map((function(t){return t.signature})):[]}},{key:"getScriptTree",value:function(){return this.generateRedeemScripts(),[{output:this.compiledTargetScript,version:192},{output:t.LOCK_LEAF_SCRIPT,version:192}]}},{key:"getTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=za(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.value)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getTotalOutputAmount(t)-this.requestedAmount}},{key:"generateRedeemScripts",value:function(){this.targetScriptRedeem={output:this.compiledTargetScript,redeemVersion:192},this.leftOverFundsScriptRedeem={output:t.LOCK_LEAF_SCRIPT,redeemVersion:192}}}],[{key:"fromBase64",value:function(e){var r=d.iL.fromBase64(e.psbt,{network:e.network});return new t(Ja(Ja({},e),{},{psbt:r}))}},{key:"verifyIfSigned",value:function(t,e){for(var r=!1,n=1;n<t.data.inputs.length;n++){var i=t.data.inputs[n];if(i.finalScriptWitness){var o=sn.readScriptWitnessToWitnessStack(i.finalScriptWitness);if(!(o.length<3))for(var a=0;a<o.length-2;a+=3)if(o[a+2].equals(e)){r=!0;break}}}return r}},{key:"signPartial",value:function(e,r,n,i){for(var o=!1,a=!0,s=n;s<e.data.inputs.length;s++){var u=e.data.inputs[s];u.tapInternalKey||(u.tapInternalKey=(0,y.toXOnly)(t.numsPoint));var c=[];if(u.finalScriptWitness){var f=sn.readScriptWitnessToWitnessStack(u.finalScriptWitness);u.tapLeafScript=[{leafVersion:192,script:f[f.length-2],controlBlock:f[f.length-1]}];for(var l=0;l<f.length-2;l+=3)c.push({signature:f[l],leafHash:f[l+1],pubkey:f[l+2]});u.tapScriptSig=(u.tapScriptSig||[]).concat(c)}delete u.finalScriptWitness;var h=t.signHashTypesArray?[t.calculateSignHash(t.signHashTypesArray)]:[];try{t.signInput(e,u,s,r,h),o=!0}catch(t){console.log(t)}if(o){if(!u.tapScriptSig)throw new Error("No new signatures for input");u.tapScriptSig.length!==i[s-n]&&(a=!1)}}return{signed:o,final:!!o&&a}}},{key:"dedupeSignatures",value:function(t,e){var r,n=new Map,i=za(t);try{for(i.s();!(r=i.n()).done;){var o=r.value;n.set(o.pubkey.toString("hex"),o)}}catch(t){i.e(t)}finally{i.f()}var a,s=za(e);try{for(s.s();!(a=s.n()).done;){var u=a.value;n.has(u.pubkey.toString("hex"))||n.set(u.pubkey.toString("hex"),u)}}catch(t){s.e(t)}finally{s.f()}return Array.from(n.values())}},{key:"attemptFinalizeInputs",value:function(e,r,n,i){for(var o=0,a=function(a){try{var s=e.data.inputs[a];s.tapInternalKey||(s.tapInternalKey=(0,y.toXOnly)(t.numsPoint));var u=[];if(s.finalScriptWitness){for(var c=sn.readScriptWitnessToWitnessStack(s.finalScriptWitness),f=0;f<c.length-2;f+=3)u.push({signature:c[f],leafHash:c[f+1],pubkey:c[f+2]});s.tapLeafScript=[{leafVersion:192,script:c[c.length-2],controlBlock:c[c.length-1]}],s.tapScriptSig=t.dedupeSignatures(s.tapScriptSig||[],u)}delete s.finalScriptWitness,e.finalizeInput(a,(function(e,o){return t.partialFinalizer(e,o,[],n[a-r],i)})),o++}catch(t){}},s=r;s<e.data.inputs.length;s++)a(s);return o===e.data.inputs.length-r}}]);var e,r,n,i}();ns(os,"LOCK_LEAF_SCRIPT",d.K$.compile([d.Ez.OP_XOR,d.Ez.OP_NOP,d.Ez.OP_CODESEPARATOR])),ns(os,"signHashTypesArray",[]),ns(os,"numsPoint",Ga.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex")),ns(os,"partialFinalizer",(function(t,e,r,n,i){if(!e.tapLeafScript||!e.tapLeafScript[0].script||!e.tapLeafScript[0].controlBlock)throw new Error("Tap leaf script is required");if(!e.tapScriptSig)throw new Error("No new signatures for input ".concat(t,"."));var o=[];if(i){var a,s=za(n);try{for(s.s();!(a=s.n()).done;){var u,c=a.value,f=!1,l=za(e.tapScriptSig);try{for(l.s();!(u=l.n()).done;){var h=u.value;h.pubkey.equals((0,y.toXOnly)(c))&&(o.push(h.signature),f=!0)}}catch(t){l.e(t)}finally{l.f()}f||o.push(Ga.alloc(0))}}catch(t){s.e(t)}finally{s.f()}o=o.reverse()}else o=e.tapScriptSig.map((function(t){return[t.signature,t.leafHash,t.pubkey]})).flat();r.length>0&&(o=o.concat(r));var p=o.concat(e.tapLeafScript[0].script).concat(e.tapLeafScript[0].controlBlock);return{finalScriptWitness:sn.witnessStackToScriptWitness(p)}}));var as=i(8287).Buffer;function ss(t){return ss="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},ss(t)}function us(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 cs(t,e);var r={}.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)?cs(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function cs(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function fs(){fs=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==ss(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(ss(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function ls(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function hs(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ls(o,n,i,a,s,"next",t)}function s(t){ls(o,n,i,a,s,"throw",t)}a(void 0)}))}}function ps(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,ws(n.key),n)}}function ds(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(ds=function(){return!!t})()}function ys(t){return ys=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},ys(t)}function bs(t,e){return bs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},bs(t,e)}function gs(t,e,r){return(e=ws(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function ws(t){var e=function(t){if("object"!=ss(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=ss(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==ss(e)?e:e+""}var vs=new ba,ms=as.from("50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),_s=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.amount<sn.MINIMUM_DUST)throw new Error("Amount is below dust limit");return e.disableAutoRefund=!0,e.calldata=t.generateBurnCalldata(e.amount),gs(r=function(t,e,r){return e=ys(e),function(t,e){if(e&&("object"==ss(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,ds()?Reflect.construct(e,r||[],ys(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.WBTC_UNWRAP),gs(r,"sighashTypes",[]),gs(r,"estimatedFeeLoss",0n),gs(r,"calculatedSignHash",Aa.calculateSignHash(r.sighashTypes)),r.wbtc=new Qn(e.network,e.chainId),r.to=r.wbtc.getAddress(),r.vaultUTXOs=e.unwrapUTXOs,r.estimatedFeeLoss=t.preEstimateTaprootTransactionFees(BigInt(r.feeRate),r.calculateNumInputs(r.vaultUTXOs),2n,r.calculateNumSignatures(r.vaultUTXOs),65n,r.calculateNumEmptyWitnesses(r.vaultUTXOs)),r.amount=e.amount,r.contractSecret=r.generateSecret(),r.calldataGenerator=new Ct(as.from(r.signer.publicKey),r.scriptSignerXOnlyPubKey(),r.network),r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,[St.UNWRAP]),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&bs(t,e)}(t,So),function(t,e,r){return e&&ps(t.prototype,e),r&&ps(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"signPSBT",value:(r=hs(fs().mark((function t(){return fs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.to||kt.verifyContractAddress(this.to,this.network)){t.next=2;break}throw new Error("Invalid contract address. The contract address must be a taproot address.");case 2:if(this.vaultUTXOs.length){t.next=4;break}throw new Error("No vault UTXOs provided");case 4:return t.next=6,this.buildTransaction();case 6:return this.ignoreSignatureError(),this.mergeVaults(),t.next=10,this.internalBuildTransaction(this.transaction);case 10:if(!t.sent){t.next=13;break}return t.abrupt("return",this.transaction);case 13:throw new Error("Could not sign transaction");case 14:case"end":return t.stop()}}),t,this)}))),function(){return r.apply(this,arguments)})},{key:"getRefund",value:function(){var t,e=-oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT,r=us(this.vaultUTXOs);try{for(r.s();!(t=r.n()).done;)for(var n=t.value,i=0;i<n.utxos.length;i++)e+=oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT}catch(t){r.e(t)}finally{r.f()}return e}},{key:"getFeeLossOrRefund",value:function(){return this.getRefund()-this.estimatedFeeLoss}},{key:"mergeVaults",value:function(){var t=this.getVaultTotalOutputAmount(this.vaultUTXOs),e=this.getRefund(),r=t-e-this.amount;if(r===oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT)e+=oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT;else if(r<oi.VAULT_MINIMUM_AMOUNT)throw new Error("Output left amount is below the minimum amount: ".concat(r," below ").concat(oi.VAULT_MINIMUM_AMOUNT));var n=this.amount+e-this.estimatedFeeLoss,i=Xi.findVaultWithMostPublicKeys(this.vaultUTXOs);if(!i)throw new Error("No vaults provided");if(r>oi.VAULT_MINIMUM_AMOUNT&&r-oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT!==0n?this.success("Consolidating output with ".concat(r," sat.")):this.warn("No consolidation in this transaction."),r-oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT!==0n&&this.addOutput({address:i.vault,value:Number(r)}),n<sn.MINIMUM_DUST)throw new Error("Amount is below dust limit. The requested amount can not be unwrapped since, after fees, it is below the dust limit. Dust: ".concat(n," sat. Are your bitcoin fees too high?"));var o=100n*n/this.amount;if(o<=60n)throw new Error("For user safety, OPNet will decline this transaction since you will lose ".concat(100n-o,"% of your btc by doing this transaction due to bitcoin fees. Are your bitcoin fees too high?"));this.addOutput({address:this.from,value:Number(n)});var a,s=us(this.vaultUTXOs);try{for(s.s();!(a=s.n()).done;){var u=a.value;this.addVaultInputs(u)}}catch(t){s.e(t)}finally{s.f()}}},{key:"calculateNumEmptyWitnesses",value:function(t){var e,r=0n,n=us(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.publicKeys.length-i.minimum)*BigInt(i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateNumSignatures",value:function(t){var e,r=0n,n=us(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.minimum*i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateNumInputs",value:function(t){var e,r=0n,n=us(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"internalPubKeyToXOnly",value:function(){return(0,y.toXOnly)(ms)}},{key:"generateTapDataForInput",value:function(t,e){var r=oe.compile(t,e),n=[{output:r,version:192},{output:os.LOCK_LEAF_SCRIPT,version:192}],i={output:r,redeemVersion:192};return{internalPubkey:this.internalPubKeyToXOnly(),network:this.network,scriptTree:n,redeem:i}}},{key:"getScriptSolution",value:function(t){if(!t.tapScriptSig)throw new Error("Tap script signature is required");return[this.contractSecret,(0,y.toXOnly)(as.from(this.signer.publicKey)),t.tapScriptSig[0].signature,t.tapScriptSig[1].signature]}},{key:"internalBuildTransaction",value:(e=hs(fs().mark((function t(e){var r,n,i,o,a,s=arguments;return fs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(r=s.length>1&&void 0!==s[1]&&s[1],0===e.data.inputs.length){for(n=this.getInputs(),i=this.getOutputs(),e.setMaximumFeeRate(this._maximumFeeRate),e.addInputs(n,r),o=0;o<this.updateInputs.length;o++)e.updateInput(o,this.updateInputs[o]);e.addOutputs(i)}return t.prev=2,t.prev=3,t.next=6,this.signInputs(e);case 6:t.next=11;break;case 8:t.prev=8,t.t0=t.catch(3),console.log(t.t0);case 11:return this.finalized&&(this.transactionFee=BigInt(e.getFee())),t.abrupt("return",!0);case 15:t.prev=15,t.t1=t.catch(2),a=t.t1,this.error("[internalBuildTransaction] Something went wrong while getting building the transaction: ".concat(a.stack));case 19:return t.abrupt("return",!1);case 20:case"end":return t.stop()}}),t,this,[[2,15],[3,8]])}))),function(t){return e.apply(this,arguments)})},{key:"addVaultUTXO",value:function(t,e,r){var n=this.generateTapDataForInput(e,r),i=d.KT.p2tr(n);if(!i.witness)throw new Error("Failed to generate taproot witness");var o=i.witness[i.witness.length-1],a={hash:t.hash,index:t.outputIndex,witnessUtxo:{script:as.from(t.output,"base64"),value:Number(t.value)},sequence:this.sequence,tapLeafScript:[{leafVersion:n.redeem.redeemVersion,script:n.redeem.output,controlBlock:o}]};this.calculatedSignHash&&(a.sighashType=this.calculatedSignHash),this.addInput(a)}},{key:"addVaultInputs",value:function(t){var e,r=t.publicKeys.map((function(t){return as.from(t,"base64")})),n=us(t.utxos);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.addVaultUTXO(i,r,t.minimum)}}catch(t){n.e(t)}finally{n.f()}}},{key:"calculateOutputLeftAmountFromVaults",value:function(t){return this.getVaultTotalOutputAmount(t)-this.amount}},{key:"getVaultTotalOutputAmount",value:function(t){var e,r=BigInt(0),n=us(t);try{for(n.s();!(e=n.n()).done;){var i,o=us(e.value.utxos);try{for(o.s();!(i=o.n()).done;){var a=i.value;r+=BigInt(a.value)}}catch(t){o.e(t)}finally{o.f()}}}catch(t){n.e(t)}finally{n.f()}return r}}],[{key:"generateBurnCalldata",value:function(e){if(!e)throw new Error("Amount is required");var r=new ha;return r.writeSelector(t.UNWRAP_SELECTOR),r.writeU256(e),as.from(r.getBuffer())}}]);var e,r}();function Es(t){return Es="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},Es(t)}function Ss(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,ks(n.key),n)}}function ks(t){var e=function(t){if("object"!=Es(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Es(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Es(e)?e:e+""}gs(_s,"UNWRAP_SELECTOR",Number("0x"+vs.encodeSelector("burn")));var Ts=function(){return function(t,e,r){return r&&Ss(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),0,[{key:"generateMultiSigAddress",value:function(t,e){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:d.o8.bitcoin;if(kt.verifyPubKeys(t,r).length!==t.length)throw new Error("Contains invalid public keys");var n=new os({network:r,utxos:[],pubkeys:t,minimumSignatures:e,feeRate:100,receiver:"a",requestedAmount:1n,refundVault:"a"}).getScriptAddress();if(!n)throw new Error("Failed to generate address");return n}}])}(),Os=i(8287).Buffer;function xs(t){return xs="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},xs(t)}function As(t){return function(t){if(Array.isArray(t))return Ps(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||function(t,e){if(t){if("string"==typeof t)return Ps(t,e);var r={}.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)?Ps(t,e):void 0}}(t)||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.")}()}function Ps(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function Is(){Is=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==xs(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(xs(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Rs(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Ls(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,Cs(n.key),n)}}function Bs(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Bs=function(){return!!t})()}function Us(t){return Us=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Us(t)}function Ns(t,e){return Ns=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Ns(t,e)}function js(t,e,r){return(e=Cs(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Cs(t){var e=function(t){if("object"!=xs(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=xs(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==xs(e)?e:e+""}var Fs,Ms=new ba,Ds=function(){function t(e){var r;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),e.amount<oi.VAULT_MINIMUM_AMOUNT)throw new Error("Amount is below the minimum required of ".concat(oi.VAULT_MINIMUM_AMOUNT," sat."));var n=e.receiver||sn.getFrom(e.from,e.signer,e.network);if(e.calldata=t.generateMintCalldata(e.amount,n,e.network),js(r=function(t,e,r){return e=Us(e),function(t,e){if(e&&("object"==xs(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,Bs()?Reflect.construct(e,r||[],Us(t).constructor):e.apply(t,r))}(this,t,[e]),"type",ri.WBTC_WRAP),js(r,"tapLeafScript",null),js(r,"interactionPubKeys",[]),js(r,"minimumSignatures",0),r.wbtc=new Qn(e.network,e.chainId),r.vault=e.generationParameters.vault,r.to=r.wbtc.getAddress(),r.receiver=n,r.amount=e.amount,r.verifyRequiredValue(),r.interactionPubKeys=e.generationParameters.pubKeys,r.minimumSignatures=e.generationParameters.constraints.minimum,r.contractSecret=r.generateSecret(),!r.verifyPublicKeysConstraints(e.generationParameters))throw new Error("Oops. Your wrapping request have been decline! It failed security checks!");return r.compiledTargetScript=r.calldataGenerator.compile(r.calldata,r.contractSecret,[],r.interactionPubKeys,r.minimumSignatures),r.scriptTree=r.getScriptTree(),r.internalInit(),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&&Ns(t,e)}(t,So),function(t,e,r){return e&&Ls(t.prototype,e),r&&Ls(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"verifyPublicKeysConstraints",value:function(t){if(t.constraints.minimum<2)throw new Error("Minimum signatures must be at least 2");if(t.keys.length<t.constraints.transactionMinimum||t.keys.length<t.constraints.minimum)throw new Error("Not enough pub keys");if(t.keys.length>255)throw new Error("Too many pub keys");var e=this.generateVaultAddress(t.pubKeys,t.constraints.minimum);if(e!==t.vault)throw new Error("Invalid vault address. Expected: ".concat(e," Got: ").concat(t.vault));var r=this.generateChecksumSalt(t,this.amount,t.vault),n=Xi.opnetHash(r);if(n!==t.signature)throw new Error("Invalid checksum. Expected: ".concat(n," Got: ").concat(t.signature));return!0}},{key:"buildTransaction",value:(e=function(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Rs(o,n,i,a,s,"next",t)}function s(t){Rs(o,n,i,a,s,"throw",t)}a(void 0)}))}}(Is().mark((function t(){var e,r;return Is().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(this.to){t.next=2;break}throw new Error("To address is required");case 2:if(e=this.scriptSigner?this.targetScriptRedeem:this.leftOverFundsScriptRedeem){t.next=5;break}throw new Error("Left over funds script redeem is required");case 5:if(e.redeemVersion){t.next=7;break}throw new Error("Left over funds script redeem version is required");case 7:if(e.output){t.next=9;break}throw new Error("Left over funds script redeem output is required");case 9:return this.tapLeafScript={leafVersion:e.redeemVersion,script:e.output,controlBlock:this.getWitness()},this.addInputsFromUTXO(),r=this.getTransactionOPNetFee(),this.addOutput({value:Number(r),address:this.to}),this.addVaultOutput(),t.next=16,this.addRefundOutput(r+this.amount+oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT);case 16:case"end":return t.stop()}}),t,this)}))),function(){return e.apply(this,arguments)})},{key:"verifyRequiredValue",value:function(){if(this.totalInputAmount<this.amount)throw new Error("Not enough funds to wrap the amount specified. ".concat(this.totalInputAmount," < ").concat(this.amount));var t=this.amount+oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT;if(this.totalInputAmount<t)throw new Error("Not enough funds to wrap the amount specified. ".concat(this.totalInputAmount," < ").concat(t,". Make sure that your inputs cover the amount to wrap, the priority fee and the unwrap prepaid fees."))}},{key:"addVaultOutput",value:function(){if(!this.vault)throw new Error("No vault address provided");var t=this.amount+oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT,e={address:this.vault,value:Number(t)};this.addOutput(e)}},{key:"generateVaultAddress",value:function(t,e){return Ts.generateMultiSigAddress(t,e,this.network)}},{key:"generateChecksumSalt",value:function(t,e,r){var n=t.constraints.version,i=t.constraints.timestamp,o=Os.alloc(12+n.length);return o.writeBigInt64BE(BigInt(i),0),o.writeInt16BE(t.constraints.minimum,8),o.writeInt16BE(t.constraints.transactionMinimum,10),o.write(n,12,n.length,"utf-8"),Os.concat([].concat(As(t.pubKeys),As(t.entities.map((function(t){return Os.from(t,"utf-8")}))),[o,Os.from(e.toString(),"utf-8"),Os.from(r,"utf-8")]))}}],[{key:"generateMintCalldata",value:function(e,r,n){if(!e)throw new Error("Amount is required");if(!r)throw new Error("To address is required");if(!ge.isValidP2TRAddress(r,n))throw new Error("Oops! The address ".concat(r," is not a valid P2TR address! If you wrap at this address, your funds will be lost!"));var i=new ha;return i.writeSelector(t.WRAP_SELECTOR),i.writeAddress(r),i.writeU256(e),Os.from(i.getBuffer())}}]);var e}();js(Ds,"WRAP_SELECTOR",Number("0x"+Ms.encodeSelector("mint"))),function(t){t[t.UNWRAP=0]="UNWRAP"}(Fs||(Fs={}));var Hs=i(8287).Buffer;function Ks(t){return Ks="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},Ks(t)}function Ws(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=Vs(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function Gs(t){return function(t){if(Array.isArray(t))return zs(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||Vs(t)||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.")}()}function Vs(t,e){if(t){if("string"==typeof t)return zs(t,e);var r={}.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)?zs(t,e):void 0}}function zs(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function qs(){qs=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Ks(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Ks(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function Xs(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 $s(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?Xs(Object(r),!0).forEach((function(e){Ys(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):Xs(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function Ys(t,e,r){return(e=tu(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Zs(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Js(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){Zs(o,n,i,a,s,"next",t)}function s(t){Zs(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Qs(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,tu(n.key),n)}}function tu(t){var e=function(t){if("object"!=Ks(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Ks(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Ks(e)?e:e+""}var eu=function(){return function(t,e){return e&&Qs(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}),[{key:"createCustomScriptTransaction",value:(s=Js(qs().mark((function t(e){var r,n,i,o,a,s,u;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:return r=new uo($s($s({},e),{},{utxos:[e.utxos[0]]})),t.next=7,r.generateTransactionMinimalSignatures();case 7:return t.next=9,r.getFundingTransactionParameters();case 9:return(n=t.sent).utxos=e.utxos,t.next=13,r.estimateTransactionFees();case 13:return t.t0=t.sent,t.t1=this.getPriorityFee(e),n.amount=t.t0+t.t1,t.next=18,this.createFundTransaction($s({},n));case 18:if(i=t.sent){t.next=21;break}throw new Error("Could not sign funding transaction.");case 21:return n.estimatedFees=i.estimatedFees,t.next=24,this.createFundTransaction(n);case 24:if(o=t.sent){t.next=27;break}throw new Error("Could not sign funding transaction.");case 27:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=$s($s({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),s=new uo(a),t.next=32,s.signTransaction();case 32:return u=t.sent,t.abrupt("return",[o.tx.toHex(),u.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 34:case"end":return t.stop()}}),t,this)}))),function(t){return s.apply(this,arguments)})},{key:"signInteraction",value:(a=Js(qs().mark((function t(e){var r,n,i,o,a,s,u;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:if(e.from){t.next=4;break}throw new Error('Field "from" not provided.');case 4:return r=new ta($s($s({},e),{},{utxos:[e.utxos[0]]})),t.next=7,r.generateTransactionMinimalSignatures();case 7:return t.next=9,r.getFundingTransactionParameters();case 9:return(n=t.sent).utxos=e.utxos,t.next=13,r.estimateTransactionFees();case 13:return t.t0=t.sent,t.t1=this.getPriorityFee(e),n.amount=t.t0+t.t1,t.next=18,this.createFundTransaction($s({},n));case 18:if(i=t.sent){t.next=21;break}throw new Error("Could not sign funding transaction.");case 21:return n.estimatedFees=i.estimatedFees,t.next=24,this.createFundTransaction(n);case 24:if(o=t.sent){t.next=27;break}throw new Error("Could not sign funding transaction.");case 27:return e.utxos=this.getUTXOAsTransaction(o.tx,e.to,0),a=$s($s({},e),{},{utxos:this.getUTXOAsTransaction(o.tx,e.to,0),randomBytes:r.getRndBytes(),nonWitnessUtxo:o.tx.toBuffer(),estimatedFees:r.estimatedFees}),s=new ta(a),t.next=32,s.signTransaction();case 32:return u=t.sent,t.abrupt("return",[o.tx.toHex(),u.toHex(),this.getUTXOAsTransaction(o.tx,e.from,1)]);case 34:case"end":return t.stop()}}),t,this)}))),function(t){return a.apply(this,arguments)})},{key:"signDeployment",value:(o=Js(qs().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return r=new Co(e),t.next=3,r.signTransaction();case 3:return t.next=5,r.getFundingTransactionParameters();case 5:return n=t.sent,t.next=8,r.estimateTransactionFees();case 8:return t.t0=t.sent,t.t1=this.getPriorityFee(e),n.amount=t.t0+t.t1,i=new qo(n),t.next=14,i.signTransaction();case 14:if(o=t.sent){t.next=17;break}throw new Error("Could not sign funding transaction.");case 17:return a=o.outs[0],s={transactionId:o.getId(),outputIndex:0,scriptPubKey:{hex:a.script.toString("hex"),address:r.getScriptAddress()},value:BigInt(a.value)},u=$s($s({},e),{},{utxos:[s],randomBytes:r.getRndBytes(),nonWitnessUtxo:o.toBuffer(),optionalOutputs:[]}),c=new Co(u),t.next=23,c.signTransaction();case 23:return f=t.sent,l=o.outs[1],h={transactionId:o.getId(),outputIndex:1,scriptPubKey:{hex:l.script.toString("hex"),address:e.from},value:BigInt(l.value)},t.abrupt("return",{transaction:[o.toHex(),f.toHex()],contractAddress:c.contractAddress,p2trAddress:c.p2trAddress,utxos:[h]});case 27:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"wrap",value:(i=Js(qs().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e.amount<oi.VAULT_MINIMUM_AMOUNT)){t.next=2;break}throw new Error("Amount is too low. Minimum consolidation is ".concat(oi.VAULT_MINIMUM_AMOUNT," sat. Received ").concat(e.amount," sat. Make sure that you cover the unwrap consolidation fees of ").concat(oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT,"sat."));case 2:return n=e.amount+oi.UNWRAP_CONSOLIDATION_PREPAID_FEES_SAT+this.getPriorityFee(e),i=new Qn(e.network,e.chainId),o=i.getAddress(),a=$s($s({},e),{},{amount:n,to:null!==(r=e.to)&&void 0!==r?r:o}),t.next=8,this.createFundTransaction(a);case 8:return s=t.sent,e.utxos=this.getUTXOAsTransaction(s.tx,o,0),u=new Ds(e),t.next=13,u.signTransaction();case 13:return t.next=15,u.getFundingTransactionParameters();case 15:return(c=t.sent).amount+=n,c.utxos=a.utxos,t.next=20,this.createFundTransaction(c);case 20:if(f=t.sent){t.next=23;break}throw new Error("Could not sign funding transaction.");case 23:return l=$s($s({},e),{},{utxos:this.getUTXOAsTransaction(f.tx,o,0),randomBytes:u.getRndBytes(),nonWitnessUtxo:f.tx.toBuffer()}),h=new Ds(l),t.next=27,h.signTransaction();case 27:return p=t.sent,t.abrupt("return",{transaction:[f.tx.toHex(),p.toHex()],vaultAddress:h.vault,amount:h.amount,receiverAddress:h.receiver,utxos:this.getUTXOAsTransaction(f.tx,e.from,1)});case 29:case"end":return t.stop()}}),t,this)}))),function(t){return i.apply(this,arguments)})},{key:"unwrapSegwit",value:(n=Js(qs().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return console.error('The "unwrap" method is deprecated. Use unwrapTap instead.'),r=new Wa(e),t.next=4,r.signTransaction();case 4:if(n=r.toAddress()){t.next=7;break}throw new Error("To address is required");case 7:return t.next=9,r.estimateTransactionFees();case 9:return i=t.sent,o=r.preEstimateTransactionFees(BigInt(e.feeRate),this.calculateNumInputs(e.unwrapUTXOs),2n,this.calculateNumSignatures(e.unwrapUTXOs),this.maxPubKeySize(e.unwrapUTXOs)),a=$s($s({},e),{},{amount:i+o,to:n}),t.next=14,this.createFundTransaction(a);case 14:return s=t.sent,e.utxos=this.getUTXOAsTransaction(s.tx,n,0),u=new Wa($s($s({},e),{},{randomBytes:r.getRndBytes()})),t.next=19,u.signTransaction();case 19:return t.next=21,u.getFundingTransactionParameters();case 21:return(c=t.sent).utxos=a.utxos,t.next=25,u.estimateTransactionFees();case 25:return t.t0=t.sent,t.t1=o,c.amount=t.t0+t.t1,t.next=30,this.createFundTransaction(c);case 30:if(f=t.sent){t.next=33;break}throw new Error("Could not sign funding transaction.");case 33:return l=$s($s({},e),{},{utxos:this.getUTXOAsTransaction(f.tx,n,0),randomBytes:u.getRndBytes(),nonWitnessUtxo:f.tx.toBuffer()}),h=new Wa(l),t.next=37,h.signPSBT();case 37:return p=t.sent,d=p.toBase64(),y=this.writePSBTHeader(Fs.UNWRAP,d),t.abrupt("return",{fundingTransaction:f.tx.toHex(),psbt:y,feeRefundOrLoss:o,utxos:[]});case 41:case"end":return t.stop()}}),t,this)}))),function(t){return n.apply(this,arguments)})},{key:"unwrap",value:(r=Js(qs().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return r=new _s(e),t.next=5,r.signTransaction();case 5:if(n=r.toAddress()){t.next=8;break}throw new Error("To address is required");case 8:return t.next=10,r.estimateTransactionFees();case 10:return i=t.sent,o=$s($s({},e),{},{amount:i,to:n}),t.next=14,this.createFundTransaction(o);case 14:return a=t.sent,e.utxos=this.getUTXOAsTransaction(a.tx,n,0),s=new _s($s($s({},e),{},{randomBytes:r.getRndBytes()})),t.next=19,s.signTransaction();case 19:return t.next=21,s.getFundingTransactionParameters();case 21:return(u=t.sent).utxos=o.utxos,t.next=25,s.estimateTransactionFees();case 25:return t.t0=t.sent,t.t1=this.getPriorityFee(e),u.amount=t.t0+t.t1,t.next=30,this.createFundTransaction(u);case 30:if(c=t.sent){t.next=33;break}throw new Error("Could not sign funding transaction.");case 33:return f=$s($s({},e),{},{utxos:this.getUTXOAsTransaction(c.tx,n,0),randomBytes:s.getRndBytes(),nonWitnessUtxo:c.tx.toBuffer()}),l=new _s(f),t.next=37,l.signPSBT();case 37:return h=t.sent,p=h.toBase64(),d=this.writePSBTHeader(Fs.UNWRAP,p),t.abrupt("return",{fundingTransaction:c.tx.toHex(),psbt:d,feeRefundOrLoss:l.getFeeLossOrRefund(),utxos:this.getUTXOAsTransaction(c.tx,e.from,1)});case 41:case"end":return t.stop()}}),t,this)}))),function(t){return r.apply(this,arguments)})},{key:"createBTCTransfer",value:(e=Js(qs().mark((function t(e){var r;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.from){t.next=2;break}throw new Error('Field "from" not provided.');case 2:return t.next=4,this.createFundTransaction(e);case 4:return r=t.sent,t.abrupt("return",{estimatedFees:r.estimatedFees,original:r.original,tx:r.tx.toHex(),nextUTXOs:this.getAllNewUTXOs(r.original,r.tx,e.from)});case 6:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"getAllNewUTXOs",value:function(t,e,r){for(var n=t.getOutputs(),i=[],o=0;o<e.outs.length;o++){var a=n[o];"address"in a&&a.address===r&&i.push.apply(i,Gs(this.getUTXOAsTransaction(e,r,o)))}return i}},{key:"createFundTransaction",value:(t=Js(qs().mark((function t(e){var r,n;return qs().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e.to){t.next=2;break}throw new Error('Field "to" not provided.');case 2:return r=new qo(e),t.next=5,r.signTransaction();case 5:if(n=t.sent){t.next=8;break}throw new Error("Could not sign funding transaction.");case 8:return t.abrupt("return",{tx:n,original:r,estimatedFees:r.estimatedFees,nextUTXOs:this.getUTXOAsTransaction(n,e.to,0)});case 9:case"end":return t.stop()}}),t,this)}))),function(e){return t.apply(this,arguments)})},{key:"calculateNumSignatures",value:function(t){var e,r=0n,n=Ws(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.minimum*i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"calculateNumInputs",value:function(t){var e,r=0n,n=Ws(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r+=BigInt(i.utxos.length)}}catch(t){n.e(t)}finally{n.f()}return r}},{key:"maxPubKeySize",value:function(t){var e,r=0,n=Ws(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;r=Math.max(r,i.publicKeys.length)}}catch(t){n.e(t)}finally{n.f()}return BigInt(r)}},{key:"writePSBTHeader",value:function(t,e){var r=Hs.from(e,"base64"),n=Hs.alloc(2);return n.writeUInt8(t,0),n.writeUInt8(ii,1),Hs.concat([n,r]).toString("hex")}},{key:"getPriorityFee",value:function(t){return t.priorityFee<sn.MINIMUM_DUST?sn.MINIMUM_DUST:t.priorityFee}},{key:"getUTXOAsTransaction",value:function(t,e,r){if(!t.outs[r])return[];var n=t.outs[r];return[{transactionId:t.getId(),outputIndex:r,scriptPubKey:{hex:n.script.toString("hex"),address:e},value:BigInt(n.value)}]}}]);var t,e,r,n,i,o,a,s}(),ru=i(8287).Buffer;function nu(t){return nu="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},nu(t)}function iu(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,au(n.key),n)}}function ou(t,e,r){return e&&iu(t.prototype,e),r&&iu(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function au(t){var e=function(t){if("object"!=nu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=nu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==nu(e)?e:e+""}var su=ou((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.constraints=e.constraints,this.entities=e.entities,this.keys=e.keys,this.signature=e.signature,this.vault=e.vault,this.pubKeys=this.keys.map((function(t){return ru.from(t,"base64")}))}));function uu(t){return uu="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},uu(t)}function cu(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,lu(n.key),n)}}function fu(t,e,r){return e&&cu(t.prototype,e),r&&cu(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function lu(t){var e=function(t){if("object"!=uu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=uu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==uu(e)?e:e+""}var hu=fu((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this.vaultUTXOs=e.vaultUTXOs,this.balance=BigInt(e.balance)}));function pu(t){return pu="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},pu(t)}function du(){du=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==pu(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(pu(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function yu(t,e){var r="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!r){if(Array.isArray(t)||(r=gu(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,a=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==r.return||r.return()}finally{if(s)throw o}}}}function bu(t){return function(t){if(Array.isArray(t))return wu(t)}(t)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(t)||gu(t)||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.")}()}function gu(t,e){if(t){if("string"==typeof t)return wu(t,e);var r={}.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)?wu(t,e):void 0}}function wu(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function vu(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function mu(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){vu(o,n,i,a,s,"next",t)}function s(t){vu(o,n,i,a,s,"throw",t)}a(void 0)}))}}function _u(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,Su(n.key),n)}}function Eu(t,e,r){return(e=Su(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Su(t){var e=function(t){if("object"!=pu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=pu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==pu(e)?e:e+""}var ku=function(){return function(t,e){return e&&_u(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}((function t(e){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),Eu(this,"utxoPath","address/utxos"),Eu(this,"rpc","json-rpc"),this.opnetAPIUrl=e}),[{key:"fetchUTXO",value:(a=mu(du().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p,d,y,b,g,w,v;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return void 0===e.usePendingUTXO&&(e.usePendingUTXO=!0),void 0===e.optimized&&(e.optimized=!0),n={method:"GET",headers:{"Content-Type":"application/json"}},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.utxoPath,"?address=").concat(e.address,"&optimize=").concat(null!==(r=e.optimized)&&void 0!==r&&r),t.next=6,fetch(i,n);case 6:if((o=t.sent).ok){t.next=9;break}throw new Error("Failed to fetch UTXO data: ".concat(o.statusText));case 9:return t.next=11,o.json();case 11:a=t.sent,s=e.usePendingUTXO?[].concat(bu(a.confirmed),bu(a.pending)):a.confirmed,u=[],c=yu(s),t.prev=15,l=du().mark((function t(){var e;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(e=f.value,!a.spentTransactions.some((function(t){return t.transactionId===e.transactionId&&t.outputIndex===e.outputIndex}))){t.next=3;break}return t.abrupt("return",1);case 3:u.push(e);case 4:case"end":return t.stop()}}),t)})),c.s();case 18:if((f=c.n()).done){t.next=24;break}return t.delegateYield(l(),"t0",20);case 20:if(!t.t0){t.next=22;break}return t.abrupt("continue",22);case 22:t.next=18;break;case 24:t.next=29;break;case 26:t.prev=26,t.t1=t.catch(15),c.e(t.t1);case 29:return t.prev=29,c.f(),t.finish(29);case 32:if(0!==u.length){t.next=34;break}throw new Error("No UTXO found");case 34:if(h=u.filter((function(t){return BigInt(t.value)>=e.minAmount})),0!==h.length){t.next=37;break}throw new Error("No UTXO found (minAmount)");case 37:p=[],d=0n,y=e.requestedAmount,b=yu(h),t.prev=41,b.s();case 43:if((g=b.n()).done){t.next=54;break}if(w=g.value,!((v=BigInt(w.value))<=0n)){t.next=48;break}return t.abrupt("continue",52);case 48:if(d+=v,p.push({transactionId:w.transactionId,outputIndex:w.outputIndex,value:v,scriptPubKey:w.scriptPubKey}),!(d>y)){t.next=52;break}return t.abrupt("break",54);case 52:t.next=43;break;case 54:t.next=59;break;case 56:t.prev=56,t.t2=t.catch(41),b.e(t.t2);case 59:return t.prev=59,b.f(),t.finish(59);case 62:return t.abrupt("return",p);case 63:case"end":return t.stop()}}),t,this,[[15,26,29,32],[41,56,59,62]])}))),function(t){return a.apply(this,arguments)})},{key:"fetchUTXOMultiAddr",value:(o=mu(du().mark((function t(e){var r,n,i,o,a,s,u,c,f,l,h,p;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=[],n=yu(e.addresses);try{for(n.s();!(i=n.n()).done;)o=i.value,a={address:o,minAmount:e.minAmount,requestedAmount:e.requestedAmount,optimized:e.optimized,usePendingUTXO:e.usePendingUTXO},s=this.fetchUTXO(a).catch((function(){return[]})),r.push(s)}catch(t){n.e(t)}finally{n.f()}return t.next=5,Promise.all(r);case 5:u=t.sent,c=u.flat(),f=[],l=0n,h=0;case 10:if(!(h<c.length)){t.next=19;break}if(p=c[h],!(l>=e.requestedAmount)){t.next=14;break}return t.abrupt("break",19);case 14:l+=p.value,f.push(p);case 16:h++,t.next=10;break;case 19:return t.abrupt("return",f);case 20:case"end":return t.stop()}}),t,this)}))),function(t){return o.apply(this,arguments)})},{key:"broadcastTransaction",value:(i=mu(du().mark((function t(e,r){var n,i;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[e,r],t.next=3,this.rpcMethod("btc_sendRawTransaction",n);case 3:if(i=t.sent){t.next=6;break}return t.abrupt("return");case 6:return t.abrupt("return",i);case 7:case"end":return t.stop()}}),t,this)}))),function(t,e){return i.apply(this,arguments)})},{key:"splitUTXOs",value:(n=mu(du().mark((function t(e,r,n,i){var o,a,s,u,c,f,l;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return o={addresses:[e.p2wpkh,e.p2tr],minAmount:330n,requestedAmount:1000000000000000n},t.next=3,this.fetchUTXOMultiAddr(o);case 3:if((a=t.sent)&&a.length){t.next=6;break}return t.abrupt("return",{error:"No UTXOs found"});case 6:return s=BigInt(n)*i,u={amount:s,feeRate:500,from:e.p2tr,utxos:a,signer:e.keypair,network:r,to:e.p2tr,splitInputsInto:n,priorityFee:330n},c=new eu,t.next=11,c.createBTCTransfer(u);case 11:return f=t.sent,t.next=14,this.broadcastTransaction(f.tx,!1);case 14:if(l=t.sent){t.next=17;break}return t.abrupt("return",{error:"Could not broadcast transaction"});case 17:return t.abrupt("return",l);case 18:case"end":return t.stop()}}),t,this)}))),function(t,e,r,i){return n.apply(this,arguments)})},{key:"rpcMethod",value:(r=mu(du().mark((function t(e,r){var n,i,o,a,s;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n={method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",method:e,params:r,id:1})},i="".concat(this.opnetAPIUrl,"/api/v1/").concat(this.rpc),t.next=4,fetch(i,n);case 4:if((o=t.sent).ok){t.next=7;break}throw new Error("Failed to fetch to rpc: ".concat(o.statusText));case 7:return t.next=9,o.json();case 9:if(a=t.sent){t.next=12;break}throw new Error("No data fetched");case 12:if(s=a.result){t.next=15;break}throw new Error("No rpc parameters found");case 15:if(!("error"in s)){t.next=17;break}throw new Error("Error in fetching to rpc ".concat(s.error));case 17:return t.abrupt("return",s);case 18:case"end":return t.stop()}}),t,this)}))),function(t,e){return r.apply(this,arguments)})},{key:"fetchWrapParameters",value:(e=mu(du().mark((function t(e){var r,n;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<oi.VAULT_MINIMUM_AMOUNT)){t.next=2;break}throw new Error("Amount must be greater than the minimum consolidation amount ".concat(oi.VAULT_MINIMUM_AMOUNT,"sat."));case 2:return r=[0,e.toString()],t.next=5,this.rpcMethod("btc_generate",r);case 5:if(n=t.sent){t.next=8;break}return t.abrupt("return");case 8:return t.abrupt("return",new su(n));case 9:case"end":return t.stop()}}),t,this)}))),function(t){return e.apply(this,arguments)})},{key:"fetchUnWrapParameters",value:(t=mu(du().mark((function t(e,r){var n,i;return du().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!(e<330n)){t.next=2;break}throw new Error("Amount must be greater than the minimum consolidation amount ".concat(oi.VAULT_MINIMUM_AMOUNT,"sat."));case 2:if(!(r.length<50)){t.next=4;break}throw new Error("Invalid receiver address");case 4:return n=[1,e.toString(),r],t.next=7,this.rpcMethod("btc_generate",n);case 7:if(i=t.sent){t.next=10;break}return t.abrupt("return");case 10:return t.abrupt("return",new hu(i));case 11:case"end":return t.stop()}}),t,this)}))),function(e,r){return t.apply(this,arguments)})}]);var t,e,r,n,i,o,a}();function Tu(t){return Tu="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},Tu(t)}function Ou(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,Au(n.key),n)}}function xu(t,e,r){return e&&Ou(t.prototype,e),r&&Ou(t,r),Object.defineProperty(t,"prototype",{writable:!1}),t}function Au(t){var e=function(t){if("object"!=Tu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Tu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Tu(e)?e:e+""}var Pu,Iu,Ru,Lu=xu((function t(){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t)}));!function(t){t.testnet="testnet",t.mainnet="livenet",t.regtest="regtest"}(Pu||(Pu={})),function(t){t.BITCOIN_MAINNET="BITCOIN_MAINNET",t.BITCOIN_TESTNET="BITCOIN_TESTNET",t.BITCOIN_TESTNET4="BITCOIN_TESTNET4",t.BITCOIN_REGTEST="BITCOIN_REGTEST",t.BITCOIN_SIGNET="BITCOIN_SIGNET",t.FRACTAL_BITCOIN_MAINNET="FRACTAL_BITCOIN_MAINNET",t.FRACTAL_BITCOIN_TESTNET="FRACTAL_BITCOIN_TESTNET"}(Iu||(Iu={})),function(t){t.ecdsa="ecdsa",t.bip322="bip322-simple"}(Ru||(Ru={}));var Bu=i(8287).Buffer;function Uu(t){return Uu="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},Uu(t)}function Nu(){Nu=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:{},a=o.iterator||"@@iterator",s=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 f(t,e,r,n){var o=e&&e.prototype instanceof g?e:g,a=Object.create(o.prototype),s=new I(n||[]);return i(a,"_invoke",{value:O(t,r,s)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=f;var h="suspendedStart",p="suspendedYield",d="executing",y="completed",b={};function g(){}function w(){}function v(){}var m={};c(m,a,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(R([])));E&&E!==r&&n.call(E,a)&&(m=E);var S=v.prototype=g.prototype=Object.create(m);function k(t){["next","throw","return"].forEach((function(e){c(t,e,(function(t){return this._invoke(e,t)}))}))}function T(t,e){function r(i,o,a,s){var u=l(t[i],t,o);if("throw"!==u.type){var c=u.arg,f=c.value;return f&&"object"==Uu(f)&&n.call(f,"__await")?e.resolve(f.__await).then((function(t){r("next",t,a,s)}),(function(t){r("throw",t,a,s)})):e.resolve(f).then((function(t){c.value=t,a(c)}),(function(t){return r("throw",t,a,s)}))}s(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 O(e,r,n){var i=h;return function(o,a){if(i===d)throw Error("Generator is already running");if(i===y){if("throw"===o)throw a;return{value:t,done:!0}}for(n.method=o,n.arg=a;;){var s=n.delegate;if(s){var u=x(s,n);if(u){if(u===b)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=l(e,r,n);if("normal"===c.type){if(i=n.done?y:p,c.arg===b)continue;return{value:c.arg,done:n.done}}"throw"===c.type&&(i=y,n.method="throw",n.arg=c.arg)}}}function x(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,x(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),b;var o=l(i,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,b;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,b):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,b)}function A(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 P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(A,this),this.reset(!0)}function R(e){if(e||""===e){var r=e[a];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(Uu(e)+" is not iterable")}return w.prototype=v,i(S,"constructor",{value:v,configurable:!0}),i(v,"constructor",{value:w,configurable:!0}),w.displayName=c(v,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,v):(t.__proto__=v,c(t,u,"GeneratorFunction")),t.prototype=Object.create(S),t},e.awrap=function(t){return{__await:t}},k(T.prototype),c(T.prototype,s,(function(){return this})),e.AsyncIterator=T,e.async=function(t,r,n,i,o){void 0===o&&(o=Promise);var a=new T(f(t,r,n,i),o);return e.isGeneratorFunction(r)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},k(S),c(S,u,"Generator"),c(S,a,(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=R,I.prototype={constructor:I,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(P),!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 s.type="throw",s.arg=e,r.next=n,i&&(r.method="next",r.arg=t),!!i}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],s=a.completion;if("root"===a.tryLoc)return i("end");if(a.tryLoc<=this.prev){var u=n.call(a,"catchLoc"),c=n.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return i(a.catchLoc,!0);if(this.prev<a.finallyLoc)return i(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return i(a.catchLoc,!0)}else{if(!c)throw Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return i(a.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 a=o?o.completion:{};return a.type=t,a.arg=e,o?(this.method="next",this.next=o.finallyLoc,b):this.complete(a)},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),b},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),P(r),b}},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;P(r)}return i}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:R(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),b}},e}function ju(t,e,r,n,i,o,a){try{var s=t[o](a),u=s.value}catch(t){return void r(t)}s.done?e(u):Promise.resolve(u).then(n,i)}function Cu(t){return function(){var e=this,r=arguments;return new Promise((function(n,i){var o=t.apply(e,r);function a(t){ju(o,n,i,a,s,"next",t)}function s(t){ju(o,n,i,a,s,"throw",t)}a(void 0)}))}}function Fu(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,Ku(n.key),n)}}function Mu(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(Mu=function(){return!!t})()}function Du(t){return Du=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},Du(t)}function Hu(t,e){return Hu=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},Hu(t,e)}function Ku(t){var e=function(t){if("object"!=Uu(t)||!t)return t;var e=t[Symbol.toPrimitive];if(void 0!==e){var r=e.call(t,"string");if("object"!=Uu(r))return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t);return"symbol"==Uu(e)?e:e+""}var Wu=function(){function t(){var e;if(function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),function(t,e,r){(e=Ku(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r}(e=function(t,e,r){return e=Du(e),function(t,e){if(e&&("object"==Uu(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,Mu()?Reflect.construct(e,r||[],Du(t).constructor):e.apply(t,r))}(this,t),"isInitialized",!1),!window)throw new Error("UnisatSigner can only be used in a browser environment");return e}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&&Hu(t,e)}(t,Lu),function(t,e){return e&&Fu(t.prototype,e),Object.defineProperty(t,"prototype",{writable:!1}),t}(t,[{key:"p2tr",get:function(){if(!this._p2tr)throw new Error("P2TR address not set");return this._p2tr}},{key:"p2wpkh",get:function(){if(!this._p2wpkh)throw new Error("P2PKH address not set");return this._p2wpkh}},{key:"addresses",get:function(){if(!this._addresses)throw new Error("Addresses not set");return this._addresses}},{key:"publicKey",get:function(){if(!this._publicKey)throw new Error("Public key not set");return this._publicKey}},{key:"network",get:function(){if(!this._network)throw new Error("Network not set");return this._network}},{key:"unisat",get:function(){var t=window.opnet||window.unisat;if(!t)throw new Error("OPWallet extension not found");return t}},{key:"init",value:(i=Cu(Nu().mark((function t(){var e,r;return Nu().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(!this.isInitialized){t.next=2;break}return t.abrupt("return");case 2:return t.next=4,this.unisat.getNetwork();case 4:e=t.sent,t.t0=e,t.next=t.t0===Pu.mainnet?8:t.t0===Pu.testnet?10:t.t0===Pu.regtest?12:14;break;case 8:return this._network=d.o8.bitcoin,t.abrupt("break",15);case 10:return this._network=d.o8.testnet,t.abrupt("break",15);case 12:return this._network=d.o8.regtest,t.abrupt("break",15);case 14:throw new Error("Invalid network: ".concat(e));case 15:return t.next=17,this.unisat.getPublicKey();case 17:r=t.sent,this._publicKey=Bu.from(r,"hex"),this._p2wpkh=kt.getP2WPKHAddress(this,this.network),this._p2tr=kt.getTaprootAddress(this,this.network),this._addresses=[this._p2wpkh,this._p2tr],this.isInitialized=!0;case 23:case"end":return t.stop()}}),t,this)}))),function(){return i.apply(this,arguments)})},{key:"getPublicKey",value:function(){if(!this.isInitialized)throw new Error("UnisatSigner not initialized");return this.publicKey}},{key:"sign",value:function(t,e){throw new Error("Not implemented: sign")}},{key:"signSchnorr",value:function(t){throw new Error("Not implemented: signSchnorr")}},{key:"verify",value:function(t,e){throw new Error("Not implemented: verify")}},{key:"signTaprootInput",value:(n=Cu(Nu().mark((function t(e,r,n){var i;return Nu().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTweaked(e,r,n,!1);case 2:i=t.sent,this.combine(e,i,r);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,r){return n.apply(this,arguments)})},{key:"signInput",value:(r=Cu(Nu().mark((function t(e,r,n){var i;return Nu().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.signTweaked(e,r,n,!0);case 2:i=t.sent,this.combine(e,i,r);case 4:case"end":return t.stop()}}),t,this)}))),function(t,e,n){return r.apply(this,arguments)})},{key:"combine",value:function(t,e,r){var n,i=e.data.inputs[r],o=t.data.inputs[r];if(i.partialSig&&t.updateInput(r,{partialSig:i.partialSig}),i.tapKeySig&&!o.tapKeySig&&t.updateInput(r,{tapKeySig:i.tapKeySig}),null!==(n=i.tapScriptSig)&&void 0!==n&&n.length){var a=o.tapScriptSig;if(a){var s=this.getNonDuplicateScriptSig(a,i.tapScriptSig);s.length&&t.updateInput(r,{tapScriptSig:s})}else t.updateInput(r,{tapScriptSig:i.tapScriptSig})}}},{key:"signTweaked",value:(e=Cu(Nu().mark((function t(e,r,n){var i,o,a,s,u=arguments;return Nu().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return i=u.length>3&&void 0!==u[3]&&u[3],o={autoFinalized:!1,toSignInputs:[{index:r,publicKey:this.publicKey.toString("hex"),sighashTypes:n,disableTweakSigner:i}]},a=e.toHex(),t.next=5,this.unisat.signPsbt(a,o);case 5:return s=t.sent,t.abrupt("return",d.iL.fromHex(s));case 7:case"end":return t.stop()}}),t,this)}))),function(t,r,n){return e.apply(this,arguments)})},{key:"getNonDuplicateScriptSig",value:function(t,e){for(var r=[],n=function(n){t.find((function(t){return t.pubkey.equals(e[n].pubkey)}))||r.push(e[n])},i=0;i<e.length;i++)n(i);return r}}]);var e,r,n,i}(),Gu=o.iy,Vu=o.gd,zu=o.z2,qu=o.G7,Xu=o.GF,$u=o.nU,Yu=o.wf,Zu=o.gf,Ju=o.P8,Qu=o.vg,tc=o.nr,ec=o.ry,rc=o.z4,nc=o.qT,ic=o.kd,oc=o.eA,ac=o.no,sc=o.o4,uc=o.YV,cc=o.O5,fc=o.cC,lc=o.Wj,hc=o.Bc,pc=o.LL,dc=o.gK,yc=o.PE,bc=o.Go,gc=o.IB,wc=o.rl,vc=o.Y_,mc=o.yo,_c=o.Ko,Ec=o.pe,Sc=o.ho,kc=o._l,Tc=o.QS,Oc=o.Bm,xc=o.W_,Ac=o.Hu,Pc=o.Mg,Ic=o.$v,Rc=o.mt,Lc=o.lJ,Bc=o.ih,Uc=o.aw,Nc=o.tm,jc=o.Qc,Cc=o.dF,Fc=o.Wb,Mc=o.D_,Dc=o.aS,Hc=o._3,Kc=o.A9,Wc=o.V$,Gc=o.xc,Vc=o.S2,zc=o.qn,qc=o.Gc,Xc=o.zM,$c=o.c,Yc=o.uW,Zc=o.FV,Jc=o.UB,Qc=o.jz,tf=o.hL,ef=o.$7,rf=o.rE,nf=o.rR;export{Gu as AddressGenerator,Vu as AddressTypes,zu as AddressVerificator,qu as BitcoinUtils,Xu as CalldataGenerator,$u as ChainId,Yu as Compressor,Zu as Consensus,Ju as ContractBaseMetadata,Qu as CustomGenerator,tc as CustomKeypair,ec as CustomScriptTransaction,rc as DeploymentGenerator,nc as DeploymentTransaction,ic as EcKeyPair,oc as FACTORY_ADDRESS_FRACTAL,ac as FACTORY_ADDRESS_REGTEST,sc as FACTORY_ADDRESS_TESTNET,uc as FeatureOpCodes,cc as Features,fc as FundingTransaction,lc as Generator,hc as InteractionTransaction,pc as MOTO_ADDRESS_FRACTAL,dc as MOTO_ADDRESS_REGTEST,yc as MOTO_ADDRESS_TESTNET,bc as MessageType,gc as MultiSignGenerator,wc as MultiSignTransaction,vc as OPNetConsensusConfig,mc as OPNetLimitedProvider,_c as OPNetMetadata,Ec as OPNetNetwork,Sc as OPNetTokenAddressManager,kc as P2TR_MS,Tc as POOL_ADDRESS_FRACTAL,Oc as POOL_ADDRESS_REGTEST,xc as POOL_ADDRESS_TESTNET,Ac as PSBTTypes,Pc as PsbtTransaction,Ic as ROUTER_ADDRESS_FRACTAL,Rc as ROUTER_ADDRESS_REGTEST,Lc as ROUTER_ADDRESS_TESTNET,Bc as RoswellConsensus,Uc as SharedInteractionTransaction,Nc as TapscriptVerificator,jc as TransactionBuilder,Cc as TransactionFactory,Fc as TransactionSequence,Mc as TransactionType,Dc as TweakedSigner,Hc as TweakedTransaction,Kc as UnisatChainType,Wc as UnisatNetwork,Gc as UnisatSigner,Vc as UnwrapGeneration,zc as UnwrapTransaction,qc as WBTC_ADDRESS_FRACTAL,Xc as WBTC_ADDRESS_REGTEST,$c as WBTC_ADDRESS_TESTNET,Yc as Wallet,Zc as WrapTransaction,Jc as WrappedGeneration,Qc as currentConsensus,tf as currentConsensusConfig,ef as opnet,rf as version,nf as wBTC};
|