@gardenfi/core 0.2.0-beta.16 → 0.2.0-beta.18
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 +5 -5
- package/dist/index.js +71 -75
- package/dist/src/index.d.ts +0 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var ci=Object.defineProperty;var li=(e,t,r)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var nt=(e,t,r)=>li(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@catalogfi/utils"),z=require("@gardenfi/orderbook"),pe=require("@gardenfi/utils"),Ne=require("viem"),hi=require("varuint-bitcoin"),di=require("tiny-secp256k1"),Nr=require("@catalogfi/wallets"),_n=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 Dr=Tr(hi),ft=Tr(di),de=Tr(_n);var gr=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(gr||{}),Se=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(Se||{});function qt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const pi=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}}}),bi=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}),yi=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}}}),_i=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 gi(e){return Buffer.concat([Uint8Array.from([192]),wi(e)])}function wi(e){const t=Dr.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Dr.encode(e.length,r),Buffer.concat([r,e])}function mi(e,t){if(e.compare(t)>0){const r=e;e=t,t=r}return[e,t]}const Ct=e=>e.length===64?e:e.slice(2),vi=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return ft.isPoint(t)}catch{return!1}},xi={ethereum:yi,ethereum_arbitrum:pi,ethereum_sepolia:_i,arbitrum_sepolia:bi,ethereum_localnet:z.EthereumLocalnet,arbitrum_localnet:z.ArbitrumLocalnet},Ei=async(e,t)=>{var a;const r=xi[e];if(r)try{if(r.id===((a=t.chain)==null?void 0:a.id))return L.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.http()});return L.Ok({message:"Switched chain",walletClient:o})}catch(o){if(Bi(o))try{await t.addChain({chain:r});const f=Ne.createWalletClient({account:t.account,chain:r,transport:Ne.http()});return L.Ok({message:"Added network",walletClient:f})}catch{return L.Err("Failed to add network")}else return L.Err("Failed to switch network")}else return L.Err("Chain not supported")},Bi=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902;var oe=(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))(oe||{}),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 gn=(e,t,r)=>{const a=Ft(e.source_swap,t),o=Ft(e.destination_swap,r);return a===ee.RedeemDetected?oe.CounterPartyRedeemDetected:a===ee.Redeemed?oe.CounterPartyRedeemed:o===ee.RedeemDetected?oe.RedeemDetected:o===ee.Redeemed?oe.Redeemed:o===ee.RefundDetected?oe.CounterPartyRefundDetected:o===ee.Refunded?oe.CounterPartyRefunded:a===ee.RefundDetected?oe.RefundDetected:a===ee.Refunded?oe.Refunded:o===ee.Expired?oe.CounterPartySwapExpired:a===ee.Expired?oe.Expired:o===ee.InitiateDetected?oe.CounterPartyInitiateDetected:o===ee.Initiated?oe.CounterPartyInitiated:a===ee.InitiateDetected?oe.InitiateDetected:a===ee.Initiated?oe.Initiated:oe.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},wn=(e,t,r)=>{switch(gn(e,t,r)){case oe.Matched:return Se.Initiate;case oe.CounterPartyInitiated:return Se.Redeem;case oe.Expired:return Se.Refund;default:return Se.Idle}},Ri=[{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 mn{constructor(t,r,a){this.url=new pe.Url("/relayer",r),this.auth=a,this.order=t}async init(t,r){if(!t.account)return L.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return L.Err("Account and order initiator mismatch");if(!r){const m=await pe.fetchEVMBlockNumber(t);if(m.error)return L.Err(m.error);r=m.val}if(Ft(this.order.source_swap,r)!==ee.Idle)return L.Err("Invalid swap status");const{create_order:o,source_swap:f}=this.order;if(!f.amount||!f.redeemer||!o.timelock||!o.secret_hash)return L.Err("Invalid order");const c=pe.with0x(o.secret_hash),u=BigInt(o.timelock),p=pe.with0x(f.redeemer),w=BigInt(f.amount);try{const m=await this.auth.getToken();if(m.error)return L.Err(m.error);const v=Ne.getContract({address:pe.with0x(this.order.source_swap.asset),abi:Ri,client:t}),A=await v.read.token(),k=await pe.checkAllowanceAndApprove(Number(w),A,this.order.source_swap.asset,t);if(k.error)return L.Err(k.error);const R=await v.read.eip712Domain(),C=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}}),S=await L.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:o.create_id,signature:C,perform_on:"Source"}),headers:{Authorization:pe.Authorization(m.val),"Content-Type":"application/json"}});return S.error?L.Err(S.error):S.result?L.Ok(S.result):L.Err("Init: No result found")}catch(m){return console.log("init error :",m),L.Err(String(m))}}async redeem(t,r){try{const a=await this.auth.getToken();if(a.error)return L.Err(a.error);const o=await L.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:L.trim0x(r),perform_on:"Destination"}),headers:{Authorization:pe.Authorization(a.val),"Content-Type":"application/json"}});return o.error?L.Err(o.error):o.result?L.Ok(o.result):L.Err("Redeem: No result found")}catch(a){return L.Err(String(a))}}}const Si=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Ai=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),Ti=Buffer.concat([Si,Ai]),Ii=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),Ur={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function ki(){const e=_n.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=ft.pointMultiply(Buffer.concat([Buffer.from("04","hex"),Ti]),e);if(!t)throw new Error(Ur.failedToCreateInternalPubkey);const r=ft.pointAdd(Ii,t);if(!r)throw new Error(Ur.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,f,c,u){this.secretHash=a,this.redeemerPubkey=o,this.initiatorPubkey=f,this.expiry=c,this.signer=t,this.network=u,this.internalPubkey=ki(),this.initiateAmount=r}static async from(t,r,a,o,f,c){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(f.length===64||f.length===66,`redeemer ${ye.pubkeyLenMismatch}`),it(c>0,ye.zeroOrNegativeExpiry);const u=await t.getNetwork();return new Nt(t,r,a,wr(f).toString("hex"),wr(o).toString("hex"),c,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(),f=await this.signer.getProvider(),c=await f.getUTXOs(o),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 f.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(A=>A.utxo===v.txid))throw new Error(ye.counterPartySigNotFound(v.txid));const f=this.getOutputScript(),c=de.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),p=o.map(v=>v.value),w=rr(f,o.length);for(let v=0;v<a.ins.length;v++){const A=a.hashForWitnessV1(v,w,p,c,u);if(!ft.verifySchnorr(A,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[v].sig,"hex")))throw new Error(ye.invalidCounterpartySigForUTXO(t[v].utxo));const k=await this.signer.signSchnorr(A),R=Buffer.from(a.ins[v].hash).reverse().toString("hex"),C=t.find(S=>S.utxo===R);if(!C)throw new Error(ye.counterPartySigNotFound(R));a.setWitness(v,[Buffer.from(C.sig,"hex"),k,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:f}=await this._buildRawTx(r??await this.signer.getAddress(),a),c=this.leafHash(1),u=f.map(v=>v.value),p=rr(this.getOutputScript(),f.length),w=de.Transaction.SIGHASH_DEFAULT;for(let v=0;v<o.ins.length;v++){const A=o.hashForWitnessV1(v,p,u,w,c),k=await this.signer.signSchnorr(A);o.setWitness(v,[k,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(o.toHex())}async refund(t,r){const{tx:a,usedUtxos:o}=await this._buildRawTx(t??await this.signer.getAddress(),r),[f,c]=await this.canRefund(o);if(!f)throw new Error(ye.htlcNotExpired(c));const u=this.leafHash(0),p=o.map(A=>A.value),w=rr(this.getOutputScript(),o.length),m=de.Transaction.SIGHASH_DEFAULT;for(let A=0;A<a.ins.length;A++){a.ins[A].sequence=this.expiry;const k=a.hashForWitnessV1(A,w,p,m,u),R=await this.signer.signSchnorr(k);a.setWitness(A,[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 f=0;if(o.status.confirmed&&o.status.block_height+this.expiry>a?f=o.status.block_height+this.expiry-a+1:o.status.confirmed||(f=this.expiry+1),f>0)return[!1,f]}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",gi(r))}refundLeaf(){return de.script.fromASM(`
|
|
1
|
+
"use strict";var ci=Object.defineProperty;var li=(e,t,r)=>t in e?ci(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r;var nt=(e,t,r)=>li(e,typeof t!="symbol"?t+"":t,r);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const L=require("@catalogfi/utils"),ee=require("@gardenfi/orderbook"),pe=require("@gardenfi/utils"),Ne=require("viem"),hi=require("varuint-bitcoin"),di=require("tiny-secp256k1"),Nr=require("@catalogfi/wallets"),_n=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 Dr=Tr(hi),ft=Tr(di),de=Tr(_n);var gr=(e=>(e[e.evm=14400]="evm",e[e.btc=288]="btc",e))(gr||{}),Se=(e=>(e.Idle="Idle",e.Initiate="Initiate",e.Redeem="Redeem",e.Refund="Refund",e))(Se||{});function qt(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}const pi=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}}}),bi=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}),yi=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}}}),_i=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 gi(e){return Buffer.concat([Uint8Array.from([192]),wi(e)])}function wi(e){const t=Dr.encodingLength(e.length),r=Buffer.allocUnsafe(t);return Dr.encode(e.length,r),Buffer.concat([r,e])}function mi(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),vi=e=>{if(!e)return!1;try{const t=Buffer.from(e,"hex");return ft.isPoint(t)}catch{return!1}},xi={ethereum:yi,ethereum_arbitrum:pi,ethereum_sepolia:_i,arbitrum_sepolia:bi,ethereum_localnet:ee.EthereumLocalnet,arbitrum_localnet:ee.ArbitrumLocalnet},Ei=async(e,t)=>{var a;const r=xi[e];if(r)try{if(r.id===((a=t.chain)==null?void 0:a.id))return L.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.http()});return L.Ok({message:"Switched chain",walletClient:o})}catch(o){if(Bi(o))try{await t.addChain({chain:r});const f=Ne.createWalletClient({account:t.account,chain:r,transport:Ne.http()});return L.Ok({message:"Added network",walletClient:f})}catch{return L.Err("Failed to add network")}else return L.Err("Failed to switch network")}else return L.Err("Chain not supported")},Bi=e=>typeof e=="object"&&e!==null&&"code"in e&&e.code===4902;var oe=(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))(oe||{}),Z=(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))(Z||{});const gn=(e,t,r)=>{const a=Ft(e.source_swap,t),o=Ft(e.destination_swap,r);return a===Z.RedeemDetected?oe.CounterPartyRedeemDetected:a===Z.Redeemed?oe.CounterPartyRedeemed:o===Z.RedeemDetected?oe.RedeemDetected:o===Z.Redeemed?oe.Redeemed:o===Z.RefundDetected?oe.CounterPartyRefundDetected:o===Z.Refunded?oe.CounterPartyRefunded:a===Z.RefundDetected?oe.RefundDetected:a===Z.Refunded?oe.Refunded:o===Z.Expired?oe.CounterPartySwapExpired:a===Z.Expired?oe.Expired:o===Z.InitiateDetected?oe.CounterPartyInitiateDetected:o===Z.Initiated?oe.CounterPartyInitiated:a===Z.InitiateDetected?oe.InitiateDetected:a===Z.Initiated?oe.Initiated:oe.Matched},Ft=(e,t)=>{if(e.redeem_tx_hash)return e.redeem_block_number?Z.Redeemed:Z.RedeemDetected;if(e.refund_tx_hash)return e.refund_block_number?Z.Refunded:Z.RefundDetected;if(Number(e.initiate_block_number)){const r=Number(e.initiate_block_number)+e.timelock;if(t>r)return Z.Expired}return e.initiate_tx_hash?e.initiate_block_number?Z.Initiated:Z.InitiateDetected:Z.Idle},wn=(e,t,r)=>{switch(gn(e,t,r)){case oe.Matched:return Se.Initiate;case oe.CounterPartyInitiated:return Se.Redeem;case oe.Expired:return Se.Refund;default:return Se.Idle}},Ri=[{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 mn{constructor(t,r,a){this.url=new pe.Url("/relayer",r),this.auth=a,this.order=t}async init(t,r){if(!t.account)return L.Err("No account found");if(t.account.address.toLowerCase()!==this.order.source_swap.initiator.toLowerCase())return L.Err("Account and order initiator mismatch");if(!r){const m=await pe.fetchEVMBlockNumber(t);if(m.error)return L.Err(m.error);r=m.val}if(Ft(this.order.source_swap,r)!==Z.Idle)return L.Err("Invalid swap status");const{create_order:o,source_swap:f}=this.order;if(!f.amount||!f.redeemer||!o.timelock||!o.secret_hash)return L.Err("Invalid order");const c=pe.with0x(o.secret_hash),u=BigInt(o.timelock),p=pe.with0x(f.redeemer),w=BigInt(f.amount);try{const m=await this.auth.getToken();if(m.error)return L.Err(m.error);const v=Ne.getContract({address:pe.with0x(this.order.source_swap.asset),abi:Ri,client:t}),A=await v.read.token(),k=await pe.checkAllowanceAndApprove(Number(w),A,this.order.source_swap.asset,t);if(k.error)return L.Err(k.error);const R=await v.read.eip712Domain(),C=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}}),S=await L.Fetcher.post(this.url.endpoint("initiate"),{body:JSON.stringify({order_id:o.create_id,signature:C,perform_on:"Source"}),headers:{Authorization:pe.Authorization(m.val),"Content-Type":"application/json"}});return S.error?L.Err(S.error):S.result?L.Ok(S.result):L.Err("Init: No result found")}catch(m){return console.log("init error :",m),L.Err(String(m))}}async redeem(t,r){try{const a=await this.auth.getToken();if(a.error)return L.Err(a.error);const o=await L.Fetcher.post(this.url.endpoint("redeem"),{body:JSON.stringify({order_id:t,secret:L.trim0x(r),perform_on:"Destination"}),headers:{Authorization:pe.Authorization(a.val),"Content-Type":"application/json"}});return o.error?L.Err(o.error):o.result?L.Ok(o.result):L.Err("Redeem: No result found")}catch(a){return L.Err(String(a))}}}const Si=Buffer.from("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798","hex"),Ai=Buffer.from("483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8","hex"),Ti=Buffer.concat([Si,Ai]),Ii=Buffer.from("0250929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0","hex"),Ur={failedToCreateInternalPubkey:"failed to create internal pubkey",failedToTweakPubkey:"failed to tweak pubkey"};function ki(){const e=_n.crypto.sha256(Buffer.from("GardenHTLC","utf-8")),t=ft.pointMultiply(Buffer.concat([Buffer.from("04","hex"),Ti]),e);if(!t)throw new Error(Ur.failedToCreateInternalPubkey);const r=ft.pointAdd(Ii,t);if(!r)throw new Error(Ur.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,f,c,u){this.secretHash=a,this.redeemerPubkey=o,this.initiatorPubkey=f,this.expiry=c,this.signer=t,this.network=u,this.internalPubkey=ki(),this.initiateAmount=r}static async from(t,r,a,o,f,c){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(f.length===64||f.length===66,`redeemer ${ye.pubkeyLenMismatch}`),it(c>0,ye.zeroOrNegativeExpiry);const u=await t.getNetwork();return new Nt(t,r,a,wr(f).toString("hex"),wr(o).toString("hex"),c,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(),f=await this.signer.getProvider(),c=await f.getUTXOs(o),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 f.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(A=>A.utxo===v.txid))throw new Error(ye.counterPartySigNotFound(v.txid));const f=this.getOutputScript(),c=de.Transaction.SIGHASH_DEFAULT,u=this.leafHash(2),p=o.map(v=>v.value),w=rr(f,o.length);for(let v=0;v<a.ins.length;v++){const A=a.hashForWitnessV1(v,w,p,c,u);if(!ft.verifySchnorr(A,Buffer.from(this.redeemerPubkey,"hex"),Buffer.from(t[v].sig,"hex")))throw new Error(ye.invalidCounterpartySigForUTXO(t[v].utxo));const k=await this.signer.signSchnorr(A),R=Buffer.from(a.ins[v].hash).reverse().toString("hex"),C=t.find(S=>S.utxo===R);if(!C)throw new Error(ye.counterPartySigNotFound(R));a.setWitness(v,[Buffer.from(C.sig,"hex"),k,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:f}=await this._buildRawTx(r??await this.signer.getAddress(),a),c=this.leafHash(1),u=f.map(v=>v.value),p=rr(this.getOutputScript(),f.length),w=de.Transaction.SIGHASH_DEFAULT;for(let v=0;v<o.ins.length;v++){const A=o.hashForWitnessV1(v,p,u,w,c),k=await this.signer.signSchnorr(A);o.setWitness(v,[k,Buffer.from(t,"hex"),this.redeemLeaf(),this.generateControlBlockFor(1)])}return await(await this.signer.getProvider()).broadcast(o.toHex())}async refund(t,r){const{tx:a,usedUtxos:o}=await this._buildRawTx(t??await this.signer.getAddress(),r),[f,c]=await this.canRefund(o);if(!f)throw new Error(ye.htlcNotExpired(c));const u=this.leafHash(0),p=o.map(A=>A.value),w=rr(this.getOutputScript(),o.length),m=de.Transaction.SIGHASH_DEFAULT;for(let A=0;A<a.ins.length;A++){a.ins[A].sequence=this.expiry;const k=a.hashForWitnessV1(A,w,p,m,u),R=await this.signer.signSchnorr(k);a.setWitness(A,[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 f=0;if(o.status.confirmed&&o.status.block_height+this.expiry>a?f=o.status.block_height+this.expiry-a+1:o.status.confirmed||(f=this.expiry+1),f>0)return[!1,f]}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",gi(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 f=mi(o,a);return[de.crypto.taggedHash("TapBranch",Buffer.concat(f))]}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 Ci{constructor(t,r){this.order=t,this.store=r}getOrder(){return this.order}set(t,r){const a={txHash:r,timeStamp:Date.now()};this.store.setItem(`${t}_${this.order.create_order.create_id}`,JSON.stringify(a))}get(t){const r=this.store.getItem(`${t}_${this.order.create_order.create_id}`);if(!r)return null;const a=JSON.parse(r);return!a.timeStamp||!a.txHash?null:a}remove(t){this.store.removeItem(`${t}_${this.order.create_order.create_id}`)}}class Oi{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.pendingOrdersCount=0,this.useRelay=!0,this.orderBook=new
|
|
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 f=mi(o,a);return[de.crypto.taggedHash("TapBranch",Buffer.concat(f))]}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 Ci{constructor(t,r){this.order=t,this.store=r}getOrder(){return this.order}set(t,r){const a={txHash:r,timeStamp:Date.now()};this.store.setItem(`${t}_${this.order.create_order.create_id}`,JSON.stringify(a))}get(t){const r=this.store.getItem(`${t}_${this.order.create_order.create_id}`);if(!r)return null;const a=JSON.parse(r);return!a.timeStamp||!a.txHash?null:a}remove(t){this.store.removeItem(`${t}_${this.order.create_order.create_id}`)}}class Oi{constructor(t){if(this.eventListeners=new Map,this.getOrderThreshold=20,this.pendingOrdersCount=0,this.useRelay=!0,this.orderBook=new ee.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.store=new pe.MemoryStorage,!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 L.Err(r.error);const{sendAddress:a,receiveAddress:o,timelock:f}=r.val,c=await this.orderBook.getOrdersCount(this.evmAddress);if(c.error)return L.Err(c.error);const u=c.val+1,p=this.secretManager.generateSecret(u);if(p.error)return L.Err(p.error);const{strategyId:w,btcAddress:m}=t.additionalData,v={strategy_id:w,...m&&{bitcoin_optional_recipient:m}},A={source_chain:t.fromAsset.chain,destination_chain:t.toAsset.chain,source_asset:t.fromAsset.atomicSwapAddress,destination_asset:t.toAsset.atomicSwapAddress,initiator_source_address:a,initiator_destination_address:o,source_amount:t.sendAmount,destination_amount:t.receiveAmount,fee:"1",nonce:u.toString(),timelock:f,secret_hash:L.trim0x(p.val.secretHash),min_destination_confirmations:t.minDestinationConfirmations??0,additional_data:v},k=await this.quote.getAttestedQuote(A);if(k.error)return L.Err(k.error);const R=await this.orderBook.createOrder(k.val);if(R.error)return L.Err(R.error);const C=await this.pollOrder(R.val);return C.error?L.Err(C.error):L.Ok(C.val)}async validateAndFillParams(t){if(t.fromAsset.chain===t.toAsset.chain&&t.fromAsset.atomicSwapAddress===t.toAsset.atomicSwapAddress)return L.Err("Source and destination assets cannot be the same");if(ee.isMainnet(t.fromAsset.chain)&&!ee.isMainnet(t.toAsset.chain)||!ee.isMainnet(t.fromAsset.chain)&&ee.isMainnet(t.toAsset.chain))return L.Err("Both assets should be on the same network (either mainnet or testnet)");if(ee.isBitcoin(t.fromAsset.chain)||ee.isBitcoin(t.toAsset.chain)){if(!this.wallets.btcWallet)return L.Err("btcWallet is required for bitcoin chain. Please provide btcWallet in the constructor");if(!t.additionalData.btcAddress)return L.Err("btcAddress in additionalData is required for bitcoin chain")}const r=await this.getAddresses(t.fromAsset.chain);if(r.error)return L.Err(r.error);const a=await this.getAddresses(t.toAsset.chain);if(a.error)return L.Err(a.error);const o=this.validateAmount(t.sendAmount);if(o.error)return L.Err(o.error);const f=this.validateAmount(t.receiveAmount);if(f.error)return L.Err(f.error);if(o<f)return L.Err("Send amount should be greater than receive amount");const c=this.getTimelock(t.fromAsset.chain);return c?L.Ok({sendAddress:r.val,receiveAddress:a.val,timelock:t.timelock??c}):L.Err("Unsupported chain for timelock")}async getAddresses(t){var a;switch(ee.getBlockchainType(t)){case ee.BlockchainType.EVM:return this.wallets.evmWallet.account?L.Ok(this.wallets.evmWallet.account.address):L.Err("EVM Wallet not found");case ee.BlockchainType.Bitcoin:{const o=await((a=this.wallets.btcWallet)==null?void 0:a.getPublicKey());return!o||!vi(o)?L.Err("Invalid btc public key"):L.Ok(yt(o))}default:return L.Err("Unsupported chain")}}validateAmount(t){const r=BigInt(t);return t==null||r<=0n||t.includes(".")?L.Err("Invalid amount ",t):L.Ok(r)}getTimelock(t){switch(ee.getBlockchainType(t)){case ee.BlockchainType.EVM:return gr.evm;case ee.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 pe.sleep(1e3),a++,r.error){if(!r.error.includes("result is undefined"))return L.Err(r.error)}else if(r.val&&r.val.create_order.create_id.toLowerCase()===t.toLowerCase())return L.Ok(r.val);r=await this.orderBook.getOrder(t,!0)}return L.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=>{var a,o;this.pendingOrdersCount=r.data.length,this.emit("onPendingOrdersChanged",r.data);for(let f=0;f<r.data.length;f++){const c=r.data[f],u=c.source_swap.chain,p=c.destination_swap.chain,w=this.getWallet(u),m=this.getWallet(p);if(w.error||m.error||!w.val||!m.val){this.emit("error",c,"Source or Destination Wallet not found while executing order");return}const v=await this.fetchCurrentBlockNumbers(c,{source:w.val,destination:m.val});if(v.error){this.emit("error",c,"Error while fetching CurrentBlockNumbers: "+v.error);return}const A=wn(c,v.val.source,v.val.destination),k=new Ci(c,this.store);if(k.get(A))continue;switch(ee.getBlockchainType(c.destination_swap.chain)){case ee.BlockchainType.EVM:switch(A){case Se.Redeem:{console.log("executing evm redeem...");const S=new mn(c,this.orderbookUrl,this.auth),I=this.secretManager.generateSecret(Number(c.create_order.nonce));if(I.error){this.emit("error",c,I.error);return}const O=await S.redeem(c.create_order.create_id,I.val.secret);if(O.error){this.emit("error",c,O.error);return}this.emit("success",c,Se.Redeem,O.val),k.set(A,O.val);break}case Se.Refund:{this.emit("error",c,"EVM refund is automatically done by relay service");break}}break;case ee.BlockchainType.Bitcoin:switch(A){case Se.Redeem:{try{const S=await Nt.from(m.val,Number(c.destination_swap.amount),c.create_order.secret_hash,yt(c.destination_swap.initiator),yt(c.destination_swap.redeemer),c.destination_swap.timelock),I=this.secretManager.generateSecret(Number(c.create_order.nonce));if(I.error){this.emit("error",c,I.error);return}const O=await S.redeem(L.trim0x(I.val.secret),(a=c.create_order.additional_data)==null?void 0:a.bitcoin_optional_recipient);this.emit("success",c,Se.Redeem,O),k.set(A,O)}catch(S){this.emit("error",c,"Failed btc redeem: "+S)}break}case Se.Refund:{try{const I=await(await Nt.from(w.val,Number(c.source_swap.amount),c.create_order.secret_hash,yt(c.source_swap.initiator),yt(c.source_swap.redeemer),c.source_swap.timelock)).refund((o=c.create_order.additional_data)==null?void 0:o.bitcoin_optional_recipient);this.emit("success",c,Se.Refund,I),k.set(A,I)}catch(S){this.emit("error",c,"Failed btc refund: "+S)}break}}break;default:this.emit("error",c,"Unsupported chain: "+c.destination_swap.chain)}return}},!0)}getWallet(t){switch(ee.getBlockchainType(t)){case ee.BlockchainType.EVM:return L.Ok(this.wallets.evmWallet);case ee.BlockchainType.Bitcoin:return L.Ok(this.wallets.btcWallet);default:return L.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 L.Err("Provide wallets to fetch the current block number");const a=ee.isBitcoin(t.source_swap.chain)?await pe.fetchBitcoinBlockNumber(await r.source.getProvider()):await pe.fetchEVMBlockNumber(r.source);if(a.error)return L.Err(a.error);const o=ee.isBitcoin(t.destination_swap.chain)?await pe.fetchBitcoinBlockNumber(await r.destination.getProvider()):await pe.fetchEVMBlockNumber(r.destination);return o.error?L.Err(o.error):L.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 Li(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 vn={},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 xn={},
|
|
22
|
+
`,bech32:"tb",bip32:{public:70617039,private:70615956},pubKeyHash:111,scriptHash:196,wif:239};var xn={},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 $r in Bt)Bt[$r].toJSON=(function(e){return e}).bind(null,$r);var Ir=Bt,Qe=Ir;function En(e){return e.name||e.toString().match(/function (.*?)\s*\(/)[1]}function kr(e){return Qe.Nil(e)?"":En(e.constructor)}function Mi(e){return Qe.Function(e)?"":Qe.String(e)?JSON.stringify(e):e&&Qe.Object(e)?"":e}function Cr(e,t){Error.captureStackTrace&&Error.captureStackTrace(e,t)}function Dt(e){return Qe.Function(e)?e.toJSON?e.toJSON():En(e):Qe.Array(e)?"Array":e&&Qe.Object(e)?"Object":e!==void 0?e:""}function Bn(e,t,r){var a=Mi(t);return"Expected "+Dt(e)+", got"+(r!==""?" "+r:"")+(a!==""?" "+a:"")}function De(e,t,r){r=r||kr(t),this.message=Bn(e,t,r),Cr(this,De),this.__type=e,this.__value=t,this.__valueTypeName=r}De.prototype=Object.create(Error.prototype);De.prototype.constructor=De;function Pi(e,t,r,a,o){var f='" of type ';return t==="key"&&(f='" with key type '),Bn('property "'+Dt(r)+f+Dt(e),a,o)}function ot(e,t,r,a,o){e?(o=o||kr(a),this.message=Pi(e,r,t,a,o)):this.message='Unexpected property "'+t+'"',Cr(this,De),this.__label=r,this.__property=t,this.__type=e,this.__value=a,this.__valueTypeName=o}ot.prototype=Object.create(Error.prototype);ot.prototype.constructor=De;function Fi(e,t){return new De(e,{},t)}function Ni(e,t,r){return e instanceof ot?(t=t+"."+e.__property,e=new ot(e.__type,t,e.__label,e.__value,e.__valueTypeName)):e instanceof De&&(e=new ot(e.__type,t,r,e.__value,e.__valueTypeName)),Cr(e),e}var Rn={TfTypeError:De,TfPropertyTypeError:ot,tfCustomError:Fi,tfSubError:Ni,tfJSON:Dt,getValueTypeName:kr},nr,Hr;function Di(){if(Hr)return nr;Hr=1;var e=Ir,t=Rn;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 D=E.toJSON();function $(ne){if(!E(ne))return!1;if(ne.length===j)return!0;throw t.tfCustomError(D+"(Length: "+j+")",D+"(Length: "+ne.length+")")}return $.toJSON=function(){return D},$}var f=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,D){D=D||e.Number;function $(ne,Te){return D(ne,Te)&&ne>E&&ne<j}return $.toJSON=function(){return`${D.toJSON()} between [${E}, ${j}]`},$}var m=Math.pow(2,53)-1;function v(E){return typeof E=="number"&&isFinite(E)}function A(E){return E<<24>>24===E}function k(E){return E<<16>>16===E}function R(E){return(E|0)===E}function C(E){return typeof E=="number"&&E>=-m&&E<=m&&Math.floor(E)===E}function S(E){return(E&255)===E}function I(E){return(E&65535)===E}function O(E){return E>>>0===E}function P(E){return typeof E=="number"&&E>=0&&E<=m&&Math.floor(E)===E}var M={ArrayN:f,Buffer:r,BufferN:c,Finite:v,Hex:a,HexN:u,Int8:A,Int16:k,Int32:R,Int53:C,Range:w,StringN:p,UInt8:S,UInt16:I,UInt32:O,UInt53:P};for(var N in M)M[N].toJSON=(function(E){return E}).bind(null,N);return nr=M,nr}var St=Rn,fe=Ir,Pe=St.tfJSON,Sn=St.TfTypeError,An=St.TfPropertyTypeError,_t=St.tfSubError,Ui=St.getValueTypeName,Fe={arrayOf:function(t,r){t=Oe(t),r=r||{};function a(o,f){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 ge(t,c,f)}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,f){if(!fe.Object(o)||fe.Nil(o))return!1;for(var c in o){try{r&&ge(r,c,f)}catch(p){throw _t(p,c,"key")}try{var u=o[c];ge(t,u,f)}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(f,c){if(!fe.Object(f)||fe.Nil(f))return!1;var u;try{for(u in r){var p=r[u],w=f[u];ge(p,w,c)}}catch(m){throw _t(m,u)}if(c){for(u in f)if(!r[u])throw new An(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(f){try{return ge(f,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(f){try{return ge(f,a,o)}catch{return!1}})}return r.toJSON=function(){return t.map(Pe).join(" & ")},r},quacksLike:function(t){function r(a){return t===Ui(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(f,c){try{return ge(f,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 ge(e,t,r,a){if(fe.Function(e)){if(e(t,r))return!0;throw new Sn(a||e,t)}return ge(Oe(e),t,r)}for(var Ke in fe)ge[Ke]=fe[Ke];for(Ke in Fe)ge[Ke]=Fe[Ke];var jr=Di();for(Ke in jr)ge[Ke]=jr[Ke];ge.compile=Oe;ge.TfTypeError=Sn;ge.TfPropertyTypeError=An;var $i=ge;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.maybe=e.Boolean=e.Array=e.Buffer256bit=e.Network=e.typeforce=void 0,e.typeforce=$i,e.Network=e.typeforce.compile({messagePrefix:e.typeforce.oneOf(e.typeforce.Buffer,e.typeforce.String),bip32:{public:e.typeforce.UInt32,private:e.typeforce.UInt32},pubKeyHash:e.typeforce.UInt8,scriptHash:e.typeforce.UInt8,wif:e.typeforce.UInt8}),e.Buffer256bit=e.typeforce.BufferN(32),e.Array=e.typeforce.Array,e.Boolean=e.typeforce.Boolean,e.maybe=e.typeforce.maybe})(xn);var mr={exports:{}},vr={exports:{}},ht={},Wt={};Wt.byteLength=qi;Wt.toByteArray=Ki;Wt.fromByteArray=Ji;var Le=[],Re=[],Hi=typeof Uint8Array<"u"?Uint8Array:Array,ir="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";for(var at=0,ji=ir.length;at<ji;++at)Le[at]=ir[at],Re[ir.charCodeAt(at)]=at;Re[45]=62;Re[95]=63;function Tn(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 qi(e){var t=Tn(e),r=t[0],a=t[1];return(r+a)*3/4-a}function Wi(e,t,r){return(t+r)*3/4-r}function Ki(e){var t,r=Tn(e),a=r[0],o=r[1],f=new Hi(Wi(e,a,o)),c=0,u=o>0?a-4:a,p;for(p=0;p<u;p+=4)t=Re[e.charCodeAt(p)]<<18|Re[e.charCodeAt(p+1)]<<12|Re[e.charCodeAt(p+2)]<<6|Re[e.charCodeAt(p+3)],f[c++]=t>>16&255,f[c++]=t>>8&255,f[c++]=t&255;return o===2&&(t=Re[e.charCodeAt(p)]<<2|Re[e.charCodeAt(p+1)]>>4,f[c++]=t&255),o===1&&(t=Re[e.charCodeAt(p)]<<10|Re[e.charCodeAt(p+1)]<<4|Re[e.charCodeAt(p+2)]>>2,f[c++]=t>>8&255,f[c++]=t&255),f}function Gi(e){return Le[e>>18&63]+Le[e>>12&63]+Le[e>>6&63]+Le[e&63]}function Vi(e,t,r){for(var a,o=[],f=t;f<r;f+=3)a=(e[f]<<16&16711680)+(e[f+1]<<8&65280)+(e[f+2]&255),o.push(Gi(a));return o.join("")}function Ji(e){for(var t,r=e.length,a=r%3,o=[],f=16383,c=0,u=r-a;c<u;c+=f)o.push(Vi(e,c,c+f>u?u:c+f));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 f,c,u=o*8-a-1,p=(1<<u)-1,w=p>>1,m=-7,v=r?o-1:0,A=r?-1:1,k=e[t+v];for(v+=A,f=k&(1<<-m)-1,k>>=-m,m+=u;m>0;f=f*256+e[t+v],v+=A,m-=8);for(c=f&(1<<-m)-1,f>>=-m,m+=a;m>0;c=c*256+e[t+v],v+=A,m-=8);if(f===0)f=1-w;else{if(f===p)return c?NaN:(k?-1:1)*(1/0);c=c+Math.pow(2,a),f=f-w}return(k?-1:1)*c*Math.pow(2,f-a)};Or.write=function(e,t,r,a,o,f){var c,u,p,w=f*8-o-1,m=(1<<w)-1,v=m>>1,A=o===23?Math.pow(2,-24)-Math.pow(2,-77):0,k=a?0:f-1,R=a?1:-1,C=t<0||t===0&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(u=isNaN(t)?1:0,c=m):(c=Math.floor(Math.log(t)/Math.LN2),t*(p=Math.pow(2,-c))<1&&(c--,p*=2),c+v>=1?t+=A/p:t+=A*Math.pow(2,1-v),t*p>=2&&(c++,p/=2),c+v>=m?(u=0,c=m):c+v>=1?(u=(t*p-1)*Math.pow(2,o),c=c+v):(u=t*Math.pow(2,v-1)*Math.pow(2,o),c=0));o>=8;e[r+k]=u&255,k+=R,u/=256,o-=8);for(c=c<<o|u,w+=o;w>0;e[r+k]=c&255,k+=R,c/=256,w-=8);e[r+k-R]|=C*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=O,e.INSPECT_MAX_BYTES=50;const o=2147483647;e.kMaxLength=o,u.TYPED_ARRAY_SUPPORT=f(),!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 f(){try{const s=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(s,n),s.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(s){if(s>o)throw new RangeError('The value "'+s+'" is invalid for option "size"');const n=new Uint8Array(s);return Object.setPrototypeOf(n,u.prototype),n}function u(s,n,i){if(typeof s=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(s)}return p(s,n,i)}u.poolSize=8192;function p(s,n,i){if(typeof s=="string")return A(s,n);if(ArrayBuffer.isView(s))return R(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(Ee(s,ArrayBuffer)||s&&Ee(s.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ee(s,SharedArrayBuffer)||s&&Ee(s.buffer,SharedArrayBuffer)))return C(s,n,i);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=s.valueOf&&s.valueOf();if(l!=null&&l!==s)return u.from(l,n,i);const b=S(s);if(b)return b;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return u.from(s[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 s)}u.from=function(s,n,i){return p(s,n,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function w(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function m(s,n,i){return w(s),s<=0?c(s):n!==void 0?typeof i=="string"?c(s).fill(n,i):c(s).fill(n):c(s)}u.alloc=function(s,n,i){return m(s,n,i)};function v(s){return w(s),c(s<0?0:I(s)|0)}u.allocUnsafe=function(s){return v(s)},u.allocUnsafeSlow=function(s){return v(s)};function A(s,n){if((typeof n!="string"||n==="")&&(n="utf8"),!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const i=P(s,n)|0;let l=c(i);const b=l.write(s,n);return b!==i&&(l=l.slice(0,b)),l}function k(s){const n=s.length<0?0:I(s.length)|0,i=c(n);for(let l=0;l<n;l+=1)i[l]=s[l]&255;return i}function R(s){if(Ee(s,Uint8Array)){const n=new Uint8Array(s);return C(n.buffer,n.byteOffset,n.byteLength)}return k(s)}function C(s,n,i){if(n<0||s.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(s.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(s):i===void 0?l=new Uint8Array(s,n):l=new Uint8Array(s,n,i),Object.setPrototypeOf(l,u.prototype),l}function S(s){if(u.isBuffer(s)){const n=I(s.length)|0,i=c(n);return i.length===0||s.copy(i,0,0,n),i}if(s.length!==void 0)return typeof s.length!="number"||ze(s.length)?c(0):k(s);if(s.type==="Buffer"&&Array.isArray(s.data))return k(s.data)}function I(s){if(s>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return s|0}function O(s){return+s!=s&&(s=0),u.alloc(+s)}u.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==u.prototype},u.compare=function(n,i){if(Ee(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),Ee(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(Ee(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(s,n){if(u.isBuffer(s))return s.length;if(ArrayBuffer.isView(s)||Ee(s,ArrayBuffer))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);const i=s.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(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return pt(s).length;default:if(b)return l?-1:G(s).length;n=(""+n).toLowerCase(),b=!0}}u.byteLength=P;function M(s,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(s||(s="utf8");;)switch(s){case"hex":return ke(this,n,i);case"utf8":case"utf-8":return we(this,n,i);case"ascii":return Ie(this,n,i);case"latin1":case"binary":return He(this,n,i);case"base64":return ae(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: "+s);s=(s+"").toLowerCase(),l=!0}}u.prototype._isBuffer=!0;function N(s,n,i){const l=s[n];s[n]=s[i],s[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?we(this,0,n):M.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(Ee(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 J=0;J<te;++J)if(Z[J]!==re[J]){x=Z[J],K=re[J];break}return x<K?-1:K<x?1:0};function E(s,n,i,l,b){if(s.length===0)return-1;if(typeof i=="string"?(l=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,ze(i)&&(i=b?0:s.length-1),i<0&&(i=s.length+i),i>=s.length){if(b)return-1;i=s.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(s,n,i,l,b);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(s,n,i):Uint8Array.prototype.lastIndexOf.call(s,n,i):j(s,[n],i,l,b);throw new TypeError("val must be string, number or Buffer")}function j(s,n,i,l,b){let g=1,x=s.length,K=n.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(s.length<2||n.length<2)return-1;g=2,x/=2,K/=2,i/=2}function te(re,J){return g===1?re[J]:re.readUInt16BE(J*g)}let Z;if(b){let re=-1;for(Z=i;Z<x;Z++)if(te(s,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 J=0;J<K;J++)if(te(s,Z+J)!==te(n,J)){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 D(s,n,i,l){i=Number(i)||0;const b=s.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(ze(K))return x;s[i+x]=K}return x}function $(s,n,i,l){return rt(G(n,s.length-i),s,i,l)}function ne(s,n,i,l){return rt(We(n),s,i,l)}function Te(s,n,i,l){return rt(pt(n),s,i,l)}function $e(s,n,i,l){return rt(tt(n,s.length-i),s,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 D(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 ae(s,n,i){return n===0&&i===s.length?t.fromByteArray(s):t.fromByteArray(s.slice(n,i))}function we(s,n,i){i=Math.min(s.length,i);const l=[];let b=n;for(;b<i;){const g=s[b];let x=null,K=g>239?4:g>223?3:g>191?2:1;if(b+K<=i){let te,Z,re,J;switch(K){case 1:g<128&&(x=g);break;case 2:te=s[b+1],(te&192)===128&&(J=(g&31)<<6|te&63,J>127&&(x=J));break;case 3:te=s[b+1],Z=s[b+2],(te&192)===128&&(Z&192)===128&&(J=(g&15)<<12|(te&63)<<6|Z&63,J>2047&&(J<55296||J>57343)&&(x=J));break;case 4:te=s[b+1],Z=s[b+2],re=s[b+3],(te&192)===128&&(Z&192)===128&&(re&192)===128&&(J=(g&15)<<18|(te&63)<<12|(Z&63)<<6|re&63,J>65535&&J<1114112&&(x=J))}}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 Je(l)}const me=4096;function Je(s){const n=s.length;if(n<=me)return String.fromCharCode.apply(String,s);let i="",l=0;for(;l<n;)i+=String.fromCharCode.apply(String,s.slice(l,l+=me));return i}function Ie(s,n,i){let l="";i=Math.min(s.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(s[b]&127);return l}function He(s,n,i){let l="";i=Math.min(s.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(s[b]);return l}function ke(s,n,i){const l=s.length;(!n||n<0)&&(n=0),(!i||i<0||i>l)&&(i=l);let b="";for(let g=n;g<i;++g)b+=bt[s[g]];return b}function je(s,n,i){const l=s.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 Q(s,n,i){if(s%1!==0||s<0)throw new RangeError("offset is not uint");if(s+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||Q(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||Q(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||Q(n,1,this.length),this[n]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(n,i){return n=n>>>0,i||Q(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(n,i){return n=n>>>0,i||Q(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(n,i){return n=n>>>0,i||Q(n,4,this.length),(this[n]|this[n+1]<<8|this[n+2]<<16)+this[n+3]*16777216},u.prototype.readUint32BE=u.prototype.readUInt32BE=function(n,i){return n=n>>>0,i||Q(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},u.prototype.readBigUInt64LE=Be(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=Be(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||Q(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||Q(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||Q(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,i){n=n>>>0,i||Q(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||Q(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||Q(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||Q(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},u.prototype.readBigInt64LE=Be(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=Be(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||Q(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,i){return n=n>>>0,i||Q(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,i){return n=n>>>0,i||Q(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,i){return n=n>>>0,i||Q(n,8,this.length),r.read(this,n,!1,52,8)};function ie(s,n,i,l,b,g){if(!u.isBuffer(s))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>s.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 xe(s,n,i,l,b){d(n,l,b,s,i,7);let g=Number(n&BigInt(4294967295));s[i++]=g,g=g>>8,s[i++]=g,g=g>>8,s[i++]=g,g=g>>8,s[i++]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return s[i++]=x,x=x>>8,s[i++]=x,x=x>>8,s[i++]=x,x=x>>8,s[i++]=x,i}function qe(s,n,i,l,b){d(n,l,b,s,i,7);let g=Number(n&BigInt(4294967295));s[i+7]=g,g=g>>8,s[i+6]=g,g=g>>8,s[i+5]=g,g=g>>8,s[i+4]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return s[i+3]=x,x=x>>8,s[i+2]=x,x=x>>8,s[i+1]=x,x=x>>8,s[i]=x,i+8}u.prototype.writeBigUInt64LE=Be(function(n,i=0){return xe(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Be(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=Be(function(n,i=0){return xe(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Be(function(n,i=0){return qe(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Me(s,n,i,l,b,g){if(i+l>s.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function _(s,n,i,l,b){return n=+n,i=i>>>0,b||Me(s,n,i,4),r.write(s,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(s,n,i,l,b){return n=+n,i=i>>>0,b||Me(s,n,i,8),r.write(s,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 T={};function U(s,n,i){T[s]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${s}]`,this.stack,delete this.name}get code(){return s}set code(b){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:b,writable:!0})}toString(){return`${this.name} [${s}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(s,n){return`The "${s}" argument must be of type number. Received type ${typeof n}`},TypeError),U("ERR_OUT_OF_RANGE",function(s,n,i){let l=`The value of "${s}" 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(s){let n="",i=s.length;const l=s[0]==="-"?1:0;for(;i>=l+4;i-=3)n=`_${s.slice(i-3,i)}${n}`;return`${s.slice(0,i)}${n}`}function h(s,n,i){B(n,"offset"),(s[n]===void 0||s[n+i]===void 0)&&F(n,s.length-(i+1))}function d(s,n,i,l,b,g){if(s>i||s<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 T.ERR_OUT_OF_RANGE("value",K,s)}h(l,b,g)}function B(s,n){if(typeof s!="number")throw new T.ERR_INVALID_ARG_TYPE(n,"number",s)}function F(s,n,i){throw Math.floor(s)!==s?(B(s,i),new T.ERR_OUT_OF_RANGE("offset","an integer",s)):n<0?new T.ERR_BUFFER_OUT_OF_BOUNDS:new T.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,s)}const X=/[^+/0-9A-Za-z-_]/g;function W(s){if(s=s.split("=")[0],s=s.trim().replace(X,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function G(s,n){n=n||1/0;let i;const l=s.length;let b=null;const g=[];for(let x=0;x<l;++x){if(i=s.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(s){const n=[];for(let i=0;i<s.length;++i)n.push(s.charCodeAt(i)&255);return n}function tt(s,n){let i,l,b;const g=[];for(let x=0;x<s.length&&!((n-=2)<0);++x)i=s.charCodeAt(x),l=i>>8,b=i%256,g.push(b),g.push(l);return g}function pt(s){return t.toByteArray(W(s))}function rt(s,n,i,l){let b;for(b=0;b<l&&!(b+i>=n.length||b>=s.length);++b)n[b+i]=s[b];return b}function Ee(s,n){return s instanceof n||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===n.name}function ze(s){return s!==s}const bt=function(){const s="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]=s[i]+s[b]}return n}();function Be(s){return typeof BigInt>"u"?Ye:s}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=f);function f(c,u,p){return a(c,u,p)}f.prototype=Object.create(a.prototype),o(a,f),f.from=function(c,u,p){if(typeof c=="number")throw new TypeError("Argument must not be a number");return a(c,u,p)},f.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},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return a(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(vr,vr.exports);var ve=vr.exports,ar=65536,zi=4294967295;function Yi(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
28
|
-
Use Chrome, Firefox or Internet Explorer 11`)}var Qi=ve.Buffer,Ut=Ge.crypto||Ge.msCrypto;Ut&&Ut.getRandomValues?mr.exports=Xi:mr.exports=Yi;function Xi(e,t){if(e>zi)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)Ut.getRandomValues(r.slice(a,a+ar));else Ut.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var Zi=mr.exports,xr={exports:{}};typeof Object.create=="function"?xr.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:xr.exports=function(t,r){if(r){t.super_=r;var 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,qr=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 ea(e){console&&console.warn&&console.warn(e)}var In=Number.isNaN||function(t){return t!==t};function V(){V.init.call(this)}Lr.exports=V;Lr.exports.once=ia;V.EventEmitter=V;V.prototype._events=void 0;V.prototype._eventsCount=0;V.prototype._maxListeners=void 0;var Wr=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 Wr},set:function(e){if(typeof e!="number"||e<0||In(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Wr=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||In(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 kn(e){return e._maxListeners===void 0?V.defaultMaxListeners:e._maxListeners}V.prototype.getMaxListeners=function(){return kn(this)};V.prototype.emit=function(t){for(var r=[],a=1;a<arguments.length;a++)r.push(arguments[a]);var o=t==="error",f=this._events;if(f!==void 0)o=o&&f.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=f[t];if(p===void 0)return!1;if(typeof p=="function")qr(p,this,r);else for(var w=p.length,m=Pn(p,w),a=0;a<w;++a)qr(m[a],this,r);return!0};function Cn(e,t,r,a){var o,f,c;if(Kt(r),f=e._events,f===void 0?(f=e._events=Object.create(null),e._eventsCount=0):(f.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),f=e._events),c=f[t]),c===void 0)c=f[t]=r,++e._eventsCount;else if(typeof c=="function"?c=f[t]=a?[r,c]:[c,r]:a?c.unshift(r):c.push(r),o=kn(e),o>0&&c.length>o&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=c.length,ea(u)}return e}V.prototype.addListener=function(t,r){return Cn(this,t,r,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(t,r){return Cn(this,t,r,!0)};function ta(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function On(e,t,r){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=ta.bind(a);return o.listener=r,a.wrapFn=o,o}V.prototype.once=function(t,r){return Kt(r),this.on(t,On(this,t,r)),this};V.prototype.prependOnceListener=function(t,r){return Kt(r),this.prependListener(t,On(this,t,r)),this};V.prototype.removeListener=function(t,r){var a,o,f,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(f=-1,c=a.length-1;c>=0;c--)if(a[c]===r||a[c].listener===r){u=a[c].listener,f=c;break}if(f<0)return this;f===0?a.shift():ra(a,f),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 f=Object.keys(a),c;for(o=0;o<f.length;++o)c=f[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 Ln(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?na(o):Pn(o,o.length)}V.prototype.listeners=function(t){return Ln(this,t,!0)};V.prototype.rawListeners=function(t){return Ln(this,t,!1)};V.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Mn.call(e,t)};V.prototype.listenerCount=Mn;function Mn(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}V.prototype.eventNames=function(){return this._eventsCount>0?Mt(this._events):[]};function Pn(e,t){for(var r=new Array(t),a=0;a<t;++a)r[a]=e[a];return r}function ra(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function na(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function ia(e,t){return new Promise(function(r,a){function o(c){e.removeListener(t,f),a(c)}function f(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}Fn(e,t,f,{once:!0}),t!=="error"&&aa(e,o,{once:!0})})}function aa(e,t,r){typeof e.on=="function"&&Fn(e,"error",t,r)}function Fn(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(f){a.once&&e.removeEventListener(t,o),r(f)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Nn=Lr.exports,Dn=Nn.EventEmitter;const oa={},sa=Object.freeze(Object.defineProperty({__proto__:null,default:oa},Symbol.toStringTag,{value:"Module"})),Mr=Li(sa);var or,Kr;function fa(){if(Kr)return or;Kr=1;function e(R,C){var S=Object.keys(R);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(R);C&&(I=I.filter(function(O){return Object.getOwnPropertyDescriptor(R,O).enumerable})),S.push.apply(S,I)}return S}function t(R){for(var C=1;C<arguments.length;C++){var S=arguments[C]!=null?arguments[C]:{};C%2?e(Object(S),!0).forEach(function(I){r(R,I,S[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(S)):e(Object(S)).forEach(function(I){Object.defineProperty(R,I,Object.getOwnPropertyDescriptor(S,I))})}return R}function r(R,C,S){return C=c(C),C in R?Object.defineProperty(R,C,{value:S,enumerable:!0,configurable:!0,writable:!0}):R[C]=S,R}function a(R,C){if(!(R instanceof C))throw new TypeError("Cannot call a class as a function")}function o(R,C){for(var S=0;S<C.length;S++){var I=C[S];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(R,c(I.key),I)}}function f(R,C,S){return C&&o(R.prototype,C),Object.defineProperty(R,"prototype",{writable:!1}),R}function c(R){var C=u(R,"string");return typeof C=="symbol"?C:String(C)}function u(R,C){if(typeof R!="object"||R===null)return R;var S=R[Symbol.toPrimitive];if(S!==void 0){var I=S.call(R,C||"default");if(typeof I!="object")return I;throw new TypeError("@@toPrimitive must return a primitive value.")}return(C==="string"?String:Number)(R)}var p=ht,w=p.Buffer,m=Mr,v=m.inspect,A=v&&v.custom||"inspect";function k(R,C,S){w.prototype.copy.call(R,C,S)}return or=function(){function R(){a(this,R),this.head=null,this.tail=null,this.length=0}return f(R,[{key:"push",value:function(S){var I={data:S,next:null};this.length>0?this.tail.next=I:this.head=I,this.tail=I,++this.length}},{key:"unshift",value:function(S){var I={data:S,next:this.head};this.length===0&&(this.tail=I),this.head=I,++this.length}},{key:"shift",value:function(){if(this.length!==0){var S=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,S}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(S){if(this.length===0)return"";for(var I=this.head,O=""+I.data;I=I.next;)O+=S+I.data;return O}},{key:"concat",value:function(S){if(this.length===0)return w.alloc(0);for(var I=w.allocUnsafe(S>>>0),O=this.head,P=0;O;)k(O.data,I,P),P+=O.data.length,O=O.next;return I}},{key:"consume",value:function(S,I){var O;return S<this.head.data.length?(O=this.head.data.slice(0,S),this.head.data=this.head.data.slice(S)):S===this.head.data.length?O=this.shift():O=I?this._getString(S):this._getBuffer(S),O}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(S){var I=this.head,O=1,P=I.data;for(S-=P.length;I=I.next;){var M=I.data,N=S>M.length?M.length:S;if(N===M.length?P+=M:P+=M.slice(0,S),S-=N,S===0){N===M.length?(++O,I.next?this.head=I.next:this.head=this.tail=null):(this.head=I,I.data=M.slice(N));break}++O}return this.length-=O,P}},{key:"_getBuffer",value:function(S){var I=w.allocUnsafe(S),O=this.head,P=1;for(O.data.copy(I),S-=O.data.length;O=O.next;){var M=O.data,N=S>M.length?M.length:S;if(M.copy(I,I.length-S,0,N),S-=N,S===0){N===M.length?(++P,O.next?this.head=O.next:this.head=this.tail=null):(this.head=O,O.data=M.slice(N));break}++P}return this.length-=P,I}},{key:A,value:function(S,I){return v(this,t(t({},I),{},{depth:0,customInspect:!1}))}}]),R}(),or}function ua(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(f){!t&&f?r._writableState?r._writableState.errorEmitted?process.nextTick(Pt,r):(r._writableState.errorEmitted=!0,process.nextTick(Gr,r,f)):process.nextTick(Gr,r,f):t?(process.nextTick(Pt,r),t(f)):process.nextTick(Pt,r)}),this)}function Gr(e,t){Br(e,t),Pt(e)}function Pt(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ca(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Br(e,t){e.emit("error",t)}function la(e,t){var r=e._readableState,a=e._writableState;r&&r.autoDestroy||a&&a.autoDestroy?e.destroy(t):e.emit("error",t)}var Un={destroy:ua,undestroy:ca,errorOrDestroy:la},Ze={};function ha(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var $n={};function Ae(e,t,r){r||(r=Error);function a(f,c,u){return typeof t=="string"?t:t(f,c,u)}var o=function(f){ha(c,f);function c(u,p,w){return f.call(this,a(u,p,w))||this}return c}(r);o.prototype.name=r.name,o.prototype.code=e,$n[e]=o}function Vr(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 da(e,t,r){return e.substr(0,t.length)===t}function pa(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function ba(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Ae("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Ae("ERR_INVALID_ARG_TYPE",function(e,t,r){var a;typeof t=="string"&&da(t,"not ")?(a="must not be",t=t.replace(/^not /,"")):a="must be";var o;if(pa(e," argument"))o="The ".concat(e," ").concat(a," ").concat(Vr(t,"type"));else{var f=ba(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(f," ").concat(a," ").concat(Vr(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=$n;var ya=Ze.codes.ERR_INVALID_OPT_VALUE;function _a(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function ga(e,t,r,a){var o=_a(t,a,r);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var f=a?r:"highWaterMark";throw new ya(f,o)}return Math.floor(o)}return e.objectMode?16:16*1024}var Hn={getHighWaterMark:ga},wa=ma;function ma(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 jn(){if(Jr)return fr;Jr=1,fr=D;function e(_){var y=this;this.next=null,this.entry=null,this.finish=function(){Me(y,_)}}var t;D.WritableState=E;var r={deprecate:wa},a=Dn,o=ht.Buffer,f=(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 f}var p=Un,w=Hn,m=w.getHighWaterMark,v=Ze.codes,A=v.ERR_INVALID_ARG_TYPE,k=v.ERR_METHOD_NOT_IMPLEMENTED,R=v.ERR_MULTIPLE_CALLBACK,C=v.ERR_STREAM_CANNOT_PIPE,S=v.ERR_STREAM_DESTROYED,I=v.ERR_STREAM_NULL_VALUES,O=v.ERR_STREAM_WRITE_AFTER_END,P=v.ERR_UNKNOWN_ENCODING,M=p.errorOrDestroy;be(D,a);function N(){}function E(_,y,T){t=t||lt(),_=_||{},typeof T!="boolean"&&(T=y instanceof t),this.objectMode=!!_.objectMode,T&&(this.objectMode=this.objectMode||!!_.writableObjectMode),this.highWaterMark=m(this,_,"writableHighWaterMark",T),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var U=_.decodeStrings===!1;this.decodeStrings=!U,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(q){Je(y,q)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=_.emitClose!==!1,this.autoDestroy=!!_.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}E.prototype.getBuffer=function(){for(var y=this.bufferedRequest,T=[];y;)T.push(y),y=y.next;return T},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(D,Symbol.hasInstance,{value:function(y){return j.call(this,y)?!0:this!==D?!1:y&&y._writableState instanceof E}})):j=function(y){return y instanceof this};function D(_){t=t||lt();var y=this instanceof t;if(!y&&!j.call(D,this))return new D(_);this._writableState=new 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)}D.prototype.pipe=function(){M(this,new C)};function $(_,y){var T=new O;M(_,T),process.nextTick(y,T)}function ne(_,y,T,U){var q;return T===null?q=new I:typeof T!="string"&&!y.objectMode&&(q=new A("chunk",["string","Buffer"],T)),q?(M(_,q),process.nextTick(U,q),!1):!0}D.prototype.write=function(_,y,T){var U=this._writableState,q=!1,h=!U.objectMode&&u(_);return h&&!o.isBuffer(_)&&(_=c(_)),typeof y=="function"&&(T=y,y=null),h?y="buffer":y||(y=U.defaultEncoding),typeof T!="function"&&(T=N),U.ending?$(this,T):(h||ne(this,U,_,T))&&(U.pendingcb++,q=$e(this,U,h,_,y,T)),q},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&ke(this,_))},D.prototype.setDefaultEncoding=function(y){if(typeof y=="string"&&(y=y.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((y+"").toLowerCase())>-1))throw new P(y);return this._writableState.defaultEncoding=y,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Te(_,y,T){return!_.objectMode&&_.decodeStrings!==!1&&typeof y=="string"&&(y=o.from(y,T)),y}Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function $e(_,y,T,U,q,h){if(!T){var d=Te(y,U,q);U!==d&&(T=!0,q="buffer",U=d)}var B=y.objectMode?1:U.length;y.length+=B;var F=y.length<y.highWaterMark;if(F||(y.needDrain=!0),y.writing||y.corked){var X=y.lastBufferedRequest;y.lastBufferedRequest={chunk:U,encoding:q,isBuf:T,callback:h,next:null},X?X.next=y.lastBufferedRequest:y.bufferedRequest=y.lastBufferedRequest,y.bufferedRequestCount+=1}else ae(_,y,!1,B,U,q,h);return F}function ae(_,y,T,U,q,h,d){y.writelen=U,y.writecb=d,y.writing=!0,y.sync=!0,y.destroyed?y.onwrite(new S("write")):T?_._writev(q,y.onwrite):_._write(q,h,y.onwrite),y.sync=!1}function we(_,y,T,U,q){--y.pendingcb,T?(process.nextTick(q,U),process.nextTick(xe,_,y),_._writableState.errorEmitted=!0,M(_,U)):(q(U),_._writableState.errorEmitted=!0,M(_,U),xe(_,y))}function me(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function Je(_,y){var T=_._writableState,U=T.sync,q=T.writecb;if(typeof q!="function")throw new R;if(me(T),y)we(_,T,U,y,q);else{var h=je(T)||_.destroyed;!h&&!T.corked&&!T.bufferProcessing&&T.bufferedRequest&&ke(_,T),U?process.nextTick(Ie,_,T,h,q):Ie(_,T,h,q)}}function Ie(_,y,T,U){T||He(_,y),y.pendingcb--,U(),xe(_,y)}function He(_,y){y.length===0&&y.needDrain&&(y.needDrain=!1,_.emit("drain"))}function ke(_,y){y.bufferProcessing=!0;var T=y.bufferedRequest;if(_._writev&&T&&T.next){var U=y.bufferedRequestCount,q=new Array(U),h=y.corkedRequestsFree;h.entry=T;for(var d=0,B=!0;T;)q[d]=T,T.isBuf||(B=!1),T=T.next,d+=1;q.allBuffers=B,ae(_,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(;T;){var F=T.chunk,X=T.encoding,W=T.callback,G=y.objectMode?1:F.length;if(ae(_,y,!1,G,F,X,W),T=T.next,y.bufferedRequestCount--,y.writing)break}T===null&&(y.lastBufferedRequest=null)}y.bufferedRequest=T,y.bufferProcessing=!1}D.prototype._write=function(_,y,T){T(new k("_write()"))},D.prototype._writev=null,D.prototype.end=function(_,y,T){var U=this._writableState;return typeof _=="function"?(T=_,_=null,y=null):typeof y=="function"&&(T=y,y=null),_!=null&&this.write(_,y),U.corked&&(U.corked=1,this.uncork()),U.ending||qe(this,U,T),this},Object.defineProperty(D.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function je(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function Q(_,y){_._final(function(T){y.pendingcb--,T&&M(_,T),y.prefinished=!0,_.emit("prefinish"),xe(_,y)})}function ie(_,y){!y.prefinished&&!y.finalCalled&&(typeof _._final=="function"&&!y.destroyed?(y.pendingcb++,y.finalCalled=!0,process.nextTick(Q,_,y)):(y.prefinished=!0,_.emit("prefinish")))}function xe(_,y){var T=je(y);if(T&&(ie(_,y),y.pendingcb===0&&(y.finished=!0,_.emit("finish"),y.autoDestroy))){var U=_._readableState;(!U||U.autoDestroy&&U.endEmitted)&&_.destroy()}return T}function qe(_,y,T){y.ending=!0,xe(_,y),T&&(y.finished?process.nextTick(T):_.once("finish",T)),y.ended=!0,_.writable=!1}function Me(_,y,T){var U=_.entry;for(_.entry=null;U;){var q=U.callback;y.pendingcb--,q(T),U=U.next}y.corkedRequestsFree.next=_}return Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(y){this._writableState&&(this._writableState.destroyed=y)}}),D.prototype.destroy=p.destroy,D.prototype._undestroy=p.undestroy,D.prototype._destroy=function(_,y){y(_)},fr}var ur,zr;function lt(){if(zr)return ur;zr=1;var e=Object.keys||function(w){var m=[];for(var v in w)m.push(v);return m};ur=c;var t=Wn(),r=jn();be(c,t);for(var a=e(r.prototype),o=0;o<a.length;o++){var f=a[o];c.prototype[f]||(c.prototype[f]=r.prototype[f])}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=ve.Buffer,Yr=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 va(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function xa(e){var t=va(e);if(typeof t!="string"&&(Pr.isEncoding===Yr||!Yr(e)))throw new Error("Unknown encoding: "+e);return t||e}$t.StringDecoder=St;function St(e){this.encoding=xa(e);var t;switch(this.encoding){case"utf16le":this.text=Ta,this.end=Ia,t=4;break;case"utf8":this.fillLast=Ra,t=4;break;case"base64":this.text=ka,this.end=Ca,t=3;break;default:this.write=Oa,this.end=La;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=Pr.allocUnsafe(t)}St.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||""};St.prototype.end=Aa;St.prototype.text=Sa;St.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 Ea(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 Ba(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"�"}}function Ra(e){var t=this.lastTotal-this.lastNeed,r=Ba(this,e);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function Sa(e,t){var r=Ea(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var a=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString("utf8",t,a)}function Aa(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function Ta(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var 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 Ia(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function ka(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Ca(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Oa(e){return e.toString(this.encoding)}function La(e){return e&&e.length?this.write(e):""}var Qr=Ze.codes.ERR_STREAM_PREMATURE_CLOSE;function Ma(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 Pa(){}function Fa(e){return e.setHeader&&typeof e.abort=="function"}function qn(e,t,r){if(typeof t=="function")return qn(e,null,t);t||(t={}),r=Ma(r||Pa);var a=t.readable||t.readable!==!1&&e.readable,o=t.writable||t.writable!==!1&&e.writable,f=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)},A=function(){e.req.on("finish",u)};return Fa(e)?(e.on("complete",u),e.on("abort",v),e.req?A():e.on("request",A)):o&&!e._writableState&&(e.on("end",f),e.on("close",f)),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",A),e.req&&e.req.removeListener("finish",u),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",u),e.removeListener("end",w),e.removeListener("error",m),e.removeListener("close",v)}}var Fr=qn,lr,Xr;function Na(){if(Xr)return lr;Xr=1;var e;function t(P,M,N){return M=r(M),M in P?Object.defineProperty(P,M,{value:N,enumerable:!0,configurable:!0,writable:!0}):P[M]=N,P}function r(P){var M=a(P,"string");return typeof M=="symbol"?M:String(M)}function a(P,M){if(typeof P!="object"||P===null)return P;var N=P[Symbol.toPrimitive];if(N!==void 0){var E=N.call(P,M||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(M==="string"?String:Number)(P)}var o=Fr,f=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),p=Symbol("ended"),w=Symbol("lastPromise"),m=Symbol("handlePromise"),v=Symbol("stream");function A(P,M){return{value:P,done:M}}function k(P){var M=P[f];if(M!==null){var N=P[v].read();N!==null&&(P[w]=null,P[f]=null,P[c]=null,M(A(N,!1)))}}function R(P){process.nextTick(k,P)}function C(P,M){return function(N,E){P.then(function(){if(M[p]){N(A(void 0,!0));return}M[m](N,E)},E)}}var S=Object.getPrototypeOf(function(){}),I=Object.setPrototypeOf((e={get stream(){return this[v]},next:function(){var M=this,N=this[u];if(N!==null)return Promise.reject(N);if(this[p])return Promise.resolve(A(void 0,!0));if(this[v].destroyed)return new Promise(function($,ne){process.nextTick(function(){M[u]?ne(M[u]):$(A(void 0,!0))})});var E=this[w],j;if(E)j=new Promise(C(E,this));else{var D=this[v].read();if(D!==null)return Promise.resolve(A(D,!1));j=new Promise(this[m])}return this[w]=j,j}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var M=this;return new Promise(function(N,E){M[v].destroy(null,function(j){if(j){E(j);return}N(A(void 0,!0))})})}),e),S),O=function(M){var N,E=Object.create(I,(N={},t(N,v,{value:M,writable:!0}),t(N,f,{value:null,writable:!0}),t(N,c,{value:null,writable:!0}),t(N,u,{value:null,writable:!0}),t(N,p,{value:M._readableState.endEmitted,writable:!0}),t(N,m,{value:function(D,$){var ne=E[v].read();ne?(E[w]=null,E[f]=null,E[c]=null,D(A(ne,!1))):(E[f]=D,E[c]=$)},writable:!0}),N));return E[w]=null,o(M,function(j){if(j&&j.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=E[c];D!==null&&(E[w]=null,E[f]=null,E[c]=null,D(j)),E[u]=j;return}var $=E[f];$!==null&&(E[w]=null,E[f]=null,E[c]=null,$(A(void 0,!0))),E[p]=!0}),M.on("readable",R.bind(null,E)),E};return lr=O,lr}var hr,Zr;function Da(){return Zr||(Zr=1,hr=function(){throw new Error("Readable.from is not available in the browser")}),hr}var dr,en;function Wn(){if(en)return dr;en=1,dr=$;var e;$.ReadableState=D,Nn.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 f(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=fa(),m=Un,v=Hn,A=v.getHighWaterMark,k=Ze.codes,R=k.ERR_INVALID_ARG_TYPE,C=k.ERR_STREAM_PUSH_AFTER_EOF,S=k.ERR_METHOD_NOT_IMPLEMENTED,I=k.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,O,P,M;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 D(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=A(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&&(O||(O=$t.StringDecoder),this.decoder=new O(h.encoding),this.encoding=h.encoding)}function $(h){if(e=e||lt(),!(this instanceof $))return new $(h);var d=this instanceof e;this._readableState=new D(h,this,d),this.readable=!0,h&&(typeof h.read=="function"&&(this._read=h.read),typeof h.destroy=="function"&&(this._destroy=h.destroy)),r.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(d){this._readableState&&(this._readableState.destroyed=d)}}),$.prototype.destroy=m.destroy,$.prototype._undestroy=m.undestroy,$.prototype._destroy=function(h,d){d(h)},$.prototype.push=function(h,d){var 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,X){p("readableAddChunk",d);var W=h._readableState;if(d===null)W.reading=!1,Je(h,W);else{var G;if(X||(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=f(d)),F)W.endEmitted?N(h,new I):Te(h,W,d,!0);else if(W.ended)N(h,new C);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){O||(O=$t.StringDecoder);var d=new O(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 ae=1073741824;function we(h){return h>=ae?h=ae:(h--,h|=h>>>1,h|=h>>>2,h|=h>>>4,h|=h>>>8,h|=h>>>16,h++),h}function me(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=we(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?T(this):Ie(this),null;if(h=me(h,d),h===0&&d.ended)return d.length===0&&T(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=me(B,d)));var X;return h>0?X=y(h,d):X=null,X===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&&T(this)),X!==null&&this.emit("data",X),X};function Je(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 S("_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 X=(!d||d.end!==!1)&&h!==process.stdout&&h!==process.stderr,W=X?We:Ye;F.endEmitted?process.nextTick(W):B.once("end",W),h.on("unpipe",G);function G(s,n){p("onunpipe"),s===B&&n&&n.hasUnpiped===!1&&(n.hasUnpiped=!0,rt())}function We(){p("onend"),h.end()}var tt=Q(B);h.on("drain",tt);var pt=!1;function rt(){p("cleanup"),h.removeListener("close",bt),h.removeListener("finish",Be),h.removeListener("drain",tt),h.removeListener("error",ze),h.removeListener("unpipe",G),B.removeListener("end",We),B.removeListener("end",Ye),B.removeListener("data",Ee),pt=!0,F.awaitDrain&&(!h._writableState||h._writableState.needDrain)&&tt()}B.on("data",Ee);function Ee(s){p("ondata");var n=h.write(s);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 ze(s){p("onerror",s),Ye(),h.removeListener("error",ze),t(h,"error")===0&&N(h,s)}j(h,"error",ze);function bt(){h.removeListener("finish",Be),Ye()}h.once("close",bt);function Be(){p("onfinish"),h.removeListener("close",bt),Ye()}h.once("finish",Be);function Ye(){p("unpipe"),B.unpipe(h)}return h.emit("pipe",B),F.flowing||(p("pipe resume"),B.resume()),h};function Q(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,X=d.pipesCount;d.pipes=null,d.pipesCount=0,d.flowing=!1;for(var W=0;W<X;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(xe,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 xe(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 X in h)this[X]===void 0&&typeof h[X]=="function"&&(this[X]=function(We){return function(){return h[We].apply(h,arguments)}}(X));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=Na()),P(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(d){this._readableState&&(this._readableState.flowing=d)}}),$._fromList=y,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function y(h,d){if(d.length===0)return null;var 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 T(h){var d=h._readableState;p("endReadable",d.endEmitted),d.endEmitted||(d.ended=!0,process.nextTick(U,d,h))}function U(h,d){if(p("endReadableNT",h.endEmitted,h.length),!h.endEmitted&&h.length===0&&(h.endEmitted=!0,d.readable=!1,d.emit("end"),h.autoDestroy)){var B=d._writableState;(!B||B.autoDestroy&&B.finished)&&d.destroy()}}typeof Symbol=="function"&&($.from=function(h,d){return M===void 0&&(M=Da()),M($,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 Kn=Ue,Gt=Ze.codes,Ua=Gt.ERR_METHOD_NOT_IMPLEMENTED,$a=Gt.ERR_MULTIPLE_CALLBACK,Ha=Gt.ERR_TRANSFORM_ALREADY_TRANSFORMING,ja=Gt.ERR_TRANSFORM_WITH_LENGTH_0,Vt=lt();be(Ue,Vt);function qa(e,t){var r=this._transformState;r.transforming=!1;var a=r.writecb;if(a===null)return this.emit("error",new $a);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 Ue(e){if(!(this instanceof Ue))return new Ue(e);Vt.call(this,e),this._transformState={afterTransform:qa.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Wa)}function Wa(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){tn(e,t,r)}):tn(this,null,null)}Ue.prototype.push=function(e,t){return this._transformState.needTransform=!1,Vt.prototype.push.call(this,e,t)};Ue.prototype._transform=function(e,t,r){r(new Ua("_transform()"))};Ue.prototype._write=function(e,t,r){var 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)}};Ue.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Ue.prototype._destroy=function(e,t){Vt.prototype._destroy.call(this,e,function(r){t(r)})};function tn(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new ja;if(e._transformState.transforming)throw new Ha;return e.push(null)}var Ka=Bt,Gn=Kn;be(Bt,Gn);function Bt(e){if(!(this instanceof Bt))return new Bt(e);Gn.call(this,e)}Bt.prototype._transform=function(e,t,r){r(null,e)};var pr;function Ga(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var Vn=Ze.codes,Va=Vn.ERR_MISSING_ARGS,Ja=Vn.ERR_STREAM_DESTROYED;function rn(e){if(e)throw e}function za(e){return e.setHeader&&typeof e.abort=="function"}function Ya(e,t,r,a){a=Ga(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 f=!1;return function(c){if(!o&&!f){if(f=!0,za(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();a(c||new Ja("pipe"))}}}function nn(e){e()}function Qa(e,t){return e.pipe(t)}function Xa(e){return!e.length||typeof e[e.length-1]!="function"?rn:e.pop()}function Za(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=Xa(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Va("streams");var o,f=t.map(function(c,u){var p=u<t.length-1,w=u>0;return Ya(c,p,w,function(m){o||(o=m),m&&f.forEach(nn),!p&&(f.forEach(nn),a(o))})});return t.reduce(Qa)}var eo=Za;(function(e,t){t=e.exports=Wn(),t.Stream=t,t.Readable=t,t.Writable=jn(),t.Duplex=lt(),t.Transform=Kn,t.PassThrough=Ka,t.finished=Fr,t.pipeline=eo})(Er,Er.exports);var to=Er.exports,Ht=ve.Buffer,Jn=to.Transform,ro=be;function no(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}ro(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(no(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 f=0,c=e.length*8;c>0;++f)this._length[f]+=c,c=this._length[f]/4294967296|0,c>0&&(this._length[f]-=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 zn=Ve,io=be,Yn=zn,ao=ve.Buffer,oo=new Array(16);function Jt(){Yn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}io(Jt,Yn);Jt.prototype._update=function(){for(var e=oo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,a=this._b,o=this._c,f=this._d;r=ue(r,a,o,f,e[0],3614090360,7),f=ue(f,r,a,o,e[1],3905402710,12),o=ue(o,f,r,a,e[2],606105819,17),a=ue(a,o,f,r,e[3],3250441966,22),r=ue(r,a,o,f,e[4],4118548399,7),f=ue(f,r,a,o,e[5],1200080426,12),o=ue(o,f,r,a,e[6],2821735955,17),a=ue(a,o,f,r,e[7],4249261313,22),r=ue(r,a,o,f,e[8],1770035416,7),f=ue(f,r,a,o,e[9],2336552879,12),o=ue(o,f,r,a,e[10],4294925233,17),a=ue(a,o,f,r,e[11],2304563134,22),r=ue(r,a,o,f,e[12],1804603682,7),f=ue(f,r,a,o,e[13],4254626195,12),o=ue(o,f,r,a,e[14],2792965006,17),a=ue(a,o,f,r,e[15],1236535329,22),r=ce(r,a,o,f,e[1],4129170786,5),f=ce(f,r,a,o,e[6],3225465664,9),o=ce(o,f,r,a,e[11],643717713,14),a=ce(a,o,f,r,e[0],3921069994,20),r=ce(r,a,o,f,e[5],3593408605,5),f=ce(f,r,a,o,e[10],38016083,9),o=ce(o,f,r,a,e[15],3634488961,14),a=ce(a,o,f,r,e[4],3889429448,20),r=ce(r,a,o,f,e[9],568446438,5),f=ce(f,r,a,o,e[14],3275163606,9),o=ce(o,f,r,a,e[3],4107603335,14),a=ce(a,o,f,r,e[8],1163531501,20),r=ce(r,a,o,f,e[13],2850285829,5),f=ce(f,r,a,o,e[2],4243563512,9),o=ce(o,f,r,a,e[7],1735328473,14),a=ce(a,o,f,r,e[12],2368359562,20),r=le(r,a,o,f,e[5],4294588738,4),f=le(f,r,a,o,e[8],2272392833,11),o=le(o,f,r,a,e[11],1839030562,16),a=le(a,o,f,r,e[14],4259657740,23),r=le(r,a,o,f,e[1],2763975236,4),f=le(f,r,a,o,e[4],1272893353,11),o=le(o,f,r,a,e[7],4139469664,16),a=le(a,o,f,r,e[10],3200236656,23),r=le(r,a,o,f,e[13],681279174,4),f=le(f,r,a,o,e[0],3936430074,11),o=le(o,f,r,a,e[3],3572445317,16),a=le(a,o,f,r,e[6],76029189,23),r=le(r,a,o,f,e[9],3654602809,4),f=le(f,r,a,o,e[12],3873151461,11),o=le(o,f,r,a,e[15],530742520,16),a=le(a,o,f,r,e[2],3299628645,23),r=he(r,a,o,f,e[0],4096336452,6),f=he(f,r,a,o,e[7],1126891415,10),o=he(o,f,r,a,e[14],2878612391,15),a=he(a,o,f,r,e[5],4237533241,21),r=he(r,a,o,f,e[12],1700485571,6),f=he(f,r,a,o,e[3],2399980690,10),o=he(o,f,r,a,e[10],4293915773,15),a=he(a,o,f,r,e[1],2240044497,21),r=he(r,a,o,f,e[8],1873313359,6),f=he(f,r,a,o,e[15],4264355552,10),o=he(o,f,r,a,e[6],2734768916,15),a=he(a,o,f,r,e[13],1309151649,21),r=he(r,a,o,f,e[4],4149444226,6),f=he(f,r,a,o,e[11],3174756917,10),o=he(o,f,r,a,e[2],718787259,15),a=he(a,o,f,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+f|0};Jt.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=ao.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function zt(e,t){return e<<t|e>>>32-t}function ue(e,t,r,a,o,f,c){return zt(e+(t&r|~t&a)+o+f|0,c)+t|0}function ce(e,t,r,a,o,f,c){return zt(e+(t&a|r&~a)+o+f|0,c)+t|0}function le(e,t,r,a,o,f,c){return zt(e+(t^r^a)+o+f|0,c)+t|0}function he(e,t,r,a,o,f,c){return zt(e+(r^(t|~a))+o+f|0,c)+t|0}var so=Jt,br=ht.Buffer,fo=be,Qn=zn,uo=new Array(16),_t=[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],gt=[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],wt=[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],mt=[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],vt=[0,1518500249,1859775393,2400959708,2840853838],xt=[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}fo(Yt,Qn);Yt.prototype._update=function(){for(var e=uo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,a=this._b|0,o=this._c|0,f=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,A=0;A<80;A+=1){var k,R;A<16?(k=an(r,a,o,f,c,e[_t[A]],vt[0],wt[A]),R=un(u,p,w,m,v,e[gt[A]],xt[0],mt[A])):A<32?(k=on(r,a,o,f,c,e[_t[A]],vt[1],wt[A]),R=fn(u,p,w,m,v,e[gt[A]],xt[1],mt[A])):A<48?(k=sn(r,a,o,f,c,e[_t[A]],vt[2],wt[A]),R=sn(u,p,w,m,v,e[gt[A]],xt[2],mt[A])):A<64?(k=fn(r,a,o,f,c,e[_t[A]],vt[3],wt[A]),R=on(u,p,w,m,v,e[gt[A]],xt[3],mt[A])):(k=un(r,a,o,f,c,e[_t[A]],vt[4],wt[A]),R=an(u,p,w,m,v,e[gt[A]],xt[4],mt[A])),r=c,c=f,f=Xe(o,10),o=a,a=k,u=v,v=m,m=Xe(w,10),w=p,p=R}var C=this._b+o+m|0;this._b=this._c+f+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=C};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 Xe(e,t){return e<<t|e>>>32-t}function an(e,t,r,a,o,f,c,u){return Xe(e+(t^r^a)+f+c|0,u)+o|0}function on(e,t,r,a,o,f,c,u){return Xe(e+(t&r|~t&a)+f+c|0,u)+o|0}function sn(e,t,r,a,o,f,c,u){return Xe(e+((t|~r)^a)+f+c|0,u)+o|0}function fn(e,t,r,a,o,f,c,u){return Xe(e+(t&a|r&~a)+f+c|0,u)+o|0}function un(e,t,r,a,o,f,c,u){return Xe(e+(t^(r|~a))+f+c|0,u)+o|0}var co=Yt,Xn={exports:{}},Zn=ve.Buffer;function Qt(e,t){this._block=Zn.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Qt.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=Zn.from(e,t));for(var r=this._block,a=this._blockSize,o=e.length,f=this._len,c=0;c<o;){for(var u=f%a,p=Math.min(o-c,a-u),w=0;w<p;w++)r[u+w]=e[c+w];f+=p,c+=p,f%a===0&&this._update(r)}return this._len+=o,this};Qt.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var 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 f=this._hash();return e?f.toString(e):f};Qt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var dt=Qt,lo=be,ei=dt,ho=ve.Buffer,po=[1518500249,1859775393,-1894007588,-899497514],bo=new Array(80);function At(){this.init(),this._w=bo,ei.call(this,64,56)}lo(At,ei);At.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function yo(e){return e<<5|e>>>27}function _o(e){return e<<30|e>>>2}function go(e,t,r,a){return e===0?t&r|~t&a:e===2?t&r|t&a|r&a:t^r^a}At.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=this._b|0,o=this._c|0,f=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=yo(r)+go(w,a,o,f)+c+t[p]+po[w]|0;c=f,f=o,o=_o(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=f+this._d|0,this._e=c+this._e|0};At.prototype._hash=function(){var e=ho.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var wo=At,mo=be,ti=dt,vo=ve.Buffer,xo=[1518500249,1859775393,-1894007588,-899497514],Eo=new Array(80);function Tt(){this.init(),this._w=Eo,ti.call(this,64,56)}mo(Tt,ti);Tt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Bo(e){return e<<1|e>>>31}function Ro(e){return e<<5|e>>>27}function So(e){return e<<30|e>>>2}function Ao(e,t,r,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,f=this._d|0,c=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Bo(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var w=~~(p/20),m=Ro(r)+Ao(w,a,o,f)+c+t[p]+xo[w]|0;c=f,f=o,o=So(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=f+this._d|0,this._e=c+this._e|0};Tt.prototype._hash=function(){var e=vo.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var To=Tt,Io=be,ri=dt,ko=ve.Buffer,Co=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Oo=new Array(64);function It(){this.init(),this._w=Oo,ri.call(this,64,56)}Io(It,ri);It.prototype.init=function(){return this._a=1779033703,this._b=3144134277,this._c=1013904242,this._d=2773480762,this._e=1359893119,this._f=2600822924,this._g=528734635,this._h=1541459225,this};function Lo(e,t,r){return r^e&(t^r)}function Mo(e,t,r){return e&t|r&(e|t)}function Po(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Fo(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function No(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Do(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}It.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=this._b|0,o=this._c|0,f=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]+No(t[m-15])+t[m-16]|0;for(var v=0;v<64;++v){var A=w+Fo(c)+Lo(c,u,p)+Co[v]+t[v]|0,k=Po(r)+Mo(r,a,o)|0;w=p,p=u,u=c,c=f+A|0,f=o,o=a,a=r,r=A+k|0}this._a=r+this._a|0,this._b=a+this._b|0,this._c=o+this._c|0,this._d=f+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};It.prototype._hash=function(){var e=ko.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var ni=It,Uo=be,$o=ni,Ho=dt,jo=ve.Buffer,qo=new Array(64);function Xt(){this.init(),this._w=qo,Ho.call(this,64,56)}Uo(Xt,$o);Xt.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};Xt.prototype._hash=function(){var e=jo.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var Wo=Xt,Ko=be,ii=dt,Go=ve.Buffer,cn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Vo=new Array(160);function kt(){this.init(),this._w=Vo,ii.call(this,128,112)}Ko(kt,ii);kt.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 ln(e,t,r){return r^e&(t^r)}function hn(e,t,r){return e&t|r&(e|t)}function dn(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function pn(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Jo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function zo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Yo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function 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}kt.prototype._update=function(e){for(var t=this._w,r=this._ah|0,a=this._bh|0,o=this._ch|0,f=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,A=this._cl|0,k=this._dl|0,R=this._el|0,C=this._fl|0,S=this._gl|0,I=this._hl|0,O=0;O<32;O+=2)t[O]=e.readInt32BE(O*4),t[O+1]=e.readInt32BE(O*4+4);for(;O<160;O+=2){var P=t[O-30],M=t[O-15*2+1],N=Jo(P,M),E=zo(M,P);P=t[O-2*2],M=t[O-2*2+1];var j=Yo(P,M),D=Qo(M,P),$=t[O-7*2],ne=t[O-7*2+1],Te=t[O-16*2],$e=t[O-16*2+1],ae=E+ne|0,we=N+$+se(ae,E)|0;ae=ae+D|0,we=we+j+se(ae,D)|0,ae=ae+$e|0,we=we+Te+se(ae,$e)|0,t[O]=we,t[O+1]=ae}for(var me=0;me<160;me+=2){we=t[me],ae=t[me+1];var Je=hn(r,a,o),Ie=hn(m,v,A),He=dn(r,m),ke=dn(m,r),je=pn(c,R),Q=pn(R,c),ie=cn[me],xe=cn[me+1],qe=ln(c,u,p),Me=ln(R,C,S),_=I+Q|0,y=w+je+se(_,I)|0;_=_+Me|0,y=y+qe+se(_,Me)|0,_=_+xe|0,y=y+ie+se(_,xe)|0,_=_+ae|0,y=y+we+se(_,ae)|0;var T=ke+Ie|0,U=He+Je+se(T,ke)|0;w=p,I=S,p=u,S=C,u=c,C=R,R=k+_|0,c=f+y+se(R,k)|0,f=o,k=A,o=a,A=v,a=r,v=m,m=_+T|0,r=y+U+se(m,_)|0}this._al=this._al+m|0,this._bl=this._bl+v|0,this._cl=this._cl+A|0,this._dl=this._dl+k|0,this._el=this._el+R|0,this._fl=this._fl+C|0,this._gl=this._gl+S|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,A)|0,this._dh=this._dh+f+se(this._dl,k)|0,this._eh=this._eh+c+se(this._el,R)|0,this._fh=this._fh+u+se(this._fl,C)|0,this._gh=this._gh+p+se(this._gl,S)|0,this._hh=this._hh+w+se(this._hl,I)|0};kt.prototype._hash=function(){var e=Go.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 ai=kt,Xo=be,Zo=ai,es=dt,ts=ve.Buffer,rs=new Array(160);function Zt(){this.init(),this._w=rs,es.call(this,128,112)}Xo(Zt,Zo);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=ts.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 ns=Zt,et=Xn.exports=function(t){t=t.toLowerCase();var r=et[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};et.sha=wo;et.sha1=To;et.sha224=Wo;et.sha256=ni;et.sha384=ns;et.sha512=ai;var is=Xn.exports,oi=ve.Buffer,si=Mr.Transform,as=$t.StringDecoder,os=be;function Ce(e){si.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}os(Ce,si);Ce.prototype.update=function(e,t,r){typeof e=="string"&&(e=oi.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()||oi.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Ce.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new as(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var a=this._decoder.write(e);return r&&(a+=this._decoder.end()),a};var ss=Ce,fs=be,us=so,cs=co,ls=is,fi=ss;function er(e){fi.call(this,"digest"),this._hash=e}fs(er,fi);er.prototype._update=function(e){this._hash.update(e)};er.prototype._final=function(){return this._hash.digest()};var hs=function(t){return t=t.toLowerCase(),t==="md5"?new us:t==="rmd160"||t==="ripemd160"?new cs:new er(ls(t))},Lt=ve.Buffer;function ds(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var a=0;a<e.length;a++){var o=e.charAt(a),f=o.charCodeAt(0);if(t[f]!==255)throw new TypeError(o+" is ambiguous");t[f]=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(k){if((Array.isArray(k)||k instanceof Uint8Array)&&(k=Lt.from(k)),!Lt.isBuffer(k))throw new TypeError("Expected Buffer");if(k.length===0)return"";for(var R=0,C=0,S=0,I=k.length;S!==I&&k[S]===0;)S++,R++;for(var O=(I-S)*w+1>>>0,P=new Uint8Array(O);S!==I;){for(var M=k[S],N=0,E=O-1;(M!==0||N<C)&&E!==-1;E--,N++)M+=256*P[E]>>>0,P[E]=M%c>>>0,M=M/c>>>0;if(M!==0)throw new Error("Non-zero carry");C=N,S++}for(var j=O-C;j!==O&&P[j]===0;)j++;for(var D=u.repeat(R);j<O;++j)D+=e.charAt(P[j]);return D}function v(k){if(typeof k!="string")throw new TypeError("Expected String");if(k.length===0)return Lt.alloc(0);for(var R=0,C=0,S=0;k[R]===u;)C++,R++;for(var I=(k.length-R)*p+1>>>0,O=new Uint8Array(I);R<k.length;){var P=t[k.charCodeAt(R)];if(P===255)return;for(var M=0,N=I-1;(P!==0||M<S)&&N!==-1;N--,M++)P+=c*O[N]>>>0,O[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");S=M,R++}for(var E=I-S;E!==I&&O[E]===0;)E++;var j=Lt.allocUnsafe(C+(I-E));j.fill(0,0,C);for(var D=C;E!==I;)j[D++]=O[E++];return j}function A(k){var R=v(k);if(R)return R;throw new Error("Non-base"+c+" character")}return{encode:m,decodeUnsafe:v,decode:A}}var ps=ds,bs=ps,ys="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_s=bs(ys),yr=_s,gs=ve.Buffer,ws=function(e){function t(f){var c=e(f);return yr.encode(gs.concat([f,c],f.length+4))}function r(f){var c=f.slice(0,-4),u=f.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(f){var c=yr.decodeUnsafe(f);if(c)return r(c)}function o(f){var c=yr.decode(f),u=r(c);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:o,decodeUnsafe:a}},bn=hs,ms=ws;function vs(e){var t=bn("sha256").update(e).digest();return bn("sha256").update(t).digest()}var xs=ms(vs),Rr=xs;function ui(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 Es(e,t){return ui(Rr.decode(e),t)}function Bs(e,t,r){return typeof e=="number"?Rr.encode(Sr(e,t,r)):Rr.encode(Sr(e.version,e.privateKey,e.compressed))}var Rs={decode:Es,decodeRaw:ui,encode:Bs,encodeRaw:Sr},tr={};Object.defineProperty(tr,"__esModule",{value:!0});tr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Ss(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=Ss;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=xn,As=Zi,yn=Rs,Ts=tr,_r=_e.typeforce.maybe(_e.typeforce.compile({compressed:_e.maybe(_e.Boolean),network:_e.maybe(_e.Network)})),Is=e=>e.length===32?e:e.slice(1,33);function ks(e){(0,Ts.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,p){if(_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=yn.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 f(u){_e.typeforce(_r,u),u===void 0&&(u={});const p=u.rng||As;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 yn.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 A=0;for(;m[0]>127;)A++,v.writeUIntLE(A,0,6),m=e.sign(p,this.__D,v);return Buffer.from(m)}}signSchnorr(p){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return Buffer.from(e.signSchnorr(p,this.privateKey))}verify(p,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=Is(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:f}}ut.ECPairFactory=ks;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=ut;Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return t.networks}})})(vn);class jt{constructor(t){this.privKey=t}static fromPrivKey(t){return new jt(L.trim0x(t))}static async fromWalletClient(t){if(!t.account)return L.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.0",Nonce:1n}});return L.Ok(new jt(L.trim0x(Ne.sha256(r))))}catch(r){return L.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),a=Ne.sha256(pe.with0x(r)),o=Ne.sha256(a);return L.Ok({secret:a,secretHash:o})}signMessage(t){const r=vn.ECPairFactory(ft),a="Garden.fi"+t.toString(),o=Buffer.from(a,"utf8"),f=Ne.sha256(o),c=Buffer.from(L.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(L.trim0x(f),"hex")).toString("hex")}}class Cs{constructor(t){this.quoteUrl=new pe.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()}),f=await L.Fetcher.get(o);return f.error?L.Err(f.error):f.result?L.Ok(f.result):L.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return L.Err("GetQuote:",String(o))}}async getAttestedQuote(t){try{const r=await L.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?L.Err(r.error):r.result?L.Ok(r.result):L.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),L.Err("GetAttestedQuote:",String(r))}}}Object.defineProperty(exports,"Asset",{enumerable:!0,get:()=>z.Asset});Object.defineProperty(exports,"MatchedOrder",{enumerable:!0,get:()=>z.MatchedOrder});Object.defineProperty(exports,"isBitcoin",{enumerable:!0,get:()=>z.isBitcoin});exports.EvmRelay=mn;exports.Garden=Oi;exports.ParseOrderStatus=gn;exports.ParseSwapStatus=Ft;exports.Quote=Cs;exports.SecretManager=jt;exports.parseAction=wn;exports.switchOrAddNetwork=Ei;
|
|
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=O,e.INSPECT_MAX_BYTES=50;const o=2147483647;e.kMaxLength=o,u.TYPED_ARRAY_SUPPORT=f(),!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 f(){try{const s=new Uint8Array(1),n={foo:function(){return 42}};return Object.setPrototypeOf(n,Uint8Array.prototype),Object.setPrototypeOf(s,n),s.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(s){if(s>o)throw new RangeError('The value "'+s+'" is invalid for option "size"');const n=new Uint8Array(s);return Object.setPrototypeOf(n,u.prototype),n}function u(s,n,i){if(typeof s=="number"){if(typeof n=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return v(s)}return p(s,n,i)}u.poolSize=8192;function p(s,n,i){if(typeof s=="string")return A(s,n);if(ArrayBuffer.isView(s))return R(s);if(s==null)throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof s);if(Ee(s,ArrayBuffer)||s&&Ee(s.buffer,ArrayBuffer)||typeof SharedArrayBuffer<"u"&&(Ee(s,SharedArrayBuffer)||s&&Ee(s.buffer,SharedArrayBuffer)))return C(s,n,i);if(typeof s=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');const l=s.valueOf&&s.valueOf();if(l!=null&&l!==s)return u.from(l,n,i);const b=S(s);if(b)return b;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof s[Symbol.toPrimitive]=="function")return u.from(s[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 s)}u.from=function(s,n,i){return p(s,n,i)},Object.setPrototypeOf(u.prototype,Uint8Array.prototype),Object.setPrototypeOf(u,Uint8Array);function w(s){if(typeof s!="number")throw new TypeError('"size" argument must be of type number');if(s<0)throw new RangeError('The value "'+s+'" is invalid for option "size"')}function m(s,n,i){return w(s),s<=0?c(s):n!==void 0?typeof i=="string"?c(s).fill(n,i):c(s).fill(n):c(s)}u.alloc=function(s,n,i){return m(s,n,i)};function v(s){return w(s),c(s<0?0:I(s)|0)}u.allocUnsafe=function(s){return v(s)},u.allocUnsafeSlow=function(s){return v(s)};function A(s,n){if((typeof n!="string"||n==="")&&(n="utf8"),!u.isEncoding(n))throw new TypeError("Unknown encoding: "+n);const i=P(s,n)|0;let l=c(i);const b=l.write(s,n);return b!==i&&(l=l.slice(0,b)),l}function k(s){const n=s.length<0?0:I(s.length)|0,i=c(n);for(let l=0;l<n;l+=1)i[l]=s[l]&255;return i}function R(s){if(Ee(s,Uint8Array)){const n=new Uint8Array(s);return C(n.buffer,n.byteOffset,n.byteLength)}return k(s)}function C(s,n,i){if(n<0||s.byteLength<n)throw new RangeError('"offset" is outside of buffer bounds');if(s.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(s):i===void 0?l=new Uint8Array(s,n):l=new Uint8Array(s,n,i),Object.setPrototypeOf(l,u.prototype),l}function S(s){if(u.isBuffer(s)){const n=I(s.length)|0,i=c(n);return i.length===0||s.copy(i,0,0,n),i}if(s.length!==void 0)return typeof s.length!="number"||ze(s.length)?c(0):k(s);if(s.type==="Buffer"&&Array.isArray(s.data))return k(s.data)}function I(s){if(s>=o)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x"+o.toString(16)+" bytes");return s|0}function O(s){return+s!=s&&(s=0),u.alloc(+s)}u.isBuffer=function(n){return n!=null&&n._isBuffer===!0&&n!==u.prototype},u.compare=function(n,i){if(Ee(n,Uint8Array)&&(n=u.from(n,n.offset,n.byteLength)),Ee(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(Ee(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(s,n){if(u.isBuffer(s))return s.length;if(ArrayBuffer.isView(s)||Ee(s,ArrayBuffer))return s.byteLength;if(typeof s!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof s);const i=s.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(s).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return i*2;case"hex":return i>>>1;case"base64":return pt(s).length;default:if(b)return l?-1:G(s).length;n=(""+n).toLowerCase(),b=!0}}u.byteLength=P;function M(s,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(s||(s="utf8");;)switch(s){case"hex":return ke(this,n,i);case"utf8":case"utf-8":return we(this,n,i);case"ascii":return Ie(this,n,i);case"latin1":case"binary":return He(this,n,i);case"base64":return ae(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: "+s);s=(s+"").toLowerCase(),l=!0}}u.prototype._isBuffer=!0;function N(s,n,i){const l=s[n];s[n]=s[i],s[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?we(this,0,n):M.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(Ee(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),X=this.slice(b,g),re=n.slice(i,l);for(let J=0;J<te;++J)if(X[J]!==re[J]){x=X[J],K=re[J];break}return x<K?-1:K<x?1:0};function E(s,n,i,l,b){if(s.length===0)return-1;if(typeof i=="string"?(l=i,i=0):i>2147483647?i=2147483647:i<-2147483648&&(i=-2147483648),i=+i,ze(i)&&(i=b?0:s.length-1),i<0&&(i=s.length+i),i>=s.length){if(b)return-1;i=s.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(s,n,i,l,b);if(typeof n=="number")return n=n&255,typeof Uint8Array.prototype.indexOf=="function"?b?Uint8Array.prototype.indexOf.call(s,n,i):Uint8Array.prototype.lastIndexOf.call(s,n,i):j(s,[n],i,l,b);throw new TypeError("val must be string, number or Buffer")}function j(s,n,i,l,b){let g=1,x=s.length,K=n.length;if(l!==void 0&&(l=String(l).toLowerCase(),l==="ucs2"||l==="ucs-2"||l==="utf16le"||l==="utf-16le")){if(s.length<2||n.length<2)return-1;g=2,x/=2,K/=2,i/=2}function te(re,J){return g===1?re[J]:re.readUInt16BE(J*g)}let X;if(b){let re=-1;for(X=i;X<x;X++)if(te(s,X)===te(n,re===-1?0:X-re)){if(re===-1&&(re=X),X-re+1===K)return re*g}else re!==-1&&(X-=X-re),re=-1}else for(i+K>x&&(i=x-K),X=i;X>=0;X--){let re=!0;for(let J=0;J<K;J++)if(te(s,X+J)!==te(n,J)){re=!1;break}if(re)return X}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 D(s,n,i,l){i=Number(i)||0;const b=s.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(ze(K))return x;s[i+x]=K}return x}function $(s,n,i,l){return rt(G(n,s.length-i),s,i,l)}function ne(s,n,i,l){return rt(We(n),s,i,l)}function Te(s,n,i,l){return rt(pt(n),s,i,l)}function $e(s,n,i,l){return rt(tt(n,s.length-i),s,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 D(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 ae(s,n,i){return n===0&&i===s.length?t.fromByteArray(s):t.fromByteArray(s.slice(n,i))}function we(s,n,i){i=Math.min(s.length,i);const l=[];let b=n;for(;b<i;){const g=s[b];let x=null,K=g>239?4:g>223?3:g>191?2:1;if(b+K<=i){let te,X,re,J;switch(K){case 1:g<128&&(x=g);break;case 2:te=s[b+1],(te&192)===128&&(J=(g&31)<<6|te&63,J>127&&(x=J));break;case 3:te=s[b+1],X=s[b+2],(te&192)===128&&(X&192)===128&&(J=(g&15)<<12|(te&63)<<6|X&63,J>2047&&(J<55296||J>57343)&&(x=J));break;case 4:te=s[b+1],X=s[b+2],re=s[b+3],(te&192)===128&&(X&192)===128&&(re&192)===128&&(J=(g&15)<<18|(te&63)<<12|(X&63)<<6|re&63,J>65535&&J<1114112&&(x=J))}}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 Je(l)}const me=4096;function Je(s){const n=s.length;if(n<=me)return String.fromCharCode.apply(String,s);let i="",l=0;for(;l<n;)i+=String.fromCharCode.apply(String,s.slice(l,l+=me));return i}function Ie(s,n,i){let l="";i=Math.min(s.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(s[b]&127);return l}function He(s,n,i){let l="";i=Math.min(s.length,i);for(let b=n;b<i;++b)l+=String.fromCharCode(s[b]);return l}function ke(s,n,i){const l=s.length;(!n||n<0)&&(n=0),(!i||i<0||i>l)&&(i=l);let b="";for(let g=n;g<i;++g)b+=bt[s[g]];return b}function je(s,n,i){const l=s.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 Y(s,n,i){if(s%1!==0||s<0)throw new RangeError("offset is not uint");if(s+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||Y(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||Y(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||Y(n,1,this.length),this[n]},u.prototype.readUint16LE=u.prototype.readUInt16LE=function(n,i){return n=n>>>0,i||Y(n,2,this.length),this[n]|this[n+1]<<8},u.prototype.readUint16BE=u.prototype.readUInt16BE=function(n,i){return n=n>>>0,i||Y(n,2,this.length),this[n]<<8|this[n+1]},u.prototype.readUint32LE=u.prototype.readUInt32LE=function(n,i){return n=n>>>0,i||Y(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||Y(n,4,this.length),this[n]*16777216+(this[n+1]<<16|this[n+2]<<8|this[n+3])},u.prototype.readBigUInt64LE=Be(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=Be(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||Y(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||Y(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||Y(n,1,this.length),this[n]&128?(255-this[n]+1)*-1:this[n]},u.prototype.readInt16LE=function(n,i){n=n>>>0,i||Y(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||Y(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||Y(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||Y(n,4,this.length),this[n]<<24|this[n+1]<<16|this[n+2]<<8|this[n+3]},u.prototype.readBigInt64LE=Be(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=Be(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||Y(n,4,this.length),r.read(this,n,!0,23,4)},u.prototype.readFloatBE=function(n,i){return n=n>>>0,i||Y(n,4,this.length),r.read(this,n,!1,23,4)},u.prototype.readDoubleLE=function(n,i){return n=n>>>0,i||Y(n,8,this.length),r.read(this,n,!0,52,8)},u.prototype.readDoubleBE=function(n,i){return n=n>>>0,i||Y(n,8,this.length),r.read(this,n,!1,52,8)};function ie(s,n,i,l,b,g){if(!u.isBuffer(s))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>s.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 xe(s,n,i,l,b){d(n,l,b,s,i,7);let g=Number(n&BigInt(4294967295));s[i++]=g,g=g>>8,s[i++]=g,g=g>>8,s[i++]=g,g=g>>8,s[i++]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return s[i++]=x,x=x>>8,s[i++]=x,x=x>>8,s[i++]=x,x=x>>8,s[i++]=x,i}function qe(s,n,i,l,b){d(n,l,b,s,i,7);let g=Number(n&BigInt(4294967295));s[i+7]=g,g=g>>8,s[i+6]=g,g=g>>8,s[i+5]=g,g=g>>8,s[i+4]=g;let x=Number(n>>BigInt(32)&BigInt(4294967295));return s[i+3]=x,x=x>>8,s[i+2]=x,x=x>>8,s[i+1]=x,x=x>>8,s[i]=x,i+8}u.prototype.writeBigUInt64LE=Be(function(n,i=0){return xe(this,n,i,BigInt(0),BigInt("0xffffffffffffffff"))}),u.prototype.writeBigUInt64BE=Be(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=Be(function(n,i=0){return xe(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))}),u.prototype.writeBigInt64BE=Be(function(n,i=0){return qe(this,n,i,-BigInt("0x8000000000000000"),BigInt("0x7fffffffffffffff"))});function Me(s,n,i,l,b,g){if(i+l>s.length)throw new RangeError("Index out of range");if(i<0)throw new RangeError("Index out of range")}function _(s,n,i,l,b){return n=+n,i=i>>>0,b||Me(s,n,i,4),r.write(s,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(s,n,i,l,b){return n=+n,i=i>>>0,b||Me(s,n,i,8),r.write(s,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 T={};function U(s,n,i){T[s]=class extends i{constructor(){super(),Object.defineProperty(this,"message",{value:n.apply(this,arguments),writable:!0,configurable:!0}),this.name=`${this.name} [${s}]`,this.stack,delete this.name}get code(){return s}set code(b){Object.defineProperty(this,"code",{configurable:!0,enumerable:!0,value:b,writable:!0})}toString(){return`${this.name} [${s}]: ${this.message}`}}}U("ERR_BUFFER_OUT_OF_BOUNDS",function(s){return s?`${s} is outside of buffer bounds`:"Attempt to access memory outside buffer bounds"},RangeError),U("ERR_INVALID_ARG_TYPE",function(s,n){return`The "${s}" argument must be of type number. Received type ${typeof n}`},TypeError),U("ERR_OUT_OF_RANGE",function(s,n,i){let l=`The value of "${s}" 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(s){let n="",i=s.length;const l=s[0]==="-"?1:0;for(;i>=l+4;i-=3)n=`_${s.slice(i-3,i)}${n}`;return`${s.slice(0,i)}${n}`}function h(s,n,i){B(n,"offset"),(s[n]===void 0||s[n+i]===void 0)&&F(n,s.length-(i+1))}function d(s,n,i,l,b,g){if(s>i||s<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 T.ERR_OUT_OF_RANGE("value",K,s)}h(l,b,g)}function B(s,n){if(typeof s!="number")throw new T.ERR_INVALID_ARG_TYPE(n,"number",s)}function F(s,n,i){throw Math.floor(s)!==s?(B(s,i),new T.ERR_OUT_OF_RANGE("offset","an integer",s)):n<0?new T.ERR_BUFFER_OUT_OF_BOUNDS:new T.ERR_OUT_OF_RANGE("offset",`>= 0 and <= ${n}`,s)}const Q=/[^+/0-9A-Za-z-_]/g;function W(s){if(s=s.split("=")[0],s=s.trim().replace(Q,""),s.length<2)return"";for(;s.length%4!==0;)s=s+"=";return s}function G(s,n){n=n||1/0;let i;const l=s.length;let b=null;const g=[];for(let x=0;x<l;++x){if(i=s.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(s){const n=[];for(let i=0;i<s.length;++i)n.push(s.charCodeAt(i)&255);return n}function tt(s,n){let i,l,b;const g=[];for(let x=0;x<s.length&&!((n-=2)<0);++x)i=s.charCodeAt(x),l=i>>8,b=i%256,g.push(b),g.push(l);return g}function pt(s){return t.toByteArray(W(s))}function rt(s,n,i,l){let b;for(b=0;b<l&&!(b+i>=n.length||b>=s.length);++b)n[b+i]=s[b];return b}function Ee(s,n){return s instanceof n||s!=null&&s.constructor!=null&&s.constructor.name!=null&&s.constructor.name===n.name}function ze(s){return s!==s}const bt=function(){const s="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]=s[i]+s[b]}return n}();function Be(s){return typeof BigInt>"u"?Ye:s}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=f);function f(c,u,p){return a(c,u,p)}f.prototype=Object.create(a.prototype),o(a,f),f.from=function(c,u,p){if(typeof c=="number")throw new TypeError("Argument must not be a number");return a(c,u,p)},f.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},f.allocUnsafe=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return a(c)},f.allocUnsafeSlow=function(c){if(typeof c!="number")throw new TypeError("Argument must be a number");return r.SlowBuffer(c)}})(vr,vr.exports);var ve=vr.exports,ar=65536,zi=4294967295;function Yi(){throw new Error(`Secure random number generation is not supported by this browser.
|
|
28
|
+
Use Chrome, Firefox or Internet Explorer 11`)}var Qi=ve.Buffer,Ut=Ge.crypto||Ge.msCrypto;Ut&&Ut.getRandomValues?mr.exports=Xi:mr.exports=Yi;function Xi(e,t){if(e>zi)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)Ut.getRandomValues(r.slice(a,a+ar));else Ut.getRandomValues(r);return typeof t=="function"?process.nextTick(function(){t(null,r)}):r}var Zi=mr.exports,xr={exports:{}};typeof Object.create=="function"?xr.exports=function(t,r){r&&(t.super_=r,t.prototype=Object.create(r.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}))}:xr.exports=function(t,r){if(r){t.super_=r;var 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,qr=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 ea(e){console&&console.warn&&console.warn(e)}var In=Number.isNaN||function(t){return t!==t};function V(){V.init.call(this)}Lr.exports=V;Lr.exports.once=ia;V.EventEmitter=V;V.prototype._events=void 0;V.prototype._eventsCount=0;V.prototype._maxListeners=void 0;var Wr=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 Wr},set:function(e){if(typeof e!="number"||e<0||In(e))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+e+".");Wr=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||In(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 kn(e){return e._maxListeners===void 0?V.defaultMaxListeners:e._maxListeners}V.prototype.getMaxListeners=function(){return kn(this)};V.prototype.emit=function(t){for(var r=[],a=1;a<arguments.length;a++)r.push(arguments[a]);var o=t==="error",f=this._events;if(f!==void 0)o=o&&f.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=f[t];if(p===void 0)return!1;if(typeof p=="function")qr(p,this,r);else for(var w=p.length,m=Pn(p,w),a=0;a<w;++a)qr(m[a],this,r);return!0};function Cn(e,t,r,a){var o,f,c;if(Kt(r),f=e._events,f===void 0?(f=e._events=Object.create(null),e._eventsCount=0):(f.newListener!==void 0&&(e.emit("newListener",t,r.listener?r.listener:r),f=e._events),c=f[t]),c===void 0)c=f[t]=r,++e._eventsCount;else if(typeof c=="function"?c=f[t]=a?[r,c]:[c,r]:a?c.unshift(r):c.push(r),o=kn(e),o>0&&c.length>o&&!c.warned){c.warned=!0;var u=new Error("Possible EventEmitter memory leak detected. "+c.length+" "+String(t)+" listeners added. Use emitter.setMaxListeners() to increase limit");u.name="MaxListenersExceededWarning",u.emitter=e,u.type=t,u.count=c.length,ea(u)}return e}V.prototype.addListener=function(t,r){return Cn(this,t,r,!1)};V.prototype.on=V.prototype.addListener;V.prototype.prependListener=function(t,r){return Cn(this,t,r,!0)};function ta(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function On(e,t,r){var a={fired:!1,wrapFn:void 0,target:e,type:t,listener:r},o=ta.bind(a);return o.listener=r,a.wrapFn=o,o}V.prototype.once=function(t,r){return Kt(r),this.on(t,On(this,t,r)),this};V.prototype.prependOnceListener=function(t,r){return Kt(r),this.prependListener(t,On(this,t,r)),this};V.prototype.removeListener=function(t,r){var a,o,f,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(f=-1,c=a.length-1;c>=0;c--)if(a[c]===r||a[c].listener===r){u=a[c].listener,f=c;break}if(f<0)return this;f===0?a.shift():ra(a,f),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 f=Object.keys(a),c;for(o=0;o<f.length;++o)c=f[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 Ln(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?na(o):Pn(o,o.length)}V.prototype.listeners=function(t){return Ln(this,t,!0)};V.prototype.rawListeners=function(t){return Ln(this,t,!1)};V.listenerCount=function(e,t){return typeof e.listenerCount=="function"?e.listenerCount(t):Mn.call(e,t)};V.prototype.listenerCount=Mn;function Mn(e){var t=this._events;if(t!==void 0){var r=t[e];if(typeof r=="function")return 1;if(r!==void 0)return r.length}return 0}V.prototype.eventNames=function(){return this._eventsCount>0?Mt(this._events):[]};function Pn(e,t){for(var r=new Array(t),a=0;a<t;++a)r[a]=e[a];return r}function ra(e,t){for(;t+1<e.length;t++)e[t]=e[t+1];e.pop()}function na(e){for(var t=new Array(e.length),r=0;r<t.length;++r)t[r]=e[r].listener||e[r];return t}function ia(e,t){return new Promise(function(r,a){function o(c){e.removeListener(t,f),a(c)}function f(){typeof e.removeListener=="function"&&e.removeListener("error",o),r([].slice.call(arguments))}Fn(e,t,f,{once:!0}),t!=="error"&&aa(e,o,{once:!0})})}function aa(e,t,r){typeof e.on=="function"&&Fn(e,"error",t,r)}function Fn(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(f){a.once&&e.removeEventListener(t,o),r(f)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof e)}var Nn=Lr.exports,Dn=Nn.EventEmitter;const oa={},sa=Object.freeze(Object.defineProperty({__proto__:null,default:oa},Symbol.toStringTag,{value:"Module"})),Mr=Li(sa);var or,Kr;function fa(){if(Kr)return or;Kr=1;function e(R,C){var S=Object.keys(R);if(Object.getOwnPropertySymbols){var I=Object.getOwnPropertySymbols(R);C&&(I=I.filter(function(O){return Object.getOwnPropertyDescriptor(R,O).enumerable})),S.push.apply(S,I)}return S}function t(R){for(var C=1;C<arguments.length;C++){var S=arguments[C]!=null?arguments[C]:{};C%2?e(Object(S),!0).forEach(function(I){r(R,I,S[I])}):Object.getOwnPropertyDescriptors?Object.defineProperties(R,Object.getOwnPropertyDescriptors(S)):e(Object(S)).forEach(function(I){Object.defineProperty(R,I,Object.getOwnPropertyDescriptor(S,I))})}return R}function r(R,C,S){return C=c(C),C in R?Object.defineProperty(R,C,{value:S,enumerable:!0,configurable:!0,writable:!0}):R[C]=S,R}function a(R,C){if(!(R instanceof C))throw new TypeError("Cannot call a class as a function")}function o(R,C){for(var S=0;S<C.length;S++){var I=C[S];I.enumerable=I.enumerable||!1,I.configurable=!0,"value"in I&&(I.writable=!0),Object.defineProperty(R,c(I.key),I)}}function f(R,C,S){return C&&o(R.prototype,C),Object.defineProperty(R,"prototype",{writable:!1}),R}function c(R){var C=u(R,"string");return typeof C=="symbol"?C:String(C)}function u(R,C){if(typeof R!="object"||R===null)return R;var S=R[Symbol.toPrimitive];if(S!==void 0){var I=S.call(R,C||"default");if(typeof I!="object")return I;throw new TypeError("@@toPrimitive must return a primitive value.")}return(C==="string"?String:Number)(R)}var p=ht,w=p.Buffer,m=Mr,v=m.inspect,A=v&&v.custom||"inspect";function k(R,C,S){w.prototype.copy.call(R,C,S)}return or=function(){function R(){a(this,R),this.head=null,this.tail=null,this.length=0}return f(R,[{key:"push",value:function(S){var I={data:S,next:null};this.length>0?this.tail.next=I:this.head=I,this.tail=I,++this.length}},{key:"unshift",value:function(S){var I={data:S,next:this.head};this.length===0&&(this.tail=I),this.head=I,++this.length}},{key:"shift",value:function(){if(this.length!==0){var S=this.head.data;return this.length===1?this.head=this.tail=null:this.head=this.head.next,--this.length,S}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(S){if(this.length===0)return"";for(var I=this.head,O=""+I.data;I=I.next;)O+=S+I.data;return O}},{key:"concat",value:function(S){if(this.length===0)return w.alloc(0);for(var I=w.allocUnsafe(S>>>0),O=this.head,P=0;O;)k(O.data,I,P),P+=O.data.length,O=O.next;return I}},{key:"consume",value:function(S,I){var O;return S<this.head.data.length?(O=this.head.data.slice(0,S),this.head.data=this.head.data.slice(S)):S===this.head.data.length?O=this.shift():O=I?this._getString(S):this._getBuffer(S),O}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(S){var I=this.head,O=1,P=I.data;for(S-=P.length;I=I.next;){var M=I.data,N=S>M.length?M.length:S;if(N===M.length?P+=M:P+=M.slice(0,S),S-=N,S===0){N===M.length?(++O,I.next?this.head=I.next:this.head=this.tail=null):(this.head=I,I.data=M.slice(N));break}++O}return this.length-=O,P}},{key:"_getBuffer",value:function(S){var I=w.allocUnsafe(S),O=this.head,P=1;for(O.data.copy(I),S-=O.data.length;O=O.next;){var M=O.data,N=S>M.length?M.length:S;if(M.copy(I,I.length-S,0,N),S-=N,S===0){N===M.length?(++P,O.next?this.head=O.next:this.head=this.tail=null):(this.head=O,O.data=M.slice(N));break}++P}return this.length-=P,I}},{key:A,value:function(S,I){return v(this,t(t({},I),{},{depth:0,customInspect:!1}))}}]),R}(),or}function ua(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(f){!t&&f?r._writableState?r._writableState.errorEmitted?process.nextTick(Pt,r):(r._writableState.errorEmitted=!0,process.nextTick(Gr,r,f)):process.nextTick(Gr,r,f):t?(process.nextTick(Pt,r),t(f)):process.nextTick(Pt,r)}),this)}function Gr(e,t){Br(e,t),Pt(e)}function Pt(e){e._writableState&&!e._writableState.emitClose||e._readableState&&!e._readableState.emitClose||e.emit("close")}function ca(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)}function Br(e,t){e.emit("error",t)}function la(e,t){var r=e._readableState,a=e._writableState;r&&r.autoDestroy||a&&a.autoDestroy?e.destroy(t):e.emit("error",t)}var Un={destroy:ua,undestroy:ca,errorOrDestroy:la},Ze={};function ha(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}var $n={};function Ae(e,t,r){r||(r=Error);function a(f,c,u){return typeof t=="string"?t:t(f,c,u)}var o=function(f){ha(c,f);function c(u,p,w){return f.call(this,a(u,p,w))||this}return c}(r);o.prototype.name=r.name,o.prototype.code=e,$n[e]=o}function Vr(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 da(e,t,r){return e.substr(0,t.length)===t}function pa(e,t,r){return(r===void 0||r>e.length)&&(r=e.length),e.substring(r-t.length,r)===t}function ba(e,t,r){return typeof r!="number"&&(r=0),r+t.length>e.length?!1:e.indexOf(t,r)!==-1}Ae("ERR_INVALID_OPT_VALUE",function(e,t){return'The value "'+t+'" is invalid for option "'+e+'"'},TypeError);Ae("ERR_INVALID_ARG_TYPE",function(e,t,r){var a;typeof t=="string"&&da(t,"not ")?(a="must not be",t=t.replace(/^not /,"")):a="must be";var o;if(pa(e," argument"))o="The ".concat(e," ").concat(a," ").concat(Vr(t,"type"));else{var f=ba(e,".")?"property":"argument";o='The "'.concat(e,'" ').concat(f," ").concat(a," ").concat(Vr(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=$n;var ya=Ze.codes.ERR_INVALID_OPT_VALUE;function _a(e,t,r){return e.highWaterMark!=null?e.highWaterMark:t?e[r]:null}function ga(e,t,r,a){var o=_a(t,a,r);if(o!=null){if(!(isFinite(o)&&Math.floor(o)===o)||o<0){var f=a?r:"highWaterMark";throw new ya(f,o)}return Math.floor(o)}return e.objectMode?16:16*1024}var Hn={getHighWaterMark:ga},wa=ma;function ma(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 jn(){if(Jr)return fr;Jr=1,fr=D;function e(_){var y=this;this.next=null,this.entry=null,this.finish=function(){Me(y,_)}}var t;D.WritableState=E;var r={deprecate:wa},a=Dn,o=ht.Buffer,f=(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 f}var p=Un,w=Hn,m=w.getHighWaterMark,v=Ze.codes,A=v.ERR_INVALID_ARG_TYPE,k=v.ERR_METHOD_NOT_IMPLEMENTED,R=v.ERR_MULTIPLE_CALLBACK,C=v.ERR_STREAM_CANNOT_PIPE,S=v.ERR_STREAM_DESTROYED,I=v.ERR_STREAM_NULL_VALUES,O=v.ERR_STREAM_WRITE_AFTER_END,P=v.ERR_UNKNOWN_ENCODING,M=p.errorOrDestroy;be(D,a);function N(){}function E(_,y,T){t=t||lt(),_=_||{},typeof T!="boolean"&&(T=y instanceof t),this.objectMode=!!_.objectMode,T&&(this.objectMode=this.objectMode||!!_.writableObjectMode),this.highWaterMark=m(this,_,"writableHighWaterMark",T),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var U=_.decodeStrings===!1;this.decodeStrings=!U,this.defaultEncoding=_.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(q){Je(y,q)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=_.emitClose!==!1,this.autoDestroy=!!_.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new e(this)}E.prototype.getBuffer=function(){for(var y=this.bufferedRequest,T=[];y;)T.push(y),y=y.next;return T},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(D,Symbol.hasInstance,{value:function(y){return j.call(this,y)?!0:this!==D?!1:y&&y._writableState instanceof E}})):j=function(y){return y instanceof this};function D(_){t=t||lt();var y=this instanceof t;if(!y&&!j.call(D,this))return new D(_);this._writableState=new 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)}D.prototype.pipe=function(){M(this,new C)};function $(_,y){var T=new O;M(_,T),process.nextTick(y,T)}function ne(_,y,T,U){var q;return T===null?q=new I:typeof T!="string"&&!y.objectMode&&(q=new A("chunk",["string","Buffer"],T)),q?(M(_,q),process.nextTick(U,q),!1):!0}D.prototype.write=function(_,y,T){var U=this._writableState,q=!1,h=!U.objectMode&&u(_);return h&&!o.isBuffer(_)&&(_=c(_)),typeof y=="function"&&(T=y,y=null),h?y="buffer":y||(y=U.defaultEncoding),typeof T!="function"&&(T=N),U.ending?$(this,T):(h||ne(this,U,_,T))&&(U.pendingcb++,q=$e(this,U,h,_,y,T)),q},D.prototype.cork=function(){this._writableState.corked++},D.prototype.uncork=function(){var _=this._writableState;_.corked&&(_.corked--,!_.writing&&!_.corked&&!_.bufferProcessing&&_.bufferedRequest&&ke(this,_))},D.prototype.setDefaultEncoding=function(y){if(typeof y=="string"&&(y=y.toLowerCase()),!(["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((y+"").toLowerCase())>-1))throw new P(y);return this._writableState.defaultEncoding=y,this},Object.defineProperty(D.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}});function Te(_,y,T){return!_.objectMode&&_.decodeStrings!==!1&&typeof y=="string"&&(y=o.from(y,T)),y}Object.defineProperty(D.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}});function $e(_,y,T,U,q,h){if(!T){var d=Te(y,U,q);U!==d&&(T=!0,q="buffer",U=d)}var B=y.objectMode?1:U.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:U,encoding:q,isBuf:T,callback:h,next:null},Q?Q.next=y.lastBufferedRequest:y.bufferedRequest=y.lastBufferedRequest,y.bufferedRequestCount+=1}else ae(_,y,!1,B,U,q,h);return F}function ae(_,y,T,U,q,h,d){y.writelen=U,y.writecb=d,y.writing=!0,y.sync=!0,y.destroyed?y.onwrite(new S("write")):T?_._writev(q,y.onwrite):_._write(q,h,y.onwrite),y.sync=!1}function we(_,y,T,U,q){--y.pendingcb,T?(process.nextTick(q,U),process.nextTick(xe,_,y),_._writableState.errorEmitted=!0,M(_,U)):(q(U),_._writableState.errorEmitted=!0,M(_,U),xe(_,y))}function me(_){_.writing=!1,_.writecb=null,_.length-=_.writelen,_.writelen=0}function Je(_,y){var T=_._writableState,U=T.sync,q=T.writecb;if(typeof q!="function")throw new R;if(me(T),y)we(_,T,U,y,q);else{var h=je(T)||_.destroyed;!h&&!T.corked&&!T.bufferProcessing&&T.bufferedRequest&&ke(_,T),U?process.nextTick(Ie,_,T,h,q):Ie(_,T,h,q)}}function Ie(_,y,T,U){T||He(_,y),y.pendingcb--,U(),xe(_,y)}function He(_,y){y.length===0&&y.needDrain&&(y.needDrain=!1,_.emit("drain"))}function ke(_,y){y.bufferProcessing=!0;var T=y.bufferedRequest;if(_._writev&&T&&T.next){var U=y.bufferedRequestCount,q=new Array(U),h=y.corkedRequestsFree;h.entry=T;for(var d=0,B=!0;T;)q[d]=T,T.isBuf||(B=!1),T=T.next,d+=1;q.allBuffers=B,ae(_,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(;T;){var F=T.chunk,Q=T.encoding,W=T.callback,G=y.objectMode?1:F.length;if(ae(_,y,!1,G,F,Q,W),T=T.next,y.bufferedRequestCount--,y.writing)break}T===null&&(y.lastBufferedRequest=null)}y.bufferedRequest=T,y.bufferProcessing=!1}D.prototype._write=function(_,y,T){T(new k("_write()"))},D.prototype._writev=null,D.prototype.end=function(_,y,T){var U=this._writableState;return typeof _=="function"?(T=_,_=null,y=null):typeof y=="function"&&(T=y,y=null),_!=null&&this.write(_,y),U.corked&&(U.corked=1,this.uncork()),U.ending||qe(this,U,T),this},Object.defineProperty(D.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}});function je(_){return _.ending&&_.length===0&&_.bufferedRequest===null&&!_.finished&&!_.writing}function Y(_,y){_._final(function(T){y.pendingcb--,T&&M(_,T),y.prefinished=!0,_.emit("prefinish"),xe(_,y)})}function ie(_,y){!y.prefinished&&!y.finalCalled&&(typeof _._final=="function"&&!y.destroyed?(y.pendingcb++,y.finalCalled=!0,process.nextTick(Y,_,y)):(y.prefinished=!0,_.emit("prefinish")))}function xe(_,y){var T=je(y);if(T&&(ie(_,y),y.pendingcb===0&&(y.finished=!0,_.emit("finish"),y.autoDestroy))){var U=_._readableState;(!U||U.autoDestroy&&U.endEmitted)&&_.destroy()}return T}function qe(_,y,T){y.ending=!0,xe(_,y),T&&(y.finished?process.nextTick(T):_.once("finish",T)),y.ended=!0,_.writable=!1}function Me(_,y,T){var U=_.entry;for(_.entry=null;U;){var q=U.callback;y.pendingcb--,q(T),U=U.next}y.corkedRequestsFree.next=_}return Object.defineProperty(D.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState===void 0?!1:this._writableState.destroyed},set:function(y){this._writableState&&(this._writableState.destroyed=y)}}),D.prototype.destroy=p.destroy,D.prototype._undestroy=p.undestroy,D.prototype._destroy=function(_,y){y(_)},fr}var ur,zr;function lt(){if(zr)return ur;zr=1;var e=Object.keys||function(w){var m=[];for(var v in w)m.push(v);return m};ur=c;var t=Wn(),r=jn();be(c,t);for(var a=e(r.prototype),o=0;o<a.length;o++){var f=a[o];c.prototype[f]||(c.prototype[f]=r.prototype[f])}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=ve.Buffer,Yr=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 va(e){if(!e)return"utf8";for(var t;;)switch(e){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return e;default:if(t)return;e=(""+e).toLowerCase(),t=!0}}function xa(e){var t=va(e);if(typeof t!="string"&&(Pr.isEncoding===Yr||!Yr(e)))throw new Error("Unknown encoding: "+e);return t||e}$t.StringDecoder=At;function At(e){this.encoding=xa(e);var t;switch(this.encoding){case"utf16le":this.text=Ta,this.end=Ia,t=4;break;case"utf8":this.fillLast=Ra,t=4;break;case"base64":this.text=ka,this.end=Ca,t=3;break;default:this.write=Oa,this.end=La;return}this.lastNeed=0,this.lastTotal=0,this.lastChar=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=Aa;At.prototype.text=Sa;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 Ea(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 Ba(e,t,r){if((t[0]&192)!==128)return e.lastNeed=0,"�";if(e.lastNeed>1&&t.length>1){if((t[1]&192)!==128)return e.lastNeed=1,"�";if(e.lastNeed>2&&t.length>2&&(t[2]&192)!==128)return e.lastNeed=2,"�"}}function Ra(e){var t=this.lastTotal-this.lastNeed,r=Ba(this,e);if(r!==void 0)return r;if(this.lastNeed<=e.length)return e.copy(this.lastChar,t,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal);e.copy(this.lastChar,t,0,e.length),this.lastNeed-=e.length}function Sa(e,t){var r=Ea(this,e,t);if(!this.lastNeed)return e.toString("utf8",t);this.lastTotal=r;var a=e.length-(r-this.lastNeed);return e.copy(this.lastChar,0,a),e.toString("utf8",t,a)}function Aa(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+"�":t}function Ta(e,t){if((e.length-t)%2===0){var r=e.toString("utf16le",t);if(r){var 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 Ia(e){var t=e&&e.length?this.write(e):"";if(this.lastNeed){var r=this.lastTotal-this.lastNeed;return t+this.lastChar.toString("utf16le",0,r)}return t}function ka(e,t){var r=(e.length-t)%3;return r===0?e.toString("base64",t):(this.lastNeed=3-r,this.lastTotal=3,r===1?this.lastChar[0]=e[e.length-1]:(this.lastChar[0]=e[e.length-2],this.lastChar[1]=e[e.length-1]),e.toString("base64",t,e.length-r))}function Ca(e){var t=e&&e.length?this.write(e):"";return this.lastNeed?t+this.lastChar.toString("base64",0,3-this.lastNeed):t}function Oa(e){return e.toString(this.encoding)}function La(e){return e&&e.length?this.write(e):""}var Qr=Ze.codes.ERR_STREAM_PREMATURE_CLOSE;function Ma(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 Pa(){}function Fa(e){return e.setHeader&&typeof e.abort=="function"}function qn(e,t,r){if(typeof t=="function")return qn(e,null,t);t||(t={}),r=Ma(r||Pa);var a=t.readable||t.readable!==!1&&e.readable,o=t.writable||t.writable!==!1&&e.writable,f=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)},A=function(){e.req.on("finish",u)};return Fa(e)?(e.on("complete",u),e.on("abort",v),e.req?A():e.on("request",A)):o&&!e._writableState&&(e.on("end",f),e.on("close",f)),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",A),e.req&&e.req.removeListener("finish",u),e.removeListener("end",f),e.removeListener("close",f),e.removeListener("finish",u),e.removeListener("end",w),e.removeListener("error",m),e.removeListener("close",v)}}var Fr=qn,lr,Xr;function Na(){if(Xr)return lr;Xr=1;var e;function t(P,M,N){return M=r(M),M in P?Object.defineProperty(P,M,{value:N,enumerable:!0,configurable:!0,writable:!0}):P[M]=N,P}function r(P){var M=a(P,"string");return typeof M=="symbol"?M:String(M)}function a(P,M){if(typeof P!="object"||P===null)return P;var N=P[Symbol.toPrimitive];if(N!==void 0){var E=N.call(P,M||"default");if(typeof E!="object")return E;throw new TypeError("@@toPrimitive must return a primitive value.")}return(M==="string"?String:Number)(P)}var o=Fr,f=Symbol("lastResolve"),c=Symbol("lastReject"),u=Symbol("error"),p=Symbol("ended"),w=Symbol("lastPromise"),m=Symbol("handlePromise"),v=Symbol("stream");function A(P,M){return{value:P,done:M}}function k(P){var M=P[f];if(M!==null){var N=P[v].read();N!==null&&(P[w]=null,P[f]=null,P[c]=null,M(A(N,!1)))}}function R(P){process.nextTick(k,P)}function C(P,M){return function(N,E){P.then(function(){if(M[p]){N(A(void 0,!0));return}M[m](N,E)},E)}}var S=Object.getPrototypeOf(function(){}),I=Object.setPrototypeOf((e={get stream(){return this[v]},next:function(){var M=this,N=this[u];if(N!==null)return Promise.reject(N);if(this[p])return Promise.resolve(A(void 0,!0));if(this[v].destroyed)return new Promise(function($,ne){process.nextTick(function(){M[u]?ne(M[u]):$(A(void 0,!0))})});var E=this[w],j;if(E)j=new Promise(C(E,this));else{var D=this[v].read();if(D!==null)return Promise.resolve(A(D,!1));j=new Promise(this[m])}return this[w]=j,j}},t(e,Symbol.asyncIterator,function(){return this}),t(e,"return",function(){var M=this;return new Promise(function(N,E){M[v].destroy(null,function(j){if(j){E(j);return}N(A(void 0,!0))})})}),e),S),O=function(M){var N,E=Object.create(I,(N={},t(N,v,{value:M,writable:!0}),t(N,f,{value:null,writable:!0}),t(N,c,{value:null,writable:!0}),t(N,u,{value:null,writable:!0}),t(N,p,{value:M._readableState.endEmitted,writable:!0}),t(N,m,{value:function(D,$){var ne=E[v].read();ne?(E[w]=null,E[f]=null,E[c]=null,D(A(ne,!1))):(E[f]=D,E[c]=$)},writable:!0}),N));return E[w]=null,o(M,function(j){if(j&&j.code!=="ERR_STREAM_PREMATURE_CLOSE"){var D=E[c];D!==null&&(E[w]=null,E[f]=null,E[c]=null,D(j)),E[u]=j;return}var $=E[f];$!==null&&(E[w]=null,E[f]=null,E[c]=null,$(A(void 0,!0))),E[p]=!0}),M.on("readable",R.bind(null,E)),E};return lr=O,lr}var hr,Zr;function Da(){return Zr||(Zr=1,hr=function(){throw new Error("Readable.from is not available in the browser")}),hr}var dr,en;function Wn(){if(en)return dr;en=1,dr=$;var e;$.ReadableState=D,Nn.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 f(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=fa(),m=Un,v=Hn,A=v.getHighWaterMark,k=Ze.codes,R=k.ERR_INVALID_ARG_TYPE,C=k.ERR_STREAM_PUSH_AFTER_EOF,S=k.ERR_METHOD_NOT_IMPLEMENTED,I=k.ERR_STREAM_UNSHIFT_AFTER_END_EVENT,O,P,M;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 D(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=A(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&&(O||(O=$t.StringDecoder),this.decoder=new O(h.encoding),this.encoding=h.encoding)}function $(h){if(e=e||lt(),!(this instanceof $))return new $(h);var d=this instanceof e;this._readableState=new D(h,this,d),this.readable=!0,h&&(typeof h.read=="function"&&(this._read=h.read),typeof h.destroy=="function"&&(this._destroy=h.destroy)),r.call(this)}Object.defineProperty($.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState===void 0?!1:this._readableState.destroyed},set:function(d){this._readableState&&(this._readableState.destroyed=d)}}),$.prototype.destroy=m.destroy,$.prototype._undestroy=m.undestroy,$.prototype._destroy=function(h,d){d(h)},$.prototype.push=function(h,d){var 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,Je(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=f(d)),F)W.endEmitted?N(h,new I):Te(h,W,d,!0);else if(W.ended)N(h,new C);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){O||(O=$t.StringDecoder);var d=new O(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 ae=1073741824;function we(h){return h>=ae?h=ae:(h--,h|=h>>>1,h|=h>>>2,h|=h>>>4,h|=h>>>8,h|=h>>>16,h++),h}function me(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=we(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?T(this):Ie(this),null;if(h=me(h,d),h===0&&d.ended)return d.length===0&&T(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=me(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&&T(this)),Q!==null&&this.emit("data",Q),Q};function Je(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 S("_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(s,n){p("onunpipe"),s===B&&n&&n.hasUnpiped===!1&&(n.hasUnpiped=!0,rt())}function We(){p("onend"),h.end()}var tt=Y(B);h.on("drain",tt);var pt=!1;function rt(){p("cleanup"),h.removeListener("close",bt),h.removeListener("finish",Be),h.removeListener("drain",tt),h.removeListener("error",ze),h.removeListener("unpipe",G),B.removeListener("end",We),B.removeListener("end",Ye),B.removeListener("data",Ee),pt=!0,F.awaitDrain&&(!h._writableState||h._writableState.needDrain)&&tt()}B.on("data",Ee);function Ee(s){p("ondata");var n=h.write(s);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 ze(s){p("onerror",s),Ye(),h.removeListener("error",ze),t(h,"error")===0&&N(h,s)}j(h,"error",ze);function bt(){h.removeListener("finish",Be),Ye()}h.once("close",bt);function Be(){p("onfinish"),h.removeListener("close",bt),Ye()}h.once("finish",Be);function Ye(){p("unpipe"),B.unpipe(h)}return h.emit("pipe",B),F.flowing||(p("pipe resume"),B.resume()),h};function Y(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(xe,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 xe(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=Na()),P(this)}),Object.defineProperty($.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty($.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty($.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(d){this._readableState&&(this._readableState.flowing=d)}}),$._fromList=y,Object.defineProperty($.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}});function y(h,d){if(d.length===0)return null;var 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 T(h){var d=h._readableState;p("endReadable",d.endEmitted),d.endEmitted||(d.ended=!0,process.nextTick(U,d,h))}function U(h,d){if(p("endReadableNT",h.endEmitted,h.length),!h.endEmitted&&h.length===0&&(h.endEmitted=!0,d.readable=!1,d.emit("end"),h.autoDestroy)){var B=d._writableState;(!B||B.autoDestroy&&B.finished)&&d.destroy()}}typeof Symbol=="function"&&($.from=function(h,d){return M===void 0&&(M=Da()),M($,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 Kn=Ue,Gt=Ze.codes,Ua=Gt.ERR_METHOD_NOT_IMPLEMENTED,$a=Gt.ERR_MULTIPLE_CALLBACK,Ha=Gt.ERR_TRANSFORM_ALREADY_TRANSFORMING,ja=Gt.ERR_TRANSFORM_WITH_LENGTH_0,Vt=lt();be(Ue,Vt);function qa(e,t){var r=this._transformState;r.transforming=!1;var a=r.writecb;if(a===null)return this.emit("error",new $a);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 Ue(e){if(!(this instanceof Ue))return new Ue(e);Vt.call(this,e),this._transformState={afterTransform:qa.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,e&&(typeof e.transform=="function"&&(this._transform=e.transform),typeof e.flush=="function"&&(this._flush=e.flush)),this.on("prefinish",Wa)}function Wa(){var e=this;typeof this._flush=="function"&&!this._readableState.destroyed?this._flush(function(t,r){tn(e,t,r)}):tn(this,null,null)}Ue.prototype.push=function(e,t){return this._transformState.needTransform=!1,Vt.prototype.push.call(this,e,t)};Ue.prototype._transform=function(e,t,r){r(new Ua("_transform()"))};Ue.prototype._write=function(e,t,r){var 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)}};Ue.prototype._read=function(e){var t=this._transformState;t.writechunk!==null&&!t.transforming?(t.transforming=!0,this._transform(t.writechunk,t.writeencoding,t.afterTransform)):t.needTransform=!0};Ue.prototype._destroy=function(e,t){Vt.prototype._destroy.call(this,e,function(r){t(r)})};function tn(e,t,r){if(t)return e.emit("error",t);if(r!=null&&e.push(r),e._writableState.length)throw new ja;if(e._transformState.transforming)throw new Ha;return e.push(null)}var Ka=Rt,Gn=Kn;be(Rt,Gn);function Rt(e){if(!(this instanceof Rt))return new Rt(e);Gn.call(this,e)}Rt.prototype._transform=function(e,t,r){r(null,e)};var pr;function Ga(e){var t=!1;return function(){t||(t=!0,e.apply(void 0,arguments))}}var Vn=Ze.codes,Va=Vn.ERR_MISSING_ARGS,Ja=Vn.ERR_STREAM_DESTROYED;function rn(e){if(e)throw e}function za(e){return e.setHeader&&typeof e.abort=="function"}function Ya(e,t,r,a){a=Ga(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 f=!1;return function(c){if(!o&&!f){if(f=!0,za(e))return e.abort();if(typeof e.destroy=="function")return e.destroy();a(c||new Ja("pipe"))}}}function nn(e){e()}function Qa(e,t){return e.pipe(t)}function Xa(e){return!e.length||typeof e[e.length-1]!="function"?rn:e.pop()}function Za(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];var a=Xa(t);if(Array.isArray(t[0])&&(t=t[0]),t.length<2)throw new Va("streams");var o,f=t.map(function(c,u){var p=u<t.length-1,w=u>0;return Ya(c,p,w,function(m){o||(o=m),m&&f.forEach(nn),!p&&(f.forEach(nn),a(o))})});return t.reduce(Qa)}var eo=Za;(function(e,t){t=e.exports=Wn(),t.Stream=t,t.Readable=t,t.Writable=jn(),t.Duplex=lt(),t.Transform=Kn,t.PassThrough=Ka,t.finished=Fr,t.pipeline=eo})(Er,Er.exports);var to=Er.exports,Ht=ve.Buffer,Jn=to.Transform,ro=be;function no(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}ro(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(no(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 f=0,c=e.length*8;c>0;++f)this._length[f]+=c,c=this._length[f]/4294967296|0,c>0&&(this._length[f]-=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 zn=Ve,io=be,Yn=zn,ao=ve.Buffer,oo=new Array(16);function Jt(){Yn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878}io(Jt,Yn);Jt.prototype._update=function(){for(var e=oo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);var r=this._a,a=this._b,o=this._c,f=this._d;r=ue(r,a,o,f,e[0],3614090360,7),f=ue(f,r,a,o,e[1],3905402710,12),o=ue(o,f,r,a,e[2],606105819,17),a=ue(a,o,f,r,e[3],3250441966,22),r=ue(r,a,o,f,e[4],4118548399,7),f=ue(f,r,a,o,e[5],1200080426,12),o=ue(o,f,r,a,e[6],2821735955,17),a=ue(a,o,f,r,e[7],4249261313,22),r=ue(r,a,o,f,e[8],1770035416,7),f=ue(f,r,a,o,e[9],2336552879,12),o=ue(o,f,r,a,e[10],4294925233,17),a=ue(a,o,f,r,e[11],2304563134,22),r=ue(r,a,o,f,e[12],1804603682,7),f=ue(f,r,a,o,e[13],4254626195,12),o=ue(o,f,r,a,e[14],2792965006,17),a=ue(a,o,f,r,e[15],1236535329,22),r=ce(r,a,o,f,e[1],4129170786,5),f=ce(f,r,a,o,e[6],3225465664,9),o=ce(o,f,r,a,e[11],643717713,14),a=ce(a,o,f,r,e[0],3921069994,20),r=ce(r,a,o,f,e[5],3593408605,5),f=ce(f,r,a,o,e[10],38016083,9),o=ce(o,f,r,a,e[15],3634488961,14),a=ce(a,o,f,r,e[4],3889429448,20),r=ce(r,a,o,f,e[9],568446438,5),f=ce(f,r,a,o,e[14],3275163606,9),o=ce(o,f,r,a,e[3],4107603335,14),a=ce(a,o,f,r,e[8],1163531501,20),r=ce(r,a,o,f,e[13],2850285829,5),f=ce(f,r,a,o,e[2],4243563512,9),o=ce(o,f,r,a,e[7],1735328473,14),a=ce(a,o,f,r,e[12],2368359562,20),r=le(r,a,o,f,e[5],4294588738,4),f=le(f,r,a,o,e[8],2272392833,11),o=le(o,f,r,a,e[11],1839030562,16),a=le(a,o,f,r,e[14],4259657740,23),r=le(r,a,o,f,e[1],2763975236,4),f=le(f,r,a,o,e[4],1272893353,11),o=le(o,f,r,a,e[7],4139469664,16),a=le(a,o,f,r,e[10],3200236656,23),r=le(r,a,o,f,e[13],681279174,4),f=le(f,r,a,o,e[0],3936430074,11),o=le(o,f,r,a,e[3],3572445317,16),a=le(a,o,f,r,e[6],76029189,23),r=le(r,a,o,f,e[9],3654602809,4),f=le(f,r,a,o,e[12],3873151461,11),o=le(o,f,r,a,e[15],530742520,16),a=le(a,o,f,r,e[2],3299628645,23),r=he(r,a,o,f,e[0],4096336452,6),f=he(f,r,a,o,e[7],1126891415,10),o=he(o,f,r,a,e[14],2878612391,15),a=he(a,o,f,r,e[5],4237533241,21),r=he(r,a,o,f,e[12],1700485571,6),f=he(f,r,a,o,e[3],2399980690,10),o=he(o,f,r,a,e[10],4293915773,15),a=he(a,o,f,r,e[1],2240044497,21),r=he(r,a,o,f,e[8],1873313359,6),f=he(f,r,a,o,e[15],4264355552,10),o=he(o,f,r,a,e[6],2734768916,15),a=he(a,o,f,r,e[13],1309151649,21),r=he(r,a,o,f,e[4],4149444226,6),f=he(f,r,a,o,e[11],3174756917,10),o=he(o,f,r,a,e[2],718787259,15),a=he(a,o,f,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+f|0};Jt.prototype._digest=function(){this._block[this._blockOffset++]=128,this._blockOffset>56&&(this._block.fill(0,this._blockOffset,64),this._update(),this._blockOffset=0),this._block.fill(0,this._blockOffset,56),this._block.writeUInt32LE(this._length[0],56),this._block.writeUInt32LE(this._length[1],60),this._update();var e=ao.allocUnsafe(16);return e.writeInt32LE(this._a,0),e.writeInt32LE(this._b,4),e.writeInt32LE(this._c,8),e.writeInt32LE(this._d,12),e};function zt(e,t){return e<<t|e>>>32-t}function ue(e,t,r,a,o,f,c){return zt(e+(t&r|~t&a)+o+f|0,c)+t|0}function ce(e,t,r,a,o,f,c){return zt(e+(t&a|r&~a)+o+f|0,c)+t|0}function le(e,t,r,a,o,f,c){return zt(e+(t^r^a)+o+f|0,c)+t|0}function he(e,t,r,a,o,f,c){return zt(e+(r^(t|~a))+o+f|0,c)+t|0}var so=Jt,br=ht.Buffer,fo=be,Qn=zn,uo=new Array(16),gt=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8,3,10,14,4,9,15,8,1,2,7,0,6,13,11,5,12,1,9,11,10,0,8,12,4,13,3,7,15,14,5,6,2,4,0,5,9,7,12,2,10,14,1,3,8,11,6,15,13],wt=[5,14,7,0,9,2,11,4,13,6,15,8,1,10,3,12,6,11,3,7,0,13,5,10,14,15,8,12,4,9,1,2,15,5,1,3,7,14,6,9,11,8,12,2,10,0,4,13,8,6,4,1,3,11,15,0,5,12,2,13,9,7,10,14,12,15,10,4,1,5,8,7,6,2,13,14,0,3,9,11],mt=[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8,7,6,8,13,11,9,7,15,7,12,15,9,11,7,13,12,11,13,6,7,14,9,13,15,14,8,13,6,5,12,7,5,11,12,14,15,14,15,9,8,9,14,5,6,8,6,5,12,9,15,5,11,6,8,13,12,5,12,13,14,11,8,5,6],vt=[8,9,9,11,13,15,15,5,7,7,8,11,14,14,12,6,9,13,15,7,12,8,9,11,7,7,12,7,6,15,13,11,9,7,15,11,8,6,6,14,12,13,5,14,13,13,7,5,15,5,8,11,14,14,6,14,6,9,12,9,12,5,15,8,8,5,12,9,12,5,14,6,8,13,6,5,15,13,11,11],xt=[0,1518500249,1859775393,2400959708,2840853838],Et=[1352829926,1548603684,1836072691,2053994217,0];function Yt(){Qn.call(this,64),this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520}fo(Yt,Qn);Yt.prototype._update=function(){for(var e=uo,t=0;t<16;++t)e[t]=this._block.readInt32LE(t*4);for(var r=this._a|0,a=this._b|0,o=this._c|0,f=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,A=0;A<80;A+=1){var k,R;A<16?(k=an(r,a,o,f,c,e[gt[A]],xt[0],mt[A]),R=un(u,p,w,m,v,e[wt[A]],Et[0],vt[A])):A<32?(k=on(r,a,o,f,c,e[gt[A]],xt[1],mt[A]),R=fn(u,p,w,m,v,e[wt[A]],Et[1],vt[A])):A<48?(k=sn(r,a,o,f,c,e[gt[A]],xt[2],mt[A]),R=sn(u,p,w,m,v,e[wt[A]],Et[2],vt[A])):A<64?(k=fn(r,a,o,f,c,e[gt[A]],xt[3],mt[A]),R=on(u,p,w,m,v,e[wt[A]],Et[3],vt[A])):(k=un(r,a,o,f,c,e[gt[A]],xt[4],mt[A]),R=an(u,p,w,m,v,e[wt[A]],Et[4],vt[A])),r=c,c=f,f=Xe(o,10),o=a,a=k,u=v,v=m,m=Xe(w,10),w=p,p=R}var C=this._b+o+m|0;this._b=this._c+f+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=C};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 Xe(e,t){return e<<t|e>>>32-t}function an(e,t,r,a,o,f,c,u){return Xe(e+(t^r^a)+f+c|0,u)+o|0}function on(e,t,r,a,o,f,c,u){return Xe(e+(t&r|~t&a)+f+c|0,u)+o|0}function sn(e,t,r,a,o,f,c,u){return Xe(e+((t|~r)^a)+f+c|0,u)+o|0}function fn(e,t,r,a,o,f,c,u){return Xe(e+(t&a|r&~a)+f+c|0,u)+o|0}function un(e,t,r,a,o,f,c,u){return Xe(e+(t^(r|~a))+f+c|0,u)+o|0}var co=Yt,Xn={exports:{}},Zn=ve.Buffer;function Qt(e,t){this._block=Zn.alloc(e),this._finalSize=t,this._blockSize=e,this._len=0}Qt.prototype.update=function(e,t){typeof e=="string"&&(t=t||"utf8",e=Zn.from(e,t));for(var r=this._block,a=this._blockSize,o=e.length,f=this._len,c=0;c<o;){for(var u=f%a,p=Math.min(o-c,a-u),w=0;w<p;w++)r[u+w]=e[c+w];f+=p,c+=p,f%a===0&&this._update(r)}return this._len+=o,this};Qt.prototype.digest=function(e){var t=this._len%this._blockSize;this._block[t]=128,this._block.fill(0,t+1),t>=this._finalSize&&(this._update(this._block),this._block.fill(0));var r=this._len*8;if(r<=4294967295)this._block.writeUInt32BE(r,this._blockSize-4);else{var 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 f=this._hash();return e?f.toString(e):f};Qt.prototype._update=function(){throw new Error("_update must be implemented by subclass")};var dt=Qt,lo=be,ei=dt,ho=ve.Buffer,po=[1518500249,1859775393,-1894007588,-899497514],bo=new Array(80);function Tt(){this.init(),this._w=bo,ei.call(this,64,56)}lo(Tt,ei);Tt.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function yo(e){return e<<5|e>>>27}function _o(e){return e<<30|e>>>2}function go(e,t,r,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,f=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=yo(r)+go(w,a,o,f)+c+t[p]+po[w]|0;c=f,f=o,o=_o(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=f+this._d|0,this._e=c+this._e|0};Tt.prototype._hash=function(){var e=ho.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var wo=Tt,mo=be,ti=dt,vo=ve.Buffer,xo=[1518500249,1859775393,-1894007588,-899497514],Eo=new Array(80);function It(){this.init(),this._w=Eo,ti.call(this,64,56)}mo(It,ti);It.prototype.init=function(){return this._a=1732584193,this._b=4023233417,this._c=2562383102,this._d=271733878,this._e=3285377520,this};function Bo(e){return e<<1|e>>>31}function Ro(e){return e<<5|e>>>27}function So(e){return e<<30|e>>>2}function Ao(e,t,r,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,f=this._d|0,c=this._e|0,u=0;u<16;++u)t[u]=e.readInt32BE(u*4);for(;u<80;++u)t[u]=Bo(t[u-3]^t[u-8]^t[u-14]^t[u-16]);for(var p=0;p<80;++p){var w=~~(p/20),m=Ro(r)+Ao(w,a,o,f)+c+t[p]+xo[w]|0;c=f,f=o,o=So(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=f+this._d|0,this._e=c+this._e|0};It.prototype._hash=function(){var e=vo.allocUnsafe(20);return e.writeInt32BE(this._a|0,0),e.writeInt32BE(this._b|0,4),e.writeInt32BE(this._c|0,8),e.writeInt32BE(this._d|0,12),e.writeInt32BE(this._e|0,16),e};var To=It,Io=be,ri=dt,ko=ve.Buffer,Co=[1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298],Oo=new Array(64);function kt(){this.init(),this._w=Oo,ri.call(this,64,56)}Io(kt,ri);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 Lo(e,t,r){return r^e&(t^r)}function Mo(e,t,r){return e&t|r&(e|t)}function Po(e){return(e>>>2|e<<30)^(e>>>13|e<<19)^(e>>>22|e<<10)}function Fo(e){return(e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7)}function No(e){return(e>>>7|e<<25)^(e>>>18|e<<14)^e>>>3}function Do(e){return(e>>>17|e<<15)^(e>>>19|e<<13)^e>>>10}kt.prototype._update=function(e){for(var t=this._w,r=this._a|0,a=this._b|0,o=this._c|0,f=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]+No(t[m-15])+t[m-16]|0;for(var v=0;v<64;++v){var A=w+Fo(c)+Lo(c,u,p)+Co[v]+t[v]|0,k=Po(r)+Mo(r,a,o)|0;w=p,p=u,u=c,c=f+A|0,f=o,o=a,a=r,r=A+k|0}this._a=r+this._a|0,this._b=a+this._b|0,this._c=o+this._c|0,this._d=f+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=ko.allocUnsafe(32);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e.writeInt32BE(this._h,28),e};var ni=kt,Uo=be,$o=ni,Ho=dt,jo=ve.Buffer,qo=new Array(64);function Xt(){this.init(),this._w=qo,Ho.call(this,64,56)}Uo(Xt,$o);Xt.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};Xt.prototype._hash=function(){var e=jo.allocUnsafe(28);return e.writeInt32BE(this._a,0),e.writeInt32BE(this._b,4),e.writeInt32BE(this._c,8),e.writeInt32BE(this._d,12),e.writeInt32BE(this._e,16),e.writeInt32BE(this._f,20),e.writeInt32BE(this._g,24),e};var Wo=Xt,Ko=be,ii=dt,Go=ve.Buffer,cn=[1116352408,3609767458,1899447441,602891725,3049323471,3964484399,3921009573,2173295548,961987163,4081628472,1508970993,3053834265,2453635748,2937671579,2870763221,3664609560,3624381080,2734883394,310598401,1164996542,607225278,1323610764,1426881987,3590304994,1925078388,4068182383,2162078206,991336113,2614888103,633803317,3248222580,3479774868,3835390401,2666613458,4022224774,944711139,264347078,2341262773,604807628,2007800933,770255983,1495990901,1249150122,1856431235,1555081692,3175218132,1996064986,2198950837,2554220882,3999719339,2821834349,766784016,2952996808,2566594879,3210313671,3203337956,3336571891,1034457026,3584528711,2466948901,113926993,3758326383,338241895,168717936,666307205,1188179964,773529912,1546045734,1294757372,1522805485,1396182291,2643833823,1695183700,2343527390,1986661051,1014477480,2177026350,1206759142,2456956037,344077627,2730485921,1290863460,2820302411,3158454273,3259730800,3505952657,3345764771,106217008,3516065817,3606008344,3600352804,1432725776,4094571909,1467031594,275423344,851169720,430227734,3100823752,506948616,1363258195,659060556,3750685593,883997877,3785050280,958139571,3318307427,1322822218,3812723403,1537002063,2003034995,1747873779,3602036899,1955562222,1575990012,2024104815,1125592928,2227730452,2716904306,2361852424,442776044,2428436474,593698344,2756734187,3733110249,3204031479,2999351573,3329325298,3815920427,3391569614,3928383900,3515267271,566280711,3940187606,3454069534,4118630271,4000239992,116418474,1914138554,174292421,2731055270,289380356,3203993006,460393269,320620315,685471733,587496836,852142971,1086792851,1017036298,365543100,1126000580,2618297676,1288033470,3409855158,1501505948,4234509866,1607167915,987167468,1816402316,1246189591],Vo=new Array(160);function Ct(){this.init(),this._w=Vo,ii.call(this,128,112)}Ko(Ct,ii);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 ln(e,t,r){return r^e&(t^r)}function hn(e,t,r){return e&t|r&(e|t)}function dn(e,t){return(e>>>28|t<<4)^(t>>>2|e<<30)^(t>>>7|e<<25)}function pn(e,t){return(e>>>14|t<<18)^(e>>>18|t<<14)^(t>>>9|e<<23)}function Jo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^e>>>7}function zo(e,t){return(e>>>1|t<<31)^(e>>>8|t<<24)^(e>>>7|t<<25)}function Yo(e,t){return(e>>>19|t<<13)^(t>>>29|e<<3)^e>>>6}function 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,f=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,A=this._cl|0,k=this._dl|0,R=this._el|0,C=this._fl|0,S=this._gl|0,I=this._hl|0,O=0;O<32;O+=2)t[O]=e.readInt32BE(O*4),t[O+1]=e.readInt32BE(O*4+4);for(;O<160;O+=2){var P=t[O-30],M=t[O-15*2+1],N=Jo(P,M),E=zo(M,P);P=t[O-2*2],M=t[O-2*2+1];var j=Yo(P,M),D=Qo(M,P),$=t[O-7*2],ne=t[O-7*2+1],Te=t[O-16*2],$e=t[O-16*2+1],ae=E+ne|0,we=N+$+se(ae,E)|0;ae=ae+D|0,we=we+j+se(ae,D)|0,ae=ae+$e|0,we=we+Te+se(ae,$e)|0,t[O]=we,t[O+1]=ae}for(var me=0;me<160;me+=2){we=t[me],ae=t[me+1];var Je=hn(r,a,o),Ie=hn(m,v,A),He=dn(r,m),ke=dn(m,r),je=pn(c,R),Y=pn(R,c),ie=cn[me],xe=cn[me+1],qe=ln(c,u,p),Me=ln(R,C,S),_=I+Y|0,y=w+je+se(_,I)|0;_=_+Me|0,y=y+qe+se(_,Me)|0,_=_+xe|0,y=y+ie+se(_,xe)|0,_=_+ae|0,y=y+we+se(_,ae)|0;var T=ke+Ie|0,U=He+Je+se(T,ke)|0;w=p,I=S,p=u,S=C,u=c,C=R,R=k+_|0,c=f+y+se(R,k)|0,f=o,k=A,o=a,A=v,a=r,v=m,m=_+T|0,r=y+U+se(m,_)|0}this._al=this._al+m|0,this._bl=this._bl+v|0,this._cl=this._cl+A|0,this._dl=this._dl+k|0,this._el=this._el+R|0,this._fl=this._fl+C|0,this._gl=this._gl+S|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,A)|0,this._dh=this._dh+f+se(this._dl,k)|0,this._eh=this._eh+c+se(this._el,R)|0,this._fh=this._fh+u+se(this._fl,C)|0,this._gh=this._gh+p+se(this._gl,S)|0,this._hh=this._hh+w+se(this._hl,I)|0};Ct.prototype._hash=function(){var e=Go.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 ai=Ct,Xo=be,Zo=ai,es=dt,ts=ve.Buffer,rs=new Array(160);function Zt(){this.init(),this._w=rs,es.call(this,128,112)}Xo(Zt,Zo);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=ts.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 ns=Zt,et=Xn.exports=function(t){t=t.toLowerCase();var r=et[t];if(!r)throw new Error(t+" is not supported (we accept pull requests)");return new r};et.sha=wo;et.sha1=To;et.sha224=Wo;et.sha256=ni;et.sha384=ns;et.sha512=ai;var is=Xn.exports,oi=ve.Buffer,si=Mr.Transform,as=$t.StringDecoder,os=be;function Ce(e){si.call(this),this.hashMode=typeof e=="string",this.hashMode?this[e]=this._finalOrDigest:this.final=this._finalOrDigest,this._final&&(this.__final=this._final,this._final=null),this._decoder=null,this._encoding=null}os(Ce,si);Ce.prototype.update=function(e,t,r){typeof e=="string"&&(e=oi.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()||oi.alloc(0);return e&&(t=this._toString(t,e,!0)),t};Ce.prototype._toString=function(e,t,r){if(this._decoder||(this._decoder=new as(t),this._encoding=t),this._encoding!==t)throw new Error("can't switch encodings");var a=this._decoder.write(e);return r&&(a+=this._decoder.end()),a};var ss=Ce,fs=be,us=so,cs=co,ls=is,fi=ss;function er(e){fi.call(this,"digest"),this._hash=e}fs(er,fi);er.prototype._update=function(e){this._hash.update(e)};er.prototype._final=function(){return this._hash.digest()};var hs=function(t){return t=t.toLowerCase(),t==="md5"?new us:t==="rmd160"||t==="ripemd160"?new cs:new er(ls(t))},Lt=ve.Buffer;function ds(e){if(e.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),r=0;r<t.length;r++)t[r]=255;for(var a=0;a<e.length;a++){var o=e.charAt(a),f=o.charCodeAt(0);if(t[f]!==255)throw new TypeError(o+" is ambiguous");t[f]=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(k){if((Array.isArray(k)||k instanceof Uint8Array)&&(k=Lt.from(k)),!Lt.isBuffer(k))throw new TypeError("Expected Buffer");if(k.length===0)return"";for(var R=0,C=0,S=0,I=k.length;S!==I&&k[S]===0;)S++,R++;for(var O=(I-S)*w+1>>>0,P=new Uint8Array(O);S!==I;){for(var M=k[S],N=0,E=O-1;(M!==0||N<C)&&E!==-1;E--,N++)M+=256*P[E]>>>0,P[E]=M%c>>>0,M=M/c>>>0;if(M!==0)throw new Error("Non-zero carry");C=N,S++}for(var j=O-C;j!==O&&P[j]===0;)j++;for(var D=u.repeat(R);j<O;++j)D+=e.charAt(P[j]);return D}function v(k){if(typeof k!="string")throw new TypeError("Expected String");if(k.length===0)return Lt.alloc(0);for(var R=0,C=0,S=0;k[R]===u;)C++,R++;for(var I=(k.length-R)*p+1>>>0,O=new Uint8Array(I);R<k.length;){var P=t[k.charCodeAt(R)];if(P===255)return;for(var M=0,N=I-1;(P!==0||M<S)&&N!==-1;N--,M++)P+=c*O[N]>>>0,O[N]=P%256>>>0,P=P/256>>>0;if(P!==0)throw new Error("Non-zero carry");S=M,R++}for(var E=I-S;E!==I&&O[E]===0;)E++;var j=Lt.allocUnsafe(C+(I-E));j.fill(0,0,C);for(var D=C;E!==I;)j[D++]=O[E++];return j}function A(k){var R=v(k);if(R)return R;throw new Error("Non-base"+c+" character")}return{encode:m,decodeUnsafe:v,decode:A}}var ps=ds,bs=ps,ys="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",_s=bs(ys),yr=_s,gs=ve.Buffer,ws=function(e){function t(f){var c=e(f);return yr.encode(gs.concat([f,c],f.length+4))}function r(f){var c=f.slice(0,-4),u=f.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(f){var c=yr.decodeUnsafe(f);if(c)return r(c)}function o(f){var c=yr.decode(f),u=r(c);if(!u)throw new Error("Invalid checksum");return u}return{encode:t,decode:o,decodeUnsafe:a}},bn=hs,ms=ws;function vs(e){var t=bn("sha256").update(e).digest();return bn("sha256").update(t).digest()}var xs=ms(vs),Rr=xs;function ui(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 Es(e,t){return ui(Rr.decode(e),t)}function Bs(e,t,r){return typeof e=="number"?Rr.encode(Sr(e,t,r)):Rr.encode(Sr(e.version,e.privateKey,e.compressed))}var Rs={decode:Es,decodeRaw:ui,encode:Bs,encodeRaw:Sr},tr={};Object.defineProperty(tr,"__esModule",{value:!0});tr.testEcc=void 0;const H=e=>Buffer.from(e,"hex");function Ss(e){z(e.isPoint(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(!e.isPoint(H("030000000000000000000000000000000000000000000000000000000000000005"))),z(e.isPrivate(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),z(!e.isPrivate(H("0000000000000000000000000000000000000000000000000000000000000000"))),z(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"))),z(!e.isPrivate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364142"))),z(Buffer.from(e.privateAdd(H("0000000000000000000000000000000000000000000000000000000000000001"),H("0000000000000000000000000000000000000000000000000000000000000000"))).equals(H("0000000000000000000000000000000000000000000000000000000000000001"))),z(e.privateAdd(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"),H("0000000000000000000000000000000000000000000000000000000000000003"))===null),z(Buffer.from(e.privateAdd(H("e211078564db65c3ce7704f08262b1f38f1ef412ad15b5ac2d76657a63b2c500"),H("b51fbb69051255d1becbd683de5848242a89c229348dd72896a87ada94ae8665"))).equals(H("9730c2ee69edbb958d42db7460bafa18fef9d955325aec99044c81c8282b0a24"))),z(Buffer.from(e.privateNegate(H("0000000000000000000000000000000000000000000000000000000000000001"))).equals(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))),z(Buffer.from(e.privateNegate(H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd036413e"))).equals(H("0000000000000000000000000000000000000000000000000000000000000003"))),z(Buffer.from(e.privateNegate(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("4eede1bf775995d70a494f0a7bb6bc11e0b8cccd41cce8009ab1132c8b0a3792"))),z(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(Buffer.from(e.pointCompress(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),z(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!0)).equals(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"))),z(Buffer.from(e.pointCompress(H("0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),!1)).equals(H("0479be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8"))),z(Buffer.from(e.pointFromScalar(H("b1121e4088a66a28f5b6b0f5844943ecd9f610196d7bb83b25214b60452c09af"))).equals(H("02b07ba9dca9523b7ef4bd97703d43d20399eb698e194704791a25ce77a400df99"))),z(e.xOnlyPointAddTweak(H("79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))===null);let t=e.xOnlyPointAddTweak(H("1617d38ed8d8657da4d4761e8057bc396ea9e4b9d29776d4be096016dbd2509b"),H("a8397a935f0dfceba6ba9618f6451ef4d80637abf4e6af2669fbc9de6a8fd2ac"));z(Buffer.from(t.xOnlyPubkey).equals(H("e478f99dab91052ab39a33ea35fd5e6e4933f4d28023cd597c9a1f6760346adf"))&&t.parity===1),t=e.xOnlyPointAddTweak(H("2c0b7cf95324a07d05398b240174dc0c2be444d96b159aa6c7f7b1e668680991"),H("823c3cd2142744b075a87eade7e1b8678ba308d566226a0056ca2b7a76f86b47")),z(Buffer.from(t.xOnlyPubkey).equals(H("9534f8dc8c6deda2dc007655981c78b49c5d96c778fbf363462a11ec9dfd948c"))&&t.parity===0),z(Buffer.from(e.sign(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140"))).equals(H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),z(e.verify(H("5e9f0a0d593efdcf78ac923bc3313e4e7d408d574354ee2b3288c0da9fbba6ed"),H("0379be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),H("54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5"))),e.signSchnorr&&z(Buffer.from(e.signSchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("c90fdaa22168c234c4c6628b80dc1cd129024e088a67cc74020bbea63b14e5c9"),H("c87aa53824b4d7ae2eb035a2b5bbbccc080e76cdc6d1692c4b0b62d798e6d906"))).equals(H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7"))),e.verifySchnorr&&z(e.verifySchnorr(H("7e2d58d8b3bcdf1abadec7829054f90dda9805aab56c77333024b9d0a508b75c"),H("dd308afec5777e13121fa72b9cc1b7cc0139715309b086c960e18fd969774eb8"),H("5831aaeed7b44bb74e5eab94ba9d4294c49bcf2a60728d8b4c200f50dd313c1bab745879a5ad954a72c45a91c3a51d3c7adea98d82f8481e0e1e03674a6f3fb7")))}tr.testEcc=Ss;function z(e){if(!e)throw new Error("ecc library invalid")}Object.defineProperty(ut,"__esModule",{value:!0});ut.ECPairFactory=ut.networks=void 0;const Ar=ct;ut.networks=Ar;const _e=xn,As=Zi,yn=Rs,Ts=tr,_r=_e.typeforce.maybe(_e.typeforce.compile({compressed:_e.maybe(_e.Boolean),network:_e.maybe(_e.Network)})),Is=e=>e.length===32?e:e.slice(1,33);function ks(e){(0,Ts.testEcc)(e);function t(u){return e.isPoint(u)}function r(u,p){if(_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=yn.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 f(u){_e.typeforce(_r,u),u===void 0&&(u={});const p=u.rng||As;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 yn.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 A=0;for(;m[0]>127;)A++,v.writeUIntLE(A,0,6),m=e.sign(p,this.__D,v);return Buffer.from(m)}}signSchnorr(p){if(!this.privateKey)throw new Error("Missing private key");if(!e.signSchnorr)throw new Error("signSchnorr not supported by ecc library");return Buffer.from(e.signSchnorr(p,this.privateKey))}verify(p,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=Is(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:f}}ut.ECPairFactory=ks;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.networks=e.ECPairFactory=e.default=void 0;var t=ut;Object.defineProperty(e,"default",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"ECPairFactory",{enumerable:!0,get:function(){return t.ECPairFactory}}),Object.defineProperty(e,"networks",{enumerable:!0,get:function(){return t.networks}})})(vn);class jt{constructor(t){this.privKey=t}static fromPrivKey(t){return new jt(L.trim0x(t))}static async fromWalletClient(t){if(!t.account)return L.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.0",Nonce:1n}});return L.Ok(new jt(L.trim0x(Ne.sha256(r))))}catch(r){return L.Err("Failed to initialize: "+r)}}getMasterPrivKey(){return this.privKey}generateSecret(t){const r=this.signMessage(t),a=Ne.sha256(pe.with0x(r)),o=Ne.sha256(a);return L.Ok({secret:a,secretHash:o})}signMessage(t){const r=vn.ECPairFactory(ft),a="Garden.fi"+t.toString(),o=Buffer.from(a,"utf8"),f=Ne.sha256(o),c=Buffer.from(L.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(L.trim0x(f),"hex")).toString("hex")}}class Cs{constructor(t){this.quoteUrl=new pe.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()}),f=await L.Fetcher.get(o);return f.error?L.Err(f.error):f.result?L.Ok(f.result):L.Err("GetQuote: Unexpected error, result is undefined")}catch(o){return L.Err("GetQuote:",String(o))}}async getAttestedQuote(t){try{const r=await L.Fetcher.post(this.quoteUrl.endpoint("/attested").toString(),{body:JSON.stringify(t),headers:{"Content-Type":"application/json"}});return r.error?L.Err(r.error):r.result?L.Ok(r.result):L.Err("GetAttestedQuote: Unexpected error, result is undefined")}catch(r){return console.log("error :",r),L.Err("GetAttestedQuote:",String(r))}}}exports.EvmRelay=mn;exports.Garden=Oi;exports.ParseOrderStatus=gn;exports.ParseSwapStatus=Ft;exports.Quote=Cs;exports.SecretManager=jt;exports.parseAction=wn;exports.switchOrAddNetwork=Ei;
|