@meshsdk/core 1.5.14 → 1.5.15
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/core.cjs +8 -1
- package/dist/core.js +2652 -1747
- package/dist/transaction/meshTxBuilder/meshTxBuilderCore.d.ts +1 -1
- package/package.json +2 -1
package/dist/core.cjs
CHANGED
|
@@ -1 +1,8 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const we=require("nanoid"),$e=require("@emurgo/cardano-serialization-lib-nodejs"),ze=require("axios"),Nt=require("bip39"),y=require("@emurgo/cardano-message-signing-nodejs"),Je=r=>r&&typeof r=="object"&&"default"in r?r:{default:r};function We(r){if(r&&r.__esModule)return r;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const s=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,s.get?s:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const n=We($e),tt=Je(ze),je=["testnet","preview","preprod","mainnet"],Be=r=>je.includes(r),nt={mem:7e6,steps:3e9},P={epoch:0,coinsPerUTxOSize:"4310",priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:"2000000",maxTxSize:16384,maxValSize:"5000",poolDeposit:"500000000",maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},Pt=2147483648,Y={V1:n.Language.new_plutus_v1(),V2:n.Language.new_plutus_v2()},V=56,Xe={CERT:n.RedeemerTag.new_cert(),MINT:n.RedeemerTag.new_mint(),REWARD:n.RedeemerTag.new_reward(),SPEND:n.RedeemerTag.new_spend()},Et={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Zt={ALONZO:n.TxBuilderConstants.plutus_alonzo_cost_models(),BABBAGE:(()=>{const r=n.Costmdls.new(),e=n.CostModel.new();Object.values({"addInteger-cpu-arguments-intercept":205665,"addInteger-cpu-arguments-slope":812,"addInteger-memory-arguments-intercept":1,"addInteger-memory-arguments-slope":1,"appendByteString-cpu-arguments-intercept":1e3,"appendByteString-cpu-arguments-slope":571,"appendByteString-memory-arguments-intercept":0,"appendByteString-memory-arguments-slope":1,"appendString-cpu-arguments-intercept":1e3,"appendString-cpu-arguments-slope":24177,"appendString-memory-arguments-intercept":4,"appendString-memory-arguments-slope":1,"bData-cpu-arguments":1e3,"bData-memory-arguments":32,"blake2b_256-cpu-arguments-intercept":117366,"blake2b_256-cpu-arguments-slope":10475,"blake2b_256-memory-arguments":4,"cekApplyCost-exBudgetCPU":23e3,"cekApplyCost-exBudgetMemory":100,"cekBuiltinCost-exBudgetCPU":23e3,"cekBuiltinCost-exBudgetMemory":100,"cekConstCost-exBudgetCPU":23e3,"cekConstCost-exBudgetMemory":100,"cekDelayCost-exBudgetCPU":23e3,"cekDelayCost-exBudgetMemory":100,"cekForceCost-exBudgetCPU":23e3,"cekForceCost-exBudgetMemory":100,"cekLamCost-exBudgetCPU":23e3,"cekLamCost-exBudgetMemory":100,"cekStartupCost-exBudgetCPU":100,"cekStartupCost-exBudgetMemory":100,"cekVarCost-exBudgetCPU":23e3,"cekVarCost-exBudgetMemory":100,"chooseData-cpu-arguments":19537,"chooseData-memory-arguments":32,"chooseList-cpu-arguments":175354,"chooseList-memory-arguments":32,"chooseUnit-cpu-arguments":46417,"chooseUnit-memory-arguments":4,"consByteString-cpu-arguments-intercept":221973,"consByteString-cpu-arguments-slope":511,"consByteString-memory-arguments-intercept":0,"consByteString-memory-arguments-slope":1,"constrData-cpu-arguments":89141,"constrData-memory-arguments":32,"decodeUtf8-cpu-arguments-intercept":497525,"decodeUtf8-cpu-arguments-slope":14068,"decodeUtf8-memory-arguments-intercept":4,"decodeUtf8-memory-arguments-slope":2,"divideInteger-cpu-arguments-constant":196500,"divideInteger-cpu-arguments-model-arguments-intercept":453240,"divideInteger-cpu-arguments-model-arguments-slope":220,"divideInteger-memory-arguments-intercept":0,"divideInteger-memory-arguments-minimum":1,"divideInteger-memory-arguments-slope":1,"encodeUtf8-cpu-arguments-intercept":1e3,"encodeUtf8-cpu-arguments-slope":28662,"encodeUtf8-memory-arguments-intercept":4,"encodeUtf8-memory-arguments-slope":2,"equalsByteString-cpu-arguments-constant":245e3,"equalsByteString-cpu-arguments-intercept":216773,"equalsByteString-cpu-arguments-slope":62,"equalsByteString-memory-arguments":1,"equalsData-cpu-arguments-intercept":1060367,"equalsData-cpu-arguments-slope":12586,"equalsData-memory-arguments":1,"equalsInteger-cpu-arguments-intercept":208512,"equalsInteger-cpu-arguments-slope":421,"equalsInteger-memory-arguments":1,"equalsString-cpu-arguments-constant":187e3,"equalsString-cpu-arguments-intercept":1e3,"equalsString-cpu-arguments-slope":52998,"equalsString-memory-arguments":1,"fstPair-cpu-arguments":80436,"fstPair-memory-arguments":32,"headList-cpu-arguments":43249,"headList-memory-arguments":32,"iData-cpu-arguments":1e3,"iData-memory-arguments":32,"ifThenElse-cpu-arguments":80556,"ifThenElse-memory-arguments":1,"indexByteString-cpu-arguments":57667,"indexByteString-memory-arguments":4,"lengthOfByteString-cpu-arguments":1e3,"lengthOfByteString-memory-arguments":10,"lessThanByteString-cpu-arguments-intercept":197145,"lessThanByteString-cpu-arguments-slope":156,"lessThanByteString-memory-arguments":1,"lessThanEqualsByteString-cpu-arguments-intercept":197145,"lessThanEqualsByteString-cpu-arguments-slope":156,"lessThanEqualsByteString-memory-arguments":1,"lessThanEqualsInteger-cpu-arguments-intercept":204924,"lessThanEqualsInteger-cpu-arguments-slope":473,"lessThanEqualsInteger-memory-arguments":1,"lessThanInteger-cpu-arguments-intercept":208896,"lessThanInteger-cpu-arguments-slope":511,"lessThanInteger-memory-arguments":1,"listData-cpu-arguments":52467,"listData-memory-arguments":32,"mapData-cpu-arguments":64832,"mapData-memory-arguments":32,"mkCons-cpu-arguments":65493,"mkCons-memory-arguments":32,"mkNilData-cpu-arguments":22558,"mkNilData-memory-arguments":32,"mkNilPairData-cpu-arguments":16563,"mkNilPairData-memory-arguments":32,"mkPairData-cpu-arguments":76511,"mkPairData-memory-arguments":32,"modInteger-cpu-arguments-constant":196500,"modInteger-cpu-arguments-model-arguments-intercept":453240,"modInteger-cpu-arguments-model-arguments-slope":220,"modInteger-memory-arguments-intercept":0,"modInteger-memory-arguments-minimum":1,"modInteger-memory-arguments-slope":1,"multiplyInteger-cpu-arguments-intercept":69522,"multiplyInteger-cpu-arguments-slope":11687,"multiplyInteger-memory-arguments-intercept":0,"multiplyInteger-memory-arguments-slope":1,"nullList-cpu-arguments":60091,"nullList-memory-arguments":32,"quotientInteger-cpu-arguments-constant":196500,"quotientInteger-cpu-arguments-model-arguments-intercept":453240,"quotientInteger-cpu-arguments-model-arguments-slope":220,"quotientInteger-memory-arguments-intercept":0,"quotientInteger-memory-arguments-minimum":1,"quotientInteger-memory-arguments-slope":1,"remainderInteger-cpu-arguments-constant":196500,"remainderInteger-cpu-arguments-model-arguments-intercept":453240,"remainderInteger-cpu-arguments-model-arguments-slope":220,"remainderInteger-memory-arguments-intercept":0,"remainderInteger-memory-arguments-minimum":1,"remainderInteger-memory-arguments-slope":1,"sha2_256-cpu-arguments-intercept":806990,"sha2_256-cpu-arguments-slope":30482,"sha2_256-memory-arguments":4,"sha3_256-cpu-arguments-intercept":1927926,"sha3_256-cpu-arguments-slope":82523,"sha3_256-memory-arguments":4,"sliceByteString-cpu-arguments-intercept":265318,"sliceByteString-cpu-arguments-slope":0,"sliceByteString-memory-arguments-intercept":4,"sliceByteString-memory-arguments-slope":0,"sndPair-cpu-arguments":85931,"sndPair-memory-arguments":32,"subtractInteger-cpu-arguments-intercept":205665,"subtractInteger-cpu-arguments-slope":812,"subtractInteger-memory-arguments-intercept":1,"subtractInteger-memory-arguments-slope":1,"tailList-cpu-arguments":41182,"tailList-memory-arguments":32,"trace-cpu-arguments":212342,"trace-memory-arguments":32,"unBData-cpu-arguments":31220,"unBData-memory-arguments":32,"unConstrData-cpu-arguments":32696,"unConstrData-memory-arguments":32,"unIData-cpu-arguments":43357,"unIData-memory-arguments":32,"unListData-cpu-arguments":32247,"unListData-memory-arguments":32,"unMapData-cpu-arguments":38314,"unMapData-memory-arguments":32,"verifyEd25519Signature-cpu-arguments-intercept":57996947,"verifyEd25519Signature-cpu-arguments-slope":18975,"verifyEd25519Signature-memory-arguments":10}).forEach((s,a)=>e.set(a,n.Int.new_i32(s)));const t=n.CostModel.new();return Object.values({"addInteger-cpu-arguments-intercept":205665,"addInteger-cpu-arguments-slope":812,"addInteger-memory-arguments-intercept":1,"addInteger-memory-arguments-slope":1,"appendByteString-cpu-arguments-intercept":1e3,"appendByteString-cpu-arguments-slope":571,"appendByteString-memory-arguments-intercept":0,"appendByteString-memory-arguments-slope":1,"appendString-cpu-arguments-intercept":1e3,"appendString-cpu-arguments-slope":24177,"appendString-memory-arguments-intercept":4,"appendString-memory-arguments-slope":1,"bData-cpu-arguments":1e3,"bData-memory-arguments":32,"blake2b_256-cpu-arguments-intercept":117366,"blake2b_256-cpu-arguments-slope":10475,"blake2b_256-memory-arguments":4,"cekApplyCost-exBudgetCPU":23e3,"cekApplyCost-exBudgetMemory":100,"cekBuiltinCost-exBudgetCPU":23e3,"cekBuiltinCost-exBudgetMemory":100,"cekConstCost-exBudgetCPU":23e3,"cekConstCost-exBudgetMemory":100,"cekDelayCost-exBudgetCPU":23e3,"cekDelayCost-exBudgetMemory":100,"cekForceCost-exBudgetCPU":23e3,"cekForceCost-exBudgetMemory":100,"cekLamCost-exBudgetCPU":23e3,"cekLamCost-exBudgetMemory":100,"cekStartupCost-exBudgetCPU":100,"cekStartupCost-exBudgetMemory":100,"cekVarCost-exBudgetCPU":23e3,"cekVarCost-exBudgetMemory":100,"chooseData-cpu-arguments":19537,"chooseData-memory-arguments":32,"chooseList-cpu-arguments":175354,"chooseList-memory-arguments":32,"chooseUnit-cpu-arguments":46417,"chooseUnit-memory-arguments":4,"consByteString-cpu-arguments-intercept":221973,"consByteString-cpu-arguments-slope":511,"consByteString-memory-arguments-intercept":0,"consByteString-memory-arguments-slope":1,"constrData-cpu-arguments":89141,"constrData-memory-arguments":32,"decodeUtf8-cpu-arguments-intercept":497525,"decodeUtf8-cpu-arguments-slope":14068,"decodeUtf8-memory-arguments-intercept":4,"decodeUtf8-memory-arguments-slope":2,"divideInteger-cpu-arguments-constant":196500,"divideInteger-cpu-arguments-model-arguments-intercept":453240,"divideInteger-cpu-arguments-model-arguments-slope":220,"divideInteger-memory-arguments-intercept":0,"divideInteger-memory-arguments-minimum":1,"divideInteger-memory-arguments-slope":1,"encodeUtf8-cpu-arguments-intercept":1e3,"encodeUtf8-cpu-arguments-slope":28662,"encodeUtf8-memory-arguments-intercept":4,"encodeUtf8-memory-arguments-slope":2,"equalsByteString-cpu-arguments-constant":245e3,"equalsByteString-cpu-arguments-intercept":216773,"equalsByteString-cpu-arguments-slope":62,"equalsByteString-memory-arguments":1,"equalsData-cpu-arguments-intercept":1060367,"equalsData-cpu-arguments-slope":12586,"equalsData-memory-arguments":1,"equalsInteger-cpu-arguments-intercept":208512,"equalsInteger-cpu-arguments-slope":421,"equalsInteger-memory-arguments":1,"equalsString-cpu-arguments-constant":187e3,"equalsString-cpu-arguments-intercept":1e3,"equalsString-cpu-arguments-slope":52998,"equalsString-memory-arguments":1,"fstPair-cpu-arguments":80436,"fstPair-memory-arguments":32,"headList-cpu-arguments":43249,"headList-memory-arguments":32,"iData-cpu-arguments":1e3,"iData-memory-arguments":32,"ifThenElse-cpu-arguments":80556,"ifThenElse-memory-arguments":1,"indexByteString-cpu-arguments":57667,"indexByteString-memory-arguments":4,"lengthOfByteString-cpu-arguments":1e3,"lengthOfByteString-memory-arguments":10,"lessThanByteString-cpu-arguments-intercept":197145,"lessThanByteString-cpu-arguments-slope":156,"lessThanByteString-memory-arguments":1,"lessThanEqualsByteString-cpu-arguments-intercept":197145,"lessThanEqualsByteString-cpu-arguments-slope":156,"lessThanEqualsByteString-memory-arguments":1,"lessThanEqualsInteger-cpu-arguments-intercept":204924,"lessThanEqualsInteger-cpu-arguments-slope":473,"lessThanEqualsInteger-memory-arguments":1,"lessThanInteger-cpu-arguments-intercept":208896,"lessThanInteger-cpu-arguments-slope":511,"lessThanInteger-memory-arguments":1,"listData-cpu-arguments":52467,"listData-memory-arguments":32,"mapData-cpu-arguments":64832,"mapData-memory-arguments":32,"mkCons-cpu-arguments":65493,"mkCons-memory-arguments":32,"mkNilData-cpu-arguments":22558,"mkNilData-memory-arguments":32,"mkNilPairData-cpu-arguments":16563,"mkNilPairData-memory-arguments":32,"mkPairData-cpu-arguments":76511,"mkPairData-memory-arguments":32,"modInteger-cpu-arguments-constant":196500,"modInteger-cpu-arguments-model-arguments-intercept":453240,"modInteger-cpu-arguments-model-arguments-slope":220,"modInteger-memory-arguments-intercept":0,"modInteger-memory-arguments-minimum":1,"modInteger-memory-arguments-slope":1,"multiplyInteger-cpu-arguments-intercept":69522,"multiplyInteger-cpu-arguments-slope":11687,"multiplyInteger-memory-arguments-intercept":0,"multiplyInteger-memory-arguments-slope":1,"nullList-cpu-arguments":60091,"nullList-memory-arguments":32,"quotientInteger-cpu-arguments-constant":196500,"quotientInteger-cpu-arguments-model-arguments-intercept":453240,"quotientInteger-cpu-arguments-model-arguments-slope":220,"quotientInteger-memory-arguments-intercept":0,"quotientInteger-memory-arguments-minimum":1,"quotientInteger-memory-arguments-slope":1,"remainderInteger-cpu-arguments-constant":196500,"remainderInteger-cpu-arguments-model-arguments-intercept":453240,"remainderInteger-cpu-arguments-model-arguments-slope":220,"remainderInteger-memory-arguments-intercept":0,"remainderInteger-memory-arguments-minimum":1,"remainderInteger-memory-arguments-slope":1,"serialiseData-cpu-arguments-intercept":1159724,"serialiseData-cpu-arguments-slope":392670,"serialiseData-memory-arguments-intercept":0,"serialiseData-memory-arguments-slope":2,"sha2_256-cpu-arguments-intercept":806990,"sha2_256-cpu-arguments-slope":30482,"sha2_256-memory-arguments":4,"sha3_256-cpu-arguments-intercept":1927926,"sha3_256-cpu-arguments-slope":82523,"sha3_256-memory-arguments":4,"sliceByteString-cpu-arguments-intercept":265318,"sliceByteString-cpu-arguments-slope":0,"sliceByteString-memory-arguments-intercept":4,"sliceByteString-memory-arguments-slope":0,"sndPair-cpu-arguments":85931,"sndPair-memory-arguments":32,"subtractInteger-cpu-arguments-intercept":205665,"subtractInteger-cpu-arguments-slope":812,"subtractInteger-memory-arguments-intercept":1,"subtractInteger-memory-arguments-slope":1,"tailList-cpu-arguments":41182,"tailList-memory-arguments":32,"trace-cpu-arguments":212342,"trace-memory-arguments":32,"unBData-cpu-arguments":31220,"unBData-memory-arguments":32,"unConstrData-cpu-arguments":32696,"unConstrData-memory-arguments":32,"unIData-cpu-arguments":43357,"unIData-memory-arguments":32,"unListData-cpu-arguments":32247,"unListData-memory-arguments":32,"unMapData-cpu-arguments":38314,"unMapData-memory-arguments":32,"verifyEcdsaSecp256k1Signature-cpu-arguments":35892428,"verifyEcdsaSecp256k1Signature-memory-arguments":10,"verifyEd25519Signature-cpu-arguments-intercept":57996947,"verifyEd25519Signature-cpu-arguments-slope":18975,"verifyEd25519Signature-memory-arguments":10,"verifySchnorrSecp256k1Signature-cpu-arguments-intercept":38887044,"verifySchnorrSecp256k1Signature-cpu-arguments-slope":32947,"verifySchnorrSecp256k1Signature-memory-arguments":10}).forEach((s,a)=>t.set(a,n.Int.new_i32(s))),r.insert(n.Language.new_plutus_v1(),e),r.insert(n.Language.new_plutus_v2(),t),r})()},Ze={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},Rt={[n.NetworkInfo.testnet().network_id()]:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",[n.NetworkInfo.mainnet().network_id()]:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},ts={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},es={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},te=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"],Se=(r,e,t="5000000")=>{const s=n.BigNum.from_str(r.get("lovelace")??"0").checked_add(n.BigNum.from_str(t)),a=e.filter(c=>c.output.amount.filter(u=>u.unit!=="lovelace").some(u=>r.has(u.unit))),i=ns(a);return[...i.less_than(s)?is(s.clamped_sub(i).to_str(),e.filter(c=>!a.some(u=>u.input.txHash===c.input.txHash&&u.input.outputIndex===c.input.outputIndex))):[],...a]},ss=(r,e,t=!1,{maxTxSize:s,minFeeA:a,minFeeB:i}=P)=>{const o=e.filter(g=>be(g)===!1).sort(Vt),c=n.BigNum.from_str($t(s,a,i)),u=t?n.BigNum.from_str(r).checked_add(c).to_str():r;return At(o,new Map([["lovelace",u]]))},Ee=(r,e,t=!1,s=P)=>{const a=e.filter(be).sort(Vt),i=as(s),o=r.get("lovelace")??"0",c=t?n.BigNum.from_str(o).checked_add(i).to_str():o;return r.set("lovelace",c),At(a,r)},rs=(r,e)=>Array.from(e,t=>({unit:t[0],quantity:n.BigNum.from_str(t[1])})).every(t=>r.filter(s=>s.output.amount.find(a=>a.unit===t.unit)!==void 0).reduce((s,a)=>{const i=a.output.amount.reduce((o,c)=>o.checked_add(n.BigNum.from_str(t.unit===c.unit?c.quantity:"0")),n.BigNum.from_str("0"));return s.checked_add(i)},n.BigNum.from_str("0")).less_than(t.quantity)===!1),Vt=(r,e)=>{var a,i;const t=n.BigNum.from_str(((a=r.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:a.quantity)??"0");return n.BigNum.from_str(((i=e.output.amount.find(o=>o.unit==="lovelace"))==null?void 0:i.quantity)??"0").compare(t)},as=r=>{const{maxTxSize:e,minFeeA:t,minFeeB:s}=r;return n.BigNum.from_str($t(e,t,s))},be=r=>r.output.amount.length>1,ns=r=>r.reduce((e,t)=>{var a;const s=((a=t.output.amount.find(i=>i.unit==="lovelace"))==null?void 0:a.quantity)??"0";return e.checked_add(n.BigNum.from_str(s))},n.BigNum.from_str("0")),is=(r,e)=>{const t=e.sort(Vt);return At(t,new Map([["lovelace",r]]))},At=(r,e,t=[])=>r.length===0||rs(t,e)?t:os(r[0],e)?At(r.slice(1),e,[...t,r[0]]):At(r.slice(1),e,t),os=(r,e)=>Array.from(e.keys()).some(t=>r.output.amount.find(s=>s.unit===t)!==void 0),cs=(r,e)=>{const t=ls(e),s=hs(r,e);return{coseKey:T(t.to_bytes()),coseSign1:T(s.to_bytes())}},us=(r,e,{key:t,signature:s})=>{var o,c;const a=y.COSEKey.from_bytes(_(t)),i=y.COSESign1.from_bytes(_(s));if((r==null?void 0:r.length)>0){const u=T(i.payload()??new Uint8Array);if(Q(r)!==u)return!1}if((e==null?void 0:e.length)>0){const d=(o=i.headers().protected().deserialized_headers().header(y.Label.new_text("address")))==null?void 0:o.as_bytes();if(d===void 0)throw new Error("Couldn't find a signer address in signature");const h=(c=a.header(y.Label.new_int(y.Int.new_negative(y.BigNum.from_str("2")))))==null?void 0:c.as_bytes();if(h===void 0)throw new Error("Couldn't find a signer key in signature");const g=at(T(d)),m=Ms(T(h));if(ds(e,g,m)===!1)throw new Error("Couldn't check signature because of address mismatch");const A=Hs(T(i.signature())),I=i.signed_data().to_bytes();return m.verify(I,A)}return!1},ds=(r,e,t)=>{if(r!==e.to_bech32())return!1;try{return it(r)===t.hash().to_hex()}catch{return!1}},ls=r=>{const e=y.COSEKey.new(y.Label.from_key_type(y.KeyType.OKP));return e.set_algorithm_id(y.Label.from_algorithm_id(y.AlgorithmId.EdDSA)),e.set_header(y.Label.new_int(y.Int.new_negative(y.BigNum.from_str("1"))),y.CBORValue.new_int(y.Int.new_i32(6))),e.set_header(y.Label.new_int(y.Int.new_negative(y.BigNum.from_str("2"))),y.CBORValue.new_bytes(r.key.to_public().as_bytes())),e},hs=(r,e)=>{const t=y.HeaderMap.new(),s=y.HeaderMap.new();t.set_algorithm_id(y.Label.from_algorithm_id(y.AlgorithmId.EdDSA)),t.set_header(y.Label.new_text("address"),y.CBORValue.new_bytes(e.address.to_bytes()));const a=y.Headers.new(y.ProtectedHeaderMap.new(t),s),i=y.COSESign1Builder.new(a,_(r.payload),!1);r.externalAAD!==void 0&&i.set_external_aad(_(r.externalAAD));const o=i.make_data_to_sign(),c=e.key.sign(o.to_bytes());return i.build(c.to_bytes())};var ee=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Qe={},v={exports:{}};z.notEqual=ms;z.notOk=As;z.equal=gs;z.ok=z;var ve=z;function gs(r,e,t){z(r==e,t)}function ms(r,e,t){z(r!=e,t)}function As(r,e){z(!r,e)}function z(r,e){if(!r)throw new Error(e||"AssertionError")}var q={exports:{}};function Is(r){throw new Error('Could not dynamically require "'+r+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var ps=qt;qt.supported=typeof WebAssembly<"u";function qt(r){if(!qt.supported)return null;var e=r&&r.imports,t=fs("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaABaiElIABBqAFqISYgAEGwAWohJyAAQbgBaiEoICEpAwAhASAiKQMAIQIgIykDACEDICQpAwAhBCAlKQMAIQUgJikDACEGICcpAwAhByAoKQMAIQhCiJLznf/M+YTqACEJQrvOqqbY0Ouzu38hCkKr8NP0r+68tzwhC0Lx7fT4paf9p6V/IQxC0YWa7/rPlIfRACENQp/Y+dnCkdqCm38hDkLr+obav7X2wR8hD0L5wvibkaOz8NsAIRAgACkDACERIABBCGopAwAhEiAAQRBqKQMAIRMgAEEYaikDACEUIABBIGopAwAhFSAAQShqKQMAIRYgAEEwaikDACEXIABBOGopAwAhGC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,memory:null,exports:null,realloc:i,onload:o};return o(function(){}),a;function i(u){a.exports.memory.grow(Math.ceil(Math.abs(u-a.memory.length)/65536)),a.memory=new Uint8Array(a.exports.memory.buffer)}function o(u){if(a.exports)return u();if(s){s.then(u.bind(null,null)).catch(u);return}try{if(r&&r.async)throw new Error("async");c({instance:new WebAssembly.Instance(new WebAssembly.Module(t),e)})}catch{s=WebAssembly.instantiate(t,e).then(c)}o(u)}function c(u){a.exports=u.instance.exports,a.memory=a.exports.memory&&a.exports.memory.buffer&&new Uint8Array(a.exports.memory.buffer)}}function fs(r){return typeof atob=="function"?new Uint8Array(atob(r).split("").map(_s)):new(Is("buffer")).Buffer(r,"base64")}function _s(r){return r.charCodeAt(0)}var O=ve,x=ps(),G=64,wt=[];q.exports=U;var se=q.exports.BYTES_MIN=16,re=q.exports.BYTES_MAX=64;q.exports.BYTES=32;var ae=q.exports.KEYBYTES_MIN=16,ne=q.exports.KEYBYTES_MAX=64;q.exports.KEYBYTES=32;var ie=q.exports.SALTBYTES=16,oe=q.exports.PERSONALBYTES=16;function U(r,e,t,s,a){if(!(this instanceof U))return new U(r,e,t,s,a);if(!(x&&x.exports))throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");r||(r=32),a!==!0&&(O(r>=se,"digestLength must be at least "+se+", was given "+r),O(r<=re,"digestLength must be at most "+re+", was given "+r),e!=null&&O(e.length>=ae,"key must be at least "+ae+", was given "+e.length),e!=null&&O(e.length<=ne,"key must be at least "+ne+", was given "+e.length),t!=null&&O(t.length===ie,"salt must be exactly "+ie+", was given "+t.length),s!=null&&O(s.length===oe,"personal must be exactly "+oe+", was given "+s.length)),wt.length||(wt.push(G),G+=216),this.digestLength=r,this.finalized=!1,this.pointer=wt.pop(),x.memory.fill(0,0,64),x.memory[0]=this.digestLength,x.memory[1]=e?e.length:0,x.memory[2]=1,x.memory[3]=1,t&&x.memory.set(t,32),s&&x.memory.set(s,48),this.pointer+216>x.memory.length&&x.realloc(this.pointer+216),x.exports.blake2b_init(this.pointer,this.digestLength),e&&(this.update(e),x.memory.fill(0,G,G+e.length),x.memory[this.pointer+200]=128)}U.prototype.update=function(r){return O(this.finalized===!1,"Hash instance finalized"),O(r,"input must be TypedArray or Buffer"),G+r.length>x.memory.length&&x.realloc(G+r.length),x.memory.set(r,G),x.exports.blake2b_update(this.pointer,G,G+r.length),this};U.prototype.digest=function(r){if(O(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,wt.push(this.pointer),x.exports.blake2b_final(this.pointer),!r||r==="binary")return x.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(r==="hex")return xs(x.memory,this.pointer+128,this.digestLength);O(r.length>=this.digestLength,"input must be TypedArray or Buffer");for(var e=0;e<this.digestLength;e++)r[e]=x.memory[this.pointer+128+e];return r};U.prototype.final=U.prototype.digest;U.WASM=x&&x.buffer;U.SUPPORTED=typeof WebAssembly<"u";U.ready=function(r){if(r||(r=ys),!x)return r(new Error("WebAssembly not supported"));var e=new Promise(function(t,s){x.onload(function(a){a?s():t(),r(a)})});return e};U.prototype.ready=U.ready;function ys(){}function xs(r,e,t){for(var s="",a=0;a<t;a++)s+=Cs(r[e+a]);return s}function Cs(r){return r<16?"0"+r.toString(16):r.toString(16)}var X=ve,It=q.exports;function _t(r,e,t){var s=r[e]+r[t],a=r[e+1]+r[t+1];s>=4294967296&&a++,r[e]=s,r[e+1]=a}function ce(r,e,t,s){var a=r[e]+t;t<0&&(a+=4294967296);var i=r[e+1]+s;a>=4294967296&&i++,r[e]=a,r[e+1]=i}function De(r,e){return r[e]^r[e+1]<<8^r[e+2]<<16^r[e+3]<<24}function W(r,e,t,s,a,i){var o=gt[a],c=gt[a+1],u=gt[i],d=gt[i+1];_t(p,r,e),ce(p,r,o,c);var h=p[s]^p[r],g=p[s+1]^p[r+1];p[s]=g,p[s+1]=h,_t(p,t,s),h=p[e]^p[t],g=p[e+1]^p[t+1],p[e]=h>>>24^g<<8,p[e+1]=g>>>24^h<<8,_t(p,r,e),ce(p,r,u,d),h=p[s]^p[r],g=p[s+1]^p[r+1],p[s]=h>>>16^g<<16,p[s+1]=g>>>16^h<<16,_t(p,t,s),h=p[e]^p[t],g=p[e+1]^p[t+1],p[e]=g>>>31^h<<1,p[e+1]=h>>>31^g<<1}var ke=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),ws=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],b=new Uint8Array(ws.map(function(r){return r*2})),p=new Uint32Array(32),gt=new Uint32Array(32);function Te(r,e){var t=0;for(t=0;t<16;t++)p[t]=r.h[t],p[t+16]=ke[t];for(p[24]=p[24]^r.t,p[25]=p[25]^r.t/4294967296,e&&(p[28]=~p[28],p[29]=~p[29]),t=0;t<32;t++)gt[t]=De(r.b,4*t);for(t=0;t<12;t++)W(0,8,16,24,b[t*16+0],b[t*16+1]),W(2,10,18,26,b[t*16+2],b[t*16+3]),W(4,12,20,28,b[t*16+4],b[t*16+5]),W(6,14,22,30,b[t*16+6],b[t*16+7]),W(0,10,20,30,b[t*16+8],b[t*16+9]),W(2,12,22,24,b[t*16+10],b[t*16+11]),W(4,14,16,26,b[t*16+12],b[t*16+13]),W(6,8,18,28,b[t*16+14],b[t*16+15]);for(t=0;t<16;t++)r.h[t]=r.h[t]^p[t]^p[t+16]}var j=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function ct(r,e,t,s){j.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=r,j[0]=r,e&&(j[1]=e.length),j[2]=1,j[3]=1,t&&j.set(t,32),s&&j.set(s,48);for(var a=0;a<16;a++)this.h[a]=ke[a]^De(j,a*4);e&&(Pe(this,e),this.c=128)}ct.prototype.update=function(r){return X(r!=null,"input must be Uint8Array or Buffer"),Pe(this,r),this};ct.prototype.digest=function(r){var e=!r||r==="binary"||r==="hex"?new Uint8Array(this.outlen):r;return X(e.length>=this.outlen,"out must have at least outlen bytes of space"),Bs(this,e),r==="hex"?Ss(e):e};ct.prototype.final=ct.prototype.digest;ct.ready=function(r){It.ready(function(){r()})};function Pe(r,e){for(var t=0;t<e.length;t++)r.c===128&&(r.t+=r.c,Te(r,!1),r.c=0),r.b[r.c++]=e[t]}function Bs(r,e){for(r.t+=r.c;r.c<128;)r.b[r.c++]=0;Te(r,!0);for(var t=0;t<r.outlen;t++)e[t]=r.h[t>>2]>>8*(t&3);return e}function Ss(r){for(var e="",t=0;t<r.length;t++)e+=Es(r[t]);return e}function Es(r){return r<16?"0"+r.toString(16):r.toString(16)}var Ue=ct;v.exports=function(e,t,s,a,i){return i!==!0&&(X(e>=ue,"outlen must be at least "+ue+", was given "+e),X(e<=de,"outlen must be at most "+de+", was given "+e),t!=null&&X(t.length>=le,"key must be at least "+le+", was given "+t.length),t!=null&&X(t.length<=he,"key must be at most "+he+", was given "+t.length),s!=null&&X(s.length===ge,"salt must be exactly "+ge+", was given "+s.length),a!=null&&X(a.length===me,"personal must be exactly "+me+", was given "+a.length)),new Ue(e,t,s,a)};v.exports.ready=function(r){It.ready(function(){r()})};v.exports.WASM_SUPPORTED=It.SUPPORTED;v.exports.WASM_LOADED=!1;var ue=v.exports.BYTES_MIN=16,de=v.exports.BYTES_MAX=64;v.exports.BYTES=32;var le=v.exports.KEYBYTES_MIN=16,he=v.exports.KEYBYTES_MAX=64;v.exports.KEYBYTES=32;var ge=v.exports.SALTBYTES=16,me=v.exports.PERSONALBYTES=16;It.ready(function(r){r||(v.exports.WASM_LOADED=!0,Ue=It)});var ut={};Object.defineProperty(ut,"__esModule",{value:!0});ut.bech32m=ut.bech32=void 0;const bt="qpzry9x8gf2tvdw0s3jn54khce6mua7l",Ne={};for(let r=0;r<bt.length;r++){const e=bt.charAt(r);Ne[e]=r}function ot(r){const e=r>>25;return(r&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function Ae(r){let e=1;for(let t=0;t<r.length;++t){const s=r.charCodeAt(t);if(s<33||s>126)return"Invalid prefix ("+r+")";e=ot(e)^s>>5}e=ot(e);for(let t=0;t<r.length;++t){const s=r.charCodeAt(t);e=ot(e)^s&31}return e}function Lt(r,e,t,s){let a=0,i=0;const o=(1<<t)-1,c=[];for(let u=0;u<r.length;++u)for(a=a<<e|r[u],i+=e;i>=t;)i-=t,c.push(a>>i&o);if(s)i>0&&c.push(a<<t-i&o);else{if(i>=e)return"Excess padding";if(a<<t-i&o)return"Non-zero padding"}return c}function bs(r){return Lt(r,8,5,!0)}function Qs(r){const e=Lt(r,5,8,!1);if(Array.isArray(e))return e}function vs(r){const e=Lt(r,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function Ke(r){let e;r==="bech32"?e=1:e=734539939;function t(o,c,u){if(u=u||90,o.length+7+c.length>u)throw new TypeError("Exceeds length limit");o=o.toLowerCase();let d=Ae(o);if(typeof d=="string")throw new Error(d);let h=o+"1";for(let g=0;g<c.length;++g){const m=c[g];if(m>>5!==0)throw new Error("Non 5-bit word");d=ot(d)^m,h+=bt.charAt(m)}for(let g=0;g<6;++g)d=ot(d);d^=e;for(let g=0;g<6;++g){const m=d>>(5-g)*5&31;h+=bt.charAt(m)}return h}function s(o,c){if(c=c||90,o.length<8)return o+" too short";if(o.length>c)return"Exceeds length limit";const u=o.toLowerCase(),d=o.toUpperCase();if(o!==u&&o!==d)return"Mixed-case string "+o;o=u;const h=o.lastIndexOf("1");if(h===-1)return"No separator character for "+o;if(h===0)return"Missing prefix for "+o;const g=o.slice(0,h),m=o.slice(h+1);if(m.length<6)return"Data too short";let A=Ae(g);if(typeof A=="string")return A;const I=[];for(let C=0;C<m.length;++C){const D=m.charAt(C),f=Ne[D];if(f===void 0)return"Unknown character "+D;A=ot(A)^f,!(C+6>=m.length)&&I.push(f)}return A!==e?"Invalid checksum for "+o:{prefix:g,words:I}}function a(o,c){const u=s(o,c);if(typeof u=="object")return u}function i(o,c){const u=s(o,c);if(typeof u=="object")return u;throw new Error(u)}return{decodeUnsafe:a,decode:i,encode:t,toWords:bs,fromWordsUnsafe:Qs,fromWords:vs}}ut.bech32=Ke("bech32");ut.bech32m=Ke("bech32m");var Ds=ee&&ee.__importDefault||function(r){return r&&r.__esModule?r:{default:r}};Object.defineProperty(Qe,"__esModule",{value:!0});const ks=Ds(v.exports),yt=ut,Ut="asset";class mt{constructor(e){this.hashBuf=e}static fromHash(e){return new mt(e)}static fromParts(e,t){const s=(0,ks.default)(20).update(new Uint8Array([...e,...t])).digest("binary");return mt.fromHash(s)}static fromBech32(e){const{prefix:t,words:s}=yt.bech32.decode(e);if(t!==Ut)throw new Error("Invalid asset fingerprint");const a=Buffer.from(yt.bech32.fromWords(s));return mt.fromHash(a)}fingerprint(){const e=yt.bech32.toWords(this.hashBuf);return yt.bech32.encode(Ut,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return Ut}checksum(){return this.fingerprint().slice(-6)}}var Ts=Qe.default=mt;const Ps=Ts,Us=(r,e)=>{const t=Ns(r),s=t.derive(Pt+1852).derive(Pt+1815).derive(Pt+e),a=s.derive(0).derive(0).to_raw_key(),i=s.derive(2).derive(0).to_raw_key();return s.free(),t.free(),{paymentKey:a,stakeKey:i}},at=r=>n.Address.from_bytes(_(r)),Ns=r=>n.Bip32PrivateKey.from_bytes(_(r)),Ks=r=>n.DataHash.from_bytes(_(r)),R=r=>n.Ed25519KeyHash.from_bytes(_(r)),Hs=r=>n.Ed25519Signature.from_bytes(_(r)),Dt=r=>n.NativeScript.from_bytes(_(r)),Ms=r=>n.PublicKey.from_bytes(_(r)),He=r=>n.PlutusData.from_bytes(_(r)),dt=(r,e)=>n.PlutusScript.from_bytes_with_version(_(r),Y[e]),Os=r=>n.ScriptRef.from_bytes(_(r)),Fs=r=>n.ScriptHash.from_bytes(_(r)),H=r=>n.Transaction.from_bytes(_(r)),Me=r=>n.TransactionHash.from_bytes(_(r)),Ie=r=>n.TransactionUnspentOutput.from_bytes(_(r)),pe=r=>n.TransactionWitnessSet.from_bytes(_(r)),Rs=r=>n.Value.from_bytes(_(r)),M=r=>n.Address.from_bech32(r),Yt=r=>n.BaseAddress.from_address(M(r)),Oe=r=>n.EnterpriseAddress.from_address(M(r)),Fe=r=>n.RewardAddress.from_address(M(r)),T=r=>Buffer.from(r).toString("hex"),_=r=>r.length%2===0&&/^[0-9A-F]*$/i.test(r)?Buffer.from(r,"hex"):Buffer.from(r,"utf-8"),kt=r=>{const e=t=>{const s=new Array;for(let a=0;a<t.len();a+=1)s.push(kt(t.get(a)));return s};switch(r.kind()){case n.NativeScriptKind.ScriptAll:{const t=r.as_script_all();return{type:"all",scripts:e(t.native_scripts())}}case n.NativeScriptKind.ScriptAny:{const t=r.as_script_any();return{type:"any",scripts:e(t.native_scripts())}}case n.NativeScriptKind.ScriptNOfK:{const t=r.as_script_n_of_k();return{type:"atLeast",required:t.n(),scripts:e(t.native_scripts())}}case n.NativeScriptKind.TimelockStart:return{type:"after",slot:r.as_timelock_start().slot_bignum().to_str()};case n.NativeScriptKind.TimelockExpiry:return{type:"before",slot:r.as_timelock_expiry().slot_bignum().to_str()};case n.NativeScriptKind.ScriptPubkey:return{type:"sig",keyHash:r.as_script_pubkey().addr_keyhash().to_hex()};default:throw new Error(`Script Kind: ${r.kind()}, is not supported`)}},Tt=r=>{const e=t=>{const s=n.NativeScripts.new();return t.forEach(a=>{s.add(Tt(a))}),s};switch(r.type){case"all":return n.NativeScript.new_script_all(n.ScriptAll.new(e(r.scripts)));case"any":return n.NativeScript.new_script_any(n.ScriptAny.new(e(r.scripts)));case"atLeast":return n.NativeScript.new_script_n_of_k(n.ScriptNOfK.new(r.required,e(r.scripts)));case"after":return n.NativeScript.new_timelock_start(n.TimelockStart.new_timelockstart(n.BigNum.from_str(r.slot)));case"before":return n.NativeScript.new_timelock_expiry(n.TimelockExpiry.new_timelockexpiry(n.BigNum.from_str(r.slot)));case"sig":return n.NativeScript.new_script_pubkey(n.ScriptPubkey.new(R(r.keyHash)))}},Bt=r=>{var s,a,i;const e=o=>{const c=[];for(let u=0;u<o.len();u+=1)c.push(Bt(o.get(u)));return c},t=o=>{const c=new Map;for(let u=0;u<o.len();u+=1){const d=o.keys().get(u),h=o.get(d)??n.PlutusData.from_hex(Q("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));c.set(Bt(d),Bt(h))}return c};switch(r.kind()){case n.PlutusDataKind.Bytes:return T(r.as_bytes()??new Uint8Array);case n.PlutusDataKind.Integer:return parseInt(((s=r.as_integer())==null?void 0:s.to_str())??"0",10);case n.PlutusDataKind.List:return e(r.as_list()??n.PlutusList.new());case n.PlutusDataKind.Map:return t(r.as_map()??n.PlutusMap.new());case n.PlutusDataKind.ConstrPlutusData:return{alternative:parseInt(((a=r.as_constr_plutus_data())==null?void 0:a.alternative().to_str())??"0",10),fields:e(((i=r.as_constr_plutus_data())==null?void 0:i.data())??n.PlutusList.new())};default:throw new Error(`PlutusData Kind: ${r.kind()}, is not supported`)}},Z=r=>{const e=t=>{const s=n.PlutusList.new();return t.forEach(a=>{s.add(Z(a))}),s};switch(typeof r){case"string":return n.PlutusData.new_bytes(_(r));case"number":return n.PlutusData.new_integer(n.BigInt.from_str(r.toString()));case"bigint":return n.PlutusData.new_integer(n.BigInt.from_str(r.toString()));case"object":if(r instanceof Array){const t=e(r);return n.PlutusData.new_list(t)}else if(r instanceof Map){const t=n.PlutusMap.new();return r.forEach((s,a)=>{t.insert(Z(a),Z(s))}),n.PlutusData.new_map(t)}else return n.PlutusData.new_constr_plutus_data(n.ConstrPlutusData.new(n.BigNum.from_str(r.alternative.toString()),e(r.fields)))}},Vs=r=>{const e=n.Relays.new();throw r.relays.forEach(t=>{e.add(Re(t))}),new Error("toPoolParams not implemented.")},Kt=r=>{const e=t=>Xe[t];return n.Redeemer.new(e(r.tag),n.BigNum.from_str(r.index.toString()),Z(r.data),n.ExUnits.new(n.BigNum.from_str(r.budget.mem.toString()),n.BigNum.from_str(r.budget.steps.toString())))},Re=r=>{switch(r.type){case"SingleHostAddr":{const e=r.IPV4?n.Ipv4.new(new Uint8Array(r.IPV4.split(".").map(s=>parseInt(s)))):void 0,t=r.IPV6?n.Ipv6.new(_(r.IPV6.replaceAll(":",""))):void 0;return n.Relay.new_single_host_addr(n.SingleHostAddr.new(r.port,e,t))}case"SingleHostName":return n.Relay.new_single_host_name(n.SingleHostName.new(r.port,n.DNSRecordAorAAAA.new(r.domainName)));case"MultiHostName":return n.Relay.new_multi_host_name(n.MultiHostName.new(n.DNSRecordSRV.new(r.domainName)))}},Ve=r=>{if(r.is_plutus_script()){const t=r.plutus_script();return{code:t.to_hex(),version:Object.keys(Y).find(s=>Y[s].to_hex()===t.language_version().to_hex())}}const e=r.native_script();return kt(e)},lt=r=>{if("code"in r){const e=dt(r.code,r.version);return n.ScriptRef.new_plutus_script(e)}return n.ScriptRef.new_native_script(Tt(r))},Qt=r=>{var a,i,o;const e=r.output().has_data_hash()?(a=r.output().data_hash())==null?void 0:a.to_hex():void 0,t=r.output().has_plutus_data()?(i=r.output().plutus_data())==null?void 0:i.to_hex():void 0,s=r.output().has_script_ref()?(o=r.output().script_ref())==null?void 0:o.to_hex():void 0;return{input:{outputIndex:r.input().index(),txHash:r.input().transaction_id().to_hex()},output:{address:r.output().address().to_bech32(),amount:qe(r.output().amount()),dataHash:e,plutusData:t,scriptRef:s}}},F=r=>{const e=n.TransactionInput.new(Me(r.input.txHash),r.input.outputIndex),t=n.TransactionOutput.new(M(r.output.address),$(r.output.amount));return r.output.dataHash!==void 0&&t.set_data_hash(Ks(r.output.dataHash)),r.output.plutusData!==void 0&&t.set_plutus_data(He(r.output.plutusData)),r.output.scriptRef!==void 0&&t.set_script_ref(Os(r.output.scriptRef)),n.TransactionUnspentOutput.new(e,t)},fe=r=>{const e=r.split(".")[1]??"0",t=`${parseInt(e,10)}`,s="1"+"0".repeat(e.length);return n.UnitInterval.new(n.BigNum.from_str(t),n.BigNum.from_str(s))},Q=r=>r.length%2===0&&/^[0-9A-F]*$/i.test(r)?r:T(Buffer.from(r,"utf-8")),Gt=r=>Buffer.from(r,"hex").toString("utf-8"),qe=r=>{const e=[{unit:"lovelace",quantity:r.coin().to_str()}],t=r.multiasset();if(t!==void 0){const s=t.keys();for(let a=0;a<s.len();a+=1){const i=s.get(a),o=t.get(i);if(o!==void 0){const c=o.keys();for(let u=0;u<c.len();u+=1){const d=c.get(u),h=o.get(d)??n.BigNum.from_str("0"),g=i.to_hex()+T(d.name());e.push({unit:g,quantity:h.to_str()})}}}}return e},$=r=>{const e=r.find(i=>i.unit==="lovelace"),t=Array.from(new Set(r.filter(i=>i.unit!=="lovelace").map(i=>i.unit.slice(0,V)))),s=n.MultiAsset.new();t.forEach(i=>{const o=n.Assets.new();r.filter(c=>c.unit.slice(0,V)===i).forEach(c=>{o.insert(n.AssetName.new(_(c.unit.slice(V))),n.BigNum.from_str(c.quantity))}),s.insert(Fs(i),o)});const a=n.Value.new(n.BigNum.from_str(e?e.quantity:"0"));return(r.length>1||!e)&&a.set_multiasset(s),a},_e=(r,e,t)=>n.BaseAddress.new(r,n.StakeCredential.from_keyhash(e),n.StakeCredential.from_keyhash(t)),Le=(r,e="")=>n.Bip32PrivateKey.from_bip39_entropy(_(r),_(Q(e))),Ht=r=>n.DataCost.new_coins_per_byte(n.BigNum.from_str(r)),qs=r=>{if(typeof r!="object"||!("input"in r))return n.DatumSource.new(Z(r));const e=F(r);if(e.output().has_plutus_data())return n.DatumSource.new_ref_input(e.input());throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`)},ye=(r,e)=>n.EnterpriseAddress.new(r,n.StakeCredential.from_keyhash(e)),xe=(r,e)=>{if(typeof r=="string")return n.MintWitness.new_native_script(Dt(r));if(e===void 0)throw new Error("Minting with plutus requires a redeemer to be defined");if(e.tag!=="MINT")throw new Error("Minting redeemer's tag must be defined as 'MINT'");return n.MintWitness.new_plutus_script(Ot(r),Kt({tag:"MINT",index:0,budget:nt,data:{alternative:0,fields:[]},...e}))},Mt=(r,e)=>n.RewardAddress.new(r,n.StakeCredential.from_keyhash(e)),Ot=r=>{if("code"in r)return n.PlutusScriptSource.new(dt(r.code,r.version));const e=F(r);if(e.output().has_script_ref()){const t=e.output().script_ref();if(t.is_plutus_script()){const s=Ve(t),a=dt(s.code,s.version).hash();return n.PlutusScriptSource.new_ref_input_with_lang_ver(a,e.input(),Y[s.version])}}throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`)},xt=r=>{const e=n.ScriptPubkey.new(r);return n.NativeScript.new_script_pubkey(e)},St=(r=P)=>{const e=n.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(n.BigNum.from_str(r.coinsPerUTxOSize)).ex_unit_prices(n.ExUnitPrices.new(fe(r.priceMem.toString()),fe(r.priceStep.toString()))).fee_algo(n.LinearFee.new(n.BigNum.from_str(r.minFeeA.toString()),n.BigNum.from_str(r.minFeeB.toString()))).key_deposit(n.BigNum.from_str(r.keyDeposit)).max_tx_size(r.maxTxSize).max_value_size(parseInt(r.maxValSize,10)).pool_deposit(n.BigNum.from_str(r.poolDeposit)).build();return n.TransactionBuilder.new(e)},Ce=r=>{const e=n.TxInputsBuilder.new();return r.map(t=>t instanceof n.TransactionUnspentOutput?t:F(t)).forEach(t=>{e.add_input(t.output().address(),t.input(),t.output().amount())}),e},Ct=r=>{if(typeof r=="string")return n.TransactionOutputBuilder.new().with_address(M(r));let e=n.TransactionOutputBuilder.new().with_address(M(r.address));if(r.datum){const{value:t,inline:s}=r.datum,a=Z(t);e=e.with_data_hash(n.hash_plutus_data(a)),s&&(e=e.with_plutus_data(a))}if(r.script){const t=lt(r.script);e=e.with_script_ref(t)}return e},J=r=>{const e=r.slice(0,V),t=r.includes(".")?Q(r.split(".")[1]):r.slice(V);return{policyId:e,assetName:t}},l=r=>tt.default.isAxiosError(r)?r.response?JSON.stringify({data:r.response.data,headers:r.response.headers,status:r.response.status}):r.request?JSON.stringify(r.request):r.message:JSON.stringify(r),Ls=r=>{const e=Z(r);return n.hash_plutus_data(e).to_hex()},Ys=(r,e=Date.now())=>{if(Et[r]){const[t,s,a,i]=Et[r];return parseInt(n.BigNum.from_str(e.toString()).div_floor(n.BigNum.from_str("1000")).checked_sub(n.BigNum.from_str(a)).div_floor(n.BigNum.from_str(i)).checked_add(n.BigNum.from_str(t)).to_str(),10)}throw new Error(`Couldn't resolve EpochNo for network: ${r}`)},Ye=(r,e)=>Ps.fromParts(_(r),_(e)).fingerprint(),Gs=(r,e)=>Ze[r][e],$s=r=>Tt(r).hash().to_hex(),st=r=>{var e,t;try{const s=[(e=Yt(r))==null?void 0:e.payment_cred().to_keyhash(),(t=Oe(r))==null?void 0:t.payment_cred().to_keyhash()].find(a=>a!==void 0);if(s!==void 0)return s.to_hex();throw new Error(`Couldn't resolve payment key hash from address: ${r}`)}catch(s){throw new Error(`An error occurred during resolvePaymentKeyHash: ${s}.`)}},zs=(r,e=0)=>{const t=dt(r.code,r.version);return n.EnterpriseAddress.new(e,n.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Js=r=>{try{const e=Oe(r),t=e==null?void 0:e.payment_cred().to_scripthash();if(t!==void 0)return t.to_hex();throw new Error(`Couldn't resolve script hash from address: ${r}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},Ws=r=>n.Ed25519KeyHash.from_hex(r).to_bech32("pool1"),js=r=>{const e=Nt.mnemonicToEntropy(r.join(" ")),t=Le(e),s=t.to_bech32();return t.free(),s},Xs=r=>lt(r).to_hex(),Zs=(r,e=Date.now())=>{if(Et[r]){const[t,s,a]=Et[r];return n.BigNum.from_str(e.toString()).div_floor(n.BigNum.from_str("1000")).checked_sub(n.BigNum.from_str(a)).checked_add(n.BigNum.from_str(s)).to_str()}throw new Error(`Couldn't resolve SlotNo for network: ${r}`)},pt=r=>{try{const e=M(r),t=Yt(r),s=t==null?void 0:t.stake_cred().to_keyhash();if(s!==void 0)return Mt(e.network_id(),s).to_address().to_bech32();throw new Error(`Couldn't resolve reward address from address: ${r}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},it=r=>{var e,t;try{const s=[(e=Yt(r))==null?void 0:e.stake_cred().to_keyhash(),(t=Fe(r))==null?void 0:t.payment_cred().to_keyhash()].find(a=>a!==void 0);if(s!==void 0)return s.to_hex();throw new Error(`Couldn't resolve stake key hash from address: ${r}`)}catch(s){throw new Error(`An error occurred during resolveStakeKeyHash: ${s}.`)}},$t=(r,e=P.minFeeA,t=P.minFeeB)=>(BigInt(e)*BigInt(r)+BigInt(t)).toString(),Ge=r=>{const e=H(r).body();return n.hash_transaction(e).to_hex()},tr=(r="",e=32)=>{if(e<=0||e>2048)throw new Error("Length must be bewteen 1 and 2048");const s=we.customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")(e);return Q(`${r}${s}`)},Ft=(r,e)=>{const t=r.vkeys();if(t!==void 0){const s=new Set;for(let i=0;i<t.len();i+=1)s.add(t.get(i).to_hex());for(let i=0;i<e.len();i+=1)s.add(e.get(i).to_hex());const a=n.Vkeywitnesses.new();return s.forEach(i=>{a.add(n.Vkeywitness.from_hex(i))}),a}return e},er=r=>Bt(He(r)),sr=r=>H(r).to_js_value();class rr{_axiosInstance;constructor(...e){if(typeof e[0]=="string"&&e[0].startsWith("http"))this._axiosInstance=tt.default.create({baseURL:e[0]});else{const t=e[0],s=t.slice(0,7);this._axiosInstance=tt.default.create({baseURL:`https://cardano-${s}.blockfrost.io/api/v${e[1]??0}`,headers:{project_id:t}})}}async fetchAccountInfo(e){const t=e.startsWith("addr")?pt(e):e;try{const{data:s,status:a}=await this._axiosInstance.get(`accounts/${t}`);if(a===200)return{poolId:s.pool_id,active:s.active||s.active_epoch!==null,balance:s.controlled_amount,rewards:s.withdrawable_amount,withdrawals:s.withdrawals_sum};throw l(s)}catch(s){throw l(s)}}resolveScriptRef=async e=>{if(e){const{data:t,status:s}=await this._axiosInstance.get(`scripts/${e}`);if(s===200){const a=t.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(e),version:t.type.replace("plutus","")}:await this.fetchNativeScriptJSON(e);return lt(a).to_hex()}throw l(t)}};toUTxO=async(e,t)=>({input:{outputIndex:e.output_index,txHash:t},output:{address:e.address,amount:e.amount,dataHash:e.data_hash??void 0,plutusData:e.inline_datum??void 0,scriptRef:await this.resolveScriptRef(e.reference_script_hash),scriptHash:e.reference_script_hash}});async fetchAddressUTxOs(e,t){const s=t!==void 0?`/${t}`:"",a=`addresses/${e}/utxos`+s,i=async(o=1,c=[])=>{const{data:u,status:d}=await this._axiosInstance.get(`${a}?page=${o}`);if(d===200)return u.length>0?i(o+1,[...c,...await Promise.all(u.map(h=>this.toUTxO(h,h.tx_hash)))]):c;throw l(u)};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const t=async(s=1,a=[])=>{const{policyId:i,assetName:o}=J(e),{data:c,status:u}=await this._axiosInstance.get(`assets/${i}${o}/addresses?page=${s}`);if(u===200)return c.length>0?t(s+1,[...a,...c]):a;throw l(c)};try{return await t()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:s}=J(e),{data:a,status:i}=await this._axiosInstance.get(`assets/${t}${s}`);if(i===200)return{...a.onchain_metadata};throw l(a)}catch(t){throw l(t)}}async fetchBlockInfo(e){try{const{data:t,status:s}=await this._axiosInstance.get(`blocks/${e}`);if(s===200)return{confirmations:t.confirmations,epoch:t.epoch,epochSlot:t.epoch_slot.toString(),fees:t.fees,hash:t.hash,nextBlock:t.next_block??"",operationalCertificate:t.op_cert,output:t.output??"0",previousBlock:t.previous_block,size:t.size,slot:t.slot.toString(),slotLeader:t.slot_leader??"",time:t.time,txCount:t.tx_count,VRFKey:t.block_vrf};throw l(t)}catch(t){throw l(t)}}async fetchCollectionAssets(e,t=1){try{const{data:s,status:a}=await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);if(a===200)return{assets:s.map(i=>({unit:i.asset,quantity:i.quantity})),next:s.length===100?t+1:null};throw l(s)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:s,status:a}=await this._axiosInstance.get(`assets/${Rt[1]}${t}/addresses`);if(a===200)return s[0].address;throw l(s)}catch(t){throw l(t)}}async fetchProtocolParameters(e=Number.NaN){try{const{data:t,status:s}=await this._axiosInstance.get(`epochs/${isNaN(e)?"latest":e}/parameters`);if(s===200)return{coinsPerUTxOSize:t.coins_per_utxo_word,collateralPercent:t.collateral_percent,decentralisation:t.decentralisation_param,epoch:t.epoch,keyDeposit:t.key_deposit,maxBlockExMem:t.max_block_ex_mem,maxBlockExSteps:t.max_block_ex_steps,maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem,maxTxExSteps:t.max_tx_ex_steps,maxTxSize:t.max_tx_size,maxValSize:t.max_val_size,minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost,poolDeposit:t.pool_deposit,priceMem:t.price_mem,priceStep:t.price_step};throw l(t)}catch(t){throw l(t)}}async fetchTxInfo(e){try{const{data:t,status:s}=await this._axiosInstance.get(`txs/${e}`);if(s===200)return{block:t.block,deposit:t.deposit,fees:t.fees,hash:t.hash,index:t.index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.slot.toString(),size:t.size};throw l(t)}catch(t){throw l(t)}}async fetchUTxOs(e){try{const{data:t,status:s}=await this._axiosInstance.get(`txs/${e}/utxos`);if(s===200){const a=t.outputs,i=[];return a.forEach(c=>{i.push(this.toUTxO(c,e))}),await Promise.all(i)}throw l(t)}catch(t){throw l(t)}}onTxConfirmed(e,t,s=100){let a=0;const i=setInterval(()=>{a>=s&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:s,status:a}=await this._axiosInstance.post("tx/submit",_(e),{headers:t});if(a===200)return s;throw l(s)}catch(t){throw l(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:s}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(s===200)return t.cbor;throw l(t)}async fetchNativeScriptJSON(e){const{data:t,status:s}=await this._axiosInstance.get(`scripts/${e}/json`);if(s===200)return t.json;throw l(t)}}class ar{_axiosInstance;constructor(e,t,s){const a=s.host??"ipfs.infura.io",i=s.port??5001,o=s.version??0;this._axiosInstance=tt.default.create({baseURL:`https://${a}:${i}/api/v${o}`,auth:{username:e,password:t}})}async uploadContent(e,t=!1){try{const s={"Content-Type":"multipart/form-data"},{data:a,status:i}=await this._axiosInstance.post(`add?recursive=${t}`,e,{headers:s});if(i===200)return a;throw l(a)}catch(s){throw l(s)}}}class nr{_axiosInstance;constructor(...e){typeof e[0]=="string"&&e[0].startsWith("http")?this._axiosInstance=tt.default.create({baseURL:e[0],headers:{Authorization:`Bearer ${e[1]}`}}):this._axiosInstance=tt.default.create({baseURL:`https://${e[0]}.koios.rest/api/v${e[2]??0}`,headers:{Authorization:`Bearer ${e[1]}`}})}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?pt(e):e,{data:s,status:a}=await this._axiosInstance.post("account_info",{_stake_addresses:[t]});if(a===200)return{poolId:s[0].delegated_pool,active:s[0].status==="registered",balance:s[0].total_balance.toString(),rewards:s[0].rewards_available,withdrawals:s[0].withdrawals};throw l(s)}catch(t){throw l(t)}}async fetchAddressUTxOs(e,t){try{const{data:s,status:a}=await this._axiosInstance.post("address_info",{_addresses:[e]});if(a===200){const i=s.flatMap(o=>o.utxo_set).map(o=>this.toUTxO(o,e));return t!==void 0?i.filter(o=>o.output.amount.find(c=>c.unit===t)!==void 0):i}throw l(s)}catch{return[]}}async fetchAssetAddresses(e){try{const{policyId:t,assetName:s}=J(e),{data:a,status:i}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${s}`);if(i===200)return a.map(o=>({address:o.payment_address,quantity:o.quantity}));throw l(a)}catch(t){throw l(t)}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:s}=J(e),{data:a,status:i}=await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${s}`);if(i===200)return{...a[0].minting_tx_metadata[721][t][Gt(s)]};throw l(a)}catch(t){throw l(t)}}async fetchBlockInfo(e){try{const{data:t,status:s}=await this._axiosInstance.post("block_info",{_block_hashes:[e]});if(s===200)return{confirmations:t[0].num_confirmations,epoch:t[0].epoch_no,epochSlot:t[0].epoch_slot.toString(),fees:t[0].total_fees??"",hash:t[0].hash,nextBlock:t[0].child_hash??"",operationalCertificate:t[0].op_cert,output:t[0].total_output??"0",previousBlock:t[0].parent_hash,size:t[0].block_size,slot:t[0].abs_slot.toString(),slotLeader:t[0].pool??"",time:t[0].block_time,txCount:t[0].tx_count,VRFKey:t[0].vrf_key};throw l(t)}catch(t){throw l(t)}}async fetchCollectionAssets(e,t=0){try{const{data:s,status:a}=await this._axiosInstance.get(`asset_policy_info?_asset_policy=${e}&limit=100&offset=${t}`);if(a===200)return{assets:s.map(i=>({unit:`${e}${i.asset_name}`,quantity:i.total_supply})),next:s.length===100?t+100:null};throw l(s)}catch(s){throw l(s)}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:s,status:a}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${Rt[1]}&_asset_name=${t}`);if(a===200)return s[0].payment_address;throw l(s)}catch(t){throw l(t)}}async fetchProtocolParameters(e){try{const{data:t,status:s}=await this._axiosInstance.get(`epoch_params?_epoch_no=${e}`);if(s===200)return{coinsPerUTxOSize:t[0].coins_per_utxo_size,collateralPercent:t[0].collateral_percent,decentralisation:t[0].decentralisation,epoch:t[0].epoch_no,keyDeposit:t[0].key_deposit,maxBlockExMem:t[0].max_block_ex_mem.toString(),maxBlockExSteps:t[0].max_block_ex_steps.toString(),maxBlockHeaderSize:t[0].max_bh_size,maxBlockSize:t[0].max_block_size,maxCollateralInputs:t[0].max_collateral_inputs,maxTxExMem:t[0].max_tx_ex_mem.toString(),maxTxExSteps:t[0].max_tx_ex_steps.toString(),maxTxSize:t[0].max_tx_size,maxValSize:t[0].max_val_size.toString(),minFeeA:t[0].min_fee_a,minFeeB:t[0].min_fee_b,minPoolCost:t[0].min_pool_cost,poolDeposit:t[0].pool_deposit,priceMem:t[0].price_mem,priceStep:t[0].price_step};throw l(t)}catch(t){throw l(t)}}async fetchTxInfo(e){var t,s;try{const{data:a,status:i}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(i===200)return{block:a[0].block_hash,deposit:a[0].deposit,fees:a[0].fee,hash:a[0].tx_hash,index:a[0].tx_block_index,invalidAfter:((t=a[0].invalid_after)==null?void 0:t.toString())??"",invalidBefore:((s=a[0].invalid_before)==null?void 0:s.toString())??"",slot:a[0].absolute_slot.toString(),size:a[0].tx_size};throw l(a)}catch(a){throw l(a)}}async fetchUTxOs(e){try{console.log("hi");const{data:t,status:s}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(s===200)return console.log(t[0]),t[0].outputs.map(i=>this.toUTxO(i,i.payment_addr.bech32));throw l(t)}catch(t){throw l(t)}}onTxConfirmed(e,t,s=100){let a=0;const i=setInterval(()=>{a>=s&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:s,status:a}=await this._axiosInstance.post("submittx",_(e),{headers:t});if(a===202)return s;throw l(s)}catch(t){throw l(t)}}toUTxO(e,t){var s,a;return{input:{outputIndex:e.tx_index,txHash:e.tx_hash},output:{address:t,amount:[{unit:"lovelace",quantity:e.value},...e.asset_list.map(i=>({unit:`${i.policy_id}${i.asset_name}`,quantity:`${i.quantity}`}))],dataHash:e.datum_hash??void 0,plutusData:((s=e.inline_datum)==null?void 0:s.bytes)??void 0,scriptRef:this.resolveScriptRef(e.reference_script),scriptHash:((a=e.reference_script)==null?void 0:a.hash)??void 0}}}resolveScriptRef=e=>{if(e){const t=e.type.startsWith("plutus")?{code:e.bytes,version:e.type.replace("plutus","")}:kt(Dt(e.bytes));return lt(t).to_hex()}}}class ir{_baseUrl;constructor(...e){this._baseUrl=Be(e[0])?ts[e[0]]:e[0]}async evaluateTx(e){const t=await this.open();return this.send(t,"EvaluateTx",{evaluate:e}),new Promise((s,a)=>{t.addEventListener("message",i=>{try{const{result:o}=JSON.parse(i.data);o.EvaluationResult?s(Object.keys(o.EvaluationResult).map(c=>({index:parseInt(c.split(":")[1],10),tag:c.split(":")[0].toUpperCase(),budget:{mem:o.EvaluationResult[c].memory,steps:o.EvaluationResult[c].steps}}))):a(o.EvaluationFailure),t.close()}catch(o){a(o)}},{once:!0})})}async onNextTx(e){const t=await this.open();return this.send(t,"AwaitAcquire",{}),t.addEventListener("message",s=>{const{result:a}=JSON.parse(s.data);if(a===null)return this.send(t,"AwaitAcquire",{});a.AwaitAcquired===void 0&&e(a),this.send(t,"NextTx",{})}),()=>t.close()}async submitTx(e){const t=await this.open();return this.send(t,"SubmitTx",{submit:e}),new Promise((s,a)=>{t.addEventListener("message",i=>{try{const{result:o}=JSON.parse(i.data);o.SubmitSuccess?s(o.SubmitSuccess.txId):a(o.SubmitFail),t.close()}catch(o){a(o)}},{once:!0})})}async open(){const e=new WebSocket(this._baseUrl);return await new Promise(t=>{e.addEventListener("open",()=>t(!0),{once:!0})}),e}send(e,t,s){e.send(JSON.stringify({version:"1.0",type:"jsonwsp/request",servicename:"ogmios",methodname:t,args:s}))}}class or{_axiosInstance;constructor(e,t,s,a=1){this._axiosInstance=tt.default.create({baseURL:`https://cardano-${e}.tangocrypto.com/${t}/v${a}`,headers:{"x-api-key":s}})}async evaluateTx(e){try{const{data:t,status:s}=await this._axiosInstance.post("transactions/evaluate",{tx:e,utxos:[]});if(s===200)return t.redeemers.map(a=>({index:a.index,tag:a.purpose.toUpperCase(),budget:{mem:a.unit_mem,steps:a.unit_steps}}));throw l(t)}catch(t){throw l(t)}}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?pt(e):e,{data:s,status:a}=await this._axiosInstance.get(`wallets/${t}`);if(a===200)return{poolId:s.pool_id,active:s.active,balance:s.controlled_total_stake,rewards:s.rewards_sum,withdrawals:s.withdrawals_sum};throw l(s)}catch(t){throw l(t)}}async fetchAddressUTxOs(e,t){const s=t!==void 0?`/assets/${t}`:"",a=`addresses/${e}${s}/utxos?size=50`,i=async(d="",h=[])=>{var A;const{data:g,status:m}=await this._axiosInstance.get(`${a}&cursor=${d}`);if(m===200)return g.cursor!==null&&((A=g.cursor)==null?void 0:A.length)>0?i(g.cursor,[...h,...g.data.map(u)]):g.data.map(u);throw l(g)},o=(d,h)=>{const g=[{unit:"lovelace",quantity:d.toString()}];return h.forEach(m=>{const A=Q(m.asset_name);g.push({unit:`${m.policy_id}${A}`,quantity:m.quantity.toString()})}),g},c=d=>{if(d){const h=d.type.startsWith("plutus")?{code:d.code,version:d.type.replace("plutus","")}:kt(Dt(d.json));return lt(h).to_hex()}},u=d=>{var h;return{input:{outputIndex:d.index,txHash:d.hash},output:{address:e,amount:o(d.value,d.assets),dataHash:void 0,plutusData:((h=d.inline_datum)==null?void 0:h.value_raw)??void 0,scriptRef:c(d.reference_script)}}};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const t=a=>({address:a.address,quantity:a.quantity.toString()}),s=async(a="",i=[])=>{var h;const{policyId:o,assetName:c}=J(e),{data:u,status:d}=await this._axiosInstance.get(`assets/${o}${c}/addresses?size=100&cursor=${a}`);if(d===200)return u.cursor!==null&&((h=u.cursor)==null?void 0:h.length)>0?s(u.cursor,[...i,...u.data.map(t)]):u.data.map(t);throw l(u)};try{return await s()}catch{return[]}}async fetchAssetMetadata(e){var t;try{const{policyId:s,assetName:a}=J(e),{data:i,status:o}=await this._axiosInstance.get(`assets/${s}${a}`);if(o===200)return{...(t=i.metadata.find(c=>c.label===721))==null?void 0:t.json[s][Gt(a)]};throw l(i)}catch(s){throw l(s)}}async fetchBlockInfo(e){try{const{data:t,status:s}=await this._axiosInstance.get(`blocks/${e}`);if(s===200)return{confirmations:t.confirmations,epoch:t.epoch_no,epochSlot:t.epoch_slot_no.toString(),fees:t.fees.toString(),hash:t.hash,nextBlock:t.next_block.toString()??"",operationalCertificate:t.op_cert,output:t.out_sum.toString()??"0",previousBlock:t.previous_block.toString(),size:t.size,slot:t.slot_no.toString(),slotLeader:t.slot_leader??"",time:Date.parse(t.time),txCount:t.tx_count,VRFKey:t.vrf_key};throw l(t)}catch(t){throw l(t)}}async fetchCollectionAssets(e,t=""){try{const{data:s,status:a}=await this._axiosInstance.get(`policies/${e}/assets?size=100&cursor=${t}`);if(a===200)return{assets:s.data.map(i=>({unit:`${i.policy_id}${i.asset_name}`,quantity:i.quantity})),next:s.cursor};throw l(s)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=Q(e.replace("$","")),{data:s,status:a}=await this._axiosInstance.get(`assets/${Rt[1]}${t}/addresses`);if(a===200)return s.data[0].address;throw l(s)}catch(t){throw l(t)}}async fetchProtocolParameters(e){try{const{data:t,status:s}=await this._axiosInstance.get(`epochs/${e}/parameters`);if(s===200)return{coinsPerUTxOSize:t.coins_per_utxo_size.toString(),collateralPercent:t.collateral_percent,decentralisation:t.decentralisation,epoch:t.epoch_no,keyDeposit:t.key_deposit.toString(),maxBlockExMem:t.max_block_ex_mem.toString(),maxBlockExSteps:t.max_block_ex_steps.toString(),maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem.toString(),maxTxExSteps:t.max_tx_ex_steps.toString(),maxTxSize:t.max_tx_size,maxValSize:t.max_val_size.toString(),minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost.toString(),poolDeposit:t.pool_deposit.toString(),priceMem:t.price_mem,priceStep:t.price_step};throw l(t)}catch(t){throw l(t)}}async fetchTxInfo(e){try{const{data:t,status:s}=await this._axiosInstance.get(`transactions/${e}`);if(s===200)return{block:t.block.hash,deposit:t.deposit,fees:t.fee,hash:t.hash,index:t.block_index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.block.slot_no.toString(),size:t.size};throw l(t)}catch(t){throw l(t)}}async fetchUTxOs(e){try{return console.log(e),[]}catch(t){throw l(t)}}onTxConfirmed(e,t,s=100){let a=0;const i=setInterval(()=>{a>=s&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/json"},{data:s,status:a}=await this._axiosInstance.post("transactions/submit",{tx:e},{headers:t});if(a===200)return s.tx_id;throw l(s)}catch(t){throw l(t)}}}class cr{_axiosInstance;_amountsAsStrings={headers:{"amounts-as-strings":"true"}};submitUrl;constructor({network:e,apiKey:t,turboSubmit:s=!1}){this._axiosInstance=tt.default.create({baseURL:`https://${e}.gomaestro-api.org/v1`,headers:{"api-key":t}}),this.submitUrl=s?"txmanager/turbosubmit":"txmanager"}async evaluateTx(e){try{const{data:t,status:s}=await this._axiosInstance.post("transactions/evaluate",{cbor:e});if(s===200){const a={spend:"SPEND",mint:"MINT",cert:"CERT",wdrl:"REWARD"};return t.map(o=>{const c=o.ex_units,u=o.redeemer_index,d=a[o.redeemer_tag];return{budget:c,index:u,tag:d}})}throw l(t)}catch(t){throw l(t)}}async fetchAccountInfo(e){const t=e.startsWith("addr")?pt(e):e;try{const{data:s,status:a}=await this._axiosInstance.get(`accounts/${t}`,this._amountsAsStrings);if(a===200){const i=s.data;return{poolId:i.delegated_pool,active:i.registered,balance:i.total_balance,rewards:i.rewards_available,withdrawals:i.total_withdrawn}}throw l(s)}catch(s){throw l(s)}}async fetchAddressUTxOs(e,t){const s=(()=>e.startsWith("addr_vkh")||e.startsWith("addr_shared_vkh")?`addresses/cred/${e}`:`addresses/${e}`)(),a=t?`&asset=${t}`:"",i=async(o=null,c=[])=>{const u=o===null?"":`&cursor=${o}`,{data:d,status:h}=await this._axiosInstance.get(`${s}/utxos?count=100${a}${u}`,this._amountsAsStrings);if(h===200){const m=d.data.map(this.toUTxO),A=[...c,...m],I=d.next_cursor;return I==null?A:i(I,A)}throw l(d)};try{return await i()}catch{return[]}}async fetchAssetAddresses(e){const{policyId:t,assetName:s}=J(e),a=async(i=null,o=[])=>{const c=i===null?"":`&cursor=${i}`,{data:u,status:d}=await this._axiosInstance.get(`assets/${t}${s}/addresses?count=100${c}`,this._amountsAsStrings);if(d===200){const g=u.data.map(I=>({address:I.address,quantity:I.amount})),m=u.next_cursor,A=[...o,...g];return m==null?A:a(m,A)}throw l(u)};try{return await a()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:s}=J(e),{data:a,status:i}=await this._axiosInstance.get(`assets/${t}${s}`);if(i===200){const o=a.data;return{...o.asset_standards.cip25_metadata,...o.asset_standards.cip68_metadata}}throw l(a)}catch(t){throw l(t)}}async fetchBlockInfo(e){var t;try{const{data:s,status:a}=await this._axiosInstance.get(`blocks/${e}`,this._amountsAsStrings);if(a===200){const i=s.data;return{confirmations:i.confirmations,epoch:i.epoch,epochSlot:i.epoch_slot.toString(),fees:i.total_fees,hash:i.hash,nextBlock:i.next_block??"",operationalCertificate:(t=i.operational_certificate)==null?void 0:t.hot_vkey,output:i.total_output_lovelace??"0",previousBlock:i.previous_block,size:i.size,slot:i.absolute_slot.toString(),slotLeader:i.block_producer??"",time:Date.parse(i.timestamp)/1e3,txCount:i.tx_hashes.length,VRFKey:n.VRFVKey.from_hex(i.vrf_key).to_bech32("vrf_vk")}}throw l(s)}catch(s){throw l(s)}}async fetchCollectionAssets(e,t){try{const{data:s,status:a}=await this._axiosInstance.get(`policy/${e}/assets?count=100${t?`&cursor=${t}`:""}`);if(a===200)return{assets:s.data.map(o=>({unit:e+o.asset_name,quantity:o.total_supply})),next:s.next_cursor};throw l(s)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=e.charAt(0)==="$"?e.substring(1):e,{data:s,status:a}=await this._axiosInstance.get(`ecosystem/adahandle/${t}`);if(a===200)return s.data;throw l(s)}catch(t){throw l(t)}}async fetchProtocolParameters(e=Number.NaN){if(!isNaN(e))throw new Error("Maestro only supports fetching Protocol parameters of the latest completed epoch.");const t=s=>{const a=s.indexOf("/");return parseInt(s.slice(0,a))/parseInt(s.slice(a+1))};try{const{data:s,status:a}=await this._axiosInstance.get("protocol-params");if(a===200){const i=s.data;try{const{data:o,status:c}=await this._axiosInstance.get("epochs/current");if(c===200){const u=o.data;return{coinsPerUTxOSize:i.coins_per_utxo_byte.toString(),collateralPercent:parseInt(i.collateral_percentage),decentralisation:0,epoch:parseInt(u.epoch_no),keyDeposit:i.stake_key_deposit.toString(),maxBlockExMem:i.max_execution_units_per_block.memory.toString(),maxBlockExSteps:i.max_execution_units_per_block.steps.toString(),maxBlockHeaderSize:parseInt(i.max_block_header_size),maxBlockSize:parseInt(i.max_block_body_size),maxCollateralInputs:parseInt(i.max_collateral_inputs),maxTxExMem:i.max_execution_units_per_transaction.memory.toString(),maxTxExSteps:i.max_execution_units_per_transaction.steps.toString(),maxTxSize:parseInt(i.max_tx_size),maxValSize:i.max_value_size.toString(),minFeeA:i.min_fee_coefficient,minFeeB:i.min_fee_constant,minPoolCost:i.min_pool_cost.toString(),poolDeposit:i.pool_deposit.toString(),priceMem:t(i.prices.memory),priceStep:t(i.prices.steps)}}throw l(o)}catch(o){throw l(o)}}throw l(s)}catch(s){throw l(s)}}async fetchTxInfo(e){try{const{data:t,status:s}=await this._axiosInstance.get(`transactions/${e}`);if(s===200){const a=t.data;return{block:a.block_hash,deposit:a.deposit.toString(),fees:a.fee.toString(),hash:a.tx_hash,index:a.block_tx_index,invalidAfter:a.invalid_hereafter??"",invalidBefore:a.invalid_before??"",slot:a.block_absolute_slot.toString(),size:a.size-1}}throw l(t)}catch(t){throw l(t)}}async fetchUTxOs(e){try{const{data:t,status:s}=await this._axiosInstance.get(`transactions/${e}`,this._amountsAsStrings);if(s===200)return t.data.outputs.map(this.toUTxO);throw l(t)}catch(t){throw l(t)}}onTxConfirmed(e,t,s=100){let a=0;const i=setInterval(()=>{a>=s&&clearInterval(i),this.fetchTxInfo(e).then(o=>{this.fetchBlockInfo(o.block).then(c=>{(c==null?void 0:c.confirmations)>0&&(clearInterval(i),t())}).catch(()=>{a+=1})}).catch(()=>{a+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:s,status:a}=await this._axiosInstance.post(this.submitUrl,_(e),{headers:t});if(a===202)return s;throw l(s)}catch(t){throw l(t)}}toUTxO=e=>{var t,s,a;return{input:{outputIndex:e.index,txHash:e.tx_hash},output:{address:e.address,amount:e.assets.map(i=>({unit:i.unit,quantity:i.amount})),dataHash:(t=e.datum)==null?void 0:t.hash,plutusData:(s=e.datum)==null?void 0:s.bytes,scriptRef:this.resolveScript(e),scriptHash:(a=e.reference_script)==null?void 0:a.hash}}};resolveScript=e=>{if(e.reference_script){const t=e.reference_script.type==="native"?e.reference_script.json:{code:e.reference_script.bytes,version:e.reference_script.type.replace("plutusv","V")};return lt(t).to_hex()}else return}}class ur{static withOneSignature(e){const t=R(st(e));return xt(t).to_hex()}static withAtLeastNSignatures(e,t){const s=n.NativeScripts.new();e.forEach(i=>{const o=R(st(i));s.add(xt(o))});const a=n.ScriptNOfK.new(t,s);return n.NativeScript.new_script_any(a).to_hex()}static withAnySignature(e){const t=n.NativeScripts.new();e.forEach(a=>{const i=R(st(a));t.add(xt(i))});const s=n.ScriptAny.new(t);return n.NativeScript.new_script_any(s).to_hex()}static withAllSignatures(e){const t=n.NativeScripts.new();e.forEach(a=>{const i=R(st(a));t.add(xt(i))});const s=n.ScriptAll.new(t);return n.NativeScript.new_script_any(s).to_hex()}static fromNativeScript(e){return Tt(e).to_hex()}}function et(r,e,t,s){var a=arguments.length,i=a<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(r,e,t,s);else for(var c=r.length-1;c>=0;c--)(o=r[c])&&(i=(a<3?o(i):a>3?o(e,t,i):o(e,t))||i);return a>3&&i&&Object.defineProperty(e,t,i),i}const dr=r=>class extends r{__visits=[]},rt=()=>function(r,e,t){const s=t.value;t.value=function(...a){const i=s.call(this,...a);return this.__visits&&this.__visits.push(e),i}};exports.Transaction=class{_changeAddress;_txOutputs=new Map;_recipients=new Map;_totalBurns=new Map;_totalMints=new Map;_era;_initiator;_mintBuilder;_protocolParameters;_txBuilder;_txCertificates;_txInputsBuilder;_txWithdrawals;constructor(e={}){this._era=e.era,this._initiator=e.initiator,this._mintBuilder=n.MintBuilder.new(),this._protocolParameters=e.parameters??P,this._txBuilder=St(e.parameters),this._txCertificates=n.Certificates.new(),this._txInputsBuilder=n.TxInputsBuilder.new(),this._txWithdrawals=n.Withdrawals.new()}static attachMetadata(e,t,s="BABBAGE"){var o;const a=H(e),i=a.auxiliary_data()??n.AuxiliaryData.new();if(i.set_metadata(n.GeneralTransactionMetadata.from_hex(t)),i.set_prefer_alonzo_format(s==="ALONZO"),n.hash_auxiliary_data(i).to_hex()!==((o=a.body().auxiliary_data_hash())==null?void 0:o.to_hex()))throw new Error("[Transaction] attachMetadata: The metadata hash does not match the auxiliary data hash.");return n.Transaction.new(a.body(),a.witness_set(),i).to_hex()}static deattachMetadata(e){const t=H(e);return n.Transaction.new(t.body(),t.witness_set(),void 0).to_hex()}static maskMetadata(e,t="BABBAGE"){var i;const s=H(e),a=(i=s.auxiliary_data())==null?void 0:i.metadata();if(a!==void 0){const o=n.GeneralTransactionMetadata.new();for(let u=0;u<a.len();u+=1){const d=a.keys().get(u),h=a.get(d);o.insert(d,n.TransactionMetadatum.from_hex("0".repeat(((h==null?void 0:h.to_hex())??"").length)))}const c=s.auxiliary_data();return c!==void 0&&(c.set_metadata(o),c.set_prefer_alonzo_format(t==="ALONZO")),n.Transaction.new(s.body(),s.witness_set(),c).to_hex()}return e}static readMetadata(e){var s,a;return((a=(s=H(e).auxiliary_data())==null?void 0:s.metadata())==null?void 0:a.to_hex())??""}static writeMetadata(e,t,s="BABBAGE"){const a=H(e),i=a.auxiliary_data()??n.AuxiliaryData.new();return i.set_metadata(n.GeneralTransactionMetadata.from_hex(t)),i.set_prefer_alonzo_format(s==="ALONZO"),n.Transaction.new(a.body(),a.witness_set(),i).to_hex()}get size(){return this._txBuilder.full_size()}async build(){try{return(this._mintBuilder.has_plutus_scripts()||this.notVisited("redeemValue")===!1)&&(await this.addRequiredSignersIfNeeded(),await this.addCollateralIfNeeded()),await this.forgeAssetsIfNeeded(),await this.addTxInputsAsNeeded(),await this.addChangeAddress(),this._txBuilder.build_tx().to_hex()}catch(e){throw new Error(`[Transaction] An error occurred during build: ${e}.`)}}burnAsset(e,t,s){const a=this._totalBurns.has(t.unit)?n.BigNum.from_str(this._totalBurns.get(t.unit)??"0").checked_add(n.BigNum.from_str(t.quantity)).to_str():t.quantity;return this._mintBuilder.add_asset(xe(e,s),n.AssetName.new(_(t.unit.slice(V))),n.Int.new_negative(n.BigNum.from_str(t.quantity))),this._totalBurns.set(t.unit,a),this}delegateStake(e,t){const s=n.Certificate.new_stake_delegation(n.StakeDelegation.new(n.StakeCredential.from_keyhash(R(it(e))),n.Ed25519KeyHash.from_bech32(t)));return this._txCertificates.add(s),this}deregisterStake(e){const t=n.Certificate.new_stake_deregistration(n.StakeDeregistration.new(n.StakeCredential.from_keyhash(R(it(e)))));return this._txCertificates.add(t),this}mintAsset(e,t,s){var d,h;const a=(g,m)=>{const A=typeof g=="string"?Dt(g).hash().to_hex():i(g).hash().to_hex(),I=Q(m.assetName);return{unit:`${A}${I}`,quantity:m.assetQuantity}},i=g=>{if("code"in g)return dt(g.code,g.version);const m=F(g);if(m.output().has_script_ref()){const A=m.output().script_ref();if(A.is_plutus_script()){const I=Ve(A);return dt(I.code,I.version)}}throw new Error(`[Transaction] No plutus script reference found in UTxO: ${m.input().transaction_id().to_hex()}`)},o=a(e,t),u=n.BigNum.from_str(((d=this._totalMints.get(o.unit))==null?void 0:d.assetQuantity)??"0").checked_add(n.BigNum.from_str(o.quantity));return this._mintBuilder.add_asset(xe(e,s),n.AssetName.new(_(Q(t.assetName))),n.Int.new(n.BigNum.from_str(o.quantity))),this._recipients.has(t.recipient)?(h=this._recipients.get(t.recipient))==null||h.push(o):this._recipients.set(t.recipient,[o]),this._totalMints.set(o.unit,{...t,assetQuantity:u.to_str()}),this}redeemValue(e){const t={tag:"SPEND",budget:nt,index:this._txInputsBuilder.inputs().len(),data:{alternative:0,fields:[]},...e.redeemer},s=F(e.value),a=e.datum?n.PlutusWitness.new_with_ref(Ot(e.script),qs(e.datum),Kt(t)):n.PlutusWitness.new_with_ref_without_datum(Ot(e.script),Kt(t));return this._txInputsBuilder.add_plutus_script_input(a,s.input(),s.output().amount()),this}registerStake(e){const t=n.Certificate.new_stake_registration(n.StakeRegistration.new(n.StakeCredential.from_keyhash(R(it(e)))));return this._txCertificates.add(t),this}registerPool(e){const t=n.Certificate.new_pool_registration(n.PoolRegistration.new(Vs(e)));return this._txCertificates.add(t),this}retirePool(e,t){const s=n.Certificate.new_pool_retirement(n.PoolRetirement.new(n.Ed25519KeyHash.from_bech32(e),t));return this._txCertificates.add(s),this}sendAssets(e,t){const s=$(t),a=s.multiasset();if(s.is_zero()||a===void 0)return this;const i=Ct(e).next(),o=s.coin().is_zero()?i.with_asset_and_min_required_coin_by_utxo_cost(a,Ht(this._protocolParameters.coinsPerUTxOSize)).build():i.with_coin_and_asset(s.coin(),a).build();return t.forEach(c=>{this.setTxOutput(c)}),this._txBuilder.add_output(o),this}sendLovelace(e,t){const a=Ct(e).next().with_coin(n.BigNum.from_str(t)).build();return this.setTxOutput({unit:"lovelace",quantity:t}),this._txBuilder.add_output(a),this}sendToken(e,t,s){return this.sendAssets(e,[{quantity:s,unit:es[t]}]),this}sendValue(e,t){const s=$(t.output.amount),i=Ct(e).next().with_value(s).build();return t.output.amount.forEach(o=>{this.setTxOutput(o)}),this._txBuilder.add_output(i),this}setChangeAddress(e){return this._changeAddress=M(e),this}setCollateral(e){const t=Ce(e);return this._txBuilder.set_collateral(t),this}setMetadata(e,t){return this._txBuilder.add_json_metadatum_with_schema(n.BigNum.from_str(e.toString()),JSON.stringify(t),n.MetadataJsonSchema.NoConversions),this}setRequiredSigners(e){return Array.from(new Set(e.map(s=>s.startsWith("addr")?st(s):it(s)).map(s=>R(s)))).forEach(s=>{this._txBuilder.add_required_signer(s)}),this}setTimeToStart(e){return this._txBuilder.set_validity_start_interval_bignum(n.BigNum.from_str(e)),this}setTimeToExpire(e){return this._txBuilder.set_ttl_bignum(n.BigNum.from_str(e)),this}setTxInputs(e){return e.map(t=>F(t)).forEach(t=>{this._txInputsBuilder.add_input(t.output().address(),t.input(),t.output().amount())}),this}setTxRefInputs(e){return e.map(t=>F(t)).forEach(t=>{this._txBuilder.add_reference_input(t.input())}),this}withdrawRewards(e,t){const s=Fe(e);return s!==void 0&&this._txWithdrawals.insert(s,n.BigNum.from_str(t)),this}async addBurnInputsIfNeeded(){if(this._initiator&&this._totalBurns.size>0&&this.notVisited("setTxInputs")){const e=await this._initiator.getUsedUTxOs();Ee(this._totalBurns,e.map(s=>Qt(s))).map(s=>F(s)).forEach(s=>{this._txInputsBuilder.add_input(s.output().address(),s.input(),s.output().amount())})}}async addChangeAddress(){if(this._initiator&&this._changeAddress===void 0){const e=await this._initiator.getUsedAddress();this._txBuilder.add_change_if_needed(e)}else this._changeAddress!==void 0&&this._txBuilder.add_change_if_needed(this._changeAddress)}async addCollateralIfNeeded(){if(this._initiator&&this.notVisited("setCollateral")){const e=await this._initiator.getUsedCollateral();this._txBuilder.set_collateral(Ce(e))}}async addRequiredSignersIfNeeded(){if(this._initiator&&this.notVisited("setRequiredSigners")){const e=await this._initiator.getUsedAddress(),t=st(e.to_bech32());this._txBuilder.add_required_signer(R(t))}}async addTxInputsAsNeeded(){if(this.notVisited("setTxInputs")){const e=await this.filterAvailableUTxOs();Se(this._txOutputs,e.map(s=>Qt(s))).map(s=>F(s)).forEach(s=>{this._txInputsBuilder.add_input(s.output().address(),s.input(),s.output().amount())})}if(this._txBuilder.set_inputs(this._txInputsBuilder),(this._mintBuilder.has_native_scripts()||this._mintBuilder.has_plutus_scripts())&&this._txBuilder.set_mint_builder(this._mintBuilder),this._txCertificates.len()>0&&this._txBuilder.set_certs(this._txCertificates),this._txWithdrawals.len()>0&&this._txBuilder.set_withdrawals(this._txWithdrawals),this._txBuilder.get_mint_builder()||this.notVisited("redeemValue")===!1){const e=this._era!==void 0?Zt[this._era]:Zt.BABBAGE;this._txBuilder.calc_script_data_hash(e)}}async forgeAssetsIfNeeded(){const e=(t,s)=>{const a=t.data.assetName,i=t.data.metadata,o=t.unit.slice(0,V);if(t.data.label==="777")return i;if(s&&s[o]){const{[o]:c,...u}=s,d={[a]:i,...c};return{[o]:{...d},...u}}return s!==void 0?{[o]:{[a]:i},...s}:{[o]:{[a]:i}}};await this.addBurnInputsIfNeeded(),Array.from(this._totalMints,t=>({unit:t[0],data:t[1]})).reduce((t,s)=>t.set(s.data.label,e(s,t.get(s.data.label))),new Map).forEach((t,s)=>{this._txBuilder.add_json_metadatum(n.BigNum.from_str(s),JSON.stringify(t))}),this.addMintOutputs()}async filterAvailableUTxOs(e=[]){return this._initiator===void 0?[]:(await this._initiator.getUsedUTxOs()).filter(s=>e.find(a=>a.input.txHash===s.input().transaction_id().to_hex())===void 0)}addMintOutputs(){this._recipients.forEach((e,t)=>{const a=$(e).multiasset();if(a!==void 0){const o=Ct(t).next().with_asset_and_min_required_coin_by_utxo_cost(a,Ht(this._protocolParameters.coinsPerUTxOSize)).build();this._txBuilder.add_output(o)}})}notVisited(e){return this.__visits.includes(e)===!1}setTxOutput(e){const s=n.BigNum.from_str(this._txOutputs.get(e.unit)??"0").checked_add(n.BigNum.from_str(e.quantity)).to_str();this._txOutputs.set(e.unit,s)}};et([rt()],exports.Transaction.prototype,"mintAsset",null);et([rt()],exports.Transaction.prototype,"redeemValue",null);et([rt()],exports.Transaction.prototype,"sendAssets",null);et([rt()],exports.Transaction.prototype,"sendValue",null);et([rt()],exports.Transaction.prototype,"setCollateral",null);et([rt()],exports.Transaction.prototype,"setRequiredSigners",null);et([rt()],exports.Transaction.prototype,"setTxInputs",null);exports.Transaction=et([dr],exports.Transaction);const lr=(r,e,t)=>{const s=new Map(e);s.set("lovelace",String(Number(s.get("lovelace"))+Number(t)));const a=new Map;for(let m=0;m<r.length;m++)a.set(m,r[m]);const i=new Set,o=new Set,c=new Set,u=new Set,d=new Set;for(let m=0;m<r.length;m++)switch(r[m].output.amount.length){case 1:{o.add(m);break}case 2:{c.add(m);break}case 3:{u.add(m);break}default:{d.add(m);break}}const h=(m,A,I)=>{const C=a.get(m);if(!C)return;const D=hr(C,A);if(Number(D)>0){i.add(m),I.delete(m);for(const f of C.output.amount)s.set(f.unit,String(Number(s.get(f.unit))-Number(f.quantity)))}};for(const m of s.keys())if(m!="lovelace"){for(const A of c){const I=s.get(m);if(!I||Number(I)<=0)break;h(A,m,c)}for(const A of u){const I=s.get(m);if(!I||Number(I)<=0)break;h(A,m,u)}for(const A of d){const I=s.get(m);if(!I||Number(I)<=0)break;h(A,m,d)}}for(const m of o){const A=s.get("lovelace");if(!A||Number(A)<=0)break;h(m,"lovelace",o)}for(const m of c){const A=s.get("lovelace");if(!A||Number(A)<=0)break;h(m,"lovelace",c)}for(const m of u){const A=s.get("lovelace");if(!A||Number(A)<=0)break;h(m,"lovelace",u)}for(const m of d){const A=s.get("lovelace");if(!A||Number(A)<=0)break;h(m,"lovelace",d)}for(const m of s.keys())if(Number(s.get(m))>0)return[];const g=[];for(const m of i){const A=a.get(m);A&&g.push(A)}return g},hr=(r,e)=>{for(const t of r.output.amount)if(t.unit==e)return t.quantity;return"0"};class gr{txHex="";txBuilder=St();txEvaluationMultiplier=1.1;_protocolParams=P;txOutput;addingScriptInput=!1;addingPlutusMint=!1;isHydra=!1;meshTxBuilderBody;mintItem;txInQueueItem;collateralQueueItem;refScriptTxInQueueItem;reset=()=>(this.txHex="",this.txBuilder=St(),this.txEvaluationMultiplier=1.1,this._protocolParams=P,this.txOutput=void 0,this.addingScriptInput=!1,this.addingPlutusMint=!1,this.mintItem=void 0,this.txInQueueItem=void 0,this.collateralQueueItem=void 0,this.refScriptTxInQueueItem=void 0,this.meshTxBuilderBody=this.emptyTxBuilderBody(),this);emptyTxBuilderBody=()=>({inputs:[],outputs:[],extraInputs:[],selectionThreshold:0,collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],signingKey:[]});constructor(){this.meshTxBuilderBody=this.emptyTxBuilderBody()}completeSync=e=>(e?this.meshTxBuilderBody=e:this.queueAllLastItem(),this.serializeTxBody(this.meshTxBuilderBody));completeSigning=()=>{const{signingKey:e}=this.meshTxBuilderBody;return e.length>0&&this.addAllSigningKeys(e),this.txHex};serializeTxBody=e=>{const{inputs:t,outputs:s,extraInputs:a,selectionThreshold:i,collaterals:o,referenceInputs:c,mints:u,changeAddress:d,certificates:h,validityRange:g,requiredSignatures:m,metadata:A}=e;if(this.isHydra?this.protocolParams({minFeeA:0,minFeeB:0,priceMem:0,priceStep:0,collateralPercent:0,coinsPerUTxOSize:"0"}):this.protocolParams({}),a.length>0&&this.addUtxosFrom(a,String(i)),this.removeDuplicateInputs(),this.meshTxBuilderBody.mints.sort((I,C)=>I.policyId.localeCompare(C.policyId)),this.meshTxBuilderBody.inputs.sort((I,C)=>I.txIn.txHash===C.txIn.txHash?I.txIn.txIndex-C.txIn.txIndex:I.txIn.txHash.localeCompare(C.txIn.txHash)),this.addAllInputs(t),this.addAllOutputs(s),this.addAllCollaterals(o),this.addAllReferenceInputs(c),this.addAllMints(u),this.addAllCertificates(h),this.addValidityRange(g),this.addAllRequiredSignatures(m),this.addAllMetadata(A),this.addCostModels(),d){const I=this.meshTxBuilderBody.collaterals.map(f=>{var w,B;return((B=(w=f.txIn.amount)==null?void 0:w.find(k=>k.unit==="lovelace"))==null?void 0:B.quantity)||"0"}).reduce((f,w)=>f+parseInt(w),0),C=Math.ceil(this._protocolParams.collateralPercent*Number(Number(this.txBuilder.min_fee().checked_add(n.BigNum.from_str("10000")).to_js_value()))/100);let D=!1;if(I-C>0){const f=n.TransactionOutput.new(n.Address.from_bech32(d),n.Value.new(n.BigNum.from_str(String(C))));I-C>Number(n.min_ada_for_output(f,n.DataCost.new_coins_per_byte(n.BigNum.from_str(this._protocolParams.coinsPerUTxOSize))).to_js_value())&&(this.txBuilder.set_collateral_return(n.TransactionOutput.new(n.Address.from_bech32(d),n.Value.new(n.BigNum.from_str(String(I))))),this.txBuilder.set_total_collateral(n.BigNum.from_str(String(I))),D=!0)}this.addChange(d),D&&this.addCollateralReturn(d)}return this.buildTx(),this};txIn=(e,t,s,a)=>(this.txInQueueItem&&this.queueInput(),this.addingScriptInput?this.txInQueueItem={type:"Script",txIn:{txHash:e,txIndex:t,amount:s,address:a},scriptTxIn:{}}:this.txInQueueItem={type:"PubKey",txIn:{txHash:e,txIndex:t,amount:s,address:a}},this.addingScriptInput=!1,this);txInScript=(e,t="V2")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Datum value attempted to be called a non script input");return this.txInQueueItem.scriptTxIn.scriptSource={type:"Provided",script:{code:e,version:t}},this};txInDatumValue=(e,t="Mesh")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Datum value attempted to be called a non script input");let s=e;return t==="JSON"&&(s=this.castRawDataToJsonString(e)),t==="Mesh"?(this.txInQueueItem.scriptTxIn.datumSource={type:"Provided",data:{type:t,content:e}},this):(this.txInQueueItem.scriptTxIn.datumSource={type:"Provided",data:{type:t,content:s}},this)};txInInlineDatumPresent=()=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Inline datum present attempted to be called a non script input");const{txHash:e,txIndex:t}=this.txInQueueItem.txIn;return e&&t.toString()&&(this.txInQueueItem.scriptTxIn.datumSource={type:"Inline",txHash:e,txIndex:t}),this};txInRedeemerValue=(e,t={...nt},s="Mesh")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Spending tx in reference redeemer attempted to be called a non script input");let a=e;return s==="Mesh"?(this.txInQueueItem.scriptTxIn.redeemer={data:{type:s,content:e},exUnits:t},this):(s==="JSON"&&(a=this.castRawDataToJsonString(e)),this.txInQueueItem.scriptTxIn.redeemer={data:{type:s,content:a},exUnits:t},this)};txOut=(e,t)=>(this.txOutput&&(this.meshTxBuilderBody.outputs.push(this.txOutput),this.txOutput=void 0),this.txOutput={address:e,amount:t},this);txOutDatumHashValue=(e,t="Mesh")=>{let s=e;if(this.txOutput){if(t==="Mesh")return this.txOutput.datum={type:"Hash",data:{type:t,content:s}},this;t==="JSON"&&(s=this.castRawDataToJsonString(e)),this.txOutput.datum={type:"Hash",data:{type:t,content:s}}}return this};txOutInlineDatumValue=(e,t="Mesh")=>{let s=e;if(this.txOutput){if(t==="Mesh")return this.txOutput.datum={type:"Inline",data:{type:t,content:s}},this;t==="JSON"&&(s=this.castRawDataToJsonString(e)),this.txOutput.datum={type:"Inline",data:{type:t,content:s}}}return this};txOutReferenceScript=(e,t="V2")=>(this.txOutput&&(this.txOutput.referenceScript={code:e,version:t}),this);spendingPlutusScriptV2=()=>(this.addingScriptInput=!0,this);spendingTxInReference=(e,t,s,a="V2")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Spending tx in reference attempted to be called a non script input");return this.txInQueueItem.scriptTxIn.scriptSource={type:"Inline",txInInfo:{txHash:e,txIndex:t,spendingScriptHash:s,version:a}},this};spendingReferenceTxInInlineDatumPresent=()=>(this.txInInlineDatumPresent(),this);spendingReferenceTxInRedeemerValue=(e,t={...nt})=>(this.txInRedeemerValue(e,t),this);readOnlyTxInReference=(e,t)=>(this.meshTxBuilderBody.referenceInputs.push({txHash:e,txIndex:t}),this);mintPlutusScriptV2=()=>(this.addingPlutusMint=!0,this);mint=(e,t,s)=>(this.mintItem&&this.queueMint(),this.mintItem={type:this.addingPlutusMint?"Plutus":"Native",policyId:t,assetName:s,amount:e},this.addingPlutusMint=!1,this);mintingScript=(e,t="V2")=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.type)throw Error("Mint information missing");return this.mintItem.scriptSource={type:"Provided",script:{code:e,version:t}},this};mintTxInReference=(e,t,s="V2")=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.type)throw Error("Mint information missing");if(this.mintItem.type=="Native")throw Error("Mint tx in reference can only be used on plutus script tokens");if(!this.mintItem.policyId)throw Error("PolicyId information missing from mint asset");return this.mintItem.scriptSource={type:"Reference Script",txHash:e,txIndex:t,version:s},this};mintReferenceTxInRedeemerValue=(e,t={...nt},s="Mesh")=>{if(!this.mintItem)throw Error("Undefined mint");if(this.mintItem.type=="Native")throw Error("Mint tx in reference can only be used on plutus script tokens");if(this.mintItem.type=="Plutus"){if(!this.mintItem.policyId)throw Error("PolicyId information missing from mint asset");let a=e;if(s==="Mesh")return this.mintItem.redeemer={data:{type:s,content:a},exUnits:t},this;s==="JSON"&&(a=this.castRawDataToJsonString(e)),this.mintItem.redeemer={data:{type:s,content:a},exUnits:t}}return this};mintRedeemerValue=(e,t={...nt},s="Mesh")=>(this.mintReferenceTxInRedeemerValue(e,t,s),this);requiredSignerHash=e=>(this.meshTxBuilderBody.requiredSignatures.push(e),this);txInCollateral=(e,t,s,a)=>(this.collateralQueueItem&&this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem),this.collateralQueueItem={type:"PubKey",txIn:{txHash:e,txIndex:t,amount:s,address:a}},this);registerPoolCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"RegisterPool",poolParams:e}),this);registerStakeCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"RegisterStake",stakeKeyHash:e}),this);delegateStakeCertificate=(e,t)=>(this.meshTxBuilderBody.certificates.push({type:"DelegateStake",stakeKeyHash:e,poolId:t}),this);deregisterStakeCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"DeregisterStake",stakeKeyHash:e}),this);retirePoolCertificate=(e,t)=>(this.meshTxBuilderBody.certificates.push({type:"RetirePool",poolId:e,epoch:t}),this);changeAddress=e=>(this.meshTxBuilderBody.changeAddress=e,this);invalidBefore=e=>(this.meshTxBuilderBody.validityRange.invalidBefore=e,this);invalidHereafter=e=>(this.meshTxBuilderBody.validityRange.invalidHereafter=e,this);metadataValue=(e,t)=>(this.meshTxBuilderBody.metadata.push({tag:e,metadata:t}),this);protocolParams=e=>{const t={...P,...e};return this._protocolParams=t,this.txBuilder=St(t),this};signingKey=e=>(this.meshTxBuilderBody.signingKey.push(e),this);selectUtxosFrom=(e,t=5e6)=>(this.meshTxBuilderBody.extraInputs=e,this.meshTxBuilderBody.selectionThreshold=t,this);addUtxosFrom=(e,t)=>{const s=this.meshTxBuilderBody.outputs.reduce((i,o)=>(o.amount.forEach(u=>{const{unit:d,quantity:h}=u,g=Number(i.get(d))||0;i.set(d,String(g+Number(h)))}),i),new Map);this.meshTxBuilderBody.inputs.reduce((i,o)=>{const c=o.txIn.amount;return c==null||c.forEach(u=>{const{unit:d,quantity:h}=u,g=Number(i.get(d))||0;i.set(d,String(g-Number(h)))}),i},s),this.meshTxBuilderBody.mints.reduce((i,o)=>{const c={unit:o.policyId+o.assetName,quantity:String(o.amount)},u=Number(i.get(c.unit))||0;return i.set(c.unit,String(u-Number(c.quantity))),i},s),lr(e,s,t).forEach(i=>{this.addTxIn({type:"PubKey",txIn:{txHash:i.input.txHash,txIndex:i.input.outputIndex,amount:i.output.amount,address:i.output.address}})})};addAllSigningKeys=e=>{if(e.length>0){const t=n.Vkeywitnesses.new(),s=n.Transaction.from_hex(this.txHex),a=s.body();e.forEach(c=>{const u=c.slice(0,4)==="5820"?c.slice(4):c,d=n.PrivateKey.from_hex(u),h=n.make_vkey_witness(n.hash_transaction(a),d);t.add(h)});const i=s.witness_set();i.set_vkeys(t);const o=n.Transaction.new(a,i,s.auxiliary_data());this.txHex=o.to_hex()}};buildTx=()=>{const e=this.txBuilder.build_tx();this.txHex=e.to_hex()};queueInput=()=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="Script")if(this.txInQueueItem.scriptTxIn){if(!this.txInQueueItem.scriptTxIn.datumSource)throw Error("Script input does not contain datum information");if(!this.txInQueueItem.scriptTxIn.redeemer)throw Error("Script input does not contain redeemer information");if(!this.txInQueueItem.scriptTxIn.scriptSource)throw Error("Script input does not contain script information")}else throw Error("Script input does not contain script, datum, or redeemer information");this.meshTxBuilderBody.inputs.push(this.txInQueueItem),this.txInQueueItem=void 0};queueMint=()=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.scriptSource)throw Error("Missing mint script information");this.meshTxBuilderBody.mints.push(this.mintItem),this.mintItem=void 0};makePlutusScriptSource=e=>{const t=n.ScriptHash.from_hex(e.spendingScriptHash),s=n.TransactionInput.new(n.TransactionHash.from_hex(e.txHash),e.txIndex);return n.PlutusScriptSource.new_ref_input_with_lang_ver(t,s,Y[e.version])};removeDuplicateInputs=()=>{const e=this.meshTxBuilderBody.inputs,t=a=>`${a.txHash}#${a.txIndex}`,s=[];for(let a=0;a<e.length;a++){const i=t(e[a].txIn);s.includes(i)?(e.splice(a,1),a--):s.push(i)}};addAllInputs=e=>{for(let t=0;t<e.length;t++){const s=e[t];switch(s.type){case"PubKey":this.addTxIn(s);break;case"Script":this.addScriptTxIn(s);break}}};addTxIn=e=>{this.txBuilder.add_input(n.Address.from_bech32(e.txIn.address),n.TransactionInput.new(n.TransactionHash.from_hex(e.txIn.txHash),e.txIn.txIndex),$(e.txIn.amount))};addScriptTxIn=({scriptTxIn:e,txIn:t})=>{let s;const{datumSource:a,scriptSource:i,redeemer:o}=e;if(a.type==="Provided")s=n.DatumSource.new(this.castDataToPlutusData(a.data));else{const d=n.TransactionInput.new(n.TransactionHash.from_hex(a.txHash),a.txIndex);s=n.DatumSource.new_ref_input(d)}let c;i.type=="Inline"?c=this.makePlutusScriptSource(i.txInInfo):c=n.PlutusScriptSource.new(n.PlutusScript.from_hex_with_version(i.script.code,Y[i.script.version]));const u=n.Redeemer.new(n.RedeemerTag.new_spend(),n.BigNum.from_str("0"),this.castDataToPlutusData(o.data),n.ExUnits.new(n.BigNum.from_str(String(o.exUnits.mem)),n.BigNum.from_str(String(o.exUnits.steps))));this.txBuilder.add_plutus_script_input(n.PlutusWitness.new_with_ref(c,s,u),n.TransactionInput.new(n.TransactionHash.from_hex(t.txHash),t.txIndex),$(t.amount))};addAllOutputs=e=>{for(let t=0;t<e.length;t++){const s=e[t];this.addOutput(s)}};addOutput=({amount:e,address:t,datum:s,referenceScript:a})=>{const i=$(e),o=i.multiasset();if(i.is_zero()&&o===void 0)throw Error("Invalid output amount");let c=n.TransactionOutputBuilder.new().with_address(M(t));s&&s.type==="Hash"&&(c=c.with_data_hash(n.hash_plutus_data(this.castDataToPlutusData(s.data)))),s&&s.type==="Inline"&&(c=c.with_plutus_data(this.castDataToPlutusData(s.data))),a&&(c=c.with_script_ref(n.ScriptRef.new_plutus_script(n.PlutusScript.from_hex_with_version(a.code,Y[a.version]))));const u=c.next();if(o){const d=i.coin().is_zero()?u.with_asset_and_min_required_coin_by_utxo_cost(o,Ht(this._protocolParams.coinsPerUTxOSize)).build():u.with_coin_and_asset(i.coin(),o).build();this.txBuilder.add_output(d)}else{const d=u.with_coin(i.coin()).build();this.txBuilder.add_output(d)}};addAllCollaterals=e=>{const t=n.TxInputsBuilder.new();for(let s=0;s<e.length;s++){const a=e[s];this.addCollateral(t,a)}this.txBuilder.set_collateral(t)};addCollateral=(e,t)=>{e.add_input(n.Address.from_bech32(t.txIn.address),n.TransactionInput.new(n.TransactionHash.from_hex(t.txIn.txHash),t.txIn.txIndex),$(t.txIn.amount))};addCollateralReturn=e=>{var s;const t=(s=this.txBuilder.get_fee_if_set())==null?void 0:s.to_js_value();if(t){const a=Math.ceil(this._protocolParams.collateralPercent*Number(t)/100);this.txBuilder.set_total_collateral_and_return(n.BigNum.from_str(String(a)),n.Address.from_bech32(e))}};addAllReferenceInputs=e=>{e.forEach(t=>{this.addReferenceInput(t)})};addReferenceInput=({txHash:e,txIndex:t})=>{const s=n.TransactionInput.new(n.TransactionHash.from_hex(e),t);this.txBuilder.add_reference_input(s)};addAllMints=e=>{const t=n.MintBuilder.new();let s=0;for(let a=0;a<e.length;a++){const i=e[a];if(!i.scriptSource)throw Error("Mint script is expected to be provided");if(i.type==="Plutus"){if(!i.redeemer)throw Error("Missing mint redeemer information");this.addPlutusMint(t,i,s),s++}else i.type==="Native"&&this.addNativeMint(t,i)}this.txBuilder.set_mint_builder(t)};addPlutusMint=(e,{redeemer:t,policyId:s,scriptSource:a,assetName:i,amount:o},c)=>{const u=n.Redeemer.new(n.RedeemerTag.new_mint(),n.BigNum.from_str(String(c)),this.castDataToPlutusData(t.data),n.ExUnits.new(n.BigNum.from_str(String(t.exUnits.mem)),n.BigNum.from_str(String(t.exUnits.steps)))),d=a.type==="Reference Script"?n.PlutusScriptSource.new_ref_input_with_lang_ver(n.ScriptHash.from_hex(s),n.TransactionInput.new(n.TransactionHash.from_hex(a.txHash),a.txIndex),Y[a.version]):n.PlutusScriptSource.new(n.PlutusScript.from_hex_with_version(a.script.code,Y[a.script.version]));e.add_asset(n.MintWitness.new_plutus_script(d,u),n.AssetName.new(Buffer.from(i,"hex")),n.Int.new(n.BigNum.from_str(o)))};addNativeMint=(e,{scriptSource:t,assetName:s,amount:a})=>{if(t.type==="Reference Script")throw Error("Native mint cannot have reference script");e.add_asset(n.MintWitness.new_native_script(n.NativeScript.from_hex(t.script.code)),n.AssetName.new(Buffer.from(s,"hex")),n.Int.new(n.BigNum.from_str(a)))};decimalToFraction(e){const t=10**e.toString().split(".")[1].length;return[e*t,t]}toPoolParams=e=>{const t=this.decimalToFraction(e.margin),s=n.Relays.new();e.relays.forEach(o=>{s.add(Re(o))});const a=n.RewardAddress.from_address(n.Address.from_bech32(e.rewardAddress));if(a===void 0)throw new Error("Reward address is invalid");const i=n.Ed25519KeyHashes.new();return e.owners.forEach(o=>{i.add(n.Ed25519KeyHash.from_hex(o))}),n.PoolParams.new(n.Ed25519KeyHash.from_hex(e.operator),n.VRFKeyHash.from_hex(e.VRFKeyHash),n.BigNum.from_str(e.pledge),n.BigNum.from_str(e.cost),n.UnitInterval.new(n.BigNum.from_str(t[0].toString()),n.BigNum.from_str(t[1].toString())),a,i,s,e.metadata?n.PoolMetadata.from_json(JSON.stringify(e.metadata)):void 0)};addCertificate=(e,t)=>{switch(t.type){case"RegisterPool":e.add(n.Certificate.new_pool_registration(n.PoolRegistration.new(this.toPoolParams(t.poolParams))));break;case"RegisterStake":e.add(n.Certificate.new_stake_registration(n.StakeRegistration.new(n.StakeCredential.from_keyhash(n.Ed25519KeyHash.from_hex(t.stakeKeyHash)))));break;case"DelegateStake":e.add(n.Certificate.new_stake_delegation(n.StakeDelegation.new(n.StakeCredential.from_keyhash(n.Ed25519KeyHash.from_hex(t.stakeKeyHash)),t.poolId.startsWith("pool")?n.Ed25519KeyHash.from_bech32(t.poolId):n.Ed25519KeyHash.from_hex(t.poolId))));break;case"DeregisterStake":e.add(n.Certificate.new_stake_deregistration(n.StakeDeregistration.new(n.StakeCredential.from_keyhash(n.Ed25519KeyHash.from_hex(t.stakeKeyHash)))));break;case"RetirePool":e.add(n.Certificate.new_pool_retirement(n.PoolRetirement.new(t.poolId.startsWith("pool")?n.Ed25519KeyHash.from_bech32(t.poolId):n.Ed25519KeyHash.from_hex(t.poolId),t.epoch)))}};queueAllLastItem=()=>{this.txOutput&&(this.meshTxBuilderBody.outputs.push(this.txOutput),this.txOutput=void 0),this.txInQueueItem&&this.queueInput(),this.collateralQueueItem&&(this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem),this.collateralQueueItem=void 0),this.mintItem&&this.queueMint()};addAllCertificates=e=>{const t=n.Certificates.new();e.forEach(s=>{this.addCertificate(t,s)}),this.txBuilder.set_certs(t)};addCostModels=()=>{this.txBuilder.calc_script_data_hash(n.TxBuilderConstants.plutus_vasil_cost_models())};addChange=e=>{this.txBuilder.add_change_if_needed(n.Address.from_bech32(e))};addValidityRange=({invalidBefore:e,invalidHereafter:t})=>{e&&this.txBuilder.set_validity_start_interval_bignum(n.BigNum.from_str(e.toString())),t&&this.txBuilder.set_ttl_bignum(n.BigNum.from_str(t.toString()))};addAllRequiredSignatures=e=>{e.forEach(t=>{this.txBuilder.add_required_signer(n.Ed25519KeyHash.from_hex(t))})};addAllMetadata=e=>{e.forEach(({tag:t,metadata:s})=>{this.txBuilder.add_json_metadatum(n.BigNum.from_str(t),JSON.stringify(s))})};updateRedeemer=(e,t)=>{t.forEach(s=>{switch(s.tag){case"SPEND":{const a=e.inputs[s.index];a.type=="Script"&&a.scriptTxIn.redeemer&&(a.scriptTxIn.redeemer.exUnits.mem=Math.floor(s.budget.mem*this.txEvaluationMultiplier),a.scriptTxIn.redeemer.exUnits.steps=Math.floor(s.budget.steps*this.txEvaluationMultiplier));break}case"MINT":{const a=e.mints[s.index];a.type=="Plutus"&&a.redeemer&&(a.redeemer.exUnits.mem=Math.floor(s.budget.mem*this.txEvaluationMultiplier),a.redeemer.exUnits.steps=Math.floor(s.budget.steps*this.txEvaluationMultiplier));break}}})};castRawDataToJsonString=e=>typeof e=="object"?JSON.stringify(e):e;castDataToPlutusData=({type:e,content:t})=>e==="Mesh"?Z(t):e==="CBOR"?n.PlutusData.from_hex(t):n.PlutusData.from_json(t,n.PlutusDatumSchema.DetailedSchema)}class mr extends gr{_fetcher;_submitter;_evaluator;queriedTxHashes=new Set;queriedUTxOs={};constructor({fetcher:e,submitter:t,evaluator:s,isHydra:a=!1}){super(),e&&(this._fetcher=e),t&&(this._submitter=t),s&&(this._evaluator=s),a&&(this.isHydra=!0)}complete=async e=>{e?this.meshTxBuilderBody=e:this.queueAllLastItem();const{inputs:t,collaterals:s}=this.meshTxBuilderBody,a=[...t,...s].filter(i=>!this.isInputComplete(i));if(console.log("Incomplete UTxO",a),await this.queryAllTxInfo(a),console.log("Incomplete UTxO",a),a.forEach(i=>{this.completeTxInformation(i)}),this.completeSync(e),this._evaluator){const i=await this._evaluator.evaluateTx(this.txHex);this.updateRedeemer(this.meshTxBuilderBody,i),this.completeSync(e)}return this};submitTx=async e=>{var s;return await((s=this._submitter)==null?void 0:s.submitTx(e))};getUTxOInfo=async e=>{var s;let t=[];this.queriedTxHashes.has(e)||(console.log("Query",e),this.queriedTxHashes.add(e),t=await((s=this._fetcher)==null?void 0:s.fetchUTxOs(e))||[],this.queriedUTxOs[e]=t)};queryAllTxInfo=e=>{var s;const t=[];if(e.length>0&&!this._fetcher)throw Error("Transaction information is incomplete while no fetcher instance is provided");for(let a=0;a<e.length;a++){const i=e[a];this.isInputInfoComplete(i)||t.push(this.getUTxOInfo(i.txIn.txHash)),i.type==="Script"&&((s=i.scriptTxIn.scriptSource)==null?void 0:s.type)==="Inline"&&!this.isRefScriptInfoComplete(i)&&t.push(this.getUTxOInfo(i.scriptTxIn.scriptSource.txInInfo.txHash))}return Promise.all(t)};completeTxInformation=e=>{var t;if(!this.isInputInfoComplete(e)){const s=this.queriedUTxOs[e.txIn.txHash],a=s==null?void 0:s.find(c=>c.input.outputIndex===e.txIn.txIndex),i=a==null?void 0:a.output.amount,o=a==null?void 0:a.output.address;if(!i||i.length===0)throw Error(`Couldn't find value information for ${e.txIn.txHash}#${e.txIn.txIndex}`);if(e.txIn.amount=i,e.type==="PubKey"){if(!o||o==="")throw Error(`Couldn't find address information for ${e.txIn.txHash}#${e.txIn.txIndex}`);e.txIn.address=o}}if(e.type==="Script"&&((t=e.scriptTxIn.scriptSource)==null?void 0:t.type)=="Inline"&&!this.isRefScriptInfoComplete(e)){const s=e.scriptTxIn.scriptSource.txInInfo,i=this.queriedUTxOs[s.txHash].find(o=>o.input.outputIndex===s.txIndex);if(!i)throw Error(`Couldn't find script reference utxo for ${s.txHash}#${s.txIndex}`);s.spendingScriptHash=i==null?void 0:i.output.scriptHash}};isInputComplete=e=>e.type==="PubKey"?this.isInputInfoComplete(e):e.type==="Script"?this.isInputInfoComplete(e)&&this.isRefScriptInfoComplete(e):!0;isInputInfoComplete=e=>{const{amount:t,address:s}=e.txIn;return!(e.type==="PubKey"&&(!t||!s)||e.type==="Script"&&!t)};isRefScriptInfoComplete=e=>{var s;const{scriptSource:t}=e.scriptTxIn;return!((t==null?void 0:t.type)==="Inline"&&!((s=t.txInInfo)!=null&&s.spendingScriptHash))}}class S{_networkId;_encryptedSecret;constructor(e,t){this._networkId=e,this._encryptedSecret=t}getAccount(e,t){return this.accountContext(e,t,(s,a)=>{const i=_e(this._networkId,s.to_public().hash(),a.to_public().hash()).to_address().to_bech32(),o=ye(this._networkId,s.to_public().hash()).to_address().to_bech32(),c=Mt(this._networkId,a.to_public().hash()).to_address().to_bech32();return{baseAddress:i,enterpriseAddress:o,rewardAddress:c}})}signData(e,t,s,a){try{return this.accountContext(e,t,(i,o)=>{const c={payload:a},u={address:S.resolveAddress(this._networkId,s,i,o),key:s.startsWith("stake")?o:i},{coseSign1:d,coseKey:h}=cs(c,u);return{signature:d,key:h}})}catch(i){throw new Error(`An error occurred during signData: ${i}.`)}}signTx(e,t,s,a,i){try{const o=Me(Ge(a));return this.accountContext(e,t,(c,u)=>{const d=n.Vkeywitnesses.new();return S.resolveSigners(a,s,c.to_public().hash().to_hex()).forEach(g=>{if(g===c.to_public().hash().to_hex())d.add(n.make_vkey_witness(o,c));else if(g===u.to_public().hash().to_hex())d.add(n.make_vkey_witness(o,u));else if(i===!1)throw new Error(`Missing key witness for: ${g}`)}),d})}catch(o){throw new Error(`An error occurred during signTx: ${o}.`)}}static encryptMnemonic(e,t){const s=Nt.mnemonicToEntropy(e.join(" ")),a=Le(s),i=T(a.as_bytes());return a.free(),S.encrypt(i,t)}static encryptPrivateKey(e,t){const s=n.Bip32PrivateKey.from_bech32(e),a=T(s.as_bytes());return s.free(),S.encrypt(a,t)}static encryptSigningKeys(e,t,s){const a=S.encrypt(e.slice(4),s),i=S.encrypt(t.slice(4),s);return[a,i]}static generateMnemonic(e=256){return Nt.generateMnemonic(e).split(" ")}accountContext(e,t,s){const{paymentKey:a,stakeKey:i}=S.resolveKeys(e,t,this._encryptedSecret),o=s(a,i);return a.free(),i.free(),o}static decrypt(e,t){try{return n.decrypt_with_password(Q(t),e)}catch{throw new Error("The password is incorrect.")}}static encrypt(e,t){const s=we.customAlphabet("0123456789abcdef"),a=s(64),i=s(24);return n.encrypt_with_password(Q(t),a,i,e)}static resolveAddress(e,t,s,a){const i=[_e(e,s.to_public().hash(),a.to_public().hash()),ye(e,s.to_public().hash()),Mt(e,a.to_public().hash())].find(o=>o.to_address().to_bech32()===t);if(i!==void 0)return i.to_address();throw new Error(`Address: ${t} doesn't belong to this account.`)}static resolveKeys(e,t,s){if(typeof s=="string"){const o=S.decrypt(s,t);return Us(o,e)}const a=S.decrypt(s[0],t),i=S.decrypt(s[1],t);return{paymentKey:n.PrivateKey.from_hex(a),stakeKey:n.PrivateKey.from_hex(i)}}static resolveSigners(e,t,s){const a=c=>{const u=(f,w=[],B=0)=>{var ft,ht,zt,Jt,Wt;if(f===void 0||B>=f.len())return w;const k=f.get(B),N=new Array;switch(k.kind()){case n.CertificateKind.StakeDeregistration:{const E=(ft=k.as_stake_deregistration())==null?void 0:ft.stake_credential(),L=(E==null?void 0:E.kind())===n.StakeCredKind.Key?E.to_keyhash():void 0;L&&N.push(L.to_hex());break}case n.CertificateKind.StakeDelegation:{const E=(ht=k.as_stake_delegation())==null?void 0:ht.stake_credential(),L=(E==null?void 0:E.kind())===n.StakeCredKind.Key?E.to_keyhash():void 0;L&&N.push(L.to_hex());break}case n.CertificateKind.PoolRegistration:{const E=(zt=k.as_pool_registration())==null?void 0:zt.pool_params().pool_owners();N.push(...h(E));break}case n.CertificateKind.PoolRetirement:{const E=(Jt=k.as_pool_retirement())==null?void 0:Jt.pool_keyhash();E&&N.push(E.to_hex());break}case n.CertificateKind.MoveInstantaneousRewardsCert:{const E=(Wt=k.as_move_instantaneous_rewards_cert())==null?void 0:Wt.move_instantaneous_reward().as_to_stake_creds();if(E)for(let L=0;L<E.len();L+=1){const jt=E.keys().get(L),Xt=jt.kind()===n.StakeCredKind.Key?jt.to_keyhash():void 0;Xt&&N.push(Xt.to_hex())}break}}return u(f,[...w,...N],B+1)},d=(f,w=[],B=0)=>{if(f===void 0||B>=f.len())return w;const k=f.get(B).index(),N=f.get(B).transaction_id(),ft=t.find(ht=>ht.input.outputIndex===k&&ht.input.txHash===N.to_hex())!==void 0?s:"OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";return d(f,[...w,ft],B+1)},h=(f,w=[],B=0)=>f===void 0||B>=f.len()?w:h(f,[...w,f.get(B).to_hex()],B+1),g=(f,w=[],B=0)=>{if(f===void 0||B>=f.len())return w;const k=f.keys().get(B).payment_cred(),N=k.kind()===n.StakeCredKind.Key?k.to_keyhash():void 0;return g(f,N?[...w,N.to_hex()]:w,B+1)},m=c.certs(),A=c.collateral(),I=c.inputs(),C=c.required_signers(),D=c.withdrawals();return[...u(m),...d(A),...d(I),...h(C),...g(D)]},i=c=>{const u=(h,g=[])=>{var m,A,I,C;if(h)for(let D=0;D<h.len();D+=1){const f=h.get(D);switch(f.kind()){case n.NativeScriptKind.ScriptPubkey:{const w=(m=f.as_script_pubkey())==null?void 0:m.addr_keyhash().to_hex();return w?[...g,w]:g}case n.NativeScriptKind.ScriptAll:return u((A=f.as_script_all())==null?void 0:A.native_scripts(),g);case n.NativeScriptKind.ScriptAny:return u((I=f.as_script_any())==null?void 0:I.native_scripts(),g);case n.NativeScriptKind.ScriptNOfK:return u((C=f.as_script_n_of_k())==null?void 0:C.native_scripts(),g)}}return g},d=c.native_scripts();return[...u(d)]},o=H(e);return new Set([...a(o.body()),...i(o.witness_set())])}}const K="MARI0TIME";class Ar{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new S(e.networkId,S.encryptMnemonic(e.key.words,K));break;case"root":this._wallet=new S(e.networkId,S.encryptPrivateKey(e.key.bech32,K));break;case"cli":this._wallet=new S(e.networkId,S.encryptSigningKeys(e.key.payment,e.key.stake??"f0".repeat(34),K))}}getBaseAddress(e=0){return this._wallet.getAccount(e,K).baseAddress}getPaymentAddress(e=0){return this._wallet.getAccount(e,K).enterpriseAddress}getRewardAddress(e=0){return this._wallet.getAccount(e,K).rewardAddress}getUsedAddress(e=0){const t=this._wallet.getAccount(e,K);return M(t.enterpriseAddress)}getUsedCollateral(e=P.maxCollateralInputs){throw new Error("getUsedCollateral not implemented.")}async getUsedUTxOs(e=0){const t=this._wallet.getAccount(e,K);return(await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map(a=>F(a))}signData(e,t,s=0){try{return this._wallet.signData(s,K,e,t)}catch(a){throw new Error(`[AppWallet] An error occurred during signData: ${a}.`)}}async signTx(e,t=!1,s=0){try{const a=this._wallet.getAccount(s,K),i=await this._fetcher.fetchAddressUTxOs(a.enterpriseAddress),o=this._wallet.signTx(s,K,i,e,t),c=H(e),u=c.witness_set(),d=Ft(u,o);return u.set_vkeys(d),n.Transaction.new(c.body(),u,c.auxiliary_data()).to_hex()}catch(a){throw new Error(`[AppWallet] An error occurred during signTx: ${a}.`)}}async signTxs(e,t){return console.log("unimplemented",e,t),[]}submitTx(e){return this._submitter.submitTx(e)}static brew(e=256){return S.generateMnemonic(e)}}class vt{_walletInstance;walletInstance;constructor(e){this._walletInstance=e,this.walletInstance={...e}}static getInstalledWallets(){return window.cardano===void 0?[]:te.filter(e=>window.cardano[e]!==void 0).map(e=>({name:window.cardano[e].name,icon:window.cardano[e].icon,version:window.cardano[e].apiVersion}))}static async enable(e){try{const t=await vt.resolveInstance(e);if(t!==void 0)return new vt(t);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${JSON.stringify(t)}.`)}}async getBalance(){const e=await this._walletInstance.getBalance();return qe(Rs(e))}async getChangeAddress(){const e=await this._walletInstance.getChangeAddress();return at(e).to_bech32()}async getCollateral(e=P.maxCollateralInputs){return(await this.getUsedCollateral(e)).map(s=>Qt(s))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>at(t).to_bech32())}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>at(t).to_bech32())}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>at(t).to_bech32())}async getUtxos(e=void 0){return(await this.getUsedUTxOs(e)).map(s=>Qt(s))}signData(e,t){const s=M(e).to_hex();return this._walletInstance.signData(s,Q(t))}async signTx(e,t=!1){try{const s=H(e),a=s.witness_set(),i=await this._walletInstance.signTx(e,t),o=pe(i).vkeys()??n.Vkeywitnesses.new(),c=Ft(a,o);return a.set_vkeys(c),T(n.Transaction.new(s.body(),a,s.auxiliary_data()).to_bytes())}catch(s){throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(s)}.`)}}async signTxs(e,t=!1){const s=await this._walletInstance.signTxs(e,t),a=[];for(let i=0;i<s.length;i++){const o=H(e[i]),c=o.witness_set(),u=pe(s[i]).vkeys()??n.Vkeywitnesses.new(),d=Ft(c,u);c.set_vkeys(d);const h=T(n.Transaction.new(o.body(),c,o.auxiliary_data()).to_bytes());a.push(h)}return a}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){const e=await this._walletInstance.getUsedAddresses();return at(e[0])}async getUsedCollateral(e=P.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(s=>Ie(s)).slice(0,e)}async getUsedUTxOs(e=void 0){const t=e?$(e).to_hex():void 0;return(await this._walletInstance.getUtxos(t)??[]).map(a=>Ie(a))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const s=t.unit.slice(0,V),a=t.unit.slice(V),i=Ye(s,a);return{unit:t.unit,policyId:s,assetName:Gt(a),fingerprint:i,quantity:t.quantity}})}async getLovelace(){const t=(await this.getBalance()).find(s=>s.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(s=>s.policyId===e)}async getPolicyIds(){const e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,V)))).filter(t=>t!=="lovelace")}static resolveInstance(e){if(window.cardano===void 0)return;const t=te.map(s=>window.cardano[s]).filter(s=>s!==void 0).find(s=>s.name.toLowerCase()===e.toLowerCase());return t==null?void 0:t.enable()}}exports.AppWallet=Ar;exports.BlockfrostProvider=rr;exports.BrowserWallet=vt;exports.EmbeddedWallet=S;exports.ForgeScript=ur;exports.InfuraProvider=ar;exports.KoiosProvider=nr;exports.MaestroProvider=cr;exports.MeshTxBuilder=mr;exports.OgmiosProvider=ir;exports.TangoProvider=or;exports.checkSignature=us;exports.generateNonce=tr;exports.isNetwork=Be;exports.keepRelevant=Se;exports.largestFirst=ss;exports.largestFirstMultiAsset=Ee;exports.parseAssetUnit=J;exports.parseHttpError=l;exports.readPlutusData=er;exports.readTransaction=sr;exports.resolveDataHash=Ls;exports.resolveEpochNo=Ys;exports.resolveFingerprint=Ye;exports.resolveLanguageView=Gs;exports.resolveNativeScriptHash=$s;exports.resolvePaymentKeyHash=st;exports.resolvePlutusScriptAddress=zs;exports.resolvePlutusScriptHash=Js;exports.resolvePoolId=Ws;exports.resolvePrivateKey=js;exports.resolveRewardAddress=pt;exports.resolveScriptRef=Xs;exports.resolveSlotNo=Zs;exports.resolveStakeKeyHash=it;exports.resolveTxFees=$t;exports.resolveTxHash=Ge;
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const mr=require("nanoid"),qr=require("@emurgo/cardano-serialization-lib-nodejs"),Vr=require("axios"),De=require("bip39"),Y=require("@emurgo/cardano-message-signing-nodejs"),Lr=s=>s&&typeof s=="object"&&"default"in s?s:{default:s};function Gr(s){if(s&&s.__esModule)return s;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const t in s)if(t!=="default"){const r=Object.getOwnPropertyDescriptor(s,t);Object.defineProperty(e,t,r.get?r:{enumerable:!0,get:()=>s[t]})}}return e.default=s,Object.freeze(e)}const i=Gr(qr),Mt=Lr(Vr),Yr=["testnet","preview","preprod","mainnet"],Ar=s=>Yr.includes(s),Gt={mem:7e6,steps:3e9},gt={epoch:0,coinsPerUTxOSize:"4310",priceMem:.0577,priceStep:721e-7,minFeeA:44,minFeeB:155381,keyDeposit:"2000000",maxTxSize:16384,maxValSize:"5000",poolDeposit:"500000000",maxCollateralInputs:3,decentralisation:0,maxBlockSize:98304,collateralPercent:150,maxBlockHeaderSize:1100,minPoolCost:"340000000",maxTxExMem:"16000000",maxTxExSteps:"10000000000",maxBlockExMem:"80000000",maxBlockExSteps:"40000000000"},be=2147483648,vt={V1:i.Language.new_plutus_v1(),V2:i.Language.new_plutus_v2()},Bt=56,$r={CERT:i.RedeemerTag.new_cert(),MINT:i.RedeemerTag.new_mint(),REWARD:i.RedeemerTag.new_reward(),SPEND:i.RedeemerTag.new_spend()},me={testnet:["74","1598400","1595967616","432000"],preview:["183","15811222","1682467200","86400"],preprod:["65","26438400","1682121600","432000"],mainnet:["208","4492800","1596059091","432000"]},Ye={ALONZO:i.TxBuilderConstants.plutus_alonzo_cost_models(),BABBAGE:(()=>{const s=i.Costmdls.new(),e=i.CostModel.new();Object.values({"addInteger-cpu-arguments-intercept":205665,"addInteger-cpu-arguments-slope":812,"addInteger-memory-arguments-intercept":1,"addInteger-memory-arguments-slope":1,"appendByteString-cpu-arguments-intercept":1e3,"appendByteString-cpu-arguments-slope":571,"appendByteString-memory-arguments-intercept":0,"appendByteString-memory-arguments-slope":1,"appendString-cpu-arguments-intercept":1e3,"appendString-cpu-arguments-slope":24177,"appendString-memory-arguments-intercept":4,"appendString-memory-arguments-slope":1,"bData-cpu-arguments":1e3,"bData-memory-arguments":32,"blake2b_256-cpu-arguments-intercept":117366,"blake2b_256-cpu-arguments-slope":10475,"blake2b_256-memory-arguments":4,"cekApplyCost-exBudgetCPU":23e3,"cekApplyCost-exBudgetMemory":100,"cekBuiltinCost-exBudgetCPU":23e3,"cekBuiltinCost-exBudgetMemory":100,"cekConstCost-exBudgetCPU":23e3,"cekConstCost-exBudgetMemory":100,"cekDelayCost-exBudgetCPU":23e3,"cekDelayCost-exBudgetMemory":100,"cekForceCost-exBudgetCPU":23e3,"cekForceCost-exBudgetMemory":100,"cekLamCost-exBudgetCPU":23e3,"cekLamCost-exBudgetMemory":100,"cekStartupCost-exBudgetCPU":100,"cekStartupCost-exBudgetMemory":100,"cekVarCost-exBudgetCPU":23e3,"cekVarCost-exBudgetMemory":100,"chooseData-cpu-arguments":19537,"chooseData-memory-arguments":32,"chooseList-cpu-arguments":175354,"chooseList-memory-arguments":32,"chooseUnit-cpu-arguments":46417,"chooseUnit-memory-arguments":4,"consByteString-cpu-arguments-intercept":221973,"consByteString-cpu-arguments-slope":511,"consByteString-memory-arguments-intercept":0,"consByteString-memory-arguments-slope":1,"constrData-cpu-arguments":89141,"constrData-memory-arguments":32,"decodeUtf8-cpu-arguments-intercept":497525,"decodeUtf8-cpu-arguments-slope":14068,"decodeUtf8-memory-arguments-intercept":4,"decodeUtf8-memory-arguments-slope":2,"divideInteger-cpu-arguments-constant":196500,"divideInteger-cpu-arguments-model-arguments-intercept":453240,"divideInteger-cpu-arguments-model-arguments-slope":220,"divideInteger-memory-arguments-intercept":0,"divideInteger-memory-arguments-minimum":1,"divideInteger-memory-arguments-slope":1,"encodeUtf8-cpu-arguments-intercept":1e3,"encodeUtf8-cpu-arguments-slope":28662,"encodeUtf8-memory-arguments-intercept":4,"encodeUtf8-memory-arguments-slope":2,"equalsByteString-cpu-arguments-constant":245e3,"equalsByteString-cpu-arguments-intercept":216773,"equalsByteString-cpu-arguments-slope":62,"equalsByteString-memory-arguments":1,"equalsData-cpu-arguments-intercept":1060367,"equalsData-cpu-arguments-slope":12586,"equalsData-memory-arguments":1,"equalsInteger-cpu-arguments-intercept":208512,"equalsInteger-cpu-arguments-slope":421,"equalsInteger-memory-arguments":1,"equalsString-cpu-arguments-constant":187e3,"equalsString-cpu-arguments-intercept":1e3,"equalsString-cpu-arguments-slope":52998,"equalsString-memory-arguments":1,"fstPair-cpu-arguments":80436,"fstPair-memory-arguments":32,"headList-cpu-arguments":43249,"headList-memory-arguments":32,"iData-cpu-arguments":1e3,"iData-memory-arguments":32,"ifThenElse-cpu-arguments":80556,"ifThenElse-memory-arguments":1,"indexByteString-cpu-arguments":57667,"indexByteString-memory-arguments":4,"lengthOfByteString-cpu-arguments":1e3,"lengthOfByteString-memory-arguments":10,"lessThanByteString-cpu-arguments-intercept":197145,"lessThanByteString-cpu-arguments-slope":156,"lessThanByteString-memory-arguments":1,"lessThanEqualsByteString-cpu-arguments-intercept":197145,"lessThanEqualsByteString-cpu-arguments-slope":156,"lessThanEqualsByteString-memory-arguments":1,"lessThanEqualsInteger-cpu-arguments-intercept":204924,"lessThanEqualsInteger-cpu-arguments-slope":473,"lessThanEqualsInteger-memory-arguments":1,"lessThanInteger-cpu-arguments-intercept":208896,"lessThanInteger-cpu-arguments-slope":511,"lessThanInteger-memory-arguments":1,"listData-cpu-arguments":52467,"listData-memory-arguments":32,"mapData-cpu-arguments":64832,"mapData-memory-arguments":32,"mkCons-cpu-arguments":65493,"mkCons-memory-arguments":32,"mkNilData-cpu-arguments":22558,"mkNilData-memory-arguments":32,"mkNilPairData-cpu-arguments":16563,"mkNilPairData-memory-arguments":32,"mkPairData-cpu-arguments":76511,"mkPairData-memory-arguments":32,"modInteger-cpu-arguments-constant":196500,"modInteger-cpu-arguments-model-arguments-intercept":453240,"modInteger-cpu-arguments-model-arguments-slope":220,"modInteger-memory-arguments-intercept":0,"modInteger-memory-arguments-minimum":1,"modInteger-memory-arguments-slope":1,"multiplyInteger-cpu-arguments-intercept":69522,"multiplyInteger-cpu-arguments-slope":11687,"multiplyInteger-memory-arguments-intercept":0,"multiplyInteger-memory-arguments-slope":1,"nullList-cpu-arguments":60091,"nullList-memory-arguments":32,"quotientInteger-cpu-arguments-constant":196500,"quotientInteger-cpu-arguments-model-arguments-intercept":453240,"quotientInteger-cpu-arguments-model-arguments-slope":220,"quotientInteger-memory-arguments-intercept":0,"quotientInteger-memory-arguments-minimum":1,"quotientInteger-memory-arguments-slope":1,"remainderInteger-cpu-arguments-constant":196500,"remainderInteger-cpu-arguments-model-arguments-intercept":453240,"remainderInteger-cpu-arguments-model-arguments-slope":220,"remainderInteger-memory-arguments-intercept":0,"remainderInteger-memory-arguments-minimum":1,"remainderInteger-memory-arguments-slope":1,"sha2_256-cpu-arguments-intercept":806990,"sha2_256-cpu-arguments-slope":30482,"sha2_256-memory-arguments":4,"sha3_256-cpu-arguments-intercept":1927926,"sha3_256-cpu-arguments-slope":82523,"sha3_256-memory-arguments":4,"sliceByteString-cpu-arguments-intercept":265318,"sliceByteString-cpu-arguments-slope":0,"sliceByteString-memory-arguments-intercept":4,"sliceByteString-memory-arguments-slope":0,"sndPair-cpu-arguments":85931,"sndPair-memory-arguments":32,"subtractInteger-cpu-arguments-intercept":205665,"subtractInteger-cpu-arguments-slope":812,"subtractInteger-memory-arguments-intercept":1,"subtractInteger-memory-arguments-slope":1,"tailList-cpu-arguments":41182,"tailList-memory-arguments":32,"trace-cpu-arguments":212342,"trace-memory-arguments":32,"unBData-cpu-arguments":31220,"unBData-memory-arguments":32,"unConstrData-cpu-arguments":32696,"unConstrData-memory-arguments":32,"unIData-cpu-arguments":43357,"unIData-memory-arguments":32,"unListData-cpu-arguments":32247,"unListData-memory-arguments":32,"unMapData-cpu-arguments":38314,"unMapData-memory-arguments":32,"verifyEd25519Signature-cpu-arguments-intercept":57996947,"verifyEd25519Signature-cpu-arguments-slope":18975,"verifyEd25519Signature-memory-arguments":10}).forEach((r,n)=>e.set(n,i.Int.new_i32(r)));const t=i.CostModel.new();return Object.values({"addInteger-cpu-arguments-intercept":205665,"addInteger-cpu-arguments-slope":812,"addInteger-memory-arguments-intercept":1,"addInteger-memory-arguments-slope":1,"appendByteString-cpu-arguments-intercept":1e3,"appendByteString-cpu-arguments-slope":571,"appendByteString-memory-arguments-intercept":0,"appendByteString-memory-arguments-slope":1,"appendString-cpu-arguments-intercept":1e3,"appendString-cpu-arguments-slope":24177,"appendString-memory-arguments-intercept":4,"appendString-memory-arguments-slope":1,"bData-cpu-arguments":1e3,"bData-memory-arguments":32,"blake2b_256-cpu-arguments-intercept":117366,"blake2b_256-cpu-arguments-slope":10475,"blake2b_256-memory-arguments":4,"cekApplyCost-exBudgetCPU":23e3,"cekApplyCost-exBudgetMemory":100,"cekBuiltinCost-exBudgetCPU":23e3,"cekBuiltinCost-exBudgetMemory":100,"cekConstCost-exBudgetCPU":23e3,"cekConstCost-exBudgetMemory":100,"cekDelayCost-exBudgetCPU":23e3,"cekDelayCost-exBudgetMemory":100,"cekForceCost-exBudgetCPU":23e3,"cekForceCost-exBudgetMemory":100,"cekLamCost-exBudgetCPU":23e3,"cekLamCost-exBudgetMemory":100,"cekStartupCost-exBudgetCPU":100,"cekStartupCost-exBudgetMemory":100,"cekVarCost-exBudgetCPU":23e3,"cekVarCost-exBudgetMemory":100,"chooseData-cpu-arguments":19537,"chooseData-memory-arguments":32,"chooseList-cpu-arguments":175354,"chooseList-memory-arguments":32,"chooseUnit-cpu-arguments":46417,"chooseUnit-memory-arguments":4,"consByteString-cpu-arguments-intercept":221973,"consByteString-cpu-arguments-slope":511,"consByteString-memory-arguments-intercept":0,"consByteString-memory-arguments-slope":1,"constrData-cpu-arguments":89141,"constrData-memory-arguments":32,"decodeUtf8-cpu-arguments-intercept":497525,"decodeUtf8-cpu-arguments-slope":14068,"decodeUtf8-memory-arguments-intercept":4,"decodeUtf8-memory-arguments-slope":2,"divideInteger-cpu-arguments-constant":196500,"divideInteger-cpu-arguments-model-arguments-intercept":453240,"divideInteger-cpu-arguments-model-arguments-slope":220,"divideInteger-memory-arguments-intercept":0,"divideInteger-memory-arguments-minimum":1,"divideInteger-memory-arguments-slope":1,"encodeUtf8-cpu-arguments-intercept":1e3,"encodeUtf8-cpu-arguments-slope":28662,"encodeUtf8-memory-arguments-intercept":4,"encodeUtf8-memory-arguments-slope":2,"equalsByteString-cpu-arguments-constant":245e3,"equalsByteString-cpu-arguments-intercept":216773,"equalsByteString-cpu-arguments-slope":62,"equalsByteString-memory-arguments":1,"equalsData-cpu-arguments-intercept":1060367,"equalsData-cpu-arguments-slope":12586,"equalsData-memory-arguments":1,"equalsInteger-cpu-arguments-intercept":208512,"equalsInteger-cpu-arguments-slope":421,"equalsInteger-memory-arguments":1,"equalsString-cpu-arguments-constant":187e3,"equalsString-cpu-arguments-intercept":1e3,"equalsString-cpu-arguments-slope":52998,"equalsString-memory-arguments":1,"fstPair-cpu-arguments":80436,"fstPair-memory-arguments":32,"headList-cpu-arguments":43249,"headList-memory-arguments":32,"iData-cpu-arguments":1e3,"iData-memory-arguments":32,"ifThenElse-cpu-arguments":80556,"ifThenElse-memory-arguments":1,"indexByteString-cpu-arguments":57667,"indexByteString-memory-arguments":4,"lengthOfByteString-cpu-arguments":1e3,"lengthOfByteString-memory-arguments":10,"lessThanByteString-cpu-arguments-intercept":197145,"lessThanByteString-cpu-arguments-slope":156,"lessThanByteString-memory-arguments":1,"lessThanEqualsByteString-cpu-arguments-intercept":197145,"lessThanEqualsByteString-cpu-arguments-slope":156,"lessThanEqualsByteString-memory-arguments":1,"lessThanEqualsInteger-cpu-arguments-intercept":204924,"lessThanEqualsInteger-cpu-arguments-slope":473,"lessThanEqualsInteger-memory-arguments":1,"lessThanInteger-cpu-arguments-intercept":208896,"lessThanInteger-cpu-arguments-slope":511,"lessThanInteger-memory-arguments":1,"listData-cpu-arguments":52467,"listData-memory-arguments":32,"mapData-cpu-arguments":64832,"mapData-memory-arguments":32,"mkCons-cpu-arguments":65493,"mkCons-memory-arguments":32,"mkNilData-cpu-arguments":22558,"mkNilData-memory-arguments":32,"mkNilPairData-cpu-arguments":16563,"mkNilPairData-memory-arguments":32,"mkPairData-cpu-arguments":76511,"mkPairData-memory-arguments":32,"modInteger-cpu-arguments-constant":196500,"modInteger-cpu-arguments-model-arguments-intercept":453240,"modInteger-cpu-arguments-model-arguments-slope":220,"modInteger-memory-arguments-intercept":0,"modInteger-memory-arguments-minimum":1,"modInteger-memory-arguments-slope":1,"multiplyInteger-cpu-arguments-intercept":69522,"multiplyInteger-cpu-arguments-slope":11687,"multiplyInteger-memory-arguments-intercept":0,"multiplyInteger-memory-arguments-slope":1,"nullList-cpu-arguments":60091,"nullList-memory-arguments":32,"quotientInteger-cpu-arguments-constant":196500,"quotientInteger-cpu-arguments-model-arguments-intercept":453240,"quotientInteger-cpu-arguments-model-arguments-slope":220,"quotientInteger-memory-arguments-intercept":0,"quotientInteger-memory-arguments-minimum":1,"quotientInteger-memory-arguments-slope":1,"remainderInteger-cpu-arguments-constant":196500,"remainderInteger-cpu-arguments-model-arguments-intercept":453240,"remainderInteger-cpu-arguments-model-arguments-slope":220,"remainderInteger-memory-arguments-intercept":0,"remainderInteger-memory-arguments-minimum":1,"remainderInteger-memory-arguments-slope":1,"serialiseData-cpu-arguments-intercept":1159724,"serialiseData-cpu-arguments-slope":392670,"serialiseData-memory-arguments-intercept":0,"serialiseData-memory-arguments-slope":2,"sha2_256-cpu-arguments-intercept":806990,"sha2_256-cpu-arguments-slope":30482,"sha2_256-memory-arguments":4,"sha3_256-cpu-arguments-intercept":1927926,"sha3_256-cpu-arguments-slope":82523,"sha3_256-memory-arguments":4,"sliceByteString-cpu-arguments-intercept":265318,"sliceByteString-cpu-arguments-slope":0,"sliceByteString-memory-arguments-intercept":4,"sliceByteString-memory-arguments-slope":0,"sndPair-cpu-arguments":85931,"sndPair-memory-arguments":32,"subtractInteger-cpu-arguments-intercept":205665,"subtractInteger-cpu-arguments-slope":812,"subtractInteger-memory-arguments-intercept":1,"subtractInteger-memory-arguments-slope":1,"tailList-cpu-arguments":41182,"tailList-memory-arguments":32,"trace-cpu-arguments":212342,"trace-memory-arguments":32,"unBData-cpu-arguments":31220,"unBData-memory-arguments":32,"unConstrData-cpu-arguments":32696,"unConstrData-memory-arguments":32,"unIData-cpu-arguments":43357,"unIData-memory-arguments":32,"unListData-cpu-arguments":32247,"unListData-memory-arguments":32,"unMapData-cpu-arguments":38314,"unMapData-memory-arguments":32,"verifyEcdsaSecp256k1Signature-cpu-arguments":35892428,"verifyEcdsaSecp256k1Signature-memory-arguments":10,"verifyEd25519Signature-cpu-arguments-intercept":57996947,"verifyEd25519Signature-cpu-arguments-slope":18975,"verifyEd25519Signature-memory-arguments":10,"verifySchnorrSecp256k1Signature-cpu-arguments-intercept":38887044,"verifySchnorrSecp256k1Signature-cpu-arguments-slope":32947,"verifySchnorrSecp256k1Signature-memory-arguments":10}).forEach((r,n)=>t.set(n,i.Int.new_i32(r))),s.insert(i.Language.new_plutus_v1(),e),s.insert(i.Language.new_plutus_v2(),t),s})()},zr={ALONZO:{V1:"a141005901d59f1a000302590001011a00060bc719026d00011a000249f01903e800011a000249f018201a0025cea81971f70419744d186419744d186419744d186419744d186419744d186419744d18641864186419744d18641a000249f018201a000249f018201a000249f018201a000249f01903e800011a000249f018201a000249f01903e800081a000242201a00067e2318760001011a000249f01903e800081a000249f01a0001b79818f7011a000249f0192710011a0002155e19052e011903e81a000249f01903e8011a000249f018201a000249f018201a000249f0182001011a000249f0011a000249f0041a000194af18f8011a000194af18f8011a0002377c190556011a0002bdea1901f1011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000242201a00067e23187600010119f04c192bd200011a000249f018201a000242201a00067e2318760001011a000242201a00067e2318760001011a0025cea81971f704001a000141bb041a000249f019138800011a000249f018201a000302590001011a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a000249f018201a00330da70101ff"},BABBAGE:{V1:"a141005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff",V2:"a20198af1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a0011b22c1a0005fdde00021a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201b00000004a817c8001b00000004a817c8001a009063b91903fd0a1b00000004a817c800001b00000004a817c80041005901b69f1a0003236119032c01011903e819023b00011903e8195e7104011903e818201a0001ca761928eb041959d818641959d818641959d818641959d818641959d818641959d81864186418641959d81864194c5118201a0002acfa182019b551041a000363151901ff00011a00015c3518201a000797751936f404021a0002ff941a0006ea7818dc0001011903e8196ff604021a0003bd081a00034ec5183e011a00102e0f19312a011a00032e801901a5011a0002da781903e819cf06011a00013a34182019a8f118201903e818201a00013aac0119e143041903e80a1a00030219189c011a00030219189c011a0003207c1901d9011a000330001901ff0119ccf3182019fd40182019ffd5182019581e18201940b318201a00012adf18201a0002ff941a0006ea7818dc0001011a00010f92192da7000119eabb18201a0002ff941a0006ea7818dc0001011a0002ff941a0006ea7818dc0001011a000c504e197712041a001d6af61a0001425b041a00040c660004001a00014fab18201a0003236119032c010119a0de18201a00033d7618201979f41820197fb8182019a95d1820197df718201995aa18201a009063b91903fd0aff"}},Me={[i.NetworkInfo.testnet().network_id()]:"8d18d786e92776c824607fd8e193ec535c79dc61ea2405ddf3b09fe3",[i.NetworkInfo.mainnet().network_id()]:"f0ff48bbb7bbe9d59a40f1ce90e9e9d0ff5002ec48f232b49ca0fb9a"},Wr={mainnet:"wss://ogmios-api.mainnet.dandelion.link",preprod:"wss://ogmios-api.iohk-preprod.dandelion.link",preview:"__TBD_SOON_TM__",testnet:"wss://ogmios-api.testnet.dandelion.link"},jr={LQ:"da8c30857834c6ae7203935b89278c532b3995245295456f993e1d244c51",MIN:"29d222ce763455e3d7a09a665ce554f00ac89d2e99a1a83d267170c64d494e",NTX:"edfd7a1d77bcb8b884c474bdc92a16002d1fb720e454fa6e993444794e5458",iBTC:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069425443",iETH:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069455448",iUSD:"f66d78b4a3cb3d37afa0ec36461e51ecbde00f26c8f0a68f94b6988069555344",MILK:"8a1cfae21368b8bebbbed9800fec304e95cce39a2a57dc35e2e3ebaa4d494c4b",AGIX:"f43a62fdc3965df486de8a0d32fe800963589c41b38946602a0dc53541474958",MELD:"6ac8ef33b510ec004fe11585f7c5a9f0c07f0c23428ab4f29c1d7d104d454c44",INDY:"533bb94a8850ee3ccbe483106489399112b74c905342cb1792a797a0494e4459",CLAY:"38ad9dc3aec6a2f38e220142b9aa6ade63ebe71f65e7cc2b7d8a8535434c4159",MCOS:"6f46e1304b16d884c85c62fb0eef35028facdc41aaa0fd319a152ed64d434f53",DING:"ce5b9e0f8a88255b65f2e4d065c6e716e9fa9a8a86dfb86423dd1ac044494e47",GERO:"10a49b996e2402269af553a8a96fb8eb90d79e9eca79e2b4223057b64745524f",NMKR:"5dac8536653edc12f6f5e1045d8164b9f59998d3bdc300fc928434894e4d4b52",PAVIA:"884892bcdc360bcef87d6b3f806e7f9cd5ac30d999d49970e7a903ae5041564941",HOSKY:"a0028f350aaabe0545fdcb56b039bfb08e4bb4d8c4d7c3c7d481c235484f534b59",YUMMI:"078eafce5cd7edafdf63900edef2c1ea759e77f30ca81d6bbdeec92479756d6d69",C3:"8e51398904a5d3fc129fbf4f1589701de23c7824d5c90fdb9490e15a434841524c4933",GIMBAL:"2b0a04a7b60132b1805b296c7fcb3b217ff14413991bf76f72663c3067696d62616c",SUNDAE:"9a9693a9a37912a5097918f97918d15240c92ab729a0b7c4aa144d7753554e444145",GREENS:"4623ab311b7d982d8d26fcbe1a9439ca56661aafcdcd8d8a0ef31fd6475245454e53",GENS:"dda5fdb1002f7389b33e036b6afee82a8189becb6cba852e8b79b4fb0014df1047454e53",SOCIETY:"25f0fc240e91bd95dcdaebd2ba7713fc5168ac77234a3d79449fc20c534f4349455459",DJED:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd61446a65644d6963726f555344",SHEN:"8db269c3ec630e06ae29f74bc39edd1f87c819f1056206e879a1cd615368656e4d6963726f555344",WMT:"1d7f33bd23d85e1a25d87d86fac4f199c3197a2f7afeb662a0f34e1e776f726c646d6f62696c65746f6b656e",COPI:"b6a7467ea1deb012808ef4e87b5ff371e85f7142d7b356a40d9b42a0436f726e75636f70696173205b76696120436861696e506f72742e696f5d"},$e=["begin","eternl","flint","lace","nami","nufi","gerowallet","typhoncip30","vespr","yoroi"],pr=(s,e,t="5000000")=>{const r=i.BigNum.from_str(s.get("lovelace")??"0").checked_add(i.BigNum.from_str(t)),n=e.filter(l=>l.output.amount.filter(p=>p.unit!=="lovelace").some(p=>s.has(p.unit))),a=ts(n);return[...a.less_than(r)?es(r.clamped_sub(a).to_str(),e.filter(l=>!n.some(p=>p.input.txHash===l.input.txHash&&p.input.outputIndex===l.input.outputIndex))):[],...n]},Jr=(s,e,t=!1,{maxTxSize:r,minFeeA:n,minFeeB:a}=gt)=>{const c=e.filter(E=>_r(E)===!1).sort(Ke),l=i.BigNum.from_str(Ve(r,n,a)),p=t?i.BigNum.from_str(s).checked_add(l).to_str():s;return se(c,new Map([["lovelace",p]]))},Ir=(s,e,t=!1,r=gt)=>{const n=e.filter(_r).sort(Ke),a=Zr(r),c=s.get("lovelace")??"0",l=t?i.BigNum.from_str(c).checked_add(a).to_str():c;return s.set("lovelace",l),se(n,s)},Xr=(s,e)=>Array.from(e,t=>({unit:t[0],quantity:i.BigNum.from_str(t[1])})).every(t=>s.filter(r=>r.output.amount.find(n=>n.unit===t.unit)!==void 0).reduce((r,n)=>{const a=n.output.amount.reduce((c,l)=>c.checked_add(i.BigNum.from_str(t.unit===l.unit?l.quantity:"0")),i.BigNum.from_str("0"));return r.checked_add(a)},i.BigNum.from_str("0")).less_than(t.quantity)===!1),Ke=(s,e)=>{var n,a;const t=i.BigNum.from_str(((n=s.output.amount.find(c=>c.unit==="lovelace"))==null?void 0:n.quantity)??"0");return i.BigNum.from_str(((a=e.output.amount.find(c=>c.unit==="lovelace"))==null?void 0:a.quantity)??"0").compare(t)},Zr=s=>{const{maxTxSize:e,minFeeA:t,minFeeB:r}=s;return i.BigNum.from_str(Ve(e,t,r))},_r=s=>s.output.amount.length>1,ts=s=>s.reduce((e,t)=>{var n;const r=((n=t.output.amount.find(a=>a.unit==="lovelace"))==null?void 0:n.quantity)??"0";return e.checked_add(i.BigNum.from_str(r))},i.BigNum.from_str("0")),es=(s,e)=>{const t=e.sort(Ke);return se(t,new Map([["lovelace",s]]))},se=(s,e,t=[])=>s.length===0||Xr(t,e)?t:rs(s[0],e)?se(s.slice(1),e,[...t,s[0]]):se(s.slice(1),e,t),rs=(s,e)=>Array.from(e.keys()).some(t=>s.output.amount.find(r=>r.unit===t)!==void 0),ss=(s,e)=>{const t=as(e),r=os(s,e);return{coseKey:dt(t.to_bytes()),coseSign1:dt(r.to_bytes())}},ns=(s,e,{key:t,signature:r})=>{var c,l;const n=Y.COSEKey.from_bytes(G(t)),a=Y.COSESign1.from_bytes(G(r));if((s==null?void 0:s.length)>0){const p=dt(a.payload()??new Uint8Array);if(ct(s)!==p)return!1}if((e==null?void 0:e.length)>0){const A=(c=a.headers().protected().deserialized_headers().header(Y.Label.new_text("address")))==null?void 0:c.as_bytes();if(A===void 0)throw new Error("Couldn't find a signer address in signature");const C=(l=n.header(Y.Label.new_int(Y.Int.new_negative(Y.BigNum.from_str("2")))))==null?void 0:l.as_bytes();if(C===void 0)throw new Error("Couldn't find a signer key in signature");const E=Lt(dt(A)),w=Ns(dt(C));if(is(e,E,w)===!1)throw new Error("Couldn't check signature because of address mismatch");const b=Ts(dt(a.signature())),P=a.signed_data().to_bytes();return w.verify(P,b)}return!1},is=(s,e,t)=>{if(s!==e.to_bech32())return!1;try{return Yt(s)===t.hash().to_hex()}catch{return!1}},as=s=>{const e=Y.COSEKey.new(Y.Label.from_key_type(Y.KeyType.OKP));return e.set_algorithm_id(Y.Label.from_algorithm_id(Y.AlgorithmId.EdDSA)),e.set_header(Y.Label.new_int(Y.Int.new_negative(Y.BigNum.from_str("1"))),Y.CBORValue.new_int(Y.Int.new_i32(6))),e.set_header(Y.Label.new_int(Y.Int.new_negative(Y.BigNum.from_str("2"))),Y.CBORValue.new_bytes(s.key.to_public().as_bytes())),e},os=(s,e)=>{const t=Y.HeaderMap.new(),r=Y.HeaderMap.new();t.set_algorithm_id(Y.Label.from_algorithm_id(Y.AlgorithmId.EdDSA)),t.set_header(Y.Label.new_text("address"),Y.CBORValue.new_bytes(e.address.to_bytes()));const n=Y.Headers.new(Y.ProtectedHeaderMap.new(t),r),a=Y.COSESign1Builder.new(n,G(s.payload),!1);s.externalAAD!==void 0&&a.set_external_aad(G(s.externalAAD));const c=a.make_data_to_sign(),l=e.key.sign(c.to_bytes());return a.build(l.to_bytes())};var ke=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},yr={},ut={exports:{}};Dt.notEqual=us;Dt.notOk=ls;Dt.equal=cs;Dt.ok=Dt;var xr=Dt;function cs(s,e,t){Dt(s==e,t)}function us(s,e,t){Dt(s!=e,t)}function ls(s,e){Dt(!s,e)}function Dt(s,e){if(!s)throw new Error(e||"AssertionError")}var Et={exports:{}};function ds(s){throw new Error('Could not dynamically require "'+s+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var hs=He;He.supported=typeof WebAssembly<"u";function He(s){if(!He.supported)return null;var e=s&&s.imports,t=fs("AGFzbQEAAAABEANgAn9/AGADf39/AGABfwADBQQAAQICBQUBAQroBwdNBQZtZW1vcnkCAAxibGFrZTJiX2luaXQAAA5ibGFrZTJiX3VwZGF0ZQABDWJsYWtlMmJfZmluYWwAAhBibGFrZTJiX2NvbXByZXNzAAMK00AElgMAIABCADcDACAAQQhqQgA3AwAgAEEQakIANwMAIABBGGpCADcDACAAQSBqQgA3AwAgAEEoakIANwMAIABBMGpCADcDACAAQThqQgA3AwAgAEHAAGpCADcDACAAQcgAakIANwMAIABB0ABqQgA3AwAgAEHYAGpCADcDACAAQeAAakIANwMAIABB6ABqQgA3AwAgAEHwAGpCADcDACAAQfgAakIANwMAIABBgAFqQoiS853/zPmE6gBBACkDAIU3AwAgAEGIAWpCu86qptjQ67O7f0EIKQMAhTcDACAAQZABakKr8NP0r+68tzxBECkDAIU3AwAgAEGYAWpC8e30+KWn/aelf0EYKQMAhTcDACAAQaABakLRhZrv+s+Uh9EAQSApAwCFNwMAIABBqAFqQp/Y+dnCkdqCm39BKCkDAIU3AwAgAEGwAWpC6/qG2r+19sEfQTApAwCFNwMAIABBuAFqQvnC+JuRo7Pw2wBBOCkDAIU3AwAgAEHAAWpCADcDACAAQcgBakIANwMAIABB0AFqQgA3AwALbQEDfyAAQcABaiEDIABByAFqIQQgBCkDAKchBQJAA0AgASACRg0BIAVBgAFGBEAgAyADKQMAIAWtfDcDAEEAIQUgABADCyAAIAVqIAEtAAA6AAAgBUEBaiEFIAFBAWohAQwACwsgBCAFrTcDAAtkAQN/IABBwAFqIQEgAEHIAWohAiABIAEpAwAgAikDAHw3AwAgAEHQAWpCfzcDACACKQMApyEDAkADQCADQYABRg0BIAAgA2pBADoAACADQQFqIQMMAAsLIAIgA603AwAgABADC+U7AiB+CX8gAEGAAWohISAAQYgBaiEiIABBkAFqISMgAEGYAWohJCAAQaAB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iEIIAMgCCAYfHwhAyAOIAOFQhCKIQ4gCSAOfCEJIAggCYVCP4ohCCAEIAUgFnx8IQQgDyAEhUIgiiEPIAogD3whCiAFIAqFQhiKIQUgBCAFIBR8fCEEIA8gBIVCEIohDyAKIA98IQogBSAKhUI/iiEFICEgISkDACABIAmFhTcDACAiICIpAwAgAiAKhYU3AwAgIyAjKQMAIAMgC4WFNwMAICQgJCkDACAEIAyFhTcDACAlICUpAwAgBSANhYU3AwAgJiAmKQMAIAYgDoWFNwMAICcgJykDACAHIA+FhTcDACAoICgpAwAgCCAQhYU3AwAL"),r=null,n={buffer:t,memory:null,exports:null,realloc:a,onload:c};return c(function(){}),n;function a(p){n.exports.memory.grow(Math.ceil(Math.abs(p-n.memory.length)/65536)),n.memory=new Uint8Array(n.exports.memory.buffer)}function c(p){if(n.exports)return p();if(r){r.then(p.bind(null,null)).catch(p);return}try{if(s&&s.async)throw new Error("async");l({instance:new WebAssembly.Instance(new WebAssembly.Module(t),e)})}catch{r=WebAssembly.instantiate(t,e).then(l)}c(p)}function l(p){n.exports=p.instance.exports,n.memory=n.exports.memory&&n.exports.memory.buffer&&new Uint8Array(n.exports.memory.buffer)}}function fs(s){return typeof atob=="function"?new Uint8Array(atob(s).split("").map(gs)):new(ds("buffer")).Buffer(s,"base64")}function gs(s){return s.charCodeAt(0)}var xt=xr,j=hs(),bt=64,he=[];Et.exports=mt;var ze=Et.exports.BYTES_MIN=16,We=Et.exports.BYTES_MAX=64;Et.exports.BYTES=32;var je=Et.exports.KEYBYTES_MIN=16,Je=Et.exports.KEYBYTES_MAX=64;Et.exports.KEYBYTES=32;var Xe=Et.exports.SALTBYTES=16,Ze=Et.exports.PERSONALBYTES=16;function mt(s,e,t,r,n){if(!(this instanceof mt))return new mt(s,e,t,r,n);if(!(j&&j.exports))throw new Error("WASM not loaded. Wait for Blake2b.ready(cb)");s||(s=32),n!==!0&&(xt(s>=ze,"digestLength must be at least "+ze+", was given "+s),xt(s<=We,"digestLength must be at most "+We+", was given "+s),e!=null&&xt(e.length>=je,"key must be at least "+je+", was given "+e.length),e!=null&&xt(e.length<=Je,"key must be at least "+Je+", was given "+e.length),t!=null&&xt(t.length===Xe,"salt must be exactly "+Xe+", was given "+t.length),r!=null&&xt(r.length===Ze,"personal must be exactly "+Ze+", was given "+r.length)),he.length||(he.push(bt),bt+=216),this.digestLength=s,this.finalized=!1,this.pointer=he.pop(),j.memory.fill(0,0,64),j.memory[0]=this.digestLength,j.memory[1]=e?e.length:0,j.memory[2]=1,j.memory[3]=1,t&&j.memory.set(t,32),r&&j.memory.set(r,48),this.pointer+216>j.memory.length&&j.realloc(this.pointer+216),j.exports.blake2b_init(this.pointer,this.digestLength),e&&(this.update(e),j.memory.fill(0,bt,bt+e.length),j.memory[this.pointer+200]=128)}mt.prototype.update=function(s){return xt(this.finalized===!1,"Hash instance finalized"),xt(s,"input must be TypedArray or Buffer"),bt+s.length>j.memory.length&&j.realloc(bt+s.length),j.memory.set(s,bt),j.exports.blake2b_update(this.pointer,bt,bt+s.length),this};mt.prototype.digest=function(s){if(xt(this.finalized===!1,"Hash instance finalized"),this.finalized=!0,he.push(this.pointer),j.exports.blake2b_final(this.pointer),!s||s==="binary")return j.memory.slice(this.pointer+128,this.pointer+128+this.digestLength);if(s==="hex")return As(j.memory,this.pointer+128,this.digestLength);xt(s.length>=this.digestLength,"input must be TypedArray or Buffer");for(var e=0;e<this.digestLength;e++)s[e]=j.memory[this.pointer+128+e];return s};mt.prototype.final=mt.prototype.digest;mt.WASM=j&&j.buffer;mt.SUPPORTED=typeof WebAssembly<"u";mt.ready=function(s){if(s||(s=ms),!j)return s(new Error("WebAssembly not supported"));var e=new Promise(function(t,r){j.onload(function(n){n?r():t(),s(n)})});return e};mt.prototype.ready=mt.ready;function ms(){}function As(s,e,t){for(var r="",n=0;n<t;n++)r+=ps(s[e+n]);return r}function ps(s){return s<16?"0"+s.toString(16):s.toString(16)}var Ut=xr,ne=Et.exports;function oe(s,e,t){var r=s[e]+s[t],n=s[e+1]+s[t+1];r>=4294967296&&n++,s[e]=r,s[e+1]=n}function tr(s,e,t,r){var n=s[e]+t;t<0&&(n+=4294967296);var a=s[e+1]+r;n>=4294967296&&a++,s[e]=n,s[e+1]=a}function wr(s,e){return s[e]^s[e+1]<<8^s[e+2]<<16^s[e+3]<<24}function Nt(s,e,t,r,n,a){var c=ee[n],l=ee[n+1],p=ee[a],A=ee[a+1];oe(H,s,e),tr(H,s,c,l);var C=H[r]^H[s],E=H[r+1]^H[s+1];H[r]=E,H[r+1]=C,oe(H,t,r),C=H[e]^H[t],E=H[e+1]^H[t+1],H[e]=C>>>24^E<<8,H[e+1]=E>>>24^C<<8,oe(H,s,e),tr(H,s,p,A),C=H[r]^H[s],E=H[r+1]^H[s+1],H[r]=C>>>16^E<<16,H[r+1]=E>>>16^C<<16,oe(H,t,r),C=H[e]^H[t],E=H[e+1]^H[t+1],H[e]=E>>>31^C<<1,H[e+1]=C>>>31^E<<1}var Cr=new Uint32Array([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Is=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3],at=new Uint8Array(Is.map(function(s){return s*2})),H=new Uint32Array(32),ee=new Uint32Array(32);function Br(s,e){var t=0;for(t=0;t<16;t++)H[t]=s.h[t],H[t+16]=Cr[t];for(H[24]=H[24]^s.t,H[25]=H[25]^s.t/4294967296,e&&(H[28]=~H[28],H[29]=~H[29]),t=0;t<32;t++)ee[t]=wr(s.b,4*t);for(t=0;t<12;t++)Nt(0,8,16,24,at[t*16+0],at[t*16+1]),Nt(2,10,18,26,at[t*16+2],at[t*16+3]),Nt(4,12,20,28,at[t*16+4],at[t*16+5]),Nt(6,14,22,30,at[t*16+6],at[t*16+7]),Nt(0,10,20,30,at[t*16+8],at[t*16+9]),Nt(2,12,22,24,at[t*16+10],at[t*16+11]),Nt(4,14,16,26,at[t*16+12],at[t*16+13]),Nt(6,8,18,28,at[t*16+14],at[t*16+15]);for(t=0;t<16;t++)s.h[t]=s.h[t]^H[t]^H[t+16]}var Pt=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]);function Wt(s,e,t,r){Pt.fill(0),this.b=new Uint8Array(128),this.h=new Uint32Array(16),this.t=0,this.c=0,this.outlen=s,Pt[0]=s,e&&(Pt[1]=e.length),Pt[2]=1,Pt[3]=1,t&&Pt.set(t,32),r&&Pt.set(r,48);for(var n=0;n<16;n++)this.h[n]=Cr[n]^wr(Pt,n*4);e&&(Er(this,e),this.c=128)}Wt.prototype.update=function(s){return Ut(s!=null,"input must be Uint8Array or Buffer"),Er(this,s),this};Wt.prototype.digest=function(s){var e=!s||s==="binary"||s==="hex"?new Uint8Array(this.outlen):s;return Ut(e.length>=this.outlen,"out must have at least outlen bytes of space"),_s(this,e),s==="hex"?ys(e):e};Wt.prototype.final=Wt.prototype.digest;Wt.ready=function(s){ne.ready(function(){s()})};function Er(s,e){for(var t=0;t<e.length;t++)s.c===128&&(s.t+=s.c,Br(s,!1),s.c=0),s.b[s.c++]=e[t]}function _s(s,e){for(s.t+=s.c;s.c<128;)s.b[s.c++]=0;Br(s,!0);for(var t=0;t<s.outlen;t++)e[t]=s.h[t>>2]>>8*(t&3);return e}function ys(s){for(var e="",t=0;t<s.length;t++)e+=xs(s[t]);return e}function xs(s){return s<16?"0"+s.toString(16):s.toString(16)}var Sr=Wt;ut.exports=function(e,t,r,n,a){return a!==!0&&(Ut(e>=er,"outlen must be at least "+er+", was given "+e),Ut(e<=rr,"outlen must be at most "+rr+", was given "+e),t!=null&&Ut(t.length>=sr,"key must be at least "+sr+", was given "+t.length),t!=null&&Ut(t.length<=nr,"key must be at most "+nr+", was given "+t.length),r!=null&&Ut(r.length===ir,"salt must be exactly "+ir+", was given "+r.length),n!=null&&Ut(n.length===ar,"personal must be exactly "+ar+", was given "+n.length)),new Sr(e,t,r,n)};ut.exports.ready=function(s){ne.ready(function(){s()})};ut.exports.WASM_SUPPORTED=ne.SUPPORTED;ut.exports.WASM_LOADED=!1;var er=ut.exports.BYTES_MIN=16,rr=ut.exports.BYTES_MAX=64;ut.exports.BYTES=32;var sr=ut.exports.KEYBYTES_MIN=16,nr=ut.exports.KEYBYTES_MAX=64;ut.exports.KEYBYTES=32;var ir=ut.exports.SALTBYTES=16,ar=ut.exports.PERSONALBYTES=16;ne.ready(function(s){s||(ut.exports.WASM_LOADED=!0,Sr=ne)});var jt={};Object.defineProperty(jt,"__esModule",{value:!0});jt.bech32m=jt.bech32=void 0;const Ae="qpzry9x8gf2tvdw0s3jn54khce6mua7l",vr={};for(let s=0;s<Ae.length;s++){const e=Ae.charAt(s);vr[e]=s}function $t(s){const e=s>>25;return(s&33554431)<<5^-(e>>0&1)&996825010^-(e>>1&1)&642813549^-(e>>2&1)&513874426^-(e>>3&1)&1027748829^-(e>>4&1)&705979059}function or(s){let e=1;for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);if(r<33||r>126)return"Invalid prefix ("+s+")";e=$t(e)^r>>5}e=$t(e);for(let t=0;t<s.length;++t){const r=s.charCodeAt(t);e=$t(e)^r&31}return e}function Fe(s,e,t,r){let n=0,a=0;const c=(1<<t)-1,l=[];for(let p=0;p<s.length;++p)for(n=n<<e|s[p],a+=e;a>=t;)a-=t,l.push(n>>a&c);if(r)a>0&&l.push(n<<t-a&c);else{if(a>=e)return"Excess padding";if(n<<t-a&c)return"Non-zero padding"}return l}function ws(s){return Fe(s,8,5,!0)}function Cs(s){const e=Fe(s,5,8,!1);if(Array.isArray(e))return e}function Bs(s){const e=Fe(s,5,8,!1);if(Array.isArray(e))return e;throw new Error(e)}function br(s){let e;s==="bech32"?e=1:e=734539939;function t(c,l,p){if(p=p||90,c.length+7+l.length>p)throw new TypeError("Exceeds length limit");c=c.toLowerCase();let A=or(c);if(typeof A=="string")throw new Error(A);let C=c+"1";for(let E=0;E<l.length;++E){const w=l[E];if(w>>5!==0)throw new Error("Non 5-bit word");A=$t(A)^w,C+=Ae.charAt(w)}for(let E=0;E<6;++E)A=$t(A);A^=e;for(let E=0;E<6;++E){const w=A>>(5-E)*5&31;C+=Ae.charAt(w)}return C}function r(c,l){if(l=l||90,c.length<8)return c+" too short";if(c.length>l)return"Exceeds length limit";const p=c.toLowerCase(),A=c.toUpperCase();if(c!==p&&c!==A)return"Mixed-case string "+c;c=p;const C=c.lastIndexOf("1");if(C===-1)return"No separator character for "+c;if(C===0)return"Missing prefix for "+c;const E=c.slice(0,C),w=c.slice(C+1);if(w.length<6)return"Data too short";let b=or(E);if(typeof b=="string")return b;const P=[];for(let k=0;k<w.length;++k){const N=w.charAt(k),T=vr[N];if(T===void 0)return"Unknown character "+N;b=$t(b)^T,!(k+6>=w.length)&&P.push(T)}return b!==e?"Invalid checksum for "+c:{prefix:E,words:P}}function n(c,l){const p=r(c,l);if(typeof p=="object")return p}function a(c,l){const p=r(c,l);if(typeof p=="object")return p;throw new Error(p)}return{decodeUnsafe:n,decode:a,encode:t,toWords:ws,fromWordsUnsafe:Cs,fromWords:Bs}}jt.bech32=br("bech32");jt.bech32m=br("bech32m");var Es=ke&&ke.__importDefault||function(s){return s&&s.__esModule?s:{default:s}};Object.defineProperty(yr,"__esModule",{value:!0});const Ss=Es(ut.exports),ce=jt,Qe="asset";class re{constructor(e){this.hashBuf=e}static fromHash(e){return new re(e)}static fromParts(e,t){const r=(0,Ss.default)(20).update(new Uint8Array([...e,...t])).digest("binary");return re.fromHash(r)}static fromBech32(e){const{prefix:t,words:r}=ce.bech32.decode(e);if(t!==Qe)throw new Error("Invalid asset fingerprint");const n=Buffer.from(ce.bech32.fromWords(r));return re.fromHash(n)}fingerprint(){const e=ce.bech32.toWords(this.hashBuf);return ce.bech32.encode(Qe,e)}hash(){return Buffer.from(this.hashBuf).toString("hex")}prefix(){return Qe}checksum(){return this.fingerprint().slice(-6)}}var vs=yr.default=re;const bs=vs,Qs=(s,e)=>{const t=Ds(s),r=t.derive(be+1852).derive(be+1815).derive(be+e),n=r.derive(0).derive(0).to_raw_key(),a=r.derive(2).derive(0).to_raw_key();return r.free(),t.free(),{paymentKey:n,stakeKey:a}},Lt=s=>i.Address.from_bytes(G(s)),Ds=s=>i.Bip32PrivateKey.from_bytes(G(s)),ks=s=>i.DataHash.from_bytes(G(s)),Ct=s=>i.Ed25519KeyHash.from_bytes(G(s)),Ts=s=>i.Ed25519Signature.from_bytes(G(s)),_e=s=>i.NativeScript.from_bytes(G(s)),Ns=s=>i.PublicKey.from_bytes(G(s)),Qr=s=>i.PlutusData.from_bytes(G(s)),Jt=(s,e)=>i.PlutusScript.from_bytes_with_version(G(s),vt[e]),Ps=s=>i.ScriptRef.from_bytes(G(s)),Us=s=>i.ScriptHash.from_bytes(G(s)),It=s=>i.Transaction.from_bytes(G(s)),Dr=s=>i.TransactionHash.from_bytes(G(s)),cr=s=>i.TransactionUnspentOutput.from_bytes(G(s)),ur=s=>i.TransactionWitnessSet.from_bytes(G(s)),Os=s=>i.Value.from_bytes(G(s)),_t=s=>i.Address.from_bech32(s),Re=s=>i.BaseAddress.from_address(_t(s)),kr=s=>i.EnterpriseAddress.from_address(_t(s)),Tr=s=>i.RewardAddress.from_address(_t(s)),dt=s=>Buffer.from(s).toString("hex"),G=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?Buffer.from(s,"hex"):Buffer.from(s,"utf-8"),ye=s=>{const e=t=>{const r=new Array;for(let n=0;n<t.len();n+=1)r.push(ye(t.get(n)));return r};switch(s.kind()){case i.NativeScriptKind.ScriptAll:{const t=s.as_script_all();return{type:"all",scripts:e(t.native_scripts())}}case i.NativeScriptKind.ScriptAny:{const t=s.as_script_any();return{type:"any",scripts:e(t.native_scripts())}}case i.NativeScriptKind.ScriptNOfK:{const t=s.as_script_n_of_k();return{type:"atLeast",required:t.n(),scripts:e(t.native_scripts())}}case i.NativeScriptKind.TimelockStart:return{type:"after",slot:s.as_timelock_start().slot_bignum().to_str()};case i.NativeScriptKind.TimelockExpiry:return{type:"before",slot:s.as_timelock_expiry().slot_bignum().to_str()};case i.NativeScriptKind.ScriptPubkey:return{type:"sig",keyHash:s.as_script_pubkey().addr_keyhash().to_hex()};default:throw new Error(`Script Kind: ${s.kind()}, is not supported`)}},xe=s=>{const e=t=>{const r=i.NativeScripts.new();return t.forEach(n=>{r.add(xe(n))}),r};switch(s.type){case"all":return i.NativeScript.new_script_all(i.ScriptAll.new(e(s.scripts)));case"any":return i.NativeScript.new_script_any(i.ScriptAny.new(e(s.scripts)));case"atLeast":return i.NativeScript.new_script_n_of_k(i.ScriptNOfK.new(s.required,e(s.scripts)));case"after":return i.NativeScript.new_timelock_start(i.TimelockStart.new_timelockstart(i.BigNum.from_str(s.slot)));case"before":return i.NativeScript.new_timelock_expiry(i.TimelockExpiry.new_timelockexpiry(i.BigNum.from_str(s.slot)));case"sig":return i.NativeScript.new_script_pubkey(i.ScriptPubkey.new(Ct(s.keyHash)))}},fe=s=>{var r,n,a;const e=c=>{const l=[];for(let p=0;p<c.len();p+=1)l.push(fe(c.get(p)));return l},t=c=>{const l=new Map;for(let p=0;p<c.len();p+=1){const A=c.keys().get(p),C=c.get(A)??i.PlutusData.from_hex(ct("NO_ITEM_FOUND_INSIDE_GOLD_ROOM"));l.set(fe(A),fe(C))}return l};switch(s.kind()){case i.PlutusDataKind.Bytes:return dt(s.as_bytes()??new Uint8Array);case i.PlutusDataKind.Integer:return parseInt(((r=s.as_integer())==null?void 0:r.to_str())??"0",10);case i.PlutusDataKind.List:return e(s.as_list()??i.PlutusList.new());case i.PlutusDataKind.Map:return t(s.as_map()??i.PlutusMap.new());case i.PlutusDataKind.ConstrPlutusData:return{alternative:parseInt(((n=s.as_constr_plutus_data())==null?void 0:n.alternative().to_str())??"0",10),fields:e(((a=s.as_constr_plutus_data())==null?void 0:a.data())??i.PlutusList.new())};default:throw new Error(`PlutusData Kind: ${s.kind()}, is not supported`)}},Ot=s=>{const e=t=>{const r=i.PlutusList.new();return t.forEach(n=>{r.add(Ot(n))}),r};switch(typeof s){case"string":return i.PlutusData.new_bytes(G(s));case"number":return i.PlutusData.new_integer(i.BigInt.from_str(s.toString()));case"bigint":return i.PlutusData.new_integer(i.BigInt.from_str(s.toString()));case"object":if(s instanceof Array){const t=e(s);return i.PlutusData.new_list(t)}else if(s instanceof Map){const t=i.PlutusMap.new();return s.forEach((r,n)=>{t.insert(Ot(n),Ot(r))}),i.PlutusData.new_map(t)}else return i.PlutusData.new_constr_plutus_data(i.ConstrPlutusData.new(i.BigNum.from_str(s.alternative.toString()),e(s.fields)))}},Ms=s=>{const e=i.Relays.new();throw s.relays.forEach(t=>{e.add(Nr(t))}),new Error("toPoolParams not implemented.")},Te=s=>{const e=t=>$r[t];return i.Redeemer.new(e(s.tag),i.BigNum.from_str(s.index.toString()),Ot(s.data),i.ExUnits.new(i.BigNum.from_str(s.budget.mem.toString()),i.BigNum.from_str(s.budget.steps.toString())))},Nr=s=>{switch(s.type){case"SingleHostAddr":{const e=s.IPV4?i.Ipv4.new(new Uint8Array(s.IPV4.split(".").map(r=>parseInt(r)))):void 0,t=s.IPV6?i.Ipv6.new(G(s.IPV6.replaceAll(":",""))):void 0;return i.Relay.new_single_host_addr(i.SingleHostAddr.new(s.port,e,t))}case"SingleHostName":return i.Relay.new_single_host_name(i.SingleHostName.new(s.port,i.DNSRecordAorAAAA.new(s.domainName)));case"MultiHostName":return i.Relay.new_multi_host_name(i.MultiHostName.new(i.DNSRecordSRV.new(s.domainName)))}},Pr=s=>{if(s.is_plutus_script()){const t=s.plutus_script();return{code:t.to_hex(),version:Object.keys(vt).find(r=>vt[r].to_hex()===t.language_version().to_hex())}}const e=s.native_script();return ye(e)},Xt=s=>{if("code"in s){const e=Jt(s.code,s.version);return i.ScriptRef.new_plutus_script(e)}return i.ScriptRef.new_native_script(xe(s))},pe=s=>{var n,a,c;const e=s.output().has_data_hash()?(n=s.output().data_hash())==null?void 0:n.to_hex():void 0,t=s.output().has_plutus_data()?(a=s.output().plutus_data())==null?void 0:a.to_hex():void 0,r=s.output().has_script_ref()?(c=s.output().script_ref())==null?void 0:c.to_hex():void 0;return{input:{outputIndex:s.input().index(),txHash:s.input().transaction_id().to_hex()},output:{address:s.output().address().to_bech32(),amount:Ur(s.output().amount()),dataHash:e,plutusData:t,scriptRef:r}}},wt=s=>{const e=i.TransactionInput.new(Dr(s.input.txHash),s.input.outputIndex),t=i.TransactionOutput.new(_t(s.output.address),Qt(s.output.amount));return s.output.dataHash!==void 0&&t.set_data_hash(ks(s.output.dataHash)),s.output.plutusData!==void 0&&t.set_plutus_data(Qr(s.output.plutusData)),s.output.scriptRef!==void 0&&t.set_script_ref(Ps(s.output.scriptRef)),i.TransactionUnspentOutput.new(e,t)},lr=s=>{const e=s.split(".")[1]??"0",t=`${parseInt(e,10)}`,r="1"+"0".repeat(e.length);return i.UnitInterval.new(i.BigNum.from_str(t),i.BigNum.from_str(r))},ct=s=>s.length%2===0&&/^[0-9A-F]*$/i.test(s)?s:dt(Buffer.from(s,"utf-8")),qe=s=>Buffer.from(s,"hex").toString("utf-8"),Ur=s=>{const e=[{unit:"lovelace",quantity:s.coin().to_str()}],t=s.multiasset();if(t!==void 0){const r=t.keys();for(let n=0;n<r.len();n+=1){const a=r.get(n),c=t.get(a);if(c!==void 0){const l=c.keys();for(let p=0;p<l.len();p+=1){const A=l.get(p),C=c.get(A)??i.BigNum.from_str("0"),E=a.to_hex()+dt(A.name());e.push({unit:E,quantity:C.to_str()})}}}}return e},Qt=s=>{const e=s.find(a=>a.unit==="lovelace"),t=Array.from(new Set(s.filter(a=>a.unit!=="lovelace").map(a=>a.unit.slice(0,Bt)))),r=i.MultiAsset.new();t.forEach(a=>{const c=i.Assets.new();s.filter(l=>l.unit.slice(0,Bt)===a).forEach(l=>{c.insert(i.AssetName.new(G(l.unit.slice(Bt))),i.BigNum.from_str(l.quantity))}),r.insert(Us(a),c)});const n=i.Value.new(i.BigNum.from_str(e?e.quantity:"0"));return(s.length>1||!e)&&n.set_multiasset(r),n},dr=(s,e,t)=>i.BaseAddress.new(s,i.StakeCredential.from_keyhash(e),i.StakeCredential.from_keyhash(t)),Or=(s,e="")=>i.Bip32PrivateKey.from_bip39_entropy(G(s),G(ct(e))),Ne=s=>i.DataCost.new_coins_per_byte(i.BigNum.from_str(s)),Ks=s=>{if(typeof s!="object"||!("input"in s))return i.DatumSource.new(Ot(s));const e=wt(s);if(e.output().has_plutus_data())return i.DatumSource.new_ref_input(e.input());throw new Error(`No inline datum found in UTxO: ${e.input().transaction_id().to_hex()}`)},hr=(s,e)=>i.EnterpriseAddress.new(s,i.StakeCredential.from_keyhash(e)),fr=(s,e)=>{if(typeof s=="string")return i.MintWitness.new_native_script(_e(s));if(e===void 0)throw new Error("Minting with plutus requires a redeemer to be defined");if(e.tag!=="MINT")throw new Error("Minting redeemer's tag must be defined as 'MINT'");return i.MintWitness.new_plutus_script(Ue(s),Te({tag:"MINT",index:0,budget:Gt,data:{alternative:0,fields:[]},...e}))},Pe=(s,e)=>i.RewardAddress.new(s,i.StakeCredential.from_keyhash(e)),Ue=s=>{if("code"in s)return i.PlutusScriptSource.new(Jt(s.code,s.version));const e=wt(s);if(e.output().has_script_ref()){const t=e.output().script_ref();if(t.is_plutus_script()){const r=Pr(t),n=Jt(r.code,r.version).hash();return i.PlutusScriptSource.new_ref_input_with_lang_ver(n,e.input(),vt[r.version])}}throw new Error(`No plutus script reference found in UTxO: ${e.input().transaction_id().to_hex()}`)},ue=s=>{const e=i.ScriptPubkey.new(s);return i.NativeScript.new_script_pubkey(e)},ge=(s=gt)=>{const e=i.TransactionBuilderConfigBuilder.new().coins_per_utxo_byte(i.BigNum.from_str(s.coinsPerUTxOSize)).ex_unit_prices(i.ExUnitPrices.new(lr(s.priceMem.toString()),lr(s.priceStep.toString()))).fee_algo(i.LinearFee.new(i.BigNum.from_str(s.minFeeA.toString()),i.BigNum.from_str(s.minFeeB.toString()))).key_deposit(i.BigNum.from_str(s.keyDeposit)).max_tx_size(s.maxTxSize).max_value_size(parseInt(s.maxValSize,10)).pool_deposit(i.BigNum.from_str(s.poolDeposit)).build();return i.TransactionBuilder.new(e)},gr=s=>{const e=i.TxInputsBuilder.new();return s.map(t=>t instanceof i.TransactionUnspentOutput?t:wt(t)).forEach(t=>{e.add_input(t.output().address(),t.input(),t.output().amount())}),e},le=s=>{if(typeof s=="string")return i.TransactionOutputBuilder.new().with_address(_t(s));let e=i.TransactionOutputBuilder.new().with_address(_t(s.address));if(s.datum){const{value:t,inline:r}=s.datum,n=Ot(t);e=e.with_data_hash(i.hash_plutus_data(n)),r&&(e=e.with_plutus_data(n))}if(s.script){const t=Xt(s.script);e=e.with_script_ref(t)}return e},kt=s=>{const e=s.slice(0,Bt),t=s.includes(".")?ct(s.split(".")[1]):s.slice(Bt);return{policyId:e,assetName:t}},S=s=>Mt.default.isAxiosError(s)?s.response?JSON.stringify({data:s.response.data,headers:s.response.headers,status:s.response.status}):s.request?JSON.stringify(s.request):s.message:JSON.stringify(s),Hs=s=>{const e=Ot(s);return i.hash_plutus_data(e).to_hex()},Fs=(s,e=Date.now())=>{if(me[s]){const[t,r,n,a]=me[s];return parseInt(i.BigNum.from_str(e.toString()).div_floor(i.BigNum.from_str("1000")).checked_sub(i.BigNum.from_str(n)).div_floor(i.BigNum.from_str(a)).checked_add(i.BigNum.from_str(t)).to_str(),10)}throw new Error(`Couldn't resolve EpochNo for network: ${s}`)},Mr=(s,e)=>bs.fromParts(G(s),G(e)).fingerprint(),Rs=(s,e)=>zr[s][e],qs=s=>xe(s).hash().to_hex(),qt=s=>{var e,t;try{const r=[(e=Re(s))==null?void 0:e.payment_cred().to_keyhash(),(t=kr(s))==null?void 0:t.payment_cred().to_keyhash()].find(n=>n!==void 0);if(r!==void 0)return r.to_hex();throw new Error(`Couldn't resolve payment key hash from address: ${s}`)}catch(r){throw new Error(`An error occurred during resolvePaymentKeyHash: ${r}.`)}},Vs=(s,e=0)=>{const t=Jt(s.code,s.version);return i.EnterpriseAddress.new(e,i.StakeCredential.from_scripthash(t.hash())).to_address().to_bech32()},Ls=s=>{try{const e=kr(s),t=e==null?void 0:e.payment_cred().to_scripthash();if(t!==void 0)return t.to_hex();throw new Error(`Couldn't resolve script hash from address: ${s}`)}catch(e){throw new Error(`An error occurred during resolveScriptHash: ${e}.`)}},Gs=s=>i.Ed25519KeyHash.from_hex(s).to_bech32("pool1"),Ys=s=>{const e=De.mnemonicToEntropy(s.join(" ")),t=Or(e),r=t.to_bech32();return t.free(),r},$s=s=>Xt(s).to_hex(),zs=(s,e=Date.now())=>{if(me[s]){const[t,r,n]=me[s];return i.BigNum.from_str(e.toString()).div_floor(i.BigNum.from_str("1000")).checked_sub(i.BigNum.from_str(n)).checked_add(i.BigNum.from_str(r)).to_str()}throw new Error(`Couldn't resolve SlotNo for network: ${s}`)},ie=s=>{try{const e=_t(s),t=Re(s),r=t==null?void 0:t.stake_cred().to_keyhash();if(r!==void 0)return Pe(e.network_id(),r).to_address().to_bech32();throw new Error(`Couldn't resolve reward address from address: ${s}`)}catch(e){throw new Error(`An error occurred during resolveRewardAddress: ${e}.`)}},Yt=s=>{var e,t;try{const r=[(e=Re(s))==null?void 0:e.stake_cred().to_keyhash(),(t=Tr(s))==null?void 0:t.payment_cred().to_keyhash()].find(n=>n!==void 0);if(r!==void 0)return r.to_hex();throw new Error(`Couldn't resolve stake key hash from address: ${s}`)}catch(r){throw new Error(`An error occurred during resolveStakeKeyHash: ${r}.`)}},Ve=(s,e=gt.minFeeA,t=gt.minFeeB)=>(BigInt(e)*BigInt(s)+BigInt(t)).toString(),Kr=s=>{const e=It(s).body();return i.hash_transaction(e).to_hex()},Ws=(s="",e=32)=>{if(e<=0||e>2048)throw new Error("Length must be bewteen 1 and 2048");const r=mr.customAlphabet("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789")(e);return ct(`${s}${r}`)},Oe=(s,e)=>{const t=s.vkeys();if(t!==void 0){const r=new Set;for(let a=0;a<t.len();a+=1)r.add(t.get(a).to_hex());for(let a=0;a<e.len();a+=1)r.add(e.get(a).to_hex());const n=i.Vkeywitnesses.new();return r.forEach(a=>{n.add(i.Vkeywitness.from_hex(a))}),n}return e},js=s=>fe(Qr(s)),Js=s=>It(s).to_js_value();class Xs{_axiosInstance;constructor(...e){if(typeof e[0]=="string"&&e[0].startsWith("http"))this._axiosInstance=Mt.default.create({baseURL:e[0]});else{const t=e[0],r=t.slice(0,7);this._axiosInstance=Mt.default.create({baseURL:`https://cardano-${r}.blockfrost.io/api/v${e[1]??0}`,headers:{project_id:t}})}}async fetchAccountInfo(e){const t=e.startsWith("addr")?ie(e):e;try{const{data:r,status:n}=await this._axiosInstance.get(`accounts/${t}`);if(n===200)return{poolId:r.pool_id,active:r.active||r.active_epoch!==null,balance:r.controlled_amount,rewards:r.withdrawable_amount,withdrawals:r.withdrawals_sum};throw S(r)}catch(r){throw S(r)}}resolveScriptRef=async e=>{if(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}`);if(r===200){const n=t.type.startsWith("plutus")?{code:await this.fetchPlutusScriptCBOR(e),version:t.type.replace("plutus","")}:await this.fetchNativeScriptJSON(e);return Xt(n).to_hex()}throw S(t)}};toUTxO=async(e,t)=>({input:{outputIndex:e.output_index,txHash:t},output:{address:e.address,amount:e.amount,dataHash:e.data_hash??void 0,plutusData:e.inline_datum??void 0,scriptRef:await this.resolveScriptRef(e.reference_script_hash),scriptHash:e.reference_script_hash}});async fetchAddressUTxOs(e,t){const r=t!==void 0?`/${t}`:"",n=`addresses/${e}/utxos`+r,a=async(c=1,l=[])=>{const{data:p,status:A}=await this._axiosInstance.get(`${n}?page=${c}`);if(A===200)return p.length>0?a(c+1,[...l,...await Promise.all(p.map(C=>this.toUTxO(C,C.tx_hash)))]):l;throw S(p)};try{return await a()}catch{return[]}}async fetchAssetAddresses(e){const t=async(r=1,n=[])=>{const{policyId:a,assetName:c}=kt(e),{data:l,status:p}=await this._axiosInstance.get(`assets/${a}${c}/addresses?page=${r}`);if(p===200)return l.length>0?t(r+1,[...n,...l]):n;throw S(l)};try{return await t()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:a}=await this._axiosInstance.get(`assets/${t}${r}`);if(a===200)return{...n.onchain_metadata};throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`blocks/${e}`);if(r===200)return{confirmations:t.confirmations,epoch:t.epoch,epochSlot:t.epoch_slot.toString(),fees:t.fees,hash:t.hash,nextBlock:t.next_block??"",operationalCertificate:t.op_cert,output:t.output??"0",previousBlock:t.previous_block,size:t.size,slot:t.slot.toString(),slotLeader:t.slot_leader??"",time:t.time,txCount:t.tx_count,VRFKey:t.block_vrf};throw S(t)}catch(t){throw S(t)}}async fetchCollectionAssets(e,t=1){try{const{data:r,status:n}=await this._axiosInstance.get(`assets/policy/${e}?page=${t}`);if(n===200)return{assets:r.map(a=>({unit:a.asset,quantity:a.quantity})),next:r.length===100?t+1:null};throw S(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=ct(e.replace("$","")),{data:r,status:n}=await this._axiosInstance.get(`assets/${Me[1]}${t}/addresses`);if(n===200)return r[0].address;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e=Number.NaN){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${isNaN(e)?"latest":e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_word,collateralPercent:t.collateral_percent,decentralisation:t.decentralisation_param,epoch:t.epoch,keyDeposit:t.key_deposit,maxBlockExMem:t.max_block_ex_mem,maxBlockExSteps:t.max_block_ex_steps,maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem,maxTxExSteps:t.max_tx_ex_steps,maxTxSize:t.max_tx_size,maxValSize:t.max_val_size,minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost,poolDeposit:t.pool_deposit,priceMem:t.price_mem,priceStep:t.price_step};throw S(t)}catch(t){throw S(t)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`txs/${e}`);if(r===200)return{block:t.block,deposit:t.deposit,fees:t.fees,hash:t.hash,index:t.index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.slot.toString(),size:t.size};throw S(t)}catch(t){throw S(t)}}async fetchUTxOs(e){try{const{data:t,status:r}=await this._axiosInstance.get(`txs/${e}/utxos`);if(r===200){const n=t.outputs,a=[];return n.forEach(l=>{a.push(this.toUTxO(l,e))}),await Promise.all(a)}throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const a=setInterval(()=>{n>=r&&clearInterval(a),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(a),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:n}=await this._axiosInstance.post("tx/submit",G(e),{headers:t});if(n===200)return r;throw S(r)}catch(t){throw S(t)}}async fetchPlutusScriptCBOR(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/cbor`);if(r===200)return t.cbor;throw S(t)}async fetchNativeScriptJSON(e){const{data:t,status:r}=await this._axiosInstance.get(`scripts/${e}/json`);if(r===200)return t.json;throw S(t)}}class Zs{_axiosInstance;constructor(e,t,r){const n=r.host??"ipfs.infura.io",a=r.port??5001,c=r.version??0;this._axiosInstance=Mt.default.create({baseURL:`https://${n}:${a}/api/v${c}`,auth:{username:e,password:t}})}async uploadContent(e,t=!1){try{const r={"Content-Type":"multipart/form-data"},{data:n,status:a}=await this._axiosInstance.post(`add?recursive=${t}`,e,{headers:r});if(a===200)return n;throw S(n)}catch(r){throw S(r)}}}class tn{_axiosInstance;constructor(...e){typeof e[0]=="string"&&e[0].startsWith("http")?this._axiosInstance=Mt.default.create({baseURL:e[0],headers:{Authorization:`Bearer ${e[1]}`}}):this._axiosInstance=Mt.default.create({baseURL:`https://${e[0]}.koios.rest/api/v${e[2]??0}`,headers:{Authorization:`Bearer ${e[1]}`}})}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?ie(e):e,{data:r,status:n}=await this._axiosInstance.post("account_info",{_stake_addresses:[t]});if(n===200)return{poolId:r[0].delegated_pool,active:r[0].status==="registered",balance:r[0].total_balance.toString(),rewards:r[0].rewards_available,withdrawals:r[0].withdrawals};throw S(r)}catch(t){throw S(t)}}async fetchAddressUTxOs(e,t){try{const{data:r,status:n}=await this._axiosInstance.post("address_info",{_addresses:[e]});if(n===200){const a=r.flatMap(c=>c.utxo_set).map(c=>this.toUTxO(c,e));return t!==void 0?a.filter(c=>c.output.amount.find(l=>l.unit===t)!==void 0):a}throw S(r)}catch{return[]}}async fetchAssetAddresses(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:a}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${t}&_asset_name=${r}`);if(a===200)return n.map(c=>({address:c.payment_address,quantity:c.quantity}));throw S(n)}catch(t){throw S(t)}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:a}=await this._axiosInstance.get(`asset_info?_asset_policy=${t}&_asset_name=${r}`);if(a===200)return{...n[0].minting_tx_metadata[721][t][qe(r)]};throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){try{const{data:t,status:r}=await this._axiosInstance.post("block_info",{_block_hashes:[e]});if(r===200)return{confirmations:t[0].num_confirmations,epoch:t[0].epoch_no,epochSlot:t[0].epoch_slot.toString(),fees:t[0].total_fees??"",hash:t[0].hash,nextBlock:t[0].child_hash??"",operationalCertificate:t[0].op_cert,output:t[0].total_output??"0",previousBlock:t[0].parent_hash,size:t[0].block_size,slot:t[0].abs_slot.toString(),slotLeader:t[0].pool??"",time:t[0].block_time,txCount:t[0].tx_count,VRFKey:t[0].vrf_key};throw S(t)}catch(t){throw S(t)}}async fetchCollectionAssets(e,t=0){try{const{data:r,status:n}=await this._axiosInstance.get(`asset_policy_info?_asset_policy=${e}&limit=100&offset=${t}`);if(n===200)return{assets:r.map(a=>({unit:`${e}${a.asset_name}`,quantity:a.total_supply})),next:r.length===100?t+100:null};throw S(r)}catch(r){throw S(r)}}async fetchHandleAddress(e){try{const t=ct(e.replace("$","")),{data:r,status:n}=await this._axiosInstance.get(`asset_address_list?_asset_policy=${Me[1]}&_asset_name=${t}`);if(n===200)return r[0].payment_address;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epoch_params?_epoch_no=${e}`);if(r===200)return{coinsPerUTxOSize:t[0].coins_per_utxo_size,collateralPercent:t[0].collateral_percent,decentralisation:t[0].decentralisation,epoch:t[0].epoch_no,keyDeposit:t[0].key_deposit,maxBlockExMem:t[0].max_block_ex_mem.toString(),maxBlockExSteps:t[0].max_block_ex_steps.toString(),maxBlockHeaderSize:t[0].max_bh_size,maxBlockSize:t[0].max_block_size,maxCollateralInputs:t[0].max_collateral_inputs,maxTxExMem:t[0].max_tx_ex_mem.toString(),maxTxExSteps:t[0].max_tx_ex_steps.toString(),maxTxSize:t[0].max_tx_size,maxValSize:t[0].max_val_size.toString(),minFeeA:t[0].min_fee_a,minFeeB:t[0].min_fee_b,minPoolCost:t[0].min_pool_cost,poolDeposit:t[0].pool_deposit,priceMem:t[0].price_mem,priceStep:t[0].price_step};throw S(t)}catch(t){throw S(t)}}async fetchTxInfo(e){var t,r;try{const{data:n,status:a}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(a===200)return{block:n[0].block_hash,deposit:n[0].deposit,fees:n[0].fee,hash:n[0].tx_hash,index:n[0].tx_block_index,invalidAfter:((t=n[0].invalid_after)==null?void 0:t.toString())??"",invalidBefore:((r=n[0].invalid_before)==null?void 0:r.toString())??"",slot:n[0].absolute_slot.toString(),size:n[0].tx_size};throw S(n)}catch(n){throw S(n)}}async fetchUTxOs(e){try{console.log("hi");const{data:t,status:r}=await this._axiosInstance.post("tx_info",{_tx_hashes:[e]});if(r===200)return console.log(t[0]),t[0].outputs.map(a=>this.toUTxO(a,a.payment_addr.bech32));throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const a=setInterval(()=>{n>=r&&clearInterval(a),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(a),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:n}=await this._axiosInstance.post("submittx",G(e),{headers:t});if(n===202)return r;throw S(r)}catch(t){throw S(t)}}toUTxO(e,t){var r,n;return{input:{outputIndex:e.tx_index,txHash:e.tx_hash},output:{address:t,amount:[{unit:"lovelace",quantity:e.value},...e.asset_list.map(a=>({unit:`${a.policy_id}${a.asset_name}`,quantity:`${a.quantity}`}))],dataHash:e.datum_hash??void 0,plutusData:((r=e.inline_datum)==null?void 0:r.bytes)??void 0,scriptRef:this.resolveScriptRef(e.reference_script),scriptHash:((n=e.reference_script)==null?void 0:n.hash)??void 0}}}resolveScriptRef=e=>{if(e){const t=e.type.startsWith("plutus")?{code:e.bytes,version:e.type.replace("plutus","")}:ye(_e(e.bytes));return Xt(t).to_hex()}}}class en{_baseUrl;constructor(...e){this._baseUrl=Ar(e[0])?Wr[e[0]]:e[0]}async evaluateTx(e){const t=await this.open();return this.send(t,"EvaluateTx",{evaluate:e}),new Promise((r,n)=>{t.addEventListener("message",a=>{try{const{result:c}=JSON.parse(a.data);c.EvaluationResult?r(Object.keys(c.EvaluationResult).map(l=>({index:parseInt(l.split(":")[1],10),tag:l.split(":")[0].toUpperCase(),budget:{mem:c.EvaluationResult[l].memory,steps:c.EvaluationResult[l].steps}}))):n(c.EvaluationFailure),t.close()}catch(c){n(c)}},{once:!0})})}async onNextTx(e){const t=await this.open();return this.send(t,"AwaitAcquire",{}),t.addEventListener("message",r=>{const{result:n}=JSON.parse(r.data);if(n===null)return this.send(t,"AwaitAcquire",{});n.AwaitAcquired===void 0&&e(n),this.send(t,"NextTx",{})}),()=>t.close()}async submitTx(e){const t=await this.open();return this.send(t,"SubmitTx",{submit:e}),new Promise((r,n)=>{t.addEventListener("message",a=>{try{const{result:c}=JSON.parse(a.data);c.SubmitSuccess?r(c.SubmitSuccess.txId):n(c.SubmitFail),t.close()}catch(c){n(c)}},{once:!0})})}async open(){const e=new WebSocket(this._baseUrl);return await new Promise(t=>{e.addEventListener("open",()=>t(!0),{once:!0})}),e}send(e,t,r){e.send(JSON.stringify({version:"1.0",type:"jsonwsp/request",servicename:"ogmios",methodname:t,args:r}))}}class rn{_axiosInstance;constructor(e,t,r,n=1){this._axiosInstance=Mt.default.create({baseURL:`https://cardano-${e}.tangocrypto.com/${t}/v${n}`,headers:{"x-api-key":r}})}async evaluateTx(e){try{const{data:t,status:r}=await this._axiosInstance.post("transactions/evaluate",{tx:e,utxos:[]});if(r===200)return t.redeemers.map(n=>({index:n.index,tag:n.purpose.toUpperCase(),budget:{mem:n.unit_mem,steps:n.unit_steps}}));throw S(t)}catch(t){throw S(t)}}async fetchAccountInfo(e){try{const t=e.startsWith("addr")?ie(e):e,{data:r,status:n}=await this._axiosInstance.get(`wallets/${t}`);if(n===200)return{poolId:r.pool_id,active:r.active,balance:r.controlled_total_stake,rewards:r.rewards_sum,withdrawals:r.withdrawals_sum};throw S(r)}catch(t){throw S(t)}}async fetchAddressUTxOs(e,t){const r=t!==void 0?`/assets/${t}`:"",n=`addresses/${e}${r}/utxos?size=50`,a=async(A="",C=[])=>{var b;const{data:E,status:w}=await this._axiosInstance.get(`${n}&cursor=${A}`);if(w===200)return E.cursor!==null&&((b=E.cursor)==null?void 0:b.length)>0?a(E.cursor,[...C,...E.data.map(p)]):E.data.map(p);throw S(E)},c=(A,C)=>{const E=[{unit:"lovelace",quantity:A.toString()}];return C.forEach(w=>{const b=ct(w.asset_name);E.push({unit:`${w.policy_id}${b}`,quantity:w.quantity.toString()})}),E},l=A=>{if(A){const C=A.type.startsWith("plutus")?{code:A.code,version:A.type.replace("plutus","")}:ye(_e(A.json));return Xt(C).to_hex()}},p=A=>{var C;return{input:{outputIndex:A.index,txHash:A.hash},output:{address:e,amount:c(A.value,A.assets),dataHash:void 0,plutusData:((C=A.inline_datum)==null?void 0:C.value_raw)??void 0,scriptRef:l(A.reference_script)}}};try{return await a()}catch{return[]}}async fetchAssetAddresses(e){const t=n=>({address:n.address,quantity:n.quantity.toString()}),r=async(n="",a=[])=>{var C;const{policyId:c,assetName:l}=kt(e),{data:p,status:A}=await this._axiosInstance.get(`assets/${c}${l}/addresses?size=100&cursor=${n}`);if(A===200)return p.cursor!==null&&((C=p.cursor)==null?void 0:C.length)>0?r(p.cursor,[...a,...p.data.map(t)]):p.data.map(t);throw S(p)};try{return await r()}catch{return[]}}async fetchAssetMetadata(e){var t;try{const{policyId:r,assetName:n}=kt(e),{data:a,status:c}=await this._axiosInstance.get(`assets/${r}${n}`);if(c===200)return{...(t=a.metadata.find(l=>l.label===721))==null?void 0:t.json[r][qe(n)]};throw S(a)}catch(r){throw S(r)}}async fetchBlockInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`blocks/${e}`);if(r===200)return{confirmations:t.confirmations,epoch:t.epoch_no,epochSlot:t.epoch_slot_no.toString(),fees:t.fees.toString(),hash:t.hash,nextBlock:t.next_block.toString()??"",operationalCertificate:t.op_cert,output:t.out_sum.toString()??"0",previousBlock:t.previous_block.toString(),size:t.size,slot:t.slot_no.toString(),slotLeader:t.slot_leader??"",time:Date.parse(t.time),txCount:t.tx_count,VRFKey:t.vrf_key};throw S(t)}catch(t){throw S(t)}}async fetchCollectionAssets(e,t=""){try{const{data:r,status:n}=await this._axiosInstance.get(`policies/${e}/assets?size=100&cursor=${t}`);if(n===200)return{assets:r.data.map(a=>({unit:`${a.policy_id}${a.asset_name}`,quantity:a.quantity})),next:r.cursor};throw S(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=ct(e.replace("$","")),{data:r,status:n}=await this._axiosInstance.get(`assets/${Me[1]}${t}/addresses`);if(n===200)return r.data[0].address;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e){try{const{data:t,status:r}=await this._axiosInstance.get(`epochs/${e}/parameters`);if(r===200)return{coinsPerUTxOSize:t.coins_per_utxo_size.toString(),collateralPercent:t.collateral_percent,decentralisation:t.decentralisation,epoch:t.epoch_no,keyDeposit:t.key_deposit.toString(),maxBlockExMem:t.max_block_ex_mem.toString(),maxBlockExSteps:t.max_block_ex_steps.toString(),maxBlockHeaderSize:t.max_block_header_size,maxBlockSize:t.max_block_size,maxCollateralInputs:t.max_collateral_inputs,maxTxExMem:t.max_tx_ex_mem.toString(),maxTxExSteps:t.max_tx_ex_steps.toString(),maxTxSize:t.max_tx_size,maxValSize:t.max_val_size.toString(),minFeeA:t.min_fee_a,minFeeB:t.min_fee_b,minPoolCost:t.min_pool_cost.toString(),poolDeposit:t.pool_deposit.toString(),priceMem:t.price_mem,priceStep:t.price_step};throw S(t)}catch(t){throw S(t)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`);if(r===200)return{block:t.block.hash,deposit:t.deposit,fees:t.fee,hash:t.hash,index:t.block_index,invalidAfter:t.invalid_hereafter??"",invalidBefore:t.invalid_before??"",slot:t.block.slot_no.toString(),size:t.size};throw S(t)}catch(t){throw S(t)}}async fetchUTxOs(e){try{return console.log(e),[]}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const a=setInterval(()=>{n>=r&&clearInterval(a),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(a),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/json"},{data:r,status:n}=await this._axiosInstance.post("transactions/submit",{tx:e},{headers:t});if(n===200)return r.tx_id;throw S(r)}catch(t){throw S(t)}}}class sn{_axiosInstance;_amountsAsStrings={headers:{"amounts-as-strings":"true"}};submitUrl;constructor({network:e,apiKey:t,turboSubmit:r=!1}){this._axiosInstance=Mt.default.create({baseURL:`https://${e}.gomaestro-api.org/v1`,headers:{"api-key":t}}),this.submitUrl=r?"txmanager/turbosubmit":"txmanager"}async evaluateTx(e){try{const{data:t,status:r}=await this._axiosInstance.post("transactions/evaluate",{cbor:e});if(r===200){const n={spend:"SPEND",mint:"MINT",cert:"CERT",wdrl:"REWARD"};return t.map(c=>{const l=c.ex_units,p=c.redeemer_index,A=n[c.redeemer_tag];return{budget:l,index:p,tag:A}})}throw S(t)}catch(t){throw S(t)}}async fetchAccountInfo(e){const t=e.startsWith("addr")?ie(e):e;try{const{data:r,status:n}=await this._axiosInstance.get(`accounts/${t}`,this._amountsAsStrings);if(n===200){const a=r.data;return{poolId:a.delegated_pool,active:a.registered,balance:a.total_balance,rewards:a.rewards_available,withdrawals:a.total_withdrawn}}throw S(r)}catch(r){throw S(r)}}async fetchAddressUTxOs(e,t){const r=(()=>e.startsWith("addr_vkh")||e.startsWith("addr_shared_vkh")?`addresses/cred/${e}`:`addresses/${e}`)(),n=t?`&asset=${t}`:"",a=async(c=null,l=[])=>{const p=c===null?"":`&cursor=${c}`,{data:A,status:C}=await this._axiosInstance.get(`${r}/utxos?count=100${n}${p}`,this._amountsAsStrings);if(C===200){const w=A.data.map(this.toUTxO),b=[...l,...w],P=A.next_cursor;return P==null?b:a(P,b)}throw S(A)};try{return await a()}catch{return[]}}async fetchAssetAddresses(e){const{policyId:t,assetName:r}=kt(e),n=async(a=null,c=[])=>{const l=a===null?"":`&cursor=${a}`,{data:p,status:A}=await this._axiosInstance.get(`assets/${t}${r}/addresses?count=100${l}`,this._amountsAsStrings);if(A===200){const E=p.data.map(P=>({address:P.address,quantity:P.amount})),w=p.next_cursor,b=[...c,...E];return w==null?b:n(w,b)}throw S(p)};try{return await n()}catch{return[]}}async fetchAssetMetadata(e){try{const{policyId:t,assetName:r}=kt(e),{data:n,status:a}=await this._axiosInstance.get(`assets/${t}${r}`);if(a===200){const c=n.data;return{...c.asset_standards.cip25_metadata,...c.asset_standards.cip68_metadata}}throw S(n)}catch(t){throw S(t)}}async fetchBlockInfo(e){var t;try{const{data:r,status:n}=await this._axiosInstance.get(`blocks/${e}`,this._amountsAsStrings);if(n===200){const a=r.data;return{confirmations:a.confirmations,epoch:a.epoch,epochSlot:a.epoch_slot.toString(),fees:a.total_fees,hash:a.hash,nextBlock:a.next_block??"",operationalCertificate:(t=a.operational_certificate)==null?void 0:t.hot_vkey,output:a.total_output_lovelace??"0",previousBlock:a.previous_block,size:a.size,slot:a.absolute_slot.toString(),slotLeader:a.block_producer??"",time:Date.parse(a.timestamp)/1e3,txCount:a.tx_hashes.length,VRFKey:i.VRFVKey.from_hex(a.vrf_key).to_bech32("vrf_vk")}}throw S(r)}catch(r){throw S(r)}}async fetchCollectionAssets(e,t){try{const{data:r,status:n}=await this._axiosInstance.get(`policy/${e}/assets?count=100${t?`&cursor=${t}`:""}`);if(n===200)return{assets:r.data.map(c=>({unit:e+c.asset_name,quantity:c.total_supply})),next:r.next_cursor};throw S(r)}catch{return{assets:[],next:null}}}async fetchHandleAddress(e){try{const t=e.charAt(0)==="$"?e.substring(1):e,{data:r,status:n}=await this._axiosInstance.get(`ecosystem/adahandle/${t}`);if(n===200)return r.data;throw S(r)}catch(t){throw S(t)}}async fetchProtocolParameters(e=Number.NaN){if(!isNaN(e))throw new Error("Maestro only supports fetching Protocol parameters of the latest completed epoch.");const t=r=>{const n=r.indexOf("/");return parseInt(r.slice(0,n))/parseInt(r.slice(n+1))};try{const{data:r,status:n}=await this._axiosInstance.get("protocol-params");if(n===200){const a=r.data;try{const{data:c,status:l}=await this._axiosInstance.get("epochs/current");if(l===200){const p=c.data;return{coinsPerUTxOSize:a.coins_per_utxo_byte.toString(),collateralPercent:parseInt(a.collateral_percentage),decentralisation:0,epoch:parseInt(p.epoch_no),keyDeposit:a.stake_key_deposit.toString(),maxBlockExMem:a.max_execution_units_per_block.memory.toString(),maxBlockExSteps:a.max_execution_units_per_block.steps.toString(),maxBlockHeaderSize:parseInt(a.max_block_header_size),maxBlockSize:parseInt(a.max_block_body_size),maxCollateralInputs:parseInt(a.max_collateral_inputs),maxTxExMem:a.max_execution_units_per_transaction.memory.toString(),maxTxExSteps:a.max_execution_units_per_transaction.steps.toString(),maxTxSize:parseInt(a.max_tx_size),maxValSize:a.max_value_size.toString(),minFeeA:a.min_fee_coefficient,minFeeB:a.min_fee_constant,minPoolCost:a.min_pool_cost.toString(),poolDeposit:a.pool_deposit.toString(),priceMem:t(a.prices.memory),priceStep:t(a.prices.steps)}}throw S(c)}catch(c){throw S(c)}}throw S(r)}catch(r){throw S(r)}}async fetchTxInfo(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`);if(r===200){const n=t.data;return{block:n.block_hash,deposit:n.deposit.toString(),fees:n.fee.toString(),hash:n.tx_hash,index:n.block_tx_index,invalidAfter:n.invalid_hereafter??"",invalidBefore:n.invalid_before??"",slot:n.block_absolute_slot.toString(),size:n.size-1}}throw S(t)}catch(t){throw S(t)}}async fetchUTxOs(e){try{const{data:t,status:r}=await this._axiosInstance.get(`transactions/${e}`,this._amountsAsStrings);if(r===200)return t.data.outputs.map(this.toUTxO);throw S(t)}catch(t){throw S(t)}}onTxConfirmed(e,t,r=100){let n=0;const a=setInterval(()=>{n>=r&&clearInterval(a),this.fetchTxInfo(e).then(c=>{this.fetchBlockInfo(c.block).then(l=>{(l==null?void 0:l.confirmations)>0&&(clearInterval(a),t())}).catch(()=>{n+=1})}).catch(()=>{n+=1})},5e3)}async submitTx(e){try{const t={"Content-Type":"application/cbor"},{data:r,status:n}=await this._axiosInstance.post(this.submitUrl,G(e),{headers:t});if(n===202)return r;throw S(r)}catch(t){throw S(t)}}toUTxO=e=>{var t,r,n;return{input:{outputIndex:e.index,txHash:e.tx_hash},output:{address:e.address,amount:e.assets.map(a=>({unit:a.unit,quantity:a.amount})),dataHash:(t=e.datum)==null?void 0:t.hash,plutusData:(r=e.datum)==null?void 0:r.bytes,scriptRef:this.resolveScript(e),scriptHash:(n=e.reference_script)==null?void 0:n.hash}}};resolveScript=e=>{if(e.reference_script){const t=e.reference_script.type==="native"?e.reference_script.json:{code:e.reference_script.bytes,version:e.reference_script.type.replace("plutusv","V")};return Xt(t).to_hex()}else return}}class nn{static withOneSignature(e){const t=Ct(qt(e));return ue(t).to_hex()}static withAtLeastNSignatures(e,t){const r=i.NativeScripts.new();e.forEach(a=>{const c=Ct(qt(a));r.add(ue(c))});const n=i.ScriptNOfK.new(t,r);return i.NativeScript.new_script_any(n).to_hex()}static withAnySignature(e){const t=i.NativeScripts.new();e.forEach(n=>{const a=Ct(qt(n));t.add(ue(a))});const r=i.ScriptAny.new(t);return i.NativeScript.new_script_any(r).to_hex()}static withAllSignatures(e){const t=i.NativeScripts.new();e.forEach(n=>{const a=Ct(qt(n));t.add(ue(a))});const r=i.ScriptAll.new(t);return i.NativeScript.new_script_any(r).to_hex()}static fromNativeScript(e){return xe(e).to_hex()}}function Kt(s,e,t,r){var n=arguments.length,a=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(s,e,t,r);else for(var l=s.length-1;l>=0;l--)(c=s[l])&&(a=(n<3?c(a):n>3?c(e,t,a):c(e,t))||a);return n>3&&a&&Object.defineProperty(e,t,a),a}const an=s=>class extends s{__visits=[]},Vt=()=>function(s,e,t){const r=t.value;t.value=function(...n){const a=r.call(this,...n);return this.__visits&&this.__visits.push(e),a}};exports.Transaction=class{_changeAddress;_txOutputs=new Map;_recipients=new Map;_totalBurns=new Map;_totalMints=new Map;_era;_initiator;_mintBuilder;_protocolParameters;_txBuilder;_txCertificates;_txInputsBuilder;_txWithdrawals;constructor(e={}){this._era=e.era,this._initiator=e.initiator,this._mintBuilder=i.MintBuilder.new(),this._protocolParameters=e.parameters??gt,this._txBuilder=ge(e.parameters),this._txCertificates=i.Certificates.new(),this._txInputsBuilder=i.TxInputsBuilder.new(),this._txWithdrawals=i.Withdrawals.new()}static attachMetadata(e,t,r="BABBAGE"){var c;const n=It(e),a=n.auxiliary_data()??i.AuxiliaryData.new();if(a.set_metadata(i.GeneralTransactionMetadata.from_hex(t)),a.set_prefer_alonzo_format(r==="ALONZO"),i.hash_auxiliary_data(a).to_hex()!==((c=n.body().auxiliary_data_hash())==null?void 0:c.to_hex()))throw new Error("[Transaction] attachMetadata: The metadata hash does not match the auxiliary data hash.");return i.Transaction.new(n.body(),n.witness_set(),a).to_hex()}static deattachMetadata(e){const t=It(e);return i.Transaction.new(t.body(),t.witness_set(),void 0).to_hex()}static maskMetadata(e,t="BABBAGE"){var a;const r=It(e),n=(a=r.auxiliary_data())==null?void 0:a.metadata();if(n!==void 0){const c=i.GeneralTransactionMetadata.new();for(let p=0;p<n.len();p+=1){const A=n.keys().get(p),C=n.get(A);c.insert(A,i.TransactionMetadatum.from_hex("0".repeat(((C==null?void 0:C.to_hex())??"").length)))}const l=r.auxiliary_data();return l!==void 0&&(l.set_metadata(c),l.set_prefer_alonzo_format(t==="ALONZO")),i.Transaction.new(r.body(),r.witness_set(),l).to_hex()}return e}static readMetadata(e){var r,n;return((n=(r=It(e).auxiliary_data())==null?void 0:r.metadata())==null?void 0:n.to_hex())??""}static writeMetadata(e,t,r="BABBAGE"){const n=It(e),a=n.auxiliary_data()??i.AuxiliaryData.new();return a.set_metadata(i.GeneralTransactionMetadata.from_hex(t)),a.set_prefer_alonzo_format(r==="ALONZO"),i.Transaction.new(n.body(),n.witness_set(),a).to_hex()}get size(){return this._txBuilder.full_size()}async build(){try{return(this._mintBuilder.has_plutus_scripts()||this.notVisited("redeemValue")===!1)&&(await this.addRequiredSignersIfNeeded(),await this.addCollateralIfNeeded()),await this.forgeAssetsIfNeeded(),await this.addTxInputsAsNeeded(),await this.addChangeAddress(),this._txBuilder.build_tx().to_hex()}catch(e){throw new Error(`[Transaction] An error occurred during build: ${e}.`)}}burnAsset(e,t,r){const n=this._totalBurns.has(t.unit)?i.BigNum.from_str(this._totalBurns.get(t.unit)??"0").checked_add(i.BigNum.from_str(t.quantity)).to_str():t.quantity;return this._mintBuilder.add_asset(fr(e,r),i.AssetName.new(G(t.unit.slice(Bt))),i.Int.new_negative(i.BigNum.from_str(t.quantity))),this._totalBurns.set(t.unit,n),this}delegateStake(e,t){const r=i.Certificate.new_stake_delegation(i.StakeDelegation.new(i.StakeCredential.from_keyhash(Ct(Yt(e))),i.Ed25519KeyHash.from_bech32(t)));return this._txCertificates.add(r),this}deregisterStake(e){const t=i.Certificate.new_stake_deregistration(i.StakeDeregistration.new(i.StakeCredential.from_keyhash(Ct(Yt(e)))));return this._txCertificates.add(t),this}mintAsset(e,t,r){var A,C;const n=(E,w)=>{const b=typeof E=="string"?_e(E).hash().to_hex():a(E).hash().to_hex(),P=ct(w.assetName);return{unit:`${b}${P}`,quantity:w.assetQuantity}},a=E=>{if("code"in E)return Jt(E.code,E.version);const w=wt(E);if(w.output().has_script_ref()){const b=w.output().script_ref();if(b.is_plutus_script()){const P=Pr(b);return Jt(P.code,P.version)}}throw new Error(`[Transaction] No plutus script reference found in UTxO: ${w.input().transaction_id().to_hex()}`)},c=n(e,t),p=i.BigNum.from_str(((A=this._totalMints.get(c.unit))==null?void 0:A.assetQuantity)??"0").checked_add(i.BigNum.from_str(c.quantity));return this._mintBuilder.add_asset(fr(e,r),i.AssetName.new(G(ct(t.assetName))),i.Int.new(i.BigNum.from_str(c.quantity))),this._recipients.has(t.recipient)?(C=this._recipients.get(t.recipient))==null||C.push(c):this._recipients.set(t.recipient,[c]),this._totalMints.set(c.unit,{...t,assetQuantity:p.to_str()}),this}redeemValue(e){const t={tag:"SPEND",budget:Gt,index:this._txInputsBuilder.inputs().len(),data:{alternative:0,fields:[]},...e.redeemer},r=wt(e.value),n=e.datum?i.PlutusWitness.new_with_ref(Ue(e.script),Ks(e.datum),Te(t)):i.PlutusWitness.new_with_ref_without_datum(Ue(e.script),Te(t));return this._txInputsBuilder.add_plutus_script_input(n,r.input(),r.output().amount()),this}registerStake(e){const t=i.Certificate.new_stake_registration(i.StakeRegistration.new(i.StakeCredential.from_keyhash(Ct(Yt(e)))));return this._txCertificates.add(t),this}registerPool(e){const t=i.Certificate.new_pool_registration(i.PoolRegistration.new(Ms(e)));return this._txCertificates.add(t),this}retirePool(e,t){const r=i.Certificate.new_pool_retirement(i.PoolRetirement.new(i.Ed25519KeyHash.from_bech32(e),t));return this._txCertificates.add(r),this}sendAssets(e,t){const r=Qt(t),n=r.multiasset();if(r.is_zero()||n===void 0)return this;const a=le(e).next(),c=r.coin().is_zero()?a.with_asset_and_min_required_coin_by_utxo_cost(n,Ne(this._protocolParameters.coinsPerUTxOSize)).build():a.with_coin_and_asset(r.coin(),n).build();return t.forEach(l=>{this.setTxOutput(l)}),this._txBuilder.add_output(c),this}sendLovelace(e,t){const n=le(e).next().with_coin(i.BigNum.from_str(t)).build();return this.setTxOutput({unit:"lovelace",quantity:t}),this._txBuilder.add_output(n),this}sendToken(e,t,r){return this.sendAssets(e,[{quantity:r,unit:jr[t]}]),this}sendValue(e,t){const r=Qt(t.output.amount),a=le(e).next().with_value(r).build();return t.output.amount.forEach(c=>{this.setTxOutput(c)}),this._txBuilder.add_output(a),this}setChangeAddress(e){return this._changeAddress=_t(e),this}setCollateral(e){const t=gr(e);return this._txBuilder.set_collateral(t),this}setMetadata(e,t){return this._txBuilder.add_json_metadatum_with_schema(i.BigNum.from_str(e.toString()),JSON.stringify(t),i.MetadataJsonSchema.NoConversions),this}setRequiredSigners(e){return Array.from(new Set(e.map(r=>r.startsWith("addr")?qt(r):Yt(r)).map(r=>Ct(r)))).forEach(r=>{this._txBuilder.add_required_signer(r)}),this}setTimeToStart(e){return this._txBuilder.set_validity_start_interval_bignum(i.BigNum.from_str(e)),this}setTimeToExpire(e){return this._txBuilder.set_ttl_bignum(i.BigNum.from_str(e)),this}setTxInputs(e){return e.map(t=>wt(t)).forEach(t=>{this._txInputsBuilder.add_input(t.output().address(),t.input(),t.output().amount())}),this}setTxRefInputs(e){return e.map(t=>wt(t)).forEach(t=>{this._txBuilder.add_reference_input(t.input())}),this}withdrawRewards(e,t){const r=Tr(e);return r!==void 0&&this._txWithdrawals.insert(r,i.BigNum.from_str(t)),this}async addBurnInputsIfNeeded(){if(this._initiator&&this._totalBurns.size>0&&this.notVisited("setTxInputs")){const e=await this._initiator.getUsedUTxOs();Ir(this._totalBurns,e.map(r=>pe(r))).map(r=>wt(r)).forEach(r=>{this._txInputsBuilder.add_input(r.output().address(),r.input(),r.output().amount())})}}async addChangeAddress(){if(this._initiator&&this._changeAddress===void 0){const e=await this._initiator.getUsedAddress();this._txBuilder.add_change_if_needed(e)}else this._changeAddress!==void 0&&this._txBuilder.add_change_if_needed(this._changeAddress)}async addCollateralIfNeeded(){if(this._initiator&&this.notVisited("setCollateral")){const e=await this._initiator.getUsedCollateral();this._txBuilder.set_collateral(gr(e))}}async addRequiredSignersIfNeeded(){if(this._initiator&&this.notVisited("setRequiredSigners")){const e=await this._initiator.getUsedAddress(),t=qt(e.to_bech32());this._txBuilder.add_required_signer(Ct(t))}}async addTxInputsAsNeeded(){if(this.notVisited("setTxInputs")){const e=await this.filterAvailableUTxOs();pr(this._txOutputs,e.map(r=>pe(r))).map(r=>wt(r)).forEach(r=>{this._txInputsBuilder.add_input(r.output().address(),r.input(),r.output().amount())})}if(this._txBuilder.set_inputs(this._txInputsBuilder),(this._mintBuilder.has_native_scripts()||this._mintBuilder.has_plutus_scripts())&&this._txBuilder.set_mint_builder(this._mintBuilder),this._txCertificates.len()>0&&this._txBuilder.set_certs(this._txCertificates),this._txWithdrawals.len()>0&&this._txBuilder.set_withdrawals(this._txWithdrawals),this._txBuilder.get_mint_builder()||this.notVisited("redeemValue")===!1){const e=this._era!==void 0?Ye[this._era]:Ye.BABBAGE;this._txBuilder.calc_script_data_hash(e)}}async forgeAssetsIfNeeded(){const e=(t,r)=>{const n=t.data.assetName,a=t.data.metadata,c=t.unit.slice(0,Bt);if(t.data.label==="777")return a;if(r&&r[c]){const{[c]:l,...p}=r,A={[n]:a,...l};return{[c]:{...A},...p}}return r!==void 0?{[c]:{[n]:a},...r}:{[c]:{[n]:a}}};await this.addBurnInputsIfNeeded(),Array.from(this._totalMints,t=>({unit:t[0],data:t[1]})).reduce((t,r)=>t.set(r.data.label,e(r,t.get(r.data.label))),new Map).forEach((t,r)=>{this._txBuilder.add_json_metadatum(i.BigNum.from_str(r),JSON.stringify(t))}),this.addMintOutputs()}async filterAvailableUTxOs(e=[]){return this._initiator===void 0?[]:(await this._initiator.getUsedUTxOs()).filter(r=>e.find(n=>n.input.txHash===r.input().transaction_id().to_hex())===void 0)}addMintOutputs(){this._recipients.forEach((e,t)=>{const n=Qt(e).multiasset();if(n!==void 0){const c=le(t).next().with_asset_and_min_required_coin_by_utxo_cost(n,Ne(this._protocolParameters.coinsPerUTxOSize)).build();this._txBuilder.add_output(c)}})}notVisited(e){return this.__visits.includes(e)===!1}setTxOutput(e){const r=i.BigNum.from_str(this._txOutputs.get(e.unit)??"0").checked_add(i.BigNum.from_str(e.quantity)).to_str();this._txOutputs.set(e.unit,r)}};Kt([Vt()],exports.Transaction.prototype,"mintAsset",null);Kt([Vt()],exports.Transaction.prototype,"redeemValue",null);Kt([Vt()],exports.Transaction.prototype,"sendAssets",null);Kt([Vt()],exports.Transaction.prototype,"sendValue",null);Kt([Vt()],exports.Transaction.prototype,"setCollateral",null);Kt([Vt()],exports.Transaction.prototype,"setRequiredSigners",null);Kt([Vt()],exports.Transaction.prototype,"setTxInputs",null);exports.Transaction=Kt([an],exports.Transaction);const on=(s,e,t)=>{const r=new Map(e);r.set("lovelace",String(Number(r.get("lovelace"))+Number(t)));const n=new Map;for(let w=0;w<s.length;w++)n.set(w,s[w]);const a=new Set,c=new Set,l=new Set,p=new Set,A=new Set;for(let w=0;w<s.length;w++)switch(s[w].output.amount.length){case 1:{c.add(w);break}case 2:{l.add(w);break}case 3:{p.add(w);break}default:{A.add(w);break}}const C=(w,b,P)=>{const k=n.get(w);if(!k)return;const N=cn(k,b);if(Number(N)>0){a.add(w),P.delete(w);for(const T of k.output.amount)r.set(T.unit,String(Number(r.get(T.unit))-Number(T.quantity)))}};for(const w of r.keys())if(w!="lovelace"){for(const b of l){const P=r.get(w);if(!P||Number(P)<=0)break;C(b,w,l)}for(const b of p){const P=r.get(w);if(!P||Number(P)<=0)break;C(b,w,p)}for(const b of A){const P=r.get(w);if(!P||Number(P)<=0)break;C(b,w,A)}}for(const w of c){const b=r.get("lovelace");if(!b||Number(b)<=0)break;C(w,"lovelace",c)}for(const w of l){const b=r.get("lovelace");if(!b||Number(b)<=0)break;C(w,"lovelace",l)}for(const w of p){const b=r.get("lovelace");if(!b||Number(b)<=0)break;C(w,"lovelace",p)}for(const w of A){const b=r.get("lovelace");if(!b||Number(b)<=0)break;C(w,"lovelace",A)}for(const w of r.keys())if(Number(r.get(w))>0)return[];const E=[];for(const w of a){const b=n.get(w);b&&E.push(b)}return E},cn=(s,e)=>{for(const t of s.output.amount)if(t.unit==e)return t.quantity;return"0"};var zt={exports:{}},Hr={exports:{}},Le={exports:{}};(function(s){(function(e){var t,r=/^-?(?:\d+(?:\.\d*)?|\.\d+)(?:e[+-]?\d+)?$/i,n=Math.ceil,a=Math.floor,c="[BigNumber Error] ",l=c+"Number primitive has more than 15 significant digits: ",p=1e14,A=14,C=9007199254740991,E=[1,10,100,1e3,1e4,1e5,1e6,1e7,1e8,1e9,1e10,1e11,1e12,1e13],w=1e7,b=1e9;function P(O){var M,W,Z,D=v.prototype={constructor:v,toString:null,valueOf:null},F=new v(1),q=20,J=4,nt=-7,lt=21,Ht=-1e7,At=1e7,Ft=!1,Zt=1,Tt=0,we={prefix:"",groupSize:3,secondaryGroupSize:0,groupSeparator:",",decimalSeparator:".",fractionGroupSize:0,fractionGroupSeparator:"\xA0",suffix:""},Rt="0123456789abcdefghijklmnopqrstuvwxyz",Ce=!0;function v(o,u){var d,_,f,m,x,h,g,y,I=this;if(!(I instanceof v))return new v(o,u);if(u==null){if(o&&o._isBigNumber===!0){I.s=o.s,!o.c||o.e>At?I.c=I.e=null:o.e<Ht?I.c=[I.e=0]:(I.e=o.e,I.c=o.c.slice());return}if((h=typeof o=="number")&&o*0==0){if(I.s=1/o<0?(o=-o,-1):1,o===~~o){for(m=0,x=o;x>=10;x/=10,m++);m>At?I.c=I.e=null:(I.e=m,I.c=[o]);return}y=String(o)}else{if(!r.test(y=String(o)))return Z(I,y,h);I.s=y.charCodeAt(0)==45?(y=y.slice(1),-1):1}(m=y.indexOf("."))>-1&&(y=y.replace(".","")),(x=y.search(/e/i))>0?(m<0&&(m=x),m+=+y.slice(x+1),y=y.substring(0,x)):m<0&&(m=y.length)}else{if(Q(u,2,Rt.length,"Base"),u==10&&Ce)return I=new v(o),ht(I,q+I.e+1,J);if(y=String(o),h=typeof o=="number"){if(o*0!=0)return Z(I,y,h,u);if(I.s=1/o<0?(y=y.slice(1),-1):1,v.DEBUG&&y.replace(/^0\.0*|\./,"").length>15)throw Error(l+o)}else I.s=y.charCodeAt(0)===45?(y=y.slice(1),-1):1;for(d=Rt.slice(0,u),m=x=0,g=y.length;x<g;x++)if(d.indexOf(_=y.charAt(x))<0){if(_=="."){if(x>m){m=g;continue}}else if(!f&&(y==y.toUpperCase()&&(y=y.toLowerCase())||y==y.toLowerCase()&&(y=y.toUpperCase()))){f=!0,x=-1,m=0;continue}return Z(I,String(o),h,u)}h=!1,y=W(y,u,10,I.s),(m=y.indexOf("."))>-1?y=y.replace(".",""):m=y.length}for(x=0;y.charCodeAt(x)===48;x++);for(g=y.length;y.charCodeAt(--g)===48;);if(y=y.slice(x,++g)){if(g-=x,h&&v.DEBUG&&g>15&&(o>C||o!==a(o)))throw Error(l+I.s*o);if((m=m-x-1)>At)I.c=I.e=null;else if(m<Ht)I.c=[I.e=0];else{if(I.e=m,I.c=[],x=(m+1)%A,m<0&&(x+=A),x<g){for(x&&I.c.push(+y.slice(0,x)),g-=A;x<g;)I.c.push(+y.slice(x,x+=A));x=A-(y=y.slice(x)).length}else x-=g;for(;x--;y+="0");I.c.push(+y)}}else I.c=[I.e=0]}v.clone=P,v.ROUND_UP=0,v.ROUND_DOWN=1,v.ROUND_CEIL=2,v.ROUND_FLOOR=3,v.ROUND_HALF_UP=4,v.ROUND_HALF_DOWN=5,v.ROUND_HALF_EVEN=6,v.ROUND_HALF_CEIL=7,v.ROUND_HALF_FLOOR=8,v.EUCLID=9,v.config=v.set=function(o){var u,d;if(o!=null)if(typeof o=="object"){if(o.hasOwnProperty(u="DECIMAL_PLACES")&&(d=o[u],Q(d,0,b,u),q=d),o.hasOwnProperty(u="ROUNDING_MODE")&&(d=o[u],Q(d,0,8,u),J=d),o.hasOwnProperty(u="EXPONENTIAL_AT")&&(d=o[u],d&&d.pop?(Q(d[0],-b,0,u),Q(d[1],0,b,u),nt=d[0],lt=d[1]):(Q(d,-b,b,u),nt=-(lt=d<0?-d:d))),o.hasOwnProperty(u="RANGE"))if(d=o[u],d&&d.pop)Q(d[0],-b,-1,u),Q(d[1],1,b,u),Ht=d[0],At=d[1];else if(Q(d,-b,b,u),d)Ht=-(At=d<0?-d:d);else throw Error(c+u+" cannot be zero: "+d);if(o.hasOwnProperty(u="CRYPTO"))if(d=o[u],d===!!d)if(d)if(typeof crypto<"u"&&crypto&&(crypto.getRandomValues||crypto.randomBytes))Ft=d;else throw Ft=!d,Error(c+"crypto unavailable");else Ft=d;else throw Error(c+u+" not true or false: "+d);if(o.hasOwnProperty(u="MODULO_MODE")&&(d=o[u],Q(d,0,9,u),Zt=d),o.hasOwnProperty(u="POW_PRECISION")&&(d=o[u],Q(d,0,b,u),Tt=d),o.hasOwnProperty(u="FORMAT"))if(d=o[u],typeof d=="object")we=d;else throw Error(c+u+" not an object: "+d);if(o.hasOwnProperty(u="ALPHABET"))if(d=o[u],typeof d=="string"&&!/^.?$|[+\-.\s]|(.).*\1/.test(d))Ce=d.slice(0,10)=="0123456789",Rt=d;else throw Error(c+u+" invalid: "+d)}else throw Error(c+"Object expected: "+o);return{DECIMAL_PLACES:q,ROUNDING_MODE:J,EXPONENTIAL_AT:[nt,lt],RANGE:[Ht,At],CRYPTO:Ft,MODULO_MODE:Zt,POW_PRECISION:Tt,FORMAT:we,ALPHABET:Rt}},v.isBigNumber=function(o){if(!o||o._isBigNumber!==!0)return!1;if(!v.DEBUG)return!0;var u,d,_=o.c,f=o.e,m=o.s;t:if({}.toString.call(_)=="[object Array]"){if((m===1||m===-1)&&f>=-b&&f<=b&&f===a(f)){if(_[0]===0){if(f===0&&_.length===1)return!0;break t}if(u=(f+1)%A,u<1&&(u+=A),String(_[0]).length==u){for(u=0;u<_.length;u++)if(d=_[u],d<0||d>=p||d!==a(d))break t;if(d!==0)return!0}}}else if(_===null&&f===null&&(m===null||m===1||m===-1))return!0;throw Error(c+"Invalid BigNumber: "+o)},v.maximum=v.max=function(){return Ge(arguments,-1)},v.minimum=v.min=function(){return Ge(arguments,1)},v.random=function(){var o=9007199254740992,u=Math.random()*o&2097151?function(){return a(Math.random()*o)}:function(){return(Math.random()*1073741824|0)*8388608+(Math.random()*8388608|0)};return function(d){var _,f,m,x,h,g=0,y=[],I=new v(F);if(d==null?d=q:Q(d,0,b),x=n(d/A),Ft)if(crypto.getRandomValues){for(_=crypto.getRandomValues(new Uint32Array(x*=2));g<x;)h=_[g]*131072+(_[g+1]>>>11),h>=9e15?(f=crypto.getRandomValues(new Uint32Array(2)),_[g]=f[0],_[g+1]=f[1]):(y.push(h%1e14),g+=2);g=x/2}else if(crypto.randomBytes){for(_=crypto.randomBytes(x*=7);g<x;)h=(_[g]&31)*281474976710656+_[g+1]*1099511627776+_[g+2]*4294967296+_[g+3]*16777216+(_[g+4]<<16)+(_[g+5]<<8)+_[g+6],h>=9e15?crypto.randomBytes(7).copy(_,g):(y.push(h%1e14),g+=7);g=x/7}else throw Ft=!1,Error(c+"crypto unavailable");if(!Ft)for(;g<x;)h=u(),h<9e15&&(y[g++]=h%1e14);for(x=y[--g],d%=A,x&&d&&(h=E[A-d],y[g]=a(x/h)*h);y[g]===0;y.pop(),g--);if(g<0)y=[m=0];else{for(m=-1;y[0]===0;y.splice(0,1),m-=A);for(g=1,h=y[0];h>=10;h/=10,g++);g<A&&(m-=A-g)}return I.e=m,I.c=y,I}}(),v.sum=function(){for(var o=1,u=arguments,d=new v(u[0]);o<u.length;)d=d.plus(u[o++]);return d},W=function(){var o="0123456789";function u(d,_,f,m){for(var x,h=[0],g,y=0,I=d.length;y<I;){for(g=h.length;g--;h[g]*=_);for(h[0]+=m.indexOf(d.charAt(y++)),x=0;x<h.length;x++)h[x]>f-1&&(h[x+1]==null&&(h[x+1]=0),h[x+1]+=h[x]/f|0,h[x]%=f)}return h.reverse()}return function(d,_,f,m,x){var h,g,y,I,B,U,K,L,tt=d.indexOf("."),rt=q,V=J;for(tt>=0&&(I=Tt,Tt=0,d=d.replace(".",""),L=new v(_),U=L.pow(d.length-tt),Tt=I,L.c=u($(N(U.c),U.e,"0"),10,f,o),L.e=L.c.length),K=u(d,_,f,x?(h=Rt,o):(h=o,Rt)),y=I=K.length;K[--I]==0;K.pop());if(!K[0])return h.charAt(0);if(tt<0?--y:(U.c=K,U.e=y,U.s=m,U=M(U,L,rt,V,f),K=U.c,B=U.r,y=U.e),g=y+rt+1,tt=K[g],I=f/2,B=B||g<0||K[g+1]!=null,B=V<4?(tt!=null||B)&&(V==0||V==(U.s<0?3:2)):tt>I||tt==I&&(V==4||B||V==6&&K[g-1]&1||V==(U.s<0?8:7)),g<1||!K[0])d=B?$(h.charAt(1),-rt,h.charAt(0)):h.charAt(0);else{if(K.length=g,B)for(--f;++K[--g]>f;)K[g]=0,g||(++y,K=[1].concat(K));for(I=K.length;!K[--I];);for(tt=0,d="";tt<=I;d+=h.charAt(K[tt++]));d=$(d,y,h.charAt(0))}return d}}(),M=function(){function o(_,f,m){var x,h,g,y,I=0,B=_.length,U=f%w,K=f/w|0;for(_=_.slice();B--;)g=_[B]%w,y=_[B]/w|0,x=K*g+y*U,h=U*g+x%w*w+I,I=(h/m|0)+(x/w|0)+K*y,_[B]=h%m;return I&&(_=[I].concat(_)),_}function u(_,f,m,x){var h,g;if(m!=x)g=m>x?1:-1;else for(h=g=0;h<m;h++)if(_[h]!=f[h]){g=_[h]>f[h]?1:-1;break}return g}function d(_,f,m,x){for(var h=0;m--;)_[m]-=h,h=_[m]<f[m]?1:0,_[m]=h*x+_[m]-f[m];for(;!_[0]&&_.length>1;_.splice(0,1));}return function(_,f,m,x,h){var g,y,I,B,U,K,L,tt,rt,V,z,it,ae,Se,ve,yt,te,ft=_.s==f.s?1:-1,ot=_.c,et=f.c;if(!ot||!ot[0]||!et||!et[0])return new v(!_.s||!f.s||(ot?et&&ot[0]==et[0]:!et)?NaN:ot&&ot[0]==0||!et?ft*0:ft/0);for(tt=new v(ft),rt=tt.c=[],y=_.e-f.e,ft=m+y+1,h||(h=p,y=k(_.e/A)-k(f.e/A),ft=ft/A|0),I=0;et[I]==(ot[I]||0);I++);if(et[I]>(ot[I]||0)&&y--,ft<0)rt.push(1),B=!0;else{for(Se=ot.length,yt=et.length,I=0,ft+=2,U=a(h/(et[0]+1)),U>1&&(et=o(et,U,h),ot=o(ot,U,h),yt=et.length,Se=ot.length),ae=yt,V=ot.slice(0,yt),z=V.length;z<yt;V[z++]=0);te=et.slice(),te=[0].concat(te),ve=et[0],et[1]>=h/2&&ve++;do{if(U=0,g=u(et,V,yt,z),g<0){if(it=V[0],yt!=z&&(it=it*h+(V[1]||0)),U=a(it/ve),U>1)for(U>=h&&(U=h-1),K=o(et,U,h),L=K.length,z=V.length;u(K,V,L,z)==1;)U--,d(K,yt<L?te:et,L,h),L=K.length,g=1;else U==0&&(g=U=1),K=et.slice(),L=K.length;if(L<z&&(K=[0].concat(K)),d(V,K,z,h),z=V.length,g==-1)for(;u(et,V,yt,z)<1;)U++,d(V,yt<z?te:et,z,h),z=V.length}else g===0&&(U++,V=[0]);rt[I++]=U,V[0]?V[z++]=ot[ae]||0:(V=[ot[ae]],z=1)}while((ae++<Se||V[0]!=null)&&ft--);B=V[0]!=null,rt[0]||rt.splice(0,1)}if(h==p){for(I=1,ft=rt[0];ft>=10;ft/=10,I++);ht(tt,m+(tt.e=I+y*A-1)+1,x,B)}else tt.e=y,tt.r=+B;return tt}}();function Be(o,u,d,_){var f,m,x,h,g;if(d==null?d=J:Q(d,0,8),!o.c)return o.toString();if(f=o.c[0],x=o.e,u==null)g=N(o.c),g=_==1||_==2&&(x<=nt||x>=lt)?X(g,x):$(g,x,"0");else if(o=ht(new v(o),u,d),m=o.e,g=N(o.c),h=g.length,_==1||_==2&&(u<=m||m<=nt)){for(;h<u;g+="0",h++);g=X(g,m)}else if(u-=x,g=$(g,m,"0"),m+1>h){if(--u>0)for(g+=".";u--;g+="0");}else if(u+=m-h,u>0)for(m+1==h&&(g+=".");u--;g+="0");return o.s<0&&f?"-"+g:g}function Ge(o,u){for(var d,_,f=1,m=new v(o[0]);f<o.length;f++)_=new v(o[f]),(!_.s||(d=T(m,_))===u||d===0&&m.s===u)&&(m=_);return m}function Ee(o,u,d){for(var _=1,f=u.length;!u[--f];u.pop());for(f=u[0];f>=10;f/=10,_++);return(d=_+d*A-1)>At?o.c=o.e=null:d<Ht?o.c=[o.e=0]:(o.e=d,o.c=u),o}Z=function(){var o=/^(-?)0([xbo])(?=\w[\w.]*$)/i,u=/^([^.]+)\.$/,d=/^\.([^.]+)$/,_=/^-?(Infinity|NaN)$/,f=/^\s*\+(?=[\w.])|^\s+|\s+$/g;return function(m,x,h,g){var y,I=h?x:x.replace(f,"");if(_.test(I))m.s=isNaN(I)?null:I<0?-1:1;else{if(!h&&(I=I.replace(o,function(B,U,K){return y=(K=K.toLowerCase())=="x"?16:K=="b"?2:8,!g||g==y?U:B}),g&&(y=g,I=I.replace(u,"$1").replace(d,"0.$1")),x!=I))return new v(I,y);if(v.DEBUG)throw Error(c+"Not a"+(g?" base "+g:"")+" number: "+x);m.s=null}m.c=m.e=null}}();function ht(o,u,d,_){var f,m,x,h,g,y,I,B=o.c,U=E;if(B){t:{for(f=1,h=B[0];h>=10;h/=10,f++);if(m=u-f,m<0)m+=A,x=u,g=B[y=0],I=a(g/U[f-x-1]%10);else if(y=n((m+1)/A),y>=B.length)if(_){for(;B.length<=y;B.push(0));g=I=0,f=1,m%=A,x=m-A+1}else break t;else{for(g=h=B[y],f=1;h>=10;h/=10,f++);m%=A,x=m-A+f,I=x<0?0:a(g/U[f-x-1]%10)}if(_=_||u<0||B[y+1]!=null||(x<0?g:g%U[f-x-1]),_=d<4?(I||_)&&(d==0||d==(o.s<0?3:2)):I>5||I==5&&(d==4||_||d==6&&(m>0?x>0?g/U[f-x]:0:B[y-1])%10&1||d==(o.s<0?8:7)),u<1||!B[0])return B.length=0,_?(u-=o.e+1,B[0]=U[(A-u%A)%A],o.e=-u||0):B[0]=o.e=0,o;if(m==0?(B.length=y,h=1,y--):(B.length=y+1,h=U[A-m],B[y]=x>0?a(g/U[f-x]%U[x])*h:0),_)for(;;)if(y==0){for(m=1,x=B[0];x>=10;x/=10,m++);for(x=B[0]+=h,h=1;x>=10;x/=10,h++);m!=h&&(o.e++,B[0]==p&&(B[0]=1));break}else{if(B[y]+=h,B[y]!=p)break;B[y--]=0,h=1}for(m=B.length;B[--m]===0;B.pop());}o.e>At?o.c=o.e=null:o.e<Ht&&(o.c=[o.e=0])}return o}function St(o){var u,d=o.e;return d===null?o.toString():(u=N(o.c),u=d<=nt||d>=lt?X(u,d):$(u,d,"0"),o.s<0?"-"+u:u)}return D.absoluteValue=D.abs=function(){var o=new v(this);return o.s<0&&(o.s=1),o},D.comparedTo=function(o,u){return T(this,new v(o,u))},D.decimalPlaces=D.dp=function(o,u){var d,_,f,m=this;if(o!=null)return Q(o,0,b),u==null?u=J:Q(u,0,8),ht(new v(m),o+m.e+1,u);if(!(d=m.c))return null;if(_=((f=d.length-1)-k(this.e/A))*A,f=d[f])for(;f%10==0;f/=10,_--);return _<0&&(_=0),_},D.dividedBy=D.div=function(o,u){return M(this,new v(o,u),q,J)},D.dividedToIntegerBy=D.idiv=function(o,u){return M(this,new v(o,u),0,1)},D.exponentiatedBy=D.pow=function(o,u){var d,_,f,m,x,h,g,y,I,B=this;if(o=new v(o),o.c&&!o.isInteger())throw Error(c+"Exponent not an integer: "+St(o));if(u!=null&&(u=new v(u)),h=o.e>14,!B.c||!B.c[0]||B.c[0]==1&&!B.e&&B.c.length==1||!o.c||!o.c[0])return I=new v(Math.pow(+St(B),h?o.s*(2-R(o)):+St(o))),u?I.mod(u):I;if(g=o.s<0,u){if(u.c?!u.c[0]:!u.s)return new v(NaN);_=!g&&B.isInteger()&&u.isInteger(),_&&(B=B.mod(u))}else{if(o.e>9&&(B.e>0||B.e<-1||(B.e==0?B.c[0]>1||h&&B.c[1]>=24e7:B.c[0]<8e13||h&&B.c[0]<=9999975e7)))return m=B.s<0&&R(o)?-0:0,B.e>-1&&(m=1/m),new v(g?1/m:m);Tt&&(m=n(Tt/A+2))}for(h?(d=new v(.5),g&&(o.s=1),y=R(o)):(f=Math.abs(+St(o)),y=f%2),I=new v(F);;){if(y){if(I=I.times(B),!I.c)break;m?I.c.length>m&&(I.c.length=m):_&&(I=I.mod(u))}if(f){if(f=a(f/2),f===0)break;y=f%2}else if(o=o.times(d),ht(o,o.e+1,1),o.e>14)y=R(o);else{if(f=+St(o),f===0)break;y=f%2}B=B.times(B),m?B.c&&B.c.length>m&&(B.c.length=m):_&&(B=B.mod(u))}return _?I:(g&&(I=F.div(I)),u?I.mod(u):m?ht(I,Tt,J,x):I)},D.integerValue=function(o){var u=new v(this);return o==null?o=J:Q(o,0,8),ht(u,u.e+1,o)},D.isEqualTo=D.eq=function(o,u){return T(this,new v(o,u))===0},D.isFinite=function(){return!!this.c},D.isGreaterThan=D.gt=function(o,u){return T(this,new v(o,u))>0},D.isGreaterThanOrEqualTo=D.gte=function(o,u){return(u=T(this,new v(o,u)))===1||u===0},D.isInteger=function(){return!!this.c&&k(this.e/A)>this.c.length-2},D.isLessThan=D.lt=function(o,u){return T(this,new v(o,u))<0},D.isLessThanOrEqualTo=D.lte=function(o,u){return(u=T(this,new v(o,u)))===-1||u===0},D.isNaN=function(){return!this.s},D.isNegative=function(){return this.s<0},D.isPositive=function(){return this.s>0},D.isZero=function(){return!!this.c&&this.c[0]==0},D.minus=function(o,u){var d,_,f,m,x=this,h=x.s;if(o=new v(o,u),u=o.s,!h||!u)return new v(NaN);if(h!=u)return o.s=-u,x.plus(o);var g=x.e/A,y=o.e/A,I=x.c,B=o.c;if(!g||!y){if(!I||!B)return I?(o.s=-u,o):new v(B?x:NaN);if(!I[0]||!B[0])return B[0]?(o.s=-u,o):new v(I[0]?x:J==3?-0:0)}if(g=k(g),y=k(y),I=I.slice(),h=g-y){for((m=h<0)?(h=-h,f=I):(y=g,f=B),f.reverse(),u=h;u--;f.push(0));f.reverse()}else for(_=(m=(h=I.length)<(u=B.length))?h:u,h=u=0;u<_;u++)if(I[u]!=B[u]){m=I[u]<B[u];break}if(m&&(f=I,I=B,B=f,o.s=-o.s),u=(_=B.length)-(d=I.length),u>0)for(;u--;I[d++]=0);for(u=p-1;_>h;){if(I[--_]<B[_]){for(d=_;d&&!I[--d];I[d]=u);--I[d],I[_]+=p}I[_]-=B[_]}for(;I[0]==0;I.splice(0,1),--y);return I[0]?Ee(o,I,y):(o.s=J==3?-1:1,o.c=[o.e=0],o)},D.modulo=D.mod=function(o,u){var d,_,f=this;return o=new v(o,u),!f.c||!o.s||o.c&&!o.c[0]?new v(NaN):!o.c||f.c&&!f.c[0]?new v(f):(Zt==9?(_=o.s,o.s=1,d=M(f,o,0,3),o.s=_,d.s*=_):d=M(f,o,0,Zt),o=f.minus(d.times(o)),!o.c[0]&&Zt==1&&(o.s=f.s),o)},D.multipliedBy=D.times=function(o,u){var d,_,f,m,x,h,g,y,I,B,U,K,L,tt,rt,V=this,z=V.c,it=(o=new v(o,u)).c;if(!z||!it||!z[0]||!it[0])return!V.s||!o.s||z&&!z[0]&&!it||it&&!it[0]&&!z?o.c=o.e=o.s=null:(o.s*=V.s,!z||!it?o.c=o.e=null:(o.c=[0],o.e=0)),o;for(_=k(V.e/A)+k(o.e/A),o.s*=V.s,g=z.length,B=it.length,g<B&&(L=z,z=it,it=L,f=g,g=B,B=f),f=g+B,L=[];f--;L.push(0));for(tt=p,rt=w,f=B;--f>=0;){for(d=0,U=it[f]%rt,K=it[f]/rt|0,x=g,m=f+x;m>f;)y=z[--x]%rt,I=z[x]/rt|0,h=K*y+I*U,y=U*y+h%rt*rt+L[m]+d,d=(y/tt|0)+(h/rt|0)+K*I,L[m--]=y%tt;L[m]=d}return d?++_:L.splice(0,1),Ee(o,L,_)},D.negated=function(){var o=new v(this);return o.s=-o.s||null,o},D.plus=function(o,u){var d,_=this,f=_.s;if(o=new v(o,u),u=o.s,!f||!u)return new v(NaN);if(f!=u)return o.s=-u,_.minus(o);var m=_.e/A,x=o.e/A,h=_.c,g=o.c;if(!m||!x){if(!h||!g)return new v(f/0);if(!h[0]||!g[0])return g[0]?o:new v(h[0]?_:f*0)}if(m=k(m),x=k(x),h=h.slice(),f=m-x){for(f>0?(x=m,d=g):(f=-f,d=h),d.reverse();f--;d.push(0));d.reverse()}for(f=h.length,u=g.length,f-u<0&&(d=g,g=h,h=d,u=f),f=0;u;)f=(h[--u]=h[u]+g[u]+f)/p|0,h[u]=p===h[u]?0:h[u]%p;return f&&(h=[f].concat(h),++x),Ee(o,h,x)},D.precision=D.sd=function(o,u){var d,_,f,m=this;if(o!=null&&o!==!!o)return Q(o,1,b),u==null?u=J:Q(u,0,8),ht(new v(m),o,u);if(!(d=m.c))return null;if(f=d.length-1,_=f*A+1,f=d[f]){for(;f%10==0;f/=10,_--);for(f=d[0];f>=10;f/=10,_++);}return o&&m.e+1>_&&(_=m.e+1),_},D.shiftedBy=function(o){return Q(o,-C,C),this.times("1e"+o)},D.squareRoot=D.sqrt=function(){var o,u,d,_,f,m=this,x=m.c,h=m.s,g=m.e,y=q+4,I=new v("0.5");if(h!==1||!x||!x[0])return new v(!h||h<0&&(!x||x[0])?NaN:x?m:1/0);if(h=Math.sqrt(+St(m)),h==0||h==1/0?(u=N(x),(u.length+g)%2==0&&(u+="0"),h=Math.sqrt(+u),g=k((g+1)/2)-(g<0||g%2),h==1/0?u="5e"+g:(u=h.toExponential(),u=u.slice(0,u.indexOf("e")+1)+g),d=new v(u)):d=new v(h+""),d.c[0]){for(g=d.e,h=g+y,h<3&&(h=0);;)if(f=d,d=I.times(f.plus(M(m,f,y,1))),N(f.c).slice(0,h)===(u=N(d.c)).slice(0,h))if(d.e<g&&--h,u=u.slice(h-3,h+1),u=="9999"||!_&&u=="4999"){if(!_&&(ht(f,f.e+q+2,0),f.times(f).eq(m))){d=f;break}y+=4,h+=4,_=1}else{(!+u||!+u.slice(1)&&u.charAt(0)=="5")&&(ht(d,d.e+q+2,1),o=!d.times(d).eq(m));break}}return ht(d,d.e+q+1,J,o)},D.toExponential=function(o,u){return o!=null&&(Q(o,0,b),o++),Be(this,o,u,1)},D.toFixed=function(o,u){return o!=null&&(Q(o,0,b),o=o+this.e+1),Be(this,o,u)},D.toFormat=function(o,u,d){var _,f=this;if(d==null)o!=null&&u&&typeof u=="object"?(d=u,u=null):o&&typeof o=="object"?(d=o,o=u=null):d=we;else if(typeof d!="object")throw Error(c+"Argument not an object: "+d);if(_=f.toFixed(o,u),f.c){var m,x=_.split("."),h=+d.groupSize,g=+d.secondaryGroupSize,y=d.groupSeparator||"",I=x[0],B=x[1],U=f.s<0,K=U?I.slice(1):I,L=K.length;if(g&&(m=h,h=g,g=m,L-=m),h>0&&L>0){for(m=L%h||h,I=K.substr(0,m);m<L;m+=h)I+=y+K.substr(m,h);g>0&&(I+=y+K.slice(m)),U&&(I="-"+I)}_=B?I+(d.decimalSeparator||"")+((g=+d.fractionGroupSize)?B.replace(new RegExp("\\d{"+g+"}\\B","g"),"$&"+(d.fractionGroupSeparator||"")):B):I}return(d.prefix||"")+_+(d.suffix||"")},D.toFraction=function(o){var u,d,_,f,m,x,h,g,y,I,B,U,K=this,L=K.c;if(o!=null&&(h=new v(o),!h.isInteger()&&(h.c||h.s!==1)||h.lt(F)))throw Error(c+"Argument "+(h.isInteger()?"out of range: ":"not an integer: ")+St(h));if(!L)return new v(K);for(u=new v(F),y=d=new v(F),_=g=new v(F),U=N(L),m=u.e=U.length-K.e-1,u.c[0]=E[(x=m%A)<0?A+x:x],o=!o||h.comparedTo(u)>0?m>0?u:y:h,x=At,At=1/0,h=new v(U),g.c[0]=0;I=M(h,u,0,1),f=d.plus(I.times(_)),f.comparedTo(o)!=1;)d=_,_=f,y=g.plus(I.times(f=y)),g=f,u=h.minus(I.times(f=u)),h=f;return f=M(o.minus(d),_,0,1),g=g.plus(f.times(y)),d=d.plus(f.times(_)),g.s=y.s=K.s,m=m*2,B=M(y,_,m,J).minus(K).abs().comparedTo(M(g,d,m,J).minus(K).abs())<1?[y,_]:[g,d],At=x,B},D.toNumber=function(){return+St(this)},D.toPrecision=function(o,u){return o!=null&&Q(o,1,b),Be(this,o,u,2)},D.toString=function(o){var u,d=this,_=d.s,f=d.e;return f===null?_?(u="Infinity",_<0&&(u="-"+u)):u="NaN":(o==null?u=f<=nt||f>=lt?X(N(d.c),f):$(N(d.c),f,"0"):o===10&&Ce?(d=ht(new v(d),q+f+1,J),u=$(N(d.c),d.e,"0")):(Q(o,2,Rt.length,"Base"),u=W($(N(d.c),f,"0"),10,o,_,!0)),_<0&&d.c[0]&&(u="-"+u)),u},D.valueOf=D.toJSON=function(){return St(this)},D._isBigNumber=!0,O!=null&&v.set(O),v}function k(O){var M=O|0;return O>0||O===M?M:M-1}function N(O){for(var M,W,Z=1,D=O.length,F=O[0]+"";Z<D;){for(M=O[Z++]+"",W=A-M.length;W--;M="0"+M);F+=M}for(D=F.length;F.charCodeAt(--D)===48;);return F.slice(0,D+1||1)}function T(O,M){var W,Z,D=O.c,F=M.c,q=O.s,J=M.s,nt=O.e,lt=M.e;if(!q||!J)return null;if(W=D&&!D[0],Z=F&&!F[0],W||Z)return W?Z?0:-J:q;if(q!=J)return q;if(W=q<0,Z=nt==lt,!D||!F)return Z?0:!D^W?1:-1;if(!Z)return nt>lt^W?1:-1;for(J=(nt=D.length)<(lt=F.length)?nt:lt,q=0;q<J;q++)if(D[q]!=F[q])return D[q]>F[q]^W?1:-1;return nt==lt?0:nt>lt^W?1:-1}function Q(O,M,W,Z){if(O<M||O>W||O!==a(O))throw Error(c+(Z||"Argument")+(typeof O=="number"?O<M||O>W?" out of range: ":" not an integer: ":" not a primitive number: ")+String(O))}function R(O){var M=O.c.length-1;return k(O.e/A)==M&&O.c[M]%2!=0}function X(O,M){return(O.length>1?O.charAt(0)+"."+O.slice(1):O)+(M<0?"e":"e+")+M}function $(O,M,W){var Z,D;if(M<0){for(D=W+".";++M;D+=W);O=D+O}else if(Z=O.length,++M>Z){for(D=W,M-=Z;--M;D+=W);O+=D}else M<Z&&(O=O.slice(0,M)+"."+O.slice(M));return O}t=P(),t.default=t.BigNumber=t,s.exports?s.exports=t:(e||(e=typeof self<"u"&&self?self:window),e.BigNumber=t)})(ke)})(Le);(function(s){var e=Le.exports,t=s.exports;(function(){var r=/[\\\"\x00-\x1f\x7f-\x9f\u00ad\u0600-\u0604\u070f\u17b4\u17b5\u200c-\u200f\u2028-\u202f\u2060-\u206f\ufeff\ufff0-\uffff]/g,n,a,c={"\b":"\\b"," ":"\\t","\n":"\\n","\f":"\\f","\r":"\\r",'"':'\\"',"\\":"\\\\"},l;function p(C){return r.lastIndex=0,r.test(C)?'"'+C.replace(r,function(E){var w=c[E];return typeof w=="string"?w:"\\u"+("0000"+E.charCodeAt(0).toString(16)).slice(-4)})+'"':'"'+C+'"'}function A(C,E){var w,b,P,k,N=n,T,Q=E[C],R=Q!=null&&(Q instanceof e||e.isBigNumber(Q));switch(Q&&typeof Q=="object"&&typeof Q.toJSON=="function"&&(Q=Q.toJSON(C)),typeof l=="function"&&(Q=l.call(E,C,Q)),typeof Q){case"string":return R?Q:p(Q);case"number":return isFinite(Q)?String(Q):"null";case"boolean":case"null":case"bigint":return String(Q);case"object":if(!Q)return"null";if(n+=a,T=[],Object.prototype.toString.apply(Q)==="[object Array]"){for(k=Q.length,w=0;w<k;w+=1)T[w]=A(w,Q)||"null";return P=T.length===0?"[]":n?`[
|
|
2
|
+
`+n+T.join(`,
|
|
3
|
+
`+n)+`
|
|
4
|
+
`+N+"]":"["+T.join(",")+"]",n=N,P}if(l&&typeof l=="object")for(k=l.length,w=0;w<k;w+=1)typeof l[w]=="string"&&(b=l[w],P=A(b,Q),P&&T.push(p(b)+(n?": ":":")+P));else Object.keys(Q).forEach(function(X){var $=A(X,Q);$&&T.push(p(X)+(n?": ":":")+$)});return P=T.length===0?"{}":n?`{
|
|
5
|
+
`+n+T.join(`,
|
|
6
|
+
`+n)+`
|
|
7
|
+
`+N+"}":"{"+T.join(",")+"}",n=N,P}}typeof t.stringify!="function"&&(t.stringify=function(C,E,w){var b;if(n="",a="",typeof w=="number")for(b=0;b<w;b+=1)a+=" ";else typeof w=="string"&&(a=w);if(l=E,E&&typeof E!="function"&&(typeof E!="object"||typeof E.length!="number"))throw new Error("JSON.stringify");return A("",{"":C})})})()})(Hr);var de=null;const un=/(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])/,ln=/(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)/;var dn=function(s){var e={strict:!1,storeAsString:!1,alwaysParseAsBig:!1,useNativeBigInt:!1,protoAction:"error",constructorAction:"error"};if(s!=null){if(s.strict===!0&&(e.strict=!0),s.storeAsString===!0&&(e.storeAsString=!0),e.alwaysParseAsBig=s.alwaysParseAsBig===!0?s.alwaysParseAsBig:!1,e.useNativeBigInt=s.useNativeBigInt===!0?s.useNativeBigInt:!1,typeof s.constructorAction<"u")if(s.constructorAction==="error"||s.constructorAction==="ignore"||s.constructorAction==="preserve")e.constructorAction=s.constructorAction;else throw new Error(`Incorrect value for constructorAction option, must be "error", "ignore" or undefined but passed ${s.constructorAction}`);if(typeof s.protoAction<"u")if(s.protoAction==="error"||s.protoAction==="ignore"||s.protoAction==="preserve")e.protoAction=s.protoAction;else throw new Error(`Incorrect value for protoAction option, must be "error", "ignore" or undefined but passed ${s.protoAction}`)}var t,r,n={'"':'"',"\\":"\\","/":"/",b:"\b",f:"\f",n:`
|
|
8
|
+
`,r:"\r",t:" "},a,c=function(k){throw{name:"SyntaxError",message:k,at:t,text:a}},l=function(k){return k&&k!==r&&c("Expected '"+k+"' instead of '"+r+"'"),r=a.charAt(t),t+=1,r},p=function(){var k,N="";for(r==="-"&&(N="-",l("-"));r>="0"&&r<="9";)N+=r,l();if(r===".")for(N+=".";l()&&r>="0"&&r<="9";)N+=r;if(r==="e"||r==="E")for(N+=r,l(),(r==="-"||r==="+")&&(N+=r,l());r>="0"&&r<="9";)N+=r,l();if(k=+N,!isFinite(k))c("Bad number");else return de==null&&(de=Le.exports),N.length>15?e.storeAsString?N:e.useNativeBigInt?BigInt(N):new de(N):e.alwaysParseAsBig?e.useNativeBigInt?BigInt(k):new de(k):k},A=function(){var k,N,T="",Q;if(r==='"')for(var R=t;l();){if(r==='"')return t-1>R&&(T+=a.substring(R,t-1)),l(),T;if(r==="\\"){if(t-1>R&&(T+=a.substring(R,t-1)),l(),r==="u"){for(Q=0,N=0;N<4&&(k=parseInt(l(),16),!!isFinite(k));N+=1)Q=Q*16+k;T+=String.fromCharCode(Q)}else if(typeof n[r]=="string")T+=n[r];else break;R=t}}c("Bad string")},C=function(){for(;r&&r<=" ";)l()},E=function(){switch(r){case"t":return l("t"),l("r"),l("u"),l("e"),!0;case"f":return l("f"),l("a"),l("l"),l("s"),l("e"),!1;case"n":return l("n"),l("u"),l("l"),l("l"),null}c("Unexpected '"+r+"'")},w,b=function(){var k=[];if(r==="["){if(l("["),C(),r==="]")return l("]"),k;for(;r;){if(k.push(w()),C(),r==="]")return l("]"),k;l(","),C()}}c("Bad array")},P=function(){var k,N=Object.create(null);if(r==="{"){if(l("{"),C(),r==="}")return l("}"),N;for(;r;){if(k=A(),C(),l(":"),e.strict===!0&&Object.hasOwnProperty.call(N,k)&&c('Duplicate key "'+k+'"'),un.test(k)===!0?e.protoAction==="error"?c("Object contains forbidden prototype property"):e.protoAction==="ignore"?w():N[k]=w():ln.test(k)===!0?e.constructorAction==="error"?c("Object contains forbidden constructor property"):e.constructorAction==="ignore"?w():N[k]=w():N[k]=w(),C(),r==="}")return l("}"),N;l(","),C()}}c("Bad object")};return w=function(){switch(C(),r){case"{":return P();case"[":return b();case'"':return A();case"-":return p();default:return r>="0"&&r<="9"?p():E()}},function(k,N){var T;return a=k+"",t=0,r=" ",T=w(),C(),r&&c("Syntax error"),typeof N=="function"?function Q(R,X){var $,O=R[X];return O&&typeof O=="object"&&Object.keys(O).forEach(function(M){$=Q(O,M),$!==void 0?O[M]=$:delete O[M]}),N.call(R,X,O)}({"":T},""):T}},hn=dn,Fr=Hr.exports.stringify,Rr=hn;zt.exports=function(s){return{parse:Rr(s),stringify:Fr}};zt.exports.parse=Rr();zt.exports.stringify=Fr;class fn{txHex="";txBuilder=ge();txEvaluationMultiplier=1.1;_protocolParams=gt;txOutput;addingScriptInput=!1;addingPlutusMint=!1;isHydra=!1;meshTxBuilderBody;mintItem;txInQueueItem;collateralQueueItem;refScriptTxInQueueItem;reset=()=>(this.txHex="",this.txBuilder=ge(),this.txEvaluationMultiplier=1.1,this._protocolParams=gt,this.txOutput=void 0,this.addingScriptInput=!1,this.addingPlutusMint=!1,this.mintItem=void 0,this.txInQueueItem=void 0,this.collateralQueueItem=void 0,this.refScriptTxInQueueItem=void 0,this.meshTxBuilderBody=this.emptyTxBuilderBody(),this);emptyTxBuilderBody=()=>({inputs:[],outputs:[],extraInputs:[],selectionThreshold:0,collaterals:[],requiredSignatures:[],referenceInputs:[],mints:[],changeAddress:"",metadata:[],validityRange:{},certificates:[],signingKey:[]});constructor(){this.meshTxBuilderBody=this.emptyTxBuilderBody()}completeSync=e=>(e?this.meshTxBuilderBody=e:this.queueAllLastItem(),this.serializeTxBody(this.meshTxBuilderBody));completeSigning=()=>{const{signingKey:e}=this.meshTxBuilderBody;return e.length>0&&this.addAllSigningKeys(e),this.txHex};serializeTxBody=e=>{const{inputs:t,outputs:r,extraInputs:n,selectionThreshold:a,collaterals:c,referenceInputs:l,mints:p,changeAddress:A,certificates:C,validityRange:E,requiredSignatures:w,metadata:b}=e;if(this.isHydra?this.protocolParams({minFeeA:0,minFeeB:0,priceMem:0,priceStep:0,collateralPercent:0,coinsPerUTxOSize:"0"}):this.protocolParams({}),n.length>0&&this.addUtxosFrom(n,String(a)),this.removeDuplicateInputs(),this.meshTxBuilderBody.mints.sort((P,k)=>P.policyId.localeCompare(k.policyId)),this.meshTxBuilderBody.inputs.sort((P,k)=>P.txIn.txHash===k.txIn.txHash?P.txIn.txIndex-k.txIn.txIndex:P.txIn.txHash.localeCompare(k.txIn.txHash)),this.addAllInputs(t),this.addAllOutputs(r),this.addAllCollaterals(c),this.addAllReferenceInputs(l),this.addAllMints(p),this.addAllCertificates(C),this.addValidityRange(E),this.addAllRequiredSignatures(w),this.addAllMetadata(b),this.addCostModels(),A){const P=this.meshTxBuilderBody.collaterals.map(T=>{var Q,R;return((R=(Q=T.txIn.amount)==null?void 0:Q.find(X=>X.unit==="lovelace"))==null?void 0:R.quantity)||"0"}).reduce((T,Q)=>T+parseInt(Q),0),k=Math.ceil(this._protocolParams.collateralPercent*Number(Number(this.txBuilder.min_fee().checked_add(i.BigNum.from_str("10000")).to_js_value()))/100);let N=!1;if(P-k>0){const T=i.TransactionOutput.new(i.Address.from_bech32(A),i.Value.new(i.BigNum.from_str(String(k))));P-k>Number(i.min_ada_for_output(T,i.DataCost.new_coins_per_byte(i.BigNum.from_str(this._protocolParams.coinsPerUTxOSize))).to_js_value())&&(this.txBuilder.set_collateral_return(i.TransactionOutput.new(i.Address.from_bech32(A),i.Value.new(i.BigNum.from_str(String(P))))),this.txBuilder.set_total_collateral(i.BigNum.from_str(String(P))),N=!0)}this.addChange(A),N&&this.addCollateralReturn(A)}return this.buildTx(),this};txIn=(e,t,r,n)=>(this.txInQueueItem&&this.queueInput(),this.addingScriptInput?this.txInQueueItem={type:"Script",txIn:{txHash:e,txIndex:t,amount:r,address:n},scriptTxIn:{}}:this.txInQueueItem={type:"PubKey",txIn:{txHash:e,txIndex:t,amount:r,address:n}},this.addingScriptInput=!1,this);txInScript=(e,t="V2")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Datum value attempted to be called a non script input");return this.txInQueueItem.scriptTxIn.scriptSource={type:"Provided",script:{code:e,version:t}},this};txInDatumValue=(e,t="Mesh")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Datum value attempted to be called a non script input");let r=e;return t==="JSON"&&(r=this.castRawDataToJsonString(e)),t==="Mesh"?(this.txInQueueItem.scriptTxIn.datumSource={type:"Provided",data:{type:t,content:e}},this):(this.txInQueueItem.scriptTxIn.datumSource={type:"Provided",data:{type:t,content:r}},this)};txInInlineDatumPresent=()=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Inline datum present attempted to be called a non script input");const{txHash:e,txIndex:t}=this.txInQueueItem.txIn;return e&&t.toString()&&(this.txInQueueItem.scriptTxIn.datumSource={type:"Inline",txHash:e,txIndex:t}),this};txInRedeemerValue=(e,t={...Gt},r="Mesh")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Spending tx in reference redeemer attempted to be called a non script input");let n=e;return r==="Mesh"?(this.txInQueueItem.scriptTxIn.redeemer={data:{type:r,content:e},exUnits:t},this):(r==="JSON"&&(n=this.castRawDataToJsonString(e)),this.txInQueueItem.scriptTxIn.redeemer={data:{type:r,content:n},exUnits:t},this)};txOut=(e,t)=>(this.txOutput&&(this.meshTxBuilderBody.outputs.push(this.txOutput),this.txOutput=void 0),this.txOutput={address:e,amount:t},this);txOutDatumHashValue=(e,t="Mesh")=>{let r=e;if(this.txOutput){if(t==="Mesh")return this.txOutput.datum={type:"Hash",data:{type:t,content:r}},this;t==="JSON"&&(r=this.castRawDataToJsonString(e)),this.txOutput.datum={type:"Hash",data:{type:t,content:r}}}return this};txOutInlineDatumValue=(e,t="Mesh")=>{let r=e;if(this.txOutput){if(t==="Mesh")return this.txOutput.datum={type:"Inline",data:{type:t,content:r}},this;t==="JSON"&&(r=this.castRawDataToJsonString(e)),this.txOutput.datum={type:"Inline",data:{type:t,content:r}}}return this};txOutReferenceScript=(e,t="V2")=>(this.txOutput&&(this.txOutput.referenceScript={code:e,version:t}),this);spendingPlutusScriptV2=()=>(this.addingScriptInput=!0,this);spendingTxInReference=(e,t,r,n="V2")=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="PubKey")throw Error("Spending tx in reference attempted to be called a non script input");return this.txInQueueItem.scriptTxIn.scriptSource={type:"Inline",txInInfo:{txHash:e,txIndex:t,spendingScriptHash:r,version:n}},this};spendingReferenceTxInInlineDatumPresent=()=>(this.txInInlineDatumPresent(),this);spendingReferenceTxInRedeemerValue=(e,t={...Gt})=>(this.txInRedeemerValue(e,t),this);readOnlyTxInReference=(e,t)=>(this.meshTxBuilderBody.referenceInputs.push({txHash:e,txIndex:t}),this);mintPlutusScriptV2=()=>(this.addingPlutusMint=!0,this);mint=(e,t,r)=>(this.mintItem&&this.queueMint(),this.mintItem={type:this.addingPlutusMint?"Plutus":"Native",policyId:t,assetName:r,amount:e},this.addingPlutusMint=!1,this);mintingScript=(e,t="V2")=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.type)throw Error("Mint information missing");return this.mintItem.scriptSource={type:"Provided",script:{code:e,version:t}},this};mintTxInReference=(e,t,r="V2")=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.type)throw Error("Mint information missing");if(this.mintItem.type=="Native")throw Error("Mint tx in reference can only be used on plutus script tokens");if(!this.mintItem.policyId)throw Error("PolicyId information missing from mint asset");return this.mintItem.scriptSource={type:"Reference Script",txHash:e,txIndex:t,version:r},this};mintReferenceTxInRedeemerValue=(e,t={...Gt},r="Mesh")=>{if(!this.mintItem)throw Error("Undefined mint");if(this.mintItem.type=="Native")throw Error("Mint tx in reference can only be used on plutus script tokens");if(this.mintItem.type=="Plutus"){if(!this.mintItem.policyId)throw Error("PolicyId information missing from mint asset");let n=e;if(r==="Mesh")return this.mintItem.redeemer={data:{type:r,content:n},exUnits:t},this;r==="JSON"&&(n=this.castRawDataToJsonString(e)),this.mintItem.redeemer={data:{type:r,content:n},exUnits:t}}return this};mintRedeemerValue=(e,t={...Gt},r="Mesh")=>(this.mintReferenceTxInRedeemerValue(e,t,r),this);requiredSignerHash=e=>(this.meshTxBuilderBody.requiredSignatures.push(e),this);txInCollateral=(e,t,r,n)=>(this.collateralQueueItem&&this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem),this.collateralQueueItem={type:"PubKey",txIn:{txHash:e,txIndex:t,amount:r,address:n}},this);registerPoolCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"RegisterPool",poolParams:e}),this);registerStakeCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"RegisterStake",stakeKeyHash:e}),this);delegateStakeCertificate=(e,t)=>(this.meshTxBuilderBody.certificates.push({type:"DelegateStake",stakeKeyHash:e,poolId:t}),this);deregisterStakeCertificate=e=>(this.meshTxBuilderBody.certificates.push({type:"DeregisterStake",stakeKeyHash:e}),this);retirePoolCertificate=(e,t)=>(this.meshTxBuilderBody.certificates.push({type:"RetirePool",poolId:e,epoch:t}),this);changeAddress=e=>(this.meshTxBuilderBody.changeAddress=e,this);invalidBefore=e=>(this.meshTxBuilderBody.validityRange.invalidBefore=e,this);invalidHereafter=e=>(this.meshTxBuilderBody.validityRange.invalidHereafter=e,this);metadataValue=(e,t)=>(this.meshTxBuilderBody.metadata.push({tag:e,metadata:t}),this);protocolParams=e=>{const t={...gt,...e};return this._protocolParams=t,this.txBuilder=ge(t),this};signingKey=e=>(this.meshTxBuilderBody.signingKey.push(e),this);selectUtxosFrom=(e,t=5e6)=>(this.meshTxBuilderBody.extraInputs=e,this.meshTxBuilderBody.selectionThreshold=t,this);addUtxosFrom=(e,t)=>{const r=this.meshTxBuilderBody.outputs.reduce((a,c)=>(c.amount.forEach(p=>{const{unit:A,quantity:C}=p,E=Number(a.get(A))||0;a.set(A,String(E+Number(C)))}),a),new Map);this.meshTxBuilderBody.inputs.reduce((a,c)=>{const l=c.txIn.amount;return l==null||l.forEach(p=>{const{unit:A,quantity:C}=p,E=Number(a.get(A))||0;a.set(A,String(E-Number(C)))}),a},r),this.meshTxBuilderBody.mints.reduce((a,c)=>{const l={unit:c.policyId+c.assetName,quantity:String(c.amount)},p=Number(a.get(l.unit))||0;return a.set(l.unit,String(p-Number(l.quantity))),a},r),on(e,r,t).forEach(a=>{this.addTxIn({type:"PubKey",txIn:{txHash:a.input.txHash,txIndex:a.input.outputIndex,amount:a.output.amount,address:a.output.address}})})};addAllSigningKeys=e=>{if(e.length>0){const t=i.Vkeywitnesses.new(),r=i.Transaction.from_hex(this.txHex),n=r.body();e.forEach(l=>{const p=l.slice(0,4)==="5820"?l.slice(4):l,A=i.PrivateKey.from_hex(p),C=i.make_vkey_witness(i.hash_transaction(n),A);t.add(C)});const a=r.witness_set();a.set_vkeys(t);const c=i.Transaction.new(n,a,r.auxiliary_data());this.txHex=c.to_hex()}};buildTx=()=>{const e=this.txBuilder.build_tx();this.txHex=e.to_hex()};queueInput=()=>{if(!this.txInQueueItem)throw Error("Undefined input");if(this.txInQueueItem.type==="Script")if(this.txInQueueItem.scriptTxIn){if(!this.txInQueueItem.scriptTxIn.datumSource)throw Error("Script input does not contain datum information");if(!this.txInQueueItem.scriptTxIn.redeemer)throw Error("Script input does not contain redeemer information");if(!this.txInQueueItem.scriptTxIn.scriptSource)throw Error("Script input does not contain script information")}else throw Error("Script input does not contain script, datum, or redeemer information");this.meshTxBuilderBody.inputs.push(this.txInQueueItem),this.txInQueueItem=void 0};queueMint=()=>{if(!this.mintItem)throw Error("Undefined mint");if(!this.mintItem.scriptSource)throw Error("Missing mint script information");this.meshTxBuilderBody.mints.push(this.mintItem),this.mintItem=void 0};makePlutusScriptSource=e=>{const t=i.ScriptHash.from_hex(e.spendingScriptHash),r=i.TransactionInput.new(i.TransactionHash.from_hex(e.txHash),e.txIndex);return i.PlutusScriptSource.new_ref_input_with_lang_ver(t,r,vt[e.version])};removeDuplicateInputs=()=>{const e=this.meshTxBuilderBody.inputs,t=n=>`${n.txHash}#${n.txIndex}`,r=[];for(let n=0;n<e.length;n++){const a=t(e[n].txIn);r.includes(a)?(e.splice(n,1),n--):r.push(a)}};addAllInputs=e=>{for(let t=0;t<e.length;t++){const r=e[t];switch(r.type){case"PubKey":this.addTxIn(r);break;case"Script":this.addScriptTxIn(r);break}}};addTxIn=e=>{this.txBuilder.add_input(i.Address.from_bech32(e.txIn.address),i.TransactionInput.new(i.TransactionHash.from_hex(e.txIn.txHash),e.txIn.txIndex),Qt(e.txIn.amount))};addScriptTxIn=({scriptTxIn:e,txIn:t})=>{let r;const{datumSource:n,scriptSource:a,redeemer:c}=e;if(n.type==="Provided")r=i.DatumSource.new(this.castDataToPlutusData(n.data));else{const A=i.TransactionInput.new(i.TransactionHash.from_hex(n.txHash),n.txIndex);r=i.DatumSource.new_ref_input(A)}let l;a.type=="Inline"?l=this.makePlutusScriptSource(a.txInInfo):l=i.PlutusScriptSource.new(i.PlutusScript.from_hex_with_version(a.script.code,vt[a.script.version]));const p=i.Redeemer.new(i.RedeemerTag.new_spend(),i.BigNum.from_str("0"),this.castDataToPlutusData(c.data),i.ExUnits.new(i.BigNum.from_str(String(c.exUnits.mem)),i.BigNum.from_str(String(c.exUnits.steps))));this.txBuilder.add_plutus_script_input(i.PlutusWitness.new_with_ref(l,r,p),i.TransactionInput.new(i.TransactionHash.from_hex(t.txHash),t.txIndex),Qt(t.amount))};addAllOutputs=e=>{for(let t=0;t<e.length;t++){const r=e[t];this.addOutput(r)}};addOutput=({amount:e,address:t,datum:r,referenceScript:n})=>{const a=Qt(e),c=a.multiasset();if(a.is_zero()&&c===void 0)throw Error("Invalid output amount");let l=i.TransactionOutputBuilder.new().with_address(_t(t));r&&r.type==="Hash"&&(l=l.with_data_hash(i.hash_plutus_data(this.castDataToPlutusData(r.data)))),r&&r.type==="Inline"&&(l=l.with_plutus_data(this.castDataToPlutusData(r.data))),n&&(l=l.with_script_ref(i.ScriptRef.new_plutus_script(i.PlutusScript.from_hex_with_version(n.code,vt[n.version]))));const p=l.next();if(c){const A=a.coin().is_zero()?p.with_asset_and_min_required_coin_by_utxo_cost(c,Ne(this._protocolParams.coinsPerUTxOSize)).build():p.with_coin_and_asset(a.coin(),c).build();this.txBuilder.add_output(A)}else{const A=p.with_coin(a.coin()).build();this.txBuilder.add_output(A)}};addAllCollaterals=e=>{const t=i.TxInputsBuilder.new();for(let r=0;r<e.length;r++){const n=e[r];this.addCollateral(t,n)}this.txBuilder.set_collateral(t)};addCollateral=(e,t)=>{e.add_input(i.Address.from_bech32(t.txIn.address),i.TransactionInput.new(i.TransactionHash.from_hex(t.txIn.txHash),t.txIn.txIndex),Qt(t.txIn.amount))};addCollateralReturn=e=>{var r;const t=(r=this.txBuilder.get_fee_if_set())==null?void 0:r.to_js_value();if(t){const n=Math.ceil(this._protocolParams.collateralPercent*Number(t)/100);this.txBuilder.set_total_collateral_and_return(i.BigNum.from_str(String(n)),i.Address.from_bech32(e))}};addAllReferenceInputs=e=>{e.forEach(t=>{this.addReferenceInput(t)})};addReferenceInput=({txHash:e,txIndex:t})=>{const r=i.TransactionInput.new(i.TransactionHash.from_hex(e),t);this.txBuilder.add_reference_input(r)};addAllMints=e=>{const t=i.MintBuilder.new();let r=0;for(let n=0;n<e.length;n++){const a=e[n];if(!a.scriptSource)throw Error("Mint script is expected to be provided");if(a.type==="Plutus"){if(!a.redeemer)throw Error("Missing mint redeemer information");this.addPlutusMint(t,a,r),r++}else a.type==="Native"&&this.addNativeMint(t,a)}this.txBuilder.set_mint_builder(t)};addPlutusMint=(e,{redeemer:t,policyId:r,scriptSource:n,assetName:a,amount:c},l)=>{const p=i.Redeemer.new(i.RedeemerTag.new_mint(),i.BigNum.from_str(String(l)),this.castDataToPlutusData(t.data),i.ExUnits.new(i.BigNum.from_str(String(t.exUnits.mem)),i.BigNum.from_str(String(t.exUnits.steps)))),A=n.type==="Reference Script"?i.PlutusScriptSource.new_ref_input_with_lang_ver(i.ScriptHash.from_hex(r),i.TransactionInput.new(i.TransactionHash.from_hex(n.txHash),n.txIndex),vt[n.version]):i.PlutusScriptSource.new(i.PlutusScript.from_hex_with_version(n.script.code,vt[n.script.version]));e.add_asset(i.MintWitness.new_plutus_script(A,p),i.AssetName.new(Buffer.from(a,"hex")),i.Int.new(i.BigNum.from_str(c)))};addNativeMint=(e,{scriptSource:t,assetName:r,amount:n})=>{if(t.type==="Reference Script")throw Error("Native mint cannot have reference script");e.add_asset(i.MintWitness.new_native_script(i.NativeScript.from_hex(t.script.code)),i.AssetName.new(Buffer.from(r,"hex")),i.Int.new(i.BigNum.from_str(n)))};decimalToFraction(e){const t=10**e.toString().split(".")[1].length;return[e*t,t]}toPoolParams=e=>{const t=this.decimalToFraction(e.margin),r=i.Relays.new();e.relays.forEach(c=>{r.add(Nr(c))});const n=i.RewardAddress.from_address(i.Address.from_bech32(e.rewardAddress));if(n===void 0)throw new Error("Reward address is invalid");const a=i.Ed25519KeyHashes.new();return e.owners.forEach(c=>{a.add(i.Ed25519KeyHash.from_hex(c))}),i.PoolParams.new(i.Ed25519KeyHash.from_hex(e.operator),i.VRFKeyHash.from_hex(e.VRFKeyHash),i.BigNum.from_str(e.pledge),i.BigNum.from_str(e.cost),i.UnitInterval.new(i.BigNum.from_str(t[0].toString()),i.BigNum.from_str(t[1].toString())),n,a,r,e.metadata?i.PoolMetadata.from_json(zt.exports.stringify(e.metadata)):void 0)};addCertificate=(e,t)=>{switch(t.type){case"RegisterPool":e.add(i.Certificate.new_pool_registration(i.PoolRegistration.new(this.toPoolParams(t.poolParams))));break;case"RegisterStake":e.add(i.Certificate.new_stake_registration(i.StakeRegistration.new(i.StakeCredential.from_keyhash(i.Ed25519KeyHash.from_hex(t.stakeKeyHash)))));break;case"DelegateStake":e.add(i.Certificate.new_stake_delegation(i.StakeDelegation.new(i.StakeCredential.from_keyhash(i.Ed25519KeyHash.from_hex(t.stakeKeyHash)),t.poolId.startsWith("pool")?i.Ed25519KeyHash.from_bech32(t.poolId):i.Ed25519KeyHash.from_hex(t.poolId))));break;case"DeregisterStake":e.add(i.Certificate.new_stake_deregistration(i.StakeDeregistration.new(i.StakeCredential.from_keyhash(i.Ed25519KeyHash.from_hex(t.stakeKeyHash)))));break;case"RetirePool":e.add(i.Certificate.new_pool_retirement(i.PoolRetirement.new(t.poolId.startsWith("pool")?i.Ed25519KeyHash.from_bech32(t.poolId):i.Ed25519KeyHash.from_hex(t.poolId),t.epoch)))}};queueAllLastItem=()=>{this.txOutput&&(this.meshTxBuilderBody.outputs.push(this.txOutput),this.txOutput=void 0),this.txInQueueItem&&this.queueInput(),this.collateralQueueItem&&(this.meshTxBuilderBody.collaterals.push(this.collateralQueueItem),this.collateralQueueItem=void 0),this.mintItem&&this.queueMint()};addAllCertificates=e=>{const t=i.Certificates.new();e.forEach(r=>{this.addCertificate(t,r)}),this.txBuilder.set_certs(t)};addCostModels=()=>{this.txBuilder.calc_script_data_hash(i.TxBuilderConstants.plutus_vasil_cost_models())};addChange=e=>{this.txBuilder.add_change_if_needed(i.Address.from_bech32(e))};addValidityRange=({invalidBefore:e,invalidHereafter:t})=>{e&&this.txBuilder.set_validity_start_interval_bignum(i.BigNum.from_str(e.toString())),t&&this.txBuilder.set_ttl_bignum(i.BigNum.from_str(t.toString()))};addAllRequiredSignatures=e=>{e.forEach(t=>{this.txBuilder.add_required_signer(i.Ed25519KeyHash.from_hex(t))})};addAllMetadata=e=>{e.forEach(({tag:t,metadata:r})=>{this.txBuilder.add_json_metadatum(i.BigNum.from_str(t),zt.exports.stringify(r))})};updateRedeemer=(e,t)=>{t.forEach(r=>{switch(r.tag){case"SPEND":{const n=e.inputs[r.index];n.type=="Script"&&n.scriptTxIn.redeemer&&(n.scriptTxIn.redeemer.exUnits.mem=Math.floor(r.budget.mem*this.txEvaluationMultiplier),n.scriptTxIn.redeemer.exUnits.steps=Math.floor(r.budget.steps*this.txEvaluationMultiplier));break}case"MINT":{const n=e.mints[r.index];n.type=="Plutus"&&n.redeemer&&(n.redeemer.exUnits.mem=Math.floor(r.budget.mem*this.txEvaluationMultiplier),n.redeemer.exUnits.steps=Math.floor(r.budget.steps*this.txEvaluationMultiplier));break}}})};castRawDataToJsonString=e=>typeof e=="object"?zt.exports.stringify(e):e;castDataToPlutusData=({type:e,content:t})=>e==="Mesh"?Ot(t):e==="CBOR"?i.PlutusData.from_hex(t):i.PlutusData.from_json(t,i.PlutusDatumSchema.DetailedSchema)}class gn extends fn{_fetcher;_submitter;_evaluator;queriedTxHashes=new Set;queriedUTxOs={};constructor({fetcher:e,submitter:t,evaluator:r,isHydra:n=!1}){super(),e&&(this._fetcher=e),t&&(this._submitter=t),r&&(this._evaluator=r),n&&(this.isHydra=!0)}complete=async e=>{e?this.meshTxBuilderBody=e:this.queueAllLastItem();const{inputs:t,collaterals:r}=this.meshTxBuilderBody,n=[...t,...r].filter(a=>!this.isInputComplete(a));if(console.log("Incomplete UTxO",n),await this.queryAllTxInfo(n),console.log("Incomplete UTxO",n),n.forEach(a=>{this.completeTxInformation(a)}),this.completeSync(e),this._evaluator){const a=await this._evaluator.evaluateTx(this.txHex);this.updateRedeemer(this.meshTxBuilderBody,a),this.completeSync(e)}return this};submitTx=async e=>{var r;return await((r=this._submitter)==null?void 0:r.submitTx(e))};getUTxOInfo=async e=>{var r;let t=[];this.queriedTxHashes.has(e)||(console.log("Query",e),this.queriedTxHashes.add(e),t=await((r=this._fetcher)==null?void 0:r.fetchUTxOs(e))||[],this.queriedUTxOs[e]=t)};queryAllTxInfo=e=>{var r;const t=[];if(e.length>0&&!this._fetcher)throw Error("Transaction information is incomplete while no fetcher instance is provided");for(let n=0;n<e.length;n++){const a=e[n];this.isInputInfoComplete(a)||t.push(this.getUTxOInfo(a.txIn.txHash)),a.type==="Script"&&((r=a.scriptTxIn.scriptSource)==null?void 0:r.type)==="Inline"&&!this.isRefScriptInfoComplete(a)&&t.push(this.getUTxOInfo(a.scriptTxIn.scriptSource.txInInfo.txHash))}return Promise.all(t)};completeTxInformation=e=>{var t;if(!this.isInputInfoComplete(e)){const r=this.queriedUTxOs[e.txIn.txHash],n=r==null?void 0:r.find(l=>l.input.outputIndex===e.txIn.txIndex),a=n==null?void 0:n.output.amount,c=n==null?void 0:n.output.address;if(!a||a.length===0)throw Error(`Couldn't find value information for ${e.txIn.txHash}#${e.txIn.txIndex}`);if(e.txIn.amount=a,e.type==="PubKey"){if(!c||c==="")throw Error(`Couldn't find address information for ${e.txIn.txHash}#${e.txIn.txIndex}`);e.txIn.address=c}}if(e.type==="Script"&&((t=e.scriptTxIn.scriptSource)==null?void 0:t.type)=="Inline"&&!this.isRefScriptInfoComplete(e)){const r=e.scriptTxIn.scriptSource.txInInfo,a=this.queriedUTxOs[r.txHash].find(c=>c.input.outputIndex===r.txIndex);if(!a)throw Error(`Couldn't find script reference utxo for ${r.txHash}#${r.txIndex}`);r.spendingScriptHash=a==null?void 0:a.output.scriptHash}};isInputComplete=e=>e.type==="PubKey"?this.isInputInfoComplete(e):e.type==="Script"?this.isInputInfoComplete(e)&&this.isRefScriptInfoComplete(e):!0;isInputInfoComplete=e=>{const{amount:t,address:r}=e.txIn;return!(e.type==="PubKey"&&(!t||!r)||e.type==="Script"&&!t)};isRefScriptInfoComplete=e=>{var r;const{scriptSource:t}=e.scriptTxIn;return!((t==null?void 0:t.type)==="Inline"&&!((r=t.txInInfo)!=null&&r.spendingScriptHash))}}class st{_networkId;_encryptedSecret;constructor(e,t){this._networkId=e,this._encryptedSecret=t}getAccount(e,t){return this.accountContext(e,t,(r,n)=>{const a=dr(this._networkId,r.to_public().hash(),n.to_public().hash()).to_address().to_bech32(),c=hr(this._networkId,r.to_public().hash()).to_address().to_bech32(),l=Pe(this._networkId,n.to_public().hash()).to_address().to_bech32();return{baseAddress:a,enterpriseAddress:c,rewardAddress:l}})}signData(e,t,r,n){try{return this.accountContext(e,t,(a,c)=>{const l={payload:n},p={address:st.resolveAddress(this._networkId,r,a,c),key:r.startsWith("stake")?c:a},{coseSign1:A,coseKey:C}=ss(l,p);return{signature:A,key:C}})}catch(a){throw new Error(`An error occurred during signData: ${a}.`)}}signTx(e,t,r,n,a){try{const c=Dr(Kr(n));return this.accountContext(e,t,(l,p)=>{const A=i.Vkeywitnesses.new();return st.resolveSigners(n,r,l.to_public().hash().to_hex()).forEach(E=>{if(E===l.to_public().hash().to_hex())A.add(i.make_vkey_witness(c,l));else if(E===p.to_public().hash().to_hex())A.add(i.make_vkey_witness(c,p));else if(a===!1)throw new Error(`Missing key witness for: ${E}`)}),A})}catch(c){throw new Error(`An error occurred during signTx: ${c}.`)}}static encryptMnemonic(e,t){const r=De.mnemonicToEntropy(e.join(" ")),n=Or(r),a=dt(n.as_bytes());return n.free(),st.encrypt(a,t)}static encryptPrivateKey(e,t){const r=i.Bip32PrivateKey.from_bech32(e),n=dt(r.as_bytes());return r.free(),st.encrypt(n,t)}static encryptSigningKeys(e,t,r){const n=st.encrypt(e.slice(4),r),a=st.encrypt(t.slice(4),r);return[n,a]}static generateMnemonic(e=256){return De.generateMnemonic(e).split(" ")}accountContext(e,t,r){const{paymentKey:n,stakeKey:a}=st.resolveKeys(e,t,this._encryptedSecret),c=r(n,a);return n.free(),a.free(),c}static decrypt(e,t){try{return i.decrypt_with_password(ct(t),e)}catch{throw new Error("The password is incorrect.")}}static encrypt(e,t){const r=mr.customAlphabet("0123456789abcdef"),n=r(64),a=r(24);return i.encrypt_with_password(ct(t),n,a,e)}static resolveAddress(e,t,r,n){const a=[dr(e,r.to_public().hash(),n.to_public().hash()),hr(e,r.to_public().hash()),Pe(e,n.to_public().hash())].find(c=>c.to_address().to_bech32()===t);if(a!==void 0)return a.to_address();throw new Error(`Address: ${t} doesn't belong to this account.`)}static resolveKeys(e,t,r){if(typeof r=="string"){const c=st.decrypt(r,t);return Qs(c,e)}const n=st.decrypt(r[0],t),a=st.decrypt(r[1],t);return{paymentKey:i.PrivateKey.from_hex(n),stakeKey:i.PrivateKey.from_hex(a)}}static resolveSigners(e,t,r){const n=l=>{const p=(T,Q=[],R=0)=>{var O,M,W,Z,D;if(T===void 0||R>=T.len())return Q;const X=T.get(R),$=new Array;switch(X.kind()){case i.CertificateKind.StakeDeregistration:{const F=(O=X.as_stake_deregistration())==null?void 0:O.stake_credential(),q=(F==null?void 0:F.kind())===i.StakeCredKind.Key?F.to_keyhash():void 0;q&&$.push(q.to_hex());break}case i.CertificateKind.StakeDelegation:{const F=(M=X.as_stake_delegation())==null?void 0:M.stake_credential(),q=(F==null?void 0:F.kind())===i.StakeCredKind.Key?F.to_keyhash():void 0;q&&$.push(q.to_hex());break}case i.CertificateKind.PoolRegistration:{const F=(W=X.as_pool_registration())==null?void 0:W.pool_params().pool_owners();$.push(...C(F));break}case i.CertificateKind.PoolRetirement:{const F=(Z=X.as_pool_retirement())==null?void 0:Z.pool_keyhash();F&&$.push(F.to_hex());break}case i.CertificateKind.MoveInstantaneousRewardsCert:{const F=(D=X.as_move_instantaneous_rewards_cert())==null?void 0:D.move_instantaneous_reward().as_to_stake_creds();if(F)for(let q=0;q<F.len();q+=1){const J=F.keys().get(q),nt=J.kind()===i.StakeCredKind.Key?J.to_keyhash():void 0;nt&&$.push(nt.to_hex())}break}}return p(T,[...Q,...$],R+1)},A=(T,Q=[],R=0)=>{if(T===void 0||R>=T.len())return Q;const X=T.get(R).index(),$=T.get(R).transaction_id(),O=t.find(M=>M.input.outputIndex===X&&M.input.txHash===$.to_hex())!==void 0?r:"OUR_PRINCESS_IS_IN_ANOTHER_CASTLE";return A(T,[...Q,O],R+1)},C=(T,Q=[],R=0)=>T===void 0||R>=T.len()?Q:C(T,[...Q,T.get(R).to_hex()],R+1),E=(T,Q=[],R=0)=>{if(T===void 0||R>=T.len())return Q;const X=T.keys().get(R).payment_cred(),$=X.kind()===i.StakeCredKind.Key?X.to_keyhash():void 0;return E(T,$?[...Q,$.to_hex()]:Q,R+1)},w=l.certs(),b=l.collateral(),P=l.inputs(),k=l.required_signers(),N=l.withdrawals();return[...p(w),...A(b),...A(P),...C(k),...E(N)]},a=l=>{const p=(C,E=[])=>{var w,b,P,k;if(C)for(let N=0;N<C.len();N+=1){const T=C.get(N);switch(T.kind()){case i.NativeScriptKind.ScriptPubkey:{const Q=(w=T.as_script_pubkey())==null?void 0:w.addr_keyhash().to_hex();return Q?[...E,Q]:E}case i.NativeScriptKind.ScriptAll:return p((b=T.as_script_all())==null?void 0:b.native_scripts(),E);case i.NativeScriptKind.ScriptAny:return p((P=T.as_script_any())==null?void 0:P.native_scripts(),E);case i.NativeScriptKind.ScriptNOfK:return p((k=T.as_script_n_of_k())==null?void 0:k.native_scripts(),E)}}return E},A=l.native_scripts();return[...p(A)]},c=It(e);return new Set([...n(c.body()),...a(c.witness_set())])}}const pt="MARI0TIME";class mn{_fetcher;_submitter;_wallet;constructor(e){switch(this._fetcher=e.fetcher,this._submitter=e.submitter,e.key.type){case"mnemonic":this._wallet=new st(e.networkId,st.encryptMnemonic(e.key.words,pt));break;case"root":this._wallet=new st(e.networkId,st.encryptPrivateKey(e.key.bech32,pt));break;case"cli":this._wallet=new st(e.networkId,st.encryptSigningKeys(e.key.payment,e.key.stake??"f0".repeat(34),pt))}}getBaseAddress(e=0){return this._wallet.getAccount(e,pt).baseAddress}getPaymentAddress(e=0){return this._wallet.getAccount(e,pt).enterpriseAddress}getRewardAddress(e=0){return this._wallet.getAccount(e,pt).rewardAddress}getUsedAddress(e=0){const t=this._wallet.getAccount(e,pt);return _t(t.enterpriseAddress)}getUsedCollateral(e=gt.maxCollateralInputs){throw new Error("getUsedCollateral not implemented.")}async getUsedUTxOs(e=0){const t=this._wallet.getAccount(e,pt);return(await this._fetcher.fetchAddressUTxOs(t.enterpriseAddress)).map(n=>wt(n))}signData(e,t,r=0){try{return this._wallet.signData(r,pt,e,t)}catch(n){throw new Error(`[AppWallet] An error occurred during signData: ${n}.`)}}async signTx(e,t=!1,r=0){try{const n=this._wallet.getAccount(r,pt),a=await this._fetcher.fetchAddressUTxOs(n.enterpriseAddress),c=this._wallet.signTx(r,pt,a,e,t),l=It(e),p=l.witness_set(),A=Oe(p,c);return p.set_vkeys(A),i.Transaction.new(l.body(),p,l.auxiliary_data()).to_hex()}catch(n){throw new Error(`[AppWallet] An error occurred during signTx: ${n}.`)}}async signTxs(e,t){return console.log("unimplemented",e,t),[]}submitTx(e){return this._submitter.submitTx(e)}static brew(e=256){return st.generateMnemonic(e)}}class Ie{_walletInstance;walletInstance;constructor(e){this._walletInstance=e,this.walletInstance={...e}}static getInstalledWallets(){return window.cardano===void 0?[]:$e.filter(e=>window.cardano[e]!==void 0).map(e=>({name:window.cardano[e].name,icon:window.cardano[e].icon,version:window.cardano[e].apiVersion}))}static async enable(e){try{const t=await Ie.resolveInstance(e);if(t!==void 0)return new Ie(t);throw new Error(`Couldn't create an instance of wallet: ${e}`)}catch(t){throw new Error(`[BrowserWallet] An error occurred during enable: ${JSON.stringify(t)}.`)}}async getBalance(){const e=await this._walletInstance.getBalance();return Ur(Os(e))}async getChangeAddress(){const e=await this._walletInstance.getChangeAddress();return Lt(e).to_bech32()}async getCollateral(e=gt.maxCollateralInputs){return(await this.getUsedCollateral(e)).map(r=>pe(r))}getNetworkId(){return this._walletInstance.getNetworkId()}async getRewardAddresses(){return(await this._walletInstance.getRewardAddresses()).map(t=>Lt(t).to_bech32())}async getUnusedAddresses(){return(await this._walletInstance.getUnusedAddresses()).map(t=>Lt(t).to_bech32())}async getUsedAddresses(){return(await this._walletInstance.getUsedAddresses()).map(t=>Lt(t).to_bech32())}async getUtxos(e=void 0){return(await this.getUsedUTxOs(e)).map(r=>pe(r))}signData(e,t){const r=_t(e).to_hex();return this._walletInstance.signData(r,ct(t))}async signTx(e,t=!1){try{const r=It(e),n=r.witness_set(),a=await this._walletInstance.signTx(e,t),c=ur(a).vkeys()??i.Vkeywitnesses.new(),l=Oe(n,c);return n.set_vkeys(l),dt(i.Transaction.new(r.body(),n,r.auxiliary_data()).to_bytes())}catch(r){throw new Error(`[BrowserWallet] An error occurred during signTx: ${JSON.stringify(r)}.`)}}async signTxs(e,t=!1){const r=await this._walletInstance.signTxs(e,t),n=[];for(let a=0;a<r.length;a++){const c=It(e[a]),l=c.witness_set(),p=ur(r[a]).vkeys()??i.Vkeywitnesses.new(),A=Oe(l,p);l.set_vkeys(A);const C=dt(i.Transaction.new(c.body(),l,c.auxiliary_data()).to_bytes());n.push(C)}return n}submitTx(e){return this._walletInstance.submitTx(e)}async getUsedAddress(){const e=await this._walletInstance.getUsedAddresses();return Lt(e[0])}async getUsedCollateral(e=gt.maxCollateralInputs){return(await this._walletInstance.experimental.getCollateral()??[]).map(r=>cr(r)).slice(0,e)}async getUsedUTxOs(e=void 0){const t=e?Qt(e).to_hex():void 0;return(await this._walletInstance.getUtxos(t)??[]).map(n=>cr(n))}async getAssets(){return(await this.getBalance()).filter(t=>t.unit!=="lovelace").map(t=>{const r=t.unit.slice(0,Bt),n=t.unit.slice(Bt),a=Mr(r,n);return{unit:t.unit,policyId:r,assetName:qe(n),fingerprint:a,quantity:t.quantity}})}async getLovelace(){const t=(await this.getBalance()).find(r=>r.unit==="lovelace");return t!==void 0?t.quantity:"0"}async getPolicyIdAssets(e){return(await this.getAssets()).filter(r=>r.policyId===e)}async getPolicyIds(){const e=await this.getBalance();return Array.from(new Set(e.map(t=>t.unit.slice(0,Bt)))).filter(t=>t!=="lovelace")}static resolveInstance(e){if(window.cardano===void 0)return;const t=$e.map(r=>window.cardano[r]).filter(r=>r!==void 0).find(r=>r.name.toLowerCase()===e.toLowerCase());return t==null?void 0:t.enable()}}exports.AppWallet=mn;exports.BlockfrostProvider=Xs;exports.BrowserWallet=Ie;exports.EmbeddedWallet=st;exports.ForgeScript=nn;exports.InfuraProvider=Zs;exports.KoiosProvider=tn;exports.MaestroProvider=sn;exports.MeshTxBuilder=gn;exports.OgmiosProvider=en;exports.TangoProvider=rn;exports.checkSignature=ns;exports.generateNonce=Ws;exports.isNetwork=Ar;exports.keepRelevant=pr;exports.largestFirst=Jr;exports.largestFirstMultiAsset=Ir;exports.parseAssetUnit=kt;exports.parseHttpError=S;exports.readPlutusData=js;exports.readTransaction=Js;exports.resolveDataHash=Hs;exports.resolveEpochNo=Fs;exports.resolveFingerprint=Mr;exports.resolveLanguageView=Rs;exports.resolveNativeScriptHash=qs;exports.resolvePaymentKeyHash=qt;exports.resolvePlutusScriptAddress=Vs;exports.resolvePlutusScriptHash=Ls;exports.resolvePoolId=Gs;exports.resolvePrivateKey=Ys;exports.resolveRewardAddress=ie;exports.resolveScriptRef=$s;exports.resolveSlotNo=zs;exports.resolveStakeKeyHash=Yt;exports.resolveTxFees=Ve;exports.resolveTxHash=Kr;
|