UNPKG

@privy-io/react-auth

Version:

React client for the Privy Auth API

24 lines (23 loc) • 20.5 kB
import{jsx as e,jsxs as t,Fragment as i}from"react/jsx-runtime";import a from"@heroicons/react/24/outline/UserCircleIcon";import l,{useState as r,useEffect as n,useRef as o,useMemo as s}from"react";import{styled as c}from"styled-components";import{T as d,M as p,B as h}from"./ModalHeader-BnVmXtvG.mjs";import{u}from"./context-DLtU3JQy.mjs";import{A as g,C as m,B as f,H as y,r as w,D as v,F as C,G as b,s as k,I as S,c as T,J as M,K as x}from"./useActiveWallet-CvP7iYvj.mjs";import{u as A}from"./internal-context-Z-fyxadS.mjs";import{u as L,a as W,i as I}from"./privy-context-DrMxzgOR.mjs";import{a as E,t as P}from"./index-YDEix4mU.mjs";import{u as N,b as j,c as D}from"./ConnectWalletView-pxEyo8WM.mjs";import{z as O}from"./use-export-wallet-_wu5ex5t.mjs";import{Mail as R,Smartphone as V,UserCircle as _}from"lucide-react";import{C as F}from"./ConnectEmailForm-bgA9z3L3.mjs";import{C as U}from"./Chip-D2-wZOHJ.mjs";import{F as $}from"./farcaster-DPlSjvF5.mjs";import{toObjectKeys as z}from"@privy-io/js-sdk-core";import H from"@heroicons/react/24/outline/QuestionMarkCircleIcon";import G from"@heroicons/react/24/outline/FingerPrintIcon";import{L as B}from"./Link-DJ5gq9Di.mjs";import{C as q}from"./ConnectPhoneForm-DP4LRtUG.mjs";import{T as K,a as J,I as Q,S as Y,L as Z,G as X,b as ee,D as te,A as ie}from"./twitter-BoAxhlj6.mjs";import{T as ae,L as le}from"./twitch-5IOe4sIQ.mjs";import{T as re}from"./telegram-B-JqnkqZ.mjs";import{W as ne}from"./WalletOverflowButton-CPDxFP5w.mjs";import{S as oe}from"./ScreenLayout-D1p_ntex.mjs";const se=()=>{let t=u(),i=t?.appearance?.logo,a=`${t?.name} logo`,r={maxHeight:"90px",maxWidth:"180px"};return i?"string"==typeof i?/*#__PURE__*/e("img",{src:i,alt:a,style:r}):"svg"===i.type||"img"===i.type?/*#__PURE__*/l.cloneElement(i,{alt:a,style:r}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},ce=c.div` display: flex; flex-direction: column; align-items: center; padding: 24px 0; flex-grow: 1; justify-content: center; `,de=({name:t,logoUrl:i,size:a="38px"})=>"string"==typeof i?/*#__PURE__*/e("img",{src:i,alt:`${t??"Provider app"} logo`,style:{width:a,height:a,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}): /*#__PURE__*/e("span",{}),pe=({appId:a})=>{let[l,o]=r(void 0),{startCrossAppAuthFlow:s,authenticated:c}=L(),{data:d}=W(),{client:p}=A();return n((()=>{(async()=>{p&&o(await p.getCrossAppProviderDetails(a))})()}),[p]),/*#__PURE__*/e(g,{onClick:()=>s({appId:a,action:c?"link":"login",disableSignup:d?.login?.disableSignup}),disabled:!l,children:l?/*#__PURE__*/t(i,{children:[/*#__PURE__*/e(m,{$fullSize:!0,children:/*#__PURE__*/e(de,{name:l.name,logoUrl:l.icon_url||void 0,size:"32px"})}),l.name]}):/*#__PURE__*/e(f,{})})},he=({isEditable:a,setIsEditable:l,defaultValue:r})=>{let n=o(null);/*#__PURE__*/return t(i,{children:[/*#__PURE__*/e(y,{$if:!a,children:/*#__PURE__*/e(F,{ref:n,defaultValue:r})}),/*#__PURE__*/e(y,{$if:a,children:/*#__PURE__*/t(g,{onClick:()=>{l(),setTimeout((()=>{n.current?.focus()}),0)},children:[/*#__PURE__*/e(m,{children:/*#__PURE__*/e(R,{})}),"Continue with Email"]})})]})},ue=()=>{let[i,a]=r(!1),{currentScreen:l,navigate:n,setModalData:o,data:s}=W(),{enabled:c,token:d}=E(),{initLoginWithFarcaster:p}=A(),{accountType:h}=w();/*#__PURE__*/return t(g,{onClick:async()=>{a(!0);try{c&&!d?(o({captchaModalData:{callback:e=>p(e,s?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:"FarcasterConnectStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),n("CaptchaScreen")):(await p(d,s?.login?.disableSignup),n("FarcasterConnectStatusScreen"))}catch(e){o({errorModalData:{error:e,previousScreen:l||"LandingScreen"}}),n("ErrorScreen")}finally{a(!1)}},disabled:!1,children:[/*#__PURE__*/e($,{width:32,height:32})," Farcaster",i&&/*#__PURE__*/e(f,{}),"farcaster"===h&&/*#__PURE__*/e(ge,{color:"gray",children:"Recent"})]})};let ge=c(U)` margin-left: auto; `;const me=({...i})=>/*#__PURE__*/t("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...i,children:[/*#__PURE__*/t("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/e("path",{d:"M22.1673 8.24075V16.3642C22.1673 17.3256 21.3421 18.105 20.3241 18.105H17.0028M22.1673 8.24075C22.1673 7.27936 21.3421 6.5 20.3241 6.5H11.5302M22.1673 8.24075V8.42852C22.1673 9.03302 21.8352 9.59423 21.2901 9.91105L15.1463 13.4818C14.5539 13.8261 13.8067 13.8261 13.2143 13.4818L10.1621 11.5401",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"}),/*#__PURE__*/e("path",{d:"M3.12913 6.64816C0.508085 12.9507 3.49251 20.1847 9.79504 22.8057L11.5068 23.5176C12.4522 23.9108 13.7783 23.2222 14.1714 22.2768L14.6054 21.2333C14.7687 20.8406 14.6438 20.3871 14.3024 20.1334L11.2872 17.8927C10.9878 17.6702 10.5843 17.6488 10.2632 17.8384L9.11575 18.5156C8.78274 18.7121 8.3597 18.6844 8.07552 18.4221C5.94293 16.4542 4.77629 13.6264 4.90096 10.7273C4.91757 10.3409 5.19796 10.023 5.57269 9.92753L6.86381 9.59869C7.22522 9.50664 7.49627 9.20696 7.55169 8.83815L8.10986 5.12321C8.17306 4.70259 7.94188 4.29293 7.54915 4.1296L6.50564 3.69564C5.56026 3.30248 4.23416 3.99103 3.84101 4.9364L3.12913 6.64816Z",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})]}),/*#__PURE__*/e("defs",{children:/*#__PURE__*/e("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/e("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),fe=({chainType:i,withPadding:a})=>{let l="";return l="ethereum-only"===i||"ethereum-and-solana"===i?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/e(v,{$withPadding:a,children:/*#__PURE__*/t(C,{children:[/*#__PURE__*/e(H,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/e("h3",{children:"No wallets available"}),/*#__PURE__*/t("p",{children:["Please download an external wallet provider, like ",l,"."]})]})},"empty-wallet-state")},ye=()=>{let{enabled:i,token:a}=E(),{navigate:l,setModalData:r,data:n}=W(),o=u(),{initLoginWithPasskey:c}=A(),d=()=>{o.loginConfig.passkeysForSignupEnabled?l("PasskeySelectSignupOrLogin"):(async()=>{i&&!a?(r({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>c({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:"PasskeyStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),l("CaptchaScreen")):(await c({withPrivyUi:!0,captchaToken:a}),r({passkeyAuthModalData:{passkeySignupFlow:!1}}),l("PasskeyStatusScreen"))})()};return 0===s((()=>{let e=n?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(o.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[o.loginMethods,n?.login])?/*#__PURE__*/t(g,{onClick:d,children:[/*#__PURE__*/e(G,{})," Continue with passkey"]}):/*#__PURE__*/e(B,{as:"button",onClick:d,size:"sm",variant:"navigation",style:{width:"100%",justifyContent:"center"},children:"I have a passkey"})},we=({isEditable:a,setIsEditable:l,defaultValue:r})=>{let n=o(null),{authenticated:s}=L(),{navigate:c,setModalData:d,currentScreen:p,data:h}=W(),{initLoginWithSms:f}=A(),{enabled:w,token:v}=E(),{whatsAppEnabled:C}=u();/*#__PURE__*/return t(i,{children:[/*#__PURE__*/e(y,{$if:!a,children:/*#__PURE__*/e(q,{ref:n,onSubmit:async function({qualifiedPhoneNumber:e}){if(!w||v||s)try{await f({phoneNumber:e,captchaToken:v,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),c("AwaitingPasswordlessCodeScreen")}catch(e){d({errorModalData:{error:e,previousScreen:p||"LandingScreen"}}),c("ErrorScreen")}else d({captchaModalData:{callback:t=>f({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:h?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:"AwaitingPasswordlessCodeScreen",onErrorNavigateTo:"ErrorScreen"}}),c("CaptchaScreen")},defaultValue:r})}),/*#__PURE__*/e(y,{$if:a,children:/*#__PURE__*/t(g,{onClick:()=>{l(),setTimeout((()=>{n.current?.focus()}),0)},children:[/*#__PURE__*/e(m,{children:/*#__PURE__*/e(V,{})}),"Continue with ",C?"WhatsApp":"SMS"]})})]})};let ve={apple:{logo:ie,displayName:"Apple"},discord:{logo:te,displayName:"Discord"},github:{logo:ee,displayName:"GitHub"},google:{logo:X,displayName:"Google"},linkedin:{logo:Z,displayName:"LinkedIn"},spotify:{logo:Y,displayName:"Spotify"},instagram:{logo:Q,displayName:"Instagram"},twitter:{logo:J,displayName:"Twitter"},tiktok:{logo:K,displayName:"TikTok"},line:{logo:le,displayName:"LINE"},twitch:{logo:ae,displayName:"Twitch"}};const Ce=({provider:i})=>{let{enabled:a,token:l}=E(),{navigate:n,setModalData:o,data:c}=W(),[d,p]=r(!1),h=u(),{initLoginWithOAuth:f}=A(),{accountType:y}=w(),v=s((()=>y&&"guest"!==y&&"authorization_key"!==y&&"cross_app"!==y?P(y):null),[y]),{displayName:C,logo:b}=s((()=>{if(I(i)){let t=h.customOAuthProviders.find((e=>e.provider===i)),a=t.provider_icon_url,l=t.provider_display_name;return{displayName:l,logo:({style:t})=>/*#__PURE__*/e("img",{alt:`${l} logo`,src:a,style:t})}}return ve[i]}),[i,h.customOAuthProviders]);/*#__PURE__*/return t(g,{onClick:()=>{p(!0),setTimeout((()=>{p(!1)}),2e3),a&&!l?(o({captchaModalData:{callback:e=>f(i,e,c?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),n("CaptchaScreen")):f(i,void 0,c?.login?.disableSignup)},disabled:d,children:[/*#__PURE__*/e(m,{$fullSize:!0,children:/*#__PURE__*/e(b,{style:{width:"32px",height:"32px"}})}),C,v?.loginMethod===i&&/*#__PURE__*/e(be,{color:"gray",children:"Recent"})]})};let be=c(U)` margin-left: auto; `;const ke=()=>{let{enabled:i,token:a}=E(),{navigate:l,setModalData:n,data:o}=W(),[s,c]=r(!1),{initLoginWithTelegram:d}=A(),{accountType:p}=w();async function h(e){try{await d(e,o?.login?.disableSignup),n({telegramAuthModalData:{seamlessAuth:!1}}),l("TelegramAuthScreen")}catch(e){console.error(e),c(!1)}}/*#__PURE__*/return t(g,{onClick:async function(){if(c(!0),i&&!a)return n({captchaModalData:{callback:h,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),void l("CaptchaScreen");await h(a)},disabled:s,children:[/*#__PURE__*/e(re,{width:32,height:32}),"Telegram","telegram"===p&&/*#__PURE__*/e(Se,{color:"gray",children:"Recent"})]})};let Se=c(U)` margin-left: auto; `;const Te=({onClick:i,text:a,icon:l})=>/*#__PURE__*/t(g,{onClick:i,children:[/*#__PURE__*/e(m,{children:l}),/*#__PURE__*/e(b,{children:a})]}),Me=({connectOnly:a})=>{let{closePrivyModal:l}=A(),{data:o,setModalData:c,onUserCloseViaDialogOrKeybindRef:p,navigate:h}=W(),g=u(),m=o?.login,f=g.appearance.walletList,y=m?.walletChainType??g.appearance.walletChainType,{accountType:v,walletClientType:C,chainType:b}=w(),T=s((()=>v&&"guest"!==v&&"authorization_key"!==v&&"cross_app"!==v?P(v):null),[v]),{email:M,sms:x,google:L,twitter:E,discord:O,github:R,spotify:V,instagram:_,tiktok:F,line:U,twitch:$,linkedin:H,apple:G,wallet:B,farcaster:q,telegram:K}=s((()=>m?.loginMethods?z(m.loginMethods,!0):null),[m])??g.loginMethods,{wallets:J}=N({enabled:k(B?f:[]),walletList:f,walletChainType:y}),Q=g.customOAuthProviders,Y=g.crossAppProviders,{passkey:Z}=g.loginMethods,X=[M&&"email",x&&"sms",L&&"google",E&&"twitter",O&&"discord",R&&"github",V&&"spotify",_&&"instagram",F&&"tiktok",U&&"line",$&&"twitch",H&&"linkedin",G&&"apple",q&&"farcaster",K&&"telegram",...Q.map((e=>e.provider)),...Y].filter((e=>!!e)),ee=X.length>0,te=s((()=>B&&!ee?"web3-first":B&&g?.appearance.loginGroupPriority||"web2-first"),[B,ee,g?.appearance.loginGroupPriority]),ie=g?.appearance.hideDirectWeb2Inputs,[ae,le]=r("default"),[re,ce]=r(Ee({mostRecentlyUsedAccountType:v,smsAvailable:x,emailAvailable:M,prefilledType:m?.prefill?.type}));n((()=>{ce(Ee({mostRecentlyUsedAccountType:v,smsAvailable:x,emailAvailable:M,prefilledType:m?.prefill?.type}))}),[M,x,v]);let de=()=>{l({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{le("default")}),150)};p.current=de;let ge=[];C&&B?ge.push(C):T?.loginMethod&&X.includes(T.loginMethod)&&ge.push(T.loginMethod);let me=t=>{if("email"===t)/*#__PURE__*/return e(he,{isEditable:"email"===re,setIsEditable:()=>{ce("email")},defaultValue:"email"===m?.prefill?.type?m.prefill.value:void 0},t);if("sms"===t)/*#__PURE__*/return e(we,{isEditable:"sms"===re,setIsEditable:()=>{ce("sms")},defaultValue:"phone"===m?.prefill?.type?m.prefill.value:void 0},t);if("apple"===t)/*#__PURE__*/return e(Ce,{provider:"apple"},t);if("discord"===t)/*#__PURE__*/return e(Ce,{provider:"discord"},t);if("farcaster"===t)/*#__PURE__*/return e(ue,{},t);if("github"===t)/*#__PURE__*/return e(Ce,{provider:"github"},t);if("google"===t)/*#__PURE__*/return e(Ce,{provider:"google"},t);if("linkedin"===t)/*#__PURE__*/return e(Ce,{provider:"linkedin"},t);if("tiktok"===t)/*#__PURE__*/return e(Ce,{provider:"tiktok"},t);if("line"===t)/*#__PURE__*/return e(Ce,{provider:"line"},t);if("twitch"===t)/*#__PURE__*/return e(Ce,{provider:"twitch"},t);if("spotify"===t)/*#__PURE__*/return e(Ce,{provider:"spotify"},t);if("instagram"===t)/*#__PURE__*/return e(Ce,{provider:"instagram"},t);if("twitter"===t)/*#__PURE__*/return e(Ce,{provider:"twitter"},t);if("telegram"===t)/*#__PURE__*/return e(ke,{},t);if(I(t))/*#__PURE__*/return e(Ce,{provider:t},t);if(t.startsWith("privy:")){let i=t.split(":")[1];if(!i)throw Error("Invalid cross-app provider format. App ID missing.");/*#__PURE__*/return e(pe,{appId:i},t)}let i=J.findIndex((({id:e})=>e===j.normalize(t))),l="solana"===b?"solana-only":"ethereum-only";/*#__PURE__*/return e(D,{recent:!0,index:i,data:{wallets:J,walletChainType:l,handleWalletClick(e){c((t=>({...t,externalConnectWallet:{walletList:f,walletChainType:l,preSelectedWalletId:e.id}}))),h(a?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}})},ve=J.filter((e=>e.id!==j.normalize(C||""))),be=ve.map(((t,i)=>/*#__PURE__*/e(D,{index:i,data:{walletChainType:y,wallets:ve,handleWalletClick(e){c((t=>({...t,externalConnectWallet:{walletList:f,walletChainType:y,preSelectedWalletId:e.id}}))),h(a?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},t.id))),Se=X.filter((e=>e!==T?.loginMethod)).flatMap(me),Me=ge.flatMap(me);"web3-first"===te&&"default"===ae?be.unshift(...Me):"web2-first"===te&&Se.unshift(...Me);let Pe="web2-overflow"===ae?()=>le("default"):void 0,Ne=X.filter((e=>"email"!==e&&"sms"!==e)),je=Le({priority:te,email:M,sms:x,social:Ne}),De=We({priority:te,email:M,sms:x,social:Ne}),Oe=/*#__PURE__*/e(ne,{text:Ie({priority:te}),onClick:()=>{c({...o,externalConnectWallet:{walletChainType:m?.walletChainType??g.appearance.walletChainType}}),h(a?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}),Re=/*#__PURE__*/e(Te,{text:je,icon:De,onClick:()=>le("web2-overflow")}),Ve=ie?0:1,_e=B&&be.length>0,Fe=0===Se.length&&B&&0===be.length,Ue=5-(_e?1:0),$e="default"===ae&&g?.appearance.logo,ze="default"===ae&&g.appearance.loginMessage;/*#__PURE__*/return t(oe,{title:g.appearance.landingHeader,icon:$e?/*#__PURE__*/e(se,{}):void 0,iconVariant:$e?"logo":void 0,onClose:de,showClose:!0,onBack:Pe,showBack:!!Pe,helpText:g||Z&&"default"===ae?/*#__PURE__*/t(i,{children:[Z&&"default"===ae&&!g.globalDisablePasskeys&&/*#__PURE__*/e(ye,{}),g&&/*#__PURE__*/e(d,{app:g})]}):void 0,watermark:!0,children:[ze&&("string"==typeof g.appearance.loginMessage?/*#__PURE__*/e(xe,{children:g.appearance.loginMessage}):/*#__PURE__*/e(Ae,{children:g.appearance.loginMessage})),/*#__PURE__*/e(S,{$colorScheme:g.appearance.palette.colorScheme,children:"default"===ae&&"web2-first"===te?/*#__PURE__*/t(i,{children:[Se.length>Ue?Se.slice(0,Ue-1):Se,Se.length>Ue&&Re,_e&&Oe,Fe&&/*#__PURE__*/e(fe,{chainType:g.appearance.walletChainType})]}):"default"===ae&&"web3-first"===te?/*#__PURE__*/t(i,{children:[B&&/*#__PURE__*/t(i,{children:[be.length>Ue?be.slice(0,Ue-1):be,be.length>Ue&&Oe]}),Se.length>Ve&&Re,Se.length===Ve&&Se[0],Fe&&/*#__PURE__*/e(fe,{chainType:g.appearance.walletChainType})]}):"web2-overflow"===ae?/*#__PURE__*/e(i,{children:"web3-first"===te?Se:Se.slice(3)}):null})]})};let xe=c.div` text-align: center; font-size: 14px; margin-bottom: 24px; `,Ae=c.div` margin-bottom: 24px; `,Le=({priority:e,email:t,sms:i,social:a})=>"web2-first"===e?"Other socials":t&&i&&a.length>0||t&&a.length>0?"Log in with email or socials":i&&a.length>0?"Log in with sms or socials":t&&i?"Continue with email or sms":t?"Continue with email":i?"Continue with sms":"Log in with a social account",We=({priority:t,email:i,sms:a,social:l})=>"web2-first"===t||l.length>0?/*#__PURE__*/e(_,{}):i&&a?/*#__PURE__*/e(me,{}):i?/*#__PURE__*/e(R,{}):a?/*#__PURE__*/e(V,{}):null,Ie=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const Ee=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:i,prefilledType:a})=>i&&("email"===e&&"phone"!==a||"email"===a)||!t||"phone"!==e&&"phone"!==a?"email":"sms",Pe=({connectOnly:l})=>{let{closePrivyModal:o,connectors:c}=A(),{data:g,setModalData:m,onUserCloseViaDialogOrKeybindRef:f,navigate:y}=W(),v=u(),C=v.appearance.palette.colorScheme,{accountType:b,walletClientType:k}=w(),L=s((()=>b&&"guest"!==b&&"authorization_key"!==b&&"cross_app"!==b?P(b):null),[b]),I=v.loginMethodsAndOrder?.primary??[],E=v.loginMethodsAndOrder?.overflow??[],N=s((()=>[...I,...E]),[I,E]),R=v.loginMethods.passkey,V=g?.login,_=[];k&&N.includes(k)?_.push(k):b&&N.includes(L?.loginMethod)&&_.push(L?.loginMethod);let[F,U]=r("default"),[$,z]=r(Ee({mostRecentlyUsedAccountType:b,smsAvailable:N.includes("sms"),emailAvailable:N.includes("email"),prefilledType:V?.prefill?.type}));n((()=>{z(Ee({mostRecentlyUsedAccountType:b,smsAvailable:N.includes("sms"),emailAvailable:N.includes("email"),prefilledType:V?.prefill?.type}))}),[N,b]),n((()=>{"phone"===b&&z("sms");let e=N.indexOf("sms"),t=N.indexOf("email");e>-1&&e<t&&z("sms")}),[b,I,E]);let H=()=>{o({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{U("default")}),150)};f.current=H;let{listings:G}=T(),B=t=>{if("email"===t)/*#__PURE__*/return e(he,{isEditable:"email"===$,setIsEditable:()=>{z("email")},defaultValue:"email"===V?.prefill?.type?V.prefill.value:void 0},t);if("sms"===t)/*#__PURE__*/return e(we,{isEditable:"sms"===$,setIsEditable:()=>{z("sms")},defaultValue:"phone"===V?.prefill?.type?V.prefill.value:void 0},t);if("apple"===t)/*#__PURE__*/return e(Ce,{provider:"apple"},t);if("discord"===t)/*#__PURE__*/return e(Ce,{provider:"discord"},t);if("farcaster"===t)/*#__PURE__*/return e(ue,{},t);if("github"===t)/*#__PURE__*/return e(Ce,{provider:"github"},t);if("google"===t)/*#__PURE__*/return e(Ce,{provider:"google"},t);if("linkedin"===t)/*#__PURE__*/return e(Ce,{provider:"linkedin"},t);if("spotify"===t)/*#__PURE__*/return e(Ce,{provider:"spotify"},t);if("instagram"===t)/*#__PURE__*/return e(Ce,{provider:"instagram"},t);if("tiktok"===t)/*#__PURE__*/return e(Ce,{provider:"tiktok"},t);if("line"===t)/*#__PURE__*/return e(Ce,{provider:"line"},t);if("twitch"===t)/*#__PURE__*/return e(Ce,{provider:"twitch"},t);if("twitter"===t)/*#__PURE__*/return e(Ce,{provider:"twitter"},t);if("telegram"===t)/*#__PURE__*/return e(ke,{},t);if(t.startsWith("privy:"))/*#__PURE__*/return e(pe,{appId:t.replace("privy:","")},t);let i=v.appearance.walletChainType,a=new j(i,[t]).getWallets(c,G);return a.wallets.map(((t,r)=>/*#__PURE__*/e(D,{index:r,data:{wallets:a.wallets,walletChainType:i,handleWalletClick(e){m((t=>({...t,externalConnectWallet:{walletList:N,walletChainType:i,preSelectedWalletId:e.id}}))),y(l?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},t.id+r)))},q=_.flatMap(B),K=I.filter((e=>e!==k&&e!==L?.loginMethod)).flatMap(B),J=E.filter((e=>e!==k&&e!==L?.loginMethod)).flatMap(B),[Q,Y]=O([...q,...K,...J],Ne({primary:K.length+q.length,overflow:J.length}));/*#__PURE__*/return t(i,{children:[/*#__PURE__*/e(p,{title:v.appearance.landingHeader,onClose:H,backFn:"default"===F?void 0:()=>{U("default")}}),"default"===F&&/*#__PURE__*/e(je,{}),"default"===F&&("string"==typeof v.appearance.loginMessage?/*#__PURE__*/e(M,{children:v.appearance.loginMessage}):v.appearance.loginMessage),/*#__PURE__*/e(x,{style:{overflow:"hidden"},children:/*#__PURE__*/t(S,{$colorScheme:C,children:["default"===F&&/*#__PURE__*/t(i,{children:[Q,Y.length>0&&/*#__PURE__*/e(Te,{text:"More options",icon:/*#__PURE__*/e(a,{}),onClick:()=>U("overflow")})]}),"overflow"===F&&/*#__PURE__*/e(i,{children:Y}),R&&"default"===F&&/*#__PURE__*/e(ye,{})]})}),v&&/*#__PURE__*/e(d,{app:v}),/*#__PURE__*/e(h,{})]})};let Ne=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,je=c((t=>{let i=u();return i?.appearance.logo?/*#__PURE__*/e(ce,{...t,children:/*#__PURE__*/e(se,{})}):null}))` margin-bottom: 16px; `;export{Pe as C,Me as L};