import{$ as e,C as t,G as n,L as r,S as i,Wt as a,dt as o,g as s,h as c,st as l,u,vt as d,y as f,z as p}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import"./http-BdoVLsWz.js";import{a as m}from"./vue-router-Bna4o8ws.js";import{t as h}from"./notification-BM55Quw3.js";import{n as g}from"./error-handling-CuGxlkPL.js";import{n as _}from"./vue-i18n-C4HYJWrq.js";import{K as v,W as y,Z as b,jn as x}from"./main-Gn9UsJwa.js";var S={class:`mt-5 mb-8`},C={class:`mb-4`},w={__name:`Login`,setup(w){let T=h(),E=g(),{t:D}=_(),O=m(),k=o(!1),A=o(!1),j=x({email:{required:y.withMessage(D(`validation.required`),b),email:y.withMessage(D(`validation.email_incorrect`),v)},password:{required:y.withMessage(D(`validation.required`),b)}},c(()=>E.loginData)),M=c(()=>A.value?`text`:`password`);async function N(){if(j.value.$touch(),j.value.$invalid)return!0;k.value=!0;try{k.value=!0,await E.login(E.loginData),O.push(`/admin/dashboard`),T.showNotification({type:`success`,message:`Logged in successfully.`})}catch{k.value=!1}}return r(()=>{window.demo_mode&&(E.loginData.email=`demo@invoiceshelf.com`,E.loginData.password=`demo`)}),(r,o)=>{let c=n(`BaseInput`),m=n(`BaseInputGroup`),h=n(`BaseIcon`),g=n(`router-link`),_=n(`BaseButton`);return p(),f(`form`,{id:`loginForm`,class:`mt-12 text-left`,onSubmit:u(N,[`prevent`])},[t(m,{error:d(j).email.$error&&d(j).email.$errors[0].$message,label:r.$t(`login.email`),class:`mb-4`,required:``},{default:e(()=>[t(c,{modelValue:d(E).loginData.email,"onUpdate:modelValue":o[0]||=e=>d(E).loginData.email=e,invalid:d(j).email.$error,focus:``,type:`email`,name:`email`,onInput:o[1]||=e=>d(j).email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),t(m,{error:d(j).password.$error&&d(j).password.$errors[0].$message,label:r.$t(`login.password`),class:`mb-4`,required:``},{default:e(()=>[t(c,{modelValue:d(E).loginData.password,"onUpdate:modelValue":o[3]||=e=>d(E).loginData.password=e,invalid:d(j).password.$error,type:M.value,name:`password`,onInput:o[4]||=e=>d(j).password.$touch()},{right:e(()=>[t(h,{name:d(A)?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 text-gray-500 cursor-pointer`,onClick:o[2]||=e=>l(A)?A.value=!d(A):A=!d(A)},null,8,[`name`])]),_:1},8,[`modelValue`,`invalid`,`type`])]),_:1},8,[`error`,`label`]),s(`div`,S,[s(`div`,C,[t(g,{to:`forgot-password`,class:`text-sm text-primary-400 hover:text-gray-700`},{default:e(()=>[i(a(r.$t(`login.forgot_password`)),1)]),_:1})])]),t(_,{loading:k.value,type:`submit`},{default:e(()=>[i(a(r.$t(`login.login`)),1)]),_:1},8,[`loading`])],32)}}};export{w as default};