UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

2 lines (1 loc) • 24.5 kB
import{jsxs as e,jsx as n,Fragment as t}from"react/jsx-runtime";import{MagnifyingGlassIcon as i}from"@heroicons/react/24/outline";import{useVirtualizer as l}from"@tanstack/react-virtual";import{useState as a,useMemo 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{B as m}from"./Button-CrJpeX0e.mjs";import p from"@heroicons/react/24/outline/CheckIcon";import{C as u}from"./copy-Bx2Jwc5_.mjs";import{L as g}from"./Link-DwjLfHwW.mjs";import{T as w}from"./ModalHeader-YP9pLMEP.mjs";import{Q as f}from"./QrCode-C0_lXRph.mjs";import{E as y}from"./EmailInputForm-B4hjCxRU.mjs";import{u as v,q as b}from"./context-BOoFAPna.mjs";import{u as C}from"./useI18n-fcpgyVzo.mjs";import{M as x,q as W,d as k,e as T,K as _,V as z,w as S,S as L}from"./useActiveWallet-BdFIc7_K.mjs";import{u as I,P as N,b as A}from"./internal-context-e-Eni5bG.mjs";import{W as B}from"./WalletCards-DH1rqayz.mjs";import{W as E,h as j}from"./prepareFundingModalData-CzDMa8gy.mjs";import{S as O}from"./Screen-CpIMiJNF.mjs";let q=/*#__PURE__*/h.button.withConfig({displayName:"CopyTextButton",componentId:"sc-4b0620dc-0"})(["display:flex;align-items:center;gap:0.5rem;&:hover{text-decoration:underline;}svg{width:0.875rem;height:0.875rem;}"]),U=/*#__PURE__*/h.span.withConfig({displayName:"CopiedText",componentId:"sc-4b0620dc-1"})(["display:flex;align-items:center;gap:0.25rem;font-size:0.875rem;color:var(--privy-color-foreground-2);"]),F=/*#__PURE__*/h(p).withConfig({displayName:"GreenCheck",componentId:"sc-4b0620dc-2"})(["color:var(--privy-color-success);"]),M=/*#__PURE__*/h(u).withConfig({displayName:"StyledCopy",componentId:"sc-4b0620dc-3"})(["color:var(--privy-color-foreground-3);opactiy:0.5;"]);function $({children:t,iconOnly:i,value:l,hideCopyIcon:o,...r}){let[c,s]=a(!1);/*#__PURE__*/return e(q,{...r,onClick:()=>{navigator.clipboard.writeText(l||t).catch(console.error),s(!0),setTimeout((()=>s(!1)),1500)},children:[t," ",c?/*#__PURE__*/e(U,{children:[/*#__PURE__*/n(F,{})," ",!i&&"Copied"]}):!o&&/*#__PURE__*/n(M,{})]})}const D={phantom:{mobile:{native:"phantom://",universal:"https://phantom.app/ul/"}},solflare:{mobile:{native:void 0,universal:"https://solflare.com/ul/v1/"}},metamask:{image_url:{sm:x,md:x}}};class P{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=P.normalize(e);return this.normalizedAllowList.some((e=>t===P.normalize(e)))}inDenyList(e,n){return"listing"===n&&"rabby"===e}chainMatches(e){return"ethereum-only"===this.chainFilter?"ethereum"===e:"solana-only"!==this.chainFilter||"solana"===e}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,i=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)}else t.set(e.id,e)};e.filter((e=>this.connectorOk(e))).forEach((e=>{let n=P.normalize(e.walletClientType);i({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"]})}));let l=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=>P.normalize(e.walletClientType)===P.normalize(n.slug)&&"ethereum"===e.chainType&&"null"!==e.connectorType))||l||n.mobile.native||n.mobile.universal||W[n.slug]?.chainTypes.includes("ethereum")||(t=t.filter((e=>!e.includes("eip155:")))),e.some((e=>P.normalize(e.walletClientType)===P.normalize(n.slug)&&"solana"===e.chainType&&"null"!==e.connectorType))||a||n.mobile.native||n.mobile.universal||W[n.slug]?.chainTypes.includes("solana")||(t=t.filter((e=>!e.includes("solana:")))),!t.length)return;let o=P.normalize(n.slug),r=D[n.slug],c=r?.image_url?.sm||n.image_url?.sm;t.some((e=>e.includes("eip155:")))&&i({id:o,label:n.name||o,source:"listing",listing:n,chainType:"ethereum",icon:c,url:n.homepage,chains:t}),t.some((e=>e.includes("solana:")))&&i({id:o,label:n.name||o,source:"listing",listing:n,chainType:"solana",icon:c,url:n.homepage,chains:t})})),this.includeWalletConnectQr&&l&&i({id:"wallet_connect_qr",label:"WalletConnect",source:"connector",connector:l,chainType:"ethereum",icon:E,url:void 0,chains:["eip155"]}),this.includeWalletConnectQrSolana&&a&&i({id:"wallet_connect_qr_solana",label:"WalletConnect",source:"connector",connector:a,chainType:"solana",icon:E,url:void 0,chains:["solana"]});let o=Array.from(t.values());o.forEach((e=>{let n=D[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(P.normalize(e),n)})),{wallets:o.slice().sort(((e,n)=>{let t=P.normalize(e.id),i=P.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"===i?i="binance":"universalprofiles"===i?i="universal_profile":"cryptocom-defi"===i?i="cryptocom":"bitkeep"===i&&(i="bitget_wallet");let l=r.has(t),a=r.has(i);return l&&a?r.get(t)-r.get(i):l?-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 Q=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"})]}),H=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 R=/*#__PURE__*/h.div.withConfig({displayName:"Header",componentId:"sc-9b65f2b6-0"})(["display:flex;justify-content:space-between;align-items:center;"]),V=/*#__PURE__*/h.button.withConfig({displayName:"CloseButton",componentId:"sc-9b65f2b6-1"})(["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);"]),G=/*#__PURE__*/h.div.withConfig({displayName:"WalletIconWithActiveIndicator",componentId:"sc-9b65f2b6-2"})(["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;}"]),Y=/*#__PURE__*/h.img.withConfig({displayName:"WalletIcon",componentId:"sc-9b65f2b6-3"})(["width:32px;height:32px;border-radius:0.25rem;object-fit:contain;"]),K=/*#__PURE__*/h.span.withConfig({displayName:"Chip",componentId:"sc-9b65f2b6-4"})(["display:flex;gap:0.25rem;align-items:center;padding:0.25rem 0.5rem;font-size:0.75rem;font-weight:500;line-height:1.125rem;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;}"]),J=/*#__PURE__*/h.div.withConfig({displayName:"ScrollContainer",componentId:"sc-9b65f2b6-5"})(["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;"," background-repeat:no-repeat;background-size:100% 32px,100% 16px;background-attachment:local,scroll;"],(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));function X({enabled:e=!0,walletList:n,walletChainType:t}){let i=v(),{connectors:l}=I(),{listings:r,loading:c}=k(e),s=t??i.appearance.walletChainType,d=n??i.appearance?.walletList,h=o((()=>new P(s,d)),[s,d]),{wallets:m,walletCount:p}=o((()=>h.getWallets(l,r)),[h,l,r]),[u,g]=a(""),w=o((()=>u?m.filter((e=>e.label.toLowerCase().includes(u.toLowerCase()))):m),[u,m]),[f,y]=a();return{selected:f,setSelected:y,search:u,setSearch:g,loadingListings:c,wallets:w,walletCount:p}}let Z=e=>!e||"string"!=typeof e&&(e instanceof S||e instanceof L);const ee=({index:i,style:l,data:a,recent:o})=>{let r=a.wallets[i],{walletChainType:c,handleWalletClick:s}=a,{t:d}=C(),h={...l,boxSizing:"border-box"};return r?/*#__PURE__*/e(le,{style:h,onClick:()=>s(r),children:[r.icon&&(r.connector&&!Z(r.connector)?/*#__PURE__*/n(G,{children:"string"==typeof r.icon?/*#__PURE__*/n(Y,{src:r.icon}):/*#__PURE__*/n(r.icon,{style:{width:"32px",height:"32px"}})}):"string"==typeof r.icon?/*#__PURE__*/n(Y,{src:r.icon}):/*#__PURE__*/n(r.icon,{style:{width:"32px",height:"32px"}})),/*#__PURE__*/n(re,{children:r.label}),o?/*#__PURE__*/e(t,{children:[/*#__PURE__*/n(K,{children:d("connectWallet.lastUsed")}),/*#__PURE__*/n(ae,{children:/*#__PURE__*/e(t,{children:["ethereum-only"===c&&/*#__PURE__*/n(Q,{}),"solana-only"===c&&/*#__PURE__*/n(H,{})]})})]}):/*#__PURE__*/n(ae,{children:!("ethereum-only"===c||"solana-only"===c)&&/*#__PURE__*/e(t,{children:[r.chains?.some((e=>e.startsWith("eip155")))&&/*#__PURE__*/n(Q,{}),r.chains?.some((e=>e.startsWith("solana")))&&/*#__PURE__*/n(H,{})]})})]}):null};var ne=({className:h,customDescription:p,connectOnly:u,preSelectedWalletId:x,hideHeader:k,...E})=>{let q=v(),{t:U}=C(),{connectors:F}=I(),M=E.walletChainType||q.appearance.walletChainType,$=E.walletList||q.appearance?.walletList,{onBack:R,onClose:V,app:G}=E,{selected:K,setSelected:J,qrUrl:ne,setQrUrl:de,connecting:he,uiState:me,errorCode:pe,wallets:ue,walletCount:ge,handleConnect:we,handleBack:fe,showSearchBar:ye,isInitialConnectView:ve,title:be,search:Ce,setSearch:xe}=function({onConnect:e,onBack:n,onClose:t,onConnectError:i,walletList:l,walletChainType:c,app:s}){let h=v(),{connectors:m}=I(),{t:p}=C(),{wallets:u,walletCount:g,search:w,setSearch:f,selected:y,setSelected:x}=X({enabled:T(l??[]),walletList:l,walletChainType:c}),[W,k]=a(),[z,S]=a(),[L,A]=a(),[B,E]=a(),j=!y&&!L&&!B,O=j&&(g>6||w.length>0),q=m.find((e=>"wallet_connect_v2"===e.connectorType)),U=r((async(n,t)=>{if(n){if(B?.connector===n&&"loading"===W)return void console.log("Already connecting to this wallet, skipping duplicate attempt");if(k("loading"),"string"==typeof n)return E({connector:n,name:t?.name??"Wallet",icon:t?.icon,id:t?.id,url:t?.url}),void window.open(n,"_blank");E({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 k("error"),S(void 0),void i?.(new N("Unable to connect wallet"));k("success"),S(void 0),_({address:t.address,client:t.walletClientType,appId:h.id}),setTimeout((()=>{e({connector:n,wallet:t})}),b)}catch(n){if(console.error("ERROR: ",{e:n}),n?.message?.includes("already pending for origin")||n?.message?.includes("wallet_requestPermissions"))return void console.log("Connection request already pending, maintaining loading state");k("error"),S(n?.privyErrorCode),i?.(n instanceof Error?n:new N(n?.message||"Unable to connect wallet"))}}}),[h.id,e,B,W]),F=r((()=>L?(k(void 0),S(void 0),E(void 0),void A(void 0)):B?(k(void 0),S(void 0),void E(void 0)):y?(k(void 0),S(void 0),E(void 0),void x(void 0)):"error"===W||"loading"===W?(k(void 0),S(void 0),void E(void 0)):void n?.()),[L,B,y,W,n]),M=o((()=>B?.connector===q&&L&&d&&B?.name?p("connectWallet.goToWallet",{walletName:B.name}):B?.connector===q&&L&&B?.name?p("connectWallet.scanToConnect",{walletName:B.name}):L&&B?.name?p(d?"connectWallet.goToWallet":"connectWallet.scanToConnect",{walletName:B.name}):"string"==typeof B?.connector?p("connectWallet.openOrInstall",{walletName:B.name}):y&&!B?p("connectWallet.selectNetwork"):B?null:p("connectWallet.selectYourWallet")),[B,L,y,q,p]);return{selected:y,setSelected:x,qrUrl:L,setQrUrl:A,connecting:B,uiState:W,errorCode:z,search:w,setSearch:f,wallets:u,walletCount:g,wc:q,isInitialConnectView:j,showSearchBar:O,title:M,handleConnect:U,handleBack:F,onClose:t,onConnect:e,app:s}}({...E,walletList:$,walletChainType:M}),We=F.find((e=>"wallet_connect_v2"===e.connectorType)),ke=F.find((e=>"walletconnect_solana"===e.walletBranding.id)),Te=c(null),_e=l({count:ue.length,getScrollElement:()=>Te.current,estimateSize:()=>56,overscan:6,gap:5}),ze=r((async e=>{let n="solana-only"!==M&&e.chains?.some((e=>e.startsWith("eip155"))),t="ethereum-only"!==M&&e.chains?.some((e=>e.startsWith("solana"))),i=()=>{let n=e.id;return W[n]||W[`${n}_wallet`]},l=n=>{let t=P.normalize(e.id);return F.find((e=>P.normalize(e.walletClientType)===t&&e.chainType===n&&!("ethereum"===e.chainType&&e instanceof S||"solana"===e.chainType&&e instanceof L)))},a=async()=>{if(!We||!e.listing)return!1;let n=D[e.listing.slug]?{...e.listing,...D[e.listing.slug]}:e.listing;return We.setWalletEntry(n,de),await We.resetConnection(e.id),await we(We,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0},o=async()=>!!ke&&!!e.listing&&(await ke.disconnect(),ke.wallet.setWalletEntry(e.listing,de),await new Promise((e=>setTimeout(e,100))),await we(ke,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0),r=async n=>{let t=(e=>{let n=i();if(n)return n.getMobileRedirect({isSolana:e,connectOnly:!!u,useUniversalLink:!1})})(n);return!!t&&(await we(t,{name:e.label,icon:e.icon,id:e.id,url:e.url}),!0)};if(n&&t)J(e);else{if(n&&!t){let n=l("ethereum");if(n&&!Z(n))return void await we(n,{name:e.label,icon:e.icon,id:e.id,url:e.url});if(d&&i()){if(await r(!1)||await a())return}else if(await a()||await r(!1))return}if(t&&!n){let n=l("solana");if(n&&!Z(n))return void await we(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(!Z(e.connector)){if(We&&"wallet_connect_v2"===e.connector?.connectorType)if(await We.resetConnection(e.id),"wallet_connect_qr"!==e.id&&e.listing){let n=D[e.listing.slug]?{...e.listing,...D[e.listing.slug]}:e.listing;We.setWalletEntry(n,de)}else We.setWalletEntry({id:"wallet_connect_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect",homepage:"",chains:["eip155"],mobile:{native:"",universal:void 0}},de);return ke&&"walletconnect_solana"===e.connector?.walletBranding.id&&(await ke.disconnect(),"wallet_connect_qr_solana"!==e.id&&e.listing?ke.wallet.setWalletEntry(e.listing,de):ke.wallet.setWalletEntry({id:"wallet_connect_solana_qr",name:"WalletConnect",rdns:"",slug:"wallet-connect-solana",homepage:"",chains:["solana"],mobile:{native:"",universal:void 0}},de),await new Promise((e=>setTimeout(e,100)))),void await we(e.connector,{name:e.label,icon:e.icon,id:e.id,url:e.url})}e.url&&await we(e.url,{name:e.label,icon:e.icon,id:e.id,url:e.url})}}),[We,ke,we,J,de,M,u,F]);return s((()=>{if(!x)return;let e=ue.find((({id:e})=>e===x));e&&ze(e).catch(console.error)}),[x]),/*#__PURE__*/e(O,{className:h,children:[/*#__PURE__*/n(O.Header,{icon:k&&ve?void 0:he&&!ne||ne&&d&&he?.icon?he.icon:he?void 0:B,iconVariant:he&&!ne||ne&&d?"loading":void 0,iconLoadingStatus:he&&!ne||ne&&d?{success:"success"===me,fail:"error"===me}:void 0,title:k&&ve?void 0:he&&!ne?U("connectWallet.waitingForWallet",{walletName:he.name}):ne&&d?U("connectWallet.waitingForWallet",{walletName:he?.name??"connection"}):be,subtitle:k&&ve?void 0:he&&!ne&&"string"==typeof he.connector?U("connectWallet.installAndConnect",{walletName:he.name}):he&&!ne&&"string"!=typeof he.connector?"error"===me?pe===A.NO_SOLANA_ACCOUNTS?`The connected wallet has no Solana accounts. Please add a Solana account in ${he.name} and try again.`:U("connectWallet.tryConnectingAgain"):U("connectionStatus.connectOneWallet"):ve?p??(G?U("connectWallet.connectToAccount",{appName:G.name}):null):null,showBack:!!R||!ve,showClose:!0,onBack:R||fe,onClose:V}),/*#__PURE__*/e(O.Body,{ref:Te,$colorScheme:q.appearance.palette.colorScheme,style:{marginBottom:ne?"0.5rem":void 0},children:[ye&&/*#__PURE__*/n(te,{children:/*#__PURE__*/e(y,{style:{background:"transparent"},children:[/*#__PURE__*/n(z,{children:/*#__PURE__*/n(i,{})}),/*#__PURE__*/n("input",{className:"login-method-button",type:"text",placeholder:U("connectWallet.searchPlaceholder",{count:String(ge)}),onChange:e=>xe(e.target.value),value:Ce})]})}),ne&&d&&"loading"===me&&/*#__PURE__*/e("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:[/*#__PURE__*/n(m,{variant:"primary",onClick:()=>window.open(ne.universal??ne.native,"_blank"),style:{width:"100%"},children:U("connectWallet.openInApp")}),/*#__PURE__*/n(ce,{value:ne.universal??ne.native,iconOnly:!0,children:"Copy link"})]}),ne&&!d&&"loading"===me&&/*#__PURE__*/n("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",gap:"1rem"},children:/*#__PURE__*/n(ce,{value:ne.universal??ne.native,iconOnly:!0,children:U("connectWallet.copyLink")})}),ne&&!d&&/*#__PURE__*/n(f,{size:280,url:ne.universal??ne.native,squareLogoElement:he?.icon?"string"==typeof he.icon?e=>/*#__PURE__*/n("svg",{...e,children:/*#__PURE__*/n("image",{href:he.icon,height:e.height,width:e.width})}):he.icon:j}),ne&&!d&&he?.url&&("binance"===he.id||"binanceus"===he.id||"binance-defi"===he.id)&&/*#__PURE__*/e(se,{children:[/*#__PURE__*/e("span",{children:["Don't have ",he.name,"? "]}),/*#__PURE__*/n(g,{href:he.url,target:"_blank",size:"sm",children:"Download here"})]}),/*#__PURE__*/e(ie,{children:[he&&!ne&&"string"==typeof he.connector&&/*#__PURE__*/e(le,{onClick:()=>window.open(he.connector,"_blank"),children:[he.icon&&("string"==typeof he.icon?/*#__PURE__*/n(Y,{src:he.icon}):/*#__PURE__*/n(he.icon,{})),/*#__PURE__*/n(re,{children:he.name})]}),K?.chains.some((e=>e.startsWith("eip155")))&&!he&&/*#__PURE__*/e(le,{onClick:()=>ze({...K,chains:K.chains.filter((e=>e.startsWith("eip155")))}),children:[K.icon&&("string"==typeof K.icon?/*#__PURE__*/n(Y,{src:K.icon}):/*#__PURE__*/n(K.icon,{})),/*#__PURE__*/n(re,{children:K.label}),/*#__PURE__*/n(ae,{children:/*#__PURE__*/n(Q,{})})]}),K?.chains.some((e=>e.startsWith("solana")))&&!he&&/*#__PURE__*/e(le,{onClick:()=>ze({...K,chains:K.chains.filter((e=>e.startsWith("solana")))}),children:[K.icon&&("string"==typeof K.icon?/*#__PURE__*/n(Y,{src:K.icon}):/*#__PURE__*/n(K.icon,{})),/*#__PURE__*/n(re,{children:K.label}),/*#__PURE__*/n(ae,{children:/*#__PURE__*/n(H,{})})]}),ve&&/*#__PURE__*/e(t,{children:[!(ge>0)&&/*#__PURE__*/n(oe,{children:U("connectWallet.noWalletsFound")}),ge>0&&!ne&&/*#__PURE__*/n("div",{style:{maxHeight:56*Math.min(ue.length,5)+5,width:"100%"},children:/*#__PURE__*/n("div",{style:{height:`${_e.getTotalSize()}px`,width:"100%",position:"relative"},children:_e.getVirtualItems().map((e=>/*#__PURE__*/n(ee,{index:e.index,style:{position:"absolute",top:0,left:0,height:`${e.size}px`,transform:`translateY(${e.start}px)`},data:{wallets:ue,walletChainType:M,handleWalletClick:ze}},e.key)))})})]})]})]}),/*#__PURE__*/e(O.Footer,{children:[he&&!ne&&"string"!=typeof he.connector&&"error"===me&&/*#__PURE__*/n(O.Actions,{children:/*#__PURE__*/n(m,{style:{width:"100%",alignItems:"center"},variant:"error",onClick:()=>we(he.connector,{name:he.name,icon:he.icon,id:he.id,url:he.url}),children:U("connectWallet.retry")})}),!!(G&&G.legal.privacyPolicyUrl&&G.legal.termsAndConditionsUrl)&&/*#__PURE__*/n(w,{app:G,alwaysShowImplicitConsent:!0}),/*#__PURE__*/n(O.Watermark,{})]})]})};let te=/*#__PURE__*/h.div.withConfig({displayName:"StickySearchContainer",componentId:"sc-5a8fc7d8-0"})(["position:sticky;margin-top:-3px;padding-top:3px;top:-3px;z-index:1;background:var(--privy-color-background);padding-bottom:calc(var(--screen-space) / 2);"]),ie=/*#__PURE__*/h.div.withConfig({displayName:"WalletListContainer",componentId:"sc-5a8fc7d8-1"})(["display:flex;flex-direction:column;gap:","px;"],5),le=/*#__PURE__*/h.button.withConfig({displayName:"Button",componentId:"sc-5a8fc7d8-2"})(["&&{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);}"]),ae=/*#__PURE__*/h.span.withConfig({displayName:"ButtonBadge",componentId:"sc-5a8fc7d8-3"})(["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;}"]),oe=/*#__PURE__*/h.div.withConfig({displayName:"EmptyContainer",componentId:"sc-5a8fc7d8-4"})(["height:60px;display:flex;align-items:center;justify-content:center;text-align:center;"]),re=/*#__PURE__*/h.span.withConfig({displayName:"WalletName",componentId:"sc-5a8fc7d8-5"})(["text-overflow:ellipsis;white-space:nowrap;color:var(--privy-color-foreground);font-weight:400;flex:1;"]),ce=/*#__PURE__*/h($).withConfig({displayName:"StyledCopyableText",componentId:"sc-5a8fc7d8-6"})(["&&{margin:0.5rem auto 0 auto;}"]),se=/*#__PURE__*/h.div.withConfig({displayName:"BinanceDownloadMessage",componentId:"sc-5a8fc7d8-7"})(["text-align:center;margin-top:1rem;font-size:0.875rem;font-weight:400;color:var(--privy-color-foreground-3);"]);export{$ as C,R as H,J as S,Y as W,K as a,V as b,P as c,ee as d,ne as i,X as u};