import{jsx as e}from"react/jsx-runtime";import{useState as t,useEffect as o}from"react";import{isMobile as r}from"react-device-detect";import{C as i}from"./wallet-connect-58EobR5U.mjs";import{r as n}from"./context-BKnOUECq.mjs";import{k as a}from"./index-BtwxknTg.mjs";import{u as s}from"./internal-context-dfitw7Ot.mjs";import{u as m}from"./modal-context-DBwfUxD-.mjs";import{S as l}from"./ScreenLayout-Caq5mGD8.mjs";import{B as c}from"./toViemAccount-4iGGrW4w.mjs";import{getErrorDetails as p}from"./ConnectionStatusScreen-qGHjVEKW.mjs";import"./errors-Dd6zfYtp.mjs";import"ofetch";import"./getPublicClient-D4yNgeGy.mjs";import"viem";import"viem/chains";import"@privy-io/js-sdk-core";import"eventemitter3";import"tinycolor2";import"zustand";import"viem/utils";import"./ModalHeader-DffkxvO4.mjs";import"styled-components";import"./useActiveWallet-BEfvREjE.mjs";import"./events-context-BJ75xIIf.mjs";import"./privy-context-Bi6vqCPc.mjs";import"@privy-io/are-addresses-equal";import"./get-entropy-details-for-user-BIWg0YxF.mjs";import"./user-D5cqJNp9.mjs";import"@heroicons/react/24/outline/ArrowLeftIcon";import"@heroicons/react/24/outline/ArrowRightIcon";import"@heroicons/react/24/outline/QuestionMarkCircleIcon";import"@heroicons/react/24/outline/XMarkIcon";import"./Screen-D8KNyGVj.mjs";import"./index-Dq_xe9dz.mjs";import"jose";import"@coinbase/wallet-sdk";import"@walletconnect/ethereum-provider";import"./pkce-BinverJO.mjs";import"./paths-BH8W4zMc.mjs";import"./PrivyPluginContext-DA-yS5vO.mjs";import"js-cookie";import"@privy-io/ethereum";import"viem/accounts";import"./index-C5jxD-zy.mjs";import"mipd";import"@scure/base";import"./usePrivy-BhL-ltvm.mjs";import"./use-unlink-wallet-oAguM2-k.mjs";import"@privy-io/popup";import"@headlessui/react";import"@privy-io/urls";import"./getEmbeddedConnectedWallet-Ba6LFHzY.mjs";import"./frame-DtizlaLu.mjs";import"@privy-io/routes";import"./use-deposit-address-BwThybOQ.mjs";import"x402/client";import"@privy-io/api-base";import"./use-sign-with-user-signer-CQI6hUH7.mjs";import"./Link-DJ5gq9Di.mjs";import"./useI18n-nYc5Yqb0.mjs";import"./shouldProceedtoEmbeddedWalletCreationFlow-SyjOJUom.mjs";const u=({walletLogo:t,success:o,errorMessage:r,title:n,subtitle:a,onRetry:s,onUseDifferentWallet:m,onBack:c,numRetries:p,maxRetries:u})=>/*#__PURE__*/e(l,{title:n,subtitle:a,icon:t,iconVariant:"loading",iconLoadingStatus:{success:o,fail:!!r},primaryCta:r===i.ERROR_USER_EXISTS?{label:"Use a different wallet",onClick:m}:!o&&r?.retryable&&p<u?{label:"Retry",onClick:s,disabled:!r?.retryable||p>=u}:!o&&r&&p>=u?{label:"Use a different wallet",onClick:m}:void 0,onBack:c,watermark:!0}),d={component:()=>{let i,{navigateBack:l,navigate:d,lastScreen:w,currentScreen:j,data:f,setModalData:y}=m(),{walletConnectionStatus:g,closePrivyModal:v}=s(),[h,k]=t(void 0),[C,b]=t(0),x=a(g?.connector?.walletClientType||"unknown"),S="connected"===g?.status,R="switching_to_supported_chain"===g?.status;o((()=>{if(S){let e;if(f?.externalConnectWallet?.onCompleteNavigateTo){let t=f.externalConnectWallet.onCompleteNavigateTo,o=g.connectedWallet?.address;e=setTimeout((()=>{if(f.funding&&g.connector){let e=g.connector.wallets.find((e=>e.address===o));y({...f,funding:{...f.funding,connectedWallet:e}})}d(t({address:o,walletClientType:g.connector?.walletClientType,walletChainType:g.connector?.chainType}))}),n)}else e=setTimeout(v,n);return()=>clearTimeout(e)}}),[S]);o((()=>{var e;g?.connectError&&(e=g?.connectError,k(p(e)))}),[g]);let T=g?.connector?.connectorType||"injected",W=g?.connector?.walletClientType||"unknown",B=x?.metadata?.shortName||x?.name||g?.connector?.walletBranding.name||"Browser Extension",E=x?.image_url?.md||g?.connector?.walletBranding.icon||(t=>/*#__PURE__*/e(c,{...t})),M="Browser Extension"===B?B.toLowerCase():B;i=S?`Successfully connected with ${M}`:h?h.message:R?"Switching networks":`Waiting for ${M}`;let _="Don’t see your wallet? Check your other browser windows.";return S?_="You’re good to go!":C>=2&&h?_="Unable to connect wallet":h?_=h.detail:R?_="Switch your wallet to the requested network.":"metamask"===W&&r?_="Click to continue to open and connect MetaMask.":"metamask"===W?_="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===T?_="Open your mobile wallet app to continue":"coinbase_wallet"===T&&(_="Confirm in the Coinbase app/popup to continue."),/*#__PURE__*/e(u,{walletName:B,walletLogo:E,success:S,errorMessage:h,title:i,subtitle:_,onRetry:()=>{b(C+1),k(void 0),g?.connectRetry()},onUseDifferentWallet:l,onBack:j===w?void 0:l,numRetries:C,maxRetries:2})}};export{d as ConnectOnlyStatusScreen,u as ConnectOnlyStatusScreenView,d as default};
//# sourceMappingURL=ConnectOnlyStatusScreen-CNyjzDQf.mjs.map
