import{At as e,B as t,Bt as n,G as r,L as i,M as a,N as o,R as s,T as c,Tt as l,Ut as u,bt as d,c as f,h as p,nt as m,ot as h,qt as g,s as _,y as v,yt as y}from"./vue-3bs2-dMU.js";import{E as b,K as x}from"./stores-DmetsdTd.js";import{C as S,D as C,E as w,K as T,T as E,vt as D,w as O}from"./vuetify-gGrfRH2I.js";import{n as k,t as A}from"./PasswordField-DKLNiFeT.js";r(),l(),u(),v();var j=t({__name:`Login`,setup(t){let{t:r}=x(),l=f(),u=_(),v=b(),j=e({username:``,password:``});async function M(){let e=await v.login(j.username,j.password);if(v.isAuthenticated)p.success(r(`login.success`)),N();else{let t=r(`login.error`);t+=`\nError code: ${e.status} (${e.data})`,p.error(t)}}function N(){u.query.redirect?l.push(u.query.redirect):l.push({name:`dashboard`})}return m(async()=>{u.query.username&&u.query.password&&await v.login(u.query.username,u.query.password)}),y(()=>{v.isAuthenticated&&N()}),(e,t)=>(h(),o(D,{class:`fill-height d-flex align-center justify-center`},{default:d(()=>[s(S,{class:`mx-auto`,rounded:`lg`,"min-width":`250`},{default:d(()=>[s(E,null,{default:d(()=>[i(g(n(r)(`login.title`)),1)]),_:1}),s(w,null,{default:d(()=>[i(g(n(r)(`login.subtitle`)),1)]),_:1}),s(O,null,{default:d(()=>[a(`form`,{onSubmit:c(M,[`prevent`])},[s(k,{id:`username`,modelValue:j.username,"onUpdate:modelValue":t[0]||=e=>j.username=e,title:n(r)(`login.username`),autocomplete:`username`,autofocus:``,name:`username`,"prepend-icon":`mdi-account`,onSubmit:M},null,8,[`modelValue`,`title`]),s(A,{id:`password`,modelValue:j.password,"onUpdate:modelValue":t[1]||=e=>j.password=e,title:n(r)(`login.password`),autocomplete:`current-password`,name:`password`,"prepend-icon":`mdi-lock`,onSubmit:M},null,8,[`modelValue`,`title`])],32)]),_:1}),s(C,null,{default:d(()=>[s(T,{variant:`elevated`,block:``,color:`accent`,onClick:M},{default:d(()=>[i(g(n(r)(`login.submit`)),1)]),_:1})]),_:1})]),_:1})]),_:1}))}});export{j as default};