@wormhole-foundation/wormhole-connect 3.0.1-beta.2-development → 3.0.1-beta.4-development
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/assets/{add-CA46SOZ1.js → add-Xg1xhVFF.js} +1 -1
- package/dist/assets/{all-wallets-B1qnLkOo.js → all-wallets-BoxRqCuD.js} +1 -1
- package/dist/assets/{app-store-NTpCK9MF.js → app-store-DWw_7TVB.js} +1 -1
- package/dist/assets/{apple-DRVt4JWr.js → apple-C3S_oS38.js} +1 -1
- package/dist/assets/{aptos-DkSiRwPH.js → aptos-BuLH7jck.js} +3 -3
- package/dist/assets/{aptos-63ExGocu.js → aptos-gb8snog6.js} +1 -1
- package/dist/assets/{arrow-bottom-CPth9tFV.js → arrow-bottom-TxaXdcXE.js} +1 -1
- package/dist/assets/{arrow-bottom-circle-BWo9DWoB.js → arrow-bottom-circle-zT0TMjGz.js} +1 -1
- package/dist/assets/{arrow-left-P6RmBJWT.js → arrow-left-DEymMKEb.js} +1 -1
- package/dist/assets/{arrow-right-BHHiE7kD.js → arrow-right-CrQ93Gth.js} +1 -1
- package/dist/assets/{arrow-top-D5GRFsZm.js → arrow-top-DO6PV0os.js} +1 -1
- package/dist/assets/{bank-C2WLfHR8.js → bank-D6rx1mBK.js} +1 -1
- package/dist/assets/{basic-BCJkH5GS.js → basic-C5fzEsEe.js} +1 -1
- package/dist/assets/{blake2b-Bb1VZYtg.js → blake2b-B2b685Yu.js} +1 -1
- package/dist/assets/{browser-BPjT1bN5.js → browser-Co04W0I6.js} +1 -1
- package/dist/assets/{card-JaBku5Bf.js → card-B2Z4mK1Z.js} +1 -1
- package/dist/assets/{ccip-CTrUg8DF.js → ccip-By49zU3M.js} +1 -1
- package/dist/assets/{chain-DF9mIQM9.js → chain-Du7paeNG.js} +1 -1
- package/dist/assets/{checkmark-BQL5JCw2.js → checkmark-C8HU5fja.js} +1 -1
- package/dist/assets/{checkmark-bold-DP1vE2RN.js → checkmark-bold-DIs1ZMqP.js} +1 -1
- package/dist/assets/{chevron-bottom-BV0Au0hP.js → chevron-bottom-BFsapVx9.js} +1 -1
- package/dist/assets/{chevron-left-C4v6Iui8.js → chevron-left-Fkdkr5ZY.js} +1 -1
- package/dist/assets/{chevron-right-CbVMuuvx.js → chevron-right-BfpUZvuC.js} +1 -1
- package/dist/assets/{chevron-top-CuIo_USv.js → chevron-top-CgQu63-4.js} +1 -1
- package/dist/assets/{chrome-store-fbydRQd1.js → chrome-store-GIO26gYx.js} +1 -1
- package/dist/assets/{chunk-KJH4KKG6-B7DCZZVY.js → chunk-KJH4KKG6-Po5MChR6.js} +1 -1
- package/dist/assets/{clock-D62L3EFP.js → clock-BDzvQcXR.js} +1 -1
- package/dist/assets/{close-BLRqO6Zn.js → close-JWa5ANIE.js} +1 -1
- package/dist/assets/{coinPlaceholder-0tmFvYYj.js → coinPlaceholder-a0UGO8gJ.js} +1 -1
- package/dist/assets/{compass-Ba8-RKca.js → compass-CEQdAwHs.js} +1 -1
- package/dist/assets/{contract-bGGxC9_m.js → contract-BhySpM-Z.js} +1 -1
- package/dist/assets/{copy-CWqrh_sD.js → copy-S_d5_yPl.js} +1 -1
- package/dist/assets/{create-CbRd6EbF.js → create-gkOVonha.js} +1 -1
- package/dist/assets/{cursor-DFYzmUAe.js → cursor-BhEbcCXK.js} +1 -1
- package/dist/assets/{cursor-transparent-IY3fA7aT.js → cursor-transparent-BcLVDVWp.js} +1 -1
- package/dist/assets/{desktop-DLudyYW3.js → desktop-DqSryZUj.js} +1 -1
- package/dist/assets/{disconnect-gShcPNrf.js → disconnect-YOsS0M4y.js} +1 -1
- package/dist/assets/{discord-S8T3fJF7.js → discord-CqeqTfSo.js} +1 -1
- package/dist/assets/{etherscan-C-ODOYjC.js → etherscan-DlH7X_ye.js} +1 -1
- package/dist/assets/{evm-DwqzhXfk.js → evm-CWAxZ2a7.js} +3 -3
- package/dist/assets/{evm-D65l_VUA.js → evm-fcQsoqVd.js} +4 -4
- package/dist/assets/{exclamation-triangle-I4hrUAkj.js → exclamation-triangle-B7tI_-cI.js} +1 -1
- package/dist/assets/{extension-C2E94rju.js → extension-DyHQJuRO.js} +1 -1
- package/dist/assets/{external-link-BE25aYRx.js → external-link-ChiVtGCq.js} +1 -1
- package/dist/assets/{facebook-VHvsuzqv.js → facebook-BIe7nERx.js} +1 -1
- package/dist/assets/{farcaster-sG7oFC35.js → farcaster-BTyklWGz.js} +1 -1
- package/dist/assets/{filters-D9VcvmFo.js → filters-De_gO5iz.js} +1 -1
- package/dist/assets/{github-BLJyKdzw.js → github-DQfZjMbN.js} +1 -1
- package/dist/assets/{google-C4YbBNSv.js → google-Gguig8Cy.js} +1 -1
- package/dist/assets/{help-circle-CMmVaOnp.js → help-circle-DHeCCsr1.js} +1 -1
- package/dist/assets/{id-g_mC9xVi.js → id-DjntBhAt.js} +1 -1
- package/dist/assets/{image-nAeKstDS.js → image-2J0s_97c.js} +1 -1
- package/dist/assets/{index-CKPf-3Vo.js → index--d0JCrsI.js} +1 -1
- package/dist/assets/{index-C0-WLpMA.js → index-BE55BSK7.js} +1 -1
- package/dist/assets/{index-Cu0b-jgK.js → index-BJYqkXUw.js} +1 -1
- package/dist/assets/{index-C_YTupmk.js → index-BYTZG2bF.js} +1 -1
- package/dist/assets/{index-CVqQ68io.js → index-BedU_k3i.js} +1 -1
- package/dist/assets/{index-BTkoFKAW.js → index-BgLBca6k.js} +1 -1
- package/dist/assets/{index-DynC8vQ4.js → index-BjvqCh5g.js} +1 -1
- package/dist/assets/{index-BqLA4xTj.js → index-BpI-Jtyb.js} +3 -3
- package/dist/assets/{index-GmuqTVr0.js → index-Breet2G4.js} +1 -1
- package/dist/assets/{index-BUtdFAj3.js → index-Bx8vjRmV.js} +1 -1
- package/dist/assets/{index-DusYxt7C.js → index-CfdmPAak.js} +3 -3
- package/dist/assets/{index-DA4wR-ie.js → index-DB7g9m_R.js} +1 -1
- package/dist/assets/{index-DKdokzug.js → index-DMWfYwZZ.js} +1 -1
- package/dist/assets/{index-COZ2cSR6.js → index-DSTd1tRp.js} +1 -1
- package/dist/assets/{index-CVqXQiSE.js → index-DZ96gAj4.js} +1 -1
- package/dist/assets/{index-CYFq9U58.js → index-TYicGq2L.js} +1 -1
- package/dist/assets/index-Z3Xir6L3.js +1 -0
- package/dist/assets/{index-DC3x_AFd.js → index-kF0xEQ0E.js} +1 -1
- package/dist/assets/{index-CCOXtJ1P.js → index-zEIfo2_n.js} +1 -1
- package/dist/assets/index.es-3Tq6bjFW.js +47 -0
- package/dist/assets/index.es-CBqWEk7T.js +15 -0
- package/dist/assets/{info-P71aU507.js → info-D4MdYH3E.js} +1 -1
- package/dist/assets/{info-circle-D8ZhpY4M.js → info-circle-2o2Bq9RM.js} +1 -1
- package/dist/assets/{lightbulb-CWL8Hapk.js → lightbulb-G1HZSu_o.js} +1 -1
- package/dist/assets/{mail-BKdMRnR2.js → mail-CYPzgN-C.js} +1 -1
- package/dist/assets/{mobile-Bw0EoBkW.js → mobile-G3tO8xk-.js} +1 -1
- package/dist/assets/{more-BSKGQd1b.js → more-nk1W6LmK.js} +1 -1
- package/dist/assets/{network-placeholder-B1xqyidN.js → network-placeholder-DakjB3wH.js} +1 -1
- package/dist/assets/{nftPlaceholder-CuCsNvkN.js → nftPlaceholder-JMholGYC.js} +1 -1
- package/dist/assets/{off-BX6zoZuA.js → off-SNO-Bsmr.js} +1 -1
- package/dist/assets/{play-store-CCveEK_B.js → play-store-BpxDB0NB.js} +1 -1
- package/dist/assets/{plus-C02SGp4V.js → plus-oY5qI4Lq.js} +1 -1
- package/dist/assets/{provider-jsonrpc-DTnJKzTS.js → provider-jsonrpc-CG-x8-V6.js} +1 -1
- package/dist/assets/{qr-code-DGe_aS_i.js → qr-code-jee4rxaz.js} +1 -1
- package/dist/assets/{recycle-horizontal-DtRomJbx.js → recycle-horizontal-BEF6XBYh.js} +1 -1
- package/dist/assets/{refresh-DPABcpes.js → refresh-aEpBxujB.js} +1 -1
- package/dist/assets/{reown-logo-DG2ULLka.js → reown-logo-CEo-n5QW.js} +1 -1
- package/dist/assets/{search-EURxday_.js → search-CrfJGGMS.js} +1 -1
- package/dist/assets/{secp256k1-D-G9AbtW.js → secp256k1-CBh6eQLF.js} +1 -1
- package/dist/assets/{secp256k1-DfnLU_Rr.js → secp256k1-OI4v3wvK.js} +1 -1
- package/dist/assets/{send-t6aoH9GB.js → send-ChU6l1_w.js} +1 -1
- package/dist/assets/signer-BRan8q4C.js +2 -0
- package/dist/assets/solana-B3bc0p0T.js +2 -0
- package/dist/assets/{solana-C-diloCa.js → solana-CxgaSoPj.js} +9 -9
- package/dist/assets/solanaEmbed.esm-Mnq6o_qa.js +10 -0
- package/dist/assets/{sui-Pc10JTxL.js → sui-CXoaI0gx.js} +2 -2
- package/dist/assets/{sui-DXg2Lhyt.js → sui-DXdm7DBB.js} +4 -4
- package/dist/assets/{swapHorizontal-Cd2Bq-oX.js → swapHorizontal-De2aXFHG.js} +1 -1
- package/dist/assets/{swapHorizontalBold-CK6YXqcD.js → swapHorizontalBold-CtwNUoVl.js} +1 -1
- package/dist/assets/{swapHorizontalMedium-BCT4Hlrg.js → swapHorizontalMedium-BsH9NNRL.js} +1 -1
- package/dist/assets/{swapHorizontalRoundedBold-C-NDd7Fq.js → swapHorizontalRoundedBold-ClK2_MrS.js} +1 -1
- package/dist/assets/{swapVertical-BfKszPb9.js → swapVertical-BVWoUs-p.js} +1 -1
- package/dist/assets/{telegram-D5sYoBZp.js → telegram-BgYefK90.js} +1 -1
- package/dist/assets/{three-dots-qiTqAG0h.js → three-dots-D6JqA1P-.js} +1 -1
- package/dist/assets/{tokens-BjeNFBPV.js → tokens-BwBlXmY1.js} +12 -12
- package/dist/assets/{twitch-1VH6BaUA.js → twitch-DSLx5P08.js} +1 -1
- package/dist/assets/{twitterIcon-hIEIDwcz.js → twitterIcon-DIhMC7Ie.js} +1 -1
- package/dist/assets/{verify-DxvRt34f.js → verify-Dh3yUwPE.js} +1 -1
- package/dist/assets/{verify-filled-RtidYdgS.js → verify-filled-mA5B8sgV.js} +1 -1
- package/dist/assets/{w3m-modal-DI_ypCY0.js → w3m-modal-DpvEw1mA.js} +1 -1
- package/dist/assets/{wallet-Cb9kcAk9.js → wallet-Bz3DYndO.js} +1 -1
- package/dist/assets/{wallet-placeholder-pTFD8Qr_.js → wallet-placeholder-BYYYxJZ1.js} +1 -1
- package/dist/assets/{walletconnect-DvJIx5jD.js → walletconnect-NKbhveni.js} +1 -1
- package/dist/assets/{warning-circle-CRzNiBlj.js → warning-circle-Dh13B0js.js} +1 -1
- package/dist/assets/{x-Dk-mK5uZ.js → x-B2DeHGEp.js} +1 -1
- package/dist/main.js +75 -75
- package/dist/src/config/index.d.ts.map +1 -1
- package/dist/src/config/tokens.d.ts +2 -2
- package/dist/src/config/tokens.d.ts.map +1 -1
- package/dist/src/config/types.d.ts +2 -0
- package/dist/src/config/types.d.ts.map +1 -1
- package/dist/src/utils/inProgressTxCache.d.ts.map +1 -1
- package/lib/{add-DrLWWjDN.mjs → add-CChCYI2G.mjs} +1 -1
- package/lib/{add-DVGSYBJf.js → add-CDVX1evr.js} +1 -1
- package/lib/{all-wallets-CjzZMHCA.mjs → all-wallets-D2JZa1Jx.mjs} +1 -1
- package/lib/{all-wallets-DGVJQYa0.js → all-wallets-Wql6lmNE.js} +1 -1
- package/lib/{app-store-BABxSxrd.js → app-store-1dBCl4tM.js} +1 -1
- package/lib/{app-store-kpf503GR.mjs → app-store-CLDcpqR0.mjs} +1 -1
- package/lib/{apple-C962M6Ax.js → apple-BHKwlbOf.js} +1 -1
- package/lib/{apple-C0AtBJDu.mjs → apple-DIxTUQFy.mjs} +1 -1
- package/lib/{aptos-uWJCRLoQ.js → aptos-BL0wRMvV.js} +1 -1
- package/lib/{aptos-XxQj_uxF.mjs → aptos-TAzFliq5.mjs} +1 -1
- package/lib/{arrow-bottom-D0wK6uMJ.mjs → arrow-bottom-BI4NLoaY.mjs} +1 -1
- package/lib/{arrow-bottom-circle-iOl-NxXR.js → arrow-bottom-circle-CAq7o5Oy.js} +1 -1
- package/lib/{arrow-bottom-circle-D5QwftYY.mjs → arrow-bottom-circle-HmnccP7v.mjs} +1 -1
- package/lib/{arrow-bottom-CIZJcZfr.js → arrow-bottom-lsBwXKtD.js} +1 -1
- package/lib/{arrow-left-BL0dHjzy.mjs → arrow-left-7ur69wUu.mjs} +1 -1
- package/lib/{arrow-left-C-RAtnQ2.js → arrow-left-BsQ-5Ptc.js} +1 -1
- package/lib/{arrow-right-COiq03Wj.js → arrow-right-D992kYZk.js} +1 -1
- package/lib/{arrow-right-DaZMOW_1.mjs → arrow-right-lENdnq4k.mjs} +1 -1
- package/lib/{arrow-top-7Srj2XLP.js → arrow-top-BO-2RkYj.js} +1 -1
- package/lib/{arrow-top-QPVhK81o.mjs → arrow-top-mSzeb_YL.mjs} +1 -1
- package/lib/{bank-C5lNHVtL.mjs → bank-CoEWKxhi.mjs} +1 -1
- package/lib/{bank-Bp2l8LtZ.js → bank-Hw0j97F3.js} +1 -1
- package/lib/{basic-C5W71-rE.mjs → basic-BaSePtpQ.mjs} +2 -2
- package/lib/{basic-DQ6ISwhI.js → basic-C2cAlU_P.js} +1 -1
- package/lib/{browser-DV0hL_fK.js → browser-BlvoS4as.js} +1 -1
- package/lib/{browser-CJhUYmz6.mjs → browser-rF5Wrb7Q.mjs} +1 -1
- package/lib/{card-yZLq1X6c.js → card-BMnXbbhN.js} +1 -1
- package/lib/{card-DSeabGLV.mjs → card-D_WE8NXm.mjs} +1 -1
- package/lib/{ccip-BCsOYNZd.js → ccip--ZxEFQf_.js} +1 -1
- package/lib/{ccip-CFqlillN.mjs → ccip-CqL9Anaf.mjs} +1 -1
- package/lib/{checkmark-BW4NeFlB.js → checkmark-CesSNUet.js} +1 -1
- package/lib/{checkmark-DhgNpDof.mjs → checkmark-OMVwQQ5U.mjs} +1 -1
- package/lib/{checkmark-bold-DnEFF9eL.js → checkmark-bold-BD-XO987.js} +1 -1
- package/lib/{checkmark-bold-CxJkyUOt.mjs → checkmark-bold-CD7QLi07.mjs} +1 -1
- package/lib/{chevron-bottom-Pi9qTSKk.mjs → chevron-bottom-BwVLFe30.mjs} +1 -1
- package/lib/{chevron-bottom-Tb5GYU7P.js → chevron-bottom-IMKe9YXA.js} +1 -1
- package/lib/{chevron-left-BRp6K_BQ.js → chevron-left-D9qVH2_2.js} +1 -1
- package/lib/{chevron-left-Cl35pkRv.mjs → chevron-left-Lf-ywM2h.mjs} +1 -1
- package/lib/{chevron-right-D1Ic6C28.js → chevron-right-WKiLOYc0.js} +1 -1
- package/lib/{chevron-right-pjH-xKxB.mjs → chevron-right-gRQ8_S61.mjs} +1 -1
- package/lib/{chevron-top-SdyRa8IE.js → chevron-top-Bxo7EgbN.js} +1 -1
- package/lib/{chevron-top-DSe-dX8z.mjs → chevron-top-DslLIugK.mjs} +1 -1
- package/lib/{chrome-store-0qgfQSAS.js → chrome-store-7358vPCZ.js} +1 -1
- package/lib/{chrome-store-ThoUGIhl.mjs → chrome-store-B7rWxuFe.mjs} +1 -1
- package/lib/{clock-B0sBEXQ5.mjs → clock-BGtDjqYb.mjs} +1 -1
- package/lib/{clock-2HqPHolX.js → clock-Ry96ruDh.js} +1 -1
- package/lib/{close-Bznv5frT.mjs → close-Bj7xcq2I.mjs} +1 -1
- package/lib/{close-BJQf5USo.js → close-C6sBVa0R.js} +1 -1
- package/lib/{coinPlaceholder-CvvSiYI-.js → coinPlaceholder-9HCA6YJ_.js} +1 -1
- package/lib/{coinPlaceholder-1gZoTAqN.mjs → coinPlaceholder-CUWHPX6Q.mjs} +1 -1
- package/lib/{compass-BE99mJOV.mjs → compass-B6RLv5bP.mjs} +1 -1
- package/lib/{compass-BBMA-82e.js → compass-CccZJ5Hi.js} +1 -1
- package/lib/{constants-Bp_337ur.mjs → constants-I50X20ow.mjs} +1 -1
- package/lib/{constants-BDS32jve.js → constants-o93Ip-ZI.js} +1 -1
- package/lib/{copy-B_JboG8P.js → copy-CQDBtuRc.js} +1 -1
- package/lib/{copy-Cwolsgnk.mjs → copy-ucy3iRHw.mjs} +1 -1
- package/lib/{cursor-C2jyr1Tt.js → cursor-CSvFFh4Q.js} +1 -1
- package/lib/{cursor-0EyS6nH4.mjs → cursor-CzBbQiJe.mjs} +1 -1
- package/lib/{cursor-transparent-ZUI7NwAo.mjs → cursor-transparent-BVPzLo6n.mjs} +1 -1
- package/lib/{cursor-transparent-BaVE19A2.js → cursor-transparent-OMlVLjL8.js} +1 -1
- package/lib/{desktop-Dmz61Quh.js → desktop-CPDPdHBV.js} +1 -1
- package/lib/{desktop-B1U1mc6q.mjs → desktop-shQ2mQoL.mjs} +1 -1
- package/lib/{disconnect-8HUMogEY.mjs → disconnect-BKVkn-S7.mjs} +1 -1
- package/lib/{disconnect-Bn_0Td6c.js → disconnect-DGSddjKW.js} +1 -1
- package/lib/{discord-4tBuPwio.js → discord-748YGKmQ.js} +1 -1
- package/lib/{discord-DNMu-4pj.mjs → discord-CU-xUnfX.mjs} +1 -1
- package/lib/{etherscan-DTafkFM9.mjs → etherscan-6_ieSOxb.mjs} +1 -1
- package/lib/{etherscan-CdfpxSFw.js → etherscan-Ccpuewtf.js} +1 -1
- package/lib/{evm-B5SS0axR.mjs → evm-DfM6aIHd.mjs} +3 -3
- package/lib/{evm-BZKMUp6E.js → evm-DoAUqshZ.js} +3 -3
- package/lib/{exclamation-triangle-BLb5RCv9.mjs → exclamation-triangle-B1yodgmL.mjs} +1 -1
- package/lib/{exclamation-triangle-W8wr4W3B.js → exclamation-triangle-BcTwNgcS.js} +1 -1
- package/lib/{extension-B3rp6j3f.js → extension-BwMlRm6l.js} +1 -1
- package/lib/{extension-DqXaH5V_.mjs → extension-CpR0U7JU.mjs} +1 -1
- package/lib/{external-link-DWSOPcgR.js → external-link-CSvt1sJd.js} +1 -1
- package/lib/{external-link-DupOMQca.mjs → external-link-D5LlQVjF.mjs} +1 -1
- package/lib/{facebook-C25qgXgI.mjs → facebook-Ch2fWEDP.mjs} +1 -1
- package/lib/{facebook-gaoSLwmV.js → facebook-DKN-SwlC.js} +1 -1
- package/lib/{farcaster-BKQVbYft.mjs → farcaster-CuhYu7xL.mjs} +1 -1
- package/lib/{farcaster-Dw_KFzSe.js → farcaster-Eo6frWYn.js} +1 -1
- package/lib/{filters-BSv2GVWx.js → filters-D8RfIYLp.js} +1 -1
- package/lib/{filters-BRj-u8fO.mjs → filters-hN9hAmqt.mjs} +1 -1
- package/lib/{github-CVSqx81G.js → github-Bj11sR8O.js} +1 -1
- package/lib/{github-B8zYv5B1.mjs → github-CBnfKu_p.mjs} +1 -1
- package/lib/{google-CJy4jhj7.mjs → google-DkNw7izD.mjs} +1 -1
- package/lib/{google-DWyFM_-_.js → google-ocyOtxA8.js} +1 -1
- package/lib/{help-circle-D2kyGnMD.mjs → help-circle-BYF3SQ07.mjs} +1 -1
- package/lib/{help-circle-BihX0QHp.js → help-circle-DIUT7rfs.js} +1 -1
- package/lib/hosted.js +1 -1
- package/lib/hosted.mjs +1 -1
- package/lib/{id-BvDoX2i7.mjs → id-C70TM1mY.mjs} +1 -1
- package/lib/{id-ZWI-bwNJ.js → id-CFPGVN7x.js} +1 -1
- package/lib/{image-CNQTgOF8.js → image-Csb5_nLh.js} +1 -1
- package/lib/{image-BeWwKKKj.mjs → image-N27_sf6L.mjs} +1 -1
- package/lib/{index-BXBTU3I5.mjs → index-BJokM0dj.mjs} +78 -78
- package/lib/{index-Dpl42t-y.mjs → index-BQI4s97M.mjs} +19199 -19189
- package/lib/index-CtU_yCFR.js +304 -0
- package/lib/{index-D2yjOpeA.js → index-DPTquT8S.js} +2 -2
- package/lib/{index.es-BvsB6Z8q.js → index.es-B-_H_cmu.js} +1 -1
- package/lib/{index.es-C4KG3MSj.mjs → index.es-DJiOqF7x.mjs} +1 -1
- package/lib/{index.es-C2112Y2b.js → index.es-WjSz4osV.js} +1 -1
- package/lib/{index.es-Cy_oFTNH.mjs → index.es-s7TRhhGL.mjs} +3 -3
- package/lib/index.js +1 -1
- package/lib/index.mjs +1 -1
- package/lib/{info-CjKZyXW_.mjs → info-AQVHCGaq.mjs} +1 -1
- package/lib/{info-C73QOiqc.js → info-CxmLliqa.js} +1 -1
- package/lib/{info-circle-DE-EmffO.js → info-circle-D2JXCfNS.js} +1 -1
- package/lib/{info-circle-CEpS6rzX.mjs → info-circle-y2TMBRYb.mjs} +1 -1
- package/lib/{lightbulb-BVq3C-EG.mjs → lightbulb-BKSrtaqH.mjs} +1 -1
- package/lib/{lightbulb-Dm6Hsfd3.js → lightbulb-BbhqbK_X.js} +1 -1
- package/lib/{mail-CqUQETIH.mjs → mail-BBgJ1r1U.mjs} +1 -1
- package/lib/{mail-GRon9tbg.js → mail-CoY6lTNd.js} +1 -1
- package/lib/{mobile-BmGmHmVh.js → mobile-Bctu3ihf.js} +1 -1
- package/lib/{mobile-CEbEFp0X.mjs → mobile-DNfcwXIc.mjs} +1 -1
- package/lib/{more-CnS-NcGa.js → more--vfXH0mk.js} +1 -1
- package/lib/{more-Cs0cmKvd.mjs → more-CH7etA30.mjs} +1 -1
- package/lib/{network-placeholder-CjPyqfGa.js → network-placeholder-6HdYNIFM.js} +1 -1
- package/lib/{network-placeholder-DYuB36S0.mjs → network-placeholder-ChGkSHiE.mjs} +1 -1
- package/lib/{nftPlaceholder-COJmgjQo.mjs → nftPlaceholder-BEC17VTi.mjs} +1 -1
- package/lib/{nftPlaceholder-CoY2NOAz.js → nftPlaceholder-CFV32cdU.js} +1 -1
- package/lib/{off-CZo3LYgL.mjs → off-ClkoZEBq.mjs} +1 -1
- package/lib/{off-B-WmBPpa.js → off-lYX-5yS0.js} +1 -1
- package/lib/{play-store-Chciiwp3.js → play-store-BG47IOEu.js} +1 -1
- package/lib/{play-store-Edmxg3AX.mjs → play-store-CkhMEAU7.mjs} +1 -1
- package/lib/{plus-D2jFkgs1.mjs → plus-BtTwbs2C.mjs} +1 -1
- package/lib/{plus-C93OSdaz.js → plus-DrlcozYb.js} +1 -1
- package/lib/{qr-code-c2tFySK0.mjs → qr-code-DYJJwRSj.mjs} +1 -1
- package/lib/{qr-code-y78Lk8wE.js → qr-code-v9_pM0Zk.js} +1 -1
- package/lib/{recycle-horizontal-PXk9BX3j.js → recycle-horizontal-BvzP-O-1.js} +1 -1
- package/lib/{recycle-horizontal-CWycpdDF.mjs → recycle-horizontal-EBM2ypKZ.mjs} +1 -1
- package/lib/{refresh-C77_db2T.mjs → refresh-BAhwdZGm.mjs} +1 -1
- package/lib/{refresh-mky0B17c.js → refresh-TpfixFZn.js} +1 -1
- package/lib/{reown-logo-0RkEf9EI.mjs → reown-logo-B0Su0Ter.mjs} +1 -1
- package/lib/{reown-logo-DceXhK36.js → reown-logo-DU1oKeQq.js} +1 -1
- package/lib/{search-BrMSW1-8.mjs → search-BPQ2hivJ.mjs} +1 -1
- package/lib/{search-CWru3218.js → search-Dmv7gbQ1.js} +1 -1
- package/lib/{secp256k1-C4P0dmMC.mjs → secp256k1-BZs3Z9mj.mjs} +1 -1
- package/lib/{secp256k1-BU-UfBCB.js → secp256k1-BjuZX5cP.js} +1 -1
- package/lib/{secp256k1-Cks0bicH.js → secp256k1-CLJ0hFH7.js} +1 -1
- package/lib/{secp256k1-CI3_SM8F.mjs → secp256k1-CtFVBB1y.mjs} +1 -1
- package/lib/{send-CRyBVD1k.js → send-BD36uDqC.js} +1 -1
- package/lib/{send-DFkvxnIh.mjs → send-BtmBm7An.mjs} +1 -1
- package/lib/{solana-BVnMWq13.js → solana-BCCsr1Cx.js} +4 -4
- package/lib/{solana-L02hbBDE.mjs → solana-CJwReM-9.mjs} +6 -6
- package/lib/{solanaEmbed.esm-DSwNdsgx.mjs → solanaEmbed.esm-DUeK0Aox.mjs} +1 -1
- package/lib/{solanaEmbed.esm-BG5cgKub.js → solanaEmbed.esm-TlHPGYbs.js} +1 -1
- package/lib/src/config/index.d.ts.map +1 -1
- package/lib/src/config/tokens.d.ts +2 -2
- package/lib/src/config/tokens.d.ts.map +1 -1
- package/lib/src/config/types.d.ts +2 -0
- package/lib/src/config/types.d.ts.map +1 -1
- package/lib/src/utils/inProgressTxCache.d.ts.map +1 -1
- package/lib/{sui-Dv1p0XoG.js → sui-CfpeqXfu.js} +1 -1
- package/lib/{sui-CN1tZAOs.mjs → sui-DCDjGAGw.mjs} +1 -1
- package/lib/{swapHorizontal-Bo_-2U6j.mjs → swapHorizontal-BrAMZxpk.mjs} +1 -1
- package/lib/{swapHorizontal-BiCkAPre.js → swapHorizontal-zZA0Pi1S.js} +1 -1
- package/lib/{swapHorizontalBold-BPL2XaSi.mjs → swapHorizontalBold-BcMCprxV.mjs} +1 -1
- package/lib/{swapHorizontalBold-CWHbSIEu.js → swapHorizontalBold-DiN_RSP7.js} +1 -1
- package/lib/{swapHorizontalMedium-CTsDFfzR.mjs → swapHorizontalMedium-BJ2Ste5L.mjs} +1 -1
- package/lib/{swapHorizontalMedium-D_2Z2Hfq.js → swapHorizontalMedium-CoOVPZkR.js} +1 -1
- package/lib/{swapHorizontalRoundedBold-8b5z2YJ_.mjs → swapHorizontalRoundedBold-Cjf3Fskk.mjs} +1 -1
- package/lib/{swapHorizontalRoundedBold-CDKFFagj.js → swapHorizontalRoundedBold-DxwvY3dz.js} +1 -1
- package/lib/{swapVertical-CNBatiM6.js → swapVertical-Bq0Lj7Jp.js} +1 -1
- package/lib/{swapVertical-UTCgpnIJ.mjs → swapVertical-p6z9y9EP.mjs} +1 -1
- package/lib/{telegram-lTj0r5My.js → telegram-dLc4G7r4.js} +1 -1
- package/lib/{telegram-CVvlgH_Z.mjs → telegram-ejEcBbcF.mjs} +1 -1
- package/lib/{three-dots-KK4NyvR7.mjs → three-dots-DaVRiDOk.mjs} +1 -1
- package/lib/{three-dots-DQLgK82o.js → three-dots-d_UVr-9U.js} +1 -1
- package/lib/{tokens-B2pmB4Ph.js → tokens-BWrHpkNL.js} +1 -1
- package/lib/{tokens-BQHmitaT.mjs → tokens-BnimC1zF.mjs} +1 -1
- package/lib/{twitch-CO4nmS5o.mjs → twitch-BHisrkgo.mjs} +1 -1
- package/lib/{twitch-wV3Yc6kA.js → twitch-C8keHWlC.js} +1 -1
- package/lib/{twitterIcon-pCNPPny7.js → twitterIcon-BQcavToi.js} +1 -1
- package/lib/{twitterIcon-BU99IvD2.mjs → twitterIcon-D3iLXIw6.mjs} +1 -1
- package/lib/{verify-Ci9XMhb8.mjs → verify-BWBTB_1a.mjs} +1 -1
- package/lib/{verify-B21LHiy7.js → verify-CXgbYH0A.js} +1 -1
- package/lib/{verify-filled-LUtqUhbS.mjs → verify-filled-D-Ce24N1.mjs} +1 -1
- package/lib/{verify-filled-DCMcHuAt.js → verify-filled-EtgRJyXw.js} +1 -1
- package/lib/{w3m-modal-DJRTg4Aa.js → w3m-modal-BRD-3_ln.js} +1 -1
- package/lib/{w3m-modal-BJkuxcj8.mjs → w3m-modal-jJj4CHrQ.mjs} +2 -2
- package/lib/{wallet-BqBebKQF.js → wallet-D5GlthNd.js} +1 -1
- package/lib/{wallet-USpq1vKL.mjs → wallet-D9nn7VuJ.mjs} +1 -1
- package/lib/{wallet-placeholder-CL_evZUb.mjs → wallet-placeholder-Bdm8Ey5Z.mjs} +1 -1
- package/lib/{wallet-placeholder-Cf1u-2wB.js → wallet-placeholder-CHDzAL0k.js} +1 -1
- package/lib/{walletconnect-Da6ZdP8w.js → walletconnect-CAKGYqr_.js} +1 -1
- package/lib/{walletconnect-3g5k3agX.mjs → walletconnect-DbTFPVUf.mjs} +1 -1
- package/lib/{warning-circle-B3ivLfCN.mjs → warning-circle-BNb3asEb.mjs} +1 -1
- package/lib/{warning-circle-CvTdOy7u.js → warning-circle-CQo0cKjW.js} +1 -1
- package/lib/{x-BOwtJrlH.mjs → x-35IydjAH.mjs} +1 -1
- package/lib/{x-DQCRmr2P.js → x-BeRG8E5j.js} +1 -1
- package/package.json +1 -1
- package/dist/assets/index-BZFyhaji.js +0 -1
- package/dist/assets/index.es-CWMLsIMc.js +0 -47
- package/dist/assets/index.es-g5_0R3zE.js +0 -15
- package/dist/assets/signer-7-tpWjBV.js +0 -2
- package/dist/assets/solana-C6mHMmQi.js +0 -2
- package/dist/assets/solanaEmbed.esm-DhAz8SOB.js +0 -10
- package/lib/index-DwMMfwYI.js +0 -304
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";var pb=Object.defineProperty;var gb=(s,e,t)=>e in s?pb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var vt=(s,e,t)=>gb(s,typeof e!="symbol"?e+"":e,t);const N=require("./address-DKM11kf_.js"),te=require("./index-DwMMfwYI.js"),fb=require("./util-G2vxTeU2.js"),mb=require("./wallets-5qGJd8Hk.js"),Rl=require("./unsignedTransaction-BwT180qj.js"),$u=require("./signer-D-HjSIgq.js"),E=require("./index-Cjz6EL9G.js"),m=require("./index.es-BvsB6Z8q.js");require("./browser-ponyfill-UnUv8h3i.js");class Tt extends Error{constructor(e,t){super(e),this.error=t}}class Ti extends Tt{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class wb extends Tt{constructor(){super(...arguments),this.name="WalletLoadError"}}class ln extends Tt{constructor(){super(...arguments),this.name="WalletConfigError"}}class fc extends Tt{constructor(){super(...arguments),this.name="WalletConnectionError"}}class Rf extends Tt{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class zo extends Tt{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class vs extends Tt{constructor(){super(...arguments),this.name="WalletAccountError"}}class dr extends Tt{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class Fe extends Tt{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class Gi extends Tt{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class Je extends Tt{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class Fo extends Tt{constructor(){super(...arguments),this.name="WalletSignMessageError"}}class Pu extends Tt{constructor(){super(...arguments),this.name="WalletSignInError"}}class yb extends Tt{constructor(){super(...arguments),this.name="WalletWindowClosedError"}}var ae;(function(s){s.Installed="Installed",s.NotDetected="NotDetected",s.Loadable="Loadable",s.Unsupported="Unsupported"})(ae||(ae={}));class Uf extends N.EventEmitter{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,i={}){const r=this.publicKey;if(!r)throw new Fe;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:i.preflightCommitment,minContextSlot:i.minContextSlot})).blockhash,e}}function qo(s){if(typeof window>"u"||typeof document>"u")return;const e=[];function t(){if(s())for(const n of e)n()}const i=setInterval(t,1e3);e.push(()=>clearInterval(i)),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",t,{once:!0}),e.push(()=>document.removeEventListener("DOMContentLoaded",t))),document.readyState!=="complete"&&(window.addEventListener("load",t,{once:!0}),e.push(()=>window.removeEventListener("load",t))),t()}function si(s){return"version"in s}class Wh extends Uf{async sendTransaction(e,t,i={}){let r=!0;try{if(si(e)){if(!this.supportedTransactionVersions)throw new Gi("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new Gi(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);const n=e.serialize();return await t.sendRawTransaction(n,i)}catch(n){throw n instanceof Je?(r=!1,n):new Gi(n==null?void 0:n.message,n)}}else try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),e=await this.signTransaction(e);const a=e.serialize();return await t.sendRawTransaction(a,o)}catch(n){throw n instanceof Je?(r=!1,n):new Gi(n==null?void 0:n.message,n)}}catch(n){throw r&&this.emit("error",n),n}}async signAllTransactions(e){for(const i of e)if(si(i)){if(!this.supportedTransactionVersions)throw new Je("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(i.version))throw new Je(`Signing transaction version ${i.version} isn't supported by this wallet`)}const t=[];for(const i of e)t.push(await this.signTransaction(i));return t}}class Bo extends Wh{}const yi="solana:signAndSendTransaction",jc="solana:signIn",Dn="solana:signMessage",St="solana:signTransaction",Lf="standard:connect",Tu="standard:disconnect",zf="standard:events";function bb(s){return Lf in s.features&&zf in s.features&&(yi in s.features||St in s.features)}var _o;(function(s){s.Mainnet="mainnet-beta",s.Testnet="testnet",s.Devnet="devnet"})(_o||(_o={}));const vb="Bitget";class Ib extends Bo{constructor(e={}){super(),this.name=vb,this.url="https://web3.bitget.com",this.icon="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIHdpZHRoPSIyNTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxmaWx0ZXIgaWQ9ImEiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBoZWlnaHQ9IjQ1MS40MzEiIHdpZHRoPSI1NjkuNTU4IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiPjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+PGZlQmxlbmQgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiBtb2RlPSJub3JtYWwiIHJlc3VsdD0ic2hhcGUiLz48ZmVHYXVzc2lhbkJsdXIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIgc3RkRGV2aWF0aW9uPSI0OS4yMzA4Ii8+PC9maWx0ZXI+PGZpbHRlciBpZD0iYiIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGhlaWdodD0iMzcxLjUwNyIgd2lkdGg9IjM1MS41OTYiIHg9Ii0xNjAuNTExIiB5PSItMTY1Ljk4NyI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJjIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSI0MjQuNDUyIiB3aWR0aD0iNDQ0Ljg1MSIgeD0iLTI0MS4wNzgiIHk9IjY3LjY0MiI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJkIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSIzODUuMTA1IiB3aWR0aD0iNDMwLjE5MSIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4Ij48ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPjxmZUJsZW5kIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgbW9kZT0ibm9ybWFsIiByZXN1bHQ9InNoYXBlIi8+PGZlR2F1c3NpYW5CbHVyIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIvPjwvZmlsdGVyPjxjbGlwUGF0aCBpZD0iZSI+PHBhdGggZD0ibTAgMGgyNTZ2MjU2aC0yNTZ6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjZSkiPjxwYXRoIGQ9Im0wIDBoMjU2djI1NmgtMjU2eiIgZmlsbD0iIzU0ZmZmNSIvPjxnIGZpbHRlcj0idXJsKCNhKSI+PHBhdGggZD0ibTEzLjQ4MDYgMTk4LjYwNWMtNDIuODA4MiAxMjAuNDM4IDE4Ni4xODA0IDg2LjQyMiAzMDYuMDI2NCA1NC4zNTkgMTIyLjY1OC00MC43MDUgMzcuODc5LTIyMC4xMzcxLTUwLjA5Mi0yMjQuMTA4Mi04Ny45NzItMy45NzExIDEwLjkwNyA4Mi45NjgyLTYzLjgyIDEwNy44MDAyLTc0LjcyNyAyNC44MzEtMTM4LjYwNDMtODguNTk3Ny0xOTIuMTE0NCA2MS45NDl6IiBmaWxsPSIjZmZmIi8+PC9nPjxnIGZpbHRlcj0idXJsKCNiKSI+PHBhdGggZD0ibTg1LjUxMTgtNDUuODIyNWMtMjIuNDU1Ni02MS4zNTM1LTEwMi40MzA3IDIxLjgyNzItMTM5LjYxMTMgNzEuMDg2OC0zNS40NjU3IDUzLjU4MzYgNTcuMTA4ODcgOTkuODg3NyA5My40MjAzIDc0Ljc3MjcgMzYuMzExNS0yNS4xMTQzLTMxLjU0NjMyLTMwLjAwMDctOS45NS02Mi42NTg1IDIxLjU5NjMtMzIuNjU3NzQgODQuMjEwMi02LjUwOSA1Ni4xNDEtODMuMjAxeiIgZmlsbD0iIzAwZmZmMCIgZmlsbC1vcGFjaXR5PSIuNjciLz48L2c+PGcgZmlsdGVyPSJ1cmwoI2MpIj48cGF0aCBkPSJtOTYuNDc5NiAyMjUuNDI0Yy0zMC42Mjk0LTEwMy4wNjEtMTYyLjU2MTQtNDguNzg3LTIyNC42OTg2LTguNzY3LTU5Ljc3MSA0Ny4zODUgODIuMTQ3OSAxODMuNjkxIDE0MS4wOTE1IDE3Ni43MTkgNTguOTQzNi02Ljk3My00Ny4yODQzLTY2LjMxMS0xMC44ODU0OC05NS4yMDYgMzYuMzk4NzgtMjguODk0IDEzMi43Nzg5OCA1Ni4wNzkgOTQuNDkyNTgtNzIuNzQ2eiIgZmlsbD0iIzlkODFmZiIvPjwvZz48ZyBmaWx0ZXI9InVybCgjZCkiPjxwYXRoIGQ9Im0yODIuMTItMTA3LjM1M2MtNjYuMDczLTc4LjY3OC0xNjAuNjU3LTEzLjYxNy0xOTkuNjkwNCAyOC43NDgzLTM0LjE1NTcgNDcuOTYwMSAxNDEuODQ1NCAxMzUuODM1OSAxOTAuNjkxNCAxMjAuNzc2MSA0OC44NDctMTUuMDU5OS02Ni42MDktNDYuMjIxNzgtNDUuODI0LTc1LjQ1OTMgMjAuNzg1LTI5LjIzNzYgMTM3LjQxNSAyNC4yODIyNCA1NC44MjMtNzQuMDY1MXoiIGZpbGw9IiM0ZDk0ZmYiLz48L2c+PHBhdGggY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtOTMuMTg5IDE1Mi44MzZoNDMuNDg1bC00OS40NjU0LTQ5Ljc4NSA1MC4xMDE0LTQ5Ljc4NDcgMTMuNjQ1LTEzLjI2NjNoLTQ1LjEzNmwtNTcuNDgzMSA1Ny43NzczYy0yLjkwMSAyLjkxMTctMi44ODYxIDcuNjI0Ny4wMjk3IDEwLjUyMTd6bTI2LjE0MS00OS42NjhoLS4zMzVsLjMzMS0uMDA0em0wIDAgNDkuNDYxIDQ5Ljc4MS01MC4xMDEgNDkuNzg1LTEzLjY0NSAxMy4yNjZoNDUuMTM1bDU3LjQ4NC01Ny43NzRjMi45MDEtMi45MTIgMi44ODYtNy42MjQtLjAzLTEwLjUyMWwtNDQuODIzLTQ0LjUzN3oiIGZpbGw9IiMwMDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>{var t,i;return(i=(t=window.bitkeep)==null?void 0:t.solana)!=null&&i.isBitKeep?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.bitkeep.solana;let t;try{t=await e.getAccount()}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new zo(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{const{signature:i}=await t.signMessage(e);return i}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Eb="Clover";class Ab extends Bo{constructor(e={}){super(),this.name=Eb,this.url="https://clv.org",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTM2LjQ4IDBIMTEuNTJDNS4xNTc2OCAwIDAgNS4xNTc2OCAwIDExLjUyVjM2LjQ4QzAgNDIuODQyMyA1LjE1NzY4IDQ4IDExLjUyIDQ4SDM2LjQ4QzQyLjg0MjMgNDggNDggNDIuODQyMyA0OCAzNi40OFYxMS41MkM0OCA1LjE1NzY4IDQyLjg0MjMgMCAzNi40OCAwWiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzc5MTBfMTYzMzUxKSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTI0LjAwMDYgMzkuMzYwNkMzMi40ODM3IDM5LjM2MDYgMzkuMzYwNiAzMi40ODM3IDM5LjM2MDYgMjQuMDAwNkMzOS4zNjA2IDE1LjUxNzUgMzIuNDgzNyA4LjY0MDYyIDI0LjAwMDYgOC42NDA2MkMxNS41MTc1IDguNjQwNjIgOC42NDA2MiAxNS41MTc1IDguNjQwNjIgMjQuMDAwNkM4LjY0MDYyIDMyLjQ4MzcgMTUuNTE3NSAzOS4zNjA2IDI0LjAwMDYgMzkuMzYwNlpNMjEuMjg5OSAxNS44Njg4SDI2LjcxMVYyMS4zNDdIMjEuMjkwNFYyNi42NTRIMjYuNzExVjMyLjEzMjJIMjEuMjg5OVYyNi44MjUySDE1Ljg2OTNWMjEuMzQ3SDIxLjI4OTlWMTUuODY4OFpNMjYuNzEyIDIxLjM0N0gzMi4xMzMxVjI2LjgyNTJIMjYuNzEyVjIxLjM0N1oiIGZpbGw9ImJsYWNrIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNzkxMF8xNjMzNTEiIHgxPSI0OCIgeTE9Ii0xLjQzMDUxZS0wNiIgeDI9IjEuNDMwNTFlLTA2IiB5Mj0iNDgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0E5RkZFMCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM4NkQ1RkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>{var t;return(t=window.clover_solana)!=null&&t.isCloverWallet?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.clover_solana;let t;try{t=await e.getAccount()}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{const{signature:i}=await t.signMessage(e);return Uint8Array.from(i)}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Nb(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var _b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Rc=Nb(_b),Cb="Coin98";class Sb extends Bo{constructor(e={}){super(),this.name=Cb,this.url="https://coin98.com",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3NiA3NSI+CiAgPGRlZnM+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIxMDEuNjgxJSIgeDI9Ii0xLjU1NyUiIHkxPSIxNS4yNjglIiB5Mj0iODQuOTE3JSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNGMUQ5NjEiLz4KICAgICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjQ0RBMTQ2Ii8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogIDwvZGVmcz4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPHJlY3Qgd2lkdGg9Ijc1IiBoZWlnaHQ9Ijc1IiBmaWxsPSIjMDAwIiByeD0iMTYiLz4KICAgIDxwYXRoIGZpbGw9InVybCgjYSkiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYxLjQ0IDBhMTMuNzE0IDEzLjcxNCAwIDAgMSA5LjY4IDQuMDEgMTMuNjYxIDEzLjY2MSAwIDAgMSA0LjAwOCA5LjY2OHY0Ny42NDZhMTMuNjYgMTMuNjYgMCAwIDEtNC4wMDcgOS42NjZBMTMuNzEzIDEzLjcxMyAwIDAgMSA2MS40NCA3NUgxMy42ODZhMTMuNzEzIDEzLjcxMyAwIDAgMS05LjY4LTQuMDFBMTMuNjYgMTMuNjYgMCAwIDEgMCA2MS4zMjRWMTMuNjc4YzAtMy42MjUgMS40NC03LjEwMiA0LjAwNy05LjY2N0ExMy43MTQgMTMuNzE0IDAgMCAxIDEzLjY4NyAwWk0yMC4wNjMgNDYuMjMxaC00LjgyNWExMC4wMzIgMTAuMDMyIDAgMCAwIDIuOTQ2IDcuMDg2IDEwLjA3IDEwLjA3IDAgMCAwIDcuMSAyLjk0MiAxMC4wNjUgMTAuMDY1IDAgMCAwIDcuMTA4LTIuOTM1IDEwLjAzIDEwLjAzIDAgMCAwIDIuOTQ2LTcuMDkzaC00LjgyNGE1LjIwNyA1LjIwNyAwIDAgMS0xLjUzIDMuNjg4IDUuMjI1IDUuMjI1IDAgMCAxLTMuNjk2IDEuNTI4IDUuMjM0IDUuMjM0IDAgMCAxLTMuNjk1LTEuNTI4IDUuMjEzIDUuMjEzIDAgMCAxLTEuNTMtMy42ODhaTTU0LjMzIDMzLjcxNmExMS43NjMgMTEuNzYzIDAgMCAwLTEyLjc5OSAyLjUzOEExMS42OTcgMTEuNjk3IDAgMCAwIDM4Ljk5IDQ5LjAzYTExLjcyMyAxMS43MjMgMCAwIDAgNC4zMjggNS4yNTkgMTEuNzU3IDExLjc1NyAwIDAgMCA2LjUyNiAxLjk3IDExLjc2NiAxMS43NjYgMCAwIDAgOC4yOS0zLjQzNSAxMS43MiAxMS43MiAwIDAgMCAzLjQ0Mi04LjI3NCAxMS43MDIgMTEuNzAyIDAgMCAwLTEuOTc1LTYuNTE0IDExLjczNiAxMS43MzYgMCAwIDAtNS4yNjktNC4zMlptLTQuNDg4IDMuOTJhNi45MzcgNi45MzcgMCAwIDEgNC45IDIuMDI1IDYuOTEgNi45MSAwIDAgMSAyLjAyOCA0Ljg5MiA2Ljg5NyA2Ljg5NyAwIDAgMS0xLjE3IDMuODM0IDYuOTMyIDYuOTMyIDAgMCAxLTEwLjY0MyAxLjA0MiA2LjkwMiA2LjkwMiAwIDAgMS0xLjUtNy41MjIgNi45MDkgNi45MDkgMCAwIDEgMi41NDQtMy4xIDYuOTI4IDYuOTI4IDAgMCAxIDMuODQxLTEuMTY3Wm0uMTcgNC41NTJhMi40MzEgMi40MzEgMCAwIDAtMi4yNDEgMS4xNTQgMi40MTggMi40MTggMCAwIDAtLjM1NiAxLjI1NyAyLjM5NSAyLjM5NSAwIDAgMCAxLjYxOSAyLjI5djEuNzUzaDEuNjE4di0xLjc1NGEyLjQyNyAyLjQyNyAwIDAgMCAxLjU5NC0xLjk1IDIuNDE4IDIuNDE4IDAgMCAwLTEtMi4zMSAyLjQzMSAyLjQzMSAwIDAgMC0xLjIzNC0uNDRabS0yMC4yMi0yMi41NTJhMTEuNzYyIDExLjc2MiAwIDAgMC0xMi43OTYgMi41MzEgMTEuNjk3IDExLjY5NyAwIDAgMC0yLjU1NCAxMi43NjkgMTEuNzIzIDExLjcyMyAwIDAgMCA0LjMyIDUuMjYyIDExLjc1NyAxMS43NTcgMCAwIDAgMTQuODI1LTEuNDQ2IDExLjcxNyAxMS43MTcgMCAwIDAgMy40NDUtOC4yODQgMTEuNzAzIDExLjcwMyAwIDAgMC0xLjk3NC02LjUxMiAxMS43MzYgMTEuNzM2IDAgMCAwLTUuMjY2LTQuMzJabS00LjUxIDMuOTE3YTYuOTQ1IDYuOTQ1IDAgMCAxIDQuODk3IDIuMDI5IDYuOTE4IDYuOTE4IDAgMCAxIDIuMDMyIDQuODg2IDYuOTA2IDYuOTA2IDAgMCAxLTEuMTY4IDMuODQyIDYuOTQgNi45NCAwIDAgMS0xMC42NiAxLjA0OCA2LjkxMSA2LjkxMSAwIDAgMS0xLjUtNy41MzYgNi45MTggNi45MTggMCAwIDEgMi41NS0zLjEwMyA2LjkzNyA2LjkzNyAwIDAgMSAzLjg1LTEuMTY2Wm0yNC41Ni00LjgxYTEwLjA1OSAxMC4wNTkgMCAwIDAtNy4xMDMgMi45NCAxMC4wMiAxMC4wMiAwIDAgMC0yLjk0IDcuMDkgOS45IDkuOSAwIDAgMCAxLjIzIDQuNzk1IDEzLjU3NSAxMy41NzUgMCAwIDEgNC4yMTQtMi4zMjIgNS4wODIgNS4wODIgMCAwIDEtLjYyNS0yLjQ3NyA1LjIwNiA1LjIwNiAwIDAgMSAxLjUwMy0zLjczNiA1LjIyMyA1LjIyMyAwIDAgMSAzLjcyMi0xLjU1NCA1LjIzNCA1LjIzNCAwIDAgMSAzLjcyIDEuNTU0IDUuMjEzIDUuMjEzIDAgMCAxIDEuNTA1IDMuNzM2IDUuMjc5IDUuMjc5IDAgMCAxLS42MjMgMi40NzMgMTMuNTc0IDEzLjU3NCAwIDAgMSA0LjIxMyAyLjMyMiA5LjkwMyA5LjkwMyAwIDAgMCAxLjIzLTQuNzk1IDEwLjAzMiAxMC4wMzIgMCAwIDAtMi45NDYtNy4wODYgMTAuMDcgMTAuMDcgMCAwIDAtNy4xLTIuOTRabS0yMy43NSA3Ljk5aC0xLjYxN3YxLjc1YTIuNDE5IDIuNDE5IDAgMCAwLTEuNTgyIDIuNjg3IDIuNDE0IDIuNDE0IDAgMCAwIDIuMzkgMi4wMDYgMi40NSAyLjQ1IDAgMCAwIDEuNTU1LS41NzQgMi40MTQgMi40MTQgMCAwIDAtLjc0Ni00LjExOXYtMS43NVoiLz4KICA8L2c+Cjwvc3ZnPgo=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>{var t;return(t=window.coin98)!=null&&t.sol?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isConnected())}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.coin98.sol;let t;try{t=(await e.connect())[0]}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new zo(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{const i=await t.request({method:"sol_sign",params:[e]}),r=new N.PublicKey(i.publicKey),n=Rc.decode(i.signature);return e.addSignature(r,N.dist.Buffer.from(n)),e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{const i=await t.request({method:"sol_signAllTransactions",params:[e]}),r=new N.PublicKey(i.publicKey),n=i.signatures;return e.map((o,a)=>{const l=Rc.decode(n[a]);return o.addSignature(r,N.dist.Buffer.from(l)),o})}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{const i=await t.request({method:"sol_signMessage",params:[e]});return Rc.decode(i.signature)}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const $b="Nightly";class Pb extends Bo{constructor(){super(),this.name=$b,this.url="https://nightly.app",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHZpZXdCb3g9IjAgMCA5NiA5NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4IDk2Qzc0LjUwOTcgOTYgOTYgNzQuNTA5NyA5NiA0OEM5NiAyMS40OTAzIDc0LjUwOTcgMCA0OCAwQzIxLjQ5MDMgMCAwIDIxLjQ5MDMgMCA0OEMwIDc0LjUwOTcgMjEuNDkwMyA5NiA0OCA5NloiIGZpbGw9IiM2RDczRjgiLz4KPHBhdGggZD0iTTQ4IDg1LjYzNTZDNDggODUuNjM1NiA1Mi40NTMzIDg1LjYzNTYgNTUuNDQgODIuNTg2N0M1OC45MTU1IDc5LjI4MDEgNTcuMzUxMSA3NS40MzEyIDYyLjI3NTUgNzEuNDMxMkM2Ni45ODY2IDY3LjY0NDUgNzIuOTI0NCA3MC4zMzc5IDcyLjkyNDQgNzAuMzM3OUM3Ny4wMjIyIDYyLjEyNDUgNzQuNzkxMSA1Mi41NjkgNzQuNzkxMSA1Mi41NjlDODEuNzY4OCAzNC4yNTc5IDc1Ljk2NDQgMjEuMTU1NyA3NC40NDQ0IDE3LjM2MDFDNjkuNDQ4OCAyNC4zMzc5IDYzLjE5MTEgMjkuMTczNCA1NS43OTU1IDMyLjQwOUM1My4yMjY2IDMxLjcwNjggNTAuNTk1NSAzMS4zMzM0IDQ4IDMxLjM2MDFDNDUuNDEzMyAzMS4zMzM0IDQyLjc3MzMgMzEuNzA2OCA0MC4yMDQ0IDMyLjQwOUMzMi44MTc3IDI5LjE2NDUgMjYuNTUxMSAyNC4zMzc5IDIxLjU1NTUgMTcuMzYwMUMyMC4wMzU1IDIxLjE1NTcgMTQuMjMxMSAzNC4yNTc5IDIxLjIwODkgNTIuNTY5QzIxLjIwODkgNTIuNTY5IDE4Ljk3NzggNjIuMTI0NSAyMy4wNzU1IDcwLjMzNzlDMjMuMDc1NSA3MC4zMzc5IDI5LjAxMzMgNjcuNjQ0NSAzMy43MjQ0IDcxLjQzMTJDMzguNjU3NyA3NS40MzEyIDM3LjA4NDQgNzkuMjgwMSA0MC41NiA4Mi41ODY3QzQzLjU0NjYgODUuNjM1NiA0OCA4NS42MzU2IDQ4IDg1LjYzNTZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNDIuNDc5OSA2NS4yOThDNDIuMjkzMyA1OS4yMTggMzYuMzAyMSA1Ny4yNjI0IDMyLjIxMzMgNTkuODIyNEMzMi4yMTMzIDU5LjgyMjQgMzIuODUzMyA2Mi40MzU4IDM1LjgzOTkgNjMuNzUxM0MzOC4yNzU1IDY0LjgyNjkgMzkuMzI0NCA2My4zODY5IDQyLjQ3OTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNMjIuNDk3NyAyMy4wOTM1QzIwLjA4ODggMzEuNTQ2OCAyMS4xMjg4IDQyLjI0MDIgMjQuOTMzMyA1MC4wMjY5QzI4LjgyNjYgNDcuMjcxMyAzMi45MTU1IDQzLjAxMzUgMzUuMDkzMyAzOC41MDY5QzI5Ljk2NDQgMzQuNzExMyAyNS42NjIyIDMxLjEwMjQgMjIuNDk3NyAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNTMuNTE5OSA2NS4yOThDNTMuNzA2NiA1OS4yMTggNTkuNjk3NyA1Ny4yNjI0IDYzLjc4NjYgNTkuODIyNEM2My43ODY2IDU5LjgyMjQgNjMuMTQ2NiA2Mi40MzU4IDYwLjE1OTkgNjMuNzUxM0M1Ny43MjQzIDY0LjgyNjkgNTYuNjc1NSA2My4zODY5IDUzLjUxOTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNzMuNTAyMiAyMy4wOTM1Qzc1LjkxMTEgMzEuNTQ2OCA3NC44NzExIDQyLjI0MDIgNzEuMDY2NiA1MC4wMjY5QzY3LjE3MzMgNDcuMjcxMyA2My4wODQ0IDQzLjAxMzUgNjAuOTA2NiAzOC41MDY5QzY2LjAzNTUgMzQuNzExMyA3MC4zMzc3IDMxLjEwMjQgNzMuNTAyMiAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNDcuOTk5OSA4NS4zMDY5QzUwLjE0MDQgODUuMzA2OSA1MS44NzU1IDgzLjc3ODcgNTEuODc1NSA4MS44OTM2QzUxLjg3NTUgODAuMDA4NCA1MC4xNDA0IDc4LjQ4MDIgNDcuOTk5OSA3OC40ODAyQzQ1Ljg1OTUgNzguNDgwMiA0NC4xMjQ0IDgwLjAwODQgNDQuMTI0NCA4MS44OTM2QzQ0LjEyNDQgODMuNzc4NyA0NS44NTk1IDg1LjMwNjkgNDcuOTk5OSA4NS4zMDY5WiIgZmlsbD0iIzdCODFGOSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._publicKey=null,this._wallet=null,this._readyState!==ae.Unsupported&&qo(()=>{var e;return(e=window==null?void 0:window.nightly)!=null&&e.solana?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get connecting(){return this._connecting}get readyState(){return this._readyState}get publicKey(){return this._publicKey}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.nightly.solana;try{await e.connect()}catch(i){throw new fc(i==null?void 0:i.message,i)}if(e.publicKey.toString()==="11111111111111111111111111111111")throw new vs;let t;try{t=new N.PublicKey(e.publicKey.toBytes())}catch(i){throw new dr(i==null?void 0:i.message,i)}this._wallet=e,this._publicKey=t,this.emit("connect",t)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch{this.emit("error",new Rf)}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{return t.signMessage(new TextDecoder().decode(e))}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Mu="solana:mainnet",Tb="solana:devnet",Mb="solana:testnet",xb="solana:localnet",Ob="Solong";class Db extends Wh{constructor(e={}){super(),this.name=Ob,this.url="https://solongwallet.io",this.icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAGlklEQVR4Ae3bA5DsyhfH8TNr49r2/du2bdu2bdu2zcdNrm3b9toz533rvctUn3Umk9p01WfdvVW/6nROBxJVS1rSkpa0pCUtaUlLWtKSpl4VXos3GJ4sujQFuUKfWl+qT730arzB8Ex9YksKcgXjFOCVeIPhBYydB8mawQ+yiGC8n0EN6zAVcgXhpQjoq1DDdsyDAAB9Pwo1HMC9INk0FIM8Bt1Qh9WohQQCvD+BtEMdtmC8I7y5aIE67MV0SBwDvB3qsE/UHwMJIpC/QB1OYiLEEeCPoQ7nMRcSwwDrao3Zl8aTIEGEUYlL0IAMXuQOr66UvsegDm+ExDJAPNiafSg0AlyIbmjAWX1aQzEkiH6T0QkNaEdpnAN8NNRhPcSF9e9el2ebBhyAuNBvGtLQgIuQOAd4D6jDMRQbM3AmOqEBDfq0xjJIEP3GohkakEFVjAP0y401sAsLnAE+pb6EsC5AA9J4sHsG+kX0PQR1eFJ8AwTWQh0+DjFm4a1Qh2/AOoz/BHX4ZdwD/CDU4aioX2GUMW+AOnB2bqiBBDHe86EOTYw5GRKJwQ/ijUM91OGTxgysxSmowzeNw7j08m5DHX4l7Igg2TY0g9hbLBZ+f7oxC98CdWjDvYzD+MVQh07GfEQsZyDgVWA71OGvorfnQQCAcqaYUFZDHW6j/itAoB70GcergzqsEa0rhGTTEA7mP0koK4xdyeOMmvBBhJU2zsjPMw7lu9O3zShpXheHk4hhcZ4w26AOG4RSxDiUfwZ12KdPqy+FBDHeV6EOZxizIg6HsMGbiQ5jdjzBXRfeefGg3tgbv9BYC0fhZE7sjUMY9Pf9rdcI5XtQh39BjBA/C3VYnM0zcgiDek+GOhzh93mQoMs7kIxze/eMhnxIEOPNM9bcFtTEeAb6I419axu/m2CsgxU4Aw1A/UxIUM/bO/9+cVkDDd5x42x8N1iH8Taow0NhHcZLoQ5Pi/MMzDMW+DTu7g6vIY9AdkAdHmaUMyn6roA6PD22AeLB6DbWplHG7LubfY+kfiIkiH5T0AJ1uFtMA1xUzOc1UIclzvCeXF+o7DygDlvds29RgVVzYj+K4xhgEX4NdcjgecE++rSL+ZdLmIxRB77Ose7l4XPIQB3eF8M60C/n8++ghltE/QLIFfqUiyUE8kOoYSW7jmLIFXeN4X0NaajDDlG/NG6XswrxKdxu+G/weh27j3wCej9uN9zEOjc3sObl4S243XBLhDfWE0mAMQjwZfhxDng7pG/8Sj4/ER/Gd/BdfBhPRGW2A/wxNAfcBOnFCHwZZ6GGs/gqapMAb/QEnIT20Uk8IQkQeB7aof3UihcM9wDvhyboANHXv1+IdWBOB2hsIftto+iSPEif8aGPcjrA50GHyPMiOIT9B/N5apaMgQT8D2poxMdwt8s+hkao4X9ZDxBTIdHwy/h8AeqQxhMhAU9BB9ThPMqHTYCYjU6owy3uPstSfL4Z6uZPC+Mk8gOomz8DEg3vXshAHb4MMXwZarhXGDPwa739w2j48623BPAniOFPUMPsMAL8INTw9AgDrLZOCmjFPEjA3WD1aUJVGAG+CGr4ECRCy6GGg3iyaF0+n/PwFByEGpaJ+qkw1sB7QA3/hUTozdBetFymvXhTWGVMOc7bp36/FhKRamNW9dcxZmpZiI+32ad+vAQSoWejGzpAXXh22Fek3wY1rDD2kVnijR3ExYQMPgkJOUB/nFW0Is3vnw6JhlHX9a4N70Iq/ACBv0MNu7J9WxHw7jaA2deFOtw32zeVHtHLWvMN0dtSkOzwS3spYy7iH1hx2d/wYdyTvnkR3BdeQjjerVBDN14JyZIfQWH5RC7e1rw32npZV54LCc+SPD5/HgqYD3WW5+gTqt6X+rA4v0701hRkKF0+bL+HTM9Hgv/MHH60wyvHWigsafwA1ZAhMguLoL34kbDcQEI1uAH8mcbuxPHImf8i5EMGxqvER9EI7cUqVMTl0Y6HoxHaBzvxNkyC9EEe7oEv4Sy0D/YQ+IS4ver1JNT38z7sWnwbb8TT8Cg8Gs/Gu/Ar7EEXtI/2ud7Ni0GAYCbiJDQiazA57k9nTcdqaJb9UtSvitXbmjavCJ9AMzRkJ/B80boUJBLhDe7Nw1/QCR1i9fgKRg6HByzvjZ/hInQQMjiCT2PSMHxC1a/l8wvwGxyG9kEaW/EtPI4xiiE5JcLrd6PxcLwM78SH8EG8Fc/H/UUXVUByGh8SSYBJgEmASYCJJMAkwBi6A3xCqZhiBz8+AAAAAElFTkSuQmCC",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>window.solong?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.currentAccount)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.solong;let t;try{t=await e.selectAccount()}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const kb="Torus";class jb extends Bo{constructor({params:e={showTorusButton:!1}}={params:{showTorusButton:!1}}){super(),this.name=kb,this.url="https://tor.us",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzMiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMyAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYuNSIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzAzNjRGRiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjIxODYgOS40OTIxOUMxMC40NTM5IDkuNDkyMTkgOS44MzM5OCAxMC4xMTIxIDkuODMzOTggMTAuODc2OFYxMi40ODk4QzkuODMzOTggMTMuMjU0NSAxMC40NTM5IDEzLjg3NDQgMTEuMjE4NiAxMy44NzQ0SDEzLjY2ODRWMjIuODk3NkMxMy42Njg0IDIzLjY2MjMgMTQuMjg4MyAyNC4yODIyIDE1LjA1MyAyNC4yODIySDE2LjY2NkMxNy40MzA3IDI0LjI4MjIgMTguMDUwNiAyMy42NjIzIDE4LjA1MDYgMjIuODk3NlYxMi41MDE1QzE4LjA1MDYgMTIuNDk3NiAxOC4wNTA2IDEyLjQ5MzcgMTguMDUwNiAxMi40ODk4VjEwLjg3NjhDMTguMDUwNiAxMC4xMTIxIDE3LjQzMDcgOS40OTIxOSAxNi42NjYgOS40OTIxOUgxNS4wNTNIMTEuMjE4NloiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0yMS4zMzc2IDEzLjg3NDRDMjIuNTQ3NyAxMy44NzQ0IDIzLjUyODcgMTIuODkzNCAyMy41Mjg3IDExLjY4MzNDMjMuNTI4NyAxMC40NzMyIDIyLjU0NzcgOS40OTIxOSAyMS4zMzc2IDkuNDkyMTlDMjAuMTI3NSA5LjQ5MjE5IDE5LjE0NjUgMTAuNDczMiAxOS4xNDY1IDExLjY4MzNDMTkuMTQ2NSAxMi44OTM0IDIwLjEyNzUgMTMuODc0NCAyMS4zMzc2IDEzLjg3NDRaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.Loadable,this._connecting=!1,this._wallet=null,this._publicKey=null,this._params=e}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isLoggedIn)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Loadable)throw new Ti;this._connecting=!0;let e;try{e=(await Promise.resolve().then(()=>require("./solanaEmbed.esm-BG5cgKub.js"))).default}catch(n){throw new wb(n==null?void 0:n.message,n)}let t;try{t=window.torus||new e}catch(n){throw new ln(n==null?void 0:n.message,n)}if(!t.isInitialized)try{await t.init(this._params)}catch(n){throw new fc(n==null?void 0:n.message,n)}let i;try{i=await t.login()}catch(n){throw new vs(n==null?void 0:n.message,n)}let r;try{r=new N.PublicKey(i[0])}catch(n){throw new dr(n==null?void 0:n.message,n)}this._wallet=t,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{e.isLoggedIn&&await e.cleanUp()}catch(t){this.emit("error",new zo(t==null?void 0:t.message,t))}}this.emit("disconnect")}async sendTransaction(e,t,i={}){try{const r=this._wallet;if(!r)throw new Fe;try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),o.preflightCommitment=o.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,o);return a}catch(n){throw n instanceof Tt?n:new Gi(n==null?void 0:n.message,n)}}catch(r){throw this.emit("error",r),r}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signMessage(e)}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Uc(s){switch(s){case"processed":case"confirmed":case"finalized":case void 0:return s;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const Rb="https://api.mainnet-beta.solana.com";function Ub(s){return s.includes(Rb)?Mu:/\bdevnet\b/i.test(s)?Tb:/\btestnet\b/i.test(s)?Mb:/\blocalhost\b/i.test(s)||/\b127\.0\.0\.1\b/.test(s)?xb:Mu}var Ga;(function(s){s.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",s.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",s.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",s.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(Ga||(Ga={}));var ys;(function(s){s.signTransaction="solana_signTransaction",s.signMessage="solana_signMessage",s.signAndSendTransaction="solana_signAndSendTransaction",s.signAndSendAllTransactions="solana_signAndSendAllTransactions",s.signAllTransactions="solana_signAllTransactions"})(ys||(ys={}));const lt={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"};let Lb=class extends m.IEvents{constructor(e){super()}};const xu=E.cjs.FIVE_SECONDS,xs={pulse:"heartbeat_pulse"};let Ff=class qf extends Lb{constructor(e){super(e),this.events=new te.eventsExports.EventEmitter,this.interval=xu,this.interval=(e==null?void 0:e.interval)||xu}static async init(e){const t=new qf(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),E.cjs.toMiliseconds(this.interval))}pulse(){this.events.emit(xs.pulse)}};function zb(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function ft(s,...e){try{return zb(s(...e))}catch(t){return Promise.reject(t)}}function Fb(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function qb(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function Oa(s){if(Fb(s))return String(s);if(qb(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return Oa(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Ul="base64:";function Bb(s){return typeof s=="string"?s:Ul+Vb(s)}function Hb(s){return typeof s!="string"||!s.startsWith(Ul)?s:Wb(s.slice(Ul.length))}function Wb(s){return globalThis.Buffer?N.dist.Buffer.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function Vb(s){return globalThis.Buffer?N.dist.Buffer.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Gt(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function Kb(...s){return Gt(s.join(":"))}function ca(s){return s=Gt(s),s?s+":":""}function Gb(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function Yb(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const Qb="memory",Zb=()=>{const s=new Map;return{name:Qb,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function Jb(s={}){const e={mounts:{"":s.driver||Zb()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(const h of e.mountpoints)if(c.startsWith(h))return{base:h,relativeKey:c.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,h)=>e.mountpoints.filter(u=>u.startsWith(c)||h&&c.startsWith(u)).map(u=>({relativeBase:c.length>u.length?c.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(c,h)=>{if(e.watching){h=Gt(h);for(const u of e.watchListeners)u(c,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const c in e.mounts)e.unwatch[c]=await Ou(e.mounts[c],r,c)}},o=async()=>{if(e.watching){for(const c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},a=(c,h,u)=>{const d=new Map,p=g=>{let f=d.get(g.base);return f||(f={driver:g.driver,base:g.base,items:[]},d.set(g.base,f)),f};for(const g of c){const f=typeof g=="string",b=Gt(f?g:g.key),y=f?void 0:g.value,w=f||!g.options?h:{...h,...g.options},v=t(b);p(v).items.push({key:b,value:y,relativeKey:v.relativeKey,options:w})}return Promise.all([...d.values()].map(g=>u(g))).then(g=>g.flat())},l={hasItem(c,h={}){c=Gt(c);const{relativeKey:u,driver:d}=t(c);return ft(d.hasItem,u,h)},getItem(c,h={}){c=Gt(c);const{relativeKey:u,driver:d}=t(c);return ft(d.getItem,u,h).then(p=>m.destr(p))},getItems(c,h={}){return a(c,h,u=>u.driver.getItems?ft(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(p=>({key:Kb(u.base,p.key),value:m.destr(p.value)}))):Promise.all(u.items.map(d=>ft(u.driver.getItem,d.relativeKey,d.options).then(p=>({key:d.key,value:m.destr(p)})))))},getItemRaw(c,h={}){c=Gt(c);const{relativeKey:u,driver:d}=t(c);return d.getItemRaw?ft(d.getItemRaw,u,h):ft(d.getItem,u,h).then(p=>Hb(p))},async setItem(c,h,u={}){if(h===void 0)return l.removeItem(c);c=Gt(c);const{relativeKey:d,driver:p}=t(c);p.setItem&&(await ft(p.setItem,d,Oa(h),u),p.watch||r("update",c))},async setItems(c,h){await a(c,h,async u=>{if(u.driver.setItems)return ft(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:Oa(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>ft(u.driver.setItem,d.relativeKey,Oa(d.value),d.options)))})},async setItemRaw(c,h,u={}){if(h===void 0)return l.removeItem(c,u);c=Gt(c);const{relativeKey:d,driver:p}=t(c);if(p.setItemRaw)await ft(p.setItemRaw,d,h,u);else if(p.setItem)await ft(p.setItem,d,Bb(h),u);else return;p.watch||r("update",c)},async removeItem(c,h={}){typeof h=="boolean"&&(h={removeMeta:h}),c=Gt(c);const{relativeKey:u,driver:d}=t(c);d.removeItem&&(await ft(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await ft(d.removeItem,u+"$",h),d.watch||r("remove",c))},async getMeta(c,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),c=Gt(c);const{relativeKey:u,driver:d}=t(c),p=Object.create(null);if(d.getMeta&&Object.assign(p,await ft(d.getMeta,u,h)),!h.nativeOnly){const g=await ft(d.getItem,u+"$",h).then(f=>m.destr(f));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(p,g))}return p},setMeta(c,h,u={}){return this.setItem(c+"$",h,u)},removeMeta(c,h={}){return this.removeItem(c+"$",h)},async getKeys(c,h={}){var b;c=ca(c);const u=i(c,!0);let d=[];const p=[];let g=!0;for(const y of u){(b=y.driver.flags)!=null&&b.maxDepth||(g=!1);const w=await ft(y.driver.getKeys,y.relativeBase,h);for(const v of w){const A=y.mountpoint+Gt(v);d.some(C=>A.startsWith(C))||p.push(A)}d=[y.mountpoint,...d.filter(v=>!v.startsWith(y.mountpoint))]}const f=h.maxDepth!==void 0&&!g;return p.filter(y=>(!f||Gb(y,h.maxDepth))&&Yb(y,c))},async clear(c,h={}){c=ca(c),await Promise.all(i(c,!1).map(async u=>{if(u.driver.clear)return ft(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(p=>u.driver.removeItem(p,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>Du(c)))},async watch(c){return await n(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,h){if(c=ca(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[c]=h,e.watching&&Promise.resolve(Ou(h,r,c)).then(u=>{e.unwatch[c]=u}).catch(console.error),l},async unmount(c,h=!0){var u,d;c=ca(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&((d=(u=e.unwatch)[c])==null||d.call(u),delete e.unwatch[c]),h&&await Du(e.mounts[c]),e.mountpoints=e.mountpoints.filter(p=>p!==c),delete e.mounts[c])},getMount(c=""){c=Gt(c)+":";const h=t(c);return{driver:h.driver,base:h.base}},getMounts(c="",h={}){return c=Gt(c),i(c,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(c,h={})=>l.getKeys(c,h),get:(c,h={})=>l.getItem(c,h),set:(c,h,u={})=>l.setItem(c,h,u),has:(c,h={})=>l.hasItem(c,h),del:(c,h={})=>l.removeItem(c,h),remove:(c,h={})=>l.removeItem(c,h)};return l}function Ou(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Du(s){typeof s.dispose=="function"&&await ft(s.dispose)}const Xb="idb-keyval";var ev=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=m.createStore(s.dbName,s.storeName)),{name:Xb,options:s,async hasItem(r){return!(typeof await m.get(t(r),i)>"u")},async getItem(r){return await m.get(t(r),i)??null},setItem(r,n){return m.set(t(r),n,i)},removeItem(r){return m.del(t(r),i)},getKeys(){return m.keys(i)},clear(){return m.clear(i)}}};const tv="WALLET_CONNECT_V2_INDEXED_DB",sv="keyvaluestorage";let iv=class{constructor(){this.indexedDb=Jb({driver:ev({dbName:tv,storeName:sv})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,m.safeJsonStringify(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof N.dist.global<"u"?N.dist.global:typeof self<"u"?self:{},Da={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Lc<"u"&&Lc.localStorage?Da.exports=Lc.localStorage:typeof window<"u"&&window.localStorage?Da.exports=window.localStorage:Da.exports=new e})();function rv(s){var e;return[s[0],m.safeJsonParse((e=s[1])!=null?e:"")]}let nv=class{constructor(){this.localStorage=Da.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(rv)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return m.safeJsonParse(t)}async setItem(e,t){this.localStorage.setItem(e,m.safeJsonStringify(t))}async removeItem(e){this.localStorage.removeItem(e)}};const ov="wc_storage_version",ku=1,av=async(s,e,t)=>{const i=ov,r=await e.getItem(i);if(r&&r>=ku){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const l=a.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const c=await s.getItem(a);await e.setItem(a,c),o.push(a)}}await e.setItem(i,ku),t(e),cv(s,o)},cv=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let lv=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new nv;this.storage=e;try{const t=new iv;av(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var hv=Object.defineProperty,uv=(s,e,t)=>e in s?hv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ju=(s,e,t)=>uv(s,typeof e!="symbol"?e+"":e,t);let dv=class extends m.IEvents{constructor(e){super(),this.opts=e,ju(this,"protocol","wc"),ju(this,"version",2)}};var pv=Object.defineProperty,gv=(s,e,t)=>e in s?pv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,fv=(s,e,t)=>gv(s,e+"",t);let mv=class extends m.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,fv(this,"records",new Map)}},wv=class{constructor(e,t){this.logger=e,this.core=t}},yv=class extends m.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},bv=class extends m.IEvents{constructor(e){super()}},vv=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},Iv=class extends m.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Ev=class extends m.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}},Av=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Nv=class{constructor(e,t){this.projectId=e,this.logger=t}},_v=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};function Co(s,{strict:e=!0}={}){return!s||typeof s!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(s):s.startsWith("0x")}function Ru(s){return Co(s,{strict:!1})?Math.ceil((s.length-2)/2):s.length}const Bf="2.23.2";let kn={getDocsUrl:({docsBaseUrl:s,docsPath:e="",docsSlug:t})=>e?`${s??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${Bf}`},mc=class Ll extends Error{constructor(e,t={}){var a;const i=(()=>{var l;return t.cause instanceof Ll?t.cause.details:(l=t.cause)!=null&&l.message?t.cause.message:t.details})(),r=t.cause instanceof Ll&&t.cause.docsPath||t.docsPath,n=(a=kn.getDocsUrl)==null?void 0:a.call(kn,{...t,docsPath:r}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...kn.version?[`Version: ${kn.version}`]:[]].join(`
|
|
2
|
-
`);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=Bf}walk(e){return Hf(this,e)}};function Hf(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?Hf(s.cause,e):e?null:s}let Wf=class extends mc{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};function _n(s,{dir:e,size:t=32}={}){return typeof s=="string"?Cv(s,{dir:e,size:t}):Sv(s,{dir:e,size:t})}function Cv(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new Wf({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function Sv(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new Wf({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}let $v=class extends mc{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},Pv=class extends mc{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Cn(s,{size:e}){if(Ru(s)>e)throw new Pv({givenSize:Ru(s),maxSize:e})}function zl(s,e={}){const{signed:t}=e;e.size&&Cn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function Tv(s,e={}){return Number(zl(s,e))}const Mv=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Fl(s,e={}){return typeof s=="number"||typeof s=="bigint"?Kf(s,e):typeof s=="string"?Dv(s,e):typeof s=="boolean"?xv(s,e):Vf(s,e)}function xv(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(Cn(t,{size:e.size}),_n(t,{size:e.size})):t}function Vf(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=Mv[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Cn(i,{size:e.size}),_n(i,{dir:"right",size:e.size})):i}function Kf(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new $v({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?_n(a,{size:i}):a}const Ov=new TextEncoder;function Dv(s,e={}){const t=Ov.encode(s);return Vf(t,e)}const kv=new TextEncoder;function jv(s,e={}){return typeof s=="number"||typeof s=="bigint"?Uv(s,e):typeof s=="boolean"?Rv(s,e):Co(s)?Gf(s,e):Yf(s,e)}function Rv(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(Cn(t,{size:e.size}),_n(t,{size:e.size})):t}const Ks={zero:48,nine:57,A:65,F:70,a:97,f:102};function Uu(s){if(s>=Ks.zero&&s<=Ks.nine)return s-Ks.zero;if(s>=Ks.A&&s<=Ks.F)return s-(Ks.A-10);if(s>=Ks.a&&s<=Ks.f)return s-(Ks.a-10)}function Gf(s,e={}){let t=s;e.size&&(Cn(t,{size:e.size}),t=_n(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const l=Uu(i.charCodeAt(a++)),c=Uu(i.charCodeAt(a++));if(l===void 0||c===void 0)throw new mc(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=l*16+c}return n}function Uv(s,e){const t=Kf(s,e);return Gf(t)}function Yf(s,e={}){const t=kv.encode(s);return typeof e.size=="number"?(Cn(t,{size:e.size}),_n(t,{dir:"right",size:e.size})):t}function Ya(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Lv(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ho(s,...e){if(!Lv(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function zv(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ya(s.outputLen),Ya(s.blockLen)}function ql(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Qf(s,e){Ho(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const la=BigInt(2**32-1),Lu=BigInt(32);function Fv(s,e=!1){return e?{h:Number(s&la),l:Number(s>>Lu&la)}:{h:Number(s>>Lu&la)|0,l:Number(s&la)|0}}function qv(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=Fv(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const Bv=(s,e,t)=>s<<t|e>>>32-t,Hv=(s,e,t)=>e<<t|s>>>32-t,Wv=(s,e,t)=>e<<t-32|s>>>64-t,Vv=(s,e,t)=>s<<t-32|e>>>64-t,Ir=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Kv(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Gv(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Yv(s,e){return s<<32-e|s>>>e}const zu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Qv(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Fu(s){for(let e=0;e<s.length;e++)s[e]=Qv(s[e])}function Zv(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function Vh(s){return typeof s=="string"&&(s=Zv(s)),Ho(s),s}function Jv(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Ho(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let Zf=class{clone(){return this._cloneInto()}};function Jf(s){const e=i=>s().update(Vh(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Xv(s=32){if(Ir&&typeof Ir.getRandomValues=="function")return Ir.getRandomValues(new Uint8Array(s));if(Ir&&typeof Ir.randomBytes=="function")return Ir.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Xf=[],em=[],tm=[],e0=BigInt(0),jn=BigInt(1),t0=BigInt(2),s0=BigInt(7),i0=BigInt(256),r0=BigInt(113);for(let s=0,e=jn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Xf.push(2*(5*i+t)),em.push((s+1)*(s+2)/2%64);let r=e0;for(let n=0;n<7;n++)e=(e<<jn^(e>>s0)*r0)%i0,e&t0&&(r^=jn<<(jn<<BigInt(n))-jn);tm.push(r)}const[n0,o0]=qv(tm,!0),qu=(s,e,t)=>t>32?Wv(s,e,t):Bv(s,e,t),Bu=(s,e,t)=>t>32?Vv(s,e,t):Hv(s,e,t);function a0(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=qu(c,h,1)^t[a],d=Bu(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=em[o],l=qu(r,n,a),c=Bu(r,n,a),h=Xf[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=n0[i],s[1]^=o0[i]}t.fill(0)}let c0=class sm extends Zf{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ya(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Kv(this.state)}keccak(){zu||Fu(this.state32),a0(this.state32,this.rounds),zu||Fu(this.state32),this.posOut=0,this.pos=0}update(e){ql(this);const{blockLen:t,state:i}=this;e=Vh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){ql(this,!1),Ho(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ya(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Qf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new sm(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const l0=(s,e,t)=>Jf(()=>new c0(e,s,t)),h0=l0(1,136,256/8);function im(s,e){const t=e||"hex",i=h0(Co(s,{strict:!1})?jv(s):s);return t==="bytes"?i:Fl(i)}let u0=class extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}};const zc=new u0(8192);function d0(s,e){if(zc.has(`${s}.${e}`))return zc.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=im(Yf(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return zc.set(`${s}.${e}`,n),n}function p0(s){const e=im(`0x${s.substring(4)}`).substring(26);return d0(`0x${e}`)}async function g0({hash:s,signature:e}){const t=Co(s)?s:Fl(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-BU-UfBCB.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:c,s:h,v:u,yParity:d}=e,p=Number(d??u),g=Hu(p);return new i.Signature(zl(c),zl(h)).addRecoveryBit(g)}const o=Co(e)?e:Fl(e),a=Tv(`0x${o.slice(130)}`),l=Hu(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(l)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function Hu(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function f0({hash:s,signature:e}){return p0(await g0({hash:s,signature:e}))}var rm=te.requireElliptic();const nm=":";function gn(s){const[e,t]=s.split(nm);return{namespace:e,reference:t}}function m0(s){const[e,t,i]=s.split(nm);return{namespace:e,reference:t,address:i}}function om(s,e){return s.includes(":")?[s]:e.chains||[]}const w0="ReactNative",as={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},y0="js";function Qa(){return typeof N.dist.process<"u"&&typeof N.dist.process.versions<"u"&&typeof N.dist.process.versions.node<"u"}function Mi(){return!E.getDocument_1()&&!!E.getNavigator_1()&&navigator.product===w0}function b0(){return Mi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="android"}function v0(){return Mi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="ios"}function Wo(){return!Qa()&&!!E.getNavigator_1()&&!!E.getDocument_1()}function Vo(){return Mi()?as.reactNative:Qa()?as.node:Wo()?as.browser:as.unknown}function Wu(){var s;try{return Mi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Application)<"u"?(s=N.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function I0(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function am(){return E.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function E0(){if(Vo()===as.reactNative&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"){const{OS:t,Version:i}=N.dist.global.Platform;return[t,i].join("-")}const s=m.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function A0(){var s;const e=Vo();return e===as.browser?[e,((s=E.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function cm(s,e,t){const i=E0(),r=A0();return[[s,e].join("-"),[y0,t].join("-"),i,r].join("/")}function N0({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:l}){const c=t.split("?"),h=cm(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:l||void 0,bundleId:a||void 0},d=I0(c[1]||"",u);return c[0]+"?"+d}function Yi(s,e){return s.filter(t=>e.includes(t)).length===s.length}function lm(s){return Object.fromEntries(s.entries())}function hm(s){return new Map(Object.entries(s))}function Fi(s=E.cjs.FIVE_MINUTES,e){const t=E.cjs.toMiliseconds(s||E.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,l)=>{if(o)return a(o);n=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),l(c)},t),i=a,r=l})}}function vi(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function um(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function _0(s){return um("topic",s)}function C0(s){return um("id",s)}function dm(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function at(s,e){return E.cjs.fromMiliseconds(Date.now()+E.cjs.toMiliseconds(s))}function gi(s){return Date.now()>=E.cjs.toMiliseconds(s)}function Ae(s,e){return`${s}${e?`:${e}`:""}`}function ka(s=[],e=[]){return[...new Set([...s,...e])]}async function S0({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=$0(n,s,e),a=Vo();if(a===as.browser){if(!((i=E.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}P0(o)}else a===as.reactNative&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u"&&await N.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function $0(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${O0(i,!0)}`}else r=`${r}/wc?${i}`;return r}function P0(s){let e="_self";x0()?e="_top":(M0()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function T0(s,e){let t="";try{if(Wo()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Vu(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ku(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function Kh(){return typeof N.dist.process<"u"&&N.dist.process.env.IS_VITEST==="true"}function M0(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function x0(){try{return window.self!==window.top}catch{return!1}}function O0(s,e=!1){const t=N.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function pm(s){return N.dist.Buffer.from(s,"base64").toString("utf-8")}function D0(s){return new Promise(e=>setTimeout(e,s))}function So(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function k0(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function wc(s,...e){if(!k0(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Gh(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");So(s.outputLen),So(s.blockLen)}function yn(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function gm(s,e){wc(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const ha=BigInt(2**32-1),Gu=BigInt(32);function j0(s,e=!1){return e?{h:Number(s&ha),l:Number(s>>Gu&ha)}:{h:Number(s>>Gu&ha)|0,l:Number(s&ha)|0}}function R0(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=j0(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const U0=(s,e,t)=>s<<t|e>>>32-t,L0=(s,e,t)=>e<<t|s>>>32-t,z0=(s,e,t)=>e<<t-32|s>>>64-t,F0=(s,e,t)=>s<<t-32|e>>>64-t,Er=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function q0(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Fc(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Os(s,e){return s<<32-e|s>>>e}const Yu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function B0(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Qu(s){for(let e=0;e<s.length;e++)s[e]=B0(s[e])}function H0(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function bn(s){return typeof s=="string"&&(s=H0(s)),wc(s),s}let Yh=class{clone(){return this._cloneInto()}};function fm(s){const e=i=>s().update(bn(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Ko(s=32){if(Er&&typeof Er.getRandomValues=="function")return Er.getRandomValues(new Uint8Array(s));if(Er&&typeof Er.randomBytes=="function")return Er.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const mm=[],wm=[],ym=[],W0=BigInt(0),Rn=BigInt(1),V0=BigInt(2),K0=BigInt(7),G0=BigInt(256),Y0=BigInt(113);for(let s=0,e=Rn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],mm.push(2*(5*i+t)),wm.push((s+1)*(s+2)/2%64);let r=W0;for(let n=0;n<7;n++)e=(e<<Rn^(e>>K0)*Y0)%G0,e&V0&&(r^=Rn<<(Rn<<BigInt(n))-Rn);ym.push(r)}const[Q0,Z0]=R0(ym,!0),Zu=(s,e,t)=>t>32?z0(s,e,t):U0(s,e,t),Ju=(s,e,t)=>t>32?F0(s,e,t):L0(s,e,t);function J0(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=Zu(c,h,1)^t[a],d=Ju(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=wm[o],l=Zu(r,n,a),c=Ju(r,n,a),h=mm[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=Q0[i],s[1]^=Z0[i]}t.fill(0)}let X0=class bm extends Yh{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,So(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=q0(this.state)}keccak(){Yu||Qu(this.state32),J0(this.state32,this.rounds),Yu||Qu(this.state32),this.posOut=0,this.pos=0}update(e){yn(this);const{blockLen:t,state:i}=this;e=bn(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){yn(this,!1),wc(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return So(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gm(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new bm(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const eI=(s,e,t)=>fm(()=>new X0(e,s,t)),tI=eI(1,136,256/8),sI="https://rpc.walletconnect.org/v1";function vm(s){const e=`Ethereum Signed Message:
|
|
1
|
+
"use strict";var pb=Object.defineProperty;var gb=(s,e,t)=>e in s?pb(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t;var vt=(s,e,t)=>gb(s,typeof e!="symbol"?e+"":e,t);const N=require("./address-DKM11kf_.js"),te=require("./index-CtU_yCFR.js"),fb=require("./util-G2vxTeU2.js"),mb=require("./wallets-5qGJd8Hk.js"),Rl=require("./unsignedTransaction-BwT180qj.js"),$u=require("./signer-D-HjSIgq.js"),E=require("./index-Cjz6EL9G.js"),m=require("./index.es-B-_H_cmu.js");require("./browser-ponyfill-UnUv8h3i.js");class Tt extends Error{constructor(e,t){super(e),this.error=t}}class Ti extends Tt{constructor(){super(...arguments),this.name="WalletNotReadyError"}}class wb extends Tt{constructor(){super(...arguments),this.name="WalletLoadError"}}class ln extends Tt{constructor(){super(...arguments),this.name="WalletConfigError"}}class fc extends Tt{constructor(){super(...arguments),this.name="WalletConnectionError"}}class Rf extends Tt{constructor(){super(...arguments),this.name="WalletDisconnectedError"}}class zo extends Tt{constructor(){super(...arguments),this.name="WalletDisconnectionError"}}class vs extends Tt{constructor(){super(...arguments),this.name="WalletAccountError"}}class dr extends Tt{constructor(){super(...arguments),this.name="WalletPublicKeyError"}}class Fe extends Tt{constructor(){super(...arguments),this.name="WalletNotConnectedError"}}class Gi extends Tt{constructor(){super(...arguments),this.name="WalletSendTransactionError"}}class Je extends Tt{constructor(){super(...arguments),this.name="WalletSignTransactionError"}}class Fo extends Tt{constructor(){super(...arguments),this.name="WalletSignMessageError"}}class Pu extends Tt{constructor(){super(...arguments),this.name="WalletSignInError"}}class yb extends Tt{constructor(){super(...arguments),this.name="WalletWindowClosedError"}}var ae;(function(s){s.Installed="Installed",s.NotDetected="NotDetected",s.Loadable="Loadable",s.Unsupported="Unsupported"})(ae||(ae={}));class Uf extends N.EventEmitter{get connected(){return!!this.publicKey}async autoConnect(){await this.connect()}async prepareTransaction(e,t,i={}){const r=this.publicKey;if(!r)throw new Fe;return e.feePayer=e.feePayer||r,e.recentBlockhash=e.recentBlockhash||(await t.getLatestBlockhash({commitment:i.preflightCommitment,minContextSlot:i.minContextSlot})).blockhash,e}}function qo(s){if(typeof window>"u"||typeof document>"u")return;const e=[];function t(){if(s())for(const n of e)n()}const i=setInterval(t,1e3);e.push(()=>clearInterval(i)),document.readyState==="loading"&&(document.addEventListener("DOMContentLoaded",t,{once:!0}),e.push(()=>document.removeEventListener("DOMContentLoaded",t))),document.readyState!=="complete"&&(window.addEventListener("load",t,{once:!0}),e.push(()=>window.removeEventListener("load",t))),t()}function si(s){return"version"in s}class Wh extends Uf{async sendTransaction(e,t,i={}){let r=!0;try{if(si(e)){if(!this.supportedTransactionVersions)throw new Gi("Sending versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(e.version))throw new Gi(`Sending transaction version ${e.version} isn't supported by this wallet`);try{e=await this.signTransaction(e);const n=e.serialize();return await t.sendRawTransaction(n,i)}catch(n){throw n instanceof Je?(r=!1,n):new Gi(n==null?void 0:n.message,n)}}else try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),e=await this.signTransaction(e);const a=e.serialize();return await t.sendRawTransaction(a,o)}catch(n){throw n instanceof Je?(r=!1,n):new Gi(n==null?void 0:n.message,n)}}catch(n){throw r&&this.emit("error",n),n}}async signAllTransactions(e){for(const i of e)if(si(i)){if(!this.supportedTransactionVersions)throw new Je("Signing versioned transactions isn't supported by this wallet");if(!this.supportedTransactionVersions.has(i.version))throw new Je(`Signing transaction version ${i.version} isn't supported by this wallet`)}const t=[];for(const i of e)t.push(await this.signTransaction(i));return t}}class Bo extends Wh{}const yi="solana:signAndSendTransaction",jc="solana:signIn",Dn="solana:signMessage",St="solana:signTransaction",Lf="standard:connect",Tu="standard:disconnect",zf="standard:events";function bb(s){return Lf in s.features&&zf in s.features&&(yi in s.features||St in s.features)}var _o;(function(s){s.Mainnet="mainnet-beta",s.Testnet="testnet",s.Devnet="devnet"})(_o||(_o={}));const vb="Bitget";class Ib extends Bo{constructor(e={}){super(),this.name=vb,this.url="https://web3.bitget.com",this.icon="data:image/svg+xml;base64,PHN2ZyBmaWxsPSJub25lIiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIHdpZHRoPSIyNTYiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiPjxmaWx0ZXIgaWQ9ImEiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiIgZmlsdGVyVW5pdHM9InVzZXJTcGFjZU9uVXNlIiBoZWlnaHQ9IjQ1MS40MzEiIHdpZHRoPSI1NjkuNTU4IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiPjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+PGZlQmxlbmQgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiBtb2RlPSJub3JtYWwiIHJlc3VsdD0ic2hhcGUiLz48ZmVHYXVzc2lhbkJsdXIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIgc3RkRGV2aWF0aW9uPSI0OS4yMzA4Ii8+PC9maWx0ZXI+PGZpbHRlciBpZD0iYiIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGhlaWdodD0iMzcxLjUwNyIgd2lkdGg9IjM1MS41OTYiIHg9Ii0xNjAuNTExIiB5PSItMTY1Ljk4NyI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJjIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSI0MjQuNDUyIiB3aWR0aD0iNDQ0Ljg1MSIgeD0iLTI0MS4wNzgiIHk9IjY3LjY0MiI+PGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz48ZmVCbGVuZCBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIG1vZGU9Im5vcm1hbCIgcmVzdWx0PSJzaGFwZSIvPjxmZUdhdXNzaWFuQmx1ciByZXN1bHQ9ImVmZmVjdDFfZm9yZWdyb3VuZEJsdXJfMjAzNV8xMTA2IiBzdGREZXZpYXRpb249IjQ5LjIzMDgiLz48L2ZpbHRlcj48ZmlsdGVyIGlkPSJkIiBjb2xvci1pbnRlcnBvbGF0aW9uLWZpbHRlcnM9InNSR0IiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgaGVpZ2h0PSIzODUuMTA1IiB3aWR0aD0iNDMwLjE5MSIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4Ij48ZmVGbG9vZCBmbG9vZC1vcGFjaXR5PSIwIiByZXN1bHQ9IkJhY2tncm91bmRJbWFnZUZpeCIvPjxmZUJsZW5kIGluPSJTb3VyY2VHcmFwaGljIiBpbjI9IkJhY2tncm91bmRJbWFnZUZpeCIgbW9kZT0ibm9ybWFsIiByZXN1bHQ9InNoYXBlIi8+PGZlR2F1c3NpYW5CbHVyIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIvPjwvZmlsdGVyPjxjbGlwUGF0aCBpZD0iZSI+PHBhdGggZD0ibTAgMGgyNTZ2MjU2aC0yNTZ6Ii8+PC9jbGlwUGF0aD48ZyBjbGlwLXBhdGg9InVybCgjZSkiPjxwYXRoIGQ9Im0wIDBoMjU2djI1NmgtMjU2eiIgZmlsbD0iIzU0ZmZmNSIvPjxnIGZpbHRlcj0idXJsKCNhKSI+PHBhdGggZD0ibTEzLjQ4MDYgMTk4LjYwNWMtNDIuODA4MiAxMjAuNDM4IDE4Ni4xODA0IDg2LjQyMiAzMDYuMDI2NCA1NC4zNTkgMTIyLjY1OC00MC43MDUgMzcuODc5LTIyMC4xMzcxLTUwLjA5Mi0yMjQuMTA4Mi04Ny45NzItMy45NzExIDEwLjkwNyA4Mi45NjgyLTYzLjgyIDEwNy44MDAyLTc0LjcyNyAyNC44MzEtMTM4LjYwNDMtODguNTk3Ny0xOTIuMTE0NCA2MS45NDl6IiBmaWxsPSIjZmZmIi8+PC9nPjxnIGZpbHRlcj0idXJsKCNiKSI+PHBhdGggZD0ibTg1LjUxMTgtNDUuODIyNWMtMjIuNDU1Ni02MS4zNTM1LTEwMi40MzA3IDIxLjgyNzItMTM5LjYxMTMgNzEuMDg2OC0zNS40NjU3IDUzLjU4MzYgNTcuMTA4ODcgOTkuODg3NyA5My40MjAzIDc0Ljc3MjcgMzYuMzExNS0yNS4xMTQzLTMxLjU0NjMyLTMwLjAwMDctOS45NS02Mi42NTg1IDIxLjU5NjMtMzIuNjU3NzQgODQuMjEwMi02LjUwOSA1Ni4xNDEtODMuMjAxeiIgZmlsbD0iIzAwZmZmMCIgZmlsbC1vcGFjaXR5PSIuNjciLz48L2c+PGcgZmlsdGVyPSJ1cmwoI2MpIj48cGF0aCBkPSJtOTYuNDc5NiAyMjUuNDI0Yy0zMC42Mjk0LTEwMy4wNjEtMTYyLjU2MTQtNDguNzg3LTIyNC42OTg2LTguNzY3LTU5Ljc3MSA0Ny4zODUgODIuMTQ3OSAxODMuNjkxIDE0MS4wOTE1IDE3Ni43MTkgNTguOTQzNi02Ljk3My00Ny4yODQzLTY2LjMxMS0xMC44ODU0OC05NS4yMDYgMzYuMzk4NzgtMjguODk0IDEzMi43Nzg5OCA1Ni4wNzkgOTQuNDkyNTgtNzIuNzQ2eiIgZmlsbD0iIzlkODFmZiIvPjwvZz48ZyBmaWx0ZXI9InVybCgjZCkiPjxwYXRoIGQ9Im0yODIuMTItMTA3LjM1M2MtNjYuMDczLTc4LjY3OC0xNjAuNjU3LTEzLjYxNy0xOTkuNjkwNCAyOC43NDgzLTM0LjE1NTcgNDcuOTYwMSAxNDEuODQ1NCAxMzUuODM1OSAxOTAuNjkxNCAxMjAuNzc2MSA0OC44NDctMTUuMDU5OS02Ni42MDktNDYuMjIxNzgtNDUuODI0LTc1LjQ1OTMgMjAuNzg1LTI5LjIzNzYgMTM3LjQxNSAyNC4yODIyNCA1NC44MjMtNzQuMDY1MXoiIGZpbGw9IiM0ZDk0ZmYiLz48L2c+PHBhdGggY2xpcC1ydWxlPSJldmVub2RkIiBkPSJtOTMuMTg5IDE1Mi44MzZoNDMuNDg1bC00OS40NjU0LTQ5Ljc4NSA1MC4xMDE0LTQ5Ljc4NDcgMTMuNjQ1LTEzLjI2NjNoLTQ1LjEzNmwtNTcuNDgzMSA1Ny43NzczYy0yLjkwMSAyLjkxMTctMi44ODYxIDcuNjI0Ny4wMjk3IDEwLjUyMTd6bTI2LjE0MS00OS42NjhoLS4zMzVsLjMzMS0uMDA0em0wIDAgNDkuNDYxIDQ5Ljc4MS01MC4xMDEgNDkuNzg1LTEzLjY0NSAxMy4yNjZoNDUuMTM1bDU3LjQ4NC01Ny43NzRjMi45MDEtMi45MTIgMi44ODYtNy42MjQtLjAzLTEwLjUyMWwtNDQuODIzLTQ0LjUzN3oiIGZpbGw9IiMwMDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>{var t,i;return(i=(t=window.bitkeep)==null?void 0:t.solana)!=null&&i.isBitKeep?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.bitkeep.solana;let t;try{t=await e.getAccount()}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new zo(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{const{signature:i}=await t.signMessage(e);return i}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Eb="Clover";class Ab extends Bo{constructor(e={}){super(),this.name=Eb,this.url="https://clv.org",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTM2LjQ4IDBIMTEuNTJDNS4xNTc2OCAwIDAgNS4xNTc2OCAwIDExLjUyVjM2LjQ4QzAgNDIuODQyMyA1LjE1NzY4IDQ4IDExLjUyIDQ4SDM2LjQ4QzQyLjg0MjMgNDggNDggNDIuODQyMyA0OCAzNi40OFYxMS41MkM0OCA1LjE1NzY4IDQyLjg0MjMgMCAzNi40OCAwWiIgZmlsbD0idXJsKCNwYWludDBfbGluZWFyXzc5MTBfMTYzMzUxKSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTI0LjAwMDYgMzkuMzYwNkMzMi40ODM3IDM5LjM2MDYgMzkuMzYwNiAzMi40ODM3IDM5LjM2MDYgMjQuMDAwNkMzOS4zNjA2IDE1LjUxNzUgMzIuNDgzNyA4LjY0MDYyIDI0LjAwMDYgOC42NDA2MkMxNS41MTc1IDguNjQwNjIgOC42NDA2MiAxNS41MTc1IDguNjQwNjIgMjQuMDAwNkM4LjY0MDYyIDMyLjQ4MzcgMTUuNTE3NSAzOS4zNjA2IDI0LjAwMDYgMzkuMzYwNlpNMjEuMjg5OSAxNS44Njg4SDI2LjcxMVYyMS4zNDdIMjEuMjkwNFYyNi42NTRIMjYuNzExVjMyLjEzMjJIMjEuMjg5OVYyNi44MjUySDE1Ljg2OTNWMjEuMzQ3SDIxLjI4OTlWMTUuODY4OFpNMjYuNzEyIDIxLjM0N0gzMi4xMzMxVjI2LjgyNTJIMjYuNzEyVjIxLjM0N1oiIGZpbGw9ImJsYWNrIi8+CjxkZWZzPgo8bGluZWFyR3JhZGllbnQgaWQ9InBhaW50MF9saW5lYXJfNzkxMF8xNjMzNTEiIHgxPSI0OCIgeTE9Ii0xLjQzMDUxZS0wNiIgeDI9IjEuNDMwNTFlLTA2IiB5Mj0iNDgiIGdyYWRpZW50VW5pdHM9InVzZXJTcGFjZU9uVXNlIj4KPHN0b3Agc3RvcC1jb2xvcj0iI0E5RkZFMCIvPgo8c3RvcCBvZmZzZXQ9IjEiIHN0b3AtY29sb3I9IiM4NkQ1RkYiLz4KPC9saW5lYXJHcmFkaWVudD4KPC9kZWZzPgo8L3N2Zz4=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>{var t;return(t=window.clover_solana)!=null&&t.isCloverWallet?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.clover_solana;let t;try{t=await e.getAccount()}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{const{signature:i}=await t.signMessage(e);return Uint8Array.from(i)}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Nb(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var _b="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Rc=Nb(_b),Cb="Coin98";class Sb extends Bo{constructor(e={}){super(),this.name=Cb,this.url="https://coin98.com",this.icon="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA3NiA3NSI+CiAgPGRlZnM+CiAgICA8bGluZWFyR3JhZGllbnQgaWQ9ImEiIHgxPSIxMDEuNjgxJSIgeDI9Ii0xLjU1NyUiIHkxPSIxNS4yNjglIiB5Mj0iODQuOTE3JSI+CiAgICAgIDxzdG9wIG9mZnNldD0iMCUiIHN0b3AtY29sb3I9IiNGMUQ5NjEiLz4KICAgICAgPHN0b3Agb2Zmc2V0PSIxMDAlIiBzdG9wLWNvbG9yPSIjQ0RBMTQ2Ii8+CiAgICA8L2xpbmVhckdyYWRpZW50PgogIDwvZGVmcz4KICA8ZyBmaWxsPSJub25lIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPgogICAgPHJlY3Qgd2lkdGg9Ijc1IiBoZWlnaHQ9Ijc1IiBmaWxsPSIjMDAwIiByeD0iMTYiLz4KICAgIDxwYXRoIGZpbGw9InVybCgjYSkiIGZpbGwtcnVsZT0ibm9uemVybyIgZD0iTTYxLjQ0IDBhMTMuNzE0IDEzLjcxNCAwIDAgMSA5LjY4IDQuMDEgMTMuNjYxIDEzLjY2MSAwIDAgMSA0LjAwOCA5LjY2OHY0Ny42NDZhMTMuNjYgMTMuNjYgMCAwIDEtNC4wMDcgOS42NjZBMTMuNzEzIDEzLjcxMyAwIDAgMSA2MS40NCA3NUgxMy42ODZhMTMuNzEzIDEzLjcxMyAwIDAgMS05LjY4LTQuMDFBMTMuNjYgMTMuNjYgMCAwIDEgMCA2MS4zMjRWMTMuNjc4YzAtMy42MjUgMS40NC03LjEwMiA0LjAwNy05LjY2N0ExMy43MTQgMTMuNzE0IDAgMCAxIDEzLjY4NyAwWk0yMC4wNjMgNDYuMjMxaC00LjgyNWExMC4wMzIgMTAuMDMyIDAgMCAwIDIuOTQ2IDcuMDg2IDEwLjA3IDEwLjA3IDAgMCAwIDcuMSAyLjk0MiAxMC4wNjUgMTAuMDY1IDAgMCAwIDcuMTA4LTIuOTM1IDEwLjAzIDEwLjAzIDAgMCAwIDIuOTQ2LTcuMDkzaC00LjgyNGE1LjIwNyA1LjIwNyAwIDAgMS0xLjUzIDMuNjg4IDUuMjI1IDUuMjI1IDAgMCAxLTMuNjk2IDEuNTI4IDUuMjM0IDUuMjM0IDAgMCAxLTMuNjk1LTEuNTI4IDUuMjEzIDUuMjEzIDAgMCAxLTEuNTMtMy42ODhaTTU0LjMzIDMzLjcxNmExMS43NjMgMTEuNzYzIDAgMCAwLTEyLjc5OSAyLjUzOEExMS42OTcgMTEuNjk3IDAgMCAwIDM4Ljk5IDQ5LjAzYTExLjcyMyAxMS43MjMgMCAwIDAgNC4zMjggNS4yNTkgMTEuNzU3IDExLjc1NyAwIDAgMCA2LjUyNiAxLjk3IDExLjc2NiAxMS43NjYgMCAwIDAgOC4yOS0zLjQzNSAxMS43MiAxMS43MiAwIDAgMCAzLjQ0Mi04LjI3NCAxMS43MDIgMTEuNzAyIDAgMCAwLTEuOTc1LTYuNTE0IDExLjczNiAxMS43MzYgMCAwIDAtNS4yNjktNC4zMlptLTQuNDg4IDMuOTJhNi45MzcgNi45MzcgMCAwIDEgNC45IDIuMDI1IDYuOTEgNi45MSAwIDAgMSAyLjAyOCA0Ljg5MiA2Ljg5NyA2Ljg5NyAwIDAgMS0xLjE3IDMuODM0IDYuOTMyIDYuOTMyIDAgMCAxLTEwLjY0MyAxLjA0MiA2LjkwMiA2LjkwMiAwIDAgMS0xLjUtNy41MjIgNi45MDkgNi45MDkgMCAwIDEgMi41NDQtMy4xIDYuOTI4IDYuOTI4IDAgMCAxIDMuODQxLTEuMTY3Wm0uMTcgNC41NTJhMi40MzEgMi40MzEgMCAwIDAtMi4yNDEgMS4xNTQgMi40MTggMi40MTggMCAwIDAtLjM1NiAxLjI1NyAyLjM5NSAyLjM5NSAwIDAgMCAxLjYxOSAyLjI5djEuNzUzaDEuNjE4di0xLjc1NGEyLjQyNyAyLjQyNyAwIDAgMCAxLjU5NC0xLjk1IDIuNDE4IDIuNDE4IDAgMCAwLTEtMi4zMSAyLjQzMSAyLjQzMSAwIDAgMC0xLjIzNC0uNDRabS0yMC4yMi0yMi41NTJhMTEuNzYyIDExLjc2MiAwIDAgMC0xMi43OTYgMi41MzEgMTEuNjk3IDExLjY5NyAwIDAgMC0yLjU1NCAxMi43NjkgMTEuNzIzIDExLjcyMyAwIDAgMCA0LjMyIDUuMjYyIDExLjc1NyAxMS43NTcgMCAwIDAgMTQuODI1LTEuNDQ2IDExLjcxNyAxMS43MTcgMCAwIDAgMy40NDUtOC4yODQgMTEuNzAzIDExLjcwMyAwIDAgMC0xLjk3NC02LjUxMiAxMS43MzYgMTEuNzM2IDAgMCAwLTUuMjY2LTQuMzJabS00LjUxIDMuOTE3YTYuOTQ1IDYuOTQ1IDAgMCAxIDQuODk3IDIuMDI5IDYuOTE4IDYuOTE4IDAgMCAxIDIuMDMyIDQuODg2IDYuOTA2IDYuOTA2IDAgMCAxLTEuMTY4IDMuODQyIDYuOTQgNi45NCAwIDAgMS0xMC42NiAxLjA0OCA2LjkxMSA2LjkxMSAwIDAgMS0xLjUtNy41MzYgNi45MTggNi45MTggMCAwIDEgMi41NS0zLjEwMyA2LjkzNyA2LjkzNyAwIDAgMSAzLjg1LTEuMTY2Wm0yNC41Ni00LjgxYTEwLjA1OSAxMC4wNTkgMCAwIDAtNy4xMDMgMi45NCAxMC4wMiAxMC4wMiAwIDAgMC0yLjk0IDcuMDkgOS45IDkuOSAwIDAgMCAxLjIzIDQuNzk1IDEzLjU3NSAxMy41NzUgMCAwIDEgNC4yMTQtMi4zMjIgNS4wODIgNS4wODIgMCAwIDEtLjYyNS0yLjQ3NyA1LjIwNiA1LjIwNiAwIDAgMSAxLjUwMy0zLjczNiA1LjIyMyA1LjIyMyAwIDAgMSAzLjcyMi0xLjU1NCA1LjIzNCA1LjIzNCAwIDAgMSAzLjcyIDEuNTU0IDUuMjEzIDUuMjEzIDAgMCAxIDEuNTA1IDMuNzM2IDUuMjc5IDUuMjc5IDAgMCAxLS42MjMgMi40NzMgMTMuNTc0IDEzLjU3NCAwIDAgMSA0LjIxMyAyLjMyMiA5LjkwMyA5LjkwMyAwIDAgMCAxLjIzLTQuNzk1IDEwLjAzMiAxMC4wMzIgMCAwIDAtMi45NDYtNy4wODYgMTAuMDcgMTAuMDcgMCAwIDAtNy4xLTIuOTRabS0yMy43NSA3Ljk5aC0xLjYxN3YxLjc1YTIuNDE5IDIuNDE5IDAgMCAwLTEuNTgyIDIuNjg3IDIuNDE0IDIuNDE0IDAgMCAwIDIuMzkgMi4wMDYgMi40NSAyLjQ1IDAgMCAwIDEuNTU1LS41NzQgMi40MTQgMi40MTQgMCAwIDAtLjc0Ni00LjExOXYtMS43NVoiLz4KICA8L2c+Cjwvc3ZnPgo=",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>{var t;return(t=window.coin98)!=null&&t.sol?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isConnected())}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.coin98.sol;let t;try{t=(await e.connect())[0]}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch(t){this.emit("error",new zo(t==null?void 0:t.message,t))}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{const i=await t.request({method:"sol_sign",params:[e]}),r=new N.PublicKey(i.publicKey),n=Rc.decode(i.signature);return e.addSignature(r,N.dist.Buffer.from(n)),e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{const i=await t.request({method:"sol_signAllTransactions",params:[e]}),r=new N.PublicKey(i.publicKey),n=i.signatures;return e.map((o,a)=>{const l=Rc.decode(n[a]);return o.addSignature(r,N.dist.Buffer.from(l)),o})}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{const i=await t.request({method:"sol_signMessage",params:[e]});return Rc.decode(i.signature)}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const $b="Nightly";class Pb extends Bo{constructor(){super(),this.name=$b,this.url="https://nightly.app",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iOTYiIGhlaWdodD0iOTYiIHZpZXdCb3g9IjAgMCA5NiA5NiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTQ4IDk2Qzc0LjUwOTcgOTYgOTYgNzQuNTA5NyA5NiA0OEM5NiAyMS40OTAzIDc0LjUwOTcgMCA0OCAwQzIxLjQ5MDMgMCAwIDIxLjQ5MDMgMCA0OEMwIDc0LjUwOTcgMjEuNDkwMyA5NiA0OCA5NloiIGZpbGw9IiM2RDczRjgiLz4KPHBhdGggZD0iTTQ4IDg1LjYzNTZDNDggODUuNjM1NiA1Mi40NTMzIDg1LjYzNTYgNTUuNDQgODIuNTg2N0M1OC45MTU1IDc5LjI4MDEgNTcuMzUxMSA3NS40MzEyIDYyLjI3NTUgNzEuNDMxMkM2Ni45ODY2IDY3LjY0NDUgNzIuOTI0NCA3MC4zMzc5IDcyLjkyNDQgNzAuMzM3OUM3Ny4wMjIyIDYyLjEyNDUgNzQuNzkxMSA1Mi41NjkgNzQuNzkxMSA1Mi41NjlDODEuNzY4OCAzNC4yNTc5IDc1Ljk2NDQgMjEuMTU1NyA3NC40NDQ0IDE3LjM2MDFDNjkuNDQ4OCAyNC4zMzc5IDYzLjE5MTEgMjkuMTczNCA1NS43OTU1IDMyLjQwOUM1My4yMjY2IDMxLjcwNjggNTAuNTk1NSAzMS4zMzM0IDQ4IDMxLjM2MDFDNDUuNDEzMyAzMS4zMzM0IDQyLjc3MzMgMzEuNzA2OCA0MC4yMDQ0IDMyLjQwOUMzMi44MTc3IDI5LjE2NDUgMjYuNTUxMSAyNC4zMzc5IDIxLjU1NTUgMTcuMzYwMUMyMC4wMzU1IDIxLjE1NTcgMTQuMjMxMSAzNC4yNTc5IDIxLjIwODkgNTIuNTY5QzIxLjIwODkgNTIuNTY5IDE4Ljk3NzggNjIuMTI0NSAyMy4wNzU1IDcwLjMzNzlDMjMuMDc1NSA3MC4zMzc5IDI5LjAxMzMgNjcuNjQ0NSAzMy43MjQ0IDcxLjQzMTJDMzguNjU3NyA3NS40MzEyIDM3LjA4NDQgNzkuMjgwMSA0MC41NiA4Mi41ODY3QzQzLjU0NjYgODUuNjM1NiA0OCA4NS42MzU2IDQ4IDg1LjYzNTZaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNNDIuNDc5OSA2NS4yOThDNDIuMjkzMyA1OS4yMTggMzYuMzAyMSA1Ny4yNjI0IDMyLjIxMzMgNTkuODIyNEMzMi4yMTMzIDU5LjgyMjQgMzIuODUzMyA2Mi40MzU4IDM1LjgzOTkgNjMuNzUxM0MzOC4yNzU1IDY0LjgyNjkgMzkuMzI0NCA2My4zODY5IDQyLjQ3OTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNMjIuNDk3NyAyMy4wOTM1QzIwLjA4ODggMzEuNTQ2OCAyMS4xMjg4IDQyLjI0MDIgMjQuOTMzMyA1MC4wMjY5QzI4LjgyNjYgNDcuMjcxMyAzMi45MTU1IDQzLjAxMzUgMzUuMDkzMyAzOC41MDY5QzI5Ljk2NDQgMzQuNzExMyAyNS42NjIyIDMxLjEwMjQgMjIuNDk3NyAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNTMuNTE5OSA2NS4yOThDNTMuNzA2NiA1OS4yMTggNTkuNjk3NyA1Ny4yNjI0IDYzLjc4NjYgNTkuODIyNEM2My43ODY2IDU5LjgyMjQgNjMuMTQ2NiA2Mi40MzU4IDYwLjE1OTkgNjMuNzUxM0M1Ny43MjQzIDY0LjgyNjkgNTYuNjc1NSA2My4zODY5IDUzLjUxOTkgNjUuMjk4WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNzMuNTAyMiAyMy4wOTM1Qzc1LjkxMTEgMzEuNTQ2OCA3NC44NzExIDQyLjI0MDIgNzEuMDY2NiA1MC4wMjY5QzY3LjE3MzMgNDcuMjcxMyA2My4wODQ0IDQzLjAxMzUgNjAuOTA2NiAzOC41MDY5QzY2LjAzNTUgMzQuNzExMyA3MC4zMzc3IDMxLjEwMjQgNzMuNTAyMiAyMy4wOTM1WiIgZmlsbD0iIzdCODFGOSIvPgo8cGF0aCBkPSJNNDcuOTk5OSA4NS4zMDY5QzUwLjE0MDQgODUuMzA2OSA1MS44NzU1IDgzLjc3ODcgNTEuODc1NSA4MS44OTM2QzUxLjg3NTUgODAuMDA4NCA1MC4xNDA0IDc4LjQ4MDIgNDcuOTk5OSA3OC40ODAyQzQ1Ljg1OTUgNzguNDgwMiA0NC4xMjQ0IDgwLjAwODQgNDQuMTI0NCA4MS44OTM2QzQ0LjEyNDQgODMuNzc4NyA0NS44NTk1IDg1LjMwNjkgNDcuOTk5OSA4NS4zMDY5WiIgZmlsbD0iIzdCODFGOSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=new Set(["legacy",0]),this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._publicKey=null,this._wallet=null,this._readyState!==ae.Unsupported&&qo(()=>{var e;return(e=window==null?void 0:window.nightly)!=null&&e.solana?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1})}get connecting(){return this._connecting}get readyState(){return this._readyState}get publicKey(){return this._publicKey}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.nightly.solana;try{await e.connect()}catch(i){throw new fc(i==null?void 0:i.message,i)}if(e.publicKey.toString()==="11111111111111111111111111111111")throw new vs;let t;try{t=new N.PublicKey(e.publicKey.toBytes())}catch(i){throw new dr(i==null?void 0:i.message,i)}this._wallet=e,this._publicKey=t,this.emit("connect",t)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{await e.disconnect()}catch{this.emit("error",new Rf)}}this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{return t.signMessage(new TextDecoder().decode(e))}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const Mu="solana:mainnet",Tb="solana:devnet",Mb="solana:testnet",xb="solana:localnet",Ob="Solong";class Db extends Wh{constructor(e={}){super(),this.name=Ob,this.url="https://solongwallet.io",this.icon="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAFAAAABQCAYAAACOEfKtAAAGlklEQVR4Ae3bA5DsyhfH8TNr49r2/du2bdu2bdu2zcdNrm3b9toz533rvctUn3Umk9p01WfdvVW/6nROBxJVS1rSkpa0pCUtaUlLWtKSpl4VXos3GJ4sujQFuUKfWl+qT730arzB8Ex9YksKcgXjFOCVeIPhBYydB8mawQ+yiGC8n0EN6zAVcgXhpQjoq1DDdsyDAAB9Pwo1HMC9INk0FIM8Bt1Qh9WohQQCvD+BtEMdtmC8I7y5aIE67MV0SBwDvB3qsE/UHwMJIpC/QB1OYiLEEeCPoQ7nMRcSwwDrao3Zl8aTIEGEUYlL0IAMXuQOr66UvsegDm+ExDJAPNiafSg0AlyIbmjAWX1aQzEkiH6T0QkNaEdpnAN8NNRhPcSF9e9el2ebBhyAuNBvGtLQgIuQOAd4D6jDMRQbM3AmOqEBDfq0xjJIEP3GohkakEFVjAP0y401sAsLnAE+pb6EsC5AA9J4sHsG+kX0PQR1eFJ8AwTWQh0+DjFm4a1Qh2/AOoz/BHX4ZdwD/CDU4aioX2GUMW+AOnB2bqiBBDHe86EOTYw5GRKJwQ/ijUM91OGTxgysxSmowzeNw7j08m5DHX4l7Igg2TY0g9hbLBZ+f7oxC98CdWjDvYzD+MVQh07GfEQsZyDgVWA71OGvorfnQQCAcqaYUFZDHW6j/itAoB70GcergzqsEa0rhGTTEA7mP0koK4xdyeOMmvBBhJU2zsjPMw7lu9O3zShpXheHk4hhcZ4w26AOG4RSxDiUfwZ12KdPqy+FBDHeV6EOZxizIg6HsMGbiQ5jdjzBXRfeefGg3tgbv9BYC0fhZE7sjUMY9Pf9rdcI5XtQh39BjBA/C3VYnM0zcgiDek+GOhzh93mQoMs7kIxze/eMhnxIEOPNM9bcFtTEeAb6I419axu/m2CsgxU4Aw1A/UxIUM/bO/9+cVkDDd5x42x8N1iH8Taow0NhHcZLoQ5Pi/MMzDMW+DTu7g6vIY9AdkAdHmaUMyn6roA6PD22AeLB6DbWplHG7LubfY+kfiIkiH5T0AJ1uFtMA1xUzOc1UIclzvCeXF+o7DygDlvds29RgVVzYj+K4xhgEX4NdcjgecE++rSL+ZdLmIxRB77Ose7l4XPIQB3eF8M60C/n8++ghltE/QLIFfqUiyUE8kOoYSW7jmLIFXeN4X0NaajDDlG/NG6XswrxKdxu+G/weh27j3wCej9uN9zEOjc3sObl4S243XBLhDfWE0mAMQjwZfhxDng7pG/8Sj4/ER/Gd/BdfBhPRGW2A/wxNAfcBOnFCHwZZ6GGs/gqapMAb/QEnIT20Uk8IQkQeB7aof3UihcM9wDvhyboANHXv1+IdWBOB2hsIftto+iSPEif8aGPcjrA50GHyPMiOIT9B/N5apaMgQT8D2poxMdwt8s+hkao4X9ZDxBTIdHwy/h8AeqQxhMhAU9BB9ThPMqHTYCYjU6owy3uPstSfL4Z6uZPC+Mk8gOomz8DEg3vXshAHb4MMXwZarhXGDPwa739w2j48623BPAniOFPUMPsMAL8INTw9AgDrLZOCmjFPEjA3WD1aUJVGAG+CGr4ECRCy6GGg3iyaF0+n/PwFByEGpaJ+qkw1sB7QA3/hUTozdBetFymvXhTWGVMOc7bp36/FhKRamNW9dcxZmpZiI+32ad+vAQSoWejGzpAXXh22Fek3wY1rDD2kVnijR3ExYQMPgkJOUB/nFW0Is3vnw6JhlHX9a4N70Iq/ACBv0MNu7J9WxHw7jaA2deFOtw32zeVHtHLWvMN0dtSkOzwS3spYy7iH1hx2d/wYdyTvnkR3BdeQjjerVBDN14JyZIfQWH5RC7e1rw32npZV54LCc+SPD5/HgqYD3WW5+gTqt6X+rA4v0701hRkKF0+bL+HTM9Hgv/MHH60wyvHWigsafwA1ZAhMguLoL34kbDcQEI1uAH8mcbuxPHImf8i5EMGxqvER9EI7cUqVMTl0Y6HoxHaBzvxNkyC9EEe7oEv4Sy0D/YQ+IS4ver1JNT38z7sWnwbb8TT8Cg8Gs/Gu/Ar7EEXtI/2ud7Ni0GAYCbiJDQiazA57k9nTcdqaJb9UtSvitXbmjavCJ9AMzRkJ/B80boUJBLhDe7Nw1/QCR1i9fgKRg6HByzvjZ/hInQQMjiCT2PSMHxC1a/l8wvwGxyG9kEaW/EtPI4xiiE5JcLrd6PxcLwM78SH8EG8Fc/H/UUXVUByGh8SSYBJgEmASYCJJMAkwBi6A3xCqZhiBz8+AAAAAElFTkSuQmCC",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.NotDetected,this._connecting=!1,this._wallet=null,this._publicKey=null,this._readyState!==ae.Unsupported&&qo(()=>window.solong?(this._readyState=ae.Installed,this.emit("readyStateChange",this._readyState),!0):!1)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.currentAccount)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Installed)throw new Ti;this._connecting=!0;const e=window.solong;let t;try{t=await e.selectAccount()}catch(r){throw new vs(r==null?void 0:r.message,r)}let i;try{i=new N.PublicKey(t)}catch(r){throw new dr(r==null?void 0:r.message,r)}this._wallet=e,this._publicKey=i,this.emit("connect",i)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){this._wallet&&(this._wallet=null,this._publicKey=null),this.emit("disconnect")}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}const kb="Torus";class jb extends Bo{constructor({params:e={showTorusButton:!1}}={params:{showTorusButton:!1}}){super(),this.name=kb,this.url="https://tor.us",this.icon="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzMiIGhlaWdodD0iMzIiIHZpZXdCb3g9IjAgMCAzMyAzMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iMTYuNSIgY3k9IjE2IiByPSIxNiIgZmlsbD0iIzAzNjRGRiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTExLjIxODYgOS40OTIxOUMxMC40NTM5IDkuNDkyMTkgOS44MzM5OCAxMC4xMTIxIDkuODMzOTggMTAuODc2OFYxMi40ODk4QzkuODMzOTggMTMuMjU0NSAxMC40NTM5IDEzLjg3NDQgMTEuMjE4NiAxMy44NzQ0SDEzLjY2ODRWMjIuODk3NkMxMy42Njg0IDIzLjY2MjMgMTQuMjg4MyAyNC4yODIyIDE1LjA1MyAyNC4yODIySDE2LjY2NkMxNy40MzA3IDI0LjI4MjIgMTguMDUwNiAyMy42NjIzIDE4LjA1MDYgMjIuODk3NlYxMi41MDE1QzE4LjA1MDYgMTIuNDk3NiAxOC4wNTA2IDEyLjQ5MzcgMTguMDUwNiAxMi40ODk4VjEwLjg3NjhDMTguMDUwNiAxMC4xMTIxIDE3LjQzMDcgOS40OTIxOSAxNi42NjYgOS40OTIxOUgxNS4wNTNIMTEuMjE4NloiIGZpbGw9IndoaXRlIi8+CjxwYXRoIGQ9Ik0yMS4zMzc2IDEzLjg3NDRDMjIuNTQ3NyAxMy44NzQ0IDIzLjUyODcgMTIuODkzNCAyMy41Mjg3IDExLjY4MzNDMjMuNTI4NyAxMC40NzMyIDIyLjU0NzcgOS40OTIxOSAyMS4zMzc2IDkuNDkyMTlDMjAuMTI3NSA5LjQ5MjE5IDE5LjE0NjUgMTAuNDczMiAxOS4xNDY1IDExLjY4MzNDMTkuMTQ2NSAxMi44OTM0IDIwLjEyNzUgMTMuODc0NCAyMS4zMzc2IDEzLjg3NDRaIiBmaWxsPSJ3aGl0ZSIvPgo8L3N2Zz4K",this.supportedTransactionVersions=null,this._readyState=typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.Loadable,this._connecting=!1,this._wallet=null,this._publicKey=null,this._params=e}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get connected(){var e;return!!((e=this._wallet)!=null&&e.isLoggedIn)}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Loadable)throw new Ti;this._connecting=!0;let e;try{e=(await Promise.resolve().then(()=>require("./solanaEmbed.esm-TlHPGYbs.js"))).default}catch(n){throw new wb(n==null?void 0:n.message,n)}let t;try{t=window.torus||new e}catch(n){throw new ln(n==null?void 0:n.message,n)}if(!t.isInitialized)try{await t.init(this._params)}catch(n){throw new fc(n==null?void 0:n.message,n)}let i;try{i=await t.login()}catch(n){throw new vs(n==null?void 0:n.message,n)}let r;try{r=new N.PublicKey(i[0])}catch(n){throw new dr(n==null?void 0:n.message,n)}this._wallet=t,this._publicKey=r,this.emit("connect",r)}catch(e){throw this.emit("error",e),e}finally{this._connecting=!1}}async disconnect(){const e=this._wallet;if(e){this._wallet=null,this._publicKey=null;try{e.isLoggedIn&&await e.cleanUp()}catch(t){this.emit("error",new zo(t==null?void 0:t.message,t))}}this.emit("disconnect")}async sendTransaction(e,t,i={}){try{const r=this._wallet;if(!r)throw new Fe;try{const{signers:n,...o}=i;e=await this.prepareTransaction(e,t,o),n!=null&&n.length&&e.partialSign(...n),o.preflightCommitment=o.preflightCommitment||t.commitment;const{signature:a}=await r.signAndSendTransaction(e,o);return a}catch(n){throw n instanceof Tt?n:new Gi(n==null?void 0:n.message,n)}}catch(r){throw this.emit("error",r),r}}async signTransaction(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signTransaction(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signAllTransactions(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signAllTransactions(e)||e}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}async signMessage(e){try{const t=this._wallet;if(!t)throw new Fe;try{return await t.signMessage(e)}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}}}function Uc(s){switch(s){case"processed":case"confirmed":case"finalized":case void 0:return s;case"recent":return"processed";case"single":case"singleGossip":return"confirmed";case"max":case"root":return"finalized";default:return}}const Rb="https://api.mainnet-beta.solana.com";function Ub(s){return s.includes(Rb)?Mu:/\bdevnet\b/i.test(s)?Tb:/\btestnet\b/i.test(s)?Mb:/\blocalhost\b/i.test(s)||/\b127\.0\.0\.1\b/.test(s)?xb:Mu}var Ga;(function(s){s.Mainnet="solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",s.Devnet="solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",s.Deprecated_Mainnet="solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",s.Deprecated_Devnet="solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"})(Ga||(Ga={}));var ys;(function(s){s.signTransaction="solana_signTransaction",s.signMessage="solana_signMessage",s.signAndSendTransaction="solana_signAndSendTransaction",s.signAndSendAllTransactions="solana_signAndSendAllTransactions",s.signAllTransactions="solana_signAllTransactions"})(ys||(ys={}));const lt={Mainnet:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",Devnet:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",Deprecated_Mainnet:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ",Deprecated_Devnet:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"};let Lb=class extends m.IEvents{constructor(e){super()}};const xu=E.cjs.FIVE_SECONDS,xs={pulse:"heartbeat_pulse"};let Ff=class qf extends Lb{constructor(e){super(e),this.events=new te.eventsExports.EventEmitter,this.interval=xu,this.interval=(e==null?void 0:e.interval)||xu}static async init(e){const t=new qf(e);return await t.init(),t}async init(){await this.initialize()}stop(){clearInterval(this.intervalRef)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async initialize(){this.intervalRef=setInterval(()=>this.pulse(),E.cjs.toMiliseconds(this.interval))}pulse(){this.events.emit(xs.pulse)}};function zb(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function ft(s,...e){try{return zb(s(...e))}catch(t){return Promise.reject(t)}}function Fb(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function qb(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function Oa(s){if(Fb(s))return String(s);if(qb(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return Oa(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const Ul="base64:";function Bb(s){return typeof s=="string"?s:Ul+Vb(s)}function Hb(s){return typeof s!="string"||!s.startsWith(Ul)?s:Wb(s.slice(Ul.length))}function Wb(s){return globalThis.Buffer?N.dist.Buffer.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function Vb(s){return globalThis.Buffer?N.dist.Buffer.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Gt(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function Kb(...s){return Gt(s.join(":"))}function ca(s){return s=Gt(s),s?s+":":""}function Gb(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function Yb(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const Qb="memory",Zb=()=>{const s=new Map;return{name:Qb,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function Jb(s={}){const e={mounts:{"":s.driver||Zb()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(const h of e.mountpoints)if(c.startsWith(h))return{base:h,relativeKey:c.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,h)=>e.mountpoints.filter(u=>u.startsWith(c)||h&&c.startsWith(u)).map(u=>({relativeBase:c.length>u.length?c.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(c,h)=>{if(e.watching){h=Gt(h);for(const u of e.watchListeners)u(c,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const c in e.mounts)e.unwatch[c]=await Ou(e.mounts[c],r,c)}},o=async()=>{if(e.watching){for(const c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},a=(c,h,u)=>{const d=new Map,p=g=>{let f=d.get(g.base);return f||(f={driver:g.driver,base:g.base,items:[]},d.set(g.base,f)),f};for(const g of c){const f=typeof g=="string",b=Gt(f?g:g.key),y=f?void 0:g.value,w=f||!g.options?h:{...h,...g.options},v=t(b);p(v).items.push({key:b,value:y,relativeKey:v.relativeKey,options:w})}return Promise.all([...d.values()].map(g=>u(g))).then(g=>g.flat())},l={hasItem(c,h={}){c=Gt(c);const{relativeKey:u,driver:d}=t(c);return ft(d.hasItem,u,h)},getItem(c,h={}){c=Gt(c);const{relativeKey:u,driver:d}=t(c);return ft(d.getItem,u,h).then(p=>m.destr(p))},getItems(c,h={}){return a(c,h,u=>u.driver.getItems?ft(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(p=>({key:Kb(u.base,p.key),value:m.destr(p.value)}))):Promise.all(u.items.map(d=>ft(u.driver.getItem,d.relativeKey,d.options).then(p=>({key:d.key,value:m.destr(p)})))))},getItemRaw(c,h={}){c=Gt(c);const{relativeKey:u,driver:d}=t(c);return d.getItemRaw?ft(d.getItemRaw,u,h):ft(d.getItem,u,h).then(p=>Hb(p))},async setItem(c,h,u={}){if(h===void 0)return l.removeItem(c);c=Gt(c);const{relativeKey:d,driver:p}=t(c);p.setItem&&(await ft(p.setItem,d,Oa(h),u),p.watch||r("update",c))},async setItems(c,h){await a(c,h,async u=>{if(u.driver.setItems)return ft(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:Oa(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>ft(u.driver.setItem,d.relativeKey,Oa(d.value),d.options)))})},async setItemRaw(c,h,u={}){if(h===void 0)return l.removeItem(c,u);c=Gt(c);const{relativeKey:d,driver:p}=t(c);if(p.setItemRaw)await ft(p.setItemRaw,d,h,u);else if(p.setItem)await ft(p.setItem,d,Bb(h),u);else return;p.watch||r("update",c)},async removeItem(c,h={}){typeof h=="boolean"&&(h={removeMeta:h}),c=Gt(c);const{relativeKey:u,driver:d}=t(c);d.removeItem&&(await ft(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await ft(d.removeItem,u+"$",h),d.watch||r("remove",c))},async getMeta(c,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),c=Gt(c);const{relativeKey:u,driver:d}=t(c),p=Object.create(null);if(d.getMeta&&Object.assign(p,await ft(d.getMeta,u,h)),!h.nativeOnly){const g=await ft(d.getItem,u+"$",h).then(f=>m.destr(f));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(p,g))}return p},setMeta(c,h,u={}){return this.setItem(c+"$",h,u)},removeMeta(c,h={}){return this.removeItem(c+"$",h)},async getKeys(c,h={}){var b;c=ca(c);const u=i(c,!0);let d=[];const p=[];let g=!0;for(const y of u){(b=y.driver.flags)!=null&&b.maxDepth||(g=!1);const w=await ft(y.driver.getKeys,y.relativeBase,h);for(const v of w){const A=y.mountpoint+Gt(v);d.some(C=>A.startsWith(C))||p.push(A)}d=[y.mountpoint,...d.filter(v=>!v.startsWith(y.mountpoint))]}const f=h.maxDepth!==void 0&&!g;return p.filter(y=>(!f||Gb(y,h.maxDepth))&&Yb(y,c))},async clear(c,h={}){c=ca(c),await Promise.all(i(c,!1).map(async u=>{if(u.driver.clear)return ft(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(p=>u.driver.removeItem(p,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>Du(c)))},async watch(c){return await n(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,h){if(c=ca(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[c]=h,e.watching&&Promise.resolve(Ou(h,r,c)).then(u=>{e.unwatch[c]=u}).catch(console.error),l},async unmount(c,h=!0){var u,d;c=ca(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&((d=(u=e.unwatch)[c])==null||d.call(u),delete e.unwatch[c]),h&&await Du(e.mounts[c]),e.mountpoints=e.mountpoints.filter(p=>p!==c),delete e.mounts[c])},getMount(c=""){c=Gt(c)+":";const h=t(c);return{driver:h.driver,base:h.base}},getMounts(c="",h={}){return c=Gt(c),i(c,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(c,h={})=>l.getKeys(c,h),get:(c,h={})=>l.getItem(c,h),set:(c,h,u={})=>l.setItem(c,h,u),has:(c,h={})=>l.hasItem(c,h),del:(c,h={})=>l.removeItem(c,h),remove:(c,h={})=>l.removeItem(c,h)};return l}function Ou(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Du(s){typeof s.dispose=="function"&&await ft(s.dispose)}const Xb="idb-keyval";var ev=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=m.createStore(s.dbName,s.storeName)),{name:Xb,options:s,async hasItem(r){return!(typeof await m.get(t(r),i)>"u")},async getItem(r){return await m.get(t(r),i)??null},setItem(r,n){return m.set(t(r),n,i)},removeItem(r){return m.del(t(r),i)},getKeys(){return m.keys(i)},clear(){return m.clear(i)}}};const tv="WALLET_CONNECT_V2_INDEXED_DB",sv="keyvaluestorage";let iv=class{constructor(){this.indexedDb=Jb({driver:ev({dbName:tv,storeName:sv})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,m.safeJsonStringify(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var Lc=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof N.dist.global<"u"?N.dist.global:typeof self<"u"?self:{},Da={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof Lc<"u"&&Lc.localStorage?Da.exports=Lc.localStorage:typeof window<"u"&&window.localStorage?Da.exports=window.localStorage:Da.exports=new e})();function rv(s){var e;return[s[0],m.safeJsonParse((e=s[1])!=null?e:"")]}let nv=class{constructor(){this.localStorage=Da.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(rv)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return m.safeJsonParse(t)}async setItem(e,t){this.localStorage.setItem(e,m.safeJsonStringify(t))}async removeItem(e){this.localStorage.removeItem(e)}};const ov="wc_storage_version",ku=1,av=async(s,e,t)=>{const i=ov,r=await e.getItem(i);if(r&&r>=ku){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const l=a.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const c=await s.getItem(a);await e.setItem(a,c),o.push(a)}}await e.setItem(i,ku),t(e),cv(s,o)},cv=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let lv=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new nv;this.storage=e;try{const t=new iv;av(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};var hv=Object.defineProperty,uv=(s,e,t)=>e in s?hv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ju=(s,e,t)=>uv(s,typeof e!="symbol"?e+"":e,t);let dv=class extends m.IEvents{constructor(e){super(),this.opts=e,ju(this,"protocol","wc"),ju(this,"version",2)}};var pv=Object.defineProperty,gv=(s,e,t)=>e in s?pv(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,fv=(s,e,t)=>gv(s,e+"",t);let mv=class extends m.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,fv(this,"records",new Map)}},wv=class{constructor(e,t){this.logger=e,this.core=t}},yv=class extends m.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},bv=class extends m.IEvents{constructor(e){super()}},vv=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},Iv=class extends m.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},Ev=class extends m.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}},Av=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},Nv=class{constructor(e,t){this.projectId=e,this.logger=t}},_v=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};function Co(s,{strict:e=!0}={}){return!s||typeof s!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(s):s.startsWith("0x")}function Ru(s){return Co(s,{strict:!1})?Math.ceil((s.length-2)/2):s.length}const Bf="2.23.2";let kn={getDocsUrl:({docsBaseUrl:s,docsPath:e="",docsSlug:t})=>e?`${s??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${Bf}`},mc=class Ll extends Error{constructor(e,t={}){var a;const i=(()=>{var l;return t.cause instanceof Ll?t.cause.details:(l=t.cause)!=null&&l.message?t.cause.message:t.details})(),r=t.cause instanceof Ll&&t.cause.docsPath||t.docsPath,n=(a=kn.getDocsUrl)==null?void 0:a.call(kn,{...t,docsPath:r}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...kn.version?[`Version: ${kn.version}`]:[]].join(`
|
|
2
|
+
`);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=Bf}walk(e){return Hf(this,e)}};function Hf(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?Hf(s.cause,e):e?null:s}let Wf=class extends mc{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}};function _n(s,{dir:e,size:t=32}={}){return typeof s=="string"?Cv(s,{dir:e,size:t}):Sv(s,{dir:e,size:t})}function Cv(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new Wf({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function Sv(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new Wf({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}let $v=class extends mc{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}},Pv=class extends mc{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}};function Cn(s,{size:e}){if(Ru(s)>e)throw new Pv({givenSize:Ru(s),maxSize:e})}function zl(s,e={}){const{signed:t}=e;e.size&&Cn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function Tv(s,e={}){return Number(zl(s,e))}const Mv=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Fl(s,e={}){return typeof s=="number"||typeof s=="bigint"?Kf(s,e):typeof s=="string"?Dv(s,e):typeof s=="boolean"?xv(s,e):Vf(s,e)}function xv(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(Cn(t,{size:e.size}),_n(t,{size:e.size})):t}function Vf(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=Mv[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Cn(i,{size:e.size}),_n(i,{dir:"right",size:e.size})):i}function Kf(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new $v({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?_n(a,{size:i}):a}const Ov=new TextEncoder;function Dv(s,e={}){const t=Ov.encode(s);return Vf(t,e)}const kv=new TextEncoder;function jv(s,e={}){return typeof s=="number"||typeof s=="bigint"?Uv(s,e):typeof s=="boolean"?Rv(s,e):Co(s)?Gf(s,e):Yf(s,e)}function Rv(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(Cn(t,{size:e.size}),_n(t,{size:e.size})):t}const Ks={zero:48,nine:57,A:65,F:70,a:97,f:102};function Uu(s){if(s>=Ks.zero&&s<=Ks.nine)return s-Ks.zero;if(s>=Ks.A&&s<=Ks.F)return s-(Ks.A-10);if(s>=Ks.a&&s<=Ks.f)return s-(Ks.a-10)}function Gf(s,e={}){let t=s;e.size&&(Cn(t,{size:e.size}),t=_n(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const l=Uu(i.charCodeAt(a++)),c=Uu(i.charCodeAt(a++));if(l===void 0||c===void 0)throw new mc(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=l*16+c}return n}function Uv(s,e){const t=Kf(s,e);return Gf(t)}function Yf(s,e={}){const t=kv.encode(s);return typeof e.size=="number"?(Cn(t,{size:e.size}),_n(t,{dir:"right",size:e.size})):t}function Ya(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Lv(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Ho(s,...e){if(!Lv(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function zv(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Ya(s.outputLen),Ya(s.blockLen)}function ql(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Qf(s,e){Ho(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const la=BigInt(2**32-1),Lu=BigInt(32);function Fv(s,e=!1){return e?{h:Number(s&la),l:Number(s>>Lu&la)}:{h:Number(s>>Lu&la)|0,l:Number(s&la)|0}}function qv(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=Fv(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const Bv=(s,e,t)=>s<<t|e>>>32-t,Hv=(s,e,t)=>e<<t|s>>>32-t,Wv=(s,e,t)=>e<<t-32|s>>>64-t,Vv=(s,e,t)=>s<<t-32|e>>>64-t,Ir=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function Kv(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Gv(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Yv(s,e){return s<<32-e|s>>>e}const zu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Qv(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Fu(s){for(let e=0;e<s.length;e++)s[e]=Qv(s[e])}function Zv(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function Vh(s){return typeof s=="string"&&(s=Zv(s)),Ho(s),s}function Jv(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Ho(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}let Zf=class{clone(){return this._cloneInto()}};function Jf(s){const e=i=>s().update(Vh(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Xv(s=32){if(Ir&&typeof Ir.getRandomValues=="function")return Ir.getRandomValues(new Uint8Array(s));if(Ir&&typeof Ir.randomBytes=="function")return Ir.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Xf=[],em=[],tm=[],e0=BigInt(0),jn=BigInt(1),t0=BigInt(2),s0=BigInt(7),i0=BigInt(256),r0=BigInt(113);for(let s=0,e=jn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Xf.push(2*(5*i+t)),em.push((s+1)*(s+2)/2%64);let r=e0;for(let n=0;n<7;n++)e=(e<<jn^(e>>s0)*r0)%i0,e&t0&&(r^=jn<<(jn<<BigInt(n))-jn);tm.push(r)}const[n0,o0]=qv(tm,!0),qu=(s,e,t)=>t>32?Wv(s,e,t):Bv(s,e,t),Bu=(s,e,t)=>t>32?Vv(s,e,t):Hv(s,e,t);function a0(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=qu(c,h,1)^t[a],d=Bu(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=em[o],l=qu(r,n,a),c=Bu(r,n,a),h=Xf[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=n0[i],s[1]^=o0[i]}t.fill(0)}let c0=class sm extends Zf{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Ya(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Kv(this.state)}keccak(){zu||Fu(this.state32),a0(this.state32,this.rounds),zu||Fu(this.state32),this.posOut=0,this.pos=0}update(e){ql(this);const{blockLen:t,state:i}=this;e=Vh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){ql(this,!1),Ho(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Ya(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Qf(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new sm(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const l0=(s,e,t)=>Jf(()=>new c0(e,s,t)),h0=l0(1,136,256/8);function im(s,e){const t=e||"hex",i=h0(Co(s,{strict:!1})?jv(s):s);return t==="bytes"?i:Fl(i)}let u0=class extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}};const zc=new u0(8192);function d0(s,e){if(zc.has(`${s}.${e}`))return zc.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=im(Yf(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return zc.set(`${s}.${e}`,n),n}function p0(s){const e=im(`0x${s.substring(4)}`).substring(26);return d0(`0x${e}`)}async function g0({hash:s,signature:e}){const t=Co(s)?s:Fl(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-BjuZX5cP.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:c,s:h,v:u,yParity:d}=e,p=Number(d??u),g=Hu(p);return new i.Signature(zl(c),zl(h)).addRecoveryBit(g)}const o=Co(e)?e:Fl(e),a=Tv(`0x${o.slice(130)}`),l=Hu(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(l)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function Hu(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function f0({hash:s,signature:e}){return p0(await g0({hash:s,signature:e}))}var rm=te.requireElliptic();const nm=":";function gn(s){const[e,t]=s.split(nm);return{namespace:e,reference:t}}function m0(s){const[e,t,i]=s.split(nm);return{namespace:e,reference:t,address:i}}function om(s,e){return s.includes(":")?[s]:e.chains||[]}const w0="ReactNative",as={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},y0="js";function Qa(){return typeof N.dist.process<"u"&&typeof N.dist.process.versions<"u"&&typeof N.dist.process.versions.node<"u"}function Mi(){return!E.getDocument_1()&&!!E.getNavigator_1()&&navigator.product===w0}function b0(){return Mi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="android"}function v0(){return Mi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="ios"}function Wo(){return!Qa()&&!!E.getNavigator_1()&&!!E.getDocument_1()}function Vo(){return Mi()?as.reactNative:Qa()?as.node:Wo()?as.browser:as.unknown}function Wu(){var s;try{return Mi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Application)<"u"?(s=N.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function I0(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function am(){return E.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function E0(){if(Vo()===as.reactNative&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"){const{OS:t,Version:i}=N.dist.global.Platform;return[t,i].join("-")}const s=m.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function A0(){var s;const e=Vo();return e===as.browser?[e,((s=E.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function cm(s,e,t){const i=E0(),r=A0();return[[s,e].join("-"),[y0,t].join("-"),i,r].join("/")}function N0({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:l}){const c=t.split("?"),h=cm(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:l||void 0,bundleId:a||void 0},d=I0(c[1]||"",u);return c[0]+"?"+d}function Yi(s,e){return s.filter(t=>e.includes(t)).length===s.length}function lm(s){return Object.fromEntries(s.entries())}function hm(s){return new Map(Object.entries(s))}function Fi(s=E.cjs.FIVE_MINUTES,e){const t=E.cjs.toMiliseconds(s||E.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,l)=>{if(o)return a(o);n=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),l(c)},t),i=a,r=l})}}function vi(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function um(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function _0(s){return um("topic",s)}function C0(s){return um("id",s)}function dm(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function at(s,e){return E.cjs.fromMiliseconds(Date.now()+E.cjs.toMiliseconds(s))}function gi(s){return Date.now()>=E.cjs.toMiliseconds(s)}function Ae(s,e){return`${s}${e?`:${e}`:""}`}function ka(s=[],e=[]){return[...new Set([...s,...e])]}async function S0({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=$0(n,s,e),a=Vo();if(a===as.browser){if(!((i=E.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}P0(o)}else a===as.reactNative&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u"&&await N.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function $0(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${O0(i,!0)}`}else r=`${r}/wc?${i}`;return r}function P0(s){let e="_self";x0()?e="_top":(M0()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function T0(s,e){let t="";try{if(Wo()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Vu(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Ku(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function Kh(){return typeof N.dist.process<"u"&&N.dist.process.env.IS_VITEST==="true"}function M0(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function x0(){try{return window.self!==window.top}catch{return!1}}function O0(s,e=!1){const t=N.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function pm(s){return N.dist.Buffer.from(s,"base64").toString("utf-8")}function D0(s){return new Promise(e=>setTimeout(e,s))}function So(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function k0(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function wc(s,...e){if(!k0(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function Gh(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");So(s.outputLen),So(s.blockLen)}function yn(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function gm(s,e){wc(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const ha=BigInt(2**32-1),Gu=BigInt(32);function j0(s,e=!1){return e?{h:Number(s&ha),l:Number(s>>Gu&ha)}:{h:Number(s>>Gu&ha)|0,l:Number(s&ha)|0}}function R0(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=j0(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const U0=(s,e,t)=>s<<t|e>>>32-t,L0=(s,e,t)=>e<<t|s>>>32-t,z0=(s,e,t)=>e<<t-32|s>>>64-t,F0=(s,e,t)=>s<<t-32|e>>>64-t,Er=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function q0(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function Fc(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Os(s,e){return s<<32-e|s>>>e}const Yu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function B0(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Qu(s){for(let e=0;e<s.length;e++)s[e]=B0(s[e])}function H0(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function bn(s){return typeof s=="string"&&(s=H0(s)),wc(s),s}let Yh=class{clone(){return this._cloneInto()}};function fm(s){const e=i=>s().update(bn(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function Ko(s=32){if(Er&&typeof Er.getRandomValues=="function")return Er.getRandomValues(new Uint8Array(s));if(Er&&typeof Er.randomBytes=="function")return Er.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const mm=[],wm=[],ym=[],W0=BigInt(0),Rn=BigInt(1),V0=BigInt(2),K0=BigInt(7),G0=BigInt(256),Y0=BigInt(113);for(let s=0,e=Rn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],mm.push(2*(5*i+t)),wm.push((s+1)*(s+2)/2%64);let r=W0;for(let n=0;n<7;n++)e=(e<<Rn^(e>>K0)*Y0)%G0,e&V0&&(r^=Rn<<(Rn<<BigInt(n))-Rn);ym.push(r)}const[Q0,Z0]=R0(ym,!0),Zu=(s,e,t)=>t>32?z0(s,e,t):U0(s,e,t),Ju=(s,e,t)=>t>32?F0(s,e,t):L0(s,e,t);function J0(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=Zu(c,h,1)^t[a],d=Ju(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=wm[o],l=Zu(r,n,a),c=Ju(r,n,a),h=mm[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=Q0[i],s[1]^=Z0[i]}t.fill(0)}let X0=class bm extends Yh{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,So(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=q0(this.state)}keccak(){Yu||Qu(this.state32),J0(this.state32,this.rounds),Yu||Qu(this.state32),this.posOut=0,this.pos=0}update(e){yn(this);const{blockLen:t,state:i}=this;e=bn(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){yn(this,!1),wc(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return So(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(gm(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new bm(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const eI=(s,e,t)=>fm(()=>new X0(e,s,t)),tI=eI(1,136,256/8),sI="https://rpc.walletconnect.org/v1";function vm(s){const e=`Ethereum Signed Message:
|
|
3
3
|
${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+N.dist.Buffer.from(tI(t)).toString("hex")}async function iI(s,e,t,i,r,n){switch(t.t){case"eip191":return await rI(s,e,t.s);case"eip1271":return await nI(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}async function rI(s,e,t){return(await f0({hash:vm(e),signature:t})).toLowerCase()===s.toLowerCase()}async function nI(s,e,t,i,r,n){const o=gn(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",l="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=t.substring(2),u=vm(e).substring(2),d=a+u+l+c+h,p=await fetch(`${n||sI}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:oI(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:d},"latest"]})}),{result:g}=await p.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function oI(){return Date.now()+Math.floor(Math.random()*1e3)}var aI=Object.defineProperty,cI=Object.defineProperties,lI=Object.getOwnPropertyDescriptors,Xu=Object.getOwnPropertySymbols,hI=Object.prototype.hasOwnProperty,uI=Object.prototype.propertyIsEnumerable,ed=(s,e,t)=>e in s?aI(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,dI=(s,e)=>{for(var t in e||(e={}))hI.call(e,t)&&ed(s,t,e[t]);if(Xu)for(var t of Xu(e))uI.call(e,t)&&ed(s,t,e[t]);return s},pI=(s,e)=>cI(s,lI(e));const gI="did:pkh:",Qh=s=>s==null?void 0:s.split(":"),fI=s=>{const e=s&&Qh(s);if(e)return s.includes(gI)?e[3]:e[1]},Bl=s=>{const e=s&&Qh(s);if(e)return e[2]+":"+e[3]},Za=s=>{const e=s&&Qh(s);if(e)return e.pop()};async function td(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=Im(r,r.iss),o=Za(r.iss);return await iI(o,n,i,Bl(r.iss),t)}const Im=(s,e)=>{const t=`${s.domain} wants you to sign in with your Ethereum account:`,i=Za(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=s.statement||void 0;const n=`URI: ${s.aud||s.uri}`,o=`Version: ${s.version}`,a=`Chain ID: ${fI(e)}`,l=`Nonce: ${s.nonce}`,c=`Issued At: ${s.iat}`,h=s.exp?`Expiration Time: ${s.exp}`:void 0,u=s.nbf?`Not Before: ${s.nbf}`:void 0,d=s.requestId?`Request ID: ${s.requestId}`:void 0,p=s.resources?`Resources:${s.resources.map(f=>`
|
|
4
4
|
- ${f}`).join("")}`:void 0,g=ja(s.resources);if(g){const f=$o(g);r=NI(r,f)}return[t,i,"",r,"",n,o,a,l,c,h,u,d,p].filter(f=>f!=null).join(`
|
|
5
5
|
`)};function mI(s){return N.dist.Buffer.from(JSON.stringify(s)).toString("base64")}function wI(s){return JSON.parse(N.dist.Buffer.from(s,"base64").toString("utf-8"))}function sr(s){if(!s)throw new Error("No recap provided, value is undefined");if(!s.att)throw new Error("No `att` property found");const e=Object.keys(s.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=s.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(r=>{const n=i[r];if(!Array.isArray(n))throw new Error(`Ability limits ${r} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${r} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${r}) must be an array of objects, found: ${o}`)})})})}function yI(s,e,t,i={}){return t==null||t.sort((r,n)=>r.localeCompare(n)),{att:{[s]:bI(e,t,i)}}}function bI(s,e,t={}){e=e==null?void 0:e.sort((r,n)=>r.localeCompare(n));const i=e.map(r=>({[`${s}/${r}`]:[t]}));return Object.assign({},...i)}function Em(s){return sr(s),`urn:recap:${mI(s).replace(/=/g,"")}`}function $o(s){const e=wI(s.replace("urn:recap:",""));return sr(e),e}function vI(s,e,t){const i=yI(s,e,t);return Em(i)}function II(s){return s&&s.includes("urn:recap:")}function EI(s,e){const t=$o(s),i=$o(e),r=AI(t,i);return Em(r)}function AI(s,e){sr(s),sr(e);const t=Object.keys(s.att).concat(Object.keys(e.att)).sort((r,n)=>r.localeCompare(n)),i={att:{}};return t.forEach(r=>{var n,o;Object.keys(((n=s.att)==null?void 0:n[r])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[r])||{})).sort((a,l)=>a.localeCompare(l)).forEach(a=>{var l,c;i.att[r]=pI(dI({},i.att[r]),{[a]:((l=s.att[r])==null?void 0:l[a])||((c=e.att[r])==null?void 0:c[a])})})}),i}function NI(s="",e){sr(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(s.includes(t))return s;const i=[];let r=0;Object.keys(e.att).forEach(a=>{const l=Object.keys(e.att[a]).map(u=>({ability:u.split("/")[0],action:u.split("/")[1]}));l.sort((u,d)=>u.action.localeCompare(d.action));const c={};l.forEach(u=>{c[u.ability]||(c[u.ability]=[]),c[u.ability].push(u.action)});const h=Object.keys(c).map(u=>(r++,`(${r}) '${u}': '${c[u].join("', '")}' for '${a}'.`));i.push(h.join(", ").replace(".,","."))});const n=i.join(" "),o=`${t}${n}`;return`${s?s+" ":""}${o}`}function sd(s){var e;const t=$o(s);sr(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(r=>r.split("/")[1]):[]}function id(s){const e=$o(s);sr(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(r=>{var n;(n=r==null?void 0:r[0])!=null&&n.chains&&t.push(r[0].chains)})}),[...new Set(t.flat())]}function ja(s){if(!s)return;const e=s==null?void 0:s[s.length-1];return II(e)?e:void 0}function qc(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function Am(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function ns(s,...e){if(!Am(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function rd(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function _I(s,e){ns(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function nd(s){if(typeof s!="boolean")throw new Error(`boolean expected, not ${s}`)}const _i=s=>new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)),CI=s=>new DataView(s.buffer,s.byteOffset,s.byteLength),SI=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!SI)throw new Error("Non little-endian hardware is not supported");function $I(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function Hl(s){if(typeof s=="string")s=$I(s);else if(Am(s))s=Wl(s);else throw new Error("Uint8Array expected, got "+typeof s);return s}function PI(s,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(s,e)}function TI(s,e){if(s.length!==e.length)return!1;let t=0;for(let i=0;i<s.length;i++)t|=s[i]^e[i];return t===0}const MI=(s,e)=>{function t(i,...r){if(ns(i),s.nonceLength!==void 0){const c=r[0];if(!c)throw new Error("nonce / iv required");s.varSizeNonce?ns(c):ns(c,s.nonceLength)}const n=s.tagLength;n&&r[1]!==void 0&&ns(r[1]);const o=e(i,...r),a=(c,h)=>{if(h!==void 0){if(c!==2)throw new Error("cipher output not supported");ns(h)}};let l=!1;return{encrypt(c,h){if(l)throw new Error("cannot encrypt() twice with same key + nonce");return l=!0,ns(c),a(o.encrypt.length,h),o.encrypt(c,h)},decrypt(c,h){if(ns(c),n&&c.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,h),o.decrypt(c,h)}}}return Object.assign(t,s),t};function od(s,e,t=!0){if(e===void 0)return new Uint8Array(s);if(e.length!==s)throw new Error("invalid output length, expected "+s+", got: "+e.length);if(t&&!xI(e))throw new Error("invalid output, must be aligned");return e}function ad(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n);s.setUint32(e+4,o,i),s.setUint32(e+0,a,i)}function xI(s){return s.byteOffset%4===0}function Wl(s){return Uint8Array.from(s)}function vn(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}const Nm=s=>Uint8Array.from(s.split("").map(e=>e.charCodeAt(0))),OI=Nm("expand 16-byte k"),DI=Nm("expand 32-byte k"),kI=_i(OI),jI=_i(DI);function ge(s,e){return s<<e|s>>>32-e}function Vl(s){return s.byteOffset%4===0}const ua=64,RI=16,_m=2**32-1,cd=new Uint32Array;function UI(s,e,t,i,r,n,o,a){const l=r.length,c=new Uint8Array(ua),h=_i(c),u=Vl(r)&&Vl(n),d=u?_i(r):cd,p=u?_i(n):cd;for(let g=0;g<l;o++){if(s(e,t,i,h,o,a),o>=_m)throw new Error("arx: counter overflow");const f=Math.min(ua,l-g);if(u&&f===ua){const b=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let y=0,w;y<RI;y++)w=b+y,p[w]=d[w]^h[y];g+=ua;continue}for(let b=0,y;b<f;b++)y=g+b,n[y]=r[y]^c[b];g+=f}}function LI(s,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:r,counterRight:n,rounds:o}=PI({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof s!="function")throw new Error("core must be a function");return qc(r),qc(o),nd(n),nd(t),(a,l,c,h,u=0)=>{ns(a),ns(l),ns(c);const d=c.length;if(h===void 0&&(h=new Uint8Array(d)),ns(h),qc(u),u<0||u>=_m)throw new Error("arx: counter overflow");if(h.length<d)throw new Error(`arx: output (${h.length}) is shorter than data (${d})`);const p=[];let g=a.length,f,b;if(g===32)p.push(f=Wl(a)),b=jI;else if(g===16&&t)f=new Uint8Array(32),f.set(a),f.set(a,16),b=kI,p.push(f);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);Vl(l)||p.push(l=Wl(l));const y=_i(f);if(i){if(l.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(b,y,_i(l.subarray(0,16)),y),l=l.subarray(16)}const w=16-r;if(w!==l.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const A=new Uint8Array(12);A.set(l,n?0:12-l.length),l=A,p.push(l)}const v=_i(l);return UI(s,b,y,v,c,h,u,o),vn(...p),h}}const It=(s,e)=>s[e++]&255|(s[e++]&255)<<8;let zI=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=Hl(e),ns(e,32);const t=It(e,0),i=It(e,2),r=It(e,4),n=It(e,6),o=It(e,8),a=It(e,10),l=It(e,12),c=It(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|r<<6)&7939,this.r[3]=(r>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|l<<5)&8065,this.r[8]=(l>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let h=0;h<8;h++)this.pad[h]=It(e,16+2*h)}process(e,t,i=!1){const r=i?0:2048,{h:n,r:o}=this,a=o[0],l=o[1],c=o[2],h=o[3],u=o[4],d=o[5],p=o[6],g=o[7],f=o[8],b=o[9],y=It(e,t+0),w=It(e,t+2),v=It(e,t+4),A=It(e,t+6),C=It(e,t+8),P=It(e,t+10),T=It(e,t+12),O=It(e,t+14);let S=n[0]+(y&8191),M=n[1]+((y>>>13|w<<3)&8191),$=n[2]+((w>>>10|v<<6)&8191),U=n[3]+((v>>>7|A<<9)&8191),L=n[4]+((A>>>4|C<<12)&8191),B=n[5]+(C>>>1&8191),H=n[6]+((C>>>14|P<<2)&8191),z=n[7]+((P>>>11|T<<5)&8191),W=n[8]+((T>>>8|O<<8)&8191),V=n[9]+(O>>>5|r),_=0,F=_+S*a+M*(5*b)+$*(5*f)+U*(5*g)+L*(5*p);_=F>>>13,F&=8191,F+=B*(5*d)+H*(5*u)+z*(5*h)+W*(5*c)+V*(5*l),_+=F>>>13,F&=8191;let Q=_+S*l+M*a+$*(5*b)+U*(5*f)+L*(5*g);_=Q>>>13,Q&=8191,Q+=B*(5*p)+H*(5*d)+z*(5*u)+W*(5*h)+V*(5*c),_+=Q>>>13,Q&=8191;let G=_+S*c+M*l+$*a+U*(5*b)+L*(5*f);_=G>>>13,G&=8191,G+=B*(5*g)+H*(5*p)+z*(5*d)+W*(5*u)+V*(5*h),_+=G>>>13,G&=8191;let Ie=_+S*h+M*c+$*l+U*a+L*(5*b);_=Ie>>>13,Ie&=8191,Ie+=B*(5*f)+H*(5*g)+z*(5*p)+W*(5*d)+V*(5*u),_+=Ie>>>13,Ie&=8191;let ce=_+S*u+M*h+$*c+U*l+L*a;_=ce>>>13,ce&=8191,ce+=B*(5*b)+H*(5*f)+z*(5*g)+W*(5*p)+V*(5*d),_+=ce>>>13,ce&=8191;let xe=_+S*d+M*u+$*h+U*c+L*l;_=xe>>>13,xe&=8191,xe+=B*a+H*(5*b)+z*(5*f)+W*(5*g)+V*(5*p),_+=xe>>>13,xe&=8191;let nt=_+S*p+M*d+$*u+U*h+L*c;_=nt>>>13,nt&=8191,nt+=B*l+H*a+z*(5*b)+W*(5*f)+V*(5*g),_+=nt>>>13,nt&=8191;let qe=_+S*g+M*p+$*d+U*u+L*h;_=qe>>>13,qe&=8191,qe+=B*c+H*l+z*a+W*(5*b)+V*(5*f),_+=qe>>>13,qe&=8191;let Ye=_+S*f+M*g+$*p+U*d+L*u;_=Ye>>>13,Ye&=8191,Ye+=B*h+H*c+z*l+W*a+V*(5*b),_+=Ye>>>13,Ye&=8191;let Be=_+S*b+M*f+$*g+U*p+L*d;_=Be>>>13,Be&=8191,Be+=B*u+H*h+z*c+W*l+V*a,_+=Be>>>13,Be&=8191,_=(_<<2)+_|0,_=_+F|0,F=_&8191,_=_>>>13,Q+=_,n[0]=F,n[1]=Q,n[2]=G,n[3]=Ie,n[4]=ce,n[5]=xe,n[6]=nt,n[7]=qe,n[8]=Ye,n[9]=Be}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=r,r=e[a]>>>13,e[a]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,i[0]=e[0]+5,r=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+r,r=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(r^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+t[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+t[a]|0)+(o>>>16)|0,e[a]=o&65535;vn(i)}update(e){rd(this);const{buffer:t,blockLen:i}=this;e=Hl(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){for(;i<=r-n;n+=i)this.process(e,n);continue}t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){vn(this.h,this.r,this.buffer,this.pad)}digestInto(e){rd(this),_I(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}};function FI(s){const e=(i,r)=>s(r).update(Hl(i)).digest(),t=s(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}const qI=FI(s=>new zI(s));function BI(s,e,t,i,r,n=20){let o=s[0],a=s[1],l=s[2],c=s[3],h=e[0],u=e[1],d=e[2],p=e[3],g=e[4],f=e[5],b=e[6],y=e[7],w=r,v=t[0],A=t[1],C=t[2],P=o,T=a,O=l,S=c,M=h,$=u,U=d,L=p,B=g,H=f,z=b,W=y,V=w,_=v,F=A,Q=C;for(let Ie=0;Ie<n;Ie+=2)P=P+M|0,V=ge(V^P,16),B=B+V|0,M=ge(M^B,12),P=P+M|0,V=ge(V^P,8),B=B+V|0,M=ge(M^B,7),T=T+$|0,_=ge(_^T,16),H=H+_|0,$=ge($^H,12),T=T+$|0,_=ge(_^T,8),H=H+_|0,$=ge($^H,7),O=O+U|0,F=ge(F^O,16),z=z+F|0,U=ge(U^z,12),O=O+U|0,F=ge(F^O,8),z=z+F|0,U=ge(U^z,7),S=S+L|0,Q=ge(Q^S,16),W=W+Q|0,L=ge(L^W,12),S=S+L|0,Q=ge(Q^S,8),W=W+Q|0,L=ge(L^W,7),P=P+$|0,Q=ge(Q^P,16),z=z+Q|0,$=ge($^z,12),P=P+$|0,Q=ge(Q^P,8),z=z+Q|0,$=ge($^z,7),T=T+U|0,V=ge(V^T,16),W=W+V|0,U=ge(U^W,12),T=T+U|0,V=ge(V^T,8),W=W+V|0,U=ge(U^W,7),O=O+L|0,_=ge(_^O,16),B=B+_|0,L=ge(L^B,12),O=O+L|0,_=ge(_^O,8),B=B+_|0,L=ge(L^B,7),S=S+M|0,F=ge(F^S,16),H=H+F|0,M=ge(M^H,12),S=S+M|0,F=ge(F^S,8),H=H+F|0,M=ge(M^H,7);let G=0;i[G++]=o+P|0,i[G++]=a+T|0,i[G++]=l+O|0,i[G++]=c+S|0,i[G++]=h+M|0,i[G++]=u+$|0,i[G++]=d+U|0,i[G++]=p+L|0,i[G++]=g+B|0,i[G++]=f+H|0,i[G++]=b+z|0,i[G++]=y+W|0,i[G++]=w+V|0,i[G++]=v+_|0,i[G++]=A+F|0,i[G++]=C+Q|0}const HI=LI(BI,{counterRight:!1,counterLength:4,allowShortKeys:!1}),WI=new Uint8Array(16),ld=(s,e)=>{s.update(e);const t=e.length%16;t&&s.update(WI.subarray(t))},VI=new Uint8Array(32);function hd(s,e,t,i,r){const n=s(e,t,VI),o=qI.create(n);r&&ld(o,r),ld(o,i);const a=new Uint8Array(16),l=CI(a);ad(l,0,BigInt(r?r.length:0),!0),ad(l,8,BigInt(i.length),!0),o.update(a);const c=o.digest();return vn(n,a),c}const KI=s=>(e,t,i)=>({encrypt(r,n){const o=r.length;n=od(o+16,n,!1),n.set(r);const a=n.subarray(0,-16);s(e,t,a,a,1);const l=hd(s,e,t,a,i);return n.set(l,o),vn(l),n},decrypt(r,n){n=od(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),l=hd(s,e,t,o,i);if(!TI(a,l))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),s(e,t,n,n,1),vn(l),n}}),Cm=MI({blockSize:64,nonceLength:12,tagLength:16},KI(HI));let Sm=class extends Yh{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Gh(e);const i=bn(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return yn(this),this.iHash.update(e),this}digestInto(e){yn(this),wc(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const Zh=(s,e,t)=>new Sm(s,e).update(t).digest();Zh.create=(s,e)=>new Sm(s,e);function GI(s,e,t){return Gh(s),t===void 0&&(t=new Uint8Array(s.outputLen)),Zh(s,bn(t),bn(e))}const Bc=new Uint8Array([0]),ud=new Uint8Array;function YI(s,e,t,i=32){if(Gh(s),So(i),i>255*s.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/s.outputLen);t===void 0&&(t=ud);const n=new Uint8Array(r*s.outputLen),o=Zh.create(s,e),a=o._cloneInto(),l=new Uint8Array(o.outputLen);for(let c=0;c<r;c++)Bc[0]=c+1,a.update(c===0?ud:l).update(t).update(Bc).digestInto(l),n.set(l,s.outputLen*c),o._cloneInto(a);return o.destroy(),a.destroy(),l.fill(0),Bc.fill(0),n.slice(0,i)}const QI=(s,e,t,i,r)=>YI(s,GI(s,e,t),i,r);function ZI(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),l=i?4:0,c=i?0:4;s.setUint32(e+l,o,i),s.setUint32(e+c,a,i)}function JI(s,e,t){return s&e^~s&t}function XI(s,e,t){return s&e^s&t^e&t}let e1=class extends Yh{constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Fc(this.buffer)}update(e){yn(this);const{view:t,buffer:i,blockLen:r}=this;e=bn(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const l=Fc(e);for(;r<=n-o;o+=r)this.process(l,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){yn(this),gm(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(i,0),o=0);for(let u=o;u<r;u++)t[u]=0;ZI(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=Fc(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)a.setUint32(4*u,h[u],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.length=r,e.pos=a,e.finished=n,e.destroyed=o,r%t&&e.buffer.set(i),e}};const t1=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),oi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ai=new Uint32Array(64);let s1=class extends e1{constructor(){super(64,32,8,!1),this.A=oi[0]|0,this.B=oi[1]|0,this.C=oi[2]|0,this.D=oi[3]|0,this.E=oi[4]|0,this.F=oi[5]|0,this.G=oi[6]|0,this.H=oi[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:l}=this;return[e,t,i,r,n,o,a,l]}set(e,t,i,r,n,o,a,l){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let u=0;u<16;u++,t+=4)ai[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=ai[u-15],p=ai[u-2],g=Os(d,7)^Os(d,18)^d>>>3,f=Os(p,17)^Os(p,19)^p>>>10;ai[u]=f+ai[u-7]+g+ai[u-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:l,G:c,H:h}=this;for(let u=0;u<64;u++){const d=Os(a,6)^Os(a,11)^Os(a,25),p=h+d+JI(a,l,c)+t1[u]+ai[u]|0,g=(Os(i,2)^Os(i,13)^Os(i,22))+XI(i,r,n)|0;h=c,c=l,l=a,a=o+p|0,o=n,n=r,r=i,i=p+g|0}i=i+this.A|0,r=r+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(i,r,n,o,a,l,c,h)}roundClean(){ai.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const yc=fm(()=>new s1);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const $m=BigInt(0);function Jh(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Pm(s){if(!Jh(s))throw new Error("Uint8Array expected")}const i1=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function r1(s){Pm(s);let e="";for(let t=0;t<s.length;t++)e+=i1[s[t]];return e}function n1(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?$m:BigInt("0x"+s)}const Gs={_0:48,_9:57,A:65,F:70,a:97,f:102};function dd(s){if(s>=Gs._0&&s<=Gs._9)return s-Gs._0;if(s>=Gs.A&&s<=Gs.F)return s-(Gs.A-10);if(s>=Gs.a&&s<=Gs.f)return s-(Gs.a-10)}function Tm(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=dd(s.charCodeAt(n)),a=dd(s.charCodeAt(n+1));if(o===void 0||a===void 0){const l=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+n)}i[r]=o*16+a}return i}function pd(s){return Pm(s),n1(r1(Uint8Array.from(s).reverse()))}function o1(s,e){return Tm(s.toString(16).padStart(e*2,"0"))}function a1(s,e){return o1(s,e).reverse()}function gd(s,e,t){let i;if(typeof e=="string")try{i=Tm(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(Jh(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}const Hc=s=>typeof s=="bigint"&&$m<=s;function c1(s,e,t){return Hc(s)&&Hc(e)&&Hc(t)&&e<=s&&s<t}function fd(s,e,t,i){if(!c1(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}const l1={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||Jh(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function h1(s,e,t={}){const i=(r,n,o)=>{const a=l1[n];if(typeof a!="function")throw new Error("invalid validator function");const l=s[r];if(!(o&&l===void 0)&&!a(l,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+l)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}const hn=BigInt(0),da=BigInt(1);function Mm(s,e){const t=s%e;return t>=hn?t:e+t}function u1(s,e,t){if(e<hn)throw new Error("invalid exponent, negatives unsupported");if(t<=hn)throw new Error("invalid modulus");if(t===da)return hn;let i=da;for(;e>hn;)e&da&&(i=i*s%t),s=s*s%t,e>>=da;return i}function Ts(s,e,t){let i=s;for(;e-- >hn;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const Ar=BigInt(0),Wc=BigInt(1);function d1(s){return h1(s,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...s})}function p1(s){const e=d1(s),{P:t}=e,i=w=>Mm(w,t),r=e.montgomeryBits,n=Math.ceil(r/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),l=e.powPminus2||(w=>u1(w,t-BigInt(2),t));function c(w,v,A){const C=i(w*(v-A));return v=i(v-C),A=i(A+C),[v,A]}const h=(e.a-BigInt(2))/BigInt(4);function u(w,v){fd("u",w,Ar,t),fd("scalar",v,Ar,t);const A=v,C=w;let P=Wc,T=Ar,O=w,S=Wc,M=Ar,$;for(let L=BigInt(r-1);L>=Ar;L--){const B=A>>L&Wc;M^=B,$=c(M,P,O),P=$[0],O=$[1],$=c(M,T,S),T=$[0],S=$[1],M=B;const H=P+T,z=i(H*H),W=P-T,V=i(W*W),_=z-V,F=O+S,Q=O-S,G=i(Q*H),Ie=i(F*W),ce=G+Ie,xe=G-Ie;O=i(ce*ce),S=i(C*i(xe*xe)),P=i(z*V),T=i(_*(z+i(h*_)))}$=c(M,P,O),P=$[0],O=$[1],$=c(M,T,S),T=$[0],S=$[1];const U=l(T);return i(P*U)}function d(w){return a1(i(w),n)}function p(w){const v=gd("u coordinate",w,n);return o===32&&(v[31]&=127),pd(v)}function g(w){const v=gd("scalar",w),A=v.length;if(A!==n&&A!==o){let C=""+n+" or "+o;throw new Error("invalid scalar, expected "+C+" bytes, got "+A)}return pd(a(v))}function f(w,v){const A=p(v),C=g(w),P=u(A,C);if(P===Ar)throw new Error("invalid private or public key received");return d(P)}const b=d(e.Gu);function y(w){return f(w,b)}return{scalarMult:f,scalarMultBase:y,getSharedSecret:(w,v)=>f(w,v),getPublicKey:w=>y(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:b}}const Kl=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const g1=BigInt(1),md=BigInt(2),f1=BigInt(3),m1=BigInt(5);BigInt(8);function w1(s){const e=BigInt(10),t=BigInt(20),i=BigInt(40),r=BigInt(80),n=Kl,o=s*s%n*s%n,a=Ts(o,md,n)*o%n,l=Ts(a,g1,n)*s%n,c=Ts(l,m1,n)*l%n,h=Ts(c,e,n)*c%n,u=Ts(h,t,n)*h%n,d=Ts(u,i,n)*u%n,p=Ts(d,r,n)*d%n,g=Ts(p,r,n)*d%n,f=Ts(g,e,n)*c%n;return{pow_p_5_8:Ts(f,md,n)*s%n,b2:o}}function y1(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const Gl=p1({P:Kl,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:s=>{const e=Kl,{pow_p_5_8:t,b2:i}=w1(s);return Mm(Ts(t,f1,e)*i,e)},adjustScalarBytes:y1,randomBytes:Ko}),xm="base10",Rt="base16",Ii="base64pad",Un="base64url",Go="utf8",Om=0,ii=1,Yo=2,b1=0,wd=1,po=12,Xh=32;function v1(){const s=Gl.utils.randomPrivateKey(),e=Gl.getPublicKey(s);return{privateKey:m.toString(s,Rt),publicKey:m.toString(e,Rt)}}function Yl(){const s=Ko(Xh);return m.toString(s,Rt)}function I1(s,e){const t=Gl.getSharedSecret(m.fromString(s,Rt),m.fromString(e,Rt)),i=QI(yc,t,void 0,void 0,Xh);return m.toString(i,Rt)}function Ra(s){const e=yc(m.fromString(s,Rt));return m.toString(e,Rt)}function ti(s){const e=yc(m.fromString(s,Go));return m.toString(e,Rt)}function Dm(s){return m.fromString(`${s}`,xm)}function ir(s){return Number(m.toString(s,xm))}function E1(s){const e=Dm(typeof s.type<"u"?s.type:Om);if(ir(e)===ii&&typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof s.senderPublicKey<"u"?m.fromString(s.senderPublicKey,Rt):void 0,i=typeof s.iv<"u"?m.fromString(s.iv,Rt):Ko(po),r=m.fromString(s.symKey,Rt),n=Cm(r,i).encrypt(m.fromString(s.message,Go));return km({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:s.encoding})}function A1(s){const e=m.fromString(s.symKey,Rt),{sealed:t,iv:i}=Po(s),r=Cm(e,i).decrypt(t);if(r===null)throw new Error("Failed to decrypt");return m.toString(r,Go)}function N1(s,e){const t=Dm(Yo),i=Ko(po),r=m.fromString(s,Go);return km({type:t,sealed:r,iv:i,encoding:e})}function _1(s,e){const{sealed:t}=Po({encoded:s,encoding:e});return m.toString(t,Go)}function km(s){const{encoding:e=Ii}=s;if(ir(s.type)===Yo)return m.toString(m.concat([s.type,s.sealed]),e);if(ir(s.type)===ii){if(typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return m.toString(m.concat([s.type,s.senderPublicKey,s.iv,s.sealed]),e)}return m.toString(m.concat([s.type,s.iv,s.sealed]),e)}function Po(s){const{encoded:e,encoding:t=Ii}=s,i=m.fromString(e,t),r=i.slice(b1,wd),n=wd;if(ir(r)===ii){const c=n+Xh,h=c+po,u=i.slice(n,c),d=i.slice(c,h),p=i.slice(h);return{type:r,sealed:p,iv:d,senderPublicKey:u}}if(ir(r)===Yo){const c=i.slice(n),h=Ko(po);return{type:r,sealed:c,iv:h}}const o=n+po,a=i.slice(n,o),l=i.slice(o);return{type:r,sealed:l,iv:a}}function C1(s,e){const t=Po({encoded:s,encoding:e==null?void 0:e.encoding});return jm({type:ir(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?m.toString(t.senderPublicKey,Rt):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function jm(s){const e=(s==null?void 0:s.type)||Om;if(e===ii){if(typeof(s==null?void 0:s.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(s==null?void 0:s.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:s==null?void 0:s.senderPublicKey,receiverPublicKey:s==null?void 0:s.receiverPublicKey}}function yd(s){return s.type===ii&&typeof s.senderPublicKey=="string"&&typeof s.receiverPublicKey=="string"}function bd(s){return s.type===Yo}function S1(s){return new rm.ec("p256").keyFromPublic({x:N.dist.Buffer.from(s.x,"base64").toString("hex"),y:N.dist.Buffer.from(s.y,"base64").toString("hex")},"hex")}function $1(s){let e=s.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function P1(s){return N.dist.Buffer.from($1(s),"base64")}function T1(s,e){const[t,i,r]=s.split("."),n=P1(r);if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),l=`${t}.${i}`,c=yc(l),h=S1(e),u=m.toString(c,Rt);if(!h.verify(u,{r:o,s:a}))throw new Error("Invalid signature");return m.sn(s).payload}const M1="irn";function Ja(s){return(s==null?void 0:s.relay)||{protocol:M1}}function ro(s){const e=m.C[s];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${s}`);return e}function x1(s,e="-"){const t={},i="relay"+e;return Object.keys(s).forEach(r=>{if(r.startsWith(i)){const n=r.replace(i,""),o=s[r];t[n]=o}}),t}function vd(s){if(!s.includes("wc:")){const c=pm(s);c!=null&&c.includes("wc:")&&(s=c)}s=s.includes("wc://")?s.replace("wc://",""):s,s=s.includes("wc:")?s.replace("wc:",""):s;const e=s.indexOf(":"),t=s.indexOf("?")!==-1?s.indexOf("?"):void 0,i=s.substring(0,e),r=s.substring(e+1,t).split("@"),n=typeof t<"u"?s.substring(t):"",o=new URLSearchParams(n),a={};o.forEach((c,h)=>{a[h]=c});const l=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:O1(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:x1(a),methods:l,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function O1(s){return s.startsWith("//")?s.substring(2):s}function D1(s,e="-"){const t="relay",i={};return Object.keys(s).forEach(r=>{const n=r,o=t+e+n;s[n]&&(i[o]=s[n])}),i}function Id(s){const e=new URLSearchParams,t=D1(s.relay);Object.keys(t).sort().forEach(r=>{e.set(r,t[r])}),e.set("symKey",s.symKey),s.expiryTimestamp&&e.set("expiryTimestamp",s.expiryTimestamp.toString()),s.methods&&e.set("methods",s.methods.join(","));const i=e.toString();return`${s.protocol}:${s.topic}@${s.version}?${i}`}function pa(s,e,t){return`${s}?wc_ev=${t}&topic=${e}`}function Sn(s){const e=[];return s.forEach(t=>{const[i,r]=t.split(":");e.push(`${i}:${r}`)}),e}function k1(s){const e=[];return Object.values(s).forEach(t=>{e.push(...Sn(t.accounts))}),e}function j1(s,e){const t=[];return Object.values(s).forEach(i=>{Sn(i.accounts).includes(e)&&t.push(...i.methods)}),t}function R1(s,e){const t=[];return Object.values(s).forEach(i=>{Sn(i.accounts).includes(e)&&t.push(...i.events)}),t}function eu(s){return s.includes(":")}function no(s){return eu(s)?s.split(":")[0]:s}function U1(s){const e={};return s==null||s.forEach(t=>{var i;const[r,n]=t.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[],methods:[]}),e[r].accounts.push(t),(i=e[r].chains)==null||i.push(`${r}:${n}`)}),e}function Ed(s,e){e=e.map(i=>i.replace("did:pkh:",""));const t=U1(e);for(const[i,r]of Object.entries(t))r.methods?r.methods=ka(r.methods,s):r.methods=s,r.events=["chainChanged","accountsChanged"];return t}const L1={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},z1={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function j(s,e){const{message:t,code:i}=z1[s];return{message:e?`${t} ${e}`:t,code:i}}function Te(s,e){const{message:t,code:i}=L1[s];return{message:e?`${t} ${e}`:t,code:i}}function rr(s,e){return!!Array.isArray(s)}function To(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}function Ft(s){return typeof s>"u"}function Xe(s,e){return e&&Ft(s)?!0:typeof s=="string"&&!!s.trim().length}function tu(s,e){return e&&Ft(s)?!0:typeof s=="number"&&!isNaN(s)}function F1(s,e){const{requiredNamespaces:t}=e,i=Object.keys(s.namespaces),r=Object.keys(t);let n=!0;return Yi(r,i)?(i.forEach(o=>{const{accounts:a,methods:l,events:c}=s.namespaces[o],h=Sn(a),u=t[o];(!Yi(om(o,u),h)||!Yi(u.methods,l)||!Yi(u.events,c))&&(n=!1)}),n):!1}function Xa(s){return Xe(s,!1)&&s.includes(":")?s.split(":").length===2:!1}function q1(s){if(Xe(s,!1)&&s.includes(":")){const e=s.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&Xa(t)}}return!1}function B1(s){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(Xe(s,!1)){if(e(s))return!0;const t=pm(s);return e(t)}}catch{}return!1}function H1(s){var e;return(e=s==null?void 0:s.proposer)==null?void 0:e.publicKey}function W1(s){return s==null?void 0:s.topic}function V1(s,e){let t=null;return Xe(s==null?void 0:s.publicKey,!1)||(t=j("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function Ad(s){let e=!0;return rr(s)?s.length&&(e=s.every(t=>Xe(t,!1))):e=!1,e}function K1(s,e,t){let i=null;return rr(e)&&e.length?e.forEach(r=>{i||Xa(r)||(i=Te("UNSUPPORTED_CHAINS",`${t}, chain ${r} should be a string and conform to "namespace:chainId" format`))}):Xa(s)||(i=Te("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function G1(s,e,t){let i=null;return Object.entries(s).forEach(([r,n])=>{if(i)return;const o=K1(r,om(r,n),`${e} ${t}`);o&&(i=o)}),i}function Y1(s,e){let t=null;return rr(s)?s.forEach(i=>{t||q1(i)||(t=Te("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Te("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function Q1(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=Y1(i==null?void 0:i.accounts,`${e} namespace`);r&&(t=r)}),t}function Z1(s,e){let t=null;return Ad(s==null?void 0:s.methods)?Ad(s==null?void 0:s.events)||(t=Te("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Te("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Rm(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=Z1(i,`${e}, namespace`);r&&(t=r)}),t}function J1(s,e,t){let i=null;if(s&&To(s)){const r=Rm(s,e);r&&(i=r);const n=G1(s,e,t);n&&(i=n)}else i=j("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function Vc(s,e){let t=null;if(s&&To(s)){const i=Rm(s,e);i&&(t=i);const r=Q1(s,e);r&&(t=r)}else t=j("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function Um(s){return Xe(s.protocol,!0)}function X1(s,e){let t=!1;return s?s&&rr(s)&&s.length&&s.forEach(i=>{t=Um(i)}):t=!0,t}function eE(s){return typeof s=="number"}function Qt(s){return typeof s<"u"&&typeof s!==null}function tE(s){return!(!s||typeof s!="object"||!s.code||!tu(s.code,!1)||!s.message||!Xe(s.message,!1))}function sE(s){return!(Ft(s)||!Xe(s.method,!1))}function iE(s){return!(Ft(s)||Ft(s.result)&&Ft(s.error)||!tu(s.id,!1)||!Xe(s.jsonrpc,!1))}function rE(s){return!(Ft(s)||!Xe(s.name,!1))}function Nd(s,e){return!(!Xa(e)||!k1(s).includes(e))}function nE(s,e,t){return Xe(t,!1)?j1(s,e).includes(t):!1}function oE(s,e,t){return Xe(t,!1)?R1(s,e).includes(t):!1}function _d(s,e,t){let i=null;const r=aE(s),n=cE(e),o=Object.keys(r),a=Object.keys(n),l=Cd(Object.keys(s)),c=Cd(Object.keys(e)),h=l.filter(u=>!c.includes(u));return h.length&&(i=j("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
|
@@ -9,7 +9,7 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+N.dist.Buffer.from(tI(t)
|
|
|
9
9
|
Approved: ${a.toString()}`)),Object.keys(e).forEach(u=>{if(!u.includes(":")||i)return;const d=Sn(e[u].accounts);d.includes(u)||(i=j("NON_CONFORMING_NAMESPACES",`${t} namespaces accounts don't satisfy namespace accounts for ${u}
|
|
10
10
|
Required: ${u}
|
|
11
11
|
Approved: ${d.toString()}`))}),o.forEach(u=>{i||(Yi(r[u].methods,n[u].methods)?Yi(r[u].events,n[u].events)||(i=j("NON_CONFORMING_NAMESPACES",`${t} namespaces events don't satisfy namespace events for ${u}`)):i=j("NON_CONFORMING_NAMESPACES",`${t} namespaces methods don't satisfy namespace methods for ${u}`))}),i}function aE(s){const e={};return Object.keys(s).forEach(t=>{var i;t.includes(":")?e[t]=s[t]:(i=s[t].chains)==null||i.forEach(r=>{e[r]={methods:s[t].methods,events:s[t].events}})}),e}function Cd(s){return[...new Set(s.map(e=>e.includes(":")?e.split(":")[0]:e))]}function cE(s){const e={};return Object.keys(s).forEach(t=>{if(t.includes(":"))e[t]=s[t];else{const i=Sn(s[t].accounts);i==null||i.forEach(r=>{e[r]={accounts:s[t].accounts.filter(n=>n.includes(`${r}:`)),methods:s[t].methods,events:s[t].events}})}}),e}function lE(s,e){return tu(s,!1)&&s<=e.max&&s>=e.min}function Sd(){const s=Vo();return new Promise(e=>{switch(s){case as.browser:e(hE());break;case as.reactNative:e(uE());break;case as.node:e(dE());break;default:e(!0)}})}function hE(){return Wo()&&(navigator==null?void 0:navigator.onLine)}async function uE(){if(Mi()&&typeof N.dist.global<"u"&&N.dist.global!=null&&N.dist.global.NetInfo){const s=await(N.dist.global==null?void 0:N.dist.global.NetInfo.fetch());return s==null?void 0:s.isConnected}return!0}function dE(){return!0}function pE(s){switch(Vo()){case as.browser:gE(s);break;case as.reactNative:fE(s);break}}function gE(s){!Mi()&&Wo()&&(window.addEventListener("online",()=>s(!0)),window.addEventListener("offline",()=>s(!1)))}function fE(s){var e;Mi()&&typeof N.dist.global<"u"&&N.dist.global!=null&&N.dist.global.NetInfo&&((e=N.dist.global)==null||e.NetInfo.addEventListener(t=>s(t==null?void 0:t.isConnected)))}const Kc={};let Ln=class{static get(e){return Kc[e]}static set(e,t){Kc[e]=t}static delete(e){delete Kc[e]}},Ge=class extends m.r{constructor(e){super(e),this.events=new te.eventsExports.EventEmitter,this.hasRegisteredEventListeners=!1,this.connection=this.setConnection(e),this.connection.connected&&this.registerEventListeners()}async connect(e=this.connection){await this.open(e)}async disconnect(){await this.close()}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async request(e,t){return this.requestStrict(m.formatJsonRpcRequest(e.method,e.params||[],e.id||m.getBigIntRpcId().toString()),t)}async requestStrict(e,t){return new Promise(async(i,r)=>{if(!this.connection.connected)try{await this.open()}catch(n){r(n)}this.events.on(`${e.id}`,n=>{m.isJsonRpcError(n)?r(n.error):i(n.result)});try{await this.connection.send(e,t)}catch(n){r(n)}})}setConnection(e=this.connection){return e}onPayload(e){this.events.emit("payload",e),m.isJsonRpcResponse(e)?this.events.emit(`${e.id}`,e):this.events.emit("message",{type:e.method,data:e.params})}onClose(e){e&&e.code===3e3&&this.events.emit("error",new Error(`WebSocket connection closed abnormally with code: ${e.code} ${e.reason?`(${e.reason})`:""}`)),this.events.emit("disconnect")}async open(e=this.connection){this.connection===e&&this.connection.connected||(this.connection.connected&&this.close(),typeof e=="string"&&(await this.connection.open(e),e=this.connection),this.connection=this.setConnection(e),await this.connection.open(),this.registerEventListeners(),this.events.emit("connect"))}async close(){await this.connection.close()}registerEventListeners(){this.hasRegisteredEventListeners||(this.connection.on("payload",e=>this.onPayload(e)),this.connection.on("close",e=>this.onClose(e)),this.connection.on("error",e=>this.events.emit("error",e)),this.connection.on("register_error",e=>this.onClose()),this.hasRegisteredEventListeners=!0)}};const mE=()=>typeof WebSocket<"u"?WebSocket:typeof N.dist.global<"u"&&typeof N.dist.global.WebSocket<"u"?N.dist.global.WebSocket:typeof window<"u"&&typeof window.WebSocket<"u"?window.WebSocket:typeof self<"u"&&typeof self.WebSocket<"u"?self.WebSocket:require("ws"),wE=()=>typeof WebSocket<"u"||typeof N.dist.global<"u"&&typeof N.dist.global.WebSocket<"u"||typeof window<"u"&&typeof window.WebSocket<"u"||typeof self<"u"&&typeof self.WebSocket<"u",$d=s=>s.split("?")[0],Pd=10,yE=mE();let Lm=class{constructor(e){if(this.url=e,this.events=new te.eventsExports.EventEmitter,this.registering=!1,!m.isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);this.url=e}get connected(){return typeof this.socket<"u"}get connecting(){return this.registering}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async open(e=this.url){await this.register(e)}async close(){return new Promise((e,t)=>{if(typeof this.socket>"u"){t(new Error("Connection already closed"));return}this.socket.onclose=i=>{this.onClose(i),e()},this.socket.close()})}async send(e){typeof this.socket>"u"&&(this.socket=await this.register());try{this.socket.send(m.safeJsonStringify(e))}catch(t){this.onError(e.id,t)}}register(e=this.url){if(!m.isWsUrl(e))throw new Error(`Provided URL is not compatible with WebSocket connection: ${e}`);if(this.registering){const t=this.events.getMaxListeners();return(this.events.listenerCount("register_error")>=t||this.events.listenerCount("open")>=t)&&this.events.setMaxListeners(t+1),new Promise((i,r)=>{this.events.once("register_error",n=>{this.resetMaxListeners(),r(n)}),this.events.once("open",()=>{if(this.resetMaxListeners(),typeof this.socket>"u")return r(new Error("WebSocket connection is missing or invalid"));i(this.socket)})})}return this.url=e,this.registering=!0,new Promise((t,i)=>{const r=m.cjs.isReactNative()?void 0:{rejectUnauthorized:!m.isLocalhostUrl(e)},n=new yE(e,[],r);wE()?n.onerror=o=>{const a=o;i(this.emitError(a.error))}:n.on("error",o=>{i(this.emitError(o))}),n.onopen=()=>{this.onOpen(n),t(n)}})}onOpen(e){e.onmessage=t=>this.onPayload(t),e.onclose=t=>this.onClose(t),this.socket=e,this.registering=!1,this.events.emit("open")}onClose(e){this.socket=void 0,this.registering=!1,this.events.emit("close",e)}onPayload(e){if(typeof e.data>"u")return;const t=typeof e.data=="string"?m.safeJsonParse(e.data):e.data;this.events.emit("payload",t)}onError(e,t){const i=this.parseError(t),r=i.message||i.toString(),n=m.formatJsonRpcError(e,r);this.events.emit("payload",n)}parseError(e,t=this.url){return m.parseConnectionError(e,$d(t),"WS")}resetMaxListeners(){this.events.getMaxListeners()>Pd&&this.events.setMaxListeners(Pd)}emitError(e){const t=this.parseError(new Error((e==null?void 0:e.message)||`WebSocket connection failed for host: ${$d(this.url)}`));return this.events.emit("register_error",t),t}};const zm="wc",Fm=2,Ql="core",Ws=`${zm}@2:${Ql}:`,bE={logger:"error"},vE={database:":memory:"},IE="crypto",Td="client_ed25519_seed",EE=E.cjs.ONE_DAY,AE="keychain",NE="0.3",_E="messages",CE="0.3",Md=E.cjs.SIX_HOURS,SE="publisher",qm="irn",$E="error",Bm="wss://relay.walletconnect.org",PE="relayer",yt={message:"relayer_message",message_ack:"relayer_message_ack",connect:"relayer_connect",disconnect:"relayer_disconnect",error:"relayer_error",connection_stalled:"relayer_connection_stalled",transport_closed:"relayer_transport_closed",publish:"relayer_publish"},TE="_subscription",us={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},ME=.1,Zl="2.19.0",We={link_mode:"link_mode",relay:"relay"},xE="0.3",OE="WALLETCONNECT_CLIENT_ID",xd="WALLETCONNECT_LINK_MODE_APPS",is={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},DE="subscription",kE="0.3",jE=E.cjs.FIVE_SECONDS*1e3,RE="pairing",UE="0.3",zn={wc_pairingDelete:{req:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:E.cjs.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:E.cjs.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:0},res:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:0}}},Wi={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},As={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},LE="history",zE="0.3",FE="expirer",ms={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},qE="0.3",BE="verify-api",HE="https://verify.walletconnect.com",Hm="https://verify.walletconnect.org",go=Hm,WE=`${go}/v3`,VE=[HE,Hm],KE="echo",GE="https://echo.walletconnect.com",Fs={pairing_started:"pairing_started",pairing_uri_validation_success:"pairing_uri_validation_success",pairing_uri_not_expired:"pairing_uri_not_expired",store_new_pairing:"store_new_pairing",subscribing_pairing_topic:"subscribing_pairing_topic",subscribe_pairing_topic_success:"subscribe_pairing_topic_success",existing_pairing:"existing_pairing",pairing_not_expired:"pairing_not_expired",emit_inactive_pairing:"emit_inactive_pairing",emit_session_proposal:"emit_session_proposal",subscribing_to_pairing_topic:"subscribing_to_pairing_topic"},Xs={no_wss_connection:"no_wss_connection",no_internet_connection:"no_internet_connection",malformed_pairing_uri:"malformed_pairing_uri",active_pairing_already_exists:"active_pairing_already_exists",subscribe_pairing_topic_failure:"subscribe_pairing_topic_failure",pairing_expired:"pairing_expired",proposal_expired:"proposal_expired",proposal_listener_not_found:"proposal_listener_not_found"},Ns={session_approve_started:"session_approve_started",proposal_not_expired:"proposal_not_expired",session_namespaces_validation_success:"session_namespaces_validation_success",create_session_topic:"create_session_topic",subscribing_session_topic:"subscribing_session_topic",subscribe_session_topic_success:"subscribe_session_topic_success",publishing_session_approve:"publishing_session_approve",session_approve_publish_success:"session_approve_publish_success",store_session:"store_session",publishing_session_settle:"publishing_session_settle",session_settle_publish_success:"session_settle_publish_success"},ji={no_internet_connection:"no_internet_connection",no_wss_connection:"no_wss_connection",proposal_expired:"proposal_expired",subscribe_session_topic_failure:"subscribe_session_topic_failure",session_approve_publish_failure:"session_approve_publish_failure",session_settle_publish_failure:"session_settle_publish_failure",session_approve_namespace_validation_failure:"session_approve_namespace_validation_failure",proposal_not_found:"proposal_not_found"},Ri={authenticated_session_approve_started:"authenticated_session_approve_started",create_authenticated_session_topic:"create_authenticated_session_topic",cacaos_verified:"cacaos_verified",store_authenticated_session:"store_authenticated_session",subscribing_authenticated_session_topic:"subscribing_authenticated_session_topic",subscribe_authenticated_session_topic_success:"subscribe_authenticated_session_topic_success",publishing_authenticated_session_approve:"publishing_authenticated_session_approve"},Fn={no_internet_connection:"no_internet_connection",invalid_cacao:"invalid_cacao",subscribe_authenticated_session_topic_failure:"subscribe_authenticated_session_topic_failure",authenticated_session_approve_publish_failure:"authenticated_session_approve_publish_failure",authenticated_session_pending_request_not_found:"authenticated_session_pending_request_not_found"},YE=.1,QE="event-client",ZE=86400,JE="https://pulse.walletconnect.org/batch";function XE(s,e){if(s.length>=255)throw new TypeError("Alphabet too long");for(var t=new Uint8Array(256),i=0;i<t.length;i++)t[i]=255;for(var r=0;r<s.length;r++){var n=s.charAt(r),o=n.charCodeAt(0);if(t[o]!==255)throw new TypeError(n+" is ambiguous");t[o]=r}var a=s.length,l=s.charAt(0),c=Math.log(a)/Math.log(256),h=Math.log(256)/Math.log(a);function u(g){if(g instanceof Uint8Array||(ArrayBuffer.isView(g)?g=new Uint8Array(g.buffer,g.byteOffset,g.byteLength):Array.isArray(g)&&(g=Uint8Array.from(g))),!(g instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(g.length===0)return"";for(var f=0,b=0,y=0,w=g.length;y!==w&&g[y]===0;)y++,f++;for(var v=(w-y)*h+1>>>0,A=new Uint8Array(v);y!==w;){for(var C=g[y],P=0,T=v-1;(C!==0||P<b)&&T!==-1;T--,P++)C+=256*A[T]>>>0,A[T]=C%a>>>0,C=C/a>>>0;if(C!==0)throw new Error("Non-zero carry");b=P,y++}for(var O=v-b;O!==v&&A[O]===0;)O++;for(var S=l.repeat(f);O<v;++O)S+=s.charAt(A[O]);return S}function d(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var f=0;if(g[f]!==" "){for(var b=0,y=0;g[f]===l;)b++,f++;for(var w=(g.length-f)*c+1>>>0,v=new Uint8Array(w);g[f];){var A=t[g.charCodeAt(f)];if(A===255)return;for(var C=0,P=w-1;(A!==0||C<y)&&P!==-1;P--,C++)A+=a*v[P]>>>0,v[P]=A%256>>>0,A=A/256>>>0;if(A!==0)throw new Error("Non-zero carry");y=C,f++}if(g[f]!==" "){for(var T=w-y;T!==w&&v[T]===0;)T++;for(var O=new Uint8Array(b+(w-T)),S=b;T!==w;)O[S++]=v[T++];return O}}}function p(g){var f=d(g);if(f)return f;throw new Error(`Non-${e} character`)}return{encode:u,decodeUnsafe:d,decode:p}}var eA=XE,tA=eA;const Wm=s=>{if(s instanceof Uint8Array&&s.constructor.name==="Uint8Array")return s;if(s instanceof ArrayBuffer)return new Uint8Array(s);if(ArrayBuffer.isView(s))return new Uint8Array(s.buffer,s.byteOffset,s.byteLength);throw new Error("Unknown type, must be binary type")},sA=s=>new TextEncoder().encode(s),iA=s=>new TextDecoder().decode(s);let rA=class{constructor(e,t,i){this.name=e,this.prefix=t,this.baseEncode=i}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}},nA=class{constructor(e,t,i){if(this.name=e,this.prefix=t,t.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=t.codePointAt(0),this.baseDecode=i}decode(e){if(typeof e=="string"){if(e.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(e)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(e.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(e){return Vm(this,e)}},oA=class{constructor(e){this.decoders=e}or(e){return Vm(this,e)}decode(e){const t=e[0],i=this.decoders[t];if(i)return i.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const Vm=(s,e)=>new oA({...s.decoders||{[s.prefix]:s},...e.decoders||{[e.prefix]:e}});let aA=class{constructor(e,t,i,r){this.name=e,this.prefix=t,this.baseEncode=i,this.baseDecode=r,this.encoder=new rA(e,t,i),this.decoder=new nA(e,t,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}};const bc=({name:s,prefix:e,encode:t,decode:i})=>new aA(s,e,t,i),Qo=({prefix:s,name:e,alphabet:t})=>{const{encode:i,decode:r}=tA(t,e);return bc({prefix:s,name:e,encode:i,decode:n=>Wm(r(n))})},cA=(s,e,t,i)=>{const r={};for(let h=0;h<e.length;++h)r[e[h]]=h;let n=s.length;for(;s[n-1]==="=";)--n;const o=new Uint8Array(n*t/8|0);let a=0,l=0,c=0;for(let h=0;h<n;++h){const u=r[s[h]];if(u===void 0)throw new SyntaxError(`Non-${i} character`);l=l<<t|u,a+=t,a>=8&&(a-=8,o[c++]=255&l>>a)}if(a>=t||255&l<<8-a)throw new SyntaxError("Unexpected end of data");return o},lA=(s,e,t)=>{const i=e[e.length-1]==="=",r=(1<<t)-1;let n="",o=0,a=0;for(let l=0;l<s.length;++l)for(a=a<<8|s[l],o+=8;o>t;)o-=t,n+=e[r&a>>o];if(o&&(n+=e[r&a<<t-o]),i)for(;n.length*t&7;)n+="=";return n},Mt=({name:s,prefix:e,bitsPerChar:t,alphabet:i})=>bc({prefix:e,name:s,encode(r){return lA(r,i,t)},decode(r){return cA(r,i,t,s)}}),hA=bc({prefix:"\0",name:"identity",encode:s=>iA(s),decode:s=>sA(s)});var uA=Object.freeze({__proto__:null,identity:hA});const dA=Mt({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var pA=Object.freeze({__proto__:null,base2:dA});const gA=Mt({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var fA=Object.freeze({__proto__:null,base8:gA});const mA=Qo({prefix:"9",name:"base10",alphabet:"0123456789"});var wA=Object.freeze({__proto__:null,base10:mA});const yA=Mt({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),bA=Mt({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var vA=Object.freeze({__proto__:null,base16:yA,base16upper:bA});const IA=Mt({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),EA=Mt({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),AA=Mt({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),NA=Mt({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),_A=Mt({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),CA=Mt({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),SA=Mt({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),$A=Mt({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),PA=Mt({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var TA=Object.freeze({__proto__:null,base32:IA,base32upper:EA,base32pad:AA,base32padupper:NA,base32hex:_A,base32hexupper:CA,base32hexpad:SA,base32hexpadupper:$A,base32z:PA});const MA=Qo({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),xA=Qo({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var OA=Object.freeze({__proto__:null,base36:MA,base36upper:xA});const DA=Qo({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),kA=Qo({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var jA=Object.freeze({__proto__:null,base58btc:DA,base58flickr:kA});const RA=Mt({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),UA=Mt({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),LA=Mt({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),zA=Mt({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var FA=Object.freeze({__proto__:null,base64:RA,base64pad:UA,base64url:LA,base64urlpad:zA});const Km=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),qA=Km.reduce((s,e,t)=>(s[t]=e,s),[]),BA=Km.reduce((s,e,t)=>(s[e.codePointAt(0)]=t,s),[]);function HA(s){return s.reduce((e,t)=>(e+=qA[t],e),"")}function WA(s){const e=[];for(const t of s){const i=BA[t.codePointAt(0)];if(i===void 0)throw new Error(`Non-base256emoji character: ${t}`);e.push(i)}return new Uint8Array(e)}const VA=bc({prefix:"🚀",name:"base256emoji",encode:HA,decode:WA});var KA=Object.freeze({__proto__:null,base256emoji:VA}),GA=Gm,Od=128,YA=-128,QA=Math.pow(2,31);function Gm(s,e,t){e=e||[],t=t||0;for(var i=t;s>=QA;)e[t++]=s&255|Od,s/=128;for(;s&YA;)e[t++]=s&255|Od,s>>>=7;return e[t]=s|0,Gm.bytes=t-i+1,e}var ZA=Jl,JA=128,Dd=127;function Jl(s,i){var t=0,i=i||0,r=0,n=i,o,a=s.length;do{if(n>=a)throw Jl.bytes=0,new RangeError("Could not decode varint");o=s[n++],t+=r<28?(o&Dd)<<r:(o&Dd)*Math.pow(2,r),r+=7}while(o>=JA);return Jl.bytes=n-i,t}var XA=Math.pow(2,7),eN=Math.pow(2,14),tN=Math.pow(2,21),sN=Math.pow(2,28),iN=Math.pow(2,35),rN=Math.pow(2,42),nN=Math.pow(2,49),oN=Math.pow(2,56),aN=Math.pow(2,63),cN=function(s){return s<XA?1:s<eN?2:s<tN?3:s<sN?4:s<iN?5:s<rN?6:s<nN?7:s<oN?8:s<aN?9:10},lN={encode:GA,decode:ZA,encodingLength:cN},Ym=lN;const kd=(s,e,t=0)=>(Ym.encode(s,e,t),e),jd=s=>Ym.encodingLength(s),Xl=(s,e)=>{const t=e.byteLength,i=jd(s),r=i+jd(t),n=new Uint8Array(r+t);return kd(s,n,0),kd(t,n,i),n.set(e,r),new hN(s,t,e,n)};let hN=class{constructor(e,t,i,r){this.code=e,this.size=t,this.digest=i,this.bytes=r}};const Qm=({name:s,code:e,encode:t})=>new uN(s,e,t);let uN=class{constructor(e,t,i){this.name=e,this.code=t,this.encode=i}digest(e){if(e instanceof Uint8Array){const t=this.encode(e);return t instanceof Uint8Array?Xl(this.code,t):t.then(i=>Xl(this.code,i))}else throw Error("Unknown type, must be binary type")}};const Zm=s=>async e=>new Uint8Array(await crypto.subtle.digest(s,e)),dN=Qm({name:"sha2-256",code:18,encode:Zm("SHA-256")}),pN=Qm({name:"sha2-512",code:19,encode:Zm("SHA-512")});var gN=Object.freeze({__proto__:null,sha256:dN,sha512:pN});const Jm=0,fN="identity",Xm=Wm,mN=s=>Xl(Jm,Xm(s)),wN={code:Jm,name:fN,encode:Xm,digest:mN};var yN=Object.freeze({__proto__:null,identity:wN});new TextEncoder,new TextDecoder;const Rd={...uA,...pA,...fA,...wA,...vA,...TA,...OA,...jA,...FA,...KA};({...gN,...yN});function bN(s=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?globalThis.Buffer.allocUnsafe(s):new Uint8Array(s)}function ew(s,e,t,i){return{name:s,prefix:e,encoder:{name:s,prefix:e,encode:t},decoder:{decode:i}}}const Ud=ew("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>new TextEncoder().encode(s.substring(1))),Gc=ew("ascii","a",s=>{let e="a";for(let t=0;t<s.length;t++)e+=String.fromCharCode(s[t]);return e},s=>{s=s.substring(1);const e=bN(s.length);for(let t=0;t<s.length;t++)e[t]=s.charCodeAt(t);return e}),vN={utf8:Ud,"utf-8":Ud,hex:Rd.base16,latin1:Gc,ascii:Gc,binary:Gc,...Rd};function IN(s,e="utf8"){const t=vN[e];if(!t)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(s,"utf8"):t.decoder.decode(`${t.prefix}${s}`)}var EN=Object.defineProperty,AN=(s,e,t)=>e in s?EN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ds=(s,e,t)=>AN(s,typeof e!="symbol"?e+"":e,t);let NN=class{constructor(e,t){this.core=e,this.logger=t,Ds(this,"keychain",new Map),Ds(this,"name",AE),Ds(this,"version",NE),Ds(this,"initialized",!1),Ds(this,"storagePrefix",Ws),Ds(this,"init",async()=>{if(!this.initialized){const i=await this.getKeyChain();typeof i<"u"&&(this.keychain=i),this.initialized=!0}}),Ds(this,"has",i=>(this.isInitialized(),this.keychain.has(i))),Ds(this,"set",async(i,r)=>{this.isInitialized(),this.keychain.set(i,r),await this.persist()}),Ds(this,"get",i=>{this.isInitialized();const r=this.keychain.get(i);if(typeof r>"u"){const{message:n}=j("NO_MATCHING_KEY",`${this.name}: ${i}`);throw new Error(n)}return r}),Ds(this,"del",async i=>{this.isInitialized(),this.keychain.delete(i),await this.persist()}),this.core=e,this.logger=m.E(t,this.name)}get context(){return m.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,lm(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?hm(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}};var _N=Object.defineProperty,CN=(s,e,t)=>e in s?_N(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Et=(s,e,t)=>CN(s,typeof e!="symbol"?e+"":e,t);let SN=class{constructor(e,t,i){this.core=e,this.logger=t,Et(this,"name",IE),Et(this,"keychain"),Et(this,"randomSessionIdentifier",Yl()),Et(this,"initialized",!1),Et(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),Et(this,"hasKeys",r=>(this.isInitialized(),this.keychain.has(r))),Et(this,"getClientId",async()=>{this.isInitialized();const r=await this.getClientSeed(),n=m.Po(r);return m.Qe(n.publicKey)}),Et(this,"generateKeyPair",()=>{this.isInitialized();const r=v1();return this.setPrivateKey(r.publicKey,r.privateKey)}),Et(this,"signJWT",async r=>{this.isInitialized();const n=await this.getClientSeed(),o=m.Po(n),a=this.randomSessionIdentifier,l=EE;return await m.Qo(a,r,l,o)}),Et(this,"generateSharedKey",(r,n,o)=>{this.isInitialized();const a=this.getPrivateKey(r),l=I1(a,n);return this.setSymKey(l,o)}),Et(this,"setSymKey",async(r,n)=>{this.isInitialized();const o=n||Ra(r);return await this.keychain.set(o,r),o}),Et(this,"deleteKeyPair",async r=>{this.isInitialized(),await this.keychain.del(r)}),Et(this,"deleteSymKey",async r=>{this.isInitialized(),await this.keychain.del(r)}),Et(this,"encode",async(r,n,o)=>{this.isInitialized();const a=jm(o),l=m.safeJsonStringify(n);if(bd(a))return N1(l,o==null?void 0:o.encoding);if(yd(a)){const d=a.senderPublicKey,p=a.receiverPublicKey;r=await this.generateSharedKey(d,p)}const c=this.getSymKey(r),{type:h,senderPublicKey:u}=a;return E1({type:h,symKey:c,message:l,senderPublicKey:u,encoding:o==null?void 0:o.encoding})}),Et(this,"decode",async(r,n,o)=>{this.isInitialized();const a=C1(n,o);if(bd(a)){const l=_1(n,o==null?void 0:o.encoding);return m.safeJsonParse(l)}if(yd(a)){const l=a.receiverPublicKey,c=a.senderPublicKey;r=await this.generateSharedKey(l,c)}try{const l=this.getSymKey(r),c=A1({symKey:l,encoded:n,encoding:o==null?void 0:o.encoding});return m.safeJsonParse(c)}catch(l){this.logger.error(`Failed to decode message from topic: '${r}', clientId: '${await this.getClientId()}'`),this.logger.error(l)}}),Et(this,"getPayloadType",(r,n=Ii)=>{const o=Po({encoded:r,encoding:n});return ir(o.type)}),Et(this,"getPayloadSenderPublicKey",(r,n=Ii)=>{const o=Po({encoded:r,encoding:n});return o.senderPublicKey?m.toString(o.senderPublicKey,Rt):void 0}),this.core=e,this.logger=m.E(t,this.name),this.keychain=i||new NN(this.core,this.logger)}get context(){return m.y(this.logger)}async setPrivateKey(e,t){return await this.keychain.set(e,t),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get(Td)}catch{e=Yl(),await this.keychain.set(Td,e)}return IN(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}};var $N=Object.defineProperty,PN=(s,e,t)=>e in s?$N(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ks=(s,e,t)=>PN(s,typeof e!="symbol"?e+"":e,t);let TN=class extends wv{constructor(e,t){super(e,t),this.logger=e,this.core=t,ks(this,"messages",new Map),ks(this,"name",_E),ks(this,"version",CE),ks(this,"initialized",!1),ks(this,"storagePrefix",Ws),ks(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const i=await this.getRelayerMessages();typeof i<"u"&&(this.messages=i),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(i){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(i)}finally{this.initialized=!0}}}),ks(this,"set",async(i,r)=>{this.isInitialized();const n=ti(r);let o=this.messages.get(i);return typeof o>"u"&&(o={}),typeof o[n]<"u"||(o[n]=r,this.messages.set(i,o),await this.persist()),n}),ks(this,"get",i=>{this.isInitialized();let r=this.messages.get(i);return typeof r>"u"&&(r={}),r}),ks(this,"has",(i,r)=>{this.isInitialized();const n=this.get(i),o=ti(r);return typeof n[o]<"u"}),ks(this,"del",async i=>{this.isInitialized(),this.messages.delete(i),await this.persist()}),this.logger=m.E(e,this.name),this.core=t}get context(){return m.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,lm(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?hm(e):void 0}async persist(){await this.setRelayerMessages(this.messages)}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}};var MN=Object.defineProperty,xN=Object.defineProperties,ON=Object.getOwnPropertyDescriptors,Ld=Object.getOwnPropertySymbols,DN=Object.prototype.hasOwnProperty,kN=Object.prototype.propertyIsEnumerable,eh=(s,e,t)=>e in s?MN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ga=(s,e)=>{for(var t in e||(e={}))DN.call(e,t)&&eh(s,t,e[t]);if(Ld)for(var t of Ld(e))kN.call(e,t)&&eh(s,t,e[t]);return s},Yc=(s,e)=>xN(s,ON(e)),_s=(s,e,t)=>eh(s,typeof e!="symbol"?e+"":e,t);let jN=class extends yv{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,_s(this,"events",new te.eventsExports.EventEmitter),_s(this,"name",SE),_s(this,"queue",new Map),_s(this,"publishTimeout",E.cjs.toMiliseconds(E.cjs.ONE_MINUTE)),_s(this,"initialPublishTimeout",E.cjs.toMiliseconds(E.cjs.ONE_SECOND*15)),_s(this,"needsTransportRestart",!1),_s(this,"publish",async(i,r,n)=>{var o;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:i,message:r,opts:n}});const a=(n==null?void 0:n.ttl)||Md,l=Ja(n),c=(n==null?void 0:n.prompt)||!1,h=(n==null?void 0:n.tag)||0,u=(n==null?void 0:n.id)||m.getBigIntRpcId().toString(),d={topic:i,message:r,opts:{ttl:a,relay:l,prompt:c,tag:h,id:u,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}},p=`Failed to publish payload, please try again. id:${u} tag:${h}`;try{const g=new Promise(async f=>{const b=({id:w})=>{d.opts.id===w&&(this.removeRequestFromQueue(w),this.relayer.events.removeListener(yt.publish,b),f(d))};this.relayer.events.on(yt.publish,b);const y=vi(new Promise((w,v)=>{this.rpcPublish({topic:i,message:r,ttl:a,prompt:c,tag:h,id:u,attestation:n==null?void 0:n.attestation,tvf:n==null?void 0:n.tvf}).then(w).catch(A=>{this.logger.warn(A,A==null?void 0:A.message),v(A)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${u} tag:${h}`);try{await y,this.events.removeListener(yt.publish,b)}catch(w){this.queue.set(u,Yc(ga({},d),{attempt:1})),this.logger.warn(w,w==null?void 0:w.message)}});this.logger.trace({type:"method",method:"publish",params:{id:u,topic:i,message:r,opts:n}}),await vi(g,this.publishTimeout,p)}catch(g){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(g),(o=n==null?void 0:n.internal)!=null&&o.throwOnFailedPublish)throw g}finally{this.queue.delete(u)}}),_s(this,"on",(i,r)=>{this.events.on(i,r)}),_s(this,"once",(i,r)=>{this.events.once(i,r)}),_s(this,"off",(i,r)=>{this.events.off(i,r)}),_s(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),this.relayer=e,this.logger=m.E(t,this.name),this.registerEventListeners()}get context(){return m.y(this.logger)}async rpcPublish(e){var t,i,r,n;const{topic:o,message:a,ttl:l=Md,prompt:c,tag:h,id:u,attestation:d,tvf:p}=e,g={method:ro(Ja().protocol).publish,params:ga({topic:o,message:a,ttl:l,prompt:c,tag:h,attestation:d},p),id:u};Ft((t=g.params)==null?void 0:t.prompt)&&((i=g.params)==null||delete i.prompt),Ft((r=g.params)==null?void 0:r.tag)&&((n=g.params)==null||delete n.tag),this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:g});const f=await this.relayer.request(g);return this.relayer.events.emit(yt.publish,e),this.logger.debug("Successfully Published Payload"),f}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,t)=>{const i=e.attempt+1;this.queue.set(t,Yc(ga({},e),{attempt:i}));const{topic:r,message:n,opts:o,attestation:a}=e;this.logger.warn({},`Publisher: queue->publishing: ${e.opts.id}, tag: ${e.opts.tag}, attempt: ${i}`),await this.rpcPublish(Yc(ga({},e),{topic:r,message:n,ttl:o.ttl,prompt:o.prompt,tag:o.tag,id:o.id,attestation:a,tvf:o.tvf})),this.logger.warn({},`Publisher: queue->published: ${e.opts.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(xs.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(yt.connection_stalled);return}this.checkQueue()}),this.relayer.on(yt.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}};var RN=Object.defineProperty,UN=(s,e,t)=>e in s?RN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Nr=(s,e,t)=>UN(s,typeof e!="symbol"?e+"":e,t);let LN=class{constructor(){Nr(this,"map",new Map),Nr(this,"set",(e,t)=>{const i=this.get(e);this.exists(e,t)||this.map.set(e,[...i,t])}),Nr(this,"get",e=>this.map.get(e)||[]),Nr(this,"exists",(e,t)=>this.get(e).includes(t)),Nr(this,"delete",(e,t)=>{if(typeof t>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const i=this.get(e);if(!this.exists(e,t))return;const r=i.filter(n=>n!==t);if(!r.length){this.map.delete(e);return}this.map.set(e,r)}),Nr(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}};var zN=Object.defineProperty,FN=Object.defineProperties,qN=Object.getOwnPropertyDescriptors,zd=Object.getOwnPropertySymbols,BN=Object.prototype.hasOwnProperty,HN=Object.prototype.propertyIsEnumerable,th=(s,e,t)=>e in s?zN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qn=(s,e)=>{for(var t in e||(e={}))BN.call(e,t)&&th(s,t,e[t]);if(zd)for(var t of zd(e))HN.call(e,t)&&th(s,t,e[t]);return s},Qc=(s,e)=>FN(s,qN(e)),Pe=(s,e,t)=>th(s,typeof e!="symbol"?e+"":e,t);let WN=class extends Iv{constructor(e,t){super(e,t),this.relayer=e,this.logger=t,Pe(this,"subscriptions",new Map),Pe(this,"topicMap",new LN),Pe(this,"events",new te.eventsExports.EventEmitter),Pe(this,"name",DE),Pe(this,"version",kE),Pe(this,"pending",new Map),Pe(this,"cached",[]),Pe(this,"initialized",!1),Pe(this,"pendingSubscriptionWatchLabel","pending_sub_watch_label"),Pe(this,"pollingInterval",20),Pe(this,"storagePrefix",Ws),Pe(this,"subscribeTimeout",E.cjs.toMiliseconds(E.cjs.ONE_MINUTE)),Pe(this,"initialSubscribeTimeout",E.cjs.toMiliseconds(E.cjs.ONE_SECOND*15)),Pe(this,"clientId"),Pe(this,"batchSubscribeTopicsLimit",500),Pe(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),Pe(this,"subscribe",async(i,r)=>{this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:r}});try{const n=Ja(r),o={topic:i,relay:n,transportType:r==null?void 0:r.transportType};this.pending.set(i,o);const a=await this.rpcSubscribe(i,n,r);return typeof a=="string"&&(this.onSubscribe(a,o),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:i,opts:r}})),a}catch(n){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(n),n}}),Pe(this,"unsubscribe",async(i,r)=>{this.isInitialized(),typeof(r==null?void 0:r.id)<"u"?await this.unsubscribeById(i,r.id,r):await this.unsubscribeByTopic(i,r)}),Pe(this,"isSubscribed",async i=>{if(this.topics.includes(i))return!0;const r=`${this.pendingSubscriptionWatchLabel}_${i}`;return await new Promise((n,o)=>{const a=new E.cjs.Watch;a.start(r);const l=setInterval(()=>{(!this.pending.has(i)&&this.topics.includes(i)||this.cached.some(c=>c.topic===i))&&(clearInterval(l),a.stop(r),n(!0)),a.elapsed(r)>=jE&&(clearInterval(l),a.stop(r),o(new Error("Subscription resolution timeout")))},this.pollingInterval)}).catch(()=>!1)}),Pe(this,"on",(i,r)=>{this.events.on(i,r)}),Pe(this,"once",(i,r)=>{this.events.once(i,r)}),Pe(this,"off",(i,r)=>{this.events.off(i,r)}),Pe(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),Pe(this,"start",async()=>{await this.onConnect()}),Pe(this,"stop",async()=>{await this.onDisconnect()}),Pe(this,"restart",async()=>{await this.restore(),await this.onRestart()}),Pe(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const i=[];this.pending.forEach(r=>{i.push(r)}),await this.batchSubscribe(i)}),Pe(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(xs.pulse,async()=>{await this.checkPending()}),this.events.on(is.created,async i=>{const r=is.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:i}),await this.persist()}),this.events.on(is.deleted,async i=>{const r=is.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:i}),await this.persist()})}),this.relayer=e,this.logger=m.E(t,this.name),this.clientId=""}get context(){return m.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.relayer.core.customStoragePrefix+"//"+this.name}get length(){return this.subscriptions.size}get ids(){return Array.from(this.subscriptions.keys())}get values(){return Array.from(this.subscriptions.values())}get topics(){return this.topicMap.topics}get hasAnyTopics(){return this.topicMap.topics.length>0||this.pending.size>0||this.cached.length>0||this.subscriptions.size>0}hasSubscription(e,t){let i=!1;try{i=this.getSubscription(e).topic===t}catch{}return i}reset(){this.cached=[],this.initialized=!0}onDisable(){this.cached=this.values,this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,t){const i=this.topicMap.get(e);await Promise.all(i.map(async r=>await this.unsubscribeById(e,r,t)))}async unsubscribeById(e,t,i){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}});try{const r=Ja(i);await this.restartToComplete({topic:e,id:t,relay:r}),await this.rpcUnsubscribe(e,t,r);const n=Te("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,t,n),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:t,opts:i}})}catch(r){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(r),r}}async rpcSubscribe(e,t,i){var r;(!i||(i==null?void 0:i.transportType)===We.relay)&&await this.restartToComplete({topic:e,id:e,relay:t});const n={method:ro(t.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});const o=(r=i==null?void 0:i.internal)==null?void 0:r.throwOnFailedPublish;try{const a=await this.getSubscriptionId(e);if((i==null?void 0:i.transportType)===We.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(n).catch(h=>this.logger.warn(h))},E.cjs.toMiliseconds(E.cjs.ONE_SECOND)),a;const l=new Promise(async h=>{const u=d=>{d.topic===e&&(this.events.removeListener(is.created,u),h(d.id))};this.events.on(is.created,u);try{const d=await vi(new Promise((p,g)=>{this.relayer.request(n).catch(f=>{this.logger.warn(f,f==null?void 0:f.message),g(f)}).then(p)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(is.created,u),h(d)}catch{}}),c=await vi(l,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!c&&o)throw new Error(`Subscribing to ${e} failed, please try again`);return c?a:null}catch(a){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(yt.connection_stalled),o)throw a}return null}async rpcBatchSubscribe(e){if(!e.length)return;const t=e[0].relay,i={method:ro(t.protocol).batchSubscribe,params:{topics:e.map(r=>r.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});try{await await vi(new Promise(r=>{this.relayer.request(i).catch(n=>this.logger.warn(n)).then(r)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(yt.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const t=e[0].relay,i={method:ro(t.protocol).batchFetchMessages,params:{topics:e.map(n=>n.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:i});let r;try{r=await await vi(new Promise((n,o)=>{this.relayer.request(i).catch(a=>{this.logger.warn(a),o(a)}).then(n)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(yt.connection_stalled)}return r}rpcUnsubscribe(e,t,i){const r={method:ro(i.protocol).unsubscribe,params:{topic:e,id:t}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,t){this.setSubscription(e,Qc(qn({},t),{id:e})),this.pending.delete(t.topic)}onBatchSubscribe(e){e.length&&e.forEach(t=>{this.setSubscription(t.id,qn({},t)),this.pending.delete(t.topic)})}async onUnsubscribe(e,t,i){this.events.removeAllListeners(t),this.hasSubscription(t,e)&&this.deleteSubscription(t,i),await this.relayer.messages.del(e)}async setRelayerSubscriptions(e){await this.relayer.core.storage.setItem(this.storageKey,e)}async getRelayerSubscriptions(){return await this.relayer.core.storage.getItem(this.storageKey)}setSubscription(e,t){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:t}),this.addSubscription(e,t)}addSubscription(e,t){this.subscriptions.set(e,qn({},t)),this.topicMap.set(t.topic,e),this.events.emit(is.created,t)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const t=this.subscriptions.get(e);if(!t){const{message:i}=j("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}deleteSubscription(e,t){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:t});const i=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(i.topic,e),this.events.emit(is.deleted,Qc(qn({},i),{reason:t}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(is.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],t=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let i=0;i<t;i++){const r=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(r)}}this.events.emit(is.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size){const{message:t}=j("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored subscriptions for ${this.name}`),this.logger.trace({type:"method",method:"restore",subscriptions:this.values})}catch(e){this.logger.debug(`Failed to Restore subscriptions for ${this.name}`),this.logger.error(e)}}async batchSubscribe(e){e.length&&(await this.rpcBatchSubscribe(e),this.onBatchSubscribe(await Promise.all(e.map(async t=>Qc(qn({},t),{id:await this.getSubscriptionId(t.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const t=await this.rpcBatchFetchMessages(e);t&&t.messages&&(await D0(E.cjs.toMiliseconds(E.cjs.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(t.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}async restartToComplete(e){!this.relayer.connected&&!this.relayer.connecting&&(this.cached.push(e),await this.relayer.transportOpen())}async getClientId(){return this.clientId||(this.clientId=await this.relayer.core.crypto.getClientId()),this.clientId}async getSubscriptionId(e){return ti(e+await this.getClientId())}};var VN=Object.defineProperty,Fd=Object.getOwnPropertySymbols,KN=Object.prototype.hasOwnProperty,GN=Object.prototype.propertyIsEnumerable,sh=(s,e,t)=>e in s?VN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,qd=(s,e)=>{for(var t in e||(e={}))KN.call(e,t)&&sh(s,t,e[t]);if(Fd)for(var t of Fd(e))GN.call(e,t)&&sh(s,t,e[t]);return s},fe=(s,e,t)=>sh(s,typeof e!="symbol"?e+"":e,t);let YN=class extends bv{constructor(e){super(e),fe(this,"protocol","wc"),fe(this,"version",2),fe(this,"core"),fe(this,"logger"),fe(this,"events",new te.eventsExports.EventEmitter),fe(this,"provider"),fe(this,"messages"),fe(this,"subscriber"),fe(this,"publisher"),fe(this,"name",PE),fe(this,"transportExplicitlyClosed",!1),fe(this,"initialized",!1),fe(this,"connectionAttemptInProgress",!1),fe(this,"relayUrl"),fe(this,"projectId"),fe(this,"packageName"),fe(this,"bundleId"),fe(this,"hasExperiencedNetworkDisruption",!1),fe(this,"pingTimeout"),fe(this,"heartBeatTimeout",E.cjs.toMiliseconds(E.cjs.THIRTY_SECONDS+E.cjs.FIVE_SECONDS)),fe(this,"reconnectTimeout"),fe(this,"connectPromise"),fe(this,"reconnectInProgress",!1),fe(this,"requestsInFlight",[]),fe(this,"connectTimeout",E.cjs.toMiliseconds(E.cjs.ONE_SECOND*15)),fe(this,"request",async t=>{var i,r;this.logger.debug("Publishing Request Payload");const n=t.id||m.getBigIntRpcId().toString();await this.toEstablishConnection();try{this.logger.trace({id:n,method:t.method,topic:(i=t.params)==null?void 0:i.topic},"relayer.request - publishing...");const o=`${n}:${((r=t.params)==null?void 0:r.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(t);return this.requestsInFlight=this.requestsInFlight.filter(l=>l!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${n}`),o}}),fe(this,"resetPingTimeout",()=>{if(Qa())try{clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var t,i,r;this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(r=(i=(t=this.provider)==null?void 0:t.connection)==null?void 0:i.socket)==null||r.terminate()},this.heartBeatTimeout)}catch(t){this.logger.warn(t,t==null?void 0:t.message)}}),fe(this,"onPayloadHandler",t=>{this.onProviderPayload(t),this.resetPingTimeout()}),fe(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(yt.connect)}),fe(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),fe(this,"onProviderErrorHandler",t=>{this.logger.fatal(`Fatal socket error: ${t.message}`),this.events.emit(yt.error,t),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),fe(this,"registerProviderListeners",()=>{this.provider.on(us.payload,this.onPayloadHandler),this.provider.on(us.connect,this.onConnectHandler),this.provider.on(us.disconnect,this.onDisconnectHandler),this.provider.on(us.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?m.E(e.logger,this.name):m.Dg(m.k({level:e.logger||$E})),this.messages=new TN(this.logger,e.core),this.subscriber=new WN(this,this.logger),this.publisher=new jN(this,this.logger),this.relayUrl=(e==null?void 0:e.relayUrl)||Bm,this.projectId=e.projectId,b0()?this.packageName=Wu():v0()&&(this.bundleId=Wu()),this.provider={}}async init(){if(this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.subscriber.hasAnyTopics)try{await this.transportOpen()}catch(e){this.logger.warn(e,e==null?void 0:e.message)}}get context(){return m.y(this.logger)}get connected(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===1||!1}get connecting(){var e,t,i;return((i=(t=(e=this.provider)==null?void 0:e.connection)==null?void 0:t.socket)==null?void 0:i.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,t,i){this.isInitialized(),await this.publisher.publish(e,t,i),await this.recordMessageEvent({topic:e,message:t,publishedAt:Date.now(),transportType:We.relay})}async subscribe(e,t){var i,r,n;this.isInitialized(),(!(t!=null&&t.transportType)||(t==null?void 0:t.transportType)==="relay")&&await this.toEstablishConnection();const o=typeof((i=t==null?void 0:t.internal)==null?void 0:i.throwOnFailedPublish)>"u"?!0:(r=t==null?void 0:t.internal)==null?void 0:r.throwOnFailedPublish;let a=((n=this.subscriber.topicMap.get(e))==null?void 0:n[0])||"",l;const c=h=>{h.topic===e&&(this.subscriber.off(is.created,c),l())};return await Promise.all([new Promise(h=>{l=h,this.subscriber.on(is.created,c)}),new Promise(async(h,u)=>{a=await this.subscriber.subscribe(e,qd({internal:{throwOnFailedPublish:o}},t)).catch(d=>{o&&u(d)})||a,h()})]),a}async unsubscribe(e,t){this.isInitialized(),await this.subscriber.unsubscribe(e,t)}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}off(e,t){this.events.off(e,t)}removeListener(e,t){this.events.removeListener(e,t)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await vi(this.provider.disconnect(),2e3,"provider.disconnect()").catch(()=>this.onProviderDisconnect()):this.onProviderDisconnect()}async transportClose(){this.transportExplicitlyClosed=!0,await this.transportDisconnect()}async transportOpen(e){if(!this.subscriber.hasAnyTopics){this.logger.warn("Starting WS connection skipped because the client has no topics to work with.");return}if(this.connectPromise?(this.logger.debug({},"Waiting for existing connection attempt to resolve..."),await this.connectPromise,this.logger.debug({},"Existing connection attempt resolved")):(this.connectPromise=new Promise(async(t,i)=>{await this.connect(e).then(t).catch(i).finally(()=>{this.connectPromise=void 0})}),await this.connectPromise),!this.connected)throw new Error(`Couldn't establish socket connection to the relay server: ${this.relayUrl}`)}async restartTransport(e){this.logger.debug({},"Restarting transport..."),!this.connectionAttemptInProgress&&(this.relayUrl=e||this.relayUrl,await this.confirmOnlineStateOrThrow(),await this.transportClose(),await this.transportOpen())}async confirmOnlineStateOrThrow(){if(!await Sd())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if((e==null?void 0:e.length)===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const t=e.sort((i,r)=>i.publishedAt-r.publishedAt);this.logger.debug(`Batch of ${t.length} message events sorted`);for(const i of t)try{await this.onMessageEvent(i)}catch(r){this.logger.warn(r,"Error while processing batch message event: "+(r==null?void 0:r.message))}this.logger.trace(`Batch of ${t.length} message events processed`)}async onLinkMessageEvent(e,t){const{topic:i}=e;if(!t.sessionExists){const r=at(E.cjs.FIVE_MINUTES),n={topic:i,expiry:r,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(i,n)}this.events.emit(yt.message,e),await this.recordMessageEvent(e)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let t=1;for(;t<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${t}...`),await this.createProvider(),await new Promise(async(i,r)=>{const n=()=>{r(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(us.disconnect,n),await vi(new Promise((o,a)=>{this.provider.connect().then(o).catch(a)}),this.connectTimeout,`Socket stalled when trying to connect to ${this.relayUrl}`).catch(o=>{r(o)}).finally(()=>{this.provider.off(us.disconnect,n),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const l=()=>{a(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(us.disconnect,l),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(us.disconnect,l)})}),this.hasExperiencedNetworkDisruption=!1,i()})}catch(i){await this.subscriber.stop();const r=i;this.logger.warn({},r.message),this.hasExperiencedNetworkDisruption=!0}finally{this.connectionAttemptInProgress=!1}if(this.connected){this.logger.debug({},`Connected to ${this.relayUrl} successfully on attempt: ${t}`);break}await new Promise(i=>setTimeout(i,E.cjs.toMiliseconds(t*1))),t++}}startPingTimeout(){var e,t,i,r,n;if(Qa())try{(t=(e=this.provider)==null?void 0:e.connection)!=null&&t.socket&&((n=(r=(i=this.provider)==null?void 0:i.connection)==null?void 0:r.socket)==null||n.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o==null?void 0:o.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ge(new Lm(N0({sdkVersion:Zl,protocol:this.protocol,version:this.version,relayUrl:this.relayUrl,projectId:this.projectId,auth:e,useOnCloseEvent:!0,bundleId:this.bundleId,packageName:this.packageName}))),this.registerProviderListeners()}async recordMessageEvent(e){const{topic:t,message:i}=e;await this.messages.set(t,i)}async shouldIgnoreMessageEvent(e){const{topic:t,message:i}=e;if(!i||i.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${i}`),!0;if(!await this.subscriber.isSubscribed(t))return this.logger.warn(`Ignoring message for non-subscribed topic ${t}`),!0;const r=this.messages.has(t,i);return r&&this.logger.warn(`Ignoring duplicate message: ${i}`),r}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),m.isJsonRpcRequest(e)){if(!e.method.endsWith(TE))return;const t=e.params,{topic:i,message:r,publishedAt:n,attestation:o}=t.data,a={topic:i,message:r,publishedAt:n,transportType:We.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(qd({type:"event",event:t.id},a)),this.events.emit(t.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else m.isJsonRpcResponse(e)&&this.events.emit(yt.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(this.events.emit(yt.message,e),await this.recordMessageEvent(e))}async acknowledgePayload(e){const t=m.formatJsonRpcResult(e.id,!0);await this.provider.connection.send(t)}unregisterProviderListeners(){this.provider.off(us.payload,this.onPayloadHandler),this.provider.off(us.connect,this.onConnectHandler),this.provider.off(us.disconnect,this.onDisconnectHandler),this.provider.off(us.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await Sd();pE(async t=>{e!==t&&(e=t,t?await this.transportOpen().catch(i=>this.logger.error(i,i==null?void 0:i.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(yt.disconnect),this.connectionAttemptInProgress=!1,!this.reconnectInProgress&&(this.reconnectInProgress=!0,await this.subscriber.stop(),this.subscriber.hasAnyTopics&&(this.transportExplicitlyClosed||(this.reconnectTimeout=setTimeout(async()=>{await this.transportOpen().catch(e=>this.logger.error(e,e==null?void 0:e.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},E.cjs.toMiliseconds(ME)))))}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){await this.confirmOnlineStateOrThrow(),!this.connected&&await this.connect()}};var QN=Object.defineProperty,Bd=Object.getOwnPropertySymbols,ZN=Object.prototype.hasOwnProperty,JN=Object.prototype.propertyIsEnumerable,ih=(s,e,t)=>e in s?QN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Hd=(s,e)=>{for(var t in e||(e={}))ZN.call(e,t)&&ih(s,t,e[t]);if(Bd)for(var t of Bd(e))JN.call(e,t)&&ih(s,t,e[t]);return s},Bt=(s,e,t)=>ih(s,typeof e!="symbol"?e+"":e,t);let pr=class extends vv{constructor(e,t,i,r=Ws,n=void 0){super(e,t,i,r),this.core=e,this.logger=t,this.name=i,Bt(this,"map",new Map),Bt(this,"version",xE),Bt(this,"cached",[]),Bt(this,"initialized",!1),Bt(this,"getKey"),Bt(this,"storagePrefix",Ws),Bt(this,"recentlyDeleted",[]),Bt(this,"recentlyDeletedLimit",200),Bt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!Ft(o)?this.map.set(this.getKey(o),o):H1(o)?this.map.set(o.id,o):W1(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),Bt(this,"set",async(o,a)=>{this.isInitialized(),this.map.has(o)?await this.update(o,a):(this.logger.debug("Setting value"),this.logger.trace({type:"method",method:"set",key:o,value:a}),this.map.set(o,a),await this.persist())}),Bt(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),Bt(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(l=>m.Gi(a[l],o[l]))):this.values)),Bt(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const l=Hd(Hd({},this.getData(o)),a);this.map.set(o,l),await this.persist()}),Bt(this,"delete",async(o,a)=>{this.isInitialized(),this.map.has(o)&&(this.logger.debug("Deleting value"),this.logger.trace({type:"method",method:"delete",key:o,reason:a}),this.map.delete(o),this.addToRecentlyDeleted(o),await this.persist())}),this.logger=m.E(t,this.name),this.storagePrefix=r,this.getKey=n}get context(){return m.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.map.size}get keys(){return Array.from(this.map.keys())}get values(){return Array.from(this.map.values())}addToRecentlyDeleted(e){this.recentlyDeleted.push(e),this.recentlyDeleted.length>=this.recentlyDeletedLimit&&this.recentlyDeleted.splice(0,this.recentlyDeletedLimit/2)}async setDataStore(e){await this.core.storage.setItem(this.storageKey,e)}async getDataStore(){return await this.core.storage.getItem(this.storageKey)}getData(e){const t=this.map.get(e);if(!t){if(this.recentlyDeleted.includes(e)){const{message:r}=j("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}const{message:i}=j("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(i),new Error(i)}return t}async persist(){await this.setDataStore(this.values)}async restore(){try{const e=await this.getDataStore();if(typeof e>"u"||!e.length)return;if(this.map.size){const{message:t}=j("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored value for ${this.name}`),this.logger.trace({type:"method",method:"restore",value:this.values})}catch(e){this.logger.debug(`Failed to Restore value for ${this.name}`),this.logger.error(e)}}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}};var XN=Object.defineProperty,e_=(s,e,t)=>e in s?XN(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,le=(s,e,t)=>e_(s,typeof e!="symbol"?e+"":e,t);let t_=class{constructor(e,t){this.core=e,this.logger=t,le(this,"name",RE),le(this,"version",UE),le(this,"events",new te.EventEmitter),le(this,"pairings"),le(this,"initialized",!1),le(this,"storagePrefix",Ws),le(this,"ignoredPayloadTypes",[ii]),le(this,"registeredMethods",[]),le(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),le(this,"register",({methods:i})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...i])]}),le(this,"create",async i=>{this.isInitialized();const r=Yl(),n=await this.core.crypto.setSymKey(r),o=at(E.cjs.FIVE_MINUTES),a={protocol:qm},l={topic:n,expiry:o,relay:a,active:!1,methods:i==null?void 0:i.methods},c=Id({protocol:this.core.protocol,version:this.core.version,topic:n,symKey:r,relay:a,expiryTimestamp:o,methods:i==null?void 0:i.methods});return this.events.emit(Wi.create,l),this.core.expirer.set(n,o),await this.pairings.set(n,l),await this.core.relayer.subscribe(n,{transportType:i==null?void 0:i.transportType}),{topic:n,uri:c}}),le(this,"pair",async i=>{this.isInitialized();const r=this.core.eventClient.createEvent({properties:{topic:i==null?void 0:i.uri,trace:[Fs.pairing_started]}});this.isValidPair(i,r);const{topic:n,symKey:o,relay:a,expiryTimestamp:l,methods:c}=vd(i.uri);r.props.properties.topic=n,r.addTrace(Fs.pairing_uri_validation_success),r.addTrace(Fs.pairing_uri_not_expired);let h;if(this.pairings.keys.includes(n)){if(h=this.pairings.get(n),r.addTrace(Fs.existing_pairing),h.active)throw r.setError(Xs.active_pairing_already_exists),new Error(`Pairing already exists: ${n}. Please try again with a new connection URI.`);r.addTrace(Fs.pairing_not_expired)}const u=l||at(E.cjs.FIVE_MINUTES),d={topic:n,relay:a,expiry:u,active:!1,methods:c};this.core.expirer.set(n,u),await this.pairings.set(n,d),r.addTrace(Fs.store_new_pairing),i.activatePairing&&await this.activate({topic:n}),this.events.emit(Wi.create,d),r.addTrace(Fs.emit_inactive_pairing),this.core.crypto.keychain.has(n)||await this.core.crypto.setSymKey(o,n),r.addTrace(Fs.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{r.setError(Xs.no_internet_connection)}try{await this.core.relayer.subscribe(n,{relay:a})}catch(p){throw r.setError(Xs.subscribe_pairing_topic_failure),p}return r.addTrace(Fs.subscribe_pairing_topic_success),d}),le(this,"activate",async({topic:i})=>{this.isInitialized();const r=at(E.cjs.FIVE_MINUTES);this.core.expirer.set(i,r),await this.pairings.update(i,{active:!0,expiry:r})}),le(this,"ping",async i=>{this.isInitialized(),await this.isValidPing(i),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:r}=i;if(this.pairings.keys.includes(r)){const n=await this.sendRequest(r,"wc_pairingPing",{}),{done:o,resolve:a,reject:l}=Fi();this.events.once(Ae("pairing_ping",n),({error:c})=>{c?l(c):a()}),await o()}}),le(this,"updateExpiry",async({topic:i,expiry:r})=>{this.isInitialized(),await this.pairings.update(i,{expiry:r})}),le(this,"updateMetadata",async({topic:i,metadata:r})=>{this.isInitialized(),await this.pairings.update(i,{peerMetadata:r})}),le(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),le(this,"disconnect",async i=>{this.isInitialized(),await this.isValidDisconnect(i);const{topic:r}=i;this.pairings.keys.includes(r)&&(await this.sendRequest(r,"wc_pairingDelete",Te("USER_DISCONNECTED")),await this.deletePairing(r))}),le(this,"formatUriFromPairing",i=>{this.isInitialized();const{topic:r,relay:n,expiry:o,methods:a}=i,l=this.core.crypto.keychain.get(r);return Id({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:l,relay:n,expiryTimestamp:o,methods:a})}),le(this,"sendRequest",async(i,r,n)=>{const o=m.formatJsonRpcRequest(r,n),a=await this.core.crypto.encode(i,o),l=zn[r].req;return this.core.history.set(i,o),this.core.relayer.publish(i,a,l),o.id}),le(this,"sendResult",async(i,r,n)=>{const o=m.formatJsonRpcResult(i,n),a=await this.core.crypto.encode(r,o),l=(await this.core.history.get(r,i)).request.method,c=zn[l].res;await this.core.relayer.publish(r,a,c),await this.core.history.resolve(o)}),le(this,"sendError",async(i,r,n)=>{const o=m.formatJsonRpcError(i,n),a=await this.core.crypto.encode(r,o),l=(await this.core.history.get(r,i)).request.method,c=zn[l]?zn[l].res:zn.unregistered_method.res;await this.core.relayer.publish(r,a,c),await this.core.history.resolve(o)}),le(this,"deletePairing",async(i,r)=>{await this.core.relayer.unsubscribe(i),await Promise.all([this.pairings.delete(i,Te("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(i),r?Promise.resolve():this.core.expirer.del(i)])}),le(this,"cleanup",async()=>{const i=this.pairings.getAll().filter(r=>gi(r.expiry));await Promise.all(i.map(r=>this.deletePairing(r.topic)))}),le(this,"onRelayEventRequest",i=>{const{topic:r,payload:n}=i;switch(n.method){case"wc_pairingPing":return this.onPairingPingRequest(r,n);case"wc_pairingDelete":return this.onPairingDeleteRequest(r,n);default:return this.onUnknownRpcMethodRequest(r,n)}}),le(this,"onRelayEventResponse",async i=>{const{topic:r,payload:n}=i,o=(await this.core.history.get(r,n.id)).request.method;switch(o){case"wc_pairingPing":return this.onPairingPingResponse(r,n);default:return this.onUnknownRpcMethodResponse(o)}}),le(this,"onPairingPingRequest",async(i,r)=>{const{id:n}=r;try{this.isValidPing({topic:i}),await this.sendResult(n,i,!0),this.events.emit(Wi.ping,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),le(this,"onPairingPingResponse",(i,r)=>{const{id:n}=r;setTimeout(()=>{m.isJsonRpcResult(r)?this.events.emit(Ae("pairing_ping",n),{}):m.isJsonRpcError(r)&&this.events.emit(Ae("pairing_ping",n),{error:r.error})},500)}),le(this,"onPairingDeleteRequest",async(i,r)=>{const{id:n}=r;try{this.isValidDisconnect({topic:i}),await this.deletePairing(i),this.events.emit(Wi.delete,{id:n,topic:i})}catch(o){await this.sendError(n,i,o),this.logger.error(o)}}),le(this,"onUnknownRpcMethodRequest",async(i,r)=>{const{id:n,method:o}=r;try{if(this.registeredMethods.includes(o))return;const a=Te("WC_METHOD_UNSUPPORTED",o);await this.sendError(n,i,a),this.logger.error(a)}catch(a){await this.sendError(n,i,a),this.logger.error(a)}}),le(this,"onUnknownRpcMethodResponse",i=>{this.registeredMethods.includes(i)||this.logger.error(Te("WC_METHOD_UNSUPPORTED",i))}),le(this,"isValidPair",(i,r)=>{var n;if(!Qt(i)){const{message:a}=j("MISSING_OR_INVALID",`pair() params: ${i}`);throw r.setError(Xs.malformed_pairing_uri),new Error(a)}if(!B1(i.uri)){const{message:a}=j("MISSING_OR_INVALID",`pair() uri: ${i.uri}`);throw r.setError(Xs.malformed_pairing_uri),new Error(a)}const o=vd(i==null?void 0:i.uri);if(!((n=o==null?void 0:o.relay)!=null&&n.protocol)){const{message:a}=j("MISSING_OR_INVALID","pair() uri#relay-protocol");throw r.setError(Xs.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=j("MISSING_OR_INVALID","pair() uri#symKey");throw r.setError(Xs.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&E.cjs.toMiliseconds(o==null?void 0:o.expiryTimestamp)<Date.now()){r.setError(Xs.pairing_expired);const{message:a}=j("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),le(this,"isValidPing",async i=>{if(!Qt(i)){const{message:n}=j("MISSING_OR_INVALID",`ping() params: ${i}`);throw new Error(n)}const{topic:r}=i;await this.isValidPairingTopic(r)}),le(this,"isValidDisconnect",async i=>{if(!Qt(i)){const{message:n}=j("MISSING_OR_INVALID",`disconnect() params: ${i}`);throw new Error(n)}const{topic:r}=i;await this.isValidPairingTopic(r)}),le(this,"isValidPairingTopic",async i=>{if(!Xe(i,!1)){const{message:r}=j("MISSING_OR_INVALID",`pairing topic should be a string: ${i}`);throw new Error(r)}if(!this.pairings.keys.includes(i)){const{message:r}=j("NO_MATCHING_KEY",`pairing topic doesn't exist: ${i}`);throw new Error(r)}if(gi(this.pairings.get(i).expiry)){await this.deletePairing(i);const{message:r}=j("EXPIRED",`pairing topic: ${i}`);throw new Error(r)}}),this.core=e,this.logger=m.E(t,this.name),this.pairings=new pr(this.core,this.logger,this.name,this.storagePrefix)}get context(){return m.y(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(yt.message,async e=>{const{topic:t,message:i,transportType:r}=e;if(!this.pairings.keys.includes(t)||r===We.link_mode||this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(i)))return;const n=await this.core.crypto.decode(t,i);try{m.isJsonRpcRequest(n)?(this.core.history.set(t,n),this.onRelayEventRequest({topic:t,payload:n})):m.isJsonRpcResponse(n)&&(await this.core.history.resolve(n),await this.onRelayEventResponse({topic:t,payload:n}),this.core.history.delete(t,n.id))}catch(o){this.logger.error(o)}})}registerExpirerEvents(){this.core.expirer.on(ms.expired,async e=>{const{topic:t}=dm(e.target);t&&this.pairings.keys.includes(t)&&(await this.deletePairing(t,!0),this.events.emit(Wi.expire,{topic:t}))})}};var s_=Object.defineProperty,i_=(s,e,t)=>e in s?s_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,At=(s,e,t)=>i_(s,typeof e!="symbol"?e+"":e,t);let r_=class extends mv{constructor(e,t){super(e,t),this.core=e,this.logger=t,At(this,"records",new Map),At(this,"events",new te.eventsExports.EventEmitter),At(this,"name",LE),At(this,"version",zE),At(this,"cached",[]),At(this,"initialized",!1),At(this,"storagePrefix",Ws),At(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.records.set(i.id,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),At(this,"set",(i,r,n)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:i,request:r,chainId:n}),this.records.has(r.id))return;const o={id:r.id,topic:i,request:{method:r.method,params:r.params||null},chainId:n,expiry:at(E.cjs.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(As.created,o)}),At(this,"resolve",async i=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:i}),!this.records.has(i.id))return;const r=await this.getRecord(i.id);typeof r.response>"u"&&(r.response=m.isJsonRpcError(i)?{error:i.error}:{result:i.result},this.records.set(r.id,r),this.persist(),this.events.emit(As.updated,r))}),At(this,"get",async(i,r)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:i,id:r}),await this.getRecord(r))),At(this,"delete",(i,r)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:r}),this.values.forEach(n=>{if(n.topic===i){if(typeof r<"u"&&n.id!==r)return;this.records.delete(n.id),this.events.emit(As.deleted,n)}}),this.persist()}),At(this,"exists",async(i,r)=>(this.isInitialized(),this.records.has(r)?(await this.getRecord(r)).topic===i:!1)),At(this,"on",(i,r)=>{this.events.on(i,r)}),At(this,"once",(i,r)=>{this.events.once(i,r)}),At(this,"off",(i,r)=>{this.events.off(i,r)}),At(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),this.logger=m.E(t,this.name)}get context(){return m.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get size(){return this.records.size}get keys(){return Array.from(this.records.keys())}get values(){return Array.from(this.records.values())}get pending(){const e=[];return this.values.forEach(t=>{if(typeof t.response<"u")return;const i={topic:t.topic,request:m.formatJsonRpcRequest(t.request.method,t.request.params,t.id),chainId:t.chainId};return e.push(i)}),e}async setJsonRpcRecords(e){await this.core.storage.setItem(this.storageKey,e)}async getJsonRpcRecords(){return await this.core.storage.getItem(this.storageKey)}getRecord(e){this.isInitialized();const t=this.records.get(e);if(!t){const{message:i}=j("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(i)}return t}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(As.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:t}=j("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",records:this.values})}catch(e){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(e)}}registerEventListeners(){this.events.on(As.created,e=>{const t=As.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(As.updated,e=>{const t=As.updated;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.events.on(As.deleted,e=>{const t=As.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,record:e})}),this.core.heartbeat.on(xs.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(t=>{E.cjs.toMiliseconds(t.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${t.id}`),this.records.delete(t.id),this.events.emit(As.deleted,t,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}};var n_=Object.defineProperty,o_=(s,e,t)=>e in s?n_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Ot=(s,e,t)=>o_(s,typeof e!="symbol"?e+"":e,t);let a_=class extends Ev{constructor(e,t){super(e,t),this.core=e,this.logger=t,Ot(this,"expirations",new Map),Ot(this,"events",new te.eventsExports.EventEmitter),Ot(this,"name",FE),Ot(this,"version",qE),Ot(this,"cached",[]),Ot(this,"initialized",!1),Ot(this,"storagePrefix",Ws),Ot(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(i=>this.expirations.set(i.target,i)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ot(this,"has",i=>{try{const r=this.formatTarget(i);return typeof this.getExpiration(r)<"u"}catch{return!1}}),Ot(this,"set",(i,r)=>{this.isInitialized();const n=this.formatTarget(i),o={target:n,expiry:r};this.expirations.set(n,o),this.checkExpiry(n,o),this.events.emit(ms.created,{target:n,expiration:o})}),Ot(this,"get",i=>{this.isInitialized();const r=this.formatTarget(i);return this.getExpiration(r)}),Ot(this,"del",i=>{if(this.isInitialized(),this.has(i)){const r=this.formatTarget(i),n=this.getExpiration(r);this.expirations.delete(r),this.events.emit(ms.deleted,{target:r,expiration:n})}}),Ot(this,"on",(i,r)=>{this.events.on(i,r)}),Ot(this,"once",(i,r)=>{this.events.once(i,r)}),Ot(this,"off",(i,r)=>{this.events.off(i,r)}),Ot(this,"removeListener",(i,r)=>{this.events.removeListener(i,r)}),this.logger=m.E(t,this.name)}get context(){return m.y(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get length(){return this.expirations.size}get keys(){return Array.from(this.expirations.keys())}get values(){return Array.from(this.expirations.values())}formatTarget(e){if(typeof e=="string")return _0(e);if(typeof e=="number")return C0(e);const{message:t}=j("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(t)}async setExpirations(e){await this.core.storage.setItem(this.storageKey,e)}async getExpirations(){return await this.core.storage.getItem(this.storageKey)}async persist(){await this.setExpirations(this.values),this.events.emit(ms.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:t}=j("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(t),new Error(t)}this.cached=e,this.logger.debug(`Successfully Restored expirations for ${this.name}`),this.logger.trace({type:"method",method:"restore",expirations:this.values})}catch(e){this.logger.debug(`Failed to Restore expirations for ${this.name}`),this.logger.error(e)}}getExpiration(e){const t=this.expirations.get(e);if(!t){const{message:i}=j("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(i),new Error(i)}return t}checkExpiry(e,t){const{expiry:i}=t;E.cjs.toMiliseconds(i)-Date.now()<=0&&this.expire(e,t)}expire(e,t){this.expirations.delete(e),this.events.emit(ms.expired,{target:e,expiration:t})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,t)=>this.checkExpiry(t,e))}registerEventListeners(){this.core.heartbeat.on(xs.pulse,()=>this.checkExpirations()),this.events.on(ms.created,e=>{const t=ms.created;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(ms.expired,e=>{const t=ms.expired;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()}),this.events.on(ms.deleted,e=>{const t=ms.deleted;this.logger.info(`Emitting ${t}`),this.logger.debug({type:"event",event:t,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}};var c_=Object.defineProperty,l_=(s,e,t)=>e in s?c_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,tt=(s,e,t)=>l_(s,typeof e!="symbol"?e+"":e,t);let h_=class extends Av{constructor(e,t,i){super(e,t,i),this.core=e,this.logger=t,this.store=i,tt(this,"name",BE),tt(this,"abortController"),tt(this,"isDevEnv"),tt(this,"verifyUrlV3",WE),tt(this,"storagePrefix",Ws),tt(this,"version",Fm),tt(this,"publicKey"),tt(this,"fetchPromise"),tt(this,"init",async()=>{var r;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&E.cjs.toMiliseconds((r=this.publicKey)==null?void 0:r.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),tt(this,"register",async r=>{if(!Wo()||this.isDevEnv)return;const n=window.location.origin,{id:o,decryptedId:a}=r,l=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${n}&id=${o}&decryptedId=${a}`;try{const c=E.getDocument_1(),h=this.startAbortTimer(E.cjs.ONE_SECOND*5),u=await new Promise((d,p)=>{const g=()=>{window.removeEventListener("message",b),c.body.removeChild(f),p("attestation aborted")};this.abortController.signal.addEventListener("abort",g);const f=c.createElement("iframe");f.src=l,f.style.display="none",f.addEventListener("error",g,{signal:this.abortController.signal});const b=y=>{if(y.data&&typeof y.data=="string")try{const w=JSON.parse(y.data);if(w.type==="verify_attestation"){if(m.sn(w.attestation).payload.id!==o)return;clearInterval(h),c.body.removeChild(f),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",b),d(w.attestation===null?"":w.attestation)}}catch(w){this.logger.warn(w)}};c.body.appendChild(f),window.addEventListener("message",b,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",u),u}catch(c){this.logger.warn(c)}return""}),tt(this,"resolve",async r=>{if(this.isDevEnv)return"";const{attestationId:n,hash:o,encryptedId:a}=r;if(n===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(n){if(m.sn(n).payload.id!==a)return;const c=await this.isValidJwtAttestation(n);if(c){if(!c.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return c}}if(!o)return;const l=this.getVerifyUrl(r==null?void 0:r.verifyUrl);return this.fetchAttestation(o,l)}),tt(this,"fetchAttestation",async(r,n)=>{this.logger.debug(`resolving attestation: ${r} from url: ${n}`);const o=this.startAbortTimer(E.cjs.ONE_SECOND*5),a=await fetch(`${n}/attestation/${r}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),tt(this,"getVerifyUrl",r=>{let n=r||go;return VE.includes(n)||(this.logger.info(`verify url: ${n}, not included in trusted list, assigning default: ${go}`),n=go),n}),tt(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const r=this.startAbortTimer(E.cjs.FIVE_SECONDS),n=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(r),await n.json()}catch(r){this.logger.warn(r)}}),tt(this,"persistPublicKey",async r=>{this.logger.debug("persisting public key to local storage",r),await this.store.setItem(this.storeKey,r),this.publicKey=r}),tt(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),tt(this,"isValidJwtAttestation",async r=>{const n=await this.getPublicKey();try{if(n)return this.validateAttestation(r,n)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}const o=await this.fetchAndPersistPublicKey();try{if(o)return this.validateAttestation(r,o)}catch(a){this.logger.error(a),this.logger.warn("error validating attestation")}}),tt(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),tt(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async n=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),n(o))});const r=await this.fetchPromise;return this.fetchPromise=void 0,r}),tt(this,"validateAttestation",(r,n)=>{const o=T1(r,n.publicKey),a={hasExpired:E.cjs.toMiliseconds(o.exp)<Date.now(),payload:o};if(a.hasExpired)throw this.logger.warn("resolve: jwt attestation expired"),new Error("JWT attestation expired");return{origin:a.payload.origin,isScam:a.payload.isScam,isVerified:a.payload.isVerified}}),this.logger=m.E(t,this.name),this.abortController=new AbortController,this.isDevEnv=Kh(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return m.y(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),E.cjs.toMiliseconds(e))}};var u_=Object.defineProperty,d_=(s,e,t)=>e in s?u_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Wd=(s,e,t)=>d_(s,typeof e!="symbol"?e+"":e,t);let p_=class extends Nv{constructor(e,t){super(e,t),this.projectId=e,this.logger=t,Wd(this,"context",KE),Wd(this,"registerDeviceToken",async i=>{const{clientId:r,token:n,notificationType:o,enableEncrypted:a=!1}=i,l=`${GE}/${this.projectId}/clients`;await fetch(l,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:r,type:o,token:n,always_raw:a})})}),this.logger=m.E(t,this.context)}};var g_=Object.defineProperty,Vd=Object.getOwnPropertySymbols,f_=Object.prototype.hasOwnProperty,m_=Object.prototype.propertyIsEnumerable,rh=(s,e,t)=>e in s?g_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Bn=(s,e)=>{for(var t in e||(e={}))f_.call(e,t)&&rh(s,t,e[t]);if(Vd)for(var t of Vd(e))m_.call(e,t)&&rh(s,t,e[t]);return s},ut=(s,e,t)=>rh(s,typeof e!="symbol"?e+"":e,t);let w_=class extends _v{constructor(e,t,i=!0){super(e,t,i),this.core=e,this.logger=t,ut(this,"context",QE),ut(this,"storagePrefix",Ws),ut(this,"storageVersion",YE),ut(this,"events",new Map),ut(this,"shouldPersist",!1),ut(this,"init",async()=>{if(!Kh())try{const r={eventId:Ku(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:cm(this.core.relayer.protocol,this.core.relayer.version,Zl)}}};await this.sendEvent([r])}catch(r){this.logger.warn(r)}}),ut(this,"createEvent",r=>{const{event:n="ERROR",type:o="",properties:{topic:a,trace:l}}=r,c=Ku(),h=this.core.projectId||"",u=Date.now(),d=Bn({eventId:c,timestamp:u,props:{event:n,type:o,properties:{topic:a,trace:l}},bundleId:h,domain:this.getAppDomain()},this.setMethods(c));return this.telemetryEnabled&&(this.events.set(c,d),this.shouldPersist=!0),d}),ut(this,"getEvent",r=>{const{eventId:n,topic:o}=r;if(n)return this.events.get(n);const a=Array.from(this.events.values()).find(l=>l.props.properties.topic===o);if(a)return Bn(Bn({},a),this.setMethods(a.eventId))}),ut(this,"deleteEvent",r=>{const{eventId:n}=r;this.events.delete(n),this.shouldPersist=!0}),ut(this,"setEventListeners",()=>{this.core.heartbeat.on(xs.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(r=>{E.cjs.fromMiliseconds(Date.now())-E.cjs.fromMiliseconds(r.timestamp)>ZE&&(this.events.delete(r.eventId),this.shouldPersist=!0)})})}),ut(this,"setMethods",r=>({addTrace:n=>this.addTrace(r,n),setError:n=>this.setError(r,n)})),ut(this,"addTrace",(r,n)=>{const o=this.events.get(r);o&&(o.props.properties.trace.push(n),this.events.set(r,o),this.shouldPersist=!0)}),ut(this,"setError",(r,n)=>{const o=this.events.get(r);o&&(o.props.type=n,o.timestamp=Date.now(),this.events.set(r,o),this.shouldPersist=!0)}),ut(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),ut(this,"restore",async()=>{try{const r=await this.core.storage.getItem(this.storageKey)||[];if(!r.length)return;r.forEach(n=>{this.events.set(n.eventId,Bn(Bn({},n),this.setMethods(n.eventId)))})}catch(r){this.logger.warn(r)}}),ut(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const r=[];for(const[n,o]of this.events)o.props.type&&r.push(o);if(r.length!==0)try{if((await this.sendEvent(r)).ok)for(const n of r)this.events.delete(n.eventId),this.shouldPersist=!0}catch(n){this.logger.warn(n)}}),ut(this,"sendEvent",async r=>{const n=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${JE}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Zl}${n}`,{method:"POST",body:JSON.stringify(r)})}),ut(this,"getAppDomain",()=>am().url),this.logger=m.E(t,this.context),this.telemetryEnabled=i,i?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}};var y_=Object.defineProperty,Kd=Object.getOwnPropertySymbols,b_=Object.prototype.hasOwnProperty,v_=Object.prototype.propertyIsEnumerable,nh=(s,e,t)=>e in s?y_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Gd=(s,e)=>{for(var t in e||(e={}))b_.call(e,t)&&nh(s,t,e[t]);if(Kd)for(var t of Kd(e))v_.call(e,t)&&nh(s,t,e[t]);return s},Re=(s,e,t)=>nh(s,typeof e!="symbol"?e+"":e,t);let I_=class tw extends dv{constructor(e){var t;super(e),Re(this,"protocol",zm),Re(this,"version",Fm),Re(this,"name",Ql),Re(this,"relayUrl"),Re(this,"projectId"),Re(this,"customStoragePrefix"),Re(this,"events",new te.eventsExports.EventEmitter),Re(this,"logger"),Re(this,"heartbeat"),Re(this,"relayer"),Re(this,"crypto"),Re(this,"storage"),Re(this,"history"),Re(this,"expirer"),Re(this,"pairing"),Re(this,"verify"),Re(this,"echoClient"),Re(this,"linkModeSupportedApps"),Re(this,"eventClient"),Re(this,"initialized",!1),Re(this,"logChunkController"),Re(this,"on",(o,a)=>this.events.on(o,a)),Re(this,"once",(o,a)=>this.events.once(o,a)),Re(this,"off",(o,a)=>this.events.off(o,a)),Re(this,"removeListener",(o,a)=>this.events.removeListener(o,a)),Re(this,"dispatchEnvelope",({topic:o,message:a,sessionExists:l})=>{if(!o||!a)return;const c={topic:o,message:a,publishedAt:Date.now(),transportType:We.link_mode};this.relayer.onLinkMessageEvent(c,{sessionExists:l})}),this.projectId=e==null?void 0:e.projectId,this.relayUrl=(e==null?void 0:e.relayUrl)||Bm,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const i=m.k({level:typeof(e==null?void 0:e.logger)=="string"&&e.logger?e.logger:bE.logger,name:Ql}),{logger:r,chunkLoggerController:n}=m.A({opts:i,maxSizeInBytes:e==null?void 0:e.maxLogBlobSizeInBytes,loggerOverride:e==null?void 0:e.logger});this.logChunkController=n,(t=this.logChunkController)!=null&&t.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var o,a;(o=this.logChunkController)!=null&&o.downloadLogsBlobInBrowser&&((a=this.logChunkController)==null||a.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=m.E(r,this.name),this.heartbeat=new Ff,this.crypto=new SN(this,this.logger,e==null?void 0:e.keychain),this.history=new r_(this,this.logger),this.expirer=new a_(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new lv(Gd(Gd({},vE),e==null?void 0:e.storageOptions)),this.relayer=new YN({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new t_(this,this.logger),this.verify=new h_(this,this.logger,this.storage),this.echoClient=new p_(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new w_(this,this.logger,e==null?void 0:e.telemetryEnabled)}static async init(e){const t=new tw(e);await t.initialize();const i=await t.crypto.getClientId();return await t.storage.setItem(OE,i),t}get context(){return m.y(this.logger)}async start(){this.initialized||await this.initialize()}async getLogsBlob(){var e;return(e=this.logChunkController)==null?void 0:e.logsToBlob({clientId:await this.crypto.getClientId()})}async addLinkModeSupportedApp(e){this.linkModeSupportedApps.includes(e)||(this.linkModeSupportedApps.push(e),await this.storage.setItem(xd,this.linkModeSupportedApps))}async initialize(){this.logger.trace("Initialized");try{await this.crypto.init(),await this.history.init(),await this.expirer.init(),await this.relayer.init(),await this.heartbeat.init(),await this.pairing.init(),this.linkModeSupportedApps=await this.storage.getItem(xd)||[],this.initialized=!0,this.logger.info("Core Initialization Success")}catch(e){throw this.logger.warn(`Core Initialization Failure at epoch ${Date.now()}`,e),this.logger.error(e.message),e}}};const E_=I_;var A_=Object.defineProperty,N_=(s,e,t)=>e in s?A_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Yd=(s,e,t)=>N_(s,typeof e!="symbol"?e+"":e,t);let __=class{constructor(e){this.opts=e,Yd(this,"protocol","wc"),Yd(this,"version",2)}},C_=class{constructor(e){this.client=e}};const sw="wc",iw=2,rw="client",su=`${sw}@${iw}:${rw}:`,Zc={name:rw,logger:"error"},Qd="WALLETCONNECT_DEEPLINK_CHOICE",S_="proposal",Zd="Proposal expired",$_="session",_r=E.cjs.SEVEN_DAYS,P_="engine",dt={wc_sessionPropose:{req:{ttl:E.cjs.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1104},res:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1106},res:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:E.cjs.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:E.cjs.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1112},res:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1114},res:{ttl:E.cjs.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:E.cjs.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:E.cjs.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:E.cjs.FIVE_MINUTES,prompt:!1,tag:1119}}},Jc={min:E.cjs.FIVE_MINUTES,max:E.cjs.SEVEN_DAYS},js={idle:"IDLE",active:"ACTIVE"},Jd={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"}},T_="request",M_=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],x_="wc",O_="auth",D_="authKeys",k_="pairingTopics",j_="requests",vc=`${x_}@${1.5}:${O_}:`,Ua=`${vc}:PUB_KEY`;var R_=Object.defineProperty,U_=Object.defineProperties,L_=Object.getOwnPropertyDescriptors,Xd=Object.getOwnPropertySymbols,z_=Object.prototype.hasOwnProperty,F_=Object.prototype.propertyIsEnumerable,oh=(s,e,t)=>e in s?R_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Qe=(s,e)=>{for(var t in e||(e={}))z_.call(e,t)&&oh(s,t,e[t]);if(Xd)for(var t of Xd(e))F_.call(e,t)&&oh(s,t,e[t]);return s},Ht=(s,e)=>U_(s,L_(e)),D=(s,e,t)=>oh(s,typeof e!="symbol"?e+"":e,t);let q_=class extends C_{constructor(e){super(e),D(this,"name",P_),D(this,"events",new te.EventEmitter),D(this,"initialized",!1),D(this,"requestQueue",{state:js.idle,queue:[]}),D(this,"sessionRequestQueue",{state:js.idle,queue:[]}),D(this,"requestQueueDelay",E.cjs.ONE_SECOND),D(this,"expectedPairingMethodMap",new Map),D(this,"recentlyDeletedMap",new Map),D(this,"recentlyDeletedLimit",200),D(this,"relayMessageCache",[]),D(this,"pendingSessions",new Map),D(this,"init",async()=>{this.initialized||(await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.registerPairingEvents(),await this.registerLinkModeListeners(),this.client.core.pairing.register({methods:Object.keys(dt)}),this.initialized=!0,setTimeout(()=>{this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},E.cjs.toMiliseconds(this.requestQueueDelay)))}),D(this,"connect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const i=Ht(Qe({},t),{requiredNamespaces:t.requiredNamespaces||{},optionalNamespaces:t.optionalNamespaces||{}});await this.isValidConnect(i);const{pairingTopic:r,requiredNamespaces:n,optionalNamespaces:o,sessionProperties:a,relays:l}=i;let c=r,h,u=!1;try{if(c){const C=this.client.core.pairing.pairings.get(c);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),u=C.active}}catch(C){throw this.client.logger.error(`connect() -> pairing.get(${c}) failed`),C}if(!c||!u){const{topic:C,uri:P}=await this.client.core.pairing.create();c=C,h=P}if(!c){const{message:C}=j("NO_MATCHING_KEY",`connect() pairing topic: ${c}`);throw new Error(C)}const d=await this.client.core.crypto.generateKeyPair(),p=dt.wc_sessionPropose.req.ttl||E.cjs.FIVE_MINUTES,g=at(p),f=Ht(Qe({requiredNamespaces:n,optionalNamespaces:o,relays:l??[{protocol:qm}],proposer:{publicKey:d,metadata:this.client.metadata},expiryTimestamp:g,pairingTopic:c},a&&{sessionProperties:a}),{id:m.payloadId()}),b=Ae("session_connect",f.id),{reject:y,resolve:w,done:v}=Fi(p,Zd),A=({id:C})=>{C===f.id&&(this.client.events.off("proposal_expire",A),this.pendingSessions.delete(f.id),this.events.emit(b,{error:{message:Zd,code:0}}))};return this.client.events.on("proposal_expire",A),this.events.once(b,({error:C,session:P})=>{this.client.events.off("proposal_expire",A),C?y(C):P&&w(P)}),await this.sendRequest({topic:c,method:"wc_sessionPropose",params:f,throwOnFailedPublish:!0,clientRpcId:f.id}),await this.setProposal(f.id,f),{uri:h,approval:v}}),D(this,"pair",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(t)}catch(i){throw this.client.logger.error("pair() failed"),i}}),D(this,"approve",async t=>{var i,r,n;const o=this.client.core.eventClient.createEvent({properties:{topic:(i=t==null?void 0:t.id)==null?void 0:i.toString(),trace:[Ns.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(O){throw o.setError(ji.no_internet_connection),O}try{await this.isValidProposalId(t==null?void 0:t.id)}catch(O){throw this.client.logger.error(`approve() -> proposal.get(${t==null?void 0:t.id}) failed`),o.setError(ji.proposal_not_found),O}try{await this.isValidApprove(t)}catch(O){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(ji.session_approve_namespace_validation_failure),O}const{id:a,relayProtocol:l,namespaces:c,sessionProperties:h,sessionConfig:u}=t,d=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:p,proposer:g,requiredNamespaces:f,optionalNamespaces:b}=d;let y=(r=this.client.core.eventClient)==null?void 0:r.getEvent({topic:p});y||(y=(n=this.client.core.eventClient)==null?void 0:n.createEvent({type:Ns.session_approve_started,properties:{topic:p,trace:[Ns.session_approve_started,Ns.session_namespaces_validation_success]}}));const w=await this.client.core.crypto.generateKeyPair(),v=g.publicKey,A=await this.client.core.crypto.generateSharedKey(w,v),C=Qe(Qe({relay:{protocol:l??"irn"},namespaces:c,controller:{publicKey:w,metadata:this.client.metadata},expiry:at(_r)},h&&{sessionProperties:h}),u&&{sessionConfig:u}),P=We.relay;y.addTrace(Ns.subscribing_session_topic);try{await this.client.core.relayer.subscribe(A,{transportType:P})}catch(O){throw y.setError(ji.subscribe_session_topic_failure),O}y.addTrace(Ns.subscribe_session_topic_success);const T=Ht(Qe({},C),{topic:A,requiredNamespaces:f,optionalNamespaces:b,pairingTopic:p,acknowledged:!1,self:C.controller,peer:{publicKey:g.publicKey,metadata:g.metadata},controller:w,transportType:We.relay});await this.client.session.set(A,T),y.addTrace(Ns.store_session);try{y.addTrace(Ns.publishing_session_settle),await this.sendRequest({topic:A,method:"wc_sessionSettle",params:C,throwOnFailedPublish:!0}).catch(O=>{throw y==null||y.setError(ji.session_settle_publish_failure),O}),y.addTrace(Ns.session_settle_publish_success),y.addTrace(Ns.publishing_session_approve),await this.sendResult({id:a,topic:p,result:{relay:{protocol:l??"irn"},responderPublicKey:w},throwOnFailedPublish:!0}).catch(O=>{throw y==null||y.setError(ji.session_approve_publish_failure),O}),y.addTrace(Ns.session_approve_publish_success)}catch(O){throw this.client.logger.error(O),this.client.session.delete(A,Te("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(A),O}return this.client.core.eventClient.deleteEvent({eventId:y.eventId}),await this.client.core.pairing.updateMetadata({topic:p,metadata:g.metadata}),await this.client.proposal.delete(a,Te("USER_DISCONNECTED")),await this.client.core.pairing.activate({topic:p}),await this.setExpiry(A,at(_r)),{topic:A,acknowledged:()=>Promise.resolve(this.client.session.get(A))}}),D(this,"reject",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(t)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:i,reason:r}=t;let n;try{n=this.client.proposal.get(i).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${i}) failed`),o}n&&(await this.sendError({id:i,topic:n,error:r,rpcOpts:dt.wc_sessionPropose.reject}),await this.client.proposal.delete(i,Te("USER_DISCONNECTED")))}),D(this,"update",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(t)}catch(u){throw this.client.logger.error("update() -> isValidUpdate() failed"),u}const{topic:i,namespaces:r}=t,{done:n,resolve:o,reject:a}=Fi(),l=m.payloadId(),c=m.getBigIntRpcId().toString(),h=this.client.session.get(i).namespaces;return this.events.once(Ae("session_update",l),({error:u})=>{u?a(u):o()}),await this.client.session.update(i,{namespaces:r}),await this.sendRequest({topic:i,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:l,relayRpcId:c}).catch(u=>{this.client.logger.error(u),this.client.session.update(i,{namespaces:h}),a(u)}),{acknowledged:n}}),D(this,"extend",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(t)}catch(l){throw this.client.logger.error("extend() -> isValidExtend() failed"),l}const{topic:i}=t,r=m.payloadId(),{done:n,resolve:o,reject:a}=Fi();return this.events.once(Ae("session_extend",r),({error:l})=>{l?a(l):o()}),await this.setExpiry(i,at(_r)),this.sendRequest({topic:i,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch(l=>{a(l)}),{acknowledged:n}}),D(this,"request",async t=>{this.isInitialized();try{await this.isValidRequest(t)}catch(y){throw this.client.logger.error("request() -> isValidRequest() failed"),y}const{chainId:i,request:r,topic:n,expiry:o=dt.wc_sessionRequest.req.ttl}=t,a=this.client.session.get(n);(a==null?void 0:a.transportType)===We.relay&&await this.confirmOnlineStateOrThrow();const l=m.payloadId(),c=m.getBigIntRpcId().toString(),{done:h,resolve:u,reject:d}=Fi(o,"Request expired. Please try again.");this.events.once(Ae("session_request",l),({error:y,result:w})=>{y?d(y):u(w)});const p="wc_sessionRequest",g=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(g)return await this.sendRequest({clientRpcId:l,relayRpcId:c,topic:n,method:p,params:{request:Ht(Qe({},r),{expiryTimestamp:at(o)}),chainId:i},expiry:o,throwOnFailedPublish:!0,appLink:g}).catch(y=>d(y)),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:i,id:l}),await h();const f={request:Ht(Qe({},r),{expiryTimestamp:at(o)}),chainId:i},b=this.shouldSetTVF(p,f);return await Promise.all([new Promise(async y=>{await this.sendRequest(Qe({clientRpcId:l,relayRpcId:c,topic:n,method:p,params:f,expiry:o,throwOnFailedPublish:!0},b&&{tvf:this.getTVFParams(l,f)})).catch(w=>d(w)),this.client.events.emit("session_request_sent",{topic:n,request:r,chainId:i,id:l}),y()}),new Promise(async y=>{var w;if(!((w=a.sessionConfig)!=null&&w.disableDeepLink)){const v=await T0(this.client.core.storage,Qd);await S0({id:l,topic:n,wcDeepLink:v})}y()}),h()]).then(y=>y[2])}),D(this,"respond",async t=>{this.isInitialized(),await this.isValidRespond(t);const{topic:i,response:r}=t,{id:n}=r,o=this.client.session.get(i);o.transportType===We.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);m.isJsonRpcResult(r)?await this.sendResult({id:n,topic:i,result:r.result,throwOnFailedPublish:!0,appLink:a}):m.isJsonRpcError(r)&&await this.sendError({id:n,topic:i,error:r.error,appLink:a}),this.cleanupAfterResponse(t)}),D(this,"ping",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(t)}catch(r){throw this.client.logger.error("ping() -> isValidPing() failed"),r}const{topic:i}=t;if(this.client.session.keys.includes(i)){const r=m.payloadId(),n=m.getBigIntRpcId().toString(),{done:o,resolve:a,reject:l}=Fi();this.events.once(Ae("session_ping",r),({error:c})=>{c?l(c):a()}),await Promise.all([this.sendRequest({topic:i,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:r,relayRpcId:n}),o()])}else this.client.core.pairing.pairings.keys.includes(i)&&(this.client.logger.warn("ping() on pairing topic is deprecated and will be removed in the next major release."),await this.client.core.pairing.ping({topic:i}))}),D(this,"emit",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(t);const{topic:i,event:r,chainId:n}=t,o=m.getBigIntRpcId().toString(),a=m.payloadId();await this.sendRequest({topic:i,method:"wc_sessionEvent",params:{event:r,chainId:n},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),D(this,"disconnect",async t=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(t);const{topic:i}=t;if(this.client.session.keys.includes(i))await this.sendRequest({topic:i,method:"wc_sessionDelete",params:Te("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:i,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(i))await this.client.core.pairing.disconnect({topic:i});else{const{message:r}=j("MISMATCHED_TOPIC",`Session or pairing topic not found: ${i}`);throw new Error(r)}}),D(this,"find",t=>(this.isInitialized(),this.client.session.getAll().filter(i=>F1(i,t)))),D(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),D(this,"authenticate",async(t,i)=>{var r;this.isInitialized(),this.isValidAuthenticate(t);const n=i&&this.client.core.linkModeSupportedApps.includes(i)&&((r=this.client.metadata.redirect)==null?void 0:r.linkMode),o=n?We.link_mode:We.relay;o===We.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:l="",uri:c,domain:h,nonce:u,type:d,exp:p,nbf:g,methods:f=[],expiry:b}=t,y=[...t.resources||[]],{topic:w,uri:v}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:w,uri:v}});const A=await this.client.core.crypto.generateKeyPair(),C=Ra(A);if(await Promise.all([this.client.auth.authKeys.set(Ua,{responseTopic:C,publicKey:A}),this.client.auth.pairingTopics.set(C,{topic:C,pairingTopic:w})]),await this.client.core.relayer.subscribe(C,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${w}`),f.length>0){const{namespace:_}=gn(a[0]);let F=vI(_,"request",f);ja(y)&&(F=EI(F,y.pop())),y.push(F)}const P=b&&b>dt.wc_sessionAuthenticate.req.ttl?b:dt.wc_sessionAuthenticate.req.ttl,T={authPayload:{type:d??"caip122",chains:a,statement:l,aud:c,domain:h,version:"1",nonce:u,iat:new Date().toISOString(),exp:p,nbf:g,resources:y},requester:{publicKey:A,metadata:this.client.metadata},expiryTimestamp:at(P)},O={eip155:{chains:a,methods:[...new Set(["personal_sign",...f])],events:["chainChanged","accountsChanged"]}},S={requiredNamespaces:{},optionalNamespaces:O,relays:[{protocol:"irn"}],pairingTopic:w,proposer:{publicKey:A,metadata:this.client.metadata},expiryTimestamp:at(dt.wc_sessionPropose.req.ttl),id:m.payloadId()},{done:M,resolve:$,reject:U}=Fi(P,"Request expired"),L=m.payloadId(),B=Ae("session_connect",S.id),H=Ae("session_request",L),z=async({error:_,session:F})=>{this.events.off(H,W),_?U(_):F&&$({session:F})},W=async _=>{var F,Q,G;if(await this.deletePendingAuthRequest(L,{message:"fulfilled",code:0}),_.error){const Be=Te("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return _.error.code===Be.code?void 0:(this.events.off(B,z),U(_.error.message))}await this.deleteProposal(S.id),this.events.off(B,z);const{cacaos:Ie,responder:ce}=_.result,xe=[],nt=[];for(const Be of Ie){await td({cacao:Be,projectId:this.client.core.projectId})||(this.client.logger.error(Be,"Signature verification failed"),U(Te("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:Oi}=Be,Di=ja(Oi.resources),On=[Bl(Oi.iss)],Dc=Za(Oi.iss);if(Di){const ki=sd(Di),kc=id(Di);xe.push(...ki),On.push(...kc)}for(const ki of On)nt.push(`${ki}:${Dc}`)}const qe=await this.client.core.crypto.generateSharedKey(A,ce.publicKey);let Ye;xe.length>0&&(Ye={topic:qe,acknowledged:!0,self:{publicKey:A,metadata:this.client.metadata},peer:ce,controller:ce.publicKey,expiry:at(_r),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:w,namespaces:Ed([...new Set(xe)],[...new Set(nt)]),transportType:o},await this.client.core.relayer.subscribe(qe,{transportType:o}),await this.client.session.set(qe,Ye),w&&await this.client.core.pairing.updateMetadata({topic:w,metadata:ce.metadata}),Ye=this.client.session.get(qe)),(F=this.client.metadata.redirect)!=null&&F.linkMode&&(Q=ce.metadata.redirect)!=null&&Q.linkMode&&(G=ce.metadata.redirect)!=null&&G.universal&&i&&(this.client.core.addLinkModeSupportedApp(ce.metadata.redirect.universal),this.client.session.update(qe,{transportType:We.link_mode})),$({auths:Ie,session:Ye})};this.events.once(B,z),this.events.once(H,W);let V;try{if(n){const _=m.formatJsonRpcRequest("wc_sessionAuthenticate",T,L);this.client.core.history.set(w,_);const F=await this.client.core.crypto.encode("",_,{type:Yo,encoding:Un});V=pa(i,w,F)}else await Promise.all([this.sendRequest({topic:w,method:"wc_sessionAuthenticate",params:T,expiry:t.expiry,throwOnFailedPublish:!0,clientRpcId:L}),this.sendRequest({topic:w,method:"wc_sessionPropose",params:S,expiry:dt.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:S.id})])}catch(_){throw this.events.off(B,z),this.events.off(H,W),_}return await this.setProposal(S.id,S),await this.setAuthRequest(L,{request:Ht(Qe({},T),{verifyContext:{}}),pairingTopic:w,transportType:o}),{uri:V??v,response:M}}),D(this,"approveSessionAuthenticate",async t=>{const{id:i,auths:r}=t,n=this.client.core.eventClient.createEvent({properties:{topic:i.toString(),trace:[Ri.authenticated_session_approve_started]}});try{this.isInitialized()}catch(b){throw n.setError(Fn.no_internet_connection),b}const o=this.getPendingAuthRequest(i);if(!o)throw n.setError(Fn.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${i}`);const a=o.transportType||We.relay;a===We.relay&&await this.confirmOnlineStateOrThrow();const l=o.requester.publicKey,c=await this.client.core.crypto.generateKeyPair(),h=Ra(l),u={type:ii,receiverPublicKey:l,senderPublicKey:c},d=[],p=[];for(const b of r){if(!await td({cacao:b,projectId:this.client.core.projectId})){n.setError(Fn.invalid_cacao);const C=Te("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:i,topic:h,error:C,encodeOpts:u}),new Error(C.message)}n.addTrace(Ri.cacaos_verified);const{p:y}=b,w=ja(y.resources),v=[Bl(y.iss)],A=Za(y.iss);if(w){const C=sd(w),P=id(w);d.push(...C),v.push(...P)}for(const C of v)p.push(`${C}:${A}`)}const g=await this.client.core.crypto.generateSharedKey(c,l);n.addTrace(Ri.create_authenticated_session_topic);let f;if((d==null?void 0:d.length)>0){f={topic:g,acknowledged:!0,self:{publicKey:c,metadata:this.client.metadata},peer:{publicKey:l,metadata:o.requester.metadata},controller:l,expiry:at(_r),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Ed([...new Set(d)],[...new Set(p)]),transportType:a},n.addTrace(Ri.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(b){throw n.setError(Fn.subscribe_authenticated_session_topic_failure),b}n.addTrace(Ri.subscribe_authenticated_session_topic_success),await this.client.session.set(g,f),n.addTrace(Ri.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}n.addTrace(Ri.publishing_authenticated_session_approve);try{await this.sendResult({topic:h,id:i,result:{cacaos:r,responder:{publicKey:c,metadata:this.client.metadata}},encodeOpts:u,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(b){throw n.setError(Fn.authenticated_session_approve_publish_failure),b}return await this.client.auth.requests.delete(i,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:n.eventId}),{session:f}}),D(this,"rejectSessionAuthenticate",async t=>{this.isInitialized();const{id:i,reason:r}=t,n=this.getPendingAuthRequest(i);if(!n)throw new Error(`Could not find pending auth request with id ${i}`);n.transportType===We.relay&&await this.confirmOnlineStateOrThrow();const o=n.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),l=Ra(o),c={type:ii,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:i,topic:l,error:r,encodeOpts:c,rpcOpts:dt.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(n.requester.metadata,n.transportType)}),await this.client.auth.requests.delete(i,{message:"rejected",code:0}),await this.client.proposal.delete(i,Te("USER_DISCONNECTED"))}),D(this,"formatAuthMessage",t=>{this.isInitialized();const{request:i,iss:r}=t;return Im(i,r)}),D(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const t=this.relayMessageCache.shift();t&&await this.onRelayMessage(t)}catch(t){this.client.logger.error(t)}},50)}),D(this,"cleanupDuplicatePairings",async t=>{if(t.pairingTopic)try{const i=this.client.core.pairing.pairings.get(t.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter(n=>{var o,a;return((o=n.peerMetadata)==null?void 0:o.url)&&((a=n.peerMetadata)==null?void 0:a.url)===t.peer.metadata.url&&n.topic&&n.topic!==i.topic});if(r.length===0)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map(n=>this.client.core.pairing.disconnect({topic:n.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(i){this.client.logger.error(i)}}),D(this,"deleteSession",async t=>{var i;const{topic:r,expirerHasDeleted:n=!1,emitEvent:o=!0,id:a=0}=t,{self:l}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,Te("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(l.publicKey)&&await this.client.core.crypto.deleteKeyPair(l.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),n||this.client.core.expirer.del(r),this.client.core.storage.removeItem(Qd).catch(c=>this.client.logger.warn(c)),this.getPendingSessionRequests().forEach(c=>{c.topic===r&&this.deletePendingSessionRequest(c.id,Te("USER_DISCONNECTED"))}),r===((i=this.sessionRequestQueue.queue[0])==null?void 0:i.topic)&&(this.sessionRequestQueue.state=js.idle),o&&this.client.events.emit("session_delete",{id:a,topic:r})}),D(this,"deleteProposal",async(t,i)=>{if(i)try{const r=this.client.proposal.get(t),n=this.client.core.eventClient.getEvent({topic:r.pairingTopic});n==null||n.setError(ji.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(t,Te("USER_DISCONNECTED")),i?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"proposal")}),D(this,"deletePendingSessionRequest",async(t,i,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(t,i),r?Promise.resolve():this.client.core.expirer.del(t)]),this.addToRecentlyDeleted(t,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(n=>n.id!==t),r&&(this.sessionRequestQueue.state=js.idle,this.client.events.emit("session_request_expire",{id:t}))}),D(this,"deletePendingAuthRequest",async(t,i,r=!1)=>{await Promise.all([this.client.auth.requests.delete(t,i),r?Promise.resolve():this.client.core.expirer.del(t)])}),D(this,"setExpiry",async(t,i)=>{this.client.session.keys.includes(t)&&(this.client.core.expirer.set(t,i),await this.client.session.update(t,{expiry:i}))}),D(this,"setProposal",async(t,i)=>{this.client.core.expirer.set(t,at(dt.wc_sessionPropose.req.ttl)),await this.client.proposal.set(t,i)}),D(this,"setAuthRequest",async(t,i)=>{const{request:r,pairingTopic:n,transportType:o=We.relay}=i;this.client.core.expirer.set(t,r.expiryTimestamp),await this.client.auth.requests.set(t,{authPayload:r.authPayload,requester:r.requester,expiryTimestamp:r.expiryTimestamp,id:t,pairingTopic:n,verifyContext:r.verifyContext,transportType:o})}),D(this,"setPendingSessionRequest",async t=>{const{id:i,topic:r,params:n,verifyContext:o}=t,a=n.request.expiryTimestamp||at(dt.wc_sessionRequest.req.ttl);this.client.core.expirer.set(i,a),await this.client.pendingRequest.set(i,{id:i,topic:r,params:n,verifyContext:o})}),D(this,"sendRequest",async t=>{const{topic:i,method:r,params:n,expiry:o,relayRpcId:a,clientRpcId:l,throwOnFailedPublish:c,appLink:h,tvf:u}=t,d=m.formatJsonRpcRequest(r,n,l);let p;const g=!!h;try{const y=g?Un:Ii;p=await this.client.core.crypto.encode(i,d,{encoding:y})}catch(y){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${i} failed`),y}let f;if(M_.includes(r)){const y=ti(JSON.stringify(d)),w=ti(p);f=await this.client.core.verify.register({id:w,decryptedId:y})}const b=dt[r].req;if(b.attestation=f,o&&(b.ttl=o),a&&(b.id=a),this.client.core.history.set(i,d),g){const y=pa(h,i,p);await N.dist.global.Linking.openURL(y,this.client.name)}else{const y=dt[r].req;o&&(y.ttl=o),a&&(y.id=a),y.tvf=Ht(Qe({},u),{correlationId:d.id}),c?(y.internal=Ht(Qe({},y.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(i,p,y)):this.client.core.relayer.publish(i,p,y).catch(w=>this.client.logger.error(w))}return d.id}),D(this,"sendResult",async t=>{const{id:i,topic:r,result:n,throwOnFailedPublish:o,encodeOpts:a,appLink:l}=t,c=m.formatJsonRpcResult(i,n);let h;const u=l&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u";try{const g=u?Un:Ii;h=await this.client.core.crypto.encode(r,c,Ht(Qe({},a||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${r} failed`),g}let d,p;try{d=await this.client.core.history.get(r,i);const g=d.request;try{this.shouldSetTVF(g.method,g.params)&&(p=this.getTVFParams(i,g.params,n))}catch(f){this.client.logger.warn("sendResult() -> getTVFParams() failed",f)}}catch(g){throw this.client.logger.error(`sendResult() -> history.get(${r}, ${i}) failed`),g}if(u){const g=pa(l,r,h);await N.dist.global.Linking.openURL(g,this.client.name)}else{const g=d.request.method,f=dt[g].res;f.tvf=Ht(Qe({},p),{correlationId:i}),o?(f.internal=Ht(Qe({},f.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,h,f)):this.client.core.relayer.publish(r,h,f).catch(b=>this.client.logger.error(b))}await this.client.core.history.resolve(c)}),D(this,"sendError",async t=>{const{id:i,topic:r,error:n,encodeOpts:o,rpcOpts:a,appLink:l}=t,c=m.formatJsonRpcError(i,n);let h;const u=l&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u";try{const p=u?Un:Ii;h=await this.client.core.crypto.encode(r,c,Ht(Qe({},o||{}),{encoding:p}))}catch(p){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${r} failed`),p}let d;try{d=await this.client.core.history.get(r,i)}catch(p){throw this.client.logger.error(`sendError() -> history.get(${r}, ${i}) failed`),p}if(u){const p=pa(l,r,h);await N.dist.global.Linking.openURL(p,this.client.name)}else{const p=d.request.method,g=a||dt[p].res;this.client.core.relayer.publish(r,h,g)}await this.client.core.history.resolve(c)}),D(this,"cleanup",async()=>{const t=[],i=[];this.client.session.getAll().forEach(r=>{let n=!1;gi(r.expiry)&&(n=!0),this.client.core.crypto.keychain.has(r.topic)||(n=!0),n&&t.push(r.topic)}),this.client.proposal.getAll().forEach(r=>{gi(r.expiryTimestamp)&&i.push(r.id)}),await Promise.all([...t.map(r=>this.deleteSession({topic:r})),...i.map(r=>this.deleteProposal(r))])}),D(this,"onRelayEventRequest",async t=>{this.requestQueue.queue.push(t),await this.processRequestsQueue()}),D(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===js.active){this.client.logger.info("Request queue already active, skipping...");return}for(this.client.logger.info(`Request queue starting with ${this.requestQueue.queue.length} requests`);this.requestQueue.queue.length>0;){this.requestQueue.state=js.active;const t=this.requestQueue.queue.shift();if(t)try{await this.processRequest(t)}catch(i){this.client.logger.warn(i)}}this.requestQueue.state=js.idle}),D(this,"processRequest",async t=>{const{topic:i,payload:r,attestation:n,transportType:o,encryptedId:a}=t,l=r.method;if(!this.shouldIgnorePairingRequest({topic:i,requestMethod:l}))switch(l){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:i,payload:r,attestation:n,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(i,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(i,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(i,r);case"wc_sessionPing":return await this.onSessionPingRequest(i,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(i,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:i,payload:r,attestation:n,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(i,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:i,payload:r,attestation:n,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${l}`)}}),D(this,"onRelayEventResponse",async t=>{const{topic:i,payload:r,transportType:n}=t,o=(await this.client.core.history.get(i,r.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(i,r,n);case"wc_sessionSettle":return this.onSessionSettleResponse(i,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(i,r);case"wc_sessionExtend":return this.onSessionExtendResponse(i,r);case"wc_sessionPing":return this.onSessionPingResponse(i,r);case"wc_sessionRequest":return this.onSessionRequestResponse(i,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(i,r);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),D(this,"onRelayEventUnknownPayload",t=>{const{topic:i}=t,{message:r}=j("MISSING_OR_INVALID",`Decoded payload on topic ${i} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)}),D(this,"shouldIgnorePairingRequest",t=>{const{topic:i,requestMethod:r}=t,n=this.expectedPairingMethodMap.get(i);return!n||n.includes(r)?!1:!!(n.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),D(this,"onSessionProposeRequest",async t=>{const{topic:i,payload:r,attestation:n,encryptedId:o}=t,{params:a,id:l}=r;try{const c=this.client.core.eventClient.getEvent({topic:i});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),c==null||c.setError(Xs.proposal_listener_not_found)),this.isValidConnect(Qe({},r.params));const h=a.expiryTimestamp||at(dt.wc_sessionPropose.req.ttl),u=Qe({id:l,pairingTopic:i,expiryTimestamp:h},a);await this.setProposal(l,u);const d=await this.getVerifyContext({attestationId:n,hash:ti(JSON.stringify(r)),encryptedId:o,metadata:u.proposer.metadata});c==null||c.addTrace(Fs.emit_session_proposal),this.client.events.emit("session_proposal",{id:l,params:u,verifyContext:d})}catch(c){await this.sendError({id:l,topic:i,error:c,rpcOpts:dt.wc_sessionPropose.autoReject}),this.client.logger.error(c)}}),D(this,"onSessionProposeResponse",async(t,i,r)=>{const{id:n}=i;if(m.isJsonRpcResult(i)){const{result:o}=i;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(n);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const l=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:l});const c=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:c});const h=await this.client.core.crypto.generateSharedKey(l,c);this.pendingSessions.set(n,{sessionTopic:h,pairingTopic:t,proposalId:n,publicKey:l});const u=await this.client.core.relayer.subscribe(h,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:u}),await this.client.core.pairing.activate({topic:t})}else if(m.isJsonRpcError(i)){await this.client.proposal.delete(n,Te("USER_DISCONNECTED"));const o=Ae("session_connect",n);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:i.error})}}),D(this,"onSessionSettleRequest",async(t,i)=>{const{id:r,params:n}=i;try{this.isValidSessionSettleRequest(n);const{relay:o,controller:a,expiry:l,namespaces:c,sessionProperties:h,sessionConfig:u}=i.params,d=[...this.pendingSessions.values()].find(f=>f.sessionTopic===t);if(!d)return this.client.logger.error(`Pending session not found for topic ${t}`);const p=this.client.proposal.get(d.proposalId),g=Ht(Qe(Qe({topic:t,relay:o,expiry:l,namespaces:c,acknowledged:!0,pairingTopic:d.pairingTopic,requiredNamespaces:p.requiredNamespaces,optionalNamespaces:p.optionalNamespaces,controller:a.publicKey,self:{publicKey:d.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},h&&{sessionProperties:h}),u&&{sessionConfig:u}),{transportType:We.relay});await this.client.session.set(g.topic,g),await this.setExpiry(g.topic,g.expiry),await this.client.core.pairing.updateMetadata({topic:d.pairingTopic,metadata:g.peer.metadata}),this.client.events.emit("session_connect",{session:g}),this.events.emit(Ae("session_connect",d.proposalId),{session:g}),this.pendingSessions.delete(d.proposalId),this.deleteProposal(d.proposalId,!1),this.cleanupDuplicatePairings(g),await this.sendResult({id:i.id,topic:t,result:!0,throwOnFailedPublish:!0})}catch(o){await this.sendError({id:r,topic:t,error:o}),this.client.logger.error(o)}}),D(this,"onSessionSettleResponse",async(t,i)=>{const{id:r}=i;m.isJsonRpcResult(i)?(await this.client.session.update(t,{acknowledged:!0}),this.events.emit(Ae("session_approve",r),{})):m.isJsonRpcError(i)&&(await this.client.session.delete(t,Te("USER_DISCONNECTED")),this.events.emit(Ae("session_approve",r),{error:i.error}))}),D(this,"onSessionUpdateRequest",async(t,i)=>{const{params:r,id:n}=i;try{const o=`${t}_session_update`,a=Ln.get(o);if(a&&this.isRequestOutOfSync(a,n)){this.client.logger.warn(`Discarding out of sync request - ${n}`),this.sendError({id:n,topic:t,error:Te("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Qe({topic:t},r));try{Ln.set(o,n),await this.client.session.update(t,{namespaces:r.namespaces}),await this.sendResult({id:n,topic:t,result:!0,throwOnFailedPublish:!0})}catch(l){throw Ln.delete(o),l}this.client.events.emit("session_update",{id:n,topic:t,params:r})}catch(o){await this.sendError({id:n,topic:t,error:o}),this.client.logger.error(o)}}),D(this,"isRequestOutOfSync",(t,i)=>i.toString().slice(0,-3)<t.toString().slice(0,-3)),D(this,"onSessionUpdateResponse",(t,i)=>{const{id:r}=i,n=Ae("session_update",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);m.isJsonRpcResult(i)?this.events.emit(Ae("session_update",r),{}):m.isJsonRpcError(i)&&this.events.emit(Ae("session_update",r),{error:i.error})}),D(this,"onSessionExtendRequest",async(t,i)=>{const{id:r}=i;try{this.isValidExtend({topic:t}),await this.setExpiry(t,at(_r)),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_extend",{id:r,topic:t})}catch(n){await this.sendError({id:r,topic:t,error:n}),this.client.logger.error(n)}}),D(this,"onSessionExtendResponse",(t,i)=>{const{id:r}=i,n=Ae("session_extend",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);m.isJsonRpcResult(i)?this.events.emit(Ae("session_extend",r),{}):m.isJsonRpcError(i)&&this.events.emit(Ae("session_extend",r),{error:i.error})}),D(this,"onSessionPingRequest",async(t,i)=>{const{id:r}=i;try{this.isValidPing({topic:t}),await this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:t})}catch(n){await this.sendError({id:r,topic:t,error:n}),this.client.logger.error(n)}}),D(this,"onSessionPingResponse",(t,i)=>{const{id:r}=i,n=Ae("session_ping",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);setTimeout(()=>{m.isJsonRpcResult(i)?this.events.emit(Ae("session_ping",r),{}):m.isJsonRpcError(i)&&this.events.emit(Ae("session_ping",r),{error:i.error})},500)}),D(this,"onSessionDeleteRequest",async(t,i)=>{const{id:r}=i;try{this.isValidDisconnect({topic:t,reason:i.params}),Promise.all([new Promise(n=>{this.client.core.relayer.once(yt.publish,async()=>{n(await this.deleteSession({topic:t,id:r}))})}),this.sendResult({id:r,topic:t,result:!0,throwOnFailedPublish:!0}),this.cleanupPendingSentRequestsForTopic({topic:t,error:Te("USER_DISCONNECTED")})]).catch(n=>this.client.logger.error(n))}catch(n){this.client.logger.error(n)}}),D(this,"onSessionRequest",async t=>{var i,r,n;const{topic:o,payload:a,attestation:l,encryptedId:c,transportType:h}=t,{id:u,params:d}=a;try{await this.isValidRequest(Qe({topic:o},d));const p=this.client.session.get(o),g=await this.getVerifyContext({attestationId:l,hash:ti(JSON.stringify(m.formatJsonRpcRequest("wc_sessionRequest",d,u))),encryptedId:c,metadata:p.peer.metadata,transportType:h}),f={id:u,topic:o,params:d,verifyContext:g};await this.setPendingSessionRequest(f),h===We.link_mode&&(i=p.peer.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp((r=p.peer.metadata.redirect)==null?void 0:r.universal),(n=this.client.signConfig)!=null&&n.disableRequestQueue?this.emitSessionRequest(f):(this.addSessionRequestToSessionRequestQueue(f),this.processSessionRequestQueue())}catch(p){await this.sendError({id:u,topic:o,error:p}),this.client.logger.error(p)}}),D(this,"onSessionRequestResponse",(t,i)=>{const{id:r}=i,n=Ae("session_request",r);if(this.events.listenerCount(n)===0)throw new Error(`emitting ${n} without any listeners`);m.isJsonRpcResult(i)?this.events.emit(Ae("session_request",r),{result:i.result}):m.isJsonRpcError(i)&&this.events.emit(Ae("session_request",r),{error:i.error})}),D(this,"onSessionEventRequest",async(t,i)=>{const{id:r,params:n}=i;try{const o=`${t}_session_event_${n.event.name}`,a=Ln.get(o);if(a&&this.isRequestOutOfSync(a,r)){this.client.logger.info(`Discarding out of sync request - ${r}`);return}this.isValidEmit(Qe({topic:t},n)),this.client.events.emit("session_event",{id:r,topic:t,params:n}),Ln.set(o,r)}catch(o){await this.sendError({id:r,topic:t,error:o}),this.client.logger.error(o)}}),D(this,"onSessionAuthenticateResponse",(t,i)=>{const{id:r}=i;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:t,payload:i}),m.isJsonRpcResult(i)?this.events.emit(Ae("session_request",r),{result:i.result}):m.isJsonRpcError(i)&&this.events.emit(Ae("session_request",r),{error:i.error})}),D(this,"onSessionAuthenticateRequest",async t=>{var i;const{topic:r,payload:n,attestation:o,encryptedId:a,transportType:l}=t;try{const{requester:c,authPayload:h,expiryTimestamp:u}=n.params,d=await this.getVerifyContext({attestationId:o,hash:ti(JSON.stringify(n)),encryptedId:a,metadata:c.metadata,transportType:l}),p={requester:c,pairingTopic:r,id:n.id,authPayload:h,verifyContext:d,expiryTimestamp:u};await this.setAuthRequest(n.id,{request:p,pairingTopic:r,transportType:l}),l===We.link_mode&&(i=c.metadata.redirect)!=null&&i.universal&&this.client.core.addLinkModeSupportedApp(c.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:r,params:n.params,id:n.id,verifyContext:d})}catch(c){this.client.logger.error(c);const h=n.params.requester.publicKey,u=await this.client.core.crypto.generateKeyPair(),d=this.getAppLinkIfEnabled(n.params.requester.metadata,l),p={type:ii,receiverPublicKey:h,senderPublicKey:u};await this.sendError({id:n.id,topic:r,error:c,encodeOpts:p,rpcOpts:dt.wc_sessionAuthenticate.autoReject,appLink:d})}}),D(this,"addSessionRequestToSessionRequestQueue",t=>{this.sessionRequestQueue.queue.push(t)}),D(this,"cleanupAfterResponse",t=>{this.deletePendingSessionRequest(t.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=js.idle,this.processSessionRequestQueue()},E.cjs.toMiliseconds(this.requestQueueDelay))}),D(this,"cleanupPendingSentRequestsForTopic",({topic:t,error:i})=>{const r=this.client.core.history.pending;r.length>0&&r.filter(n=>n.topic===t&&n.request.method==="wc_sessionRequest").forEach(n=>{const o=n.request.id,a=Ae("session_request",o);if(this.events.listenerCount(a)===0)throw new Error(`emitting ${a} without any listeners`);this.events.emit(Ae("session_request",n.request.id),{error:i})})}),D(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===js.active){this.client.logger.info("session request queue is already active.");return}const t=this.sessionRequestQueue.queue[0];if(!t){this.client.logger.info("session request queue is empty.");return}try{this.sessionRequestQueue.state=js.active,this.emitSessionRequest(t)}catch(i){this.client.logger.error(i)}}),D(this,"emitSessionRequest",t=>{this.client.events.emit("session_request",t)}),D(this,"onPairingCreated",t=>{if(t.methods&&this.expectedPairingMethodMap.set(t.topic,t.methods),t.active)return;const i=this.client.proposal.getAll().find(r=>r.pairingTopic===t.topic);i&&this.onSessionProposeRequest({topic:t.topic,payload:m.formatJsonRpcRequest("wc_sessionPropose",{requiredNamespaces:i.requiredNamespaces,optionalNamespaces:i.optionalNamespaces,relays:i.relays,proposer:i.proposer,sessionProperties:i.sessionProperties},i.id)})}),D(this,"isValidConnect",async t=>{if(!Qt(t)){const{message:l}=j("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(t)}`);throw new Error(l)}const{pairingTopic:i,requiredNamespaces:r,optionalNamespaces:n,sessionProperties:o,relays:a}=t;if(Ft(i)||await this.isValidPairingTopic(i),!X1(a)){const{message:l}=j("MISSING_OR_INVALID",`connect() relays: ${a}`);throw new Error(l)}!Ft(r)&&To(r)!==0&&this.validateNamespaces(r,"requiredNamespaces"),!Ft(n)&&To(n)!==0&&this.validateNamespaces(n,"optionalNamespaces"),Ft(o)||this.validateSessionProps(o,"sessionProperties")}),D(this,"validateNamespaces",(t,i)=>{const r=J1(t,"connect()",i);if(r)throw new Error(r.message)}),D(this,"isValidApprove",async t=>{if(!Qt(t))throw new Error(j("MISSING_OR_INVALID",`approve() params: ${t}`).message);const{id:i,namespaces:r,relayProtocol:n,sessionProperties:o}=t;this.checkRecentlyDeleted(i),await this.isValidProposalId(i);const a=this.client.proposal.get(i),l=Vc(r,"approve()");if(l)throw new Error(l.message);const c=_d(a.requiredNamespaces,r,"approve()");if(c)throw new Error(c.message);if(!Xe(n,!0)){const{message:h}=j("MISSING_OR_INVALID",`approve() relayProtocol: ${n}`);throw new Error(h)}Ft(o)||this.validateSessionProps(o,"sessionProperties")}),D(this,"isValidReject",async t=>{if(!Qt(t)){const{message:n}=j("MISSING_OR_INVALID",`reject() params: ${t}`);throw new Error(n)}const{id:i,reason:r}=t;if(this.checkRecentlyDeleted(i),await this.isValidProposalId(i),!tE(r)){const{message:n}=j("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(n)}}),D(this,"isValidSessionSettleRequest",t=>{if(!Qt(t)){const{message:c}=j("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${t}`);throw new Error(c)}const{relay:i,controller:r,namespaces:n,expiry:o}=t;if(!Um(i)){const{message:c}=j("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(c)}const a=V1(r,"onSessionSettleRequest()");if(a)throw new Error(a.message);const l=Vc(n,"onSessionSettleRequest()");if(l)throw new Error(l.message);if(gi(o)){const{message:c}=j("EXPIRED","onSessionSettleRequest()");throw new Error(c)}}),D(this,"isValidUpdate",async t=>{if(!Qt(t)){const{message:l}=j("MISSING_OR_INVALID",`update() params: ${t}`);throw new Error(l)}const{topic:i,namespaces:r}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const n=this.client.session.get(i),o=Vc(r,"update()");if(o)throw new Error(o.message);const a=_d(n.requiredNamespaces,r,"update()");if(a)throw new Error(a.message)}),D(this,"isValidExtend",async t=>{if(!Qt(t)){const{message:r}=j("MISSING_OR_INVALID",`extend() params: ${t}`);throw new Error(r)}const{topic:i}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i)}),D(this,"isValidRequest",async t=>{if(!Qt(t)){const{message:l}=j("MISSING_OR_INVALID",`request() params: ${t}`);throw new Error(l)}const{topic:i,request:r,chainId:n,expiry:o}=t;this.checkRecentlyDeleted(i),await this.isValidSessionTopic(i);const{namespaces:a}=this.client.session.get(i);if(!Nd(a,n)){const{message:l}=j("MISSING_OR_INVALID",`request() chainId: ${n}`);throw new Error(l)}if(!sE(r)){const{message:l}=j("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(l)}if(!nE(a,n,r.method)){const{message:l}=j("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(l)}if(o&&!lE(o,Jc)){const{message:l}=j("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Jc.min} and ${Jc.max}`);throw new Error(l)}}),D(this,"isValidRespond",async t=>{var i;if(!Qt(t)){const{message:o}=j("MISSING_OR_INVALID",`respond() params: ${t}`);throw new Error(o)}const{topic:r,response:n}=t;try{await this.isValidSessionTopic(r)}catch(o){throw(i=t==null?void 0:t.response)!=null&&i.id&&this.cleanupAfterResponse(t),o}if(!iE(n)){const{message:o}=j("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(n)}`);throw new Error(o)}}),D(this,"isValidPing",async t=>{if(!Qt(t)){const{message:r}=j("MISSING_OR_INVALID",`ping() params: ${t}`);throw new Error(r)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)}),D(this,"isValidEmit",async t=>{if(!Qt(t)){const{message:a}=j("MISSING_OR_INVALID",`emit() params: ${t}`);throw new Error(a)}const{topic:i,event:r,chainId:n}=t;await this.isValidSessionTopic(i);const{namespaces:o}=this.client.session.get(i);if(!Nd(o,n)){const{message:a}=j("MISSING_OR_INVALID",`emit() chainId: ${n}`);throw new Error(a)}if(!rE(r)){const{message:a}=j("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(a)}if(!oE(o,n,r.name)){const{message:a}=j("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(a)}}),D(this,"isValidDisconnect",async t=>{if(!Qt(t)){const{message:r}=j("MISSING_OR_INVALID",`disconnect() params: ${t}`);throw new Error(r)}const{topic:i}=t;await this.isValidSessionOrPairingTopic(i)}),D(this,"isValidAuthenticate",t=>{const{chains:i,uri:r,domain:n,nonce:o}=t;if(!Array.isArray(i)||i.length===0)throw new Error("chains is required and must be a non-empty array");if(!Xe(r,!1))throw new Error("uri is required parameter");if(!Xe(n,!1))throw new Error("domain is required parameter");if(!Xe(o,!1))throw new Error("nonce is required parameter");if([...new Set(i.map(l=>gn(l).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=gn(i[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),D(this,"getVerifyContext",async t=>{const{attestationId:i,hash:r,encryptedId:n,metadata:o,transportType:a}=t,l={verified:{verifyUrl:o.verifyUrl||go,validation:"UNKNOWN",origin:o.url||""}};try{if(a===We.link_mode){const h=this.getAppLinkIfEnabled(o,a);return l.verified.validation=h&&new URL(h).origin===new URL(o.url).origin?"VALID":"INVALID",l}const c=await this.client.core.verify.resolve({attestationId:i,hash:r,encryptedId:n,verifyUrl:o.verifyUrl});c&&(l.verified.origin=c.origin,l.verified.isScam=c.isScam,l.verified.validation=c.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(c){this.client.logger.warn(c)}return this.client.logger.debug(`Verify context: ${JSON.stringify(l)}`),l}),D(this,"validateSessionProps",(t,i)=>{Object.values(t).forEach(r=>{if(!Xe(r,!1)){const{message:n}=j("MISSING_OR_INVALID",`${i} must be in Record<string, string> format. Received: ${JSON.stringify(r)}`);throw new Error(n)}})}),D(this,"getPendingAuthRequest",t=>{const i=this.client.auth.requests.get(t);return typeof i=="object"?i:void 0}),D(this,"addToRecentlyDeleted",(t,i)=>{if(this.recentlyDeletedMap.set(t,i),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let r=0;const n=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(r++>=n)break;this.recentlyDeletedMap.delete(o)}}}),D(this,"checkRecentlyDeleted",t=>{const i=this.recentlyDeletedMap.get(t);if(i){const{message:r}=j("MISSING_OR_INVALID",`Record was recently deleted - ${i}: ${t}`);throw new Error(r)}}),D(this,"isLinkModeEnabled",(t,i)=>{var r,n,o,a,l,c,h,u,d;return!t||i!==We.link_mode?!1:((n=(r=this.client.metadata)==null?void 0:r.redirect)==null?void 0:n.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((c=(l=this.client.metadata)==null?void 0:l.redirect)==null?void 0:c.universal)!==""&&((h=t==null?void 0:t.redirect)==null?void 0:h.universal)!==void 0&&((u=t==null?void 0:t.redirect)==null?void 0:u.universal)!==""&&((d=t==null?void 0:t.redirect)==null?void 0:d.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(t.redirect.universal)&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u"}),D(this,"getAppLinkIfEnabled",(t,i)=>{var r;return this.isLinkModeEnabled(t,i)?(r=t==null?void 0:t.redirect)==null?void 0:r.universal:void 0}),D(this,"handleLinkModeMessage",({url:t})=>{if(!t||!t.includes("wc_ev")||!t.includes("topic"))return;const i=Vu(t,"topic")||"",r=decodeURIComponent(Vu(t,"wc_ev")||""),n=this.client.session.keys.includes(i);n&&this.client.session.update(i,{transportType:We.link_mode}),this.client.core.dispatchEnvelope({topic:i,message:r,sessionExists:n})}),D(this,"registerLinkModeListeners",async()=>{var t;if(Kh()||Mi()&&(t=this.client.metadata.redirect)!=null&&t.linkMode){const i=N.dist.global==null?void 0:N.dist.global.Linking;if(typeof i<"u"){i.addEventListener("url",this.handleLinkModeMessage,this.client.name);const r=await i.getInitialURL();r&&setTimeout(()=>{this.handleLinkModeMessage({url:r})},50)}}}),D(this,"shouldSetTVF",(t,i)=>{if(!i||t!=="wc_sessionRequest")return!1;const{request:r}=i;return Object.keys(Jd).includes(r.method)}),D(this,"getTVFParams",(t,i,r)=>{var n,o;try{const a=i.request.method,l=this.extractTxHashesFromResult(a,r);return Ht(Qe({correlationId:t,rpcMethods:[a],chainId:i.chainId},this.isValidContractData(i.request.params)&&{contractAddresses:[(o=(n=i.request.params)==null?void 0:n[0])==null?void 0:o.to]}),{txHashes:l})}catch(a){this.client.logger.warn("Error getting TVF params",a)}return{}}),D(this,"isValidContractData",t=>{var i;if(!t)return!1;try{const r=(t==null?void 0:t.data)||((i=t==null?void 0:t[0])==null?void 0:i.data);if(!r.startsWith("0x"))return!1;const n=r.slice(2);return/^[0-9a-fA-F]*$/.test(n)?n.length%2===0:!1}catch{}return!1}),D(this,"extractTxHashesFromResult",(t,i)=>{try{const r=Jd[t];if(typeof i=="string")return[i];const n=i[r.key];if(rr(n))return n;if(typeof n=="string")return[n]}catch(r){this.client.logger.warn("Error extracting tx hashes from result",r)}return[]})}isInitialized(){if(!this.initialized){const{message:e}=j("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(yt.message,e=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(e):this.onRelayMessage(e)})}async onRelayMessage(e){const{topic:t,message:i,attestation:r,transportType:n}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Ua)?this.client.auth.authKeys.get(Ua):{publicKey:void 0},a=await this.client.core.crypto.decode(t,i,{receiverPublicKey:o,encoding:n===We.link_mode?Un:Ii});try{m.isJsonRpcRequest(a)?(this.client.core.history.set(t,a),this.onRelayEventRequest({topic:t,payload:a,attestation:r,transportType:n,encryptedId:ti(i)})):m.isJsonRpcResponse(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:t,payload:a,transportType:n}),this.client.core.history.delete(t,a.id)):this.onRelayEventUnknownPayload({topic:t,payload:a,transportType:n})}catch(l){this.client.logger.error(l)}}registerExpirerEvents(){this.client.core.expirer.on(ms.expired,async e=>{const{topic:t,id:i}=dm(e.target);if(i&&this.client.pendingRequest.keys.includes(i))return await this.deletePendingSessionRequest(i,j("EXPIRED"),!0);if(i&&this.client.auth.requests.keys.includes(i))return await this.deletePendingAuthRequest(i,j("EXPIRED"),!0);t?this.client.session.keys.includes(t)&&(await this.deleteSession({topic:t,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:t})):i&&(await this.deleteProposal(i,!0),this.client.events.emit("proposal_expire",{id:i}))})}registerPairingEvents(){this.client.core.pairing.events.on(Wi.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(Wi.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Xe(e,!1)){const{message:t}=j("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(t)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:t}=j("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.core.pairing.pairings.get(e).expiry)){const{message:t}=j("EXPIRED",`pairing topic: ${e}`);throw new Error(t)}}async isValidSessionTopic(e){if(!Xe(e,!1)){const{message:t}=j("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(t)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:t}=j("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:t}=j("EXPIRED",`session topic: ${e}`);throw new Error(t)}if(!this.client.core.crypto.keychain.has(e)){const{message:t}=j("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(t)}}async isValidSessionOrPairingTopic(e){if(this.checkRecentlyDeleted(e),this.client.session.keys.includes(e))await this.isValidSessionTopic(e);else if(this.client.core.pairing.pairings.keys.includes(e))this.isValidPairingTopic(e);else if(Xe(e,!1)){const{message:t}=j("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(t)}else{const{message:t}=j("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(t)}}async isValidProposalId(e){if(!eE(e)){const{message:t}=j("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(t)}if(!this.client.proposal.keys.includes(e)){const{message:t}=j("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(t)}if(gi(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:t}=j("EXPIRED",`proposal id: ${e}`);throw new Error(t)}}},B_=class extends pr{constructor(e,t){super(e,t,S_,su),this.core=e,this.logger=t}},H_=class extends pr{constructor(e,t){super(e,t,$_,su),this.core=e,this.logger=t}},W_=class extends pr{constructor(e,t){super(e,t,T_,su,i=>i.id),this.core=e,this.logger=t}},V_=class extends pr{constructor(e,t){super(e,t,D_,vc,()=>Ua),this.core=e,this.logger=t}},K_=class extends pr{constructor(e,t){super(e,t,k_,vc),this.core=e,this.logger=t}},G_=class extends pr{constructor(e,t){super(e,t,j_,vc,i=>i.id),this.core=e,this.logger=t}};var Y_=Object.defineProperty,Q_=(s,e,t)=>e in s?Y_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Xc=(s,e,t)=>Q_(s,typeof e!="symbol"?e+"":e,t);let Z_=class{constructor(e,t){this.core=e,this.logger=t,Xc(this,"authKeys"),Xc(this,"pairingTopics"),Xc(this,"requests"),this.authKeys=new V_(this.core,this.logger),this.pairingTopics=new K_(this.core,this.logger),this.requests=new G_(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}};var J_=Object.defineProperty,X_=(s,e,t)=>e in s?J_(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,he=(s,e,t)=>X_(s,typeof e!="symbol"?e+"":e,t);let eC=class nw extends __{constructor(e){super(e),he(this,"protocol",sw),he(this,"version",iw),he(this,"name",Zc.name),he(this,"metadata"),he(this,"core"),he(this,"logger"),he(this,"events",new te.eventsExports.EventEmitter),he(this,"engine"),he(this,"session"),he(this,"proposal"),he(this,"pendingRequest"),he(this,"auth"),he(this,"signConfig"),he(this,"on",(i,r)=>this.events.on(i,r)),he(this,"once",(i,r)=>this.events.once(i,r)),he(this,"off",(i,r)=>this.events.off(i,r)),he(this,"removeListener",(i,r)=>this.events.removeListener(i,r)),he(this,"removeAllListeners",i=>this.events.removeAllListeners(i)),he(this,"connect",async i=>{try{return await this.engine.connect(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"pair",async i=>{try{return await this.engine.pair(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"approve",async i=>{try{return await this.engine.approve(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"reject",async i=>{try{return await this.engine.reject(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"update",async i=>{try{return await this.engine.update(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"extend",async i=>{try{return await this.engine.extend(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"request",async i=>{try{return await this.engine.request(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"respond",async i=>{try{return await this.engine.respond(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"ping",async i=>{try{return await this.engine.ping(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"emit",async i=>{try{return await this.engine.emit(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"disconnect",async i=>{try{return await this.engine.disconnect(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"find",i=>{try{return this.engine.find(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(i){throw this.logger.error(i.message),i}}),he(this,"authenticate",async(i,r)=>{try{return await this.engine.authenticate(i,r)}catch(n){throw this.logger.error(n.message),n}}),he(this,"formatAuthMessage",i=>{try{return this.engine.formatAuthMessage(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"approveSessionAuthenticate",async i=>{try{return await this.engine.approveSessionAuthenticate(i)}catch(r){throw this.logger.error(r.message),r}}),he(this,"rejectSessionAuthenticate",async i=>{try{return await this.engine.rejectSessionAuthenticate(i)}catch(r){throw this.logger.error(r.message),r}}),this.name=(e==null?void 0:e.name)||Zc.name,this.metadata=(e==null?void 0:e.metadata)||am(),this.signConfig=e==null?void 0:e.signConfig;const t=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:m.Dg(m.k({level:(e==null?void 0:e.logger)||Zc.logger}));this.core=(e==null?void 0:e.core)||new E_(e),this.logger=m.E(t,this.name),this.session=new H_(this.core,this.logger),this.proposal=new B_(this.core,this.logger),this.pendingRequest=new W_(this.core,this.logger),this.engine=new q_(this),this.auth=new Z_(this.core,this.logger)}static async init(e){const t=new nw(e);return await t.initialize(),t}get context(){return m.y(this.logger)}get pairing(){return this.core.pairing.pairings}async initialize(){this.logger.trace("Initialized");try{await this.core.start(),await this.session.init(),await this.proposal.init(),await this.pendingRequest.init(),await this.auth.init(),await this.engine.init(),this.logger.info("SignClient Initialization Success"),setTimeout(()=>{this.engine.processRelayMessageCache()},E.cjs.toMiliseconds(E.cjs.ONE_SECOND))}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const ep="error",tC="wss://relay.walletconnect.org",sC="wc",iC="universal_provider",tp=`${sC}@2:${iC}:`,ow="https://rpc.walletconnect.org/v1/",en="generic",rC=`${ow}bundler`,Is={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};var fa=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof N.dist.global<"u"?N.dist.global:typeof self<"u"?self:{};function nC(){this.__data__=[],this.size=0}var oC=nC;function aC(s,e){return s===e||s!==s&&e!==e}var Ic=aC,cC=Ic;function lC(s,e){for(var t=s.length;t--;)if(cC(s[t][0],e))return t;return-1}var Ec=lC,hC=Ec,uC=Array.prototype,dC=uC.splice;function pC(s){var e=this.__data__,t=hC(e,s);if(t<0)return!1;var i=e.length-1;return t==i?e.pop():dC.call(e,t,1),--this.size,!0}var gC=pC,fC=Ec;function mC(s){var e=this.__data__,t=fC(e,s);return t<0?void 0:e[t][1]}var wC=mC,yC=Ec;function bC(s){return yC(this.__data__,s)>-1}var vC=bC,IC=Ec;function EC(s,e){var t=this.__data__,i=IC(t,s);return i<0?(++this.size,t.push([s,e])):t[i][1]=e,this}var AC=EC,NC=oC,_C=gC,CC=wC,SC=vC,$C=AC;function tn(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var i=s[e];this.set(i[0],i[1])}}tn.prototype.clear=NC,tn.prototype.delete=_C,tn.prototype.get=CC,tn.prototype.has=SC,tn.prototype.set=$C;var Ac=tn,PC=Ac;function TC(){this.__data__=new PC,this.size=0}var MC=TC;function xC(s){var e=this.__data__,t=e.delete(s);return this.size=e.size,t}var OC=xC;function DC(s){return this.__data__.get(s)}var kC=DC;function jC(s){return this.__data__.has(s)}var RC=jC,UC=typeof fa=="object"&&fa&&fa.Object===Object&&fa,aw=UC,LC=aw,zC=typeof self=="object"&&self&&self.Object===Object&&self,FC=LC||zC||Function("return this")(),$n=FC,qC=$n,BC=qC.Symbol,cw=BC,sp=cw,lw=Object.prototype,HC=lw.hasOwnProperty,WC=lw.toString,Hn=sp?sp.toStringTag:void 0;function VC(s){var e=HC.call(s,Hn),t=s[Hn];try{s[Hn]=void 0;var i=!0}catch{}var r=WC.call(s);return i&&(e?s[Hn]=t:delete s[Hn]),r}var KC=VC,GC=Object.prototype,YC=GC.toString;function QC(s){return YC.call(s)}var ZC=QC,ip=cw,JC=KC,XC=ZC,eS="[object Null]",tS="[object Undefined]",rp=ip?ip.toStringTag:void 0;function sS(s){return s==null?s===void 0?tS:eS:rp&&rp in Object(s)?JC(s):XC(s)}var Nc=sS;function iS(s){var e=typeof s;return s!=null&&(e=="object"||e=="function")}var gr=iS,rS=Nc,nS=gr,oS="[object AsyncFunction]",aS="[object Function]",cS="[object GeneratorFunction]",lS="[object Proxy]";function hS(s){if(!nS(s))return!1;var e=rS(s);return e==aS||e==cS||e==oS||e==lS}var iu=hS,uS=$n,dS=uS["__core-js_shared__"],pS=dS,el=pS,np=function(){var s=/[^.]+$/.exec(el&&el.keys&&el.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""}();function gS(s){return!!np&&np in s}var fS=gS,mS=Function.prototype,wS=mS.toString;function yS(s){if(s!=null){try{return wS.call(s)}catch{}try{return s+""}catch{}}return""}var bS=yS,vS=iu,IS=fS,ES=gr,AS=bS,NS=/[\\^$.*+?()[\]{}|]/g,_S=/^\[object .+?Constructor\]$/,CS=Function.prototype,SS=Object.prototype,$S=CS.toString,PS=SS.hasOwnProperty,TS=RegExp("^"+$S.call(PS).replace(NS,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function MS(s){if(!ES(s)||IS(s))return!1;var e=vS(s)?TS:_S;return e.test(AS(s))}var xS=MS;function OS(s,e){return s==null?void 0:s[e]}var DS=OS,kS=xS,jS=DS;function RS(s,e){var t=jS(s,e);return kS(t)?t:void 0}var ru=RS,US=ru,LS=$n,zS=US(LS,"Map"),hw=zS,FS=ru,qS=FS(Object,"create"),_c=qS,op=_c;function BS(){this.__data__=op?op(null):{},this.size=0}var HS=BS;function WS(s){var e=this.has(s)&&delete this.__data__[s];return this.size-=e?1:0,e}var VS=WS,KS=_c,GS="__lodash_hash_undefined__",YS=Object.prototype,QS=YS.hasOwnProperty;function ZS(s){var e=this.__data__;if(KS){var t=e[s];return t===GS?void 0:t}return QS.call(e,s)?e[s]:void 0}var JS=ZS,XS=_c,e$=Object.prototype,t$=e$.hasOwnProperty;function s$(s){var e=this.__data__;return XS?e[s]!==void 0:t$.call(e,s)}var i$=s$,r$=_c,n$="__lodash_hash_undefined__";function o$(s,e){var t=this.__data__;return this.size+=this.has(s)?0:1,t[s]=r$&&e===void 0?n$:e,this}var a$=o$,c$=HS,l$=VS,h$=JS,u$=i$,d$=a$;function sn(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var i=s[e];this.set(i[0],i[1])}}sn.prototype.clear=c$,sn.prototype.delete=l$,sn.prototype.get=h$,sn.prototype.has=u$,sn.prototype.set=d$;var p$=sn,ap=p$,g$=Ac,f$=hw;function m$(){this.size=0,this.__data__={hash:new ap,map:new(f$||g$),string:new ap}}var w$=m$;function y$(s){var e=typeof s;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?s!=="__proto__":s===null}var b$=y$,v$=b$;function I$(s,e){var t=s.__data__;return v$(e)?t[typeof e=="string"?"string":"hash"]:t.map}var Cc=I$,E$=Cc;function A$(s){var e=E$(this,s).delete(s);return this.size-=e?1:0,e}var N$=A$,_$=Cc;function C$(s){return _$(this,s).get(s)}var S$=C$,$$=Cc;function P$(s){return $$(this,s).has(s)}var T$=P$,M$=Cc;function x$(s,e){var t=M$(this,s),i=t.size;return t.set(s,e),this.size+=t.size==i?0:1,this}var O$=x$,D$=w$,k$=N$,j$=S$,R$=T$,U$=O$;function rn(s){var e=-1,t=s==null?0:s.length;for(this.clear();++e<t;){var i=s[e];this.set(i[0],i[1])}}rn.prototype.clear=D$,rn.prototype.delete=k$,rn.prototype.get=j$,rn.prototype.has=R$,rn.prototype.set=U$;var L$=rn,z$=Ac,F$=hw,q$=L$,B$=200;function H$(s,e){var t=this.__data__;if(t instanceof z$){var i=t.__data__;if(!F$||i.length<B$-1)return i.push([s,e]),this.size=++t.size,this;t=this.__data__=new q$(i)}return t.set(s,e),this.size=t.size,this}var W$=H$,V$=Ac,K$=MC,G$=OC,Y$=kC,Q$=RC,Z$=W$;function nn(s){var e=this.__data__=new V$(s);this.size=e.size}nn.prototype.clear=K$,nn.prototype.delete=G$,nn.prototype.get=Y$,nn.prototype.has=Q$,nn.prototype.set=Z$;var J$=nn,X$=ru,eP=function(){try{var s=X$(Object,"defineProperty");return s({},"",{}),s}catch{}}(),uw=eP,cp=uw;function tP(s,e,t){e=="__proto__"&&cp?cp(s,e,{configurable:!0,enumerable:!0,value:t,writable:!0}):s[e]=t}var nu=tP,sP=nu,iP=Ic;function rP(s,e,t){(t!==void 0&&!iP(s[e],t)||t===void 0&&!(e in s))&&sP(s,e,t)}var dw=rP;function nP(s){return function(e,t,i){for(var r=-1,n=Object(e),o=i(e),a=o.length;a--;){var l=o[s?a:++r];if(t(n[l],l,n)===!1)break}return e}}var oP=nP,aP=oP,cP=aP(),lP=cP,ah={exports:{}};(function(s,e){var t=$n,i=e&&!e.nodeType&&e,r=i&&!0&&s&&!s.nodeType&&s,n=r&&r.exports===i,o=n?t.Buffer:void 0,a=o?o.allocUnsafe:void 0;function l(c,h){if(h)return c.slice();var u=c.length,d=a?a(u):new c.constructor(u);return c.copy(d),d}s.exports=l})(ah,ah.exports);var hP=$n,uP=hP.Uint8Array,dP=uP,lp=dP;function pP(s){var e=new s.constructor(s.byteLength);return new lp(e).set(new lp(s)),e}var gP=pP,fP=gP;function mP(s,e){var t=e?fP(s.buffer):s.buffer;return new s.constructor(t,s.byteOffset,s.length)}var wP=mP;function yP(s,e){var t=-1,i=s.length;for(e||(e=Array(i));++t<i;)e[t]=s[t];return e}var bP=yP,vP=gr,hp=Object.create,IP=function(){function s(){}return function(e){if(!vP(e))return{};if(hp)return hp(e);s.prototype=e;var t=new s;return s.prototype=void 0,t}}(),EP=IP;function AP(s,e){return function(t){return s(e(t))}}var NP=AP,_P=NP,CP=_P(Object.getPrototypeOf,Object),pw=CP,SP=Object.prototype;function $P(s){var e=s&&s.constructor,t=typeof e=="function"&&e.prototype||SP;return s===t}var gw=$P,PP=EP,TP=pw,MP=gw;function xP(s){return typeof s.constructor=="function"&&!MP(s)?PP(TP(s)):{}}var OP=xP;function DP(s){return s!=null&&typeof s=="object"}var Zo=DP,kP=Nc,jP=Zo,RP="[object Arguments]";function UP(s){return jP(s)&&kP(s)==RP}var LP=UP,up=LP,zP=Zo,fw=Object.prototype,FP=fw.hasOwnProperty,qP=fw.propertyIsEnumerable,BP=up(function(){return arguments}())?up:function(s){return zP(s)&&FP.call(s,"callee")&&!qP.call(s,"callee")},mw=BP,HP=Array.isArray,ww=HP,WP=9007199254740991;function VP(s){return typeof s=="number"&&s>-1&&s%1==0&&s<=WP}var yw=VP,KP=iu,GP=yw;function YP(s){return s!=null&&GP(s.length)&&!KP(s)}var ou=YP,QP=ou,ZP=Zo;function JP(s){return ZP(s)&&QP(s)}var XP=JP,ec={exports:{}};function eT(){return!1}var tT=eT;(function(s,e){var t=$n,i=tT,r=e&&!e.nodeType&&e,n=r&&!0&&s&&!s.nodeType&&s,o=n&&n.exports===r,a=o?t.Buffer:void 0,l=a?a.isBuffer:void 0,c=l||i;s.exports=c})(ec,ec.exports);var sT=Nc,iT=pw,rT=Zo,nT="[object Object]",oT=Function.prototype,aT=Object.prototype,bw=oT.toString,cT=aT.hasOwnProperty,lT=bw.call(Object);function hT(s){if(!rT(s)||sT(s)!=nT)return!1;var e=iT(s);if(e===null)return!0;var t=cT.call(e,"constructor")&&e.constructor;return typeof t=="function"&&t instanceof t&&bw.call(t)==lT}var uT=hT,dT=Nc,pT=yw,gT=Zo,fT="[object Arguments]",mT="[object Array]",wT="[object Boolean]",yT="[object Date]",bT="[object Error]",vT="[object Function]",IT="[object Map]",ET="[object Number]",AT="[object Object]",NT="[object RegExp]",_T="[object Set]",CT="[object String]",ST="[object WeakMap]",$T="[object ArrayBuffer]",PT="[object DataView]",TT="[object Float32Array]",MT="[object Float64Array]",xT="[object Int8Array]",OT="[object Int16Array]",DT="[object Int32Array]",kT="[object Uint8Array]",jT="[object Uint8ClampedArray]",RT="[object Uint16Array]",UT="[object Uint32Array]",He={};He[TT]=He[MT]=He[xT]=He[OT]=He[DT]=He[kT]=He[jT]=He[RT]=He[UT]=!0,He[fT]=He[mT]=He[$T]=He[wT]=He[PT]=He[yT]=He[bT]=He[vT]=He[IT]=He[ET]=He[AT]=He[NT]=He[_T]=He[CT]=He[ST]=!1;function LT(s){return gT(s)&&pT(s.length)&&!!He[dT(s)]}var zT=LT;function FT(s){return function(e){return s(e)}}var qT=FT,ch={exports:{}};(function(s,e){var t=aw,i=e&&!e.nodeType&&e,r=i&&!0&&s&&!s.nodeType&&s,n=r&&r.exports===i,o=n&&t.process,a=function(){try{var l=r&&r.require&&r.require("util").types;return l||o&&o.binding&&o.binding("util")}catch{}}();s.exports=a})(ch,ch.exports);var BT=zT,HT=qT,dp=ch.exports,pp=dp&&dp.isTypedArray,WT=pp?HT(pp):BT,vw=WT;function VT(s,e){if(!(e==="constructor"&&typeof s[e]=="function")&&e!="__proto__")return s[e]}var Iw=VT,KT=nu,GT=Ic,YT=Object.prototype,QT=YT.hasOwnProperty;function ZT(s,e,t){var i=s[e];(!(QT.call(s,e)&>(i,t))||t===void 0&&!(e in s))&&KT(s,e,t)}var JT=ZT,XT=JT,e2=nu;function t2(s,e,t,i){var r=!t;t||(t={});for(var n=-1,o=e.length;++n<o;){var a=e[n],l=i?i(t[a],s[a],a,t,s):void 0;l===void 0&&(l=s[a]),r?e2(t,a,l):XT(t,a,l)}return t}var s2=t2;function i2(s,e){for(var t=-1,i=Array(s);++t<s;)i[t]=e(t);return i}var r2=i2,n2=9007199254740991,o2=/^(?:0|[1-9]\d*)$/;function a2(s,e){var t=typeof s;return e=e??n2,!!e&&(t=="number"||t!="symbol"&&o2.test(s))&&s>-1&&s%1==0&&s<e}var Ew=a2,c2=r2,l2=mw,h2=ww,u2=ec.exports,d2=Ew,p2=vw,g2=Object.prototype,f2=g2.hasOwnProperty;function m2(s,e){var t=h2(s),i=!t&&l2(s),r=!t&&!i&&u2(s),n=!t&&!i&&!r&&p2(s),o=t||i||r||n,a=o?c2(s.length,String):[],l=a.length;for(var c in s)(e||f2.call(s,c))&&!(o&&(c=="length"||r&&(c=="offset"||c=="parent")||n&&(c=="buffer"||c=="byteLength"||c=="byteOffset")||d2(c,l)))&&a.push(c);return a}var w2=m2;function y2(s){var e=[];if(s!=null)for(var t in Object(s))e.push(t);return e}var b2=y2,v2=gr,I2=gw,E2=b2,A2=Object.prototype,N2=A2.hasOwnProperty;function _2(s){if(!v2(s))return E2(s);var e=I2(s),t=[];for(var i in s)i=="constructor"&&(e||!N2.call(s,i))||t.push(i);return t}var C2=_2,S2=w2,$2=C2,P2=ou;function T2(s){return P2(s)?S2(s,!0):$2(s)}var Aw=T2,M2=s2,x2=Aw;function O2(s){return M2(s,x2(s))}var D2=O2,gp=dw,k2=ah.exports,j2=wP,R2=bP,U2=OP,fp=mw,mp=ww,L2=XP,z2=ec.exports,F2=iu,q2=gr,B2=uT,H2=vw,wp=Iw,W2=D2;function V2(s,e,t,i,r,n,o){var a=wp(s,t),l=wp(e,t),c=o.get(l);if(c){gp(s,t,c);return}var h=n?n(a,l,t+"",s,e,o):void 0,u=h===void 0;if(u){var d=mp(l),p=!d&&z2(l),g=!d&&!p&&H2(l);h=l,d||p||g?mp(a)?h=a:L2(a)?h=R2(a):p?(u=!1,h=k2(l,!0)):g?(u=!1,h=j2(l,!0)):h=[]:B2(l)||fp(l)?(h=a,fp(a)?h=W2(a):(!q2(a)||F2(a))&&(h=U2(l))):u=!1}u&&(o.set(l,h),r(h,l,i,n,o),o.delete(l)),gp(s,t,h)}var K2=V2,G2=J$,Y2=dw,Q2=lP,Z2=K2,J2=gr,X2=Aw,eM=Iw;function Nw(s,e,t,i,r){s!==e&&Q2(e,function(n,o){if(r||(r=new G2),J2(n))Z2(s,e,o,t,Nw,i,r);else{var a=i?i(eM(s,o),n,o+"",s,e,r):void 0;a===void 0&&(a=n),Y2(s,o,a)}},X2)}var tM=Nw;function sM(s){return s}var _w=sM;function iM(s,e,t){switch(t.length){case 0:return s.call(e);case 1:return s.call(e,t[0]);case 2:return s.call(e,t[0],t[1]);case 3:return s.call(e,t[0],t[1],t[2])}return s.apply(e,t)}var rM=iM,nM=rM,yp=Math.max;function oM(s,e,t){return e=yp(e===void 0?s.length-1:e,0),function(){for(var i=arguments,r=-1,n=yp(i.length-e,0),o=Array(n);++r<n;)o[r]=i[e+r];r=-1;for(var a=Array(e+1);++r<e;)a[r]=i[r];return a[e]=t(o),nM(s,this,a)}}var aM=oM;function cM(s){return function(){return s}}var lM=cM,hM=lM,bp=uw,uM=_w,dM=bp?function(s,e){return bp(s,"toString",{configurable:!0,enumerable:!1,value:hM(e),writable:!0})}:uM,pM=dM,gM=800,fM=16,mM=Date.now;function wM(s){var e=0,t=0;return function(){var i=mM(),r=fM-(i-t);if(t=i,r>0){if(++e>=gM)return arguments[0]}else e=0;return s.apply(void 0,arguments)}}var yM=wM,bM=pM,vM=yM,IM=vM(bM),EM=IM,AM=_w,NM=aM,_M=EM;function CM(s,e){return _M(NM(s,e,AM),s+"")}var SM=CM,$M=Ic,PM=ou,TM=Ew,MM=gr;function xM(s,e,t){if(!MM(t))return!1;var i=typeof e;return(i=="number"?PM(t)&&TM(e,t.length):i=="string"&&e in t)?$M(t[e],s):!1}var OM=xM,DM=SM,kM=OM;function jM(s){return DM(function(e,t){var i=-1,r=t.length,n=r>1?t[r-1]:void 0,o=r>2?t[2]:void 0;for(n=s.length>3&&typeof n=="function"?(r--,n):void 0,o&&kM(t[0],t[1],o)&&(n=r<3?void 0:n,r=1),e=Object(e);++i<r;){var a=t[i];a&&s(e,a,i,n)}return e})}var RM=jM,UM=tM,LM=RM,zM=LM(function(s,e,t){UM(s,e,t)}),FM=zM,qM=Object.defineProperty,BM=Object.defineProperties,HM=Object.getOwnPropertyDescriptors,vp=Object.getOwnPropertySymbols,WM=Object.prototype.hasOwnProperty,VM=Object.prototype.propertyIsEnumerable,Ip=(s,e,t)=>e in s?qM(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,ma=(s,e)=>{for(var t in e||(e={}))WM.call(e,t)&&Ip(s,t,e[t]);if(vp)for(var t of vp(e))VM.call(e,t)&&Ip(s,t,e[t]);return s},KM=(s,e)=>BM(s,HM(e));function ls(s,e,t){var i;const r=gn(s);return((i=e.rpcMap)==null?void 0:i[r.reference])||`${ow}?chainId=${r.namespace}:${r.reference}&projectId=${t}`}function fr(s){return s.includes(":")?s.split(":")[1]:s}function Cw(s){return s.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function GM(s,e){const t=Object.keys(e.namespaces).filter(r=>r.includes(s));if(!t.length)return[];const i=[];return t.forEach(r=>{const n=e.namespaces[r].accounts;i.push(...n)}),i}function tl(s={},e={}){const t=Ep(s),i=Ep(e);return FM(t,i)}function Ep(s){var e,t,i,r;const n={};if(!To(s))return n;for(const[o,a]of Object.entries(s)){const l=eu(o)?[o]:a.chains,c=a.methods||[],h=a.events||[],u=a.rpcMap||{},d=no(o);n[d]=KM(ma(ma({},n[d]),a),{chains:ka(l,(e=n[d])==null?void 0:e.chains),methods:ka(c,(t=n[d])==null?void 0:t.methods),events:ka(h,(i=n[d])==null?void 0:i.events),rpcMap:ma(ma({},u),(r=n[d])==null?void 0:r.rpcMap)})}return n}function YM(s){return s.includes(":")?s.split(":")[2]:s}function Ap(s){const e={};for(const[t,i]of Object.entries(s)){const r=i.methods||[],n=i.events||[],o=i.accounts||[],a=eu(t)?[t]:i.chains?i.chains:Cw(i.accounts);e[t]={chains:a,methods:r,events:n,accounts:o}}return e}function sl(s){return typeof s=="number"?s:s.includes("0x")?parseInt(s,16):(s=s.includes(":")?s.split(":")[1]:s,isNaN(Number(s))?s:Number(s))}const Sw={},be=s=>Sw[s],il=(s,e)=>{Sw[s]=e};var QM=Object.defineProperty,ZM=(s,e,t)=>e in s?QM(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Cr=(s,e,t)=>ZM(s,typeof e!="symbol"?e+"":e,t);class JM{constructor(e){Cr(this,"name","polkadot"),Cr(this,"client"),Cr(this,"httpProviders"),Cr(this,"events"),Cr(this,"namespace"),Cr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=fr(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var XM=Object.defineProperty,ex=Object.defineProperties,tx=Object.getOwnPropertyDescriptors,Np=Object.getOwnPropertySymbols,sx=Object.prototype.hasOwnProperty,ix=Object.prototype.propertyIsEnumerable,lh=(s,e,t)=>e in s?XM(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,_p=(s,e)=>{for(var t in e||(e={}))sx.call(e,t)&&lh(s,t,e[t]);if(Np)for(var t of Np(e))ix.call(e,t)&&lh(s,t,e[t]);return s},Cp=(s,e)=>ex(s,tx(e)),Sr=(s,e,t)=>lh(s,typeof e!="symbol"?e+"":e,t);class rx{constructor(e){Sr(this,"name","eip155"),Sr(this,"client"),Sr(this,"chainId"),Sr(this,"namespace"),Sr(this,"httpProviders"),Sr(this,"events"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain())}async request(e){switch(e.request.method){case"eth_requestAccounts":return this.getAccounts();case"eth_accounts":return this.getAccounts();case"wallet_switchEthereumChain":return await this.handleSwitchChain(e);case"eth_chainId":return parseInt(this.getDefaultChain());case"wallet_getCapabilities":return await this.getCapabilities(e);case"wallet_getCallsStatus":return await this.getCallStatus(e)}return this.namespace.methods.includes(e.request.method)?await this.client.request(e):this.getHttpProvider().request(e.request)}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(parseInt(e),t),this.chainId=parseInt(e),this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId.toString();if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}createHttpProvider(e,t){const i=t||ls(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=parseInt(fr(t));e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}getHttpProvider(){const e=this.chainId,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}async handleSwitchChain(e){var t,i;let r=e.request.params?(t=e.request.params[0])==null?void 0:t.chainId:"0x0";r=r.startsWith("0x")?r:`0x${r}`;const n=parseInt(r,16);if(this.isChainApproved(n))this.setDefaultChain(`${n}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:r}]},chainId:(i=this.namespace.chains)==null?void 0:i[0]}),this.setDefaultChain(`${n}`);else throw new Error(`Failed to switch to chain 'eip155:${n}'. The chain is not approved or the wallet does not support 'wallet_switchEthereumChain' method.`);return null}isChainApproved(e){return this.namespace.chains.includes(`${this.name}:${e}`)}async getCapabilities(e){var t,i,r;const n=(i=(t=e.request)==null?void 0:t.params)==null?void 0:i[0];if(!n)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const o=this.client.session.get(e.topic),a=((r=o==null?void 0:o.sessionProperties)==null?void 0:r.capabilities)||{};if(a!=null&&a[n])return a==null?void 0:a[n];const l=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Cp(_p({},o.sessionProperties||{}),{capabilities:Cp(_p({},a||{}),{[n]:l})})})}catch(c){console.warn("Failed to update session with capabilities",c)}return l}async getCallStatus(e){var t,i;const r=this.client.session.get(e.topic),n=(t=r.sessionProperties)==null?void 0:t.bundler_name;if(n){const a=this.getBundlerUrl(e.chainId,n);try{return await this.getUserOperationReceipt(a,e)}catch(l){console.warn("Failed to fetch call status from bundler",l,a)}}const o=(i=r.sessionProperties)==null?void 0:i.bundler_url;if(o)try{return await this.getUserOperationReceipt(o,e)}catch(a){console.warn("Failed to fetch call status from custom bundler",a,o)}if(this.namespace.methods.includes(e.request.method))return await this.client.request(e);throw new Error("Fetching call status not approved by the wallet.")}async getUserOperationReceipt(e,t){var i;const r=new URL(e),n=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(m.formatJsonRpcRequest("eth_getUserOperationReceipt",[(i=t.request.params)==null?void 0:i[0]]))});if(!n.ok)throw new Error(`Failed to fetch user operation receipt - ${n.status}`);return await n.json()}getBundlerUrl(e,t){return`${rC}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${t}`}}var nx=Object.defineProperty,ox=(s,e,t)=>e in s?nx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,$r=(s,e,t)=>ox(s,typeof e!="symbol"?e+"":e,t);class ax{constructor(e){$r(this,"name","solana"),$r(this,"client"),$r(this,"httpProviders"),$r(this,"events"),$r(this,"namespace"),$r(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=fr(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var cx=Object.defineProperty,lx=(s,e,t)=>e in s?cx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Pr=(s,e,t)=>lx(s,typeof e!="symbol"?e+"":e,t);class hx{constructor(e){Pr(this,"name","cosmos"),Pr(this,"client"),Pr(this,"httpProviders"),Pr(this,"events"),Pr(this,"namespace"),Pr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=fr(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var ux=Object.defineProperty,dx=(s,e,t)=>e in s?ux(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Tr=(s,e,t)=>dx(s,typeof e!="symbol"?e+"":e,t);class px{constructor(e){Tr(this,"name","algorand"),Tr(this,"client"),Tr(this,"httpProviders"),Tr(this,"events"),Tr(this,"namespace"),Tr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(!this.httpProviders[e]){const i=t||ls(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);return typeof i>"u"?void 0:new Ge(new m.f(i,be("disableProviderPing")))}}var gx=Object.defineProperty,fx=(s,e,t)=>e in s?gx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mr=(s,e,t)=>fx(s,typeof e!="symbol"?e+"":e,t);class mx{constructor(e){Mr(this,"name","cip34"),Mr(this,"client"),Mr(this,"httpProviders"),Mr(this,"events"),Mr(this,"namespace"),Mr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{const i=this.getCardanoRPCUrl(t),r=fr(t);e[r]=this.createHttpProvider(r,i)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}getCardanoRPCUrl(e){const t=this.namespace.rpcMap;if(t)return t[e]}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||this.getCardanoRPCUrl(e);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var wx=Object.defineProperty,yx=(s,e,t)=>e in s?wx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xr=(s,e,t)=>yx(s,typeof e!="symbol"?e+"":e,t);class bx{constructor(e){xr(this,"name","elrond"),xr(this,"client"),xr(this,"httpProviders"),xr(this,"events"),xr(this,"namespace"),xr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=fr(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var vx=Object.defineProperty,Ix=(s,e,t)=>e in s?vx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Or=(s,e,t)=>Ix(s,typeof e!="symbol"?e+"":e,t);class Ex{constructor(e){Or(this,"name","multiversx"),Or(this,"client"),Or(this,"httpProviders"),Or(this,"events"),Or(this,"namespace"),Or(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;const r=fr(t);e[r]=this.createHttpProvider(r,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var Ax=Object.defineProperty,Nx=(s,e,t)=>e in s?Ax(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Dr=(s,e,t)=>Nx(s,typeof e!="symbol"?e+"":e,t);class _x{constructor(e){Dr(this,"name","near"),Dr(this,"client"),Dr(this,"httpProviders"),Dr(this,"events"),Dr(this,"namespace"),Dr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||ls(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{var i;e[t]=this.createHttpProvider(t,(i=this.namespace.rpcMap)==null?void 0:i[t])}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace);return typeof i>"u"?void 0:new Ge(new m.f(i,be("disableProviderPing")))}}var Cx=Object.defineProperty,Sx=(s,e,t)=>e in s?Cx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,kr=(s,e,t)=>Sx(s,typeof e!="symbol"?e+"":e,t);class $x{constructor(e){kr(this,"name","tezos"),kr(this,"client"),kr(this,"httpProviders"),kr(this,"events"),kr(this,"namespace"),kr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace=Object.assign(this.namespace,e)}requestAccounts(){return this.getAccounts()}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider().request(e.request)}setDefaultChain(e,t){if(this.chainId=e,!this.httpProviders[e]){const i=t||ls(`${this.name}:${e}`,this.namespace);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);this.setHttpProvider(e,i)}this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${this.chainId}`)}getAccounts(){const e=this.namespace.accounts;return e?e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2])||[]:[]}createHttpProviders(){const e={};return this.namespace.chains.forEach(t=>{e[t]=this.createHttpProvider(t)}),e}getHttpProvider(){const e=`${this.name}:${this.chainId}`,t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace);return typeof i>"u"?void 0:new Ge(new m.f(i))}}var Px=Object.defineProperty,Tx=(s,e,t)=>e in s?Px(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,jr=(s,e,t)=>Tx(s,typeof e!="symbol"?e+"":e,t);class Mx{constructor(e){jr(this,"name",en),jr(this,"client"),jr(this,"httpProviders"),jr(this,"events"),jr(this,"namespace"),jr(this,"chainId"),this.namespace=e.namespace,this.events=be("events"),this.client=be("client"),this.chainId=this.getDefaultChain(),this.httpProviders=this.createHttpProviders()}updateNamespace(e){this.namespace.chains=[...new Set((this.namespace.chains||[]).concat(e.chains||[]))],this.namespace.accounts=[...new Set((this.namespace.accounts||[]).concat(e.accounts||[]))],this.namespace.methods=[...new Set((this.namespace.methods||[]).concat(e.methods||[]))],this.namespace.events=[...new Set((this.namespace.events||[]).concat(e.events||[]))],this.httpProviders=this.createHttpProviders()}requestAccounts(){return this.getAccounts()}request(e){return this.namespace.methods.includes(e.request.method)?this.client.request(e):this.getHttpProvider(e.chainId).request(e.request)}setDefaultChain(e,t){this.httpProviders[e]||this.setHttpProvider(e,t),this.chainId=e,this.events.emit(Is.DEFAULT_CHAIN_CHANGED,`${this.name}:${e}`)}getDefaultChain(){if(this.chainId)return this.chainId;if(this.namespace.defaultChain)return this.namespace.defaultChain;const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return e.split(":")[1]}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(t=>t.split(":")[1]===this.chainId.toString()).map(t=>t.split(":")[2]))]:[]}createHttpProviders(){var e,t;const i={};return(t=(e=this.namespace)==null?void 0:e.accounts)==null||t.forEach(r=>{const n=gn(r);i[`${n.namespace}:${n.reference}`]=this.createHttpProvider(r)}),i}getHttpProvider(e){const t=this.httpProviders[e];if(typeof t>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return t}setHttpProvider(e,t){const i=this.createHttpProvider(e,t);i&&(this.httpProviders[e]=i)}createHttpProvider(e,t){const i=t||ls(e,this.namespace,this.client.core.projectId);if(!i)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ge(new m.f(i,be("disableProviderPing")))}}var xx=Object.defineProperty,Ox=Object.defineProperties,Dx=Object.getOwnPropertyDescriptors,Sp=Object.getOwnPropertySymbols,kx=Object.prototype.hasOwnProperty,jx=Object.prototype.propertyIsEnumerable,hh=(s,e,t)=>e in s?xx(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,wa=(s,e)=>{for(var t in e||(e={}))kx.call(e,t)&&hh(s,t,e[t]);if(Sp)for(var t of Sp(e))jx.call(e,t)&&hh(s,t,e[t]);return s},rl=(s,e)=>Ox(s,Dx(e)),Cs=(s,e,t)=>hh(s,typeof e!="symbol"?e+"":e,t);class au{constructor(e){Cs(this,"client"),Cs(this,"namespaces"),Cs(this,"optionalNamespaces"),Cs(this,"sessionProperties"),Cs(this,"events",new te.EventEmitter),Cs(this,"rpcProviders",{}),Cs(this,"session"),Cs(this,"providerOpts"),Cs(this,"logger"),Cs(this,"uri"),Cs(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof(e==null?void 0:e.logger)<"u"&&typeof(e==null?void 0:e.logger)!="string"?e.logger:m.Dg(m.k({level:(e==null?void 0:e.logger)||ep})),this.disableProviderPing=(e==null?void 0:e.disableProviderPing)||!1}static async init(e){const t=new au(e);return await t.initialize(),t}async request(e,t,i){const[r,n]=this.validateChain(t);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:wa({},e),chainId:`${r}:${n}`,topic:this.session.topic,expiry:i})}sendAsync(e,t,i,r){const n=new Date().getTime();this.request(e,i,r).then(o=>t(null,m.formatJsonRpcResult(n,o))).catch(o=>t(o,void 0))}async enable(){if(!this.client)throw new Error("Sign Client not initialized");return this.session||await this.connect({namespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties}),await this.requestAccounts()}async disconnect(){var e;if(!this.session)throw new Error("Please call connect() before enable()");await this.client.disconnect({topic:(e=this.session)==null?void 0:e.topic,reason:Te("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),await this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,t){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:i,response:r}=await this.client.authenticate(e,t);i&&(this.uri=i,this.events.emit("display_uri",i));const n=await r();if(this.session=n.session,this.session){const o=Ap(this.session.namespaces);this.namespaces=tl(this.namespaces,o),this.persist("namespaces",this.namespaces),this.onConnect()}return n}on(e,t){this.events.on(e,t)}once(e,t){this.events.once(e,t)}removeListener(e,t){this.events.removeListener(e,t)}off(e,t){this.events.off(e,t)}get isWalletConnect(){return!0}async pair(e){const{uri:t,approval:i}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties});t&&(this.uri=t,this.events.emit("display_uri",t));const r=await i();this.session=r;const n=Ap(r.namespaces);return this.namespaces=tl(this.namespaces,n),this.persist("namespaces",this.namespaces),this.onConnect(),this.session}setDefaultChain(e,t){try{if(!this.session)return;const[i,r]=this.validateChain(e),n=this.getProvider(i);n.name===en?n.setDefaultChain(`${i}:${r}`,t):n.setDefaultChain(r,t)}catch(i){if(!/Please call connect/.test(i.message))throw i}}async cleanupPendingPairings(e={}){this.logger.info("Cleaning up inactive pairings...");const t=this.client.pairing.getAll();if(rr(t)){for(const i of t)e.deletePairings?this.client.core.expirer.set(i.topic,0):await this.client.core.relayer.subscriber.unsubscribe(i.topic);this.logger.info(`Inactive pairings cleared: ${t.length}`)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){if(this.namespaces=await this.getFromStore("namespaces"),this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.client.session.length){const e=this.client.session.keys.length-1;this.session=this.client.session.get(this.client.session.keys[e]),this.createProviders()}}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){this.client=this.providerOpts.client||await eC.init({core:this.providerOpts.core,logger:this.providerOpts.logger||ep,relayUrl:this.providerOpts.relayUrl||tC,projectId:this.providerOpts.projectId,metadata:this.providerOpts.metadata,storageOptions:this.providerOpts.storageOptions,storage:this.providerOpts.storage,name:this.providerOpts.name,customStoragePrefix:this.providerOpts.customStoragePrefix,telemetryEnabled:this.providerOpts.telemetryEnabled}),this.logger.trace("SignClient Initialized")}createProviders(){if(!this.client)throw new Error("Sign Client not initialized");if(!this.session)throw new Error("Session not initialized. Please call connect() before enable()");const e=[...new Set(Object.keys(this.session.namespaces).map(t=>no(t)))];il("client",this.client),il("events",this.events),il("disableProviderPing",this.disableProviderPing),e.forEach(t=>{if(!this.session)return;const i=GM(t,this.session),r=Cw(i),n=tl(this.namespaces,this.optionalNamespaces),o=rl(wa({},n[t]),{accounts:i,chains:r});switch(t){case"eip155":this.rpcProviders[t]=new rx({namespace:o});break;case"algorand":this.rpcProviders[t]=new px({namespace:o});break;case"solana":this.rpcProviders[t]=new ax({namespace:o});break;case"cosmos":this.rpcProviders[t]=new hx({namespace:o});break;case"polkadot":this.rpcProviders[t]=new JM({namespace:o});break;case"cip34":this.rpcProviders[t]=new mx({namespace:o});break;case"elrond":this.rpcProviders[t]=new bx({namespace:o});break;case"multiversx":this.rpcProviders[t]=new Ex({namespace:o});break;case"near":this.rpcProviders[t]=new _x({namespace:o});break;case"tezos":this.rpcProviders[t]=new $x({namespace:o});break;default:this.rpcProviders[en]?this.rpcProviders[en].updateNamespace(o):this.rpcProviders[en]=new Mx({namespace:o})}})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{const{params:t}=e,{event:i}=t;if(i.name==="accountsChanged"){const r=i.data;r&&rr(r)&&this.events.emit("accountsChanged",r.map(YM))}else if(i.name==="chainChanged"){const r=t.chainId,n=t.event.data,o=no(r),a=sl(r)!==sl(n)?`${o}:${sl(n)}`:r;this.onChainChanged(a)}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:t})=>{var i;const{namespaces:r}=t,n=(i=this.client)==null?void 0:i.session.get(e);this.session=rl(wa({},n),{namespaces:r}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:t})}),this.client.on("session_delete",async e=>{await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",rl(wa({},Te("USER_DISCONNECTED")),{data:e.topic}))}),this.on(Is.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(e,!0)})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[en]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var t;this.getProvider(e).updateNamespace((t=this.session)==null?void 0:t.namespaces[e])})}setNamespaces(e){const{namespaces:t,optionalNamespaces:i,sessionProperties:r}=e;t&&Object.keys(t).length&&(this.namespaces=t),i&&Object.keys(i).length&&(this.optionalNamespaces=i),this.sessionProperties=r,this.persist("namespaces",t),this.persist("optionalNamespaces",i)}validateChain(e){const[t,i]=(e==null?void 0:e.split(":"))||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[t,i];if(t&&!Object.keys(this.namespaces||{}).map(o=>no(o)).includes(t))throw new Error(`Namespace '${t}' is not configured. Please call connect() first with namespace config.`);if(t&&i)return[t,i];const r=no(Object.keys(this.namespaces)[0]),n=this.rpcProviders[r].getDefaultChain();return[r,n]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}onChainChanged(e,t=!1){if(!this.namespaces)return;const[i,r]=this.validateChain(e);r&&(t||this.getProvider(i).setDefaultChain(r),this.namespaces[i]?this.namespaces[i].defaultChain=r:this.namespaces[`${i}:${r}`]?this.namespaces[`${i}:${r}`].defaultChain=r:this.namespaces[`${i}:${r}`]={defaultChain:r},this.persist("namespaces",this.namespaces),this.events.emit("chainChanged",r))}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.session=void 0,this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,this.persist("namespaces",void 0),this.persist("optionalNamespaces",void 0),this.persist("sessionProperties",void 0),await this.cleanupPendingPairings({deletePairings:!0})}persist(e,t){this.client.core.storage.setItem(`${tp}/${e}`,t)}async getFromStore(e){return await this.client.core.storage.getItem(`${tp}/${e}`)}}const Rx=au,$w={caipNetworkIdToNumber(s){return s?Number(s.split(":")[1]):void 0},parseEvmChainId(s){return typeof s=="string"?this.caipNetworkIdToNumber(s):s},getNetworksByNamespace(s,e){return(s==null?void 0:s.filter(t=>t.chainNamespace===e))||[]},getFirstNetworkByNamespace(s,e){return this.getNetworksByNamespace(s,e)[0]}};var Ux=20,Lx=1,Pn=1e6,zx=1e6,Fx=-7,qx=21,Bx=!1,Jo="[big.js] ",mr=Jo+"Invalid ",Sc=mr+"decimal places",Hx=mr+"rounding mode",Pw=Jo+"Division by zero",$e={},Hs=void 0,Wx=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function Tw(){function s(e){var t=this;if(!(t instanceof s))return e===Hs?Tw():new s(e);if(e instanceof s)t.s=e.s,t.e=e.e,t.c=e.c.slice();else{if(typeof e!="string"){if(s.strict===!0&&typeof e!="bigint")throw TypeError(mr+"value");e=e===0&&1/e<0?"-0":String(e)}Vx(t,e)}t.constructor=s}return s.prototype=$e,s.DP=Ux,s.RM=Lx,s.NE=Fx,s.PE=qx,s.strict=Bx,s.roundDown=0,s.roundHalfUp=1,s.roundHalfEven=2,s.roundUp=3,s}function Vx(s,e){var t,i,r;if(!Wx.test(e))throw Error(mr+"number");for(s.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(t=e.indexOf("."))>-1&&(e=e.replace(".","")),(i=e.search(/e/i))>0?(t<0&&(t=i),t+=+e.slice(i+1),e=e.substring(0,i)):t<0&&(t=e.length),r=e.length,i=0;i<r&&e.charAt(i)=="0";)++i;if(i==r)s.c=[s.e=0];else{for(;r>0&&e.charAt(--r)=="0";);for(s.e=t-i-1,s.c=[],t=0;i<=r;)s.c[t++]=+e.charAt(i++)}return s}function wr(s,e,t,i){var r=s.c;if(t===Hs&&(t=s.constructor.RM),t!==0&&t!==1&&t!==2&&t!==3)throw Error(Hx);if(e<1)i=t===3&&(i||!!r[0])||e===0&&(t===1&&r[0]>=5||t===2&&(r[0]>5||r[0]===5&&(i||r[1]!==Hs))),r.length=1,i?(s.e=s.e-e+1,r[0]=1):r[0]=s.e=0;else if(e<r.length){if(i=t===1&&r[e]>=5||t===2&&(r[e]>5||r[e]===5&&(i||r[e+1]!==Hs||r[e-1]&1))||t===3&&(i||!!r[0]),r.length=e,i){for(;++r[--e]>9;)if(r[e]=0,e===0){++s.e,r.unshift(1);break}}for(e=r.length;!r[--e];)r.pop()}return s}function yr(s,e,t){var i=s.e,r=s.c.join(""),n=r.length;if(e)r=r.charAt(0)+(n>1?"."+r.slice(1):"")+(i<0?"e":"e+")+i;else if(i<0){for(;++i;)r="0"+r;r="0."+r}else if(i>0)if(++i>n)for(i-=n;i--;)r+="0";else i<n&&(r=r.slice(0,i)+"."+r.slice(i));else n>1&&(r=r.charAt(0)+"."+r.slice(1));return s.s<0&&t?"-"+r:r}$e.abs=function(){var s=new this.constructor(this);return s.s=1,s};$e.cmp=function(s){var e,t=this,i=t.c,r=(s=new t.constructor(s)).c,n=t.s,o=s.s,a=t.e,l=s.e;if(!i[0]||!r[0])return i[0]?n:r[0]?-o:0;if(n!=o)return n;if(e=n<0,a!=l)return a>l^e?1:-1;for(o=(a=i.length)<(l=r.length)?a:l,n=-1;++n<o;)if(i[n]!=r[n])return i[n]>r[n]^e?1:-1;return a==l?0:a>l^e?1:-1};$e.div=function(s){var e=this,t=e.constructor,i=e.c,r=(s=new t(s)).c,n=e.s==s.s?1:-1,o=t.DP;if(o!==~~o||o<0||o>Pn)throw Error(Sc);if(!r[0])throw Error(Pw);if(!i[0])return s.s=n,s.c=[s.e=0],s;var a,l,c,h,u,d=r.slice(),p=a=r.length,g=i.length,f=i.slice(0,a),b=f.length,y=s,w=y.c=[],v=0,A=o+(y.e=e.e-s.e)+1;for(y.s=n,n=A<0?0:A,d.unshift(0);b++<a;)f.push(0);do{for(c=0;c<10;c++){if(a!=(b=f.length))h=a>b?1:-1;else for(u=-1,h=0;++u<a;)if(r[u]!=f[u]){h=r[u]>f[u]?1:-1;break}if(h<0){for(l=b==a?r:d;b;){if(f[--b]<l[b]){for(u=b;u&&!f[--u];)f[u]=9;--f[u],f[b]+=10}f[b]-=l[b]}for(;!f[0];)f.shift()}else break}w[v++]=h?c:++c,f[0]&&h?f[b]=i[p]||0:f=[i[p]]}while((p++<g||f[0]!==Hs)&&n--);return!w[0]&&v!=1&&(w.shift(),y.e--,A--),v>A&&wr(y,A,t.RM,f[0]!==Hs),y};$e.eq=function(s){return this.cmp(s)===0};$e.gt=function(s){return this.cmp(s)>0};$e.gte=function(s){return this.cmp(s)>-1};$e.lt=function(s){return this.cmp(s)<0};$e.lte=function(s){return this.cmp(s)<1};$e.minus=$e.sub=function(s){var e,t,i,r,n=this,o=n.constructor,a=n.s,l=(s=new o(s)).s;if(a!=l)return s.s=-l,n.plus(s);var c=n.c.slice(),h=n.e,u=s.c,d=s.e;if(!c[0]||!u[0])return u[0]?s.s=-l:c[0]?s=new o(n):s.s=1,s;if(a=h-d){for((r=a<0)?(a=-a,i=c):(d=h,i=u),i.reverse(),l=a;l--;)i.push(0);i.reverse()}else for(t=((r=c.length<u.length)?c:u).length,a=l=0;l<t;l++)if(c[l]!=u[l]){r=c[l]<u[l];break}if(r&&(i=c,c=u,u=i,s.s=-s.s),(l=(t=u.length)-(e=c.length))>0)for(;l--;)c[e++]=0;for(l=e;t>a;){if(c[--t]<u[t]){for(e=t;e&&!c[--e];)c[e]=9;--c[e],c[t]+=10}c[t]-=u[t]}for(;c[--l]===0;)c.pop();for(;c[0]===0;)c.shift(),--d;return c[0]||(s.s=1,c=[d=0]),s.c=c,s.e=d,s};$e.mod=function(s){var e,t=this,i=t.constructor,r=t.s,n=(s=new i(s)).s;if(!s.c[0])throw Error(Pw);return t.s=s.s=1,e=s.cmp(t)==1,t.s=r,s.s=n,e?new i(t):(r=i.DP,n=i.RM,i.DP=i.RM=0,t=t.div(s),i.DP=r,i.RM=n,this.minus(t.times(s)))};$e.neg=function(){var s=new this.constructor(this);return s.s=-s.s,s};$e.plus=$e.add=function(s){var e,t,i,r=this,n=r.constructor;if(s=new n(s),r.s!=s.s)return s.s=-s.s,r.minus(s);var o=r.e,a=r.c,l=s.e,c=s.c;if(!a[0]||!c[0])return c[0]||(a[0]?s=new n(r):s.s=r.s),s;if(a=a.slice(),e=o-l){for(e>0?(l=o,i=c):(e=-e,i=a),i.reverse();e--;)i.push(0);i.reverse()}for(a.length-c.length<0&&(i=c,c=a,a=i),e=c.length,t=0;e;a[e]%=10)t=(a[--e]=a[e]+c[e]+t)/10|0;for(t&&(a.unshift(t),++l),e=a.length;a[--e]===0;)a.pop();return s.c=a,s.e=l,s};$e.pow=function(s){var e=this,t=new e.constructor("1"),i=t,r=s<0;if(s!==~~s||s<-1e6||s>zx)throw Error(mr+"exponent");for(r&&(s=-s);s&1&&(i=i.times(e)),s>>=1,!!s;)e=e.times(e);return r?t.div(i):i};$e.prec=function(s,e){if(s!==~~s||s<1||s>Pn)throw Error(mr+"precision");return wr(new this.constructor(this),s,e)};$e.round=function(s,e){if(s===Hs)s=0;else if(s!==~~s||s<-1e6||s>Pn)throw Error(Sc);return wr(new this.constructor(this),s+this.e+1,e)};$e.sqrt=function(){var s,e,t,i=this,r=i.constructor,n=i.s,o=i.e,a=new r("0.5");if(!i.c[0])return new r(i);if(n<0)throw Error(Jo+"No square root");n=Math.sqrt(+yr(i,!0,!0)),n===0||n===1/0?(e=i.c.join(""),e.length+o&1||(e+="0"),n=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),s=new r((n==1/0?"5e":(n=n.toExponential()).slice(0,n.indexOf("e")+1))+o)):s=new r(n+""),o=s.e+(r.DP+=4);do t=s,s=a.times(t.plus(i.div(t)));while(t.c.slice(0,o).join("")!==s.c.slice(0,o).join(""));return wr(s,(r.DP-=4)+s.e+1,r.RM)};$e.times=$e.mul=function(s){var e,t=this,i=t.constructor,r=t.c,n=(s=new i(s)).c,o=r.length,a=n.length,l=t.e,c=s.e;if(s.s=t.s==s.s?1:-1,!r[0]||!n[0])return s.c=[s.e=0],s;for(s.e=l+c,o<a&&(e=r,r=n,n=e,c=o,o=a,a=c),e=new Array(c=o+a);c--;)e[c]=0;for(l=a;l--;){for(a=0,c=o+l;c>l;)a=e[c]+n[l]*r[c-l-1]+a,e[c--]=a%10,a=a/10|0;e[c]=a}for(a?++s.e:e.shift(),l=e.length;!e[--l];)e.pop();return s.c=e,s};$e.toExponential=function(s,e){var t=this,i=t.c[0];if(s!==Hs){if(s!==~~s||s<0||s>Pn)throw Error(Sc);for(t=wr(new t.constructor(t),++s,e);t.c.length<s;)t.c.push(0)}return yr(t,!0,!!i)};$e.toFixed=function(s,e){var t=this,i=t.c[0];if(s!==Hs){if(s!==~~s||s<0||s>Pn)throw Error(Sc);for(t=wr(new t.constructor(t),s+t.e+1,e),s=s+t.e+1;t.c.length<s;)t.c.push(0)}return yr(t,!1,!!i)};$e[Symbol.for("nodejs.util.inspect.custom")]=$e.toJSON=$e.toString=function(){var s=this,e=s.constructor;return yr(s,s.e<=e.NE||s.e>=e.PE,!!s.c[0])};$e.toNumber=function(){var s=+yr(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(s.toString()))throw Error(Jo+"Imprecise conversion");return s};$e.toPrecision=function(s,e){var t=this,i=t.constructor,r=t.c[0];if(s!==Hs){if(s!==~~s||s<1||s>Pn)throw Error(mr+"precision");for(t=wr(new i(t),s,e);t.c.length<s;)t.c.push(0)}return yr(t,s<=t.e||t.e<=i.NE||t.e>=i.PE,!!r)};$e.valueOf=function(){var s=this,e=s.constructor;if(e.strict===!0)throw Error(Jo+"valueOf disallowed");return yr(s,s.e<=e.NE||s.e>=e.PE,!0)};var Wn=Tw();const ya={bigNumber(s){return s?new Wn(s):new Wn(0)},multiply(s,e){if(s===void 0||e===void 0)return new Wn(0);const t=new Wn(s),i=new Wn(e);return t.times(i)},formatNumberToLocalString(s,e=2){return s===void 0?"0.00":typeof s=="number"?s.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e}):parseFloat(s).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e})},parseLocalStringToNumber(s){return s===void 0?0:parseFloat(s.replace(/,/gu,""))}},Kx=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"_from",type:"address"},{name:"_to",type:"address"},{name:"_value",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Gx=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],Yx=[{type:"function",name:"transfer",stateMutability:"nonpayable",inputs:[{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[]},{type:"function",name:"transferFrom",stateMutability:"nonpayable",inputs:[{name:"sender",type:"address"},{name:"recipient",type:"address"},{name:"amount",type:"uint256"}],outputs:[{name:"",type:"bool"}]}],Z={WC_NAME_SUFFIX:".reown.id",WC_NAME_SUFFIX_LEGACY:".wcn.id",BLOCKCHAIN_API_RPC_URL:"https://rpc.walletconnect.org",PULSE_API_URL:"https://pulse.walletconnect.org",W3M_API_URL:"https://api.web3modal.org",CONNECTOR_ID:{WALLET_CONNECT:"walletConnect",INJECTED:"injected",WALLET_STANDARD:"announced",COINBASE:"coinbaseWallet",COINBASE_SDK:"coinbaseWalletSDK",SAFE:"safe",LEDGER:"ledger",OKX:"okx",EIP6963:"eip6963",AUTH:"ID_AUTH"},CONNECTOR_NAMES:{AUTH:"Auth"},AUTH_CONNECTOR_SUPPORTED_CHAINS:["eip155","solana"],LIMITS:{PENDING_TRANSACTIONS:99},CHAIN:{EVM:"eip155",SOLANA:"solana",POLKADOT:"polkadot",BITCOIN:"bip122"},CHAIN_NAME_MAP:{eip155:"EVM Networks",solana:"Solana",polkadot:"Polkadot",bip122:"Bitcoin"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],HTTP_STATUS_CODES:{SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network"},Qx={getERC20Abi:s=>Z.USDT_CONTRACT_ADDRESSES.includes(s)?Yx:Kx,getSwapAbi:()=>Gx},ci={validateCaipAddress(s){var e;if(((e=s.split(":"))==null?void 0:e.length)!==3)throw new Error("Invalid CAIP Address");return s},parseCaipAddress(s){const e=s.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${s}`);const[t,i,r]=e;if(!t||!i||!r)throw new Error(`Invalid CAIP-10 address: ${s}`);return{chainNamespace:t,chainId:i,address:r}},parseCaipNetworkId(s){const e=s.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${s}`);const[t,i]=e;if(!t||!i)throw new Error(`Invalid CAIP-2 network id: ${s}`);return{chainNamespace:t,chainId:i}}},oe={WALLET_ID:"@appkit/wallet_id",WALLET_NAME:"@appkit/wallet_name",SOLANA_WALLET:"@appkit/solana_wallet",SOLANA_CAIP_CHAIN:"@appkit/solana_caip_chain",ACTIVE_CAIP_NETWORK_ID:"@appkit/active_caip_network_id",CONNECTED_SOCIAL:"@appkit/connected_social",CONNECTED_SOCIAL_USERNAME:"@appkit-wallet/SOCIAL_USERNAME",RECENT_WALLETS:"@appkit/recent_wallets",DEEPLINK_CHOICE:"WALLETCONNECT_DEEPLINK_CHOICE",ACTIVE_NAMESPACE:"@appkit/active_namespace",CONNECTED_NAMESPACES:"@appkit/connected_namespaces",CONNECTION_STATUS:"@appkit/connection_status",SIWX_AUTH_TOKEN:"@appkit/siwx-auth-token",SIWX_NONCE_TOKEN:"@appkit/siwx-nonce-token",TELEGRAM_SOCIAL_PROVIDER:"@appkit/social_provider",NATIVE_BALANCE_CACHE:"@appkit/native_balance_cache",PORTFOLIO_CACHE:"@appkit/portfolio_cache",ENS_CACHE:"@appkit/ens_cache",IDENTITY_CACHE:"@appkit/identity_cache"};function nl(s){if(!s)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${s}:connected_connector_id`}const se={setItem(s,e){oo()&&e!==void 0&&localStorage.setItem(s,e)},getItem(s){if(oo())return localStorage.getItem(s)||void 0},removeItem(s){oo()&&localStorage.removeItem(s)},clear(){oo()&&localStorage.clear()}};function oo(){return typeof window<"u"&&typeof localStorage<"u"}function Ei(s,e){return e==="light"?{"--w3m-accent":(s==null?void 0:s["--w3m-accent"])||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":(s==null?void 0:s["--w3m-accent"])||"hsla(230, 100%, 67%, 1)","--w3m-background":"#121313"}}const Zx=Symbol(),$p=Object.getPrototypeOf,uh=new WeakMap,Jx=s=>s&&(uh.has(s)?uh.get(s):$p(s)===Object.prototype||$p(s)===Array.prototype),Xx=s=>Jx(s)&&s[Zx]||null,Pp=(s,e=!0)=>{uh.set(s,e)},tc={},ol=s=>typeof s=="object"&&s!==null,fi=new WeakMap,ao=new WeakSet,eO=(s=Object.is,e=(c,h)=>new Proxy(c,h),t=c=>ol(c)&&!ao.has(c)&&(Array.isArray(c)||!(Symbol.iterator in c))&&!(c instanceof WeakMap)&&!(c instanceof WeakSet)&&!(c instanceof Error)&&!(c instanceof Number)&&!(c instanceof Date)&&!(c instanceof String)&&!(c instanceof RegExp)&&!(c instanceof ArrayBuffer),i=c=>{switch(c.status){case"fulfilled":return c.value;case"rejected":throw c.reason;default:throw c}},r=new WeakMap,n=(c,h,u=i)=>{const d=r.get(c);if((d==null?void 0:d[0])===h)return d[1];const p=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c));return Pp(p,!0),r.set(c,[h,p]),Reflect.ownKeys(c).forEach(g=>{if(Object.getOwnPropertyDescriptor(p,g))return;const f=Reflect.get(c,g),{enumerable:b}=Reflect.getOwnPropertyDescriptor(c,g),y={value:f,enumerable:b,configurable:!0};if(ao.has(f))Pp(f,!1);else if(f instanceof Promise)delete y.value,y.get=()=>u(f);else if(fi.has(f)){const[w,v]=fi.get(f);y.value=n(w,v(),u)}Object.defineProperty(p,g,y)}),Object.preventExtensions(p)},o=new WeakMap,a=[1,1],l=c=>{if(!ol(c))throw new Error("object required");const h=o.get(c);if(h)return h;let u=a[0];const d=new Set,p=(S,M=++a[0])=>{u!==M&&(u=M,d.forEach($=>$(S,M)))};let g=a[1];const f=(S=++a[1])=>(g!==S&&!d.size&&(g=S,y.forEach(([M])=>{const $=M[1](S);$>u&&(u=$)})),u),b=S=>(M,$)=>{const U=[...M];U[1]=[S,...U[1]],p(U,$)},y=new Map,w=(S,M)=>{if((tc?"production":void 0)!=="production"&&y.has(S))throw new Error("prop listener already exists");if(d.size){const $=M[3](b(S));y.set(S,[M,$])}else y.set(S,[M])},v=S=>{var M;const $=y.get(S);$&&(y.delete(S),(M=$[1])==null||M.call($))},A=S=>(d.add(S),d.size===1&&y.forEach(([$,U],L)=>{if((tc?"production":void 0)!=="production"&&U)throw new Error("remove already exists");const B=$[3](b(L));y.set(L,[$,B])}),()=>{d.delete(S),d.size===0&&y.forEach(([$,U],L)=>{U&&(U(),y.set(L,[$]))})}),C=Array.isArray(c)?[]:Object.create(Object.getPrototypeOf(c)),T=e(C,{deleteProperty(S,M){const $=Reflect.get(S,M);v(M);const U=Reflect.deleteProperty(S,M);return U&&p(["delete",[M],$]),U},set(S,M,$,U){const L=Reflect.has(S,M),B=Reflect.get(S,M,U);if(L&&(s(B,$)||o.has($)&&s(B,o.get($))))return!0;v(M),ol($)&&($=Xx($)||$);let H=$;if($ instanceof Promise)$.then(z=>{$.status="fulfilled",$.value=z,p(["resolve",[M],z])}).catch(z=>{$.status="rejected",$.reason=z,p(["reject",[M],z])});else{!fi.has($)&&t($)&&(H=l($));const z=!ao.has(H)&&fi.get(H);z&&w(M,z)}return Reflect.set(S,M,H,U),p(["set",[M],$,B]),!0}});o.set(c,T);const O=[C,f,n,A];return fi.set(T,O),Reflect.ownKeys(c).forEach(S=>{const M=Object.getOwnPropertyDescriptor(c,S);"value"in M&&(T[S]=c[S],delete M.value,delete M.writable),Object.defineProperty(C,S,M)}),T})=>[l,fi,ao,s,e,t,i,r,n,o,a],[tO]=eO();function Ke(s={}){return tO(s)}function Lt(s,e,t){const i=fi.get(s);(tc?"production":void 0)!=="production"&&!i&&console.warn("Please use proxy object");let r;const n=[],o=i[3];let a=!1;const c=o(h=>{n.push(h),r||(r=Promise.resolve().then(()=>{r=void 0,a&&e(n.splice(0))}))});return a=!0,()=>{a=!1,c()}}function Mo(s,e){const t=fi.get(s);(tc?"production":void 0)!=="production"&&!t&&console.warn("Please use proxy object");const[i,r,n]=t;return n(i,r(),e)}function nr(s){return ao.add(s),s}function Xt(s,e,t,i){let r=s[e];return Lt(s,()=>{const n=s[e];Object.is(r,n)||t(r=n)})}function sO(s){const e=Ke({data:Array.from([]),has(t){return this.data.some(i=>i[0]===t)},set(t,i){const r=this.data.find(n=>n[0]===t);return r?r[1]=i:this.data.push([t,i]),this},get(t){var i;return(i=this.data.find(r=>r[0]===t))==null?void 0:i[1]},delete(t){const i=this.data.findIndex(r=>r[0]===t);return i===-1?!1:(this.data.splice(i,1),!0)},clear(){this.data.splice(0)},get size(){return this.data.length},toJSON(){return new Map(this.data)},forEach(t){this.data.forEach(i=>{t(i[1],i[0],this)})},keys(){return this.data.map(t=>t[0]).values()},values(){return this.data.map(t=>t[1]).values()},entries(){return new Map(this.data).entries()},get[Symbol.toStringTag](){return"Map"},[Symbol.iterator](){return this.entries()}});return Object.defineProperties(e,{data:{enumerable:!1},size:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(e),e}const al=(typeof N.dist.process<"u"&&typeof N.dist.process.env<"u"?N.dist.process.env.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",qt={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:al,SECURE_SITE_DASHBOARD:`${al}/dashboard`,SECURE_SITE_FAVICON:`${al}/images/favicon.png`,RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],WC_COINBASE_PAY_SDK_CHAINS:["ethereum","arbitrum","polygon","berachain","avalanche-c-chain","optimism","celo","base"],WC_COINBASE_PAY_SDK_FALLBACK_CHAIN:"ethereum",WC_COINBASE_PAY_SDK_CHAIN_NAME_MAP:{Ethereum:"ethereum","Arbitrum One":"arbitrum",Polygon:"polygon",Berachain:"berachain",Avalanche:"avalanche-c-chain","OP Mainnet":"optimism",Celo:"celo",Base:"base"},WC_COINBASE_ONRAMP_APP_ID:"bf18c88d-495a-463b-b249-0b9d3656cf5e",SWAP_SUGGESTED_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP"],SWAP_POPULAR_TOKENS:["ETH","UNI","1INCH","AAVE","SOL","ADA","AVAX","DOT","LINK","NITRO","GAIA","MILK","TRX","NEAR","GNO","WBTC","DAI","WETH","USDC","USDT","ARB","BAL","BICO","CRV","ENS","MATIC","OP","METAL","DAI","CHAMP","WOLF","SALE","BAL","BUSD","MUST","BTCpx","ROUTE","HEX","WELT","amDAI","VSQ","VISION","AURUM","pSP","SNX","VC","LINK","CHP","amUSDT","SPHERE","FOX","GIDDY","GFC","OMEN","OX_OLD","DE","WNT"],BALANCE_SUPPORTED_CHAINS:["eip155","solana"],SWAP_SUPPORTED_NETWORKS:["eip155:1","eip155:42161","eip155:10","eip155:324","eip155:8453","eip155:56","eip155:137","eip155:100","eip155:43114","eip155:250","eip155:8217","eip155:1313161554"],NAMES_SUPPORTED_CHAIN_NAMESPACES:["eip155"],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:["eip155","solana"],ACTIVITY_ENABLED_CHAIN_NAMESPACES:["eip155","solana"],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in a new browser tab"},DEFAULT_FEATURES:{swaps:!0,onramp:!0,receive:!0,send:!0,email:!0,emailShowWallets:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],history:!0,analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0},DEFAULT_ACCOUNT_TYPES:{bip122:"payment",eip155:"smartAccount",polkadot:"eoa",solana:"eoa"},ADAPTER_TYPES:{UNIVERSAL:"universal",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5",BITCOIN:"bitcoin"}},Y={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5},isCacheExpired(s,e){return Date.now()-s>e},getActiveNetworkProps(){const s=Y.getActiveNamespace(),e=Y.getActiveCaipNetworkId(),t=e?e.split(":")[1]:void 0,i=t?isNaN(Number(t))?t:Number(t):void 0;return{namespace:s,caipNetworkId:e,chainId:i}},setWalletConnectDeepLink({name:s,href:e}){try{se.setItem(oe.DEEPLINK_CHOICE,JSON.stringify({href:e,name:s}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const s=se.getItem(oe.DEEPLINK_CHOICE);if(s)return JSON.parse(s)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{se.removeItem(oe.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(s){try{se.setItem(oe.ACTIVE_NAMESPACE,s)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(s){try{se.setItem(oe.ACTIVE_CAIP_NETWORK_ID,s),Y.setActiveNamespace(s.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return se.getItem(oe.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{se.removeItem(oe.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(s){try{const e=nl(s);se.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(s){try{const e=Y.getRecentWallets();e.find(i=>i.id===s.id)||(e.unshift(s),e.length>2&&e.pop(),se.setItem(oe.RECENT_WALLETS,JSON.stringify(e)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const s=se.getItem(oe.RECENT_WALLETS);return s?JSON.parse(s):[]}catch{console.info("Unable to get AppKit recent")}return[]},setConnectedConnectorId(s,e){try{const t=nl(s);se.setItem(t,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return se.getItem(oe.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(s){if(s)try{const e=nl(s);return se.getItem(e)}catch{console.info("Unable to get connected connector id in namespace ",s)}},setConnectedSocialProvider(s){try{se.setItem(oe.CONNECTED_SOCIAL,s)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return se.getItem(oe.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{se.removeItem(oe.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return se.getItem(oe.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){var t;const s=se.getItem(oe.ACTIVE_CAIP_NETWORK_ID);return(t=s==null?void 0:s.split(":"))==null?void 0:t[1]},setConnectionStatus(s){try{se.setItem(oe.CONNECTION_STATUS,s)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return se.getItem(oe.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const s=se.getItem(oe.CONNECTED_NAMESPACES);return s!=null&&s.length?s.split(","):[]}catch{return[]}},setConnectedNamespaces(s){try{const e=Array.from(new Set(s));se.setItem(oe.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(s){try{const e=Y.getConnectedNamespaces();e.includes(s)||(e.push(s),Y.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(s){try{const e=Y.getConnectedNamespaces(),t=e.indexOf(s);t>-1&&(e.splice(t,1),Y.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return se.getItem(oe.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(s){try{se.setItem(oe.TELEGRAM_SOCIAL_PROVIDER,s)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{se.removeItem(oe.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let s={};try{const e=se.getItem(oe.PORTFOLIO_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return s},removeAddressFromBalanceCache(s){try{const e=Y.getBalanceCache();se.setItem(oe.PORTFOLIO_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove address from balance cache",s)}},getBalanceCacheForCaipAddress(s){try{const t=Y.getBalanceCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.portfolio))return t.balance;Y.removeAddressFromBalanceCache(s)}catch{console.info("Unable to get balance cache for address",s)}},updateBalanceCache(s){try{const e=Y.getBalanceCache();e[s.caipAddress]=s,se.setItem(oe.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",s)}},getNativeBalanceCache(){let s={};try{const e=se.getItem(oe.NATIVE_BALANCE_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return s},removeAddressFromNativeBalanceCache(s){try{const e=Y.getBalanceCache();se.setItem(oe.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove address from balance cache",s)}},getNativeBalanceCacheForCaipAddress(s){try{const t=Y.getNativeBalanceCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.nativeBalance))return t;console.info("Discarding cache for address",s),Y.removeAddressFromBalanceCache(s)}catch{console.info("Unable to get balance cache for address",s)}},updateNativeBalanceCache(s){try{const e=Y.getNativeBalanceCache();e[s.caipAddress]=s,se.setItem(oe.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",s)}},getEnsCache(){let s={};try{const e=se.getItem(oe.ENS_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return s},getEnsFromCacheForAddress(s){try{const t=Y.getEnsCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.ens))return t.ens;Y.removeEnsFromCache(s)}catch{console.info("Unable to get ens name from cache",s)}},updateEnsCache(s){try{const e=Y.getEnsCache();e[s.address]=s,se.setItem(oe.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",s)}},removeEnsFromCache(s){try{const e=Y.getEnsCache();se.setItem(oe.ENS_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove ens name from cache",s)}},getIdentityCache(){let s={};try{const e=se.getItem(oe.IDENTITY_CACHE);s=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return s},getIdentityFromCacheForAddress(s){try{const t=Y.getIdentityCache()[s];if(t&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.identity))return t.identity;Y.removeIdentityFromCache(s)}catch{console.info("Unable to get identity from cache",s)}},updateIdentityCache(s){try{const e=Y.getIdentityCache();e[s.address]={identity:s.identity,timestamp:s.timestamp},se.setItem(oe.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",s)}},removeIdentityFromCache(s){try{const e=Y.getIdentityCache();se.setItem(oe.IDENTITY_CACHE,JSON.stringify({...e,[s]:void 0}))}catch{console.info("Unable to remove identity from cache",s)}},clearAddressCache(){try{se.removeItem(oe.PORTFOLIO_CACHE),se.removeItem(oe.NATIVE_BALANCE_CACHE),se.removeItem(oe.ENS_CACHE),se.removeItem(oe.IDENTITY_CACHE)}catch{console.info("Unable to clear address cache")}}},re={isMobile(){var s;return this.isClient()?!!((s=window==null?void 0:window.matchMedia("(pointer:coarse)"))!=null&&s.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(s,e=""){return s==null?void 0:s.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const s=window==null?void 0:window.navigator.userAgent.toLowerCase();return re.isMobile()&&s.includes("android")},isIos(){if(!this.isMobile())return!1;const s=window==null?void 0:window.navigator.userAgent.toLowerCase();return s.includes("iphone")||s.includes("ipad")},isSafari(){return this.isClient()?(window==null?void 0:window.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(s){return s?s-Date.now()<=qt.TEN_SEC_MS:!0},isAllowedRetry(s,e=qt.ONE_SEC_MS){return Date.now()-s>=e},copyToClopboard(s){navigator.clipboard.writeText(s)},isIframe(){try{return(window==null?void 0:window.self)!==(window==null?void 0:window.top)}catch{return!1}},getPairingExpiry(){return Date.now()+qt.FOUR_MINUTES_MS},getNetworkId(s){return s==null?void 0:s.split(":")[1]},getPlainAddress(s){return s==null?void 0:s.split(":")[2]},async wait(s){return new Promise(e=>{setTimeout(e,s)})},debounce(s,e=500){let t;return(...i)=>{function r(){s(...i)}t&&clearTimeout(t),t=setTimeout(r,e)}},isHttpUrl(s){return s.startsWith("http://")||s.startsWith("https://")},formatNativeUrl(s,e){if(re.isHttpUrl(s))return this.formatUniversalUrl(s,e);let t=s;t.includes("://")||(t=s.replaceAll("/","").replaceAll(":",""),t=`${t}://`),t.endsWith("/")||(t=`${t}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${t}wc?uri=${i}`,href:t}},formatUniversalUrl(s,e){if(!re.isHttpUrl(s))return this.formatNativeUrl(s,e);let t=s;t.endsWith("/")||(t=`${t}/`);const i=encodeURIComponent(e);return{redirect:`${t}wc?uri=${i}`,href:t}},getOpenTargetForPlatform(s){return s==="popupWindow"?s:this.isTelegram()?Y.getTelegramSocialProvider()?"_top":"_blank":s},openHref(s,e,t){window==null||window.open(s,this.getOpenTargetForPlatform(e),t||"noreferrer noopener")},returnOpenHref(s,e,t){return window==null?void 0:window.open(s,this.getOpenTargetForPlatform(e),t||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},async preloadImage(s){const e=new Promise((t,i)=>{const r=new Image;r.onload=t,r.onerror=i,r.crossOrigin="anonymous",r.src=s});return Promise.race([e,re.wait(2e3)])},formatBalance(s,e){let t="0.000";if(typeof s=="string"){const i=Number(s);if(i){const r=Math.floor(i*1e3)/1e3;r&&(t=r.toString())}}return`${t}${e?` ${e}`:""}`},formatBalance2(s,e){var i;let t;if(s==="0")t="0";else if(typeof s=="string"){const r=Number(s);r&&(t=(i=r.toString().match(/^-?\d+(?:\.\d{0,3})?/u))==null?void 0:i[0])}return{value:t??"0",rest:t==="0"?"000":"",symbol:e}},getApiUrl(){return Z.W3M_API_URL},getBlockchainApiUrl(){return Z.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return Z.PULSE_API_URL},getUUID(){return crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})},parseError(s){var e,t;return typeof s=="string"?s:typeof((t=(e=s==null?void 0:s.issues)==null?void 0:e[0])==null?void 0:t.message)=="string"?s.issues[0].message:s instanceof Error?s.message:"Unknown error"},sortRequestedNetworks(s,e=[]){const t={};return e&&s&&(s.forEach((i,r)=>{t[i]=r}),e.sort((i,r)=>{const n=t[i.id],o=t[r.id];return n!==void 0&&o!==void 0?n-o:n!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(s){let e=0;for(const t of s)e+=t.value??0;return e},formatTokenBalance(s){const e=s.toFixed(2),[t,i]=e.split(".");return{dollars:t,pennies:i}},isAddress(s,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(s)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(s)||/^(?:0x)?[0-9A-F]{40}$/iu.test(s))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(s);default:return!1}},uniqueBy(s,e){const t=new Set;return s.filter(i=>{const r=i[e];return t.has(r)?!1:(t.add(r),!0)})},generateSdkVersion(s,e,t){const r=s.length===0?qt.ADAPTER_TYPES.UNIVERSAL:s.map(n=>n.adapterType).join(",");return`${e}-${r}-${t}`},createAccount(s,e,t,i,r){return{namespace:s,address:e,type:t,publicKey:i,path:r}},isCaipAddress(s){if(typeof s!="string")return!1;const e=s.split(":"),t=e[0];return e.filter(Boolean).length===3&&t in Z.CHAIN_NAME_MAP},isMac(){const s=window==null?void 0:window.navigator.userAgent.toLowerCase();return s.includes("macintosh")&&!s.includes("safari")},formatTelegramSocialLoginUrl(s){const e=`--${encodeURIComponent(window==null?void 0:window.location.href)}`,t="state=";if(new URL(s).host==="auth.magic.link"){const r="provider_authorization_url=",n=s.substring(s.indexOf(r)+r.length),o=this.injectIntoUrl(decodeURIComponent(n),t,e);return s.replace(n,encodeURIComponent(o))}return this.injectIntoUrl(s,t,e)},injectIntoUrl(s,e,t){const i=s.indexOf(e);if(i===-1)throw new Error(`${e} parameter not found in the URL: ${s}`);const r=s.indexOf("&",i),n=e.length,o=r!==-1?r:s.length,a=s.substring(0,i+n),l=s.substring(i+n,o),c=s.substring(r),h=l+t;return a+h+c}};async function Vn(...s){const e=await fetch(...s);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class $c{constructor({baseUrl:e,clientId:t}){this.baseUrl=e,this.clientId=t}async get({headers:e,signal:t,cache:i,...r}){const n=this.createUrl(r);return(await Vn(n,{method:"GET",headers:e,signal:t,cache:i})).json()}async getBlob({headers:e,signal:t,...i}){const r=this.createUrl(i);return(await Vn(r,{method:"GET",headers:e,signal:t})).blob()}async post({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await Vn(n,{method:"POST",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}async put({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await Vn(n,{method:"PUT",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}async delete({body:e,headers:t,signal:i,...r}){const n=this.createUrl(r);return(await Vn(n,{method:"DELETE",headers:t,body:e?JSON.stringify(e):void 0,signal:i})).json()}createUrl({path:e,params:t}){const i=new URL(e,this.baseUrl);return t&&Object.entries(t).forEach(([r,n])=>{n&&i.searchParams.append(r,n)}),this.clientId&&i.searchParams.append("clientId",this.clientId),i}}const iO={handleSolanaDeeplinkRedirect(s){if(I.state.activeChain===Z.CHAIN.SOLANA){const e=window.location.href,t=encodeURIComponent(e);if(s==="Phantom"&&!("phantom"in window)){const i=e.startsWith("https")?"https":"http",r=e.split("/")[2],n=encodeURIComponent(`${i}://${r}`);window.location.href=`https://phantom.app/ul/browse/${t}?ref=${n}`}s==="Coinbase Wallet"&&!("coinbaseSolana"in window)&&(window.location.href=`https://go.cb-w.com/dapp?cb_url=${t}`)}}},es=Ke({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),bs={state:es,subscribeNetworkImages(s){return Lt(es.networkImages,()=>s(es.networkImages))},subscribeKey(s,e){return Xt(es,s,e)},subscribe(s){return Lt(es,()=>s(es))},setWalletImage(s,e){es.walletImages[s]=e},setNetworkImage(s,e){es.networkImages[s]=e},setChainImage(s,e){es.chainImages[s]=e},setConnectorImage(s,e){es.connectorImages={...es.connectorImages,[s]:e}},setTokenImage(s,e){es.tokenImages[s]=e},setCurrencyImage(s,e){es.currencyImages[s]=e}},rO={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00"},cl=Ke({networkImagePromises:{}}),cu={async fetchWalletImage(s){if(s)return await ne._fetchWalletImage(s),this.getWalletImageById(s)},async fetchNetworkImage(s){if(!s)return;const e=this.getNetworkImageById(s);return e||(cl.networkImagePromises[s]||(cl.networkImagePromises[s]=ne._fetchNetworkImage(s)),await cl.networkImagePromises[s],this.getNetworkImageById(s))},getWalletImageById(s){if(s)return bs.state.walletImages[s]},getWalletImage(s){if(s!=null&&s.image_url)return s==null?void 0:s.image_url;if(s!=null&&s.image_id)return bs.state.walletImages[s.image_id]},getNetworkImage(s){var e,t,i;if((e=s==null?void 0:s.assets)!=null&&e.imageUrl)return(t=s==null?void 0:s.assets)==null?void 0:t.imageUrl;if((i=s==null?void 0:s.assets)!=null&&i.imageId)return bs.state.networkImages[s.assets.imageId]},getNetworkImageById(s){if(s)return bs.state.networkImages[s]},getConnectorImage(s){if(s!=null&&s.imageUrl)return s.imageUrl;if(s!=null&&s.imageId)return bs.state.connectorImages[s.imageId]},getChainImage(s){return bs.state.networkImages[rO[s]]}},nO={getFeatureValue(s,e){const t=e==null?void 0:e[s];return t===void 0?qt.DEFAULT_FEATURES[s]:t},filterSocialsByPlatform(s){if(!s||!s.length)return s;if(re.isTelegram()){if(re.isIos())return s.filter(e=>e!=="google");if(re.isMac())return s.filter(e=>e!=="x");if(re.isAndroid())return s.filter(e=>!["facebook","x"].includes(e))}return s}},X=Ke({features:qt.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:qt.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0}),k={state:X,subscribeKey(s,e){return Xt(X,s,e)},setOptions(s){Object.assign(X,s)},setFeatures(s){if(!s)return;X.features||(X.features=qt.DEFAULT_FEATURES);const e={...X.features,...s};X.features=e,X.features.socials&&(X.features.socials=nO.filterSocialsByPlatform(X.features.socials))},setProjectId(s){X.projectId=s},setCustomRpcUrls(s){X.customRpcUrls=s},setAllWallets(s){X.allWallets=s},setIncludeWalletIds(s){X.includeWalletIds=s},setExcludeWalletIds(s){X.excludeWalletIds=s},setFeaturedWalletIds(s){X.featuredWalletIds=s},setTokens(s){X.tokens=s},setTermsConditionsUrl(s){X.termsConditionsUrl=s},setPrivacyPolicyUrl(s){X.privacyPolicyUrl=s},setCustomWallets(s){X.customWallets=s},setIsSiweEnabled(s){X.isSiweEnabled=s},setIsUniversalProvider(s){X.isUniversalProvider=s},setSdkVersion(s){X.sdkVersion=s},setMetadata(s){X.metadata=s},setDisableAppend(s){X.disableAppend=s},setEIP6963Enabled(s){X.enableEIP6963=s},setDebug(s){X.debug=s},setEnableWalletConnect(s){X.enableWalletConnect=s},setEnableWalletGuide(s){X.enableWalletGuide=s},setEnableAuthLogger(s){X.enableAuthLogger=s},setEnableWallets(s){X.enableWallets=s},setHasMultipleAddresses(s){X.hasMultipleAddresses=s},setSIWX(s){X.siwx=s},setConnectMethodsOrder(s){X.features={...X.features,connectMethodsOrder:s}},setWalletFeaturesOrder(s){X.features={...X.features,walletFeaturesOrder:s}},setSocialsOrder(s){X.features={...X.features,socials:s}},setCollapseWallets(s){X.features={...X.features,collapseWallets:s}},setEnableEmbedded(s){X.enableEmbedded=s},setAllowUnsupportedChain(s){X.allowUnsupportedChain=s},setManualWCControl(s){X.manualWCControl=s},setEnableNetworkSwitch(s){X.enableNetworkSwitch=s},setDefaultAccountTypes(s={}){Object.entries(s).forEach(([e,t])=>{t&&(X.defaultAccountTypes[e]=t)})},setUniversalProviderConfigOverride(s){X.universalProviderConfigOverride=s},getUniversalProviderConfigOverride(){return X.universalProviderConfigOverride},getSnapshot(){return Mo(X)}},li=Ke({message:"",variant:"info",open:!1}),fo={state:li,subscribeKey(s,e){return Xt(li,s,e)},open(s,e){const{debug:t}=k.state,{shortMessage:i,longMessage:r}=s;t&&(li.message=i,li.variant=e,li.open=!0),r&&console.error(typeof r=="function"?r():r)},close(){li.open=!1,li.message="",li.variant="info"}},oO=re.getAnalyticsUrl(),aO=new $c({baseUrl:oO,clientId:null}),cO=["MODAL_CREATED"],Ys=Ke({timestamp:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"}}),je={state:Ys,subscribe(s){return Lt(Ys,()=>s(Ys))},getSdkProperties(){const{projectId:s,sdkType:e,sdkVersion:t}=k.state;return{projectId:s,st:e,sv:t||"html-wagmi-4.2.2"}},async _sendAnalyticsEvent(s){try{const e=J.state.address;if(cO.includes(s.data.event)||typeof window>"u")return;await aO.post({path:"/e",params:je.getSdkProperties(),body:{eventId:re.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:s.timestamp,props:{...s.data,address:e}}}),Ys.reportedErrors.FORBIDDEN=!1}catch(e){e instanceof Error&&e.cause instanceof Response&&e.cause.status===Z.HTTP_STATUS_CODES.FORBIDDEN&&!Ys.reportedErrors.FORBIDDEN&&(fo.open({shortMessage:"Invalid App Configuration",longMessage:`Origin ${oo()?window.origin:"uknown"} not found on Allowlist - update configuration on cloud.reown.com`},"error"),Ys.reportedErrors.FORBIDDEN=!0)}},sendEvent(s){var e;Ys.timestamp=Date.now(),Ys.data=s,(e=k.state.features)!=null&&e.analytics&&je._sendAnalyticsEvent(Ys)}},lO=re.getApiUrl(),Dt=new $c({baseUrl:lO,clientId:null}),hO="40",Tp="4",uO=20,Ce=Ke({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1}),ne={state:Ce,subscribeKey(s,e){return Xt(Ce,s,e)},_getSdkProperties(){const{projectId:s,sdkType:e,sdkVersion:t}=k.state;return{projectId:s,st:e||"appkit",sv:t||"html-wagmi-4.2.2"}},_filterOutExtensions(s){return k.state.isUniversalProvider?s.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):s},async _fetchWalletImage(s){const e=`${Dt.baseUrl}/getWalletImage/${s}`,t=await Dt.getBlob({path:e,params:ne._getSdkProperties()});bs.setWalletImage(s,URL.createObjectURL(t))},async _fetchNetworkImage(s){const e=`${Dt.baseUrl}/public/getAssetImage/${s}`,t=await Dt.getBlob({path:e,params:ne._getSdkProperties()});bs.setNetworkImage(s,URL.createObjectURL(t))},async _fetchConnectorImage(s){const e=`${Dt.baseUrl}/public/getAssetImage/${s}`,t=await Dt.getBlob({path:e,params:ne._getSdkProperties()});bs.setConnectorImage(s,URL.createObjectURL(t))},async _fetchCurrencyImage(s){const e=`${Dt.baseUrl}/public/getCurrencyImage/${s}`,t=await Dt.getBlob({path:e,params:ne._getSdkProperties()});bs.setCurrencyImage(s,URL.createObjectURL(t))},async _fetchTokenImage(s){const e=`${Dt.baseUrl}/public/getTokenImage/${s}`,t=await Dt.getBlob({path:e,params:ne._getSdkProperties()});bs.setTokenImage(s,URL.createObjectURL(t))},async fetchNetworkImages(){const s=I.getAllRequestedCaipNetworks(),e=s==null?void 0:s.map(({assets:t})=>t==null?void 0:t.imageId).filter(Boolean).filter(t=>!cu.getNetworkImageById(t));e&&await Promise.allSettled(e.map(t=>ne._fetchNetworkImage(t)))},async fetchConnectorImages(){const{connectors:s}=ie.state,e=s.map(({imageId:t})=>t).filter(Boolean);await Promise.allSettled(e.map(t=>ne._fetchConnectorImage(t)))},async fetchCurrencyImages(s=[]){await Promise.allSettled(s.map(e=>ne._fetchCurrencyImage(e)))},async fetchTokenImages(s=[]){await Promise.allSettled(s.map(e=>ne._fetchTokenImage(e)))},async fetchFeaturedWallets(){const{featuredWalletIds:s}=k.state;if(s!=null&&s.length){const{data:e}=await Dt.get({path:"/getWallets",params:{...ne._getSdkProperties(),page:"1",entries:s!=null&&s.length?String(s.length):Tp,include:s==null?void 0:s.join(",")}});e.sort((i,r)=>s.indexOf(i.id)-s.indexOf(r.id));const t=e.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(t.map(i=>ne._fetchWalletImage(i))),Ce.featured=e,Ce.allFeatured=e}},async fetchRecommendedWallets(){try{Ce.isFetchingRecommendedWallets=!0;const{includeWalletIds:s,excludeWalletIds:e,featuredWalletIds:t}=k.state,i=[...e??[],...t??[]].filter(Boolean),r=I.getRequestedCaipNetworkIds().join(","),{data:n,count:o}=await Dt.get({path:"/getWallets",params:{...ne._getSdkProperties(),page:"1",chains:r,entries:Tp,include:s==null?void 0:s.join(","),exclude:i==null?void 0:i.join(",")}}),a=Y.getRecentWallets(),l=n.map(h=>h.image_id).filter(Boolean),c=a.map(h=>h.image_id).filter(Boolean);await Promise.allSettled([...l,...c].map(h=>ne._fetchWalletImage(h))),Ce.recommended=n,Ce.allRecommended=n,Ce.count=o??0}catch{}finally{Ce.isFetchingRecommendedWallets=!1}},async fetchWallets({page:s}){const{includeWalletIds:e,excludeWalletIds:t,featuredWalletIds:i}=k.state,r=I.getRequestedCaipNetworkIds().join(","),n=[...Ce.recommended.map(({id:c})=>c),...t??[],...i??[]].filter(Boolean),{data:o,count:a}=await Dt.get({path:"/getWallets",params:{...ne._getSdkProperties(),page:String(s),entries:hO,chains:r,include:e==null?void 0:e.join(","),exclude:n.join(",")}}),l=o.slice(0,uO).map(c=>c.image_id).filter(Boolean);await Promise.allSettled(l.map(c=>ne._fetchWalletImage(c))),Ce.wallets=re.uniqueBy([...Ce.wallets,...ne._filterOutExtensions(o)],"id"),Ce.count=a>Ce.count?a:Ce.count,Ce.page=s},async initializeExcludedWallets({ids:s}){const e=I.getRequestedCaipNetworkIds().join(","),{data:t}=await Dt.get({path:"/getWallets",params:{...ne._getSdkProperties(),page:"1",entries:String(s.length),chains:e,include:s==null?void 0:s.join(",")}});t&&t.forEach(i=>{i!=null&&i.rdns&&Ce.excludedWallets.push({rdns:i.rdns,name:i.name})})},async searchWallet({search:s,badge:e}){const{includeWalletIds:t,excludeWalletIds:i}=k.state;Ce.search=[];const r=I.getRequestedCaipNetworkIds().join(","),{data:n}=await Dt.get({path:"/getWallets",params:{...ne._getSdkProperties(),page:"1",entries:"100",search:s==null?void 0:s.trim(),badge_type:e,chains:r,include:t==null?void 0:t.join(","),exclude:i==null?void 0:i.join(",")}});je.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:s??""}});const o=n.map(a=>a.image_id).filter(Boolean);await Promise.allSettled([...o.map(a=>ne._fetchWalletImage(a)),re.wait(300)]),Ce.search=ne._filterOutExtensions(n)},initPromise(s,e){const t=Ce.promises[s];return t||(Ce.promises[s]=e())},prefetch({fetchConnectorImages:s=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:t=!0,fetchNetworkImages:i=!0}={}){const r=[s&&ne.initPromise("connectorImages",ne.fetchConnectorImages),e&&ne.initPromise("featuredWallets",ne.fetchFeaturedWallets),t&&ne.initPromise("recommendedWallets",ne.fetchRecommendedWallets),i&&ne.initPromise("networkImages",ne.fetchNetworkImages)].filter(Boolean);return Promise.allSettled(r)},prefetchAnalyticsConfig(){var s;(s=k.state.features)!=null&&s.analytics&&ne.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:s}=await Dt.get({path:"/getAnalyticsConfig",params:ne._getSdkProperties()});k.setFeatures({analytics:s})}catch{k.setFeatures({analytics:!1})}},setFilterByNamespace(s){if(!s){Ce.featured=Ce.allFeatured,Ce.recommended=Ce.allRecommended;return}const e=I.getRequestedCaipNetworkIds().join(",");Ce.featured=Ce.allFeatured.filter(t=>{var i;return(i=t.chains)==null?void 0:i.some(r=>e.includes(r))}),Ce.recommended=Ce.allRecommended.filter(t=>{var i;return(i=t.chains)==null?void 0:i.some(r=>e.includes(r))})}},Ee=Ke({view:"Connect",history:["Connect"],transactionStack:[]}),_e={state:Ee,subscribeKey(s,e){return Xt(Ee,s,e)},pushTransactionStack(s){Ee.transactionStack.push(s)},popTransactionStack(s){var t,i;const e=Ee.transactionStack.pop();if(e)if(s)this.goBack(),(t=e==null?void 0:e.onCancel)==null||t.call(e);else{if(e.goBack)this.goBack();else if(e.replace){const n=Ee.history.indexOf("ConnectingSiwe");n>0?this.goBackToIndex(n-1):(et.close(),Ee.history=[])}else e.view&&this.reset(e.view);(i=e==null?void 0:e.onSuccess)==null||i.call(e)}},push(s,e){s!==Ee.view&&(Ee.view=s,Ee.history.push(s),Ee.data=e)},reset(s,e){Ee.view=s,Ee.history=[s],Ee.data=e},replace(s,e){Ee.history.at(-1)===s||(Ee.view=s,Ee.history[Ee.history.length-1]=s,Ee.data=e)},goBack(){var e;const s=!I.state.activeCaipAddress&&this.state.view==="ConnectingFarcaster";if(Ee.history.length>1&&!Ee.history.includes("UnsupportedChain")){Ee.history.pop();const[t]=Ee.history.slice(-1);t&&(Ee.view=t)}else et.close();(e=Ee.data)!=null&&e.wallet&&(Ee.data.wallet=void 0),setTimeout(()=>{var t,i,r;if(s){J.setFarcasterUrl(void 0,I.state.activeChain);const n=ie.getAuthConnector();(t=n==null?void 0:n.provider)==null||t.reload();const o=Mo(k.state);(r=(i=n==null?void 0:n.provider)==null?void 0:i.syncDappData)==null||r.call(i,{metadata:o.metadata,sdkVersion:o.sdkVersion,projectId:o.projectId,sdkType:o.sdkType})}},100)},goBackToIndex(s){if(Ee.history.length>1){Ee.history=Ee.history.slice(0,s+1);const[e]=Ee.history.slice(-1);e&&(Ee.view=e)}}},Qs=Ke({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),jt={state:Qs,subscribe(s){return Lt(Qs,()=>s(Qs))},setThemeMode(s){Qs.themeMode=s;try{const e=ie.getAuthConnector();if(e){const t=jt.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:s,themeVariables:t,w3mThemeVariables:Ei(t,s)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(s){Qs.themeVariables={...Qs.themeVariables,...s};try{const e=ie.getAuthConnector();if(e){const t=jt.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:t,w3mThemeVariables:Ei(Qs.themeVariables,Qs.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Mo(Qs)}},Mw={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0},Se=Ke({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:{...Mw}}),ie={state:Se,subscribe(s){return Lt(Se,()=>{s(Se)})},subscribeKey(s,e){return Xt(Se,s,e)},initialize(s){s.forEach(e=>{const t=Y.getConnectedConnectorId(e);t&&this.setConnectorId(t,e)})},setActiveConnector(s){s&&(Se.activeConnector=nr(s))},setConnectors(s){s.filter(t=>!Se.allConnectors.some(i=>i.id===t.id&&this.getConnectorName(i.name)===this.getConnectorName(t.name)&&i.chain===t.chain)).forEach(t=>{t.type!=="MULTI_CHAIN"&&Se.allConnectors.push(nr(t))}),Se.connectors=this.mergeMultiChainConnectors(Se.allConnectors)},removeAdapter(s){Se.allConnectors=Se.allConnectors.filter(e=>e.chain!==s),Se.connectors=this.mergeMultiChainConnectors(Se.allConnectors)},mergeMultiChainConnectors(s){const e=this.generateConnectorMapByName(s),t=[];return e.forEach(i=>{const r=i[0],n=(r==null?void 0:r.id)===Z.CONNECTOR_ID.AUTH;i.length>1&&r?t.push({name:r.name,imageUrl:r.imageUrl,imageId:r.imageId,connectors:[...i],type:n?"AUTH":"MULTI_CHAIN",chain:"eip155",id:(r==null?void 0:r.id)||""}):r&&t.push(r)}),t},generateConnectorMapByName(s){const e=new Map;return s.forEach(t=>{const{name:i}=t,r=this.getConnectorName(i);if(!r)return;const n=e.get(r)||[];n.find(a=>a.chain===t.chain)||n.push(t),e.set(r,n)}),e},getConnectorName(s){return s&&({"Trust Wallet":"Trust"}[s]||s)},getUniqueConnectorsByName(s){const e=[];return s.forEach(t=>{e.find(i=>i.chain===t.chain)||e.push(t)}),e},addConnector(s){var e,t,i;if(s.id===Z.CONNECTOR_ID.AUTH){const r=s,n=Mo(k.state),o=jt.getSnapshot().themeMode,a=jt.getSnapshot().themeVariables;(t=(e=r==null?void 0:r.provider)==null?void 0:e.syncDappData)==null||t.call(e,{metadata:n.metadata,sdkVersion:n.sdkVersion,projectId:n.projectId,sdkType:n.sdkType}),(i=r==null?void 0:r.provider)==null||i.syncTheme({themeMode:o,themeVariables:a,w3mThemeVariables:Ei(a,o)}),this.setConnectors([s])}else this.setConnectors([s])},getAuthConnector(s){var i;const e=s||I.state.activeChain,t=Se.connectors.find(r=>r.id===Z.CONNECTOR_ID.AUTH);if(t)return(i=t==null?void 0:t.connectors)!=null&&i.length?t.connectors.find(n=>n.chain===e):t},getAnnouncedConnectorRdns(){return Se.connectors.filter(s=>s.type==="ANNOUNCED").map(s=>{var e;return(e=s.info)==null?void 0:e.rdns})},getConnectorById(s){return Se.allConnectors.find(e=>e.id===s)},getConnector(s,e){return Se.allConnectors.filter(i=>i.chain===I.state.activeChain).find(i=>{var r;return i.explorerId===s||((r=i.info)==null?void 0:r.rdns)===e})},syncIfAuthConnector(s){var n,o;if(s.id!=="ID_AUTH")return;const e=s,t=Mo(k.state),i=jt.getSnapshot().themeMode,r=jt.getSnapshot().themeVariables;(o=(n=e==null?void 0:e.provider)==null?void 0:n.syncDappData)==null||o.call(n,{metadata:t.metadata,sdkVersion:t.sdkVersion,sdkType:t.sdkType,projectId:t.projectId}),e.provider.syncTheme({themeMode:i,themeVariables:r,w3mThemeVariables:Ei(r,i)})},getConnectorsByNamespace(s){const e=Se.allConnectors.filter(t=>t.chain===s);return this.mergeMultiChainConnectors(e)},selectWalletConnector(s){const e=ie.getConnector(s.id,s.rdns);I.state.activeChain===Z.CHAIN.SOLANA&&iO.handleSolanaDeeplinkRedirect((e==null?void 0:e.name)||s.name||""),e?_e.push("ConnectingExternal",{connector:e}):_e.push("ConnectingWalletConnect",{wallet:s})},getConnectors(s){return s?this.getConnectorsByNamespace(s):this.mergeMultiChainConnectors(Se.allConnectors)},setFilterByNamespace(s){Se.filterByNamespace=s,Se.connectors=this.getConnectors(s),ne.setFilterByNamespace(s)},setConnectorId(s,e){s&&(Se.activeConnectorIds={...Se.activeConnectorIds,[e]:s},Y.setConnectedConnectorId(e,s))},removeConnectorId(s){Se.activeConnectorIds={...Se.activeConnectorIds,[s]:void 0},Y.deleteConnectedConnectorId(s)},getConnectorId(s){if(s)return Se.activeConnectorIds[s]},isConnected(s){return s?!!Se.activeConnectorIds[s]:Object.values(Se.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){Se.activeConnectorIds={...Mw}}};function ba(s,e){return ie.getConnectorId(s)===e}function dO(s){const e=Array.from(I.state.chains.keys());let t=[];return s?(t.push([s,I.state.chains.get(s)]),ba(s,Z.CONNECTOR_ID.WALLET_CONNECT)?e.forEach(i=>{i!==s&&ba(i,Z.CONNECTOR_ID.WALLET_CONNECT)&&t.push([i,I.state.chains.get(i)])}):ba(s,Z.CONNECTOR_ID.AUTH)&&e.forEach(i=>{i!==s&&ba(i,Z.CONNECTOR_ID.AUTH)&&t.push([i,I.state.chains.get(i)])})):t=Array.from(I.state.chains.entries()),t}var pO=Object.defineProperty,gO=(s,e,t)=>e in s?pO(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Mp=(s,e,t)=>gO(s,typeof e!="symbol"?e+"":e,t);let fO=class extends m.IEvents{constructor(e){super(),this.opts=e,Mp(this,"protocol","wc"),Mp(this,"version",2)}};var mO=Object.defineProperty,wO=(s,e,t)=>e in s?mO(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,yO=(s,e,t)=>wO(s,e+"",t);let bO=class extends m.IEvents{constructor(e,t){super(),this.core=e,this.logger=t,yO(this,"records",new Map)}},vO=class{constructor(e,t){this.logger=e,this.core=t}},IO=class extends m.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},EO=class extends m.IEvents{constructor(e){super()}},AO=class{constructor(e,t,i,r){this.core=e,this.logger=t,this.name=i}},NO=class extends m.IEvents{constructor(e,t){super(),this.relayer=e,this.logger=t}},_O=class extends m.IEvents{constructor(e,t){super(),this.core=e,this.logger=t}},CO=class{constructor(e,t,i){this.core=e,this.logger=t,this.store=i}},SO=class{constructor(e,t){this.projectId=e,this.logger=t}},$O=class{constructor(e,t,i){this.core=e,this.logger=t,this.telemetryEnabled=i}};var PO=Object.defineProperty,TO=(s,e,t)=>e in s?PO(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,xp=(s,e,t)=>TO(s,typeof e!="symbol"?e+"":e,t);let MO=class{constructor(e){this.opts=e,xp(this,"protocol","wc"),xp(this,"version",2)}},xO=class{constructor(e){this.client=e}};const OO="https://secure.walletconnect.org/sdk";typeof N.dist.process<"u"&&typeof N.dist.process.env<"u"&&N.dist.process.env.NEXT_PUBLIC_SECURE_SITE_SDK_URL;typeof N.dist.process<"u"&&typeof N.dist.process.env<"u"&&N.dist.process.env.NEXT_PUBLIC_DEFAULT_LOG_LEVEL;typeof N.dist.process<"u"&&typeof N.dist.process.env<"u"&&N.dist.process.env.NEXT_PUBLIC_SECURE_SITE_SDK_VERSION;const mi={SAFE_RPC_METHODS:["eth_accounts","eth_blockNumber","eth_call","eth_chainId","eth_estimateGas","eth_feeHistory","eth_gasPrice","eth_getAccount","eth_getBalance","eth_getBlockByHash","eth_getBlockByNumber","eth_getBlockReceipts","eth_getBlockTransactionCountByHash","eth_getBlockTransactionCountByNumber","eth_getCode","eth_getFilterChanges","eth_getFilterLogs","eth_getLogs","eth_getProof","eth_getStorageAt","eth_getTransactionByBlockHashAndIndex","eth_getTransactionByBlockNumberAndIndex","eth_getTransactionByHash","eth_getTransactionCount","eth_getTransactionReceipt","eth_getUncleCountByBlockHash","eth_getUncleCountByBlockNumber","eth_maxPriorityFeePerGas","eth_newBlockFilter","eth_newFilter","eth_newPendingTransactionFilter","eth_sendRawTransaction","eth_syncing","eth_uninstallFilter","wallet_getCapabilities","wallet_getCallsStatus","eth_getUserOperationReceipt","eth_estimateUserOperationGas","eth_getUserOperationByHash","eth_supportedEntryPoints","wallet_getAssets"],NOT_SAFE_RPC_METHODS:["personal_sign","eth_signTypedData_v4","eth_sendTransaction","solana_signMessage","solana_signTransaction","solana_signAllTransactions","solana_signAndSendTransaction","wallet_sendCalls","wallet_grantPermissions","wallet_revokePermissions","eth_sendUserOperation"],GET_CHAIN_ID:"eth_chainId",RPC_METHOD_NOT_ALLOWED_MESSAGE:"Requested RPC call is not allowed",RPC_METHOD_NOT_ALLOWED_UI_MESSAGE:"Action not allowed",ACCOUNT_TYPES:{EOA:"eoa",SMART_ACCOUNT:"smartAccount"}},qi=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),ot=Ke({...qi}),wt={state:ot,subscribeKey(s,e){return Xt(ot,s,e)},showLoading(s,e={}){this._showMessage({message:s,variant:"loading",...e})},showSuccess(s){this._showMessage({message:s,variant:"success"})},showSvg(s,e){this._showMessage({message:s,svg:e})},showError(s){const e=re.parseError(s);this._showMessage({message:e,variant:"error"})},hide(){ot.message=qi.message,ot.variant=qi.variant,ot.svg=qi.svg,ot.open=qi.open,ot.autoClose=qi.autoClose},_showMessage({message:s,svg:e,variant:t="success",autoClose:i=qi.autoClose}){ot.open?(ot.open=!1,setTimeout(()=>{ot.message=s,ot.variant=t,ot.svg=e,ot.open=!0,ot.autoClose=i},150)):(ot.message=s,ot.variant=t,ot.svg=e,ot.open=!0,ot.autoClose=i)}},fn={getSIWX(){return k.state.siwx},async initializeIfEnabled(){var n;const s=k.state.siwx,e=I.getActiveCaipAddress();if(!(s&&e))return;const[t,i,r]=e.split(":");if(I.checkIfSupportedNetwork(t))try{if((await s.getSessions(`${t}:${i}`,r)).length)return;await et.open({view:"SIWXSignMessage"})}catch(o){console.error("SIWXUtil:initializeIfEnabled",o),je.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties()}),await((n=ke._getClient())==null?void 0:n.disconnect().catch(console.error)),_e.reset("Connect"),wt.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const s=k.state.siwx,e=re.getPlainAddress(I.getActiveCaipAddress()),t=I.getActiveCaipNetwork(),i=ke._getClient();if(!s)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!t)throw new Error("No ActiveCaipNetwork or client found");if(!i)throw new Error("No ConnectionController client found");try{const r=await s.createMessage({chainId:t.caipNetworkId,accountAddress:e}),n=r.toString();ie.getConnectorId(t.chainNamespace)===Z.CONNECTOR_ID.AUTH&&_e.pushTransactionStack({view:null,goBack:!1,replace:!0});const a=await i.signMessage(n);await s.addSession({data:r,message:n,signature:a}),et.close(),je.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(r){const n=this.getSIWXEventProperties();(!et.state.open||_e.state.view==="ApproveTransaction")&&await et.open({view:"SIWXSignMessage"}),n.isSmartAccount?wt.showError("This application might not support Smart Accounts"):wt.showError("Signature declined"),je.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:n}),console.error("SWIXUtil:requestSignMessage",r)}},async cancelSignMessage(){var s;try{const e=this.getSIWX();((s=e==null?void 0:e.getRequired)==null?void 0:s.call(e))?await ke.disconnect():et.close(),_e.reset("Connect"),je.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(e){console.error("SIWXUtil:cancelSignMessage",e)}},async getSessions(){const s=k.state.siwx,e=re.getPlainAddress(I.getActiveCaipAddress()),t=I.getActiveCaipNetwork();return s&&e&&t?s.getSessions(t.caipNetworkId,e):[]},async isSIWXCloseDisabled(){var e;const s=this.getSIWX();if(s){const t=_e.state.view==="ApproveTransaction",i=_e.state.view==="SIWXSignMessage";if(t||i)return((e=s.getRequired)==null?void 0:e.call(s))&&(await this.getSessions()).length===0}return!1},async universalProviderAuthenticate({universalProvider:s,chains:e,methods:t}){var a,l,c;const i=fn.getSIWX(),r=new Set(e.map(h=>h.split(":")[0]));if(!i||r.size!==1||!r.has("eip155"))return!1;const n=await i.createMessage({chainId:((a=I.getActiveCaipNetwork())==null?void 0:a.caipNetworkId)||"",accountAddress:""}),o=await s.authenticate({nonce:n.nonce,domain:n.domain,uri:n.uri,exp:n.expirationTime,iat:n.issuedAt,nbf:n.notBefore,requestId:n.requestId,version:n.version,resources:n.resources,statement:n.statement,chainId:n.chainId,methods:t,chains:[n.chainId,...e.filter(h=>h!==n.chainId)]});if(wt.showLoading("Authenticating...",{autoClose:!1}),J.setConnectedWalletInfo({...o.session.peer.metadata,name:o.session.peer.metadata.name,icon:(l=o.session.peer.metadata.icons)==null?void 0:l[0],type:"WALLET_CONNECT"},Array.from(r)[0]),(c=o==null?void 0:o.auths)!=null&&c.length){const h=o.auths.map(u=>{const d=s.client.formatAuthMessage({request:u.p,iss:u.p.iss});return{data:{...u.p,accountAddress:u.p.iss.split(":").slice(-1).join(""),chainId:u.p.iss.split(":").slice(2,4).join(":"),uri:u.p.aud,version:u.p.version||n.version,expirationTime:u.p.exp,issuedAt:u.p.iat,notBefore:u.p.nbf},message:d,signature:u.s.s,cacao:u}});try{await i.setSessions(h),je.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:fn.getSIWXEventProperties()})}catch(u){throw console.error("SIWX:universalProviderAuth - failed to set sessions",u),je.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:fn.getSIWXEventProperties()}),await s.disconnect().catch(console.error),u}finally{wt.hide()}}return!0},getSIWXEventProperties(){var s;return{network:((s=I.state.activeCaipNetwork)==null?void 0:s.caipNetworkId)||"",isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT}},async clearSessions(){const s=this.getSIWX();s&&await s.setSessions([])}},Ue=Ke({transactions:[],coinbaseTransactions:{},transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),DO={state:Ue,subscribe(s){return Lt(Ue,()=>s(Ue))},setLastNetworkInView(s){Ue.lastNetworkInView=s},async fetchTransactions(s,e){var t;if(!s)throw new Error("Transactions can't be fetched without an accountAddress");Ue.loading=!0;try{const i=await ee.fetchTransactions({account:s,cursor:Ue.next,onramp:e,cache:e==="coinbase"?"no-cache":void 0,chainId:(t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId}),r=this.filterSpamTransactions(i.data),n=this.filterByConnectedChain(r),o=[...Ue.transactions,...n];Ue.loading=!1,e==="coinbase"?Ue.coinbaseTransactions=this.groupTransactionsByYearAndMonth(Ue.coinbaseTransactions,i.data):(Ue.transactions=o,Ue.transactionsByYear=this.groupTransactionsByYearAndMonth(Ue.transactionsByYear,n)),Ue.empty=o.length===0,Ue.next=i.next?i.next:void 0}catch{je.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:s,projectId:k.state.projectId,cursor:Ue.next,isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT}}),wt.showError("Failed to fetch transactions"),Ue.loading=!1,Ue.empty=!0,Ue.next=void 0}},groupTransactionsByYearAndMonth(s={},e=[]){const t=s;return e.forEach(i=>{const r=new Date(i.metadata.minedAt).getFullYear(),n=new Date(i.metadata.minedAt).getMonth(),o=t[r]??{},l=(o[n]??[]).filter(c=>c.id!==i.id);t[r]={...o,[n]:[...l,i].sort((c,h)=>new Date(h.metadata.minedAt).getTime()-new Date(c.metadata.minedAt).getTime())}}),t},filterSpamTransactions(s){return s.filter(e=>!e.transfers.every(i=>{var r;return((r=i.nft_info)==null?void 0:r.flags.is_spam)===!0}))},filterByConnectedChain(s){var i;const e=(i=I.state.activeCaipNetwork)==null?void 0:i.caipNetworkId;return s.filter(r=>r.metadata.chain===e)},clearCursor(){Ue.next=void 0},resetTransactions(){Ue.transactions=[],Ue.transactionsByYear={},Ue.lastNetworkInView=void 0,Ue.loading=!1,Ue.empty=!1,Ue.next=void 0}},Le=Ke({wcError:!1,buffering:!1,status:"disconnected"});let Rr;const ke={state:Le,subscribeKey(s,e){return Xt(Le,s,e)},_getClient(){return Le._client},setClient(s){Le._client=nr(s)},async connectWalletConnect(){var s,e,t,i;if(re.isTelegram()||re.isSafari()&&re.isIos()){if(Rr){await Rr,Rr=void 0;return}if(!re.isPairingExpired(Le==null?void 0:Le.wcPairingExpiry)){const r=Le.wcUri;Le.wcUri=r;return}Rr=(e=(s=this._getClient())==null?void 0:s.connectWalletConnect)==null?void 0:e.call(s).catch(()=>{}),this.state.status="connecting",await Rr,Rr=void 0,Le.wcPairingExpiry=void 0,this.state.status="connected"}else await((i=(t=this._getClient())==null?void 0:t.connectWalletConnect)==null?void 0:i.call(t))},async connectExternal(s,e,t=!0){var i,r;await((r=(i=this._getClient())==null?void 0:i.connectExternal)==null?void 0:r.call(i,s)),t&&I.setActiveNamespace(e)},async reconnectExternal(s){var t,i;await((i=(t=this._getClient())==null?void 0:t.reconnectExternal)==null?void 0:i.call(t,s));const e=s.chain||I.state.activeChain;e&&ie.setConnectorId(s.id,e)},async setPreferredAccountType(s){var t;et.setLoading(!0,I.state.activeChain);const e=ie.getAuthConnector();e&&(await(e==null?void 0:e.provider.setPreferredAccount(s)),await this.reconnectExternal(e),et.setLoading(!1,I.state.activeChain),je.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:s,network:((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)||""}}))},async signMessage(s){var e;return(e=this._getClient())==null?void 0:e.signMessage(s)},parseUnits(s,e){var t;return(t=this._getClient())==null?void 0:t.parseUnits(s,e)},formatUnits(s,e){var t;return(t=this._getClient())==null?void 0:t.formatUnits(s,e)},async sendTransaction(s){var e;return(e=this._getClient())==null?void 0:e.sendTransaction(s)},async getCapabilities(s){var e;return(e=this._getClient())==null?void 0:e.getCapabilities(s)},async grantPermissions(s){var e;return(e=this._getClient())==null?void 0:e.grantPermissions(s)},async walletGetAssets(s){var e;return((e=this._getClient())==null?void 0:e.walletGetAssets(s))??{}},async estimateGas(s){var e;return(e=this._getClient())==null?void 0:e.estimateGas(s)},async writeContract(s){var e;return(e=this._getClient())==null?void 0:e.writeContract(s)},async getEnsAddress(s){var e;return(e=this._getClient())==null?void 0:e.getEnsAddress(s)},async getEnsAvatar(s){var e;return(e=this._getClient())==null?void 0:e.getEnsAvatar(s)},checkInstalled(s){var e,t;return((t=(e=this._getClient())==null?void 0:e.checkInstalled)==null?void 0:t.call(e,s))||!1},resetWcConnection(){Le.wcUri=void 0,Le.wcPairingExpiry=void 0,Le.wcLinking=void 0,Le.recentWallet=void 0,Le.status="disconnected",DO.resetTransactions(),Y.deleteWalletConnectDeepLink()},resetUri(){Le.wcUri=void 0,Le.wcPairingExpiry=void 0},finalizeWcConnection(){var t,i;const{wcLinking:s,recentWallet:e}=ke.state;s&&Y.setWalletConnectDeepLink(s),e&&Y.setAppKitRecent(e),je.sendEvent({type:"track",event:"CONNECT_SUCCESS",properties:{method:s?"mobile":"qrcode",name:((i=(t=_e.state.data)==null?void 0:t.wallet)==null?void 0:i.name)||"Unknown"}})},setWcBasic(s){Le.wcBasic=s},setUri(s){Le.wcUri=s,Le.wcPairingExpiry=re.getPairingExpiry()},setWcLinking(s){Le.wcLinking=s},setWcError(s){Le.wcError=s,Le.buffering=!1},setRecentWallet(s){Le.recentWallet=s},setBuffering(s){Le.buffering=s},setStatus(s){Le.status=s},async disconnect(s){try{et.setLoading(!0,s),await fn.clearSessions(),await I.disconnect(s),et.setLoading(!1,s),ie.setFilterByNamespace(void 0)}catch{throw new Error("Failed to disconnect")}}},Kn=Ke({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),ri={state:Kn,subscribe(s){return Lt(Kn,()=>s(Kn))},set(s){Object.assign(Kn,{...Kn,...s})}},ll={createBalance(s,e){const t={name:s.metadata.name||"",symbol:s.metadata.symbol||"",decimals:s.metadata.decimals||0,value:s.metadata.value||0,price:s.metadata.price||0,iconUrl:s.metadata.iconUrl||""};return{name:t.name,symbol:t.symbol,chainId:e,address:s.address==="native"?void 0:this.convertAddressToCAIP10Address(s.address,e),value:t.value,price:t.price,quantity:{decimals:t.decimals.toString(),numeric:this.convertHexToBalance({hex:s.balance,decimals:t.decimals})},iconUrl:t.iconUrl}},convertHexToBalance({hex:s,decimals:e}){return E.formatUnits(BigInt(s),e)},convertAddressToCAIP10Address(s,e){return`${e}:${s}`},createCAIP2ChainId(s,e){return`${e}:${parseInt(s,16)}`},getChainIdHexFromCAIP2ChainId(s){const e=s.split(":");if(e.length<2||!e[1])return"0x0";const t=e[1],i=parseInt(t,10);return isNaN(i)?"0x0":`0x${i.toString(16)}`},isWalletGetAssetsResponse(s){return typeof s!="object"||s===null?!1:Object.values(s).every(e=>Array.isArray(e)&&e.every(t=>this.isValidAsset(t)))},isValidAsset(s){return typeof s=="object"&&s!==null&&typeof s.address=="string"&&typeof s.balance=="string"&&(s.type==="ERC20"||s.type==="NATIVE")&&typeof s.metadata=="object"&&s.metadata!==null&&typeof s.metadata.name=="string"&&typeof s.metadata.symbol=="string"&&typeof s.metadata.decimals=="number"&&typeof s.metadata.price=="number"&&typeof s.metadata.iconUrl=="string"}},Op={async getMyTokensWithBalance(s){const e=J.state.address,t=I.state.activeCaipNetwork;if(!e||!t)return[];if(t.chainNamespace==="eip155"){const r=await this.getEIP155Balances(e,t);if(r)return this.filterLowQualityTokens(r)}const i=await ee.getBalance(e,t.caipNetworkId,s);return this.filterLowQualityTokens(i.balances)},async getEIP155Balances(s,e){var t,i;try{const r=ll.getChainIdHexFromCAIP2ChainId(e.caipNetworkId),n=await ke.getCapabilities(s);if(!((i=(t=n==null?void 0:n[r])==null?void 0:t.assetDiscovery)!=null&&i.supported))return null;const o=await ke.walletGetAssets({account:s,chainFilter:[r]});return ll.isWalletGetAssetsResponse(o)?(o[r]||[]).map(l=>ll.createBalance(l,e.caipNetworkId)):null}catch{return null}},filterLowQualityTokens(s){return s.filter(e=>e.quantity.decimals!=="0")},mapBalancesToSwapTokens(s){return(s==null?void 0:s.map(e=>({...e,address:e!=null&&e.address?e.address:I.getActiveNetworkTokenAddress(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1})))||[]}},pe=Ke({tokenBalances:[],loading:!1}),Dp={state:pe,subscribe(s){return Lt(pe,()=>s(pe))},subscribeKey(s,e){return Xt(pe,s,e)},setToken(s){s&&(pe.token=nr(s))},setTokenAmount(s){pe.sendTokenAmount=s},setReceiverAddress(s){pe.receiverAddress=s},setReceiverProfileImageUrl(s){pe.receiverProfileImageUrl=s},setReceiverProfileName(s){pe.receiverProfileName=s},setGasPrice(s){pe.gasPrice=s},setGasPriceInUsd(s){pe.gasPriceInUSD=s},setNetworkBalanceInUsd(s){pe.networkBalanceInUSD=s},setLoading(s){pe.loading=s},sendToken(){var s;switch((s=I.state.activeCaipNetwork)==null?void 0:s.chainNamespace){case"eip155":this.sendEvmToken();return;case"solana":this.sendSolanaToken();return;default:throw new Error("Unsupported chain")}},sendEvmToken(){var s,e,t,i,r;(s=this.state.token)!=null&&s.address&&this.state.sendTokenAmount&&this.state.receiverAddress?(je.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT,token:this.state.token.address,amount:this.state.sendTokenAmount,network:((e=I.state.activeCaipNetwork)==null?void 0:e.caipNetworkId)||""}}),this.sendERC20Token({receiverAddress:this.state.receiverAddress,tokenAddress:this.state.token.address,sendTokenAmount:this.state.sendTokenAmount,decimals:this.state.token.quantity.decimals})):this.state.receiverAddress&&this.state.sendTokenAmount&&this.state.gasPrice&&((t=this.state.token)!=null&&t.quantity.decimals)&&(je.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT,token:(i=this.state.token)==null?void 0:i.symbol,amount:this.state.sendTokenAmount,network:((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)||""}}),this.sendNativeToken({receiverAddress:this.state.receiverAddress,sendTokenAmount:this.state.sendTokenAmount,gasPrice:this.state.gasPrice,decimals:this.state.token.quantity.decimals}))},async fetchTokenBalance(s){var n,o;pe.loading=!0;const e=(n=I.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,t=(o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace,i=I.state.activeCaipAddress,r=i?re.getPlainAddress(i):void 0;if(pe.lastRetry&&!re.isAllowedRetry(pe.lastRetry,30*qt.ONE_SEC_MS))return pe.loading=!1,[];try{if(r&&e&&t){const a=await Op.getMyTokensWithBalance();return pe.tokenBalances=a,pe.lastRetry=void 0,a}}catch(a){pe.lastRetry=Date.now(),s==null||s(a),wt.showError("Token Balance Unavailable")}finally{pe.loading=!1}return[]},fetchNetworkBalance(){if(pe.tokenBalances.length===0)return;const s=Op.mapBalancesToSwapTokens(pe.tokenBalances);if(!s)return;const e=s.find(t=>t.address===I.getActiveNetworkTokenAddress());e&&(pe.networkBalanceInUSD=e?ya.multiply(e.quantity.numeric,e.price).toString():"0")},isInsufficientNetworkTokenForGas(s,e){const t=e||"0";return ya.bigNumber(s).eq(0)?!0:ya.bigNumber(ya.bigNumber(t)).gt(s)},hasInsufficientGasFunds(){let s=!0;return J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT?s=!1:pe.networkBalanceInUSD&&(s=this.isInsufficientNetworkTokenForGas(pe.networkBalanceInUSD,pe.gasPriceInUSD)),s},async sendNativeToken(s){var n,o,a,l;_e.pushTransactionStack({view:"Account",goBack:!1});const e=s.receiverAddress,t=J.state.address,i=ke.parseUnits(s.sendTokenAmount.toString(),Number(s.decimals)),r="0x";try{await ke.sendTransaction({chainNamespace:"eip155",to:e,address:t,data:r,value:i??BigInt(0),gasPrice:s.gasPrice}),wt.showSuccess("Transaction started"),je.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT,token:((n=this.state.token)==null?void 0:n.symbol)||"",amount:s.sendTokenAmount,network:((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)||""}}),this.resetSend()}catch(c){console.error("SendController:sendERC20Token - failed to send native token",c);const h=c instanceof Error?c.message:"Unknown error";je.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:h,isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT,token:((a=this.state.token)==null?void 0:a.symbol)||"",amount:s.sendTokenAmount,network:((l=I.state.activeCaipNetwork)==null?void 0:l.caipNetworkId)||""}}),wt.showError("Something went wrong")}},async sendERC20Token(s){var t,i;_e.pushTransactionStack({view:"Account",goBack:!1});const e=ke.parseUnits(s.sendTokenAmount.toString(),Number(s.decimals));try{if(J.state.address&&s.sendTokenAmount&&s.receiverAddress&&s.tokenAddress){const r=re.getPlainAddress(s.tokenAddress);await ke.writeContract({fromAddress:J.state.address,tokenAddress:r,args:[s.receiverAddress,e??BigInt(0)],method:"transfer",abi:Qx.getERC20Abi(r),chainNamespace:"eip155"}),wt.showSuccess("Transaction started"),this.resetSend()}}catch(r){console.error("SendController:sendERC20Token - failed to send erc20 token",r);const n=r instanceof Error?r.message:"Unknown error";je.sendEvent({type:"track",event:"SEND_ERROR",properties:{message:n,isSmartAccount:J.state.preferredAccountType===mi.ACCOUNT_TYPES.SMART_ACCOUNT,token:((t=this.state.token)==null?void 0:t.symbol)||"",amount:s.sendTokenAmount,network:((i=I.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)||""}}),wt.showError("Something went wrong")}},sendSolanaToken(){if(!this.state.sendTokenAmount||!this.state.receiverAddress){wt.showError("Please enter a valid amount and receiver address");return}_e.pushTransactionStack({view:"Account",goBack:!1}),ke.sendTransaction({chainNamespace:"solana",to:this.state.receiverAddress,value:this.state.sendTokenAmount}).then(()=>{this.resetSend(),J.fetchTokenBalance()}).catch(s=>{wt.showError("Failed to send transaction. Please try again."),console.error("SendController:sendToken - failed to send solana transaction",s)})},resetSend(){pe.token=void 0,pe.sendTokenAmount=void 0,pe.receiverAddress=void 0,pe.receiverProfileImageUrl=void 0,pe.receiverProfileName=void 0,pe.loading=!1,pe.tokenBalances=[]}},hl={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[],user:void 0},va={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},q=Ke({chains:sO(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),I={state:q,subscribe(s){return Lt(q,()=>{s(q)})},subscribeKey(s,e){return Xt(q,s,e)},subscribeChainProp(s,e,t){let i;return Lt(q.chains,()=>{var n;const r=t||q.activeChain;if(r){const o=(n=q.chains.get(r))==null?void 0:n[s];i!==o&&(i=o,e(o))}})},initialize(s,e,t){const{chainId:i,namespace:r}=Y.getActiveNetworkProps(),n=e==null?void 0:e.find(c=>c.id.toString()===(i==null?void 0:i.toString())),a=s.find(c=>(c==null?void 0:c.namespace)===r)||(s==null?void 0:s[0]),l=new Set([...(e==null?void 0:e.map(c=>c.chainNamespace))??[]]);((s==null?void 0:s.length)===0||!a)&&(q.noAdapters=!0),q.noAdapters||(q.activeChain=a==null?void 0:a.namespace,q.activeCaipNetwork=n,this.setChainNetworkData(a==null?void 0:a.namespace,{caipNetwork:n}),q.activeChain&&ri.set({activeChain:a==null?void 0:a.namespace})),l.forEach(c=>{const h=e==null?void 0:e.filter(u=>u.chainNamespace===c);I.state.chains.set(c,{namespace:c,networkState:Ke({...va,caipNetwork:h==null?void 0:h[0]}),accountState:Ke(hl),caipNetworks:h??[],...t}),this.setRequestedCaipNetworks(h??[],c)})},removeAdapter(s){var e,t;if(q.activeChain===s){const i=Array.from(q.chains.entries()).find(([r])=>r!==s);if(i){const r=(t=(e=i[1])==null?void 0:e.caipNetworks)==null?void 0:t[0];r&&this.setActiveCaipNetwork(r)}}q.chains.delete(s)},addAdapter(s,{networkControllerClient:e,connectionControllerClient:t},i){q.chains.set(s.namespace,{namespace:s.namespace,networkState:{...va,caipNetwork:i[0]},accountState:hl,caipNetworks:i,connectionControllerClient:t,networkControllerClient:e}),this.setRequestedCaipNetworks((i==null?void 0:i.filter(r=>r.chainNamespace===s.namespace))??[],s.namespace)},addNetwork(s){var t;const e=q.chains.get(s.chainNamespace);if(e){const i=[...e.caipNetworks||[]];(t=e.caipNetworks)!=null&&t.find(r=>r.id===s.id)||i.push(s),q.chains.set(s.chainNamespace,{...e,caipNetworks:i}),this.setRequestedCaipNetworks(i,s.chainNamespace)}},removeNetwork(s,e){var i,r,n;const t=q.chains.get(s);if(t){const o=((i=q.activeCaipNetwork)==null?void 0:i.id)===e,a=[...((r=t.caipNetworks)==null?void 0:r.filter(l=>l.id!==e))||[]];o&&((n=t==null?void 0:t.caipNetworks)!=null&&n[0])&&this.setActiveCaipNetwork(t.caipNetworks[0]),q.chains.set(s,{...t,caipNetworks:a}),this.setRequestedCaipNetworks(a||[],s)}},setAdapterNetworkState(s,e){const t=q.chains.get(s);t&&(t.networkState={...t.networkState||va,...e},q.chains.set(s,t))},setChainAccountData(s,e,t=!0){if(!s)throw new Error("Chain is required to update chain account data");const i=q.chains.get(s);if(i){const r={...i.accountState||hl,...e};q.chains.set(s,{...i,accountState:r}),(q.chains.size===1||q.activeChain===s)&&(e.caipAddress&&(q.activeCaipAddress=e.caipAddress),J.replaceState(r))}},setChainNetworkData(s,e){if(!s)return;const t=q.chains.get(s);if(t){const i={...t.networkState||va,...e};q.chains.set(s,{...t,networkState:i})}},setAccountProp(s,e,t,i=!0){this.setChainAccountData(t,{[s]:e},i),s==="status"&&e==="disconnected"&&t&&ie.removeConnectorId(t)},setActiveNamespace(s){var i,r;q.activeChain=s;const e=s?q.chains.get(s):void 0,t=(i=e==null?void 0:e.networkState)==null?void 0:i.caipNetwork;t!=null&&t.id&&s&&(q.activeCaipAddress=(r=e==null?void 0:e.accountState)==null?void 0:r.caipAddress,q.activeCaipNetwork=t,this.setChainNetworkData(s,{caipNetwork:t}),Y.setActiveCaipNetworkId(t==null?void 0:t.caipNetworkId),ri.set({activeChain:s,selectedNetworkId:t==null?void 0:t.caipNetworkId}))},setActiveCaipNetwork(s){var i,r,n;if(!s)return;q.activeChain!==s.chainNamespace&&this.setIsSwitchingNamespace(!0);const e=q.chains.get(s.chainNamespace);q.activeChain=s.chainNamespace,q.activeCaipNetwork=s,this.setChainNetworkData(s.chainNamespace,{caipNetwork:s}),(i=e==null?void 0:e.accountState)!=null&&i.address?q.activeCaipAddress=`${s.chainNamespace}:${s.id}:${(r=e==null?void 0:e.accountState)==null?void 0:r.address}`:q.activeCaipAddress=void 0,this.setAccountProp("caipAddress",q.activeCaipAddress,s.chainNamespace),e&&J.replaceState(e.accountState),Dp.resetSend(),ri.set({activeChain:q.activeChain,selectedNetworkId:(n=q.activeCaipNetwork)==null?void 0:n.caipNetworkId}),Y.setActiveCaipNetworkId(s.caipNetworkId),!this.checkIfSupportedNetwork(s.chainNamespace)&&k.state.enableNetworkSwitch&&!k.state.allowUnsupportedChain&&!ke.state.wcBasic&&this.showUnsupportedChainUI()},addCaipNetwork(s){var t;if(!s)return;const e=q.chains.get(s.chainNamespace);e&&((t=e==null?void 0:e.caipNetworks)==null||t.push(s))},async switchActiveNamespace(s){var r;if(!s)return;const e=s!==I.state.activeChain,t=(r=I.getNetworkData(s))==null?void 0:r.caipNetwork,i=I.getCaipNetworkByNamespace(s,t==null?void 0:t.id);e&&i&&await I.switchActiveNetwork(i)},async switchActiveNetwork(s){var r;const e=I.state.chains.get(I.state.activeChain);!((r=e==null?void 0:e.caipNetworks)!=null&&r.some(n=>{var o;return n.id===((o=q.activeCaipNetwork)==null?void 0:o.id)}))&&_e.goBack();const i=this.getNetworkControllerClient(s.chainNamespace);i&&(await i.switchCaipNetwork(s),je.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:s.caipNetworkId}}))},getNetworkControllerClient(s){const e=s||q.activeChain,t=q.chains.get(e);if(!t)throw new Error("Chain adapter not found");if(!t.networkControllerClient)throw new Error("NetworkController client not set");return t.networkControllerClient},getConnectionControllerClient(s){const e=s||q.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const t=q.chains.get(e);if(!(t!=null&&t.connectionControllerClient))throw new Error("ConnectionController client not set");return t.connectionControllerClient},getAccountProp(s,e){var r;let t=q.activeChain;if(e&&(t=e),!t)return;const i=(r=q.chains.get(t))==null?void 0:r.accountState;if(i)return i[s]},getNetworkProp(s,e){var i;const t=(i=q.chains.get(e))==null?void 0:i.networkState;if(t)return t[s]},getRequestedCaipNetworks(s){const e=q.chains.get(s),{approvedCaipNetworkIds:t=[],requestedCaipNetworks:i=[]}=(e==null?void 0:e.networkState)||{};return re.sortRequestedNetworks(t,i)},getAllRequestedCaipNetworks(){const s=[];return q.chains.forEach(e=>{const t=this.getRequestedCaipNetworks(e.namespace);s.push(...t)}),s},setRequestedCaipNetworks(s,e){this.setAdapterNetworkState(e,{requestedCaipNetworks:s})},getAllApprovedCaipNetworkIds(){const s=[];return q.chains.forEach(e=>{const t=this.getApprovedCaipNetworkIds(e.namespace);s.push(...t)}),s},getActiveCaipNetwork(){return q.activeCaipNetwork},getActiveCaipAddress(){return q.activeCaipAddress},getApprovedCaipNetworkIds(s){var i;const e=q.chains.get(s);return((i=e==null?void 0:e.networkState)==null?void 0:i.approvedCaipNetworkIds)||[]},async setApprovedCaipNetworksData(s){const e=this.getNetworkControllerClient(),t=await(e==null?void 0:e.getApprovedCaipNetworksData());this.setAdapterNetworkState(s,{approvedCaipNetworkIds:t==null?void 0:t.approvedCaipNetworkIds,supportsAllNetworks:t==null?void 0:t.supportsAllNetworks})},checkIfSupportedNetwork(s,e){const t=e||q.activeCaipNetwork,i=this.getRequestedCaipNetworks(s);return i.length?i==null?void 0:i.some(r=>r.id===(t==null?void 0:t.id)):!0},checkIfSupportedChainId(s){if(!q.activeChain)return!0;const e=this.getRequestedCaipNetworks(q.activeChain);return e==null?void 0:e.some(t=>t.id===s)},setSmartAccountEnabledNetworks(s,e){this.setAdapterNetworkState(e,{smartAccountEnabledNetworks:s})},checkIfSmartAccountEnabled(){var i;const s=$w.caipNetworkIdToNumber((i=q.activeCaipNetwork)==null?void 0:i.caipNetworkId),e=q.activeChain;if(!e||!s)return!1;const t=this.getNetworkProp("smartAccountEnabledNetworks",e);return!!(t!=null&&t.includes(Number(s)))},getActiveNetworkTokenAddress(){var i,r;const s=((i=q.activeCaipNetwork)==null?void 0:i.chainNamespace)||"eip155",e=((r=q.activeCaipNetwork)==null?void 0:r.id)||1,t=qt.NATIVE_TOKEN_ADDRESS[s];return`${s}:${e}:${t}`},showUnsupportedChainUI(){et.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const s=q.activeCaipNetwork;return!!(s!=null&&s.chainNamespace&&qt.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(s.chainNamespace))},resetNetwork(s){this.setAdapterNetworkState(s,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]})},resetAccount(s){const e=s;if(!e)throw new Error("Chain is required to set account prop");q.activeCaipAddress=void 0,this.setChainAccountData(e,{smartAccountDeployed:!1,currentTab:0,caipAddress:void 0,address:void 0,balance:void 0,balanceSymbol:void 0,profileName:void 0,profileImage:void 0,addressExplorerUrl:void 0,tokenBalance:[],connectedWalletInfo:void 0,preferredAccountType:void 0,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,allAccounts:[],user:void 0,status:"disconnected"}),ie.removeConnectorId(e)},async disconnect(s){const e=dO(s);try{Dp.resetSend();const t=await Promise.allSettled(e.map(async([r,n])=>{var o;try{const{caipAddress:a}=this.getAccountData(r)||{};a&&((o=n.connectionControllerClient)!=null&&o.disconnect)&&await n.connectionControllerClient.disconnect(r),this.resetAccount(r),this.resetNetwork(r)}catch(a){throw new Error(`Failed to disconnect chain ${r}: ${a.message}`)}}));ke.resetWcConnection();const i=t.filter(r=>r.status==="rejected");if(i.length>0)throw new Error(i.map(r=>r.reason.message).join(", "));Y.deleteConnectedSocialProvider(),s?ie.removeConnectorId(s):ie.resetConnectorIds(),je.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:s||"all"}})}catch(t){console.error(t.message||"Failed to disconnect chains"),je.sendEvent({type:"track",event:"DISCONNECT_ERROR",properties:{message:t.message||"Failed to disconnect chains"}})}},setIsSwitchingNamespace(s){q.isSwitchingNamespace=s},getFirstCaipNetworkSupportsAuthConnector(){var t,i;const s=[];let e;if(q.chains.forEach(r=>{Z.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===r.namespace)&&r.namespace&&s.push(r.namespace)}),s.length>0){const r=s[0];return e=r?(i=(t=q.chains.get(r))==null?void 0:t.caipNetworks)==null?void 0:i[0]:void 0,e}},getAccountData(s){var e;return s?(e=I.state.chains.get(s))==null?void 0:e.accountState:J.state},getNetworkData(s){var t;const e=s||q.activeChain;if(e)return(t=I.state.chains.get(e))==null?void 0:t.networkState},getCaipNetworkByNamespace(s,e){var r,n,o;if(!s)return;const t=I.state.chains.get(s),i=(r=t==null?void 0:t.caipNetworks)==null?void 0:r.find(a=>a.id===e);return i||((n=t==null?void 0:t.networkState)==null?void 0:n.caipNetwork)||((o=t==null?void 0:t.caipNetworks)==null?void 0:o[0])},getRequestedCaipNetworkIds(){const s=ie.state.filterByNamespace;return(s?[q.chains.get(s)]:Array.from(q.chains.values())).flatMap(t=>(t==null?void 0:t.caipNetworks)||[]).map(t=>t.caipNetworkId)}},kO={purchaseCurrencies:[{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"USD Coin",symbol:"USDC",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]},{id:"2b92315d-eab7-5bef-84fa-089a131333f5",name:"Ether",symbol:"ETH",networks:[{name:"ethereum-mainnet",display_name:"Ethereum",chain_id:"1",contract_address:"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48"},{name:"polygon-mainnet",display_name:"Polygon",chain_id:"137",contract_address:"0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174"}]}],paymentCurrencies:[{id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},{id:"EUR",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]}]},xw=re.getBlockchainApiUrl(),ts=Ke({clientId:null,api:new $c({baseUrl:xw,clientId:null}),supportedChains:{http:[],ws:[]}}),ee={state:ts,async get(s){const{st:e,sv:t}=ee.getSdkProperties(),i=k.state.projectId,r={...s.params||{},st:e,sv:t,projectId:i};return ts.api.get({...s,params:r})},getSdkProperties(){const{sdkType:s,sdkVersion:e}=k.state;return{st:s||"unknown",sv:e||"unknown"}},async isNetworkSupported(s){if(!s)return!1;try{ts.supportedChains.http.length||await ee.getSupportedNetworks()}catch{return!1}return ts.supportedChains.http.includes(s)},async getSupportedNetworks(){const s=await ee.get({path:"v1/supported-chains"});return ts.supportedChains=s,s},async fetchIdentity({address:s,caipNetworkId:e}){if(!await ee.isNetworkSupported(e))return{avatar:"",name:""};const i=Y.getIdentityFromCacheForAddress(s);if(i)return i;const r=await ee.get({path:`/v1/identity/${s}`,params:{sender:I.state.activeCaipAddress?re.getPlainAddress(I.state.activeCaipAddress):void 0}});return Y.updateIdentityCache({address:s,identity:r,timestamp:Date.now()}),r},async fetchTransactions({account:s,cursor:e,onramp:t,signal:i,cache:r,chainId:n}){var a;return await ee.isNetworkSupported((a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?ee.get({path:`/v1/account/${s}/history`,params:{cursor:e,onramp:t,chainId:n},signal:i,cache:r}):{data:[],next:void 0}},async fetchSwapQuote({amount:s,userAddress:e,from:t,to:i,gasPrice:r}){var o;return await ee.isNetworkSupported((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId)?ee.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:s,userAddress:e,from:t,to:i,gasPrice:r}}):{quotes:[]}},async fetchSwapTokens({chainId:s}){var t;return await ee.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ee.get({path:"/v1/convert/tokens",params:{chainId:s}}):{tokens:[]}},async fetchTokenPrice({addresses:s}){var t;return await ee.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ts.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:s,projectId:k.state.projectId},headers:{"Content-Type":"application/json"}}):{fungibles:[]}},async fetchSwapAllowance({tokenAddress:s,userAddress:e}){var i;return await ee.isNetworkSupported((i=I.state.activeCaipNetwork)==null?void 0:i.caipNetworkId)?ee.get({path:"/v1/convert/allowance",params:{tokenAddress:s,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:s}){var r;const{st:e,sv:t}=ee.getSdkProperties();if(!await ee.isNetworkSupported((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId))throw new Error("Network not supported for Gas Price");return ee.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:s,st:e,sv:t}})},async generateSwapCalldata({amount:s,from:e,to:t,userAddress:i,disableEstimate:r}){var o;if(!await ee.isNetworkSupported((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return ts.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:s,eip155:{slippage:qt.CONVERT_SLIPPAGE_TOLERANCE},projectId:k.state.projectId,from:e,to:t,userAddress:i,disableEstimate:r}})},async generateApproveCalldata({from:s,to:e,userAddress:t}){var o;const{st:i,sv:r}=ee.getSdkProperties();if(!await ee.isNetworkSupported((o=I.state.activeCaipNetwork)==null?void 0:o.caipNetworkId))throw new Error("Network not supported for Swaps");return ee.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:t,from:s,to:e,st:i,sv:r}})},async getBalance(s,e,t){var c;const{st:i,sv:r}=ee.getSdkProperties();if(!await ee.isNetworkSupported((c=I.state.activeCaipNetwork)==null?void 0:c.caipNetworkId))return wt.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${s}`,a=Y.getBalanceCacheForCaipAddress(o);if(a)return a;const l=await ee.get({path:`/v1/account/${s}/balance`,params:{currency:"usd",chainId:e,forceUpdate:t,st:i,sv:r}});return Y.updateBalanceCache({caipAddress:o,balance:l,timestamp:Date.now()}),l},async lookupEnsName(s){var t;return await ee.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ee.get({path:`/v1/profile/account/${s}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:s}){var t;return await ee.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ee.get({path:`/v1/profile/reverse/${s}`,params:{sender:J.state.address,apiVersion:"2"}}):[]},async getEnsNameSuggestions(s){var t;return await ee.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ee.get({path:`/v1/profile/suggestions/${s}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:s,address:e,message:t,signature:i}){var n;return await ee.isNetworkSupported((n=I.state.activeCaipNetwork)==null?void 0:n.caipNetworkId)?ts.api.post({path:"/v1/profile/account",body:{coin_type:s,address:e,message:t,signature:i},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:s,partnerUserId:e,defaultNetwork:t,purchaseAmount:i,paymentAmount:r}){var a;return await ee.isNetworkSupported((a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)?(await ts.api.post({path:"/v1/generators/onrampurl",params:{projectId:k.state.projectId},body:{destinationWallets:s,defaultNetwork:t,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:i,presetFiatAmount:r}})).url:""},async getOnrampOptions(){var e;if(!await ee.isNetworkSupported((e=I.state.activeCaipNetwork)==null?void 0:e.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await ee.get({path:"/v1/onramp/options"})}catch{return kO}},async getOnrampQuote({purchaseCurrency:s,paymentCurrency:e,amount:t,network:i}){var r;try{return await ee.isNetworkSupported((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?await ts.api.post({path:"/v1/onramp/quote",params:{projectId:k.state.projectId},body:{purchaseCurrency:s,paymentCurrency:e,amount:t,network:i}}):null}catch{return{coinbaseFee:{amount:t,currency:e.id},networkFee:{amount:t,currency:e.id},paymentSubtotal:{amount:t,currency:e.id},paymentTotal:{amount:t,currency:e.id},purchaseAmount:{amount:t,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(s){var t;return await ee.isNetworkSupported((t=I.state.activeCaipNetwork)==null?void 0:t.caipNetworkId)?ee.get({path:`/v1/sessions/${s}`}):[]},async revokeSmartSession(s,e,t){var r;return await ee.isNetworkSupported((r=I.state.activeCaipNetwork)==null?void 0:r.caipNetworkId)?ts.api.post({path:`/v1/sessions/${s}/revoke`,params:{projectId:k.state.projectId},body:{pci:e,signature:t}}):{success:!1}},setClientId(s){ts.clientId=s,ts.api=new $c({baseUrl:xw,clientId:s})}},Rs=Ke({currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,allAccounts:[]}),J={state:Rs,replaceState(s){s&&Object.assign(Rs,nr(s))},subscribe(s){return I.subscribeChainProp("accountState",e=>{if(e)return s(e)})},subscribeKey(s,e,t){let i;return I.subscribeChainProp("accountState",r=>{if(r){const n=r[s];i!==n&&(i=n,e(n))}},t)},setStatus(s,e){I.setAccountProp("status",s,e)},getCaipAddress(s){return I.getAccountProp("caipAddress",s)},setCaipAddress(s,e){const t=s?re.getPlainAddress(s):void 0;e===I.state.activeChain&&(I.state.activeCaipAddress=s),I.setAccountProp("caipAddress",s,e),I.setAccountProp("address",t,e)},setBalance(s,e,t){I.setAccountProp("balance",s,t),I.setAccountProp("balanceSymbol",e,t)},setProfileName(s,e){I.setAccountProp("profileName",s,e)},setProfileImage(s,e){I.setAccountProp("profileImage",s,e)},setUser(s,e){I.setAccountProp("user",s,e)},setAddressExplorerUrl(s,e){I.setAccountProp("addressExplorerUrl",s,e)},setSmartAccountDeployed(s,e){I.setAccountProp("smartAccountDeployed",s,e)},setCurrentTab(s){I.setAccountProp("currentTab",s,I.state.activeChain)},setTokenBalance(s,e){s&&I.setAccountProp("tokenBalance",s,e)},setShouldUpdateToAddress(s,e){I.setAccountProp("shouldUpdateToAddress",s,e)},setAllAccounts(s,e){I.setAccountProp("allAccounts",s,e)},addAddressLabel(s,e,t){const i=I.getAccountProp("addressLabels",t)||new Map;i.set(s,e),I.setAccountProp("addressLabels",i,t)},removeAddressLabel(s,e){const t=I.getAccountProp("addressLabels",e)||new Map;t.delete(s),I.setAccountProp("addressLabels",t,e)},setConnectedWalletInfo(s,e){I.setAccountProp("connectedWalletInfo",s,e,!1)},setPreferredAccountType(s,e){I.setAccountProp("preferredAccountType",s,e)},setSocialProvider(s,e){s&&I.setAccountProp("socialProvider",s,e)},setSocialWindow(s,e){I.setAccountProp("socialWindow",s?nr(s):void 0,e)},setFarcasterUrl(s,e){I.setAccountProp("farcasterUrl",s,e)},async fetchTokenBalance(s){var n,o;Rs.balanceLoading=!0;const e=(n=I.state.activeCaipNetwork)==null?void 0:n.caipNetworkId,t=(o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace,i=I.state.activeCaipAddress,r=i?re.getPlainAddress(i):void 0;if(Rs.lastRetry&&!re.isAllowedRetry(Rs.lastRetry,30*qt.ONE_SEC_MS))return Rs.balanceLoading=!1,[];try{if(r&&e&&t){const l=(await ee.getBalance(r,e)).balances.filter(c=>c.quantity.decimals!=="0");return this.setTokenBalance(l,t),Rs.lastRetry=void 0,Rs.balanceLoading=!1,l}}catch(a){Rs.lastRetry=Date.now(),s==null||s(a),wt.showError("Token Balance Unavailable")}finally{Rs.balanceLoading=!1}return[]},resetAccount(s){I.resetAccount(s)}},Wt=Ke({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),et={state:Wt,subscribe(s){return Lt(Wt,()=>s(Wt))},subscribeKey(s,e){return Xt(Wt,s,e)},async open(s){var r;const e=J.state.status==="connected";ke.state.wcBasic?ne.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1}):await ne.prefetch({fetchConnectorImages:!e,fetchFeaturedWallets:!e,fetchRecommendedWallets:!e}),s!=null&&s.namespace?(await I.switchActiveNamespace(s.namespace),et.setLoading(!0,s.namespace)):et.setLoading(!0),ie.setFilterByNamespace(s==null?void 0:s.namespace);const t=(r=I.getAccountData(s==null?void 0:s.namespace))==null?void 0:r.caipAddress;I.state.noAdapters&&!t?re.isMobile()?_e.reset("AllWallets"):_e.reset("ConnectingWalletConnectBasic"):s!=null&&s.view?_e.reset(s.view):t?_e.reset("Account"):_e.reset("Connect"),Wt.open=!0,ri.set({open:!0}),je.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!t}})},close(){const s=k.state.enableEmbedded,e=!!I.state.activeCaipAddress;Wt.open&&je.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),Wt.open=!1,et.clearLoading(),s?e?_e.replace("Account"):_e.push("Connect"):ri.set({open:!1}),ke.resetUri()},setLoading(s,e){e&&Wt.loadingNamespaceMap.set(e,s),Wt.loading=s,ri.set({loading:s})},clearLoading(){Wt.loadingNamespaceMap.clear(),Wt.loading=!1},shake(){Wt.shake||(Wt.shake=!0,setTimeout(()=>{Wt.shake=!1},500))}},kp=2147483648,jO={convertEVMChainIdToCoinType(s){if(s>=kp)throw new Error("Invalid chainId");return(kp|s)>>>0}},ds=Ke({suggestions:[],loading:!1}),Ow={state:ds,subscribe(s){return Lt(ds,()=>s(ds))},subscribeKey(s,e){return Xt(ds,s,e)},async resolveName(s){var e,t;try{return await ee.lookupEnsName(s)}catch(i){const r=i;throw new Error(((t=(e=r==null?void 0:r.reasons)==null?void 0:e[0])==null?void 0:t.description)||"Error resolving name")}},async isNameRegistered(s){try{return await ee.lookupEnsName(s),!0}catch{return!1}},async getSuggestions(s){try{ds.loading=!0,ds.suggestions=[];const e=await ee.getEnsNameSuggestions(s);return ds.suggestions=e.suggestions.map(t=>({...t,name:t.name}))||[],ds.suggestions}catch(e){const t=this.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(t)}finally{ds.loading=!1}},async getNamesForAddress(s){try{if(!I.state.activeCaipNetwork)return[];const t=Y.getEnsFromCacheForAddress(s);if(t)return t;const i=await ee.reverseLookupEnsName({address:s});return Y.updateEnsCache({address:s,ens:i,timestamp:Date.now()}),i}catch(e){const t=this.parseEnsApiError(e,"Error fetching names for address");throw new Error(t)}},async registerName(s){const e=I.state.activeCaipNetwork;if(!e)throw new Error("Network not found");const t=J.state.address,i=ie.getAuthConnector();if(!t||!i)throw new Error("Address or auth connector not found");ds.loading=!0;try{const r=JSON.stringify({name:s,attributes:{},timestamp:Math.floor(Date.now()/1e3)});_e.pushTransactionStack({view:"RegisterAccountNameSuccess",goBack:!1,replace:!0,onCancel(){ds.loading=!1}});const n=await ke.signMessage(r),o=e.id;if(!o)throw new Error("Network not found");const a=jO.convertEVMChainIdToCoinType(Number(o));await ee.registerEnsName({coinType:a,address:t,signature:n,message:r}),J.setProfileName(s,e.chainNamespace),_e.replace("RegisterAccountNameSuccess")}catch(r){const n=this.parseEnsApiError(r,`Error registering name ${s}`);throw _e.replace("RegisterAccountName"),new Error(n)}finally{ds.loading=!1}},validateName(s){return/^[a-zA-Z0-9-]{4,}$/u.test(s)},parseEnsApiError(s,e){var i,r;const t=s;return((r=(i=t==null?void 0:t.reasons)==null?void 0:i[0])==null?void 0:r.description)||e}};function RO(s){return!s||typeof s.then!="function"?Promise.resolve(s):s}function mt(s,...e){try{return RO(s(...e))}catch(t){return Promise.reject(t)}}function UO(s){const e=typeof s;return s===null||e!=="object"&&e!=="function"}function LO(s){const e=Object.getPrototypeOf(s);return!e||e.isPrototypeOf(Object)}function La(s){if(UO(s))return String(s);if(LO(s)||Array.isArray(s))return JSON.stringify(s);if(typeof s.toJSON=="function")return La(s.toJSON());throw new Error("[unstorage] Cannot stringify value!")}const dh="base64:";function zO(s){return typeof s=="string"?s:dh+BO(s)}function FO(s){return typeof s!="string"||!s.startsWith(dh)?s:qO(s.slice(dh.length))}function qO(s){return globalThis.Buffer?N.dist.Buffer.from(s,"base64"):Uint8Array.from(globalThis.atob(s),e=>e.codePointAt(0))}function BO(s){return globalThis.Buffer?N.dist.Buffer.from(s).toString("base64"):globalThis.btoa(String.fromCodePoint(...s))}function Yt(s){var e;return s&&((e=s.split("?")[0])==null?void 0:e.replace(/[/\\]/g,":").replace(/:+/g,":").replace(/^:|:$/g,""))||""}function HO(...s){return Yt(s.join(":"))}function Ia(s){return s=Yt(s),s?s+":":""}function WO(s,e){if(e===void 0)return!0;let t=0,i=s.indexOf(":");for(;i>-1;)t++,i=s.indexOf(":",i+1);return t<=e}function VO(s,e){return e?s.startsWith(e)&&s[s.length-1]!=="$":s[s.length-1]!=="$"}const KO="memory",GO=()=>{const s=new Map;return{name:KO,getInstance:()=>s,hasItem(e){return s.has(e)},getItem(e){return s.get(e)??null},getItemRaw(e){return s.get(e)??null},setItem(e,t){s.set(e,t)},setItemRaw(e,t){s.set(e,t)},removeItem(e){s.delete(e)},getKeys(){return[...s.keys()]},clear(){s.clear()},dispose(){s.clear()}}};function YO(s={}){const e={mounts:{"":s.driver||GO()},mountpoints:[""],watching:!1,watchListeners:[],unwatch:{}},t=c=>{for(const h of e.mountpoints)if(c.startsWith(h))return{base:h,relativeKey:c.slice(h.length),driver:e.mounts[h]};return{base:"",relativeKey:c,driver:e.mounts[""]}},i=(c,h)=>e.mountpoints.filter(u=>u.startsWith(c)||h&&c.startsWith(u)).map(u=>({relativeBase:c.length>u.length?c.slice(u.length):void 0,mountpoint:u,driver:e.mounts[u]})),r=(c,h)=>{if(e.watching){h=Yt(h);for(const u of e.watchListeners)u(c,h)}},n=async()=>{if(!e.watching){e.watching=!0;for(const c in e.mounts)e.unwatch[c]=await jp(e.mounts[c],r,c)}},o=async()=>{if(e.watching){for(const c in e.unwatch)await e.unwatch[c]();e.unwatch={},e.watching=!1}},a=(c,h,u)=>{const d=new Map,p=g=>{let f=d.get(g.base);return f||(f={driver:g.driver,base:g.base,items:[]},d.set(g.base,f)),f};for(const g of c){const f=typeof g=="string",b=Yt(f?g:g.key),y=f?void 0:g.value,w=f||!g.options?h:{...h,...g.options},v=t(b);p(v).items.push({key:b,value:y,relativeKey:v.relativeKey,options:w})}return Promise.all([...d.values()].map(g=>u(g))).then(g=>g.flat())},l={hasItem(c,h={}){c=Yt(c);const{relativeKey:u,driver:d}=t(c);return mt(d.hasItem,u,h)},getItem(c,h={}){c=Yt(c);const{relativeKey:u,driver:d}=t(c);return mt(d.getItem,u,h).then(p=>m.destr(p))},getItems(c,h={}){return a(c,h,u=>u.driver.getItems?mt(u.driver.getItems,u.items.map(d=>({key:d.relativeKey,options:d.options})),h).then(d=>d.map(p=>({key:HO(u.base,p.key),value:m.destr(p.value)}))):Promise.all(u.items.map(d=>mt(u.driver.getItem,d.relativeKey,d.options).then(p=>({key:d.key,value:m.destr(p)})))))},getItemRaw(c,h={}){c=Yt(c);const{relativeKey:u,driver:d}=t(c);return d.getItemRaw?mt(d.getItemRaw,u,h):mt(d.getItem,u,h).then(p=>FO(p))},async setItem(c,h,u={}){if(h===void 0)return l.removeItem(c);c=Yt(c);const{relativeKey:d,driver:p}=t(c);p.setItem&&(await mt(p.setItem,d,La(h),u),p.watch||r("update",c))},async setItems(c,h){await a(c,h,async u=>{if(u.driver.setItems)return mt(u.driver.setItems,u.items.map(d=>({key:d.relativeKey,value:La(d.value),options:d.options})),h);u.driver.setItem&&await Promise.all(u.items.map(d=>mt(u.driver.setItem,d.relativeKey,La(d.value),d.options)))})},async setItemRaw(c,h,u={}){if(h===void 0)return l.removeItem(c,u);c=Yt(c);const{relativeKey:d,driver:p}=t(c);if(p.setItemRaw)await mt(p.setItemRaw,d,h,u);else if(p.setItem)await mt(p.setItem,d,zO(h),u);else return;p.watch||r("update",c)},async removeItem(c,h={}){typeof h=="boolean"&&(h={removeMeta:h}),c=Yt(c);const{relativeKey:u,driver:d}=t(c);d.removeItem&&(await mt(d.removeItem,u,h),(h.removeMeta||h.removeMata)&&await mt(d.removeItem,u+"$",h),d.watch||r("remove",c))},async getMeta(c,h={}){typeof h=="boolean"&&(h={nativeOnly:h}),c=Yt(c);const{relativeKey:u,driver:d}=t(c),p=Object.create(null);if(d.getMeta&&Object.assign(p,await mt(d.getMeta,u,h)),!h.nativeOnly){const g=await mt(d.getItem,u+"$",h).then(f=>m.destr(f));g&&typeof g=="object"&&(typeof g.atime=="string"&&(g.atime=new Date(g.atime)),typeof g.mtime=="string"&&(g.mtime=new Date(g.mtime)),Object.assign(p,g))}return p},setMeta(c,h,u={}){return this.setItem(c+"$",h,u)},removeMeta(c,h={}){return this.removeItem(c+"$",h)},async getKeys(c,h={}){var b;c=Ia(c);const u=i(c,!0);let d=[];const p=[];let g=!0;for(const y of u){(b=y.driver.flags)!=null&&b.maxDepth||(g=!1);const w=await mt(y.driver.getKeys,y.relativeBase,h);for(const v of w){const A=y.mountpoint+Yt(v);d.some(C=>A.startsWith(C))||p.push(A)}d=[y.mountpoint,...d.filter(v=>!v.startsWith(y.mountpoint))]}const f=h.maxDepth!==void 0&&!g;return p.filter(y=>(!f||WO(y,h.maxDepth))&&VO(y,c))},async clear(c,h={}){c=Ia(c),await Promise.all(i(c,!1).map(async u=>{if(u.driver.clear)return mt(u.driver.clear,u.relativeBase,h);if(u.driver.removeItem){const d=await u.driver.getKeys(u.relativeBase||"",h);return Promise.all(d.map(p=>u.driver.removeItem(p,h)))}}))},async dispose(){await Promise.all(Object.values(e.mounts).map(c=>Rp(c)))},async watch(c){return await n(),e.watchListeners.push(c),async()=>{e.watchListeners=e.watchListeners.filter(h=>h!==c),e.watchListeners.length===0&&await o()}},async unwatch(){e.watchListeners=[],await o()},mount(c,h){if(c=Ia(c),c&&e.mounts[c])throw new Error(`already mounted at ${c}`);return c&&(e.mountpoints.push(c),e.mountpoints.sort((u,d)=>d.length-u.length)),e.mounts[c]=h,e.watching&&Promise.resolve(jp(h,r,c)).then(u=>{e.unwatch[c]=u}).catch(console.error),l},async unmount(c,h=!0){var u,d;c=Ia(c),!(!c||!e.mounts[c])&&(e.watching&&c in e.unwatch&&((d=(u=e.unwatch)[c])==null||d.call(u),delete e.unwatch[c]),h&&await Rp(e.mounts[c]),e.mountpoints=e.mountpoints.filter(p=>p!==c),delete e.mounts[c])},getMount(c=""){c=Yt(c)+":";const h=t(c);return{driver:h.driver,base:h.base}},getMounts(c="",h={}){return c=Yt(c),i(c,h.parents).map(d=>({driver:d.driver,base:d.mountpoint}))},keys:(c,h={})=>l.getKeys(c,h),get:(c,h={})=>l.getItem(c,h),set:(c,h,u={})=>l.setItem(c,h,u),has:(c,h={})=>l.hasItem(c,h),del:(c,h={})=>l.removeItem(c,h),remove:(c,h={})=>l.removeItem(c,h)};return l}function jp(s,e,t){return s.watch?s.watch((i,r)=>e(i,t+r)):()=>{}}async function Rp(s){typeof s.dispose=="function"&&await mt(s.dispose)}const QO="idb-keyval";var ZO=(s={})=>{const e=s.base&&s.base.length>0?`${s.base}:`:"",t=r=>e+r;let i;return s.dbName&&s.storeName&&(i=m.createStore(s.dbName,s.storeName)),{name:QO,options:s,async hasItem(r){return!(typeof await m.get(t(r),i)>"u")},async getItem(r){return await m.get(t(r),i)??null},setItem(r,n){return m.set(t(r),n,i)},removeItem(r){return m.del(t(r),i)},getKeys(){return m.keys(i)},clear(){return m.clear(i)}}};const JO="WALLET_CONNECT_V2_INDEXED_DB",XO="keyvaluestorage";let eD=class{constructor(){this.indexedDb=YO({driver:ZO({dbName:JO,storeName:XO})})}async getKeys(){return this.indexedDb.getKeys()}async getEntries(){return(await this.indexedDb.getItems(await this.indexedDb.getKeys())).map(e=>[e.key,e.value])}async getItem(e){const t=await this.indexedDb.getItem(e);if(t!==null)return t}async setItem(e,t){await this.indexedDb.setItem(e,m.safeJsonStringify(t))}async removeItem(e){await this.indexedDb.removeItem(e)}};var ul=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof N.dist.global<"u"?N.dist.global:typeof self<"u"?self:{},za={exports:{}};(function(){let s;function e(){}s=e,s.prototype.getItem=function(t){return this.hasOwnProperty(t)?String(this[t]):null},s.prototype.setItem=function(t,i){this[t]=String(i)},s.prototype.removeItem=function(t){delete this[t]},s.prototype.clear=function(){const t=this;Object.keys(t).forEach(function(i){t[i]=void 0,delete t[i]})},s.prototype.key=function(t){return t=t||0,Object.keys(this)[t]},s.prototype.__defineGetter__("length",function(){return Object.keys(this).length}),typeof ul<"u"&&ul.localStorage?za.exports=ul.localStorage:typeof window<"u"&&window.localStorage?za.exports=window.localStorage:za.exports=new e})();function tD(s){var e;return[s[0],m.safeJsonParse((e=s[1])!=null?e:"")]}let sD=class{constructor(){this.localStorage=za.exports}async getKeys(){return Object.keys(this.localStorage)}async getEntries(){return Object.entries(this.localStorage).map(tD)}async getItem(e){const t=this.localStorage.getItem(e);if(t!==null)return m.safeJsonParse(t)}async setItem(e,t){this.localStorage.setItem(e,m.safeJsonStringify(t))}async removeItem(e){this.localStorage.removeItem(e)}};const iD="wc_storage_version",Up=1,rD=async(s,e,t)=>{const i=iD,r=await e.getItem(i);if(r&&r>=Up){t(e);return}const n=await s.getKeys();if(!n.length){t(e);return}const o=[];for(;n.length;){const a=n.shift();if(!a)continue;const l=a.toLowerCase();if(l.includes("wc@")||l.includes("walletconnect")||l.includes("wc_")||l.includes("wallet_connect")){const c=await s.getItem(a);await e.setItem(a,c),o.push(a)}}await e.setItem(i,Up),t(e),nD(s,o)},nD=async(s,e)=>{e.length&&e.forEach(async t=>{await s.removeItem(t)})};let oD=class{constructor(){this.initialized=!1,this.setInitialized=t=>{this.storage=t,this.initialized=!0};const e=new sD;this.storage=e;try{const t=new eD;rD(e,t,this.setInitialized)}catch{this.initialized=!0}}async getKeys(){return await this.initialize(),this.storage.getKeys()}async getEntries(){return await this.initialize(),this.storage.getEntries()}async getItem(e){return await this.initialize(),this.storage.getItem(e)}async setItem(e,t){return await this.initialize(),this.storage.setItem(e,t)}async removeItem(e){return await this.initialize(),this.storage.removeItem(e)}async initialize(){this.initialized||await new Promise(e=>{const t=setInterval(()=>{this.initialized&&(clearInterval(t),e())},20)})}};function xo(s,{strict:e=!0}={}){return!s||typeof s!="string"?!1:e?/^0x[0-9a-fA-F]*$/.test(s):s.startsWith("0x")}function Lp(s){return xo(s,{strict:!1})?Math.ceil((s.length-2)/2):s.length}const Dw="2.23.2";let Gn={getDocsUrl:({docsBaseUrl:s,docsPath:e="",docsSlug:t})=>e?`${s??"https://viem.sh"}${e}${t?`#${t}`:""}`:void 0,version:`viem@${Dw}`};class or extends Error{constructor(e,t={}){var a;const i=(()=>{var l;return t.cause instanceof or?t.cause.details:(l=t.cause)!=null&&l.message?t.cause.message:t.details})(),r=t.cause instanceof or&&t.cause.docsPath||t.docsPath,n=(a=Gn.getDocsUrl)==null?void 0:a.call(Gn,{...t,docsPath:r}),o=[e||"An error occurred.","",...t.metaMessages?[...t.metaMessages,""]:[],...n?[`Docs: ${n}`]:[],...i?[`Details: ${i}`]:[],...Gn.version?[`Version: ${Gn.version}`]:[]].join(`
|
|
12
|
-
`);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=Dw}walk(e){return kw(this,e)}}function kw(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?kw(s.cause,e):e?null:s}class jw extends or{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function Tn(s,{dir:e,size:t=32}={}){return typeof s=="string"?aD(s,{dir:e,size:t}):cD(s,{dir:e,size:t})}function aD(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new jw({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function cD(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new jw({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}class lD extends or{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class hD extends or{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Mn(s,{size:e}){if(Lp(s)>e)throw new hD({givenSize:Lp(s),maxSize:e})}function ph(s,e={}){const{signed:t}=e;e.size&&Mn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function uD(s,e={}){return Number(ph(s,e))}const dD=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function gh(s,e={}){return typeof s=="number"||typeof s=="bigint"?Uw(s,e):typeof s=="string"?fD(s,e):typeof s=="boolean"?pD(s,e):Rw(s,e)}function pD(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(Mn(t,{size:e.size}),Tn(t,{size:e.size})):t}function Rw(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=dD[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Mn(i,{size:e.size}),Tn(i,{dir:"right",size:e.size})):i}function Uw(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new lD({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Tn(a,{size:i}):a}const gD=new TextEncoder;function fD(s,e={}){const t=gD.encode(s);return Rw(t,e)}const mD=new TextEncoder;function wD(s,e={}){return typeof s=="number"||typeof s=="bigint"?bD(s,e):typeof s=="boolean"?yD(s,e):xo(s)?Lw(s,e):zw(s,e)}function yD(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(Mn(t,{size:e.size}),Tn(t,{size:e.size})):t}const Zs={zero:48,nine:57,A:65,F:70,a:97,f:102};function zp(s){if(s>=Zs.zero&&s<=Zs.nine)return s-Zs.zero;if(s>=Zs.A&&s<=Zs.F)return s-(Zs.A-10);if(s>=Zs.a&&s<=Zs.f)return s-(Zs.a-10)}function Lw(s,e={}){let t=s;e.size&&(Mn(t,{size:e.size}),t=Tn(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const l=zp(i.charCodeAt(a++)),c=zp(i.charCodeAt(a++));if(l===void 0||c===void 0)throw new or(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=l*16+c}return n}function bD(s,e){const t=Uw(s,e);return Lw(t)}function zw(s,e={}){const t=mD.encode(s);return typeof e.size=="number"?(Mn(t,{size:e.size}),Tn(t,{dir:"right",size:e.size})):t}function sc(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function vD(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Xo(s,...e){if(!vD(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function ID(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");sc(s.outputLen),sc(s.blockLen)}function fh(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Fw(s,e){Xo(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Ea=BigInt(2**32-1),Fp=BigInt(32);function ED(s,e=!1){return e?{h:Number(s&Ea),l:Number(s>>Fp&Ea)}:{h:Number(s>>Fp&Ea)|0,l:Number(s&Ea)|0}}function AD(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=ED(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const ND=(s,e,t)=>s<<t|e>>>32-t,_D=(s,e,t)=>e<<t|s>>>32-t,CD=(s,e,t)=>e<<t-32|s>>>64-t,SD=(s,e,t)=>s<<t-32|e>>>64-t,Ur=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $D(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function PD(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function TD(s,e){return s<<32-e|s>>>e}const qp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function MD(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Bp(s){for(let e=0;e<s.length;e++)s[e]=MD(s[e])}function xD(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function lu(s){return typeof s=="string"&&(s=xD(s)),Xo(s),s}function OD(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Xo(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}class qw{clone(){return this._cloneInto()}}function Bw(s){const e=i=>s().update(lu(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function DD(s=32){if(Ur&&typeof Ur.getRandomValues=="function")return Ur.getRandomValues(new Uint8Array(s));if(Ur&&typeof Ur.randomBytes=="function")return Ur.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Hw=[],Ww=[],Vw=[],kD=BigInt(0),Yn=BigInt(1),jD=BigInt(2),RD=BigInt(7),UD=BigInt(256),LD=BigInt(113);for(let s=0,e=Yn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Hw.push(2*(5*i+t)),Ww.push((s+1)*(s+2)/2%64);let r=kD;for(let n=0;n<7;n++)e=(e<<Yn^(e>>RD)*LD)%UD,e&jD&&(r^=Yn<<(Yn<<BigInt(n))-Yn);Vw.push(r)}const[zD,FD]=AD(Vw,!0),Hp=(s,e,t)=>t>32?CD(s,e,t):ND(s,e,t),Wp=(s,e,t)=>t>32?SD(s,e,t):_D(s,e,t);function qD(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=Hp(c,h,1)^t[a],d=Wp(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Ww[o],l=Hp(r,n,a),c=Wp(r,n,a),h=Hw[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=zD[i],s[1]^=FD[i]}t.fill(0)}class hu extends qw{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,sc(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=$D(this.state)}keccak(){qp||Bp(this.state32),qD(this.state32,this.rounds),qp||Bp(this.state32),this.posOut=0,this.pos=0}update(e){fh(this);const{blockLen:t,state:i}=this;e=lu(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){fh(this,!1),Xo(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return sc(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Fw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new hu(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const BD=(s,e,t)=>Bw(()=>new hu(e,s,t)),HD=BD(1,136,256/8);function Kw(s,e){const t=e||"hex",i=HD(xo(s,{strict:!1})?wD(s):s);return t==="bytes"?i:gh(i)}class WD extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const dl=new WD(8192);function VD(s,e){if(dl.has(`${s}.${e}`))return dl.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=Kw(zw(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return dl.set(`${s}.${e}`,n),n}function KD(s){const e=Kw(`0x${s.substring(4)}`).substring(26);return VD(`0x${e}`)}async function GD({hash:s,signature:e}){const t=xo(s)?s:gh(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-Cks0bicH.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:c,s:h,v:u,yParity:d}=e,p=Number(d??u),g=Vp(p);return new i.Signature(ph(c),ph(h)).addRecoveryBit(g)}const o=xo(e)?e:gh(e),a=uD(`0x${o.slice(130)}`),l=Vp(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(l)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function Vp(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function YD({hash:s,signature:e}){return KD(await GD({hash:s,signature:e}))}function QD(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var ZD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Gw=QD(ZD),JD=":";function mn(s){const[e,t]=s.split(JD);return{namespace:e,reference:t}}function Yw(s,e){return s.includes(":")?[s]:e.chains||[]}const XD="ReactNative",cs={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},ek="js";function ic(){return typeof N.dist.process<"u"&&typeof N.dist.process.versions<"u"&&typeof N.dist.process.versions.node<"u"}function xi(){return!E.getDocument_1()&&!!E.getNavigator_1()&&navigator.product===XD}function tk(){return xi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="android"}function sk(){return xi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="ios"}function ea(){return!ic()&&!!E.getNavigator_1()&&!!E.getDocument_1()}function ta(){return xi()?cs.reactNative:ic()?cs.node:ea()?cs.browser:cs.unknown}function Kp(){var s;try{return xi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Application)<"u"?(s=N.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function ik(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function Qw(){return E.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function rk(){if(ta()===cs.reactNative&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"){const{OS:t,Version:i}=N.dist.global.Platform;return[t,i].join("-")}const s=m.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function nk(){var s;const e=ta();return e===cs.browser?[e,((s=E.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function Zw(s,e,t){const i=rk(),r=nk();return[[s,e].join("-"),[ek,t].join("-"),i,r].join("/")}function ok({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:l}){const c=t.split("?"),h=Zw(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:l||void 0,bundleId:a||void 0},d=ik(c[1]||"",u);return c[0]+"?"+d}function Qi(s,e){return s.filter(t=>e.includes(t)).length===s.length}function mh(s){return Object.fromEntries(s.entries())}function wh(s){return new Map(Object.entries(s))}function Bi(s=E.cjs.FIVE_MINUTES,e){const t=E.cjs.toMiliseconds(s||E.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,l)=>{if(o)return a(o);n=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),l(c)},t),i=a,r=l})}}function Ai(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function Jw(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function ak(s){return Jw("topic",s)}function ck(s){return Jw("id",s)}function Xw(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ct(s,e){return E.cjs.fromMiliseconds(Date.now()+E.cjs.toMiliseconds(s))}function wi(s){return Date.now()>=E.cjs.toMiliseconds(s)}function Ne(s,e){return`${s}${e?`:${e}`:""}`}function Fa(s=[],e=[]){return[...new Set([...s,...e])]}async function lk({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=hk(n,s,e),a=ta();if(a===cs.browser){if(!((i=E.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}uk(o)}else a===cs.reactNative&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u"&&await N.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function hk(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${fk(i,!0)}`}else r=`${r}/wc?${i}`;return r}function uk(s){let e="_self";gk()?e="_top":(pk()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function dk(s,e){let t="";try{if(ea()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Gp(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Yp(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function uu(){return typeof N.dist.process<"u"&&N.dist.process.env.IS_VITEST==="true"}function pk(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function gk(){try{return window.self!==window.top}catch{return!1}}function fk(s,e=!1){const t=N.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function ey(s){return N.dist.Buffer.from(s,"base64").toString("utf-8")}function mk(s){return new Promise(e=>setTimeout(e,s))}function Oo(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function wk(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Pc(s,...e){if(!wk(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function du(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Oo(s.outputLen),Oo(s.blockLen)}function In(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function ty(s,e){Pc(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Aa=BigInt(2**32-1),Qp=BigInt(32);function yk(s,e=!1){return e?{h:Number(s&Aa),l:Number(s>>Qp&Aa)}:{h:Number(s>>Qp&Aa)|0,l:Number(s&Aa)|0}}function bk(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=yk(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const vk=(s,e,t)=>s<<t|e>>>32-t,Ik=(s,e,t)=>e<<t|s>>>32-t,Ek=(s,e,t)=>e<<t-32|s>>>64-t,Ak=(s,e,t)=>s<<t-32|e>>>64-t,Lr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Nk(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function pl(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Us(s,e){return s<<32-e|s>>>e}const Zp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _k(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Jp(s){for(let e=0;e<s.length;e++)s[e]=_k(s[e])}function Ck(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function En(s){return typeof s=="string"&&(s=Ck(s)),Pc(s),s}let pu=class{clone(){return this._cloneInto()}};function sy(s){const e=i=>s().update(En(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function sa(s=32){if(Lr&&typeof Lr.getRandomValues=="function")return Lr.getRandomValues(new Uint8Array(s));if(Lr&&typeof Lr.randomBytes=="function")return Lr.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const iy=[],ry=[],ny=[],Sk=BigInt(0),Qn=BigInt(1),$k=BigInt(2),Pk=BigInt(7),Tk=BigInt(256),Mk=BigInt(113);for(let s=0,e=Qn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],iy.push(2*(5*i+t)),ry.push((s+1)*(s+2)/2%64);let r=Sk;for(let n=0;n<7;n++)e=(e<<Qn^(e>>Pk)*Mk)%Tk,e&$k&&(r^=Qn<<(Qn<<BigInt(n))-Qn);ny.push(r)}const[xk,Ok]=bk(ny,!0),Xp=(s,e,t)=>t>32?Ek(s,e,t):vk(s,e,t),eg=(s,e,t)=>t>32?Ak(s,e,t):Ik(s,e,t);function Dk(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=Xp(c,h,1)^t[a],d=eg(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=ry[o],l=Xp(r,n,a),c=eg(r,n,a),h=iy[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=xk[i],s[1]^=Ok[i]}t.fill(0)}let kk=class oy extends pu{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Oo(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Nk(this.state)}keccak(){Zp||Jp(this.state32),Dk(this.state32,this.rounds),Zp||Jp(this.state32),this.posOut=0,this.pos=0}update(e){In(this);const{blockLen:t,state:i}=this;e=En(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){In(this,!1),Pc(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Oo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ty(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new oy(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const jk=(s,e,t)=>sy(()=>new kk(e,s,t)),Rk=jk(1,136,256/8),Uk="https://rpc.walletconnect.org/v1";function ay(s){const e=`Ethereum Signed Message:
|
|
12
|
+
`);super(o,t.cause?{cause:t.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"metaMessages",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),this.details=i,this.docsPath=r,this.metaMessages=t.metaMessages,this.name=t.name??this.name,this.shortMessage=e,this.version=Dw}walk(e){return kw(this,e)}}function kw(s,e){return e!=null&&e(s)?s:s&&typeof s=="object"&&"cause"in s&&s.cause!==void 0?kw(s.cause,e):e?null:s}class jw extends or{constructor({size:e,targetSize:t,type:i}){super(`${i.charAt(0).toUpperCase()}${i.slice(1).toLowerCase()} size (${e}) exceeds padding size (${t}).`,{name:"SizeExceedsPaddingSizeError"})}}function Tn(s,{dir:e,size:t=32}={}){return typeof s=="string"?aD(s,{dir:e,size:t}):cD(s,{dir:e,size:t})}function aD(s,{dir:e,size:t=32}={}){if(t===null)return s;const i=s.replace("0x","");if(i.length>t*2)throw new jw({size:Math.ceil(i.length/2),targetSize:t,type:"hex"});return`0x${i[e==="right"?"padEnd":"padStart"](t*2,"0")}`}function cD(s,{dir:e,size:t=32}={}){if(t===null)return s;if(s.length>t)throw new jw({size:s.length,targetSize:t,type:"bytes"});const i=new Uint8Array(t);for(let r=0;r<t;r++){const n=e==="right";i[n?r:t-r-1]=s[n?r:s.length-r-1]}return i}class lD extends or{constructor({max:e,min:t,signed:i,size:r,value:n}){super(`Number "${n}" is not in safe ${r?`${r*8}-bit ${i?"signed":"unsigned"} `:""}integer range ${e?`(${t} to ${e})`:`(above ${t})`}`,{name:"IntegerOutOfRangeError"})}}class hD extends or{constructor({givenSize:e,maxSize:t}){super(`Size cannot exceed ${t} bytes. Given size: ${e} bytes.`,{name:"SizeOverflowError"})}}function Mn(s,{size:e}){if(Lp(s)>e)throw new hD({givenSize:Lp(s),maxSize:e})}function ph(s,e={}){const{signed:t}=e;e.size&&Mn(s,{size:e.size});const i=BigInt(s);if(!t)return i;const r=(s.length-2)/2,n=(1n<<BigInt(r)*8n-1n)-1n;return i<=n?i:i-BigInt(`0x${"f".padStart(r*2,"f")}`)-1n}function uD(s,e={}){return Number(ph(s,e))}const dD=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function gh(s,e={}){return typeof s=="number"||typeof s=="bigint"?Uw(s,e):typeof s=="string"?fD(s,e):typeof s=="boolean"?pD(s,e):Rw(s,e)}function pD(s,e={}){const t=`0x${Number(s)}`;return typeof e.size=="number"?(Mn(t,{size:e.size}),Tn(t,{size:e.size})):t}function Rw(s,e={}){let t="";for(let r=0;r<s.length;r++)t+=dD[s[r]];const i=`0x${t}`;return typeof e.size=="number"?(Mn(i,{size:e.size}),Tn(i,{dir:"right",size:e.size})):i}function Uw(s,e={}){const{signed:t,size:i}=e,r=BigInt(s);let n;i?t?n=(1n<<BigInt(i)*8n-1n)-1n:n=2n**(BigInt(i)*8n)-1n:typeof s=="number"&&(n=BigInt(Number.MAX_SAFE_INTEGER));const o=typeof n=="bigint"&&t?-n-1n:0;if(n&&r>n||r<o){const l=typeof s=="bigint"?"n":"";throw new lD({max:n?`${n}${l}`:void 0,min:`${o}${l}`,signed:t,size:i,value:`${s}${l}`})}const a=`0x${(t&&r<0?(1n<<BigInt(i*8))+BigInt(r):r).toString(16)}`;return i?Tn(a,{size:i}):a}const gD=new TextEncoder;function fD(s,e={}){const t=gD.encode(s);return Rw(t,e)}const mD=new TextEncoder;function wD(s,e={}){return typeof s=="number"||typeof s=="bigint"?bD(s,e):typeof s=="boolean"?yD(s,e):xo(s)?Lw(s,e):zw(s,e)}function yD(s,e={}){const t=new Uint8Array(1);return t[0]=Number(s),typeof e.size=="number"?(Mn(t,{size:e.size}),Tn(t,{size:e.size})):t}const Zs={zero:48,nine:57,A:65,F:70,a:97,f:102};function zp(s){if(s>=Zs.zero&&s<=Zs.nine)return s-Zs.zero;if(s>=Zs.A&&s<=Zs.F)return s-(Zs.A-10);if(s>=Zs.a&&s<=Zs.f)return s-(Zs.a-10)}function Lw(s,e={}){let t=s;e.size&&(Mn(t,{size:e.size}),t=Tn(t,{dir:"right",size:e.size}));let i=t.slice(2);i.length%2&&(i=`0${i}`);const r=i.length/2,n=new Uint8Array(r);for(let o=0,a=0;o<r;o++){const l=zp(i.charCodeAt(a++)),c=zp(i.charCodeAt(a++));if(l===void 0||c===void 0)throw new or(`Invalid byte sequence ("${i[a-2]}${i[a-1]}" in "${i}").`);n[o]=l*16+c}return n}function bD(s,e){const t=Uw(s,e);return Lw(t)}function zw(s,e={}){const t=mD.encode(s);return typeof e.size=="number"?(Mn(t,{size:e.size}),Tn(t,{dir:"right",size:e.size})):t}function sc(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function vD(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Xo(s,...e){if(!vD(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function ID(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");sc(s.outputLen),sc(s.blockLen)}function fh(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function Fw(s,e){Xo(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Ea=BigInt(2**32-1),Fp=BigInt(32);function ED(s,e=!1){return e?{h:Number(s&Ea),l:Number(s>>Fp&Ea)}:{h:Number(s>>Fp&Ea)|0,l:Number(s&Ea)|0}}function AD(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=ED(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const ND=(s,e,t)=>s<<t|e>>>32-t,_D=(s,e,t)=>e<<t|s>>>32-t,CD=(s,e,t)=>e<<t-32|s>>>64-t,SD=(s,e,t)=>s<<t-32|e>>>64-t,Ur=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */function $D(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function PD(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function TD(s,e){return s<<32-e|s>>>e}const qp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function MD(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Bp(s){for(let e=0;e<s.length;e++)s[e]=MD(s[e])}function xD(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function lu(s){return typeof s=="string"&&(s=xD(s)),Xo(s),s}function OD(...s){let e=0;for(let i=0;i<s.length;i++){const r=s[i];Xo(r),e+=r.length}const t=new Uint8Array(e);for(let i=0,r=0;i<s.length;i++){const n=s[i];t.set(n,r),r+=n.length}return t}class qw{clone(){return this._cloneInto()}}function Bw(s){const e=i=>s().update(lu(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function DD(s=32){if(Ur&&typeof Ur.getRandomValues=="function")return Ur.getRandomValues(new Uint8Array(s));if(Ur&&typeof Ur.randomBytes=="function")return Ur.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const Hw=[],Ww=[],Vw=[],kD=BigInt(0),Yn=BigInt(1),jD=BigInt(2),RD=BigInt(7),UD=BigInt(256),LD=BigInt(113);for(let s=0,e=Yn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],Hw.push(2*(5*i+t)),Ww.push((s+1)*(s+2)/2%64);let r=kD;for(let n=0;n<7;n++)e=(e<<Yn^(e>>RD)*LD)%UD,e&jD&&(r^=Yn<<(Yn<<BigInt(n))-Yn);Vw.push(r)}const[zD,FD]=AD(Vw,!0),Hp=(s,e,t)=>t>32?CD(s,e,t):ND(s,e,t),Wp=(s,e,t)=>t>32?SD(s,e,t):_D(s,e,t);function qD(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=Hp(c,h,1)^t[a],d=Wp(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=Ww[o],l=Hp(r,n,a),c=Wp(r,n,a),h=Hw[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=zD[i],s[1]^=FD[i]}t.fill(0)}class hu extends qw{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,sc(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=$D(this.state)}keccak(){qp||Bp(this.state32),qD(this.state32,this.rounds),qp||Bp(this.state32),this.posOut=0,this.pos=0}update(e){fh(this);const{blockLen:t,state:i}=this;e=lu(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){fh(this,!1),Xo(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return sc(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Fw(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new hu(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}}const BD=(s,e,t)=>Bw(()=>new hu(e,s,t)),HD=BD(1,136,256/8);function Kw(s,e){const t=e||"hex",i=HD(xo(s,{strict:!1})?wD(s):s);return t==="bytes"?i:gh(i)}class WD extends Map{constructor(e){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=e}get(e){const t=super.get(e);return super.has(e)&&t!==void 0&&(this.delete(e),super.set(e,t)),t}set(e,t){if(super.set(e,t),this.maxSize&&this.size>this.maxSize){const i=this.keys().next().value;i&&this.delete(i)}return this}}const dl=new WD(8192);function VD(s,e){if(dl.has(`${s}.${e}`))return dl.get(`${s}.${e}`);const t=s.substring(2).toLowerCase(),i=Kw(zw(t),"bytes"),r=t.split("");for(let o=0;o<40;o+=2)i[o>>1]>>4>=8&&r[o]&&(r[o]=r[o].toUpperCase()),(i[o>>1]&15)>=8&&r[o+1]&&(r[o+1]=r[o+1].toUpperCase());const n=`0x${r.join("")}`;return dl.set(`${s}.${e}`,n),n}function KD(s){const e=Kw(`0x${s.substring(4)}`).substring(26);return VD(`0x${e}`)}async function GD({hash:s,signature:e}){const t=xo(s)?s:gh(s),{secp256k1:i}=await Promise.resolve().then(()=>require("./secp256k1-CLJ0hFH7.js"));return`0x${(()=>{if(typeof e=="object"&&"r"in e&&"s"in e){const{r:c,s:h,v:u,yParity:d}=e,p=Number(d??u),g=Vp(p);return new i.Signature(ph(c),ph(h)).addRecoveryBit(g)}const o=xo(e)?e:gh(e),a=uD(`0x${o.slice(130)}`),l=Vp(a);return i.Signature.fromCompact(o.substring(2,130)).addRecoveryBit(l)})().recoverPublicKey(t.substring(2)).toHex(!1)}`}function Vp(s){if(s===0||s===1)return s;if(s===27)return 0;if(s===28)return 1;throw new Error("Invalid yParityOrV value")}async function YD({hash:s,signature:e}){return KD(await GD({hash:s,signature:e}))}function QD(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var ZD="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const Gw=QD(ZD),JD=":";function mn(s){const[e,t]=s.split(JD);return{namespace:e,reference:t}}function Yw(s,e){return s.includes(":")?[s]:e.chains||[]}const XD="ReactNative",cs={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},ek="js";function ic(){return typeof N.dist.process<"u"&&typeof N.dist.process.versions<"u"&&typeof N.dist.process.versions.node<"u"}function xi(){return!E.getDocument_1()&&!!E.getNavigator_1()&&navigator.product===XD}function tk(){return xi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="android"}function sk(){return xi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"&&(N.dist.global==null?void 0:N.dist.global.Platform.OS)==="ios"}function ea(){return!ic()&&!!E.getNavigator_1()&&!!E.getDocument_1()}function ta(){return xi()?cs.reactNative:ic()?cs.node:ea()?cs.browser:cs.unknown}function Kp(){var s;try{return xi()&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Application)<"u"?(s=N.dist.global.Application)==null?void 0:s.applicationId:void 0}catch{return}}function ik(s,e){const t=new URLSearchParams(s);for(const i of Object.keys(e).sort())if(e.hasOwnProperty(i)){const r=e[i];r!==void 0&&t.set(i,r)}return t.toString()}function Qw(){return E.getWindowMetadata_1()||{name:"",description:"",url:"",icons:[""]}}function rk(){if(ta()===cs.reactNative&&typeof N.dist.global<"u"&&typeof(N.dist.global==null?void 0:N.dist.global.Platform)<"u"){const{OS:t,Version:i}=N.dist.global.Platform;return[t,i].join("-")}const s=m.detect();if(s===null)return"unknown";const e=s.os?s.os.replace(" ","").toLowerCase():"unknown";return s.type==="browser"?[e,s.name,s.version].join("-"):[e,s.version].join("-")}function nk(){var s;const e=ta();return e===cs.browser?[e,((s=E.getLocation_1())==null?void 0:s.host)||"unknown"].join(":"):e}function Zw(s,e,t){const i=rk(),r=nk();return[[s,e].join("-"),[ek,t].join("-"),i,r].join("/")}function ok({protocol:s,version:e,relayUrl:t,sdkVersion:i,auth:r,projectId:n,useOnCloseEvent:o,bundleId:a,packageName:l}){const c=t.split("?"),h=Zw(s,e,i),u={auth:r,ua:h,projectId:n,useOnCloseEvent:o,packageName:l||void 0,bundleId:a||void 0},d=ik(c[1]||"",u);return c[0]+"?"+d}function Qi(s,e){return s.filter(t=>e.includes(t)).length===s.length}function mh(s){return Object.fromEntries(s.entries())}function wh(s){return new Map(Object.entries(s))}function Bi(s=E.cjs.FIVE_MINUTES,e){const t=E.cjs.toMiliseconds(s||E.cjs.FIVE_MINUTES);let i,r,n,o;return{resolve:a=>{n&&i&&(clearTimeout(n),i(a),o=Promise.resolve(a))},reject:a=>{n&&r&&(clearTimeout(n),r(a))},done:()=>new Promise((a,l)=>{if(o)return a(o);n=setTimeout(()=>{const c=new Error(e);o=Promise.reject(c),l(c)},t),i=a,r=l})}}function Ai(s,e,t){return new Promise(async(i,r)=>{const n=setTimeout(()=>r(new Error(t)),e);try{const o=await s;i(o)}catch(o){r(o)}clearTimeout(n)})}function Jw(s,e){if(typeof e=="string"&&e.startsWith(`${s}:`))return e;if(s.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(s.toLowerCase()==="id"){if(typeof e!="number")throw new Error('Value must be "number" for expirer target type: id');return`id:${e}`}throw new Error(`Unknown expirer target type: ${s}`)}function ak(s){return Jw("topic",s)}function ck(s){return Jw("id",s)}function Xw(s){const[e,t]=s.split(":"),i={id:void 0,topic:void 0};if(e==="topic"&&typeof t=="string")i.topic=t;else if(e==="id"&&Number.isInteger(Number(t)))i.id=Number(t);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${t}`);return i}function ct(s,e){return E.cjs.fromMiliseconds(Date.now()+E.cjs.toMiliseconds(s))}function wi(s){return Date.now()>=E.cjs.toMiliseconds(s)}function Ne(s,e){return`${s}${e?`:${e}`:""}`}function Fa(s=[],e=[]){return[...new Set([...s,...e])]}async function lk({id:s,topic:e,wcDeepLink:t}){var i;try{if(!t)return;const r=typeof t=="string"?JSON.parse(t):t,n=r==null?void 0:r.href;if(typeof n!="string")return;const o=hk(n,s,e),a=ta();if(a===cs.browser){if(!((i=E.getDocument_1())!=null&&i.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}uk(o)}else a===cs.reactNative&&typeof(N.dist.global==null?void 0:N.dist.global.Linking)<"u"&&await N.dist.global.Linking.openURL(o)}catch(r){console.error(r)}}function hk(s,e,t){const i=`requestId=${e}&sessionTopic=${t}`;s.endsWith("/")&&(s=s.slice(0,-1));let r=`${s}`;if(s.startsWith("https://t.me")){const n=s.includes("?")?"&startapp=":"?startapp=";r=`${r}${n}${fk(i,!0)}`}else r=`${r}/wc?${i}`;return r}function uk(s){let e="_self";gk()?e="_top":(pk()||s.startsWith("https://")||s.startsWith("http://"))&&(e="_blank"),window.open(s,e,"noreferrer noopener")}async function dk(s,e){let t="";try{if(ea()&&(t=localStorage.getItem(e),t))return t;t=await s.getItem(e)}catch(i){console.error(i)}return t}function Gp(s,e){if(!s.includes(e))return null;const t=s.split(/([&,?,=])/),i=t.indexOf(e);return t[i+2]}function Yp(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,s=>{const e=Math.random()*16|0;return(s==="x"?e:e&3|8).toString(16)})}function uu(){return typeof N.dist.process<"u"&&N.dist.process.env.IS_VITEST==="true"}function pk(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function gk(){try{return window.self!==window.top}catch{return!1}}function fk(s,e=!1){const t=N.dist.Buffer.from(s).toString("base64");return e?t.replace(/[=]/g,""):t}function ey(s){return N.dist.Buffer.from(s,"base64").toString("utf-8")}function mk(s){return new Promise(e=>setTimeout(e,s))}function Oo(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function wk(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function Pc(s,...e){if(!wk(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function du(s){if(typeof s!="function"||typeof s.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Oo(s.outputLen),Oo(s.blockLen)}function In(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function ty(s,e){Pc(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}const Aa=BigInt(2**32-1),Qp=BigInt(32);function yk(s,e=!1){return e?{h:Number(s&Aa),l:Number(s>>Qp&Aa)}:{h:Number(s>>Qp&Aa)|0,l:Number(s&Aa)|0}}function bk(s,e=!1){let t=new Uint32Array(s.length),i=new Uint32Array(s.length);for(let r=0;r<s.length;r++){const{h:n,l:o}=yk(s[r],e);[t[r],i[r]]=[n,o]}return[t,i]}const vk=(s,e,t)=>s<<t|e>>>32-t,Ik=(s,e,t)=>e<<t|s>>>32-t,Ek=(s,e,t)=>e<<t-32|s>>>64-t,Ak=(s,e,t)=>s<<t-32|e>>>64-t,Lr=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Nk(s){return new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4))}function pl(s){return new DataView(s.buffer,s.byteOffset,s.byteLength)}function Us(s,e){return s<<32-e|s>>>e}const Zp=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function _k(s){return s<<24&4278190080|s<<8&16711680|s>>>8&65280|s>>>24&255}function Jp(s){for(let e=0;e<s.length;e++)s[e]=_k(s[e])}function Ck(s){if(typeof s!="string")throw new Error("utf8ToBytes expected string, got "+typeof s);return new Uint8Array(new TextEncoder().encode(s))}function En(s){return typeof s=="string"&&(s=Ck(s)),Pc(s),s}let pu=class{clone(){return this._cloneInto()}};function sy(s){const e=i=>s().update(En(i)).digest(),t=s();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>s(),e}function sa(s=32){if(Lr&&typeof Lr.getRandomValues=="function")return Lr.getRandomValues(new Uint8Array(s));if(Lr&&typeof Lr.randomBytes=="function")return Lr.randomBytes(s);throw new Error("crypto.getRandomValues must be defined")}const iy=[],ry=[],ny=[],Sk=BigInt(0),Qn=BigInt(1),$k=BigInt(2),Pk=BigInt(7),Tk=BigInt(256),Mk=BigInt(113);for(let s=0,e=Qn,t=1,i=0;s<24;s++){[t,i]=[i,(2*t+3*i)%5],iy.push(2*(5*i+t)),ry.push((s+1)*(s+2)/2%64);let r=Sk;for(let n=0;n<7;n++)e=(e<<Qn^(e>>Pk)*Mk)%Tk,e&$k&&(r^=Qn<<(Qn<<BigInt(n))-Qn);ny.push(r)}const[xk,Ok]=bk(ny,!0),Xp=(s,e,t)=>t>32?Ek(s,e,t):vk(s,e,t),eg=(s,e,t)=>t>32?Ak(s,e,t):Ik(s,e,t);function Dk(s,e=24){const t=new Uint32Array(10);for(let i=24-e;i<24;i++){for(let o=0;o<10;o++)t[o]=s[o]^s[o+10]^s[o+20]^s[o+30]^s[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],h=t[l+1],u=Xp(c,h,1)^t[a],d=eg(c,h,1)^t[a+1];for(let p=0;p<50;p+=10)s[o+p]^=u,s[o+p+1]^=d}let r=s[2],n=s[3];for(let o=0;o<24;o++){const a=ry[o],l=Xp(r,n,a),c=eg(r,n,a),h=iy[o];r=s[h],n=s[h+1],s[h]=l,s[h+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=s[o+a];for(let a=0;a<10;a++)s[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}s[0]^=xk[i],s[1]^=Ok[i]}t.fill(0)}let kk=class oy extends pu{constructor(e,t,i,r=!1,n=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=i,this.enableXOF=r,this.rounds=n,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Oo(i),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=Nk(this.state)}keccak(){Zp||Jp(this.state32),Dk(this.state32,this.rounds),Zp||Jp(this.state32),this.posOut=0,this.pos=0}update(e){In(this);const{blockLen:t,state:i}=this;e=En(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(t-this.pos,r-n);for(let a=0;a<o;a++)i[this.pos++]^=e[n++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:i,blockLen:r}=this;e[i]^=t,t&128&&i===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){In(this,!1),Pc(e),this.finish();const t=this.state,{blockLen:i}=this;for(let r=0,n=e.length;r<n;){this.posOut>=i&&this.keccak();const o=Math.min(i-this.posOut,n-r);e.set(t.subarray(this.posOut,this.posOut+o),r),this.posOut+=o,r+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Oo(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(ty(e,this),this.finished)throw new Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){const{blockLen:t,suffix:i,outputLen:r,rounds:n,enableXOF:o}=this;return e||(e=new oy(t,i,r,o,n)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=n,e.suffix=i,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const jk=(s,e,t)=>sy(()=>new kk(e,s,t)),Rk=jk(1,136,256/8),Uk="https://rpc.walletconnect.org/v1";function ay(s){const e=`Ethereum Signed Message:
|
|
13
13
|
${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+N.dist.Buffer.from(Rk(t)).toString("hex")}async function Lk(s,e,t,i,r,n){switch(t.t){case"eip191":return await zk(s,e,t.s);case"eip1271":return await Fk(s,e,t.s,i,r,n);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${t.t}`)}}async function zk(s,e,t){return(await YD({hash:ay(e),signature:t})).toLowerCase()===s.toLowerCase()}async function Fk(s,e,t,i,r,n){const o=mn(i);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${i}`);try{const a="0x1626ba7e",l="0000000000000000000000000000000000000000000000000000000000000040",c="0000000000000000000000000000000000000000000000000000000000000041",h=t.substring(2),u=ay(e).substring(2),d=a+u+l+c+h,p=await fetch(`${n||Uk}/?chainId=${i}&projectId=${r}`,{method:"POST",body:JSON.stringify({id:qk(),jsonrpc:"2.0",method:"eth_call",params:[{to:s,data:d},"latest"]})}),{result:g}=await p.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function qk(){return Date.now()+Math.floor(Math.random()*1e3)}function Bk(s){const e=atob(s),t=new Uint8Array(e.length);for(let o=0;o<e.length;o++)t[o]=e.charCodeAt(o);const i=t[0];if(i===0)throw new Error("No signatures found");const r=1+i*64;if(t.length<r)throw new Error("Transaction data too short for claimed signature count");if(t.length<100)throw new Error("Transaction too short");const n=N.dist.Buffer.from(s,"base64").slice(1,65);return Gw.encode(n)}var Hk=Object.defineProperty,Wk=Object.defineProperties,Vk=Object.getOwnPropertyDescriptors,tg=Object.getOwnPropertySymbols,Kk=Object.prototype.hasOwnProperty,Gk=Object.prototype.propertyIsEnumerable,sg=(s,e,t)=>e in s?Hk(s,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):s[e]=t,Yk=(s,e)=>{for(var t in e||(e={}))Kk.call(e,t)&&sg(s,t,e[t]);if(tg)for(var t of tg(e))Gk.call(e,t)&&sg(s,t,e[t]);return s},Qk=(s,e)=>Wk(s,Vk(e));const Zk="did:pkh:",gu=s=>s==null?void 0:s.split(":"),Jk=s=>{const e=s&&gu(s);if(e)return s.includes(Zk)?e[3]:e[1]},yh=s=>{const e=s&&gu(s);if(e)return e[2]+":"+e[3]},rc=s=>{const e=s&&gu(s);if(e)return e.pop()};async function ig(s){const{cacao:e,projectId:t}=s,{s:i,p:r}=e,n=cy(r,r.iss),o=rc(r.iss);return await Lk(o,n,i,yh(r.iss),t)}const cy=(s,e)=>{const t=`${s.domain} wants you to sign in with your Ethereum account:`,i=rc(e);if(!s.aud&&!s.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=s.statement||void 0;const n=`URI: ${s.aud||s.uri}`,o=`Version: ${s.version}`,a=`Chain ID: ${Jk(e)}`,l=`Nonce: ${s.nonce}`,c=`Issued At: ${s.iat}`,h=s.exp?`Expiration Time: ${s.exp}`:void 0,u=s.nbf?`Not Before: ${s.nbf}`:void 0,d=s.requestId?`Request ID: ${s.requestId}`:void 0,p=s.resources?`Resources:${s.resources.map(f=>`
|
|
14
14
|
- ${f}`).join("")}`:void 0,g=qa(s.resources);if(g){const f=Do(g);r=aj(r,f)}return[t,i,"",r,"",n,o,a,l,c,h,u,d,p].filter(f=>f!=null).join(`
|
|
15
15
|
`)};function Xk(s){return N.dist.Buffer.from(JSON.stringify(s)).toString("base64")}function ej(s){return JSON.parse(N.dist.Buffer.from(s,"base64").toString("utf-8"))}function ar(s){if(!s)throw new Error("No recap provided, value is undefined");if(!s.att)throw new Error("No `att` property found");const e=Object.keys(s.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(t=>{const i=s.att[t];if(Array.isArray(i))throw new Error(`Resource must be an object: ${t}`);if(typeof i!="object")throw new Error(`Resource must be an object: ${t}`);if(!Object.keys(i).length)throw new Error(`Resource object is empty: ${t}`);Object.keys(i).forEach(r=>{const n=i[r];if(!Array.isArray(n))throw new Error(`Ability limits ${r} must be an array of objects, found: ${n}`);if(!n.length)throw new Error(`Value of ${r} is empty array, must be an array with objects`);n.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${r}) must be an array of objects, found: ${o}`)})})})}function tj(s,e,t,i={}){return t==null||t.sort((r,n)=>r.localeCompare(n)),{att:{[s]:sj(e,t,i)}}}function sj(s,e,t={}){e=e==null?void 0:e.sort((r,n)=>r.localeCompare(n));const i=e.map(r=>({[`${s}/${r}`]:[t]}));return Object.assign({},...i)}function ly(s){return ar(s),`urn:recap:${Xk(s).replace(/=/g,"")}`}function Do(s){const e=ej(s.replace("urn:recap:",""));return ar(e),e}function ij(s,e,t){const i=tj(s,e,t);return ly(i)}function rj(s){return s&&s.includes("urn:recap:")}function nj(s,e){const t=Do(s),i=Do(e),r=oj(t,i);return ly(r)}function oj(s,e){ar(s),ar(e);const t=Object.keys(s.att).concat(Object.keys(e.att)).sort((r,n)=>r.localeCompare(n)),i={att:{}};return t.forEach(r=>{var n,o;Object.keys(((n=s.att)==null?void 0:n[r])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[r])||{})).sort((a,l)=>a.localeCompare(l)).forEach(a=>{var l,c;i.att[r]=Qk(Yk({},i.att[r]),{[a]:((l=s.att[r])==null?void 0:l[a])||((c=e.att[r])==null?void 0:c[a])})})}),i}function aj(s="",e){ar(e);const t="I further authorize the stated URI to perform the following actions on my behalf: ";if(s.includes(t))return s;const i=[];let r=0;Object.keys(e.att).forEach(a=>{const l=Object.keys(e.att[a]).map(u=>({ability:u.split("/")[0],action:u.split("/")[1]}));l.sort((u,d)=>u.action.localeCompare(d.action));const c={};l.forEach(u=>{c[u.ability]||(c[u.ability]=[]),c[u.ability].push(u.action)});const h=Object.keys(c).map(u=>(r++,`(${r}) '${u}': '${c[u].join("', '")}' for '${a}'.`));i.push(h.join(", ").replace(".,","."))});const n=i.join(" "),o=`${t}${n}`;return`${s?s+" ":""}${o}`}function rg(s){var e;const t=Do(s);ar(t);const i=(e=t.att)==null?void 0:e.eip155;return i?Object.keys(i).map(r=>r.split("/")[1]):[]}function ng(s){const e=Do(s);ar(e);const t=[];return Object.values(e.att).forEach(i=>{Object.values(i).forEach(r=>{var n;(n=r==null?void 0:r[0])!=null&&n.chains&&t.push(r[0].chains)})}),[...new Set(t.flat())]}function qa(s){if(!s)return;const e=s==null?void 0:s[s.length-1];return rj(e)?e:void 0}function gl(s){if(!Number.isSafeInteger(s)||s<0)throw new Error("positive integer expected, got "+s)}function hy(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function os(s,...e){if(!hy(s))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(s.length))throw new Error("Uint8Array expected of length "+e+", got length="+s.length)}function og(s,e=!0){if(s.destroyed)throw new Error("Hash instance has been destroyed");if(e&&s.finished)throw new Error("Hash#digest() has already been called")}function cj(s,e){os(s);const t=e.outputLen;if(s.length<t)throw new Error("digestInto() expects output buffer of length at least "+t)}function ag(s){if(typeof s!="boolean")throw new Error(`boolean expected, not ${s}`)}const Ci=s=>new Uint32Array(s.buffer,s.byteOffset,Math.floor(s.byteLength/4)),lj=s=>new DataView(s.buffer,s.byteOffset,s.byteLength),hj=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;if(!hj)throw new Error("Non little-endian hardware is not supported");function uj(s){if(typeof s!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(s))}function bh(s){if(typeof s=="string")s=uj(s);else if(hy(s))s=vh(s);else throw new Error("Uint8Array expected, got "+typeof s);return s}function dj(s,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(s,e)}function pj(s,e){if(s.length!==e.length)return!1;let t=0;for(let i=0;i<s.length;i++)t|=s[i]^e[i];return t===0}const gj=(s,e)=>{function t(i,...r){if(os(i),s.nonceLength!==void 0){const c=r[0];if(!c)throw new Error("nonce / iv required");s.varSizeNonce?os(c):os(c,s.nonceLength)}const n=s.tagLength;n&&r[1]!==void 0&&os(r[1]);const o=e(i,...r),a=(c,h)=>{if(h!==void 0){if(c!==2)throw new Error("cipher output not supported");os(h)}};let l=!1;return{encrypt(c,h){if(l)throw new Error("cannot encrypt() twice with same key + nonce");return l=!0,os(c),a(o.encrypt.length,h),o.encrypt(c,h)},decrypt(c,h){if(os(c),n&&c.length<n)throw new Error("invalid ciphertext length: smaller than tagLength="+n);return a(o.decrypt.length,h),o.decrypt(c,h)}}}return Object.assign(t,s),t};function cg(s,e,t=!0){if(e===void 0)return new Uint8Array(s);if(e.length!==s)throw new Error("invalid output length, expected "+s+", got: "+e.length);if(t&&!fj(e))throw new Error("invalid output, must be aligned");return e}function lg(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n);s.setUint32(e+4,o,i),s.setUint32(e+0,a,i)}function fj(s){return s.byteOffset%4===0}function vh(s){return Uint8Array.from(s)}function An(...s){for(let e=0;e<s.length;e++)s[e].fill(0)}const uy=s=>Uint8Array.from(s.split("").map(e=>e.charCodeAt(0))),mj=uy("expand 16-byte k"),wj=uy("expand 32-byte k"),yj=Ci(mj),bj=Ci(wj);function me(s,e){return s<<e|s>>>32-e}function Ih(s){return s.byteOffset%4===0}const Na=64,vj=16,dy=2**32-1,hg=new Uint32Array;function Ij(s,e,t,i,r,n,o,a){const l=r.length,c=new Uint8Array(Na),h=Ci(c),u=Ih(r)&&Ih(n),d=u?Ci(r):hg,p=u?Ci(n):hg;for(let g=0;g<l;o++){if(s(e,t,i,h,o,a),o>=dy)throw new Error("arx: counter overflow");const f=Math.min(Na,l-g);if(u&&f===Na){const b=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let y=0,w;y<vj;y++)w=b+y,p[w]=d[w]^h[y];g+=Na;continue}for(let b=0,y;b<f;b++)y=g+b,n[y]=r[y]^c[b];g+=f}}function Ej(s,e){const{allowShortKeys:t,extendNonceFn:i,counterLength:r,counterRight:n,rounds:o}=dj({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof s!="function")throw new Error("core must be a function");return gl(r),gl(o),ag(n),ag(t),(a,l,c,h,u=0)=>{os(a),os(l),os(c);const d=c.length;if(h===void 0&&(h=new Uint8Array(d)),os(h),gl(u),u<0||u>=dy)throw new Error("arx: counter overflow");if(h.length<d)throw new Error(`arx: output (${h.length}) is shorter than data (${d})`);const p=[];let g=a.length,f,b;if(g===32)p.push(f=vh(a)),b=bj;else if(g===16&&t)f=new Uint8Array(32),f.set(a),f.set(a,16),b=yj,p.push(f);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);Ih(l)||p.push(l=vh(l));const y=Ci(f);if(i){if(l.length!==24)throw new Error("arx: extended nonce must be 24 bytes");i(b,y,Ci(l.subarray(0,16)),y),l=l.subarray(16)}const w=16-r;if(w!==l.length)throw new Error(`arx: nonce must be ${w} or 16 bytes`);if(w!==12){const A=new Uint8Array(12);A.set(l,n?0:12-l.length),l=A,p.push(l)}const v=Ci(l);return Ij(s,b,y,v,c,h,u,o),An(...p),h}}const Nt=(s,e)=>s[e++]&255|(s[e++]&255)<<8;let Aj=class{constructor(e){this.blockLen=16,this.outputLen=16,this.buffer=new Uint8Array(16),this.r=new Uint16Array(10),this.h=new Uint16Array(10),this.pad=new Uint16Array(8),this.pos=0,this.finished=!1,e=bh(e),os(e,32);const t=Nt(e,0),i=Nt(e,2),r=Nt(e,4),n=Nt(e,6),o=Nt(e,8),a=Nt(e,10),l=Nt(e,12),c=Nt(e,14);this.r[0]=t&8191,this.r[1]=(t>>>13|i<<3)&8191,this.r[2]=(i>>>10|r<<6)&7939,this.r[3]=(r>>>7|n<<9)&8191,this.r[4]=(n>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|l<<5)&8065,this.r[8]=(l>>>8|c<<8)&8191,this.r[9]=c>>>5&127;for(let h=0;h<8;h++)this.pad[h]=Nt(e,16+2*h)}process(e,t,i=!1){const r=i?0:2048,{h:n,r:o}=this,a=o[0],l=o[1],c=o[2],h=o[3],u=o[4],d=o[5],p=o[6],g=o[7],f=o[8],b=o[9],y=Nt(e,t+0),w=Nt(e,t+2),v=Nt(e,t+4),A=Nt(e,t+6),C=Nt(e,t+8),P=Nt(e,t+10),T=Nt(e,t+12),O=Nt(e,t+14);let S=n[0]+(y&8191),M=n[1]+((y>>>13|w<<3)&8191),$=n[2]+((w>>>10|v<<6)&8191),U=n[3]+((v>>>7|A<<9)&8191),L=n[4]+((A>>>4|C<<12)&8191),B=n[5]+(C>>>1&8191),H=n[6]+((C>>>14|P<<2)&8191),z=n[7]+((P>>>11|T<<5)&8191),W=n[8]+((T>>>8|O<<8)&8191),V=n[9]+(O>>>5|r),_=0,F=_+S*a+M*(5*b)+$*(5*f)+U*(5*g)+L*(5*p);_=F>>>13,F&=8191,F+=B*(5*d)+H*(5*u)+z*(5*h)+W*(5*c)+V*(5*l),_+=F>>>13,F&=8191;let Q=_+S*l+M*a+$*(5*b)+U*(5*f)+L*(5*g);_=Q>>>13,Q&=8191,Q+=B*(5*p)+H*(5*d)+z*(5*u)+W*(5*h)+V*(5*c),_+=Q>>>13,Q&=8191;let G=_+S*c+M*l+$*a+U*(5*b)+L*(5*f);_=G>>>13,G&=8191,G+=B*(5*g)+H*(5*p)+z*(5*d)+W*(5*u)+V*(5*h),_+=G>>>13,G&=8191;let Ie=_+S*h+M*c+$*l+U*a+L*(5*b);_=Ie>>>13,Ie&=8191,Ie+=B*(5*f)+H*(5*g)+z*(5*p)+W*(5*d)+V*(5*u),_+=Ie>>>13,Ie&=8191;let ce=_+S*u+M*h+$*c+U*l+L*a;_=ce>>>13,ce&=8191,ce+=B*(5*b)+H*(5*f)+z*(5*g)+W*(5*p)+V*(5*d),_+=ce>>>13,ce&=8191;let xe=_+S*d+M*u+$*h+U*c+L*l;_=xe>>>13,xe&=8191,xe+=B*a+H*(5*b)+z*(5*f)+W*(5*g)+V*(5*p),_+=xe>>>13,xe&=8191;let nt=_+S*p+M*d+$*u+U*h+L*c;_=nt>>>13,nt&=8191,nt+=B*l+H*a+z*(5*b)+W*(5*f)+V*(5*g),_+=nt>>>13,nt&=8191;let qe=_+S*g+M*p+$*d+U*u+L*h;_=qe>>>13,qe&=8191,qe+=B*c+H*l+z*a+W*(5*b)+V*(5*f),_+=qe>>>13,qe&=8191;let Ye=_+S*f+M*g+$*p+U*d+L*u;_=Ye>>>13,Ye&=8191,Ye+=B*h+H*c+z*l+W*a+V*(5*b),_+=Ye>>>13,Ye&=8191;let Be=_+S*b+M*f+$*g+U*p+L*d;_=Be>>>13,Be&=8191,Be+=B*u+H*h+z*c+W*l+V*a,_+=Be>>>13,Be&=8191,_=(_<<2)+_|0,_=_+F|0,F=_&8191,_=_>>>13,Q+=_,n[0]=F,n[1]=Q,n[2]=G,n[3]=Ie,n[4]=ce,n[5]=xe,n[6]=nt,n[7]=qe,n[8]=Ye,n[9]=Be}finalize(){const{h:e,pad:t}=this,i=new Uint16Array(10);let r=e[1]>>>13;e[1]&=8191;for(let a=2;a<10;a++)e[a]+=r,r=e[a]>>>13,e[a]&=8191;e[0]+=r*5,r=e[0]>>>13,e[0]&=8191,e[1]+=r,r=e[1]>>>13,e[1]&=8191,e[2]+=r,i[0]=e[0]+5,r=i[0]>>>13,i[0]&=8191;for(let a=1;a<10;a++)i[a]=e[a]+r,r=i[a]>>>13,i[a]&=8191;i[9]-=8192;let n=(r^1)-1;for(let a=0;a<10;a++)i[a]&=n;n=~n;for(let a=0;a<10;a++)e[a]=e[a]&n|i[a];e[0]=(e[0]|e[1]<<13)&65535,e[1]=(e[1]>>>3|e[2]<<10)&65535,e[2]=(e[2]>>>6|e[3]<<7)&65535,e[3]=(e[3]>>>9|e[4]<<4)&65535,e[4]=(e[4]>>>12|e[5]<<1|e[6]<<14)&65535,e[5]=(e[6]>>>2|e[7]<<11)&65535,e[6]=(e[7]>>>5|e[8]<<8)&65535,e[7]=(e[8]>>>8|e[9]<<5)&65535;let o=e[0]+t[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+t[a]|0)+(o>>>16)|0,e[a]=o&65535;An(i)}update(e){og(this);const{buffer:t,blockLen:i}=this;e=bh(e);const r=e.length;for(let n=0;n<r;){const o=Math.min(i-this.pos,r-n);if(o===i){for(;i<=r-n;n+=i)this.process(e,n);continue}t.set(e.subarray(n,n+o),this.pos),this.pos+=o,n+=o,this.pos===i&&(this.process(t,0,!1),this.pos=0)}return this}destroy(){An(this.h,this.r,this.buffer,this.pad)}digestInto(e){og(this),cj(e,this),this.finished=!0;const{buffer:t,h:i}=this;let{pos:r}=this;if(r){for(t[r++]=1;r<16;r++)t[r]=0;this.process(t,0,!0)}this.finalize();let n=0;for(let o=0;o<8;o++)e[n++]=i[o]>>>0,e[n++]=i[o]>>>8;return e}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}};function Nj(s){const e=(i,r)=>s(r).update(bh(i)).digest(),t=s(new Uint8Array(32));return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=i=>s(i),e}const _j=Nj(s=>new Aj(s));function Cj(s,e,t,i,r,n=20){let o=s[0],a=s[1],l=s[2],c=s[3],h=e[0],u=e[1],d=e[2],p=e[3],g=e[4],f=e[5],b=e[6],y=e[7],w=r,v=t[0],A=t[1],C=t[2],P=o,T=a,O=l,S=c,M=h,$=u,U=d,L=p,B=g,H=f,z=b,W=y,V=w,_=v,F=A,Q=C;for(let Ie=0;Ie<n;Ie+=2)P=P+M|0,V=me(V^P,16),B=B+V|0,M=me(M^B,12),P=P+M|0,V=me(V^P,8),B=B+V|0,M=me(M^B,7),T=T+$|0,_=me(_^T,16),H=H+_|0,$=me($^H,12),T=T+$|0,_=me(_^T,8),H=H+_|0,$=me($^H,7),O=O+U|0,F=me(F^O,16),z=z+F|0,U=me(U^z,12),O=O+U|0,F=me(F^O,8),z=z+F|0,U=me(U^z,7),S=S+L|0,Q=me(Q^S,16),W=W+Q|0,L=me(L^W,12),S=S+L|0,Q=me(Q^S,8),W=W+Q|0,L=me(L^W,7),P=P+$|0,Q=me(Q^P,16),z=z+Q|0,$=me($^z,12),P=P+$|0,Q=me(Q^P,8),z=z+Q|0,$=me($^z,7),T=T+U|0,V=me(V^T,16),W=W+V|0,U=me(U^W,12),T=T+U|0,V=me(V^T,8),W=W+V|0,U=me(U^W,7),O=O+L|0,_=me(_^O,16),B=B+_|0,L=me(L^B,12),O=O+L|0,_=me(_^O,8),B=B+_|0,L=me(L^B,7),S=S+M|0,F=me(F^S,16),H=H+F|0,M=me(M^H,12),S=S+M|0,F=me(F^S,8),H=H+F|0,M=me(M^H,7);let G=0;i[G++]=o+P|0,i[G++]=a+T|0,i[G++]=l+O|0,i[G++]=c+S|0,i[G++]=h+M|0,i[G++]=u+$|0,i[G++]=d+U|0,i[G++]=p+L|0,i[G++]=g+B|0,i[G++]=f+H|0,i[G++]=b+z|0,i[G++]=y+W|0,i[G++]=w+V|0,i[G++]=v+_|0,i[G++]=A+F|0,i[G++]=C+Q|0}const Sj=Ej(Cj,{counterRight:!1,counterLength:4,allowShortKeys:!1}),$j=new Uint8Array(16),ug=(s,e)=>{s.update(e);const t=e.length%16;t&&s.update($j.subarray(t))},Pj=new Uint8Array(32);function dg(s,e,t,i,r){const n=s(e,t,Pj),o=_j.create(n);r&&ug(o,r),ug(o,i);const a=new Uint8Array(16),l=lj(a);lg(l,0,BigInt(r?r.length:0),!0),lg(l,8,BigInt(i.length),!0),o.update(a);const c=o.digest();return An(n,a),c}const Tj=s=>(e,t,i)=>({encrypt(r,n){const o=r.length;n=cg(o+16,n,!1),n.set(r);const a=n.subarray(0,-16);s(e,t,a,a,1);const l=dg(s,e,t,a,i);return n.set(l,o),An(l),n},decrypt(r,n){n=cg(r.length-16,n,!1);const o=r.subarray(0,-16),a=r.subarray(-16),l=dg(s,e,t,o,i);if(!pj(a,l))throw new Error("invalid tag");return n.set(r.subarray(0,-16)),s(e,t,n,n,1),An(l),n}}),py=gj({blockSize:64,nonceLength:12,tagLength:16},Tj(Sj));let gy=class extends pu{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,du(e);const i=En(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const r=this.blockLen,n=new Uint8Array(r);n.set(i.length>r?e.create().update(i).digest():i);for(let o=0;o<n.length;o++)n[o]^=54;this.iHash.update(n),this.oHash=e.create();for(let o=0;o<n.length;o++)n[o]^=106;this.oHash.update(n),n.fill(0)}update(e){return In(this),this.iHash.update(e),this}digestInto(e){In(this),Pc(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:i,finished:r,destroyed:n,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=n,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=i._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const fu=(s,e,t)=>new gy(s,e).update(t).digest();fu.create=(s,e)=>new gy(s,e);function Mj(s,e,t){return du(s),t===void 0&&(t=new Uint8Array(s.outputLen)),fu(s,En(t),En(e))}const fl=new Uint8Array([0]),pg=new Uint8Array;function xj(s,e,t,i=32){if(du(s),Oo(i),i>255*s.outputLen)throw new Error("Length should be <= 255*HashLen");const r=Math.ceil(i/s.outputLen);t===void 0&&(t=pg);const n=new Uint8Array(r*s.outputLen),o=fu.create(s,e),a=o._cloneInto(),l=new Uint8Array(o.outputLen);for(let c=0;c<r;c++)fl[0]=c+1,a.update(c===0?pg:l).update(t).update(fl).digestInto(l),n.set(l,s.outputLen*c),o._cloneInto(a);return o.destroy(),a.destroy(),l.fill(0),fl.fill(0),n.slice(0,i)}const Oj=(s,e,t,i,r)=>xj(s,Mj(s,e,t),i,r);function Dj(s,e,t,i){if(typeof s.setBigUint64=="function")return s.setBigUint64(e,t,i);const r=BigInt(32),n=BigInt(4294967295),o=Number(t>>r&n),a=Number(t&n),l=i?4:0,c=i?0:4;s.setUint32(e+l,o,i),s.setUint32(e+c,a,i)}function kj(s,e,t){return s&e^~s&t}function jj(s,e,t){return s&e^s&t^e&t}class Rj extends pu{constructor(e,t,i,r){super(),this.blockLen=e,this.outputLen=t,this.padOffset=i,this.isLE=r,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=pl(this.buffer)}update(e){In(this);const{view:t,buffer:i,blockLen:r}=this;e=En(e);const n=e.length;for(let o=0;o<n;){const a=Math.min(r-this.pos,n-o);if(a===r){const l=pl(e);for(;r<=n-o;o+=r)this.process(l,o);continue}i.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){In(this),ty(e,this),this.finished=!0;const{buffer:t,view:i,blockLen:r,isLE:n}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>r-o&&(this.process(i,0),o=0);for(let u=o;u<r;u++)t[u]=0;Dj(i,r-8,BigInt(this.length*8),n),this.process(i,0);const a=pl(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,h=this.get();if(c>h.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<c;u++)a.setUint32(4*u,h[u],n)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const i=e.slice(0,t);return this.destroy(),i}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:i,length:r,finished:n,destroyed:o,pos:a}=this;return e.length=r,e.pos=a,e.finished=n,e.destroyed=o,r%t&&e.buffer.set(i),e}}const Uj=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),hi=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ui=new Uint32Array(64);let Lj=class extends Rj{constructor(){super(64,32,8,!1),this.A=hi[0]|0,this.B=hi[1]|0,this.C=hi[2]|0,this.D=hi[3]|0,this.E=hi[4]|0,this.F=hi[5]|0,this.G=hi[6]|0,this.H=hi[7]|0}get(){const{A:e,B:t,C:i,D:r,E:n,F:o,G:a,H:l}=this;return[e,t,i,r,n,o,a,l]}set(e,t,i,r,n,o,a,l){this.A=e|0,this.B=t|0,this.C=i|0,this.D=r|0,this.E=n|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let u=0;u<16;u++,t+=4)ui[u]=e.getUint32(t,!1);for(let u=16;u<64;u++){const d=ui[u-15],p=ui[u-2],g=Us(d,7)^Us(d,18)^d>>>3,f=Us(p,17)^Us(p,19)^p>>>10;ui[u]=f+ui[u-7]+g+ui[u-16]|0}let{A:i,B:r,C:n,D:o,E:a,F:l,G:c,H:h}=this;for(let u=0;u<64;u++){const d=Us(a,6)^Us(a,11)^Us(a,25),p=h+d+kj(a,l,c)+Uj[u]+ui[u]|0,g=(Us(i,2)^Us(i,13)^Us(i,22))+jj(i,r,n)|0;h=c,c=l,l=a,a=o+p|0,o=n,n=r,r=i,i=p+g|0}i=i+this.A|0,r=r+this.B|0,n=n+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,h=h+this.H|0,this.set(i,r,n,o,a,l,c,h)}roundClean(){ui.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}};const Tc=sy(()=>new Lj);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const fy=BigInt(0);function mu(s){return s instanceof Uint8Array||ArrayBuffer.isView(s)&&s.constructor.name==="Uint8Array"}function my(s){if(!mu(s))throw new Error("Uint8Array expected")}const zj=Array.from({length:256},(s,e)=>e.toString(16).padStart(2,"0"));function Fj(s){my(s);let e="";for(let t=0;t<s.length;t++)e+=zj[s[t]];return e}function qj(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);return s===""?fy:BigInt("0x"+s)}const Js={_0:48,_9:57,A:65,F:70,a:97,f:102};function gg(s){if(s>=Js._0&&s<=Js._9)return s-Js._0;if(s>=Js.A&&s<=Js.F)return s-(Js.A-10);if(s>=Js.a&&s<=Js.f)return s-(Js.a-10)}function wy(s){if(typeof s!="string")throw new Error("hex string expected, got "+typeof s);const e=s.length,t=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const i=new Uint8Array(t);for(let r=0,n=0;r<t;r++,n+=2){const o=gg(s.charCodeAt(n)),a=gg(s.charCodeAt(n+1));if(o===void 0||a===void 0){const l=s[n]+s[n+1];throw new Error('hex string expected, got non-hex character "'+l+'" at index '+n)}i[r]=o*16+a}return i}function fg(s){return my(s),qj(Fj(Uint8Array.from(s).reverse()))}function Bj(s,e){return wy(s.toString(16).padStart(e*2,"0"))}function Hj(s,e){return Bj(s,e).reverse()}function mg(s,e,t){let i;if(typeof e=="string")try{i=wy(e)}catch(n){throw new Error(s+" must be hex string or Uint8Array, cause: "+n)}else if(mu(e))i=Uint8Array.from(e);else throw new Error(s+" must be hex string or Uint8Array");const r=i.length;if(typeof t=="number"&&r!==t)throw new Error(s+" of length "+t+" expected, got "+r);return i}const ml=s=>typeof s=="bigint"&&fy<=s;function Wj(s,e,t){return ml(s)&&ml(e)&&ml(t)&&e<=s&&s<t}function wg(s,e,t,i){if(!Wj(e,t,i))throw new Error("expected valid "+s+": "+t+" <= n < "+i+", got "+e)}const Vj={bigint:s=>typeof s=="bigint",function:s=>typeof s=="function",boolean:s=>typeof s=="boolean",string:s=>typeof s=="string",stringOrUint8Array:s=>typeof s=="string"||mu(s),isSafeInteger:s=>Number.isSafeInteger(s),array:s=>Array.isArray(s),field:(s,e)=>e.Fp.isValid(s),hash:s=>typeof s=="function"&&Number.isSafeInteger(s.outputLen)};function Kj(s,e,t={}){const i=(r,n,o)=>{const a=Vj[n];if(typeof a!="function")throw new Error("invalid validator function");const l=s[r];if(!(o&&l===void 0)&&!a(l,s))throw new Error("param "+String(r)+" is invalid. Expected "+n+", got "+l)};for(const[r,n]of Object.entries(e))i(r,n,!1);for(const[r,n]of Object.entries(t))i(r,n,!0);return s}const un=BigInt(0),_a=BigInt(1);function yy(s,e){const t=s%e;return t>=un?t:e+t}function Gj(s,e,t){if(e<un)throw new Error("invalid exponent, negatives unsupported");if(t<=un)throw new Error("invalid modulus");if(t===_a)return un;let i=_a;for(;e>un;)e&_a&&(i=i*s%t),s=s*s%t,e>>=_a;return i}function Ms(s,e,t){let i=s;for(;e-- >un;)i*=i,i%=t;return i}BigInt(0),BigInt(1),BigInt(0),BigInt(1),BigInt(2),BigInt(8);const zr=BigInt(0),wl=BigInt(1);function Yj(s){return Kj(s,{a:"bigint"},{montgomeryBits:"isSafeInteger",nByteLength:"isSafeInteger",adjustScalarBytes:"function",domain:"function",powPminus2:"function",Gu:"bigint"}),Object.freeze({...s})}function Qj(s){const e=Yj(s),{P:t}=e,i=w=>yy(w,t),r=e.montgomeryBits,n=Math.ceil(r/8),o=e.nByteLength,a=e.adjustScalarBytes||(w=>w),l=e.powPminus2||(w=>Gj(w,t-BigInt(2),t));function c(w,v,A){const C=i(w*(v-A));return v=i(v-C),A=i(A+C),[v,A]}const h=(e.a-BigInt(2))/BigInt(4);function u(w,v){wg("u",w,zr,t),wg("scalar",v,zr,t);const A=v,C=w;let P=wl,T=zr,O=w,S=wl,M=zr,$;for(let L=BigInt(r-1);L>=zr;L--){const B=A>>L&wl;M^=B,$=c(M,P,O),P=$[0],O=$[1],$=c(M,T,S),T=$[0],S=$[1],M=B;const H=P+T,z=i(H*H),W=P-T,V=i(W*W),_=z-V,F=O+S,Q=O-S,G=i(Q*H),Ie=i(F*W),ce=G+Ie,xe=G-Ie;O=i(ce*ce),S=i(C*i(xe*xe)),P=i(z*V),T=i(_*(z+i(h*_)))}$=c(M,P,O),P=$[0],O=$[1],$=c(M,T,S),T=$[0],S=$[1];const U=l(T);return i(P*U)}function d(w){return Hj(i(w),n)}function p(w){const v=mg("u coordinate",w,n);return o===32&&(v[31]&=127),fg(v)}function g(w){const v=mg("scalar",w),A=v.length;if(A!==n&&A!==o){let C=""+n+" or "+o;throw new Error("invalid scalar, expected "+C+" bytes, got "+A)}return fg(a(v))}function f(w,v){const A=p(v),C=g(w),P=u(A,C);if(P===zr)throw new Error("invalid private or public key received");return d(P)}const b=d(e.Gu);function y(w){return f(w,b)}return{scalarMult:f,scalarMultBase:y,getSharedSecret:(w,v)=>f(w,v),getPublicKey:w=>y(w),utils:{randomPrivateKey:()=>e.randomBytes(e.nByteLength)},GuBytes:b}}const Eh=BigInt("57896044618658097711785492504343953926634992332820282019728792003956564819949");BigInt(0);const Zj=BigInt(1),yg=BigInt(2),Jj=BigInt(3),Xj=BigInt(5);BigInt(8);function e3(s){const e=BigInt(10),t=BigInt(20),i=BigInt(40),r=BigInt(80),n=Eh,o=s*s%n*s%n,a=Ms(o,yg,n)*o%n,l=Ms(a,Zj,n)*s%n,c=Ms(l,Xj,n)*l%n,h=Ms(c,e,n)*c%n,u=Ms(h,t,n)*h%n,d=Ms(u,i,n)*u%n,p=Ms(d,r,n)*d%n,g=Ms(p,r,n)*d%n,f=Ms(g,e,n)*c%n;return{pow_p_5_8:Ms(f,yg,n)*s%n,b2:o}}function t3(s){return s[0]&=248,s[31]&=127,s[31]|=64,s}const Ah=Qj({P:Eh,a:BigInt(486662),montgomeryBits:255,nByteLength:32,Gu:BigInt(9),powPminus2:s=>{const e=Eh,{pow_p_5_8:t,b2:i}=e3(s);return yy(Ms(t,Jj,e)*i,e)},adjustScalarBytes:t3,randomBytes:sa}),by="base10",Ut="base16",Ni="base64pad",Zn="base64url",ia="utf8",vy=0,ni=1,ra=2,s3=0,bg=1,mo=12,wu=32;function i3(){const s=Ah.utils.randomPrivateKey(),e=Ah.getPublicKey(s);return{privateKey:m.toString(s,Ut),publicKey:m.toString(e,Ut)}}function Nh(){const s=sa(wu);return m.toString(s,Ut)}function r3(s,e){const t=Ah.getSharedSecret(m.fromString(s,Ut),m.fromString(e,Ut)),i=Oj(Tc,t,void 0,void 0,wu);return m.toString(i,Ut)}function Ba(s){const e=Tc(m.fromString(s,Ut));return m.toString(e,Ut)}function Bs(s){const e=Tc(m.fromString(s,ia));return m.toString(e,Ut)}function Iy(s){return m.fromString(`${s}`,by)}function cr(s){return Number(m.toString(s,by))}function n3(s){const e=Iy(typeof s.type<"u"?s.type:vy);if(cr(e)===ni&&typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const t=typeof s.senderPublicKey<"u"?m.fromString(s.senderPublicKey,Ut):void 0,i=typeof s.iv<"u"?m.fromString(s.iv,Ut):sa(mo),r=m.fromString(s.symKey,Ut),n=py(r,i).encrypt(m.fromString(s.message,ia));return Ey({type:e,sealed:n,iv:i,senderPublicKey:t,encoding:s.encoding})}function o3(s){const e=m.fromString(s.symKey,Ut),{sealed:t,iv:i}=ko(s),r=py(e,i).decrypt(t);if(r===null)throw new Error("Failed to decrypt");return m.toString(r,ia)}function a3(s,e){const t=Iy(ra),i=sa(mo),r=m.fromString(s,ia);return Ey({type:t,sealed:r,iv:i,encoding:e})}function c3(s,e){const{sealed:t}=ko({encoded:s,encoding:e});return m.toString(t,ia)}function Ey(s){const{encoding:e=Ni}=s;if(cr(s.type)===ra)return m.toString(m.concat([s.type,s.sealed]),e);if(cr(s.type)===ni){if(typeof s.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return m.toString(m.concat([s.type,s.senderPublicKey,s.iv,s.sealed]),e)}return m.toString(m.concat([s.type,s.iv,s.sealed]),e)}function ko(s){const{encoded:e,encoding:t=Ni}=s,i=m.fromString(e,t),r=i.slice(s3,bg),n=bg;if(cr(r)===ni){const c=n+wu,h=c+mo,u=i.slice(n,c),d=i.slice(c,h),p=i.slice(h);return{type:r,sealed:p,iv:d,senderPublicKey:u}}if(cr(r)===ra){const c=i.slice(n),h=sa(mo);return{type:r,sealed:c,iv:h}}const o=n+mo,a=i.slice(n,o),l=i.slice(o);return{type:r,sealed:l,iv:a}}function l3(s,e){const t=ko({encoded:s,encoding:e==null?void 0:e.encoding});return Ay({type:cr(t.type),senderPublicKey:typeof t.senderPublicKey<"u"?m.toString(t.senderPublicKey,Ut):void 0,receiverPublicKey:e==null?void 0:e.receiverPublicKey})}function Ay(s){const e=(s==null?void 0:s.type)||vy;if(e===ni){if(typeof(s==null?void 0:s.senderPublicKey)>"u")throw new Error("missing sender public key");if(typeof(s==null?void 0:s.receiverPublicKey)>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:s==null?void 0:s.senderPublicKey,receiverPublicKey:s==null?void 0:s.receiverPublicKey}}function vg(s){return s.type===ni&&typeof s.senderPublicKey=="string"&&typeof s.receiverPublicKey=="string"}function Ig(s){return s.type===ra}function h3(s){return new rm.ec("p256").keyFromPublic({x:N.dist.Buffer.from(s.x,"base64").toString("hex"),y:N.dist.Buffer.from(s.y,"base64").toString("hex")},"hex")}function u3(s){let e=s.replace(/-/g,"+").replace(/_/g,"/");const t=e.length%4;return t>0&&(e+="=".repeat(4-t)),e}function d3(s){return N.dist.Buffer.from(u3(s),"base64")}function p3(s,e){const[t,i,r]=s.split("."),n=d3(r);if(n.length!==64)throw new Error("Invalid signature length");const o=n.slice(0,32).toString("hex"),a=n.slice(32,64).toString("hex"),l=`${t}.${i}`,c=Tc(l),h=h3(e),u=m.toString(c,Ut);if(!h.verify(u,{r:o,s:a}))throw new Error("Invalid signature");return m.sn(s).payload}const g3="irn";function nc(s){return(s==null?void 0:s.relay)||{protocol:g3}}function co(s){const e=m.C[s];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${s}`);return e}function f3(s,e="-"){const t={},i="relay"+e;return Object.keys(s).forEach(r=>{if(r.startsWith(i)){const n=r.replace(i,""),o=s[r];t[n]=o}}),t}function Eg(s){if(!s.includes("wc:")){const c=ey(s);c!=null&&c.includes("wc:")&&(s=c)}s=s.includes("wc://")?s.replace("wc://",""):s,s=s.includes("wc:")?s.replace("wc:",""):s;const e=s.indexOf(":"),t=s.indexOf("?")!==-1?s.indexOf("?"):void 0,i=s.substring(0,e),r=s.substring(e+1,t).split("@"),n=typeof t<"u"?s.substring(t):"",o=new URLSearchParams(n),a={};o.forEach((c,h)=>{a[h]=c});const l=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:i,topic:m3(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:f3(a),methods:l,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function m3(s){return s.startsWith("//")?s.substring(2):s}function w3(s,e="-"){const t="relay",i={};return Object.keys(s).forEach(r=>{const n=r,o=t+e+n;s[n]&&(i[o]=s[n])}),i}function Ag(s){const e=new URLSearchParams,t=w3(s.relay);Object.keys(t).sort().forEach(r=>{e.set(r,t[r])}),e.set("symKey",s.symKey),s.expiryTimestamp&&e.set("expiryTimestamp",s.expiryTimestamp.toString()),s.methods&&e.set("methods",s.methods.join(","));const i=e.toString();return`${s.protocol}:${s.topic}@${s.version}?${i}`}function Ca(s,e,t){return`${s}?wc_ev=${t}&topic=${e}`}function xn(s){const e=[];return s.forEach(t=>{const[i,r]=t.split(":");e.push(`${i}:${r}`)}),e}function y3(s){const e=[];return Object.values(s).forEach(t=>{e.push(...xn(t.accounts))}),e}function b3(s,e){const t=[];return Object.values(s).forEach(i=>{xn(i.accounts).includes(e)&&t.push(...i.methods)}),t}function v3(s,e){const t=[];return Object.values(s).forEach(i=>{xn(i.accounts).includes(e)&&t.push(...i.events)}),t}function yu(s){return s.includes(":")}function lo(s){return yu(s)?s.split(":")[0]:s}function I3(s){const e={};return s==null||s.forEach(t=>{var i;const[r,n]=t.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[],methods:[]}),e[r].accounts.push(t),(i=e[r].chains)==null||i.push(`${r}:${n}`)}),e}function Ng(s,e){e=e.map(i=>i.replace("did:pkh:",""));const t=I3(e);for(const[i,r]of Object.entries(t))r.methods?r.methods=Fa(r.methods,s):r.methods=s,r.events=["chainChanged","accountsChanged"];return t}const E3={INVALID_METHOD:{message:"Invalid method.",code:1001},INVALID_EVENT:{message:"Invalid event.",code:1002},INVALID_UPDATE_REQUEST:{message:"Invalid update request.",code:1003},INVALID_EXTEND_REQUEST:{message:"Invalid extend request.",code:1004},INVALID_SESSION_SETTLE_REQUEST:{message:"Invalid session settle request.",code:1005},UNAUTHORIZED_METHOD:{message:"Unauthorized method.",code:3001},UNAUTHORIZED_EVENT:{message:"Unauthorized event.",code:3002},UNAUTHORIZED_UPDATE_REQUEST:{message:"Unauthorized update request.",code:3003},UNAUTHORIZED_EXTEND_REQUEST:{message:"Unauthorized extend request.",code:3004},USER_REJECTED:{message:"User rejected.",code:5e3},USER_REJECTED_CHAINS:{message:"User rejected chains.",code:5001},USER_REJECTED_METHODS:{message:"User rejected methods.",code:5002},USER_REJECTED_EVENTS:{message:"User rejected events.",code:5003},UNSUPPORTED_CHAINS:{message:"Unsupported chains.",code:5100},UNSUPPORTED_METHODS:{message:"Unsupported methods.",code:5101},UNSUPPORTED_EVENTS:{message:"Unsupported events.",code:5102},UNSUPPORTED_ACCOUNTS:{message:"Unsupported accounts.",code:5103},UNSUPPORTED_NAMESPACE_KEY:{message:"Unsupported namespace key.",code:5104},USER_DISCONNECTED:{message:"User disconnected.",code:6e3},SESSION_SETTLEMENT_FAILED:{message:"Session settlement failed.",code:7e3},WC_METHOD_UNSUPPORTED:{message:"Unsupported wc_ method.",code:10001}},A3={NOT_INITIALIZED:{message:"Not initialized.",code:1},NO_MATCHING_KEY:{message:"No matching key.",code:2},RESTORE_WILL_OVERRIDE:{message:"Restore will override.",code:3},RESUBSCRIBED:{message:"Resubscribed.",code:4},MISSING_OR_INVALID:{message:"Missing or invalid.",code:5},EXPIRED:{message:"Expired.",code:6},UNKNOWN_TYPE:{message:"Unknown type.",code:7},MISMATCHED_TOPIC:{message:"Mismatched topic.",code:8},NON_CONFORMING_NAMESPACES:{message:"Non conforming namespaces.",code:9}};function R(s,e){const{message:t,code:i}=A3[s];return{message:e?`${t} ${e}`:t,code:i}}function Me(s,e){const{message:t,code:i}=E3[s];return{message:e?`${t} ${e}`:t,code:i}}function lr(s,e){return!!Array.isArray(s)}function jo(s){return Object.getPrototypeOf(s)===Object.prototype&&Object.keys(s).length}function Pt(s){return typeof s>"u"}function rt(s,e){return e&&Pt(s)?!0:typeof s=="string"&&!!s.trim().length}function bu(s,e){return e&&Pt(s)?!0:typeof s=="number"&&!isNaN(s)}function N3(s,e){const{requiredNamespaces:t}=e,i=Object.keys(s.namespaces),r=Object.keys(t);let n=!0;return Qi(r,i)?(i.forEach(o=>{const{accounts:a,methods:l,events:c}=s.namespaces[o],h=xn(a),u=t[o];(!Qi(Yw(o,u),h)||!Qi(u.methods,l)||!Qi(u.events,c))&&(n=!1)}),n):!1}function oc(s){return rt(s,!1)&&s.includes(":")?s.split(":").length===2:!1}function _3(s){if(rt(s,!1)&&s.includes(":")){const e=s.split(":");if(e.length===3){const t=e[0]+":"+e[1];return!!e[2]&&oc(t)}}return!1}function C3(s){function e(t){try{return typeof new URL(t)<"u"}catch{return!1}}try{if(rt(s,!1)){if(e(s))return!0;const t=ey(s);return e(t)}}catch{}return!1}function S3(s){var e;return(e=s==null?void 0:s.proposer)==null?void 0:e.publicKey}function $3(s){return s==null?void 0:s.topic}function P3(s,e){let t=null;return rt(s==null?void 0:s.publicKey,!1)||(t=R("MISSING_OR_INVALID",`${e} controller public key should be a string`)),t}function _g(s){let e=!0;return lr(s)?s.length&&(e=s.every(t=>rt(t,!1))):e=!1,e}function T3(s,e,t){let i=null;return lr(e)&&e.length?e.forEach(r=>{i||oc(r)||(i=Me("UNSUPPORTED_CHAINS",`${t}, chain ${r} should be a string and conform to "namespace:chainId" format`))}):oc(s)||(i=Me("UNSUPPORTED_CHAINS",`${t}, chains must be defined as "namespace:chainId" e.g. "eip155:1": {...} in the namespace key OR as an array of CAIP-2 chainIds e.g. eip155: { chains: ["eip155:1", "eip155:5"] }`)),i}function M3(s,e,t){let i=null;return Object.entries(s).forEach(([r,n])=>{if(i)return;const o=T3(r,Yw(r,n),`${e} ${t}`);o&&(i=o)}),i}function x3(s,e){let t=null;return lr(s)?s.forEach(i=>{t||_3(i)||(t=Me("UNSUPPORTED_ACCOUNTS",`${e}, account ${i} should be a string and conform to "namespace:chainId:address" format`))}):t=Me("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),t}function O3(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=x3(i==null?void 0:i.accounts,`${e} namespace`);r&&(t=r)}),t}function D3(s,e){let t=null;return _g(s==null?void 0:s.methods)?_g(s==null?void 0:s.events)||(t=Me("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):t=Me("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),t}function Ny(s,e){let t=null;return Object.values(s).forEach(i=>{if(t)return;const r=D3(i,`${e}, namespace`);r&&(t=r)}),t}function k3(s,e,t){let i=null;if(s&&jo(s)){const r=Ny(s,e);r&&(i=r);const n=M3(s,e,t);n&&(i=n)}else i=R("MISSING_OR_INVALID",`${e}, ${t} should be an object with data`);return i}function yl(s,e){let t=null;if(s&&jo(s)){const i=Ny(s,e);i&&(t=i);const r=O3(s,e);r&&(t=r)}else t=R("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return t}function _y(s){return rt(s.protocol,!0)}function j3(s,e){let t=!1;return s?s&&lr(s)&&s.length&&s.forEach(i=>{t=_y(i)}):t=!0,t}function R3(s){return typeof s=="number"}function Zt(s){return typeof s<"u"&&typeof s!==null}function U3(s){return!(!s||typeof s!="object"||!s.code||!bu(s.code,!1)||!s.message||!rt(s.message,!1))}function L3(s){return!(Pt(s)||!rt(s.method,!1))}function z3(s){return!(Pt(s)||Pt(s.result)&&Pt(s.error)||!bu(s.id,!1)||!rt(s.jsonrpc,!1))}function F3(s){return!(Pt(s)||!rt(s.name,!1))}function Cg(s,e){return!(!oc(e)||!y3(s).includes(e))}function q3(s,e,t){return rt(t,!1)?b3(s,e).includes(t):!1}function B3(s,e,t){return rt(t,!1)?v3(s,e).includes(t):!1}function Sg(s,e,t){let i=null;const r=H3(s),n=W3(e),o=Object.keys(r),a=Object.keys(n),l=$g(Object.keys(s)),c=$g(Object.keys(e)),h=l.filter(u=>!c.includes(u));return h.length&&(i=R("NON_CONFORMING_NAMESPACES",`${t} namespaces keys don't satisfy requiredNamespaces.
|
|
@@ -912,7 +912,7 @@ ${s.length}`,t=new TextEncoder().encode(e+s);return"0x"+N.dist.Buffer.from(Rk(t)
|
|
|
912
912
|
.wui-color-fg-350 {
|
|
913
913
|
background-color: var(--wui-color-fg-350);
|
|
914
914
|
}
|
|
915
|
-
`,xa={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};function aa(s){return{formatters:void 0,fees:void 0,serializers:void 0,...s}}const zh=aa({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),Fh=aa({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}),h8=aa({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});aa({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});aa({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const u8={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},ub={getMethodsByChainNamespace(s){return u8[s]||[]},createDefaultNamespace(s){return{methods:this.getMethodsByChainNamespace(s),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(s,e){if(!e)return{...s};const t={...s},i=new Set;if(e.methods&&Object.keys(e.methods).forEach(r=>i.add(r)),e.chains&&Object.keys(e.chains).forEach(r=>i.add(r)),e.events&&Object.keys(e.events).forEach(r=>i.add(r)),e.rpcMap&&Object.keys(e.rpcMap).forEach(r=>{const[n]=r.split(":");n&&i.add(n)}),i.forEach(r=>{t[r]||(t[r]=this.createDefaultNamespace(r))}),e.methods&&Object.entries(e.methods).forEach(([r,n])=>{t[r]&&(t[r].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([r,n])=>{t[r]&&(t[r].chains=n)}),e.events&&Object.entries(e.events).forEach(([r,n])=>{t[r]&&(t[r].events=n)}),e.rpcMap){const r=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,l]=n.split(":");!a||!l||!t[a]||(t[a].rpcMap||(t[a].rpcMap={}),r.has(a)||(t[a].rpcMap={},r.add(a)),t[a].rpcMap[l]=o)})}return t},createNamespaces(s,e){const t=s.reduce((i,r)=>{const{id:n,chainNamespace:o,rpcUrls:a}=r,l=a.default.http[0];i[o]||(i[o]=this.createDefaultNamespace(o));const c=`${o}:${n}`,h=i[o];switch(h.chains.push(c),c){case zh.caipNetworkId:h.chains.push(zh.deprecatedCaipNetworkId);break;case Fh.caipNetworkId:h.chains.push(Fh.deprecatedCaipNetworkId);break}return h!=null&&h.rpcMap&&l&&(h.rpcMap[n]=l),i},{});return this.applyNamespaceOverrides(t,e)},resolveReownName:async s=>{var i;const e=await Ow.resolveName(s);return((i=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:i.address)||!1},getChainsFromNamespaces(s={}){return Object.values(s).flatMap(e=>{const t=e.chains||[],i=e.accounts.map(r=>{const[n,o]=r.split(":");return`${n}:${o}`});return Array.from(new Set([...t,...i]))})},isSessionEventData(s){return typeof s=="object"&&s!==null&&"id"in s&&"topic"in s&&"params"in s&&typeof s.params=="object"&&s.params!==null&&"chainId"in s.params&&"event"in s.params&&typeof s.params.event=="object"&&s.params.event!==null}};class db{constructor({provider:e,caipNetworks:t,namespace:i}){this.id=Z.CONNECTOR_ID.WALLET_CONNECT,this.name=ac.ConnectorNamesMap[Z.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=ac.ConnectorImageIds[Z.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=i}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const t=k.state.universalProviderConfigOverride,i=ub.createNamespaces(this.caipNetworks,t);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(t=>t.caipNetworkId);return fn.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:d8})}}const d8=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class p8{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:Z.CONNECTOR_ID.AUTH,type:"AUTH",name:Z.CONNECTOR_NAMES.AUTH,provider:e,imageId:ac.ConnectorImageIds[Z.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(i=>t.has(i.id)?!1:(t.add(i.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){J.setStatus(e,t)}on(e,t){var i;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(i=this.eventListeners.get(e))==null||i.add(t)}off(e,t){const i=this.eventListeners.get(e);i&&i.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const i=this.eventListeners.get(e);i&&i.forEach(r=>r(t))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:i}=e;if(!e.provider)return;const r="provider"in e.provider?e.provider.provider:e.provider;if(i==="WALLET_CONNECT"){r.setDefaultChain(t.caipNetworkId);return}if(r&&i==="AUTH"){const n=r;await n.switchNetwork(t.caipNetworkId);const o=await n.getUser({chainId:t.caipNetworkId,preferredAccountType:k.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",o)}}getWalletConnectConnector(){const e=this.connectors.find(t=>t instanceof db);if(!e)throw new Error("WalletConnectConnector not found");return e}}class g8 extends p8{setUniversalProvider(e){this.addConnector(new db({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var r,n,o,a;const t=this.provider,i=((a=(o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(l=>{const[,,c]=l.split(":");return c}).filter((l,c,h)=>h.indexOf(l)===c))||[];return Promise.resolve({accounts:i.map(l=>re.createAccount(e,l,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,l,c;if(!(e.caipNetwork&&qt.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(J.state.balanceLoading&&e.chainId===((l=I.state.activeCaipNetwork)==null?void 0:l.id))return{balance:J.state.balance||"0.00",symbol:J.state.balanceSymbol||""};const r=(await J.fetchTokenBalance()).find(h=>{var u,d;return h.chainId===`${(u=e.caipNetwork)==null?void 0:u.chainNamespace}:${e.chainId}`&&h.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(r==null?void 0:r.quantity.numeric)||"0.00",symbol:(r==null?void 0:r.symbol)||((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,l;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===Z.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Gw.encode(new TextEncoder().encode(i)),pubkey:r}},(a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(l=I.state.activeCaipNetwork)==null?void 0:l.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,n,o,a,l,c;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===Z.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:E.toHex(t.id)}]}))}catch(h){if(h.code===xa.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===xa.ERROR_INVALID_CHAIN_ID||h.code===xa.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===xa.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((c=i.provider)==null?void 0:c.request({method:"wallet_addEthereumChain",params:[{chainId:E.toHex(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(l=t.blockExplorers)==null?void 0:l.default.url]}]}))}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}class f8{constructor(e){var t;this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=i=>{var r,n;if(i){const o=(r=I.getNetworkData(i))==null?void 0:r.caipNetwork;return o||((n=I.getRequestedCaipNetworks(i).filter(a=>a.chainNamespace===i))==null?void 0:n[0])}return I.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const i=this.getCaipNetwork();if(i)return i.id},this.getCaipNetworks=i=>I.getRequestedCaipNetworks(i),this.getActiveChainNamespace=()=>I.state.activeChain,this.setRequestedCaipNetworks=(i,r)=>{I.setRequestedCaipNetworks(i,r)},this.getApprovedCaipNetworkIds=()=>I.getAllApprovedCaipNetworkIds(),this.getCaipAddress=i=>I.state.activeChain===i||!i?I.state.activeCaipAddress:I.getAccountProp("caipAddress",i),this.setClientId=i=>{ee.setClientId(i)},this.getProvider=i=>Ze.getProvider(i),this.getProviderType=i=>Ze.getProviderId(i),this.getPreferredAccountType=()=>J.state.preferredAccountType,this.setCaipAddress=(i,r)=>{J.setCaipAddress(i,r)},this.setBalance=(i,r,n)=>{J.setBalance(i,r,n)},this.setProfileName=(i,r)=>{J.setProfileName(i,r)},this.setProfileImage=(i,r)=>{J.setProfileImage(i,r)},this.setUser=(i,r)=>{J.setUser(i,r),k.state.enableEmbedded&&et.close()},this.resetAccount=i=>{J.resetAccount(i)},this.setCaipNetwork=i=>{I.setActiveCaipNetwork(i)},this.setCaipNetworkOfNamespace=(i,r)=>{I.setChainNetworkData(r,{caipNetwork:i})},this.setAllAccounts=(i,r)=>{J.setAllAccounts(i,r),k.setHasMultipleAddresses((i==null?void 0:i.length)>1)},this.setStatus=(i,r)=>{J.setStatus(i,r),ie.isConnected()?Y.setConnectionStatus("connected"):Y.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=i=>I.getAccountProp("address",i),this.setConnectors=i=>{const r=[...ie.getConnectors(),...i];ie.setConnectors(r)},this.fetchIdentity=i=>ee.fetchIdentity(i),this.getReownName=i=>Ow.getNamesForAddress(i),this.getConnectors=()=>ie.getConnectors(),this.getConnectorImage=i=>cu.getConnectorImage(i),this.setConnectedWalletInfo=(i,r)=>{const n=Ze.getProviderId(r),o=i?{...i,type:n}:void 0;J.setConnectedWalletInfo(o,r)},this.getIsConnectedState=()=>!!I.state.activeCaipAddress,this.addAddressLabel=(i,r,n)=>{J.addAddressLabel(i,r,n)},this.removeAddressLabel=(i,r)=>{J.removeAddressLabel(i,r)},this.getAddress=i=>I.state.activeChain===i||!i?J.state.address:I.getAccountProp("address",i),this.setApprovedCaipNetworksData=i=>I.setApprovedCaipNetworksData(i),this.resetNetwork=i=>{I.resetNetwork(i)},this.addConnector=i=>{ie.addConnector(i)},this.resetWcConnection=()=>{ke.resetWcConnection()},this.setAddressExplorerUrl=(i,r)=>{J.setAddressExplorerUrl(i,r)},this.setSmartAccountDeployed=(i,r)=>{J.setSmartAccountDeployed(i,r)},this.setSmartAccountEnabledNetworks=(i,r)=>{I.setSmartAccountEnabledNetworks(i,r)},this.setPreferredAccountType=(i,r)=>{J.setPreferredAccountType(i,r)},this.setEIP6963Enabled=i=>{k.setEIP6963Enabled(i)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set((t=this.caipNetworks)==null?void 0:t.map(i=>i.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),ri.set({initialized:!0})}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,je.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&jt.setThemeMode(e.themeMode),e.themeVariables&&jt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");I.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&I.setActiveCaipNetwork(t)}initializeConnectionController(e){ke.setWcBasic(e.basic??!1)}initializeConnectorController(){ie.initialize(this.chainNamespaces)}initializeOptionsController(e){var r;k.setDebug(e.debug!==!1),k.setEnableWalletConnect(e.enableWalletConnect!==!1),k.setEnableWalletGuide(e.enableWalletGuide!==!1),k.setEnableWallets(e.enableWallets!==!1),k.setEIP6963Enabled(e.enableEIP6963!==!1),k.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),k.setEnableAuthLogger(e.enableAuthLogger!==!1),k.setCustomRpcUrls(e.customRpcUrls),k.setSdkVersion(e.sdkVersion),k.setProjectId(e.projectId),k.setEnableEmbedded(e.enableEmbedded),k.setAllWallets(e.allWallets),k.setIncludeWalletIds(e.includeWalletIds),k.setExcludeWalletIds(e.excludeWalletIds),k.setFeaturedWalletIds(e.featuredWalletIds),k.setTokens(e.tokens),k.setTermsConditionsUrl(e.termsConditionsUrl),k.setPrivacyPolicyUrl(e.privacyPolicyUrl),k.setCustomWallets(e.customWallets),k.setFeatures(e.features),k.setAllowUnsupportedChain(e.allowUnsupportedChain),k.setDefaultAccountTypes(e.defaultAccountTypes),k.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),k.setMetadata(e.metadata),k.setDisableAppend(e.disableAppend),k.setEnableEmbedded(e.enableEmbedded),k.setSIWX(e.siwx),!e.projectId){fo.open(Ma.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===Z.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");k.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return typeof window<"u"&&typeof document<"u"?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=an.getUnsupportedNetwork(`${t}:${e}`);I.setActiveCaipNetwork(i)}}getDefaultNetwork(){return an.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return an.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return an.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?an.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=I.state.activeChain,t=this.getAdapter(e),i=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!t)throw new Error("Adapter not found");const r=await t.connectWalletConnect(i);this.close(),this.setClientId((r==null?void 0:r.clientId)||null),Y.setConnectedNamespaces([...I.state.chains.keys()]),this.chainNamespaces.forEach(o=>{ie.setConnectorId(di.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:i,provider:r,chain:n,caipNetwork:o})=>{var p,g,f,b,y,w,v;const a=I.state.activeChain,l=n||a,c=this.getAdapter(l);if(n&&n!==a&&!o){const A=(p=this.caipNetworks)==null?void 0:p.find(C=>C.chainNamespace===n);A&&this.setCaipNetwork(A)}if(!c)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),u=await c.connect({id:e,info:t,type:i,provider:r,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((b=(f=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:f.http)==null?void 0:b[0])||((v=(w=(y=h==null?void 0:h.rpcUrls)==null?void 0:y.default)==null?void 0:w.http)==null?void 0:v[0])});if(!u)return;Y.addConnectedNamespace(l),this.syncProvider({...u,chainNamespace:l}),await this.syncAccount({...u,chainNamespace:l});const{accounts:d}=await c.getAccounts({namespace:l,id:e});this.setAllAccounts(d,l)},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=I.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),Y.addConnectedNamespace(n))},disconnect:async e=>{const t=e||I.state.activeChain,i=this.getAdapter(t),r=Ze.getProvider(t),n=Ze.getProviderId(t);await(i==null?void 0:i.disconnect({provider:r,providerType:n})),Y.removeConnectedNamespace(t),Ze.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=this.getAdapter(I.state.activeChain),i=await(t==null?void 0:t.signMessage({message:e,address:J.state.address,provider:Ze.getProvider(I.state.activeChain)}));return(i==null?void 0:i.signature)||""},sendTransaction:async e=>{if(e.chainNamespace===Z.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=Ze.getProvider(I.state.activeChain),r=await(t==null?void 0:t.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(r==null?void 0:r.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===Z.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=Ze.getProvider(I.state.activeChain),r=this.getCaipNetwork();if(!r)throw new Error("CaipNetwork is undefined");const n=await(t==null?void 0:t.estimateGas({...e,provider:i,caipNetwork:r}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var i;const e=this.getAdapter(I.state.activeChain),t=await(e==null?void 0:e.getProfile({address:J.state.address,chainId:Number((i=this.getCaipNetwork())==null?void 0:i.id)}));return(t==null?void 0:t.profileImage)||!1},getEnsAddress:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork();if(!i)return!1;const r=await(t==null?void 0:t.getEnsAddress({name:e,caipNetwork:i}));return(r==null?void 0:r.address)||!1},writeContract:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork(),r=this.getCaipAddress(),n=Ze.getProvider(I.state.activeChain);if(!i||!r)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(t==null?void 0:t.writeContract({...e,caipNetwork:i,provider:n,caipAddress:r}));return o==null?void 0:o.hash},parseUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},ke.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var t,i,r,n,o;if(Ze.getProviderId(I.state.activeChain)===di.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=Ze.getProvider(t),n=Ze.getProviderId(t);if(e.chainNamespace===I.state.activeChain){const o=this.getAdapter(t);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:r,providerType:n}))}else if(this.setCaipNetwork(e),n===di.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(t);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=ci.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n;const r=e==null?void 0:e.find(o=>o.namespace===i);return r?(t[i]=r,t[i].namespace=i,t[i].construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.caipNetworks})):t[i]=new g8({namespace:i,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){var t;this.onConnectors(e),this.listenAdapter(e),(t=this.chainAdapters)==null||t[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=Y.getConnectionStatus();i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(Y.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var c;const o=(c=this.caipNetworks)==null?void 0:c.find(h=>h.id===n||h.caipNetworkId===n),a=I.state.activeChain===e,l=I.getAccountProp("address",e);if(o){const h=a&&r?r:l;h&&this.syncAccount({address:h,chainId:n,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const r=J.state.address,n=I.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n})=>{var a,l;const o=I.state.activeChain===e;o&&n?this.syncAccount({address:r,chainId:n,chainNamespace:e}):o&&((a=I.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:r,chainId:(l=I.state.activeCaipNetwork)==null?void 0:l.id,chainNamespace:e}):this.syncAccountInfo(r,n,e)})}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null||r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=ie.getConnectorId(e);switch(this.setStatus("connecting",e),t){case Z.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case Z.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var o,a,l;const t=this.getAdapter(e),i=ie.getConnectorId(e),r=this.getCaipNetwork(e),n=ie.getConnectors(e).find(c=>c.id===i);try{if(!t||!n)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(r!=null&&r.id))throw new Error("CaipNetwork not found");const c=await(t==null?void 0:t.syncConnection({namespace:e,id:n.id,chainId:r.id,rpcUrl:(l=(a=(o=r==null?void 0:r.rpcUrls)==null?void 0:o.default)==null?void 0:a.http)==null?void 0:l[0]}));if(c){const h=await(t==null?void 0:t.getAccounts({namespace:e,id:n.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([re.createAccount(e,c.address,"eoa")],e),this.syncProvider({...c,chainNamespace:e}),await this.syncAccount({...c,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async t=>{var a,l,c,h,u;const i=this.getAdapter(t),r=((h=(c=(l=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:l.namespaces)==null?void 0:c[t])==null?void 0:h.accounts)||[],n=(u=I.state.activeCaipNetwork)==null?void 0:u.id,o=r.find(d=>{const{chainId:p}=ci.parseCaipAddress(d);return p===(n==null?void 0:n.toString())})||r[0];if(o){const d=ci.validateCaipAddress(o),{chainId:p,address:g}=ci.parseCaipAddress(d);if(Ze.setProviderId(t,di.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&I.state.activeCaipNetwork&&(i==null?void 0:i.namespace)!==Z.CHAIN.EVM){const f=i==null?void 0:i.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:I.state.activeCaipNetwork});Ze.setProvider(t,f)}else Ze.setProvider(t,this.universalProvider);ie.setConnectorId(Z.CONNECTOR_ID.WALLET_CONNECT,t),Y.addConnectedNamespace(t),this.syncWalletConnectAccounts(t),await this.syncAccount({address:g,chainId:p,chainNamespace:t})}else this.setStatus("disconnected",t);await I.setApprovedCaipNetworksData(t)});await Promise.all(e)}syncWalletConnectAccounts(e){var i,r,n,o,a;const t=(a=(o=(n=(r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(l=>{const{address:c}=ci.parseCaipAddress(l);return c}).filter((l,c,h)=>h.indexOf(l)===c);t&&this.setAllAccounts(t.map(l=>re.createAccount(e,l,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){Ze.setProviderId(r,e),Ze.setProvider(r,t),ie.setConnectorId(i,r)}async syncAccount(e){var u,d,p,g,f,b;const t=e.chainNamespace===I.state.activeChain,i=I.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=Y.getActiveNetworkProps(),l=n||a,c=((u=I.state.activeCaipNetwork)==null?void 0:u.name)===Z.UNSUPPORTED_NETWORK_NAME,h=I.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(c&&!h)&&l){let y=(d=this.caipNetworks)==null?void 0:d.find(A=>A.id.toString()===l.toString()),w=(p=this.caipNetworks)==null?void 0:p.find(A=>A.chainNamespace===o);if(!h&&!y&&!w){const A=this.getApprovedCaipNetworkIds()||[],C=A.find(T=>{var O;return((O=ci.parseCaipNetworkId(T))==null?void 0:O.chainId)===l.toString()}),P=A.find(T=>{var O;return((O=ci.parseCaipNetworkId(T))==null?void 0:O.chainNamespace)===o});y=(g=this.caipNetworks)==null?void 0:g.find(T=>T.caipNetworkId===C),w=(f=this.caipNetworks)==null?void 0:f.find(T=>T.caipNetworkId===P||"deprecatedCaipNetworkId"in T&&T.deprecatedCaipNetworkId===P)}const v=y||w;(v==null?void 0:v.chainNamespace)===I.state.activeChain?k.state.enableNetworkSwitch&&!k.state.allowUnsupportedChain&&((b=I.state.activeCaipNetwork)==null?void 0:b.name)===Z.UNSUPPORTED_NETWORK_NAME?I.showUnsupportedChainUI():this.setCaipNetwork(v):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o),sb.isLowerCaseMatch(r,J.state.address)||this.syncAccountInfo(r,v==null?void 0:v.id,o),t?await this.syncBalance({address:r,chainId:v==null?void 0:v.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=ie.getConnectorId(e),i=Ze.getProviderId(e);if(i===di.CONNECTOR_TYPE_ANNOUNCED||i===di.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(o=>o.id===t);if(n){const{info:o,name:a,imageUrl:l}=n,c=l||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:c,...o},e)}}}else if(i===di.CONNECTOR_TYPE_WALLET_CONNECT){const n=Ze.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t)if(t===Z.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===Z.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){!$w.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,i){const r=this.getAdapter(i);if(r){const n=await r.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(i),tokens:this.options.tokens});this.setBalance(n.balance,n.symbol,i)}}async initializeUniversalAdapter(){var i,r,n,o,a,l,c,h,u,d;const e=Rz.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),t={projectId:(i=this.options)==null?void 0:i.projectId,metadata:{name:(r=this.options)!=null&&r.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(c=this.options)==null?void 0:c.metadata.url:"",icons:(h=this.options)!=null&&h.metadata?(u=this.options)==null?void 0:u.metadata.icons:[""]},logger:e};k.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await kz.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{ke.setUri(e)}),this.universalProvider.on("connect",ke.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),ke.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{var r;const t=(r=this.caipNetworks)==null?void 0:r.find(n=>n.id==e),i=this.getCaipNetwork();if(!t){this.setUnsupportedNetwork(e);return}(i==null?void 0:i.id)!==(t==null?void 0:t.id)&&this.setCaipNetwork(t)}),this.universalProvider.on("session_event",e=>{if(ub.isSessionEventData(e)){const{name:t,data:i}=e.params.event;t==="accountsChanged"&&Array.isArray(i)&&re.isCaipAddress(i[0])&&this.syncAccount(ci.parseCaipAddress(i[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&re.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){je.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries(Ma.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Ma.ALERT_ERRORS[o];a&&(fo.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&ke.setUri(e.uri),await et.open(e)}async close(){await this.injectModalUi(),et.close()}setLoading(e,t){et.setLoading(e,t)}async disconnect(e){await ke.disconnect(e)}getError(){return""}getChainId(){var e;return(e=I.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){var i;const t=(i=this.caipNetworks)==null?void 0:i.find(r=>r.id===e.id);if(!t){fo.open(Ma.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await I.switchActiveNetwork(t)}getWalletProvider(){return I.state.activeChain?Ze.state.providers[I.state.activeChain]:null}getWalletProviderType(){return Ze.getProviderId(I.state.activeChain)}subscribeProviders(e){return Ze.subscribeProviders(e)}getThemeMode(){return jt.state.themeMode}getThemeVariables(){return jt.state.themeVariables}setThemeMode(e){jt.setThemeMode(e),hb(jt.state.themeMode)}setTermsConditionsUrl(e){k.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){k.setPrivacyPolicyUrl(e)}setThemeVariables(e){jt.setThemeVariables(e),o8(jt.state.themeVariables)}subscribeTheme(e){return jt.subscribe(e)}getWalletInfo(){return J.state.connectedWalletInfo}getAccount(e){const t=ie.getAuthConnector(e),i=I.getAccountData(e);if(i)return{allAccounts:i.allAccounts,caipAddress:i.caipAddress,address:re.getPlainAddress(i.caipAddress),isConnected:!!i.caipAddress,status:i.status,embeddedWalletInfo:t?{user:i.user,authProvider:i.socialProvider||"email",accountType:i.preferredAccountType,isSmartAccountDeployed:!!i.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=()=>{const r=this.getAccount(t);r&&e(r)};t?I.subscribeChainProp("accountState",i,t):I.subscribe(i),ie.subscribe(i)}subscribeNetwork(e){return I.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId})})}subscribeWalletInfo(e){return J.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){J.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){I.subscribeKey("activeCaipNetwork",e)}getState(){return ri.state}subscribeState(e){return ri.subscribe(e)}showErrorMessage(e){wt.showError(e)}showSuccessMessage(e){wt.showSuccess(e)}getEvent(){return{...je.state}}subscribeEvents(e){return je.subscribe(e)}replace(e){_e.replace(e)}redirect(e){_e.push(e)}popTransactionStack(e){_e.popTransactionStack(e)}isOpen(){return et.state.open}isTransactionStackEmpty(){return _e.state.transactionStack.length===0}isTransactionShouldReplaceView(){var e;return(e=_e.state.transactionStack[_e.state.transactionStack.length-1])==null?void 0:e.replace}static getInstance(){return this.instance}updateFeatures(e){k.setFeatures(e)}updateOptions(e){const i={...k.state||{},...e};k.setOptions(i)}setConnectMethodsOrder(e){k.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){k.setWalletFeaturesOrder(e)}setCollapseWallets(e){k.setCollapseWallets(e)}setSocialsOrder(e){k.setSocialsOrder(e)}getConnectMethodsOrder(){return lc.getConnectOrderMethod(k.state.features,ie.getConnectors())}removeAdapter(e){var n;const t=this.getIsConnectedState(),i=this.getAdapter(e);if(!i||!this.chainAdapters||t)return;const r=(n=this.caipNetworks)==null?void 0:n.filter(o=>o.chainNamespace!==e);I.removeAdapter(e),ie.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(o=>o!==e),this.caipNetworks=r,i.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const i=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient||!this.chainAdapters||!i)return;const r=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...r],this.createAdapter(e),this.initChainAdapter(i),I.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},r)}addNetwork(e,t){var r;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);I.addNetwork(i),this.caipNetworks&&!((r=this.caipNetworks)!=null&&r.find(n=>n.id===i.id))&&this.caipNetworks.push(i)}removeNetwork(e,t){var n;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);if(!((n=this.caipNetworks)==null?void 0:n.find(o=>o.id===t)))throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const r=this.caipNetworks.filter(o=>o.chainNamespace===e&&o.id!==t);if(!(r!=null&&r.length))throw new Error("Cannot remove last network for a namespace");I.removeNetwork(e,t),this.caipNetworks=[...r]}}let Sf=!1;class m8 extends f8{async open(e){ie.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&ke.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!Sf&&re.isClient()){if(await Promise.resolve().then(()=>require("./basic-DQ6ISwhI.js")),await Promise.resolve().then(()=>require("./w3m-modal-DJRTg4Aa.js")),!document.querySelector("w3m-modal")){const t=document.createElement("w3m-modal");!k.state.disableAppend&&!k.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",t)}Sf=!0}}}const w8="1.7.2";function y8(s){return new m8({...s,basic:!0,sdkVersion:`html-core-${w8}`})}function b8(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var v8="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const jl=b8(v8);class pn extends Error{constructor(){super(),Object.setPrototypeOf(this,pn.prototype)}}class $f extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}function I8(s){let e=[s];return s===lt.Mainnet||s===lt.Deprecated_Mainnet?(e=[lt.Mainnet,lt.Deprecated_Mainnet],s===lt.Deprecated_Mainnet&&console.warn(dc.mainnet)):(s===lt.Deprecated_Devnet||s===lt.Devnet)&&(e=[lt.Devnet,lt.Deprecated_Devnet],console.warn(dc.devnet)),e}const dc={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${lt.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${lt.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function Pf(s,e){var i;const t=(i=s.namespaces.solana)==null?void 0:i.accounts.map(r=>`solana:${r.split(":")[1]}`);if(e===lt.Mainnet)return t!=null&&t.find(r=>r===lt.Mainnet)?lt.Mainnet:(console.warn(dc.wallet),lt.Deprecated_Mainnet);if(e===lt.Devnet)return t!=null&&t.find(r=>r===lt.Devnet)?lt.Devnet:(console.warn(dc.wallet),lt.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function E8(s){return{optionalNamespaces:{solana:{chains:I8(s),methods:[ys.signTransaction,ys.signMessage],events:[]}}}}class Su extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,Su.prototype),this.name="QRCodeModalError"}}class A8{constructor(e){vt(this,"_UniversalProvider");vt(this,"_session");vt(this,"_modal");vt(this,"_projectId");vt(this,"_network");vt(this,"_ConnectQueueResolver");if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){var r,n,o,a,l,c;if(this._UniversalProvider||await new Promise(h=>{this._ConnectQueueResolver=h}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const h=Pf(this._session,this._network);return this._network=h,this._UniversalProvider.setDefaultChain(h),{publicKey:this.publicKey}}await this.initModal();const e=E8(this._network);(r=this._modal)==null||r.open();const t=new AbortController,i=t.signal;(n=this._modal)==null||n.subscribeState(h=>{h.open||t.abort(new Su)});try{const h=await Promise.race([(o=this._UniversalProvider)==null?void 0:o.connect(e),new Promise((d,p)=>{i.addEventListener("abort",()=>{p(i.reason)})})]);if((a=this._modal)==null||a.close(),this._session=h,!h)throw new fc;const u=Pf(h,this._network);return this._network=u,(l=this._UniversalProvider)==null||l.setDefaultChain(u),{publicKey:this.publicKey}}catch(h){throw(c=this._modal)==null||c.close(),h}}async disconnect(){var e;if((e=this._UniversalProvider)!=null&&e.session){if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}else throw new pn}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new pn}get session(){if(!this._session)throw new pn;return this._session}get publicKey(){var e,t,i;if((e=this._UniversalProvider)!=null&&e.session&&this._session){const{address:r}=m0(((i=(t=this._session)==null?void 0:t.namespaces.solana)==null?void 0:i.accounts[0])??"");return new N.PublicKey(r)}throw new pn}async signTransaction(e){this.checkIfWalletSupportsMethod(ys.signTransaction);const t=si(e),i=t?{}:e,{signature:r,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signTransaction,params:{...i,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,N.dist.Buffer.from(jl.decode(r))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(ys.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signMessage,params:{pubkey:this.publicKey.toString(),message:jl.encode(e)}}});return jl.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(ys.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(ys.signAllTransactions);const t=e.map(r=>this.serialize(r)),{transactions:i}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signAllTransactions,params:{transactions:t}}});return e.map((r,n)=>si(r)?this.deserialize(i[n]??"",!0):this.deserialize(i[n]??""))}catch(t){if(t instanceof $f){const i=e.map(n=>this.signTransaction(n));return await Promise.all(i)}throw t}}async initClient(e){const t=await Rx.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=y8({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[zh,Fh,h8],manualWCControl:!0})}}serialize(e){return N.dist.Buffer.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?N.VersionedTransaction.deserialize(N.dist.Buffer.from(e,"base64")):N.Transaction.from(N.dist.Buffer.from(e,"base64"))}checkIfWalletSupportsMethod(e){var t;if(!((t=this.session.namespaces.solana)!=null&&t.methods.includes(e)))throw new $f(e)}}const N8="WalletConnect";class _8 extends Wh{constructor(t){super();vt(this,"name",N8);vt(this,"url","https://walletconnect.org");vt(this,"icon","data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+");vt(this,"supportedTransactionVersions",new Set(["legacy",0]));vt(this,"_publicKey");vt(this,"_connecting");vt(this,"_wallet");vt(this,"_config");vt(this,"_readyState");vt(this,"_onDisconnect");this._publicKey=null,this._connecting=!1,this._config=t,this._wallet=null,this._readyState=typeof window>"u"?ae.Unsupported:ae.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Loadable)throw new Ti;this._connecting=!0,this._wallet=new A8({network:this._config.network===_o.Mainnet?Ga.Mainnet:Ga.Devnet,options:this._config.options});const{publicKey:t}=await this._wallet.connect();this._publicKey=t,this.emit("connect",t),this._wallet.client.on("session_delete",this._onDisconnect)}catch(t){throw t.constructor.name==="QRCodeModalError"||t instanceof Error&&t.name==="QRCodeModalError"?new yb:(this._connecting=!1,t)}finally{this._connecting=!1}}async disconnect(){const t=this._wallet;if(t){t.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{t.client.session&&await t.disconnect()}catch(i){console.error("WalletConnectWalletAdapter: disconnect error",i),this.emit("error",new zo(i==null?void 0:i.message,i))}}this.emit("disconnect")}async signTransaction(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signTransaction(t)}catch(r){throw new Je(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signMessage(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signMessage(t)}catch(r){throw new Fo(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAndSendTransaction(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signAndSendTransaction(t)}catch(r){throw new Je(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAllTransactions(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signAllTransactions(t)}catch(r){throw new Je(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}}const C8={icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMDM1XzExMDYpIj4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IiM1NEZGRjUiLz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjBfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTEzLjQ4MDYgMTk4LjYwNUMtMjkuMzI3NiAzMTkuMDQzIDE5OS42NjEgMjg1LjAyNyAzMTkuNTA3IDI1Mi45NjRDNDQyLjE2NSAyMTIuMjU5IDM1Ny4zODYgMzIuODI2OSAyNjkuNDE1IDI4Ljg1NThDMTgxLjQ0MyAyNC44ODQ3IDI4MC4zMjIgMTExLjgyNCAyMDUuNTk1IDEzNi42NTZDMTMwLjg2OCAxNjEuNDg3IDY2Ljk5MDcgNDguMDU4MyAxMy40ODA2IDE5OC42MDVaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2ZfMjAzNV8xMTA2KSI+CjxwYXRoIGQ9Ik04NS41MTE4IC00NS44MjI1QzYzLjA1NjIgLTEwNy4xNzYgLTE2LjkxODkgLTIzLjk5NTMgLTU0LjA5OTUgMjUuMjY0M0MtODkuNTY1MiA3OC44NDc5IDMuMDA5MzcgMTI1LjE1MiAzOS4zMjA4IDEwMC4wMzdDNzUuNjMyMyA3NC45MjI3IDcuNzc0NDggNzAuMDM2MyAyOS4zNzA4IDM3LjM3ODVDNTAuOTY3MSA0LjcyMDc2IDExMy41ODEgMzAuODY5NSA4NS41MTE4IC00NS44MjI1WiIgZmlsbD0iIzAwRkZGMCIgZmlsbC1vcGFjaXR5PSIwLjY3Ii8+CjwvZz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjJfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTk2LjQ3OTYgMjI1LjQyNEM2NS44NTAyIDEyMi4zNjMgLTY2LjA4MTggMTc2LjYzNyAtMTI4LjIxOSAyMTYuNjU3Qy0xODcuOTkgMjY0LjA0MiAtNDYuMDcxMSA0MDAuMzQ4IDEyLjg3MjUgMzkzLjM3NkM3MS44MTYxIDM4Ni40MDMgLTM0LjQxMTggMzI3LjA2NSAxLjk4NzAyIDI5OC4xN0MzOC4zODU4IDI2OS4yNzYgMTM0Ljc2NiAzNTQuMjQ5IDk2LjQ3OTYgMjI1LjQyNFoiIGZpbGw9IiM5RDgxRkYiLz4KPC9nPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyM19mXzIwMzVfMTEwNikiPgo8cGF0aCBkPSJNMjgyLjEyIC0xMDcuMzUzQzIxNi4wNDcgLTE4Ni4wMzEgMTIxLjQ2MyAtMTIwLjk3IDgyLjQyOTYgLTc4LjYwNDdDNDguMjczOSAtMzAuNjQ0NiAyMjQuMjc1IDU3LjIzMTIgMjczLjEyMSA0Mi4xNzE0QzMyMS45NjggMjcuMTExNSAyMDYuNTEyIC00LjA1MDM4IDIyNy4yOTcgLTMzLjI4NzlDMjQ4LjA4MiAtNjIuNTI1NSAzNjQuNzEyIC05LjAwNTY2IDI4Mi4xMiAtMTA3LjM1M1oiIGZpbGw9IiM0RDk0RkYiLz4KPC9nPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTkzLjE4OSAxNTIuODM2SDEzNi42NzRMODcuMjA4NiAxMDMuMDUxTDEzNy4zMSA1My4yNjYzTDE1MC45NTUgNDBIMTA1LjgxOUw0OC4zMzU5IDk3Ljc3NzNDNDUuNDM0OSAxMDAuNjg5IDQ1LjQ0OTggMTA1LjQwMiA0OC4zNjU2IDEwOC4yOTlMOTMuMTg5IDE1Mi44MzZaTTExOS4zMyAxMDMuMTY4SDExOC45OTVMMTE5LjMyNiAxMDMuMTY0TDExOS4zMyAxMDMuMTY4Wk0xMTkuMzMgMTAzLjE2OEwxNjguNzkxIDE1Mi45NDlMMTE4LjY5IDIwMi43MzRMMTA1LjA0NSAyMTZIMTUwLjE4TDIwNy42NjQgMTU4LjIyNkMyMTAuNTY1IDE1NS4zMTQgMjEwLjU1IDE1MC42MDIgMjA3LjYzNCAxNDcuNzA1TDE2Mi44MTEgMTAzLjE2OEgxMTkuMzNaIiBmaWxsPSJibGFjayIvPgo8L2c+CjxkZWZzPgo8ZmlsdGVyIGlkPSJmaWx0ZXIwX2ZfMjAzNV8xMTA2IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiIHdpZHRoPSI1NjkuNTU4IiBoZWlnaHQ9IjQ1MS40MzEiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyMV9mXzIwMzVfMTEwNiIgeD0iLTE2MC41MTEiIHk9Ii0xNjUuOTg3IiB3aWR0aD0iMzUxLjU5NiIgaGVpZ2h0PSIzNzEuNTA3IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxmaWx0ZXIgaWQ9ImZpbHRlcjJfZl8yMDM1XzExMDYiIHg9Ii0yNDEuMDc4IiB5PSI2Ny42NDIiIHdpZHRoPSI0NDQuODUxIiBoZWlnaHQ9IjQyNC40NTIiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyM19mXzIwMzVfMTEwNiIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4IiB3aWR0aD0iNDMwLjE5MSIgaGVpZ2h0PSIzODUuMTA1IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMjAzNV8xMTA2Ij4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==",name:"Bitget Wallet"},S8=[C8],$8=s=>S8.find(e=>e.name.toLocaleLowerCase().includes(s.name.toLocaleLowerCase()))||s,P8=(s,e,t)=>e[s]||t[s],Tf=(s,e)=>P8(s,$8(e),e);class pi extends te.Wallet{constructor(e,t){super(),this.adapter=e,this.connection=t}getAdapter(){return this.adapter}getName(){return Tf("name",this.adapter)}getUrl(){return this.adapter.url}async connect(){if(this.isConnected())return this.getAddresses();const e=await new Promise((t,i)=>{this.adapter.on("connect",()=>{this.adapter.off("connect"),this.adapter.off("error"),t(this.getAddresses())}),this.adapter.on("error",r=>{this.adapter.off("connect"),this.adapter.off("error"),i(r)}),this.adapter.connect().catch(i)});return this.emit("connect"),this.adapter.on("disconnect",()=>this.emit("disconnect")),e}getNetworkInfo(){return{}}isConnected(){return this.adapter.connected}async disconnect(){this.isConnected()&&(await new Promise((e,t)=>{this.adapter.on("disconnect",()=>{this.adapter.off("disconnect"),this.adapter.off("error"),e(void 0)}),this.adapter.on("error",i=>{this.adapter.off("disconnect"),this.adapter.off("error"),t(i)}),this.adapter.disconnect().catch(t)}),this.adapter.removeAllListeners(),this.emit("disconnect"))}getChainId(){return te.CHAIN_ID_SOLANA}getAddress(){var e;return(e=this.adapter.publicKey)==null?void 0:e.toString()}getAddresses(){const e=this.getAddress();return e?[e]:[]}setMainAddress(){throw new Error("Not supported")}getBalance(){throw new Error("Not supported")}async signTransaction(e){if(!this.adapter.signTransaction||!this.adapter.signAllTransactions)throw new Error("Not supported");return Array.isArray(e)?this.adapter.signAllTransactions(e):this.adapter.signTransaction(e)}async sendTransaction(e){var n;const{transaction:t}=e,i=Array.isArray(t)?t:[t];if(i.length===0)throw new Error("Empty transactions array");const r=[];for(const o of i){const a=await this.adapter.sendTransaction(o,this.connection,{...e.options});r.push(a)}return await this.connection.confirmTransaction(r[0],(n=e.options)==null?void 0:n.commitment),{id:r[0],data:r.length===1?r[0]:r}}async signAndSendTransaction(e){return this.sendTransaction(e)}signMessage(e){if(!this.adapter.signMessage)throw new Error("Not supported");return this.adapter.signMessage(e)}getIcon(){return Tf("icon",this.adapter)}getWalletState(){const e=this.adapter.readyState;if(!(e in te.WalletState))throw new Error(`Unknown wallet state ${e}`);return te.WalletState[e]}getFeatures(){const e=[te.BaseFeatures.SendTransaction,te.BaseFeatures.SignAndSendTransaction];return this.adapter.signTransaction&&this.adapter.signAllTransactions&&e.push(te.BaseFeatures.SignTransaction),this.adapter.signMessage&&e.push(te.BaseFeatures.SignMessage),e}supportsChain(e){return e===te.CHAIN_ID_SOLANA}}function T8(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var M8="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const x8=T8(M8);var K=function(s,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!i:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(s):i?i.value:e.get(s)},it=function(s,e,t,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(s,t):r?r.value=t:e.set(s,t),t},$t,Jt,Ji,Xi,Hi,uo,pc,ye,gc,qh,Ka,Bh,No,Hh,Mf,xf,Of,Df;class O8 extends Uf{get name(){return K(this,ye,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return K(this,ye,"f").icon}get readyState(){return K(this,gc,"f")}get publicKey(){return K(this,Ji,"f")}get connecting(){return K(this,Xi,"f")}get supportedTransactionVersions(){return K(this,pc,"f")}get wallet(){return K(this,ye,"f")}get standard(){return!0}constructor({wallet:e}){super(),$t.add(this),Jt.set(this,void 0),Ji.set(this,void 0),Xi.set(this,void 0),Hi.set(this,void 0),uo.set(this,void 0),pc.set(this,void 0),ye.set(this,void 0),gc.set(this,typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.Installed),Hh.set(this,t=>{if("accounts"in t){const i=K(this,ye,"f").accounts[0];K(this,Jt,"f")&&!K(this,Hi,"f")&&i!==K(this,Jt,"f")&&(i?K(this,$t,"m",Ka).call(this,i):(this.emit("error",new Rf),K(this,$t,"m",Bh).call(this)))}"features"in t&&K(this,$t,"m",No).call(this)}),it(this,ye,e,"f"),it(this,Jt,null,"f"),it(this,Ji,null,"f"),it(this,Xi,!1,"f"),it(this,Hi,!1,"f"),it(this,uo,K(this,ye,"f").features[zf].on("change",K(this,Hh,"f")),"f"),K(this,$t,"m",No).call(this)}destroy(){it(this,Jt,null,"f"),it(this,Ji,null,"f"),it(this,Xi,!1,"f"),it(this,Hi,!1,"f");const e=K(this,uo,"f");e&&(it(this,uo,null,"f"),e())}async autoConnect(){return K(this,$t,"m",qh).call(this,{silent:!0})}async connect(){return K(this,$t,"m",qh).call(this)}async disconnect(){if(Tu in K(this,ye,"f").features)try{it(this,Hi,!0,"f"),await K(this,ye,"f").features[Tu].disconnect()}catch(e){this.emit("error",new zo(e==null?void 0:e.message,e))}finally{it(this,Hi,!1,"f")}K(this,$t,"m",Bh).call(this)}async sendTransaction(e,t,i={}){try{const r=K(this,Jt,"f");if(!r)throw new Fe;let n;if(yi in K(this,ye,"f").features)if(r.features.includes(yi))n=yi;else if(St in K(this,ye,"f").features&&r.features.includes(St))n=St;else throw new vs;else if(St in K(this,ye,"f").features){if(!r.features.includes(St))throw new vs;n=St}else throw new ln;const o=Ub(t.rpcEndpoint);if(!r.chains.includes(o))throw new Gi;try{const{signers:a,...l}=i;let c;if(si(e)?(a!=null&&a.length&&e.sign(a),c=e.serialize()):(e=await this.prepareTransaction(e,t,l),a!=null&&a.length&&e.partialSign(...a),c=new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))),n===yi){const[h]=await K(this,ye,"f").features[yi].signAndSendTransaction({account:r,chain:o,transaction:c,options:{preflightCommitment:Uc(l.preflightCommitment||t.commitment),skipPreflight:l.skipPreflight,maxRetries:l.maxRetries,minContextSlot:l.minContextSlot}});return x8.encode(h.signature)}else{const[h]=await K(this,ye,"f").features[St].signTransaction({account:r,chain:o,transaction:c,options:{preflightCommitment:Uc(l.preflightCommitment||t.commitment),minContextSlot:l.minContextSlot}});return await t.sendRawTransaction(h.signedTransaction,{...l,preflightCommitment:Uc(l.preflightCommitment||t.commitment)})}}catch(a){throw a instanceof Tt?a:new Gi(a==null?void 0:a.message,a)}}catch(r){throw this.emit("error",r),r}}}Jt=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,Hi=new WeakMap,uo=new WeakMap,pc=new WeakMap,ye=new WeakMap,gc=new WeakMap,Hh=new WeakMap,$t=new WeakSet,qh=async function(e){try{if(this.connected||this.connecting)return;if(K(this,gc,"f")!==ae.Installed)throw new Ti;if(it(this,Xi,!0,"f"),!K(this,ye,"f").accounts.length)try{await K(this,ye,"f").features[Lf].connect(e)}catch(i){throw new fc(i==null?void 0:i.message,i)}const t=K(this,ye,"f").accounts[0];if(!t)throw new vs;K(this,$t,"m",Ka).call(this,t)}catch(t){throw this.emit("error",t),t}finally{it(this,Xi,!1,"f")}},Ka=function(e){let t;try{t=new N.PublicKey(e.address)}catch(i){throw new dr(i==null?void 0:i.message,i)}it(this,Jt,e,"f"),it(this,Ji,t,"f"),K(this,$t,"m",No).call(this),this.emit("connect",t)},Bh=function(){it(this,Jt,null,"f"),it(this,Ji,null,"f"),K(this,$t,"m",No).call(this),this.emit("disconnect")},No=function(){var t,i;const e=yi in K(this,ye,"f").features?K(this,ye,"f").features[yi].supportedTransactionVersions:K(this,ye,"f").features[St].supportedTransactionVersions;it(this,pc,fb.arraysEqual(e,["legacy"])?null:new Set(e),"f"),St in K(this,ye,"f").features&&((t=K(this,Jt,"f"))!=null&&t.features.includes(St))?(this.signTransaction=K(this,$t,"m",Mf),this.signAllTransactions=K(this,$t,"m",xf)):(delete this.signTransaction,delete this.signAllTransactions),Dn in K(this,ye,"f").features&&((i=K(this,Jt,"f"))!=null&&i.features.includes(Dn))?this.signMessage=K(this,$t,"m",Of):delete this.signMessage,jc in K(this,ye,"f").features?this.signIn=K(this,$t,"m",Df):delete this.signIn},Mf=async function(e){try{const t=K(this,Jt,"f");if(!t)throw new Fe;if(!(St in K(this,ye,"f").features))throw new ln;if(!t.features.includes(St))throw new vs;try{const r=(await K(this,ye,"f").features[St].signTransaction({account:t,transaction:si(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return si(e)?N.VersionedTransaction.deserialize(r):N.Transaction.from(r)}catch(i){throw i instanceof Tt?i:new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},xf=async function(e){try{const t=K(this,Jt,"f");if(!t)throw new Fe;if(!(St in K(this,ye,"f").features))throw new ln;if(!t.features.includes(St))throw new vs;try{const i=await K(this,ye,"f").features[St].signTransaction(...e.map(r=>({account:t,transaction:si(r)?r.serialize():new Uint8Array(r.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return e.map((r,n)=>{const o=i[n].signedTransaction;return si(r)?N.VersionedTransaction.deserialize(o):N.Transaction.from(o)})}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},Of=async function(e){try{const t=K(this,Jt,"f");if(!t)throw new Fe;if(!(Dn in K(this,ye,"f").features))throw new ln;if(!t.features.includes(Dn))throw new vs;try{return(await K(this,ye,"f").features[Dn].signMessage({account:t,message:e}))[0].signature}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},Df=async function(e={}){try{if(!(jc in K(this,ye,"f").features))throw new ln;let t;try{[t]=await K(this,ye,"f").features[jc].signIn(e)}catch(i){throw new Pu(i==null?void 0:i.message,i)}if(!t)throw new Pu;return K(this,$t,"m",Ka).call(this,t.account),t}catch(t){throw this.emit("error",t),t}};function D8(s){return mb.getWallets().get().filter(bb).map(e=>new pi(new O8({wallet:e}),s))}function k8(s){return s.includes("rpcpool.com")?"triton":s.includes("helius-rpc.com")?"helius":s.includes("rpc.ankr.com")?"ankr":"unknown"}async function j8(s,e,t,i){const r=i.transaction.transaction,n=o=>o.programId.toString()!=="ComputeBudget111111111111111111111111111111";if(Rl.isVersionedTransaction(r)){const o=(await Promise.all(r.message.addressTableLookups.map(l=>s.getAddressLookupTable(l.accountKey)))).map(l=>l.value).filter(l=>l!==null),a=N.TransactionMessage.decompile(r.message,{addressLookupTableAccounts:o});a.recentBlockhash=e,r.message.recentBlockhash=e,a.instructions=a.instructions.filter(n),a.instructions.push(...await kf(s,r)),r.message=a.compileToV0Message(o),r.sign(i.transaction.signers??[])}else r.recentBlockhash=e,r.lastValidBlockHeight=t,r.instructions=r.instructions.filter(n),r.add(...await kf(s,r)),i.transaction.signers&&r.partialSign(...i.transaction.signers);return r}async function kf(s,e,t){var y,w;let i=2e5,r=0;e:for(;;){if(Rl.isVersionedTransaction(e)&&!e.message.recentBlockhash){const{blockhash:A}=await s.getLatestBlockhash(t);e.message.recentBlockhash=A}const v=await(Rl.isVersionedTransaction(e)?s.simulateTransaction(e,{commitment:t,replaceRecentBlockhash:!0}):s.simulateTransaction(e));if(v.value.err){if(R8(v.value)){if(r<5){r++,await te.sleep(1e3);continue e}}else if(r<3){r++,await te.sleep(1e3);continue e}throw new Error(`Simulation failed: ${JSON.stringify(v.value.err)}
|
|
915
|
+
`,xa={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603};function aa(s){return{formatters:void 0,fees:void 0,serializers:void 0,...s}}const zh=aa({id:"5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",name:"Solana",network:"solana-mainnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!1,chainNamespace:"solana",caipNetworkId:"solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp",deprecatedCaipNetworkId:"solana:4sGjMW1sUnHzSxGspuhpqLDx6wiyjNtZ"}),Fh=aa({id:"EtWTRABZaYq6iMfeYKouRu166VU2xqa1",name:"Solana Devnet",network:"solana-devnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1",deprecatedCaipNetworkId:"solana:8E9rvCKLFQia2Y35HXjjpWzj8weVo44K"}),h8=aa({id:"4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z",name:"Solana Testnet",network:"solana-testnet",nativeCurrency:{name:"Solana",symbol:"SOL",decimals:9},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},blockExplorers:{default:{name:"Solscan",url:"https://solscan.io"}},testnet:!0,chainNamespace:"solana",caipNetworkId:"solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z"});aa({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});aa({id:"000000000933ea01ad0ee984209779ba",caipNetworkId:"bip122:000000000933ea01ad0ee984209779ba",chainNamespace:"bip122",name:"Bitcoin Testnet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const u8={solana:["solana_signMessage","solana_signTransaction","solana_requestAccounts","solana_getAccounts","solana_signAllTransactions","solana_signAndSendTransaction"],eip155:["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_showCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"],bip122:["sendTransfer","signMessage","signPsbt","getAccountAddresses"]},ub={getMethodsByChainNamespace(s){return u8[s]||[]},createDefaultNamespace(s){return{methods:this.getMethodsByChainNamespace(s),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(s,e){if(!e)return{...s};const t={...s},i=new Set;if(e.methods&&Object.keys(e.methods).forEach(r=>i.add(r)),e.chains&&Object.keys(e.chains).forEach(r=>i.add(r)),e.events&&Object.keys(e.events).forEach(r=>i.add(r)),e.rpcMap&&Object.keys(e.rpcMap).forEach(r=>{const[n]=r.split(":");n&&i.add(n)}),i.forEach(r=>{t[r]||(t[r]=this.createDefaultNamespace(r))}),e.methods&&Object.entries(e.methods).forEach(([r,n])=>{t[r]&&(t[r].methods=n)}),e.chains&&Object.entries(e.chains).forEach(([r,n])=>{t[r]&&(t[r].chains=n)}),e.events&&Object.entries(e.events).forEach(([r,n])=>{t[r]&&(t[r].events=n)}),e.rpcMap){const r=new Set;Object.entries(e.rpcMap).forEach(([n,o])=>{const[a,l]=n.split(":");!a||!l||!t[a]||(t[a].rpcMap||(t[a].rpcMap={}),r.has(a)||(t[a].rpcMap={},r.add(a)),t[a].rpcMap[l]=o)})}return t},createNamespaces(s,e){const t=s.reduce((i,r)=>{const{id:n,chainNamespace:o,rpcUrls:a}=r,l=a.default.http[0];i[o]||(i[o]=this.createDefaultNamespace(o));const c=`${o}:${n}`,h=i[o];switch(h.chains.push(c),c){case zh.caipNetworkId:h.chains.push(zh.deprecatedCaipNetworkId);break;case Fh.caipNetworkId:h.chains.push(Fh.deprecatedCaipNetworkId);break}return h!=null&&h.rpcMap&&l&&(h.rpcMap[n]=l),i},{});return this.applyNamespaceOverrides(t,e)},resolveReownName:async s=>{var i;const e=await Ow.resolveName(s);return((i=(Object.values(e==null?void 0:e.addresses)||[])[0])==null?void 0:i.address)||!1},getChainsFromNamespaces(s={}){return Object.values(s).flatMap(e=>{const t=e.chains||[],i=e.accounts.map(r=>{const[n,o]=r.split(":");return`${n}:${o}`});return Array.from(new Set([...t,...i]))})},isSessionEventData(s){return typeof s=="object"&&s!==null&&"id"in s&&"topic"in s&&"params"in s&&typeof s.params=="object"&&s.params!==null&&"chainId"in s.params&&"event"in s.params&&typeof s.params.event=="object"&&s.params.event!==null}};class db{constructor({provider:e,caipNetworks:t,namespace:i}){this.id=Z.CONNECTOR_ID.WALLET_CONNECT,this.name=ac.ConnectorNamesMap[Z.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=ac.ConnectorImageIds[Z.CONNECTOR_ID.WALLET_CONNECT],this.caipNetworks=t,this.provider=e,this.chain=i}get chains(){return this.caipNetworks}async connectWalletConnect(){if(!await this.authenticate()){const t=k.state.universalProviderConfigOverride,i=ub.createNamespaces(this.caipNetworks,t);await this.provider.connect({optionalNamespaces:i})}return{clientId:await this.provider.client.core.crypto.getClientId(),session:this.provider.session}}async disconnect(){await this.provider.disconnect()}async authenticate(){const e=this.chains.map(t=>t.caipNetworkId);return fn.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:d8})}}const d8=["eth_accounts","eth_requestAccounts","eth_sendRawTransaction","eth_sign","eth_signTransaction","eth_signTypedData","eth_signTypedData_v3","eth_signTypedData_v4","eth_sendTransaction","personal_sign","wallet_switchEthereumChain","wallet_addEthereumChain","wallet_getPermissions","wallet_requestPermissions","wallet_registerOnboarding","wallet_watchAsset","wallet_scanQRCode","wallet_getCallsStatus","wallet_sendCalls","wallet_getCapabilities","wallet_grantPermissions","wallet_revokePermissions","wallet_getAssets"];class p8{constructor(e){this.availableConnectors=[],this.eventListeners=new Map,e&&this.construct(e)}construct(e){this.caipNetworks=e.networks,this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get networks(){return this.caipNetworks||[]}setAuthProvider(e){this.addConnector({id:Z.CONNECTOR_ID.AUTH,type:"AUTH",name:Z.CONNECTOR_NAMES.AUTH,provider:e,imageId:ac.ConnectorImageIds[Z.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const t=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(i=>t.has(i.id)?!1:(t.add(i.id),!0)),this.emit("connectors",this.availableConnectors)}setStatus(e,t){J.setStatus(e,t)}on(e,t){var i;this.eventListeners.has(e)||this.eventListeners.set(e,new Set),(i=this.eventListeners.get(e))==null||i.add(t)}off(e,t){const i=this.eventListeners.get(e);i&&i.delete(t)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,t){const i=this.eventListeners.get(e);i&&i.forEach(r=>r(t))}async connectWalletConnect(e){return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}async switchNetwork(e){const{caipNetwork:t,providerType:i}=e;if(!e.provider)return;const r="provider"in e.provider?e.provider.provider:e.provider;if(i==="WALLET_CONNECT"){r.setDefaultChain(t.caipNetworkId);return}if(r&&i==="AUTH"){const n=r;await n.switchNetwork(t.caipNetworkId);const o=await n.getUser({chainId:t.caipNetworkId,preferredAccountType:k.state.defaultAccountTypes[t.chainNamespace]});this.emit("switchNetwork",o)}}getWalletConnectConnector(){const e=this.connectors.find(t=>t instanceof db);if(!e)throw new Error("WalletConnectConnector not found");return e}}class g8 extends p8{setUniversalProvider(e){this.addConnector(new db({provider:e,caipNetworks:this.caipNetworks||[],namespace:this.namespace}))}async connect(e){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:Number(e.chainId),provider:this.provider,address:""})}async disconnect(){try{await this.getWalletConnectConnector().disconnect()}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}}async getAccounts({namespace:e}){var r,n,o,a;const t=this.provider,i=((a=(o=(n=(r=t==null?void 0:t.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(l=>{const[,,c]=l.split(":");return c}).filter((l,c,h)=>h.indexOf(l)===c))||[];return Promise.resolve({accounts:i.map(l=>re.createAccount(e,l,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){var n,o,a,l,c;if(!(e.caipNetwork&&qt.BALANCE_SUPPORTED_CHAINS.includes((n=e.caipNetwork)==null?void 0:n.chainNamespace))||(o=e.caipNetwork)!=null&&o.testnet)return{balance:"0.00",symbol:((a=e.caipNetwork)==null?void 0:a.nativeCurrency.symbol)||""};if(J.state.balanceLoading&&e.chainId===((l=I.state.activeCaipNetwork)==null?void 0:l.id))return{balance:J.state.balance||"0.00",symbol:J.state.balanceSymbol||""};const r=(await J.fetchTokenBalance()).find(h=>{var u,d;return h.chainId===`${(u=e.caipNetwork)==null?void 0:u.chainNamespace}:${e.chainId}`&&h.symbol===((d=e.caipNetwork)==null?void 0:d.nativeCurrency.symbol)});return{balance:(r==null?void 0:r.quantity.numeric)||"0.00",symbol:(r==null?void 0:r.symbol)||((c=e.caipNetwork)==null?void 0:c.nativeCurrency.symbol)||""}}async signMessage(e){var o,a,l;const{provider:t,message:i,address:r}=e;if(!t)throw new Error("UniversalAdapter:signMessage - provider is undefined");let n="";return((o=I.state.activeCaipNetwork)==null?void 0:o.chainNamespace)===Z.CHAIN.SOLANA?n=(await t.request({method:"solana_signMessage",params:{message:Gw.encode(new TextEncoder().encode(i)),pubkey:r}},(a=I.state.activeCaipNetwork)==null?void 0:a.caipNetworkId)).signature:n=await t.request({method:"personal_sign",params:[i,r]},(l=I.state.activeCaipNetwork)==null?void 0:l.caipNetworkId),{signature:n}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async getProfile(){return Promise.resolve({profileImage:"",profileName:""})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}async getEnsAddress(){return Promise.resolve({address:!1})}parseUnits(){return 0n}formatUnits(){return"0"}async getCapabilities(){return Promise.resolve({})}async grantPermissions(){return Promise.resolve({})}async revokePermissions(){return Promise.resolve("0x")}async syncConnection(){return Promise.resolve({id:"WALLET_CONNECT",type:"WALLET_CONNECT",chainId:1,provider:this.provider,address:""})}async switchNetwork(e){var r,n,o,a,l,c;const{caipNetwork:t}=e,i=this.getWalletConnectConnector();if(t.chainNamespace===Z.CHAIN.EVM)try{await((r=i.provider)==null?void 0:r.request({method:"wallet_switchEthereumChain",params:[{chainId:E.toHex(t.id)}]}))}catch(h){if(h.code===xa.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||h.code===xa.ERROR_INVALID_CHAIN_ID||h.code===xa.ERROR_CODE_DEFAULT||((o=(n=h==null?void 0:h.data)==null?void 0:n.originalError)==null?void 0:o.code)===xa.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await((c=i.provider)==null?void 0:c.request({method:"wallet_addEthereumChain",params:[{chainId:E.toHex(t.id),rpcUrls:[(a=t==null?void 0:t.rpcUrls.chainDefault)==null?void 0:a.http],chainName:t.name,nativeCurrency:t.nativeCurrency,blockExplorerUrls:[(l=t.blockExplorers)==null?void 0:l.default.url]}]}))}catch{throw new Error("Chain is not supported")}}i.provider.setDefaultChain(t.caipNetworkId)}getWalletConnectProvider(){const e=this.connectors.find(i=>i.type==="WALLET_CONNECT");return e==null?void 0:e.provider}}class f8{constructor(e){var t;this.hasSwitchedToPreferredAccountTypeOnConnect=!1,this.chainNamespaces=[],this.reportedAlertErrors={},this.getCaipNetwork=i=>{var r,n;if(i){const o=(r=I.getNetworkData(i))==null?void 0:r.caipNetwork;return o||((n=I.getRequestedCaipNetworks(i).filter(a=>a.chainNamespace===i))==null?void 0:n[0])}return I.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const i=this.getCaipNetwork();if(i)return i.id},this.getCaipNetworks=i=>I.getRequestedCaipNetworks(i),this.getActiveChainNamespace=()=>I.state.activeChain,this.setRequestedCaipNetworks=(i,r)=>{I.setRequestedCaipNetworks(i,r)},this.getApprovedCaipNetworkIds=()=>I.getAllApprovedCaipNetworkIds(),this.getCaipAddress=i=>I.state.activeChain===i||!i?I.state.activeCaipAddress:I.getAccountProp("caipAddress",i),this.setClientId=i=>{ee.setClientId(i)},this.getProvider=i=>Ze.getProvider(i),this.getProviderType=i=>Ze.getProviderId(i),this.getPreferredAccountType=()=>J.state.preferredAccountType,this.setCaipAddress=(i,r)=>{J.setCaipAddress(i,r)},this.setBalance=(i,r,n)=>{J.setBalance(i,r,n)},this.setProfileName=(i,r)=>{J.setProfileName(i,r)},this.setProfileImage=(i,r)=>{J.setProfileImage(i,r)},this.setUser=(i,r)=>{J.setUser(i,r),k.state.enableEmbedded&&et.close()},this.resetAccount=i=>{J.resetAccount(i)},this.setCaipNetwork=i=>{I.setActiveCaipNetwork(i)},this.setCaipNetworkOfNamespace=(i,r)=>{I.setChainNetworkData(r,{caipNetwork:i})},this.setAllAccounts=(i,r)=>{J.setAllAccounts(i,r),k.setHasMultipleAddresses((i==null?void 0:i.length)>1)},this.setStatus=(i,r)=>{J.setStatus(i,r),ie.isConnected()?Y.setConnectionStatus("connected"):Y.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=i=>I.getAccountProp("address",i),this.setConnectors=i=>{const r=[...ie.getConnectors(),...i];ie.setConnectors(r)},this.fetchIdentity=i=>ee.fetchIdentity(i),this.getReownName=i=>Ow.getNamesForAddress(i),this.getConnectors=()=>ie.getConnectors(),this.getConnectorImage=i=>cu.getConnectorImage(i),this.setConnectedWalletInfo=(i,r)=>{const n=Ze.getProviderId(r),o=i?{...i,type:n}:void 0;J.setConnectedWalletInfo(o,r)},this.getIsConnectedState=()=>!!I.state.activeCaipAddress,this.addAddressLabel=(i,r,n)=>{J.addAddressLabel(i,r,n)},this.removeAddressLabel=(i,r)=>{J.removeAddressLabel(i,r)},this.getAddress=i=>I.state.activeChain===i||!i?J.state.address:I.getAccountProp("address",i),this.setApprovedCaipNetworksData=i=>I.setApprovedCaipNetworksData(i),this.resetNetwork=i=>{I.resetNetwork(i)},this.addConnector=i=>{ie.addConnector(i)},this.resetWcConnection=()=>{ke.resetWcConnection()},this.setAddressExplorerUrl=(i,r)=>{J.setAddressExplorerUrl(i,r)},this.setSmartAccountDeployed=(i,r)=>{J.setSmartAccountDeployed(i,r)},this.setSmartAccountEnabledNetworks=(i,r)=>{I.setSmartAccountEnabledNetworks(i,r)},this.setPreferredAccountType=(i,r)=>{J.setPreferredAccountType(i,r)},this.setEIP6963Enabled=i=>{k.setEIP6963Enabled(i)},this.handleUnsafeRPCRequest=()=>{if(this.isOpen()){if(this.isTransactionStackEmpty())return;this.redirect("ApproveTransaction")}else this.open({view:"ApproveTransaction"})},this.options=e,this.version=e.sdkVersion,this.caipNetworks=this.extendCaipNetworks(e),this.chainNamespaces=[...new Set((t=this.caipNetworks)==null?void 0:t.map(i=>i.chainNamespace))],this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.initialize(e),this.sendInitializeEvent(e)}async initialize(e){this.initControllers(e),await this.initChainAdapters(),await this.injectModalUi(),await this.syncExistingConnection(),ri.set({initialized:!0})}sendInitializeEvent(e){var i;const{...t}=e;delete t.adapters,je.sendEvent({type:"track",event:"INITIALIZE",properties:{...t,networks:e.networks.map(r=>r.id),siweConfig:{options:((i=e.siweConfig)==null?void 0:i.options)||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&jt.setThemeMode(e.themeMode),e.themeVariables&&jt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");I.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const t=this.getDefaultNetwork();t&&I.setActiveCaipNetwork(t)}initializeConnectionController(e){ke.setWcBasic(e.basic??!1)}initializeConnectorController(){ie.initialize(this.chainNamespaces)}initializeOptionsController(e){var r;k.setDebug(e.debug!==!1),k.setEnableWalletConnect(e.enableWalletConnect!==!1),k.setEnableWalletGuide(e.enableWalletGuide!==!1),k.setEnableWallets(e.enableWallets!==!1),k.setEIP6963Enabled(e.enableEIP6963!==!1),k.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),k.setEnableAuthLogger(e.enableAuthLogger!==!1),k.setCustomRpcUrls(e.customRpcUrls),k.setSdkVersion(e.sdkVersion),k.setProjectId(e.projectId),k.setEnableEmbedded(e.enableEmbedded),k.setAllWallets(e.allWallets),k.setIncludeWalletIds(e.includeWalletIds),k.setExcludeWalletIds(e.excludeWalletIds),k.setFeaturedWalletIds(e.featuredWalletIds),k.setTokens(e.tokens),k.setTermsConditionsUrl(e.termsConditionsUrl),k.setPrivacyPolicyUrl(e.privacyPolicyUrl),k.setCustomWallets(e.customWallets),k.setFeatures(e.features),k.setAllowUnsupportedChain(e.allowUnsupportedChain),k.setDefaultAccountTypes(e.defaultAccountTypes),k.setUniversalProviderConfigOverride(e.universalProviderConfigOverride);const t=this.getDefaultMetaData();if(!e.metadata&&t&&(e.metadata=t),k.setMetadata(e.metadata),k.setDisableAppend(e.disableAppend),k.setEnableEmbedded(e.enableEmbedded),k.setSIWX(e.siwx),!e.projectId){fo.open(Ma.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(((r=e.adapters)==null?void 0:r.find(n=>n.namespace===Z.CHAIN.EVM))&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");k.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){var e,t,i,r;return typeof window<"u"&&typeof document<"u"?{name:((t=(e=document.getElementsByTagName("title"))==null?void 0:e[0])==null?void 0:t.textContent)||"",description:((i=document.querySelector('meta[property="og:description"]'))==null?void 0:i.content)||"",url:window.location.origin,icons:[((r=document.querySelector('link[rel~="icon"]'))==null?void 0:r.href)||""]}:null}setUnsupportedNetwork(e){const t=this.getActiveChainNamespace();if(t){const i=an.getUnsupportedNetwork(`${t}:${e}`);I.setActiveCaipNetwork(i)}}getDefaultNetwork(){return an.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,t){return an.extendCaipNetwork(e,{customNetworkImageUrls:t.chainImages,projectId:t.projectId})}extendCaipNetworks(e){return an.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const t=e.networks.find(r=>{var n;return r.id===((n=e.defaultNetwork)==null?void 0:n.id)});return t?an.extendCaipNetwork(t,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{var n;const e=I.state.activeChain,t=this.getAdapter(e),i=(n=this.getCaipNetwork(e))==null?void 0:n.id;if(!t)throw new Error("Adapter not found");const r=await t.connectWalletConnect(i);this.close(),this.setClientId((r==null?void 0:r.clientId)||null),Y.setConnectedNamespaces([...I.state.chains.keys()]),this.chainNamespaces.forEach(o=>{ie.setConnectorId(di.CONNECTOR_TYPE_WALLET_CONNECT,o)}),await this.syncWalletConnectAccount()},connectExternal:async({id:e,info:t,type:i,provider:r,chain:n,caipNetwork:o})=>{var p,g,f,b,y,w,v;const a=I.state.activeChain,l=n||a,c=this.getAdapter(l);if(n&&n!==a&&!o){const A=(p=this.caipNetworks)==null?void 0:p.find(C=>C.chainNamespace===n);A&&this.setCaipNetwork(A)}if(!c)throw new Error("Adapter not found");const h=this.getCaipNetwork(l),u=await c.connect({id:e,info:t,type:i,provider:r,chainId:(o==null?void 0:o.id)||(h==null?void 0:h.id),rpcUrl:((b=(f=(g=o==null?void 0:o.rpcUrls)==null?void 0:g.default)==null?void 0:f.http)==null?void 0:b[0])||((v=(w=(y=h==null?void 0:h.rpcUrls)==null?void 0:y.default)==null?void 0:w.http)==null?void 0:v[0])});if(!u)return;Y.addConnectedNamespace(l),this.syncProvider({...u,chainNamespace:l}),await this.syncAccount({...u,chainNamespace:l});const{accounts:d}=await c.getAccounts({namespace:l,id:e});this.setAllAccounts(d,l)},reconnectExternal:async({id:e,info:t,type:i,provider:r})=>{var a;const n=I.state.activeChain,o=this.getAdapter(n);o!=null&&o.reconnect&&(await(o==null?void 0:o.reconnect({id:e,info:t,type:i,provider:r,chainId:(a=this.getCaipNetwork())==null?void 0:a.id})),Y.addConnectedNamespace(n))},disconnect:async e=>{const t=e||I.state.activeChain,i=this.getAdapter(t),r=Ze.getProvider(t),n=Ze.getProviderId(t);await(i==null?void 0:i.disconnect({provider:r,providerType:n})),Y.removeConnectedNamespace(t),Ze.resetChain(t),this.setUser(void 0,t),this.setStatus("disconnected",t),this.hasSwitchedToPreferredAccountTypeOnConnect=!1},checkInstalled:e=>e?e.some(t=>{var i;return!!((i=window.ethereum)!=null&&i[String(t)])}):!!window.ethereum,signMessage:async e=>{const t=this.getAdapter(I.state.activeChain),i=await(t==null?void 0:t.signMessage({message:e,address:J.state.address,provider:Ze.getProvider(I.state.activeChain)}));return(i==null?void 0:i.signature)||""},sendTransaction:async e=>{if(e.chainNamespace===Z.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=Ze.getProvider(I.state.activeChain),r=await(t==null?void 0:t.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:i}));return(r==null?void 0:r.hash)||""}return""},estimateGas:async e=>{if(e.chainNamespace===Z.CHAIN.EVM){const t=this.getAdapter(I.state.activeChain),i=Ze.getProvider(I.state.activeChain),r=this.getCaipNetwork();if(!r)throw new Error("CaipNetwork is undefined");const n=await(t==null?void 0:t.estimateGas({...e,provider:i,caipNetwork:r}));return(n==null?void 0:n.gas)||0n}return 0n},getEnsAvatar:async()=>{var i;const e=this.getAdapter(I.state.activeChain),t=await(e==null?void 0:e.getProfile({address:J.state.address,chainId:Number((i=this.getCaipNetwork())==null?void 0:i.id)}));return(t==null?void 0:t.profileImage)||!1},getEnsAddress:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork();if(!i)return!1;const r=await(t==null?void 0:t.getEnsAddress({name:e,caipNetwork:i}));return(r==null?void 0:r.address)||!1},writeContract:async e=>{const t=this.getAdapter(I.state.activeChain),i=this.getCaipNetwork(),r=this.getCaipAddress(),n=Ze.getProvider(I.state.activeChain);if(!i||!r)throw new Error("CaipNetwork or CaipAddress is undefined");const o=await(t==null?void 0:t.writeContract({...e,caipNetwork:i,provider:n,caipAddress:r}));return o==null?void 0:o.hash},parseUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.parseUnits({value:e,decimals:t}))??0n},formatUnits:(e,t)=>{const i=this.getAdapter(I.state.activeChain);return(i==null?void 0:i.formatUnits({value:e,decimals:t}))??"0"},getCapabilities:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.getCapabilities(e))},grantPermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.grantPermissions(e))},revokePermissions:async e=>{const t=this.getAdapter(I.state.activeChain);return t!=null&&t.revokePermissions?await t.revokePermissions(e):"0x"},walletGetAssets:async e=>{const t=this.getAdapter(I.state.activeChain);return await(t==null?void 0:t.walletGetAssets(e))??{}}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},ke.setClient(this.connectionControllerClient)}getApprovedCaipNetworksData(){var t,i,r,n,o;if(Ze.getProviderId(I.state.activeChain)===di.CONNECTOR_TYPE_WALLET_CONNECT){const a=(i=(t=this.universalProvider)==null?void 0:t.session)==null?void 0:i.namespaces;return{supportsAllNetworks:((o=(n=(r=this.universalProvider)==null?void 0:r.session)==null?void 0:n.peer)==null?void 0:o.metadata.name)==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(a)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){if(!e)return;const t=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=Ze.getProvider(t),n=Ze.getProviderId(t);if(e.chainNamespace===I.state.activeChain){const o=this.getAdapter(t);await(o==null?void 0:o.switchNetwork({caipNetwork:e,provider:r,providerType:n}))}else if(this.setCaipNetwork(e),n===di.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(t);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:t})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(t=>{const i=t.chains||[],r=t.accounts.map(n=>{const{chainId:o,chainNamespace:a}=ci.parseCaipAddress(n);return`${a}:${o}`});return Array.from(new Set([...i,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((t,i)=>{var n;const r=e==null?void 0:e.find(o=>o.namespace===i);return r?(t[i]=r,t[i].namespace=i,t[i].construct({namespace:i,projectId:(n=this.options)==null?void 0:n.projectId,networks:this.caipNetworks})):t[i]=new g8({namespace:i,networks:this.caipNetworks}),t},{})}async initChainAdapter(e){var t;this.onConnectors(e),this.listenAdapter(e),(t=this.chainAdapters)==null||t[e].syncConnectors(this.options,this),await this.createUniversalProviderForAdapter(e)}async initChainAdapters(){await Promise.all(this.chainNamespaces.map(async e=>{await this.initChainAdapter(e)}))}onConnectors(e){const t=this.getAdapter(e);t==null||t.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const t=this.getAdapter(e);if(!t)return;const i=Y.getConnectionStatus();i==="connected"?this.setStatus("connecting",e):i==="disconnected"?(Y.clearAddressCache(),this.setStatus(i,e)):this.setStatus(i,e),t.on("switchNetwork",({address:r,chainId:n})=>{var c;const o=(c=this.caipNetworks)==null?void 0:c.find(h=>h.id===n||h.caipNetworkId===n),a=I.state.activeChain===e,l=I.getAccountProp("address",e);if(o){const h=a&&r?r:l;h&&this.syncAccount({address:h,chainId:n,chainNamespace:e})}else this.setUnsupportedNetwork(n)}),t.on("disconnect",this.disconnect.bind(this,e)),t.on("pendingTransactions",()=>{const r=J.state.address,n=I.state.activeCaipNetwork;!r||!(n!=null&&n.id)||this.updateNativeBalance(r,n.id,n.chainNamespace)}),t.on("accountChanged",({address:r,chainId:n})=>{var a,l;const o=I.state.activeChain===e;o&&n?this.syncAccount({address:r,chainId:n,chainNamespace:e}):o&&((a=I.state.activeCaipNetwork)!=null&&a.id)?this.syncAccount({address:r,chainId:(l=I.state.activeCaipNetwork)==null?void 0:l.id,chainNamespace:e}):this.syncAccountInfo(r,n,e)})}async createUniversalProviderForAdapter(e){var t,i,r;await this.getUniversalProvider(),this.universalProvider&&((r=(i=(t=this.chainAdapters)==null?void 0:t[e])==null?void 0:i.setUniversalProvider)==null||r.call(i,this.universalProvider))}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async syncNamespaceConnection(e){try{const t=ie.getConnectorId(e);switch(this.setStatus("connecting",e),t){case Z.CONNECTOR_ID.WALLET_CONNECT:await this.syncWalletConnectAccount();break;case Z.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(t){console.warn("AppKit couldn't sync existing connection",t),this.setStatus("disconnected",e)}}async syncAdapterConnection(e){var o,a,l;const t=this.getAdapter(e),i=ie.getConnectorId(e),r=this.getCaipNetwork(e),n=ie.getConnectors(e).find(c=>c.id===i);try{if(!t||!n)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!(r!=null&&r.id))throw new Error("CaipNetwork not found");const c=await(t==null?void 0:t.syncConnection({namespace:e,id:n.id,chainId:r.id,rpcUrl:(l=(a=(o=r==null?void 0:r.rpcUrls)==null?void 0:o.default)==null?void 0:a.http)==null?void 0:l[0]}));if(c){const h=await(t==null?void 0:t.getAccounts({namespace:e,id:n.id}));h&&h.accounts.length>0?this.setAllAccounts(h.accounts,e):this.setAllAccounts([re.createAccount(e,c.address,"eoa")],e),this.syncProvider({...c,chainNamespace:e}),await this.syncAccount({...c,chainNamespace:e}),this.setStatus("connected",e)}else this.setStatus("disconnected",e)}catch{this.setStatus("disconnected",e)}}async syncWalletConnectAccount(){const e=this.chainNamespaces.map(async t=>{var a,l,c,h,u;const i=this.getAdapter(t),r=((h=(c=(l=(a=this.universalProvider)==null?void 0:a.session)==null?void 0:l.namespaces)==null?void 0:c[t])==null?void 0:h.accounts)||[],n=(u=I.state.activeCaipNetwork)==null?void 0:u.id,o=r.find(d=>{const{chainId:p}=ci.parseCaipAddress(d);return p===(n==null?void 0:n.toString())})||r[0];if(o){const d=ci.validateCaipAddress(o),{chainId:p,address:g}=ci.parseCaipAddress(d);if(Ze.setProviderId(t,di.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&I.state.activeCaipNetwork&&(i==null?void 0:i.namespace)!==Z.CHAIN.EVM){const f=i==null?void 0:i.getWalletConnectProvider({caipNetworks:this.caipNetworks,provider:this.universalProvider,activeCaipNetwork:I.state.activeCaipNetwork});Ze.setProvider(t,f)}else Ze.setProvider(t,this.universalProvider);ie.setConnectorId(Z.CONNECTOR_ID.WALLET_CONNECT,t),Y.addConnectedNamespace(t),this.syncWalletConnectAccounts(t),await this.syncAccount({address:g,chainId:p,chainNamespace:t})}else this.setStatus("disconnected",t);await I.setApprovedCaipNetworksData(t)});await Promise.all(e)}syncWalletConnectAccounts(e){var i,r,n,o,a;const t=(a=(o=(n=(r=(i=this.universalProvider)==null?void 0:i.session)==null?void 0:r.namespaces)==null?void 0:n[e])==null?void 0:o.accounts)==null?void 0:a.map(l=>{const{address:c}=ci.parseCaipAddress(l);return c}).filter((l,c,h)=>h.indexOf(l)===c);t&&this.setAllAccounts(t.map(l=>re.createAccount(e,l,e==="bip122"?"payment":"eoa")),e)}syncProvider({type:e,provider:t,id:i,chainNamespace:r}){Ze.setProviderId(r,e),Ze.setProvider(r,t),ie.setConnectorId(i,r)}async syncAccount(e){var u,d,p,g,f,b;const t=e.chainNamespace===I.state.activeChain,i=I.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:n,chainNamespace:o}=e,{chainId:a}=Y.getActiveNetworkProps(),l=n||a,c=((u=I.state.activeCaipNetwork)==null?void 0:u.name)===Z.UNSUPPORTED_NETWORK_NAME,h=I.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(c&&!h)&&l){let y=(d=this.caipNetworks)==null?void 0:d.find(A=>A.id.toString()===l.toString()),w=(p=this.caipNetworks)==null?void 0:p.find(A=>A.chainNamespace===o);if(!h&&!y&&!w){const A=this.getApprovedCaipNetworkIds()||[],C=A.find(T=>{var O;return((O=ci.parseCaipNetworkId(T))==null?void 0:O.chainId)===l.toString()}),P=A.find(T=>{var O;return((O=ci.parseCaipNetworkId(T))==null?void 0:O.chainNamespace)===o});y=(g=this.caipNetworks)==null?void 0:g.find(T=>T.caipNetworkId===C),w=(f=this.caipNetworks)==null?void 0:f.find(T=>T.caipNetworkId===P||"deprecatedCaipNetworkId"in T&&T.deprecatedCaipNetworkId===P)}const v=y||w;(v==null?void 0:v.chainNamespace)===I.state.activeChain?k.state.enableNetworkSwitch&&!k.state.allowUnsupportedChain&&((b=I.state.activeCaipNetwork)==null?void 0:b.name)===Z.UNSUPPORTED_NETWORK_NAME?I.showUnsupportedChainUI():this.setCaipNetwork(v):t||i&&this.setCaipNetworkOfNamespace(i,o),this.syncConnectedWalletInfo(o),sb.isLowerCaseMatch(r,J.state.address)||this.syncAccountInfo(r,v==null?void 0:v.id,o),t?await this.syncBalance({address:r,chainId:v==null?void 0:v.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:i==null?void 0:i.id,chainNamespace:o})}}async syncAccountInfo(e,t,i){const r=this.getCaipAddress(i),n=t||(r==null?void 0:r.split(":")[1]);if(!n)return;const o=`${i}:${n}:${e}`;this.setCaipAddress(o,i),await this.syncIdentity({address:e,chainId:n,chainNamespace:i})}async syncReownName(e,t){try{const i=await this.getReownName(e);if(i[0]){const r=i[0];this.setProfileName(r.name,t)}else this.setProfileName(null,t)}catch{this.setProfileName(null,t)}}syncConnectedWalletInfo(e){var r;const t=ie.getConnectorId(e),i=Ze.getProviderId(e);if(i===di.CONNECTOR_TYPE_ANNOUNCED||i===di.CONNECTOR_TYPE_INJECTED){if(t){const n=this.getConnectors().find(o=>o.id===t);if(n){const{info:o,name:a,imageUrl:l}=n,c=l||this.getConnectorImage(n);this.setConnectedWalletInfo({name:a,icon:c,...o},e)}}}else if(i===di.CONNECTOR_TYPE_WALLET_CONNECT){const n=Ze.getProvider(e);n!=null&&n.session&&this.setConnectedWalletInfo({...n.session.peer.metadata,name:n.session.peer.metadata.name,icon:(r=n.session.peer.metadata.icons)==null?void 0:r[0]},e)}else if(t)if(t===Z.CONNECTOR_ID.COINBASE){const n=this.getConnectors().find(o=>o.id===Z.CONNECTOR_ID.COINBASE);this.setConnectedWalletInfo({name:"Coinbase Wallet",icon:this.getConnectorImage(n)},e)}else this.setConnectedWalletInfo({name:t},e)}async syncBalance(e){!$w.getNetworksByNamespace(this.caipNetworks,e.chainNamespace).find(i=>{var r;return i.id.toString()===((r=e.chainId)==null?void 0:r.toString())})||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async updateNativeBalance(e,t,i){const r=this.getAdapter(i);if(r){const n=await r.getBalance({address:e,chainId:t,caipNetwork:this.getCaipNetwork(i),tokens:this.options.tokens});this.setBalance(n.balance,n.symbol,i)}}async initializeUniversalAdapter(){var i,r,n,o,a,l,c,h,u,d;const e=Rz.createLogger((p,...g)=>{p&&this.handleAlertError(p),console.error(...g)}),t={projectId:(i=this.options)==null?void 0:i.projectId,metadata:{name:(r=this.options)!=null&&r.metadata?(n=this.options)==null?void 0:n.metadata.name:"",description:(o=this.options)!=null&&o.metadata?(a=this.options)==null?void 0:a.metadata.description:"",url:(l=this.options)!=null&&l.metadata?(c=this.options)==null?void 0:c.metadata.url:"",icons:(h=this.options)!=null&&h.metadata?(u=this.options)==null?void 0:u.metadata.icons:[""]},logger:e};k.setManualWCControl(!!((d=this.options)!=null&&d.manualWCControl)),this.universalProvider=this.options.universalProvider??await kz.init(t),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&(this.universalProvider.on("display_uri",e=>{ke.setUri(e)}),this.universalProvider.on("connect",ke.finalizeWcConnection),this.universalProvider.on("disconnect",()=>{this.chainNamespaces.forEach(e=>{this.resetAccount(e)}),ke.resetWcConnection()}),this.universalProvider.on("chainChanged",e=>{var r;const t=(r=this.caipNetworks)==null?void 0:r.find(n=>n.id==e),i=this.getCaipNetwork();if(!t){this.setUnsupportedNetwork(e);return}(i==null?void 0:i.id)!==(t==null?void 0:t.id)&&this.setCaipNetwork(t)}),this.universalProvider.on("session_event",e=>{if(ub.isSessionEventData(e)){const{name:t,data:i}=e.params.event;t==="accountsChanged"&&Array.isArray(i)&&re.isCaipAddress(i[0])&&this.syncAccount(ci.parseCaipAddress(i[0]))}}))}createUniversalProvider(){var e;return!this.universalProviderInitPromise&&re.isClient()&&((e=this.options)!=null&&e.projectId)&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){je.sendEvent({type:"error",event:"INTERNAL_SDK_ERROR",properties:{errorType:"UniversalProviderInitError",errorMessage:e instanceof Error?e.message:"Unknown",uncaught:!1}}),console.error("AppKit:getUniversalProvider - Cannot create provider",e)}return this.universalProvider}handleAlertError(e){const t=Object.entries(Ma.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[i,r]=t??[],{message:n,alertErrorKey:o}=r??{};if(i&&n&&!this.reportedAlertErrors[i]){const a=Ma.ALERT_ERRORS[o];a&&(fo.open(a,"error"),this.reportedAlertErrors[i]=!0)}}getAdapter(e){var t;if(e)return(t=this.chainAdapters)==null?void 0:t[e]}createAdapter(e){var r;if(!e)return;const t=e.namespace;if(!t)return;this.createClients();const i=e;i.namespace=t,i.construct({namespace:t,projectId:(r=this.options)==null?void 0:r.projectId,networks:this.caipNetworks}),this.chainNamespaces.includes(t)||this.chainNamespaces.push(t),this.chainAdapters&&(this.chainAdapters[t]=i)}async open(e){await this.injectModalUi(),e!=null&&e.uri&&ke.setUri(e.uri),await et.open(e)}async close(){await this.injectModalUi(),et.close()}setLoading(e,t){et.setLoading(e,t)}async disconnect(e){await ke.disconnect(e)}getError(){return""}getChainId(){var e;return(e=I.state.activeCaipNetwork)==null?void 0:e.id}async switchNetwork(e){var i;const t=(i=this.caipNetworks)==null?void 0:i.find(r=>r.id===e.id);if(!t){fo.open(Ma.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await I.switchActiveNetwork(t)}getWalletProvider(){return I.state.activeChain?Ze.state.providers[I.state.activeChain]:null}getWalletProviderType(){return Ze.getProviderId(I.state.activeChain)}subscribeProviders(e){return Ze.subscribeProviders(e)}getThemeMode(){return jt.state.themeMode}getThemeVariables(){return jt.state.themeVariables}setThemeMode(e){jt.setThemeMode(e),hb(jt.state.themeMode)}setTermsConditionsUrl(e){k.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){k.setPrivacyPolicyUrl(e)}setThemeVariables(e){jt.setThemeVariables(e),o8(jt.state.themeVariables)}subscribeTheme(e){return jt.subscribe(e)}getWalletInfo(){return J.state.connectedWalletInfo}getAccount(e){const t=ie.getAuthConnector(e),i=I.getAccountData(e);if(i)return{allAccounts:i.allAccounts,caipAddress:i.caipAddress,address:re.getPlainAddress(i.caipAddress),isConnected:!!i.caipAddress,status:i.status,embeddedWalletInfo:t?{user:i.user,authProvider:i.socialProvider||"email",accountType:i.preferredAccountType,isSmartAccountDeployed:!!i.smartAccountDeployed}:void 0}}subscribeAccount(e,t){const i=()=>{const r=this.getAccount(t);r&&e(r)};t?I.subscribeChainProp("accountState",i,t):I.subscribe(i),ie.subscribe(i)}subscribeNetwork(e){return I.subscribe(({activeCaipNetwork:t})=>{e({caipNetwork:t,chainId:t==null?void 0:t.id,caipNetworkId:t==null?void 0:t.caipNetworkId})})}subscribeWalletInfo(e){return J.subscribeKey("connectedWalletInfo",e)}subscribeShouldUpdateToAddress(e){J.subscribeKey("shouldUpdateToAddress",e)}subscribeCaipNetworkChange(e){I.subscribeKey("activeCaipNetwork",e)}getState(){return ri.state}subscribeState(e){return ri.subscribe(e)}showErrorMessage(e){wt.showError(e)}showSuccessMessage(e){wt.showSuccess(e)}getEvent(){return{...je.state}}subscribeEvents(e){return je.subscribe(e)}replace(e){_e.replace(e)}redirect(e){_e.push(e)}popTransactionStack(e){_e.popTransactionStack(e)}isOpen(){return et.state.open}isTransactionStackEmpty(){return _e.state.transactionStack.length===0}isTransactionShouldReplaceView(){var e;return(e=_e.state.transactionStack[_e.state.transactionStack.length-1])==null?void 0:e.replace}static getInstance(){return this.instance}updateFeatures(e){k.setFeatures(e)}updateOptions(e){const i={...k.state||{},...e};k.setOptions(i)}setConnectMethodsOrder(e){k.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){k.setWalletFeaturesOrder(e)}setCollapseWallets(e){k.setCollapseWallets(e)}setSocialsOrder(e){k.setSocialsOrder(e)}getConnectMethodsOrder(){return lc.getConnectOrderMethod(k.state.features,ie.getConnectors())}removeAdapter(e){var n;const t=this.getIsConnectedState(),i=this.getAdapter(e);if(!i||!this.chainAdapters||t)return;const r=(n=this.caipNetworks)==null?void 0:n.filter(o=>o.chainNamespace!==e);I.removeAdapter(e),ie.removeAdapter(e),this.chainNamespaces=this.chainNamespaces.filter(o=>o!==e),this.caipNetworks=r,i.removeAllEventListeners(),Reflect.deleteProperty(this.chainAdapters,e)}addAdapter(e,t){const i=e.namespace;if(!this.connectionControllerClient||!this.networkControllerClient||!this.chainAdapters||!i)return;const r=this.extendCaipNetworks({...this.options,networks:t});this.caipNetworks=[...this.caipNetworks||[],...r],this.createAdapter(e),this.initChainAdapter(i),I.addAdapter(e,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient},r)}addNetwork(e,t){var r;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const i=this.extendCaipNetwork(t,this.options);I.addNetwork(i),this.caipNetworks&&!((r=this.caipNetworks)!=null&&r.find(n=>n.id===i.id))&&this.caipNetworks.push(i)}removeNetwork(e,t){var n;if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);if(!((n=this.caipNetworks)==null?void 0:n.find(o=>o.id===t)))throw new Error(`Network with ID ${t} not found`);if(!this.caipNetworks)return;const r=this.caipNetworks.filter(o=>o.chainNamespace===e&&o.id!==t);if(!(r!=null&&r.length))throw new Error("Cannot remove last network for a namespace");I.removeNetwork(e,t),this.caipNetworks=[...r]}}let Sf=!1;class m8 extends f8{async open(e){ie.isConnected()||await super.open(e)}async close(){await super.close(),this.options.manualWCControl&&ke.finalizeWcConnection()}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!Sf&&re.isClient()){if(await Promise.resolve().then(()=>require("./basic-C2cAlU_P.js")),await Promise.resolve().then(()=>require("./w3m-modal-BRD-3_ln.js")),!document.querySelector("w3m-modal")){const t=document.createElement("w3m-modal");!k.state.disableAppend&&!k.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",t)}Sf=!0}}}const w8="1.7.2";function y8(s){return new m8({...s,basic:!0,sdkVersion:`html-core-${w8}`})}function b8(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var v8="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const jl=b8(v8);class pn extends Error{constructor(){super(),Object.setPrototypeOf(this,pn.prototype)}}class $f extends Error{constructor(e){super(`WalletConnect Adapter - Method ${e} is not supported by the wallet`),this.name="WalletConnectFeatureNotSupportedError"}}function I8(s){let e=[s];return s===lt.Mainnet||s===lt.Deprecated_Mainnet?(e=[lt.Mainnet,lt.Deprecated_Mainnet],s===lt.Deprecated_Mainnet&&console.warn(dc.mainnet)):(s===lt.Deprecated_Devnet||s===lt.Devnet)&&(e=[lt.Devnet,lt.Deprecated_Devnet],console.warn(dc.devnet)),e}const dc={mainnet:`You are using a deprecated chain ID for Solana Mainnet, please use ${lt.Mainnet} instead.`,devnet:`You are using a deprecated chain ID for Solana Devnet, please use ${lt.Devnet} instead.`,wallet:"The connected wallet is using a deprecated chain ID for Solana. Please, contact them to upgrade. You can learn more at https://github.com/ChainAgnostic/namespaces/blob/main/solana/caip10.md#chain-ids"};function Pf(s,e){var i;const t=(i=s.namespaces.solana)==null?void 0:i.accounts.map(r=>`solana:${r.split(":")[1]}`);if(e===lt.Mainnet)return t!=null&&t.find(r=>r===lt.Mainnet)?lt.Mainnet:(console.warn(dc.wallet),lt.Deprecated_Mainnet);if(e===lt.Devnet)return t!=null&&t.find(r=>r===lt.Devnet)?lt.Devnet:(console.warn(dc.wallet),lt.Deprecated_Devnet);throw Error("WalletConnect Solana Adapter: Unable to get a default chain from the session.")}function E8(s){return{optionalNamespaces:{solana:{chains:I8(s),methods:[ys.signTransaction,ys.signMessage],events:[]}}}}class Su extends Error{constructor(){super("QR Code Modal was closed by user"),Object.setPrototypeOf(this,Su.prototype),this.name="QRCodeModalError"}}class A8{constructor(e){vt(this,"_UniversalProvider");vt(this,"_session");vt(this,"_modal");vt(this,"_projectId");vt(this,"_network");vt(this,"_ConnectQueueResolver");if(this.initClient(e.options),this._network=e.network,!e.options.projectId)throw Error("WalletConnect Adapter: Project ID is undefined");this._projectId=e.options.projectId}async connect(){var r,n,o,a,l,c;if(this._UniversalProvider||await new Promise(h=>{this._ConnectQueueResolver=h}),!this._UniversalProvider)throw new Error("WalletConnect Adapter - Universal Provider was undefined while calling 'connect()'");if(this._UniversalProvider.session){this._session=this._UniversalProvider.session;const h=Pf(this._session,this._network);return this._network=h,this._UniversalProvider.setDefaultChain(h),{publicKey:this.publicKey}}await this.initModal();const e=E8(this._network);(r=this._modal)==null||r.open();const t=new AbortController,i=t.signal;(n=this._modal)==null||n.subscribeState(h=>{h.open||t.abort(new Su)});try{const h=await Promise.race([(o=this._UniversalProvider)==null?void 0:o.connect(e),new Promise((d,p)=>{i.addEventListener("abort",()=>{p(i.reason)})})]);if((a=this._modal)==null||a.close(),this._session=h,!h)throw new fc;const u=Pf(h,this._network);return this._network=u,(l=this._UniversalProvider)==null||l.setDefaultChain(u),{publicKey:this.publicKey}}catch(h){throw(c=this._modal)==null||c.close(),h}}async disconnect(){var e;if((e=this._UniversalProvider)!=null&&e.session){if(await this.initModal(),!this._modal)throw Error("WalletConnect Adapter -Modal is undefined: unable to disconnect");await this.client.disconnect(),this._session=void 0}else throw new pn}get client(){if(this._UniversalProvider)return this._UniversalProvider;throw new pn}get session(){if(!this._session)throw new pn;return this._session}get publicKey(){var e,t,i;if((e=this._UniversalProvider)!=null&&e.session&&this._session){const{address:r}=m0(((i=(t=this._session)==null?void 0:t.namespaces.solana)==null?void 0:i.accounts[0])??"");return new N.PublicKey(r)}throw new pn}async signTransaction(e){this.checkIfWalletSupportsMethod(ys.signTransaction);const t=si(e),i=t?{}:e,{signature:r,transaction:n}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signTransaction,params:{...i,transaction:this.serialize(e)}}});return n?this.deserialize(n,t):(e.addSignature(this.publicKey,N.dist.Buffer.from(jl.decode(r))),e)}async signMessage(e){this.checkIfWalletSupportsMethod(ys.signMessage);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signMessage,params:{pubkey:this.publicKey.toString(),message:jl.encode(e)}}});return jl.decode(t)}async signAndSendTransaction(e){this.checkIfWalletSupportsMethod(ys.signAndSendTransaction);const{signature:t}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signAndSendTransaction,params:{transaction:this.serialize(e)}}});return t}async signAllTransactions(e){try{this.checkIfWalletSupportsMethod(ys.signAllTransactions);const t=e.map(r=>this.serialize(r)),{transactions:i}=await this.client.client.request({chainId:this._network,topic:this.session.topic,request:{method:ys.signAllTransactions,params:{transactions:t}}});return e.map((r,n)=>si(r)?this.deserialize(i[n]??"",!0):this.deserialize(i[n]??""))}catch(t){if(t instanceof $f){const i=e.map(n=>this.signTransaction(n));return await Promise.all(i)}throw t}}async initClient(e){const t=await Rx.init(e);this._UniversalProvider=t,this._ConnectQueueResolver&&this._ConnectQueueResolver(!0)}async initModal(){if(!this._modal){if(!this._UniversalProvider)throw new Error("WalletConnect Adapter - cannot init modal when Universal Provider is undefined");this._modal=y8({projectId:this._projectId,universalProvider:this._UniversalProvider,networks:[zh,Fh,h8],manualWCControl:!0})}}serialize(e){return N.dist.Buffer.from(e.serialize({verifySignatures:!1})).toString("base64")}deserialize(e,t=!1){return t?N.VersionedTransaction.deserialize(N.dist.Buffer.from(e,"base64")):N.Transaction.from(N.dist.Buffer.from(e,"base64"))}checkIfWalletSupportsMethod(e){var t;if(!((t=this.session.namespaces.solana)!=null&&t.methods.includes(e)))throw new $f(e)}}const N8="WalletConnect";class _8 extends Wh{constructor(t){super();vt(this,"name",N8);vt(this,"url","https://walletconnect.org");vt(this,"icon","data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjE4NSIgdmlld0JveD0iMCAwIDMwMCAxODUiIHdpZHRoPSIzMDAiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+PHBhdGggZD0ibTYxLjQzODU0MjkgMzYuMjU2MjYxMmM0OC45MTEyMjQxLTQ3Ljg4ODE2NjMgMTI4LjIxMTk4NzEtNDcuODg4MTY2MyAxNzcuMTIzMjA5MSAwbDUuODg2NTQ1IDUuNzYzNDE3NGMyLjQ0NTU2MSAyLjM5NDQwODEgMi40NDU1NjEgNi4yNzY1MTEyIDAgOC42NzA5MjA0bC0yMC4xMzY2OTUgMTkuNzE1NTAzYy0xLjIyMjc4MSAxLjE5NzIwNTEtMy4yMDUzIDEuMTk3MjA1MS00LjQyODA4MSAwbC04LjEwMDU4NC03LjkzMTE0NzljLTM0LjEyMTY5Mi0zMy40MDc5ODE3LTg5LjQ0Mzg4Ni0zMy40MDc5ODE3LTEyMy41NjU1Nzg4IDBsLTguNjc1MDU2MiA4LjQ5MzYwNTFjLTEuMjIyNzgxNiAxLjE5NzIwNDEtMy4yMDUzMDEgMS4xOTcyMDQxLTQuNDI4MDgwNiAwbC0yMC4xMzY2OTQ5LTE5LjcxNTUwMzFjLTIuNDQ1NTYxMi0yLjM5NDQwOTItMi40NDU1NjEyLTYuMjc2NTEyMiAwLTguNjcwOTIwNHptMjE4Ljc2Nzc5NjEgNDAuNzczNzQ0OSAxNy45MjE2OTcgMTcuNTQ2ODk3YzIuNDQ1NTQ5IDIuMzk0Mzk2OSAyLjQ0NTU2MyA2LjI3NjQ3NjkuMDAwMDMxIDguNjcwODg5OWwtODAuODEwMTcxIDc5LjEyMTEzNGMtMi40NDU1NDQgMi4zOTQ0MjYtNi40MTA1ODIgMi4zOTQ0NTMtOC44NTYxNi4wMDAwNjItLjAwMDAxLS4wMDAwMS0uMDAwMDIyLS4wMDAwMjItLjAwMDAzMi0uMDAwMDMybC01Ny4zNTQxNDMtNTYuMTU0NTcyYy0uNjExMzktLjU5ODYwMi0xLjYwMjY1LS41OTg2MDItMi4yMTQwNCAwLS4wMDAwMDQuMDAwMDA0LS4wMDAwMDcuMDAwMDA4LS4wMDAwMTEuMDAwMDExbC01Ny4zNTI5MjEyIDU2LjE1NDUzMWMtMi40NDU1MzY4IDIuMzk0NDMyLTYuNDEwNTc1NSAyLjM5NDQ3Mi04Ljg1NjE2MTIuMDAwMDg3LS4wMDAwMTQzLS4wMDAwMTQtLjAwMDAyOTYtLjAwMDAyOC0uMDAwMDQ0OS0uMDAwMDQ0bC04MC44MTI0MTk0My03OS4xMjIxODVjLTIuNDQ1NTYwMjEtMi4zOTQ0MDgtMi40NDU1NjAyMS02LjI3NjUxMTUgMC04LjY3MDkxOTdsMTcuOTIxNzI5NjMtMTcuNTQ2ODY3M2MyLjQ0NTU2MDItMi4zOTQ0MDgyIDYuNDEwNTk4OS0yLjM5NDQwODIgOC44NTYxNjAyIDBsNTcuMzU0OTc3NSA1Ni4xNTUzNTdjLjYxMTM5MDguNTk4NjAyIDEuNjAyNjQ5LjU5ODYwMiAyLjIxNDAzOTggMCAuMDAwMDA5Mi0uMDAwMDA5LjAwMDAxNzQtLjAwMDAxNy4wMDAwMjY1LS4wMDAwMjRsNTcuMzUyMTAzMS01Ni4xNTUzMzNjMi40NDU1MDUtMi4zOTQ0NjMzIDYuNDEwNTQ0LTIuMzk0NTUzMSA4Ljg1NjE2MS0uMDAwMi4wMDAwMzQuMDAwMDMzNi4wMDAwNjguMDAwMDY3My4wMDAxMDEuMDAwMTAxbDU3LjM1NDkwMiA1Ni4xNTU0MzJjLjYxMTM5LjU5ODYwMSAxLjYwMjY1LjU5ODYwMSAyLjIxNDA0IDBsNTcuMzUzOTc1LTU2LjE1NDMyNDljMi40NDU1NjEtMi4zOTQ0MDkyIDYuNDEwNTk5LTIuMzk0NDA5MiA4Ljg1NjE2IDB6IiBmaWxsPSIjM2I5OWZjIi8+PC9zdmc+");vt(this,"supportedTransactionVersions",new Set(["legacy",0]));vt(this,"_publicKey");vt(this,"_connecting");vt(this,"_wallet");vt(this,"_config");vt(this,"_readyState");vt(this,"_onDisconnect");this._publicKey=null,this._connecting=!1,this._config=t,this._wallet=null,this._readyState=typeof window>"u"?ae.Unsupported:ae.Loadable,this._onDisconnect=this.disconnect.bind(this)}get publicKey(){return this._publicKey}get connecting(){return this._connecting}get readyState(){return this._readyState}async connect(){try{if(this.connected||this.connecting)return;if(this._readyState!==ae.Loadable)throw new Ti;this._connecting=!0,this._wallet=new A8({network:this._config.network===_o.Mainnet?Ga.Mainnet:Ga.Devnet,options:this._config.options});const{publicKey:t}=await this._wallet.connect();this._publicKey=t,this.emit("connect",t),this._wallet.client.on("session_delete",this._onDisconnect)}catch(t){throw t.constructor.name==="QRCodeModalError"||t instanceof Error&&t.name==="QRCodeModalError"?new yb:(this._connecting=!1,t)}finally{this._connecting=!1}}async disconnect(){const t=this._wallet;if(t){t.client.off("session_delete",this._onDisconnect),this._publicKey=null;try{t.client.session&&await t.disconnect()}catch(i){console.error("WalletConnectWalletAdapter: disconnect error",i),this.emit("error",new zo(i==null?void 0:i.message,i))}}this.emit("disconnect")}async signTransaction(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signTransaction(t)}catch(r){throw new Je(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signMessage(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signMessage(t)}catch(r){throw new Fo(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAndSendTransaction(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signAndSendTransaction(t)}catch(r){throw new Je(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}async signAllTransactions(t){try{const i=this._wallet;if(!i)throw new Fe;try{return await i.signAllTransactions(t)}catch(r){throw new Je(r==null?void 0:r.message,r)}}catch(i){throw this.emit("error",i),i}}}const C8={icon:"data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMjU2IiBoZWlnaHQ9IjI1NiIgdmlld0JveD0iMCAwIDI1NiAyNTYiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8yMDM1XzExMDYpIj4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IiM1NEZGRjUiLz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjBfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTEzLjQ4MDYgMTk4LjYwNUMtMjkuMzI3NiAzMTkuMDQzIDE5OS42NjEgMjg1LjAyNyAzMTkuNTA3IDI1Mi45NjRDNDQyLjE2NSAyMTIuMjU5IDM1Ny4zODYgMzIuODI2OSAyNjkuNDE1IDI4Ljg1NThDMTgxLjQ0MyAyNC44ODQ3IDI4MC4zMjIgMTExLjgyNCAyMDUuNTk1IDEzNi42NTZDMTMwLjg2OCAxNjEuNDg3IDY2Ljk5MDcgNDguMDU4MyAxMy40ODA2IDE5OC42MDVaIiBmaWxsPSJ3aGl0ZSIvPgo8L2c+CjxnIGZpbHRlcj0idXJsKCNmaWx0ZXIxX2ZfMjAzNV8xMTA2KSI+CjxwYXRoIGQ9Ik04NS41MTE4IC00NS44MjI1QzYzLjA1NjIgLTEwNy4xNzYgLTE2LjkxODkgLTIzLjk5NTMgLTU0LjA5OTUgMjUuMjY0M0MtODkuNTY1MiA3OC44NDc5IDMuMDA5MzcgMTI1LjE1MiAzOS4zMjA4IDEwMC4wMzdDNzUuNjMyMyA3NC45MjI3IDcuNzc0NDggNzAuMDM2MyAyOS4zNzA4IDM3LjM3ODVDNTAuOTY3MSA0LjcyMDc2IDExMy41ODEgMzAuODY5NSA4NS41MTE4IC00NS44MjI1WiIgZmlsbD0iIzAwRkZGMCIgZmlsbC1vcGFjaXR5PSIwLjY3Ii8+CjwvZz4KPGcgZmlsdGVyPSJ1cmwoI2ZpbHRlcjJfZl8yMDM1XzExMDYpIj4KPHBhdGggZD0iTTk2LjQ3OTYgMjI1LjQyNEM2NS44NTAyIDEyMi4zNjMgLTY2LjA4MTggMTc2LjYzNyAtMTI4LjIxOSAyMTYuNjU3Qy0xODcuOTkgMjY0LjA0MiAtNDYuMDcxMSA0MDAuMzQ4IDEyLjg3MjUgMzkzLjM3NkM3MS44MTYxIDM4Ni40MDMgLTM0LjQxMTggMzI3LjA2NSAxLjk4NzAyIDI5OC4xN0MzOC4zODU4IDI2OS4yNzYgMTM0Ljc2NiAzNTQuMjQ5IDk2LjQ3OTYgMjI1LjQyNFoiIGZpbGw9IiM5RDgxRkYiLz4KPC9nPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyM19mXzIwMzVfMTEwNikiPgo8cGF0aCBkPSJNMjgyLjEyIC0xMDcuMzUzQzIxNi4wNDcgLTE4Ni4wMzEgMTIxLjQ2MyAtMTIwLjk3IDgyLjQyOTYgLTc4LjYwNDdDNDguMjczOSAtMzAuNjQ0NiAyMjQuMjc1IDU3LjIzMTIgMjczLjEyMSA0Mi4xNzE0QzMyMS45NjggMjcuMTExNSAyMDYuNTEyIC00LjA1MDM4IDIyNy4yOTcgLTMzLjI4NzlDMjQ4LjA4MiAtNjIuNTI1NSAzNjQuNzEyIC05LjAwNTY2IDI4Mi4xMiAtMTA3LjM1M1oiIGZpbGw9IiM0RDk0RkYiLz4KPC9nPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTkzLjE4OSAxNTIuODM2SDEzNi42NzRMODcuMjA4NiAxMDMuMDUxTDEzNy4zMSA1My4yNjYzTDE1MC45NTUgNDBIMTA1LjgxOUw0OC4zMzU5IDk3Ljc3NzNDNDUuNDM0OSAxMDAuNjg5IDQ1LjQ0OTggMTA1LjQwMiA0OC4zNjU2IDEwOC4yOTlMOTMuMTg5IDE1Mi44MzZaTTExOS4zMyAxMDMuMTY4SDExOC45OTVMMTE5LjMyNiAxMDMuMTY0TDExOS4zMyAxMDMuMTY4Wk0xMTkuMzMgMTAzLjE2OEwxNjguNzkxIDE1Mi45NDlMMTE4LjY5IDIwMi43MzRMMTA1LjA0NSAyMTZIMTUwLjE4TDIwNy42NjQgMTU4LjIyNkMyMTAuNTY1IDE1NS4zMTQgMjEwLjU1IDE1MC42MDIgMjA3LjYzNCAxNDcuNzA1TDE2Mi44MTEgMTAzLjE2OEgxMTkuMzNaIiBmaWxsPSJibGFjayIvPgo8L2c+CjxkZWZzPgo8ZmlsdGVyIGlkPSJmaWx0ZXIwX2ZfMjAzNV8xMTA2IiB4PSItOTAuMjQxMSIgeT0iLTY5LjczNjkiIHdpZHRoPSI1NjkuNTU4IiBoZWlnaHQ9IjQ1MS40MzEiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyMV9mXzIwMzVfMTEwNiIgeD0iLTE2MC41MTEiIHk9Ii0xNjUuOTg3IiB3aWR0aD0iMzUxLjU5NiIgaGVpZ2h0PSIzNzEuNTA3IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxmaWx0ZXIgaWQ9ImZpbHRlcjJfZl8yMDM1XzExMDYiIHg9Ii0yNDEuMDc4IiB5PSI2Ny42NDIiIHdpZHRoPSI0NDQuODUxIiBoZWlnaHQ9IjQyNC40NTIiIGZpbHRlclVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgY29sb3ItaW50ZXJwb2xhdGlvbi1maWx0ZXJzPSJzUkdCIj4KPGZlRmxvb2QgZmxvb2Qtb3BhY2l0eT0iMCIgcmVzdWx0PSJCYWNrZ3JvdW5kSW1hZ2VGaXgiLz4KPGZlQmxlbmQgbW9kZT0ibm9ybWFsIiBpbj0iU291cmNlR3JhcGhpYyIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0ic2hhcGUiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iNDkuMjMwOCIgcmVzdWx0PSJlZmZlY3QxX2ZvcmVncm91bmRCbHVyXzIwMzVfMTEwNiIvPgo8L2ZpbHRlcj4KPGZpbHRlciBpZD0iZmlsdGVyM19mXzIwMzVfMTEwNiIgeD0iLTIwLjM5NjgiIHk9Ii0yNDIuNzU4IiB3aWR0aD0iNDMwLjE5MSIgaGVpZ2h0PSIzODUuMTA1IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iQmFja2dyb3VuZEltYWdlRml4IiByZXN1bHQ9InNoYXBlIi8+CjxmZUdhdXNzaWFuQmx1ciBzdGREZXZpYXRpb249IjQ5LjIzMDgiIHJlc3VsdD0iZWZmZWN0MV9mb3JlZ3JvdW5kQmx1cl8yMDM1XzExMDYiLz4KPC9maWx0ZXI+CjxjbGlwUGF0aCBpZD0iY2xpcDBfMjAzNV8xMTA2Ij4KPHJlY3Qgd2lkdGg9IjI1NiIgaGVpZ2h0PSIyNTYiIGZpbGw9IndoaXRlIi8+CjwvY2xpcFBhdGg+CjwvZGVmcz4KPC9zdmc+Cg==",name:"Bitget Wallet"},S8=[C8],$8=s=>S8.find(e=>e.name.toLocaleLowerCase().includes(s.name.toLocaleLowerCase()))||s,P8=(s,e,t)=>e[s]||t[s],Tf=(s,e)=>P8(s,$8(e),e);class pi extends te.Wallet{constructor(e,t){super(),this.adapter=e,this.connection=t}getAdapter(){return this.adapter}getName(){return Tf("name",this.adapter)}getUrl(){return this.adapter.url}async connect(){if(this.isConnected())return this.getAddresses();const e=await new Promise((t,i)=>{this.adapter.on("connect",()=>{this.adapter.off("connect"),this.adapter.off("error"),t(this.getAddresses())}),this.adapter.on("error",r=>{this.adapter.off("connect"),this.adapter.off("error"),i(r)}),this.adapter.connect().catch(i)});return this.emit("connect"),this.adapter.on("disconnect",()=>this.emit("disconnect")),e}getNetworkInfo(){return{}}isConnected(){return this.adapter.connected}async disconnect(){this.isConnected()&&(await new Promise((e,t)=>{this.adapter.on("disconnect",()=>{this.adapter.off("disconnect"),this.adapter.off("error"),e(void 0)}),this.adapter.on("error",i=>{this.adapter.off("disconnect"),this.adapter.off("error"),t(i)}),this.adapter.disconnect().catch(t)}),this.adapter.removeAllListeners(),this.emit("disconnect"))}getChainId(){return te.CHAIN_ID_SOLANA}getAddress(){var e;return(e=this.adapter.publicKey)==null?void 0:e.toString()}getAddresses(){const e=this.getAddress();return e?[e]:[]}setMainAddress(){throw new Error("Not supported")}getBalance(){throw new Error("Not supported")}async signTransaction(e){if(!this.adapter.signTransaction||!this.adapter.signAllTransactions)throw new Error("Not supported");return Array.isArray(e)?this.adapter.signAllTransactions(e):this.adapter.signTransaction(e)}async sendTransaction(e){var n;const{transaction:t}=e,i=Array.isArray(t)?t:[t];if(i.length===0)throw new Error("Empty transactions array");const r=[];for(const o of i){const a=await this.adapter.sendTransaction(o,this.connection,{...e.options});r.push(a)}return await this.connection.confirmTransaction(r[0],(n=e.options)==null?void 0:n.commitment),{id:r[0],data:r.length===1?r[0]:r}}async signAndSendTransaction(e){return this.sendTransaction(e)}signMessage(e){if(!this.adapter.signMessage)throw new Error("Not supported");return this.adapter.signMessage(e)}getIcon(){return Tf("icon",this.adapter)}getWalletState(){const e=this.adapter.readyState;if(!(e in te.WalletState))throw new Error(`Unknown wallet state ${e}`);return te.WalletState[e]}getFeatures(){const e=[te.BaseFeatures.SendTransaction,te.BaseFeatures.SignAndSendTransaction];return this.adapter.signTransaction&&this.adapter.signAllTransactions&&e.push(te.BaseFeatures.SignTransaction),this.adapter.signMessage&&e.push(te.BaseFeatures.SignMessage),e}supportsChain(e){return e===te.CHAIN_ID_SOLANA}}function T8(s){if(s.length>=255)throw new TypeError("Alphabet too long");const e=new Uint8Array(256);for(let c=0;c<e.length;c++)e[c]=255;for(let c=0;c<s.length;c++){const h=s.charAt(c),u=h.charCodeAt(0);if(e[u]!==255)throw new TypeError(h+" is ambiguous");e[u]=c}const t=s.length,i=s.charAt(0),r=Math.log(t)/Math.log(256),n=Math.log(256)/Math.log(t);function o(c){if(c instanceof Uint8Array||(ArrayBuffer.isView(c)?c=new Uint8Array(c.buffer,c.byteOffset,c.byteLength):Array.isArray(c)&&(c=Uint8Array.from(c))),!(c instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(c.length===0)return"";let h=0,u=0,d=0;const p=c.length;for(;d!==p&&c[d]===0;)d++,h++;const g=(p-d)*n+1>>>0,f=new Uint8Array(g);for(;d!==p;){let w=c[d],v=0;for(let A=g-1;(w!==0||v<u)&&A!==-1;A--,v++)w+=256*f[A]>>>0,f[A]=w%t>>>0,w=w/t>>>0;if(w!==0)throw new Error("Non-zero carry");u=v,d++}let b=g-u;for(;b!==g&&f[b]===0;)b++;let y=i.repeat(h);for(;b<g;++b)y+=s.charAt(f[b]);return y}function a(c){if(typeof c!="string")throw new TypeError("Expected String");if(c.length===0)return new Uint8Array;let h=0,u=0,d=0;for(;c[h]===i;)u++,h++;const p=(c.length-h)*r+1>>>0,g=new Uint8Array(p);for(;h<c.length;){const w=c.charCodeAt(h);if(w>255)return;let v=e[w];if(v===255)return;let A=0;for(let C=p-1;(v!==0||A<d)&&C!==-1;C--,A++)v+=t*g[C]>>>0,g[C]=v%256>>>0,v=v/256>>>0;if(v!==0)throw new Error("Non-zero carry");d=A,h++}let f=p-d;for(;f!==p&&g[f]===0;)f++;const b=new Uint8Array(u+(p-f));let y=u;for(;f!==p;)b[y++]=g[f++];return b}function l(c){const h=a(c);if(h)return h;throw new Error("Non-base"+t+" character")}return{encode:o,decodeUnsafe:a,decode:l}}var M8="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";const x8=T8(M8);var K=function(s,e,t,i){if(t==="a"&&!i)throw new TypeError("Private accessor was defined without a getter");if(typeof e=="function"?s!==e||!i:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?i:t==="a"?i.call(s):i?i.value:e.get(s)},it=function(s,e,t,i,r){if(i==="m")throw new TypeError("Private method is not writable");if(i==="a"&&!r)throw new TypeError("Private accessor was defined without a setter");if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return i==="a"?r.call(s,t):r?r.value=t:e.set(s,t),t},$t,Jt,Ji,Xi,Hi,uo,pc,ye,gc,qh,Ka,Bh,No,Hh,Mf,xf,Of,Df;class O8 extends Uf{get name(){return K(this,ye,"f").name}get url(){return"https://github.com/solana-labs/wallet-standard"}get icon(){return K(this,ye,"f").icon}get readyState(){return K(this,gc,"f")}get publicKey(){return K(this,Ji,"f")}get connecting(){return K(this,Xi,"f")}get supportedTransactionVersions(){return K(this,pc,"f")}get wallet(){return K(this,ye,"f")}get standard(){return!0}constructor({wallet:e}){super(),$t.add(this),Jt.set(this,void 0),Ji.set(this,void 0),Xi.set(this,void 0),Hi.set(this,void 0),uo.set(this,void 0),pc.set(this,void 0),ye.set(this,void 0),gc.set(this,typeof window>"u"||typeof document>"u"?ae.Unsupported:ae.Installed),Hh.set(this,t=>{if("accounts"in t){const i=K(this,ye,"f").accounts[0];K(this,Jt,"f")&&!K(this,Hi,"f")&&i!==K(this,Jt,"f")&&(i?K(this,$t,"m",Ka).call(this,i):(this.emit("error",new Rf),K(this,$t,"m",Bh).call(this)))}"features"in t&&K(this,$t,"m",No).call(this)}),it(this,ye,e,"f"),it(this,Jt,null,"f"),it(this,Ji,null,"f"),it(this,Xi,!1,"f"),it(this,Hi,!1,"f"),it(this,uo,K(this,ye,"f").features[zf].on("change",K(this,Hh,"f")),"f"),K(this,$t,"m",No).call(this)}destroy(){it(this,Jt,null,"f"),it(this,Ji,null,"f"),it(this,Xi,!1,"f"),it(this,Hi,!1,"f");const e=K(this,uo,"f");e&&(it(this,uo,null,"f"),e())}async autoConnect(){return K(this,$t,"m",qh).call(this,{silent:!0})}async connect(){return K(this,$t,"m",qh).call(this)}async disconnect(){if(Tu in K(this,ye,"f").features)try{it(this,Hi,!0,"f"),await K(this,ye,"f").features[Tu].disconnect()}catch(e){this.emit("error",new zo(e==null?void 0:e.message,e))}finally{it(this,Hi,!1,"f")}K(this,$t,"m",Bh).call(this)}async sendTransaction(e,t,i={}){try{const r=K(this,Jt,"f");if(!r)throw new Fe;let n;if(yi in K(this,ye,"f").features)if(r.features.includes(yi))n=yi;else if(St in K(this,ye,"f").features&&r.features.includes(St))n=St;else throw new vs;else if(St in K(this,ye,"f").features){if(!r.features.includes(St))throw new vs;n=St}else throw new ln;const o=Ub(t.rpcEndpoint);if(!r.chains.includes(o))throw new Gi;try{const{signers:a,...l}=i;let c;if(si(e)?(a!=null&&a.length&&e.sign(a),c=e.serialize()):(e=await this.prepareTransaction(e,t,l),a!=null&&a.length&&e.partialSign(...a),c=new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))),n===yi){const[h]=await K(this,ye,"f").features[yi].signAndSendTransaction({account:r,chain:o,transaction:c,options:{preflightCommitment:Uc(l.preflightCommitment||t.commitment),skipPreflight:l.skipPreflight,maxRetries:l.maxRetries,minContextSlot:l.minContextSlot}});return x8.encode(h.signature)}else{const[h]=await K(this,ye,"f").features[St].signTransaction({account:r,chain:o,transaction:c,options:{preflightCommitment:Uc(l.preflightCommitment||t.commitment),minContextSlot:l.minContextSlot}});return await t.sendRawTransaction(h.signedTransaction,{...l,preflightCommitment:Uc(l.preflightCommitment||t.commitment)})}}catch(a){throw a instanceof Tt?a:new Gi(a==null?void 0:a.message,a)}}catch(r){throw this.emit("error",r),r}}}Jt=new WeakMap,Ji=new WeakMap,Xi=new WeakMap,Hi=new WeakMap,uo=new WeakMap,pc=new WeakMap,ye=new WeakMap,gc=new WeakMap,Hh=new WeakMap,$t=new WeakSet,qh=async function(e){try{if(this.connected||this.connecting)return;if(K(this,gc,"f")!==ae.Installed)throw new Ti;if(it(this,Xi,!0,"f"),!K(this,ye,"f").accounts.length)try{await K(this,ye,"f").features[Lf].connect(e)}catch(i){throw new fc(i==null?void 0:i.message,i)}const t=K(this,ye,"f").accounts[0];if(!t)throw new vs;K(this,$t,"m",Ka).call(this,t)}catch(t){throw this.emit("error",t),t}finally{it(this,Xi,!1,"f")}},Ka=function(e){let t;try{t=new N.PublicKey(e.address)}catch(i){throw new dr(i==null?void 0:i.message,i)}it(this,Jt,e,"f"),it(this,Ji,t,"f"),K(this,$t,"m",No).call(this),this.emit("connect",t)},Bh=function(){it(this,Jt,null,"f"),it(this,Ji,null,"f"),K(this,$t,"m",No).call(this),this.emit("disconnect")},No=function(){var t,i;const e=yi in K(this,ye,"f").features?K(this,ye,"f").features[yi].supportedTransactionVersions:K(this,ye,"f").features[St].supportedTransactionVersions;it(this,pc,fb.arraysEqual(e,["legacy"])?null:new Set(e),"f"),St in K(this,ye,"f").features&&((t=K(this,Jt,"f"))!=null&&t.features.includes(St))?(this.signTransaction=K(this,$t,"m",Mf),this.signAllTransactions=K(this,$t,"m",xf)):(delete this.signTransaction,delete this.signAllTransactions),Dn in K(this,ye,"f").features&&((i=K(this,Jt,"f"))!=null&&i.features.includes(Dn))?this.signMessage=K(this,$t,"m",Of):delete this.signMessage,jc in K(this,ye,"f").features?this.signIn=K(this,$t,"m",Df):delete this.signIn},Mf=async function(e){try{const t=K(this,Jt,"f");if(!t)throw new Fe;if(!(St in K(this,ye,"f").features))throw new ln;if(!t.features.includes(St))throw new vs;try{const r=(await K(this,ye,"f").features[St].signTransaction({account:t,transaction:si(e)?e.serialize():new Uint8Array(e.serialize({requireAllSignatures:!1,verifySignatures:!1}))}))[0].signedTransaction;return si(e)?N.VersionedTransaction.deserialize(r):N.Transaction.from(r)}catch(i){throw i instanceof Tt?i:new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},xf=async function(e){try{const t=K(this,Jt,"f");if(!t)throw new Fe;if(!(St in K(this,ye,"f").features))throw new ln;if(!t.features.includes(St))throw new vs;try{const i=await K(this,ye,"f").features[St].signTransaction(...e.map(r=>({account:t,transaction:si(r)?r.serialize():new Uint8Array(r.serialize({requireAllSignatures:!1,verifySignatures:!1}))})));return e.map((r,n)=>{const o=i[n].signedTransaction;return si(r)?N.VersionedTransaction.deserialize(o):N.Transaction.from(o)})}catch(i){throw new Je(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},Of=async function(e){try{const t=K(this,Jt,"f");if(!t)throw new Fe;if(!(Dn in K(this,ye,"f").features))throw new ln;if(!t.features.includes(Dn))throw new vs;try{return(await K(this,ye,"f").features[Dn].signMessage({account:t,message:e}))[0].signature}catch(i){throw new Fo(i==null?void 0:i.message,i)}}catch(t){throw this.emit("error",t),t}},Df=async function(e={}){try{if(!(jc in K(this,ye,"f").features))throw new ln;let t;try{[t]=await K(this,ye,"f").features[jc].signIn(e)}catch(i){throw new Pu(i==null?void 0:i.message,i)}if(!t)throw new Pu;return K(this,$t,"m",Ka).call(this,t.account),t}catch(t){throw this.emit("error",t),t}};function D8(s){return mb.getWallets().get().filter(bb).map(e=>new pi(new O8({wallet:e}),s))}function k8(s){return s.includes("rpcpool.com")?"triton":s.includes("helius-rpc.com")?"helius":s.includes("rpc.ankr.com")?"ankr":"unknown"}async function j8(s,e,t,i){const r=i.transaction.transaction,n=o=>o.programId.toString()!=="ComputeBudget111111111111111111111111111111";if(Rl.isVersionedTransaction(r)){const o=(await Promise.all(r.message.addressTableLookups.map(l=>s.getAddressLookupTable(l.accountKey)))).map(l=>l.value).filter(l=>l!==null),a=N.TransactionMessage.decompile(r.message,{addressLookupTableAccounts:o});a.recentBlockhash=e,r.message.recentBlockhash=e,a.instructions=a.instructions.filter(n),a.instructions.push(...await kf(s,r)),r.message=a.compileToV0Message(o),r.sign(i.transaction.signers??[])}else r.recentBlockhash=e,r.lastValidBlockHeight=t,r.instructions=r.instructions.filter(n),r.add(...await kf(s,r)),i.transaction.signers&&r.partialSign(...i.transaction.signers);return r}async function kf(s,e,t){var y,w;let i=2e5,r=0;e:for(;;){if(Rl.isVersionedTransaction(e)&&!e.message.recentBlockhash){const{blockhash:A}=await s.getLatestBlockhash(t);e.message.recentBlockhash=A}const v=await(Rl.isVersionedTransaction(e)?s.simulateTransaction(e,{commitment:t,replaceRecentBlockhash:!0}):s.simulateTransaction(e));if(v.value.err){if(R8(v.value)){if(r<5){r++,await te.sleep(1e3);continue e}}else if(r<3){r++,await te.sleep(1e3);continue e}throw new Error(`Simulation failed: ${JSON.stringify(v.value.err)}
|
|
916
916
|
Logs:
|
|
917
917
|
${(v.value.logs||[]).join(`
|
|
918
918
|
`)}`)}else{v.value.unitsConsumed&&(i=v.value.unitsConsumed);break}}const n=Math.floor(i*1.2),o=[];o.push(N.ComputeBudgetProgram.setComputeUnitLimit({units:n}));const a=((w=(y=te.config.transactionSettings)==null?void 0:y.Solana)==null?void 0:w.priorityFee)||{},{percentile:l=.9,percentileMultiple:c=1,min:h=1e5,max:u=1e8}=a,d=async v=>{if(v==="triton")try{return{fee:await $u.determinePriorityFeeTritonOne(s,e,l,c,h,u),methodUsed:"triton"}}catch(A){console.warn("Failed to determine priority fee using Triton RPC:",A)}try{return{fee:await $u.determinePriorityFee(s,e,l,c,h,u),methodUsed:"default"}}catch(A){return console.warn("Failed to determine priority fee using Triton RPC:",A),{fee:h,methodUsed:"minimum"}}},p=k8(s.rpcEndpoint),{fee:g,methodUsed:f}=await d(p),b=g/1e6/N.LAMPORTS_PER_SOL*n;return console.table({"RPC Provider":p,"Method used":f,"Percentile used":l,"Multiple used":c,"Compute budget":n,"Priority fee":g,"Max fee in SOL":b}),o.push(N.ComputeBudgetProgram.setComputeUnitPrice({microLamports:g})),o}function R8(s){const e={};if(s.err==="BlockhashNotFound"&&(e.BlockhashNotFound="Blockhash not found during simulation. Trying again."),s.logs)for(const t of s.logs)t.includes("SlippageToleranceExceeded")&&(e.SlippageToleranceExceeded="Slippage failure during simulation. Trying again."),t.includes("RequireGteViolated")&&(e.RequireGteViolated="Swap instruction failure during simulation. Trying again.");return te.isEmptyObject(e)?!1:(console.table(e),!0)}const U8=s=>s.getName().toLowerCase().replaceAll("wallet","").trim();function L8(){const s=te.config.isMainnet?"mainnet-beta":"devnet",e=new N.Connection(te.config.rpcs.Solana||N.clusterApiUrl(s));return{...D8(e).reduce((t,i)=>(t[U8(i)]=i,t),{}),bitget:new pi(new Ib,e),clover:new pi(new Ab,e),coin98:new pi(new Sb,e),solong:new pi(new Db,e),torus:new pi(new jb,e),nightly:new pi(new Pb,e),...te.config.ui.walletConnectProjectId?{walletConnect:new pi(new _8({network:te.config.isMainnet?_o.Mainnet:_o.Devnet,options:{projectId:te.config.ui.walletConnectProjectId,customStoragePrefix:"wh-connect-solana-adapter"}}),e)}:{}}}async function z8(s,e,t){if(!e)throw new Error("Wallet not found");if(!te.config.rpcs.Solana)throw new Error("Solana RPC not found");const i=(t==null?void 0:t.commitment)??"finalized",r=new N.Connection(te.config.rpcs.Solana),{blockhash:n,lastValidBlockHeight:o}=await r.getLatestBlockhash(i),a=await j8(r,n,o,s);let l=null,c=null,h=1,u="";const p=(await e.signTransaction(a)).serialize(),g={skipPreflight:!0,maxRetries:0,preFlightCommitment:i};u=await r.sendRawTransaction(p,g),l=r.confirmTransaction({signature:u,blockhash:n,lastValidBlockHeight:o},i);try{for(;!c&&(c=await Promise.race([l,new Promise(b=>setTimeout(()=>{b(null)},5e3))]),!c);){console.log(`Tx not confirmed after ${5e3*h++}ms, resending`);try{await r.sendRawTransaction(p,g)}catch(b){console.error("Failed to resend transaction:",b)}}}catch(f){if(f instanceof Error&&f.name==="TransactionExpiredBlockheightExceededError")for(let w=0;w<5;++w){try{if(await r.getTransaction(u,{commitment:"confirmed",maxSupportedTransactionVersion:0}))return u}catch{}await te.sleep(2e3)}throw f}if(c.value.err){let f=`Transaction failed: ${c.value.err}`;if(typeof c.value.err=="object")try{f=`Transaction failed: ${JSON.stringify(c.value.err,(b,y)=>typeof y=="bigint"?y.toString():y)}`}catch{f="Transaction failed: Unknown error"}throw new Error(`Transaction failed: ${f}`)}return u}const F8=Object.freeze(Object.defineProperty({__proto__:null,fetchOptions:L8,signAndSendTransaction:z8},Symbol.toStringTag,{value:"Module"}));exports.AccountController=J;exports.AlertController=fo;exports.ApiController=ne;exports.AssetController=bs;exports.AssetUtil=cu;exports.ChainController=I;exports.ConnectionController=ke;exports.ConnectorController=ie;exports.ConnectorUtil=bo;exports.ConstantsUtil=Z;exports.ConstantsUtil$1=qt;exports.ConstantsUtil$2=ib;exports.CoreHelperUtil=re;exports.E=ht;exports.EventsController=je;exports.Hash=Zf;exports.Hash$1=qw;exports.ModalController=et;exports.OptionsController=k;exports.RouterController=_e;exports.SIWXUtil=fn;exports.SnackController=wt;exports.StorageUtil=Y;exports.T=ur;exports.ThemeController=jt;exports.WalletUtil=lc;exports.abytes=Ho;exports.abytes$1=Xo;exports.aexists=ql;exports.aexists$1=fh;exports.ahash=zv;exports.ahash$1=ID;exports.aoutput=Qf;exports.aoutput$1=Fw;exports.b=Zz;exports.colorStyles=l8;exports.concatBytes=Jv;exports.concatBytes$1=OD;exports.createView=Gv;exports.createView$1=PD;exports.elementStyles=c8;exports.f=_u;exports.i=er;exports.i$1=Eo;exports.initializeTheming=n8;exports.proxy=Ke;exports.randomBytes=Xv;exports.randomBytes$1=DD;exports.resetStyles=a8;exports.rotr=Yv;exports.rotr$1=TD;exports.solana=F8;exports.subscribe=Lt;exports.subscribeKey=Xt;exports.toBytes=Vh;exports.toBytes$1=lu;exports.u=hc;exports.wrapConstructor=Jf;exports.wrapConstructor$1=Bw;exports.x=Qz;
|