import{o as e}from"./rolldown-runtime.js";import{n as t,t as n}from"./jsx-runtime.js";import{Mt as r,T as i,Vt as a,_ as o,c as s,nt as c}from"./useActiveWallet-CEs8euQ3.js";import{k as l}from"./context-Cdw68BC2.js";import{t as u}from"./index-CKYEOQWW.js";import{t as d}from"./modal-context-DHfp-mFQ.js";import{t as f}from"./mail.js";import{i as p,l as m}from"./ModalHeader-BS54PZSj.js";import{t as h}from"./ErrorMessage-D8VaAP5m.js";import{r as g,t as _}from"./EmailInputForm-Dgoii4vf.js";import{t as v}from"./Chip-D2-wZOHJ.js";var y=n(),b=e(t(),1),x=(0,b.forwardRef)(((e,t)=>{let[n,i]=(0,b.useState)(e.defaultValue||``),[o,g]=(0,b.useState)(``),[_,x]=(0,b.useState)(!1),{authenticated:T}=r(),{initLoginWithEmail:E}=a(),{navigate:D,setModalData:O,currentScreen:k,data:A}=d(),{enabled:j,token:M}=u(),[N,P]=(0,b.useState)(!1),{accountType:F}=s(),I=l(),L=c(n)&&(I.disablePlusEmails&&n.includes(`+`)?(o||g(`Please enter a valid email address without a '+'.`),!1):(o&&g(``),!0)),R=_||!L,z=()=>{var e;R||(O({login:A?.login,inlineError:void 0}),!j||M||T?(e=M,x(!0),E({email:n,captchaToken:e,disableSignup:A?.login?.disableSignup,withPrivyUi:!0}).then((()=>{D(`AwaitingPasswordlessCodeScreen`)})).catch((e=>{O({errorModalData:{error:e,previousScreen:k||`LandingScreen`}}),D(`ErrorScreen`)})).finally((()=>{x(!1)}))):(O({captchaModalData:{callback:e=>E({email:n,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:`AwaitingPasswordlessCodeScreen`,onErrorNavigateTo:`ErrorScreen`}}),D(`CaptchaScreen`)))};return(0,y.jsxs)(y.Fragment,{children:[(0,y.jsxs)(S,{children:[o&&(0,y.jsx)(h,{style:{display:`block`,marginTop:`0.25rem`,textAlign:`left`},children:o}),(0,y.jsxs)(C,{stacked:e.stacked,$error:!!o,children:[(0,y.jsx)(w,{children:(0,y.jsx)(f,{})}),(0,y.jsx)(`input`,{ref:t,id:`email-input`,className:`login-method-button`,type:`email`,placeholder:`your@email.com`,onFocus:()=>P(!0),onChange:e=>i(e.target.value),onKeyUp:e=>{e.key===`Enter`&&z()},value:n,autoComplete:`email`}),F!==`email`||N?e.stacked?(0,y.jsx)(`span`,{}):(0,y.jsx)(p,{isSubmitting:_,onClick:z,disabled:R,children:`Submit`}):(0,y.jsx)(v,{color:`gray`,children:`Recent`})]})]}),e.stacked?(0,y.jsx)(m,{loadingText:null,loading:_,disabled:R,onClick:z,style:{width:`100%`},children:`Submit`}):null]})})),S=g,C=_,w=i(o)`
  display: inline-flex;
`;export{x as t};