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