
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},n=(new Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f5f3a762-ba5b-5bf8-abb8-4da5757eb7cc")}catch(e){}}();
import{j as e}from"./jsx-runtime-BjG_zV1W.js";import{r as f}from"./index-D6da9p6-.js";import{T as a}from"./index-BdpAPpdN.js";import{u as h}from"./useIsLoggedIn-BdeVQWXr.js";import{u as j}from"./useToast-DK42uF07.js";import{B as b}from"./index-pXcQb956.js";import{I as u}from"./Input-snMSpc3o.js";import{S as _}from"./StatusInputs-JkVhk_jg.js";import{u as x}from"./useTranslation-CfKJAmGY.js";import{R as y}from"./RedirectToHiddenInput-mUb4yii7.js";import{c as w,L as N}from"./components-PKPTORWS.js";const p=({emailFieldName:n="email",emailFieldType:i="email",isSubmitting:r=!1})=>{const[l,c]=f.useState(!0),{t:s}=x(),t=e.jsx("button",{type:"button",onClick:()=>c(!l),children:e.jsx(a,{as:"span",size:"xs",type:"body",weight:"bold",theme:"default",children:s(l?"login.login_with_password_label":"login.login_with_email_label")})});return e.jsxs("div",{className:"flex w-full flex-col space-y-2 sm:space-y-6",children:[e.jsx(_,{name:"login",errorMessage:`${s("errors.default")} ${s("errors.try_later")}`,successMessage:s(l?"toast.login_link.message":"login.success.message")}),e.jsx("input",{type:"hidden",name:"request_magic_link",value:l?"true":"false"}),e.jsxs("div",{className:"flex w-full flex-col gap-y-6 text-left",children:[e.jsxs("div",{className:"flex flex-col gap-y-1",children:[e.jsx(u,{name:n,type:i,required:!0,placeholder:s("login.email_placeholder"),autoComplete:"email",label:s("login.email_label")}),l?e.jsx("div",{className:"flex w-full justify-end",children:t}):null]}),l?null:e.jsxs("div",{className:"flex w-full flex-col gap-y-1",children:[e.jsx(u,{name:"password",type:"password",placeholder:s("login.password_placeholder"),label:s("login.password_label"),required:!l}),e.jsxs("div",{className:"flex w-full flex-col items-end gap-y-1 sm:flex-row-reverse sm:items-center sm:justify-between",children:[l?null:t,e.jsx(a,{as:"p",size:"xs",type:"body",theme:"default",className:"",children:e.jsx("a",{href:"/reset_password",className:"underline",children:e.jsx(a,{as:"span",size:"xs",type:"body",weight:"bold",theme:"default",children:s("login.set_new_password")})})})]})]})]}),e.jsx(b,{disabled:r,type:"submit",children:s(l?"login.send_magic_link_button_label":"login.login_button_label")})]})},E=({onSuccess:n,bypassSparkLoopMode:i=!1})=>{const r=h(),l=w(),c=l.data,s=l.state==="submitting",{t}=x();if(f.useEffect(()=>{localStorage.removeItem("signup_redirects")},[]),j(c?.toast,n),r)return null;const g=o=>{o.preventDefault();const m=new FormData(o.currentTarget),d=m.get("login_email");i&&d&&m.append("email",d),l.submit(m,{method:"post",action:"/login"})};return e.jsx(e.Fragment,{children:e.jsxs(l.Form,{method:"post",action:"/login",className:"w-full",onSubmit:o=>g(o),children:[e.jsx(y,{redirectToHome:!0}),e.jsx("div",{className:"flex w-full flex-col space-y-2 sm:space-y-6",children:i?e.jsx(p,{emailFieldName:"login_email",emailFieldType:"text",isSubmitting:s}):e.jsxs(e.Fragment,{children:[e.jsx(p,{isSubmitting:s}),e.jsx("div",{className:"flex flex-col",children:e.jsxs(a,{as:"p",size:"xs",type:"body",theme:"default",children:[t("login.sign_up_label")," ",e.jsx(N,{to:"/subscribe",className:"underline",children:e.jsx(a,{as:"span",size:"xs",type:"body",weight:"bold",theme:"default",children:t("shared.cta.sign_up")})})]})})]})})]})})};export{E as L};
//# sourceMappingURL=LoginWithPasswordAction-M6Cib05n.js.map

//# debugId=f5f3a762-ba5b-5bf8-abb8-4da5757eb7cc
