1import{cX as D,cW as B,cZ as F,dB as P,c$ as p,d6 as g,dC as V,dm as S,cY as W,dD as L,d1 as X}from"./index-CKiyprHq.js";import{a as Y}from"./shouldProceedtoEmbeddedWalletCreationFlow-BMHEqcS9-BtZnUBzJ.js";import{n as q}from"./ScreenLayout-Yoa2TSpi-BHji0yAx.js";import"./ModalHeader-CAqKnddp-FNM_ewX3.js";import"./Screen-CLdp3cO6-BoU1Ckhl.js";import"./index-Dq_xe9dz-B4y8Y4kf.js";const K=({providerApp:a,success:s,error:r,onClose:u})=>{let{title:m,subtitle:f}=p.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 W.jsx(q,{title:m,subtitle:f,icon:a.logoUrl,iconVariant:"loading",iconLoadingStatus:{success:s,fail:!!r},onBack:u,watermark:!0})},k={component:()=>{let a=D(),{data:s,navigate:r,setModalData:u,onUserCloseViaDialogOrKeybindRef:m}=B(),{crossAppAuthFlow:f,updateWallets:j,closePrivyModal:C,createAnalyticsEvent:_}=F(),{logout:M}=P(),[o,l]=p.useState({}),e=s==null?void 0:s.crossAppAuth,A=new g(`There was an issue connecting your ${e==null?void 0:e.name} account. Please try again.`),N=new V((async n=>{var d,c,i,y,b,w,v,T,U,I,E,$,x,O,R;if(e!=null&&e.popup)try{let t=await f({appId:n,popup:e.popup,action:e.action,disableSignup:e.disableSignup});l({data:t})}catch(t){if(t instanceof g)l({error:t});else if(t instanceof L){if(t.privyErrorCode===X.ACCOUNT_TRANSFER_REQUIRED&&((c=(d=t.data)==null?void 0:d.data)!=null&&c.nonce))return u({accountTransfer:{nonce:(y=(i=t.data)==null?void 0:i.data)==null?void 0:y.nonce,account:(w=(b=t.data)==null?void 0:b.data)==null?void 0:w.subject,displayName:(U=(T=(v=t.data)==null?void 0:v.data)==null?void 0:T.account)==null?void 0:U.displayName,linkMethod:`privy:${e.appId}`,embeddedWalletAddress:($=(E=(I=t.data)==null?void 0:I.data)==null?void 0:E.otherUser)==null?void 0:$.embeddedWalletAddress,oAuthUserInfo:(R=(O=(x=t.data)==null?void 0:x.data)==null?void 0:O.otherUser)==null?void 0:R.oAuthUserInfo}}),void r("LinkConflictScreen");e.popup&&e.popup.close(),l({error:A})}else l({error:A})}else l({error:A})})),h=()=>{o.data&&(j(),e==null||e.onSuccess(o.data),C({shouldCallAuthOnSuccess:!0,isSuccess:!0})),e==null||e.onError(o.error??new g("User canceled flow")),C({shouldCallAuthOnSuccess:!1,isSuccess:!1})};return m.current=h,p.useEffect((()=>{var n;(n=e==null?void 0:e.appId)!=null&&n.length&&N.execute(e.appId)}),[e==null?void 0:e.appId]),p.useEffect((()=>{if(!o.data)return;let n=o.data;if(a.legal.requireUsersAcceptTerms&&!n.hasAcceptedTerms){let c=setTimeout((()=>{r("AffirmativeConsentScreen")}),S);return()=>clearTimeout(c)}if(Y(n,a.embeddedWallets)){let c=setTimeout((()=>{u({createWallet:{onSuccess:()=>{},onFailure:i=>{console.error(i),_({eventName:"embedded_wallet_creation_failure_logout",payload:{error:i,provider:`privy:${e==null?void 0:e.appId}`,screen:"CrossAppAuthScreen"}}),M()},callAuthOnSuccessOnClose:!0}}),r("EmbeddedWalletOnAccountCreateScreen")}),S);return()=>clearTimeout(c)}let d=setTimeout(h,S);return()=>clearTimeout(d)}),[o.data]),e!=null&&e.appId?W.jsx(K,{providerApp:{id:e==null?void 0:e.appId,logoUrl:e==null?void 0:e.logoUrl,name:e==null?void 0:e.name},success:!!o.data,error:o.error,onClose:h}):(console.warn("Missing data for Screen"),null)},isShownBeforeReady:!0};export{k as CrossAppAuthScreen,K as CrossAppAuthScreenView,k as default};
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.