import{u as x,d as k,v as M,e as f,f as p,g as v,h as N,i as C,j as w,k as E,c as L,a as r,b as $,w as l,l as e,m as j,r as u,n as G,o as R,p as T,q as _,t as y,s as U}from"./main-FAzQ_AST.js";const A={class:"mt-5 mb-8"},F={class:"mb-4"},H={__name:"Login",setup(P){const h=x(),s=k(),{t:m}=M.useI18n(),b=G(),d=f(!1);let t=f(!1);const B={email:{required:p.withMessage(m("validation.required"),v),email:p.withMessage(m("validation.email_incorrect"),N)},password:{required:p.withMessage(m("validation.required"),v)}},o=C(B,w(()=>s.loginData)),I=w(()=>t.value?"text":"password");async function V(){if(U.defaults.withCredentials=!0,o.value.$touch(),o.value.$invalid)return!0;d.value=!0;try{d.value=!0,await s.login(s.loginData),b.push("/admin/dashboard"),h.showNotification({type:"success",message:"Logged in successfully."})}catch{d.value=!1}}return E(()=>{window.demo_mode&&(s.loginData.email="demo@invoiceshelf.com",s.loginData.password="demo")}),(i,a)=>{const c=u("BaseInput"),g=u("BaseInputGroup"),D=u("BaseIcon"),S=u("router-link"),q=u("BaseButton");return R(),L("form",{id:"loginForm",class:"mt-12 text-left",onSubmit:j(V,["prevent"])},[r(g,{error:e(o).email.$error&&e(o).email.$errors[0].$message,label:i.$t("login.email"),class:"mb-4",required:""},{default:l(()=>[r(c,{modelValue:e(s).loginData.email,"onUpdate:modelValue":a[0]||(a[0]=n=>e(s).loginData.email=n),invalid:e(o).email.$error,focus:"",type:"email",name:"email",onInput:a[1]||(a[1]=n=>e(o).email.$touch())},null,8,["modelValue","invalid"])]),_:1},8,["error","label"]),r(g,{error:e(o).password.$error&&e(o).password.$errors[0].$message,label:i.$t("login.password"),class:"mb-4",required:""},{default:l(()=>[r(c,{modelValue:e(s).loginData.password,"onUpdate:modelValue":a[3]||(a[3]=n=>e(s).loginData.password=n),invalid:e(o).password.$error,type:I.value,name:"password",onInput:a[4]||(a[4]=n=>e(o).password.$touch())},{right:l(()=>[r(D,{name:e(t)?"EyeIcon":"EyeSlashIcon",class:"mr-1 text-gray-500 cursor-pointer",onClick:a[2]||(a[2]=n=>T(t)?t.value=!e(t):t=!e(t))},null,8,["name"])]),_:1},8,["modelValue","invalid","type"])]),_:1},8,["error","label"]),$("div",A,[$("div",F,[r(S,{to:"forgot-password",class:"text-sm text-primary-400 hover:text-gray-700"},{default:l(()=>[_(y(i.$t("login.forgot_password")),1)]),_:1})])]),r(q,{loading:d.value,type:"submit"},{default:l(()=>[_(y(i.$t("login.login")),1)]),_:1},8,["loading"])],32)}}};export{H as default};
