1import{u as h,e as s,aT as y,t as o,j as t}from"./vendor-NGvcDSyr.js";import{fJ as j,fK as L,fL as R,fM as d,fN as A,a9 as u,fO as S,bo as v,fP as N,a4 as B,a5 as I,B as F}from"./shared-CPB1NCFY.js";function M(){const e=h({mutationFn:j,meta:{global:!1},onSuccess:async(a,r)=>{await L(),R(r.email),d(a.ok)}});return{login:e.mutate,isLoggingIn:e.isPending}}function w(e){s.useEffect(()=>{let a=!1;async function r(){if(await y())try{const n=await A({useBrowserAutofill:!0});d(n)}catch(n){!a&&n instanceof u&&e(S(n))}}return r(),()=>{a=!0}},[e])}const c="Temporary error. Try again later.",O="Email is required.",_="Enter a valid email address.";function C(e){return e instanceof u&&Array.isArray(e.body?.email)}function m(e){if(e instanceof u){const a=e.body;return a?.email?.[0]??a?.error??c}return c}function f(e){return e===""?O:v(e)?void 0:_}function T(){const[e,a]=s.useState(""),[r,n]=s.useState(null),{login:g,isLoggingIn:x}=M();w(o.error);const E=!!f(e);s.useEffect(()=>{document.title="Screenly | Sign in"},[]);function p(){n(f(e)??null)}function b(i){i.preventDefault(),n(null),g({email:e},{onError:l=>{if(C(l)){n(m(l));return}o.error(m(l))}})}return t.jsxs(t.Fragment,{children:[t.jsx("h1",{className:"mb-6 text-center text-2xl text-(--text-neutral-default)",children:"Sign in to Screenly"}),t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(N,{onError:o.error}),t.jsxs("div",{className:"flex items-center gap-2 py-1 text-xs text-(--text-neutral-subtle)",children:[t.jsx("span",{className:"h-px flex-1 bg-(--border-neutral-default)"})," or ",t.jsx("span",{className:"h-px flex-1 bg-(--border-neutral-default)"})]}),t.jsxs("form",{onSubmit:b,className:"flex flex-col gap-4",children:[t.jsxs("div",{className:"flex flex-col gap-2",children:[t.jsx(B,{htmlFor:"username",children:"Email"}),t.jsx(I,{id:"username",name:"username","data-testid":"login-email",type:"email",required:!0,placeholder:"[email protected]",autoComplete:"username webauthn",value:e,error:r??void 0,onChange:i=>a(i.target.value),onBlur:p})]}),t.jsx(F,{type:"submit",disabled:E,"data-testid":"login-submit",loading:x,children:"Sign in"})]})]})]})}export{T as LoginContent};
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.