1import{r as u,j as e}from"./vendor-Dz9lJ0A9.js";import{u as ie,h as le,Q as de,az as ce,f as K,dC as ue,B as Y,E as $,P as I,L as R,A as q,af as me,aY as W,dX as Q,av as M,m as pe,K as F,aa as z,aU as ee,aW as b}from"./index-BDOD5E4V.js";import{u as J,F as V,a as h,b as x,c as f,d as w,e as y}from"./form-D1OIziNW.js";import{t as H}from"./zod-BzyEACVE.js";import{I as m}from"./input-uKcRzRZU.js";import{c as ge}from"./index-CEY-X8xw.js";import{a as he}from"./free-tool-import-CuW36tTK.js";import{m as j}from"./framer-motion-B-6Peltb.js";import{E as X}from"./eye-off-lB8x--i3.js";import"./label-xakz0IwZ.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};s.SENTRY_RELEASE={id:"8dd115ac638cf6a2a2cf5668d0686c96509328ed"};var i=new s.Error().stack;i&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[i]="5d209139-5847-4031-a439-1316a88a7f51",s._sentryDebugIdIdentifier="sentry-dbid-5d209139-5847-4031-a439-1316a88a7f51")}catch{}})();const xe=ee({email:b().email("Please enter a valid email"),password:b().min(1,"Password is required")}),fe=ee({firstName:b().min(1,"First name is required"),lastName:b().min(1,"Last name is required"),email:b().email("Please enter a valid email"),password:b().min(8,"Password must be at least 8 characters").regex(/[0-9!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?]/,"Include at least one number or special character")});async function Z(s,i){const p=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},credentials:"include",body:JSON.stringify(i)}),o=await p.json().catch(()=>({}));if(!p.ok)throw new W({status:p.status,body:o,message:typeof o.message=="string"?o.message:"Request failed",code:typeof o.code=="string"?o.code:void 0});return o}function Fe(){const[s,i]=ie(),{isAuthenticated:p,isLoading:o}=le(),{toast:l}=de(),g=new URLSearchParams(window.location.search),E=g.get("promo")||"",_=g.get("returnTo")||"/dashboard",d=_.startsWith("/")&&!_.startsWith("//")?_:"/dashboard",G=g.get("plan")||"trial",L=g.get("email")||"",te=L.length<=254&&/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(L)?L:"",[T]=u.useState(()=>he(g.get("from"))),S=g.get("error");u.useEffect(()=>{if(!S)return;const t={invalid_state:"Your Google sign-in session expired before it finished. Please try again.",not_configured:"Google sign-in is temporarily unavailable. Please sign in with your email and password.",token_failed:"We couldn't finish signing you in with Google. Please try again.",no_email:"Your Google account didn't share an email address, which we need to create your account.",signup_rate_limited:"Too many accounts were just created from this network. Please wait and try again.",google_failed:"Something went wrong signing in with Google. Please try again."};l({title:S==="signup_rate_limited"?"Could not create account":"Google sign-in didn't work",description:t[S]||t.google_failed,variant:"destructive"});const r=new URL(window.location.href);r.searchParams.delete("error"),window.history.replaceState({},"",r.pathname+r.search+r.hash)},[S,l]);const ae=s.startsWith("/signup")?"signup":s.startsWith("/forgot")?"forgot":"login",[a,N]=u.useState(ae),[n,D]=u.useState(!1),[se,A]=u.useState(!1),[U,B]=u.useState(!1),[O,re]=u.useState("");ce({title:a==="forgot"?"Reset Password | Colara":a==="signup"?"Create Account | Colara":"Log In | Colara",description:a==="signup"?"Create your free Colara account and start planning your wedding.":"Sign in to your Colara wedding planning account."});const v=J({resolver:H(xe),defaultValues:{email:"",password:""}}),c=J({resolver:H(fe),defaultValues:{firstName:T?.firstName??"",lastName:T?.lastName??"",email:te||T?.email||"",password:""}}),C=K({mutationFn:async t=>{const r=await Z("/api/auth/local-login",t);if(r.needsPassword)throw new W({status:200,message:"__NEEDS_PASSWORD__",code:"needs_password"});return r},onSuccess:async()=>{if(E)try{(await pe("POST","/api/promo/redeem",{code:E})).ok&&l({title:"Welcome back!",description:"Your promo code has been applied."})}catch{}await F.refetchQueries({queryKey:["/api/auth/user"]}),F.removeQueries({queryKey:["/api/user-role"]}),i(d)},onError:t=>{if(t instanceof W&&t.code==="needs_password"){l({title:"Check your email",description:"We've sent you a link to set your password. Please check your inbox."});return}Q(v,t)||l({title:"Login failed",description:M(t,"Please check your credentials and try again."),variant:"destructive"})}}),P=K({mutationFn:t=>Z("/api/auth/signup",{...t,promoCode:E||void 0}),onSuccess:async()=>{await F.refetchQueries({queryKey:["/api/auth/user"]}),F.removeQueries({queryKey:["/api/user-role"]}),z("conversion",{send_to:"AW-1020583874/hVFiCMyA8qgcEMK_0-YD",value:20,currency:"USD"}),z("qualify_lead",{method:"email",plan:G}),window.dataLayer=window.dataLayer||[],window.dataLayer.push({event:"trial_started",plan:G}),i(d.includes("?")?`${d}&signup=1`:`${d}?signup=1`)},onError:t=>{Q(c,t)||l({title:"Couldn't create account",description:M(t,"Please try again."),variant:"destructive"})}}),oe=async t=>{t.preventDefault(),B(!0);try{await fetch("/api/auth/forgot-password",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:O})}),A(!0)}catch(r){l({title:"Couldn't send reset email",description:M(r,"We couldn't reach the server. Please check your connection and try again."),variant:"destructive"})}finally{B(!1)}},ne=()=>{const t=d!=="/dashboard"?`?returnTo=${encodeURIComponent(d)}`:"";window.location.href=`/api/auth/google${t}`},k={hidden:{y:16,opacity:0}
1,visible:{y:0,opacity:1,transition:{duration:.5,ease:[.25,.1,.25,1]}}};return!o&&p&&!C.isSuccess&&!P.isSuccess?(window.location.href=d,null):e.jsx("div",{className:"min-h-screen bg-background flex flex-col items-center justify-center px-4 py-12",children:e.jsxs(j.div,{initial:"hidden",animate:"visible",variants:{hidden:{opacity:0},visible:{opacity:1,transition:{staggerChildren:.08}}},className:"w-full max-w-[420px]",children:[e.jsxs(j.div,{variants:k,className:"text-center mb-10",children:[e.jsx("img",{src:ue,alt:"Colara",className:"h-10 w-auto mx-auto mb-8 dark:invert object-contain","data-testid":"img-auth-logo"}),e.jsxs("h1",{className:"font-display text-3xl font-normal mb-2","data-testid":"text-auth-title",children:[a==="login"&&"Welcome back",a==="signup"&&"Create your account",a==="forgot"&&"Reset your password"]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[a==="login"&&"Sign in to your wedding planning dashboard.",a==="signup"&&"Free to start. No credit card required.",a==="forgot"&&"Enter your email and we'll send you a reset link."]})]}),(a==="login"||a==="signup")&&e.jsx(j.div,{variants:k,className:"mb-6 space-y-3",children:e.jsxs(Y,{variant:"outline",className:"w-full h-12 text-sm tracking-wide gap-3",onClick:ne,"data-testid":"button-google-login",children:[e.jsx(ge,{className:"w-4 h-4","aria-hidden":"true"}),a==="signup"?"Sign up with Google":"Continue with Google"]})}),(a==="login"||a==="signup")&&e.jsxs(j.div,{variants:k,className:"flex items-center gap-4 mb-6",children:[e.jsx("div",{className:"flex-1 h-px bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground tracking-wider uppercase",children:"or"}),e.jsx("div",{className:"flex-1 h-px bg-border"})]}),e.jsxs(j.div,{variants:k,children:[a==="login"&&e.jsx(V,{...v,children:e.jsxs("form",{onSubmit:v.handleSubmit(t=>C.mutate(t)),className:"space-y-4",children:[e.jsx(h,{control:v.control,name:"email",render:({field:t})=>e.jsxs(x,{children:[e.jsx(f,{className:"text-xs tracking-wide uppercase text-muted-foreground",children:"Email"}),e.jsx(w,{children:e.jsx(m,{type:"email",placeholder:"[email protected]",autoComplete:"email",className:"h-11","data-testid":"input-email",...t})}),e.jsx(y,{})]})}),e.jsx(h,{control:v.control,name:"password",render:({field:t})=>e.jsxs(x,{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx(f,{className:"text-xs tracking-wide uppercase text-muted-foreground",children:"Password"}),e.jsx("button",{type:"button",onClick:()=>{N("forgot"),A(!1)},className:"text-xs text-foreground font-medium hover:underline","data-testid":"link-forgot-password",children:"Forgot password?"})]}),e.jsx(w,{children:e.jsxs("div",{className:"relative",children:[e.jsx(m,{type:n?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",autoComplete:"current-password",className:"h-11 pr-10","data-testid":"input-password",...t}),e.jsx("button",{type:"button",onClick:()=>D(!n),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":n?"Hide password":"Show password",children:n?e.jsx(X,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"})})]})}),e.jsx(y,{})]})}),e.jsx(I,{size:"plain",type:"submit",className:"w-full h-11 tracking-wider uppercase text-[11px]",disabled:C.isPending,"data-testid":"button-login-submit",children:C.isPending?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:["Sign In ",e.jsx(q,{className:"ml-2 w-4 h-4"})]})}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground pt-1",children:["Don't have an account?"," ",e.jsx("button",{type:"button",onClick:()=>N("signup"),className:"text-foreground font-medium hover:underline","data-testid":"link-switch-to-signup",children:"Create one"})]})]})}),a==="signup"&&e.jsx(V,{...c,children:e.jsxs("form",{onSubmit:c.handleSubmit(t=>P.mutate(t)),className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[e.jsx(h,{control:c.control,name:"firstName",render:({field:t})=>e.jsxs(x,{children:[e.jsxs(f,{className:"text-xs tracking-wide uppercase text-muted-foreground",children:["First name ",e.jsx("span",{"aria-hidden":"true",children:"*"})]}),e.jsx(w,{children:e.jsx(m,{placeholder:"Jane",autoComplete:"given-name",className:"h-11","data-testid":"input-first-name",...t})}),e.jsx(y,{})]})}),e.jsx(h,{control:c.control,name:"lastName",render:({field:t})=>e.jsxs(x,{children:[e.jsxs(f,{className:"text-xs tracking-wide uppercase text-muted-foreground",children:["Last name ",e.jsx("span",{"aria-hidden":"true",children:"*"})]}),e.jsx(w,{children:e.jsx(m,{placeholder:"Smith",autoComplete:"family-name",className:"h-11","data-testid":"input-last-name",...t})}),e.jsx(y,{})]})})]}),e.jsx(h,{control:c.control,name:"email",render:({field:t})=>e.jsxs(x,{children:[e.jsx(f,{className:"text-xs tracking-wide uppercase text-muted-foreground",children:"Email"}),e.jsx(w,{children:e.jsx(m,{type:"email",placeholder:"[email protected]",autoComplete:"email",className:"h-11","data-testid":"input-signup-email",...t})}),e.jsx(y,{})]})}),e.jsx(h,{control:c.control,name:"password",render:({field:t})=>e.jsxs(x,{children:[e.jsx(f,{className:"text-xs tracking-wide uppercase text-muted-foreground",children:"Password"}),e.jsx(w,{children:e.jsxs("div",{className:"relative",children:[e.jsx(m,{type:n?"text":"password",placeholder:"8+ characters, with a number or symbol",autoComplete:"new-password",className:"h-11 pr-10","data-testid":"input-signup-password",...t}),e.jsx("button",{type:"button",onClick:()=>D(!n),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground",tabIndex:-1,"aria-label":n?"Hide password":"Show password",children:n?e.jsx(X,{className:"w-4 h-4"}):e.jsx($,{className:"w-4 h-4"})})]})}),e.jsx(y,{}),e.jsx("p",{className:"text-[11px] text-muted-foreground",children:"Must be 8+ characters and include a number or special character."})]})}),e.jsx(I,{size:"plain",type:"submit",className:"w-full h-11 tracking-wider up
1percase text-[11px]",disabled:P.isPending,"data-testid":"button-signup-submit",children:P.isPending?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:["Create Account ",e.jsx(q,{className:"ml-2 w-4 h-4"})]})}),e.jsxs("p",{className:"text-xs text-center text-muted-foreground pt-1",children:["Already have an account?"," ",e.jsx("button",{type:"button",onClick:()=>N("login"),className:"text-foreground font-medium hover:underline","data-testid":"link-switch-to-login",children:"Sign in"})]})]})}),a==="forgot"&&(se?e.jsxs("div",{className:"text-center space-y-4",children:[e.jsx("div",{className:"w-12 h-12 rounded-full bg-[#8B6F5C]/10 dark:bg-[#A8836F]/15 flex items-center justify-center mx-auto",children:e.jsx(me,{className:"w-5 h-5 text-[#6F5440] dark:text-[#A8836F]"})}),e.jsx("p",{className:"text-sm text-muted-foreground leading-relaxed",children:"If an account with that email exists, we've sent a password reset link. Check your inbox (and spam folder)."}),e.jsx(Y,{variant:"outline",className:"tracking-wider uppercase text-xs",onClick:()=>{N("login"),A(!1)},"data-testid":"button-back-to-login",children:"Back to Sign In"})]}):e.jsxs("form",{onSubmit:oe,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"forgot-email",className:"text-xs tracking-wide uppercase text-muted-foreground block mb-1.5",children:"Email"}),e.jsx(m,{id:"forgot-email",type:"email",value:O,onChange:t=>re(t.target.value),placeholder:"[email protected]",required:!0,className:"h-11","data-testid":"input-forgot-email"})]}),e.jsx(I,{size:"plain",type:"submit",className:"w-full h-11 tracking-wider uppercase text-[11px]",disabled:U,"data-testid":"button-forgot-submit",children:U?e.jsx(R,{className:"w-4 h-4 animate-spin"}):e.jsxs(e.Fragment,{children:["Send Reset Link ",e.jsx(q,{className:"ml-2 w-4 h-4"})]})}),e.jsx("div",{className:"text-center",children:e.jsx("button",{type:"button",onClick:()=>N("login"),className:"text-xs text-muted-foreground hover:text-foreground transition-colors","data-testid":"link-back-to-login",children:"Back to sign in"})})]}))]}),a!=="forgot"&&e.jsx(j.div,{variants:k,className:"mt-10 text-center",children:e.jsxs("p",{className:"text-[11px] text-muted-foreground",children:["By continuing, you agree to our"," ",e.jsx("a",{href:"/terms",className:"underline hover:text-foreground",children:"Terms of Service"})," ","and"," ",e.jsx("a",{href:"/privacy",className:"underline hover:text-foreground",children:"Privacy Policy"}),"."]})})]})})}export{Fe as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.