import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{useState as l,useEffect as a}from"react";import{M as o,B as i}from"./ModalHeader-DffkxvO4.mjs";import{C as r}from"./ScreenHeader-CHmc4-Lu.mjs";import{t as c}from"./FundWalletMethodHeader-A50eT5P4.mjs";import{I as s}from"./InjectedWalletIcon-DLcYOGDj.mjs";import{C as p}from"./Chip-D2-wZOHJ.mjs";import{S as m}from"./Subtitle-CV-2yKE4.mjs";import{u as d}from"./context-BKnOUECq.mjs";import{k as y,b as u,l as h,d as w}from"./index-BtwxknTg.mjs";import{u as f}from"./internal-context-dfitw7Ot.mjs";import{u as C}from"./modal-context-DBwfUxD-.mjs";import{u as T}from"./get-entropy-details-for-user-BIWg0YxF.mjs";import{W as g}from"./WalletOverflowButton-zWfc2OYf.mjs";import{v,w as j}from"./toViemAccount-4iGGrW4w.mjs";import{isMobile as _}from"react-device-detect";import{styled as x}from"styled-components";import{q as S}from"./wallet-connect-58EobR5U.mjs";import{r as W}from"./index-C5jxD-zy.mjs";import{g as b,l as k,q as $}from"./useActiveWallet-BEfvREjE.mjs";import{I as O}from"./styles-ByUO8DsA.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"@heroicons/react/24/outline/WalletIcon";import"./LoadingSkeleton-U6-3yFwI.mjs";import"@privy-io/js-sdk-core";import"tinycolor2";import"zustand";import"viem";import"viem/utils";import"./errors-Dd6zfYtp.mjs";import"ofetch";import"./user-D5cqJNp9.mjs";import"./privy-context-Bi6vqCPc.mjs";import"@privy-io/are-addresses-equal";import"lucide-react";import"jose";import"eventemitter3";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"./getPublicClient-D4yNgeGy.mjs";import"viem/chains";import"mipd";import"@scure/base";import"./usePrivy-BhL-ltvm.mjs";import"./use-unlink-wallet-oAguM2-k.mjs";import"@privy-io/popup";import"./events-context-BJ75xIIf.mjs";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"./LinkPasskeyScreen-C-MqivSL.mjs";import"./TodoList-CgrU7uwu.mjs";import"./ScreenLayout-Caq5mGD8.mjs";import"./Screen-D8KNyGVj.mjs";import"./index-Dq_xe9dz.mjs";const I=({provider:t,displayName:o,logo:i,connectOnly:r,connector:c})=>{let p,{navigate:m,setModalData:d}=C(),{connectWallet:w,walletConnectionStatus:T}=f(),g=b(),[v,j]=l(!1),x="wallet_connect_v2"===c.connectorType?t:c.walletClientType,[k,$]=l(!1);a((()=>{k&&("connected"===T?.status||T?.connectError)&&(m(r?"ConnectOnlyStatusScreen":"ConnectionStatusScreen"),$(!1))}),[k,T]);let O=y(t),I=window.matchMedia("(display-mode: standalone)").matches,B=u({connectorType:c.connectorType,walletClientType:x});p=B&&B.chainTypes.includes(c.chainType)?()=>{B.isInstalled||"solana"===c.chainType&&"isInstalled"in c&&c.isInstalled?(w(c,x),m(r?"ConnectOnlyStatusScreen":"ConnectionStatusScreen")):h({isMobile:_,walletConfig:B})?(d((e=>({...e,externalConnectWallet:{...e?.externalConnectWallet,preSelectedWalletId:t,walletChainType:"solana"===c.chainType?"solana-only":"ethereum-only"}}))),m(r?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")):_?(d({installWalletModalData:{walletConfig:B,chainType:c.chainType,connectOnly:r}}),m("WalletInterstitialScreen")):(d({installWalletModalData:{walletConfig:B,chainType:c.chainType,connectOnly:r}}),m("InstallWalletScreen"))}:"coinbase_wallet"!==c.connectorType||"eoaOnly"!==c.coinbaseWalletConfig.preference?.options||!_||I||S()?()=>{if(!W(window.navigator.userAgent)||event?.isTrusted){if("mobile_wallet_adapter"===c.walletClientType)return w(c,x),void $(!0);w(c,x),r?"wallet_connect_v2"===c.connectorType?(d((e=>({...e,externalConnectWallet:{...e?.externalConnectWallet,preSelectedWalletId:"wallet_connect_qr"}}))),m("ConnectOnlyLandingScreen")):m("ConnectOnlyStatusScreen"):m("ConnectionStatusScreen")}}:()=>{window.location.href=`https://go.cb-w.com/dapp?cb_url=${encodeURI(window.location.href)}`};let E=o||O?.metadata?.shortName||O?.name||c.walletClientType;/*#__PURE__*/return e(D,{onClick:()=>{v||(j(!0),setTimeout((()=>j(!1)),2e3),p())},disabled:v,children:[/*#__PURE__*/n(s,{icon:i||O?.image_url?.md,name:E}),/*#__PURE__*/n("span",{children:E}),/*#__PURE__*/e(A,{id:"chip-container",children:[g?.walletClientType===x&&g?.chainType===c.chainType?/*#__PURE__*/n(M,{color:"gray",children:"Recent"}):/*#__PURE__*/n("span",{id:"connect-text",children:"Connect"}),"solana"===c.chainType&&/*#__PURE__*/n(M,{color:"gray",children:"Solana"})]})]})};let D=x(k)`
  /* Wallet name text color */
  > span {
    color: var(--privy-color-foreground);
  }

  /* Show "Connect" on hover */
  > #chip-container > #connect-text {
    font-weight: 500;
    color: var(--privy-color-accent);
    opacity: 0;
    transition: opacity 0.1s ease-out;
  }

  :hover > #chip-container > #connect-text {
    opacity: 1;
  }

  @media (max-width: 440px) {
    > #chip-container > #connect-text {
      display: none;
    }
  }
`,M=x(p)`
  margin-left: auto;
`,A=x.div`
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-left: auto;
`;const B=["coinbase_wallet","base_account"];let E=["metamask","okx_wallet","rainbow","uniswap","bybit_wallet","ronin_wallet","haha_wallet","uniswap_extension","zerion","rabby_wallet","cryptocom","binance","kraken_wallet"];const F=["safe"],L=["phantom","backpack","solflare","jupiter","universal_profile"],N={component:()=>{let s,{connectors:p}=f(),{setModalData:y,data:u,navigate:h}=C(),_=d(),{wallets:x}=T(),S=p.filter(w).flatMap((e=>e.wallets)),[W,b]=l("default"),k="solana"===u?.funding?.chainType,O=!!u?.funding?.crossChainBridgingEnabled;s="ethereum"===u?.funding?.chainType?u.funding.erc20Address&&!u.funding.isUSDC?"ethereum-only":O&&!u.funding.chain.testnet?"ethereum-and-solana":"ethereum-only":O&&!u.funding?.isUSDC?"ethereum-and-solana":"solana-only";let D=x.filter((e=>"privy"!==e.walletClientType)),M=D.map((e=>e.walletClientType)),A=S.filter((e=>"privy"!==e.walletClientType)),N=A.map((e=>e.walletClientType)),P=[],H={...u.funding};H.usingDefaultFundingMethod&&(H.usingDefaultFundingMethod=!1);let R=({wallet:e,walletChainType:n})=>{y({...u,funding:{...H,connectedWallet:e,onContinueWithExternalWallet:()=>h(z({destChainType:k?"solana":"ethereum",sourceChainType:n}))},solanaFundingData:u?.solanaFundingData?{...u.solanaFundingData,sourceWalletData:{address:e.address,walletClientType:e.walletClientType}}:void 0}),h("FundingAmountEditScreen")};"solana-only"!==s&&P.push(...D.map(((e,t)=>/*#__PURE__*/n(q,{onClick:()=>R({wallet:e,walletChainType:"ethereum"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},t)))),"ethereum-only"!==s&&P.push(...A.map(((e,t)=>/*#__PURE__*/n(q,{onClick:()=>R({wallet:e,walletChainType:"solana"}),icon:e.meta.icon,name:e.meta.name,chainType:e.type},t)))),P.push(...(({walletList:e,walletChainType:t,connectors:l,connectOnly:a,ignore:o,walletConnectEnabled:i,forceWallet:r})=>{let c=[],s=[],p=[],m=l.filter((e=>"ethereum-only"===t?"ethereum"===e.chainType:"solana-only"!==t||"solana"===e.chainType)),d=m.find((e=>"wallet_connect_v2"===e.connectorType));for(let[l,y]of(r?[r.wallet]:e).entries()){if("detected_ethereum_wallets"===y)for(let[e,t]of m.filter((({chainType:e,connectorType:n,walletClientType:t})=>"solana"!==e&&("uniswap_wallet_extension"===t||"uniswap_extension"===t?!o.includes("uniswap"):"crypto.com_wallet_extension"===t||"crypto.com_onchain"===t?!o.includes("cryptocom"):"injected"===n&&!o.includes(t)))).entries()){let{walletClientType:o,walletBranding:i,chainType:r}=t;("unknown"===o?s:c).push(/*#__PURE__*/n(I,{connectOnly:a,provider:o,logo:i.icon,displayName:i.name,connector:t},`${l}-${y}-${o}-${r}-${e}`))}if("detected_solana_wallets"===y)for(let[e,i]of m.filter((({chainType:e,walletClientType:n})=>{if("solana"===e)return"ethereum-only"!==t&&!o.includes(n)})).entries()){let{walletClientType:t,walletBranding:o,chainType:r}=i;("unknown"===t?s:c).push(/*#__PURE__*/n(I,{connectOnly:a,provider:t,logo:o.icon,displayName:o.name,connector:i},`${l}-${y}-${t}-${r}-${e}`))}if(L.includes(y)){let e=m.find((e=>"injected"===e.connectorType&&e.walletClientType===y||e.connectorType===y));if(e&&c.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:e},`${l}-${y}`)),"solana-only"===t||"ethereum-and-solana"===t){let e=m.find((({chainType:e,walletClientType:n})=>"solana"===e&&n===y));e&&c.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:e},`${y}-solana`))}}else if(E.includes(y)){let e=m.find((e=>"uniswap"===y?"uniswap_wallet_extension"===e.walletClientType||"uniswap_extension"===e.walletClientType:"cryptocom"===y?"crypto.com_wallet_extension"===e.walletClientType||"crypto.com_onchain"===e.walletClientType:"injected"===e.connectorType&&e.walletClientType===y));if(i&&!e&&(e=d),e&&c.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:e,logo:"injected"===e.connectorType?e.walletBranding.icon:void 0,displayName:"injected"===e.connectorType?e.walletBranding.name:void 0},`${l}-${y}`)),"solana-only"===t||"ethereum-and-solana"===t){let e=m.find((({chainType:e,walletClientType:n})=>"solana"===e&&n===y));e&&c.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:e},`${y}-solana`))}}else if(B.includes(y)){let e=m.find((({connectorType:e})=>e===y));e&&c.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:e,displayName:"coinbase_wallet"===e.walletClientType?"Coinbase":"Base",logo:"coinbase_wallet"===e.walletClientType?v:j},`${l}-${y}`))}else if(F.includes(y))d&&p.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:d},`${l}-${y}`));else if("wallet_connect"===y)d&&p.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,connector:d,logo:d.walletBranding.icon,displayName:"WalletConnect"},`${l}-${y}`));else if(y===r?.wallet){let t="ethereum"===r.chainType&&e.includes("detected_ethereum_wallets"),o="solana"===r.chainType&&e.includes("detected_solana_wallets");if(t||o){let e=m.find((({walletClientType:e})=>e===y));e&&c.push(/*#__PURE__*/n(I,{connectOnly:a,provider:y,displayName:e.walletBranding?.name,logo:e.walletBranding?.icon,connector:e},`${l}-${y}`))}}}return[...s,...c,...p]})({walletList:_.appearance.walletList.filter((e=>!D.some((n=>n.walletClientType===e))&&!A.some((n=>n.walletClientType===e)))),walletChainType:s,connectors:p,connectOnly:!0,ignore:[..._.appearance.walletList,...M,...N],walletConnectEnabled:_.externalWallets.walletConnect.enabled}));let U=/*#__PURE__*/n(g,{text:"More wallets",onClick:()=>b("overflow")}),z=({sourceChainType:e,destChainType:n})=>"ethereum"===e&&"solana"===n?"AwaitingEvmToSolBridgingScreen":"ethereum"===e&&"ethereum"===n?"AwaitingExternalEthereumTransferScreen":"solana"===e&&"ethereum"===n?"AwaitingSolToEvmBridgingScreen":H.externalSolanaFundingScreen;return a((()=>{y({...u,externalConnectWallet:{onCompleteNavigateTo:({address:e,walletClientType:n,walletChainType:t})=>{let l=t??"ethereum",a="ethereum"===l?D.find((t=>t.address===e&&t.walletClientType===n)):A.find((t=>t.address===e&&t.walletClientType===n));return y({...u,funding:{...H,connectedWallet:a,onContinueWithExternalWallet:()=>{h(z({destChainType:k?"solana":"ethereum",sourceChainType:l}))}},solanaFundingData:u?.solanaFundingData?{...u.solanaFundingData,sourceWalletData:{address:e||"",walletClientType:n||""}}:void 0}),"FundingAmountEditScreen"}}})}),[]),/*#__PURE__*/e(t,"overflow"===W?{children:[/*#__PURE__*/n(o,{backFn:()=>b("default")},"header"),/*#__PURE__*/e($,{children:[/*#__PURE__*/n(m,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),P]}),/*#__PURE__*/n(i,{})]}:{children:[/*#__PURE__*/n(c,{}),/*#__PURE__*/n(r,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),/*#__PURE__*/e($,{children:[P.length>4?P.slice(0,3):P,P.length>4&&U]}),/*#__PURE__*/n(i,{})]})}};let q=({onClick:t,icon:l,name:a,chainType:o})=>/*#__PURE__*/e(k,{onClick:t,children:[/*#__PURE__*/n(O,{style:{width:20},children:/*#__PURE__*/n(s,{icon:l,name:a})}),a,/*#__PURE__*/n(p,{color:"gray",style:{marginLeft:"auto"},children:"Connected"}),"solana"===o&&/*#__PURE__*/n(p,{color:"gray",children:"Solana"})]});export{N as TransferFromWalletScreen,N as default};
//# sourceMappingURL=TransferFromWalletScreen-trFHXW1-.mjs.map
