1import{s as T,P as I,I as U,cB as E,y as A,cC as $,b9 as h,j as C,bT as x,B as O}from"./privy-C70SmBOt.js";import{r as i}from"./vendor-BhTrWUXb.js";import{a as R}from"./shouldProceedtoEmbeddedWalletCreationFlow-BTsQS1ZO-Dh9n3qtd.js";import{n as _}from"./ScreenLayout-BgwOsyLd-B2abtQKQ.js";import"./ModalHeader-D7u2VQIH-DmAvoeoM.js";import"./Screen-yabWN6I5-CKn-9o50.js";import"./index-Dq_xe9dz-C35b9bEG.js";const j=({providerApp:a,success:s,error:r,onClose:c})=>{let{title:u,subtitle:d}=i.useMemo((()=>s?{title:`Successfully connected with ${a.name}`,subtitle:"You're good to go!"}:r?{title:"Authentication failed",subtitle:r.message}:{title:`Connecting to ${a.name}`,subtitle:`Please check the pop-up from ${a.name} to continue`}),[s,r,a.name]);return C.jsx(_,{title:u,subtitle:d,icon:a.logoUrl,iconVariant:"loading",iconLoadingStatus:{success:s,fail:!!r},onBack:c,watermark:!0})},F={component:()=>{let a=T(),{data:s,navigate:r,setModalData:c,onUserCloseViaDialogOrKeybindRef:u}=I(),{crossAppAuthFlow:d,updateWallets:b,closePrivyModal:S,createAnalyticsEvent:y}=U(),{logout:v}=E(),[o,n]=i.useState({}),e=s?.crossAppAuth,p=new A(`There was an issue connecting your ${e?.name} account. Please try again.`),w=new $((async l=>{if(e?.popup)try{let t=await d({appId:l,popup:e.popup,action:e.action,disableSignup:e.disableSignup});n({data:t})}catch(t){if(t instanceof A)n({error:t});else if(t instanceof x){if(t.privyErrorCode===O.ACCOUNT_TRANSFER_REQUIRED&&t.data?.data?.nonce)return c({accountTransfer:{nonce:t.data?.data?.nonce,account:t.data?.data?.subject,displayName:t.data?.data?.account?.displayName,linkMethod:`privy:${e.appId}`,embeddedWalletAddress:t.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:t.data?.data?.otherUser?.oAuthUserInfo}}),void r("LinkConflictScreen");e.popup&&e.popup.close(),n({error:p})}else n({error:p})}else n({error:p})})),m=()=>{o.data&&(b(),e?.onSuccess(o.data),S({shouldCallAuthOnSuccess:!0,isSuccess:!0})),e?.onError(o.error??new A("User canceled flow")),S({shouldCallAuthOnSuccess:!1,isSuccess:!1})};return u.current=m,i.useEffect((()=>{e?.appId?.length&&w.execute(e.appId)}),[e?.appId]),i.useEffect((()=>{if(!o.data)return;let l=o.data;if(a.legal.requireUsersAcceptTerms&&!l.hasAcceptedTerms){let f=setTimeout((()=>{r("AffirmativeConsentScreen")}),h);return()=>clearTimeout(f)}if(R(l,a.embeddedWallets)){let f=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:g=>{console.error(g),y({eventName:"embedded_wallet_creation_failure_logout",payload:{error:g,provider:`privy:${e?.appId}`,screen:"CrossAppAuthScreen"}}),v()},callAuthOnSuccessOnClose:!0}}),r("EmbeddedWalletOnAccountCreateScreen")}),h);return()=>clearTimeout(f)}let t=setTimeout(m,h);return()=>clearTimeout(t)}),[o.data]),e?.appId?C.jsx(j,{providerApp:{id:e?.appId,logoUrl:e?.logoUrl,name:e?.name},success:!!o.data,error:o.error,onClose:m}):(console.warn("Missing data for Screen"),null)},isShownBeforeReady:!0};export{F as CrossAppAuthScreen,j as CrossAppAuthScreenView,F as default}; 2//# sourceMappingURL=CrossAppAuthScreen-DVxnn1BP-Da9PwTnU.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.