import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{Mt as r,Vt as i,j as a}from"./useActiveWallet-CEs8euQ3.js";import"./context-Cdw68BC2.js";import{t as o}from"./modal-context-DHfp-mFQ.js";import{t as s}from"./ScreenLayout-Dy-3vlz4.js";import{t as c}from"./PhoneIcon.js";import{t as l}from"./ConnectPhoneForm-6YkGGDnO.js";var u=n(),d=e(t(),1);a();var f=({title:e=`Update your phone number`,subtitle:t=`Add the phone number you'd like to use going forward. We'll send you a confirmation code`,onSubmit:n,isSubmitting:r=!1})=>{let[i,a]=(0,d.useState)(null);return(0,u.jsx)(s,{title:e,subtitle:t,icon:c,primaryCta:{label:r?`Submitting`:`Update`,onClick:async()=>{i?.qualifiedPhoneNumber&&await n(i)},disabled:!i?.isValid||r},watermark:!0,children:(0,u.jsx)(l,{onChange:e=>{a(e)},onSubmit:async()=>{},noIncludeSubmitButton:!0,hideRecent:!0})})},p={component:()=>{let{currentScreen:e,data:t,navigate:n,setModalData:a}=o(),{user:s}=r(),{initUpdatePhone:c}=i(),[l,p]=(0,d.useState)(!1);return(0,u.jsx)(f,{onSubmit:async r=>{p(!0);try{if(!s?.phone?.number)throw Error(`User is required to have an phone number to update it.`);await c(s?.phone?.number,r.qualifiedPhoneNumber),n(`AwaitingPasswordlessCodeScreen`)}catch(r){a({errorModalData:{error:r,previousScreen:t?.errorModalData?.previousScreen||e||`LinkPhoneScreen`}}),n(`ErrorScreen`)}finally{p(!1)}},isSubmitting:l})}};export{p as UpdatePhoneScreen,p as default,f as UpdatePhoneScreenView};