@gardenfi/core 0.2.0-beta.67 → 0.2.0-beta.68
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +9 -12
- package/dist/index.js +2797 -4432
- package/dist/src/lib/utils.d.ts +1 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1,31 +1,28 @@
|
|
|
1
|
-
"use strict";var Fs=Object.defineProperty;var Us=(e,t,r)=>t in e?Fs(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var pt=(e,t,r)=>Us(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("@catalogfi/utils"),J=require("@gardenfi/orderbook"),ge=require("@gardenfi/utils"),He=require("viem"),Ns=require("varuint-bitcoin"),Ms=require("tiny-secp256k1"),An=require("@catalogfi/wallets"),gi=require("bitcoinjs-lib"),Ds=require("bignumber.js");function fn(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Rn=fn(Ns),wt=fn(Ms),ye=fn(gi);var or=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(or||{}),ue=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(ue||{});function Wt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const mi="2.21.30";let kt={getDocsUrl:({docsBaseUrl:e,docsPath:t="",docsSlug:r})=>t?`${e??"https://viem.sh"}${t}${r?`#${r}`:""}`:void 0,version:`viem@${mi}`};class Z extends Error{constructor(t,r={}){var u;const n=(()=>{var l;return r.cause instanceof Z?r.cause.details:(l=r.cause)!=null&&l.message?r.cause.message:r.details})(),i=r.cause instanceof Z&&r.cause.docsPath||r.docsPath,a=(u=kt.getDocsUrl)==null?void 0:u.call(kt,{...r,docsPath:i}),f=[t||"An error occurred.","",...r.metaMessages?[...r.metaMessages,""]:[],...a?[`Docs: ${a}`]:[],...n?[`Details: ${n}`]:[],...kt.version?[`Version: ${kt.version}`]:[]].join(`
|
|
2
|
-
`);super(f,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=n,this.docsPath=i,this.metaMessages=r.metaMessages,this.name=r.name??this.name,this.shortMessage=t,this.version=mi}walk(t){return _i(this,t)}}function _i(e,t){return t!=null&&t(e)?e:e&&typeof e=="object"&&"cause"in e?_i(e.cause,t):t?null:e}class $s extends Z{constructor({max:t,min:r,signed:n,size:i,value:a}){super(`Number "${a}" is not in safe ${i?`${i*8}-bit ${n?"signed":"unsigned"} `:""}integer range ${t?`(${r} to ${t})`:`(above ${r})`}`,{name:"IntegerOutOfRangeError"})}}class Hs extends Z{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed ${r} bytes. Given size: ${t} bytes.`,{name:"SizeOverflowError"})}}function qt(e,{strict:t=!0}={}){return!e||typeof e!="string"?!1:t?/^0x[0-9a-fA-F]*$/.test(e):e.startsWith("0x")}function xt(e){return qt(e,{strict:!1})?Math.ceil((e.length-2)/2):e.length}function ar(e,{dir:t="left"}={}){let r=typeof e=="string"?e.replace("0x",""):e,n=0;for(let i=0;i<r.length-1&&r[t==="left"?i:r.length-i-1].toString()==="0";i++)n++;return r=t==="left"?r.slice(n):r.slice(0,r.length-n),typeof e=="string"?(r.length===1&&t==="right"&&(r=`${r}0`),`0x${r.length%2===1?`0${r}`:r}`):r}class zs extends Z{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset "${t}" is out-of-bounds (size: ${n}).`,{name:"SliceOffsetOutOfBoundsError"})}}class wi extends Z{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (${t}) exceeds padding size (${r}).`,{name:"SizeExceedsPaddingSizeError"})}}function St(e,{dir:t,size:r=32}={}){return typeof e=="string"?js(e,{dir:t,size:r}):Gs(e,{dir:t,size:r})}function js(e,{dir:t,size:r=32}={}){if(r===null)return e;const n=e.replace("0x","");if(n.length>r*2)throw new wi({size:Math.ceil(n.length/2),targetSize:r,type:"hex"});return`0x${n[t==="right"?"padEnd":"padStart"](r*2,"0")}`}function Gs(e,{dir:t,size:r=32}={}){if(r===null)return e;if(e.length>r)throw new wi({size:e.length,targetSize:r,type:"bytes"});const n=new Uint8Array(r);for(let i=0;i<r;i++){const a=t==="right";n[a?i:r-i-1]=e[a?i:e.length-i-1]}return n}const Ws=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function W(e,t={}){return typeof e=="number"||typeof e=="bigint"?xi(e,t):typeof e=="string"?Ks(e,t):typeof e=="boolean"?qs(e,t):Ze(e,t)}function qs(e,t={}){const r=`0x${Number(e)}`;return typeof t.size=="number"?(It(r,{size:t.size}),St(r,{size:t.size})):r}function Ze(e,t={}){let r="";for(let i=0;i<e.length;i++)r+=Ws[e[i]];const n=`0x${r}`;return typeof t.size=="number"?(It(n,{size:t.size}),St(n,{dir:"right",size:t.size})):n}function xi(e,t={}){const{signed:r,size:n}=t,i=BigInt(e);let a;n?r?a=(1n<<BigInt(n)*8n-1n)-1n:a=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(a=BigInt(Number.MAX_SAFE_INTEGER));const f=typeof a=="bigint"&&r?-a-1n:0;if(a&&i>a||i<f){const l=typeof e=="bigint"?"n":"";throw new $s({max:a?`${a}${l}`:void 0,min:`${f}${l}`,signed:r,size:n,value:`${e}${l}`})}const u=`0x${(r&&i<0?(1n<<BigInt(n*8))+BigInt(i):i).toString(16)}`;return n?St(u,{size:n}):u}const Vs=new TextEncoder;function Ks(e,t={}){const r=Vs.encode(e);return Ze(r,t)}const Ys=new TextEncoder;function vi(e,t={}){return typeof e=="number"||typeof e=="bigint"?Xs(e,t):typeof e=="boolean"?Js(e,t):qt(e)?st(e,t):Ei(e,t)}function Js(e,t={}){const r=new Uint8Array(1);return r[0]=Number(e),typeof t.size=="number"?(It(r,{size:t.size}),St(r,{size:t.size})):r}const Me={zero:48,nine:57,A:65,F:70,a:97,f:102};function Tn(e){if(e>=Me.zero&&e<=Me.nine)return e-Me.zero;if(e>=Me.A&&e<=Me.F)return e-(Me.A-10);if(e>=Me.a&&e<=Me.f)return e-(Me.a-10)}function st(e,t={}){let r=e;t.size&&(It(r,{size:t.size}),r=St(r,{dir:"right",size:t.size}));let n=r.slice(2);n.length%2&&(n=`0${n}`);const i=n.length/2,a=new Uint8Array(i);for(let f=0,u=0;f<i;f++){const l=Tn(n.charCodeAt(u++)),b=Tn(n.charCodeAt(u++));if(l===void 0||b===void 0)throw new Z(`Invalid byte sequence ("${n[u-2]}${n[u-1]}" in "${n}").`);a[f]=l*16+b}return a}function Xs(e,t){const r=xi(e,t);return st(r)}function Ei(e,t={}){const r=Ys.encode(e);return typeof t.size=="number"?(It(r,{size:t.size}),St(r,{dir:"right",size:t.size})):r}function It(e,{size:t}){if(xt(e)>t)throw new Hs({givenSize:xt(e),maxSize:t})}function gt(e,t={}){const{signed:r}=t;t.size&&It(e,{size:t.size});const n=BigInt(e);if(!r)return n;const i=(e.length-2)/2,a=(1n<<BigInt(i)*8n-1n)-1n;return n<=a?n:n-BigInt(`0x${"f".padStart(i*2,"f")}`)-1n}function fr(e,t={}){return Number(gt(e,t))}function un(e,t){return({exclude:r,format:n})=>({exclude:r,format:i=>{const a=t(i);if(r)for(const f of r)delete a[f];return{...a,...n(i)}},type:e})}const Bi={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function cn(e){const t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?fr(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?fr(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?Bi[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=Zs(e.authorizationList)),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof t.v=="bigint"){if(t.v===0n||t.v===27n)return 0;if(t.v===1n||t.v===28n)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),t.type==="legacy"&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),t.type==="eip2930"&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),t.type==="eip1559"&&delete t.maxFeePerBlobGas,t}const Qs=un("transaction",cn);function Zs(e){return e.map(t=>({contractAddress:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function eo(e){var r;const t=(r=e.transactions)==null?void 0:r.map(n=>typeof n=="string"?n:cn(n));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}const to=un("block",eo);function ro(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}const no={"0x0":"reverted","0x1":"success"};function io(e){const t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(r=>ro(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?fr(e.transactionIndex):null,status:e.status?no[e.status]:null,type:e.type?Bi[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}const so=un("transactionReceipt",io),ln=2n**256n-1n;function Vt(e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}class Pn extends Z{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`,{name:"NegativeOffsetError"})}}class oo extends Z{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`,{name:"PositionOutOfBoundsError"})}}class ao extends Z{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`,{name:"RecursiveReadLimitExceededError"})}}const fo={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new ao({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new oo({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new Pn({offset:e});const t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new Pn({offset:e});const t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){const r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){const t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){const t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){const t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){const t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();const e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();const r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();const e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();const e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();const e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();const e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){const t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;const e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function Si(e,{recursiveReadLimit:t=8192}={}){const r=Object.create(fo);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}function ot(e,t="hex"){const r=Ii(e),n=Si(new Uint8Array(r.length));return r.encode(n),t==="hex"?Ze(n.bytes):n.bytes}function Ii(e){return Array.isArray(e)?uo(e.map(t=>Ii(t))):co(e)}function uo(e){const t=e.reduce((i,a)=>i+a.length,0),r=Ai(t);return{length:t<=55?1+t:1+r+t,encode(i){t<=55?i.pushByte(192+t):(i.pushByte(247+r),r===1?i.pushUint8(t):r===2?i.pushUint16(t):r===3?i.pushUint24(t):i.pushUint32(t));for(const{encode:a}of e)a(i)}}}function co(e){const t=typeof e=="string"?st(e):e,r=Ai(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(i){t.length===1&&t[0]<128?i.pushBytes(t):t.length<=55?(i.pushByte(128+t.length),i.pushBytes(t)):(i.pushByte(183+r),r===1?i.pushUint8(t.length):r===2?i.pushUint16(t.length):r===3?i.pushUint24(t.length):i.pushUint32(t.length),i.pushBytes(t))}}}function Ai(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new Z("Length is too large.")}const lo={ether:-9,wei:9};function ho(e,t){let r=e.toString();const n=r.startsWith("-");n&&(r=r.slice(1)),r=r.padStart(t,"0");let[i,a]=[r.slice(0,r.length-t),r.slice(r.length-t)];return a=a.replace(/(0+)$/,""),`${n?"-":""}${i||"0"}${a?`.${a}`:""}`}function Xr(e,t="wei"){return ho(e,lo[t])}function po(e){const t=Object.entries(e).map(([n,i])=>i===void 0||i===!1?null:[n,i]).filter(Boolean),r=t.reduce((n,[i])=>Math.max(n,i.length),0);return t.map(([n,i])=>` ${`${n}:`.padEnd(r+1)} ${i}`).join(`
|
|
3
|
-
`)}class bo extends Z{constructor({v:t}){super(`Invalid \`v\` value "${t}". Expected 27 or 28.`,{name:"InvalidLegacyVError"})}}class yo extends Z{constructor({transaction:t}){super("Cannot infer a transaction type from provided transaction.",{metaMessages:["Provided Transaction:","{",po(t),"}","","To infer the type, either provide:","- a `type` to the Transaction, or","- an EIP-1559 Transaction with `maxFeePerGas`, or","- an EIP-2930 Transaction with `gasPrice` & `accessList`, or","- an EIP-4844 Transaction with `blobs`, `blobVersionedHashes`, `sidecars`, or","- an EIP-7702 Transaction with `authorizationList`, or","- a Legacy Transaction with `gasPrice`"],name:"InvalidSerializableTransactionError"})}}class go extends Z{constructor({storageKey:t}){super(`Size for storage key "${t}" is invalid. Expected 32 bytes. Got ${Math.floor((t.length-2)/2)} bytes.`,{name:"InvalidStorageKeySizeError"})}}function Ri(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(a=>st(a)):e.blobs,i=[];for(const a of n)i.push(Uint8Array.from(t.blobToKzgCommitment(a)));return r==="bytes"?i:i.map(a=>Ze(a))}function Ti(e){const{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(f=>st(f)):e.blobs,i=typeof e.commitments[0]=="string"?e.commitments.map(f=>st(f)):e.commitments,a=[];for(let f=0;f<n.length;f++){const u=n[f],l=i[f];a.push(Uint8Array.from(t.computeBlobKzgProof(u,l)))}return r==="bytes"?a:a.map(f=>Ze(f))}function kn(e){if(!Number.isSafeInteger(e)||e<0)throw new Error(`positive integer expected, not ${e}`)}function mo(e){return e instanceof Uint8Array||e!=null&&typeof e=="object"&&e.constructor.name==="Uint8Array"}function hn(e,...t){if(!mo(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error(`Uint8Array expected of length ${t}, not of length=${e.length}`)}function ur(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Pi(e,t){hn(e);const r=t.outputLen;if(e.length<r)throw new Error(`digestInto() expects output buffer of length at least ${r}`)}/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const _o=e=>new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4)),Cr=e=>new DataView(e.buffer,e.byteOffset,e.byteLength),Oe=(e,t)=>e<<32-t|e>>>t,Cn=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68,wo=e=>e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255;function Ln(e){for(let t=0;t<e.length;t++)e[t]=wo(e[t])}function xo(e){if(typeof e!="string")throw new Error(`utf8ToBytes expected string, got ${typeof e}`);return new Uint8Array(new TextEncoder().encode(e))}function dn(e){return typeof e=="string"&&(e=xo(e)),hn(e),e}let ki=class{clone(){return this._cloneInto()}};function Ci(e){const t=n=>e().update(dn(n)).digest(),r=e();return t.outputLen=r.outputLen,t.blockLen=r.blockLen,t.create=()=>e(),t}function vo(e,t,r,n){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,r,n);const i=BigInt(32),a=BigInt(4294967295),f=Number(r>>i&a),u=Number(r&a),l=n?4:0,b=n?0:4;e.setUint32(t+l,f,n),e.setUint32(t+b,u,n)}const Eo=(e,t,r)=>e&t^~e&r,Bo=(e,t,r)=>e&t^e&r^t&r;class So extends ki{constructor(t,r,n,i){super(),this.blockLen=t,this.outputLen=r,this.padOffset=n,this.isLE=i,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(t),this.view=Cr(this.buffer)}update(t){ur(this);const{view:r,buffer:n,blockLen:i}=this;t=dn(t);const a=t.length;for(let f=0;f<a;){const u=Math.min(i-this.pos,a-f);if(u===i){const l=Cr(t);for(;i<=a-f;f+=i)this.process(l,f);continue}n.set(t.subarray(f,f+u),this.pos),this.pos+=u,f+=u,this.pos===i&&(this.process(r,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){ur(this),Pi(t,this),this.finished=!0;const{buffer:r,view:n,blockLen:i,isLE:a}=this;let{pos:f}=this;r[f++]=128,this.buffer.subarray(f).fill(0),this.padOffset>i-f&&(this.process(n,0),f=0);for(let m=f;m<i;m++)r[m]=0;vo(n,i-8,BigInt(this.length*8),a),this.process(n,0);const u=Cr(t),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const b=l/4,g=this.get();if(b>g.length)throw new Error("_sha2: outputLen bigger than state");for(let m=0;m<b;m++)u.setUint32(4*m,g[m],a)}digest(){const{buffer:t,outputLen:r}=this;this.digestInto(t);const n=t.slice(0,r);return this.destroy(),n}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:r,buffer:n,length:i,finished:a,destroyed:f,pos:u}=this;return t.length=i,t.pos=u,t.finished=a,t.destroyed=f,i%r&&t.buffer.set(n),t}}const Io=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]),Ye=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),Je=new Uint32Array(64);class Ao extends So{constructor(){super(64,32,8,!1),this.A=Ye[0]|0,this.B=Ye[1]|0,this.C=Ye[2]|0,this.D=Ye[3]|0,this.E=Ye[4]|0,this.F=Ye[5]|0,this.G=Ye[6]|0,this.H=Ye[7]|0}get(){const{A:t,B:r,C:n,D:i,E:a,F:f,G:u,H:l}=this;return[t,r,n,i,a,f,u,l]}set(t,r,n,i,a,f,u,l){this.A=t|0,this.B=r|0,this.C=n|0,this.D=i|0,this.E=a|0,this.F=f|0,this.G=u|0,this.H=l|0}process(t,r){for(let m=0;m<16;m++,r+=4)Je[m]=t.getUint32(r,!1);for(let m=16;m<64;m++){const v=Je[m-15],I=Je[m-2],B=Oe(v,7)^Oe(v,18)^v>>>3,k=Oe(I,17)^Oe(I,19)^I>>>10;Je[m]=k+Je[m-7]+B+Je[m-16]|0}let{A:n,B:i,C:a,D:f,E:u,F:l,G:b,H:g}=this;for(let m=0;m<64;m++){const v=Oe(u,6)^Oe(u,11)^Oe(u,25),I=g+v+Eo(u,l,b)+Io[m]+Je[m]|0,k=(Oe(n,2)^Oe(n,13)^Oe(n,22))+Bo(n,i,a)|0;g=b,b=l,l=u,u=f+I|0,f=a,a=i,i=n,n=I+k|0}n=n+this.A|0,i=i+this.B|0,a=a+this.C|0,f=f+this.D|0,u=u+this.E|0,l=l+this.F|0,b=b+this.G|0,g=g+this.H|0,this.set(n,i,a,f,u,l,b,g)}roundClean(){Je.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const Ro=Ci(()=>new Ao);function To(e,t){return Ro(qt(e,{strict:!1})?vi(e):e)}function Po(e){const{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),i=To(t);return i.set([r],0),n==="bytes"?i:Ze(i)}function ko(e){const{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),i=[];for(const a of t)i.push(Po({commitment:a,to:n,version:r}));return i}const On=6,Li=32,pn=4096,Oi=Li*pn,Fn=Oi*On-1-1*pn*On,Fi=1;class Co extends Z{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}}class Ui extends Z{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}}class Lo extends Z{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}}class Oo extends Z{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${Fi}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}}function Fo(e){const t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?st(e.data):e.data,n=xt(r);if(!n)throw new Ui;if(n>Fn)throw new Co({maxSize:Fn,size:n});const i=[];let a=!0,f=0;for(;a;){const u=Si(new Uint8Array(Oi));let l=0;for(;l<pn;){const b=r.slice(f,f+(Li-1));if(u.pushByte(0),u.pushBytes(b),b.length<31){u.pushByte(128),a=!1;break}l++,f+=31}i.push(u)}return t==="bytes"?i.map(u=>u.bytes):i.map(u=>Ze(u.bytes))}function Uo(e){const{data:t,kzg:r,to:n}=e,i=e.blobs??Fo({data:t,to:n}),a=e.commitments??Ri({blobs:i,kzg:r,to:n}),f=e.proofs??Ti({blobs:i,commitments:a,kzg:r,to:n}),u=[];for(let l=0;l<i.length;l++)u.push({blob:i[l],commitment:a[l],proof:f[l]});return u}function No(e){if(!e||e.length===0)return[];const t=[];for(const r of e){const{contractAddress:n,chainId:i,nonce:a,...f}=r;t.push([W(i),n,a?W(a):"0x",...Kt({},f)])}return t}class at extends Z{constructor({address:t}){super(`Address "${t}" is invalid.`,{metaMessages:["- Address must be a hex value of 20 bytes (40 hex characters).","- Address must match its checksum counterpart."],name:"InvalidAddressError"})}}class gr extends Z{constructor({chainId:t}){super(typeof t=="number"?`Chain ID "${t}" is invalid.`:"Chain ID is invalid.",{name:"InvalidChainIdError"})}}class mr extends Z{constructor({cause:t,maxFeePerGas:r}={}){super(`The fee cap (\`maxFeePerGas\`${r?` = ${Xr(r)} gwei`:""}) cannot be higher than the maximum allowed value (2^256-1).`,{cause:t,name:"FeeCapTooHighError"})}}Object.defineProperty(mr,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max fee per gas higher than 2\^256-1|fee cap higher than 2\^256-1/});class Ni extends Z{constructor({cause:t,maxPriorityFeePerGas:r,maxFeePerGas:n}={}){super([`The provided tip (\`maxPriorityFeePerGas\`${r?` = ${Xr(r)} gwei`:""}) cannot be higher than the fee cap (\`maxFeePerGas\`${n?` = ${Xr(n)} gwei`:""}).`].join(`
|
|
4
|
-
`),{cause:t,name:"TipAboveFeeCapError"})}}Object.defineProperty(Ni,"nodeMessage",{enumerable:!0,configurable:!0,writable:!0,value:/max priority fee per gas higher than max fee per gas|tip higher than fee cap/});class Mi extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){const r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){const n=this.keys().next().value;n&&this.delete(n)}return this}}const tr=BigInt(2**32-1),Un=BigInt(32);function Mo(e,t=!1){return t?{h:Number(e&tr),l:Number(e>>Un&tr)}:{h:Number(e>>Un&tr)|0,l:Number(e&tr)|0}}function Do(e,t=!1){let r=new Uint32Array(e.length),n=new Uint32Array(e.length);for(let i=0;i<e.length;i++){const{h:a,l:f}=Mo(e[i],t);[r[i],n[i]]=[a,f]}return[r,n]}const $o=(e,t,r)=>e<<r|t>>>32-r,Ho=(e,t,r)=>t<<r|e>>>32-r,zo=(e,t,r)=>t<<r-32|e>>>64-r,jo=(e,t,r)=>e<<r-32|t>>>64-r,Di=[],$i=[],Hi=[],Go=BigInt(0),Ct=BigInt(1),Wo=BigInt(2),qo=BigInt(7),Vo=BigInt(256),Ko=BigInt(113);for(let e=0,t=Ct,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],Di.push(2*(5*n+r)),$i.push((e+1)*(e+2)/2%64);let i=Go;for(let a=0;a<7;a++)t=(t<<Ct^(t>>qo)*Ko)%Vo,t&Wo&&(i^=Ct<<(Ct<<BigInt(a))-Ct);Hi.push(i)}const[Yo,Jo]=Do(Hi,!0),Nn=(e,t,r)=>r>32?zo(e,t,r):$o(e,t,r),Mn=(e,t,r)=>r>32?jo(e,t,r):Ho(e,t,r);function Xo(e,t=24){const r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let f=0;f<10;f++)r[f]=e[f]^e[f+10]^e[f+20]^e[f+30]^e[f+40];for(let f=0;f<10;f+=2){const u=(f+8)%10,l=(f+2)%10,b=r[l],g=r[l+1],m=Nn(b,g,1)^r[u],v=Mn(b,g,1)^r[u+1];for(let I=0;I<50;I+=10)e[f+I]^=m,e[f+I+1]^=v}let i=e[2],a=e[3];for(let f=0;f<24;f++){const u=$i[f],l=Nn(i,a,u),b=Mn(i,a,u),g=Di[f];i=e[g],a=e[g+1],e[g]=l,e[g+1]=b}for(let f=0;f<50;f+=10){for(let u=0;u<10;u++)r[u]=e[f+u];for(let u=0;u<10;u++)e[f+u]^=~r[(u+2)%10]&r[(u+4)%10]}e[0]^=Yo[n],e[1]^=Jo[n]}r.fill(0)}class bn extends ki{constructor(t,r,n,i=!1,a=24){if(super(),this.blockLen=t,this.suffix=r,this.outputLen=n,this.enableXOF=i,this.rounds=a,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,kn(n),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=_o(this.state)}keccak(){Cn||Ln(this.state32),Xo(this.state32,this.rounds),Cn||Ln(this.state32),this.posOut=0,this.pos=0}update(t){ur(this);const{blockLen:r,state:n}=this;t=dn(t);const i=t.length;for(let a=0;a<i;){const f=Math.min(r-this.pos,i-a);for(let u=0;u<f;u++)n[this.pos++]^=t[a++];this.pos===r&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:r,pos:n,blockLen:i}=this;t[n]^=r,r&128&&n===i-1&&this.keccak(),t[i-1]^=128,this.keccak()}writeInto(t){ur(this,!1),hn(t),this.finish();const r=this.state,{blockLen:n}=this;for(let i=0,a=t.length;i<a;){this.posOut>=n&&this.keccak();const f=Math.min(n-this.posOut,a-i);t.set(r.subarray(this.posOut,this.posOut+f),i),this.posOut+=f,i+=f}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return kn(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Pi(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(t){const{blockLen:r,suffix:n,outputLen:i,rounds:a,enableXOF:f}=this;return t||(t=new bn(r,n,i,f,a)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=a,t.suffix=n,t.outputLen=i,t.enableXOF=f,t.destroyed=this.destroyed,t}}const Qo=(e,t,r)=>Ci(()=>new bn(t,e,r)),Zo=Qo(1,136,256/8);function ea(e,t){return Zo(qt(e,{strict:!1})?vi(e):e)}const Lr=new Mi(8192);function ta(e,t){if(Lr.has(`${e}.${t}`))return Lr.get(`${e}.${t}`);const r=e.substring(2).toLowerCase(),n=ea(Ei(r)),i=r.split("");for(let f=0;f<40;f+=2)n[f>>1]>>4>=8&&i[f]&&(i[f]=i[f].toUpperCase()),(n[f>>1]&15)>=8&&i[f+1]&&(i[f+1]=i[f+1].toUpperCase());const a=`0x${i.join("")}`;return Lr.set(`${e}.${t}`,a),a}const ra=/^0x[a-fA-F0-9]{40}$/,Or=new Mi(8192);function ft(e,t){const{strict:r=!0}=t??{},n=`${e}.${r}`;if(Or.has(n))return Or.get(n);const i=ra.test(e)?e.toLowerCase()===e?!0:r?ta(e)===e:!0:!1;return Or.set(n,i),i}function na(e,t,r,{strict:n}={}){return qt(e,{strict:!1})?sa(e,t,r,{strict:n}):ia(e,t,r,{strict:n})}function zi(e,t,r){if(xt(e)!==r-t)throw new zs({offset:r,position:"end",size:xt(e)})}function ia(e,t,r,{strict:n}={}){const i=e.slice(t,r);return n&&zi(i,t,r),i}function sa(e,t,r,{strict:n}={}){const i=`0x${e.replace("0x","").slice(t*2,r*2)}`;return n&&zi(i,t,r),i}function oa(e){const{authorizationList:t}=e;if(t)for(const r of t){const{contractAddress:n,chainId:i}=r;if(!ft(n))throw new at({address:n});if(i<=0)throw new gr({chainId:i})}yn(e)}function aa(e){const{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Ui;for(const r of t){const n=xt(r),i=fr(na(r,0,1));if(n!==32)throw new Lo({hash:r,size:n});if(i!==Fi)throw new Oo({hash:r,version:i})}}yn(e)}function yn(e){const{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:i}=e;if(t<=0)throw new gr({chainId:t});if(i&&!ft(i))throw new at({address:i});if(n&&n>ln)throw new mr({maxFeePerGas:n});if(r&&n&&r>n)throw new Ni({maxFeePerGas:n,maxPriorityFeePerGas:r})}function fa(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:a}=e;if(t<=0)throw new gr({chainId:t});if(a&&!ft(a))throw new at({address:a});if(r||i)throw new Z("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>ln)throw new mr({maxFeePerGas:n})}function ua(e){const{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:i,to:a}=e;if(a&&!ft(a))throw new at({address:a});if(typeof t<"u"&&t<=0)throw new gr({chainId:t});if(r||i)throw new Z("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>ln)throw new mr({maxFeePerGas:n})}function ca(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new yo({transaction:e})}function _r(e){if(!e||e.length===0)return[];const t=[];for(let r=0;r<e.length;r++){const{address:n,storageKeys:i}=e[r];for(let a=0;a<i.length;a++)if(i[a].length-2!==64)throw new go({storageKey:i[a]});if(!ft(n,{strict:!1}))throw new at({address:n});t.push([n,i])}return t}function la(e,t){const r=ca(e);return r==="eip1559"?pa(e,t):r==="eip2930"?ba(e,t):r==="eip4844"?da(e,t):r==="eip7702"?ha(e,t):ya(e,t)}function ha(e,t){const{authorizationList:r,chainId:n,gas:i,nonce:a,to:f,value:u,maxFeePerGas:l,maxPriorityFeePerGas:b,accessList:g,data:m}=e;oa(e);const v=_r(g),I=No(r);return Vt(["0x04",ot([W(n),a?W(a):"0x",b?W(b):"0x",l?W(l):"0x",i?W(i):"0x",f??"0x",u?W(u):"0x",m??"0x",v,I,...Kt(e,t)])])}function da(e,t){const{chainId:r,gas:n,nonce:i,to:a,value:f,maxFeePerBlobGas:u,maxFeePerGas:l,maxPriorityFeePerGas:b,accessList:g,data:m}=e;aa(e);let v=e.blobVersionedHashes,I=e.sidecars;if(e.blobs&&(typeof v>"u"||typeof I>"u")){const O=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(S=>Ze(S)),L=e.kzg,U=Ri({blobs:O,kzg:L});if(typeof v>"u"&&(v=ko({commitments:U})),typeof I>"u"){const S=Ti({blobs:O,commitments:U,kzg:L});I=Uo({blobs:O,commitments:U,proofs:S})}}const B=_r(g),k=[W(r),i?W(i):"0x",b?W(b):"0x",l?W(l):"0x",n?W(n):"0x",a??"0x",f?W(f):"0x",m??"0x",B,u?W(u):"0x",v??[],...Kt(e,t)],T=[],C=[],F=[];if(I)for(let O=0;O<I.length;O++){const{blob:L,commitment:U,proof:S}=I[O];T.push(L),C.push(U),F.push(S)}return Vt(["0x03",ot(I?[k,T,C,F]:k)])}function pa(e,t){const{chainId:r,gas:n,nonce:i,to:a,value:f,maxFeePerGas:u,maxPriorityFeePerGas:l,accessList:b,data:g}=e;yn(e);const m=_r(b),v=[W(r),i?W(i):"0x",l?W(l):"0x",u?W(u):"0x",n?W(n):"0x",a??"0x",f?W(f):"0x",g??"0x",m,...Kt(e,t)];return Vt(["0x02",ot(v)])}function ba(e,t){const{chainId:r,gas:n,data:i,nonce:a,to:f,value:u,accessList:l,gasPrice:b}=e;fa(e);const g=_r(l),m=[W(r),a?W(a):"0x",b?W(b):"0x",n?W(n):"0x",f??"0x",u?W(u):"0x",i??"0x",g,...Kt(e,t)];return Vt(["0x01",ot(m)])}function ya(e,t){const{chainId:r=0,gas:n,data:i,nonce:a,to:f,value:u,gasPrice:l}=e;ua(e);let b=[a?W(a):"0x",l?W(l):"0x",n?W(n):"0x",f??"0x",u?W(u):"0x",i??"0x"];if(t){const g=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);const I=27n+(t.v===27n?0n:1n);if(t.v!==I)throw new bo({v:t.v});return I})(),m=ar(t.r),v=ar(t.s);b=[...b,W(g),m==="0x00"?"0x":m,v==="0x00"?"0x":v]}else r>0&&(b=[...b,W(r),"0x","0x"]);return ot(b)}function Kt(e,t){const r=t??e,{v:n,yParity:i}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof i>"u")return[];const a=ar(r.r),f=ar(r.s);return[typeof i=="number"?i?W(1):"0x":n===0n?"0x":n===1n?W(1):n===27n?"0x":W(1),a==="0x00"?"0x":a,f==="0x00"?"0x":f]}const ga={gasPriceOracle:{address:"0x420000000000000000000000000000000000000F"},l1Block:{address:"0x4200000000000000000000000000000000000015"},l2CrossDomainMessenger:{address:"0x4200000000000000000000000000000000000007"},l2Erc721Bridge:{address:"0x4200000000000000000000000000000000000014"},l2StandardBridge:{address:"0x4200000000000000000000000000000000000010"},l2ToL1MessagePasser:{address:"0x4200000000000000000000000000000000000016"}},ma={block:to({format(e){var r;return{transactions:(r=e.transactions)==null?void 0:r.map(n=>{if(typeof n=="string")return n;const i=cn(n);return i.typeHex==="0x7e"&&(i.isSystemTx=n.isSystemTx,i.mint=n.mint?gt(n.mint):void 0,i.sourceHash=n.sourceHash,i.type="deposit"),i}),stateRoot:e.stateRoot}}}),transaction:Qs({format(e){const t={};return e.type==="0x7e"&&(t.isSystemTx=e.isSystemTx,t.mint=e.mint?gt(e.mint):void 0,t.sourceHash=e.sourceHash,t.type="deposit"),t}}),transactionReceipt:so({format(e){return{l1GasPrice:e.l1GasPrice?gt(e.l1GasPrice):null,l1GasUsed:e.l1GasUsed?gt(e.l1GasUsed):null,l1Fee:e.l1Fee?gt(e.l1Fee):null,l1FeeScalar:e.l1FeeScalar?Number(e.l1FeeScalar):null}}})};function _a(e,t){return va(e)?xa(e):la(e,t)}const wa={transaction:_a};function xa(e){Ea(e);const{sourceHash:t,data:r,from:n,gas:i,isSystemTx:a,mint:f,to:u,value:l}=e,b=[t,n,u??"0x",f?W(f):"0x",l?W(l):"0x",i?W(i):"0x",a?"0x1":"0x",r??"0x"];return Vt(["0x7e",ot(b)])}function va(e){return e.type==="deposit"||typeof e.sourceHash<"u"}function Ea(e){const{from:t,to:r}=e;if(t&&!ft(t))throw new at({address:t});if(r&&!ft(r))throw new at({address:r})}const Dn={contracts:ga,formatters:ma,serializers:wa},Ba=Wt({id:42161,name:"Arbitrum One",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://arb1.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://arbiscan.io",apiUrl:"https://api.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:7654707}}}),Sa=Wt({id:421614,name:"Arbitrum Sepolia",nativeCurrency:{name:"Arbitrum Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia-rollup.arbitrum.io/rpc"]}},blockExplorers:{default:{name:"Arbiscan",url:"https://sepolia.arbiscan.io",apiUrl:"https://api-sepolia.arbiscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:81930}},testnet:!0}),Lt=11155111,Ia=Wt({...Dn,id:84532,network:"base-sepolia",name:"Base Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://sepolia.base.org"]}},blockExplorers:{default:{name:"Basescan",url:"https://sepolia.basescan.org",apiUrl:"https://api-sepolia.basescan.org/api"}},contracts:{...Dn.contracts,disputeGameFactory:{[Lt]:{address:"0xd6E6dBf4F7EA0ac412fD8b65ED297e64BB7a06E1"}},l2OutputOracle:{[Lt]:{address:"0x84457ca9D0163FbC4bbfe4Dfbb20ba46e48DF254"}},portal:{[Lt]:{address:"0x49f53e41452c74589e85ca1677426ba426459e85",blockCreated:4446677}},l1StandardBridge:{[Lt]:{address:"0xfd0Bf71F60660E2f608ed56e1659C450eB113120",blockCreated:4446677}},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:1059647}},testnet:!0,sourceId:Lt}),Aa=Wt({id:1,name:"Ethereum",nativeCurrency:{name:"Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://cloudflare-eth.com"]}},blockExplorers:{default:{name:"Etherscan",url:"https://etherscan.io",apiUrl:"https://api.etherscan.io/api"}},contracts:{ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xce01f8eee7E479C928F8919abD53E553a36CeF67",blockCreated:19258213},multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:14353601}}}),Ra=Wt({id:11155111,name:"Sepolia",nativeCurrency:{name:"Sepolia Ether",symbol:"ETH",decimals:18},rpcUrls:{default:{http:["https://rpc2.sepolia.org"]}},blockExplorers:{default:{name:"Etherscan",url:"https://sepolia.etherscan.io",apiUrl:"https://api-sepolia.etherscan.io/api"}},contracts:{multicall3:{address:"0xca11bde05977b3631167028862be2a173976ca11",blockCreated:751532},ensRegistry:{address:"0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e"},ensUniversalResolver:{address:"0xc8Af999e38273D658BE1b921b88A9Ddf005769cC",blockCreated:5317080}},testnet:!0});function Qr(e){return typeof e=="string"&&(e=Buffer.from(e,"hex")),e.length===32?e:e.subarray(1,33)}function bt(e,t){if(!e)throw new Error(t)}function Ta(e){return Buffer.concat([Uint8Array.from([192]),Pa(e)])}function Pa(e){const t=Rn.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Rn.encode(e.length,r),Buffer.concat([r,e])}function ka(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const Ot=e=>e.length===64?e:e.slice(2),Ca=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return wt.isPoint(t)}catch{return!1}},La={ethereum:Aa,ethereum_arbitrum:Ba,ethereum_sepolia:Ra,arbitrum_sepolia:Sa,ethereum_localnet:J.EthereumLocalnet,arbitrum_localnet:J.ArbitrumLocalnet,base_sepolia:Ia},Oa=async(e,t)=>{var n;const r=La[e];if(r)try{if(r.id===((n=t.chain)==null?void 0:n.id))return P.Ok({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const i=He.createWalletClient({account:t.account,chain:r,transport:He.custom(window.ethereum)});return P.Ok({message:"Switched chain",walletClient:i})}catch(i){if(Fa(i))try{await t.addChain({chain:r});const a=He.createWalletClient({account:t.account,chain:r,transport:He.custom(window.ethereum)});return P.Ok({message:"Added network",walletClient:a})}catch{return P.Err("Failed to add network")}else return P.Err("Failed to switch network")}else return P.Err("Chain not supported")},Fa=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902,ji=(e,t,r,n)=>e+":"+t.toLowerCase()+"::"+r+":"+n.toLowerCase();var ne=(e=>(e.Created="Created",e.Matched="Matched",e.InitiateDetected="InitiateDetected",e.Initiated="Initiated",e.CounterPartyInitiateDetected="CounterPartyInitiateDetected",e.CounterPartyInitiated="CounterPartyInitiated",e.RedeemDetected="RedeemDetected",e.Redeemed="Redeemed",e.CounterPartyRedeemDetected="CounterPartyRedeemDetected",e.CounterPartyRedeemed="CounterPartyRedeemed",e.Completed="Completed",e.CounterPartySwapExpired="CounterPartySwapExpired",e.Expired="Expired",e.RefundDetected="RefundDetected",e.Refunded="Refunded",e.CounterPartyRefundDetected="CounterPartyRefundDetected",e.CounterPartyRefunded="CounterPartyRefunded",e.Cancelled="Cancelled",e.DeadLineExceeded="DeadLineExceeded",e))(ne||{}),Q=(e=>(e.Idle="Idle",e.InitiateDetected="InitiateDetected",e.Initiated="Initiated",e.RedeemDetected="RedeemDetected",e.Redeemed="Redeemed",e.RefundDetected="RefundDetected",e.Refunded="Refunded",e.Expired="Expired",e))(Q||{});const gn=(e,t,r)=>{const n=cr(e.source_swap,t),i=cr(e.destination_swap,r);if(i===Q.RedeemDetected)return ne.RedeemDetected;if(n===Q.Redeemed)return ne.CounterPartyRedeemed;if(n===Q.RedeemDetected)return ne.CounterPartyRedeemDetected;if(i===Q.Redeemed)return ne.Redeemed;if(n===Q.Refunded)return ne.Refunded;if(n===Q.RefundDetected)return ne.RefundDetected;if(i===Q.Expired)return ne.CounterPartySwapExpired;if(n===Q.Expired)return ne.Expired;if(i===Q.Refunded)return ne.CounterPartyRefunded;if(i===Q.RefundDetected)return ne.CounterPartyRefundDetected;const a=Number(e.create_order.additional_data.deadline);return i===Q.Initiated?ne.CounterPartyInitiated:i===Q.InitiateDetected?ne.CounterPartyInitiateDetected:zt(a,12)?ne.DeadLineExceeded:n===Q.Initiated?ne.Initiated:zt(a,1)?ne.DeadLineExceeded:n===Q.InitiateDetected?ne.InitiateDetected:ne.Matched},cr=(e,t)=>{if(e.redeem_tx_hash)return Number(e.redeem_block_number)?Q.Redeemed:Q.RedeemDetected;if(e.refund_tx_hash)return Number(e.refund_block_number)?Q.Refunded:Q.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return Q.Expired}return e.initiate_tx_hash?Number(e.initiate_block_number)?Q.Initiated:Q.InitiateDetected:Q.Idle},Ua=(e,t,r)=>{const n=gn(e,t,r);return mn(n)},mn=e=>{switch(e){case ne.Matched:return ue.Initiate;case ne.CounterPartyInitiated:case ne.CounterPartyInitiateDetected:case ne.RedeemDetected:return ue.Redeem;case ne.Expired:return ue.Refund;default:return ue.Idle}},zt=(e,t=0)=>{const r=Date.now(),n=e*1e3+t*36e5;return r>=n},Gi=e=>e.filter(t=>{const{source_swap:r,create_order:n}=t,{initiate_tx_hash:i,initiate_block_number:a}=r,{deadline:f}=n.additional_data;return i&&Number(a)?!0:i&&!Number(a)?!zt(Number(f),12):i?!0:!zt(Number(f),1)}),Na=[{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"initiateWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],internalType:"struct HTLC.InitWithSig[]",name:"inits",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],internalType:"struct HTLC.Redeem[]",name:"redeems",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],internalType:"struct HTLC.Refund[]",name:"refunds",type:"tuple[]"}],name:"multicall",outputs:[{internalType:"bool[]",name:"results",type:"bool[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address",name:"initiator",type:"address"},{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"}];class Wi{constructor(t,r,n){this.url=new ge.Url("/relayer",r),this.auth=n,this.order=t}async init(t,r){if(!t.account)return P.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return P.Err("Account address and order initiator mismatch");if(!r){const g=await ge.fetchEVMBlockNumber(t);if(g.error)return P.Err(g.error);r=g.val}if(cr(this.order.source_swap,r)!==Q.Idle)return P.Err("Invalid swap status");const{create_order:i,source_swap:a}=this.order;if(!a.amount||!a.redeemer||!i.timelock||!i.secret_hash)return P.Err("Invalid order");const f=ge.with0x(i.secret_hash),u=BigInt(i.timelock),l=ge.with0x(a.redeemer),b=BigInt(a.amount);try{const g=await this.auth.getToken();if(g.error)return P.Err(g.error);const m=He.getContract({address:ge.with0x(this.order.source_swap.asset),abi:Na,client:t}),v=await m.read.token(),I=await ge.checkAllowanceAndApprove(Number(b),v,this.order.source_swap.asset,t);if(I.error)return P.Err(I.error);const B=await m.read.eip712Domain(),k=await t.signTypedData({account:t.account,domain:{name:B[1],version:B[2],chainId:Number(B[3]),verifyingContract:B[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:l,timelock:u,amount:b,secretHash:f}}),T=await P.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:i.create_id,signature:k,perform_on:"Source"}),headers:{Authorization:ge.Authorization(g.val),"Content-Type":"application/json"}});return T.error?P.Err(T.error):T.result?P.Ok(T.result):P.Err("Init: No result found")}catch(g){return console.log("init error :",g),P.Err(String(g))}}async redeem(t,r){try{const n=await this.auth.getToken();if(n.error)return P.Err(n.error);const i=await P.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:P.trim0x(r),perform_on:"Destination"}),headers:{Authorization:ge.Authorization(n.val),"Content-Type":"application/json"}});return i.error?P.Err(i.error):i.result?P.Ok(i.result):P.Err("Redeem: No result found")}catch(n){return P.Err(String(n))}}}const Ma=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Da=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),$a=Buffer.concat([Ma,Da]),Ha=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),$n={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function za(){const e=gi.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=wt.pointMultiply(Buffer.concat([Buffer.from("04","hex"),$a]),e);if(!t)throw new Error($n.failedToCreateInternalPubkey);const r=wt.pointAdd(Ha,t);if(!r)throw new Error($n.failedToCreateInternalPubkey);return Qr(Buffer.from(r))}const _e={secretMismatch:"invalid secret",secretHashLenMismatch:"secret hash should be 32 bytes",pubkeyLenMismatch:"pubkey should be 32 bytes",zeroOrNegativeExpiry:"expiry should be greater than 0",htlcAddressGenerationFailed:"failed to generate htlc address",notFunded:"address not funded",noCounterpartySigs:"counterparty signatures are required",counterPartySigNotFound:e=>"counterparty signature not found for utxo "+e,invalidCounterpartySigForUTXO:e=>"invalid counterparty signature for utxo "+e,htlcNotExpired:e=>`HTLC not expired, need more ${e} blocks`,controlBlockGenerationFailed:"failed to generate control block",invalidLeaf:"invalid leaf"},rr=192;ye.initEccLib(wt);class lr{constructor(t,r,n,i,a,f,u,l){this.secretHash=n,this.redeemerPubkey=i,this.initiatorPubkey=a,this.expiry=f,this.signer=t,this.network=u,this.internalPubkey=za(),this.initiateAmount=r,this.utxoHashes=l}static async from(t,r,n,i,a,f,u){n=n.startsWith("0x")?n.slice(2):n,bt(n.length===64,_e.secretHashLenMismatch),bt(i.length===64||i.length===66,`initiator ${_e.pubkeyLenMismatch}`),bt(a.length===64||a.length===66,`redeemer ${_e.pubkeyLenMismatch}`),bt(f>0,_e.zeroOrNegativeExpiry);const l=await t.getNetwork();return new lr(t,r,n,Qr(a).toString("hex"),Qr(i).toString("hex"),f,l,u)}address(){const{address:t}=ye.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!t)throw new Error(_e.htlcAddressGenerationFailed);return t}id(){return this.address()}async _buildRawTx(t,r){const n=new ye.Transaction;n.version=2;const i=this.address(),a=await this.signer.getProvider();let f=[];if(this.utxoHashes&&this.utxoHashes.length>0)for(const l of this.utxoHashes){const b=await a.getTransaction(l);for(let g=0;g<b.vout.length;g++){const m=b.vout[g];m.scriptpubkey_address===i&&f.push({txid:b.txid,vout:g,value:m.value,status:{confirmed:!1}})}}else f=await a.getUTXOs(i);const u=f.reduce((l,b)=>l+b.value,0);if(u===0)throw new Error(`${i} ${_e.notFunded}`);for(let l=0;l<f.length;l++)n.addInput(Buffer.from(f[l].txid,"hex").reverse(),f[l].vout);return r??(r=await a.suggestFee(i,u,An.Urgency.MEDIUM)),n.addOutput(ye.address.toOutputScript(t,this.network),u-r),{tx:n,usedUtxos:f}}async buildRawTx(t){return await this._buildRawTx(await this.signer.getAddress(),t)}getOutputScript(){return ye.address.toOutputScript(this.address(),this.network)}async init(t){return t??(t=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,An.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,t)}async instantRefund(t,r){bt(t.length>0,_e.noCounterpartySigs);const{tx:n,usedUtxos:i}=await this.buildRawTx(r);for(const m of i)if(!t.find(v=>v.utxo===m.txid))throw new Error(_e.counterPartySigNotFound(m.txid));const a=this.getOutputScript(),f=ye.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),l=i.map(m=>m.value),b=Fr(a,i.length);for(let m=0;m<n.ins.length;m++){const v=n.hashForWitnessV1(m,b,l,f,u);if(!wt.verifySchnorr(v,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[m].sig,"hex")))throw new Error(_e.invalidCounterpartySigForUTXO(t[m].utxo));const I=await this.signer.signSchnorr(v),B=Buffer.from(n.ins[m].hash).reverse().toString("hex"),k=t.find(T=>T.utxo===B);if(!k)throw new Error(_e.counterPartySigNotFound(B));n.setWitness(m,[Buffer.from(k.sig,"hex"),I,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(n.toHex())}async redeem(t,r,n){bt(ye.crypto.sha256(Buffer.from(t,"hex")).toString("hex")===this.secretHash,_e.secretMismatch);const{tx:i,usedUtxos:a}=await this._buildRawTx(r??await this.signer.getAddress(),n),f=this.leafHash(1),u=a.map(m=>m.value),l=Fr(this.getOutputScript(),a.length),b=ye.Transaction.SIGHASH_DEFAULT;for(let m=0;m<i.ins.length;m++){const v=i.hashForWitnessV1(m,l,u,b,f),I=await this.signer.signSchnorr(v);i.setWitness(m,[I,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(i.toHex())}async refund(t,r){const{tx:n,usedUtxos:i}=await this._buildRawTx(t??await this.signer.getAddress(),r),[a,f]=await this.canRefund(i);if(!a)throw new Error(_e.htlcNotExpired(f));const u=this.leafHash(0),l=i.map(v=>v.value),b=Fr(this.getOutputScript(),i.length),g=ye.Transaction.SIGHASH_DEFAULT;console.log("hashType :",g),console.log("values :",l),console.log("outputs :",b),console.log("tx.ins.length :",n.ins.length),console.log("refundLeafHash :",u);for(let v=0;v<n.ins.length;v++){n.ins[v].sequence=this.expiry;const I=n.hashForWitnessV1(v,b,l,g,u),B=await this.signer.signSchnorr(I);n.setWitness(v,[B,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(n.toHex())}async canRefund(t){const n=await(await this.signer.getProvider()).getLatestTip();for(const i of t){let a=0;if(i.status.confirmed&&i.status.block_height+this.expiry>n?a=i.status.block_height+this.expiry-n+1:i.status.confirmed||(a=this.expiry+1),a>0)return[!1,a]}return[!0,0]}generateControlBlockFor(t){let r;switch(t){case 1:r=this.redeemLeaf();break;case 0:r=this.refundLeaf();break;case 2:r=this.instantRefundLeaf();break;default:throw new Error(_e.invalidLeaf)}const n=ye.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:rr}});if(!n.witness)throw new Error(_e.controlBlockGenerationFailed);return n.witness[n.witness.length-1]}leafHash(t){let r=this.redeemLeaf();return t===0&&(r=this.refundLeaf()),t===2&&(r=this.instantRefundLeaf()),ye.crypto.taggedHash("TapLeaf",Ta(r))}refundLeaf(){return ye.script.fromASM(`
|
|
5
|
-
${ye.script.number.encode(this.expiry).toString("hex")}
|
|
1
|
+
"use strict";var hi=Object.defineProperty;var di=(e,t,r)=>t in e?hi(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var nt=(e,t,r)=>di(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const I=require("@catalogfi/utils"),Y=require("@gardenfi/orderbook"),be=require("@gardenfi/utils"),Ne=require("viem"),pi=require("varuint-bitcoin"),bi=require("tiny-secp256k1"),Ur=require("@catalogfi/wallets"),wn=require("bitcoinjs-lib"),yi=require("bignumber.js");function Tr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const i=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,i.get?i:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const $r=Tr(pi),ft=Tr(bi),pe=Tr(wn);var Nt=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(Nt||{}),se=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(se||{});function wr(e){return typeof e=="string"&&(e=Buffer.from(e,"hex")),e.length===32?e:e.subarray(1,33)}function it(e,t){if(!e)throw new Error(t)}function _i(e){return Buffer.concat([Uint8Array.from([192]),gi(e)])}function gi(e){const t=$r.encodingLength(e.length),r=Buffer.allocUnsafe(t);return $r.encode(e.length,r),Buffer.concat([r,e])}function wi(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const yt=e=>e.length===64?e:e.slice(2),mi=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return ft.isPoint(t)}catch{return!1}},vi=async(e,t)=>{var i;const r=Y.evmToViemChainMap[e];if(r)try{if(r.id===((i=t.chain)==null?void 0:i.id))return I.Ok({message:"Already on the network",walletClient:t});await t.switchChain({id:r.id});const o=Ne.createWalletClient({account:t.account,chain:r,transport:Ne.custom(window.ethereum)});return I.Ok({message:"Switched chain",walletClient:o})}catch(o){if(xi(o))try{await t.addChain({chain:r});const s=Ne.createWalletClient({account:t.account,chain:r,transport:Ne.custom(window.ethereum)});return I.Ok({message:"Added network",walletClient:s})}catch{return I.Err("Failed to add network")}else return I.Err("Failed to switch network")}else return I.Err("Chain not supported")},xi=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902,mn=(e,t,r,i)=>e+":"+t.toLowerCase()+"::"+r+":"+i.toLowerCase();var te=(e=>(e.Created="Created",e.Matched="Matched",e.InitiateDetected="InitiateDetected",e.Initiated="Initiated",e.CounterPartyInitiateDetected="CounterPartyInitiateDetected",e.CounterPartyInitiated="CounterPartyInitiated",e.RedeemDetected="RedeemDetected",e.Redeemed="Redeemed",e.CounterPartyRedeemDetected="CounterPartyRedeemDetected",e.CounterPartyRedeemed="CounterPartyRedeemed",e.Completed="Completed",e.CounterPartySwapExpired="CounterPartySwapExpired",e.Expired="Expired",e.RefundDetected="RefundDetected",e.Refunded="Refunded",e.CounterPartyRefundDetected="CounterPartyRefundDetected",e.CounterPartyRefunded="CounterPartyRefunded",e.Cancelled="Cancelled",e.DeadLineExceeded="DeadLineExceeded",e))(te||{}),X=(e=>(e.Idle="Idle",e.InitiateDetected="InitiateDetected",e.Initiated="Initiated",e.RedeemDetected="RedeemDetected",e.Redeemed="Redeemed",e.RefundDetected="RefundDetected",e.Refunded="Refunded",e.Expired="Expired",e))(X||{});const Ir=(e,t,r)=>{const i=Dt(e.source_swap,t),o=Dt(e.destination_swap,r);if(o===X.RedeemDetected)return te.RedeemDetected;if(i===X.Redeemed)return te.CounterPartyRedeemed;if(i===X.RedeemDetected)return te.CounterPartyRedeemDetected;if(o===X.Redeemed)return te.Redeemed;if(i===X.Refunded)return te.Refunded;if(i===X.RefundDetected)return te.RefundDetected;if(o===X.Expired)return te.CounterPartySwapExpired;if(i===X.Expired)return te.Expired;if(o===X.Refunded)return te.CounterPartyRefunded;if(o===X.RefundDetected)return te.CounterPartyRefundDetected;const s=Number(e.create_order.additional_data.deadline);return o===X.Initiated?te.CounterPartyInitiated:o===X.InitiateDetected?te.CounterPartyInitiateDetected:Bt(s,12)?te.DeadLineExceeded:i===X.Initiated?te.Initiated:Bt(s,1)?te.DeadLineExceeded:i===X.InitiateDetected?te.InitiateDetected:te.Matched},Dt=(e,t)=>{if(e.redeem_tx_hash)return Number(e.redeem_block_number)?X.Redeemed:X.RedeemDetected;if(e.refund_tx_hash)return Number(e.refund_block_number)?X.Refunded:X.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return X.Expired}return e.initiate_tx_hash?Number(e.initiate_block_number)?X.Initiated:X.InitiateDetected:X.Idle},Ei=(e,t,r)=>{const i=Ir(e,t,r);return kr(i)},kr=e=>{switch(e){case te.Matched:return se.Initiate;case te.CounterPartyInitiated:case te.CounterPartyInitiateDetected:case te.RedeemDetected:return se.Redeem;case te.Expired:return se.Refund;default:return se.Idle}},Bt=(e,t=0)=>{const r=Date.now(),i=e*1e3+t*36e5;return r>=i},vn=e=>e.filter(t=>{const{source_swap:r,create_order:i}=t,{initiate_tx_hash:o,initiate_block_number:s}=r,{deadline:c}=i.additional_data;return o&&Number(s)?!0:o&&!Number(s)?!Bt(Number(c),12):o?!0:!Bt(Number(c),1)}),Bi=[{inputs:[{internalType:"address",name:"token_",type:"address"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"InvalidShortString",type:"error"},{inputs:[{internalType:"string",name:"str",type:"string"}],name:"StringTooLong",type:"error"},{anonymous:!1,inputs:[],name:"EIP712DomainChanged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"uint256",name:"amount",type:"uint256"}],name:"Initiated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"},{indexed:!0,internalType:"bytes32",name:"secretHash",type:"bytes32"},{indexed:!1,internalType:"bytes",name:"secret",type:"bytes"}],name:"Redeemed",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"Refunded",type:"event"},{inputs:[],name:"eip712Domain",outputs:[{internalType:"bytes1",name:"fields",type:"bytes1"},{internalType:"string",name:"name",type:"string"},{internalType:"string",name:"version",type:"string"},{internalType:"uint256",name:"chainId",type:"uint256"},{internalType:"address",name:"verifyingContract",type:"address"},{internalType:"bytes32",name:"salt",type:"bytes32"},{internalType:"uint256[]",name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"}],name:"initiate",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"initiateWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"instantRefund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{components:[{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"expiry",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"},{internalType:"bytes32",name:"secretHash",type:"bytes32"},{internalType:"bytes",name:"signature",type:"bytes"}],internalType:"struct HTLC.InitWithSig[]",name:"inits",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],internalType:"struct HTLC.Redeem[]",name:"redeems",type:"tuple[]"},{components:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],internalType:"struct HTLC.Refund[]",name:"refunds",type:"tuple[]"}],name:"multicall",outputs:[{internalType:"bool[]",name:"results",type:"bool[]"}],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"orders",outputs:[{internalType:"bool",name:"isFulfilled",type:"bool"},{internalType:"address",name:"initiator",type:"address"},{internalType:"address",name:"redeemer",type:"address"},{internalType:"uint256",name:"initiatedAt",type:"uint256"},{internalType:"uint256",name:"timelock",type:"uint256"},{internalType:"uint256",name:"amount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"},{internalType:"bytes",name:"secret",type:"bytes"}],name:"redeem",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"orderID",type:"bytes32"}],name:"refund",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"token",outputs:[{internalType:"contract IERC20",name:"",type:"address"}],stateMutability:"view",type:"function"}];class xn{constructor(t,r,i){this.url=new be.Url("/relayer",r),this.auth=i,this.order=t}async init(t,r){if(!t.account)return I.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return I.Err("Account address and order initiator mismatch");if(!r){const m=await be.fetchEVMBlockNumber(t);if(m.error)return I.Err(m.error);r=m.val}if(Dt(this.order.source_swap,r)!==X.Idle)return I.Err("Invalid swap status");const{create_order:o,source_swap:s}=this.order;if(!s.amount||!s.redeemer||!o.timelock||!o.secret_hash)return I.Err("Invalid order");const c=be.with0x(o.secret_hash),u=BigInt(o.timelock),p=be.with0x(s.redeemer),g=BigInt(s.amount);try{const m=await this.auth.getToken();if(m.error)return I.Err(m.error);const v=Ne.getContract({address:be.with0x(this.order.source_swap.asset),abi:Bi,client:t}),A=await v.read.token(),k=await be.checkAllowanceAndApprove(Number(g),A,this.order.source_swap.asset,t);if(k.error)return I.Err(k.error);const E=await v.read.eip712Domain(),O=await t.signTypedData({account:t.account,domain:{name:E[1],version:E[2],chainId:Number(E[3]),verifyingContract:E[4]},types:{Initiate:[{name:"redeemer",type:"address"},{name:"timelock",type:"uint256"},{name:"amount",type:"uint256"},{name:"secretHash",type:"bytes32"}]},primaryType:"Initiate",message:{redeemer:p,timelock:u,amount:g,secretHash:c}}),T=await I.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:o.create_id,signature:O,perform_on:"Source"}),headers:{Authorization:be.Authorization(m.val),"Content-Type":"application/json"}});return T.error?I.Err(T.error):T.result?I.Ok(T.result):I.Err("Init: No result found")}catch(m){return console.log("init error :",m),I.Err(String(m))}}async redeem(t,r){try{const i=await this.auth.getToken();if(i.error)return I.Err(i.error);const o=await I.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:I.trim0x(r),perform_on:"Destination"}),headers:{Authorization:be.Authorization(i.val),"Content-Type":"application/json"}});return o.error?I.Err(o.error):o.result?I.Ok(o.result):I.Err("Redeem: No result found")}catch(i){return I.Err(String(i))}}}const Ri=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Si=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),Ai=Buffer.concat([Ri,Si]),Ti=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),Hr={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function Ii(){const e=wn.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=ft.pointMultiply(Buffer.concat([Buffer.from("04","hex"),Ai]),e);if(!t)throw new Error(Hr.failedToCreateInternalPubkey);const r=ft.pointAdd(Ti,t);if(!r)throw new Error(Hr.failedToCreateInternalPubkey);return wr(Buffer.from(r))}const _e={secretMismatch:"invalid secret",secretHashLenMismatch:"secret hash should be 32 bytes",pubkeyLenMismatch:"pubkey should be 32 bytes",zeroOrNegativeExpiry:"expiry should be greater than 0",htlcAddressGenerationFailed:"failed to generate htlc address",notFunded:"address not funded",noCounterpartySigs:"counterparty signatures are required",counterPartySigNotFound:e=>"counterparty signature not found for utxo "+e,invalidCounterpartySigForUTXO:e=>"invalid counterparty signature for utxo "+e,htlcNotExpired:e=>`HTLC not expired, need more ${e} blocks`,controlBlockGenerationFailed:"failed to generate control block",invalidLeaf:"invalid leaf"},Lt=192;pe.initEccLib(ft);class Ut{constructor(t,r,i,o,s,c,u,p){this.secretHash=i,this.redeemerPubkey=o,this.initiatorPubkey=s,this.expiry=c,this.signer=t,this.network=u,this.internalPubkey=Ii(),this.initiateAmount=r,this.utxoHashes=p}static async from(t,r,i,o,s,c,u){i=i.startsWith("0x")?i.slice(2):i,it(i.length===64,_e.secretHashLenMismatch),it(o.length===64||o.length===66,`initiator ${_e.pubkeyLenMismatch}`),it(s.length===64||s.length===66,`redeemer ${_e.pubkeyLenMismatch}`),it(c>0,_e.zeroOrNegativeExpiry);const p=await t.getNetwork();return new Ut(t,r,i,wr(s).toString("hex"),wr(o).toString("hex"),c,p,u)}address(){const{address:t}=pe.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!t)throw new Error(_e.htlcAddressGenerationFailed);return t}id(){return this.address()}async _buildRawTx(t,r){const i=new pe.Transaction;i.version=2;const o=this.address(),s=await this.signer.getProvider();let c=[];if(this.utxoHashes&&this.utxoHashes.length>0)for(const p of this.utxoHashes){const g=await s.getTransaction(p);for(let m=0;m<g.vout.length;m++){const v=g.vout[m];v.scriptpubkey_address===o&&c.push({txid:g.txid,vout:m,value:v.value,status:{confirmed:!1}})}}else c=await s.getUTXOs(o);const u=c.reduce((p,g)=>p+g.value,0);if(u===0)throw new Error(`${o} ${_e.notFunded}`);for(let p=0;p<c.length;p++)i.addInput(Buffer.from(c[p].txid,"hex").reverse(),c[p].vout);return r??(r=await s.suggestFee(o,u,Ur.Urgency.MEDIUM)),i.addOutput(pe.address.toOutputScript(t,this.network),u-r),{tx:i,usedUtxos:c}}async buildRawTx(t){return await this._buildRawTx(await this.signer.getAddress(),t)}getOutputScript(){return pe.address.toOutputScript(this.address(),this.network)}async init(t){return t??(t=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,Ur.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,t)}async instantRefund(t,r){it(t.length>0,_e.noCounterpartySigs);const{tx:i,usedUtxos:o}=await this.buildRawTx(r);for(const v of o)if(!t.find(A=>A.utxo===v.txid))throw new Error(_e.counterPartySigNotFound(v.txid));const s=this.getOutputScript(),c=pe.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),p=o.map(v=>v.value),g=nr(s,o.length);for(let v=0;v<i.ins.length;v++){const A=i.hashForWitnessV1(v,g,p,c,u);if(!ft.verifySchnorr(A,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[v].sig,"hex")))throw new Error(_e.invalidCounterpartySigForUTXO(t[v].utxo));const k=await this.signer.signSchnorr(A),E=Buffer.from(i.ins[v].hash).reverse().toString("hex"),O=t.find(T=>T.utxo===E);if(!O)throw new Error(_e.counterPartySigNotFound(E));i.setWitness(v,[Buffer.from(O.sig,"hex"),k,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(i.toHex())}async redeem(t,r,i){it(pe.crypto.sha256(Buffer.from(t,"hex")).toString("hex")===this.secretHash,_e.secretMismatch);const{tx:o,usedUtxos:s}=await this._buildRawTx(r??await this.signer.getAddress(),i),c=this.leafHash(1),u=s.map(v=>v.value),p=nr(this.getOutputScript(),s.length),g=pe.Transaction.SIGHASH_DEFAULT;for(let v=0;v<o.ins.length;v++){const A=o.hashForWitnessV1(v,p,u,g,c),k=await this.signer.signSchnorr(A);o.setWitness(v,[k,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(o.toHex())}async refund(t,r){const{tx:i,usedUtxos:o}=await this._buildRawTx(t??await this.signer.getAddress(),r),[s,c]=await this.canRefund(o);if(!s)throw new Error(_e.htlcNotExpired(c));const u=this.leafHash(0),p=o.map(A=>A.value),g=nr(this.getOutputScript(),o.length),m=pe.Transaction.SIGHASH_DEFAULT;for(let A=0;A<i.ins.length;A++){i.ins[A].sequence=this.expiry;const k=i.hashForWitnessV1(A,g,p,m,u),E=await this.signer.signSchnorr(k);i.setWitness(A,[E,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(i.toHex())}async canRefund(t){const i=await(await this.signer.getProvider()).getLatestTip();for(const o of t){let s=0;if(o.status.confirmed&&o.status.block_height+this.expiry>i?s=o.status.block_height+this.expiry-i+1:o.status.confirmed||(s=this.expiry+1),s>0)return[!1,s]}return[!0,0]}generateControlBlockFor(t){let r;switch(t){case 1:r=this.redeemLeaf();break;case 0:r=this.refundLeaf();break;case 2:r=this.instantRefundLeaf();break;default:throw new Error(_e.invalidLeaf)}const i=pe.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:Lt}});if(!i.witness)throw new Error(_e.controlBlockGenerationFailed);return i.witness[i.witness.length-1]}leafHash(t){let r=this.redeemLeaf();return t===0&&(r=this.refundLeaf()),t===2&&(r=this.instantRefundLeaf()),pe.crypto.taggedHash("TapLeaf",_i(r))}refundLeaf(){return pe.script.fromASM(`
|
|
2
|
+
${pe.script.number.encode(this.expiry).toString("hex")}
|
|
6
3
|
OP_CHECKSEQUENCEVERIFY
|
|
7
4
|
OP_DROP
|
|
8
5
|
${this.initiatorPubkey}
|
|
9
6
|
OP_CHECKSIG
|
|
10
|
-
`.trim().replace(/\s+/g," "))}redeemLeaf(){return
|
|
7
|
+
`.trim().replace(/\s+/g," "))}redeemLeaf(){return pe.script.fromASM(`
|
|
11
8
|
OP_SHA256
|
|
12
9
|
${this.secretHash}
|
|
13
10
|
OP_EQUALVERIFY
|
|
14
11
|
${this.redeemerPubkey}
|
|
15
12
|
OP_CHECKSIG
|
|
16
|
-
`.trim().replace(/\s+/g," "))}instantRefundLeaf(){return
|
|
13
|
+
`.trim().replace(/\s+/g," "))}instantRefundLeaf(){return pe.script.fromASM(`
|
|
17
14
|
${this.initiatorPubkey}
|
|
18
15
|
OP_CHECKSIG
|
|
19
16
|
${this.redeemerPubkey}
|
|
20
17
|
OP_CHECKSIGADD
|
|
21
18
|
OP_2
|
|
22
19
|
OP_NUMEQUAL
|
|
23
|
-
`.trim().replace(/\s+/g," "))}leaves(){return[{version:rr,output:this.redeemLeaf()},[{version:rr,output:this.refundLeaf()},{version:rr,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),n=this.leafHash(2),i=this.leafHash(0);switch(t){case 1:{const a=ka(i,n);return[ye.crypto.taggedHash("TapBranch",Buffer.concat(a))]}case 0:return[n,r];case 2:return[i,r];default:throw new Error(_e.invalidLeaf)}}}function Fr(e,t){const r=[];for(let n=0;n<t;n++)r.push(e);return r}class ja{constructor(){this.cache={}}set(t,r,n,i){const a={txHash:n,timeStamp:Date.now(),btcRedeemUTXO:i};this.cache[`${r}_${t.create_order.create_id}`]=a}get(t,r){return this.cache[`${r}_${t.create_order.create_id}`]||null}remove(t,r){delete this.cache[`${r}_${t.create_order.create_id}`]}}class Ga{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.useRelay=!0,this.orderBook=new J.Orderbook({url:t.orderbookURl,walletClient:t.wallets.evmWallet,auth:t.auth}),this.quote=t.quote,this.secretManager=t.secretManager,this.wallets=t.wallets,this.orderbookUrl=t.orderbookURl,this.auth=t.auth,this.orderExecutorCache=new ja,!t.wallets.evmWallet.account)throw new Error("Account not found in evmWallet");this.evmAddress=t.wallets.evmWallet.account.address,this.blockNumberFetcher=t.blockNumberFetcher}setUseRelay(t){this.useRelay=t}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return P.Err(r.error);const{sendAddress:n,receiveAddress:i,timelock:a}=r.val,f=await this.orderBook.getOrdersCount(this.evmAddress);if(f.error)return P.Err(f.error);const u=f.val+1,l=this.secretManager.generateSecret(u);if(l.error)return P.Err(l.error);const{strategyId:b,btcAddress:g}=t.additionalData,m={strategy_id:b,...g&&{bitcoin_optional_recipient:g}},v={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:n,initiator_destination_address:i,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:u.toString(),timelock:a,secret_hash:P.trim0x(l.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:m},I=await this.quote.getAttestedQuote(v);if(I.error)return P.Err(I.error);const B=await this.orderBook.createOrder(I.val);if(B.error)return P.Err(B.error);const k=await this.pollOrder(B.val);return k.error?P.Err(k.error):P.Ok(k.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return P.Err("Source and destination assets cannot be the same");if(J.isMainnet(t.fromAsset.chain)&&!J.isMainnet(t.toAsset.chain)||!J.isMainnet(t.fromAsset.chain)&&J.isMainnet(t.toAsset.chain))return P.Err("Both assets should be on the same network (either mainnet or testnet)");if(J.isBitcoin(t.fromAsset.chain)||J.isBitcoin(t.toAsset.chain)){if(!this.wallets.btcWallet)return P.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return P.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return P.Err(r.error);const n=await this.getAddresses(t.toAsset.chain);if(n.error)return P.Err(n.error);const i=this.validateAmount(t.sendAmount);if(i.error)return P.Err(i.error);const a=this.validateAmount(t.receiveAmount);if(a.error)return P.Err(a.error);if(i<a)return P.Err("Send amount should be greater than receive amount");const f=this.getTimelock(t.fromAsset.chain);return f?P.Ok({sendAddress:r.val,receiveAddress:n.val,timelock:t.timelock??f}):P.Err("Unsupported chain for timelock")}async getAddresses(t){var n;switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return this.wallets.evmWallet.account?P.Ok(this.wallets.evmWallet.account.address):P.Err("EVM Wallet not found");case J.BlockchainType.Bitcoin:{const i=await((n=this.wallets.btcWallet)==null?void 0:n.getPublicKey());return!i||!Ca(i)?P.Err("Invalid btc public key"):P.Ok(Ot(i))}default:return P.Err("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return P.Err("Invalid amount ",t);const r=new Ds(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?P.Err("Invalid amount ",t):P.Ok(r)}getTimelock(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return or.evm;case J.BlockchainType.Bitcoin:return or.btc;default:return}}async pollOrder(t){let r=await this.orderBook.getOrder(t,!0),n=0;for(;n<this.getOrderThreshold;){if(await ge.sleep(1e3),n++,r.error){if(!r.error.includes("result is undefined"))return P.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return P.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return P.Err(`Order not found, createOrder id: ${t}`)}emit(t,...r){(this.eventListeners.get(t)??[]).forEach(i=>{i(...r)})}async execute(t=5e3){return await this.orderBook.subscribeToOrders(!0,t,async r=>{const n=Gi(r.data),i=await this.assignOrderStatus(n);this.emit("onPendingOrdersChanged",i);for(let a=0;a<i.length;a++){const f=i[a];switch(mn(f.status)){case ue.Redeem:{const l=this.secretManager.generateSecret(Number(f.create_order.nonce));if(l.error){this.emit("error",f,l.error);return}switch(J.getBlockchainType(f.destination_swap.chain)){case J.BlockchainType.EVM:{await this.evmRedeem(f,l.val.secret);break}case J.BlockchainType.Bitcoin:{const b=this.getWallet(f.destination_swap.chain);if(b.error){this.emit("error",f,b.error);return}await this.btcRedeem(b.val,f,l.val.secret);break}default:this.emit("error",f,"Unsupported chain: "+f.destination_swap.chain)}break}case ue.Refund:{switch(J.getBlockchainType(f.source_swap.chain)){case J.BlockchainType.EVM:{this.emit("error",f,"EVM refund is automatically done by relay service");break}case J.BlockchainType.Bitcoin:{const l=this.getWallet(f.source_swap.chain);if(l.error){this.emit("error",f,l.error);return}await this.btcRefund(l.val,f);break}default:this.emit("error",f,"Unsupported chain: "+f.source_swap.chain)}break}}}},{per_page:500},!0)}async evmRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing evm redeem"),this.orderExecutorCache.get(t,ue.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}const a=await new Wi(t,this.orderbookUrl,this.auth).redeem(t.create_order.create_id,r);if(a.error){this.emit("error",t,a.error),a.error.includes("Order already redeemed")&&this.orderExecutorCache.set(t,ue.Redeem,t.destination_swap.redeem_tx_hash);return}this.emit("success",t,ue.Redeem,a.val),this.orderExecutorCache.set(t,ue.Redeem,a.val)}async btcRedeem(t,r,n){var u,l;const i=this.orderExecutorCache.get(r,ue.Redeem),a=(u=r.destination_swap.initiate_tx_hash.split(",").at(-1))==null?void 0:u.split(":").at(0);if(!a){this.emit("error",r,"Failed to get initiate_tx_hash");return}let f=!1;if(i)if(i.btcRedeemUTXO&&i.btcRedeemUTXO!==a)f=!0,this.emit("log",r.create_order.create_id,"rbf btc redeem");else{this.emit("log",r.create_order.create_id,"btcRedeem: already redeemed");return}else if(r.destination_swap.redeem_tx_hash&&!Number(r.destination_swap.redeem_block_number))try{const b=await(await t.getProvider()).getTransaction(r.destination_swap.redeem_tx_hash);let g=!1;for(const m of b.vin)if(m.txid===a){g=!0;break}if(g){this.emit("log",r.create_order.create_id,"already a valid redeem"),this.orderExecutorCache.set(r,ue.Redeem,r.destination_swap.redeem_tx_hash,a);return}f=!0}catch(b){if(b.message.includes("Transaction not found"))f=!0;else{this.emit("error",r,"Failed to get redeem tx: "+b);return}}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const g=await(await lr.from(t,Number(r.destination_swap.amount),r.create_order.secret_hash,Ot(r.destination_swap.initiator),Ot(r.destination_swap.redeemer),r.destination_swap.timelock,f?[a]:[])).redeem(P.trim0x(n),(l=r.create_order.additional_data)==null?void 0:l.bitcoin_optional_recipient);f?this.emit("log",r.create_order.create_id,"rbf: btc redeem success"):this.emit("success",r,ue.Redeem,g),this.orderExecutorCache.set(r,ue.Redeem,g,a)}catch(b){this.emit("error",r,"Failed btc redeem: "+b)}}async btcRefund(t,r){var n;if(!this.orderExecutorCache.get(r,ue.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const a=await(await lr.from(t,Number(r.source_swap.amount),r.create_order.secret_hash,Ot(r.source_swap.initiator),Ot(r.source_swap.redeemer),r.source_swap.timelock)).refund((n=r.create_order.additional_data)==null?void 0:n.bitcoin_optional_recipient);this.emit("success",r,ue.Refund,a),this.orderExecutorCache.set(r,ue.Refund,a)}catch(i){this.emit("error",r,"Failed btc refund: "+i)}}}getWallet(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return P.Ok(this.wallets.evmWallet);case J.BlockchainType.Bitcoin:return P.Ok(this.wallets.btcWallet);default:return P.Err("Unsupported chain for wallet")}}on(t,r){const n=this.eventListeners.get(t)??[];n.push(r),this.eventListeners.set(t,n)}off(t,r){const n=this.eventListeners.get(t)??[],i=n.indexOf(r);i!==-1&&n.splice(i,1)}async fetchCurrentBlockNumbers(t,r){if(!r||!r.source||!r.destination)return P.Err("Provide wallets to fetch the current block number");const n=J.isBitcoin(t.source_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.source.getProvider()):await ge.fetchEVMBlockNumber(r.source);if(n.error)return P.Err(n.error);const i=J.isBitcoin(t.destination_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.destination.getProvider()):await ge.fetchEVMBlockNumber(r.destination);return i.error?P.Err(i.error):P.Ok({source:n.val,destination:i.val})}async assignOrderStatus(t){var i;const r=await((i=this.blockNumberFetcher)==null?void 0:i.fetchBlockNumbers()),n=[];for(let a=0;a<t.length;a++){const f=t[a],u=f.source_swap.chain,l=f.destination_swap.chain,b=this.getWallet(u),g=this.getWallet(l);if(b.error||g.error||!b.val||!g.val){this.emit("error",f,"Source or Destination Wallet not found while executing order");continue}let m=r==null?void 0:r.val[u],v=r==null?void 0:r.val[l];if(!m||!v){const B=await this.fetchCurrentBlockNumbers(f,{source:b.val,destination:g.val});if(B.error){this.emit("error",f,"Error while fetching CurrentBlockNumbers: "+B.error);continue}m=B.val.source,v=B.val.destination}const I=gn(f,m,v);n.push({...f,status:I})}return n}}class Wa{constructor(t,r){this.url=new ge.Url("/blocknumber/"+r,t)}async fetchBlockNumbers(){try{const t=await P.Fetcher.get(this.url);return P.Ok(t)}catch(t){return P.Err("Failed to fetch block numbers",t)}}}var Qe=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function qa(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function n(){return this instanceof n?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(n){var i=Object.getOwnPropertyDescriptor(e,n);Object.defineProperty(r,n,i.get?i:{enumerable:!0,get:function(){return e[n]}})}),r}var qi={},vt={},Et={};Object.defineProperty(Et,"__esModule",{value:!0});Et.testnet=Et.bitcoin=void 0;Et.bitcoin={messagePrefix:`Bitcoin Signed Message:
|
|
24
|
-
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};
|
|
25
|
-
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var
|
|
20
|
+
`.trim().replace(/\s+/g," "))}leaves(){return[{version:Lt,output:this.redeemLeaf()},[{version:Lt,output:this.refundLeaf()},{version:Lt,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),i=this.leafHash(2),o=this.leafHash(0);switch(t){case 1:{const s=wi(o,i);return[pe.crypto.taggedHash("TapBranch",Buffer.concat(s))]}case 0:return[i,r];case 2:return[o,r];default:throw new Error(_e.invalidLeaf)}}}function nr(e,t){const r=[];for(let i=0;i<t;i++)r.push(e);return r}class ki{constructor(){this.cache={}}set(t,r,i,o){const s={txHash:i,timeStamp:Date.now(),btcRedeemUTXO:o};this.cache[`${r}_${t.create_order.create_id}`]=s}get(t,r){return this.cache[`${r}_${t.create_order.create_id}`]||null}remove(t,r){delete this.cache[`${r}_${t.create_order.create_id}`]}}class Ci{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.useRelay=!0,this.orderBook=new Y.Orderbook({url:t.orderbookURl,walletClient:t.wallets.evmWallet,auth:t.auth}),this.quote=t.quote,this.secretManager=t.secretManager,this.wallets=t.wallets,this.orderbookUrl=t.orderbookURl,this.auth=t.auth,this.orderExecutorCache=new ki,!t.wallets.evmWallet.account)throw new Error("Account not found in evmWallet");this.evmAddress=t.wallets.evmWallet.account.address,this.blockNumberFetcher=t.blockNumberFetcher}setUseRelay(t){this.useRelay=t}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return I.Err(r.error);const{sendAddress:i,receiveAddress:o,timelock:s}=r.val,c=await this.orderBook.getOrdersCount(this.evmAddress);if(c.error)return I.Err(c.error);const u=c.val+1,p=this.secretManager.generateSecret(u);if(p.error)return I.Err(p.error);const{strategyId:g,btcAddress:m}=t.additionalData,v={strategy_id:g,...m&&{bitcoin_optional_recipient:m}},A={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:i,initiator_destination_address:o,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:u.toString(),timelock:s,secret_hash:I.trim0x(p.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:v},k=await this.quote.getAttestedQuote(A);if(k.error)return I.Err(k.error);const E=await this.orderBook.createOrder(k.val);if(E.error)return I.Err(E.error);const O=await this.pollOrder(E.val);return O.error?I.Err(O.error):I.Ok(O.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return I.Err("Source and destination assets cannot be the same");if(Y.isMainnet(t.fromAsset.chain)&&!Y.isMainnet(t.toAsset.chain)||!Y.isMainnet(t.fromAsset.chain)&&Y.isMainnet(t.toAsset.chain))return I.Err("Both assets should be on the same network (either mainnet or testnet)");if(Y.isBitcoin(t.fromAsset.chain)||Y.isBitcoin(t.toAsset.chain)){if(!this.wallets.btcWallet)return I.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return I.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return I.Err(r.error);const i=await this.getAddresses(t.toAsset.chain);if(i.error)return I.Err(i.error);const o=this.validateAmount(t.sendAmount);if(o.error)return I.Err(o.error);const s=this.validateAmount(t.receiveAmount);if(s.error)return I.Err(s.error);if(o<s)return I.Err("Send amount should be greater than receive amount");const c=this.getTimelock(t.fromAsset.chain);return c?I.Ok({sendAddress:r.val,receiveAddress:i.val,timelock:t.timelock??c}):I.Err("Unsupported chain for timelock")}async getAddresses(t){var i;switch(Y.getBlockchainType(t)){case Y.BlockchainType.EVM:return this.wallets.evmWallet.account?I.Ok(this.wallets.evmWallet.account.address):I.Err("EVM Wallet not found");case Y.BlockchainType.Bitcoin:{const o=await((i=this.wallets.btcWallet)==null?void 0:i.getPublicKey());return!o||!mi(o)?I.Err("Invalid btc public key"):I.Ok(yt(o))}default:return I.Err("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return I.Err("Invalid amount ",t);const r=new yi(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?I.Err("Invalid amount ",t):I.Ok(r)}getTimelock(t){switch(Y.getBlockchainType(t)){case Y.BlockchainType.EVM:return Nt.evm;case Y.BlockchainType.Bitcoin:return Nt.btc;default:return}}async pollOrder(t){let r=await this.orderBook.getOrder(t,!0),i=0;for(;i<this.getOrderThreshold;){if(await be.sleep(1e3),i++,r.error){if(!r.error.includes("result is undefined"))return I.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return I.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return I.Err(`Order not found, createOrder id: ${t}`)}emit(t,...r){(this.eventListeners.get(t)??[]).forEach(o=>{o(...r)})}async execute(t=5e3){return await this.orderBook.subscribeToOrders(!0,t,async r=>{const i=vn(r.data),o=await this.assignOrderStatus(i);this.emit("onPendingOrdersChanged",o);for(let s=0;s<o.length;s++){const c=o[s];switch(kr(c.status)){case se.Redeem:{const p=this.secretManager.generateSecret(Number(c.create_order.nonce));if(p.error){this.emit("error",c,p.error);return}switch(Y.getBlockchainType(c.destination_swap.chain)){case Y.BlockchainType.EVM:{await this.evmRedeem(c,p.val.secret);break}case Y.BlockchainType.Bitcoin:{const g=this.getWallet(c.destination_swap.chain);if(g.error){this.emit("error",c,g.error);return}await this.btcRedeem(g.val,c,p.val.secret);break}default:this.emit("error",c,"Unsupported chain: "+c.destination_swap.chain)}break}case se.Refund:{switch(Y.getBlockchainType(c.source_swap.chain)){case Y.BlockchainType.EVM:{this.emit("error",c,"EVM refund is automatically done by relay service");break}case Y.BlockchainType.Bitcoin:{const p=this.getWallet(c.source_swap.chain);if(p.error){this.emit("error",c,p.error);return}await this.btcRefund(p.val,c);break}default:this.emit("error",c,"Unsupported chain: "+c.source_swap.chain)}break}}}},{per_page:500},!0)}async evmRedeem(t,r){if(this.emit("log",t.create_order.create_id,"executing evm redeem"),this.orderExecutorCache.get(t,se.Redeem)){this.emit("log",t.create_order.create_id,"already redeemed");return}const s=await new xn(t,this.orderbookUrl,this.auth).redeem(t.create_order.create_id,r);if(s.error){this.emit("error",t,s.error),s.error.includes("Order already redeemed")&&this.orderExecutorCache.set(t,se.Redeem,t.destination_swap.redeem_tx_hash);return}this.emit("success",t,se.Redeem,s.val),this.orderExecutorCache.set(t,se.Redeem,s.val)}async btcRedeem(t,r,i){var u,p;const o=this.orderExecutorCache.get(r,se.Redeem),s=(u=r.destination_swap.initiate_tx_hash.split(",").at(-1))==null?void 0:u.split(":").at(0);if(!s){this.emit("error",r,"Failed to get initiate_tx_hash");return}let c=!1;if(o)if(o.btcRedeemUTXO&&o.btcRedeemUTXO!==s)c=!0,this.emit("log",r.create_order.create_id,"rbf btc redeem");else{this.emit("log",r.create_order.create_id,"btcRedeem: already redeemed");return}else if(r.destination_swap.redeem_tx_hash&&!Number(r.destination_swap.redeem_block_number))try{const g=await(await t.getProvider()).getTransaction(r.destination_swap.redeem_tx_hash);let m=!1;for(const v of g.vin)if(v.txid===s){m=!0;break}if(m){this.emit("log",r.create_order.create_id,"already a valid redeem"),this.orderExecutorCache.set(r,se.Redeem,r.destination_swap.redeem_tx_hash,s);return}c=!0}catch(g){if(g.message.includes("Transaction not found"))c=!0;else{this.emit("error",r,"Failed to get redeem tx: "+g);return}}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const m=await(await Ut.from(t,Number(r.destination_swap.amount),r.create_order.secret_hash,yt(r.destination_swap.initiator),yt(r.destination_swap.redeemer),r.destination_swap.timelock,c?[s]:[])).redeem(I.trim0x(i),(p=r.create_order.additional_data)==null?void 0:p.bitcoin_optional_recipient);c?this.emit("log",r.create_order.create_id,"rbf: btc redeem success"):this.emit("success",r,se.Redeem,m),this.orderExecutorCache.set(r,se.Redeem,m,s)}catch(g){this.emit("error",r,"Failed btc redeem: "+g)}}async btcRefund(t,r){var i;if(!this.orderExecutorCache.get(r,se.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const s=await(await Ut.from(t,Number(r.source_swap.amount),r.create_order.secret_hash,yt(r.source_swap.initiator),yt(r.source_swap.redeemer),r.source_swap.timelock)).refund((i=r.create_order.additional_data)==null?void 0:i.bitcoin_optional_recipient);this.emit("success",r,se.Refund,s),this.orderExecutorCache.set(r,se.Refund,s)}catch(o){this.emit("error",r,"Failed btc refund: "+o)}}}getWallet(t){switch(Y.getBlockchainType(t)){case Y.BlockchainType.EVM:return I.Ok(this.wallets.evmWallet);case Y.BlockchainType.Bitcoin:return I.Ok(this.wallets.btcWallet);default:return I.Err("Unsupported chain for wallet")}}on(t,r){const i=this.eventListeners.get(t)??[];i.push(r),this.eventListeners.set(t,i)}off(t,r){const i=this.eventListeners.get(t)??[],o=i.indexOf(r);o!==-1&&i.splice(o,1)}async fetchCurrentBlockNumbers(t,r){if(!r||!r.source||!r.destination)return I.Err("Provide wallets to fetch the current block number");const i=Y.isBitcoin(t.source_swap.chain)?await be.fetchBitcoinBlockNumber(await r.source.getProvider()):await be.fetchEVMBlockNumber(r.source);if(i.error)return I.Err(i.error);const o=Y.isBitcoin(t.destination_swap.chain)?await be.fetchBitcoinBlockNumber(await r.destination.getProvider()):await be.fetchEVMBlockNumber(r.destination);return o.error?I.Err(o.error):I.Ok({source:i.val,destination:o.val})}async assignOrderStatus(t){var o;const r=await((o=this.blockNumberFetcher)==null?void 0:o.fetchBlockNumbers()),i=[];for(let s=0;s<t.length;s++){const c=t[s],u=c.source_swap.chain,p=c.destination_swap.chain,g=this.getWallet(u),m=this.getWallet(p);if(g.error||m.error||!g.val||!m.val){this.emit("error",c,"Source or Destination Wallet not found while executing order");continue}let v=r==null?void 0:r.val[u],A=r==null?void 0:r.val[p];if(!v||!A){const E=await this.fetchCurrentBlockNumbers(c,{source:g.val,destination:m.val});if(E.error){this.emit("error",c,"Error while fetching CurrentBlockNumbers: "+E.error);continue}v=E.val.source,A=E.val.destination}const k=Ir(c,v,A);i.push({...c,status:k})}return i}}class Oi{constructor(t,r){this.url=new be.Url("/blocknumber/"+r,t)}async fetchBlockNumbers(){try{const t=await I.Fetcher.get(this.url);return I.Ok(t)}catch(t){return I.Err("Failed to fetch block numbers",t)}}}var Ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Li(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function i(){return this instanceof i?Reflect.construct(t,arguments,this.constructor):t.apply(this,arguments)};r.prototype=t.prototype}else r={};return Object.defineProperty(r,"__esModule",{value:!0}),Object.keys(e).forEach(function(i){var o=Object.getOwnPropertyDescriptor(e,i);Object.defineProperty(r,i,o.get?o:{enumerable:!0,get:function(){return e[i]}})}),r}var En={},ut={},ct={};Object.defineProperty(ct,"__esModule",{value:!0});ct.testnet=ct.bitcoin=void 0;ct.bitcoin={messagePrefix:`Bitcoin Signed Message:
|
|
21
|
+
`,bech32:"bc",bip32:{public:76067358,private:76066276},pubKeyHash:0,scriptHash:5,wif:128};ct.testnet={messagePrefix:`Bitcoin Signed Message:
|
|
22
|
+
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var Bn={},Rt={Array:function(e){return e!=null&&e.constructor===Array},Boolean:function(e){return typeof e=="boolean"},Function:function(e){return typeof e=="function"},Nil:function(e){return e==null},Number:function(e){return typeof e=="number"},Object:function(e){return typeof e=="object"},String:function(e){return typeof e=="string"},"":function(){return!0}};Rt.Null=Rt.Nil;for(var jr in Rt)Rt[jr].toJSON=(function(e){return e}).bind(null,jr);var Cr=Rt,Xe=Cr;function Rn(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function Or(e){return Xe.Nil(e)?"":Rn(e.constructor)}function Fi(e){return Xe.Function(e)?"":Xe.String(e)?JSON.stringify(e):e&&Xe.Object(e)?"":e}function Lr(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function $t(e){return Xe.Function(e)?e.toJSON?e.toJSON():Rn(e):Xe.Array(e)?"Array":e&&Xe.Object(e)?"Object":e!==void 0?e:""}function Sn(e,t,r){var i=Fi(t);return"Expected "+$t(e)+", got"+(r!==""?" "+r:"")+(i!==""?" "+i:"")}function De(e,t,r){r=r||Or(t),this.message=Sn(e,t,r),Lr(this,De),this.__type=e,this.__value=t,this.__valueTypeName=r}De.prototype=Object.create(Error.prototype);De.prototype.constructor=De;function Pi(e,t,r,i,o){var s='" of type ';return t==="key"&&(s='" with key type '),Sn('property "'+$t(r)+s+$t(e),i,o)}function ot(e,t,r,i,o){e?(o=o||Or(i),this.message=Pi(e,r,t,i,o)):this.message='Unexpected property "'+t+'"',Lr(this,De),this.__label=r,this.__property=t,this.__type=e,this.__value=i,this.__valueTypeName=o}ot.prototype=Object.create(Error.prototype);ot.prototype.constructor=De;function Mi(e,t){return new De(e,{},t)}function Ni(e,t,r){return e instanceof ot?(t=t+"."+e.__property,e=new ot(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof De&&(e=new ot(e.__type,t,r,e.__value,e.__valueTypeName)),Lr(e),e}var An={TfTypeError:De,TfPropertyTypeError:ot,tfCustomError:Mi,tfSubError:Ni,tfJSON:$t,getValueTypeName:Or},ir,qr;function Di(){if(qr)return ir;qr=1;var e=Cr,t=An;function r(B){return Buffer.isBuffer(B)}function i(B){return typeof B=="string"&&/^([0-9a-f]{2})+$/i.test(B)}function o(B,j){var D=B.toJSON();function $(ie){if(!B(ie))return!1;if(ie.length===j)return!0;throw t.tfCustomError(D+"(Length: "+j+")",D+"(Length: "+ie.length+")")}return $.toJSON=function(){return D},$}var s=o.bind(null,e.Array),c=o.bind(null,r),u=o.bind(null,i),p=o.bind(null,e.String);function g(B,j,D){D=D||e.Number;function $(ie,Te){return D(ie,Te)&&ie>B&&ie<j}return $.toJSON=function(){return`${D.toJSON()} between [${B}, ${j}]`},$}var m=Math.pow(2,53)-1;function v(B){return typeof B=="number"&&isFinite(B)}function A(B){return B<<24>>24===B}function k(B){return B<<16>>16===B}function E(B){return(B|0)===B}function O(B){return typeof B=="number"&&B>=-m&&B<=m&&Math.floor(B)===B}function T(B){return(B&255)===B}function C(B){return(B&65535)===B}function F(B){return B>>>0===B}function P(B){return typeof B=="number"&&B>=0&&B<=m&&Math.floor(B)===B}var L={ArrayN:s,Buffer:r,BufferN:c,Finite:v,Hex:i,HexN:u,Int8:A,Int16:k,Int32:E,Int53:O,Range:g,StringN:p,UInt8:T,UInt16:C,UInt32:F,UInt53:P};for(var N in L)L[N].toJSON=(function(B){return B}).bind(null,N);return ir=L,ir}var At=An,ue=Cr,Pe=At.tfJSON,Tn=At.TfTypeError,In=At.TfPropertyTypeError,_t=At.tfSubError,Ui=At.getValueTypeName,Me={arrayOf:function(t,r){t=Oe(t),r=r||{};function i(o,s){return!ue.Array(o)||ue.Nil(o)||r.minLength!==void 0&&o.length<r.minLength||r.maxLength!==void 0&&o.length>r.maxLength||r.length!==void 0&&o.length!==r.length?!1:o.every(function(c,u){try{return we(t,c,s)}catch(p){throw _t(p,u)}})}return i.toJSON=function(){var o="["+Pe(t)+"]";return r.length!==void 0?o+="{"+r.length+"}":(r.minLength!==void 0||r.maxLength!==void 0)&&(o+="{"+(r.minLength===void 0?0:r.minLength)+","+(r.maxLength===void 0?1/0:r.maxLength)+"}"),o},i},maybe:function e(t){t=Oe(t);function r(i,o){return ue.Nil(i)||t(i,o,e)}return r.toJSON=function(){return"?"+Pe(t)},r},map:function(t,r){t=Oe(t),r&&(r=Oe(r));function i(o,s){if(!ue.Object(o)||ue.Nil(o))return!1;for(var c in o){try{r&&we(r,c,s)}catch(p){throw _t(p,c,"key")}try{var u=o[c];we(t,u,s)}catch(p){throw _t(p,c)}}return!0}return r?i.toJSON=function(){return"{"+Pe(r)+": "+Pe(t)+"}"}:i.toJSON=function(){return"{"+Pe(t)+"}"},i},object:function(t){var r={};for(var i in t)r[i]=Oe(t[i]);function o(s,c){if(!ue.Object(s)||ue.Nil(s))return!1;var u;try{for(u in r){var p=r[u],g=s[u];we(p,g,c)}}catch(m){throw _t(m,u)}if(c){for(u in s)if(!r[u])throw new In(void 0,u)}return!0}return o.toJSON=function(){return Pe(r)},o},anyOf:function(){var t=[].slice.call(arguments).map(Oe);function r(i,o){return t.some(function(s){try{return we(s,i,o)}catch{return!1}})}return r.toJSON=function(){return t.map(Pe).join("|")},r},allOf:function(){var t=[].slice.call(arguments).map(Oe);function r(i,o){return t.every(function(s){try{return we(s,i,o)}catch{return!1}})}return r.toJSON=function(){return t.map(Pe).join(" & ")},r},quacksLike:function(t){function r(i){return t===Ui(i)}return r.toJSON=function(){return t},r},tuple:function(){var t=[].slice.call(arguments).map(Oe);function r(i,o){return ue.Nil(i)||ue.Nil(i.length)||o&&i.length!==t.length?!1:t.every(function(s,c){try{return we(s,i[c],o)}catch(u){throw _t(u,c)}})}return r.toJSON=function(){return"("+t.map(Pe).join(", ")+")"},r},value:function(t){function r(i){return i===t}return r.toJSON=function(){return t},r}};Me.oneOf=Me.anyOf;function Oe(e){if(ue.String(e))return e[0]==="?"?Me.maybe(e.slice(1)):ue[e]||Me.quacksLike(e);if(e&&ue.Object(e)){if(ue.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return Me.arrayOf(e[0])}return Me.object(e)}else if(ue.Function(e))return e;return Me.value(e)}function we(e,t,r,i){if(ue.Function(e)){if(e(t,r))return!0;throw new Tn(i||e,t)}return we(Oe(e),t,r)}for(var Ge in ue)we[Ge]=ue[Ge];for(Ge in Me)we[Ge]=Me[Ge];var Wr=Di();for(Ge in Wr)we[Ge]=Wr[Ge];we.compile=Oe;we.TfTypeError=Tn;we.TfPropertyTypeError=In;var $i=we;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=$i,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})(Bn);var mr={exports:{}},vr={exports:{}},ht={},Gt={};Gt.byteLength=qi;Gt.toByteArray=Gi;Gt.fromByteArray=Ji;var Le=[],Se=[],Hi=typeof Uint8Array<"u"?Uint8Array:Array,ar="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var at=0,ji=ar.length;at<ji;++at)Le[at]=ar[at],Se[ar.charCodeAt(at)]=at;Se[45]=62;Se[95]=63;function kn(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var r=e.indexOf("=");r===-1&&(r=t);var i=r===t?0:4-r%4;return[r,i]}function qi(e){var t=kn(e),r=t[0],i=t[1];return(r+i)*3/4-i}function Wi(e,t,r){return(t+r)*3/4-r}function Gi(e){var t,r=kn(e),i=r[0],o=r[1],s=new Hi(Wi(e,i,o)),c=0,u=o>0?i-4:i,p;for(p=0;p<u;p+=4)t=Se[e.charCodeAt(p)]<<18|Se[e.charCodeAt(p+1)]<<12|Se[e.charCodeAt(p+2)]<<6|Se[e.charCodeAt(p+3)],s[c++]=t>>16&255,s[c++]=t>>8&255,s[c++]=t&255;return o===2&&(t=Se[e.charCodeAt(p)]<<2|Se[e.charCodeAt(p+1)]>>4,s[c++]=t&255),o===1&&(t=Se[e.charCodeAt(p)]<<10|Se[e.charCodeAt(p+1)]<<4|Se[e.charCodeAt(p+2)]>>2,s[c++]=t>>8&255,s[c++]=t&255),s}function Ki(e){return Le[e>>18&63]+Le[e>>12&63]+Le[e>>6&63]+Le[e&63]}function Vi(e,t,r){for(var i,o=[],s=t;s<r;s+=3)i=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),o.push(Ki(i));return o.join("")}function Ji(e){for(var t,r=e.length,i=r%3,o=[],s=16383,c=0,u=r-i;c<u;c+=s)o.push(Vi(e,c,c+s>u?u:c+s));return i===1?(t=e[r-1],o.push(Le[t>>2]+Le[t<<4&63]+"==")):i===2&&(t=(e[r-2]<<8)+e[r-1],o.push(Le[t>>10]+Le[t>>4&63]+Le[t<<2&63]+"=")),o.join("")}var Fr={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Fr.read=function(e,t,r,i,o){var s,c,u=o*8-i-1,p=(1<<u)-1,g=p>>1,m=-7,v=r?o-1:0,A=r?-1:1,k=e[t+v];for(v+=A,s=k&(1<<-m)-1,k>>=-m,m+=u;m>0;s=s*256+e[t+v],v+=A,m-=8);for(c=s&(1<<-m)-1,s>>=-m,m+=i;m>0;c=c*256+e[t+v],v+=A,m-=8);if(s===0)s=1-g;else{if(s===p)return c?NaN:(k?-1:1)*(1/0);c=c+Math.pow(2,i),s=s-g}return(k?-1:1)*c*Math.pow(2,s-i)};Fr.write=function(e,t,r,i,o,s){var c,u,p,g=s*8-o-1,m=(1<<g)-1,v=m>>1,A=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=i?0:s-1,E=i?1:-1,O=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,c=m):(c=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-c))<1&&(c--,p*=2),c+v>=1?t+=A/p:t+=A*Math.pow(2,1-v),t*p>=2&&(c++,p/=2),c+v>=m?(u=0,c=m):c+v>=1?(u=(t*p-1)*Math.pow(2,o),c=c+v):(u=t*Math.pow(2,v-1)*Math.pow(2,o),c=0));o>=8;e[r+k]=u&255,k+=E,u/=256,o-=8);for(c=c<<o|u,g+=o;g>0;e[r+k]=c&255,k+=E,c/=256,g-=8);e[r+k-E]|=O*128};/*!
|
|
26
23
|
* The buffer module from node.js, for the browser.
|
|
27
24
|
*
|
|
28
25
|
* @author Feross Aboukhadijeh <https://feross.org>
|
|
29
26
|
* @license MIT
|
|
30
|
-
*/(function(e){const t=wr,r=vn,n=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=F,e.INSPECT_MAX_BYTES=50;const i=2147483647;e.kMaxLength=i,u.TYPED_ARRAY_SUPPORT=a(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function a(){try{const c=new Uint8Array(1),s={foo:function(){return 42}};return Object.setPrototypeOf(s,Uint8Array.prototype),Object.setPrototypeOf(c,s),c.foo()===42}catch{return!1}}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}});function f(c){if(c>i)throw new RangeError('The value "'+c+'" is invalid for option "size"');const s=new Uint8Array(c);return Object.setPrototypeOf(s,u.prototype),s}function u(c,s,o){if(typeof c=="number"){if(typeof s=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return m(c)}return l(c,s,o)}u.poolSize=8192;function l(c,s,o){if(typeof c=="string")return v(c,s);if(ArrayBuffer.isView(c))return B(c);if(c==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c);if(Ie(c,ArrayBuffer)||c&&Ie(c.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ie(c,SharedArrayBuffer)||c&&Ie(c.buffer,SharedArrayBuffer)))return k(c,s,o);if(typeof c=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const h=c.valueOf&&c.valueOf();if(h!=null&&h!==c)return u.from(h,s,o);const y=T(c);if(y)return y;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof c[Symbol.toPrimitive]=="function")return u.from(c[Symbol.toPrimitive]("string"),s,o);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof c)}u.from=function(c,s,o){return l(c,s,o)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function b(c){if(typeof c!="number")throw new TypeError('"size" argument must be of type number');if(c<0)throw new RangeError('The value "'+c+'" is invalid for option "size"')}function g(c,s,o){return b(c),c<=0?f(c):s!==void 0?typeof o=="string"?f(c).fill(s,o):f(c).fill(s):f(c)}u.alloc=function(c,s,o){return g(c,s,o)};function m(c){return b(c),f(c<0?0:C(c)|0)}u.allocUnsafe=function(c){return m(c)},u.allocUnsafeSlow=function(c){return m(c)};function v(c,s){if((typeof s!="string"||s==="")&&(s="utf8"),!u.isEncoding(s))throw new TypeError("Unknown encoding: "+s);const o=O(c,s)|0;let h=f(o);const y=h.write(c,s);return y!==o&&(h=h.slice(0,y)),h}function I(c){const s=c.length<0?0:C(c.length)|0,o=f(s);for(let h=0;h<s;h+=1)o[h]=c[h]&255;return o}function B(c){if(Ie(c,Uint8Array)){const s=new Uint8Array(c);return k(s.buffer,s.byteOffset,s.byteLength)}return I(c)}function k(c,s,o){if(s<0||c.byteLength<s)throw new RangeError('"offset" is outside of buffer bounds');if(c.byteLength<s+(o||0))throw new RangeError('"length" is outside of buffer bounds');let h;return s===void 0&&o===void 0?h=new Uint8Array(c):o===void 0?h=new Uint8Array(c,s):h=new Uint8Array(c,s,o),Object.setPrototypeOf(h,u.prototype),h}function T(c){if(u.isBuffer(c)){const s=C(c.length)|0,o=f(s);return o.length===0||c.copy(o,0,0,s),o}if(c.length!==void 0)return typeof c.length!="number"||rt(c.length)?f(0):I(c);if(c.type==="Buffer"&&Array.isArray(c.data))return I(c.data)}function C(c){if(c>=i)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+i.toString(16)+" bytes");return c|0}function F(c){return+c!=c&&(c=0),u.alloc(+c)}u.isBuffer=function(s){return s!=null&&s._isBuffer===!0&&s!==u.prototype},u.compare=function(s,o){if(Ie(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),Ie(o,Uint8Array)&&(o=u.from(o,o.offset,o.byteLength)),!u.isBuffer(s)||!u.isBuffer(o))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(s===o)return 0;let h=s.length,y=o.length;for(let x=0,E=Math.min(h,y);x<E;++x)if(s[x]!==o[x]){h=s[x],y=o[x];break}return h<y?-1:y<h?1:0},u.isEncoding=function(s){switch(String(s).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(s,o){if(!Array.isArray(s))throw new TypeError('"list" argument must be an Array of Buffers');if(s.length===0)return u.alloc(0);let h;if(o===void 0)for(o=0,h=0;h<s.length;++h)o+=s[h].length;const y=u.allocUnsafe(o);let x=0;for(h=0;h<s.length;++h){let E=s[h];if(Ie(E,Uint8Array))x+E.length>y.length?(u.isBuffer(E)||(E=u.from(E)),E.copy(y,x)):Uint8Array.prototype.set.call(y,E,x);else if(u.isBuffer(E))E.copy(y,x);else throw new TypeError('"list" argument must be an Array of Buffers');x+=E.length}return y};function O(c,s){if(u.isBuffer(c))return c.length;if(ArrayBuffer.isView(c)||Ie(c,ArrayBuffer))return c.byteLength;if(typeof c!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof c);const o=c.length,h=arguments.length>2&&arguments[2]===!0;if(!h&&o===0)return 0;let y=!1;for(;;)switch(s){case"ascii":case"latin1":case"binary":return o;case"utf8":case"utf-8":return V(c).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return o*2;case"hex":return o>>>1;case"base64":return Tt(c).length;default:if(y)return h?-1:V(c).length;s=(""+s).toLowerCase(),y=!0}}u.byteLength=O;function L(c,s,o){let h=!1;if((s===void 0||s<0)&&(s=0),s>this.length||((o===void 0||o>this.length)&&(o=this.length),o<=0)||(o>>>=0,s>>>=0,o<=s))return"";for(c||(c="utf8");;)switch(c){case"hex":return Ce(this,s,o);case"utf8":case"utf-8":return ve(this,s,o);case"ascii":return ke(this,s,o);case"latin1":case"binary":return We(this,s,o);case"base64":return fe(this,s,o);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return qe(this,s,o);default:if(h)throw new TypeError("Unknown encoding: "+c);c=(c+"").toLowerCase(),h=!0}}u.prototype._isBuffer=!0;function U(c,s,o){const h=c[s];c[s]=c[o],c[o]=h}u.prototype.swap16=function(){const s=this.length;if(s%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let o=0;o<s;o+=2)U(this,o,o+1);return this},u.prototype.swap32=function(){const s=this.length;if(s%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let o=0;o<s;o+=4)U(this,o,o+3),U(this,o+1,o+2);return this},u.prototype.swap64=function(){const s=this.length;if(s%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let o=0;o<s;o+=8)U(this,o,o+7),U(this,o+1,o+6),U(this,o+2,o+5),U(this,o+3,o+4);return this},u.prototype.toString=function(){const s=this.length;return s===0?"":arguments.length===0?ve(this,0,s):L.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(s){if(!u.isBuffer(s))throw new TypeError("Argument must be a Buffer");return this===s?!0:u.compare(this,s)===0},u.prototype.inspect=function(){let s="";const o=e.INSPECT_MAX_BYTES;return s=this.toString("hex",0,o).replace(/(.{2})/g,"$1 ").trim(),this.length>o&&(s+=" ... "),"<Buffer "+s+">"},n&&(u.prototype[n]=u.prototype.inspect),u.prototype.compare=function(s,o,h,y,x){if(Ie(s,Uint8Array)&&(s=u.from(s,s.offset,s.byteLength)),!u.isBuffer(s))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof s);if(o===void 0&&(o=0),h===void 0&&(h=s?s.length:0),y===void 0&&(y=0),x===void 0&&(x=this.length),o<0||h>s.length||y<0||x>this.length)throw new RangeError("out of range index");if(y>=x&&o>=h)return 0;if(y>=x)return-1;if(o>=h)return 1;if(o>>>=0,h>>>=0,y>>>=0,x>>>=0,this===s)return 0;let E=x-y,q=h-o;const ie=Math.min(E,q),re=this.slice(y,x),se=s.slice(o,h);for(let Y=0;Y<ie;++Y)if(re[Y]!==se[Y]){E=re[Y],q=se[Y];break}return E<q?-1:q<E?1:0};function S(c,s,o,h,y){if(c.length===0)return-1;if(typeof o=="string"?(h=o,o=0):o>2147483647?o=2147483647:o<-2147483648&&(o=-2147483648),o=+o,rt(o)&&(o=y?0:c.length-1),o<0&&(o=c.length+o),o>=c.length){if(y)return-1;o=c.length-1}else if(o<0)if(y)o=0;else return-1;if(typeof s=="string"&&(s=u.from(s,h)),u.isBuffer(s))return s.length===0?-1:z(c,s,o,h,y);if(typeof s=="number")return s=s&255,typeof Uint8Array.prototype.indexOf=="function"?y?Uint8Array.prototype.indexOf.call(c,s,o):Uint8Array.prototype.lastIndexOf.call(c,s,o):z(c,[s],o,h,y);throw new TypeError("val must be string, number or Buffer")}function z(c,s,o,h,y){let x=1,E=c.length,q=s.length;if(h!==void 0&&(h=String(h).toLowerCase(),h==="ucs2"||h==="ucs-2"||h==="utf16le"||h==="utf-16le")){if(c.length<2||s.length<2)return-1;x=2,E/=2,q/=2,o/=2}function ie(se,Y){return x===1?se[Y]:se.readUInt16BE(Y*x)}let re;if(y){let se=-1;for(re=o;re<E;re++)if(ie(c,re)===ie(s,se===-1?0:re-se)){if(se===-1&&(se=re),re-se+1===q)return se*x}else se!==-1&&(re-=re-se),se=-1}else for(o+q>E&&(o=E-q),re=o;re>=0;re--){let se=!0;for(let Y=0;Y<q;Y++)if(ie(c,re+Y)!==ie(s,Y)){se=!1;break}if(se)return re}return-1}u.prototype.includes=function(s,o,h){return this.indexOf(s,o,h)!==-1},u.prototype.indexOf=function(s,o,h){return S(this,s,o,h,!0)},u.prototype.lastIndexOf=function(s,o,h){return S(this,s,o,h,!1)};function M(c,s,o,h){o=Number(o)||0;const y=c.length-o;h?(h=Number(h),h>y&&(h=y)):h=y;const x=s.length;h>x/2&&(h=x/2);let E;for(E=0;E<h;++E){const q=parseInt(s.substr(E*2,2),16);if(rt(q))return E;c[o+E]=q}return E}function $(c,s,o,h){return dt(V(s,c.length-o),c,o,h)}function oe(c,s,o,h){return dt(Ke(s),c,o,h)}function Pe(c,s,o,h){return dt(Tt(s),c,o,h)}function Ge(c,s,o,h){return dt(ht(s,c.length-o),c,o,h)}u.prototype.write=function(s,o,h,y){if(o===void 0)y="utf8",h=this.length,o=0;else if(h===void 0&&typeof o=="string")y=o,h=this.length,o=0;else if(isFinite(o))o=o>>>0,isFinite(h)?(h=h>>>0,y===void 0&&(y="utf8")):(y=h,h=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const x=this.length-o;if((h===void 0||h>x)&&(h=x),s.length>0&&(h<0||o<0)||o>this.length)throw new RangeError("Attempt to write outside buffer bounds");y||(y="utf8");let E=!1;for(;;)switch(y){case"hex":return M(this,s,o,h);case"utf8":case"utf-8":return $(this,s,o,h);case"ascii":case"latin1":case"binary":return oe(this,s,o,h);case"base64":return Pe(this,s,o,h);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return Ge(this,s,o,h);default:if(E)throw new TypeError("Unknown encoding: "+y);y=(""+y).toLowerCase(),E=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function fe(c,s,o){return s===0&&o===c.length?t.fromByteArray(c):t.fromByteArray(c.slice(s,o))}function ve(c,s,o){o=Math.min(c.length,o);const h=[];let y=s;for(;y<o;){const x=c[y];let E=null,q=x>239?4:x>223?3:x>191?2:1;if(y+q<=o){let ie,re,se,Y;switch(q){case 1:x<128&&(E=x);break;case 2:ie=c[y+1],(ie&192)===128&&(Y=(x&31)<<6|ie&63,Y>127&&(E=Y));break;case 3:ie=c[y+1],re=c[y+2],(ie&192)===128&&(re&192)===128&&(Y=(x&15)<<12|(ie&63)<<6|re&63,Y>2047&&(Y<55296||Y>57343)&&(E=Y));break;case 4:ie=c[y+1],re=c[y+2],se=c[y+3],(ie&192)===128&&(re&192)===128&&(se&192)===128&&(Y=(x&15)<<18|(ie&63)<<12|(re&63)<<6|se&63,Y>65535&&Y<1114112&&(E=Y))}}E===null?(E=65533,q=1):E>65535&&(E-=65536,h.push(E>>>10&1023|55296),E=56320|E&1023),h.push(E),y+=q}return tt(h)}const Ee=4096;function tt(c){const s=c.length;if(s<=Ee)return String.fromCharCode.apply(String,c);let o="",h=0;for(;h<s;)o+=String.fromCharCode.apply(String,c.slice(h,h+=Ee));return o}function ke(c,s,o){let h="";o=Math.min(c.length,o);for(let y=s;y<o;++y)h+=String.fromCharCode(c[y]&127);return h}function We(c,s,o){let h="";o=Math.min(c.length,o);for(let y=s;y<o;++y)h+=String.fromCharCode(c[y]);return h}function Ce(c,s,o){const h=c.length;(!s||s<0)&&(s=0),(!o||o<0||o>h)&&(o=h);let y="";for(let x=s;x<o;++x)y+=Pt[c[x]];return y}function qe(c,s,o){const h=c.slice(s,o);let y="";for(let x=0;x<h.length-1;x+=2)y+=String.fromCharCode(h[x]+h[x+1]*256);return y}u.prototype.slice=function(s,o){const h=this.length;s=~~s,o=o===void 0?h:~~o,s<0?(s+=h,s<0&&(s=0)):s>h&&(s=h),o<0?(o+=h,o<0&&(o=0)):o>h&&(o=h),o<s&&(o=s);const y=this.subarray(s,o);return Object.setPrototypeOf(y,u.prototype),y};function ee(c,s,o){if(c%1!==0||c<0)throw new RangeError("offset is not uint");if(c+s>o)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(s,o,h){s=s>>>0,o=o>>>0,h||ee(s,o,this.length);let y=this[s],x=1,E=0;for(;++E<o&&(x*=256);)y+=this[s+E]*x;return y},u.prototype.readUintBE=u.prototype.readUIntBE=function(s,o,h){s=s>>>0,o=o>>>0,h||ee(s,o,this.length);let y=this[s+--o],x=1;for(;o>0&&(x*=256);)y+=this[s+--o]*x;return y},u.prototype.readUint8=u.prototype.readUInt8=function(s,o){return s=s>>>0,o||ee(s,1,this.length),this[s]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(s,o){return s=s>>>0,o||ee(s,2,this.length),this[s]|this[s+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(s,o){return s=s>>>0,o||ee(s,2,this.length),this[s]<<8|this[s+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(s,o){return s=s>>>0,o||ee(s,4,this.length),(this[s]|this[s+1]<<8|this[s+2]<<16)+this[s+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(s,o){return s=s>>>0,o||ee(s,4,this.length),this[s]*16777216+(this[s+1]<<16|this[s+2]<<8|this[s+3])},u.prototype.readBigUInt64LE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&N(s,this.length-8);const y=o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24,x=this[++s]+this[++s]*2**8+this[++s]*2**16+h*2**24;return BigInt(y)+(BigInt(x)<<BigInt(32))}),u.prototype.readBigUInt64BE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&N(s,this.length-8);const y=o*2**24+this[++s]*2**16+this[++s]*2**8+this[++s],x=this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+h;return(BigInt(y)<<BigInt(32))+BigInt(x)}),u.prototype.readIntLE=function(s,o,h){s=s>>>0,o=o>>>0,h||ee(s,o,this.length);let y=this[s],x=1,E=0;for(;++E<o&&(x*=256);)y+=this[s+E]*x;return x*=128,y>=x&&(y-=Math.pow(2,8*o)),y},u.prototype.readIntBE=function(s,o,h){s=s>>>0,o=o>>>0,h||ee(s,o,this.length);let y=o,x=1,E=this[s+--y];for(;y>0&&(x*=256);)E+=this[s+--y]*x;return x*=128,E>=x&&(E-=Math.pow(2,8*o)),E},u.prototype.readInt8=function(s,o){return s=s>>>0,o||ee(s,1,this.length),this[s]&128?(255-this[s]+1)*-1:this[s]},u.prototype.readInt16LE=function(s,o){s=s>>>0,o||ee(s,2,this.length);const h=this[s]|this[s+1]<<8;return h&32768?h|4294901760:h},u.prototype.readInt16BE=function(s,o){s=s>>>0,o||ee(s,2,this.length);const h=this[s+1]|this[s]<<8;return h&32768?h|4294901760:h},u.prototype.readInt32LE=function(s,o){return s=s>>>0,o||ee(s,4,this.length),this[s]|this[s+1]<<8|this[s+2]<<16|this[s+3]<<24},u.prototype.readInt32BE=function(s,o){return s=s>>>0,o||ee(s,4,this.length),this[s]<<24|this[s+1]<<16|this[s+2]<<8|this[s+3]},u.prototype.readBigInt64LE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&N(s,this.length-8);const y=this[s+4]+this[s+5]*2**8+this[s+6]*2**16+(h<<24);return(BigInt(y)<<BigInt(32))+BigInt(o+this[++s]*2**8+this[++s]*2**16+this[++s]*2**24)}),u.prototype.readBigInt64BE=Ae(function(s){s=s>>>0,A(s,"offset");const o=this[s],h=this[s+7];(o===void 0||h===void 0)&&N(s,this.length-8);const y=(o<<24)+this[++s]*2**16+this[++s]*2**8+this[++s];return(BigInt(y)<<BigInt(32))+BigInt(this[++s]*2**24+this[++s]*2**16+this[++s]*2**8+h)}),u.prototype.readFloatLE=function(s,o){return s=s>>>0,o||ee(s,4,this.length),r.read(this,s,!0,23,4)},u.prototype.readFloatBE=function(s,o){return s=s>>>0,o||ee(s,4,this.length),r.read(this,s,!1,23,4)},u.prototype.readDoubleLE=function(s,o){return s=s>>>0,o||ee(s,8,this.length),r.read(this,s,!0,52,8)},u.prototype.readDoubleBE=function(s,o){return s=s>>>0,o||ee(s,8,this.length),r.read(this,s,!1,52,8)};function ae(c,s,o,h,y,x){if(!u.isBuffer(c))throw new TypeError('"buffer" argument must be a Buffer instance');if(s>y||s<x)throw new RangeError('"value" argument is out of bounds');if(o+h>c.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(s,o,h,y){if(s=+s,o=o>>>0,h=h>>>0,!y){const q=Math.pow(2,8*h)-1;ae(this,s,o,h,q,0)}let x=1,E=0;for(this[o]=s&255;++E<h&&(x*=256);)this[o+E]=s/x&255;return o+h},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(s,o,h,y){if(s=+s,o=o>>>0,h=h>>>0,!y){const q=Math.pow(2,8*h)-1;ae(this,s,o,h,q,0)}let x=h-1,E=1;for(this[o+x]=s&255;--x>=0&&(E*=256);)this[o+x]=s/E&255;return o+h},u.prototype.writeUint8=u.prototype.writeUInt8=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,1,255,0),this[o]=s&255,o+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,65535,0),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,65535,0),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,4294967295,0),this[o+3]=s>>>24,this[o+2]=s>>>16,this[o+1]=s>>>8,this[o]=s&255,o+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,4294967295,0),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4};function Se(c,s,o,h,y){p(s,h,y,c,o,7);let x=Number(s&BigInt(4294967295));c[o++]=x,x=x>>8,c[o++]=x,x=x>>8,c[o++]=x,x=x>>8,c[o++]=x;let E=Number(s>>BigInt(32)&BigInt(4294967295));return c[o++]=E,E=E>>8,c[o++]=E,E=E>>8,c[o++]=E,E=E>>8,c[o++]=E,o}function Ve(c,s,o,h,y){p(s,h,y,c,o,7);let x=Number(s&BigInt(4294967295));c[o+7]=x,x=x>>8,c[o+6]=x,x=x>>8,c[o+5]=x,x=x>>8,c[o+4]=x;let E=Number(s>>BigInt(32)&BigInt(4294967295));return c[o+3]=E,E=E>>8,c[o+2]=E,E=E>>8,c[o+1]=E,E=E>>8,c[o]=E,o+8}u.prototype.writeBigUInt64LE=Ae(function(s,o=0){return Se(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Ae(function(s,o=0){return Ve(this,s,o,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(s,o,h,y){if(s=+s,o=o>>>0,!y){const ie=Math.pow(2,8*h-1);ae(this,s,o,h,ie-1,-ie)}let x=0,E=1,q=0;for(this[o]=s&255;++x<h&&(E*=256);)s<0&&q===0&&this[o+x-1]!==0&&(q=1),this[o+x]=(s/E>>0)-q&255;return o+h},u.prototype.writeIntBE=function(s,o,h,y){if(s=+s,o=o>>>0,!y){const ie=Math.pow(2,8*h-1);ae(this,s,o,h,ie-1,-ie)}let x=h-1,E=1,q=0;for(this[o+x]=s&255;--x>=0&&(E*=256);)s<0&&q===0&&this[o+x+1]!==0&&(q=1),this[o+x]=(s/E>>0)-q&255;return o+h},u.prototype.writeInt8=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,1,127,-128),s<0&&(s=255+s+1),this[o]=s&255,o+1},u.prototype.writeInt16LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,32767,-32768),this[o]=s&255,this[o+1]=s>>>8,o+2},u.prototype.writeInt16BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,2,32767,-32768),this[o]=s>>>8,this[o+1]=s&255,o+2},u.prototype.writeInt32LE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,2147483647,-2147483648),this[o]=s&255,this[o+1]=s>>>8,this[o+2]=s>>>16,this[o+3]=s>>>24,o+4},u.prototype.writeInt32BE=function(s,o,h){return s=+s,o=o>>>0,h||ae(this,s,o,4,2147483647,-2147483648),s<0&&(s=4294967295+s+1),this[o]=s>>>24,this[o+1]=s>>>16,this[o+2]=s>>>8,this[o+3]=s&255,o+4},u.prototype.writeBigInt64LE=Ae(function(s,o=0){return Se(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Ae(function(s,o=0){return Ve(this,s,o,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Ne(c,s,o,h,y,x){if(o+h>c.length)throw new RangeError("Index out of range");if(o<0)throw new RangeError("Index out of range")}function w(c,s,o,h,y){return s=+s,o=o>>>0,y||Ne(c,s,o,4),r.write(c,s,o,h,23,4),o+4}u.prototype.writeFloatLE=function(s,o,h){return w(this,s,o,!0,h)},u.prototype.writeFloatBE=function(s,o,h){return w(this,s,o,!1,h)};function _(c,s,o,h,y){return s=+s,o=o>>>0,y||Ne(c,s,o,8),r.write(c,s,o,h,52,8),o+8}u.prototype.writeDoubleLE=function(s,o,h){return _(this,s,o,!0,h)},u.prototype.writeDoubleBE=function(s,o,h){return _(this,s,o,!1,h)},u.prototype.copy=function(s,o,h,y){if(!u.isBuffer(s))throw new TypeError("argument should be a Buffer");if(h||(h=0),!y&&y!==0&&(y=this.length),o>=s.length&&(o=s.length),o||(o=0),y>0&&y<h&&(y=h),y===h||s.length===0||this.length===0)return 0;if(o<0)throw new RangeError("targetStart out of bounds");if(h<0||h>=this.length)throw new RangeError("Index out of range");if(y<0)throw new RangeError("sourceEnd out of bounds");y>this.length&&(y=this.length),s.length-o<y-h&&(y=s.length-o+h);const x=y-h;return this===s&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(o,h,y):Uint8Array.prototype.set.call(s,this.subarray(h,y),o),x},u.prototype.fill=function(s,o,h,y){if(typeof s=="string"){if(typeof o=="string"?(y=o,o=0,h=this.length):typeof h=="string"&&(y=h,h=this.length),y!==void 0&&typeof y!="string")throw new TypeError("encoding must be a string");if(typeof y=="string"&&!u.isEncoding(y))throw new TypeError("Unknown encoding: "+y);if(s.length===1){const E=s.charCodeAt(0);(y==="utf8"&&E<128||y==="latin1")&&(s=E)}}else typeof s=="number"?s=s&255:typeof s=="boolean"&&(s=Number(s));if(o<0||this.length<o||this.length<h)throw new RangeError("Out of range index");if(h<=o)return this;o=o>>>0,h=h===void 0?this.length:h>>>0,s||(s=0);let x;if(typeof s=="number")for(x=o;x<h;++x)this[x]=s;else{const E=u.isBuffer(s)?s:u.from(s,y),q=E.length;if(q===0)throw new TypeError('The value "'+s+'" is invalid for argument "value"');for(x=0;x<h-o;++x)this[x+o]=E[x%q]}return this};const R={};function D(c,s,o){R[c]=class extends o{constructor(){super(),Object.defineProperty(this,"message",{value:s.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${c}]`,this.stack,delete this.name}get code(){return c}set code(y){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:y,writable:!0})}toString(){return`${this.name} [${c}]: ${this.message}`}}}D("ERR_BUFFER_OUT_OF_BOUNDS",function(c){return c?`${c} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(c,s){return`The "${c}" argument must be of type number. Received type ${typeof s}`},TypeError),D("ERR_OUT_OF_RANGE",function(c,s,o){let h=`The value of "${c}" is out of range.`,y=o;return Number.isInteger(o)&&Math.abs(o)>2**32?y=j(String(o)):typeof o=="bigint"&&(y=String(o),(o>BigInt(2)**BigInt(32)||o<-(BigInt(2)**BigInt(32)))&&(y=j(y)),y+="n"),h+=` It must be ${s}. Received ${y}`,h},RangeError);function j(c){let s="",o=c.length;const h=c[0]==="-"?1:0;for(;o>=h+4;o-=3)s=`_${c.slice(o-3,o)}${s}`;return`${c.slice(0,o)}${s}`}function d(c,s,o){A(s,"offset"),(c[s]===void 0||c[s+o]===void 0)&&N(s,c.length-(o+1))}function p(c,s,o,h,y,x){if(c>o||c<s){const E=typeof s=="bigint"?"n":"";let q;throw s===0||s===BigInt(0)?q=`>= 0${E} and < 2${E} ** ${(x+1)*8}${E}`:q=`>= -(2${E} ** ${(x+1)*8-1}${E}) and < 2 ** ${(x+1)*8-1}${E}`,new R.ERR_OUT_OF_RANGE("value",q,c)}d(h,y,x)}function A(c,s){if(typeof c!="number")throw new R.ERR_INVALID_ARG_TYPE(s,"number",c)}function N(c,s,o){throw Math.floor(c)!==c?(A(c,o),new R.ERR_OUT_OF_RANGE("offset","an integer",c)):s<0?new R.ERR_BUFFER_OUT_OF_BOUNDS:new R.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${s}`,c)}const te=/[^+/0-9A-Za-z-_]/g;function G(c){if(c=c.split("=")[0],c=c.trim().replace(te,""),c.length<2)return"";for(;c.length%4!==0;)c=c+"=";return c}function V(c,s){s=s||1/0;let o;const h=c.length;let y=null;const x=[];for(let E=0;E<h;++E){if(o=c.charCodeAt(E),o>55295&&o<57344){if(!y){if(o>56319){(s-=3)>-1&&x.push(239,191,189);continue}else if(E+1===h){(s-=3)>-1&&x.push(239,191,189);continue}y=o;continue}if(o<56320){(s-=3)>-1&&x.push(239,191,189),y=o;continue}o=(y-55296<<10|o-56320)+65536}else y&&(s-=3)>-1&&x.push(239,191,189);if(y=null,o<128){if((s-=1)<0)break;x.push(o)}else if(o<2048){if((s-=2)<0)break;x.push(o>>6|192,o&63|128)}else if(o<65536){if((s-=3)<0)break;x.push(o>>12|224,o>>6&63|128,o&63|128)}else if(o<1114112){if((s-=4)<0)break;x.push(o>>18|240,o>>12&63|128,o>>6&63|128,o&63|128)}else throw new Error("Invalid code point")}return x}function Ke(c){const s=[];for(let o=0;o<c.length;++o)s.push(c.charCodeAt(o)&255);return s}function ht(c,s){let o,h,y;const x=[];for(let E=0;E<c.length&&!((s-=2)<0);++E)o=c.charCodeAt(E),h=o>>8,y=o%256,x.push(y),x.push(h);return x}function Tt(c){return t.toByteArray(G(c))}function dt(c,s,o,h){let y;for(y=0;y<h&&!(y+o>=s.length||y>=c.length);++y)s[y+o]=c[y];return y}function Ie(c,s){return c instanceof s||c!=null&&c.constructor!=null&&c.constructor.name!=null&&c.constructor.name===s.name}function rt(c){return c!==c}const Pt=function(){const c="0123456789abcdef",s=new Array(256);for(let o=0;o<16;++o){const h=o*16;for(let y=0;y<16;++y)s[h+y]=c[o]+c[y]}return s}();function Ae(c){return typeof BigInt>"u"?nt:c}function nt(){throw new Error("BigInt not supported")}})(At);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(e,t){var r=At,n=r.Buffer;function i(f,u){for(var l in f)u[l]=f[l]}n.from&&n.alloc&&n.allocUnsafe&&n.allocUnsafeSlow?e.exports=r:(i(r,t),t.Buffer=a);function a(f,u,l){return n(f,u,l)}a.prototype=Object.create(n.prototype),i(n,a),a.from=function(f,u,l){if(typeof f=="number")throw new TypeError("Argument must not be a number");return n(f,u,l)},a.alloc=function(f,u,l){if(typeof f!="number")throw new TypeError("Argument must be a number");var b=n(f);return u!==void 0?typeof l=="string"?b.fill(u,l):b.fill(u):b.fill(0),b},a.allocUnsafe=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return n(f)},a.allocUnsafeSlow=function(f){if(typeof f!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(f)}})(en,en.exports);var Be=en.exports,Mr=65536,uf=4294967295;function cf(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
31
|
-
Use Chrome, Firefox or Internet Explorer 11`)}var lf=Be.Buffer,dr=Qe.crypto||Qe.msCrypto;dr&&dr.getRandomValues?Zr.exports=hf:Zr.exports=cf;function hf(e,t){if(e>uf)throw new RangeError("requested too many random bytes");var r=lf.allocUnsafe(e);if(e>0)if(e>Mr)for(var n=0;n<e;n+=Mr)dr.getRandomValues(r.slice(n,n+Mr));else dr.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var df=Zr.exports,tn={exports:{}};typeof Object.create=="function"?tn.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:tn.exports=function(t,r){if(r){t.super_=r;var n=function(){};n.prototype=r.prototype,t.prototype=new n,t.prototype.constructor=t}};var me=tn.exports,rn={exports:{}},En={exports:{}},_t=typeof Reflect=="object"?Reflect:null,Gn=_t&&typeof _t.apply=="function"?_t.apply:function(t,r,n){return Function.prototype.apply.call(t,r,n)},ir;_t&&typeof _t.ownKeys=="function"?ir=_t.ownKeys:Object.getOwnPropertySymbols?ir=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:ir=function(t){return Object.getOwnPropertyNames(t)};function pf(e){console&&console.warn&&console.warn(e)}var es=Number.isNaN||function(t){return t!==t};function K(){K.init.call(this)}En.exports=K;En.exports.once=mf;K.EventEmitter=K;K.prototype._events=void 0;K.prototype._eventsCount=0;K.prototype._maxListeners=void 0;var Wn=10;function xr(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(K,"defaultMaxListeners",{enumerable:!0,get:function(){return Wn},set:function(e){if(typeof e!="number"||e<0||es(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Wn=e}});K.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};K.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||es(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};function ts(e){return e._maxListeners===void 0?K.defaultMaxListeners:e._maxListeners}K.prototype.getMaxListeners=function(){return ts(this)};K.prototype.emit=function(t){for(var r=[],n=1;n<arguments.length;n++)r.push(arguments[n]);var i=t==="error",a=this._events;if(a!==void 0)i=i&&a.error===void 0;else if(!i)return!1;if(i){var f;if(r.length>0&&(f=r[0]),f instanceof Error)throw f;var u=new Error("Unhandled error."+(f?" ("+f.message+")":""));throw u.context=f,u}var l=a[t];if(l===void 0)return!1;if(typeof l=="function")Gn(l,this,r);else for(var b=l.length,g=os(l,b),n=0;n<b;++n)Gn(g[n],this,r);return!0};function rs(e,t,r,n){var i,a,f;if(xr(r),a=e._events,a===void 0?(a=e._events=Object.create(null),e._eventsCount=0):(a.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),a=e._events),f=a[t]),f===void 0)f=a[t]=r,++e._eventsCount;else if(typeof f=="function"?f=a[t]=n?[r,f]:[f,r]:n?f.unshift(r):f.push(r),i=ts(e),i>0&&f.length>i&&!f.warned){f.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+f.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=f.length,pf(u)}return e}K.prototype.addListener=function(t,r){return rs(this,t,r,!1)};K.prototype.on=K.prototype.addListener;K.prototype.prependListener=function(t,r){return rs(this,t,r,!0)};function bf(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function ns(e,t,r){var n={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},i=bf.bind(n);return i.listener=r,n.wrapFn=i,i}K.prototype.once=function(t,r){return xr(r),this.on(t,ns(this,t,r)),this};K.prototype.prependOnceListener=function(t,r){return xr(r),this.prependListener(t,ns(this,t,r)),this};K.prototype.removeListener=function(t,r){var n,i,a,f,u;if(xr(r),i=this._events,i===void 0)return this;if(n=i[t],n===void 0)return this;if(n===r||n.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete i[t],i.removeListener&&this.emit("removeListener",t,n.listener||r));else if(typeof n!="function"){for(a=-1,f=n.length-1;f>=0;f--)if(n[f]===r||n[f].listener===r){u=n[f].listener,a=f;break}if(a<0)return this;a===0?n.shift():yf(n,a),n.length===1&&(i[t]=n[0]),i.removeListener!==void 0&&this.emit("removeListener",t,u||r)}return this};K.prototype.off=K.prototype.removeListener;K.prototype.removeAllListeners=function(t){var r,n,i;if(n=this._events,n===void 0)return this;if(n.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):n[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete n[t]),this;if(arguments.length===0){var a=Object.keys(n),f;for(i=0;i<a.length;++i)f=a[i],f!=="removeListener"&&this.removeAllListeners(f);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=n[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(i=r.length-1;i>=0;i--)this.removeListener(t,r[i]);return this};function is(e,t,r){var n=e._events;if(n===void 0)return[];var i=n[t];return i===void 0?[]:typeof i=="function"?r?[i.listener||i]:[i]:r?gf(i):os(i,i.length)}K.prototype.listeners=function(t){return is(this,t,!0)};K.prototype.rawListeners=function(t){return is(this,t,!1)};K.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):ss.call(e,t)};K.prototype.listenerCount=ss;function ss(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}K.prototype.eventNames=function(){return this._eventsCount>0?ir(this._events):[]};function os(e,t){for(var r=new Array(t),n=0;n<t;++n)r[n]=e[n];return r}function yf(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function gf(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function mf(e,t){return new Promise(function(r,n){function i(f){e.removeListener(t,a),n(f)}function a(){typeof e.removeListener=="function"&&e.removeListener("error",i),r([].slice.call(arguments))}as(e,t,a,{once:!0}),t!=="error"&&_f(e,i,{once:!0})})}function _f(e,t,r){typeof e.on=="function"&&as(e,"error",t,r)}function as(e,t,r,n){if(typeof e.on=="function")n.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function i(a){n.once&&e.removeEventListener(t,i),r(a)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var fs=En.exports,us=fs.EventEmitter;const wf={},xf=Object.freeze(Object.defineProperty({__proto__:null,default:wf},Symbol.toStringTag,{value:"Module"})),Bn=qa(xf);var Dr,qn;function vf(){if(qn)return Dr;qn=1;function e(B,k){var T=Object.keys(B);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(B);k&&(C=C.filter(function(F){return Object.getOwnPropertyDescriptor(B,F).enumerable})),T.push.apply(T,C)}return T}function t(B){for(var k=1;k<arguments.length;k++){var T=arguments[k]!=null?arguments[k]:{};k%2?e(Object(T),!0).forEach(function(C){r(B,C,T[C])}):Object.getOwnPropertyDescriptors?Object.defineProperties(B,Object.getOwnPropertyDescriptors(T)):e(Object(T)).forEach(function(C){Object.defineProperty(B,C,Object.getOwnPropertyDescriptor(T,C))})}return B}function r(B,k,T){return k=f(k),k in B?Object.defineProperty(B,k,{value:T,enumerable:!0,configurable:!0,writable:!0}):B[k]=T,B}function n(B,k){if(!(B instanceof k))throw new TypeError("Cannot call a class as a function")}function i(B,k){for(var T=0;T<k.length;T++){var C=k[T];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(B,f(C.key),C)}}function a(B,k,T){return k&&i(B.prototype,k),Object.defineProperty(B,"prototype",{writable:!1}),B}function f(B){var k=u(B,"string");return typeof k=="symbol"?k:String(k)}function u(B,k){if(typeof B!="object"||B===null)return B;var T=B[Symbol.toPrimitive];if(T!==void 0){var C=T.call(B,k||"default");if(typeof C!="object")return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return(k==="string"?String:Number)(B)}var l=At,b=l.Buffer,g=Bn,m=g.inspect,v=m&&m.custom||"inspect";function I(B,k,T){b.prototype.copy.call(B,k,T)}return Dr=function(){function B(){n(this,B),this.head=null,this.tail=null,this.length=0}return a(B,[{key:"push",value:function(T){var C={data:T,next:null};this.length>0?this.tail.next=C:this.head=C,this.tail=C,++this.length}},{key:"unshift",value:function(T){var C={data:T,next:this.head};this.length===0&&(this.tail=C),this.head=C,++this.length}},{key:"shift",value:function(){if(this.length!==0){var T=this.head.data;return this.length===1?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(this.length===0)return"";for(var C=this.head,F=""+C.data;C=C.next;)F+=T+C.data;return F}},{key:"concat",value:function(T){if(this.length===0)return b.alloc(0);for(var C=b.allocUnsafe(T>>>0),F=this.head,O=0;F;)I(F.data,C,O),O+=F.data.length,F=F.next;return C}},{key:"consume",value:function(T,C){var F;return T<this.head.data.length?(F=this.head.data.slice(0,T),this.head.data=this.head.data.slice(T)):T===this.head.data.length?F=this.shift():F=C?this._getString(T):this._getBuffer(T),F}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(T){var C=this.head,F=1,O=C.data;for(T-=O.length;C=C.next;){var L=C.data,U=T>L.length?L.length:T;if(U===L.length?O+=L:O+=L.slice(0,T),T-=U,T===0){U===L.length?(++F,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=L.slice(U));break}++F}return this.length-=F,O}},{key:"_getBuffer",value:function(T){var C=b.allocUnsafe(T),F=this.head,O=1;for(F.data.copy(C),T-=F.data.length;F=F.next;){var L=F.data,U=T>L.length?L.length:T;if(L.copy(C,C.length-T,0,U),T-=U,T===0){U===L.length?(++O,F.next?this.head=F.next:this.head=this.tail=null):(this.head=F,F.data=L.slice(U));break}++O}return this.length-=O,C}},{key:v,value:function(T,C){return m(this,t(t({},C),{},{depth:0,customInspect:!1}))}}]),B}(),Dr}function Ef(e,t){var r=this,n=this._readableState&&this._readableState.destroyed,i=this._writableState&&this._writableState.destroyed;return n||i?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(nn,this,e)):process.nextTick(nn,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(a){!t&&a?r._writableState?r._writableState.errorEmitted?process.nextTick(sr,r):(r._writableState.errorEmitted=!0,process.nextTick(Vn,r,a)):process.nextTick(Vn,r,a):t?(process.nextTick(sr,r),t(a)):process.nextTick(sr,r)}),this)}function Vn(e,t){nn(e,t),sr(e)}function sr(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function Bf(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function nn(e,t){e.emit("error",t)}function Sf(e,t){var r=e._readableState,n=e._writableState;r&&r.autoDestroy||n&&n.autoDestroy?e.destroy(t):e.emit("error",t)}var cs={destroy:Ef,undestroy:Bf,errorOrDestroy:Sf},ct={};function If(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var ls={};function Te(e,t,r){r||(r=Error);function n(a,f,u){return typeof t=="string"?t:t(a,f,u)}var i=function(a){If(f,a);function f(u,l,b){return a.call(this,n(u,l,b))||this}return f}(r);i.prototype.name=r.name,i.prototype.code=e,ls[e]=i}function Kn(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(n){return String(n)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function Af(e,t,r){return e.substr(0,t.length)===t}function Rf(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function Tf(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Te("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Te("ERR_INVALID_ARG_TYPE",function(e,t,r){var n;typeof t=="string"&&Af(t,"not ")?(n="must not be",t=t.replace(/^not /,"")):n="must be";var i;if(Rf(e," argument"))i="The ".concat(e," ").concat(n," ").concat(Kn(t,"type"));else{var a=Tf(e,".")?"property":"argument";i='The "'.concat(e,'" ').concat(a," ").concat(n," ").concat(Kn(t,"type"))}return i+=". Received type ".concat(typeof r),i},TypeError);Te("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Te("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});Te("ERR_STREAM_PREMATURE_CLOSE","Premature close");Te("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});Te("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Te("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Te("ERR_STREAM_WRITE_AFTER_END","write after end");Te("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Te("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);Te("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");ct.codes=ls;var Pf=ct.codes.ERR_INVALID_OPT_VALUE;function kf(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function Cf(e,t,r,n){var i=kf(t,n,r);if(i!=null){if(!(isFinite(i)&&Math.floor(i)===i)||i<0){var a=n?r:"highWaterMark";throw new Pf(a,i)}return Math.floor(i)}return e.objectMode?16:16*1024}var hs={getHighWaterMark:Cf},Lf=Of;function Of(e,t){if($r("noDeprecation"))return e;var r=!1;function n(){if(!r){if($r("throwDeprecation"))throw new Error(t);$r("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return n}function $r(e){try{if(!Qe.localStorage)return!1}catch{return!1}var t=Qe.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var Hr,Yn;function ds(){if(Yn)return Hr;Yn=1,Hr=M;function e(w){var _=this;this.next=null,this.entry=null,this.finish=function(){Ne(_,w)}}var t;M.WritableState=S;var r={deprecate:Lf},n=us,i=At.Buffer,a=(typeof Qe<"u"?Qe:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function f(w){return i.from(w)}function u(w){return i.isBuffer(w)||w instanceof a}var l=cs,b=hs,g=b.getHighWaterMark,m=ct.codes,v=m.ERR_INVALID_ARG_TYPE,I=m.ERR_METHOD_NOT_IMPLEMENTED,B=m.ERR_MULTIPLE_CALLBACK,k=m.ERR_STREAM_CANNOT_PIPE,T=m.ERR_STREAM_DESTROYED,C=m.ERR_STREAM_NULL_VALUES,F=m.ERR_STREAM_WRITE_AFTER_END,O=m.ERR_UNKNOWN_ENCODING,L=l.errorOrDestroy;me(M,n);function U(){}function S(w,_,R){t=t||Bt(),w=w||{},typeof R!="boolean"&&(R=_ instanceof t),this.objectMode=!!w.objectMode,R&&(this.objectMode=this.objectMode||!!w.writableObjectMode),this.highWaterMark=g(this,w,"writableHighWaterMark",R),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var D=w.decodeStrings===!1;this.decodeStrings=!D,this.defaultEncoding=w.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(j){tt(_,j)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=w.emitClose!==!1,this.autoDestroy=!!w.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}S.prototype.getBuffer=function(){for(var _=this.bufferedRequest,R=[];_;)R.push(_),_=_.next;return R},function(){try{Object.defineProperty(S.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var z;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(z=Function.prototype[Symbol.hasInstance],Object.defineProperty(M,Symbol.hasInstance,{value:function(_){return z.call(this,_)?!0:this!==M?!1:_&&_._writableState instanceof S}})):z=function(_){return _ instanceof this};function M(w){t=t||Bt();var _=this instanceof t;if(!_&&!z.call(M,this))return new M(w);this._writableState=new S(w,this,_),this.writable=!0,w&&(typeof w.write=="function"&&(this._write=w.write),typeof w.writev=="function"&&(this._writev=w.writev),typeof w.destroy=="function"&&(this._destroy=w.destroy),typeof w.final=="function"&&(this._final=w.final)),n.call(this)}M.prototype.pipe=function(){L(this,new k)};function $(w,_){var R=new F;L(w,R),process.nextTick(_,R)}function oe(w,_,R,D){var j;return R===null?j=new C:typeof R!="string"&&!_.objectMode&&(j=new v("chunk",["string","Buffer"],R)),j?(L(w,j),process.nextTick(D,j),!1):!0}M.prototype.write=function(w,_,R){var D=this._writableState,j=!1,d=!D.objectMode&&u(w);return d&&!i.isBuffer(w)&&(w=f(w)),typeof _=="function"&&(R=_,_=null),d?_="buffer":_||(_=D.defaultEncoding),typeof R!="function"&&(R=U),D.ending?$(this,R):(d||oe(this,D,w,R))&&(D.pendingcb++,j=Ge(this,D,d,w,_,R)),j},M.prototype.cork=function(){this._writableState.corked++},M.prototype.uncork=function(){var w=this._writableState;w.corked&&(w.corked--,!w.writing&&!w.corked&&!w.bufferProcessing&&w.bufferedRequest&&Ce(this,w))},M.prototype.setDefaultEncoding=function(_){if(typeof _=="string"&&(_=_.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((_+"").toLowerCase())>-1))throw new O(_);return this._writableState.defaultEncoding=_,this},Object.defineProperty(M.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Pe(w,_,R){return!w.objectMode&&w.decodeStrings!==!1&&typeof _=="string"&&(_=i.from(_,R)),_}Object.defineProperty(M.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function Ge(w,_,R,D,j,d){if(!R){var p=Pe(_,D,j);D!==p&&(R=!0,j="buffer",D=p)}var A=_.objectMode?1:D.length;_.length+=A;var N=_.length<_.highWaterMark;if(N||(_.needDrain=!0),_.writing||_.corked){var te=_.lastBufferedRequest;_.lastBufferedRequest={chunk:D,encoding:j,isBuf:R,callback:d,next:null},te?te.next=_.lastBufferedRequest:_.bufferedRequest=_.lastBufferedRequest,_.bufferedRequestCount+=1}else fe(w,_,!1,A,D,j,d);return N}function fe(w,_,R,D,j,d,p){_.writelen=D,_.writecb=p,_.writing=!0,_.sync=!0,_.destroyed?_.onwrite(new T("write")):R?w._writev(j,_.onwrite):w._write(j,d,_.onwrite),_.sync=!1}function ve(w,_,R,D,j){--_.pendingcb,R?(process.nextTick(j,D),process.nextTick(Se,w,_),w._writableState.errorEmitted=!0,L(w,D)):(j(D),w._writableState.errorEmitted=!0,L(w,D),Se(w,_))}function Ee(w){w.writing=!1,w.writecb=null,w.length-=w.writelen,w.writelen=0}function tt(w,_){var R=w._writableState,D=R.sync,j=R.writecb;if(typeof j!="function")throw new B;if(Ee(R),_)ve(w,R,D,_,j);else{var d=qe(R)||w.destroyed;!d&&!R.corked&&!R.bufferProcessing&&R.bufferedRequest&&Ce(w,R),D?process.nextTick(ke,w,R,d,j):ke(w,R,d,j)}}function ke(w,_,R,D){R||We(w,_),_.pendingcb--,D(),Se(w,_)}function We(w,_){_.length===0&&_.needDrain&&(_.needDrain=!1,w.emit("drain"))}function Ce(w,_){_.bufferProcessing=!0;var R=_.bufferedRequest;if(w._writev&&R&&R.next){var D=_.bufferedRequestCount,j=new Array(D),d=_.corkedRequestsFree;d.entry=R;for(var p=0,A=!0;R;)j[p]=R,R.isBuf||(A=!1),R=R.next,p+=1;j.allBuffers=A,fe(w,_,!0,_.length,j,"",d.finish),_.pendingcb++,_.lastBufferedRequest=null,d.next?(_.corkedRequestsFree=d.next,d.next=null):_.corkedRequestsFree=new e(_),_.bufferedRequestCount=0}else{for(;R;){var N=R.chunk,te=R.encoding,G=R.callback,V=_.objectMode?1:N.length;if(fe(w,_,!1,V,N,te,G),R=R.next,_.bufferedRequestCount--,_.writing)break}R===null&&(_.lastBufferedRequest=null)}_.bufferedRequest=R,_.bufferProcessing=!1}M.prototype._write=function(w,_,R){R(new I("_write()"))},M.prototype._writev=null,M.prototype.end=function(w,_,R){var D=this._writableState;return typeof w=="function"?(R=w,w=null,_=null):typeof _=="function"&&(R=_,_=null),w!=null&&this.write(w,_),D.corked&&(D.corked=1,this.uncork()),D.ending||Ve(this,D,R),this},Object.defineProperty(M.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function qe(w){return w.ending&&w.length===0&&w.bufferedRequest===null&&!w.finished&&!w.writing}function ee(w,_){w._final(function(R){_.pendingcb--,R&&L(w,R),_.prefinished=!0,w.emit("prefinish"),Se(w,_)})}function ae(w,_){!_.prefinished&&!_.finalCalled&&(typeof w._final=="function"&&!_.destroyed?(_.pendingcb++,_.finalCalled=!0,process.nextTick(ee,w,_)):(_.prefinished=!0,w.emit("prefinish")))}function Se(w,_){var R=qe(_);if(R&&(ae(w,_),_.pendingcb===0&&(_.finished=!0,w.emit("finish"),_.autoDestroy))){var D=w._readableState;(!D||D.autoDestroy&&D.endEmitted)&&w.destroy()}return R}function Ve(w,_,R){_.ending=!0,Se(w,_),R&&(_.finished?process.nextTick(R):w.once("finish",R)),_.ended=!0,w.writable=!1}function Ne(w,_,R){var D=w.entry;for(w.entry=null;D;){var j=D.callback;_.pendingcb--,j(R),D=D.next}_.corkedRequestsFree.next=w}return Object.defineProperty(M.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(_){this._writableState&&(this._writableState.destroyed=_)}}),M.prototype.destroy=l.destroy,M.prototype._undestroy=l.undestroy,M.prototype._destroy=function(w,_){_(w)},Hr}var zr,Jn;function Bt(){if(Jn)return zr;Jn=1;var e=Object.keys||function(b){var g=[];for(var m in b)g.push(m);return g};zr=f;var t=bs(),r=ds();me(f,t);for(var n=e(r.prototype),i=0;i<n.length;i++){var a=n[i];f.prototype[a]||(f.prototype[a]=r.prototype[a])}function f(b){if(!(this instanceof f))return new f(b);t.call(this,b),r.call(this,b),this.allowHalfOpen=!0,b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",u)))}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}});function u(){this._writableState.ended||process.nextTick(l,this)}function l(b){b.end()}return Object.defineProperty(f.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(g){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=g,this._writableState.destroyed=g)}}),zr}var pr={},Sn=Be.Buffer,Xn=Sn.isEncoding||function(e){switch(e=""+e,e&&e.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 Ff(e){if(!e)return"utf8";for(var t;;)switch(e){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 e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function Uf(e){var t=Ff(e);if(typeof t!="string"&&(Sn.isEncoding===Xn||!Xn(e)))throw new Error("Unknown encoding: "+e);return t||e}pr.StringDecoder=Jt;function Jt(e){this.encoding=Uf(e);var t;switch(this.encoding){case"utf16le":this.text=zf,this.end=jf,t=4;break;case"utf8":this.fillLast=Df,t=4;break;case"base64":this.text=Gf,this.end=Wf,t=3;break;default:this.write=qf,this.end=Vf;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Sn.allocUnsafe(t)}Jt.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Jt.prototype.end=Hf;Jt.prototype.text=$f;Jt.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function jr(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Nf(e,t,r){var n=t.length-1;if(n<r)return 0;var i=jr(t[n]);return i>=0?(i>0&&(e.lastNeed=i-1),i):--n<r||i===-2?0:(i=jr(t[n]),i>=0?(i>0&&(e.lastNeed=i-2),i):--n<r||i===-2?0:(i=jr(t[n]),i>=0?(i>0&&(i===2?i=0:e.lastNeed=i-3),i):0))}function Mf(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"�"}}function Df(e){var t=this.lastTotal-this.lastNeed,r=Mf(this,e);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function $f(e,t){var r=Nf(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var n=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,n),e.toString("utf8",t,n)}function Hf(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function zf(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var n=r.charCodeAt(r.length-1);if(n>=55296&&n<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function jf(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function Gf(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Wf(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function qf(e){return e.toString(this.encoding)}function Vf(e){return e&&e.length?this.write(e):""}var Qn=ct.codes.ERR_STREAM_PREMATURE_CLOSE;function Kf(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,n=new Array(r),i=0;i<r;i++)n[i]=arguments[i];e.apply(this,n)}}}function Yf(){}function Jf(e){return e.setHeader&&typeof e.abort=="function"}function ps(e,t,r){if(typeof t=="function")return ps(e,null,t);t||(t={}),r=Kf(r||Yf);var n=t.readable||t.readable!==!1&&e.readable,i=t.writable||t.writable!==!1&&e.writable,a=function(){e.writable||u()},f=e._writableState&&e._writableState.finished,u=function(){i=!1,f=!0,n||r.call(e)},l=e._readableState&&e._readableState.endEmitted,b=function(){n=!1,l=!0,i||r.call(e)},g=function(B){r.call(e,B)},m=function(){var B;if(n&&!l)return(!e._readableState||!e._readableState.ended)&&(B=new Qn),r.call(e,B);if(i&&!f)return(!e._writableState||!e._writableState.ended)&&(B=new Qn),r.call(e,B)},v=function(){e.req.on("finish",u)};return Jf(e)?(e.on("complete",u),e.on("abort",m),e.req?v():e.on("request",v)):i&&!e._writableState&&(e.on("end",a),e.on("close",a)),e.on("end",b),e.on("finish",u),t.error!==!1&&e.on("error",g),e.on("close",m),function(){e.removeListener("complete",u),e.removeListener("abort",m),e.removeListener("request",v),e.req&&e.req.removeListener("finish",u),e.removeListener("end",a),e.removeListener("close",a),e.removeListener("finish",u),e.removeListener("end",b),e.removeListener("error",g),e.removeListener("close",m)}}var In=ps,Gr,Zn;function Xf(){if(Zn)return Gr;Zn=1;var e;function t(O,L,U){return L=r(L),L in O?Object.defineProperty(O,L,{value:U,enumerable:!0,configurable:!0,writable:!0}):O[L]=U,O}function r(O){var L=n(O,"string");return typeof L=="symbol"?L:String(L)}function n(O,L){if(typeof O!="object"||O===null)return O;var U=O[Symbol.toPrimitive];if(U!==void 0){var S=U.call(O,L||"default");if(typeof S!="object")return S;throw new TypeError("@@toPrimitive must return a primitive value.")}return(L==="string"?String:Number)(O)}var i=In,a=Symbol("lastResolve"),f=Symbol("lastReject"),u=Symbol("error"),l=Symbol("ended"),b=Symbol("lastPromise"),g=Symbol("handlePromise"),m=Symbol("stream");function v(O,L){return{value:O,done:L}}function I(O){var L=O[a];if(L!==null){var U=O[m].read();U!==null&&(O[b]=null,O[a]=null,O[f]=null,L(v(U,!1)))}}function B(O){process.nextTick(I,O)}function k(O,L){return function(U,S){O.then(function(){if(L[l]){U(v(void 0,!0));return}L[g](U,S)},S)}}var T=Object.getPrototypeOf(function(){}),C=Object.setPrototypeOf((e={get stream(){return this[m]},next:function(){var L=this,U=this[u];if(U!==null)return Promise.reject(U);if(this[l])return Promise.resolve(v(void 0,!0));if(this[m].destroyed)return new Promise(function($,oe){process.nextTick(function(){L[u]?oe(L[u]):$(v(void 0,!0))})});var S=this[b],z;if(S)z=new Promise(k(S,this));else{var M=this[m].read();if(M!==null)return Promise.resolve(v(M,!1));z=new Promise(this[g])}return this[b]=z,z}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var L=this;return new Promise(function(U,S){L[m].destroy(null,function(z){if(z){S(z);return}U(v(void 0,!0))})})}),e),T),F=function(L){var U,S=Object.create(C,(U={},t(U,m,{value:L,writable:!0}),t(U,a,{value:null,writable:!0}),t(U,f,{value:null,writable:!0}),t(U,u,{value:null,writable:!0}),t(U,l,{value:L._readableState.endEmitted,writable:!0}),t(U,g,{value:function(M,$){var oe=S[m].read();oe?(S[b]=null,S[a]=null,S[f]=null,M(v(oe,!1))):(S[a]=M,S[f]=$)},writable:!0}),U));return S[b]=null,i(L,function(z){if(z&&z.code!=="ERR_STREAM_PREMATURE_CLOSE"){var M=S[f];M!==null&&(S[b]=null,S[a]=null,S[f]=null,M(z)),S[u]=z;return}var $=S[a];$!==null&&(S[b]=null,S[a]=null,S[f]=null,$(v(void 0,!0))),S[l]=!0}),L.on("readable",B.bind(null,S)),S};return Gr=F,Gr}var Wr,ei;function Qf(){return ei||(ei=1,Wr=function(){throw new Error("Readable.from is not available in the browser")}),Wr}var qr,ti;function bs(){if(ti)return qr;ti=1,qr=$;var e;$.ReadableState=M,fs.EventEmitter;var t=function(p,A){return p.listeners(A).length},r=us,n=At.Buffer,i=(typeof Qe<"u"?Qe:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function a(d){return n.from(d)}function f(d){return n.isBuffer(d)||d instanceof i}var u=Bn,l;u&&u.debuglog?l=u.debuglog("stream"):l=function(){};var b=vf(),g=cs,m=hs,v=m.getHighWaterMark,I=ct.codes,B=I.ERR_INVALID_ARG_TYPE,k=I.ERR_STREAM_PUSH_AFTER_EOF,T=I.ERR_METHOD_NOT_IMPLEMENTED,C=I.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,F,O,L;me($,r);var U=g.errorOrDestroy,S=["error","close","destroy","pause","resume"];function z(d,p,A){if(typeof d.prependListener=="function")return d.prependListener(p,A);!d._events||!d._events[p]?d.on(p,A):Array.isArray(d._events[p])?d._events[p].unshift(A):d._events[p]=[A,d._events[p]]}function M(d,p,A){e=e||Bt(),d=d||{},typeof A!="boolean"&&(A=p instanceof e),this.objectMode=!!d.objectMode,A&&(this.objectMode=this.objectMode||!!d.readableObjectMode),this.highWaterMark=v(this,d,"readableHighWaterMark",A),this.buffer=new b,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=d.emitClose!==!1,this.autoDestroy=!!d.autoDestroy,this.destroyed=!1,this.defaultEncoding=d.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,d.encoding&&(F||(F=pr.StringDecoder),this.decoder=new F(d.encoding),this.encoding=d.encoding)}function $(d){if(e=e||Bt(),!(this instanceof $))return new $(d);var p=this instanceof e;this._readableState=new M(d,this,p),this.readable=!0,d&&(typeof d.read=="function"&&(this._read=d.read),typeof d.destroy=="function"&&(this._destroy=d.destroy)),r.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(p){this._readableState&&(this._readableState.destroyed=p)}}),$.prototype.destroy=g.destroy,$.prototype._undestroy=g.undestroy,$.prototype._destroy=function(d,p){p(d)},$.prototype.push=function(d,p){var A=this._readableState,N;return A.objectMode?N=!0:typeof d=="string"&&(p=p||A.defaultEncoding,p!==A.encoding&&(d=n.from(d,p),p=""),N=!0),oe(this,d,p,!1,N)},$.prototype.unshift=function(d){return oe(this,d,null,!0,!1)};function oe(d,p,A,N,te){l("readableAddChunk",p);var G=d._readableState;if(p===null)G.reading=!1,tt(d,G);else{var V;if(te||(V=Ge(G,p)),V)U(d,V);else if(G.objectMode||p&&p.length>0)if(typeof p!="string"&&!G.objectMode&&Object.getPrototypeOf(p)!==n.prototype&&(p=a(p)),N)G.endEmitted?U(d,new C):Pe(d,G,p,!0);else if(G.ended)U(d,new k);else{if(G.destroyed)return!1;G.reading=!1,G.decoder&&!A?(p=G.decoder.write(p),G.objectMode||p.length!==0?Pe(d,G,p,!1):Ce(d,G)):Pe(d,G,p,!1)}else N||(G.reading=!1,Ce(d,G))}return!G.ended&&(G.length<G.highWaterMark||G.length===0)}function Pe(d,p,A,N){p.flowing&&p.length===0&&!p.sync?(p.awaitDrain=0,d.emit("data",A)):(p.length+=p.objectMode?1:A.length,N?p.buffer.unshift(A):p.buffer.push(A),p.needReadable&&ke(d)),Ce(d,p)}function Ge(d,p){var A;return!f(p)&&typeof p!="string"&&p!==void 0&&!d.objectMode&&(A=new B("chunk",["string","Buffer","Uint8Array"],p)),A}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(d){F||(F=pr.StringDecoder);var p=new F(d);this._readableState.decoder=p,this._readableState.encoding=this._readableState.decoder.encoding;for(var A=this._readableState.buffer.head,N="";A!==null;)N+=p.write(A.data),A=A.next;return this._readableState.buffer.clear(),N!==""&&this._readableState.buffer.push(N),this._readableState.length=N.length,this};var fe=1073741824;function ve(d){return d>=fe?d=fe:(d--,d|=d>>>1,d|=d>>>2,d|=d>>>4,d|=d>>>8,d|=d>>>16,d++),d}function Ee(d,p){return d<=0||p.length===0&&p.ended?0:p.objectMode?1:d!==d?p.flowing&&p.length?p.buffer.head.data.length:p.length:(d>p.highWaterMark&&(p.highWaterMark=ve(d)),d<=p.length?d:p.ended?p.length:(p.needReadable=!0,0))}$.prototype.read=function(d){l("read",d),d=parseInt(d,10);var p=this._readableState,A=d;if(d!==0&&(p.emittedReadable=!1),d===0&&p.needReadable&&((p.highWaterMark!==0?p.length>=p.highWaterMark:p.length>0)||p.ended))return l("read: emitReadable",p.length,p.ended),p.length===0&&p.ended?R(this):ke(this),null;if(d=Ee(d,p),d===0&&p.ended)return p.length===0&&R(this),null;var N=p.needReadable;l("need readable",N),(p.length===0||p.length-d<p.highWaterMark)&&(N=!0,l("length less than watermark",N)),p.ended||p.reading?(N=!1,l("reading or ended",N)):N&&(l("do read"),p.reading=!0,p.sync=!0,p.length===0&&(p.needReadable=!0),this._read(p.highWaterMark),p.sync=!1,p.reading||(d=Ee(A,p)));var te;return d>0?te=_(d,p):te=null,te===null?(p.needReadable=p.length<=p.highWaterMark,d=0):(p.length-=d,p.awaitDrain=0),p.length===0&&(p.ended||(p.needReadable=!0),A!==d&&p.ended&&R(this)),te!==null&&this.emit("data",te),te};function tt(d,p){if(l("onEofChunk"),!p.ended){if(p.decoder){var A=p.decoder.end();A&&A.length&&(p.buffer.push(A),p.length+=p.objectMode?1:A.length)}p.ended=!0,p.sync?ke(d):(p.needReadable=!1,p.emittedReadable||(p.emittedReadable=!0,We(d)))}}function ke(d){var p=d._readableState;l("emitReadable",p.needReadable,p.emittedReadable),p.needReadable=!1,p.emittedReadable||(l("emitReadable",p.flowing),p.emittedReadable=!0,process.nextTick(We,d))}function We(d){var p=d._readableState;l("emitReadable_",p.destroyed,p.length,p.ended),!p.destroyed&&(p.length||p.ended)&&(d.emit("readable"),p.emittedReadable=!1),p.needReadable=!p.flowing&&!p.ended&&p.length<=p.highWaterMark,w(d)}function Ce(d,p){p.readingMore||(p.readingMore=!0,process.nextTick(qe,d,p))}function qe(d,p){for(;!p.reading&&!p.ended&&(p.length<p.highWaterMark||p.flowing&&p.length===0);){var A=p.length;if(l("maybeReadMore read 0"),d.read(0),A===p.length)break}p.readingMore=!1}$.prototype._read=function(d){U(this,new T("_read()"))},$.prototype.pipe=function(d,p){var A=this,N=this._readableState;switch(N.pipesCount){case 0:N.pipes=d;break;case 1:N.pipes=[N.pipes,d];break;default:N.pipes.push(d);break}N.pipesCount+=1,l("pipe count=%d opts=%j",N.pipesCount,p);var te=(!p||p.end!==!1)&&d!==process.stdout&&d!==process.stderr,G=te?Ke:nt;N.endEmitted?process.nextTick(G):A.once("end",G),d.on("unpipe",V);function V(c,s){l("onunpipe"),c===A&&s&&s.hasUnpiped===!1&&(s.hasUnpiped=!0,dt())}function Ke(){l("onend"),d.end()}var ht=ee(A);d.on("drain",ht);var Tt=!1;function dt(){l("cleanup"),d.removeListener("close",Pt),d.removeListener("finish",Ae),d.removeListener("drain",ht),d.removeListener("error",rt),d.removeListener("unpipe",V),A.removeListener("end",Ke),A.removeListener("end",nt),A.removeListener("data",Ie),Tt=!0,N.awaitDrain&&(!d._writableState||d._writableState.needDrain)&&ht()}A.on("data",Ie);function Ie(c){l("ondata");var s=d.write(c);l("dest.write",s),s===!1&&((N.pipesCount===1&&N.pipes===d||N.pipesCount>1&&j(N.pipes,d)!==-1)&&!Tt&&(l("false write response, pause",N.awaitDrain),N.awaitDrain++),A.pause())}function rt(c){l("onerror",c),nt(),d.removeListener("error",rt),t(d,"error")===0&&U(d,c)}z(d,"error",rt);function Pt(){d.removeListener("finish",Ae),nt()}d.once("close",Pt);function Ae(){l("onfinish"),d.removeListener("close",Pt),nt()}d.once("finish",Ae);function nt(){l("unpipe"),A.unpipe(d)}return d.emit("pipe",A),N.flowing||(l("pipe resume"),A.resume()),d};function ee(d){return function(){var A=d._readableState;l("pipeOnDrain",A.awaitDrain),A.awaitDrain&&A.awaitDrain--,A.awaitDrain===0&&t(d,"data")&&(A.flowing=!0,w(d))}}$.prototype.unpipe=function(d){var p=this._readableState,A={hasUnpiped:!1};if(p.pipesCount===0)return this;if(p.pipesCount===1)return d&&d!==p.pipes?this:(d||(d=p.pipes),p.pipes=null,p.pipesCount=0,p.flowing=!1,d&&d.emit("unpipe",this,A),this);if(!d){var N=p.pipes,te=p.pipesCount;p.pipes=null,p.pipesCount=0,p.flowing=!1;for(var G=0;G<te;G++)N[G].emit("unpipe",this,{hasUnpiped:!1});return this}var V=j(p.pipes,d);return V===-1?this:(p.pipes.splice(V,1),p.pipesCount-=1,p.pipesCount===1&&(p.pipes=p.pipes[0]),d.emit("unpipe",this,A),this)},$.prototype.on=function(d,p){var A=r.prototype.on.call(this,d,p),N=this._readableState;return d==="data"?(N.readableListening=this.listenerCount("readable")>0,N.flowing!==!1&&this.resume()):d==="readable"&&!N.endEmitted&&!N.readableListening&&(N.readableListening=N.needReadable=!0,N.flowing=!1,N.emittedReadable=!1,l("on readable",N.length,N.reading),N.length?ke(this):N.reading||process.nextTick(Se,this)),A},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(d,p){var A=r.prototype.removeListener.call(this,d,p);return d==="readable"&&process.nextTick(ae,this),A},$.prototype.removeAllListeners=function(d){var p=r.prototype.removeAllListeners.apply(this,arguments);return(d==="readable"||d===void 0)&&process.nextTick(ae,this),p};function ae(d){var p=d._readableState;p.readableListening=d.listenerCount("readable")>0,p.resumeScheduled&&!p.paused?p.flowing=!0:d.listenerCount("data")>0&&d.resume()}function Se(d){l("readable nexttick read 0"),d.read(0)}$.prototype.resume=function(){var d=this._readableState;return d.flowing||(l("resume"),d.flowing=!d.readableListening,Ve(this,d)),d.paused=!1,this};function Ve(d,p){p.resumeScheduled||(p.resumeScheduled=!0,process.nextTick(Ne,d,p))}function Ne(d,p){l("resume",p.reading),p.reading||d.read(0),p.resumeScheduled=!1,d.emit("resume"),w(d),p.flowing&&!p.reading&&d.read(0)}$.prototype.pause=function(){return l("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(l("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function w(d){var p=d._readableState;for(l("flow",p.flowing);p.flowing&&d.read()!==null;);}$.prototype.wrap=function(d){var p=this,A=this._readableState,N=!1;d.on("end",function(){if(l("wrapped end"),A.decoder&&!A.ended){var V=A.decoder.end();V&&V.length&&p.push(V)}p.push(null)}),d.on("data",function(V){if(l("wrapped data"),A.decoder&&(V=A.decoder.write(V)),!(A.objectMode&&V==null)&&!(!A.objectMode&&(!V||!V.length))){var Ke=p.push(V);Ke||(N=!0,d.pause())}});for(var te in d)this[te]===void 0&&typeof d[te]=="function"&&(this[te]=function(Ke){return function(){return d[Ke].apply(d,arguments)}}(te));for(var G=0;G<S.length;G++)d.on(S[G],this.emit.bind(this,S[G]));return this._read=function(V){l("wrapped _read",V),N&&(N=!1,d.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return O===void 0&&(O=Xf()),O(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(p){this._readableState&&(this._readableState.flowing=p)}}),$._fromList=_,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function _(d,p){if(p.length===0)return null;var A;return p.objectMode?A=p.buffer.shift():!d||d>=p.length?(p.decoder?A=p.buffer.join(""):p.buffer.length===1?A=p.buffer.first():A=p.buffer.concat(p.length),p.buffer.clear()):A=p.buffer.consume(d,p.decoder),A}function R(d){var p=d._readableState;l("endReadable",p.endEmitted),p.endEmitted||(p.ended=!0,process.nextTick(D,p,d))}function D(d,p){if(l("endReadableNT",d.endEmitted,d.length),!d.endEmitted&&d.length===0&&(d.endEmitted=!0,p.readable=!1,p.emit("end"),d.autoDestroy)){var A=p._writableState;(!A||A.autoDestroy&&A.finished)&&p.destroy()}}typeof Symbol=="function"&&($.from=function(d,p){return L===void 0&&(L=Qf()),L($,d,p)});function j(d,p){for(var A=0,N=d.length;A<N;A++)if(d[A]===p)return A;return-1}return qr}var ys=je,vr=ct.codes,Zf=vr.ERR_METHOD_NOT_IMPLEMENTED,eu=vr.ERR_MULTIPLE_CALLBACK,tu=vr.ERR_TRANSFORM_ALREADY_TRANSFORMING,ru=vr.ERR_TRANSFORM_WITH_LENGTH_0,Er=Bt();me(je,Er);function nu(e,t){var r=this._transformState;r.transforming=!1;var n=r.writecb;if(n===null)return this.emit("error",new eu);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),n(e);var i=this._readableState;i.reading=!1,(i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}function je(e){if(!(this instanceof je))return new je(e);Er.call(this,e),this._transformState={afterTransform:nu.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",iu)}function iu(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){ri(e,t,r)}):ri(this,null,null)}je.prototype.push=function(e,t){return this._transformState.needTransform=!1,Er.prototype.push.call(this,e,t)};je.prototype._transform=function(e,t,r){r(new Zf("_transform()"))};je.prototype._write=function(e,t,r){var n=this._transformState;if(n.writecb=r,n.writechunk=e,n.writeencoding=t,!n.transforming){var i=this._readableState;(n.needTransform||i.needReadable||i.length<i.highWaterMark)&&this._read(i.highWaterMark)}};je.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};je.prototype._destroy=function(e,t){Er.prototype._destroy.call(this,e,function(r){t(r)})};function ri(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new ru;if(e._transformState.transforming)throw new tu;return e.push(null)}var su=Gt,gs=ys;me(Gt,gs);function Gt(e){if(!(this instanceof Gt))return new Gt(e);gs.call(this,e)}Gt.prototype._transform=function(e,t,r){r(null,e)};var Vr;function ou(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var ms=ct.codes,au=ms.ERR_MISSING_ARGS,fu=ms.ERR_STREAM_DESTROYED;function ni(e){if(e)throw e}function uu(e){return e.setHeader&&typeof e.abort=="function"}function cu(e,t,r,n){n=ou(n);var i=!1;e.on("close",function(){i=!0}),Vr===void 0&&(Vr=In),Vr(e,{readable:t,writable:r},function(f){if(f)return n(f);i=!0,n()});var a=!1;return function(f){if(!i&&!a){if(a=!0,uu(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();n(f||new fu("pipe"))}}}function ii(e){e()}function lu(e,t){return e.pipe(t)}function hu(e){return!e.length||typeof e[e.length-1]!="function"?ni:e.pop()}function du(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var n=hu(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new au("streams");var i,a=t.map(function(f,u){var l=u<t.length-1,b=u>0;return cu(f,l,b,function(g){i||(i=g),g&&a.forEach(ii),!l&&(a.forEach(ii),n(i))})});return t.reduce(lu)}var pu=du;(function(e,t){t=e.exports=bs(),t.Stream=t,t.Readable=t,t.Writable=ds(),t.Duplex=Bt(),t.Transform=ys,t.PassThrough=su,t.finished=In,t.pipeline=pu})(rn,rn.exports);var bu=rn.exports,br=Be.Buffer,_s=bu.Transform,yu=me;function gu(e,t){if(!br.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function et(e){_s.call(this),this._block=br.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}yu(et,_s);et.prototype._transform=function(e,t,r){var n=null;try{this.update(e,t)}catch(i){n=i}r(n)};et.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};et.prototype.update=function(e,t){if(gu(e,"Data"),this._finalized)throw new Error("Digest already called");br.isBuffer(e)||(e=br.from(e,t));for(var r=this._block,n=0;this._blockOffset+e.length-n>=this._blockSize;){for(var i=this._blockOffset;i<this._blockSize;)r[i++]=e[n++];this._update(),this._blockOffset=0}for(;n<e.length;)r[this._blockOffset++]=e[n++];for(var a=0,f=e.length*8;f>0;++a)this._length[a]+=f,f=this._length[a]/4294967296|0,f>0&&(this._length[a]-=4294967296*f);return this};et.prototype._update=function(){throw new Error("_update is not implemented")};et.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};et.prototype._digest=function(){throw new Error("_digest is not implemented")};var ws=et,mu=me,xs=ws,_u=Be.Buffer,wu=new Array(16);function Br(){xs.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}mu(Br,xs);Br.prototype._update=function(){for(var e=wu,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,n=this._b,i=this._c,a=this._d;r=he(r,n,i,a,e[0],3614090360,7),a=he(a,r,n,i,e[1],3905402710,12),i=he(i,a,r,n,e[2],606105819,17),n=he(n,i,a,r,e[3],3250441966,22),r=he(r,n,i,a,e[4],4118548399,7),a=he(a,r,n,i,e[5],1200080426,12),i=he(i,a,r,n,e[6],2821735955,17),n=he(n,i,a,r,e[7],4249261313,22),r=he(r,n,i,a,e[8],1770035416,7),a=he(a,r,n,i,e[9],2336552879,12),i=he(i,a,r,n,e[10],4294925233,17),n=he(n,i,a,r,e[11],2304563134,22),r=he(r,n,i,a,e[12],1804603682,7),a=he(a,r,n,i,e[13],4254626195,12),i=he(i,a,r,n,e[14],2792965006,17),n=he(n,i,a,r,e[15],1236535329,22),r=de(r,n,i,a,e[1],4129170786,5),a=de(a,r,n,i,e[6],3225465664,9),i=de(i,a,r,n,e[11],643717713,14),n=de(n,i,a,r,e[0],3921069994,20),r=de(r,n,i,a,e[5],3593408605,5),a=de(a,r,n,i,e[10],38016083,9),i=de(i,a,r,n,e[15],3634488961,14),n=de(n,i,a,r,e[4],3889429448,20),r=de(r,n,i,a,e[9],568446438,5),a=de(a,r,n,i,e[14],3275163606,9),i=de(i,a,r,n,e[3],4107603335,14),n=de(n,i,a,r,e[8],1163531501,20),r=de(r,n,i,a,e[13],2850285829,5),a=de(a,r,n,i,e[2],4243563512,9),i=de(i,a,r,n,e[7],1735328473,14),n=de(n,i,a,r,e[12],2368359562,20),r=pe(r,n,i,a,e[5],4294588738,4),a=pe(a,r,n,i,e[8],2272392833,11),i=pe(i,a,r,n,e[11],1839030562,16),n=pe(n,i,a,r,e[14],4259657740,23),r=pe(r,n,i,a,e[1],2763975236,4),a=pe(a,r,n,i,e[4],1272893353,11),i=pe(i,a,r,n,e[7],4139469664,16),n=pe(n,i,a,r,e[10],3200236656,23),r=pe(r,n,i,a,e[13],681279174,4),a=pe(a,r,n,i,e[0],3936430074,11),i=pe(i,a,r,n,e[3],3572445317,16),n=pe(n,i,a,r,e[6],76029189,23),r=pe(r,n,i,a,e[9],3654602809,4),a=pe(a,r,n,i,e[12],3873151461,11),i=pe(i,a,r,n,e[15],530742520,16),n=pe(n,i,a,r,e[2],3299628645,23),r=be(r,n,i,a,e[0],4096336452,6),a=be(a,r,n,i,e[7],1126891415,10),i=be(i,a,r,n,e[14],2878612391,15),n=be(n,i,a,r,e[5],4237533241,21),r=be(r,n,i,a,e[12],1700485571,6),a=be(a,r,n,i,e[3],2399980690,10),i=be(i,a,r,n,e[10],4293915773,15),n=be(n,i,a,r,e[1],2240044497,21),r=be(r,n,i,a,e[8],1873313359,6),a=be(a,r,n,i,e[15],4264355552,10),i=be(i,a,r,n,e[6],2734768916,15),n=be(n,i,a,r,e[13],1309151649,21),r=be(r,n,i,a,e[4],4149444226,6),a=be(a,r,n,i,e[11],3174756917,10),i=be(i,a,r,n,e[2],718787259,15),n=be(n,i,a,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+n|0,this._c=this._c+i|0,this._d=this._d+a|0};Br.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 e=_u.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Sr(e,t){return e<<t|e>>>32-t}function he(e,t,r,n,i,a,f){return Sr(e+(t&r|~t&n)+i+a|0,f)+t|0}function de(e,t,r,n,i,a,f){return Sr(e+(t&n|r&~n)+i+a|0,f)+t|0}function pe(e,t,r,n,i,a,f){return Sr(e+(t^r^n)+i+a|0,f)+t|0}function be(e,t,r,n,i,a,f){return Sr(e+(r^(t|~n))+i+a|0,f)+t|0}var xu=Br,Kr=At.Buffer,vu=me,vs=ws,Eu=new Array(16),Ut=[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],Nt=[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],Mt=[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],Dt=[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],$t=[0,1518500249,1859775393,2400959708,2840853838],Ht=[1352829926,1548603684,1836072691,2053994217,0];function Ir(){vs.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}vu(Ir,vs);Ir.prototype._update=function(){for(var e=Eu,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=this._a|0,l=this._b|0,b=this._c|0,g=this._d|0,m=this._e|0,v=0;v<80;v+=1){var I,B;v<16?(I=si(r,n,i,a,f,e[Ut[v]],$t[0],Mt[v]),B=ui(u,l,b,g,m,e[Nt[v]],Ht[0],Dt[v])):v<32?(I=oi(r,n,i,a,f,e[Ut[v]],$t[1],Mt[v]),B=fi(u,l,b,g,m,e[Nt[v]],Ht[1],Dt[v])):v<48?(I=ai(r,n,i,a,f,e[Ut[v]],$t[2],Mt[v]),B=ai(u,l,b,g,m,e[Nt[v]],Ht[2],Dt[v])):v<64?(I=fi(r,n,i,a,f,e[Ut[v]],$t[3],Mt[v]),B=oi(u,l,b,g,m,e[Nt[v]],Ht[3],Dt[v])):(I=ui(r,n,i,a,f,e[Ut[v]],$t[4],Mt[v]),B=si(u,l,b,g,m,e[Nt[v]],Ht[4],Dt[v])),r=f,f=a,a=ut(i,10),i=n,n=I,u=m,m=g,g=ut(b,10),b=l,l=B}var k=this._b+i+g|0;this._b=this._c+a+m|0,this._c=this._d+f+u|0,this._d=this._e+r+l|0,this._e=this._a+n+b|0,this._a=k};Ir.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 e=Kr.alloc?Kr.alloc(20):new Kr(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};function ut(e,t){return e<<t|e>>>32-t}function si(e,t,r,n,i,a,f,u){return ut(e+(t^r^n)+a+f|0,u)+i|0}function oi(e,t,r,n,i,a,f,u){return ut(e+(t&r|~t&n)+a+f|0,u)+i|0}function ai(e,t,r,n,i,a,f,u){return ut(e+((t|~r)^n)+a+f|0,u)+i|0}function fi(e,t,r,n,i,a,f,u){return ut(e+(t&n|r&~n)+a+f|0,u)+i|0}function ui(e,t,r,n,i,a,f,u){return ut(e+(t^(r|~n))+a+f|0,u)+i|0}var Bu=Ir,Es={exports:{}},Bs=Be.Buffer;function Ar(e,t){this._block=Bs.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Ar.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=Bs.from(e,t));for(var r=this._block,n=this._blockSize,i=e.length,a=this._len,f=0;f<i;){for(var u=a%n,l=Math.min(i-f,n-u),b=0;b<l;b++)r[u+b]=e[f+b];a+=l,f+=l,a%n===0&&this._update(r)}return this._len+=i,this};Ar.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var n=(r&4294967295)>>>0,i=(r-n)/4294967296;this._block.writeUInt32BE(i,this._blockSize-8),this._block.writeUInt32BE(n,this._blockSize-4)}this._update(this._block);var a=this._hash();return e?a.toString(e):a};Ar.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var Rt=Ar,Su=me,Ss=Rt,Iu=Be.Buffer,Au=[1518500249,1859775393,-1894007588,-899497514],Ru=new Array(80);function Xt(){this.init(),this._w=Ru,Ss.call(this,64,56)}Su(Xt,Ss);Xt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Tu(e){return e<<5|e>>>27}function Pu(e){return e<<30|e>>>2}function ku(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Xt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var l=0;l<80;++l){var b=~~(l/20),g=Tu(r)+ku(b,n,i,a)+f+t[l]+Au[b]|0;f=a,a=i,i=Pu(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0};Xt.prototype._hash=function(){var e=Iu.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Cu=Xt,Lu=me,Is=Rt,Ou=Be.Buffer,Fu=[1518500249,1859775393,-1894007588,-899497514],Uu=new Array(80);function Qt(){this.init(),this._w=Uu,Is.call(this,64,56)}Lu(Qt,Is);Qt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Nu(e){return e<<1|e>>>31}function Mu(e){return e<<5|e>>>27}function Du(e){return e<<30|e>>>2}function $u(e,t,r,n){return e===0?t&r|~t&n:e===2?t&r|t&n|r&n:t^r^n}Qt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Nu(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var l=0;l<80;++l){var b=~~(l/20),g=Mu(r)+$u(b,n,i,a)+f+t[l]+Fu[b]|0;f=a,a=i,i=Du(n),n=r,r=g}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0};Qt.prototype._hash=function(){var e=Ou.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var Hu=Qt,zu=me,As=Rt,ju=Be.Buffer,Gu=[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],Wu=new Array(64);function Zt(){this.init(),this._w=Wu,As.call(this,64,56)}zu(Zt,As);Zt.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function qu(e,t,r){return r^e&(t^r)}function Vu(e,t,r){return e&t|r&(e|t)}function Ku(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Yu(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Ju(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Xu(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Zt.prototype._update=function(e){for(var t=this._w,r=this._a|0,n=this._b|0,i=this._c|0,a=this._d|0,f=this._e|0,u=this._f|0,l=this._g|0,b=this._h|0,g=0;g<16;++g)t[g]=e.readInt32BE(g*4);for(;g<64;++g)t[g]=Xu(t[g-2])+t[g-7]+Ju(t[g-15])+t[g-16]|0;for(var m=0;m<64;++m){var v=b+Yu(f)+qu(f,u,l)+Gu[m]+t[m]|0,I=Ku(r)+Vu(r,n,i)|0;b=l,l=u,u=f,f=a+v|0,a=i,i=n,n=r,r=v+I|0}this._a=r+this._a|0,this._b=n+this._b|0,this._c=i+this._c|0,this._d=a+this._d|0,this._e=f+this._e|0,this._f=u+this._f|0,this._g=l+this._g|0,this._h=b+this._h|0};Zt.prototype._hash=function(){var e=ju.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var Rs=Zt,Qu=me,Zu=Rs,ec=Rt,tc=Be.Buffer,rc=new Array(64);function Rr(){this.init(),this._w=rc,ec.call(this,64,56)}Qu(Rr,Zu);Rr.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};Rr.prototype._hash=function(){var e=tc.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var nc=Rr,ic=me,Ts=Rt,sc=Be.Buffer,ci=[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],oc=new Array(160);function er(){this.init(),this._w=oc,Ts.call(this,128,112)}ic(er,Ts);er.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function li(e,t,r){return r^e&(t^r)}function hi(e,t,r){return e&t|r&(e|t)}function di(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function pi(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function ac(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function fc(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function uc(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function cc(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function ce(e,t){return e>>>0<t>>>0?1:0}er.prototype._update=function(e){for(var t=this._w,r=this._ah|0,n=this._bh|0,i=this._ch|0,a=this._dh|0,f=this._eh|0,u=this._fh|0,l=this._gh|0,b=this._hh|0,g=this._al|0,m=this._bl|0,v=this._cl|0,I=this._dl|0,B=this._el|0,k=this._fl|0,T=this._gl|0,C=this._hl|0,F=0;F<32;F+=2)t[F]=e.readInt32BE(F*4),t[F+1]=e.readInt32BE(F*4+4);for(;F<160;F+=2){var O=t[F-30],L=t[F-15*2+1],U=ac(O,L),S=fc(L,O);O=t[F-2*2],L=t[F-2*2+1];var z=uc(O,L),M=cc(L,O),$=t[F-7*2],oe=t[F-7*2+1],Pe=t[F-16*2],Ge=t[F-16*2+1],fe=S+oe|0,ve=U+$+ce(fe,S)|0;fe=fe+M|0,ve=ve+z+ce(fe,M)|0,fe=fe+Ge|0,ve=ve+Pe+ce(fe,Ge)|0,t[F]=ve,t[F+1]=fe}for(var Ee=0;Ee<160;Ee+=2){ve=t[Ee],fe=t[Ee+1];var tt=hi(r,n,i),ke=hi(g,m,v),We=di(r,g),Ce=di(g,r),qe=pi(f,B),ee=pi(B,f),ae=ci[Ee],Se=ci[Ee+1],Ve=li(f,u,l),Ne=li(B,k,T),w=C+ee|0,_=b+qe+ce(w,C)|0;w=w+Ne|0,_=_+Ve+ce(w,Ne)|0,w=w+Se|0,_=_+ae+ce(w,Se)|0,w=w+fe|0,_=_+ve+ce(w,fe)|0;var R=Ce+ke|0,D=We+tt+ce(R,Ce)|0;b=l,C=T,l=u,T=k,u=f,k=B,B=I+w|0,f=a+_+ce(B,I)|0,a=i,I=v,i=n,v=m,n=r,m=g,g=w+R|0,r=_+D+ce(g,w)|0}this._al=this._al+g|0,this._bl=this._bl+m|0,this._cl=this._cl+v|0,this._dl=this._dl+I|0,this._el=this._el+B|0,this._fl=this._fl+k|0,this._gl=this._gl+T|0,this._hl=this._hl+C|0,this._ah=this._ah+r+ce(this._al,g)|0,this._bh=this._bh+n+ce(this._bl,m)|0,this._ch=this._ch+i+ce(this._cl,v)|0,this._dh=this._dh+a+ce(this._dl,I)|0,this._eh=this._eh+f+ce(this._el,B)|0,this._fh=this._fh+u+ce(this._fl,k)|0,this._gh=this._gh+l+ce(this._gl,T)|0,this._hh=this._hh+b+ce(this._hl,C)|0};er.prototype._hash=function(){var e=sc.allocUnsafe(64);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var Ps=er,lc=me,hc=Ps,dc=Rt,pc=Be.Buffer,bc=new Array(160);function Tr(){this.init(),this._w=bc,dc.call(this,128,112)}lc(Tr,hc);Tr.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};Tr.prototype._hash=function(){var e=pc.allocUnsafe(48);function t(r,n,i){e.writeInt32BE(r,i),e.writeInt32BE(n,i+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var yc=Tr,lt=Es.exports=function(t){t=t.toLowerCase();var r=lt[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};lt.sha=Cu;lt.sha1=Hu;lt.sha224=nc;lt.sha256=Rs;lt.sha384=yc;lt.sha512=Ps;var gc=Es.exports,ks=Be.Buffer,Cs=Bn.Transform,mc=pr.StringDecoder,_c=me;function Le(e){Cs.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}_c(Le,Cs);Le.prototype.update=function(e,t,r){typeof e=="string"&&(e=ks.from(e,t));var n=this._update(e);return this.hashMode?this:(r&&(n=this._toString(n,r)),n)};Le.prototype.setAutoPadding=function(){};Le.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Le.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Le.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Le.prototype._transform=function(e,t,r){var n;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(i){n=i}finally{r(n)}};Le.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Le.prototype._finalOrDigest=function(e){var t=this.__final()||ks.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Le.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new mc(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var n=this._decoder.write(e);return r&&(n+=this._decoder.end()),n};var wc=Le,xc=me,vc=xu,Ec=Bu,Bc=gc,Ls=wc;function Pr(e){Ls.call(this,"digest"),this._hash=e}xc(Pr,Ls);Pr.prototype._update=function(e){this._hash.update(e)};Pr.prototype._final=function(){return this._hash.digest()};var Sc=function(t){return t=t.toLowerCase(),t==="md5"?new vc:t==="rmd160"||t==="ripemd160"?new Ec:new Pr(Bc(t))},nr=Be.Buffer;function Ic(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var n=0;n<e.length;n++){var i=e.charAt(n),a=i.charCodeAt(0);if(t[a]!==255)throw new TypeError(i+" is ambiguous");t[a]=n}var f=e.length,u=e.charAt(0),l=Math.log(f)/Math.log(256),b=Math.log(256)/Math.log(f);function g(I){if((Array.isArray(I)||I instanceof Uint8Array)&&(I=nr.from(I)),!nr.isBuffer(I))throw new TypeError("Expected Buffer");if(I.length===0)return"";for(var B=0,k=0,T=0,C=I.length;T!==C&&I[T]===0;)T++,B++;for(var F=(C-T)*b+1>>>0,O=new Uint8Array(F);T!==C;){for(var L=I[T],U=0,S=F-1;(L!==0||U<k)&&S!==-1;S--,U++)L+=256*O[S]>>>0,O[S]=L%f>>>0,L=L/f>>>0;if(L!==0)throw new Error("Non-zero carry");k=U,T++}for(var z=F-k;z!==F&&O[z]===0;)z++;for(var M=u.repeat(B);z<F;++z)M+=e.charAt(O[z]);return M}function m(I){if(typeof I!="string")throw new TypeError("Expected String");if(I.length===0)return nr.alloc(0);for(var B=0,k=0,T=0;I[B]===u;)k++,B++;for(var C=(I.length-B)*l+1>>>0,F=new Uint8Array(C);B<I.length;){var O=t[I.charCodeAt(B)];if(O===255)return;for(var L=0,U=C-1;(O!==0||L<T)&&U!==-1;U--,L++)O+=f*F[U]>>>0,F[U]=O%256>>>0,O=O/256>>>0;if(O!==0)throw new Error("Non-zero carry");T=L,B++}for(var S=C-T;S!==C&&F[S]===0;)S++;var z=nr.allocUnsafe(k+(C-S));z.fill(0,0,k);for(var M=k;S!==C;)z[M++]=F[S++];return z}function v(I){var B=m(I);if(B)return B;throw new Error("Non-base"+f+" character")}return{encode:g,decodeUnsafe:m,decode:v}}var Ac=Ic,Rc=Ac,Tc="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Pc=Rc(Tc),Yr=Pc,kc=Be.Buffer,Cc=function(e){function t(a){var f=e(a);return Yr.encode(kc.concat([a,f],a.length+4))}function r(a){var f=a.slice(0,-4),u=a.slice(-4),l=e(f);if(!(u[0]^l[0]|u[1]^l[1]|u[2]^l[2]|u[3]^l[3]))return f}function n(a){var f=Yr.decodeUnsafe(a);if(f)return r(f)}function i(a){var f=Yr.decode(a),u=r(f);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:i,decodeUnsafe:n}},bi=Sc,Lc=Cc;function Oc(e){var t=bi("sha256").update(e).digest();return bi("sha256").update(t).digest()}var Fc=Lc(Oc),sn=Fc;function Os(e,t){if(t!==void 0&&e[0]!==t)throw new Error("Invalid network version");if(e.length===33)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(e.length!==34)throw new Error("Invalid WIF length");if(e[33]!==1)throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function on(e,t,r){var n=new Buffer(r?34:33);return n.writeUInt8(e,0),t.copy(n,1),r&&(n[33]=1),n}function Uc(e,t){return Os(sn.decode(e),t)}function Nc(e,t,r){return typeof e=="number"?sn.encode(on(e,t,r)):sn.encode(on(e.version,e.privateKey,e.compressed))}var Mc={decode:Uc,decodeRaw:Os,encode:Nc,encodeRaw:on},kr={};Object.defineProperty(kr,"__esModule",{value:!0});kr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Dc(e){X(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),X(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),X(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),X(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),X(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),X(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),X(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),X(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),X(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),X(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),X(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),X(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),X(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),X(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),X(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));X(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),X(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),X(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),X(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&X(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&X(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}kr.testEcc=Dc;function X(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(vt,"__esModule",{value:!0});vt.ECPairFactory=vt.networks=void 0;const an=Et;vt.networks=an;const we=Vi,$c=df,yi=Mc,Hc=kr,Jr=we.typeforce.maybe(we.typeforce.compile({compressed:we.maybe(we.Boolean),network:we.maybe(we.Network)})),zc=e=>e.length===32?e:e.slice(1,33);function jc(e){(0,Hc.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,l){if(we.typeforce(we.Buffer256bit,u),!e.isPrivate(u))throw new TypeError("Private key not in range [1, n)");return we.typeforce(Jr,l),new f(u,void 0,l)}function n(u,l){return we.typeforce(e.isPoint,u),we.typeforce(Jr,l),new f(void 0,u,l)}function i(u,l){const b=yi.decode(u),g=b.version;if(we.Array(l)){if(l=l.filter(m=>g===m.wif).pop(),!l)throw new Error("Unknown network version")}else if(l=l||an.bitcoin,g!==l.wif)throw new Error("Invalid network version");return r(b.privateKey,{compressed:b.compressed,network:l})}function a(u){we.typeforce(Jr,u),u===void 0&&(u={});const l=u.rng||$c;let b;do b=l(32),we.typeforce(we.Buffer256bit,b);while(!e.isPrivate(b));return r(b,u)}class f{constructor(l,b,g){pt(this,"__D");pt(this,"__Q");pt(this,"compressed");pt(this,"network");pt(this,"lowR");this.__D=l,this.__Q=b,this.lowR=!1,g===void 0&&(g={}),this.compressed=g.compressed===void 0?!0:g.compressed,this.network=g.network||an.bitcoin,b!==void 0&&(this.__Q=Buffer.from(e.pointCompress(b,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const l=e.pointFromScalar(this.__D,this.compressed);this.__Q=Buffer.from(l)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return yi.encode(this.network.wif,this.__D,this.compressed)}tweak(l){return this.privateKey?this.tweakFromPrivateKey(l):this.tweakFromPublicKey(l)}sign(l,b){if(!this.__D)throw new Error("Missing private key");if(b===void 0&&(b=this.lowR),b===!1)return Buffer.from(e.sign(l,this.__D));{let g=e.sign(l,this.__D);const m=Buffer.alloc(32,0);let v=0;for(;g[0]>127;)v++,m.writeUIntLE(v,0,6),g=e.sign(l,this.__D,m);return Buffer.from(g)}}signSchnorr(l){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return Buffer.from(e.signSchnorr(l,this.privateKey))}verify(l,b){return e.verify(l,this.publicKey,b)}verifySchnorr(l,b){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(l,this.publicKey.subarray(1,33),b)}tweakFromPublicKey(l){const b=zc(this.publicKey),g=e.xOnlyPointAddTweak(b,l);if(!g||g.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const m=Buffer.from([g.parity===0?2:3]);return n(Buffer.concat([m,g.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(l){const g=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?e.privateNegate(this.privateKey):this.privateKey,m=e.privateAdd(g,l);if(!m)throw new Error("Invalid tweaked private key!");return r(Buffer.from(m),{network:this.network,compressed:this.compressed})}}return{isPoint:t,fromPrivateKey:r,fromPublicKey:n,fromWIF:i,makeRandom:a}}vt.ECPairFactory=jc;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=vt;Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return t.networks}})})(qi);class yr{constructor(t){this.privKey=t}static fromPrivKey(t){return new yr(P.trim0x(t))}static async fromWalletClient(t){if(!t.account)return P.Err("No account found");try{const r=await t.signTypedData({account:t.account,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],Data:[{name:"Message",type:"string"},{name:"Version",type:"string"},{name:"Nonce",type:"uint256"}]},domain:{name:"WBTC GARDEN",version:"1"},primaryType:"Data",message:{Message:"Initialize your account",Version:"1.0.2",Nonce:1n}});return P.Ok(new yr(P.trim0x(He.sha256(r))))}catch(r){return P.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),n=He.sha256(ge.with0x(r)),i=He.sha256(n);return P.Ok({secret:n,secretHash:i})}signMessage(t){const r=qi.ECPairFactory(wt),n="Garden.fi"+t.toString(),i=Buffer.from(n,"utf8"),a=He.sha256(i),f=Buffer.from(P.trim0x(this.privKey),"hex");if(f.length!==32)throw new Error("Invalid private key length. Expected 32 bytes.");return r.fromPrivateKey(f).sign(Buffer.from(P.trim0x(a),"hex")).toString("hex")}}class Gc{constructor(t){this.quoteUrl=new ge.Url("/quote",t)}async getQuote(t,r,n=!1){try{const i=this.quoteUrl.addSearchParams({order_pair:t,amount:r.toString(),exact_out:n.toString()}),a=await P.Fetcher.get(i);return a.error?P.Err(a.error):a.result?P.Ok(a.result):P.Err("GetQuote: Unexpected error, result is undefined")}catch(i){return P.Err("GetQuote:",String(i))}}async getAttestedQuote(t){try{const r=await P.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?P.Err(r.error):r.result?P.Ok(r.result):P.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),P.Err("GetAttestedQuote:",String(r))}}async getStrategies(){try{const t=await P.Fetcher.get(this.quoteUrl.endpoint("/strategies"));if(t.error)return P.Err(t.error);if(!t.result)return P.Err("GetStrategies: Unexpected error, result is undefined");const r={};for(const n of Object.values(t.result)){const i=ji(n.source_chain,n.source_asset.asset,n.dest_chain,n.dest_asset.asset);r[i]={id:n.id,minAmount:n.min_amount,maxAmount:n.max_amount}}return P.Ok(r)}catch(t){return P.Err("GetStrategies:",String(t))}}}exports.BlockNumberFetcher=Wa;exports.EvmRelay=Wi;exports.Garden=Ga;exports.OrderActions=ue;exports.OrderStatus=ne;exports.ParseOrderStatus=gn;exports.ParseSwapStatus=cr;exports.Quote=Gc;exports.SecretManager=yr;exports.SwapStatus=Q;exports.TimeLocks=or;exports.constructOrderPair=ji;exports.filterDeadlineExpiredOrders=Gi;exports.isExpired=zt;exports.parseAction=Ua;exports.parseActionFromStatus=mn;exports.switchOrAddNetwork=Oa;
|
|
27
|
+
*/(function(e){const t=Gt,r=Fr,i=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=F,e.INSPECT_MAX_BYTES=50;const o=2147483647;e.kMaxLength=o,u.TYPED_ARRAY_SUPPORT=s(),!u.TYPED_ARRAY_SUPPORT&&typeof console<"u"&&typeof console.error=="function"&&console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support.");function s(){try{const f=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(f,n),f.foo()===42}catch{return!1}}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}});function c(f){if(f>o)throw new RangeError('The value "'+f+'" is invalid for option "size"');const n=new Uint8Array(f);return Object.setPrototypeOf(n,u.prototype),n}function u(f,n,a){if(typeof f=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(f)}return p(f,n,a)}u.poolSize=8192;function p(f,n,a){if(typeof f=="string")return A(f,n);if(ArrayBuffer.isView(f))return E(f);if(f==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f);if(Be(f,ArrayBuffer)||f&&Be(f.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Be(f,SharedArrayBuffer)||f&&Be(f.buffer,SharedArrayBuffer)))return O(f,n,a);if(typeof f=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=f.valueOf&&f.valueOf();if(l!=null&&l!==f)return u.from(l,n,a);const b=T(f);if(b)return b;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof f[Symbol.toPrimitive]=="function")return u.from(f[Symbol.toPrimitive]("string"),n,a);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof f)}u.from=function(f,n,a){return p(f,n,a)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function g(f){if(typeof f!="number")throw new TypeError('"size" argument must be of type number');if(f<0)throw new RangeError('The value "'+f+'" is invalid for option "size"')}function m(f,n,a){return g(f),f<=0?c(f):n!==void 0?typeof a=="string"?c(f).fill(n,a):c(f).fill(n):c(f)}u.alloc=function(f,n,a){return m(f,n,a)};function v(f){return g(f),c(f<0?0:C(f)|0)}u.allocUnsafe=function(f){return v(f)},u.allocUnsafeSlow=function(f){return v(f)};function A(f,n){if((typeof n!="string"||n==="")&&(n="utf8"),!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const a=P(f,n)|0;let l=c(a);const b=l.write(f,n);return b!==a&&(l=l.slice(0,b)),l}function k(f){const n=f.length<0?0:C(f.length)|0,a=c(n);for(let l=0;l<n;l+=1)a[l]=f[l]&255;return a}function E(f){if(Be(f,Uint8Array)){const n=new Uint8Array(f);return O(n.buffer,n.byteOffset,n.byteLength)}return k(f)}function O(f,n,a){if(n<0||f.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(f.byteLength<n+(a||0))throw new RangeError('"length" is outside of buffer bounds');let l;return n===void 0&&a===void 0?l=new Uint8Array(f):a===void 0?l=new Uint8Array(f,n):l=new Uint8Array(f,n,a),Object.setPrototypeOf(l,u.prototype),l}function T(f){if(u.isBuffer(f)){const n=C(f.length)|0,a=c(n);return a.length===0||f.copy(a,0,0,n),a}if(f.length!==void 0)return typeof f.length!="number"||ze(f.length)?c(0):k(f);if(f.type==="Buffer"&&Array.isArray(f.data))return k(f.data)}function C(f){if(f>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return f|0}function F(f){return+f!=f&&(f=0),u.alloc(+f)}u.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==u.prototype},u.compare=function(n,a){if(Be(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),Be(a,Uint8Array)&&(a=u.from(a,a.offset,a.byteLength)),!u.isBuffer(n)||!u.isBuffer(a))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===a)return 0;let l=n.length,b=a.length;for(let w=0,x=Math.min(l,b);w<x;++w)if(n[w]!==a[w]){l=n[w],b=a[w];break}return l<b?-1:b<l?1:0},u.isEncoding=function(n){switch(String(n).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(n,a){if(!Array.isArray(n))throw new TypeError('"list" argument must be an Array of Buffers');if(n.length===0)return u.alloc(0);let l;if(a===void 0)for(a=0,l=0;l<n.length;++l)a+=n[l].length;const b=u.allocUnsafe(a);let w=0;for(l=0;l<n.length;++l){let x=n[l];if(Be(x,Uint8Array))w+x.length>b.length?(u.isBuffer(x)||(x=u.from(x)),x.copy(b,w)):Uint8Array.prototype.set.call(b,x,w);else if(u.isBuffer(x))x.copy(b,w);else throw new TypeError('"list" argument must be an Array of Buffers');w+=x.length}return b};function P(f,n){if(u.isBuffer(f))return f.length;if(ArrayBuffer.isView(f)||Be(f,ArrayBuffer))return f.byteLength;if(typeof f!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof f);const a=f.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&a===0)return 0;let b=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return a;case"utf8":case"utf-8":return K(f).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return a*2;case"hex":return a>>>1;case"base64":return pt(f).length;default:if(b)return l?-1:K(f).length;n=(""+n).toLowerCase(),b=!0}}u.byteLength=P;function L(f,n,a){let l=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((a===void 0||a>this.length)&&(a=this.length),a<=0)||(a>>>=0,n>>>=0,a<=n))return"";for(f||(f="utf8");;)switch(f){case"hex":return ke(this,n,a);case"utf8":case"utf-8":return me(this,n,a);case"ascii":return Ie(this,n,a);case"latin1":case"binary":return He(this,n,a);case"base64":return oe(this,n,a);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return je(this,n,a);default:if(l)throw new TypeError("Unknown encoding: "+f);f=(f+"").toLowerCase(),l=!0}}u.prototype._isBuffer=!0;function N(f,n,a){const l=f[n];f[n]=f[a],f[a]=l}u.prototype.swap16=function(){const n=this.length;if(n%2!==0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(let a=0;a<n;a+=2)N(this,a,a+1);return this},u.prototype.swap32=function(){const n=this.length;if(n%4!==0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(let a=0;a<n;a+=4)N(this,a,a+3),N(this,a+1,a+2);return this},u.prototype.swap64=function(){const n=this.length;if(n%8!==0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(let a=0;a<n;a+=8)N(this,a,a+7),N(this,a+1,a+6),N(this,a+2,a+5),N(this,a+3,a+4);return this},u.prototype.toString=function(){const n=this.length;return n===0?"":arguments.length===0?me(this,0,n):L.apply(this,arguments)},u.prototype.toLocaleString=u.prototype.toString,u.prototype.equals=function(n){if(!u.isBuffer(n))throw new TypeError("Argument must be a Buffer");return this===n?!0:u.compare(this,n)===0},u.prototype.inspect=function(){let n="";const a=e.INSPECT_MAX_BYTES;return n=this.toString("hex",0,a).replace(/(.{2})/g,"$1 ").trim(),this.length>a&&(n+=" ... "),"<Buffer "+n+">"},i&&(u.prototype[i]=u.prototype.inspect),u.prototype.compare=function(n,a,l,b,w){if(Be(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),!u.isBuffer(n))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof n);if(a===void 0&&(a=0),l===void 0&&(l=n?n.length:0),b===void 0&&(b=0),w===void 0&&(w=this.length),a<0||l>n.length||b<0||w>this.length)throw new RangeError("out of range index");if(b>=w&&a>=l)return 0;if(b>=w)return-1;if(a>=l)return 1;if(a>>>=0,l>>>=0,b>>>=0,w>>>=0,this===n)return 0;let x=w-b,G=l-a;const re=Math.min(x,G),ee=this.slice(b,w),ne=n.slice(a,l);for(let J=0;J<re;++J)if(ee[J]!==ne[J]){x=ee[J],G=ne[J];break}return x<G?-1:G<x?1:0};function B(f,n,a,l,b){if(f.length===0)return-1;if(typeof a=="string"?(l=a,a=0):a>2147483647?a=2147483647:a<-2147483648&&(a=-2147483648),a=+a,ze(a)&&(a=b?0:f.length-1),a<0&&(a=f.length+a),a>=f.length){if(b)return-1;a=f.length-1}else if(a<0)if(b)a=0;else return-1;if(typeof n=="string"&&(n=u.from(n,l)),u.isBuffer(n))return n.length===0?-1:j(f,n,a,l,b);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(f,n,a):Uint8Array.prototype.lastIndexOf.call(f,n,a):j(f,[n],a,l,b);throw new TypeError("val must be string, number or Buffer")}function j(f,n,a,l,b){let w=1,x=f.length,G=n.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(f.length<2||n.length<2)return-1;w=2,x/=2,G/=2,a/=2}function re(ne,J){return w===1?ne[J]:ne.readUInt16BE(J*w)}let ee;if(b){let ne=-1;for(ee=a;ee<x;ee++)if(re(f,ee)===re(n,ne===-1?0:ee-ne)){if(ne===-1&&(ne=ee),ee-ne+1===G)return ne*w}else ne!==-1&&(ee-=ee-ne),ne=-1}else for(a+G>x&&(a=x-G),ee=a;ee>=0;ee--){let ne=!0;for(let J=0;J<G;J++)if(re(f,ee+J)!==re(n,J)){ne=!1;break}if(ne)return ee}return-1}u.prototype.includes=function(n,a,l){return this.indexOf(n,a,l)!==-1},u.prototype.indexOf=function(n,a,l){return B(this,n,a,l,!0)},u.prototype.lastIndexOf=function(n,a,l){return B(this,n,a,l,!1)};function D(f,n,a,l){a=Number(a)||0;const b=f.length-a;l?(l=Number(l),l>b&&(l=b)):l=b;const w=n.length;l>w/2&&(l=w/2);let x;for(x=0;x<l;++x){const G=parseInt(n.substr(x*2,2),16);if(ze(G))return x;f[a+x]=G}return x}function $(f,n,a,l){return rt(K(n,f.length-a),f,a,l)}function ie(f,n,a,l){return rt(We(n),f,a,l)}function Te(f,n,a,l){return rt(pt(n),f,a,l)}function $e(f,n,a,l){return rt(tt(n,f.length-a),f,a,l)}u.prototype.write=function(n,a,l,b){if(a===void 0)b="utf8",l=this.length,a=0;else if(l===void 0&&typeof a=="string")b=a,l=this.length,a=0;else if(isFinite(a))a=a>>>0,isFinite(l)?(l=l>>>0,b===void 0&&(b="utf8")):(b=l,l=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");const w=this.length-a;if((l===void 0||l>w)&&(l=w),n.length>0&&(l<0||a<0)||a>this.length)throw new RangeError("Attempt to write outside buffer bounds");b||(b="utf8");let x=!1;for(;;)switch(b){case"hex":return D(this,n,a,l);case"utf8":case"utf-8":return $(this,n,a,l);case"ascii":case"latin1":case"binary":return ie(this,n,a,l);case"base64":return Te(this,n,a,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,n,a,l);default:if(x)throw new TypeError("Unknown encoding: "+b);b=(""+b).toLowerCase(),x=!0}},u.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}};function oe(f,n,a){return n===0&&a===f.length?t.fromByteArray(f):t.fromByteArray(f.slice(n,a))}function me(f,n,a){a=Math.min(f.length,a);const l=[];let b=n;for(;b<a;){const w=f[b];let x=null,G=w>239?4:w>223?3:w>191?2:1;if(b+G<=a){let re,ee,ne,J;switch(G){case 1:w<128&&(x=w);break;case 2:re=f[b+1],(re&192)===128&&(J=(w&31)<<6|re&63,J>127&&(x=J));break;case 3:re=f[b+1],ee=f[b+2],(re&192)===128&&(ee&192)===128&&(J=(w&15)<<12|(re&63)<<6|ee&63,J>2047&&(J<55296||J>57343)&&(x=J));break;case 4:re=f[b+1],ee=f[b+2],ne=f[b+3],(re&192)===128&&(ee&192)===128&&(ne&192)===128&&(J=(w&15)<<18|(re&63)<<12|(ee&63)<<6|ne&63,J>65535&&J<1114112&&(x=J))}}x===null?(x=65533,G=1):x>65535&&(x-=65536,l.push(x>>>10&1023|55296),x=56320|x&1023),l.push(x),b+=G}return Je(l)}const ve=4096;function Je(f){const n=f.length;if(n<=ve)return String.fromCharCode.apply(String,f);let a="",l=0;for(;l<n;)a+=String.fromCharCode.apply(String,f.slice(l,l+=ve));return a}function Ie(f,n,a){let l="";a=Math.min(f.length,a);for(let b=n;b<a;++b)l+=String.fromCharCode(f[b]&127);return l}function He(f,n,a){let l="";a=Math.min(f.length,a);for(let b=n;b<a;++b)l+=String.fromCharCode(f[b]);return l}function ke(f,n,a){const l=f.length;(!n||n<0)&&(n=0),(!a||a<0||a>l)&&(a=l);let b="";for(let w=n;w<a;++w)b+=bt[f[w]];return b}function je(f,n,a){const l=f.slice(n,a);let b="";for(let w=0;w<l.length-1;w+=2)b+=String.fromCharCode(l[w]+l[w+1]*256);return b}u.prototype.slice=function(n,a){const l=this.length;n=~~n,a=a===void 0?l:~~a,n<0?(n+=l,n<0&&(n=0)):n>l&&(n=l),a<0?(a+=l,a<0&&(a=0)):a>l&&(a=l),a<n&&(a=n);const b=this.subarray(n,a);return Object.setPrototypeOf(b,u.prototype),b};function Q(f,n,a){if(f%1!==0||f<0)throw new RangeError("offset is not uint");if(f+n>a)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(n,a,l){n=n>>>0,a=a>>>0,l||Q(n,a,this.length);let b=this[n],w=1,x=0;for(;++x<a&&(w*=256);)b+=this[n+x]*w;return b},u.prototype.readUintBE=u.prototype.readUIntBE=function(n,a,l){n=n>>>0,a=a>>>0,l||Q(n,a,this.length);let b=this[n+--a],w=1;for(;a>0&&(w*=256);)b+=this[n+--a]*w;return b},u.prototype.readUint8=u.prototype.readUInt8=function(n,a){return n=n>>>0,a||Q(n,1,this.length),this[n]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(n,a){return n=n>>>0,a||Q(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(n,a){return n=n>>>0,a||Q(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(n,a){return n=n>>>0,a||Q(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(n,a){return n=n>>>0,a||Q(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},u.prototype.readBigUInt64LE=Re(function(n){n=n>>>0,R(n,"offset");const a=this[n],l=this[n+7];(a===void 0||l===void 0)&&M(n,this.length-8);const b=a+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,w=this[++n]+this[++n]*2**8+this[++n]*2**16+l*2**24;return BigInt(b)+(BigInt(w)<<BigInt(32))}),u.prototype.readBigUInt64BE=Re(function(n){n=n>>>0,R(n,"offset");const a=this[n],l=this[n+7];(a===void 0||l===void 0)&&M(n,this.length-8);const b=a*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],w=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l;return(BigInt(b)<<BigInt(32))+BigInt(w)}),u.prototype.readIntLE=function(n,a,l){n=n>>>0,a=a>>>0,l||Q(n,a,this.length);let b=this[n],w=1,x=0;for(;++x<a&&(w*=256);)b+=this[n+x]*w;return w*=128,b>=w&&(b-=Math.pow(2,8*a)),b},u.prototype.readIntBE=function(n,a,l){n=n>>>0,a=a>>>0,l||Q(n,a,this.length);let b=a,w=1,x=this[n+--b];for(;b>0&&(w*=256);)x+=this[n+--b]*w;return w*=128,x>=w&&(x-=Math.pow(2,8*a)),x},u.prototype.readInt8=function(n,a){return n=n>>>0,a||Q(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,a){n=n>>>0,a||Q(n,2,this.length);const l=this[n]|this[n+1]<<8;return l&32768?l|4294901760:l},u.prototype.readInt16BE=function(n,a){n=n>>>0,a||Q(n,2,this.length);const l=this[n+1]|this[n]<<8;return l&32768?l|4294901760:l},u.prototype.readInt32LE=function(n,a){return n=n>>>0,a||Q(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},u.prototype.readInt32BE=function(n,a){return n=n>>>0,a||Q(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},u.prototype.readBigInt64LE=Re(function(n){n=n>>>0,R(n,"offset");const a=this[n],l=this[n+7];(a===void 0||l===void 0)&&M(n,this.length-8);const b=this[n+4]+this[n+5]*2**8+this[n+6]*2**16+(l<<24);return(BigInt(b)<<BigInt(32))+BigInt(a+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),u.prototype.readBigInt64BE=Re(function(n){n=n>>>0,R(n,"offset");const a=this[n],l=this[n+7];(a===void 0||l===void 0)&&M(n,this.length-8);const b=(a<<24)+this[++n]*2**16+this[++n]*2**8+this[++n];return(BigInt(b)<<BigInt(32))+BigInt(this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l)}),u.prototype.readFloatLE=function(n,a){return n=n>>>0,a||Q(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,a){return n=n>>>0,a||Q(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,a){return n=n>>>0,a||Q(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,a){return n=n>>>0,a||Q(n,8,this.length),r.read(this,n,!1,52,8)};function ae(f,n,a,l,b,w){if(!u.isBuffer(f))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>b||n<w)throw new RangeError('"value" argument is out of bounds');if(a+l>f.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(n,a,l,b){if(n=+n,a=a>>>0,l=l>>>0,!b){const G=Math.pow(2,8*l)-1;ae(this,n,a,l,G,0)}let w=1,x=0;for(this[a]=n&255;++x<l&&(w*=256);)this[a+x]=n/w&255;return a+l},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(n,a,l,b){if(n=+n,a=a>>>0,l=l>>>0,!b){const G=Math.pow(2,8*l)-1;ae(this,n,a,l,G,0)}let w=l-1,x=1;for(this[a+w]=n&255;--w>=0&&(x*=256);)this[a+w]=n/x&255;return a+l},u.prototype.writeUint8=u.prototype.writeUInt8=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,1,255,0),this[a]=n&255,a+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,2,65535,0),this[a]=n&255,this[a+1]=n>>>8,a+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,2,65535,0),this[a]=n>>>8,this[a+1]=n&255,a+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,4,4294967295,0),this[a+3]=n>>>24,this[a+2]=n>>>16,this[a+1]=n>>>8,this[a]=n&255,a+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,4,4294967295,0),this[a]=n>>>24,this[a+1]=n>>>16,this[a+2]=n>>>8,this[a+3]=n&255,a+4};function Ee(f,n,a,l,b){d(n,l,b,f,a,7);let w=Number(n&BigInt(4294967295));f[a++]=w,w=w>>8,f[a++]=w,w=w>>8,f[a++]=w,w=w>>8,f[a++]=w;let x=Number(n>>BigInt(32)&BigInt(4294967295));return f[a++]=x,x=x>>8,f[a++]=x,x=x>>8,f[a++]=x,x=x>>8,f[a++]=x,a}function qe(f,n,a,l,b){d(n,l,b,f,a,7);let w=Number(n&BigInt(4294967295));f[a+7]=w,w=w>>8,f[a+6]=w,w=w>>8,f[a+5]=w,w=w>>8,f[a+4]=w;let x=Number(n>>BigInt(32)&BigInt(4294967295));return f[a+3]=x,x=x>>8,f[a+2]=x,x=x>>8,f[a+1]=x,x=x>>8,f[a]=x,a+8}u.prototype.writeBigUInt64LE=Re(function(n,a=0){return Ee(this,n,a,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Re(function(n,a=0){return qe(this,n,a,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(n,a,l,b){if(n=+n,a=a>>>0,!b){const re=Math.pow(2,8*l-1);ae(this,n,a,l,re-1,-re)}let w=0,x=1,G=0;for(this[a]=n&255;++w<l&&(x*=256);)n<0&&G===0&&this[a+w-1]!==0&&(G=1),this[a+w]=(n/x>>0)-G&255;return a+l},u.prototype.writeIntBE=function(n,a,l,b){if(n=+n,a=a>>>0,!b){const re=Math.pow(2,8*l-1);ae(this,n,a,l,re-1,-re)}let w=l-1,x=1,G=0;for(this[a+w]=n&255;--w>=0&&(x*=256);)n<0&&G===0&&this[a+w+1]!==0&&(G=1),this[a+w]=(n/x>>0)-G&255;return a+l},u.prototype.writeInt8=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,1,127,-128),n<0&&(n=255+n+1),this[a]=n&255,a+1},u.prototype.writeInt16LE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,2,32767,-32768),this[a]=n&255,this[a+1]=n>>>8,a+2},u.prototype.writeInt16BE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,2,32767,-32768),this[a]=n>>>8,this[a+1]=n&255,a+2},u.prototype.writeInt32LE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,4,2147483647,-2147483648),this[a]=n&255,this[a+1]=n>>>8,this[a+2]=n>>>16,this[a+3]=n>>>24,a+4},u.prototype.writeInt32BE=function(n,a,l){return n=+n,a=a>>>0,l||ae(this,n,a,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[a]=n>>>24,this[a+1]=n>>>16,this[a+2]=n>>>8,this[a+3]=n&255,a+4},u.prototype.writeBigInt64LE=Re(function(n,a=0){return Ee(this,n,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Re(function(n,a=0){return qe(this,n,a,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Fe(f,n,a,l,b,w){if(a+l>f.length)throw new RangeError("Index out of range");if(a<0)throw new RangeError("Index out of range")}function _(f,n,a,l,b){return n=+n,a=a>>>0,b||Fe(f,n,a,4),r.write(f,n,a,l,23,4),a+4}u.prototype.writeFloatLE=function(n,a,l){return _(this,n,a,!0,l)},u.prototype.writeFloatBE=function(n,a,l){return _(this,n,a,!1,l)};function y(f,n,a,l,b){return n=+n,a=a>>>0,b||Fe(f,n,a,8),r.write(f,n,a,l,52,8),a+8}u.prototype.writeDoubleLE=function(n,a,l){return y(this,n,a,!0,l)},u.prototype.writeDoubleBE=function(n,a,l){return y(this,n,a,!1,l)},u.prototype.copy=function(n,a,l,b){if(!u.isBuffer(n))throw new TypeError("argument should be a Buffer");if(l||(l=0),!b&&b!==0&&(b=this.length),a>=n.length&&(a=n.length),a||(a=0),b>0&&b<l&&(b=l),b===l||n.length===0||this.length===0)return 0;if(a<0)throw new RangeError("targetStart out of bounds");if(l<0||l>=this.length)throw new RangeError("Index out of range");if(b<0)throw new RangeError("sourceEnd out of bounds");b>this.length&&(b=this.length),n.length-a<b-l&&(b=n.length-a+l);const w=b-l;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(a,l,b):Uint8Array.prototype.set.call(n,this.subarray(l,b),a),w},u.prototype.fill=function(n,a,l,b){if(typeof n=="string"){if(typeof a=="string"?(b=a,a=0,l=this.length):typeof l=="string"&&(b=l,l=this.length),b!==void 0&&typeof b!="string")throw new TypeError("encoding must be a string");if(typeof b=="string"&&!u.isEncoding(b))throw new TypeError("Unknown encoding: "+b);if(n.length===1){const x=n.charCodeAt(0);(b==="utf8"&&x<128||b==="latin1")&&(n=x)}}else typeof n=="number"?n=n&255:typeof n=="boolean"&&(n=Number(n));if(a<0||this.length<a||this.length<l)throw new RangeError("Out of range index");if(l<=a)return this;a=a>>>0,l=l===void 0?this.length:l>>>0,n||(n=0);let w;if(typeof n=="number")for(w=a;w<l;++w)this[w]=n;else{const x=u.isBuffer(n)?n:u.from(n,b),G=x.length;if(G===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(w=0;w<l-a;++w)this[w+a]=x[w%G]}return this};const S={};function U(f,n,a){S[f]=class extends a{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${f}]`,this.stack,delete this.name}get code(){return f}set code(b){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:b,writable:!0})}toString(){return`${this.name} [${f}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(f){return f?`${f} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(f,n){return`The "${f}" argument must be of type number. Received type ${typeof n}`},TypeError),U("ERR_OUT_OF_RANGE",function(f,n,a){let l=`The value of "${f}" is out of range.`,b=a;return Number.isInteger(a)&&Math.abs(a)>2**32?b=q(String(a)):typeof a=="bigint"&&(b=String(a),(a>BigInt(2)**BigInt(32)||a<-(BigInt(2)**BigInt(32)))&&(b=q(b)),b+="n"),l+=` It must be ${n}. Received ${b}`,l},RangeError);function q(f){let n="",a=f.length;const l=f[0]==="-"?1:0;for(;a>=l+4;a-=3)n=`_${f.slice(a-3,a)}${n}`;return`${f.slice(0,a)}${n}`}function h(f,n,a){R(n,"offset"),(f[n]===void 0||f[n+a]===void 0)&&M(n,f.length-(a+1))}function d(f,n,a,l,b,w){if(f>a||f<n){const x=typeof n=="bigint"?"n":"";let G;throw n===0||n===BigInt(0)?G=`>= 0${x} and < 2${x} ** ${(w+1)*8}${x}`:G=`>= -(2${x} ** ${(w+1)*8-1}${x}) and < 2 ** ${(w+1)*8-1}${x}`,new S.ERR_OUT_OF_RANGE("value",G,f)}h(l,b,w)}function R(f,n){if(typeof f!="number")throw new S.ERR_INVALID_ARG_TYPE(n,"number",f)}function M(f,n,a){throw Math.floor(f)!==f?(R(f,a),new S.ERR_OUT_OF_RANGE("offset","an integer",f)):n<0?new S.ERR_BUFFER_OUT_OF_BOUNDS:new S.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,f)}const Z=/[^+/0-9A-Za-z-_]/g;function W(f){if(f=f.split("=")[0],f=f.trim().replace(Z,""),f.length<2)return"";for(;f.length%4!==0;)f=f+"=";return f}function K(f,n){n=n||1/0;let a;const l=f.length;let b=null;const w=[];for(let x=0;x<l;++x){if(a=f.charCodeAt(x),a>55295&&a<57344){if(!b){if(a>56319){(n-=3)>-1&&w.push(239,191,189);continue}else if(x+1===l){(n-=3)>-1&&w.push(239,191,189);continue}b=a;continue}if(a<56320){(n-=3)>-1&&w.push(239,191,189),b=a;continue}a=(b-55296<<10|a-56320)+65536}else b&&(n-=3)>-1&&w.push(239,191,189);if(b=null,a<128){if((n-=1)<0)break;w.push(a)}else if(a<2048){if((n-=2)<0)break;w.push(a>>6|192,a&63|128)}else if(a<65536){if((n-=3)<0)break;w.push(a>>12|224,a>>6&63|128,a&63|128)}else if(a<1114112){if((n-=4)<0)break;w.push(a>>18|240,a>>12&63|128,a>>6&63|128,a&63|128)}else throw new Error("Invalid code point")}return w}function We(f){const n=[];for(let a=0;a<f.length;++a)n.push(f.charCodeAt(a)&255);return n}function tt(f,n){let a,l,b;const w=[];for(let x=0;x<f.length&&!((n-=2)<0);++x)a=f.charCodeAt(x),l=a>>8,b=a%256,w.push(b),w.push(l);return w}function pt(f){return t.toByteArray(W(f))}function rt(f,n,a,l){let b;for(b=0;b<l&&!(b+a>=n.length||b>=f.length);++b)n[b+a]=f[b];return b}function Be(f,n){return f instanceof n||f!=null&&f.constructor!=null&&f.constructor.name!=null&&f.constructor.name===n.name}function ze(f){return f!==f}const bt=function(){const f="0123456789abcdef",n=new Array(256);for(let a=0;a<16;++a){const l=a*16;for(let b=0;b<16;++b)n[l+b]=f[a]+f[b]}return n}();function Re(f){return typeof BigInt>"u"?Ye:f}function Ye(){throw new Error("BigInt not supported")}})(ht);/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */(function(e,t){var r=ht,i=r.Buffer;function o(c,u){for(var p in c)u[p]=c[p]}i.from&&i.alloc&&i.allocUnsafe&&i.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=s);function s(c,u,p){return i(c,u,p)}s.prototype=Object.create(i.prototype),o(i,s),s.from=function(c,u,p){if(typeof c=="number")throw new TypeError("Argument must not be a number");return i(c,u,p)},s.alloc=function(c,u,p){if(typeof c!="number")throw new TypeError("Argument must be a number");var g=i(c);return u!==void 0?typeof p=="string"?g.fill(u,p):g.fill(u):g.fill(0),g},s.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return i(c)},s.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(vr,vr.exports);var xe=vr.exports,or=65536,zi=4294967295;function Yi(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
28
|
+
Use Chrome, Firefox or Internet Explorer 11`)}var Xi=xe.Buffer,Ht=Ke.crypto||Ke.msCrypto;Ht&&Ht.getRandomValues?mr.exports=Qi:mr.exports=Yi;function Qi(e,t){if(e>zi)throw new RangeError("requested too many random bytes");var r=Xi.allocUnsafe(e);if(e>0)if(e>or)for(var i=0;i<e;i+=or)Ht.getRandomValues(r.slice(i,i+or));else Ht.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var Zi=mr.exports,xr={exports:{}};typeof Object.create=="function"?xr.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:xr.exports=function(t,r){if(r){t.super_=r;var i=function(){};i.prototype=r.prototype,t.prototype=new i,t.prototype.constructor=t}};var ye=xr.exports,Er={exports:{}},Pr={exports:{}},st=typeof Reflect=="object"?Reflect:null,Gr=st&&typeof st.apply=="function"?st.apply:function(t,r,i){return Function.prototype.apply.call(t,r,i)},Pt;st&&typeof st.ownKeys=="function"?Pt=st.ownKeys:Object.getOwnPropertySymbols?Pt=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Pt=function(t){return Object.getOwnPropertyNames(t)};function ea(e){console&&console.warn&&console.warn(e)}var Cn=Number.isNaN||function(t){return t!==t};function V(){V.init.call(this)}Pr.exports=V;Pr.exports.once=ia;V.EventEmitter=V;V.prototype._events=void 0;V.prototype._eventsCount=0;V.prototype._maxListeners=void 0;var Kr=10;function Kt(e){if(typeof e!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof e)}Object.defineProperty(V,"defaultMaxListeners",{enumerable:!0,get:function(){return Kr},set:function(e){if(typeof e!="number"||e<0||Cn(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Kr=e}});V.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};V.prototype.setMaxListeners=function(t){if(typeof t!="number"||t<0||Cn(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};function On(e){return e._maxListeners===void 0?V.defaultMaxListeners:e._maxListeners}V.prototype.getMaxListeners=function(){return On(this)};V.prototype.emit=function(t){for(var r=[],i=1;i<arguments.length;i++)r.push(arguments[i]);var o=t==="error",s=this._events;if(s!==void 0)o=o&&s.error===void 0;else if(!o)return!1;if(o){var c;if(r.length>0&&(c=r[0]),c instanceof Error)throw c;var u=new Error("Unhandled error."+(c?" ("+c.message+")":""));throw u.context=c,u}var p=s[t];if(p===void 0)return!1;if(typeof p=="function")Gr(p,this,r);else for(var g=p.length,m=Nn(p,g),i=0;i<g;++i)Gr(m[i],this,r);return!0};function Ln(e,t,r,i){var o,s,c;if(Kt(r),s=e._events,s===void 0?(s=e._events=Object.create(null),e._eventsCount=0):(s.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),s=e._events),c=s[t]),c===void 0)c=s[t]=r,++e._eventsCount;else if(typeof c=="function"?c=s[t]=i?[r,c]:[c,r]:i?c.unshift(r):c.push(r),o=On(e),o>0&&c.length>o&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=c.length,ea(u)}return e}V.prototype.addListener=function(t,r){return Ln(this,t,r,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(t,r){return Ln(this,t,r,!0)};function ta(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function Fn(e,t,r){var i={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=ta.bind(i);return o.listener=r,i.wrapFn=o,o}V.prototype.once=function(t,r){return Kt(r),this.on(t,Fn(this,t,r)),this};V.prototype.prependOnceListener=function(t,r){return Kt(r),this.prependListener(t,Fn(this,t,r)),this};V.prototype.removeListener=function(t,r){var i,o,s,c,u;if(Kt(r),o=this._events,o===void 0)return this;if(i=o[t],i===void 0)return this;if(i===r||i.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,i.listener||r));else if(typeof i!="function"){for(s=-1,c=i.length-1;c>=0;c--)if(i[c]===r||i[c].listener===r){u=i[c].listener,s=c;break}if(s<0)return this;s===0?i.shift():ra(i,s),i.length===1&&(o[t]=i[0]),o.removeListener!==void 0&&this.emit("removeListener",t,u||r)}return this};V.prototype.off=V.prototype.removeListener;V.prototype.removeAllListeners=function(t){var r,i,o;if(i=this._events,i===void 0)return this;if(i.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):i[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete i[t]),this;if(arguments.length===0){var s=Object.keys(i),c;for(o=0;o<s.length;++o)c=s[o],c!=="removeListener"&&this.removeAllListeners(c);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(r=i[t],typeof r=="function")this.removeListener(t,r);else if(r!==void 0)for(o=r.length-1;o>=0;o--)this.removeListener(t,r[o]);return this};function Pn(e,t,r){var i=e._events;if(i===void 0)return[];var o=i[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?na(o):Nn(o,o.length)}V.prototype.listeners=function(t){return Pn(this,t,!0)};V.prototype.rawListeners=function(t){return Pn(this,t,!1)};V.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Mn.call(e,t)};V.prototype.listenerCount=Mn;function Mn(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}V.prototype.eventNames=function(){return this._eventsCount>0?Pt(this._events):[]};function Nn(e,t){for(var r=new Array(t),i=0;i<t;++i)r[i]=e[i];return r}function ra(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function na(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function ia(e,t){return new Promise(function(r,i){function o(c){e.removeListener(t,s),i(c)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}Dn(e,t,s,{once:!0}),t!=="error"&&aa(e,o,{once:!0})})}function aa(e,t,r){typeof e.on=="function"&&Dn(e,"error",t,r)}function Dn(e,t,r,i){if(typeof e.on=="function")i.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function o(s){i.once&&e.removeEventListener(t,o),r(s)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Un=Pr.exports,$n=Un.EventEmitter;const oa={},sa=Object.freeze(Object.defineProperty({__proto__:null,default:oa},Symbol.toStringTag,{value:"Module"})),Mr=Li(sa);var sr,Vr;function fa(){if(Vr)return sr;Vr=1;function e(E,O){var T=Object.keys(E);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(E);O&&(C=C.filter(function(F){return Object.getOwnPropertyDescriptor(E,F).enumerable})),T.push.apply(T,C)}return T}function t(E){for(var O=1;O<arguments.length;O++){var T=arguments[O]!=null?arguments[O]:{};O%2?e(Object(T),!0).forEach(function(C){r(E,C,T[C])}):Object.getOwnPropertyDescriptors?Object.defineProperties(E,Object.getOwnPropertyDescriptors(T)):e(Object(T)).forEach(function(C){Object.defineProperty(E,C,Object.getOwnPropertyDescriptor(T,C))})}return E}function r(E,O,T){return O=c(O),O in E?Object.defineProperty(E,O,{value:T,enumerable:!0,configurable:!0,writable:!0}):E[O]=T,E}function i(E,O){if(!(E instanceof O))throw new TypeError("Cannot call a class as a function")}function o(E,O){for(var T=0;T<O.length;T++){var C=O[T];C.enumerable=C.enumerable||!1,C.configurable=!0,"value"in C&&(C.writable=!0),Object.defineProperty(E,c(C.key),C)}}function s(E,O,T){return O&&o(E.prototype,O),Object.defineProperty(E,"prototype",{writable:!1}),E}function c(E){var O=u(E,"string");return typeof O=="symbol"?O:String(O)}function u(E,O){if(typeof E!="object"||E===null)return E;var T=E[Symbol.toPrimitive];if(T!==void 0){var C=T.call(E,O||"default");if(typeof C!="object")return C;throw new TypeError("@@toPrimitive must return a primitive value.")}return(O==="string"?String:Number)(E)}var p=ht,g=p.Buffer,m=Mr,v=m.inspect,A=v&&v.custom||"inspect";function k(E,O,T){g.prototype.copy.call(E,O,T)}return sr=function(){function E(){i(this,E),this.head=null,this.tail=null,this.length=0}return s(E,[{key:"push",value:function(T){var C={data:T,next:null};this.length>0?this.tail.next=C:this.head=C,this.tail=C,++this.length}},{key:"unshift",value:function(T){var C={data:T,next:this.head};this.length===0&&(this.tail=C),this.head=C,++this.length}},{key:"shift",value:function(){if(this.length!==0){var T=this.head.data;return this.length===1?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(this.length===0)return"";for(var C=this.head,F=""+C.data;C=C.next;)F+=T+C.data;return F}},{key:"concat",value:function(T){if(this.length===0)return g.alloc(0);for(var C=g.allocUnsafe(T>>>0),F=this.head,P=0;F;)k(F.data,C,P),P+=F.data.length,F=F.next;return C}},{key:"consume",value:function(T,C){var F;return T<this.head.data.length?(F=this.head.data.slice(0,T),this.head.data=this.head.data.slice(T)):T===this.head.data.length?F=this.shift():F=C?this._getString(T):this._getBuffer(T),F}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(T){var C=this.head,F=1,P=C.data;for(T-=P.length;C=C.next;){var L=C.data,N=T>L.length?L.length:T;if(N===L.length?P+=L:P+=L.slice(0,T),T-=N,T===0){N===L.length?(++F,C.next?this.head=C.next:this.head=this.tail=null):(this.head=C,C.data=L.slice(N));break}++F}return this.length-=F,P}},{key:"_getBuffer",value:function(T){var C=g.allocUnsafe(T),F=this.head,P=1;for(F.data.copy(C),T-=F.data.length;F=F.next;){var L=F.data,N=T>L.length?L.length:T;if(L.copy(C,C.length-T,0,N),T-=N,T===0){N===L.length?(++P,F.next?this.head=F.next:this.head=this.tail=null):(this.head=F,F.data=L.slice(N));break}++P}return this.length-=P,C}},{key:A,value:function(T,C){return v(this,t(t({},C),{},{depth:0,customInspect:!1}))}}]),E}(),sr}function ua(e,t){var r=this,i=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return i||o?(t?t(e):e&&(this._writableState?this._writableState.errorEmitted||(this._writableState.errorEmitted=!0,process.nextTick(Br,this,e)):process.nextTick(Br,this,e)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(e||null,function(s){!t&&s?r._writableState?r._writableState.errorEmitted?process.nextTick(Mt,r):(r._writableState.errorEmitted=!0,process.nextTick(Jr,r,s)):process.nextTick(Jr,r,s):t?(process.nextTick(Mt,r),t(s)):process.nextTick(Mt,r)}),this)}function Jr(e,t){Br(e,t),Mt(e)}function Mt(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ca(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Br(e,t){e.emit("error",t)}function la(e,t){var r=e._readableState,i=e._writableState;r&&r.autoDestroy||i&&i.autoDestroy?e.destroy(t):e.emit("error",t)}var Hn={destroy:ua,undestroy:ca,errorOrDestroy:la},Ze={};function ha(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var jn={};function Ae(e,t,r){r||(r=Error);function i(s,c,u){return typeof t=="string"?t:t(s,c,u)}var o=function(s){ha(c,s);function c(u,p,g){return s.call(this,i(u,p,g))||this}return c}(r);o.prototype.name=r.name,o.prototype.code=e,jn[e]=o}function zr(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(i){return String(i)}),r>2?"one of ".concat(t," ").concat(e.slice(0,r-1).join(", "),", or ")+e[r-1]:r===2?"one of ".concat(t," ").concat(e[0]," or ").concat(e[1]):"of ".concat(t," ").concat(e[0])}else return"of ".concat(t," ").concat(String(e))}function da(e,t,r){return e.substr(0,t.length)===t}function pa(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function ba(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Ae("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Ae("ERR_INVALID_ARG_TYPE",function(e,t,r){var i;typeof t=="string"&&da(t,"not ")?(i="must not be",t=t.replace(/^not /,"")):i="must be";var o;if(pa(e," argument"))o="The ".concat(e," ").concat(i," ").concat(zr(t,"type"));else{var s=ba(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(i," ").concat(zr(t,"type"))}return o+=". Received type ".concat(typeof r),o},TypeError);Ae("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF");Ae("ERR_METHOD_NOT_IMPLEMENTED",function(e){return"The "+e+" method is not implemented"});Ae("ERR_STREAM_PREMATURE_CLOSE","Premature close");Ae("ERR_STREAM_DESTROYED",function(e){return"Cannot call "+e+" after a stream was destroyed"});Ae("ERR_MULTIPLE_CALLBACK","Callback called multiple times");Ae("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable");Ae("ERR_STREAM_WRITE_AFTER_END","write after end");Ae("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError);Ae("ERR_UNKNOWN_ENCODING",function(e){return"Unknown encoding: "+e},TypeError);Ae("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event");Ze.codes=jn;var ya=Ze.codes.ERR_INVALID_OPT_VALUE;function _a(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function ga(e,t,r,i){var o=_a(t,i,r);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var s=i?r:"highWaterMark";throw new ya(s,o)}return Math.floor(o)}return e.objectMode?16:16*1024}var qn={getHighWaterMark:ga},wa=ma;function ma(e,t){if(fr("noDeprecation"))return e;var r=!1;function i(){if(!r){if(fr("throwDeprecation"))throw new Error(t);fr("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return i}function fr(e){try{if(!Ke.localStorage)return!1}catch{return!1}var t=Ke.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var ur,Yr;function Wn(){if(Yr)return ur;Yr=1,ur=D;function e(_){var y=this;this.next=null,this.entry=null,this.finish=function(){Fe(y,_)}}var t;D.WritableState=B;var r={deprecate:wa},i=$n,o=ht.Buffer,s=(typeof Ke<"u"?Ke:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(_){return o.from(_)}function u(_){return o.isBuffer(_)||_ instanceof s}var p=Hn,g=qn,m=g.getHighWaterMark,v=Ze.codes,A=v.ERR_INVALID_ARG_TYPE,k=v.ERR_METHOD_NOT_IMPLEMENTED,E=v.ERR_MULTIPLE_CALLBACK,O=v.ERR_STREAM_CANNOT_PIPE,T=v.ERR_STREAM_DESTROYED,C=v.ERR_STREAM_NULL_VALUES,F=v.ERR_STREAM_WRITE_AFTER_END,P=v.ERR_UNKNOWN_ENCODING,L=p.errorOrDestroy;ye(D,i);function N(){}function B(_,y,S){t=t||lt(),_=_||{},typeof S!="boolean"&&(S=y instanceof t),this.objectMode=!!_.objectMode,S&&(this.objectMode=this.objectMode||!!_.writableObjectMode),this.highWaterMark=m(this,_,"writableHighWaterMark",S),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var U=_.decodeStrings===!1;this.decodeStrings=!U,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(q){Je(y,q)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=_.emitClose!==!1,this.autoDestroy=!!_.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}B.prototype.getBuffer=function(){for(var y=this.bufferedRequest,S=[];y;)S.push(y),y=y.next;return S},function(){try{Object.defineProperty(B.prototype,"buffer",{get:r.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var j;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(j=Function.prototype[Symbol.hasInstance],Object.defineProperty(D,Symbol.hasInstance,{value:function(y){return j.call(this,y)?!0:this!==D?!1:y&&y._writableState instanceof B}})):j=function(y){return y instanceof this};function D(_){t=t||lt();var y=this instanceof t;if(!y&&!j.call(D,this))return new D(_);this._writableState=new B(_,this,y),this.writable=!0,_&&(typeof _.write=="function"&&(this._write=_.write),typeof _.writev=="function"&&(this._writev=_.writev),typeof _.destroy=="function"&&(this._destroy=_.destroy),typeof _.final=="function"&&(this._final=_.final)),i.call(this)}D.prototype.pipe=function(){L(this,new O)};function $(_,y){var S=new F;L(_,S),process.nextTick(y,S)}function ie(_,y,S,U){var q;return S===null?q=new C:typeof S!="string"&&!y.objectMode&&(q=new A("chunk",["string","Buffer"],S)),q?(L(_,q),process.nextTick(U,q),!1):!0}D.prototype.write=function(_,y,S){var U=this._writableState,q=!1,h=!U.objectMode&&u(_);return h&&!o.isBuffer(_)&&(_=c(_)),typeof y=="function"&&(S=y,y=null),h?y="buffer":y||(y=U.defaultEncoding),typeof S!="function"&&(S=N),U.ending?$(this,S):(h||ie(this,U,_,S))&&(U.pendingcb++,q=$e(this,U,h,_,y,S)),q},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&ke(this,_))},D.prototype.setDefaultEncoding=function(y){if(typeof y=="string"&&(y=y.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((y+"").toLowerCase())>-1))throw new P(y);return this._writableState.defaultEncoding=y,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Te(_,y,S){return!_.objectMode&&_.decodeStrings!==!1&&typeof y=="string"&&(y=o.from(y,S)),y}Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function $e(_,y,S,U,q,h){if(!S){var d=Te(y,U,q);U!==d&&(S=!0,q="buffer",U=d)}var R=y.objectMode?1:U.length;y.length+=R;var M=y.length<y.highWaterMark;if(M||(y.needDrain=!0),y.writing||y.corked){var Z=y.lastBufferedRequest;y.lastBufferedRequest={chunk:U,encoding:q,isBuf:S,callback:h,next:null},Z?Z.next=y.lastBufferedRequest:y.bufferedRequest=y.lastBufferedRequest,y.bufferedRequestCount+=1}else oe(_,y,!1,R,U,q,h);return M}function oe(_,y,S,U,q,h,d){y.writelen=U,y.writecb=d,y.writing=!0,y.sync=!0,y.destroyed?y.onwrite(new T("write")):S?_._writev(q,y.onwrite):_._write(q,h,y.onwrite),y.sync=!1}function me(_,y,S,U,q){--y.pendingcb,S?(process.nextTick(q,U),process.nextTick(Ee,_,y),_._writableState.errorEmitted=!0,L(_,U)):(q(U),_._writableState.errorEmitted=!0,L(_,U),Ee(_,y))}function ve(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function Je(_,y){var S=_._writableState,U=S.sync,q=S.writecb;if(typeof q!="function")throw new E;if(ve(S),y)me(_,S,U,y,q);else{var h=je(S)||_.destroyed;!h&&!S.corked&&!S.bufferProcessing&&S.bufferedRequest&&ke(_,S),U?process.nextTick(Ie,_,S,h,q):Ie(_,S,h,q)}}function Ie(_,y,S,U){S||He(_,y),y.pendingcb--,U(),Ee(_,y)}function He(_,y){y.length===0&&y.needDrain&&(y.needDrain=!1,_.emit("drain"))}function ke(_,y){y.bufferProcessing=!0;var S=y.bufferedRequest;if(_._writev&&S&&S.next){var U=y.bufferedRequestCount,q=new Array(U),h=y.corkedRequestsFree;h.entry=S;for(var d=0,R=!0;S;)q[d]=S,S.isBuf||(R=!1),S=S.next,d+=1;q.allBuffers=R,oe(_,y,!0,y.length,q,"",h.finish),y.pendingcb++,y.lastBufferedRequest=null,h.next?(y.corkedRequestsFree=h.next,h.next=null):y.corkedRequestsFree=new e(y),y.bufferedRequestCount=0}else{for(;S;){var M=S.chunk,Z=S.encoding,W=S.callback,K=y.objectMode?1:M.length;if(oe(_,y,!1,K,M,Z,W),S=S.next,y.bufferedRequestCount--,y.writing)break}S===null&&(y.lastBufferedRequest=null)}y.bufferedRequest=S,y.bufferProcessing=!1}D.prototype._write=function(_,y,S){S(new k("_write()"))},D.prototype._writev=null,D.prototype.end=function(_,y,S){var U=this._writableState;return typeof _=="function"?(S=_,_=null,y=null):typeof y=="function"&&(S=y,y=null),_!=null&&this.write(_,y),U.corked&&(U.corked=1,this.uncork()),U.ending||qe(this,U,S),this},Object.defineProperty(D.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function je(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function Q(_,y){_._final(function(S){y.pendingcb--,S&&L(_,S),y.prefinished=!0,_.emit("prefinish"),Ee(_,y)})}function ae(_,y){!y.prefinished&&!y.finalCalled&&(typeof _._final=="function"&&!y.destroyed?(y.pendingcb++,y.finalCalled=!0,process.nextTick(Q,_,y)):(y.prefinished=!0,_.emit("prefinish")))}function Ee(_,y){var S=je(y);if(S&&(ae(_,y),y.pendingcb===0&&(y.finished=!0,_.emit("finish"),y.autoDestroy))){var U=_._readableState;(!U||U.autoDestroy&&U.endEmitted)&&_.destroy()}return S}function qe(_,y,S){y.ending=!0,Ee(_,y),S&&(y.finished?process.nextTick(S):_.once("finish",S)),y.ended=!0,_.writable=!1}function Fe(_,y,S){var U=_.entry;for(_.entry=null;U;){var q=U.callback;y.pendingcb--,q(S),U=U.next}y.corkedRequestsFree.next=_}return Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(y){this._writableState&&(this._writableState.destroyed=y)}}),D.prototype.destroy=p.destroy,D.prototype._undestroy=p.undestroy,D.prototype._destroy=function(_,y){y(_)},ur}var cr,Xr;function lt(){if(Xr)return cr;Xr=1;var e=Object.keys||function(g){var m=[];for(var v in g)m.push(v);return m};cr=c;var t=Kn(),r=Wn();ye(c,t);for(var i=e(r.prototype),o=0;o<i.length;o++){var s=i[o];c.prototype[s]||(c.prototype[s]=r.prototype[s])}function c(g){if(!(this instanceof c))return new c(g);t.call(this,g),r.call(this,g),this.allowHalfOpen=!0,g&&(g.readable===!1&&(this.readable=!1),g.writable===!1&&(this.writable=!1),g.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",u)))}Object.defineProperty(c.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(c.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(c.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function u(){this._writableState.ended||process.nextTick(p,this)}function p(g){g.end()}return Object.defineProperty(c.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0||this._writableState===void 0?!1:this._readableState.destroyed&&this._writableState.destroyed},set:function(m){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=m,this._writableState.destroyed=m)}}),cr}var jt={},Nr=xe.Buffer,Qr=Nr.isEncoding||function(e){switch(e=""+e,e&&e.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 va(e){if(!e)return"utf8";for(var t;;)switch(e){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 e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function xa(e){var t=va(e);if(typeof t!="string"&&(Nr.isEncoding===Qr||!Qr(e)))throw new Error("Unknown encoding: "+e);return t||e}jt.StringDecoder=Tt;function Tt(e){this.encoding=xa(e);var t;switch(this.encoding){case"utf16le":this.text=Ta,this.end=Ia,t=4;break;case"utf8":this.fillLast=Ra,t=4;break;case"base64":this.text=ka,this.end=Ca,t=3;break;default:this.write=Oa,this.end=La;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Nr.allocUnsafe(t)}Tt.prototype.write=function(e){if(e.length===0)return"";var t,r;if(this.lastNeed){if(t=this.fillLast(e),t===void 0)return"";r=this.lastNeed,this.lastNeed=0}else r=0;return r<e.length?t?t+this.text(e,r):this.text(e,r):t||""};Tt.prototype.end=Aa;Tt.prototype.text=Sa;Tt.prototype.fillLast=function(e){if(this.lastNeed<=e.length)return e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,this.lastTotal-this.lastNeed,0,e.length),this.lastNeed-=e.length};function lr(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Ea(e,t,r){var i=t.length-1;if(i<r)return 0;var o=lr(t[i]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--i<r||o===-2?0:(o=lr(t[i]),o>=0?(o>0&&(e.lastNeed=o-2),o):--i<r||o===-2?0:(o=lr(t[i]),o>=0?(o>0&&(o===2?o=0:e.lastNeed=o-3),o):0))}function Ba(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"�"}}function Ra(e){var t=this.lastTotal-this.lastNeed,r=Ba(this,e);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function Sa(e,t){var r=Ea(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var i=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,i),e.toString("utf8",t,i)}function Aa(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function Ta(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var i=r.charCodeAt(r.length-1);if(i>=55296&&i<=56319)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1],r.slice(0,-1)}return r}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=e[e.length-1],e.toString("utf16le",t,e.length-1)}function Ia(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function ka(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Ca(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Oa(e){return e.toString(this.encoding)}function La(e){return e&&e.length?this.write(e):""}var Zr=Ze.codes.ERR_STREAM_PREMATURE_CLOSE;function Fa(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,i=new Array(r),o=0;o<r;o++)i[o]=arguments[o];e.apply(this,i)}}}function Pa(){}function Ma(e){return e.setHeader&&typeof e.abort=="function"}function Gn(e,t,r){if(typeof t=="function")return Gn(e,null,t);t||(t={}),r=Fa(r||Pa);var i=t.readable||t.readable!==!1&&e.readable,o=t.writable||t.writable!==!1&&e.writable,s=function(){e.writable||u()},c=e._writableState&&e._writableState.finished,u=function(){o=!1,c=!0,i||r.call(e)},p=e._readableState&&e._readableState.endEmitted,g=function(){i=!1,p=!0,o||r.call(e)},m=function(E){r.call(e,E)},v=function(){var E;if(i&&!p)return(!e._readableState||!e._readableState.ended)&&(E=new Zr),r.call(e,E);if(o&&!c)return(!e._writableState||!e._writableState.ended)&&(E=new Zr),r.call(e,E)},A=function(){e.req.on("finish",u)};return Ma(e)?(e.on("complete",u),e.on("abort",v),e.req?A():e.on("request",A)):o&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",g),e.on("finish",u),t.error!==!1&&e.on("error",m),e.on("close",v),function(){e.removeListener("complete",u),e.removeListener("abort",v),e.removeListener("request",A),e.req&&e.req.removeListener("finish",u),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",u),e.removeListener("end",g),e.removeListener("error",m),e.removeListener("close",v)}}var Dr=Gn,hr,en;function Na(){if(en)return hr;en=1;var e;function t(P,L,N){return L=r(L),L in P?Object.defineProperty(P,L,{value:N,enumerable:!0,configurable:!0,writable:!0}):P[L]=N,P}function r(P){var L=i(P,"string");return typeof L=="symbol"?L:String(L)}function i(P,L){if(typeof P!="object"||P===null)return P;var N=P[Symbol.toPrimitive];if(N!==void 0){var B=N.call(P,L||"default");if(typeof B!="object")return B;throw new TypeError("@@toPrimitive must return a primitive value.")}return(L==="string"?String:Number)(P)}var o=Dr,s=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),p=Symbol("ended"),g=Symbol("lastPromise"),m=Symbol("handlePromise"),v=Symbol("stream");function A(P,L){return{value:P,done:L}}function k(P){var L=P[s];if(L!==null){var N=P[v].read();N!==null&&(P[g]=null,P[s]=null,P[c]=null,L(A(N,!1)))}}function E(P){process.nextTick(k,P)}function O(P,L){return function(N,B){P.then(function(){if(L[p]){N(A(void 0,!0));return}L[m](N,B)},B)}}var T=Object.getPrototypeOf(function(){}),C=Object.setPrototypeOf((e={get stream(){return this[v]},next:function(){var L=this,N=this[u];if(N!==null)return Promise.reject(N);if(this[p])return Promise.resolve(A(void 0,!0));if(this[v].destroyed)return new Promise(function($,ie){process.nextTick(function(){L[u]?ie(L[u]):$(A(void 0,!0))})});var B=this[g],j;if(B)j=new Promise(O(B,this));else{var D=this[v].read();if(D!==null)return Promise.resolve(A(D,!1));j=new Promise(this[m])}return this[g]=j,j}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var L=this;return new Promise(function(N,B){L[v].destroy(null,function(j){if(j){B(j);return}N(A(void 0,!0))})})}),e),T),F=function(L){var N,B=Object.create(C,(N={},t(N,v,{value:L,writable:!0}),t(N,s,{value:null,writable:!0}),t(N,c,{value:null,writable:!0}),t(N,u,{value:null,writable:!0}),t(N,p,{value:L._readableState.endEmitted,writable:!0}),t(N,m,{value:function(D,$){var ie=B[v].read();ie?(B[g]=null,B[s]=null,B[c]=null,D(A(ie,!1))):(B[s]=D,B[c]=$)},writable:!0}),N));return B[g]=null,o(L,function(j){if(j&&j.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=B[c];D!==null&&(B[g]=null,B[s]=null,B[c]=null,D(j)),B[u]=j;return}var $=B[s];$!==null&&(B[g]=null,B[s]=null,B[c]=null,$(A(void 0,!0))),B[p]=!0}),L.on("readable",E.bind(null,B)),B};return hr=F,hr}var dr,tn;function Da(){return tn||(tn=1,dr=function(){throw new Error("Readable.from is not available in the browser")}),dr}var pr,rn;function Kn(){if(rn)return pr;rn=1,pr=$;var e;$.ReadableState=D,Un.EventEmitter;var t=function(d,R){return d.listeners(R).length},r=$n,i=ht.Buffer,o=(typeof Ke<"u"?Ke:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(h){return i.from(h)}function c(h){return i.isBuffer(h)||h instanceof o}var u=Mr,p;u&&u.debuglog?p=u.debuglog("stream"):p=function(){};var g=fa(),m=Hn,v=qn,A=v.getHighWaterMark,k=Ze.codes,E=k.ERR_INVALID_ARG_TYPE,O=k.ERR_STREAM_PUSH_AFTER_EOF,T=k.ERR_METHOD_NOT_IMPLEMENTED,C=k.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,F,P,L;ye($,r);var N=m.errorOrDestroy,B=["error","close","destroy","pause","resume"];function j(h,d,R){if(typeof h.prependListener=="function")return h.prependListener(d,R);!h._events||!h._events[d]?h.on(d,R):Array.isArray(h._events[d])?h._events[d].unshift(R):h._events[d]=[R,h._events[d]]}function D(h,d,R){e=e||lt(),h=h||{},typeof R!="boolean"&&(R=d instanceof e),this.objectMode=!!h.objectMode,R&&(this.objectMode=this.objectMode||!!h.readableObjectMode),this.highWaterMark=A(this,h,"readableHighWaterMark",R),this.buffer=new g,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=h.emitClose!==!1,this.autoDestroy=!!h.autoDestroy,this.destroyed=!1,this.defaultEncoding=h.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,h.encoding&&(F||(F=jt.StringDecoder),this.decoder=new F(h.encoding),this.encoding=h.encoding)}function $(h){if(e=e||lt(),!(this instanceof $))return new $(h);var d=this instanceof e;this._readableState=new D(h,this,d),this.readable=!0,h&&(typeof h.read=="function"&&(this._read=h.read),typeof h.destroy=="function"&&(this._destroy=h.destroy)),r.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(d){this._readableState&&(this._readableState.destroyed=d)}}),$.prototype.destroy=m.destroy,$.prototype._undestroy=m.undestroy,$.prototype._destroy=function(h,d){d(h)},$.prototype.push=function(h,d){var R=this._readableState,M;return R.objectMode?M=!0:typeof h=="string"&&(d=d||R.defaultEncoding,d!==R.encoding&&(h=i.from(h,d),d=""),M=!0),ie(this,h,d,!1,M)},$.prototype.unshift=function(h){return ie(this,h,null,!0,!1)};function ie(h,d,R,M,Z){p("readableAddChunk",d);var W=h._readableState;if(d===null)W.reading=!1,Je(h,W);else{var K;if(Z||(K=$e(W,d)),K)N(h,K);else if(W.objectMode||d&&d.length>0)if(typeof d!="string"&&!W.objectMode&&Object.getPrototypeOf(d)!==i.prototype&&(d=s(d)),M)W.endEmitted?N(h,new C):Te(h,W,d,!0);else if(W.ended)N(h,new O);else{if(W.destroyed)return!1;W.reading=!1,W.decoder&&!R?(d=W.decoder.write(d),W.objectMode||d.length!==0?Te(h,W,d,!1):ke(h,W)):Te(h,W,d,!1)}else M||(W.reading=!1,ke(h,W))}return!W.ended&&(W.length<W.highWaterMark||W.length===0)}function Te(h,d,R,M){d.flowing&&d.length===0&&!d.sync?(d.awaitDrain=0,h.emit("data",R)):(d.length+=d.objectMode?1:R.length,M?d.buffer.unshift(R):d.buffer.push(R),d.needReadable&&Ie(h)),ke(h,d)}function $e(h,d){var R;return!c(d)&&typeof d!="string"&&d!==void 0&&!h.objectMode&&(R=new E("chunk",["string","Buffer","Uint8Array"],d)),R}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(h){F||(F=jt.StringDecoder);var d=new F(h);this._readableState.decoder=d,this._readableState.encoding=this._readableState.decoder.encoding;for(var R=this._readableState.buffer.head,M="";R!==null;)M+=d.write(R.data),R=R.next;return this._readableState.buffer.clear(),M!==""&&this._readableState.buffer.push(M),this._readableState.length=M.length,this};var oe=1073741824;function me(h){return h>=oe?h=oe:(h--,h|=h>>>1,h|=h>>>2,h|=h>>>4,h|=h>>>8,h|=h>>>16,h++),h}function ve(h,d){return h<=0||d.length===0&&d.ended?0:d.objectMode?1:h!==h?d.flowing&&d.length?d.buffer.head.data.length:d.length:(h>d.highWaterMark&&(d.highWaterMark=me(h)),h<=d.length?h:d.ended?d.length:(d.needReadable=!0,0))}$.prototype.read=function(h){p("read",h),h=parseInt(h,10);var d=this._readableState,R=h;if(h!==0&&(d.emittedReadable=!1),h===0&&d.needReadable&&((d.highWaterMark!==0?d.length>=d.highWaterMark:d.length>0)||d.ended))return p("read: emitReadable",d.length,d.ended),d.length===0&&d.ended?S(this):Ie(this),null;if(h=ve(h,d),h===0&&d.ended)return d.length===0&&S(this),null;var M=d.needReadable;p("need readable",M),(d.length===0||d.length-h<d.highWaterMark)&&(M=!0,p("length less than watermark",M)),d.ended||d.reading?(M=!1,p("reading or ended",M)):M&&(p("do read"),d.reading=!0,d.sync=!0,d.length===0&&(d.needReadable=!0),this._read(d.highWaterMark),d.sync=!1,d.reading||(h=ve(R,d)));var Z;return h>0?Z=y(h,d):Z=null,Z===null?(d.needReadable=d.length<=d.highWaterMark,h=0):(d.length-=h,d.awaitDrain=0),d.length===0&&(d.ended||(d.needReadable=!0),R!==h&&d.ended&&S(this)),Z!==null&&this.emit("data",Z),Z};function Je(h,d){if(p("onEofChunk"),!d.ended){if(d.decoder){var R=d.decoder.end();R&&R.length&&(d.buffer.push(R),d.length+=d.objectMode?1:R.length)}d.ended=!0,d.sync?Ie(h):(d.needReadable=!1,d.emittedReadable||(d.emittedReadable=!0,He(h)))}}function Ie(h){var d=h._readableState;p("emitReadable",d.needReadable,d.emittedReadable),d.needReadable=!1,d.emittedReadable||(p("emitReadable",d.flowing),d.emittedReadable=!0,process.nextTick(He,h))}function He(h){var d=h._readableState;p("emitReadable_",d.destroyed,d.length,d.ended),!d.destroyed&&(d.length||d.ended)&&(h.emit("readable"),d.emittedReadable=!1),d.needReadable=!d.flowing&&!d.ended&&d.length<=d.highWaterMark,_(h)}function ke(h,d){d.readingMore||(d.readingMore=!0,process.nextTick(je,h,d))}function je(h,d){for(;!d.reading&&!d.ended&&(d.length<d.highWaterMark||d.flowing&&d.length===0);){var R=d.length;if(p("maybeReadMore read 0"),h.read(0),R===d.length)break}d.readingMore=!1}$.prototype._read=function(h){N(this,new T("_read()"))},$.prototype.pipe=function(h,d){var R=this,M=this._readableState;switch(M.pipesCount){case 0:M.pipes=h;break;case 1:M.pipes=[M.pipes,h];break;default:M.pipes.push(h);break}M.pipesCount+=1,p("pipe count=%d opts=%j",M.pipesCount,d);var Z=(!d||d.end!==!1)&&h!==process.stdout&&h!==process.stderr,W=Z?We:Ye;M.endEmitted?process.nextTick(W):R.once("end",W),h.on("unpipe",K);function K(f,n){p("onunpipe"),f===R&&n&&n.hasUnpiped===!1&&(n.hasUnpiped=!0,rt())}function We(){p("onend"),h.end()}var tt=Q(R);h.on("drain",tt);var pt=!1;function rt(){p("cleanup"),h.removeListener("close",bt),h.removeListener("finish",Re),h.removeListener("drain",tt),h.removeListener("error",ze),h.removeListener("unpipe",K),R.removeListener("end",We),R.removeListener("end",Ye),R.removeListener("data",Be),pt=!0,M.awaitDrain&&(!h._writableState||h._writableState.needDrain)&&tt()}R.on("data",Be);function Be(f){p("ondata");var n=h.write(f);p("dest.write",n),n===!1&&((M.pipesCount===1&&M.pipes===h||M.pipesCount>1&&q(M.pipes,h)!==-1)&&!pt&&(p("false write response, pause",M.awaitDrain),M.awaitDrain++),R.pause())}function ze(f){p("onerror",f),Ye(),h.removeListener("error",ze),t(h,"error")===0&&N(h,f)}j(h,"error",ze);function bt(){h.removeListener("finish",Re),Ye()}h.once("close",bt);function Re(){p("onfinish"),h.removeListener("close",bt),Ye()}h.once("finish",Re);function Ye(){p("unpipe"),R.unpipe(h)}return h.emit("pipe",R),M.flowing||(p("pipe resume"),R.resume()),h};function Q(h){return function(){var R=h._readableState;p("pipeOnDrain",R.awaitDrain),R.awaitDrain&&R.awaitDrain--,R.awaitDrain===0&&t(h,"data")&&(R.flowing=!0,_(h))}}$.prototype.unpipe=function(h){var d=this._readableState,R={hasUnpiped:!1};if(d.pipesCount===0)return this;if(d.pipesCount===1)return h&&h!==d.pipes?this:(h||(h=d.pipes),d.pipes=null,d.pipesCount=0,d.flowing=!1,h&&h.emit("unpipe",this,R),this);if(!h){var M=d.pipes,Z=d.pipesCount;d.pipes=null,d.pipesCount=0,d.flowing=!1;for(var W=0;W<Z;W++)M[W].emit("unpipe",this,{hasUnpiped:!1});return this}var K=q(d.pipes,h);return K===-1?this:(d.pipes.splice(K,1),d.pipesCount-=1,d.pipesCount===1&&(d.pipes=d.pipes[0]),h.emit("unpipe",this,R),this)},$.prototype.on=function(h,d){var R=r.prototype.on.call(this,h,d),M=this._readableState;return h==="data"?(M.readableListening=this.listenerCount("readable")>0,M.flowing!==!1&&this.resume()):h==="readable"&&!M.endEmitted&&!M.readableListening&&(M.readableListening=M.needReadable=!0,M.flowing=!1,M.emittedReadable=!1,p("on readable",M.length,M.reading),M.length?Ie(this):M.reading||process.nextTick(Ee,this)),R},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(h,d){var R=r.prototype.removeListener.call(this,h,d);return h==="readable"&&process.nextTick(ae,this),R},$.prototype.removeAllListeners=function(h){var d=r.prototype.removeAllListeners.apply(this,arguments);return(h==="readable"||h===void 0)&&process.nextTick(ae,this),d};function ae(h){var d=h._readableState;d.readableListening=h.listenerCount("readable")>0,d.resumeScheduled&&!d.paused?d.flowing=!0:h.listenerCount("data")>0&&h.resume()}function Ee(h){p("readable nexttick read 0"),h.read(0)}$.prototype.resume=function(){var h=this._readableState;return h.flowing||(p("resume"),h.flowing=!h.readableListening,qe(this,h)),h.paused=!1,this};function qe(h,d){d.resumeScheduled||(d.resumeScheduled=!0,process.nextTick(Fe,h,d))}function Fe(h,d){p("resume",d.reading),d.reading||h.read(0),d.resumeScheduled=!1,h.emit("resume"),_(h),d.flowing&&!d.reading&&h.read(0)}$.prototype.pause=function(){return p("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(p("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this};function _(h){var d=h._readableState;for(p("flow",d.flowing);d.flowing&&h.read()!==null;);}$.prototype.wrap=function(h){var d=this,R=this._readableState,M=!1;h.on("end",function(){if(p("wrapped end"),R.decoder&&!R.ended){var K=R.decoder.end();K&&K.length&&d.push(K)}d.push(null)}),h.on("data",function(K){if(p("wrapped data"),R.decoder&&(K=R.decoder.write(K)),!(R.objectMode&&K==null)&&!(!R.objectMode&&(!K||!K.length))){var We=d.push(K);We||(M=!0,h.pause())}});for(var Z in h)this[Z]===void 0&&typeof h[Z]=="function"&&(this[Z]=function(We){return function(){return h[We].apply(h,arguments)}}(Z));for(var W=0;W<B.length;W++)h.on(B[W],this.emit.bind(this,B[W]));return this._read=function(K){p("wrapped _read",K),M&&(M=!1,h.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return P===void 0&&(P=Na()),P(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(d){this._readableState&&(this._readableState.flowing=d)}}),$._fromList=y,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function y(h,d){if(d.length===0)return null;var R;return d.objectMode?R=d.buffer.shift():!h||h>=d.length?(d.decoder?R=d.buffer.join(""):d.buffer.length===1?R=d.buffer.first():R=d.buffer.concat(d.length),d.buffer.clear()):R=d.buffer.consume(h,d.decoder),R}function S(h){var d=h._readableState;p("endReadable",d.endEmitted),d.endEmitted||(d.ended=!0,process.nextTick(U,d,h))}function U(h,d){if(p("endReadableNT",h.endEmitted,h.length),!h.endEmitted&&h.length===0&&(h.endEmitted=!0,d.readable=!1,d.emit("end"),h.autoDestroy)){var R=d._writableState;(!R||R.autoDestroy&&R.finished)&&d.destroy()}}typeof Symbol=="function"&&($.from=function(h,d){return L===void 0&&(L=Da()),L($,h,d)});function q(h,d){for(var R=0,M=h.length;R<M;R++)if(h[R]===d)return R;return-1}return pr}var Vn=Ue,Vt=Ze.codes,Ua=Vt.ERR_METHOD_NOT_IMPLEMENTED,$a=Vt.ERR_MULTIPLE_CALLBACK,Ha=Vt.ERR_TRANSFORM_ALREADY_TRANSFORMING,ja=Vt.ERR_TRANSFORM_WITH_LENGTH_0,Jt=lt();ye(Ue,Jt);function qa(e,t){var r=this._transformState;r.transforming=!1;var i=r.writecb;if(i===null)return this.emit("error",new $a);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),i(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function Ue(e){if(!(this instanceof Ue))return new Ue(e);Jt.call(this,e),this._transformState={afterTransform:qa.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Wa)}function Wa(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){nn(e,t,r)}):nn(this,null,null)}Ue.prototype.push=function(e,t){return this._transformState.needTransform=!1,Jt.prototype.push.call(this,e,t)};Ue.prototype._transform=function(e,t,r){r(new Ua("_transform()"))};Ue.prototype._write=function(e,t,r){var i=this._transformState;if(i.writecb=r,i.writechunk=e,i.writeencoding=t,!i.transforming){var o=this._readableState;(i.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}};Ue.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Ue.prototype._destroy=function(e,t){Jt.prototype._destroy.call(this,e,function(r){t(r)})};function nn(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new ja;if(e._transformState.transforming)throw new Ha;return e.push(null)}var Ga=St,Jn=Vn;ye(St,Jn);function St(e){if(!(this instanceof St))return new St(e);Jn.call(this,e)}St.prototype._transform=function(e,t,r){r(null,e)};var br;function Ka(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var zn=Ze.codes,Va=zn.ERR_MISSING_ARGS,Ja=zn.ERR_STREAM_DESTROYED;function an(e){if(e)throw e}function za(e){return e.setHeader&&typeof e.abort=="function"}function Ya(e,t,r,i){i=Ka(i);var o=!1;e.on("close",function(){o=!0}),br===void 0&&(br=Dr),br(e,{readable:t,writable:r},function(c){if(c)return i(c);o=!0,i()});var s=!1;return function(c){if(!o&&!s){if(s=!0,za(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();i(c||new Ja("pipe"))}}}function on(e){e()}function Xa(e,t){return e.pipe(t)}function Qa(e){return!e.length||typeof e[e.length-1]!="function"?an:e.pop()}function Za(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var i=Qa(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Va("streams");var o,s=t.map(function(c,u){var p=u<t.length-1,g=u>0;return Ya(c,p,g,function(m){o||(o=m),m&&s.forEach(on),!p&&(s.forEach(on),i(o))})});return t.reduce(Xa)}var eo=Za;(function(e,t){t=e.exports=Kn(),t.Stream=t,t.Readable=t,t.Writable=Wn(),t.Duplex=lt(),t.Transform=Vn,t.PassThrough=Ga,t.finished=Dr,t.pipeline=eo})(Er,Er.exports);var to=Er.exports,qt=xe.Buffer,Yn=to.Transform,ro=ye;function no(e,t){if(!qt.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function Ve(e){Yn.call(this),this._block=qt.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}ro(Ve,Yn);Ve.prototype._transform=function(e,t,r){var i=null;try{this.update(e,t)}catch(o){i=o}r(i)};Ve.prototype._flush=function(e){var t=null;try{this.push(this.digest())}catch(r){t=r}e(t)};Ve.prototype.update=function(e,t){if(no(e,"Data"),this._finalized)throw new Error("Digest already called");qt.isBuffer(e)||(e=qt.from(e,t));for(var r=this._block,i=0;this._blockOffset+e.length-i>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=e[i++];this._update(),this._blockOffset=0}for(;i<e.length;)r[this._blockOffset++]=e[i++];for(var s=0,c=e.length*8;c>0;++s)this._length[s]+=c,c=this._length[s]/4294967296|0,c>0&&(this._length[s]-=4294967296*c);return this};Ve.prototype._update=function(){throw new Error("_update is not implemented")};Ve.prototype.digest=function(e){if(this._finalized)throw new Error("Digest already called");this._finalized=!0;var t=this._digest();e!==void 0&&(t=t.toString(e)),this._block.fill(0),this._blockOffset=0;for(var r=0;r<4;++r)this._length[r]=0;return t};Ve.prototype._digest=function(){throw new Error("_digest is not implemented")};var Xn=Ve,io=ye,Qn=Xn,ao=xe.Buffer,oo=new Array(16);function zt(){Qn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}io(zt,Qn);zt.prototype._update=function(){for(var e=oo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,i=this._b,o=this._c,s=this._d;r=ce(r,i,o,s,e[0],3614090360,7),s=ce(s,r,i,o,e[1],3905402710,12),o=ce(o,s,r,i,e[2],606105819,17),i=ce(i,o,s,r,e[3],3250441966,22),r=ce(r,i,o,s,e[4],4118548399,7),s=ce(s,r,i,o,e[5],1200080426,12),o=ce(o,s,r,i,e[6],2821735955,17),i=ce(i,o,s,r,e[7],4249261313,22),r=ce(r,i,o,s,e[8],1770035416,7),s=ce(s,r,i,o,e[9],2336552879,12),o=ce(o,s,r,i,e[10],4294925233,17),i=ce(i,o,s,r,e[11],2304563134,22),r=ce(r,i,o,s,e[12],1804603682,7),s=ce(s,r,i,o,e[13],4254626195,12),o=ce(o,s,r,i,e[14],2792965006,17),i=ce(i,o,s,r,e[15],1236535329,22),r=le(r,i,o,s,e[1],4129170786,5),s=le(s,r,i,o,e[6],3225465664,9),o=le(o,s,r,i,e[11],643717713,14),i=le(i,o,s,r,e[0],3921069994,20),r=le(r,i,o,s,e[5],3593408605,5),s=le(s,r,i,o,e[10],38016083,9),o=le(o,s,r,i,e[15],3634488961,14),i=le(i,o,s,r,e[4],3889429448,20),r=le(r,i,o,s,e[9],568446438,5),s=le(s,r,i,o,e[14],3275163606,9),o=le(o,s,r,i,e[3],4107603335,14),i=le(i,o,s,r,e[8],1163531501,20),r=le(r,i,o,s,e[13],2850285829,5),s=le(s,r,i,o,e[2],4243563512,9),o=le(o,s,r,i,e[7],1735328473,14),i=le(i,o,s,r,e[12],2368359562,20),r=he(r,i,o,s,e[5],4294588738,4),s=he(s,r,i,o,e[8],2272392833,11),o=he(o,s,r,i,e[11],1839030562,16),i=he(i,o,s,r,e[14],4259657740,23),r=he(r,i,o,s,e[1],2763975236,4),s=he(s,r,i,o,e[4],1272893353,11),o=he(o,s,r,i,e[7],4139469664,16),i=he(i,o,s,r,e[10],3200236656,23),r=he(r,i,o,s,e[13],681279174,4),s=he(s,r,i,o,e[0],3936430074,11),o=he(o,s,r,i,e[3],3572445317,16),i=he(i,o,s,r,e[6],76029189,23),r=he(r,i,o,s,e[9],3654602809,4),s=he(s,r,i,o,e[12],3873151461,11),o=he(o,s,r,i,e[15],530742520,16),i=he(i,o,s,r,e[2],3299628645,23),r=de(r,i,o,s,e[0],4096336452,6),s=de(s,r,i,o,e[7],1126891415,10),o=de(o,s,r,i,e[14],2878612391,15),i=de(i,o,s,r,e[5],4237533241,21),r=de(r,i,o,s,e[12],1700485571,6),s=de(s,r,i,o,e[3],2399980690,10),o=de(o,s,r,i,e[10],4293915773,15),i=de(i,o,s,r,e[1],2240044497,21),r=de(r,i,o,s,e[8],1873313359,6),s=de(s,r,i,o,e[15],4264355552,10),o=de(o,s,r,i,e[6],2734768916,15),i=de(i,o,s,r,e[13],1309151649,21),r=de(r,i,o,s,e[4],4149444226,6),s=de(s,r,i,o,e[11],3174756917,10),o=de(o,s,r,i,e[2],718787259,15),i=de(i,o,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+i|0,this._c=this._c+o|0,this._d=this._d+s|0};zt.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 e=ao.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function Yt(e,t){return e<<t|e>>>32-t}function ce(e,t,r,i,o,s,c){return Yt(e+(t&r|~t&i)+o+s|0,c)+t|0}function le(e,t,r,i,o,s,c){return Yt(e+(t&i|r&~i)+o+s|0,c)+t|0}function he(e,t,r,i,o,s,c){return Yt(e+(t^r^i)+o+s|0,c)+t|0}function de(e,t,r,i,o,s,c){return Yt(e+(r^(t|~i))+o+s|0,c)+t|0}var so=zt,yr=ht.Buffer,fo=ye,Zn=Xn,uo=new Array(16),gt=[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],wt=[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],mt=[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],vt=[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],xt=[0,1518500249,1859775393,2400959708,2840853838],Et=[1352829926,1548603684,1836072691,2053994217,0];function Xt(){Zn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}fo(Xt,Zn);Xt.prototype._update=function(){for(var e=uo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,i=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=this._a|0,p=this._b|0,g=this._c|0,m=this._d|0,v=this._e|0,A=0;A<80;A+=1){var k,E;A<16?(k=sn(r,i,o,s,c,e[gt[A]],xt[0],mt[A]),E=ln(u,p,g,m,v,e[wt[A]],Et[0],vt[A])):A<32?(k=fn(r,i,o,s,c,e[gt[A]],xt[1],mt[A]),E=cn(u,p,g,m,v,e[wt[A]],Et[1],vt[A])):A<48?(k=un(r,i,o,s,c,e[gt[A]],xt[2],mt[A]),E=un(u,p,g,m,v,e[wt[A]],Et[2],vt[A])):A<64?(k=cn(r,i,o,s,c,e[gt[A]],xt[3],mt[A]),E=fn(u,p,g,m,v,e[wt[A]],Et[3],vt[A])):(k=ln(r,i,o,s,c,e[gt[A]],xt[4],mt[A]),E=sn(u,p,g,m,v,e[wt[A]],Et[4],vt[A])),r=c,c=s,s=Qe(o,10),o=i,i=k,u=v,v=m,m=Qe(g,10),g=p,p=E}var O=this._b+o+m|0;this._b=this._c+s+v|0,this._c=this._d+c+u|0,this._d=this._e+r+p|0,this._e=this._a+i+g|0,this._a=O};Xt.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 e=yr.alloc?yr.alloc(20):new yr(20);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e.writeInt32LE(this._e,16),e};function Qe(e,t){return e<<t|e>>>32-t}function sn(e,t,r,i,o,s,c,u){return Qe(e+(t^r^i)+s+c|0,u)+o|0}function fn(e,t,r,i,o,s,c,u){return Qe(e+(t&r|~t&i)+s+c|0,u)+o|0}function un(e,t,r,i,o,s,c,u){return Qe(e+((t|~r)^i)+s+c|0,u)+o|0}function cn(e,t,r,i,o,s,c,u){return Qe(e+(t&i|r&~i)+s+c|0,u)+o|0}function ln(e,t,r,i,o,s,c,u){return Qe(e+(t^(r|~i))+s+c|0,u)+o|0}var co=Xt,ei={exports:{}},ti=xe.Buffer;function Qt(e,t){this._block=ti.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Qt.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=ti.from(e,t));for(var r=this._block,i=this._blockSize,o=e.length,s=this._len,c=0;c<o;){for(var u=s%i,p=Math.min(o-c,i-u),g=0;g<p;g++)r[u+g]=e[c+g];s+=p,c+=p,s%i===0&&this._update(r)}return this._len+=o,this};Qt.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var i=(r&4294967295)>>>0,o=(r-i)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(i,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};Qt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var dt=Qt,lo=ye,ri=dt,ho=xe.Buffer,po=[1518500249,1859775393,-1894007588,-899497514],bo=new Array(80);function It(){this.init(),this._w=bo,ri.call(this,64,56)}lo(It,ri);It.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function yo(e){return e<<5|e>>>27}function _o(e){return e<<30|e>>>2}function go(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}It.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=t[u-3]^t[u-8]^t[u-14]^t[u-16];for(var p=0;p<80;++p){var g=~~(p/20),m=yo(r)+go(g,i,o,s)+c+t[p]+po[g]|0;c=s,s=o,o=_o(i),i=r,r=m}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0};It.prototype._hash=function(){var e=ho.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var wo=It,mo=ye,ni=dt,vo=xe.Buffer,xo=[1518500249,1859775393,-1894007588,-899497514],Eo=new Array(80);function kt(){this.init(),this._w=Eo,ni.call(this,64,56)}mo(kt,ni);kt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Bo(e){return e<<1|e>>>31}function Ro(e){return e<<5|e>>>27}function So(e){return e<<30|e>>>2}function Ao(e,t,r,i){return e===0?t&r|~t&i:e===2?t&r|t&i|r&i:t^r^i}kt.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Bo(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var g=~~(p/20),m=Ro(r)+Ao(g,i,o,s)+c+t[p]+xo[g]|0;c=s,s=o,o=So(i),i=r,r=m}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0};kt.prototype._hash=function(){var e=vo.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var To=kt,Io=ye,ii=dt,ko=xe.Buffer,Co=[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],Oo=new Array(64);function Ct(){this.init(),this._w=Oo,ii.call(this,64,56)}Io(Ct,ii);Ct.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Lo(e,t,r){return r^e&(t^r)}function Fo(e,t,r){return e&t|r&(e|t)}function Po(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Mo(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function No(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Do(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}Ct.prototype._update=function(e){for(var t=this._w,r=this._a|0,i=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=this._f|0,p=this._g|0,g=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=Do(t[m-2])+t[m-7]+No(t[m-15])+t[m-16]|0;for(var v=0;v<64;++v){var A=g+Mo(c)+Lo(c,u,p)+Co[v]+t[v]|0,k=Po(r)+Fo(r,i,o)|0;g=p,p=u,u=c,c=s+A|0,s=o,o=i,i=r,r=A+k|0}this._a=r+this._a|0,this._b=i+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0,this._f=u+this._f|0,this._g=p+this._g|0,this._h=g+this._h|0};Ct.prototype._hash=function(){var e=ko.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var ai=Ct,Uo=ye,$o=ai,Ho=dt,jo=xe.Buffer,qo=new Array(64);function Zt(){this.init(),this._w=qo,Ho.call(this,64,56)}Uo(Zt,$o);Zt.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};Zt.prototype._hash=function(){var e=jo.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var Wo=Zt,Go=ye,oi=dt,Ko=xe.Buffer,hn=[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],Vo=new Array(160);function Ot(){this.init(),this._w=Vo,oi.call(this,128,112)}Go(Ot,oi);Ot.prototype.init=function(){return this._ah=1779033703,this._bh=3144134277,this._ch=1013904242,this._dh=2773480762,this._eh=1359893119,this._fh=2600822924,this._gh=528734635,this._hh=1541459225,this._al=4089235720,this._bl=2227873595,this._cl=4271175723,this._dl=1595750129,this._el=2917565137,this._fl=725511199,this._gl=4215389547,this._hl=327033209,this};function dn(e,t,r){return r^e&(t^r)}function pn(e,t,r){return e&t|r&(e|t)}function bn(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function yn(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Jo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function zo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Yo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Xo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function fe(e,t){return e>>>0<t>>>0?1:0}Ot.prototype._update=function(e){for(var t=this._w,r=this._ah|0,i=this._bh|0,o=this._ch|0,s=this._dh|0,c=this._eh|0,u=this._fh|0,p=this._gh|0,g=this._hh|0,m=this._al|0,v=this._bl|0,A=this._cl|0,k=this._dl|0,E=this._el|0,O=this._fl|0,T=this._gl|0,C=this._hl|0,F=0;F<32;F+=2)t[F]=e.readInt32BE(F*4),t[F+1]=e.readInt32BE(F*4+4);for(;F<160;F+=2){var P=t[F-30],L=t[F-15*2+1],N=Jo(P,L),B=zo(L,P);P=t[F-2*2],L=t[F-2*2+1];var j=Yo(P,L),D=Xo(L,P),$=t[F-7*2],ie=t[F-7*2+1],Te=t[F-16*2],$e=t[F-16*2+1],oe=B+ie|0,me=N+$+fe(oe,B)|0;oe=oe+D|0,me=me+j+fe(oe,D)|0,oe=oe+$e|0,me=me+Te+fe(oe,$e)|0,t[F]=me,t[F+1]=oe}for(var ve=0;ve<160;ve+=2){me=t[ve],oe=t[ve+1];var Je=pn(r,i,o),Ie=pn(m,v,A),He=bn(r,m),ke=bn(m,r),je=yn(c,E),Q=yn(E,c),ae=hn[ve],Ee=hn[ve+1],qe=dn(c,u,p),Fe=dn(E,O,T),_=C+Q|0,y=g+je+fe(_,C)|0;_=_+Fe|0,y=y+qe+fe(_,Fe)|0,_=_+Ee|0,y=y+ae+fe(_,Ee)|0,_=_+oe|0,y=y+me+fe(_,oe)|0;var S=ke+Ie|0,U=He+Je+fe(S,ke)|0;g=p,C=T,p=u,T=O,u=c,O=E,E=k+_|0,c=s+y+fe(E,k)|0,s=o,k=A,o=i,A=v,i=r,v=m,m=_+S|0,r=y+U+fe(m,_)|0}this._al=this._al+m|0,this._bl=this._bl+v|0,this._cl=this._cl+A|0,this._dl=this._dl+k|0,this._el=this._el+E|0,this._fl=this._fl+O|0,this._gl=this._gl+T|0,this._hl=this._hl+C|0,this._ah=this._ah+r+fe(this._al,m)|0,this._bh=this._bh+i+fe(this._bl,v)|0,this._ch=this._ch+o+fe(this._cl,A)|0,this._dh=this._dh+s+fe(this._dl,k)|0,this._eh=this._eh+c+fe(this._el,E)|0,this._fh=this._fh+u+fe(this._fl,O)|0,this._gh=this._gh+p+fe(this._gl,T)|0,this._hh=this._hh+g+fe(this._hl,C)|0};Ot.prototype._hash=function(){var e=Ko.allocUnsafe(64);function t(r,i,o){e.writeInt32BE(r,o),e.writeInt32BE(i,o+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),t(this._gh,this._gl,48),t(this._hh,this._hl,56),e};var si=Ot,Qo=ye,Zo=si,es=dt,ts=xe.Buffer,rs=new Array(160);function er(){this.init(),this._w=rs,es.call(this,128,112)}Qo(er,Zo);er.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};er.prototype._hash=function(){var e=ts.allocUnsafe(48);function t(r,i,o){e.writeInt32BE(r,o),e.writeInt32BE(i,o+4)}return t(this._ah,this._al,0),t(this._bh,this._bl,8),t(this._ch,this._cl,16),t(this._dh,this._dl,24),t(this._eh,this._el,32),t(this._fh,this._fl,40),e};var ns=er,et=ei.exports=function(t){t=t.toLowerCase();var r=et[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};et.sha=wo;et.sha1=To;et.sha224=Wo;et.sha256=ai;et.sha384=ns;et.sha512=si;var is=ei.exports,fi=xe.Buffer,ui=Mr.Transform,as=jt.StringDecoder,os=ye;function Ce(e){ui.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}os(Ce,ui);Ce.prototype.update=function(e,t,r){typeof e=="string"&&(e=fi.from(e,t));var i=this._update(e);return this.hashMode?this:(r&&(i=this._toString(i,r)),i)};Ce.prototype.setAutoPadding=function(){};Ce.prototype.getAuthTag=function(){throw new Error("trying to get auth tag in unsupported state")};Ce.prototype.setAuthTag=function(){throw new Error("trying to set auth tag in unsupported state")};Ce.prototype.setAAD=function(){throw new Error("trying to set aad in unsupported state")};Ce.prototype._transform=function(e,t,r){var i;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(o){i=o}finally{r(i)}};Ce.prototype._flush=function(e){var t;try{this.push(this.__final())}catch(r){t=r}e(t)};Ce.prototype._finalOrDigest=function(e){var t=this.__final()||fi.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Ce.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new as(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var i=this._decoder.write(e);return r&&(i+=this._decoder.end()),i};var ss=Ce,fs=ye,us=so,cs=co,ls=is,ci=ss;function tr(e){ci.call(this,"digest"),this._hash=e}fs(tr,ci);tr.prototype._update=function(e){this._hash.update(e)};tr.prototype._final=function(){return this._hash.digest()};var hs=function(t){return t=t.toLowerCase(),t==="md5"?new us:t==="rmd160"||t==="ripemd160"?new cs:new tr(ls(t))},Ft=xe.Buffer;function ds(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var i=0;i<e.length;i++){var o=e.charAt(i),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=i}var c=e.length,u=e.charAt(0),p=Math.log(c)/Math.log(256),g=Math.log(256)/Math.log(c);function m(k){if((Array.isArray(k)||k instanceof Uint8Array)&&(k=Ft.from(k)),!Ft.isBuffer(k))throw new TypeError("Expected Buffer");if(k.length===0)return"";for(var E=0,O=0,T=0,C=k.length;T!==C&&k[T]===0;)T++,E++;for(var F=(C-T)*g+1>>>0,P=new Uint8Array(F);T!==C;){for(var L=k[T],N=0,B=F-1;(L!==0||N<O)&&B!==-1;B--,N++)L+=256*P[B]>>>0,P[B]=L%c>>>0,L=L/c>>>0;if(L!==0)throw new Error("Non-zero carry");O=N,T++}for(var j=F-O;j!==F&&P[j]===0;)j++;for(var D=u.repeat(E);j<F;++j)D+=e.charAt(P[j]);return D}function v(k){if(typeof k!="string")throw new TypeError("Expected String");if(k.length===0)return Ft.alloc(0);for(var E=0,O=0,T=0;k[E]===u;)O++,E++;for(var C=(k.length-E)*p+1>>>0,F=new Uint8Array(C);E<k.length;){var P=t[k.charCodeAt(E)];if(P===255)return;for(var L=0,N=C-1;(P!==0||L<T)&&N!==-1;N--,L++)P+=c*F[N]>>>0,F[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");T=L,E++}for(var B=C-T;B!==C&&F[B]===0;)B++;var j=Ft.allocUnsafe(O+(C-B));j.fill(0,0,O);for(var D=O;B!==C;)j[D++]=F[B++];return j}function A(k){var E=v(k);if(E)return E;throw new Error("Non-base"+c+" character")}return{encode:m,decodeUnsafe:v,decode:A}}var ps=ds,bs=ps,ys="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_s=bs(ys),_r=_s,gs=xe.Buffer,ws=function(e){function t(s){var c=e(s);return _r.encode(gs.concat([s,c],s.length+4))}function r(s){var c=s.slice(0,-4),u=s.slice(-4),p=e(c);if(!(u[0]^p[0]|u[1]^p[1]|u[2]^p[2]|u[3]^p[3]))return c}function i(s){var c=_r.decodeUnsafe(s);if(c)return r(c)}function o(s){var c=_r.decode(s),u=r(c);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:o,decodeUnsafe:i}},_n=hs,ms=ws;function vs(e){var t=_n("sha256").update(e).digest();return _n("sha256").update(t).digest()}var xs=ms(vs),Rr=xs;function li(e,t){if(t!==void 0&&e[0]!==t)throw new Error("Invalid network version");if(e.length===33)return{version:e[0],privateKey:e.slice(1,33),compressed:!1};if(e.length!==34)throw new Error("Invalid WIF length");if(e[33]!==1)throw new Error("Invalid compression flag");return{version:e[0],privateKey:e.slice(1,33),compressed:!0}}function Sr(e,t,r){var i=new Buffer(r?34:33);return i.writeUInt8(e,0),t.copy(i,1),r&&(i[33]=1),i}function Es(e,t){return li(Rr.decode(e),t)}function Bs(e,t,r){return typeof e=="number"?Rr.encode(Sr(e,t,r)):Rr.encode(Sr(e.version,e.privateKey,e.compressed))}var Rs={decode:Es,decodeRaw:li,encode:Bs,encodeRaw:Sr},rr={};Object.defineProperty(rr,"__esModule",{value:!0});rr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Ss(e){z(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),z(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),z(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),z(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),z(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),z(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),z(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),z(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),z(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),z(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),z(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),z(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),z(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),z(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),z(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));z(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),z(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),z(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),z(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&z(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&z(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}rr.testEcc=Ss;function z(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(ut,"__esModule",{value:!0});ut.ECPairFactory=ut.networks=void 0;const Ar=ct;ut.networks=Ar;const ge=Bn,As=Zi,gn=Rs,Ts=rr,gr=ge.typeforce.maybe(ge.typeforce.compile({compressed:ge.maybe(ge.Boolean),network:ge.maybe(ge.Network)})),Is=e=>e.length===32?e:e.slice(1,33);function ks(e){(0,Ts.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,p){if(ge.typeforce(ge.Buffer256bit,u),!e.isPrivate(u))throw new TypeError("Private key not in range [1, n)");return ge.typeforce(gr,p),new c(u,void 0,p)}function i(u,p){return ge.typeforce(e.isPoint,u),ge.typeforce(gr,p),new c(void 0,u,p)}function o(u,p){const g=gn.decode(u),m=g.version;if(ge.Array(p)){if(p=p.filter(v=>m===v.wif).pop(),!p)throw new Error("Unknown network version")}else if(p=p||Ar.bitcoin,m!==p.wif)throw new Error("Invalid network version");return r(g.privateKey,{compressed:g.compressed,network:p})}function s(u){ge.typeforce(gr,u),u===void 0&&(u={});const p=u.rng||As;let g;do g=p(32),ge.typeforce(ge.Buffer256bit,g);while(!e.isPrivate(g));return r(g,u)}class c{constructor(p,g,m){nt(this,"__D");nt(this,"__Q");nt(this,"compressed");nt(this,"network");nt(this,"lowR");this.__D=p,this.__Q=g,this.lowR=!1,m===void 0&&(m={}),this.compressed=m.compressed===void 0?!0:m.compressed,this.network=m.network||Ar.bitcoin,g!==void 0&&(this.__Q=Buffer.from(e.pointCompress(g,this.compressed)))}get privateKey(){return this.__D}get publicKey(){if(!this.__Q){const p=e.pointFromScalar(this.__D,this.compressed);this.__Q=Buffer.from(p)}return this.__Q}toWIF(){if(!this.__D)throw new Error("Missing private key");return gn.encode(this.network.wif,this.__D,this.compressed)}tweak(p){return this.privateKey?this.tweakFromPrivateKey(p):this.tweakFromPublicKey(p)}sign(p,g){if(!this.__D)throw new Error("Missing private key");if(g===void 0&&(g=this.lowR),g===!1)return Buffer.from(e.sign(p,this.__D));{let m=e.sign(p,this.__D);const v=Buffer.alloc(32,0);let A=0;for(;m[0]>127;)A++,v.writeUIntLE(A,0,6),m=e.sign(p,this.__D,v);return Buffer.from(m)}}signSchnorr(p){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return Buffer.from(e.signSchnorr(p,this.privateKey))}verify(p,g){return e.verify(p,this.publicKey,g)}verifySchnorr(p,g){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(p,this.publicKey.subarray(1,33),g)}tweakFromPublicKey(p){const g=Is(this.publicKey),m=e.xOnlyPointAddTweak(g,p);if(!m||m.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const v=Buffer.from([m.parity===0?2:3]);return i(Buffer.concat([v,m.xOnlyPubkey]),{network:this.network,compressed:this.compressed})}tweakFromPrivateKey(p){const m=this.publicKey[0]===3||this.publicKey[0]===4&&(this.publicKey[64]&1)===1?e.privateNegate(this.privateKey):this.privateKey,v=e.privateAdd(m,p);if(!v)throw new Error("Invalid tweaked private key!");return r(Buffer.from(v),{network:this.network,compressed:this.compressed})}}return{isPoint:t,fromPrivateKey:r,fromPublicKey:i,fromWIF:o,makeRandom:s}}ut.ECPairFactory=ks;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=ut;Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return t.networks}})})(En);class Wt{constructor(t){this.privKey=t}static fromPrivKey(t){return new Wt(I.trim0x(t))}static async fromWalletClient(t){if(!t.account)return I.Err("No account found");try{const r=await t.signTypedData({account:t.account,types:{EIP712Domain:[{name:"name",type:"string"},{name:"version",type:"string"}],Data:[{name:"Message",type:"string"},{name:"Version",type:"string"},{name:"Nonce",type:"uint256"}]},domain:{name:"WBTC GARDEN",version:"1"},primaryType:"Data",message:{Message:"Initialize your account",Version:"1.0.2",Nonce:1n}});return I.Ok(new Wt(I.trim0x(Ne.sha256(r))))}catch(r){return I.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),i=Ne.sha256(be.with0x(r)),o=Ne.sha256(i);return I.Ok({secret:i,secretHash:o})}signMessage(t){const r=En.ECPairFactory(ft),i="Garden.fi"+t.toString(),o=Buffer.from(i,"utf8"),s=Ne.sha256(o),c=Buffer.from(I.trim0x(this.privKey),"hex");if(c.length!==32)throw new Error("Invalid private key length. Expected 32 bytes.");return r.fromPrivateKey(c).sign(Buffer.from(I.trim0x(s),"hex")).toString("hex")}}class Cs{constructor(t){this.quoteUrl=new be.Url("/quote",t)}async getQuote(t,r,i=!1){try{const o=this.quoteUrl.addSearchParams({order_pair:t,amount:r.toString(),exact_out:i.toString()}),s=await I.Fetcher.get(o);return s.error?I.Err(s.error):s.result?I.Ok(s.result):I.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return I.Err("GetQuote:",String(o))}}async getAttestedQuote(t){try{const r=await I.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?I.Err(r.error):r.result?I.Ok(r.result):I.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),I.Err("GetAttestedQuote:",String(r))}}async getStrategies(){try{const t=await I.Fetcher.get(this.quoteUrl.endpoint("/strategies"));if(t.error)return I.Err(t.error);if(!t.result)return I.Err("GetStrategies: Unexpected error, result is undefined");const r={};for(const i of Object.values(t.result)){const o=mn(i.source_chain,i.source_asset.asset,i.dest_chain,i.dest_asset.asset);r[o]={id:i.id,minAmount:i.min_amount,maxAmount:i.max_amount}}return I.Ok(r)}catch(t){return I.Err("GetStrategies:",String(t))}}}exports.BlockNumberFetcher=Oi;exports.EvmRelay=xn;exports.Garden=Ci;exports.OrderActions=se;exports.OrderStatus=te;exports.ParseOrderStatus=Ir;exports.ParseSwapStatus=Dt;exports.Quote=Cs;exports.SecretManager=Wt;exports.SwapStatus=X;exports.TimeLocks=Nt;exports.constructOrderPair=mn;exports.filterDeadlineExpiredOrders=vn;exports.isExpired=Bt;exports.parseAction=Ei;exports.parseActionFromStatus=kr;exports.switchOrAddNetwork=vi;
|