@privy-io/react-auth
Version:
React client for the Privy Auth API
148 lines (137 loc) • 24.8 kB
JavaScript
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{MagnifyingGlassIcon as l}from"@heroicons/react/24/outline";import{useVirtualizer as i}from"@tanstack/react-virtual";import{useMemo as a,useState as o,useCallback as r,useRef as c,useEffect as s}from"react";import{isMobile as d}from"react-device-detect";import{styled as h}from"styled-components";import{a as u,T as m}from"./ModalHeader-BnVmXtvG.mjs";import{C as p}from"./CopyableText-BCytXyJL.mjs";import{L as g}from"./Link-DJ5gq9Di.mjs";import{Q as w}from"./QrCode-B84kEIjT.mjs";import{E as y}from"./EmailInputForm-Dgoii4vf.mjs";import{u as f,q as v}from"./context-DLtU3JQy.mjs";import{u as b}from"./useI18n-C4fmUAf3.mjs";import{M as C,m as T,c as x,s as _,w as W,C as k,k as L,S as z}from"./useActiveWallet-CvP7iYvj.mjs";import{W as S,c as A,A as E}from"./use-export-wallet-_wu5ex5t.mjs";import{u as j,P as B,b as K}from"./internal-context-Z-fyxadS.mjs";import{W as q}from"./WalletCards-DH1rqayz.mjs";import{S as N}from"./Screen-Cycy3IzT.mjs";const I={phantom:{mobile:{native:"phantom://",universal:"https://phantom.app/ul/"}},solflare:{mobile:{native:void 0,universal:"https://solflare.com/ul/v1/"}},metamask:{image_url:{sm:C,md:C}}};class O{static normalize(e){return e.replace(/[-_]wallet$/,"").replace(/[-_]extension$/,"").toLowerCase()}isEth(e){return e.chains.some((e=>e.includes("eip155:")))}isSol(e){return e.chains.some((e=>e.includes("solana:")))}inAllowList(e,n){if(!this.normalizedAllowList||0===this.normalizedAllowList.length||"listing"===n&&this.includeWalletConnect)return!0;let t=O.normalize(e);return this.normalizedAllowList.some((e=>t===O.normalize(e)))}inDenyList(e,n){return"listing"===n&&"rabby"===e||"agw"===O.normalize(e)}chainMatches(e){return"ethereum-only"===this.chainFilter?"ethereum"===e:"solana-only"!==this.chainFilter||"solana"===e}getAllowListKey(e,n,t,l){let i=O.normalize(e);for(let e of this.normalizedAllowList||[])if(i===O.normalize(e))return e;if("connector"===n){if(("injected"===t||"solana_adapter"===t)&&"ethereum"===l&&this.detectedEth)return"detected_ethereum_wallets";if(("injected"===t||"solana_adapter"===t)&&"solana"===l&&this.detectedSol)return"detected_solana_wallets"}if("listing"===n&&this.includeWalletConnect)return"wallet_connect"}connectorOk(e){return!!("null"!==e.connectorType&&"walletconnect_solana"!==e.walletBranding.id&&this.chainMatches(e.chainType)&&(this.inAllowList(e.walletClientType,"connector")||("injected"===e.connectorType||"solana_adapter"===e.connectorType)&&("ethereum"===e.chainType&&this.detectedEth||"solana"===e.chainType&&this.detectedSol)))}listingOk(e){if(e.slug.includes("coinbase"))return!1;if("ethereum-only"===this.chainFilter){if(!this.isEth(e))return!1}else if("solana-only"===this.chainFilter&&!this.isSol(e))return!1;return!(!this.inAllowList(e.slug,"listing")||this.inDenyList(e.slug,"listing"))}getWallets(e,n){let t=new Map,l=e=>{let n=t.get(e.id);if(n){n.chainType!==e.chainType&&(n.chainType="multi");let t=new Set(n.chains);e.chains.forEach((e=>t.add(e))),n.chains=Array.from(t),!n.icon&&e.icon&&(n.icon=e.icon),!n.url&&e.url&&(n.url=e.url),!n.listing&&e.listing&&(n.listing=e.listing),!n.allowListKey&&e.allowListKey&&(n.allowListKey=e.allowListKey)}else t.set(e.id,e)};e.filter((e=>this.connectorOk(e))).forEach((e=>{let n=O.normalize(e.walletClientType);l({id:n,label:e.walletBranding?.name??n,source:"connector",connector:e,chainType:e.chainType,icon:e.walletBranding?.icon,url:void 0,chains:["ethereum"===e.chainType?"eip155":"solana"],allowListKey:this.getAllowListKey(e.walletClientType,"connector",e.connectorType,e.chainType)})}));let i=e.find((e=>"wallet_connect_v2"===e.connectorType)),a=e.find((e=>"walletconnect_solana"===e.walletBranding.id));n.filter((e=>this.listingOk(e))).forEach((n=>{let t=[...n.chains].filter((e=>e.includes("eip155:")||e.includes("solana:")));if(e.some((e=>O.normalize(e.walletClientType)===O.normalize(n.slug)&&"ethereum"===e.chainType&&"null"!==e.connectorType))||i||n.mobile.native||n.mobile.universal||T[n.slug]?.chainTypes.includes("ethereum")||(t=t.filter((e=>!e.includes("eip155:")))),e.some((e=>O.normalize(e.walletClientType)===O.normalize(n.slug)&&"solana"===e.chainType&&"null"!==e.connectorType))||a||n.mobile.native||n.mobile.universal||T[n.slug]?.chainTypes.includes("solana")||(t=t.filter((e=>!e.includes("solana:")))),!t.length)return;let o=O.normalize(n.slug),r=I[n.slug],c=r?.image_url?.sm||n.image_url?.sm;t.some((e=>e.includes("eip155:")))&&l({id:o,label:n.name||o,source:"listing",listing:n,chainType:"ethereum",icon:c,url:n.homepage,chains:t,allowListKey:this.getAllowListKey(n.slug,"listing")}),t.some((e=>e.includes("solana:")))&&l({id:o,label:n.name||o,source:"listing",listing:n,chainType:"solana",icon:c,url:n.homepage,chains:t,allowListKey:this.getAllowListKey(n.slug,"listing")})})),this.includeWalletConnectQr&&i&&l({id:"wallet_connect_qr",label:"WalletConnect",source:"connector",connector:i,chainType:"ethereum",icon:S,url:void 0,chains:["eip155"],allowListKey:"wallet_connect_qr"}),this.includeWalletConnectQrSolana&&a&&l({id:"wallet_connect_qr_solana",label:"WalletConnect",source:"connector",connector:a,chainType:"solana",icon:S,url:void 0,chains:["solana"],allowListKey:"wallet_connect_qr_solana"});let o=Array.from(t.values());o.forEach((e=>{let n=I[e.listing?.slug||e.id];n?.image_url?.sm&&(e.icon=n.image_url.sm)}));let r=new Map;return this.normalizedAllowList?.forEach(((e,n)=>{r.set(O.normalize(e),n)})),{wallets:o.slice().sort(((e,n)=>{if(e.allowListKey&&n.allowListKey){let t=this.normalizedAllowList?.findIndex((n=>O.normalize(n)===O.normalize(e.allowListKey)))??-1,l=this.normalizedAllowList?.findIndex((e=>O.normalize(e)===O.normalize(n.allowListKey)))??-1;if(t!==l&&t>=0&&l>=0)return t-l}if(e.allowListKey&&!n.allowListKey)return-1;if(!e.allowListKey&&n.allowListKey)return 1;let t=O.normalize(e.id),l=O.normalize(n.id);"binance-defi"===t?t="binance":"universalprofiles"===t?t="universal_profile":"cryptocom-defi"===t?t="cryptocom":"bitkeep"===t&&(t="bitget_wallet"),"binance-defi"===l?l="binance":"universalprofiles"===l?l="universal_profile":"cryptocom-defi"===l?l="cryptocom":"bitkeep"===l&&(l="bitget_wallet");let i=r.has(t),a=r.has(l);return i&&a?r.get(t)-r.get(l):i?-1:a?1:"connector"===e.source&&"listing"===n.source?-1:"listing"===e.source&&"connector"===n.source?1:e.label.toLowerCase().localeCompare(n.label.toLowerCase())})),walletCount:o.length}}constructor(e,n){this.chainFilter=e,n&&n.length>0&&(this.normalizedAllowList=n.map(String),this.normalizedAllowList.includes("binance")&&this.normalizedAllowList.push("binance-defi-wallet"),this.normalizedAllowList.includes("bitget_wallet")&&this.normalizedAllowList.push("bitkeep")),this.detectedEth=this.normalizedAllowList?.includes("detected_ethereum_wallets")??!1,this.detectedSol=this.normalizedAllowList?.includes("detected_solana_wallets")??!1,this.includeWalletConnect=this.normalizedAllowList?.includes("wallet_connect")??!1,this.includeWalletConnectQr=this.normalizedAllowList?.includes("wallet_connect_qr")??!1,this.includeWalletConnectQrSolana=this.normalizedAllowList?.includes("wallet_connect_qr_solana")??!1}}var U=t=>/*#__PURE__*/e("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...t,children:[/*#__PURE__*/n("path",{d:"m0 0h32v32h-32z",fill:"#5469d4"}),/*#__PURE__*/n("path",{d:"m15.997 5.333-.143.486v14.106l.143.143 6.548-3.87z",fill:"#c2ccf4"}),/*#__PURE__*/n("path",{d:"m15.996 5.333-6.548 10.865 6.548 3.87z",fill:"#fff"}),/*#__PURE__*/n("path",{d:"m15.997 21.306-.08.098v5.025l.08.236 6.552-9.227z",fill:"#c2ccf4"}),/*#__PURE__*/n("path",{d:"m15.996 26.665v-5.36l-6.548-3.867z",fill:"#fff"}),/*#__PURE__*/n("path",{d:"m15.995 20.07 6.548-3.87-6.548-2.976v6.847z",fill:"#8698e8"}),/*#__PURE__*/n("path",{d:"m9.448 16.2 6.548 3.87v-6.846z",fill:"#c2ccf4"})]}),$=t=>/*#__PURE__*/e("svg",{viewBox:"0 0 32 32",xmlns:"http://www.w3.org/2000/svg",...t,children:[/*#__PURE__*/e("linearGradient",{id:"a",gradientUnits:"userSpaceOnUse",x1:"7.233",x2:"24.766",y1:"24.766",y2:"7.234",children:[/*#__PURE__*/n("stop",{offset:"0",stopColor:"#9945ff"}),/*#__PURE__*/n("stop",{offset:".2",stopColor:"#7962e7"}),/*#__PURE__*/n("stop",{offset:"1",stopColor:"#00d18c"})]}),/*#__PURE__*/n("path",{d:"m0 0h32v32h-32z",fill:"#10111a"}),/*#__PURE__*/n("path",{clipRule:"evenodd",d:"m9.873 20.41a.645.645 0 0 1 .476-.21l14.662.012a.323.323 0 0 1 .238.54l-3.123 3.438a.643.643 0 0 1 -.475.21l-14.662-.012a.323.323 0 0 1 -.238-.54zm15.376-2.862a.322.322 0 0 1 -.238.54l-14.662.012a.642.642 0 0 1 -.476-.21l-3.122-3.44a.323.323 0 0 1 .238-.54l14.662-.012a.644.644 0 0 1 .475.21zm-15.376-9.738a.644.644 0 0 1 .476-.21l14.662.012a.322.322 0 0 1 .238.54l-3.123 3.438a.643.643 0 0 1 -.475.21l-14.662-.012a.323.323 0 0 1 -.238-.54z",fill:"url(#a)",fillRule:"evenodd"})]});const F=h.div`
display: flex;
justify-content: space-between;
align-items: center;
`,D=h.button`
padding: 0.25rem;
height: 30px;
width: 30px;
display: flex;
align-items: center;
justify-content: center;
border-radius: var(--privy-border-radius-full);
background: var(--privy-color-background-2);
`,M=h.div`
position: relative;
display: inline-flex;
align-items: center;
&::after {
content: ' ';
border-radius: var(--privy-border-radius-full);
height: 6px;
width: 6px;
background-color: var(--privy-color-icon-success);
position: absolute;
right: -3px;
top: -3px;
}
`,P=h.img`
width: 32px;
height: 32px;
border-radius: 0.25rem;
object-fit: contain;
`,Q=h.span`
display: flex;
gap: 0.25rem;
align-items: center;
padding: 0.25rem 0.5rem;
font-size: 0.75rem;
font-weight: 500;
line-height: 1.125rem; /* 150% */
border-radius: var(--privy-border-radius-sm);
background-color: var(--privy-color-background-2);
svg {
width: 100%;
max-width: 1rem;
max-height: 1rem;
stroke-width: 2;
}
`,H=h.div`
display: flex;
flex-direction: column;
gap: 0.5rem;
max-height: 24rem;
overflow-y: scroll;
&::-webkit-scrollbar {
display: none;
}
scrollbar-gutter: stable both-edges;
scrollbar-width: none;
-ms-overflow-style: none;
${e=>"light"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(0, 0, 0, 0) 20%, rgba(0, 0, 0, 0.06)) bottom;":"dark"===e.$colorScheme?"background: linear-gradient(var(--privy-color-background), var(--privy-color-background) 70%) bottom, linear-gradient(rgba(255, 255, 255, 0) 20%, rgba(255, 255, 255, 0.06)) bottom;":void 0}
background-repeat: no-repeat;
background-size:
100% 32px,
100% 16px;
background-attachment: local, scroll;
`;function V({enabled:e=!0,walletList:n,walletChainType:t}){let l=f(),{connectors:i}=j(),{listings:r,loading:c}=x(e),s=t??l.appearance.walletChainType,d=n??l.appearance?.walletList,h=a((()=>new O(s,d)),[s,d]),{wallets:u,walletCount:m}=a((()=>h.getWallets(i,r)),[h,i,r]),[p,g]=o(""),w=a((()=>p?u.filter((e=>e.label.toLowerCase().includes(p.toLowerCase()))):u),[p,u]),[y,v]=o();return{selected:y,setSelected:v,search:p,setSearch:g,loadingListings:c,wallets:w,walletCount:m}}let R=e=>!e||"string"!=typeof e&&(e instanceof L||e instanceof z);const Y=({index:l,style:i,data:a,recent:o})=>{let r=a.wallets[l],{walletChainType:c,handleWalletClick:s}=a,{t:d}=b(),h={...i,boxSizing:"border-box"};return r?/*#__PURE__*/e(Z,{style:h,onClick:()=>s(r),children:[r.icon&&(r.connector&&!R(r.connector)?/*#__PURE__*/n(M,{children:"string"==typeof r.icon?/*#__PURE__*/n(P,{src:r.icon}):/*#__PURE__*/n(r.icon,{style:{width:"32px",height:"32px"}})}):"string"==typeof r.icon?/*#__PURE__*/n(P,{src:r.icon}):/*#__PURE__*/n(r.icon,{style:{width:"32px",height:"32px"}})),/*#__PURE__*/n(te,{children:r.label}),o?/*#__PURE__*/e(t,{children:[/*#__PURE__*/n(Q,{children:d("connectWallet.lastUsed")}),/*#__PURE__*/n(ee,{children:/*#__PURE__*/e(t,{children:["ethereum-only"===c&&/*#__PURE__*/n(U,{}),"solana-only"===c&&/*#__PURE__*/n($,{})]})})]}):/*#__PURE__*/n(ee,{children:!("ethereum-only"===c||"solana-only"===c)&&/*#__PURE__*/e(t,{children:[r.chains?.some((e=>e.startsWith("eip155")))&&/*#__PURE__*/n(U,{}),r.chains?.some((e=>e.startsWith("solana")))&&/*#__PURE__*/n($,{})]})})]}):null};var G=({className:h,customDescription:p,connectOnly:C,preSelectedWalletId:x,hideHeader:S,...F})=>{let D=f(),{t:M}=b(),{connectors:Q}=j(),H=F.walletChainType||D.appearance.walletChainType,G=F.walletList||D.appearance?.walletList,{onBack:ae,onClose:oe,app:re}=F,{selected:ce,setSelected:se,qrUrl:de,setQrUrl:he,connecting:ue,uiState:me,errorCode:pe,wallets:ge,walletCount:we,handleConnect:ye,handleBack:fe,showSearchBar:ve,isInitialConnectView:be,title:Ce,search:Te,setSearch:xe}=function({onConnect:e,onBack:n,onClose:t,onConnectError:l,walletList:i,walletChainType:c,app:s}){let h=f(),{connectors:u}=j(),{t:m}=b(),{wallets:p,walletCount:g,search:w,setSearch:y,selected:C,setSelected:T}=V({enabled:_(i??[]),walletList:i,walletChainType:c}),[x,k]=o(),[L,z]=o(),[S,E]=o(),[K,q]=o(),N=!C&&!S&&!K,I=N&&(g>6||w.length>0),O=u.find((e=>"wallet_connect_v2"===e.connectorType)),U=r((async(n,t)=>{if(!n)return;let i=t?.name??"Wallet";if(K?.connector!==n||"loading"!==x){if(k("loading"),"string"==typeof n)return A.debug("Connecting wallet via deeplink",{wallet:i,url:n.length>80?`${n.slice(0,80)}...`:n}),q({connector:n,name:i,icon:t?.icon,id:t?.id,url:t?.url}),void window.open(n,"_blank");A.debug("Connecting wallet via connector",{wallet:i,connectorType:n.connectorType}),q({connector:n,name:t?.name??n.walletBranding.name??"Wallet",icon:t?.icon??n.walletBranding.icon,id:t?.id,url:t?.url});try{let t=await n.connect({showPrompt:!0});if(!t)return A.warn("Wallet connection returned null",{wallet:i,connectorType:n.connectorType}),k("error"),z(void 0),void l?.(new B("Unable to connect wallet"));A.debug("Wallet connection successful",{wallet:i,connectorType:n.connectorType}),k("success"),z(void 0),W({address:t.address,client:t.walletClientType,appId:h.id}),setTimeout((()=>{e({connector:n,wallet:t})}),v)}catch(e){if(e?.message?.includes("already pending for origin")||e?.message?.includes("wallet_requestPermissions"))return void A.debug("Connection request already pending, maintaining loading state",{wallet:i});let t=e instanceof Error?e.message:String(e?.message||"Unknown error");A.error("Wallet connection failed",e,{wallet:i,connectorType:n.connectorType,errorCode:e?.privyErrorCode}),k("error"),z(e?.privyErrorCode),l?.(e instanceof Error?e:new B(t||"Unable to connect wallet"))}}else A.debug("Duplicate connection attempt prevented",{wallet:i})}),[h.id,e,K,x]),$=r((()=>S?(k(void 0),z(void 0),q(void 0),void E(void 0)):K?(k(void 0),z(void 0),void q(void 0)):C?(k(void 0),z(void 0),q(void 0),void T(void 0)):"error"===x||"loading"===x?(k(void 0),z(void 0),void q(void 0)):void n?.()),[S,K,C,x,n]),F=a((()=>K?.connector===O&&S&&d&&K?.name?m("connectWallet.goToWallet",{walletName:K.name}):K?.connector===O&&S&&K?.name?m("connectWallet.scanToConnect",{walletName:K.name}):S&&K?.name?m(d?"connectWallet.goToWallet":"connectWallet.scanToConnect",{walletName:K.name}):"string"==typeof K?.connector?m("connectWallet.openOrInstall",{walletName:K.name}):C&&!K?m("connectWallet.selectNetwork"):K?null:m("connectWallet.selectYourWallet")),[K,S,C,O,m]);return{selected:C,setSelected:T,qrUrl:S,setQrUrl:E,connecting:K,uiState:x,errorCode:L,search:w,setSearch:y,wallets:p,walletCount:g,wc:O,isInitialConnectView:N,showSearchBar:I,title:F,handleConnect:U,handleBack:$,onClose:t,onConnect:e,app:s}}({...F,walletList:G,walletChainType:H}),_e=Q.find((e=>"wallet_connect_v2"===e.connectorType)),We=Q.find((e=>"walletconnect_solana"===e.walletBranding.id)),ke=c(null),Le=i({count:ge.length,getScrollElement:()=>ke.current,estimateSize:()=>56,overscan:6,gap:5}),ze=r((async e=>{let n="solana-only"!==H&&e.chains?.some((e=>e.startsWith("eip155"))),t="ethereum-only"!==H&&e.chains?.some((e=>e.startsWith("solana"))),l=()=>{let n=e.id;return T[n]||T[`${n}_wallet`]},i=n=>{let t=O.normalize(e.id);return Q.find((e=>O.normalize(e.walletClientType)===t&&e.chainType===n&&"wallet_connect_v2"!==e.connectorType&&!("ethereum"===e.chainType&&e instanceof L||"solana"===e.chainType&&e instanceof z)))},a=async()=>{if(!_e||!e.listing)return!1;let n=I[e.listing.slug]?{...e.listing,...I[e.listing.slug]}:e.listing;return _e.setWalletEntry(n,he),await _e.resetConnection(e.id),await ye(_e,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0},o=async()=>!!We&&!!e.listing&&(await We.disconnect(),We.wallet.setWalletEntry(e.listing,he),await new Promise((e=>setTimeout(e,100))),await ye(We,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0),r=async n=>{let t=(e=>{let n=l();if(n)return n.getMobileRedirect({isSolana:e,connectOnly:!!C,useUniversalLink:!1})})(n);return!!t&&(await ye(t,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0)};if(n&&t)se(e);else{if(n&&!t){let n=i("ethereum");if(n&&!R(n))return A.debug("Attempting injected EVM connection",{wallet:e.id,connectorType:n.connectorType}),void await ye(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(d&&l()){if(await r(!1)||await a())return}else if(await a()||await r(!1))return}if(t&&!n){let n=i("solana");if(n&&!R(n))return A.debug("Attempting injected Solana connection",{wallet:e.id,connectorType:n.connectorType}),void await ye(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(d){if(await r(!0)||await o())return}else if(await o()||await r(!0))return}if(!R(e.connector)){if(A.debug("Using fallback direct connector",{wallet:e.id,connectorType:e.connector?.connectorType}),_e&&"wallet_connect_v2"===e.connector?.connectorType)if(await _e.resetConnection(e.id),"wallet_connect_qr"!==e.id&&e.listing){let n=I[e.listing.slug]?{...e.listing,...I[e.listing.slug]}:e.listing;_e.setWalletEntry(n,he)}else _e.setWalletEntry({id:"wallet_connect_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect",homepage:"",chains:["eip155"],mobile:{native:"",universal:void 0}},he);return We&&"walletconnect_solana"===e.connector?.walletBranding.id&&(await We.disconnect(),"wallet_connect_qr_solana"!==e.id&&e.listing?We.wallet.setWalletEntry(e.listing,he):We.wallet.setWalletEntry({id:"wallet_connect_solana_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect-solana",homepage:"",chains:["solana"],mobile:{native:"",universal:void 0}},he),await new Promise((e=>setTimeout(e,100)))),void await ye(e.connector,{name:e.label,icon:e.icon,id:e.id,url:e.url})}e.url?await ye(e.url,{name:e.label,icon:e.icon,id:e.id,url:e.url}):A.warn("No available connection method for wallet",{wallet:e.id})}}),[_e,We,ye,se,he,H,C,Q]);return s((()=>{if(!x)return;let e=ge.find((({id:e})=>e===x));e&&ze(e).catch(console.error)}),[x]),/*#__PURE__*/e(N,{className:h,children:[/*#__PURE__*/n(N.Header,{icon:S&&be?void 0:ue&&!de||de&&d&&ue?.icon?ue.icon:ue?void 0:q,iconVariant:ue&&!de||de&&d?"loading":void 0,iconLoadingStatus:ue&&!de||de&&d?{success:"success"===me,fail:"error"===me}:void 0,title:S&&be?void 0:ue&&!de?M("connectWallet.waitingForWallet",{walletName:ue.name}):de&&d?M("connectWallet.waitingForWallet",{walletName:ue?.name??"connection"}):Ce,subtitle:S&&be?void 0:ue&&!de&&"string"==typeof ue.connector?M("connectWallet.installAndConnect",{walletName:ue.name}):ue&&!de&&"string"!=typeof ue.connector?"error"===me?pe===K.NO_SOLANA_ACCOUNTS?`The connected wallet has no Solana accounts. Please add a Solana account in ${ue.name} and try again.`:M("connectWallet.tryConnectingAgain"):M("connectionStatus.connectOneWallet"):be?p??(re?M("connectWallet.connectToAccount",{appName:re.name}):null):null,showBack:!!ae||!be,showClose:!0,onBack:ae||fe,onClose:oe}),/*#__PURE__*/e(N.Body,{ref:ke,$colorScheme:D.appearance.palette.colorScheme,style:{marginBottom:de?"0.5rem":void 0},children:[ve&&/*#__PURE__*/n(J,{children:/*#__PURE__*/e(y,{style:{background:"transparent"},children:[/*#__PURE__*/n(k,{children:/*#__PURE__*/n(l,{})}),/*#__PURE__*/n("input",{className:"login-method-button",type:"text",placeholder:M("connectWallet.searchPlaceholder",{count:String(we)}),onChange:e=>xe(e.target.value),value:Te})]})}),de&&d&&"loading"===me&&/*#__PURE__*/e("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:[/*#__PURE__*/n(u,{variant:"primary",onClick:()=>window.open(de.universal??de.native,"_blank"),style:{width:"100%"},children:M("connectWallet.openInApp")}),/*#__PURE__*/n(le,{value:de.universal??de.native,iconOnly:!0,children:"Copy link"})]}),de&&!d&&"loading"===me&&/*#__PURE__*/n("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:/*#__PURE__*/n(le,{value:de.universal??de.native,iconOnly:!0,children:M("connectWallet.copyLink")})}),de&&!d&&/*#__PURE__*/n(w,{size:280,url:de.universal??de.native,squareLogoElement:ue?.icon?"string"==typeof ue.icon?e=>/*#__PURE__*/n("svg",{...e,children:/*#__PURE__*/n("image",{href:ue.icon,height:e.height,width:e.width})}):ue.icon:E}),de&&!d&&ue?.url&&("binance"===ue.id||"binanceus"===ue.id||"binance-defi"===ue.id)&&/*#__PURE__*/e(ie,{children:[/*#__PURE__*/e("span",{children:["Don't have ",ue.name,"? "]}),/*#__PURE__*/n(g,{href:ue.url,target:"_blank",size:"sm",children:"Download here"})]}),/*#__PURE__*/e(X,{children:[ue&&!de&&"string"==typeof ue.connector&&/*#__PURE__*/e(Z,{onClick:()=>window.open(ue.connector,"_blank"),children:[ue.icon&&("string"==typeof ue.icon?/*#__PURE__*/n(P,{src:ue.icon}):/*#__PURE__*/n(ue.icon,{})),/*#__PURE__*/n(te,{children:ue.name})]}),ce?.chains.some((e=>e.startsWith("eip155")))&&!ue&&/*#__PURE__*/e(Z,{onClick:()=>ze({...ce,chains:ce.chains.filter((e=>e.startsWith("eip155")))}),children:[ce.icon&&("string"==typeof ce.icon?/*#__PURE__*/n(P,{src:ce.icon}):/*#__PURE__*/n(ce.icon,{})),/*#__PURE__*/n(te,{children:ce.label}),/*#__PURE__*/n(ee,{children:/*#__PURE__*/n(U,{})})]}),ce?.chains.some((e=>e.startsWith("solana")))&&!ue&&/*#__PURE__*/e(Z,{onClick:()=>ze({...ce,chains:ce.chains.filter((e=>e.startsWith("solana")))}),children:[ce.icon&&("string"==typeof ce.icon?/*#__PURE__*/n(P,{src:ce.icon}):/*#__PURE__*/n(ce.icon,{})),/*#__PURE__*/n(te,{children:ce.label}),/*#__PURE__*/n(ee,{children:/*#__PURE__*/n($,{})})]}),be&&/*#__PURE__*/e(t,{children:[!(we>0)&&/*#__PURE__*/n(ne,{children:M("connectWallet.noWalletsFound")}),we>0&&!de&&/*#__PURE__*/n("div",{style:{maxHeight:56*Math.min(ge.length,5)+5,width:"100%"},children:/*#__PURE__*/n("div",{style:{height:`${Le.getTotalSize()}px`,width:"100%",position:"relative"},children:Le.getVirtualItems().map((e=>/*#__PURE__*/n(Y,{index:e.index,style:{position:"absolute",top:0,left:0,height:`${e.size}px`,transform:`translateY(${e.start}px)`},data:{wallets:ge,walletChainType:H,handleWalletClick:ze}},e.key)))})})]})]})]}),/*#__PURE__*/e(N.Footer,{children:[ue&&!de&&"string"!=typeof ue.connector&&"error"===me&&/*#__PURE__*/n(N.Actions,{children:/*#__PURE__*/n(u,{style:{width:"100%",alignItems:"center"},variant:"error",onClick:()=>ye(ue.connector,{name:ue.name,icon:ue.icon,id:ue.id,url:ue.url}),children:M("connectWallet.retry")})}),!!(re&&re.legal.privacyPolicyUrl&&re.legal.termsAndConditionsUrl)&&/*#__PURE__*/n(m,{app:re,alwaysShowImplicitConsent:!0}),/*#__PURE__*/n(N.Watermark,{})]})]})};let J=h.div`
position: sticky;
// Offset by negative margin to account for focus outline
margin-top: -3px;
padding-top: 3px;
top: -3px;
z-index: 1;
background: var(--privy-color-background);
padding-bottom: calc(var(--screen-space) / 2);
`,X=h.div`
display: flex;
flex-direction: column;
gap: ${5}px;
`,Z=h.button`
&& {
gap: 0.5rem;
align-items: center;
display: flex;
position: relative;
text-align: left;
font-weight: 500;
transition: background 200ms ease-in;
width: calc(100% - 4px);
border-radius: var(--privy-border-radius-md);
padding: 0.75em;
border: 1px solid var(--privy-color-foreground-4);
justify-content: space-between;
}
&:hover {
background: var(--privy-color-background-2);
}
`,ee=h.span`
display: flex;
align-items: center;
justify-content: end;
position: relative;
& > svg {
border-radius: var(--privy-border-radius-full);
stroke-width: 2.5;
width: 100%;
max-height: 1rem;
max-width: 1rem;
flex-shrink: 0;
}
& > svg:not(:last-child) {
border-radius: var(--privy-border-radius-full);
margin-right: -0.375rem;
}
`,ne=h.div`
height: 60px;
display: flex;
align-items: center;
justify-content: center;
text-align: center;
`,te=h.span`
text-overflow: ellipsis;
white-space: nowrap;
color: var(--privy-color-foreground);
font-weight: 400;
flex: 1;
`,le=h(p)`
&& {
margin: 0.5rem auto 0 auto;
}
`,ie=h.div`
text-align: center;
margin-top: 1rem;
font-size: 0.875rem;
font-weight: 400;
color: var(--privy-color-foreground-3);
`;export{Q as C,F as H,H as S,P as W,D as a,O as b,Y as c,G as i,V as u};