import{d as h,u as k,c as u,a as t,w as S,b,v as x,t as d,e as f,f as g,r as c,g as y,h as V,i as E,o as m}from"./index-BhMpD06x.js";const U={class:"flex min-h-full items-center justify-center bg-slate-900 p-6 text-slate-100"},q={class:"w-full max-w-md rounded-2xl border border-slate-700 bg-slate-800 p-8 shadow-2xl"},B={class:"block text-sm"},M={class:"block text-sm"},P={key:0,class:"text-sm text-amber-200"},R={key:1,class:"text-sm text-rose-300"},C=["disabled"],N=h({__name:"LoginView",setup(D){const a=V(),v=E(),n=k(),l=c("admin"),r=c("refrain"),s=c(null),w=y(()=>typeof a.query.redirect=="string"?a.query.redirect:"/"),p=y(()=>a.query.reason==="session-expired"?"Your session expired. Please sign in again.":null);async function _(){s.value=null;try{await n.login(l.value,r.value),await v.replace(w.value)}catch(o){s.value=o instanceof Error?o.message:String(o)}}return(o,e)=>(m(),u("main",U,[t("section",q,[e[4]||(e[4]=t("h1",{class:"text-2xl font-semibold"},"Sign in to Refrain",-1)),e[5]||(e[5]=t("p",{class:"mt-2 text-sm text-slate-300"},"Use your account to access communities and channels.",-1)),t("form",{class:"mt-6 space-y-4",onSubmit:S(_,["prevent"])},[t("label",B,[e[2]||(e[2]=t("span",{class:"mb-1 block text-slate-300"},"Username",-1)),b(t("input",{"onUpdate:modelValue":e[0]||(e[0]=i=>l.value=i),type:"text",autocomplete:"username",class:"w-full rounded-md border border-slate-600 bg-slate-900 px-3 py-2 text-slate-100 outline-none ring-0 focus:border-blue-400"},null,512),[[x,l.value]])]),t("label",M,[e[3]||(e[3]=t("span",{class:"mb-1 block text-slate-300"},"Password",-1)),b(t("input",{"onUpdate:modelValue":e[1]||(e[1]=i=>r.value=i),type:"password",autocomplete:"current-password",class:"w-full rounded-md border border-slate-600 bg-slate-900 px-3 py-2 text-slate-100 outline-none ring-0 focus:border-blue-400"},null,512),[[x,r.value]])]),p.value?(m(),u("p",P,d(p.value),1)):f("",!0),s.value?(m(),u("p",R,d(s.value),1)):f("",!0),t("button",{type:"submit",disabled:g(n).pending,class:"w-full rounded-md bg-blue-500 px-4 py-2 font-medium text-white transition hover:bg-blue-400 disabled:cursor-not-allowed disabled:opacity-50"},d(g(n).pending?"Signing in...":"Sign in"),9,C)],32)])]))}});export{N as default};
//# sourceMappingURL=LoginView-BKyX1k7a.js.map
