@privy-io/react-auth 3.13.0 → 3.13.1-beta-20260202140759
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/AccountNotFoundScreen-DopQJydk.js +1 -0
- package/dist/cjs/{Address-aEAhUJFV.js → Address-C0i_Lgxz.js} +1 -1
- package/dist/cjs/AffirmativeConsentScreen-DrfsiAOF.js +6 -0
- package/dist/cjs/AllowlistRejectionScreen-B4F7MdmW.js +1 -0
- package/dist/cjs/AuthenticateWithWalletScreen-BImVaE8G.js +1 -0
- package/dist/cjs/AwaitingEvmToSolBridgingScreen-Bld2VoQo.js +2 -0
- package/dist/cjs/AwaitingExternalEthereumTransferScreen-CK2PMVQH.js +2 -0
- package/dist/cjs/AwaitingPasswordlessCodeScreen-mc4TfLdK.js +103 -0
- package/dist/cjs/AwaitingSolToEvmBridgingScreen-BHTmPSzt.js +2 -0
- package/dist/cjs/{BridgeNetworkSelectionView-CE2o-1QO.js → BridgeNetworkSelectionView-BTW55LDI.js} +1 -1
- package/dist/cjs/CaptchaScreen-C4OKrOJj.js +1 -0
- package/dist/cjs/CoinbaseOnrampStatusScreen-DuBusEzK.js +16 -0
- package/dist/cjs/{ConnectEmailForm-D-TxBaE5.js → ConnectEmailForm-BAtI_Su2.js} +1 -1
- package/dist/cjs/ConnectLedgerScreen-Cxy5kYQy.js +9 -0
- package/dist/cjs/ConnectOnlyLandingScreen-UHxAPPxv.js +1 -0
- package/dist/cjs/ConnectOnlyStatusScreen-D7hEyOkF.js +1 -0
- package/dist/cjs/ConnectOrCreateScreen-DCXEsisd.js +1 -0
- package/dist/cjs/{ConnectPhoneForm-DK6jm19G.js → ConnectPhoneForm-IaeAlSaT.js} +1 -1
- package/dist/cjs/{ConnectWalletView-1cBOsYe3.js → ConnectWalletView-I7l3i_Tn.js} +1 -1
- package/dist/cjs/ConnectionStatusScreen-B5eG6O0t.js +7 -0
- package/dist/cjs/CrossAppAuthScreen-BHfk_dqk.js +1 -0
- package/dist/cjs/{CustomLandingScreenView-C879x5ia.js → CustomLandingScreenView-ZdAEwrj3.js} +1 -1
- package/dist/cjs/DelegatedActionsConsentScreen-LeQ6Lxpc.js +1 -0
- package/dist/cjs/DelegatedActionsRevokeScreen-C8v4E_cj.js +1 -0
- package/dist/cjs/EmbeddedWalletConnectingScreen-B1rrh4GO.js +1 -0
- package/dist/cjs/EmbeddedWalletCreatedScreen-Cem5Ix9r.js +1 -0
- package/dist/cjs/{EmbeddedWalletKeyExportScreen-BpjA7HGz.js → EmbeddedWalletKeyExportScreen-C9Et_UFA.js} +3 -3
- package/dist/cjs/EmbeddedWalletOnAccountCreateScreen-tJoXkQEs.js +1 -0
- package/dist/cjs/EmbeddedWalletPasswordUpdateScreen-C2wVljgA.js +1 -0
- package/dist/cjs/EmbeddedWalletPasswordUpdateSplashScreen-CG1oHF6a.js +1 -0
- package/dist/cjs/{EnrollTotp-D1jQjLxQ.js → EnrollTotp-BveYXBKW.js} +1 -1
- package/dist/cjs/ErrorScreen-Ckke6sz3.js +4 -0
- package/dist/cjs/{FarcasterConnectStatusScreen-JBJeeu9F.js → FarcasterConnectStatusScreen-D5ziktAq.js} +3 -3
- package/dist/cjs/{FarcasterSignerStatusScreen-8DplKa45.js → FarcasterSignerStatusScreen-8edRjO2Y.js} +6 -6
- package/dist/cjs/FundSolWalletWithExternalSolanaWallet-DJEyYpCy.js +2 -0
- package/dist/cjs/{FundWalletMethodHeader-CW2KubxL.js → FundWalletMethodHeader-Dyg72x32.js} +1 -1
- package/dist/cjs/FundingEditAmountScreen-2vgGeOzZ.js +1 -0
- package/dist/cjs/FundingMethodSelectionScreen-D6K2RTnb.js +1 -0
- package/dist/cjs/InAppBrowserLoginNotPossible-DlH26fht.js +1 -0
- package/dist/cjs/InstallWalletScreen-D-aty_-m.js +1 -0
- package/dist/cjs/LandingScreen-C3ycf-sm.js +1 -0
- package/dist/cjs/{LinkConflictScreen-DKkFMAqc.js → LinkConflictScreen-tpqlaHKl.js} +2 -2
- package/dist/cjs/LinkEmailScreen-CVJ8MM6X.js +1 -0
- package/dist/cjs/{LinkPasskeyScreen-D-5RrGXJ.js → LinkPasskeyScreen-BVI23any.js} +1 -1
- package/dist/cjs/LinkPhoneScreen-COZH83MT.js +1 -0
- package/dist/cjs/LoginFailedScreen-B_f3bRu3.js +1 -0
- package/dist/cjs/ManualTransferScreen-DCjvNWqd.js +1 -0
- package/dist/cjs/MfaAuthEnrollmentFlowScreen-DN4ce0UG.js +1 -0
- package/dist/cjs/MfaAuthVerifyFlowScreen-c-lQ_fEz.js +1 -0
- package/dist/cjs/MfaEnrollmentFlowScreen-B6-EB6WE.js +1 -0
- package/dist/cjs/MfaVerifyFlowScreen-zbdZQoq2.js +1 -0
- package/dist/cjs/{ModalHeader-DmWqn83H.js → ModalHeader-Cy6QK4_e.js} +1 -1
- package/dist/cjs/MoonpayStatusScreen-BEtRocSA.js +16 -0
- package/dist/cjs/OAuthStatusScreen-FvgZmHXu.js +1 -0
- package/dist/cjs/PasskeySelectSignupOrLogin-DqSfSR6i.js +1 -0
- package/dist/cjs/PasskeyStatusScreen-DvA6G4hk.js +3 -0
- package/dist/cjs/PasswordRecoveryScreen-Befeqrad.js +20 -0
- package/dist/cjs/{QrCode-BG2PX4HL.js → QrCode-DuBadwvo.js} +1 -1
- package/dist/cjs/RecoveryOAuthStatusScreen-C6mVwtQH.js +1 -0
- package/dist/cjs/RecoveryPasswordCreateScreen-DzNiXRjH.js +1 -0
- package/dist/cjs/{RecoverySelectionScreen-qP99_3WR.js → RecoverySelectionScreen-CjnlE9el.js} +2 -2
- package/dist/cjs/{Screen-BnWlRqz4.js → Screen-edUQX_SB.js} +1 -1
- package/dist/cjs/{ScreenLayout-8Ho-PwHJ.js → ScreenLayout-DGTvokS8.js} +1 -1
- package/dist/cjs/{SetAutomaticRecoveryScreen-Dw8eXtFM.js → SetAutomaticRecoveryScreen-CrRjNWxq.js} +2 -2
- package/dist/cjs/{SetWalletPasswordForm-BtxQiQCF.js → SetWalletPasswordForm-DJeemCn9.js} +1 -1
- package/dist/cjs/SignRequestScreen-DHoZ6sz5.js +26 -0
- package/dist/cjs/{StandardSignAndSendTransactionScreen-BRCG_Otm.js → StandardSignAndSendTransactionScreen-CBLYn4pf.js} +1 -1
- package/dist/cjs/TelegramAuthScreen-D7mlDw-E.js +1 -0
- package/dist/cjs/{TransactionDetails-CB_SFjYb.js → TransactionDetails-CXgPk3J1.js} +1 -1
- package/dist/cjs/{TransactionErrorView-C6AwpMpC.js → TransactionErrorView-Deibl2Uf.js} +1 -1
- package/dist/cjs/{TransferFromWalletScreen-DDbM2aZ-.js → TransferFromWalletScreen-DSItFmOL.js} +2 -2
- package/dist/cjs/{TransferOrBridgeLoadingScreen-BdFZ-kHB.js → TransferOrBridgeLoadingScreen-CZY4tSPW.js} +1 -1
- package/dist/cjs/UpdateEmailScreen-Bcbi12kY.js +1 -0
- package/dist/cjs/UpdatePhoneScreen-lJE1r_mk.js +1 -0
- package/dist/cjs/UserLimitReachedScreen-CKsbmhwX.js +1 -0
- package/dist/cjs/{WalletInfoCard-BP4plvST.js → WalletInfoCard-BPFjUGT5.js} +1 -1
- package/dist/cjs/WalletInterstitialScreen-C-wi9rZH.js +1 -0
- package/dist/cjs/{WalletLink-Be-wt7BS.js → WalletLink-DQka9Syl.js} +1 -1
- package/dist/cjs/{WalletOverflowButton-DNXb1rWu.js → WalletOverflowButton-CT3ToLGt.js} +1 -1
- package/dist/cjs/abstract-smart-wallets.js +1 -1
- package/dist/cjs/{context-B5x3dsBc.js → context-BgcJR59W.js} +1 -1
- package/dist/cjs/{ethers-CcPcMmj-.js → ethers-CUHJ8mll.js} +1 -1
- package/dist/cjs/extended-chains.js +1 -1
- package/dist/cjs/get-entropy-details-for-user-Bh25VOwU.js +1 -0
- package/dist/cjs/{get-is-unified-wallet-huyBqM6I.js → get-is-unified-wallet-pvisKZtt.js} +1 -1
- package/dist/cjs/{index-C9h5dbsX.js → index-BgLmUrL3.js} +1 -1
- package/dist/cjs/index-C40Nmmja.js +174 -0
- package/dist/cjs/{index-Ddh08VH6.js → index-Y7m6JUJT.js} +1 -1
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/internal.js +1 -1
- package/dist/cjs/{shared-B4PQQyG9.js → shared-BrkTXSb9.js} +1 -1
- package/dist/cjs/{shouldProceedtoEmbeddedWalletCreationFlow-Cwmd9p6v.js → shouldProceedtoEmbeddedWalletCreationFlow-ClGopOFu.js} +1 -1
- package/dist/cjs/smart-wallets-DhMgsCrP.js +1 -0
- package/dist/cjs/smart-wallets.js +1 -1
- package/dist/cjs/solana.js +1 -1
- package/dist/cjs/{styles-BYA0sdA8.js → styles-Dg1gwPet.js} +1 -1
- package/dist/cjs/{to-ui-error-kjcnhSmN.js → to-ui-error-Cj4nmAIy.js} +1 -1
- package/dist/cjs/ui.js +1 -1
- package/dist/cjs/use-export-wallet-BHqL5lkN.js +1 -0
- package/dist/cjs/use-export-wallet-CHdfox2p.js +1 -0
- package/dist/cjs/useActiveWallet-DQaSSN2M.js +185 -0
- package/dist/cjs/{useGetTokenPrice-XbJ2xnl_.js → useGetTokenPrice-Q-LRDLGC.js} +1 -1
- package/dist/cjs/{useI18n-CJec5B3S.js → useI18n-C-2tQwPP.js} +1 -1
- package/dist/cjs/usePrivy-DN8Ajdzm.js +1 -0
- package/dist/cjs/{useSolanaRpcClient-CN7MyWq4.js → useSolanaRpcClient-DAhvriV9.js} +1 -1
- package/dist/cjs/useWallets-DOb8xzgz.js +1 -0
- package/dist/dts/{events-context-CV9PiG6M.d.ts → events-context-uQF86xPo.d.mts} +1 -1
- package/dist/dts/{events-context-CV9PiG6M.d.mts → events-context-uQF86xPo.d.ts} +1 -1
- package/dist/dts/extended-chains.d.mts +1 -1
- package/dist/dts/extended-chains.d.ts +1 -1
- package/dist/dts/farcaster.d.mts +1 -1
- package/dist/dts/farcaster.d.ts +1 -1
- package/dist/dts/index.d.mts +4 -38
- package/dist/dts/index.d.ts +4 -38
- package/dist/dts/internal.d.mts +1 -1
- package/dist/dts/internal.d.ts +1 -1
- package/dist/dts/smart-wallets.d.mts +1 -1
- package/dist/dts/smart-wallets.d.ts +1 -1
- package/dist/dts/solana.d.mts +3 -3
- package/dist/dts/solana.d.ts +3 -3
- package/dist/dts/{types-xIUh0rN4.d.mts → types-DLEfLPEB.d.mts} +1 -1
- package/dist/dts/{types-xIUh0rN4.d.ts → types-DLEfLPEB.d.ts} +1 -1
- package/dist/dts/ui.d.mts +1 -1
- package/dist/dts/ui.d.ts +1 -1
- package/dist/esm/AccountNotFoundScreen-CVBAv1Mv.mjs +1 -0
- package/dist/esm/{Address-BuCMjci7.mjs → Address-BupZf8Rc.mjs} +1 -1
- package/dist/esm/AffirmativeConsentScreen-CFSY5nE4.mjs +6 -0
- package/dist/esm/AllowlistRejectionScreen-0Z0EYviP.mjs +1 -0
- package/dist/esm/AuthenticateWithWalletScreen-BdJYQ2JJ.mjs +1 -0
- package/dist/esm/AwaitingEvmToSolBridgingScreen-D9Ef3Dnt.mjs +2 -0
- package/dist/esm/AwaitingExternalEthereumTransferScreen-mj07gSaD.mjs +2 -0
- package/dist/esm/AwaitingPasswordlessCodeScreen-DE3g9VwQ.mjs +103 -0
- package/dist/esm/AwaitingSolToEvmBridgingScreen-CUKh2oVG.mjs +2 -0
- package/dist/esm/{BridgeNetworkSelectionView-0VRZoDMv.mjs → BridgeNetworkSelectionView-D8aRUIg2.mjs} +1 -1
- package/dist/esm/CaptchaScreen-Co8CjcuQ.mjs +1 -0
- package/dist/esm/CoinbaseOnrampStatusScreen-Da7VjKBi.mjs +16 -0
- package/dist/esm/ConnectEmailForm-D5UhENmm.mjs +3 -0
- package/dist/esm/ConnectLedgerScreen-JDfzYq9M.mjs +9 -0
- package/dist/esm/ConnectOnlyLandingScreen-C0j3-tOW.mjs +1 -0
- package/dist/esm/ConnectOnlyStatusScreen-D-gYePr8.mjs +1 -0
- package/dist/esm/ConnectOrCreateScreen-CqLbK7av.mjs +1 -0
- package/dist/esm/{ConnectPhoneForm-DMcfvHG9.mjs → ConnectPhoneForm-CQJPasTi.mjs} +1 -1
- package/dist/esm/{ConnectWalletView-rtAY2uds.mjs → ConnectWalletView-mIrd9fmT.mjs} +3 -3
- package/dist/esm/ConnectionStatusScreen-D8G_flGR.mjs +7 -0
- package/dist/esm/CrossAppAuthScreen-Btm1d-iO.mjs +1 -0
- package/dist/esm/{CustomLandingScreenView-Dt4TEi0A.mjs → CustomLandingScreenView-C2TNxHAb.mjs} +1 -1
- package/dist/esm/DelegatedActionsConsentScreen-DXwSOiLw.mjs +1 -0
- package/dist/esm/DelegatedActionsRevokeScreen-B7uTGw9J.mjs +1 -0
- package/dist/esm/EmbeddedWalletConnectingScreen-BioR068C.mjs +1 -0
- package/dist/esm/EmbeddedWalletCreatedScreen-Cq1thot_.mjs +1 -0
- package/dist/esm/{EmbeddedWalletKeyExportScreen-sjrAvCm3.mjs → EmbeddedWalletKeyExportScreen-CtEY8G7E.mjs} +2 -2
- package/dist/esm/EmbeddedWalletOnAccountCreateScreen-ShyQ92Jq.mjs +1 -0
- package/dist/esm/EmbeddedWalletPasswordUpdateScreen-qoWRlbPz.mjs +1 -0
- package/dist/esm/EmbeddedWalletPasswordUpdateSplashScreen-BeN-dpqi.mjs +1 -0
- package/dist/esm/{EnrollTotp-DlnMoeNk.mjs → EnrollTotp-3j3Uj3wv.mjs} +1 -1
- package/dist/esm/ErrorScreen-BpG9IyOu.mjs +4 -0
- package/dist/esm/{FarcasterConnectStatusScreen-BLgCDUxR.mjs → FarcasterConnectStatusScreen-DadPWt5w.mjs} +4 -4
- package/dist/esm/FarcasterSignerStatusScreen-DyJNx88F.mjs +28 -0
- package/dist/esm/FundSolWalletWithExternalSolanaWallet-Dhp2jhkc.mjs +1 -0
- package/dist/esm/{FundWalletMethodHeader-Dujd1j7J.mjs → FundWalletMethodHeader-Cyn7MCWO.mjs} +1 -1
- package/dist/esm/FundingEditAmountScreen-D0KCT7EC.mjs +1 -0
- package/dist/esm/FundingMethodSelectionScreen-CrHLwmNP.mjs +1 -0
- package/dist/esm/InAppBrowserLoginNotPossible-CcbdJWpW.mjs +1 -0
- package/dist/esm/InstallWalletScreen-0udkV09c.mjs +1 -0
- package/dist/esm/LandingScreen-C7xCusAZ.mjs +1 -0
- package/dist/esm/{LinkConflictScreen-DOsLOvpT.mjs → LinkConflictScreen-B31exGN7.mjs} +4 -4
- package/dist/esm/LinkEmailScreen-DZf6HS1n.mjs +1 -0
- package/dist/esm/{LinkPasskeyScreen-jzRj6Yq0.mjs → LinkPasskeyScreen-Bl7uzJ8Q.mjs} +7 -7
- package/dist/esm/LinkPhoneScreen-DUIIaqp0.mjs +1 -0
- package/dist/esm/LoginFailedScreen-DsSbXSXA.mjs +1 -0
- package/dist/esm/ManualTransferScreen-B-Kkarxd.mjs +1 -0
- package/dist/esm/MfaAuthEnrollmentFlowScreen-D82inQR9.mjs +1 -0
- package/dist/esm/MfaAuthVerifyFlowScreen-Cw5rWozq.mjs +1 -0
- package/dist/esm/MfaEnrollmentFlowScreen-B3F6HEAl.mjs +1 -0
- package/dist/esm/MfaVerifyFlowScreen-DYuvXWXh.mjs +1 -0
- package/dist/esm/{ModalHeader-CSfzkWxZ.mjs → ModalHeader-Byy3j4Lh.mjs} +1 -1
- package/dist/esm/MoonpayStatusScreen-CBtEX6lf.mjs +16 -0
- package/dist/esm/OAuthStatusScreen-YCUnttYA.mjs +1 -0
- package/dist/esm/PasskeySelectSignupOrLogin-DuXG4uXH.mjs +1 -0
- package/dist/esm/PasskeyStatusScreen-DPvVVoC2.mjs +3 -0
- package/dist/esm/PasswordRecoveryScreen-IS0ckI65.mjs +20 -0
- package/dist/esm/{QrCode-BkoTqsec.mjs → QrCode-lPYtXNC_.mjs} +1 -1
- package/dist/esm/RecoveryOAuthStatusScreen-CJO3irqx.mjs +1 -0
- package/dist/esm/RecoveryPasswordCreateScreen-DZb7gDAd.mjs +1 -0
- package/dist/esm/{RecoverySelectionScreen-0YIfrkiv.mjs → RecoverySelectionScreen-CThvVB-J.mjs} +2 -2
- package/dist/esm/{Screen-5StC6JLQ.mjs → Screen-Ct4Lyoaf.mjs} +1 -1
- package/dist/esm/{ScreenLayout-C2Le_YIv.mjs → ScreenLayout-DOt2sB2J.mjs} +1 -1
- package/dist/esm/{SetAutomaticRecoveryScreen-BAAv--Sk.mjs → SetAutomaticRecoveryScreen-D1IKpF6a.mjs} +2 -2
- package/dist/esm/{SetWalletPasswordForm-lzuYpBex.mjs → SetWalletPasswordForm-CiQmt-HX.mjs} +1 -1
- package/dist/esm/{SignRequestScreen-YrG-iwWX.mjs → SignRequestScreen-DKJky_Un.mjs} +2 -2
- package/dist/esm/{StandardSignAndSendTransactionScreen-Csw3bRQ4.mjs → StandardSignAndSendTransactionScreen-CPKZQMPj.mjs} +2 -2
- package/dist/esm/TelegramAuthScreen-bIm5jFOU.mjs +1 -0
- package/dist/esm/{TransactionDetails-BMVu0qlz.mjs → TransactionDetails-DLLlKhs7.mjs} +1 -1
- package/dist/esm/{TransactionErrorView-C6AZ1RC0.mjs → TransactionErrorView-CSRxuGt5.mjs} +1 -1
- package/dist/esm/{TransferFromWalletScreen-BOOq-OqM.mjs → TransferFromWalletScreen-ClNSdttH.mjs} +4 -4
- package/dist/esm/{TransferOrBridgeLoadingScreen-gM_oel5i.mjs → TransferOrBridgeLoadingScreen-rWz1yK-a.mjs} +1 -1
- package/dist/esm/UpdateEmailScreen-mog8U9Vt.mjs +1 -0
- package/dist/esm/UpdatePhoneScreen-CLLjzpN7.mjs +1 -0
- package/dist/esm/UserLimitReachedScreen-Baf8QzFD.mjs +1 -0
- package/dist/esm/{WalletInfoCard-TfOxho0A.mjs → WalletInfoCard-BWAC4Crm.mjs} +1 -1
- package/dist/esm/WalletInterstitialScreen-chmHYyvD.mjs +1 -0
- package/dist/esm/{WalletLink-CZTmkBKu.mjs → WalletLink-cm_UqBHl.mjs} +1 -1
- package/dist/esm/{WalletOverflowButton-C0Ysaik4.mjs → WalletOverflowButton-CoHTrzr-.mjs} +1 -1
- package/dist/esm/abstract-smart-wallets.mjs +1 -1
- package/dist/esm/context-BEE1GR3p.mjs +1 -0
- package/dist/esm/{ethers-DrSqg5wi.mjs → ethers-CzVYf1X2.mjs} +1 -1
- package/dist/esm/extended-chains.mjs +1 -1
- package/dist/esm/farcaster.mjs +1 -1
- package/dist/esm/{frame-uzTmvtww.mjs → frame-CjhCpycO.mjs} +1 -1
- package/dist/esm/get-entropy-details-for-user-DXl-F6zT.mjs +1 -0
- package/dist/esm/{get-is-unified-wallet-GcvxyU9r.mjs → get-is-unified-wallet-szLxUazm.mjs} +1 -1
- package/dist/esm/{getErc20Balance-D0MGUaOw.mjs → getErc20Balance-Bs6MYMo9.mjs} +1 -1
- package/dist/esm/{getErc20TokenInfo-CZJTqd4c.mjs → getErc20TokenInfo-Cymy79Tp.mjs} +1 -1
- package/dist/esm/{getPublicClient-B4uPLKn-.mjs → getPublicClient-BltMpU4i.mjs} +1 -1
- package/dist/esm/{index-BXKPenEy.mjs → index-21Khs68W.mjs} +1 -1
- package/dist/esm/index-BXdEd5-h.mjs +174 -0
- package/dist/esm/{index-tsoVOGEt.mjs → index-CXuTLe54.mjs} +1 -1
- package/dist/esm/index.mjs +1 -1
- package/dist/esm/{internal-context-Z-fyxadS.mjs → internal-context-C4ZqP8IF.mjs} +1 -1
- package/dist/esm/internal.mjs +1 -1
- package/dist/esm/{paths-3HW55qZg.mjs → paths-BzM95ysC.mjs} +1 -1
- package/dist/esm/reservoir-CB32KXxK.mjs +1 -0
- package/dist/esm/{shared-CQ6jg1BO.mjs → shared-CcT7geMr.mjs} +1 -1
- package/dist/esm/{shouldProceedtoEmbeddedWalletCreationFlow-BfZwb-3N.mjs → shouldProceedtoEmbeddedWalletCreationFlow-eeAK_6M1.mjs} +1 -1
- package/dist/esm/smart-wallets-CHETrkmZ.mjs +1 -0
- package/dist/esm/smart-wallets.mjs +1 -1
- package/dist/esm/solana.mjs +1 -1
- package/dist/esm/{styles-C3H3yhVT.mjs → styles-CVcwbZBK.mjs} +1 -1
- package/dist/esm/{to-ui-error-fYkDcQhz.mjs → to-ui-error-CymSkIi1.mjs} +2 -2
- package/dist/esm/ui.mjs +1 -1
- package/dist/esm/use-export-wallet-BghmI1bY.mjs +1 -0
- package/dist/esm/use-export-wallet-DmJRcrg3.mjs +1 -0
- package/dist/esm/{use-sign-with-user-signer-Do5Oi_rb.mjs → use-sign-with-user-signer-BYctG7hm.mjs} +1 -1
- package/dist/esm/useActiveWallet-CeJ_zia0.mjs +185 -0
- package/dist/esm/{useGetSolPrice-DwwjjGbd.mjs → useGetSolPrice-DaxM-vxD.mjs} +1 -1
- package/dist/esm/{useGetTokenPrice-YObgUU6L.mjs → useGetTokenPrice-BS8CeRfC.mjs} +1 -1
- package/dist/esm/{useI18n-VPW2SjZN.mjs → useI18n-BWqAKjsd.mjs} +1 -1
- package/dist/esm/usePrivy-DZkUhG2n.mjs +1 -0
- package/dist/esm/{useSolanaRpcClient-BTAchFxj.mjs → useSolanaRpcClient-D-Ekw787.mjs} +1 -1
- package/dist/esm/{useWalletBalance-BDrbQBDX.mjs → useWalletBalance-CCG99ZD8.mjs} +1 -1
- package/dist/esm/useWallets-CaOutpwQ.mjs +1 -0
- package/package.json +1 -1
- package/dist/cjs/AccountNotFoundScreen-DxO5LvIc.js +0 -1
- package/dist/cjs/AffirmativeConsentScreen-DfJW4zFz.js +0 -6
- package/dist/cjs/AllowlistRejectionScreen-CP01TiLV.js +0 -1
- package/dist/cjs/AuthenticateWithWalletScreen-CQw1iHsK.js +0 -1
- package/dist/cjs/AwaitingEvmToSolBridgingScreen-BzcvlEoa.js +0 -2
- package/dist/cjs/AwaitingExternalEthereumTransferScreen-CF8PGODY.js +0 -2
- package/dist/cjs/AwaitingPasswordlessCodeScreen-BByZHkHQ.js +0 -103
- package/dist/cjs/AwaitingSolToEvmBridgingScreen-DcalXeu-.js +0 -2
- package/dist/cjs/CaptchaScreen-anNodbfx.js +0 -1
- package/dist/cjs/CoinbaseOnrampStatusScreen-JGw8hfLn.js +0 -16
- package/dist/cjs/ConnectLedgerScreen-CwS0odD_.js +0 -9
- package/dist/cjs/ConnectOnlyLandingScreen-fpFbLO8Y.js +0 -1
- package/dist/cjs/ConnectOnlyStatusScreen-DziODgdH.js +0 -1
- package/dist/cjs/ConnectOrCreateScreen-D-V8KzJp.js +0 -1
- package/dist/cjs/ConnectionStatusScreen-D4NtHDFM.js +0 -7
- package/dist/cjs/CrossAppAuthScreen-BtEXDc88.js +0 -1
- package/dist/cjs/DelegatedActionsConsentScreen-CGnSYhkE.js +0 -1
- package/dist/cjs/DelegatedActionsRevokeScreen-Dd8u3U62.js +0 -1
- package/dist/cjs/EmbeddedWalletConnectingScreen-yIHjjIR2.js +0 -1
- package/dist/cjs/EmbeddedWalletCreatedScreen-CouqreWe.js +0 -1
- package/dist/cjs/EmbeddedWalletOnAccountCreateScreen-Cv8bAxPB.js +0 -1
- package/dist/cjs/EmbeddedWalletPasswordUpdateScreen-roXY9Gv8.js +0 -1
- package/dist/cjs/EmbeddedWalletPasswordUpdateSplashScreen-9I5OZ38V.js +0 -1
- package/dist/cjs/ErrorScreen-DbETfzK4.js +0 -4
- package/dist/cjs/FundSolWalletWithExternalSolanaWallet-CE1VdpiY.js +0 -2
- package/dist/cjs/FundingEditAmountScreen-Cjzgv7Q-.js +0 -1
- package/dist/cjs/FundingMethodSelectionScreen-Bje3JXwS.js +0 -1
- package/dist/cjs/InAppBrowserLoginNotPossible-DpFXJi29.js +0 -1
- package/dist/cjs/InstallWalletScreen-DP80Lixb.js +0 -1
- package/dist/cjs/LandingScreen-B_s7VUcj.js +0 -1
- package/dist/cjs/LinkEmailScreen-POTKFhXp.js +0 -1
- package/dist/cjs/LinkPhoneScreen-RWN6_lR0.js +0 -1
- package/dist/cjs/LoginFailedScreen-BGq1l-h2.js +0 -1
- package/dist/cjs/ManualTransferScreen-S07FPGso.js +0 -1
- package/dist/cjs/MfaAuthEnrollmentFlowScreen-Bnb9xLgu.js +0 -1
- package/dist/cjs/MfaAuthVerifyFlowScreen-Bn7NxwbP.js +0 -1
- package/dist/cjs/MfaEnrollmentFlowScreen-DixH-nyJ.js +0 -1
- package/dist/cjs/MfaVerifyFlowScreen-BtjZAo_J.js +0 -1
- package/dist/cjs/MoonpayStatusScreen-BAgiyXOW.js +0 -16
- package/dist/cjs/OAuthStatusScreen-RWYIpAEG.js +0 -1
- package/dist/cjs/PasskeySelectSignupOrLogin-DvUcmWfj.js +0 -1
- package/dist/cjs/PasskeyStatusScreen-CpL_C3--.js +0 -3
- package/dist/cjs/PasswordRecoveryScreen-FcFRBHq1.js +0 -20
- package/dist/cjs/RecoveryOAuthStatusScreen-AV5BAFgZ.js +0 -1
- package/dist/cjs/RecoveryPasswordCreateScreen-CvtuH2mp.js +0 -1
- package/dist/cjs/SignRequestScreen-B5xPIK1u.js +0 -26
- package/dist/cjs/TelegramAuthScreen-CjTMUNYb.js +0 -1
- package/dist/cjs/UpdateEmailScreen-BvzkGAlB.js +0 -1
- package/dist/cjs/UpdatePhoneScreen-e8rAhVvP.js +0 -1
- package/dist/cjs/UserLimitReachedScreen-x5P5FX13.js +0 -1
- package/dist/cjs/WalletInterstitialScreen-DrApzB6o.js +0 -1
- package/dist/cjs/index-BZqehL-Z.js +0 -174
- package/dist/cjs/smart-wallets-xoXme78U.js +0 -1
- package/dist/cjs/use-export-wallet-1gw5h-6F.js +0 -1
- package/dist/cjs/use-export-wallet-CedJPqOx.js +0 -1
- package/dist/cjs/useActiveWallet-4V55N-5C.js +0 -185
- package/dist/cjs/usePrivy-Tr-VZh0x.js +0 -1
- package/dist/cjs/useWallets-By_aiK-e.js +0 -1
- package/dist/cjs/useWallets-Ds2FjLWj.js +0 -1
- package/dist/esm/AccountNotFoundScreen-DvDKQEeR.mjs +0 -1
- package/dist/esm/AffirmativeConsentScreen-DmjKmR3p.mjs +0 -6
- package/dist/esm/AllowlistRejectionScreen-Dzgqqss9.mjs +0 -1
- package/dist/esm/AuthenticateWithWalletScreen-DqEYmKRq.mjs +0 -1
- package/dist/esm/AwaitingEvmToSolBridgingScreen-mM0yFabb.mjs +0 -2
- package/dist/esm/AwaitingExternalEthereumTransferScreen-B8RwfC4k.mjs +0 -2
- package/dist/esm/AwaitingPasswordlessCodeScreen-DiwMdkl1.mjs +0 -103
- package/dist/esm/AwaitingSolToEvmBridgingScreen-DDjqJpxK.mjs +0 -2
- package/dist/esm/CaptchaScreen-DRpV5XFL.mjs +0 -1
- package/dist/esm/CoinbaseOnrampStatusScreen-B5SpiCFR.mjs +0 -16
- package/dist/esm/ConnectEmailForm-CUfcb4US.mjs +0 -3
- package/dist/esm/ConnectLedgerScreen-D54DrxnP.mjs +0 -9
- package/dist/esm/ConnectOnlyLandingScreen-Cm10LiWd.mjs +0 -1
- package/dist/esm/ConnectOnlyStatusScreen-Bz7rafsR.mjs +0 -1
- package/dist/esm/ConnectOrCreateScreen-aeQK2RJ_.mjs +0 -1
- package/dist/esm/ConnectionStatusScreen-_g1A1Dg2.mjs +0 -7
- package/dist/esm/CrossAppAuthScreen-4oQDzYzy.mjs +0 -1
- package/dist/esm/DelegatedActionsConsentScreen-Cj9bU7Q1.mjs +0 -1
- package/dist/esm/DelegatedActionsRevokeScreen-DGFRARuM.mjs +0 -1
- package/dist/esm/EmbeddedWalletConnectingScreen-Cmt8I8TX.mjs +0 -1
- package/dist/esm/EmbeddedWalletCreatedScreen-Dj_JuLO5.mjs +0 -1
- package/dist/esm/EmbeddedWalletOnAccountCreateScreen-BOS_pyDI.mjs +0 -1
- package/dist/esm/EmbeddedWalletPasswordUpdateScreen-DulDjFpp.mjs +0 -1
- package/dist/esm/EmbeddedWalletPasswordUpdateSplashScreen-BkwyRHPS.mjs +0 -1
- package/dist/esm/ErrorScreen-8UMMZ6is.mjs +0 -4
- package/dist/esm/FarcasterSignerStatusScreen-RHH68QtJ.mjs +0 -28
- package/dist/esm/FundSolWalletWithExternalSolanaWallet-DVgX3EaM.mjs +0 -1
- package/dist/esm/FundingEditAmountScreen-D10JPLdP.mjs +0 -1
- package/dist/esm/FundingMethodSelectionScreen-BuWGEgge.mjs +0 -1
- package/dist/esm/InAppBrowserLoginNotPossible-TigdvlfS.mjs +0 -1
- package/dist/esm/InstallWalletScreen-DgyXxk_4.mjs +0 -1
- package/dist/esm/LandingScreen-C6rQCvI5.mjs +0 -1
- package/dist/esm/LinkEmailScreen-C7CpFuoA.mjs +0 -1
- package/dist/esm/LinkPhoneScreen-BKHv_Kdp.mjs +0 -1
- package/dist/esm/LoginFailedScreen-CJgWFc1S.mjs +0 -1
- package/dist/esm/ManualTransferScreen-CFNzuajf.mjs +0 -1
- package/dist/esm/MfaAuthEnrollmentFlowScreen-DflCQFD5.mjs +0 -1
- package/dist/esm/MfaAuthVerifyFlowScreen-D0KWDrSF.mjs +0 -1
- package/dist/esm/MfaEnrollmentFlowScreen-B5CTxsyW.mjs +0 -1
- package/dist/esm/MfaVerifyFlowScreen-Bds0d6wr.mjs +0 -1
- package/dist/esm/MoonpayStatusScreen-BgCvITlM.mjs +0 -16
- package/dist/esm/OAuthStatusScreen-B9LjQopq.mjs +0 -1
- package/dist/esm/PasskeySelectSignupOrLogin-BH-9DnYX.mjs +0 -1
- package/dist/esm/PasskeyStatusScreen-B0BMf34N.mjs +0 -3
- package/dist/esm/PasswordRecoveryScreen-BGO3xmU6.mjs +0 -20
- package/dist/esm/RecoveryOAuthStatusScreen-9ngTLe_q.mjs +0 -1
- package/dist/esm/RecoveryPasswordCreateScreen-BDCDfQzo.mjs +0 -1
- package/dist/esm/TelegramAuthScreen-CXnXpJTY.mjs +0 -1
- package/dist/esm/UpdateEmailScreen-B4u7SqtR.mjs +0 -1
- package/dist/esm/UpdatePhoneScreen-Dz75pT5l.mjs +0 -1
- package/dist/esm/UserLimitReachedScreen-BEQAxJvA.mjs +0 -1
- package/dist/esm/WalletInterstitialScreen-jHLFeLvC.mjs +0 -1
- package/dist/esm/context-bWeWAiND.mjs +0 -1
- package/dist/esm/index-DEtvMjrv.mjs +0 -174
- package/dist/esm/reservoir-0wfhnc0j.mjs +0 -1
- package/dist/esm/smart-wallets-wzmiQDh1.mjs +0 -1
- package/dist/esm/use-export-wallet-8amsQKG9.mjs +0 -1
- package/dist/esm/use-export-wallet-DyNNbsJn.mjs +0 -1
- package/dist/esm/useActiveWallet-CSq3KvGj.mjs +0 -185
- package/dist/esm/usePrivy-CvOp4eQ7.mjs +0 -1
- package/dist/esm/useWallets-izyyA2re.mjs +0 -1
- package/dist/esm/useWallets-yDa5ACXD.mjs +0 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";var e=require("react/jsx-runtime"),t=require("react"),r=require("@privy-io/js-sdk-core"),n=require("uuid"),i=require("jose"),a=require("./get-is-unified-wallet-pvisKZtt.js"),s=require("eventemitter3"),o=require("./useActiveWallet-DQaSSN2M.js"),l=require("./internal-context-BJv4f_bO.js"),c=require("./use-export-wallet-BHqL5lkN.js"),d=require("@coinbase/wallet-sdk"),u=require("react-device-detect"),h=require("@walletconnect/ethereum-provider"),p=require("./usePrivy-DN8Ajdzm.js"),y=require("./context-BgcJR59W.js"),w=require("zustand"),m=require("ofetch"),g=require("./paths-DizMb-lU.js"),v=require("js-cookie"),f=require("./PrivyPluginContext-DsgaS6n9.js"),E=require("mipd"),C=require("viem/utils"),A=require("@privy-io/popup"),P=require("@scure/base"),T=require("styled-components"),k=require("./events-context-Di6--rDg.js"),_=require("@headlessui/react"),S=require("./get-entropy-details-for-user-Bh25VOwU.js"),b=require("@privy-io/urls"),I=require("viem"),W=require("@privy-io/ethereum"),U=require("./getEmbeddedConnectedWallet-pJd-l936.js"),x=require("./getPublicClient-BsmZyCGX.js"),R=require("./frame-Oz7volks.js"),O=require("@privy-io/routes"),N=require("x402/client"),M=require("@privy-io/api-base"),F=require("viem/accounts"),L=require("./use-sign-with-user-signer-Cu_6Bx7m.js");function D(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}function j(e){if(e&&"object"==typeof e&&"default"in e)return e;var t=Object.create(null);return e&&Object.keys(e).forEach((function(r){if("default"!==r){var n=Object.getOwnPropertyDescriptor(e,r);Object.defineProperty(t,r,n.get?n:{enumerable:!0,get:function(){return e[r]}})}})),t.default=e,Object.freeze(t)}var q=/*#__PURE__*/D(t),K=/*#__PURE__*/D(r),z=/*#__PURE__*/j(i),H=/*#__PURE__*/D(s),V=/*#__PURE__*/D(v);class B{static parse(e){try{return new B(e)}catch(e){return null}}static throwIfNotWellFormedJwt(e){return z.decodeJwt(e),e}get subject(){return this._decoded.sub}get expiration(){return this._decoded.exp}get issuer(){return this._decoded.iss}get audience(){return this._decoded.aud}isExpired(e=0){return Date.now()>=1e3*(this.expiration-e)}constructor(e){this.value=e,this._decoded=z.decodeJwt(e)}}class Y extends B{static parse(e){try{return new Y(e)}catch(e){return null}}get appId(){return this._decoded.aid?this._decoded.aid:this.audience}}const G="data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PScwIDAgMTAyNCAxMDI0JyBmaWxsPSdub25lJyB4bWxucz0naHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmcnIHN0eWxlPSdoZWlnaHQ6MjhweDt3aWR0aDoyOHB4Jz48cmVjdCB3aWR0aD0nMTAyNCcgaGVpZ2h0PScxMDI0JyBmaWxsPScjMDA1MkZGJyByeD0nMTAwJyByeT0nMTAwJz48L3JlY3Q+PHBhdGggZmlsbC1ydWxlPSdldmVub2RkJyBjbGlwLXJ1bGU9J2V2ZW5vZGQnIGQ9J00xNTIgNTEyQzE1MiA3MTAuODIzIDMxMy4xNzcgODcyIDUxMiA4NzJDNzEwLjgyMyA4NzIgODcyIDcxMC44MjMgODcyIDUxMkM4NzIgMzEzLjE3NyA3MTAuODIzIDE1MiA1MTIgMTUyQzMxMy4xNzcgMTUyIDE1MiAzMTMuMTc3IDE1MiA1MTJaTTQyMCAzOTZDNDA2Ljc0NSAzOTYgMzk2IDQwNi43NDUgMzk2IDQyMFY2MDRDMzk2IDYxNy4yNTUgNDA2Ljc0NSA2MjggNDIwIDYyOEg2MDRDNjE3LjI1NSA2MjggNjI4IDYxNy4yNTUgNjI4IDYwNFY0MjBDNjI4IDQwNi43NDUgNjE3LjI1NSAzOTYgNjA0IDM5Nkg0MjBaJyBmaWxsPSd3aGl0ZSc+PC9wYXRoPjwvc3ZnPg==",$="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADAAAAAwCAYAAABXAvmHAAAAAXNSR0IArs4c6QAAALZJREFUaEPtmjEOhDAMBNc/O14GvOzys3CAKK6eAlmaVGl2Zc+kTOU685vkc9/bnD2prZK5/TZY24z9P+g4F5hNh7/GdoG37WlAA5CATwgCxHENYISwQAMQII5rACOEBRqAAHFcAxghLNAABIjjGsAIYYEGIEAc1wBGCAs0AAHiuAYwQligAQgQxzWAEcICDUCAOK4BjBAWaAACxHENYISwQAMQII6fBjr+VHkW3+u+tfyxMpJaDgYzYxb/ALZVAAAAAElFTkSuQmCC";let J,Q;class X extends o.EthereumWalletConnector{async initialize(){await this.importPromise,await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:$,id:"com.coinbase.wallet"}}async promptConnection(){try{await this.importPromise;let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new l.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw c.formatConnectorError(e)}}constructor(e,t,r,n,i){super("base_account",e,t,r),this.connectorType="base_account",this.walletClientType="base_account",this.displayName="Base",this.setBaseAccountSdk=i,this.proxyProvider=new o.PrivyProxyProvider(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.baseAccountConfig={...n,appChainIds:[t.id].concat(e.map((e=>e.id)))},J?(this.proxyProvider.setWalletProvider(J.getProvider()),this.setBaseAccountSdk(J)):this.importPromise=import("@base-org/account").then((({createBaseAccountSDK:e})=>{J=e(this.baseAccountConfig),this.proxyProvider.setWalletProvider(J.getProvider()),this.setBaseAccountSdk(J)})).catch(console.error)}}let Z=[1,11155111,137,10,8453,84532,42161,7777777,43114,56];class ee extends o.EthereumWalletConnector{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}disconnect(){this.proxyProvider.walletProvider.disconnect(),this.onDisconnect()}get walletBranding(){return{name:this.displayName,icon:G,id:"com.coinbase.wallet"}}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new l.PrivyConnectorError("Unable to retrieve accounts");this.connected=!0,await this.syncAccounts([e[0]])}catch(e){throw c.formatConnectorError(e)}}updateConnectionPreference(e){this.coinbaseWalletConfig={...this.coinbaseWalletConfig,preference:{...this.coinbaseWalletConfig.preference,options:e}},this.walletClientType="smartWalletOnly"===e?"coinbase_smart_wallet":"coinbase_wallet",Q=d.createCoinbaseWalletSDK({...this.coinbaseWalletConfig}),this.proxyProvider.setWalletProvider(Q.getProvider())}constructor(e,t,n,i){if(super("coinbase_wallet",e,t,n),this.connectorType="coinbase_wallet",this.displayName="Coinbase Wallet",this.proxyProvider=new o.PrivyProxyProvider(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.coinbaseWalletConfig={...i,appChainIds:[t.id].concat(e.map((e=>e.id)))},this.walletClientType="smartWalletOnly"===this.coinbaseWalletConfig.preference?.options?"coinbase_smart_wallet":"coinbase_wallet","coinbase_smart_wallet"===this.walletClientType&&(this.displayName="Coinbase Smart Wallet"),!Q){let e="eoaOnly"!==this.coinbaseWalletConfig.preference?.options?(this.coinbaseWalletConfig.appChainIds??[]).filter((e=>!Z.includes(e))):[];e.length>0&&!e.every((e=>r.DEFAULT_SUPPORTED_CHAIN_IDS.has(e)))&&console.info(`The configured chains are not supported by Coinbase Smart Wallet: ${e.join(", ")}`),Q=d.createCoinbaseWalletSDK(this.coinbaseWalletConfig)}this.proxyProvider.setWalletProvider(Q.getProvider())}}const te=({style:t,...r})=>/*#__PURE__*/e.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",fill:"none",stroke:"currentColor",strokeWidth:1.5,viewBox:"0 0 24 24",style:{...t},...r,children:/*#__PURE__*/e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M9 17.25v1.007a3 3 0 01-.879 2.122L7.5 21h9l-.621-.621A3 3 0 0115 18.257V17.25m6-12V15a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 15V5.25m18 0A2.25 2.25 0 0018.75 3H5.25A2.25 2.25 0 003 5.25m18 0V12a2.25 2.25 0 01-2.25 2.25H5.25A2.25 2.25 0 013 12V5.25"})}),re=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"108",height:"108",viewBox:"0 0 108 108",fill:"none",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"108",height:"108",rx:"23",fill:"#AB9FF2"}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M46.5267 69.9229C42.0054 76.8509 34.4292 85.6182 24.348 85.6182C19.5824 85.6182 15 83.6563 15 75.1342C15 53.4305 44.6326 19.8327 72.1268 19.8327C87.768 19.8327 94 30.6846 94 43.0079C94 58.8258 83.7355 76.9122 73.5321 76.9122C70.2939 76.9122 68.7053 75.1342 68.7053 72.314C68.7053 71.5783 68.8275 70.7812 69.0719 69.9229C65.5893 75.8699 58.8685 81.3878 52.5754 81.3878C47.993 81.3878 45.6713 78.5063 45.6713 74.4598C45.6713 72.9884 45.9768 71.4556 46.5267 69.9229ZM83.6761 42.5794C83.6761 46.1704 81.5575 47.9658 79.1875 47.9658C76.7816 47.9658 74.6989 46.1704 74.6989 42.5794C74.6989 38.9885 76.7816 37.1931 79.1875 37.1931C81.5575 37.1931 83.6761 38.9885 83.6761 42.5794ZM70.2103 42.5795C70.2103 46.1704 68.0916 47.9658 65.7216 47.9658C63.3157 47.9658 61.233 46.1704 61.233 42.5795C61.233 38.9885 63.3157 37.1931 65.7216 37.1931C68.0916 37.1931 70.2103 38.9885 70.2103 42.5795Z",fill:"#FFFDF8"})]});function ne(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}var ie=0;class ae extends o.EthereumWalletConnector{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return{name:this.providerDetail.info.name,icon:this.providerDetail.info.icon,id:this.providerDetail.info.rdns}}disconnect(){console.warn(`Programmatic disconnect with ${this.providerDetail.info.name} is not yet supported.`)}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new l.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw c.formatConnectorError(e)}}constructor(e,t,r,n,i){super(i||"unknown",e,t,r),this.connectorType="injected",this.proxyProvider=new o.PrivyProxyProvider(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.providerDetail=n;let a=n.provider;this.proxyProvider.setWalletProvider(a)}}var se="__private_"+ie+++"__walletBranding";class oe extends o.EthereumWalletConnector{async initialize(){await this.syncAccounts(),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),await this.isConnected()?this.getConnectedWallet():null}get walletBranding(){return ne(this,se)[se]??{name:"Browser Extension",icon:te,id:"extension"}}disconnect(){console.warn("Programmatic disconnect with browser wallets is not yet supported.")}async promptConnection(){try{let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new l.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw c.formatConnectorError(e)}}constructor(e,t,r,n,i){super(i??"unknown",e,t,r),Object.defineProperty(this,se,{writable:!0,value:void 0}),this.connectorType="injected",this.proxyProvider=new o.PrivyProxyProvider(void 0,this.rpcTimeoutDuration),this.subscribeListeners(),this.proxyProvider.setWalletProvider(n),"metamask"===i?ne(this,se)[se]={name:"MetaMask",icon:o.Metamask,id:"io.metamask"}:"phantom"===i&&(ne(this,se)[se]={name:"Phantom",icon:re,id:"phantom"})}}class le extends ae{disconnect(){console.warn("MetaMask does not support programmatic disconnect.")}async promptConnection(){try{u.isMobile||await this.proxyProvider.request({method:"wallet_requestPermissions",params:[{eth_accounts:{}}]});let e=await this.proxyProvider.request({method:"eth_requestAccounts"});if(!e||0===e.length||!e[0])throw new l.PrivyConnectorError("Unable to retrieve accounts");await this.syncAccounts([e[0]])}catch(e){throw c.formatConnectorError(e)}}}class ce extends o.EthereumWalletConnector{async initialize(){let e=await this.createProvider();this.provider=e,this.proxyProvider.setWalletProvider(e),this.subscribeListeners(),e.session&&(this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=o.getExternalWalletDataByUrl(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown"),this.connected=!0,await this.syncAccounts()),this.initialized=!0,this.emit("initialized")}async connect(e){return e.showPrompt&&await this.promptConnection(),this.getConnectedWallet()}async isConnected(){return!!this.walletProvider?.connected}get walletBranding(){let e=this.walletProvider?.session?.peer.metadata.icons?.[0];return{name:o.stripEmoji(this.walletProvider?.session?.peer.metadata.name||"")||"WalletConnect",icon:"string"==typeof e?e:c.WALLET_CONNECT_LOGO_DATA_URI,id:this.walletProvider?.session?.peer.metadata.name.toLowerCase()||"wallet_connect_v2"}}async resetConnection(e){this.walletProvider&&this.walletProvider.connected&&(await this.walletProvider.disconnect(),this.walletProvider.signer.session=void 0,this.walletClientType=e,this.redirectUri=void 0,this.fallbackUniversalRedirectUri=void 0,p.deleteWalletConnectDeepLink(),this.onDisconnect())}async promptConnection(){if(this.provider)return new Promise(((e,t)=>{(async()=>{let t="",r=await Promise.race([this.walletProvider?.enable(),this.proxyProvider.walletTimeout()]);if(r?.length&&(t=r[0]),!t||""===t)throw new l.PrivyConnectorError("Unable to retrieve address");this.walletProvider?.session?.peer.metadata.url&&(this.walletEntry=o.getExternalWalletDataByUrl(this.walletProvider?.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown",this.proxyProvider.rpcTimeoutDuration=o.getRpcTimeout(this.rpcConfig,this.walletClientType)),this.connected=!0,await this.syncAccounts(r),e()})().catch((e=>{t(e?c.formatConnectorError(e):new l.PrivyConnectorError("Unknown error during connection"))}))}))}disconnect(){this.walletProvider?.disconnect().then((()=>this.onDisconnect())).catch((()=>console.warn("Unable to disconnect WalletConnect provider")))}get walletProvider(){return this.proxyProvider.walletProvider}setWalletProvider(e){this.proxyProvider.setWalletProvider(e)}async createProvider(){let e={};for(let t of this.chains){let r=o.getJsonRpcEndpoint(t.id,this.chains,this.rpcConfig,this.privyAppId);r&&(e[t.id]=r)}let t=this.shouldEnforceDefaultChainOnConnect?[this.defaultChain.id]:[],r=this.chains.map((e=>e.id)),n=await h.EthereumProvider.init({projectId:this.walletConnectCloudProjectId,chains:t,optionalChains:r,optionalEvents:h.OPTIONAL_EVENTS,optionalMethods:h.OPTIONAL_METHODS,rpcMap:e,showQrModal:!1,metadata:{description:this.privyAppName,name:this.privyAppName,url:window.location.origin,icons:[]}});return n.on("display_uri",(e=>{if(n.signer.abortPairingAttempt(),p.removeWalletConnectDeepLink(),!this.showPrivyQrModal)throw new l.PrivyConnectorError("WalletConnect modal not available - Privy handles wallet connections through its own UI");if(u.isMobile&&this.walletEntry){let{redirect:t,href:r}=p.buildTargetUrl(e,this.walletEntry);p.openHref(t,"_self"),p.setWalletConnectDeepLink({href:r,name:this.walletEntry.metadata?.shortName||this.walletEntry.name});let n=p.buildUniversalFallbackUrl(e,this.walletEntry);return this.redirectUri=t,this.fallbackUniversalRedirectUri=n?.redirect,this.showPrivyQrModal({native:t,universal:t})}if(this.redirectUri=void 0,this.walletEntry){let t=p.buildUniversalFallbackUrl(e,this.walletEntry);this.fallbackUniversalRedirectUri=t?.redirect}this.showPrivyQrModal({native:e,universal:void 0})})),n.on("connect",(()=>{n.session?.peer.metadata.url&&(this.walletEntry=o.getExternalWalletDataByUrl(n.session?.peer.metadata.url),this.walletClientType=this.walletEntry?.slug||"unknown")})),n}async enableProvider(){return this.walletProvider?.connected?Promise.resolve(this.walletProvider.accounts):await(this.walletProvider?.enable())}setWalletEntry(e,t){this.walletEntry=e,this.showPrivyQrModal=t}constructor({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,shouldEnforceDefaultChainOnConnect:i,privyAppId:a,privyAppName:s,walletClientType:l}){super(l||"unknown",r,n,t),this.connectorType="wallet_connect_v2",this.privyAppId=a,this.privyAppName=s,this.walletConnectCloudProjectId=e,this.rpcConfig=t,this.shouldEnforceDefaultChainOnConnect=i,this.proxyProvider=new o.PrivyProxyProvider(void 0,this.rpcTimeoutDuration),l&&(this.walletEntry=o.getExternalWalletData(l),this.walletClientType=l)}}class de extends H.default{get wallets(){let e=new Set;return this.walletConnectors.flatMap((e=>e.wallets)).sort(((e,t)=>e.connectedAt&&t.connectedAt?t.connectedAt-e.connectedAt:0)).filter((t=>{let r=`${t.address}${t.walletClientType}${t.connectorType}${t.meta.id}`;return!e.has(r)&&(e.add(r),!0)}))}async initialize(e){if(this.initialized&&!e||(e&&this.removeAllConnectors(),this.externalWalletConfig.disableAllExternalWallets))return;let t=o.detectInjectedConnectors({store:this.store,walletList:this.walletList,externalWalletConfig:this.externalWalletConfig,walletChainType:this.walletChainType}).then((e=>{e.forEach((({type:e,eip6963InjectedProvider:t,legacyInjectedProvider:r})=>{this.createEthereumWalletConnector({connectorType:"injected",walletClientType:e,providers:{eip6963InjectedProvider:t,legacyInjectedProvider:r}})}))}));for(let e of(this.walletList.includes("coinbase_wallet")&&this.createEthereumWalletConnector({connectorType:"coinbase_wallet",walletClientType:"coinbase_wallet"}),this.walletList.includes("base_account")&&this.createEthereumWalletConnector({connectorType:"base_account",walletClientType:"base_account"}),Object.values(o.mobileWalletsConfig)))!e.isInstalled&&this.walletList.includes(e.client)&&(["ethereum-only","ethereum-and-solana"].includes(this.walletChainType)&&e.chainTypes.includes("ethereum")&&this.createEthereumWalletConnector({connectorType:"null",walletClientType:e.client,walletConfig:e}),["ethereum-and-solana","solana-only"].includes(this.walletChainType)&&e.chainTypes.includes("solana")&&this.addSolanaWalletConnector(new o.SolanaNullConnector({id:e.client,name:e.name})));this.externalWalletConfig.walletConnect.enabled&&(this.walletList.includes("wallet_connect_qr")||o.shouldFetchWcRegistryListings(this.walletList))&&"solana-only"!==this.walletChainType&&this.createEthereumWalletConnector({connectorType:"wallet_connect_v2",walletClientType:"unknown"});let r=this.walletList.includes("wallet_connect_qr_solana")||o.shouldFetchWcRegistryListings(this.walletList)&&"ethereum-only"!==this.walletChainType,n=this.externalWalletConfig.solana.connectors?.get()||[],i=async e=>{if(!r)return;let t=e.find((e=>"walletconnect_solana"===e.walletBranding?.id));t&&t.wallet&&await t.wallet.initialize({walletConnectCloudProjectId:this.walletConnectCloudProjectId,privyAppName:this.privyAppName})};i(n),n.filter((e=>r||"walletconnect_solana"!==e.walletBranding?.id)).forEach(this.addSolanaWalletConnector),this.externalWalletConfig.solana.connectors?._setOnConnectorsUpdated?.((e=>{i(e),e?.filter((e=>r||"walletconnect_solana"!==e.walletBranding?.id)).forEach(this.addSolanaWalletConnector)})),await t,this.initialized=!0}findWalletConnector(e,t,r){return"wallet_connect_v2"===e?this.walletConnectors.filter(o.isEthereumWalletConnector).find((t=>t.connectorType===e&&(!r||t.wallets.some((e=>e.address===r)))))??null:this.walletConnectors.filter(o.isEthereumWalletConnector).find((n=>n.connectorType===e&&n.walletClientType===t&&(!r||n.wallets.some((e=>e.address===r)))))??null}findSolanaWalletConnector(e){return this.walletConnectors.filter(o.isSolanaWalletConnector).find((t=>"unknown"===t.walletClientType?t.walletBranding.id===e:t.walletClientType===e))??null}onInitialized(e){e.wallets.forEach((e=>{let t=this.storedConnections.find((t=>t.address===e.address&&t.connectorType===e.connectorType&&("solana"===e.type&&"unknown"===t.walletClientType&&"unknown"===e.walletClientType?e.meta.id===t.id:t.walletClientType===e.walletClientType)));t&&(e.connectedAt=t.connectedAt)})),this.emit("walletsUpdated"),this.emit("connectorInitialized")}onWalletsUpdated(e){e.initialized&&this.emit("walletsUpdated")}async createEthereumWalletConnector({connectorType:e,walletClientType:t,providers:r,walletConfig:n}){let i=this.findWalletConnector(e,t);if(i&&o.isEthereumWalletConnector(i))return i instanceof ce&&i.resetConnection(t),i;let a=(()=>"injected"!==e?"coinbase_wallet"===e?new ee(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.coinbaseWallet.config):"base_account"===e?new X(this.chains,this.defaultChain,this.rpcConfig,this.externalWalletConfig.baseAccount.config,this.setBaseAccountSdk):"null"!==e?new ce({walletConnectCloudProjectId:this.walletConnectCloudProjectId,rpcConfig:this.rpcConfig,chains:this.chains,defaultChain:this.defaultChain,shouldEnforceDefaultChainOnConnect:this.shouldEnforceDefaultChainOnConnect,privyAppId:this.privyAppId,privyAppName:this.privyAppName,walletClientType:t}):n?new o.EthereumNullConnector({id:n.client,name:n.name,defaultChain:this.defaultChain,walletClientType:n.client}):null:"metamask"===t&&r?.eip6963InjectedProvider?new le(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,"metamask"):"metamask"===t&&r?.legacyInjectedProvider?new oe(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"metamask"):"phantom"===t&&r?.legacyInjectedProvider?new oe(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider,"phantom"):r?.legacyInjectedProvider&&"unknown_browser_extension"===t?new oe(this.chains,this.defaultChain,this.rpcConfig,r?.legacyInjectedProvider):r?.eip6963InjectedProvider?new ae(this.chains,this.defaultChain,this.rpcConfig,r?.eip6963InjectedProvider,t):void 0)();return a&&this.addWalletConnector(a),a||null}addWalletConnector(e){this.walletConnectors.push(e),e.on("initialized",(()=>this.onInitialized(e))),e.on("walletsUpdated",(()=>this.onWalletsUpdated(e))),e.initialize().catch((e=>{console.debug("Failed to initialize connector",e)}))}setWalletList(e){this.walletList=e,this.initialized&&this.initialize(!0).catch(console.error)}removeAllConnectors(){for(let e of this.walletConnectors)e.removeAllListeners();this.walletConnectors=[]}constructor(e,t,r,n,i,a,s,o,l,d,u,h){super(),this.addSolanaWalletConnector=async e=>{let t=this.findSolanaWalletConnector(e.walletClientType);if(!t||"null"===t.connectorType){if("null"===t?.connectorType){let e=this.walletConnectors.indexOf(t);this.walletConnectors.splice(e,1)}this.addWalletConnector(e)}},this.privyAppId=e,this.walletConnectCloudProjectId=t,this.rpcConfig=r,this.chains=n,this.defaultChain=i,this.walletConnectors=[],this.initialized=!1,this.store=a,this.walletList=s,this.shouldEnforceDefaultChainOnConnect=o,this.externalWalletConfig=l,this.privyAppName=d,this.walletChainType=h||"ethereum-only",this.setBaseAccountSdk=u,this.storedConnections=c.loadConnectionHistory()}}const ue=w.create((()=>({identityToken:null})));let he=[g.sessionsRefreshPath,g.sessionsLogoutPath,g.analyticsEventsPath];class pe{async get(e,t){try{return await this.baseFetch(e,t)}catch(e){throw l.formatApiError(e)}}async post(e,t,r){try{return await this.baseFetch(e,{method:"POST",...t?{body:t}:{},...r})}catch(e){throw l.formatApiError(e)}}async delete(e,t){try{return await this.baseFetch(e,{method:"DELETE",...t})}catch(e){throw l.formatApiError(e)}}constructor({appId:e,appClientId:t,client:r,defaults:n}){this.appId=e,this.appClientId=t,this.clientAnalyticsId=r.clientAnalyticsId,this.sdkVersion=y.VERSION,this.client=r,this.defaults=n,this.fallbackApiUrl=r.fallbackApiUrl,this.baseFetch=m.ofetch.create({baseURL:this.defaults.baseURL,timeout:this.defaults.timeout,retry:3,retryDelay:500,retryStatusCodes:[408,409,425,500,502,503,504],credentials:"include",onRequest:async({request:e,options:t})=>{let r=new Headers(t.headers);r.set("privy-app-id",this.appId),this.appClientId&&r.set("privy-client-id",this.appClientId),r.set("privy-ca-id",this.clientAnalyticsId||""),r.set("privy-client",`react-auth:${this.sdkVersion}`);let n=he.includes(e.toString());if(!r.has("authorization")){let e=await this.client.getAccessToken({disableAutoRefresh:n});null!==e&&r.set("authorization",`Bearer ${e}`)}t.headers=r,t.retryDelay&&"number"==typeof t.retryDelay&&(t.retryDelay=3*t.retryDelay)},onRequestError:({error:e})=>{if(e instanceof DOMException&&"AbortError"===e.name)throw new l.PrivyTimeoutError}})}}const ye=e=>({rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification});class we{async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.customJwtAccountAuthenticatePath,{token:this.meta.token})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.customJwtAccountLinkPath,{token:this.meta.token})}catch(e){throw l.formatApiError(e)}}constructor(e){this.meta={token:e}}}function me(e){return e?{"privy-ui":"t"}:void 0}class ge{async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new l.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(g.passwordlessAuthenticatePath,{email:this.meta.email,code:this.meta.emailCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode)throw new l.PrivyClientError("Email and email code must be set prior to calling authenticate.");try{return await this.api.post(g.passwordlessLinkPath,{email:this.meta.email,code:this.meta.emailCode})}catch(e){throw l.formatApiError(e)}}async sendCodeEmail({email:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.email=e),t&&(this.meta.captchaToken=t),!this.meta.email)throw new l.PrivyClientError("Email must be set when initialzing authentication.");let n=me(r);try{return await this.api.post(g.passwordlessInitPath,{email:this.meta.email,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw l.formatApiError(e)}}constructor({email:e,captchaToken:t,disableSignup:r}){this.meta={email:e,captchaToken:t,disableSignup:r??!1}}}class ve extends ge{async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.email||!this.meta.emailCode||!this.meta.oldAddress)throw new l.PrivyClientError("Email, email code, and an old email address must be set prior to calling update.");try{return await this.api.post(g.updateEmailPath,{oldAddress:this.meta.oldAddress,newAddress:this.meta.email,code:this.meta.emailCode})}catch(e){throw l.formatApiError(e)}}constructor(e,t,r){super({email:t,captchaToken:r}),this.meta={email:t,captchaToken:r,oldAddress:e,disableSignup:!1}}}function fe(e){return crypto.getRandomValues(new Uint8Array(e))}class Ee{getOrCreateGuestCredential(e){let t=y.getGuestCredentialStorageKey(e);if(c.e()){if(c.s.get(t))return c.s.get(t);{let e=i.base64url.encode(fe(32));return c.s.put(t,e),e}}return i.base64url.encode(fe(32))}async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.guestAccountAuthenticatePath,{guest_credential:this.meta.guestCredential})}catch(e){throw l.formatApiError(e)}}async link(){throw Error("Linking is not supported for the guest flow")}constructor(e){this.meta={guestCredential:this.getOrCreateGuestCredential(e)}}}function Ce(){return"undefined"!=typeof window&&"chrome-extension:"===window.location.protocol&&"chrome"in window}function Ae(){if(!Ce())return;let e=window.chrome;return e?.runtime?.id}function Pe(){if(!Ce())return!1;let e=window.chrome;return"function"==typeof e?.identity?.launchWebAuthFlow}async function Te(e){return new Promise(((t,r)=>{Pe()?window.chrome.identity.launchWebAuthFlow({url:e,interactive:!0},(async e=>{try{let r=function(){if(!Ce())return;let e=window.chrome;return e?.runtime?.lastError?.message}();if(r||!e){let e=`WebAuthFlow failed: ${r||"Response URI missing"}`;throw Error(e)}let n=new URL(e),i=Ae();if(!i)throw Error("Invalid extension context");if("chrome-extension:"===n.protocol){if(n.hostname!==i)throw Error("Invalid responseUri origin")}else{if("https:"!==n.protocol)throw Error("Invalid responseUri protocol");{let e=n.hostname.split(".");if(3!==e.length||"chromiumapp"!==e[1]||"org"!==e[2]||e[0]!==i)throw Error("Invalid responseUri origin")}}let a=n.searchParams.get("privy_oauth_state"),s=n.searchParams.get("privy_oauth_code");if(!a||!s)throw Error("Invalid responseUri - missing required parameters");t({privyOAuthState:a,privyOAuthCode:s})}catch(e){r(e)}})):r(Error("Chrome identity API not available"))}))}function ke(){return i.base64url.encode(fe(36))}function _e(){return ke()}async function Se(e,t="S256"){if("S256"!=t)return e;{let t=await async function(e){let t=(new TextEncoder).encode(e);return new Uint8Array(await crypto.subtle.digest("SHA-256",t))}(e);return i.base64url.encode(t)}}class be{addCaptchaToken(e){this.meta.captchaToken=e}isActive(){return!!(this.meta.authorizationCode&&this.meta.stateCode&&this.meta.provider)}async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new l.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling authenticate.");if("undefined"===this.meta.authorizationCode)throw new l.PrivyClientError("User denied confirmation during OAuth flow");let e=function(){let e=c.s.get(y.CODE_VERIFIER_KEY);if(!e)throw new l.PrivyClientError("Authentication error.");return e}();try{let t=await this.api.post(g.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});return c.s.del(y.CODE_VERIFIER_KEY),c.s.del(y.HEADLESS_OAUTH_KEY),c.s.del(y.OAUTH_DISABLE_SIGNUP_KEY),t}catch(e){let t=l.formatApiError(e);if(t.privyErrorCode)throw new l.PrivyClientError(t.message||"Invalid code during OAuth flow.",void 0,t.privyErrorCode);if("User denied confirmation during OAuth flow"===t.message)throw new l.PrivyClientError("Invalid code during oauth flow.",void 0,l.PrivyErrorCode.OAUTH_USER_DENIED);throw new l.PrivyClientError("Invalid code during OAuth flow.",void 0,l.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.authorizationCode||!this.meta.stateCode)throw new l.PrivyClientError("[OAuth AuthFlow] Authorization and state codes code must be set prior to calling link.");if("undefined"===this.meta.authorizationCode)throw new l.PrivyClientError("User denied confirmation during OAuth flow");let e=c.s.get(y.CODE_VERIFIER_KEY);if(!e)throw new l.PrivyClientError("Authentication error.");try{let t=await this.api.post(g.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:e});return c.s.del(y.CODE_VERIFIER_KEY),t}catch(e){throw l.formatApiError(e)}}async getAuthorizationUrl(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.provider)throw new l.PrivyClientError("Provider must be set when initializing OAuth authentication.");let e=ke();c.s.put(y.CODE_VERIFIER_KEY,e);let t=_e();c.s.put(y.STATE_CODE_KEY,t);let r=await Se(e);this.meta.withPrivyUi||c.s.put(y.HEADLESS_OAUTH_KEY,!0),this.meta.disableSignup?c.s.put(y.OAUTH_DISABLE_SIGNUP_KEY,!0):c.s.del(y.OAUTH_DISABLE_SIGNUP_KEY);let n=me(this.meta.withPrivyUi),i=window.location.href,a=function(){let e=Ae();if(e)return`https://${e}.chromiumapp.org`}();a&&(i=a);try{return await this.api.post(g.oAuthInitPath,{provider:this.meta.provider,redirect_to:this.meta.customOAuthRedirectUrl||i,token:this.meta.captchaToken,code_challenge:r,state_code:t},{headers:{...n}})}catch(e){throw l.formatApiError(e)}}constructor(e){this.meta=e}}function Ie(){let e=new URLSearchParams(window.location.search),t=e.get("privy_oauth_code"),r=e.get("privy_oauth_state"),n=e.get("privy_oauth_provider");if(!t||!r||!n)return{inProgress:!1};let i=!1;try{i=!!window.opener.location.origin}catch{}return{inProgress:!0,authorizationCode:t,stateCode:r,provider:n,withPrivyUi:!c.s.get(y.HEADLESS_OAUTH_KEY),popupFlow:null!==window.opener&&i,disableSignup:!!c.s.get(y.OAUTH_DISABLE_SIGNUP_KEY)}}function We(){let e=new URL(window.location.href);e.searchParams.delete("privy_oauth_code"),e.searchParams.delete("privy_oauth_provider"),e.searchParams.delete("privy_oauth_state"),c.s.del(y.STATE_CODE_KEY),window.history.replaceState({},"",e)}class Ue{execute(e){return null===this.promise&&(this.promise=(async()=>{try{return await this.fn(e)}finally{this.promise=null}})()),this.promise}constructor(e){this.promise=null,this.fn=e}}const xe=({address:e,chainId:t,nonce:r})=>`${window.location.host} wants you to sign in with your Ethereum account:\n${e}\n\nBy signing, you are proving you own this wallet and logging in. This does not initiate a transaction or cost any fees.\n\nURI: ${window.location.origin}\nVersion: 1\nChain ID: ${t}\nNonce: ${r}\nIssued At: ${(new Date).toISOString()}\nResources:\n- https://privy.io`;class Re{get meta(){return{connectorType:this.wallet?.connectorType,walletClientType:this.wallet?.walletClientType,chainId:this.wallet?.chainId,address:this.wallet?.address,disableSignup:this._meta.disableSignup}}async authenticate(){if(!this.client)throw new l.PrivyClientError("SiweFlow has no client instance");try{if(this.preparedMessage&&this.signature)return await this.client.authenticateWithSiweInternal({message:this.preparedMessage,signature:this.signature,chainId:this.wallet?.chainId,walletClientType:this.walletClientType??this.wallet?.walletClientType,connectorType:this.connectorType??this.wallet?.connectorType,mode:this._meta.disableSignup?"no-signup":"login-or-sign-up"});if(!this.wallet)throw new l.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.client)throw new l.PrivyClientError("SiweFlow has no client instance");try{if(!this.wallet)throw new l.PrivyClientError("SiweFlow has no wallet instance");let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiweInternal({message:e,signature:t,chainId:this.wallet.chainId,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType})}catch(e){throw l.formatApiError(e)}}async sign(){if(!this.client)throw new l.PrivyClientError("SiweFlow has no client instance");if(await this.buildMessage(),!this.preparedMessage)throw new l.PrivyClientError("Could not prepare SIWE message");if(!this.wallet)throw new l.PrivyClientError("SiweFlow has no wallet instance");let e=await this.wallet.sign(this.preparedMessage);return{message:this.preparedMessage,signature:e}}async _getNonceOnce(){if(!this.client)throw new l.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new l.PrivyClientError("UI SiweFlow has no wallet instance");return await this.client.generateSiweNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new l.PrivyClientError("SiweFlow has no client instance");if(!this.wallet)throw new l.PrivyClientError("SiweFlow has no wallet instance");let e=this.wallet.address,t=this.wallet.chainId.replace("eip155:","");return this.nonce||(this.nonce=await this.getNonceOnce.execute()),this.preparedMessage=xe({address:e,chainId:t,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,i){this._meta={disableSignup:!1},this.getNonceOnce=new Ue(this._getNonceOnce.bind(this)),this.wallet=t,this.captchaToken=r,this.client=e,this._meta.disableSignup=n,this.preparedMessage=i?.message,this.signature=i?.signature,this.walletClientType=i?.walletClientType,this.connectorType=i?.connectorType}}class Oe{async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new l.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(g.passwordlessSmsAuthenticatePath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode)throw new l.PrivyClientError("phone number and sms code must be set prior to calling authenticate.");try{return await this.api.post(g.passwordlessSmsLinkPath,{phoneNumber:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw l.formatApiError(e)}}async sendSmsCode({phoneNumber:e,captchaToken:t,withPrivyUi:r}){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(e&&(this.meta.phoneNumber=e),t&&(this.meta.captchaToken=t),!this.meta.phoneNumber)throw new l.PrivyClientError("phone nNumber must be set when initialzing authentication.");let n=me(r);try{return await this.api.post(g.passwordlessSmsInitPath,{phoneNumber:this.meta.phoneNumber,token:this.meta.captchaToken},{headers:{...n}})}catch(e){throw l.formatApiError(e)}}constructor({phoneNumber:e,captchaToken:t,disableSignup:r}){this.meta={phoneNumber:e,captchaToken:t,disableSignup:r??!1}}}class Ne extends Oe{async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.phoneNumber||!this.meta.smsCode||!this.meta.oldPhoneNumber)throw new l.PrivyClientError("Phone number, sms code, and an old phone number must be set prior to calling update.");try{return await this.api.post(g.updatePhonePath,{old_phone_number:this.meta.oldPhoneNumber,new_phone_number:this.meta.phoneNumber,code:this.meta.smsCode})}catch(e){throw l.formatApiError(e)}}constructor(e,t,r){super({phoneNumber:t,captchaToken:r}),this.meta={phoneNumber:t,captchaToken:r,oldPhoneNumber:e,disableSignup:!1}}}function Me(){return!(u.isSafari&&window.location.origin.startsWith("http://localhost"))}var Fe,Le=((Fe={}).PRIVY="privy_access_token",Fe.CUSTOMER="customer_access_token",Fe);class De{get token(){return this.privyAccessToken||this.customerAccessToken}getToken(e){return"privy_access_token"===e?this.privyAccessToken:this.customerAccessToken}get customerAccessToken(){return this._getToken(y.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY)}get privyAccessToken(){return this._getToken(y.PRIVY_ACCESS_TOKEN_STORAGE_KEY)}_getToken(e){try{let t=c.s.get(e);return"string"==typeof t?B.throwIfNotWellFormedJwt(t):null}catch(e){return console.error(e),this.destroyLocalState(),null}}get refreshToken(){try{let e=c.s.get(y.REFRESH_TOKEN_STORAGE_KEY);return"string"==typeof e?e:null}catch(e){return console.error(e),this.destroyLocalState(),null}}getProviderAccessToken(e){try{let t=c.s.get(y.getProviderAccessTokenStorageKey(e));if("string"!=typeof t)return null;{let r=new B(t);return r.isExpired()?(c.s.del(y.getProviderAccessTokenStorageKey(e)),null):r.value}}catch(e){return console.error(e),null}}get mightHaveServerCookies(){try{let e=V.default.get(y.SESSION_COOKIE_KEY);return void 0!==e&&e.length>0}catch(e){console.error(e)}return!1}hasRefreshCredentials(e="privy_access_token"){let t="string"==typeof this.getToken(e),r="string"==typeof this.refreshToken&&this.refreshToken!==y.DEPRECATED_REFRESH_TOKEN;return this.mightHaveServerCookies||t&&r}hasActiveAccessToken(e){let t=B.parse(this.getToken(e));return null!==t&&!t.isExpired(30)}authenticate(e){return this.authenticateOnce.execute(e)}link(e){return this.linkOnce.execute(e)}refresh(){return this.refreshOnce.execute()}destroy(){return this.destroyOnce.execute()}storeProviderAccessToken(e,t){"string"==typeof t?c.s.put(y.getProviderAccessTokenStorageKey(e),t):c.s.del(y.getProviderAccessTokenStorageKey(e))}updateIdentityToken(e){"string"==typeof e?this.storeIdentityToken(e):this.clearIdentityToken()}async _authenticate(e){try{let t=await e.authenticate(),{user:r,is_new_user:n,oauth_tokens:i}=t;this.handleTokenResponse(t);let s=i?{provider:i.provider,accessToken:i.access_token,accessTokenExpiresInSeconds:i.access_token_expires_in_seconds,refreshToken:i.refresh_token,refreshTokenExpiresInSeconds:i.refresh_token_expires_in_seconds,scopes:i.scopes}:void 0;return this._trackAuthenticateEvents(e,n),{user:a.convertUserResponseToUser(r),isNewUser:n,oAuthTokens:s}}catch(e){throw console.warn("Error authenticating session"),l.formatPrivyError(e)}}_trackAuthenticateEvents(e,t){let r=function(e){return e instanceof ge?"email":e instanceof Oe?"sms":e instanceof Re?"siwe":e instanceof Ee?"guest":e instanceof we?"custom_auth":e instanceof be?e.meta.provider:null}(e);r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate",payload:{method:r,isNewUser:t}}),"siwe"===r&&this.client&&this.client.createAnalyticsEvent({eventName:"sdk_authenticate_siwe",payload:{connectorType:e.meta.connectorType,walletClientType:e.meta.walletClientType}})}async _link(e){try{let t=await e.link(),r=t.oauth_tokens,n=r?{provider:r.provider,accessToken:r.access_token,accessTokenExpiresInSeconds:r.access_token_expires_in_seconds,refreshToken:r.refresh_token,refreshTokenExpiresInSeconds:r.refresh_token_expires_in_seconds,scopes:r.scopes}:void 0;return{user:a.convertUserResponseToUser(t),oAuthTokens:n}}catch(e){throw console.warn("Error linking account"),l.formatPrivyError(e)}}async _refresh(){if(!this.api)throw new l.PrivyClientError("Session has no API instance");if(!this.client)throw new l.PrivyClientError("Session has no PrivyClient instance");await this.client.getAccessToken({disableAutoRefresh:!0});let e=this.token,t=this.refreshToken;if(this.client.useServerCookies&&!this.mightHaveServerCookies&&this.token&&window.location.origin===this.client.apiUrl)return this.destroyLocalState(),null;try{let r;if(!(e&&t||this.mightHaveServerCookies))return null;{let n={};e&&(n.authorization=`Bearer ${e}`),r=await this.api.post(g.sessionsRefreshPath,t?{refresh_token:t}:{},{headers:n})}return this.handleTokenResponse(r),a.convertUserResponseToUser(r.user)}catch(e){if(e instanceof l.PrivyApiError&&e.privyErrorCode===l.PrivyErrorCode.MISSING_OR_INVALID_TOKEN)return console.warn("Unable to refresh tokens - token is missing or no longer valid"),this.destroyLocalState(),null;throw l.formatPrivyError(e)}}handleTokenResponse(e){e.session_update_action&&"set"!==e.session_update_action?"clear"===e.session_update_action?this.destroyLocalState():"ignore"===e.session_update_action&&(e.token&&(this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token)),e.identity_token&&this.storeIdentityToken(e.identity_token)):this._storeAllTokens(e)}_storeAllTokens(e){this.storeRefreshToken(e.refresh_token),this.storeCustomerAccessToken(e.token),this.storePrivyAccessToken(e.privy_access_token),e.identity_token&&this.storeIdentityToken(e.identity_token)}async _destroy(){try{await(this.api?.post(g.sessionsLogoutPath,{refresh_token:this.refreshToken}))}catch(e){console.warn("Error destroying session")}this.destroyLocalState()}destroyLocalState(){this.storeRefreshToken(null),this.storeCustomerAccessToken(null),this.storePrivyAccessToken(null),this.clearIdentityToken()}storeCustomerAccessToken(e){if("string"==typeof e){let t=c.s.get(y.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY);if(c.s.put(y.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY,e),!this.client?.useServerCookies){let t=B.parse(e)?.expiration;V.default.set(y.CUSTOMER_ACCESS_TOKEN_COOKIE_KEY,e,{sameSite:"Strict",secure:Me(),expires:t?new Date(1e3*t):void 0})}t!==e&&this.client?.onStoreCustomerAccessToken?.(e)}else c.s.del(y.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY),V.default.remove(y.CUSTOMER_ACCESS_TOKEN_COOKIE_KEY),this.client?.onDeleteCustomerAccessToken?.()}storeRefreshToken(e){"string"==typeof e?(c.s.put(y.REFRESH_TOKEN_STORAGE_KEY,e),this.client?.useServerCookies||V.default.set(y.SESSION_COOKIE_KEY,"t",{sameSite:"Strict",secure:Me(),expires:30})):(c.s.del(y.REFRESH_TOKEN_STORAGE_KEY),V.default.remove(y.REFRESH_TOKEN_COOKIE_KEY),V.default.remove(y.SESSION_COOKIE_KEY))}storePrivyAccessToken(e){"string"==typeof e?c.s.put(y.PRIVY_ACCESS_TOKEN_STORAGE_KEY,e):c.s.del(y.PRIVY_ACCESS_TOKEN_STORAGE_KEY)}storeIdentityToken(e){if(ue.setState({identityToken:e}),this.client?.useServerCookies)return;c.s.put(y.IDENTITY_TOKEN_STORAGE_KEY,e);let t=B.parse(e)?.expiration;V.default.set(y.IDENTITY_TOKEN_COOKIE_KEY,e,{sameSite:"Strict",secure:Me(),expires:t?new Date(1e3*t):void 0})}clearIdentityToken(){c.s.del(y.IDENTITY_TOKEN_STORAGE_KEY),ue.setState({identityToken:null}),V.default.remove(y.IDENTITY_TOKEN_COOKIE_KEY)}constructor(){this.authenticateOnce=new Ue((async e=>this._authenticate(e))),this.linkOnce=new Ue((async e=>this._link(e))),this.refreshOnce=new Ue(this._refresh.bind(this)),this.destroyOnce=new Ue(this._destroy.bind(this))}}let je,qe;var Ke=0,ze="__private_"+Ke+++"__getOrGenerateClientAnalyticsId";class He{getAppId(){return this.appId}initializeConnectorManager({walletConnectCloudProjectId:e,rpcConfig:t,chains:r,defaultChain:n,store:i,walletList:a,shouldEnforceDefaultChainOnConnect:s,externalWalletConfig:o,appName:l,walletChainType:c,setBaseAccountSdk:d}){this.connectors||(this.connectors=new de(this.appId,e,t,r,n,i,a,s,o,l,d,c))}generateApi(){let e=new pe({appId:this.appId,appClientId:this.appClientId,client:this,defaults:{baseURL:this.apiUrl,timeout:this.timeout}});return this.session.api=e,e}updateApiUrl(e){this.apiUrl=e||this.fallbackApiUrl,this.api=this.generateApi(),e&&(this.useServerCookies=!0)}authenticate(){if(!this.authFlow)throw new l.PrivyClientError("No auth flow in progress.");return this.session.authenticate(this.authFlow)}async link(){if(!this.authFlow)throw new l.PrivyClientError("No auth flow in progress.");let{oAuthTokens:e}=await this.session.link(this.authFlow);return{user:await this.getAuthenticatedUser(),oAuthTokens:e}}storeProviderAccessToken(e,t){this.session.storeProviderAccessToken(e,t)}getProviderAccessToken(e){return this.session.getProviderAccessToken(e)}async logout(){await this.session.destroy(),this.authFlow=void 0}clearProviderAcccessTokens(e){e.linkedAccounts.filter((e=>"cross_app"===e.type)).forEach((e=>{this.storeProviderAccessToken(e.providerApp.id,null)}))}startAuthFlow(e){return e.api=this.api,this.authFlow=e,this.authFlow}async initMfaSmsVerification(){try{await this.api.post(g.mfaPasswordlessSmsInitPath,{action:"verify"})}catch(e){throw l.formatApiError(e)}}async initMfaPasskeyVerification(){try{let e=await this.api.post(g.mfaPasskeyInitPath,{});return ye(e.options)}catch(e){throw l.formatApiError(e)}}async getCrossAppProviderDetails(e){try{return this._cachedProviderAppDetails[e]||(this._cachedProviderAppDetails[e]=await this.api.get(`/api/v1/apps/${e}/cross-app/details`)),this._cachedProviderAppDetails[e]}catch(e){console.error("Error fetching cross app provider details",e)}}async acceptTerms(){try{let e=await this.api.post(g.acceptTermsPath,{});return a.convertUserResponseToUser(e)}catch(e){throw l.formatPrivyError(e)}}async unlinkEmail(e){try{let t=await this.api.post(g.unlinkEmailPath,{address:e});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(t)}catch(e){throw l.formatPrivyError(e)}}async unlinkPhone(e){try{let t=await this.api.post(g.unlinkPhonePath,{phoneNumber:e});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(t)}catch(e){throw l.formatPrivyError(e)}}async unlinkEthereumWallet(e){try{let t=await this.api.post(g.unlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(t)}catch(e){throw l.formatPrivyError(e)}}async unlinkSolanaWallet(e){try{let t=await this.api.post(g.siwsUnlinkWalletPath,{address:e});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(t)}catch(e){throw l.formatPrivyError(e)}}async unlinkOAuth(e,t){try{let r=await this.api.post(g.unlinkOAuthPath,{provider:e,subject:t});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(r)}catch(e){throw l.formatPrivyError(e)}}async unlinkFarcaster(e){try{let t=await this.api.post(g.unlinkFarcasterPath,{fid:e});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(t)}catch(e){throw l.formatPrivyError(e)}}async unlinkTelegram(e){try{let t=await this.api.post(g.telegramAccountUnlinkPath,{telegram_user_id:e});return await this.getAuthenticatedUser()??a.convertUserResponseToUser(t)}catch(e){throw l.formatPrivyError(e)}}async revokeDelegatedWallet(){try{await this.api.post(g.delegatedActionsRevokePath,{})}catch(e){throw l.formatPrivyError(e)}}async createAnalyticsEvent({eventName:e,payload:t,timestamp:r,options:n}){if("undefined"!=typeof window)try{this.clientAnalyticsId||console.warn("No client analytics id set, refusing to send analytics event"),await this.api.post(g.analyticsEventsPath,{event_name:e,client_id:this.clientAnalyticsId,payload:{...t||{},clientTimestamp:r?r.toISOString():(new Date).toISOString()}},{retry:-1,keepalive:n?.keepAlive??!1})}catch(e){console.log("Unable to submit event. This is not an issue.")}}async signMoonpayOnRampUrl(e){try{return this.api.post(g.moonpayPluginOnRampPath,e)}catch(e){throw l.formatPrivyError(e)}}async initCoinbaseOnRamp(e){try{return this.api.post(g.coinbaseOnRampInitPath,e)}catch(e){throw l.formatPrivyError(e)}}async getCoinbaseOnRampStatus({partnerUserId:e}){try{return this.api.get(`${g.coinbaseOnRampStatusPath}?partnerUserId=${e}`)}catch(e){throw l.formatPrivyError(e)}}async getAuthenticatedUser(){return this.session.hasRefreshCredentials()?this.session.refresh():null}async getAccessToken(e){return await this.getPrivyAccessToken(e)||await this.getCustomerAccessToken(e)}async getCustomerAccessToken(e){return await this._getToken(Le.CUSTOMER,e)}async getPrivyAccessToken(e){return await this._getToken(Le.PRIVY,e)}async _getToken(e,t){return this.session.getToken(e)?this.session.hasActiveAccessToken(e)?this.session.hasRefreshCredentials(e)?Y.parse(this.session.getToken(e))?.appId!==this.appId?(await this.logout(),null):this.session.getToken(e):(this.session.destroyLocalState(),null):!t?.disableAutoRefresh&&this.session.hasRefreshCredentials(e)?(await this.session.refresh(),this.session.getToken(e)):null:null}async getUsdTokenPrice(e){try{return(await this.api.get(`/api/v1/token_price?chainId=${e.id}&tokenSymbol=${e.nativeCurrency.symbol}`)).usd}catch(t){return void console.error(`Unable to fetch token price for chain with id ${e.id}`)}}async getUsdPriceForSol(){try{return(await this.api.get("/api/v1/token_price?chainId=0&tokenSymbol=SOL")).usd}catch(e){return void console.error("Unable to fetch token price for SOL")}}async getSplTokenMetadata({mintAddress:e,cluster:t}){try{return await this.api.get(`/api/v1/spl_token_info?mint_address=${e}&cluster=${t}`)}catch(r){return void console.error(`Unable to fetch token metadata for ${t}:${e}`)}}async requestFarcasterSignerStatus(e){try{return await this.api.post("/api/v1/farcaster/signer/status",{ed25519_public_key:e})}catch(e){throw console.error("Unable to fetch Farcaster signer status"),e}}async generateSiweNonce({address:e,captchaToken:t}){try{return(await this.api.post(g.siweInitPath,{address:e,token:t})).nonce}catch(e){throw l.formatPrivyError(e)}}async authenticateWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i,mode:a}){return await this.api.post(g.siweAuthenticatePath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:i,mode:a})}async linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i}){return await this.api.post(g.siweLinkPath,{message:e,signature:t,chainId:r,walletClientType:n,connectorType:i})}async linkSmartWallet({message:e,signature:t,smartWalletType:r,smartWalletVersion:n}){try{let i=await this.api.post(g.smartWalletLinkPath,{message:e,signature:t,smart_wallet_type:r,smart_wallet_version:n});return a.convertUserResponseToUser(i)}catch(e){throw l.formatPrivyError(e)}}async linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i}){try{let s=await this.linkWithSiweInternal({message:e,signature:t,chainId:r,walletClientType:n,connectorType:i});return a.convertUserResponseToUser(s)}catch(e){throw l.formatPrivyError(e)}}async generateSiwsNonce({address:e,captchaToken:t}){try{return(await this.api.post(g.siwsInitPath,{address:e,token:t})).nonce}catch(e){throw l.formatPrivyError(e)}}async authenticateWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,mode:i,messageType:a="plain"}){return await this.api.post(g.siwsAuthenticatePath,{message:e,signature:t,walletClientType:r,connectorType:n,mode:i,message_type:a})}async authenticateWithSiws({message:e,signature:t,walletClientType:r,connectorType:n,mode:i,messageType:s="plain"}){let o=await this.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,mode:i,messageType:s});this.session.handleTokenResponse(o);let l=a.convertUserResponseToUser(o.user);if(!l)throw Error("Authentication failed - no user returned");return{user:l,isNewUser:o.is_new_user||!1}}async sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:i,telegramWebAppData:s,farcasterEmbeddedAddress:o,oAuthUserInfo:c}){try{let l,d;switch(r){case"email":l=g.transferEmailPath,d={nonce:e,email:t};break;case"sms":l=g.transferPhonePath,d={nonce:e,phoneNumber:t};break;case"siwe":if(l=g.transferWalletPath,!n)throw Error("Wallet parameters must be defined");d={nonce:e,address:t,...n};break;case"farcaster":l=g.transferFarcasterPath,d={nonce:e,farcaster_id:t,farcaster_embedded_address:o};break;case"telegram":l=g.telegramAccountTransferPath,d={nonce:e,telegram_auth_result:i,telegram_web_app_data:s};break;case"siws":l=g.siwsTransferPath,d={nonce:e,address:t,...n};break;case"custom":case"guest":case"passkey":throw Error("Invalid transfer account type");default:l=g.transferOAuthPath,d={nonce:e,userInfo:c}}let u=await this.api.post(l,d);return await this.getAuthenticatedUser()??a.convertUserResponseToUser(u)}catch(e){throw l.formatPrivyError(e)}}async linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:i="plain"}){return await this.api.post(g.siwsLinkPath,{message:e,signature:t,walletClientType:r,connectorType:n,message_type:i})}async linkWithSiws({message:e,signature:t,walletClientType:r,connectorType:n,messageType:i="plain"}){try{let s=await this.linkWithSiwsInternal({message:e,signature:t,walletClientType:r,connectorType:n,messageType:i});return a.convertUserResponseToUser(s)}catch(e){throw l.formatPrivyError(e)}}async updateUserAndIdToken(){try{let e=await this.api.get(g.usersMePath);return this.session.updateIdentityToken(e.identity_token),a.convertUserResponseToUser(e.user)}catch(e){throw l.formatPrivyError(e)}}async scanTransaction(e){try{return await this.api.post(g.transactionScanningPath,e)}catch(e){throw l.formatPrivyError(e)}}constructor({apiUrl:e=y.DEFAULT_PRIVY_API_URL,appId:t,appClientId:r,timeout:n=y.DEFAULT_API_TIMEOUT_MS}){Object.defineProperty(this,ze,{value:Ve}),this._cachedProviderAppDetails={},this.apiUrl=e,this.fallbackApiUrl=this.apiUrl,this.useServerCookies=e!==y.DEFAULT_PRIVY_API_URL&&e.startsWith("https://privy."),this.timeout=n,this.appId=t,this.appClientId=r,this.clientAnalyticsId=function(e,t){if(!Object.prototype.hasOwnProperty.call(e,t))throw TypeError("attempted to use private field on non-instance");return e}(this,ze)[ze](),je||(je=new De),this.session=je,this.api=this.generateApi(),this.session.client=this}}function Ve(){if("undefined"==typeof window)return null;try{let e=c.s.get(y.CLIENT_ANALYTICS_ID_KEY);if("string"==typeof e&&e.length>0)return e}catch(e){}let e=n.v4();try{return c.s.put(y.CLIENT_ANALYTICS_ID_KEY,e),e}catch(t){return e}}function Be(){if(!qe)throw new l.PrivyClientError("No global PrivyClient instance found. Please ensure you have initialized the PrivyProvider.");return qe}class Ye{get meta(){return this._meta}async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new l.PrivyClientError("Auth flow must be initialized first");try{let e=await this.api.post(g.farcasterAuthenticatePath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"});if(!e)throw new l.PrivyClientError("No response from authentication");return e}catch(e){throw l.formatApiError(e)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.farcasterLinkPath,{channel_token:this.meta.channelToken,message:this.message,signature:this.signature,fid:this.fid})}catch(e){throw l.formatApiError(e)}}async _startChannelOnce(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");let e=await this.api.post(g.farcasterInitPath,{token:this.captchaToken});u.isMobile&&!u.isIOS&&e.connect_uri&&p.openHref(e.connect_uri,"_blank"),this._meta={...this._meta,connectUri:e.connect_uri,channelToken:e.channel_token}}async initializeFarcasterConnect(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");await this.startChannelOnce.execute()}async _pollForReady(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!this.meta.channelToken)throw new l.PrivyClientError("Auth flow must be initialized first");let e=await this.api.get(g.farcasterStatusPath,{headers:{"farcaster-channel-token":this.meta.channelToken}});return"completed"===e.state&&(this.message=e.message,this.signature=e.signature,this.fid=e.fid,!0)}constructor(e,t=!1){this._meta={disableSignup:!1},this.captchaToken=e,this.startChannelOnce=new Ue(this._startChannelOnce.bind(this)),this.pollForReady=new Ue(this._pollForReady.bind(this)),this._meta.disableSignup=t}}class Ge{async initRegisterFlow(e){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!0,this.meta.initRegisterResponse=await this.initRegisterOnce.execute(e)}async initAuthenticationFlow(e){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");this.authenticateForRegistration=!1,this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute(e)}async initLinkFlow(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");this.meta.initLinkResponse=await this.initLinkOnce.execute()}async register(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new l.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initRegisterResponse||(this.meta.initRegisterResponse=await this.initRegisterOnce.execute());try{let t=this.meta.initRegisterResponse.options,r=await e.startRegistration({optionsJSON:this._transformInitLinkOptionsToCamelCase(t)});return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(g.passkeyRegisterPath,{relying_party:this.meta.initRegisterResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new l.PrivyClientError("Passkey request timed out or rejected by user.",void 0,l.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw l.formatApiError(e)}}async authenticate(){if(this.authenticateForRegistration)return this.register();let e=await import("@simplewebauthn/browser");if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new l.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initAuthenticateResponse||(this.meta.initAuthenticateResponse=await this.initAuthenticateOnce.execute());let t=this.meta.allowedCredentialsIds?.map((e=>({type:"public-key",id:e})))??this.meta.initAuthenticateResponse.options.allow_credentials;try{let r=await e.startAuthentication({optionsJSON:this._transformInitAuthenticateOptionsToCamelCase({...this.meta.initAuthenticateResponse.options,allow_credentials:t})});return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(g.passkeyAuthenticatePath,{relying_party:this.meta.initAuthenticateResponse.relying_party,challenge:this.meta.initAuthenticateResponse.options.challenge,authenticator_response:this._transformAuthenticationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new l.PrivyClientError("Passkey request timed out or rejected by user.",void 0,l.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw l.formatApiError(e)}}async link(){let e=await import("@simplewebauthn/browser");if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");if(!e.browserSupportsWebAuthn())throw new l.PrivyClientError("WebAuthn is not supported in this browser");this.meta.initLinkResponse||(this.meta.initLinkResponse=await this.initLinkOnce.execute());try{let t=this.meta.initLinkResponse.options,r=await e.startRegistration({optionsJSON:this._transformInitLinkOptionsToCamelCase(t)});return this.meta.setPasskeyAuthState?.({status:"submitting-response"}),await this.api.post(g.passkeyLinkPath,{relying_party:this.meta.initLinkResponse.relying_party,authenticator_response:this._transformRegistrationResponseToSnakeCase(r)})}catch(e){if("NotAllowedError"===e.name)throw new l.PrivyClientError("Passkey request timed out or rejected by user.",void 0,l.PrivyErrorCode.PASSKEY_NOT_ALLOWED);throw l.formatApiError(e)}}async _initRegisterOnce(e){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");let t=me(e);return await this.api.post(g.passkeyInitRegisterPath,{token:this.meta.captchaToken},{headers:{...t}})}async _initAuthenticateOnce(e){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");let t=me(e);return await this.api.post(g.passkeyInitAuthenticatePath,{token:this.meta.captchaToken},{headers:{...t}})}async _initLinkOnce(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");return await this.api.post(g.passkeyInitLinkPath,{})}_transformInitLinkOptionsToCamelCase(e){return{rp:e.rp,user:{id:e.user.id,name:e.user.name,displayName:e.user.display_name},challenge:e.challenge,pubKeyCredParams:e.pub_key_cred_params.map((e=>({type:e.type,alg:e.alg}))),timeout:e.timeout,excludeCredentials:e.exclude_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports}))),authenticatorSelection:{authenticatorAttachment:e.authenticator_selection?.authenticator_attachment,requireResidentKey:e.authenticator_selection?.require_resident_key,residentKey:e.authenticator_selection?.resident_key,userVerification:e.authenticator_selection?.user_verification},attestation:e.attestation,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props?.rk,hmacCreateSecret:e.extensions?.hmac_create_secret},hints:this.meta.hints}}_transformRegistrationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,attestation_object:e.response.attestationObject,authenticator_data:e.response.authenticatorData},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}_transformInitAuthenticateOptionsToCamelCase(e){return{rpId:e.rp_id,challenge:e.challenge,allowCredentials:e.allow_credentials?.map((e=>({id:e.id,type:e.type,transports:e.transports})))||[],timeout:e.timeout,extensions:{appid:e.extensions?.app_id,credProps:e.extensions?.cred_props,hmacCreateSecret:e.extensions?.hmac_create_secret},userVerification:e.user_verification}}_transformAuthenticationResponseToSnakeCase(e){return{id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}}constructor({captchaToken:e,setPasskeyAuthState:t,hints:r}){this.authenticateForRegistration=!1,this.initRegisterOnce=new Ue(this._initRegisterOnce.bind(this)),this.initAuthenticateOnce=new Ue(this._initAuthenticateOnce.bind(this)),this.initLinkOnce=new Ue(this._initLinkOnce.bind(this)),this.meta={captchaToken:e,setPasskeyAuthState:t,hints:r}}}class $e{get meta(){return{connectorType:this.wallet.connectorType,walletClientType:this.wallet.walletClientType,disableSignup:this._meta.disableSignup,messageType:this._meta.messageType,address:this.wallet?.address}}set messageType(e){this._meta.messageType=e}async authenticate(){if(!this.client)throw new l.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.authenticateWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up",messageType:this.meta.messageType})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.client)throw new l.PrivyClientError("SiwsFlow has no client instance");try{let{message:e,signature:t}=await this.sign();return await this.client.linkWithSiwsInternal({message:e,signature:t,walletClientType:this.wallet.walletClientType,connectorType:this.wallet.connectorType,messageType:this.meta.messageType})}catch(e){throw l.formatApiError(e)}}async sign(){let e,t;if(!this.client)throw new l.PrivyClientError("SiwsFlow has no client instance");await this.buildMessage();let r="transaction"===this.meta.messageType;if(!this.preparedMessage)throw new l.PrivyClientError("Could not prepare SIWS message");if(!r&&!this.wallet.provider.signMessage||r&&!this.wallet.provider.signTransaction)throw new l.PrivyClientError("Wallet does not support the necessary signing methods");if(r&&this._plugin){let r=await this.wallet.provider.signTransaction({transaction:P.base64.decode(this.preparedMessage)});e=P.base64.encode(r.signedTransaction),t=this._plugin.getSignatureFromTransaction(r.signedTransaction,this.wallet.address)}else{e=this.preparedMessage;let r=await this.wallet.provider.signMessage({message:(new TextEncoder).encode(this.preparedMessage)});t=P.base64.encode(r.signature)}return{message:e,signature:t}}async _getNonceOnce(){if(!this.client)throw new l.PrivyClientError("SiwsFlow has no client instance");return await this.client.generateSiwsNonce({address:this.wallet.address,captchaToken:this.captchaToken})}async buildMessage(){if(!this.client)throw new l.PrivyClientError("SiwsFlow has no client instance");let e=this.wallet.address;return this.nonce||(this.nonce=await this.getNonceOnce.execute()),"transaction"===this.meta.messageType&&this._plugin?this.preparedMessage=this._plugin.createSiwsMemoTransaction({address:e,nonce:this.nonce}):this.preparedMessage=p.prepareSiwsMessageWithNonce({address:e,nonce:this.nonce}),this.preparedMessage}constructor(e,t,r,n=!1,i="plain",a){this._meta={disableSignup:!1,messageType:"plain"},this.getNonceOnce=new Ue(this._getNonceOnce.bind(this)),this.wallet=e,this.captchaToken=r,this.client=t,this._meta.disableSignup=n,this._meta.messageType=i,this._plugin=a}}const Je=/*#__PURE__*/t.createContext({enabled:!1,siteKey:"",provider:void 0,appId:void 0,token:void 0,error:void 0,status:"disabled",setToken:l.notImplemented,setError:l.notImplemented,setExecuting:l.notImplemented,waitForResult:()=>Promise.resolve(""),ref:{current:null},remove:l.noop,reset:l.notImplemented,execute:l.notImplemented});class Qe extends l.PrivyError{constructor(e,t,r){super(e||"Captcha failed"),this.type="Captcha",t instanceof Error&&(this.cause=t),this.privyErrorCode=r}}const Xe=({children:r,appId:n,captchaSiteKey:i,enabledCaptchaProvider:a})=>{let s=t.useRef(null),c=t.useRef(null),[d,u]=t.useState(),[h,p]=t.useState(),[y,w]=t.useState(!1),m=t.useMemo((()=>a?y||d||h?!y||d||h?d&&!h?{status:"success",token:d}:h?{status:"error",error:h}:{status:"ready"}:{status:"loading"}:{status:"ready"}:{status:"disabled"}),[a,d,h,y]),g=t.useMemo((()=>a?"turnstile"===a?{remove:()=>{s.current?.remove(),w(!1),p(void 0),u(void 0)},reset:()=>{s.current?.reset(),w(!1),p(void 0),u(void 0)},execute:()=>{w(!0),s.current?.execute()},waitForResult:async()=>{try{return await o.pollForResult((()=>s.current?.getResponse()),{interval:200,timeout:2e4})}catch(e){throw new Qe("Captcha failed",null,l.PrivyErrorCode.CAPTCHA_TIMEOUT)}}}:{remove:()=>{c.current?.removeCaptcha(),w(!1),p(void 0),u(void 0)},reset:()=>{c.current?.resetCaptcha(),w(!1),p(void 0),u(void 0)},execute:()=>{w(!0),c.current?.execute()},waitForResult:async()=>{try{return await o.pollForResult((()=>{let e=c.current?.getResponse();if(e)return e}),{interval:200,timeout:2e4})}catch(e){throw new Qe("Captcha failed",null,l.PrivyErrorCode.CAPTCHA_TIMEOUT)}}}:null),[a]),v=t.useMemo((()=>{if(!a||!g)return{...m,enabled:!1,siteKey:"",appId:n,setToken:l.notImplemented,setError:l.notImplemented,setExecuting:l.notImplemented,waitForResult:()=>Promise.resolve(void 0),remove:l.noop,reset:l.notImplemented,execute:l.notImplemented,provider:void 0,ref:{current:null}};let e={...m,enabled:!0,appId:n,setToken:u,setError:p,setExecuting:w};return"turnstile"===a?{...e,provider:"turnstile",ref:s,siteKey:i.split("t:")[1]??"",...g}:{...e,provider:"hcaptcha",ref:c,siteKey:i.split("h:")[1]??"",...g}}),[m,a,g,n,i]);/*#__PURE__*/return e.jsx(Je.Provider,{value:v,children:r})},Ze=()=>t.useContext(Je);async function et(e){if(e.enabled){if("error"===e.status)throw new Qe(e.error,null,l.PrivyErrorCode.CAPTCHA_FAILURE);return"success"===e.status?e.token:(e.execute(),await e.waitForResult())}}class tt{async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.telegramAccountAuthenticatePath,{captcha_token:this.meta.captchaToken,telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.telegramAccountLinkPath,{telegram_auth_result:this.meta.telegramAuthResult,telegram_web_app_data:this.meta.telegramWebAppData})}catch(e){throw l.formatApiError(e)}}constructor(e,t=!1){this.meta={disableSignup:!1},this.meta={captchaToken:e,disableSignup:!1},this.meta.disableSignup=t}}function rt(e){return Object.fromEntries(decodeURIComponent(e).split("&").map((e=>e.split("=").map(decodeURIComponent))))}function nt(){let e=new URL(window.location.href);e.searchParams.delete("id"),e.searchParams.delete("hash"),e.searchParams.delete("auth_date"),e.searchParams.delete("first_name"),e.searchParams.delete("last_name"),e.searchParams.delete("username"),e.searchParams.delete("photo_url"),e.hash="",window.history.replaceState({},"",e)}async function it(){let e=Be();return e?e.getAccessToken():Promise.resolve(c.s.get(y.PRIVY_ACCESS_TOKEN_STORAGE_KEY)||c.s.get(y.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY)||null)}let at=/*#__PURE__*/t.lazy((()=>Promise.resolve().then((function(){return require("./TurnstileWrapper-qLN0G5m7.js")})))),st=/*#__PURE__*/t.lazy((()=>Promise.resolve().then((function(){return require("./HCaptchaWrapper-CxqJE5RH.js")}))));const ot=r=>{let n=Ze();return t.useEffect((()=>n.remove),[n.remove]),n.enabled&&n.provider?/*#__PURE__*/e.jsx(t.Suspense,{fallback:null,children:/*#__PURE__*/e.jsxs("div",{className:"hidden h-0 w-0",children:["turnstile"===n.provider&&/*#__PURE__*/e.jsx(at,{...r,captchaContext:n}),"hcaptcha"===n.provider&&/*#__PURE__*/e.jsx(st,{...r,captchaContext:n})]})}):null};var lt=/*#__PURE__*/Object.freeze({__proto__:null,AccountNotFoundScreen:()=>Promise.resolve().then((function(){return require("./AccountNotFoundScreen-DopQJydk.js")})),AffirmativeConsentScreen:()=>Promise.resolve().then((function(){return require("./AffirmativeConsentScreen-DrfsiAOF.js")})),AllowlistRejectionScreen:()=>Promise.resolve().then((function(){return require("./AllowlistRejectionScreen-B4F7MdmW.js")})),AuthenticateWithWalletScreen:()=>Promise.resolve().then((function(){return require("./AuthenticateWithWalletScreen-BImVaE8G.js")})),AwaitingEvmToSolBridgingScreen:()=>Promise.resolve().then((function(){return require("./AwaitingEvmToSolBridgingScreen-Bld2VoQo.js")})),AwaitingExternalEthereumTransferScreen:()=>Promise.resolve().then((function(){return require("./AwaitingExternalEthereumTransferScreen-CK2PMVQH.js")})),AwaitingPasswordlessCodeScreen:()=>Promise.resolve().then((function(){return require("./AwaitingPasswordlessCodeScreen-mc4TfLdK.js")})),AwaitingSolToEvmBridgingScreen:()=>Promise.resolve().then((function(){return require("./AwaitingSolToEvmBridgingScreen-BHTmPSzt.js")})),CaptchaScreen:()=>Promise.resolve().then((function(){return require("./CaptchaScreen-C4OKrOJj.js")})),CoinbaseOnrampStatusScreen:()=>Promise.resolve().then((function(){return require("./CoinbaseOnrampStatusScreen-DuBusEzK.js")})),ConnectLedgerScreen:()=>Promise.resolve().then((function(){return require("./ConnectLedgerScreen-Cxy5kYQy.js")})),ConnectOnlyLandingScreen:()=>Promise.resolve().then((function(){return require("./ConnectOnlyLandingScreen-UHxAPPxv.js")})),ConnectOnlyStatusScreen:()=>Promise.resolve().then((function(){return require("./ConnectOnlyStatusScreen-D7hEyOkF.js")})),ConnectOrCreateScreen:()=>Promise.resolve().then((function(){return require("./ConnectOrCreateScreen-DCXEsisd.js")})),ConnectionStatusScreen:()=>Promise.resolve().then((function(){return require("./ConnectionStatusScreen-B5eG6O0t.js")})),CrossAppAuthScreen:()=>Promise.resolve().then((function(){return require("./CrossAppAuthScreen-BHfk_dqk.js")})),DelegatedActionsConsentScreen:()=>Promise.resolve().then((function(){return require("./DelegatedActionsConsentScreen-LeQ6Lxpc.js")})),DelegatedActionsRevokeScreen:()=>Promise.resolve().then((function(){return require("./DelegatedActionsRevokeScreen-C8v4E_cj.js")})),EmbeddedWalletConnectingScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletConnectingScreen-B1rrh4GO.js")})),EmbeddedWalletCreatedScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletCreatedScreen-Cem5Ix9r.js")})),EmbeddedWalletKeyExportScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletKeyExportScreen-C9Et_UFA.js")})),EmbeddedWalletOnAccountCreateScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletOnAccountCreateScreen-tJoXkQEs.js")})),EmbeddedWalletPasswordCreateScreen:()=>Promise.resolve().then((function(){return require("./RecoveryPasswordCreateScreen-DzNiXRjH.js")})),EmbeddedWalletPasswordUpdateScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletPasswordUpdateScreen-C2wVljgA.js")})),EmbeddedWalletPasswordUpdateSplashScreen:()=>Promise.resolve().then((function(){return require("./EmbeddedWalletPasswordUpdateSplashScreen-CG1oHF6a.js")})),ErrorScreen:()=>Promise.resolve().then((function(){return require("./ErrorScreen-Ckke6sz3.js")})),FarcasterConnectStatusScreen:()=>Promise.resolve().then((function(){return require("./FarcasterConnectStatusScreen-D5ziktAq.js")})),FarcasterSignerStatusScreen:()=>Promise.resolve().then((function(){return require("./FarcasterSignerStatusScreen-8edRjO2Y.js")})),FundSolWalletWithExternalSolanaWallet:()=>Promise.resolve().then((function(){return require("./FundSolWalletWithExternalSolanaWallet-DJEyYpCy.js")})),FundingAmountEditScreen:()=>Promise.resolve().then((function(){return require("./FundingEditAmountScreen-2vgGeOzZ.js")})),FundingMethodSelectionScreen:()=>Promise.resolve().then((function(){return require("./FundingMethodSelectionScreen-D6K2RTnb.js")})),InAppBrowserLoginNotPossible:()=>Promise.resolve().then((function(){return require("./InAppBrowserLoginNotPossible-DlH26fht.js")})),InstallWalletScreen:()=>Promise.resolve().then((function(){return require("./InstallWalletScreen-D-aty_-m.js")})),LandingScreen:()=>Promise.resolve().then((function(){return require("./LandingScreen-C3ycf-sm.js")})),LinkConflictScreen:()=>Promise.resolve().then((function(){return require("./LinkConflictScreen-tpqlaHKl.js")})),LinkEmailScreen:()=>Promise.resolve().then((function(){return require("./LinkEmailScreen-CVJ8MM6X.js")})),LinkPasskeyScreen:()=>Promise.resolve().then((function(){return require("./LinkPasskeyScreen-BVI23any.js")})),LinkPhoneScreen:()=>Promise.resolve().then((function(){return require("./LinkPhoneScreen-COZH83MT.js")})),LoginFailedScreen:()=>Promise.resolve().then((function(){return require("./LoginFailedScreen-B_f3bRu3.js")})),ManualTransferScreen:()=>Promise.resolve().then((function(){return require("./ManualTransferScreen-DCjvNWqd.js")})),MfaAuthEnrollmentFlowScreen:()=>Promise.resolve().then((function(){return require("./MfaAuthEnrollmentFlowScreen-DN4ce0UG.js")})),MfaAuthVerifyFlowScreen:()=>Promise.resolve().then((function(){return require("./MfaAuthVerifyFlowScreen-c-lQ_fEz.js")})),MfaEnrollmentFlowScreen:()=>Promise.resolve().then((function(){return require("./MfaEnrollmentFlowScreen-B6-EB6WE.js")})),MoonpayStatusScreen:()=>Promise.resolve().then((function(){return require("./MoonpayStatusScreen-BEtRocSA.js")})),OAuthStatusScreen:()=>Promise.resolve().then((function(){return require("./OAuthStatusScreen-FvgZmHXu.js")})),PasskeySelectSignupOrLogin:()=>Promise.resolve().then((function(){return require("./PasskeySelectSignupOrLogin-DqSfSR6i.js")})),PasskeyStatusScreen:()=>Promise.resolve().then((function(){return require("./PasskeyStatusScreen-DvA6G4hk.js")})),PasswordRecoveryScreen:()=>Promise.resolve().then((function(){return require("./PasswordRecoveryScreen-Befeqrad.js")})),RecoveryOAuthScreen:()=>Promise.resolve().then((function(){return require("./RecoveryOAuthStatusScreen-C6mVwtQH.js")})),RecoverySelectionScreen:()=>Promise.resolve().then((function(){return require("./RecoverySelectionScreen-CjnlE9el.js")})),SendTransactionScreen:()=>Promise.resolve().then((function(){return require("./index-Y7m6JUJT.js")})),SetAutomaticRecoveryScreen:()=>Promise.resolve().then((function(){return require("./SetAutomaticRecoveryScreen-CrRjNWxq.js")})),SignRequestScreen:()=>Promise.resolve().then((function(){return require("./SignRequestScreen-DHoZ6sz5.js")})),StandardSignAndSendTransactionScreen:()=>Promise.resolve().then((function(){return require("./StandardSignAndSendTransactionScreen-CBLYn4pf.js")})),TelegramAuthScreen:()=>Promise.resolve().then((function(){return require("./TelegramAuthScreen-D7mlDw-E.js")})),TransferFromWalletScreen:()=>Promise.resolve().then((function(){return require("./TransferFromWalletScreen-DSItFmOL.js")})),UpdateEmailScreen:()=>Promise.resolve().then((function(){return require("./UpdateEmailScreen-Bcbi12kY.js")})),UpdatePhoneScreen:()=>Promise.resolve().then((function(){return require("./UpdatePhoneScreen-lJE1r_mk.js")})),UserLimitReachedScreen:()=>Promise.resolve().then((function(){return require("./UserLimitReachedScreen-CKsbmhwX.js")})),WalletInterstitialScreen:()=>Promise.resolve().then((function(){return require("./WalletInterstitialScreen-C-wi9rZH.js")}))});function ct(e){k.usePrivyEventSubscription("configureMfa",e)}const dt=w.create((()=>({inProgressMfaFlow:void 0})));const ut=T.createGlobalStyle`
|
|
2
|
+
:root {
|
|
3
|
+
${e=>ht(e.palette)}
|
|
4
|
+
};
|
|
5
|
+
`;const ht=e=>{let t=function(e){return{"--privy-color-background":e.background,"--privy-color-background-2":e.background2,"--privy-color-background-3":e.background3,"--privy-color-foreground":e.foreground,"--privy-color-foreground-2":e.foreground2,"--privy-color-foreground-3":e.foreground3,"--privy-color-foreground-4":e.foreground4,"--privy-color-foreground-accent":e.foregroundAccent,"--privy-color-accent":e.accent,"--privy-color-accent-light":e.accentLight,"--privy-color-accent-hover":e.accentHover,"--privy-color-accent-dark":e.accentDark,"--privy-color-accent-darkest":e.accentDarkest,"--privy-color-success":e.success,"--privy-color-success-dark":e.successDark,"--privy-color-success-light":e.successLight,"--privy-color-success-bg":e.successBg,"--privy-color-error":e.error,"--privy-color-error-light":e.errorLight,"--privy-color-error-bg":e.errorBg,"--privy-color-error-bg-hover":e.errorBgHover,"--privy-color-warn":e.warn,"--privy-color-warn-light":e.warnLight,"--privy-color-warn-bg":e.warnBg,"--privy-color-warning-dark":e.warningDark,"--privy-color-error-dark":e.errorDark,"--privy-color-info-bg":e.infoBg,"--privy-color-info-bg-hover":e.infoBgHover,"--privy-color-border-default":e.borderDefault,"--privy-color-border-hover":e.borderHover,"--privy-color-border-focus":e.borderFocus,"--privy-color-border-error":e.borderError,"--privy-color-border-success":e.borderSuccess,"--privy-color-border-warning":e.borderWarning,"--privy-color-border-info":e.borderInfo,"--privy-color-border-interactive":e.borderInteractive,"--privy-color-border-interactive-hover":e.borderInteractiveHover,"--privy-color-background-hover":e.backgroundHover,"--privy-color-background-clicked":e.backgroundClicked,"--privy-color-background-disabled":e.backgroundDisabled,"--privy-color-background-interactive":e.backgroundInteractive,"--privy-color-background-interactive-hover":e.backgroundInteractiveHover,"--privy-color-background-interactive-clicked":e.backgroundInteractiveClicked,"--privy-color-background-interactive-disabled":e.backgroundInteractiveDisabled,"--privy-color-foreground-hover":e.foregroundHover,"--privy-color-foreground-clicked":e.foregroundClicked,"--privy-color-foreground-disabled":e.foregroundDisabled,"--privy-color-foreground-interactive":e.foregroundInteractive,"--privy-color-foreground-interactive-hover":e.foregroundInteractiveHover,"--privy-link-navigation-color":e.linkNavigationColor,"--privy-link-navigation-decoration":e.linkNavigationDecoration,"--privy-accent-has-good-contrast":e.accentHasGoodContrast,"--privy-color-icon-default":e.iconDefault,"--privy-color-icon-muted":e.iconMuted,"--privy-color-icon-subtle":e.iconSubtle,"--privy-color-icon-inverse":e.iconInverse,"--privy-color-icon-success":e.iconSuccess,"--privy-color-icon-warning":e.iconWarning,"--privy-color-icon-error":e.iconError,"--privy-color-icon-interactive":e.iconInteractive,"--privy-color-icon-default-hover":e.iconDefaultHover,"--privy-color-icon-muted-hover":e.iconMutedHover,"--privy-color-icon-subtle-hover":e.iconSubtleHover,"--privy-color-icon-default-clicked":e.iconDefaultClicked,"--privy-color-icon-muted-clicked":e.iconMutedClicked,"--privy-color-icon-subtle-clicked":e.iconSubtleClicked,"--privy-color-icon-default-disabled":e.iconDefaultDisabled,"--privy-color-icon-muted-disabled":e.iconMutedDisabled,"--privy-color-icon-subtle-disabled":e.iconSubtleDisabled,"--privy-color-icon-error-hover":e.iconErrorHover,"--privy-color-icon-interactive-hover":e.iconInteractiveHover,"--privy-color-icon-error-clicked":e.iconErrorClicked,"--privy-color-icon-interactive-clicked":e.iconInteractiveClicked,"--privy-color-icon-muted-disabled-alt":e.iconMutedDisabledAlt,"--privy-color-icon-subtle-disabled-alt":e.iconSubtleDisabledAlt,"--privy-border-radius-xs":"6px","--privy-border-radius-sm":"8px","--privy-border-radius-md":"12px","--privy-border-radius-mdlg":"16px","--privy-border-radius-lg":"24px","--privy-border-radius-full":"9999px","--privy-height-modal-full":"620px","--privy-height-modal-compact":"480px"}}(e);return T.css`
|
|
6
|
+
${Object.entries(t).map((([e,t])=>`${e}: ${t};`)).join("\n")}
|
|
7
|
+
`},pt=T.styled.div`
|
|
8
|
+
// css normalize only the privy application to avoid conflicts
|
|
9
|
+
// with consuming application
|
|
10
|
+
${"\n *,\n ::before,\n ::after {\n box-sizing: border-box;\n border-width: 0;\n border-style: solid;\n }\n\n line-height: 1.15;\n -webkit-text-size-adjust: 100%;\n -moz-tab-size: 4;\n tab-size: 4;\n font-feature-settings: normal;\n\n margin: 0;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n\n hr {\n height: 0;\n color: inherit;\n border-top-width: 1px;\n }\n\n abbr:where([title]) {\n text-decoration: underline dotted;\n }\n\n h1,\n h2,\n h3,\n h4,\n h5,\n h6 {\n font-size: inherit;\n font-weight: inherit;\n font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif,\n 'Apple Color Emoji', 'Segoe UI Emoji';\n display: inline;\n }\n\n a {\n color: inherit;\n text-decoration: inherit;\n }\n\n b,\n strong {\n font-weight: bolder;\n }\n\n code,\n kbd,\n samp,\n pre {\n font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;\n font-size: 1em;\n }\n\n small {\n font-size: 80%;\n }\n\n sub,\n sup {\n font-size: 75%;\n line-height: 0;\n position: relative;\n vertical-align: baseline;\n }\n\n sub {\n bottom: -0.25em;\n }\n\n sup {\n top: -0.5em;\n }\n\n table {\n text-indent: 0;\n border-color: inherit;\n border-collapse: collapse;\n }\n\n button,\n input,\n optgroup,\n select,\n textarea {\n font-family: inherit;\n font-size: 100%;\n font-weight: inherit;\n line-height: inherit;\n color: inherit;\n margin: 0;\n padding: 0;\n }\n\n button,\n select {\n text-transform: none;\n }\n\n button,\n [type='button'],\n [type='reset'],\n [type='submit'] {\n -webkit-appearance: button;\n background-color: transparent;\n background-image: none;\n }\n\n ::-moz-focus-inner {\n border-style: none;\n padding: 0;\n }\n\n :-moz-focusring {\n outline: 1px dotted ButtonText;\n }\n\n :-moz-ui-invalid {\n box-shadow: none;\n }\n\n legend {\n padding: 0;\n }\n\n progress {\n vertical-align: baseline;\n }\n\n ::-webkit-inner-spin-button,\n ::-webkit-outer-spin-button {\n height: auto;\n }\n\n [type='search'] {\n -webkit-appearance: textfield;\n outline-offset: -2px;\n }\n\n ::-webkit-search-decoration {\n -webkit-appearance: none;\n }\n\n ::-webkit-file-upload-button {\n -webkit-appearance: button;\n font: inherit;\n }\n\n summary {\n display: list-item;\n }\n\n blockquote,\n dl,\n dd,\n h1,\n h2,\n h3,\n h4,\n h5,\n h6,\n hr,\n figure,\n p,\n pre {\n margin: 0;\n }\n\n fieldset {\n margin: 0;\n padding: 0;\n }\n\n legend {\n padding: 0;\n }\n\n ol,\n ul,\n menu {\n list-style: none;\n margin: 0;\n padding: 0;\n }\n\n textarea {\n resize: vertical;\n }\n\n input::placeholder,\n textarea::placeholder {\n opacity: 1;\n color: #9ca3af;\n }\n\n button,\n [role='button'] {\n cursor: pointer;\n }\n\n :disabled {\n cursor: default;\n }\n\n img,\n svg,\n video,\n canvas,\n audio,\n iframe,\n embed,\n object {\n display: block;\n }\n\n img,\n video {\n max-width: 100%;\n height: auto;\n }\n\n [hidden] {\n display: none;\n }\n"}
|
|
11
|
+
|
|
12
|
+
// Privy styles
|
|
13
|
+
color: var(--privy-color-foreground-2);
|
|
14
|
+
|
|
15
|
+
h3 {
|
|
16
|
+
font-size: 16px;
|
|
17
|
+
line-height: 24px;
|
|
18
|
+
font-weight: 500;
|
|
19
|
+
color: var(--privy-color-foreground-2);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
h4 {
|
|
23
|
+
font-size: 14px;
|
|
24
|
+
line-height: 20px;
|
|
25
|
+
font-weight: 500;
|
|
26
|
+
color: var(--privy-color-foreground);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
p {
|
|
30
|
+
font-size: 13px;
|
|
31
|
+
line-height: 20px;
|
|
32
|
+
color: var(--privy-color-foreground-2);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
button:focus,
|
|
36
|
+
input:focus,
|
|
37
|
+
optgroup:focus,
|
|
38
|
+
select:focus,
|
|
39
|
+
textarea:focus {
|
|
40
|
+
outline: none;
|
|
41
|
+
border-color: var(--privy-color-accent-light);
|
|
42
|
+
box-shadow: 0 0 0 3px var(--privy-color-border-focus);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.mobile-only {
|
|
46
|
+
@media (min-width: 441px) {
|
|
47
|
+
display: none;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/* Animations */
|
|
52
|
+
|
|
53
|
+
@keyframes fadein {
|
|
54
|
+
0% {
|
|
55
|
+
opacity: 0;
|
|
56
|
+
}
|
|
57
|
+
100% {
|
|
58
|
+
opacity: 1;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
`,yt=({children:t,open:r,onClick:n,...i})=>/*#__PURE__*/e.jsx(_.Transition,{show:r,as:q.default.Fragment,children:/*#__PURE__*/e.jsxs(_.Dialog,{onClose:n,...i,as:mt,children:[/*#__PURE__*/e.jsx(_.TransitionChild,{as:q.default.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/e.jsx(wt,{id:"privy-dialog-backdrop","aria-hidden":"true"})}),/*#__PURE__*/e.jsx(gt,{children:/*#__PURE__*/e.jsx(_.TransitionChild,{as:q.default.Fragment,enterFrom:"entering",leaveTo:"leaving",children:/*#__PURE__*/e.jsx(_.DialogPanel,{as:vt,children:t})})})]})});let wt=T.styled.div`
|
|
62
|
+
position: fixed;
|
|
63
|
+
inset: 0;
|
|
64
|
+
|
|
65
|
+
transition: backdrop-filter 100ms ease;
|
|
66
|
+
backdrop-filter: blur(3px);
|
|
67
|
+
-webkit-backdrop-filter: blur(3px);
|
|
68
|
+
|
|
69
|
+
&.entering,
|
|
70
|
+
&.leaving {
|
|
71
|
+
backdrop-filter: unset;
|
|
72
|
+
-webkit-backdrop-filter: unset;
|
|
73
|
+
}
|
|
74
|
+
`,mt=T.styled.div`
|
|
75
|
+
position: relative;
|
|
76
|
+
z-index: 999999;
|
|
77
|
+
`,gt=T.styled.div`
|
|
78
|
+
position: fixed;
|
|
79
|
+
inset: 0;
|
|
80
|
+
display: flex;
|
|
81
|
+
align-items: center;
|
|
82
|
+
justify-content: center;
|
|
83
|
+
width: 100vw;
|
|
84
|
+
min-height: 100vh;
|
|
85
|
+
`;const vt=T.styled.div`
|
|
86
|
+
// reset some default dialog styles
|
|
87
|
+
padding: 0;
|
|
88
|
+
background: transparent;
|
|
89
|
+
border: none;
|
|
90
|
+
width: 100%;
|
|
91
|
+
pointer-events: auto;
|
|
92
|
+
|
|
93
|
+
outline: none;
|
|
94
|
+
display: block;
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* Normally it is bad to mix media queries like this We are doing
|
|
98
|
+
* this here specifically for animations to avoid weird jank.
|
|
99
|
+
*/
|
|
100
|
+
/* Mobile animation is a bottom drawer */
|
|
101
|
+
@media (max-width: 440px) {
|
|
102
|
+
opacity: 1;
|
|
103
|
+
transform: translate3d(0, 0, 0);
|
|
104
|
+
transition: transform 200ms ease-in;
|
|
105
|
+
position: fixed;
|
|
106
|
+
bottom: 0;
|
|
107
|
+
|
|
108
|
+
&.entering,
|
|
109
|
+
&.leaving {
|
|
110
|
+
opacity: 0;
|
|
111
|
+
transform: translate3d(0, 100%, 0);
|
|
112
|
+
transition:
|
|
113
|
+
transform 150ms ease-in 0ms,
|
|
114
|
+
opacity 0ms ease 150ms;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/* Tablet/Desktop animation is a fade in */
|
|
119
|
+
@media (min-width: 441px) {
|
|
120
|
+
opacity: 1;
|
|
121
|
+
transition: opacity 100ms ease-in;
|
|
122
|
+
|
|
123
|
+
&.entering,
|
|
124
|
+
&.leaving {
|
|
125
|
+
opacity: 0;
|
|
126
|
+
transition-delay: 5ms;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
margin: auto;
|
|
130
|
+
width: 360px;
|
|
131
|
+
box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15);
|
|
132
|
+
border-radius: var(--privy-border-radius-lg);
|
|
133
|
+
}
|
|
134
|
+
`;T.styled.div`
|
|
135
|
+
display: flex;
|
|
136
|
+
flex-direction: column;
|
|
137
|
+
align-items: center;
|
|
138
|
+
justify-content: center;
|
|
139
|
+
height: 100%;
|
|
140
|
+
`;const ft=()=>{let{ready:e}=a.usePrivyContext(),{currentScreen:r}=a.usePrivyModal(),[n,i]=t.useState(null),[s,o]=t.useState(!1),l=function(e){let[r,n]=t.useState(!1),i=t.useRef(null),a=t.useRef(null),s=t.useRef(null);return t.useEffect((()=>{if(i.current&&(clearTimeout(i.current),i.current=null),a.current&&(clearTimeout(a.current),a.current=null),e)s.current=Date.now(),i.current=setTimeout((()=>{n(!0)}),150);else if(null!==s.current){let e=Date.now()-s.current;if(e>=150){let t=Math.max(0,400-(e-150));a.current=setTimeout((()=>{n(!1),s.current=null}),t)}else i.current&&(clearTimeout(i.current),i.current=null),n(!1),s.current=null}return()=>{i.current&&clearTimeout(i.current),a.current&&clearTimeout(a.current)}}),[e]),r}(s);return t.useEffect((()=>{if(!r)return i(null),void o(!1);o(!0),lt[r]().then((t=>{(!r||e||t.default.isShownBeforeReady)&&(i((()=>t.default.component)),o(!1))})).catch((()=>{i(null),o(!1)}))}),[r,e]),{component:n,isLoading:l}};let Et=/*#__PURE__*/t.lazy((()=>Promise.resolve().then((function(){return require("./MfaVerifyFlowScreen-zbdZQoq2.js")})))),Ct=/*#__PURE__*/t.lazy((()=>(e=>lt[e]().then((e=>({default:e.default.component}))))("MfaAuthVerifyFlowScreen"))),At=()=>/*#__PURE__*/e.jsx(bt,{children:/*#__PURE__*/e.jsx(o.Loader,{})}),Pt=()=>{let{currentScreen:r}=a.usePrivyModal(),n=dt((e=>e.inProgressMfaFlow)),i=()=>dt.setState({inProgressMfaFlow:void 0}),{component:s,isLoading:l}=ft();return function(){let{isModalOpen:e}=a.usePrivyContext(),{headless:r}=y.useAppConfig(),{currentScreen:n}=a.usePrivyModal(),{status:i,execute:s,reset:o,enabled:l}=Ze(),[c,d]=t.useState(!1);t.useEffect((()=>{!e&&l&&o()}),[e,l,o]),t.useEffect((()=>{n?lt[n]().then((e=>{d(!!e.default.isCaptchaRequired)})).catch((()=>{d(!1)})):d(!1)}),[n]),t.useEffect((()=>{e&&c&&!r&&"ready"===i&&l&&s()}),[e,c,r,i,l,s])}(),r||"txn"!==n?l?/*#__PURE__*/e.jsx(At,{}):s?
|
|
141
|
+
/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(o.Hide,{$if:!!n,children:/*#__PURE__*/e.jsx(t.Suspense,{children:/*#__PURE__*/e.jsx(s,{})})}),/*#__PURE__*/e.jsxs(t.Suspense,{children:["txn"===n&&/*#__PURE__*/e.jsx(Et,{onClose:i}),"auth"===n&&/*#__PURE__*/e.jsx(Ct,{})]})]}):null:/*#__PURE__*/e.jsx(t.Suspense,{children:/*#__PURE__*/e.jsx(Et,{onClose:i})})},Tt=()=>{let r=t.useRef(null);/*#__PURE__*/return e.jsx(St,{style:{height:o.useElementHeight(r)},id:"privy-modal-content",children:/*#__PURE__*/e.jsx("div",{ref:r,children:/*#__PURE__*/e.jsx(Pt,{})})})};const kt=({open:r})=>{let n=y.useAppConfig(),{gracefulClosePrivyModal:i}=(()=>{let{closePrivyModal:e}=l.usePrivyInternal(),{onUserCloseViaDialogOrKeybindRef:r}=a.usePrivyModal();return{gracefulClosePrivyModal:t.useCallback((()=>{if(!r?.current)return e({shouldCallAuthOnSuccess:!1});r.current()}),[e])}})(),s=dt((e=>e.inProgressMfaFlow));return ct({onMfaRequired:()=>{n.mfa.noPromptOnMfaRequired||dt.setState({inProgressMfaFlow:"txn"})}}),n.render.standalone?/*#__PURE__*/e.jsx(pt,{children:/*#__PURE__*/e.jsx(_t,{id:"privy-modal-content",children:/*#__PURE__*/e.jsx(Pt,{})})}):/*#__PURE__*/e.jsx(yt,{open:!(!r&&!s),id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>i(),children:/*#__PURE__*/e.jsx(pt,{children:/*#__PURE__*/e.jsx(Tt,{})})})};let _t=T.styled.div`
|
|
142
|
+
display: flex;
|
|
143
|
+
flex-direction: column;
|
|
144
|
+
text-align: center;
|
|
145
|
+
font-size: 14px;
|
|
146
|
+
line-height: 20px;
|
|
147
|
+
width: 100%;
|
|
148
|
+
background: var(--privy-color-background);
|
|
149
|
+
padding: 0 16px;
|
|
150
|
+
`,St=T.styled(_t)`
|
|
151
|
+
transition: height 150ms ease-out;
|
|
152
|
+
overflow-x: hidden;
|
|
153
|
+
overflow-y: auto;
|
|
154
|
+
scrollbar-width: none;
|
|
155
|
+
|
|
156
|
+
// Ensure the modal gets pinned to the top if it ever gets too tall
|
|
157
|
+
max-height: calc(100svh - 32px);
|
|
158
|
+
|
|
159
|
+
border-radius: var(--privy-border-radius-lg) var(--privy-border-radius-lg) 0 0;
|
|
160
|
+
box-shadow: 0px 0px 36px rgba(55, 65, 81, 0.15);
|
|
161
|
+
|
|
162
|
+
@media (min-width: 441px) {
|
|
163
|
+
box-shadow: 0px 8px 36px rgba(55, 65, 81, 0.15);
|
|
164
|
+
border-radius: var(--privy-border-radius-lg);
|
|
165
|
+
}
|
|
166
|
+
`,bt=T.styled.div`
|
|
167
|
+
display: flex;
|
|
168
|
+
align-items: center;
|
|
169
|
+
justify-content: center;
|
|
170
|
+
min-height: 300px;
|
|
171
|
+
padding: 2rem;
|
|
172
|
+
`;function It(r){let n=t.useRef(null),i=t.useRef();return t.useEffect((()=>{i.current?.remove(),i.current=function({botUsername:e,scriptHost:t}){let r=document.createElement("script"),{origin:n}=new URL(t);return r.async=!0,r.src=`${n}/js/telegram-login.js`,r.setAttribute("data-telegram-login",e),r.setAttribute("data-request-access","write"),r.setAttribute("data-lang","en"),r}(r),n.current?.after(i.current)}),[r]),/*#__PURE__*/e.jsx("div",{ref:n,hidden:!0})}const Wt=()=>{let{ready:e,wallets:r}=S.useWallets();return t.useEffect((()=>{if(!e)return;let t=r.map((e=>({address:e.address,connectorType:e.connectorType,walletClientType:e.walletClientType,connectedAt:e.connectedAt,id:e.meta.id})));c.s.put(y.CONNECTIONS_HISTORY_KEY,t)}),[e,r]),null},Ut=["error","invalid_request_arguments","wallet_not_on_device","invalid_recovery_pin","insufficient_funds","missing_or_invalid_mfa","mfa_verification_max_attempts_reached","mfa_timeout","twilio_verification_failed"];class xt extends Error{constructor(e,t){super(t),this.type=e}}function Rt(e){let t=e.type;return"string"==typeof t&&Ut.includes(t)}function Ot(e){return Rt(e)&&"wallet_not_on_device"===e.type}async function Nt(e,t,r,n,i,a=!1){let s=a,o=async o=>{if(s&&t&&t.length>0){o===(a?0:1)?i("configureMfa","onMfaRequired",{mfaMethods:t}):n.current?.reject(new xt("missing_or_invalid_mfa","MFA verification failed, retry."));let s=await new Promise(((e,t)=>{r.current={resolve:e,reject:t},setTimeout((()=>{let e=new xt("mfa_timeout","Timed out waiting for MFA code");n.current?.reject(e),t(e)}),3e5)}));return await e(s)}return await e()},l=null;for(let e=0;e<4;e++)try{l=await o(e),n.current?.resolve(void 0);break}catch(e){if("missing_or_invalid_mfa"!==e.type)throw n.current?.resolve(void 0),e;s=!0}if(null===l){let e=new xt("mfa_verification_max_attempts_reached","Max MFA verification attempts reached");throw n.current?.reject(e),e}return l}var Mt;let Ft=(Mt=0,()=>"id-"+Mt++);function Lt(e){return void 0!==e.error}let Dt=new class{enqueue(e,t){this.callbacks[e]=t}dequeue(e,t){let r=this.callbacks[t];if(!r)throw Error(`cannot dequeue ${e} event: no event found for id ${t}`);switch(delete this.callbacks[t],e){case"privy:iframe:ready":case"privy:user-signer:sign":case"privy:wallets:add":case"privy:wallets:import":case"privy:wallets:set-recovery":case"privy:wallets:connect":case"privy:wallets:recover":case"privy:wallets:rpc":case"privy:wallet:create":case"privy:mfa:verify":case"privy:mfa:init-enrollment":case"privy:mfa:submit-enrollment":case"privy:mfa:unenroll":case"privy:mfa:clear":case"privy:auth:unlink-passkey":case"privy:farcaster:init-signer":case"privy:farcaster:sign":case"privy:solana-wallet:create":case"privy:delegated-actions:consent":return r;default:throw Error(`invalid wallet event type ${e}`)}}constructor(){this.callbacks={}}},jt=new Map,qt=(e,t)=>"bigint"==typeof t?t.toString():t;function Kt(e,t,r,n){let i=r.contentWindow;if(!i)throw Error("iframe not initialized");let a=((e,t)=>`${e}${JSON.stringify(t,qt)}`)(e,t);if("privy:wallet:create"===e){let e=jt.get(a);if(e)return e}let s=new Promise(((r,a)=>{let s=Ft();Dt.enqueue(s,{resolve:r,reject:a}),i.postMessage({id:s,event:e,data:t},n)})).finally((()=>{jt.delete(a)}));return jt.set(a,s),s}function zt(r){let n=y.useIsServerConfigLoaded(),i=t.useRef(null),a=t.useRef(r.mfaMethods),s=k.useEmitPrivyEvent(),[l,c]=t.useState(!1);return t.useEffect((()=>{a.current=r.mfaMethods}),[r.mfaMethods]),t.useEffect((()=>{if(!l)return;let e=i.current;if(!e)return;function t(e){var t;e&&e.origin===r.origin&&"string"==typeof(t=e.data).event&&/^privy:.+/.test(t.event)&&function(e){switch(e.event){case"privy:iframe:ready":let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data);case"privy:user-signer:sign":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:add":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:set-recovery":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:connect":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:recover":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallets:rpc":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:wallet:create":let r=Dt.dequeue(e.event,e.id);return Lt(e)?r.reject(new xt(e.error.type,e.error.message)):r.resolve(e.data);case"privy:wallets:import":let n=Dt.dequeue(e.event,e.id);return Lt(e)?n.reject(new xt(e.error.type,e.error.message)):n.resolve(e.data);case"privy:mfa:verify":let i=Dt.dequeue(e.event,e.id);return Lt(e)?i.reject(new xt(e.error.type,e.error.message)):i.resolve(e.data);case"privy:mfa:init-enrollment":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:submit-enrollment":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:unenroll":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:mfa:clear":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:auth:unlink-passkey":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:solana-wallet:create":let a=Dt.dequeue(e.event,e.id);return Lt(e)?a.reject(new xt(e.error.type,e.error.message)):a.resolve(e.data);case"privy:farcaster:init-signer":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:farcaster:sign":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}case"privy:delegated-actions:consent":{let t=Dt.dequeue(e.event,e.id);return Lt(e)?t.reject(new xt(e.error.type,e.error.message)):t.resolve(e.data)}default:console.warn("Unsupported wallet proxy method:",e)}}(e.data)}let n={signWithUserSigner:t=>Nt((n=>Kt("privy:user-signer:sign",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),addWallet:t=>Nt((n=>Kt("privy:wallets:add",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),setRecovery:t=>Nt((n=>Kt("privy:wallets:set-recovery",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),connect:t=>Nt((n=>Kt("privy:wallets:connect",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),recover:t=>Nt((n=>Kt("privy:wallets:recover",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s,!t.recoveryAccessToken&&!t.recoveryPassword&&!t.recoverySecretOverride),rpc:t=>Nt((n=>Kt("privy:wallets:rpc",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),create:t=>Kt("privy:wallet:create",t,e,r.origin),importWallet:t=>Kt("privy:wallets:import",t,e,r.origin),createSolana:t=>Nt((n=>Kt("privy:solana-wallet:create",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),createDelegatedAction:t=>Kt("privy:delegated-actions:consent",t,e,r.origin),verifyMfa:t=>Nt((n=>Kt("privy:mfa:verify",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s,!0),initEnrollMfa:t=>Nt((n=>Kt("privy:mfa:init-enrollment",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),submitEnrollMfa:t=>Nt((n=>Kt("privy:mfa:submit-enrollment",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),unenrollMfa:t=>Nt((n=>Kt("privy:mfa:unenroll",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),clearMfa:t=>Kt("privy:mfa:clear",t,e,r.origin),unlinkPasskeyAccount:t=>Nt((n=>Kt("privy:auth:unlink-passkey",{...t,...n},e,r.origin)),a.current,r.mfaPromise,r.mfaSubmitPromise,s),initFarcasterSigner:t=>Kt("privy:farcaster:init-signer",t,e,r.origin),signFarcasterMessage:t=>Kt("privy:farcaster:sign",t,e,r.origin)};window.addEventListener("message",t);let c=new AbortController;return o.invokeUntilSettled((()=>Kt("privy:iframe:ready",{},e,r.origin)),{abortSignal:c.signal}).then((()=>r.onLoad(n)),((...e)=>{console.warn("Privy iframe failed to load: ",...e),r.onLoadFailed()})),()=>{window.removeEventListener("message",t),c.abort()}}),[l]),n?
|
|
173
|
+
/*#__PURE__*/e.jsx("iframe",{ref:i,width:"0",height:"0",style:{display:"none",height:"0px",width:"0px"},onLoad:()=>c(!0),src:b.constructURL({origin:r.origin,path:`/apps/${r.appId}/embedded-wallets`,query:{caid:r.clientAnalyticsId,client_id:r.appClientId}})}):null}const Ht=({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new l.PrivyClientError("Address to delegate is not associated with current user.");if(!c.isFirstClassChainWallet(r))throw new l.PrivyClientError(`useDelegatedActions is not supported for ${r.chainType} wallets. Use the useSessionSigners hook to provision server side access on behalf of your users.`);return{address:r.address,chainType:r.chainType,walletIndex:r.walletIndex??0}},Vt=({address:e,user:t})=>{let r=t.linkedAccounts.find((t=>"wallet"===t.type&&"privy"===t.walletClientType&&t.address===e));if(!r)throw new l.PrivyClientError("Address to delegate is not associated with current user.");let n=r.imported?r:a.getPrivyPrimaryWallet(t);if(!n)throw new l.PrivyClientError("Unable to determine root address for delegated address.");if(!c.isFirstClassChainWallet(n))throw new l.PrivyClientError(`useDelegatedActions is not supported for ${n.chainType} wallets. Use the useSessionSigners hook to provision server side access on behalf of your users.`);return{address:n.address,chainType:n.chainType,imported:n.imported}},Bt=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.delegated));const Yt="popup-privy-oauth",Gt="PRIVY_OAUTH_USE_BROADCAST_CHANNEL";class $t{async authenticate(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.oAuthAuthenticatePath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider,mode:this.meta.disableSignup?"no-signup":"login-or-sign-up"})}catch(e){throw l.formatApiError(e)}}async link(){if(!this.api)throw new l.PrivyClientError("Auth flow has no API instance");try{return await this.api.post(g.oAuthLinkPath,{authorization_code:this.meta.authorizationCode,state_code:this.meta.stateCode,code_verifier:this.meta.codeVerifier,provider:this.meta.provider})}catch(e){throw l.formatApiError(e)}}constructor(e){this.meta=e}}async function Jt({api:e,requesterAppId:t,providerAppId:r}){let n=(await e.get(`/api/v1/apps/${t}/cross-app/connections`)).connections.find((e=>e.provider_app_id===r));if(!n)throw new l.PrivyClientError("Invalid connected app");return{name:n.provider_app_name,logoUrl:n.provider_app_icon_url||void 0,apiUrl:n.provider_app_custom_api_url,readOnly:n.read_only,customAuthAuthorizeUrl:n.provider_app_custom_auth_authorize_url,customAuthTransactUrl:n.provider_app_custom_auth_transact_url}}const Qt=async({user:e,address:t,client:r,request:n,requesterAppId:i,reconnect:a})=>{r.createAnalyticsEvent({eventName:"cross_app_request_started",payload:{address:t,method:n.method}});let s=e?.linkedAccounts.find((e=>"cross_app"===e.type&&(e.embeddedWallets.some((e=>e.address===t))||e.smartWallets.some((e=>e.address===t)))));if(!e||!s)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Cannot request a signature with this wallet address",address:t}}),new l.PrivyClientError("Cannot request a signature with this wallet address");let o=r.getProviderAccessToken(s.providerApp.id),c=await Jt({api:r.api,requesterAppId:i,providerAppId:s.providerApp.id});if(!o){if(c.readOnly)throw console.error("cannot transact against a read-only provider app"),new l.PrivyClientError("Cannot transact against a read-only provider app");await a({appId:s.providerApp.id,action:"link"})&&(o=r.getProviderAccessToken(s.providerApp.id))}if(!o)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Transactions require a valid token",address:t}}),new l.PrivyClientError("Transactions require a valid token");let d=new URL(c.customAuthTransactUrl||`${c.apiUrl}/oauth/transact`);d.searchParams.set("token",o||""),d.searchParams.set("request",Xt(n));let u=A.trigger({location:d.href});if(!u)throw r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Missing token",address:t}}),new l.PrivyClientError("Failed to initialize signature request");return new Promise(((e,i)=>{let a=setTimeout((()=>{d(),i(new l.PrivyClientError("Request timeout")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"Request timeout",address:t}})}),12e4),o=setInterval((()=>{u.closed&&(d(),i(new l.PrivyClientError("User rejected request")),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:"User rejected request",address:t}}))}),300),c=a=>{a.data&&("set"===a.data.token?.action&&void 0!==a.data.token?.value?r.storeProviderAccessToken(s.providerApp.id,a.data.token.value):"clear"===a.data.token?.action&&r.storeProviderAccessToken(s.providerApp.id,null),"PRIVY_CROSS_APP_ACTION_RESPONSE"===a.data.type&&a.data.result&&(d(),e(a.data.result),r.createAnalyticsEvent({eventName:"cross_app_request_success",payload:{address:t,method:n.method}})),"PRIVY_CROSS_APP_ACTION_ERROR"===a.data.type&&a.data.error&&(d(),i(a.data.error),r.createAnalyticsEvent({eventName:"cross_app_request_error",payload:{error:a.data.error,address:t}})))};window.addEventListener("message",c);let d=()=>{u.close(),clearInterval(o),clearTimeout(a),window.removeEventListener("message",c)}}))};let Xt=e=>JSON.stringify({content:{request:{request:Zt(e,I.toHex)}},timestamp:Date.now(),callbackUrl:window.origin});const Zt=(e,t)=>"bigint"==typeof e?t(e):Array.isArray(e)?e.map((e=>Zt(e,t))):e&&"object"==typeof e?Object.fromEntries(Object.entries(e).map((([e,r])=>[e,Zt(r,t)]))):e;function er({isCreatingWallet:e,skipSplashScreen:t}){return e?"EmbeddedWalletPasswordCreateScreen":t?"EmbeddedWalletPasswordUpdateScreen":"EmbeddedWalletPasswordUpdateSplashScreen"}function tr({walletAction:e,availableRecoveryMethods:t,legacySetWalletPasswordFlow:r,isResettingPassword:n,showAutomaticRecovery:i}){return i?"SetAutomaticRecoveryScreen":r||1===t.length?er({isCreatingWallet:"create"===e,skipSplashScreen:n}):"RecoverySelectionScreen"}function rr(e){switch(e){case"user-passcode":return"PasswordRecoveryScreen";case"google-drive":case"icloud":return"RecoveryOAuthScreen";default:throw Error("Recovery method not supported")}}function nr(e,t){if(e.onComplete)switch(t){case"external":e.fundingResult?e.onComplete({...e.fundingResult,fundingMethod:t}):e.onComplete({status:"cancelled",address:e.address,fundingMethod:t,amount:e.amount});break;case null:e.onComplete({status:"cancelled",address:e.address,fundingMethod:void 0,amount:e.amount});break;default:e.onComplete({status:"completed",address:e.address,fundingMethod:t,amount:e.amount})}}const ir=new Map([["FundingMethodSelectionScreen",null],["TransferFromWalletScreen","external"],["FundingAmountEditScreen","external"],["ConnectOnlyLandingScreen","external"],["ConnectOnlyStatusScreen","external"],["AwaitingExternalEthereumTransferScreen","external"],["AwaitingEvmToSolBridgingScreen","external"],["AwaitingSolToEvmBridgingScreen","external"],["ManualTransferScreen","manual"],["MoonpayStatusScreen","moonpay"]]);function ar(e){let t=e.toLowerCase();return!!window?.webkit?.messageHandlers?.ReactNativeWebView||!!window?.ReactNativeWebView||["fbav","fban","instagram","snapchat","linkedinapp"].some((e=>t.includes(e)))}async function sr({rpc:e,address:t}){return(await e.getBalance(t,{commitment:"confirmed"}).send()).value??0n}let or={apple_oauth:"apple",custom_auth:"custom",discord_oauth:"discord",email:"email",farcaster:"farcaster",github_oauth:"github",google_oauth:"google",instagram_oauth:"instagram",linkedin_oauth:"linkedin",passkey:"passkey",phone:"sms",spotify_oauth:"spotify",telegram:"telegram",tiktok_oauth:"tiktok",line_oauth:"line",twitch_oauth:"twitch",twitter_oauth:"twitter",wallet:"siwe",smart_wallet:"siwe",cross_app:"privy:"};const lr=e=>{if(a.isCustomOAuthProvider(e))return{displayName:e.replace("custom:",""),loginMethod:"custom"};let t=or[e];return"wallet"===e||"phone"===e?{displayName:e,loginMethod:t}:{displayName:t,loginMethod:t}};async function cr(e,t,r,n){let i=W.toViemTransactionSerializable(e),{chain:a,...s}=await(async()=>n?await n():await t.prepareTransactionRequest({...i,account:{address:r,type:"json-rpc"}}))();return{...s,type:W.STRING_TO_NUMBER_TXN_TYPE[s.type]}}const dr=()=>{let e=y.useAppConfig(),{user:r}=a.usePrivyContext(),{client:n,refreshSessionAndUser:i,walletProxy:s}=l.usePrivyInternal();return{migrate:t.useCallback((async()=>{if("legacy-embedded-wallets-only"===e.embeddedWallets.mode)return{success:!0,migrated:!1};if(!r)throw new l.PrivyClientError("User must be authenticated before migrating wallets",l.PrivyErrorCode.MUST_BE_AUTHENTICATED);if(!s)throw new l.PrivyClientError("Cannot connect to wallet proxy");let t=await n.getAccessToken();if(!t)throw new l.PrivyClientError("User must be authenticated before migrating wallets",l.PrivyErrorCode.MUST_BE_AUTHENTICATED);let o=r.linkedAccounts.filter((e=>"wallet"===e.type&&"privy"===e.walletClientType&&c.isFirstClassChainWallet(e)&&!a.getIsUnifiedWallet(e)));if(0===o.length)return{success:!0,migrated:!1};let d=o.filter((e=>e.imported)),u=o.filter((e=>!e.imported));if(u.length>0){let e=u.find((e=>"ethereum"===e.chainType&&0===e.walletIndex))??u.find((e=>"solana"===e.chainType&&0===e.walletIndex))??null;if(!e)throw new l.PrivyClientError("Primary wallet not found");let{entropyId:r,entropyIdVerifier:n}=S.toEntropyDetailsFromAccount(e);try{await s.connect({accessToken:t,entropyId:r,entropyIdVerifier:n})}catch(i){if(!Ot(i)||"privy"!==e.recoveryMethod)throw i;await s.recover({accessToken:t,entropyId:r,entropyIdVerifier:n})}await s.createDelegatedAction({accessToken:t,rootWallet:{address:e.address,chainType:e.chainType,imported:!1},delegatedWallets:u.map((e=>({address:e.address,chainType:e.chainType,walletIndex:e.walletIndex??0})))})}for(let e of d){let{entropyId:r,entropyIdVerifier:n}=S.toEntropyDetailsFromAccount(e);try{await s.connect({accessToken:t,entropyId:r,entropyIdVerifier:n})}catch(d){if(!Ot(d)||"privy"!==e.recoveryMethod)throw d;await s.recover({accessToken:t,entropyId:r,entropyIdVerifier:n})}await s.createDelegatedAction({accessToken:t,rootWallet:{address:e.address,chainType:e.chainType,imported:!0},delegatedWallets:[{address:e.address,chainType:e.chainType,walletIndex:e.walletIndex??0}]})}return await i(),{success:!0,migrated:!0}}),[e.embeddedWallets.mode,r,s,n,i])}},ur=({disabled:e})=>{let{migrate:r}=dr(),{user:n}=a.usePrivyContext(),{walletProxy:i}=l.usePrivyInternal(),s=t.useRef(!1);return t.useEffect((()=>{!e&&!s.current&&n&&i&&(s.current=!0,r().catch((e=>{console.debug("Unable to migrate wallets: ",e)})).finally((()=>{s.current=!1})))}),[n,i,e,r]),null},hr=e=>({id:e.id,raw_id:e.rawId,response:{client_data_json:e.response.clientDataJSON,authenticator_data:e.response.authenticatorData,signature:e.response.signature,user_handle:e.response.userHandle},authenticator_attachment:e.authenticatorAttachment,client_extension_results:{app_id:e.clientExtensionResults.appid,cred_props:e.clientExtensionResults.credProps,hmac_create_secret:e.clientExtensionResults.hmacCreateSecret},type:e.type}),pr=()=>{let{ethereumEmbedded:e,ethereumExternal:t}=S.useWalletStore.getState();return[...e,...t]},yr=(e,t)=>!a.getPrivyEthereumWallet(e)&&("all-users"===t||"users-without-wallets"===t&&!wr(e).length);let wr=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"ethereum"===e.chainType));const mr=(e,t)=>!a.getPrivySolanaWallet(e)&&("all-users"===t||"users-without-wallets"===t&&!gr(e).length);let gr=e=>e.linkedAccounts.filter((e=>"wallet"===e.type&&"solana"===e.chainType));const vr=()=>{let{walletProxy:e,recoverEmbeddedWallet:t,setUser:r,refreshSessionAndUser:n,privy:i,client:a}=l.usePrivyInternal(),s=y.useAppConfig();return{create:async({walletIndex:o,chainType:l,latestUser:c,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h,idempotencyKey:y})=>{let w=c;w||(w=await n());let m=await a.getAccessToken();if(!w||!m||!e)throw Error("User must be authenticated before creating a Privy wallet");return await p.createWalletAtIndex({appConfig:s,user:w,refreshSessionAndUser:n,privy:i,accessToken:m,proxy:e,recoverEmbeddedWallet:t,setUser:r,walletIndex:o,chainType:l,recoveryMethod:d,recoveryPassword:u,recoveryAccessToken:h,idempotencyKey:y})}}};function fr({subscribe:e,getExternalJwt:r,enabled:n=!0,onAuthenticated:i,onUnauthenticated:a,onError:s}){let{client:o,setAuthenticated:c,setUser:d,setIsNewUser:u}=l.usePrivyInternal(),{logout:h,authenticated:w,ready:m}=p.usePrivy(),{create:g}=vr(),v=y.useAppConfig();if(!o)throw new l.PrivyClientError("`useSyncJwtBasedAuthState` must be used within a `PrivyProvider`");let[f,E]=t.useState({status:"initial"}),C=t.useRef(),A=t.useRef(!1),P=t.useRef(r);t.useEffect((()=>{P.current=r}),[r]);let T=t.useRef(i);t.useEffect((()=>{T.current=i}),[i]);let k=t.useRef(a);t.useEffect((()=>{k.current=a}),[a]);let _=t.useRef(s);t.useEffect((()=>{_.current=s}),[s]);let S=t.useRef(g);t.useEffect((()=>{S.current=g}),[g]);let b=t.useRef(v.embeddedWallets.ethereum.createOnLogin);t.useEffect((()=>{b.current=v.embeddedWallets.ethereum.createOnLogin}),[v.embeddedWallets.ethereum.createOnLogin]);let I=t.useRef(v.embeddedWallets.solana.createOnLogin);t.useEffect((()=>{I.current=v.embeddedWallets.solana.createOnLogin}),[v.embeddedWallets.solana.createOnLogin]);let W=t.useRef(d);t.useEffect((()=>{W.current=d}),[d]);let U=t.useRef(u);t.useEffect((()=>{U.current=u}),[u]);let x=t.useRef(c);return t.useEffect((()=>{x.current=c}),[c]),t.useEffect((()=>{if(!n||!m)return;let t=async()=>{if(!A.current){A.current=!0;try{E({status:"loading"});let e=await P.current();if(void 0!==C.current&&C.current===e)return void E({status:"done"});if(!e)return w&&(await h(),k.current?.()),C.current=e,void E({status:"done"});o.startAuthFlow(new we(e));let{user:t,isNewUser:r=!1}=await o.authenticate();if(!t)throw new l.PrivyClientError("Failed to sync with custom auth provider");T.current?.({user:t,isNewUser:r}),W.current(t),U.current(r),x.current(!0);let n=yr(t,b.current),i=mr(t,I.current);if(n&&i){let e=await S.current({chainType:"ethereum",walletIndex:0,latestUser:t});await S.current({chainType:"solana",walletIndex:0,latestUser:e.user})}else i?await S.current({chainType:"solana",walletIndex:0,latestUser:t}):n&&await S.current({chainType:"ethereum",walletIndex:0,latestUser:t});C.current=e,E({status:"done"})}catch(e){if(console.warn(e),await h().catch((()=>{})),k.current?.(),e instanceof l.PrivyApiError&&e.privyErrorCode===l.PrivyErrorCode.LINKED_TO_ANOTHER_USER)return E({status:"initial"}),void setTimeout((()=>{t()}),0);_.current?.(e),E({status:"error",error:e})}finally{A.current=!1}}};return t(),e(t)}),[e,o,w,h,n,m]),n?{state:f}:{state:{status:"not-enabled"}}}let Er=w.create((()=>({jwtAuthFlowState:{status:"not-enabled"}})));function Cr({customAuth:e}){let{jwtAuthFlowState:r}=function({customAuth:e}){let r=k.useEmitPrivyEvent(),n=t.useRef(),i=t.useCallback((e=>(n.current=e,()=>{n.current=void 0})),[]),a=e?.getCustomAccessToken??(()=>Promise.resolve(void 0)),{state:s}=fr({enabled:!0===e?.enabled,subscribe:i,getExternalJwt:a,onAuthenticated:({user:e,isNewUser:t})=>{r("login","onComplete",{user:e,isNewUser:t,wasAlreadyAuthenticated:!1,loginMethod:"custom",loginAccount:null}),r("customAuth","onAuthenticated",{user:e})},onUnauthenticated:()=>{r("customAuth","onUnauthenticated")},onError:e=>{r("login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}});return t.useEffect((()=>{(async()=>{e&&!e.isLoading&&n.current?.()})()}),[e?.enabled,e?.getCustomAccessToken,e?.isLoading]),{jwtAuthFlowState:s}}({customAuth:e});return t.useEffect((()=>{Er.setState({jwtAuthFlowState:r})}),[r]),null}const Ar=["eth_sign","eth_populateTransactionRequest","eth_signTransaction","personal_sign","eth_signTypedData_v4","csw_signUserOperation","secp256k1_sign"];class Pr extends Error{constructor(e,t,r){super(e),this.code=t,this.data=r}}class Tr extends H.default{async handleSendTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Pr(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await it()||!this.address)throw new Pr("Disconnected",4900);let{hash:r}=await Lr(t,{address:this.address});return r}async handleSignTransaction(e){if(!e.params||!Array.isArray(e.params))throw new Pr(`Invalid params for ${e.method}`,4200);let t=e.params[0];if(!await it()||!this.address)throw new Pr("Disconnected",4900);let{signature:r}=await Fr(t,{address:this.address});return r}handleSwitchEthereumChain(e){let t;if(!e.params||!Array.isArray(e.params))throw new Pr(`Invalid params for ${e.method}`,4200);if("string"==typeof e.params[0])t=e.params[0];else{if(!("chainId"in e.params[0])||"string"!=typeof e.params[0].chainId)throw new Pr(`Invalid params for ${e.method}`,4200);t=e.params[0].chainId}this.chainId=Number(t),this.publicClient=x.getPublicClient(this.chainId,this.chains,this.rpcConfig,{appId:this.appId}),this.emit("chainChanged",t)}async handlePersonalSign(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for personal_sign");let t=e.params[0],r=e.params[1],{signature:n}=await Nr({message:t},{address:r});return n}async handleSignedTypedData(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_signTypedData_v4");let t=e.params[0],r="string"==typeof e.params[1]?JSON.parse(e.params[1]):e.params[1],{signature:n}=await Mr(o.generateTypedDataWithDomainType(r),{address:t});return n}async handleEstimateGas(e){if(!e.params||!Array.isArray(e.params))throw Error("Invalid params for eth_estimateGas");delete e.params[0].gasPrice,delete e.params[0].maxFeePerGas,delete e.params[0].maxPriorityFeePerGas;let t={...e.params[0],chainId:o.toHex(this.chainId)};return await this.publicClient.estimateGas({account:t.from??this.address,...W.toViemTransactionSerializable(t)})}async request(e){switch(console.debug("Embedded1193Provider.request() called with args",e),e.method){case"eth_accounts":case"eth_requestAccounts":return this.address?[this.address]:[];case"eth_chainId":return o.toHex(this.chainId);case"eth_estimateGas":return this.handleEstimateGas(e);case"eth_sendTransaction":return this.handleSendTransaction(e);case"eth_signTransaction":return this.handleSignTransaction(e);case"wallet_switchEthereumChain":return this.handleSwitchEthereumChain(e);case"personal_sign":return this.handlePersonalSign(e);case"eth_signTypedData_v4":return this.handleSignedTypedData(e)}if(!(e=>Ar.includes(e))(e.method))return this.publicClient.request({method:e.method,params:e.params});{let t=await it();if(await Dr({address:this.address}),!t||!this.address)throw new Pr("Disconnected",4900);try{let r={method:e.method,params:e.params},n=this.walletAccount;return n&&a.getIsUnifiedWallet(n)?this.handleWalletApiRequest(r,n,t):(await this.walletProxy.rpc({accessToken:t,entropyId:this.entropyId,entropyIdVerifier:this.entropyIdVerifier,chainType:"ethereum",hdWalletIndex:this.walletIndex,request:r})).response.data}catch(e){throw console.error(e),new Pr("Disconnected",4900)}}}async handleWalletApiRequest(e,t,n){let i=this.privyClient;if(!i)throw new Pr("Disconnected",4900);if("secp256k1_sign"===e.method){let a=await r.rpc(i,(async({message:e})=>this.walletProxy.signWithUserSigner({accessToken:n,message:e})),{chain_type:"ethereum",method:"secp256k1_sign",wallet_id:t.id,params:{hash:e.params[0]}});if("secp256k1_sign"!==a.method)throw new Pr(`Invalid params for ${e.method}`,4200);return a.data.signature}throw new Pr(`Method not supported: ${e.method}`,4200)}constructor({walletProxy:e,address:t,entropyId:r,entropyIdVerifier:n,rpcConfig:i,chains:a,appId:s,chainId:l=1,walletIndex:c,privyClient:d,walletAccount:u}){super(),this.walletProxy=e,this.address=t,this.entropyId=r,this.entropyIdVerifier=n,this.chainId=l,this.rpcConfig=i,this.chains=a,this.publicClient=x.getPublicClient(l,this.chains,i,{appId:s}),this.rpcTimeoutDuration=o.getRpcTimeout(i,"privy"),this.appId=s,this.walletIndex=c,this.privyClient=d,this.walletAccount=u}}const kr=({...t})=>/*#__PURE__*/e.jsx("svg",{width:"15",height:"15",viewBox:"0 0 15 15",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t,children:/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M2.37126 11.0323C2.37126 12.696 3.90598 13.4421 5.40654 13.4468C8.91753 13.4468 12.8021 11.2897 12.7819 7.67984C12.7673 5.07728 10.3748 2.86167 7.54357 2.88296C4.8495 2.88296 2.21821 4.6411 2.21803 7.03628C2.21803 7.67951 2.58722 8.30178 3.55231 8.37184C2.74763 9.16826 2.37126 10.1225 2.37126 11.0323ZM7.55283 8.68012C8.11562 8.68012 8.57186 8.13217 8.57186 7.45624C8.57186 6.78032 8.11562 6.23237 7.55283 6.23237C6.99003 6.23237 6.53379 6.78032 6.53379 7.45624C6.53379 8.13217 6.99003 8.68012 7.55283 8.68012ZM10.4747 8.68012C11.0375 8.68012 11.4937 8.13217 11.4937 7.45625C11.4937 6.78032 11.0375 6.23237 10.4747 6.23237C9.91186 6.23237 9.45562 6.78032 9.45562 7.45625C9.45562 8.13217 9.91186 8.68012 10.4747 8.68012Z",fill:t.color||"var(--privy-color-foreground-3)"})});let _r=[];const Sr=()=>((()=>{let e=y.useAppConfig(),{user:r}=a.usePrivyContext(),{walletProxy:n,privy:i}=l.usePrivyInternal(),{fundWallet:s}=o.useFundWallet(),[d,u]=t.useState(e.defaultChain.id),h=t.useMemo((()=>r&&n?r.linkedAccounts.filter((e=>"wallet"===e.type&&"ethereum"===e.chainType&&null!==e.walletIndex&&"privy"===e.walletClientType)):_r),[r,n]);t.useEffect((()=>{if(h.length<1)return;let t=c.loadConnectionHistory(),a=h.map((a=>{let o=()=>{if(!r||!n)throw new l.PrivyClientError("User not ready");let{entropyId:t,entropyIdVerifier:s}=S.getEntropyDetailsForUser(r,a);return new Tr({walletProxy:n,address:a.address,entropyId:t,entropyIdVerifier:s,rpcConfig:e.rpcConfig,chains:e.chains,appId:e.id,chainId:d,walletIndex:a.walletIndex,privyClient:i,walletAccount:a})},c=t.find((e=>e.address===a.address&&e.connectorType===a.connectorType&&e.walletClientType===a.walletClientType))?.connectedAt??a.firstVerifiedAt?.getTime()??Date.now();return{fund:async e=>{await s({address:a.address,options:e})},type:"ethereum",chainId:`eip155:${d}`,switchChain:async e=>{u(Number(e))},getEthereumProvider:async()=>o(),sign:async e=>{let t=o();return await t.request({method:"personal_sign",params:[C.toHex(e),a.address]})},address:a.address,connectedAt:c,walletClientType:"privy",connectorType:"embedded",imported:a.imported,meta:{name:"Privy Wallet",icon:kr,id:"io.privy.wallet"},isConnected:async()=>!0,disconnect:()=>{},linked:!0,loginOrLink:async()=>{throw new l.PrivyClientError("Cannot link or login with embedded wallet")},unlink:async()=>{throw new l.PrivyClientError("Cannot unlink with embedded wallet")},walletIndex:a.walletIndex}}));S.useWalletStore.setState({ethereumEmbedded:a})}),[h,d])})(),null),br=/*#__PURE__*/t.createContext(!1);let Ir,Wr,Ur,xr,Rr;const Or=n=>{let i=n.client,s=n.privy,d=f.usePlugins(),h=y.useAppConfig();o.useExternalWalletListings(o.shouldFetchWcRegistryListings(h?.appearance.walletList??[]));let[w,m]=t.useState(!1),v=dt((e=>e.inProgressMfaFlow)),[P,T]=t.useState(!1),[_,b]=t.useState(null),[I,W]=t.useState(void 0),[R,O]=t.useState(!1),[N,M]=t.useState(null),[F,L]=t.useState(!1),[D,j]=t.useState({status:"disconnected",connectedWallet:null,connectError:null,connector:null,connectRetry:l.notImplemented}),[q,K]=t.useState({status:"initial"}),[z,H]=t.useState({status:"initial"}),[V,B]=t.useState({status:"initial"}),[Y,G]=t.useState({status:"initial"}),[$,J]=t.useState({status:"initial"}),[Q,X]=t.useState({status:"initial"}),[Z,ee]=t.useState(null),te=y.useIsServerConfigLoaded(),[re,ne]=t.useState({}),[ie,ae]=t.useState(null),se=t.useRef(null),oe=t.useRef(null),le=t.useRef(null),de=t.useRef(k.privyEventsDefault),[ue,he]=t.useState(!1),pe=t.useCallback((e=>{he(e),!e&&N&<[N]().then((e=>{e.default.isUnauthenticatedScreem&&M(null)}))}),[N]);i.onStoreCustomerAccessToken=e=>{e&&k.emitPrivyEvent(de,"accessToken","onAccessTokenGranted",{accessToken:e})},i.onDeleteCustomerAccessToken=()=>{b(null),pe(!1),k.emitPrivyEvent(de,"accessToken","onAccessTokenRemoved")};let ye=t.useRef(null),we=t.useRef(null),me=t.useRef(!1),fe=({showWalletUIs:e})=>me.current?me.current:void 0!==e?!e:!h.embeddedWallets.showWalletUIs,Ee=e=>{M(e),setTimeout((()=>{m(!0)}),15)};t.useEffect((()=>{Z&&se.current?.(Z)}),[Z]),t.useEffect((()=>{if(h.externalWallets.solana.connectors)return h.externalWallets.solana.connectors.onMount(),()=>h.externalWallets.solana.connectors?.onUnmount()}),[h.externalWallets.solana.connectors]),t.useEffect((()=>{!P&&te&&async function(){let e,t=Ce(),r=Ae(),n=E.createStore();i.initializeConnectorManager({walletConnectCloudProjectId:h.walletConnectCloudProjectId,rpcConfig:h.rpcConfig,chains:h.chains,defaultChain:h.defaultChain,store:n,walletList:h.appearance.walletList,shouldEnforceDefaultChainOnConnect:h.shouldEnforceDefaultChainOnConnect,externalWalletConfig:h.externalWallets,appName:h.name??"Privy",walletChainType:h.appearance.walletChainType,setBaseAccountSdk:W}),i.connectors?.on("connectorInitialized",(()=>{e&&clearTimeout(e);let t=i.connectors.walletConnectors.length,r=i.connectors.walletConnectors.reduce(((e,t)=>e+(t.initialized?1:0)),0);r===t?S.setAreExternalConnectorsReady(!0):e=setTimeout((()=>{console.debug({message:"Unable to initialize all expected connectors before timeout",initialized:r,expected:t}),S.setAreExternalConnectorsReady(!0)}),1500)})),i.connectors?.initialize().then((()=>{Le()}));let a=await i.getAuthenticatedUser(),s=!!a;h.legal.requireUsersAcceptTerms&&a&&!a.hasAcceptedTerms?(await i.logout(),et.setReadyToTrue(!0),k.emitPrivyEvent(de,"logout","onSuccess")):(h.customAuth?.enabled||(pe(!!a),a&&k.emitPrivyEvent(de,"login","onComplete",{user:a,isNewUser:!1,wasAlreadyAuthenticated:!0,loginMethod:null,loginAccount:null}),b(a)),t?we.current=s?"link":"login":r&&!s?(we.current="login",ne({telegramAuthModalData:{seamlessAuth:!0}}),Ee("TelegramAuthScreen")):et.setReadyToTrue(!!a))}()}),[i,ie,P,te]),t.useEffect((()=>{i.connectors?.setWalletList(h.appearance.walletList)}),[h.appearance.walletList.join()]);let Ce=()=>{let e=Ie();return e.inProgress&&e.popupFlow?window.opener.location.origin!==window.location.origin?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Origins between parent and child windows do not match."}):"error"===e.authorizationCode?void window.opener.postMessage({type:"PRIVY_OAUTH_ERROR",error:"Something went wrong. Try again."}):void window.opener.postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}):(e.inProgress&&e.provider.startsWith("privy:")&&!e.popupFlow&&(new BroadcastChannel(Yt).postMessage({type:"PRIVY_OAUTH_RESPONSE",stateCode:e.stateCode,authorizationCode:e.authorizationCode}),window.close()),!!e.inProgress&&!!e.withPrivyUi&&(i.startAuthFlow(new be({...e,customOAuthRedirectUrl:h.customOAuthRedirectUrl})),Ee("OAuthStatusScreen"),!0))},Ae=()=>{let e=function(){let e;return(e=function(){let e=new URLSearchParams(window.location.search),t=Number(e.get("id")||""),r=e.get("hash"),n=Number(e.get("auth_date")||""),i=e.get("first_name");if(t&&i&&n&&r)return Object.fromEntries(e.entries())}())?(nt(),{flowType:"login-url",authData:e}):(e=function(){let e=window.location.hash;if(!e||!e.startsWith("#tgWebAppData"))return;let t=rt(e.replace("#tgWebAppData=","")),{user:r,auth_date:n,hash:i}=t;return r&&n&&i?t:void 0}())?(nt(),{flowType:"web-app",authData:e}):void 0}();if(!e||!h.loginMethods.telegram||!h.loginConfig.telegramAuthConfiguration?.seamlessAuthEnabled)return;let t=new tt;return i.startAuthFlow(t),"login-url"===e.flowType&&(t.meta.telegramWebAppData=void 0,t.meta.telegramAuthResult=e.authData),"web-app"===e.flowType&&(t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=e.authData),!0},We=async(e,t,r,n)=>{if("solana_adapter"!==e)Ue(await(i.connectors?.createEthereumWalletConnector({connectorType:e,walletClientType:t}))||null,t,r,n);else{let e=i.connectors?.findSolanaWalletConnector(t);if(!e)return;Ue(e,t,r,n)}};async function Ue(e,t,r,n){if(!e)return j({status:"disconnected",connectedWallet:null,connectError:new l.PrivyConnectorError("Unable to connect to wallet."),connector:null,connectRetry:l.notImplemented}),n?.(null,r);j({status:"disconnected",connectedWallet:null,connectError:null,connector:e,connectRetry:l.notImplemented}),e instanceof ce&&t&&await e.resetConnection(t),j({connector:e,status:"connecting",connectedWallet:null,connectError:null,connectRetry:()=>Ue(e,t,r,n)});try{let t=await e.connect({showPrompt:!0});if((!t||o.isBaseConnectedEthereumWallet(t))&&h.shouldEnforceDefaultChainOnConnect&&!h.chains.find((e=>e.id===Number(t?.chainId.replace("eip155:",""))))&&("wallet_connect_v2"!==t?.connectorType||"metamask"!==t?.walletClientType)){j((t=>({...t,connector:e,status:"switching_to_supported_chain",connectedWallet:null,connectError:null,connectRetry:l.notImplemented})));try{await(t?.switchChain(h.defaultChain.id)),t&&(t.chainId=o.formatChainIdToCAIP2(C.toHex(h.defaultChain.id)))}catch{console.warn(`Unable to switch to default chain: ${h.defaultChain.id}`)}}return j((e=>({...e,status:"connected",connectedWallet:t,connectError:null,connectRetry:l.notImplemented}))),t&&k.emitPrivyEvent(de,"connectWallet","onSuccess",{wallet:t}),n?.(t,r)}catch(e){return e instanceof l.PrivyError?(console.warn(e.cause?e.cause:e.message),k.emitPrivyEvent(de,"connectWallet","onError",e.privyErrorCode||l.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR)):(console.warn(e),k.emitPrivyEvent(de,"connectWallet","onError",l.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR)),j((t=>({...t,status:"disconnected",connectedWallet:null,connectError:e}))),n?.(null,r)}}let Me=async(e,t,r)=>{if(null===e||!o.isBaseConnectedEthereumWallet(e))return;let n=new Re(i,e,t,r);i.startAuthFlow(n)},Fe=async(e,t,r,n="plain")=>{let a=d(p.SOLANA_LEDGER_PLUGIN_ID);if("transaction"===n&&!a)throw new l.PrivyClientError("useSolanaLedger plugin hook must be mounted");if(null===e||!o.isBaseConnectedSolanaWallet(e))return;let s=new $e(e,i,t,r,n,a);i.startAuthFlow(s)},Le=async()=>{let e=new URLSearchParams(window.location.search),t=e.get("privy_connector"),r=e.get("privy_wallet_client"),n="true"===e.get("privy_connect_only");if(!t||!r)return;let a=o.getWalletConfigForConnector({connectorType:t,walletClientType:r});if(!a||!a.isInstalled)return Ee("LoginFailedScreen");if(!i.connectors)throw new l.PrivyClientError("Connector not initialized");await Ee(n?"ConnectOnlyStatusScreen":"ConnectionStatusScreen");let s=new URL(window.location.href);s.searchParams.delete("privy_connector"),s.searchParams.delete("privy_wallet_client"),s.searchParams.delete("privy_connect_only"),window.history.pushState({},"",s),We(t,r,void 0,n?void 0:"solana_adapter"===t?Fe:Me)};t.useEffect((()=>{P&&ue&&null===_&&i.getAuthenticatedUser().then(b)}),[P,ue,_,i]);let De=e=>{if(!ue)throw k.emitPrivyEvent(de,"linkAccount","onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:e}),new l.PrivyClientError("User must be authenticated before linking an account.")},je=e=>{if(!ue||!_)return!1;if("privy"===e.walletClientType)return!0;for(let t of _.linkedAccounts)if("wallet"===t.type&&t.address===e.address&&"privy"!==t.walletClientType)return!0;return!1},qe=()=>{S.useWalletStore.setState((e=>{let t=i.connectors?.wallets.filter(o.isBaseConnectedEthereumWallet).map((e=>({...e,linked:je(e),loginOrLink:async()=>{if(!await e.isConnected())throw new l.PrivyClientError("Wallet is not connected");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new l.PrivyClientError("Cannot link or login with embedded wallet");(async e=>{let t;if(!i.connectors)throw new l.PrivyClientError("Connector not initialized");t="ethereum"===e.type?i.connectors.findWalletConnector(e.connectorType,e.walletClientType)||null:i.connectors.findSolanaWalletConnector(e.walletClientType)||null,j((r=>({...r,connector:t,status:"connected",connectedWallet:e,connectError:null,connectRetry:l.notImplemented}))),h.captcha.enabledProvider&&!ue?(ne({captchaModalData:{callback:t=>o.isBaseConnectedEthereumWallet(e)?Me(e,t):Fe(e,t),userIntentRequired:!1,onSuccessNavigateTo:"ConnectionStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),await Ee("CaptchaScreen")):(o.isBaseConnectedEthereumWallet(e)?await Me(e):await Fe(e),await Ee("ConnectionStatusScreen"))})(e)},fund:async t=>{await et.fundWallet(e.address,t)},unlink:async()=>{if(!ue)throw new l.PrivyClientError("User is not authenticated.");if("embedded"===e.connectorType&&"privy"===e.walletClientType)throw new l.PrivyClientError("Cannot unlink an embedded wallet");b(await i.unlinkEthereumWallet(e.address))}})))||[];return o.areWalletArraysEqual(e.ethereumExternal,t)?{}:{ethereumExternal:t}}))};t.useEffect((()=>{qe()}),[_?.linkedAccounts,ue,P]),t.useEffect((()=>{if(P){if(!i.connectors)throw new l.PrivyClientError("Connector not initialized");qe(),i.connectors.on("walletsUpdated",qe)}}),[P]),t.useEffect((()=>{[...h.loginMethodsAndOrder?.primary??[],...h.loginMethodsAndOrder?.overflow??[]].filter((e=>e.startsWith("privy:"))).forEach((e=>i.getCrossAppProviderDetails(e.replace("privy:",""))))}),[!!i]);let Ke=({transaction:e,sponsor:t,uiOptions:u,fundWalletConfig:p,address:y,signOnly:w})=>new Promise((async(m,g)=>{let{requesterAppId:v}=u||{},f=w?"signTransaction":"sendTransaction",E=y?a.getPrivyWalletWithAddress(_,y):a.getPrivyEthereumWallet(_);if(!E&&y){let r=a.getConnectedWalletWithAddress(pr(),y);if(r){if(t)throw new l.PrivyClientError("Cannot sponsor transactions for externally connected wallet.");try{let t=await r.getEthereumProvider(),n=e.data,i=d(U.DATA_SUFFIX_PLUGIN_ID);i&&(n=i.appendDataSuffix({data:n}));let a={...e,from:y,chainId:e.chainId||Number(r.chainId.replace("eip155:","")),value:void 0!==e.value?C.toHex(e.value):void 0,data:n},s=await t.request({method:"sendTransaction"===f?"eth_sendTransaction":"eth_signTransaction",params:[a]});return k.emitPrivyEvent(de,f,"onSuccess",{hash:s}),void m({hash:s})}catch(e){return k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.TRANSACTION_FAILURE),void g(e??new c.PrivyProviderRpcError("Unable to "+f+e))}}}if(!E)return k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void g(new l.PrivyClientError("No embedded or connected wallet found for address."));if(!ue||!_)return k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED),void g(Error("User must be authenticated before signing with a Privy wallet"));let A=E.address,P=E.walletIndex??0,{entropyId:T,entropyIdVerifier:b}=S.getEntropyDetailsForUser(_,E),I=a.getConnectedWalletWithAddress(pr(),A);if(!I)return k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void g(Error("Must have a Privy wallet before signing"));let W=await I.getEthereumProvider(),R=await W.request({method:"eth_chainId"}),O=e.chainId?Number(e.chainId):c.extractChainIdFromCAIP2(R);(e=>{if(!h.chains.map((e=>e.id)).includes(e))throw new l.PrivyConnectorError(`Chain ID ${e} is not supported. It must be added to the config.supportedChains property of the PrivyProvider.`,l.PrivyErrorCode.UNSUPPORTED_CHAIN_ID)})(O);let N=e.data,M=d(U.DATA_SUFFIX_PLUGIN_ID);M&&(N=M.appendDataSuffix({data:N}));let F={...e,from:e.from??A,chainId:O,data:N},L=await it();if(!L||!Z)return k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),void g(Error("Must have valid access token and Privy wallet to send transaction"));let D=x.getPublicClient(F.chainId,h.chains,h.rpcConfig,{appId:n.appId}),j=a.getIsUnifiedWallet(E),q=async({transactionRequest:e})=>{try{let n;if(!await et.recoverEmbeddedWallet({address:A}))throw k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),g(Error("Unable to connect to wallet")),Error("Unable to connect to wallet");if(t){let t=await(async({transactionRequest:e})=>{if(!j)throw new l.PrivyClientError("Sponsoring is only supported for wallets on the TEE stack");if(w)throw new l.PrivyClientError("Cannot sponsor a sign transaction request");let t=e=>null==e?void 0:C.toHex(e),n=await r.rpc(s,(async({message:e})=>await Z.signWithUserSigner({accessToken:L,requesterAppId:v,message:e})),{chain_type:"ethereum",method:"eth_sendTransaction",caip2:o.formatChainIdToCAIP2(C.toHex(e.chainId)),sponsor:!0,params:{transaction:{from:e.from,to:e.to,chain_id:t(e.chainId),data:C.isHex(e.data)?e.data?e.data:C.toHex(Uint8Array.from(e.data)):void 0,value:t(e.value)}},wallet_id:E.id});if(n.data&&"hash"in n.data)return n.data.hash;throw new c.PrivyProviderRpcError("Unable to sign transaction")})({transactionRequest:e});return k.emitPrivyEvent(de,"sendTransaction","onSuccess",{hash:t}),t}if(j){let t=e=>null==e?void 0:C.toHex(e),i=await r.rpc(s,(async({message:e})=>await Z.signWithUserSigner({accessToken:L,requesterAppId:v,message:e})),{chain_type:"ethereum",method:"eth_signTransaction",params:{transaction:{from:e.from,to:e.to,nonce:t(e.nonce),chain_id:t(e.chainId),data:C.isHex(e.data)?e.data?e.data:C.toHex(Uint8Array.from(e.data)):void 0,value:t(e.value),type:e.type,gas_limit:t(e.gasLimit??e.gas),gas_price:t(e.gasPrice??e.gas),max_fee_per_gas:t(e.maxFeePerGas),max_priority_fee_per_gas:t(e.maxPriorityFeePerGas)}},wallet_id:E.id});if(!i.data||!("signed_transaction"in i.data))throw new c.PrivyProviderRpcError("Unable to sign transaction");n=i.data.signed_transaction}else n=await async function({accessToken:e,entropyId:t,entropyIdVerifier:r,transactingWalletIndex:n,walletProxy:i,transactionRequest:a,requesterAppId:s}){return(await i.rpc({entropyId:t,entropyIdVerifier:r,hdWalletIndex:n??0,chainType:"ethereum",accessToken:e,requesterAppId:s,request:{method:"eth_signTransaction",params:[a]}})).response.data}({accessToken:L,entropyId:T,entropyIdVerifier:b,transactingWalletIndex:P,walletProxy:Z,transactionRequest:e,requesterAppId:v});if(w)return k.emitPrivyEvent(de,"signTransaction","onSuccess",{signature:n}),n;{let e=await D.sendRawTransaction({serializedTransaction:n});return k.emitPrivyEvent(de,"sendTransaction","onSuccess",{hash:e}),e}}catch(e){throw k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.TRANSACTION_FAILURE),e}};if(fe({showWalletUIs:u?.showWalletUIs})){let e=w||t?F:await cr(F,D,F.from);try{let t=await q({transactionRequest:e});w?k.emitPrivyEvent(de,"signTransaction","onSuccess",{signature:t}):k.emitPrivyEvent(de,"sendTransaction","onSuccess",{hash:t}),m({hash:t})}catch(e){k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.TRANSACTION_FAILURE),g(e)}}else{let e={connectingWalletAddress:A,recoveryMethod:E.recoveryMethod,entropyId:T,entropyIdVerifier:b,onCompleteNavigateTo:"SendTransactionScreen",isUnifiedWallet:j,onFailure:e=>{k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),g(e)}},r=(e=>!!e.fundingConfig&&c.filterSupportedOptions(e.fundingConfig.options).length>=1)(h)?c.prepareFundingModalData({address:A,appConfig:h,fundWalletConfig:p,methodScreen:"FundingMethodSelectionScreen",chainIdOverride:F.chainId,comingFromSendTransactionScreen:!0}):void 0;ne({connectWallet:e,sendTransaction:{transactionRequest:F,transactingWalletIndex:P,transactingWalletAddress:A,entropyId:T,entropyIdVerifier:b,signOnly:w,scanTransaction:async()=>{let e=await cr(F,D,F.from);return await i.scanTransaction({metadata:{domain:h.embeddedWallets.transactionScanning.domain},chain_id:e.chainId.toString(),request:{method:"eth_sendTransaction",params:[{from:e.from,to:e.to,value:e.value?.toString(),gas:e.gas?.toString(),gasPrice:e.gasPrice?.toString(),nonce:e.nonce?.toString(),data:e.data}]}})},getIsSponsored:async()=>!!t,onConfirm:({transactionRequest:e})=>q({transactionRequest:e}),onSuccess:e=>{w?k.emitPrivyEvent(de,"signTransaction","onSuccess",{signature:e.hash}):k.emitPrivyEvent(de,"sendTransaction","onSuccess",{hash:e.hash}),m(e)},onFailure:e=>{k.emitPrivyEvent(de,f,"onError",l.PrivyErrorCode.TRANSACTION_FAILURE),g(e)},uiOptions:u||{},fundWalletConfig:p,requesterAppId:v},funding:r}),Ee("EmbeddedWalletConnectingScreen")}}));function ze(){return new Promise((async(e,t)=>{let r=await it();if(!r||!Z)throw Error("Must have valid access token to enroll in MFA");try{await Z.verifyMfa({accessToken:r}),e()}catch(e){t(e)}}))}let He=e=>e?.linkedAccounts.filter((e=>null!==e.latestVerifiedAt&&!("wallet"===e.type&&"privy"===e.walletClientType))).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0],Ve=e=>{let t=_?.linkedAccounts.filter((t=>t.type===e)).length??0,{displayName:r,loginMethod:n}=lr(e);if("passkey"===e&&t>=5||"passkey"!==e&&t>=1)throw k.emitPrivyEvent(de,"linkAccount","onError",l.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE,{linkMethod:n}),new l.PrivyClientError(`User already has an account of type ${r} linked.`)};async function Be({showAutomaticRecovery:e=!1,legacySetWalletPasswordFlow:t=!1}){M(null);let r=t?"setWalletPassword":"setWalletRecovery";if(!ue||!_)throw k.emitPrivyEvent(de,r,"onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED),Error("User must be authenticated before adding recovery method to Privy wallet");let n=a.getPrivyPrimaryWallet(_);if(!n||!Z)throw k.emitPrivyEvent(de,r,"onError",l.PrivyErrorCode.EMBEDDED_WALLET_NOT_FOUND),Error("Must have a Privy wallet to add a recovery method");let i=a.getIsUnifiedWallet(n);if(i)throw k.emitPrivyEvent(de,r,"onError",l.PrivyErrorCode.UNSUPPORTED_WALLET_TYPE),new l.PrivyClientError("User owned wallet recovery is only supported for on-device execution and this app uses TEE execution. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");try{await ze()}catch(e){throw k.emitPrivyEvent(de,r,"onError",l.PrivyErrorCode.MISSING_MFA_CREDENTIALS),e}return new Promise(((a,s)=>{let o="user-passcode"===n.recoveryMethod,c=tr({walletAction:"update",availableRecoveryMethods:h.embeddedWallets.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:t,isResettingPassword:o,showAutomaticRecovery:e}),{entropyId:d,entropyIdVerifier:u}=S.getEntropyDetailsForUser(_),p={recoveryMethod:n.recoveryMethod,connectingWalletAddress:n.address,onCompleteNavigateTo:c,shouldForceMFA:!1,entropyId:d,isUnifiedWallet:i,entropyIdVerifier:u,onFailure:e=>{k.emitPrivyEvent(de,r,"onError",l.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),s(e)}};ne({setWalletPassword:{onSuccess:e=>{k.emitPrivyEvent(de,r,"onSuccess",{method:"user-passcode",wallet:e}),a(e)},onFailure:e=>{k.emitPrivyEvent(de,r,"onError",l.PrivyErrorCode.USER_EXITED_SET_PASSWORD_FLOW),s(e)},callAuthOnSuccessOnClose:!1},recoverWallet:{entropyId:d,entropyIdVerifier:u,onFailure:s},connectWallet:p,recoverySelection:{isInAccountCreateFlow:!1,isResettingPassword:o,shouldCreateEth:!1,shouldCreateSol:!1}}),Ee("EmbeddedWalletConnectingScreen")}))}async function Je({appId:e,action:t,disableSignup:r}){let n=await it();if("link"===t&&!n)throw k.emitPrivyEvent(de,"linkAccount","onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:`privy:${e}`}),new l.PrivyClientError("User must be authenticated before linking an account.");if("login"===t&&n)throw k.emitPrivyEvent(de,"login","onError",l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),new l.PrivyClientError("Attempted to log in, but user is already logged in. Use a `link` helper instead.");ye.current=`privy:${e}`,we.current=t;let a=A.trigger();return i.createAnalyticsEvent({eventName:"cross_app_auth_started",payload:{providerAppId:e}}),new Promise((async(n,s)=>{let{name:o,logoUrl:l}=await Jt({api:i.api,providerAppId:e,requesterAppId:h.id});ne({crossAppAuth:{appId:e,name:o,logoUrl:l,action:t,popup:a,disableSignup:r,onSuccess:n,onError:s}}),Ee("CrossAppAuthScreen")}))}let Qe={ready:P,authenticated:ue,user:_,walletConnectors:i.connectors||null,connectWallet:e=>{e&&"target"in e&&e&&(e=void 0),ne({externalConnectWallet:{walletList:e?.walletList&&e?.walletList.length>0?e.walletList:void 0,walletChainType:e?.walletChainType,description:e?.description,hideHeader:e?.hideHeader}}),Ee("ConnectOnlyLandingScreen")},linkWallet:e=>(e&&"target"in e&&e&&(e=void 0),De("siwe"),ye.current="siwe",we.current="link",ne({...re,externalConnectWallet:{...re.externalConnectWallet,walletList:e?.walletList,walletChainType:e?.walletChainType,description:e?.description||`Link a wallet to your ${h?.name} account`}}),Ee("AuthenticateWithWalletScreen")),startCrossAppAuthFlow:Je,linkEmail:()=>{De("email"),Ve("email"),ye.current="email",we.current="link",Ee("LinkEmailScreen")},linkPhone:()=>{De("sms"),Ve("phone"),ye.current="sms",we.current="link",Ee("LinkPhoneScreen")},linkGoogle:async()=>{De("google"),Ve("google_oauth"),we.current="link",await et.initLoginWithOAuth("google")},linkTwitter:async()=>{De("twitter"),Ve("twitter_oauth"),we.current="link",await et.initLoginWithOAuth("twitter")},linkTwitch:async()=>{De("twitch"),Ve("twitch_oauth"),we.current="link",await et.initLoginWithOAuth("twitch")},linkDiscord:async()=>{De("discord"),Ve("discord_oauth"),we.current="link",await et.initLoginWithOAuth("discord")},linkGithub:async()=>{De("github"),Ve("github_oauth"),we.current="link",await et.initLoginWithOAuth("github")},linkSpotify:async()=>{De("spotify"),Ve("spotify_oauth"),we.current="link",await et.initLoginWithOAuth("spotify")},linkInstagram:async()=>{De("instagram"),Ve("instagram_oauth"),we.current="link",await et.initLoginWithOAuth("instagram")},linkTiktok:async()=>{De("tiktok"),Ve("tiktok_oauth"),we.current="link",await et.initLoginWithOAuth("tiktok")},linkLine:async()=>{De("line"),Ve("line_oauth"),we.current="link",await et.initLoginWithOAuth("line")},linkLinkedIn:async()=>{De("linkedin"),Ve("linkedin_oauth"),we.current="link",await et.initLoginWithOAuth("linkedin")},linkApple:async()=>{De("apple"),Ve("apple_oauth"),we.current="link",await et.initLoginWithOAuth("apple")},linkPasskey:async()=>{De("passkey"),Ve("passkey"),await et.initLinkWithPasskey(),Ee("LinkPasskeyScreen")},linkTelegram:async e=>{if(De("telegram"),Ve("telegram"),we.current="link",ye.current="telegram",e?.launchParams)if(e.launchParams.initDataRaw){let t=new tt;i.startAuthFlow(t),t.meta.telegramAuthResult=void 0,t.meta.telegramWebAppData=rt(e.launchParams.initDataRaw),ne({telegramAuthModalData:{seamlessAuth:!0}}),Ee("TelegramAuthScreen")}else k.emitPrivyEvent(de,"linkAccount","onError",l.PrivyErrorCode.INVALID_DATA,{linkMethod:"telegram"});else await et.initLoginWithTelegram();Ee("TelegramAuthScreen")},linkFarcaster:async()=>{De("farcaster"),Ve("farcaster"),await et.initLoginWithFarcaster(),we.current="link",ye.current="farcaster",Ee("FarcasterConnectStatusScreen")},updateEmail:()=>{if(De("email"),!_?.email)throw new l.PrivyClientError("User does not have an email linked to their account.");we.current="update",ye.current="email",Ee("UpdateEmailScreen")},updatePhone:()=>{if(De("sms"),!_?.phone)throw new l.PrivyClientError("User does not have a phone number linked to their account.");we.current="update",ye.current="sms",Ee("UpdatePhoneScreen")},login:async e=>{e&&"target"in e&&e&&(e=void 0);let t="Attempted to log in, but user is already logged in. Use a `link` helper instead.";if(!P){let e=await new Promise((e=>{ae((t=>e.bind(t)))}));if(ae(null),e)return void console.warn(t)}!_||_.isGuest?(we.current="login",ne({login:e}),Ee("LandingScreen")):console.warn(t)},connectOrCreateWallet:async()=>{P||(await new Promise((e=>{ae((()=>e))})),ae(null)),ue?console.warn("User must be unauthenticated to `connectOrCreateWallet`"):(we.current="connect-or-create",Ee("ConnectOrCreateScreen"))},logout:async()=>{if(we.current=null,ye.current=null,_&&i.clearProviderAcccessTokens(_),M(null),await i.logout(),_&&Z)try{await Z.clearMfa({userId:_.id})}catch(e){}b(null),pe(!1),H({status:"initial"}),B({status:"initial"}),K({status:"initial"}),G({status:"initial"}),J({status:"initial"}),X({status:"initial"}),k.emitPrivyEvent(de,"logout","onSuccess"),m(!1),c.s.del(y.CLIENT_ANALYTICS_ID_KEY),c.s.del(y.getGuestCredentialStorageKey(h.id))},getAccessToken:t.useCallback((async()=>{let e=await i.getCustomerAccessToken();return e&&!ue&&pe(!0),e}),[i,ue]),unlinkWallet:async e=>{let t;return b(t=e.startsWith("0x")?await i.unlinkEthereumWallet(e):await i.unlinkSolanaWallet(e)),t},unlinkEmail:async e=>{let t=await i.unlinkEmail(e);return b(t),t},unlinkPhone:async e=>{let t=await i.unlinkPhone(e);return b(t),t},unlinkGoogle:async e=>{let t=await i.unlinkOAuth("google",e);return b(t),t},unlinkTwitter:async e=>{let t=await i.unlinkOAuth("twitter",e);return b(t),t},unlinkTwitch:async e=>{let t=await i.unlinkOAuth("twitch",e);return b(t),t},unlinkDiscord:async e=>{let t=await i.unlinkOAuth("discord",e);return b(t),t},unlinkGithub:async e=>{let t=await i.unlinkOAuth("github",e);return b(t),t},unlinkSpotify:async e=>{let t=await i.unlinkOAuth("spotify",e);return b(t),t},unlinkInstagram:async e=>{let t=await i.unlinkOAuth("instagram",e);return b(t),t},unlinkTiktok:async e=>{let t=await i.unlinkOAuth("tiktok",e);return b(t),t},unlinkLine:async e=>{let t=await i.unlinkOAuth("line",e);return b(t),t},unlinkLinkedIn:async e=>{let t=await i.unlinkOAuth("linkedin",e);return b(t),t},unlinkApple:async e=>{let t=await i.unlinkOAuth("apple",e);return b(t),t},unlinkFarcaster:async e=>{let t=await i.unlinkFarcaster(e);return b(t),t},unlinkTelegram:async e=>{let t=await i.unlinkTelegram(e);return b(t),t},unlinkPasskey:async e=>{let t=await it();if(!t)throw Error("Must have valid access token to enroll in MFA");if(!Z)throw Error("Wallet proxy not initialized.");let r=h.passkeys.shouldUnenrollMfaOnUnlink;await Z.unlinkPasskeyAccount({credentialId:e,accessToken:t,removeAsMfa:r});let n=await i.getAuthenticatedUser();return b(n),n},unlinkCrossAppAccount:async({subject:e})=>{let t=_?.linkedAccounts.find((t=>"cross_app"===t.type&&t.subject===e))?.providerApp;if(!t)throw new l.PrivyClientError("Invalid subject");i.storeProviderAccessToken(t.id,null);let r=await i.unlinkOAuth(`privy:${t.id}`,e);return b(r),r},setWalletRecovery:async e=>Be({legacySetWalletPasswordFlow:!1,showAutomaticRecovery:e?.showAutomaticRecovery??!1}),setWalletPassword:async()=>Be({legacySetWalletPasswordFlow:!0,showAutomaticRecovery:!1}),signMessage:(e,t)=>new Promise((async(n,o)=>{let{requesterAppId:d}=t?.uiOptions||{},u=e.message,h=t?.address?a.getPrivyWalletWithAddress(_,t.address):a.getPrivyEthereumWallet(_);if(!h&&void 0!==t?.address){let e=a.getConnectedWalletWithAddress(pr(),t.address);if(e)try{let t=await e.getEthereumProvider(),r=await t.request({method:"personal_sign",params:[u,e.address]});return k.emitPrivyEvent(de,"signMessage","onSuccess",{signature:r}),void n({signature:r})}catch(e){return k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.UNABLE_TO_SIGN),void o(e??new c.PrivyProviderRpcError("Unable to sign message"))}}if(!h)throw new l.PrivyClientError("No embedded or connected wallet found for address.");if(!ue||!_)return k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED),void o(Error("User must be authenticated before signing with a Privy wallet"));let p=h.address,y=h.walletIndex??0,{entropyId:w,entropyIdVerifier:m}=S.getEntropyDetailsForUser(_,h),g=a.getIsUnifiedWallet(h);if("string"!=typeof u||u.length<1)return k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.INVALID_MESSAGE),void o(Error("Message must be a non-empty string"));let v=async()=>{let t;if(!ue)throw Error("User must be authenticated before signing with a Privy wallet");let n=await it();if(!Z||!n||!await et.recoverEmbeddedWallet({address:p}))throw Error("Unable to connect to wallet");if(i.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_started",payload:{walletAddress:p,requesterAppId:d}}),g){let i=C.isHex(e.message,{strict:!0}),a=await r.rpc(s,(async({message:e})=>await Z.signWithUserSigner({accessToken:n,requesterAppId:d,message:e})),{chain_type:"ethereum",method:"personal_sign",params:i?{message:u.slice(2),encoding:"hex"}:{message:u,encoding:"utf-8"},wallet_id:h.id});if(!a.data||!("signature"in a.data))throw new c.PrivyProviderRpcError("Unable to sign message");t=a.data.signature}else{let{response:e}=await Z.rpc({accessToken:n,entropyId:w,entropyIdVerifier:m,chainType:"ethereum",hdWalletIndex:y,requesterAppId:d,request:{method:"personal_sign",params:[u,p]}});t=e.data}return i.createAnalyticsEvent({eventName:"embedded_wallet_sign_message_completed",payload:{walletAddress:p,requesterAppId:d}}),t};if(fe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await v();k.emitPrivyEvent(de,"signMessage","onSuccess",{signature:e}),n({signature:e})}catch(e){k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.UNABLE_TO_SIGN),o(e??new c.PrivyProviderRpcError("Unable to sign message"))}else ne({signMessage:{method:"personal_sign",data:u,confirmAndSign:v,onSuccess:e=>{k.emitPrivyEvent(de,"signMessage","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.UNABLE_TO_SIGN),o(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:h.recoveryMethod,connectingWalletAddress:p,entropyId:w,entropyIdVerifier:m,onCompleteNavigateTo:"SignRequestScreen",isUnifiedWallet:g,onFailure:e=>{k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),o(e)}}}),Ee("EmbeddedWalletConnectingScreen")})),signTypedData:(e,t)=>new Promise((async(n,d)=>{let{requesterAppId:u}=t?.uiOptions||{},h=t?.address?a.getPrivyWalletWithAddress(_,t.address):a.getPrivyEthereumWallet(_);if(!h&&t?.address){let r=a.getConnectedWalletWithAddress(pr(),t.address);if(r)try{let t=await r.getEthereumProvider(),i=o.generateTypedDataWithDomainType(e),a=await t.request({method:"eth_signTypedData_v4",params:[r.address,i]});return k.emitPrivyEvent(de,"signTypedData","onSuccess",{signature:a}),void n({signature:a})}catch(e){return k.emitPrivyEvent(de,"signTypedData","onError",l.PrivyErrorCode.UNABLE_TO_SIGN),void d(e??new c.PrivyProviderRpcError("Unable to sign typed data "+e))}}if(!h)throw new l.PrivyClientError("No embedded or connected wallet found for address.");if(!ue||!_)return k.emitPrivyEvent(de,"signTypedData","onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED),void d(Error("User must be authenticated before signing with a Privy wallet"));let p=h.address,y=h.walletIndex??0,{entropyId:w,entropyIdVerifier:m}=S.getEntropyDetailsForUser(_,h),g=a.getIsUnifiedWallet(h),v=o.generateTypedDataWithDomainType(e),f=async()=>{let e;if(!ue)throw Error("User must be authenticated before signing with a Privy wallet");let t=await it();if(!Z||!t||!await et.recoverEmbeddedWallet({address:p}))throw Error("Unable to connect to wallet");if(i.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_started",payload:{walletAddress:p,requesterAppId:u}}),g){let{domain:n,types:i,primaryType:a,message:o}=v,l=await r.rpc(s,(async({message:e})=>await Z.signWithUserSigner({accessToken:t,requesterAppId:u,message:e})),{chain_type:"ethereum",method:"eth_signTypedData_v4",params:{typed_data:{domain:n,types:i,primary_type:a,message:o}},wallet_id:h.id});if(!l.data||!("signature"in l.data))throw new c.PrivyProviderRpcError("Unable to sign message");e=l.data.signature}else{let{response:r}=await Z.rpc({accessToken:t,entropyId:w,entropyIdVerifier:m,chainType:"ethereum",hdWalletIndex:y,requesterAppId:u,request:{method:"eth_signTypedData_v4",params:[p,v]}});e=r.data}return i.createAnalyticsEvent({eventName:"embedded_wallet_sign_typed_data_completed",payload:{walletAddress:p,requesterAppId:u}}),e};if(fe({showWalletUIs:t?.uiOptions?.showWalletUIs}))try{let e=await f();k.emitPrivyEvent(de,"signTypedData","onSuccess",{signature:e}),n({signature:e})}catch(e){k.emitPrivyEvent(de,"signTypedData","onError",l.PrivyErrorCode.UNABLE_TO_SIGN),d(e??new c.PrivyProviderRpcError("Unable to sign message"))}else ne({signMessage:{method:"eth_signTypedData_v4",data:v,confirmAndSign:f,onSuccess:e=>{k.emitPrivyEvent(de,"signTypedData","onSuccess",{signature:e}),n({signature:e})},onFailure:e=>{k.emitPrivyEvent(de,"signTypedData","onError",l.PrivyErrorCode.UNABLE_TO_SIGN),d(e)},uiOptions:t?.uiOptions||{}},connectWallet:{recoveryMethod:h.recoveryMethod,connectingWalletAddress:h.address,entropyId:w,isUnifiedWallet:g,entropyIdVerifier:m,onCompleteNavigateTo:"SignRequestScreen",onFailure:e=>{k.emitPrivyEvent(de,"signMessage","onError",l.PrivyErrorCode.UNKNOWN_CONNECT_WALLET_ERROR),d(e)}}}),Ee("EmbeddedWalletConnectingScreen")})),sendTransaction:async(e,t)=>await Ke({transaction:e,sponsor:t?.sponsor,uiOptions:t?.uiOptions,fundWalletConfig:t?.fundWalletConfig,address:t?.address,signOnly:!1}),signTransaction:async(e,t)=>({signature:(await Ke({transaction:e,uiOptions:t?.uiOptions,address:t?.address,signOnly:!0})).hash}),promptMfa:ze,async init(e){switch(e){case"sms":return void await i.initMfaSmsVerification();case"passkey":return await i.initMfaPasskeyVerification();case"totp":return;default:throw Error(`Unsupported MFA method: ${e}`)}},async submit(e,t){switch(e){case"totp":case"sms":if("string"!=typeof t)throw new l.PrivyClientError("Invalid MFA code");oe.current?.resolve({mfaMethod:e,mfaCode:t,relyingParty:window.origin}),await new Promise(((e,t)=>{le.current={resolve:e,reject:t}}));break;case"passkey":if("string"==typeof t)throw new l.PrivyClientError("Invalid authenticator response");let r=await import("@simplewebauthn/browser"),n=hr(await r.startAuthentication({optionsJSON:t}));oe.current?.resolve({mfaMethod:e,mfaCode:n,relyingParty:window.origin}),await new Promise(((e,t)=>{le.current={resolve:e,reject:t}}));break;default:throw oe.current?.reject(new l.PrivyClientError("Unsupported MFA method")),new l.PrivyClientError(`Unsupported MFA method: ${e}`)}},cancel(){oe.current?.reject(new l.PrivyClientError("MFA canceled"))},async initEnrollmentWithSms(e){let t=await it();if(!t||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.initEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber})},enrollInMfa:e=>new Promise(((t,r)=>{if(!e)return et.closePrivyModal(),void t();h.mfa.noPromptOnMfaRequired&&console.warn("[Privy Warning] Triggering the 'showMfaEnrollmentModal' function when 'noPromptOnMfaRequired' is set to true is unexpected. If this is intentional, ensure that you are building custom UIs for MFA verification."),ne({mfaEnrollmentFlow:{mfaMethods:h.mfa.methods,shouldUnlinkOnUnenrollMfa:h.passkeys.shouldUnlinkOnUnenrollMfa,onSuccess:t,onFailure:r}}),Ee("MfaEnrollmentFlowScreen")})),async initEnrollmentWithTotp(){let e=await it();if(!e||!Z)throw Error("Must have valid access token to enroll in MFA");let t=await Z.initEnrollMfa({method:"totp",accessToken:e});return{secret:t.secret,authUrl:t.authUrl}},async submitEnrollmentWithSms(e){let t=await it();if(!t||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.submitEnrollMfa({method:"sms",accessToken:t,phoneNumber:e.phoneNumber,code:e.mfaCode}),b(await i.getAuthenticatedUser())},async submitEnrollmentWithTotp(e){let t=await it();if(!t||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.submitEnrollMfa({method:"totp",accessToken:t,code:e.mfaCode}),b(await i.getAuthenticatedUser())},async initEnrollmentWithPasskey(){},async submitEnrollmentWithPasskey({credentialIds:e},t={}){let r=await it();if(!r||!Z)throw Error("Must have valid access token to enroll in MFA");await Z.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:e,removeForLogin:t.removeForLogin}),b(await i.getAuthenticatedUser())},async unenroll(e,t={}){let r=await it();if(!r||!Z)throw Error("Must have valid access token to remove MFA");"passkey"===e?await Z.submitEnrollMfa({method:"passkey",accessToken:r,credentialIds:[],removeForLogin:t.removeForLogin}):await Z.unenrollMfa({method:e,accessToken:r}),b(await i.getAuthenticatedUser())},requestFarcasterSignerFromWarpcast:async()=>{let e=await it(),t=_?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!e)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!t)throw Error("Must have an embedded wallet to use Farcaster signers");if(a.getIsUnifiedWallet(t))throw new l.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!_?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await et.recoverEmbeddedWallet({address:t.address}))throw Error("Unable to connect to wallet");let r=await Z.initFarcasterSigner({address:t.address,hdWalletIndex:null,accessToken:e,mfaCode:null,mfaMethod:null,relyingParty:window.origin});"approved"===r.status&&b(await i.getAuthenticatedUser()||_||null),ne({farcasterSigner:r}),Ee("FarcasterSignerStatusScreen")},getFarcasterSignerPublicKey:async()=>{let e,t=await it(),r=_?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(a.getIsUnifiedWallet(r))throw new l.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!_?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await et.recoverEmbeddedWallet({address:r.address}))throw Error("Unable to connect to wallet");if(!_.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");return e=_.farcaster.signerPublicKey.slice(2),Uint8Array.from(e.match(/.{1,2}/g).map((e=>parseInt(e,16))))},signFarcasterMessage:async e=>{let t=await it(),r=_?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(a.getIsUnifiedWallet(r))throw new l.PrivyClientError("Farcaster signers are only supported for on-device execution and this app uses TEE execution. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");if(!_?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");if(!await et.recoverEmbeddedWallet({address:r.address}))throw Error("Unable to connect to wallet");if(!_.farcaster?.signerPublicKey)throw Error("Must have a Farcaster signer public key to sign");let n=await import("@simplewebauthn/browser"),i=await Z.signFarcasterMessage({address:r.address,hdWalletIndex:null,accessToken:t,mfaCode:null,mfaMethod:null,payload:{hash:n.bufferToBase64URLString(e)},fid:BigInt(_.farcaster.fid),relyingParty:window.origin});return new Uint8Array(n.base64URLStringToBuffer(i.signature))},signMessageWithCrossAppWallet(e,{address:t,chainId:r}){let n=_?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Qt({user:_,client:i,address:t,requesterAppId:h.id,request:{method:n?"privy_signSmartWalletMessage":"personal_sign",params:[e,t],chainId:r},reconnect:Je})},signTypedDataWithCrossAppWallet(e,{address:t,chainId:r}){let n=_?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t)))),a=o.generateTypedDataWithDomainType(e);return Qt({user:_,client:i,address:t,requesterAppId:h.id,request:{method:n?"privy_signSmartWalletTypedData":"eth_signTypedData_v4",params:[t,a],chainId:r},reconnect:Je})},sendTransactionWithCrossAppWallet(e,{address:t}){let r=_?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Qt({user:_,client:i,address:t,requesterAppId:h.id,request:{method:r?"privy_sendSmartWalletTx":"eth_sendTransaction",params:[e],chainId:e.chainId},reconnect:Je})},signTransactionWithCrossAppWallet(e,{address:t}){let r=_?.linkedAccounts.some((e=>"cross_app"===e.type&&e.smartWallets.some((e=>e.address===t))));return Qt({user:_,client:i,address:t,requesterAppId:h.id,request:{method:r?"privy_signSmartWalletTx":"eth_signTransaction",params:[e],chainId:e.chainId},reconnect:Je})},isModalOpen:w||!!v,mfaMethods:h.mfa.methods};Ir=Qe.signMessage,Wr=Qe.signTypedData,xr=async(e,t)=>await Ke({transaction:e,...t,signOnly:!1}),Ur=async(e,t)=>({signature:(await Ke({transaction:e,...t,signOnly:!0})).hash});let Ze=async e=>{let t,r,n;L(!0),J({status:"loading"}),i.startAuthFlow(new be({...e,customOAuthRedirectUrl:h.customOAuthRedirectUrl}));let a=c.s.get(y.STATE_CODE_KEY),s=e.stateCode;if(a!==s)throw i.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e.provider,storedStateCode:a??"",returnedStateCode:s??""}}),L(!1),new l.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,l.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await i.getAccessToken())try{({user:t,oAuthTokens:n}=await i.link()),ye.current=e.provider;let r=He(t);t&&r&&k.emitPrivyEvent(de,"linkAccount","onSuccess",{user:t,linkMethod:ye.current,linkedAccount:r})}catch(t){throw L(!1),k.emitPrivyEvent(de,"linkAccount","onError",t.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e.provider}),t}else try{({user:t,isNewUser:r,oAuthTokens:n}=await i.authenticate()),ye.current=e.provider;let a=He(t);t&&a&&void 0!==r&&k.emitPrivyEvent(de,"login","onComplete",{user:t,isNewUser:r,wasAlreadyAuthenticated:!1,loginMethod:ye.current,loginAccount:a})}catch(e){throw L(!1),J({status:"error",error:e}),k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}return b(t),O(r||!1),pe(!0),L(!1),J({status:"done"}),n&&t&&k.emitPrivyEvent(de,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),t??void 0},et={privy:s,setAuthenticated:pe,setUser:b,setIsNewUser:O,isNewUserThisSession:R,pendingTransaction:null,walletConnectionStatus:D,setWalletConnectionStatus:j,connectors:i.connectors?.walletConnectors??[],rpcConfig:h.rpcConfig,chains:h.chains,appId:n.appId,showFiatPrices:"native-token"!==h.embeddedWallets.priceDisplay.primary,clientAnalyticsId:i.clientAnalyticsId,hideWalletUIs:me,isHeadlessSigning:t.useCallback(fe,[h.embeddedWallets.showWalletUIs]),emailOtpState:z,setEmailOtpState:H,smsOtpState:V,setSmsOtpState:B,oAuthState:$,setOAuthState:J,telegramAuthState:Q,setTelegramAuthState:X,siweState:Y,setSiweState:G,isHeadlessOAuthLoading:F,baseAccountSdk:I,setBaseAccountSdk:W,nativeTokenSymbolForChainId:e=>h.chains.find((t=>t.id===Number(e)))?.nativeCurrency.symbol,initializeWalletProxy:async e=>{if(Z)return Z;let t=new Promise((e=>{se.current=e})),r=new Promise((t=>setTimeout((()=>t(null)),e))),n=await Promise.race([t,r]);return se.current=null,n},getAuthFlow:()=>i.authFlow,getAuthMeta:()=>i.authFlow?.meta,client:i,closePrivyModal:async(e={shouldCallAuthOnSuccess:!0,isSuccess:!1})=>{let t,r=P&&ue&&_;if(r&&ye.current&&(t=He(_)),"login"===we.current)e.shouldCallAuthOnSuccess&&r&&ye.current?k.emitPrivyEvent(de,"login","onComplete",{user:_,isNewUser:R,wasAlreadyAuthenticated:!1,loginMethod:ye.current,loginAccount:t??null}):k.emitPrivyEvent(de,"login","onError",l.PrivyErrorCode.USER_EXITED_AUTH_FLOW);else if("link"===we.current&&t)e.isSuccess&&r&&ye.current?k.emitPrivyEvent(de,"linkAccount","onSuccess",{user:_,linkMethod:ye.current,linkedAccount:t}):ye.current&&k.emitPrivyEvent(de,"linkAccount","onError",l.PrivyErrorCode.USER_EXITED_LINK_FLOW,{linkMethod:ye.current});else if("update"===we.current&&t)e.isSuccess&&r&&ye.current?k.emitPrivyEvent(de,"update","onSuccess",{user:_,updateMethod:ye.current,updatedAccount:t}):ye.current&&k.emitPrivyEvent(de,"update","onError",l.PrivyErrorCode.USER_EXITED_UPDATE_FLOW,{linkMethod:ye.current});else if("connect-or-create"===we.current){let e=pr();e[0]?k.emitPrivyEvent(de,"connectOrCreateWallet","onSuccess",{wallet:e[0]}):k.emitPrivyEvent(de,"connectOrCreateWallet","onError",l.PrivyErrorCode.USER_EXITED_AUTH_FLOW)}let a=N&&ir.has(N),s="ErrorScreen"===N&&re.errorModalData&&ir.has(re.errorModalData.previousScreen);if((a||s)&&re.funding){let e,t=ir.get(N)??null;if(s&&re.funding?.onError){let e=re.errorModalData?.error,t=e?.privyErrorCode||l.PrivyErrorCode.UNKNOWN_FUNDING_ERROR,r=new l.PrivyClientError(e?.message||"Funding failed",e,t);re.funding?.onError?.(r)}if("solana"===re.funding.chainType){let r=h.solanaRpcs[re.funding.chain];if(!r)return console.warn("Unable to load solana rpc, skipping balance"),k.emitPrivyEvent(de,"fundSolanaWallet","onUserExited",{address:re.funding.address,fundingMethod:t,chain:re.funding.chain,balance:e}),m(!1),void nr(re.funding,t);if(d(p.SOLANA_FUNDING_PLUGIN_ID))try{e=await sr({rpc:r.rpc,address:re.funding.address})}catch{console.error("Unable to pull wallet balance")}else console.warn("Unable to load solana plugin, skipping balance");k.emitPrivyEvent(de,"fundSolanaWallet","onUserExited",{address:re.funding.address,fundingMethod:t,chain:re.funding.chain,balance:e})}else{let r=x.getPublicClient(re.funding.chain.id,h.chains,h.rpcConfig,{appId:n.appId});try{e=await r.getBalance({address:re.funding.address})}catch{console.error("Unable to pull wallet balance")}k.emitPrivyEvent(de,"fundWallet","onUserExited",{address:re.funding.address,chain:re.funding.chain,fundingMethod:t,balance:e}),nr(re.funding,t)}}ne((e=>({...e,externalConnectWallet:{}}))),we.current=null,ye.current=null,O(!1),m(!1),j({status:"disconnected",connectedWallet:null,connector:null,connectError:null,connectRetry:()=>{}}),setTimeout((()=>{i.authFlow=void 0}),200)},openPrivyModal:Ee,connectWallet:Ue,initLoginWithWallet:async(e,t,r,n)=>{o.isBaseConnectedEthereumWallet(e)?(ye.current="siwe",Me(e,t,r)):(ye.current="siws",Fe(e,t,r,n))},loginWithWallet:async()=>{let e,t,r;if(!P)throw new l.PrivyNotReadyError;if(i.authFlow instanceof Re?e="siwe":i.authFlow instanceof $e&&(e="siws"),!e)throw new l.PrivyClientError("Must initialize SIWE/SIWS flow first.");if(null!==await i.getAccessToken())try{({user:t}=await i.link()),ye.current=e}catch(t){throw k.emitPrivyEvent(de,"linkAccount","onError",t.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{({user:t,isNewUser:r}=await i.authenticate()),ye.current=e}catch(e){throw k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.GENERIC_CONNECT_WALLET_ERROR),e}b(t||_||null),O(r||!1),pe(!0)},delegateWallet:async({address:e,chainType:t,showDelegationUIs:r})=>new Promise((async(n,i)=>{let s=await it();if(!ue||!_||!s)throw new l.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if("solana"!==t&&"ethereum"!==t)throw new l.PrivyClientError("Only Solana and Ethereum embedded wallets are supported for delegation and revocation.");let o=et.walletProxy??await et.initializeWalletProxy(15e3);if(!o)throw new l.PrivyClientError("Wallet proxy not initialized.");if((({address:e,user:t})=>!!Bt(t).find((t=>t.address===e)))({address:e,user:_}))return n();let c=a.getPrivyWalletWithAddress(_,e);if(!c)throw new l.PrivyClientError("Address to delegate is not associated with current user.");if(a.getIsUnifiedWallet(c))throw new l.PrivyClientError("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let d=Ht({address:e,user:_}),u=Vt({address:e,user:_}),h=async()=>{await o.createDelegatedAction({accessToken:s,rootWallet:u,delegatedWallets:[d]}),await et.refreshSessionAndUser()};if(await et.recoverEmbeddedWallet({address:e}),r)ne({delegatedActions:{consent:{address:e,onDelegate:h,onSuccess:async()=>{n()},onError:async e=>{i(e)}}}}),Ee("DelegatedActionsConsentScreen");else try{await h(),n()}catch(e){i(e)}})),revokeDelegatedWallets:async({showDelegationUIs:e})=>new Promise((async(t,r)=>{if(!ue||!_)throw new l.PrivyClientError("User must be authenticated and have an embedded wallet to revoke a delegated wallet.");let n=Bt(_);if(0===n.length)throw new l.PrivyClientError("User has no delegated wallets to revoke.");if(n.some(a.getIsUnifiedWallet))throw new l.PrivyClientError("useDelegatedActions is only supported for on-device execution and this app uses TEE execution. Use the useSessionSigners hook to provision server side access on behalf of your users. Learn more at https://docs.privy.io/recipes/tee-wallet-migration-guide");let s=async()=>{await i.revokeDelegatedWallet(),await et.refreshSessionAndUser()};if(e)ne({delegatedActions:{revoke:{onRevoke:s,onSuccess:async()=>{t()},onError:async e=>{r(e)}}}}),Ee("DelegatedActionsRevokeScreen");else try{await s(),t()}catch(e){r(e)}})),initLoginWithFarcaster:async(e,t)=>{let r=new Ye(e,t);i.startAuthFlow(r);try{ye.current="farcaster",await r.initializeFarcasterConnect()}catch(e){throw"login"===we.current?k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===we.current&&k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"farcaster"}),e}},loginWithFarcaster:async()=>{let e,t;if(!P)throw new l.PrivyNotReadyError;if(!(i.authFlow instanceof Ye))throw new l.PrivyClientError("Must initialize Farcaster flow first.");if(null!==await i.getAccessToken())try{({user:e}=await i.link()),ye.current="farcaster"}catch(e){throw k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"farcaster"}),e}else try{({user:e,isNewUser:t}=await i.authenticate()),ye.current="farcaster"}catch(e){throw k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}b(e||null),O(t||!1),pe(!0)},async crossAppAuthFlow({appId:e,popup:t,action:r,disableSignup:n}){let a=`privy:${e}`;ye.current=a;let{url:s,stateCode:o,codeVerifier:c}=await async function({api:e,appId:t}){let r=ke(),n=_e(),i=await Se(r);try{let{url:a}=await e.post(g.oAuthInitPath,{provider:`privy:${t}`,redirect_to:window.location.href,code_challenge:i,state_code:n});return{url:a,stateCode:n,codeVerifier:r}}catch(e){throw l.formatApiError(e)}}({api:i.api,appId:e});if(!s)throw i.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:"Unable to open cross-app auth popup",appId:e}}),new l.PrivyClientError("No authorization URL returned for cross-app auth.");try{let d=await async function({url:e,popup:t}){return t.location=e,new Promise(((e,r)=>{let n,i=setTimeout((()=>{r(new l.PrivyClientError("Authorization request timed out after 2 minutes.")),a()}),12e4);function a(){t?.close(),window.removeEventListener("message",o)}let s=setInterval((()=>{t?.closed&&!n&&(a(),clearInterval(s),clearTimeout(i),r(new l.PrivyClientError("User rejected request")))}),300);function o(t){t.data&&("PRIVY_OAUTH_RESPONSE"===t.data.type&&t.data.stateCode&&t.data.authorizationCode&&(clearTimeout(i),e(t.data),a()),"PRIVY_OAUTH_ERROR"===t.data.type&&(clearTimeout(i),r(new l.PrivyClientError(t.data.error)),a()),t.data.type===Gt&&((n=new BroadcastChannel(Yt)).onmessage=o))}window.addEventListener("message",o)}))}({url:s,popup:t,provider:a}),u=d.stateCode,h=d.authorizationCode;if(u!==o)throw i.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:a,storedStateCode:o??"",returnedStateCode:u??""}}),new l.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,l.PrivyErrorCode.OAUTH_UNEXPECTED);let p=await async function({appId:e,stateCode:t,codeVerifier:r,authorizationCode:n,action:i,client:a,disableSignup:s}){if(!n||!t)throw new l.PrivyClientError("[Cross-App AuthFlow] Authorization and state codes code must be set prior to calling authenicate.");if("undefined"===n)throw new l.PrivyClientError("User denied confirmation during cross-app auth flow");try{let o=new $t({authorizationCode:n,stateCode:t,codeVerifier:r,provider:`privy:${e}`,disableSignup:!!s});a.startAuthFlow(o);let l="link"===i?await a.link():await a.authenticate(),c=l.oAuthTokens?.accessToken;return console.debug(),c}catch(e){let t=l.formatApiError(e);if(t.privyErrorCode===l.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED)throw t;if(t.privyErrorCode)throw new l.PrivyClientError(t.message||"Invalid code during cross-app auth flow.",void 0,t.privyErrorCode);if("User denied confirmation during cross-app auth flow"===t.message)throw new l.PrivyClientError("Invalid code during cross-app auth flow.",void 0,l.PrivyErrorCode.OAUTH_USER_DENIED);throw new l.PrivyClientError("Invalid code during cross-app auth flow.",void 0,l.PrivyErrorCode.UNKNOWN_AUTH_ERROR)}}({appId:e,codeVerifier:c,stateCode:u,authorizationCode:h,action:r,client:i,disableSignup:n});p&&i.storeProviderAccessToken(e,p);let y=await et.refreshSessionAndUser();if(!y)throw new l.PrivyClientError("Unable to update user");return i.createAnalyticsEvent({eventName:"cross_app_auth_completed",payload:{providerAppId:e}}),y}catch(e){throw i.createAnalyticsEvent({eventName:"cross_app_auth_error",payload:{error:e.toString(),provider:a}}),e}},async initLoginWithOAuth(e,t,r){if(ye.current=e,!c.e())return void Ee("InAppBrowserLoginNotPossible");if("google"===e&&!h.allowOAuthInEmbeddedBrowsers&&ar(window.navigator.userAgent))return void Ee("InAppBrowserLoginNotPossible");"twitter"===e&&window.opener&&window.opener.postMessage({type:Gt},"*"),c.s.del(y.HEADLESS_OAUTH_KEY),c.s.del(y.OAUTH_DISABLE_SIGNUP_KEY);let n=new be({provider:e,disableSignup:!!r,withPrivyUi:!0,customOAuthRedirectUrl:h.customOAuthRedirectUrl});t&&n.addCaptchaToken(t),i.startAuthFlow(n);let a=await i.authFlow.getAuthorizationUrl();if(a&&a.url)if("twitter"===e&&u.isAndroid&&(a.url=a.url.replace("x.com","twitter.com")),"chrome-extension:"===window.location.protocol&&Pe())try{let{privyOAuthCode:e,privyOAuthState:t}=await Te(a.url);Ee("OAuthStatusScreen"),n.meta.stateCode=t,n.meta.authorizationCode=e}catch(e){throw console.error("OAuth in chrome extension flow failed:",e),e}else window.location.assign(a.url)},async initLoginWithTelegram(e,t){if(!P)throw new l.PrivyNotReadyError;ye.current="telegram";let r=new tt(e,t);i.startAuthFlow(r),X({status:"loading"}),r.meta.telegramWebAppData=void 0,r.meta.telegramAuthResult=await new Promise(((e,t)=>h.loginConfig.telegramAuthConfiguration?window.Telegram?void window.Telegram.Login.auth({bot_id:h.loginConfig.telegramAuthConfiguration.botId,request_access:!0},(r=>r?e(r):("link"===we.current?k.emitPrivyEvent(de,"linkAccount","onError",l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}):"login"===we.current?k.emitPrivyEvent(de,"login","onError",l.PrivyErrorCode.INVALID_CREDENTIALS):"update"===we.current&&k.emitPrivyEvent(de,"login","onError",l.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT),t(new l.PrivyClientError("Telegram auth failed or was canceled by the client"))))):t(new l.PrivyClientError("Telegram was not initialized")):t(new l.PrivyClientError("Telegram Auth configuration is not loaded"))))},async loginWithTelegram(e){let t,r;if(!(i.authFlow instanceof tt))throw new l.PrivyClientError("Must initialize Telegram flow before calling loginWithTelegram");i.authFlow.meta.captchaToken||=e?.captchaToken;let n=await it(),a=e?.intent||we.current;if("login"===a)try{let e=await i.authenticate();t=e.user,r=e.isNewUser,ye.current="telegram"}catch(e){throw k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}else{if("link"!==a)throw new l.PrivyClientError("Unknown auth intent");try{t=(await i.link()).user,ye.current="telegram"}catch(e){throw k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"telegram"}),e}}b(t),O(r||!1),pe(!0),X({status:"done"});let s=t?.linkedAccounts.find((({type:e})=>"telegram"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:s}},async loginWithOAuth(e){let t,r,n;if(!(i.authFlow instanceof be))throw new l.PrivyClientError("Must initialize OAuth flow before calling loginWithOAuth");let a=c.s.get(y.STATE_CODE_KEY),s=i.authFlow.meta.stateCode;if(a!==s)throw i.createAnalyticsEvent({eventName:"possible_phishing_attempt",payload:{provider:e,storedStateCode:a??"",returnedStateCode:s??""}}),new l.PrivyClientError("Unexpected auth flow. This may be a phishing attempt.",void 0,l.PrivyErrorCode.OAUTH_UNEXPECTED);if(null!==await i.getAccessToken())try{let r=await i.link();t=r.user,n=r.oAuthTokens,ye.current=e}catch(t){throw k.emitPrivyEvent(de,"linkAccount","onError",t.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}else try{let a=await i.authenticate();t=a.user,r=a.isNewUser,n=a.oAuthTokens,ye.current=e}catch(t){throw"login"===we.current?k.emitPrivyEvent(de,"login","onError",t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===we.current&&k.emitPrivyEvent(de,"linkAccount","onError",t.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:e}),t}return b(t),O(r||!1),pe(!0),n&&t&&k.emitPrivyEvent(de,"oAuthAuthorization","onOAuthTokenGrant",{oAuthTokens:n,user:t}),n},passkeyAuthState:q,setPasskeyAuthState:K,async initSignupWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new Ge({captchaToken:e,setPasskeyAuthState:K,hints:h.passkeys.registration?.hints});i.startAuthFlow(r),we.current="login";try{ye.current="passkey",K({status:"generating-challenge"}),await r.initRegisterFlow(t),K({status:"awaiting-passkey"})}catch(e){throw K({status:"error",error:e}),k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async signupWithPasskey(){let e,t;if(!P)throw new l.PrivyNotReadyError;if(!(i.authFlow instanceof Ge))throw new l.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==ye.current){let e=new l.PrivyClientError("Must init login with Passkey flow first.");throw K({status:"error",error:e}),e}let r=await it();try{ye.current="passkey",K({status:"awaiting-passkey"}),({user:e,isNewUser:t}=await i.authenticate())}catch(e){throw K({status:"error",error:e}),k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}b(e),O(t||!1),pe(!0),K({status:"done"});let n=e?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:e,isNewUser:t||!1,wasAlreadyAuthenticated:!!r,loginAccount:n}},async initLoginWithPasskey({captchaToken:e,withPrivyUi:t}){let r=new Ge({captchaToken:e,setPasskeyAuthState:K,hints:void 0});i.startAuthFlow(r),we.current="login";try{ye.current="passkey",K({status:"generating-challenge"}),await r.initAuthenticationFlow(t),K({status:"awaiting-passkey"})}catch(e){throw K({status:"error",error:e}),k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}},async loginWithPasskey(e){let t,r;if(!P)throw new l.PrivyNotReadyError;if(!(i.authFlow instanceof Ge))throw new l.PrivyClientError("Must initialize Passkey flow first.");if(e?.credentialIds&&(i.authFlow.meta.allowedCredentialsIds=e.credentialIds),"passkey"!==ye.current){let e=new l.PrivyClientError("Must init login with Passkey flow first.");throw K({status:"error",error:e}),e}let n=await it();try{ye.current="passkey",K({status:"awaiting-passkey"}),({user:t,isNewUser:r}=await i.authenticate())}catch(e){throw K({status:"error",error:e}),k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}b(t),O(r||!1),pe(!0),K({status:"done"});let a=t?.linkedAccounts.find((({type:e})=>"passkey"===e))||null;return{user:t,isNewUser:r||!1,wasAlreadyAuthenticated:!!n,loginAccount:a}},async initLinkWithPasskey(e){let t=new Ge({captchaToken:e,hints:h.passkeys.registration?.hints});i.startAuthFlow(t),we.current="link",ye.current="passkey",K({status:"generating-challenge"});try{await t.initLinkFlow(),K({status:"awaiting-passkey"})}catch(e){throw k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),K({status:"error",error:e}),e}},async linkWithPasskey(){let e;if(!P)throw new l.PrivyNotReadyError;if(!(i.authFlow instanceof Ge))throw new l.PrivyClientError("Must initialize Passkey flow first.");if("passkey"!==ye.current)throw new l.PrivyClientError("Must init login with Passkey flow first.");try{ye.current="passkey",({user:e}=await i.link())}catch(e){throw k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"passkey"}),e}return b(e||_||null),K({status:"done"}),e},async initLoginWithHeadlessOAuth(e,t,r){if(!c.e())throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");if("google"===e&&!h.allowOAuthInEmbeddedBrowsers&&ar(window.navigator.userAgent))throw Error("It looks like you're using an in-app browser. To log in, please try again using an external browser.");let n=new be({provider:e,withPrivyUi:!1,disableSignup:r??!1,customOAuthRedirectUrl:h.customOAuthRedirectUrl});t&&n.addCaptchaToken(t),J({status:"loading"});let a=await i.startAuthFlow(n).getAuthorizationUrl();if(a?.url)if("chrome-extension:"===window.location.protocol&&Pe())try{let{privyOAuthCode:e,privyOAuthState:t}=await Te(a.url);n.meta.stateCode=t,n.meta.authorizationCode=e,await Ze(n.meta)}catch(e){throw J({status:"error",error:e}),e}else window.location.assign(a.url)},loginWithHeadlessOAuth:Ze,initLoginWithEmail:async({email:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{let a=new ge({email:e,captchaToken:t,disableSignup:r});i.startAuthFlow(a);try{ye.current="email",H({status:"sending-code"});let e=await a.sendCodeEmail({withPrivyUi:n});if(e?.ssoRedirectUrl)return window.location.href=e.ssoRedirectUrl,void await o.sleep(1e4);H({status:"awaiting-code-input"})}catch(e){throw H({status:"error",error:e}),"login"===we.current?k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===we.current&&k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"email"}),e}},initUpdateEmail:async({oldAddress:e,newAddress:t,captchaToken:r})=>{let n=new ve(e,t,r);i.startAuthFlow(n);try{await n.sendCodeEmail({withPrivyUi:!0})}catch(e){throw k.emitPrivyEvent(de,"update","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:ye.current}),e}},initUpdatePhone:async(e,t,r)=>{let n=new Ne(e,t,r);i.startAuthFlow(n);try{await n.sendSmsCode({withPrivyUi:!0})}catch(e){k.emitPrivyEvent(de,"update","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:ye.current})}},initLoginWithSms:async({phoneNumber:e,captchaToken:t,disableSignup:r,withPrivyUi:n})=>{B({status:"sending-code"});let a=new Oe({phoneNumber:e,captchaToken:t,disableSignup:r});i.startAuthFlow(a);try{ye.current="sms",await a.sendSmsCode({withPrivyUi:n}),B({status:"awaiting-code-input"})}catch(e){throw B({status:"error",error:e}),"login"===we.current?k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR):"link"===we.current&&k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"sms"}),e}},resendEmailCode:async()=>{await(i.authFlow?.sendCodeEmail({withPrivyUi:!0}))},resendSmsCode:async()=>{await(i.authFlow?.sendSmsCode({withPrivyUi:!0}))},loginWithCode:async e=>{let t,r;function n(e){i.authFlow instanceof ge?H(e):i.authFlow instanceof Oe&&B(e)}if(n({status:"submitting-code"}),!P){let e=new l.PrivyNotReadyError;throw n({status:"error",error:e}),e}if(i.authFlow instanceof ge)i.authFlow.meta.emailCode=e.trim();else{if(!(i.authFlow instanceof Oe)){let e=new l.PrivyClientError("Must initialize a passwordless code flow first");throw n({status:"error",error:e}),e}i.authFlow.meta.smsCode=e.trim()}let a=await it();if("link"===we.current)try{({user:t}=await i.link())}catch(e){throw n({status:"error",error:e}),k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:ye.current}),e}else if("update"===we.current)try{({user:t}=await i.link())}catch(e){throw n({status:"error",error:e}),k.emitPrivyEvent(de,"update","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_UPDATE_ACCOUNT,{linkMethod:ye.current}),e}else try{({user:t,isNewUser:r}=await i.authenticate())}catch(e){throw n({status:"error",error:e}),k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}let s=t||_;b(s||null),O(r||!1),pe(!0),n({status:"done"});let o=null;return i.authFlow instanceof ge?o=s?.linkedAccounts.find((({type:e})=>"email"===e))||null:i.authFlow instanceof Oe&&(o=s?.linkedAccounts.find((({type:e})=>"phone"===e))||null),{user:s,isNewUser:r||!1,wasAlreadyAuthenticated:!!a,linkedAccount:o}},generateSiweMessage:async({address:e,chainId:t,captchaToken:r})=>{we.current=ue?"link":"login",ye.current="siwe",G({status:"generating-message"});let n=await i.generateSiweNonce({address:e,captchaToken:r});return G({status:"awaiting-signature"}),xe({address:e,chainId:t.replace("eip155:",""),nonce:n})},generateSiweMessageForSmartWallet:async({address:e,chainId:t})=>{let r=await i.generateSiweNonce({address:e});return xe({address:e,chainId:t.replace("eip155:",""),nonce:r})},linkSmartWallet:async({message:e,signature:t,smartWalletType:r,smartWalletVersion:n})=>{let a;a=await i.linkSmartWallet({message:e,signature:t,smartWalletType:r,smartWalletVersion:n}),b((a=await et.refreshSessionAndUser()??a)||_||null)},loginWithSiwe:async({message:e,signature:t,captchaToken:r,disableSignup:n,walletClientType:a,connectorType:s})=>{let o,c=null;try{if(_)throw Error("User already authenticated");let l=new Re(i,void 0,r,n,{message:e,signature:t,walletClientType:a,connectorType:s});i.startAuthFlow(l),ye.current="siwe",we.current="login",G({status:"submitting-signature"});let d=await i.authenticate();if(({user:c,isNewUser:o}=d),!c)throw Error("Authentication failed - no user returned")}catch(e){throw k.emitPrivyEvent(de,"login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),G({status:"error",error:e}),e}return b(c),O(o||!1),pe(!0),G({status:"done"}),we.current=null,ye.current=null,{user:c,isNewUser:o||!1}},linkWithSiwe:async({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a})=>{let s;De("siwe");let o=null;try{G({status:"submitting-signature"}),s=await i.linkWithSiwe({message:e,signature:t,chainId:r,walletClientType:n,connectorType:a}),s=await et.refreshSessionAndUser()??s,G({status:"done"}),(o=He(s)||null)&&k.emitPrivyEvent(de,"linkAccount","onSuccess",{user:s,linkMethod:"siwe",linkedAccount:o})}catch(e){throw k.emitPrivyEvent(de,"linkAccount","onError",e.privyErrorCode||l.PrivyErrorCode.FAILED_TO_LINK_ACCOUNT,{linkMethod:"siwe"}),we.current=null,ye.current=null,G({status:"error",error:e}),e}let c=s||_;return b(c||null),we.current=null,ye.current=null,{user:c,linkedAccount:o}},refreshSessionAndUser:async()=>{let e=await i.getAuthenticatedUser();return pe(!!e),b(e),e},walletProxy:Z,createAnalyticsEvent:({eventName:e,payload:t,timestamp:r})=>i.createAnalyticsEvent({eventName:e,payload:t,timestamp:r}),acceptTerms:async()=>{let e=await i.acceptTerms();return b(e),e},getUsdTokenPrice:e=>i.getUsdTokenPrice(e),getUsdPriceForSol:()=>i.getUsdPriceForSol(),getSplTokenMetadata:e=>i.getSplTokenMetadata(e),recoverEmbeddedWallet:async e=>new Promise((async(t,r)=>{if(!_)return void t(!0);let n=e?.address?a.getPrivyWalletWithAddress(_,e.address):a.getPrivyPrimaryWallet(_)||a.getImportedPrivyEthereumWallets(_).at(0)||a.getImportedPrivySolanaWallets(_).at(0);if(!n||a.getIsUnifiedWallet(n))return void t(!0);let s=await it();if(!s||!Z||!n)return void r(Error("Must have valid access token and Privy wallet to recover wallet"));let{entropyId:o,entropyIdVerifier:l}=S.getEntropyDetailsForUser(_,n);try{await Z.connect({accessToken:s,entropyId:o,entropyIdVerifier:l}),t(!0)}catch(e){if(Ot(e)&&"privy"===n.recoveryMethod){let e;i.createAnalyticsEvent({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:n.address}});try{e=await Z.recover({entropyId:o,entropyIdVerifier:l,accessToken:s})}catch(e){return void r(e)}e.entropyId||r(Error("Unable to recover wallet")),i.createAnalyticsEvent({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:n.address}}),t(!0)}else Ot(e)&&"privy"!==n.recoveryMethod&&"privy-v2"!==n.recoveryMethod?(ne({recoverWallet:{entropyId:o,entropyIdVerifier:l,onFailure:r,onSuccess:()=>t(!0)},recoveryOAuthStatus:{provider:n.recoveryMethod,action:"recover",shouldCreateEth:!1,shouldCreateSol:!1}}),Ee(rr(n.recoveryMethod))):r(e)}})),setReadyToTrue:e=>{T(!0),ie?.(e)},updateWallets:()=>qe(),fundWallet:async(e,t)=>{let r="FundingMethodSelectionScreen";return new Promise(((n,i)=>{ne({funding:{...c.prepareFundingModalData({address:e,appConfig:h,fundWalletConfig:t,methodScreen:r,onComplete:n,onError:i})}}),Ee(r)}))},openModal:Ee,requestFarcasterSignerStatus:async e=>{let t=await it(),r=_?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType));if(!t)throw Error("Must have valid access token to connect with Farcaster");if(!Z||!r)throw Error("Must have an embedded wallet to use Farcaster signers");if(!_?.farcaster?.fid)throw Error("Must have Farcaster account to use Farcaster signers");let n=await i.requestFarcasterSignerStatus(e);return"approved"===n.status&&b(await i.getAuthenticatedUser()||_||null),n},connectCoinbaseSmartWallet:async()=>{h.externalWallets.coinbaseWallet.config.preference={...h.externalWallets.coinbaseWallet.config.preference,options:"smartWalletOnly"};let e=i.connectors?.findWalletConnector("coinbase_wallet","coinbase_smart_wallet")||i.connectors?.findWalletConnector("coinbase_wallet","coinbase_wallet");if(e)return e.updateConnectionPreference("smartWalletOnly"),Ue(e);await We("coinbase_wallet","coinbase_smart_wallet")},connectBaseAccount:async()=>{let e=i.connectors?.findWalletConnector("base_account","base_account");if(e)return Ue(e);await We("base_account","base_account")},initiateAccountTransfer:async({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:s,farcasterEmbeddedAddress:o,oAuthUserInfo:l})=>{let c=await i.sendAccountTransferRequest({nonce:e,account:t,accountType:r,externalWalletMetadata:n,telegramAuthResult:a,telegramWebAppData:s,farcasterEmbeddedAddress:o,oAuthUserInfo:l});return b(c),c},inProgressAuthFlowRef:we,inProgressLoginOrLinkMethodRef:ye};Rr=et.recoverEmbeddedWallet,et.recoverEmbeddedWallet;let at=i.authFlow instanceof tt,{siteKey:st,enabledProvider:ct}=h.captcha,ht=!h.headless&&ct&&!ue&&(P||at);/*#__PURE__*/return e.jsx(br.Provider,{value:!0,children:/*#__PURE__*/e.jsx(a.PrivyContext.Provider,{value:Qe,children:/*#__PURE__*/e.jsx(k.PrivyEventsContext.Provider,{value:de,children:/*#__PURE__*/e.jsx(Xe,{appId:h.id,captchaSiteKey:st,enabledCaptchaProvider:ct,children:/*#__PURE__*/e.jsxs(l.InternalPrivyContext.Provider,{value:et,children:[/*#__PURE__*/e.jsx(o.RecentlyUsedAccountProvider,{children:/*#__PURE__*/e.jsxs(a.ModalProvider,{data:re,setModalData:ne,setInitialScreen:M,initialScreen:N,authenticated:ue,open:w,children:[n.children,/*#__PURE__*/e.jsx(Cr,{customAuth:h.customAuth}),ht&&/*#__PURE__*/e.jsx(ot,{delayedExecution:!1}),/*#__PURE__*/e.jsx(Wt,{}),/*#__PURE__*/e.jsx(Sr,{}),/*#__PURE__*/e.jsx(ur,{disabled:h.embeddedWallets.disableAutomaticMigration}),/*#__PURE__*/e.jsx(ut,{palette:h.appearance.palette||{}}),!h.render.standalone&&/*#__PURE__*/e.jsx(kt,{open:w})]})}),/*#__PURE__*/e.jsx(zt,{appId:n.appId,appClientId:n.clientId,clientAnalyticsId:i.clientAnalyticsId,origin:i.apiUrl,mfaMethods:_?.mfaMethods,mfaPromise:oe,mfaSubmitPromise:le,onLoad:ee,onLoadFailed:()=>null}),h.loginConfig.telegramAuthConfiguration&&
|
|
174
|
+
/*#__PURE__*/e.jsx(o.Hide,{$if:!0,children:/*#__PURE__*/e.jsx(It,{scriptHost:n.apiUrl||y.DEFAULT_PRIVY_API_URL,botUsername:h.loginConfig.telegramAuthConfiguration.botName})})]})})})})})},Nr=(e,t)=>Ir(e,t),Mr=(e,t)=>Wr(e,t),Fr=(e,t)=>Ur(e,t),Lr=(e,t)=>xr(e,t),Dr=e=>Rr(e);const jr=()=>{let{setModalData:e}=a.usePrivyModal(),{openModal:r,privy:n,closePrivyModal:i}=l.usePrivyInternal(),{user:s}=a.usePrivyContext();return t.useMemo((()=>({verify:async({standalone:t=!0}={standalone:!0})=>new Promise(((a,o)=>s?0===s.mfaMethods.length?a():(e((e=>({...e,mfaVerify:{onSuccess:async()=>{t?await i({shouldCallAuthOnSuccess:!1,isSuccess:!0}):dt.setState({inProgressMfaFlow:void 0}),a()},onFailure:async e=>{t?await i({shouldCallAuthOnSuccess:!1,isSuccess:!1}):dt.setState({inProgressMfaFlow:void 0}),o(e)},sendSmsCode:async()=>{throw Error("Not enabled")},verifySmsCode:async()=>{throw Error("Not enabled")},verifyTotpCode:async e=>{await n.fetchPrivyRoute(O.MfaAuthTotpVerify,{body:{code:e}})},generateOptions:async()=>ye((await n.fetchPrivyRoute(O.MfaAuthPasskeyInit,{body:{}})).options),verifyPasskey:async e=>{let t=await import("@simplewebauthn/browser"),r=await t.startAuthentication({optionsJSON:e});await n.fetchPrivyRoute(O.MfaAuthPasskeyVerify,{body:{authenticator_response:hr(r)}})}}}))),void(t?r("MfaAuthVerifyFlowScreen"):dt.setState({inProgressMfaFlow:"auth"}))):o(Error("Must be logged in to verify MFA"))))})),[n,e,r,i])};const qr=async({wallet:e})=>{let t=await e.getEthereumProvider();return F.toAccount({address:e.address,sign:async({hash:n})=>{if("privy"!==e.walletClientType)throw new r.PrivyClientError({error:"Unprefixed signing is not supported by external wallets.",code:"unsupported_wallet_type"});return await t.request({method:"secp256k1_sign",params:[n]})},signMessage:async({message:r})=>await t.request({method:"personal_sign",params:[r,e.address]}),signTypedData:async r=>await t.request({method:"eth_signTypedData_v4",params:[e.address,r]}),signTransaction:async e=>await t.request({method:"eth_signTransaction",params:[e]})})};let Kr=async(e,t,r,n,i)=>{if(!e)throw n("linkAccount","onError",l.PrivyErrorCode.MUST_BE_AUTHENTICATED,{linkMethod:i}),new l.PrivyClientError("User must be authenticated before linking an account.");if(!t?.linkedAccounts.some((e=>e.type.includes(i))))throw new l.PrivyClientError(`OAuth account of type ${i} not linked to the account.`);await r(i)};const zr=()=>{let{user:e}=a.usePrivyContext(),t=l.usePrivyInternal(),{signWithUserSigner:n}=L.useSignWithUserSigner(),i=async({wallet:i,additional_signers:a})=>{let s=await t.client.getAccessToken();if(!e||!s)throw new l.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if(!i.id)throw new l.PrivyClientError("Wallet to add signers to must have ID on server");if(!t.walletProxy)throw new l.PrivyClientError("Wallet proxy not initialized.");await r.updateWallet(t.privy,{wallet_id:i.id},n,{additional_signers:a})};return{addSessionSignersInternal:async({address:n,signers:s})=>{let c=await t.client.getAccessToken();if(!e||!c)throw new l.PrivyClientError("User must be authenticated and have an embedded wallet to add a session signer.");let d=t.walletProxy??await t.initializeWalletProxy(15e3);if(!d)throw new l.PrivyClientError("Wallet proxy not initialized.");let u=a.getPrivyWalletWithAddress(e,n);if(!u)throw new l.PrivyClientError("Address to add signers too is not associated with current user.");if(a.getIsUnifiedWallet(u)){if(0===s.length)throw new l.PrivyClientError("Must specify at least one signer to add.");let e=[...(await r.getWallet(t.privy,{wallet_id:u.id})).additional_signers,...o.parseAdditionalSigners(s)];await i({wallet:u,additional_signers:e})}else{if(u.delegated)return{user:e};if(s.length>0)throw new l.PrivyClientError("Specifying signers in addSessionSigners is only supported for TEE execution and this app uses On-device execution. Pass an empty array for signers instead. Learn more https://docs.privy.io/recipes/tee-wallet-migration-guide");let r=Ht({address:n,user:e}),i=Vt({address:n,user:e});await t.recoverEmbeddedWallet({address:n}),await d.createDelegatedAction({accessToken:c,rootWallet:i,delegatedWallets:[r]})}let h=await t.refreshSessionAndUser();if(!h)throw Error("Could not refresh user");return{user:h}},removeSessionSignersInternal:async({address:r})=>{let n=await t.client.getAccessToken();if(!e||!n)throw new l.PrivyClientError("User must be authenticated and have an embedded wallet to delegate actions.");if(!(t.walletProxy??await t.initializeWalletProxy(15e3)))throw new l.PrivyClientError("Wallet proxy not initialized.");let s=a.getPrivyWalletWithAddress(e,r);if(!s)throw new l.PrivyClientError("Address to remove signers from is not associated with current user.");a.getIsUnifiedWallet(s)?await i({wallet:s,additional_signers:[]}):await t.client.revokeDelegatedWallet();let o=await t.refreshSessionAndUser();if(!o)throw Error("Could not refresh user");return{user:o}}}};const Hr=kt;exports.BASE_ACCOUNT_DATA_URI=$,exports.Blobby=kr,exports.BrowserExtensionWallet=te,exports.COINBASE_WALLET_DATA_URI=G,exports.Captcha=ot,exports.CaptchaError=Qe,exports.CoinbaseWallet=({style:t,...r})=>/*#__PURE__*/e.jsxs("svg",{viewBox:"0 0 1024 1024",fill:"none",xmlns:"http://www.w3.org/2000/svg",style:{height:"28px",width:"28px",...t},...r,children:[/*#__PURE__*/e.jsx("rect",{width:"1024",height:"1024",fill:"#0052FF",rx:100,ry:100}),/*#__PURE__*/e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M152 512C152 710.823 313.177 872 512 872C710.823 872 872 710.823 872 512C872 313.177 710.823 152 512 152C313.177 152 152 313.177 152 512ZM420 396C406.745 396 396 406.745 396 420V604C396 617.255 406.745 628 420 628H604C617.255 628 628 617.255 628 604V420C628 406.745 617.255 396 604 396H420Z",fill:"white"})]}),exports.ConnectorManager=de,exports.LoginModal=Hr,exports.Phantom=re,exports.PrivyClient=He,exports.PrivyIframeError=xt,exports.PrivyModal=kt,exports.PrivyProvider=({config:r,...n})=>{(()=>{if(t.useContext(br))throw new l.PrivyClientError("Multiple PrivyProvider instances found","Found multiple instances of PrivyProvider, ensure there is only one mounted in your application tree.")})(),function(){if("undefined"==typeof window)return;let e=["localhost","127.0.0.1"].includes(window.location.hostname),t="https:"===window.location.protocol||"chrome-extension:"===window.location.protocol;if(!e&&!t)throw new l.PrivyClientError("Embedded wallet is only available over HTTPS")}(),function(e){if("string"!=typeof e||25!==e.length)throw new l.PrivyClientError("Cannot initialize the Privy provider with an invalid Privy app ID")}(n.appId),function(e){qe||(qe=new He({appId:e.appId,appClientId:e.clientId,apiUrl:e.apiUrl}))}(n);let i=t.useMemo((()=>new K.default({appId:n.appId,clientId:n.clientId,storage:c.s,baseUrl:n.apiUrl,sdkVersion:"react-auth:3.13.1-beta-20260202140759"})),[]),a=Be(),s=Object.assign({},r);/*#__PURE__*/return e.jsx(y.PrivyAppConfigProvider,{client:i,legacyClient:a,appClientId:n.clientId,clientConfig:s,children:/*#__PURE__*/e.jsx(f.PrivyPluginProvider,{configPlugins:r?.plugins,children:/*#__PURE__*/e.jsx(Or,{...n,client:a,privy:i})})})},exports.RunEffectOnce=Ue,exports.SiweFlow=Re,exports.SiwsFlow=$e,exports.WalletConnectV2WalletConnector=ce,exports.addFundingResultToModalData=function(e,t,r,n,i,a,s){return{...e,funding:e?.funding?{...e.funding,fundingResult:{status:t,address:e.funding.address,fundingMethod:void 0,transactionHash:r,amount:e.funding.amount,assetType:i?a?.symbol||"ETH":s.nativeCurrency.symbol||"ETH",metadata:{walletClientType:n}}}:void 0,solanaFundingData:e?.solanaFundingData,sendTransaction:e?.sendTransaction}},exports.createCodeVerifier=ke,exports.createStateCode=_e,exports.deriveCodeChallengeFromCodeVerifier=Se,exports.e=ar,exports.embeddedWalletRecoveryScreen=rr,exports.embeddedWalletSetPasswordScreen=er,exports.errorIndicatesInvalidRecoveryPassword=function(e){return Rt(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)},exports.errorIndicatesMaxMfaRetries=function(e){return!!Rt(e)&&"mfa_verification_max_attempts_reached"===e.type},exports.errorIndicatesMfaCanceled=function(e){return!!function(e){let t=e.type;return"string"==typeof t&&"client_error"===t}(e)&&"MFA canceled"===e.message},exports.errorIndicatesMfaRateLimit=function(e){return!(!Rt(e)||!e.message.includes("code 429"))},exports.errorIndicatesMfaTimeout=function(e){return!!Rt(e)&&"mfa_timeout"===e.type},exports.errorIndicatesMfaVerificationFailed=function(e){return!!Rt(e)&&"missing_or_invalid_mfa"===e.type},exports.errorIndicatesRecoveryIsNeeded=Ot,exports.fetchWalletBalance=sr,exports.getCustomerAccessToken=function(){let e=Be();return e?e.getCustomerAccessToken():Promise.resolve(c.s.get(y.CUSTOMER_ACCESS_TOKEN_STORAGE_KEY)||null)},exports.getIdentityToken=async function(){return await(qe?.updateUserAndIdToken()),qe?.useServerCookies?ue.getState().identityToken:Promise.resolve(c.s.get(y.IDENTITY_TOKEN_STORAGE_KEY)||null)},exports.getTelegramAuthErrorMessage=function(e){let t={detail:"",retryable:!1};return e?.privyErrorCode===l.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(t.detail="This account has already been linked to another user."),e?.privyErrorCode===l.PrivyErrorCode.DISALLOWED_LOGIN_METHOD&&(t.detail="Login with Telegram not allowed."),e?.privyErrorCode===l.PrivyErrorCode.INVALID_DATA&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===l.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===l.PrivyErrorCode.INVALID_CREDENTIALS&&(t.retryable=!0,t.detail="Something went wrong. Try again."),e?.privyErrorCode===l.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===l.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("rate limit")&&(t.detail="Request limit reached for Telegram. Please wait a moment and try again."),e instanceof Qe&&(t.retryable=!0,t.detail="Something went wrong. Try again."),t},exports.prepareTransactionRequest=cr,exports.shouldCreateEmbeddedEthWallet=yr,exports.shouldCreateEmbeddedSolWallet=mr,exports.stripUrlOAuthParamsAndRemoveStateCode=We,exports.toDisplayFromAccountType=lr,exports.toEmbeddedWalletSetRecoveryScreen=tr,exports.toViemAccount=qr,exports.useAuthMfa=jr,exports.useAuthMfaEnrollment=()=>{let e=y.useAppConfig(),{setModalData:r}=a.usePrivyModal(),{verify:n}=jr(),{openModal:i,privy:s,closePrivyModal:o,refreshSessionAndUser:c,setUser:d}=l.usePrivyInternal();return t.useMemo((()=>({enroll:async t=>new Promise(((a,l)=>{r({mfaEnroll:{onSuccess:async e=>{await o({shouldCallAuthOnSuccess:!1,isSuccess:!0}),a(e)},onFailure:async e=>{await o({shouldCallAuthOnSuccess:!1,isSuccess:!1}),l(e)},onBack:t?.onBack?async()=>{await o({shouldCallAuthOnSuccess:!1,isSuccess:!1}),l(Error("User canceled MFA enrollment flow.")),t.onBack?.()}:void 0,verify:()=>n({standalone:!1}),shouldUnlinkOnUnenrollMfa:!0,mfaMethods:e.mfa.methods,sendSmsCode:async()=>{throw Error("Not enabled")},enrollSms:async()=>{throw Error("Not enabled")},unenrollSms:async()=>{throw Error("Not enabled")},generateTotpSecret:async()=>await s.fetchPrivyRoute(O.MfaAuthTotpInit,{body:{}}),enrollTotp:async e=>{await s.fetchPrivyRoute(O.MfaAuthTotpEnroll,{body:{code:e}});let t=await c();return d(t),t},unenrollTotp:async()=>{await s.fetchPrivyRoute(O.MfaAuthTotpUnenroll,{body:{}});let e=await c();return d(e),e},enrollPasskey:async e=>{await s.fetchPrivyRoute(O.MfaAuthPasskeyEnrollment,{body:{credential_ids:e,remove_for_login:!0}});let t=await c();return d(t),t}}}),i("MfaAuthEnrollmentFlowScreen")}))})),[s,r,i,o])},exports.useAuthorizationSignature=()=>{let{signWithUserSigner:e}=L.useSignWithUserSigner();return t.useMemo((()=>({async generateAuthorizationSignature(t){let{targetAppId:n,...i}=t,{signature:a}=await r.generateAuthorizationSignature((async({message:t})=>e({message:t,targetAppId:n})),i);return{signature:a}}})),[e])},exports.useBaseAccountSdk=()=>{let{baseAccountSdk:e}=l.usePrivyInternal();return{baseAccountSdk:e}},exports.useCaptcha=Ze,exports.useConnectBaseAccount=()=>{let{connectBaseAccount:e}=l.usePrivyInternal();return{connectBaseAccount:e}},exports.useConnectCoinbaseSmartWallet=()=>{let{connectCoinbaseSmartWallet:e}=l.usePrivyInternal();return{connectCoinbaseSmartWallet:e}},exports.useConnectOrCreateWallet=e=>{let{connectOrCreateWallet:t}=a.usePrivyContext();return k.usePrivyEventSubscription("connectOrCreateWallet",e),{connectOrCreateWallet:t}},exports.useCreateWalletWithoutFallback=vr,exports.useCrossAppAccounts=()=>{let{startCrossAppAuthFlow:e,unlinkCrossAppAccount:t,signMessageWithCrossAppWallet:r,signTypedDataWithCrossAppWallet:n,sendTransactionWithCrossAppWallet:i,signTransactionWithCrossAppWallet:s}=a.usePrivyContext();return{loginWithCrossAppAccount:({appId:t})=>e({appId:t,action:"login"}),linkCrossAppAccount:({appId:t})=>e({appId:t,action:"link"}),unlinkCrossAppAccount:t,signMessage:r,signTypedData:n,sendTransaction:i,signTransaction:s}},exports.useCustomAuth=e=>{let t=Er((e=>e.jwtAuthFlowState));return k.usePrivyEventSubscription("customAuth",e),{status:t}},exports.useDelegatedActions=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=l.usePrivyInternal();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!0}),revokeWallets:async()=>await e({showDelegationUIs:!0})}},exports.useFarcasterSigner=function(){let{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}=a.usePrivyContext();return{getFarcasterSignerPublicKey:e,signFarcasterMessage:t,requestFarcasterSignerFromWarpcast:r}},exports.useGetAccessTokenForProvider=()=>t.useMemo((()=>({getAccessTokenForProvider:({appId:e})=>{try{let t=c.s.get(y.getProviderAccessTokenStorageKey(e));if("string"!=typeof t)return{token:null};{let r=new B(t);return r.isExpired()?(c.s.del(y.getProviderAccessTokenStorageKey(e)),{token:null}):{token:r.value}}}catch(e){return console.error(e),{token:null}}}})),[]),exports.useGetWalletPrivateKey=function(){let{user:e}=a.usePrivyContext(),{client:r}=l.usePrivyInternal(),n=y.useAppConfig(),i=t.useCallback((async({address:t,recipientPublicKey:i})=>{if(!e)throw new l.PrivyClientError("User must be authenticated before exporting their wallet");let s=await r.getAccessToken();if(!s)throw new l.PrivyClientError("Must have valid access token");let o=a.getPrivyWalletWithAddress(e,t);if(!o)throw new l.PrivyClientError("User does not have a wallet with this address");if(!a.getIsUnifiedWallet(o))throw new l.PrivyClientError("Client export is only supported for unified stack wallets. On-device wallets are not supported.");return function(e,t,r){let n=document.createElement("iframe");return n.style.display="none",n.src=e,document.body.appendChild(n),new Promise(((e,i)=>{let a=null,s=()=>{null!==a&&(clearTimeout(a),a=null),window.removeEventListener("message",o),n.parentNode&&n.parentNode.removeChild(n)},o=t=>{var n;t.origin===r&&"object"==typeof(n=t.data)&&null!==n&&"type"in n&&("CLIENT_EXPORT_RESPONSE"===n.type||"CLIENT_EXPORT_ERROR"===n.type)&&(s(),"CLIENT_EXPORT_ERROR"===t.data.type?i(new l.PrivyClientError(t.data.error)):e({ciphertext:t.data.ciphertext,encapsulatedKey:t.data.encapsulatedKey,chainType:t.data.chainType}))};window.addEventListener("message",o),n.onload=()=>{n.contentWindow?.postMessage({type:"CLIENT_EXPORT_REQUEST",recipientPublicKey:t},r)},a=setTimeout((()=>{s(),i(new l.PrivyClientError("Wallet export timed out"))}),3e4)}))}(b.constructURL({origin:r.apiUrl,path:`/apps/${n.id}/embedded-wallets/export`,query:{v:"1-unified",wallet_id:o.id,client_id:n.appClientId,mode:"client-export"},hash:{token:s}}),i,r.apiUrl)}),[e,r,n.id,n.appClientId]);return t.useMemo((()=>({getWalletPrivateKey:i})),[i])},exports.useGuestAccounts=function(){let e=y.useAppConfig(),t=k.useEmitPrivyEvent(),{client:r,setUser:n,setAuthenticated:i,setIsNewUser:a,initializeWalletProxy:s}=l.usePrivyInternal(),{create:o}=p.useCreateWalletInternal();return{createGuestAccount:async()=>{if(!e.id||!r)throw Error("SDK not yet ready");r.startAuthFlow(new Ee(e.id));try{let c=await r.authenticate(),d=c.user,u=c.isNewUser??!1;if(!d)throw new l.PrivyClientError("Unable to authenticate guest account");let h=await r.getAccessToken(),p=await s(y.WALLET_PROXY_TIMEOUT);if(h&&p)try{let t=yr(d,e.embeddedWallets.ethereum.createOnLogin),r=mr(d,e.embeddedWallets.solana.createOnLogin);t&&r?(d=(await o({chainType:"ethereum",latestUser:d})).user,d=(await o({chainType:"solana",latestUser:d})).user):r?d=(await o({chainType:"solana",latestUser:d})).user:t?d=(await o({chainType:"ethereum",latestUser:d})).user:n(d)}catch(e){n(d),console.warn("Unable to create embedded wallet for guest account")}return a(u),i(!0),t("login","onComplete",{user:d,isNewUser:u,wasAlreadyAuthenticated:!1,loginMethod:"guest",loginAccount:null}),d}catch(e){throw t("login","onError",e.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),e}}}},exports.useHeadlessDelegatedActions=()=>{let{revokeDelegatedWallets:e,delegateWallet:t}=l.usePrivyInternal();return{delegateWallet:async({address:e,chainType:r})=>await t({address:e,chainType:r,showDelegationUIs:!1}),revokeWallets:async()=>await e({showDelegationUIs:!1})}},exports.useIdentityToken=function(){let{identityToken:e}=ue();return{identityToken:e}},exports.useLinkAccount=function(e){let{linkEmail:r,linkPhone:n,linkWallet:i,linkGoogle:s,linkApple:o,linkTwitter:l,linkTwitch:c,linkDiscord:d,linkGithub:u,linkLinkedIn:h,linkTiktok:p,linkLine:y,linkSpotify:w,linkInstagram:m,linkTelegram:g,linkFarcaster:v,linkPasskey:f}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("linkAccount",e),{linkEmail:r,linkPhone:n,linkWallet:i,linkGoogle:s,linkApple:o,linkTwitter:l,linkTwitch:c,linkDiscord:d,linkGithub:u,linkLinkedIn:h,linkTiktok:p,linkLine:y,linkSpotify:w,linkInstagram:m,linkFarcaster:v,linkTelegram:g,linkPasskey:f}},exports.useLinkJwtAccount=function(e){let{client:r}=l.usePrivyInternal(),[n,i]=t.useState({status:"initial"});return{linkWithCustomJwt:t.useCallback((async t=>{try{i({status:"initial"}),r.startAuthFlow(new we(t)),i({status:"loading"});let{user:n}=await r.link();if(!n)throw Error("Error, user not found");let a=n.linkedAccounts.filter((e=>"custom_auth"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime())).at(0);return i({status:"done"}),e?.onSuccess?.({user:n,linkMethod:"custom",linkedAccount:a}),{user:n}}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"custom"}),t}}),[r.startAuthFlow,r.link]),state:n}},exports.useLinkWithPasskey=e=>{let{initLinkWithPasskey:r,linkWithPasskey:n,passkeyAuthState:i,setPasskeyAuthState:a}=l.usePrivyInternal();return{linkWithPasskey:t.useCallback((async()=>{try{await r();let t=await n();if(!t)throw Error("Error, user not found");let i=t.linkedAccounts.filter((e=>"passkey"===e.type)).sort(((e,t)=>t.latestVerifiedAt.getTime()-e.latestVerifiedAt.getTime()))[0];e?.onSuccess?.({user:t,linkMethod:"passkey",linkedAccount:i})}catch(t){throw a({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"passkey"}),t}}),[n]),state:i}},exports.useLinkWithSiwe=e=>{let r=Ze(),{siweState:n,setSiweState:i,linkWithSiwe:a,generateSiweMessage:s}=l.usePrivyInternal();return{generateSiweMessage:t.useCallback((async({address:t,chainId:r})=>{try{if(!t||!r)throw Error("wallet address and chainId required to generate nonce");return await s({address:t,chainId:r}).then((e=>e))}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[s]),linkWithSiwe:t.useCallback((async({signature:t,message:n,chainId:s,walletClientType:o,connectorType:c})=>{try{if(r.enabled&&"success"!==r.status)throw new Qe(r.error,null,l.PrivyErrorCode.CAPTCHA_FAILURE);let{user:i,linkedAccount:d}=await a({message:n,signature:t,chainId:s,walletClientType:o,connectorType:c});d&&e?.onSuccess?.({user:i,linkMethod:"siwe",linkedAccount:d})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"siwe"}),t}}),[a,r.status]),state:n}},exports.useLinkWithSiws=()=>{let e=Ze(),{client:r,setUser:n,refreshSessionAndUser:i}=l.usePrivyInternal(),{authenticated:a}=p.usePrivy();return{generateSiwsMessage:t.useCallback((async({address:t})=>{let n=await et(e),i=await r.generateSiwsNonce({address:t,captchaToken:n});return p.prepareSiwsMessageWithNonce({address:t,nonce:i})}),[e,r]),linkWithSiws:t.useCallback((async({signature:t,message:s,walletClientType:o,connectorType:l})=>{if(!a)throw Error("User must be authenticated before linking");await et(e);let c=await r.linkWithSiws({message:s,signature:t,walletClientType:o,connectorType:l,messageType:"plain"}),d=(e=>{if(!e)return;let t=e.linkedAccounts;return t&&0!==t.length?t[t.length-1]:void 0})(c=await i()??c)||null;return n(c||null),{user:c,linkedAccount:d}}),[a,e,r,i,n])}},exports.useLoginWithEmail=e=>{let r=Ze(),{emailOtpState:n,setEmailOtpState:i,initLoginWithEmail:a,loginWithCode:s}=l.usePrivyInternal();return{sendCode:t.useCallback((async({email:t,disableSignup:n})=>{try{if(!t)throw Error("Email required to send OTP code");let e=await et(r);return await a({email:t,captchaToken:e,disableSignup:n,withPrivyUi:!1})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[a,r]),loginWithCode:t.useCallback((async({code:t})=>{try{let{user:r,isNewUser:n,wasAlreadyAuthenticated:i,linkedAccount:a}=await s(t);e?.onComplete?.({user:r,isNewUser:n,wasAlreadyAuthenticated:i,loginMethod:"email",loginAccount:a})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[s]),state:n}},exports.useLoginWithFarcasterV2=()=>{let{client:e,setAuthenticated:r,setUser:n}=l.usePrivyInternal();return t.useMemo((()=>({init:async()=>{if(!e)throw new l.PrivyClientError("Must initialize Privy client first.");let t=new R.FarcasterFramesFlow;return e.startAuthFlow(t),await t.init()},login:async({fid:t,message:i,signature:a})=>{if(!e)throw new l.PrivyClientError("Must initialize Privy client first.");if(!(e.authFlow instanceof R.FarcasterFramesFlow))throw new l.PrivyClientError("Must initialize Farcaster Mini App flow first.");e.authFlow.setAuthData({message:i,signature:a,fid:t});let{user:s}=await e.authenticate();if(!s)throw new l.PrivyClientError("Failed to login with Farcaster V2");return n(s),r(!0),{user:s}}})),[e,n,r])},exports.useLoginWithOAuth=e=>{k.usePrivyEventSubscription("login",e);let r=Ze(),n=y.useIsServerConfigLoaded(),{ready:i,user:s}=a.usePrivyContext(),{initLoginWithHeadlessOAuth:o,loginWithHeadlessOAuth:c,oAuthState:d,setOAuthState:u,isHeadlessOAuthLoading:h}=l.usePrivyInternal(),p=t.useCallback((async e=>{try{if(r.enabled&&"success"!==r.status)throw new Qe(r.error,null,l.PrivyErrorCode.CAPTCHA_FAILURE);return await o(e.provider,r.token,e.disableSignup)}catch(e){throw u({status:"error",error:e}),e}}),[o,r]),w=t.useCallback((async()=>{let e=Ie();try{if(!e.inProgress)throw Error("Cannot login with OAuth because no OAuth flow is in progress");let t=e.provider;if(a.isCustomOAuthProvider(t)){if(s&&s.linkedAccounts.some((e=>e.type===t)))return console.warn("User is already logged in with this OAuth provider"),s}else if(s&&t in s&&s[t])return console.warn("User is already logged in with this OAuth provider"),s;if(e.popupFlow)return}catch(e){throw u({status:"error",error:e}),e}try{return await c(e)}catch(e){throw u({status:"error",error:e}),e}finally{We()}}),[c]);return t.useEffect((()=>{let e=Ie();i&&n&&e.inProgress&&!e.withPrivyUi&&!e.popupFlow&&w().catch((()=>{}))}),[i,n]),{initOAuth:p,loading:h,state:d}},exports.useLoginWithPasskey=e=>{let r=Ze(),{initLoginWithPasskey:n,loginWithPasskey:i,passkeyAuthState:a,setPasskeyAuthState:s}=l.usePrivyInternal();return{loginWithPasskey:t.useCallback((async t=>{try{let a=await et(r);await n({captchaToken:a,withPrivyUi:!1});let{user:s,isNewUser:o,wasAlreadyAuthenticated:l,loginAccount:c}=await i(t);e?.onComplete?.({user:s,isNewUser:o,wasAlreadyAuthenticated:l,loginMethod:"passkey",loginAccount:c})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[i,r]),state:a}},exports.useLoginWithSiwe=e=>{let r=Ze(),{siweState:n,setSiweState:i,client:a,generateSiweMessage:s,loginWithSiwe:o}=l.usePrivyInternal();return{generateSiweNonce:t.useCallback((async t=>{try{let e=await et(r);i({status:"generating-message"});let n=await a.generateSiweNonce({address:t?.address,captchaToken:e});return i({status:"awaiting-signature"}),n}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[a,r]),generateSiweMessage:t.useCallback((async({address:t,chainId:n})=>{try{let e=await et(r);return await s({address:t,chainId:n,captchaToken:e})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[s,r]),loginWithSiwe:t.useCallback((async({message:t,signature:n,disableSignup:a,walletClientType:s,connectorType:c})=>{try{let i=await et(r),{user:l,isNewUser:d}=await o({message:t,signature:n,captchaToken:i,disableSignup:a,walletClientType:s,connectorType:c});return e?.onComplete?.({user:l,isNewUser:d,wasAlreadyAuthenticated:!1,loginMethod:"siwe",loginAccount:null}),l}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[o,r]),state:n}},exports.useLoginWithSiws=()=>{let e=Ze(),{client:r,setAuthenticated:n,setUser:i,setIsNewUser:a}=l.usePrivyInternal(),{authenticated:s}=p.usePrivy();return{generateSiwsMessage:t.useCallback((async({address:t})=>{let n=await et(e),i=await r.generateSiwsNonce({address:t,captchaToken:n});return p.prepareSiwsMessageWithNonce({address:t,nonce:i})}),[e,r]),loginWithSiws:t.useCallback((async({message:e,signature:t,disableSignup:o,walletClientType:l,connectorType:c})=>{if(s)throw Error("User already authenticated");let{user:d,isNewUser:u}=await r.authenticateWithSiws({message:e,signature:t,walletClientType:l,connectorType:c,mode:o?"no-signup":"login-or-sign-up",messageType:"plain"});if(!d)throw Error("Authentication failed - no user returned");return i(d),a(u||!1),n(!0),d}),[s,r,n,i,a])}},exports.useLoginWithSms=e=>{let r=Ze(),{smsOtpState:n,setSmsOtpState:i,initLoginWithSms:a,loginWithCode:s}=l.usePrivyInternal();return{sendCode:t.useCallback((async({phoneNumber:t,disableSignup:n})=>{try{if(!t)throw Error("SMS required to send OTP code");let e=await et(r);return await a({phoneNumber:t,captchaToken:e,disableSignup:n,withPrivyUi:!1})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[a,r]),loginWithCode:t.useCallback((async({code:t})=>{try{let{user:r,isNewUser:n,wasAlreadyAuthenticated:i,linkedAccount:a}=await s(t);e?.onComplete?.({user:r,isNewUser:n,wasAlreadyAuthenticated:i,loginMethod:"sms",loginAccount:a})}catch(t){throw i({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[s]),state:n}},exports.useLoginWithTelegram=e=>{let r=Ze(),{initLoginWithTelegram:n,loginWithTelegram:i,telegramAuthState:a,setTelegramAuthState:s}=l.usePrivyInternal();return{login:t.useCallback((async t=>{try{if(r.enabled&&"success"!==r.status)throw new Qe(r.error,null,l.PrivyErrorCode.CAPTCHA_FAILURE);await n(r.token,t?.disableSignup);let{user:a,isNewUser:s,loginAccount:o,wasAlreadyAuthenticated:c}=await i({intent:"login"});e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:c,loginMethod:"telegram",loginAccount:o})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[n,i,r]),state:a}},exports.useMfa=function(){let{promptMfa:e,init:r,submit:n,cancel:i,mfaMethods:s}=t.useContext(a.PrivyContext);return{promptMfa:e,init:r,submit:n,cancel:i,mfaMethods:s}},exports.useMfaEnrollment=function(){let{initEnrollmentWithSms:e,initEnrollmentWithTotp:r,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:i,submitEnrollmentWithTotp:s,submitEnrollmentWithPasskey:o,unenroll:l,enrollInMfa:c}=t.useContext(a.PrivyContext);return{initEnrollmentWithSms:e,initEnrollmentWithTotp:r,initEnrollmentWithPasskey:n,submitEnrollmentWithSms:i,submitEnrollmentWithTotp:s,submitEnrollmentWithPasskey:o,unenrollWithSms:()=>l("sms"),unenrollWithTotp:()=>l("totp"),unenrollWithPasskey:e=>l("passkey",e),showMfaEnrollmentModal:()=>c(!0),closeMfaEnrollmentModal:()=>c(!1)}},exports.useMigrateWallets=dr,exports.useModalStatus=()=>{let{isModalOpen:e}=t.useContext(a.PrivyContext);return{isOpen:e}},exports.useOAuthTokens=function(e){let{authenticated:t,user:r}=a.usePrivyContext(),{initLoginWithOAuth:n}=l.usePrivyInternal(),i=k.useEmitPrivyEvent();return k.usePrivyEventSubscription("oAuthAuthorization",e),{reauthorize:e=>Kr(t,r,n,i,e.provider)}},exports.useRecoverEmbeddedWallet=()=>{let{user:e}=a.usePrivyContext(),{walletProxy:r}=l.usePrivyInternal();return{recover:t.useCallback((async t=>{if(!r)throw Error("Wallet proxy is not ready");let n=await it();if(!e||!n)throw new l.PrivyClientError("User must be logged in before attempting to modify the recovery method.");let{entropyId:i,entropyIdVerifier:a}=S.getEntropyDetailsForUser(e);try{await r.recover({entropyId:i,entropyIdVerifier:a,accessToken:n,...t})}catch{throw new l.PrivyClientError("Unable to recover wallets")}}),[r,e])}},exports.useRegisterMfaListener=ct,exports.useSendTransaction=function(e){let{sendTransaction:r}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("sendTransaction",e),{sendTransaction:r}},exports.useSessionSigners=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=zr();return{addSessionSigners:async({address:t,signers:r})=>e({address:t,signers:r}),removeSessionSigners:async({address:e})=>t({address:e})}},exports.useSetWalletRecovery=function(e){let{setWalletRecovery:r}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("setWalletRecovery",e),{setWalletRecovery:r}},exports.useSign7702Authorization=()=>{let{ready:e,wallets:r}=S.useWallets(),{user:n}=a.usePrivyContext(),{rpcConfig:i,chains:s,appId:o}=l.usePrivyInternal();return{signAuthorization:t.useCallback((async(t,l)=>{let c;if(!n)throw Error("User must be authenticated before signing with a Privy wallet");if(!e)throw Error("Wallets are not ready");let d=l?.address??a.getPrivyEthereumWallet(n)?.address??I.zeroAddress,u=r.find((e=>I.getAddress(e.address)===I.getAddress(d)));if(!u)throw Error("Signing wallet not found.");let h=t.chainId??Number(u.chainId.split(":")[1]);if(0===h)c={chainId:0,address:t.contractAddress,nonce:t.nonce??0};else{let e=s.find((e=>e.id===h));if(!e)throw Error("Error, chain not configured in PrivyProvider config");let r=I.createWalletClient({account:d,chain:e,transport:I.http(x.getJsonRpcEndpointFromChain(e,i,o))});c=await r.prepareAuthorization({...t})}let p=await u.getEthereumProvider(),y=await p.request({method:"secp256k1_sign",params:[C.hashAuthorization(c)]});return{...c,...I.parseSignature(y)}}),[e,r,n,s])}},exports.useSignMessage=function(e){let{signMessage:r}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("signMessage",e),{signMessage:r}},exports.useSignTransaction=function(){let{signTransaction:e}=t.useContext(a.PrivyContext);return{signTransaction:e}},exports.useSignTypedData=function(e){let{signTypedData:r}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("signTypedData",e),{signTypedData:r}},exports.useSigners=()=>{let{addSessionSignersInternal:e,removeSessionSignersInternal:t}=zr();return{addSigners:async({address:t,signers:r})=>e({address:t,signers:r}),removeSigners:async({address:e})=>t({address:e})}},exports.useSignupWithPasskey=e=>{let r=Ze(),{initSignupWithPasskey:n,signupWithPasskey:i,passkeyAuthState:a,setPasskeyAuthState:s}=l.usePrivyInternal();return{signupWithPasskey:t.useCallback((async()=>{try{let t=await et(r);await n({captchaToken:t,withPrivyUi:!1});let{user:a,isNewUser:s,wasAlreadyAuthenticated:o,loginAccount:l}=await i();e?.onComplete?.({user:a,isNewUser:s,wasAlreadyAuthenticated:o,loginMethod:"passkey",loginAccount:l})}catch(t){throw s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR),t}}),[i,r]),state:a}},exports.useSubscribeToJwtAuthWithFlag=function({isAuthenticated:e,isLoading:r,...n}){let i=t.useRef();t.useEffect((()=>{r||i.current?.()}),[e,r]);let a=t.useCallback((e=>(i.current=e,()=>{i.current=void 0})),[]);return fr({...n,subscribe:a})},exports.useSyncJwtBasedAuthState=fr,exports.useToken=function(e){let{getAccessToken:r}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("accessToken",e),{getAccessToken:r}},exports.useUpdateAccount=function(e){let{updateEmail:r,updatePhone:n}=t.useContext(a.PrivyContext);return k.usePrivyEventSubscription("update",e),{updateEmail:r,updatePhone:n}},exports.useUpdateEmail=e=>{let{user:r}=a.usePrivyContext(),{loginWithCode:n,emailOtpState:i,setEmailOtpState:s,client:o,inProgressAuthFlowRef:c,inProgressLoginOrLinkMethodRef:d}=l.usePrivyInternal();return{state:i,sendCode:t.useCallback((async({newEmailAddress:t})=>{try{if(!r?.email)throw Error("User is required to have an email address to update it.");let e=new ve(r.email.address,t);o.startAuthFlow(e),await e.sendCodeEmail({withPrivyUi:!1})}catch(t){s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[r?.email]),verifyCode:t.useCallback((async({code:t})=>{try{if(!r?.email)throw Error("User is required to have an email address to update it.");c.current="update",d.current="email";let{user:i,linkedAccount:a}=await n(t);return e?.onSuccess?.({user:i,updateMethod:"email",updatedAccount:a}),{user:i}}catch(t){s({status:"error",error:t}),e?.onError?.(t.privyErrorCode||l.PrivyErrorCode.UNKNOWN_AUTH_ERROR,{linkMethod:"email"})}}),[r?.email])}},exports.useUser=()=>{let{setUser:e,client:r}=t.useContext(l.InternalPrivyContext),{user:n}=t.useContext(a.PrivyContext);return{user:n,refreshUser:t.useCallback((async()=>{let t=await(r?.updateUserAndIdToken());return e(t??null),t}),[r,e])}},exports.useX402Fetch=()=>{let{wallets:e}=S.useWallets();return t.useMemo((()=>({wrapFetchWithPayment:({walletAddress:t,fetch:r,maxValue:n=BigInt(1e5),paymentRequirementsSelector:i=N.selectPaymentRequirements,config:s})=>{let o=t||e[0]?.address;if(!o)throw new M.InvalidInputError("No wallet available for payment");let l=e.find((e=>a.areAddressesEqual(e.address,o)));if(!l)throw new M.InvalidInputError(`Wallet ${o} not found in connected wallets`);return async(e,t)=>{let a=await r(e,t);if(402!==a.status)return a;if(t?.__is402Retry)throw Error("Payment already attempted for this request");let{x402Version:o,accepts:c}=await a.json(),d=i(c,void 0,"exact");if(BigInt(d.maxAmountRequired)>n)throw new M.InvalidInputError("Payment amount exceeds maximum allowed");let u=await qr({wallet:l}),h=await N.createPaymentHeader(u,o,d,s),p={...t,headers:{...t?.headers||{},"X-PAYMENT":h,"Access-Control-Expose-Headers":"X-PAYMENT-RESPONSE"},__is402Retry:!0};return await r(e,p)}}})),[e])};
|