@privy-io/react-auth 1.88.4-beta-20241004182123 → 1.88.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cjs/index.js CHANGED
@@ -2256,7 +2256,7 @@
2256
2256
  && > input::placeholder {
2257
2257
  color: var(--privy-color-foreground-3);
2258
2258
  }
2259
- `;const gp=({isEditable:t,setIsEditable:r,defaultValue:n})=>{let a=i.useRef(null),{authenticated:s}=o.usePrivy(),{navigate:l,setModalData:d,currentScreen:c,data:u}=g.usePrivyModal(),{initLoginWithSms:h}=o.usePrivyInternal(),{enabled:p,token:y}=ba();return e.jsxs(e.Fragment,{children:[e.jsx(ns,{$if:!t,children:e.jsx(yp,{ref:a,onSubmit:async function({qualifiedPhoneNumber:e}){if(!p||y||s)try{await h(e,y,u?.login?.disableSignup),l(g.ModalScreen.AWAITING_PASSWORDLESS_CODE)}catch(e){d({errorModalData:{error:e,previousScreen:c||g.ModalScreen.LANDING}}),l(g.ModalScreen.ERROR_SCREEN)}else d({captchaModalData:{callback:t=>h(e,t,u?.login?.disableSignup),userIntentRequired:!1,onSuccessNavigateTo:g.ModalScreen.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),l(g.ModalScreen.CAPTCHA_SCREEN)},defaultValue:n})}),e.jsx(ns,{$if:t,children:e.jsxs(ts,{onClick:()=>{r(),setTimeout((()=>{a.current?.focus()}),0)},children:[e.jsx(Ye.default,{})," Continue with SMS"]})})]})};let vp={apple:{logo:e.jsx(ea,{}),displayName:"Apple"},discord:{logo:e.jsx(ta,{}),displayName:"Discord"},github:{logo:e.jsx(ra,{}),displayName:"GitHub"},google:{logo:e.jsx(ia,{}),displayName:"Google"},linkedin:{logo:e.jsx(oa,{}),displayName:"LinkedIn"},spotify:{logo:e.jsx(sa,{}),displayName:"Spotify"},instagram:{logo:e.jsx(aa,{}),displayName:"Instagram"},twitter:{logo:e.jsx(da,{}),displayName:"X (Twitter)"},tiktok:{logo:e.jsx(la,{}),displayName:"TikTok"}};const wp=({provider:t})=>{let{enabled:r,token:n}=ba(),{navigate:a,setModalData:s,data:l}=g.usePrivyModal(),[c,u]=i.useState(!1),{initLoginWithOAuth:h}=o.usePrivyInternal(),{accountType:p}=d.useRecentlyUsedLogin(),y=p?np(p):null,{displayName:m,logo:f}=vp[t];return e.jsxs(ts,{onClick:()=>{u(!0),r&&!n?(s({captchaModalData:{callback:e=>h(t,e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),a(g.ModalScreen.CAPTCHA_SCREEN)):h(t,void 0,l?.login?.disableSignup)},disabled:c,children:[f," ",m,y?.loginMethod===t&&e.jsx(xp,{color:"gray",children:"Recent"})]})};let xp=C.styled(d.Chip)`
2259
+ `;const gp=({isEditable:t,setIsEditable:r,defaultValue:n})=>{let a=i.useRef(null),{authenticated:s}=o.usePrivy(),{navigate:l,setModalData:d,currentScreen:c,data:u}=g.usePrivyModal(),{initLoginWithSms:h}=o.usePrivyInternal(),{enabled:p,token:y}=ba();return e.jsxs(e.Fragment,{children:[e.jsx(ns,{$if:!t,children:e.jsx(yp,{ref:a,onSubmit:async function({qualifiedPhoneNumber:e}){if(!p||y||s)try{await h(e,y,u?.login?.disableSignup),l(g.ModalScreen.AWAITING_PASSWORDLESS_CODE)}catch(e){d({errorModalData:{error:e,previousScreen:c||g.ModalScreen.LANDING}}),l(g.ModalScreen.ERROR_SCREEN)}else d({captchaModalData:{callback:t=>h(e,t,u?.login?.disableSignup),userIntentRequired:!1,onSuccessNavigateTo:g.ModalScreen.AWAITING_PASSWORDLESS_CODE,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),l(g.ModalScreen.CAPTCHA_SCREEN)},defaultValue:n})}),e.jsx(ns,{$if:t,children:e.jsxs(ts,{onClick:()=>{r(),setTimeout((()=>{a.current?.focus()}),0)},children:[e.jsx(Ye.default,{})," Continue with SMS"]})})]})};let vp={apple:{logo:e.jsx(ea,{}),displayName:"Apple"},discord:{logo:e.jsx(ta,{}),displayName:"Discord"},github:{logo:e.jsx(ra,{}),displayName:"GitHub"},google:{logo:e.jsx(ia,{}),displayName:"Google"},linkedin:{logo:e.jsx(oa,{}),displayName:"LinkedIn"},spotify:{logo:e.jsx(sa,{}),displayName:"Spotify"},instagram:{logo:e.jsx(aa,{}),displayName:"Instagram"},twitter:{logo:e.jsx(da,{}),displayName:"Twitter"},tiktok:{logo:e.jsx(la,{}),displayName:"TikTok"}};const wp=({provider:t})=>{let{enabled:r,token:n}=ba(),{navigate:a,setModalData:s,data:l}=g.usePrivyModal(),[c,u]=i.useState(!1),{initLoginWithOAuth:h}=o.usePrivyInternal(),{accountType:p}=d.useRecentlyUsedLogin(),y=p?np(p):null,{displayName:m,logo:f}=vp[t];return e.jsxs(ts,{onClick:()=>{u(!0),r&&!n?(s({captchaModalData:{callback:e=>h(t,e,l?.login?.disableSignup),userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),a(g.ModalScreen.CAPTCHA_SCREEN)):h(t,void 0,l?.login?.disableSignup)},disabled:c,children:[f," ",m,y?.loginMethod===t&&e.jsx(xp,{color:"gray",children:"Recent"})]})};let xp=C.styled(d.Chip)`
2260
2260
  margin-left: auto;
2261
2261
  `;function Cp(t){return e.jsxs("svg",{xmlns:"http://www.w3.org/2000/svg",xmlnsXlink:"http://www.w3.org/1999/xlink",viewBox:"0 0 240 240",...t,children:[e.jsx("defs",{children:e.jsxs("linearGradient",{x1:"120",y1:"240",x2:"120",gradientUnits:"userSpaceOnUse",id:"telegram-linear-gradient",children:[e.jsx("stop",{offset:"0",stopColor:"#1d93d2"}),e.jsx("stop",{offset:"1",stopColor:"#38b0e3"})]})}),e.jsx("title",{children:"Telegram_logo"}),e.jsx("circle",{cx:"120",cy:"120",r:"120",fill:"url(#telegram-linear-gradient)"}),e.jsx("path",{d:"M81.229,128.772l14.237,39.406s1.78,3.687,3.686,3.687,30.255-29.492,30.255-29.492l31.525-60.89L81.737,118.6Z",fill:"#c8daea"}),e.jsx("path",{d:"M100.106,138.878l-2.733,29.046s-1.144,8.9,7.754,0,17.415-15.763,17.415-15.763",fill:"#a9c6d8"}),e.jsx("path",{d:"M81.486,130.178,52.2,120.636s-3.5-1.42-2.373-4.64c.232-.664.7-1.229,2.1-2.2,6.489-4.523,120.106-45.36,120.106-45.36s3.208-1.081,5.1-.362a2.766,2.766,0,0,1,1.885,2.055,9.357,9.357,0,0,1,.254,2.585c-.009.752-.1,1.449-.169,2.542-.692,11.165-21.4,94.493-21.4,94.493s-1.239,4.876-5.678,5.043A8.13,8.13,0,0,1,146.1,172.5c-8.711-7.493-38.819-27.727-45.472-32.177a1.27,1.27,0,0,1-.546-.9c-.093-.469.417-1.05.417-1.05s52.426-46.6,53.821-51.492c.108-.379-.3-.566-.848-.4-3.482,1.281-63.844,39.4-70.506,43.607A3.21,3.21,0,0,1,81.486,130.178Z",fill:"#fff"})]})}const Ep=()=>{let{enabled:t,token:r}=ba(),{navigate:n,setModalData:a,data:s}=g.usePrivyModal(),[l,c]=i.useState(!1),{initLoginWithTelegram:u}=o.usePrivyInternal(),{accountType:h}=d.useRecentlyUsedLogin();async function p(e){try{await u(e,s?.login?.disableSignup),a({telegramAuthModalData:{seamlessAuth:!1}}),n(g.ModalScreen.TELEGRAM_AUTH_SCREEN)}catch(e){console.error(e),c(!1)}}return e.jsxs(ts,{onClick:async function(){if(c(!0),t&&!r)return a({captchaModalData:{callback:p,userIntentRequired:!0,onSuccessNavigateTo:null,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),void n(g.ModalScreen.CAPTCHA_SCREEN);await p(r)},disabled:l,children:[e.jsx(Cp,{}),"Telegram","telegram"===h&&e.jsx(bp,{color:"gray",children:"Recent"})]})};let bp=C.styled(d.Chip)`
2262
2262
  margin-left: auto;
@@ -3092,7 +3092,7 @@
3092
3092
  align-items: center;
3093
3093
  justify-content: center;
3094
3094
  height: 100%;
3095
- `;let Yf={[g.ModalScreen.LANDING]:()=>{let{app:t}=g.usePrivyModal();return t.loginMethodsAndOrder&&t.loginMethodsAndOrder.primary.length>0?e.jsx(Ap,{connectOnly:!1}):e.jsx(Pp,{connectOnly:!1})},[g.ModalScreen.CONNECT_OR_CREATE]:()=>{let{app:t}=g.usePrivyModal();return t.loginMethodsAndOrder&&t.loginMethodsAndOrder.primary.length>0?e.jsx(Ap,{connectOnly:!0}):e.jsx(Pp,{connectOnly:!0})},[g.ModalScreen.AWAITING_PASSWORDLESS_CODE]:()=>{let{app:t,navigate:r,lastScreen:n,navigateBack:s,setModalData:c,onUserCloseViaDialogOrKeybindRef:h}=g.usePrivyModal(),{closePrivyModal:p,resendEmailCode:y,resendSmsCode:m,getAuthMeta:f,loginWithCode:v,updateWallets:w,createAnalyticsEvent:x}=o.usePrivyInternal(),{authenticated:C,logout:E,user:b}=o.usePrivy(),[S,A]=i.useState(ul),[j,$]=i.useState(!1),[T,P]=i.useState(null),[_,k]=i.useState(null),[N,I]=i.useState(0);h.current=()=>null;let M=f()?.email?0:1,O=l.DEFAULT_SUCCESS_SCREEN_DURATION_MS-500;i.useEffect((()=>{if(N){let e=setTimeout((()=>{I(N-1)}),1e3);return()=>clearTimeout(e)}}),[N]),i.useEffect((()=>{if(C&&j&&b){if(t?.legal.requireUsersAcceptTerms&&!b.hasAcceptedTerms){let e=setTimeout((()=>{r(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),O);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(b,t?.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),x({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),E()},callAuthOnSuccessOnClose:!0}}),r(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),O);return()=>clearTimeout(e)}{w();let e=setTimeout((()=>p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}}}),[C,j,b]),i.useEffect((()=>{if(T&&0===_){let e=setTimeout((()=>{A(ul),P(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[T]);let R=e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return P("Code should be numeric"),void k(1);P(null),k(null);let i=Number(e.currentTarget.name?.charAt(5)),a=[...t||[""]].slice(0,6-i),s=[...S.slice(0,i),...a,...S.slice(i+a.length)];A(s);let l=Math.min(Math.max(i+a.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${l}]`);e?.focus()}if(s.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${l}]`);e?.blur(),v(s.join("")).then((()=>$(!0))).catch((e=>{if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS)P("Invalid or expired verification code");else if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)P(e.message);else{if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),void r(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return void r(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER)return c({errorModalData:{error:e,previousScreen:n??g.ModalScreen.AWAITING_PASSWORDLESS_CODE}}),void r(g.ModalScreen.ERROR_SCREEN,!1);if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return c({accountTransfer:{nonce:e.data?.data?.nonce,account:0===M?f()?.email:f()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===M?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void r(g.ModalScreen.LINK_CONFLICT_SCREEN);P("Issue verifying code")}k(0)}))}},F=0==M?e.jsx(Ke.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):e.jsx(Ye.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),L=0==M?e.jsxs("p",{children:["Please check ",e.jsx(vl,{children:f()?.email})," for an email from privy.io and enter your code below."]}):e.jsxs("p",{children:["Please check ",e.jsx(vl,{children:f()?.phoneNumber})," for a message from ",t?.name||"Privy"," and enter your code below."]});return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>s()},"header"),e.jsxs(hl,{children:[e.jsx(il,{title:"Enter confirmation code",description:L,icon:F}),e.jsxs(qs,{children:[e.jsxs(pl,{children:[e.jsx(yl,{$fail:!!T,$success:j,children:e.jsx("span",{children:T||(j?"Success!":"")})}),e.jsx("div",{children:S.map(((t,r)=>e.jsx("input",{name:`code-${r}`,type:"text",value:S[r],onChange:R,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===_&&(P(null),k(null)),A([...S.slice(0,e),"",...S.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(r)},inputMode:"numeric",autoFocus:0===r,pattern:"[0-9]",className:`${j?"success":""} ${T?"fail":""}`,autoComplete:a.isMobile?"one-time-code":"off"},r)))})]}),e.jsxs(ml,{children:[e.jsxs("span",{children:["Didn't get ",0==M?"an email":"a message","?"]}),N?e.jsxs(gl,{children:[e.jsx(Ve.default,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),e.jsx("span",{children:"Code sent"})]}):e.jsx(fl,{children:e.jsx("button",{onClick:async()=>{I(30),0==M?await y():await m()},children:"Resend code"})})]})]})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.AWAITING_CONNECTION]:()=>{let t,[r,n]=i.useState(!1),[s,c]=i.useState(!1),[h,p]=i.useState(void 0),{authenticated:y,logout:f}=o.usePrivy(),{app:v,navigate:w,navigateBack:x,lastScreen:C,currentScreen:E,setModalData:b,data:S}=g.usePrivyModal(),{getAuthFlow:A,walletConnectionStatus:j,closePrivyModal:$,initLoginWithWallet:T,loginWithWallet:P,updateWallets:_,createAnalyticsEvent:k}=o.usePrivyInternal(),{walletConnectors:N}=o.usePrivy(),[I,M]=i.useState(0),{user:O}=o.usePrivy(),[R]=i.useState(O?.linkedAccounts.length||0),[F,L]=i.useState(""),[U,D]=i.useState(""),[W,B]=i.useState(!1),{hasTabbedAway:H}=function(){let[e,t]=i.useState(!1),r=i.useCallback((()=>{document.hidden&&t(!0)}),[]);return i.useEffect((()=>(document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r))),[r]),{hasTabbedAway:e,reset:()=>t(!1)}}(),{enabled:G,token:q}=ba(),z=a.isMobile&&"wallet_connect_v2"===j?.connector?.connectorType||a.isMobile&&"coinbase_wallet"===j?.connector?.connectorType||a.isMobile&&"injected"===j?.connector?.connectorType&&"phantom"===j?.connector?.walletClientType,V="connected"===j?.status,K="switching_to_supported_chain"===j?.status;i.useEffect((()=>{let e=A(),t=e instanceof fa||e instanceof ga?e:void 0;V&&!t&&(!G||q||y?T(j.connectedWallet,q,S?.login?.disableSignup).then((()=>{B(!0)})):(b({captchaModalData:{callback:e=>T(j.connectedWallet,e,S?.login?.disableSignup).then((()=>{B(!0)})),userIntentRequired:!1,onSuccessNavigateTo:g.ModalScreen.AWAITING_CONNECTION,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),w(g.ModalScreen.CAPTCHA_SCREEN,!1))),t&&z&&V&&!t.preparedMessage?t.buildMessage():t&&!z&&V&&(s||(async()=>{c(!0),p(void 0);try{"wallet_connect_v2"===j?.connector?.connectorType&&"metamask"===j?.connector?.walletClientType&&await d.sleep(2500),await Z()}catch(e){console.warn("Auto-prompted signature failed",e)}finally{c(!1)}})())}),[I,V,W]),i.useEffect((()=>{if(O&&r){let e=l.DEFAULT_SUCCESS_SCREEN_DURATION_MS-500;if(v?.legal.requireUsersAcceptTerms&&!O.hasAcceptedTerms){let t=setTimeout((()=>{w(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),e);return()=>clearTimeout(t)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(O,v?.embeddedWallets?.createOnLogin)){let t=setTimeout((()=>{b({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),k({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"ConnectionStatusScreen"}}),f()},callAuthOnSuccessOnClose:!0}}),w(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),e);return()=>clearTimeout(t)}_();let t=setTimeout((()=>$({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(t)}}),[O,r]);let Y=e=>{if(e?.privyErrorCode!==o.PrivyErrorCode.ALLOWLIST_REJECTED){if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),void w(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode!==o.PrivyErrorCode.USER_DOES_NOT_EXIST)return e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce?(b({accountTransfer:{nonce:e.data?.data?.nonce,account:A()?.meta.address,displayName:e.data?.data?.account?.displayName,externalWalletMetadata:{walletClientType:A()?.meta.walletClientType,chainId:A()?.meta.chainId,connectorType:A()?.meta.connectorType},linkMethod:"siwe",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void w(g.ModalScreen.LINK_CONFLICT_SCREEN)):void p(Fl(e));w(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN)}else w(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN)};async function Z(){try{await P(),n(!0)}catch(e){Y(e)}finally{c(!1)}}i.useEffect((()=>{j?.connectError&&Y(j?.connectError)}),[j]),((e,t)=>{let r=i.useRef((()=>{}));i.useEffect((()=>{r.current=e})),i.useEffect((()=>{if(null!==t){let e=setInterval((()=>r.current()),t||0);return()=>clearInterval(e)}}),[t])})((()=>{let e="wallet_connect_v2"===X&&j?.connector instanceof to?j.connector.redirectUri:void 0;e&&L(e);let t="wallet_connect_v2"===X&&j?.connector instanceof to?j.connector.fallbackUniversalRedirectUri:void 0;t&&D(t)}),j?.connector instanceof to&&!F?500:null);let X=j?.connector?.connectorType||"injected",J=j?.connector?.walletClientType||"unknown",Q=bl[J]?.displayName||j?.connector?.walletBranding.name||"Browser Extension",ee=bl[J]?.logo||j?.connector?.walletBranding.icon||(t=>e.jsx(Ha,{...t})),te="Browser Extension"===Q?Q.toLowerCase():Q;t=r?`Successfully connected with ${te}`:h?h.message:K?"Switching networks":V?s&&z?"Signing":"Sign to verify":`Waiting for ${te}`;let re="Don’t see your wallet? Check your other browser windows.";r?re=R===(O?.linkedAccounts.length||0)?"Wallet was already linked.":"You’re good to go!":I>=2&&h?re="Unable to connect wallet":h?re=h.detail:K?re="Switch your wallet to the requested network.":V&&z?re="Sign the message in your wallet to verify it belongs to you.":"metamask"===J&&a.isMobile?re="Click continue to open and connect MetaMask.":"metamask"===J?re="For the best experience, connect only one wallet at a time.":"wallet_connect"===X?re="Open your mobile wallet app to continue":"coinbase_wallet"!==X||d.isCoinbaseWalletInstalled()||(re=ro(O)?"Continue with the Coinbase app. Not the right wallet? Reset your connection below.":"Open the Coinbase app on your phone to continue.");let ne=N?.walletConnectors?.find((e=>"coinbase_wallet"===e.walletClientType)),ie="coinbase_wallet"===J&&(ro(O)||h===m.ConnectorErrors.ERROR_USER_EXISTS);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:C&&E!==C?x:void 0}),e.jsxs(Ll,{children:[e.jsx(Dl,{walletLogo:ee,success:r,fail:!!h}),e.jsxs(Ys,{children:[e.jsx("h3",{children:t}),e.jsx("p",{children:re}),V||!F||H?null:e.jsxs("p",{children:["Still here?"," ",e.jsx("a",{href:F,target:"_blank",style:{textDecoration:"underline"},children:"Try connecting again"}),U&&e.jsxs(e.Fragment,{children:[" ","or"," ",e.jsx("a",{href:U,target:"_blank",style:{textDecoration:"underline"},children:"use this different link"})]})]})]}),ie?e.jsx(jo,{onClick:()=>ne&&ne?.disconnect(),disabled:r,children:"Use a different wallet"}):h==m.ConnectorErrors.ERROR_USER_EXISTS&&E!==C?e.jsx(jo,{onClick:x,children:"Use a different wallet"}):V&&!r&&z?e.jsx(jo,{onClick:()=>{c(!0),Z()},disabled:s,children:s?"Signing":"Sign with your wallet"}):!r&&h?.retryable&&I<2?e.jsx(jo,{onClick:()=>{M(I+1),p(void 0),V?(c(!0),Z()):j?.connectRetry()},disabled:!r&&(!h?.retryable||I>=2),children:"Retry"}):r||h?null:e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Connecting"})]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_CONNECT_ONLY_CONNECTION]:()=>{let t,{navigateBack:r,navigate:n,lastScreen:s,currentScreen:c,data:u}=g.usePrivyModal(),{walletConnectionStatus:h,closePrivyModal:p}=o.usePrivyInternal(),[y,f]=i.useState(void 0),[v,w]=i.useState(0),x="connected"===h?.status,C="switching_to_supported_chain"===h?.status;i.useEffect((()=>{if(x){let e;if(u?.externalConnectWallet?.onCompleteNavigateTo){let t=u.externalConnectWallet.onCompleteNavigateTo;e=setTimeout((()=>{n(t)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}else e=setTimeout(p,l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}}),[x]);i.useEffect((()=>{h?.connectError&&(e=>{f(Fl(e))})(h?.connectError)}),[h]);let E=h?.connector?.connectorType||"injected",b=h?.connector?.walletClientType||"unknown",S=bl[b]?.displayName||h?.connector?.walletBranding.name||"Browser Extension",A=bl[b]?.logo||h?.connector?.walletBranding.icon||(t=>e.jsx(Ha,{...t})),j="Browser Extension"===S?S.toLowerCase():S;t=x?`Successfully connected with ${j}`:y?y.message:C?"Switching networks":`Waiting for ${j}`;let $="Don’t see your wallet? Check your other browser windows.";return x?$="You’re good to go!":v>=2&&y?$="Unable to connect wallet":y?$=y.detail:C?$="Switch your wallet to the requested network.":"metamask"===b&&a.isMobile?$="Click to continue to open and connect MetaMask.":"metamask"===b?$="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===E?$="Open your mobile wallet app to continue":"coinbase_wallet"===E&&($="Open the Coinbase app on your phone to continue."),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:c===s?void 0:r}),e.jsxs(Wl,{children:[e.jsx(Dl,{walletLogo:A,success:x,fail:!!y}),e.jsxs(Ys,{children:[e.jsx("h3",{children:t}),e.jsx("p",{children:$})]}),y==m.ConnectorErrors.ERROR_USER_EXISTS?e.jsx(jo,{onClick:r,children:"Use a different wallet"}):!x&&y?.retryable&&v<2?e.jsx(jo,{onClick:()=>{w(v+1),f(void 0),h?.connectRetry()},disabled:!x&&(!y?.retryable||v>=2),children:"Retry"}):!x&&y&&v>=2?e.jsx(jo,{onClick:r,children:"Use a different wallet"}):null]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_FARCASTER_CONNECTION]:()=>{let{authenticated:t,logout:r,ready:n,user:s}=o.usePrivy(),{lastScreen:c,navigate:h,navigateBack:p,setModalData:y,app:m}=g.usePrivyModal(),{getAuthFlow:f,loginWithFarcaster:v,closePrivyModal:w,createAnalyticsEvent:x}=o.usePrivyInternal(),[C,E]=i.useState(void 0),[b,S]=i.useState(!1),[A,j]=i.useState(!1),$=i.useRef([]),T=f(),P=T?.meta.connectUri;return i.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{let r=await T.pollForReady.execute(),n=Date.now()-e;if(r){clearInterval(t),S(!0);try{await v(),j(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return void h(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),void h(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return void h(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER)t.detail="This account has already been linked to another user.";else{if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return y({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void h(g.ModalScreen.LINK_CONFLICT_SCREEN);e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}E(t)}}else n>12e4&&(clearInterval(t),E({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),$.current.forEach((e=>clearTimeout(e)))}}),[]),i.useEffect((()=>{if(n&&t&&A&&s){if(m?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{h(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}A&&(u.shouldProceedtoEmbeddedWalletCreationFlow(s,m?.embeddedWallets.createOnLogin)?$.current.push(setTimeout((()=>{y({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),x({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),h(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)):$.current.push(setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)))}}),[A,n,t,s]),a.isMobile||b?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:c?p:void 0,onClose:w},"header"),e.jsx(Xs,{}),a.isIOS?e.jsx(e.Fragment,{children:e.jsxs(Ic,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:A,fail:!!C}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:C?C.message:"Sign in with Farcaster"}),e.jsx(Es,{children:C?C.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),P&&e.jsx(jo,{onClick:e=>{e.preventDefault(),window.location.href=P},children:"Open Warpcast app"})]})}):e.jsx(e.Fragment,{children:e.jsxs(Nc,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:A,fail:!!C}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:C?C.message:"Signing in with Farcaster"}),e.jsx(Es,{children:C?C.detail:"This should only take a moment"}),e.jsx(Gs,{children:P&&a.isMobile&&e.jsx(wc,{text:"Take me to Warpcast",url:P,color:kc})})]})]})}),e.jsx(d.ModalFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:c?p:void 0,onClose:w},"header"),e.jsx(Xs,{}),e.jsx(Nc,{children:e.jsxs("div",{children:[e.jsx(Cs,{children:"Sign in with Farcaster"}),e.jsx(Es,{children:"Scan with your phone's camera to continue."}),e.jsx(zs,{children:P?e.jsx(Pc,{url:P,size:275,squareLogoElement:_c}):e.jsx(Co,{})}),e.jsxs(Gs,{children:[e.jsx(Es,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),P&&e.jsx(gc,{text:P,itemName:"link",color:kc})]})]})}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_FARCASTER_SIGNER]:()=>{let{lastScreen:t,navigateBack:r,data:n,app:s}=g.usePrivyModal(),{requestFarcasterSignerStatus:c,closePrivyModal:u}=o.usePrivyInternal(),[h,p]=i.useState(void 0),[y,m]=i.useState(!1),[f,v]=i.useState(!1),w=i.useRef([]),x=n?.farcasterSigner;i.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{if(!x?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===x.status&&(clearInterval(t),m(!1),v(!0),w.current.push(setTimeout((()=>u({shouldCallAuthOnSuccess:!1,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)));let r=await c(x?.public_key),n=Date.now()-e;"approved"===r.status?(clearInterval(t),m(!1),v(!0),w.current.push(setTimeout((()=>u({shouldCallAuthOnSuccess:!1,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS))):n>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===r.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),w.current.forEach((e=>clearTimeout(e)))}}),[]);let C="pending_approval"===x?.status?x.signer_approval_url:void 0;return a.isMobile||y?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t?r:void 0,onClose:u},"header"),e.jsx(Xs,{}),a.isIOS?e.jsx(e.Fragment,{children:e.jsxs(Rc,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:f,fail:!!h}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:h?h.message:"Add a signer to Farcaster"}),e.jsx(Es,{children:h?h.detail:"This will allow "+s.name+" to add casts, likes, follows, and more on your behalf."})]}),C&&e.jsx(jo,{onClick:e=>{e.preventDefault(),window.location.href=C},children:"Open Warpcast app"})]})}):e.jsx(e.Fragment,{children:e.jsxs(Oc,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:f,fail:!!h}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:h?h.message:"Requesting signer from Farcaster"}),e.jsx(Es,{children:h?h.detail:"This should only take a moment"}),e.jsx(Gs,{children:C&&a.isMobile&&e.jsx(wc,{text:"Take me to Warpcast",url:C,color:Mc})})]})]})}),e.jsx(d.ModalFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t?r:void 0,onClose:u},"header"),e.jsx(Xs,{}),e.jsx(Oc,{children:e.jsxs("div",{children:[e.jsx(Cs,{children:"Add a signer to Farcaster"}),e.jsxs(Es,{children:["This will allow ",s.name," to add casts, likes, follows, and more on your behalf."]}),e.jsx(zs,{children:"pending_approval"===x?.status?e.jsx(Pc,{url:x.signer_approval_url,size:275,squareLogoElement:_c}):e.jsx(Co,{})}),e.jsxs(Gs,{children:[e.jsx(Es,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===x?.status&&e.jsx(gc,{text:x.signer_approval_url,itemName:"link",color:Mc})]})]})}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_PASSKEY_SYSTEM_DIALOGUE]:()=>{let{lastScreen:t,currentScreen:r,navigateBack:n}=g.usePrivyModal(),{loginWithPasskey:a,closePrivyModal:s}=o.usePrivyInternal(),[c,u]=i.useState("loading"),[h,p]=i.useState(null),y=i.useRef([]);i.useEffect((()=>()=>{y.current.forEach((e=>clearTimeout(e))),y.current=[]}),[]);let m=async()=>{u("loading");try{await a(),u("success")}catch(e){p(e),u("error")}};return i.useEffect((()=>{"success"===c&&(e=>{y.current=[e,...y.current]})(setTimeout((()=>{s({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS))}),[c]),i.useEffect((()=>{m()}),[]),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t&&r!==t?n:void 0}),e.jsxs(am,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:"success"===c,fail:"error"===c}),e.jsx(mu,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:(()=>{switch(c){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),e.jsx("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(c){case"loading":return"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(h instanceof o.PrivyError){if(h.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(h.privyErrorCode===o.PrivyErrorCode.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(c){case"loading":case"success":return e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":return e.jsx(jo,{onClick:m,disabled:!1,children:"Retry"})}})()]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.PHANTOM_INTERSTITIAL_SCREEN]:()=>{let{forkSession:t,ready:r,authenticated:n}=o.usePrivy(),{walletConnectionStatus:s}=o.usePrivyInternal(),[l,c]=i.useState(""),[u,h]=i.useState(!1);i.useEffect((()=>{r&&n&&t().then(c)}),[r,n]);let p=((e,t,r)=>{let n=encodeURIComponent(new URL(window.location.href).href.replace(/\/$/g,"")+`?privy_token=${e}&privy_connector=${r?"solana_adapter":"injected"}&privy_wallet_client=${r?"phantom_solana":"phantom"}`);if(!d.isPhantomInstalled()&&a.isMobile)return`${t?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`})(l,!u,"solana"===s?.connector?.chainType),y={title:"Redirecting to Phantom Mobile Wallet",description:"We'll take you to the Phantom Mobile Wallet app to continue your login experience.",footnote:""};return r&&(y.description="For the best experience, we'll automatically log you into the Phantom Mobile Wallet in-app browser.",y.footnote="Once you're done, you can always return here and refresh to view your updated account."),u&&(y.title="Still here?",y.description="You may need to install the Phantom mobile app.",y.footnote="Once you're done, you can return here or connect via Phantom's in-app browser."),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(nl,{title:y.title,description:y.description}),e.jsxs(Hs,{children:[e.jsx(om,{children:e.jsx(qa,{style:{width:"72px",height:"72px"}})}),e.jsx(Po,{href:p,onClick:()=>{setTimeout((()=>h(!0)),1e3)},loading:r&&!p,children:u?"Go to App Store":"Continue"}),y.footnote?e.jsx("p",{children:y.footnote}):null]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LOGIN_FAILED_SCREEN]:()=>{let{closePrivyModal:t}=o.usePrivyInternal(),{navigate:r}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(Op,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),e.jsx(nl,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),e.jsxs(Hs,{children:[e.jsx(jo,{onClick:()=>r(g.ModalScreen.LANDING),children:"Try again"}),e.jsx(ko,{onClick:()=>t(),children:"Cancel"})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.AWAITING_OAUTH_SCREEN]:()=>{let{authenticated:t,logout:r,ready:n,user:a}=o.usePrivy(),{app:s,setModalData:c,navigate:h,resetNavigation:p}=g.usePrivyModal(),{getAuthMeta:y,initLoginWithOAuth:m,loginWithOAuth:f,updateWallets:v,setReadyToTrue:w,closePrivyModal:x,createAnalyticsEvent:C}=o.usePrivyInternal(),[E,b]=i.useState(!1),[S,A]=i.useState(void 0),j=y()?.provider||"google",{name:$,component:T}=ua(j),P=d.useEmitPrivyEvent();i.useEffect((()=>{f(j).then((e=>{b(!0),w(!0),e&&P("login","onOAuthLoginComplete",e)})).catch((e=>{if(w(!1),e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return A(void 0),p(),void h(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),A(void 0),p(),void h(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return A(void 0),p(),void h(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return A(void 0),p(),c({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:y()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void h(g.ModalScreen.LINK_CONFLICT_SCREEN);let{retryable:t,detail:r}=function(e,t){let r={detail:"",retryable:!1},n=Qi(t);if(e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode===o.PrivyErrorCode.OAUTH_USER_DENIED&&(r.detail=`Retry and check ${n} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=ua(t).name;r.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===o.PrivyErrorCode.OAUTH_ACCOUNT_SUSPENDED){let e=ua(t).name;r.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===o.PrivyErrorCode.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}(e,j);A({retryable:t,detail:r,message:"Authentication failed"})})).finally((()=>{pa()}))}),[$,j]),i.useEffect((()=>{if(n&&t&&E&&a){if(s?.legal.requireUsersAcceptTerms&&!a.hasAcceptedTerms){let e=setTimeout((()=>{h(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(a,s?.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:j,screen:"OAuthStatusScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),h(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}{let e=setTimeout((()=>x({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return v(),()=>clearTimeout(e)}}}),[n,t,E,a]);let _=E?`Successfully connected with ${$}`:S?S.message:`Verifying connection to ${$}`,k="";return k=E?"You’re good to go!":S?S.detail:"Just a few moments more",e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsx(Xs,{}),e.jsxs(im,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:E,fail:!!S}),e.jsx(T,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:_}),e.jsx("p",{children:k})]}),S&&S?.retryable?e.jsx(Io,{onClick:()=>{pa(),m(j),A(void 0)},disabled:!E&&!S?.retryable,children:"Retry"}):null]}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.CROSS_APP_AUTH_SCREEN]:()=>{let t=l.useAppConfig(),{data:r,navigate:n,setModalData:a,onUserCloseViaDialogOrKeybindRef:s}=g.usePrivyModal(),{crossAppAuthFlow:c,updateWallets:h,closePrivyModal:p,createAnalyticsEvent:y}=o.usePrivyInternal(),{logout:m}=d.useLogout(),[f,v]=i.useState({}),w=r?.crossAppAuth,x={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new o.PrivyClientError(`There was an issue connecting your ${x.name} account. Please try again.`),E=new Gi((async e=>{if(w.popup)try{let t=await c({appId:e,popup:w.popup,action:w.action});v({data:t})}catch(e){e instanceof o.PrivyClientError?v({error:e}):(e instanceof o.PrivyApiError&&w.popup&&w.popup.close(),v({error:C}))}else v({error:C})})),b=()=>{f.data&&(h(),w.onSuccess(f.data),p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(f.error??new o.PrivyClientError("User canceled flow")),p({shouldCallAuthOnSuccess:!1,isSuccess:!1})};s.current=b,i.useEffect((()=>{x.id.length&&E.execute(x.id)}),[x.id]),i.useEffect((()=>{if(!f.data)return;let e=f.data;if(t.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{n(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(e,t.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),y({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${x.id}`,screen:"CrossAppAuthScreen"}}),m()},callAuthOnSuccessOnClose:!0}}),n(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}let r=setTimeout(b,l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(r)}),[f.data]);let{title:S,subtitle:A}=i.useMemo((()=>f.data?{title:`Successfully connected with ${x.name}`,subtitle:"You're good to go!"}:f.error?{title:"Authentication failed",subtitle:f.error.message}:{title:`Connecting to ${x.name}`,subtitle:`Please check the pop-up from ${x.name} to continue`}),[f,x.name]);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:b}),e.jsx(Xs,{}),e.jsxs(Hl,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:!!f.data,fail:!!f.error}),e.jsx(Bl,{name:x.name,logoUrl:x.logoUrl})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:S}),e.jsx("p",{children:A})]})]}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.ALLOWLIST_REJECTION_SCREEN]:()=>{let{navigate:t,app:r}=g.usePrivyModal(),n=r?.allowlistConfig.errorTitle||"You don't have access to this app",i=r?.allowlistConfig.errorDetail||"Have you been invited?",a=r?.allowlistConfig.errorCtaText||"Try another account";return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsxs(Ws,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(os,{}),e.jsx(Ds,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),e.jsxs(Bs,{children:["string"==typeof n?e.jsx("h3",{children:n}):e.jsx(e.Fragment,{children:n}),"string"==typeof i?e.jsx("p",{children:i}):e.jsx(e.Fragment,{children:i})]}),r?.allowlistConfig.errorCtaLink?e.jsx(jo,{as:"a",href:r.allowlistConfig.errorCtaLink,children:a}):e.jsx(jo,{onClick:()=>{t(g.ModalScreen.LANDING)},children:a})]})]})},[g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN]:()=>{let{navigate:t,app:r}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsxs(is,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(Ro,{color:"var(--privy-color-warn-light)"}),e.jsx(Ue.default,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),e.jsxs(as,{children:[e.jsx("h3",{children:"Account not found"}),e.jsxs("p",{children:["Please try logging in again or go to ",r.name," to create an account."]})]}),e.jsx(Yo,{}),e.jsx(jo,{onClick:()=>t(g.ModalScreen.LANDING),children:"Try logging in again"})]})]})},[g.ModalScreen.USER_LIMIT_REACHED_SCREEN]:()=>{let{navigate:t}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsxs(Lf,{children:[e.jsx(Uf,{children:e.jsx(Ff,{})}),e.jsxs(Df,{children:[e.jsx("h3",{children:"Unable to sign in"}),e.jsx("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),e.jsx(jo,{onClick:()=>{t(g.ModalScreen.LANDING)},children:"Go back"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.INSTALL_PHANTOM_SCREEN]:()=>{let{navigateBack:t}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t},"header"),e.jsx(Xs,{}),e.jsx(ep,{}),e.jsx(Js,{}),e.jsxs(d.ModalFooter,{children:[e.jsx("span",{children:"Still not sure? "}),e.jsx("a",{target:"_blank",href:"https://ethereum.org/en/wallets/",children:"Learn more"})]})]})},[g.ModalScreen.LINK_EMAIL_SCREEN]:()=>{let{app:t}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Connect your email",description:`Add your email to your ${t?.name} account`,icon:e.jsx(Ke.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),e.jsx(Hs,{children:e.jsx(sp,{stacked:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LINK_PHONE_SCREEN]:()=>{let{app:t,currentScreen:r,data:n,navigate:i,setModalData:a}=g.usePrivyModal(),{initLoginWithSms:s}=o.usePrivyInternal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Connect your phone",description:`Add your number to your ${t?.name} account`,icon:e.jsx(Ye.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),e.jsx(Hs,{children:e.jsx(yp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await s(e),i(g.ModalScreen.AWAITING_PASSWORDLESS_CODE)}catch(e){a({errorModalData:{error:e,previousScreen:n?.errorModalData?.previousScreen||r||g.ModalScreen.LINK_PHONE_SCREEN}}),i(g.ModalScreen.ERROR_SCREEN)}},hideRecent:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LINK_WALLET_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),n=r?.externalConnectWallet?.suggestedAddress,i=n?e.jsxs("span",{children:["Link the wallet with address ",e.jsx(d.Address,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Link a wallet to your ${t?.name} account`;return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(nl,{title:"Link your wallet",description:i}),e.jsx(Xo,{children:e.jsx(Ol,{connectOnly:!1})}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LINK_PASSKEY_SCREEN]:()=>{let{user:t,unlinkPasskey:r}=o.usePrivy(),{linkWithPasskey:n,closePrivyModal:a}=o.usePrivyInternal(),s=t?.linkedAccounts.filter((e=>"passkey"===e.type)),[l,c]=i.useState(!1),[u,h]=i.useState(""),[p,y]=i.useState(!1),[m,f]=i.useState(!1);i.useEffect((()=>{0===s.length&&f(!1)}),[s.length]);let g=async e=>(c(!0),await r(e).then((()=>y(!0))).catch((e=>{e instanceof o.PrivyError&&e.privyErrorCode===o.PrivyErrorCode.MISSING_MFA_CREDENTIALS?h("Cannot unlink a passkey enrolled in MFA"):h("Unknown error occurred.")})).finally((()=>{c(!1)})));return p?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:()=>a()},"header"),e.jsx(xs,{children:e.jsx(Rs,{status:"success",children:e.jsx(Ze.default,{})})}),e.jsx(bu,{children:"Passkey added"}),e.jsx(Su,{children:"From now on, you can use your passkey to log in."}),e.jsx($s,{children:e.jsx(jo,{onClick:()=>a(),children:"Done"})}),e.jsx(d.ModalFooter,{})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>f(!1),onClose:()=>a()},"header"),e.jsx(fu,{passkeys:s,expanded:m,onUnlink:g,onExpand:()=>f(!0)}),e.jsx(d.ModalFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:()=>a()},"header"),e.jsx(xs,{children:e.jsxs(vu,{children:[e.jsx(yu,{}),e.jsx(mu,{})]})}),e.jsx(bu,{children:"Secure your account with a passkey"}),e.jsx(Au,{}),0===s.length?e.jsx(gu,{}):e.jsx(fu,{passkeys:s,expanded:m,onUnlink:g,onExpand:()=>f(!0)}),e.jsxs($s,{style:{marginTop:"12px"},children:[u&&e.jsx(wu,{$fail:!0,children:u}),e.jsx(jo,{onClick:()=>{c(!0),n().then((()=>y(!0))).catch((e=>{if(e instanceof o.PrivyError){if(e.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)return void h("Cannot link more passkeys to account.");if(e.privyErrorCode===o.PrivyErrorCode.PASSKEY_NOT_ALLOWED)return void h("Passkey request timed out or rejected by user.")}h("Unknown error occurred.")})).finally((()=>{c(!1)}))},loading:l,children:"Add new passkey"})]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.UPDATE_EMAIL_SCREEN]:()=>e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:e.jsx(Ke.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),e.jsx(Hs,{children:e.jsx(Mf,{stacked:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]}),[g.ModalScreen.UPDATE_PHONE_SCREEN]:()=>{let{currentScreen:t,data:r,navigate:n,setModalData:i}=g.usePrivyModal(),{user:a}=o.usePrivy(),{initUpdatePhone:s}=o.usePrivyInternal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:e.jsx(Ye.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),e.jsx(Hs,{children:e.jsx(yp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!a?.phone?.number)throw Error("User is required to have an phone number to update it.");await s(a?.phone?.number,e),n(g.ModalScreen.AWAITING_PASSWORDLESS_CODE)}catch(e){i({errorModalData:{error:e,previousScreen:r?.errorModalData?.previousScreen||t||g.ModalScreen.LINK_PHONE_SCREEN}}),n(g.ModalScreen.ERROR_SCREEN)}},hideRecent:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.CONNECT_ONLY_LANDING_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),n=r?.externalConnectWallet?.suggestedAddress,i=n?e.jsxs("span",{children:["Connect the wallet with address ",e.jsx(d.Address,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Connect a wallet to your ${t?.name} account`;return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(rl,{title:"Connect your wallet",description:i}),e.jsx(Xo,{children:e.jsx(Ol,{connectOnly:!0})}),t&&e.jsx(d.TermsAndConditions,{app:t,alwaysShowImplicitConsent:!0}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.CONNECT_ONLY_AUTHENTICATED_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),n=r?.externalConnectWallet?.suggestedAddress,i=n?`Connect the wallet with address ${d.formatWalletAddress(n)} ${t?.name?`to ${t.name}.`:"."}`:`Connect a wallet to ${t?.name}`;return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(nl,{title:"Connect your wallet",description:i}),e.jsx(Xo,{children:e.jsx(Ol,{connectOnly:!0})}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN]:()=>{let{app:t,setModalData:r,navigate:n,data:a,onUserCloseViaDialogOrKeybindRef:s}=g.usePrivyModal(),[d,c]=i.useState(""),{embeddedWallets:u}=l.useAppConfig(),{authenticated:h,user:p}=o.usePrivy(),{closePrivyModal:y}=o.usePrivyInternal(),{onSuccess:m,onFailure:f,callAuthOnSuccessOnClose:v}=a.createWallet,w=!0===t?.embeddedWallets.requireUserOwnedRecoveryOnCreate,{createWallet:x}=Cd(),[C,E]=i.useState(null),b=new Gi((async()=>{try{let e=await x({user:p});if(!e)return;E(e),n(g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN)}catch(e){c(e.message)}}));return i.useEffect((()=>h&&p?w?(r({...a,recoverySelection:{...a?.recoverySelection,isInAccountCreateFlow:!0}}),n(ld({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:u.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void b.execute():(n(g.ModalScreen.LANDING),void f(Error("User must be authenticated before creating a Privy wallet")))),[w,h]),s.current=()=>null,d?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{closeable:!1}),e.jsxs(Vs,{children:[e.jsx(Xe.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),e.jsx(il,{title:"Something went wrong",description:d})]}),e.jsx(jo,{onClick:()=>{C?(m(C),y({shouldCallAuthOnSuccess:v})):(f(new o.PrivyEmbeddedWalletError("User wallet creation failed")),y({shouldCallAuthOnSuccess:!1}))},children:"Close"}),e.jsx(Ed,{})]}):e.jsx(Vl,{})},[g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN]:()=>{let{user:t}=o.usePrivy(),{closePrivyModal:r,isNewUserThisSession:n,updateWallets:a}=o.usePrivyInternal(),{app:s,data:c,onUserCloseViaDialogOrKeybindRef:h}=g.usePrivyModal(),{onSuccess:p,onFailure:y,callAuthOnSuccessOnClose:m}=c.createWallet,f=()=>{let e=u.getPrivyEthereumWallet(t);e?(a(),p(e)):y(Error("Failed to create wallet")),r({shouldCallAuthOnSuccess:m})};return i.useEffect((()=>{let e=setTimeout(f,l.DEFAULT_SUCCESS_SCREEN_LONG_DURATION_MS);return()=>clearTimeout(e)}),[]),h.current=f,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:f}),e.jsx(Xs,{}),e.jsxs(Vs,{children:[e.jsx(Ze.default,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),e.jsx(il,{title:n?"Welcome"+(s?.name?` to ${s?.name}`:""):"All set!",description:n?"You’ve successfully created an account.":"Your account is secured."})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_CONNECTING_SCREEN]:()=>{let{authenticated:t,user:r,getAccessToken:n}=o.usePrivy(),{closePrivyModal:a,createAnalyticsEvent:s,walletProxy:l}=o.usePrivyInternal(),{navigate:d,data:c,setModalData:h,onUserCloseViaDialogOrKeybindRef:p}=g.usePrivyModal(),y=i.useMemo((()=>Date.now()),[]),[m,f]=i.useState(!1),{onCompleteNavigateTo:v,onFailure:w,shouldForceMFA:x,address:C}=c?.connectWallet,E=e=>{m||(f(!0),w("string"==typeof e?Error(e):e))};i.useEffect((()=>{let e,i=C?r?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.address===C)):u.getPrivyEthereumWallet(r);return t&&i?l?((async()=>{let t=await n();if(!t)return E("User must be authenticated and have a Privy wallet before it can be connected");let r="ethereum"===i.chainType;try{r?await l.connect({accessToken:t,address:i.address}):await l.connectSolana({accessToken:t,publicKey:i.address}),x&&await l.verifyMfa({accessToken:t});let n=(Date.now()-y)/1e3;v===g.ModalScreen.EMBEDDED_WALLET_KEY_EXPORT_SCREEN&&n<1?e=setTimeout((()=>{d(v,!1)}),1e3*(1-n)):d(v,!1)}catch(e){if(td(e)&&"privy"===i.recoveryMethod){let e=await n();if(!e)return E("User must be authenticated and have a Privy wallet before it can be recovered");try{if(s({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:i.address}}),r){let t=await(l?.recover({address:i.address,accessToken:e,recoveryMethod:i.recoveryMethod}));t?.address||E(Error("Unable to recover wallet"))}else{let t=await(l?.recoverSolana({publicKey:i.address,accessToken:e}));t?.publicKey||E(Error("Unable to recover wallet"))}v?d(v):a({shouldCallAuthOnSuccess:!1}),s({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:i.address}}),d(v)}catch(e){E("An error has occurred, please try again.")}}else td(e)&&"privy"!==i.recoveryMethod?(h({...c,recoverWallet:{privyWallet:i,onCompleteNavigateTo:v,onFailure:w},recoveryOAuthStatus:{provider:i.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),d(dd(i.recoveryMethod))):E(e)}})(),()=>clearTimeout(e)):void 0:E("User must be authenticated and have a Privy wallet before it can be connected")}),[t,r,l]);let b=()=>{E("User exited before wallet could be connected"),a({shouldCallAuthOnSuccess:!1})};return p.current=b,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:b}),m?e.jsxs(e.Fragment,{children:[e.jsxs(Vs,{children:[e.jsx(Xe.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),e.jsx(il,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),e.jsx(jo,{onClick:()=>a({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):e.jsx(Vl,{}),e.jsx(hd,{})]})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN]:()=>{let[t,r]=i.useState(!0),{authenticated:n,getAccessToken:a}=o.usePrivy(),{walletProxy:s,closePrivyModal:l,createAnalyticsEvent:c}=o.usePrivyInternal(),{navigate:u,data:h,onUserCloseViaDialogOrKeybindRef:p}=g.usePrivyModal(),[y,m]=i.useState(void 0),[f,v]=i.useState(""),[w,x]=i.useState(!1),{privyWallet:C,onCompleteNavigateTo:E,onSuccess:b,onFailure:S}=h.recoverWallet,A=(e="User exited before their wallet could be recovered")=>{l({shouldCallAuthOnSuccess:!1}),S("string"==typeof e?new o.PrivyEmbeddedWalletError(e):e)};p.current=A,i.useEffect((()=>{if(!n||!C)return A("User must be authenticated and have a Privy wallet before it can be recovered")}),[n]);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A}),e.jsx(Xs,{}),e.jsxs(lm,{children:[e.jsxs(sm,{children:[e.jsx(Pt.default,{height:48,width:48,stroke:"var(--privy-color-accent)"}),e.jsx("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),e.jsx("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),e.jsxs("div",{children:[e.jsxs(_d,{children:[e.jsx(Td,{type:t?"password":"text",onChange:e=>(e=>{e&&m(e)})(e.target.value),disabled:w,style:{paddingRight:"2.3rem"}}),e.jsx(Od,{style:{right:"0.75rem"},children:t?e.jsx(Fd,{onClick:()=>r(!1)}):e.jsx(Ld,{onClick:()=>r(!0)})})]}),!!f&&e.jsx(dm,{children:f})]}),e.jsxs("div",{children:[e.jsxs(Zs,{children:[e.jsx("h4",{children:"Why is this necessary?"}),e.jsx("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),e.jsx(cm,{loading:w||!s,disabled:!y,onClick:async()=>{x(!0);let e=await a();if(!e||!C||null===y)return A("User must be authenticated and have a Privy wallet before it can be recovered");try{c({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:C.address}}),await(s?.recover({address:C.address,accessToken:e,recoveryPin:y,recoveryMethod:C.recoveryMethod})),v(""),E?u(E):l({shouldCallAuthOnSuccess:!1}),b?.(C),c({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:C.address}})}catch(e){!function(e){return ed(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{x(!1)}},warn:!1,hideAnimations:!C&&w,children:"Recover your account"})]})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN]:()=>{let[t,r]=i.useState(!1),{navigate:n,lastScreen:a,navigateBack:s,setModalData:c,data:h,onUserCloseViaDialogOrKeybindRef:p}=g.usePrivyModal(),{user:y}=o.usePrivy(),{embeddedWallets:m}=l.useAppConfig(),{closePrivyModal:f}=o.usePrivyInternal(),v=u.getPrivyEthereumWallet(y),w=null===v,{isInAccountCreateFlow:x,isResettingPassword:C}=h.recoverySelection,E=v&&"privy"!==v.recoveryMethod,b=E?e.jsxs("span",{children:["Your account is currently secured using"," ",e.jsx("strong",{children:gm[v?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function S(e){c({recoveryOAuthStatus:{provider:e,action:w?"create-wallet":"set-recovery",isInAccountCreateFlow:x}}),n(g.ModalScreen.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN)}function A(){h?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),f({shouldCallAuthOnSuccess:h?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return p.current=A,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A,backFn:t?()=>r(!1):a?s:void 0,infoFn:a||t?void 0:()=>r(!0)},"header"),t?e.jsx(vm,{onClose:()=>r(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(il,{title:E?"Update backup method":"Secure your account",icon:e.jsx(It.default,{width:48}),description:b}),e.jsx(pm,{children:m.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(v?.recoveryMethod||"")||e!==v?.recoveryMethod)).sort().map((t=>{switch(t){case"google-drive":return e.jsxs(ts,{onClick:()=>S("google-drive"),children:[e.jsx(fm,{children:e.jsx(hm,{style:{width:18}})}),"Back up to Google Drive"]},t);case"icloud":return e.jsxs(ts,{onClick:()=>S("icloud"),children:[e.jsx(fm,{children:e.jsx(um,{style:{width:24}})}),"Back up to Apple iCloud"]},t);case"user-passcode":return e.jsxs(ts,{onClick:()=>{n(sd({isCreatingWallet:w,skipSplashScreen:!0}))},children:[e.jsx(fm,{children:e.jsx(Mt.default,{style:{width:18}})}),C?"Reset your":"Set a"," password"]},t);default:return null}}))})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN]:()=>{let{user:t,getAccessToken:r}=o.usePrivy(),n=u.getPrivyEthereumWallet(t),{walletProxy:a,refreshUser:s,closePrivyModal:c}=o.usePrivyInternal(),h=g.usePrivyModal(),[p,y]=i.useState(!1),[m,f]=i.useState(null),[v,w]=i.useState(null);function x(){if(!p){if(v)return h.data?.setWalletPassword?.onFailure(v),void c();if(!m)return h.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void c()}}h.onUserCloseViaDialogOrKeybindRef.current=x;let C=!(!p&&!m);return v?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:x},"header"),e.jsx(wm,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:e.jsx(He.default,{height:38,width:38,stroke:"var(--privy-color-error)"})}),e.jsx(fd,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),e.jsx(Yo,{style:{minHeight:"2rem"}}),e.jsx($o,{onClick:()=>w(null),children:"Try again"}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:x},"header"),e.jsx(It.default,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),e.jsx(fd,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),e.jsx(md,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),e.jsx(Yo,{style:{minHeight:"2rem"}}),e.jsx($o,{loading:p,disabled:C,onClick:()=>async function(){y(!0);try{let e=await r();if(!e||!a||!n)return;if(!(await a.setRecovery({recoveryMethod:"privy",address:n.address,accessToken:e})).address)throw Error("Unable to set recovery on wallet");let t=await s();if(!t)throw Error("Unable to set recovery on wallet");let i=u.getPrivyEthereumWallet(t);if(!i)throw Error("Unabled to set recovery on wallet");f(!!t),setTimeout((()=>{h.data?.setWalletPassword?.onSuccess(i),c()}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}catch(e){w(e)}finally{y(!1)}}(),children:m?"Success":"Confirm"}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN]:()=>{let{logout:t}=o.usePrivy(),{navigate:r,setModalData:n,data:a}=g.usePrivyModal(),{recoveryOAuthFlow:s,closePrivyModal:c,createAnalyticsEvent:u}=o.usePrivyInternal(),[h,p]=i.useState(!1),{provider:y,action:m,isInAccountCreateFlow:f}=a?.recoveryOAuthStatus,[v,w]=i.useState(void 0),[x,C]=i.useState("create-wallet"===m);if("user-passcode"===y)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let E=mm[y].name,b=mm[y].component,S=a?.recoverWallet?.onCompleteNavigateTo,A=new Gi((async(e="create-wallet")=>(C(!0),new Promise(((t,r)=>{setTimeout((async()=>{try{let r=window.open();await s(y,e,r),p(!0),t()}catch(t){w({message:`${"recover"===e?"Recovery":"Back up"} with ${E} unsuccessful`,detail:"recover"===m?`Please verify that you are selecting the ${E} account associated with your backup.`:"",retryable:!0}),r()}}),0)})))));i.useEffect((()=>{"recover"!==m&&A.execute(f?"create-wallet":"set-recovery")}),[]),i.useEffect((()=>{if(!h)return;let e=setTimeout((()=>{f?(n({createWallet:{onSuccess:()=>{},onFailure:e=>{u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"RecoveryOAuthScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),r(g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN)):c({shouldCallAuthOnSuccess:!1})}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}),[h]);let j=i.useCallback((async()=>{await A.execute("recover"),S?r(S):p(!0)}),[]),$="google-drive"===y?"Google Drive":"Apple iCloud",T=h&&`Successfully ${"recover"===m?"recovered":"backed up"} with ${$}.`||v&&v.message||`${"recover"===m?"Recovering":"Backing up"} with ${$}...`,P=v?v.detail:"";return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),x?e.jsx(e.Fragment,{children:e.jsxs(pm,{children:[e.jsx(il,{title:T,icon:e.jsx(b,{style:{width:"38px",height:"38px"}}),description:P}),v&&v?.retryable?e.jsx(jo,{onClick:()=>{pa(),w(void 0),"create-wallet"===m?A.execute("create-wallet"):j()},disabled:!h&&!v?.retryable,children:"Try again"}):null]})}):e.jsxs(pm,{children:[e.jsx(il,{title:"Confirm it's really you",icon:e.jsx(b,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${$} where your account is backed up.`}),e.jsxs(jo,{onClick:j,children:["Confirm with ",$]})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_KEY_EXPORT_SCREEN]:()=>{let[t,r]=i.useState(null),{authenticated:n,user:a,getAccessToken:s}=o.usePrivy(),{closePrivyModal:c,createAnalyticsEvent:u,clientAnalyticsId:h}=o.usePrivyInternal(),p=l.useAppConfig(),{data:y,onUserCloseViaDialogOrKeybindRef:m}=g.usePrivyModal(),{onFailure:f,onSuccess:v,origin:w,appId:x,appClientId:C,wallet:E}=y.keyExport,b=e=>{c({shouldCallAuthOnSuccess:!1}),f("string"==typeof e?Error(e):e)},S=()=>{c({shouldCallAuthOnSuccess:!1}),v(),u({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return i.useEffect((()=>{if(!n||!E)return b("User must be authenticated before exporting their wallet");s().then(r,b)}),[n,a]),m.current=S,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:S}),e.jsxs(vd,{children:[e.jsx(fd,{children:"Transfer wallet"}),e.jsxs(md,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",e.jsx("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),e.jsx(pd,{theme:p.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),e.jsx(d.WalletInfoCard,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),e.jsx("div",{style:{width:"100%"},children:t&&e.jsx(gd,{origin:w,appId:x,appClientId:C,accessToken:t,clientAnalyticsId:h,wallet:E,dimensions:{height:"44px"}})})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN]:()=>{let{authenticated:t}=o.usePrivy(),{initializeWalletProxy:r,closePrivyModal:n}=o.usePrivyInternal(),{navigate:a,data:s,onUserCloseViaDialogOrKeybindRef:c}=g.usePrivyModal(),[u,h]=i.useState(!0),[p,y]=i.useState(""),[f,v]=i.useState(),[w,x]=i.useState(null),[C,E]=i.useState(!1),b=null!==w;i.useEffect((()=>{t||a(g.ModalScreen.LANDING)}),[t]),i.useEffect((()=>{r(l.WALLET_PROXY_TIMEOUT).then((e=>{h(!1),e||(y("An error has occurred, please try again."),v(new m.PrivyProviderRpcError(new m.ProviderRpcError(p,m.E.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:S,data:A,confirmAndSign:j,onSuccess:$,onFailure:T,uiOptions:P}=s.signMessage,_={title:P.title||"Sign message",description:P.description||"Signing this message will not cost you any fees.",buttonText:P.buttonText||"Sign and continue"},k=e=>{e?$(e):T(f||new m.PrivyProviderRpcError(new m.ProviderRpcError("The user rejected the request.",m.E.E4001_USER_REJECTED_REQUEST.eipCode))),n({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{x(null),y(""),v(void 0)}),200)};return c.current=()=>{k(w)},e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:()=>k(w)}),e.jsx(Xs,{}),P.iconUrl&&"string"==typeof P.iconUrl?e.jsx(kf,{children:e.jsx(Ef,{size:"sm",src:P.iconUrl,alt:"app image"})}):null,e.jsx(fd,{children:_.title}),e.jsx(md,{children:_.description}),"personal_sign"===S&&e.jsx($f,{children:bf(A)}),"eth_signTypedData_v4"===S&&e.jsx(jf,{typedData:A}),"solana_signMessage"===S&&e.jsx($f,{children:A}),e.jsx(Nf,{}),e.jsx(Pf,{$fail:!0,children:p}),e.jsx($o,{disabled:C||b||u,loading:C,onClick:async()=>{E(!0),y("");try{let e=await j();x(e),E(!1),setTimeout((()=>{k(e)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}catch(e){console.error(e),y("An error has occurred, please try again."),v(new m.PrivyProviderRpcError(new m.ProviderRpcError(p,m.E.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),E(!1)}},children:C?"Signing...":b?e.jsxs(_f,{children:[e.jsx(fc,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",e.jsx("span",{children:"Success"})]}):_.buttonText}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN]:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:r,setModalData:n,navigate:a}=g.usePrivyModal(),{rpcConfig:s,chains:c,closePrivyModal:u,walletProxy:h}=o.usePrivyInternal(),{getAccessToken:p,user:y}=o.usePrivy(),f=l.useAppConfig(),[v,w]=i.useState(0),x=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(t),[C,E]=i.useState(((e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0)(t,v)),[b,S]=i.useState(null),[A,j]=i.useState(),[$,T]=i.useState(!1),[P,_]=i.useState(null),[k,N]=i.useState(null);if(!C||!t?.sendTransaction||!t?.sendTransaction.transactingWallet)return e.jsx(pc,{error:Error("Invalid transaction request"),onClick:()=>{t?.sendTransaction?.onFailure(Cf),u({shouldCallAuthOnSuccess:!1})}});let I=t.sendTransaction.rootWallet,M=t.sendTransaction.transactingWallet,O=i.useMemo((()=>c.find((e=>Number(e.id)===Number(C.chainId)))),[C.chainId]),R=O?.nativeCurrency.symbol??"ETH",{action:F,amount:L,spender:U,isErc20Ish:D}=i.useMemo((()=>(e=>{let t=vf(e);if(t)return{action:"approve",isErc20Ish:!0,functionName:t.functionName,spender:t.args[0],amount:t.args[1]};let r=wf(e);return r?{action:"transfer",isErc20Ish:!0,functionName:r.functionName,amount:r.args[1]}:{action:"transaction",isErc20Ish:!1}})(C.data)),[C.data]);i.useEffect((()=>{C.to&&O&&D&&dh({address:C.to,chain:O,rpcConfig:f.rpcConfig,privyAppId:f.id}).then(S).catch(console.error)}),[C.to,O]);let{tokenPrice:W,isTokenPriceLoading:B}=Hc(C),H=i.useMemo((()=>d.getJsonRpcProvider(Number(C.chainId),c,s,{appId:f.id})),[C.chainId,s]),G=xf(C,M,H);i.useEffect((()=>{t.sendTransaction?.getIsSponsored?t.sendTransaction.getIsSponsored().then(j).catch(console.error):j(!1)}),[t.sendTransaction.getIsSponsored]);let q=()=>{if(!$)return P?t?.sendTransaction?.onSuccess(P.response):k||G?.errors[0]?t?.sendTransaction?.onFailure(k??G?.errors[0]??Cf):t?.sendTransaction?.onFailure(new m.PrivyProviderRpcError(new m.ProviderRpcError("The user rejected the request",m.E.E4001_USER_REJECTED_REQUEST.eipCode))),u({shouldCallAuthOnSuccess:!1})};r.current=q;let z=!!(f.fundingConfig&&f.fundingConfig.methods.length>0&&t.funding),V="fiat-currency"===f.embeddedWallets.priceDisplay.primary,K=d.i(G?.tx.value??0).add(d.i(G?.totalGasEstimate?.toBigInt()??0)).toHexString(),Y=d.getNativeCurrencyFromWei(K,R),Z=V&&W?d.getDollarsFromWei(K,W):void 0,X=d.getNativeCurrencyFromWei(G?.totalGasEstimate?.toString()??0,R),J=V&&W?d.getDollarsFromWei(G?.totalGasEstimate?.toString()??0,W):void 0,Q=d.getNativeCurrencyFromWei(G?.balance?.toString()??0,R,void 0,!0),ee=V&&W?d.getDollarsFromWei(G?.balance?.toString()??0,W):void 0,te=t.sendTransaction?.uiOptions?.transactionInfo?.title||("approve"===F?"Confirm address":`Approve ${F}`),re=t.sendTransaction?.uiOptions?.description||`${f.name} wants your permission to approve the following transaction.`,ne=t.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?e.jsx("img",{src:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,ie=!(!G||G.errors[0]||G.hasFunds||!1!==A),ae=ie&&z,oe=ae?"Add funds":t.sendTransaction?.uiOptions?.buttonText||(v<x?"Continue":"Approve");if(P?.receipt)return e.jsx(mf,{txn:G?.tx??C,onClose:q,receipt:P.receipt,transactionInfo:t.sendTransaction?.uiOptions.transactionInfo,tokenPrice:W,tokenSymbol:R,l1GasEstimate:G?.l1ExecutionFeeEstimate?.toString(),receiptHeader:t.sendTransaction?.uiOptions.successHeader,receiptDescription:t.sendTransaction?.uiOptions.successDescription});if(k)return e.jsx(Nm,{transactionError:k,network:"ethereum",chainId:G?.tx.chainId??C.chainId,onClose:q,onRetry:({resetNonce:e})=>{N(null);let t={...G?.tx??C};e&&(t.nonce=void 0),E(t)}});let se=0!==x&&"number"==typeof v&&0!==v?()=>{w(v-1)}:void 0;return e.jsx(bm,{transactionIndex:v,onBack:se,maxIndex:x,disabled:ie&&!z,isSubmitting:$,submitError:k,isPreparing:!G,isTokenPriceLoading:B,isTokenContractInfoLoading:!b,prepareError:G?.errors[0],symbol:b?.symbol,chain:O,img:ne,title:te,subtitle:re,spender:U,total:C.value?Z??Y:void 0,txValue:C.value,fee:J??X,isSponsored:A,to:C.to,network:f.chains.find((e=>e.id===C.chainId))?.name??"",from:M?.address??"",cta:oe,missingFunds:ie,action:F,balance:ee??Q,amount:L&&b?qc({amount:L,decimals:b.decimals}):L,onClose:q,onClick:ae?async()=>{if(!M)return;if(!z)throw Error("Funding wallet is not enabled");let e=pf({fundingMethods:f.fundingConfig.methods});n({...t,funding:{...t.funding,methodScreen:e}}),a(e)}:async()=>{if(v<x)w(v+1);else{T(!0);try{let e=await p();if($||!e||!M||!h||!y)return;let r=t?.sendTransaction?.onConfirm?await t.sendTransaction.onConfirm().then((e=>H.getTransaction(e))):await nf({accessToken:e,transactingWallet:M,rootWallet:I,walletProxy:h,transactionRequest:G?.tx??C,provider:H,requesterAppId:t.sendTransaction?.requesterAppId}),n=await r.wait();_({receipt:of(n),response:r})}catch(e){console.warn({transaction:G?.tx??C,error:e}),N(e)}finally{T(!1)}}}})},[g.ModalScreen.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN]:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:r}=g.usePrivyModal(),{closePrivyModal:n,walletProxy:a}=o.usePrivyInternal(),s=l.useAppConfig(),{user:d}=o.usePrivy(),[c,u]=i.useState(t?.sendSolanaTransaction?.transactionRequest),[h,p]=i.useState(),[y,m]=i.useState(),[f,v]=i.useState(0),[w,x]=i.useState(!1),[C,E]=i.useState(),[b,S]=i.useState(null),A=t?.sendSolanaTransaction?.connection,j=t?.sendSolanaTransaction?.transactingWallet,$=h?.instructions.at(f),T=h?.instructions.length??1;if(i.useEffect((()=>{!async function(){if(c&&A)try{m(void 0);let e=await vy(c,A);p(e),v(0)}catch(e){console.warn("Failed to prepare transaction",e),m(e)}}()}),[c,A]),!(c&&t?.sendSolanaTransaction&&j&&A)){let r=Error("Invalid transaction request");return e.jsx(pc,{error:r,onClick:()=>{t?.sendSolanaTransaction?.onFailure(r),n({shouldCallAuthOnSuccess:!1})}})}let{solPrice:P,isSolPriceLoading:_}=(()=>{let{showFiatPrices:e,getUsdPriceForSol:t}=o.usePrivyInternal(),[r,n]=i.useState(!0),[a,s]=i.useState(void 0),[l,d]=i.useState(void 0);return i.useEffect((()=>{(async()=>{if(e)try{n(!0);let e=await t();e?d(e):s(Error("Unable to fetch SOL price"))}catch(e){s(e)}finally{n(!1)}else n(!1)})()}),[]),{solPrice:l,isSolPriceLoading:r,solPriceError:a}})(),k=()=>{if(!w)return C?t?.sendSolanaTransaction?.onSuccess(C):(t?.sendSolanaTransaction?.onFailure(b??y??Error("User exited the modal before submitting the transaction")),v(0)),n({shouldCallAuthOnSuccess:!1})};r.current=k;let N="fiat-currency"===s.embeddedWallets.priceDisplay.primary,I=t.sendTransaction?.uiOptions?.transactionInfo?.title||("approve"===$?.action?"Confirm address":"Approve transaction"),M=t.sendTransaction?.uiOptions?.description||`${s.name} wants your permission to approve the following transaction.`,O=t.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?e.jsx("img",{src:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,R=$?.amount||0n,F=0===f&&h?.fees||0n,L=$?.balance||0n,U=$?.from,D=$?.to,W=R+F,B=uy(W),H=N&&P?hy(W,P):void 0,G=F?uy(F):void 0,q=N&&P?hy(F,P):void 0,z=L?uy(L):void 0,V=N&&P?hy(L,P):void 0,K=t.sendTransaction?.uiOptions?.buttonText||"Approve";return C?e.jsx(tf,{instructions:h?.instructions.map((({from:e,to:t,amount:r})=>({from:e.toBase58(),to:t.toBase58(),amount:r})))??[],fees:0===f?C.fees:0n,onClose:k,transactionInfo:t.sendTransaction?.uiOptions.transactionInfo,solPrice:P,receiptHeader:t.sendTransaction?.uiOptions.successHeader,receiptDescription:t.sendTransaction?.uiOptions.successDescription,rpcEndpoint:A.rpcEndpoint}):b?e.jsx(Nm,{transactionError:b,connection:A,onClose:k,network:"solana",onRetry:async()=>{S(null);let{blockhash:e}=await A.getLatestBlockhash();$e.isVersionedTransaction(c)?c.message.recentBlockhash=e:c.recentBlockhash=e,u(c)}}):e.jsx(bm,{isSubmitting:w,submitError:b,isPreparing:!h,isTokenPriceLoading:_,isTokenContractInfoLoading:!1,symbol:"SOL",chain:void 0,img:O,title:I,subtitle:M,from:U?.toBase58()||"",to:D?.toBase58(),fee:q??G,total:null!=R?H??B:void 0,txValue:R,spender:$?.spender?.toBase58(),network:"Solana",cta:K,missingFunds:!y&&!$?.hasFunds,action:$?.action,balance:V??z,prepareError:y,chainName:"Solana",onClose:k,onClick:async()=>{if(f<(h?.instructions.length??1)-1)v(f+1);else try{x(!0);let e=await Sg();if(w||!e||!j||!a||!d)return;let{signature:r,receipt:n}=await Cm({tx:c,accessToken:e,connection:A,walletProxy:a,transactingWalletAddress:j.address,transactionOptions:t.sendSolanaTransaction?.transactionOptions});E(gy(r,n))}catch(e){console.warn({transaction:c,error:e}),S(e)}finally{x(!1)}},isSponsored:!1,transactionIndex:f,maxIndex:T-1,disabled:!$?.hasFunds,onBack:f>0&&T>1?()=>v(f-1):void 0})},[g.ModalScreen.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),{closePrivyModal:n}=o.usePrivyInternal(),[a,s]=i.useState(!1),[c,u]=i.useState(),h=async()=>{a?r?.delegatedActions?.onSuccess():r?.delegatedActions?.onError(c??new o.PrivyClientError("User declined delegating actions.")),n({shouldCallAuthOnSuccess:!1})};return i.useEffect((()=>{if(!a&&!c)return;let e=setTimeout(h,l.DEFAULT_SUCCESS_SCREEN_LONG_DURATION_MS);return()=>clearTimeout(e)}),[a,c]),a||c?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:h}),e.jsx(Xs,{}),e.jsxs(qs,{children:[c?e.jsx(T.ExclamationCircleIcon,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):e.jsx(T.CheckCircleIcon,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),e.jsx(el,{height:20}),e.jsx(il,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":"You've successfully delegated actions."})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{closeable:!0,onClose:h}),e.jsx(Gl,{width:56,height:56,style:{margin:"auto"}}),e.jsx(Cs,{style:{marginTop:24},children:"Enable delegated actions"}),e.jsxs(Es,{children:["Give ",t.name," permissions to transact on your behalf. You can revoke this later."," ",e.jsx("a",{style:{color:"var(--privy-color-accent-dark)"},href:"https://www.privy.io/using-privy",target:"_blank",children:"Learn more"})]}),e.jsx(zl,{showIcon:!0,address:r?.delegatedActions?.address??"",title:"Wallet",isLoading:!1}),e.jsxs(ql,{style:{marginTop:24},children:[e.jsx(ko,{onClick:h,children:"No thanks"}),e.jsx(jo,{onClick:async()=>{try{await(r?.delegatedActions?.onDelegate()),s(!0)}catch(e){u(e)}},children:"Accept"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_METHOD_SELECTION_SCREEN]:()=>{let{wallets:r}=l.useWallets(),{navigate:n,data:a,setModalData:o}=g.usePrivyModal(),s=l.useAppConfig(),c=a?.funding,u=i.useRef(null),[h,p]=i.useState(!1);i.useEffect((()=>{u.current&&u.current.style.setProperty("--funding-input-length",Math.max(c.amount.length,1).toString())}),[c.amount,u.current]);let y=s.fundingConfig?.methods.slice()??[],{tokenPrice:m}=Hc({chainId:c.chain.id});i.useEffect((()=>{c.erc20Address&&c.chain&&!c.erc20ContractInfo&&dh({address:c.erc20Address,chain:c.chain,rpcConfig:s.rpcConfig,privyAppId:s.id}).then((e=>o({...a,funding:{...a.funding,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}}))).catch(console.error)}),[c.erc20Address,c.chain]);let f=m?d.getDollarsFromStringFloat(c.amount,m):void 0,v=r.find((e=>t.getAddress(e.address)===t.getAddress(c.address))),w=v&&"privy"!==v.walletClientType?Sl(v.walletClientType,v.connectorType,v.walletClientType):s.name,x=parseFloat(c.amount),C=!isNaN(x)&&x>0,E=!(!c.erc20Address||c.erc20ContractInfo),b=c.isUSDC?"USDC":c.erc20Address?void 0:"native-currency",S=b&&((e,t)=>{switch(t){case"native-currency":return hh.has(e);case"USDC":return ph.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}})(Number(c.chain.id),b),A=b&&((e,t)=>{switch(t){case"native-currency":return Qu.has(e);case"USDC":return eh.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}})(Number(c.chain.id),b),j=c.erc20Address||!c.erc20Address&&!c.isUSDC;return e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsxs("h3",{children:["Add funds to your"," ",w?.toLowerCase().endsWith("wallet")?w:w+" wallet"]}),e.jsx(Ks,{style:{marginTop:"32px"},children:e.jsx(Mu,{children:E?e.jsx(Lc,{size:"50px"}):e.jsxs(e.Fragment,{children:[e.jsxs(Ou,{onClick:()=>u.current?.focus(),children:[e.jsx(Fu,{ref:u,value:c.amount,onFocus:()=>p(!0),onBlur:()=>p(!1),onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&o({...a,funding:{...c,amount:t}})}}),e.jsx(Uu,{children:c.erc20Address?c.erc20ContractInfo?.symbol:c.chain.nativeCurrency.symbol}),!h&&e.jsx(Lu,{children:e.jsx(ft.default,{width:12,height:12})})]}),!c.erc20Address&&e.jsx(Du,{children:f&&C?f:""})]})})}),e.jsxs(Nu,{children:[c.errorMessage&&e.jsx(sh,{children:c.errorMessage}),y.sort().map((t=>{switch(t){case"moonpay":return S?e.jsxs(ts,{disabled:!C||E,onClick:()=>{n(g.ModalScreen.MOONPAY_PROMPT_SCREEN)},children:[e.jsx(Iu,{children:e.jsx(wh,{style:{width:24}})}),"Moonpay"]},t):null;case"coinbase-onramp":return A?e.jsxs(ts,{disabled:!C||E,onClick:()=>{n(g.ModalScreen.COINBASE_ONRAMP_STATUS_SCREEN)},children:[e.jsx(Iu,{children:e.jsx($a,{style:{width:24}})}),"Coinbase Onramp"]},t):null;case"external":return j?e.jsxs(ts,{disabled:!C||E,onClick:()=>{n(g.ModalScreen.FUNDING_TRANSFER_FROM_WALLET_SCREEN)},children:[e.jsx(Iu,{children:e.jsx(Ge.default,{style:{width:24}})}),"Transfer from wallet"]},t):null}})),e.jsx(Bu,{disabled:!C,onClick:()=>n(g.ModalScreen.FUNDING_MANUAL_TRANSFER_SCREEN),children:"Send funds manually"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.MOONPAY_PROMPT_SCREEN]:()=>{let{app:t,data:r,navigate:n,setModalData:a}=g.usePrivyModal(),{createAnalyticsEvent:s,getMoonpaySignedUrl:l}=o.usePrivyInternal(),[c,u]=i.useState(null),h=r?.funding,p=h.isUSDC?"USDC":"native-currency";return i.useEffect((()=>{!c&&h&&async function(){if(!t.fundingConfig)return;let{signedUrl:e,externalTransactionId:n}=await l(h.address,{...t.fundingMethodConfig.moonpay,...h.moonpayConfigOverride,currencyCode:h.moonpayConfigOverride?.currencyCode??yh(h.chain.id,p),quoteCurrencyAmount:h.moonpayConfigOverride?.quoteCurrencyAmount??mh(h.amount)});u(e),a({moonpayStatus:{externalTransactionId:n},funding:r?.funding})}()}),[c,h]),e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(Ph,{app:t,signedUrl:c,onContinue:()=>{s({eventName:"sdk_fiat_on_ramp_started",payload:{provider:uh}}),n(g.ModalScreen.MOONPAY_STATUS_SCREEN)}}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.MOONPAY_STATUS_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),{closePrivyModal:n}=o.usePrivyInternal(),{externalTransactionId:i}=r?.moonpayStatus,a=vh(i||null,t.fundingMethodConfig.moonpay.useSandbox??!1);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{title:"Fund account"},"header"),e.jsx(Dh,{status:a,onClickCta:n}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.COINBASE_ONRAMP_STATUS_SCREEN]:()=>{let{data:t,setModalData:r,navigate:n}=g.usePrivyModal(),{closePrivyModal:a,createAnalyticsEvent:s,initCoinbaseOnRamp:l,getCoinbaseOnRampStatus:c}=o.usePrivyInternal(),u=t?.funding,h=u.isUSDC?"USDC":"ETH",[p,y]=i.useState(!1),[m,f]=i.useState(!1);return i.useEffect((()=>{if(p)return;y(!0);let e=async()=>{try{s({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:u.amount,chainId:u.chain.id}});let e=window.open(void 0,void 0,Ju({w:440,h:680})),t=function(e){let t=th[e];if(!t)throw new o.PrivyClientError(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(u.chain.id),r=await l({addresses:[{address:u.address,blockchains:[t]}],assets:[h]}),{url:n}=(({input:e,amount:t,blockchain:r})=>{let n=new URL("https://pay.coinbase.com/buy/select-asset");return n.searchParams.set("appId",e.app_id),n.searchParams.set("sessionToken",e.session_token),n.searchParams.set("defaultExperience","buy"),n.searchParams.set("presetCryptoAmount",t.startsWith(".")?`0${t}`:t),n.searchParams.set("defaultNetwork",r),n.searchParams.set("partnerUserId",e.partner_user_id),{url:n}})({input:r,amount:u.amount,blockchain:t});if(!e)throw Error("Unable to initiate Coinbase Onramp flow.");e.location=n.toString();let i=0,a=!1;for(;i<rh;){i++;let{status:t}=await c({partnerUserId:r.partner_user_id});if("success"===t){a=!0;break}if("failure"===t)throw Error("There was an error completing Coinbase Onramp flow.");if(e.closed)throw Error("User exited Coinbase Onramp flow before transaction response.");await new Promise((e=>setTimeout(e,1500)))}if(!a)throw Error("Timed out waiting for transaction response from Coinbase Onramp.");f(!0)}catch(e){console.error(e),s({eventName:zc,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),r({funding:{...u,errorMessage:"Something went wrong adding funds from Coinbase Onramp. Please try again or use another method to fund your wallet."}}),n(g.ModalScreen.FUNDING_METHOD_SELECTION_SCREEN)}finally{y(!1)}},t=setTimeout((()=>{e()}),500);return()=>clearTimeout(t)}),[]),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{title:"Fund account"},"header"),e.jsx(nh,{isSucccess:m,onClickCta:a}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:()=>{let{connectors:t}=o.usePrivyInternal(),{app:r,setModalData:n,data:a,navigate:s}=g.usePrivyModal(),[l,c]=i.useState("default"),u=Rl(r.appearance.walletList,"ethereum-only",t,!0,r.appearance.walletList,r.externalWallets.walletConnect.enabled),h=e.jsx(Vh,{text:"More wallets",onClick:()=>c("overflow")});return i.useEffect((()=>{n({...a,externalConnectWallet:{onCompleteNavigateTo:g.ModalScreen.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN}})}),[]),"overflow"===l?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>c("default")},"header"),e.jsxs(Xo,{children:[e.jsx(md,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),u]}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(il,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),e.jsxs(Xo,{children:[...u.length>3?u.slice(0,2):u,u.length>3&&h,e.jsx(zh,{onClick:()=>s(g.ModalScreen.FUNDING_MANUAL_TRANSFER_SCREEN),children:"Send funds manually"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:()=>{let{rpcConfig:t,appId:r,closePrivyModal:n,createAnalyticsEvent:a}=o.usePrivyInternal(),{navigate:s,setModalData:c,app:u,data:h}=g.usePrivyModal(),{wallets:p}=l.useWallets(),[y,m]=i.useState(!1),[f,v]=i.useState(0n),[w,x]=i.useState(!1),[C,E]=i.useState(null),[b,S]=i.useState(null),[A,j]=i.useState([]),[$,T]=i.useState(0),[P,_]=i.useState(!1),[k,N]=i.useState(!1),[I,M]=i.useState(!1),[O,R]=i.useState(!1),{erc20ContractInfo:F,erc20Address:L,address:U,chain:D,amount:W}=h.funding;i.useEffect((()=>{L&&!F&&E(Error("Unable to fetch token details"))}),[]);let B=!!L&&!!F,H=B?BigInt(parseFloat(W)*10**F.decimals):Z.parseEther(W),G=p[0],[q,z]=i.useState(null);i.useEffect((()=>{(async()=>{if(!G)return;let e=await G.getEthereumProvider();z(Z.createWalletClient({account:G.address,transport:Z.custom(e)}).extend(Z.publicActions))})().catch(console.error)}),[G]);let[V,K]=i.useState(0n);i.useEffect((()=>{Z.createPublicClient({chain:D,transport:Z.http(d.getJsonRpcEndpointFromChain(D,t,r))}).getBalance({address:U}).then(K).catch(console.error)}),[]);let[Y,X]=i.useState(0n);i.useEffect((()=>{B&&(async({chain:e,address:t,appId:r,rpcConfig:n,erc20Address:i})=>{let a=Z.createPublicClient({chain:e,transport:Z.http(d.getJsonRpcEndpointFromChain(e,n,r))});return{balance:await a.readContract({address:i,abi:Xc,functionName:"balanceOf",args:[t]}).catch((()=>0n)),chain:e}})({chain:D,address:U,appId:r,rpcConfig:t,erc20Address:L}).then((e=>X(e.balance))).catch(console.error)}),[]);let{tokenPrice:J}=Hc({chainId:D.id}),[Q,ee]=i.useState({to:U,chain:D,value:H,data:void 0});i.useEffect((()=>{(async()=>{let e,n;if(!q||!G||P||I)return;_(!0);let i=Z.createPublicClient({chain:Q.chain,transport:Z.http(d.getJsonRpcEndpointFromChain(Q.chain,t,r))});if(B&&!Q.data)return await i.simulateContract({address:L,chain:Q.chain,abi:Gc,functionName:"transfer",args:[U,H],account:G.address}).catch((e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)}))?(_(!1),void ee({to:L,chain:Q.chain,data:Z.encodeFunctionData({abi:Gc,functionName:"transfer",args:[U,H]}),value:"0x0"})):(_(!1),void x(!0));try{e=await i.prepareTransactionRequest({account:G.address,to:Q.to,chain:Q.chain,data:Q.data,value:BigInt(Q.value??0)})}catch(e){console.error(e),A.length>1&&S(e.shortMessage??"Something went wrong")}if(!e)return _(!1),void x(!0);_(!1),M(!0),m(!0),v(e.gas);try{await q.switchChain({id:Q.chain.id})}catch(e){await q.addChain({chain:Q.chain}),await q.switchChain({id:Q.chain.id})}try{n=await q.sendTransaction(e),a({eventName:zc,payload:{provider:"external",status:"success",address:G.address,chainId:Q.chain.id,value:Q.value?.toString(),txHash:n}})}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(A.length<1?E(new o.PrivyClientError(e.shortMessage,void 0,o.PrivyErrorCode.TRANSACTION_FAILURE)):S(e.shortMessage??"Something went wrong"))}n?(await q.waitForTransactionReceipt({hash:n}),M(!1),R(!0)):M(!1)})().catch(console.error)}),[q,Q]),i.useEffect((()=>{(async()=>{if(!w||!q||!G)return;let e=l.addToDefaultChains(u.chains).filter((e=>e.id!==h.funding.chain.id&&!!e.testnet==!!h.funding.chain.testnet));B&&e.unshift(h.funding.chain);let n=await(({chains:e,appId:t,address:r,rpcConfig:n})=>Promise.all(e.map((async e=>{let i=Z.createPublicClient({chain:e,transport:Z.http(d.getJsonRpcEndpointFromChain(e,n,t))});return{balance:await i.getBalance({address:r}).catch((()=>0n)),chain:e}}))))({chains:e,address:G.address,appId:r,rpcConfig:t}),i=B?n.filter((e=>e.balance>0n)):n.filter((e=>e.balance>H));if(i.length<1)return void E(new o.PrivyClientError(`Wallet ${d.formatWalletAddress(G.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE));i.sort(((e,t)=>Number(t.balance-e.balance)));let a=(await Promise.allSettled(i.map((async e=>({quote:await Yc({isTestnet:!!h.funding?.chain.testnet,input:Kc({amount:H.toString(),user:G.address,recipient:U,destinationChainId:D.id,destinationCurrency:L,originChainId:e.chain.id})}),...e}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(a.length<1)return void E(new o.PrivyClientError(`Wallet ${d.formatWalletAddress(G.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE));let s=a.map((e=>({bridgeTx:Zc(e.quote),balance:e.balance,chain:e.chain}))).filter((e=>!!e.bridgeTx));if(s.length>1)return void j(s);let c=s[0];c?(N(!0),ee({data:c.bridgeTx.data,to:c.bridgeTx.to,value:c.bridgeTx.value,chain:c.chain})):E(new o.PrivyClientError(`Wallet ${d.formatWalletAddress(G.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE))})().catch(console.error)}),[w]),i.useEffect((()=>{if(!C)return;let e={error:C,previousScreen:g.ModalScreen.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),s(g.ModalScreen.ERROR_SCREEN,!1)}),[C]);let te=G?Sl(G.walletClientType,G.connectorType,G.walletClientType)||"wallet":null,re=!B&&J?d.getDollarsFromStringFloat(h?.funding?.amount??"0",J):void 0,ne=B?f:d.sumWeiQuantitiesToHexString([f,H]),ie=ne&&J?d.getDollarsFromWei(ne,J):void 0,ae=ne?d.getNativeCurrencyFromWei(ne,"ETH"):void 0,oe=f&&J?d.getDollarsFromWei(f,J):void 0,se=f?d.getNativeCurrencyFromWei(f,"ETH"):void 0;if(i.useEffect((()=>{if(!O)return;let e=setTimeout(n,l.DEFAULT_SUCCESS_SCREEN_EXTRA_LONG_DURATION_MS);return()=>clearTimeout(e)}),[O]),O)return e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(Xs,{}),e.jsxs(Vs,{children:[e.jsx(ct.default,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),e.jsx(il,{title:"Success!",description:`You’ve successfully added ${W} ${B?F.symbol:D.nativeCurrency.symbol} to your ${u.name} wallet. It may take a minute before the funds are available to use.`})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]});let le=B?`${qc({amount:Y,decimals:F.decimals})} ${F.symbol}`:d.getNativeCurrencyFromWei(V,D.nativeCurrency.symbol,3,!0),de=A[$];return A.length>1&&de?e.jsx(qu,{displayName:te,configuredFundingChain:D,formattedBalance:le,fundingAmount:W,fundingCurrency:B?F.symbol:D.nativeCurrency.symbol,fundingAmountInUsd:re,options:A,selectedOption:de,isPreparing:P,isSubmitting:I,errorMessage:b,onSubmit:()=>{ee({to:de.bridgeTx.to,data:de.bridgeTx.data,value:de.bridgeTx.value,chain:de.chain})},onSelect:e=>{e!==$&&(S(null),T(e))}}):y&&f&&G&&h?.funding?e.jsx(zu,{wallet:G,displayName:te,addressToFund:U,isBridging:k,isErc20Flow:B,totalPriceInUsd:ie,totalPriceInNativeCurrency:ae,gasPriceInUsd:oe,gasPriceInNativeCurrency:se,chain:h.funding.chain}):e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(Lc,{}),e.jsx("div",{style:{marginTop:"1rem"}}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_MANUAL_TRANSFER_SCREEN]:()=>{let{wallets:t}=l.useWallets(),{app:r,data:n,setModalData:a,navigate:s,lastScreen:c}=g.usePrivyModal(),{chains:u,rpcConfig:h,appId:p,closePrivyModal:y,createAnalyticsEvent:m}=o.usePrivyInternal(),[f,v]=i.useState("default"),[w,x]=i.useState(void 0),C=n?.funding,{tokenPrice:E}=Hc({chainId:C.chain.id}),b=E?d.getDollarsFromStringFloat(C.amount,E):void 0,S=t.find((e=>d.formatWalletAddress(e.address)===d.formatWalletAddress(C.address))),A=S&&"privy"!==S.walletClientType?Sl(S.walletClientType,S.connectorType,S.walletClientType):r.name;if(!C)return a({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:c||g.ModalScreen.FUNDING_METHOD_SELECTION_SCREEN},funding:n?.funding,sendTransaction:n?.sendTransaction}),s(g.ModalScreen.ERROR_SCREEN),e.jsx(e.Fragment,{});i.useEffect((()=>{let e=d.getJsonRpcProvider(C.chain.id,u,h,{appId:p});function t(){e.getBalance(C.address).then((e=>{let t=parseFloat(ie.formatUnits(e,"ether"));x((e=>(e&&t>e&&m({eventName:zc,payload:{provider:"manual",status:"success",address:S?.address,value:(t-e).toString()}}),t)))})).catch((()=>x(void 0)))}let r=setInterval(t,2e3);return t(),()=>clearInterval(r)}),[]);let j=i.useMemo((()=>void 0!==w&&w>=parseFloat(C.amount)),[w,C.amount]),$=e.jsxs(e.Fragment,{children:[e.jsx(d.WalletInfoCard,{title:"Your wallet",errMsg:void 0,isLoading:!C||void 0===w,isPulsing:!j,balance:`${void 0!==w?w.toPrecision(2):""} ETH`,address:C.address,statusColor:j?"green":"gray"}),j&&e.jsx(Gu,{onClick:()=>y(),children:"Close"})]});return"qr-code"===f?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>v("default")}),e.jsxs(Ks,{style:{gap:"24px",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx(Cs,{children:"Scan QR code"}),e.jsxs(Es,{children:["Scan this code using your mobile wallet to send funds to your ",A," ","wallet."]})]}),e.jsx(Pc,{url:C.address,size:200,squareLogoElement:xh}),$]}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(il,{title:"Send funds",description:"Send funds directly to your wallet by copying your wallet address or scanning a QR code."}),e.jsxs(Ks,{style:{gap:"16px"},children:[e.jsxs(bh,{children:[e.jsx(gt.default,{height:"20px",width:"20px",color:"var(--privy-color-accent-light)"}),e.jsxs(Sh,{children:["Make sure to send on ",C.chain.name,"."]})]}),e.jsxs(Ah,{children:[e.jsx(el,{height:16}),e.jsxs(Mu,{children:[e.jsxs(Ou,{children:[e.jsx(Ru,{children:C.amount}),e.jsx(Uu,{children:C.chain.nativeCurrency.symbol})]}),e.jsx(Du,{children:b?`${b} USD`:"..."}),e.jsxs(Wu,{children:[e.jsx(nu,{chainId:C.chain.id,height:16,width:16})," ",C.chain.name]})]}),e.jsx(el,{height:8}),e.jsxs(Eh,{children:[e.jsx(Ch,{text:C.address}),e.jsx($h,{onClick:()=>v("qr-code"),children:e.jsxs(jh,{children:[e.jsx(vt.default,{height:"16px",width:"16px"}),"Scan code"]})})]})]}),$]}),e.jsx(el,{height:16}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN]:()=>{let{closePrivyModal:t}=o.usePrivyInternal(),{data:r,setModalData:n,navigate:i,onUserCloseViaDialogOrKeybindRef:a}=g.usePrivyModal(),{onSuccess:s,onFailure:l}=r.setWalletPassword,c=()=>{l(new o.PrivyEmbeddedWalletError("Exited before password was added to wallet")),t({shouldCallAuthOnSuccess:!1})};return a.current=c,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:c}),e.jsx(Xs,{}),e.jsxs(Vs,{children:[e.jsxs(Qs,{children:[e.jsx(st.default,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),e.jsx(tl,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:e.jsx(lt.default,{width:"12px",height:"12px",fill:"white"})})]}),e.jsxs(il,{title:"Secure Your Account",children:["Please set a password to secure your account.",e.jsx("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),e.jsx(jo,{onClick:()=>{n({createWallet:{onFailure:l,onSuccess:s,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),i(g.ModalScreen.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN)},children:"Add password"}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN]:()=>{let[t,r]=i.useState(null),[n,a]=i.useState(!1),[s,l]=i.useState(null),[d,c]=i.useState(""),{authenticated:h,getAccessToken:p,user:y}=o.usePrivy(),{walletProxy:m,refreshUser:f,closePrivyModal:v,createAnalyticsEvent:w}=o.usePrivyInternal(),{app:x,navigate:C,data:E,onUserCloseViaDialogOrKeybindRef:b}=g.usePrivyModal(),{onSuccess:S,onFailure:A}=E.createWallet,j=u.getPrivyEthereumWallet(y),$="user-passcode"===t?.recoveryMethod,T="user-passcode"===j?.recoveryMethod;i.useEffect((()=>{h||(C(g.ModalScreen.LANDING),A(new o.PrivyUnauthenticatedError("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let P=()=>s?(A(s),void v({shouldCallAuthOnSuccess:!1})):$?(S(t),void v({shouldCallAuthOnSuccess:!1})):(A(new o.PrivyEmbeddedWalletError("Exited before password was added to wallet")),void v({shouldCallAuthOnSuccess:!1}));b.current=P;return e.jsx(hc,{appName:x?.name||"privy",config:{initiatedBy:"user",onCancel:P},error:s?"An error has occurred, please try again.":void 0,buttonLoading:n,buttonHideAnimations:!1,password:d,isResettingPassword:T,onPasswordGenerate:()=>c(rc()),onPasswordChange:c,onSubmit:async()=>{$?(S(t),v({shouldCallAuthOnSuccess:!1})):(a(!0),l(null),await(async()=>{let e=await p();if(e&&j?.address&&d&&m)try{if(w({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T}}),!(await m.setRecovery({accessToken:e,address:j.address,recoveryPassword:d,recoveryMethod:"user-passcode"})).address)return l(new o.PrivyEmbeddedWalletError("Error setting password on privy wallet")),void w({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T,reason:"error setting password"}});let t=await f(),n=u.getPrivyEthereumWallet(t);if(!n)return l(new o.PrivyEmbeddedWalletError("Error setting password on privy wallet")),void w({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T,reason:"wallet disconnected"}});r(n),w({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T}})}catch(e){console.warn(e),l(e instanceof Error?e:Error("Error setting password on privy wallet")),w({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:j.address,reason:e}})}})(),a(!1))},onClose:P})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN]:()=>{let{app:t,navigate:r,data:n,onUserCloseViaDialogOrKeybindRef:a}=g.usePrivyModal(),[s,l]=i.useState(""),[d,c]=i.useState(!1),[u,h]=i.useState(),[p,y]=i.useState(null),{authenticated:m,user:f}=o.usePrivy(),{closePrivyModal:v,isNewUserThisSession:w,initializeWalletProxy:x}=o.usePrivyInternal(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:b}=n.createWallet,{createWallet:S}=Cd(),[A,j]=i.useState(null),$=new Gi((async()=>{try{let e=await S({recoveryPassword:u,user:f});if(!e)return;j(e),w?r(g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN):(C(e),v({shouldCallAuthOnSuccess:b}))}catch(e){l(e.message)}}));i.useEffect((()=>{p||x(3e4).then((e=>y(e)))}),[p]),i.useEffect((()=>{if(!m||!f)return r(g.ModalScreen.LANDING),void E(Error("User must be authenticated before creating a Privy wallet"))}),[m]),a.current=()=>null;return e.jsx(hc,{config:{initiatedBy:"automatic"},appName:t?.name||"privy",loading:!p,buttonLoading:d,buttonHideAnimations:!A&&d,isResettingPassword:!1,error:s,password:u||"",onClose:()=>{A&&"user-passcode"!==A?.recoveryMethod?(E(new o.PrivyEmbeddedWalletError("User created a wallet but failed to set a password for it")),v({shouldCallAuthOnSuccess:!1})):A?(C(A),v({shouldCallAuthOnSuccess:b})):(E(new o.PrivyEmbeddedWalletError("User wallet creation failed")),v({shouldCallAuthOnSuccess:!1}))},onPasswordChange:h,onPasswordGenerate:()=>h(rc()),onSubmit:async()=>(c(!0),$.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>c(!1))))})},[g.ModalScreen.MFA_ENROLLMENT_FLOW_SCREEN]:()=>{let{user:t,enrollInMfa:r}=o.usePrivy(),[n,a]=i.useState(null),{unenrollWithSms:s,unenrollWithTotp:l,unenrollWithPasskey:c}=Fp(),{app:u,ready:h,data:p,onUserCloseViaDialogOrKeybindRef:y}=g.usePrivyModal(),{closePrivyModal:m}=o.usePrivyInternal(),{promptMfa:f}=Rp(),{initEnrollmentWithTotp:v}=Fp(),[w,x]=i.useState(!1),[C,E]=i.useState(null),[b,S]=i.useState(null),A=()=>{m({shouldCallAuthOnSuccess:!0}),r(!1),setTimeout((()=>{a(null),E(null)}),500)},{initEnrollmentWithPasskey:j,submitEnrollmentWithPasskey:$}=Fp(),[T,P]=i.useState(!1),[_,k]=i.useState(null);y.current=A;let N=t?.mfaMethods.includes("sms"),I=!!t?.phone,M=t?.mfaMethods.includes("totp"),O=t?.mfaMethods.includes("passkey"),R=N||M||O,F=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function L(){a(null),E(null)}if(i.useEffect((()=>{R&&x(!0)}),[R]),!h||!t||!u)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A},"header"),e.jsx(xs,{children:e.jsx(Lp,{})}),e.jsx(bs,{children:e.jsx(Co,{})}),e.jsx(d.ModalFooter,{})]});if("sms"===n)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:L,onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(bt.default,{})})}),e.jsx(Cs,{children:"Remove SMS verification?"}),e.jsxs(Es,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),e.jsx($s,{children:e.jsx(jo,{warn:!0,onClick:async function(){a(null);try{await s()}catch(e){a(null)}},children:"Remove SMS for MFA"})}),e.jsx(d.ModalFooter,{})]});if("totp"===n)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:L,onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(Ct.default,{})})}),e.jsx(Cs,{children:"Remove Authenticator App verification?"}),e.jsxs(Es,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),e.jsx($s,{children:e.jsx(jo,{warn:!0,onClick:async function(){a(null);try{await l()}catch(e){a(null)}},children:"Remove Authenticator App for MFA"})}),e.jsx(d.ModalFooter,{})]});if("passkey"===n)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:L,onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(St.default,{})})}),e.jsx(Cs,{children:"Are you sure you want to remove passkey verification?"}),e.jsx(Es,{children:"This will disable any passkeys you have set up for verification. You’ll still be able to login with your passkeys if you’ve set up passkey login."}),e.jsx($s,{children:e.jsx(jo,{warn:!0,onClick:async function(){a(null);try{await f(),await c()}catch(e){a(null)}},children:"Yes, remove"})}),e.jsx(d.ModalFooter,{})]});if(0===p.mfaEnrollmentFlow.mfaMethods.length&&!R)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(At.default,{})})}),e.jsx(Cs,{children:"Add more security"}),e.jsxs(Es,{children:[u?.name," does not have any verification methods enabled."]}),e.jsx($s,{children:e.jsx(jo,{onClick:A,children:"Close"})}),e.jsx(d.ModalFooter,{})]});let U=!R&&!w;return U?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(At.default,{})})}),e.jsx(Cs,{children:"Transaction Protection"}),e.jsx(Es,{children:"Set up transaction protection to add an extra layer of security to your account"}),e.jsxs(Ss,{children:[e.jsxs(js,{children:[e.jsx(As,{children:e.jsx(yt.default,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),e.jsxs(js,{children:[e.jsx(As,{children:e.jsx(Et.default,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),e.jsxs($s,{children:[e.jsx(jo,{onClick:()=>x(!0),children:"Continue"}),e.jsx(ko,{onClick:A,children:"Not now"})]}),e.jsx(d.ModalFooter,{})]}):"sms"===C?e.jsx(iy,{onComplete:A,onReset:L,onClose:A}):"totp"===C&&b?e.jsx(oy,{onComplete:A,onClose:A,onReset:L,totpInfo:b}):"passkey"===C?e.jsx(Wp,{onComplete:A,onReset:L,onClose:A}):e.jsx(Dp,{showIntro:U,userMfaMethods:t.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:I,onBackToIntro:function(){x(!1)},handleSelectMethod:async function(e){return await f().catch(k),"totp"===e?(E(e),S(null),void v().then((e=>{S(e)})).catch((()=>{S(null),L()}))):"passkey"===e&&1===F.length?await async function(){P(!0);try{await j(),await $({credentialIds:F})}catch(e){k(e)}finally{P(!1)}}():void E(e)},isTotpLoading:"totp"===C&&!b,isPasskeyLoading:T,error:_,onClose:A,setRemovingMfaMethod:a})},[g.ModalScreen.CAPTCHA_SCREEN]:()=>{let{lastScreen:t,currentScreen:r,data:n,navigateBack:a,navigate:o,setModalData:s}=g.usePrivyModal(),{status:l,token:c,waitForResult:u,reset:h,execute:p}=ba(),y=i.useRef([]),m=e=>{y.current=[e,...y.current]},[f,v]=i.useState(!0);i.useEffect((()=>(m(setTimeout(v,1e3,!1)),()=>{y.current.forEach((e=>clearTimeout(e))),y.current=[]})),[]);let[w,x]=i.useState(""),[C,E]=i.useState("Checking that you are a human..."),[b,S]=i.useState(e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Continue"})),[A,j]=i.useState(!1),[$,T]=i.useState(3),P=n?.captchaModalData,_=async e=>{try{await(P?.callback(e)),P?.onSuccessNavigateTo&&o(P?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof Ca)return;s({errorModalData:{error:e,previousScreen:t||g.ModalScreen.LANDING}}),o(P?.onErrorNavigateTo||g.ModalScreen.ERROR_SCREEN,!1)}};i.useEffect((()=>{"success"===l?m(setTimeout((async()=>{let e=await u();!e||P?.userIntentRequired||_(e)}),1e3)):"ready"===l&&m(setTimeout((()=>{"ready"===l&&p()}),500))}),[l]),i.useEffect((()=>{if(!f)switch(l){case"success":x("Success!"),E("CAPTCHA passed successfully."),S(e.jsx(jo,{onClick:()=>{j(!0),_(c)},disabled:!P?.userIntentRequired,loading:A,children:P?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":x(""),E("Checking that you are a human..."),S(e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":x("Something went wrong"),$<=0?(E("If you use an adblocker or VPN, try disabling and re-attempting."),S(null)):(E("You did not pass CAPTCHA. Please try again."),S(e.jsx(jo,{onClick:k,children:"Retry"})))}}),[l,f,A]);let k=async()=>{if($<=0)return;T((e=>e-1)),h(),p();let e=await u();!e||P?.userIntentRequired||_(e)};return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t&&r!==t?a:void 0}),e.jsxs(Cl,{children:["success"===l?e.jsx(Ze.default,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===l?e.jsx(Xe.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):e.jsx(wl,{}),e.jsxs(Ys,{children:[w?e.jsx("h3",{children:w}):null,e.jsx("p",{children:C})]}),b]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.ERROR_SCREEN]:()=>{let{navigate:t,navigateBack:r,data:n,lastScreen:i,currentScreen:a}=g.usePrivyModal(),o=n?.errorModalData?.previousScreen||(i===a?void 0:i);return e.jsx(pc,{error:n?.errorModalData?.error||Error(),backFn:()=>o?t(o,!1):r(),onClick:()=>t(o||g.ModalScreen.LANDING,!1)})},[g.ModalScreen.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE]:()=>{let{closePrivyModal:t}=o.usePrivyInternal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Kh,{children:e.jsx(qe.default,{style:{width:32,height:32}})}),e.jsx(nl,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),e.jsx(Hs,{children:e.jsx(jo,{onClick:()=>t(),children:"Close"})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN]:()=>{let{user:t,logout:r}=o.usePrivy(),{app:n,onUserCloseViaDialogOrKeybindRef:i,setModalData:a,navigate:s}=g.usePrivyModal(),{acceptTerms:l,closePrivyModal:d,createAnalyticsEvent:c}=o.usePrivyInternal(),h=e=>{e?.preventDefault(),d({shouldCallAuthOnSuccess:!1}),r()};i.current=h;return e.jsx(Ls,{termsAndConditionsUrl:n?.legal.termsAndConditionsUrl,privacyPolicyUrl:n?.legal.privacyPolicyUrl,onAccept:async e=>{e.preventDefault(),await l(),t&&u.shouldProceedtoEmbeddedWalletCreationFlow(t,n?.embeddedWallets?.createOnLogin)?(a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),c({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),s(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)):d()},onDecline:h})},[g.ModalScreen.TELEGRAM_AUTH_SCREEN]:()=>{let{authenticated:t,logout:r,ready:n,user:a}=o.usePrivy(),{app:s,setModalData:c,navigate:h,resetNavigation:p,data:y}=g.usePrivyModal(),{initLoginWithTelegram:m,loginWithTelegram:f,updateWallets:v,setReadyToTrue:w,closePrivyModal:x,createAnalyticsEvent:C,getAuthMeta:E}=o.usePrivyInternal(),[b,S]=i.useState(!1),[A,j]=i.useState(void 0),$=ba();async function T(){try{let e=await async function(){let e;if($.enabled&&"error"===$.status)throw new Ca($.error,null,o.PrivyErrorCode.CAPTCHA_FAILURE);return $.enabled&&"success"!==$.status&&($.execute(),e=await $.waitForResult()),e}();await f(e),S(!0),w(!0)}catch(e){if(e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return j(void 0),p(),void h(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),j(void 0),p(),void h(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return j(void 0),p(),void h(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return j(void 0),p(),c({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:E()?.telegramAuthResult,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void h(g.ModalScreen.LINK_CONFLICT_SCREEN);let{retryable:t,detail:r}=Aa(e);j({retryable:t,detail:r,message:"Authentication failed"})}}i.useEffect((()=>{T()}),[]),i.useEffect((()=>{if(!(n&&t&&b&&a))return;if(s?.legal.requireUsersAcceptTerms&&!a.hasAcceptedTerms){let e=setTimeout((()=>{h(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(a,s?.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),h(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}v();let e=setTimeout((()=>x({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}),[n,t,b,a]);let P=b?"Successfully connected with Telegram":A?A.message:"Verifying connection to Telegram",_="";return _=b?"You’re good to go!":A?A.detail:"Just a few moments more",e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsx(Xs,{}),e.jsxs(If,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:b,fail:!!A}),e.jsx(Cp,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:P}),e.jsx("p",{children:_})]}),A&&A?.retryable?e.jsx(Io,{onClick:async()=>{try{j(void 0),y?.telegramAuthModalData?.seamlessAuth||await m(void 0,y?.login?.disableSignup),await T()}catch(e){let{retryable:t,detail:r}=Aa(e);j({retryable:t,detail:r,message:"Authentication failed"})}},disabled:!b&&!A?.retryable,children:"Retry"}):null]}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.LINK_CONFLICT_SCREEN]:()=>{let{initiateAccountTransfer:t,closePrivyModal:r}=o.usePrivyInternal(),{data:n,navigate:a,lastScreen:s,setModalData:l}=g.usePrivyModal(),[d,c]=i.useState(void 0),[u,h]=i.useState(!1),[p,y]=i.useState(!1),m=async()=>{try{if(!n?.accountTransfer?.nonce||!n?.accountTransfer?.account)throw Error("missing account transfer inputs");y(!0),await t({nonce:n?.accountTransfer?.nonce,account:n?.accountTransfer?.account,accountType:n?.accountTransfer?.linkMethod,externalWalletMetadata:n?.accountTransfer?.externalWalletMetadata,telegramAuthResult:n?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:n?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:n?.accountTransfer?.oAuthUserInfo}),h(!0),y(!1),setTimeout(r,1e3)}catch(e){l({errorModalData:{error:e,previousScreen:s||g.ModalScreen.LINK_CONFLICT_SCREEN}}),a(g.ModalScreen.ERROR_SCREEN,!0)}};return d?e.jsx(gs,{address:d,onClose:r,onRetry:()=>c(void 0),onTransfer:m,isTransferring:p,transferSuccess:u}):e.jsx(vs,{onClose:r,onInfo:()=>c(n?.accountTransfer?.embeddedWalletAddress),onContinue:()=>c(n?.accountTransfer?.embeddedWalletAddress),onTransfer:m,isTransferring:p,transferSuccess:u,data:n})}},Zf=[g.ModalScreen.LANDING,g.ModalScreen.AWAITING_CONNECTION],Xf=({isMfaVerifying:t,onMfaVerificationComplete:r})=>{let{ready:n,isModalOpen:a}=o.usePrivy(),{headless:s}=l.useAppConfig(),{ready:c,currentScreen:u}=g.usePrivyModal(),{status:h,execute:p,reset:y,enabled:m}=ba(),f=a&&u&&Zf.includes(u)&&!s&&"ready"===h;return i.useEffect((()=>{f&&p()}),[f]),i.useEffect((()=>{!a&&m&&y()}),[a,m]),n&&c||u===g.ModalScreen.AWAITING_OAUTH_SCREEN||u===g.ModalScreen.CROSS_APP_AUTH_SCREEN||u===g.ModalScreen.TELEGRAM_AUTH_SCREEN?!u&&t?e.jsx(rm,{open:t,onClose:r}):u?e.jsxs(e.Fragment,{children:[e.jsx(ns,{$if:!!t,children:e.jsx(Yf[u],{})}),e.jsx(ns,{$if:!t,children:e.jsx(rm,{open:t,onClose:r})})]}):null:e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsx(Xs,{}),e.jsx(Kf,{children:e.jsx(Co,{})}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},Jf=({isMfaVerifying:t,onMfaVerificationComplete:r})=>{let n=i.useRef(null);return e.jsx(tg,{style:{height:d.useElementHeight(n)},id:"privy-modal-content",children:e.jsx("div",{ref:n,children:e.jsx(Xf,{isMfaVerifying:t,onMfaVerificationComplete:r})})})};const Qf=({open:t})=>{let{app:r}=g.usePrivyModal(),{gracefulClosePrivyModal:n}=(()=>{let{closePrivyModal:e}=o.usePrivyInternal(),{onUserCloseViaDialogOrKeybindRef:t}=g.usePrivyModal();return{gracefulClosePrivyModal:i.useCallback((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),[a,s]=i.useState(!1);wo({onMfaRequired:()=>{r?.mfa.noPromptOnMfaRequired||s(!0)}});let l=t||a;return r.render.standalone?e.jsx(Bf,{children:e.jsx(eg,{id:"privy-modal-content",children:e.jsx(Xf,{isMfaVerifying:a,onMfaVerificationComplete:()=>s(!1)})})}):e.jsx(Hf,{open:l,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>n(),children:e.jsx(Bf,{children:e.jsx(Jf,{isMfaVerifying:a,onMfaVerificationComplete:()=>s(!1)})})})};let eg=C.styled.div`
3095
+ `;let Yf={[g.ModalScreen.LANDING]:()=>{let{app:t}=g.usePrivyModal();return t.loginMethodsAndOrder&&t.loginMethodsAndOrder.primary.length>0?e.jsx(Ap,{connectOnly:!1}):e.jsx(Pp,{connectOnly:!1})},[g.ModalScreen.CONNECT_OR_CREATE]:()=>{let{app:t}=g.usePrivyModal();return t.loginMethodsAndOrder&&t.loginMethodsAndOrder.primary.length>0?e.jsx(Ap,{connectOnly:!0}):e.jsx(Pp,{connectOnly:!0})},[g.ModalScreen.AWAITING_PASSWORDLESS_CODE]:()=>{let{app:t,navigate:r,lastScreen:n,navigateBack:s,setModalData:c,onUserCloseViaDialogOrKeybindRef:h}=g.usePrivyModal(),{closePrivyModal:p,resendEmailCode:y,resendSmsCode:m,getAuthMeta:f,loginWithCode:v,updateWallets:w,createAnalyticsEvent:x}=o.usePrivyInternal(),{authenticated:C,logout:E,user:b}=o.usePrivy(),[S,A]=i.useState(ul),[j,$]=i.useState(!1),[T,P]=i.useState(null),[_,k]=i.useState(null),[N,I]=i.useState(0);h.current=()=>null;let M=f()?.email?0:1,O=l.DEFAULT_SUCCESS_SCREEN_DURATION_MS-500;i.useEffect((()=>{if(N){let e=setTimeout((()=>{I(N-1)}),1e3);return()=>clearTimeout(e)}}),[N]),i.useEffect((()=>{if(C&&j&&b){if(t?.legal.requireUsersAcceptTerms&&!b.hasAcceptedTerms){let e=setTimeout((()=>{r(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),O);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(b,t?.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),x({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AwaitingPasswordlessCodeScreen"}}),E()},callAuthOnSuccessOnClose:!0}}),r(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),O);return()=>clearTimeout(e)}{w();let e=setTimeout((()=>p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}}}),[C,j,b]),i.useEffect((()=>{if(T&&0===_){let e=setTimeout((()=>{A(ul),P(null);let e=document.querySelector("input[name=code-0]");e?.focus()}),1400);return()=>clearTimeout(e)}}),[T]);let R=e=>{e.preventDefault();let t=e.currentTarget.value.replace(" ","");if(""===t)return;if(isNaN(Number(t)))return P("Code should be numeric"),void k(1);P(null),k(null);let i=Number(e.currentTarget.name?.charAt(5)),a=[...t||[""]].slice(0,6-i),s=[...S.slice(0,i),...a,...S.slice(i+a.length)];A(s);let l=Math.min(Math.max(i+a.length,0),5);if(!isNaN(Number(e.currentTarget.value))){let e=document.querySelector(`input[name=code-${l}]`);e?.focus()}if(s.every((e=>e&&!isNaN(+e)))){let e=document.querySelector(`input[name=code-${l}]`);e?.blur(),v(s.join("")).then((()=>$(!0))).catch((e=>{if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS)P("Invalid or expired verification code");else if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)P(e.message);else{if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),void r(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return void r(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER)return c({errorModalData:{error:e,previousScreen:n??g.ModalScreen.AWAITING_PASSWORDLESS_CODE}}),void r(g.ModalScreen.ERROR_SCREEN,!1);if(e instanceof o.PrivyApiError&&e.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return c({accountTransfer:{nonce:e.data?.data?.nonce,account:0===M?f()?.email:f()?.phoneNumber,displayName:e.data?.data?.account?.displayName,linkMethod:0===M?"email":"sms",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void r(g.ModalScreen.LINK_CONFLICT_SCREEN);P("Issue verifying code")}k(0)}))}},F=0==M?e.jsx(Ke.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"}):e.jsx(Ye.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"}),L=0==M?e.jsxs("p",{children:["Please check ",e.jsx(vl,{children:f()?.email})," for an email from privy.io and enter your code below."]}):e.jsxs("p",{children:["Please check ",e.jsx(vl,{children:f()?.phoneNumber})," for a message from ",t?.name||"Privy"," and enter your code below."]});return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>s()},"header"),e.jsxs(hl,{children:[e.jsx(il,{title:"Enter confirmation code",description:L,icon:F}),e.jsxs(qs,{children:[e.jsxs(pl,{children:[e.jsx(yl,{$fail:!!T,$success:j,children:e.jsx("span",{children:T||(j?"Success!":"")})}),e.jsx("div",{children:S.map(((t,r)=>e.jsx("input",{name:`code-${r}`,type:"text",value:S[r],onChange:R,onKeyUp:e=>{"Backspace"===e.key&&(e=>{if(1===_&&(P(null),k(null)),A([...S.slice(0,e),"",...S.slice(e+1)]),e>0){let t=document.querySelector(`input[name=code-${e-1}]`);t?.focus()}})(r)},inputMode:"numeric",autoFocus:0===r,pattern:"[0-9]",className:`${j?"success":""} ${T?"fail":""}`,autoComplete:a.isMobile?"one-time-code":"off"},r)))})]}),e.jsxs(ml,{children:[e.jsxs("span",{children:["Didn't get ",0==M?"an email":"a message","?"]}),N?e.jsxs(gl,{children:[e.jsx(Ve.default,{color:"var(--privy-color-foreground)",strokeWidth:1.33,height:"12px",width:"12px"}),e.jsx("span",{children:"Code sent"})]}):e.jsx(fl,{children:e.jsx("button",{onClick:async()=>{I(30),0==M?await y():await m()},children:"Resend code"})})]})]})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.AWAITING_CONNECTION]:()=>{let t,[r,n]=i.useState(!1),[s,c]=i.useState(!1),[h,p]=i.useState(void 0),{authenticated:y,logout:f}=o.usePrivy(),{app:v,navigate:w,navigateBack:x,lastScreen:C,currentScreen:E,setModalData:b,data:S}=g.usePrivyModal(),{getAuthFlow:A,walletConnectionStatus:j,closePrivyModal:$,initLoginWithWallet:T,loginWithWallet:P,updateWallets:_,createAnalyticsEvent:k}=o.usePrivyInternal(),{walletConnectors:N}=o.usePrivy(),[I,M]=i.useState(0),{user:O}=o.usePrivy(),[R]=i.useState(O?.linkedAccounts.length||0),[F,L]=i.useState(""),[U,D]=i.useState(""),[W,B]=i.useState(!1),{hasTabbedAway:H}=function(){let[e,t]=i.useState(!1),r=i.useCallback((()=>{document.hidden&&t(!0)}),[]);return i.useEffect((()=>(document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r))),[r]),{hasTabbedAway:e,reset:()=>t(!1)}}(),{enabled:G,token:q}=ba(),z=a.isMobile&&"wallet_connect_v2"===j?.connector?.connectorType||a.isMobile&&"coinbase_wallet"===j?.connector?.connectorType||a.isMobile&&"injected"===j?.connector?.connectorType&&"phantom"===j?.connector?.walletClientType,V="connected"===j?.status,K="switching_to_supported_chain"===j?.status;i.useEffect((()=>{let e=A(),t=e instanceof fa||e instanceof ga?e:void 0;V&&!t&&(!G||q||y?T(j.connectedWallet,q,S?.login?.disableSignup).then((()=>{B(!0)})):(b({captchaModalData:{callback:e=>T(j.connectedWallet,e,S?.login?.disableSignup).then((()=>{B(!0)})),userIntentRequired:!1,onSuccessNavigateTo:g.ModalScreen.AWAITING_CONNECTION,onErrorNavigateTo:g.ModalScreen.ERROR_SCREEN}}),w(g.ModalScreen.CAPTCHA_SCREEN,!1))),t&&z&&V&&!t.preparedMessage?t.buildMessage():t&&!z&&V&&(s||(async()=>{c(!0),p(void 0);try{"wallet_connect_v2"===j?.connector?.connectorType&&"metamask"===j?.connector?.walletClientType&&await d.sleep(2500),await Z()}catch(e){console.warn("Auto-prompted signature failed",e)}finally{c(!1)}})())}),[I,V,W]),i.useEffect((()=>{if(O&&r){let e=l.DEFAULT_SUCCESS_SCREEN_DURATION_MS-500;if(v?.legal.requireUsersAcceptTerms&&!O.hasAcceptedTerms){let t=setTimeout((()=>{w(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),e);return()=>clearTimeout(t)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(O,v?.embeddedWallets?.createOnLogin)){let t=setTimeout((()=>{b({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),k({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"ConnectionStatusScreen"}}),f()},callAuthOnSuccessOnClose:!0}}),w(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),e);return()=>clearTimeout(t)}_();let t=setTimeout((()=>$({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(t)}}),[O,r]);let Y=e=>{if(e?.privyErrorCode!==o.PrivyErrorCode.ALLOWLIST_REJECTED){if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),void w(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode!==o.PrivyErrorCode.USER_DOES_NOT_EXIST)return e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce?(b({accountTransfer:{nonce:e.data?.data?.nonce,account:A()?.meta.address,displayName:e.data?.data?.account?.displayName,externalWalletMetadata:{walletClientType:A()?.meta.walletClientType,chainId:A()?.meta.chainId,connectorType:A()?.meta.connectorType},linkMethod:"siwe",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void w(g.ModalScreen.LINK_CONFLICT_SCREEN)):void p(Fl(e));w(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN)}else w(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN)};async function Z(){try{await P(),n(!0)}catch(e){Y(e)}finally{c(!1)}}i.useEffect((()=>{j?.connectError&&Y(j?.connectError)}),[j]),((e,t)=>{let r=i.useRef((()=>{}));i.useEffect((()=>{r.current=e})),i.useEffect((()=>{if(null!==t){let e=setInterval((()=>r.current()),t||0);return()=>clearInterval(e)}}),[t])})((()=>{let e="wallet_connect_v2"===X&&j?.connector instanceof to?j.connector.redirectUri:void 0;e&&L(e);let t="wallet_connect_v2"===X&&j?.connector instanceof to?j.connector.fallbackUniversalRedirectUri:void 0;t&&D(t)}),j?.connector instanceof to&&!F?500:null);let X=j?.connector?.connectorType||"injected",J=j?.connector?.walletClientType||"unknown",Q=bl[J]?.displayName||j?.connector?.walletBranding.name||"Browser Extension",ee=bl[J]?.logo||j?.connector?.walletBranding.icon||(t=>e.jsx(Ha,{...t})),te="Browser Extension"===Q?Q.toLowerCase():Q;t=r?`Successfully connected with ${te}`:h?h.message:K?"Switching networks":V?s&&z?"Signing":"Sign to verify":`Waiting for ${te}`;let re="Don’t see your wallet? Check your other browser windows.";r?re=R===(O?.linkedAccounts.length||0)?"Wallet was already linked.":"You’re good to go!":I>=2&&h?re="Unable to connect wallet":h?re=h.detail:K?re="Switch your wallet to the requested network.":V&&z?re="Sign the message in your wallet to verify it belongs to you.":"metamask"===J&&a.isMobile?re="Click continue to open and connect MetaMask.":"metamask"===J?re="For the best experience, connect only one wallet at a time.":"wallet_connect"===X?re="Open your mobile wallet app to continue":"coinbase_wallet"!==X||d.isCoinbaseWalletInstalled()||(re=ro(O)?"Continue with the Coinbase app. Not the right wallet? Reset your connection below.":"Open the Coinbase app on your phone to continue.");let ne=N?.walletConnectors?.find((e=>"coinbase_wallet"===e.walletClientType)),ie="coinbase_wallet"===J&&(ro(O)||h===m.ConnectorErrors.ERROR_USER_EXISTS);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:C&&E!==C?x:void 0}),e.jsxs(Ll,{children:[e.jsx(Dl,{walletLogo:ee,success:r,fail:!!h}),e.jsxs(Ys,{children:[e.jsx("h3",{children:t}),e.jsx("p",{children:re}),V||!F||H?null:e.jsxs("p",{children:["Still here?"," ",e.jsx("a",{href:F,target:"_blank",style:{textDecoration:"underline"},children:"Try connecting again"}),U&&e.jsxs(e.Fragment,{children:[" ","or"," ",e.jsx("a",{href:U,target:"_blank",style:{textDecoration:"underline"},children:"use this different link"})]})]})]}),ie?e.jsx(jo,{onClick:()=>ne&&ne?.disconnect(),disabled:r,children:"Use a different wallet"}):h==m.ConnectorErrors.ERROR_USER_EXISTS&&E!==C?e.jsx(jo,{onClick:x,children:"Use a different wallet"}):V&&!r&&z?e.jsx(jo,{onClick:()=>{c(!0),Z()},disabled:s,children:s?"Signing":"Sign with your wallet"}):!r&&h?.retryable&&I<2?e.jsx(jo,{onClick:()=>{M(I+1),p(void 0),V?(c(!0),Z()):j?.connectRetry()},disabled:!r&&(!h?.retryable||I>=2),children:"Retry"}):r||h?null:e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Connecting"})]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_CONNECT_ONLY_CONNECTION]:()=>{let t,{navigateBack:r,navigate:n,lastScreen:s,currentScreen:c,data:u}=g.usePrivyModal(),{walletConnectionStatus:h,closePrivyModal:p}=o.usePrivyInternal(),[y,f]=i.useState(void 0),[v,w]=i.useState(0),x="connected"===h?.status,C="switching_to_supported_chain"===h?.status;i.useEffect((()=>{if(x){let e;if(u?.externalConnectWallet?.onCompleteNavigateTo){let t=u.externalConnectWallet.onCompleteNavigateTo;e=setTimeout((()=>{n(t)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}else e=setTimeout(p,l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}}),[x]);i.useEffect((()=>{h?.connectError&&(e=>{f(Fl(e))})(h?.connectError)}),[h]);let E=h?.connector?.connectorType||"injected",b=h?.connector?.walletClientType||"unknown",S=bl[b]?.displayName||h?.connector?.walletBranding.name||"Browser Extension",A=bl[b]?.logo||h?.connector?.walletBranding.icon||(t=>e.jsx(Ha,{...t})),j="Browser Extension"===S?S.toLowerCase():S;t=x?`Successfully connected with ${j}`:y?y.message:C?"Switching networks":`Waiting for ${j}`;let $="Don’t see your wallet? Check your other browser windows.";return x?$="You’re good to go!":v>=2&&y?$="Unable to connect wallet":y?$=y.detail:C?$="Switch your wallet to the requested network.":"metamask"===b&&a.isMobile?$="Click to continue to open and connect MetaMask.":"metamask"===b?$="For the best experience, connect only one wallet at a time.":"wallet_connect_v2"===E?$="Open your mobile wallet app to continue":"coinbase_wallet"===E&&($="Open the Coinbase app on your phone to continue."),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:c===s?void 0:r}),e.jsxs(Wl,{children:[e.jsx(Dl,{walletLogo:A,success:x,fail:!!y}),e.jsxs(Ys,{children:[e.jsx("h3",{children:t}),e.jsx("p",{children:$})]}),y==m.ConnectorErrors.ERROR_USER_EXISTS?e.jsx(jo,{onClick:r,children:"Use a different wallet"}):!x&&y?.retryable&&v<2?e.jsx(jo,{onClick:()=>{w(v+1),f(void 0),h?.connectRetry()},disabled:!x&&(!y?.retryable||v>=2),children:"Retry"}):!x&&y&&v>=2?e.jsx(jo,{onClick:r,children:"Use a different wallet"}):null]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_FARCASTER_CONNECTION]:()=>{let{authenticated:t,logout:r,ready:n,user:s}=o.usePrivy(),{lastScreen:c,navigate:h,navigateBack:p,setModalData:y,app:m}=g.usePrivyModal(),{getAuthFlow:f,loginWithFarcaster:v,closePrivyModal:w,createAnalyticsEvent:x}=o.usePrivyInternal(),[C,E]=i.useState(void 0),[b,S]=i.useState(!1),[A,j]=i.useState(!1),$=i.useRef([]),T=f(),P=T?.meta.connectUri;return i.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{let r=await T.pollForReady.execute(),n=Date.now()-e;if(r){clearInterval(t),S(!0);try{await v(),j(!0)}catch(e){let t={retryable:!1,message:"Authentication failed"};if(e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return void h(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),void h(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return void h(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER)t.detail="This account has already been linked to another user.";else{if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return y({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:"farcaster",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,farcasterEmbeddedAddress:e.data?.data?.otherUser?.farcasterEmbeddedAddress}}),void h(g.ModalScreen.LINK_CONFLICT_SCREEN);e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS?(t.retryable=!0,t.detail="Something went wrong. Try again."):e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(t.detail="Too many requests. Please wait before trying again.")}E(t)}}else n>12e4&&(clearInterval(t),E({retryable:!0,message:"Authentication failed",detail:"The request timed out. Try again."}))}),2e3);return()=>{clearInterval(t),$.current.forEach((e=>clearTimeout(e)))}}),[]),i.useEffect((()=>{if(n&&t&&A&&s){if(m?.legal.requireUsersAcceptTerms&&!s.hasAcceptedTerms){let e=setTimeout((()=>{h(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}A&&(u.shouldProceedtoEmbeddedWalletCreationFlow(s,m?.embeddedWallets.createOnLogin)?$.current.push(setTimeout((()=>{y({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),x({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"FarcasterConnectStatusScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),h(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)):$.current.push(setTimeout((()=>w({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)))}}),[A,n,t,s]),a.isMobile||b?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:c?p:void 0,onClose:w},"header"),e.jsx(Xs,{}),a.isIOS?e.jsx(e.Fragment,{children:e.jsxs(Ic,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:A,fail:!!C}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:C?C.message:"Sign in with Farcaster"}),e.jsx(Es,{children:C?C.detail:"To sign in with Farcaster, please open the Warpcast app."})]}),P&&e.jsx(jo,{onClick:e=>{e.preventDefault(),window.location.href=P},children:"Open Warpcast app"})]})}):e.jsx(e.Fragment,{children:e.jsxs(Nc,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:A,fail:!!C}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:C?C.message:"Signing in with Farcaster"}),e.jsx(Es,{children:C?C.detail:"This should only take a moment"}),e.jsx(Gs,{children:P&&a.isMobile&&e.jsx(wc,{text:"Take me to Warpcast",url:P,color:kc})})]})]})}),e.jsx(d.ModalFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:c?p:void 0,onClose:w},"header"),e.jsx(Xs,{}),e.jsx(Nc,{children:e.jsxs("div",{children:[e.jsx(Cs,{children:"Sign in with Farcaster"}),e.jsx(Es,{children:"Scan with your phone's camera to continue."}),e.jsx(zs,{children:P?e.jsx(Pc,{url:P,size:275,squareLogoElement:_c}):e.jsx(Co,{})}),e.jsxs(Gs,{children:[e.jsx(Es,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),P&&e.jsx(gc,{text:P,itemName:"link",color:kc})]})]})}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_FARCASTER_SIGNER]:()=>{let{lastScreen:t,navigateBack:r,data:n,app:s}=g.usePrivyModal(),{requestFarcasterSignerStatus:c,closePrivyModal:u}=o.usePrivyInternal(),[h,p]=i.useState(void 0),[y,m]=i.useState(!1),[f,v]=i.useState(!1),w=i.useRef([]),x=n?.farcasterSigner;i.useEffect((()=>{let e=Date.now(),t=setInterval((async()=>{if(!x?.public_key)return clearInterval(t),void p({retryable:!0,message:"Connect failed",detail:"Something went wrong. Please try again."});"approved"===x.status&&(clearInterval(t),m(!1),v(!0),w.current.push(setTimeout((()=>u({shouldCallAuthOnSuccess:!1,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)));let r=await c(x?.public_key),n=Date.now()-e;"approved"===r.status?(clearInterval(t),m(!1),v(!0),w.current.push(setTimeout((()=>u({shouldCallAuthOnSuccess:!1,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS))):n>3e5?(clearInterval(t),p({retryable:!0,message:"Connect failed",detail:"The request timed out. Try again."})):"revoked"===r.status&&(clearInterval(t),p({retryable:!0,message:"Request rejected",detail:"The request was rejected. Please try again."}))}),2e3);return()=>{clearInterval(t),w.current.forEach((e=>clearTimeout(e)))}}),[]);let C="pending_approval"===x?.status?x.signer_approval_url:void 0;return a.isMobile||y?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t?r:void 0,onClose:u},"header"),e.jsx(Xs,{}),a.isIOS?e.jsx(e.Fragment,{children:e.jsxs(Rc,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:f,fail:!!h}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:h?h.message:"Add a signer to Farcaster"}),e.jsx(Es,{children:h?h.detail:"This will allow "+s.name+" to add casts, likes, follows, and more on your behalf."})]}),C&&e.jsx(jo,{onClick:e=>{e.preventDefault(),window.location.href=C},children:"Open Warpcast app"})]})}):e.jsx(e.Fragment,{children:e.jsxs(Oc,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:f,fail:!!h}),e.jsx(_c,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx(Cs,{children:h?h.message:"Requesting signer from Farcaster"}),e.jsx(Es,{children:h?h.detail:"This should only take a moment"}),e.jsx(Gs,{children:C&&a.isMobile&&e.jsx(wc,{text:"Take me to Warpcast",url:C,color:Mc})})]})]})}),e.jsx(d.ModalFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t?r:void 0,onClose:u},"header"),e.jsx(Xs,{}),e.jsx(Oc,{children:e.jsxs("div",{children:[e.jsx(Cs,{children:"Add a signer to Farcaster"}),e.jsxs(Es,{children:["This will allow ",s.name," to add casts, likes, follows, and more on your behalf."]}),e.jsx(zs,{children:"pending_approval"===x?.status?e.jsx(Pc,{url:x.signer_approval_url,size:275,squareLogoElement:_c}):e.jsx(Co,{})}),e.jsxs(Gs,{children:[e.jsx(Es,{children:"Or copy this link and paste it into a phone browser to open the Warpcast app."}),"pending_approval"===x?.status&&e.jsx(gc,{text:x.signer_approval_url,itemName:"link",color:Mc})]})]})}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.AWAITING_PASSKEY_SYSTEM_DIALOGUE]:()=>{let{lastScreen:t,currentScreen:r,navigateBack:n}=g.usePrivyModal(),{loginWithPasskey:a,closePrivyModal:s}=o.usePrivyInternal(),[c,u]=i.useState("loading"),[h,p]=i.useState(null),y=i.useRef([]);i.useEffect((()=>()=>{y.current.forEach((e=>clearTimeout(e))),y.current=[]}),[]);let m=async()=>{u("loading");try{await a(),u("success")}catch(e){p(e),u("error")}};return i.useEffect((()=>{"success"===c&&(e=>{y.current=[e,...y.current]})(setTimeout((()=>{s({shouldCallAuthOnSuccess:!0,isSuccess:!0})}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS))}),[c]),i.useEffect((()=>{m()}),[]),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t&&r!==t?n:void 0}),e.jsxs(am,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:"success"===c,fail:"error"===c}),e.jsx(mu,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:(()=>{switch(c){case"loading":return"Waiting for passkey";case"success":return"Success";case"error":return"Something went wrong"}})()}),e.jsx("p",{style:{whiteSpace:"pre-wrap"},children:(()=>{switch(c){case"loading":return"Please follow prompts to verify your passkey.\nYou will have to sign up with another method first to register a passkey for your account.";case"success":return"You've successfully logged in with your passkey.";case"error":if(h instanceof o.PrivyError){if(h.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)return"Cannot link more passkeys to account.";if(h.privyErrorCode===o.PrivyErrorCode.PASSKEY_NOT_ALLOWED)return"Passkey request timed out or rejected by user.\nYou will have to sign up with another method first to register a passkey for your account."}return"An unknown error occurred.\nYou will have to sign up with another method first to register a passkey for your account."}})()})]}),(()=>{switch(c){case"loading":case"success":return e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Continue"});case"error":return e.jsx(jo,{onClick:m,disabled:!1,children:"Retry"})}})()]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.PHANTOM_INTERSTITIAL_SCREEN]:()=>{let{forkSession:t,ready:r,authenticated:n}=o.usePrivy(),{walletConnectionStatus:s}=o.usePrivyInternal(),[l,c]=i.useState(""),[u,h]=i.useState(!1);i.useEffect((()=>{r&&n&&t().then(c)}),[r,n]);let p=((e,t,r)=>{let n=encodeURIComponent(new URL(window.location.href).href.replace(/\/$/g,"")+`?privy_token=${e}&privy_connector=${r?"solana_adapter":"injected"}&privy_wallet_client=${r?"phantom_solana":"phantom"}`);if(!d.isPhantomInstalled()&&a.isMobile)return`${t?"phantom://":"https://phantom.app/ul/"}browse/${n}?ref=${n}`})(l,!u,"solana"===s?.connector?.chainType),y={title:"Redirecting to Phantom Mobile Wallet",description:"We'll take you to the Phantom Mobile Wallet app to continue your login experience.",footnote:""};return r&&(y.description="For the best experience, we'll automatically log you into the Phantom Mobile Wallet in-app browser.",y.footnote="Once you're done, you can always return here and refresh to view your updated account."),u&&(y.title="Still here?",y.description="You may need to install the Phantom mobile app.",y.footnote="Once you're done, you can return here or connect via Phantom's in-app browser."),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(nl,{title:y.title,description:y.description}),e.jsxs(Hs,{children:[e.jsx(om,{children:e.jsx(qa,{style:{width:"72px",height:"72px"}})}),e.jsx(Po,{href:p,onClick:()=>{setTimeout((()=>h(!0)),1e3)},loading:r&&!p,children:u?"Go to App Store":"Continue"}),y.footnote?e.jsx("p",{children:y.footnote}):null]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LOGIN_FAILED_SCREEN]:()=>{let{closePrivyModal:t}=o.usePrivyInternal(),{navigate:r}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(Op,{style:{width:"160px",height:"160px",margin:"0 auto 20px"}}),e.jsx(nl,{title:"Could not connect with wallet",description:"Please check that Phantom multichain is enabled and try again.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),e.jsxs(Hs,{children:[e.jsx(jo,{onClick:()=>r(g.ModalScreen.LANDING),children:"Try again"}),e.jsx(ko,{onClick:()=>t(),children:"Cancel"})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.AWAITING_OAUTH_SCREEN]:()=>{let{authenticated:t,logout:r,ready:n,user:a}=o.usePrivy(),{app:s,setModalData:c,navigate:h,resetNavigation:p}=g.usePrivyModal(),{getAuthMeta:y,initLoginWithOAuth:m,loginWithOAuth:f,updateWallets:v,setReadyToTrue:w,closePrivyModal:x,createAnalyticsEvent:C}=o.usePrivyInternal(),[E,b]=i.useState(!1),[S,A]=i.useState(void 0),j=y()?.provider||"google",{name:$,component:T}=ua(j),P=d.useEmitPrivyEvent();i.useEffect((()=>{f(j).then((e=>{b(!0),w(!0),e&&P("login","onOAuthLoginComplete",e)})).catch((e=>{if(w(!1),e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return A(void 0),p(),void h(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),A(void 0),p(),void h(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return A(void 0),p(),void h(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return A(void 0),p(),c({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,displayName:e.data?.data?.account?.displayName,linkMethod:y()?.provider,embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress,oAuthUserInfo:e.data?.data?.otherUser?.oAuthUserInfo}}),void h(g.ModalScreen.LINK_CONFLICT_SCREEN);let{retryable:t,detail:r}=function(e,t){let r={detail:"",retryable:!1},n=Qi(t);if(e?.privyErrorCode===o.PrivyErrorCode.LINKED_TO_ANOTHER_USER&&(r.detail="This account has already been linked to another user."),e?.privyErrorCode===o.PrivyErrorCode.INVALID_CREDENTIALS&&(r.retryable=!0,r.detail="Something went wrong. Try again."),e.privyErrorCode===o.PrivyErrorCode.OAUTH_USER_DENIED&&(r.detail=`Retry and check ${n} to finish connecting your account.`,r.retryable=!0),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&(r.detail="Too many requests. Please wait before trying again."),e?.privyErrorCode===o.PrivyErrorCode.TOO_MANY_REQUESTS&&e.message.includes("provider rate limit")){let e=ua(t).name;r.detail=`Request limit reached for ${e}. Please wait a moment and try again.`}if(e?.privyErrorCode===o.PrivyErrorCode.OAUTH_ACCOUNT_SUSPENDED){let e=ua(t).name;r.detail=`Your ${e} account is suspended. Please try another login method.`}return e?.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE&&(r.detail="You cannot authorize more than one account for this user."),e?.privyErrorCode===o.PrivyErrorCode.OAUTH_UNEXPECTED&&t.startsWith("privy:")&&(r.detail="Something went wrong. Please try again."),r}(e,j);A({retryable:t,detail:r,message:"Authentication failed"})})).finally((()=>{pa()}))}),[$,j]),i.useEffect((()=>{if(n&&t&&E&&a){if(s?.legal.requireUsersAcceptTerms&&!a.hasAcceptedTerms){let e=setTimeout((()=>{h(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(a,s?.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:j,screen:"OAuthStatusScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),h(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}{let e=setTimeout((()=>x({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return v(),()=>clearTimeout(e)}}}),[n,t,E,a]);let _=E?`Successfully connected with ${$}`:S?S.message:`Verifying connection to ${$}`,k="";return k=E?"You’re good to go!":S?S.detail:"Just a few moments more",e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsx(Xs,{}),e.jsxs(im,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:E,fail:!!S}),e.jsx(T,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:_}),e.jsx("p",{children:k})]}),S&&S?.retryable?e.jsx(Io,{onClick:()=>{pa(),m(j),A(void 0)},disabled:!E&&!S?.retryable,children:"Retry"}):null]}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.CROSS_APP_AUTH_SCREEN]:()=>{let t=l.useAppConfig(),{data:r,navigate:n,setModalData:a,onUserCloseViaDialogOrKeybindRef:s}=g.usePrivyModal(),{crossAppAuthFlow:c,updateWallets:h,closePrivyModal:p,createAnalyticsEvent:y}=o.usePrivyInternal(),{logout:m}=d.useLogout(),[f,v]=i.useState({}),w=r?.crossAppAuth,x={id:w.appId,name:w.name,logoUrl:w.logoUrl},C=new o.PrivyClientError(`There was an issue connecting your ${x.name} account. Please try again.`),E=new Gi((async e=>{if(w.popup)try{let t=await c({appId:e,popup:w.popup,action:w.action});v({data:t})}catch(e){e instanceof o.PrivyClientError?v({error:e}):(e instanceof o.PrivyApiError&&w.popup&&w.popup.close(),v({error:C}))}else v({error:C})})),b=()=>{f.data&&(h(),w.onSuccess(f.data),p({shouldCallAuthOnSuccess:!0,isSuccess:!0})),w.onError(f.error??new o.PrivyClientError("User canceled flow")),p({shouldCallAuthOnSuccess:!1,isSuccess:!1})};s.current=b,i.useEffect((()=>{x.id.length&&E.execute(x.id)}),[x.id]),i.useEffect((()=>{if(!f.data)return;let e=f.data;if(t.legal.requireUsersAcceptTerms&&!e.hasAcceptedTerms){let e=setTimeout((()=>{n(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(e,t.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),y({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:`privy:${x.id}`,screen:"CrossAppAuthScreen"}}),m()},callAuthOnSuccessOnClose:!0}}),n(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}let r=setTimeout(b,l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(r)}),[f.data]);let{title:S,subtitle:A}=i.useMemo((()=>f.data?{title:`Successfully connected with ${x.name}`,subtitle:"You're good to go!"}:f.error?{title:"Authentication failed",subtitle:f.error.message}:{title:`Connecting to ${x.name}`,subtitle:`Please check the pop-up from ${x.name} to continue`}),[f,x.name]);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:b}),e.jsx(Xs,{}),e.jsxs(Hl,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:!!f.data,fail:!!f.error}),e.jsx(Bl,{name:x.name,logoUrl:x.logoUrl})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:S}),e.jsx("p",{children:A})]})]}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.ALLOWLIST_REJECTION_SCREEN]:()=>{let{navigate:t,app:r}=g.usePrivyModal(),n=r?.allowlistConfig.errorTitle||"You don't have access to this app",i=r?.allowlistConfig.errorDetail||"Have you been invited?",a=r?.allowlistConfig.errorCtaText||"Try another account";return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsxs(Ws,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(os,{}),e.jsx(Ds,{style:{width:"38px",height:"38px",strokeWidth:"1",stroke:"var(--privy-color-accent)",fill:"var(--privy-color-accent)"}})]})}),e.jsxs(Bs,{children:["string"==typeof n?e.jsx("h3",{children:n}):e.jsx(e.Fragment,{children:n}),"string"==typeof i?e.jsx("p",{children:i}):e.jsx(e.Fragment,{children:i})]}),r?.allowlistConfig.errorCtaLink?e.jsx(jo,{as:"a",href:r.allowlistConfig.errorCtaLink,children:a}):e.jsx(jo,{onClick:()=>{t(g.ModalScreen.LANDING)},children:a})]})]})},[g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN]:()=>{let{navigate:t,app:r}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsxs(is,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(Ro,{color:"var(--privy-color-warn-light)"}),e.jsx(Ue.default,{height:38,width:38,strokeWidth:2,stroke:"var(--privy-color-warn)"})]})}),e.jsxs(as,{children:[e.jsx("h3",{children:"Account not found"}),e.jsxs("p",{children:["Please try logging in again or go to ",r.name," to create an account."]})]}),e.jsx(Yo,{}),e.jsx(jo,{onClick:()=>t(g.ModalScreen.LANDING),children:"Try logging in again"})]})]})},[g.ModalScreen.USER_LIMIT_REACHED_SCREEN]:()=>{let{navigate:t}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsxs(Lf,{children:[e.jsx(Uf,{children:e.jsx(Ff,{})}),e.jsxs(Df,{children:[e.jsx("h3",{children:"Unable to sign in"}),e.jsx("p",{children:"This application has reached its user limit and cannot sign in new users."})]}),e.jsx(jo,{onClick:()=>{t(g.ModalScreen.LANDING)},children:"Go back"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.INSTALL_PHANTOM_SCREEN]:()=>{let{navigateBack:t}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t},"header"),e.jsx(Xs,{}),e.jsx(ep,{}),e.jsx(Js,{}),e.jsxs(d.ModalFooter,{children:[e.jsx("span",{children:"Still not sure? "}),e.jsx("a",{target:"_blank",href:"https://ethereum.org/en/wallets/",children:"Learn more"})]})]})},[g.ModalScreen.LINK_EMAIL_SCREEN]:()=>{let{app:t}=g.usePrivyModal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Connect your email",description:`Add your email to your ${t?.name} account`,icon:e.jsx(Ke.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),e.jsx(Hs,{children:e.jsx(sp,{stacked:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LINK_PHONE_SCREEN]:()=>{let{app:t,currentScreen:r,data:n,navigate:i,setModalData:a}=g.usePrivyModal(),{initLoginWithSms:s}=o.usePrivyInternal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Connect your phone",description:`Add your number to your ${t?.name} account`,icon:e.jsx(Ye.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"40px",width:"40px"})}),e.jsx(Hs,{children:e.jsx(yp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{await s(e),i(g.ModalScreen.AWAITING_PASSWORDLESS_CODE)}catch(e){a({errorModalData:{error:e,previousScreen:n?.errorModalData?.previousScreen||r||g.ModalScreen.LINK_PHONE_SCREEN}}),i(g.ModalScreen.ERROR_SCREEN)}},hideRecent:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LINK_WALLET_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),n=r?.externalConnectWallet?.suggestedAddress,i=n?e.jsxs("span",{children:["Link the wallet with address ",e.jsx(d.Address,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Link a wallet to your ${t?.name} account`;return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(nl,{title:"Link your wallet",description:i}),e.jsx(Xo,{children:e.jsx(Ol,{connectOnly:!1})}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.LINK_PASSKEY_SCREEN]:()=>{let{user:t,unlinkPasskey:r}=o.usePrivy(),{linkWithPasskey:n,closePrivyModal:a}=o.usePrivyInternal(),s=t?.linkedAccounts.filter((e=>"passkey"===e.type)),[l,c]=i.useState(!1),[u,h]=i.useState(""),[p,y]=i.useState(!1),[m,f]=i.useState(!1);i.useEffect((()=>{0===s.length&&f(!1)}),[s.length]);let g=async e=>(c(!0),await r(e).then((()=>y(!0))).catch((e=>{e instanceof o.PrivyError&&e.privyErrorCode===o.PrivyErrorCode.MISSING_MFA_CREDENTIALS?h("Cannot unlink a passkey enrolled in MFA"):h("Unknown error occurred.")})).finally((()=>{c(!1)})));return p?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:()=>a()},"header"),e.jsx(xs,{children:e.jsx(Rs,{status:"success",children:e.jsx(Ze.default,{})})}),e.jsx(bu,{children:"Passkey added"}),e.jsx(Su,{children:"From now on, you can use your passkey to log in."}),e.jsx($s,{children:e.jsx(jo,{onClick:()=>a(),children:"Done"})}),e.jsx(d.ModalFooter,{})]}):m?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>f(!1),onClose:()=>a()},"header"),e.jsx(fu,{passkeys:s,expanded:m,onUnlink:g,onExpand:()=>f(!0)}),e.jsx(d.ModalFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:()=>a()},"header"),e.jsx(xs,{children:e.jsxs(vu,{children:[e.jsx(yu,{}),e.jsx(mu,{})]})}),e.jsx(bu,{children:"Secure your account with a passkey"}),e.jsx(Au,{}),0===s.length?e.jsx(gu,{}):e.jsx(fu,{passkeys:s,expanded:m,onUnlink:g,onExpand:()=>f(!0)}),e.jsxs($s,{style:{marginTop:"12px"},children:[u&&e.jsx(wu,{$fail:!0,children:u}),e.jsx(jo,{onClick:()=>{c(!0),n().then((()=>y(!0))).catch((e=>{if(e instanceof o.PrivyError){if(e.privyErrorCode===o.PrivyErrorCode.CANNOT_LINK_MORE_OF_TYPE)return void h("Cannot link more passkeys to account.");if(e.privyErrorCode===o.PrivyErrorCode.PASSKEY_NOT_ALLOWED)return void h("Passkey request timed out or rejected by user.")}h("Unknown error occurred.")})).finally((()=>{c(!1)}))},loading:l,children:"Add new passkey"})]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.UPDATE_EMAIL_SCREEN]:()=>e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Update your email",description:"Add the email address you'd like to use going forward. We'll send you a confirmation code",icon:e.jsx(Ke.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),e.jsx(Hs,{children:e.jsx(Mf,{stacked:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]}),[g.ModalScreen.UPDATE_PHONE_SCREEN]:()=>{let{currentScreen:t,data:r,navigate:n,setModalData:i}=g.usePrivyModal(),{user:a}=o.usePrivy(),{initUpdatePhone:s}=o.usePrivyInternal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Xs,{}),e.jsx(il,{title:"Update your phone number",description:"Add the phone number you'd like to use going forward. We'll send you a confirmation code",icon:e.jsx(Ye.default,{color:"var(--privy-color-accent)",strokeWidth:2,height:"48px",width:"48px"})}),e.jsx(Hs,{children:e.jsx(yp,{stacked:!0,onSubmit:async function({qualifiedPhoneNumber:e}){try{if(!a?.phone?.number)throw Error("User is required to have an phone number to update it.");await s(a?.phone?.number,e),n(g.ModalScreen.AWAITING_PASSWORDLESS_CODE)}catch(e){i({errorModalData:{error:e,previousScreen:r?.errorModalData?.previousScreen||t||g.ModalScreen.LINK_PHONE_SCREEN}}),n(g.ModalScreen.ERROR_SCREEN)}},hideRecent:!0})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.CONNECT_ONLY_LANDING_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),n=r?.externalConnectWallet?.suggestedAddress,i=n?e.jsxs("span",{children:["Connect the wallet with address ",e.jsx(d.Address,{showCopyIcon:!1,address:n})," ",t?.name?`to ${t.name}.`:"."]}):`Connect a wallet to your ${t?.name} account`;return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(rl,{title:"Connect your wallet",description:i}),e.jsx(Xo,{children:e.jsx(Ol,{connectOnly:!0})}),t&&e.jsx(d.TermsAndConditions,{app:t,alwaysShowImplicitConsent:!0}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.CONNECT_ONLY_AUTHENTICATED_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),n=r?.externalConnectWallet?.suggestedAddress,i=n?`Connect the wallet with address ${d.formatWalletAddress(n)} ${t?.name?`to ${t.name}.`:"."}`:`Connect a wallet to ${t?.name}`;return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(nl,{title:"Connect your wallet",description:i}),e.jsx(Xo,{children:e.jsx(Ol,{connectOnly:!0})}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN]:()=>{let{app:t,setModalData:r,navigate:n,data:a,onUserCloseViaDialogOrKeybindRef:s}=g.usePrivyModal(),[d,c]=i.useState(""),{embeddedWallets:u}=l.useAppConfig(),{authenticated:h,user:p}=o.usePrivy(),{closePrivyModal:y}=o.usePrivyInternal(),{onSuccess:m,onFailure:f,callAuthOnSuccessOnClose:v}=a.createWallet,w=!0===t?.embeddedWallets.requireUserOwnedRecoveryOnCreate,{createWallet:x}=Cd(),[C,E]=i.useState(null),b=new Gi((async()=>{try{let e=await x({user:p});if(!e)return;E(e),n(g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN)}catch(e){c(e.message)}}));return i.useEffect((()=>h&&p?w?(r({...a,recoverySelection:{...a?.recoverySelection,isInAccountCreateFlow:!0}}),n(ld({walletAction:"create",showAutomaticRecovery:!1,availableRecoveryMethods:u.userOwnedRecoveryOptions,legacySetWalletPasswordFlow:!1,isResettingPassword:!1}))):void b.execute():(n(g.ModalScreen.LANDING),void f(Error("User must be authenticated before creating a Privy wallet")))),[w,h]),s.current=()=>null,d?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{closeable:!1}),e.jsxs(Vs,{children:[e.jsx(Xe.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),e.jsx(il,{title:"Something went wrong",description:d})]}),e.jsx(jo,{onClick:()=>{C?(m(C),y({shouldCallAuthOnSuccess:v})):(f(new o.PrivyEmbeddedWalletError("User wallet creation failed")),y({shouldCallAuthOnSuccess:!1}))},children:"Close"}),e.jsx(Ed,{})]}):e.jsx(Vl,{})},[g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN]:()=>{let{user:t}=o.usePrivy(),{closePrivyModal:r,isNewUserThisSession:n,updateWallets:a}=o.usePrivyInternal(),{app:s,data:c,onUserCloseViaDialogOrKeybindRef:h}=g.usePrivyModal(),{onSuccess:p,onFailure:y,callAuthOnSuccessOnClose:m}=c.createWallet,f=()=>{let e=u.getPrivyEthereumWallet(t);e?(a(),p(e)):y(Error("Failed to create wallet")),r({shouldCallAuthOnSuccess:m})};return i.useEffect((()=>{let e=setTimeout(f,l.DEFAULT_SUCCESS_SCREEN_LONG_DURATION_MS);return()=>clearTimeout(e)}),[]),h.current=f,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:f}),e.jsx(Xs,{}),e.jsxs(Vs,{children:[e.jsx(Ze.default,{fill:"var(--privy-color-accent)",width:"64px",height:"64px"}),e.jsx(il,{title:n?"Welcome"+(s?.name?` to ${s?.name}`:""):"All set!",description:n?"You’ve successfully created an account.":"Your account is secured."})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_CONNECTING_SCREEN]:()=>{let{authenticated:t,user:r,getAccessToken:n}=o.usePrivy(),{closePrivyModal:a,createAnalyticsEvent:s,walletProxy:l}=o.usePrivyInternal(),{navigate:d,data:c,setModalData:h,onUserCloseViaDialogOrKeybindRef:p}=g.usePrivyModal(),y=i.useMemo((()=>Date.now()),[]),[m,f]=i.useState(!1),{onCompleteNavigateTo:v,onFailure:w,shouldForceMFA:x,address:C}=c?.connectWallet,E=e=>{m||(f(!0),w("string"==typeof e?Error(e):e))};i.useEffect((()=>{let e,i=C?r?.linkedAccounts.find((e=>"wallet"===e.type&&"privy"===e.walletClientType&&e.address===C)):u.getPrivyEthereumWallet(r);return t&&i?l?((async()=>{let t=await n();if(!t)return E("User must be authenticated and have a Privy wallet before it can be connected");let r="ethereum"===i.chainType;try{r?await l.connect({accessToken:t,address:i.address}):await l.connectSolana({accessToken:t,publicKey:i.address}),x&&await l.verifyMfa({accessToken:t});let n=(Date.now()-y)/1e3;v===g.ModalScreen.EMBEDDED_WALLET_KEY_EXPORT_SCREEN&&n<1?e=setTimeout((()=>{d(v,!1)}),1e3*(1-n)):d(v,!1)}catch(e){if(td(e)&&"privy"===i.recoveryMethod){let e=await n();if(!e)return E("User must be authenticated and have a Privy wallet before it can be recovered");try{if(s({eventName:"embedded_wallet_pinless_recovery_started",payload:{walletAddress:i.address}}),r){let t=await(l?.recover({address:i.address,accessToken:e,recoveryMethod:i.recoveryMethod}));t?.address||E(Error("Unable to recover wallet"))}else{let t=await(l?.recoverSolana({publicKey:i.address,accessToken:e}));t?.publicKey||E(Error("Unable to recover wallet"))}v?d(v):a({shouldCallAuthOnSuccess:!1}),s({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:i.address}}),d(v)}catch(e){E("An error has occurred, please try again.")}}else td(e)&&"privy"!==i.recoveryMethod?(h({...c,recoverWallet:{privyWallet:i,onCompleteNavigateTo:v,onFailure:w},recoveryOAuthStatus:{provider:i.recoveryMethod,action:"recover",isInAccountCreateFlow:!1}}),d(dd(i.recoveryMethod))):E(e)}})(),()=>clearTimeout(e)):void 0:E("User must be authenticated and have a Privy wallet before it can be connected")}),[t,r,l]);let b=()=>{E("User exited before wallet could be connected"),a({shouldCallAuthOnSuccess:!1})};return p.current=b,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:b}),m?e.jsxs(e.Fragment,{children:[e.jsxs(Vs,{children:[e.jsx(Xe.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}),e.jsx(il,{title:"Something went wrong",description:"We’re on it. Please try again later."})]}),e.jsx(jo,{onClick:()=>a({shouldCallAuthOnSuccess:!1}),children:"Close"})]}):e.jsx(Vl,{}),e.jsx(hd,{})]})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_RECOVERY_SCREEN]:()=>{let[t,r]=i.useState(!0),{authenticated:n,getAccessToken:a}=o.usePrivy(),{walletProxy:s,closePrivyModal:l,createAnalyticsEvent:c}=o.usePrivyInternal(),{navigate:u,data:h,onUserCloseViaDialogOrKeybindRef:p}=g.usePrivyModal(),[y,m]=i.useState(void 0),[f,v]=i.useState(""),[w,x]=i.useState(!1),{privyWallet:C,onCompleteNavigateTo:E,onSuccess:b,onFailure:S}=h.recoverWallet,A=(e="User exited before their wallet could be recovered")=>{l({shouldCallAuthOnSuccess:!1}),S("string"==typeof e?new o.PrivyEmbeddedWalletError(e):e)};p.current=A,i.useEffect((()=>{if(!n||!C)return A("User must be authenticated and have a Privy wallet before it can be recovered")}),[n]);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A}),e.jsx(Xs,{}),e.jsxs(lm,{children:[e.jsxs(sm,{children:[e.jsx(Pt.default,{height:48,width:48,stroke:"var(--privy-color-accent)"}),e.jsx("h3",{style:{color:"var(--privy-color-foreground)"},children:"Enter your password"}),e.jsx("p",{style:{color:"var(--privy-color-foreground-2)"},children:"Please provision your account on this new device. To continue, enter your recovery password."})]}),e.jsxs("div",{children:[e.jsxs(_d,{children:[e.jsx(Td,{type:t?"password":"text",onChange:e=>(e=>{e&&m(e)})(e.target.value),disabled:w,style:{paddingRight:"2.3rem"}}),e.jsx(Od,{style:{right:"0.75rem"},children:t?e.jsx(Fd,{onClick:()=>r(!1)}):e.jsx(Ld,{onClick:()=>r(!0)})})]}),!!f&&e.jsx(dm,{children:f})]}),e.jsxs("div",{children:[e.jsxs(Zs,{children:[e.jsx("h4",{children:"Why is this necessary?"}),e.jsx("p",{children:"You previously set a password for this wallet. This helps ensure only you can access it"})]}),e.jsx(cm,{loading:w||!s,disabled:!y,onClick:async()=>{x(!0);let e=await a();if(!e||!C||null===y)return A("User must be authenticated and have a Privy wallet before it can be recovered");try{c({eventName:"embedded_wallet_recovery_started",payload:{walletAddress:C.address}}),await(s?.recover({address:C.address,accessToken:e,recoveryPin:y,recoveryMethod:C.recoveryMethod})),v(""),E?u(E):l({shouldCallAuthOnSuccess:!1}),b?.(C),c({eventName:"embedded_wallet_recovery_completed",payload:{walletAddress:C.address}})}catch(e){!function(e){return ed(e)&&("invalid_recovery_pin"===e.type||"invalid_request_arguments"===e.type)}(e)?v("An error has occurred, please try again."):v("Invalid recovery password, please try again.")}finally{x(!1)}},warn:!1,hideAnimations:!C&&w,children:"Recover your account"})]})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_RECOVERY_SELECTION_SCREEN]:()=>{let[t,r]=i.useState(!1),{navigate:n,lastScreen:a,navigateBack:s,setModalData:c,data:h,onUserCloseViaDialogOrKeybindRef:p}=g.usePrivyModal(),{user:y}=o.usePrivy(),{embeddedWallets:m}=l.useAppConfig(),{closePrivyModal:f}=o.usePrivyInternal(),v=u.getPrivyEthereumWallet(y),w=null===v,{isInAccountCreateFlow:x,isResettingPassword:C}=h.recoverySelection,E=v&&"privy"!==v.recoveryMethod,b=E?e.jsxs("span",{children:["Your account is currently secured using"," ",e.jsx("strong",{children:gm[v?.recoveryMethod||"user-passcode"]}),"."]}):"Select a method for logging in on new devices and recovering your account.";function S(e){c({recoveryOAuthStatus:{provider:e,action:w?"create-wallet":"set-recovery",isInAccountCreateFlow:x}}),n(g.ModalScreen.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN)}function A(){h?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),f({shouldCallAuthOnSuccess:h?.setWalletPassword?.callAuthOnSuccessOnClose??!1})}return p.current=A,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A,backFn:t?()=>r(!1):a?s:void 0,infoFn:a||t?void 0:()=>r(!0)},"header"),t?e.jsx(vm,{onClose:()=>r(!1)}):e.jsxs(e.Fragment,{children:[e.jsx(il,{title:E?"Update backup method":"Secure your account",icon:e.jsx(It.default,{width:48}),description:b}),e.jsx(pm,{children:m.userOwnedRecoveryOptions.filter((e=>!["icloud","google-drive"].includes(v?.recoveryMethod||"")||e!==v?.recoveryMethod)).sort().map((t=>{switch(t){case"google-drive":return e.jsxs(ts,{onClick:()=>S("google-drive"),children:[e.jsx(fm,{children:e.jsx(hm,{style:{width:18}})}),"Back up to Google Drive"]},t);case"icloud":return e.jsxs(ts,{onClick:()=>S("icloud"),children:[e.jsx(fm,{children:e.jsx(um,{style:{width:24}})}),"Back up to Apple iCloud"]},t);case"user-passcode":return e.jsxs(ts,{onClick:()=>{n(sd({isCreatingWallet:w,skipSplashScreen:!0}))},children:[e.jsx(fm,{children:e.jsx(Mt.default,{style:{width:18}})}),C?"Reset your":"Set a"," password"]},t);default:return null}}))})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_SET_AUTOMATIC_RECOVERY_SCREEN]:()=>{let{user:t,getAccessToken:r}=o.usePrivy(),n=u.getPrivyEthereumWallet(t),{walletProxy:a,refreshUser:s,closePrivyModal:c}=o.usePrivyInternal(),h=g.usePrivyModal(),[p,y]=i.useState(!1),[m,f]=i.useState(null),[v,w]=i.useState(null);function x(){if(!p){if(v)return h.data?.setWalletPassword?.onFailure(v),void c();if(!m)return h.data?.setWalletPassword?.onFailure(Error("User exited set recovery flow")),void c()}}h.onUserCloseViaDialogOrKeybindRef.current=x;let C=!(!p&&!m);return v?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:x},"header"),e.jsx(wm,{$color:"var(--privy-color-error)",style:{alignSelf:"center"},children:e.jsx(He.default,{height:38,width:38,stroke:"var(--privy-color-error)"})}),e.jsx(fd,{style:{marginTop:"0.5rem"},children:"Something went wrong"}),e.jsx(Yo,{style:{minHeight:"2rem"}}),e.jsx($o,{onClick:()=>w(null),children:"Try again"}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:x},"header"),e.jsx(It.default,{style:{width:"3rem",height:"3rem",alignSelf:"center"}}),e.jsx(fd,{style:{marginTop:"0.5rem"},children:"Automatically secure your account"}),e.jsx(md,{style:{marginTop:"1rem"},children:"When you log into a new device, you’ll only need to authenticate to access your account. Never get logged out if you forget your password."}),e.jsx(Yo,{style:{minHeight:"2rem"}}),e.jsx($o,{loading:p,disabled:C,onClick:()=>async function(){y(!0);try{let e=await r();if(!e||!a||!n)return;if(!(await a.setRecovery({recoveryMethod:"privy",address:n.address,accessToken:e})).address)throw Error("Unable to set recovery on wallet");let t=await s();if(!t)throw Error("Unable to set recovery on wallet");let i=u.getPrivyEthereumWallet(t);if(!i)throw Error("Unabled to set recovery on wallet");f(!!t),setTimeout((()=>{h.data?.setWalletPassword?.onSuccess(i),c()}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}catch(e){w(e)}finally{y(!1)}}(),children:m?"Success":"Confirm"}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_RECOVERY_OAUTH_SCREEN]:()=>{let{logout:t}=o.usePrivy(),{navigate:r,setModalData:n,data:a}=g.usePrivyModal(),{recoveryOAuthFlow:s,closePrivyModal:c,createAnalyticsEvent:u}=o.usePrivyInternal(),[h,p]=i.useState(!1),{provider:y,action:m,isInAccountCreateFlow:f}=a?.recoveryOAuthStatus,[v,w]=i.useState(void 0),[x,C]=i.useState("create-wallet"===m);if("user-passcode"===y)throw Error("RecoveryOAuthScreen should never be called with a wallet that specifies recoveryMethod: `user-passcode`");let E=mm[y].name,b=mm[y].component,S=a?.recoverWallet?.onCompleteNavigateTo,A=new Gi((async(e="create-wallet")=>(C(!0),new Promise(((t,r)=>{setTimeout((async()=>{try{let r=window.open();await s(y,e,r),p(!0),t()}catch(t){w({message:`${"recover"===e?"Recovery":"Back up"} with ${E} unsuccessful`,detail:"recover"===m?`Please verify that you are selecting the ${E} account associated with your backup.`:"",retryable:!0}),r()}}),0)})))));i.useEffect((()=>{"recover"!==m&&A.execute(f?"create-wallet":"set-recovery")}),[]),i.useEffect((()=>{if(!h)return;let e=setTimeout((()=>{f?(n({createWallet:{onSuccess:()=>{},onFailure:e=>{u({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"RecoveryOAuthScreen"}}),t()},callAuthOnSuccessOnClose:!0}}),r(g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN)):c({shouldCallAuthOnSuccess:!1})}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}),[h]);let j=i.useCallback((async()=>{await A.execute("recover"),S?r(S):p(!0)}),[]),$="google-drive"===y?"Google Drive":"Apple iCloud",T=h&&`Successfully ${"recover"===m?"recovered":"backed up"} with ${$}.`||v&&v.message||`${"recover"===m?"Recovering":"Backing up"} with ${$}...`,P=v?v.detail:"";return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),x?e.jsx(e.Fragment,{children:e.jsxs(pm,{children:[e.jsx(il,{title:T,icon:e.jsx(b,{style:{width:"38px",height:"38px"}}),description:P}),v&&v?.retryable?e.jsx(jo,{onClick:()=>{pa(),w(void 0),"create-wallet"===m?A.execute("create-wallet"):j()},disabled:!h&&!v?.retryable,children:"Try again"}):null]})}):e.jsxs(pm,{children:[e.jsx(il,{title:"Confirm it's really you",icon:e.jsx(b,{style:{height:42,width:48}}),description:`To confirm your identity, please log in to ${$} where your account is backed up.`}),e.jsxs(jo,{onClick:j,children:["Confirm with ",$]})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_KEY_EXPORT_SCREEN]:()=>{let[t,r]=i.useState(null),{authenticated:n,user:a,getAccessToken:s}=o.usePrivy(),{closePrivyModal:c,createAnalyticsEvent:u,clientAnalyticsId:h}=o.usePrivyInternal(),p=l.useAppConfig(),{data:y,onUserCloseViaDialogOrKeybindRef:m}=g.usePrivyModal(),{onFailure:f,onSuccess:v,origin:w,appId:x,appClientId:C,wallet:E}=y.keyExport,b=e=>{c({shouldCallAuthOnSuccess:!1}),f("string"==typeof e?Error(e):e)},S=()=>{c({shouldCallAuthOnSuccess:!1}),v(),u({eventName:"embedded_wallet_key_export_completed",payload:{walletAddress:E.address}})};return i.useEffect((()=>{if(!n||!E)return b("User must be authenticated before exporting their wallet");s().then(r,b)}),[n,a]),m.current=S,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:S}),e.jsxs(vd,{children:[e.jsx(fd,{children:"Transfer wallet"}),e.jsxs(md,{children:["Either copy your private key or seed phrase to transfer your wallet."," ",e.jsx("a",{href:"https://privy-io.notion.site/Transferring-your-account-9dab9e16c6034a7ab1ff7fa479b02828",target:"blank",rel:"noopener noreferrer",children:"Learn more"})]}),e.jsx(pd,{theme:p.appearance.palette.colorScheme,children:"Never share your private key or seed phrase with anyone."}),e.jsx(d.WalletInfoCard,{isLoading:!1,isPulsing:!1,title:"Your wallet",address:E.address,showIcon:!0}),e.jsx("div",{style:{width:"100%"},children:t&&e.jsx(gd,{origin:w,appId:x,appClientId:C,accessToken:t,clientAnalyticsId:h,wallet:E,dimensions:{height:"44px"}})})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_SIGN_REQUEST_SCREEN]:()=>{let{authenticated:t}=o.usePrivy(),{initializeWalletProxy:r,closePrivyModal:n}=o.usePrivyInternal(),{navigate:a,data:s,onUserCloseViaDialogOrKeybindRef:c}=g.usePrivyModal(),[u,h]=i.useState(!0),[p,y]=i.useState(""),[f,v]=i.useState(),[w,x]=i.useState(null),[C,E]=i.useState(!1),b=null!==w;i.useEffect((()=>{t||a(g.ModalScreen.LANDING)}),[t]),i.useEffect((()=>{r(l.WALLET_PROXY_TIMEOUT).then((e=>{h(!1),e||(y("An error has occurred, please try again."),v(new m.PrivyProviderRpcError(new m.ProviderRpcError(p,m.E.E32603_DEFAULT_INTERNAL_ERROR.eipCode))))}))}),[]);let{method:S,data:A,confirmAndSign:j,onSuccess:$,onFailure:T,uiOptions:P}=s.signMessage,_={title:P.title||"Sign message",description:P.description||"Signing this message will not cost you any fees.",buttonText:P.buttonText||"Sign and continue"},k=e=>{e?$(e):T(f||new m.PrivyProviderRpcError(new m.ProviderRpcError("The user rejected the request.",m.E.E4001_USER_REJECTED_REQUEST.eipCode))),n({shouldCallAuthOnSuccess:!1}),setTimeout((()=>{x(null),y(""),v(void 0)}),200)};return c.current=()=>{k(w)},e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:()=>k(w)}),e.jsx(Xs,{}),P.iconUrl&&"string"==typeof P.iconUrl?e.jsx(kf,{children:e.jsx(Ef,{size:"sm",src:P.iconUrl,alt:"app image"})}):null,e.jsx(fd,{children:_.title}),e.jsx(md,{children:_.description}),"personal_sign"===S&&e.jsx($f,{children:bf(A)}),"eth_signTypedData_v4"===S&&e.jsx(jf,{typedData:A}),"solana_signMessage"===S&&e.jsx($f,{children:A}),e.jsx(Nf,{}),e.jsx(Pf,{$fail:!0,children:p}),e.jsx($o,{disabled:C||b||u,loading:C,onClick:async()=>{E(!0),y("");try{let e=await j();x(e),E(!1),setTimeout((()=>{k(e)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS)}catch(e){console.error(e),y("An error has occurred, please try again."),v(new m.PrivyProviderRpcError(new m.ProviderRpcError(p,m.E.E32603_DEFAULT_INTERNAL_ERROR.eipCode))),E(!1)}},children:C?"Signing...":b?e.jsxs(_f,{children:[e.jsx(fc,{style:{height:"0.9rem",width:"0.9rem"},strokeWidth:2})," ",e.jsx("span",{children:"Success"})]}):_.buttonText}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_SEND_TRANSACTION_SCREEN]:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:r,setModalData:n,navigate:a}=g.usePrivyModal(),{rpcConfig:s,chains:c,closePrivyModal:u,walletProxy:h}=o.usePrivyInternal(),{getAccessToken:p,user:y}=o.usePrivy(),f=l.useAppConfig(),[v,w]=i.useState(0),x=(e=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?0:e.sendTransaction.transactionRequests.length-1:0)(t),[C,E]=i.useState(((e,t)=>e?.sendTransaction?"transactionRequest"in e.sendTransaction?e.sendTransaction.transactionRequest:e.sendTransaction.transactionRequests[t]:void 0)(t,v)),[b,S]=i.useState(null),[A,j]=i.useState(),[$,T]=i.useState(!1),[P,_]=i.useState(null),[k,N]=i.useState(null);if(!C||!t?.sendTransaction||!t?.sendTransaction.transactingWallet)return e.jsx(pc,{error:Error("Invalid transaction request"),onClick:()=>{t?.sendTransaction?.onFailure(Cf),u({shouldCallAuthOnSuccess:!1})}});let I=t.sendTransaction.rootWallet,M=t.sendTransaction.transactingWallet,O=i.useMemo((()=>c.find((e=>Number(e.id)===Number(C.chainId)))),[C.chainId]),R=O?.nativeCurrency.symbol??"ETH",{action:F,amount:L,spender:U,isErc20Ish:D}=i.useMemo((()=>(e=>{let t=vf(e);if(t)return{action:"approve",isErc20Ish:!0,functionName:t.functionName,spender:t.args[0],amount:t.args[1]};let r=wf(e);return r?{action:"transfer",isErc20Ish:!0,functionName:r.functionName,amount:r.args[1]}:{action:"transaction",isErc20Ish:!1}})(C.data)),[C.data]);i.useEffect((()=>{C.to&&O&&D&&dh({address:C.to,chain:O,rpcConfig:f.rpcConfig,privyAppId:f.id}).then(S).catch(console.error)}),[C.to,O]);let{tokenPrice:W,isTokenPriceLoading:B}=Hc(C),H=i.useMemo((()=>d.getJsonRpcProvider(Number(C.chainId),c,s,{appId:f.id})),[C.chainId,s]),G=xf(C,M,H);i.useEffect((()=>{t.sendTransaction?.getIsSponsored?t.sendTransaction.getIsSponsored().then(j).catch(console.error):j(!1)}),[t.sendTransaction.getIsSponsored]);let q=()=>{if(!$)return P?t?.sendTransaction?.onSuccess(P.response):k||G?.errors[0]?t?.sendTransaction?.onFailure(k??G?.errors[0]??Cf):t?.sendTransaction?.onFailure(new m.PrivyProviderRpcError(new m.ProviderRpcError("The user rejected the request",m.E.E4001_USER_REJECTED_REQUEST.eipCode))),u({shouldCallAuthOnSuccess:!1})};r.current=q;let z=!!(f.fundingConfig&&f.fundingConfig.methods.length>0&&t.funding),V="fiat-currency"===f.embeddedWallets.priceDisplay.primary,K=d.i(G?.tx.value??0).add(d.i(G?.totalGasEstimate?.toBigInt()??0)).toHexString(),Y=d.getNativeCurrencyFromWei(K,R),Z=V&&W?d.getDollarsFromWei(K,W):void 0,X=d.getNativeCurrencyFromWei(G?.totalGasEstimate?.toString()??0,R),J=V&&W?d.getDollarsFromWei(G?.totalGasEstimate?.toString()??0,W):void 0,Q=d.getNativeCurrencyFromWei(G?.balance?.toString()??0,R,void 0,!0),ee=V&&W?d.getDollarsFromWei(G?.balance?.toString()??0,W):void 0,te=t.sendTransaction?.uiOptions?.transactionInfo?.title||("approve"===F?"Confirm address":`Approve ${F}`),re=t.sendTransaction?.uiOptions?.description||`${f.name} wants your permission to approve the following transaction.`,ne=t.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?e.jsx("img",{src:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,ie=!(!G||G.errors[0]||G.hasFunds||!1!==A),ae=ie&&z,oe=ae?"Add funds":t.sendTransaction?.uiOptions?.buttonText||(v<x?"Continue":"Approve");if(P?.receipt)return e.jsx(mf,{txn:G?.tx??C,onClose:q,receipt:P.receipt,transactionInfo:t.sendTransaction?.uiOptions.transactionInfo,tokenPrice:W,tokenSymbol:R,l1GasEstimate:G?.l1ExecutionFeeEstimate?.toString(),receiptHeader:t.sendTransaction?.uiOptions.successHeader,receiptDescription:t.sendTransaction?.uiOptions.successDescription});if(k)return e.jsx(Nm,{transactionError:k,network:"ethereum",chainId:G?.tx.chainId??C.chainId,onClose:q,onRetry:({resetNonce:e})=>{N(null);let t={...G?.tx??C};e&&(t.nonce=void 0),E(t)}});let se=0!==x&&"number"==typeof v&&0!==v?()=>{w(v-1)}:void 0;return e.jsx(bm,{transactionIndex:v,onBack:se,maxIndex:x,disabled:ie&&!z,isSubmitting:$,submitError:k,isPreparing:!G,isTokenPriceLoading:B,isTokenContractInfoLoading:!b,prepareError:G?.errors[0],symbol:b?.symbol,chain:O,img:ne,title:te,subtitle:re,spender:U,total:C.value?Z??Y:void 0,txValue:C.value,fee:J??X,isSponsored:A,to:C.to,network:f.chains.find((e=>e.id===C.chainId))?.name??"",from:M?.address??"",cta:oe,missingFunds:ie,action:F,balance:ee??Q,amount:L&&b?qc({amount:L,decimals:b.decimals}):L,onClose:q,onClick:ae?async()=>{if(!M)return;if(!z)throw Error("Funding wallet is not enabled");let e=pf({fundingMethods:f.fundingConfig.methods});n({...t,funding:{...t.funding,methodScreen:e}}),a(e)}:async()=>{if(v<x)w(v+1);else{T(!0);try{let e=await p();if($||!e||!M||!h||!y)return;let r=t?.sendTransaction?.onConfirm?await t.sendTransaction.onConfirm().then((e=>H.getTransaction(e))):await nf({accessToken:e,transactingWallet:M,rootWallet:I,walletProxy:h,transactionRequest:G?.tx??C,provider:H,requesterAppId:t.sendTransaction?.requesterAppId}),n=await r.wait();_({receipt:of(n),response:r})}catch(e){console.warn({transaction:G?.tx??C,error:e}),N(e)}finally{T(!1)}}}})},[g.ModalScreen.EMBEDDED_WALLET_SEND_SOLANA_TRANSACTION_SCREEN]:()=>{let{data:t,onUserCloseViaDialogOrKeybindRef:r}=g.usePrivyModal(),{closePrivyModal:n,walletProxy:a}=o.usePrivyInternal(),s=l.useAppConfig(),{user:d}=o.usePrivy(),[c,u]=i.useState(t?.sendSolanaTransaction?.transactionRequest),[h,p]=i.useState(),[y,m]=i.useState(),[f,v]=i.useState(0),[w,x]=i.useState(!1),[C,E]=i.useState(),[b,S]=i.useState(null),A=t?.sendSolanaTransaction?.connection,j=t?.sendSolanaTransaction?.transactingWallet,$=h?.instructions.at(f),T=h?.instructions.length??1;if(i.useEffect((()=>{!async function(){if(c&&A)try{m(void 0);let e=await vy(c,A);p(e),v(0)}catch(e){console.warn("Failed to prepare transaction",e),m(e)}}()}),[c,A]),!(c&&t?.sendSolanaTransaction&&j&&A)){let r=Error("Invalid transaction request");return e.jsx(pc,{error:r,onClick:()=>{t?.sendSolanaTransaction?.onFailure(r),n({shouldCallAuthOnSuccess:!1})}})}let{solPrice:P,isSolPriceLoading:_}=(()=>{let{showFiatPrices:e,getUsdPriceForSol:t}=o.usePrivyInternal(),[r,n]=i.useState(!0),[a,s]=i.useState(void 0),[l,d]=i.useState(void 0);return i.useEffect((()=>{(async()=>{if(e)try{n(!0);let e=await t();e?d(e):s(Error("Unable to fetch SOL price"))}catch(e){s(e)}finally{n(!1)}else n(!1)})()}),[]),{solPrice:l,isSolPriceLoading:r,solPriceError:a}})(),k=()=>{if(!w)return C?t?.sendSolanaTransaction?.onSuccess(C):(t?.sendSolanaTransaction?.onFailure(b??y??Error("User exited the modal before submitting the transaction")),v(0)),n({shouldCallAuthOnSuccess:!1})};r.current=k;let N="fiat-currency"===s.embeddedWallets.priceDisplay.primary,I=t.sendTransaction?.uiOptions?.transactionInfo?.title||("approve"===$?.action?"Confirm address":"Approve transaction"),M=t.sendTransaction?.uiOptions?.description||`${s.name} wants your permission to approve the following transaction.`,O=t.sendTransaction?.uiOptions?.transactionInfo?.contractInfo?.imgUrl?e.jsx("img",{src:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgUrl,alt:t.sendTransaction.uiOptions.transactionInfo.contractInfo.imgAltText}):null,R=$?.amount||0n,F=0===f&&h?.fees||0n,L=$?.balance||0n,U=$?.from,D=$?.to,W=R+F,B=uy(W),H=N&&P?hy(W,P):void 0,G=F?uy(F):void 0,q=N&&P?hy(F,P):void 0,z=L?uy(L):void 0,V=N&&P?hy(L,P):void 0,K=t.sendTransaction?.uiOptions?.buttonText||"Approve";return C?e.jsx(tf,{instructions:h?.instructions.map((({from:e,to:t,amount:r})=>({from:e.toBase58(),to:t.toBase58(),amount:r})))??[],fees:0===f?C.fees:0n,onClose:k,transactionInfo:t.sendTransaction?.uiOptions.transactionInfo,solPrice:P,receiptHeader:t.sendTransaction?.uiOptions.successHeader,receiptDescription:t.sendTransaction?.uiOptions.successDescription,rpcEndpoint:A.rpcEndpoint}):b?e.jsx(Nm,{transactionError:b,connection:A,onClose:k,network:"solana",onRetry:async()=>{S(null);let{blockhash:e}=await A.getLatestBlockhash();$e.isVersionedTransaction(c)?c.message.recentBlockhash=e:c.recentBlockhash=e,u(c)}}):e.jsx(bm,{isSubmitting:w,submitError:b,isPreparing:!h,isTokenPriceLoading:_,isTokenContractInfoLoading:!1,symbol:"SOL",chain:void 0,img:O,title:I,subtitle:M,from:U?.toBase58()||"",to:D?.toBase58(),fee:q??G,total:null!=R?H??B:void 0,txValue:R,spender:$?.spender?.toBase58(),network:"Solana",cta:K,missingFunds:!y&&!$?.hasFunds,action:$?.action,balance:V??z,prepareError:y,chainName:"Solana",onClose:k,onClick:async()=>{if(f<(h?.instructions.length??1)-1)v(f+1);else try{x(!0);let e=await Sg();if(w||!e||!j||!a||!d)return;let{signature:r,receipt:n}=await Cm({tx:c,accessToken:e,connection:A,walletProxy:a,transactingWalletAddress:j.address,transactionOptions:t.sendSolanaTransaction?.transactionOptions});E(gy(r,n))}catch(e){console.warn({transaction:c,error:e}),S(e)}finally{x(!1)}},isSponsored:!1,transactionIndex:f,maxIndex:T-1,disabled:!$?.hasFunds,onBack:f>0&&T>1?()=>v(f-1):void 0})},[g.ModalScreen.EMBEDDED_WALLET_DELEGATED_ACTIONS_CONSENT_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),{closePrivyModal:n}=o.usePrivyInternal(),[a,s]=i.useState(!1),[c,u]=i.useState(),h=async()=>{a?r?.delegatedActions?.onSuccess():r?.delegatedActions?.onError(c??new o.PrivyClientError("User declined delegating actions.")),n({shouldCallAuthOnSuccess:!1})};return i.useEffect((()=>{if(!a&&!c)return;let e=setTimeout(h,l.DEFAULT_SUCCESS_SCREEN_LONG_DURATION_MS);return()=>clearTimeout(e)}),[a,c]),a||c?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:h}),e.jsx(Xs,{}),e.jsxs(qs,{children:[c?e.jsx(T.ExclamationCircleIcon,{stroke:"var(--privy-color-error)",width:"64px",height:"64px"}):e.jsx(T.CheckCircleIcon,{stroke:"var(--privy-color-success)",width:"64px",height:"64px"}),e.jsx(el,{height:20}),e.jsx(il,{title:c?"Something went wrong":"Success!",description:c?"Please try again.":"You've successfully delegated actions."})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Wo,{closeable:!0,onClose:h}),e.jsx(Gl,{width:56,height:56,style:{margin:"auto"}}),e.jsx(Cs,{style:{marginTop:24},children:"Enable delegated actions"}),e.jsxs(Es,{children:["Give ",t.name," permissions to transact on your behalf. You can revoke this later."," ",e.jsx("a",{style:{color:"var(--privy-color-accent-dark)"},href:"https://www.privy.io/using-privy",target:"_blank",children:"Learn more"})]}),e.jsx(zl,{showIcon:!0,address:r?.delegatedActions?.address??"",title:"Wallet",isLoading:!1}),e.jsxs(ql,{style:{marginTop:24},children:[e.jsx(ko,{onClick:h,children:"No thanks"}),e.jsx(jo,{onClick:async()=>{try{await(r?.delegatedActions?.onDelegate()),s(!0)}catch(e){u(e)}},children:"Accept"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_METHOD_SELECTION_SCREEN]:()=>{let{wallets:r}=l.useWallets(),{navigate:n,data:a,setModalData:o}=g.usePrivyModal(),s=l.useAppConfig(),c=a?.funding,u=i.useRef(null),[h,p]=i.useState(!1);i.useEffect((()=>{u.current&&u.current.style.setProperty("--funding-input-length",Math.max(c.amount.length,1).toString())}),[c.amount,u.current]);let y=s.fundingConfig?.methods.slice()??[],{tokenPrice:m}=Hc({chainId:c.chain.id});i.useEffect((()=>{c.erc20Address&&c.chain&&!c.erc20ContractInfo&&dh({address:c.erc20Address,chain:c.chain,rpcConfig:s.rpcConfig,privyAppId:s.id}).then((e=>o({...a,funding:{...a.funding,erc20ContractInfo:e?{symbol:e.symbol,decimals:e.decimals}:void 0}}))).catch(console.error)}),[c.erc20Address,c.chain]);let f=m?d.getDollarsFromStringFloat(c.amount,m):void 0,v=r.find((e=>t.getAddress(e.address)===t.getAddress(c.address))),w=v&&"privy"!==v.walletClientType?Sl(v.walletClientType,v.connectorType,v.walletClientType):s.name,x=parseFloat(c.amount),C=!isNaN(x)&&x>0,E=!(!c.erc20Address||c.erc20ContractInfo),b=c.isUSDC?"USDC":c.erc20Address?void 0:"native-currency",S=b&&((e,t)=>{switch(t){case"native-currency":return hh.has(e);case"USDC":return ph.has(e);default:return console.warn("Unknown asset passed to MoonPay Onramp"),!1}})(Number(c.chain.id),b),A=b&&((e,t)=>{switch(t){case"native-currency":return Qu.has(e);case"USDC":return eh.has(e);default:return console.warn("Unknown asset passed to Coinbase Onramp"),!1}})(Number(c.chain.id),b),j=c.erc20Address||!c.erc20Address&&!c.isUSDC;return e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsxs("h3",{children:["Add funds to your"," ",w?.toLowerCase().endsWith("wallet")?w:w+" wallet"]}),e.jsx(Ks,{style:{marginTop:"32px"},children:e.jsx(Mu,{children:E?e.jsx(Lc,{size:"50px"}):e.jsxs(e.Fragment,{children:[e.jsxs(Ou,{onClick:()=>u.current?.focus(),children:[e.jsx(Fu,{ref:u,value:c.amount,onFocus:()=>p(!0),onBlur:()=>p(!1),onChange:e=>{let t=e.target.value;/^[0-9.]*$/.test(t)&&t.split(".").length-1<=1&&o({...a,funding:{...c,amount:t}})}}),e.jsx(Uu,{children:c.erc20Address?c.erc20ContractInfo?.symbol:c.chain.nativeCurrency.symbol}),!h&&e.jsx(Lu,{children:e.jsx(ft.default,{width:12,height:12})})]}),!c.erc20Address&&e.jsx(Du,{children:f&&C?f:""})]})})}),e.jsxs(Nu,{children:[c.errorMessage&&e.jsx(sh,{children:c.errorMessage}),y.sort().map((t=>{switch(t){case"moonpay":return S?e.jsxs(ts,{disabled:!C||E,onClick:()=>{n(g.ModalScreen.MOONPAY_PROMPT_SCREEN)},children:[e.jsx(Iu,{children:e.jsx(wh,{style:{width:24}})}),"Moonpay"]},t):null;case"coinbase-onramp":return A?e.jsxs(ts,{disabled:!C||E,onClick:()=>{n(g.ModalScreen.COINBASE_ONRAMP_STATUS_SCREEN)},children:[e.jsx(Iu,{children:e.jsx($a,{style:{width:24}})}),"Coinbase Onramp"]},t):null;case"external":return j?e.jsxs(ts,{disabled:!C||E,onClick:()=>{n(g.ModalScreen.FUNDING_TRANSFER_FROM_WALLET_SCREEN)},children:[e.jsx(Iu,{children:e.jsx(Ge.default,{style:{width:24}})}),"Transfer from wallet"]},t):null}})),e.jsx(Bu,{disabled:!C,onClick:()=>n(g.ModalScreen.FUNDING_MANUAL_TRANSFER_SCREEN),children:"Send funds manually"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.MOONPAY_PROMPT_SCREEN]:()=>{let{app:t,data:r,navigate:n,setModalData:a}=g.usePrivyModal(),{createAnalyticsEvent:s,getMoonpaySignedUrl:l}=o.usePrivyInternal(),[c,u]=i.useState(null),h=r?.funding,p=h.isUSDC?"USDC":"native-currency";return i.useEffect((()=>{!c&&h&&async function(){if(!t.fundingConfig)return;let{signedUrl:e,externalTransactionId:n}=await l(h.address,{...t.fundingMethodConfig.moonpay,...h.moonpayConfigOverride,currencyCode:h.moonpayConfigOverride?.currencyCode??yh(h.chain.id,p),quoteCurrencyAmount:h.moonpayConfigOverride?.quoteCurrencyAmount??mh(h.amount)});u(e),a({moonpayStatus:{externalTransactionId:n},funding:r?.funding})}()}),[c,h]),e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(Ph,{app:t,signedUrl:c,onContinue:()=>{s({eventName:"sdk_fiat_on_ramp_started",payload:{provider:uh}}),n(g.ModalScreen.MOONPAY_STATUS_SCREEN)}}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.MOONPAY_STATUS_SCREEN]:()=>{let{app:t,data:r}=g.usePrivyModal(),{closePrivyModal:n}=o.usePrivyInternal(),{externalTransactionId:i}=r?.moonpayStatus,a=vh(i||null,t.fundingMethodConfig.moonpay.useSandbox??!1);return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{title:"Fund account"},"header"),e.jsx(Dh,{status:a,onClickCta:n}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.COINBASE_ONRAMP_STATUS_SCREEN]:()=>{let{data:t,setModalData:r,navigate:n}=g.usePrivyModal(),{closePrivyModal:a,createAnalyticsEvent:s,initCoinbaseOnRamp:l,getCoinbaseOnRampStatus:c}=o.usePrivyInternal(),u=t?.funding,h=u.isUSDC?"USDC":"ETH",[p,y]=i.useState(!1),[m,f]=i.useState(!1);return i.useEffect((()=>{if(p)return;y(!0);let e=async()=>{try{s({eventName:"sdk_fiat_on_ramp_started",payload:{provider:"coinbase-onramp",value:u.amount,chainId:u.chain.id}});let e=window.open(void 0,void 0,Ju({w:440,h:680})),t=function(e){let t=th[e];if(!t)throw new o.PrivyClientError(`Unsupported chainId: ${e} for Coinbase Onramp`);return t}(u.chain.id),r=await l({addresses:[{address:u.address,blockchains:[t]}],assets:[h]}),{url:n}=(({input:e,amount:t,blockchain:r})=>{let n=new URL("https://pay.coinbase.com/buy/select-asset");return n.searchParams.set("appId",e.app_id),n.searchParams.set("sessionToken",e.session_token),n.searchParams.set("defaultExperience","buy"),n.searchParams.set("presetCryptoAmount",t.startsWith(".")?`0${t}`:t),n.searchParams.set("defaultNetwork",r),n.searchParams.set("partnerUserId",e.partner_user_id),{url:n}})({input:r,amount:u.amount,blockchain:t});if(!e)throw Error("Unable to initiate Coinbase Onramp flow.");e.location=n.toString();let i=0,a=!1;for(;i<rh;){i++;let{status:t}=await c({partnerUserId:r.partner_user_id});if("success"===t){a=!0;break}if("failure"===t)throw Error("There was an error completing Coinbase Onramp flow.");if(e.closed)throw Error("User exited Coinbase Onramp flow before transaction response.");await new Promise((e=>setTimeout(e,1500)))}if(!a)throw Error("Timed out waiting for transaction response from Coinbase Onramp.");f(!0)}catch(e){console.error(e),s({eventName:zc,payload:{status:"failure",provider:"coinbase-onramp",error:e.message}}),r({funding:{...u,errorMessage:"Something went wrong adding funds from Coinbase Onramp. Please try again or use another method to fund your wallet."}}),n(g.ModalScreen.FUNDING_METHOD_SELECTION_SCREEN)}finally{y(!1)}},t=setTimeout((()=>{e()}),500);return()=>clearTimeout(t)}),[]),e.jsxs(e.Fragment,{children:[e.jsx(Wo,{title:"Fund account"},"header"),e.jsx(nh,{isSucccess:m,onClickCta:a}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_TRANSFER_FROM_WALLET_SCREEN]:()=>{let{connectors:t}=o.usePrivyInternal(),{app:r,setModalData:n,data:a,navigate:s}=g.usePrivyModal(),[l,c]=i.useState("default"),u=Rl(r.appearance.walletList,"ethereum-only",t,!0,r.appearance.walletList,r.externalWallets.walletConnect.enabled),h=e.jsx(Vh,{text:"More wallets",onClick:()=>c("overflow")});return i.useEffect((()=>{n({...a,externalConnectWallet:{onCompleteNavigateTo:g.ModalScreen.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN}})}),[]),"overflow"===l?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>c("default")},"header"),e.jsxs(Xo,{children:[e.jsx(md,{style:{color:"var(--privy-color-foreground-3)",textAlign:"left"},children:"More wallets"}),u]}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(il,{title:"Transfer from wallet",description:"Connect a wallet to deposit funds or send funds manually to your wallet address."}),e.jsxs(Xo,{children:[...u.length>3?u.slice(0,2):u,u.length>3&&h,e.jsx(zh,{onClick:()=>s(g.ModalScreen.FUNDING_MANUAL_TRANSFER_SCREEN),children:"Send funds manually"})]}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_AWAITING_TRANSFER_FROM_EXTERNAL_WALLET_SCREEN]:()=>{let{rpcConfig:t,appId:r,closePrivyModal:n,createAnalyticsEvent:a}=o.usePrivyInternal(),{navigate:s,setModalData:c,app:u,data:h}=g.usePrivyModal(),{wallets:p}=l.useWallets(),[y,m]=i.useState(!1),[f,v]=i.useState(0n),[w,x]=i.useState(!1),[C,E]=i.useState(null),[b,S]=i.useState(null),[A,j]=i.useState([]),[$,T]=i.useState(0),[P,_]=i.useState(!1),[k,N]=i.useState(!1),[I,M]=i.useState(!1),[O,R]=i.useState(!1),{erc20ContractInfo:F,erc20Address:L,address:U,chain:D,amount:W}=h.funding;i.useEffect((()=>{L&&!F&&E(Error("Unable to fetch token details"))}),[]);let B=!!L&&!!F,H=B?BigInt(parseFloat(W)*10**F.decimals):Z.parseEther(W),G=p[0],[q,z]=i.useState(null);i.useEffect((()=>{(async()=>{if(!G)return;let e=await G.getEthereumProvider();z(Z.createWalletClient({account:G.address,transport:Z.custom(e)}).extend(Z.publicActions))})().catch(console.error)}),[G]);let[V,K]=i.useState(0n);i.useEffect((()=>{Z.createPublicClient({chain:D,transport:Z.http(d.getJsonRpcEndpointFromChain(D,t,r))}).getBalance({address:U}).then(K).catch(console.error)}),[]);let[Y,X]=i.useState(0n);i.useEffect((()=>{B&&(async({chain:e,address:t,appId:r,rpcConfig:n,erc20Address:i})=>{let a=Z.createPublicClient({chain:e,transport:Z.http(d.getJsonRpcEndpointFromChain(e,n,r))});return{balance:await a.readContract({address:i,abi:Xc,functionName:"balanceOf",args:[t]}).catch((()=>0n)),chain:e}})({chain:D,address:U,appId:r,rpcConfig:t,erc20Address:L}).then((e=>X(e.balance))).catch(console.error)}),[]);let{tokenPrice:J}=Hc({chainId:D.id}),[Q,ee]=i.useState({to:U,chain:D,value:H,data:void 0});i.useEffect((()=>{(async()=>{let e,n;if(!q||!G||P||I)return;_(!0);let i=Z.createPublicClient({chain:Q.chain,transport:Z.http(d.getJsonRpcEndpointFromChain(Q.chain,t,r))});if(B&&!Q.data)return await i.simulateContract({address:L,chain:Q.chain,abi:Gc,functionName:"transfer",args:[U,H],account:G.address}).catch((e=>{console.warn("Simulated token transfer failed with error, fetching bridge options.",e)}))?(_(!1),void ee({to:L,chain:Q.chain,data:Z.encodeFunctionData({abi:Gc,functionName:"transfer",args:[U,H]}),value:"0x0"})):(_(!1),void x(!0));try{e=await i.prepareTransactionRequest({account:G.address,to:Q.to,chain:Q.chain,data:Q.data,value:BigInt(Q.value??0)})}catch(e){console.error(e),A.length>1&&S(e.shortMessage??"Something went wrong")}if(!e)return _(!1),void x(!0);_(!1),M(!0),m(!0),v(e.gas);try{await q.switchChain({id:Q.chain.id})}catch(e){await q.addChain({chain:Q.chain}),await q.switchChain({id:Q.chain.id})}try{n=await q.sendTransaction(e),a({eventName:zc,payload:{provider:"external",status:"success",address:G.address,chainId:Q.chain.id,value:Q.value?.toString(),txHash:n}})}catch(e){console.error(e),"TransactionExecutionError"===e.name&&(A.length<1?E(new o.PrivyClientError(e.shortMessage,void 0,o.PrivyErrorCode.TRANSACTION_FAILURE)):S(e.shortMessage??"Something went wrong"))}n?(await q.waitForTransactionReceipt({hash:n}),M(!1),R(!0)):M(!1)})().catch(console.error)}),[q,Q]),i.useEffect((()=>{(async()=>{if(!w||!q||!G)return;let e=l.addToDefaultChains(u.chains).filter((e=>e.id!==h.funding.chain.id&&!!e.testnet==!!h.funding.chain.testnet));B&&e.unshift(h.funding.chain);let n=await(({chains:e,appId:t,address:r,rpcConfig:n})=>Promise.all(e.map((async e=>{let i=Z.createPublicClient({chain:e,transport:Z.http(d.getJsonRpcEndpointFromChain(e,n,t))});return{balance:await i.getBalance({address:r}).catch((()=>0n)),chain:e}}))))({chains:e,address:G.address,appId:r,rpcConfig:t}),i=B?n.filter((e=>e.balance>0n)):n.filter((e=>e.balance>H));if(i.length<1)return void E(new o.PrivyClientError(`Wallet ${d.formatWalletAddress(G.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE));i.sort(((e,t)=>Number(t.balance-e.balance)));let a=(await Promise.allSettled(i.map((async e=>({quote:await Yc({isTestnet:!!h.funding?.chain.testnet,input:Kc({amount:H.toString(),user:G.address,recipient:U,destinationChainId:D.id,destinationCurrency:L,originChainId:e.chain.id})}),...e}))))).filter((e=>"fulfilled"===e.status)).map((e=>e.value));if(a.length<1)return void E(new o.PrivyClientError(`Wallet ${d.formatWalletAddress(G.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE));let s=a.map((e=>({bridgeTx:Zc(e.quote),balance:e.balance,chain:e.chain}))).filter((e=>!!e.bridgeTx));if(s.length>1)return void j(s);let c=s[0];c?(N(!0),ee({data:c.bridgeTx.data,to:c.bridgeTx.to,value:c.bridgeTx.value,chain:c.chain})):E(new o.PrivyClientError(`Wallet ${d.formatWalletAddress(G.address)} does not have enough funds.`,void 0,o.PrivyErrorCode.INSUFFICIENT_BALANCE))})().catch(console.error)}),[w]),i.useEffect((()=>{if(!C)return;let e={error:C,previousScreen:g.ModalScreen.FUNDING_TRANSFER_FROM_WALLET_SCREEN};c({funding:h?.funding,sendTransaction:h?.sendTransaction,errorModalData:e}),s(g.ModalScreen.ERROR_SCREEN,!1)}),[C]);let te=G?Sl(G.walletClientType,G.connectorType,G.walletClientType)||"wallet":null,re=!B&&J?d.getDollarsFromStringFloat(h?.funding?.amount??"0",J):void 0,ne=B?f:d.sumWeiQuantitiesToHexString([f,H]),ie=ne&&J?d.getDollarsFromWei(ne,J):void 0,ae=ne?d.getNativeCurrencyFromWei(ne,"ETH"):void 0,oe=f&&J?d.getDollarsFromWei(f,J):void 0,se=f?d.getNativeCurrencyFromWei(f,"ETH"):void 0;if(i.useEffect((()=>{if(!O)return;let e=setTimeout(n,l.DEFAULT_SUCCESS_SCREEN_EXTRA_LONG_DURATION_MS);return()=>clearTimeout(e)}),[O]),O)return e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(Xs,{}),e.jsxs(Vs,{children:[e.jsx(ct.default,{color:"var(--privy-color-success)",width:"64px",height:"64px"}),e.jsx(il,{title:"Success!",description:`You’ve successfully added ${W} ${B?F.symbol:D.nativeCurrency.symbol} to your ${u.name} wallet. It may take a minute before the funds are available to use.`})]}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]});let le=B?`${qc({amount:Y,decimals:F.decimals})} ${F.symbol}`:d.getNativeCurrencyFromWei(V,D.nativeCurrency.symbol,3,!0),de=A[$];return A.length>1&&de?e.jsx(qu,{displayName:te,configuredFundingChain:D,formattedBalance:le,fundingAmount:W,fundingCurrency:B?F.symbol:D.nativeCurrency.symbol,fundingAmountInUsd:re,options:A,selectedOption:de,isPreparing:P,isSubmitting:I,errorMessage:b,onSubmit:()=>{ee({to:de.bridgeTx.to,data:de.bridgeTx.data,value:de.bridgeTx.value,chain:de.chain})},onSelect:e=>{e!==$&&(S(null),T(e))}}):y&&f&&G&&h?.funding?e.jsx(zu,{wallet:G,displayName:te,addressToFund:U,isBridging:k,isErc20Flow:B,totalPriceInUsd:ie,totalPriceInNativeCurrency:ae,gasPriceInUsd:oe,gasPriceInNativeCurrency:se,chain:h.funding.chain}):e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(Lc,{}),e.jsx("div",{style:{marginTop:"1rem"}}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.FUNDING_MANUAL_TRANSFER_SCREEN]:()=>{let{wallets:t}=l.useWallets(),{app:r,data:n,setModalData:a,navigate:s,lastScreen:c}=g.usePrivyModal(),{chains:u,rpcConfig:h,appId:p,closePrivyModal:y,createAnalyticsEvent:m}=o.usePrivyInternal(),[f,v]=i.useState("default"),[w,x]=i.useState(void 0),C=n?.funding,{tokenPrice:E}=Hc({chainId:C.chain.id}),b=parseFloat(C.amount),S=!isNaN(b)&&b>0,A=E?d.getDollarsFromStringFloat(C.amount,E):void 0,j=t.find((e=>d.formatWalletAddress(e.address)===d.formatWalletAddress(C.address))),$=j&&"privy"!==j.walletClientType?Sl(j.walletClientType,j.connectorType,j.walletClientType):r.name;if(!C)return a({errorModalData:{error:Error("Couldn't find funding config"),previousScreen:c||g.ModalScreen.FUNDING_METHOD_SELECTION_SCREEN},funding:n?.funding,sendTransaction:n?.sendTransaction}),s(g.ModalScreen.ERROR_SCREEN),e.jsx(e.Fragment,{});i.useEffect((()=>{let e=d.getJsonRpcProvider(C.chain.id,u,h,{appId:p});function t(){e.getBalance(C.address).then((e=>{let t=parseFloat(ie.formatUnits(e,"ether"));x((e=>(e&&t>e&&m({eventName:zc,payload:{provider:"manual",status:"success",address:j?.address,value:(t-e).toString()}}),t)))})).catch((()=>x(void 0)))}let r=setInterval(t,2e3);return t(),()=>clearInterval(r)}),[]);let T=i.useMemo((()=>void 0!==w&&w>=parseFloat(C.amount)),[w,C.amount]),P=e.jsxs(e.Fragment,{children:[e.jsx(d.WalletInfoCard,{title:"Your wallet",errMsg:void 0,isLoading:!C||void 0===w,isPulsing:!T,balance:`${void 0!==w?w.toPrecision(2):""} ETH`,address:C.address,statusColor:T?"green":"gray"}),T&&e.jsx(Gu,{onClick:()=>y(),children:"Close"})]});return"qr-code"===f?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:()=>v("default")}),e.jsxs(Ks,{style:{gap:"24px",marginBottom:"24px"},children:[e.jsxs("div",{children:[e.jsx(Cs,{children:"Scan QR code"}),e.jsxs(Es,{children:["Scan this code using your mobile wallet to send funds to your ",$," ","wallet."]})]}),e.jsx(Pc,{url:C.address,size:200,squareLogoElement:xh}),P]}),e.jsx(d.BlobbyFooter,{})]}):e.jsxs(e.Fragment,{children:[e.jsx(Fc,{}),e.jsx(il,{title:"Send funds",description:"Send funds directly to your wallet by copying your wallet address or scanning a QR code."}),e.jsxs(Ks,{style:{gap:"16px"},children:[e.jsxs(bh,{children:[e.jsx(gt.default,{height:"20px",width:"20px",color:"var(--privy-color-accent-light)"}),e.jsxs(Sh,{children:["Make sure to send on ",C.chain.name,"."]})]}),e.jsxs(Ah,{children:[e.jsx(el,{height:16}),e.jsxs(Mu,{children:[e.jsxs(Ou,{children:[e.jsx(Ru,{children:C.amount}),e.jsx(Uu,{children:C.erc20Address?C.erc20ContractInfo?.symbol:C.chain.nativeCurrency.symbol})]}),e.jsx(Du,{children:!C.erc20Address&&e.jsx(Du,{children:A&&S?A:"..."})}),e.jsxs(Wu,{children:[e.jsx(nu,{chainId:C.chain.id,height:16,width:16})," ",C.chain.name]})]}),e.jsx(el,{height:8}),e.jsxs(Eh,{children:[e.jsx(Ch,{text:C.address}),e.jsx($h,{onClick:()=>v("qr-code"),children:e.jsxs(jh,{children:[e.jsx(vt.default,{height:"16px",width:"16px"}),"Scan code"]})})]})]}),P]}),e.jsx(el,{height:16}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_UPDATE_SPLASH_SCREEN]:()=>{let{closePrivyModal:t}=o.usePrivyInternal(),{data:r,setModalData:n,navigate:i,onUserCloseViaDialogOrKeybindRef:a}=g.usePrivyModal(),{onSuccess:s,onFailure:l}=r.setWalletPassword,c=()=>{l(new o.PrivyEmbeddedWalletError("Exited before password was added to wallet")),t({shouldCallAuthOnSuccess:!1})};return a.current=c,e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:c}),e.jsx(Xs,{}),e.jsxs(Vs,{children:[e.jsxs(Qs,{children:[e.jsx(st.default,{stroke:"var(--privy-color-accent)",width:"64px",height:"64px"}),e.jsx(tl,{style:{width:24,height:24,position:"absolute",bottom:0,right:0},children:e.jsx(lt.default,{width:"12px",height:"12px",fill:"white"})})]}),e.jsxs(il,{title:"Secure Your Account",children:["Please set a password to secure your account.",e.jsx("p",{children:"Losing access to this password and this device will make your account inaccessible."})]})]}),e.jsx(jo,{onClick:()=>{n({createWallet:{onFailure:l,onSuccess:s,callAuthOnSuccessOnClose:!1,addPasswordToExistingWallet:!0}}),i(g.ModalScreen.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN)},children:"Add password"}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_UPDATE_SCREEN]:()=>{let[t,r]=i.useState(null),[n,a]=i.useState(!1),[s,l]=i.useState(null),[d,c]=i.useState(""),{authenticated:h,getAccessToken:p,user:y}=o.usePrivy(),{walletProxy:m,refreshUser:f,closePrivyModal:v,createAnalyticsEvent:w}=o.usePrivyInternal(),{app:x,navigate:C,data:E,onUserCloseViaDialogOrKeybindRef:b}=g.usePrivyModal(),{onSuccess:S,onFailure:A}=E.createWallet,j=u.getPrivyEthereumWallet(y),$="user-passcode"===t?.recoveryMethod,T="user-passcode"===j?.recoveryMethod;i.useEffect((()=>{h||(C(g.ModalScreen.LANDING),A(new o.PrivyUnauthenticatedError("User must be authenticated before setting a password on a Privy wallet")))}),[h]);let P=()=>s?(A(s),void v({shouldCallAuthOnSuccess:!1})):$?(S(t),void v({shouldCallAuthOnSuccess:!1})):(A(new o.PrivyEmbeddedWalletError("Exited before password was added to wallet")),void v({shouldCallAuthOnSuccess:!1}));b.current=P;return e.jsx(hc,{appName:x?.name||"privy",config:{initiatedBy:"user",onCancel:P},error:s?"An error has occurred, please try again.":void 0,buttonLoading:n,buttonHideAnimations:!1,password:d,isResettingPassword:T,onPasswordGenerate:()=>c(rc()),onPasswordChange:c,onSubmit:async()=>{$?(S(t),v({shouldCallAuthOnSuccess:!1})):(a(!0),l(null),await(async()=>{let e=await p();if(e&&j?.address&&d&&m)try{if(w({eventName:"embedded_wallet_set_recovery_started",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T}}),!(await m.setRecovery({accessToken:e,address:j.address,recoveryPassword:d,recoveryMethod:"user-passcode"})).address)return l(new o.PrivyEmbeddedWalletError("Error setting password on privy wallet")),void w({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T,reason:"error setting password"}});let t=await f(),n=u.getPrivyEthereumWallet(t);if(!n)return l(new o.PrivyEmbeddedWalletError("Error setting password on privy wallet")),void w({eventName:"embedded_wallet_set_recovery_failed",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T,reason:"wallet disconnected"}});r(n),w({eventName:"embedded_wallet_set_recovery_completed",payload:{walletAddress:j.address,existingRecoveryMethod:j.recoveryMethod,targetRecoveryMethod:"user-passcode",isResettingPassword:T}})}catch(e){console.warn(e),l(e instanceof Error?e:Error("Error setting password on privy wallet")),w({eventName:"embedded_wallet_set_password_failed",payload:{walletAddress:j.address,reason:e}})}})(),a(!1))},onClose:P})},[g.ModalScreen.EMBEDDED_WALLET_PASSWORD_CREATE_SCREEN]:()=>{let{app:t,navigate:r,data:n,onUserCloseViaDialogOrKeybindRef:a}=g.usePrivyModal(),[s,l]=i.useState(""),[d,c]=i.useState(!1),[u,h]=i.useState(),[p,y]=i.useState(null),{authenticated:m,user:f}=o.usePrivy(),{closePrivyModal:v,isNewUserThisSession:w,initializeWalletProxy:x}=o.usePrivyInternal(),{onSuccess:C,onFailure:E,callAuthOnSuccessOnClose:b}=n.createWallet,{createWallet:S}=Cd(),[A,j]=i.useState(null),$=new Gi((async()=>{try{let e=await S({recoveryPassword:u,user:f});if(!e)return;j(e),w?r(g.ModalScreen.EMBEDDED_WALLET_CREATED_SCREEN):(C(e),v({shouldCallAuthOnSuccess:b}))}catch(e){l(e.message)}}));i.useEffect((()=>{p||x(3e4).then((e=>y(e)))}),[p]),i.useEffect((()=>{if(!m||!f)return r(g.ModalScreen.LANDING),void E(Error("User must be authenticated before creating a Privy wallet"))}),[m]),a.current=()=>null;return e.jsx(hc,{config:{initiatedBy:"automatic"},appName:t?.name||"privy",loading:!p,buttonLoading:d,buttonHideAnimations:!A&&d,isResettingPassword:!1,error:s,password:u||"",onClose:()=>{A&&"user-passcode"!==A?.recoveryMethod?(E(new o.PrivyEmbeddedWalletError("User created a wallet but failed to set a password for it")),v({shouldCallAuthOnSuccess:!1})):A?(C(A),v({shouldCallAuthOnSuccess:b})):(E(new o.PrivyEmbeddedWalletError("User wallet creation failed")),v({shouldCallAuthOnSuccess:!1}))},onPasswordChange:h,onPasswordGenerate:()=>h(rc()),onSubmit:async()=>(c(!0),$.execute().then((()=>new Promise((e=>setTimeout(e,250))))).finally((()=>c(!1))))})},[g.ModalScreen.MFA_ENROLLMENT_FLOW_SCREEN]:()=>{let{user:t,enrollInMfa:r}=o.usePrivy(),[n,a]=i.useState(null),{unenrollWithSms:s,unenrollWithTotp:l,unenrollWithPasskey:c}=Fp(),{app:u,ready:h,data:p,onUserCloseViaDialogOrKeybindRef:y}=g.usePrivyModal(),{closePrivyModal:m}=o.usePrivyInternal(),{promptMfa:f}=Rp(),{initEnrollmentWithTotp:v}=Fp(),[w,x]=i.useState(!1),[C,E]=i.useState(null),[b,S]=i.useState(null),A=()=>{m({shouldCallAuthOnSuccess:!0}),r(!1),setTimeout((()=>{a(null),E(null)}),500)},{initEnrollmentWithPasskey:j,submitEnrollmentWithPasskey:$}=Fp(),[T,P]=i.useState(!1),[_,k]=i.useState(null);y.current=A;let N=t?.mfaMethods.includes("sms"),I=!!t?.phone,M=t?.mfaMethods.includes("totp"),O=t?.mfaMethods.includes("passkey"),R=N||M||O,F=t?.linkedAccounts.filter((e=>"passkey"===e.type)).map((e=>e.credentialId))??[];function L(){a(null),E(null)}if(i.useEffect((()=>{R&&x(!0)}),[R]),!h||!t||!u)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A},"header"),e.jsx(xs,{children:e.jsx(Lp,{})}),e.jsx(bs,{children:e.jsx(Co,{})}),e.jsx(d.ModalFooter,{})]});if("sms"===n)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:L,onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(bt.default,{})})}),e.jsx(Cs,{children:"Remove SMS verification?"}),e.jsxs(Es,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),e.jsx($s,{children:e.jsx(jo,{warn:!0,onClick:async function(){a(null);try{await s()}catch(e){a(null)}},children:"Remove SMS for MFA"})}),e.jsx(d.ModalFooter,{})]});if("totp"===n)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:L,onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(Ct.default,{})})}),e.jsx(Cs,{children:"Remove Authenticator App verification?"}),e.jsxs(Es,{children:["MFA adds an extra layer of security to your ",u?.name," account. Make sure you have other methods to secure your account."]}),e.jsx($s,{children:e.jsx(jo,{warn:!0,onClick:async function(){a(null);try{await l()}catch(e){a(null)}},children:"Remove Authenticator App for MFA"})}),e.jsx(d.ModalFooter,{})]});if("passkey"===n)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:L,onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(St.default,{})})}),e.jsx(Cs,{children:"Are you sure you want to remove passkey verification?"}),e.jsx(Es,{children:"This will disable any passkeys you have set up for verification. You’ll still be able to login with your passkeys if you’ve set up passkey login."}),e.jsx($s,{children:e.jsx(jo,{warn:!0,onClick:async function(){a(null);try{await f(),await c()}catch(e){a(null)}},children:"Yes, remove"})}),e.jsx(d.ModalFooter,{})]});if(0===p.mfaEnrollmentFlow.mfaMethods.length&&!R)return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(At.default,{})})}),e.jsx(Cs,{children:"Add more security"}),e.jsxs(Es,{children:[u?.name," does not have any verification methods enabled."]}),e.jsx($s,{children:e.jsx(jo,{onClick:A,children:"Close"})}),e.jsx(d.ModalFooter,{})]});let U=!R&&!w;return U?e.jsxs(e.Fragment,{children:[e.jsx(Wo,{onClose:A},"header"),e.jsx(xs,{children:e.jsx(Rs,{children:e.jsx(At.default,{})})}),e.jsx(Cs,{children:"Transaction Protection"}),e.jsx(Es,{children:"Set up transaction protection to add an extra layer of security to your account"}),e.jsxs(Ss,{children:[e.jsxs(js,{children:[e.jsx(As,{children:e.jsx(yt.default,{})}),"Enable 2-Step verification for your ",u?.name," wallet."]}),e.jsxs(js,{children:[e.jsx(As,{children:e.jsx(Et.default,{})}),"You'll be prompted to authenticate to complete transactions."]})]}),e.jsxs($s,{children:[e.jsx(jo,{onClick:()=>x(!0),children:"Continue"}),e.jsx(ko,{onClick:A,children:"Not now"})]}),e.jsx(d.ModalFooter,{})]}):"sms"===C?e.jsx(iy,{onComplete:A,onReset:L,onClose:A}):"totp"===C&&b?e.jsx(oy,{onComplete:A,onClose:A,onReset:L,totpInfo:b}):"passkey"===C?e.jsx(Wp,{onComplete:A,onReset:L,onClose:A}):e.jsx(Dp,{showIntro:U,userMfaMethods:t.mfaMethods,appMfaMethods:u.mfa.methods,userHasAuthSms:I,onBackToIntro:function(){x(!1)},handleSelectMethod:async function(e){return await f().catch(k),"totp"===e?(E(e),S(null),void v().then((e=>{S(e)})).catch((()=>{S(null),L()}))):"passkey"===e&&1===F.length?await async function(){P(!0);try{await j(),await $({credentialIds:F})}catch(e){k(e)}finally{P(!1)}}():void E(e)},isTotpLoading:"totp"===C&&!b,isPasskeyLoading:T,error:_,onClose:A,setRemovingMfaMethod:a})},[g.ModalScreen.CAPTCHA_SCREEN]:()=>{let{lastScreen:t,currentScreen:r,data:n,navigateBack:a,navigate:o,setModalData:s}=g.usePrivyModal(),{status:l,token:c,waitForResult:u,reset:h,execute:p}=ba(),y=i.useRef([]),m=e=>{y.current=[e,...y.current]},[f,v]=i.useState(!0);i.useEffect((()=>(m(setTimeout(v,1e3,!1)),()=>{y.current.forEach((e=>clearTimeout(e))),y.current=[]})),[]);let[w,x]=i.useState(""),[C,E]=i.useState("Checking that you are a human..."),[b,S]=i.useState(e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Continue"})),[A,j]=i.useState(!1),[$,T]=i.useState(3),P=n?.captchaModalData,_=async e=>{try{await(P?.callback(e)),P?.onSuccessNavigateTo&&o(P?.onSuccessNavigateTo,!1)}catch(e){if(e instanceof Ca)return;s({errorModalData:{error:e,previousScreen:t||g.ModalScreen.LANDING}}),o(P?.onErrorNavigateTo||g.ModalScreen.ERROR_SCREEN,!1)}};i.useEffect((()=>{"success"===l?m(setTimeout((async()=>{let e=await u();!e||P?.userIntentRequired||_(e)}),1e3)):"ready"===l&&m(setTimeout((()=>{"ready"===l&&p()}),500))}),[l]),i.useEffect((()=>{if(!f)switch(l){case"success":x("Success!"),E("CAPTCHA passed successfully."),S(e.jsx(jo,{onClick:()=>{j(!0),_(c)},disabled:!P?.userIntentRequired,loading:A,children:P?.userIntentRequired?"Continue":"Continuing..."}));break;case"loading":x(""),E("Checking that you are a human..."),S(e.jsx(jo,{onClick:()=>{},disabled:!0,children:"Continue"}));break;case"error":x("Something went wrong"),$<=0?(E("If you use an adblocker or VPN, try disabling and re-attempting."),S(null)):(E("You did not pass CAPTCHA. Please try again."),S(e.jsx(jo,{onClick:k,children:"Retry"})))}}),[l,f,A]);let k=async()=>{if($<=0)return;T((e=>e-1)),h(),p();let e=await u();!e||P?.userIntentRequired||_(e)};return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{backFn:t&&r!==t?a:void 0}),e.jsxs(Cl,{children:["success"===l?e.jsx(Ze.default,{fill:"var(--privy-color-success)",width:"64px",height:"64px"}):"error"===l?e.jsx(Xe.default,{fill:"var(--privy-color-error)",width:"64px",height:"64px"}):e.jsx(wl,{}),e.jsxs(Ys,{children:[w?e.jsx("h3",{children:w}):null,e.jsx("p",{children:C})]}),b]}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.ERROR_SCREEN]:()=>{let{navigate:t,navigateBack:r,data:n,lastScreen:i,currentScreen:a}=g.usePrivyModal(),o=n?.errorModalData?.previousScreen||(i===a?void 0:i);return e.jsx(pc,{error:n?.errorModalData?.error||Error(),backFn:()=>o?t(o,!1):r(),onClick:()=>t(o||g.ModalScreen.LANDING,!1)})},[g.ModalScreen.IN_APP_BROWSER_LOGIN_NOT_POSSIBLE]:()=>{let{closePrivyModal:t}=o.usePrivyInternal();return e.jsxs(e.Fragment,{children:[e.jsx(Wo,{},"header"),e.jsx(Kh,{children:e.jsx(qe.default,{style:{width:32,height:32}})}),e.jsx(nl,{title:"Could not log in with provider",description:"It looks like you're using an in-app browser. To log in, please try again using an external browser.",style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",textAlign:"center"}}),e.jsx(Hs,{children:e.jsx(jo,{onClick:()=>t(),children:"Close"})}),e.jsx(Js,{}),e.jsx(d.BlobbyFooter,{})]})},[g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN]:()=>{let{user:t,logout:r}=o.usePrivy(),{app:n,onUserCloseViaDialogOrKeybindRef:i,setModalData:a,navigate:s}=g.usePrivyModal(),{acceptTerms:l,closePrivyModal:d,createAnalyticsEvent:c}=o.usePrivyInternal(),h=e=>{e?.preventDefault(),d({shouldCallAuthOnSuccess:!1}),r()};i.current=h;return e.jsx(Ls,{termsAndConditionsUrl:n?.legal.termsAndConditionsUrl,privacyPolicyUrl:n?.legal.privacyPolicyUrl,onAccept:async e=>{e.preventDefault(),await l(),t&&u.shouldProceedtoEmbeddedWalletCreationFlow(t,n?.embeddedWallets?.createOnLogin)?(a({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),c({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,screen:"AffirmativeConsentScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),s(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)):d()},onDecline:h})},[g.ModalScreen.TELEGRAM_AUTH_SCREEN]:()=>{let{authenticated:t,logout:r,ready:n,user:a}=o.usePrivy(),{app:s,setModalData:c,navigate:h,resetNavigation:p,data:y}=g.usePrivyModal(),{initLoginWithTelegram:m,loginWithTelegram:f,updateWallets:v,setReadyToTrue:w,closePrivyModal:x,createAnalyticsEvent:C,getAuthMeta:E}=o.usePrivyInternal(),[b,S]=i.useState(!1),[A,j]=i.useState(void 0),$=ba();async function T(){try{let e=await async function(){let e;if($.enabled&&"error"===$.status)throw new Ca($.error,null,o.PrivyErrorCode.CAPTCHA_FAILURE);return $.enabled&&"success"!==$.status&&($.execute(),e=await $.waitForResult()),e}();await f(e),S(!0),w(!0)}catch(e){if(e?.privyErrorCode===o.PrivyErrorCode.ALLOWLIST_REJECTED)return j(void 0),p(),void h(g.ModalScreen.ALLOWLIST_REJECTION_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_LIMIT_REACHED)return console.error(new o.PrivyUserLimitReachedError(e).toString()),j(void 0),p(),void h(g.ModalScreen.USER_LIMIT_REACHED_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.USER_DOES_NOT_EXIST)return j(void 0),p(),void h(g.ModalScreen.ACCOUNT_NOT_FOUND_SCREEN);if(e?.privyErrorCode===o.PrivyErrorCode.ACCOUNT_TRANSFER_REQUIRED&&e.data?.data?.nonce)return j(void 0),p(),c({accountTransfer:{nonce:e.data?.data?.nonce,account:e.data?.data?.subject,telegramAuthResult:E()?.telegramAuthResult,displayName:e.data?.data?.account?.displayName,linkMethod:"telegram",embeddedWalletAddress:e.data?.data?.otherUser?.embeddedWalletAddress}}),void h(g.ModalScreen.LINK_CONFLICT_SCREEN);let{retryable:t,detail:r}=Aa(e);j({retryable:t,detail:r,message:"Authentication failed"})}}i.useEffect((()=>{T()}),[]),i.useEffect((()=>{if(!(n&&t&&b&&a))return;if(s?.legal.requireUsersAcceptTerms&&!a.hasAcceptedTerms){let e=setTimeout((()=>{h(g.ModalScreen.AFFIRMATIVE_CONSENT_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}if(u.shouldProceedtoEmbeddedWalletCreationFlow(a,s?.embeddedWallets?.createOnLogin)){let e=setTimeout((()=>{c({createWallet:{onSuccess:()=>{},onFailure:e=>{console.error(e),C({eventName:"embedded_wallet_creation_failure_logout",payload:{error:e,provider:"telegram",screen:"TelegramAuthScreen"}}),r()},callAuthOnSuccessOnClose:!0}}),h(g.ModalScreen.EMBEDDED_WALLET_ON_ACCOUNT_CREATE_SCREEN)}),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}v();let e=setTimeout((()=>x({shouldCallAuthOnSuccess:!0,isSuccess:!0})),l.DEFAULT_SUCCESS_SCREEN_DURATION_MS);return()=>clearTimeout(e)}),[n,t,b,a]);let P=b?"Successfully connected with Telegram":A?A.message:"Verifying connection to Telegram",_="";return _=b?"You’re good to go!":A?A.detail:"Just a few moments more",e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsx(Xs,{}),e.jsxs(If,{children:[e.jsx(Ko,{children:e.jsxs("div",{children:[e.jsx(xo,{success:b,fail:!!A}),e.jsx(Cp,{style:{width:"38px",height:"38px"}})]})}),e.jsxs(Ys,{children:[e.jsx("h3",{children:P}),e.jsx("p",{children:_})]}),A&&A?.retryable?e.jsx(Io,{onClick:async()=>{try{j(void 0),y?.telegramAuthModalData?.seamlessAuth||await m(void 0,y?.login?.disableSignup),await T()}catch(e){let{retryable:t,detail:r}=Aa(e);j({retryable:t,detail:r,message:"Authentication failed"})}},disabled:!b&&!A?.retryable,children:"Retry"}):null]}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},[g.ModalScreen.LINK_CONFLICT_SCREEN]:()=>{let{initiateAccountTransfer:t,closePrivyModal:r}=o.usePrivyInternal(),{data:n,navigate:a,lastScreen:s,setModalData:l}=g.usePrivyModal(),[d,c]=i.useState(void 0),[u,h]=i.useState(!1),[p,y]=i.useState(!1),m=async()=>{try{if(!n?.accountTransfer?.nonce||!n?.accountTransfer?.account)throw Error("missing account transfer inputs");y(!0),await t({nonce:n?.accountTransfer?.nonce,account:n?.accountTransfer?.account,accountType:n?.accountTransfer?.linkMethod,externalWalletMetadata:n?.accountTransfer?.externalWalletMetadata,telegramAuthResult:n?.accountTransfer?.telegramAuthResult,farcasterEmbeddedAddress:n?.accountTransfer?.farcasterEmbeddedAddress,oAuthUserInfo:n?.accountTransfer?.oAuthUserInfo}),h(!0),y(!1),setTimeout(r,1e3)}catch(e){l({errorModalData:{error:e,previousScreen:s||g.ModalScreen.LINK_CONFLICT_SCREEN}}),a(g.ModalScreen.ERROR_SCREEN,!0)}};return d?e.jsx(gs,{address:d,onClose:r,onRetry:()=>c(void 0),onTransfer:m,isTransferring:p,transferSuccess:u}):e.jsx(vs,{onClose:r,onInfo:()=>c(n?.accountTransfer?.embeddedWalletAddress),onContinue:()=>c(n?.accountTransfer?.embeddedWalletAddress),onTransfer:m,isTransferring:p,transferSuccess:u,data:n})}},Zf=[g.ModalScreen.LANDING,g.ModalScreen.AWAITING_CONNECTION],Xf=({isMfaVerifying:t,onMfaVerificationComplete:r})=>{let{ready:n,isModalOpen:a}=o.usePrivy(),{headless:s}=l.useAppConfig(),{ready:c,currentScreen:u}=g.usePrivyModal(),{status:h,execute:p,reset:y,enabled:m}=ba(),f=a&&u&&Zf.includes(u)&&!s&&"ready"===h;return i.useEffect((()=>{f&&p()}),[f]),i.useEffect((()=>{!a&&m&&y()}),[a,m]),n&&c||u===g.ModalScreen.AWAITING_OAUTH_SCREEN||u===g.ModalScreen.CROSS_APP_AUTH_SCREEN||u===g.ModalScreen.TELEGRAM_AUTH_SCREEN?!u&&t?e.jsx(rm,{open:t,onClose:r}):u?e.jsxs(e.Fragment,{children:[e.jsx(ns,{$if:!!t,children:e.jsx(Yf[u],{})}),e.jsx(ns,{$if:!t,children:e.jsx(rm,{open:t,onClose:r})})]}):null:e.jsxs(e.Fragment,{children:[e.jsx(Wo,{}),e.jsx(Xs,{}),e.jsx(Kf,{children:e.jsx(Co,{})}),e.jsx(Js,{}),e.jsx(d.ModalFooter,{})]})},Jf=({isMfaVerifying:t,onMfaVerificationComplete:r})=>{let n=i.useRef(null);return e.jsx(tg,{style:{height:d.useElementHeight(n)},id:"privy-modal-content",children:e.jsx("div",{ref:n,children:e.jsx(Xf,{isMfaVerifying:t,onMfaVerificationComplete:r})})})};const Qf=({open:t})=>{let{app:r}=g.usePrivyModal(),{gracefulClosePrivyModal:n}=(()=>{let{closePrivyModal:e}=o.usePrivyInternal(),{onUserCloseViaDialogOrKeybindRef:t}=g.usePrivyModal();return{gracefulClosePrivyModal:i.useCallback((()=>{if(!t?.current)return e({shouldCallAuthOnSuccess:!1});t.current()}),[e])}})(),[a,s]=i.useState(!1);wo({onMfaRequired:()=>{r?.mfa.noPromptOnMfaRequired||s(!0)}});let l=t||a;return r.render.standalone?e.jsx(Bf,{children:e.jsx(eg,{id:"privy-modal-content",children:e.jsx(Xf,{isMfaVerifying:a,onMfaVerificationComplete:()=>s(!1)})})}):e.jsx(Hf,{open:l,id:"privy-dialog","aria-label":"log in or sign up","aria-labelledby":"privy-dialog-title",onClick:()=>n(),children:e.jsx(Bf,{children:e.jsx(Jf,{isMfaVerifying:a,onMfaVerificationComplete:()=>s(!1)})})})};let eg=C.styled.div`
3096
3096
  display: flex;
3097
3097
  flex-direction: column;
3098
3098
  text-align: center;