@privy-io/react-auth
Version:
React client for the Privy Auth API
24 lines (23 loc) • 22.6 kB
JavaScript
"use strict";var e=require("react/jsx-runtime"),t=require("@heroicons/react/24/outline/UserCircleIcon"),i=require("react"),a=require("styled-components"),l=require("./ModalHeader-C5Wuo3-1.js"),r=require("./context-Cg3IEi80.js"),n=require("./useActiveWallet-BfMD5hzE.js"),s=require("./internal-context-BJv4f_bO.js"),o=require("./privy-context-CrM9_s6G.js"),d=require("./index-DchMyzt9.js"),c=require("./ConnectWalletView-C6ISoYJv.js"),p=require("./use-export-wallet-_EIyxyle.js"),u=require("lucide-react"),h=require("./ConnectEmailForm-CnoGdJHM.js"),g=require("./Chip-C6r7fZiR.js"),y=require("./farcaster-CWHXGAib.js"),m=require("@privy-io/js-sdk-core"),f=require("@heroicons/react/24/outline/QuestionMarkCircleIcon"),x=require("@heroicons/react/24/outline/FingerPrintIcon"),j=require("./Link-BdtTp2J4.js"),w=require("./ConnectPhoneForm-D3q0wloY.js"),v=require("./twitter-CJSxxOMI.js"),C=require("./twitch-BNvhZb2Y.js"),b=require("./telegram-D3O0_F1a.js"),S=require("./WalletOverflowButton-BMn1cJfA.js"),k=require("./ScreenLayout-C4QHZMbl.js");function M(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var T=/*#__PURE__*/M(t),L=/*#__PURE__*/M(i),A=/*#__PURE__*/M(f),W=/*#__PURE__*/M(x);const P=()=>{let t=r.useAppConfig(),i=t?.appearance?.logo,a=`${t?.name} logo`,l={maxHeight:"90px",maxWidth:"180px"};return i?"string"==typeof i?/*#__PURE__*/e.jsx("img",{src:i,alt:a,style:l}):"svg"===i.type||"img"===i.type?/*#__PURE__*/L.default.cloneElement(i,{alt:a,style:l}):(console.warn("`config.appearance.logo` must be a string, or an SVG / IMG element. Nothing will be rendered."),null):null},I=a.styled.div`
display: flex;
flex-direction: column;
align-items: center;
padding: 24px 0;
flex-grow: 1;
justify-content: center;
`,E=({name:t,logoUrl:i,size:a="38px"})=>{let l=`${t??"Provider app"} logo`;return"string"==typeof i?/*#__PURE__*/e.jsx("img",{src:i,alt:l,style:{width:a,height:a,maxHeight:"90px",maxWidth:"180px",borderRadius:"8px"}}):
/*#__PURE__*/e.jsx("span",{})},F=({appId:t})=>{let[a,l]=i.useState(void 0),{startCrossAppAuthFlow:r,authenticated:d}=o.usePrivyContext(),{data:c}=o.usePrivyModal(),{client:p}=s.usePrivyInternal();return i.useEffect((()=>{(async()=>{p&&l(await p.getCrossAppProviderDetails(t))})()}),[p]),/*#__PURE__*/e.jsx(n.LoginMethodButton,{onClick:()=>r({appId:t,action:d?"link":"login",disableSignup:c?.login?.disableSignup}),disabled:!a,children:a?/*#__PURE__*/e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{$fullSize:!0,children:/*#__PURE__*/e.jsx(E,{name:a.name,logoUrl:a.icon_url||void 0,size:"32px"})}),a.name]}):/*#__PURE__*/e.jsx(n.ButtonLoader,{})})},q=({isEditable:t,setIsEditable:a,defaultValue:l})=>{let r=i.useRef(null);/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.Hide,{$if:!t,children:/*#__PURE__*/e.jsx(h.ConnectEmailForm,{ref:r,defaultValue:l})}),/*#__PURE__*/e.jsx(n.Hide,{$if:t,children:/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:()=>{a(),setTimeout((()=>{r.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(u.Mail,{})}),"Continue with Email"]})})]})},N=()=>{let[t,a]=i.useState(!1),{currentScreen:l,navigate:r,setModalData:c,data:p}=o.usePrivyModal(),{enabled:u,token:h}=d.useCaptcha(),{initLoginWithFarcaster:g}=s.usePrivyInternal(),{accountType:m}=n.useRecentlyUsedLogin();/*#__PURE__*/return e.jsxs(n.LoginMethodButton,{onClick:async()=>{a(!0);try{u&&!h?(c({captchaModalData:{callback:e=>g(e,p?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:"FarcasterConnectStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),r("CaptchaScreen")):(await g(h,p?.login?.disableSignup),r("FarcasterConnectStatusScreen"))}catch(e){c({errorModalData:{error:e,previousScreen:l||"LandingScreen"}}),r("ErrorScreen")}finally{a(!1)}},disabled:!1,children:[/*#__PURE__*/e.jsx(y.Farcaster,{width:32,height:32})," Farcaster",t&&/*#__PURE__*/e.jsx(n.ButtonLoader,{}),"farcaster"===m&&/*#__PURE__*/e.jsx(D,{color:"gray",children:"Recent"})]})};let D=a.styled(g.Chip)`
margin-left: auto;
`;const R=({...t})=>/*#__PURE__*/e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",width:"25",height:"25",viewBox:"0 0 25 25",fill:"none",...t,children:[/*#__PURE__*/e.jsxs("g",{clipPath:"url(#clip0_2856_1743)",children:[/*#__PURE__*/e.jsx("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.jsx("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.jsx("defs",{children:/*#__PURE__*/e.jsx("clipPath",{id:"clip0_2856_1743",children:/*#__PURE__*/e.jsx("rect",{x:"0.5",y:"0.5",width:"24",height:"24",rx:"6",fill:"white"})})})]}),O=({chainType:t,withPadding:i})=>{let a="";return a="ethereum-only"===t||"ethereum-and-solana"===t?"Rainbow, Phantom, or Coinbase Wallet":"Phantom or Solflare",/*#__PURE__*/e.jsx(n.EmptyWalletState,{$withPadding:i,children:/*#__PURE__*/e.jsxs(n.Header,{children:[/*#__PURE__*/e.jsx(A.default,{style:{color:"var(--privy-color-warn)",height:48,width:48}}),/*#__PURE__*/e.jsx("h3",{children:"No wallets available"}),/*#__PURE__*/e.jsxs("p",{children:["Please download an external wallet provider, like ",a,"."]})]})},"empty-wallet-state")},U=()=>{let{enabled:t,token:a}=d.useCaptcha(),{navigate:l,setModalData:c,data:p}=o.usePrivyModal(),u=r.useAppConfig(),{initLoginWithPasskey:h}=s.usePrivyInternal(),g=()=>{u.loginConfig.passkeysForSignupEnabled?l("PasskeySelectSignupOrLogin"):(async()=>{t&&!a?(c({passkeyAuthModalData:{passkeySignupFlow:!1},captchaModalData:{callback:e=>h({captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:"PasskeyStatusScreen",onErrorNavigateTo:"ErrorScreen"}}),l("CaptchaScreen")):(await h({withPrivyUi:!0,captchaToken:a}),c({passkeyAuthModalData:{passkeySignupFlow:!1}}),l("PasskeyStatusScreen"))})()};return 0===i.useMemo((()=>{let e=p?.login?.loginMethods;return e?e.filter((e=>"passkey"!==e)).length:Object.entries(u.loginMethods).filter((([e,t])=>t)).filter((([e])=>"passkey"!==e)).length}),[u.loginMethods,p?.login])?/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:g,children:[/*#__PURE__*/e.jsx(W.default,{})," Continue with passkey"]}):/*#__PURE__*/e.jsx(j.Link,{as:"button",onClick:g,size:"sm",variant:"navigation",style:{width:"100%",justifyContent:"center"},children:"I have a passkey"})},B=({isEditable:t,setIsEditable:a,defaultValue:l})=>{let c=i.useRef(null),{authenticated:p}=o.usePrivyContext(),{navigate:h,setModalData:g,currentScreen:y,data:m}=o.usePrivyModal(),{initLoginWithSms:f}=s.usePrivyInternal(),{enabled:x,token:j}=d.useCaptcha(),{whatsAppEnabled:v}=r.useAppConfig();/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(n.Hide,{$if:!t,children:/*#__PURE__*/e.jsx(w.ConnectPhoneNumberForm,{ref:c,onSubmit:async function({qualifiedPhoneNumber:e}){if(!x||j||p)try{await f({phoneNumber:e,captchaToken:j,withPrivyUi:!0,disableSignup:m?.login?.disableSignup}),h("AwaitingPasswordlessCodeScreen")}catch(e){g({errorModalData:{error:e,previousScreen:y||"LandingScreen"}}),h("ErrorScreen")}else g({captchaModalData:{callback:t=>f({phoneNumber:e,captchaToken:t,withPrivyUi:!0,disableSignup:m?.login?.disableSignup}),userIntentRequired:!1,onSuccessNavigateTo:"AwaitingPasswordlessCodeScreen",onErrorNavigateTo:"ErrorScreen"}}),h("CaptchaScreen")},defaultValue:l})}),/*#__PURE__*/e.jsx(n.Hide,{$if:t,children:/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:()=>{a(),setTimeout((()=>{c.current?.focus()}),0)},children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{children:/*#__PURE__*/e.jsx(u.Smartphone,{})}),"Continue with ",v?"WhatsApp":"SMS"]})})]})};let V={apple:{logo:v.Apple,displayName:"Apple"},discord:{logo:v.Discord,displayName:"Discord"},github:{logo:v.Github,displayName:"GitHub"},google:{logo:v.Google,displayName:"Google"},linkedin:{logo:v.LinkedIn,displayName:"LinkedIn"},spotify:{logo:v.Spotify,displayName:"Spotify"},instagram:{logo:v.Instagram,displayName:"Instagram"},twitter:{logo:v.Twitter,displayName:"Twitter"},tiktok:{logo:v.Tiktok,displayName:"TikTok"},line:{logo:C.Line,displayName:"LINE"},twitch:{logo:C.Twitch,displayName:"Twitch"}};const _=({provider:t})=>{let{enabled:a,token:l}=d.useCaptcha(),{navigate:c,setModalData:p,data:u}=o.usePrivyModal(),[h,g]=i.useState(!1),y=r.useAppConfig(),{initLoginWithOAuth:m}=s.usePrivyInternal(),{accountType:f}=n.useRecentlyUsedLogin(),x=i.useMemo((()=>f&&"guest"!==f&&"authorization_key"!==f&&"cross_app"!==f?d.toDisplayFromAccountType(f):null),[f]),{displayName:j,logo:w}=i.useMemo((()=>{if(o.isCustomOAuthProvider(t)){let i=y.customOAuthProviders.find((e=>e.provider===t)),a=i.provider_icon_url,l=i.provider_display_name;return{displayName:l,logo:({style:t})=>/*#__PURE__*/e.jsx("img",{alt:`${l} logo`,src:a,style:t})}}return V[t]}),[t,y.customOAuthProviders]);/*#__PURE__*/return e.jsxs(n.LoginMethodButton,{onClick:()=>{g(!0),setTimeout((()=>{g(!1)}),2e3),a&&!l?(p({captchaModalData:{callback:e=>m(t,e,u?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),c("CaptchaScreen")):m(t,void 0,u?.login?.disableSignup)},disabled:h,children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{$fullSize:!0,children:/*#__PURE__*/e.jsx(w,{style:{width:"32px",height:"32px"}})}),j,x?.loginMethod===t&&/*#__PURE__*/e.jsx(H,{color:"gray",children:"Recent"})]})};let H=a.styled(g.Chip)`
margin-left: auto;
`;const $=()=>{let{enabled:t,token:a}=d.useCaptcha(),{navigate:l,setModalData:r,data:c}=o.usePrivyModal(),[p,u]=i.useState(!1),{initLoginWithTelegram:h}=s.usePrivyInternal(),{accountType:g}=n.useRecentlyUsedLogin();async function y(e){try{await h(e,c?.login?.disableSignup),r({telegramAuthModalData:{seamlessAuth:!1}}),l("TelegramAuthScreen")}catch(e){console.error(e),u(!1)}}/*#__PURE__*/return e.jsxs(n.LoginMethodButton,{onClick:async function(){if(u(!0),t&&!a)return r({captchaModalData:{callback:y,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:"ErrorScreen"}}),void l("CaptchaScreen");await y(a)},disabled:p,children:[/*#__PURE__*/e.jsx(b.Telegram,{width:32,height:32}),"Telegram","telegram"===g&&/*#__PURE__*/e.jsx(z,{color:"gray",children:"Recent"})]})};let z=a.styled(g.Chip)`
margin-left: auto;
`;const G=({onClick:t,text:i,icon:a})=>/*#__PURE__*/e.jsxs(n.LoginMethodButton,{onClick:t,children:[/*#__PURE__*/e.jsx(n.LoginMethodIconWrapper,{children:a}),/*#__PURE__*/e.jsx(n.Grow,{children:i})]});let K=a.styled.div`
text-align: center;
font-size: 14px;
margin-bottom: 24px;
`,Q=a.styled.div`
margin-bottom: 24px;
`,Y=({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",Z=({priority:t,email:i,sms:a,social:l})=>"web2-first"===t||l.length>0?/*#__PURE__*/e.jsx(u.UserCircle,{}):i&&a?/*#__PURE__*/e.jsx(R,{}):i?/*#__PURE__*/e.jsx(u.Mail,{}):a?/*#__PURE__*/e.jsx(u.Smartphone,{}):null,J=({priority:e})=>"web2-first"===e?"Continue with a wallet":"Other wallets";const X=({mostRecentlyUsedAccountType:e,smsAvailable:t,emailAvailable:i,prefilledType:a})=>i&&("email"===e&&"phone"!==a||"email"===a)||!t||"phone"!==e&&"phone"!==a?"email":"sms";let ee=({primary:e,overflow:t})=>e<5?e:5===e&&0===t?5:4,te=a.styled((t=>{let i=r.useAppConfig();return i?.appearance.logo?/*#__PURE__*/e.jsx(I,{...t,children:/*#__PURE__*/e.jsx(P,{})}):null}))`
margin-bottom: 16px;
`;exports.CustomLandingScreenView=({connectOnly:t})=>{let{closePrivyModal:a,connectors:u}=s.usePrivyInternal(),{data:h,setModalData:g,onUserCloseViaDialogOrKeybindRef:y,navigate:m}=o.usePrivyModal(),f=r.useAppConfig(),x=f.appearance.palette.colorScheme,{accountType:j,walletClientType:w}=n.useRecentlyUsedLogin(),v=i.useMemo((()=>j&&"guest"!==j&&"authorization_key"!==j&&"cross_app"!==j?d.toDisplayFromAccountType(j):null),[j]),C=f.loginMethodsAndOrder?.primary??[],b=f.loginMethodsAndOrder?.overflow??[],S=i.useMemo((()=>[...C,...b]),[C,b]),k=f.loginMethods.passkey,M=h?.login,L=[];w&&S.includes(w)?L.push(w):j&&S.includes(v?.loginMethod)&&L.push(v?.loginMethod);let[A,W]=i.useState("default"),[P,I]=i.useState(X({mostRecentlyUsedAccountType:j,smsAvailable:S.includes("sms"),emailAvailable:S.includes("email"),prefilledType:M?.prefill?.type}));i.useEffect((()=>{I(X({mostRecentlyUsedAccountType:j,smsAvailable:S.includes("sms"),emailAvailable:S.includes("email"),prefilledType:M?.prefill?.type}))}),[S,j]),i.useEffect((()=>{"phone"===j&&I("sms");let e=S.indexOf("sms"),t=S.indexOf("email");e>-1&&e<t&&I("sms")}),[j,C,b]);let E=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{W("default")}),150)};y.current=E;let{listings:D}=n.useExternalWalletListings(),R=i=>{if("email"===i)/*#__PURE__*/return e.jsx(q,{isEditable:"email"===P,setIsEditable:()=>{I("email")},defaultValue:"email"===M?.prefill?.type?M.prefill.value:void 0},i);if("sms"===i)/*#__PURE__*/return e.jsx(B,{isEditable:"sms"===P,setIsEditable:()=>{I("sms")},defaultValue:"phone"===M?.prefill?.type?M.prefill.value:void 0},i);if("apple"===i)/*#__PURE__*/return e.jsx(_,{provider:"apple"},i);if("discord"===i)/*#__PURE__*/return e.jsx(_,{provider:"discord"},i);if("farcaster"===i)/*#__PURE__*/return e.jsx(N,{},i);if("github"===i)/*#__PURE__*/return e.jsx(_,{provider:"github"},i);if("google"===i)/*#__PURE__*/return e.jsx(_,{provider:"google"},i);if("linkedin"===i)/*#__PURE__*/return e.jsx(_,{provider:"linkedin"},i);if("spotify"===i)/*#__PURE__*/return e.jsx(_,{provider:"spotify"},i);if("instagram"===i)/*#__PURE__*/return e.jsx(_,{provider:"instagram"},i);if("tiktok"===i)/*#__PURE__*/return e.jsx(_,{provider:"tiktok"},i);if("line"===i)/*#__PURE__*/return e.jsx(_,{provider:"line"},i);if("twitch"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitch"},i);if("twitter"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitter"},i);if("telegram"===i)/*#__PURE__*/return e.jsx($,{},i);if(i.startsWith("privy:"))/*#__PURE__*/return e.jsx(F,{appId:i.replace("privy:","")},i);let a=f.appearance.walletChainType,l=new c.WalletFilterer(a,[i]).getWallets(u,D);return l.wallets.map(((i,r)=>/*#__PURE__*/e.jsx(c.WalletRow,{index:r,data:{wallets:l.wallets,walletChainType:a,handleWalletClick(e){g((t=>({...t,externalConnectWallet:{walletList:S,walletChainType:a,preSelectedWalletId:e.id}}))),m(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},i.id+r)))},O=L.flatMap(R),V=C.filter((e=>e!==w&&e!==v?.loginMethod)).flatMap(R),H=b.filter((e=>e!==w&&e!==v?.loginMethod)).flatMap(R),[z,K]=p.splitAtIndex([...O,...V,...H],ee({primary:V.length+O.length,overflow:H.length}));/*#__PURE__*/return e.jsxs(e.Fragment,{children:[/*#__PURE__*/e.jsx(l.ModalHeader,{title:f.appearance.landingHeader,onClose:E,backFn:"default"===A?void 0:()=>{W("default")}}),"default"===A&&/*#__PURE__*/e.jsx(te,{}),"default"===A&&("string"==typeof f.appearance.loginMessage?/*#__PURE__*/e.jsx(n.Subtitle,{children:f.appearance.loginMessage}):f.appearance.loginMessage),/*#__PURE__*/e.jsx(n.AlignBottom,{style:{overflow:"hidden"},children:/*#__PURE__*/e.jsxs(n.LoginMethodContainerWithScrollShadows,{$colorScheme:x,children:["default"===A&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[z,K.length>0&&/*#__PURE__*/e.jsx(G,{text:"More options",icon:/*#__PURE__*/e.jsx(T.default,{}),onClick:()=>W("overflow")})]}),"overflow"===A&&/*#__PURE__*/e.jsx(e.Fragment,{children:K}),k&&"default"===A&&/*#__PURE__*/e.jsx(U,{})]})}),f&&/*#__PURE__*/e.jsx(l.TermsAndConditions,{app:f}),/*#__PURE__*/e.jsx(l.BlobbyFooter,{})]})},exports.LandingScreenView=({connectOnly:t})=>{let{closePrivyModal:a}=s.usePrivyInternal(),{data:p,setModalData:u,onUserCloseViaDialogOrKeybindRef:h,navigate:g}=o.usePrivyModal(),y=r.useAppConfig(),f=p?.login,x=y.appearance.walletList,j=f?.walletChainType??y.appearance.walletChainType,{accountType:w,walletClientType:v,chainType:C}=n.useRecentlyUsedLogin(),b=i.useMemo((()=>w&&"guest"!==w&&"authorization_key"!==w&&"cross_app"!==w?d.toDisplayFromAccountType(w):null),[w]),{email:M,sms:T,google:L,twitter:A,discord:W,github:I,spotify:E,instagram:D,tiktok:R,line:V,twitch:H,linkedin:z,apple:ee,wallet:te,farcaster:ie,telegram:ae}=i.useMemo((()=>f?.loginMethods?m.toObjectKeys(f.loginMethods,!0):null),[f])??y.loginMethods,{wallets:le}=c.useWalletsListController({enabled:n.shouldFetchWcRegistryListings(te?x:[]),walletList:x,walletChainType:j}),re=y.customOAuthProviders,ne=y.crossAppProviders,{passkey:se}=y.loginMethods,oe=[M&&"email",T&&"sms",L&&"google",A&&"twitter",W&&"discord",I&&"github",E&&"spotify",D&&"instagram",R&&"tiktok",V&&"line",H&&"twitch",z&&"linkedin",ee&&"apple",ie&&"farcaster",ae&&"telegram",...re.map((e=>e.provider)),...ne].filter((e=>!!e)),de=oe.length>0,ce=i.useMemo((()=>te&&!de?"web3-first":te&&y?.appearance.loginGroupPriority||"web2-first"),[te,de,y?.appearance.loginGroupPriority]),pe=y?.appearance.hideDirectWeb2Inputs,[ue,he]=i.useState("default"),[ge,ye]=i.useState(X({mostRecentlyUsedAccountType:w,smsAvailable:T,emailAvailable:M,prefilledType:f?.prefill?.type}));i.useEffect((()=>{ye(X({mostRecentlyUsedAccountType:w,smsAvailable:T,emailAvailable:M,prefilledType:f?.prefill?.type}))}),[M,T,w]);let me=()=>{a({shouldCallAuthOnSuccess:!0}),setTimeout((()=>{he("default")}),150)};h.current=me;let fe=[];v&&te?fe.push(v):b?.loginMethod&&oe.includes(b.loginMethod)&&fe.push(b.loginMethod);let xe=i=>{if("email"===i)/*#__PURE__*/return e.jsx(q,{isEditable:"email"===ge,setIsEditable:()=>{ye("email")},defaultValue:"email"===f?.prefill?.type?f.prefill.value:void 0},i);if("sms"===i)/*#__PURE__*/return e.jsx(B,{isEditable:"sms"===ge,setIsEditable:()=>{ye("sms")},defaultValue:"phone"===f?.prefill?.type?f.prefill.value:void 0},i);if("apple"===i)/*#__PURE__*/return e.jsx(_,{provider:"apple"},i);if("discord"===i)/*#__PURE__*/return e.jsx(_,{provider:"discord"},i);if("farcaster"===i)/*#__PURE__*/return e.jsx(N,{},i);if("github"===i)/*#__PURE__*/return e.jsx(_,{provider:"github"},i);if("google"===i)/*#__PURE__*/return e.jsx(_,{provider:"google"},i);if("linkedin"===i)/*#__PURE__*/return e.jsx(_,{provider:"linkedin"},i);if("tiktok"===i)/*#__PURE__*/return e.jsx(_,{provider:"tiktok"},i);if("line"===i)/*#__PURE__*/return e.jsx(_,{provider:"line"},i);if("twitch"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitch"},i);if("spotify"===i)/*#__PURE__*/return e.jsx(_,{provider:"spotify"},i);if("instagram"===i)/*#__PURE__*/return e.jsx(_,{provider:"instagram"},i);if("twitter"===i)/*#__PURE__*/return e.jsx(_,{provider:"twitter"},i);if("telegram"===i)/*#__PURE__*/return e.jsx($,{},i);if(o.isCustomOAuthProvider(i))/*#__PURE__*/return e.jsx(_,{provider:i},i);if(i.startsWith("privy:")){let t=i.split(":")[1];if(!t)throw Error("Invalid cross-app provider format. App ID missing.");/*#__PURE__*/return e.jsx(F,{appId:t},i)}let a=le.findIndex((({id:e})=>e===c.WalletFilterer.normalize(i))),l="solana"===C?"solana-only":"ethereum-only";/*#__PURE__*/return e.jsx(c.WalletRow,{recent:!0,index:a,data:{wallets:le,walletChainType:l,handleWalletClick(e){u((t=>({...t,externalConnectWallet:{walletList:x,walletChainType:l,preSelectedWalletId:e.id}}))),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}})},je=le.filter((e=>e.id!==c.WalletFilterer.normalize(v||""))),we=je.map(((i,a)=>/*#__PURE__*/e.jsx(c.WalletRow,{index:a,data:{walletChainType:j,wallets:je,handleWalletClick(e){u((t=>({...t,externalConnectWallet:{walletList:x,walletChainType:j,preSelectedWalletId:e.id}}))),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}},i.id))),ve=oe.filter((e=>e!==b?.loginMethod)).flatMap(xe),Ce=fe.flatMap(xe);"web3-first"===ce&&"default"===ue?we.unshift(...Ce):"web2-first"===ce&&ve.unshift(...Ce);let be="web2-overflow"===ue?()=>he("default"):void 0,Se=oe.filter((e=>"email"!==e&&"sms"!==e)),ke=Y({priority:ce,email:M,sms:T,social:Se}),Me=Z({priority:ce,email:M,sms:T,social:Se}),Te=/*#__PURE__*/e.jsx(S.WalletOverflowButton,{text:J({priority:ce}),onClick:()=>{u({...p,externalConnectWallet:{walletChainType:f?.walletChainType??y.appearance.walletChainType}}),g(t?"ConnectOnlyLandingScreen":"AuthenticateWithWalletScreen")}}),Le=/*#__PURE__*/e.jsx(G,{text:ke,icon:Me,onClick:()=>he("web2-overflow")}),Ae=pe?0:1,We=te&&we.length>0,Pe=0===ve.length&&te&&0===we.length,Ie=5-(We?1:0),Ee="default"===ue&&y?.appearance.logo,Fe="default"===ue&&y.appearance.loginMessage;/*#__PURE__*/return e.jsxs(k.ScreenLayout,{title:y.appearance.landingHeader,icon:Ee?/*#__PURE__*/e.jsx(P,{}):void 0,iconVariant:Ee?"logo":void 0,onClose:me,showClose:!0,onBack:be,showBack:!!be,helpText:y||se&&"default"===ue?/*#__PURE__*/e.jsxs(e.Fragment,{children:[se&&"default"===ue&&!y.globalDisablePasskeys&&/*#__PURE__*/e.jsx(U,{}),y&&/*#__PURE__*/e.jsx(l.TermsAndConditions,{app:y})]}):void 0,watermark:!0,children:[Fe&&("string"==typeof y.appearance.loginMessage?/*#__PURE__*/e.jsx(K,{children:y.appearance.loginMessage}):/*#__PURE__*/e.jsx(Q,{children:y.appearance.loginMessage})),/*#__PURE__*/e.jsx(n.LoginMethodContainerWithScrollShadows,{$colorScheme:y.appearance.palette.colorScheme,children:"default"===ue&&"web2-first"===ce?/*#__PURE__*/e.jsxs(e.Fragment,{children:[ve.length>Ie?ve.slice(0,Ie-1):ve,ve.length>Ie&&Le,We&&Te,Pe&&/*#__PURE__*/e.jsx(O,{chainType:y.appearance.walletChainType})]}):"default"===ue&&"web3-first"===ce?/*#__PURE__*/e.jsxs(e.Fragment,{children:[te&&/*#__PURE__*/e.jsxs(e.Fragment,{children:[we.length>Ie?we.slice(0,Ie-1):we,we.length>Ie&&Te]}),ve.length>Ae&&Le,ve.length===Ae&&ve[0],Pe&&/*#__PURE__*/e.jsx(O,{chainType:y.appearance.walletChainType})]}):"web2-overflow"===ue?/*#__PURE__*/e.jsx(e.Fragment,{children:"web3-first"===ce?ve:ve.slice(3)}):null})]})};