import{r as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{St as r,T as i,_t as a,bt as o,j as s,xt as c}from"./useActiveWallet-CEs8euQ3.js";import{k as l}from"./context-Cdw68BC2.js";import{O as u,t as d}from"./index-CKYEOQWW.js";import{t as f}from"./modal-context-DHfp-mFQ.js";import{t as p}from"./createLucideIcon.js";import{t as m}from"./lock.js";import{t as h}from"./triangle-alert.js";import{t as g}from"./ScreenLayout-Dy-3vlz4.js";import{t as _}from"./safe-url-D7SRPu33.js";import{i as v}from"./reservoir-B7XIq5qj.js";var y=p(`phone`,[[`path`,{d:`M13.832 16.568a1 1 0 0 0 1.213-.303l.355-.465A2 2 0 0 1 17 15h3a2 2 0 0 1 2 2v3a2 2 0 0 1-2 2A18 18 0 0 1 2 4a2 2 0 0 1 2-2h3a2 2 0 0 1 2 2v3a2 2 0 0 1-.8 1.6l-.468.351a1 1 0 0 0-.292 1.233 14 14 0 0 0 6.392 6.384`,key:`9njp5v`}]]),b=e({ErrorScreen:()=>C,ErrorScreenView:()=>S,default:()=>C}),x=n();t(),s();var S=({error:e,allowlistConfig:t,onRetry:n,onCaptchaReset:i,onBack:s})=>{let l=((e,t)=>{if(e instanceof v)return{title:`Transaction failed`,detail:(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`span`,{children:e.message}),(0,x.jsxs)(`span`,{children:[` `,`Check the`,` `,(0,x.jsx)(w,{href:e.relayLink,target:`_blank`,children:`refund status`}),`.`]})]}),ctaText:`Try again`,icon:h};if(e instanceof c)switch(e.privyErrorCode){case a.CLIENT_REQUEST_TIMEOUT:return{title:`Timed out`,detail:e.message,ctaText:`Try again`,icon:h};case a.INSUFFICIENT_BALANCE:return{title:`Insufficient balance`,detail:e.message,ctaText:`Try again`,icon:h};case a.TRANSACTION_FAILURE:return{title:`Transaction failure`,detail:e.message,ctaText:`Try again`,icon:h};default:return{title:`Something went wrong`,detail:`Try again later`,ctaText:`Try again`,icon:h}}else{if(e instanceof u&&e.type===`twilio_verification_failed`)return{title:`Something went wrong`,detail:e.message,ctaText:`Try again`,icon:y};if(!(e instanceof r))return e instanceof o&&e.status&&[400,422].includes(e.status)?{title:`Something went wrong`,detail:e.message,ctaText:`Try again`,icon:h}:{title:`Something went wrong`,detail:`Try again later`,ctaText:`Try again`,icon:h};switch(e.privyErrorCode){case a.INVALID_CAPTCHA:return{title:`Something went wrong`,detail:`Please try again.`,ctaText:`Try again`,icon:h};case a.DISALLOWED_LOGIN_METHOD:return{title:`Not allowed`,detail:e.message,ctaText:`Try another method`,icon:h};case a.ALLOWLIST_REJECTED:return{title:t.errorTitle||`You don't have access to this app`,detail:t.errorDetail||`Have you been invited?`,ctaText:t.errorCtaText||`Try another account`,icon:m};case a.CAPTCHA_FAILURE:return{title:`Something went wrong`,detail:`You did not pass CAPTCHA. Please try again.`,ctaText:`Try again`,icon:null};case a.CAPTCHA_TIMEOUT:return{title:`Something went wrong`,detail:`Something went wrong! Please try again later.`,ctaText:`Try again`,icon:null};case a.LINKED_TO_ANOTHER_USER:return{title:`Authentication failed`,detail:`This account has already been linked to another user.`,ctaText:`Try again`,icon:h};case a.NOT_SUPPORTED:return{title:`This region is not supported`,detail:`SMS authentication from this region is not available`,ctaText:`Try another method`,icon:h};case a.TOO_MANY_REQUESTS:return{title:`Request failed`,detail:`Too many attempts.`,ctaText:`Try again later`,icon:h};default:return{title:`Something went wrong`,detail:`Try again later`,ctaText:`Try again`,icon:h}}}})(e,t);return(0,x.jsx)(g,{title:l.title,subtitle:l.detail,icon:l.icon,onBack:s,iconVariant:`error`,primaryCta:{label:l.ctaText,onClick:()=>{if(e instanceof r&&(e.privyErrorCode===a.INVALID_CAPTCHA&&i?.(),e.privyErrorCode===a.ALLOWLIST_REJECTED)){let e=_(t.errorCtaLink);if(e)return void window.open(e,`_blank`,`noopener,noreferrer`)}n?.()},variant:`error`},watermark:!0})},C={component:()=>{let{navigate:e,data:t,lastScreen:n,currentScreen:r}=f(),i=l(),{reset:a}=d(),o=t?.errorModalData?.previousScreen||(n===r?void 0:n);return(0,x.jsx)(S,{error:t?.errorModalData?.error||Error(),allowlistConfig:i.allowlistConfig,onRetry:()=>{e(o||`LandingScreen`,!1)},onCaptchaReset:a})}},w=i.a`
  color: var(--privy-color-accent) !important;
  font-weight: 600;
`;export{S as n,b as t};