1import{j as e}from"./vendor-ui-x7D0iLe8.js";import{b as ee,m as se,s as p,l as te,g as re,B as x,u as a,r as T,n as ae,o as ie}from"./index-CgmaCIwJ.js";import{I as S}from"./input-DqgkKQ22.js";import{L as B}from"./label-iymYxFO8.js";import{r,j as oe,L as k}from"./vendor-react-aMKJrssV.js";import{l as $}from"./auth-validation-C4OKPjhp.js";import{l as ne}from"./index-CLypEEG9.js";import{m as le}from"./vendor-motion-C3azNPMs.js";import{L as g}from"./loader-circle-BqgSt_yg.js";import{M as ce}from"./mail-Du-dpIAW.js";import{E as de}from"./eye-off-BpEVz-5C.js";import{E as me}from"./eye-BYAvdeaG.js";import"./vendor-data-LOeL2b27.js";import"./vendor-forms-DefGbaKM.js";const y="eqiqs_last_email",Ee=()=>{const[t,D]=r.useState(()=>{try{return localStorage.getItem(y)||""}catch{return""}}),[b,V]=r.useState(""),[w,z]=r.useState(!1),[j,L]=r.useState(!1),[E,C]=r.useState(!1),[v,I]=r.useState(!1),[M,G]=r.useState(!1),[l,P]=r.useState(0),[f,H]=r.useState(""),[_,q]=r.useState(!1),[K,N]=r.useState(!1);r.useState("password");const{signIn:U,user:m}=ee(),d=oe(),W=new URLSearchParams(window.location.search).get("redirect"),u=se(W,"/getting-started");r.useEffect(()=>{m&&d(u,{replace:!0})},[m,d,u]),r.useEffect(()=>{const s=t?"password":"email";document.getElementById(s)?.focus()},[]),r.useEffect(()=>{if(l<=0)return;const s=setTimeout(()=>P(i=>i-1),1e3);return()=>clearTimeout(s)},[l]),r.useEffect(()=>{if(new URLSearchParams(window.location.hash.substring(1)).get("type")==="recovery"){d(`/reset-password${window.location.hash}`,{replace:!0});return}const{data:{subscription:i}}=p.auth.onAuthStateChange(o=>{o==="PASSWORD_RECOVERY"&&d("/reset-password",{replace:!0})});return()=>i.unsubscribe()},[d]),r.useEffect(()=>{if(m){const s=localStorage.getItem("eqiqs_pending_specialty");s&&p.from("profiles").update({specialty:s}).eq("user_id",m.id).then(()=>{localStorage.removeItem("eqiqs_pending_specialty")})}},[m]);const[n,O]=r.useState({}),[h,R]=r.useState(null),Y=async s=>{const i=s.split("@")[1];if(!i)return null;const{data:o}=await p.from("saml_configurations").select("domain, is_active").eq("domain",i).eq("is_active",!0).maybeSingle();return o?.domain||null},J=async()=>{C(!0);try{localStorage.setItem("eqiqs_oauth_redirect",u);const s={};if(t){const o=await Y(t);o&&(s.hd=o,s.login_hint=t)}const i=await ne.auth.signInWithOAuth("google",{redirect_uri:window.location.origin,...Object.keys(s).length>0?{extraParams:s}:{}});i.error&&a.error(i.error.message||"Failed to sign in with Google")}catch{a.error("Failed to sign in with Google")}finally{C(!1)}},F=async()=>{if(!t){a.error("Please enter your email address first");return}if(!$.shape.email.safeParse(t).success){a.error("Please enter a valid email address");return}I(!0);const{error:i}=await p.auth.signInWithOtp({email:t,options:{emailRedirectTo:window.location.origin+u}});if(I(!1),i)a.error(i.message);else{G(!0),P(30);try{localStorage.setItem(y,t)}catch{}a.success("Magic link sent! Check your email inbox.")}},X=async()=>{if(!t){a.error("Enter your email first");return}if(f.length!==6){a.error("Enter the 6-digit code from your email");return}q(!0);const{error:s}=await p.auth.verifyOtp({email:t,token:f,type:"email"});if(q(!1),s){a.error(s.message.includes("expired")||s.message.includes("invalid")?"That code is invalid or expired. Tap âSend Magic Linkâ again to get a new one.":s.message);return}a.success("Signed in!");try{localStorage.setItem(y,t)}catch{}},Z=async s=>{s.preventDefault(),O({}),R(null);const i=$.safeParse({email:t,password:b});if(!i.success){const c={};i.error.issues.forEach(A=>{const Q=A.path[0];c[Q]||(c[Q]=A.message)}),O(c),a.error(Object.values(c)[0]);return}L(!0);const{error:o}=await U(t,b);if(L(!1),o){const c=/invalid login credentials/i.test(o)?"Email or password is incorrect. Try again, send yourself a magic link, or reset your password.":o;R(c),a.error(c)}else{try{localStorage.setItem(y,t)}catch{}ae(),ie("email"),d(u)}};return e.jsxs("main",{id:"main-content",className:"min-h-dvh bg-background flex items-center justify-center px-6",children:[e.jsx(te,{title:"Log In â EQIQs Relationship Intelligence",description:"Log in to your EQIQs account to access compatibility scoring, relationship insights, and AI coaching.",path:"/login",
1noindex:!0}),e.jsx("a",{href:"#login-form",className:"sr-only focus:not-sr-only focus:absolute focus:top-4 focus:left-4 focus:z-50 focus:bg-primary focus:text-primary-foreground focus:px-4 focus:py-2 focus:rounded-lg",children:"Skip to login form"}),e.jsxs(le.div,{initial:{opacity:0,y:16},animate:{opacity:1,y:0},transition:{duration:.4},className:"w-full max-w-sm",children:[e.jsxs("div",{className:"text-center mb-6",children:[e.jsx(k,{to:"/",className:"inline-flex items-center gap-2 mb-4","aria-label":"EQIQs home",children:e.jsx("div",{className:"h-10 w-10 rounded-xl bg-primary/20 flex items-center justify-center",children:e.jsx(re,{className:"h-5 w-5 text-primary","aria-hidden":"true"})})}),e.jsx("h1",{className:"text-2xl font-bold mb-1",children:"Log in to EQIQs"}),e.jsx("p",{className:"text-sm text-muted-foreground font-body",children:"Resume your 21-framework personality analysis"})]}),e.jsx(k,{to:"/signup",className:"group block mb-4 rounded-xl border border-primary/30 bg-gradient-to-r from-primary/10 via-primary/5 to-accent/10 px-4 py-3 hover:border-primary/60 hover:from-primary/15 hover:to-accent/15 transition-all",children:e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-semibold text-foreground",children:"New to EQIQs?"}),e.jsx("p",{className:"text-xs text-muted-foreground font-body",children:"Free forever â no card required"})]}),e.jsx("span",{className:"text-xs font-semibold text-primary whitespace-nowrap group-hover:underline",children:"Start Free â"})]})}),e.jsx("div",{className:"flex items-center justify-center mb-2",children:e.jsx("span",{className:"inline-flex items-center gap-1.5 text-[11px] font-semibold uppercase tracking-wider text-primary bg-primary/10 px-2.5 py-1 rounded-full border border-primary/20",children:"â
Fastest · 1-click login"})}),e.jsxs(x,{type:"button",variant:"outline",className:"w-full min-h-[52px] text-base font-semibold gap-2.5 border-2 border-primary/30 bg-primary/[0.03] hover:border-primary/60 hover:bg-primary/10 transition-all shadow-sm ring-1 ring-primary/10",onClick:J,disabled:E,children:[E?e.jsx(g,{className:"h-5 w-5 animate-spin"}):e.jsxs("svg",{className:"h-5 w-5",viewBox:"0 0 24 24",children:[e.jsx("path",{d:"M22.56 12.25c0-.78-.07-1.53-.2-2.25H12v4.26h5.92a5.06 5.06 0 01-2.2 3.32v2.77h3.57c2.08-1.92 3.28-4.74 3.28-8.1z",fill:"#4285F4"}),e.jsx("path",{d:"M12 23c2.97 0 5.46-.98 7.28-2.66l-3.57-2.77c-.98.66-2.23 1.06-3.71 1.06-2.86 0-5.29-1.93-6.16-4.53H2.18v2.84C3.99 20.53 7.7 23 12 23z",fill:"#34A853"}),e.jsx("path",{d:"M5.84 14.09c-.22-.66-.35-1.36-.35-2.09s.13-1.43.35-2.09V7.07H2.18C1.43 8.55 1 10.22 1 12s.43 3.45 1.18 4.93l2.85-2.22.81-.62z",fill:"#FBBC05"}),e.jsx("path",{d:"M12 5.38c1.62 0 3.06.56 4.21 1.64l3.15-3.15C17.45 2.09 14.97 1 12 1 7.7 1 3.99 3.47 2.18 7.07l3.66 2.84c.87-2.6 3.3-4.53 6.16-4.53z",fill:"#EA4335"})]}),"Continue with Google"]}),e.jsxs(x,{type:"button",variant:"outline",className:"w-full min-h-[48px] text-sm font-medium gap-2 mt-2 hover:border-primary/40 hover:bg-primary/5 transition-all",onClick:F,disabled:v||l>0,children:[v?e.jsx(g,{className:"h-4 w-4 animate-spin"}):e.jsx(ce,{className:"h-4 w-4"}),l>0?`Resend in ${l}s`:M?"Resend Magic Link":"Send Magic Link (passwordless)"]}),M&&e.jsxs("div",{className:"rounded-lg border border-primary/30 bg-primary/5 px-4 py-3 text-sm text-foreground font-body mt-3 space-y-3",role:"status",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-semibold mb-1",children:"Magic link sent!"}),e.jsx("p",{className:"text-muted-foreground text-xs",children:"Tap the button in the email â or, if you opened the email on a different device, paste the 6-digit code below."})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(S,{id:"otp-code",type:"text",inputMode:"numeric",pattern:"[0-9]*",maxLength:6,placeholder:"123456",value:f,onChange:s=>H(s.target.value.replace(/\D/g,"").slice(0,6)),className:"min-h-[44px] text-base tracking-[0.4em] font-mono","aria-label":"6-digit login code"}),e.jsx(x,{type:"button",onClick:X,disabled:_||f.length!==6,className:"min-h-[44px] whitespace-nowrap",children:_?e.jsx(g,{className:"h-4 w-4 animate-spin"}):"Sign in"})]})]}),e.jsxs("div",{className:"relative flex items-center gap-3 my-5",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsx("span",{className:"text-xs text-muted-foreground font-body",children:"or use email & password"}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),h&&e.jsxs("div",{className:"rounded-lg border border-destructive/50 bg-destructive/10 px-4 py-3 text-sm text-destructive font-body mb-2 space-y-2",role:"alert",children:[e.jsx("p",{children:h}),/invalid login credentials/i.test(h)||/incorrect/i.test(h)?e.jsxs("div",{className:"flex flex-wrap gap-2 pt-1",children:[e.jsx("button",{type:"button",className:"text-xs font-semibold underline underline-offset-2 hover:opacity-80",onClick:async()=>
1{if(!t){a.error("Enter your email first");return}const{error:s}=await T(t,`${window.location.origin}/reset-password`);s?a.error(s):a.success("Password reset email sent â check your inbox.")},children:"Reset password"}),e.jsx("span",{className:"text-xs opacity-60",children:"·"}),e.jsx("button",{type:"button",className:"text-xs font-semibold underline underline-offset-2 hover:opacity-80",onClick:F,disabled:v||l>0,children:l>0?`Magic link in ${l}s`:"Send magic link instead"})]}):null]}),e.jsxs("form",{id:"login-form",onSubmit:Z,className:"space-y-4",noValidate:!0,children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(B,{htmlFor:"email",className:"font-body text-sm",children:"Email"}),e.jsx(S,{id:"email",type:"email",placeholder:"[email protected]",value:t,onChange:s=>D(s.target.value),required:!0,autoComplete:"email",className:`min-h-[48px] text-base ${n.email?"border-destructive":""}`,inputMode:"email","aria-invalid":!!n.email,"aria-describedby":n.email?"email-error":void 0}),n.email&&e.jsx("p",{id:"email-error",className:"text-xs text-destructive font-body",role:"alert",children:n.email})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsx(B,{htmlFor:"password",className:"font-body text-sm",children:"Password"}),e.jsx("button",{type:"button",className:"text-xs text-primary hover:underline font-body min-h-[44px] flex items-center",onClick:async()=>{if(!t){a.error("Enter your email first");return}const{error:s}=await T(t,`${window.location.origin}/reset-password`);s?a.error(s):a.success("Password reset email sent â check your inbox.")},children:"Forgot password?"})]}),e.jsxs("div",{className:"relative",children:[e.jsx(S,{id:"password",type:w?"text":"password",placeholder:"â¢â¢â¢â¢â¢â¢â¢â¢",value:b,onChange:s=>V(s.target.value),onKeyDown:s=>N(s.getModifierState&&s.getModifierState("CapsLock")),onKeyUp:s=>N(s.getModifierState&&s.getModifierState("CapsLock")),onBlur:()=>N(!1),required:!0,autoComplete:"current-password",className:`min-h-[48px] text-base pr-12 ${n.password?"border-destructive":""}`,"aria-invalid":!!n.password}),e.jsx("button",{type:"button",onClick:()=>z(s=>!s),className:"absolute right-3 top-1/2 -translate-y-1/2 text-muted-foreground hover:text-foreground transition-colors","aria-label":w?"Hide password":"Show password",children:w?e.jsx(de,{className:"h-5 w-5"}):e.jsx(me,{className:"h-5 w-5"})})]}),K&&e.jsx("p",{className:"text-xs text-accent font-body",role:"status",children:"⪠Caps Lock is on"}),n.password&&e.jsx("p",{className:"text-xs text-destructive font-body",role:"alert",children:n.password})]}),e.jsxs(x,{type:"submit",className:"w-full min-h-[52px] text-base font-semibold",disabled:j,children:[j&&e.jsx(g,{className:"h-4 w-4 animate-spin mr-2"}),j?"Logging inâ¦":"Log In"]})]}),e.jsxs("p",{className:"text-center text-sm text-muted-foreground font-body mt-6",children:["Don't have an account?"," ",e.jsx(k,{to:"/signup",className:"text-primary font-semibold hover:underline",children:"Sign up"})]})]})]})};export{Ee 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.