import{jsxs as e,Fragment as a,jsx as r}from"react/jsx-runtime";import{Mail as i}from"lucide-react";import{forwardRef as t,useState as o}from"react";import{styled as n}from"styled-components";import{u as l}from"./context-BKnOUECq.mjs";import{a as s}from"./index-C5jxD-zy.mjs";import{u as m}from"./internal-context-dfitw7Ot.mjs";import{u as c}from"./modal-context-DBwfUxD-.mjs";import{u as d}from"./privy-context-Bi6vqCPc.mjs";import{g as p,m as u}from"./useActiveWallet-BEfvREjE.mjs";import{v as g}from"./wallet-connect-58EobR5U.mjs";import{E as h,P as f}from"./ModalHeader-DffkxvO4.mjs";import{C as y}from"./Chip-D2-wZOHJ.mjs";import{I as v,a as S}from"./EmailInputForm-Dgoii4vf.mjs";import{E as b}from"./ErrorMessage-D8VaAP5m.mjs";const j=/*#__PURE__*/t(((t,n)=>{let[u,v]=o(t.defaultValue||""),[S,j]=o(""),[C,w]=o(!1),{authenticated:P}=d(),{initLoginWithEmail:T}=m(),{navigate:M,setModalData:A,currentScreen:D,data:I}=c(),{enabled:L,token:N}=s(),[U,F]=o(!1),{accountType:R}=p(),W=l(),q=g(u)&&(W.disablePlusEmails&&u.includes("+")?(S||j("Please enter a valid email address without a '+'."),!1):(S&&j(""),!0)),H=C||!q,K=()=>{var e;H||(A({login:I?.login,inlineError:void 0}),!L||N||P?(e=N,w(!0),T({email:u,captchaToken:e,disableSignup:I?.login?.disableSignup,withPrivyUi:!0}).then((()=>{M("AwaitingPasswordlessCodeScreen")})).catch((e=>{A({errorModalData:{error:e,previousScreen:D||"LandingScreen"}}),M("ErrorScreen")})).finally((()=>{w(!1)}))):(A({captchaModalData:{callback:e=>T({email:u,captchaToken:e,withPrivyUi:!0}),userIntentRequired:!1,onSuccessNavigateTo:"AwaitingPasswordlessCodeScreen",onErrorNavigateTo:"ErrorScreen"}}),M("CaptchaScreen")))};/*#__PURE__*/return e(a,{children:[/*#__PURE__*/e(k,{children:[S&&/*#__PURE__*/r(b,{style:{display:"block",marginTop:"0.25rem",textAlign:"left"},children:S}),/*#__PURE__*/e(E,{stacked:t.stacked,$error:!!S,children:[/*#__PURE__*/r(x,{children:/*#__PURE__*/r(i,{})}),/*#__PURE__*/r("input",{ref:n,id:"email-input",className:"login-method-button",type:"email",placeholder:"your@email.com",onFocus:()=>F(!0),onChange:e=>v(e.target.value),onKeyUp:e=>{"Enter"===e.key&&K()},value:u,autoComplete:"email"}),"email"!==R||U?t.stacked?/*#__PURE__*/r("span",{}):/*#__PURE__*/r(h,{isSubmitting:C,onClick:K,disabled:H,children:"Submit"}):/*#__PURE__*/r(y,{color:"gray",children:"Recent"})]})]}),t.stacked?/*#__PURE__*/r(f,{loadingText:null,loading:C,disabled:H,onClick:K,style:{width:"100%"},children:"Submit"}):null]})}));let k=v,E=S,x=n(u)`
  display: inline-flex;
`;export{j as C};
//# sourceMappingURL=ConnectEmailForm-C3yzMONB.mjs.map
