@fangorn-network/westmarch 2026.10.2-0.0-dev → 2026.10.2-2.0-dev
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/docs/app-to-agent.md +25 -41
- package/package.json +6 -5
- package/site/dist/assets/AccountNotFoundScreen-C4njXc69-DyVH4CEz.js +1 -0
- package/site/dist/assets/AddFundsSelectionScreen-RAoCn7ej-Dz1--SS9.js +31 -0
- package/site/dist/assets/Address-H8kD1d9O-BdFZmRwI.js +17 -0
- package/site/dist/assets/AffirmativeConsentScreen-BG0MJxku-CxaCAisL.js +6 -0
- package/site/dist/assets/AllowlistRejectionScreen-Cae6e1Od-JGk7vndN.js +1 -0
- package/site/dist/assets/ApiController-CTLbMCcH.js +5 -0
- package/site/dist/assets/ArrowsRightLeftIcon-B8g9adpz.js +1 -0
- package/site/dist/assets/AuthenticateWithWalletScreen-CU6hIcFT-CXD9_OP8.js +1 -0
- package/site/dist/assets/AwaitingEvmToSolBridgingScreen-D0e_sZMS-BtJCglvU.js +1 -0
- package/site/dist/assets/AwaitingExternalEthereumTransferScreen-ur5HL4R7-BgC2TsqH.js +1 -0
- package/site/dist/assets/AwaitingPasswordlessCodeScreen-DRHz76mM-B9OzLeEO.js +103 -0
- package/site/dist/assets/AwaitingSolToEvmBridgingScreen-CdLRrGD2-C7r5snUL.js +1 -0
- package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-BTV0NRio.js +68 -0
- package/site/dist/assets/CaptchaScreen-DbpvkIGx-7rSZIuM-.js +1 -0
- package/site/dist/assets/CheckCircleIcon-B1l17ioc.js +1 -0
- package/site/dist/assets/CheckCircleIcon-BGSI8nKf.js +1 -0
- package/site/dist/assets/Checkbox-D1EDeo41-BUfq0w99.js +52 -0
- package/site/dist/assets/ChevronDownIcon-B6uJvPHu.js +1 -0
- package/site/dist/assets/Chip-CZKIKt9K-r9Nk__0-.js +26 -0
- package/site/dist/assets/CoinbaseOnrampStatusScreen-BbyCJDXL-DWWNHxmR.js +16 -0
- package/site/dist/assets/ConnectEmailForm-B-VRE0MN-CRQwS0Xu.js +3 -0
- package/site/dist/assets/ConnectLedgerScreen-DWHABGot-CZcCt31O.js +10 -0
- package/site/dist/assets/ConnectOnlyLandingScreen-CZYx9Bmp-C5IOf-SQ.js +1 -0
- package/site/dist/assets/ConnectOnlyStatusScreen-DCRzjxHx-cwg74F3A.js +1 -0
- package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-D28oeK6b.js +1 -0
- package/site/dist/assets/ConnectPhoneForm-Dek5xn4C-EEdkKeTp.js +95 -0
- package/site/dist/assets/ConnectWalletView-DqI-PTvX-C2mEzukj.js +74 -0
- package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-CH_7r8iV.js +7 -0
- package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-Z33kis0B.js +1 -0
- package/site/dist/assets/ConnectorUtil-DH4NePk5.js +21 -0
- package/site/dist/assets/ConstantsUtil-DmLsRHAl.js +198 -0
- package/site/dist/assets/CopyToClipboard-i_OQSBJr-_G88JCVR.js +39 -0
- package/site/dist/assets/CopyableText-CQapvaMr-CGGfc_zM.js +28 -0
- package/site/dist/assets/CrossAppAuthScreen-CLw7ymZq-C9Okoc0V.js +1 -0
- package/site/dist/assets/CustomLandingScreenView-Cm_MBSyX-D2l6hdSl.js +22 -0
- package/site/dist/assets/DelegatedActionsConsentScreen-DYF2U4y5-Dda3KKqS.js +1 -0
- package/site/dist/assets/DelegatedActionsRevokeScreen-bPp6Uwyh-DG8kJPt1.js +1 -0
- package/site/dist/assets/DepositAddressAddressStepView-4vdkb55L-CcOUfn6f.js +187 -0
- package/site/dist/assets/DepositAddressScreen-DBLRs7aI-DeituDNh.js +8 -0
- package/site/dist/assets/DepositAddressV3Screen-CDqIEMQw-FDg6K14-.js +1 -0
- package/site/dist/assets/{EmailInputForm-Cqo1mda8-CZD4r5LM.js → EmailInputForm-Cqo1mda8-BmbxvPHC.js} +11 -11
- package/site/dist/assets/EmbeddedWalletConnectingScreen-D4T7DUzs-B05CQ9rx.js +1 -0
- package/site/dist/assets/EmbeddedWalletCreatedScreen-D7WhW5ve-Cxd1b9XH.js +1 -0
- package/site/dist/assets/EmbeddedWalletKeyExportScreen-CqV4NYQ3-CrJy0ViX.js +23 -0
- package/site/dist/assets/EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-Bakaa3zu.js +1 -0
- package/site/dist/assets/EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-j78vKrcj.js +1 -0
- package/site/dist/assets/EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-D3dr7W9_.js +1 -0
- package/site/dist/assets/EnrollTotp-Dibew4dp-BXbYV8nI.js +66 -0
- package/site/dist/assets/EnvelopeIcon-DjPofnRI.js +1 -0
- package/site/dist/assets/ErrorBanner-BcpGRt0h-BhH6_V-9.js +21 -0
- package/site/dist/assets/{ErrorMessage-D8VaAP5m-oSruKN8L.js → ErrorMessage-D8VaAP5m-Bs7uX2a9.js} +2 -2
- package/site/dist/assets/ErrorScreen-DipdTWzE-BgPRgnOb.js +4 -0
- package/site/dist/assets/ErrorScreen-DipdTWzE-CvxXC6pz.js +1 -0
- package/site/dist/assets/ExclamationCircleIcon-BE-WGrut.js +1 -0
- package/site/dist/assets/ExclamationTriangleIcon-Ca1Xlc_f.js +1 -0
- package/site/dist/assets/FarcasterConnectStatusScreen-51tjUxqq-De2JvZdV.js +75 -0
- package/site/dist/assets/FarcasterSignerStatusScreen-6x-Uh95G-bLp3hXoO.js +28 -0
- package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-Jr6D6JiZ.js +491 -0
- package/site/dist/assets/FingerPrintIcon-DOCbS93y.js +1 -0
- package/site/dist/assets/FundSolWalletWithExternalSolanaWallet-WtLwYaOl-A_G5kfa1.js +1 -0
- package/site/dist/assets/FundWalletMethodHeader-BWNkokCT-LPv35wkD.js +1 -0
- package/site/dist/assets/FundWithBankDepositScreen-DajkHxBD-0hfGrfvf.js +58 -0
- package/site/dist/assets/FundingEditAmountScreen-CpvpiO4M-Dz0s_NWR.js +1 -0
- package/site/dist/assets/FundingMethodSelectionScreen-Db7vhRlE-ZGm-3-Io.js +1 -0
- package/site/dist/assets/GlobeAltIcon-BBRl2MMn.js +1 -0
- package/site/dist/assets/GooglePay-B53WnudL-BGiVpB8y.js +1 -0
- package/site/dist/assets/HCaptchaWrapper-CUi9LJsp-CHdfIeD_.js +4 -0
- package/site/dist/assets/InAppBrowserLoginNotPossible-BMR9br1T-Cgoiow3m.js +1 -0
- package/site/dist/assets/InfoBanner-Cb3p1z12-_YqQmRiu.js +22 -0
- package/site/dist/assets/InjectedWalletIcon-DLcYOGDj-tuIrKQHH.js +1 -0
- package/site/dist/assets/InstallWalletScreen-DTA8dwLv-BMU_wa61.js +1 -0
- package/site/dist/assets/{JsonTree-BHzNC-ic-pAEq1bl9.js → JsonTree-BHzNC-ic-DcVr0YF0.js} +3 -3
- package/site/dist/assets/{LabelXs-oqZNqbm_-D09YjVR4.js → LabelXs-oqZNqbm_-CNprGVQM.js} +2 -2
- package/site/dist/assets/LandingScreen-CGWUoSUG-fH6rsQen.js +1 -0
- package/site/dist/assets/{Layouts-BMRfo5hw-D2u1-w8g.js → Layouts-BMRfo5hw-e-sepi6F.js} +16 -16
- package/site/dist/assets/Link-BdDilT2T-BdwlRJch.js +40 -0
- package/site/dist/assets/LinkConflictScreen-C3ZEPsgl-BXKN2Qm5.js +77 -0
- package/site/dist/assets/LinkEmailScreen-dKo9frwc-Cyn7Q8p1.js +1 -0
- package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-CWiqnwLM.js +117 -0
- package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-YmDevJzf.js +1 -0
- package/site/dist/assets/LinkPhoneScreen-oIUpfj0w-h7shW-Ay.js +1 -0
- package/site/dist/assets/Loader-UAZqxsnw-DJEVblm1.js +62 -0
- package/site/dist/assets/{LoadingSkeleton-BMsgO5PV-BRMh4Fv4.js → LoadingSkeleton-BMsgO5PV-D2atjsP5.js} +6 -6
- package/site/dist/assets/LockClosedIcon-9EFzWK1C.js +1 -0
- package/site/dist/assets/LoginFailedScreen-CN0dJV6U-By3Si77a.js +1 -0
- package/site/dist/assets/ManualTransferScreen-CHqcuqbs-BAHPY8rs.js +1 -0
- package/site/dist/assets/MfaAuthEnrollmentFlowScreen-Dj7gPTRC-CLjffFG1.js +1 -0
- package/site/dist/assets/MfaAuthVerifyFlowScreen-DbFpyWMy-BmQg1Y61.js +1 -0
- package/site/dist/assets/MfaEnrollmentFlowScreen-DhLnGgnr-DmBtTtlw.js +1 -0
- package/site/dist/assets/MfaVerifyFlowScreen-C_XPjMRP-4a683Bmf.js +1 -0
- package/site/dist/assets/ModalFooter-BCuEK_nz-C_71qsaz.js +403 -0
- package/site/dist/assets/MoonpayStatusScreen-CzTUtokc-DEHHcEf8.js +16 -0
- package/site/dist/assets/OAuthStatusScreen-ufbOa-da-BjAb_WsY.js +1 -0
- package/site/dist/assets/OpenLink-CUpJ1mOr-BLWFsPOW.js +39 -0
- package/site/dist/assets/PasskeySelectSignupOrLogin-xh2ScC_l-2PJTJxX-.js +1 -0
- package/site/dist/assets/PasskeyStatusScreen-Bla8MaOk-DCEg761l.js +6 -0
- package/site/dist/assets/PasswordRecoveryScreen-awGXZkQk-8nVjNc8k.js +20 -0
- package/site/dist/assets/{PhArrowCircleDown-BtlNV0TZ.js → PhArrowCircleDown-D97G-BOA.js} +5 -5
- package/site/dist/assets/PhArrowClockwise-DVgyFuez.js +14 -0
- package/site/dist/assets/PhArrowDown-87b1BizM.js +14 -0
- package/site/dist/assets/PhArrowLeft-Da0MfnbK.js +14 -0
- package/site/dist/assets/PhArrowRight-AdrIL4DW.js +14 -0
- package/site/dist/assets/{PhArrowSquareOut-DnQ7n_B4.js → PhArrowSquareOut-Bk2CMG3I.js} +5 -5
- package/site/dist/assets/PhArrowUp-4sgyKPGx.js +14 -0
- package/site/dist/assets/PhArrowUpRight-BNghD2zq.js +14 -0
- package/site/dist/assets/{PhArrowsClockwise-Brtx2Re-.js → PhArrowsClockwise-BXRn1GEl.js} +5 -5
- package/site/dist/assets/{PhArrowsDownUp-PZosTqZG.js → PhArrowsDownUp-DM09Jo_3.js} +5 -5
- package/site/dist/assets/PhArrowsLeftRight-MuKBLUoF.js +14 -0
- package/site/dist/assets/{PhBank-hhPAIPVb.js → PhBank-fHbgCqqZ.js} +5 -5
- package/site/dist/assets/PhBrowser-2-9m-AkM.js +14 -0
- package/site/dist/assets/PhCaretDown-BDNabFuL.js +14 -0
- package/site/dist/assets/PhCaretLeft-CI460R-A.js +14 -0
- package/site/dist/assets/PhCaretRight-D7ZS3Ls8.js +14 -0
- package/site/dist/assets/PhCaretUp-C-iIfyvO.js +14 -0
- package/site/dist/assets/PhCheck-DxQXn57r.js +14 -0
- package/site/dist/assets/{PhCircleHalf-Bk9C4DvT.js → PhCircleHalf-MJZeRBGF.js} +5 -5
- package/site/dist/assets/PhClock-x3MS3Mwi.js +14 -0
- package/site/dist/assets/{PhCompass-Df1ugFO-.js → PhCompass-hYn3HhGN.js} +5 -5
- package/site/dist/assets/PhCopy-CWNYcABI.js +14 -0
- package/site/dist/assets/{PhCreditCard-CZpdid2n.js → PhCreditCard-Fy4pzwtt.js} +5 -5
- package/site/dist/assets/{PhCurrencyDollar-B6IKKjue.js → PhCurrencyDollar-BgiaenCi.js} +5 -5
- package/site/dist/assets/{PhDesktop-BuCDXYJj.js → PhDesktop-CxrzCSv5.js} +5 -5
- package/site/dist/assets/PhDeviceMobile-CsyA5Goi.js +14 -0
- package/site/dist/assets/PhDotsThree-D-k1BiYg.js +14 -0
- package/site/dist/assets/PhEnvelope-D8kzeNox.js +14 -0
- package/site/dist/assets/PhFunnelSimple-CfQs5DAW.js +14 -0
- package/site/dist/assets/{PhGlobe-q1mqj65V.js → PhGlobe-DvmSc9_A.js} +5 -5
- package/site/dist/assets/{PhIdentificationCard-BeLXJpfZ.js → PhIdentificationCard-CfkZm-5K.js} +5 -5
- package/site/dist/assets/{PhImage-BYrKfN9k.js → PhImage-Cf0J2ZfJ.js} +5 -5
- package/site/dist/assets/{PhInfo-X33f06Ej.js → PhInfo-Bwi51-2X.js} +5 -5
- package/site/dist/assets/{PhLightbulb-DMZJsowR.js → PhLightbulb-C4FZV7Es.js} +5 -5
- package/site/dist/assets/PhMagnifyingGlass-C9u8jSCJ.js +14 -0
- package/site/dist/assets/{PhPaperPlaneRight-Dvo-nXr9.js → PhPaperPlaneRight-zxQVvPLX.js} +5 -5
- package/site/dist/assets/PhPlus-C4UoW-2n.js +14 -0
- package/site/dist/assets/{PhPower-D8-AcNM6.js → PhPower-CFyWDmgD.js} +5 -5
- package/site/dist/assets/{PhPuzzlePiece-C-7mYqGO.js → PhPuzzlePiece-BjoNVfST.js} +5 -5
- package/site/dist/assets/{PhQrCode-uIXlI5ER.js → PhQrCode-CP3tFauY.js} +5 -5
- package/site/dist/assets/{PhQuestion-rUoqC2sC.js → PhQuestion-wOWJBd3G.js} +5 -5
- package/site/dist/assets/{PhQuestionMark-W55Txvvb.js → PhQuestionMark-CV0k9C0Y.js} +5 -5
- package/site/dist/assets/{PhSealCheck-BeVLq9PH.js → PhSealCheck-vIKzREuN.js} +5 -5
- package/site/dist/assets/{PhSignOut-Cq2PivQ6.js → PhSignOut-CxELV-i0.js} +5 -5
- package/site/dist/assets/{PhSpinner-CZMtAFdX.js → PhSpinner-CGDmbzUd.js} +5 -5
- package/site/dist/assets/{PhTrash-BamrmMsN.js → PhTrash-C9PD0SAt.js} +5 -5
- package/site/dist/assets/{PhUser-A2fxqIV0.js → PhUser-0sWNXQeZ.js} +5 -5
- package/site/dist/assets/{PhVault-B8m1usHw.js → PhVault-6JTskUcC.js} +5 -5
- package/site/dist/assets/{PhWarning-CpkID9oi.js → PhWarning-CoKs3gz6.js} +5 -5
- package/site/dist/assets/PhWarningCircle-BXHw1fCt.js +14 -0
- package/site/dist/assets/PhX-DX0SFIqC.js +14 -0
- package/site/dist/assets/PhoneIcon-CZ47md80.js +1 -0
- package/site/dist/assets/PinInput-DbZ0b1i1-BrTXu3Km.js +247 -0
- package/site/dist/assets/PrivyPluginContext-DA-yS5vO-CY60yubk.js +1 -0
- package/site/dist/assets/QrCode-DbnZwlkH-CcMrWV5D.js +22 -0
- package/site/dist/assets/RecoveryOAuthStatusScreen-CsgtTI2x-DgeDnHOK.js +1 -0
- package/site/dist/assets/RecoveryPasswordCreateScreen-Be-qJ-LU-CvJJwLhK.js +1 -0
- package/site/dist/assets/RecoverySelectionScreen-D1iGtpmi-CADtGtSV.js +7 -0
- package/site/dist/assets/SIWXUtil-Cpiv91-M.js +1 -0
- package/site/dist/assets/{Screen-D30meWsY-DDum2qlY.js → Screen-D30meWsY-vEusJ7KX.js} +22 -22
- package/site/dist/assets/{ScreenHeader-CHmc4-Lu-BqrAEXbV.js → ScreenHeader-CHmc4-Lu-BvGTLg53.js} +4 -4
- package/site/dist/assets/ScreenLayout-OwaQQcxH-cfOTmyl0.js +1 -0
- package/site/dist/assets/{SelectSourceAsset-CWFog6gm-8iXuqbAs.js → SelectSourceAsset-CWFog6gm-DxYklZYs.js} +18 -18
- package/site/dist/assets/SetAutomaticRecoveryScreen-BO_OEqAZ-oeqeo05x.js +14 -0
- package/site/dist/assets/SetWalletPasswordForm-DwCTVtAh-BxFee9UA.js +11 -0
- package/site/dist/assets/ShieldCheckIcon-eFjsosCA.js +1 -0
- package/site/dist/assets/SignRequestScreen-BHKv32KR-z8ixfIma.js +26 -0
- package/site/dist/assets/SolanaWalletConnector-C7Lqk-Wz-Bc_lvdiF.js +1 -0
- package/site/dist/assets/{StackedContainer-B2vaEl56-C-ojzCoQ.js → StackedContainer-B2vaEl56-Do5dXB8-.js} +2 -2
- package/site/dist/assets/StandardSignAndSendTransactionScreen-CfhIXVtd-DudetZAc.js +20 -0
- package/site/dist/assets/{Subtitle-CV-2yKE4-o-1FQLlX.js → Subtitle-CV-2yKE4-DV0o1av3.js} +2 -2
- package/site/dist/assets/TelegramAuthScreen-UL9zLfO8-Bo3sONvf.js +1 -0
- package/site/dist/assets/{Title-BnzYV3Is-RX1f0RV-.js → Title-BnzYV3Is-C3qOPnO_.js} +2 -2
- package/site/dist/assets/TodoList-DnyULl18-BvxvubbF.js +36 -0
- package/site/dist/assets/TransactionDetails-e9nesl30-WWflkOIi.js +109 -0
- package/site/dist/assets/TransactionErrorView-BDBNqA_f-CotYKcgf.js +178 -0
- package/site/dist/assets/TransferFromWalletScreen-Qvn1Yuno-sVFlWqa8.js +31 -0
- package/site/dist/assets/TransferOrBridgeLoadingScreen-Dl1I_iIz-CV2-mY19.js +6 -0
- package/site/dist/assets/TurnstileWrapper-B7sNddys-oPbuMTQt.js +1 -0
- package/site/dist/assets/UpdateEmailScreen-DVOhPV0H-D_mjSpAy.js +1 -0
- package/site/dist/assets/UpdatePhoneScreen-CXRswTNZ-6RLG0ahv.js +1 -0
- package/site/dist/assets/UserLimitReachedScreen-5we2DHn8-CaVN0bti.js +1 -0
- package/site/dist/assets/{Value-DTgR824E-DZpvBCWi.js → Value-DTgR824E-Bp6WGZZm.js} +7 -7
- package/site/dist/assets/WalletCards-DH1rqayz-D3cOTb9x.js +1 -0
- package/site/dist/assets/WalletIcon-DOIZhb2l.js +1 -0
- package/site/dist/assets/WalletInfoCard-sq_2wgFg-bOqfl5MA.js +29 -0
- package/site/dist/assets/WalletInterstitialScreen-Sh7LfsAh-DWaVkMCA.js +1 -0
- package/site/dist/assets/WalletLink-DK5LB5Ha-DjUZvqs-.js +20 -0
- package/site/dist/assets/WalletOverflowButton-bfCnp-9T-B6P7DQXA.js +1 -0
- package/site/dist/assets/WarningBanner-ZZqCEtZK-Bc2YKZb7.js +21 -0
- package/site/dist/assets/__vite-browser-external-NciY4Vu1.js +1 -0
- package/site/dist/assets/_esm-BZP3cXTv.js +1 -0
- package/site/dist/assets/_esm-ZmzBJpEs.js +6 -0
- package/site/dist/assets/accounts-D4AXF17G.js +1 -0
- package/site/dist/assets/accounts-IkdFx9nq.js +1 -0
- package/site/dist/assets/analytics-mkkvFRju-BRBcadka.js +1 -0
- package/site/dist/assets/baseSepolia-Bn1j1Ysw.js +1 -0
- package/site/dist/assets/basic-Cz1YiCSk.js +1575 -0
- package/site/dist/assets/capitalizeFirstLetter-DmLYqXsO-DtOXx-2n.js +1 -0
- package/site/dist/assets/ccip-B1J3oTZx.js +7 -0
- package/site/dist/assets/ccip-Bd7261zy.js +1 -0
- package/site/dist/assets/ccip-D6EHKpjI.js +1 -0
- package/site/dist/assets/chain-scefkYIH.js +5 -0
- package/site/dist/assets/check-DHnllI8N.js +1 -0
- package/site/dist/assets/chevron-down-1y-r4bGO.js +1 -0
- package/site/dist/assets/circle-alert-OwxamXUX.js +1 -0
- package/site/dist/assets/circle-check-big-3sZGVC10.js +1 -0
- package/site/dist/assets/circle-x-DQjNUV9J.js +1 -0
- package/site/dist/assets/client-B-BpRtwY.js +1 -0
- package/site/dist/assets/client-BfIR1FvH.js +9 -0
- package/site/dist/assets/coinbase-DCPC2L_R-YEuIn3jh.js +3 -0
- package/site/dist/assets/copy-DMOX_yn7.js +1 -0
- package/site/dist/assets/core-GIEmxmAa.js +12 -0
- package/site/dist/assets/createLucideIcon-BsERoFTA.js +1 -0
- package/site/dist/assets/defineChain-B-SQDLTG.js +1 -0
- package/site/dist/assets/dijkstra-CY95afk4.js +1 -0
- package/site/dist/assets/dist-CoS6E-3x.js +1 -0
- package/site/dist/assets/dist-Cp6IXeJd.js +1 -0
- package/site/dist/assets/dist-CrNxmdZj.js +1 -0
- package/site/dist/assets/dist-DYGtf4F0.js +16 -0
- package/site/dist/assets/embed.worker-Cnl4VGr3.js +1 -0
- package/site/dist/assets/errors-BQ3N-RVt-CZPAWCgC.js +1 -0
- package/site/dist/assets/esm-C3DslVJx.js +1 -0
- package/site/dist/assets/esm-Ci1ogKuK.js +1 -0
- package/site/dist/assets/esm-Co94ENUV.js +37 -0
- package/site/dist/assets/esm-bb8SANZh.js +1 -0
- package/site/dist/assets/esm-n2lWo7kz.js +1 -0
- package/site/dist/assets/ethers-zTjbodk5-Cs648CnD.js +1 -0
- package/site/dist/assets/eventemitter3-Dzc_0Uq2.js +1 -0
- package/site/dist/assets/external-link-BBPG3rG7.js +1 -0
- package/site/dist/assets/farcaster-DPlSjvF5-CzBCmgyL.js +1 -0
- package/site/dist/assets/features-CuiHbgEJ.js +2 -0
- package/site/dist/assets/fingerprint-pattern-CjLtyIxB.js +1 -0
- package/site/dist/assets/floating-ui.react-DmaCfayr.js +1 -0
- package/site/dist/assets/floating-ui.react-dom-CaoMF8mP.js +1 -0
- package/site/dist/assets/formatErc20TokenAmount-BuPk9xcy-BVqOKQif.js +1 -0
- package/site/dist/assets/formatter-CVbp4SlJ.js +1 -0
- package/site/dist/assets/get-entropy-details-for-user-dHRH5Gpi-BNiOFXbK.js +1 -0
- package/site/dist/assets/getChainName-DjpPdUSc-DUyKDrnp.js +1 -0
- package/site/dist/assets/getErc20Balance-jXNpFf0N-q4bV8kQq.js +1 -0
- package/site/dist/assets/getErc20TokenInfo-BNTrzLMP-DcnTFrXN.js +1 -0
- package/site/dist/assets/getFormattedUsdFromLamports-De3U9GlO-Gx4_wxON.js +1 -0
- package/site/dist/assets/getUsdcMintAddress-BVgm9GRo-r2UnDeEy.js +1 -0
- package/site/dist/assets/guards-BIW-GiMJ-D3tWTQAR.js +1 -0
- package/site/dist/assets/hooks.module-BYZGfwDl.js +1 -0
- package/site/dist/assets/hourglass-D_GfQdJr.js +1 -0
- package/site/dist/assets/id-UqEwL2BI-CTlvRMA5.js +1 -0
- package/site/dist/assets/index-BdEw5wyl-kLbhqLbv.js +1 -0
- package/site/dist/assets/index-C2h3EneX.js +8 -0
- package/site/dist/assets/{index-CWARkn2w-D6ikWJWj.js → index-CWARkn2w-DxuckIFn.js} +7 -7
- package/site/dist/assets/index-DvMddJcd-CNBb4VUn.js +12 -0
- package/site/dist/assets/index-YiCw0Y_x-Czl0tWfF.js +436 -0
- package/site/dist/assets/index.browser-B-i-Lj3J.js +1 -0
- package/site/dist/assets/index.browser-BMmUcykv.js +1 -0
- package/site/dist/assets/index.es-Crd0TyUS.js +2 -0
- package/site/dist/assets/index.es-DQbup1WG.js +3 -0
- package/site/dist/assets/isPaymentRequestAvailable-Bq1cemEn-Cjf3l05I.js +1 -0
- package/site/dist/assets/jsx-runtime-CndCZlyt.js +1 -0
- package/site/dist/assets/landmark-BZPqMFEf.js +1 -0
- package/site/dist/assets/lib-DGtzi2DK.js +1 -0
- package/site/dist/assets/localBatchGatewayRequest-B71J8sQ9.js +29 -0
- package/site/dist/assets/lock-DyN_c-ud.js +1 -0
- package/site/dist/assets/logger-CsXm3oIv-B0UYpNFI.js +1 -0
- package/site/dist/assets/mail-V_mcPb64.js +1 -0
- package/site/dist/assets/modal-context-CwmSeFcv-DPWNJrfK.js +1 -0
- package/site/dist/assets/native-BKj27wfc.js +1 -0
- package/site/dist/assets/ofetch.CWycOUEr-Duby3iHT.js +1 -0
- package/site/dist/assets/parseAbi-Csg-8t59.js +2 -0
- package/site/dist/assets/parseAbiParameters-BWbIMYe4.js +1 -0
- package/site/dist/assets/parseEther-CHS0GNkM.js +1 -0
- package/site/dist/assets/pkce-DXF0yKjP-7_VY-d83.js +1 -0
- package/site/dist/assets/preload-helper-CRzLMJPS.js +1 -0
- package/site/dist/assets/privy-context-81KmsBw2-DiR6-Yq8.js +2 -0
- package/site/dist/assets/property-DuZ9DLP4.js +3 -0
- package/site/dist/assets/react-BfYA1q0G.js +1 -0
- package/site/dist/assets/react-CK2HRI1t.js +1 -0
- package/site/dist/assets/react-DxGeY8B8.js +1 -0
- package/site/dist/assets/react-auth-sHnipzbS.js +1 -0
- package/site/dist/assets/react-dom-BI2Koe4o.js +1 -0
- package/site/dist/assets/reservoir-x-nGuZkT-BguVFH3D.js +1 -0
- package/site/dist/assets/roles-BDPDWrwo.js +1 -0
- package/site/dist/assets/roles-DKPW79Ca.js +1 -0
- package/site/dist/assets/rolldown-runtime-Bjp52BOI.js +1 -0
- package/site/dist/assets/safe-url-D7SRPu33-CkMedGro.js +1 -0
- package/site/dist/assets/secp256k1-BeYL8aZl.js +1 -0
- package/site/dist/assets/secp256k1-Bh4MSkhz.js +1 -0
- package/site/dist/assets/secp256k1-Ci4cqHl0.js +1 -0
- package/site/dist/assets/secp256k1-DsxXqbXv.js +1 -0
- package/site/dist/assets/secp256k1-N9RUmafO.js +1 -0
- package/site/dist/assets/serializeAuthorizationList-DGMik9Wx.js +1 -0
- package/site/dist/assets/serializeSignature-CWKpxoab.js +2 -0
- package/site/dist/assets/sha2-C6s7zZmb.js +1 -0
- package/site/dist/assets/{shared-DRZUmnL5-MWD-C-pp.js → shared-DRZUmnL5-BewE5wK8.js} +33 -33
- package/site/dist/assets/{shared-FM0rljBt-c4eSjzGj.js → shared-FM0rljBt-CxLACri_.js} +6 -6
- package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-BkAKsRNi.js +1 -0
- package/site/dist/assets/simulateTransaction-CfuOrae4-PjA_tGjX.js +1 -0
- package/site/dist/assets/smartphone-3p8nFSTE.js +1 -0
- package/site/dist/assets/src-BBjkfi-Q.js +1 -0
- package/site/dist/assets/storage-Ufl800Ne-1qCR2JMO.js +8 -0
- package/site/dist/assets/stringify-DqUj9VzO.js +20 -0
- package/site/dist/assets/stripe.esm-DEi2D291.js +2 -0
- package/site/dist/assets/styles-BsotlekN-Aq27nZGc.js +9 -0
- package/site/dist/assets/{styles-Cm9H63WO-Cv1TbqYi.js → styles-Cm9H63WO-p_ic_dxE.js} +17 -17
- package/site/dist/assets/{styles-DVyDvTdj-CI4xZNHp.js → styles-DVyDvTdj-CjsWqAld.js} +8 -8
- package/site/dist/assets/{styles-hslXy6xG-DeVcFoDD.js → styles-hslXy6xG-D5QHIrJU.js} +23 -23
- package/site/dist/assets/telegram-B-JqnkqZ-Dqkm4rDn.js +1 -0
- package/site/dist/assets/to-ui-error-DWe-qwS3-Bi1HUQI9.js +4 -0
- package/site/dist/assets/toViemAccount-B5iDGq1b-CdFZwv07.js +2 -0
- package/site/dist/assets/transaction-BNTP-bFm-M5tJx8vY.js +1 -0
- package/site/dist/assets/transfer-6YztDh-t-BVQkTvG-.js +1 -0
- package/site/dist/assets/transformers.web-BTyOEJ0C.js +40 -0
- package/site/dist/assets/transformers.web-CUZUFjAK.js +49 -0
- package/site/dist/assets/triangle-alert-BG3Qw-Hq.js +1 -0
- package/site/dist/assets/twitch-5IOe4sIQ-CaXHFlAu.js +1 -0
- package/site/dist/assets/types-4CuOD23i.js +1 -0
- package/site/dist/assets/use-headless-crypto-deposit-Yn-QRLB3-CQqeyhGY.js +1 -0
- package/site/dist/assets/use-unlink-wallet-BKK4_5Ur-C0xQN_Lp.js +1 -0
- package/site/dist/assets/useActiveWallet-B-yZYGc6-BkK6rFBm.js +123 -0
- package/site/dist/assets/useGetSolPrice-x7gfUIHJ-CLVXqv6I.js +1 -0
- package/site/dist/assets/useGetTokenPrice-CaoUkb79-DAXXs3rs.js +1 -0
- package/site/dist/assets/useI18n-C-5n_noF-CGpkgIVy.js +1 -0
- package/site/dist/assets/useWalletBalance-CZnP5f_f-Cfd64m4n.js +1 -0
- package/site/dist/assets/useWallets-X1ndvJ_U-CAYqg7Za.js +1 -0
- package/site/dist/assets/utils-BkR7EQjg.js +1 -0
- package/site/dist/assets/utils-DJhBNOZA.js +1 -0
- package/site/dist/assets/utils-DdckVfQr.js +1 -0
- package/site/dist/assets/w3m-modal-B4H_uiPH.js +1174 -0
- package/site/dist/assets/wallet-BNI12IYk.js +1 -0
- package/site/dist/assets/wallet-CITSaPlB.js +2 -0
- package/site/dist/assets/wallet-connect-BvJtUsDt-CVlSNIXP.js +1 -0
- package/site/dist/assets/walletconnect-registry-xxG8XLCb-BpzpBq5s.js +1 -0
- package/site/dist/assets/walletconnect-v2-3frQFwbg-CzZ6oybX.js +12 -0
- package/site/dist/assets/{index-CztIxJB6.js → wui-ux-by-reown-XyHdtV1O.js} +296 -296
- package/site/dist/assets/x-gjDrY2rk.js +1 -0
- package/site/dist/index.html +5 -117
- package/site/worker.js +20 -32
- package/src/agent/mcp.js +46 -14
- package/src/agent/view-tools.js +3 -11
- package/src/agent/x402.js +3 -42
- package/src/discover/apps.js +37 -2
- package/src/discover/explore.js +19 -13
- package/src/publish/init.js +74 -0
- package/src/publish/ship.js +90 -79
- package/src/publish/view-cli.js +6 -3
- package/src/publish/view.js +27 -43
- package/template/README.md +49 -0
- package/template/app.json +27 -0
- package/template/eval/goals.md +7 -0
- package/template/eval/golden.jsonl +0 -0
- package/template/gitignore +3 -0
- package/template/package.json +13 -0
- package/template/wrangler.json +12 -0
- package/site/dist/assets/AccountNotFoundScreen-C4njXc69-RUyAWRzV.js +0 -1
- package/site/dist/assets/AddFundsSelectionScreen-RAoCn7ej-ZV-LlYBe.js +0 -31
- package/site/dist/assets/Address-H8kD1d9O-CGQnt7Pu.js +0 -17
- package/site/dist/assets/AffirmativeConsentScreen-BG0MJxku-CKn2JLwq.js +0 -6
- package/site/dist/assets/AllowlistRejectionScreen-Cae6e1Od-9oIP9fma.js +0 -1
- package/site/dist/assets/ArrowsRightLeftIcon-BEhBD_6N.js +0 -1
- package/site/dist/assets/AuthenticateWithWalletScreen-CU6hIcFT-D1wLlSJs.js +0 -1
- package/site/dist/assets/AwaitingEvmToSolBridgingScreen-D0e_sZMS-CSBbHTyz.js +0 -1
- package/site/dist/assets/AwaitingExternalEthereumTransferScreen-ur5HL4R7-BsRq-xBt.js +0 -1
- package/site/dist/assets/AwaitingPasswordlessCodeScreen-DRHz76mM-BPdhsKvN.js +0 -103
- package/site/dist/assets/AwaitingSolToEvmBridgingScreen-CdLRrGD2-CEGNdrkr.js +0 -1
- package/site/dist/assets/BridgeNetworkSelectionView-CFGjB2nO-Da9P7eSx.js +0 -68
- package/site/dist/assets/CaptchaScreen-DbpvkIGx-BecgMnD_.js +0 -1
- package/site/dist/assets/CheckCircleIcon-DBiWFjO6.js +0 -1
- package/site/dist/assets/CheckCircleIcon-DzG2ROJZ.js +0 -1
- package/site/dist/assets/Checkbox-D1EDeo41-DMHcj9o_.js +0 -52
- package/site/dist/assets/ChevronDownIcon-2Os56gUt.js +0 -1
- package/site/dist/assets/Chip-CZKIKt9K-BWzs9fj5.js +0 -26
- package/site/dist/assets/CoinbaseOnrampStatusScreen-BbyCJDXL-CFvcSiDs.js +0 -16
- package/site/dist/assets/ConnectEmailForm-B-VRE0MN-BozkCg8q.js +0 -3
- package/site/dist/assets/ConnectLedgerScreen-DWHABGot-DaCnbBzh.js +0 -10
- package/site/dist/assets/ConnectOnlyLandingScreen-CZYx9Bmp-DUkCLkxD.js +0 -1
- package/site/dist/assets/ConnectOnlyStatusScreen-DCRzjxHx-Dv_5nMkZ.js +0 -1
- package/site/dist/assets/ConnectOrCreateScreen-CUUYUO07-DSGEeB3Y.js +0 -1
- package/site/dist/assets/ConnectPhoneForm-Dek5xn4C-C-s4s_Lq.js +0 -95
- package/site/dist/assets/ConnectWalletView-DqI-PTvX-BKX7fdYr.js +0 -74
- package/site/dist/assets/ConnectionStatusScreen-fUfROm9m-DSoAuMFZ.js +0 -7
- package/site/dist/assets/CopyToClipboard-i_OQSBJr-CZTXyfV0.js +0 -39
- package/site/dist/assets/CopyableText-CQapvaMr-DHO818I0.js +0 -28
- package/site/dist/assets/CrossAppAuthScreen-CLw7ymZq-DW4nRGfz.js +0 -1
- package/site/dist/assets/CustomLandingScreenView-Cm_MBSyX-DH8Nnb4Y.js +0 -22
- package/site/dist/assets/DelegatedActionsConsentScreen-DYF2U4y5-gfUS_uV5.js +0 -1
- package/site/dist/assets/DelegatedActionsRevokeScreen-bPp6Uwyh-DZj9HTHc.js +0 -1
- package/site/dist/assets/DepositAddressAddressStepView-4vdkb55L-eHYsDK9W.js +0 -187
- package/site/dist/assets/DepositAddressScreen-DBLRs7aI-DK_XVgVk.js +0 -8
- package/site/dist/assets/DepositAddressV3Screen-CDqIEMQw-6gRZzhLe.js +0 -1
- package/site/dist/assets/EmbeddedWalletConnectingScreen-D4T7DUzs-BZu2ae0k.js +0 -1
- package/site/dist/assets/EmbeddedWalletCreatedScreen-D7WhW5ve-86pviemJ.js +0 -1
- package/site/dist/assets/EmbeddedWalletKeyExportScreen-CqV4NYQ3-vDcvT53Y.js +0 -23
- package/site/dist/assets/EmbeddedWalletOnAccountCreateScreen-BoKb3Q2S-rNJAtSJc.js +0 -1
- package/site/dist/assets/EmbeddedWalletPasswordUpdateScreen-D3rMlqS7-I8Q95280.js +0 -1
- package/site/dist/assets/EmbeddedWalletPasswordUpdateSplashScreen-BPFkWJeE-Coi7OxoI.js +0 -1
- package/site/dist/assets/EnrollTotp-Dibew4dp-DC7FrDgo.js +0 -66
- package/site/dist/assets/EnvelopeIcon-DY6ERnW7.js +0 -1
- package/site/dist/assets/ErrorBanner-BcpGRt0h-BvESwN99.js +0 -21
- package/site/dist/assets/ErrorScreen-DipdTWzE-DnKGxH1Z.js +0 -4
- package/site/dist/assets/ExclamationCircleIcon-BZhlqH0r.js +0 -1
- package/site/dist/assets/ExclamationTriangleIcon-CkAOJIYV.js +0 -1
- package/site/dist/assets/FarcasterConnectStatusScreen-51tjUxqq-4pi7jooW.js +0 -75
- package/site/dist/assets/FarcasterSignerStatusScreen-6x-Uh95G-z2XCMaLL.js +0 -28
- package/site/dist/assets/FiatOnrampScreen-BAhYeiTI-CBVA9v1-.js +0 -491
- package/site/dist/assets/FingerPrintIcon-ra2dqmJO.js +0 -1
- package/site/dist/assets/FundSolWalletWithExternalSolanaWallet-WtLwYaOl-DwAwc6Ny.js +0 -1
- package/site/dist/assets/FundWalletMethodHeader-BWNkokCT-CZszQsZf.js +0 -1
- package/site/dist/assets/FundWithBankDepositScreen-DajkHxBD-DfX6nvFQ.js +0 -58
- package/site/dist/assets/FundingEditAmountScreen-CpvpiO4M-CDS_sk_t.js +0 -1
- package/site/dist/assets/FundingMethodSelectionScreen-Db7vhRlE-CPfNQemT.js +0 -1
- package/site/dist/assets/GlobeAltIcon-SEUEIe_E.js +0 -1
- package/site/dist/assets/GooglePay-B53WnudL-aap7zwag.js +0 -1
- package/site/dist/assets/HCaptchaWrapper-CUi9LJsp-DgSjCjQI.js +0 -4
- package/site/dist/assets/InAppBrowserLoginNotPossible-BMR9br1T-DO4wICml.js +0 -1
- package/site/dist/assets/InfoBanner-Cb3p1z12-CDWt2ADo.js +0 -22
- package/site/dist/assets/InjectedWalletIcon-DLcYOGDj-Ba19XoBr.js +0 -1
- package/site/dist/assets/InstallWalletScreen-DTA8dwLv-DGpewEch.js +0 -1
- package/site/dist/assets/LandingScreen-CGWUoSUG-CUOCWUXd.js +0 -1
- package/site/dist/assets/Link-BdDilT2T-BYiP1zvW.js +0 -40
- package/site/dist/assets/LinkConflictScreen-C3ZEPsgl-Tb6cAepT.js +0 -77
- package/site/dist/assets/LinkEmailScreen-dKo9frwc-pq0NF2JO.js +0 -1
- package/site/dist/assets/LinkPasskeyScreen-zbrl_AI_-D9MOmDqg.js +0 -117
- package/site/dist/assets/LinkPhoneScreen-oIUpfj0w-B80UJqAZ.js +0 -1
- package/site/dist/assets/LockClosedIcon-BqkoEL9J.js +0 -1
- package/site/dist/assets/LoginFailedScreen-CN0dJV6U-DlnOM-Kh.js +0 -1
- package/site/dist/assets/ManualTransferScreen-CHqcuqbs-DSShupq9.js +0 -1
- package/site/dist/assets/MfaAuthEnrollmentFlowScreen-Dj7gPTRC-DUPV_SLA.js +0 -1
- package/site/dist/assets/MfaAuthVerifyFlowScreen-DbFpyWMy-D96GpzXX.js +0 -1
- package/site/dist/assets/MfaEnrollmentFlowScreen-DhLnGgnr-CYQDa4ND.js +0 -1
- package/site/dist/assets/MfaVerifyFlowScreen-C_XPjMRP-CJtSAXGN.js +0 -1
- package/site/dist/assets/ModalFooter-BCuEK_nz-D2I8KWtk.js +0 -403
- package/site/dist/assets/MoonpayStatusScreen-CzTUtokc-Bx5aHy-z.js +0 -16
- package/site/dist/assets/OAuthStatusScreen-ufbOa-da-CS6988X2.js +0 -1
- package/site/dist/assets/OpenLink-CUpJ1mOr-EZWVSX2r.js +0 -39
- package/site/dist/assets/PasskeySelectSignupOrLogin-xh2ScC_l-BY4eK5Jh.js +0 -1
- package/site/dist/assets/PasskeyStatusScreen-Bla8MaOk-LXys76u9.js +0 -6
- package/site/dist/assets/PasswordRecoveryScreen-awGXZkQk-RczvLvmo.js +0 -20
- package/site/dist/assets/PhArrowClockwise-mOiWYLMV.js +0 -14
- package/site/dist/assets/PhArrowDown-CkoOD89h.js +0 -14
- package/site/dist/assets/PhArrowLeft-C0jlxVhM.js +0 -14
- package/site/dist/assets/PhArrowRight-BI-V03Xf.js +0 -14
- package/site/dist/assets/PhArrowUp-izKvURUW.js +0 -14
- package/site/dist/assets/PhArrowUpRight-Bn-JhHsY.js +0 -14
- package/site/dist/assets/PhArrowsLeftRight-CYsRQ2qh.js +0 -14
- package/site/dist/assets/PhBrowser-BjzAmrHO.js +0 -14
- package/site/dist/assets/PhCaretDown-ddSjwcwm.js +0 -14
- package/site/dist/assets/PhCaretLeft-B7YLoNEF.js +0 -14
- package/site/dist/assets/PhCaretRight-BY8D5MIg.js +0 -14
- package/site/dist/assets/PhCaretUp-BG10nSut.js +0 -14
- package/site/dist/assets/PhCheck-DrKd7pBC.js +0 -14
- package/site/dist/assets/PhClock-Sj17weCB.js +0 -14
- package/site/dist/assets/PhCopy-rgttky8E.js +0 -14
- package/site/dist/assets/PhDeviceMobile-CnybhXY-.js +0 -14
- package/site/dist/assets/PhDotsThree-CSAEcba1.js +0 -14
- package/site/dist/assets/PhEnvelope-SmaNeXoQ.js +0 -14
- package/site/dist/assets/PhFunnelSimple-DKx35ITq.js +0 -14
- package/site/dist/assets/PhMagnifyingGlass-B6D0sWFL.js +0 -14
- package/site/dist/assets/PhPlus-CBvZvLax.js +0 -14
- package/site/dist/assets/PhWarningCircle-Cm58gXb9.js +0 -14
- package/site/dist/assets/PhX-C3b4cCEy.js +0 -14
- package/site/dist/assets/PhoneIcon-CzbssTb8.js +0 -1
- package/site/dist/assets/PinInput-DbZ0b1i1-1DtLWL81.js +0 -247
- package/site/dist/assets/QrCode-DbnZwlkH-ChwcUk_h.js +0 -22
- package/site/dist/assets/RecoveryOAuthStatusScreen-CsgtTI2x-C79jd345.js +0 -1
- package/site/dist/assets/RecoveryPasswordCreateScreen-Be-qJ-LU-C9c0x-yq.js +0 -1
- package/site/dist/assets/RecoverySelectionScreen-D1iGtpmi-PNqHb6CI.js +0 -7
- package/site/dist/assets/ScreenLayout-OwaQQcxH-B4Z8FjFp.js +0 -1
- package/site/dist/assets/SetAutomaticRecoveryScreen-BO_OEqAZ-CUpQZ9wq.js +0 -14
- package/site/dist/assets/SetWalletPasswordForm-DwCTVtAh-ZzvPLj2s.js +0 -15
- package/site/dist/assets/ShieldCheckIcon-Bjwe_-PV.js +0 -1
- package/site/dist/assets/SignRequestScreen-BHKv32KR-0qGeNipB.js +0 -26
- package/site/dist/assets/StandardSignAndSendTransactionScreen-CfhIXVtd-C3lgJb68.js +0 -20
- package/site/dist/assets/TelegramAuthScreen-UL9zLfO8-l35_C2DG.js +0 -1
- package/site/dist/assets/TodoList-DnyULl18-JxWWU9KA.js +0 -36
- package/site/dist/assets/TransactionDetails-e9nesl30-C91nJPM9.js +0 -109
- package/site/dist/assets/TransactionErrorView-BDBNqA_f-Cpm-4xzm.js +0 -178
- package/site/dist/assets/TransferFromWalletScreen-Qvn1Yuno-BWCH7-Si.js +0 -31
- package/site/dist/assets/TransferOrBridgeLoadingScreen-Dl1I_iIz-BWMeJabk.js +0 -6
- package/site/dist/assets/TurnstileWrapper-B7sNddys-Dgr80Gih.js +0 -1
- package/site/dist/assets/UpdateEmailScreen-DVOhPV0H-Clk4zk-8.js +0 -1
- package/site/dist/assets/UpdatePhoneScreen-CXRswTNZ-BgRsoR3B.js +0 -1
- package/site/dist/assets/UserLimitReachedScreen-5we2DHn8-D-SU-vAz.js +0 -1
- package/site/dist/assets/WalletCards-DH1rqayz-UuZ4i_Ze.js +0 -1
- package/site/dist/assets/WalletIcon-B1i03Vqc.js +0 -1
- package/site/dist/assets/WalletInfoCard-sq_2wgFg-TXTxmb8L.js +0 -29
- package/site/dist/assets/WalletInterstitialScreen-Sh7LfsAh-CbrFb0ON.js +0 -1
- package/site/dist/assets/WalletLink-DK5LB5Ha-BYQZV7UV.js +0 -20
- package/site/dist/assets/WalletOverflowButton-bfCnp-9T-CNgSPnTS.js +0 -1
- package/site/dist/assets/WarningBanner-ZZqCEtZK-DNZUUOph.js +0 -21
- package/site/dist/assets/__vite-browser-external-BIHI7g3E.js +0 -1
- package/site/dist/assets/analytics-mkkvFRju-DOXuftJB.js +0 -1
- package/site/dist/assets/basic-C9wn6QoQ.js +0 -1575
- package/site/dist/assets/bytes-CjWw8TJh.js +0 -1
- package/site/dist/assets/capitalizeFirstLetter-DmLYqXsO-tV1Idewc.js +0 -1
- package/site/dist/assets/ccip-BhHEqVIW.js +0 -1
- package/site/dist/assets/check-C_DTyjLS.js +0 -1
- package/site/dist/assets/chevron-down-iklXXH-z.js +0 -1
- package/site/dist/assets/circle-alert-KEOUF48T.js +0 -1
- package/site/dist/assets/circle-check-big-BJ_ADwB4.js +0 -1
- package/site/dist/assets/circle-x-BSfWmhYk.js +0 -1
- package/site/dist/assets/client-BnDcP42J.js +0 -9
- package/site/dist/assets/client-DH86IrJA.js +0 -125
- package/site/dist/assets/coinbase-DCPC2L_R-2ivYfoMv.js +0 -3
- package/site/dist/assets/copy-sK00DOfH.js +0 -1
- package/site/dist/assets/core-CRE213RM.js +0 -211
- package/site/dist/assets/createLucideIcon-D9OK_uxG.js +0 -1
- package/site/dist/assets/custom-V1wex-Di.js +0 -1
- package/site/dist/assets/dijkstra-COg3n3zL.js +0 -1
- package/site/dist/assets/embed.worker-BRIYO7m8.js +0 -1
- package/site/dist/assets/encodePacked-DyXYq3Cc.js +0 -1
- package/site/dist/assets/ethers-zTjbodk5-DSYOi6tU.js +0 -1
- package/site/dist/assets/external-link-Cdp8NBio.js +0 -1
- package/site/dist/assets/fallback-DiFue5Zm.js +0 -1
- package/site/dist/assets/farcaster-DPlSjvF5-DP2DLoHZ.js +0 -1
- package/site/dist/assets/features-B6BTj_BL.js +0 -5
- package/site/dist/assets/fingerprint-pattern-gFJTz5e4.js +0 -1
- package/site/dist/assets/floating-ui.react-D9ndYqYK.js +0 -1
- package/site/dist/assets/floating-ui.react-dom-CNbOgOFt.js +0 -1
- package/site/dist/assets/formatErc20TokenAmount-BuPk9xcy-CkAr4Oc0.js +0 -1
- package/site/dist/assets/getChainName-DjpPdUSc-c2urPd0g.js +0 -1
- package/site/dist/assets/getErc20Balance-jXNpFf0N-mFQ9Iqk-.js +0 -1
- package/site/dist/assets/getErc20TokenInfo-BNTrzLMP-Dx5he_uG.js +0 -1
- package/site/dist/assets/getFormattedUsdFromLamports-De3U9GlO-C446pzMl.js +0 -1
- package/site/dist/assets/getTransactionCount-80UHlwAV.js +0 -1
- package/site/dist/assets/getUsdcMintAddress-BVgm9GRo-FDalV59C.js +0 -1
- package/site/dist/assets/hashTypedData-Beq57Ogb.js +0 -22
- package/site/dist/assets/hooks.module-ClpaQ1Tg.js +0 -1
- package/site/dist/assets/hourglass-CB7z_I9H.js +0 -1
- package/site/dist/assets/http-BocEfKYb.js +0 -19
- package/site/dist/assets/index-0knDOgU9.js +0 -1
- package/site/dist/assets/index-9jNeS_nC.js +0 -1
- package/site/dist/assets/index-B--T-Fmt.js +0 -16
- package/site/dist/assets/index-BDkarAkX.js +0 -2
- package/site/dist/assets/index-BMfMy017.js +0 -679
- package/site/dist/assets/index-BOd8jv8-.js +0 -1
- package/site/dist/assets/index-BdEw5wyl-2VGMzHIs.js +0 -1
- package/site/dist/assets/index-C8ThRelw.js +0 -9
- package/site/dist/assets/index-D4LdLFDC.js +0 -1
- package/site/dist/assets/index-D6T-s6sR.js +0 -1
- package/site/dist/assets/index-D7396TWe.js +0 -1
- package/site/dist/assets/index-DdxtHe81.js +0 -2
- package/site/dist/assets/index-DvMddJcd-D7AEQrzj.js +0 -12
- package/site/dist/assets/index-nibyPLVP.js +0 -1
- package/site/dist/assets/index.browser-B6Bt5URJ.js +0 -1
- package/site/dist/assets/isPaymentRequestAvailable-Bq1cemEn-D7xtzRqA.js +0 -1
- package/site/dist/assets/landmark-CMLKifhk.js +0 -1
- package/site/dist/assets/lock-BkyjNE8h.js +0 -1
- package/site/dist/assets/mail-B6-Tq9Ld.js +0 -1
- package/site/dist/assets/native-CJ5et6AR.js +0 -1
- package/site/dist/assets/nonceManager-zkW7cM66.js +0 -1
- package/site/dist/assets/parseEther-C7aOvuze.js +0 -1
- package/site/dist/assets/parseSignature-BIjcuWdB.js +0 -1
- package/site/dist/assets/preload-helper-PPVm8Dsz.js +0 -1
- package/site/dist/assets/privateKeyToAccount-CRvvpHWf.js +0 -1
- package/site/dist/assets/property-CnFDNXw5.js +0 -3
- package/site/dist/assets/react-auth_false-DedQs79w.js +0 -1
- package/site/dist/assets/reservoir-x-nGuZkT-DFxAFt2v.js +0 -1
- package/site/dist/assets/roles-DV_6FRBZ.js +0 -1
- package/site/dist/assets/safe-url-D7SRPu33-A8zMgOTd.js +0 -1
- package/site/dist/assets/serializeErc6492Signature-CeJeL3h6.js +0 -1
- package/site/dist/assets/serializeTransaction-L-_Ej-jW.js +0 -8
- package/site/dist/assets/shouldProceedtoEmbeddedWalletCreationFlow-B3vyavrh-CF2QteTJ.js +0 -1
- package/site/dist/assets/simulateTransaction-CfuOrae4-BHUMPf6Q.js +0 -1
- package/site/dist/assets/smartphone-DAN5rY0T.js +0 -1
- package/site/dist/assets/stripe.esm-Dv8C3q95.js +0 -2
- package/site/dist/assets/styles-BsotlekN-Cjuu2SDV.js +0 -9
- package/site/dist/assets/telegram-B-JqnkqZ-DTjJLkIF.js +0 -1
- package/site/dist/assets/to-ui-error-DWe-qwS3-Dx3yzcV0.js +0 -4
- package/site/dist/assets/toAccount-Bq6rbpbI.js +0 -1
- package/site/dist/assets/transaction-BNTP-bFm-CrebgH-D.js +0 -1
- package/site/dist/assets/transactionReceipt-BwJl-gjg.js +0 -1
- package/site/dist/assets/transfer-6YztDh-t-DU6hH7CZ.js +0 -1
- package/site/dist/assets/transformers.web-BEKVh7pD.js +0 -40
- package/site/dist/assets/transformers.web-aWa49tv1.js +0 -40
- package/site/dist/assets/triangle-alert-ndoiBs4y.js +0 -1
- package/site/dist/assets/twitch-5IOe4sIQ-BXviIywg.js +0 -1
- package/site/dist/assets/useGetSolPrice-x7gfUIHJ-C7axYJ--.js +0 -1
- package/site/dist/assets/useGetTokenPrice-CaoUkb79-CR4CrguU.js +0 -1
- package/site/dist/assets/useI18n-C-5n_noF-C_t8QqBJ.js +0 -1
- package/site/dist/assets/useWalletBalance-CZnP5f_f-BnSHLVI_.js +0 -1
- package/site/dist/assets/w3m-modal-Bz5KWTQ-.js +0 -1174
- package/site/dist/assets/wallet-DTM31trz.js +0 -2
- package/site/dist/assets/wallet-UESEqPei.js +0 -1
- package/site/dist/assets/wallet-connect-BvJtUsDt-CnvUnFbz.js +0 -1
- package/site/dist/assets/walletconnect-v2-3frQFwbg-CzQk99gS.js +0 -15
- package/site/dist/assets/x-B2_XdOVQ.js +0 -1
|
@@ -1,211 +0,0 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["./index-D7396TWe.js","./http-BocEfKYb.js","./serializeTransaction-L-_Ej-jW.js","./hashTypedData-Beq57Ogb.js","./getTransactionCount-80UHlwAV.js","./transactionReceipt-BwJl-gjg.js","./preload-helper-PPVm8Dsz.js","./custom-V1wex-Di.js","./fallback-DiFue5Zm.js","./bytes-CjWw8TJh.js","./encodePacked-DyXYq3Cc.js","./ccip-BhHEqVIW.js","./nonceManager-zkW7cM66.js","./parseSignature-BIjcuWdB.js","./serializeErc6492Signature-CeJeL3h6.js","./parseEther-C7aOvuze.js","./features-B6BTj_BL.js","./walletconnect-v2-3frQFwbg-CzQk99gS.js","./index-9jNeS_nC.js","./index-BMfMy017.js","./index-BOd8jv8-.js","./toAccount-Bq6rbpbI.js","./index-D6T-s6sR.js","./index-nibyPLVP.js","./wallet-connect-BvJtUsDt-CnvUnFbz.js","./basic-C9wn6QoQ.js","./index-CztIxJB6.js","./dijkstra-COg3n3zL.js","./w3m-modal-Bz5KWTQ-.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import{_ as Oi}from"./preload-helper-PPVm8Dsz.js";import{r as La,s as Rr,I as sr,c as dp,a as H,b as Ss,C as hp,d as pp,e as Jo,f as nr,g as fp,h as gp,i as mp,j as An,k as wp,l as yp,m as ss,n as rr,o as Ba,p as bp,q as Ma,t as ja,u as xr,x as Fa,P as gc,Q as Ep,v as Cp,w as mc,y as dn,z as Ku,A as fs,B as ts,D as ks,E as Gu}from"./walletconnect-v2-3frQFwbg-CzQk99gS.js";import{g as Yu}from"./index-9jNeS_nC.js";import{eN as vp}from"./index-BMfMy017.js";import{ah as Ju,c3 as ni,aG as Ap,aj as ri}from"./http-BocEfKYb.js";import{t as wc}from"./serializeTransaction-L-_Ej-jW.js";import{f as yc}from"./fallback-DiFue5Zm.js";var bc={};const x={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",cosmos:"Cosmos",sui:"Sui",stacks:"Stacks"},ADAPTER_TYPES:{BITCOIN:"bitcoin",SOLANA:"solana",WAGMI:"wagmi",ETHERS:"ethers",ETHERS5:"ethers5"},USDT_CONTRACT_ADDRESSES:["0xdac17f958d2ee523a2206206994597c13d831ec7","0xc2132d05d31c914a87c6611c10748aeb04b58e8f","0x9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7","0x919C1c267BC06a7039e03fcc2eF738525769109c","0x48065fbBE25f71C9282ddf5e1cD6D6A887483D5e","0x55d398326f99059fF775485246999027B3197955","0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9"],SOLANA_SPL_TOKEN_ADDRESSES:{SOL:"So11111111111111111111111111111111111111112"},HTTP_STATUS_CODES:{SERVER_ERROR:500,TOO_MANY_REQUESTS:429,SERVICE_UNAVAILABLE:503,FORBIDDEN:403},UNSUPPORTED_NETWORK_NAME:"Unknown Network",SECURE_SITE_SDK_ORIGIN:(typeof process<"u"&&typeof bc<"u"?bc.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",REMOTE_FEATURES_ALERTS:{MULTI_WALLET_NOT_ENABLED:{DEFAULT:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com."},CONNECTIONS_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnections hook."},CONNECTION_HOOK:{displayMessage:"Multi-Wallet Not Enabled",debugMessage:"Multi-wallet support is not enabled. Please enable it in your AppKit configuration at cloud.reown.com to use the useAppKitConnection hook."}}},IS_DEVELOPMENT:typeof process<"u"&&!1},Xu={caipNetworkIdToNumber(t){return t?Number(t.split(":")[1]):void 0},parseEvmChainId(t){return typeof t=="string"?this.caipNetworkIdToNumber(t):t},getNetworksByNamespace(t,e){return t?.filter(s=>s.chainNamespace===e)||[]},getFirstNetworkByNamespace(t,e){return this.getNetworksByNamespace(t,e)[0]},getNetworkNameByCaipNetworkId(t,e){if(!e)return;const s=t.find(r=>r.caipNetworkId===e);if(s)return s.name;const[n]=e.split(":");return x.CHAIN_NAME_MAP?.[n]||void 0}},Zu=["eip155","solana","polkadot","bip122","cosmos","sui","stacks"];var Ip=20,Np=1,yn=1e6,Ec=1e6,_p=-7,Sp=21,Tp=!1,Vr="[big.js] ",In=Vr+"Invalid ",Ji=In+"decimal places",Op=In+"rounding mode",Qu=Vr+"Division by zero",Ne={},cs=void 0,kp=/^-?(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i;function ed(){function t(e){var s=this;if(!(s instanceof t))return e===cs?ed():new t(e);if(e instanceof t)s.s=e.s,s.e=e.e,s.c=e.c.slice();else{if(typeof e!="string"){if(t.strict===!0&&typeof e!="bigint")throw TypeError(In+"value");e=e===0&&1/e<0?"-0":String(e)}Dp(s,e)}s.constructor=t}return t.prototype=Ne,t.DP=Ip,t.RM=Np,t.NE=_p,t.PE=Sp,t.strict=Tp,t.roundDown=0,t.roundHalfUp=1,t.roundHalfEven=2,t.roundUp=3,t}function Dp(t,e){var s,n,r;if(!kp.test(e))throw Error(In+"number");for(t.s=e.charAt(0)=="-"?(e=e.slice(1),-1):1,(s=e.indexOf("."))>-1&&(e=e.replace(".","")),(n=e.search(/e/i))>0?(s<0&&(s=n),s+=+e.slice(n+1),e=e.substring(0,n)):s<0&&(s=e.length),r=e.length,n=0;n<r&&e.charAt(n)=="0";)++n;if(n==r)t.c=[t.e=0];else{for(;r>0&&e.charAt(--r)=="0";);for(t.e=s-n-1,t.c=[],s=0;n<=r;)t.c[s++]=+e.charAt(n++)}return t}function Nn(t,e,s,n){var r=t.c;if(s===cs&&(s=t.constructor.RM),s!==0&&s!==1&&s!==2&&s!==3)throw Error(Op);if(e<1)n=s===3&&(n||!!r[0])||e===0&&(s===1&&r[0]>=5||s===2&&(r[0]>5||r[0]===5&&(n||r[1]!==cs))),r.length=1,n?(t.e=t.e-e+1,r[0]=1):r[0]=t.e=0;else if(e<r.length){if(n=s===1&&r[e]>=5||s===2&&(r[e]>5||r[e]===5&&(n||r[e+1]!==cs||r[e-1]&1))||s===3&&(n||!!r[0]),r.length=e,n){for(;++r[--e]>9;)if(r[e]=0,e===0){++t.e,r.unshift(1);break}}for(e=r.length;!r[--e];)r.pop()}return t}function _n(t,e,s){var n=t.e,r=t.c.join(""),i=r.length;if(e)r=r.charAt(0)+(i>1?"."+r.slice(1):"")+(n<0?"e":"e+")+n;else if(n<0){for(;++n;)r="0"+r;r="0."+r}else if(n>0)if(++n>i)for(n-=i;n--;)r+="0";else n<i&&(r=r.slice(0,n)+"."+r.slice(n));else i>1&&(r=r.charAt(0)+"."+r.slice(1));return t.s<0&&s?"-"+r:r}Ne.abs=function(){var t=new this.constructor(this);return t.s=1,t};Ne.cmp=function(t){var e,s=this,n=s.c,r=(t=new s.constructor(t)).c,i=s.s,o=t.s,a=s.e,c=t.e;if(!n[0]||!r[0])return n[0]?i:r[0]?-o:0;if(i!=o)return i;if(e=i<0,a!=c)return a>c^e?1:-1;for(o=(a=n.length)<(c=r.length)?a:c,i=-1;++i<o;)if(n[i]!=r[i])return n[i]>r[i]^e?1:-1;return a==c?0:a>c^e?1:-1};Ne.div=function(t){var e=this,s=e.constructor,n=e.c,r=(t=new s(t)).c,i=e.s==t.s?1:-1,o=s.DP;if(o!==~~o||o<0||o>yn)throw Error(Ji);if(!r[0])throw Error(Qu);if(!n[0])return t.s=i,t.c=[t.e=0],t;var a,c,l,u,d,h=r.slice(),m=a=r.length,g=n.length,b=n.slice(0,a),y=b.length,_=t,N=_.c=[],D=0,M=o+(_.e=e.e-t.e)+1;for(_.s=i,i=M<0?0:M,h.unshift(0);y++<a;)b.push(0);do{for(l=0;l<10;l++){if(a!=(y=b.length))u=a>y?1:-1;else for(d=-1,u=0;++d<a;)if(r[d]!=b[d]){u=r[d]>b[d]?1:-1;break}if(u<0){for(c=y==a?r:h;y;){if(b[--y]<c[y]){for(d=y;d&&!b[--d];)b[d]=9;--b[d],b[y]+=10}b[y]-=c[y]}for(;!b[0];)b.shift()}else break}N[D++]=u?l:++l,b[0]&&u?b[y]=n[m]||0:b=[n[m]]}while((m++<g||b[0]!==cs)&&i--);return!N[0]&&D!=1&&(N.shift(),_.e--,M--),D>M&&Nn(_,M,s.RM,b[0]!==cs),_};Ne.eq=function(t){return this.cmp(t)===0};Ne.gt=function(t){return this.cmp(t)>0};Ne.gte=function(t){return this.cmp(t)>-1};Ne.lt=function(t){return this.cmp(t)<0};Ne.lte=function(t){return this.cmp(t)<1};Ne.minus=Ne.sub=function(t){var e,s,n,r,i=this,o=i.constructor,a=i.s,c=(t=new o(t)).s;if(a!=c)return t.s=-c,i.plus(t);var l=i.c.slice(),u=i.e,d=t.c,h=t.e;if(!l[0]||!d[0])return d[0]?t.s=-c:l[0]?t=new o(i):t.s=1,t;if(a=u-h){for((r=a<0)?(a=-a,n=l):(h=u,n=d),n.reverse(),c=a;c--;)n.push(0);n.reverse()}else for(s=((r=l.length<d.length)?l:d).length,a=c=0;c<s;c++)if(l[c]!=d[c]){r=l[c]<d[c];break}if(r&&(n=l,l=d,d=n,t.s=-t.s),(c=(s=d.length)-(e=l.length))>0)for(;c--;)l[e++]=0;for(c=e;s>a;){if(l[--s]<d[s]){for(e=s;e&&!l[--e];)l[e]=9;--l[e],l[s]+=10}l[s]-=d[s]}for(;l[--c]===0;)l.pop();for(;l[0]===0;)l.shift(),--h;return l[0]||(t.s=1,l=[h=0]),t.c=l,t.e=h,t};Ne.mod=function(t){var e,s=this,n=s.constructor,r=s.s,i=(t=new n(t)).s;if(!t.c[0])throw Error(Qu);return s.s=t.s=1,e=t.cmp(s)==1,s.s=r,t.s=i,e?new n(s):(r=n.DP,i=n.RM,n.DP=n.RM=0,s=s.div(t),n.DP=r,n.RM=i,this.minus(s.times(t)))};Ne.neg=function(){var t=new this.constructor(this);return t.s=-t.s,t};Ne.plus=Ne.add=function(t){var e,s,n,r=this,i=r.constructor;if(t=new i(t),r.s!=t.s)return t.s=-t.s,r.minus(t);var o=r.e,a=r.c,c=t.e,l=t.c;if(!a[0]||!l[0])return l[0]||(a[0]?t=new i(r):t.s=r.s),t;if(a=a.slice(),e=o-c){for(e>0?(c=o,n=l):(e=-e,n=a),n.reverse();e--;)n.push(0);n.reverse()}for(a.length-l.length<0&&(n=l,l=a,a=n),e=l.length,s=0;e;a[e]%=10)s=(a[--e]=a[e]+l[e]+s)/10|0;for(s&&(a.unshift(s),++c),e=a.length;a[--e]===0;)a.pop();return t.c=a,t.e=c,t};Ne.pow=function(t){var e=this,s=new e.constructor("1"),n=s,r=t<0;if(t!==~~t||t<-Ec||t>Ec)throw Error(In+"exponent");for(r&&(t=-t);t&1&&(n=n.times(e)),t>>=1,!!t;)e=e.times(e);return r?s.div(n):n};Ne.prec=function(t,e){if(t!==~~t||t<1||t>yn)throw Error(In+"precision");return Nn(new this.constructor(this),t,e)};Ne.round=function(t,e){if(t===cs)t=0;else if(t!==~~t||t<-yn||t>yn)throw Error(Ji);return Nn(new this.constructor(this),t+this.e+1,e)};Ne.sqrt=function(){var t,e,s,n=this,r=n.constructor,i=n.s,o=n.e,a=new r("0.5");if(!n.c[0])return new r(n);if(i<0)throw Error(Vr+"No square root");i=Math.sqrt(+_n(n,!0,!0)),i===0||i===1/0?(e=n.c.join(""),e.length+o&1||(e+="0"),i=Math.sqrt(e),o=((o+1)/2|0)-(o<0||o&1),t=new r((i==1/0?"5e":(i=i.toExponential()).slice(0,i.indexOf("e")+1))+o)):t=new r(i+""),o=t.e+(r.DP+=4);do s=t,t=a.times(s.plus(n.div(s)));while(s.c.slice(0,o).join("")!==t.c.slice(0,o).join(""));return Nn(t,(r.DP-=4)+t.e+1,r.RM)};Ne.times=Ne.mul=function(t){var e,s=this,n=s.constructor,r=s.c,i=(t=new n(t)).c,o=r.length,a=i.length,c=s.e,l=t.e;if(t.s=s.s==t.s?1:-1,!r[0]||!i[0])return t.c=[t.e=0],t;for(t.e=c+l,o<a&&(e=r,r=i,i=e,l=o,o=a,a=l),e=new Array(l=o+a);l--;)e[l]=0;for(c=a;c--;){for(a=0,l=o+c;l>c;)a=e[l]+i[c]*r[l-c-1]+a,e[l--]=a%10,a=a/10|0;e[l]=a}for(a?++t.e:e.shift(),c=e.length;!e[--c];)e.pop();return t.c=e,t};Ne.toExponential=function(t,e){var s=this,n=s.c[0];if(t!==cs){if(t!==~~t||t<0||t>yn)throw Error(Ji);for(s=Nn(new s.constructor(s),++t,e);s.c.length<t;)s.c.push(0)}return _n(s,!0,!!n)};Ne.toFixed=function(t,e){var s=this,n=s.c[0];if(t!==cs){if(t!==~~t||t<0||t>yn)throw Error(Ji);for(s=Nn(new s.constructor(s),t+s.e+1,e),t=t+s.e+1;s.c.length<t;)s.c.push(0)}return _n(s,!1,!!n)};Ne[Symbol.for("nodejs.util.inspect.custom")]=Ne.toJSON=Ne.toString=function(){var t=this,e=t.constructor;return _n(t,t.e<=e.NE||t.e>=e.PE,!!t.c[0])};Ne.toNumber=function(){var t=+_n(this,!0,!0);if(this.constructor.strict===!0&&!this.eq(t.toString()))throw Error(Vr+"Imprecise conversion");return t};Ne.toPrecision=function(t,e){var s=this,n=s.constructor,r=s.c[0];if(t!==cs){if(t!==~~t||t<1||t>yn)throw Error(In+"precision");for(s=Nn(new n(s),t,e);s.c.length<t;)s.c.push(0)}return _n(s,t<=s.e||s.e<=n.NE||s.e>=n.PE,!!r)};Ne.valueOf=function(){var t=this,e=t.constructor;if(e.strict===!0)throw Error(Vr+"valueOf disallowed");return _n(t,t.e<=e.NE||t.e>=e.PE,!0)};var Ds=ed();const Pp={bigNumber(t){return t?new Ds(t):new Ds(0)},multiply(t,e){if(t===void 0||e===void 0)return new Ds(0);const s=new Ds(t),n=new Ds(e);return s.times(n)},toFixed(t,e=2){return t===void 0||t===""?new Ds(0).toFixed(e):new Ds(t).toFixed(e)},formatNumberToLocalString(t,e=2){return t===void 0||t===""?"0.00":typeof t=="number"?t.toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e,roundingMode:"floor"}):parseFloat(t).toLocaleString("en-US",{maximumFractionDigits:e,minimumFractionDigits:e,roundingMode:"floor"})},parseLocalStringToNumber(t){if(t===void 0||t==="")return 0;const e=t.replace(/,/gu,"");return new Ds(e).toNumber()}},Rp=[{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"}]}],xp=[{type:"function",name:"approve",stateMutability:"nonpayable",inputs:[{name:"spender",type:"address"},{name:"amount",type:"uint256"}],outputs:[{type:"bool"}]}],$p=[{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"}]}],Up={getERC20Abi:t=>x.USDT_CONTRACT_ADDRESSES.includes(t)?$p:Rp,getSwapAbi:()=>xp},ot={validateCaipAddress(t){if(t.split(":")?.length!==3)throw new Error("Invalid CAIP Address");return t},parseCaipAddress(t){const e=t.split(":");if(e.length!==3)throw new Error(`Invalid CAIP-10 address: ${t}`);const[s,n,r]=e;if(!s||!n||!r)throw new Error(`Invalid CAIP-10 address: ${t}`);return{chainNamespace:s,chainId:n,address:r}},parseCaipNetworkId(t){const e=t.split(":");if(e.length!==2)throw new Error(`Invalid CAIP-2 network id: ${t}`);const[s,n]=e;if(!s||!n)throw new Error(`Invalid CAIP-2 network id: ${t}`);return{chainNamespace:s,chainId:n}}},Ks={RPC_ERROR_CODE:{USER_REJECTED_REQUEST:4001},PROVIDER_RPC_ERROR_NAME:{PROVIDER_RPC:"ProviderRpcError",USER_REJECTED_REQUEST:"UserRejectedRequestError"},isRpcProviderError(t){try{if(typeof t=="object"&&t!==null){const e=t,s=typeof e.message=="string",n=typeof e.code=="number";return s&&n}return!1}catch{return!1}},isUserRejectedMessage(t){return t.toLowerCase().includes("user rejected")||t.toLowerCase().includes("user cancelled")||t.toLowerCase().includes("user canceled")},isUserRejectedRequestError(t){return Ks.isRpcProviderError(t)?t.code===Ks.RPC_ERROR_CODE.USER_REJECTED_REQUEST||Ks.isUserRejectedMessage(t.message):t instanceof Error?Ks.isUserRejectedMessage(t.message):!1}};class Lp extends Error{constructor(e,s){super(s.message,{cause:e}),this.name=Ks.PROVIDER_RPC_ERROR_NAME.PROVIDER_RPC,this.code=s.code}}class td extends Lp{constructor(e){super(e,{code:Ks.RPC_ERROR_CODE.USER_REJECTED_REQUEST,message:"User rejected the request"}),this.name=Ks.PROVIDER_RPC_ERROR_NAME.USER_REJECTED_REQUEST}}const ee={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",RECENT_WALLET:"@appkit/recent_wallet",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",PREFERRED_ACCOUNT_TYPES:"@appkit/preferred_account_types",CONNECTIONS:"@appkit/connections",DISCONNECTED_CONNECTOR_IDS:"@appkit/disconnected_connector_ids",HISTORY_TRANSACTIONS_CACHE:"@appkit/history_transactions_cache",TOKEN_PRICE_CACHE:"@appkit/token_price_cache",RECENT_EMAILS:"@appkit/recent_emails",LATEST_APPKIT_VERSION:"@appkit/latest_version"};function po(t){if(!t)throw new Error("Namespace is required for CONNECTED_CONNECTOR_ID");return`@appkit/${t}:connected_connector_id`}const Z={setItem(t,e){Er()&&e!==void 0&&localStorage.setItem(t,e)},getItem(t){if(Er())return localStorage.getItem(t)||void 0},removeItem(t){Er()&&localStorage.removeItem(t)},clear(){Er()&&localStorage.clear()}};function Er(){return typeof window<"u"&&typeof localStorage<"u"}function ki(t,e){return e==="light"?{"--w3m-accent":t?.["--w3m-accent"]||"hsla(231, 100%, 70%, 1)","--w3m-background":"#fff"}:{"--w3m-accent":t?.["--w3m-accent"]||"hsla(230, 100%, 67%, 1)","--w3m-background":"#202020"}}const Bp=Symbol(),Cc=Object.getPrototypeOf,Xo=new WeakMap,Mp=t=>t&&(Xo.has(t)?Xo.get(t):Cc(t)===Object.prototype||Cc(t)===Array.prototype),jp=t=>Mp(t)&&t[Bp]||null,vc=(t,e=!0)=>{Xo.set(t,e)},Di={},qa=t=>typeof t=="object"&&t!==null,Fp=t=>qa(t)&&!zr.has(t)&&(Array.isArray(t)||!(Symbol.iterator in t))&&!(t instanceof WeakMap)&&!(t instanceof WeakSet)&&!(t instanceof Error)&&!(t instanceof Number)&&!(t instanceof Date)&&!(t instanceof String)&&!(t instanceof RegExp)&&!(t instanceof ArrayBuffer)&&!(t instanceof Promise),sd=(t,e)=>{const s=Zo.get(t);if(s?.[0]===e)return s[1];const n=Array.isArray(t)?[]:Object.create(Object.getPrototypeOf(t));return vc(n,!0),Zo.set(t,[e,n]),Reflect.ownKeys(t).forEach(r=>{if(Object.getOwnPropertyDescriptor(n,r))return;const i=Reflect.get(t,r),{enumerable:o}=Reflect.getOwnPropertyDescriptor(t,r),a={value:i,enumerable:o,configurable:!0};if(zr.has(i))vc(i,!1);else if(Ys.has(i)){const[c,l]=Ys.get(i);a.value=sd(c,l())}Object.defineProperty(n,r,a)}),Object.preventExtensions(n)},qp=(t,e,s,n)=>({deleteProperty(r,i){const o=Reflect.get(r,i);s(i);const a=Reflect.deleteProperty(r,i);return a&&n(["delete",[i],o]),a},set(r,i,o,a){const c=!t()&&Reflect.has(r,i),l=Reflect.get(r,i,a);if(c&&(Ac(l,o)||$r.has(o)&&Ac(l,$r.get(o))))return!0;s(i),qa(o)&&(o=jp(o)||o);const u=!Ys.has(o)&&Vp(o)?ke(o):o;return e(i,u),Reflect.set(r,i,u,a),n(["set",[i],o,l]),!0}}),Ys=new WeakMap,zr=new WeakSet,Zo=new WeakMap,bi=[1],$r=new WeakMap;let Ac=Object.is,Wp=(t,e)=>new Proxy(t,e),Vp=Fp,zp=sd,Hp=qp;function ke(t={}){if(!qa(t))throw new Error("object required");const e=$r.get(t);if(e)return e;let s=bi[0];const n=new Set,r=(y,_=++bi[0])=>{s!==_&&(i=s=_,n.forEach(N=>N(y,_)))};let i=s;const o=(y=bi[0])=>(i!==y&&(i=y,c.forEach(([_])=>{const N=_[1](y);N>s&&(s=N)})),s),a=y=>(_,N)=>{const D=[..._];D[1]=[y,...D[1]],r(D,N)},c=new Map,l=(y,_)=>{const N=!zr.has(_)&&Ys.get(_);if(N){if((Di?"production":void 0)!=="production"&&c.has(y))throw new Error("prop listener already exists");if(n.size){const D=N[2](a(y));c.set(y,[N,D])}else c.set(y,[N])}},u=y=>{var _;const N=c.get(y);N&&(c.delete(y),(_=N[1])==null||_.call(N))},d=y=>(n.add(y),n.size===1&&c.forEach(([N,D],M)=>{if((Di?"production":void 0)!=="production"&&D)throw new Error("remove already exists");const q=N[2](a(M));c.set(M,[N,q])}),()=>{n.delete(y),n.size===0&&c.forEach(([N,D],M)=>{D&&(D(),c.set(M,[N]))})});let h=!0;const m=Hp(()=>h,l,u,r),g=Wp(t,m);$r.set(t,g);const b=[t,o,d];return Ys.set(g,b),Reflect.ownKeys(t).forEach(y=>{const _=Object.getOwnPropertyDescriptor(t,y);"value"in _&&_.writable&&(g[y]=t[y])}),h=!1,g}function Je(t,e,s){const n=Ys.get(t);(Di?"production":void 0)!=="production"&&!n&&console.warn("Please use proxy object");let r;const i=[],o=n[2];let a=!1;const l=o(u=>{i.push(u),r||(r=Promise.resolve().then(()=>{r=void 0,a&&e(i.splice(0))}))});return a=!0,()=>{a=!1,l()}}function Ur(t){const e=Ys.get(t);(Di?"production":void 0)!=="production"&&!e&&console.warn("Please use proxy object");const[s,n]=e;return zp(s,n())}function Xn(t){return zr.add(t),t}function Kp(){return{proxyStateMap:Ys,refSet:zr,snapCache:Zo,versionHolder:bi,proxyCache:$r}}function Xe(t,e,s,n){let r=t[e];return Je(t,()=>{const i=t[e];Object.is(r,i)||s(r=i)})}const{proxyStateMap:Gp,snapCache:Yp}=Kp(),ii=t=>Gp.has(t);function Jp(t){const e=[];let s=0;const n=new Map,r=new WeakMap,i=()=>{const l=Yp.get(a),u=l?.[1];if(u&&!r.has(u)){const d=new Map(n);r.set(u,d)}},o=l=>r.get(l)||n,a={data:e,index:s,epoch:0,get size(){return ii(this)||i(),o(this).size},get(l){const d=o(this).get(l);if(d===void 0){this.epoch;return}return this.data[d]},has(l){const u=o(this);return this.epoch,u.has(l)},set(l,u){if(!ii(this))throw new Error("Cannot perform mutations on a snapshot");const d=n.get(l);return d===void 0?(n.set(l,this.index),this.data[this.index++]=u):this.data[d]=u,this.epoch++,this},delete(l){if(!ii(this))throw new Error("Cannot perform mutations on a snapshot");const u=n.get(l);return u===void 0?!1:(delete this.data[u],n.delete(l),this.epoch++,!0)},clear(){if(!ii(this))throw new Error("Cannot perform mutations on a snapshot");this.data.length=0,this.index=0,this.epoch++,n.clear()},forEach(l){this.epoch,o(this).forEach((d,h)=>{l(this.data[d],h,this)})},*entries(){this.epoch;const l=o(this);for(const[u,d]of l)yield[u,this.data[d]]},*keys(){this.epoch;const l=o(this);for(const u of l.keys())yield u},*values(){this.epoch;const l=o(this);for(const u of l.values())yield this.data[u]},[Symbol.iterator](){return this.entries()},get[Symbol.toStringTag](){return"Map"},toJSON(){return new Map(this.entries())}},c=ke(a);return Object.defineProperties(c,{size:{enumerable:!1},index:{enumerable:!1},epoch:{enumerable:!1},data:{enumerable:!1},toJSON:{enumerable:!1}}),Object.seal(c),c}var Ic={};const fo=(typeof process<"u"&&typeof Ic<"u"?Ic.NEXT_PUBLIC_SECURE_SITE_ORIGIN:void 0)||"https://secure.walletconnect.org",nd=[{label:"Meld.io",name:"meld",feeRange:"1-2%",url:"https://meldcrypto.com",supportedChains:["eip155","solana"]}],Xp="WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU",me={FOUR_MINUTES_MS:24e4,TEN_SEC_MS:1e4,FIVE_SEC_MS:5e3,THREE_SEC_MS:3e3,ONE_SEC_MS:1e3,SECURE_SITE:fo,SECURE_SITE_DASHBOARD:`${fo}/dashboard`,SECURE_SITE_FAVICON:`${fo}/images/favicon.png`,SOLANA_NATIVE_TOKEN_ADDRESS:"So11111111111111111111111111111111111111111",RESTRICTED_TIMEZONES:["ASIA/SHANGHAI","ASIA/URUMQI","ASIA/CHONGQING","ASIA/HARBIN","ASIA/KASHGAR","ASIA/MACAU","ASIA/HONG_KONG","ASIA/MACAO","ASIA/BEIJING","ASIA/HARBIN"],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:[x.CHAIN.EVM,x.CHAIN.SOLANA],SEND_PARAMS_SUPPORTED_CHAINS:[x.CHAIN.EVM],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:[x.CHAIN.EVM],ONRAMP_SUPPORTED_CHAIN_NAMESPACES:[x.CHAIN.EVM,x.CHAIN.SOLANA],PAY_WITH_EXCHANGE_SUPPORTED_CHAIN_NAMESPACES:[x.CHAIN.EVM,x.CHAIN.SOLANA],ACTIVITY_ENABLED_CHAIN_NAMESPACES:[x.CHAIN.EVM],NATIVE_TOKEN_ADDRESS:{eip155:"0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee",solana:"So11111111111111111111111111111111111111111",polkadot:"0x",bip122:"0x",cosmos:"0x",sui:"0x",stacks:"0x"},CONVERT_SLIPPAGE_TOLERANCE:1,CONNECT_LABELS:{MOBILE:"Open and continue in the wallet app",WEB:"Open and continue in the wallet app"},SEND_SUPPORTED_NAMESPACES:[x.CHAIN.EVM,x.CHAIN.SOLANA],DEFAULT_REMOTE_FEATURES:{swaps:["1inch"],onramp:["meld"],email:!0,socials:["google","x","discord","farcaster","github","apple","facebook"],activity:!0,reownBranding:!0,multiWallet:!1,emailCapture:!1,payWithExchange:!1,payments:!1,reownAuthentication:!1},DEFAULT_REMOTE_FEATURES_DISABLED:{email:!1,socials:!1,swaps:!1,onramp:!1,activity:!1,reownBranding:!1,emailCapture:!1,reownAuthentication:!1},DEFAULT_FEATURES:{receive:!0,send:!0,emailShowWallets:!0,connectorTypeOrder:["walletConnect","recent","injected","featured","custom","external","recommended"],analytics:!0,allWallets:!0,legalCheckbox:!1,smartSessions:!1,collapseWallets:!1,walletFeaturesOrder:["onramp","swaps","receive","send"],connectMethodsOrder:void 0,pay:!1,reownAuthentication:!1},DEFAULT_SOCIALS:["google","x","farcaster","discord","apple","github","facebook"],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"},SIWX_DEFAULTS:{signOutOnDisconnect:!0}},B={cacheExpiry:{portfolio:3e4,nativeBalance:3e4,ens:3e5,identity:3e5,transactionsHistory:15e3,tokenPrice:15e3,latestAppKitVersion:6048e5},isCacheExpired(t,e){return Date.now()-t>e},getActiveNetworkProps(){const t=B.getActiveNamespace(),e=B.getActiveCaipNetworkId(),s=e?e.split(":")[1]:void 0,n=s?isNaN(Number(s))?s:Number(s):void 0;return{namespace:t,caipNetworkId:e,chainId:n}},setWalletConnectDeepLink({name:t,href:e}){try{Z.setItem(ee.DEEPLINK_CHOICE,JSON.stringify({href:e,name:t}))}catch{console.info("Unable to set WalletConnect deep link")}},getWalletConnectDeepLink(){try{const t=Z.getItem(ee.DEEPLINK_CHOICE);if(t)return JSON.parse(t)}catch{console.info("Unable to get WalletConnect deep link")}},deleteWalletConnectDeepLink(){try{Z.removeItem(ee.DEEPLINK_CHOICE)}catch{console.info("Unable to delete WalletConnect deep link")}},setActiveNamespace(t){try{Z.setItem(ee.ACTIVE_NAMESPACE,t)}catch{console.info("Unable to set active namespace")}},setActiveCaipNetworkId(t){try{Z.setItem(ee.ACTIVE_CAIP_NETWORK_ID,t),B.setActiveNamespace(t.split(":")[0])}catch{console.info("Unable to set active caip network id")}},getActiveCaipNetworkId(){try{return Z.getItem(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to get active caip network id");return}},deleteActiveCaipNetworkId(){try{Z.removeItem(ee.ACTIVE_CAIP_NETWORK_ID)}catch{console.info("Unable to delete active caip network id")}},deleteConnectedConnectorId(t){try{const e=po(t);Z.removeItem(e)}catch{console.info("Unable to delete connected connector id")}},setAppKitRecent(t){try{const e=B.getRecentWallets();e.find(n=>n.id===t.id)||(e.unshift(t),e.length>2&&e.pop(),Z.setItem(ee.RECENT_WALLETS,JSON.stringify(e)),Z.setItem(ee.RECENT_WALLET,JSON.stringify(t)))}catch{console.info("Unable to set AppKit recent")}},getRecentWallets(){try{const t=Z.getItem(ee.RECENT_WALLETS);return t?JSON.parse(t):[]}catch{console.info("Unable to get AppKit recent")}return[]},getRecentWallet(){try{const t=Z.getItem(ee.RECENT_WALLET);return t?JSON.parse(t):null}catch{console.info("Unable to get AppKit recent")}return null},deleteRecentWallet(){try{Z.removeItem(ee.RECENT_WALLET)}catch{console.info("Unable to delete AppKit recent")}},setConnectedConnectorId(t,e){try{const s=po(t);Z.setItem(s,e)}catch{console.info("Unable to set Connected Connector Id")}},getActiveNamespace(){try{return Z.getItem(ee.ACTIVE_NAMESPACE)}catch{console.info("Unable to get active namespace")}},getConnectedConnectorId(t){if(t)try{const e=po(t);return Z.getItem(e)}catch{console.info("Unable to get connected connector id in namespace",t)}},setConnectedSocialProvider(t){try{Z.setItem(ee.CONNECTED_SOCIAL,t)}catch{console.info("Unable to set connected social provider")}},getConnectedSocialProvider(){try{return Z.getItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to get connected social provider")}},deleteConnectedSocialProvider(){try{Z.removeItem(ee.CONNECTED_SOCIAL)}catch{console.info("Unable to delete connected social provider")}},getConnectedSocialUsername(){try{return Z.getItem(ee.CONNECTED_SOCIAL_USERNAME)}catch{console.info("Unable to get connected social username")}},getStoredActiveCaipNetworkId(){return Z.getItem(ee.ACTIVE_CAIP_NETWORK_ID)?.split(":")?.[1]},setConnectionStatus(t){try{Z.setItem(ee.CONNECTION_STATUS,t)}catch{console.info("Unable to set connection status")}},getConnectionStatus(){try{return Z.getItem(ee.CONNECTION_STATUS)}catch{return}},getConnectedNamespaces(){try{const t=Z.getItem(ee.CONNECTED_NAMESPACES);return t?.length?t.split(","):[]}catch{return[]}},setConnectedNamespaces(t){try{const e=Array.from(new Set(t));Z.setItem(ee.CONNECTED_NAMESPACES,e.join(","))}catch{console.info("Unable to set namespaces in storage")}},addConnectedNamespace(t){try{const e=B.getConnectedNamespaces();e.includes(t)||(e.push(t),B.setConnectedNamespaces(e))}catch{console.info("Unable to add connected namespace")}},removeConnectedNamespace(t){try{const e=B.getConnectedNamespaces(),s=e.indexOf(t);s>-1&&(e.splice(s,1),B.setConnectedNamespaces(e))}catch{console.info("Unable to remove connected namespace")}},getTelegramSocialProvider(){try{return Z.getItem(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{return console.info("Unable to get telegram social provider"),null}},setTelegramSocialProvider(t){try{Z.setItem(ee.TELEGRAM_SOCIAL_PROVIDER,t)}catch{console.info("Unable to set telegram social provider")}},removeTelegramSocialProvider(){try{Z.removeItem(ee.TELEGRAM_SOCIAL_PROVIDER)}catch{console.info("Unable to remove telegram social provider")}},getBalanceCache(){let t={};try{const e=Z.getItem(ee.PORTFOLIO_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromBalanceCache(t){try{const e=B.getBalanceCache();Z.setItem(ee.PORTFOLIO_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getBalanceCacheForCaipAddress(t){try{const s=B.getBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.portfolio))return s.balance;B.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateBalanceCache(t){try{const e=B.getBalanceCache();e[t.caipAddress]=t,Z.setItem(ee.PORTFOLIO_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getNativeBalanceCache(){let t={};try{const e=Z.getItem(ee.NATIVE_BALANCE_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get balance cache")}return t},removeAddressFromNativeBalanceCache(t){try{const e=B.getBalanceCache();Z.setItem(ee.NATIVE_BALANCE_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove address from balance cache",t)}},getNativeBalanceCacheForCaipAddress(t){try{const s=B.getNativeBalanceCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.nativeBalance))return s;console.info("Discarding cache for address",t),B.removeAddressFromBalanceCache(t)}catch{console.info("Unable to get balance cache for address",t)}},updateNativeBalanceCache(t){try{const e=B.getNativeBalanceCache();e[t.caipAddress]=t,Z.setItem(ee.NATIVE_BALANCE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update balance cache",t)}},getEnsCache(){let t={};try{const e=Z.getItem(ee.ENS_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get ens name cache")}return t},getEnsFromCacheForAddress(t){try{const s=B.getEnsCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.ens))return s.ens;B.removeEnsFromCache(t)}catch{console.info("Unable to get ens name from cache",t)}},updateEnsCache(t){try{const e=B.getEnsCache();e[t.address]=t,Z.setItem(ee.ENS_CACHE,JSON.stringify(e))}catch{console.info("Unable to update ens name cache",t)}},removeEnsFromCache(t){try{const e=B.getEnsCache();Z.setItem(ee.ENS_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove ens name from cache",t)}},getIdentityCache(){let t={};try{const e=Z.getItem(ee.IDENTITY_CACHE);t=e?JSON.parse(e):{}}catch{console.info("Unable to get identity cache")}return t},getIdentityFromCacheForAddress(t){try{const s=B.getIdentityCache()[t];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.identity))return s.identity;B.removeIdentityFromCache(t)}catch{console.info("Unable to get identity from cache",t)}},updateIdentityCache(t){try{const e=B.getIdentityCache();e[t.address]={identity:t.identity,timestamp:t.timestamp},Z.setItem(ee.IDENTITY_CACHE,JSON.stringify(e))}catch{console.info("Unable to update identity cache",t)}},removeIdentityFromCache(t){try{const e=B.getIdentityCache();Z.setItem(ee.IDENTITY_CACHE,JSON.stringify({...e,[t]:void 0}))}catch{console.info("Unable to remove identity from cache",t)}},clearAddressCache(){try{Z.removeItem(ee.PORTFOLIO_CACHE),Z.removeItem(ee.NATIVE_BALANCE_CACHE),Z.removeItem(ee.ENS_CACHE),Z.removeItem(ee.IDENTITY_CACHE),Z.removeItem(ee.HISTORY_TRANSACTIONS_CACHE)}catch{console.info("Unable to clear address cache")}},setPreferredAccountTypes(t){try{Z.setItem(ee.PREFERRED_ACCOUNT_TYPES,JSON.stringify(t))}catch{console.info("Unable to set preferred account types",t)}},getPreferredAccountTypes(){try{const t=Z.getItem(ee.PREFERRED_ACCOUNT_TYPES);return t?JSON.parse(t):{}}catch{console.info("Unable to get preferred account types")}return{}},setConnections(t,e){try{const s=B.getConnections(),n=s[e]??[],r=new Map;for(const o of n)r.set(o.connectorId,{...o});for(const o of t){const a=r.get(o.connectorId),c=o.connectorId===x.CONNECTOR_ID.AUTH;if(a&&!c){const l=new Set(a.accounts.map(d=>d.address.toLowerCase())),u=o.accounts.filter(d=>!l.has(d.address.toLowerCase()));a.accounts.push(...u)}else r.set(o.connectorId,{...o})}const i={...s,[e]:Array.from(r.values())};Z.setItem(ee.CONNECTIONS,JSON.stringify(i))}catch(s){console.error("Unable to sync connections to storage",s)}},getConnections(){try{const t=Z.getItem(ee.CONNECTIONS);return t?JSON.parse(t):{}}catch(t){return console.error("Unable to get connections from storage",t),{}}},deleteAddressFromConnection({connectorId:t,address:e,namespace:s}){try{const n=B.getConnections(),r=n[s]??[],i=new Map(r.map(a=>[a.connectorId,a])),o=i.get(t);o&&(o.accounts.filter(c=>c.address.toLowerCase()!==e.toLowerCase()).length===0?i.delete(t):i.set(t,{...o,accounts:o.accounts.filter(c=>c.address.toLowerCase()!==e.toLowerCase())})),Z.setItem(ee.CONNECTIONS,JSON.stringify({...n,[s]:Array.from(i.values())}))}catch{console.error(`Unable to remove address "${e}" from connector "${t}" in namespace "${s}"`)}},getDisconnectedConnectorIds(){try{const t=Z.getItem(ee.DISCONNECTED_CONNECTOR_IDS);return t?JSON.parse(t):{}}catch{console.info("Unable to get disconnected connector ids")}return{}},addDisconnectedConnectorId(t,e){try{const s=B.getDisconnectedConnectorIds(),n=s[e]??[];n.push(t),Z.setItem(ee.DISCONNECTED_CONNECTOR_IDS,JSON.stringify({...s,[e]:Array.from(new Set(n))}))}catch{console.error(`Unable to set disconnected connector id "${t}" for namespace "${e}"`)}},removeDisconnectedConnectorId(t,e){try{const s=B.getDisconnectedConnectorIds();let n=s[e]??[];n=n.filter(r=>r.toLowerCase()!==t.toLowerCase()),Z.setItem(ee.DISCONNECTED_CONNECTOR_IDS,JSON.stringify({...s,[e]:Array.from(new Set(n))}))}catch{console.error(`Unable to remove disconnected connector id "${t}" for namespace "${e}"`)}},isConnectorDisconnected(t,e){try{return(B.getDisconnectedConnectorIds()[e]??[]).some(r=>r.toLowerCase()===t.toLowerCase())}catch{console.info(`Unable to get disconnected connector id "${t}" for namespace "${e}"`)}return!1},getTransactionsCache(){try{const t=Z.getItem(ee.HISTORY_TRANSACTIONS_CACHE);return t?JSON.parse(t):{}}catch{console.info("Unable to get transactions cache")}return{}},getTransactionsCacheForAddress({address:t,chainId:e=""}){try{const n=B.getTransactionsCache()[t]?.[e];if(n&&!this.isCacheExpired(n.timestamp,this.cacheExpiry.transactionsHistory))return n.transactions;B.removeTransactionsCache({address:t,chainId:e})}catch{console.info("Unable to get transactions cache")}},updateTransactionsCache({address:t,chainId:e="",timestamp:s,transactions:n}){try{const r=B.getTransactionsCache();r[t]={...r[t],[e]:{timestamp:s,transactions:n}},Z.setItem(ee.HISTORY_TRANSACTIONS_CACHE,JSON.stringify(r))}catch{console.info("Unable to update transactions cache",{address:t,chainId:e,timestamp:s,transactions:n})}},removeTransactionsCache({address:t,chainId:e}){try{const s=B.getTransactionsCache(),n=s?.[t]||{},{[e]:r,...i}=n;Z.setItem(ee.HISTORY_TRANSACTIONS_CACHE,JSON.stringify({...s,[t]:i}))}catch{console.info("Unable to remove transactions cache",{address:t,chainId:e})}},getTokenPriceCache(){try{const t=Z.getItem(ee.TOKEN_PRICE_CACHE);return t?JSON.parse(t):{}}catch{console.info("Unable to get token price cache")}return{}},getTokenPriceCacheForAddresses(t){try{const s=B.getTokenPriceCache()[t.join(",")];if(s&&!this.isCacheExpired(s.timestamp,this.cacheExpiry.tokenPrice))return s.tokenPrice;B.removeTokenPriceCache(t)}catch{console.info("Unable to get token price cache for addresses",t)}},updateTokenPriceCache(t){try{const e=B.getTokenPriceCache();e[t.addresses.join(",")]={timestamp:t.timestamp,tokenPrice:t.tokenPrice},Z.setItem(ee.TOKEN_PRICE_CACHE,JSON.stringify(e))}catch{console.info("Unable to update token price cache",t)}},removeTokenPriceCache(t){try{const e=B.getTokenPriceCache();Z.setItem(ee.TOKEN_PRICE_CACHE,JSON.stringify({...e,[t.join(",")]:void 0}))}catch{console.info("Unable to remove token price cache",t)}},getLatestAppKitVersion(){try{const t=this.getLatestAppKitVersionCache(),e=t?.version;return e&&!this.isCacheExpired(t.timestamp,this.cacheExpiry.latestAppKitVersion)?e:void 0}catch{console.info("Unable to get latest AppKit version")}},getLatestAppKitVersionCache(){try{const t=Z.getItem(ee.LATEST_APPKIT_VERSION);return t?JSON.parse(t):{}}catch{console.info("Unable to get latest AppKit version cache")}return{}},updateLatestAppKitVersion(t){try{const e=B.getLatestAppKitVersionCache();e.timestamp=t.timestamp,e.version=t.version,Z.setItem(ee.LATEST_APPKIT_VERSION,JSON.stringify(e))}catch{console.info("Unable to update latest AppKit version on local storage",t)}}},J={isMobile(){return this.isClient()?!!(window?.matchMedia&&typeof window.matchMedia=="function"&&window.matchMedia("(pointer:coarse)")?.matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1},checkCaipNetwork(t,e=""){return t?.caipNetworkId.toLocaleLowerCase().includes(e.toLowerCase())},isAndroid(){if(!this.isMobile())return!1;const t=window?.navigator.userAgent.toLowerCase();return J.isMobile()&&t.includes("android")},isIos(){if(!this.isMobile())return!1;const t=window?.navigator.userAgent.toLowerCase();return t.includes("iphone")||t.includes("ipad")},isSafari(){return this.isClient()?(window?.navigator.userAgent.toLowerCase()).includes("safari"):!1},isClient(){return typeof window<"u"},isPairingExpired(t){return t?t-Date.now()<=me.TEN_SEC_MS:!0},isAllowedRetry(t,e=me.ONE_SEC_MS){return Date.now()-t>=e},copyToClopboard(t){navigator.clipboard.writeText(t)},isIframe(){try{return window?.self!==window?.top}catch{return!1}},isSafeApp(){if(J.isClient()&&window.self!==window.top)try{const t=window?.location?.ancestorOrigins?.[0],e="https://app.safe.global";if(t){const s=new URL(t),n=new URL(e);return s.hostname===n.hostname}}catch{return!1}return!1},getPairingExpiry(){return Date.now()+me.FOUR_MINUTES_MS},getNetworkId(t){return t?.split(":")[1]},getPlainAddress(t){return t?.split(":")[2]},async wait(t){return new Promise(e=>{setTimeout(e,t)})},debounce(t,e=500){let s;return(...n)=>{function r(){t(...n)}s&&clearTimeout(s),s=setTimeout(r,e)}},isHttpUrl(t){return t.startsWith("http://")||t.startsWith("https://")},formatNativeUrl(t,e,s=null){if(J.isHttpUrl(t))return this.formatUniversalUrl(t,e);let n=t,r=s;n&&(n.includes("://")||(n=t.replaceAll("/","").replaceAll(":",""),n=`${n}://`),n.endsWith("/")||(n=`${n}/`)),r&&!r?.endsWith("/")&&(r=`${r}/`),this.isTelegram()&&this.isAndroid()&&(e=encodeURIComponent(e));const i=encodeURIComponent(e);return{redirect:`${n}wc?uri=${i}`,redirectUniversalLink:r?`${r}wc?uri=${i}`:void 0,href:n}},formatUniversalUrl(t,e){if(!J.isHttpUrl(t))return this.formatNativeUrl(t,e);let s=t;s.endsWith("/")||(s=`${s}/`);const n=encodeURIComponent(e);return{redirect:`${s}wc?uri=${n}`,href:s}},getOpenTargetForPlatform(t){return t==="popupWindow"?t:this.isTelegram()?B.getTelegramSocialProvider()?"_top":"_blank":t},openHref(t,e,s){window?.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},returnOpenHref(t,e,s){return window?.open(t,this.getOpenTargetForPlatform(e),s||"noreferrer noopener")},isTelegram(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)},isPWA(){if(typeof window>"u")return!1;const t=window?.matchMedia&&typeof window.matchMedia=="function"?window.matchMedia("(display-mode: standalone)")?.matches:!1,e=window?.navigator?.standalone;return!!(t||e)},async preloadImage(t){const e=new Promise((s,n)=>{const r=new Image;r.onload=s,r.onerror=n,r.crossOrigin="anonymous",r.src=t});return Promise.race([e,J.wait(2e3)])},parseBalance(t,e){let s="0.000";if(typeof t=="string"){const c=Number(t);if(!isNaN(c)){const l=(Math.floor(c*1e3)/1e3).toFixed(3);l&&(s=l)}}const[n,r]=s.split("."),i=n||"0",o=r||"000";return{formattedText:`${i}.${o}${e?` ${e}`:""}`,value:i,decimals:o,symbol:e}},getApiUrl(){return x.W3M_API_URL},getBlockchainApiUrl(){return x.BLOCKCHAIN_API_RPC_URL},getAnalyticsUrl(){return x.PULSE_API_URL},getUUID(){return crypto?.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})},parseError(t){return typeof t=="string"?t:typeof t?.issues?.[0]?.message=="string"?t.issues[0].message:t instanceof Error?t.message:"Unknown error"},sortRequestedNetworks(t,e=[]){const s={};return e&&t&&(t.forEach((n,r)=>{s[n]=r}),e.sort((n,r)=>{const i=s[n.id],o=s[r.id];return i!==void 0&&o!==void 0?i-o:i!==void 0?-1:o!==void 0?1:0})),e},calculateBalance(t){let e=0;for(const s of t)e+=s.value??0;return e},formatTokenBalance(t){const e=t.toFixed(2),[s,n]=e.split(".");return{dollars:s,pennies:n}},isAddress(t,e="eip155"){switch(e){case"eip155":if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)){if(/^(?:0x)?[0-9a-f]{40}$/iu.test(t)||/^(?:0x)?[0-9A-F]{40}$/iu.test(t))return!0}else return!1;return!1;case"solana":return/[1-9A-HJ-NP-Za-km-z]{32,44}$/iu.test(t);default:return!1}},uniqueBy(t,e){const s=new Set;return t.filter(n=>{const r=n[e];return s.has(r)?!1:(s.add(r),!0)})},generateSdkVersion(t,e,s){const r=t.length===0?me.ADAPTER_TYPES.UNIVERSAL:t.map(i=>i.adapterType).join(",");return`${e}-${r}-${s}`},createAccount(t,e,s,n,r){return{namespace:t,address:e,type:s,publicKey:n,path:r}},isCaipAddress(t){if(typeof t!="string")return!1;const e=t.split(":"),s=e[0];return e.filter(Boolean).length===3&&s in x.CHAIN_NAME_MAP},getAccount(t){return t?typeof t=="string"?{address:t,chainId:void 0}:{address:t.address,chainId:t.chainId}:{address:void 0,chainId:void 0}},isMac(){const t=window?.navigator.userAgent.toLowerCase();return t.includes("macintosh")&&!t.includes("safari")},formatTelegramSocialLoginUrl(t){const e=`--${encodeURIComponent(window?.location.href)}`,s="state=";if(new URL(t).host==="auth.magic.link"){const r="provider_authorization_url=",i=t.substring(t.indexOf(r)+r.length),o=this.injectIntoUrl(decodeURIComponent(i),s,e);return t.replace(i,encodeURIComponent(o))}return this.injectIntoUrl(t,s,e)},injectIntoUrl(t,e,s){const n=t.indexOf(e);if(n===-1)throw new Error(`${e} parameter not found in the URL: ${t}`);const r=t.indexOf("&",n),i=e.length,o=r!==-1?r:t.length,a=t.substring(0,n+i),c=t.substring(n+i,o),l=t.substring(r),u=c+s;return a+u+l}};async function cr(...t){const e=await fetch(...t);if(!e.ok)throw new Error(`HTTP status code: ${e.status}`,{cause:e});return e}class Hr{constructor({baseUrl:e,clientId:s}){this.baseUrl=e,this.clientId=s}async get({headers:e,signal:s,cache:n,...r}){const i=this.createUrl(r);return(await cr(i,{method:"GET",headers:e,signal:s,cache:n})).json()}async getBlob({headers:e,signal:s,...n}){const r=this.createUrl(n);return(await cr(r,{method:"GET",headers:e,signal:s})).blob()}async post({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await cr(i,{method:"POST",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}async put({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await cr(i,{method:"PUT",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}async delete({body:e,headers:s,signal:n,...r}){const i=this.createUrl(r);return(await cr(i,{method:"DELETE",headers:s,body:e?JSON.stringify(e):void 0,signal:n})).json()}createUrl({path:e,params:s}){const n=new URL(e,this.baseUrl);return s&&Object.entries(s).forEach(([r,i])=>{i&&n.searchParams.append(r,i)}),this.clientId&&n.searchParams.append("clientId",this.clientId),n}sendBeacon({body:e,...s}){const n=this.createUrl(s);return navigator.sendBeacon(n.toString(),e?JSON.stringify(e):void 0)}}const Qo={getFeatureValue(t,e){const s=e?.[t];return s===void 0?me.DEFAULT_FEATURES[t]:s},filterSocialsByPlatform(t){if(!t||!t.length)return t;if(J.isTelegram()){if(J.isIos())return t.filter(e=>e!=="google");if(J.isMac())return t.filter(e=>e!=="x");if(J.isAndroid())return t.filter(e=>!["facebook","x"].includes(e))}return t},isSocialsEnabled(){return Array.isArray(R.state.features?.socials)&&R.state.features?.socials.length>0||Array.isArray(R.state.remoteFeatures?.socials)&&R.state.remoteFeatures?.socials.length>0},isEmailEnabled(){return!!(R.state.features?.email||R.state.remoteFeatures?.email)}},Q=ke({features:me.DEFAULT_FEATURES,projectId:"",sdkType:"appkit",sdkVersion:"html-wagmi-undefined",defaultAccountTypes:me.DEFAULT_ACCOUNT_TYPES,enableNetworkSwitch:!0,experimental_preferUniversalLinks:!1,remoteFeatures:{},enableMobileFullScreen:!1}),R={state:Q,subscribeKey(t,e){return Xe(Q,t,e)},setOptions(t){Object.assign(Q,t)},setRemoteFeatures(t){if(!t)return;const e={...Q.remoteFeatures,...t};Q.remoteFeatures=e,Q.remoteFeatures?.socials&&(Q.remoteFeatures.socials=Qo.filterSocialsByPlatform(Q.remoteFeatures.socials)),Q.features?.pay&&(Q.remoteFeatures.email=!1,Q.remoteFeatures.socials=!1)},setFeatures(t){if(!t)return;Q.features||(Q.features=me.DEFAULT_FEATURES);const e={...Q.features,...t};Q.features=e,Q.features?.pay&&Q.remoteFeatures&&(Q.remoteFeatures.email=!1,Q.remoteFeatures.socials=!1)},setProjectId(t){Q.projectId=t},setCustomRpcUrls(t){Q.customRpcUrls=t},setAllWallets(t){Q.allWallets=t},setIncludeWalletIds(t){Q.includeWalletIds=t},setExcludeWalletIds(t){Q.excludeWalletIds=t},setFeaturedWalletIds(t){Q.featuredWalletIds=t},setTokens(t){Q.tokens=t},setTermsConditionsUrl(t){Q.termsConditionsUrl=t},setPrivacyPolicyUrl(t){Q.privacyPolicyUrl=t},setCustomWallets(t){Q.customWallets=t},setIsSiweEnabled(t){Q.isSiweEnabled=t},setIsUniversalProvider(t){Q.isUniversalProvider=t},setSdkVersion(t){Q.sdkVersion=t},setMetadata(t){Q.metadata=t},setDisableAppend(t){Q.disableAppend=t},setEIP6963Enabled(t){Q.enableEIP6963=t},setDebug(t){Q.debug=t},setEnableWalletGuide(t){Q.enableWalletGuide=t},setEnableAuthLogger(t){Q.enableAuthLogger=t},setEnableWallets(t){Q.enableWallets=t},setPreferUniversalLinks(t){Q.experimental_preferUniversalLinks=t},setSIWX(t){if(t)for(const[e,s]of Object.entries(me.SIWX_DEFAULTS))t[e]??=s;Q.siwx=t},setConnectMethodsOrder(t){Q.features={...Q.features,connectMethodsOrder:t}},setWalletFeaturesOrder(t){Q.features={...Q.features,walletFeaturesOrder:t}},setSocialsOrder(t){Q.remoteFeatures={...Q.remoteFeatures,socials:t}},setCollapseWallets(t){Q.features={...Q.features,collapseWallets:t}},setEnableEmbedded(t){Q.enableEmbedded=t},setAllowUnsupportedChain(t){Q.allowUnsupportedChain=t},setManualWCControl(t){Q.manualWCControl=t},setEnableNetworkSwitch(t){Q.enableNetworkSwitch=t},setEnableMobileFullScreen(t){Q.enableMobileFullScreen=J.isMobile()&&t},setEnableReconnect(t){Q.enableReconnect=t},setDefaultAccountTypes(t={}){Object.entries(t).forEach(([e,s])=>{s&&(Q.defaultAccountTypes[e]=s)})},setUniversalProviderConfigOverride(t){Q.universalProviderConfigOverride=t},getUniversalProviderConfigOverride(){return Q.universalProviderConfigOverride},getSnapshot(){return Ur(Q)}},on=Object.freeze({message:"",variant:"success",svg:void 0,open:!1,autoClose:!0}),je=ke({...on}),Zp={state:je,subscribeKey(t,e){return Xe(je,t,e)},showLoading(t,e={}){this._showMessage({message:t,variant:"loading",...e})},showSuccess(t){this._showMessage({message:t,variant:"success"})},showSvg(t,e){this._showMessage({message:t,svg:e})},showError(t){const e=J.parseError(t);this._showMessage({message:e,variant:"error"})},hide(){je.message=on.message,je.variant=on.variant,je.svg=on.svg,je.open=on.open,je.autoClose=on.autoClose},_showMessage({message:t,svg:e,variant:s="success",autoClose:n=on.autoClose}){je.open?(je.open=!1,setTimeout(()=>{je.message=t,je.variant=s,je.svg=e,je.open=!0,je.autoClose=n},150)):(je.message=t,je.variant=s,je.svg=e,je.open=!0,je.autoClose=n)}},is=Zp,Qp={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"}]}]},rd=J.getBlockchainApiUrl(),ut=ke({clientId:null,api:new Hr({baseUrl:rd,clientId:null}),supportedChains:{http:[],ws:[]}}),re={state:ut,async get(t){const{st:e,sv:s}=re.getSdkProperties(),n=R.state.projectId,r={...t.params||{},st:e,sv:s,projectId:n};return ut.api.get({...t,params:r})},getSdkProperties(){const{sdkType:t,sdkVersion:e}=R.state;return{st:t||"unknown",sv:e||"unknown"}},async isNetworkSupported(t){if(!t)return!1;try{ut.supportedChains.http.length||await re.getSupportedNetworks()}catch{return!1}return ut.supportedChains.http.includes(t)},async getSupportedNetworks(){try{const t=await re.get({path:"v1/supported-chains"});return ut.supportedChains=t,t}catch{return ut.supportedChains}},async fetchIdentity({address:t}){const e=B.getIdentityFromCacheForAddress(t);if(e)return e;const s=await re.get({path:`/v1/identity/${t}`,params:{sender:f.state.activeCaipAddress?J.getPlainAddress(f.state.activeCaipAddress):void 0}});return B.updateIdentityCache({address:t,identity:s,timestamp:Date.now()}),s},async fetchTransactions({account:t,cursor:e,signal:s,cache:n,chainId:r}){if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))return{data:[],next:void 0};const o=B.getTransactionsCacheForAddress({address:t,chainId:r});if(o)return o;const a=await re.get({path:`/v1/account/${t}/history`,params:{cursor:e,chainId:r},signal:s,cache:n});return B.updateTransactionsCache({address:t,chainId:r,timestamp:Date.now(),transactions:a}),a},async fetchSwapQuote({amount:t,userAddress:e,from:s,to:n,gasPrice:r}){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?re.get({path:"/v1/convert/quotes",headers:{"Content-Type":"application/json"},params:{amount:t,userAddress:e,from:s,to:n,gasPrice:r}}):{quotes:[]}},async fetchSwapTokens({chainId:t}){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?re.get({path:"/v1/convert/tokens",params:{chainId:t}}):{tokens:[]}},async fetchTokenPrice({addresses:t}){if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))return{fungibles:[]};const s=B.getTokenPriceCacheForAddresses(t);if(s)return s;const n=await ut.api.post({path:"/v1/fungible/price",body:{currency:"usd",addresses:t,projectId:R.state.projectId},headers:{"Content-Type":"application/json"}});return B.updateTokenPriceCache({addresses:t,timestamp:Date.now(),tokenPrice:n}),n},async fetchSwapAllowance({tokenAddress:t,userAddress:e}){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?re.get({path:"/v1/convert/allowance",params:{tokenAddress:t,userAddress:e},headers:{"Content-Type":"application/json"}}):{allowance:"0"}},async fetchGasPrice({chainId:t}){const{st:e,sv:s}=re.getSdkProperties();if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Gas Price");return re.get({path:"/v1/convert/gas-price",headers:{"Content-Type":"application/json"},params:{chainId:t,st:e,sv:s}})},async generateSwapCalldata({amount:t,from:e,to:s,userAddress:n,disableEstimate:r}){if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return ut.api.post({path:"/v1/convert/build-transaction",headers:{"Content-Type":"application/json"},body:{amount:t,eip155:{slippage:me.CONVERT_SLIPPAGE_TOLERANCE},projectId:R.state.projectId,from:e,to:s,userAddress:n,disableEstimate:r}})},async generateApproveCalldata({from:t,to:e,userAddress:s}){const{st:n,sv:r}=re.getSdkProperties();if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))throw new Error("Network not supported for Swaps");return re.get({path:"/v1/convert/build-approve",headers:{"Content-Type":"application/json"},params:{userAddress:s,from:t,to:e,st:n,sv:r}})},async getBalance(t,e,s){const{st:n,sv:r}=re.getSdkProperties();if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))return is.showError("Token Balance Unavailable"),{balances:[]};const o=`${e}:${t}`,a=B.getBalanceCacheForCaipAddress(o);if(a)return a;const c=await re.get({path:`/v1/account/${t}/balance`,params:{currency:"usd",chainId:e,forceUpdate:s,st:n,sv:r}});return B.updateBalanceCache({caipAddress:o,balance:c,timestamp:Date.now()}),c},async lookupEnsName(t){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?re.get({path:`/v1/profile/account/${t}`,params:{apiVersion:"2"}}):{addresses:{},attributes:[]}},async reverseLookupEnsName({address:t}){if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))return[];const s=f.getAccountData()?.address;return re.get({path:`/v1/profile/reverse/${t}`,params:{sender:s,apiVersion:"2"}})},async getEnsNameSuggestions(t){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?re.get({path:`/v1/profile/suggestions/${t}`,params:{zone:"reown.id"}}):{suggestions:[]}},async registerEnsName({coinType:t,address:e,message:s,signature:n}){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?ut.api.post({path:"/v1/profile/account",body:{coin_type:t,address:e,message:s,signature:n},headers:{"Content-Type":"application/json"}}):{success:!1}},async generateOnRampURL({destinationWallets:t,partnerUserId:e,defaultNetwork:s,purchaseAmount:n,paymentAmount:r}){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?(await ut.api.post({path:"/v1/generators/onrampurl",params:{projectId:R.state.projectId},body:{destinationWallets:t,defaultNetwork:s,partnerUserId:e,defaultExperience:"buy",presetCryptoAmount:n,presetFiatAmount:r}})).url:""},async getOnrampOptions(){if(!await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId))return{paymentCurrencies:[],purchaseCurrencies:[]};try{return await re.get({path:"/v1/onramp/options"})}catch{return Qp}},async getOnrampQuote({purchaseCurrency:t,paymentCurrency:e,amount:s,network:n}){try{return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?await ut.api.post({path:"/v1/onramp/quote",params:{projectId:R.state.projectId},body:{purchaseCurrency:t,paymentCurrency:e,amount:s,network:n}}):null}catch{return{networkFee:{amount:s,currency:e.id},paymentSubtotal:{amount:s,currency:e.id},paymentTotal:{amount:s,currency:e.id},purchaseAmount:{amount:s,currency:e.id},quoteId:"mocked-quote-id"}}},async getSmartSessions(t){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?re.get({path:`/v1/sessions/${t}`}):[]},async revokeSmartSession(t,e,s){return await re.isNetworkSupported(f.state.activeCaipNetwork?.caipNetworkId)?ut.api.post({path:`/v1/sessions/${t}/revoke`,params:{projectId:R.state.projectId},body:{pci:e,signature:s}}):{success:!1}},setClientId(t){ut.clientId=t,ut.api=new Hr({baseUrl:rd,clientId:t})}},Cs={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"}},Rt={PHANTOM:{id:"a797aa35c0fadbfc1a53e7f675162ed5226968b44a19ee3d24385c64d1d3c393",url:"https://phantom.app"},SOLFLARE:{id:"1ca0bdd4747578705b1939af023d120677c64fe6ca76add81fda36e350605e79",url:"https://solflare.com"},COINBASE:{id:"fd20dc426fb37566d803205b19bbc1d4096b248ac04548e3cfb6b3a38bd033aa",url:"https://go.cb-w.com"},BINANCE:{id:"2fafea35bb471d22889ccb49c08d99dd0a18a37982602c33f696a5723934ba25",appId:"yFK5FCqYprrXDiVFbhyRx7",deeplink:"bnc://app.binance.com/mp/app",url:"https://app.binance.com/en/download"}},ef={handleMobileDeeplinkRedirect(t,e){const s=window.location.href,n=encodeURIComponent(s);if(t===Rt.PHANTOM.id&&!("phantom"in window)){const r=s.startsWith("https")?"https":"http",i=s.split("/")[2],o=encodeURIComponent(`${r}://${i}`);window.location.href=`${Rt.PHANTOM.url}/ul/browse/${n}?ref=${o}`}if(t===Rt.SOLFLARE.id&&!("solflare"in window)&&(window.location.href=`${Rt.SOLFLARE.url}/ul/v1/browse/${n}?ref=${n}`),e===x.CHAIN.SOLANA&&t===Rt.COINBASE.id&&!("coinbaseSolana"in window)&&(window.location.href=`${Rt.COINBASE.url}/dapp?cb_url=${n}`),e===x.CHAIN.BITCOIN&&t===Rt.BINANCE.id&&!("binancew3w"in window)){const r=f.state.activeCaipNetwork,i=window.btoa("/pages/browser/index"),o=window.btoa(`url=${n}&defaultChainId=${r?.id??1}`),a=new URL(Rt.BINANCE.deeplink);a.searchParams.set("appId",Rt.BINANCE.appId),a.searchParams.set("startPagePath",i),a.searchParams.set("startPageQuery",o);const c=new URL(Rt.BINANCE.url);c.searchParams.set("_dp",window.btoa(a.toString())),window.location.href=c.toString()}}},tf=Object.freeze({enabled:!0,events:[]}),sf=new Hr({baseUrl:J.getAnalyticsUrl(),clientId:null}),nf=5,rf=60*1e3,Ps=ke({...tf}),of={state:Ps,subscribeKey(t,e){return Xe(Ps,t,e)},async sendError(t,e){if(!Ps.enabled)return;const s=Date.now();if(Ps.events.filter(i=>{const o=new Date(i.properties.timestamp||"").getTime();return s-o<rf}).length>=nf)return;const r={type:"error",event:e,properties:{errorType:t.name,errorMessage:t.message,stackTrace:t.stack,timestamp:new Date().toISOString()}};Ps.events.push(r);try{if(typeof window>"u")return;const{projectId:i,sdkType:o,sdkVersion:a}=R.state;await sf.post({path:"/e",params:{projectId:i,st:o,sv:a||"html-wagmi-4.2.2"},body:{eventId:J.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:new Date().toISOString(),props:{type:"error",event:e,errorType:t.name,errorMessage:t.message,stackTrace:t.stack}}})}catch{}},enable(){Ps.enabled=!0},disable(){Ps.enabled=!1},clearEvents(){Ps.events=[]}};class bn extends Error{constructor(e,s,n){super(e),this.originalName="AppKitError",this.name="AppKitError",this.category=s,this.originalError=n,n&&n instanceof Error&&(this.originalName=n.name),Object.setPrototypeOf(this,bn.prototype);let r=!1;if(n instanceof Error&&typeof n.stack=="string"&&n.stack){const i=n.stack,o=i.indexOf(`
|
|
3
|
-
`);if(o>-1){const a=i.substring(o+1);this.stack=`${this.name}: ${this.message}
|
|
4
|
-
${a}`,r=!0}}r||(Error.captureStackTrace?Error.captureStackTrace(this,bn):this.stack||(this.stack=`${this.name}: ${this.message}`))}}function Nc(t,e){let s="";try{t instanceof Error?s=t.message:typeof t=="string"?s=t:typeof t=="object"&&t!==null?Object.keys(t).length===0?s="Unknown error":s=t?.message||JSON.stringify(t):s=String(t)}catch(r){s="Unknown error",console.error("Error parsing error message",r)}const n=t instanceof bn?t:new bn(s,e,t);throw of.sendError(n,n.category),n}function jt(t,e="INTERNAL_SDK_ERROR"){const s={};return Object.keys(t).forEach(n=>{const r=t[n];if(typeof r=="function"){let i=r;r.constructor.name==="AsyncFunction"?i=async(...o)=>{try{return await r(...o)}catch(a){return Nc(a,e)}}:i=(...o)=>{try{return r(...o)}catch(a){return Nc(a,e)}},s[n]=i}else s[n]=r}),s}const Ct=ke({walletImages:{},networkImages:{},chainImages:{},connectorImages:{},tokenImages:{},currencyImages:{}}),af={state:Ct,subscribeNetworkImages(t){return Je(Ct.networkImages,()=>t(Ct.networkImages))},subscribeKey(t,e){return Xe(Ct,t,e)},subscribe(t){return Je(Ct,()=>t(Ct))},setWalletImage(t,e){Ct.walletImages[t]=e},setNetworkImage(t,e){Ct.networkImages[t]=e},setChainImage(t,e){Ct.chainImages[t]=e},setConnectorImage(t,e){Ct.connectorImages={...Ct.connectorImages,[t]:e}},setTokenImage(t,e){Ct.tokenImages[t]=e},setCurrencyImage(t,e){Ct.currencyImages[t]=e}},Ut=jt(af),cf={eip155:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",solana:"a1b58899-f671-4276-6a5e-56ca5bd59700",polkadot:"",bip122:"0b4838db-0161-4ffe-022d-532bf03dba00",cosmos:"",sui:"",stacks:""},go=ke({networkImagePromises:{}}),id={async fetchWalletImage(t){if(t)return await te._fetchWalletImage(t),this.getWalletImageById(t)},async fetchNetworkImage(t){if(!t)return;const e=this.getNetworkImageById(t);return e||(go.networkImagePromises[t]||(go.networkImagePromises[t]=te._fetchNetworkImage(t)),await go.networkImagePromises[t],this.getNetworkImageById(t))},getWalletImageById(t){if(t)return Ut.state.walletImages[t]},getWalletImage(t){if(t?.image_url)return t?.image_url;if(t?.image_id)return Ut.state.walletImages[t.image_id]},getNetworkImage(t){if(t?.assets?.imageUrl)return t?.assets?.imageUrl;if(t?.assets?.imageId)return Ut.state.networkImages[t.assets.imageId]},getNetworkImageById(t){if(t)return Ut.state.networkImages[t]},getConnectorImage(t){if(t?.imageUrl)return t.imageUrl;if(t?.info?.icon)return t.info.icon;if(t?.imageId)return Ut.state.connectorImages[t.imageId]},getChainImage(t){return Ut.state.networkImages[cf[t]]},getTokenImage(t){if(t)return Ut.state.tokenImages[t]}},lf=J.getAnalyticsUrl(),uf=new Hr({baseUrl:lf,clientId:null}),df=["MODAL_CREATED"],hf=45,_c=1e3*10,xe=ke({timestamp:Date.now(),lastFlush:Date.now(),reportedErrors:{},data:{type:"track",event:"MODAL_CREATED"},pendingEvents:[],subscribedToVisibilityChange:!1,walletImpressions:[]}),le={state:xe,subscribe(t){return Je(xe,()=>t(xe))},getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=R.state;return{projectId:t,st:e,sv:s||"html-wagmi-4.2.2"}},shouldFlushEvents(){const t=JSON.stringify(xe.pendingEvents).length/1024>hf,e=xe.lastFlush+_c<Date.now();return t||e},_setPendingEvent(t){try{let e=f.getAccountData()?.address;if("address"in t.data&&t.data.address&&(e=t.data.address),df.includes(t.data.event)||typeof window>"u")return;const s=f.getActiveCaipNetwork()?.caipNetworkId;this.state.pendingEvents.push({eventId:J.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:t.timestamp,props:{...t.data,address:e,properties:{..."properties"in t.data?t.data.properties:{},caipNetworkId:s}}}),xe.reportedErrors.FORBIDDEN=!1,le.shouldFlushEvents()&&le._submitPendingEvents()}catch(e){console.warn("_setPendingEvent",e)}},sendEvent(t){xe.timestamp=Date.now(),xe.data=t;const e=["INITIALIZE","CONNECT_SUCCESS","SOCIAL_LOGIN_SUCCESS"];(R.state.features?.analytics||e.includes(t.event))&&le._setPendingEvent(xe),this.subscribeToFlushTriggers()},sendWalletImpressionEvent(t){xe.walletImpressions.push(t)},_transformPendingEventsForBatch(t){try{return t.filter(e=>e.props.event!=="WALLET_IMPRESSION")}catch{return t}},_submitPendingEvents(){if(xe.lastFlush=Date.now(),!(xe.pendingEvents.length===0&&xe.walletImpressions.length===0))try{const t=le._transformPendingEventsForBatch(xe.pendingEvents);xe.walletImpressions.length&&t.push({eventId:J.getUUID(),url:window.location.href,domain:window.location.hostname,timestamp:Date.now(),props:{type:"track",event:"WALLET_IMPRESSION",items:[...xe.walletImpressions]}}),uf.sendBeacon({path:"/batch",params:le.getSdkProperties(),body:t}),xe.reportedErrors.FORBIDDEN=!1,xe.pendingEvents=[],xe.walletImpressions=[]}catch{xe.reportedErrors.FORBIDDEN=!0}},subscribeToFlushTriggers(){xe.subscribedToVisibilityChange||typeof document>"u"||(xe.subscribedToVisibilityChange=!0,document?.addEventListener?.("visibilitychange",()=>{document.visibilityState==="hidden"&&le._submitPendingEvents()}),document?.addEventListener?.("freeze",()=>{le._submitPendingEvents()}),window?.addEventListener?.("pagehide",()=>{le._submitPendingEvents()}),setInterval(()=>{le._submitPendingEvents()},_c))}},pf=J.getApiUrl(),dt=new Hr({baseUrl:pf,clientId:null}),ff=40,Sc=4,gf=20,ae=ke({promises:{},page:1,count:0,featured:[],allFeatured:[],recommended:[],allRecommended:[],wallets:[],filteredWallets:[],search:[],isAnalyticsEnabled:!1,excludedWallets:[],isFetchingRecommendedWallets:!1,explorerWallets:[],explorerFilteredWallets:[]}),te={state:ae,subscribeKey(t,e){return Xe(ae,t,e)},_getSdkProperties(){const{projectId:t,sdkType:e,sdkVersion:s}=R.state;return{projectId:t,st:e||"appkit",sv:s||"html-wagmi-4.2.2"}},_filterOutExtensions(t){return R.state.isUniversalProvider?t.filter(e=>!!(e.mobile_link||e.desktop_link||e.webapp_link)):t},async _fetchWalletImage(t){const e=`${dt.baseUrl}/getWalletImage/${t}`,s=await dt.getBlob({path:e,params:te._getSdkProperties()});Ut.setWalletImage(t,URL.createObjectURL(s))},async _fetchNetworkImage(t){const e=`${dt.baseUrl}/public/getAssetImage/${t}`,s=await dt.getBlob({path:e,params:te._getSdkProperties()});Ut.setNetworkImage(t,URL.createObjectURL(s))},async _fetchConnectorImage(t){const e=`${dt.baseUrl}/public/getAssetImage/${t}`,s=await dt.getBlob({path:e,params:te._getSdkProperties()});Ut.setConnectorImage(t,URL.createObjectURL(s))},async _fetchCurrencyImage(t){const e=`${dt.baseUrl}/public/getCurrencyImage/${t}`,s=await dt.getBlob({path:e,params:te._getSdkProperties()});Ut.setCurrencyImage(t,URL.createObjectURL(s))},async _fetchTokenImage(t){const e=`${dt.baseUrl}/public/getTokenImage/${t}`,s=await dt.getBlob({path:e,params:te._getSdkProperties()});Ut.setTokenImage(t,URL.createObjectURL(s))},_filterWalletsByPlatform(t){const e=t.length,s=J.isMobile()?t?.filter(r=>r.mobile_link||r.webapp_link?!0:Object.values(Rt).map(o=>o.id).includes(r.id)):t,n=e-s.length;return{filteredWallets:s,mobileFilteredOutWalletsLength:n}},async fetchProjectConfig(){return(await dt.get({path:"/appkit/v1/config",params:te._getSdkProperties()})).features},async fetchAllowedOrigins(){try{const{allowedOrigins:t}=await dt.get({path:"/projects/v1/origins",params:te._getSdkProperties()});return t}catch(t){if(t instanceof Error&&t.cause instanceof Response){const e=t.cause.status;if(e===x.HTTP_STATUS_CODES.TOO_MANY_REQUESTS)throw new Error("RATE_LIMITED",{cause:t});if(e>=x.HTTP_STATUS_CODES.SERVER_ERROR&&e<600)throw new Error("SERVER_ERROR",{cause:t});return[]}return[]}},async fetchNetworkImages(){const e=f.getAllRequestedCaipNetworks()?.map(({assets:s})=>s?.imageId).filter(Boolean).filter(s=>!id.getNetworkImageById(s));e&&await Promise.allSettled(e.map(s=>te._fetchNetworkImage(s)))},async fetchConnectorImages(){const{connectors:t}=F.state,e=t.map(({imageId:s})=>s).filter(Boolean);await Promise.allSettled(e.map(s=>te._fetchConnectorImage(s)))},async fetchCurrencyImages(t=[]){await Promise.allSettled(t.map(e=>te._fetchCurrencyImage(e)))},async fetchTokenImages(t=[]){await Promise.allSettled(t.map(e=>te._fetchTokenImage(e)))},async fetchWallets(t){const e=t.exclude??[];te._getSdkProperties().sv.startsWith("html-core-")&&e.push(...Object.values(Rt).map(o=>o.id));const n=await dt.get({path:"/getWallets",params:{...te._getSdkProperties(),...t,page:String(t.page),entries:String(t.entries),include:t.include?.join(","),exclude:e.join(",")}}),{filteredWallets:r,mobileFilteredOutWalletsLength:i}=te._filterWalletsByPlatform(n?.data);return{data:r||[],count:n?.count,mobileFilteredOutWalletsLength:i}},async prefetchWalletRanks(){const t=F.state.connectors;if(!t?.length)return;const e={page:1,entries:20,badge:"certified"};if(e.names=t.map(r=>r.name).join(","),f.state.activeChain===x.CHAIN.EVM){const r=[...t.flatMap(i=>i.connectors?.map(o=>o.info?.rdns)||[]),...t.map(i=>i.info?.rdns)].filter(i=>typeof i=="string"&&i.length>0);r.length&&(e.rdns=r.join(","))}const{data:s}=await te.fetchWallets(e);ae.explorerWallets=s;const n=f.getRequestedCaipNetworkIds().join(",");ae.explorerFilteredWallets=s.filter(r=>r.chains?.some(i=>n.includes(i)))},async fetchFeaturedWallets(){const{featuredWalletIds:t}=R.state;if(t?.length){const e={...te._getSdkProperties(),page:1,entries:t?.length??Sc,include:t},{data:s}=await te.fetchWallets(e),n=[...s].sort((i,o)=>t.indexOf(i.id)-t.indexOf(o.id)),r=n.map(i=>i.image_id).filter(Boolean);await Promise.allSettled(r.map(i=>te._fetchWalletImage(i))),ae.featured=n,ae.allFeatured=n}},async fetchRecommendedWallets(){try{ae.isFetchingRecommendedWallets=!0;const{includeWalletIds:t,excludeWalletIds:e,featuredWalletIds:s}=R.state,n=[...e??[],...s??[]].filter(Boolean),r=f.getRequestedCaipNetworkIds().join(","),i={page:1,entries:Sc,include:t,exclude:n,chains:r},{data:o,count:a}=await te.fetchWallets(i),c=B.getRecentWallets(),l=o.map(d=>d.image_id).filter(Boolean),u=c.map(d=>d.image_id).filter(Boolean);await Promise.allSettled([...l,...u].map(d=>te._fetchWalletImage(d))),ae.recommended=o,ae.allRecommended=o,ae.count=a??0}catch{}finally{ae.isFetchingRecommendedWallets=!1}},async fetchWalletsByPage({page:t}){const{includeWalletIds:e,excludeWalletIds:s,featuredWalletIds:n}=R.state,r=f.getRequestedCaipNetworkIds().join(","),i=[...ae.recommended.map(({id:d})=>d),...s??[],...n??[]].filter(Boolean),o={page:t,entries:ff,include:e,exclude:i,chains:r},{data:a,count:c,mobileFilteredOutWalletsLength:l}=await te.fetchWallets(o);ae.mobileFilteredOutWalletsLength=l+(ae.mobileFilteredOutWalletsLength??0);const u=a.slice(0,gf).map(d=>d.image_id).filter(Boolean);await Promise.allSettled(u.map(d=>te._fetchWalletImage(d))),ae.wallets=J.uniqueBy([...ae.wallets,...te._filterOutExtensions(a)],"id").filter(d=>d.chains?.some(h=>r.includes(h))),ae.count=c>ae.count?c:ae.count,ae.page=t},async initializeExcludedWallets({ids:t}){const e={page:1,entries:t.length,include:t},{data:s}=await te.fetchWallets(e);s&&s.forEach(n=>{ae.excludedWallets.push({rdns:n.rdns,name:n.name})})},async searchWallet({search:t,badge:e}){const{includeWalletIds:s,excludeWalletIds:n}=R.state,r=f.getRequestedCaipNetworkIds().join(",");ae.search=[];const i={page:1,entries:100,search:t?.trim(),badge_type:e,include:s,exclude:n,chains:r},{data:o}=await te.fetchWallets(i);le.sendEvent({type:"track",event:"SEARCH_WALLET",properties:{badge:e??"",search:t??""}});const a=o.map(c=>c.image_id).filter(Boolean);await Promise.allSettled([...a.map(c=>te._fetchWalletImage(c)),J.wait(300)]),ae.search=te._filterOutExtensions(o)},initPromise(t,e){const s=ae.promises[t];return s||(ae.promises[t]=e())},prefetch({fetchConnectorImages:t=!0,fetchFeaturedWallets:e=!0,fetchRecommendedWallets:s=!0,fetchNetworkImages:n=!0,fetchWalletRanks:r=!0}={}){const i=[t&&te.initPromise("connectorImages",te.fetchConnectorImages),e&&te.initPromise("featuredWallets",te.fetchFeaturedWallets),s&&te.initPromise("recommendedWallets",te.fetchRecommendedWallets),n&&te.initPromise("networkImages",te.fetchNetworkImages),r&&te.initPromise("walletRanks",te.prefetchWalletRanks)].filter(Boolean);return Promise.allSettled(i)},prefetchAnalyticsConfig(){R.state.features?.analytics&&te.fetchAnalyticsConfig()},async fetchAnalyticsConfig(){try{const{isAnalyticsEnabled:t}=await dt.get({path:"/getAnalyticsConfig",params:te._getSdkProperties()});R.setFeatures({analytics:t})}catch{R.setFeatures({analytics:!1})}},filterByNamespaces(t){if(!t?.length){ae.featured=ae.allFeatured,ae.recommended=ae.allRecommended;return}const e=f.getRequestedCaipNetworkIds().join(",");ae.featured=ae.allFeatured.filter(s=>s.chains?.some(n=>e.includes(n))),ae.recommended=ae.allRecommended.filter(s=>s.chains?.some(n=>e.includes(n))),ae.filteredWallets=ae.wallets.filter(s=>s.chains?.some(n=>e.includes(n)))},clearFilterByNamespaces(){ae.filteredWallets=[]},setFilterByNamespace(t){if(!t){ae.featured=ae.allFeatured,ae.recommended=ae.allRecommended;return}const e=f.getRequestedCaipNetworkIds().join(",");ae.featured=ae.allFeatured.filter(s=>s.chains?.some(n=>e.includes(n))),ae.recommended=ae.allRecommended.filter(s=>s.chains?.some(n=>e.includes(n))),ae.filteredWallets=ae.wallets.filter(s=>s.chains?.some(n=>e.includes(n)))}},ve=ke({view:"Connect",history:["Connect"],transactionStack:[]}),mf={state:ve,subscribeKey(t,e){return Xe(ve,t,e)},pushTransactionStack(t){ve.transactionStack.push(t)},popTransactionStack(t){const e=ve.transactionStack.pop();if(!e)return;const{onSuccess:s,onError:n,onCancel:r}=e;switch(t){case"success":s?.();break;case"error":n?.(),ne.goBack();break;case"cancel":r?.(),ne.goBack();break}},push(t,e){t!==ve.view&&(ve.view=t,ve.history.push(t),ve.data=e)},reset(t,e){ve.view=t,ve.history=[t],ve.data=e},replace(t,e){ve.history.at(-1)===t||(ve.view=t,ve.history[ve.history.length-1]=t,ve.data=e)},goBack(){const t=f.state.activeCaipAddress,e=ne.state.view==="ConnectingFarcaster",s=!t&&e;if(ve.history.length>1){ve.history.pop();const[n]=ve.history.slice(-1);n&&(t&&n==="Connect"?ve.view="Account":ve.view=n)}else he.close();ve.data?.wallet&&(ve.data.wallet=void 0),ve.data?.redirectView&&(ve.data.redirectView=void 0),setTimeout(()=>{if(s){f.setAccountProp("farcasterUrl",void 0,f.state.activeChain);const n=F.getAuthConnector();n?.provider?.reload();const r=Ur(R.state);n?.provider?.syncDappData?.({metadata:r.metadata,sdkVersion:r.sdkVersion,projectId:r.projectId,sdkType:r.sdkType})}},100)},goBackToIndex(t){if(ve.history.length>1){ve.history=ve.history.slice(0,t+1);const[e]=ve.history.slice(-1);e&&(ve.view=e)}},goBackOrCloseModal(){ne.state.history.length>1?ne.goBack():he.close()}},ne=jt(mf),hs=ke({themeMode:"dark",themeVariables:{},w3mThemeVariables:void 0}),ea={state:hs,subscribe(t){return Je(hs,()=>t(hs))},setThemeMode(t){hs.themeMode=t;try{const e=F.getAuthConnector();if(e){const s=ea.getSnapshot().themeVariables;e.provider.syncTheme({themeMode:t,themeVariables:s,w3mThemeVariables:ki(s,t)})}}catch{console.info("Unable to sync theme to auth connector")}},setThemeVariables(t){hs.themeVariables={...hs.themeVariables,...t};try{const e=F.getAuthConnector();if(e){const s=ea.getSnapshot().themeVariables;e.provider.syncTheme({themeVariables:s,w3mThemeVariables:ki(hs.themeVariables,hs.themeMode)})}}catch{console.info("Unable to sync theme to auth connector")}},getSnapshot(){return Ur(hs)}},Nt=jt(ea),od=Object.fromEntries(Zu.map(t=>[t,void 0])),wf=Object.fromEntries(Zu.map(t=>[t,!0])),ye=ke({allConnectors:[],connectors:[],activeConnector:void 0,filterByNamespace:void 0,activeConnectorIds:od,filterByNamespaceMap:wf}),yf={state:ye,subscribe(t){return Je(ye,()=>{t(ye)})},subscribeKey(t,e){return Xe(ye,t,e)},initialize(t){t.forEach(e=>{const s=B.getConnectedConnectorId(e);s&&F.setConnectorId(s,e)})},setActiveConnector(t){t&&(ye.activeConnector=Xn(t))},setConnectors(t){t.filter(r=>!ye.allConnectors.some(i=>i.id===r.id&&F.getConnectorName(i.name)===F.getConnectorName(r.name)&&i.chain===r.chain)).forEach(r=>{r.type!=="MULTI_CHAIN"&&ye.allConnectors.push(Xn(r))});const s=F.getEnabledNamespaces(),n=F.getEnabledConnectors(s);ye.connectors=F.mergeMultiChainConnectors(n)},filterByNamespaces(t){Object.keys(ye.filterByNamespaceMap).forEach(e=>{ye.filterByNamespaceMap[e]=!1}),t.forEach(e=>{ye.filterByNamespaceMap[e]=!0}),F.updateConnectorsForEnabledNamespaces()},filterByNamespace(t,e){ye.filterByNamespaceMap[t]=e,F.updateConnectorsForEnabledNamespaces()},updateConnectorsForEnabledNamespaces(){const t=F.getEnabledNamespaces(),e=F.getEnabledConnectors(t),s=F.areAllNamespacesEnabled();ye.connectors=F.mergeMultiChainConnectors(e),s?te.clearFilterByNamespaces():te.filterByNamespaces(t)},getEnabledNamespaces(){return Object.entries(ye.filterByNamespaceMap).filter(([t,e])=>e).map(([t])=>t)},getEnabledConnectors(t){return ye.allConnectors.filter(e=>t.includes(e.chain))},areAllNamespacesEnabled(){return Object.values(ye.filterByNamespaceMap).every(t=>t)},mergeMultiChainConnectors(t){const e=F.generateConnectorMapByName(t),s=[];return e.forEach(n=>{const r=n[0],i=r?.id===x.CONNECTOR_ID.AUTH;n.length>1&&r?s.push({name:r.name,imageUrl:r.imageUrl,imageId:r.imageId,connectors:[...n],type:i?"AUTH":"MULTI_CHAIN",chain:"eip155",id:r?.id||""}):r&&s.push(r)}),s},generateConnectorMapByName(t){const e=new Map;return t.forEach(s=>{const{name:n}=s,r=F.getConnectorName(n);if(!r)return;const i=e.get(r)||[];i.find(a=>a.chain===s.chain)||i.push(s),e.set(r,i)}),e},getConnectorName(t){return t&&({"Trust Wallet":"Trust"}[t]||t)},getUniqueConnectorsByName(t){const e=[];return t.forEach(s=>{e.find(n=>n.chain===s.chain)||e.push(s)}),e},addConnector(t){if(t.id===x.CONNECTOR_ID.AUTH){const e=t,s=Ur(R.state),n=Nt.getSnapshot().themeMode,r=Nt.getSnapshot().themeVariables;e?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,projectId:s.projectId,sdkType:s.sdkType}),e?.provider?.syncTheme({themeMode:n,themeVariables:r,w3mThemeVariables:ki(r,n)}),F.setConnectors([t])}else F.setConnectors([t])},getAuthConnector(t){const e=t||f.state.activeChain,s=ye.connectors.find(n=>n.id===x.CONNECTOR_ID.AUTH);if(s)return s?.connectors?.length?s.connectors.find(r=>r.chain===e):s},getAnnouncedConnectorRdns(){return ye.connectors.filter(t=>t.type==="ANNOUNCED").map(t=>t.info?.rdns)},getConnectorById(t){return ye.allConnectors.find(e=>e.id===t)},getConnector({id:t,rdns:e,namespace:s}){const n=s||f.state.activeChain;return ye.allConnectors.filter(i=>i.chain===n).find(i=>i.explorerId===t||i.info?.rdns===e)},syncIfAuthConnector(t){if(t.id!=="ID_AUTH")return;const e=t,s=Ur(R.state),n=Nt.getSnapshot().themeMode,r=Nt.getSnapshot().themeVariables;e?.provider?.syncDappData?.({metadata:s.metadata,sdkVersion:s.sdkVersion,sdkType:s.sdkType,projectId:s.projectId}),e.provider.syncTheme({themeMode:n,themeVariables:r,w3mThemeVariables:ki(r,n)})},getConnectorsByNamespace(t){const e=ye.allConnectors.filter(s=>s.chain===t);return F.mergeMultiChainConnectors(e)},canSwitchToSmartAccount(t){return f.checkIfSmartAccountEnabled()&&Lt(t)===Cs.ACCOUNT_TYPES.EOA},selectWalletConnector(t){const e=ne.state.data?.redirectView,s=F.getConnector({id:t.id,rdns:t.rdns});ef.handleMobileDeeplinkRedirect(s?.explorerId||t.id,f.state.activeChain),s?ne.push("ConnectingExternal",{connector:s,wallet:t,redirectView:e}):ne.push("ConnectingWalletConnect",{wallet:t,redirectView:e})},getConnectors(t){return t?F.getConnectorsByNamespace(t):F.mergeMultiChainConnectors(ye.allConnectors)},setFilterByNamespace(t){ye.filterByNamespace=t,ye.connectors=F.getConnectors(t),te.setFilterByNamespace(t)},setConnectorId(t,e){t&&(ye.activeConnectorIds={...ye.activeConnectorIds,[e]:t},B.setConnectedConnectorId(e,t))},removeConnectorId(t){ye.activeConnectorIds={...ye.activeConnectorIds,[t]:void 0},B.deleteConnectedConnectorId(t)},getConnectorId(t){if(t)return ye.activeConnectorIds[t]},isConnected(t){return t?!!ye.activeConnectorIds[t]:Object.values(ye.activeConnectorIds).some(e=>!!e)},resetConnectorIds(){ye.activeConnectorIds={...od}}},F=jt(yf),bf=1e3,lr={checkNamespaceConnectorId(t,e){return F.getConnectorId(t)===e},isSocialProvider(t){return me.DEFAULT_REMOTE_FEATURES.socials.includes(t)},connectWalletConnect({walletConnect:t,connector:e,closeModalOnConnect:s=!0,redirectViewOnModalClose:n="Connect",onOpen:r,onConnect:i}){return new Promise((o,a)=>{if(t&&F.setActiveConnector(e),r?.(J.isMobile()&&t),n){const l=he.subscribeKey("open",u=>{u||(ne.state.view!==n&&ne.replace(n),l(),a(new Error("Modal closed")))})}const c=f.subscribeKey("activeCaipAddress",l=>{l&&(i?.(),s&&he.close(),c(),o(ot.parseCaipAddress(l)))})})},connectExternal(t){return new Promise((e,s)=>{const n=f.subscribeKey("activeCaipAddress",r=>{r&&(he.close(),n(),e(ot.parseCaipAddress(r)))});G.connectExternal(t,t.chain).catch(()=>{n(),s(new Error("Connection rejected"))})})},connectSocial({social:t,namespace:e,closeModalOnConnect:s=!0,onOpenFarcaster:n,onConnect:r}){const i=f.getAccountData(e);let o=i?.socialWindow,a=i?.socialProvider,c=!1,l=null;const u=e||f.state.activeChain,d=f.subscribeKey("activeCaipAddress",h=>{h&&(s&&he.close(),d())});return new Promise((h,m)=>{async function g(y){if(y.data?.resultUri)if(y.origin===x.SECURE_SITE_SDK_ORIGIN){window.removeEventListener("message",g,!1);try{const _=F.getAuthConnector(u);if(_&&!c){const N=f.getAccountData(u);o&&(o.close(),f.setAccountProp("socialWindow",void 0,u),o=N?.socialWindow),c=!0;const D=y.data.resultUri;if(a&&le.sendEvent({type:"track",event:"SOCIAL_LOGIN_REQUEST_USER_DATA",properties:{provider:a}}),a){B.setConnectedSocialProvider(a),await G.connectExternal({id:_.id,type:_.type,socialUri:D},_.chain);const M=f.state.activeCaipAddress;if(!M){m(new Error("Failed to connect"));return}h(ot.parseCaipAddress(M)),le.sendEvent({type:"track",event:"SOCIAL_LOGIN_SUCCESS",properties:{provider:a}})}}}catch(_){a&&le.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:a,message:J.parseError(_)}}),m(new Error("Failed to connect"))}}else a&&le.sendEvent({type:"track",event:"SOCIAL_LOGIN_ERROR",properties:{provider:a,message:"Untrusted Origin"}})}async function b(){if(t){const y=f.getAccountData(u);f.setAccountProp("socialProvider",t,u),a=y?.socialProvider,le.sendEvent({type:"track",event:"SOCIAL_LOGIN_STARTED",properties:{provider:a}})}if(a==="farcaster"){n?.();const y=he.subscribeKey("open",N=>{!N&&t==="farcaster"&&(m(new Error("Popup closed")),r?.(),y())}),_=F.getAuthConnector();if(_&&!f.getAccountData(u)?.farcasterUrl)try{const{url:D}=await _.provider.getFarcasterUri();f.setAccountProp("farcasterUrl",D,u)}catch{m(new Error("Failed to connect to farcaster"))}}else{const y=F.getAuthConnector();l=J.returnOpenHref(`${x.SECURE_SITE_SDK_ORIGIN}/loading`,"popupWindow","width=600,height=800,scrollbars=yes");try{if(y&&a){const{uri:_}=await y.provider.getSocialRedirectUri({provider:a});if(l&&_){f.setAccountProp("socialWindow",Xn(l),u),o=i?.socialWindow,l.location.href=_;const N=setInterval(()=>{o?.closed&&!c&&(m(new Error("Popup closed")),clearInterval(N))},1e3);window.addEventListener("message",g,!1)}else l?.close(),m(new Error("Failed to initiate social connection"))}}catch{m(new Error("Failed to initiate social connection")),l?.close()}}}b()})},connectEmail({closeModalOnConnect:t=!0,redirectViewOnModalClose:e="Connect",onOpen:s,onConnect:n}){return new Promise((r,i)=>{if(s?.(),e){const a=he.subscribeKey("open",c=>{c||(ne.state.view!==e&&ne.replace(e),a(),i(new Error("Modal closed")))})}const o=f.subscribeKey("activeCaipAddress",a=>{a&&(n?.(),t&&he.close(),o(),r(ot.parseCaipAddress(a)))})})},async updateEmail(){const t=B.getConnectedConnectorId(f.state.activeChain),e=F.getAuthConnector();if(!e)throw new Error("No auth connector found");if(t!==x.CONNECTOR_ID.AUTH)throw new Error("Not connected to email or social");const s=e.provider.getEmail()??"";return await he.open({view:"UpdateEmailWallet",data:{email:s,redirectView:void 0}}),new Promise((n,r)=>{const i=setInterval(()=>{const a=e.provider.getEmail()??"";a!==s&&(he.close(),clearInterval(i),o(),n({email:a}))},bf),o=he.subscribeKey("open",a=>{a||(ne.state.view!=="Connect"&&ne.push("Connect"),clearInterval(i),o(),r(new Error("Modal closed")))})})},canSwitchToSmartAccount(t){return f.checkIfSmartAccountEnabled()&&Lt(t)===Cs.ACCOUNT_TYPES.EOA}};function ad(){const t=f.state.activeCaipNetwork?.chainNamespace||"eip155",e=f.state.activeCaipNetwork?.id||1,s=me.NATIVE_TOKEN_ADDRESS[t];return`${t}:${e}:${s}`}function Lt(t){return f.getAccountData(t)?.preferredAccountType}function oi(t){return f.state.activeCaipNetwork}const Pi={getConnectionStatus(t,e){const s=F.state.activeConnectorIds[e],n=G.getConnections(e);return!!s&&t.connectorId===s?"connected":n.some(o=>o.connectorId.toLowerCase()===t.connectorId.toLowerCase())?"active":"disconnected"},excludeConnectorAddressFromConnections({connections:t,connectorId:e,addresses:s}){return t.map(n=>{if((e?n.connectorId.toLowerCase()===e.toLowerCase():!1)&&s){const i=n.accounts.filter(o=>!s.some(c=>c.toLowerCase()===o.address.toLowerCase()));return{...n,accounts:i}}return n})},excludeExistingConnections(t,e){const s=new Set(t);return e.filter(n=>!s.has(n.connectorId))},getConnectionsByConnectorId(t,e){return t.filter(s=>s.connectorId.toLowerCase()===e.toLowerCase())},getConnectionsData(t){const e=!!R.state.remoteFeatures?.multiWallet,s=F.state.activeConnectorIds[t],n=G.getConnections(t),i=(G.state.recentConnections.get(t)??[]).filter(a=>F.getConnectorById(a.connectorId)),o=Pi.excludeExistingConnections([...n.map(a=>a.connectorId),...s?[s]:[]],i);return e?{connections:n,recentConnections:o}:{connections:n.filter(a=>a.connectorId.toLowerCase()===s?.toLowerCase()),recentConnections:[]}}},De=ke({transactions:[],transactionsByYear:{},lastNetworkInView:void 0,loading:!1,empty:!1,next:void 0}),Ef={state:De,subscribe(t){return Je(De,()=>t(De))},setLastNetworkInView(t){De.lastNetworkInView=t},async fetchTransactions(t){if(!t)throw new Error("Transactions can't be fetched without an accountAddress");De.loading=!0;try{const e=await re.fetchTransactions({account:t,cursor:De.next,chainId:f.state.activeCaipNetwork?.caipNetworkId}),s=Ei.filterSpamTransactions(e.data),n=Ei.filterByConnectedChain(s),r=[...De.transactions,...n];De.loading=!1,De.transactions=r,De.transactionsByYear=Ei.groupTransactionsByYearAndMonth(De.transactionsByYear,n),De.empty=r.length===0,De.next=e.next?e.next:void 0}catch{const s=f.state.activeChain;le.sendEvent({type:"track",event:"ERROR_FETCH_TRANSACTIONS",properties:{address:t,projectId:R.state.projectId,cursor:De.next,isSmartAccount:Lt(s)===Cs.ACCOUNT_TYPES.SMART_ACCOUNT}}),is.showError("Failed to fetch transactions"),De.loading=!1,De.empty=!0,De.next=void 0}},groupTransactionsByYearAndMonth(t={},e=[]){const s=t;return e.forEach(n=>{const r=new Date(n.metadata.minedAt).getFullYear(),i=new Date(n.metadata.minedAt).getMonth(),o=s[r]??{},c=(o[i]??[]).filter(l=>l.id!==n.id);s[r]={...o,[i]:[...c,n].sort((l,u)=>new Date(u.metadata.minedAt).getTime()-new Date(l.metadata.minedAt).getTime())}}),s},filterSpamTransactions(t){return t.filter(e=>!e.transfers.every(n=>n.nft_info?.flags.is_spam===!0))},filterByConnectedChain(t){const e=f.state.activeCaipNetwork?.caipNetworkId;return t.filter(n=>n.metadata.chain===e)},clearCursor(){De.next=void 0},resetTransactions(){De.transactions=[],De.transactionsByYear={},De.lastNetworkInView=void 0,De.loading=!1,De.empty=!1,De.next=void 0}},Ei=jt(Ef,"API_ERROR"),be=ke({connections:new Map,recentConnections:new Map,isSwitchingConnection:!1,wcError:!1,buffering:!1,status:"disconnected"});let en;const Cf={state:be,subscribe(t){return Je(be,()=>t(be))},subscribeKey(t,e){return Xe(be,t,e)},_getClient(){return be._client},setClient(t){be._client=Xn(t)},initialize(t){const e=t.filter(s=>!!s.namespace).map(s=>s.namespace);G.syncStorageConnections(e)},syncStorageConnections(t){const e=B.getConnections(),s=t??Array.from(f.state.chains.keys());for(const n of s){const r=e[n]??[],i=new Map(be.recentConnections);i.set(n,r),be.recentConnections=i}},getConnections(t){return t?be.connections.get(t)??[]:[]},hasAnyConnection(t){const e=G.state.connections;return Array.from(e.values()).flatMap(s=>s).some(({connectorId:s})=>s===t)},async connectWalletConnect({cache:t="auto"}={}){const e=J.isTelegram()||J.isSafari()&&J.isIos();if(t==="always"||t==="auto"&&e){if(en){await en,en=void 0;return}if(!J.isPairingExpired(be?.wcPairingExpiry)){const s=be.wcUri;be.wcUri=s;return}en=G._getClient()?.connectWalletConnect?.().catch(()=>{}),G.state.status="connecting",await en,en=void 0,be.wcPairingExpiry=void 0,G.state.status="connected"}else await G._getClient()?.connectWalletConnect?.()},async connectExternal(t,e,s=!0){const n=await G._getClient()?.connectExternal?.(t);return s&&f.setActiveNamespace(e),n},async reconnectExternal(t){await G._getClient()?.reconnectExternal?.(t);const e=t.chain||f.state.activeChain;e&&F.setConnectorId(t.id,e)},async setPreferredAccountType(t,e){if(!e)return;he.setLoading(!0,f.state.activeChain);const s=F.getAuthConnector();s&&(f.setAccountProp("preferredAccountType",t,e),await s.provider.setPreferredAccount(t),B.setPreferredAccountTypes(Object.entries(f.state.chains).reduce((n,[r,i])=>{const o=r,a=Lt(o);return a!==void 0&&(n[o]=a),n},{})),await G.reconnectExternal(s),he.setLoading(!1,f.state.activeChain),le.sendEvent({type:"track",event:"SET_PREFERRED_ACCOUNT_TYPE",properties:{accountType:t,network:f.state.activeCaipNetwork?.caipNetworkId||""}}))},async signMessage(t){return G._getClient()?.signMessage(t)},parseUnits(t,e){return G._getClient()?.parseUnits(t,e)},formatUnits(t,e){return G._getClient()?.formatUnits(t,e)},updateBalance(t){return G._getClient()?.updateBalance(t)},async sendTransaction(t){return G._getClient()?.sendTransaction(t)},async getCapabilities(t){return G._getClient()?.getCapabilities(t)},async grantPermissions(t){return G._getClient()?.grantPermissions(t)},async walletGetAssets(t){return G._getClient()?.walletGetAssets(t)??{}},async estimateGas(t){return G._getClient()?.estimateGas(t)},async writeContract(t){return G._getClient()?.writeContract(t)},async getEnsAddress(t){return G._getClient()?.getEnsAddress(t)},async getEnsAvatar(t){return G._getClient()?.getEnsAvatar(t)},checkInstalled(t){return G._getClient()?.checkInstalled?.(t)||!1},resetWcConnection(){be.wcUri=void 0,be.wcPairingExpiry=void 0,be.wcLinking=void 0,be.recentWallet=void 0,be.status="disconnected",Ei.resetTransactions(),B.deleteWalletConnectDeepLink(),B.deleteRecentWallet()},resetUri(){be.wcUri=void 0,be.wcPairingExpiry=void 0,en=void 0},finalizeWcConnection(t){const{wcLinking:e,recentWallet:s}=G.state;e&&B.setWalletConnectDeepLink(e),s&&B.setAppKitRecent(s),t&&le.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:t,properties:{method:e?"mobile":"qrcode",name:ne.state.data?.wallet?.name||"Unknown",view:ne.state.view,walletRank:s?.order}})},setWcBasic(t){be.wcBasic=t},setUri(t){be.wcUri=t,be.wcPairingExpiry=J.getPairingExpiry()},setWcLinking(t){be.wcLinking=t},setWcError(t){be.wcError=t,be.buffering=!1},setRecentWallet(t){be.recentWallet=t},setBuffering(t){be.buffering=t},setStatus(t){be.status=t},setIsSwitchingConnection(t){be.isSwitchingConnection=t},async disconnect({id:t,namespace:e,initialDisconnect:s}={}){try{await G._getClient()?.disconnect({id:t,chainNamespace:e,initialDisconnect:s})}catch(n){throw new bn("Failed to disconnect","INTERNAL_SDK_ERROR",n)}},async disconnectConnector({id:t,namespace:e}){try{await G._getClient()?.disconnectConnector({id:t,namespace:e})}catch(s){throw new bn("Failed to disconnect connector","INTERNAL_SDK_ERROR",s)}},setConnections(t,e){const s=new Map(be.connections);s.set(e,t),be.connections=s},async handleAuthAccountSwitch({address:t,namespace:e}){const n=f.getAccountData(e)?.user?.accounts?.find(i=>i.type==="smartAccount"),r=n&&n.address.toLowerCase()===t.toLowerCase()&&lr.canSwitchToSmartAccount(e)?"smartAccount":"eoa";await G.setPreferredAccountType(r,e)},async handleActiveConnection({connection:t,namespace:e,address:s}){const n=F.getConnectorById(t.connectorId),r=t.connectorId===x.CONNECTOR_ID.AUTH;if(!n)throw new Error(`No connector found for connection: ${t.connectorId}`);if(r)r&&s&&await G.handleAuthAccountSwitch({address:s,namespace:e});else return(await G.connectExternal({id:n.id,type:n.type,provider:n.provider,address:s,chain:e},e))?.address;return s},async handleDisconnectedConnection({connection:t,namespace:e,address:s,closeModalOnConnect:n}){const r=F.getConnectorById(t.connectorId),i=t.auth?.name?.toLowerCase(),o=t.connectorId===x.CONNECTOR_ID.AUTH,a=t.connectorId===x.CONNECTOR_ID.WALLET_CONNECT;if(!r)throw new Error(`No connector found for connection: ${t.connectorId}`);let c;if(o)if(i&&lr.isSocialProvider(i)){const{address:l}=await lr.connectSocial({social:i,closeModalOnConnect:n,onOpenFarcaster(){he.open({view:"ConnectingFarcaster"})},onConnect(){ne.replace("ProfileWallets")}});c=l}else{const{address:l}=await lr.connectEmail({closeModalOnConnect:n,onOpen(){he.open({view:"EmailLogin"})},onConnect(){ne.replace("ProfileWallets")}});c=l}else if(a){const{address:l}=await lr.connectWalletConnect({walletConnect:!0,connector:r,closeModalOnConnect:n,onOpen(u){const d=u?"AllWallets":"ConnectingWalletConnect";he.state.open?ne.push(d):he.open({view:d})},onConnect(){ne.replace("ProfileWallets")}});c=l}else{const l=await G.connectExternal({id:r.id,type:r.type,provider:r.provider,chain:e},e);l&&(c=l.address)}return o&&s&&await G.handleAuthAccountSwitch({address:s,namespace:e}),c},async switchConnection({connection:t,address:e,namespace:s,closeModalOnConnect:n,onChange:r}){let i;const o=f.getAccountData(s)?.caipAddress;if(o){const{address:c}=ot.parseCaipAddress(o);i=c}const a=Pi.getConnectionStatus(t,s);switch(a){case"connected":case"active":{const c=await G.handleActiveConnection({connection:t,namespace:s,address:e});if(i&&c){const l=c.toLowerCase()!==i.toLowerCase();r?.({address:c,namespace:s,hasSwitchedAccount:l,hasSwitchedWallet:a==="active"})}break}case"disconnected":{const c=await G.handleDisconnectedConnection({connection:t,namespace:s,address:e,closeModalOnConnect:n});c&&r?.({address:c,namespace:s,hasSwitchedAccount:!0,hasSwitchedWallet:!0});break}default:throw new Error(`Invalid connection status: ${a}`)}}},G=jt(Cf),mo={createBalance(t,e){const s={name:t.metadata.name||"",symbol:t.metadata.symbol||"",decimals:t.metadata.decimals||0,value:t.metadata.value||0,price:t.metadata.price||0,iconUrl:t.metadata.iconUrl||""};return{name:s.name,symbol:s.symbol,chainId:e,address:t.address==="native"?void 0:this.convertAddressToCAIP10Address(t.address,e),value:s.value,price:s.price,quantity:{decimals:s.decimals.toString(),numeric:this.convertHexToBalance({hex:t.balance,decimals:s.decimals})},iconUrl:s.iconUrl}},convertHexToBalance({hex:t,decimals:e}){return Ju(BigInt(t),e)},convertAddressToCAIP10Address(t,e){return`${e}:${t}`},createCAIP2ChainId(t,e){return`${e}:${parseInt(t,16)}`},getChainIdHexFromCAIP2ChainId(t){const e=t.split(":");if(e.length<2||!e[1])return"0x0";const s=e[1],n=parseInt(s,10);return isNaN(n)?"0x0":`0x${n.toString(16)}`},isWalletGetAssetsResponse(t){return typeof t!="object"||t===null?!1:Object.values(t).every(e=>Array.isArray(e)&&e.every(s=>this.isValidAsset(s)))},isValidAsset(t){return typeof t=="object"&&t!==null&&typeof t.address=="string"&&typeof t.balance=="string"&&(t.type==="ERC20"||t.type==="NATIVE")&&typeof t.metadata=="object"&&t.metadata!==null&&typeof t.metadata.name=="string"&&typeof t.metadata.symbol=="string"&&typeof t.metadata.decimals=="number"&&typeof t.metadata.price=="number"&&typeof t.metadata.iconUrl=="string"}};let wo;async function Tc(){if(!wo){const{createPublicClient:t,http:e,defineChain:s}=await Oi(async()=>{const{createPublicClient:n,http:r,defineChain:i}=await import("./index-D7396TWe.js");return{createPublicClient:n,http:r,defineChain:i}},__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]),import.meta.url);wo={createPublicClient:t,http:e,defineChain:s}}return wo}const ta={getBlockchainApiRpcUrl(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()},async getViemChain(t){const{defineChain:e}=await Tc(),{chainId:s}=ot.parseCaipNetworkId(t.caipNetworkId);return e({...t,id:Number(s)})},async createViemPublicClient(t){const{createPublicClient:e,http:s}=await Tc(),n=R.state.projectId,r=await ta.getViemChain(t);if(!r)throw new Error(`Chain ${t.caipNetworkId} not found in viem/chains`);return e({chain:r,transport:s(ta.getBlockchainApiRpcUrl(t.caipNetworkId,n))})}},Wa={async getMyTokensWithBalance(t){const e=f.getAccountData()?.address,s=f.state.activeCaipNetwork,n=F.getConnectorId("eip155")===x.CONNECTOR_ID.AUTH;if(!e||!s)return[];const r=`${s.caipNetworkId}:${e}`,i=B.getBalanceCacheForCaipAddress(r);if(i)return i.balances;if(s.chainNamespace===x.CHAIN.EVM&&n){const a=await this.getEIP155Balances(e,s);if(a)return this.filterLowQualityTokens(a)}const o=await re.getBalance(e,s.caipNetworkId,t);return this.filterLowQualityTokens(o.balances)},async getEIP155Balances(t,e){try{const s=mo.getChainIdHexFromCAIP2ChainId(e.caipNetworkId);if(!(await G.getCapabilities(t))?.[s]?.assetDiscovery?.supported)return null;const r=await G.walletGetAssets({account:t,chainFilter:[s]});if(!mo.isWalletGetAssetsResponse(r))return null;const o=(r[s]||[]).map(a=>mo.createBalance(a,e.caipNetworkId));return B.updateBalanceCache({caipAddress:`${e.caipNetworkId}:${t}`,balance:{balances:o},timestamp:Date.now()}),o}catch{return null}},filterLowQualityTokens(t){return t.filter(e=>e.quantity.decimals!=="0")},async fetchERC20Balance({caipAddress:t,assetAddress:e,caipNetwork:s}){const n=await ta.createViemPublicClient(s),{address:r}=ot.parseCaipAddress(t),[{result:i},{result:o},{result:a},{result:c}]=await n.multicall({contracts:[{address:e,functionName:"name",args:[],abi:ni},{address:e,functionName:"symbol",args:[],abi:ni},{address:e,functionName:"balanceOf",args:[r],abi:ni},{address:e,functionName:"decimals",args:[],abi:ni}]});return{name:i,symbol:o,decimals:c,balance:a&&c?Ju(a,c):"0"}}},kn=ke({loading:!1,open:!1,selectedNetworkId:void 0,activeChain:void 0,initialized:!1}),vs={state:kn,subscribe(t){return Je(kn,()=>t(kn))},subscribeOpen(t){return Xe(kn,"open",t)},set(t){Object.assign(kn,{...kn,...t})}},vf={async getTokenList(t){return(await re.fetchSwapTokens({chainId:t}))?.tokens?.map(n=>({...n,eip2612:!1,quantity:{decimals:"0",numeric:"0"},price:0,value:0}))||[]},async fetchGasPrice(){const t=f.state.activeCaipNetwork;if(!t)return null;try{if(t.chainNamespace==="solana"){const e=(await G?.estimateGas({chainNamespace:"solana"}))?.toString();return{standard:e,fast:e,instant:e}}else return await re.fetchGasPrice({chainId:t.caipNetworkId})}catch{return null}},async fetchSwapAllowance({tokenAddress:t,userAddress:e,sourceTokenAmount:s,sourceTokenDecimals:n}){const r=await re.fetchSwapAllowance({tokenAddress:t,userAddress:e});if(r?.allowance&&s&&n){const i=G.parseUnits(s,n)||0;return BigInt(r.allowance)>=i}return!1},async getMyTokensWithBalance(t){const e=await Wa.getMyTokensWithBalance(t);return f.setAccountProp("tokenBalance",e,f.state.activeChain),this.mapBalancesToSwapTokens(e)},mapBalancesToSwapTokens(t){return t?.map(e=>({...e,address:e?.address?e.address:ad(),decimals:parseInt(e.quantity.decimals,10),logoUri:e.iconUrl,eip2612:!1}))||[]},async handleSwapError(t){try{const e=t?.cause;return e?.json&&(await e.json())?.reasons?.[0]?.description?.includes("insufficient liquidity")?"Insufficient liquidity":void 0}catch{return}}},ge=ke({tokenBalances:[],loading:!1}),Af={state:ge,subscribe(t){return Je(ge,()=>t(ge))},subscribeKey(t,e){return Xe(ge,t,e)},setToken(t){t&&(ge.token=Xn(t))},setTokenAmount(t){ge.sendTokenAmount=t},setReceiverAddress(t){ge.receiverAddress=t},setReceiverProfileImageUrl(t){ge.receiverProfileImageUrl=t},setReceiverProfileName(t){ge.receiverProfileName=t},setNetworkBalanceInUsd(t){ge.networkBalanceInUSD=t},setLoading(t){ge.loading=t},getSdkEventProperties(t){return{message:J.parseError(t),isSmartAccount:Lt(f.state.activeChain)===Cs.ACCOUNT_TYPES.SMART_ACCOUNT,token:ge.token?.symbol||"",amount:ge.sendTokenAmount??0,network:f.state.activeCaipNetwork?.caipNetworkId||""}},async sendToken(){try{switch(ce.setLoading(!0),f.state.activeCaipNetwork?.chainNamespace){case"eip155":await ce.sendEvmToken();return;case"solana":await ce.sendSolanaToken();return;default:throw new Error("Unsupported chain")}}catch(t){throw Ks.isUserRejectedRequestError(t)?new td(t):t}finally{ce.setLoading(!1)}},async sendEvmToken(){const t=f.state.activeChain;if(!t)throw new Error("SendController:sendEvmToken - activeChainNamespace is required");const e=Lt(t);if(!ce.state.sendTokenAmount||!ce.state.receiverAddress)throw new Error("An amount and receiver address are required");if(!ce.state.token)throw new Error("A token is required");if(ce.state.token?.address){le.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Cs.ACCOUNT_TYPES.SMART_ACCOUNT,token:ce.state.token.address,amount:ce.state.sendTokenAmount,network:f.state.activeCaipNetwork?.caipNetworkId||""}});const{hash:s}=await ce.sendERC20Token({receiverAddress:ce.state.receiverAddress,tokenAddress:ce.state.token.address,sendTokenAmount:ce.state.sendTokenAmount,decimals:ce.state.token.quantity.decimals});s&&(ge.hash=s)}else{le.sendEvent({type:"track",event:"SEND_INITIATED",properties:{isSmartAccount:e===Cs.ACCOUNT_TYPES.SMART_ACCOUNT,token:ce.state.token.symbol||"",amount:ce.state.sendTokenAmount,network:f.state.activeCaipNetwork?.caipNetworkId||""}});const{hash:s}=await ce.sendNativeToken({receiverAddress:ce.state.receiverAddress,sendTokenAmount:ce.state.sendTokenAmount,decimals:ce.state.token.quantity.decimals});s&&(ge.hash=s)}},async fetchTokenBalance(t){ge.loading=!0;const e=f.state.activeChain,s=f.state.activeCaipNetwork?.caipNetworkId,n=f.state.activeCaipNetwork?.chainNamespace,r=f.getAccountData(e)?.caipAddress??f.state.activeCaipAddress,i=r?J.getPlainAddress(r):void 0;if(ge.lastRetry&&!J.isAllowedRetry(ge.lastRetry,30*me.ONE_SEC_MS))return ge.loading=!1,[];try{if(i&&s&&n){const o=await Wa.getMyTokensWithBalance();return ge.tokenBalances=o,ge.lastRetry=void 0,o}}catch(o){ge.lastRetry=Date.now(),t?.(o),is.showError("Token Balance Unavailable")}finally{ge.loading=!1}return[]},fetchNetworkBalance(){if(ge.tokenBalances.length===0)return;const t=vf.mapBalancesToSwapTokens(ge.tokenBalances);if(!t)return;const e=t.find(s=>s.address===ad());e&&(ge.networkBalanceInUSD=e?Pp.multiply(e.quantity.numeric,e.price).toString():"0")},async sendNativeToken(t){ne.pushTransactionStack({});const e=t.receiverAddress,s=f.getAccountData()?.address,n=G.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),i=await G.sendTransaction({chainNamespace:x.CHAIN.EVM,to:e,address:s,data:"0x",value:n??BigInt(0)});return le.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:Lt("eip155")===Cs.ACCOUNT_TYPES.SMART_ACCOUNT,token:ce.state.token?.symbol||"",amount:t.sendTokenAmount,network:f.state.activeCaipNetwork?.caipNetworkId||"",hash:i||""}}),G._getClient()?.updateBalance("eip155"),ce.resetSend(),{hash:i}},async sendERC20Token(t){ne.pushTransactionStack({onSuccess(){ne.replace("Account")}});const e=G.parseUnits(t.sendTokenAmount.toString(),Number(t.decimals)),s=f.getAccountData()?.address;if(s&&t.sendTokenAmount&&t.receiverAddress&&t.tokenAddress){const n=J.getPlainAddress(t.tokenAddress);if(!n)throw new Error("SendController:sendERC20Token - tokenAddress is required");const r=await G.writeContract({fromAddress:s,tokenAddress:n,args:[t.receiverAddress,e??BigInt(0)],method:"transfer",abi:Up.getERC20Abi(n),chainNamespace:x.CHAIN.EVM});return le.sendEvent({type:"track",event:"SEND_SUCCESS",properties:{isSmartAccount:Lt("eip155")===Cs.ACCOUNT_TYPES.SMART_ACCOUNT,token:ce.state.token?.symbol||"",amount:t.sendTokenAmount,network:f.state.activeCaipNetwork?.caipNetworkId||"",hash:r||""}}),ce.resetSend(),{hash:r}}return{hash:void 0}},async sendSolanaToken(){if(!ce.state.sendTokenAmount||!ce.state.receiverAddress)throw new Error("An amount and receiver address are required");ne.pushTransactionStack({onSuccess(){ne.replace("Account")}});let t;ce.state.token&&ce.state.token.address!==me.SOLANA_NATIVE_TOKEN_ADDRESS&&(J.isCaipAddress(ce.state.token.address)?t=J.getPlainAddress(ce.state.token.address):t=ce.state.token.address);const e=await G.sendTransaction({chainNamespace:"solana",tokenMint:t,to:ce.state.receiverAddress,value:ce.state.sendTokenAmount});e&&(ge.hash=e),G._getClient()?.updateBalance("solana"),ce.resetSend()},resetSend(){ge.token=void 0,ge.sendTokenAmount=void 0,ge.receiverAddress=void 0,ge.receiverProfileImageUrl=void 0,ge.receiverProfileName=void 0,ge.loading=!1,ge.tokenBalances=[]}},ce=jt(Af),yo={currentTab:0,tokenBalance:[],smartAccountDeployed:!1,addressLabels:new Map,user:void 0,preferredAccountType:void 0},ai={caipNetwork:void 0,supportsAllNetworks:!0,smartAccountEnabledNetworks:[]},K=ke({chains:Jp(),activeCaipAddress:void 0,activeChain:void 0,activeCaipNetwork:void 0,noAdapters:!1,universalAdapter:{networkControllerClient:void 0,connectionControllerClient:void 0},isSwitchingNamespace:!1}),cd={state:K,subscribe(t){return Je(K,()=>{t(K)})},subscribeKey(t,e){return Xe(K,t,e)},subscribeAccountStateProp(t,e,s){const n=s||K.activeChain;return n?Xe(K.chains.get(n)?.accountState||{},t,e):()=>{}},subscribeChainProp(t,e,s){let n;return Je(K.chains,()=>{const r=s||K.activeChain;if(r){const i=K.chains.get(r)?.[t];n!==i&&(n=i,e(i))}})},initialize(t,e,s){const{chainId:n,namespace:r}=B.getActiveNetworkProps(),i=e?.find(u=>u.id.toString()===n?.toString()),a=t.find(u=>u?.namespace===r)||t?.[0],c=t.map(u=>u.namespace).filter(u=>u!==void 0),l=R.state.enableEmbedded?new Set([...c]):new Set([...e?.map(u=>u.chainNamespace)??[]]);(t?.length===0||!a)&&(K.noAdapters=!0),K.noAdapters||(K.activeChain=a?.namespace,K.activeCaipNetwork=i,f.setChainNetworkData(a?.namespace,{caipNetwork:i}),K.activeChain&&vs.set({activeChain:a?.namespace})),l.forEach(u=>{const d=e?.filter(g=>g.chainNamespace===u),h=B.getPreferredAccountTypes()||{},m={...R.state.defaultAccountTypes,...h};f.state.chains.set(u,{namespace:u,networkState:ke({...ai,caipNetwork:d?.[0]}),accountState:ke({...yo,preferredAccountType:m[u]}),caipNetworks:d??[],...s}),f.setRequestedCaipNetworks(d??[],u)})},removeAdapter(t){if(K.activeChain===t){const e=Array.from(K.chains.entries()).find(([s])=>s!==t);if(e){const s=e[1]?.caipNetworks?.[0];s&&f.setActiveCaipNetwork(s)}}K.chains.delete(t)},addAdapter(t,{networkControllerClient:e,connectionControllerClient:s},n){if(!t.namespace)throw new Error("ChainController:addAdapter - adapter must have a namespace");K.chains.set(t.namespace,{namespace:t.namespace,networkState:{...ai,caipNetwork:n[0]},accountState:{...yo},caipNetworks:n,connectionControllerClient:s,networkControllerClient:e}),f.setRequestedCaipNetworks(n?.filter(r=>r.chainNamespace===t.namespace)??[],t.namespace)},addNetwork(t){const e=K.chains.get(t.chainNamespace);if(e){const s=[...e.caipNetworks||[]];e.caipNetworks?.find(n=>n.id===t.id)||s.push(t),K.chains.set(t.chainNamespace,{...e,caipNetworks:s}),f.setRequestedCaipNetworks(s,t.chainNamespace),F.filterByNamespace(t.chainNamespace,!0)}},removeNetwork(t,e){const s=K.chains.get(t);if(s){const n=K.activeCaipNetwork?.id===e,r=[...s.caipNetworks?.filter(i=>i.id!==e)||[]];n&&s?.caipNetworks?.[0]&&f.setActiveCaipNetwork(s.caipNetworks[0]),K.chains.set(t,{...s,caipNetworks:r}),f.setRequestedCaipNetworks(r||[],t),r.length===0&&F.filterByNamespace(t,!1)}},setAdapterNetworkState(t,e){const s=K.chains.get(t);s&&(s.networkState={...s.networkState||ai,...e},K.chains.set(t,s))},setChainAccountData(t,e,s=!0){if(!t)throw new Error("Chain is required to update chain account data");const n=K.chains.get(t);if(n){const r={...n.accountState||yo,...e};K.chains.set(t,{...n,accountState:r}),(K.chains.size===1||K.activeChain===t)&&e.caipAddress&&(K.activeCaipAddress=e.caipAddress)}},setChainNetworkData(t,e){if(!t)return;const s=K.chains.get(t);if(s){const n={...s.networkState||ai,...e};K.chains.set(t,{...s,networkState:n})}},setAccountProp(t,e,s,n=!0){f.setChainAccountData(s,{[t]:e},n)},setActiveNamespace(t){K.activeChain=t;const e=t?K.chains.get(t):void 0,s=e?.networkState?.caipNetwork;s?.id&&t&&(K.activeCaipAddress=e?.accountState?.caipAddress,K.activeCaipNetwork=s,f.setChainNetworkData(t,{caipNetwork:s}),B.setActiveCaipNetworkId(s?.caipNetworkId),vs.set({activeChain:t,selectedNetworkId:s?.caipNetworkId}))},setActiveCaipNetwork(t){if(!t)return;const e=K.activeChain===t.chainNamespace;e||f.setIsSwitchingNamespace(!0);const s=K.chains.get(t.chainNamespace);K.activeChain=t.chainNamespace,K.activeCaipNetwork=t,f.setChainNetworkData(t.chainNamespace,{caipNetwork:t});let n=s?.accountState?.address;if(n)K.activeCaipAddress=`${t.chainNamespace}:${t.id}:${n}`;else if(e&&K.activeCaipAddress){const{address:i}=ot.parseCaipAddress(K.activeCaipAddress);n=i,K.activeCaipAddress=`${t.caipNetworkId}:${n}`}else K.activeCaipAddress=void 0;f.setChainAccountData(t.chainNamespace,{address:n,caipAddress:K.activeCaipAddress}),ce.resetSend(),vs.set({activeChain:K.activeChain,selectedNetworkId:K.activeCaipNetwork?.caipNetworkId}),B.setActiveCaipNetworkId(t.caipNetworkId),!f.checkIfSupportedNetwork(t.chainNamespace)&&R.state.enableNetworkSwitch&&!R.state.allowUnsupportedChain&&!G.state.wcBasic&&f.showUnsupportedChainUI()},addCaipNetwork(t){if(!t)return;const e=K.chains.get(t.chainNamespace);e&&e?.caipNetworks?.push(t)},async switchActiveNamespace(t){if(!t)return;const e=t!==f.state.activeChain,s=f.getNetworkData(t)?.caipNetwork,n=f.getCaipNetworkByNamespace(t,s?.id);e&&n&&await f.switchActiveNetwork(n)},async switchActiveNetwork(t,{throwOnFailure:e=!1}={}){const s=f.state.activeChain;if(!s)throw new Error("ChainController:switchActiveNetwork - namespace is required");const r=!f.state.chains.get(s)?.caipNetworks?.some(o=>o.id===K.activeCaipNetwork?.id),i=f.getNetworkControllerClient(t.chainNamespace);if(i){try{await i.switchCaipNetwork(t),r&&he.close()}catch(o){if(e)throw o;ne.goBack()}le.sendEvent({type:"track",event:"SWITCH_NETWORK",properties:{network:t.caipNetworkId}})}},getNetworkControllerClient(t){const e=t||K.activeChain;if(!e)throw new Error("ChainController:getNetworkControllerClient - chain is required");const s=K.chains.get(e);if(!s)throw new Error("Chain adapter not found");if(!s.networkControllerClient)throw new Error("NetworkController client not set");return s.networkControllerClient},getConnectionControllerClient(t){const e=t||K.activeChain;if(!e)throw new Error("Chain is required to get connection controller client");const s=K.chains.get(e);if(!s?.connectionControllerClient)throw new Error("ConnectionController client not set");return s.connectionControllerClient},getNetworkProp(t,e){const s=K.chains.get(e)?.networkState;if(s)return s[t]},getRequestedCaipNetworks(t){const e=K.chains.get(t),{approvedCaipNetworkIds:s=[],requestedCaipNetworks:n=[]}=e?.networkState||{};return J.sortRequestedNetworks(s,n).filter(o=>o?.id)},getAllRequestedCaipNetworks(){const t=[];return K.chains.forEach(e=>{if(!e.namespace)throw new Error("ChainController:getAllRequestedCaipNetworks - chainAdapter must have a namespace");const s=f.getRequestedCaipNetworks(e.namespace);t.push(...s)}),t},setRequestedCaipNetworks(t,e){f.setAdapterNetworkState(e,{requestedCaipNetworks:t});const n=f.getAllRequestedCaipNetworks().map(i=>i.chainNamespace),r=Array.from(new Set(n));F.filterByNamespaces(r)},getAllApprovedCaipNetworkIds(){const t=[];return K.chains.forEach(e=>{if(!e.namespace)throw new Error("ChainController:getAllApprovedCaipNetworkIds - chainAdapter must have a namespace");const s=f.getApprovedCaipNetworkIds(e.namespace);t.push(...s)}),t},getActiveCaipNetwork(t){return t?K.chains.get(t)?.networkState?.caipNetwork:K.activeCaipNetwork},getActiveCaipAddress(){return K.activeCaipAddress},getApprovedCaipNetworkIds(t){return K.chains.get(t)?.networkState?.approvedCaipNetworkIds||[]},async setApprovedCaipNetworksData(t){const s=await f.getNetworkControllerClient()?.getApprovedCaipNetworksData();f.setAdapterNetworkState(t,{approvedCaipNetworkIds:s?.approvedCaipNetworkIds,supportsAllNetworks:s?.supportsAllNetworks})},checkIfSupportedNetwork(t,e){const s=e||K.activeCaipNetwork?.caipNetworkId,n=f.getRequestedCaipNetworks(t);return n.length?n?.some(r=>r.caipNetworkId===s):!0},checkIfSupportedChainId(t){return K.activeChain?f.getRequestedCaipNetworks(K.activeChain)?.some(s=>s.id===t):!0},setSmartAccountEnabledNetworks(t,e){f.setAdapterNetworkState(e,{smartAccountEnabledNetworks:t})},checkIfSmartAccountEnabled(){const t=Xu.caipNetworkIdToNumber(K.activeCaipNetwork?.caipNetworkId),e=K.activeChain;return!e||!t?!1:!!f.getNetworkProp("smartAccountEnabledNetworks",e)?.includes(Number(t))},showUnsupportedChainUI(){he.open({view:"UnsupportedChain"})},checkIfNamesSupported(){const t=K.activeCaipNetwork;return!!(t?.chainNamespace&&me.NAMES_SUPPORTED_CHAIN_NAMESPACES.includes(t.chainNamespace))},resetNetwork(t){f.setAdapterNetworkState(t,{approvedCaipNetworkIds:void 0,supportsAllNetworks:!0})},resetAccount(t){const e=t;if(!e)throw new Error("Chain is required to set account prop");const s=f.state.chains.get(e)?.accountState?.preferredAccountType,n=R.state.defaultAccountTypes[e];K.activeCaipAddress=void 0,f.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:n||s,socialProvider:void 0,socialWindow:void 0,farcasterUrl:void 0,user:void 0,status:"disconnected"}),F.removeConnectorId(e)},setIsSwitchingNamespace(t){K.isSwitchingNamespace=t},getFirstCaipNetworkSupportsAuthConnector(){const t=[];let e;if(K.chains.forEach(s=>{x.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(n=>n===s.namespace)&&s.namespace&&t.push(s.namespace)}),t.length>0){const s=t[0];return e=s?K.chains.get(s)?.caipNetworks?.[0]:void 0,e}},getAccountData(t){const e=t||K.activeChain;if(e)return f.state.chains.get(e)?.accountState},getNetworkData(t){const e=t||K.activeChain;if(e)return f.state.chains.get(e)?.networkState},getCaipNetworkByNamespace(t,e){if(!t)return;const s=f.state.chains.get(t),n=s?.caipNetworks?.find(r=>r.id===e);return n||s?.networkState?.caipNetwork||s?.caipNetworks?.[0]},getRequestedCaipNetworkIds(){const t=F.state.filterByNamespace;return(t?[K.chains.get(t)]:Array.from(K.chains.values())).flatMap(s=>s?.caipNetworks||[]).map(s=>s.caipNetworkId)},getCaipNetworks(t){return t?f.getRequestedCaipNetworks(t):f.getAllRequestedCaipNetworks()},getCaipNetworkById(t,e){return cd.getCaipNetworks(e).find(s=>s.id.toString()===t.toString()||s.caipNetworkId.toString()===t.toString())},setLastConnectedSIWECaipNetwork(t){K.lastConnectedSIWECaipNetwork=t},getLastConnectedSIWECaipNetwork(){return K.lastConnectedSIWECaipNetwork},async fetchTokenBalance(t){const e=f.getAccountData();if(!e)return[];const s=f.state.activeCaipNetwork?.caipNetworkId,n=f.state.activeCaipNetwork?.chainNamespace,r=f.state.activeCaipAddress,i=r?J.getPlainAddress(r):void 0;if(f.setAccountProp("balanceLoading",!0,n),e.lastRetry&&!J.isAllowedRetry(e.lastRetry,30*me.ONE_SEC_MS))return f.setAccountProp("balanceLoading",!1,n),[];try{if(i&&s&&n){const o=await Wa.getMyTokensWithBalance();return f.setAccountProp("tokenBalance",o,n),f.setAccountProp("lastRetry",void 0,n),f.setAccountProp("balanceLoading",!1,n),o}}catch(o){f.setAccountProp("lastRetry",Date.now(),n),t?.(o),is.showError("Token Balance Unavailable")}finally{f.setAccountProp("balanceLoading",!1,n)}return[]},isCaipNetworkDisabled(t){const e=t.chainNamespace,s=!!f.getAccountData(e)?.caipAddress,n=f.getAllApprovedCaipNetworkIds(),r=f.getNetworkProp("supportsAllNetworks",e)!==!1,i=F.getConnectorId(e),o=F.getAuthConnector(),a=i===x.CONNECTOR_ID.AUTH&&o;return!s||r||a?!1:!n?.includes(t.caipNetworkId)}},f=jt(cd),If={onSwitchNetwork({network:t,ignoreSwitchConfirmation:e=!1}){const s=f.state.activeCaipNetwork,n=f.state.activeChain,r=ne.state.data;if(t.id===s?.id)return;const o=!!f.getAccountData(n)?.address,a=!!f.getAccountData(t.chainNamespace)?.address,c=t.chainNamespace!==n,u=F.getConnectorId(n)===x.CONNECTOR_ID.AUTH,d=x.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(h=>h===t.chainNamespace);e||u&&d?ne.push("SwitchNetwork",{...r,network:t}):o&&c&&!a?ne.push("SwitchActiveChain",{switchToChain:t.chainNamespace,navigateTo:"Connect",navigateWithReplace:!0,network:t}):ne.push("SwitchNetwork",{...r,network:t})}},ht=ke({loading:!1,loadingNamespaceMap:new Map,open:!1,shake:!1,namespace:void 0}),Nf={state:ht,subscribe(t){return Je(ht,()=>t(ht))},subscribeKey(t,e){return Xe(ht,t,e)},async open(t){const e=t?.namespace,s=f.state.activeChain,n=e&&e!==s,r=f.getAccountData(t?.namespace)?.caipAddress,i=f.state.noAdapters;if(G.state.wcBasic?te.prefetch({fetchNetworkImages:!1,fetchConnectorImages:!1,fetchWalletRanks:!1}):await te.prefetch(),F.setFilterByNamespace(t?.namespace),he.setLoading(!0,e),e&&n){const o=f.getNetworkData(e)?.caipNetwork||f.getRequestedCaipNetworks(e)[0];o&&(i?(await f.switchActiveNetwork(o),ne.push("ConnectingWalletConnectBasic")):If.onSwitchNetwork({network:o,ignoreSwitchConfirmation:!0}))}else R.state.manualWCControl||i&&!r?J.isMobile()?ne.reset("AllWallets"):ne.reset("ConnectingWalletConnectBasic"):t?.view?ne.reset(t.view,t.data):r?ne.reset("Account"):ne.reset("Connect");ht.open=!0,vs.set({open:!0}),le.sendEvent({type:"track",event:"MODAL_OPEN",properties:{connected:!!r}})},close(){const t=R.state.enableEmbedded,e=!!f.state.activeCaipAddress;ht.open&&le.sendEvent({type:"track",event:"MODAL_CLOSE",properties:{connected:e}}),ht.open=!1,ne.reset("Connect"),he.clearLoading(),t?e?ne.replace("Account"):ne.push("Connect"):vs.set({open:!1}),G.resetUri()},setLoading(t,e){e&&ht.loadingNamespaceMap.set(e,t),ht.loading=t,vs.set({loading:t})},clearLoading(){ht.loadingNamespaceMap.clear(),ht.loading=!1,vs.set({loading:!1})},shake(){ht.shake||(ht.shake=!0,setTimeout(()=>{ht.shake=!1},500))}},he=jt(Nf),Ri={eip155:void 0,solana:void 0,polkadot:void 0,bip122:void 0,cosmos:void 0,sui:void 0,stacks:void 0},pt=ke({providers:{...Ri},providerIds:{...Ri}}),Re={state:pt,subscribeKey(t,e){return Xe(pt,t,e)},subscribe(t){return Je(pt,()=>{t(pt)})},subscribeProviders(t){return Je(pt.providers,()=>t(pt.providers))},setProvider(t,e){t&&e&&(pt.providers[t]=Xn(e))},getProvider(t){if(t)return pt.providers[t]},setProviderId(t,e){e&&(pt.providerIds[t]=e)},getProviderId(t){if(t)return pt.providerIds[t]},reset(){pt.providers={...Ri},pt.providerIds={...Ri}},resetChain(t){pt.providers[t]=void 0,pt.providerIds[t]=void 0}},_r={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"}]},sa={id:"USD",payment_method_limits:[{id:"card",min:"10.00",max:"7500.00"},{id:"ach_bank_account",min:"10.00",max:"25000.00"}]},_f={providers:nd,selectedProvider:null,error:null,purchaseCurrency:_r,paymentCurrency:sa,purchaseCurrencies:[_r],paymentCurrencies:[],quotesLoading:!1},we=ke(_f),Sf={state:we,subscribe(t){return Je(we,()=>t(we))},subscribeKey(t,e){return Xe(we,t,e)},setSelectedProvider(t){if(t&&t.name==="meld"){const e=f.state.activeChain,s=e===x.CHAIN.SOLANA?"SOL":"USDC",n=e?f.state.chains.get(e)?.accountState?.address??"":"",r=new URL(t.url);r.searchParams.append("publicKey",Xp),r.searchParams.append("destinationCurrencyCode",s),r.searchParams.append("walletAddress",n),r.searchParams.append("externalCustomerId",R.state.projectId),we.selectedProvider={...t,url:r.toString()}}else we.selectedProvider=t},setOnrampProviders(t){if(Array.isArray(t)&&t.every(e=>typeof e=="string")){const e=t,s=nd.filter(n=>e.includes(n.name));we.providers=s}else we.providers=[]},setPurchaseCurrency(t){we.purchaseCurrency=t},setPaymentCurrency(t){we.paymentCurrency=t},setPurchaseAmount(t){na.state.purchaseAmount=t},setPaymentAmount(t){na.state.paymentAmount=t},async getAvailableCurrencies(){const t=await re.getOnrampOptions();we.purchaseCurrencies=t.purchaseCurrencies,we.paymentCurrencies=t.paymentCurrencies,we.paymentCurrency=t.paymentCurrencies[0]||sa,we.purchaseCurrency=t.purchaseCurrencies[0]||_r,await te.fetchCurrencyImages(t.paymentCurrencies.map(e=>e.id)),await te.fetchTokenImages(t.purchaseCurrencies.map(e=>e.symbol))},async getQuote(){we.quotesLoading=!0;try{const t=await re.getOnrampQuote({purchaseCurrency:we.purchaseCurrency,paymentCurrency:we.paymentCurrency,amount:we.paymentAmount?.toString()||"0",network:we.purchaseCurrency?.symbol});return we.quotesLoading=!1,we.purchaseAmount=Number(t?.purchaseAmount.amount),t}catch(t){return we.error=t.message,we.quotesLoading=!1,null}finally{we.quotesLoading=!1}},resetState(){we.selectedProvider=null,we.error=null,we.purchaseCurrency=_r,we.paymentCurrency=sa,we.purchaseCurrencies=[_r],we.paymentCurrencies=[],we.paymentAmount=void 0,we.purchaseAmount=void 0,we.quotesLoading=!1}},na=jt(Sf),qt=ke({message:"",variant:"info",open:!1}),Tf={state:qt,subscribeKey(t,e){return Xe(qt,t,e)},open(t,e){const{debug:s}=R.state,{code:n,displayMessage:r,debugMessage:i}=t;r&&s&&(qt.message=r,qt.variant=e,qt.open=!0),i&&console.error(typeof i=="function"?i():i,n?{code:n}:void 0)},warn(t,e,s){qt.open=!0,qt.message=t,qt.variant="warning",e&&console.warn(e,s)},close(){qt.open=!1,qt.message="",qt.variant="info"}},At=jt(Tf),Oc=2147483648,Of={convertEVMChainIdToCoinType(t){if(t>=Oc)throw new Error("Invalid chainId");return(Oc|t)>>>0}},Tt=ke({suggestions:[],loading:!1}),kf={state:Tt,subscribe(t){return Je(Tt,()=>t(Tt))},subscribeKey(t,e){return Xe(Tt,t,e)},async resolveName(t){try{return await re.lookupEnsName(t)}catch(e){const s=e;throw new Error(s?.reasons?.[0]?.description||"Error resolving name")}},async isNameRegistered(t){try{return await re.lookupEnsName(t),!0}catch{return!1}},async getSuggestions(t){try{Tt.loading=!0,Tt.suggestions=[];const e=await re.getEnsNameSuggestions(t);return Tt.suggestions=e.suggestions||[],Tt.suggestions}catch(e){const s=Sr.parseEnsApiError(e,"Error fetching name suggestions");throw new Error(s)}finally{Tt.loading=!1}},async getNamesForAddress(t){try{if(!f.state.activeCaipNetwork)return[];const s=B.getEnsFromCacheForAddress(t);if(s)return s;const n=await re.reverseLookupEnsName({address:t});return B.updateEnsCache({address:t,ens:n,timestamp:Date.now()}),n}catch(e){const s=Sr.parseEnsApiError(e,"Error fetching names for address");throw new Error(s)}},async registerName(t){const e=f.state.activeCaipNetwork,s=f.getAccountData(e?.chainNamespace)?.address,n=F.getAuthConnector();if(!e)throw new Error("Network not found");if(!s||!n)throw new Error("Address or auth connector not found");Tt.loading=!0;try{const r=JSON.stringify({name:t,attributes:{},timestamp:Math.floor(Date.now()/1e3)});ne.pushTransactionStack({onCancel(){ne.replace("RegisterAccountName")}});const i=await G.signMessage(r);Tt.loading=!1;const o=e.id;if(!o)throw new Error("Network not found");const a=Of.convertEVMChainIdToCoinType(Number(o));await re.registerEnsName({coinType:a,address:s,signature:i,message:r}),f.setAccountProp("profileName",t,e.chainNamespace),B.updateEnsCache({address:s,ens:[{name:t,registered_at:new Date().toISOString(),updated_at:void 0,addresses:{},attributes:[]}],timestamp:Date.now()}),ne.replace("RegisterAccountNameSuccess")}catch(r){const i=Sr.parseEnsApiError(r,`Error registering name ${t}`);throw ne.replace("RegisterAccountName"),new Error(i)}finally{Tt.loading=!1}},validateName(t){return/^[a-zA-Z0-9-]{4,}$/u.test(t)},parseEnsApiError(t,e){return t?.reasons?.[0]?.description||e}},Sr=jt(kf),Df={asset:"0x833589fcd6edb6e08f4c7c32d4f71b54bda02913"},Pf={asset:"0x036CbD53842c5426634e7929541eC2318f3dCF7e"};var bo,kc;function Rf(){if(kc)return bo;kc=1;const t=La();bo=r;const e=q().console||{},s={mapHttpRequest:g,mapHttpResponse:g,wrapRequestSerializer:b,wrapResponseSerializer:b,wrapErrorSerializer:b,req:g,res:g,err:h};function n(p,E){return Array.isArray(p)?p.filter(function(A){return A!=="!stdSerializers.err"}):p===!0?Object.keys(E):!1}function r(p){p=p||{},p.browser=p.browser||{};const E=p.browser.transmit;if(E&&typeof E.send!="function")throw Error("pino: transmit option must have a send function");const C=p.browser.write||e;p.browser.write&&(p.browser.asObject=!0);const A=p.serializers||{},S=n(p.browser.serialize,A);let $=p.browser.serialize;Array.isArray(p.browser.serialize)&&p.browser.serialize.indexOf("!stdSerializers.err")>-1&&($=!1);const O=["error","fatal","warn","info","debug","trace"];typeof C=="function"&&(C.error=C.fatal=C.warn=C.info=C.debug=C.trace=C),p.enabled===!1&&(p.level="silent");const v=p.level||"info",w=Object.create(C);w.log||(w.log=y),Object.defineProperty(w,"levelVal",{get:P}),Object.defineProperty(w,"level",{get:U,set:j});const I={transmit:E,serialize:S,asObject:p.browser.asObject,levels:O,timestamp:m(p)};w.levels=r.levels,w.level=v,w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=A,w._serialize=S,w._stdErrSerialize=$,w.child=k,E&&(w._logEvent=d());function P(){return this.level==="silent"?1/0:this.levels.values[this.level]}function U(){return this._level}function j(T){if(T!=="silent"&&!this.levels.values[T])throw Error("unknown level "+T);this._level=T,i(I,w,"error","log"),i(I,w,"fatal","error"),i(I,w,"warn","error"),i(I,w,"info","log"),i(I,w,"debug","log"),i(I,w,"trace","log")}function k(T,W){if(!T)throw new Error("missing bindings for child Pino");W=W||{},S&&T.serializers&&(W.serializers=T.serializers);const z=W.serializers;if(S&&z){var ie=Object.assign({},A,z),oe=p.browser.serialize===!0?Object.keys(ie):S;delete T.serializers,c([T],oe,ie,this._stdErrSerialize)}function se(X){this._childLevel=(X._childLevel|0)+1,this.error=l(X,T,"error"),this.fatal=l(X,T,"fatal"),this.warn=l(X,T,"warn"),this.info=l(X,T,"info"),this.debug=l(X,T,"debug"),this.trace=l(X,T,"trace"),ie&&(this.serializers=ie,this._serialize=oe),E&&(this._logEvent=d([].concat(X._logEvent.bindings,T)))}return se.prototype=this,new se(this)}return w}r.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},r.stdSerializers=s,r.stdTimeFunctions=Object.assign({},{nullTime:_,epochTime:N,unixTime:D,isoTime:M});function i(p,E,C,A){const S=Object.getPrototypeOf(E);E[C]=E.levelVal>E.levels.values[C]?y:S[C]?S[C]:e[C]||e[A]||y,o(p,E,C)}function o(p,E,C){!p.transmit&&E[C]===y||(E[C]=(function(A){return function(){const $=p.timestamp(),O=new Array(arguments.length),v=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var w=0;w<O.length;w++)O[w]=arguments[w];if(p.serialize&&!p.asObject&&c(O,this._serialize,this.serializers,this._stdErrSerialize),p.asObject?A.call(v,a(this,C,O,$)):A.apply(v,O),p.transmit){const I=p.transmit.level||E.level,P=r.levels.values[I],U=r.levels.values[C];if(U<P)return;u(this,{ts:$,methodLevel:C,methodValue:U,transmitValue:r.levels.values[p.transmit.level||E.level],send:p.transmit.send,val:E.levelVal},O)}}})(E[C]))}function a(p,E,C,A){p._serialize&&c(C,p._serialize,p.serializers,p._stdErrSerialize);const S=C.slice();let $=S[0];const O={};A&&(O.time=A),O.level=r.levels.values[E];let v=(p._childLevel|0)+1;if(v<1&&(v=1),$!==null&&typeof $=="object"){for(;v--&&typeof S[0]=="object";)Object.assign(O,S.shift());$=S.length?t(S.shift(),S):void 0}else typeof $=="string"&&($=t(S.shift(),S));return $!==void 0&&(O.msg=$),O}function c(p,E,C,A){for(const S in p)if(A&&p[S]instanceof Error)p[S]=r.stdSerializers.err(p[S]);else if(typeof p[S]=="object"&&!Array.isArray(p[S]))for(const $ in p[S])E&&E.indexOf($)>-1&&$ in C&&(p[S][$]=C[$](p[S][$]))}function l(p,E,C){return function(){const A=new Array(1+arguments.length);A[0]=E;for(var S=1;S<A.length;S++)A[S]=arguments[S-1];return p[C].apply(this,A)}}function u(p,E,C){const A=E.send,S=E.ts,$=E.methodLevel,O=E.methodValue,v=E.val,w=p._logEvent.bindings;c(C,p._serialize||Object.keys(p.serializers),p.serializers,p._stdErrSerialize===void 0?!0:p._stdErrSerialize),p._logEvent.ts=S,p._logEvent.messages=C.filter(function(I){return w.indexOf(I)===-1}),p._logEvent.level.label=$,p._logEvent.level.value=O,A($,p._logEvent,v),p._logEvent=d(w)}function d(p){return{ts:0,messages:[],bindings:p||[],level:{label:"",value:0}}}function h(p){const E={type:p.constructor.name,msg:p.message,stack:p.stack};for(const C in p)E[C]===void 0&&(E[C]=p[C]);return E}function m(p){return typeof p.timestamp=="function"?p.timestamp:p.timestamp===!1?_:N}function g(){return{}}function b(p){return p}function y(){}function _(){return!1}function N(){return Date.now()}function D(){return Math.round(Date.now()/1e3)}function M(){return new Date(Date.now()).toISOString()}function q(){function p(E){return typeof E<"u"&&E}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return p(self)||p(window)||p(this)||{}}}return bo}Rf();let tn=null;const ns={getSIWX(){return R.state.siwx},async initializeIfEnabled(t=f.getActiveCaipAddress()){const e=R.state.siwx;if(!(e&&t))return;const[s,n,r]=t.split(":");if(f.checkIfSupportedNetwork(s,`${s}:${n}`))try{if(R.state.remoteFeatures?.emailCapture){const o=f.getAccountData(s)?.user;await he.open({view:"DataCapture",data:{email:o?.email??void 0}});return}if(tn&&await tn,(await e.getSessions(`${s}:${n}`,r)).length)return;await he.open({view:"SIWXSignMessage"})}catch(i){console.error("SIWXUtil:initializeIfEnabled",i),le.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties(i)}),await G._getClient()?.disconnect().catch(console.error),ne.reset("Connect"),is.showError("A problem occurred while trying initialize authentication")}},async requestSignMessage(){const t=R.state.siwx,e=J.getPlainAddress(f.getActiveCaipAddress()),s=oi(),n=G._getClient();if(!t)throw new Error("SIWX is not enabled");if(!e)throw new Error("No ActiveCaipAddress found");if(!s)throw new Error("No ActiveCaipNetwork or client found");if(!n)throw new Error("No ConnectionController client found");try{const r=await t.createMessage({chainId:s.caipNetworkId,accountAddress:e}),i=r.toString();F.getConnectorId(s.chainNamespace)===x.CONNECTOR_ID.AUTH&&ne.pushTransactionStack({});const a=await n.signMessage(i);await t.addSession({data:r,message:i,signature:a}),f.setLastConnectedSIWECaipNetwork(s),he.close(),le.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:this.getSIWXEventProperties()})}catch(r){(!he.state.open||ne.state.view==="ApproveTransaction")&&await he.open({view:"SIWXSignMessage"}),is.showError("Error signing message"),le.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:this.getSIWXEventProperties(r)}),console.error("SWIXUtil:requestSignMessage",r)}},async cancelSignMessage(){try{const t=this.getSIWX();if(t?.getRequired?.()){const s=f.getLastConnectedSIWECaipNetwork();if(s){const n=await t?.getSessions(s?.caipNetworkId,J.getPlainAddress(f.getActiveCaipAddress())||"");n&&n.length>0?await f.switchActiveNetwork(s):await G.disconnect()}else await G.disconnect()}else he.close();he.close(),le.sendEvent({event:"CLICK_CANCEL_SIWX",type:"track",properties:this.getSIWXEventProperties()})}catch(t){console.error("SIWXUtil:cancelSignMessage",t)}},async getAllSessions(){const t=this.getSIWX(),e=f.getAllRequestedCaipNetworks(),s=[];return await Promise.all(e.map(async n=>{const r=await t?.getSessions(n.caipNetworkId,J.getPlainAddress(f.getActiveCaipAddress())||"");r&&s.push(...r)})),s},async getSessions(t){const e=R.state.siwx;let s=t?.address;if(!s){const r=f.getActiveCaipAddress();s=J.getPlainAddress(r)}let n=t?.caipNetworkId;return n||(n=f.getActiveCaipNetwork()?.caipNetworkId),e&&s&&n?e.getSessions(n,s):[]},async isSIWXCloseDisabled(){const t=this.getSIWX();if(t){const e=ne.state.view==="ApproveTransaction",s=ne.state.view==="SIWXSignMessage";if(e||s)return t.getRequired?.()&&(await this.getSessions()).length===0}return!1},async authConnectorAuthenticate({authConnector:t,chainId:e,socialUri:s,preferredAccountType:n,chainNamespace:r}){const i=ns.getSIWX(),o=oi();if(!i||!r.includes(x.CHAIN.EVM)||R.state.remoteFeatures?.emailCapture){const d=await t.connect({chainId:e,socialUri:s,preferredAccountType:n});return{address:d.address,chainId:d.chainId,accounts:d.accounts}}const a=`${r}:${e}`,c=await i.createMessage({chainId:a,accountAddress:"<<AccountAddress>>"}),l={accountAddress:c.accountAddress,chainId:c.chainId,domain:c.domain,uri:c.uri,version:c.version,nonce:c.nonce,notBefore:c.notBefore,statement:c.statement,resources:c.resources,requestId:c.requestId,issuedAt:c.issuedAt,expirationTime:c.expirationTime,serializedMessage:c.toString()},u=await t.connect({chainId:e,socialUri:s,siwxMessage:l,preferredAccountType:n});return l.accountAddress=u.address,l.serializedMessage=u.message||"",u.signature&&u.message&&await ns.addEmbeddedWalletSession(l,u.message,u.signature),f.setLastConnectedSIWECaipNetwork(o),{address:u.address,chainId:u.chainId,accounts:u.accounts}},async addEmbeddedWalletSession(t,e,s){if(tn)return tn;const n=ns.getSIWX();return n?(tn=n.addSession({data:t,message:e,signature:s}).finally(()=>{tn=null}),tn):Promise.resolve()},async universalProviderAuthenticate({universalProvider:t,chains:e,methods:s}){const n=ns.getSIWX(),r=oi(),i=new Set(e.map(l=>l.split(":")[0]));if(!n||i.size!==1||!i.has("eip155"))return!1;const o=await n.createMessage({chainId:oi()?.caipNetworkId||"",accountAddress:""}),a=await t.authenticate({nonce:o.nonce,domain:o.domain,uri:o.uri,exp:o.expirationTime,iat:o.issuedAt,nbf:o.notBefore,requestId:o.requestId,version:o.version,resources:o.resources,statement:o.statement,chainId:o.chainId,methods:s,chains:[o.chainId,...e.filter(l=>l!==o.chainId)]});is.showLoading("Authenticating...",{autoClose:!1});const c={...a.session.peer.metadata,name:a.session.peer.metadata.name,icon:a.session.peer.metadata.icons?.[0],type:"WALLET_CONNECT"};if(f.setAccountProp("connectedWalletInfo",c,Array.from(i)[0]),a?.auths?.length){const l=a.auths.map(u=>{const d=t.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||o.version,expirationTime:u.p.exp,issuedAt:u.p.iat,notBefore:u.p.nbf},message:d,signature:u.s.s,cacao:u}});try{await n.setSessions(l),r&&f.setLastConnectedSIWECaipNetwork(r),le.sendEvent({type:"track",event:"SIWX_AUTH_SUCCESS",properties:ns.getSIWXEventProperties()})}catch(u){throw console.error("SIWX:universalProviderAuth - failed to set sessions",u),le.sendEvent({type:"track",event:"SIWX_AUTH_ERROR",properties:ns.getSIWXEventProperties(u)}),await t.disconnect().catch(console.error),u}finally{is.hide()}}return!0},getSIWXEventProperties(t){const e=f.state.activeChain;if(!e)throw new Error("SIWXUtil:getSIWXEventProperties - namespace is required");return{network:f.state.activeCaipNetwork?.caipNetworkId||"",isSmartAccount:Lt(e)===Cs.ACCOUNT_TYPES.SMART_ACCOUNT,message:t?J.parseError(t):void 0}},async clearSessions(){const t=this.getSIWX();t&&await t.setSessions([])}};var Eo,Dc;function xf(){if(Dc)return Eo;Dc=1;const t=La();Eo=r;const e=q().console||{},s={mapHttpRequest:g,mapHttpResponse:g,wrapRequestSerializer:b,wrapResponseSerializer:b,wrapErrorSerializer:b,req:g,res:g,err:h};function n(p,E){return Array.isArray(p)?p.filter(function(A){return A!=="!stdSerializers.err"}):p===!0?Object.keys(E):!1}function r(p){p=p||{},p.browser=p.browser||{};const E=p.browser.transmit;if(E&&typeof E.send!="function")throw Error("pino: transmit option must have a send function");const C=p.browser.write||e;p.browser.write&&(p.browser.asObject=!0);const A=p.serializers||{},S=n(p.browser.serialize,A);let $=p.browser.serialize;Array.isArray(p.browser.serialize)&&p.browser.serialize.indexOf("!stdSerializers.err")>-1&&($=!1);const O=["error","fatal","warn","info","debug","trace"];typeof C=="function"&&(C.error=C.fatal=C.warn=C.info=C.debug=C.trace=C),p.enabled===!1&&(p.level="silent");const v=p.level||"info",w=Object.create(C);w.log||(w.log=y),Object.defineProperty(w,"levelVal",{get:P}),Object.defineProperty(w,"level",{get:U,set:j});const I={transmit:E,serialize:S,asObject:p.browser.asObject,levels:O,timestamp:m(p)};w.levels=r.levels,w.level=v,w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=A,w._serialize=S,w._stdErrSerialize=$,w.child=k,E&&(w._logEvent=d());function P(){return this.level==="silent"?1/0:this.levels.values[this.level]}function U(){return this._level}function j(T){if(T!=="silent"&&!this.levels.values[T])throw Error("unknown level "+T);this._level=T,i(I,w,"error","log"),i(I,w,"fatal","error"),i(I,w,"warn","error"),i(I,w,"info","log"),i(I,w,"debug","log"),i(I,w,"trace","log")}function k(T,W){if(!T)throw new Error("missing bindings for child Pino");W=W||{},S&&T.serializers&&(W.serializers=T.serializers);const z=W.serializers;if(S&&z){var ie=Object.assign({},A,z),oe=p.browser.serialize===!0?Object.keys(ie):S;delete T.serializers,c([T],oe,ie,this._stdErrSerialize)}function se(X){this._childLevel=(X._childLevel|0)+1,this.error=l(X,T,"error"),this.fatal=l(X,T,"fatal"),this.warn=l(X,T,"warn"),this.info=l(X,T,"info"),this.debug=l(X,T,"debug"),this.trace=l(X,T,"trace"),ie&&(this.serializers=ie,this._serialize=oe),E&&(this._logEvent=d([].concat(X._logEvent.bindings,T)))}return se.prototype=this,new se(this)}return w}r.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},r.stdSerializers=s,r.stdTimeFunctions=Object.assign({},{nullTime:_,epochTime:N,unixTime:D,isoTime:M});function i(p,E,C,A){const S=Object.getPrototypeOf(E);E[C]=E.levelVal>E.levels.values[C]?y:S[C]?S[C]:e[C]||e[A]||y,o(p,E,C)}function o(p,E,C){!p.transmit&&E[C]===y||(E[C]=(function(A){return function(){const $=p.timestamp(),O=new Array(arguments.length),v=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var w=0;w<O.length;w++)O[w]=arguments[w];if(p.serialize&&!p.asObject&&c(O,this._serialize,this.serializers,this._stdErrSerialize),p.asObject?A.call(v,a(this,C,O,$)):A.apply(v,O),p.transmit){const I=p.transmit.level||E.level,P=r.levels.values[I],U=r.levels.values[C];if(U<P)return;u(this,{ts:$,methodLevel:C,methodValue:U,transmitValue:r.levels.values[p.transmit.level||E.level],send:p.transmit.send,val:E.levelVal},O)}}})(E[C]))}function a(p,E,C,A){p._serialize&&c(C,p._serialize,p.serializers,p._stdErrSerialize);const S=C.slice();let $=S[0];const O={};A&&(O.time=A),O.level=r.levels.values[E];let v=(p._childLevel|0)+1;if(v<1&&(v=1),$!==null&&typeof $=="object"){for(;v--&&typeof S[0]=="object";)Object.assign(O,S.shift());$=S.length?t(S.shift(),S):void 0}else typeof $=="string"&&($=t(S.shift(),S));return $!==void 0&&(O.msg=$),O}function c(p,E,C,A){for(const S in p)if(A&&p[S]instanceof Error)p[S]=r.stdSerializers.err(p[S]);else if(typeof p[S]=="object"&&!Array.isArray(p[S]))for(const $ in p[S])E&&E.indexOf($)>-1&&$ in C&&(p[S][$]=C[$](p[S][$]))}function l(p,E,C){return function(){const A=new Array(1+arguments.length);A[0]=E;for(var S=1;S<A.length;S++)A[S]=arguments[S-1];return p[C].apply(this,A)}}function u(p,E,C){const A=E.send,S=E.ts,$=E.methodLevel,O=E.methodValue,v=E.val,w=p._logEvent.bindings;c(C,p._serialize||Object.keys(p.serializers),p.serializers,p._stdErrSerialize===void 0?!0:p._stdErrSerialize),p._logEvent.ts=S,p._logEvent.messages=C.filter(function(I){return w.indexOf(I)===-1}),p._logEvent.level.label=$,p._logEvent.level.value=O,A($,p._logEvent,v),p._logEvent=d(w)}function d(p){return{ts:0,messages:[],bindings:p||[],level:{label:"",value:0}}}function h(p){const E={type:p.constructor.name,msg:p.message,stack:p.stack};for(const C in p)E[C]===void 0&&(E[C]=p[C]);return E}function m(p){return typeof p.timestamp=="function"?p.timestamp:p.timestamp===!1?_:N}function g(){return{}}function b(p){return p}function y(){}function _(){return!1}function N(){return Date.now()}function D(){return Math.round(Date.now()/1e3)}function M(){return new Date(Date.now()).toISOString()}function q(){function p(E){return typeof E<"u"&&E}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return p(self)||p(window)||p(this)||{}}}return Eo}var Bn=xf();const Kr=Yu(Bn),$f={level:"info"},Gr="custom_context",Va=1e3*1024;let Uf=class{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}},Pc=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const s=new Uf(e);if(s.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${s.size}`);for(;this.size+s.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=s),this.tail=s):(this.head=s,this.tail=s),this.lengthInNodes++,this.sizeInBytes+=s.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let s=this.head;for(;s!==null;)e.push(s.value),s=s.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const s=e.value;return e=e.next,{done:!1,value:s}}}}},ld=class{constructor(e,s=Va){this.level=e??"error",this.levelValue=Bn.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=s,this.logs=new Pc(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,s){s===Bn.levels.values.error?console.error(e):s===Bn.levels.values.warn?console.warn(e):s===Bn.levels.values.debug?console.debug(e):s===Bn.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Rr({timestamp:new Date().toISOString(),log:e}));const s=typeof e=="string"?JSON.parse(e).level:e.level;s>=this.levelValue&&this.forwardToConsole(e,s)}getLogs(){return this.logs}clearLogs(){this.logs=new Pc(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const s=this.getLogArray();return s.push(Rr({extraMetadata:e})),new Blob(s,{type:"application/json"})}},Lf=class{constructor(e,s=Va){this.baseChunkLogger=new ld(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const s=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=s,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}},Bf=class{constructor(e,s=Va){this.baseChunkLogger=new ld(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var Mf=Object.defineProperty,jf=Object.defineProperties,Ff=Object.getOwnPropertyDescriptors,Rc=Object.getOwnPropertySymbols,qf=Object.prototype.hasOwnProperty,Wf=Object.prototype.propertyIsEnumerable,xc=(t,e,s)=>e in t?Mf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xi=(t,e)=>{for(var s in e||(e={}))qf.call(e,s)&&xc(t,s,e[s]);if(Rc)for(var s of Rc(e))Wf.call(e,s)&&xc(t,s,e[s]);return t},$i=(t,e)=>jf(t,Ff(e));function Xi(t){return $i(xi({},t),{level:t?.level||$f.level})}function Vf(t,e=Gr){return t[e]||""}function zf(t,e,s=Gr){return t[s]=e,t}function Et(t,e=Gr){let s="";return typeof t.bindings>"u"?s=Vf(t,e):s=t.bindings().context||"",s}function Hf(t,e,s=Gr){const n=Et(t,s);return n.trim()?`${n}/${e}`:e}function lt(t,e,s=Gr){const n=Hf(t,e,s),r=t.child({context:n});return zf(r,n,s)}function Kf(t){var e,s;const n=new Lf((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Kr($i(xi({},t.opts),{level:"trace",browser:$i(xi({},(s=t.opts)==null?void 0:s.browser),{write:r=>n.write(r)})})),chunkLoggerController:n}}function Gf(t){var e;const s=new Bf((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Kr($i(xi({},t.opts),{level:"trace"}),s),chunkLoggerController:s}}function Yf(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?Kf(t):Gf(t)}var Jf=Object.defineProperty,Xf=(t,e,s)=>e in t?Jf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,$c=(t,e,s)=>Xf(t,typeof e!="symbol"?e+"":e,s);let Zf=class extends sr{constructor(e){super(),this.opts=e,$c(this,"protocol","wc"),$c(this,"version",2)}};var Qf=Object.defineProperty,eg=(t,e,s)=>e in t?Qf(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,tg=(t,e,s)=>eg(t,e+"",s);let sg=class extends sr{constructor(e,s){super(),this.core=e,this.logger=s,tg(this,"records",new Map)}},ng=class{constructor(e,s){this.logger=e,this.core=s}},rg=class extends sr{constructor(e,s){super(),this.relayer=e,this.logger=s}},ig=class extends sr{constructor(e){super()}},og=class{constructor(e,s,n,r){this.core=e,this.logger=s,this.name=n}},ag=class extends sr{constructor(e,s){super(),this.relayer=e,this.logger=s}},cg=class extends sr{constructor(e,s){super(),this.core=e,this.logger=s}},lg=class{constructor(e,s,n){this.core=e,this.logger=s,this.store=n}},ug=class{constructor(e,s){this.projectId=e,this.logger=s}},dg=class{constructor(e,s,n){this.core=e,this.logger=s,this.telemetryEnabled=n}};var hg=Object.defineProperty,pg=(t,e,s)=>e in t?hg(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Uc=(t,e,s)=>pg(t,typeof e!="symbol"?e+"":e,s);let fg=class{constructor(e){this.opts=e,Uc(this,"protocol","wc"),Uc(this,"version",2)}},gg=class{constructor(e){this.client=e}};function za(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function ud(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?za(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function Tr(t,e){e||(e=t.reduce((r,i)=>r+i.length,0));const s=ud(e);let n=0;for(const r of t)s.set(r,n),n+=r.length;return za(s)}function mg(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(s[o]!==255)throw new TypeError(i+" is ambiguous");s[o]=r}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(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 b=0,y=0,_=0,N=g.length;_!==N&&g[_]===0;)_++,b++;for(var D=(N-_)*u+1>>>0,M=new Uint8Array(D);_!==N;){for(var q=g[_],p=0,E=D-1;(q!==0||p<y)&&E!==-1;E--,p++)q+=256*M[E]>>>0,M[E]=q%a>>>0,q=q/a>>>0;if(q!==0)throw new Error("Non-zero carry");y=p,_++}for(var C=D-y;C!==D&&M[C]===0;)C++;for(var A=c.repeat(b);C<D;++C)A+=t.charAt(M[C]);return A}function h(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var b=0;if(g[b]!==" "){for(var y=0,_=0;g[b]===c;)y++,b++;for(var N=(g.length-b)*l+1>>>0,D=new Uint8Array(N);g[b];){var M=s[g.charCodeAt(b)];if(M===255)return;for(var q=0,p=N-1;(M!==0||q<_)&&p!==-1;p--,q++)M+=a*D[p]>>>0,D[p]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");_=q,b++}if(g[b]!==" "){for(var E=N-_;E!==N&&D[E]===0;)E++;for(var C=new Uint8Array(y+(N-E)),A=y;E!==N;)C[A++]=D[E++];return C}}}function m(g){var b=h(g);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:h,decode:m}}var wg=mg,yg=wg;const bg=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},Eg=t=>new TextEncoder().encode(t),Cg=t=>new TextDecoder().decode(t);class vg{constructor(e,s,n){this.name=e,this.prefix=s,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class Ag{constructor(e,s,n){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=n}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 dd(this,e)}}class Ig{constructor(e){this.decoders=e}or(e){return dd(this,e)}decode(e){const s=e[0],n=this.decoders[s];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const dd=(t,e)=>new Ig({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class Ng{constructor(e,s,n,r){this.name=e,this.prefix=s,this.baseEncode=n,this.baseDecode=r,this.encoder=new vg(e,s,n),this.decoder=new Ag(e,s,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const Zi=({name:t,prefix:e,encode:s,decode:n})=>new Ng(t,e,s,n),Yr=({prefix:t,name:e,alphabet:s})=>{const{encode:n,decode:r}=yg(s,e);return Zi({prefix:t,name:e,encode:n,decode:i=>bg(r(i))})},_g=(t,e,s,n)=>{const r={};for(let u=0;u<e.length;++u)r[e[u]]=u;let i=t.length;for(;t[i-1]==="=";)--i;const o=new Uint8Array(i*s/8|0);let a=0,c=0,l=0;for(let u=0;u<i;++u){const d=r[t[u]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<s|d,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},Sg=(t,e,s)=>{const n=e[e.length-1]==="=",r=(1<<s)-1;let i="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,i+=e[r&a>>o];if(o&&(i+=e[r&a<<s-o]),n)for(;i.length*s&7;)i+="=";return i},Ze=({name:t,prefix:e,bitsPerChar:s,alphabet:n})=>Zi({prefix:e,name:t,encode(r){return Sg(r,n,s)},decode(r){return _g(r,n,s,t)}}),Tg=Zi({prefix:"\0",name:"identity",encode:t=>Cg(t),decode:t=>Eg(t)}),Og=Object.freeze(Object.defineProperty({__proto__:null,identity:Tg},Symbol.toStringTag,{value:"Module"})),kg=Ze({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),Dg=Object.freeze(Object.defineProperty({__proto__:null,base2:kg},Symbol.toStringTag,{value:"Module"})),Pg=Ze({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Rg=Object.freeze(Object.defineProperty({__proto__:null,base8:Pg},Symbol.toStringTag,{value:"Module"})),xg=Yr({prefix:"9",name:"base10",alphabet:"0123456789"}),$g=Object.freeze(Object.defineProperty({__proto__:null,base10:xg},Symbol.toStringTag,{value:"Module"})),Ug=Ze({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),Lg=Ze({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),Bg=Object.freeze(Object.defineProperty({__proto__:null,base16:Ug,base16upper:Lg},Symbol.toStringTag,{value:"Module"})),Mg=Ze({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),jg=Ze({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),Fg=Ze({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),qg=Ze({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),Wg=Ze({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),Vg=Ze({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),zg=Ze({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),Hg=Ze({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Kg=Ze({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Gg=Object.freeze(Object.defineProperty({__proto__:null,base32:Mg,base32hex:Wg,base32hexpad:zg,base32hexpadupper:Hg,base32hexupper:Vg,base32pad:Fg,base32padupper:qg,base32upper:jg,base32z:Kg},Symbol.toStringTag,{value:"Module"})),Yg=Yr({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),Jg=Yr({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Xg=Object.freeze(Object.defineProperty({__proto__:null,base36:Yg,base36upper:Jg},Symbol.toStringTag,{value:"Module"})),Zg=Yr({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Qg=Yr({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),em=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Zg,base58flickr:Qg},Symbol.toStringTag,{value:"Module"})),tm=Ze({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),sm=Ze({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),nm=Ze({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),rm=Ze({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),im=Object.freeze(Object.defineProperty({__proto__:null,base64:tm,base64pad:sm,base64url:nm,base64urlpad:rm},Symbol.toStringTag,{value:"Module"})),hd=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),om=hd.reduce((t,e,s)=>(t[s]=e,t),[]),am=hd.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function cm(t){return t.reduce((e,s)=>(e+=om[s],e),"")}function lm(t){const e=[];for(const s of t){const n=am[s.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(n)}return new Uint8Array(e)}const um=Zi({prefix:"🚀",name:"base256emoji",encode:cm,decode:lm}),dm=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:um},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const Lc={...Og,...Dg,...Rg,...$g,...Bg,...Gg,...Xg,...em,...im,...dm};function pd(t,e,s,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:n}}}const Bc=pd("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),Co=pd("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=ud(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),fd={utf8:Bc,"utf-8":Bc,hex:Lc.base16,latin1:Co,ascii:Co,binary:Co,...Lc};function Bt(t,e="utf8"){const s=fd[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?za(globalThis.Buffer.from(t,"utf-8")):s.decoder.decode(`${s.prefix}${t}`)}function bt(t,e="utf8"){const s=fd[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(t.buffer,t.byteOffset,t.byteLength).toString("utf8"):s.encoder.encode(t).substring(1)}var hm={};const pm=":";function Is(t){const[e,s]=t.split(pm);return{namespace:e,reference:s}}function gd(t,e){return t.includes(":")?[t]:e.chains||[]}var fm=Object.defineProperty,gm=Object.defineProperties,mm=Object.getOwnPropertyDescriptors,Mc=Object.getOwnPropertySymbols,wm=Object.prototype.hasOwnProperty,ym=Object.prototype.propertyIsEnumerable,ra=(t,e,s)=>e in t?fm(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jc=(t,e)=>{for(var s in e||(e={}))wm.call(e,s)&&ra(t,s,e[s]);if(Mc)for(var s of Mc(e))ym.call(e,s)&&ra(t,s,e[s]);return t},bm=(t,e)=>gm(t,mm(e)),Fc=(t,e,s)=>ra(t,typeof e!="symbol"?e+"":e,s);const Em="ReactNative",St={reactNative:"react-native",node:"node",browser:"browser",unknown:"unknown"},Cm="js";function Ui(){return typeof process<"u"&&typeof process.versions<"u"&&typeof process.versions.node<"u"}function Xs(){return!Ss.getDocument()&&!!Ss.getNavigator()&&navigator.product===Em}function vm(){return Xs()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="android"}function Am(){return Xs()&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"&&(global==null?void 0:global.Platform.OS)==="ios"}function ir(){return!Ui()&&!!Ss.getNavigator()&&!!Ss.getDocument()}function Jr(){return Xs()?St.reactNative:Ui()?St.node:ir()?St.browser:St.unknown}function qc(){var t;try{return Xs()&&typeof global<"u"&&typeof(global==null?void 0:global.Application)<"u"?(t=global.Application)==null?void 0:t.applicationId:void 0}catch{return}}function Im(t,e){const s=new URLSearchParams(t);return Object.entries(e).sort(([n],[r])=>n.localeCompare(r)).forEach(([n,r])=>{r!=null&&s.set(n,String(r))}),s.toString()}function Nm(t){var e,s;const n=md();try{return t!=null&&t.url&&n.url&&new URL(t.url).host!==new URL(n.url).host&&(console.warn(`The configured WalletConnect 'metadata.url':${t.url} differs from the actual page url:${n.url}. This is probably unintended and can lead to issues.`),t.url=n.url),(e=t?.icons)!=null&&e.length&&t.icons.length>0&&(t.icons=t.icons.filter(r=>r!=="")),bm(jc(jc({},n),t),{url:t?.url||n.url,name:t?.name||n.name,description:t?.description||n.description,icons:(s=t?.icons)!=null&&s.length&&t.icons.length>0?t.icons:n.icons})}catch(r){return console.warn("Error populating app metadata",r),t||n}}function md(){return dp.getWindowMetadata()||{name:"",description:"",url:"",icons:[""]}}function _m(){if(Jr()===St.reactNative&&typeof global<"u"&&typeof(global==null?void 0:global.Platform)<"u"){const{OS:s,Version:n}=global.Platform;return[s,n].join("-")}const t=pp();if(t===null)return"unknown";const e=t.os?t.os.replace(" ","").toLowerCase():"unknown";return t.type==="browser"?[e,t.name,t.version].join("-"):[e,t.version].join("-")}function Sm(){var t;const e=Jr();return e===St.browser?[e,((t=Ss.getLocation())==null?void 0:t.host)||"unknown"].join(":"):e}function wd(t,e,s){const n=_m(),r=Sm();return[[t,e].join("-"),[Cm,s].join("-"),n,r].join("/")}function Tm({protocol:t,version:e,relayUrl:s,sdkVersion:n,auth:r,projectId:i,useOnCloseEvent:o,bundleId:a,packageName:c}){const l=s.split("?"),u=wd(t,e,n),d={auth:r,ua:u,projectId:i,useOnCloseEvent:o,packageName:c||void 0,bundleId:a||void 0},h=Im(l[1]||"",d);return l[0]+"?"+h}function hn(t,e){return t.filter(s=>e.includes(s)).length===t.length}function ia(t){return Object.fromEntries(t.entries())}function oa(t){return new Map(Object.entries(t))}function an(t=H.FIVE_MINUTES,e){const s=H.toMiliseconds(t||H.FIVE_MINUTES);let n,r,i,o;return{resolve:a=>{i&&n&&(clearTimeout(i),n(a),o=Promise.resolve(a))},reject:a=>{i&&r&&(clearTimeout(i),r(a))},done:()=>new Promise((a,c)=>{if(o)return a(o);i=setTimeout(()=>{const l=new Error(e);o=Promise.reject(l),c(l)},s),n=a,r=c})}}function os(t,e,s){return new Promise(async(n,r)=>{const i=setTimeout(()=>r(new Error(s)),e);try{const o=await t;n(o)}catch(o){r(o)}clearTimeout(i)})}function yd(t,e){if(typeof e=="string"&&e.startsWith(`${t}:`))return e;if(t.toLowerCase()==="topic"){if(typeof e!="string")throw new Error('Value must be "string" for expirer target type: topic');return`topic:${e}`}else if(t.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: ${t}`)}function Om(t){return yd("topic",t)}function km(t){return yd("id",t)}function bd(t){const[e,s]=t.split(":"),n={id:void 0,topic:void 0};if(e==="topic"&&typeof s=="string")n.topic=s;else if(e==="id"&&Number.isInteger(Number(s)))n.id=Number(s);else throw new Error(`Invalid target, expected id:number or topic:string, got ${e}:${s}`);return n}function Be(t,e){return H.fromMiliseconds(Date.now()+H.toMiliseconds(t))}function rs(t){return Date.now()>=H.toMiliseconds(t)}function Ae(t,e){return`${t}${e?`:${e}`:""}`}function ls(t=[],e=[]){return[...new Set([...t,...e])]}async function Dm({id:t,topic:e,wcDeepLink:s}){var n;try{if(!s)return;const r=typeof s=="string"?JSON.parse(s):s,i=r?.href;if(typeof i!="string")return;const o=Pm(i,t,e),a=Jr();if(a===St.browser){if(!((n=Ss.getDocument())!=null&&n.hasFocus())){console.warn("Document does not have focus, skipping deeplink.");return}Rm(o)}else a===St.reactNative&&typeof(global==null?void 0:global.Linking)<"u"&&await global.Linking.openURL(o)}catch(r){console.error(r)}}function Pm(t,e,s){const n=`requestId=${e}&sessionTopic=${s}`;t.endsWith("/")&&(t=t.slice(0,-1));let r=`${t}`;if(t.startsWith("https://t.me")){const i=t.includes("?")?"&startapp=":"?startapp=";r=`${r}${i}${Lm(n,!0)}`}else r=`${r}/wc?${n}`;return r}function Rm(t){let e="_self";Um()?e="_top":($m()||t.startsWith("https://")||t.startsWith("http://"))&&(e="_blank"),window.open(t,e,"noreferrer noopener")}async function xm(t,e){let s="";try{if(ir()&&(s=localStorage.getItem(e),s))return s;s=await t.getItem(e)}catch(n){console.error(n)}return s}function Wc(t,e){if(!t.includes(e))return null;const s=t.split(/([&,?,=])/),n=s.indexOf(e);return s[n+2]}function Vc(){return typeof crypto<"u"&&crypto!=null&&crypto.randomUUID?crypto.randomUUID():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/gu,t=>{const e=Math.random()*16|0;return(t==="x"?e:e&3|8).toString(16)})}function Ha(){return typeof process<"u"&&hm.IS_VITEST==="true"}function $m(){return typeof window<"u"&&(!!window.TelegramWebviewProxy||!!window.Telegram||!!window.TelegramWebviewProxyProto)}function Um(){try{return window.self!==window.top}catch{return!1}}function Lm(t,e=!1){const s=Buffer.from(t).toString("base64");return e?s.replace(/[=]/g,""):s}function Ed(t){return Buffer.from(t,"base64").toString("utf-8")}function Bm(t){return new Promise(e=>setTimeout(e,t))}let Mm=class{constructor({limit:e}){Fc(this,"limit"),Fc(this,"set"),this.limit=e,this.set=new Set}add(e){if(!this.set.has(e)){if(this.set.size>=this.limit){const s=this.set.values().next().value;s&&this.set.delete(s)}this.set.add(e)}}has(e){return this.set.has(e)}};const ci=BigInt(2**32-1),zc=BigInt(32);function Cd(t,e=!1){return e?{h:Number(t&ci),l:Number(t>>zc&ci)}:{h:Number(t>>zc&ci)|0,l:Number(t&ci)|0}}function vd(t,e=!1){const s=t.length;let n=new Uint32Array(s),r=new Uint32Array(s);for(let i=0;i<s;i++){const{h:o,l:a}=Cd(t[i],e);[n[i],r[i]]=[o,a]}return[n,r]}const Hc=(t,e,s)=>t>>>s,Kc=(t,e,s)=>t<<32-s|e>>>s,js=(t,e,s)=>t>>>s|e<<32-s,Fs=(t,e,s)=>t<<32-s|e>>>s,Cr=(t,e,s)=>t<<64-s|e>>>s-32,vr=(t,e,s)=>t>>>s-32|e<<64-s,jm=(t,e)=>e,Fm=(t,e)=>t,qm=(t,e,s)=>t<<s|e>>>32-s,Wm=(t,e,s)=>e<<s|t>>>32-s,Vm=(t,e,s)=>e<<s-32|t>>>64-s,zm=(t,e,s)=>t<<s-32|e>>>64-s;function zt(t,e,s,n){const r=(e>>>0)+(n>>>0);return{h:t+s+(r/2**32|0)|0,l:r|0}}const Ka=(t,e,s)=>(t>>>0)+(e>>>0)+(s>>>0),Ga=(t,e,s,n)=>e+s+n+(t/2**32|0)|0,Hm=(t,e,s,n)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0),Km=(t,e,s,n,r)=>e+s+n+r+(t/2**32|0)|0,Gm=(t,e,s,n,r)=>(t>>>0)+(e>>>0)+(s>>>0)+(n>>>0)+(r>>>0),Ym=(t,e,s,n,r,i)=>e+s+n+r+i+(t/2**32|0)|0,Dn=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Qi(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function Ts(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function Jt(t,...e){if(!Qi(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function eo(t){if(typeof t!="function"||typeof t.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");Ts(t.outputLen),Ts(t.blockLen)}function Js(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function Ya(t,e){Jt(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Lr(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Mt(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function vo(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}function Xt(t,e){return t<<32-e|t>>>e}const Ad=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Id(t){return t<<24&4278190080|t<<8&16711680|t>>>8&65280|t>>>24&255}const gs=Ad?t=>t:t=>Id(t);function Jm(t){for(let e=0;e<t.length;e++)t[e]=Id(t[e]);return t}const qs=Ad?t=>t:Jm,Nd=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Xm=Array.from({length:256},(t,e)=>e.toString(16).padStart(2,"0"));function Hn(t){if(Jt(t),Nd)return t.toHex();let e="";for(let s=0;s<t.length;s++)e+=Xm[t[s]];return e}const ps={_0:48,_9:57,A:65,F:70,a:97,f:102};function Gc(t){if(t>=ps._0&&t<=ps._9)return t-ps._0;if(t>=ps.A&&t<=ps.F)return t-(ps.A-10);if(t>=ps.a&&t<=ps.f)return t-(ps.a-10)}function Li(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);if(Nd)return Uint8Array.fromHex(t);const e=t.length,s=e/2;if(e%2)throw new Error("hex string expected, got unpadded hex of length "+e);const n=new Uint8Array(s);for(let r=0,i=0;r<s;r++,i+=2){const o=Gc(t.charCodeAt(i)),a=Gc(t.charCodeAt(i+1));if(o===void 0||a===void 0){const c=t[i]+t[i+1];throw new Error('hex string expected, got non-hex character "'+c+'" at index '+i)}n[r]=o*16+a}return n}function _d(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function Gt(t){return typeof t=="string"&&(t=_d(t)),Jt(t),t}function Ws(...t){let e=0;for(let n=0;n<t.length;n++){const r=t[n];Jt(r),e+=r.length}const s=new Uint8Array(e);for(let n=0,r=0;n<t.length;n++){const i=t[n];s.set(i,r),r+=i.length}return s}class to{}function Xr(t){const e=n=>t().update(Gt(n)).digest(),s=t();return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=()=>t(),e}function Zm(t){const e=(n,r)=>t(r).update(Gt(n)).digest(),s=t({});return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=n=>t(n),e}function Sn(t=32){if(Dn&&typeof Dn.getRandomValues=="function")return Dn.getRandomValues(new Uint8Array(t));if(Dn&&typeof Dn.randomBytes=="function")return Uint8Array.from(Dn.randomBytes(t));throw new Error("crypto.getRandomValues must be defined")}const Qm=BigInt(0),ur=BigInt(1),ew=BigInt(2),tw=BigInt(7),sw=BigInt(256),nw=BigInt(113),Sd=[],Td=[],Od=[];for(let t=0,e=ur,s=1,n=0;t<24;t++){[s,n]=[n,(2*s+3*n)%5],Sd.push(2*(5*n+s)),Td.push((t+1)*(t+2)/2%64);let r=Qm;for(let i=0;i<7;i++)e=(e<<ur^(e>>tw)*nw)%sw,e&ew&&(r^=ur<<(ur<<BigInt(i))-ur);Od.push(r)}const kd=vd(Od,!0),rw=kd[0],iw=kd[1],Yc=(t,e,s)=>s>32?Vm(t,e,s):qm(t,e,s),Jc=(t,e,s)=>s>32?zm(t,e,s):Wm(t,e,s);function ow(t,e=24){const s=new Uint32Array(10);for(let n=24-e;n<24;n++){for(let o=0;o<10;o++)s[o]=t[o]^t[o+10]^t[o+20]^t[o+30]^t[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,c=(o+2)%10,l=s[c],u=s[c+1],d=Yc(l,u,1)^s[a],h=Jc(l,u,1)^s[a+1];for(let m=0;m<50;m+=10)t[o+m]^=d,t[o+m+1]^=h}let r=t[2],i=t[3];for(let o=0;o<24;o++){const a=Td[o],c=Yc(r,i,a),l=Jc(r,i,a),u=Sd[o];r=t[u],i=t[u+1],t[u]=c,t[u+1]=l}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)s[a]=t[o+a];for(let a=0;a<10;a++)t[o+a]^=~s[(a+2)%10]&s[(a+4)%10]}t[0]^=rw[n],t[1]^=iw[n]}Mt(s)}let aw=class Dd extends to{constructor(e,s,n,r=!1,i=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=e,this.suffix=s,this.outputLen=n,this.enableXOF=r,this.rounds=i,Ts(n),!(0<e&&e<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Lr(this.state)}clone(){return this._cloneInto()}keccak(){qs(this.state32),ow(this.state32,this.rounds),qs(this.state32),this.posOut=0,this.pos=0}update(e){Js(this),e=Gt(e),Jt(e);const{blockLen:s,state:n}=this,r=e.length;for(let i=0;i<r;){const o=Math.min(s-this.pos,r-i);for(let a=0;a<o;a++)n[this.pos++]^=e[i++];this.pos===s&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:s,pos:n,blockLen:r}=this;e[n]^=s,(s&128)!==0&&n===r-1&&this.keccak(),e[r-1]^=128,this.keccak()}writeInto(e){Js(this,!1),Jt(e),this.finish();const s=this.state,{blockLen:n}=this;for(let r=0,i=e.length;r<i;){this.posOut>=n&&this.keccak();const o=Math.min(n-this.posOut,i-r);e.set(s.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 Ts(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(Ya(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,Mt(this.state)}_cloneInto(e){const{blockLen:s,suffix:n,outputLen:r,rounds:i,enableXOF:o}=this;return e||(e=new Dd(s,n,r,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=n,e.outputLen=r,e.enableXOF=o,e.destroyed=this.destroyed,e}};const cw=(t,e,s)=>Xr(()=>new aw(e,t,s)),lw=cw(1,136,256/8);function uw(t,e,s,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,n);const r=BigInt(32),i=BigInt(4294967295),o=Number(s>>r&i),a=Number(s&i),c=n?4:0,l=n?0:4;t.setUint32(e+c,o,n),t.setUint32(e+l,a,n)}function dw(t,e,s){return t&e^~t&s}function hw(t,e,s){return t&e^t&s^e&s}let Pd=class extends to{constructor(e,s,n,r){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=e,this.outputLen=s,this.padOffset=n,this.isLE=r,this.buffer=new Uint8Array(e),this.view=vo(this.buffer)}update(e){Js(this),e=Gt(e),Jt(e);const{view:s,buffer:n,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(r-this.pos,i-o);if(a===r){const c=vo(e);for(;r<=i-o;o+=r)this.process(c,o);continue}n.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(s,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Js(this),Ya(e,this),this.finished=!0;const{buffer:s,view:n,blockLen:r,isLE:i}=this;let{pos:o}=this;s[o++]=128,Mt(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(n,0),o=0);for(let d=o;d<r;d++)s[d]=0;uw(n,r-8,BigInt(this.length*8),i),this.process(n,0);const a=vo(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const l=c/4,u=this.get();if(l>u.length)throw new Error("_sha2: outputLen bigger than state");for(let d=0;d<l;d++)a.setUint32(4*d,u[d],i)}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:s,buffer:n,length:r,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=a,r%s&&e.buffer.set(n),e}clone(){return this._cloneInto()}};const Rs=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),et=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),tt=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),pw=Uint32Array.from([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]),xs=new Uint32Array(64);class fw extends Pd{constructor(e=32){super(64,e,8,!1),this.A=Rs[0]|0,this.B=Rs[1]|0,this.C=Rs[2]|0,this.D=Rs[3]|0,this.E=Rs[4]|0,this.F=Rs[5]|0,this.G=Rs[6]|0,this.H=Rs[7]|0}get(){const{A:e,B:s,C:n,D:r,E:i,F:o,G:a,H:c}=this;return[e,s,n,r,i,o,a,c]}set(e,s,n,r,i,o,a,c){this.A=e|0,this.B=s|0,this.C=n|0,this.D=r|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=c|0}process(e,s){for(let d=0;d<16;d++,s+=4)xs[d]=e.getUint32(s,!1);for(let d=16;d<64;d++){const h=xs[d-15],m=xs[d-2],g=Xt(h,7)^Xt(h,18)^h>>>3,b=Xt(m,17)^Xt(m,19)^m>>>10;xs[d]=b+xs[d-7]+g+xs[d-16]|0}let{A:n,B:r,C:i,D:o,E:a,F:c,G:l,H:u}=this;for(let d=0;d<64;d++){const h=Xt(a,6)^Xt(a,11)^Xt(a,25),m=u+h+dw(a,c,l)+pw[d]+xs[d]|0,g=(Xt(n,2)^Xt(n,13)^Xt(n,22))+hw(n,r,i)|0;u=l,l=c,c=a,a=o+m|0,o=i,i=r,r=n,n=m+g|0}n=n+this.A|0,r=r+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,c=c+this.F|0,l=l+this.G|0,u=u+this.H|0,this.set(n,r,i,o,a,c,l,u)}roundClean(){Mt(xs)}destroy(){this.set(0,0,0,0,0,0,0,0),Mt(this.buffer)}}const Rd=vd(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(t=>BigInt(t))),gw=Rd[0],mw=Rd[1],$s=new Uint32Array(80),Us=new Uint32Array(80);let Ja=class extends Pd{constructor(e=64){super(128,e,16,!1),this.Ah=tt[0]|0,this.Al=tt[1]|0,this.Bh=tt[2]|0,this.Bl=tt[3]|0,this.Ch=tt[4]|0,this.Cl=tt[5]|0,this.Dh=tt[6]|0,this.Dl=tt[7]|0,this.Eh=tt[8]|0,this.El=tt[9]|0,this.Fh=tt[10]|0,this.Fl=tt[11]|0,this.Gh=tt[12]|0,this.Gl=tt[13]|0,this.Hh=tt[14]|0,this.Hl=tt[15]|0}get(){const{Ah:e,Al:s,Bh:n,Bl:r,Ch:i,Cl:o,Dh:a,Dl:c,Eh:l,El:u,Fh:d,Fl:h,Gh:m,Gl:g,Hh:b,Hl:y}=this;return[e,s,n,r,i,o,a,c,l,u,d,h,m,g,b,y]}set(e,s,n,r,i,o,a,c,l,u,d,h,m,g,b,y){this.Ah=e|0,this.Al=s|0,this.Bh=n|0,this.Bl=r|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=l|0,this.El=u|0,this.Fh=d|0,this.Fl=h|0,this.Gh=m|0,this.Gl=g|0,this.Hh=b|0,this.Hl=y|0}process(e,s){for(let D=0;D<16;D++,s+=4)$s[D]=e.getUint32(s),Us[D]=e.getUint32(s+=4);for(let D=16;D<80;D++){const M=$s[D-15]|0,q=Us[D-15]|0,p=js(M,q,1)^js(M,q,8)^Hc(M,q,7),E=Fs(M,q,1)^Fs(M,q,8)^Kc(M,q,7),C=$s[D-2]|0,A=Us[D-2]|0,S=js(C,A,19)^Cr(C,A,61)^Hc(C,A,6),$=Fs(C,A,19)^vr(C,A,61)^Kc(C,A,6),O=Hm(E,$,Us[D-7],Us[D-16]),v=Km(O,p,S,$s[D-7],$s[D-16]);$s[D]=v|0,Us[D]=O|0}let{Ah:n,Al:r,Bh:i,Bl:o,Ch:a,Cl:c,Dh:l,Dl:u,Eh:d,El:h,Fh:m,Fl:g,Gh:b,Gl:y,Hh:_,Hl:N}=this;for(let D=0;D<80;D++){const M=js(d,h,14)^js(d,h,18)^Cr(d,h,41),q=Fs(d,h,14)^Fs(d,h,18)^vr(d,h,41),p=d&m^~d&b,E=h&g^~h&y,C=Gm(N,q,E,mw[D],Us[D]),A=Ym(C,_,M,p,gw[D],$s[D]),S=C|0,$=js(n,r,28)^Cr(n,r,34)^Cr(n,r,39),O=Fs(n,r,28)^vr(n,r,34)^vr(n,r,39),v=n&i^n&a^i&a,w=r&o^r&c^o&c;_=b|0,N=y|0,b=m|0,y=g|0,m=d|0,g=h|0,{h:d,l:h}=zt(l|0,u|0,A|0,S|0),l=a|0,u=c|0,a=i|0,c=o|0,i=n|0,o=r|0;const I=Ka(S,O,w);n=Ga(I,A,$,v),r=I|0}({h:n,l:r}=zt(this.Ah|0,this.Al|0,n|0,r|0)),{h:i,l:o}=zt(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=zt(this.Ch|0,this.Cl|0,a|0,c|0),{h:l,l:u}=zt(this.Dh|0,this.Dl|0,l|0,u|0),{h:d,l:h}=zt(this.Eh|0,this.El|0,d|0,h|0),{h:m,l:g}=zt(this.Fh|0,this.Fl|0,m|0,g|0),{h:b,l:y}=zt(this.Gh|0,this.Gl|0,b|0,y|0),{h:_,l:N}=zt(this.Hh|0,this.Hl|0,_|0,N|0),this.set(n,r,i,o,a,c,l,u,d,h,m,g,b,y,_,N)}roundClean(){Mt($s,Us)}destroy(){Mt(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}};class ww extends Ja{constructor(){super(48),this.Ah=et[0]|0,this.Al=et[1]|0,this.Bh=et[2]|0,this.Bl=et[3]|0,this.Ch=et[4]|0,this.Cl=et[5]|0,this.Dh=et[6]|0,this.Dl=et[7]|0,this.Eh=et[8]|0,this.El=et[9]|0,this.Fh=et[10]|0,this.Fl=et[11]|0,this.Gh=et[12]|0,this.Gl=et[13]|0,this.Hh=et[14]|0,this.Hl=et[15]|0}}const st=Uint32Array.from([573645204,4230739756,2673172387,3360449730,596883563,1867755857,2520282905,1497426621,2519219938,2827943907,3193839141,1401305490,721525244,746961066,246885852,2177182882]);class yw extends Ja{constructor(){super(32),this.Ah=st[0]|0,this.Al=st[1]|0,this.Bh=st[2]|0,this.Bl=st[3]|0,this.Ch=st[4]|0,this.Cl=st[5]|0,this.Dh=st[6]|0,this.Dl=st[7]|0,this.Eh=st[8]|0,this.El=st[9]|0,this.Fh=st[10]|0,this.Fl=st[11]|0,this.Gh=st[12]|0,this.Gl=st[13]|0,this.Hh=st[14]|0,this.Hl=st[15]|0}}const so=Xr(()=>new fw),bw=Xr(()=>new Ja),Ew=Xr(()=>new ww),Cw=Xr(()=>new yw),vw=Uint8Array.from([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9,12,5,1,15,14,13,4,10,0,7,6,3,9,2,8,11,13,11,7,14,12,1,3,9,5,0,15,4,8,6,2,10,6,15,14,9,11,3,0,8,12,2,13,7,1,4,10,5,10,2,8,4,7,6,1,5,15,11,9,14,3,12,13,0,0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,14,10,4,8,9,15,13,6,1,12,0,2,11,7,5,3,11,8,12,0,5,2,15,13,10,14,3,6,7,1,9,4,7,9,3,1,13,12,11,14,2,6,5,10,4,0,15,8,9,0,5,7,2,4,10,15,14,1,11,12,6,8,3,13,2,12,6,10,0,11,8,3,4,13,7,5,15,14,1,9]),Fe=Uint32Array.from([4089235720,1779033703,2227873595,3144134277,4271175723,1013904242,1595750129,2773480762,2917565137,1359893119,725511199,2600822924,4215389547,528734635,327033209,1541459225]),Y=new Uint32Array(32);function Ls(t,e,s,n,r,i){const o=r[i],a=r[i+1];let c=Y[2*t],l=Y[2*t+1],u=Y[2*e],d=Y[2*e+1],h=Y[2*s],m=Y[2*s+1],g=Y[2*n],b=Y[2*n+1],y=Ka(c,u,o);l=Ga(y,l,d,a),c=y|0,{Dh:b,Dl:g}={Dh:b^l,Dl:g^c},{Dh:b,Dl:g}={Dh:jm(b,g),Dl:Fm(b)},{h:m,l:h}=zt(m,h,b,g),{Bh:d,Bl:u}={Bh:d^m,Bl:u^h},{Bh:d,Bl:u}={Bh:js(d,u,24),Bl:Fs(d,u,24)},Y[2*t]=c,Y[2*t+1]=l,Y[2*e]=u,Y[2*e+1]=d,Y[2*s]=h,Y[2*s+1]=m,Y[2*n]=g,Y[2*n+1]=b}function Bs(t,e,s,n,r,i){const o=r[i],a=r[i+1];let c=Y[2*t],l=Y[2*t+1],u=Y[2*e],d=Y[2*e+1],h=Y[2*s],m=Y[2*s+1],g=Y[2*n],b=Y[2*n+1],y=Ka(c,u,o);l=Ga(y,l,d,a),c=y|0,{Dh:b,Dl:g}={Dh:b^l,Dl:g^c},{Dh:b,Dl:g}={Dh:js(b,g,16),Dl:Fs(b,g,16)},{h:m,l:h}=zt(m,h,b,g),{Bh:d,Bl:u}={Bh:d^m,Bl:u^h},{Bh:d,Bl:u}={Bh:Cr(d,u,63),Bl:vr(d,u,63)},Y[2*t]=c,Y[2*t+1]=l,Y[2*e]=u,Y[2*e+1]=d,Y[2*s]=h,Y[2*s+1]=m,Y[2*n]=g,Y[2*n+1]=b}function Aw(t,e={},s,n,r){if(Ts(s),t<0||t>s)throw new Error("outputLen bigger than keyLen");const{key:i,salt:o,personalization:a}=e;if(i!==void 0&&(i.length<1||i.length>s))throw new Error("key length must be undefined or 1.."+s);if(o!==void 0&&o.length!==n)throw new Error("salt must be undefined or "+n);if(a!==void 0&&a.length!==r)throw new Error("personalization must be undefined or "+r)}class Iw extends to{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,this.length=0,this.pos=0,Ts(e),Ts(s),this.blockLen=e,this.outputLen=s,this.buffer=new Uint8Array(e),this.buffer32=Lr(this.buffer)}update(e){Js(this),e=Gt(e),Jt(e);const{blockLen:s,buffer:n,buffer32:r}=this,i=e.length,o=e.byteOffset,a=e.buffer;for(let c=0;c<i;){this.pos===s&&(qs(r),this.compress(r,0,!1),qs(r),this.pos=0);const l=Math.min(s-this.pos,i-c),u=o+c;if(l===s&&!(u%4)&&c+l<i){const d=new Uint32Array(a,u,Math.floor((i-c)/4));qs(d);for(let h=0;c+s<i;h+=r.length,c+=s)this.length+=s,this.compress(d,h,!1);qs(d);continue}n.set(e.subarray(c,c+l),this.pos),this.pos+=l,this.length+=l,c+=l}return this}digestInto(e){Js(this),Ya(e,this);const{pos:s,buffer32:n}=this;this.finished=!0,Mt(this.buffer.subarray(s)),qs(n),this.compress(n,0,!0),qs(n);const r=Lr(e);this.get().forEach((i,o)=>r[o]=gs(i))}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}_cloneInto(e){const{buffer:s,length:n,finished:r,destroyed:i,outputLen:o,pos:a}=this;return e||(e=new this.constructor({dkLen:o})),e.set(...this.get()),e.buffer.set(s),e.destroyed=i,e.finished=r,e.length=n,e.pos=a,e.outputLen=o,e}clone(){return this._cloneInto()}}class Nw extends Iw{constructor(e={}){const s=e.dkLen===void 0?64:e.dkLen;super(128,s),this.v0l=Fe[0]|0,this.v0h=Fe[1]|0,this.v1l=Fe[2]|0,this.v1h=Fe[3]|0,this.v2l=Fe[4]|0,this.v2h=Fe[5]|0,this.v3l=Fe[6]|0,this.v3h=Fe[7]|0,this.v4l=Fe[8]|0,this.v4h=Fe[9]|0,this.v5l=Fe[10]|0,this.v5h=Fe[11]|0,this.v6l=Fe[12]|0,this.v6h=Fe[13]|0,this.v7l=Fe[14]|0,this.v7h=Fe[15]|0,Aw(s,e,64,16,16);let{key:n,personalization:r,salt:i}=e,o=0;if(n!==void 0&&(n=Gt(n),o=n.length),this.v0l^=this.outputLen|o<<8|65536|1<<24,i!==void 0){i=Gt(i);const a=Lr(i);this.v4l^=gs(a[0]),this.v4h^=gs(a[1]),this.v5l^=gs(a[2]),this.v5h^=gs(a[3])}if(r!==void 0){r=Gt(r);const a=Lr(r);this.v6l^=gs(a[0]),this.v6h^=gs(a[1]),this.v7l^=gs(a[2]),this.v7h^=gs(a[3])}if(n!==void 0){const a=new Uint8Array(this.blockLen);a.set(n),this.update(a)}}get(){let{v0l:e,v0h:s,v1l:n,v1h:r,v2l:i,v2h:o,v3l:a,v3h:c,v4l:l,v4h:u,v5l:d,v5h:h,v6l:m,v6h:g,v7l:b,v7h:y}=this;return[e,s,n,r,i,o,a,c,l,u,d,h,m,g,b,y]}set(e,s,n,r,i,o,a,c,l,u,d,h,m,g,b,y){this.v0l=e|0,this.v0h=s|0,this.v1l=n|0,this.v1h=r|0,this.v2l=i|0,this.v2h=o|0,this.v3l=a|0,this.v3h=c|0,this.v4l=l|0,this.v4h=u|0,this.v5l=d|0,this.v5h=h|0,this.v6l=m|0,this.v6h=g|0,this.v7l=b|0,this.v7h=y|0}compress(e,s,n){this.get().forEach((c,l)=>Y[l]=c),Y.set(Fe,16);let{h:r,l:i}=Cd(BigInt(this.length));Y[24]=Fe[8]^i,Y[25]=Fe[9]^r,n&&(Y[28]=~Y[28],Y[29]=~Y[29]);let o=0;const a=vw;for(let c=0;c<12;c++)Ls(0,4,8,12,e,s+2*a[o++]),Bs(0,4,8,12,e,s+2*a[o++]),Ls(1,5,9,13,e,s+2*a[o++]),Bs(1,5,9,13,e,s+2*a[o++]),Ls(2,6,10,14,e,s+2*a[o++]),Bs(2,6,10,14,e,s+2*a[o++]),Ls(3,7,11,15,e,s+2*a[o++]),Bs(3,7,11,15,e,s+2*a[o++]),Ls(0,5,10,15,e,s+2*a[o++]),Bs(0,5,10,15,e,s+2*a[o++]),Ls(1,6,11,12,e,s+2*a[o++]),Bs(1,6,11,12,e,s+2*a[o++]),Ls(2,7,8,13,e,s+2*a[o++]),Bs(2,7,8,13,e,s+2*a[o++]),Ls(3,4,9,14,e,s+2*a[o++]),Bs(3,4,9,14,e,s+2*a[o++]);this.v0l^=Y[0]^Y[16],this.v0h^=Y[1]^Y[17],this.v1l^=Y[2]^Y[18],this.v1h^=Y[3]^Y[19],this.v2l^=Y[4]^Y[20],this.v2h^=Y[5]^Y[21],this.v3l^=Y[6]^Y[22],this.v3h^=Y[7]^Y[23],this.v4l^=Y[8]^Y[24],this.v4h^=Y[9]^Y[25],this.v5l^=Y[10]^Y[26],this.v5h^=Y[11]^Y[27],this.v6l^=Y[12]^Y[28],this.v6h^=Y[13]^Y[29],this.v7l^=Y[14]^Y[30],this.v7h^=Y[15]^Y[31],Mt(Y)}destroy(){this.destroyed=!0,Mt(this.buffer32),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const _w=Zm(t=>new Nw(t)),Sw="https://rpc.walletconnect.org/v1";function xd(t){const e=`Ethereum Signed Message:
|
|
5
|
-
${t.length}`,s=new TextEncoder().encode(e+t);return"0x"+Buffer.from(lw(s)).toString("hex")}async function Tw(t,e,s,n,r,i){switch(s.t){case"eip191":return await Ow(t,e,s.s);case"eip1271":return await kw(t,e,s.s,n,r,i);default:throw new Error(`verifySignature failed: Attempted to verify CacaoSignature with unknown type: ${s.t}`)}}async function Ow(t,e,s){return(await Ap({hash:xd(e),signature:s})).toLowerCase()===t.toLowerCase()}async function kw(t,e,s,n,r,i){const o=Is(n);if(!o.namespace||!o.reference)throw new Error(`isValidEip1271Signature failed: chainId must be in CAIP-2 format, received: ${n}`);try{const a="0x1626ba7e",c="0000000000000000000000000000000000000000000000000000000000000040",l=s.substring(2),u=(l.length/2).toString(16).padStart(64,"0"),d=(e.startsWith("0x")?e:xd(e)).substring(2),h=a+d+c+u+l,m=await fetch(`${i||Sw}/?chainId=${n}&projectId=${r}`,{headers:{"Content-Type":"application/json"},method:"POST",body:JSON.stringify({id:Dw(),jsonrpc:"2.0",method:"eth_call",params:[{to:t,data:h},"latest"]})}),{result:g}=await m.json();return g?g.slice(0,a.length).toLowerCase()===a.toLowerCase():!1}catch(a){return console.error("isValidEip1271Signature: ",a),!1}}function Dw(){return Date.now()+Math.floor(Math.random()*1e3)}function Pw(t){const e=atob(t),s=new Uint8Array(e.length);for(let o=0;o<e.length;o++)s[o]=e.charCodeAt(o);const n=s[0];if(n===0)throw new Error("No signatures found");const r=1+n*64;if(s.length<r)throw new Error("Transaction data too short for claimed signature count");if(s.length<100)throw new Error("Transaction too short");const i=Buffer.from(t,"base64").slice(1,65);return nr.encode(i)}function Rw(t){const e=new Uint8Array(Buffer.from(t,"base64")),s=Array.from("TransactionData::").map(i=>i.charCodeAt(0)),n=new Uint8Array(s.length+e.length);n.set(s),n.set(e,s.length);const r=_w(n,{dkLen:32});return nr.encode(r)}function Xc(t){const e=new Uint8Array(so(xw(t)));return nr.encode(e)}function xw(t){if(t instanceof Uint8Array)return t;if(Array.isArray(t))return new Uint8Array(t);if(typeof t=="object"&&t!=null&&t.data)return new Uint8Array(Object.values(t.data));if(typeof t=="object"&&t)return new Uint8Array(Object.values(t));throw new Error("getNearUint8ArrayFromBytes: Unexpected result type from bytes array")}function Zc(t){const e=Buffer.from(t,"base64"),s=fp(e).txn;if(!s)throw new Error("Invalid signed transaction: missing 'txn' field");const n=gp(s),r=Buffer.from("TX"),i=Buffer.concat([r,Buffer.from(n)]),o=Cw(i);return vp.encode(o).replace(/=+$/,"")}function Ao(t){const e=[];let s=BigInt(t);for(;s>=BigInt(128);)e.push(Number(s&BigInt(127)|BigInt(128))),s>>=BigInt(7);return e.push(Number(s)),Buffer.from(e)}function $w(t){const e=Buffer.from(t.signed.bodyBytes,"base64"),s=Buffer.from(t.signed.authInfoBytes,"base64"),n=Buffer.from(t.signature.signature,"base64"),r=[];r.push(Buffer.from([10])),r.push(Ao(e.length)),r.push(e),r.push(Buffer.from([18])),r.push(Ao(s.length)),r.push(s),r.push(Buffer.from([26])),r.push(Ao(n.length)),r.push(n);const i=Buffer.concat(r),o=so(i);return Buffer.from(o).toString("hex").toUpperCase()}function Uw(t){var e,s;const n=[];try{if(typeof t=="string")return n.push(t),n;if(typeof t!="object")return n;t!=null&&t.id&&n.push(t.id);const r=(s=(e=t?.capabilities)==null?void 0:e.caip345)==null?void 0:s.transactionHashes;r&&n.push(...r)}catch(r){console.warn("getWalletSendCallsHashes failed: ",r)}return n}var Lw=Object.defineProperty,Bw=Object.defineProperties,Mw=Object.getOwnPropertyDescriptors,Qc=Object.getOwnPropertySymbols,jw=Object.prototype.hasOwnProperty,Fw=Object.prototype.propertyIsEnumerable,el=(t,e,s)=>e in t?Lw(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,qw=(t,e)=>{for(var s in e||(e={}))jw.call(e,s)&&el(t,s,e[s]);if(Qc)for(var s of Qc(e))Fw.call(e,s)&&el(t,s,e[s]);return t},Ww=(t,e)=>Bw(t,Mw(e));const Vw="did:pkh:",Xa=t=>t?.split(":"),zw=t=>{const e=t&&Xa(t);if(e)return t.includes(Vw)?e[3]:e[1]},aa=t=>{const e=t&&Xa(t);if(e)return e[2]+":"+e[3]},Bi=t=>{const e=t&&Xa(t);if(e)return e.pop()};async function tl(t){const{cacao:e,projectId:s}=t,{s:n,p:r}=e,i=$d(r,r.iss),o=Bi(r.iss);return await Tw(o,i,n,aa(r.iss),s)}const $d=(t,e)=>{const s=`${t.domain} wants you to sign in with your Ethereum account:`,n=Bi(e);if(!t.aud&&!t.uri)throw new Error("Either `aud` or `uri` is required to construct the message");let r=t.statement||void 0;const i=`URI: ${t.aud||t.uri}`,o=`Version: ${t.version}`,a=`Chain ID: ${zw(e)}`,c=`Nonce: ${t.nonce}`,l=`Issued At: ${t.iat}`,u=t.exp?`Expiration Time: ${t.exp}`:void 0,d=t.nbf?`Not Before: ${t.nbf}`:void 0,h=t.requestId?`Request ID: ${t.requestId}`:void 0,m=t.resources?`Resources:${t.resources.map(b=>`
|
|
6
|
-
- ${b}`).join("")}`:void 0,g=Ci(t.resources);if(g){const b=Br(g);r=ey(r,b)}return[s,n,"",r,"",i,o,a,c,l,u,d,h,m].filter(b=>b!=null).join(`
|
|
7
|
-
`)};function Hw(t){return Buffer.from(JSON.stringify(t)).toString("base64")}function Kw(t){return JSON.parse(Buffer.from(t,"base64").toString("utf-8"))}function En(t){if(!t)throw new Error("No recap provided, value is undefined");if(!t.att)throw new Error("No `att` property found");const e=Object.keys(t.att);if(!(e!=null&&e.length))throw new Error("No resources found in `att` property");e.forEach(s=>{const n=t.att[s];if(Array.isArray(n))throw new Error(`Resource must be an object: ${s}`);if(typeof n!="object")throw new Error(`Resource must be an object: ${s}`);if(!Object.keys(n).length)throw new Error(`Resource object is empty: ${s}`);Object.keys(n).forEach(r=>{const i=n[r];if(!Array.isArray(i))throw new Error(`Ability limits ${r} must be an array of objects, found: ${i}`);if(!i.length)throw new Error(`Value of ${r} is empty array, must be an array with objects`);i.forEach(o=>{if(typeof o!="object")throw new Error(`Ability limits (${r}) must be an array of objects, found: ${o}`)})})})}function Gw(t,e,s,n={}){return s?.sort((r,i)=>r.localeCompare(i)),{att:{[t]:Yw(e,s,n)}}}function Yw(t,e,s={}){e=e?.sort((r,i)=>r.localeCompare(i));const n=e.map(r=>({[`${t}/${r}`]:[s]}));return Object.assign({},...n)}function Ud(t){return En(t),`urn:recap:${Hw(t).replace(/=/g,"")}`}function Br(t){const e=Kw(t.replace("urn:recap:",""));return En(e),e}function Jw(t,e,s){const n=Gw(t,e,s);return Ud(n)}function Xw(t){return t&&t.includes("urn:recap:")}function Zw(t,e){const s=Br(t),n=Br(e),r=Qw(s,n);return Ud(r)}function Qw(t,e){En(t),En(e);const s=Object.keys(t.att).concat(Object.keys(e.att)).sort((r,i)=>r.localeCompare(i)),n={att:{}};return s.forEach(r=>{var i,o;Object.keys(((i=t.att)==null?void 0:i[r])||{}).concat(Object.keys(((o=e.att)==null?void 0:o[r])||{})).sort((a,c)=>a.localeCompare(c)).forEach(a=>{var c,l;n.att[r]=Ww(qw({},n.att[r]),{[a]:((c=t.att[r])==null?void 0:c[a])||((l=e.att[r])==null?void 0:l[a])})})}),n}function ey(t="",e){En(e);const s="I further authorize the stated URI to perform the following actions on my behalf: ";if(t.includes(s))return t;const n=[];let r=0;Object.keys(e.att).forEach(a=>{const c=Object.keys(e.att[a]).map(d=>({ability:d.split("/")[0],action:d.split("/")[1]}));c.sort((d,h)=>d.action.localeCompare(h.action));const l={};c.forEach(d=>{l[d.ability]||(l[d.ability]=[]),l[d.ability].push(d.action)});const u=Object.keys(l).map(d=>(r++,`(${r}) '${d}': '${l[d].join("', '")}' for '${a}'.`));n.push(u.join(", ").replace(".,","."))});const i=n.join(" "),o=`${s}${i}`;return`${t?t+" ":""}${o}`}function sl(t){var e;const s=Br(t);En(s);const n=(e=s.att)==null?void 0:e.eip155;return n?Object.keys(n).map(r=>r.split("/")[1]):[]}function nl(t){const e=Br(t);En(e);const s=[];return Object.values(e.att).forEach(n=>{Object.values(n).forEach(r=>{var i;(i=r?.[0])!=null&&i.chains&&s.push(r[0].chains)})}),[...new Set(s.flat())]}function Ci(t){if(!t)return;const e=t?.[t.length-1];return Xw(e)?e:void 0}function Ld(t){return t instanceof Uint8Array||ArrayBuffer.isView(t)&&t.constructor.name==="Uint8Array"}function ca(t){if(typeof t!="boolean")throw new Error(`boolean expected, not ${t}`)}function Io(t){if(!Number.isSafeInteger(t)||t<0)throw new Error("positive integer expected, got "+t)}function mt(t,...e){if(!Ld(t))throw new Error("Uint8Array expected");if(e.length>0&&!e.includes(t.length))throw new Error("Uint8Array expected of length "+e+", got length="+t.length)}function rl(t,e=!0){if(t.destroyed)throw new Error("Hash instance has been destroyed");if(e&&t.finished)throw new Error("Hash#digest() has already been called")}function ty(t,e){mt(t);const s=e.outputLen;if(t.length<s)throw new Error("digestInto() expects output buffer of length at least "+s)}function Gs(t){return new Uint32Array(t.buffer,t.byteOffset,Math.floor(t.byteLength/4))}function Zn(...t){for(let e=0;e<t.length;e++)t[e].fill(0)}function sy(t){return new DataView(t.buffer,t.byteOffset,t.byteLength)}const ny=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function ry(t){if(typeof t!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(t))}function la(t){if(typeof t=="string")t=ry(t);else if(Ld(t))t=ua(t);else throw new Error("Uint8Array expected, got "+typeof t);return t}function iy(t,e){if(e==null||typeof e!="object")throw new Error("options must be defined");return Object.assign(t,e)}function oy(t,e){if(t.length!==e.length)return!1;let s=0;for(let n=0;n<t.length;n++)s|=t[n]^e[n];return s===0}const ay=(t,e)=>{function s(n,...r){if(mt(n),!ny)throw new Error("Non little-endian hardware is not yet supported");if(t.nonceLength!==void 0){const l=r[0];if(!l)throw new Error("nonce / iv required");t.varSizeNonce?mt(l):mt(l,t.nonceLength)}const i=t.tagLength;i&&r[1]!==void 0&&mt(r[1]);const o=e(n,...r),a=(l,u)=>{if(u!==void 0){if(l!==2)throw new Error("cipher output not supported");mt(u)}};let c=!1;return{encrypt(l,u){if(c)throw new Error("cannot encrypt() twice with same key + nonce");return c=!0,mt(l),a(o.encrypt.length,u),o.encrypt(l,u)},decrypt(l,u){if(mt(l),i&&l.length<i)throw new Error("invalid ciphertext length: smaller than tagLength="+i);return a(o.decrypt.length,u),o.decrypt(l,u)}}}return Object.assign(s,t),s};function il(t,e,s=!0){if(e===void 0)return new Uint8Array(t);if(e.length!==t)throw new Error("invalid output length, expected "+t+", got: "+e.length);if(s&&!ly(e))throw new Error("invalid output, must be aligned");return e}function ol(t,e,s,n){if(typeof t.setBigUint64=="function")return t.setBigUint64(e,s,n);const r=BigInt(32),i=BigInt(4294967295),o=Number(s>>r&i),a=Number(s&i);t.setUint32(e+4,o,n),t.setUint32(e+0,a,n)}function cy(t,e,s){ca(s);const n=new Uint8Array(16),r=sy(n);return ol(r,0,BigInt(e),s),ol(r,8,BigInt(t),s),n}function ly(t){return t.byteOffset%4===0}function ua(t){return Uint8Array.from(t)}const Bd=t=>Uint8Array.from(t.split("").map(e=>e.charCodeAt(0))),uy=Bd("expand 16-byte k"),dy=Bd("expand 32-byte k"),hy=Gs(uy),py=Gs(dy);function Ee(t,e){return t<<e|t>>>32-e}function da(t){return t.byteOffset%4===0}const li=64,fy=16,Md=2**32-1,al=new Uint32Array;function gy(t,e,s,n,r,i,o,a){const c=r.length,l=new Uint8Array(li),u=Gs(l),d=da(r)&&da(i),h=d?Gs(r):al,m=d?Gs(i):al;for(let g=0;g<c;o++){if(t(e,s,n,u,o,a),o>=Md)throw new Error("arx: counter overflow");const b=Math.min(li,c-g);if(d&&b===li){const y=g/4;if(g%4!==0)throw new Error("arx: invalid block position");for(let _=0,N;_<fy;_++)N=y+_,m[N]=h[N]^u[_];g+=li;continue}for(let y=0,_;y<b;y++)_=g+y,i[_]=r[_]^l[y];g+=b}}function my(t,e){const{allowShortKeys:s,extendNonceFn:n,counterLength:r,counterRight:i,rounds:o}=iy({allowShortKeys:!1,counterLength:8,counterRight:!1,rounds:20},e);if(typeof t!="function")throw new Error("core must be a function");return Io(r),Io(o),ca(i),ca(s),(a,c,l,u,d=0)=>{mt(a),mt(c),mt(l);const h=l.length;if(u===void 0&&(u=new Uint8Array(h)),mt(u),Io(d),d<0||d>=Md)throw new Error("arx: counter overflow");if(u.length<h)throw new Error(`arx: output (${u.length}) is shorter than data (${h})`);const m=[];let g=a.length,b,y;if(g===32)m.push(b=ua(a)),y=py;else if(g===16&&s)b=new Uint8Array(32),b.set(a),b.set(a,16),y=hy,m.push(b);else throw new Error(`arx: invalid 32-byte key, got length=${g}`);da(c)||m.push(c=ua(c));const _=Gs(b);if(n){if(c.length!==24)throw new Error("arx: extended nonce must be 24 bytes");n(y,_,Gs(c.subarray(0,16)),_),c=c.subarray(16)}const N=16-r;if(N!==c.length)throw new Error(`arx: nonce must be ${N} or 16 bytes`);if(N!==12){const M=new Uint8Array(12);M.set(c,i?0:12-c.length),c=M,m.push(c)}const D=Gs(c);return gy(t,y,_,D,l,u,d,o),Zn(...m),u}}const ze=(t,e)=>t[e++]&255|(t[e++]&255)<<8;class wy{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=la(e),mt(e,32);const s=ze(e,0),n=ze(e,2),r=ze(e,4),i=ze(e,6),o=ze(e,8),a=ze(e,10),c=ze(e,12),l=ze(e,14);this.r[0]=s&8191,this.r[1]=(s>>>13|n<<3)&8191,this.r[2]=(n>>>10|r<<6)&7939,this.r[3]=(r>>>7|i<<9)&8191,this.r[4]=(i>>>4|o<<12)&255,this.r[5]=o>>>1&8190,this.r[6]=(o>>>14|a<<2)&8191,this.r[7]=(a>>>11|c<<5)&8065,this.r[8]=(c>>>8|l<<8)&8191,this.r[9]=l>>>5&127;for(let u=0;u<8;u++)this.pad[u]=ze(e,16+2*u)}process(e,s,n=!1){const r=n?0:2048,{h:i,r:o}=this,a=o[0],c=o[1],l=o[2],u=o[3],d=o[4],h=o[5],m=o[6],g=o[7],b=o[8],y=o[9],_=ze(e,s+0),N=ze(e,s+2),D=ze(e,s+4),M=ze(e,s+6),q=ze(e,s+8),p=ze(e,s+10),E=ze(e,s+12),C=ze(e,s+14);let A=i[0]+(_&8191),S=i[1]+((_>>>13|N<<3)&8191),$=i[2]+((N>>>10|D<<6)&8191),O=i[3]+((D>>>7|M<<9)&8191),v=i[4]+((M>>>4|q<<12)&8191),w=i[5]+(q>>>1&8191),I=i[6]+((q>>>14|p<<2)&8191),P=i[7]+((p>>>11|E<<5)&8191),U=i[8]+((E>>>8|C<<8)&8191),j=i[9]+(C>>>5|r),k=0,T=k+A*a+S*(5*y)+$*(5*b)+O*(5*g)+v*(5*m);k=T>>>13,T&=8191,T+=w*(5*h)+I*(5*d)+P*(5*u)+U*(5*l)+j*(5*c),k+=T>>>13,T&=8191;let W=k+A*c+S*a+$*(5*y)+O*(5*b)+v*(5*g);k=W>>>13,W&=8191,W+=w*(5*m)+I*(5*h)+P*(5*d)+U*(5*u)+j*(5*l),k+=W>>>13,W&=8191;let z=k+A*l+S*c+$*a+O*(5*y)+v*(5*b);k=z>>>13,z&=8191,z+=w*(5*g)+I*(5*m)+P*(5*h)+U*(5*d)+j*(5*u),k+=z>>>13,z&=8191;let ie=k+A*u+S*l+$*c+O*a+v*(5*y);k=ie>>>13,ie&=8191,ie+=w*(5*b)+I*(5*g)+P*(5*m)+U*(5*h)+j*(5*d),k+=ie>>>13,ie&=8191;let oe=k+A*d+S*u+$*l+O*c+v*a;k=oe>>>13,oe&=8191,oe+=w*(5*y)+I*(5*b)+P*(5*g)+U*(5*m)+j*(5*h),k+=oe>>>13,oe&=8191;let se=k+A*h+S*d+$*u+O*l+v*c;k=se>>>13,se&=8191,se+=w*a+I*(5*y)+P*(5*b)+U*(5*g)+j*(5*m),k+=se>>>13,se&=8191;let X=k+A*m+S*h+$*d+O*u+v*l;k=X>>>13,X&=8191,X+=w*c+I*a+P*(5*y)+U*(5*b)+j*(5*g),k+=X>>>13,X&=8191;let ue=k+A*g+S*m+$*h+O*d+v*u;k=ue>>>13,ue&=8191,ue+=w*l+I*c+P*a+U*(5*y)+j*(5*b),k+=ue>>>13,ue&=8191;let Te=k+A*b+S*g+$*m+O*h+v*d;k=Te>>>13,Te&=8191,Te+=w*u+I*l+P*c+U*a+j*(5*y),k+=Te>>>13,Te&=8191;let de=k+A*y+S*b+$*g+O*m+v*h;k=de>>>13,de&=8191,de+=w*d+I*u+P*l+U*c+j*a,k+=de>>>13,de&=8191,k=(k<<2)+k|0,k=k+T|0,T=k&8191,k=k>>>13,W+=k,i[0]=T,i[1]=W,i[2]=z,i[3]=ie,i[4]=oe,i[5]=se,i[6]=X,i[7]=ue,i[8]=Te,i[9]=de}finalize(){const{h:e,pad:s}=this,n=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,n[0]=e[0]+5,r=n[0]>>>13,n[0]&=8191;for(let a=1;a<10;a++)n[a]=e[a]+r,r=n[a]>>>13,n[a]&=8191;n[9]-=8192;let i=(r^1)-1;for(let a=0;a<10;a++)n[a]&=i;i=~i;for(let a=0;a<10;a++)e[a]=e[a]&i|n[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]+s[0];e[0]=o&65535;for(let a=1;a<8;a++)o=(e[a]+s[a]|0)+(o>>>16)|0,e[a]=o&65535;Zn(n)}update(e){rl(this),e=la(e),mt(e);const{buffer:s,blockLen:n}=this,r=e.length;for(let i=0;i<r;){const o=Math.min(n-this.pos,r-i);if(o===n){for(;n<=r-i;i+=n)this.process(e,i);continue}s.set(e.subarray(i,i+o),this.pos),this.pos+=o,i+=o,this.pos===n&&(this.process(s,0,!1),this.pos=0)}return this}destroy(){Zn(this.h,this.r,this.buffer,this.pad)}digestInto(e){rl(this),ty(e,this),this.finished=!0;const{buffer:s,h:n}=this;let{pos:r}=this;if(r){for(s[r++]=1;r<16;r++)s[r]=0;this.process(s,0,!0)}this.finalize();let i=0;for(let o=0;o<8;o++)e[i++]=n[o]>>>0,e[i++]=n[o]>>>8;return e}digest(){const{buffer:e,outputLen:s}=this;this.digestInto(e);const n=e.slice(0,s);return this.destroy(),n}}function yy(t){const e=(n,r)=>t(r).update(la(n)).digest(),s=t(new Uint8Array(32));return e.outputLen=s.outputLen,e.blockLen=s.blockLen,e.create=n=>t(n),e}const by=yy(t=>new wy(t));function Ey(t,e,s,n,r,i=20){let o=t[0],a=t[1],c=t[2],l=t[3],u=e[0],d=e[1],h=e[2],m=e[3],g=e[4],b=e[5],y=e[6],_=e[7],N=r,D=s[0],M=s[1],q=s[2],p=o,E=a,C=c,A=l,S=u,$=d,O=h,v=m,w=g,I=b,P=y,U=_,j=N,k=D,T=M,W=q;for(let ie=0;ie<i;ie+=2)p=p+S|0,j=Ee(j^p,16),w=w+j|0,S=Ee(S^w,12),p=p+S|0,j=Ee(j^p,8),w=w+j|0,S=Ee(S^w,7),E=E+$|0,k=Ee(k^E,16),I=I+k|0,$=Ee($^I,12),E=E+$|0,k=Ee(k^E,8),I=I+k|0,$=Ee($^I,7),C=C+O|0,T=Ee(T^C,16),P=P+T|0,O=Ee(O^P,12),C=C+O|0,T=Ee(T^C,8),P=P+T|0,O=Ee(O^P,7),A=A+v|0,W=Ee(W^A,16),U=U+W|0,v=Ee(v^U,12),A=A+v|0,W=Ee(W^A,8),U=U+W|0,v=Ee(v^U,7),p=p+$|0,W=Ee(W^p,16),P=P+W|0,$=Ee($^P,12),p=p+$|0,W=Ee(W^p,8),P=P+W|0,$=Ee($^P,7),E=E+O|0,j=Ee(j^E,16),U=U+j|0,O=Ee(O^U,12),E=E+O|0,j=Ee(j^E,8),U=U+j|0,O=Ee(O^U,7),C=C+v|0,k=Ee(k^C,16),w=w+k|0,v=Ee(v^w,12),C=C+v|0,k=Ee(k^C,8),w=w+k|0,v=Ee(v^w,7),A=A+S|0,T=Ee(T^A,16),I=I+T|0,S=Ee(S^I,12),A=A+S|0,T=Ee(T^A,8),I=I+T|0,S=Ee(S^I,7);let z=0;n[z++]=o+p|0,n[z++]=a+E|0,n[z++]=c+C|0,n[z++]=l+A|0,n[z++]=u+S|0,n[z++]=d+$|0,n[z++]=h+O|0,n[z++]=m+v|0,n[z++]=g+w|0,n[z++]=b+I|0,n[z++]=y+P|0,n[z++]=_+U|0,n[z++]=N+j|0,n[z++]=D+k|0,n[z++]=M+T|0,n[z++]=q+W|0}const Cy=my(Ey,{counterRight:!1,counterLength:4,allowShortKeys:!1}),vy=new Uint8Array(16),cl=(t,e)=>{t.update(e);const s=e.length%16;s&&t.update(vy.subarray(s))},Ay=new Uint8Array(32);function ll(t,e,s,n,r){const i=t(e,s,Ay),o=by.create(i);r&&cl(o,r),cl(o,n);const a=cy(n.length,r?r.length:0,!0);o.update(a);const c=o.digest();return Zn(i,a),c}const Iy=t=>(e,s,n)=>({encrypt(r,i){const o=r.length;i=il(o+16,i,!1),i.set(r);const a=i.subarray(0,-16);t(e,s,a,a,1);const c=ll(t,e,s,a,n);return i.set(c,o),Zn(c),i},decrypt(r,i){i=il(r.length-16,i,!1);const o=r.subarray(0,-16),a=r.subarray(-16),c=ll(t,e,s,o,n);if(!oy(a,c))throw new Error("invalid tag");return i.set(r.subarray(0,-16)),t(e,s,i,i,1),Zn(c),i}}),jd=ay({blockSize:64,nonceLength:12,tagLength:16},Iy(Cy));let Fd=class extends to{constructor(e,s){super(),this.finished=!1,this.destroyed=!1,eo(e);const n=Gt(s);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,i=new Uint8Array(r);i.set(n.length>r?e.create().update(n).digest():n);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),Mt(i)}update(e){return Js(this),this.iHash.update(e),this}digestInto(e){Js(this),Jt(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:s,iHash:n,finished:r,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=s._cloneInto(e.oHash),e.iHash=n._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}};const no=(t,e,s)=>new Fd(t,e).update(s).digest();no.create=(t,e)=>new Fd(t,e);function Ny(t,e,s){return eo(t),s===void 0&&(s=new Uint8Array(t.outputLen)),no(t,Gt(s),Gt(e))}const No=Uint8Array.from([0]),ul=Uint8Array.of();function _y(t,e,s,n=32){eo(t),Ts(n);const r=t.outputLen;if(n>255*r)throw new Error("Length should be <= 255*HashLen");const i=Math.ceil(n/r);s===void 0&&(s=ul);const o=new Uint8Array(i*r),a=no.create(t,e),c=a._cloneInto(),l=new Uint8Array(a.outputLen);for(let u=0;u<i;u++)No[0]=u+1,c.update(u===0?ul:l).update(s).update(No).digestInto(l),o.set(l,r*u),a._cloneInto(c);return a.destroy(),c.destroy(),Mt(l,No),o.slice(0,n)}const Sy=(t,e,s,n,r)=>_y(t,Ny(t,e,s),n,r),ro=so,Za=BigInt(0),ha=BigInt(1);function Mi(t,e=""){if(typeof t!="boolean"){const s=e&&`"${e}"`;throw new Error(s+"expected boolean, got type="+typeof t)}return t}function pn(t,e,s=""){const n=Qi(t),r=t?.length,i=e!==void 0;if(!n||i&&r!==e){const o=s&&`"${s}" `,a=i?` of length ${e}`:"",c=n?`length=${r}`:`type=${typeof t}`;throw new Error(o+"expected Uint8Array"+a+", got "+c)}return t}function ui(t){const e=t.toString(16);return e.length&1?"0"+e:e}function qd(t){if(typeof t!="string")throw new Error("hex string expected, got "+typeof t);return t===""?Za:BigInt("0x"+t)}function io(t){return qd(Hn(t))}function ji(t){return Jt(t),qd(Hn(Uint8Array.from(t).reverse()))}function Qa(t,e){return Li(t.toString(16).padStart(e*2,"0"))}function ec(t,e){return Qa(t,e).reverse()}function it(t,e,s){let n;if(typeof e=="string")try{n=Li(e)}catch(i){throw new Error(t+" must be hex string or Uint8Array, cause: "+i)}else if(Qi(e))n=Uint8Array.from(e);else throw new Error(t+" must be hex string or Uint8Array");const r=n.length;if(typeof s=="number"&&r!==s)throw new Error(t+" of length "+s+" expected, got "+r);return n}const _o=t=>typeof t=="bigint"&&Za<=t;function Ty(t,e,s){return _o(t)&&_o(e)&&_o(s)&&e<=t&&t<s}function pa(t,e,s,n){if(!Ty(e,s,n))throw new Error("expected valid "+t+": "+s+" <= n < "+n+", got "+e)}function Wd(t){let e;for(e=0;t>Za;t>>=ha,e+=1);return e}const Zr=t=>(ha<<BigInt(t))-ha;function Oy(t,e,s){if(typeof t!="number"||t<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof s!="function")throw new Error("hmacFn must be a function");const n=h=>new Uint8Array(h),r=h=>Uint8Array.of(h);let i=n(t),o=n(t),a=0;const c=()=>{i.fill(1),o.fill(0),a=0},l=(...h)=>s(o,i,...h),u=(h=n(0))=>{o=l(r(0),h),i=l(),h.length!==0&&(o=l(r(1),h),i=l())},d=()=>{if(a++>=1e3)throw new Error("drbg: tried 1000 values");let h=0;const m=[];for(;h<e;){i=l();const g=i.slice();m.push(g),h+=i.length}return Ws(...m)};return(h,m)=>{c(),u(h);let g;for(;!(g=m(d()));)u();return c(),g}}function oo(t,e,s={}){if(!t||typeof t!="object")throw new Error("expected valid options object");function n(r,i,o){const a=t[r];if(o&&a===void 0)return;const c=typeof a;if(c!==i||a===null)throw new Error(`param "${r}" is invalid: expected ${i}, got ${c}`)}Object.entries(e).forEach(([r,i])=>n(r,i,!1)),Object.entries(s).forEach(([r,i])=>n(r,i,!0))}function dl(t){const e=new WeakMap;return(s,...n)=>{const r=e.get(s);if(r!==void 0)return r;const i=t(s,...n);return e.set(s,i),i}}const yt=BigInt(0),at=BigInt(1),fn=BigInt(2),Vd=BigInt(3),zd=BigInt(4),Hd=BigInt(5),ky=BigInt(7),Kd=BigInt(8),Dy=BigInt(9),Gd=BigInt(16);function _t(t,e){const s=t%e;return s>=yt?s:e+s}function Vt(t,e,s){let n=t;for(;e-- >yt;)n*=n,n%=s;return n}function hl(t,e){if(t===yt)throw new Error("invert: expected non-zero number");if(e<=yt)throw new Error("invert: expected positive modulus, got "+e);let s=_t(t,e),n=e,r=yt,i=at;for(;s!==yt;){const o=n/s,a=n%s,c=r-i*o;n=s,s=a,r=i,i=c}if(n!==at)throw new Error("invert: does not exist");return _t(r,e)}function tc(t,e,s){if(!t.eql(t.sqr(e),s))throw new Error("Cannot find square root")}function Yd(t,e){const s=(t.ORDER+at)/zd,n=t.pow(e,s);return tc(t,n,e),n}function Py(t,e){const s=(t.ORDER-Hd)/Kd,n=t.mul(e,fn),r=t.pow(n,s),i=t.mul(e,r),o=t.mul(t.mul(i,fn),r),a=t.mul(i,t.sub(o,t.ONE));return tc(t,a,e),a}function Ry(t){const e=Zs(t),s=Jd(t),n=s(e,e.neg(e.ONE)),r=s(e,n),i=s(e,e.neg(n)),o=(t+ky)/Gd;return(a,c)=>{let l=a.pow(c,o),u=a.mul(l,n);const d=a.mul(l,r),h=a.mul(l,i),m=a.eql(a.sqr(u),c),g=a.eql(a.sqr(d),c);l=a.cmov(l,u,m),u=a.cmov(h,d,g);const b=a.eql(a.sqr(u),c),y=a.cmov(l,u,b);return tc(a,y,c),y}}function Jd(t){if(t<Vd)throw new Error("sqrt is not defined for small field");let e=t-at,s=0;for(;e%fn===yt;)e/=fn,s++;let n=fn;const r=Zs(t);for(;pl(r,n)===1;)if(n++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(s===1)return Yd;let i=r.pow(n,e);const o=(e+at)/fn;return function(a,c){if(a.is0(c))return c;if(pl(a,c)!==1)throw new Error("Cannot find square root");let l=s,u=a.mul(a.ONE,i),d=a.pow(c,e),h=a.pow(c,o);for(;!a.eql(d,a.ONE);){if(a.is0(d))return a.ZERO;let m=1,g=a.sqr(d);for(;!a.eql(g,a.ONE);)if(m++,g=a.sqr(g),m===l)throw new Error("Cannot find square root");const b=at<<BigInt(l-m-1),y=a.pow(u,b);l=m,u=a.sqr(y),d=a.mul(d,u),h=a.mul(h,y)}return h}}function xy(t){return t%zd===Vd?Yd:t%Kd===Hd?Py:t%Gd===Dy?Ry(t):Jd(t)}const $y=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function Uy(t){const e={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},s=$y.reduce((n,r)=>(n[r]="function",n),e);return oo(t,s),t}function Ly(t,e,s){if(s<yt)throw new Error("invalid exponent, negatives unsupported");if(s===yt)return t.ONE;if(s===at)return e;let n=t.ONE,r=e;for(;s>yt;)s&at&&(n=t.mul(n,r)),r=t.sqr(r),s>>=at;return n}function Xd(t,e,s=!1){const n=new Array(e.length).fill(s?t.ZERO:void 0),r=e.reduce((o,a,c)=>t.is0(a)?o:(n[c]=o,t.mul(o,a)),t.ONE),i=t.inv(r);return e.reduceRight((o,a,c)=>t.is0(a)?o:(n[c]=t.mul(o,n[c]),t.mul(o,a)),i),n}function pl(t,e){const s=(t.ORDER-at)/fn,n=t.pow(e,s),r=t.eql(n,t.ONE),i=t.eql(n,t.ZERO),o=t.eql(n,t.neg(t.ONE));if(!r&&!i&&!o)throw new Error("invalid Legendre symbol result");return r?1:i?0:-1}function Zd(t,e){e!==void 0&&Ts(e);const s=e!==void 0?e:t.toString(2).length,n=Math.ceil(s/8);return{nBitLength:s,nByteLength:n}}function Zs(t,e,s=!1,n={}){if(t<=yt)throw new Error("invalid field: expected ORDER > 0, got "+t);let r,i,o=!1,a;if(typeof e=="object"&&e!=null){if(n.sqrt||s)throw new Error("cannot specify opts in two arguments");const h=e;h.BITS&&(r=h.BITS),h.sqrt&&(i=h.sqrt),typeof h.isLE=="boolean"&&(s=h.isLE),typeof h.modFromBytes=="boolean"&&(o=h.modFromBytes),a=h.allowedLengths}else typeof e=="number"&&(r=e),n.sqrt&&(i=n.sqrt);const{nBitLength:c,nByteLength:l}=Zd(t,r);if(l>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let u;const d=Object.freeze({ORDER:t,isLE:s,BITS:c,BYTES:l,MASK:Zr(c),ZERO:yt,ONE:at,allowedLengths:a,create:h=>_t(h,t),isValid:h=>{if(typeof h!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof h);return yt<=h&&h<t},is0:h=>h===yt,isValidNot0:h=>!d.is0(h)&&d.isValid(h),isOdd:h=>(h&at)===at,neg:h=>_t(-h,t),eql:(h,m)=>h===m,sqr:h=>_t(h*h,t),add:(h,m)=>_t(h+m,t),sub:(h,m)=>_t(h-m,t),mul:(h,m)=>_t(h*m,t),pow:(h,m)=>Ly(d,h,m),div:(h,m)=>_t(h*hl(m,t),t),sqrN:h=>h*h,addN:(h,m)=>h+m,subN:(h,m)=>h-m,mulN:(h,m)=>h*m,inv:h=>hl(h,t),sqrt:i||(h=>(u||(u=xy(t)),u(d,h))),toBytes:h=>s?ec(h,l):Qa(h,l),fromBytes:(h,m=!0)=>{if(a){if(!a.includes(h.length)||h.length>l)throw new Error("Field.fromBytes: expected "+a+" bytes, got "+h.length);const b=new Uint8Array(l);b.set(h,s?0:b.length-h.length),h=b}if(h.length!==l)throw new Error("Field.fromBytes: expected "+l+" bytes, got "+h.length);let g=s?ji(h):io(h);if(o&&(g=_t(g,t)),!m&&!d.isValid(g))throw new Error("invalid field element: outside of range 0..ORDER");return g},invertBatch:h=>Xd(d,h),cmov:(h,m,g)=>g?m:h});return Object.freeze(d)}function Qd(t){if(typeof t!="bigint")throw new Error("field order must be bigint");const e=t.toString(2).length;return Math.ceil(e/8)}function eh(t){const e=Qd(t);return e+Math.ceil(e/2)}function By(t,e,s=!1){const n=t.length,r=Qd(e),i=eh(e);if(n<16||n<i||n>1024)throw new Error("expected "+i+"-1024 bytes of input, got "+n);const o=s?ji(t):io(t),a=_t(o,e-at)+at;return s?ec(a,r):Qa(a,r)}const Qn=BigInt(0),gn=BigInt(1);function Fi(t,e){const s=e.negate();return t?s:e}function So(t,e){const s=Xd(t.Fp,e.map(n=>n.Z));return e.map((n,r)=>t.fromAffine(n.toAffine(s[r])))}function th(t,e){if(!Number.isSafeInteger(t)||t<=0||t>e)throw new Error("invalid window size, expected [1.."+e+"], got W="+t)}function To(t,e){th(t,e);const s=Math.ceil(e/t)+1,n=2**(t-1),r=2**t,i=Zr(t),o=BigInt(t);return{windows:s,windowSize:n,mask:i,maxNumber:r,shiftBy:o}}function fl(t,e,s){const{windowSize:n,mask:r,maxNumber:i,shiftBy:o}=s;let a=Number(t&r),c=t>>o;a>n&&(a-=i,c+=gn);const l=e*n,u=l+Math.abs(a)-1,d=a===0,h=a<0,m=e%2!==0;return{nextN:c,offset:u,isZero:d,isNeg:h,isNegF:m,offsetF:l}}function My(t,e){if(!Array.isArray(t))throw new Error("array expected");t.forEach((s,n)=>{if(!(s instanceof e))throw new Error("invalid point at index "+n)})}function jy(t,e){if(!Array.isArray(t))throw new Error("array of scalars expected");t.forEach((s,n)=>{if(!e.isValid(s))throw new Error("invalid scalar at index "+n)})}const Oo=new WeakMap,sh=new WeakMap;function ko(t){return sh.get(t)||1}function gl(t){if(t!==Qn)throw new Error("invalid wNAF")}class Fy{constructor(e,s){this.BASE=e.BASE,this.ZERO=e.ZERO,this.Fn=e.Fn,this.bits=s}_unsafeLadder(e,s,n=this.ZERO){let r=e;for(;s>Qn;)s&gn&&(n=n.add(r)),r=r.double(),s>>=gn;return n}precomputeWindow(e,s){const{windows:n,windowSize:r}=To(s,this.bits),i=[];let o=e,a=o;for(let c=0;c<n;c++){a=o,i.push(a);for(let l=1;l<r;l++)a=a.add(o),i.push(a);o=a.double()}return i}wNAF(e,s,n){if(!this.Fn.isValid(n))throw new Error("invalid scalar");let r=this.ZERO,i=this.BASE;const o=To(e,this.bits);for(let a=0;a<o.windows;a++){const{nextN:c,offset:l,isZero:u,isNeg:d,isNegF:h,offsetF:m}=fl(n,a,o);n=c,u?i=i.add(Fi(h,s[m])):r=r.add(Fi(d,s[l]))}return gl(n),{p:r,f:i}}wNAFUnsafe(e,s,n,r=this.ZERO){const i=To(e,this.bits);for(let o=0;o<i.windows&&n!==Qn;o++){const{nextN:a,offset:c,isZero:l,isNeg:u}=fl(n,o,i);if(n=a,!l){const d=s[c];r=r.add(u?d.negate():d)}}return gl(n),r}getPrecomputes(e,s,n){let r=Oo.get(s);return r||(r=this.precomputeWindow(s,e),e!==1&&(typeof n=="function"&&(r=n(r)),Oo.set(s,r))),r}cached(e,s,n){const r=ko(e);return this.wNAF(r,this.getPrecomputes(r,e,n),s)}unsafe(e,s,n,r){const i=ko(e);return i===1?this._unsafeLadder(e,s,r):this.wNAFUnsafe(i,this.getPrecomputes(i,e,n),s,r)}createCache(e,s){th(s,this.bits),sh.set(e,s),Oo.delete(e)}hasCache(e){return ko(e)!==1}}function qy(t,e,s,n){let r=e,i=t.ZERO,o=t.ZERO;for(;s>Qn||n>Qn;)s&gn&&(i=i.add(r)),n&gn&&(o=o.add(r)),r=r.double(),s>>=gn,n>>=gn;return{p1:i,p2:o}}function Wy(t,e,s,n){My(s,t),jy(n,e);const r=s.length,i=n.length;if(r!==i)throw new Error("arrays of points and scalars must have equal length");const o=t.ZERO,a=Wd(BigInt(r));let c=1;a>12?c=a-3:a>4?c=a-2:a>0&&(c=2);const l=Zr(c),u=new Array(Number(l)+1).fill(o),d=Math.floor((e.BITS-1)/c)*c;let h=o;for(let m=d;m>=0;m-=c){u.fill(o);for(let b=0;b<i;b++){const y=n[b],_=Number(y>>BigInt(m)&l);u[_]=u[_].add(s[b])}let g=o;for(let b=u.length-1,y=o;b>0;b--)y=y.add(u[b]),g=g.add(y);if(h=h.add(g),m!==0)for(let b=0;b<c;b++)h=h.double()}return h}function ml(t,e,s){if(e){if(e.ORDER!==t)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return Uy(e),e}else return Zs(t,{isLE:s})}function Vy(t,e,s={},n){if(n===void 0&&(n=t==="edwards"),!e||typeof e!="object")throw new Error(`expected valid ${t} CURVE object`);for(const a of["p","n","h"]){const c=e[a];if(!(typeof c=="bigint"&&c>Qn))throw new Error(`CURVE.${a} must be positive bigint`)}const r=ml(e.p,s.Fp,n),i=ml(e.n,s.Fn,n),o=["Gx","Gy","a","b"];for(const a of o)if(!r.isValid(e[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return e=Object.freeze(Object.assign({},e)),{CURVE:e,Fp:r,Fn:i}}BigInt(0),BigInt(1),BigInt(2),BigInt(8),_d("HashToScalar-");const dr=BigInt(0),Pn=BigInt(1),di=BigInt(2);function zy(t){return oo(t,{adjustScalarBytes:"function",powPminus2:"function"}),Object.freeze({...t})}function Hy(t){const e=zy(t),{P:s,type:n,adjustScalarBytes:r,powPminus2:i,randomBytes:o}=e,a=n==="x25519";if(!a&&n!=="x448")throw new Error("invalid type");const c=o||Sn,l=a?255:448,u=a?32:56,d=BigInt(a?9:5),h=BigInt(a?121665:39081),m=a?di**BigInt(254):di**BigInt(447),g=a?BigInt(8)*di**BigInt(251)-Pn:BigInt(4)*di**BigInt(445)-Pn,b=m+g+Pn,y=O=>_t(O,s),_=N(d);function N(O){return ec(y(O),u)}function D(O){const v=it("u coordinate",O,u);return a&&(v[31]&=127),y(ji(v))}function M(O){return ji(r(it("scalar",O,u)))}function q(O,v){const w=C(D(v),M(O));if(w===dr)throw new Error("invalid private or public key received");return N(w)}function p(O){return q(O,_)}function E(O,v,w){const I=y(O*(v-w));return v=y(v-I),w=y(w+I),{x_2:v,x_3:w}}function C(O,v){pa("u",O,dr,s),pa("scalar",v,m,b);const w=v,I=O;let P=Pn,U=dr,j=O,k=Pn,T=dr;for(let z=BigInt(l-1);z>=dr;z--){const ie=w>>z&Pn;T^=ie,{x_2:P,x_3:j}=E(T,P,j),{x_2:U,x_3:k}=E(T,U,k),T=ie;const oe=P+U,se=y(oe*oe),X=P-U,ue=y(X*X),Te=se-ue,de=j+k,$e=j-k,Ft=y($e*oe),Os=y(de*X),Qs=Ft+Os,On=Ft-Os;j=y(Qs*Qs),k=y(I*y(On*On)),P=y(se*ue),U=y(Te*(se+y(h*Te)))}({x_2:P,x_3:j}=E(T,P,j)),{x_2:U,x_3:k}=E(T,U,k);const W=i(U);return y(P*W)}const A={secretKey:u,publicKey:u,seed:u},S=(O=c(u))=>(Jt(O,A.seed),O);function $(O){const v=S(O);return{secretKey:v,publicKey:p(v)}}return{keygen:$,getSharedSecret:(O,v)=>q(O,v),getPublicKey:O=>p(O),scalarMult:q,scalarMultBase:p,utils:{randomSecretKey:S,randomPrivateKey:S},GuBytes:_.slice(),lengths:A}}const Ky=BigInt(1),wl=BigInt(2),Gy=BigInt(3),Yy=BigInt(5);BigInt(8);const nh=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),Jy={p:nh,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Xy(t){const e=BigInt(10),s=BigInt(20),n=BigInt(40),r=BigInt(80),i=nh,o=t*t%i*t%i,a=Vt(o,wl,i)*o%i,c=Vt(a,Ky,i)*t%i,l=Vt(c,Yy,i)*c%i,u=Vt(l,e,i)*l%i,d=Vt(u,s,i)*u%i,h=Vt(d,n,i)*d%i,m=Vt(h,r,i)*h%i,g=Vt(m,r,i)*h%i,b=Vt(g,e,i)*l%i;return{pow_p_5_8:Vt(b,wl,i)*t%i,b2:o}}function Zy(t){return t[0]&=248,t[31]&=127,t[31]|=64,t}const Qy=Zs(Jy.p,{isLE:!0}),fa=(()=>{const t=Qy.ORDER;return Hy({P:t,type:"x25519",powPminus2:e=>{const{pow_p_5_8:s,b2:n}=Xy(e);return _t(Vt(s,Gy,t)*n,t)},adjustScalarBytes:Zy})})(),yl=(t,e)=>(t+(t>=0?e:-e)/rh)/e;function eb(t,e,s){const[[n,r],[i,o]]=e,a=yl(o*t,s),c=yl(-r*t,s);let l=t-a*n-c*i,u=-a*r-c*o;const d=l<As,h=u<As;d&&(l=-l),h&&(u=-u);const m=Zr(Math.ceil(Wd(s)/2))+Kn;if(l<As||l>=m||u<As||u>=m)throw new Error("splitScalar (endomorphism): failed, k="+t);return{k1neg:d,k1:l,k2neg:h,k2:u}}function ga(t){if(!["compact","recovered","der"].includes(t))throw new Error('Signature format must be "compact", "recovered", or "der"');return t}function Do(t,e){const s={};for(let n of Object.keys(e))s[n]=t[n]===void 0?e[n]:t[n];return Mi(s.lowS,"lowS"),Mi(s.prehash,"prehash"),s.format!==void 0&&ga(s.format),s}class tb extends Error{constructor(e=""){super(e)}}const Es={Err:tb,_tlv:{encode:(t,e)=>{const{Err:s}=Es;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length&1)throw new s("tlv.encode: unpadded data");const n=e.length/2,r=ui(n);if(r.length/2&128)throw new s("tlv.encode: long form length too big");const i=n>127?ui(r.length/2|128):"";return ui(t)+i+r+e},decode(t,e){const{Err:s}=Es;let n=0;if(t<0||t>256)throw new s("tlv.encode: wrong tag");if(e.length<2||e[n++]!==t)throw new s("tlv.decode: wrong tlv");const r=e[n++],i=!!(r&128);let o=0;if(!i)o=r;else{const c=r&127;if(!c)throw new s("tlv.decode(long): indefinite length not supported");if(c>4)throw new s("tlv.decode(long): byte length is too big");const l=e.subarray(n,n+c);if(l.length!==c)throw new s("tlv.decode: length bytes not complete");if(l[0]===0)throw new s("tlv.decode(long): zero leftmost byte");for(const u of l)o=o<<8|u;if(n+=c,o<128)throw new s("tlv.decode(long): not minimal encoding")}const a=e.subarray(n,n+o);if(a.length!==o)throw new s("tlv.decode: wrong value length");return{v:a,l:e.subarray(n+o)}}},_int:{encode(t){const{Err:e}=Es;if(t<As)throw new e("integer: negative integers are not allowed");let s=ui(t);if(Number.parseInt(s[0],16)&8&&(s="00"+s),s.length&1)throw new e("unexpected DER parsing assertion: unpadded hex");return s},decode(t){const{Err:e}=Es;if(t[0]&128)throw new e("invalid signature integer: negative");if(t[0]===0&&!(t[1]&128))throw new e("invalid signature integer: unnecessary leading zero");return io(t)}},toSig(t){const{Err:e,_int:s,_tlv:n}=Es,r=it("signature",t),{v:i,l:o}=n.decode(48,r);if(o.length)throw new e("invalid signature: left bytes after parsing");const{v:a,l:c}=n.decode(2,i),{v:l,l:u}=n.decode(2,c);if(u.length)throw new e("invalid signature: left bytes after parsing");return{r:s.decode(a),s:s.decode(l)}},hexFromSig(t){const{_tlv:e,_int:s}=Es,n=e.encode(2,s.encode(t.r)),r=e.encode(2,s.encode(t.s)),i=n+r;return e.encode(48,i)}},As=BigInt(0),Kn=BigInt(1),rh=BigInt(2),hi=BigInt(3),sb=BigInt(4);function qn(t,e){const{BYTES:s}=t;let n;if(typeof e=="bigint")n=e;else{let r=it("private key",e);try{n=t.fromBytes(r)}catch{throw new Error(`invalid private key: expected ui8a of size ${s}, got ${typeof e}`)}}if(!t.isValidNot0(n))throw new Error("invalid private key: out of range [1..N-1]");return n}function nb(t,e={}){const s=Vy("weierstrass",t,e),{Fp:n,Fn:r}=s;let i=s.CURVE;const{h:o,n:a}=i;oo(e,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:c}=e;if(c&&(!n.is0(i.a)||typeof c.beta!="bigint"||!Array.isArray(c.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const l=oh(n,r);function u(){if(!n.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function d(O,v,w){const{x:I,y:P}=v.toAffine(),U=n.toBytes(I);if(Mi(w,"isCompressed"),w){u();const j=!n.isOdd(P);return Ws(ih(j),U)}else return Ws(Uint8Array.of(4),U,n.toBytes(P))}function h(O){pn(O,void 0,"Point");const{publicKey:v,publicKeyUncompressed:w}=l,I=O.length,P=O[0],U=O.subarray(1);if(I===v&&(P===2||P===3)){const j=n.fromBytes(U);if(!n.isValid(j))throw new Error("bad point: is not on curve, wrong x");const k=b(j);let T;try{T=n.sqrt(k)}catch(z){const ie=z instanceof Error?": "+z.message:"";throw new Error("bad point: is not on curve, sqrt error"+ie)}u();const W=n.isOdd(T);return(P&1)===1!==W&&(T=n.neg(T)),{x:j,y:T}}else if(I===w&&P===4){const j=n.BYTES,k=n.fromBytes(U.subarray(0,j)),T=n.fromBytes(U.subarray(j,j*2));if(!y(k,T))throw new Error("bad point: is not on curve");return{x:k,y:T}}else throw new Error(`bad point: got length ${I}, expected compressed=${v} or uncompressed=${w}`)}const m=e.toBytes||d,g=e.fromBytes||h;function b(O){const v=n.sqr(O),w=n.mul(v,O);return n.add(n.add(w,n.mul(O,i.a)),i.b)}function y(O,v){const w=n.sqr(v),I=b(O);return n.eql(w,I)}if(!y(i.Gx,i.Gy))throw new Error("bad curve params: generator point");const _=n.mul(n.pow(i.a,hi),sb),N=n.mul(n.sqr(i.b),BigInt(27));if(n.is0(n.add(_,N)))throw new Error("bad curve params: a or b");function D(O,v,w=!1){if(!n.isValid(v)||w&&n.is0(v))throw new Error(`bad point coordinate ${O}`);return v}function M(O){if(!(O instanceof A))throw new Error("ProjectivePoint expected")}function q(O){if(!c||!c.basises)throw new Error("no endo");return eb(O,c.basises,r.ORDER)}const p=dl((O,v)=>{const{X:w,Y:I,Z:P}=O;if(n.eql(P,n.ONE))return{x:w,y:I};const U=O.is0();v==null&&(v=U?n.ONE:n.inv(P));const j=n.mul(w,v),k=n.mul(I,v),T=n.mul(P,v);if(U)return{x:n.ZERO,y:n.ZERO};if(!n.eql(T,n.ONE))throw new Error("invZ was invalid");return{x:j,y:k}}),E=dl(O=>{if(O.is0()){if(e.allowInfinityPoint&&!n.is0(O.Y))return;throw new Error("bad point: ZERO")}const{x:v,y:w}=O.toAffine();if(!n.isValid(v)||!n.isValid(w))throw new Error("bad point: x or y not field elements");if(!y(v,w))throw new Error("bad point: equation left != right");if(!O.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function C(O,v,w,I,P){return w=new A(n.mul(w.X,O),w.Y,w.Z),v=Fi(I,v),w=Fi(P,w),v.add(w)}class A{constructor(v,w,I){this.X=D("x",v),this.Y=D("y",w,!0),this.Z=D("z",I),Object.freeze(this)}static CURVE(){return i}static fromAffine(v){const{x:w,y:I}=v||{};if(!v||!n.isValid(w)||!n.isValid(I))throw new Error("invalid affine point");if(v instanceof A)throw new Error("projective point not allowed");return n.is0(w)&&n.is0(I)?A.ZERO:new A(w,I,n.ONE)}static fromBytes(v){const w=A.fromAffine(g(pn(v,void 0,"point")));return w.assertValidity(),w}static fromHex(v){return A.fromBytes(it("pointHex",v))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(v=8,w=!0){return $.createCache(this,v),w||this.multiply(hi),this}assertValidity(){E(this)}hasEvenY(){const{y:v}=this.toAffine();if(!n.isOdd)throw new Error("Field doesn't support isOdd");return!n.isOdd(v)}equals(v){M(v);const{X:w,Y:I,Z:P}=this,{X:U,Y:j,Z:k}=v,T=n.eql(n.mul(w,k),n.mul(U,P)),W=n.eql(n.mul(I,k),n.mul(j,P));return T&&W}negate(){return new A(this.X,n.neg(this.Y),this.Z)}double(){const{a:v,b:w}=i,I=n.mul(w,hi),{X:P,Y:U,Z:j}=this;let k=n.ZERO,T=n.ZERO,W=n.ZERO,z=n.mul(P,P),ie=n.mul(U,U),oe=n.mul(j,j),se=n.mul(P,U);return se=n.add(se,se),W=n.mul(P,j),W=n.add(W,W),k=n.mul(v,W),T=n.mul(I,oe),T=n.add(k,T),k=n.sub(ie,T),T=n.add(ie,T),T=n.mul(k,T),k=n.mul(se,k),W=n.mul(I,W),oe=n.mul(v,oe),se=n.sub(z,oe),se=n.mul(v,se),se=n.add(se,W),W=n.add(z,z),z=n.add(W,z),z=n.add(z,oe),z=n.mul(z,se),T=n.add(T,z),oe=n.mul(U,j),oe=n.add(oe,oe),z=n.mul(oe,se),k=n.sub(k,z),W=n.mul(oe,ie),W=n.add(W,W),W=n.add(W,W),new A(k,T,W)}add(v){M(v);const{X:w,Y:I,Z:P}=this,{X:U,Y:j,Z:k}=v;let T=n.ZERO,W=n.ZERO,z=n.ZERO;const ie=i.a,oe=n.mul(i.b,hi);let se=n.mul(w,U),X=n.mul(I,j),ue=n.mul(P,k),Te=n.add(w,I),de=n.add(U,j);Te=n.mul(Te,de),de=n.add(se,X),Te=n.sub(Te,de),de=n.add(w,P);let $e=n.add(U,k);return de=n.mul(de,$e),$e=n.add(se,ue),de=n.sub(de,$e),$e=n.add(I,P),T=n.add(j,k),$e=n.mul($e,T),T=n.add(X,ue),$e=n.sub($e,T),z=n.mul(ie,de),T=n.mul(oe,ue),z=n.add(T,z),T=n.sub(X,z),z=n.add(X,z),W=n.mul(T,z),X=n.add(se,se),X=n.add(X,se),ue=n.mul(ie,ue),de=n.mul(oe,de),X=n.add(X,ue),ue=n.sub(se,ue),ue=n.mul(ie,ue),de=n.add(de,ue),se=n.mul(X,de),W=n.add(W,se),se=n.mul($e,de),T=n.mul(Te,T),T=n.sub(T,se),se=n.mul(Te,X),z=n.mul($e,z),z=n.add(z,se),new A(T,W,z)}subtract(v){return this.add(v.negate())}is0(){return this.equals(A.ZERO)}multiply(v){const{endo:w}=e;if(!r.isValidNot0(v))throw new Error("invalid scalar: out of range");let I,P;const U=j=>$.cached(this,j,k=>So(A,k));if(w){const{k1neg:j,k1:k,k2neg:T,k2:W}=q(v),{p:z,f:ie}=U(k),{p:oe,f:se}=U(W);P=ie.add(se),I=C(w.beta,z,oe,j,T)}else{const{p:j,f:k}=U(v);I=j,P=k}return So(A,[I,P])[0]}multiplyUnsafe(v){const{endo:w}=e,I=this;if(!r.isValid(v))throw new Error("invalid scalar: out of range");if(v===As||I.is0())return A.ZERO;if(v===Kn)return I;if($.hasCache(this))return this.multiply(v);if(w){const{k1neg:P,k1:U,k2neg:j,k2:k}=q(v),{p1:T,p2:W}=qy(A,I,U,k);return C(w.beta,T,W,P,j)}else return $.unsafe(I,v)}multiplyAndAddUnsafe(v,w,I){const P=this.multiplyUnsafe(w).add(v.multiplyUnsafe(I));return P.is0()?void 0:P}toAffine(v){return p(this,v)}isTorsionFree(){const{isTorsionFree:v}=e;return o===Kn?!0:v?v(A,this):$.unsafe(this,a).is0()}clearCofactor(){const{clearCofactor:v}=e;return o===Kn?this:v?v(A,this):this.multiplyUnsafe(o)}isSmallOrder(){return this.multiplyUnsafe(o).is0()}toBytes(v=!0){return Mi(v,"isCompressed"),this.assertValidity(),m(A,this,v)}toHex(v=!0){return Hn(this.toBytes(v))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(v=!0){return this.toBytes(v)}_setWindowSize(v){this.precompute(v)}static normalizeZ(v){return So(A,v)}static msm(v,w){return Wy(A,r,v,w)}static fromPrivateKey(v){return A.BASE.multiply(qn(r,v))}}A.BASE=new A(i.Gx,i.Gy,n.ONE),A.ZERO=new A(n.ZERO,n.ONE,n.ZERO),A.Fp=n,A.Fn=r;const S=r.BITS,$=new Fy(A,e.endo?Math.ceil(S/2):S);return A.BASE.precompute(8),A}function ih(t){return Uint8Array.of(t?2:3)}function oh(t,e){return{secretKey:e.BYTES,publicKey:1+t.BYTES,publicKeyUncompressed:1+2*t.BYTES,publicKeyHasPrefix:!0,signature:2*e.BYTES}}function rb(t,e={}){const{Fn:s}=t,n=e.randomBytes||Sn,r=Object.assign(oh(t.Fp,s),{seed:eh(s.ORDER)});function i(h){try{return!!qn(s,h)}catch{return!1}}function o(h,m){const{publicKey:g,publicKeyUncompressed:b}=r;try{const y=h.length;return m===!0&&y!==g||m===!1&&y!==b?!1:!!t.fromBytes(h)}catch{return!1}}function a(h=n(r.seed)){return By(pn(h,r.seed,"seed"),s.ORDER)}function c(h,m=!0){return t.BASE.multiply(qn(s,h)).toBytes(m)}function l(h){const m=a(h);return{secretKey:m,publicKey:c(m)}}function u(h){if(typeof h=="bigint")return!1;if(h instanceof t)return!0;const{secretKey:m,publicKey:g,publicKeyUncompressed:b}=r;if(s.allowedLengths||m===g)return;const y=it("key",h).length;return y===g||y===b}function d(h,m,g=!0){if(u(h)===!0)throw new Error("first arg must be private key");if(u(m)===!1)throw new Error("second arg must be public key");const b=qn(s,h);return t.fromHex(m).multiply(b).toBytes(g)}return Object.freeze({getPublicKey:c,getSharedSecret:d,keygen:l,Point:t,utils:{isValidSecretKey:i,isValidPublicKey:o,randomSecretKey:a,isValidPrivateKey:i,randomPrivateKey:a,normPrivateKeyToScalar:h=>qn(s,h),precompute(h=8,m=t.BASE){return m.precompute(h,!1)}},lengths:r})}function ib(t,e,s={}){eo(e),oo(s,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const n=s.randomBytes||Sn,r=s.hmac||((w,...I)=>no(e,w,Ws(...I))),{Fp:i,Fn:o}=t,{ORDER:a,BITS:c}=o,{keygen:l,getPublicKey:u,getSharedSecret:d,utils:h,lengths:m}=rb(t,s),g={prehash:!1,lowS:typeof s.lowS=="boolean"?s.lowS:!1,format:void 0,extraEntropy:!1},b="compact";function y(w){const I=a>>Kn;return w>I}function _(w,I){if(!o.isValidNot0(I))throw new Error(`invalid signature ${w}: out of range 1..Point.Fn.ORDER`);return I}function N(w,I){ga(I);const P=m.signature,U=I==="compact"?P:I==="recovered"?P+1:void 0;return pn(w,U,`${I} signature`)}class D{constructor(I,P,U){this.r=_("r",I),this.s=_("s",P),U!=null&&(this.recovery=U),Object.freeze(this)}static fromBytes(I,P=b){N(I,P);let U;if(P==="der"){const{r:W,s:z}=Es.toSig(pn(I));return new D(W,z)}P==="recovered"&&(U=I[0],P="compact",I=I.subarray(1));const j=o.BYTES,k=I.subarray(0,j),T=I.subarray(j,j*2);return new D(o.fromBytes(k),o.fromBytes(T),U)}static fromHex(I,P){return this.fromBytes(Li(I),P)}addRecoveryBit(I){return new D(this.r,this.s,I)}recoverPublicKey(I){const P=i.ORDER,{r:U,s:j,recovery:k}=this;if(k==null||![0,1,2,3].includes(k))throw new Error("recovery id invalid");if(a*rh<P&&k>1)throw new Error("recovery id is ambiguous for h>1 curve");const T=k===2||k===3?U+a:U;if(!i.isValid(T))throw new Error("recovery id 2 or 3 invalid");const W=i.toBytes(T),z=t.fromBytes(Ws(ih((k&1)===0),W)),ie=o.inv(T),oe=q(it("msgHash",I)),se=o.create(-oe*ie),X=o.create(j*ie),ue=t.BASE.multiplyUnsafe(se).add(z.multiplyUnsafe(X));if(ue.is0())throw new Error("point at infinify");return ue.assertValidity(),ue}hasHighS(){return y(this.s)}toBytes(I=b){if(ga(I),I==="der")return Li(Es.hexFromSig(this));const P=o.toBytes(this.r),U=o.toBytes(this.s);if(I==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Ws(Uint8Array.of(this.recovery),P,U)}return Ws(P,U)}toHex(I){return Hn(this.toBytes(I))}assertValidity(){}static fromCompact(I){return D.fromBytes(it("sig",I),"compact")}static fromDER(I){return D.fromBytes(it("sig",I),"der")}normalizeS(){return this.hasHighS()?new D(this.r,o.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return Hn(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return Hn(this.toBytes("compact"))}}const M=s.bits2int||function(w){if(w.length>8192)throw new Error("input is too large");const I=io(w),P=w.length*8-c;return P>0?I>>BigInt(P):I},q=s.bits2int_modN||function(w){return o.create(M(w))},p=Zr(c);function E(w){return pa("num < 2^"+c,w,As,p),o.toBytes(w)}function C(w,I){return pn(w,void 0,"message"),I?pn(e(w),void 0,"prehashed message"):w}function A(w,I,P){if(["recovered","canonical"].some(X=>X in P))throw new Error("sign() legacy options not supported");const{lowS:U,prehash:j,extraEntropy:k}=Do(P,g);w=C(w,j);const T=q(w),W=qn(o,I),z=[E(W),E(T)];if(k!=null&&k!==!1){const X=k===!0?n(m.secretKey):k;z.push(it("extraEntropy",X))}const ie=Ws(...z),oe=T;function se(X){const ue=M(X);if(!o.isValidNot0(ue))return;const Te=o.inv(ue),de=t.BASE.multiply(ue).toAffine(),$e=o.create(de.x);if($e===As)return;const Ft=o.create(Te*o.create(oe+$e*W));if(Ft===As)return;let Os=(de.x===$e?0:2)|Number(de.y&Kn),Qs=Ft;return U&&y(Ft)&&(Qs=o.neg(Ft),Os^=1),new D($e,Qs,Os)}return{seed:ie,k2sig:se}}function S(w,I,P={}){w=it("message",w);const{seed:U,k2sig:j}=A(w,I,P);return Oy(e.outputLen,o.BYTES,r)(U,j)}function $(w){let I;const P=typeof w=="string"||Qi(w),U=!P&&w!==null&&typeof w=="object"&&typeof w.r=="bigint"&&typeof w.s=="bigint";if(!P&&!U)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(U)I=new D(w.r,w.s);else if(P){try{I=D.fromBytes(it("sig",w),"der")}catch(j){if(!(j instanceof Es.Err))throw j}if(!I)try{I=D.fromBytes(it("sig",w),"compact")}catch{return!1}}return I||!1}function O(w,I,P,U={}){const{lowS:j,prehash:k,format:T}=Do(U,g);if(P=it("publicKey",P),I=C(it("message",I),k),"strict"in U)throw new Error("options.strict was renamed to lowS");const W=T===void 0?$(w):D.fromBytes(it("sig",w),T);if(W===!1)return!1;try{const z=t.fromBytes(P);if(j&&W.hasHighS())return!1;const{r:ie,s:oe}=W,se=q(I),X=o.inv(oe),ue=o.create(se*X),Te=o.create(ie*X),de=t.BASE.multiplyUnsafe(ue).add(z.multiplyUnsafe(Te));return de.is0()?!1:o.create(de.x)===ie}catch{return!1}}function v(w,I,P={}){const{prehash:U}=Do(P,g);return I=C(I,U),D.fromBytes(w,"recovered").recoverPublicKey(I).toBytes()}return Object.freeze({keygen:l,getPublicKey:u,getSharedSecret:d,utils:h,lengths:m,Point:t,sign:S,verify:O,recoverPublicKey:v,Signature:D,hash:e})}function ob(t){const e={a:t.a,b:t.b,p:t.Fp.ORDER,n:t.n,h:t.h,Gx:t.Gx,Gy:t.Gy},s=t.Fp;let n=t.allowedPrivateKeyLengths?Array.from(new Set(t.allowedPrivateKeyLengths.map(o=>Math.ceil(o/2)))):void 0;const r=Zs(e.n,{BITS:t.nBitLength,allowedLengths:n,modFromBytes:t.wrapPrivateKey}),i={Fp:s,Fn:r,allowInfinityPoint:t.allowInfinityPoint,endo:t.endo,isTorsionFree:t.isTorsionFree,clearCofactor:t.clearCofactor,fromBytes:t.fromBytes,toBytes:t.toBytes};return{CURVE:e,curveOpts:i}}function ab(t){const{CURVE:e,curveOpts:s}=ob(t),n={hmac:t.hmac,randomBytes:t.randomBytes,lowS:t.lowS,bits2int:t.bits2int,bits2int_modN:t.bits2int_modN};return{CURVE:e,curveOpts:s,hash:t.hash,ecdsaOpts:n}}function cb(t,e){const s=e.Point;return Object.assign({},e,{ProjectivePoint:s,CURVE:Object.assign({},t,Zd(s.Fn.ORDER,s.Fn.BITS))})}function lb(t){const{CURVE:e,curveOpts:s,hash:n,ecdsaOpts:r}=ab(t),i=nb(e,s),o=ib(i,n,r);return cb(t,o)}function ma(t,e){const s=n=>lb({...t,hash:n});return{...s(e),create:s}}const ah={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},ch={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},lh={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},ub=Zs(ah.p),db=Zs(ch.p),hb=Zs(lh.p),pb=ma({...ah,Fp:ub,lowS:!1},so);ma({...ch,Fp:db,lowS:!1},Ew),ma({...lh,Fp:hb,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},bw);const fb=pb,uh="base10",ct="base16",wt="base64pad",Vs="base64url",Qr="utf8",dh=0,Ns=1,ei=2,gb=0,bl=1,Or=12,sc=32;function mb(){const t=fa.utils.randomPrivateKey(),e=fa.getPublicKey(t);return{privateKey:bt(t,ct),publicKey:bt(e,ct)}}function wa(){const t=Sn(sc);return bt(t,ct)}function wb(t,e){const s=fa.getSharedSecret(Bt(t,ct),Bt(e,ct)),n=Sy(ro,s,void 0,void 0,sc);return bt(n,ct)}function vi(t){const e=ro(Bt(t,ct));return bt(e,ct)}function $t(t){const e=ro(Bt(t,Qr));return bt(e,ct)}function hh(t){return Bt(`${t}`,uh)}function Cn(t){return Number(bt(t,uh))}function ph(t){return t.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function fh(t){const e=t.replace(/-/g,"+").replace(/_/g,"/"),s=(4-e.length%4)%4;return e+"=".repeat(s)}function yb(t){const e=hh(typeof t.type<"u"?t.type:dh);if(Cn(e)===Ns&&typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");const s=typeof t.senderPublicKey<"u"?Bt(t.senderPublicKey,ct):void 0,n=typeof t.iv<"u"?Bt(t.iv,ct):Sn(Or),r=Bt(t.symKey,ct),i=jd(r,n).encrypt(Bt(t.message,Qr)),o=gh({type:e,sealed:i,iv:n,senderPublicKey:s});return t.encoding===Vs?ph(o):o}function bb(t){const e=Bt(t.symKey,ct),{sealed:s,iv:n}=Mr({encoded:t.encoded,encoding:t.encoding}),r=jd(e,n).decrypt(s);if(r===null)throw new Error("Failed to decrypt");return bt(r,Qr)}function Eb(t,e){const s=hh(ei),n=Sn(Or),r=Bt(t,Qr),i=gh({type:s,sealed:r,iv:n});return e===Vs?ph(i):i}function Cb(t,e){const{sealed:s}=Mr({encoded:t,encoding:e});return bt(s,Qr)}function gh(t){if(Cn(t.type)===ei)return bt(Tr([t.type,t.sealed]),wt);if(Cn(t.type)===Ns){if(typeof t.senderPublicKey>"u")throw new Error("Missing sender public key for type 1 envelope");return bt(Tr([t.type,t.senderPublicKey,t.iv,t.sealed]),wt)}return bt(Tr([t.type,t.iv,t.sealed]),wt)}function Mr(t){const e=(t.encoding||wt)===Vs?fh(t.encoded):t.encoded,s=Bt(e,wt),n=s.slice(gb,bl),r=bl;if(Cn(n)===Ns){const c=r+sc,l=c+Or,u=s.slice(r,c),d=s.slice(c,l),h=s.slice(l);return{type:n,sealed:h,iv:d,senderPublicKey:u}}if(Cn(n)===ei){const c=s.slice(r),l=Sn(Or);return{type:n,sealed:c,iv:l}}const i=r+Or,o=s.slice(r,i),a=s.slice(i);return{type:n,sealed:a,iv:o}}function vb(t,e){const s=Mr({encoded:t,encoding:e?.encoding});return mh({type:Cn(s.type),senderPublicKey:typeof s.senderPublicKey<"u"?bt(s.senderPublicKey,ct):void 0,receiverPublicKey:e?.receiverPublicKey})}function mh(t){const e=t?.type||dh;if(e===Ns){if(typeof t?.senderPublicKey>"u")throw new Error("missing sender public key");if(typeof t?.receiverPublicKey>"u")throw new Error("missing receiver public key")}return{type:e,senderPublicKey:t?.senderPublicKey,receiverPublicKey:t?.receiverPublicKey}}function El(t){return t.type===Ns&&typeof t.senderPublicKey=="string"&&typeof t.receiverPublicKey=="string"}function Cl(t){return t.type===ei}function Ab(t){const e=Buffer.from(t.x,"base64"),s=Buffer.from(t.y,"base64");return Tr([new Uint8Array([4]),e,s])}function Ib(t,e){const[s,n,r]=t.split("."),i=Buffer.from(fh(r),"base64");if(i.length!==64)throw new Error("Invalid signature length");const o=i.slice(0,32),a=i.slice(32,64),c=`${s}.${n}`,l=ro(c),u=Ab(e);if(!fb.verify(Tr([o,a]),l,u))throw new Error("Invalid signature");return Jo(t).payload}const Nb="irn";function qi(t){return t?.relay||{protocol:Nb}}function Wn(t){const e=hp[t];if(typeof e>"u")throw new Error(`Relay Protocol not supported: ${t}`);return e}var _b=Object.defineProperty,Sb=Object.defineProperties,Tb=Object.getOwnPropertyDescriptors,vl=Object.getOwnPropertySymbols,Ob=Object.prototype.hasOwnProperty,kb=Object.prototype.propertyIsEnumerable,Al=(t,e,s)=>e in t?_b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Po=(t,e)=>{for(var s in e||(e={}))Ob.call(e,s)&&Al(t,s,e[s]);if(vl)for(var s of vl(e))kb.call(e,s)&&Al(t,s,e[s]);return t},Db=(t,e)=>Sb(t,Tb(e));function Pb(t,e="-"){const s={},n="relay"+e;return Object.keys(t).forEach(r=>{if(r.startsWith(n)){const i=r.replace(n,""),o=t[r];s[i]=o}}),s}function Il(t){if(!t.includes("wc:")){const l=Ed(t);l!=null&&l.includes("wc:")&&(t=l)}t=t.includes("wc://")?t.replace("wc://",""):t,t=t.includes("wc:")?t.replace("wc:",""):t;const e=t.indexOf(":"),s=t.indexOf("?")!==-1?t.indexOf("?"):void 0,n=t.substring(0,e),r=t.substring(e+1,s).split("@"),i=typeof s<"u"?t.substring(s):"",o=new URLSearchParams(i),a=Object.fromEntries(o.entries()),c=typeof a.methods=="string"?a.methods.split(","):void 0;return{protocol:n,topic:Rb(r[0]),version:parseInt(r[1],10),symKey:a.symKey,relay:Pb(a),methods:c,expiryTimestamp:a.expiryTimestamp?parseInt(a.expiryTimestamp,10):void 0}}function Rb(t){return t.startsWith("//")?t.substring(2):t}function xb(t,e="-"){const s="relay",n={};return Object.keys(t).forEach(r=>{const i=r,o=s+e+i;t[i]&&(n[o]=t[i])}),n}function Nl(t){const e=new URLSearchParams,s=Po(Po(Db(Po({},xb(t.relay)),{symKey:t.symKey}),t.expiryTimestamp&&{expiryTimestamp:t.expiryTimestamp.toString()}),t.methods&&{methods:t.methods.join(",")});return Object.entries(s).sort(([n],[r])=>n.localeCompare(r)).forEach(([n,r])=>{r!==void 0&&e.append(n,String(r))}),`${t.protocol}:${t.topic}@${t.version}?${e}`}function pi(t,e,s){return`${t}?wc_ev=${s}&topic=${e}`}var $b=Object.defineProperty,Ub=Object.defineProperties,Lb=Object.getOwnPropertyDescriptors,_l=Object.getOwnPropertySymbols,Bb=Object.prototype.hasOwnProperty,Mb=Object.prototype.propertyIsEnumerable,Sl=(t,e,s)=>e in t?$b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jb=(t,e)=>{for(var s in e||(e={}))Bb.call(e,s)&&Sl(t,s,e[s]);if(_l)for(var s of _l(e))Mb.call(e,s)&&Sl(t,s,e[s]);return t},Fb=(t,e)=>Ub(t,Lb(e));function or(t){const e=[];return t.forEach(s=>{const[n,r]=s.split(":");e.push(`${n}:${r}`)}),e}function qb(t){const e=[];return Object.values(t).forEach(s=>{e.push(...or(s.accounts))}),e}function Wb(t,e){const s=[];return Object.values(t).forEach(n=>{or(n.accounts).includes(e)&&s.push(...n.methods)}),s}function Vb(t,e){const s=[];return Object.values(t).forEach(n=>{or(n.accounts).includes(e)&&s.push(...n.events)}),s}function ao(t){return t.includes(":")}function Vn(t){return ao(t)?t.split(":")[0]:t}function Tl(t){var e,s,n;const r={};if(!us(t))return r;for(const[i,o]of Object.entries(t)){const a=ao(i)?[i]:o.chains,c=o.methods||[],l=o.events||[],u=Vn(i);r[u]=Fb(jb({},r[u]),{chains:ls(a,(e=r[u])==null?void 0:e.chains),methods:ls(c,(s=r[u])==null?void 0:s.methods),events:ls(l,(n=r[u])==null?void 0:n.events)})}return r}function zb(t){const e={};return t?.forEach(s=>{var n;const[r,i]=s.split(":");e[r]||(e[r]={accounts:[],chains:[],events:[],methods:[]}),e[r].accounts.push(s),(n=e[r].chains)==null||n.push(`${r}:${i}`)}),e}function Ol(t,e){e=e.map(n=>n.replace("did:pkh:",""));const s=zb(e);for(const[n,r]of Object.entries(s))r.methods?r.methods=ls(r.methods,t):r.methods=t,r.events=["chainChanged","accountsChanged"];return s}function Hb(t,e){var s,n,r,i,o,a;const c=Tl(t),l=Tl(e),u={},d=Object.keys(c).concat(Object.keys(l));for(const h of d)u[h]={chains:ls((s=c[h])==null?void 0:s.chains,(n=l[h])==null?void 0:n.chains),methods:ls((r=c[h])==null?void 0:r.methods,(i=l[h])==null?void 0:i.methods),events:ls((o=c[h])==null?void 0:o.events,(a=l[h])==null?void 0:a.events)};return u}const Kb={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}},Gb={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 V(t,e){const{message:s,code:n}=Gb[t];return{message:e?`${s} ${e}`:s,code:n}}function Pe(t,e){const{message:s,code:n}=Kb[t];return{message:e?`${s} ${e}`:s,code:n}}function _s(t,e){return!!Array.isArray(t)}function us(t){return Object.getPrototypeOf(t)===Object.prototype&&Object.keys(t).length}function qe(t){return typeof t>"u"}function Me(t,e){return e&&qe(t)?!0:typeof t=="string"&&!!t.trim().length}function nc(t,e){return e&&qe(t)?!0:typeof t=="number"&&!isNaN(t)}function Yb(t,e){const{requiredNamespaces:s}=e,n=Object.keys(t.namespaces),r=Object.keys(s);let i=!0;return hn(r,n)?(n.forEach(o=>{const{accounts:a,methods:c,events:l}=t.namespaces[o],u=or(a),d=s[o];(!hn(gd(o,d),u)||!hn(d.methods,c)||!hn(d.events,l))&&(i=!1)}),i):!1}function Wi(t){return Me(t,!1)&&t.includes(":")?t.split(":").length===2:!1}function Jb(t){if(Me(t,!1)&&t.includes(":")){const e=t.split(":");if(e.length===3){const s=e[0]+":"+e[1];return!!e[2]&&Wi(s)}}return!1}function Xb(t){function e(s){try{return typeof new URL(s)<"u"}catch{return!1}}try{if(Me(t,!1)){if(e(t))return!0;const s=Ed(t);return e(s)}}catch{}return!1}function Zb(t){var e;return(e=t?.proposer)==null?void 0:e.publicKey}function Qb(t){return t?.topic}function e0(t,e){let s=null;return Me(t?.publicKey,!1)||(s=V("MISSING_OR_INVALID",`${e} controller public key should be a string`)),s}function kl(t){let e=!0;return _s(t)?t.length&&(e=t.every(s=>Me(s,!1))):e=!1,e}function t0(t,e,s){let n=null;return _s(e)&&e.length?e.forEach(r=>{n||Wi(r)||(n=Pe("UNSUPPORTED_CHAINS",`${s}, chain ${r} should be a string and conform to "namespace:chainId" format`))}):Wi(t)||(n=Pe("UNSUPPORTED_CHAINS",`${s}, 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"] }`)),n}function s0(t,e,s){let n=null;return Object.entries(t).forEach(([r,i])=>{if(n)return;const o=t0(r,gd(r,i),`${e} ${s}`);o&&(n=o)}),n}function n0(t,e){let s=null;return _s(t)?t.forEach(n=>{s||Jb(n)||(s=Pe("UNSUPPORTED_ACCOUNTS",`${e}, account ${n} should be a string and conform to "namespace:chainId:address" format`))}):s=Pe("UNSUPPORTED_ACCOUNTS",`${e}, accounts should be an array of strings conforming to "namespace:chainId:address" format`),s}function r0(t,e){let s=null;return Object.values(t).forEach(n=>{if(s)return;const r=n0(n?.accounts,`${e} namespace`);r&&(s=r)}),s}function i0(t,e){let s=null;return kl(t?.methods)?kl(t?.events)||(s=Pe("UNSUPPORTED_EVENTS",`${e}, events should be an array of strings or empty array for no events`)):s=Pe("UNSUPPORTED_METHODS",`${e}, methods should be an array of strings or empty array for no methods`),s}function wh(t,e){let s=null;return Object.values(t).forEach(n=>{if(s)return;const r=i0(n,`${e}, namespace`);r&&(s=r)}),s}function o0(t,e,s){let n=null;if(t&&us(t)){const r=wh(t,e);r&&(n=r);const i=s0(t,e,s);i&&(n=i)}else n=V("MISSING_OR_INVALID",`${e}, ${s} should be an object with data`);return n}function Ro(t,e){let s=null;if(t&&us(t)){const n=wh(t,e);n&&(s=n);const r=r0(t,e);r&&(s=r)}else s=V("MISSING_OR_INVALID",`${e}, namespaces should be an object with data`);return s}function yh(t){return Me(t.protocol,!0)}function a0(t,e){let s=!1;return t?t&&_s(t)&&t.length&&t.forEach(n=>{s=yh(n)}):s=!0,s}function c0(t){return typeof t=="number"}function gt(t){return typeof t<"u"&&typeof t!==null}function l0(t){return!(!t||typeof t!="object"||!t.code||!nc(t.code,!1)||!t.message||!Me(t.message,!1))}function u0(t){return!(qe(t)||!Me(t.method,!1))}function d0(t){return!(qe(t)||qe(t.result)&&qe(t.error)||!nc(t.id,!1)||!Me(t.jsonrpc,!1))}function h0(t){return!(qe(t)||!Me(t.name,!1))}function Dl(t,e){return!(!Wi(e)||!qb(t).includes(e))}function p0(t,e,s){return Me(s,!1)?Wb(t,e).includes(s):!1}function f0(t,e,s){return Me(s,!1)?Vb(t,e).includes(s):!1}function Pl(t,e,s){let n=null;const r=g0(t),i=m0(e),o=Object.keys(r),a=Object.keys(i),c=Rl(Object.keys(t)),l=Rl(Object.keys(e)),u=c.filter(d=>!l.includes(d));return u.length&&(n=V("NON_CONFORMING_NAMESPACES",`${s} namespaces keys don't satisfy requiredNamespaces.
|
|
8
|
-
Required: ${u.toString()}
|
|
9
|
-
Received: ${Object.keys(e).toString()}`)),hn(o,a)||(n=V("NON_CONFORMING_NAMESPACES",`${s} namespaces chains don't satisfy required namespaces.
|
|
10
|
-
Required: ${o.toString()}
|
|
11
|
-
Approved: ${a.toString()}`)),Object.keys(e).forEach(d=>{if(!d.includes(":")||n)return;const h=or(e[d].accounts);h.includes(d)||(n=V("NON_CONFORMING_NAMESPACES",`${s} namespaces accounts don't satisfy namespace accounts for ${d}
|
|
12
|
-
Required: ${d}
|
|
13
|
-
Approved: ${h.toString()}`))}),o.forEach(d=>{n||(hn(r[d].methods,i[d].methods)?hn(r[d].events,i[d].events)||(n=V("NON_CONFORMING_NAMESPACES",`${s} namespaces events don't satisfy namespace events for ${d}`)):n=V("NON_CONFORMING_NAMESPACES",`${s} namespaces methods don't satisfy namespace methods for ${d}`))}),n}function g0(t){const e={};return Object.keys(t).forEach(s=>{var n;s.includes(":")?e[s]=t[s]:(n=t[s].chains)==null||n.forEach(r=>{e[r]={methods:t[s].methods,events:t[s].events}})}),e}function Rl(t){return[...new Set(t.map(e=>e.includes(":")?e.split(":")[0]:e))]}function m0(t){const e={};return Object.keys(t).forEach(s=>{s.includes(":")?e[s]=t[s]:or(t[s].accounts)?.forEach(r=>{e[r]={accounts:t[s].accounts.filter(i=>i.includes(`${r}:`)),methods:t[s].methods,events:t[s].events}})}),e}function w0(t,e){return nc(t,!1)&&t<=e.max&&t>=e.min}function xl(){const t=Jr();return new Promise(e=>{switch(t){case St.browser:e(y0());break;case St.reactNative:e(b0());break;case St.node:e(E0());break;default:e(!0)}})}function y0(){return ir()&&navigator?.onLine}async function b0(){return Xs()&&typeof global<"u"&&global!=null&&global.NetInfo?(await(global==null?void 0:global.NetInfo.fetch()))?.isConnected:!0}function E0(){return!0}function C0(t){switch(Jr()){case St.browser:v0(t);break;case St.reactNative:A0(t);break}}function v0(t){!Xs()&&ir()&&(window.addEventListener("online",()=>t(!0)),window.addEventListener("offline",()=>t(!1)))}function A0(t){Xs()&&typeof global<"u"&&global!=null&&global.NetInfo&&global?.NetInfo.addEventListener(e=>t(e?.isConnected))}function I0(){var t;return ir()&&Ss.getDocument()?((t=Ss.getDocument())==null?void 0:t.visibilityState)==="visible":!0}const xo={};class hr{static get(e){return xo[e]}static set(e,s){xo[e]=s}static delete(e){delete xo[e]}}function N0(t){const e=nr.decode(t);if(e.length<33)throw new Error("Too short to contain a public key");return e.slice(1,33)}function _0({publicKey:t,signature:e,payload:s}){var n;const r=ya(s.method),i=128|parseInt(((n=s.version)==null?void 0:n.toString())||"4"),o=O0(s.address),a=s.era==="00"?new Uint8Array([0]):ya(s.era);if(a.length!==1&&a.length!==2)throw new Error("Invalid era length");const c=parseInt(s.nonce,16),l=new Uint8Array([c&255,c>>8&255]),u=BigInt(`0x${T0(s.tip)}`),d=D0(u),h=new Uint8Array([0,...t,o,...e,...a,...l,...d,...r]),m=k0(h.length+1);return new Uint8Array([...m,i,...h])}function S0(t){const e=ya(t),s=mp.blake2b(e,void 0,32);return"0x"+Buffer.from(s).toString("hex")}function ya(t){return new Uint8Array(t.replace(/^0x/,"").match(/.{1,2}/g).map(e=>parseInt(e,16)))}function T0(t){return t.startsWith("0x")?t.slice(2):t}function O0(t){const e=nr.decode(t)[0];return e===42?0:e===60?2:1}function k0(t){if(t<64)return new Uint8Array([t<<2]);if(t<16384){const e=t<<2|1;return new Uint8Array([e&255,e>>8&255])}else if(t<1<<30){const e=t<<2|2;return new Uint8Array([e&255,e>>8&255,e>>16&255,e>>24&255])}else throw new Error("Compact encoding > 2^30 not supported")}function D0(t){if(t<BigInt(1)<<BigInt(6))return new Uint8Array([Number(t<<BigInt(2))]);if(t<BigInt(1)<<BigInt(14)){const e=t<<BigInt(2)|BigInt(1);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255))])}else if(t<BigInt(1)<<BigInt(30)){const e=t<<BigInt(2)|BigInt(2);return new Uint8Array([Number(e&BigInt(255)),Number(e>>BigInt(8)&BigInt(255)),Number(e>>BigInt(16)&BigInt(255)),Number(e>>BigInt(24)&BigInt(255))])}else throw new Error("BigInt compact encoding not supported > 2^30")}function P0(t){const e=Uint8Array.from(Buffer.from(t.signature,"hex")),s=N0(t.transaction.address),n=_0({publicKey:s,signature:e,payload:t.transaction}),r=Buffer.from(n).toString("hex");return S0(r)}var R0={};const bh="wc",Eh=2,ba="core",ds=`${bh}@2:${ba}:`,x0={logger:"error"},$0={database:":memory:"},U0="crypto",$l="client_ed25519_seed",L0=H.ONE_DAY,B0="keychain",M0="0.3",j0="messages",F0="0.3",q0=H.SIX_HOURS,W0="publisher",Ch="irn",V0="error",vh="wss://relay.walletconnect.org",z0="relayer",Ue={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"},H0="_subscription",Ot={payload:"payload",connect:"connect",disconnect:"disconnect",error:"error"},K0=.1,Ea="2.21.9",Oe={link_mode:"link_mode",relay:"relay"},Ai={inbound:"inbound",outbound:"outbound"},G0="0.3",Y0="WALLETCONNECT_CLIENT_ID",Ul="WALLETCONNECT_LINK_MODE_APPS",It={created:"subscription_created",deleted:"subscription_deleted",expired:"subscription_expired",disabled:"subscription_disabled",sync:"subscription_sync",resubscribed:"subscription_resubscribed"},J0="subscription",X0="0.3",Z0="pairing",Q0="0.3",pr={wc_pairingDelete:{req:{ttl:H.ONE_DAY,prompt:!1,tag:1e3},res:{ttl:H.ONE_DAY,prompt:!1,tag:1001}},wc_pairingPing:{req:{ttl:H.THIRTY_SECONDS,prompt:!1,tag:1002},res:{ttl:H.THIRTY_SECONDS,prompt:!1,tag:1003}},unregistered_method:{req:{ttl:H.ONE_DAY,prompt:!1,tag:0},res:{ttl:H.ONE_DAY,prompt:!1,tag:0}}},cn={create:"pairing_create",expire:"pairing_expire",delete:"pairing_delete",ping:"pairing_ping"},Wt={created:"history_created",updated:"history_updated",deleted:"history_deleted",sync:"history_sync"},eE="history",tE="0.3",sE="expirer",xt={created:"expirer_created",deleted:"expirer_deleted",expired:"expirer_expired",sync:"expirer_sync"},nE="0.3",rE="verify-api",iE="https://verify.walletconnect.com",Ah="https://verify.walletconnect.org",kr=Ah,oE=`${kr}/v3`,aE=[iE,Ah],cE="echo",lE="https://echo.walletconnect.com",es={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"},ms={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"},Ms={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"},fr={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"},sn={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"},gr={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"},uE=.1,dE="event-client",hE=86400,pE="https://pulse.walletconnect.org/batch";function fE(t,e){if(t.length>=255)throw new TypeError("Alphabet too long");for(var s=new Uint8Array(256),n=0;n<s.length;n++)s[n]=255;for(var r=0;r<t.length;r++){var i=t.charAt(r),o=i.charCodeAt(0);if(s[o]!==255)throw new TypeError(i+" is ambiguous");s[o]=r}var a=t.length,c=t.charAt(0),l=Math.log(a)/Math.log(256),u=Math.log(256)/Math.log(a);function d(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 b=0,y=0,_=0,N=g.length;_!==N&&g[_]===0;)_++,b++;for(var D=(N-_)*u+1>>>0,M=new Uint8Array(D);_!==N;){for(var q=g[_],p=0,E=D-1;(q!==0||p<y)&&E!==-1;E--,p++)q+=256*M[E]>>>0,M[E]=q%a>>>0,q=q/a>>>0;if(q!==0)throw new Error("Non-zero carry");y=p,_++}for(var C=D-y;C!==D&&M[C]===0;)C++;for(var A=c.repeat(b);C<D;++C)A+=t.charAt(M[C]);return A}function h(g){if(typeof g!="string")throw new TypeError("Expected String");if(g.length===0)return new Uint8Array;var b=0;if(g[b]!==" "){for(var y=0,_=0;g[b]===c;)y++,b++;for(var N=(g.length-b)*l+1>>>0,D=new Uint8Array(N);g[b];){var M=s[g.charCodeAt(b)];if(M===255)return;for(var q=0,p=N-1;(M!==0||q<_)&&p!==-1;p--,q++)M+=a*D[p]>>>0,D[p]=M%256>>>0,M=M/256>>>0;if(M!==0)throw new Error("Non-zero carry");_=q,b++}if(g[b]!==" "){for(var E=N-_;E!==N&&D[E]===0;)E++;for(var C=new Uint8Array(y+(N-E)),A=y;E!==N;)C[A++]=D[E++];return C}}}function m(g){var b=h(g);if(b)return b;throw new Error(`Non-${e} character`)}return{encode:d,decodeUnsafe:h,decode:m}}var gE=fE,mE=gE;const Ih=t=>{if(t instanceof Uint8Array&&t.constructor.name==="Uint8Array")return t;if(t instanceof ArrayBuffer)return new Uint8Array(t);if(ArrayBuffer.isView(t))return new Uint8Array(t.buffer,t.byteOffset,t.byteLength);throw new Error("Unknown type, must be binary type")},wE=t=>new TextEncoder().encode(t),yE=t=>new TextDecoder().decode(t);class bE{constructor(e,s,n){this.name=e,this.prefix=s,this.baseEncode=n}encode(e){if(e instanceof Uint8Array)return`${this.prefix}${this.baseEncode(e)}`;throw Error("Unknown type, must be binary type")}}class EE{constructor(e,s,n){if(this.name=e,this.prefix=s,s.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=s.codePointAt(0),this.baseDecode=n}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 Nh(this,e)}}class CE{constructor(e){this.decoders=e}or(e){return Nh(this,e)}decode(e){const s=e[0],n=this.decoders[s];if(n)return n.decode(e);throw RangeError(`Unable to decode multibase string ${JSON.stringify(e)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}const Nh=(t,e)=>new CE({...t.decoders||{[t.prefix]:t},...e.decoders||{[e.prefix]:e}});class vE{constructor(e,s,n,r){this.name=e,this.prefix=s,this.baseEncode=n,this.baseDecode=r,this.encoder=new bE(e,s,n),this.decoder=new EE(e,s,r)}encode(e){return this.encoder.encode(e)}decode(e){return this.decoder.decode(e)}}const co=({name:t,prefix:e,encode:s,decode:n})=>new vE(t,e,s,n),ti=({prefix:t,name:e,alphabet:s})=>{const{encode:n,decode:r}=mE(s,e);return co({prefix:t,name:e,encode:n,decode:i=>Ih(r(i))})},AE=(t,e,s,n)=>{const r={};for(let u=0;u<e.length;++u)r[e[u]]=u;let i=t.length;for(;t[i-1]==="=";)--i;const o=new Uint8Array(i*s/8|0);let a=0,c=0,l=0;for(let u=0;u<i;++u){const d=r[t[u]];if(d===void 0)throw new SyntaxError(`Non-${n} character`);c=c<<s|d,a+=s,a>=8&&(a-=8,o[l++]=255&c>>a)}if(a>=s||255&c<<8-a)throw new SyntaxError("Unexpected end of data");return o},IE=(t,e,s)=>{const n=e[e.length-1]==="=",r=(1<<s)-1;let i="",o=0,a=0;for(let c=0;c<t.length;++c)for(a=a<<8|t[c],o+=8;o>s;)o-=s,i+=e[r&a>>o];if(o&&(i+=e[r&a<<s-o]),n)for(;i.length*s&7;)i+="=";return i},Qe=({name:t,prefix:e,bitsPerChar:s,alphabet:n})=>co({prefix:e,name:t,encode(r){return IE(r,n,s)},decode(r){return AE(r,n,s,t)}}),NE=co({prefix:"\0",name:"identity",encode:t=>yE(t),decode:t=>wE(t)});var _E=Object.freeze({__proto__:null,identity:NE});const SE=Qe({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1});var TE=Object.freeze({__proto__:null,base2:SE});const OE=Qe({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3});var kE=Object.freeze({__proto__:null,base8:OE});const DE=ti({prefix:"9",name:"base10",alphabet:"0123456789"});var PE=Object.freeze({__proto__:null,base10:DE});const RE=Qe({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),xE=Qe({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4});var $E=Object.freeze({__proto__:null,base16:RE,base16upper:xE});const UE=Qe({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),LE=Qe({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),BE=Qe({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),ME=Qe({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),jE=Qe({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),FE=Qe({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),qE=Qe({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),WE=Qe({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),VE=Qe({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5});var zE=Object.freeze({__proto__:null,base32:UE,base32upper:LE,base32pad:BE,base32padupper:ME,base32hex:jE,base32hexupper:FE,base32hexpad:qE,base32hexpadupper:WE,base32z:VE});const HE=ti({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),KE=ti({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"});var GE=Object.freeze({__proto__:null,base36:HE,base36upper:KE});const YE=ti({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),JE=ti({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"});var XE=Object.freeze({__proto__:null,base58btc:YE,base58flickr:JE});const ZE=Qe({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),QE=Qe({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),eC=Qe({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),tC=Qe({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6});var sC=Object.freeze({__proto__:null,base64:ZE,base64pad:QE,base64url:eC,base64urlpad:tC});const _h=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),nC=_h.reduce((t,e,s)=>(t[s]=e,t),[]),rC=_h.reduce((t,e,s)=>(t[e.codePointAt(0)]=s,t),[]);function iC(t){return t.reduce((e,s)=>(e+=nC[s],e),"")}function oC(t){const e=[];for(const s of t){const n=rC[s.codePointAt(0)];if(n===void 0)throw new Error(`Non-base256emoji character: ${s}`);e.push(n)}return new Uint8Array(e)}const aC=co({prefix:"🚀",name:"base256emoji",encode:iC,decode:oC});var cC=Object.freeze({__proto__:null,base256emoji:aC}),lC=Sh,Ll=128,uC=-128,dC=Math.pow(2,31);function Sh(t,e,s){e=e||[],s=s||0;for(var n=s;t>=dC;)e[s++]=t&255|Ll,t/=128;for(;t&uC;)e[s++]=t&255|Ll,t>>>=7;return e[s]=t|0,Sh.bytes=s-n+1,e}var hC=Ca,pC=128,Bl=127;function Ca(t,n){var s=0,n=n||0,r=0,i=n,o,a=t.length;do{if(i>=a)throw Ca.bytes=0,new RangeError("Could not decode varint");o=t[i++],s+=r<28?(o&Bl)<<r:(o&Bl)*Math.pow(2,r),r+=7}while(o>=pC);return Ca.bytes=i-n,s}var fC=Math.pow(2,7),gC=Math.pow(2,14),mC=Math.pow(2,21),wC=Math.pow(2,28),yC=Math.pow(2,35),bC=Math.pow(2,42),EC=Math.pow(2,49),CC=Math.pow(2,56),vC=Math.pow(2,63),AC=function(t){return t<fC?1:t<gC?2:t<mC?3:t<wC?4:t<yC?5:t<bC?6:t<EC?7:t<CC?8:t<vC?9:10},IC={encode:lC,decode:hC,encodingLength:AC},Th=IC;const Ml=(t,e,s=0)=>(Th.encode(t,e,s),e),jl=t=>Th.encodingLength(t),va=(t,e)=>{const s=e.byteLength,n=jl(t),r=n+jl(s),i=new Uint8Array(r+s);return Ml(t,i,0),Ml(s,i,n),i.set(e,r),new NC(t,s,e,i)};class NC{constructor(e,s,n,r){this.code=e,this.size=s,this.digest=n,this.bytes=r}}const Oh=({name:t,code:e,encode:s})=>new _C(t,e,s);class _C{constructor(e,s,n){this.name=e,this.code=s,this.encode=n}digest(e){if(e instanceof Uint8Array){const s=this.encode(e);return s instanceof Uint8Array?va(this.code,s):s.then(n=>va(this.code,n))}else throw Error("Unknown type, must be binary type")}}const kh=t=>async e=>new Uint8Array(await crypto.subtle.digest(t,e)),SC=Oh({name:"sha2-256",code:18,encode:kh("SHA-256")}),TC=Oh({name:"sha2-512",code:19,encode:kh("SHA-512")});var OC=Object.freeze({__proto__:null,sha256:SC,sha512:TC});const Dh=0,kC="identity",Ph=Ih,DC=t=>va(Dh,Ph(t)),PC={code:Dh,name:kC,encode:Ph,digest:DC};var RC=Object.freeze({__proto__:null,identity:PC});new TextEncoder,new TextDecoder;const Fl={..._E,...TE,...kE,...PE,...$E,...zE,...GE,...XE,...sC,...cC};({...OC,...RC});function Rh(t){return globalThis.Buffer!=null?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):t}function xC(t=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?Rh(globalThis.Buffer.allocUnsafe(t)):new Uint8Array(t)}function xh(t,e,s,n){return{name:t,prefix:e,encoder:{name:t,prefix:e,encode:s},decoder:{decode:n}}}const ql=xh("utf8","u",t=>"u"+new TextDecoder("utf8").decode(t),t=>new TextEncoder().encode(t.substring(1))),$o=xh("ascii","a",t=>{let e="a";for(let s=0;s<t.length;s++)e+=String.fromCharCode(t[s]);return e},t=>{t=t.substring(1);const e=xC(t.length);for(let s=0;s<t.length;s++)e[s]=t.charCodeAt(s);return e}),$C={utf8:ql,"utf-8":ql,hex:Fl.base16,latin1:$o,ascii:$o,binary:$o,...Fl};function UC(t,e="utf8"){const s=$C[e];if(!s)throw new Error(`Unsupported encoding "${e}"`);return(e==="utf8"||e==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?Rh(globalThis.Buffer.from(t,"utf-8")):s.decoder.decode(`${s.prefix}${t}`)}var LC=Object.defineProperty,BC=(t,e,s)=>e in t?LC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Zt=(t,e,s)=>BC(t,typeof e!="symbol"?e+"":e,s);class MC{constructor(e,s){this.core=e,this.logger=s,Zt(this,"keychain",new Map),Zt(this,"name",B0),Zt(this,"version",M0),Zt(this,"initialized",!1),Zt(this,"storagePrefix",ds),Zt(this,"init",async()=>{if(!this.initialized){const n=await this.getKeyChain();typeof n<"u"&&(this.keychain=n),this.initialized=!0}}),Zt(this,"has",n=>(this.isInitialized(),this.keychain.has(n))),Zt(this,"set",async(n,r)=>{this.isInitialized(),this.keychain.set(n,r),await this.persist()}),Zt(this,"get",n=>{this.isInitialized();const r=this.keychain.get(n);if(typeof r>"u"){const{message:i}=V("NO_MATCHING_KEY",`${this.name}: ${n}`);throw new Error(i)}return r}),Zt(this,"del",async n=>{this.isInitialized(),this.keychain.delete(n),await this.persist()}),this.core=e,this.logger=lt(s,this.name)}get context(){return Et(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}async setKeyChain(e){await this.core.storage.setItem(this.storageKey,ia(e))}async getKeyChain(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?oa(e):void 0}async persist(){await this.setKeyChain(this.keychain)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var jC=Object.defineProperty,FC=(t,e,s)=>e in t?jC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,He=(t,e,s)=>FC(t,typeof e!="symbol"?e+"":e,s);class qC{constructor(e,s,n){this.core=e,this.logger=s,He(this,"name",U0),He(this,"keychain"),He(this,"randomSessionIdentifier",wa()),He(this,"initialized",!1),He(this,"init",async()=>{this.initialized||(await this.keychain.init(),this.initialized=!0)}),He(this,"hasKeys",r=>(this.isInitialized(),this.keychain.has(r))),He(this,"getClientId",async()=>{this.isInitialized();const r=await this.getClientSeed(),i=gc(r);return Ep(i.publicKey)}),He(this,"generateKeyPair",()=>{this.isInitialized();const r=mb();return this.setPrivateKey(r.publicKey,r.privateKey)}),He(this,"signJWT",async r=>{this.isInitialized();const i=await this.getClientSeed(),o=gc(i),a=this.randomSessionIdentifier;return await Cp(a,r,L0,o)}),He(this,"generateSharedKey",(r,i,o)=>{this.isInitialized();const a=this.getPrivateKey(r),c=wb(a,i);return this.setSymKey(c,o)}),He(this,"setSymKey",async(r,i)=>{this.isInitialized();const o=i||vi(r);return await this.keychain.set(o,r),o}),He(this,"deleteKeyPair",async r=>{this.isInitialized(),await this.keychain.del(r)}),He(this,"deleteSymKey",async r=>{this.isInitialized(),await this.keychain.del(r)}),He(this,"encode",async(r,i,o)=>{this.isInitialized();const a=mh(o),c=Rr(i);if(Cl(a))return Eb(c,o?.encoding);if(El(a)){const h=a.senderPublicKey,m=a.receiverPublicKey;r=await this.generateSharedKey(h,m)}const l=this.getSymKey(r),{type:u,senderPublicKey:d}=a;return yb({type:u,symKey:l,message:c,senderPublicKey:d,encoding:o?.encoding})}),He(this,"decode",async(r,i,o)=>{this.isInitialized();const a=vb(i,o);if(Cl(a)){const c=Cb(i,o?.encoding);return mc(c)}if(El(a)){const c=a.receiverPublicKey,l=a.senderPublicKey;r=await this.generateSharedKey(c,l)}try{const c=this.getSymKey(r),l=bb({symKey:c,encoded:i,encoding:o?.encoding});return mc(l)}catch(c){this.logger.error(`Failed to decode message from topic: '${r}', clientId: '${await this.getClientId()}'`),this.logger.error(c)}}),He(this,"getPayloadType",(r,i=wt)=>{const o=Mr({encoded:r,encoding:i});return Cn(o.type)}),He(this,"getPayloadSenderPublicKey",(r,i=wt)=>{const o=Mr({encoded:r,encoding:i});return o.senderPublicKey?bt(o.senderPublicKey,ct):void 0}),this.core=e,this.logger=lt(s,this.name),this.keychain=n||new MC(this.core,this.logger)}get context(){return Et(this.logger)}async setPrivateKey(e,s){return await this.keychain.set(e,s),e}getPrivateKey(e){return this.keychain.get(e)}async getClientSeed(){let e="";try{e=this.keychain.get($l)}catch{e=wa(),await this.keychain.set($l,e)}return UC(e,"base16")}getSymKey(e){return this.keychain.get(e)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var WC=Object.defineProperty,VC=Object.defineProperties,zC=Object.getOwnPropertyDescriptors,Wl=Object.getOwnPropertySymbols,HC=Object.prototype.hasOwnProperty,KC=Object.prototype.propertyIsEnumerable,Aa=(t,e,s)=>e in t?WC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,GC=(t,e)=>{for(var s in e||(e={}))HC.call(e,s)&&Aa(t,s,e[s]);if(Wl)for(var s of Wl(e))KC.call(e,s)&&Aa(t,s,e[s]);return t},YC=(t,e)=>VC(t,zC(e)),vt=(t,e,s)=>Aa(t,typeof e!="symbol"?e+"":e,s);class JC extends ng{constructor(e,s){super(e,s),this.logger=e,this.core=s,vt(this,"messages",new Map),vt(this,"messagesWithoutClientAck",new Map),vt(this,"name",j0),vt(this,"version",F0),vt(this,"initialized",!1),vt(this,"storagePrefix",ds),vt(this,"init",async()=>{if(!this.initialized){this.logger.trace("Initialized");try{const n=await this.getRelayerMessages();typeof n<"u"&&(this.messages=n);const r=await this.getRelayerMessagesWithoutClientAck();typeof r<"u"&&(this.messagesWithoutClientAck=r),this.logger.debug(`Successfully Restored records for ${this.name}`),this.logger.trace({type:"method",method:"restore",size:this.messages.size})}catch(n){this.logger.debug(`Failed to Restore records for ${this.name}`),this.logger.error(n)}finally{this.initialized=!0}}}),vt(this,"set",async(n,r,i)=>{this.isInitialized();const o=$t(r);let a=this.messages.get(n);if(typeof a>"u"&&(a={}),typeof a[o]<"u")return o;if(a[o]=r,this.messages.set(n,a),i===Ai.inbound){const c=this.messagesWithoutClientAck.get(n)||{};this.messagesWithoutClientAck.set(n,YC(GC({},c),{[o]:r}))}return await this.persist(),o}),vt(this,"get",n=>{this.isInitialized();let r=this.messages.get(n);return typeof r>"u"&&(r={}),r}),vt(this,"getWithoutAck",n=>{this.isInitialized();const r={};for(const i of n){const o=this.messagesWithoutClientAck.get(i)||{};r[i]=Object.values(o)}return r}),vt(this,"has",(n,r)=>{this.isInitialized();const i=this.get(n),o=$t(r);return typeof i[o]<"u"}),vt(this,"ack",async(n,r)=>{this.isInitialized();const i=this.messagesWithoutClientAck.get(n);if(typeof i>"u")return;const o=$t(r);delete i[o],Object.keys(i).length===0?this.messagesWithoutClientAck.delete(n):this.messagesWithoutClientAck.set(n,i),await this.persist()}),vt(this,"del",async n=>{this.isInitialized(),this.messages.delete(n),this.messagesWithoutClientAck.delete(n),await this.persist()}),this.logger=lt(e,this.name),this.core=s}get context(){return Et(this.logger)}get storageKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name}get storageKeyWithoutClientAck(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//"+this.name+"_withoutClientAck"}async setRelayerMessages(e){await this.core.storage.setItem(this.storageKey,ia(e))}async setRelayerMessagesWithoutClientAck(e){await this.core.storage.setItem(this.storageKeyWithoutClientAck,ia(e))}async getRelayerMessages(){const e=await this.core.storage.getItem(this.storageKey);return typeof e<"u"?oa(e):void 0}async getRelayerMessagesWithoutClientAck(){const e=await this.core.storage.getItem(this.storageKeyWithoutClientAck);return typeof e<"u"?oa(e):void 0}async persist(){await this.setRelayerMessages(this.messages),await this.setRelayerMessagesWithoutClientAck(this.messagesWithoutClientAck)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var XC=Object.defineProperty,ZC=Object.defineProperties,QC=Object.getOwnPropertyDescriptors,Vl=Object.getOwnPropertySymbols,ev=Object.prototype.hasOwnProperty,tv=Object.prototype.propertyIsEnumerable,Ia=(t,e,s)=>e in t?XC(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Rn=(t,e)=>{for(var s in e||(e={}))ev.call(e,s)&&Ia(t,s,e[s]);if(Vl)for(var s of Vl(e))tv.call(e,s)&&Ia(t,s,e[s]);return t},zl=(t,e)=>ZC(t,QC(e)),kt=(t,e,s)=>Ia(t,typeof e!="symbol"?e+"":e,s);class sv extends rg{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,kt(this,"events",new An.EventEmitter),kt(this,"name",W0),kt(this,"queue",new Map),kt(this,"publishTimeout",H.toMiliseconds(H.ONE_MINUTE)),kt(this,"initialPublishTimeout",H.toMiliseconds(H.ONE_SECOND*15)),kt(this,"needsTransportRestart",!1),kt(this,"publish",async(n,r,i)=>{var o,a,c,l,u;this.logger.debug("Publishing Payload"),this.logger.trace({type:"method",method:"publish",params:{topic:n,message:r,opts:i}});const d=i?.ttl||q0,h=i?.prompt||!1,m=i?.tag||0,g=i?.id||dn().toString(),b=Wn(qi().protocol),y={id:g,method:i?.publishMethod||b.publish,params:Rn({topic:n,message:r,ttl:d,prompt:h,tag:m,attestation:i?.attestation},i?.tvf)},_=`Failed to publish payload, please try again. id:${g} tag:${m}`;try{qe((o=y.params)==null?void 0:o.prompt)&&((a=y.params)==null||delete a.prompt),qe((c=y.params)==null?void 0:c.tag)&&((l=y.params)==null||delete l.tag);const N=new Promise(async D=>{const M=({id:p})=>{var E;((E=y.id)==null?void 0:E.toString())===p.toString()&&(this.removeRequestFromQueue(p),this.relayer.events.removeListener(Ue.publish,M),D())};this.relayer.events.on(Ue.publish,M);const q=os(new Promise((p,E)=>{this.rpcPublish(y,i).then(p).catch(C=>{this.logger.warn(C,C?.message),E(C)})}),this.initialPublishTimeout,`Failed initial publish, retrying.... id:${g} tag:${m}`);try{await q,this.events.removeListener(Ue.publish,M)}catch(p){this.queue.set(g,{request:y,opts:i,attempt:1}),this.logger.warn(p,p?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:g,topic:n,message:r,opts:i}}),await os(N,this.publishTimeout,_)}catch(N){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(N),(u=i?.internal)!=null&&u.throwOnFailedPublish)throw N}finally{this.queue.delete(g)}}),kt(this,"publishCustom",async n=>{var r,i,o,a,c;this.logger.debug("Publishing custom payload"),this.logger.trace({type:"method",method:"publishCustom",params:n});const{payload:l,opts:u={}}=n,{attestation:d,tvf:h,publishMethod:m,prompt:g,tag:b,ttl:y=H.FIVE_MINUTES}=u,_=u.id||dn().toString(),N=Wn(qi().protocol),D=m||N.publish,M={id:_,method:D,params:Rn(zl(Rn({},l),{ttl:y,prompt:g,tag:b,attestation:d}),h)},q=`Failed to publish custom payload, please try again. id:${_} tag:${b}`;try{qe((r=M.params)==null?void 0:r.prompt)&&((i=M.params)==null||delete i.prompt),qe((o=M.params)==null?void 0:o.tag)&&((a=M.params)==null||delete a.tag);const p=new Promise(async E=>{const C=({id:S})=>{var $;(($=M.id)==null?void 0:$.toString())===S.toString()&&(this.removeRequestFromQueue(S),this.relayer.events.removeListener(Ue.publish,C),E())};this.relayer.events.on(Ue.publish,C);const A=os(new Promise((S,$)=>{this.rpcPublish(M,u).then(S).catch(O=>{this.logger.warn(O,O?.message),$(O)})}),this.initialPublishTimeout,`Failed initial custom payload publish, retrying.... method:${D} id:${_} tag:${b}`);try{await A,this.events.removeListener(Ue.publish,C)}catch(S){this.queue.set(_,{request:M,opts:u,attempt:1}),this.logger.warn(S,S?.message)}});this.logger.trace({type:"method",method:"publish",params:{id:_,payload:l,opts:u}}),await os(p,this.publishTimeout,q)}catch(p){if(this.logger.debug("Failed to Publish Payload"),this.logger.error(p),(c=u?.internal)!=null&&c.throwOnFailedPublish)throw p}finally{this.queue.delete(_)}}),kt(this,"on",(n,r)=>{this.events.on(n,r)}),kt(this,"once",(n,r)=>{this.events.once(n,r)}),kt(this,"off",(n,r)=>{this.events.off(n,r)}),kt(this,"removeListener",(n,r)=>{this.events.removeListener(n,r)}),this.relayer=e,this.logger=lt(s,this.name),this.registerEventListeners()}get context(){return Et(this.logger)}async rpcPublish(e,s){this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"message",direction:"outgoing",request:e});const n=await this.relayer.request(e);return this.relayer.events.emit(Ue.publish,Rn(Rn({},e),s)),this.logger.debug("Successfully Published Payload"),n}removeRequestFromQueue(e){this.queue.delete(e)}checkQueue(){this.queue.forEach(async(e,s)=>{var n;const r=e.attempt+1;this.queue.set(s,zl(Rn({},e),{attempt:r})),this.logger.warn({},`Publisher: queue->publishing: ${e.request.id}, tag: ${(n=e.request.params)==null?void 0:n.tag}, attempt: ${r}`),await this.rpcPublish(e.request,e.opts),this.logger.warn({},`Publisher: queue->published: ${e.request.id}`)})}registerEventListeners(){this.relayer.core.heartbeat.on(rr.pulse,()=>{if(this.needsTransportRestart){this.needsTransportRestart=!1,this.relayer.events.emit(Ue.connection_stalled);return}this.checkQueue()}),this.relayer.on(Ue.message_ack,e=>{this.removeRequestFromQueue(e.id.toString())})}}var nv=Object.defineProperty,rv=(t,e,s)=>e in t?nv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,xn=(t,e,s)=>rv(t,typeof e!="symbol"?e+"":e,s);class iv{constructor(){xn(this,"map",new Map),xn(this,"set",(e,s)=>{const n=this.get(e);this.exists(e,s)||this.map.set(e,[...n,s])}),xn(this,"get",e=>this.map.get(e)||[]),xn(this,"exists",(e,s)=>this.get(e).includes(s)),xn(this,"delete",(e,s)=>{if(typeof s>"u"){this.map.delete(e);return}if(!this.map.has(e))return;const n=this.get(e);if(!this.exists(e,s))return;const r=n.filter(i=>i!==s);if(!r.length){this.map.delete(e);return}this.map.set(e,r)}),xn(this,"clear",()=>{this.map.clear()})}get topics(){return Array.from(this.map.keys())}}var ov=Object.defineProperty,av=Object.defineProperties,cv=Object.getOwnPropertyDescriptors,Hl=Object.getOwnPropertySymbols,lv=Object.prototype.hasOwnProperty,uv=Object.prototype.propertyIsEnumerable,Na=(t,e,s)=>e in t?ov(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,mr=(t,e)=>{for(var s in e||(e={}))lv.call(e,s)&&Na(t,s,e[s]);if(Hl)for(var s of Hl(e))uv.call(e,s)&&Na(t,s,e[s]);return t},Uo=(t,e)=>av(t,cv(e)),_e=(t,e,s)=>Na(t,typeof e!="symbol"?e+"":e,s);class dv extends ag{constructor(e,s){super(e,s),this.relayer=e,this.logger=s,_e(this,"subscriptions",new Map),_e(this,"topicMap",new iv),_e(this,"events",new An.EventEmitter),_e(this,"name",J0),_e(this,"version",X0),_e(this,"pending",new Map),_e(this,"cached",[]),_e(this,"initialized",!1),_e(this,"storagePrefix",ds),_e(this,"subscribeTimeout",H.toMiliseconds(H.ONE_MINUTE)),_e(this,"initialSubscribeTimeout",H.toMiliseconds(H.ONE_SECOND*15)),_e(this,"clientId"),_e(this,"batchSubscribeTopicsLimit",500),_e(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),this.registerEventListeners(),await this.restore()),this.initialized=!0}),_e(this,"subscribe",async(n,r)=>{var i;this.isInitialized(),this.logger.debug("Subscribing Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:r}});try{const o=qi(r),a={topic:n,relay:o,transportType:r?.transportType};(i=r?.internal)!=null&&i.skipSubscribe||this.pending.set(n,a);const c=await this.rpcSubscribe(n,o,r);return typeof c=="string"&&(this.onSubscribe(c,a),this.logger.debug("Successfully Subscribed Topic"),this.logger.trace({type:"method",method:"subscribe",params:{topic:n,opts:r}})),c}catch(o){throw this.logger.debug("Failed to Subscribe Topic"),this.logger.error(o),o}}),_e(this,"unsubscribe",async(n,r)=>{this.isInitialized(),typeof r?.id<"u"?await this.unsubscribeById(n,r.id,r):await this.unsubscribeByTopic(n,r)}),_e(this,"isSubscribed",n=>new Promise(r=>{r(this.topicMap.topics.includes(n))})),_e(this,"isKnownTopic",n=>new Promise(r=>{r(this.topicMap.topics.includes(n)||this.pending.has(n)||this.cached.some(i=>i.topic===n))})),_e(this,"on",(n,r)=>{this.events.on(n,r)}),_e(this,"once",(n,r)=>{this.events.once(n,r)}),_e(this,"off",(n,r)=>{this.events.off(n,r)}),_e(this,"removeListener",(n,r)=>{this.events.removeListener(n,r)}),_e(this,"start",async()=>{await this.onConnect()}),_e(this,"stop",async()=>{await this.onDisconnect()}),_e(this,"restart",async()=>{await this.restore(),await this.onRestart()}),_e(this,"checkPending",async()=>{if(this.pending.size===0&&(!this.initialized||!this.relayer.connected))return;const n=[];this.pending.forEach(r=>{n.push(r)}),await this.batchSubscribe(n)}),_e(this,"registerEventListeners",()=>{this.relayer.core.heartbeat.on(rr.pulse,async()=>{await this.checkPending()}),this.events.on(It.created,async n=>{const r=It.created;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:n}),await this.persist()}),this.events.on(It.deleted,async n=>{const r=It.deleted;this.logger.info(`Emitting ${r}`),this.logger.debug({type:"event",event:r,data:n}),await this.persist()})}),this.relayer=e,this.logger=lt(s,this.name),this.clientId=""}get context(){return Et(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,s){let n=!1;try{n=this.getSubscription(e).topic===s}catch{}return n}reset(){this.cached=[],this.initialized=!0}onDisable(){this.values.length>0&&(this.cached=this.values),this.subscriptions.clear(),this.topicMap.clear()}async unsubscribeByTopic(e,s){const n=this.topicMap.get(e);await Promise.all(n.map(async r=>await this.unsubscribeById(e,r,s)))}async unsubscribeById(e,s,n){this.logger.debug("Unsubscribing Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:n}});try{const r=qi(n);await this.restartToComplete({topic:e,id:s,relay:r}),await this.rpcUnsubscribe(e,s,r);const i=Pe("USER_DISCONNECTED",`${this.name}, ${e}`);await this.onUnsubscribe(e,s,i),this.logger.debug("Successfully Unsubscribed Topic"),this.logger.trace({type:"method",method:"unsubscribe",params:{topic:e,id:s,opts:n}})}catch(r){throw this.logger.debug("Failed to Unsubscribe Topic"),this.logger.error(r),r}}async rpcSubscribe(e,s,n){var r,i;const o=await this.getSubscriptionId(e);if((r=n?.internal)!=null&&r.skipSubscribe)return o;(!n||n?.transportType===Oe.relay)&&await this.restartToComplete({topic:e,id:e,relay:s});const a={method:Wn(s.protocol).subscribe,params:{topic:e}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:a});const c=(i=n?.internal)==null?void 0:i.throwOnFailedPublish;try{if(n?.transportType===Oe.link_mode)return setTimeout(()=>{(this.relayer.connected||this.relayer.connecting)&&this.relayer.request(a).catch(d=>this.logger.warn(d))},H.toMiliseconds(H.ONE_SECOND)),o;const l=new Promise(async d=>{const h=m=>{m.topic===e&&(this.events.removeListener(It.created,h),d(m.id))};this.events.on(It.created,h);try{const m=await os(new Promise((g,b)=>{this.relayer.request(a).catch(y=>{this.logger.warn(y,y?.message),b(y)}).then(g)}),this.initialSubscribeTimeout,`Subscribing to ${e} failed, please try again`);this.events.removeListener(It.created,h),d(m)}catch{}}),u=await os(l,this.subscribeTimeout,`Subscribing to ${e} failed, please try again`);if(!u&&c)throw new Error(`Subscribing to ${e} failed, please try again`);return u?o:null}catch(l){if(this.logger.debug("Outgoing Relay Subscribe Payload stalled"),this.relayer.events.emit(Ue.connection_stalled),c)throw l}return null}async rpcBatchSubscribe(e){if(!e.length)return;const s=e[0].relay,n={method:Wn(s.protocol).batchSubscribe,params:{topics:e.map(r=>r.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});try{await await os(new Promise(r=>{this.relayer.request(n).catch(i=>this.logger.warn(i)).then(r)}),this.subscribeTimeout,"rpcBatchSubscribe failed, please try again")}catch{this.relayer.events.emit(Ue.connection_stalled)}}async rpcBatchFetchMessages(e){if(!e.length)return;const s=e[0].relay,n={method:Wn(s.protocol).batchFetchMessages,params:{topics:e.map(i=>i.topic)}};this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:n});let r;try{r=await await os(new Promise((i,o)=>{this.relayer.request(n).catch(a=>{this.logger.warn(a),o(a)}).then(i)}),this.subscribeTimeout,"rpcBatchFetchMessages failed, please try again")}catch{this.relayer.events.emit(Ue.connection_stalled)}return r}rpcUnsubscribe(e,s,n){const r={method:Wn(n.protocol).unsubscribe,params:{topic:e,id:s}};return this.logger.debug("Outgoing Relay Payload"),this.logger.trace({type:"payload",direction:"outgoing",request:r}),this.relayer.request(r)}onSubscribe(e,s){this.setSubscription(e,Uo(mr({},s),{id:e})),this.pending.delete(s.topic)}onBatchSubscribe(e){e.length&&e.forEach(s=>{this.setSubscription(s.id,mr({},s)),this.pending.delete(s.topic)})}async onUnsubscribe(e,s,n){this.events.removeAllListeners(s),this.hasSubscription(s,e)&&this.deleteSubscription(s,n),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,s){this.logger.debug("Setting subscription"),this.logger.trace({type:"method",method:"setSubscription",id:e,subscription:s}),this.addSubscription(e,s)}addSubscription(e,s){this.subscriptions.set(e,mr({},s)),this.topicMap.set(s.topic,e),this.events.emit(It.created,s)}getSubscription(e){this.logger.debug("Getting subscription"),this.logger.trace({type:"method",method:"getSubscription",id:e});const s=this.subscriptions.get(e);if(!s){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return s}deleteSubscription(e,s){this.logger.debug("Deleting subscription"),this.logger.trace({type:"method",method:"deleteSubscription",id:e,reason:s});const n=this.getSubscription(e);this.subscriptions.delete(e),this.topicMap.delete(n.topic,e),this.events.emit(It.deleted,Uo(mr({},n),{reason:s}))}async persist(){await this.setRelayerSubscriptions(this.values),this.events.emit(It.sync)}async onRestart(){if(this.cached.length){const e=[...this.cached],s=Math.ceil(this.cached.length/this.batchSubscribeTopicsLimit);for(let n=0;n<s;n++){const r=e.splice(0,this.batchSubscribeTopicsLimit);await this.batchSubscribe(r)}}this.events.emit(It.resubscribed)}async restore(){try{const e=await this.getRelayerSubscriptions();if(typeof e>"u"||!e.length)return;if(this.subscriptions.size&&!e.every(s=>{var n;return s.topic===((n=this.subscriptions.get(s.id))==null?void 0:n.topic)})){const{message:s}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),this.logger.error(`${this.name}: ${JSON.stringify(this.values)}`),new Error(s)}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 s=>Uo(mr({},s),{id:await this.getSubscriptionId(s.topic)})))))}async batchFetchMessages(e){if(!e.length)return;this.logger.trace(`Fetching batch messages for ${e.length} subscriptions`);const s=await this.rpcBatchFetchMessages(e);s&&s.messages&&(await Bm(H.toMiliseconds(H.ONE_SECOND)),await this.relayer.handleBatchMessageEvents(s.messages))}async onConnect(){await this.restart(),this.reset()}onDisconnect(){this.onDisable()}isInitialized(){if(!this.initialized){const{message:e}=V("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 $t(e+await this.getClientId())}}var hv=Object.defineProperty,Kl=Object.getOwnPropertySymbols,pv=Object.prototype.hasOwnProperty,fv=Object.prototype.propertyIsEnumerable,_a=(t,e,s)=>e in t?hv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Gl=(t,e)=>{for(var s in e||(e={}))pv.call(e,s)&&_a(t,s,e[s]);if(Kl)for(var s of Kl(e))fv.call(e,s)&&_a(t,s,e[s]);return t},Ce=(t,e,s)=>_a(t,typeof e!="symbol"?e+"":e,s);class gv extends ig{constructor(e){super(e),Ce(this,"protocol","wc"),Ce(this,"version",2),Ce(this,"core"),Ce(this,"logger"),Ce(this,"events",new An.EventEmitter),Ce(this,"provider"),Ce(this,"messages"),Ce(this,"subscriber"),Ce(this,"publisher"),Ce(this,"name",z0),Ce(this,"transportExplicitlyClosed",!1),Ce(this,"initialized",!1),Ce(this,"connectionAttemptInProgress",!1),Ce(this,"relayUrl"),Ce(this,"projectId"),Ce(this,"packageName"),Ce(this,"bundleId"),Ce(this,"hasExperiencedNetworkDisruption",!1),Ce(this,"pingTimeout"),Ce(this,"heartBeatTimeout",H.toMiliseconds(H.THIRTY_SECONDS+H.FIVE_SECONDS)),Ce(this,"reconnectTimeout"),Ce(this,"connectPromise"),Ce(this,"reconnectInProgress",!1),Ce(this,"requestsInFlight",[]),Ce(this,"connectTimeout",H.toMiliseconds(H.ONE_SECOND*15)),Ce(this,"request",async s=>{var n,r;this.logger.debug("Publishing Request Payload");const i=s.id||dn().toString();await this.toEstablishConnection();try{this.logger.trace({id:i,method:s.method,topic:(n=s.params)==null?void 0:n.topic},"relayer.request - publishing...");const o=`${i}:${((r=s.params)==null?void 0:r.tag)||""}`;this.requestsInFlight.push(o);const a=await this.provider.request(s);return this.requestsInFlight=this.requestsInFlight.filter(c=>c!==o),a}catch(o){throw this.logger.debug(`Failed to Publish Request: ${i}`),o}}),Ce(this,"resetPingTimeout",()=>{Ui()&&(clearTimeout(this.pingTimeout),this.pingTimeout=setTimeout(()=>{var s,n,r,i;try{this.logger.debug({},"pingTimeout: Connection stalled, terminating..."),(i=(r=(n=(s=this.provider)==null?void 0:s.connection)==null?void 0:n.socket)==null?void 0:r.terminate)==null||i.call(r)}catch(o){this.logger.warn(o,o?.message)}},this.heartBeatTimeout))}),Ce(this,"onPayloadHandler",s=>{this.onProviderPayload(s),this.resetPingTimeout()}),Ce(this,"onConnectHandler",()=>{this.logger.warn({},"Relayer connected 🛜"),this.startPingTimeout(),this.events.emit(Ue.connect)}),Ce(this,"onDisconnectHandler",()=>{this.logger.warn({},"Relayer disconnected 🛑"),this.requestsInFlight=[],this.onProviderDisconnect()}),Ce(this,"onProviderErrorHandler",s=>{this.logger.fatal(`Fatal socket error: ${s.message}`),this.events.emit(Ue.error,s),this.logger.fatal("Fatal socket error received, closing transport"),this.transportClose()}),Ce(this,"registerProviderListeners",()=>{this.provider.on(Ot.payload,this.onPayloadHandler),this.provider.on(Ot.connect,this.onConnectHandler),this.provider.on(Ot.disconnect,this.onDisconnectHandler),this.provider.on(Ot.error,this.onProviderErrorHandler)}),this.core=e.core,this.logger=typeof e.logger<"u"&&typeof e.logger!="string"?lt(e.logger,this.name):Kr(Xi({level:e.logger||V0})),this.messages=new JC(this.logger,e.core),this.subscriber=new dv(this,this.logger),this.publisher=new sv(this,this.logger),this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||vh,vm()?this.packageName=qc():Am()&&(this.bundleId=qc()),this.provider={}}async init(){this.logger.trace("Initialized"),this.registerEventListeners(),await Promise.all([this.messages.init(),this.subscriber.init()]),this.initialized=!0,this.transportOpen().catch(e=>this.logger.warn(e,e?.message))}get context(){return Et(this.logger)}get connected(){var e,s,n;return((n=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:n.readyState)===1||!1}get connecting(){var e,s,n;return((n=(s=(e=this.provider)==null?void 0:e.connection)==null?void 0:s.socket)==null?void 0:n.readyState)===0||this.connectPromise!==void 0||!1}async publish(e,s,n){this.isInitialized(),await this.publisher.publish(e,s,n),await this.recordMessageEvent({topic:e,message:s,publishedAt:Date.now(),transportType:Oe.relay},Ai.outbound)}async publishCustom(e){this.isInitialized(),await this.publisher.publishCustom(e)}async subscribe(e,s){var n,r,i;this.isInitialized(),(!(s!=null&&s.transportType)||s?.transportType==="relay")&&await this.toEstablishConnection();const o=typeof((n=s?.internal)==null?void 0:n.throwOnFailedPublish)>"u"?!0:(r=s?.internal)==null?void 0:r.throwOnFailedPublish;let a=((i=this.subscriber.topicMap.get(e))==null?void 0:i[0])||"",c;const l=u=>{u.topic===e&&(this.subscriber.off(It.created,l),c())};return await Promise.all([new Promise(u=>{c=u,this.subscriber.on(It.created,l)}),new Promise(async(u,d)=>{a=await this.subscriber.subscribe(e,Gl({internal:{throwOnFailedPublish:o}},s)).catch(h=>{o&&d(h)})||a,u()})]),a}async unsubscribe(e,s){this.isInitialized(),await this.subscriber.unsubscribe(e,s)}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}off(e,s){this.events.off(e,s)}removeListener(e,s){this.events.removeListener(e,s)}async transportDisconnect(){this.provider.disconnect&&(this.hasExperiencedNetworkDisruption||this.connected)?await os(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.info("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(s,n)=>{await this.connect(e).then(s).catch(n).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 xl())throw new Error("No internet connection detected. Please restart your network and try again.")}async handleBatchMessageEvents(e){if(e?.length===0){this.logger.trace("Batch message events is empty. Ignoring...");return}const s=e.sort((n,r)=>n.publishedAt-r.publishedAt);this.logger.debug(`Batch of ${s.length} message events sorted`);for(const n of s)try{await this.onMessageEvent(n)}catch(r){this.logger.warn(r,"Error while processing batch message event: "+r?.message)}this.logger.trace(`Batch of ${s.length} message events processed`)}async onLinkMessageEvent(e,s){const{topic:n}=e;if(!s.sessionExists){const r=Be(H.FIVE_MINUTES),i={topic:n,expiry:r,relay:{protocol:"irn"},active:!1};await this.core.pairing.pairings.set(n,i)}this.events.emit(Ue.message,e),await this.recordMessageEvent(e,Ai.inbound)}async connect(e){await this.confirmOnlineStateOrThrow(),e&&e!==this.relayUrl&&(this.relayUrl=e,await this.transportDisconnect()),this.connectionAttemptInProgress=!0,this.transportExplicitlyClosed=!1;let s=1;for(;s<6;){try{if(this.transportExplicitlyClosed)break;this.logger.debug({},`Connecting to ${this.relayUrl}, attempt: ${s}...`),await this.createProvider(),await new Promise(async(n,r)=>{const i=()=>{r(new Error("Connection interrupted while trying to connect"))};this.provider.once(Ot.disconnect,i),await os(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(Ot.disconnect,i),clearTimeout(this.reconnectTimeout)}),await new Promise(async(o,a)=>{const c=()=>{r(new Error("Connection interrupted while trying to subscribe"))};this.provider.once(Ot.disconnect,c),await this.subscriber.start().then(o).catch(a).finally(()=>{this.provider.off(Ot.disconnect,c)})}),this.hasExperiencedNetworkDisruption=!1,n()})}catch(n){await this.subscriber.stop();const r=n;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: ${s}`);break}await new Promise(n=>setTimeout(n,H.toMiliseconds(s*1))),s++}}startPingTimeout(){var e,s,n,r,i;if(Ui())try{(s=(e=this.provider)==null?void 0:e.connection)!=null&&s.socket&&((i=(r=(n=this.provider)==null?void 0:n.connection)==null?void 0:r.socket)==null||i.on("ping",()=>{this.resetPingTimeout()})),this.resetPingTimeout()}catch(o){this.logger.warn(o,o?.message)}}async createProvider(){this.provider.connection&&this.unregisterProviderListeners();const e=await this.core.crypto.signJWT(this.relayUrl);this.provider=new Ba(new bp(Tm({sdkVersion:Ea,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,s){const{topic:n,message:r}=e;await this.messages.set(n,r,s)}async shouldIgnoreMessageEvent(e){const{topic:s,message:n}=e;if(!n||n.length===0)return this.logger.warn(`Ignoring invalid/empty message: ${n}`),!0;if(!await this.subscriber.isKnownTopic(s))return this.logger.warn(`Ignoring message for unknown topic ${s}`),!0;const r=this.messages.has(s,n);return r&&this.logger.warn(`Ignoring duplicate message: ${n}`),r}async onProviderPayload(e){if(this.logger.debug("Incoming Relay Payload"),this.logger.trace({type:"payload",direction:"incoming",payload:e}),Ma(e)){if(!e.method.endsWith(H0))return;const s=e.params,{topic:n,message:r,publishedAt:i,attestation:o}=s.data,a={topic:n,message:r,publishedAt:i,transportType:Oe.relay,attestation:o};this.logger.debug("Emitting Relayer Payload"),this.logger.trace(Gl({type:"event",event:s.id},a)),this.events.emit(s.id,a),await this.acknowledgePayload(e),await this.onMessageEvent(a)}else ja(e)&&this.events.emit(Ue.message_ack,e)}async onMessageEvent(e){await this.shouldIgnoreMessageEvent(e)||(await this.recordMessageEvent(e,Ai.inbound),this.events.emit(Ue.message,e))}async acknowledgePayload(e){const s=xr(e.id,!0);await this.provider.connection.send(s)}unregisterProviderListeners(){this.provider.off(Ot.payload,this.onPayloadHandler),this.provider.off(Ot.connect,this.onConnectHandler),this.provider.off(Ot.disconnect,this.onDisconnectHandler),this.provider.off(Ot.error,this.onProviderErrorHandler),clearTimeout(this.pingTimeout)}async registerEventListeners(){let e=await xl();C0(async s=>{e!==s&&(e=s,s?await this.transportOpen().catch(n=>this.logger.error(n,n?.message)):(this.hasExperiencedNetworkDisruption=!0,await this.transportDisconnect(),this.transportExplicitlyClosed=!1))}),this.core.heartbeat.on(rr.pulse,async()=>{if(!this.transportExplicitlyClosed&&!this.connected&&I0())try{await this.confirmOnlineStateOrThrow(),await this.transportOpen()}catch(s){this.logger.warn(s,s?.message)}})}async onProviderDisconnect(){clearTimeout(this.pingTimeout),this.events.emit(Ue.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?.message)),this.reconnectTimeout=void 0,this.reconnectInProgress=!1},H.toMiliseconds(K0)))))}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}async toEstablishConnection(){if(await this.confirmOnlineStateOrThrow(),!this.connected){if(this.connectPromise){await this.connectPromise;return}await this.connect()}}}function mv(t,e){return t===e||Number.isNaN(t)&&Number.isNaN(e)}function Yl(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Jl(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const wv="[object RegExp]",yv="[object String]",bv="[object Number]",Ev="[object Boolean]",Xl="[object Arguments]",Cv="[object Symbol]",vv="[object Date]",Av="[object Map]",Iv="[object Set]",Nv="[object Array]",_v="[object Function]",Sv="[object ArrayBuffer]",Lo="[object Object]",Tv="[object Error]",Ov="[object DataView]",kv="[object Uint8Array]",Dv="[object Uint8ClampedArray]",Pv="[object Uint16Array]",Rv="[object Uint32Array]",xv="[object BigUint64Array]",$v="[object Int8Array]",Uv="[object Int16Array]",Lv="[object Int32Array]",Bv="[object BigInt64Array]",Mv="[object Float32Array]",jv="[object Float64Array]";function Fv(){}function Zl(t){if(!t||typeof t!="object")return!1;const e=Object.getPrototypeOf(t);return e===null||e===Object.prototype||Object.getPrototypeOf(e)===null?Object.prototype.toString.call(t)==="[object Object]":!1}function qv(t,e,s){return Ar(t,e,void 0,void 0,void 0,void 0,s)}function Ar(t,e,s,n,r,i,o){const a=o(t,e,s,n,r,i);if(a!==void 0)return a;if(typeof t==typeof e)switch(typeof t){case"bigint":case"string":case"boolean":case"symbol":case"undefined":return t===e;case"number":return t===e||Object.is(t,e);case"function":return t===e;case"object":return Dr(t,e,i,o)}return Dr(t,e,i,o)}function Dr(t,e,s,n){if(Object.is(t,e))return!0;let r=Jl(t),i=Jl(e);if(r===Xl&&(r=Lo),i===Xl&&(i=Lo),r!==i)return!1;switch(r){case yv:return t.toString()===e.toString();case bv:{const c=t.valueOf(),l=e.valueOf();return mv(c,l)}case Ev:case vv:case Cv:return Object.is(t.valueOf(),e.valueOf());case wv:return t.source===e.source&&t.flags===e.flags;case _v:return t===e}s=s??new Map;const o=s.get(t),a=s.get(e);if(o!=null&&a!=null)return o===e;s.set(t,e),s.set(e,t);try{switch(r){case Av:{if(t.size!==e.size)return!1;for(const[c,l]of t.entries())if(!e.has(c)||!Ar(l,e.get(c),c,t,e,s,n))return!1;return!0}case Iv:{if(t.size!==e.size)return!1;const c=Array.from(t.values()),l=Array.from(e.values());for(let u=0;u<c.length;u++){const d=c[u],h=l.findIndex(m=>Ar(d,m,void 0,t,e,s,n));if(h===-1)return!1;l.splice(h,1)}return!0}case Nv:case kv:case Dv:case Pv:case Rv:case xv:case $v:case Uv:case Lv:case Bv:case Mv:case jv:{if(typeof Buffer<"u"&&Buffer.isBuffer(t)!==Buffer.isBuffer(e)||t.length!==e.length)return!1;for(let c=0;c<t.length;c++)if(!Ar(t[c],e[c],c,t,e,s,n))return!1;return!0}case Sv:return t.byteLength!==e.byteLength?!1:Dr(new Uint8Array(t),new Uint8Array(e),s,n);case Ov:return t.byteLength!==e.byteLength||t.byteOffset!==e.byteOffset?!1:Dr(new Uint8Array(t),new Uint8Array(e),s,n);case Tv:return t.name===e.name&&t.message===e.message;case Lo:{if(!(Dr(t.constructor,e.constructor,s,n)||Zl(t)&&Zl(e)))return!1;const c=[...Object.keys(t),...Yl(t)],l=[...Object.keys(e),...Yl(e)];if(c.length!==l.length)return!1;for(let u=0;u<c.length;u++){const d=c[u],h=t[d];if(!Object.hasOwn(e,d))return!1;const m=e[d];if(!Ar(h,m,d,t,e,s,n))return!1}return!0}default:return!1}}finally{s.delete(t),s.delete(e)}}function Wv(t,e){return qv(t,e,Fv)}var Vv=Object.defineProperty,Ql=Object.getOwnPropertySymbols,zv=Object.prototype.hasOwnProperty,Hv=Object.prototype.propertyIsEnumerable,Sa=(t,e,s)=>e in t?Vv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,eu=(t,e)=>{for(var s in e||(e={}))zv.call(e,s)&&Sa(t,s,e[s]);if(Ql)for(var s of Ql(e))Hv.call(e,s)&&Sa(t,s,e[s]);return t},ft=(t,e,s)=>Sa(t,typeof e!="symbol"?e+"":e,s);class Tn extends og{constructor(e,s,n,r=ds,i=void 0){super(e,s,n,r),this.core=e,this.logger=s,this.name=n,ft(this,"map",new Map),ft(this,"version",G0),ft(this,"cached",[]),ft(this,"initialized",!1),ft(this,"getKey"),ft(this,"storagePrefix",ds),ft(this,"recentlyDeleted",[]),ft(this,"recentlyDeletedLimit",200),ft(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(o=>{this.getKey&&o!==null&&!qe(o)?this.map.set(this.getKey(o),o):Zb(o)?this.map.set(o.id,o):Qb(o)&&this.map.set(o.topic,o)}),this.cached=[],this.initialized=!0)}),ft(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())}),ft(this,"get",o=>(this.isInitialized(),this.logger.debug("Getting value"),this.logger.trace({type:"method",method:"get",key:o}),this.getData(o))),ft(this,"getAll",o=>(this.isInitialized(),o?this.values.filter(a=>Object.keys(o).every(c=>Wv(a[c],o[c]))):this.values)),ft(this,"update",async(o,a)=>{this.isInitialized(),this.logger.debug("Updating value"),this.logger.trace({type:"method",method:"update",key:o,update:a});const c=eu(eu({},this.getData(o)),a);this.map.set(o,c),await this.persist()}),ft(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=lt(s,this.name),this.storagePrefix=r,this.getKey=i}get context(){return Et(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 s=this.map.get(e);if(!s){if(this.recentlyDeleted.includes(e)){const{message:r}=V("MISSING_OR_INVALID",`Record was recently deleted - ${this.name}: ${e}`);throw this.logger.error(r),new Error(r)}const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.error(n),new Error(n)}return s}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:s}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}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}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Kv=Object.defineProperty,Gv=(t,e,s)=>e in t?Kv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,pe=(t,e,s)=>Gv(t,typeof e!="symbol"?e+"":e,s);class Yv{constructor(e,s){this.core=e,this.logger=s,pe(this,"name",Z0),pe(this,"version",Q0),pe(this,"events",new Fa),pe(this,"pairings"),pe(this,"initialized",!1),pe(this,"storagePrefix",ds),pe(this,"ignoredPayloadTypes",[Ns]),pe(this,"registeredMethods",[]),pe(this,"init",async()=>{this.initialized||(await this.pairings.init(),await this.cleanup(),this.registerRelayerEvents(),this.registerExpirerEvents(),this.initialized=!0,this.logger.trace("Initialized"))}),pe(this,"register",({methods:n})=>{this.isInitialized(),this.registeredMethods=[...new Set([...this.registeredMethods,...n])]}),pe(this,"create",async n=>{this.isInitialized();const r=wa(),i=await this.core.crypto.setSymKey(r),o=Be(H.FIVE_MINUTES),a={protocol:Ch},c={topic:i,expiry:o,relay:a,active:!1,methods:n?.methods},l=Nl({protocol:this.core.protocol,version:this.core.version,topic:i,symKey:r,relay:a,expiryTimestamp:o,methods:n?.methods});return this.events.emit(cn.create,c),this.core.expirer.set(i,o),await this.pairings.set(i,c),await this.core.relayer.subscribe(i,{transportType:n?.transportType,internal:n?.internal}),{topic:i,uri:l}}),pe(this,"pair",async n=>{this.isInitialized();const r=this.core.eventClient.createEvent({properties:{topic:n?.uri,trace:[es.pairing_started]}});this.isValidPair(n,r);const{topic:i,symKey:o,relay:a,expiryTimestamp:c,methods:l}=Il(n.uri);r.props.properties.topic=i,r.addTrace(es.pairing_uri_validation_success),r.addTrace(es.pairing_uri_not_expired);let u;if(this.pairings.keys.includes(i)){if(u=this.pairings.get(i),r.addTrace(es.existing_pairing),u.active)throw r.setError(ms.active_pairing_already_exists),new Error(`Pairing already exists: ${i}. Please try again with a new connection URI.`);r.addTrace(es.pairing_not_expired)}const d=c||Be(H.FIVE_MINUTES),h={topic:i,relay:a,expiry:d,active:!1,methods:l};this.core.expirer.set(i,d),await this.pairings.set(i,h),r.addTrace(es.store_new_pairing),n.activatePairing&&await this.activate({topic:i}),this.events.emit(cn.create,h),r.addTrace(es.emit_inactive_pairing),this.core.crypto.keychain.has(i)||await this.core.crypto.setSymKey(o,i),r.addTrace(es.subscribing_pairing_topic);try{await this.core.relayer.confirmOnlineStateOrThrow()}catch{r.setError(ms.no_internet_connection)}try{await this.core.relayer.subscribe(i,{relay:a})}catch(m){throw r.setError(ms.subscribe_pairing_topic_failure),m}return r.addTrace(es.subscribe_pairing_topic_success),h}),pe(this,"activate",async({topic:n})=>{this.isInitialized();const r=Be(H.FIVE_MINUTES);this.core.expirer.set(n,r),await this.pairings.update(n,{active:!0,expiry:r})}),pe(this,"ping",async n=>{this.isInitialized(),await this.isValidPing(n),this.logger.warn("ping() is deprecated and will be removed in the next major release.");const{topic:r}=n;if(this.pairings.keys.includes(r)){const i=await this.sendRequest(r,"wc_pairingPing",{}),{done:o,resolve:a,reject:c}=an();this.events.once(Ae("pairing_ping",i),({error:l})=>{l?c(l):a()}),await o()}}),pe(this,"updateExpiry",async({topic:n,expiry:r})=>{this.isInitialized(),await this.pairings.update(n,{expiry:r})}),pe(this,"updateMetadata",async({topic:n,metadata:r})=>{this.isInitialized(),await this.pairings.update(n,{peerMetadata:r})}),pe(this,"getPairings",()=>(this.isInitialized(),this.pairings.values)),pe(this,"disconnect",async n=>{this.isInitialized(),await this.isValidDisconnect(n);const{topic:r}=n;this.pairings.keys.includes(r)&&(await this.sendRequest(r,"wc_pairingDelete",Pe("USER_DISCONNECTED")),await this.deletePairing(r))}),pe(this,"formatUriFromPairing",n=>{this.isInitialized();const{topic:r,relay:i,expiry:o,methods:a}=n,c=this.core.crypto.keychain.get(r);return Nl({protocol:this.core.protocol,version:this.core.version,topic:r,symKey:c,relay:i,expiryTimestamp:o,methods:a})}),pe(this,"sendRequest",async(n,r,i)=>{const o=ss(r,i),a=await this.core.crypto.encode(n,o),c=pr[r].req;return this.core.history.set(n,o),this.core.relayer.publish(n,a,c),o.id}),pe(this,"sendResult",async(n,r,i)=>{const o=xr(n,i),a=await this.core.crypto.encode(r,o),c=(await this.core.history.get(r,n)).request.method,l=pr[c].res;await this.core.relayer.publish(r,a,l),await this.core.history.resolve(o)}),pe(this,"sendError",async(n,r,i)=>{const o=Ku(n,i),a=await this.core.crypto.encode(r,o),c=(await this.core.history.get(r,n)).request.method,l=pr[c]?pr[c].res:pr.unregistered_method.res;await this.core.relayer.publish(r,a,l),await this.core.history.resolve(o)}),pe(this,"deletePairing",async(n,r)=>{await this.core.relayer.unsubscribe(n),await Promise.all([this.pairings.delete(n,Pe("USER_DISCONNECTED")),this.core.crypto.deleteSymKey(n),r?Promise.resolve():this.core.expirer.del(n)])}),pe(this,"cleanup",async()=>{const n=this.pairings.getAll().filter(r=>rs(r.expiry));await Promise.all(n.map(r=>this.deletePairing(r.topic)))}),pe(this,"onRelayEventRequest",async n=>{const{topic:r,payload:i}=n;switch(i.method){case"wc_pairingPing":return await this.onPairingPingRequest(r,i);case"wc_pairingDelete":return await this.onPairingDeleteRequest(r,i);default:return await this.onUnknownRpcMethodRequest(r,i)}}),pe(this,"onRelayEventResponse",async n=>{const{topic:r,payload:i}=n,o=(await this.core.history.get(r,i.id)).request.method;return o==="wc_pairingPing"?this.onPairingPingResponse(r,i):this.onUnknownRpcMethodResponse(o)}),pe(this,"onPairingPingRequest",async(n,r)=>{const{id:i}=r;try{this.isValidPing({topic:n}),await this.sendResult(i,n,!0),this.events.emit(cn.ping,{id:i,topic:n})}catch(o){await this.sendError(i,n,o),this.logger.error(o)}}),pe(this,"onPairingPingResponse",(n,r)=>{const{id:i}=r;setTimeout(()=>{fs(r)?this.events.emit(Ae("pairing_ping",i),{}):ts(r)&&this.events.emit(Ae("pairing_ping",i),{error:r.error})},500)}),pe(this,"onPairingDeleteRequest",async(n,r)=>{const{id:i}=r;try{this.isValidDisconnect({topic:n}),await this.deletePairing(n),this.events.emit(cn.delete,{id:i,topic:n})}catch(o){await this.sendError(i,n,o),this.logger.error(o)}}),pe(this,"onUnknownRpcMethodRequest",async(n,r)=>{const{id:i,method:o}=r;try{if(this.registeredMethods.includes(o))return;const a=Pe("WC_METHOD_UNSUPPORTED",o);await this.sendError(i,n,a),this.logger.error(a)}catch(a){await this.sendError(i,n,a),this.logger.error(a)}}),pe(this,"onUnknownRpcMethodResponse",n=>{this.registeredMethods.includes(n)||this.logger.error(Pe("WC_METHOD_UNSUPPORTED",n))}),pe(this,"isValidPair",(n,r)=>{var i;if(!gt(n)){const{message:a}=V("MISSING_OR_INVALID",`pair() params: ${n}`);throw r.setError(ms.malformed_pairing_uri),new Error(a)}if(!Xb(n.uri)){const{message:a}=V("MISSING_OR_INVALID",`pair() uri: ${n.uri}`);throw r.setError(ms.malformed_pairing_uri),new Error(a)}const o=Il(n?.uri);if(!((i=o?.relay)!=null&&i.protocol)){const{message:a}=V("MISSING_OR_INVALID","pair() uri#relay-protocol");throw r.setError(ms.malformed_pairing_uri),new Error(a)}if(!(o!=null&&o.symKey)){const{message:a}=V("MISSING_OR_INVALID","pair() uri#symKey");throw r.setError(ms.malformed_pairing_uri),new Error(a)}if(o!=null&&o.expiryTimestamp&&H.toMiliseconds(o?.expiryTimestamp)<Date.now()){r.setError(ms.pairing_expired);const{message:a}=V("EXPIRED","pair() URI has expired. Please try again with a new connection URI.");throw new Error(a)}}),pe(this,"isValidPing",async n=>{if(!gt(n)){const{message:i}=V("MISSING_OR_INVALID",`ping() params: ${n}`);throw new Error(i)}const{topic:r}=n;await this.isValidPairingTopic(r)}),pe(this,"isValidDisconnect",async n=>{if(!gt(n)){const{message:i}=V("MISSING_OR_INVALID",`disconnect() params: ${n}`);throw new Error(i)}const{topic:r}=n;await this.isValidPairingTopic(r)}),pe(this,"isValidPairingTopic",async n=>{if(!Me(n,!1)){const{message:r}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${n}`);throw new Error(r)}if(!this.pairings.keys.includes(n)){const{message:r}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${n}`);throw new Error(r)}if(rs(this.pairings.get(n).expiry)){await this.deletePairing(n);const{message:r}=V("EXPIRED",`pairing topic: ${n}`);throw new Error(r)}}),this.core=e,this.logger=lt(s,this.name),this.pairings=new Tn(this.core,this.logger,this.name,this.storagePrefix)}get context(){return Et(this.logger)}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}registerRelayerEvents(){this.core.relayer.on(Ue.message,async e=>{const{topic:s,message:n,transportType:r}=e;if(this.pairings.keys.includes(s)&&r!==Oe.link_mode&&!this.ignoredPayloadTypes.includes(this.core.crypto.getPayloadType(n)))try{const i=await this.core.crypto.decode(s,n);Ma(i)?(this.core.history.set(s,i),await this.onRelayEventRequest({topic:s,payload:i})):ja(i)&&(await this.core.history.resolve(i),await this.onRelayEventResponse({topic:s,payload:i}),this.core.history.delete(s,i.id)),await this.core.relayer.messages.ack(s,n)}catch(i){this.logger.error(i)}})}registerExpirerEvents(){this.core.expirer.on(xt.expired,async e=>{const{topic:s}=bd(e.target);s&&this.pairings.keys.includes(s)&&(await this.deletePairing(s,!0),this.events.emit(cn.expire,{topic:s}))})}}var Jv=Object.defineProperty,Xv=(t,e,s)=>e in t?Jv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ke=(t,e,s)=>Xv(t,typeof e!="symbol"?e+"":e,s);class Zv extends sg{constructor(e,s){super(e,s),this.core=e,this.logger=s,Ke(this,"records",new Map),Ke(this,"events",new An.EventEmitter),Ke(this,"name",eE),Ke(this,"version",tE),Ke(this,"cached",[]),Ke(this,"initialized",!1),Ke(this,"storagePrefix",ds),Ke(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.records.set(n.id,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),Ke(this,"set",(n,r,i)=>{if(this.isInitialized(),this.logger.debug("Setting JSON-RPC request history record"),this.logger.trace({type:"method",method:"set",topic:n,request:r,chainId:i}),this.records.has(r.id))return;const o={id:r.id,topic:n,request:{method:r.method,params:r.params||null},chainId:i,expiry:Be(H.THIRTY_DAYS)};this.records.set(o.id,o),this.persist(),this.events.emit(Wt.created,o)}),Ke(this,"resolve",async n=>{if(this.isInitialized(),this.logger.debug("Updating JSON-RPC response history record"),this.logger.trace({type:"method",method:"update",response:n}),!this.records.has(n.id))return;const r=await this.getRecord(n.id);typeof r.response>"u"&&(r.response=ts(n)?{error:n.error}:{result:n.result},this.records.set(r.id,r),this.persist(),this.events.emit(Wt.updated,r))}),Ke(this,"get",async(n,r)=>(this.isInitialized(),this.logger.debug("Getting record"),this.logger.trace({type:"method",method:"get",topic:n,id:r}),await this.getRecord(r))),Ke(this,"delete",(n,r)=>{this.isInitialized(),this.logger.debug("Deleting record"),this.logger.trace({type:"method",method:"delete",id:r}),this.values.forEach(i=>{if(i.topic===n){if(typeof r<"u"&&i.id!==r)return;this.records.delete(i.id),this.events.emit(Wt.deleted,i)}}),this.persist()}),Ke(this,"exists",async(n,r)=>(this.isInitialized(),this.records.has(r)?(await this.getRecord(r)).topic===n:!1)),Ke(this,"on",(n,r)=>{this.events.on(n,r)}),Ke(this,"once",(n,r)=>{this.events.once(n,r)}),Ke(this,"off",(n,r)=>{this.events.off(n,r)}),Ke(this,"removeListener",(n,r)=>{this.events.removeListener(n,r)}),this.logger=lt(s,this.name)}get context(){return Et(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(s=>{if(typeof s.response<"u")return;const n={topic:s.topic,request:ss(s.request.method,s.request.params,s.id),chainId:s.chainId};return e.push(n)}),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 s=this.records.get(e);if(!s){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw new Error(n)}return s}async persist(){await this.setJsonRpcRecords(this.values),this.events.emit(Wt.sync)}async restore(){try{const e=await this.getJsonRpcRecords();if(typeof e>"u"||!e.length)return;if(this.records.size){const{message:s}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}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(Wt.created,e=>{const s=Wt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Wt.updated,e=>{const s=Wt.updated;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.events.on(Wt.deleted,e=>{const s=Wt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,record:e})}),this.core.heartbeat.on(rr.pulse,()=>{this.cleanup()})}cleanup(){try{this.isInitialized();let e=!1;this.records.forEach(s=>{H.toMiliseconds(s.expiry||0)-Date.now()<=0&&(this.logger.info(`Deleting expired history log: ${s.id}`),this.records.delete(s.id),this.events.emit(Wt.deleted,s,!1),e=!0)}),e&&this.persist()}catch(e){this.logger.warn(e)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var Qv=Object.defineProperty,e1=(t,e,s)=>e in t?Qv(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,nt=(t,e,s)=>e1(t,typeof e!="symbol"?e+"":e,s);class t1 extends cg{constructor(e,s){super(e,s),this.core=e,this.logger=s,nt(this,"expirations",new Map),nt(this,"events",new An.EventEmitter),nt(this,"name",sE),nt(this,"version",nE),nt(this,"cached",[]),nt(this,"initialized",!1),nt(this,"storagePrefix",ds),nt(this,"init",async()=>{this.initialized||(this.logger.trace("Initialized"),await this.restore(),this.cached.forEach(n=>this.expirations.set(n.target,n)),this.cached=[],this.registerEventListeners(),this.initialized=!0)}),nt(this,"has",n=>{try{const r=this.formatTarget(n);return typeof this.getExpiration(r)<"u"}catch{return!1}}),nt(this,"set",(n,r)=>{this.isInitialized();const i=this.formatTarget(n),o={target:i,expiry:r};this.expirations.set(i,o),this.checkExpiry(i,o),this.events.emit(xt.created,{target:i,expiration:o})}),nt(this,"get",n=>{this.isInitialized();const r=this.formatTarget(n);return this.getExpiration(r)}),nt(this,"del",n=>{if(this.isInitialized(),this.has(n)){const r=this.formatTarget(n),i=this.getExpiration(r);this.expirations.delete(r),this.events.emit(xt.deleted,{target:r,expiration:i})}}),nt(this,"on",(n,r)=>{this.events.on(n,r)}),nt(this,"once",(n,r)=>{this.events.once(n,r)}),nt(this,"off",(n,r)=>{this.events.off(n,r)}),nt(this,"removeListener",(n,r)=>{this.events.removeListener(n,r)}),this.logger=lt(s,this.name)}get context(){return Et(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 Om(e);if(typeof e=="number")return km(e);const{message:s}=V("UNKNOWN_TYPE",`Target type: ${typeof e}`);throw new Error(s)}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(xt.sync)}async restore(){try{const e=await this.getExpirations();if(typeof e>"u"||!e.length)return;if(this.expirations.size){const{message:s}=V("RESTORE_WILL_OVERRIDE",this.name);throw this.logger.error(s),new Error(s)}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 s=this.expirations.get(e);if(!s){const{message:n}=V("NO_MATCHING_KEY",`${this.name}: ${e}`);throw this.logger.warn(n),new Error(n)}return s}checkExpiry(e,s){const{expiry:n}=s;H.toMiliseconds(n)-Date.now()<=0&&this.expire(e,s)}expire(e,s){this.expirations.delete(e),this.events.emit(xt.expired,{target:e,expiration:s})}checkExpirations(){this.core.relayer.connected&&this.expirations.forEach((e,s)=>this.checkExpiry(s,e))}registerEventListeners(){this.core.heartbeat.on(rr.pulse,()=>this.checkExpirations()),this.events.on(xt.created,e=>{const s=xt.created;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(xt.expired,e=>{const s=xt.expired;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()}),this.events.on(xt.deleted,e=>{const s=xt.deleted;this.logger.info(`Emitting ${s}`),this.logger.debug({type:"event",event:s,data:e}),this.persist()})}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}}var s1=Object.defineProperty,n1=(t,e,s)=>e in t?s1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Le=(t,e,s)=>n1(t,typeof e!="symbol"?e+"":e,s);class r1 extends lg{constructor(e,s,n){super(e,s,n),this.core=e,this.logger=s,this.store=n,Le(this,"name",rE),Le(this,"abortController"),Le(this,"isDevEnv"),Le(this,"verifyUrlV3",oE),Le(this,"storagePrefix",ds),Le(this,"version",Eh),Le(this,"publicKey"),Le(this,"fetchPromise"),Le(this,"init",async()=>{var r;this.isDevEnv||(this.publicKey=await this.store.getItem(this.storeKey),this.publicKey&&H.toMiliseconds((r=this.publicKey)==null?void 0:r.expiresAt)<Date.now()&&(this.logger.debug("verify v2 public key expired"),await this.removePublicKey()))}),Le(this,"register",async r=>{if(!ir()||this.isDevEnv)return;const i=window.location.origin,{id:o,decryptedId:a}=r,c=`${this.verifyUrlV3}/attestation?projectId=${this.core.projectId}&origin=${i}&id=${o}&decryptedId=${a}`;try{const l=Ss.getDocument(),u=this.startAbortTimer(H.ONE_SECOND*5),d=await new Promise((h,m)=>{const g=()=>{window.removeEventListener("message",y),l.body.removeChild(b),m("attestation aborted")};this.abortController.signal.addEventListener("abort",g);const b=l.createElement("iframe");b.src=c,b.style.display="none",b.addEventListener("error",g,{signal:this.abortController.signal});const y=_=>{if(_.data&&typeof _.data=="string")try{const N=JSON.parse(_.data);if(N.type==="verify_attestation"){if(Jo(N.attestation).payload.id!==o)return;clearInterval(u),l.body.removeChild(b),this.abortController.signal.removeEventListener("abort",g),window.removeEventListener("message",y),h(N.attestation===null?"":N.attestation)}}catch(N){this.logger.warn(N)}};l.body.appendChild(b),window.addEventListener("message",y,{signal:this.abortController.signal})});return this.logger.debug("jwt attestation",d),d}catch(l){this.logger.warn(l)}return""}),Le(this,"resolve",async r=>{if(this.isDevEnv)return"";const{attestationId:i,hash:o,encryptedId:a}=r;if(i===""){this.logger.debug("resolve: attestationId is empty, skipping");return}if(i){if(Jo(i).payload.id!==a)return;const l=await this.isValidJwtAttestation(i);if(l){if(!l.isVerified){this.logger.warn("resolve: jwt attestation: origin url not verified");return}return l}}if(!o)return;const c=this.getVerifyUrl(r?.verifyUrl);return this.fetchAttestation(o,c)}),Le(this,"fetchAttestation",async(r,i)=>{this.logger.debug(`resolving attestation: ${r} from url: ${i}`);const o=this.startAbortTimer(H.ONE_SECOND*5),a=await fetch(`${i}/attestation/${r}?v2Supported=true`,{signal:this.abortController.signal});return clearTimeout(o),a.status===200?await a.json():void 0}),Le(this,"getVerifyUrl",r=>{let i=r||kr;return aE.includes(i)||(this.logger.info(`verify url: ${i}, not included in trusted list, assigning default: ${kr}`),i=kr),i}),Le(this,"fetchPublicKey",async()=>{try{this.logger.debug(`fetching public key from: ${this.verifyUrlV3}`);const r=this.startAbortTimer(H.FIVE_SECONDS),i=await fetch(`${this.verifyUrlV3}/public-key`,{signal:this.abortController.signal});return clearTimeout(r),await i.json()}catch(r){this.logger.warn(r)}}),Le(this,"persistPublicKey",async r=>{this.logger.debug("persisting public key to local storage",r),await this.store.setItem(this.storeKey,r),this.publicKey=r}),Le(this,"removePublicKey",async()=>{this.logger.debug("removing verify v2 public key from storage"),await this.store.removeItem(this.storeKey),this.publicKey=void 0}),Le(this,"isValidJwtAttestation",async r=>{const i=await this.getPublicKey();try{if(i)return this.validateAttestation(r,i)}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")}}),Le(this,"getPublicKey",async()=>this.publicKey?this.publicKey:await this.fetchAndPersistPublicKey()),Le(this,"fetchAndPersistPublicKey",async()=>{if(this.fetchPromise)return await this.fetchPromise,this.publicKey;this.fetchPromise=new Promise(async i=>{const o=await this.fetchPublicKey();o&&(await this.persistPublicKey(o),i(o))});const r=await this.fetchPromise;return this.fetchPromise=void 0,r}),Le(this,"validateAttestation",(r,i)=>{const o=Ib(r,i.publicKey),a={hasExpired:H.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=lt(s,this.name),this.abortController=new AbortController,this.isDevEnv=Ha(),this.init()}get storeKey(){return this.storagePrefix+this.version+this.core.customStoragePrefix+"//verify:public:key"}get context(){return Et(this.logger)}startAbortTimer(e){return this.abortController=new AbortController,setTimeout(()=>this.abortController.abort(),H.toMiliseconds(e))}}var i1=Object.defineProperty,o1=(t,e,s)=>e in t?i1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,tu=(t,e,s)=>o1(t,typeof e!="symbol"?e+"":e,s);class a1 extends ug{constructor(e,s){super(e,s),this.projectId=e,this.logger=s,tu(this,"context",cE),tu(this,"registerDeviceToken",async n=>{const{clientId:r,token:i,notificationType:o,enableEncrypted:a=!1}=n,c=`${lE}/${this.projectId}/clients`;await fetch(c,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_id:r,type:o,token:i,always_raw:a})})}),this.logger=lt(s,this.context)}}var c1=Object.defineProperty,su=Object.getOwnPropertySymbols,l1=Object.prototype.hasOwnProperty,u1=Object.prototype.propertyIsEnumerable,Ta=(t,e,s)=>e in t?c1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,wr=(t,e)=>{for(var s in e||(e={}))l1.call(e,s)&&Ta(t,s,e[s]);if(su)for(var s of su(e))u1.call(e,s)&&Ta(t,s,e[s]);return t},We=(t,e,s)=>Ta(t,typeof e!="symbol"?e+"":e,s);class d1 extends dg{constructor(e,s,n=!0){super(e,s,n),this.core=e,this.logger=s,We(this,"context",dE),We(this,"storagePrefix",ds),We(this,"storageVersion",uE),We(this,"events",new Map),We(this,"shouldPersist",!1),We(this,"init",async()=>{if(!Ha())try{const r={eventId:Vc(),timestamp:Date.now(),domain:this.getAppDomain(),props:{event:"INIT",type:"",properties:{client_id:await this.core.crypto.getClientId(),user_agent:wd(this.core.relayer.protocol,this.core.relayer.version,Ea)}}};await this.sendEvent([r])}catch(r){this.logger.warn(r)}}),We(this,"createEvent",r=>{const{event:i="ERROR",type:o="",properties:{topic:a,trace:c}}=r,l=Vc(),u=this.core.projectId||"",d=Date.now(),h=wr({eventId:l,timestamp:d,props:{event:i,type:o,properties:{topic:a,trace:c}},bundleId:u,domain:this.getAppDomain()},this.setMethods(l));return this.telemetryEnabled&&(this.events.set(l,h),this.shouldPersist=!0),h}),We(this,"getEvent",r=>{const{eventId:i,topic:o}=r;if(i)return this.events.get(i);const a=Array.from(this.events.values()).find(c=>c.props.properties.topic===o);if(a)return wr(wr({},a),this.setMethods(a.eventId))}),We(this,"deleteEvent",r=>{const{eventId:i}=r;this.events.delete(i),this.shouldPersist=!0}),We(this,"setEventListeners",()=>{this.core.heartbeat.on(rr.pulse,async()=>{this.shouldPersist&&await this.persist(),this.events.forEach(r=>{H.fromMiliseconds(Date.now())-H.fromMiliseconds(r.timestamp)>hE&&(this.events.delete(r.eventId),this.shouldPersist=!0)})})}),We(this,"setMethods",r=>({addTrace:i=>this.addTrace(r,i),setError:i=>this.setError(r,i)})),We(this,"addTrace",(r,i)=>{const o=this.events.get(r);o&&(o.props.properties.trace.push(i),this.events.set(r,o),this.shouldPersist=!0)}),We(this,"setError",(r,i)=>{const o=this.events.get(r);o&&(o.props.type=i,o.timestamp=Date.now(),this.events.set(r,o),this.shouldPersist=!0)}),We(this,"persist",async()=>{await this.core.storage.setItem(this.storageKey,Array.from(this.events.values())),this.shouldPersist=!1}),We(this,"restore",async()=>{try{const r=await this.core.storage.getItem(this.storageKey)||[];if(!r.length)return;r.forEach(i=>{this.events.set(i.eventId,wr(wr({},i),this.setMethods(i.eventId)))})}catch(r){this.logger.warn(r)}}),We(this,"submit",async()=>{if(!this.telemetryEnabled||this.events.size===0)return;const r=[];for(const[i,o]of this.events)o.props.type&&r.push(o);if(r.length!==0)try{if((await this.sendEvent(r)).ok)for(const i of r)this.events.delete(i.eventId),this.shouldPersist=!0}catch(i){this.logger.warn(i)}}),We(this,"sendEvent",async r=>{const i=this.getAppDomain()?"":"&sp=desktop";return await fetch(`${pE}?projectId=${this.core.projectId}&st=events_sdk&sv=js-${Ea}${i}`,{method:"POST",body:JSON.stringify(r)})}),We(this,"getAppDomain",()=>md().url),this.logger=lt(s,this.context),this.telemetryEnabled=n,n?this.restore().then(async()=>{await this.submit(),this.setEventListeners()}):this.persist()}get storageKey(){return this.storagePrefix+this.storageVersion+this.core.customStoragePrefix+"//"+this.context}}var h1=Object.defineProperty,nu=Object.getOwnPropertySymbols,p1=Object.prototype.hasOwnProperty,f1=Object.prototype.propertyIsEnumerable,Oa=(t,e,s)=>e in t?h1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,ru=(t,e)=>{for(var s in e||(e={}))p1.call(e,s)&&Oa(t,s,e[s]);if(nu)for(var s of nu(e))f1.call(e,s)&&Oa(t,s,e[s]);return t},Se=(t,e,s)=>Oa(t,typeof e!="symbol"?e+"":e,s);let g1=class $h extends Zf{constructor(e){var s;super(e),Se(this,"protocol",bh),Se(this,"version",Eh),Se(this,"name",ba),Se(this,"relayUrl"),Se(this,"projectId"),Se(this,"customStoragePrefix"),Se(this,"events",new An.EventEmitter),Se(this,"logger"),Se(this,"heartbeat"),Se(this,"relayer"),Se(this,"crypto"),Se(this,"storage"),Se(this,"history"),Se(this,"expirer"),Se(this,"pairing"),Se(this,"verify"),Se(this,"echoClient"),Se(this,"linkModeSupportedApps"),Se(this,"eventClient"),Se(this,"initialized",!1),Se(this,"logChunkController"),Se(this,"on",(a,c)=>this.events.on(a,c)),Se(this,"once",(a,c)=>this.events.once(a,c)),Se(this,"off",(a,c)=>this.events.off(a,c)),Se(this,"removeListener",(a,c)=>this.events.removeListener(a,c)),Se(this,"dispatchEnvelope",({topic:a,message:c,sessionExists:l})=>{if(!a||!c)return;const u={topic:a,message:c,publishedAt:Date.now(),transportType:Oe.link_mode};this.relayer.onLinkMessageEvent(u,{sessionExists:l})});const n=this.getGlobalCore(e?.customStoragePrefix);if(n)try{return this.customStoragePrefix=n.customStoragePrefix,this.logger=n.logger,this.heartbeat=n.heartbeat,this.crypto=n.crypto,this.history=n.history,this.expirer=n.expirer,this.storage=n.storage,this.relayer=n.relayer,this.pairing=n.pairing,this.verify=n.verify,this.echoClient=n.echoClient,this.linkModeSupportedApps=n.linkModeSupportedApps,this.eventClient=n.eventClient,this.initialized=n.initialized,this.logChunkController=n.logChunkController,n}catch(a){console.warn("Failed to copy global core",a)}this.projectId=e?.projectId,this.relayUrl=e?.relayUrl||vh,this.customStoragePrefix=e!=null&&e.customStoragePrefix?`:${e.customStoragePrefix}`:"";const r=Xi({level:typeof e?.logger=="string"&&e.logger?e.logger:x0.logger,name:ba}),{logger:i,chunkLoggerController:o}=Yf({opts:r,maxSizeInBytes:e?.maxLogBlobSizeInBytes,loggerOverride:e?.logger});this.logChunkController=o,(s=this.logChunkController)!=null&&s.downloadLogsBlobInBrowser&&(window.downloadLogsBlobInBrowser=async()=>{var a,c;(a=this.logChunkController)!=null&&a.downloadLogsBlobInBrowser&&((c=this.logChunkController)==null||c.downloadLogsBlobInBrowser({clientId:await this.crypto.getClientId()}))}),this.logger=lt(i,this.name),this.heartbeat=new wp,this.crypto=new qC(this,this.logger,e?.keychain),this.history=new Zv(this,this.logger),this.expirer=new t1(this,this.logger),this.storage=e!=null&&e.storage?e.storage:new yp(ru(ru({},$0),e?.storageOptions)),this.relayer=new gv({core:this,logger:this.logger,relayUrl:this.relayUrl,projectId:this.projectId}),this.pairing=new Yv(this,this.logger),this.verify=new r1(this,this.logger,this.storage),this.echoClient=new a1(this.projectId||"",this.logger),this.linkModeSupportedApps=[],this.eventClient=new d1(this,this.logger,e?.telemetryEnabled),this.setGlobalCore(this)}static async init(e){const s=new $h(e);await s.initialize();const n=await s.crypto.getClientId();return await s.storage.setItem(Y0,n),s}get context(){return Et(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(Ul,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(Ul)||[],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}}getGlobalCore(e=""){try{if(this.isGlobalCoreDisabled())return;const s=`_walletConnectCore_${e}`,n=`${s}_count`;return globalThis[n]=(globalThis[n]||0)+1,globalThis[n]>1&&console.warn(`WalletConnect Core is already initialized. This is probably a mistake and can lead to unexpected behavior. Init() was called ${globalThis[n]} times.`),globalThis[s]}catch(s){console.warn("Failed to get global WalletConnect core",s);return}}setGlobalCore(e){var s;try{if(this.isGlobalCoreDisabled())return;const n=`_walletConnectCore_${((s=e.opts)==null?void 0:s.customStoragePrefix)||""}`;globalThis[n]=e}catch(n){console.warn("Failed to set global WalletConnect core",n)}}isGlobalCoreDisabled(){try{return typeof process<"u"&&R0.DISABLE_GLOBAL_CORE==="true"}catch{return!0}}};const m1=g1,Uh="wc",Lh=2,Bh="client",rc=`${Uh}@${Lh}:${Bh}:`,Bo={name:Bh,logger:"error"},iu="WALLETCONNECT_DEEPLINK_CHOICE",w1="proposal",ou="Proposal expired",y1="session",$n=H.SEVEN_DAYS,b1="engine",Ge={wc_sessionPropose:{req:{ttl:H.FIVE_MINUTES,prompt:!0,tag:1100},res:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1101},reject:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1120},autoReject:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1121}},wc_sessionSettle:{req:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1102},res:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1103}},wc_sessionUpdate:{req:{ttl:H.ONE_DAY,prompt:!1,tag:1104},res:{ttl:H.ONE_DAY,prompt:!1,tag:1105}},wc_sessionExtend:{req:{ttl:H.ONE_DAY,prompt:!1,tag:1106},res:{ttl:H.ONE_DAY,prompt:!1,tag:1107}},wc_sessionRequest:{req:{ttl:H.FIVE_MINUTES,prompt:!0,tag:1108},res:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1109}},wc_sessionEvent:{req:{ttl:H.FIVE_MINUTES,prompt:!0,tag:1110},res:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1111}},wc_sessionDelete:{req:{ttl:H.ONE_DAY,prompt:!1,tag:1112},res:{ttl:H.ONE_DAY,prompt:!1,tag:1113}},wc_sessionPing:{req:{ttl:H.ONE_DAY,prompt:!1,tag:1114},res:{ttl:H.ONE_DAY,prompt:!1,tag:1115}},wc_sessionAuthenticate:{req:{ttl:H.ONE_HOUR,prompt:!0,tag:1116},res:{ttl:H.ONE_HOUR,prompt:!1,tag:1117},reject:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1118},autoReject:{ttl:H.FIVE_MINUTES,prompt:!1,tag:1119}}},Mo={min:H.FIVE_MINUTES,max:H.SEVEN_DAYS},Qt={idle:"IDLE",active:"ACTIVE"},E1={eth_sendTransaction:{key:""},eth_sendRawTransaction:{key:""},wallet_sendCalls:{key:""},solana_signTransaction:{key:"signature"},solana_signAllTransactions:{key:"transactions"},solana_signAndSendTransaction:{key:"signature"},sui_signAndExecuteTransaction:{key:"digest"},sui_signTransaction:{key:""},hedera_signAndExecuteTransaction:{key:"transactionId"},hedera_executeTransaction:{key:"transactionId"},near_signTransaction:{key:""},near_signTransactions:{key:""},tron_signTransaction:{key:"txID"},xrpl_signTransaction:{key:""},xrpl_signTransactionFor:{key:""},algo_signTxn:{key:""},sendTransfer:{key:"txid"},stacks_stxTransfer:{key:"txId"},polkadot_signTransaction:{key:""},cosmos_signDirect:{key:""}},C1="request",v1=["wc_sessionPropose","wc_sessionRequest","wc_authRequest","wc_sessionAuthenticate"],A1="wc",I1="auth",N1="authKeys",_1="pairingTopics",S1="requests",lo=`${A1}@${1.5}:${I1}:`,Ii=`${lo}:PUB_KEY`;var T1=Object.defineProperty,O1=Object.defineProperties,k1=Object.getOwnPropertyDescriptors,au=Object.getOwnPropertySymbols,D1=Object.prototype.hasOwnProperty,P1=Object.prototype.propertyIsEnumerable,ka=(t,e,s)=>e in t?T1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Ie=(t,e)=>{for(var s in e||(e={}))D1.call(e,s)&&ka(t,s,e[s]);if(au)for(var s of au(e))P1.call(e,s)&&ka(t,s,e[s]);return t},rt=(t,e)=>O1(t,k1(e)),L=(t,e,s)=>ka(t,typeof e!="symbol"?e+"":e,s);class R1 extends gg{constructor(e){super(e),L(this,"name",b1),L(this,"events",new Fa),L(this,"initialized",!1),L(this,"requestQueue",{state:Qt.idle,queue:[]}),L(this,"sessionRequestQueue",{state:Qt.idle,queue:[]}),L(this,"emittedSessionRequests",new Mm({limit:500})),L(this,"requestQueueDelay",H.ONE_SECOND),L(this,"expectedPairingMethodMap",new Map),L(this,"recentlyDeletedMap",new Map),L(this,"recentlyDeletedLimit",200),L(this,"relayMessageCache",[]),L(this,"pendingSessions",new Map),L(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(Ge)}),this.initialized=!0,setTimeout(async()=>{await this.processPendingMessageEvents(),this.sessionRequestQueue.queue=this.getPendingSessionRequests(),this.processSessionRequestQueue()},H.toMiliseconds(this.requestQueueDelay)))}),L(this,"connect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();const n=rt(Ie({},s),{requiredNamespaces:s.requiredNamespaces||{},optionalNamespaces:s.optionalNamespaces||{}});await this.isValidConnect(n),n.optionalNamespaces=Hb(n.requiredNamespaces,n.optionalNamespaces),n.requiredNamespaces={};const{pairingTopic:r,requiredNamespaces:i,optionalNamespaces:o,sessionProperties:a,scopedProperties:c,relays:l}=n;let u=r,d,h=!1;try{if(u){const p=this.client.core.pairing.pairings.get(u);this.client.logger.warn("connect() with existing pairing topic is deprecated and will be removed in the next major release."),h=p.active}}catch(p){throw this.client.logger.error(`connect() -> pairing.get(${u}) failed`),p}if(!u||!h){const{topic:p,uri:E}=await this.client.core.pairing.create({internal:{skipSubscribe:!0}});u=p,d=E}if(!u){const{message:p}=V("NO_MATCHING_KEY",`connect() pairing topic: ${u}`);throw new Error(p)}const m=await this.client.core.crypto.generateKeyPair(),g=Ge.wc_sessionPropose.req.ttl||H.FIVE_MINUTES,b=Be(g),y=rt(Ie(Ie({requiredNamespaces:i,optionalNamespaces:o,relays:l??[{protocol:Ch}],proposer:{publicKey:m,metadata:this.client.metadata},expiryTimestamp:b,pairingTopic:u},a&&{sessionProperties:a}),c&&{scopedProperties:c}),{id:ks()}),_=Ae("session_connect",y.id),{reject:N,resolve:D,done:M}=an(g,ou),q=({id:p})=>{p===y.id&&(this.client.events.off("proposal_expire",q),this.pendingSessions.delete(y.id),this.events.emit(_,{error:{message:ou,code:0}}))};return this.client.events.on("proposal_expire",q),this.events.once(_,({error:p,session:E})=>{this.client.events.off("proposal_expire",q),p?N(p):E&&D(E)}),await this.sendProposeSession({proposal:y,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:y.id}}}),await this.setProposal(y.id,y),{uri:d,approval:M}}),L(this,"pair",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{return await this.client.core.pairing.pair(s)}catch(n){throw this.client.logger.error("pair() failed"),n}}),L(this,"approve",async s=>{var n,r,i;const o=this.client.core.eventClient.createEvent({properties:{topic:(n=s?.id)==null?void 0:n.toString(),trace:[Ms.session_approve_started]}});try{this.isInitialized(),await this.confirmOnlineStateOrThrow()}catch(A){throw o.setError(fr.no_internet_connection),A}try{await this.isValidProposalId(s?.id)}catch(A){throw this.client.logger.error(`approve() -> proposal.get(${s?.id}) failed`),o.setError(fr.proposal_not_found),A}try{await this.isValidApprove(s)}catch(A){throw this.client.logger.error("approve() -> isValidApprove() failed"),o.setError(fr.session_approve_namespace_validation_failure),A}const{id:a,relayProtocol:c,namespaces:l,sessionProperties:u,scopedProperties:d,sessionConfig:h}=s,m=this.client.proposal.get(a);this.client.core.eventClient.deleteEvent({eventId:o.eventId});const{pairingTopic:g,proposer:b,requiredNamespaces:y,optionalNamespaces:_}=m;let N=(r=this.client.core.eventClient)==null?void 0:r.getEvent({topic:g});N||(N=(i=this.client.core.eventClient)==null?void 0:i.createEvent({type:Ms.session_approve_started,properties:{topic:g,trace:[Ms.session_approve_started,Ms.session_namespaces_validation_success]}}));const D=await this.client.core.crypto.generateKeyPair(),M=b.publicKey,q=await this.client.core.crypto.generateSharedKey(D,M),p=Ie(Ie(Ie({relay:{protocol:c??"irn"},namespaces:l,controller:{publicKey:D,metadata:this.client.metadata},expiry:Be($n)},u&&{sessionProperties:u}),d&&{scopedProperties:d}),h&&{sessionConfig:h}),E=Oe.relay;N.addTrace(Ms.subscribing_session_topic);try{await this.client.core.relayer.subscribe(q,{transportType:E,internal:{skipSubscribe:!0}})}catch(A){throw N.setError(fr.subscribe_session_topic_failure),A}N.addTrace(Ms.subscribe_session_topic_success);const C=rt(Ie({},p),{topic:q,requiredNamespaces:y,optionalNamespaces:_,pairingTopic:g,acknowledged:!1,self:p.controller,peer:{publicKey:b.publicKey,metadata:b.metadata},controller:D,transportType:Oe.relay});await this.client.session.set(q,C),N.addTrace(Ms.store_session);try{await this.sendApproveSession({sessionTopic:q,proposal:m,pairingProposalResponse:{relay:{protocol:c??"irn"},responderPublicKey:D},sessionSettleRequest:p,publishOpts:{internal:{throwOnFailedPublish:!0},tvf:{correlationId:a}}}),N.addTrace(Ms.session_approve_publish_success)}catch(A){throw this.client.logger.error(A),this.client.session.delete(q,Pe("USER_DISCONNECTED")),await this.client.core.relayer.unsubscribe(q),A}return this.client.core.eventClient.deleteEvent({eventId:N.eventId}),await this.client.core.pairing.updateMetadata({topic:g,metadata:b.metadata}),await this.deleteProposal(a),await this.client.core.pairing.activate({topic:g}),await this.setExpiry(q,Be($n)),{topic:q,acknowledged:()=>Promise.resolve(this.client.session.get(q))}}),L(this,"reject",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidReject(s)}catch(o){throw this.client.logger.error("reject() -> isValidReject() failed"),o}const{id:n,reason:r}=s;let i;try{i=this.client.proposal.get(n).pairingTopic}catch(o){throw this.client.logger.error(`reject() -> proposal.get(${n}) failed`),o}i&&await this.sendError({id:n,topic:i,error:r,rpcOpts:Ge.wc_sessionPropose.reject}),await this.deleteProposal(n)}),L(this,"update",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidUpdate(s)}catch(d){throw this.client.logger.error("update() -> isValidUpdate() failed"),d}const{topic:n,namespaces:r}=s,{done:i,resolve:o,reject:a}=an(),c=ks(),l=dn().toString(),u=this.client.session.get(n).namespaces;return this.events.once(Ae("session_update",c),({error:d})=>{d?a(d):o()}),await this.client.session.update(n,{namespaces:r}),await this.sendRequest({topic:n,method:"wc_sessionUpdate",params:{namespaces:r},throwOnFailedPublish:!0,clientRpcId:c,relayRpcId:l}).catch(d=>{this.client.logger.error(d),this.client.session.update(n,{namespaces:u}),a(d)}),{acknowledged:i}}),L(this,"extend",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidExtend(s)}catch(c){throw this.client.logger.error("extend() -> isValidExtend() failed"),c}const{topic:n}=s,r=ks(),{done:i,resolve:o,reject:a}=an();return this.events.once(Ae("session_extend",r),({error:c})=>{c?a(c):o()}),await this.setExpiry(n,Be($n)),this.sendRequest({topic:n,method:"wc_sessionExtend",params:{},clientRpcId:r,throwOnFailedPublish:!0}).catch(c=>{a(c)}),{acknowledged:i}}),L(this,"request",async s=>{this.isInitialized();try{await this.isValidRequest(s)}catch(y){throw this.client.logger.error("request() -> isValidRequest() failed"),y}const{chainId:n,request:r,topic:i,expiry:o=Ge.wc_sessionRequest.req.ttl}=s,a=this.client.session.get(i);a?.transportType===Oe.relay&&await this.confirmOnlineStateOrThrow();const c=ks(),l=dn().toString(),{done:u,resolve:d,reject:h}=an(o,"Request expired. Please try again.");this.events.once(Ae("session_request",c),({error:y,result:_})=>{y?h(y):d(_)});const m="wc_sessionRequest",g=this.getAppLinkIfEnabled(a.peer.metadata,a.transportType);if(g)return await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:i,method:m,params:{request:rt(Ie({},r),{expiryTimestamp:Be(o)}),chainId:n},expiry:o,throwOnFailedPublish:!0,appLink:g}).catch(y=>h(y)),this.client.events.emit("session_request_sent",{topic:i,request:r,chainId:n,id:c}),await u();const b={request:rt(Ie({},r),{expiryTimestamp:Be(o)}),chainId:n};return await Promise.all([new Promise(async y=>{await this.sendRequest({clientRpcId:c,relayRpcId:l,topic:i,method:m,params:b,expiry:o,throwOnFailedPublish:!0,tvf:this.getTVFParams(c,b)}).catch(_=>h(_)),this.client.events.emit("session_request_sent",{topic:i,request:r,chainId:n,id:c}),y()}),new Promise(async y=>{var _;if(!((_=a.sessionConfig)!=null&&_.disableDeepLink)){const N=await xm(this.client.core.storage,iu);await Dm({id:c,topic:i,wcDeepLink:N})}y()}),u()]).then(y=>y[2])}),L(this,"respond",async s=>{this.isInitialized(),await this.isValidRespond(s);const{topic:n,response:r}=s,{id:i}=r,o=this.client.session.get(n);o.transportType===Oe.relay&&await this.confirmOnlineStateOrThrow();const a=this.getAppLinkIfEnabled(o.peer.metadata,o.transportType);fs(r)?await this.sendResult({id:i,topic:n,result:r.result,throwOnFailedPublish:!0,appLink:a}):ts(r)&&await this.sendError({id:i,topic:n,error:r.error,appLink:a}),this.cleanupAfterResponse(s)}),L(this,"ping",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow();try{await this.isValidPing(s)}catch(r){throw this.client.logger.error("ping() -> isValidPing() failed"),r}const{topic:n}=s;if(this.client.session.keys.includes(n)){const r=ks(),i=dn().toString(),{done:o,resolve:a,reject:c}=an();this.events.once(Ae("session_ping",r),({error:l})=>{l?c(l):a()}),await Promise.all([this.sendRequest({topic:n,method:"wc_sessionPing",params:{},throwOnFailedPublish:!0,clientRpcId:r,relayRpcId:i}),o()])}else this.client.core.pairing.pairings.keys.includes(n)&&(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:n}))}),L(this,"emit",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidEmit(s);const{topic:n,event:r,chainId:i}=s,o=dn().toString(),a=ks();await this.sendRequest({topic:n,method:"wc_sessionEvent",params:{event:r,chainId:i},throwOnFailedPublish:!0,relayRpcId:o,clientRpcId:a})}),L(this,"disconnect",async s=>{this.isInitialized(),await this.confirmOnlineStateOrThrow(),await this.isValidDisconnect(s);const{topic:n}=s;if(this.client.session.keys.includes(n))await this.sendRequest({topic:n,method:"wc_sessionDelete",params:Pe("USER_DISCONNECTED"),throwOnFailedPublish:!0}),await this.deleteSession({topic:n,emitEvent:!1});else if(this.client.core.pairing.pairings.keys.includes(n))await this.client.core.pairing.disconnect({topic:n});else{const{message:r}=V("MISMATCHED_TOPIC",`Session or pairing topic not found: ${n}`);throw new Error(r)}}),L(this,"find",s=>(this.isInitialized(),this.client.session.getAll().filter(n=>Yb(n,s)))),L(this,"getPendingSessionRequests",()=>this.client.pendingRequest.getAll()),L(this,"authenticate",async(s,n)=>{var r;this.isInitialized(),this.isValidAuthenticate(s);const i=n&&this.client.core.linkModeSupportedApps.includes(n)&&((r=this.client.metadata.redirect)==null?void 0:r.linkMode),o=i?Oe.link_mode:Oe.relay;o===Oe.relay&&await this.confirmOnlineStateOrThrow();const{chains:a,statement:c="",uri:l,domain:u,nonce:d,type:h,exp:m,nbf:g,methods:b=[],expiry:y}=s,_=[...s.resources||[]],{topic:N,uri:D}=await this.client.core.pairing.create({methods:["wc_sessionAuthenticate"],transportType:o});this.client.logger.info({message:"Generated new pairing",pairing:{topic:N,uri:D}});const M=await this.client.core.crypto.generateKeyPair(),q=vi(M);if(await Promise.all([this.client.auth.authKeys.set(Ii,{responseTopic:q,publicKey:M}),this.client.auth.pairingTopics.set(q,{topic:q,pairingTopic:N})]),await this.client.core.relayer.subscribe(q,{transportType:o}),this.client.logger.info(`sending request to new pairing topic: ${N}`),b.length>0){const{namespace:k}=Is(a[0]);let T=Jw(k,"request",b);Ci(_)&&(T=Zw(T,_.pop())),_.push(T)}const p=y&&y>Ge.wc_sessionAuthenticate.req.ttl?y:Ge.wc_sessionAuthenticate.req.ttl,E={authPayload:{type:h??"caip122",chains:a,statement:c,aud:l,domain:u,version:"1",nonce:d,iat:new Date().toISOString(),exp:m,nbf:g,resources:_},requester:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:Be(p)},C={eip155:{chains:a,methods:[...new Set(["personal_sign",...b])],events:["chainChanged","accountsChanged"]}},A={requiredNamespaces:{},optionalNamespaces:C,relays:[{protocol:"irn"}],pairingTopic:N,proposer:{publicKey:M,metadata:this.client.metadata},expiryTimestamp:Be(Ge.wc_sessionPropose.req.ttl),id:ks()},{done:S,resolve:$,reject:O}=an(p,"Request expired"),v=ks(),w=Ae("session_connect",A.id),I=Ae("session_request",v),P=async({error:k,session:T})=>{this.events.off(I,U),k?O(k):T&&$({session:T})},U=async k=>{var T,W,z;if(await this.deletePendingAuthRequest(v,{message:"fulfilled",code:0}),k.error){const de=Pe("WC_METHOD_UNSUPPORTED","wc_sessionAuthenticate");return k.error.code===de.code?void 0:(this.events.off(w,P),O(k.error.message))}await this.deleteProposal(A.id),this.events.off(w,P);const{cacaos:ie,responder:oe}=k.result,se=[],X=[];for(const de of ie){await tl({cacao:de,projectId:this.client.core.projectId})||(this.client.logger.error(de,"Signature verification failed"),O(Pe("SESSION_SETTLEMENT_FAILED","Signature verification failed")));const{p:$e}=de,Ft=Ci($e.resources),Os=[aa($e.iss)],Qs=Bi($e.iss);if(Ft){const On=sl(Ft),up=nl(Ft);se.push(...On),Os.push(...up)}for(const On of Os)X.push(`${On}:${Qs}`)}const ue=await this.client.core.crypto.generateSharedKey(M,oe.publicKey);let Te;se.length>0&&(Te={topic:ue,acknowledged:!0,self:{publicKey:M,metadata:this.client.metadata},peer:oe,controller:oe.publicKey,expiry:Be($n),requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:N,namespaces:Ol([...new Set(se)],[...new Set(X)]),transportType:o},await this.client.core.relayer.subscribe(ue,{transportType:o}),await this.client.session.set(ue,Te),N&&await this.client.core.pairing.updateMetadata({topic:N,metadata:oe.metadata}),Te=this.client.session.get(ue)),(T=this.client.metadata.redirect)!=null&&T.linkMode&&(W=oe.metadata.redirect)!=null&&W.linkMode&&(z=oe.metadata.redirect)!=null&&z.universal&&n&&(this.client.core.addLinkModeSupportedApp(oe.metadata.redirect.universal),this.client.session.update(ue,{transportType:Oe.link_mode})),$({auths:ie,session:Te})};this.events.once(w,P),this.events.once(I,U);let j;try{if(i){const k=ss("wc_sessionAuthenticate",E,v);this.client.core.history.set(N,k);const T=await this.client.core.crypto.encode("",k,{type:ei,encoding:Vs});j=pi(n,N,T)}else await Promise.all([this.sendRequest({topic:N,method:"wc_sessionAuthenticate",params:E,expiry:s.expiry,throwOnFailedPublish:!0,clientRpcId:v}),this.sendRequest({topic:N,method:"wc_sessionPropose",params:A,expiry:Ge.wc_sessionPropose.req.ttl,throwOnFailedPublish:!0,clientRpcId:A.id})])}catch(k){throw this.events.off(w,P),this.events.off(I,U),k}return await this.setProposal(A.id,A),await this.setAuthRequest(v,{request:rt(Ie({},E),{verifyContext:{}}),pairingTopic:N,transportType:o}),{uri:j??D,response:S}}),L(this,"approveSessionAuthenticate",async s=>{const{id:n,auths:r}=s,i=this.client.core.eventClient.createEvent({properties:{topic:n.toString(),trace:[sn.authenticated_session_approve_started]}});try{this.isInitialized()}catch(y){throw i.setError(gr.no_internet_connection),y}const o=this.getPendingAuthRequest(n);if(!o)throw i.setError(gr.authenticated_session_pending_request_not_found),new Error(`Could not find pending auth request with id ${n}`);const a=o.transportType||Oe.relay;a===Oe.relay&&await this.confirmOnlineStateOrThrow();const c=o.requester.publicKey,l=await this.client.core.crypto.generateKeyPair(),u=vi(c),d={type:Ns,receiverPublicKey:c,senderPublicKey:l},h=[],m=[];for(const y of r){if(!await tl({cacao:y,projectId:this.client.core.projectId})){i.setError(gr.invalid_cacao);const q=Pe("SESSION_SETTLEMENT_FAILED","Signature verification failed");throw await this.sendError({id:n,topic:u,error:q,encodeOpts:d}),new Error(q.message)}i.addTrace(sn.cacaos_verified);const{p:_}=y,N=Ci(_.resources),D=[aa(_.iss)],M=Bi(_.iss);if(N){const q=sl(N),p=nl(N);h.push(...q),D.push(...p)}for(const q of D)m.push(`${q}:${M}`)}const g=await this.client.core.crypto.generateSharedKey(l,c);i.addTrace(sn.create_authenticated_session_topic);let b;if(h?.length>0){b={topic:g,acknowledged:!0,self:{publicKey:l,metadata:this.client.metadata},peer:{publicKey:c,metadata:o.requester.metadata},controller:c,expiry:Be($n),authentication:r,requiredNamespaces:{},optionalNamespaces:{},relay:{protocol:"irn"},pairingTopic:o.pairingTopic,namespaces:Ol([...new Set(h)],[...new Set(m)]),transportType:a},i.addTrace(sn.subscribing_authenticated_session_topic);try{await this.client.core.relayer.subscribe(g,{transportType:a})}catch(y){throw i.setError(gr.subscribe_authenticated_session_topic_failure),y}i.addTrace(sn.subscribe_authenticated_session_topic_success),await this.client.session.set(g,b),i.addTrace(sn.store_authenticated_session),await this.client.core.pairing.updateMetadata({topic:o.pairingTopic,metadata:o.requester.metadata})}i.addTrace(sn.publishing_authenticated_session_approve);try{await this.sendResult({topic:u,id:n,result:{cacaos:r,responder:{publicKey:l,metadata:this.client.metadata}},encodeOpts:d,throwOnFailedPublish:!0,appLink:this.getAppLinkIfEnabled(o.requester.metadata,a)})}catch(y){throw i.setError(gr.authenticated_session_approve_publish_failure),y}return await this.client.auth.requests.delete(n,{message:"fulfilled",code:0}),await this.client.core.pairing.activate({topic:o.pairingTopic}),this.client.core.eventClient.deleteEvent({eventId:i.eventId}),{session:b}}),L(this,"rejectSessionAuthenticate",async s=>{this.isInitialized();const{id:n,reason:r}=s,i=this.getPendingAuthRequest(n);if(!i)throw new Error(`Could not find pending auth request with id ${n}`);i.transportType===Oe.relay&&await this.confirmOnlineStateOrThrow();const o=i.requester.publicKey,a=await this.client.core.crypto.generateKeyPair(),c=vi(o),l={type:Ns,receiverPublicKey:o,senderPublicKey:a};await this.sendError({id:n,topic:c,error:r,encodeOpts:l,rpcOpts:Ge.wc_sessionAuthenticate.reject,appLink:this.getAppLinkIfEnabled(i.requester.metadata,i.transportType)}),await this.client.auth.requests.delete(n,{message:"rejected",code:0}),await this.deleteProposal(n)}),L(this,"formatAuthMessage",s=>{this.isInitialized();const{request:n,iss:r}=s;return $d(n,r)}),L(this,"processRelayMessageCache",()=>{setTimeout(async()=>{if(this.relayMessageCache.length!==0)for(;this.relayMessageCache.length>0;)try{const s=this.relayMessageCache.shift();s&&await this.onRelayMessage(s)}catch(s){this.client.logger.error(s)}},50)}),L(this,"cleanupDuplicatePairings",async s=>{if(s.pairingTopic)try{const n=this.client.core.pairing.pairings.get(s.pairingTopic),r=this.client.core.pairing.pairings.getAll().filter(i=>{var o,a;return((o=i.peerMetadata)==null?void 0:o.url)&&((a=i.peerMetadata)==null?void 0:a.url)===s.peer.metadata.url&&i.topic&&i.topic!==n.topic});if(r.length===0)return;this.client.logger.info(`Cleaning up ${r.length} duplicate pairing(s)`),await Promise.all(r.map(i=>this.client.core.pairing.disconnect({topic:i.topic}))),this.client.logger.info("Duplicate pairings clean up finished")}catch(n){this.client.logger.error(n)}}),L(this,"deleteSession",async s=>{var n;const{topic:r,expirerHasDeleted:i=!1,emitEvent:o=!0,id:a=0}=s,{self:c}=this.client.session.get(r);await this.client.core.relayer.unsubscribe(r),await this.client.session.delete(r,Pe("USER_DISCONNECTED")),this.addToRecentlyDeleted(r,"session"),this.client.core.crypto.keychain.has(c.publicKey)&&await this.client.core.crypto.deleteKeyPair(c.publicKey),this.client.core.crypto.keychain.has(r)&&await this.client.core.crypto.deleteSymKey(r),i||this.client.core.expirer.del(r),this.client.core.storage.removeItem(iu).catch(l=>this.client.logger.warn(l)),this.getPendingSessionRequests().forEach(l=>{l.topic===r&&this.deletePendingSessionRequest(l.id,Pe("USER_DISCONNECTED"))}),r===((n=this.sessionRequestQueue.queue[0])==null?void 0:n.topic)&&(this.sessionRequestQueue.state=Qt.idle),o&&this.client.events.emit("session_delete",{id:a,topic:r})}),L(this,"deleteProposal",async(s,n)=>{if(n)try{const r=this.client.proposal.get(s);this.client.core.eventClient.getEvent({topic:r.pairingTopic})?.setError(fr.proposal_expired)}catch{}await Promise.all([this.client.proposal.delete(s,Pe("USER_DISCONNECTED")),n?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"proposal")}),L(this,"deletePendingSessionRequest",async(s,n,r=!1)=>{await Promise.all([this.client.pendingRequest.delete(s,n),r?Promise.resolve():this.client.core.expirer.del(s)]),this.addToRecentlyDeleted(s,"request"),this.sessionRequestQueue.queue=this.sessionRequestQueue.queue.filter(i=>i.id!==s),r&&(this.sessionRequestQueue.state=Qt.idle,this.client.events.emit("session_request_expire",{id:s}))}),L(this,"deletePendingAuthRequest",async(s,n,r=!1)=>{await Promise.all([this.client.auth.requests.delete(s,n),r?Promise.resolve():this.client.core.expirer.del(s)])}),L(this,"setExpiry",async(s,n)=>{this.client.session.keys.includes(s)&&(this.client.core.expirer.set(s,n),await this.client.session.update(s,{expiry:n}))}),L(this,"setProposal",async(s,n)=>{this.client.core.expirer.set(s,Be(Ge.wc_sessionPropose.req.ttl)),await this.client.proposal.set(s,n)}),L(this,"setAuthRequest",async(s,n)=>{const{request:r,pairingTopic:i,transportType:o=Oe.relay}=n;this.client.core.expirer.set(s,r.expiryTimestamp),await this.client.auth.requests.set(s,{authPayload:r.authPayload,requester:r.requester,expiryTimestamp:r.expiryTimestamp,id:s,pairingTopic:i,verifyContext:r.verifyContext,transportType:o})}),L(this,"setPendingSessionRequest",async s=>{const{id:n,topic:r,params:i,verifyContext:o}=s,a=i.request.expiryTimestamp||Be(Ge.wc_sessionRequest.req.ttl);this.client.core.expirer.set(n,a),await this.client.pendingRequest.set(n,{id:n,topic:r,params:i,verifyContext:o})}),L(this,"sendRequest",async s=>{const{topic:n,method:r,params:i,expiry:o,relayRpcId:a,clientRpcId:c,throwOnFailedPublish:l,appLink:u,tvf:d,publishOpts:h={}}=s,m=ss(r,i,c);let g;const b=!!u;try{const N=b?Vs:wt;g=await this.client.core.crypto.encode(n,m,{encoding:N})}catch(N){throw await this.cleanup(),this.client.logger.error(`sendRequest() -> core.crypto.encode() for topic ${n} failed`),N}let y;if(v1.includes(r)){const N=$t(JSON.stringify(m)),D=$t(g);y=await this.client.core.verify.register({id:D,decryptedId:N})}const _=Ie(Ie({},Ge[r].req),h);if(_.attestation=y,o&&(_.ttl=o),a&&(_.id=a),this.client.core.history.set(n,m),b){const N=pi(u,n,g);await global.Linking.openURL(N,this.client.name)}else _.tvf=rt(Ie({},d),{correlationId:m.id}),l?(_.internal=rt(Ie({},_.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(n,g,_)):this.client.core.relayer.publish(n,g,_).catch(N=>this.client.logger.error(N));return m.id}),L(this,"sendProposeSession",async s=>{const{proposal:n,publishOpts:r}=s,i=ss("wc_sessionPropose",n,n.id);this.client.core.history.set(n.pairingTopic,i);const o=await this.client.core.crypto.encode(n.pairingTopic,i,{encoding:wt}),a=$t(JSON.stringify(i)),c=$t(o),l=await this.client.core.verify.register({id:c,decryptedId:a});await this.client.core.relayer.publishCustom({payload:{pairingTopic:n.pairingTopic,sessionProposal:o},opts:rt(Ie({},r),{publishMethod:"wc_proposeSession",attestation:l})})}),L(this,"sendApproveSession",async s=>{const{sessionTopic:n,pairingProposalResponse:r,proposal:i,sessionSettleRequest:o,publishOpts:a}=s,c=xr(i.id,r),l=await this.client.core.crypto.encode(i.pairingTopic,c,{encoding:wt}),u=ss("wc_sessionSettle",o,a?.id),d=await this.client.core.crypto.encode(n,u,{encoding:wt});this.client.core.history.set(n,u),await this.client.core.relayer.publishCustom({payload:{sessionTopic:n,pairingTopic:i.pairingTopic,sessionProposalResponse:l,sessionSettlementRequest:d},opts:rt(Ie({},a),{publishMethod:"wc_approveSession"})})}),L(this,"sendResult",async s=>{const{id:n,topic:r,result:i,throwOnFailedPublish:o,encodeOpts:a,appLink:c}=s,l=xr(n,i);let u;const d=c&&typeof(global==null?void 0:global.Linking)<"u";try{const g=d?Vs:wt;u=await this.client.core.crypto.encode(r,l,rt(Ie({},a||{}),{encoding:g}))}catch(g){throw await this.cleanup(),this.client.logger.error(`sendResult() -> core.crypto.encode() for topic ${r} failed`),g}let h,m;try{h=await this.client.core.history.get(r,n);const g=h.request;try{m=this.getTVFParams(n,g.params,i)}catch(b){this.client.logger.warn(`sendResult() -> getTVFParams() failed: ${b?.message}`)}}catch(g){throw this.client.logger.error(`sendResult() -> history.get(${r}, ${n}) failed`),g}if(d){const g=pi(c,r,u);await global.Linking.openURL(g,this.client.name)}else{const g=h.request.method,b=Ge[g].res;b.tvf=rt(Ie({},m),{correlationId:n}),o?(b.internal=rt(Ie({},b.internal),{throwOnFailedPublish:!0}),await this.client.core.relayer.publish(r,u,b)):this.client.core.relayer.publish(r,u,b).catch(y=>this.client.logger.error(y))}await this.client.core.history.resolve(l)}),L(this,"sendError",async s=>{const{id:n,topic:r,error:i,encodeOpts:o,rpcOpts:a,appLink:c}=s,l=Ku(n,i);let u;const d=c&&typeof(global==null?void 0:global.Linking)<"u";try{const m=d?Vs:wt;u=await this.client.core.crypto.encode(r,l,rt(Ie({},o||{}),{encoding:m}))}catch(m){throw await this.cleanup(),this.client.logger.error(`sendError() -> core.crypto.encode() for topic ${r} failed`),m}let h;try{h=await this.client.core.history.get(r,n)}catch(m){throw this.client.logger.error(`sendError() -> history.get(${r}, ${n}) failed`),m}if(d){const m=pi(c,r,u);await global.Linking.openURL(m,this.client.name)}else{const m=h.request.method,g=a||Ge[m].res;this.client.core.relayer.publish(r,u,g)}await this.client.core.history.resolve(l)}),L(this,"cleanup",async()=>{const s=[],n=[];this.client.session.getAll().forEach(r=>{let i=!1;rs(r.expiry)&&(i=!0),this.client.core.crypto.keychain.has(r.topic)||(i=!0),i&&s.push(r.topic)}),this.client.proposal.getAll().forEach(r=>{rs(r.expiryTimestamp)&&n.push(r.id)}),await Promise.all([...s.map(r=>this.deleteSession({topic:r})),...n.map(r=>this.deleteProposal(r))])}),L(this,"onProviderMessageEvent",async s=>{!this.initialized||this.relayMessageCache.length>0?this.relayMessageCache.push(s):await this.onRelayMessage(s)}),L(this,"onRelayEventRequest",async s=>{this.requestQueue.queue.push(s),await this.processRequestsQueue()}),L(this,"processRequestsQueue",async()=>{if(this.requestQueue.state===Qt.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=Qt.active;const s=this.requestQueue.queue.shift();if(s)try{await this.processRequest(s)}catch(n){this.client.logger.warn(n)}}this.requestQueue.state=Qt.idle}),L(this,"processRequest",async s=>{const{topic:n,payload:r,attestation:i,transportType:o,encryptedId:a}=s,c=r.method;if(!this.shouldIgnorePairingRequest({topic:n,requestMethod:c}))switch(c){case"wc_sessionPropose":return await this.onSessionProposeRequest({topic:n,payload:r,attestation:i,encryptedId:a});case"wc_sessionSettle":return await this.onSessionSettleRequest(n,r);case"wc_sessionUpdate":return await this.onSessionUpdateRequest(n,r);case"wc_sessionExtend":return await this.onSessionExtendRequest(n,r);case"wc_sessionPing":return await this.onSessionPingRequest(n,r);case"wc_sessionDelete":return await this.onSessionDeleteRequest(n,r);case"wc_sessionRequest":return await this.onSessionRequest({topic:n,payload:r,attestation:i,encryptedId:a,transportType:o});case"wc_sessionEvent":return await this.onSessionEventRequest(n,r);case"wc_sessionAuthenticate":return await this.onSessionAuthenticateRequest({topic:n,payload:r,attestation:i,encryptedId:a,transportType:o});default:return this.client.logger.info(`Unsupported request method ${c}`)}}),L(this,"onRelayEventResponse",async s=>{const{topic:n,payload:r,transportType:i}=s,o=(await this.client.core.history.get(n,r.id)).request.method;switch(o){case"wc_sessionPropose":return this.onSessionProposeResponse(n,r,i);case"wc_sessionSettle":return this.onSessionSettleResponse(n,r);case"wc_sessionUpdate":return this.onSessionUpdateResponse(n,r);case"wc_sessionExtend":return this.onSessionExtendResponse(n,r);case"wc_sessionPing":return this.onSessionPingResponse(n,r);case"wc_sessionRequest":return this.onSessionRequestResponse(n,r);case"wc_sessionAuthenticate":return this.onSessionAuthenticateResponse(n,r);default:return this.client.logger.info(`Unsupported response method ${o}`)}}),L(this,"onRelayEventUnknownPayload",s=>{const{topic:n}=s,{message:r}=V("MISSING_OR_INVALID",`Decoded payload on topic ${n} is not identifiable as a JSON-RPC request or a response.`);throw new Error(r)}),L(this,"shouldIgnorePairingRequest",s=>{const{topic:n,requestMethod:r}=s,i=this.expectedPairingMethodMap.get(n);return!i||i.includes(r)?!1:!!(i.includes("wc_sessionAuthenticate")&&this.client.events.listenerCount("session_authenticate")>0)}),L(this,"onSessionProposeRequest",async s=>{const{topic:n,payload:r,attestation:i,encryptedId:o}=s,{params:a,id:c}=r;try{const l=this.client.core.eventClient.getEvent({topic:n});this.client.events.listenerCount("session_proposal")===0&&(console.warn("No listener for session_proposal event"),l?.setError(ms.proposal_listener_not_found)),this.isValidConnect(Ie({},r.params));const u=a.expiryTimestamp||Be(Ge.wc_sessionPropose.req.ttl),d=Ie({id:c,pairingTopic:n,expiryTimestamp:u,attestation:i,encryptedId:o},a);await this.setProposal(c,d);const h=await this.getVerifyContext({attestationId:i,hash:$t(JSON.stringify(r)),encryptedId:o,metadata:d.proposer.metadata});l?.addTrace(es.emit_session_proposal),this.client.events.emit("session_proposal",{id:c,params:d,verifyContext:h})}catch(l){await this.sendError({id:c,topic:n,error:l,rpcOpts:Ge.wc_sessionPropose.autoReject}),this.client.logger.error(l)}}),L(this,"onSessionProposeResponse",async(s,n,r)=>{const{id:i}=n;if(fs(n)){const{result:o}=n;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",result:o});const a=this.client.proposal.get(i);this.client.logger.trace({type:"method",method:"onSessionProposeResponse",proposal:a});const c=a.proposer.publicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",selfPublicKey:c});const l=o.responderPublicKey;this.client.logger.trace({type:"method",method:"onSessionProposeResponse",peerPublicKey:l});const u=await this.client.core.crypto.generateSharedKey(c,l);this.pendingSessions.set(i,{sessionTopic:u,pairingTopic:s,proposalId:i,publicKey:c});const d=await this.client.core.relayer.subscribe(u,{transportType:r});this.client.logger.trace({type:"method",method:"onSessionProposeResponse",subscriptionId:d}),await this.client.core.pairing.activate({topic:s})}else if(ts(n)){await this.deleteProposal(i);const o=Ae("session_connect",i);if(this.events.listenerCount(o)===0)throw new Error(`emitting ${o} without any listeners, 954`);this.events.emit(o,{error:n.error})}}),L(this,"onSessionSettleRequest",async(s,n)=>{const{id:r,params:i}=n;try{this.isValidSessionSettleRequest(i);const{relay:o,controller:a,expiry:c,namespaces:l,sessionProperties:u,scopedProperties:d,sessionConfig:h}=n.params,m=[...this.pendingSessions.values()].find(y=>y.sessionTopic===s);if(!m)return this.client.logger.error(`Pending session not found for topic ${s}`);const g=this.client.proposal.get(m.proposalId),b=rt(Ie(Ie(Ie({topic:s,relay:o,expiry:c,namespaces:l,acknowledged:!0,pairingTopic:m.pairingTopic,requiredNamespaces:g.requiredNamespaces,optionalNamespaces:g.optionalNamespaces,controller:a.publicKey,self:{publicKey:m.publicKey,metadata:this.client.metadata},peer:{publicKey:a.publicKey,metadata:a.metadata}},u&&{sessionProperties:u}),d&&{scopedProperties:d}),h&&{sessionConfig:h}),{transportType:Oe.relay});await this.client.session.set(b.topic,b),await this.setExpiry(b.topic,b.expiry),await this.client.core.pairing.updateMetadata({topic:m.pairingTopic,metadata:b.peer.metadata}),this.client.events.emit("session_connect",{session:b}),this.events.emit(Ae("session_connect",m.proposalId),{session:b}),this.pendingSessions.delete(m.proposalId),this.deleteProposal(m.proposalId,!1),this.cleanupDuplicatePairings(b),await this.sendResult({id:n.id,topic:s,result:!0})}catch(o){await this.sendError({id:r,topic:s,error:o}),this.client.logger.error(o)}}),L(this,"onSessionSettleResponse",async(s,n)=>{const{id:r}=n;fs(n)?(await this.client.session.update(s,{acknowledged:!0}),this.events.emit(Ae("session_approve",r),{})):ts(n)&&(await this.client.session.delete(s,Pe("USER_DISCONNECTED")),this.events.emit(Ae("session_approve",r),{error:n.error}))}),L(this,"onSessionUpdateRequest",async(s,n)=>{const{params:r,id:i}=n;try{const o=`${s}_session_update`,a=hr.get(o);if(a&&this.isRequestOutOfSync(a,i)){this.client.logger.warn(`Discarding out of sync request - ${i}`),this.sendError({id:i,topic:s,error:Pe("INVALID_UPDATE_REQUEST")});return}this.isValidUpdate(Ie({topic:s},r));try{hr.set(o,i),await this.client.session.update(s,{namespaces:r.namespaces}),await this.sendResult({id:i,topic:s,result:!0})}catch(c){throw hr.delete(o),c}this.client.events.emit("session_update",{id:i,topic:s,params:r})}catch(o){await this.sendError({id:i,topic:s,error:o}),this.client.logger.error(o)}}),L(this,"isRequestOutOfSync",(s,n)=>n.toString().slice(0,-3)<s.toString().slice(0,-3)),L(this,"onSessionUpdateResponse",(s,n)=>{const{id:r}=n,i=Ae("session_update",r);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);fs(n)?this.events.emit(Ae("session_update",r),{}):ts(n)&&this.events.emit(Ae("session_update",r),{error:n.error})}),L(this,"onSessionExtendRequest",async(s,n)=>{const{id:r}=n;try{this.isValidExtend({topic:s}),await this.setExpiry(s,Be($n)),await this.sendResult({id:r,topic:s,result:!0}),this.client.events.emit("session_extend",{id:r,topic:s})}catch(i){await this.sendError({id:r,topic:s,error:i}),this.client.logger.error(i)}}),L(this,"onSessionExtendResponse",(s,n)=>{const{id:r}=n,i=Ae("session_extend",r);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);fs(n)?this.events.emit(Ae("session_extend",r),{}):ts(n)&&this.events.emit(Ae("session_extend",r),{error:n.error})}),L(this,"onSessionPingRequest",async(s,n)=>{const{id:r}=n;try{this.isValidPing({topic:s}),await this.sendResult({id:r,topic:s,result:!0,throwOnFailedPublish:!0}),this.client.events.emit("session_ping",{id:r,topic:s})}catch(i){await this.sendError({id:r,topic:s,error:i}),this.client.logger.error(i)}}),L(this,"onSessionPingResponse",(s,n)=>{const{id:r}=n,i=Ae("session_ping",r);setTimeout(()=>{if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners 2176`);fs(n)?this.events.emit(Ae("session_ping",r),{}):ts(n)&&this.events.emit(Ae("session_ping",r),{error:n.error})},500)}),L(this,"onSessionDeleteRequest",async(s,n)=>{const{id:r}=n;try{this.isValidDisconnect({topic:s,reason:n.params}),await Promise.all([new Promise(i=>{this.client.core.relayer.once(Ue.publish,async()=>{i(await this.deleteSession({topic:s,id:r}))})}),this.sendResult({id:r,topic:s,result:!0}),this.cleanupPendingSentRequestsForTopic({topic:s,error:Pe("USER_DISCONNECTED")})]).catch(i=>this.client.logger.error(i))}catch(i){this.client.logger.error(i)}}),L(this,"onSessionRequest",async s=>{var n,r,i;const{topic:o,payload:a,attestation:c,encryptedId:l,transportType:u}=s,{id:d,params:h}=a;try{await this.isValidRequest(Ie({topic:o},h));const m=this.client.session.get(o),g=await this.getVerifyContext({attestationId:c,hash:$t(JSON.stringify(ss("wc_sessionRequest",h,d))),encryptedId:l,metadata:m.peer.metadata,transportType:u}),b={id:d,topic:o,params:h,verifyContext:g};await this.setPendingSessionRequest(b),u===Oe.link_mode&&(n=m.peer.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp((r=m.peer.metadata.redirect)==null?void 0:r.universal),(i=this.client.signConfig)!=null&&i.disableRequestQueue?this.emitSessionRequest(b):(this.addSessionRequestToSessionRequestQueue(b),this.processSessionRequestQueue())}catch(m){await this.sendError({id:d,topic:o,error:m}),this.client.logger.error(m)}}),L(this,"onSessionRequestResponse",(s,n)=>{const{id:r}=n,i=Ae("session_request",r);if(this.events.listenerCount(i)===0)throw new Error(`emitting ${i} without any listeners`);fs(n)?this.events.emit(Ae("session_request",r),{result:n.result}):ts(n)&&this.events.emit(Ae("session_request",r),{error:n.error})}),L(this,"onSessionEventRequest",async(s,n)=>{const{id:r,params:i}=n;try{const o=`${s}_session_event_${i.event.name}`,a=hr.get(o);if(a&&this.isRequestOutOfSync(a,r)){this.client.logger.info(`Discarding out of sync request - ${r}`);return}this.isValidEmit(Ie({topic:s},i)),this.client.events.emit("session_event",{id:r,topic:s,params:i}),hr.set(o,r)}catch(o){await this.sendError({id:r,topic:s,error:o}),this.client.logger.error(o)}}),L(this,"onSessionAuthenticateResponse",(s,n)=>{const{id:r}=n;this.client.logger.trace({type:"method",method:"onSessionAuthenticateResponse",topic:s,payload:n}),fs(n)?this.events.emit(Ae("session_request",r),{result:n.result}):ts(n)&&this.events.emit(Ae("session_request",r),{error:n.error})}),L(this,"onSessionAuthenticateRequest",async s=>{var n;const{topic:r,payload:i,attestation:o,encryptedId:a,transportType:c}=s;try{const{requester:l,authPayload:u,expiryTimestamp:d}=i.params,h=await this.getVerifyContext({attestationId:o,hash:$t(JSON.stringify(i)),encryptedId:a,metadata:l.metadata,transportType:c}),m={requester:l,pairingTopic:r,id:i.id,authPayload:u,verifyContext:h,expiryTimestamp:d};await this.setAuthRequest(i.id,{request:m,pairingTopic:r,transportType:c}),c===Oe.link_mode&&(n=l.metadata.redirect)!=null&&n.universal&&this.client.core.addLinkModeSupportedApp(l.metadata.redirect.universal),this.client.events.emit("session_authenticate",{topic:r,params:i.params,id:i.id,verifyContext:h})}catch(l){this.client.logger.error(l);const u=i.params.requester.publicKey,d=await this.client.core.crypto.generateKeyPair(),h=this.getAppLinkIfEnabled(i.params.requester.metadata,c),m={type:Ns,receiverPublicKey:u,senderPublicKey:d};await this.sendError({id:i.id,topic:r,error:l,encodeOpts:m,rpcOpts:Ge.wc_sessionAuthenticate.autoReject,appLink:h})}}),L(this,"addSessionRequestToSessionRequestQueue",s=>{this.sessionRequestQueue.queue.push(s)}),L(this,"cleanupAfterResponse",s=>{this.deletePendingSessionRequest(s.response.id,{message:"fulfilled",code:0}),setTimeout(()=>{this.sessionRequestQueue.state=Qt.idle,this.processSessionRequestQueue()},H.toMiliseconds(this.requestQueueDelay))}),L(this,"cleanupPendingSentRequestsForTopic",({topic:s,error:n})=>{const r=this.client.core.history.pending;r.length>0&&r.filter(i=>i.topic===s&&i.request.method==="wc_sessionRequest").forEach(i=>{const o=i.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",i.request.id),{error:n})})}),L(this,"processSessionRequestQueue",()=>{if(this.sessionRequestQueue.state===Qt.active){this.client.logger.info("session request queue is already active.");return}const s=this.sessionRequestQueue.queue[0];if(!s){this.client.logger.info("session request queue is empty.");return}try{this.emitSessionRequest(s)}catch(n){this.client.logger.error(n)}}),L(this,"emitSessionRequest",s=>{if(this.emittedSessionRequests.has(s.id)){this.client.logger.warn({id:s.id},`Skipping emitting \`session_request\` event for duplicate request. id: ${s.id}`);return}this.sessionRequestQueue.state=Qt.active,this.emittedSessionRequests.add(s.id),this.client.events.emit("session_request",s)}),L(this,"onPairingCreated",s=>{if(s.methods&&this.expectedPairingMethodMap.set(s.topic,s.methods),s.active)return;const n=this.client.proposal.getAll().find(r=>r.pairingTopic===s.topic);n&&this.onSessionProposeRequest({topic:s.topic,payload:ss("wc_sessionPropose",rt(Ie({},n),{requiredNamespaces:n.requiredNamespaces,optionalNamespaces:n.optionalNamespaces,relays:n.relays,proposer:n.proposer,sessionProperties:n.sessionProperties,scopedProperties:n.scopedProperties}),n.id),attestation:n.attestation,encryptedId:n.encryptedId})}),L(this,"isValidConnect",async s=>{if(!gt(s)){const{message:l}=V("MISSING_OR_INVALID",`connect() params: ${JSON.stringify(s)}`);throw new Error(l)}const{pairingTopic:n,requiredNamespaces:r,optionalNamespaces:i,sessionProperties:o,scopedProperties:a,relays:c}=s;if(qe(n)||await this.isValidPairingTopic(n),!a0(c)){const{message:l}=V("MISSING_OR_INVALID",`connect() relays: ${c}`);throw new Error(l)}if(!qe(r)&&us(r)!==0){const l="requiredNamespaces are deprecated and are automatically assigned to optionalNamespaces";["fatal","error","silent"].includes(this.client.logger.level)?console.warn(l):this.client.logger.warn(l),this.validateNamespaces(r,"requiredNamespaces")}if(!qe(i)&&us(i)!==0&&this.validateNamespaces(i,"optionalNamespaces"),qe(o)||this.validateSessionProps(o,"sessionProperties"),!qe(a)){this.validateSessionProps(a,"scopedProperties");const l=Object.keys(r||{}).concat(Object.keys(i||{}));if(!Object.keys(a).every(u=>l.includes(u.split(":")[0])))throw new Error(`Scoped properties must be a subset of required/optional namespaces, received: ${JSON.stringify(a)}, required/optional namespaces: ${JSON.stringify(l)}`)}}),L(this,"validateNamespaces",(s,n)=>{const r=o0(s,"connect()",n);if(r)throw new Error(r.message)}),L(this,"isValidApprove",async s=>{if(!gt(s))throw new Error(V("MISSING_OR_INVALID",`approve() params: ${s}`).message);const{id:n,namespaces:r,relayProtocol:i,sessionProperties:o,scopedProperties:a}=s;this.checkRecentlyDeleted(n),await this.isValidProposalId(n);const c=this.client.proposal.get(n),l=Ro(r,"approve()");if(l)throw new Error(l.message);const u=Pl(c.requiredNamespaces,r,"approve()");if(u)throw new Error(u.message);if(!Me(i,!0)){const{message:d}=V("MISSING_OR_INVALID",`approve() relayProtocol: ${i}`);throw new Error(d)}if(qe(o)||this.validateSessionProps(o,"sessionProperties"),!qe(a)){this.validateSessionProps(a,"scopedProperties");const d=new Set(Object.keys(r));if(!Object.keys(a).every(h=>d.has(h.split(":")[0])))throw new Error(`Scoped properties must be a subset of approved namespaces, received: ${JSON.stringify(a)}, approved namespaces: ${Array.from(d).join(", ")}`)}}),L(this,"isValidReject",async s=>{if(!gt(s)){const{message:i}=V("MISSING_OR_INVALID",`reject() params: ${s}`);throw new Error(i)}const{id:n,reason:r}=s;if(this.checkRecentlyDeleted(n),await this.isValidProposalId(n),!l0(r)){const{message:i}=V("MISSING_OR_INVALID",`reject() reason: ${JSON.stringify(r)}`);throw new Error(i)}}),L(this,"isValidSessionSettleRequest",s=>{if(!gt(s)){const{message:l}=V("MISSING_OR_INVALID",`onSessionSettleRequest() params: ${s}`);throw new Error(l)}const{relay:n,controller:r,namespaces:i,expiry:o}=s;if(!yh(n)){const{message:l}=V("MISSING_OR_INVALID","onSessionSettleRequest() relay protocol should be a string");throw new Error(l)}const a=e0(r,"onSessionSettleRequest()");if(a)throw new Error(a.message);const c=Ro(i,"onSessionSettleRequest()");if(c)throw new Error(c.message);if(rs(o)){const{message:l}=V("EXPIRED","onSessionSettleRequest()");throw new Error(l)}}),L(this,"isValidUpdate",async s=>{if(!gt(s)){const{message:c}=V("MISSING_OR_INVALID",`update() params: ${s}`);throw new Error(c)}const{topic:n,namespaces:r}=s;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const i=this.client.session.get(n),o=Ro(r,"update()");if(o)throw new Error(o.message);const a=Pl(i.requiredNamespaces,r,"update()");if(a)throw new Error(a.message)}),L(this,"isValidExtend",async s=>{if(!gt(s)){const{message:r}=V("MISSING_OR_INVALID",`extend() params: ${s}`);throw new Error(r)}const{topic:n}=s;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n)}),L(this,"isValidRequest",async s=>{if(!gt(s)){const{message:c}=V("MISSING_OR_INVALID",`request() params: ${s}`);throw new Error(c)}const{topic:n,request:r,chainId:i,expiry:o}=s;this.checkRecentlyDeleted(n),await this.isValidSessionTopic(n);const{namespaces:a}=this.client.session.get(n);if(!Dl(a,i)){const{message:c}=V("MISSING_OR_INVALID",`request() chainId: ${i}`);throw new Error(c)}if(!u0(r)){const{message:c}=V("MISSING_OR_INVALID",`request() ${JSON.stringify(r)}`);throw new Error(c)}if(!p0(a,i,r.method)){const{message:c}=V("MISSING_OR_INVALID",`request() method: ${r.method}`);throw new Error(c)}if(o&&!w0(o,Mo)){const{message:c}=V("MISSING_OR_INVALID",`request() expiry: ${o}. Expiry must be a number (in seconds) between ${Mo.min} and ${Mo.max}`);throw new Error(c)}}),L(this,"isValidRespond",async s=>{var n;if(!gt(s)){const{message:o}=V("MISSING_OR_INVALID",`respond() params: ${s}`);throw new Error(o)}const{topic:r,response:i}=s;try{await this.isValidSessionTopic(r)}catch(o){throw(n=s?.response)!=null&&n.id&&this.cleanupAfterResponse(s),o}if(!d0(i)){const{message:o}=V("MISSING_OR_INVALID",`respond() response: ${JSON.stringify(i)}`);throw new Error(o)}}),L(this,"isValidPing",async s=>{if(!gt(s)){const{message:r}=V("MISSING_OR_INVALID",`ping() params: ${s}`);throw new Error(r)}const{topic:n}=s;await this.isValidSessionOrPairingTopic(n)}),L(this,"isValidEmit",async s=>{if(!gt(s)){const{message:a}=V("MISSING_OR_INVALID",`emit() params: ${s}`);throw new Error(a)}const{topic:n,event:r,chainId:i}=s;await this.isValidSessionTopic(n);const{namespaces:o}=this.client.session.get(n);if(!Dl(o,i)){const{message:a}=V("MISSING_OR_INVALID",`emit() chainId: ${i}`);throw new Error(a)}if(!h0(r)){const{message:a}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(a)}if(!f0(o,i,r.name)){const{message:a}=V("MISSING_OR_INVALID",`emit() event: ${JSON.stringify(r)}`);throw new Error(a)}}),L(this,"isValidDisconnect",async s=>{if(!gt(s)){const{message:r}=V("MISSING_OR_INVALID",`disconnect() params: ${s}`);throw new Error(r)}const{topic:n}=s;await this.isValidSessionOrPairingTopic(n)}),L(this,"isValidAuthenticate",s=>{const{chains:n,uri:r,domain:i,nonce:o}=s;if(!Array.isArray(n)||n.length===0)throw new Error("chains is required and must be a non-empty array");if(!Me(r,!1))throw new Error("uri is required parameter");if(!Me(i,!1))throw new Error("domain is required parameter");if(!Me(o,!1))throw new Error("nonce is required parameter");if([...new Set(n.map(c=>Is(c).namespace))].length>1)throw new Error("Multi-namespace requests are not supported. Please request single namespace only.");const{namespace:a}=Is(n[0]);if(a!=="eip155")throw new Error("Only eip155 namespace is supported for authenticated sessions. Please use .connect() for non-eip155 chains.")}),L(this,"getVerifyContext",async s=>{const{attestationId:n,hash:r,encryptedId:i,metadata:o,transportType:a}=s,c={verified:{verifyUrl:o.verifyUrl||kr,validation:"UNKNOWN",origin:o.url||""}};try{if(a===Oe.link_mode){const u=this.getAppLinkIfEnabled(o,a);return c.verified.validation=u&&new URL(u).origin===new URL(o.url).origin?"VALID":"INVALID",c}const l=await this.client.core.verify.resolve({attestationId:n,hash:r,encryptedId:i,verifyUrl:o.verifyUrl});l&&(c.verified.origin=l.origin,c.verified.isScam=l.isScam,c.verified.validation=l.origin===new URL(o.url).origin?"VALID":"INVALID")}catch(l){this.client.logger.warn(l)}return this.client.logger.debug(`Verify context: ${JSON.stringify(c)}`),c}),L(this,"validateSessionProps",(s,n)=>{Object.values(s).forEach((r,i)=>{if(r==null){const{message:o}=V("MISSING_OR_INVALID",`${n} must contain an existing value for each key. Received: ${r} for key ${Object.keys(s)[i]}`);throw new Error(o)}})}),L(this,"getPendingAuthRequest",s=>{const n=this.client.auth.requests.get(s);return typeof n=="object"?n:void 0}),L(this,"addToRecentlyDeleted",(s,n)=>{if(this.recentlyDeletedMap.set(s,n),this.recentlyDeletedMap.size>=this.recentlyDeletedLimit){let r=0;const i=this.recentlyDeletedLimit/2;for(const o of this.recentlyDeletedMap.keys()){if(r++>=i)break;this.recentlyDeletedMap.delete(o)}}}),L(this,"checkRecentlyDeleted",s=>{const n=this.recentlyDeletedMap.get(s);if(n){const{message:r}=V("MISSING_OR_INVALID",`Record was recently deleted - ${n}: ${s}`);throw new Error(r)}}),L(this,"isLinkModeEnabled",(s,n)=>{var r,i,o,a,c,l,u,d,h;return!s||n!==Oe.link_mode?!1:((i=(r=this.client.metadata)==null?void 0:r.redirect)==null?void 0:i.linkMode)===!0&&((a=(o=this.client.metadata)==null?void 0:o.redirect)==null?void 0:a.universal)!==void 0&&((l=(c=this.client.metadata)==null?void 0:c.redirect)==null?void 0:l.universal)!==""&&((u=s?.redirect)==null?void 0:u.universal)!==void 0&&((d=s?.redirect)==null?void 0:d.universal)!==""&&((h=s?.redirect)==null?void 0:h.linkMode)===!0&&this.client.core.linkModeSupportedApps.includes(s.redirect.universal)&&typeof(global==null?void 0:global.Linking)<"u"}),L(this,"getAppLinkIfEnabled",(s,n)=>{var r;return this.isLinkModeEnabled(s,n)?(r=s?.redirect)==null?void 0:r.universal:void 0}),L(this,"handleLinkModeMessage",({url:s})=>{if(!s||!s.includes("wc_ev")||!s.includes("topic"))return;const n=Wc(s,"topic")||"",r=decodeURIComponent(Wc(s,"wc_ev")||""),i=this.client.session.keys.includes(n);i&&this.client.session.update(n,{transportType:Oe.link_mode}),this.client.core.dispatchEnvelope({topic:n,message:r,sessionExists:i})}),L(this,"registerLinkModeListeners",async()=>{var s;if(Ha()||Xs()&&(s=this.client.metadata.redirect)!=null&&s.linkMode){const n=global==null?void 0:global.Linking;if(typeof n<"u"){n.addEventListener("url",this.handleLinkModeMessage,this.client.name);const r=await n.getInitialURL();r&&setTimeout(()=>{this.handleLinkModeMessage({url:r})},50)}}}),L(this,"getTVFParams",(s,n,r)=>{var i,o,a;if(!((i=n.request)!=null&&i.method))return{};const c={correlationId:s,rpcMethods:[n.request.method],chainId:n.chainId};try{const l=this.extractTxHashesFromResult(n.request,r);c.txHashes=l,c.contractAddresses=this.isValidContractData(n.request.params)?[(a=(o=n.request.params)==null?void 0:o[0])==null?void 0:a.to]:[]}catch(l){this.client.logger.warn("Error getting TVF params",l)}return c}),L(this,"isValidContractData",s=>{var n;if(!s)return!1;try{const r=s?.data||((n=s?.[0])==null?void 0:n.data);if(!r.startsWith("0x"))return!1;const i=r.slice(2);return/^[0-9a-fA-F]*$/.test(i)?i.length%2===0:!1}catch{}return!1}),L(this,"extractTxHashesFromResult",(s,n)=>{var r;try{if(!n)return[];const i=s.method,o=E1[i];if(i==="sui_signTransaction")return[Rw(n.transactionBytes)];if(i==="near_signTransaction")return[Xc(n)];if(i==="near_signTransactions")return n.map(c=>Xc(c));if(i==="xrpl_signTransactionFor"||i==="xrpl_signTransaction")return[(r=n.tx_json)==null?void 0:r.hash];if(i==="polkadot_signTransaction")return[P0({transaction:s.params.transactionPayload,signature:n.signature})];if(i==="algo_signTxn")return _s(n)?n.map(c=>Zc(c)):[Zc(n)];if(i==="cosmos_signDirect")return[$w(n)];if(i==="wallet_sendCalls")return Uw(n);if(typeof n=="string")return[n];const a=n[o.key];if(_s(a))return i==="solana_signAllTransactions"?a.map(c=>Pw(c)):a;if(typeof a=="string")return[a]}catch(i){this.client.logger.warn("Error extracting tx hashes from result",i)}return[]})}async processPendingMessageEvents(){try{const e=this.client.session.keys,s=this.client.core.relayer.messages.getWithoutAck(e);for(const[n,r]of Object.entries(s))for(const i of r)try{await this.onProviderMessageEvent({topic:n,message:i,publishedAt:Date.now()})}catch{this.client.logger.warn(`Error processing pending message event for topic: ${n}, message: ${i}`)}}catch(e){this.client.logger.warn("processPendingMessageEvents failed",e)}}isInitialized(){if(!this.initialized){const{message:e}=V("NOT_INITIALIZED",this.name);throw new Error(e)}}async confirmOnlineStateOrThrow(){await this.client.core.relayer.confirmOnlineStateOrThrow()}registerRelayerEvents(){this.client.core.relayer.on(Ue.message,e=>{this.onProviderMessageEvent(e)})}async onRelayMessage(e){const{topic:s,message:n,attestation:r,transportType:i}=e,{publicKey:o}=this.client.auth.authKeys.keys.includes(Ii)?this.client.auth.authKeys.get(Ii):{publicKey:void 0};try{const a=await this.client.core.crypto.decode(s,n,{receiverPublicKey:o,encoding:i===Oe.link_mode?Vs:wt});Ma(a)?(this.client.core.history.set(s,a),await this.onRelayEventRequest({topic:s,payload:a,attestation:r,transportType:i,encryptedId:$t(n)})):ja(a)?(await this.client.core.history.resolve(a),await this.onRelayEventResponse({topic:s,payload:a,transportType:i}),this.client.core.history.delete(s,a.id)):await this.onRelayEventUnknownPayload({topic:s,payload:a,transportType:i}),await this.client.core.relayer.messages.ack(s,n)}catch(a){this.client.logger.error(a)}}registerExpirerEvents(){this.client.core.expirer.on(xt.expired,async e=>{const{topic:s,id:n}=bd(e.target);if(n&&this.client.pendingRequest.keys.includes(n))return await this.deletePendingSessionRequest(n,V("EXPIRED"),!0);if(n&&this.client.auth.requests.keys.includes(n))return await this.deletePendingAuthRequest(n,V("EXPIRED"),!0);s?this.client.session.keys.includes(s)&&(await this.deleteSession({topic:s,expirerHasDeleted:!0}),this.client.events.emit("session_expire",{topic:s})):n&&(await this.deleteProposal(n,!0),this.client.events.emit("proposal_expire",{id:n}))})}registerPairingEvents(){this.client.core.pairing.events.on(cn.create,e=>this.onPairingCreated(e)),this.client.core.pairing.events.on(cn.delete,e=>{this.addToRecentlyDeleted(e.topic,"pairing")})}isValidPairingTopic(e){if(!Me(e,!1)){const{message:s}=V("MISSING_OR_INVALID",`pairing topic should be a string: ${e}`);throw new Error(s)}if(!this.client.core.pairing.pairings.keys.includes(e)){const{message:s}=V("NO_MATCHING_KEY",`pairing topic doesn't exist: ${e}`);throw new Error(s)}if(rs(this.client.core.pairing.pairings.get(e).expiry)){const{message:s}=V("EXPIRED",`pairing topic: ${e}`);throw new Error(s)}}async isValidSessionTopic(e){if(!Me(e,!1)){const{message:s}=V("MISSING_OR_INVALID",`session topic should be a string: ${e}`);throw new Error(s)}if(this.checkRecentlyDeleted(e),!this.client.session.keys.includes(e)){const{message:s}=V("NO_MATCHING_KEY",`session topic doesn't exist: ${e}`);throw new Error(s)}if(rs(this.client.session.get(e).expiry)){await this.deleteSession({topic:e});const{message:s}=V("EXPIRED",`session topic: ${e}`);throw new Error(s)}if(!this.client.core.crypto.keychain.has(e)){const{message:s}=V("MISSING_OR_INVALID",`session topic does not exist in keychain: ${e}`);throw await this.deleteSession({topic:e}),new Error(s)}}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(Me(e,!1)){const{message:s}=V("NO_MATCHING_KEY",`session or pairing topic doesn't exist: ${e}`);throw new Error(s)}else{const{message:s}=V("MISSING_OR_INVALID",`session or pairing topic should be a string: ${e}`);throw new Error(s)}}async isValidProposalId(e){if(!c0(e)){const{message:s}=V("MISSING_OR_INVALID",`proposal id should be a number: ${e}`);throw new Error(s)}if(!this.client.proposal.keys.includes(e)){const{message:s}=V("NO_MATCHING_KEY",`proposal id doesn't exist: ${e}`);throw new Error(s)}if(rs(this.client.proposal.get(e).expiryTimestamp)){await this.deleteProposal(e);const{message:s}=V("EXPIRED",`proposal id: ${e}`);throw new Error(s)}}}class x1 extends Tn{constructor(e,s){super(e,s,w1,rc),this.core=e,this.logger=s}}let $1=class extends Tn{constructor(e,s){super(e,s,y1,rc),this.core=e,this.logger=s}};class U1 extends Tn{constructor(e,s){super(e,s,C1,rc,n=>n.id),this.core=e,this.logger=s}}class L1 extends Tn{constructor(e,s){super(e,s,N1,lo,()=>Ii),this.core=e,this.logger=s}}class B1 extends Tn{constructor(e,s){super(e,s,_1,lo),this.core=e,this.logger=s}}class M1 extends Tn{constructor(e,s){super(e,s,S1,lo,n=>n.id),this.core=e,this.logger=s}}var j1=Object.defineProperty,F1=(t,e,s)=>e in t?j1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,jo=(t,e,s)=>F1(t,typeof e!="symbol"?e+"":e,s);class q1{constructor(e,s){this.core=e,this.logger=s,jo(this,"authKeys"),jo(this,"pairingTopics"),jo(this,"requests"),this.authKeys=new L1(this.core,this.logger),this.pairingTopics=new B1(this.core,this.logger),this.requests=new M1(this.core,this.logger)}async init(){await this.authKeys.init(),await this.pairingTopics.init(),await this.requests.init()}}var W1=Object.defineProperty,V1=(t,e,s)=>e in t?W1(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,fe=(t,e,s)=>V1(t,typeof e!="symbol"?e+"":e,s);let z1=class Mh extends fg{constructor(e){super(e),fe(this,"protocol",Uh),fe(this,"version",Lh),fe(this,"name",Bo.name),fe(this,"metadata"),fe(this,"core"),fe(this,"logger"),fe(this,"events",new An.EventEmitter),fe(this,"engine"),fe(this,"session"),fe(this,"proposal"),fe(this,"pendingRequest"),fe(this,"auth"),fe(this,"signConfig"),fe(this,"on",(n,r)=>this.events.on(n,r)),fe(this,"once",(n,r)=>this.events.once(n,r)),fe(this,"off",(n,r)=>this.events.off(n,r)),fe(this,"removeListener",(n,r)=>this.events.removeListener(n,r)),fe(this,"removeAllListeners",n=>this.events.removeAllListeners(n)),fe(this,"connect",async n=>{try{return await this.engine.connect(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"pair",async n=>{try{return await this.engine.pair(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"approve",async n=>{try{return await this.engine.approve(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"reject",async n=>{try{return await this.engine.reject(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"update",async n=>{try{return await this.engine.update(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"extend",async n=>{try{return await this.engine.extend(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"request",async n=>{try{return await this.engine.request(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"respond",async n=>{try{return await this.engine.respond(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"ping",async n=>{try{return await this.engine.ping(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"emit",async n=>{try{return await this.engine.emit(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"disconnect",async n=>{try{return await this.engine.disconnect(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"find",n=>{try{return this.engine.find(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"getPendingSessionRequests",()=>{try{return this.engine.getPendingSessionRequests()}catch(n){throw this.logger.error(n.message),n}}),fe(this,"authenticate",async(n,r)=>{try{return await this.engine.authenticate(n,r)}catch(i){throw this.logger.error(i.message),i}}),fe(this,"formatAuthMessage",n=>{try{return this.engine.formatAuthMessage(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"approveSessionAuthenticate",async n=>{try{return await this.engine.approveSessionAuthenticate(n)}catch(r){throw this.logger.error(r.message),r}}),fe(this,"rejectSessionAuthenticate",async n=>{try{return await this.engine.rejectSessionAuthenticate(n)}catch(r){throw this.logger.error(r.message),r}}),this.name=e?.name||Bo.name,this.metadata=Nm(e?.metadata),this.signConfig=e?.signConfig;const s=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Kr(Xi({level:e?.logger||Bo.logger}));this.core=e?.core||new m1(e),this.logger=lt(s,this.name),this.session=new $1(this.core,this.logger),this.proposal=new x1(this.core,this.logger),this.pendingRequest=new U1(this.core,this.logger),this.engine=new R1(this),this.auth=new q1(this.core,this.logger)}static async init(e){const s=new Mh(e);return await s.initialize(),s}get context(){return Et(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")}catch(e){throw this.logger.info("SignClient Initialization Failure"),this.logger.error(e.message),e}}};const cu="error",H1="wss://relay.walletconnect.org",K1="wc",G1="universal_provider",fi=`${K1}@2:${G1}:`,jh="https://rpc.walletconnect.org/v1/",Fh="generic",Y1=`${jh}bundler`,Gn="call_status",J1=86400,ic={DEFAULT_CHAIN_CHANGED:"default_chain_changed"};function oc(t){return t==null||typeof t!="object"&&typeof t!="function"}function qh(t){return Object.getOwnPropertySymbols(t).filter(e=>Object.prototype.propertyIsEnumerable.call(t,e))}function Wh(t){return t==null?t===void 0?"[object Undefined]":"[object Null]":Object.prototype.toString.call(t)}const X1="[object RegExp]",Vh="[object String]",zh="[object Number]",Hh="[object Boolean]",Kh="[object Arguments]",Z1="[object Symbol]",Q1="[object Date]",eA="[object Map]",tA="[object Set]",sA="[object Array]",nA="[object ArrayBuffer]",rA="[object Object]",iA="[object DataView]",oA="[object Uint8Array]",aA="[object Uint8ClampedArray]",cA="[object Uint16Array]",lA="[object Uint32Array]",uA="[object Int8Array]",dA="[object Int16Array]",hA="[object Int32Array]",pA="[object Float32Array]",fA="[object Float64Array]";function ac(t){return ArrayBuffer.isView(t)&&!(t instanceof DataView)}function gA(t,e){return zn(t,void 0,t,new Map,e)}function zn(t,e,s,n=new Map,r=void 0){const i=r?.(t,e,s,n);if(i!=null)return i;if(oc(t))return t;if(n.has(t))return n.get(t);if(Array.isArray(t)){const o=new Array(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=zn(t[a],a,s,n,r);return Object.hasOwn(t,"index")&&(o.index=t.index),Object.hasOwn(t,"input")&&(o.input=t.input),o}if(t instanceof Date)return new Date(t.getTime());if(t instanceof RegExp){const o=new RegExp(t.source,t.flags);return o.lastIndex=t.lastIndex,o}if(t instanceof Map){const o=new Map;n.set(t,o);for(const[a,c]of t)o.set(a,zn(c,a,s,n,r));return o}if(t instanceof Set){const o=new Set;n.set(t,o);for(const a of t)o.add(zn(a,void 0,s,n,r));return o}if(typeof Buffer<"u"&&Buffer.isBuffer(t))return t.subarray();if(ac(t)){const o=new(Object.getPrototypeOf(t)).constructor(t.length);n.set(t,o);for(let a=0;a<t.length;a++)o[a]=zn(t[a],a,s,n,r);return o}if(t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);if(t instanceof DataView){const o=new DataView(t.buffer.slice(0),t.byteOffset,t.byteLength);return n.set(t,o),ln(o,t,s,n,r),o}if(typeof File<"u"&&t instanceof File){const o=new File([t],t.name,{type:t.type});return n.set(t,o),ln(o,t,s,n,r),o}if(t instanceof Blob){const o=new Blob([t],{type:t.type});return n.set(t,o),ln(o,t,s,n,r),o}if(t instanceof Error){const o=new t.constructor;return n.set(t,o),o.message=t.message,o.name=t.name,o.stack=t.stack,o.cause=t.cause,ln(o,t,s,n,r),o}if(typeof t=="object"&&mA(t)){const o=Object.create(Object.getPrototypeOf(t));return n.set(t,o),ln(o,t,s,n,r),o}return t}function ln(t,e,s=t,n,r){const i=[...Object.keys(e),...qh(e)];for(let o=0;o<i.length;o++){const a=i[o],c=Object.getOwnPropertyDescriptor(t,a);(c==null||c.writable)&&(t[a]=zn(e[a],a,s,n,r))}}function mA(t){switch(Wh(t)){case Kh:case sA:case nA:case iA:case Hh:case Q1:case pA:case fA:case uA:case dA:case hA:case eA:case zh:case rA:case X1:case tA:case Vh:case Z1:case oA:case aA:case cA:case lA:return!0;default:return!1}}function wA(t,e){return gA(t,(s,n,r,i)=>{if(typeof t=="object")switch(Object.prototype.toString.call(t)){case zh:case Vh:case Hh:{const o=new t.constructor(t?.valueOf());return ln(o,t),o}case Kh:{const o={};return ln(o,t),o.length=t.length,o[Symbol.iterator]=t[Symbol.iterator],o}default:return}})}function lu(t){return wA(t)}function uu(t){return t!==null&&typeof t=="object"&&Wh(t)==="[object Arguments]"}function du(t){return typeof t=="object"&&t!==null}function yA(){}function bA(t){return ac(t)}function EA(t){if(typeof t!="object"||t==null)return!1;if(Object.getPrototypeOf(t)===null)return!0;if(Object.prototype.toString.call(t)!=="[object Object]"){const s=t[Symbol.toStringTag];return s==null||!Object.getOwnPropertyDescriptor(t,Symbol.toStringTag)?.writable?!1:t.toString()===`[object ${s}]`}let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e}function CA(t){if(oc(t))return t;if(Array.isArray(t)||ac(t)||t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer)return t.slice(0);const e=Object.getPrototypeOf(t),s=e.constructor;if(t instanceof Date||t instanceof Map||t instanceof Set)return new s(t);if(t instanceof RegExp){const n=new s(t);return n.lastIndex=t.lastIndex,n}if(t instanceof DataView)return new s(t.buffer.slice(0));if(t instanceof Error){const n=new s(t.message);return n.stack=t.stack,n.name=t.name,n.cause=t.cause,n}if(typeof File<"u"&&t instanceof File)return new s([t],t.name,{type:t.type,lastModified:t.lastModified});if(typeof t=="object"){const n=Object.create(e);return Object.assign(n,t)}return t}function vA(t,...e){const s=e.slice(0,-1),n=e[e.length-1];let r=t;for(let i=0;i<s.length;i++){const o=s[i];r=Da(r,o,n,new Map)}return r}function Da(t,e,s,n){if(oc(t)&&(t=Object(t)),e==null||typeof e!="object")return t;if(n.has(e))return CA(n.get(e));if(n.set(e,t),Array.isArray(e)){e=e.slice();for(let i=0;i<e.length;i++)e[i]=e[i]??void 0}const r=[...Object.keys(e),...qh(e)];for(let i=0;i<r.length;i++){const o=r[i];let a=e[o],c=t[o];if(uu(a)&&(a={...a}),uu(c)&&(c={...c}),typeof Buffer<"u"&&Buffer.isBuffer(a)&&(a=lu(a)),Array.isArray(a))if(typeof c=="object"&&c!=null){const u=[],d=Reflect.ownKeys(c);for(let h=0;h<d.length;h++){const m=d[h];u[m]=c[m]}c=u}else c=[];const l=s(c,a,o,t,e,n);l!=null?t[o]=l:Array.isArray(a)||du(c)&&du(a)?t[o]=Da(c,a,s,n):c==null&&EA(a)?t[o]=Da({},a,s,n):c==null&&bA(a)?t[o]=lu(a):(c===void 0||a!==void 0)&&(t[o]=a)}return t}function AA(t,...e){return vA(t,...e,yA)}var IA=Object.defineProperty,NA=Object.defineProperties,_A=Object.getOwnPropertyDescriptors,hu=Object.getOwnPropertySymbols,SA=Object.prototype.hasOwnProperty,TA=Object.prototype.propertyIsEnumerable,pu=(t,e,s)=>e in t?IA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,gi=(t,e)=>{for(var s in e||(e={}))SA.call(e,s)&&pu(t,s,e[s]);if(hu)for(var s of hu(e))TA.call(e,s)&&pu(t,s,e[s]);return t},OA=(t,e)=>NA(t,_A(e));function Gh(t,e,s){var n;const r=Is(t);return((n=e.rpcMap)==null?void 0:n[r.reference])||`${jh}?chainId=${r.namespace}:${r.reference}&projectId=${s}`}function kA(t){return t.includes(":")?t.split(":")[1]:t}function Yh(t){return t.map(e=>`${e.split(":")[0]}:${e.split(":")[1]}`)}function DA(t,e){const s=Object.keys(e.namespaces).filter(r=>r.includes(t));if(!s.length)return[];const n=[];return s.forEach(r=>{const i=e.namespaces[r].accounts;n.push(...i)}),n}function fu(t){return Object.fromEntries(Object.entries(t).filter(([e,s])=>{var n,r;return((n=s?.chains)==null?void 0:n.length)&&((r=s?.chains)==null?void 0:r.length)>0}))}function mi(t={},e={}){const s=fu(gu(t)),n=fu(gu(e));return AA(s,n)}function gu(t){var e,s,n,r,i;const o={};if(!us(t))return o;for(const[a,c]of Object.entries(t)){const l=ao(a)?[a]:c.chains,u=c.methods||[],d=c.events||[],h=c.rpcMap||{},m=Vn(a);o[m]=OA(gi(gi({},o[m]),c),{chains:ls(l,(e=o[m])==null?void 0:e.chains),methods:ls(u,(s=o[m])==null?void 0:s.methods),events:ls(d,(n=o[m])==null?void 0:n.events)}),(us(h)||us(((r=o[m])==null?void 0:r.rpcMap)||{}))&&(o[m].rpcMap=gi(gi({},h),(i=o[m])==null?void 0:i.rpcMap))}return o}function mu(t){return t.includes(":")?t.split(":")[2]:t}function wu(t){const e={};for(const[s,n]of Object.entries(t)){const r=n.methods||[],i=n.events||[],o=n.accounts||[],a=ao(s)?[s]:n.chains?n.chains:Yh(n.accounts);e[s]={chains:a,methods:r,events:i,accounts:o}}return e}function Fo(t){return typeof t=="number"?t:t.includes("0x")?parseInt(t,16):(t=t.includes(":")?t.split(":")[1]:t,isNaN(Number(t))?t:Number(t))}function PA(t){try{const e=JSON.parse(t);return typeof e=="object"&&e!==null&&!Array.isArray(e)}catch{return!1}}const Jh={},Yn=t=>Jh[t],qo=(t,e)=>{Jh[t]=e};var RA=Object.defineProperty,yu=Object.getOwnPropertySymbols,xA=Object.prototype.hasOwnProperty,$A=Object.prototype.propertyIsEnumerable,bu=(t,e,s)=>e in t?RA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Eu=(t,e)=>{for(var s in e||(e={}))xA.call(e,s)&&bu(t,s,e[s]);if(yu)for(var s of yu(e))$A.call(e,s)&&bu(t,s,e[s]);return t};const Cu="eip155",UA=["atomic","flow-control","paymasterService","sessionKeys","auxiliaryFunds"],LA=t=>t&&t.startsWith("0x")?BigInt(t).toString(10):t,Wo=t=>t&&t.startsWith("0x")?t:`0x${BigInt(t).toString(16)}`,vu=t=>Object.keys(t).filter(e=>UA.includes(e)).reduce((e,s)=>(e[s]=BA(t[s]),e),{}),BA=t=>typeof t=="string"&&PA(t)?JSON.parse(t):t,MA=(t,e,s)=>{const{sessionProperties:n={},scopedProperties:r={}}=t,i={};if(!us(r)&&!us(n))return;const o=vu(n);for(const a of s){const c=LA(a);if(!c)continue;i[Wo(c)]=o;const l=r?.[`${Cu}:${c}`];if(l){const u=l?.[`${Cu}:${c}:${e}`];i[Wo(c)]=Eu(Eu({},i[Wo(c)]),vu(u||l))}}for(const[a,c]of Object.entries(i))Object.keys(c).length===0&&delete i[a];return Object.keys(i).length>0?i:void 0};var jA=Object.defineProperty,FA=(t,e,s)=>e in t?jA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,qA=(t,e,s)=>FA(t,e+"",s);let Vo;class cc{constructor(e){qA(this,"storage"),this.storage=e}async getItem(e){return await this.storage.getItem(e)}async setItem(e,s){return await this.storage.setItem(e,s)}async removeItem(e){return await this.storage.removeItem(e)}static getStorage(e){return Vo||(Vo=new cc(e)),Vo}}var WA=Object.defineProperty,VA=Object.defineProperties,zA=Object.getOwnPropertyDescriptors,Au=Object.getOwnPropertySymbols,HA=Object.prototype.hasOwnProperty,KA=Object.prototype.propertyIsEnumerable,Iu=(t,e,s)=>e in t?WA(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,GA=(t,e)=>{for(var s in e||(e={}))HA.call(e,s)&&Iu(t,s,e[s]);if(Au)for(var s of Au(e))KA.call(e,s)&&Iu(t,s,e[s]);return t},YA=(t,e)=>VA(t,zA(e));async function JA(t,e){const s=Is(t.result.capabilities.caip345.caip2),n=t.result.capabilities.caip345.transactionHashes,r=await Promise.allSettled(n.map(d=>XA(s.reference,d,e))),i=r.filter(d=>d.status==="fulfilled").map(d=>d.value).filter(d=>d);r.filter(d=>d.status==="rejected").forEach(d=>console.warn("Failed to fetch transaction receipt:",d.reason));const o=!i.length||i.some(d=>!d),a=i.every(d=>d?.status==="0x1"),c=i.every(d=>d?.status==="0x0"),l=i.some(d=>d?.status==="0x0");let u;return o?u=100:a?u=200:c?u=500:l&&(u=600),{id:t.result.id,version:t.request.version,atomic:t.request.atomicRequired,chainId:t.request.chainId,capabilities:t.result.capabilities,receipts:i,status:u}}async function XA(t,e,s){return await s(parseInt(t)).request(ss("eth_getTransactionReceipt",[e]))}async function ZA({sendCalls:t,storage:e}){const s=await e.getItem(Gn);await e.setItem(Gn,YA(GA({},s),{[t.result.id]:{request:t.request,result:t.result,expiry:Be(J1)}}))}async function QA({resultId:t,storage:e}){const s=await e.getItem(Gn);if(s){delete s[t],await e.setItem(Gn,s);for(const n in s)rs(s[n].expiry)&&delete s[n];await e.setItem(Gn,s)}}async function eI({resultId:t,storage:e}){const s=await e.getItem(Gn),n=s?.[t];if(n&&!rs(n.expiry))return n;await QA({resultId:t,storage:e})}var tI=Object.defineProperty,sI=Object.defineProperties,nI=Object.getOwnPropertyDescriptors,Nu=Object.getOwnPropertySymbols,rI=Object.prototype.hasOwnProperty,iI=Object.prototype.propertyIsEnumerable,Pa=(t,e,s)=>e in t?tI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,zo=(t,e)=>{for(var s in e||(e={}))rI.call(e,s)&&Pa(t,s,e[s]);if(Nu)for(var s of Nu(e))iI.call(e,s)&&Pa(t,s,e[s]);return t},Ho=(t,e)=>sI(t,nI(e)),nn=(t,e,s)=>Pa(t,typeof e!="symbol"?e+"":e,s);class oI{constructor(e){nn(this,"name","eip155"),nn(this,"client"),nn(this,"chainId"),nn(this,"namespace"),nn(this,"httpProviders"),nn(this,"events"),nn(this,"storage"),this.namespace=e.namespace,this.events=Yn("events"),this.client=Yn("client"),this.httpProviders=this.createHttpProviders(),this.chainId=parseInt(this.getDefaultChain()),this.storage=cc.getStorage(this.client.core.storage)}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);case"wallet_sendCalls":return await this.sendCalls(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,s){this.httpProviders[e]||this.setHttpProvider(parseInt(e),s);const n=this.chainId;this.chainId=parseInt(e),this.events.emit(ic.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${n}`})}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,s){const n=s||Gh(`${this.name}:${e}`,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ba(new Gu(n,Yn("disableProviderPing")))}setHttpProvider(e,s){const n=this.createHttpProvider(e,s);n&&(this.httpProviders[e]=n)}createHttpProviders(){const e={};return this.namespace.chains.forEach(s=>{var n;const r=parseInt(kA(s));e[r]=this.createHttpProvider(r,(n=this.namespace.rpcMap)==null?void 0:n[s])}),e}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}getHttpProvider(e){const s=e||this.chainId;return this.httpProviders[s]||(this.httpProviders=Ho(zo({},this.httpProviders),{[s]:this.createHttpProvider(s)}),this.httpProviders[s])}async handleSwitchChain(e){var s,n;let r=e.request.params?(s=e.request.params[0])==null?void 0:s.chainId:"0x0";r=r.startsWith("0x")?r:`0x${r}`;const i=parseInt(r,16);if(this.isChainApproved(i))this.setDefaultChain(`${i}`);else if(this.namespace.methods.includes("wallet_switchEthereumChain"))await this.client.request({topic:e.topic,request:{method:e.request.method,params:[{chainId:r}]},chainId:(n=this.namespace.chains)==null?void 0:n[0]}),this.setDefaultChain(`${i}`);else throw new Error(`Failed to switch to chain 'eip155:${i}'. 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 s,n,r,i,o;const a=(n=(s=e.request)==null?void 0:s.params)==null?void 0:n[0],c=((i=(r=e.request)==null?void 0:r.params)==null?void 0:i[1])||[];if(!a)throw new Error("Missing address parameter in `wallet_getCapabilities` request");const l=this.client.session.get(e.topic),u=((o=l?.sessionProperties)==null?void 0:o.capabilities)||{},d=`${a}${c.join(",")}`,h=u?.[d];if(h)return h;let m;try{m=MA(l,a,c)}catch(b){console.warn("Failed to extract capabilities from session",b)}if(m)return m;const g=await this.client.request(e);try{await this.client.session.update(e.topic,{sessionProperties:Ho(zo({},l.sessionProperties||{}),{capabilities:Ho(zo({},u||{}),{[d]:g})})})}catch(b){console.warn("Failed to update session with capabilities",b)}return g}async getCallStatus(e){var s,n,r;const i=this.client.session.get(e.topic),o=(s=i.sessionProperties)==null?void 0:s.bundler_name;if(o){const l=this.getBundlerUrl(e.chainId,o);try{return await this.getUserOperationReceipt(l,e)}catch(u){console.warn("Failed to fetch call status from bundler",u,l)}}const a=(n=i.sessionProperties)==null?void 0:n.bundler_url;if(a)try{return await this.getUserOperationReceipt(a,e)}catch(l){console.warn("Failed to fetch call status from custom bundler",l,a)}const c=await eI({resultId:(r=e.request.params)==null?void 0:r[0],storage:this.storage});if(c)try{return await JA(c,this.getHttpProvider.bind(this))}catch(l){console.warn("Failed to fetch call status from stored send calls",l,c)}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,s){var n;const r=new URL(e),i=await fetch(r,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(ss("eth_getUserOperationReceipt",[(n=s.request.params)==null?void 0:n[0]]))});if(!i.ok)throw new Error(`Failed to fetch user operation receipt - ${i.status}`);return await i.json()}getBundlerUrl(e,s){return`${Y1}?projectId=${this.client.core.projectId}&chainId=${e}&bundler=${s}`}async sendCalls(e){var s,n,r;const i=await this.client.request(e),o=(s=e.request.params)==null?void 0:s[0],a=i?.id,c=i?.capabilities||{},l=(n=c?.caip345)==null?void 0:n.caip2,u=(r=c?.caip345)==null?void 0:r.transactionHashes;return!a||!l||!(u!=null&&u.length)||await ZA({sendCalls:{request:o,result:i},storage:this.storage}),i}}var aI=Object.defineProperty,cI=(t,e,s)=>e in t?aI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Un=(t,e,s)=>cI(t,typeof e!="symbol"?e+"":e,s);class lI{constructor(e){Un(this,"name",Fh),Un(this,"client"),Un(this,"httpProviders"),Un(this,"events"),Un(this,"namespace"),Un(this,"chainId"),this.namespace=e.namespace,this.events=Yn("events"),this.client=Yn("client"),this.chainId=this.getDefaultChain(),this.name=this.getNamespaceName(),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,s){this.httpProviders[e]||this.setHttpProvider(e,s);const n=this.chainId;this.chainId=e,this.events.emit(ic.DEFAULT_CHAIN_CHANGED,{currentCaipChainId:`${this.name}:${e}`,previousCaipChainId:`${this.name}:${n}`})}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]}getNamespaceName(){const e=this.namespace.chains[0];if(!e)throw new Error("ChainId not found");return Is(e).namespace}getAccounts(){const e=this.namespace.accounts;return e?[...new Set(e.filter(s=>s.split(":")[1]===this.chainId.toString()).map(s=>s.split(":")[2]))]:[]}createHttpProviders(){var e,s;const n={};return(s=(e=this.namespace)==null?void 0:e.accounts)==null||s.forEach(r=>{var i,o;const a=Is(r),c=(o=(i=this.namespace)==null?void 0:i.rpcMap)==null?void 0:o[`${a.namespace}:${a.reference}`];n[a.reference]=this.createHttpProvider(r,c)}),n}getHttpProvider(e){const s=Is(e).reference,n=this.httpProviders[s];if(typeof n>"u")throw new Error(`JSON-RPC provider for ${e} not found`);return n}setHttpProvider(e,s){const n=this.createHttpProvider(e,s);n&&(this.httpProviders[e]=n)}createHttpProvider(e,s){const n=s||Gh(e,this.namespace,this.client.core.projectId);if(!n)throw new Error(`No RPC url provided for chainId: ${e}`);return new Ba(new Gu(n,Yn("disableProviderPing")))}}var uI=Object.defineProperty,dI=Object.defineProperties,hI=Object.getOwnPropertyDescriptors,_u=Object.getOwnPropertySymbols,pI=Object.prototype.hasOwnProperty,fI=Object.prototype.propertyIsEnumerable,Ra=(t,e,s)=>e in t?uI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,yr=(t,e)=>{for(var s in e||(e={}))pI.call(e,s)&&Ra(t,s,e[s]);if(_u)for(var s of _u(e))fI.call(e,s)&&Ra(t,s,e[s]);return t},wi=(t,e)=>dI(t,hI(e)),Dt=(t,e,s)=>Ra(t,typeof e!="symbol"?e+"":e,s);let gI=class Xh{constructor(e){Dt(this,"client"),Dt(this,"namespaces"),Dt(this,"optionalNamespaces"),Dt(this,"sessionProperties"),Dt(this,"scopedProperties"),Dt(this,"events",new Fa),Dt(this,"rpcProviders",{}),Dt(this,"session"),Dt(this,"providerOpts"),Dt(this,"logger"),Dt(this,"uri"),Dt(this,"disableProviderPing",!1),this.providerOpts=e,this.logger=typeof e?.logger<"u"&&typeof e?.logger!="string"?e.logger:Kr(Xi({level:e?.logger||cu})),this.disableProviderPing=e?.disableProviderPing||!1}static async init(e){const s=new Xh(e);return await s.initialize(),s}async request(e,s,n){const[r,i]=this.validateChain(s);if(!this.session)throw new Error("Please call connect() before request()");return await this.getProvider(r).request({request:yr({},e),chainId:`${r}:${i}`,topic:this.session.topic,expiry:n})}sendAsync(e,s,n,r){const i=new Date().getTime();this.request(e,n,r).then(o=>s(null,xr(i,o))).catch(o=>s(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,scopedProperties:this.scopedProperties}),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:Pe("USER_DISCONNECTED")}),await this.cleanup()}async connect(e){if(!this.client)throw new Error("Sign Client not initialized");if(this.setNamespaces(e),this.cleanupPendingPairings(),!e.skipPairing)return await this.pair(e.pairingTopic)}async authenticate(e,s){if(!this.client)throw new Error("Sign Client not initialized");this.setNamespaces(e),await this.cleanupPendingPairings();const{uri:n,response:r}=await this.client.authenticate(e,s);n&&(this.uri=n,this.events.emit("display_uri",n));const i=await r();if(this.session=i.session,this.session){const o=wu(this.session.namespaces);this.namespaces=mi(this.namespaces,o),await this.persist("namespaces",this.namespaces),this.onConnect()}return i}on(e,s){this.events.on(e,s)}once(e,s){this.events.once(e,s)}removeListener(e,s){this.events.removeListener(e,s)}off(e,s){this.events.off(e,s)}get isWalletConnect(){return!0}async pair(e){const{uri:s,approval:n}=await this.client.connect({pairingTopic:e,requiredNamespaces:this.namespaces,optionalNamespaces:this.optionalNamespaces,sessionProperties:this.sessionProperties,scopedProperties:this.scopedProperties});s&&(this.uri=s,this.events.emit("display_uri",s));const r=await n();this.session=r;const i=wu(r.namespaces);return this.namespaces=mi(this.namespaces,i),await this.persist("namespaces",this.namespaces),await this.persist("optionalNamespaces",this.optionalNamespaces),this.onConnect(),this.session}setDefaultChain(e,s){try{if(!this.session)return;const[n,r]=this.validateChain(e);this.getProvider(n).setDefaultChain(r,s)}catch(n){if(!/Please call connect/.test(n.message))throw n}}async cleanupPendingPairings(e={}){try{this.logger.info("Cleaning up inactive pairings...");const s=this.client.pairing.getAll();if(!_s(s))return;for(const n of s)e.deletePairings?this.client.core.expirer.set(n.topic,0):await this.client.core.relayer.subscriber.unsubscribe(n.topic);this.logger.info(`Inactive pairings cleared: ${s.length}`)}catch(s){this.logger.warn("Failed to cleanup pending pairings",s)}}abortPairingAttempt(){this.logger.warn("abortPairingAttempt is deprecated. This is now a no-op.")}async checkStorage(){this.namespaces=await this.getFromStore("namespaces")||{},this.optionalNamespaces=await this.getFromStore("optionalNamespaces")||{},this.session&&this.createProviders()}async initialize(){this.logger.trace("Initialized"),await this.createClient(),await this.checkStorage(),this.registerEventListeners()}async createClient(){var e,s;if(this.client=this.providerOpts.client||await z1.init({core:this.providerOpts.core,logger:this.providerOpts.logger||cu,relayUrl:this.providerOpts.relayUrl||H1,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.providerOpts.session)try{this.session=this.client.session.get(this.providerOpts.session.topic)}catch(n){throw this.logger.error("Failed to get session",n),new Error(`The provided session: ${(s=(e=this.providerOpts)==null?void 0:e.session)==null?void 0:s.topic} doesn't exist in the Sign client`)}else{const n=this.client.session.getAll();this.session=n[0]}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(s=>Vn(s)))];qo("client",this.client),qo("events",this.events),qo("disableProviderPing",this.disableProviderPing),e.forEach(s=>{if(!this.session)return;const n=DA(s,this.session);if(n?.length===0)return;const r=Yh(n),i=mi(this.namespaces,this.optionalNamespaces),o=wi(yr({},i[s]),{accounts:n,chains:r});s==="eip155"?this.rpcProviders[s]=new oI({namespace:o}):this.rpcProviders[s]=new lI({namespace:o})})}registerEventListeners(){if(typeof this.client>"u")throw new Error("Sign Client is not initialized");this.client.on("session_ping",e=>{var s;const{topic:n}=e;n===((s=this.session)==null?void 0:s.topic)&&this.events.emit("session_ping",e)}),this.client.on("session_event",e=>{var s;const{params:n,topic:r}=e;if(r!==((s=this.session)==null?void 0:s.topic))return;const{event:i}=n;if(i.name==="accountsChanged"){const o=i.data;o&&_s(o)&&this.events.emit("accountsChanged",o.map(mu))}else if(i.name==="chainChanged"){const o=n.chainId,a=n.event.data,c=Vn(o),l=Fo(o)!==Fo(a)?`${c}:${Fo(a)}`:o;this.onChainChanged({currentCaipChainId:l})}else this.events.emit(i.name,i.data);this.events.emit("session_event",e)}),this.client.on("session_update",({topic:e,params:s})=>{var n,r;if(e!==((n=this.session)==null?void 0:n.topic))return;const{namespaces:i}=s,o=(r=this.client)==null?void 0:r.session.get(e);this.session=wi(yr({},o),{namespaces:i}),this.onSessionUpdate(),this.events.emit("session_update",{topic:e,params:s})}),this.client.on("session_delete",async e=>{var s;e.topic===((s=this.session)==null?void 0:s.topic)&&(await this.cleanup(),this.events.emit("session_delete",e),this.events.emit("disconnect",wi(yr({},Pe("USER_DISCONNECTED")),{data:e.topic})))}),this.on(ic.DEFAULT_CHAIN_CHANGED,e=>{this.onChainChanged(wi(yr({},e),{internal:!0}))})}getProvider(e){return this.rpcProviders[e]||this.rpcProviders[Fh]}onSessionUpdate(){Object.keys(this.rpcProviders).forEach(e=>{var s;this.getProvider(e).updateNamespace((s=this.session)==null?void 0:s.namespaces[e])})}setNamespaces(e){const{namespaces:s={},optionalNamespaces:n={},sessionProperties:r,scopedProperties:i}=e;this.optionalNamespaces=mi(s,n),this.sessionProperties=r,this.scopedProperties=i}validateChain(e){const[s,n]=e?.split(":")||["",""];if(!this.namespaces||!Object.keys(this.namespaces).length)return[s,n];if(s&&!Object.keys(this.namespaces||{}).map(o=>Vn(o)).includes(s))throw new Error(`Namespace '${s}' is not configured. Please call connect() first with namespace config.`);if(s&&n)return[s,n];const r=Vn(Object.keys(this.namespaces)[0]),i=this.rpcProviders[r].getDefaultChain();return[r,i]}async requestAccounts(){const[e]=this.validateChain();return await this.getProvider(e).requestAccounts()}async onChainChanged({currentCaipChainId:e,previousCaipChainId:s,internal:n=!1}){if(!this.namespaces)return;const[r,i]=this.validateChain(e);i&&(this.updateNamespaceChain(r,i),n?(this.events.emit("chainChanged",i),this.emitAccountsChangedOnChainChange({namespace:r,currentCaipChainId:e,previousCaipChainId:s})):this.getProvider(r).setDefaultChain(i),await this.persist("namespaces",this.namespaces))}emitAccountsChangedOnChainChange({namespace:e,currentCaipChainId:s,previousCaipChainId:n}){var r,i;try{if(n===s)return;const o=(i=(r=this.session)==null?void 0:r.namespaces[e])==null?void 0:i.accounts;if(!o)return;const a=o.filter(c=>c.includes(`${s}:`)).map(mu);if(!_s(a))return;this.events.emit("accountsChanged",a)}catch(o){this.logger.warn("Failed to emit accountsChanged on chain change",o)}}updateNamespaceChain(e,s){if(!this.namespaces)return;const n=this.namespaces[e]?e:`${e}:${s}`,r={chains:[],methods:[],events:[],defaultChain:s};this.namespaces[n]?this.namespaces[n]&&(this.namespaces[n].defaultChain=s):this.namespaces[n]=r}onConnect(){this.createProviders(),this.events.emit("connect",{session:this.session})}async cleanup(){this.namespaces=void 0,this.optionalNamespaces=void 0,this.sessionProperties=void 0,await this.deleteFromStore("namespaces"),await this.deleteFromStore("optionalNamespaces"),await this.deleteFromStore("sessionProperties"),this.session=void 0,this.cleanupPendingPairings({deletePairings:!0}),await this.cleanupStorage()}async persist(e,s){var n;const r=((n=this.session)==null?void 0:n.topic)||"";await this.client.core.storage.setItem(`${fi}/${e}${r}`,s)}async getFromStore(e){var s;const n=((s=this.session)==null?void 0:s.topic)||"";return await this.client.core.storage.getItem(`${fi}/${e}${n}`)}async deleteFromStore(e){var s;const n=((s=this.session)==null?void 0:s.topic)||"";await this.client.core.storage.removeItem(`${fi}/${e}${n}`)}async cleanupStorage(){var e;try{if(((e=this.client)==null?void 0:e.session.length)>0)return;const s=await this.client.core.storage.getKeys();for(const n of s)n.startsWith(fi)&&await this.client.core.storage.removeItem(n)}catch(s){this.logger.warn("Failed to cleanup storage",s)}}};const ws={EIP155:x.CHAIN.EVM,CONNECTOR_TYPE_WALLET_CONNECT:"WALLET_CONNECT",CONNECTOR_TYPE_INJECTED:"INJECTED",CONNECTOR_TYPE_ANNOUNCED:"ANNOUNCED",CONNECTOR_TYPE_AUTH:"AUTH"},jr={NetworkImageIds:{1:"ba0ba0cd-17c6-4806-ad93-f9d174f17900",42161:"3bff954d-5cb0-47a0-9a23-d20192e74600",43114:"30c46e53-e989-45fb-4549-be3bd4eb3b00",56:"93564157-2e8e-4ce7-81df-b264dbee9b00",250:"06b26297-fe0c-4733-5d6b-ffa5498aac00",10:"ab9c186a-c52f-464b-2906-ca59d760a400",137:"41d04d42-da3b-4453-8506-668cc0727900",5e3:"e86fae9b-b770-4eea-e520-150e12c81100",295:"6a97d510-cac8-4e58-c7ce-e8681b044c00",11155111:"e909ea0a-f92a-4512-c8fc-748044ea6800",84532:"a18a7ecd-e307-4360-4746-283182228e00",1301:"4eeea7ef-0014-4649-5d1d-07271a80f600",130:"2257980a-3463-48c6-cbac-a42d2a956e00",10143:"0a728e83-bacb-46db-7844-948f05434900",100:"02b53f6a-e3d4-479e-1cb4-21178987d100",9001:"f926ff41-260d-4028-635e-91913fc28e00",324:"b310f07f-4ef7-49f3-7073-2a0a39685800",314:"5a73b3dd-af74-424e-cae0-0de859ee9400",4689:"34e68754-e536-40da-c153-6ef2e7188a00",1088:"3897a66d-40b9-4833-162f-a2c90531c900",1284:"161038da-44ae-4ec7-1208-0ea569454b00",1285:"f1d73bb6-5450-4e18-38f7-fb6484264a00",7777777:"845c60df-d429-4991-e687-91ae45791600",42220:"ab781bbc-ccc6-418d-d32d-789b15da1f00",8453:"7289c336-3981-4081-c5f4-efc26ac64a00",1313161554:"3ff73439-a619-4894-9262-4470c773a100",2020:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",2021:"b8101fc0-9c19-4b6f-ec65-f6dfff106e00",80094:"e329c2c9-59b0-4a02-83e4-212ff3779900",2741:"fc2427d1-5af9-4a9c-8da5-6f94627cd900","5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp":"a1b58899-f671-4276-6a5e-56ca5bd59700","4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z":"a1b58899-f671-4276-6a5e-56ca5bd59700",EtWTRABZaYq6iMfeYKouRu166VU2xqa1:"a1b58899-f671-4276-6a5e-56ca5bd59700","000000000019d6689c085ae165831e93":"0b4838db-0161-4ffe-022d-532bf03dba00","000000000933ea01ad0ee984209779ba":"39354064-d79b-420b-065d-f980c4b78200","00000008819873e925422c1ff0f99f7c":"b3406e4a-bbfc-44fb-e3a6-89673c78b700"},ConnectorImageIds:{[x.CONNECTOR_ID.COINBASE]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[x.CONNECTOR_ID.COINBASE_SDK]:"0c2840c3-5b04-4c44-9661-fbd4b49e1800",[x.CONNECTOR_ID.SAFE]:"461db637-8616-43ce-035a-d89b8a1d5800",[x.CONNECTOR_ID.LEDGER]:"54a1aa77-d202-4f8d-0fb2-5d2bb6db0300",[x.CONNECTOR_ID.WALLET_CONNECT]:"ef1a1fcf-7fe8-4d69-bd6d-fda1345b4400",[x.CONNECTOR_ID.INJECTED]:"07ba87ed-43aa-4adf-4540-9e6a2b9cae00"},ConnectorNamesMap:{[x.CONNECTOR_ID.INJECTED]:"Browser Wallet",[x.CONNECTOR_ID.WALLET_CONNECT]:"WalletConnect",[x.CONNECTOR_ID.COINBASE]:"Coinbase",[x.CONNECTOR_ID.COINBASE_SDK]:"Coinbase",[x.CONNECTOR_ID.LEDGER]:"Ledger",[x.CONNECTOR_ID.SAFE]:"Safe"}},Ye={getCaipTokens(t){if(!t)return;const e={};return Object.entries(t).forEach(([s,n])=>{e[`${ws.EIP155}:${s}`]=n}),e},isLowerCaseMatch(t,e){return t?.toLowerCase()===e?.toLowerCase()},getActiveNamespaceConnectedToAuth(){const t=f.state.activeChain;return x.AUTH_CONNECTOR_SUPPORTED_CHAINS.find(e=>F.getConnectorId(e)===x.CONNECTOR_ID.AUTH&&e===t)},withRetry({conditionFn:t,intervalMs:e,maxRetries:s}){let n=0;return new Promise(r=>{async function i(){return n+=1,await t()?r(!0):n>=s?r(!1):(setTimeout(i,e),null)}i()})},userChainIdToChainNamespace(t){if(typeof t=="number")return x.CHAIN.EVM;const[e]=t.split(":");return e},getOtherAuthNamespaces(t){return t?x.AUTH_CONNECTOR_SUPPORTED_CHAINS.filter(n=>n!==t):[]},getConnectorStorageInfo(t,e){const n=B.getConnections()[e]??[];return{hasDisconnected:B.isConnectorDisconnected(t,e),hasConnected:n.some(r=>Ye.isLowerCaseMatch(r.connectorId,t))}}},mI={extractVersion(t){if(!t||typeof t!="string")return null;const e=/(?:[~^>=<]+\s*)?(?<version>\d+(?:\.\d+){0,2})(?:-[a-zA-Z]+\.\d+)?/u;return t.match(e)?.groups?.version||null},checkSDKVersion(t){this.extractVersion(t)},isValidVersion(t){return typeof t=="string"&&/^\d+\.\d+\.\d+$/u.test(t)},isOlder(t,e){const s=this.extractVersion(t),n=this.extractVersion(e);if(!s||!n)return!1;function r(a){const c=a.split(".").map(Number);for(;c.length<3;)c.push(0);return c}const i=r(s),o=r(n);for(let a=0;a<Math.max(i.length,o.length);a+=1){const c=i[a]||0,l=o[a]||0;if(c<l)return!0;if(c>l)return!1}return!1}},wI=new AbortController,Pt={EmbeddedWalletAbortController:wI,UniversalProviderErrors:{UNAUTHORIZED_DOMAIN_NOT_ALLOWED:{message:"Unauthorized: origin not allowed",alertErrorKey:"ORIGIN_NOT_ALLOWED"},JWT_VALIDATION_ERROR:{message:"JWT validation error: JWT Token is not yet valid",alertErrorKey:"JWT_TOKEN_NOT_VALID"},INVALID_KEY:{message:"Unauthorized: invalid key",alertErrorKey:"INVALID_PROJECT_ID"}},ALERT_ERRORS:{SWITCH_NETWORK_NOT_FOUND:{code:"APKT001",displayMessage:"Network Not Found",debugMessage:"The specified network is not recognized. Please ensure it is included in the `networks` array of your `createAppKit` configuration."},ORIGIN_NOT_ALLOWED:{code:"APKT002",displayMessage:"Invalid App Configuration",debugMessage:()=>`The origin ${Er()?window.origin:"unknown"} is not in your allow list. Please update your allowed domains at https://dashboard.reown.com.`},IFRAME_LOAD_FAILED:{code:"APKT003",displayMessage:"Network Error: Wallet Load Failed",debugMessage:()=>"Failed to load the embedded wallet. This may be due to network issues or server downtime. Please check your network connection and try again shortly. Contact support if the issue persists."},IFRAME_REQUEST_TIMEOUT:{code:"APKT004",displayMessage:"Wallet Request Timeout",debugMessage:()=>"The request to the embedded wallet timed out. Please check your network connection and try again shortly. Contact support if the issue persists."},UNVERIFIED_DOMAIN:{code:"APKT005",displayMessage:"Unverified Domain",debugMessage:()=>"Embedded wallet load failed. Ensure your domain is verified in https://dashboard.reown.com."},JWT_TOKEN_NOT_VALID:{code:"APKT006",displayMessage:"Session Expired",debugMessage:"Your session is invalid or expired. Please check your system’s date and time settings, then reconnect."},INVALID_PROJECT_ID:{code:"APKT007",displayMessage:"Invalid Project ID",debugMessage:"The specified project ID is invalid. Please visit https://dashboard.reown.com to obtain a valid project ID."},PROJECT_ID_NOT_CONFIGURED:{code:"APKT008",displayMessage:"Project ID Missing",debugMessage:"No project ID is configured. You can create and configure a project ID at https://dashboard.reown.com."},SERVER_ERROR_APP_CONFIGURATION:{code:"APKT009",displayMessage:"Server Error",debugMessage:t=>`Unable to fetch App Configuration. ${t}. Please check your network connection and try again shortly. Contact support if the issue persists.`},RATE_LIMITED_APP_CONFIGURATION:{code:"APKT010",displayMessage:"Rate Limited",debugMessage:"You have been rate limited while retrieving App Configuration. Please wait a few minutes and try again. Contact support if the issue persists."}},ALERT_WARNINGS:{LOCAL_CONFIGURATION_IGNORED:{debugMessage:t=>`[Reown Config Notice] ${t}`},INACTIVE_NAMESPACE_NOT_CONNECTED:{code:"APKTW001",displayMessage:"Inactive Namespace Not Connected",debugMessage:(t,e)=>`An error occurred while connecting an inactive namespace ${t}: "${e}"`},INVALID_EMAIL:{code:"APKTW002",displayMessage:"Invalid Email Address",debugMessage:"Please enter a valid email address"}}},Zh={TOKEN_ADDRESSES_BY_SYMBOL:{USDC:{8453:Df.asset,84532:Pf.asset}},getTokenSymbolByAddress(t){if(!t)return;const[e]=Object.entries(Zh.TOKEN_ADDRESSES_BY_SYMBOL).find(([s,n])=>Object.values(n).includes(t))??[];return e}};var Ko,Su;function yI(){if(Su)return Ko;Su=1;const t=La();Ko=r;const e=q().console||{},s={mapHttpRequest:g,mapHttpResponse:g,wrapRequestSerializer:b,wrapResponseSerializer:b,wrapErrorSerializer:b,req:g,res:g,err:h};function n(p,E){return Array.isArray(p)?p.filter(function(A){return A!=="!stdSerializers.err"}):p===!0?Object.keys(E):!1}function r(p){p=p||{},p.browser=p.browser||{};const E=p.browser.transmit;if(E&&typeof E.send!="function")throw Error("pino: transmit option must have a send function");const C=p.browser.write||e;p.browser.write&&(p.browser.asObject=!0);const A=p.serializers||{},S=n(p.browser.serialize,A);let $=p.browser.serialize;Array.isArray(p.browser.serialize)&&p.browser.serialize.indexOf("!stdSerializers.err")>-1&&($=!1);const O=["error","fatal","warn","info","debug","trace"];typeof C=="function"&&(C.error=C.fatal=C.warn=C.info=C.debug=C.trace=C),p.enabled===!1&&(p.level="silent");const v=p.level||"info",w=Object.create(C);w.log||(w.log=y),Object.defineProperty(w,"levelVal",{get:P}),Object.defineProperty(w,"level",{get:U,set:j});const I={transmit:E,serialize:S,asObject:p.browser.asObject,levels:O,timestamp:m(p)};w.levels=r.levels,w.level=v,w.setMaxListeners=w.getMaxListeners=w.emit=w.addListener=w.on=w.prependListener=w.once=w.prependOnceListener=w.removeListener=w.removeAllListeners=w.listeners=w.listenerCount=w.eventNames=w.write=w.flush=y,w.serializers=A,w._serialize=S,w._stdErrSerialize=$,w.child=k,E&&(w._logEvent=d());function P(){return this.level==="silent"?1/0:this.levels.values[this.level]}function U(){return this._level}function j(T){if(T!=="silent"&&!this.levels.values[T])throw Error("unknown level "+T);this._level=T,i(I,w,"error","log"),i(I,w,"fatal","error"),i(I,w,"warn","error"),i(I,w,"info","log"),i(I,w,"debug","log"),i(I,w,"trace","log")}function k(T,W){if(!T)throw new Error("missing bindings for child Pino");W=W||{},S&&T.serializers&&(W.serializers=T.serializers);const z=W.serializers;if(S&&z){var ie=Object.assign({},A,z),oe=p.browser.serialize===!0?Object.keys(ie):S;delete T.serializers,c([T],oe,ie,this._stdErrSerialize)}function se(X){this._childLevel=(X._childLevel|0)+1,this.error=l(X,T,"error"),this.fatal=l(X,T,"fatal"),this.warn=l(X,T,"warn"),this.info=l(X,T,"info"),this.debug=l(X,T,"debug"),this.trace=l(X,T,"trace"),ie&&(this.serializers=ie,this._serialize=oe),E&&(this._logEvent=d([].concat(X._logEvent.bindings,T)))}return se.prototype=this,new se(this)}return w}r.levels={values:{fatal:60,error:50,warn:40,info:30,debug:20,trace:10},labels:{10:"trace",20:"debug",30:"info",40:"warn",50:"error",60:"fatal"}},r.stdSerializers=s,r.stdTimeFunctions=Object.assign({},{nullTime:_,epochTime:N,unixTime:D,isoTime:M});function i(p,E,C,A){const S=Object.getPrototypeOf(E);E[C]=E.levelVal>E.levels.values[C]?y:S[C]?S[C]:e[C]||e[A]||y,o(p,E,C)}function o(p,E,C){!p.transmit&&E[C]===y||(E[C]=(function(A){return function(){const $=p.timestamp(),O=new Array(arguments.length),v=Object.getPrototypeOf&&Object.getPrototypeOf(this)===e?e:this;for(var w=0;w<O.length;w++)O[w]=arguments[w];if(p.serialize&&!p.asObject&&c(O,this._serialize,this.serializers,this._stdErrSerialize),p.asObject?A.call(v,a(this,C,O,$)):A.apply(v,O),p.transmit){const I=p.transmit.level||E.level,P=r.levels.values[I],U=r.levels.values[C];if(U<P)return;u(this,{ts:$,methodLevel:C,methodValue:U,transmitValue:r.levels.values[p.transmit.level||E.level],send:p.transmit.send,val:E.levelVal},O)}}})(E[C]))}function a(p,E,C,A){p._serialize&&c(C,p._serialize,p.serializers,p._stdErrSerialize);const S=C.slice();let $=S[0];const O={};A&&(O.time=A),O.level=r.levels.values[E];let v=(p._childLevel|0)+1;if(v<1&&(v=1),$!==null&&typeof $=="object"){for(;v--&&typeof S[0]=="object";)Object.assign(O,S.shift());$=S.length?t(S.shift(),S):void 0}else typeof $=="string"&&($=t(S.shift(),S));return $!==void 0&&(O.msg=$),O}function c(p,E,C,A){for(const S in p)if(A&&p[S]instanceof Error)p[S]=r.stdSerializers.err(p[S]);else if(typeof p[S]=="object"&&!Array.isArray(p[S]))for(const $ in p[S])E&&E.indexOf($)>-1&&$ in C&&(p[S][$]=C[$](p[S][$]))}function l(p,E,C){return function(){const A=new Array(1+arguments.length);A[0]=E;for(var S=1;S<A.length;S++)A[S]=arguments[S-1];return p[C].apply(this,A)}}function u(p,E,C){const A=E.send,S=E.ts,$=E.methodLevel,O=E.methodValue,v=E.val,w=p._logEvent.bindings;c(C,p._serialize||Object.keys(p.serializers),p.serializers,p._stdErrSerialize===void 0?!0:p._stdErrSerialize),p._logEvent.ts=S,p._logEvent.messages=C.filter(function(I){return w.indexOf(I)===-1}),p._logEvent.level.label=$,p._logEvent.level.value=O,A($,p._logEvent,v),p._logEvent=d(w)}function d(p){return{ts:0,messages:[],bindings:p||[],level:{label:"",value:0}}}function h(p){const E={type:p.constructor.name,msg:p.message,stack:p.stack};for(const C in p)E[C]===void 0&&(E[C]=p[C]);return E}function m(p){return typeof p.timestamp=="function"?p.timestamp:p.timestamp===!1?_:N}function g(){return{}}function b(p){return p}function y(){}function _(){return!1}function N(){return Date.now()}function D(){return Math.round(Date.now()/1e3)}function M(){return new Date(Date.now()).toISOString()}function q(){function p(E){return typeof E<"u"&&E}try{return typeof globalThis<"u"||Object.defineProperty(Object.prototype,"globalThis",{get:function(){return delete Object.prototype.globalThis,this.globalThis=this},configurable:!0}),globalThis}catch{return p(self)||p(window)||p(this)||{}}}return Ko}var Mn=yI();const Qh=Yu(Mn),bI={level:"info"},lc=1e3*1024;class EI{constructor(e){this.nodeValue=e,this.sizeInBytes=new TextEncoder().encode(this.nodeValue).length,this.next=null}get value(){return this.nodeValue}get size(){return this.sizeInBytes}}let Tu=class{constructor(e){this.head=null,this.tail=null,this.lengthInNodes=0,this.maxSizeInBytes=e,this.sizeInBytes=0}append(e){const s=new EI(e);if(s.size>this.maxSizeInBytes)throw new Error(`[LinkedList] Value too big to insert into list: ${e} with size ${s.size}`);for(;this.size+s.size>this.maxSizeInBytes;)this.shift();this.head?(this.tail&&(this.tail.next=s),this.tail=s):(this.head=s,this.tail=s),this.lengthInNodes++,this.sizeInBytes+=s.size}shift(){if(!this.head)return;const e=this.head;this.head=this.head.next,this.head||(this.tail=null),this.lengthInNodes--,this.sizeInBytes-=e.size}toArray(){const e=[];let s=this.head;for(;s!==null;)e.push(s.value),s=s.next;return e}get length(){return this.lengthInNodes}get size(){return this.sizeInBytes}toOrderedArray(){return Array.from(this)}[Symbol.iterator](){let e=this.head;return{next:()=>{if(!e)return{done:!0,value:null};const s=e.value;return e=e.next,{done:!1,value:s}}}}},ep=class{constructor(e,s=lc){this.level=e??"error",this.levelValue=Mn.levels.values[this.level],this.MAX_LOG_SIZE_IN_BYTES=s,this.logs=new Tu(this.MAX_LOG_SIZE_IN_BYTES)}forwardToConsole(e,s){s===Mn.levels.values.error?console.error(e):s===Mn.levels.values.warn?console.warn(e):s===Mn.levels.values.debug?console.debug(e):s===Mn.levels.values.trace?console.trace(e):console.log(e)}appendToLogs(e){this.logs.append(Rr({timestamp:new Date().toISOString(),log:e}));const s=typeof e=="string"?JSON.parse(e).level:e.level;s>=this.levelValue&&this.forwardToConsole(e,s)}getLogs(){return this.logs}clearLogs(){this.logs=new Tu(this.MAX_LOG_SIZE_IN_BYTES)}getLogArray(){return Array.from(this.logs)}logsToBlob(e){const s=this.getLogArray();return s.push(Rr({extraMetadata:e})),new Blob(s,{type:"application/json"})}},CI=class{constructor(e,s=lc){this.baseChunkLogger=new ep(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}downloadLogsBlobInBrowser(e){const s=URL.createObjectURL(this.logsToBlob(e)),n=document.createElement("a");n.href=s,n.download=`walletconnect-logs-${new Date().toISOString()}.txt`,document.body.appendChild(n),n.click(),document.body.removeChild(n),URL.revokeObjectURL(s)}},vI=class{constructor(e,s=lc){this.baseChunkLogger=new ep(e,s)}write(e){this.baseChunkLogger.appendToLogs(e)}getLogs(){return this.baseChunkLogger.getLogs()}clearLogs(){this.baseChunkLogger.clearLogs()}getLogArray(){return this.baseChunkLogger.getLogArray()}logsToBlob(e){return this.baseChunkLogger.logsToBlob(e)}};var AI=Object.defineProperty,II=Object.defineProperties,NI=Object.getOwnPropertyDescriptors,Ou=Object.getOwnPropertySymbols,_I=Object.prototype.hasOwnProperty,SI=Object.prototype.propertyIsEnumerable,ku=(t,e,s)=>e in t?AI(t,e,{enumerable:!0,configurable:!0,writable:!0,value:s}):t[e]=s,Vi=(t,e)=>{for(var s in e||(e={}))_I.call(e,s)&&ku(t,s,e[s]);if(Ou)for(var s of Ou(e))SI.call(e,s)&&ku(t,s,e[s]);return t},zi=(t,e)=>II(t,NI(e));function TI(t){return zi(Vi({},t),{level:t?.level||bI.level})}function OI(t){var e,s;const n=new CI((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Qh(zi(Vi({},t.opts),{level:"trace",browser:zi(Vi({},(s=t.opts)==null?void 0:s.browser),{write:r=>n.write(r)})})),chunkLoggerController:n}}function kI(t){var e;const s=new vI((e=t.opts)==null?void 0:e.level,t.maxSizeInBytes);return{logger:Qh(zi(Vi({},t.opts),{level:"trace"}),s),chunkLoggerController:s}}function DI(t){return typeof t.loggerOverride<"u"&&typeof t.loggerOverride!="string"?{logger:t.loggerOverride,chunkLoggerController:null}:typeof window<"u"?OI(t):kI(t)}const PI={createLogger(t,e="error"){const s=TI({level:e}),{logger:n}=DI({opts:s});return n.error=(...r)=>{for(const i of r)if(i instanceof Error){t(i,...r);return}t(void 0,...r)},n}},RI="rpc.walletconnect.org";function Du(t,e){const s=new URL("https://rpc.walletconnect.org/v1/");return s.searchParams.set("chainId",t),s.searchParams.set("projectId",e),s.toString()}const Go=["near:mainnet","solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp","eip155:1101","eip155:56","eip155:42161","eip155:7777777","eip155:59144","eip155:324","solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1","eip155:5000","solana:4sgjmw1sunhzsxgspuhpqldx6wiyjntz","eip155:80084","eip155:5003","eip155:100","eip155:8453","eip155:42220","eip155:1313161555","eip155:17000","eip155:1","eip155:300","eip155:1313161554","eip155:1329","eip155:84532","eip155:421614","eip155:11155111","eip155:8217","eip155:43114","solana:4uhcVJyU9pJkvQyS88uRDiswHXSCkY3z","eip155:999999999","eip155:11155420","eip155:80002","eip155:97","eip155:43113","eip155:137","eip155:10","eip155:1301","eip155:80094","eip155:80069","eip155:560048","eip155:31","eip155:2818","eip155:57054","eip155:911867","eip155:534351","eip155:1112","eip155:534352","eip155:1111","eip155:146","eip155:130","eip155:1284","eip155:30","eip155:2810","bip122:000000000019d6689c085ae165831e93","bip122:000000000933ea01ad0ee984209779ba"],jn={extendRpcUrlWithProjectId(t,e){let s=!1;try{s=new URL(t).host===RI}catch{s=!1}if(s){const n=new URL(t);return n.searchParams.has("projectId")||n.searchParams.set("projectId",e),n.toString()}return t},isCaipNetwork(t){return"chainNamespace"in t&&"caipNetworkId"in t},getChainNamespace(t){return this.isCaipNetwork(t)?t.chainNamespace:x.CHAIN.EVM},getCaipNetworkId(t){return this.isCaipNetwork(t)?t.caipNetworkId:`${x.CHAIN.EVM}:${t.id}`},getDefaultRpcUrl(t,e,s){const n=t.rpcUrls?.default?.http?.[0];return Go.includes(e)?Du(e,s):n||""},extendCaipNetwork(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:n}){const r=this.getChainNamespace(t),i=this.getCaipNetworkId(t),o=t.rpcUrls?.default?.http?.[0],a=this.getDefaultRpcUrl(t,i,s),c=t?.rpcUrls?.chainDefault?.http?.[0]||o,l=n?.[i]?.map(h=>h.url)||[],u=[...l,...a?[a]:[]],d=[...l];return c&&!d.includes(c)&&d.push(c),{...t,chainNamespace:r,caipNetworkId:i,assets:{imageId:jr.NetworkImageIds[t.id],imageUrl:e?.[t.id]},rpcUrls:{...t.rpcUrls,default:{http:u},chainDefault:{http:d}}}},extendCaipNetworks(t,{customNetworkImageUrls:e,projectId:s,customRpcUrls:n}){return t.map(r=>jn.extendCaipNetwork(r,{customNetworkImageUrls:e,customRpcUrls:n,projectId:s}))},getViemTransport(t,e,s){const n=[];return s?.forEach(r=>{n.push(ri(r.url,r.config))}),Go.includes(t.caipNetworkId)&&n.push(ri(Du(t.caipNetworkId,e),{fetchOptions:{headers:{"Content-Type":"text/plain"}}})),t?.rpcUrls?.default?.http?.forEach(r=>{n.push(ri(r))}),yc(n)},extendWagmiTransports(t,e,s){if(Go.includes(t.caipNetworkId)){const n=this.getDefaultRpcUrl(t,t.caipNetworkId,e);return yc([s,ri(n)])}return s},getUnsupportedNetwork(t){return{id:t.split(":")[1],caipNetworkId:t,name:x.UNSUPPORTED_NETWORK_NAME,chainNamespace:t.split(":")[0],nativeCurrency:{name:"",decimals:0,symbol:""},rpcUrls:{default:{http:[]}}}},getCaipNetworkFromStorage(t){const e=B.getActiveCaipNetworkId(),s=f.getAllRequestedCaipNetworks(),n=Array.from(f.state.chains?.keys()||[]),r=e?.split(":")[0],i=r?n.includes(r):!1,o=s?.find(c=>c.caipNetworkId===e);return i&&!o&&e?this.getUnsupportedNetwork(e):o||t||s?.[0]}},xI={ACCOUNT_TABS:[{label:"Tokens"},{label:"Activity"}],VIEW_DIRECTION:{Next:"next",Prev:"prev"},DEFAULT_CONNECT_METHOD_ORDER:["email","social","wallet"],ANIMATION_DURATIONS:{HeaderText:120},VIEWS_WITH_LEGAL_FOOTER:["Connect","ConnectWallets","OnRampTokenSelect","OnRampFiatSelect","OnRampProviders"],VIEWS_WITH_DEFAULT_FOOTER:["Networks"]},Ir={filterOutDuplicatesByRDNS(t){const e=R.state.enableEIP6963?F.state.connectors:[],s=B.getRecentWallets(),n=e.map(a=>a.info?.rdns).filter(Boolean),r=s.map(a=>a.rdns).filter(Boolean),i=n.concat(r);if(i.includes("io.metamask.mobile")&&J.isMobile()){const a=i.indexOf("io.metamask.mobile");i[a]="io.metamask"}return t.filter(a=>!(a?.rdns&&i.includes(String(a.rdns))||!a?.rdns&&e.some(l=>l.name===a.name)))},filterOutDuplicatesByIds(t){const e=F.state.connectors.filter(a=>a.type==="ANNOUNCED"||a.type==="INJECTED"),s=B.getRecentWallets(),n=e.map(a=>a.explorerId),r=s.map(a=>a.id),i=n.concat(r);return t.filter(a=>!i.includes(a?.id))},filterOutDuplicateWallets(t){const e=this.filterOutDuplicatesByRDNS(t);return this.filterOutDuplicatesByIds(e)},markWalletsAsInstalled(t){const{connectors:e}=F.state,{featuredWalletIds:s}=R.state,n=e.filter(o=>o.type==="ANNOUNCED").reduce((o,a)=>(a.info?.rdns&&(o[a.info.rdns]=!0),o),{});return t.map(o=>({...o,installed:!!o.rdns&&!!n[o.rdns??""]})).sort((o,a)=>{const c=Number(a.installed)-Number(o.installed);if(c!==0)return c;if(s?.length){const l=s.indexOf(o.id),u=s.indexOf(a.id);if(l!==-1&&u!==-1)return l-u;if(l!==-1)return-1;if(u!==-1)return 1}return 0})},getConnectOrderMethod(t,e){const s=t?.connectMethodsOrder||R.state.features?.connectMethodsOrder,n=e||F.state.connectors;if(s)return s;const{injected:r,announced:i}=Ni.getConnectorsByType(n,te.state.recommended,te.state.featured),o=r.filter(Ni.showConnector),a=i.filter(Ni.showConnector);return o.length||a.length?["wallet","email","social"]:xI.DEFAULT_CONNECT_METHOD_ORDER},isExcluded(t){const e=!!t.rdns&&te.state.excludedWallets.some(n=>n.rdns===t.rdns),s=!!t.name&&te.state.excludedWallets.some(n=>Ye.isLowerCaseMatch(n.name,t.name));return e||s},markWalletsWithDisplayIndex(t){return t.map((e,s)=>({...e,display_index:s}))}},Ni={getConnectorsByType(t,e,s){const{customWallets:n}=R.state,r=B.getRecentWallets(),i=Ir.filterOutDuplicateWallets(e),o=Ir.filterOutDuplicateWallets(s),a=t.filter(d=>d.type==="MULTI_CHAIN"),c=t.filter(d=>d.type==="ANNOUNCED"),l=t.filter(d=>d.type==="INJECTED"),u=t.filter(d=>d.type==="EXTERNAL");return{custom:n,recent:r,external:u,multiChain:a,announced:c,injected:l,recommended:i,featured:o}},showConnector(t){const e=t.info?.rdns,s=!!e&&te.state.excludedWallets.some(r=>!!r.rdns&&r.rdns===e),n=!!t.name&&te.state.excludedWallets.some(r=>Ye.isLowerCaseMatch(r.name,t.name));return!(t.type==="INJECTED"&&(t.name==="Browser Wallet"&&(!J.isMobile()||J.isMobile()&&!e&&!G.checkInstalled())||s||n)||(t.type==="ANNOUNCED"||t.type==="EXTERNAL")&&(s||n))},getIsConnectedWithWC(){return Array.from(f.state.chains.values()).some(s=>F.getConnectorId(s.namespace)===x.CONNECTOR_ID.WALLET_CONNECT)},getConnectorTypeOrder({recommended:t,featured:e,custom:s,recent:n,announced:r,injected:i,multiChain:o,external:a,overriddenConnectors:c=R.state.features?.connectorTypeOrder??[]}){const u=[{type:"walletConnect",isEnabled:!0},{type:"recent",isEnabled:n.length>0},{type:"injected",isEnabled:[...i,...r,...o].length>0},{type:"featured",isEnabled:e.length>0},{type:"custom",isEnabled:s&&s.length>0},{type:"external",isEnabled:a.length>0},{type:"recommended",isEnabled:t.length>0}].filter(g=>g.isEnabled),d=new Set(u.map(g=>g.type)),h=c.filter(g=>d.has(g)).map(g=>({type:g,isEnabled:!0})),m=u.filter(({type:g})=>!h.some(({type:y})=>y===g));return Array.from(new Set([...h,...m].map(({type:g})=>g)))},sortConnectorsByExplorerWallet(t){return[...t].sort((e,s)=>e.explorerWallet&&s.explorerWallet?(e.explorerWallet.order??0)-(s.explorerWallet.order??0):e.explorerWallet?-1:s.explorerWallet?1:0)},getAuthName({email:t,socialUsername:e,socialProvider:s}){return e?s&&s==="discord"&&e.endsWith("0")?e.slice(0,-1):e:t.length>30?`${t.slice(0,-3)}...`:t},async fetchProviderData(t){try{if(t.name==="Browser Wallet"&&!J.isMobile())return{accounts:[],chainId:void 0};if(t.id===x.CONNECTOR_ID.AUTH)return{accounts:[],chainId:void 0};const[e,s]=await Promise.all([t.provider?.request({method:"eth_accounts"}),t.provider?.request({method:"eth_chainId"}).then(n=>Number(n))]);return{accounts:e,chainId:s}}catch(e){return console.warn(`Failed to fetch provider data for ${t.name}`,e),{accounts:[],chainId:void 0}}},getFilteredCustomWallets(t){const e=B.getRecentWallets(),s=F.state.connectors.map(o=>o.info?.rdns).filter(Boolean),n=e.map(o=>o.rdns).filter(Boolean),r=s.concat(n);if(r.includes("io.metamask.mobile")&&J.isMobile()){const o=r.indexOf("io.metamask.mobile");r[o]="io.metamask"}return t.filter(o=>!r.includes(String(o?.rdns)))},hasWalletConnector(t){return F.state.connectors.some(e=>e.id===t.id||e.name===t.name)},isWalletCompatibleWithCurrentChain(t){const e=f.state.activeChain;return e&&t.chains?t.chains.some(s=>{const n=s.split(":")[0];return e===n}):!0},getFilteredRecentWallets(){return B.getRecentWallets().filter(s=>!Ir.isExcluded(s)).filter(s=>!this.hasWalletConnector(s)).filter(s=>this.isWalletCompatibleWithCurrentChain(s))},getCappedRecommendedWallets(t){const{connectors:e}=F.state,{customWallets:s,featuredWalletIds:n}=R.state,r=e.find(N=>N.id==="walletConnect"),i=e.filter(N=>N.type==="INJECTED"||N.type==="ANNOUNCED"||N.type==="MULTI_CHAIN");if(!r&&!i.length&&!s?.length)return[];const o=Qo.isEmailEnabled(),a=Qo.isSocialsEnabled(),c=i.filter(N=>N.name!=="Browser Wallet"),l=n?.length||0,u=s?.length||0,d=c.length||0,h=o?1:0,m=a?1:0,g=l+u+d+h+m,y=Math.max(0,4-g);return y<=0?[]:Ir.filterOutDuplicateWallets(t).slice(0,y)}};const _i=globalThis,uc=_i.ShadowRoot&&(_i.ShadyCSS===void 0||_i.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,dc=Symbol(),Pu=new WeakMap;let tp=class{constructor(e,s,n){if(this._$cssResult$=!0,n!==dc)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=s}get styleSheet(){let e=this.o;const s=this.t;if(uc&&e===void 0){const n=s!==void 0&&s.length===1;n&&(e=Pu.get(s)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),n&&Pu.set(s,e))}return e}toString(){return this.cssText}};const Ht=t=>new tp(typeof t=="string"?t:t+"",void 0,dc),zs=(t,...e)=>{const s=t.length===1?t[0]:e.reduce((n,r,i)=>n+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+t[i+1],t[0]);return new tp(s,t,dc)},$I=(t,e)=>{if(uc)t.adoptedStyleSheets=e.map(s=>s instanceof CSSStyleSheet?s:s.styleSheet);else for(const s of e){const n=document.createElement("style"),r=_i.litNonce;r!==void 0&&n.setAttribute("nonce",r),n.textContent=s.cssText,t.appendChild(n)}},Ru=uc?t=>t:t=>t instanceof CSSStyleSheet?(e=>{let s="";for(const n of e.cssRules)s+=n.cssText;return Ht(s)})(t):t;const{is:UI,defineProperty:LI,getOwnPropertyDescriptor:BI,getOwnPropertyNames:MI,getOwnPropertySymbols:jI,getPrototypeOf:FI}=Object,uo=globalThis,xu=uo.trustedTypes,qI=xu?xu.emptyScript:"",WI=uo.reactiveElementPolyfillSupport,Pr=(t,e)=>t,xa={toAttribute(t,e){switch(e){case Boolean:t=t?qI:null;break;case Object:case Array:t=t==null?t:JSON.stringify(t)}return t},fromAttribute(t,e){let s=t;switch(e){case Boolean:s=t!==null;break;case Number:s=t===null?null:Number(t);break;case Object:case Array:try{s=JSON.parse(t)}catch{s=null}}return s}},sp=(t,e)=>!UI(t,e),$u={attribute:!0,type:String,converter:xa,reflect:!1,useDefault:!1,hasChanged:sp};Symbol.metadata??=Symbol("metadata"),uo.litPropertyMetadata??=new WeakMap;let Fn=class extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,s=$u){if(s.state&&(s.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(e)&&((s=Object.create(s)).wrapped=!0),this.elementProperties.set(e,s),!s.noAccessor){const n=Symbol(),r=this.getPropertyDescriptor(e,n,s);r!==void 0&&LI(this.prototype,e,r)}}static getPropertyDescriptor(e,s,n){const{get:r,set:i}=BI(this.prototype,e)??{get(){return this[s]},set(o){this[s]=o}};return{get:r,set(o){const a=r?.call(this);i?.call(this,o),this.requestUpdate(e,a,n)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??$u}static _$Ei(){if(this.hasOwnProperty(Pr("elementProperties")))return;const e=FI(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(Pr("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(Pr("properties"))){const s=this.properties,n=[...MI(s),...jI(s)];for(const r of n)this.createProperty(r,s[r])}const e=this[Symbol.metadata];if(e!==null){const s=litPropertyMetadata.get(e);if(s!==void 0)for(const[n,r]of s)this.elementProperties.set(n,r)}this._$Eh=new Map;for(const[s,n]of this.elementProperties){const r=this._$Eu(s,n);r!==void 0&&this._$Eh.set(r,s)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const s=[];if(Array.isArray(e)){const n=new Set(e.flat(1/0).reverse());for(const r of n)s.unshift(Ru(r))}else e!==void 0&&s.push(Ru(e));return s}static _$Eu(e,s){const n=s.attribute;return n===!1?void 0:typeof n=="string"?n:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,s=this.constructor.elementProperties;for(const n of s.keys())this.hasOwnProperty(n)&&(e.set(n,this[n]),delete this[n]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return $I(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,s,n){this._$AK(e,n)}_$ET(e,s){const n=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,n);if(r!==void 0&&n.reflect===!0){const i=(n.converter?.toAttribute!==void 0?n.converter:xa).toAttribute(s,n.type);this._$Em=e,i==null?this.removeAttribute(r):this.setAttribute(r,i),this._$Em=null}}_$AK(e,s){const n=this.constructor,r=n._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const i=n.getPropertyOptions(r),o=typeof i.converter=="function"?{fromAttribute:i.converter}:i.converter?.fromAttribute!==void 0?i.converter:xa;this._$Em=r;const a=o.fromAttribute(s,i.type);this[r]=a??this._$Ej?.get(r)??a,this._$Em=null}}requestUpdate(e,s,n,r=!1,i){if(e!==void 0){const o=this.constructor;if(r===!1&&(i=this[e]),n??=o.getPropertyOptions(e),!((n.hasChanged??sp)(i,s)||n.useDefault&&n.reflect&&i===this._$Ej?.get(e)&&!this.hasAttribute(o._$Eu(e,n))))return;this.C(e,s,n)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(e,s,{useDefault:n,reflect:r,wrapped:i},o){n&&!(this._$Ej??=new Map).has(e)&&(this._$Ej.set(e,o??s??this[e]),i!==!0||o!==void 0)||(this._$AL.has(e)||(this.hasUpdated||n||(s=void 0),this._$AL.set(e,s)),r===!0&&this._$Em!==e&&(this._$Eq??=new Set).add(e))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(s){Promise.reject(s)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[r,i]of this._$Ep)this[r]=i;this._$Ep=void 0}const n=this.constructor.elementProperties;if(n.size>0)for(const[r,i]of n){const{wrapped:o}=i,a=this[r];o!==!0||this._$AL.has(r)||a===void 0||this.C(r,void 0,i,a)}}let e=!1;const s=this._$AL;try{e=this.shouldUpdate(s),e?(this.willUpdate(s),this._$EO?.forEach(n=>n.hostUpdate?.()),this.update(s)):this._$EM()}catch(n){throw e=!1,this._$EM(),n}e&&this._$AE(s)}willUpdate(e){}_$AE(e){this._$EO?.forEach(s=>s.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Eq&&=this._$Eq.forEach(s=>this._$ET(s,this[s])),this._$EM()}updated(e){}firstUpdated(e){}};Fn.elementStyles=[],Fn.shadowRootOptions={mode:"open"},Fn[Pr("elementProperties")]=new Map,Fn[Pr("finalized")]=new Map,WI?.({ReactiveElement:Fn}),(uo.reactiveElementVersions??=[]).push("2.1.2");const hc=globalThis,Uu=t=>t,Hi=hc.trustedTypes,Lu=Hi?Hi.createPolicy("lit-html",{createHTML:t=>t}):void 0,np="$lit$",Hs=`lit$${Math.random().toFixed(9).slice(2)}$`,rp="?"+Hs,VI=`<${rp}>`,vn=document,Fr=()=>vn.createComment(""),qr=t=>t===null||typeof t!="object"&&typeof t!="function",pc=Array.isArray,zI=t=>pc(t)||typeof t?.[Symbol.iterator]=="function",Yo=`[
|
|
14
|
-
\f\r]`,br=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Bu=/-->/g,Mu=/>/g,rn=RegExp(`>|${Yo}(?:([^\\s"'>=/]+)(${Yo}*=${Yo}*(?:[^
|
|
15
|
-
\f\r"'\`<>=]|("|')|))|$)`,"g"),ju=/'/g,Fu=/"/g,ip=/^(?:script|style|textarea|title)$/i,op=t=>(e,...s)=>({_$litType$:t,strings:e,values:s}),i_=op(1),o_=op(2),er=Symbol.for("lit-noChange"),Ve=Symbol.for("lit-nothing"),qu=new WeakMap,mn=vn.createTreeWalker(vn,129);function ap(t,e){if(!pc(t)||!t.hasOwnProperty("raw"))throw Error("invalid template strings array");return Lu!==void 0?Lu.createHTML(e):e}const HI=(t,e)=>{const s=t.length-1,n=[];let r,i=e===2?"<svg>":e===3?"<math>":"",o=br;for(let a=0;a<s;a++){const c=t[a];let l,u,d=-1,h=0;for(;h<c.length&&(o.lastIndex=h,u=o.exec(c),u!==null);)h=o.lastIndex,o===br?u[1]==="!--"?o=Bu:u[1]!==void 0?o=Mu:u[2]!==void 0?(ip.test(u[2])&&(r=RegExp("</"+u[2],"g")),o=rn):u[3]!==void 0&&(o=rn):o===rn?u[0]===">"?(o=r??br,d=-1):u[1]===void 0?d=-2:(d=o.lastIndex-u[2].length,l=u[1],o=u[3]===void 0?rn:u[3]==='"'?Fu:ju):o===Fu||o===ju?o=rn:o===Bu||o===Mu?o=br:(o=rn,r=void 0);const m=o===rn&&t[a+1].startsWith("/>")?" ":"";i+=o===br?c+VI:d>=0?(n.push(l),c.slice(0,d)+np+c.slice(d)+Hs+m):c+Hs+(d===-2?a:m)}return[ap(t,i+(t[s]||"<?>")+(e===2?"</svg>":e===3?"</math>":"")),n]};class Wr{constructor({strings:e,_$litType$:s},n){let r;this.parts=[];let i=0,o=0;const a=e.length-1,c=this.parts,[l,u]=HI(e,s);if(this.el=Wr.createElement(l,n),mn.currentNode=this.el.content,s===2||s===3){const d=this.el.content.firstChild;d.replaceWith(...d.childNodes)}for(;(r=mn.nextNode())!==null&&c.length<a;){if(r.nodeType===1){if(r.hasAttributes())for(const d of r.getAttributeNames())if(d.endsWith(np)){const h=u[o++],m=r.getAttribute(d).split(Hs),g=/([.?@])?(.*)/.exec(h);c.push({type:1,index:i,name:g[2],strings:m,ctor:g[1]==="."?GI:g[1]==="?"?YI:g[1]==="@"?JI:ho}),r.removeAttribute(d)}else d.startsWith(Hs)&&(c.push({type:6,index:i}),r.removeAttribute(d));if(ip.test(r.tagName)){const d=r.textContent.split(Hs),h=d.length-1;if(h>0){r.textContent=Hi?Hi.emptyScript:"";for(let m=0;m<h;m++)r.append(d[m],Fr()),mn.nextNode(),c.push({type:2,index:++i});r.append(d[h],Fr())}}}else if(r.nodeType===8)if(r.data===rp)c.push({type:2,index:i});else{let d=-1;for(;(d=r.data.indexOf(Hs,d+1))!==-1;)c.push({type:7,index:i}),d+=Hs.length-1}i++}}static createElement(e,s){const n=vn.createElement("template");return n.innerHTML=e,n}}function tr(t,e,s=t,n){if(e===er)return e;let r=n!==void 0?s._$Co?.[n]:s._$Cl;const i=qr(e)?void 0:e._$litDirective$;return r?.constructor!==i&&(r?._$AO?.(!1),i===void 0?r=void 0:(r=new i(t),r._$AT(t,s,n)),n!==void 0?(s._$Co??=[])[n]=r:s._$Cl=r),r!==void 0&&(e=tr(t,r._$AS(t,e.values),r,n)),e}class KI{constructor(e,s){this._$AV=[],this._$AN=void 0,this._$AD=e,this._$AM=s}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(e){const{el:{content:s},parts:n}=this._$AD,r=(e?.creationScope??vn).importNode(s,!0);mn.currentNode=r;let i=mn.nextNode(),o=0,a=0,c=n[0];for(;c!==void 0;){if(o===c.index){let l;c.type===2?l=new si(i,i.nextSibling,this,e):c.type===1?l=new c.ctor(i,c.name,c.strings,this,e):c.type===6&&(l=new XI(i,this,e)),this._$AV.push(l),c=n[++a]}o!==c?.index&&(i=mn.nextNode(),o++)}return mn.currentNode=vn,r}p(e){let s=0;for(const n of this._$AV)n!==void 0&&(n.strings!==void 0?(n._$AI(e,n,s),s+=n.strings.length-2):n._$AI(e[s])),s++}}class si{get _$AU(){return this._$AM?._$AU??this._$Cv}constructor(e,s,n,r){this.type=2,this._$AH=Ve,this._$AN=void 0,this._$AA=e,this._$AB=s,this._$AM=n,this.options=r,this._$Cv=r?.isConnected??!0}get parentNode(){let e=this._$AA.parentNode;const s=this._$AM;return s!==void 0&&e?.nodeType===11&&(e=s.parentNode),e}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(e,s=this){e=tr(this,e,s),qr(e)?e===Ve||e==null||e===""?(this._$AH!==Ve&&this._$AR(),this._$AH=Ve):e!==this._$AH&&e!==er&&this._(e):e._$litType$!==void 0?this.$(e):e.nodeType!==void 0?this.T(e):zI(e)?this.k(e):this._(e)}O(e){return this._$AA.parentNode.insertBefore(e,this._$AB)}T(e){this._$AH!==e&&(this._$AR(),this._$AH=this.O(e))}_(e){this._$AH!==Ve&&qr(this._$AH)?this._$AA.nextSibling.data=e:this.T(vn.createTextNode(e)),this._$AH=e}$(e){const{values:s,_$litType$:n}=e,r=typeof n=="number"?this._$AC(e):(n.el===void 0&&(n.el=Wr.createElement(ap(n.h,n.h[0]),this.options)),n);if(this._$AH?._$AD===r)this._$AH.p(s);else{const i=new KI(r,this),o=i.u(this.options);i.p(s),this.T(o),this._$AH=i}}_$AC(e){let s=qu.get(e.strings);return s===void 0&&qu.set(e.strings,s=new Wr(e)),s}k(e){pc(this._$AH)||(this._$AH=[],this._$AR());const s=this._$AH;let n,r=0;for(const i of e)r===s.length?s.push(n=new si(this.O(Fr()),this.O(Fr()),this,this.options)):n=s[r],n._$AI(i),r++;r<s.length&&(this._$AR(n&&n._$AB.nextSibling,r),s.length=r)}_$AR(e=this._$AA.nextSibling,s){for(this._$AP?.(!1,!0,s);e!==this._$AB;){const n=Uu(e).nextSibling;Uu(e).remove(),e=n}}setConnected(e){this._$AM===void 0&&(this._$Cv=e,this._$AP?.(e))}}class ho{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(e,s,n,r,i){this.type=1,this._$AH=Ve,this._$AN=void 0,this.element=e,this.name=s,this._$AM=r,this.options=i,n.length>2||n[0]!==""||n[1]!==""?(this._$AH=Array(n.length-1).fill(new String),this.strings=n):this._$AH=Ve}_$AI(e,s=this,n,r){const i=this.strings;let o=!1;if(i===void 0)e=tr(this,e,s,0),o=!qr(e)||e!==this._$AH&&e!==er,o&&(this._$AH=e);else{const a=e;let c,l;for(e=i[0],c=0;c<i.length-1;c++)l=tr(this,a[n+c],s,c),l===er&&(l=this._$AH[c]),o||=!qr(l)||l!==this._$AH[c],l===Ve?e=Ve:e!==Ve&&(e+=(l??"")+i[c+1]),this._$AH[c]=l}o&&!r&&this.j(e)}j(e){e===Ve?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,e??"")}}class GI extends ho{constructor(){super(...arguments),this.type=3}j(e){this.element[this.name]=e===Ve?void 0:e}}class YI extends ho{constructor(){super(...arguments),this.type=4}j(e){this.element.toggleAttribute(this.name,!!e&&e!==Ve)}}class JI extends ho{constructor(e,s,n,r,i){super(e,s,n,r,i),this.type=5}_$AI(e,s=this){if((e=tr(this,e,s,0)??Ve)===er)return;const n=this._$AH,r=e===Ve&&n!==Ve||e.capture!==n.capture||e.once!==n.once||e.passive!==n.passive,i=e!==Ve&&(n===Ve||r);r&&this.element.removeEventListener(this.name,this,n),i&&this.element.addEventListener(this.name,this,e),this._$AH=e}handleEvent(e){typeof this._$AH=="function"?this._$AH.call(this.options?.host??this.element,e):this._$AH.handleEvent(e)}}class XI{constructor(e,s,n){this.element=e,this.type=6,this._$AN=void 0,this._$AM=s,this.options=n}get _$AU(){return this._$AM._$AU}_$AI(e){tr(this,e)}}const ZI=hc.litHtmlPolyfillSupport;ZI?.(Wr,si),(hc.litHtmlVersions??=[]).push("3.3.3");const QI=(t,e,s)=>{const n=s?.renderBefore??e;let r=n._$litPart$;if(r===void 0){const i=s?.renderBefore??null;n._$litPart$=r=new si(e.insertBefore(Fr(),i),i,void 0,s??{})}return r._$AI(t),r};const fc=globalThis;class Si extends Fn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const s=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=QI(s,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return er}}Si._$litElement$=!0,Si.finalized=!0,fc.litElementHydrateSupport?.({LitElement:Si});const eN=fc.litElementPolyfillSupport;eN?.({LitElement:Si});(fc.litElementVersions??=[]).push("4.2.2");const tN={black:"#202020",white:"#FFFFFF",white010:"rgba(255, 255, 255, 0.1)",accent010:"rgba(9, 136, 240, 0.1)",accent020:"rgba(9, 136, 240, 0.2)",accent030:"rgba(9, 136, 240, 0.3)",accent040:"rgba(9, 136, 240, 0.4)",accent050:"rgba(9, 136, 240, 0.5)",accent060:"rgba(9, 136, 240, 0.6)",accent070:"rgba(9, 136, 240, 0.7)",accent080:"rgba(9, 136, 240, 0.8)",accent090:"rgba(9, 136, 240, 0.9)",accent100:"rgba(9, 136, 240, 1.0)",accentSecondary010:"rgba(199, 185, 148, 0.1)",accentSecondary020:"rgba(199, 185, 148, 0.2)",accentSecondary030:"rgba(199, 185, 148, 0.3)",accentSecondary040:"rgba(199, 185, 148, 0.4)",accentSecondary050:"rgba(199, 185, 148, 0.5)",accentSecondary060:"rgba(199, 185, 148, 0.6)",accentSecondary070:"rgba(199, 185, 148, 0.7)",accentSecondary080:"rgba(199, 185, 148, 0.8)",accentSecondary090:"rgba(199, 185, 148, 0.9)",accentSecondary100:"rgba(199, 185, 148, 1.0)",productWalletKit:"#FFB800",productAppKit:"#FF573B",productCloud:"#0988F0",productDocumentation:"#008847",neutrals050:"#F6F6F6",neutrals100:"#F3F3F3",neutrals200:"#E9E9E9",neutrals300:"#D0D0D0",neutrals400:"#BBB",neutrals500:"#9A9A9A",neutrals600:"#6C6C6C",neutrals700:"#4F4F4F",neutrals800:"#363636",neutrals900:"#2A2A2A",neutrals1000:"#252525",semanticSuccess010:"rgba(48, 164, 107, 0.1)",semanticSuccess020:"rgba(48, 164, 107, 0.2)",semanticSuccess030:"rgba(48, 164, 107, 0.3)",semanticSuccess040:"rgba(48, 164, 107, 0.4)",semanticSuccess050:"rgba(48, 164, 107, 0.5)",semanticSuccess060:"rgba(48, 164, 107, 0.6)",semanticSuccess070:"rgba(48, 164, 107, 0.7)",semanticSuccess080:"rgba(48, 164, 107, 0.8)",semanticSuccess090:"rgba(48, 164, 107, 0.9)",semanticSuccess100:"rgba(48, 164, 107, 1.0)",semanticError010:"rgba(223, 74, 52, 0.1)",semanticError020:"rgba(223, 74, 52, 0.2)",semanticError030:"rgba(223, 74, 52, 0.3)",semanticError040:"rgba(223, 74, 52, 0.4)",semanticError050:"rgba(223, 74, 52, 0.5)",semanticError060:"rgba(223, 74, 52, 0.6)",semanticError070:"rgba(223, 74, 52, 0.7)",semanticError080:"rgba(223, 74, 52, 0.8)",semanticError090:"rgba(223, 74, 52, 0.9)",semanticError100:"rgba(223, 74, 52, 1.0)",semanticWarning010:"rgba(243, 161, 63, 0.1)",semanticWarning020:"rgba(243, 161, 63, 0.2)",semanticWarning030:"rgba(243, 161, 63, 0.3)",semanticWarning040:"rgba(243, 161, 63, 0.4)",semanticWarning050:"rgba(243, 161, 63, 0.5)",semanticWarning060:"rgba(243, 161, 63, 0.6)",semanticWarning070:"rgba(243, 161, 63, 0.7)",semanticWarning080:"rgba(243, 161, 63, 0.8)",semanticWarning090:"rgba(243, 161, 63, 0.9)",semanticWarning100:"rgba(243, 161, 63, 1.0)"},Ki={core:{backgroundAccentPrimary:"#0988F0",backgroundAccentCertified:"#C7B994",backgroundWalletKit:"#FFB800",backgroundAppKit:"#FF573B",backgroundCloud:"#0988F0",backgroundDocumentation:"#008847",backgroundSuccess:"rgba(48, 164, 107, 0.20)",backgroundError:"rgba(223, 74, 52, 0.20)",backgroundWarning:"rgba(243, 161, 63, 0.20)",textAccentPrimary:"#0988F0",textAccentCertified:"#C7B994",textWalletKit:"#FFB800",textAppKit:"#FF573B",textCloud:"#0988F0",textDocumentation:"#008847",textSuccess:"#30A46B",textError:"#DF4A34",textWarning:"#F3A13F",borderAccentPrimary:"#0988F0",borderSecondary:"#C7B994",borderSuccess:"#30A46B",borderError:"#DF4A34",borderWarning:"#F3A13F",foregroundAccent010:"rgba(9, 136, 240, 0.1)",foregroundAccent020:"rgba(9, 136, 240, 0.2)",foregroundAccent040:"rgba(9, 136, 240, 0.4)",foregroundAccent060:"rgba(9, 136, 240, 0.6)",foregroundSecondary020:"rgba(199, 185, 148, 0.2)",foregroundSecondary040:"rgba(199, 185, 148, 0.4)",foregroundSecondary060:"rgba(199, 185, 148, 0.6)",iconAccentPrimary:"#0988F0",iconAccentCertified:"#C7B994",iconSuccess:"#30A46B",iconError:"#DF4A34",iconWarning:"#F3A13F",glass010:"rgba(255, 255, 255, 0.1)",zIndex:"9999"},dark:{overlay:"rgba(0, 0, 0, 0.50)",backgroundPrimary:"#202020",backgroundInvert:"#FFFFFF",textPrimary:"#FFFFFF",textSecondary:"#9A9A9A",textTertiary:"#BBBBBB",textInvert:"#202020",borderPrimary:"#2A2A2A",borderPrimaryDark:"#363636",borderSecondary:"#4F4F4F",foregroundPrimary:"#252525",foregroundSecondary:"#2A2A2A",foregroundTertiary:"#363636",iconDefault:"#9A9A9A",iconInverse:"#FFFFFF"},light:{overlay:"rgba(230 , 230, 230, 0.5)",backgroundPrimary:"#FFFFFF",borderPrimaryDark:"#E9E9E9",backgroundInvert:"#202020",textPrimary:"#202020",textSecondary:"#9A9A9A",textTertiary:"#6C6C6C",textInvert:"#FFFFFF",borderPrimary:"#E9E9E9",borderSecondary:"#D0D0D0",foregroundPrimary:"#F3F3F3",foregroundSecondary:"#E9E9E9",foregroundTertiary:"#D0D0D0",iconDefault:"#9A9A9A",iconInverse:"#202020"}},sN={1:"4px",2:"8px",10:"10px",3:"12px",4:"16px",6:"24px",5:"20px",8:"32px",16:"64px",20:"80px",32:"128px",64:"256px",128:"512px",round:"9999px"},nN={0:"0px","01":"2px",1:"4px",2:"8px",3:"12px",4:"16px",5:"20px",6:"24px",7:"28px",8:"32px",9:"36px",10:"40px",12:"48px",14:"56px",16:"64px",20:"80px",32:"128px",64:"256px"},rN={regular:"KHTeka",mono:"KHTekaMono"},iN={regular:"400",medium:"500"},oN={h1:"50px",h2:"44px",h3:"38px",h4:"32px",h5:"26px",h6:"20px",large:"16px",medium:"14px",small:"12px"},aN={"h1-regular-mono":{lineHeight:"50px",letterSpacing:"-3px"},"h1-regular":{lineHeight:"50px",letterSpacing:"-1px"},"h1-medium":{lineHeight:"50px",letterSpacing:"-0.84px"},"h2-regular-mono":{lineHeight:"44px",letterSpacing:"-2.64px"},"h2-regular":{lineHeight:"44px",letterSpacing:"-0.88px"},"h2-medium":{lineHeight:"44px",letterSpacing:"-0.88px"},"h3-regular-mono":{lineHeight:"38px",letterSpacing:"-2.28px"},"h3-regular":{lineHeight:"38px",letterSpacing:"-0.76px"},"h3-medium":{lineHeight:"38px",letterSpacing:"-0.76px"},"h4-regular-mono":{lineHeight:"32px",letterSpacing:"-1.92px"},"h4-regular":{lineHeight:"32px",letterSpacing:"-0.32px"},"h4-medium":{lineHeight:"32px",letterSpacing:"-0.32px"},"h5-regular-mono":{lineHeight:"26px",letterSpacing:"-1.56px"},"h5-regular":{lineHeight:"26px",letterSpacing:"-0.26px"},"h5-medium":{lineHeight:"26px",letterSpacing:"-0.26px"},"h6-regular-mono":{lineHeight:"20px",letterSpacing:"-1.2px"},"h6-regular":{lineHeight:"20px",letterSpacing:"-0.6px"},"h6-medium":{lineHeight:"20px",letterSpacing:"-0.6px"},"lg-regular-mono":{lineHeight:"16px",letterSpacing:"-0.96px"},"lg-regular":{lineHeight:"18px",letterSpacing:"-0.16px"},"lg-medium":{lineHeight:"18px",letterSpacing:"-0.16px"},"md-regular-mono":{lineHeight:"14px",letterSpacing:"-0.84px"},"md-regular":{lineHeight:"16px",letterSpacing:"-0.14px"},"md-medium":{lineHeight:"16px",letterSpacing:"-0.14px"},"sm-regular-mono":{lineHeight:"12px",letterSpacing:"-0.72px"},"sm-regular":{lineHeight:"14px",letterSpacing:"-0.12px"},"sm-medium":{lineHeight:"14px",letterSpacing:"-0.12px"}},cN={"ease-out-power-2":"cubic-bezier(0.23, 0.09, 0.08, 1.13)","ease-out-power-1":"cubic-bezier(0.12, 0.04, 0.2, 1.06)","ease-in-power-2":"cubic-bezier(0.92, -0.13, 0.77, 0.91)","ease-in-power-1":"cubic-bezier(0.88, -0.06, 0.8, 0.96)","ease-inout-power-2":"cubic-bezier(0.77, 0.09, 0.23, 1.13)","ease-inout-power-1":"cubic-bezier(0.88, 0.04, 0.12, 1.06)"},lN={xl:"400ms",lg:"200ms",md:"125ms",sm:"75ms"},$a={colors:tN,fontFamily:rN,fontWeight:iN,textSize:oN,typography:aN,tokens:{core:Ki.core,theme:Ki.dark},borderRadius:sN,spacing:nN,durations:lN,easings:cN},Wu="--apkt",bs={createCSSVariables(t){const e={},s={};function n(i,o,a=""){for(const[c,l]of Object.entries(i)){const u=a?`${a}-${c}`:c;l&&typeof l=="object"&&Object.keys(l).length?(o[c]={},n(l,o[c],u)):typeof l=="string"&&(o[c]=`${Wu}-${u}`)}}function r(i,o){for(const[a,c]of Object.entries(i))c&&typeof c=="object"?(o[a]={},r(c,o[a])):typeof c=="string"&&(o[a]=`var(${c})`)}return n(t,e),r(e,s),{cssVariables:e,cssVariablesVarPrefix:s}},assignCSSVariables(t,e){const s={};function n(r,i,o){for(const[a,c]of Object.entries(r)){const l=o?`${o}-${a}`:a,u=i[a];c&&typeof c=="object"?n(c,u,l):typeof u=="string"&&(s[`${Wu}-${l}`]=u)}}return n(t,e),s},createRootStyles(t,e){const s={...$a,tokens:{...$a.tokens,theme:t==="light"?Ki.light:Ki.dark}},{cssVariables:n}=bs.createCSSVariables(s),r=bs.assignCSSVariables(n,s),i=bs.generateW3MVariables(e),o=bs.generateW3MOverrides(e),a=bs.generateScaledVariables(e),c=bs.generateBaseVariables(r),l={...r,...c,...i,...o,...a},u=bs.applyColorMixToVariables(e,l),d={...l,...u};return`:root {${Object.entries(d).map(([m,g])=>`${m}:${g.replace("/[:;{}</>]/g","")};`).join("")}}`},generateW3MVariables(t){if(!t)return{};const e={};return e["--w3m-font-family"]=t["--w3m-font-family"]||"KHTeka",e["--w3m-accent"]=t["--w3m-accent"]||"#0988F0",e["--w3m-color-mix"]=t["--w3m-color-mix"]||"#000",e["--w3m-color-mix-strength"]=`${t["--w3m-color-mix-strength"]||0}%`,e["--w3m-font-size-master"]=t["--w3m-font-size-master"]||"10px",e["--w3m-border-radius-master"]=t["--w3m-border-radius-master"]||"4px",e},generateW3MOverrides(t){if(!t)return{};const e={};if(t["--w3m-accent"]){const s=t["--w3m-accent"];e["--apkt-tokens-core-iconAccentPrimary"]=s,e["--apkt-tokens-core-borderAccentPrimary"]=s,e["--apkt-tokens-core-textAccentPrimary"]=s,e["--apkt-tokens-core-backgroundAccentPrimary"]=s}return t["--w3m-font-family"]&&(e["--apkt-fontFamily-regular"]=t["--w3m-font-family"]),t["--w3m-z-index"]&&(e["--apkt-tokens-core-zIndex"]=`${t["--w3m-z-index"]}`),e},generateScaledVariables(t){if(!t)return{};const e={};if(t["--w3m-font-size-master"]){const s=parseFloat(t["--w3m-font-size-master"].replace("px",""));e["--apkt-textSize-h1"]=`${Number(s)*5}px`,e["--apkt-textSize-h2"]=`${Number(s)*4.4}px`,e["--apkt-textSize-h3"]=`${Number(s)*3.8}px`,e["--apkt-textSize-h4"]=`${Number(s)*3.2}px`,e["--apkt-textSize-h5"]=`${Number(s)*2.6}px`,e["--apkt-textSize-h6"]=`${Number(s)*2}px`,e["--apkt-textSize-large"]=`${Number(s)*1.6}px`,e["--apkt-textSize-medium"]=`${Number(s)*1.4}px`,e["--apkt-textSize-small"]=`${Number(s)*1.2}px`}if(t["--w3m-border-radius-master"]){const s=parseFloat(t["--w3m-border-radius-master"].replace("px",""));e["--apkt-borderRadius-1"]=`${Number(s)}px`,e["--apkt-borderRadius-2"]=`${Number(s)*2}px`,e["--apkt-borderRadius-3"]=`${Number(s)*3}px`,e["--apkt-borderRadius-4"]=`${Number(s)*4}px`,e["--apkt-borderRadius-5"]=`${Number(s)*5}px`,e["--apkt-borderRadius-6"]=`${Number(s)*6}px`,e["--apkt-borderRadius-8"]=`${Number(s)*8}px`,e["--apkt-borderRadius-16"]=`${Number(s)*16}px`,e["--apkt-borderRadius-20"]=`${Number(s)*20}px`,e["--apkt-borderRadius-32"]=`${Number(s)*32}px`,e["--apkt-borderRadius-64"]=`${Number(s)*64}px`,e["--apkt-borderRadius-128"]=`${Number(s)*128}px`}return e},generateColorMixCSS(t,e){if(!t?.["--w3m-color-mix"]||!t["--w3m-color-mix-strength"])return"";const s=t["--w3m-color-mix"],n=t["--w3m-color-mix-strength"];if(!n||n===0)return"";const r=Object.keys(e||{}).filter(o=>{const a=o.includes("-tokens-core-background")||o.includes("-tokens-core-text")||o.includes("-tokens-core-border")||o.includes("-tokens-core-foreground")||o.includes("-tokens-core-icon")||o.includes("-tokens-theme-background")||o.includes("-tokens-theme-text")||o.includes("-tokens-theme-border")||o.includes("-tokens-theme-foreground")||o.includes("-tokens-theme-icon"),c=o.includes("-borderRadius-")||o.includes("-spacing-")||o.includes("-textSize-")||o.includes("-fontFamily-")||o.includes("-fontWeight-")||o.includes("-typography-")||o.includes("-duration-")||o.includes("-ease-")||o.includes("-path-")||o.includes("-width-")||o.includes("-height-")||o.includes("-visual-size-")||o.includes("-modal-width")||o.includes("-cover");return a&&!c});return r.length===0?"":` @supports (background: color-mix(in srgb, white 50%, black)) {
|
|
16
|
-
:root {
|
|
17
|
-
${r.map(o=>{const a=e?.[o]||"";return a.includes("color-mix")||a.startsWith("#")||a.startsWith("rgb")?`${o}: color-mix(in srgb, ${s} ${n}%, ${a});`:`${o}: color-mix(in srgb, ${s} ${n}%, var(${o}-base, ${a}));`}).join("")}
|
|
18
|
-
}
|
|
19
|
-
}`},generateBaseVariables(t){const e={},s=t["--apkt-tokens-theme-backgroundPrimary"];s&&(e["--apkt-tokens-theme-backgroundPrimary-base"]=s);const n=t["--apkt-tokens-core-backgroundAccentPrimary"];return n&&(e["--apkt-tokens-core-backgroundAccentPrimary-base"]=n),e},applyColorMixToVariables(t,e){const s={};if(e?.["--apkt-tokens-theme-backgroundPrimary"]&&(s["--apkt-tokens-theme-backgroundPrimary"]="var(--apkt-tokens-theme-backgroundPrimary-base)"),e?.["--apkt-tokens-core-backgroundAccentPrimary"]&&(s["--apkt-tokens-core-backgroundAccentPrimary"]="var(--apkt-tokens-core-backgroundAccentPrimary-base)"),!t?.["--w3m-color-mix"]||!t["--w3m-color-mix-strength"])return s;const n=t["--w3m-color-mix"],r=t["--w3m-color-mix-strength"];if(!r||r===0)return s;const i=Object.keys(e||{}).filter(o=>{const a=o.includes("-tokens-core-background")||o.includes("-tokens-core-text")||o.includes("-tokens-core-border")||o.includes("-tokens-core-foreground")||o.includes("-tokens-core-icon")||o.includes("-tokens-theme-background")||o.includes("-tokens-theme-text")||o.includes("-tokens-theme-border")||o.includes("-tokens-theme-foreground")||o.includes("-tokens-theme-icon")||o.includes("-tokens-theme-overlay"),c=o.includes("-borderRadius-")||o.includes("-spacing-")||o.includes("-textSize-")||o.includes("-fontFamily-")||o.includes("-fontWeight-")||o.includes("-typography-")||o.includes("-duration-")||o.includes("-ease-")||o.includes("-path-")||o.includes("-width-")||o.includes("-height-")||o.includes("-visual-size-")||o.includes("-modal-width")||o.includes("-cover");return a&&!c});return i.length===0||i.forEach(o=>{const a=e?.[o]||"";o.endsWith("-base")||(o==="--apkt-tokens-theme-backgroundPrimary"||o==="--apkt-tokens-core-backgroundAccentPrimary"?s[o]=`color-mix(in srgb, ${n} ${r}%, var(${o}-base))`:a.includes("color-mix")||a.startsWith("#")||a.startsWith("rgb")?s[o]=`color-mix(in srgb, ${n} ${r}%, ${a})`:s[o]=`color-mix(in srgb, ${n} ${r}%, var(${o}-base, ${a}))`)}),s}},{cssVariablesVarPrefix:uN}=bs.createCSSVariables($a);function a_(t,...e){return zs(t,...e.map(s=>Ht(typeof s=="function"?s(uN):s)))}let un,wn,as,Kt,Gi;const ys={"KHTeka-500-woff2":"https://fonts.reown.com/KHTeka-Medium.woff2","KHTeka-400-woff2":"https://fonts.reown.com/KHTeka-Regular.woff2","KHTeka-300-woff2":"https://fonts.reown.com/KHTeka-Light.woff2","KHTekaMono-400-woff2":"https://fonts.reown.com/KHTekaMono-Regular.woff2","KHTeka-500-woff":"https://fonts.reown.com/KHTeka-Light.woff","KHTeka-400-woff":"https://fonts.reown.com/KHTeka-Regular.woff","KHTeka-300-woff":"https://fonts.reown.com/KHTeka-Light.woff","KHTekaMono-400-woff":"https://fonts.reown.com/KHTekaMono-Regular.woff"};function Yi(t,e="dark"){un&&document.head.removeChild(un),un=document.createElement("style"),un.textContent=bs.createRootStyles(e,t),document.head.appendChild(un)}function c_(t,e="dark"){if(Gi=t,wn=document.createElement("style"),as=document.createElement("style"),Kt=document.createElement("style"),wn.textContent=Jn(t).core.cssText,as.textContent=Jn(t).dark.cssText,Kt.textContent=Jn(t).light.cssText,document.head.appendChild(wn),document.head.appendChild(as),document.head.appendChild(Kt),Yi(t,e),Ua(e),!t?.["--w3m-font-family"])for(const[s,n]of Object.entries(ys)){const r=document.createElement("link");r.rel="preload",r.href=n,r.as="font",r.type=s.includes("woff2")?"font/woff2":"font/woff",r.crossOrigin="anonymous",document.head.appendChild(r)}Ua(e)}function Ua(t="dark"){as&&Kt&&un&&(t==="light"?(Yi(Gi,t),as.removeAttribute("media"),Kt.media="enabled"):(Yi(Gi,t),Kt.removeAttribute("media"),as.media="enabled"))}function dN(t){if(Gi=t,wn&&as&&Kt&&(wn.textContent=Jn(t).core.cssText,as.textContent=Jn(t).dark.cssText,Kt.textContent=Jn(t).light.cssText,t?.["--w3m-font-family"])){const e=t["--w3m-font-family"];wn.textContent=wn.textContent?.replace("font-family: KHTeka",`font-family: ${e}`),as.textContent=as.textContent?.replace("font-family: KHTeka",`font-family: ${e}`),Kt.textContent=Kt.textContent?.replace("font-family: KHTeka",`font-family: ${e}`)}if(un){const e=Kt?.media==="enabled"?"light":"dark";Yi(t,e)}}function Jn(t){const e=!!t?.["--w3m-font-family"];return{core:zs`
|
|
20
|
-
${e?zs``:zs`
|
|
21
|
-
@font-face {
|
|
22
|
-
font-family: 'KHTeka';
|
|
23
|
-
src:
|
|
24
|
-
url(${Ht(ys["KHTeka-400-woff2"])}) format('woff2'),
|
|
25
|
-
url(${Ht(ys["KHTeka-400-woff"])}) format('woff');
|
|
26
|
-
font-weight: 400;
|
|
27
|
-
font-style: normal;
|
|
28
|
-
font-display: swap;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
@font-face {
|
|
32
|
-
font-family: 'KHTeka';
|
|
33
|
-
src:
|
|
34
|
-
url(${Ht(ys["KHTeka-300-woff2"])}) format('woff2'),
|
|
35
|
-
url(${Ht(ys["KHTeka-300-woff"])}) format('woff');
|
|
36
|
-
font-weight: 300;
|
|
37
|
-
font-style: normal;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
@font-face {
|
|
41
|
-
font-family: 'KHTekaMono';
|
|
42
|
-
src:
|
|
43
|
-
url(${Ht(ys["KHTekaMono-400-woff2"])}) format('woff2'),
|
|
44
|
-
url(${Ht(ys["KHTekaMono-400-woff"])}) format('woff');
|
|
45
|
-
font-weight: 400;
|
|
46
|
-
font-style: normal;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
@font-face {
|
|
50
|
-
font-family: 'KHTeka';
|
|
51
|
-
src:
|
|
52
|
-
url(${Ht(ys["KHTeka-400-woff2"])}) format('woff2'),
|
|
53
|
-
url(${Ht(ys["KHTeka-400-woff"])}) format('woff');
|
|
54
|
-
font-weight: 400;
|
|
55
|
-
font-style: normal;
|
|
56
|
-
}
|
|
57
|
-
`}
|
|
58
|
-
|
|
59
|
-
@keyframes w3m-shake {
|
|
60
|
-
0% {
|
|
61
|
-
transform: scale(1) rotate(0deg);
|
|
62
|
-
}
|
|
63
|
-
20% {
|
|
64
|
-
transform: scale(1) rotate(-1deg);
|
|
65
|
-
}
|
|
66
|
-
40% {
|
|
67
|
-
transform: scale(1) rotate(1.5deg);
|
|
68
|
-
}
|
|
69
|
-
60% {
|
|
70
|
-
transform: scale(1) rotate(-1.5deg);
|
|
71
|
-
}
|
|
72
|
-
80% {
|
|
73
|
-
transform: scale(1) rotate(1deg);
|
|
74
|
-
}
|
|
75
|
-
100% {
|
|
76
|
-
transform: scale(1) rotate(0deg);
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
@keyframes w3m-iframe-fade-out {
|
|
80
|
-
0% {
|
|
81
|
-
opacity: 1;
|
|
82
|
-
}
|
|
83
|
-
100% {
|
|
84
|
-
opacity: 0;
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
@keyframes w3m-iframe-zoom-in {
|
|
88
|
-
0% {
|
|
89
|
-
transform: translateY(50px);
|
|
90
|
-
opacity: 0;
|
|
91
|
-
}
|
|
92
|
-
100% {
|
|
93
|
-
transform: translateY(0px);
|
|
94
|
-
opacity: 1;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
@keyframes w3m-iframe-zoom-in-mobile {
|
|
98
|
-
0% {
|
|
99
|
-
transform: scale(0.95);
|
|
100
|
-
opacity: 0;
|
|
101
|
-
}
|
|
102
|
-
100% {
|
|
103
|
-
transform: scale(1);
|
|
104
|
-
opacity: 1;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
:root {
|
|
108
|
-
--apkt-modal-width: 370px;
|
|
109
|
-
|
|
110
|
-
--apkt-visual-size-inherit: inherit;
|
|
111
|
-
--apkt-visual-size-sm: 40px;
|
|
112
|
-
--apkt-visual-size-md: 55px;
|
|
113
|
-
--apkt-visual-size-lg: 80px;
|
|
114
|
-
|
|
115
|
-
--apkt-path-network-sm: path(
|
|
116
|
-
'M15.4 2.1a5.21 5.21 0 0 1 5.2 0l11.61 6.7a5.21 5.21 0 0 1 2.61 4.52v13.4c0 1.87-1 3.59-2.6 4.52l-11.61 6.7c-1.62.93-3.6.93-5.22 0l-11.6-6.7a5.21 5.21 0 0 1-2.61-4.51v-13.4c0-1.87 1-3.6 2.6-4.52L15.4 2.1Z'
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
--apkt-path-network-md: path(
|
|
120
|
-
'M43.4605 10.7248L28.0485 1.61089C25.5438 0.129705 22.4562 0.129705 19.9515 1.61088L4.53951 10.7248C2.03626 12.2051 0.5 14.9365 0.5 17.886V36.1139C0.5 39.0635 2.03626 41.7949 4.53951 43.2752L19.9515 52.3891C22.4562 53.8703 25.5438 53.8703 28.0485 52.3891L43.4605 43.2752C45.9637 41.7949 47.5 39.0635 47.5 36.114V17.8861C47.5 14.9365 45.9637 12.2051 43.4605 10.7248Z'
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
--apkt-path-network-lg: path(
|
|
124
|
-
'M78.3244 18.926L50.1808 2.45078C45.7376 -0.150261 40.2624 -0.150262 35.8192 2.45078L7.6756 18.926C3.23322 21.5266 0.5 26.3301 0.5 31.5248V64.4752C0.5 69.6699 3.23322 74.4734 7.6756 77.074L35.8192 93.5492C40.2624 96.1503 45.7376 96.1503 50.1808 93.5492L78.3244 77.074C82.7668 74.4734 85.5 69.6699 85.5 64.4752V31.5248C85.5 26.3301 82.7668 21.5266 78.3244 18.926Z'
|
|
125
|
-
);
|
|
126
|
-
|
|
127
|
-
--apkt-width-network-sm: 36px;
|
|
128
|
-
--apkt-width-network-md: 48px;
|
|
129
|
-
--apkt-width-network-lg: 86px;
|
|
130
|
-
|
|
131
|
-
--apkt-duration-dynamic: 0ms;
|
|
132
|
-
--apkt-height-network-sm: 40px;
|
|
133
|
-
--apkt-height-network-md: 54px;
|
|
134
|
-
--apkt-height-network-lg: 96px;
|
|
135
|
-
}
|
|
136
|
-
`,dark:zs`
|
|
137
|
-
:root {
|
|
138
|
-
}
|
|
139
|
-
`,light:zs`
|
|
140
|
-
:root {
|
|
141
|
-
}
|
|
142
|
-
`}}const l_=zs`
|
|
143
|
-
div,
|
|
144
|
-
span,
|
|
145
|
-
iframe,
|
|
146
|
-
a,
|
|
147
|
-
img,
|
|
148
|
-
form,
|
|
149
|
-
button,
|
|
150
|
-
label,
|
|
151
|
-
*::after,
|
|
152
|
-
*::before {
|
|
153
|
-
margin: 0;
|
|
154
|
-
padding: 0;
|
|
155
|
-
box-sizing: border-box;
|
|
156
|
-
font-style: normal;
|
|
157
|
-
text-rendering: optimizeSpeed;
|
|
158
|
-
-webkit-font-smoothing: antialiased;
|
|
159
|
-
-moz-osx-font-smoothing: grayscale;
|
|
160
|
-
-webkit-tap-highlight-color: transparent;
|
|
161
|
-
backface-visibility: hidden;
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
:host {
|
|
165
|
-
font-family: var(--apkt-fontFamily-regular);
|
|
166
|
-
}
|
|
167
|
-
`,u_=zs`
|
|
168
|
-
button,
|
|
169
|
-
a {
|
|
170
|
-
cursor: pointer;
|
|
171
|
-
display: flex;
|
|
172
|
-
justify-content: center;
|
|
173
|
-
align-items: center;
|
|
174
|
-
position: relative;
|
|
175
|
-
|
|
176
|
-
will-change: background-color, color, border, box-shadow, width, height, transform, opacity;
|
|
177
|
-
outline: none;
|
|
178
|
-
border: none;
|
|
179
|
-
text-decoration: none;
|
|
180
|
-
transition:
|
|
181
|
-
background-color var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
182
|
-
color var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
183
|
-
border var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
184
|
-
box-shadow var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
185
|
-
width var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
186
|
-
height var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
187
|
-
transform var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
188
|
-
opacity var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
189
|
-
scale var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2),
|
|
190
|
-
border-radius var(--apkt-durations-lg) var(--apkt-easings-ease-out-power-2);
|
|
191
|
-
will-change:
|
|
192
|
-
background-color, color, border, box-shadow, width, height, transform, opacity, scale,
|
|
193
|
-
border-radius;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
a:active:not([disabled]),
|
|
197
|
-
button:active:not([disabled]) {
|
|
198
|
-
scale: 0.975;
|
|
199
|
-
transform-origin: center;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
button:disabled {
|
|
203
|
-
cursor: default;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
input {
|
|
207
|
-
border: none;
|
|
208
|
-
outline: none;
|
|
209
|
-
appearance: none;
|
|
210
|
-
}
|
|
211
|
-
`,Ti={hexStringToNumber(t){const e=t.startsWith("0x")?t.slice(2):t;return parseInt(e,16)},numberToHexString(t){return`0x${t.toString(16)}`},async getUserInfo(t){const[e,s]=await Promise.all([Ti.getAddresses(t),Ti.getChainId(t)]);return{chainId:s,addresses:e}},async getChainId(t){const e=await t.request({method:"eth_chainId"});return Number(e)},async getAddress(t){const[e]=await t.request({method:"eth_accounts"});return e},async getAddresses(t){return await t.request({method:"eth_accounts"})},async addEthereumChain(t,e){const s=e.rpcUrls.chainDefault?.http||[];await t.request({method:"wallet_addEthereumChain",params:[{chainId:Ti.numberToHexString(e.id),rpcUrls:[...s],chainName:e.name,nativeCurrency:{name:e.nativeCurrency.name,decimals:e.nativeCurrency.decimals,symbol:e.nativeCurrency.symbol},blockExplorerUrls:[e.blockExplorers?.default.url],iconUrls:[jr.NetworkImageIds[e.id]]}]})}},Ln={ACCOUNT_INDEXES:{PAYMENT:0,ORDINAL:1}};function ar(t){return{formatters:void 0,fees:void 0,serializers:void 0,...t}}const Vu=ar({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"}),zu=ar({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"});ar({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"});ar({id:"000000000019d6689c085ae165831e93",caipNetworkId:"bip122:000000000019d6689c085ae165831e93",chainNamespace:"bip122",name:"Bitcoin",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}}});ar({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});ar({id:"00000008819873e925422c1ff0f99f7c",caipNetworkId:"bip122:00000008819873e925422c1ff0f99f7c",chainNamespace:"bip122",name:"Bitcoin Signet",nativeCurrency:{name:"Bitcoin",symbol:"BTC",decimals:8},rpcUrls:{default:{http:["https://rpc.walletconnect.org/v1"]}},testnet:!0});const hN={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"]},Yt={RPC_ERROR_CODE:{USER_REJECTED:5e3,USER_REJECTED_METHODS:5002},getMethodsByChainNamespace(t){return hN[t]||[]},createDefaultNamespace(t){return{methods:this.getMethodsByChainNamespace(t),events:["accountsChanged","chainChanged"],chains:[],rpcMap:{}}},applyNamespaceOverrides(t,e){if(!e)return{...t};const s={...t},n=new Set;if(e.methods&&Object.keys(e.methods).forEach(r=>n.add(r)),e.chains&&Object.keys(e.chains).forEach(r=>n.add(r)),e.events&&Object.keys(e.events).forEach(r=>n.add(r)),e.rpcMap&&Object.keys(e.rpcMap).forEach(r=>{const[i]=r.split(":");i&&n.add(i)}),n.forEach(r=>{s[r]||(s[r]=this.createDefaultNamespace(r))}),e.methods&&Object.entries(e.methods).forEach(([r,i])=>{s[r]&&(s[r].methods=i)}),e.chains&&Object.entries(e.chains).forEach(([r,i])=>{s[r]&&(s[r].chains=i)}),e.events&&Object.entries(e.events).forEach(([r,i])=>{s[r]&&(s[r].events=i)}),e.rpcMap){const r=new Set;Object.entries(e.rpcMap).forEach(([i,o])=>{const[a,c]=i.split(":");!a||!c||!s[a]||(s[a].rpcMap||(s[a].rpcMap={}),r.has(a)||(s[a].rpcMap={},r.add(a)),s[a].rpcMap[c]=o)})}return s},createNamespaces(t,e){const s=t.reduce((n,r)=>{const{id:i,chainNamespace:o,rpcUrls:a}=r,c=a.default.http[0];n[o]||(n[o]=this.createDefaultNamespace(o));const l=`${o}:${i}`,u=n[o];switch(u.chains.push(l),l){case Vu.caipNetworkId:u.chains.push(Vu.deprecatedCaipNetworkId);break;case zu.caipNetworkId:u.chains.push(zu.deprecatedCaipNetworkId);break}return u?.rpcMap&&c&&(u.rpcMap[i]=c),n},{});return this.applyNamespaceOverrides(s,e)},resolveReownName:async t=>{const e=await Sr.resolveName(t);return(Object.values(e?.addresses)||[])[0]?.address||!1},getChainsFromNamespaces(t={}){return Object.values(t).flatMap(e=>{const s=e.chains||[],n=e.accounts.map(r=>{const[i,o]=r.split(":");return`${i}:${o}`});return Array.from(new Set([...s,...n]))})},isSessionEventData(t){return typeof t=="object"&&t!==null&&"id"in t&&"topic"in t&&"params"in t&&typeof t.params=="object"&&t.params!==null&&"chainId"in t.params&&"event"in t.params&&typeof t.params.event=="object"&&t.params.event!==null},isUserRejectedRequestError(t){try{if(typeof t=="object"&&t!==null){const e=t,s=typeof e.code=="number",n=s&&e.code===Yt.RPC_ERROR_CODE.USER_REJECTED_METHODS,r=s&&e.code===Yt.RPC_ERROR_CODE.USER_REJECTED;return n||r}return!1}catch{return!1}},isOriginAllowed(t,e,s){for(const n of[...e,...s])if(n.includes("*")){const i=`^${n.replace(/[.*+?^${}()|[\]\\]/gu,"\\$&").replace(/\\\*/gu,".*")}$`;if(new RegExp(i,"u").test(t))return!0}else try{if(new URL(n).origin===t)return!0}catch{if(n===t)return!0}return!1},listenWcProvider({universalProvider:t,namespace:e,onConnect:s,onDisconnect:n,onAccountsChanged:r,onChainChanged:i,onDisplayUri:o}){s&&t.on("connect",()=>{const a=Yt.getWalletConnectAccounts(t,e);s(a)}),n&&t.on("disconnect",()=>{n()}),r&&t.on("accountsChanged",a=>{try{const c=t.session?.namespaces?.[e]?.accounts||[],l=t.rpcProviders?.[e]?.getDefaultChain(),u=a.map(d=>{const h=c.find(b=>b.includes(`${e}:${l}:${d}`));if(!h)return;const{chainId:m,chainNamespace:g}=ot.parseCaipAddress(h);return{address:d,chainId:m,chainNamespace:g}}).filter(d=>d!==void 0);u.length>0&&r(u)}catch(c){console.warn("Failed to parse accounts for namespace on accountsChanged event",e,a,c)}}),i&&t.on("chainChanged",a=>{i(a)}),o&&t.on("display_uri",a=>{o(a)})},getWalletConnectAccounts(t,e){const s=new Set,n=t?.session?.namespaces?.[e]?.accounts?.map(r=>ot.parseCaipAddress(r)).filter(({address:r})=>s.has(r.toLowerCase())?!1:(s.add(r.toLowerCase()),!0));return n&&n.length>0?n:[]}};class pN{constructor(e){this.namespace=e.namespace}async syncConnections(e){switch(this.namespace){case x.CHAIN.EVM:await this.syncEVMConnections(e);break;case x.CHAIN.SOLANA:await this.syncSolanaConnections(e);break;case x.CHAIN.BITCOIN:await this.syncBitcoinConnections(e);break;default:throw new Error(`Unsupported chain namespace: ${this.namespace}`)}}async syncEVMConnections({connectors:e,caipNetworks:s,universalProvider:n,onConnection:r,onListenProvider:i}){await Promise.all(e.filter(o=>{const{hasDisconnected:a,hasConnected:c}=Ye.getConnectorStorageInfo(o.id,this.namespace);return!a&&c}).map(async o=>{if(o.id===x.CONNECTOR_ID.WALLET_CONNECT){const a=Yt.getWalletConnectAccounts(n,this.namespace),c=s.find(l=>l.chainNamespace===this.namespace&&l.id.toString()===a[0]?.chainId?.toString());a.length>0&&r({connectorId:o.id,accounts:a.map(l=>({address:l.address})),caipNetwork:c})}else{const{accounts:a,chainId:c}=await Ni.fetchProviderData(o);if(a.length>0&&c){const l=s.find(u=>u.chainNamespace===this.namespace&&u.id.toString()===c.toString());r({connectorId:o.id,accounts:a.map(u=>({address:u})),caipNetwork:l}),o.provider&&o.id!==x.CONNECTOR_ID.AUTH&&o.id!==x.CONNECTOR_ID.WALLET_CONNECT&&i(o.id,o.provider)}}}))}async syncSolanaConnections({connectors:e,caipNetwork:s,universalProvider:n,onConnection:r,onListenProvider:i}){await Promise.all(e.filter(o=>{const{hasDisconnected:a,hasConnected:c}=Ye.getConnectorStorageInfo(o.id,this.namespace);return!a&&c}).map(async o=>{if(o.id===x.CONNECTOR_ID.WALLET_CONNECT){const a=Yt.getWalletConnectAccounts(n,this.namespace);a.length>0&&r({connectorId:o.id,accounts:a.map(c=>({address:c.address})),caipNetwork:s})}else{const a=await o.connect({chainId:s?.id});a&&(r({connectorId:o.id,accounts:[{address:a}],caipNetwork:s}),i(o.id,o.provider))}}))}async syncBitcoinConnections({connectors:e,caipNetwork:s,universalProvider:n,onConnection:r,onListenProvider:i}){await Promise.all(e.filter(o=>{const{hasDisconnected:a,hasConnected:c}=Ye.getConnectorStorageInfo(o.id,this.namespace);return!a&&c}).map(async o=>{if(o.id===x.CONNECTOR_ID.WALLET_CONNECT){const d=Yt.getWalletConnectAccounts(n,this.namespace);d.length>0&&r({connectorId:o.id,accounts:d.map(h=>({address:h.address})),caipNetwork:s});return}const a=await o.connect();let l=(await o.getAccountAddresses())?.map(d=>J.createAccount(x.CHAIN.BITCOIN,d.address,d.purpose||"payment",d.publicKey,d.path));if(l&&l.length>1&&(l=[{namespace:x.CHAIN.BITCOIN,publicKey:l[Ln.ACCOUNT_INDEXES.PAYMENT]?.publicKey??"",path:l[Ln.ACCOUNT_INDEXES.PAYMENT]?.path??"",address:l[Ln.ACCOUNT_INDEXES.PAYMENT]?.address??"",type:"payment"},{namespace:x.CHAIN.BITCOIN,publicKey:l[Ln.ACCOUNT_INDEXES.ORDINAL]?.publicKey??"",path:l[Ln.ACCOUNT_INDEXES.ORDINAL]?.path??"",address:l[Ln.ACCOUNT_INDEXES.ORDINAL]?.address??"",type:"ordinal"}]),!(o.chains.find(d=>d.id===s?.id)||o.chains[0]))throw new Error("The connector does not support any of the requested chains");a&&(i(o.id,o.provider),r({connectorId:o.id,accounts:l.map(d=>({address:d.address,type:d.type,publicKey:d.publicKey,path:d.path})),caipNetwork:s}))}))}getConnection({address:e,connectorId:s,connections:n,connectors:r}){if(s){const o=n.find(l=>Ye.isLowerCaseMatch(l.connectorId,s));if(!o)return null;const a=r.find(l=>Ye.isLowerCaseMatch(l.id,o.connectorId)),c=e?o.accounts.find(l=>Ye.isLowerCaseMatch(l.address,e)):o.accounts[0];return{...o,account:c,connector:a}}const i=n.find(o=>o.accounts.length>0&&r.some(a=>Ye.isLowerCaseMatch(a.id,o.connectorId)));if(i){const[o]=i.accounts,a=r.find(c=>Ye.isLowerCaseMatch(c.id,i.connectorId));return{...i,account:o,connector:a}}return null}}const Nr={ERROR_CODE_UNRECOGNIZED_CHAIN_ID:4902,ERROR_CODE_DEFAULT:5e3,ERROR_INVALID_CHAIN_ID:32603,DEFAULT_ALLOWED_ANCESTORS:["http://localhost:*","https://localhost:*","http://127.0.0.1:*","https://127.0.0.1:*","https://*.pages.dev","https://*.vercel.app","https://*.ngrok-free.app","https://secure-mobile.walletconnect.com","https://secure-mobile.walletconnect.org"]};class cp{constructor({provider:e,namespace:s}){this.id=x.CONNECTOR_ID.WALLET_CONNECT,this.name=jr.ConnectorNamesMap[x.CONNECTOR_ID.WALLET_CONNECT],this.type="WALLET_CONNECT",this.imageId=jr.ConnectorImageIds[x.CONNECTOR_ID.WALLET_CONNECT],this.getCaipNetworks=f.getCaipNetworks.bind(f),this.caipNetworks=this.getCaipNetworks(),this.provider=e,this.chain=s}get chains(){return this.getCaipNetworks()}async connectWalletConnect(){if(!await this.authenticate()){const s=this.getCaipNetworks(),n=R.state.universalProviderConfigOverride,r=Yt.createNamespaces(s,n);await this.provider.connect({optionalNamespaces:r})}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(s=>s.caipNetworkId);return ns.universalProviderAuthenticate({universalProvider:this.provider,chains:e,methods:fN})}}const fN=["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"],gN=[x.CONNECTOR_ID.AUTH,x.CONNECTOR_ID.WALLET_CONNECT];class mN{constructor(e){this.availableConnectors=[],this.availableConnections=[],this.providerHandlers={},this.eventListeners=new Map,this.getCaipNetworks=s=>f.getCaipNetworks(s),this.getConnectorId=s=>F.getConnectorId(s),e&&this.construct(e),e?.namespace&&(this.connectionManager=new pN({namespace:e.namespace}))}construct(e){this.projectId=e.projectId,this.namespace=e.namespace,this.adapterType=e.adapterType}get connectors(){return this.availableConnectors}get connections(){return this.availableConnections}get networks(){return this.getCaipNetworks(this.namespace)}onAuthConnected({accounts:e,chainId:s}){const n=this.getCaipNetworks().filter(r=>r.chainNamespace===this.namespace).find(r=>r.id.toString()===s?.toString());e&&n&&this.addConnection({connectorId:x.CONNECTOR_ID.AUTH,accounts:e,caipNetwork:n})}setAuthProvider(e){e.onConnect(this.onAuthConnected.bind(this)),e.onSocialConnected(this.onAuthConnected.bind(this)),this.addConnector({id:x.CONNECTOR_ID.AUTH,type:"AUTH",name:x.CONNECTOR_NAMES.AUTH,provider:e,imageId:jr.ConnectorImageIds[x.CONNECTOR_ID.AUTH],chain:this.namespace,chains:[]})}addConnector(...e){const s=new Set;this.availableConnectors=[...e,...this.availableConnectors].filter(n=>s.has(n.id)?!1:(s.add(n.id),!0)),this.emit("connectors",this.availableConnectors)}addConnection(...e){const s=new Set;this.availableConnections=[...e,...this.availableConnections].filter(n=>s.has(n.connectorId.toLowerCase())?!1:(s.add(n.connectorId.toLowerCase()),!0)),this.emit("connections",this.availableConnections)}deleteConnection(e){this.availableConnections=this.availableConnections.filter(s=>!Ye.isLowerCaseMatch(s.connectorId,e)),this.emit("connections",this.availableConnections)}clearConnections(e=!1){this.availableConnections=[],e&&this.emit("connections",this.availableConnections)}setStatus(e,s){f.setAccountProp("status",e,s)}on(e,s){this.eventListeners.has(e)||this.eventListeners.set(e,new Set),this.eventListeners.get(e)?.add(s)}off(e,s){const n=this.eventListeners.get(e);n&&n.delete(s)}removeAllEventListeners(){this.eventListeners.forEach(e=>{e.clear()})}emit(e,s){const n=this.eventListeners.get(e);n&&n.forEach(r=>r(s))}async connectWalletConnect(e){try{return{clientId:(await this.getWalletConnectConnector().connectWalletConnect()).clientId}}catch(s){throw Yt.isUserRejectedRequestError(s)?new td(s):s}}async switchNetwork(e){const{caipNetwork:s,providerType:n}=e;if(!e.provider)return;const r="provider"in e.provider?e.provider.provider:e.provider;if(n==="WALLET_CONNECT"){r.setDefaultChain(s.caipNetworkId);return}if(r&&n==="AUTH"){const i=r,o=Lt(s.chainNamespace);await i.switchNetwork({chainId:s.caipNetworkId});const a=await i.getUser({chainId:s.caipNetworkId,preferredAccountType:o});this.emit("switchNetwork",a)}}getWalletConnectConnector(){const e=this.connectors.find(s=>s instanceof cp);if(!e)throw new Error("WalletConnectConnector not found");return e}onConnect(e,s){if(e.length>0){const{address:n,chainId:r}=J.getAccount(e[0]),i=this.getCaipNetworks().filter(a=>a.chainNamespace===this.namespace).find(a=>a.id.toString()===r?.toString()),o=this.connectors.find(a=>a.id===s);n&&(this.emit("accountChanged",{address:n,chainId:r,connector:o}),this.addConnection({connectorId:s,accounts:e.map(a=>{const{address:c}=J.getAccount(a);return{address:c}}),caipNetwork:i}))}}onAccountsChanged(e,s,n=!0){if(e.length>0){const{address:r}=J.getAccount(e[0]),i=this.connectionManager?.getConnection({connectorId:s,connections:this.connections,connectors:this.connectors});r&&Ye.isLowerCaseMatch(this.getConnectorId(x.CHAIN.EVM),s)&&this.emit("accountChanged",{address:r,chainId:i?.caipNetwork?.id,connector:i?.connector}),this.addConnection({connectorId:s,accounts:e.map(o=>{const{address:a}=J.getAccount(o);return{address:a}}),caipNetwork:i?.caipNetwork})}else n&&this.onDisconnect(s)}onDisconnect(e){this.removeProviderListeners(e),this.deleteConnection(e),Ye.isLowerCaseMatch(this.getConnectorId(x.CHAIN.EVM),e)&&this.emitFirstAvailableConnection(),this.connections.length===0&&this.emit("disconnect")}onChainChanged(e,s){const n=typeof e=="string"&&e.startsWith("0x")?Ti.hexStringToNumber(e).toString():e.toString(),r=this.connectionManager?.getConnection({connectorId:s,connections:this.connections,connectors:this.connectors}),i=this.getCaipNetworks().filter(o=>o.chainNamespace===this.namespace).find(o=>o.id.toString()===n);r&&this.addConnection({connectorId:s,accounts:r.accounts,caipNetwork:i}),Ye.isLowerCaseMatch(this.getConnectorId(x.CHAIN.EVM),s)&&this.emit("switchNetwork",{chainId:n})}listenProviderEvents(e,s){if(gN.includes(e))return;const n=o=>this.onAccountsChanged(o,e),r=o=>this.onChainChanged(o,e),i=()=>this.onDisconnect(e);this.providerHandlers[e]||(s.on("disconnect",i),s.on("accountsChanged",n),s.on("chainChanged",r),this.providerHandlers[e]={provider:s,disconnect:i,accountsChanged:n,chainChanged:r})}removeProviderListeners(e){if(this.providerHandlers[e]){const{provider:s,disconnect:n,accountsChanged:r,chainChanged:i}=this.providerHandlers[e];s.removeListener("disconnect",n),s.removeListener("accountsChanged",r),s.removeListener("chainChanged",i),this.providerHandlers[e]=null}}emitFirstAvailableConnection(){const e=this.connectionManager?.getConnection({connections:this.connections,connectors:this.connectors});if(e){const[s]=e.accounts;this.emit("accountChanged",{address:s?.address,chainId:e.caipNetwork?.id,connector:e.connector})}}}class wN extends mN{async setUniversalProvider(e){if(!this.namespace)throw new Error("UniversalAdapter:setUniversalProvider - namespace is required");return this.addConnector(new cp({provider:e,caipNetworks:this.getCaipNetworks(),namespace:this.namespace})),Promise.resolve()}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(),this.emit("disconnect")}catch(e){console.warn("UniversalAdapter:disconnect - error",e)}return{connections:[]}}syncConnections(){return Promise.resolve()}async getAccounts({namespace:e}){const n=this.provider?.session?.namespaces?.[e]?.accounts?.map(r=>{const[,,i]=r.split(":");return i}).filter((r,i,o)=>o.indexOf(r)===i)||[];return Promise.resolve({accounts:n.map(r=>J.createAccount(e,r,e==="bip122"?"payment":"eoa"))})}async syncConnectors(){return Promise.resolve()}async getBalance(e){if(!(e.caipNetwork&&me.BALANCE_SUPPORTED_CHAINS.includes(e.caipNetwork?.chainNamespace))||e.caipNetwork?.testnet)return{balance:"0.00",symbol:e.caipNetwork?.nativeCurrency.symbol||""};const n=f.getAccountData();if(n?.balanceLoading&&e.chainId===f.state.activeCaipNetwork?.id)return{balance:n?.balance||"0.00",symbol:n?.balanceSymbol||""};const i=(await f.fetchTokenBalance()).find(o=>o.chainId===`${e.caipNetwork?.chainNamespace}:${e.chainId}`&&o.symbol===e.caipNetwork?.nativeCurrency.symbol);return{balance:i?.quantity.numeric||"0.00",symbol:i?.symbol||e.caipNetwork?.nativeCurrency.symbol||""}}async signMessage(e){const{provider:s,message:n,address:r}=e;if(!s)throw new Error("UniversalAdapter:signMessage - provider is undefined");let i="";return f.state.activeCaipNetwork?.chainNamespace===x.CHAIN.SOLANA?i=(await s.request({method:"solana_signMessage",params:{message:nr.encode(new TextEncoder().encode(n)),pubkey:r}},f.state.activeCaipNetwork?.caipNetworkId)).signature:i=await s.request({method:"personal_sign",params:[n,r]},f.state.activeCaipNetwork?.caipNetworkId),{signature:i}}async estimateGas(){return Promise.resolve({gas:BigInt(0)})}async sendTransaction(){return Promise.resolve({hash:""})}walletGetAssets(e){return Promise.resolve({})}async writeContract(){return Promise.resolve({hash:""})}emitFirstAvailableConnection(){}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){const{caipNetwork:s}=e,n=this.getWalletConnectConnector();if(s.chainNamespace===x.CHAIN.EVM)try{await n.provider?.request({method:"wallet_switchEthereumChain",params:[{chainId:wc(s.id)}]})}catch(r){if(r.code===Nr.ERROR_CODE_UNRECOGNIZED_CHAIN_ID||r.code===Nr.ERROR_INVALID_CHAIN_ID||r.code===Nr.ERROR_CODE_DEFAULT||r?.data?.originalError?.code===Nr.ERROR_CODE_UNRECOGNIZED_CHAIN_ID)try{await n.provider?.request({method:"wallet_addEthereumChain",params:[{chainId:wc(s.id),rpcUrls:[s?.rpcUrls.chainDefault?.http],chainName:s.name,nativeCurrency:s.nativeCurrency,blockExplorerUrls:[s.blockExplorers?.default.url]}]})}catch{throw new Error("Chain is not supported")}}n.provider.setDefaultChain(s.caipNetworkId)}getWalletConnectProvider(){return this.connectors.find(n=>n.type==="WALLET_CONNECT")?.provider}}const yN=["email","socials","swaps","onramp","activity","reownBranding","multiWallet","emailCapture","payWithExchange","payments","reownAuthentication"],yi={email:{apiFeatureName:"social_login",localFeatureName:"email",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return!!t.isEnabled&&e.includes("email")},processFallback:t=>t===void 0?me.DEFAULT_REMOTE_FEATURES.email:!!t},socials:{apiFeatureName:"social_login",localFeatureName:"socials",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return t.isEnabled&&e.length>0?e.filter(s=>s!=="email"):!1},processFallback:t=>t===void 0?me.DEFAULT_REMOTE_FEATURES.socials:typeof t=="boolean"?t?me.DEFAULT_REMOTE_FEATURES.socials:!1:t},swaps:{apiFeatureName:"swap",localFeatureName:"swaps",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?me.DEFAULT_REMOTE_FEATURES.swaps:typeof t=="boolean"?t?me.DEFAULT_REMOTE_FEATURES.swaps:!1:t},onramp:{apiFeatureName:"onramp",localFeatureName:"onramp",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>{if(!t?.config)return!1;const e=t.config;return t.isEnabled&&e.length>0?e:!1},processFallback:t=>t===void 0?me.DEFAULT_REMOTE_FEATURES.onramp:typeof t=="boolean"?t?me.DEFAULT_REMOTE_FEATURES.onramp:!1:t},activity:{apiFeatureName:"activity",localFeatureName:"history",returnType:!1,isLegacy:!0,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?me.DEFAULT_REMOTE_FEATURES.activity:!!t},reownBranding:{apiFeatureName:"reown_branding",localFeatureName:"reownBranding",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>t===void 0?me.DEFAULT_REMOTE_FEATURES.reownBranding:!!t},emailCapture:{apiFeatureName:"email_capture",localFeatureName:"emailCapture",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>t.isEnabled&&(t.config??[]),processFallback:t=>!1},multiWallet:{apiFeatureName:"multi_wallet",localFeatureName:"multiWallet",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>me.DEFAULT_REMOTE_FEATURES.multiWallet},payWithExchange:{apiFeatureName:"fund_from_exchange",localFeatureName:"payWithExchange",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>me.DEFAULT_REMOTE_FEATURES.payWithExchange},payments:{apiFeatureName:"payments",localFeatureName:"payments",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:()=>me.DEFAULT_REMOTE_FEATURES.payments},reownAuthentication:{apiFeatureName:"reown_authentication",localFeatureName:"reownAuthentication",returnType:!1,isLegacy:!1,isAvailableOnBasic:!1,processApi:t=>!!t.isEnabled,processFallback:t=>typeof t>"u"?me.DEFAULT_REMOTE_FEATURES.reownAuthentication:!!t}},bN={localSettingsOverridden:new Set,getApiConfig(t,e){return e?.find(s=>s.id===t)},addWarning(t,e){if(t!==void 0){const s=yi[e],n=s.isLegacy?`"features.${s.localFeatureName}" (now "${e}")`:`"features.${e}"`;this.localSettingsOverridden.add(n)}},processFeature(t,e,s,n,r){const i=yi[t],o=e[i.localFeatureName];if(r&&!i.isAvailableOnBasic)return!1;if(n){const a=this.getApiConfig(i.apiFeatureName,s);return a?.config===null?this.processFallbackFeature(t,o):a?.config?(o!==void 0&&this.addWarning(o,t),this.processApiFeature(t,a)):!1}return this.processFallbackFeature(t,o)},processApiFeature(t,e){return yi[t].processApi(e)},processFallbackFeature(t,e){return yi[t].processFallback(e)},async fetchRemoteFeatures(t){const e=t.basic??!1,s=t.features||{};this.localSettingsOverridden.clear();let n=null,r=!1;try{n=await te.fetchProjectConfig(),r=n!=null}catch(o){console.warn("[Reown Config] Failed to fetch remote project configuration. Using local/default values.",o)}const i=r&&!e?me.DEFAULT_REMOTE_FEATURES:me.DEFAULT_REMOTE_FEATURES_DISABLED;try{for(const o of yN){const a=this.processFeature(o,s,n,r,e);Object.assign(i,{[o]:a})}}catch(o){return console.warn("[Reown Config] Failed to process the configuration from Cloud. Using default values.",o),me.DEFAULT_REMOTE_FEATURES}if(r&&this.localSettingsOverridden.size>0){const o=`Your local configuration for ${Array.from(this.localSettingsOverridden).join(", ")} was ignored because a remote configuration was successfully fetched. Please manage these features via your project dashboard on dashboard.reown.com.`;At.open({debugMessage:Pt.ALERT_WARNINGS.LOCAL_CONFIGURATION_IGNORED.debugMessage(o)},"warning")}return i}};class EN{constructor(e){this.chainNamespaces=[],this.features={},this.remoteFeatures={},this.reportedAlertErrors={},this.getCaipNetwork=(s,n)=>{if(s){const r=f.getCaipNetworks(s)?.find(a=>a.id===n);if(r)return r;const i=f.getNetworkData(s)?.caipNetwork;return i||f.getRequestedCaipNetworks(s).filter(a=>a.chainNamespace===s)?.[0]}return f.state.activeCaipNetwork||this.defaultCaipNetwork},this.getCaipNetworkId=()=>{const s=this.getCaipNetwork();if(s)return s.id},this.getCaipNetworks=s=>f.getCaipNetworks(s),this.getActiveChainNamespace=()=>f.state.activeChain,this.setRequestedCaipNetworks=(s,n)=>{f.setRequestedCaipNetworks(s,n)},this.getApprovedCaipNetworkIds=()=>f.getAllApprovedCaipNetworkIds(),this.getCaipAddress=s=>f.state.activeChain===s||!s?f.state.activeCaipAddress:f.state.chains.get(s)?.accountState?.caipAddress,this.setClientId=s=>{re.setClientId(s)},this.getProvider=s=>Re.getProvider(s),this.getProviderType=s=>Re.getProviderId(s),this.getPreferredAccountType=s=>Lt(s),this.setCaipAddress=(s,n,r=!1)=>{f.setAccountProp("caipAddress",s,n,r),f.setAccountProp("address",J.getPlainAddress(s),n,r)},this.setBalance=(s,n,r)=>{f.setAccountProp("balance",s,r),f.setAccountProp("balanceSymbol",n,r)},this.setProfileName=(s,n)=>{f.setAccountProp("profileName",s,n)},this.setProfileImage=(s,n)=>{f.setAccountProp("profileImage",s,n)},this.setUser=(s,n)=>{f.setAccountProp("user",s,n)},this.resetAccount=s=>{f.resetAccount(s)},this.setCaipNetwork=s=>{f.setActiveCaipNetwork(s)},this.setCaipNetworkOfNamespace=(s,n)=>{f.setChainNetworkData(n,{caipNetwork:s})},this.setStatus=(s,n)=>{f.setAccountProp("status",s,n),F.isConnected()?B.setConnectionStatus("connected"):B.setConnectionStatus("disconnected")},this.getAddressByChainNamespace=s=>f.getAccountData(s)?.address,this.setConnectors=s=>{const n=[...F.state.allConnectors,...s];F.setConnectors(n)},this.setConnections=(s,n)=>{B.setConnections(s,n),G.setConnections(s,n)},this.fetchIdentity=s=>re.fetchIdentity(s),this.getReownName=s=>Sr.getNamesForAddress(s),this.getConnectors=()=>F.getConnectors(),this.getConnectorImage=s=>id.getConnectorImage(s),this.getConnections=s=>this.remoteFeatures.multiWallet?Pi.getConnectionsData(s).connections:(At.open(x.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.getRecentConnections=s=>this.remoteFeatures.multiWallet?Pi.getConnectionsData(s).recentConnections:(At.open(x.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),[]),this.switchConnection=async s=>{if(!this.remoteFeatures.multiWallet){At.open(x.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}await G.switchConnection(s)},this.deleteConnection=s=>{if(!this.remoteFeatures.multiWallet){At.open(x.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info");return}B.deleteAddressFromConnection(s),G.syncStorageConnections()},this.setConnectedWalletInfo=(s,n)=>{const r=Re.getProviderId(n),i=s?{...s,type:r}:void 0;f.setAccountProp("connectedWalletInfo",i,n)},this.getIsConnectedState=()=>!!f.state.activeCaipAddress,this.addAddressLabel=(s,n,r)=>{const i=f.getAccountData(r)?.addressLabels||{};f.setAccountProp("addressLabels",{...i,[s]:n},r)},this.removeAddressLabel=(s,n)=>{const r=f.getAccountData(n)?.addressLabels||{};f.setAccountProp("addressLabels",{...r,[s]:void 0},n)},this.getAddress=s=>{const n=s||f.state.activeChain;return f.getAccountData(n)?.address},this.setApprovedCaipNetworksData=s=>f.setApprovedCaipNetworksData(s),this.resetNetwork=s=>{f.resetNetwork(s)},this.addConnector=s=>{F.addConnector(s)},this.resetWcConnection=()=>{G.resetWcConnection()},this.setAddressExplorerUrl=(s,n)=>{f.setAccountProp("addressExplorerUrl",s,n)},this.setSmartAccountDeployed=(s,n)=>{f.setAccountProp("smartAccountDeployed",s,n)},this.setPreferredAccountType=(s,n)=>{f.setAccountProp("preferredAccountType",s,n)},this.setEIP6963Enabled=s=>{R.setEIP6963Enabled(s)},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=this.getChainNamespacesSet(e.adapters,this.caipNetworks),this.defaultCaipNetwork=this.extendDefaultCaipNetwork(e),this.chainAdapters=this.createAdapters(e.adapters),this.readyPromise=this.initialize(e),mI.checkSDKVersion(e.sdkVersion)}getChainNamespacesSet(e,s){const n=e?.map(i=>i.namespace).filter(i=>!!i);if(n?.length)return[...new Set(n)];const r=s?.map(i=>i.chainNamespace);return[...new Set(r)]}async initialize(e){if(this.initializeProjectSettings(e),this.initControllers(e),await this.initChainAdapters(),this.sendInitializeEvent(e),R.state.enableReconnect?(await this.syncExistingConnection(),await this.syncAdapterConnections()):await this.unSyncExistingConnection(),this.remoteFeatures=await bN.fetchRemoteFeatures(e),R.setRemoteFeatures(this.remoteFeatures),this.remoteFeatures.onramp&&na.setOnrampProviders(this.remoteFeatures.onramp),(R.state.remoteFeatures?.email||Array.isArray(R.state.remoteFeatures?.socials)&&R.state.remoteFeatures?.socials.length>0)&&await this.checkAllowedOrigins(),R.state.features?.reownAuthentication||R.state.remoteFeatures?.reownAuthentication){const{ReownAuthentication:s}=await Oi(async()=>{const{ReownAuthentication:r}=await import("./features-B6BTj_BL.js");return{ReownAuthentication:r}},__vite__mapDeps([16,6,17,18,19,20,2,1,3,4,5,21,13,22,23,24,8]),import.meta.url),n=R.state.siwx;n instanceof s||(n&&console.warn("ReownAuthentication option is enabled, SIWX configuration will be overridden."),R.setSIWX(new s))}}async openSend(e){const s=e.namespace||f.state.activeChain,n=this.getCaipAddress(s),r=this.getCaipNetwork(s)?.id;if(!n)throw new Error("openSend: caipAddress not found");if(r?.toString()!==e.chainId.toString()){const i=f.getCaipNetworkById(e.chainId,s);if(!i)throw new Error(`openSend: caipNetwork with chainId ${e.chainId} not found`);await this.switchNetwork(i,{throwOnFailure:!0})}try{const i=Zh.getTokenSymbolByAddress(e.assetAddress);i&&await te.fetchTokenImages([i])}catch{}return await he.open({view:"WalletSend",data:{send:e}}),new Promise((i,o)=>{const a=ce.subscribeKey("hash",u=>{u&&(l(),i({hash:u}))}),c=he.subscribe(u=>{u.open||(l(),o(new Error("Modal closed")))}),l=this.createCleanupHandler([a,c])})}toModalOptions(){function e(n){return n?.view==="Swap"}function s(n){return n?.view==="WalletSend"}return{isSwap:e,isSend:s}}async checkAllowedOrigins(){try{const e=await te.fetchAllowedOrigins();if(!J.isClient())return;const s=window.location.origin;Yt.isOriginAllowed(s,e,Nr.DEFAULT_ALLOWED_ANCESTORS)||At.open(Pt.ALERT_ERRORS.ORIGIN_NOT_ALLOWED,"error")}catch(e){if(!(e instanceof Error))return;switch(e.message){case"RATE_LIMITED":At.open(Pt.ALERT_ERRORS.RATE_LIMITED_APP_CONFIGURATION,"error");break;case"SERVER_ERROR":{const s=e.cause instanceof Error?e.cause:e;At.open({displayMessage:Pt.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.displayMessage,debugMessage:Pt.ALERT_ERRORS.SERVER_ERROR_APP_CONFIGURATION.debugMessage(s.message)},"error");break}}}}createCleanupHandler(e){return()=>{e.forEach(s=>{try{s()}catch{}})}}sendInitializeEvent(e){const{...s}=e;delete s.adapters,delete s.universalProvider,le.sendEvent({type:"track",event:"INITIALIZE",properties:{...s,networks:e.networks.map(n=>n.id),siweConfig:{options:e.siweConfig?.options||{}}}})}initControllers(e){this.initializeOptionsController(e),this.initializeChainController(e),this.initializeThemeController(e),this.initializeConnectionController(e),this.initializeConnectorController()}initializeThemeController(e){e.themeMode&&Nt.setThemeMode(e.themeMode),e.themeVariables&&Nt.setThemeVariables(e.themeVariables)}initializeChainController(e){if(!this.connectionControllerClient||!this.networkControllerClient)throw new Error("ConnectionControllerClient and NetworkControllerClient must be set");f.initialize(e.adapters??[],this.caipNetworks,{connectionControllerClient:this.connectionControllerClient,networkControllerClient:this.networkControllerClient});const s=this.getDefaultNetwork();s&&f.setActiveCaipNetwork(s)}initializeConnectionController(e){G.initialize(e.adapters??[]),G.setWcBasic(e.basic??!1)}initializeConnectorController(){F.initialize(this.chainNamespaces)}initializeProjectSettings(e){R.setProjectId(e.projectId),R.setSdkVersion(e.sdkVersion)}initializeOptionsController(e){R.setDebug(e.debug!==!1),R.setEnableWalletGuide(e.enableWalletGuide!==!1),R.setEnableWallets(e.enableWallets!==!1),R.setEIP6963Enabled(e.enableEIP6963!==!1),R.setEnableNetworkSwitch(e.enableNetworkSwitch!==!1),R.setEnableReconnect(e.enableReconnect!==!1),R.setEnableMobileFullScreen(e.enableMobileFullScreen===!0),R.setEnableAuthLogger(e.enableAuthLogger!==!1),R.setCustomRpcUrls(e.customRpcUrls),R.setEnableEmbedded(e.enableEmbedded),R.setAllWallets(e.allWallets),R.setIncludeWalletIds(e.includeWalletIds),R.setExcludeWalletIds(e.excludeWalletIds),R.setFeaturedWalletIds(e.featuredWalletIds),R.setTokens(e.tokens),R.setTermsConditionsUrl(e.termsConditionsUrl),R.setPrivacyPolicyUrl(e.privacyPolicyUrl),R.setCustomWallets(e.customWallets),R.setFeatures(e.features),R.setAllowUnsupportedChain(e.allowUnsupportedChain),R.setUniversalProviderConfigOverride(e.universalProviderConfigOverride),R.setPreferUniversalLinks(e.experimental_preferUniversalLinks),R.setDefaultAccountTypes(e.defaultAccountTypes);const s=this.getDefaultMetaData();if(!e.metadata&&s&&(e.metadata=s),R.setMetadata(e.metadata),R.setDisableAppend(e.disableAppend),R.setEnableEmbedded(e.enableEmbedded),R.setSIWX(e.siwx),this.features=R.state.features??{},!e.projectId){At.open(Pt.ALERT_ERRORS.PROJECT_ID_NOT_CONFIGURED,"error");return}if(e.adapters?.find(r=>r.namespace===x.CHAIN.EVM)&&e.siweConfig){if(e.siwx)throw new Error("Cannot set both `siweConfig` and `siwx` options");R.setSIWX(e.siweConfig.mapToSIWX())}}getDefaultMetaData(){return J.isClient()?{name:document.getElementsByTagName("title")?.[0]?.textContent||"",description:document.querySelector('meta[property="og:description"]')?.content||"",url:window.location.origin,icons:[document.querySelector('link[rel~="icon"]')?.href||""]}:null}setUnsupportedNetwork(e){const s=this.getActiveChainNamespace();if(s){const n=jn.getUnsupportedNetwork(`${s}:${e}`);f.setActiveCaipNetwork(n)}}getDefaultNetwork(){return jn.getCaipNetworkFromStorage(this.defaultCaipNetwork)}extendCaipNetwork(e,s){return jn.extendCaipNetwork(e,{customNetworkImageUrls:s.chainImages,projectId:s.projectId})}extendCaipNetworks(e){return jn.extendCaipNetworks(e.networks,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId})}extendDefaultCaipNetwork(e){const s=e.networks.find(r=>r.id===e.defaultNetwork?.id);return s?jn.extendCaipNetwork(s,{customNetworkImageUrls:e.chainImages,customRpcUrls:e.customRpcUrls,projectId:e.projectId}):void 0}async disconnectConnector(e,s){try{this.setLoading(!0,e);let n={connections:[]};const r=this.getAdapter(e);return(f.state.chains.get(e)?.accountState?.caipAddress||!R.state.enableReconnect)&&r?.disconnect&&(n=await r.disconnect({id:s})),this.setLoading(!1,e),n}catch(n){throw this.setLoading(!1,e),new Error(`Failed to disconnect chains: ${n.message}`)}}createClients(){this.connectionControllerClient={connectWalletConnect:async()=>{const e=f.state.activeChain,s=this.getAdapter(e),n=this.getCaipNetwork(e)?.id,r=G.getConnections(e),i=this.remoteFeatures.multiWallet,o=r.length>0;if(!s)throw new Error("Adapter not found");const a=await s.connectWalletConnect(n);(!o||!i)&&this.close(),this.setClientId(a?.clientId||null),B.setConnectedNamespaces([...f.state.chains.keys()]),await this.syncWalletConnectAccount(),await ns.initializeIfEnabled()},connectExternal:async e=>{const s=await this.onConnectExternal(e);return await this.connectInactiveNamespaces(e,s),s?{address:s.address}:void 0},reconnectExternal:async({id:e,info:s,type:n,provider:r})=>{const i=f.state.activeChain,o=this.getAdapter(i);if(!i)throw new Error("reconnectExternal: namespace not found");if(!o)throw new Error("reconnectExternal: adapter not found");o?.reconnect&&(await o?.reconnect({id:e,info:s,type:n,provider:r,chainId:this.getCaipNetwork()?.id}),B.addConnectedNamespace(i),this.syncConnectedWalletInfo(i))},disconnectConnector:async e=>{await this.disconnectConnector(e.namespace,e.id)},disconnect:async e=>{const{id:s,chainNamespace:n,initialDisconnect:r}=e||{},i=n||f.state.activeChain,o=F.getConnectorId(i),a=s===x.CONNECTOR_ID.AUTH||o===x.CONNECTOR_ID.AUTH,c=s===x.CONNECTOR_ID.WALLET_CONNECT||o===x.CONNECTOR_ID.WALLET_CONNECT;try{const l=Array.from(f.state.chains.keys());let u=n?[n]:l;(c||a)&&(u=l);const d=u.map(async g=>{const b=F.getConnectorId(g),y=s||b,_=await this.disconnectConnector(g,y);_&&(a&&B.deleteConnectedSocialProvider(),_.connections.forEach(N=>{B.addDisconnectedConnectorId(N.connectorId,g)})),r&&this.onDisconnectNamespace({chainNamespace:g,closeModal:!1})}),h=await Promise.allSettled(d);ce.resetSend(),G.resetWcConnection(),ns.getSIWX()?.signOutOnDisconnect&&await ns.clearSessions(),F.setFilterByNamespace(void 0),G.syncStorageConnections();const m=h.filter(g=>g.status==="rejected");if(m.length>0)throw new Error(m.map(g=>g.reason.message).join(", "));le.sendEvent({type:"track",event:"DISCONNECT_SUCCESS",properties:{namespace:n||"all"}})}catch(l){throw new Error(`Failed to disconnect chains: ${l.message}`)}},checkInstalled:e=>e?e.some(s=>!!window.ethereum?.[String(s)]):!!window.ethereum,signMessage:async e=>{const s=f.state.activeChain,n=this.getAdapter(f.state.activeChain);if(!s)throw new Error("signMessage: namespace not found");if(!n)throw new Error("signMessage: adapter not found");const r=this.getAddress(s);if(!r)throw new Error("signMessage: address not found");return(await n?.signMessage({message:e,address:r,provider:Re.getProvider(s)}))?.signature||""},sendTransaction:async e=>{const s=e.chainNamespace;if(!s)throw new Error("sendTransaction: namespace not found");if(me.SEND_SUPPORTED_NAMESPACES.includes(s)){const n=this.getAdapter(s);if(!n)throw new Error("sendTransaction: adapter not found");const r=Re.getProvider(s);return(await n?.sendTransaction({...e,caipNetwork:this.getCaipNetwork(),provider:r}))?.hash||""}return""},estimateGas:async e=>{const s=e.chainNamespace;if(s===x.CHAIN.EVM){const n=this.getAdapter(s);if(!n)throw new Error("estimateGas: adapter is required but got undefined");const r=Re.getProvider(s),i=this.getCaipNetwork();if(!i)throw new Error("estimateGas: caipNetwork is required but got undefined");return(await n?.estimateGas({...e,provider:r,caipNetwork:i}))?.gas||0n}return 0n},getEnsAvatar:async()=>{const e=f.state.activeChain;if(!e)throw new Error("getEnsAvatar: namespace is required but got undefined");const s=this.getAddress(e);if(!s)throw new Error("getEnsAvatar: address not found");return await this.syncIdentity({address:s,chainId:Number(this.getCaipNetwork()?.id),chainNamespace:e}),f.getAccountData()?.profileImage||!1},getEnsAddress:async e=>await Yt.resolveReownName(e),writeContract:async e=>{const s=f.state.activeChain,n=this.getAdapter(s);if(!s)throw new Error("writeContract: namespace is required but got undefined");if(!n)throw new Error("writeContract: adapter is required but got undefined");const r=this.getCaipNetwork(),i=this.getCaipAddress(),o=Re.getProvider(s);if(!r||!i)throw new Error("writeContract: caipNetwork or caipAddress is required but got undefined");return(await n?.writeContract({...e,caipNetwork:r,provider:o,caipAddress:i}))?.hash},parseUnits:(e,s)=>{const n=this.getAdapter(f.state.activeChain);if(!n)throw new Error("parseUnits: adapter is required but got undefined");return n?.parseUnits({value:e,decimals:s})??0n},formatUnits:(e,s)=>{const n=this.getAdapter(f.state.activeChain);if(!n)throw new Error("formatUnits: adapter is required but got undefined");return n?.formatUnits({value:e,decimals:s})??"0"},getCapabilities:async e=>{const s=this.getAdapter(f.state.activeChain);if(!s)throw new Error("getCapabilities: adapter is required but got undefined");return await s?.getCapabilities(e)},grantPermissions:async e=>{const s=this.getAdapter(f.state.activeChain);if(!s)throw new Error("grantPermissions: adapter is required but got undefined");return await s?.grantPermissions(e)},revokePermissions:async e=>{const s=this.getAdapter(f.state.activeChain);if(!s)throw new Error("revokePermissions: adapter is required but got undefined");return s?.revokePermissions?await s.revokePermissions(e):"0x"},walletGetAssets:async e=>{const s=this.getAdapter(f.state.activeChain);if(!s)throw new Error("walletGetAssets: adapter is required but got undefined");return await s?.walletGetAssets(e)??{}},updateBalance:e=>{const s=this.getAddress(e),n=this.getCaipNetwork(e);!n||!s||this.updateNativeBalance(s,n?.id,e)}},this.networkControllerClient={switchCaipNetwork:async e=>await this.switchCaipNetwork(e),getApprovedCaipNetworksData:async()=>this.getApprovedCaipNetworksData()},G.setClient(this.connectionControllerClient)}async onConnectExternal(e){const s=f.state.activeChain,n=e.chain||s,r=this.getAdapter(n);let i=!0;if(e.type===ws.CONNECTOR_TYPE_AUTH&&x.AUTH_CONNECTOR_SUPPORTED_CHAINS.some(d=>F.getConnectorId(d)===x.CONNECTOR_ID.AUTH)&&e.chain!==s&&(i=!1),e.chain&&e.chain!==s&&!e.caipNetwork){const l=this.getCaipNetworks().find(u=>u.chainNamespace===e.chain);l&&i&&this.setCaipNetwork(l)}if(!n)throw new Error("connectExternal: namespace not found");if(!r)throw new Error("connectExternal: adapter not found");const o=this.getCaipNetwork(n),a=e.caipNetwork||o,c=await r.connect({id:e.id,address:e.address,info:e.info,type:e.type,provider:e.provider,socialUri:e.socialUri,chainId:e.caipNetwork?.id||o?.id,rpcUrl:e.caipNetwork?.rpcUrls?.default?.http?.[0]||o?.rpcUrls?.default?.http?.[0]});if(c)return B.addConnectedNamespace(n),this.syncProvider({...c,chainNamespace:n}),this.setStatus("connected",n),this.syncConnectedWalletInfo(n),B.removeDisconnectedConnectorId(e.id,n),{address:c.address,connectedCaipNetwork:a}}async connectInactiveNamespaces(e,s){const n=e.type===ws.CONNECTOR_TYPE_AUTH,r=Ye.getOtherAuthNamespaces(s?.connectedCaipNetwork?.chainNamespace),i=f.state.activeCaipNetwork,o=this.getAdapter(i?.chainNamespace),a=Re.getProvider(i?.chainNamespace);n&&(await Promise.all(r.map(async c=>{try{const l=Re.getProvider(c),u=this.getCaipNetwork(c);await this.getAdapter(c)?.connect({...e,provider:l,socialUri:void 0,chainId:u?.id,rpcUrl:u?.rpcUrls?.default?.http?.[0]})&&(B.addConnectedNamespace(c),B.removeDisconnectedConnectorId(e.id,c),this.setStatus("connected",c),this.syncConnectedWalletInfo(c))}catch(l){At.warn(Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.displayMessage,Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.debugMessage(c,l instanceof Error?l.message:void 0),Pt.ALERT_WARNINGS.INACTIVE_NAMESPACE_NOT_CONNECTED.code)}})),i&&await o?.switchNetwork({caipNetwork:i,provider:a,providerType:e.type}))}getApprovedCaipNetworksData(){if(Re.getProviderId(f.state.activeChain)===ws.CONNECTOR_TYPE_WALLET_CONNECT){const s=this.universalProvider?.session?.namespaces;return{supportsAllNetworks:this.universalProvider?.session?.peer?.metadata.name==="MetaMask Wallet",approvedCaipNetworkIds:this.getChainsFromNamespaces(s)}}return{supportsAllNetworks:!0,approvedCaipNetworkIds:[]}}async switchCaipNetwork(e){const s=e.chainNamespace;if(this.getAddressByChainNamespace(e.chainNamespace)){const r=Re.getProvider(s),i=Re.getProviderId(s);if(e.chainNamespace===f.state.activeChain)await this.getAdapter(s)?.switchNetwork({caipNetwork:e,provider:r,providerType:i});else if(this.setCaipNetwork(e),i===ws.CONNECTOR_TYPE_WALLET_CONNECT)this.syncWalletConnectAccount();else{const o=this.getAddressByChainNamespace(s);o&&this.syncAccount({address:o,chainId:e.id,chainNamespace:s})}}else this.setCaipNetwork(e)}getChainsFromNamespaces(e={}){return Object.values(e).flatMap(s=>{const n=s.chains||[],r=s.accounts.map(i=>{const{chainId:o,chainNamespace:a}=ot.parseCaipAddress(i);return`${a}:${o}`});return Array.from(new Set([...n,...r]))})}createAdapters(e){return this.createClients(),this.chainNamespaces.reduce((s,n)=>{const r=e?.find(i=>i.namespace===n);return r?(r.construct({namespace:n,projectId:this.options?.projectId,networks:this.caipNetworks?.filter(({chainNamespace:i})=>i===n)}),s[n]=r):s[n]=new wN({namespace:n,networks:this.getCaipNetworks()}),s},{})}async initChainAdapter(e){this.onConnectors(e),this.listenAdapter(e),await this.chainAdapters?.[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){this.getAdapter(e)?.on("connectors",this.setConnectors.bind(this))}listenAdapter(e){const s=this.getAdapter(e);if(!s)return;const n=B.getConnectionStatus();R.state.enableReconnect===!1?this.setStatus("disconnected",e):n==="connected"?this.setStatus("connecting",e):n==="disconnected"?(B.clearAddressCache(),this.setStatus(n,e)):this.setStatus(n,e),s.on("switchNetwork",({address:r,chainId:i})=>{const o=this.getCaipNetworks().find(l=>l.id.toString()===i.toString()||l.caipNetworkId.toString()===i.toString()),a=f.state.activeChain===e,c=f.state.chains.get(e)?.accountState?.address;if(o){const l=a&&r?r:c;l&&this.syncAccount({address:l,chainId:o.id,chainNamespace:e})}else this.setUnsupportedNetwork(i)}),s.on("disconnect",()=>{const r=this.remoteFeatures.multiWallet,i=Array.from(G.state.connections.values()).flat();this.onDisconnectNamespace({chainNamespace:e,closeModal:!r||i.length===0})}),s.on("connections",r=>{this.setConnections(r,e)}),s.on("pendingTransactions",()=>{const r=this.getAddress(e),i=f.state.activeCaipNetwork;!r||!i?.id||this.updateNativeBalance(r,i.id,i.chainNamespace)}),s.on("accountChanged",({address:r,chainId:i,connector:o})=>{this.handlePreviousConnectorConnection(o);const a=f.state.activeChain===e;o?.provider&&(this.syncProvider({id:o.id,type:o.type,provider:o?.provider,chainNamespace:e}),this.syncConnectedWalletInfo(e));const c=f.getNetworkData(e)?.caipNetwork?.id,l=i||c;a&&l?this.syncAccount({address:r,chainId:l,chainNamespace:e}):!a&&l?(this.syncAccountInfo(r,l,e),this.syncBalance({address:r,chainId:l,chainNamespace:e})):this.syncAccountInfo(r,i,e),B.addConnectedNamespace(e)})}async handlePreviousConnectorConnection(e){const s=e?.chain,n=e?.id,r=F.getConnectorId(s),i=R.state.remoteFeatures?.multiWallet,a=s&&n&&r&&r!==n&&!i;try{a&&await G.disconnect({id:r,namespace:s})}catch(c){console.warn("Error disconnecting previous connector",c)}}async createUniversalProviderForAdapter(e){await this.getUniversalProvider(),this.universalProvider&&await this.chainAdapters?.[e]?.setUniversalProvider?.(this.universalProvider)}async syncExistingConnection(){await Promise.allSettled(this.chainNamespaces.map(e=>this.syncNamespaceConnection(e)))}async unSyncExistingConnection(){try{await Promise.allSettled(this.chainNamespaces.map(e=>G.disconnect({namespace:e,initialDisconnect:!0})))}catch(e){console.error("Error disconnecting existing connections:",e)}}async reconnectWalletConnect(){await this.syncWalletConnectAccount();const e=this.getAddress();this.getCaipAddress()||B.deleteRecentWallet();const s=B.getRecentWallet();le.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:e,properties:{method:J.isMobile()?"mobile":"qrcode",name:s?.name||"Unknown",reconnect:!0,view:ne.state.view,walletRank:s?.order}})}async syncNamespaceConnection(e){try{e===x.CHAIN.EVM&&J.isSafeApp()&&F.setConnectorId(x.CONNECTOR_ID.SAFE,e);const s=F.getConnectorId(e);switch(this.setStatus("connecting",e),s){case x.CONNECTOR_ID.WALLET_CONNECT:await this.reconnectWalletConnect();break;case x.CONNECTOR_ID.AUTH:break;default:await this.syncAdapterConnection(e)}}catch(s){console.warn("AppKit couldn't sync existing connection",s),this.setStatus("disconnected",e)}}onDisconnectNamespace(e){const{chainNamespace:s,closeModal:n}=e||{};f.resetAccount(s),f.resetNetwork(s),B.removeConnectedNamespace(s);const r=Array.from(f.state.chains.keys());(s?[s]:r).forEach(o=>B.addDisconnectedConnectorId(F.getConnectorId(o)||"",o)),F.removeConnectorId(s),Re.resetChain(s),this.setUser(null,s),this.setStatus("disconnected",s),this.setConnectedWalletInfo(null,s),n!==!1&&he.close()}async syncAdapterConnections(){await Promise.allSettled(this.chainNamespaces.map(e=>{const s=this.getAdapter(e),n=this.getCaipAddress(e),r=this.getCaipNetwork(e);return s?.syncConnections({connectToFirstConnector:!n,caipNetwork:r})}))}async syncAdapterConnection(e){const s=this.getAdapter(e),n=this.getCaipNetwork(e),r=F.getConnectorId(e),o=F.getConnectors(e).find(a=>a.id===r);try{if(!s||!o)throw new Error(`Adapter or connector not found for namespace ${e}`);if(!n?.id)throw new Error("CaipNetwork not found");const a=await s?.syncConnection({namespace:e,id:o.id,chainId:n.id,rpcUrl:n?.rpcUrls?.default?.http?.[0]});a?(this.syncProvider({...a,chainNamespace:e}),await this.syncAccount({...a,chainNamespace:e}),this.setStatus("connected",e),le.sendEvent({type:"track",event:"CONNECT_SUCCESS",address:a.address,properties:{method:"browser",name:o.info?.name||o.name||"Unknown",reconnect:!0,view:ne.state.view,walletRank:void 0}})):this.setStatus("disconnected",e)}catch{this.onDisconnectNamespace({chainNamespace:e,closeModal:!1})}}async syncWalletConnectAccount(){const e=Object.keys(this.universalProvider?.session?.namespaces||{}),s=this.chainNamespaces.map(async n=>{const r=this.getAdapter(n);if(!r)return;const i=this.universalProvider?.session?.namespaces?.[n]?.accounts||[],o=f.state.activeCaipNetwork?.id,a=i.find(c=>{const{chainId:l}=ot.parseCaipAddress(c);return l===o?.toString()})||i[0];if(a){const c=ot.validateCaipAddress(a),{chainId:l,address:u}=ot.parseCaipAddress(c);if(Re.setProviderId(n,ws.CONNECTOR_TYPE_WALLET_CONNECT),this.caipNetworks&&f.state.activeCaipNetwork&&r.namespace!==x.CHAIN.EVM){const d=r.getWalletConnectProvider({caipNetworks:this.getCaipNetworks(),provider:this.universalProvider,activeCaipNetwork:f.state.activeCaipNetwork});Re.setProvider(n,d)}else Re.setProvider(n,this.universalProvider);F.setConnectorId(x.CONNECTOR_ID.WALLET_CONNECT,n),B.addConnectedNamespace(n),await this.syncAccount({address:u,chainId:l,chainNamespace:n})}else e.includes(n)&&this.setStatus("disconnected",n);this.syncConnectedWalletInfo(n),await f.setApprovedCaipNetworksData(n)});await Promise.all(s)}syncProvider({type:e,provider:s,id:n,chainNamespace:r}){Re.setProviderId(r,e),Re.setProvider(r,s),F.setConnectorId(n,r)}async syncAccount(e){const s=e.chainNamespace===f.state.activeChain,n=f.getCaipNetworkByNamespace(e.chainNamespace,e.chainId),{address:r,chainId:i,chainNamespace:o}=e,{chainId:a}=B.getActiveNetworkProps(),c=i||a,l=f.state.activeCaipNetwork?.name===x.UNSUPPORTED_NETWORK_NAME,u=f.getNetworkProp("supportsAllNetworks",o);if(this.setStatus("connected",o),!(l&&!u)&&c){let d=this.getCaipNetworks().find(b=>b.id.toString()===c.toString()),h=this.getCaipNetworks().find(b=>b.chainNamespace===o);if(!u&&!d&&!h){const b=this.getApprovedCaipNetworkIds()||[],y=b.find(N=>ot.parseCaipNetworkId(N)?.chainId===c.toString()),_=b.find(N=>ot.parseCaipNetworkId(N)?.chainNamespace===o);d=this.getCaipNetworks().find(N=>N.caipNetworkId===y),h=this.getCaipNetworks().find(N=>N.caipNetworkId===_||"deprecatedCaipNetworkId"in N&&N.deprecatedCaipNetworkId===_)}const m=d||h;m?.chainNamespace===f.state.activeChain?R.state.enableNetworkSwitch&&!R.state.allowUnsupportedChain&&f.state.activeCaipNetwork?.name===x.UNSUPPORTED_NETWORK_NAME?f.showUnsupportedChainUI():this.setCaipNetwork(m):s||n&&this.setCaipNetworkOfNamespace(n,o),this.syncConnectedWalletInfo(o);const g=this.getAddress(o);Ye.isLowerCaseMatch(r,g)||this.syncAccountInfo(r,m?.id,o),s?await this.syncBalance({address:r,chainId:m?.id,chainNamespace:o}):await this.syncBalance({address:r,chainId:n?.id,chainNamespace:o}),this.syncIdentity({address:r,chainId:i,chainNamespace:o})}}async syncAccountInfo(e,s,n){const r=this.getCaipAddress(n),i=s||r?.split(":")[1];if(!i)return;const o=`${n}:${i}:${e}`;this.setCaipAddress(o,n,!0),await this.syncIdentity({address:e,chainId:i,chainNamespace:n})}async syncReownName(e,s){try{const n=await this.getReownName(e);if(n[0]){const r=n[0];this.setProfileName(r.name,s)}else this.setProfileName(null,s)}catch{this.setProfileName(null,s)}}syncConnectedWalletInfo(e){const s=F.getConnectorId(e),n=Re.getProviderId(e);if(n===ws.CONNECTOR_TYPE_ANNOUNCED||n===ws.CONNECTOR_TYPE_INJECTED){if(s){const i=this.getConnectors().find(o=>{const a=o.id===s,c=o.info?.rdns===s,l=o.connectors?.some(u=>u.id===s||u.info?.rdns===s);return a||c||!!l});if(i){const{info:o,name:a,imageUrl:c}=i,l=c||this.getConnectorImage(i);this.setConnectedWalletInfo({name:a,icon:l,...o},e)}}}else if(n===ws.CONNECTOR_TYPE_WALLET_CONNECT){const r=Re.getProvider(e);r?.session&&this.setConnectedWalletInfo({...r.session.peer.metadata,name:r.session.peer.metadata.name,icon:r.session.peer.metadata.icons?.[0]},e)}else if(s&&(s===x.CONNECTOR_ID.COINBASE_SDK||s===x.CONNECTOR_ID.COINBASE)){const r=this.getConnectors().find(c=>c.id===s),i=r?.name||"Coinbase Wallet",o=r?.imageUrl||this.getConnectorImage(r),a=r?.info;this.setConnectedWalletInfo({...a,name:i,icon:o},e)}}async syncBalance(e){!Xu.getNetworksByNamespace(this.getCaipNetworks(),e.chainNamespace).find(n=>n.id.toString()===e.chainId?.toString())||!e.chainId||await this.updateNativeBalance(e.address,e.chainId,e.chainNamespace)}async ready(){await this.readyPromise}async updateNativeBalance(e,s,n){const r=this.getAdapter(n),i=f.getCaipNetworkByNamespace(n,s);if(r){const o=await r.getBalance({address:e,chainId:s,caipNetwork:i,tokens:this.options.tokens});return this.setBalance(o.balance,o.symbol,n),o}}async initializeUniversalAdapter(){const e=PI.createLogger((n,...r)=>{n&&this.handleAlertError(n),console.error(...r)}),s={projectId:this.options?.projectId,metadata:{name:this.options?.metadata?this.options?.metadata.name:"",description:this.options?.metadata?this.options?.metadata.description:"",url:this.options?.metadata?this.options?.metadata.url:"",icons:this.options?.metadata?this.options?.metadata.icons:[""]},logger:e};R.setManualWCControl(!!this.options?.manualWCControl),this.universalProvider=this.options.universalProvider??await gI.init(s),R.state.enableReconnect===!1&&this.universalProvider.session&&await this.universalProvider.disconnect(),this.listenWalletConnect()}listenWalletConnect(){this.universalProvider&&this.chainNamespaces.forEach(e=>{Yt.listenWcProvider({universalProvider:this.universalProvider,namespace:e,onDisplayUri:s=>{G.setUri(s)},onConnect:s=>{const{address:n}=J.getAccount(s[0]);G.finalizeWcConnection(n)},onDisconnect:()=>{f.state.noAdapters&&this.resetAccount(e),G.resetWcConnection()},onChainChanged:s=>{const n=f.state.activeChain,r=n&&F.state.activeConnectorIds[n]===x.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(f.state.noAdapters||r)){const i=this.getCaipNetworks().find(a=>a.id.toString()===s.toString()||a.caipNetworkId.toString()===s.toString()),o=this.getCaipNetwork();if(!i){this.setUnsupportedNetwork(s);return}o?.id.toString()!==i?.id.toString()&&o?.chainNamespace===i?.chainNamespace&&this.setCaipNetwork(i)}},onAccountsChanged:s=>{const n=f.state.activeChain,r=n&&F.state.activeConnectorIds[n]===x.CONNECTOR_ID.WALLET_CONNECT;if(n===e&&(f.state.noAdapters||r)){const i=s?.[0];i&&this.syncAccount({address:i.address,chainId:i.chainId,chainNamespace:i.chainNamespace})}}})})}createUniversalProvider(){return!this.universalProviderInitPromise&&J.isClient()&&this.options?.projectId&&(this.universalProviderInitPromise=this.initializeUniversalAdapter()),this.universalProviderInitPromise}async getUniversalProvider(){if(!this.universalProvider)try{await this.createUniversalProvider()}catch(e){le.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}getDisabledCaipNetworks(){const e=f.getAllApprovedCaipNetworkIds(),s=f.getAllRequestedCaipNetworks();return J.sortRequestedNetworks(e,s).filter(r=>f.isCaipNetworkDisabled(r))}handleAlertError(e){const s=Object.entries(Pt.UniversalProviderErrors).find(([,{message:a}])=>e.message.includes(a)),[n,r]=s??[],{message:i,alertErrorKey:o}=r??{};if(n&&i&&!this.reportedAlertErrors[n]){const a=Pt.ALERT_ERRORS[o];a&&(At.open(a,"error"),this.reportedAlertErrors[n]=!0)}}getAdapter(e){if(e)return this.chainAdapters?.[e]}createAdapter(e){if(!e)return;const s=e.namespace;if(!s)return;this.createClients();const n=e;n.namespace=s,n.construct({namespace:s,projectId:this.options?.projectId,networks:this.caipNetworks?.filter(({chainNamespace:r})=>r===s)}),this.chainNamespaces.includes(s)||this.chainNamespaces.push(s),this.chainAdapters&&(this.chainAdapters[s]=n)}async open(e){await this.injectModalUi(),e?.uri&&G.setUri(e.uri);const{isSwap:s,isSend:n}=this.toModalOptions();return s(e)?he.open({...e,data:{swap:e.arguments}}):n(e)&&e.arguments?this.openSend(e.arguments):he.open(e)}async close(){await this.injectModalUi(),he.close()}setLoading(e,s){he.setLoading(e,s)}async disconnect(e){await G.disconnect({namespace:e})}getSIWX(){return R.state.siwx}getError(){return""}getChainId(){return f.state.activeCaipNetwork?.id}async switchNetwork(e,{throwOnFailure:s=!1}={}){const n=this.getCaipNetworks().find(r=>r.id===e.id);if(!n){At.open(Pt.ALERT_ERRORS.SWITCH_NETWORK_NOT_FOUND,"error");return}await f.switchActiveNetwork(n,{throwOnFailure:s})}getWalletProvider(){return f.state.activeChain?Re.state.providers[f.state.activeChain]:null}getWalletProviderType(){return Re.getProviderId(f.state.activeChain)}subscribeProviders(e){return Re.subscribeProviders(e)}getThemeMode(){return Nt.state.themeMode}getThemeVariables(){return Nt.state.themeVariables}setThemeMode(e){Nt.setThemeMode(e),Ua(Nt.state.themeMode)}setTermsConditionsUrl(e){R.setTermsConditionsUrl(e)}setPrivacyPolicyUrl(e){R.setPrivacyPolicyUrl(e)}setThemeVariables(e){Nt.setThemeVariables(e),dN(Nt.state.themeVariables)}subscribeTheme(e){return Nt.subscribe(e)}subscribeConnections(e){return this.remoteFeatures.multiWallet?G.subscribe(e):(At.open(x.REMOTE_FEATURES_ALERTS.MULTI_WALLET_NOT_ENABLED.DEFAULT,"info"),()=>{})}getWalletInfo(e){return e?f.state.chains.get(e)?.accountState?.connectedWalletInfo:f.getAccountData()?.connectedWalletInfo}getAccount(e){const s=e||f.state.activeChain,n=F.getAuthConnector(s),r=f.getAccountData(s),i=B.getConnectedConnectorId(f.state.activeChain),o=G.getConnections(s);if(!s)throw new Error("AppKit:getAccount - namespace is required");const a=o.flatMap(c=>c.accounts.map(({address:l,type:u,publicKey:d})=>J.createAccount(s,l,u||"eoa",d)));if(r)return{allAccounts:a,caipAddress:r.caipAddress,address:J.getPlainAddress(r.caipAddress),isConnected:!!r.caipAddress,status:r.status,embeddedWalletInfo:n&&i===x.CONNECTOR_ID.AUTH?{user:r.user?{...r.user,username:B.getConnectedSocialUsername()}:void 0,authProvider:r.socialProvider||"email",accountType:Lt(s),isSmartAccountDeployed:!!r.smartAccountDeployed}:void 0}}subscribeAccount(e,s){const n=()=>{const r=this.getAccount(s);r&&e(r)};s?f.subscribeChainProp("accountState",n,s):f.subscribe(n),F.subscribe(n)}subscribeNetwork(e){return f.subscribe(({activeCaipNetwork:s})=>{e({caipNetwork:s,chainId:s?.id,caipNetworkId:s?.caipNetworkId})})}subscribeWalletInfo(e,s){return s?f.subscribeChainProp("accountState",n=>e(n?.connectedWalletInfo),s):f.subscribeChainProp("accountState",n=>e(n?.connectedWalletInfo))}subscribeShouldUpdateToAddress(e){f.subscribeChainProp("accountState",s=>e(s?.shouldUpdateToAddress))}subscribeCaipNetworkChange(e){f.subscribeKey("activeCaipNetwork",e)}getState(){return vs.state}getRemoteFeatures(){return R.state.remoteFeatures}subscribeState(e){return vs.subscribe(e)}subscribeRemoteFeatures(e){return R.subscribeKey("remoteFeatures",e)}showErrorMessage(e){is.showError(e)}showSuccessMessage(e){is.showSuccess(e)}getEvent(){return{...le.state}}subscribeEvents(e){return le.subscribe(e)}replace(e){ne.replace(e)}redirect(e){ne.push(e)}popTransactionStack(e){ne.popTransactionStack(e)}isOpen(){return he.state.open}isTransactionStackEmpty(){return ne.state.transactionStack.length===0}static getInstance(){return this.instance}updateFeatures(e){R.setFeatures(e)}updateRemoteFeatures(e){R.setRemoteFeatures(e)}updateOptions(e){const n={...R.state||{},...e};R.setOptions(n)}setConnectMethodsOrder(e){R.setConnectMethodsOrder(e)}setWalletFeaturesOrder(e){R.setWalletFeaturesOrder(e)}setCollapseWallets(e){R.setCollapseWallets(e)}setSocialsOrder(e){R.setSocialsOrder(e)}getConnectMethodsOrder(){return Ir.getConnectOrderMethod(R.state.features,F.getConnectors())}addNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);const n=this.extendCaipNetwork(s,this.options);this.getCaipNetworks().find(r=>r.id===n.id)||f.addNetwork(n)}removeNetwork(e,s){if(this.chainAdapters&&!this.chainAdapters[e])throw new Error(`Adapter for namespace ${e} doesn't exist`);this.getCaipNetworks().find(r=>r.id===s)&&f.removeNetwork(e,s)}}let Hu=!1;class lp extends EN{async open(e){F.isConnected()||await super.open(e)}async close(){if(await super.close(),this.options.manualWCControl){const e=f.getAccountData(this.activeChainNamespace)?.address;G.finalizeWcConnection(e)}}async syncIdentity(e){return Promise.resolve()}async syncBalance(e){return Promise.resolve()}async injectModalUi(){if(!Hu&&J.isClient()){if(await Oi(()=>import("./basic-C9wn6QoQ.js"),__vite__mapDeps([25,26,6,18,27,17,19,20,2,1,3,4,5,21,13,22,23,24,8]),import.meta.url),await Oi(()=>import("./w3m-modal-Bz5KWTQ-.js"),__vite__mapDeps([28,26,6,17,18,19,20,2,1,3,4,5,21,13,22,23,24,8]),import.meta.url),!document.querySelector("w3m-modal")){const s=document.createElement("w3m-modal");!R.state.disableAppend&&!R.state.enableEmbedded&&document.body.insertAdjacentElement("beforeend",s)}Hu=!0}}}const CN="1.8.7";function vN(t){return new lp({...t,basic:!0,sdkVersion:`html-core-${CN}`})}const d_=Object.freeze(Object.defineProperty({__proto__:null,AppKit:lp,createAppKit:vN},Symbol.toStringTag,{value:"Module"}));export{Z as $,te as A,Cs as B,F as C,re as D,le as E,vf as F,At as G,Ye as H,Wa as I,ad as J,Xe as K,Je as L,he as M,Pp as N,R as O,ke as P,ns as Q,ne as R,is as S,Nt as T,xI as U,c_ as V,Ir as W,ot as X,Xu as Y,ee as Z,oi as _,J as a,d_ as a0,G as b,x as c,i_ as d,a_ as e,Ut as f,Ni as g,id as h,Si as i,u_ as j,bn as k,Ks as l,me as m,f as n,jn as o,B as p,Ve as q,l_ as r,zs as s,sp as t,xa as u,uN as v,o_ as w,er as x,jt as y,Lt as z};
|