1import{c as k,u as N,a as S,r as n,s as l,j as e,H as w,b as C,d as g}from"./index-BMOVqzTo.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const A=k("MailCheck",[["path",{d:"M22 13V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v12c0 1.1.9 2 2 2h8",key:"12jkf8"}],["path",{d:"m22 7-8.97 5.7a1.94 1.94 0 0 1-2.06 0L2 7",key:"1ocrg3"}],["path",{d:"m16 19 2 2 4-4",key:"1b14m6"}]]),E=()=>{const m=N(),{toast:h}=S(),[o,p]=n.useState(""),[i,d]=n.useState(!1),[b,u]=n.useState(!1),[j,c]=n.useState(!0);n.useEffect(()=>{let t=!0;const r=setTimeout(()=>t&&c(!1),3e3),x=async s=>{if(!s){t&&c(!1);return}try{const{data:a}=await l.from("user_roles").select("role").eq("user_id",s).eq("role","admin").maybeSingle();if(!t)return;if(a){m("/admin",{replace:!0});return}}catch{}t&&c(!1)},{data:{subscription:v}}=l.auth.onAuthStateChange((s,a)=>{var f;return x(((f=a==null?void 0:a.user)==null?void 0:f.id)??null)});return l.auth.getSession().then(({data:{session:s}})=>{var a;return x(((a=s==null?void 0:s.user)==null?void 0:a.id)??null)}),()=>{t=!1,clearTimeout(r),v.unsubscribe()}},[m]);const y=async t=>{t.preventDefault(),d(!0);const{error:r}=await l.auth.signInWithOtp({email:o.trim(),options:{shouldCreateUser:!0,emailRedirectTo:`${window.location.origin}/admin`}});if(r){h({title:"Sign-in failed",description:r.message||"Please try again.",variant:"destructive"}),d(!1);return}u(!0),d(!1)};return e.jsxs(e.Fragment,{children:[e.jsxs(w,{children:[e.jsx("title",{children:"Admin Sign In | Zakov AI"}),e.jsx("meta",{name:"robots",content:"noindex,nofollow"})]}),e.jsx("div",{className:"min-h-screen bg-background flex items-center justify-center px-4",children:e.jsxs("div",{className:"w-full max-w-md glass-card p-8",children:[e.jsxs("div",{className:"flex items-center gap-3 mb-6",children:[e.jsx("div",{className:"w-10 h-10 rounded-lg bg-primary/10 border border-primary/30 flex items-center justify-center",children:e.jsx(C,{size:20,className:"text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-lg font-semibold text-foreground",children:"Admin Access"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Zakov AI Dashboard"})]})]}),j?e.jsx("div",{className:"py-8 flex justify-center",children:e.jsx(g,{size:24,className:"text-primary animate-spin"})}):b?e.jsxs("div",{className:"flex flex-col items-center gap-3 py-4 text-center",children:[e.jsx(A,{size:28,className:"text-primary"}),e.jsx("p",{className:"text-sm text-foreground font-medium",children:"Check your inbox"}),e.jsxs("p",{className:"text-xs text-muted-foreground leading-relaxed",children:["We sent a sign-in link to"," ",e.jsx("span",{className:"text-foreground font-medium",children:o}),". Open it on this device to access the dashboard."]}),e.jsx("button",{onClick:()=>u(!1),className:"text-xs text-muted-foreground underline hover:text-foreground transition",children:"Use a different email"})]}):e.jsxs(e.Fragment,{children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-6 leading-relaxed",children:["Enter your admin email and we'll send you a one-time sign-in link. Only"," ",e.jsx("span",{className:"text-foreground font-medium",children:"@zakov.ai"})," admins can sign in."]}),e.jsxs("form",{onSubmit:y,className:"space-y-3",children:[e.jsx("input",{type:"email",required:!0,autoFocus:!0,value:o,onChange:t=>p(t.target.value),placeholder:"[email protected]",disabled:i,className:"w-full rounded-lg bg-background border border-border px-4 py-3 text-sm text-foreground outline-none focus:border-primary/60 disabled:opacity-60","aria-label":"Admin email"}),e.jsxs("button",{type:"submit",disabled:i,className:"w-full inline-flex items-center justify-center gap-2 rounded-lg bg-foreground text-background px-4 py-3 text-sm font-semibold hover:opacity-90 transition disabled:opacity-60 disabled:cursor-not-allowed",children:[i&&e.jsx(g,{size:16,className:"animate-spin"}),i?"Sending link...":"Email me a sign-in link"]})]})]})]})})]})};export{E 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.