@gardenfi/core 0.2.0-beta.32 → 0.2.0-beta.34

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var li=Object.defineProperty;var hi=(e,t,r)=>t in e?li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var nt=(e,t,r)=>hi(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const O=require("@catalogfi/utils"),J=require("@gardenfi/orderbook"),ge=require("@gardenfi/utils"),Ne=require("viem"),di=require("varuint-bitcoin"),pi=require("tiny-secp256k1"),Nr=require("@catalogfi/wallets"),gn=require("bitcoinjs-lib");function Tr(e){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(e){for(const r in e)if(r!=="default"){const a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Ur=Tr(di),ft=Tr(pi),de=Tr(gn);var gr=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(gr||{}),pe=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(pe||{});function qt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const bi=qt({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}}}),yi=qt({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}),_i=qt({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}}}),gi=qt({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 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 wi(e){return Buffer.concat([Uint8Array.from([192]),mi(e)])}function mi(e){const t=Ur.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Ur.encode(e.length,r),Buffer.concat([r,e])}function vi(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),xi=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return ft.isPoint(t)}catch{return!1}},Ei={ethereum:_i,ethereum_arbitrum:bi,ethereum_sepolia:gi,arbitrum_sepolia:yi,ethereum_localnet:J.EthereumLocalnet,arbitrum_localnet:J.ArbitrumLocalnet},Bi=async(e,t)=>{var a;const r=Ei[e];if(r)try{if(r.id===((a=t.chain)==null?void 0:a.id))return O.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 O.Ok({message:"Switched chain",walletClient:o})}catch(o){if(Ri(o))try{await t.addChain({chain:r});const s=Ne.createWalletClient({account:t.account,chain:r,transport:Ne.custom(window.ethereum)});return O.Ok({message:"Added network",walletClient:s})}catch{return O.Err("Failed to add network")}else return O.Err("Failed to switch network")}else return O.Err("Chain not supported")},Ri=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902;var ae=(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))(ae||{}),ee=(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))(ee||{});const wn=(e,t,r)=>{const a=Ft(e.source_swap,t),o=Ft(e.destination_swap,r);if(a===ee.RedeemDetected)return ae.CounterPartyRedeemDetected;if(a===ee.Redeemed)return ae.CounterPartyRedeemed;if(o===ee.RedeemDetected)return ae.RedeemDetected;if(o===ee.Redeemed)return ae.Redeemed;if(o===ee.RefundDetected)return ae.CounterPartyRefundDetected;if(o===ee.Refunded)return ae.CounterPartyRefunded;if(a===ee.RefundDetected)return ae.RefundDetected;if(a===ee.Refunded)return ae.Refunded;if(o===ee.Expired)return ae.CounterPartySwapExpired;if(a===ee.Expired)return ae.Expired;const s=Number(e.create_order.additional_data.deadline)*1e3;return o===ee.InitiateDetected?ae.CounterPartyInitiateDetected:o===ee.Initiated?ae.CounterPartyInitiated:Dr(s,1)?ae.Expired:a===ee.InitiateDetected?ae.InitiateDetected:Dr(s,12)?ae.Expired:a===ee.Initiated?ae.Initiated:ae.Matched},Ft=(e,t)=>{if(e.redeem_tx_hash)return e.redeem_block_number?ee.Redeemed:ee.RedeemDetected;if(e.refund_tx_hash)return e.refund_block_number?ee.Refunded:ee.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return ee.Expired}return e.initiate_tx_hash?e.initiate_block_number?ee.Initiated:ee.InitiateDetected:ee.Idle},mn=(e,t,r)=>{switch(wn(e,t,r)){case ae.Matched:return pe.Initiate;case ae.CounterPartyInitiated:return pe.Redeem;case ae.Expired:return pe.Refund;default:return pe.Idle}},Dr=(e,t=0)=>{const r=Date.now(),a=e*1e3+t*36e5;return r>=a},Si=[{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 vn{constructor(t,r,a){this.url=new ge.Url("/relayer",r),this.auth=a,this.order=t}async init(t,r){if(!t.account)return O.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return O.Err("Account address and order initiator mismatch");if(!r){const m=await ge.fetchEVMBlockNumber(t);if(m.error)return O.Err(m.error);r=m.val}if(Ft(this.order.source_swap,r)!==ee.Idle)return O.Err("Invalid swap status");const{create_order:o,source_swap:s}=this.order;if(!s.amount||!s.redeemer||!o.timelock||!o.secret_hash)return O.Err("Invalid order");const c=ge.with0x(o.secret_hash),u=BigInt(o.timelock),p=ge.with0x(s.redeemer),w=BigInt(s.amount);try{const m=await this.auth.getToken();if(m.error)return O.Err(m.error);const v=Ne.getContract({address:ge.with0x(this.order.source_swap.asset),abi:Si,client:t}),T=await v.read.token(),C=await ge.checkAllowanceAndApprove(Number(w),T,this.order.source_swap.asset,t);if(C.error)return O.Err(C.error);const R=await v.read.eip712Domain(),k=await t.signTypedData({account:t.account,domain:{name:R[1],version:R[2],chainId:Number(R[3]),verifyingContract:R[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:w,secretHash:c}}),A=await O.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:o.create_id,signature:k,perform_on:"Source"}),headers:{Authorization:ge.Authorization(m.val),"Content-Type":"application/json"}});return A.error?O.Err(A.error):A.result?O.Ok(A.result):O.Err("Init: No result found")}catch(m){return console.log("init error :",m),O.Err(String(m))}}async redeem(t,r){try{const a=await this.auth.getToken();if(a.error)return O.Err(a.error);const o=await O.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:O.trim0x(r),perform_on:"Destination"}),headers:{Authorization:ge.Authorization(a.val),"Content-Type":"application/json"}});return o.error?O.Err(o.error):o.result?O.Ok(o.result):O.Err("Redeem: No result found")}catch(a){return O.Err(String(a))}}}const Ai=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Ti=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),Ii=Buffer.concat([Ai,Ti]),ki=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),$r={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function Ci(){const e=gn.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=ft.pointMultiply(Buffer.concat([Buffer.from("04","hex"),Ii]),e);if(!t)throw new Error($r.failedToCreateInternalPubkey);const r=ft.pointAdd(ki,t);if(!r)throw new Error($r.failedToCreateInternalPubkey);return wr(Buffer.from(r))}const ye={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"},Ot=192;de.initEccLib(ft);class Nt{constructor(t,r,a,o,s,c,u,p){this.secretHash=a,this.redeemerPubkey=o,this.initiatorPubkey=s,this.expiry=c,this.signer=t,this.network=u,this.internalPubkey=Ci(),this.initiateAmount=r,this.utxoHashes=p}static async from(t,r,a,o,s,c,u){a=a.startsWith("0x")?a.slice(2):a,it(a.length===64,ye.secretHashLenMismatch),it(o.length===64||o.length===66,`initiator ${ye.pubkeyLenMismatch}`),it(s.length===64||s.length===66,`redeemer ${ye.pubkeyLenMismatch}`),it(c>0,ye.zeroOrNegativeExpiry);const p=await t.getNetwork();return new Nt(t,r,a,wr(s).toString("hex"),wr(o).toString("hex"),c,p,u)}address(){const{address:t}=de.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!t)throw new Error(ye.htlcAddressGenerationFailed);return t}id(){return this.address()}async _buildRawTx(t,r){const a=new de.Transaction;a.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 w=await s.getTransaction(p);for(let m=0;m<w.vout.length;m++){const v=w.vout[m];v.scriptpubkey_address===o&&c.push({txid:w.txid,vout:m,value:v.value,status:{confirmed:!1}})}}else c=await s.getUTXOs(o);const u=c.reduce((p,w)=>p+w.value,0);if(u===0)throw new Error(`${o} ${ye.notFunded}`);for(let p=0;p<c.length;p++)a.addInput(Buffer.from(c[p].txid,"hex").reverse(),c[p].vout);return r??(r=await s.suggestFee(o,u,Nr.Urgency.MEDIUM)),a.addOutput(de.address.toOutputScript(t,this.network),u-r),{tx:a,usedUtxos:c}}async buildRawTx(t){return await this._buildRawTx(await this.signer.getAddress(),t)}getOutputScript(){return de.address.toOutputScript(this.address(),this.network)}async init(t){return t??(t=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,Nr.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,t)}async instantRefund(t,r){it(t.length>0,ye.noCounterpartySigs);const{tx:a,usedUtxos:o}=await this.buildRawTx(r);for(const v of o)if(!t.find(T=>T.utxo===v.txid))throw new Error(ye.counterPartySigNotFound(v.txid));const s=this.getOutputScript(),c=de.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),p=o.map(v=>v.value),w=rr(s,o.length);for(let v=0;v<a.ins.length;v++){const T=a.hashForWitnessV1(v,w,p,c,u);if(!ft.verifySchnorr(T,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[v].sig,"hex")))throw new Error(ye.invalidCounterpartySigForUTXO(t[v].utxo));const C=await this.signer.signSchnorr(T),R=Buffer.from(a.ins[v].hash).reverse().toString("hex"),k=t.find(A=>A.utxo===R);if(!k)throw new Error(ye.counterPartySigNotFound(R));a.setWitness(v,[Buffer.from(k.sig,"hex"),C,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(a.toHex())}async redeem(t,r,a){it(de.crypto.sha256(Buffer.from(t,"hex")).toString("hex")===this.secretHash,ye.secretMismatch);const{tx:o,usedUtxos:s}=await this._buildRawTx(r??await this.signer.getAddress(),a),c=this.leafHash(1),u=s.map(v=>v.value),p=rr(this.getOutputScript(),s.length),w=de.Transaction.SIGHASH_DEFAULT;for(let v=0;v<o.ins.length;v++){const T=o.hashForWitnessV1(v,p,u,w,c),C=await this.signer.signSchnorr(T);o.setWitness(v,[C,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(o.toHex())}async refund(t,r){const{tx:a,usedUtxos:o}=await this._buildRawTx(t??await this.signer.getAddress(),r),[s,c]=await this.canRefund(o);if(!s)throw new Error(ye.htlcNotExpired(c));const u=this.leafHash(0),p=o.map(T=>T.value),w=rr(this.getOutputScript(),o.length),m=de.Transaction.SIGHASH_DEFAULT;for(let T=0;T<a.ins.length;T++){a.ins[T].sequence=this.expiry;const C=a.hashForWitnessV1(T,w,p,m,u),R=await this.signer.signSchnorr(C);a.setWitness(T,[R,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(a.toHex())}async canRefund(t){const a=await(await this.signer.getProvider()).getLatestTip();for(const o of t){let s=0;if(o.status.confirmed&&o.status.block_height+this.expiry>a?s=o.status.block_height+this.expiry-a+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(ye.invalidLeaf)}const a=de.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:Ot}});if(!a.witness)throw new Error(ye.controlBlockGenerationFailed);return a.witness[a.witness.length-1]}leafHash(t){let r=this.redeemLeaf();return t===0&&(r=this.refundLeaf()),t===2&&(r=this.instantRefundLeaf()),de.crypto.taggedHash("TapLeaf",wi(r))}refundLeaf(){return de.script.fromASM(`
1
+ "use strict";var li=Object.defineProperty;var hi=(e,t,r)=>t in e?li(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var nt=(e,t,r)=>hi(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=require("@catalogfi/utils"),J=require("@gardenfi/orderbook"),ge=require("@gardenfi/utils"),Ne=require("viem"),di=require("varuint-bitcoin"),pi=require("tiny-secp256k1"),Nr=require("@catalogfi/wallets"),gn=require("bitcoinjs-lib"),bi=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 a=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,a.get?a:{enumerable:!0,get:()=>e[r]})}}return t.default=e,Object.freeze(t)}const Ur=Tr(di),ft=Tr(pi),de=Tr(gn);var gr=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(gr||{}),pe=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(pe||{});function qt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const yi=qt({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}}}),_i=qt({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}),gi=qt({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}}}),wi=qt({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 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 mi(e){return Buffer.concat([Uint8Array.from([192]),vi(e)])}function vi(e){const t=Ur.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Ur.encode(e.length,r),Buffer.concat([r,e])}function xi(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),Ei=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return ft.isPoint(t)}catch{return!1}},Bi={ethereum:gi,ethereum_arbitrum:yi,ethereum_sepolia:wi,arbitrum_sepolia:_i,ethereum_localnet:J.EthereumLocalnet,arbitrum_localnet:J.ArbitrumLocalnet},Ri=async(e,t)=>{var a;const r=Bi[e];if(r)try{if(r.id===((a=t.chain)==null?void 0:a.id))return C.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 C.Ok({message:"Switched chain",walletClient:o})}catch(o){if(Si(o))try{await t.addChain({chain:r});const s=Ne.createWalletClient({account:t.account,chain:r,transport:Ne.custom(window.ethereum)});return C.Ok({message:"Added network",walletClient:s})}catch{return C.Err("Failed to add network")}else return C.Err("Failed to switch network")}else return C.Err("Chain not supported")},Si=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902;var ae=(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))(ae||{}),ee=(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))(ee||{});const wn=(e,t,r)=>{const a=Ft(e.source_swap,t),o=Ft(e.destination_swap,r);if(a===ee.RedeemDetected)return ae.CounterPartyRedeemDetected;if(a===ee.Redeemed)return ae.CounterPartyRedeemed;if(o===ee.RedeemDetected)return ae.RedeemDetected;if(o===ee.Redeemed)return ae.Redeemed;if(o===ee.RefundDetected)return ae.CounterPartyRefundDetected;if(o===ee.Refunded)return ae.CounterPartyRefunded;if(a===ee.RefundDetected)return ae.RefundDetected;if(a===ee.Refunded)return ae.Refunded;if(o===ee.Expired)return ae.CounterPartySwapExpired;if(a===ee.Expired)return ae.Expired;const s=Number(e.create_order.additional_data.deadline)*1e3;return o===ee.InitiateDetected?ae.CounterPartyInitiateDetected:o===ee.Initiated?ae.CounterPartyInitiated:Dr(s,1)?ae.Expired:a===ee.InitiateDetected?ae.InitiateDetected:Dr(s,12)?ae.Expired:a===ee.Initiated?ae.Initiated:ae.Matched},Ft=(e,t)=>{if(e.redeem_tx_hash)return e.redeem_block_number?ee.Redeemed:ee.RedeemDetected;if(e.refund_tx_hash)return e.refund_block_number?ee.Refunded:ee.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return ee.Expired}return e.initiate_tx_hash?e.initiate_block_number?ee.Initiated:ee.InitiateDetected:ee.Idle},mn=(e,t,r)=>{const a=wn(e,t,r);switch(console.log("orderId: ",e.create_order.create_id," orderStatus :",a),a){case ae.Matched:return pe.Initiate;case ae.CounterPartyInitiated:return pe.Redeem;case ae.Expired:return pe.Refund;default:return pe.Idle}},Dr=(e,t=0)=>{const r=Date.now(),a=e*1e3+t*36e5;return r>=a},Ai=[{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 vn{constructor(t,r,a){this.url=new ge.Url("/relayer",r),this.auth=a,this.order=t}async init(t,r){if(!t.account)return C.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return C.Err("Account address and order initiator mismatch");if(!r){const m=await ge.fetchEVMBlockNumber(t);if(m.error)return C.Err(m.error);r=m.val}if(Ft(this.order.source_swap,r)!==ee.Idle)return C.Err("Invalid swap status");const{create_order:o,source_swap:s}=this.order;if(!s.amount||!s.redeemer||!o.timelock||!o.secret_hash)return C.Err("Invalid order");const c=ge.with0x(o.secret_hash),u=BigInt(o.timelock),p=ge.with0x(s.redeemer),w=BigInt(s.amount);try{const m=await this.auth.getToken();if(m.error)return C.Err(m.error);const v=Ne.getContract({address:ge.with0x(this.order.source_swap.asset),abi:Ai,client:t}),T=await v.read.token(),O=await ge.checkAllowanceAndApprove(Number(w),T,this.order.source_swap.asset,t);if(O.error)return C.Err(O.error);const R=await v.read.eip712Domain(),k=await t.signTypedData({account:t.account,domain:{name:R[1],version:R[2],chainId:Number(R[3]),verifyingContract:R[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:w,secretHash:c}}),A=await C.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:o.create_id,signature:k,perform_on:"Source"}),headers:{Authorization:ge.Authorization(m.val),"Content-Type":"application/json"}});return A.error?C.Err(A.error):A.result?C.Ok(A.result):C.Err("Init: No result found")}catch(m){return console.log("init error :",m),C.Err(String(m))}}async redeem(t,r){try{const a=await this.auth.getToken();if(a.error)return C.Err(a.error);const o=await C.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:C.trim0x(r),perform_on:"Destination"}),headers:{Authorization:ge.Authorization(a.val),"Content-Type":"application/json"}});return o.error?C.Err(o.error):o.result?C.Ok(o.result):C.Err("Redeem: No result found")}catch(a){return C.Err(String(a))}}}const Ti=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Ii=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),ki=Buffer.concat([Ti,Ii]),Ci=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),$r={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function Oi(){const e=gn.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=ft.pointMultiply(Buffer.concat([Buffer.from("04","hex"),ki]),e);if(!t)throw new Error($r.failedToCreateInternalPubkey);const r=ft.pointAdd(Ci,t);if(!r)throw new Error($r.failedToCreateInternalPubkey);return wr(Buffer.from(r))}const ye={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"},Ot=192;de.initEccLib(ft);class Nt{constructor(t,r,a,o,s,c,u,p){this.secretHash=a,this.redeemerPubkey=o,this.initiatorPubkey=s,this.expiry=c,this.signer=t,this.network=u,this.internalPubkey=Oi(),this.initiateAmount=r,this.utxoHashes=p}static async from(t,r,a,o,s,c,u){a=a.startsWith("0x")?a.slice(2):a,it(a.length===64,ye.secretHashLenMismatch),it(o.length===64||o.length===66,`initiator ${ye.pubkeyLenMismatch}`),it(s.length===64||s.length===66,`redeemer ${ye.pubkeyLenMismatch}`),it(c>0,ye.zeroOrNegativeExpiry);const p=await t.getNetwork();return new Nt(t,r,a,wr(s).toString("hex"),wr(o).toString("hex"),c,p,u)}address(){const{address:t}=de.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves()});if(!t)throw new Error(ye.htlcAddressGenerationFailed);return t}id(){return this.address()}async _buildRawTx(t,r){const a=new de.Transaction;a.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 w=await s.getTransaction(p);for(let m=0;m<w.vout.length;m++){const v=w.vout[m];v.scriptpubkey_address===o&&c.push({txid:w.txid,vout:m,value:v.value,status:{confirmed:!1}})}}else c=await s.getUTXOs(o);const u=c.reduce((p,w)=>p+w.value,0);if(u===0)throw new Error(`${o} ${ye.notFunded}`);for(let p=0;p<c.length;p++)a.addInput(Buffer.from(c[p].txid,"hex").reverse(),c[p].vout);return r??(r=await s.suggestFee(o,u,Nr.Urgency.MEDIUM)),a.addOutput(de.address.toOutputScript(t,this.network),u-r),{tx:a,usedUtxos:c}}async buildRawTx(t){return await this._buildRawTx(await this.signer.getAddress(),t)}getOutputScript(){return de.address.toOutputScript(this.address(),this.network)}async init(t){return t??(t=await(await this.signer.getProvider()).suggestFee(await this.signer.getAddress(),this.initiateAmount,Nr.Urgency.MEDIUM)),await this.signer.send(this.address(),this.initiateAmount,t)}async instantRefund(t,r){it(t.length>0,ye.noCounterpartySigs);const{tx:a,usedUtxos:o}=await this.buildRawTx(r);for(const v of o)if(!t.find(T=>T.utxo===v.txid))throw new Error(ye.counterPartySigNotFound(v.txid));const s=this.getOutputScript(),c=de.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),p=o.map(v=>v.value),w=rr(s,o.length);for(let v=0;v<a.ins.length;v++){const T=a.hashForWitnessV1(v,w,p,c,u);if(!ft.verifySchnorr(T,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[v].sig,"hex")))throw new Error(ye.invalidCounterpartySigForUTXO(t[v].utxo));const O=await this.signer.signSchnorr(T),R=Buffer.from(a.ins[v].hash).reverse().toString("hex"),k=t.find(A=>A.utxo===R);if(!k)throw new Error(ye.counterPartySigNotFound(R));a.setWitness(v,[Buffer.from(k.sig,"hex"),O,this.instantRefundLeaf(),this.generateControlBlockFor(2)])}return await(await this.signer.getProvider()).broadcast(a.toHex())}async redeem(t,r,a){it(de.crypto.sha256(Buffer.from(t,"hex")).toString("hex")===this.secretHash,ye.secretMismatch);const{tx:o,usedUtxos:s}=await this._buildRawTx(r??await this.signer.getAddress(),a),c=this.leafHash(1),u=s.map(v=>v.value),p=rr(this.getOutputScript(),s.length),w=de.Transaction.SIGHASH_DEFAULT;for(let v=0;v<o.ins.length;v++){const T=o.hashForWitnessV1(v,p,u,w,c),O=await this.signer.signSchnorr(T);o.setWitness(v,[O,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(o.toHex())}async refund(t,r){const{tx:a,usedUtxos:o}=await this._buildRawTx(t??await this.signer.getAddress(),r),[s,c]=await this.canRefund(o);if(!s)throw new Error(ye.htlcNotExpired(c));const u=this.leafHash(0),p=o.map(T=>T.value),w=rr(this.getOutputScript(),o.length),m=de.Transaction.SIGHASH_DEFAULT;for(let T=0;T<a.ins.length;T++){a.ins[T].sequence=this.expiry;const O=a.hashForWitnessV1(T,w,p,m,u),R=await this.signer.signSchnorr(O);a.setWitness(T,[R,this.refundLeaf(),this.generateControlBlockFor(0)])}return await(await this.signer.getProvider()).broadcast(a.toHex())}async canRefund(t){const a=await(await this.signer.getProvider()).getLatestTip();for(const o of t){let s=0;if(o.status.confirmed&&o.status.block_height+this.expiry>a?s=o.status.block_height+this.expiry-a+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(ye.invalidLeaf)}const a=de.payments.p2tr({internalPubkey:this.internalPubkey,network:this.network,scriptTree:this.leaves(),redeem:{output:r,redeemVersion:Ot}});if(!a.witness)throw new Error(ye.controlBlockGenerationFailed);return a.witness[a.witness.length-1]}leafHash(t){let r=this.redeemLeaf();return t===0&&(r=this.refundLeaf()),t===2&&(r=this.instantRefundLeaf()),de.crypto.taggedHash("TapLeaf",mi(r))}refundLeaf(){return de.script.fromASM(`
2
2
  ${de.script.number.encode(this.expiry).toString("hex")}
3
3
  OP_CHECKSEQUENCEVERIFY
4
4
  OP_DROP
@@ -17,12 +17,12 @@
17
17
  OP_CHECKSIGADD
18
18
  OP_2
19
19
  OP_NUMEQUAL
20
- `.trim().replace(/\s+/g," "))}leaves(){return[{version:Ot,output:this.redeemLeaf()},[{version:Ot,output:this.refundLeaf()},{version:Ot,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),a=this.leafHash(2),o=this.leafHash(0);switch(t){case 1:{const s=vi(o,a);return[de.crypto.taggedHash("TapBranch",Buffer.concat(s))]}case 0:return[a,r];case 2:return[o,r];default:throw new Error(ye.invalidLeaf)}}}function rr(e,t){const r=[];for(let a=0;a<t;a++)r.push(e);return r}class Oi{constructor(){this.cache={}}set(t,r,a,o){const s={txHash:a,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 Li{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.pendingOrdersCount=0,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 Oi,!t.wallets.evmWallet.account)throw new Error("Account not found in evmWallet");this.evmAddress=t.wallets.evmWallet.account.address}getPendingOrderCount(){return this.pendingOrdersCount}setUseRelay(t){this.useRelay=t}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return O.Err(r.error);const{sendAddress:a,receiveAddress:o,timelock:s}=r.val,c=await this.orderBook.getOrdersCount(this.evmAddress);if(c.error)return O.Err(c.error);const u=c.val+1,p=this.secretManager.generateSecret(u);if(p.error)return O.Err(p.error);const{strategyId:w,btcAddress:m}=t.additionalData,v={strategy_id:w,...m&&{bitcoin_optional_recipient:m}},T={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:a,initiator_destination_address:o,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:u.toString(),timelock:s,secret_hash:O.trim0x(p.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:v},C=await this.quote.getAttestedQuote(T);if(C.error)return O.Err(C.error);const R=await this.orderBook.createOrder(C.val);if(R.error)return O.Err(R.error);const k=await this.pollOrder(R.val);return k.error?O.Err(k.error):O.Ok(k.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return O.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 O.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 O.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return O.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return O.Err(r.error);const a=await this.getAddresses(t.toAsset.chain);if(a.error)return O.Err(a.error);const o=this.validateAmount(t.sendAmount);if(o.error)return O.Err(o.error);const s=this.validateAmount(t.receiveAmount);if(s.error)return O.Err(s.error);if(o<s)return O.Err("Send amount should be greater than receive amount");const c=this.getTimelock(t.fromAsset.chain);return c?O.Ok({sendAddress:r.val,receiveAddress:a.val,timelock:t.timelock??c}):O.Err("Unsupported chain for timelock")}async getAddresses(t){var a;switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return this.wallets.evmWallet.account?O.Ok(this.wallets.evmWallet.account.address):O.Err("EVM Wallet not found");case J.BlockchainType.Bitcoin:{const o=await((a=this.wallets.btcWallet)==null?void 0:a.getPublicKey());return!o||!xi(o)?O.Err("Invalid btc public key"):O.Ok(yt(o))}default:return O.Err("Unsupported chain")}}validateAmount(t){const r=BigInt(t);return t==null||r<=0n||t.includes(".")?O.Err("Invalid amount ",t):O.Ok(r)}getTimelock(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return gr.evm;case J.BlockchainType.Bitcoin:return gr.btc;default:return}}async pollOrder(t){let r=await this.orderBook.getOrder(t,!0),a=0;for(;a<this.getOrderThreshold;){if(await ge.sleep(1e3),a++,r.error){if(!r.error.includes("result is undefined"))return O.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return O.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return O.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=>{this.pendingOrdersCount=r.data.length,this.emit("onPendingOrdersChanged",r.data);for(let a=0;a<r.data.length;a++){const o=r.data[a],s=o.source_swap.chain,c=o.destination_swap.chain;this.emit("log",o.create_order.create_id,"executing order");const u=this.getWallet(s),p=this.getWallet(c);if(u.error||p.error||!u.val||!p.val){this.emit("error",o,"Source or Destination Wallet not found while executing order");return}const w=await this.fetchCurrentBlockNumbers(o,{source:u.val,destination:p.val});if(w.error){this.emit("error",o,"Error while fetching CurrentBlockNumbers: "+w.error);return}switch(mn(o,w.val.source,w.val.destination)){case pe.Redeem:{const v=this.secretManager.generateSecret(Number(o.create_order.nonce));if(v.error){this.emit("error",o,v.error);return}switch(J.getBlockchainType(o.destination_swap.chain)){case J.BlockchainType.EVM:{await this.evmRedeem(o,v.val.secret);break}case J.BlockchainType.Bitcoin:{await this.btcRedeem(p.val,o,v.val.secret);break}default:this.emit("error",o,"Unsupported chain: "+o.destination_swap.chain)}break}case pe.Refund:{switch(J.getBlockchainType(o.source_swap.chain)){case J.BlockchainType.EVM:{this.emit("error",o,"EVM refund is automatically done by relay service");break}case J.BlockchainType.Bitcoin:{await this.btcRefund(u.val,o);break}default:this.emit("error",o,"Unsupported chain: "+o.source_swap.chain)}break}}}},{per_page:500},!0)}async evmRedeem(t,r){this.emit("log",t.create_order.create_id,"executing evm redeem");const a=this.orderExecutorCache.get(t,pe.Redeem);if(console.log("cache inside evm redeem :",a),a){this.emit("log",t.create_order.create_id,"already redeemed");return}const s=await new vn(t,this.orderbookUrl,this.auth).redeem(t.create_order.create_id,r);if(s.error){this.emit("error",t,s.error);return}this.emit("success",t,pe.Redeem,s.val),this.orderExecutorCache.set(t,pe.Redeem,s.val)}async btcRedeem(t,r,a){var c;const o=this.orderExecutorCache.get(r,pe.Redeem);console.log("cache inside btc redeem :",o);let s=!1;if(o)if(o.btcRedeemUTXO&&o.btcRedeemUTXO!==r.destination_swap.initiate_tx_hash)s=!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}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const p=await(await Nt.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,s?[r.destination_swap.initiate_tx_hash]:[])).redeem(O.trim0x(a),(c=r.create_order.additional_data)==null?void 0:c.bitcoin_optional_recipient);this.emit("success",r,pe.Redeem,p),this.orderExecutorCache.set(r,pe.Redeem,p,r.destination_swap.initiate_tx_hash)}catch(u){this.emit("error",r,"Failed btc redeem: "+u)}}async btcRefund(t,r){var a;if(!this.orderExecutorCache.get(r,pe.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const s=await(await Nt.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((a=r.create_order.additional_data)==null?void 0:a.bitcoin_optional_recipient);this.emit("success",r,pe.Refund,s),this.orderExecutorCache.set(r,pe.Refund,s)}catch(o){this.emit("error",r,"Failed btc refund: "+o)}}}getWallet(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return O.Ok(this.wallets.evmWallet);case J.BlockchainType.Bitcoin:return O.Ok(this.wallets.btcWallet);default:return O.Err("Unsupported chain for wallet")}}on(t,r){const a=this.eventListeners.get(t)??[];a.push(r),this.eventListeners.set(t,a)}off(t,r){const a=this.eventListeners.get(t)??[],o=a.indexOf(r);o!==-1&&a.splice(o,1)}async fetchCurrentBlockNumbers(t,r){if(!r||!r.source||!r.destination)return O.Err("Provide wallets to fetch the current block number");const a=J.isBitcoin(t.source_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.source.getProvider()):await ge.fetchEVMBlockNumber(r.source);if(a.error)return O.Err(a.error);const o=J.isBitcoin(t.destination_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.destination.getProvider()):await ge.fetchEVMBlockNumber(r.destination);return o.error?O.Err(o.error):O.Ok({source:a.val,destination:o.val})}}var Ge=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Mi(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function a(){return this instanceof a?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(a){var o=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,o.get?o:{enumerable:!0,get:function(){return e[a]}})}),r}var xn={},ut={},ct={};Object.defineProperty(ct,"__esModule",{value:!0});ct.testnet=ct.bitcoin=void 0;ct.bitcoin={messagePrefix:`Bitcoin Signed Message:
20
+ `.trim().replace(/\s+/g," "))}leaves(){return[{version:Ot,output:this.redeemLeaf()},[{version:Ot,output:this.refundLeaf()},{version:Ot,output:this.instantRefundLeaf()}]]}generateMerkleProofFor(t){const r=this.leafHash(1),a=this.leafHash(2),o=this.leafHash(0);switch(t){case 1:{const s=xi(o,a);return[de.crypto.taggedHash("TapBranch",Buffer.concat(s))]}case 0:return[a,r];case 2:return[o,r];default:throw new Error(ye.invalidLeaf)}}}function rr(e,t){const r=[];for(let a=0;a<t;a++)r.push(e);return r}class Li{constructor(){this.cache={}}set(t,r,a,o){const s={txHash:a,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 Mi{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.pendingOrdersCount=0,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 Li,!t.wallets.evmWallet.account)throw new Error("Account not found in evmWallet");this.evmAddress=t.wallets.evmWallet.account.address}getPendingOrderCount(){return this.pendingOrdersCount}setUseRelay(t){this.useRelay=t}async swap(t){const r=await this.validateAndFillParams(t);if(r.error)return C.Err(r.error);const{sendAddress:a,receiveAddress:o,timelock:s}=r.val,c=await this.orderBook.getOrdersCount(this.evmAddress);if(c.error)return C.Err(c.error);const u=c.val+1,p=this.secretManager.generateSecret(u);if(p.error)return C.Err(p.error);const{strategyId:w,btcAddress:m}=t.additionalData,v={strategy_id:w,...m&&{bitcoin_optional_recipient:m}},T={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:a,initiator_destination_address:o,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:u.toString(),timelock:s,secret_hash:C.trim0x(p.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:v},O=await this.quote.getAttestedQuote(T);if(O.error)return C.Err(O.error);const R=await this.orderBook.createOrder(O.val);if(R.error)return C.Err(R.error);const k=await this.pollOrder(R.val);return k.error?C.Err(k.error):C.Ok(k.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return C.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 C.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 C.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return C.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return C.Err(r.error);const a=await this.getAddresses(t.toAsset.chain);if(a.error)return C.Err(a.error);const o=this.validateAmount(t.sendAmount);if(o.error)return C.Err(o.error);const s=this.validateAmount(t.receiveAmount);if(s.error)return C.Err(s.error);if(o<s)return C.Err("Send amount should be greater than receive amount");const c=this.getTimelock(t.fromAsset.chain);return c?C.Ok({sendAddress:r.val,receiveAddress:a.val,timelock:t.timelock??c}):C.Err("Unsupported chain for timelock")}async getAddresses(t){var a;switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return this.wallets.evmWallet.account?C.Ok(this.wallets.evmWallet.account.address):C.Err("EVM Wallet not found");case J.BlockchainType.Bitcoin:{const o=await((a=this.wallets.btcWallet)==null?void 0:a.getPublicKey());return!o||!Ei(o)?C.Err("Invalid btc public key"):C.Ok(yt(o))}default:return C.Err("Unsupported chain")}}validateAmount(t){if(t==null||t.includes("."))return C.Err("Invalid amount ",t);const r=new bi(t);return!r.isInteger()||r.isNaN()||r.lt(0)||r.isLessThanOrEqualTo(0)?C.Err("Invalid amount ",t):C.Ok(r)}getTimelock(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return gr.evm;case J.BlockchainType.Bitcoin:return gr.btc;default:return}}async pollOrder(t){let r=await this.orderBook.getOrder(t,!0),a=0;for(;a<this.getOrderThreshold;){if(await ge.sleep(1e3),a++,r.error){if(!r.error.includes("result is undefined"))return C.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return C.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return C.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=>{this.pendingOrdersCount=r.data.length,this.emit("onPendingOrdersChanged",r.data);for(let a=0;a<r.data.length;a++){const o=r.data[a],s=o.source_swap.chain,c=o.destination_swap.chain,u=this.getWallet(s),p=this.getWallet(c);if(u.error||p.error||!u.val||!p.val){this.emit("error",o,"Source or Destination Wallet not found while executing order");return}const w=await this.fetchCurrentBlockNumbers(o,{source:u.val,destination:p.val});if(w.error){this.emit("error",o,"Error while fetching CurrentBlockNumbers: "+w.error);return}const m=mn(o,w.val.source,w.val.destination);switch(this.emit("log",o.create_order.create_id,`executing order, action: ${m}`),m){case pe.Redeem:{const v=this.secretManager.generateSecret(Number(o.create_order.nonce));if(v.error){this.emit("error",o,v.error);return}switch(J.getBlockchainType(o.destination_swap.chain)){case J.BlockchainType.EVM:{await this.evmRedeem(o,v.val.secret);break}case J.BlockchainType.Bitcoin:{await this.btcRedeem(p.val,o,v.val.secret);break}default:this.emit("error",o,"Unsupported chain: "+o.destination_swap.chain)}break}case pe.Refund:{switch(J.getBlockchainType(o.source_swap.chain)){case J.BlockchainType.EVM:{this.emit("error",o,"EVM refund is automatically done by relay service");break}case J.BlockchainType.Bitcoin:{await this.btcRefund(u.val,o);break}default:this.emit("error",o,"Unsupported chain: "+o.source_swap.chain)}break}}}},{per_page:500},!0)}async evmRedeem(t,r){this.emit("log",t.create_order.create_id,"executing evm redeem");const a=this.orderExecutorCache.get(t,pe.Redeem);if(console.log("cache inside evm redeem :",a),a){this.emit("log",t.create_order.create_id,"already redeemed");return}const s=await new vn(t,this.orderbookUrl,this.auth).redeem(t.create_order.create_id,r);if(s.error){this.emit("error",t,s.error);return}this.emit("success",t,pe.Redeem,s.val),this.orderExecutorCache.set(t,pe.Redeem,s.val)}async btcRedeem(t,r,a){var c;const o=this.orderExecutorCache.get(r,pe.Redeem);console.log("cache inside btc redeem :",o);let s=!1;if(o)if(o.btcRedeemUTXO&&o.btcRedeemUTXO!==r.destination_swap.initiate_tx_hash)s=!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}this.emit("log",r.create_order.create_id,"executing btc redeem");try{const p=await(await Nt.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,s?[r.destination_swap.initiate_tx_hash]:[])).redeem(C.trim0x(a),(c=r.create_order.additional_data)==null?void 0:c.bitcoin_optional_recipient);this.emit("success",r,pe.Redeem,p),this.orderExecutorCache.set(r,pe.Redeem,p,r.destination_swap.initiate_tx_hash)}catch(u){this.emit("error",r,"Failed btc redeem: "+u)}}async btcRefund(t,r){var a;if(!this.orderExecutorCache.get(r,pe.Refund)){this.emit("log",r.create_order.create_id,"executing btc refund");try{const s=await(await Nt.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((a=r.create_order.additional_data)==null?void 0:a.bitcoin_optional_recipient);this.emit("success",r,pe.Refund,s),this.orderExecutorCache.set(r,pe.Refund,s)}catch(o){this.emit("error",r,"Failed btc refund: "+o)}}}getWallet(t){switch(J.getBlockchainType(t)){case J.BlockchainType.EVM:return C.Ok(this.wallets.evmWallet);case J.BlockchainType.Bitcoin:return C.Ok(this.wallets.btcWallet);default:return C.Err("Unsupported chain for wallet")}}on(t,r){const a=this.eventListeners.get(t)??[];a.push(r),this.eventListeners.set(t,a)}off(t,r){const a=this.eventListeners.get(t)??[],o=a.indexOf(r);o!==-1&&a.splice(o,1)}async fetchCurrentBlockNumbers(t,r){if(!r||!r.source||!r.destination)return C.Err("Provide wallets to fetch the current block number");const a=J.isBitcoin(t.source_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.source.getProvider()):await ge.fetchEVMBlockNumber(r.source);if(a.error)return C.Err(a.error);const o=J.isBitcoin(t.destination_swap.chain)?await ge.fetchBitcoinBlockNumber(await r.destination.getProvider()):await ge.fetchEVMBlockNumber(r.destination);return o.error?C.Err(o.error):C.Ok({source:a.val,destination:o.val})}}var Ge=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Pi(e){if(e.__esModule)return e;var t=e.default;if(typeof t=="function"){var r=function a(){return this instanceof a?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(a){var o=Object.getOwnPropertyDescriptor(e,a);Object.defineProperty(r,a,o.get?o:{enumerable:!0,get:function(){return e[a]}})}),r}var xn={},ut={},ct={};Object.defineProperty(ct,"__esModule",{value:!0});ct.testnet=ct.bitcoin=void 0;ct.bitcoin={messagePrefix:`Bitcoin Signed Message:
21
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 En={},Bt={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}};Bt.Null=Bt.Nil;for(var Hr in Bt)Bt[Hr].toJSON=(function(e){return e}).bind(null,Hr);var Ir=Bt,Xe=Ir;function Bn(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function kr(e){return Xe.Nil(e)?"":Bn(e.constructor)}function Pi(e){return Xe.Function(e)?"":Xe.String(e)?JSON.stringify(e):e&&Xe.Object(e)?"":e}function Cr(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function Ut(e){return Xe.Function(e)?e.toJSON?e.toJSON():Bn(e):Xe.Array(e)?"Array":e&&Xe.Object(e)?"Object":e!==void 0?e:""}function Rn(e,t,r){var a=Pi(t);return"Expected "+Ut(e)+", got"+(r!==""?" "+r:"")+(a!==""?" "+a:"")}function Ue(e,t,r){r=r||kr(t),this.message=Rn(e,t,r),Cr(this,Ue),this.__type=e,this.__value=t,this.__valueTypeName=r}Ue.prototype=Object.create(Error.prototype);Ue.prototype.constructor=Ue;function Fi(e,t,r,a,o){var s='" of type ';return t==="key"&&(s='" with key type '),Rn('property "'+Ut(r)+s+Ut(e),a,o)}function ot(e,t,r,a,o){e?(o=o||kr(a),this.message=Fi(e,r,t,a,o)):this.message='Unexpected property "'+t+'"',Cr(this,Ue),this.__label=r,this.__property=t,this.__type=e,this.__value=a,this.__valueTypeName=o}ot.prototype=Object.create(Error.prototype);ot.prototype.constructor=Ue;function Ni(e,t){return new Ue(e,{},t)}function Ui(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 Ue&&(e=new ot(e.__type,t,r,e.__value,e.__valueTypeName)),Cr(e),e}var Sn={TfTypeError:Ue,TfPropertyTypeError:ot,tfCustomError:Ni,tfSubError:Ui,tfJSON:Ut,getValueTypeName:kr},nr,jr;function Di(){if(jr)return nr;jr=1;var e=Ir,t=Sn;function r(E){return Buffer.isBuffer(E)}function a(E){return typeof E=="string"&&/^([0-9a-f]{2})+$/i.test(E)}function o(E,j){var U=E.toJSON();function $(ne){if(!E(ne))return!1;if(ne.length===j)return!0;throw t.tfCustomError(U+"(Length: "+j+")",U+"(Length: "+ne.length+")")}return $.toJSON=function(){return U},$}var s=o.bind(null,e.Array),c=o.bind(null,r),u=o.bind(null,a),p=o.bind(null,e.String);function w(E,j,U){U=U||e.Number;function $(ne,Te){return U(ne,Te)&&ne>E&&ne<j}return $.toJSON=function(){return`${U.toJSON()} between [${E}, ${j}]`},$}var m=Math.pow(2,53)-1;function v(E){return typeof E=="number"&&isFinite(E)}function T(E){return E<<24>>24===E}function C(E){return E<<16>>16===E}function R(E){return(E|0)===E}function k(E){return typeof E=="number"&&E>=-m&&E<=m&&Math.floor(E)===E}function A(E){return(E&255)===E}function I(E){return(E&65535)===E}function M(E){return E>>>0===E}function P(E){return typeof E=="number"&&E>=0&&E<=m&&Math.floor(E)===E}var L={ArrayN:s,Buffer:r,BufferN:c,Finite:v,Hex:a,HexN:u,Int8:T,Int16:C,Int32:R,Int53:k,Range:w,StringN:p,UInt8:A,UInt16:I,UInt32:M,UInt53:P};for(var N in L)L[N].toJSON=(function(E){return E}).bind(null,N);return nr=L,nr}var St=Sn,fe=Ir,Pe=St.tfJSON,An=St.TfTypeError,Tn=St.TfPropertyTypeError,_t=St.tfSubError,$i=St.getValueTypeName,Fe={arrayOf:function(t,r){t=Oe(t),r=r||{};function a(o,s){return!fe.Array(o)||fe.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 a.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},a},maybe:function e(t){t=Oe(t);function r(a,o){return fe.Nil(a)||t(a,o,e)}return r.toJSON=function(){return"?"+Pe(t)},r},map:function(t,r){t=Oe(t),r&&(r=Oe(r));function a(o,s){if(!fe.Object(o)||fe.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?a.toJSON=function(){return"{"+Pe(r)+": "+Pe(t)+"}"}:a.toJSON=function(){return"{"+Pe(t)+"}"},a},object:function(t){var r={};for(var a in t)r[a]=Oe(t[a]);function o(s,c){if(!fe.Object(s)||fe.Nil(s))return!1;var u;try{for(u in r){var p=r[u],w=s[u];we(p,w,c)}}catch(m){throw _t(m,u)}if(c){for(u in s)if(!r[u])throw new Tn(void 0,u)}return!0}return o.toJSON=function(){return Pe(r)},o},anyOf:function(){var t=[].slice.call(arguments).map(Oe);function r(a,o){return t.some(function(s){try{return we(s,a,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(a,o){return t.every(function(s){try{return we(s,a,o)}catch{return!1}})}return r.toJSON=function(){return t.map(Pe).join(" & ")},r},quacksLike:function(t){function r(a){return t===$i(a)}return r.toJSON=function(){return t},r},tuple:function(){var t=[].slice.call(arguments).map(Oe);function r(a,o){return fe.Nil(a)||fe.Nil(a.length)||o&&a.length!==t.length?!1:t.every(function(s,c){try{return we(s,a[c],o)}catch(u){throw _t(u,c)}})}return r.toJSON=function(){return"("+t.map(Pe).join(", ")+")"},r},value:function(t){function r(a){return a===t}return r.toJSON=function(){return t},r}};Fe.oneOf=Fe.anyOf;function Oe(e){if(fe.String(e))return e[0]==="?"?Fe.maybe(e.slice(1)):fe[e]||Fe.quacksLike(e);if(e&&fe.Object(e)){if(fe.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return Fe.arrayOf(e[0])}return Fe.object(e)}else if(fe.Function(e))return e;return Fe.value(e)}function we(e,t,r,a){if(fe.Function(e)){if(e(t,r))return!0;throw new An(a||e,t)}return we(Oe(e),t,r)}for(var Ke in fe)we[Ke]=fe[Ke];for(Ke in Fe)we[Ke]=Fe[Ke];var qr=Di();for(Ke in qr)we[Ke]=qr[Ke];we.compile=Oe;we.TfTypeError=An;we.TfPropertyTypeError=Tn;var Hi=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=Hi,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})(En);var mr={exports:{}},vr={exports:{}},ht={},Wt={};Wt.byteLength=Wi;Wt.toByteArray=Gi;Wt.fromByteArray=Ji;var Le=[],Se=[],ji=typeof Uint8Array<"u"?Uint8Array:Array,ir="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var at=0,qi=ir.length;at<qi;++at)Le[at]=ir[at],Se[ir.charCodeAt(at)]=at;Se[45]=62;Se[95]=63;function In(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 a=r===t?0:4-r%4;return[r,a]}function Wi(e){var t=In(e),r=t[0],a=t[1];return(r+a)*3/4-a}function Ki(e,t,r){return(t+r)*3/4-r}function Gi(e){var t,r=In(e),a=r[0],o=r[1],s=new ji(Ki(e,a,o)),c=0,u=o>0?a-4:a,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 Vi(e){return Le[e>>18&63]+Le[e>>12&63]+Le[e>>6&63]+Le[e&63]}function zi(e,t,r){for(var a,o=[],s=t;s<r;s+=3)a=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),o.push(Vi(a));return o.join("")}function Ji(e){for(var t,r=e.length,a=r%3,o=[],s=16383,c=0,u=r-a;c<u;c+=s)o.push(zi(e,c,c+s>u?u:c+s));return a===1?(t=e[r-1],o.push(Le[t>>2]+Le[t<<4&63]+"==")):a===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 Or={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Or.read=function(e,t,r,a,o){var s,c,u=o*8-a-1,p=(1<<u)-1,w=p>>1,m=-7,v=r?o-1:0,T=r?-1:1,C=e[t+v];for(v+=T,s=C&(1<<-m)-1,C>>=-m,m+=u;m>0;s=s*256+e[t+v],v+=T,m-=8);for(c=s&(1<<-m)-1,s>>=-m,m+=a;m>0;c=c*256+e[t+v],v+=T,m-=8);if(s===0)s=1-w;else{if(s===p)return c?NaN:(C?-1:1)*(1/0);c=c+Math.pow(2,a),s=s-w}return(C?-1:1)*c*Math.pow(2,s-a)};Or.write=function(e,t,r,a,o,s){var c,u,p,w=s*8-o-1,m=(1<<w)-1,v=m>>1,T=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,C=a?0:s-1,R=a?1:-1,k=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+=T/p:t+=T*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+C]=u&255,C+=R,u/=256,o-=8);for(c=c<<o|u,w+=o;w>0;e[r+C]=c&255,C+=R,c/=256,w-=8);e[r+C-R]|=k*128};/*!
22
+ `,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var En={},Bt={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}};Bt.Null=Bt.Nil;for(var Hr in Bt)Bt[Hr].toJSON=(function(e){return e}).bind(null,Hr);var Ir=Bt,Xe=Ir;function Bn(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function kr(e){return Xe.Nil(e)?"":Bn(e.constructor)}function Fi(e){return Xe.Function(e)?"":Xe.String(e)?JSON.stringify(e):e&&Xe.Object(e)?"":e}function Cr(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function Ut(e){return Xe.Function(e)?e.toJSON?e.toJSON():Bn(e):Xe.Array(e)?"Array":e&&Xe.Object(e)?"Object":e!==void 0?e:""}function Rn(e,t,r){var a=Fi(t);return"Expected "+Ut(e)+", got"+(r!==""?" "+r:"")+(a!==""?" "+a:"")}function Ue(e,t,r){r=r||kr(t),this.message=Rn(e,t,r),Cr(this,Ue),this.__type=e,this.__value=t,this.__valueTypeName=r}Ue.prototype=Object.create(Error.prototype);Ue.prototype.constructor=Ue;function Ni(e,t,r,a,o){var s='" of type ';return t==="key"&&(s='" with key type '),Rn('property "'+Ut(r)+s+Ut(e),a,o)}function ot(e,t,r,a,o){e?(o=o||kr(a),this.message=Ni(e,r,t,a,o)):this.message='Unexpected property "'+t+'"',Cr(this,Ue),this.__label=r,this.__property=t,this.__type=e,this.__value=a,this.__valueTypeName=o}ot.prototype=Object.create(Error.prototype);ot.prototype.constructor=Ue;function Ui(e,t){return new Ue(e,{},t)}function Di(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 Ue&&(e=new ot(e.__type,t,r,e.__value,e.__valueTypeName)),Cr(e),e}var Sn={TfTypeError:Ue,TfPropertyTypeError:ot,tfCustomError:Ui,tfSubError:Di,tfJSON:Ut,getValueTypeName:kr},nr,jr;function $i(){if(jr)return nr;jr=1;var e=Ir,t=Sn;function r(E){return Buffer.isBuffer(E)}function a(E){return typeof E=="string"&&/^([0-9a-f]{2})+$/i.test(E)}function o(E,j){var U=E.toJSON();function $(ne){if(!E(ne))return!1;if(ne.length===j)return!0;throw t.tfCustomError(U+"(Length: "+j+")",U+"(Length: "+ne.length+")")}return $.toJSON=function(){return U},$}var s=o.bind(null,e.Array),c=o.bind(null,r),u=o.bind(null,a),p=o.bind(null,e.String);function w(E,j,U){U=U||e.Number;function $(ne,Te){return U(ne,Te)&&ne>E&&ne<j}return $.toJSON=function(){return`${U.toJSON()} between [${E}, ${j}]`},$}var m=Math.pow(2,53)-1;function v(E){return typeof E=="number"&&isFinite(E)}function T(E){return E<<24>>24===E}function O(E){return E<<16>>16===E}function R(E){return(E|0)===E}function k(E){return typeof E=="number"&&E>=-m&&E<=m&&Math.floor(E)===E}function A(E){return(E&255)===E}function I(E){return(E&65535)===E}function M(E){return E>>>0===E}function P(E){return typeof E=="number"&&E>=0&&E<=m&&Math.floor(E)===E}var L={ArrayN:s,Buffer:r,BufferN:c,Finite:v,Hex:a,HexN:u,Int8:T,Int16:O,Int32:R,Int53:k,Range:w,StringN:p,UInt8:A,UInt16:I,UInt32:M,UInt53:P};for(var N in L)L[N].toJSON=(function(E){return E}).bind(null,N);return nr=L,nr}var St=Sn,fe=Ir,Pe=St.tfJSON,An=St.TfTypeError,Tn=St.TfPropertyTypeError,_t=St.tfSubError,Hi=St.getValueTypeName,Fe={arrayOf:function(t,r){t=Oe(t),r=r||{};function a(o,s){return!fe.Array(o)||fe.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 a.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},a},maybe:function e(t){t=Oe(t);function r(a,o){return fe.Nil(a)||t(a,o,e)}return r.toJSON=function(){return"?"+Pe(t)},r},map:function(t,r){t=Oe(t),r&&(r=Oe(r));function a(o,s){if(!fe.Object(o)||fe.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?a.toJSON=function(){return"{"+Pe(r)+": "+Pe(t)+"}"}:a.toJSON=function(){return"{"+Pe(t)+"}"},a},object:function(t){var r={};for(var a in t)r[a]=Oe(t[a]);function o(s,c){if(!fe.Object(s)||fe.Nil(s))return!1;var u;try{for(u in r){var p=r[u],w=s[u];we(p,w,c)}}catch(m){throw _t(m,u)}if(c){for(u in s)if(!r[u])throw new Tn(void 0,u)}return!0}return o.toJSON=function(){return Pe(r)},o},anyOf:function(){var t=[].slice.call(arguments).map(Oe);function r(a,o){return t.some(function(s){try{return we(s,a,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(a,o){return t.every(function(s){try{return we(s,a,o)}catch{return!1}})}return r.toJSON=function(){return t.map(Pe).join(" & ")},r},quacksLike:function(t){function r(a){return t===Hi(a)}return r.toJSON=function(){return t},r},tuple:function(){var t=[].slice.call(arguments).map(Oe);function r(a,o){return fe.Nil(a)||fe.Nil(a.length)||o&&a.length!==t.length?!1:t.every(function(s,c){try{return we(s,a[c],o)}catch(u){throw _t(u,c)}})}return r.toJSON=function(){return"("+t.map(Pe).join(", ")+")"},r},value:function(t){function r(a){return a===t}return r.toJSON=function(){return t},r}};Fe.oneOf=Fe.anyOf;function Oe(e){if(fe.String(e))return e[0]==="?"?Fe.maybe(e.slice(1)):fe[e]||Fe.quacksLike(e);if(e&&fe.Object(e)){if(fe.Array(e)){if(e.length!==1)throw new TypeError("Expected compile() parameter of type Array of length 1");return Fe.arrayOf(e[0])}return Fe.object(e)}else if(fe.Function(e))return e;return Fe.value(e)}function we(e,t,r,a){if(fe.Function(e)){if(e(t,r))return!0;throw new An(a||e,t)}return we(Oe(e),t,r)}for(var Ke in fe)we[Ke]=fe[Ke];for(Ke in Fe)we[Ke]=Fe[Ke];var qr=$i();for(Ke in qr)we[Ke]=qr[Ke];we.compile=Oe;we.TfTypeError=An;we.TfPropertyTypeError=Tn;var ji=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=ji,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})(En);var mr={exports:{}},vr={exports:{}},ht={},Wt={};Wt.byteLength=Ki;Wt.toByteArray=Vi;Wt.fromByteArray=Yi;var Le=[],Se=[],qi=typeof Uint8Array<"u"?Uint8Array:Array,ir="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var at=0,Wi=ir.length;at<Wi;++at)Le[at]=ir[at],Se[ir.charCodeAt(at)]=at;Se[45]=62;Se[95]=63;function In(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 a=r===t?0:4-r%4;return[r,a]}function Ki(e){var t=In(e),r=t[0],a=t[1];return(r+a)*3/4-a}function Gi(e,t,r){return(t+r)*3/4-r}function Vi(e){var t,r=In(e),a=r[0],o=r[1],s=new qi(Gi(e,a,o)),c=0,u=o>0?a-4:a,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 zi(e){return Le[e>>18&63]+Le[e>>12&63]+Le[e>>6&63]+Le[e&63]}function Ji(e,t,r){for(var a,o=[],s=t;s<r;s+=3)a=(e[s]<<16&16711680)+(e[s+1]<<8&65280)+(e[s+2]&255),o.push(zi(a));return o.join("")}function Yi(e){for(var t,r=e.length,a=r%3,o=[],s=16383,c=0,u=r-a;c<u;c+=s)o.push(Ji(e,c,c+s>u?u:c+s));return a===1?(t=e[r-1],o.push(Le[t>>2]+Le[t<<4&63]+"==")):a===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 Or={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */Or.read=function(e,t,r,a,o){var s,c,u=o*8-a-1,p=(1<<u)-1,w=p>>1,m=-7,v=r?o-1:0,T=r?-1:1,O=e[t+v];for(v+=T,s=O&(1<<-m)-1,O>>=-m,m+=u;m>0;s=s*256+e[t+v],v+=T,m-=8);for(c=s&(1<<-m)-1,s>>=-m,m+=a;m>0;c=c*256+e[t+v],v+=T,m-=8);if(s===0)s=1-w;else{if(s===p)return c?NaN:(O?-1:1)*(1/0);c=c+Math.pow(2,a),s=s-w}return(O?-1:1)*c*Math.pow(2,s-a)};Or.write=function(e,t,r,a,o,s){var c,u,p,w=s*8-o-1,m=(1<<w)-1,v=m>>1,T=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,O=a?0:s-1,R=a?1:-1,k=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+=T/p:t+=T*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+O]=u&255,O+=R,u/=256,o-=8);for(c=c<<o|u,w+=o;w>0;e[r+O]=c&255,O+=R,c/=256,w-=8);e[r+O-R]|=k*128};/*!
23
23
  * The buffer module from node.js, for the browser.
24
24
  *
25
25
  * @author Feross Aboukhadijeh <https://feross.org>
26
26
  * @license MIT
27
- */(function(e){const t=Wt,r=Or,a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=M,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,i){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,i)}u.poolSize=8192;function p(f,n,i){if(typeof f=="string")return T(f,n);if(ArrayBuffer.isView(f))return R(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 k(f,n,i);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,i);const b=A(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,i);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,i){return p(f,n,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function w(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,i){return w(f),f<=0?c(f):n!==void 0?typeof i=="string"?c(f).fill(n,i):c(f).fill(n):c(f)}u.alloc=function(f,n,i){return m(f,n,i)};function v(f){return w(f),c(f<0?0:I(f)|0)}u.allocUnsafe=function(f){return v(f)},u.allocUnsafeSlow=function(f){return v(f)};function T(f,n){if((typeof n!="string"||n==="")&&(n="utf8"),!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const i=P(f,n)|0;let l=c(i);const b=l.write(f,n);return b!==i&&(l=l.slice(0,b)),l}function C(f){const n=f.length<0?0:I(f.length)|0,i=c(n);for(let l=0;l<n;l+=1)i[l]=f[l]&255;return i}function R(f){if(Be(f,Uint8Array)){const n=new Uint8Array(f);return k(n.buffer,n.byteOffset,n.byteLength)}return C(f)}function k(f,n,i){if(n<0||f.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(f.byteLength<n+(i||0))throw new RangeError('"length" is outside of buffer bounds');let l;return n===void 0&&i===void 0?l=new Uint8Array(f):i===void 0?l=new Uint8Array(f,n):l=new Uint8Array(f,n,i),Object.setPrototypeOf(l,u.prototype),l}function A(f){if(u.isBuffer(f)){const n=I(f.length)|0,i=c(n);return i.length===0||f.copy(i,0,0,n),i}if(f.length!==void 0)return typeof f.length!="number"||Je(f.length)?c(0):C(f);if(f.type==="Buffer"&&Array.isArray(f.data))return C(f.data)}function I(f){if(f>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return f|0}function M(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,i){if(Be(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),Be(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(n)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===i)return 0;let l=n.length,b=i.length;for(let g=0,x=Math.min(l,b);g<x;++g)if(n[g]!==i[g]){l=n[g],b=i[g];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,i){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(i===void 0)for(i=0,l=0;l<n.length;++l)i+=n[l].length;const b=u.allocUnsafe(i);let g=0;for(l=0;l<n.length;++l){let x=n[l];if(Be(x,Uint8Array))g+x.length>b.length?(u.isBuffer(x)||(x=u.from(x)),x.copy(b,g)):Uint8Array.prototype.set.call(b,x,g);else if(u.isBuffer(x))x.copy(b,g);else throw new TypeError('"list" argument must be an Array of Buffers');g+=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 i=f.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&i===0)return 0;let b=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return G(f).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return pt(f).length;default:if(b)return l?-1:G(f).length;n=(""+n).toLowerCase(),b=!0}}u.byteLength=P;function L(f,n,i){let l=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,n>>>=0,i<=n))return"";for(f||(f="utf8");;)switch(f){case"hex":return ke(this,n,i);case"utf8":case"utf-8":return me(this,n,i);case"ascii":return Ie(this,n,i);case"latin1":case"binary":return He(this,n,i);case"base64":return oe(this,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return je(this,n,i);default:if(l)throw new TypeError("Unknown encoding: "+f);f=(f+"").toLowerCase(),l=!0}}u.prototype._isBuffer=!0;function N(f,n,i){const l=f[n];f[n]=f[i],f[i]=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 i=0;i<n;i+=2)N(this,i,i+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 i=0;i<n;i+=4)N(this,i,i+3),N(this,i+1,i+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 i=0;i<n;i+=8)N(this,i,i+7),N(this,i+1,i+6),N(this,i+2,i+5),N(this,i+3,i+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 i=e.INSPECT_MAX_BYTES;return n=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(n+=" ... "),"<Buffer "+n+">"},a&&(u.prototype[a]=u.prototype.inspect),u.prototype.compare=function(n,i,l,b,g){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(i===void 0&&(i=0),l===void 0&&(l=n?n.length:0),b===void 0&&(b=0),g===void 0&&(g=this.length),i<0||l>n.length||b<0||g>this.length)throw new RangeError("out of range index");if(b>=g&&i>=l)return 0;if(b>=g)return-1;if(i>=l)return 1;if(i>>>=0,l>>>=0,b>>>=0,g>>>=0,this===n)return 0;let x=g-b,K=l-i;const te=Math.min(x,K),Z=this.slice(b,g),re=n.slice(i,l);for(let z=0;z<te;++z)if(Z[z]!==re[z]){x=Z[z],K=re[z];break}return x<K?-1:K<x?1:0};function E(f,n,i,l,b){if(f.length===0)return-1;if(typeof i=="string"?(l=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,Je(i)&&(i=b?0:f.length-1),i<0&&(i=f.length+i),i>=f.length){if(b)return-1;i=f.length-1}else if(i<0)if(b)i=0;else return-1;if(typeof n=="string"&&(n=u.from(n,l)),u.isBuffer(n))return n.length===0?-1:j(f,n,i,l,b);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(f,n,i):Uint8Array.prototype.lastIndexOf.call(f,n,i):j(f,[n],i,l,b);throw new TypeError("val must be string, number or Buffer")}function j(f,n,i,l,b){let g=1,x=f.length,K=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;g=2,x/=2,K/=2,i/=2}function te(re,z){return g===1?re[z]:re.readUInt16BE(z*g)}let Z;if(b){let re=-1;for(Z=i;Z<x;Z++)if(te(f,Z)===te(n,re===-1?0:Z-re)){if(re===-1&&(re=Z),Z-re+1===K)return re*g}else re!==-1&&(Z-=Z-re),re=-1}else for(i+K>x&&(i=x-K),Z=i;Z>=0;Z--){let re=!0;for(let z=0;z<K;z++)if(te(f,Z+z)!==te(n,z)){re=!1;break}if(re)return Z}return-1}u.prototype.includes=function(n,i,l){return this.indexOf(n,i,l)!==-1},u.prototype.indexOf=function(n,i,l){return E(this,n,i,l,!0)},u.prototype.lastIndexOf=function(n,i,l){return E(this,n,i,l,!1)};function U(f,n,i,l){i=Number(i)||0;const b=f.length-i;l?(l=Number(l),l>b&&(l=b)):l=b;const g=n.length;l>g/2&&(l=g/2);let x;for(x=0;x<l;++x){const K=parseInt(n.substr(x*2,2),16);if(Je(K))return x;f[i+x]=K}return x}function $(f,n,i,l){return rt(G(n,f.length-i),f,i,l)}function ne(f,n,i,l){return rt(We(n),f,i,l)}function Te(f,n,i,l){return rt(pt(n),f,i,l)}function $e(f,n,i,l){return rt(tt(n,f.length-i),f,i,l)}u.prototype.write=function(n,i,l,b){if(i===void 0)b="utf8",l=this.length,i=0;else if(l===void 0&&typeof i=="string")b=i,l=this.length,i=0;else if(isFinite(i))i=i>>>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 g=this.length-i;if((l===void 0||l>g)&&(l=g),n.length>0&&(l<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");b||(b="utf8");let x=!1;for(;;)switch(b){case"hex":return U(this,n,i,l);case"utf8":case"utf-8":return $(this,n,i,l);case"ascii":case"latin1":case"binary":return ne(this,n,i,l);case"base64":return Te(this,n,i,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,n,i,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,i){return n===0&&i===f.length?t.fromByteArray(f):t.fromByteArray(f.slice(n,i))}function me(f,n,i){i=Math.min(f.length,i);const l=[];let b=n;for(;b<i;){const g=f[b];let x=null,K=g>239?4:g>223?3:g>191?2:1;if(b+K<=i){let te,Z,re,z;switch(K){case 1:g<128&&(x=g);break;case 2:te=f[b+1],(te&192)===128&&(z=(g&31)<<6|te&63,z>127&&(x=z));break;case 3:te=f[b+1],Z=f[b+2],(te&192)===128&&(Z&192)===128&&(z=(g&15)<<12|(te&63)<<6|Z&63,z>2047&&(z<55296||z>57343)&&(x=z));break;case 4:te=f[b+1],Z=f[b+2],re=f[b+3],(te&192)===128&&(Z&192)===128&&(re&192)===128&&(z=(g&15)<<18|(te&63)<<12|(Z&63)<<6|re&63,z>65535&&z<1114112&&(x=z))}}x===null?(x=65533,K=1):x>65535&&(x-=65536,l.push(x>>>10&1023|55296),x=56320|x&1023),l.push(x),b+=K}return ze(l)}const ve=4096;function ze(f){const n=f.length;if(n<=ve)return String.fromCharCode.apply(String,f);let i="",l=0;for(;l<n;)i+=String.fromCharCode.apply(String,f.slice(l,l+=ve));return i}function Ie(f,n,i){let l="";i=Math.min(f.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(f[b]&127);return l}function He(f,n,i){let l="";i=Math.min(f.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(f[b]);return l}function ke(f,n,i){const l=f.length;(!n||n<0)&&(n=0),(!i||i<0||i>l)&&(i=l);let b="";for(let g=n;g<i;++g)b+=bt[f[g]];return b}function je(f,n,i){const l=f.slice(n,i);let b="";for(let g=0;g<l.length-1;g+=2)b+=String.fromCharCode(l[g]+l[g+1]*256);return b}u.prototype.slice=function(n,i){const l=this.length;n=~~n,i=i===void 0?l:~~i,n<0?(n+=l,n<0&&(n=0)):n>l&&(n=l),i<0?(i+=l,i<0&&(i=0)):i>l&&(i=l),i<n&&(i=n);const b=this.subarray(n,i);return Object.setPrototypeOf(b,u.prototype),b};function X(f,n,i){if(f%1!==0||f<0)throw new RangeError("offset is not uint");if(f+n>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=this[n],g=1,x=0;for(;++x<i&&(g*=256);)b+=this[n+x]*g;return b},u.prototype.readUintBE=u.prototype.readUIntBE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=this[n+--i],g=1;for(;i>0&&(g*=256);)b+=this[n+--i]*g;return b},u.prototype.readUint8=u.prototype.readUInt8=function(n,i){return n=n>>>0,i||X(n,1,this.length),this[n]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(n,i){return n=n>>>0,i||X(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(n,i){return n=n>>>0,i||X(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(n,i){return n=n>>>0,i||X(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,i){return n=n>>>0,i||X(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,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(n,this.length-8);const b=i+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,g=this[++n]+this[++n]*2**8+this[++n]*2**16+l*2**24;return BigInt(b)+(BigInt(g)<<BigInt(32))}),u.prototype.readBigUInt64BE=Re(function(n){n=n>>>0,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(n,this.length-8);const b=i*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],g=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l;return(BigInt(b)<<BigInt(32))+BigInt(g)}),u.prototype.readIntLE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=this[n],g=1,x=0;for(;++x<i&&(g*=256);)b+=this[n+x]*g;return g*=128,b>=g&&(b-=Math.pow(2,8*i)),b},u.prototype.readIntBE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=i,g=1,x=this[n+--b];for(;b>0&&(g*=256);)x+=this[n+--b]*g;return g*=128,x>=g&&(x-=Math.pow(2,8*i)),x},u.prototype.readInt8=function(n,i){return n=n>>>0,i||X(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,i){n=n>>>0,i||X(n,2,this.length);const l=this[n]|this[n+1]<<8;return l&32768?l|4294901760:l},u.prototype.readInt16BE=function(n,i){n=n>>>0,i||X(n,2,this.length);const l=this[n+1]|this[n]<<8;return l&32768?l|4294901760:l},u.prototype.readInt32LE=function(n,i){return n=n>>>0,i||X(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},u.prototype.readInt32BE=function(n,i){return n=n>>>0,i||X(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,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(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(i+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),u.prototype.readBigInt64BE=Re(function(n){n=n>>>0,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(n,this.length-8);const b=(i<<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,i){return n=n>>>0,i||X(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,i){return n=n>>>0,i||X(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,i){return n=n>>>0,i||X(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,i){return n=n>>>0,i||X(n,8,this.length),r.read(this,n,!1,52,8)};function ie(f,n,i,l,b,g){if(!u.isBuffer(f))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>b||n<g)throw new RangeError('"value" argument is out of bounds');if(i+l>f.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(n,i,l,b){if(n=+n,i=i>>>0,l=l>>>0,!b){const K=Math.pow(2,8*l)-1;ie(this,n,i,l,K,0)}let g=1,x=0;for(this[i]=n&255;++x<l&&(g*=256);)this[i+x]=n/g&255;return i+l},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(n,i,l,b){if(n=+n,i=i>>>0,l=l>>>0,!b){const K=Math.pow(2,8*l)-1;ie(this,n,i,l,K,0)}let g=l-1,x=1;for(this[i+g]=n&255;--g>=0&&(x*=256);)this[i+g]=n/x&255;return i+l},u.prototype.writeUint8=u.prototype.writeUInt8=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,1,255,0),this[i]=n&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,65535,0),this[i]=n&255,this[i+1]=n>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,65535,0),this[i]=n>>>8,this[i+1]=n&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,4294967295,0),this[i+3]=n>>>24,this[i+2]=n>>>16,this[i+1]=n>>>8,this[i]=n&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,4294967295,0),this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255,i+4};function Ee(f,n,i,l,b){d(n,l,b,f,i,7);let g=Number(n&BigInt(4294967295));f[i++]=g,g=g>>8,f[i++]=g,g=g>>8,f[i++]=g,g=g>>8,f[i++]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return f[i++]=x,x=x>>8,f[i++]=x,x=x>>8,f[i++]=x,x=x>>8,f[i++]=x,i}function qe(f,n,i,l,b){d(n,l,b,f,i,7);let g=Number(n&BigInt(4294967295));f[i+7]=g,g=g>>8,f[i+6]=g,g=g>>8,f[i+5]=g,g=g>>8,f[i+4]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return f[i+3]=x,x=x>>8,f[i+2]=x,x=x>>8,f[i+1]=x,x=x>>8,f[i]=x,i+8}u.prototype.writeBigUInt64LE=Re(function(n,i=0){return Ee(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Re(function(n,i=0){return qe(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(n,i,l,b){if(n=+n,i=i>>>0,!b){const te=Math.pow(2,8*l-1);ie(this,n,i,l,te-1,-te)}let g=0,x=1,K=0;for(this[i]=n&255;++g<l&&(x*=256);)n<0&&K===0&&this[i+g-1]!==0&&(K=1),this[i+g]=(n/x>>0)-K&255;return i+l},u.prototype.writeIntBE=function(n,i,l,b){if(n=+n,i=i>>>0,!b){const te=Math.pow(2,8*l-1);ie(this,n,i,l,te-1,-te)}let g=l-1,x=1,K=0;for(this[i+g]=n&255;--g>=0&&(x*=256);)n<0&&K===0&&this[i+g+1]!==0&&(K=1),this[i+g]=(n/x>>0)-K&255;return i+l},u.prototype.writeInt8=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,1,127,-128),n<0&&(n=255+n+1),this[i]=n&255,i+1},u.prototype.writeInt16LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,32767,-32768),this[i]=n&255,this[i+1]=n>>>8,i+2},u.prototype.writeInt16BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,32767,-32768),this[i]=n>>>8,this[i+1]=n&255,i+2},u.prototype.writeInt32LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,2147483647,-2147483648),this[i]=n&255,this[i+1]=n>>>8,this[i+2]=n>>>16,this[i+3]=n>>>24,i+4},u.prototype.writeInt32BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255,i+4},u.prototype.writeBigInt64LE=Re(function(n,i=0){return Ee(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Re(function(n,i=0){return qe(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Me(f,n,i,l,b,g){if(i+l>f.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function _(f,n,i,l,b){return n=+n,i=i>>>0,b||Me(f,n,i,4),r.write(f,n,i,l,23,4),i+4}u.prototype.writeFloatLE=function(n,i,l){return _(this,n,i,!0,l)},u.prototype.writeFloatBE=function(n,i,l){return _(this,n,i,!1,l)};function y(f,n,i,l,b){return n=+n,i=i>>>0,b||Me(f,n,i,8),r.write(f,n,i,l,52,8),i+8}u.prototype.writeDoubleLE=function(n,i,l){return y(this,n,i,!0,l)},u.prototype.writeDoubleBE=function(n,i,l){return y(this,n,i,!1,l)},u.prototype.copy=function(n,i,l,b){if(!u.isBuffer(n))throw new TypeError("argument should be a Buffer");if(l||(l=0),!b&&b!==0&&(b=this.length),i>=n.length&&(i=n.length),i||(i=0),b>0&&b<l&&(b=l),b===l||n.length===0||this.length===0)return 0;if(i<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-i<b-l&&(b=n.length-i+l);const g=b-l;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,l,b):Uint8Array.prototype.set.call(n,this.subarray(l,b),i),g},u.prototype.fill=function(n,i,l,b){if(typeof n=="string"){if(typeof i=="string"?(b=i,i=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(i<0||this.length<i||this.length<l)throw new RangeError("Out of range index");if(l<=i)return this;i=i>>>0,l=l===void 0?this.length:l>>>0,n||(n=0);let g;if(typeof n=="number")for(g=i;g<l;++g)this[g]=n;else{const x=u.isBuffer(n)?n:u.from(n,b),K=x.length;if(K===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(g=0;g<l-i;++g)this[g+i]=x[g%K]}return this};const S={};function D(f,n,i){S[f]=class extends i{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}`}}}D("ERR_BUFFER_OUT_OF_BOUNDS",function(f){return f?`${f} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(f,n){return`The "${f}" argument must be of type number. Received type ${typeof n}`},TypeError),D("ERR_OUT_OF_RANGE",function(f,n,i){let l=`The value of "${f}" is out of range.`,b=i;return Number.isInteger(i)&&Math.abs(i)>2**32?b=q(String(i)):typeof i=="bigint"&&(b=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(b=q(b)),b+="n"),l+=` It must be ${n}. Received ${b}`,l},RangeError);function q(f){let n="",i=f.length;const l=f[0]==="-"?1:0;for(;i>=l+4;i-=3)n=`_${f.slice(i-3,i)}${n}`;return`${f.slice(0,i)}${n}`}function h(f,n,i){B(n,"offset"),(f[n]===void 0||f[n+i]===void 0)&&F(n,f.length-(i+1))}function d(f,n,i,l,b,g){if(f>i||f<n){const x=typeof n=="bigint"?"n":"";let K;throw n===0||n===BigInt(0)?K=`>= 0${x} and < 2${x} ** ${(g+1)*8}${x}`:K=`>= -(2${x} ** ${(g+1)*8-1}${x}) and < 2 ** ${(g+1)*8-1}${x}`,new S.ERR_OUT_OF_RANGE("value",K,f)}h(l,b,g)}function B(f,n){if(typeof f!="number")throw new S.ERR_INVALID_ARG_TYPE(n,"number",f)}function F(f,n,i){throw Math.floor(f)!==f?(B(f,i),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 Q=/[^+/0-9A-Za-z-_]/g;function W(f){if(f=f.split("=")[0],f=f.trim().replace(Q,""),f.length<2)return"";for(;f.length%4!==0;)f=f+"=";return f}function G(f,n){n=n||1/0;let i;const l=f.length;let b=null;const g=[];for(let x=0;x<l;++x){if(i=f.charCodeAt(x),i>55295&&i<57344){if(!b){if(i>56319){(n-=3)>-1&&g.push(239,191,189);continue}else if(x+1===l){(n-=3)>-1&&g.push(239,191,189);continue}b=i;continue}if(i<56320){(n-=3)>-1&&g.push(239,191,189),b=i;continue}i=(b-55296<<10|i-56320)+65536}else b&&(n-=3)>-1&&g.push(239,191,189);if(b=null,i<128){if((n-=1)<0)break;g.push(i)}else if(i<2048){if((n-=2)<0)break;g.push(i>>6|192,i&63|128)}else if(i<65536){if((n-=3)<0)break;g.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((n-=4)<0)break;g.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return g}function We(f){const n=[];for(let i=0;i<f.length;++i)n.push(f.charCodeAt(i)&255);return n}function tt(f,n){let i,l,b;const g=[];for(let x=0;x<f.length&&!((n-=2)<0);++x)i=f.charCodeAt(x),l=i>>8,b=i%256,g.push(b),g.push(l);return g}function pt(f){return t.toByteArray(W(f))}function rt(f,n,i,l){let b;for(b=0;b<l&&!(b+i>=n.length||b>=f.length);++b)n[b+i]=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 Je(f){return f!==f}const bt=function(){const f="0123456789abcdef",n=new Array(256);for(let i=0;i<16;++i){const l=i*16;for(let b=0;b<16;++b)n[l+b]=f[i]+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,a=r.Buffer;function o(c,u){for(var p in c)u[p]=c[p]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=s);function s(c,u,p){return a(c,u,p)}s.prototype=Object.create(a.prototype),o(a,s),s.from=function(c,u,p){if(typeof c=="number")throw new TypeError("Argument must not be a number");return a(c,u,p)},s.alloc=function(c,u,p){if(typeof c!="number")throw new TypeError("Argument must be a number");var w=a(c);return u!==void 0?typeof p=="string"?w.fill(u,p):w.fill(u):w.fill(0),w},s.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return a(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,ar=65536,Yi=4294967295;function Xi(){throw new Error(`Secure random number generation is not supported by this browser.
28
- Use Chrome, Firefox or Internet Explorer 11`)}var Qi=xe.Buffer,Dt=Ge.crypto||Ge.msCrypto;Dt&&Dt.getRandomValues?mr.exports=Zi:mr.exports=Xi;function Zi(e,t){if(e>Yi)throw new RangeError("requested too many random bytes");var r=Qi.allocUnsafe(e);if(e>0)if(e>ar)for(var a=0;a<e;a+=ar)Dt.getRandomValues(r.slice(a,a+ar));else Dt.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var ea=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 a=function(){};a.prototype=r.prototype,t.prototype=new a,t.prototype.constructor=t}};var be=xr.exports,Er={exports:{}},Lr={exports:{}},st=typeof Reflect=="object"?Reflect:null,Wr=st&&typeof st.apply=="function"?st.apply:function(t,r,a){return Function.prototype.apply.call(t,r,a)},Mt;st&&typeof st.ownKeys=="function"?Mt=st.ownKeys:Object.getOwnPropertySymbols?Mt=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Mt=function(t){return Object.getOwnPropertyNames(t)};function ta(e){console&&console.warn&&console.warn(e)}var kn=Number.isNaN||function(t){return t!==t};function V(){V.init.call(this)}Lr.exports=V;Lr.exports.once=aa;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||kn(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||kn(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 Cn(e){return e._maxListeners===void 0?V.defaultMaxListeners:e._maxListeners}V.prototype.getMaxListeners=function(){return Cn(this)};V.prototype.emit=function(t){for(var r=[],a=1;a<arguments.length;a++)r.push(arguments[a]);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")Wr(p,this,r);else for(var w=p.length,m=Fn(p,w),a=0;a<w;++a)Wr(m[a],this,r);return!0};function On(e,t,r,a){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]=a?[r,c]:[c,r]:a?c.unshift(r):c.push(r),o=Cn(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,ta(u)}return e}V.prototype.addListener=function(t,r){return On(this,t,r,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(t,r){return On(this,t,r,!0)};function ra(){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 Ln(e,t,r){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=ra.bind(a);return o.listener=r,a.wrapFn=o,o}V.prototype.once=function(t,r){return Kt(r),this.on(t,Ln(this,t,r)),this};V.prototype.prependOnceListener=function(t,r){return Kt(r),this.prependListener(t,Ln(this,t,r)),this};V.prototype.removeListener=function(t,r){var a,o,s,c,u;if(Kt(r),o=this._events,o===void 0)return this;if(a=o[t],a===void 0)return this;if(a===r||a.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,a.listener||r));else if(typeof a!="function"){for(s=-1,c=a.length-1;c>=0;c--)if(a[c]===r||a[c].listener===r){u=a[c].listener,s=c;break}if(s<0)return this;s===0?a.shift():na(a,s),a.length===1&&(o[t]=a[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,a,o;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[t]),this;if(arguments.length===0){var s=Object.keys(a),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=a[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 Mn(e,t,r){var a=e._events;if(a===void 0)return[];var o=a[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?ia(o):Fn(o,o.length)}V.prototype.listeners=function(t){return Mn(this,t,!0)};V.prototype.rawListeners=function(t){return Mn(this,t,!1)};V.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Pn.call(e,t)};V.prototype.listenerCount=Pn;function Pn(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?Mt(this._events):[]};function Fn(e,t){for(var r=new Array(t),a=0;a<t;++a)r[a]=e[a];return r}function na(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function ia(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function aa(e,t){return new Promise(function(r,a){function o(c){e.removeListener(t,s),a(c)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}Nn(e,t,s,{once:!0}),t!=="error"&&oa(e,o,{once:!0})})}function oa(e,t,r){typeof e.on=="function"&&Nn(e,"error",t,r)}function Nn(e,t,r,a){if(typeof e.on=="function")a.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function o(s){a.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=Lr.exports,Dn=Un.EventEmitter;const sa={},fa=Object.freeze(Object.defineProperty({__proto__:null,default:sa},Symbol.toStringTag,{value:"Module"})),Mr=Mi(fa);var or,Gr;function ua(){if(Gr)return or;Gr=1;function e(R,k){var A=Object.keys(R);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(R);k&&(I=I.filter(function(M){return Object.getOwnPropertyDescriptor(R,M).enumerable})),A.push.apply(A,I)}return A}function t(R){for(var k=1;k<arguments.length;k++){var A=arguments[k]!=null?arguments[k]:{};k%2?e(Object(A),!0).forEach(function(I){r(R,I,A[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(A)):e(Object(A)).forEach(function(I){Object.defineProperty(R,I,Object.getOwnPropertyDescriptor(A,I))})}return R}function r(R,k,A){return k=c(k),k in R?Object.defineProperty(R,k,{value:A,enumerable:!0,configurable:!0,writable:!0}):R[k]=A,R}function a(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")}function o(R,k){for(var A=0;A<k.length;A++){var I=k[A];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(R,c(I.key),I)}}function s(R,k,A){return k&&o(R.prototype,k),Object.defineProperty(R,"prototype",{writable:!1}),R}function c(R){var k=u(R,"string");return typeof k=="symbol"?k:String(k)}function u(R,k){if(typeof R!="object"||R===null)return R;var A=R[Symbol.toPrimitive];if(A!==void 0){var I=A.call(R,k||"default");if(typeof I!="object")return I;throw new TypeError("@@toPrimitive must return a primitive value.")}return(k==="string"?String:Number)(R)}var p=ht,w=p.Buffer,m=Mr,v=m.inspect,T=v&&v.custom||"inspect";function C(R,k,A){w.prototype.copy.call(R,k,A)}return or=function(){function R(){a(this,R),this.head=null,this.tail=null,this.length=0}return s(R,[{key:"push",value:function(A){var I={data:A,next:null};this.length>0?this.tail.next=I:this.head=I,this.tail=I,++this.length}},{key:"unshift",value:function(A){var I={data:A,next:this.head};this.length===0&&(this.tail=I),this.head=I,++this.length}},{key:"shift",value:function(){if(this.length!==0){var A=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,A}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(A){if(this.length===0)return"";for(var I=this.head,M=""+I.data;I=I.next;)M+=A+I.data;return M}},{key:"concat",value:function(A){if(this.length===0)return w.alloc(0);for(var I=w.allocUnsafe(A>>>0),M=this.head,P=0;M;)C(M.data,I,P),P+=M.data.length,M=M.next;return I}},{key:"consume",value:function(A,I){var M;return A<this.head.data.length?(M=this.head.data.slice(0,A),this.head.data=this.head.data.slice(A)):A===this.head.data.length?M=this.shift():M=I?this._getString(A):this._getBuffer(A),M}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(A){var I=this.head,M=1,P=I.data;for(A-=P.length;I=I.next;){var L=I.data,N=A>L.length?L.length:A;if(N===L.length?P+=L:P+=L.slice(0,A),A-=N,A===0){N===L.length?(++M,I.next?this.head=I.next:this.head=this.tail=null):(this.head=I,I.data=L.slice(N));break}++M}return this.length-=M,P}},{key:"_getBuffer",value:function(A){var I=w.allocUnsafe(A),M=this.head,P=1;for(M.data.copy(I),A-=M.data.length;M=M.next;){var L=M.data,N=A>L.length?L.length:A;if(L.copy(I,I.length-A,0,N),A-=N,A===0){N===L.length?(++P,M.next?this.head=M.next:this.head=this.tail=null):(this.head=M,M.data=L.slice(N));break}++P}return this.length-=P,I}},{key:T,value:function(A,I){return v(this,t(t({},I),{},{depth:0,customInspect:!1}))}}]),R}(),or}function ca(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||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(Pt,r):(r._writableState.errorEmitted=!0,process.nextTick(Vr,r,s)):process.nextTick(Vr,r,s):t?(process.nextTick(Pt,r),t(s)):process.nextTick(Pt,r)}),this)}function Vr(e,t){Br(e,t),Pt(e)}function Pt(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function la(){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 ha(e,t){var r=e._readableState,a=e._writableState;r&&r.autoDestroy||a&&a.autoDestroy?e.destroy(t):e.emit("error",t)}var $n={destroy:ca,undestroy:la,errorOrDestroy:ha},Ze={};function da(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Hn={};function Ae(e,t,r){r||(r=Error);function a(s,c,u){return typeof t=="string"?t:t(s,c,u)}var o=function(s){da(c,s);function c(u,p,w){return s.call(this,a(u,p,w))||this}return c}(r);o.prototype.name=r.name,o.prototype.code=e,Hn[e]=o}function zr(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(a){return String(a)}),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 pa(e,t,r){return e.substr(0,t.length)===t}function ba(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function ya(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 a;typeof t=="string"&&pa(t,"not ")?(a="must not be",t=t.replace(/^not /,"")):a="must be";var o;if(ba(e," argument"))o="The ".concat(e," ").concat(a," ").concat(zr(t,"type"));else{var s=ya(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(a," ").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=Hn;var _a=Ze.codes.ERR_INVALID_OPT_VALUE;function ga(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function wa(e,t,r,a){var o=ga(t,a,r);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var s=a?r:"highWaterMark";throw new _a(s,o)}return Math.floor(o)}return e.objectMode?16:16*1024}var jn={getHighWaterMark:wa},ma=va;function va(e,t){if(sr("noDeprecation"))return e;var r=!1;function a(){if(!r){if(sr("throwDeprecation"))throw new Error(t);sr("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return a}function sr(e){try{if(!Ge.localStorage)return!1}catch{return!1}var t=Ge.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var fr,Jr;function qn(){if(Jr)return fr;Jr=1,fr=U;function e(_){var y=this;this.next=null,this.entry=null,this.finish=function(){Me(y,_)}}var t;U.WritableState=E;var r={deprecate:ma},a=Dn,o=ht.Buffer,s=(typeof Ge<"u"?Ge:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(_){return o.from(_)}function u(_){return o.isBuffer(_)||_ instanceof s}var p=$n,w=jn,m=w.getHighWaterMark,v=Ze.codes,T=v.ERR_INVALID_ARG_TYPE,C=v.ERR_METHOD_NOT_IMPLEMENTED,R=v.ERR_MULTIPLE_CALLBACK,k=v.ERR_STREAM_CANNOT_PIPE,A=v.ERR_STREAM_DESTROYED,I=v.ERR_STREAM_NULL_VALUES,M=v.ERR_STREAM_WRITE_AFTER_END,P=v.ERR_UNKNOWN_ENCODING,L=p.errorOrDestroy;be(U,a);function N(){}function E(_,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 D=_.decodeStrings===!1;this.decodeStrings=!D,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(q){ze(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)}E.prototype.getBuffer=function(){for(var y=this.bufferedRequest,S=[];y;)S.push(y),y=y.next;return S},function(){try{Object.defineProperty(E.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(U,Symbol.hasInstance,{value:function(y){return j.call(this,y)?!0:this!==U?!1:y&&y._writableState instanceof E}})):j=function(y){return y instanceof this};function U(_){t=t||lt();var y=this instanceof t;if(!y&&!j.call(U,this))return new U(_);this._writableState=new E(_,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)),a.call(this)}U.prototype.pipe=function(){L(this,new k)};function $(_,y){var S=new M;L(_,S),process.nextTick(y,S)}function ne(_,y,S,D){var q;return S===null?q=new I:typeof S!="string"&&!y.objectMode&&(q=new T("chunk",["string","Buffer"],S)),q?(L(_,q),process.nextTick(D,q),!1):!0}U.prototype.write=function(_,y,S){var D=this._writableState,q=!1,h=!D.objectMode&&u(_);return h&&!o.isBuffer(_)&&(_=c(_)),typeof y=="function"&&(S=y,y=null),h?y="buffer":y||(y=D.defaultEncoding),typeof S!="function"&&(S=N),D.ending?$(this,S):(h||ne(this,D,_,S))&&(D.pendingcb++,q=$e(this,D,h,_,y,S)),q},U.prototype.cork=function(){this._writableState.corked++},U.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&ke(this,_))},U.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(U.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(U.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function $e(_,y,S,D,q,h){if(!S){var d=Te(y,D,q);D!==d&&(S=!0,q="buffer",D=d)}var B=y.objectMode?1:D.length;y.length+=B;var F=y.length<y.highWaterMark;if(F||(y.needDrain=!0),y.writing||y.corked){var Q=y.lastBufferedRequest;y.lastBufferedRequest={chunk:D,encoding:q,isBuf:S,callback:h,next:null},Q?Q.next=y.lastBufferedRequest:y.bufferedRequest=y.lastBufferedRequest,y.bufferedRequestCount+=1}else oe(_,y,!1,B,D,q,h);return F}function oe(_,y,S,D,q,h,d){y.writelen=D,y.writecb=d,y.writing=!0,y.sync=!0,y.destroyed?y.onwrite(new A("write")):S?_._writev(q,y.onwrite):_._write(q,h,y.onwrite),y.sync=!1}function me(_,y,S,D,q){--y.pendingcb,S?(process.nextTick(q,D),process.nextTick(Ee,_,y),_._writableState.errorEmitted=!0,L(_,D)):(q(D),_._writableState.errorEmitted=!0,L(_,D),Ee(_,y))}function ve(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function ze(_,y){var S=_._writableState,D=S.sync,q=S.writecb;if(typeof q!="function")throw new R;if(ve(S),y)me(_,S,D,y,q);else{var h=je(S)||_.destroyed;!h&&!S.corked&&!S.bufferProcessing&&S.bufferedRequest&&ke(_,S),D?process.nextTick(Ie,_,S,h,q):Ie(_,S,h,q)}}function Ie(_,y,S,D){S||He(_,y),y.pendingcb--,D(),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 D=y.bufferedRequestCount,q=new Array(D),h=y.corkedRequestsFree;h.entry=S;for(var d=0,B=!0;S;)q[d]=S,S.isBuf||(B=!1),S=S.next,d+=1;q.allBuffers=B,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 F=S.chunk,Q=S.encoding,W=S.callback,G=y.objectMode?1:F.length;if(oe(_,y,!1,G,F,Q,W),S=S.next,y.bufferedRequestCount--,y.writing)break}S===null&&(y.lastBufferedRequest=null)}y.bufferedRequest=S,y.bufferProcessing=!1}U.prototype._write=function(_,y,S){S(new C("_write()"))},U.prototype._writev=null,U.prototype.end=function(_,y,S){var D=this._writableState;return typeof _=="function"?(S=_,_=null,y=null):typeof y=="function"&&(S=y,y=null),_!=null&&this.write(_,y),D.corked&&(D.corked=1,this.uncork()),D.ending||qe(this,D,S),this},Object.defineProperty(U.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function je(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function X(_,y){_._final(function(S){y.pendingcb--,S&&L(_,S),y.prefinished=!0,_.emit("prefinish"),Ee(_,y)})}function ie(_,y){!y.prefinished&&!y.finalCalled&&(typeof _._final=="function"&&!y.destroyed?(y.pendingcb++,y.finalCalled=!0,process.nextTick(X,_,y)):(y.prefinished=!0,_.emit("prefinish")))}function Ee(_,y){var S=je(y);if(S&&(ie(_,y),y.pendingcb===0&&(y.finished=!0,_.emit("finish"),y.autoDestroy))){var D=_._readableState;(!D||D.autoDestroy&&D.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 Me(_,y,S){var D=_.entry;for(_.entry=null;D;){var q=D.callback;y.pendingcb--,q(S),D=D.next}y.corkedRequestsFree.next=_}return Object.defineProperty(U.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(y){this._writableState&&(this._writableState.destroyed=y)}}),U.prototype.destroy=p.destroy,U.prototype._undestroy=p.undestroy,U.prototype._destroy=function(_,y){y(_)},fr}var ur,Yr;function lt(){if(Yr)return ur;Yr=1;var e=Object.keys||function(w){var m=[];for(var v in w)m.push(v);return m};ur=c;var t=Kn(),r=qn();be(c,t);for(var a=e(r.prototype),o=0;o<a.length;o++){var s=a[o];c.prototype[s]||(c.prototype[s]=r.prototype[s])}function c(w){if(!(this instanceof c))return new c(w);t.call(this,w),r.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.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(w){w.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)}}),ur}var $t={},Pr=xe.Buffer,Xr=Pr.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 xa(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 Ea(e){var t=xa(e);if(typeof t!="string"&&(Pr.isEncoding===Xr||!Xr(e)))throw new Error("Unknown encoding: "+e);return t||e}$t.StringDecoder=At;function At(e){this.encoding=Ea(e);var t;switch(this.encoding){case"utf16le":this.text=Ia,this.end=ka,t=4;break;case"utf8":this.fillLast=Sa,t=4;break;case"base64":this.text=Ca,this.end=Oa,t=3;break;default:this.write=La,this.end=Ma;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Pr.allocUnsafe(t)}At.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||""};At.prototype.end=Ta;At.prototype.text=Aa;At.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 cr(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Ba(e,t,r){var a=t.length-1;if(a<r)return 0;var o=cr(t[a]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--a<r||o===-2?0:(o=cr(t[a]),o>=0?(o>0&&(e.lastNeed=o-2),o):--a<r||o===-2?0:(o=cr(t[a]),o>=0?(o>0&&(o===2?o=0:e.lastNeed=o-3),o):0))}function Ra(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 Sa(e){var t=this.lastTotal-this.lastNeed,r=Ra(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 Aa(e,t){var r=Ba(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var a=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString("utf8",t,a)}function Ta(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function Ia(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var a=r.charCodeAt(r.length-1);if(a>=55296&&a<=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 ka(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 Ca(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 Oa(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function La(e){return e.toString(this.encoding)}function Ma(e){return e&&e.length?this.write(e):""}var Qr=Ze.codes.ERR_STREAM_PREMATURE_CLOSE;function Pa(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];e.apply(this,a)}}}function Fa(){}function Na(e){return e.setHeader&&typeof e.abort=="function"}function Wn(e,t,r){if(typeof t=="function")return Wn(e,null,t);t||(t={}),r=Pa(r||Fa);var a=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,a||r.call(e)},p=e._readableState&&e._readableState.endEmitted,w=function(){a=!1,p=!0,o||r.call(e)},m=function(R){r.call(e,R)},v=function(){var R;if(a&&!p)return(!e._readableState||!e._readableState.ended)&&(R=new Qr),r.call(e,R);if(o&&!c)return(!e._writableState||!e._writableState.ended)&&(R=new Qr),r.call(e,R)},T=function(){e.req.on("finish",u)};return Na(e)?(e.on("complete",u),e.on("abort",v),e.req?T():e.on("request",T)):o&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",w),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",T),e.req&&e.req.removeListener("finish",u),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",u),e.removeListener("end",w),e.removeListener("error",m),e.removeListener("close",v)}}var Fr=Wn,lr,Zr;function Ua(){if(Zr)return lr;Zr=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=a(P,"string");return typeof L=="symbol"?L:String(L)}function a(P,L){if(typeof P!="object"||P===null)return P;var N=P[Symbol.toPrimitive];if(N!==void 0){var E=N.call(P,L||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(L==="string"?String:Number)(P)}var o=Fr,s=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),p=Symbol("ended"),w=Symbol("lastPromise"),m=Symbol("handlePromise"),v=Symbol("stream");function T(P,L){return{value:P,done:L}}function C(P){var L=P[s];if(L!==null){var N=P[v].read();N!==null&&(P[w]=null,P[s]=null,P[c]=null,L(T(N,!1)))}}function R(P){process.nextTick(C,P)}function k(P,L){return function(N,E){P.then(function(){if(L[p]){N(T(void 0,!0));return}L[m](N,E)},E)}}var A=Object.getPrototypeOf(function(){}),I=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(T(void 0,!0));if(this[v].destroyed)return new Promise(function($,ne){process.nextTick(function(){L[u]?ne(L[u]):$(T(void 0,!0))})});var E=this[w],j;if(E)j=new Promise(k(E,this));else{var U=this[v].read();if(U!==null)return Promise.resolve(T(U,!1));j=new Promise(this[m])}return this[w]=j,j}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var L=this;return new Promise(function(N,E){L[v].destroy(null,function(j){if(j){E(j);return}N(T(void 0,!0))})})}),e),A),M=function(L){var N,E=Object.create(I,(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(U,$){var ne=E[v].read();ne?(E[w]=null,E[s]=null,E[c]=null,U(T(ne,!1))):(E[s]=U,E[c]=$)},writable:!0}),N));return E[w]=null,o(L,function(j){if(j&&j.code!=="ERR_STREAM_PREMATURE_CLOSE"){var U=E[c];U!==null&&(E[w]=null,E[s]=null,E[c]=null,U(j)),E[u]=j;return}var $=E[s];$!==null&&(E[w]=null,E[s]=null,E[c]=null,$(T(void 0,!0))),E[p]=!0}),L.on("readable",R.bind(null,E)),E};return lr=M,lr}var hr,en;function Da(){return en||(en=1,hr=function(){throw new Error("Readable.from is not available in the browser")}),hr}var dr,tn;function Kn(){if(tn)return dr;tn=1,dr=$;var e;$.ReadableState=U,Un.EventEmitter;var t=function(d,B){return d.listeners(B).length},r=Dn,a=ht.Buffer,o=(typeof Ge<"u"?Ge:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(h){return a.from(h)}function c(h){return a.isBuffer(h)||h instanceof o}var u=Mr,p;u&&u.debuglog?p=u.debuglog("stream"):p=function(){};var w=ua(),m=$n,v=jn,T=v.getHighWaterMark,C=Ze.codes,R=C.ERR_INVALID_ARG_TYPE,k=C.ERR_STREAM_PUSH_AFTER_EOF,A=C.ERR_METHOD_NOT_IMPLEMENTED,I=C.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,M,P,L;be($,r);var N=m.errorOrDestroy,E=["error","close","destroy","pause","resume"];function j(h,d,B){if(typeof h.prependListener=="function")return h.prependListener(d,B);!h._events||!h._events[d]?h.on(d,B):Array.isArray(h._events[d])?h._events[d].unshift(B):h._events[d]=[B,h._events[d]]}function U(h,d,B){e=e||lt(),h=h||{},typeof B!="boolean"&&(B=d instanceof e),this.objectMode=!!h.objectMode,B&&(this.objectMode=this.objectMode||!!h.readableObjectMode),this.highWaterMark=T(this,h,"readableHighWaterMark",B),this.buffer=new w,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&&(M||(M=$t.StringDecoder),this.decoder=new M(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 U(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 B=this._readableState,F;return B.objectMode?F=!0:typeof h=="string"&&(d=d||B.defaultEncoding,d!==B.encoding&&(h=a.from(h,d),d=""),F=!0),ne(this,h,d,!1,F)},$.prototype.unshift=function(h){return ne(this,h,null,!0,!1)};function ne(h,d,B,F,Q){p("readableAddChunk",d);var W=h._readableState;if(d===null)W.reading=!1,ze(h,W);else{var G;if(Q||(G=$e(W,d)),G)N(h,G);else if(W.objectMode||d&&d.length>0)if(typeof d!="string"&&!W.objectMode&&Object.getPrototypeOf(d)!==a.prototype&&(d=s(d)),F)W.endEmitted?N(h,new I):Te(h,W,d,!0);else if(W.ended)N(h,new k);else{if(W.destroyed)return!1;W.reading=!1,W.decoder&&!B?(d=W.decoder.write(d),W.objectMode||d.length!==0?Te(h,W,d,!1):ke(h,W)):Te(h,W,d,!1)}else F||(W.reading=!1,ke(h,W))}return!W.ended&&(W.length<W.highWaterMark||W.length===0)}function Te(h,d,B,F){d.flowing&&d.length===0&&!d.sync?(d.awaitDrain=0,h.emit("data",B)):(d.length+=d.objectMode?1:B.length,F?d.buffer.unshift(B):d.buffer.push(B),d.needReadable&&Ie(h)),ke(h,d)}function $e(h,d){var B;return!c(d)&&typeof d!="string"&&d!==void 0&&!h.objectMode&&(B=new R("chunk",["string","Buffer","Uint8Array"],d)),B}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(h){M||(M=$t.StringDecoder);var d=new M(h);this._readableState.decoder=d,this._readableState.encoding=this._readableState.decoder.encoding;for(var B=this._readableState.buffer.head,F="";B!==null;)F+=d.write(B.data),B=B.next;return this._readableState.buffer.clear(),F!==""&&this._readableState.buffer.push(F),this._readableState.length=F.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,B=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 F=d.needReadable;p("need readable",F),(d.length===0||d.length-h<d.highWaterMark)&&(F=!0,p("length less than watermark",F)),d.ended||d.reading?(F=!1,p("reading or ended",F)):F&&(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(B,d)));var Q;return h>0?Q=y(h,d):Q=null,Q===null?(d.needReadable=d.length<=d.highWaterMark,h=0):(d.length-=h,d.awaitDrain=0),d.length===0&&(d.ended||(d.needReadable=!0),B!==h&&d.ended&&S(this)),Q!==null&&this.emit("data",Q),Q};function ze(h,d){if(p("onEofChunk"),!d.ended){if(d.decoder){var B=d.decoder.end();B&&B.length&&(d.buffer.push(B),d.length+=d.objectMode?1:B.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 B=d.length;if(p("maybeReadMore read 0"),h.read(0),B===d.length)break}d.readingMore=!1}$.prototype._read=function(h){N(this,new A("_read()"))},$.prototype.pipe=function(h,d){var B=this,F=this._readableState;switch(F.pipesCount){case 0:F.pipes=h;break;case 1:F.pipes=[F.pipes,h];break;default:F.pipes.push(h);break}F.pipesCount+=1,p("pipe count=%d opts=%j",F.pipesCount,d);var Q=(!d||d.end!==!1)&&h!==process.stdout&&h!==process.stderr,W=Q?We:Ye;F.endEmitted?process.nextTick(W):B.once("end",W),h.on("unpipe",G);function G(f,n){p("onunpipe"),f===B&&n&&n.hasUnpiped===!1&&(n.hasUnpiped=!0,rt())}function We(){p("onend"),h.end()}var tt=X(B);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",Je),h.removeListener("unpipe",G),B.removeListener("end",We),B.removeListener("end",Ye),B.removeListener("data",Be),pt=!0,F.awaitDrain&&(!h._writableState||h._writableState.needDrain)&&tt()}B.on("data",Be);function Be(f){p("ondata");var n=h.write(f);p("dest.write",n),n===!1&&((F.pipesCount===1&&F.pipes===h||F.pipesCount>1&&q(F.pipes,h)!==-1)&&!pt&&(p("false write response, pause",F.awaitDrain),F.awaitDrain++),B.pause())}function Je(f){p("onerror",f),Ye(),h.removeListener("error",Je),t(h,"error")===0&&N(h,f)}j(h,"error",Je);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"),B.unpipe(h)}return h.emit("pipe",B),F.flowing||(p("pipe resume"),B.resume()),h};function X(h){return function(){var B=h._readableState;p("pipeOnDrain",B.awaitDrain),B.awaitDrain&&B.awaitDrain--,B.awaitDrain===0&&t(h,"data")&&(B.flowing=!0,_(h))}}$.prototype.unpipe=function(h){var d=this._readableState,B={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,B),this);if(!h){var F=d.pipes,Q=d.pipesCount;d.pipes=null,d.pipesCount=0,d.flowing=!1;for(var W=0;W<Q;W++)F[W].emit("unpipe",this,{hasUnpiped:!1});return this}var G=q(d.pipes,h);return G===-1?this:(d.pipes.splice(G,1),d.pipesCount-=1,d.pipesCount===1&&(d.pipes=d.pipes[0]),h.emit("unpipe",this,B),this)},$.prototype.on=function(h,d){var B=r.prototype.on.call(this,h,d),F=this._readableState;return h==="data"?(F.readableListening=this.listenerCount("readable")>0,F.flowing!==!1&&this.resume()):h==="readable"&&!F.endEmitted&&!F.readableListening&&(F.readableListening=F.needReadable=!0,F.flowing=!1,F.emittedReadable=!1,p("on readable",F.length,F.reading),F.length?Ie(this):F.reading||process.nextTick(Ee,this)),B},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(h,d){var B=r.prototype.removeListener.call(this,h,d);return h==="readable"&&process.nextTick(ie,this),B},$.prototype.removeAllListeners=function(h){var d=r.prototype.removeAllListeners.apply(this,arguments);return(h==="readable"||h===void 0)&&process.nextTick(ie,this),d};function ie(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(Me,h,d))}function Me(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,B=this._readableState,F=!1;h.on("end",function(){if(p("wrapped end"),B.decoder&&!B.ended){var G=B.decoder.end();G&&G.length&&d.push(G)}d.push(null)}),h.on("data",function(G){if(p("wrapped data"),B.decoder&&(G=B.decoder.write(G)),!(B.objectMode&&G==null)&&!(!B.objectMode&&(!G||!G.length))){var We=d.push(G);We||(F=!0,h.pause())}});for(var Q in h)this[Q]===void 0&&typeof h[Q]=="function"&&(this[Q]=function(We){return function(){return h[We].apply(h,arguments)}}(Q));for(var W=0;W<E.length;W++)h.on(E[W],this.emit.bind(this,E[W]));return this._read=function(G){p("wrapped _read",G),F&&(F=!1,h.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return P===void 0&&(P=Ua()),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 B;return d.objectMode?B=d.buffer.shift():!h||h>=d.length?(d.decoder?B=d.buffer.join(""):d.buffer.length===1?B=d.buffer.first():B=d.buffer.concat(d.length),d.buffer.clear()):B=d.buffer.consume(h,d.decoder),B}function S(h){var d=h._readableState;p("endReadable",d.endEmitted),d.endEmitted||(d.ended=!0,process.nextTick(D,d,h))}function D(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 B=d._writableState;(!B||B.autoDestroy&&B.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 B=0,F=h.length;B<F;B++)if(h[B]===d)return B;return-1}return dr}var Gn=De,Gt=Ze.codes,$a=Gt.ERR_METHOD_NOT_IMPLEMENTED,Ha=Gt.ERR_MULTIPLE_CALLBACK,ja=Gt.ERR_TRANSFORM_ALREADY_TRANSFORMING,qa=Gt.ERR_TRANSFORM_WITH_LENGTH_0,Vt=lt();be(De,Vt);function Wa(e,t){var r=this._transformState;r.transforming=!1;var a=r.writecb;if(a===null)return this.emit("error",new Ha);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),a(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function De(e){if(!(this instanceof De))return new De(e);Vt.call(this,e),this._transformState={afterTransform:Wa.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",Ka)}function Ka(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){rn(e,t,r)}):rn(this,null,null)}De.prototype.push=function(e,t){return this._transformState.needTransform=!1,Vt.prototype.push.call(this,e,t)};De.prototype._transform=function(e,t,r){r(new $a("_transform()"))};De.prototype._write=function(e,t,r){var a=this._transformState;if(a.writecb=r,a.writechunk=e,a.writeencoding=t,!a.transforming){var o=this._readableState;(a.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}};De.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};De.prototype._destroy=function(e,t){Vt.prototype._destroy.call(this,e,function(r){t(r)})};function rn(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new qa;if(e._transformState.transforming)throw new ja;return e.push(null)}var Ga=Rt,Vn=Gn;be(Rt,Vn);function Rt(e){if(!(this instanceof Rt))return new Rt(e);Vn.call(this,e)}Rt.prototype._transform=function(e,t,r){r(null,e)};var pr;function Va(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var zn=Ze.codes,za=zn.ERR_MISSING_ARGS,Ja=zn.ERR_STREAM_DESTROYED;function nn(e){if(e)throw e}function Ya(e){return e.setHeader&&typeof e.abort=="function"}function Xa(e,t,r,a){a=Va(a);var o=!1;e.on("close",function(){o=!0}),pr===void 0&&(pr=Fr),pr(e,{readable:t,writable:r},function(c){if(c)return a(c);o=!0,a()});var s=!1;return function(c){if(!o&&!s){if(s=!0,Ya(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();a(c||new Ja("pipe"))}}}function an(e){e()}function Qa(e,t){return e.pipe(t)}function Za(e){return!e.length||typeof e[e.length-1]!="function"?nn:e.pop()}function eo(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=Za(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new za("streams");var o,s=t.map(function(c,u){var p=u<t.length-1,w=u>0;return Xa(c,p,w,function(m){o||(o=m),m&&s.forEach(an),!p&&(s.forEach(an),a(o))})});return t.reduce(Qa)}var to=eo;(function(e,t){t=e.exports=Kn(),t.Stream=t,t.Readable=t,t.Writable=qn(),t.Duplex=lt(),t.Transform=Gn,t.PassThrough=Ga,t.finished=Fr,t.pipeline=to})(Er,Er.exports);var ro=Er.exports,Ht=xe.Buffer,Jn=ro.Transform,no=be;function io(e,t){if(!Ht.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function Ve(e){Jn.call(this),this._block=Ht.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}no(Ve,Jn);Ve.prototype._transform=function(e,t,r){var a=null;try{this.update(e,t)}catch(o){a=o}r(a)};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(io(e,"Data"),this._finalized)throw new Error("Digest already called");Ht.isBuffer(e)||(e=Ht.from(e,t));for(var r=this._block,a=0;this._blockOffset+e.length-a>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=e[a++];this._update(),this._blockOffset=0}for(;a<e.length;)r[this._blockOffset++]=e[a++];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 Yn=Ve,ao=be,Xn=Yn,oo=xe.Buffer,so=new Array(16);function zt(){Xn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}ao(zt,Xn);zt.prototype._update=function(){for(var e=so,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,a=this._b,o=this._c,s=this._d;r=ue(r,a,o,s,e[0],3614090360,7),s=ue(s,r,a,o,e[1],3905402710,12),o=ue(o,s,r,a,e[2],606105819,17),a=ue(a,o,s,r,e[3],3250441966,22),r=ue(r,a,o,s,e[4],4118548399,7),s=ue(s,r,a,o,e[5],1200080426,12),o=ue(o,s,r,a,e[6],2821735955,17),a=ue(a,o,s,r,e[7],4249261313,22),r=ue(r,a,o,s,e[8],1770035416,7),s=ue(s,r,a,o,e[9],2336552879,12),o=ue(o,s,r,a,e[10],4294925233,17),a=ue(a,o,s,r,e[11],2304563134,22),r=ue(r,a,o,s,e[12],1804603682,7),s=ue(s,r,a,o,e[13],4254626195,12),o=ue(o,s,r,a,e[14],2792965006,17),a=ue(a,o,s,r,e[15],1236535329,22),r=ce(r,a,o,s,e[1],4129170786,5),s=ce(s,r,a,o,e[6],3225465664,9),o=ce(o,s,r,a,e[11],643717713,14),a=ce(a,o,s,r,e[0],3921069994,20),r=ce(r,a,o,s,e[5],3593408605,5),s=ce(s,r,a,o,e[10],38016083,9),o=ce(o,s,r,a,e[15],3634488961,14),a=ce(a,o,s,r,e[4],3889429448,20),r=ce(r,a,o,s,e[9],568446438,5),s=ce(s,r,a,o,e[14],3275163606,9),o=ce(o,s,r,a,e[3],4107603335,14),a=ce(a,o,s,r,e[8],1163531501,20),r=ce(r,a,o,s,e[13],2850285829,5),s=ce(s,r,a,o,e[2],4243563512,9),o=ce(o,s,r,a,e[7],1735328473,14),a=ce(a,o,s,r,e[12],2368359562,20),r=le(r,a,o,s,e[5],4294588738,4),s=le(s,r,a,o,e[8],2272392833,11),o=le(o,s,r,a,e[11],1839030562,16),a=le(a,o,s,r,e[14],4259657740,23),r=le(r,a,o,s,e[1],2763975236,4),s=le(s,r,a,o,e[4],1272893353,11),o=le(o,s,r,a,e[7],4139469664,16),a=le(a,o,s,r,e[10],3200236656,23),r=le(r,a,o,s,e[13],681279174,4),s=le(s,r,a,o,e[0],3936430074,11),o=le(o,s,r,a,e[3],3572445317,16),a=le(a,o,s,r,e[6],76029189,23),r=le(r,a,o,s,e[9],3654602809,4),s=le(s,r,a,o,e[12],3873151461,11),o=le(o,s,r,a,e[15],530742520,16),a=le(a,o,s,r,e[2],3299628645,23),r=he(r,a,o,s,e[0],4096336452,6),s=he(s,r,a,o,e[7],1126891415,10),o=he(o,s,r,a,e[14],2878612391,15),a=he(a,o,s,r,e[5],4237533241,21),r=he(r,a,o,s,e[12],1700485571,6),s=he(s,r,a,o,e[3],2399980690,10),o=he(o,s,r,a,e[10],4293915773,15),a=he(a,o,s,r,e[1],2240044497,21),r=he(r,a,o,s,e[8],1873313359,6),s=he(s,r,a,o,e[15],4264355552,10),o=he(o,s,r,a,e[6],2734768916,15),a=he(a,o,s,r,e[13],1309151649,21),r=he(r,a,o,s,e[4],4149444226,6),s=he(s,r,a,o,e[11],3174756917,10),o=he(o,s,r,a,e[2],718787259,15),a=he(a,o,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+a|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=oo.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 Jt(e,t){return e<<t|e>>>32-t}function ue(e,t,r,a,o,s,c){return Jt(e+(t&r|~t&a)+o+s|0,c)+t|0}function ce(e,t,r,a,o,s,c){return Jt(e+(t&a|r&~a)+o+s|0,c)+t|0}function le(e,t,r,a,o,s,c){return Jt(e+(t^r^a)+o+s|0,c)+t|0}function he(e,t,r,a,o,s,c){return Jt(e+(r^(t|~a))+o+s|0,c)+t|0}var fo=zt,br=ht.Buffer,uo=be,Qn=Yn,co=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 Yt(){Qn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}uo(Yt,Qn);Yt.prototype._update=function(){for(var e=co,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,a=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=this._a|0,p=this._b|0,w=this._c|0,m=this._d|0,v=this._e|0,T=0;T<80;T+=1){var C,R;T<16?(C=on(r,a,o,s,c,e[gt[T]],xt[0],mt[T]),R=cn(u,p,w,m,v,e[wt[T]],Et[0],vt[T])):T<32?(C=sn(r,a,o,s,c,e[gt[T]],xt[1],mt[T]),R=un(u,p,w,m,v,e[wt[T]],Et[1],vt[T])):T<48?(C=fn(r,a,o,s,c,e[gt[T]],xt[2],mt[T]),R=fn(u,p,w,m,v,e[wt[T]],Et[2],vt[T])):T<64?(C=un(r,a,o,s,c,e[gt[T]],xt[3],mt[T]),R=sn(u,p,w,m,v,e[wt[T]],Et[3],vt[T])):(C=cn(r,a,o,s,c,e[gt[T]],xt[4],mt[T]),R=on(u,p,w,m,v,e[wt[T]],Et[4],vt[T])),r=c,c=s,s=Qe(o,10),o=a,a=C,u=v,v=m,m=Qe(w,10),w=p,p=R}var k=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+a+w|0,this._a=k};Yt.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=br.alloc?br.alloc(20):new br(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 on(e,t,r,a,o,s,c,u){return Qe(e+(t^r^a)+s+c|0,u)+o|0}function sn(e,t,r,a,o,s,c,u){return Qe(e+(t&r|~t&a)+s+c|0,u)+o|0}function fn(e,t,r,a,o,s,c,u){return Qe(e+((t|~r)^a)+s+c|0,u)+o|0}function un(e,t,r,a,o,s,c,u){return Qe(e+(t&a|r&~a)+s+c|0,u)+o|0}function cn(e,t,r,a,o,s,c,u){return Qe(e+(t^(r|~a))+s+c|0,u)+o|0}var lo=Yt,Zn={exports:{}},ei=xe.Buffer;function Xt(e,t){this._block=ei.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Xt.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=ei.from(e,t));for(var r=this._block,a=this._blockSize,o=e.length,s=this._len,c=0;c<o;){for(var u=s%a,p=Math.min(o-c,a-u),w=0;w<p;w++)r[u+w]=e[c+w];s+=p,c+=p,s%a===0&&this._update(r)}return this._len+=o,this};Xt.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 a=(r&4294967295)>>>0,o=(r-a)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(a,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};Xt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var dt=Xt,ho=be,ti=dt,po=xe.Buffer,bo=[1518500249,1859775393,-1894007588,-899497514],yo=new Array(80);function Tt(){this.init(),this._w=yo,ti.call(this,64,56)}ho(Tt,ti);Tt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function _o(e){return e<<5|e>>>27}function go(e){return e<<30|e>>>2}function wo(e,t,r,a){return e===0?t&r|~t&a:e===2?t&r|t&a|r&a:t^r^a}Tt.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=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 w=~~(p/20),m=_o(r)+wo(w,a,o,s)+c+t[p]+bo[w]|0;c=s,s=o,o=go(a),a=r,r=m}this._a=r+this._a|0,this._b=a+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0};Tt.prototype._hash=function(){var e=po.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 mo=Tt,vo=be,ri=dt,xo=xe.Buffer,Eo=[1518500249,1859775393,-1894007588,-899497514],Bo=new Array(80);function It(){this.init(),this._w=Bo,ri.call(this,64,56)}vo(It,ri);It.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Ro(e){return e<<1|e>>>31}function So(e){return e<<5|e>>>27}function Ao(e){return e<<30|e>>>2}function To(e,t,r,a){return e===0?t&r|~t&a:e===2?t&r|t&a|r&a:t^r^a}It.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=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]=Ro(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var w=~~(p/20),m=So(r)+To(w,a,o,s)+c+t[p]+Eo[w]|0;c=s,s=o,o=Ao(a),a=r,r=m}this._a=r+this._a|0,this._b=a+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=xo.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 Io=It,ko=be,ni=dt,Co=xe.Buffer,Oo=[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],Lo=new Array(64);function kt(){this.init(),this._w=Lo,ni.call(this,64,56)}ko(kt,ni);kt.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 Mo(e,t,r){return r^e&(t^r)}function Po(e,t,r){return e&t|r&(e|t)}function Fo(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function No(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Uo(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}kt.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=this._f|0,p=this._g|0,w=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]+Uo(t[m-15])+t[m-16]|0;for(var v=0;v<64;++v){var T=w+No(c)+Mo(c,u,p)+Oo[v]+t[v]|0,C=Fo(r)+Po(r,a,o)|0;w=p,p=u,u=c,c=s+T|0,s=o,o=a,a=r,r=T+C|0}this._a=r+this._a|0,this._b=a+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=w+this._h|0};kt.prototype._hash=function(){var e=Co.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 ii=kt,$o=be,Ho=ii,jo=dt,qo=xe.Buffer,Wo=new Array(64);function Qt(){this.init(),this._w=Wo,jo.call(this,64,56)}$o(Qt,Ho);Qt.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};Qt.prototype._hash=function(){var e=qo.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 Ko=Qt,Go=be,ai=dt,Vo=xe.Buffer,ln=[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],zo=new Array(160);function Ct(){this.init(),this._w=zo,ai.call(this,128,112)}Go(Ct,ai);Ct.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 hn(e,t,r){return r^e&(t^r)}function dn(e,t,r){return e&t|r&(e|t)}function pn(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function bn(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 Yo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Xo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Qo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function se(e,t){return e>>>0<t>>>0?1:0}Ct.prototype._update=function(e){for(var t=this._w,r=this._ah|0,a=this._bh|0,o=this._ch|0,s=this._dh|0,c=this._eh|0,u=this._fh|0,p=this._gh|0,w=this._hh|0,m=this._al|0,v=this._bl|0,T=this._cl|0,C=this._dl|0,R=this._el|0,k=this._fl|0,A=this._gl|0,I=this._hl|0,M=0;M<32;M+=2)t[M]=e.readInt32BE(M*4),t[M+1]=e.readInt32BE(M*4+4);for(;M<160;M+=2){var P=t[M-30],L=t[M-15*2+1],N=Jo(P,L),E=Yo(L,P);P=t[M-2*2],L=t[M-2*2+1];var j=Xo(P,L),U=Qo(L,P),$=t[M-7*2],ne=t[M-7*2+1],Te=t[M-16*2],$e=t[M-16*2+1],oe=E+ne|0,me=N+$+se(oe,E)|0;oe=oe+U|0,me=me+j+se(oe,U)|0,oe=oe+$e|0,me=me+Te+se(oe,$e)|0,t[M]=me,t[M+1]=oe}for(var ve=0;ve<160;ve+=2){me=t[ve],oe=t[ve+1];var ze=dn(r,a,o),Ie=dn(m,v,T),He=pn(r,m),ke=pn(m,r),je=bn(c,R),X=bn(R,c),ie=ln[ve],Ee=ln[ve+1],qe=hn(c,u,p),Me=hn(R,k,A),_=I+X|0,y=w+je+se(_,I)|0;_=_+Me|0,y=y+qe+se(_,Me)|0,_=_+Ee|0,y=y+ie+se(_,Ee)|0,_=_+oe|0,y=y+me+se(_,oe)|0;var S=ke+Ie|0,D=He+ze+se(S,ke)|0;w=p,I=A,p=u,A=k,u=c,k=R,R=C+_|0,c=s+y+se(R,C)|0,s=o,C=T,o=a,T=v,a=r,v=m,m=_+S|0,r=y+D+se(m,_)|0}this._al=this._al+m|0,this._bl=this._bl+v|0,this._cl=this._cl+T|0,this._dl=this._dl+C|0,this._el=this._el+R|0,this._fl=this._fl+k|0,this._gl=this._gl+A|0,this._hl=this._hl+I|0,this._ah=this._ah+r+se(this._al,m)|0,this._bh=this._bh+a+se(this._bl,v)|0,this._ch=this._ch+o+se(this._cl,T)|0,this._dh=this._dh+s+se(this._dl,C)|0,this._eh=this._eh+c+se(this._el,R)|0,this._fh=this._fh+u+se(this._fl,k)|0,this._gh=this._gh+p+se(this._gl,A)|0,this._hh=this._hh+w+se(this._hl,I)|0};Ct.prototype._hash=function(){var e=Vo.allocUnsafe(64);function t(r,a,o){e.writeInt32BE(r,o),e.writeInt32BE(a,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 oi=Ct,Zo=be,es=oi,ts=dt,rs=xe.Buffer,ns=new Array(160);function Zt(){this.init(),this._w=ns,ts.call(this,128,112)}Zo(Zt,es);Zt.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};Zt.prototype._hash=function(){var e=rs.allocUnsafe(48);function t(r,a,o){e.writeInt32BE(r,o),e.writeInt32BE(a,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 is=Zt,et=Zn.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=mo;et.sha1=Io;et.sha224=Ko;et.sha256=ii;et.sha384=is;et.sha512=oi;var as=Zn.exports,si=xe.Buffer,fi=Mr.Transform,os=$t.StringDecoder,ss=be;function Ce(e){fi.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}ss(Ce,fi);Ce.prototype.update=function(e,t,r){typeof e=="string"&&(e=si.from(e,t));var a=this._update(e);return this.hashMode?this:(r&&(a=this._toString(a,r)),a)};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 a;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(o){a=o}finally{r(a)}};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()||si.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Ce.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new os(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var a=this._decoder.write(e);return r&&(a+=this._decoder.end()),a};var fs=Ce,us=be,cs=fo,ls=lo,hs=as,ui=fs;function er(e){ui.call(this,"digest"),this._hash=e}us(er,ui);er.prototype._update=function(e){this._hash.update(e)};er.prototype._final=function(){return this._hash.digest()};var ds=function(t){return t=t.toLowerCase(),t==="md5"?new cs:t==="rmd160"||t==="ripemd160"?new ls:new er(hs(t))},Lt=xe.Buffer;function ps(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 a=0;a<e.length;a++){var o=e.charAt(a),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=a}var c=e.length,u=e.charAt(0),p=Math.log(c)/Math.log(256),w=Math.log(256)/Math.log(c);function m(C){if((Array.isArray(C)||C instanceof Uint8Array)&&(C=Lt.from(C)),!Lt.isBuffer(C))throw new TypeError("Expected Buffer");if(C.length===0)return"";for(var R=0,k=0,A=0,I=C.length;A!==I&&C[A]===0;)A++,R++;for(var M=(I-A)*w+1>>>0,P=new Uint8Array(M);A!==I;){for(var L=C[A],N=0,E=M-1;(L!==0||N<k)&&E!==-1;E--,N++)L+=256*P[E]>>>0,P[E]=L%c>>>0,L=L/c>>>0;if(L!==0)throw new Error("Non-zero carry");k=N,A++}for(var j=M-k;j!==M&&P[j]===0;)j++;for(var U=u.repeat(R);j<M;++j)U+=e.charAt(P[j]);return U}function v(C){if(typeof C!="string")throw new TypeError("Expected String");if(C.length===0)return Lt.alloc(0);for(var R=0,k=0,A=0;C[R]===u;)k++,R++;for(var I=(C.length-R)*p+1>>>0,M=new Uint8Array(I);R<C.length;){var P=t[C.charCodeAt(R)];if(P===255)return;for(var L=0,N=I-1;(P!==0||L<A)&&N!==-1;N--,L++)P+=c*M[N]>>>0,M[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");A=L,R++}for(var E=I-A;E!==I&&M[E]===0;)E++;var j=Lt.allocUnsafe(k+(I-E));j.fill(0,0,k);for(var U=k;E!==I;)j[U++]=M[E++];return j}function T(C){var R=v(C);if(R)return R;throw new Error("Non-base"+c+" character")}return{encode:m,decodeUnsafe:v,decode:T}}var bs=ps,ys=bs,_s="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",gs=ys(_s),yr=gs,ws=xe.Buffer,ms=function(e){function t(s){var c=e(s);return yr.encode(ws.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 a(s){var c=yr.decodeUnsafe(s);if(c)return r(c)}function o(s){var c=yr.decode(s),u=r(c);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:o,decodeUnsafe:a}},yn=ds,vs=ms;function xs(e){var t=yn("sha256").update(e).digest();return yn("sha256").update(t).digest()}var Es=vs(xs),Rr=Es;function ci(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 a=new Buffer(r?34:33);return a.writeUInt8(e,0),t.copy(a,1),r&&(a[33]=1),a}function Bs(e,t){return ci(Rr.decode(e),t)}function Rs(e,t,r){return typeof e=="number"?Rr.encode(Sr(e,t,r)):Rr.encode(Sr(e.version,e.privateKey,e.compressed))}var Ss={decode:Bs,decodeRaw:ci,encode:Rs,encodeRaw:Sr},tr={};Object.defineProperty(tr,"__esModule",{value:!0});tr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function As(e){Y(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),Y(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Y(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),Y(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),Y(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),Y(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),Y(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),Y(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),Y(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Y(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),Y(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),Y(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),Y(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),Y(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),Y(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));Y(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),Y(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),Y(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),Y(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&Y(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&Y(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}tr.testEcc=As;function Y(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 _e=En,Ts=ea,_n=Ss,Is=tr,_r=_e.typeforce.maybe(_e.typeforce.compile({compressed:_e.maybe(_e.Boolean),network:_e.maybe(_e.Network)})),ks=e=>e.length===32?e:e.slice(1,33);function Cs(e){(0,Is.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,p){if(_e.typeforce(_e.Buffer256bit,u),!e.isPrivate(u))throw new TypeError("Private key not in range [1, n)");return _e.typeforce(_r,p),new c(u,void 0,p)}function a(u,p){return _e.typeforce(e.isPoint,u),_e.typeforce(_r,p),new c(void 0,u,p)}function o(u,p){const w=_n.decode(u),m=w.version;if(_e.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(w.privateKey,{compressed:w.compressed,network:p})}function s(u){_e.typeforce(_r,u),u===void 0&&(u={});const p=u.rng||Ts;let w;do w=p(32),_e.typeforce(_e.Buffer256bit,w);while(!e.isPrivate(w));return r(w,u)}class c{constructor(p,w,m){nt(this,"__D");nt(this,"__Q");nt(this,"compressed");nt(this,"network");nt(this,"lowR");this.__D=p,this.__Q=w,this.lowR=!1,m===void 0&&(m={}),this.compressed=m.compressed===void 0?!0:m.compressed,this.network=m.network||Ar.bitcoin,w!==void 0&&(this.__Q=Buffer.from(e.pointCompress(w,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 _n.encode(this.network.wif,this.__D,this.compressed)}tweak(p){return this.privateKey?this.tweakFromPrivateKey(p):this.tweakFromPublicKey(p)}sign(p,w){if(!this.__D)throw new Error("Missing private key");if(w===void 0&&(w=this.lowR),w===!1)return Buffer.from(e.sign(p,this.__D));{let m=e.sign(p,this.__D);const v=Buffer.alloc(32,0);let T=0;for(;m[0]>127;)T++,v.writeUIntLE(T,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,w){return e.verify(p,this.publicKey,w)}verifySchnorr(p,w){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(p,this.publicKey.subarray(1,33),w)}tweakFromPublicKey(p){const w=ks(this.publicKey),m=e.xOnlyPointAddTweak(w,p);if(!m||m.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const v=Buffer.from([m.parity===0?2:3]);return a(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:a,fromWIF:o,makeRandom:s}}ut.ECPairFactory=Cs;(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}})})(xn);class jt{constructor(t){this.privKey=t}static fromPrivKey(t){return new jt(O.trim0x(t))}static async fromWalletClient(t){if(!t.account)return O.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 swap",Version:"1.0.2",Nonce:1n}});return O.Ok(new jt(O.trim0x(Ne.sha256(r))))}catch(r){return O.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),a=Ne.sha256(ge.with0x(r)),o=Ne.sha256(a);return O.Ok({secret:a,secretHash:o})}signMessage(t){const r=xn.ECPairFactory(ft),a="Garden.fi"+t.toString(),o=Buffer.from(a,"utf8"),s=Ne.sha256(o),c=Buffer.from(O.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(O.trim0x(s),"hex")).toString("hex")}}class Os{constructor(t){this.quoteUrl=new ge.Url("/quote",t)}async getQuote(t,r,a=!1){try{const o=this.quoteUrl.addSearchParams({order_pair:t,amount:r.toString(),exact_out:a.toString()}),s=await O.Fetcher.get(o);return s.error?O.Err(s.error):s.result?O.Ok(s.result):O.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return O.Err("GetQuote:",String(o))}}async getAttestedQuote(t){try{const r=await O.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?O.Err(r.error):r.result?O.Ok(r.result):O.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),O.Err("GetAttestedQuote:",String(r))}}}exports.EvmRelay=vn;exports.Garden=Li;exports.ParseOrderStatus=wn;exports.ParseSwapStatus=Ft;exports.Quote=Os;exports.SecretManager=jt;exports.parseAction=mn;exports.switchOrAddNetwork=Bi;
27
+ */(function(e){const t=Wt,r=Or,a=typeof Symbol=="function"&&typeof Symbol.for=="function"?Symbol.for("nodejs.util.inspect.custom"):null;e.Buffer=u,e.SlowBuffer=M,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,i){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,i)}u.poolSize=8192;function p(f,n,i){if(typeof f=="string")return T(f,n);if(ArrayBuffer.isView(f))return R(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 k(f,n,i);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,i);const b=A(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,i);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,i){return p(f,n,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function w(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,i){return w(f),f<=0?c(f):n!==void 0?typeof i=="string"?c(f).fill(n,i):c(f).fill(n):c(f)}u.alloc=function(f,n,i){return m(f,n,i)};function v(f){return w(f),c(f<0?0:I(f)|0)}u.allocUnsafe=function(f){return v(f)},u.allocUnsafeSlow=function(f){return v(f)};function T(f,n){if((typeof n!="string"||n==="")&&(n="utf8"),!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const i=P(f,n)|0;let l=c(i);const b=l.write(f,n);return b!==i&&(l=l.slice(0,b)),l}function O(f){const n=f.length<0?0:I(f.length)|0,i=c(n);for(let l=0;l<n;l+=1)i[l]=f[l]&255;return i}function R(f){if(Be(f,Uint8Array)){const n=new Uint8Array(f);return k(n.buffer,n.byteOffset,n.byteLength)}return O(f)}function k(f,n,i){if(n<0||f.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(f.byteLength<n+(i||0))throw new RangeError('"length" is outside of buffer bounds');let l;return n===void 0&&i===void 0?l=new Uint8Array(f):i===void 0?l=new Uint8Array(f,n):l=new Uint8Array(f,n,i),Object.setPrototypeOf(l,u.prototype),l}function A(f){if(u.isBuffer(f)){const n=I(f.length)|0,i=c(n);return i.length===0||f.copy(i,0,0,n),i}if(f.length!==void 0)return typeof f.length!="number"||Je(f.length)?c(0):O(f);if(f.type==="Buffer"&&Array.isArray(f.data))return O(f.data)}function I(f){if(f>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return f|0}function M(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,i){if(Be(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),Be(i,Uint8Array)&&(i=u.from(i,i.offset,i.byteLength)),!u.isBuffer(n)||!u.isBuffer(i))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(n===i)return 0;let l=n.length,b=i.length;for(let g=0,x=Math.min(l,b);g<x;++g)if(n[g]!==i[g]){l=n[g],b=i[g];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,i){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(i===void 0)for(i=0,l=0;l<n.length;++l)i+=n[l].length;const b=u.allocUnsafe(i);let g=0;for(l=0;l<n.length;++l){let x=n[l];if(Be(x,Uint8Array))g+x.length>b.length?(u.isBuffer(x)||(x=u.from(x)),x.copy(b,g)):Uint8Array.prototype.set.call(b,x,g);else if(u.isBuffer(x))x.copy(b,g);else throw new TypeError('"list" argument must be an Array of Buffers');g+=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 i=f.length,l=arguments.length>2&&arguments[2]===!0;if(!l&&i===0)return 0;let b=!1;for(;;)switch(n){case"ascii":case"latin1":case"binary":return i;case"utf8":case"utf-8":return G(f).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return pt(f).length;default:if(b)return l?-1:G(f).length;n=(""+n).toLowerCase(),b=!0}}u.byteLength=P;function L(f,n,i){let l=!1;if((n===void 0||n<0)&&(n=0),n>this.length||((i===void 0||i>this.length)&&(i=this.length),i<=0)||(i>>>=0,n>>>=0,i<=n))return"";for(f||(f="utf8");;)switch(f){case"hex":return ke(this,n,i);case"utf8":case"utf-8":return me(this,n,i);case"ascii":return Ie(this,n,i);case"latin1":case"binary":return He(this,n,i);case"base64":return oe(this,n,i);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return je(this,n,i);default:if(l)throw new TypeError("Unknown encoding: "+f);f=(f+"").toLowerCase(),l=!0}}u.prototype._isBuffer=!0;function N(f,n,i){const l=f[n];f[n]=f[i],f[i]=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 i=0;i<n;i+=2)N(this,i,i+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 i=0;i<n;i+=4)N(this,i,i+3),N(this,i+1,i+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 i=0;i<n;i+=8)N(this,i,i+7),N(this,i+1,i+6),N(this,i+2,i+5),N(this,i+3,i+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 i=e.INSPECT_MAX_BYTES;return n=this.toString("hex",0,i).replace(/(.{2})/g,"$1 ").trim(),this.length>i&&(n+=" ... "),"<Buffer "+n+">"},a&&(u.prototype[a]=u.prototype.inspect),u.prototype.compare=function(n,i,l,b,g){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(i===void 0&&(i=0),l===void 0&&(l=n?n.length:0),b===void 0&&(b=0),g===void 0&&(g=this.length),i<0||l>n.length||b<0||g>this.length)throw new RangeError("out of range index");if(b>=g&&i>=l)return 0;if(b>=g)return-1;if(i>=l)return 1;if(i>>>=0,l>>>=0,b>>>=0,g>>>=0,this===n)return 0;let x=g-b,K=l-i;const te=Math.min(x,K),Z=this.slice(b,g),re=n.slice(i,l);for(let z=0;z<te;++z)if(Z[z]!==re[z]){x=Z[z],K=re[z];break}return x<K?-1:K<x?1:0};function E(f,n,i,l,b){if(f.length===0)return-1;if(typeof i=="string"?(l=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,Je(i)&&(i=b?0:f.length-1),i<0&&(i=f.length+i),i>=f.length){if(b)return-1;i=f.length-1}else if(i<0)if(b)i=0;else return-1;if(typeof n=="string"&&(n=u.from(n,l)),u.isBuffer(n))return n.length===0?-1:j(f,n,i,l,b);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(f,n,i):Uint8Array.prototype.lastIndexOf.call(f,n,i):j(f,[n],i,l,b);throw new TypeError("val must be string, number or Buffer")}function j(f,n,i,l,b){let g=1,x=f.length,K=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;g=2,x/=2,K/=2,i/=2}function te(re,z){return g===1?re[z]:re.readUInt16BE(z*g)}let Z;if(b){let re=-1;for(Z=i;Z<x;Z++)if(te(f,Z)===te(n,re===-1?0:Z-re)){if(re===-1&&(re=Z),Z-re+1===K)return re*g}else re!==-1&&(Z-=Z-re),re=-1}else for(i+K>x&&(i=x-K),Z=i;Z>=0;Z--){let re=!0;for(let z=0;z<K;z++)if(te(f,Z+z)!==te(n,z)){re=!1;break}if(re)return Z}return-1}u.prototype.includes=function(n,i,l){return this.indexOf(n,i,l)!==-1},u.prototype.indexOf=function(n,i,l){return E(this,n,i,l,!0)},u.prototype.lastIndexOf=function(n,i,l){return E(this,n,i,l,!1)};function U(f,n,i,l){i=Number(i)||0;const b=f.length-i;l?(l=Number(l),l>b&&(l=b)):l=b;const g=n.length;l>g/2&&(l=g/2);let x;for(x=0;x<l;++x){const K=parseInt(n.substr(x*2,2),16);if(Je(K))return x;f[i+x]=K}return x}function $(f,n,i,l){return rt(G(n,f.length-i),f,i,l)}function ne(f,n,i,l){return rt(We(n),f,i,l)}function Te(f,n,i,l){return rt(pt(n),f,i,l)}function $e(f,n,i,l){return rt(tt(n,f.length-i),f,i,l)}u.prototype.write=function(n,i,l,b){if(i===void 0)b="utf8",l=this.length,i=0;else if(l===void 0&&typeof i=="string")b=i,l=this.length,i=0;else if(isFinite(i))i=i>>>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 g=this.length-i;if((l===void 0||l>g)&&(l=g),n.length>0&&(l<0||i<0)||i>this.length)throw new RangeError("Attempt to write outside buffer bounds");b||(b="utf8");let x=!1;for(;;)switch(b){case"hex":return U(this,n,i,l);case"utf8":case"utf-8":return $(this,n,i,l);case"ascii":case"latin1":case"binary":return ne(this,n,i,l);case"base64":return Te(this,n,i,l);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return $e(this,n,i,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,i){return n===0&&i===f.length?t.fromByteArray(f):t.fromByteArray(f.slice(n,i))}function me(f,n,i){i=Math.min(f.length,i);const l=[];let b=n;for(;b<i;){const g=f[b];let x=null,K=g>239?4:g>223?3:g>191?2:1;if(b+K<=i){let te,Z,re,z;switch(K){case 1:g<128&&(x=g);break;case 2:te=f[b+1],(te&192)===128&&(z=(g&31)<<6|te&63,z>127&&(x=z));break;case 3:te=f[b+1],Z=f[b+2],(te&192)===128&&(Z&192)===128&&(z=(g&15)<<12|(te&63)<<6|Z&63,z>2047&&(z<55296||z>57343)&&(x=z));break;case 4:te=f[b+1],Z=f[b+2],re=f[b+3],(te&192)===128&&(Z&192)===128&&(re&192)===128&&(z=(g&15)<<18|(te&63)<<12|(Z&63)<<6|re&63,z>65535&&z<1114112&&(x=z))}}x===null?(x=65533,K=1):x>65535&&(x-=65536,l.push(x>>>10&1023|55296),x=56320|x&1023),l.push(x),b+=K}return ze(l)}const ve=4096;function ze(f){const n=f.length;if(n<=ve)return String.fromCharCode.apply(String,f);let i="",l=0;for(;l<n;)i+=String.fromCharCode.apply(String,f.slice(l,l+=ve));return i}function Ie(f,n,i){let l="";i=Math.min(f.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(f[b]&127);return l}function He(f,n,i){let l="";i=Math.min(f.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(f[b]);return l}function ke(f,n,i){const l=f.length;(!n||n<0)&&(n=0),(!i||i<0||i>l)&&(i=l);let b="";for(let g=n;g<i;++g)b+=bt[f[g]];return b}function je(f,n,i){const l=f.slice(n,i);let b="";for(let g=0;g<l.length-1;g+=2)b+=String.fromCharCode(l[g]+l[g+1]*256);return b}u.prototype.slice=function(n,i){const l=this.length;n=~~n,i=i===void 0?l:~~i,n<0?(n+=l,n<0&&(n=0)):n>l&&(n=l),i<0?(i+=l,i<0&&(i=0)):i>l&&(i=l),i<n&&(i=n);const b=this.subarray(n,i);return Object.setPrototypeOf(b,u.prototype),b};function X(f,n,i){if(f%1!==0||f<0)throw new RangeError("offset is not uint");if(f+n>i)throw new RangeError("Trying to access beyond buffer length")}u.prototype.readUintLE=u.prototype.readUIntLE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=this[n],g=1,x=0;for(;++x<i&&(g*=256);)b+=this[n+x]*g;return b},u.prototype.readUintBE=u.prototype.readUIntBE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=this[n+--i],g=1;for(;i>0&&(g*=256);)b+=this[n+--i]*g;return b},u.prototype.readUint8=u.prototype.readUInt8=function(n,i){return n=n>>>0,i||X(n,1,this.length),this[n]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(n,i){return n=n>>>0,i||X(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(n,i){return n=n>>>0,i||X(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(n,i){return n=n>>>0,i||X(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,i){return n=n>>>0,i||X(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,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(n,this.length-8);const b=i+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24,g=this[++n]+this[++n]*2**8+this[++n]*2**16+l*2**24;return BigInt(b)+(BigInt(g)<<BigInt(32))}),u.prototype.readBigUInt64BE=Re(function(n){n=n>>>0,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(n,this.length-8);const b=i*2**24+this[++n]*2**16+this[++n]*2**8+this[++n],g=this[++n]*2**24+this[++n]*2**16+this[++n]*2**8+l;return(BigInt(b)<<BigInt(32))+BigInt(g)}),u.prototype.readIntLE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=this[n],g=1,x=0;for(;++x<i&&(g*=256);)b+=this[n+x]*g;return g*=128,b>=g&&(b-=Math.pow(2,8*i)),b},u.prototype.readIntBE=function(n,i,l){n=n>>>0,i=i>>>0,l||X(n,i,this.length);let b=i,g=1,x=this[n+--b];for(;b>0&&(g*=256);)x+=this[n+--b]*g;return g*=128,x>=g&&(x-=Math.pow(2,8*i)),x},u.prototype.readInt8=function(n,i){return n=n>>>0,i||X(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,i){n=n>>>0,i||X(n,2,this.length);const l=this[n]|this[n+1]<<8;return l&32768?l|4294901760:l},u.prototype.readInt16BE=function(n,i){n=n>>>0,i||X(n,2,this.length);const l=this[n+1]|this[n]<<8;return l&32768?l|4294901760:l},u.prototype.readInt32LE=function(n,i){return n=n>>>0,i||X(n,4,this.length),this[n]|this[n+1]<<8|this[n+2]<<16|this[n+3]<<24},u.prototype.readInt32BE=function(n,i){return n=n>>>0,i||X(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,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(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(i+this[++n]*2**8+this[++n]*2**16+this[++n]*2**24)}),u.prototype.readBigInt64BE=Re(function(n){n=n>>>0,B(n,"offset");const i=this[n],l=this[n+7];(i===void 0||l===void 0)&&F(n,this.length-8);const b=(i<<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,i){return n=n>>>0,i||X(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,i){return n=n>>>0,i||X(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,i){return n=n>>>0,i||X(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,i){return n=n>>>0,i||X(n,8,this.length),r.read(this,n,!1,52,8)};function ie(f,n,i,l,b,g){if(!u.isBuffer(f))throw new TypeError('"buffer" argument must be a Buffer instance');if(n>b||n<g)throw new RangeError('"value" argument is out of bounds');if(i+l>f.length)throw new RangeError("Index out of range")}u.prototype.writeUintLE=u.prototype.writeUIntLE=function(n,i,l,b){if(n=+n,i=i>>>0,l=l>>>0,!b){const K=Math.pow(2,8*l)-1;ie(this,n,i,l,K,0)}let g=1,x=0;for(this[i]=n&255;++x<l&&(g*=256);)this[i+x]=n/g&255;return i+l},u.prototype.writeUintBE=u.prototype.writeUIntBE=function(n,i,l,b){if(n=+n,i=i>>>0,l=l>>>0,!b){const K=Math.pow(2,8*l)-1;ie(this,n,i,l,K,0)}let g=l-1,x=1;for(this[i+g]=n&255;--g>=0&&(x*=256);)this[i+g]=n/x&255;return i+l},u.prototype.writeUint8=u.prototype.writeUInt8=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,1,255,0),this[i]=n&255,i+1},u.prototype.writeUint16LE=u.prototype.writeUInt16LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,65535,0),this[i]=n&255,this[i+1]=n>>>8,i+2},u.prototype.writeUint16BE=u.prototype.writeUInt16BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,65535,0),this[i]=n>>>8,this[i+1]=n&255,i+2},u.prototype.writeUint32LE=u.prototype.writeUInt32LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,4294967295,0),this[i+3]=n>>>24,this[i+2]=n>>>16,this[i+1]=n>>>8,this[i]=n&255,i+4},u.prototype.writeUint32BE=u.prototype.writeUInt32BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,4294967295,0),this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255,i+4};function Ee(f,n,i,l,b){d(n,l,b,f,i,7);let g=Number(n&BigInt(4294967295));f[i++]=g,g=g>>8,f[i++]=g,g=g>>8,f[i++]=g,g=g>>8,f[i++]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return f[i++]=x,x=x>>8,f[i++]=x,x=x>>8,f[i++]=x,x=x>>8,f[i++]=x,i}function qe(f,n,i,l,b){d(n,l,b,f,i,7);let g=Number(n&BigInt(4294967295));f[i+7]=g,g=g>>8,f[i+6]=g,g=g>>8,f[i+5]=g,g=g>>8,f[i+4]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return f[i+3]=x,x=x>>8,f[i+2]=x,x=x>>8,f[i+1]=x,x=x>>8,f[i]=x,i+8}u.prototype.writeBigUInt64LE=Re(function(n,i=0){return Ee(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Re(function(n,i=0){return qe(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeIntLE=function(n,i,l,b){if(n=+n,i=i>>>0,!b){const te=Math.pow(2,8*l-1);ie(this,n,i,l,te-1,-te)}let g=0,x=1,K=0;for(this[i]=n&255;++g<l&&(x*=256);)n<0&&K===0&&this[i+g-1]!==0&&(K=1),this[i+g]=(n/x>>0)-K&255;return i+l},u.prototype.writeIntBE=function(n,i,l,b){if(n=+n,i=i>>>0,!b){const te=Math.pow(2,8*l-1);ie(this,n,i,l,te-1,-te)}let g=l-1,x=1,K=0;for(this[i+g]=n&255;--g>=0&&(x*=256);)n<0&&K===0&&this[i+g+1]!==0&&(K=1),this[i+g]=(n/x>>0)-K&255;return i+l},u.prototype.writeInt8=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,1,127,-128),n<0&&(n=255+n+1),this[i]=n&255,i+1},u.prototype.writeInt16LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,32767,-32768),this[i]=n&255,this[i+1]=n>>>8,i+2},u.prototype.writeInt16BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,2,32767,-32768),this[i]=n>>>8,this[i+1]=n&255,i+2},u.prototype.writeInt32LE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,2147483647,-2147483648),this[i]=n&255,this[i+1]=n>>>8,this[i+2]=n>>>16,this[i+3]=n>>>24,i+4},u.prototype.writeInt32BE=function(n,i,l){return n=+n,i=i>>>0,l||ie(this,n,i,4,2147483647,-2147483648),n<0&&(n=4294967295+n+1),this[i]=n>>>24,this[i+1]=n>>>16,this[i+2]=n>>>8,this[i+3]=n&255,i+4},u.prototype.writeBigInt64LE=Re(function(n,i=0){return Ee(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Re(function(n,i=0){return qe(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Me(f,n,i,l,b,g){if(i+l>f.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function _(f,n,i,l,b){return n=+n,i=i>>>0,b||Me(f,n,i,4),r.write(f,n,i,l,23,4),i+4}u.prototype.writeFloatLE=function(n,i,l){return _(this,n,i,!0,l)},u.prototype.writeFloatBE=function(n,i,l){return _(this,n,i,!1,l)};function y(f,n,i,l,b){return n=+n,i=i>>>0,b||Me(f,n,i,8),r.write(f,n,i,l,52,8),i+8}u.prototype.writeDoubleLE=function(n,i,l){return y(this,n,i,!0,l)},u.prototype.writeDoubleBE=function(n,i,l){return y(this,n,i,!1,l)},u.prototype.copy=function(n,i,l,b){if(!u.isBuffer(n))throw new TypeError("argument should be a Buffer");if(l||(l=0),!b&&b!==0&&(b=this.length),i>=n.length&&(i=n.length),i||(i=0),b>0&&b<l&&(b=l),b===l||n.length===0||this.length===0)return 0;if(i<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-i<b-l&&(b=n.length-i+l);const g=b-l;return this===n&&typeof Uint8Array.prototype.copyWithin=="function"?this.copyWithin(i,l,b):Uint8Array.prototype.set.call(n,this.subarray(l,b),i),g},u.prototype.fill=function(n,i,l,b){if(typeof n=="string"){if(typeof i=="string"?(b=i,i=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(i<0||this.length<i||this.length<l)throw new RangeError("Out of range index");if(l<=i)return this;i=i>>>0,l=l===void 0?this.length:l>>>0,n||(n=0);let g;if(typeof n=="number")for(g=i;g<l;++g)this[g]=n;else{const x=u.isBuffer(n)?n:u.from(n,b),K=x.length;if(K===0)throw new TypeError('The value "'+n+'" is invalid for argument "value"');for(g=0;g<l-i;++g)this[g+i]=x[g%K]}return this};const S={};function D(f,n,i){S[f]=class extends i{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}`}}}D("ERR_BUFFER_OUT_OF_BOUNDS",function(f){return f?`${f} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),D("ERR_INVALID_ARG_TYPE",function(f,n){return`The "${f}" argument must be of type number. Received type ${typeof n}`},TypeError),D("ERR_OUT_OF_RANGE",function(f,n,i){let l=`The value of "${f}" is out of range.`,b=i;return Number.isInteger(i)&&Math.abs(i)>2**32?b=q(String(i)):typeof i=="bigint"&&(b=String(i),(i>BigInt(2)**BigInt(32)||i<-(BigInt(2)**BigInt(32)))&&(b=q(b)),b+="n"),l+=` It must be ${n}. Received ${b}`,l},RangeError);function q(f){let n="",i=f.length;const l=f[0]==="-"?1:0;for(;i>=l+4;i-=3)n=`_${f.slice(i-3,i)}${n}`;return`${f.slice(0,i)}${n}`}function h(f,n,i){B(n,"offset"),(f[n]===void 0||f[n+i]===void 0)&&F(n,f.length-(i+1))}function d(f,n,i,l,b,g){if(f>i||f<n){const x=typeof n=="bigint"?"n":"";let K;throw n===0||n===BigInt(0)?K=`>= 0${x} and < 2${x} ** ${(g+1)*8}${x}`:K=`>= -(2${x} ** ${(g+1)*8-1}${x}) and < 2 ** ${(g+1)*8-1}${x}`,new S.ERR_OUT_OF_RANGE("value",K,f)}h(l,b,g)}function B(f,n){if(typeof f!="number")throw new S.ERR_INVALID_ARG_TYPE(n,"number",f)}function F(f,n,i){throw Math.floor(f)!==f?(B(f,i),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 Q=/[^+/0-9A-Za-z-_]/g;function W(f){if(f=f.split("=")[0],f=f.trim().replace(Q,""),f.length<2)return"";for(;f.length%4!==0;)f=f+"=";return f}function G(f,n){n=n||1/0;let i;const l=f.length;let b=null;const g=[];for(let x=0;x<l;++x){if(i=f.charCodeAt(x),i>55295&&i<57344){if(!b){if(i>56319){(n-=3)>-1&&g.push(239,191,189);continue}else if(x+1===l){(n-=3)>-1&&g.push(239,191,189);continue}b=i;continue}if(i<56320){(n-=3)>-1&&g.push(239,191,189),b=i;continue}i=(b-55296<<10|i-56320)+65536}else b&&(n-=3)>-1&&g.push(239,191,189);if(b=null,i<128){if((n-=1)<0)break;g.push(i)}else if(i<2048){if((n-=2)<0)break;g.push(i>>6|192,i&63|128)}else if(i<65536){if((n-=3)<0)break;g.push(i>>12|224,i>>6&63|128,i&63|128)}else if(i<1114112){if((n-=4)<0)break;g.push(i>>18|240,i>>12&63|128,i>>6&63|128,i&63|128)}else throw new Error("Invalid code point")}return g}function We(f){const n=[];for(let i=0;i<f.length;++i)n.push(f.charCodeAt(i)&255);return n}function tt(f,n){let i,l,b;const g=[];for(let x=0;x<f.length&&!((n-=2)<0);++x)i=f.charCodeAt(x),l=i>>8,b=i%256,g.push(b),g.push(l);return g}function pt(f){return t.toByteArray(W(f))}function rt(f,n,i,l){let b;for(b=0;b<l&&!(b+i>=n.length||b>=f.length);++b)n[b+i]=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 Je(f){return f!==f}const bt=function(){const f="0123456789abcdef",n=new Array(256);for(let i=0;i<16;++i){const l=i*16;for(let b=0;b<16;++b)n[l+b]=f[i]+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,a=r.Buffer;function o(c,u){for(var p in c)u[p]=c[p]}a.from&&a.alloc&&a.allocUnsafe&&a.allocUnsafeSlow?e.exports=r:(o(r,t),t.Buffer=s);function s(c,u,p){return a(c,u,p)}s.prototype=Object.create(a.prototype),o(a,s),s.from=function(c,u,p){if(typeof c=="number")throw new TypeError("Argument must not be a number");return a(c,u,p)},s.alloc=function(c,u,p){if(typeof c!="number")throw new TypeError("Argument must be a number");var w=a(c);return u!==void 0?typeof p=="string"?w.fill(u,p):w.fill(u):w.fill(0),w},s.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return a(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,ar=65536,Xi=4294967295;function Qi(){throw new Error(`Secure random number generation is not supported by this browser.
28
+ Use Chrome, Firefox or Internet Explorer 11`)}var Zi=xe.Buffer,Dt=Ge.crypto||Ge.msCrypto;Dt&&Dt.getRandomValues?mr.exports=ea:mr.exports=Qi;function ea(e,t){if(e>Xi)throw new RangeError("requested too many random bytes");var r=Zi.allocUnsafe(e);if(e>0)if(e>ar)for(var a=0;a<e;a+=ar)Dt.getRandomValues(r.slice(a,a+ar));else Dt.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var ta=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 a=function(){};a.prototype=r.prototype,t.prototype=new a,t.prototype.constructor=t}};var be=xr.exports,Er={exports:{}},Lr={exports:{}},st=typeof Reflect=="object"?Reflect:null,Wr=st&&typeof st.apply=="function"?st.apply:function(t,r,a){return Function.prototype.apply.call(t,r,a)},Mt;st&&typeof st.ownKeys=="function"?Mt=st.ownKeys:Object.getOwnPropertySymbols?Mt=function(t){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))}:Mt=function(t){return Object.getOwnPropertyNames(t)};function ra(e){console&&console.warn&&console.warn(e)}var kn=Number.isNaN||function(t){return t!==t};function V(){V.init.call(this)}Lr.exports=V;Lr.exports.once=oa;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||kn(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||kn(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 Cn(e){return e._maxListeners===void 0?V.defaultMaxListeners:e._maxListeners}V.prototype.getMaxListeners=function(){return Cn(this)};V.prototype.emit=function(t){for(var r=[],a=1;a<arguments.length;a++)r.push(arguments[a]);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")Wr(p,this,r);else for(var w=p.length,m=Fn(p,w),a=0;a<w;++a)Wr(m[a],this,r);return!0};function On(e,t,r,a){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]=a?[r,c]:[c,r]:a?c.unshift(r):c.push(r),o=Cn(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,ra(u)}return e}V.prototype.addListener=function(t,r){return On(this,t,r,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(t,r){return On(this,t,r,!0)};function na(){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 Ln(e,t,r){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=na.bind(a);return o.listener=r,a.wrapFn=o,o}V.prototype.once=function(t,r){return Kt(r),this.on(t,Ln(this,t,r)),this};V.prototype.prependOnceListener=function(t,r){return Kt(r),this.prependListener(t,Ln(this,t,r)),this};V.prototype.removeListener=function(t,r){var a,o,s,c,u;if(Kt(r),o=this._events,o===void 0)return this;if(a=o[t],a===void 0)return this;if(a===r||a.listener===r)--this._eventsCount===0?this._events=Object.create(null):(delete o[t],o.removeListener&&this.emit("removeListener",t,a.listener||r));else if(typeof a!="function"){for(s=-1,c=a.length-1;c>=0;c--)if(a[c]===r||a[c].listener===r){u=a[c].listener,s=c;break}if(s<0)return this;s===0?a.shift():ia(a,s),a.length===1&&(o[t]=a[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,a,o;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[t]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[t]),this;if(arguments.length===0){var s=Object.keys(a),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=a[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 Mn(e,t,r){var a=e._events;if(a===void 0)return[];var o=a[t];return o===void 0?[]:typeof o=="function"?r?[o.listener||o]:[o]:r?aa(o):Fn(o,o.length)}V.prototype.listeners=function(t){return Mn(this,t,!0)};V.prototype.rawListeners=function(t){return Mn(this,t,!1)};V.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Pn.call(e,t)};V.prototype.listenerCount=Pn;function Pn(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?Mt(this._events):[]};function Fn(e,t){for(var r=new Array(t),a=0;a<t;++a)r[a]=e[a];return r}function ia(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function aa(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function oa(e,t){return new Promise(function(r,a){function o(c){e.removeListener(t,s),a(c)}function s(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}Nn(e,t,s,{once:!0}),t!=="error"&&sa(e,o,{once:!0})})}function sa(e,t,r){typeof e.on=="function"&&Nn(e,"error",t,r)}function Nn(e,t,r,a){if(typeof e.on=="function")a.once?e.once(t,r):e.on(t,r);else if(typeof e.addEventListener=="function")e.addEventListener(t,function o(s){a.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=Lr.exports,Dn=Un.EventEmitter;const fa={},ua=Object.freeze(Object.defineProperty({__proto__:null,default:fa},Symbol.toStringTag,{value:"Module"})),Mr=Pi(ua);var or,Gr;function ca(){if(Gr)return or;Gr=1;function e(R,k){var A=Object.keys(R);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(R);k&&(I=I.filter(function(M){return Object.getOwnPropertyDescriptor(R,M).enumerable})),A.push.apply(A,I)}return A}function t(R){for(var k=1;k<arguments.length;k++){var A=arguments[k]!=null?arguments[k]:{};k%2?e(Object(A),!0).forEach(function(I){r(R,I,A[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(A)):e(Object(A)).forEach(function(I){Object.defineProperty(R,I,Object.getOwnPropertyDescriptor(A,I))})}return R}function r(R,k,A){return k=c(k),k in R?Object.defineProperty(R,k,{value:A,enumerable:!0,configurable:!0,writable:!0}):R[k]=A,R}function a(R,k){if(!(R instanceof k))throw new TypeError("Cannot call a class as a function")}function o(R,k){for(var A=0;A<k.length;A++){var I=k[A];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(R,c(I.key),I)}}function s(R,k,A){return k&&o(R.prototype,k),Object.defineProperty(R,"prototype",{writable:!1}),R}function c(R){var k=u(R,"string");return typeof k=="symbol"?k:String(k)}function u(R,k){if(typeof R!="object"||R===null)return R;var A=R[Symbol.toPrimitive];if(A!==void 0){var I=A.call(R,k||"default");if(typeof I!="object")return I;throw new TypeError("@@toPrimitive must return a primitive value.")}return(k==="string"?String:Number)(R)}var p=ht,w=p.Buffer,m=Mr,v=m.inspect,T=v&&v.custom||"inspect";function O(R,k,A){w.prototype.copy.call(R,k,A)}return or=function(){function R(){a(this,R),this.head=null,this.tail=null,this.length=0}return s(R,[{key:"push",value:function(A){var I={data:A,next:null};this.length>0?this.tail.next=I:this.head=I,this.tail=I,++this.length}},{key:"unshift",value:function(A){var I={data:A,next:this.head};this.length===0&&(this.tail=I),this.head=I,++this.length}},{key:"shift",value:function(){if(this.length!==0){var A=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,A}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(A){if(this.length===0)return"";for(var I=this.head,M=""+I.data;I=I.next;)M+=A+I.data;return M}},{key:"concat",value:function(A){if(this.length===0)return w.alloc(0);for(var I=w.allocUnsafe(A>>>0),M=this.head,P=0;M;)O(M.data,I,P),P+=M.data.length,M=M.next;return I}},{key:"consume",value:function(A,I){var M;return A<this.head.data.length?(M=this.head.data.slice(0,A),this.head.data=this.head.data.slice(A)):A===this.head.data.length?M=this.shift():M=I?this._getString(A):this._getBuffer(A),M}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(A){var I=this.head,M=1,P=I.data;for(A-=P.length;I=I.next;){var L=I.data,N=A>L.length?L.length:A;if(N===L.length?P+=L:P+=L.slice(0,A),A-=N,A===0){N===L.length?(++M,I.next?this.head=I.next:this.head=this.tail=null):(this.head=I,I.data=L.slice(N));break}++M}return this.length-=M,P}},{key:"_getBuffer",value:function(A){var I=w.allocUnsafe(A),M=this.head,P=1;for(M.data.copy(I),A-=M.data.length;M=M.next;){var L=M.data,N=A>L.length?L.length:A;if(L.copy(I,I.length-A,0,N),A-=N,A===0){N===L.length?(++P,M.next?this.head=M.next:this.head=this.tail=null):(this.head=M,M.data=L.slice(N));break}++P}return this.length-=P,I}},{key:T,value:function(A,I){return v(this,t(t({},I),{},{depth:0,customInspect:!1}))}}]),R}(),or}function la(e,t){var r=this,a=this._readableState&&this._readableState.destroyed,o=this._writableState&&this._writableState.destroyed;return a||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(Pt,r):(r._writableState.errorEmitted=!0,process.nextTick(Vr,r,s)):process.nextTick(Vr,r,s):t?(process.nextTick(Pt,r),t(s)):process.nextTick(Pt,r)}),this)}function Vr(e,t){Br(e,t),Pt(e)}function Pt(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ha(){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 da(e,t){var r=e._readableState,a=e._writableState;r&&r.autoDestroy||a&&a.autoDestroy?e.destroy(t):e.emit("error",t)}var $n={destroy:la,undestroy:ha,errorOrDestroy:da},Ze={};function pa(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var Hn={};function Ae(e,t,r){r||(r=Error);function a(s,c,u){return typeof t=="string"?t:t(s,c,u)}var o=function(s){pa(c,s);function c(u,p,w){return s.call(this,a(u,p,w))||this}return c}(r);o.prototype.name=r.name,o.prototype.code=e,Hn[e]=o}function zr(e,t){if(Array.isArray(e)){var r=e.length;return e=e.map(function(a){return String(a)}),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 ba(e,t,r){return e.substr(0,t.length)===t}function ya(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function _a(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 a;typeof t=="string"&&ba(t,"not ")?(a="must not be",t=t.replace(/^not /,"")):a="must be";var o;if(ya(e," argument"))o="The ".concat(e," ").concat(a," ").concat(zr(t,"type"));else{var s=_a(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(s," ").concat(a," ").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=Hn;var ga=Ze.codes.ERR_INVALID_OPT_VALUE;function wa(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function ma(e,t,r,a){var o=wa(t,a,r);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var s=a?r:"highWaterMark";throw new ga(s,o)}return Math.floor(o)}return e.objectMode?16:16*1024}var jn={getHighWaterMark:ma},va=xa;function xa(e,t){if(sr("noDeprecation"))return e;var r=!1;function a(){if(!r){if(sr("throwDeprecation"))throw new Error(t);sr("traceDeprecation")?console.trace(t):console.warn(t),r=!0}return e.apply(this,arguments)}return a}function sr(e){try{if(!Ge.localStorage)return!1}catch{return!1}var t=Ge.localStorage[e];return t==null?!1:String(t).toLowerCase()==="true"}var fr,Jr;function qn(){if(Jr)return fr;Jr=1,fr=U;function e(_){var y=this;this.next=null,this.entry=null,this.finish=function(){Me(y,_)}}var t;U.WritableState=E;var r={deprecate:va},a=Dn,o=ht.Buffer,s=(typeof Ge<"u"?Ge:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function c(_){return o.from(_)}function u(_){return o.isBuffer(_)||_ instanceof s}var p=$n,w=jn,m=w.getHighWaterMark,v=Ze.codes,T=v.ERR_INVALID_ARG_TYPE,O=v.ERR_METHOD_NOT_IMPLEMENTED,R=v.ERR_MULTIPLE_CALLBACK,k=v.ERR_STREAM_CANNOT_PIPE,A=v.ERR_STREAM_DESTROYED,I=v.ERR_STREAM_NULL_VALUES,M=v.ERR_STREAM_WRITE_AFTER_END,P=v.ERR_UNKNOWN_ENCODING,L=p.errorOrDestroy;be(U,a);function N(){}function E(_,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 D=_.decodeStrings===!1;this.decodeStrings=!D,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(q){ze(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)}E.prototype.getBuffer=function(){for(var y=this.bufferedRequest,S=[];y;)S.push(y),y=y.next;return S},function(){try{Object.defineProperty(E.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(U,Symbol.hasInstance,{value:function(y){return j.call(this,y)?!0:this!==U?!1:y&&y._writableState instanceof E}})):j=function(y){return y instanceof this};function U(_){t=t||lt();var y=this instanceof t;if(!y&&!j.call(U,this))return new U(_);this._writableState=new E(_,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)),a.call(this)}U.prototype.pipe=function(){L(this,new k)};function $(_,y){var S=new M;L(_,S),process.nextTick(y,S)}function ne(_,y,S,D){var q;return S===null?q=new I:typeof S!="string"&&!y.objectMode&&(q=new T("chunk",["string","Buffer"],S)),q?(L(_,q),process.nextTick(D,q),!1):!0}U.prototype.write=function(_,y,S){var D=this._writableState,q=!1,h=!D.objectMode&&u(_);return h&&!o.isBuffer(_)&&(_=c(_)),typeof y=="function"&&(S=y,y=null),h?y="buffer":y||(y=D.defaultEncoding),typeof S!="function"&&(S=N),D.ending?$(this,S):(h||ne(this,D,_,S))&&(D.pendingcb++,q=$e(this,D,h,_,y,S)),q},U.prototype.cork=function(){this._writableState.corked++},U.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&ke(this,_))},U.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(U.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(U.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function $e(_,y,S,D,q,h){if(!S){var d=Te(y,D,q);D!==d&&(S=!0,q="buffer",D=d)}var B=y.objectMode?1:D.length;y.length+=B;var F=y.length<y.highWaterMark;if(F||(y.needDrain=!0),y.writing||y.corked){var Q=y.lastBufferedRequest;y.lastBufferedRequest={chunk:D,encoding:q,isBuf:S,callback:h,next:null},Q?Q.next=y.lastBufferedRequest:y.bufferedRequest=y.lastBufferedRequest,y.bufferedRequestCount+=1}else oe(_,y,!1,B,D,q,h);return F}function oe(_,y,S,D,q,h,d){y.writelen=D,y.writecb=d,y.writing=!0,y.sync=!0,y.destroyed?y.onwrite(new A("write")):S?_._writev(q,y.onwrite):_._write(q,h,y.onwrite),y.sync=!1}function me(_,y,S,D,q){--y.pendingcb,S?(process.nextTick(q,D),process.nextTick(Ee,_,y),_._writableState.errorEmitted=!0,L(_,D)):(q(D),_._writableState.errorEmitted=!0,L(_,D),Ee(_,y))}function ve(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function ze(_,y){var S=_._writableState,D=S.sync,q=S.writecb;if(typeof q!="function")throw new R;if(ve(S),y)me(_,S,D,y,q);else{var h=je(S)||_.destroyed;!h&&!S.corked&&!S.bufferProcessing&&S.bufferedRequest&&ke(_,S),D?process.nextTick(Ie,_,S,h,q):Ie(_,S,h,q)}}function Ie(_,y,S,D){S||He(_,y),y.pendingcb--,D(),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 D=y.bufferedRequestCount,q=new Array(D),h=y.corkedRequestsFree;h.entry=S;for(var d=0,B=!0;S;)q[d]=S,S.isBuf||(B=!1),S=S.next,d+=1;q.allBuffers=B,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 F=S.chunk,Q=S.encoding,W=S.callback,G=y.objectMode?1:F.length;if(oe(_,y,!1,G,F,Q,W),S=S.next,y.bufferedRequestCount--,y.writing)break}S===null&&(y.lastBufferedRequest=null)}y.bufferedRequest=S,y.bufferProcessing=!1}U.prototype._write=function(_,y,S){S(new O("_write()"))},U.prototype._writev=null,U.prototype.end=function(_,y,S){var D=this._writableState;return typeof _=="function"?(S=_,_=null,y=null):typeof y=="function"&&(S=y,y=null),_!=null&&this.write(_,y),D.corked&&(D.corked=1,this.uncork()),D.ending||qe(this,D,S),this},Object.defineProperty(U.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function je(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function X(_,y){_._final(function(S){y.pendingcb--,S&&L(_,S),y.prefinished=!0,_.emit("prefinish"),Ee(_,y)})}function ie(_,y){!y.prefinished&&!y.finalCalled&&(typeof _._final=="function"&&!y.destroyed?(y.pendingcb++,y.finalCalled=!0,process.nextTick(X,_,y)):(y.prefinished=!0,_.emit("prefinish")))}function Ee(_,y){var S=je(y);if(S&&(ie(_,y),y.pendingcb===0&&(y.finished=!0,_.emit("finish"),y.autoDestroy))){var D=_._readableState;(!D||D.autoDestroy&&D.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 Me(_,y,S){var D=_.entry;for(_.entry=null;D;){var q=D.callback;y.pendingcb--,q(S),D=D.next}y.corkedRequestsFree.next=_}return Object.defineProperty(U.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(y){this._writableState&&(this._writableState.destroyed=y)}}),U.prototype.destroy=p.destroy,U.prototype._undestroy=p.undestroy,U.prototype._destroy=function(_,y){y(_)},fr}var ur,Yr;function lt(){if(Yr)return ur;Yr=1;var e=Object.keys||function(w){var m=[];for(var v in w)m.push(v);return m};ur=c;var t=Kn(),r=qn();be(c,t);for(var a=e(r.prototype),o=0;o<a.length;o++){var s=a[o];c.prototype[s]||(c.prototype[s]=r.prototype[s])}function c(w){if(!(this instanceof c))return new c(w);t.call(this,w),r.call(this,w),this.allowHalfOpen=!0,w&&(w.readable===!1&&(this.readable=!1),w.writable===!1&&(this.writable=!1),w.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(w){w.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)}}),ur}var $t={},Pr=xe.Buffer,Xr=Pr.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 Ea(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 Ba(e){var t=Ea(e);if(typeof t!="string"&&(Pr.isEncoding===Xr||!Xr(e)))throw new Error("Unknown encoding: "+e);return t||e}$t.StringDecoder=At;function At(e){this.encoding=Ba(e);var t;switch(this.encoding){case"utf16le":this.text=ka,this.end=Ca,t=4;break;case"utf8":this.fillLast=Aa,t=4;break;case"base64":this.text=Oa,this.end=La,t=3;break;default:this.write=Ma,this.end=Pa;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Pr.allocUnsafe(t)}At.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||""};At.prototype.end=Ia;At.prototype.text=Ta;At.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 cr(e){return e<=127?0:e>>5===6?2:e>>4===14?3:e>>3===30?4:e>>6===2?-1:-2}function Ra(e,t,r){var a=t.length-1;if(a<r)return 0;var o=cr(t[a]);return o>=0?(o>0&&(e.lastNeed=o-1),o):--a<r||o===-2?0:(o=cr(t[a]),o>=0?(o>0&&(e.lastNeed=o-2),o):--a<r||o===-2?0:(o=cr(t[a]),o>=0?(o>0&&(o===2?o=0:e.lastNeed=o-3),o):0))}function Sa(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 Aa(e){var t=this.lastTotal-this.lastNeed,r=Sa(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 Ta(e,t){var r=Ra(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var a=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString("utf8",t,a)}function Ia(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function ka(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var a=r.charCodeAt(r.length-1);if(a>=55296&&a<=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 Ca(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 Oa(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 La(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Ma(e){return e.toString(this.encoding)}function Pa(e){return e&&e.length?this.write(e):""}var Qr=Ze.codes.ERR_STREAM_PREMATURE_CLOSE;function Fa(e){var t=!1;return function(){if(!t){t=!0;for(var r=arguments.length,a=new Array(r),o=0;o<r;o++)a[o]=arguments[o];e.apply(this,a)}}}function Na(){}function Ua(e){return e.setHeader&&typeof e.abort=="function"}function Wn(e,t,r){if(typeof t=="function")return Wn(e,null,t);t||(t={}),r=Fa(r||Na);var a=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,a||r.call(e)},p=e._readableState&&e._readableState.endEmitted,w=function(){a=!1,p=!0,o||r.call(e)},m=function(R){r.call(e,R)},v=function(){var R;if(a&&!p)return(!e._readableState||!e._readableState.ended)&&(R=new Qr),r.call(e,R);if(o&&!c)return(!e._writableState||!e._writableState.ended)&&(R=new Qr),r.call(e,R)},T=function(){e.req.on("finish",u)};return Ua(e)?(e.on("complete",u),e.on("abort",v),e.req?T():e.on("request",T)):o&&!e._writableState&&(e.on("end",s),e.on("close",s)),e.on("end",w),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",T),e.req&&e.req.removeListener("finish",u),e.removeListener("end",s),e.removeListener("close",s),e.removeListener("finish",u),e.removeListener("end",w),e.removeListener("error",m),e.removeListener("close",v)}}var Fr=Wn,lr,Zr;function Da(){if(Zr)return lr;Zr=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=a(P,"string");return typeof L=="symbol"?L:String(L)}function a(P,L){if(typeof P!="object"||P===null)return P;var N=P[Symbol.toPrimitive];if(N!==void 0){var E=N.call(P,L||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(L==="string"?String:Number)(P)}var o=Fr,s=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),p=Symbol("ended"),w=Symbol("lastPromise"),m=Symbol("handlePromise"),v=Symbol("stream");function T(P,L){return{value:P,done:L}}function O(P){var L=P[s];if(L!==null){var N=P[v].read();N!==null&&(P[w]=null,P[s]=null,P[c]=null,L(T(N,!1)))}}function R(P){process.nextTick(O,P)}function k(P,L){return function(N,E){P.then(function(){if(L[p]){N(T(void 0,!0));return}L[m](N,E)},E)}}var A=Object.getPrototypeOf(function(){}),I=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(T(void 0,!0));if(this[v].destroyed)return new Promise(function($,ne){process.nextTick(function(){L[u]?ne(L[u]):$(T(void 0,!0))})});var E=this[w],j;if(E)j=new Promise(k(E,this));else{var U=this[v].read();if(U!==null)return Promise.resolve(T(U,!1));j=new Promise(this[m])}return this[w]=j,j}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var L=this;return new Promise(function(N,E){L[v].destroy(null,function(j){if(j){E(j);return}N(T(void 0,!0))})})}),e),A),M=function(L){var N,E=Object.create(I,(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(U,$){var ne=E[v].read();ne?(E[w]=null,E[s]=null,E[c]=null,U(T(ne,!1))):(E[s]=U,E[c]=$)},writable:!0}),N));return E[w]=null,o(L,function(j){if(j&&j.code!=="ERR_STREAM_PREMATURE_CLOSE"){var U=E[c];U!==null&&(E[w]=null,E[s]=null,E[c]=null,U(j)),E[u]=j;return}var $=E[s];$!==null&&(E[w]=null,E[s]=null,E[c]=null,$(T(void 0,!0))),E[p]=!0}),L.on("readable",R.bind(null,E)),E};return lr=M,lr}var hr,en;function $a(){return en||(en=1,hr=function(){throw new Error("Readable.from is not available in the browser")}),hr}var dr,tn;function Kn(){if(tn)return dr;tn=1,dr=$;var e;$.ReadableState=U,Un.EventEmitter;var t=function(d,B){return d.listeners(B).length},r=Dn,a=ht.Buffer,o=(typeof Ge<"u"?Ge:typeof window<"u"?window:typeof self<"u"?self:{}).Uint8Array||function(){};function s(h){return a.from(h)}function c(h){return a.isBuffer(h)||h instanceof o}var u=Mr,p;u&&u.debuglog?p=u.debuglog("stream"):p=function(){};var w=ca(),m=$n,v=jn,T=v.getHighWaterMark,O=Ze.codes,R=O.ERR_INVALID_ARG_TYPE,k=O.ERR_STREAM_PUSH_AFTER_EOF,A=O.ERR_METHOD_NOT_IMPLEMENTED,I=O.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,M,P,L;be($,r);var N=m.errorOrDestroy,E=["error","close","destroy","pause","resume"];function j(h,d,B){if(typeof h.prependListener=="function")return h.prependListener(d,B);!h._events||!h._events[d]?h.on(d,B):Array.isArray(h._events[d])?h._events[d].unshift(B):h._events[d]=[B,h._events[d]]}function U(h,d,B){e=e||lt(),h=h||{},typeof B!="boolean"&&(B=d instanceof e),this.objectMode=!!h.objectMode,B&&(this.objectMode=this.objectMode||!!h.readableObjectMode),this.highWaterMark=T(this,h,"readableHighWaterMark",B),this.buffer=new w,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&&(M||(M=$t.StringDecoder),this.decoder=new M(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 U(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 B=this._readableState,F;return B.objectMode?F=!0:typeof h=="string"&&(d=d||B.defaultEncoding,d!==B.encoding&&(h=a.from(h,d),d=""),F=!0),ne(this,h,d,!1,F)},$.prototype.unshift=function(h){return ne(this,h,null,!0,!1)};function ne(h,d,B,F,Q){p("readableAddChunk",d);var W=h._readableState;if(d===null)W.reading=!1,ze(h,W);else{var G;if(Q||(G=$e(W,d)),G)N(h,G);else if(W.objectMode||d&&d.length>0)if(typeof d!="string"&&!W.objectMode&&Object.getPrototypeOf(d)!==a.prototype&&(d=s(d)),F)W.endEmitted?N(h,new I):Te(h,W,d,!0);else if(W.ended)N(h,new k);else{if(W.destroyed)return!1;W.reading=!1,W.decoder&&!B?(d=W.decoder.write(d),W.objectMode||d.length!==0?Te(h,W,d,!1):ke(h,W)):Te(h,W,d,!1)}else F||(W.reading=!1,ke(h,W))}return!W.ended&&(W.length<W.highWaterMark||W.length===0)}function Te(h,d,B,F){d.flowing&&d.length===0&&!d.sync?(d.awaitDrain=0,h.emit("data",B)):(d.length+=d.objectMode?1:B.length,F?d.buffer.unshift(B):d.buffer.push(B),d.needReadable&&Ie(h)),ke(h,d)}function $e(h,d){var B;return!c(d)&&typeof d!="string"&&d!==void 0&&!h.objectMode&&(B=new R("chunk",["string","Buffer","Uint8Array"],d)),B}$.prototype.isPaused=function(){return this._readableState.flowing===!1},$.prototype.setEncoding=function(h){M||(M=$t.StringDecoder);var d=new M(h);this._readableState.decoder=d,this._readableState.encoding=this._readableState.decoder.encoding;for(var B=this._readableState.buffer.head,F="";B!==null;)F+=d.write(B.data),B=B.next;return this._readableState.buffer.clear(),F!==""&&this._readableState.buffer.push(F),this._readableState.length=F.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,B=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 F=d.needReadable;p("need readable",F),(d.length===0||d.length-h<d.highWaterMark)&&(F=!0,p("length less than watermark",F)),d.ended||d.reading?(F=!1,p("reading or ended",F)):F&&(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(B,d)));var Q;return h>0?Q=y(h,d):Q=null,Q===null?(d.needReadable=d.length<=d.highWaterMark,h=0):(d.length-=h,d.awaitDrain=0),d.length===0&&(d.ended||(d.needReadable=!0),B!==h&&d.ended&&S(this)),Q!==null&&this.emit("data",Q),Q};function ze(h,d){if(p("onEofChunk"),!d.ended){if(d.decoder){var B=d.decoder.end();B&&B.length&&(d.buffer.push(B),d.length+=d.objectMode?1:B.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 B=d.length;if(p("maybeReadMore read 0"),h.read(0),B===d.length)break}d.readingMore=!1}$.prototype._read=function(h){N(this,new A("_read()"))},$.prototype.pipe=function(h,d){var B=this,F=this._readableState;switch(F.pipesCount){case 0:F.pipes=h;break;case 1:F.pipes=[F.pipes,h];break;default:F.pipes.push(h);break}F.pipesCount+=1,p("pipe count=%d opts=%j",F.pipesCount,d);var Q=(!d||d.end!==!1)&&h!==process.stdout&&h!==process.stderr,W=Q?We:Ye;F.endEmitted?process.nextTick(W):B.once("end",W),h.on("unpipe",G);function G(f,n){p("onunpipe"),f===B&&n&&n.hasUnpiped===!1&&(n.hasUnpiped=!0,rt())}function We(){p("onend"),h.end()}var tt=X(B);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",Je),h.removeListener("unpipe",G),B.removeListener("end",We),B.removeListener("end",Ye),B.removeListener("data",Be),pt=!0,F.awaitDrain&&(!h._writableState||h._writableState.needDrain)&&tt()}B.on("data",Be);function Be(f){p("ondata");var n=h.write(f);p("dest.write",n),n===!1&&((F.pipesCount===1&&F.pipes===h||F.pipesCount>1&&q(F.pipes,h)!==-1)&&!pt&&(p("false write response, pause",F.awaitDrain),F.awaitDrain++),B.pause())}function Je(f){p("onerror",f),Ye(),h.removeListener("error",Je),t(h,"error")===0&&N(h,f)}j(h,"error",Je);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"),B.unpipe(h)}return h.emit("pipe",B),F.flowing||(p("pipe resume"),B.resume()),h};function X(h){return function(){var B=h._readableState;p("pipeOnDrain",B.awaitDrain),B.awaitDrain&&B.awaitDrain--,B.awaitDrain===0&&t(h,"data")&&(B.flowing=!0,_(h))}}$.prototype.unpipe=function(h){var d=this._readableState,B={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,B),this);if(!h){var F=d.pipes,Q=d.pipesCount;d.pipes=null,d.pipesCount=0,d.flowing=!1;for(var W=0;W<Q;W++)F[W].emit("unpipe",this,{hasUnpiped:!1});return this}var G=q(d.pipes,h);return G===-1?this:(d.pipes.splice(G,1),d.pipesCount-=1,d.pipesCount===1&&(d.pipes=d.pipes[0]),h.emit("unpipe",this,B),this)},$.prototype.on=function(h,d){var B=r.prototype.on.call(this,h,d),F=this._readableState;return h==="data"?(F.readableListening=this.listenerCount("readable")>0,F.flowing!==!1&&this.resume()):h==="readable"&&!F.endEmitted&&!F.readableListening&&(F.readableListening=F.needReadable=!0,F.flowing=!1,F.emittedReadable=!1,p("on readable",F.length,F.reading),F.length?Ie(this):F.reading||process.nextTick(Ee,this)),B},$.prototype.addListener=$.prototype.on,$.prototype.removeListener=function(h,d){var B=r.prototype.removeListener.call(this,h,d);return h==="readable"&&process.nextTick(ie,this),B},$.prototype.removeAllListeners=function(h){var d=r.prototype.removeAllListeners.apply(this,arguments);return(h==="readable"||h===void 0)&&process.nextTick(ie,this),d};function ie(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(Me,h,d))}function Me(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,B=this._readableState,F=!1;h.on("end",function(){if(p("wrapped end"),B.decoder&&!B.ended){var G=B.decoder.end();G&&G.length&&d.push(G)}d.push(null)}),h.on("data",function(G){if(p("wrapped data"),B.decoder&&(G=B.decoder.write(G)),!(B.objectMode&&G==null)&&!(!B.objectMode&&(!G||!G.length))){var We=d.push(G);We||(F=!0,h.pause())}});for(var Q in h)this[Q]===void 0&&typeof h[Q]=="function"&&(this[Q]=function(We){return function(){return h[We].apply(h,arguments)}}(Q));for(var W=0;W<E.length;W++)h.on(E[W],this.emit.bind(this,E[W]));return this._read=function(G){p("wrapped _read",G),F&&(F=!1,h.resume())},this},typeof Symbol=="function"&&($.prototype[Symbol.asyncIterator]=function(){return P===void 0&&(P=Da()),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 B;return d.objectMode?B=d.buffer.shift():!h||h>=d.length?(d.decoder?B=d.buffer.join(""):d.buffer.length===1?B=d.buffer.first():B=d.buffer.concat(d.length),d.buffer.clear()):B=d.buffer.consume(h,d.decoder),B}function S(h){var d=h._readableState;p("endReadable",d.endEmitted),d.endEmitted||(d.ended=!0,process.nextTick(D,d,h))}function D(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 B=d._writableState;(!B||B.autoDestroy&&B.finished)&&d.destroy()}}typeof Symbol=="function"&&($.from=function(h,d){return L===void 0&&(L=$a()),L($,h,d)});function q(h,d){for(var B=0,F=h.length;B<F;B++)if(h[B]===d)return B;return-1}return dr}var Gn=De,Gt=Ze.codes,Ha=Gt.ERR_METHOD_NOT_IMPLEMENTED,ja=Gt.ERR_MULTIPLE_CALLBACK,qa=Gt.ERR_TRANSFORM_ALREADY_TRANSFORMING,Wa=Gt.ERR_TRANSFORM_WITH_LENGTH_0,Vt=lt();be(De,Vt);function Ka(e,t){var r=this._transformState;r.transforming=!1;var a=r.writecb;if(a===null)return this.emit("error",new ja);r.writechunk=null,r.writecb=null,t!=null&&this.push(t),a(e);var o=this._readableState;o.reading=!1,(o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}function De(e){if(!(this instanceof De))return new De(e);Vt.call(this,e),this._transformState={afterTransform:Ka.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",Ga)}function Ga(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){rn(e,t,r)}):rn(this,null,null)}De.prototype.push=function(e,t){return this._transformState.needTransform=!1,Vt.prototype.push.call(this,e,t)};De.prototype._transform=function(e,t,r){r(new Ha("_transform()"))};De.prototype._write=function(e,t,r){var a=this._transformState;if(a.writecb=r,a.writechunk=e,a.writeencoding=t,!a.transforming){var o=this._readableState;(a.needTransform||o.needReadable||o.length<o.highWaterMark)&&this._read(o.highWaterMark)}};De.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};De.prototype._destroy=function(e,t){Vt.prototype._destroy.call(this,e,function(r){t(r)})};function rn(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new Wa;if(e._transformState.transforming)throw new qa;return e.push(null)}var Va=Rt,Vn=Gn;be(Rt,Vn);function Rt(e){if(!(this instanceof Rt))return new Rt(e);Vn.call(this,e)}Rt.prototype._transform=function(e,t,r){r(null,e)};var pr;function za(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var zn=Ze.codes,Ja=zn.ERR_MISSING_ARGS,Ya=zn.ERR_STREAM_DESTROYED;function nn(e){if(e)throw e}function Xa(e){return e.setHeader&&typeof e.abort=="function"}function Qa(e,t,r,a){a=za(a);var o=!1;e.on("close",function(){o=!0}),pr===void 0&&(pr=Fr),pr(e,{readable:t,writable:r},function(c){if(c)return a(c);o=!0,a()});var s=!1;return function(c){if(!o&&!s){if(s=!0,Xa(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();a(c||new Ya("pipe"))}}}function an(e){e()}function Za(e,t){return e.pipe(t)}function eo(e){return!e.length||typeof e[e.length-1]!="function"?nn:e.pop()}function to(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=eo(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Ja("streams");var o,s=t.map(function(c,u){var p=u<t.length-1,w=u>0;return Qa(c,p,w,function(m){o||(o=m),m&&s.forEach(an),!p&&(s.forEach(an),a(o))})});return t.reduce(Za)}var ro=to;(function(e,t){t=e.exports=Kn(),t.Stream=t,t.Readable=t,t.Writable=qn(),t.Duplex=lt(),t.Transform=Gn,t.PassThrough=Va,t.finished=Fr,t.pipeline=ro})(Er,Er.exports);var no=Er.exports,Ht=xe.Buffer,Jn=no.Transform,io=be;function ao(e,t){if(!Ht.isBuffer(e)&&typeof e!="string")throw new TypeError(t+" must be a string or a buffer")}function Ve(e){Jn.call(this),this._block=Ht.allocUnsafe(e),this._blockSize=e,this._blockOffset=0,this._length=[0,0,0,0],this._finalized=!1}io(Ve,Jn);Ve.prototype._transform=function(e,t,r){var a=null;try{this.update(e,t)}catch(o){a=o}r(a)};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(ao(e,"Data"),this._finalized)throw new Error("Digest already called");Ht.isBuffer(e)||(e=Ht.from(e,t));for(var r=this._block,a=0;this._blockOffset+e.length-a>=this._blockSize;){for(var o=this._blockOffset;o<this._blockSize;)r[o++]=e[a++];this._update(),this._blockOffset=0}for(;a<e.length;)r[this._blockOffset++]=e[a++];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 Yn=Ve,oo=be,Xn=Yn,so=xe.Buffer,fo=new Array(16);function zt(){Xn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}oo(zt,Xn);zt.prototype._update=function(){for(var e=fo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,a=this._b,o=this._c,s=this._d;r=ue(r,a,o,s,e[0],3614090360,7),s=ue(s,r,a,o,e[1],3905402710,12),o=ue(o,s,r,a,e[2],606105819,17),a=ue(a,o,s,r,e[3],3250441966,22),r=ue(r,a,o,s,e[4],4118548399,7),s=ue(s,r,a,o,e[5],1200080426,12),o=ue(o,s,r,a,e[6],2821735955,17),a=ue(a,o,s,r,e[7],4249261313,22),r=ue(r,a,o,s,e[8],1770035416,7),s=ue(s,r,a,o,e[9],2336552879,12),o=ue(o,s,r,a,e[10],4294925233,17),a=ue(a,o,s,r,e[11],2304563134,22),r=ue(r,a,o,s,e[12],1804603682,7),s=ue(s,r,a,o,e[13],4254626195,12),o=ue(o,s,r,a,e[14],2792965006,17),a=ue(a,o,s,r,e[15],1236535329,22),r=ce(r,a,o,s,e[1],4129170786,5),s=ce(s,r,a,o,e[6],3225465664,9),o=ce(o,s,r,a,e[11],643717713,14),a=ce(a,o,s,r,e[0],3921069994,20),r=ce(r,a,o,s,e[5],3593408605,5),s=ce(s,r,a,o,e[10],38016083,9),o=ce(o,s,r,a,e[15],3634488961,14),a=ce(a,o,s,r,e[4],3889429448,20),r=ce(r,a,o,s,e[9],568446438,5),s=ce(s,r,a,o,e[14],3275163606,9),o=ce(o,s,r,a,e[3],4107603335,14),a=ce(a,o,s,r,e[8],1163531501,20),r=ce(r,a,o,s,e[13],2850285829,5),s=ce(s,r,a,o,e[2],4243563512,9),o=ce(o,s,r,a,e[7],1735328473,14),a=ce(a,o,s,r,e[12],2368359562,20),r=le(r,a,o,s,e[5],4294588738,4),s=le(s,r,a,o,e[8],2272392833,11),o=le(o,s,r,a,e[11],1839030562,16),a=le(a,o,s,r,e[14],4259657740,23),r=le(r,a,o,s,e[1],2763975236,4),s=le(s,r,a,o,e[4],1272893353,11),o=le(o,s,r,a,e[7],4139469664,16),a=le(a,o,s,r,e[10],3200236656,23),r=le(r,a,o,s,e[13],681279174,4),s=le(s,r,a,o,e[0],3936430074,11),o=le(o,s,r,a,e[3],3572445317,16),a=le(a,o,s,r,e[6],76029189,23),r=le(r,a,o,s,e[9],3654602809,4),s=le(s,r,a,o,e[12],3873151461,11),o=le(o,s,r,a,e[15],530742520,16),a=le(a,o,s,r,e[2],3299628645,23),r=he(r,a,o,s,e[0],4096336452,6),s=he(s,r,a,o,e[7],1126891415,10),o=he(o,s,r,a,e[14],2878612391,15),a=he(a,o,s,r,e[5],4237533241,21),r=he(r,a,o,s,e[12],1700485571,6),s=he(s,r,a,o,e[3],2399980690,10),o=he(o,s,r,a,e[10],4293915773,15),a=he(a,o,s,r,e[1],2240044497,21),r=he(r,a,o,s,e[8],1873313359,6),s=he(s,r,a,o,e[15],4264355552,10),o=he(o,s,r,a,e[6],2734768916,15),a=he(a,o,s,r,e[13],1309151649,21),r=he(r,a,o,s,e[4],4149444226,6),s=he(s,r,a,o,e[11],3174756917,10),o=he(o,s,r,a,e[2],718787259,15),a=he(a,o,s,r,e[9],3951481745,21),this._a=this._a+r|0,this._b=this._b+a|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=so.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 Jt(e,t){return e<<t|e>>>32-t}function ue(e,t,r,a,o,s,c){return Jt(e+(t&r|~t&a)+o+s|0,c)+t|0}function ce(e,t,r,a,o,s,c){return Jt(e+(t&a|r&~a)+o+s|0,c)+t|0}function le(e,t,r,a,o,s,c){return Jt(e+(t^r^a)+o+s|0,c)+t|0}function he(e,t,r,a,o,s,c){return Jt(e+(r^(t|~a))+o+s|0,c)+t|0}var uo=zt,br=ht.Buffer,co=be,Qn=Yn,lo=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 Yt(){Qn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}co(Yt,Qn);Yt.prototype._update=function(){for(var e=lo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,a=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=this._a|0,p=this._b|0,w=this._c|0,m=this._d|0,v=this._e|0,T=0;T<80;T+=1){var O,R;T<16?(O=on(r,a,o,s,c,e[gt[T]],xt[0],mt[T]),R=cn(u,p,w,m,v,e[wt[T]],Et[0],vt[T])):T<32?(O=sn(r,a,o,s,c,e[gt[T]],xt[1],mt[T]),R=un(u,p,w,m,v,e[wt[T]],Et[1],vt[T])):T<48?(O=fn(r,a,o,s,c,e[gt[T]],xt[2],mt[T]),R=fn(u,p,w,m,v,e[wt[T]],Et[2],vt[T])):T<64?(O=un(r,a,o,s,c,e[gt[T]],xt[3],mt[T]),R=sn(u,p,w,m,v,e[wt[T]],Et[3],vt[T])):(O=cn(r,a,o,s,c,e[gt[T]],xt[4],mt[T]),R=on(u,p,w,m,v,e[wt[T]],Et[4],vt[T])),r=c,c=s,s=Qe(o,10),o=a,a=O,u=v,v=m,m=Qe(w,10),w=p,p=R}var k=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+a+w|0,this._a=k};Yt.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=br.alloc?br.alloc(20):new br(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 on(e,t,r,a,o,s,c,u){return Qe(e+(t^r^a)+s+c|0,u)+o|0}function sn(e,t,r,a,o,s,c,u){return Qe(e+(t&r|~t&a)+s+c|0,u)+o|0}function fn(e,t,r,a,o,s,c,u){return Qe(e+((t|~r)^a)+s+c|0,u)+o|0}function un(e,t,r,a,o,s,c,u){return Qe(e+(t&a|r&~a)+s+c|0,u)+o|0}function cn(e,t,r,a,o,s,c,u){return Qe(e+(t^(r|~a))+s+c|0,u)+o|0}var ho=Yt,Zn={exports:{}},ei=xe.Buffer;function Xt(e,t){this._block=ei.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Xt.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=ei.from(e,t));for(var r=this._block,a=this._blockSize,o=e.length,s=this._len,c=0;c<o;){for(var u=s%a,p=Math.min(o-c,a-u),w=0;w<p;w++)r[u+w]=e[c+w];s+=p,c+=p,s%a===0&&this._update(r)}return this._len+=o,this};Xt.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 a=(r&4294967295)>>>0,o=(r-a)/4294967296;this._block.writeUInt32BE(o,this._blockSize-8),this._block.writeUInt32BE(a,this._blockSize-4)}this._update(this._block);var s=this._hash();return e?s.toString(e):s};Xt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var dt=Xt,po=be,ti=dt,bo=xe.Buffer,yo=[1518500249,1859775393,-1894007588,-899497514],_o=new Array(80);function Tt(){this.init(),this._w=_o,ti.call(this,64,56)}po(Tt,ti);Tt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function go(e){return e<<5|e>>>27}function wo(e){return e<<30|e>>>2}function mo(e,t,r,a){return e===0?t&r|~t&a:e===2?t&r|t&a|r&a:t^r^a}Tt.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=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 w=~~(p/20),m=go(r)+mo(w,a,o,s)+c+t[p]+yo[w]|0;c=s,s=o,o=wo(a),a=r,r=m}this._a=r+this._a|0,this._b=a+this._b|0,this._c=o+this._c|0,this._d=s+this._d|0,this._e=c+this._e|0};Tt.prototype._hash=function(){var e=bo.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 vo=Tt,xo=be,ri=dt,Eo=xe.Buffer,Bo=[1518500249,1859775393,-1894007588,-899497514],Ro=new Array(80);function It(){this.init(),this._w=Ro,ri.call(this,64,56)}xo(It,ri);It.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function So(e){return e<<1|e>>>31}function Ao(e){return e<<5|e>>>27}function To(e){return e<<30|e>>>2}function Io(e,t,r,a){return e===0?t&r|~t&a:e===2?t&r|t&a|r&a:t^r^a}It.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=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]=So(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var w=~~(p/20),m=Ao(r)+Io(w,a,o,s)+c+t[p]+Bo[w]|0;c=s,s=o,o=To(a),a=r,r=m}this._a=r+this._a|0,this._b=a+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=Eo.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 ko=It,Co=be,ni=dt,Oo=xe.Buffer,Lo=[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],Mo=new Array(64);function kt(){this.init(),this._w=Mo,ni.call(this,64,56)}Co(kt,ni);kt.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 Po(e,t,r){return r^e&(t^r)}function Fo(e,t,r){return e&t|r&(e|t)}function No(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Uo(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function Do(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function $o(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}kt.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=this._b|0,o=this._c|0,s=this._d|0,c=this._e|0,u=this._f|0,p=this._g|0,w=this._h|0,m=0;m<16;++m)t[m]=e.readInt32BE(m*4);for(;m<64;++m)t[m]=$o(t[m-2])+t[m-7]+Do(t[m-15])+t[m-16]|0;for(var v=0;v<64;++v){var T=w+Uo(c)+Po(c,u,p)+Lo[v]+t[v]|0,O=No(r)+Fo(r,a,o)|0;w=p,p=u,u=c,c=s+T|0,s=o,o=a,a=r,r=T+O|0}this._a=r+this._a|0,this._b=a+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=w+this._h|0};kt.prototype._hash=function(){var e=Oo.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 ii=kt,Ho=be,jo=ii,qo=dt,Wo=xe.Buffer,Ko=new Array(64);function Qt(){this.init(),this._w=Ko,qo.call(this,64,56)}Ho(Qt,jo);Qt.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};Qt.prototype._hash=function(){var e=Wo.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 Go=Qt,Vo=be,ai=dt,zo=xe.Buffer,ln=[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],Jo=new Array(160);function Ct(){this.init(),this._w=Jo,ai.call(this,128,112)}Vo(Ct,ai);Ct.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 hn(e,t,r){return r^e&(t^r)}function dn(e,t,r){return e&t|r&(e|t)}function pn(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function bn(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Yo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function Xo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Qo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function Zo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^(e>>>6|t<<26)}function se(e,t){return e>>>0<t>>>0?1:0}Ct.prototype._update=function(e){for(var t=this._w,r=this._ah|0,a=this._bh|0,o=this._ch|0,s=this._dh|0,c=this._eh|0,u=this._fh|0,p=this._gh|0,w=this._hh|0,m=this._al|0,v=this._bl|0,T=this._cl|0,O=this._dl|0,R=this._el|0,k=this._fl|0,A=this._gl|0,I=this._hl|0,M=0;M<32;M+=2)t[M]=e.readInt32BE(M*4),t[M+1]=e.readInt32BE(M*4+4);for(;M<160;M+=2){var P=t[M-30],L=t[M-15*2+1],N=Yo(P,L),E=Xo(L,P);P=t[M-2*2],L=t[M-2*2+1];var j=Qo(P,L),U=Zo(L,P),$=t[M-7*2],ne=t[M-7*2+1],Te=t[M-16*2],$e=t[M-16*2+1],oe=E+ne|0,me=N+$+se(oe,E)|0;oe=oe+U|0,me=me+j+se(oe,U)|0,oe=oe+$e|0,me=me+Te+se(oe,$e)|0,t[M]=me,t[M+1]=oe}for(var ve=0;ve<160;ve+=2){me=t[ve],oe=t[ve+1];var ze=dn(r,a,o),Ie=dn(m,v,T),He=pn(r,m),ke=pn(m,r),je=bn(c,R),X=bn(R,c),ie=ln[ve],Ee=ln[ve+1],qe=hn(c,u,p),Me=hn(R,k,A),_=I+X|0,y=w+je+se(_,I)|0;_=_+Me|0,y=y+qe+se(_,Me)|0,_=_+Ee|0,y=y+ie+se(_,Ee)|0,_=_+oe|0,y=y+me+se(_,oe)|0;var S=ke+Ie|0,D=He+ze+se(S,ke)|0;w=p,I=A,p=u,A=k,u=c,k=R,R=O+_|0,c=s+y+se(R,O)|0,s=o,O=T,o=a,T=v,a=r,v=m,m=_+S|0,r=y+D+se(m,_)|0}this._al=this._al+m|0,this._bl=this._bl+v|0,this._cl=this._cl+T|0,this._dl=this._dl+O|0,this._el=this._el+R|0,this._fl=this._fl+k|0,this._gl=this._gl+A|0,this._hl=this._hl+I|0,this._ah=this._ah+r+se(this._al,m)|0,this._bh=this._bh+a+se(this._bl,v)|0,this._ch=this._ch+o+se(this._cl,T)|0,this._dh=this._dh+s+se(this._dl,O)|0,this._eh=this._eh+c+se(this._el,R)|0,this._fh=this._fh+u+se(this._fl,k)|0,this._gh=this._gh+p+se(this._gl,A)|0,this._hh=this._hh+w+se(this._hl,I)|0};Ct.prototype._hash=function(){var e=zo.allocUnsafe(64);function t(r,a,o){e.writeInt32BE(r,o),e.writeInt32BE(a,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 oi=Ct,es=be,ts=oi,rs=dt,ns=xe.Buffer,is=new Array(160);function Zt(){this.init(),this._w=is,rs.call(this,128,112)}es(Zt,ts);Zt.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};Zt.prototype._hash=function(){var e=ns.allocUnsafe(48);function t(r,a,o){e.writeInt32BE(r,o),e.writeInt32BE(a,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 as=Zt,et=Zn.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=vo;et.sha1=ko;et.sha224=Go;et.sha256=ii;et.sha384=as;et.sha512=oi;var os=Zn.exports,si=xe.Buffer,fi=Mr.Transform,ss=$t.StringDecoder,fs=be;function Ce(e){fi.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}fs(Ce,fi);Ce.prototype.update=function(e,t,r){typeof e=="string"&&(e=si.from(e,t));var a=this._update(e);return this.hashMode?this:(r&&(a=this._toString(a,r)),a)};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 a;try{this.hashMode?this._update(e):this.push(this._update(e))}catch(o){a=o}finally{r(a)}};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()||si.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Ce.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new ss(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var a=this._decoder.write(e);return r&&(a+=this._decoder.end()),a};var us=Ce,cs=be,ls=uo,hs=ho,ds=os,ui=us;function er(e){ui.call(this,"digest"),this._hash=e}cs(er,ui);er.prototype._update=function(e){this._hash.update(e)};er.prototype._final=function(){return this._hash.digest()};var ps=function(t){return t=t.toLowerCase(),t==="md5"?new ls:t==="rmd160"||t==="ripemd160"?new hs:new er(ds(t))},Lt=xe.Buffer;function bs(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 a=0;a<e.length;a++){var o=e.charAt(a),s=o.charCodeAt(0);if(t[s]!==255)throw new TypeError(o+" is ambiguous");t[s]=a}var c=e.length,u=e.charAt(0),p=Math.log(c)/Math.log(256),w=Math.log(256)/Math.log(c);function m(O){if((Array.isArray(O)||O instanceof Uint8Array)&&(O=Lt.from(O)),!Lt.isBuffer(O))throw new TypeError("Expected Buffer");if(O.length===0)return"";for(var R=0,k=0,A=0,I=O.length;A!==I&&O[A]===0;)A++,R++;for(var M=(I-A)*w+1>>>0,P=new Uint8Array(M);A!==I;){for(var L=O[A],N=0,E=M-1;(L!==0||N<k)&&E!==-1;E--,N++)L+=256*P[E]>>>0,P[E]=L%c>>>0,L=L/c>>>0;if(L!==0)throw new Error("Non-zero carry");k=N,A++}for(var j=M-k;j!==M&&P[j]===0;)j++;for(var U=u.repeat(R);j<M;++j)U+=e.charAt(P[j]);return U}function v(O){if(typeof O!="string")throw new TypeError("Expected String");if(O.length===0)return Lt.alloc(0);for(var R=0,k=0,A=0;O[R]===u;)k++,R++;for(var I=(O.length-R)*p+1>>>0,M=new Uint8Array(I);R<O.length;){var P=t[O.charCodeAt(R)];if(P===255)return;for(var L=0,N=I-1;(P!==0||L<A)&&N!==-1;N--,L++)P+=c*M[N]>>>0,M[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");A=L,R++}for(var E=I-A;E!==I&&M[E]===0;)E++;var j=Lt.allocUnsafe(k+(I-E));j.fill(0,0,k);for(var U=k;E!==I;)j[U++]=M[E++];return j}function T(O){var R=v(O);if(R)return R;throw new Error("Non-base"+c+" character")}return{encode:m,decodeUnsafe:v,decode:T}}var ys=bs,_s=ys,gs="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ws=_s(gs),yr=ws,ms=xe.Buffer,vs=function(e){function t(s){var c=e(s);return yr.encode(ms.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 a(s){var c=yr.decodeUnsafe(s);if(c)return r(c)}function o(s){var c=yr.decode(s),u=r(c);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:o,decodeUnsafe:a}},yn=ps,xs=vs;function Es(e){var t=yn("sha256").update(e).digest();return yn("sha256").update(t).digest()}var Bs=xs(Es),Rr=Bs;function ci(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 a=new Buffer(r?34:33);return a.writeUInt8(e,0),t.copy(a,1),r&&(a[33]=1),a}function Rs(e,t){return ci(Rr.decode(e),t)}function Ss(e,t,r){return typeof e=="number"?Rr.encode(Sr(e,t,r)):Rr.encode(Sr(e.version,e.privateKey,e.compressed))}var As={decode:Rs,decodeRaw:ci,encode:Ss,encodeRaw:Sr},tr={};Object.defineProperty(tr,"__esModule",{value:!0});tr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Ts(e){Y(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),Y(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Y(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),Y(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),Y(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),Y(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),Y(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),Y(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),Y(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),Y(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),Y(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),Y(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),Y(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),Y(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),Y(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),Y(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));Y(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),Y(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),Y(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),Y(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&Y(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&Y(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}tr.testEcc=Ts;function Y(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 _e=En,Is=ta,_n=As,ks=tr,_r=_e.typeforce.maybe(_e.typeforce.compile({compressed:_e.maybe(_e.Boolean),network:_e.maybe(_e.Network)})),Cs=e=>e.length===32?e:e.slice(1,33);function Os(e){(0,ks.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,p){if(_e.typeforce(_e.Buffer256bit,u),!e.isPrivate(u))throw new TypeError("Private key not in range [1, n)");return _e.typeforce(_r,p),new c(u,void 0,p)}function a(u,p){return _e.typeforce(e.isPoint,u),_e.typeforce(_r,p),new c(void 0,u,p)}function o(u,p){const w=_n.decode(u),m=w.version;if(_e.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(w.privateKey,{compressed:w.compressed,network:p})}function s(u){_e.typeforce(_r,u),u===void 0&&(u={});const p=u.rng||Is;let w;do w=p(32),_e.typeforce(_e.Buffer256bit,w);while(!e.isPrivate(w));return r(w,u)}class c{constructor(p,w,m){nt(this,"__D");nt(this,"__Q");nt(this,"compressed");nt(this,"network");nt(this,"lowR");this.__D=p,this.__Q=w,this.lowR=!1,m===void 0&&(m={}),this.compressed=m.compressed===void 0?!0:m.compressed,this.network=m.network||Ar.bitcoin,w!==void 0&&(this.__Q=Buffer.from(e.pointCompress(w,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 _n.encode(this.network.wif,this.__D,this.compressed)}tweak(p){return this.privateKey?this.tweakFromPrivateKey(p):this.tweakFromPublicKey(p)}sign(p,w){if(!this.__D)throw new Error("Missing private key");if(w===void 0&&(w=this.lowR),w===!1)return Buffer.from(e.sign(p,this.__D));{let m=e.sign(p,this.__D);const v=Buffer.alloc(32,0);let T=0;for(;m[0]>127;)T++,v.writeUIntLE(T,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,w){return e.verify(p,this.publicKey,w)}verifySchnorr(p,w){if(!e.verifySchnorr)throw new Error("verifySchnorr not supported by ecc library");return e.verifySchnorr(p,this.publicKey.subarray(1,33),w)}tweakFromPublicKey(p){const w=Cs(this.publicKey),m=e.xOnlyPointAddTweak(w,p);if(!m||m.xOnlyPubkey===null)throw new Error("Cannot tweak public key!");const v=Buffer.from([m.parity===0?2:3]);return a(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:a,fromWIF:o,makeRandom:s}}ut.ECPairFactory=Os;(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}})})(xn);class jt{constructor(t){this.privKey=t}static fromPrivKey(t){return new jt(C.trim0x(t))}static async fromWalletClient(t){if(!t.account)return C.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 swap",Version:"1.0.2",Nonce:1n}});return C.Ok(new jt(C.trim0x(Ne.sha256(r))))}catch(r){return C.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),a=Ne.sha256(ge.with0x(r)),o=Ne.sha256(a);return C.Ok({secret:a,secretHash:o})}signMessage(t){const r=xn.ECPairFactory(ft),a="Garden.fi"+t.toString(),o=Buffer.from(a,"utf8"),s=Ne.sha256(o),c=Buffer.from(C.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(C.trim0x(s),"hex")).toString("hex")}}class Ls{constructor(t){this.quoteUrl=new ge.Url("/quote",t)}async getQuote(t,r,a=!1){try{const o=this.quoteUrl.addSearchParams({order_pair:t,amount:r.toString(),exact_out:a.toString()}),s=await C.Fetcher.get(o);return s.error?C.Err(s.error):s.result?C.Ok(s.result):C.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return C.Err("GetQuote:",String(o))}}async getAttestedQuote(t){try{const r=await C.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?C.Err(r.error):r.result?C.Ok(r.result):C.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),C.Err("GetAttestedQuote:",String(r))}}}exports.EvmRelay=vn;exports.Garden=Mi;exports.ParseOrderStatus=wn;exports.ParseSwapStatus=Ft;exports.Quote=Ls;exports.SecretManager=jt;exports.parseAction=mn;exports.switchOrAddNetwork=Ri;