import{$ as e,C as t,G as n,S as r,Wt as i,dt as a,g as o,h as s,u as c,vt as l,y as u,z as d,zt as f}from"./vue.runtime.esm-bundler-DAWRyTnP.js";import{a as p,i as m}from"./vue-router-Bna4o8ws.js";import{n as h}from"./vue-i18n-C4HYJWrq.js";import{K as g,Mn as _,W as v,Z as y}from"./main-CgSmSYZA.js";import{t as b}from"./auth-CmHHJsI-.js";var x={class:`flex items-center justify-between`},S={__name:`Login`,setup(S){let C=p(),w=m(),T=b(),{t:E}=h(),D=a(!1),O=a(!1),k=s(()=>O.value?`text`:`password`),A=_(s(()=>({loginData:{email:{required:v.withMessage(E(`validation.required`),y),email:v.withMessage(E(`validation.email_incorrect`),g)},password:{required:v.withMessage(E(`validation.required`),y)}}})),T);async function j(){if(A.value.loginData.$touch(),A.value.loginData.$invalid)return!0;D.value=!0;let e={...T.loginData,company:w.params.company};try{return await T.login(e),D.value=!1,C.push({name:`customer.dashboard`})}catch{D.value=!1}}return(a,s)=>{let p=n(`BaseInput`),m=n(`BaseInputGroup`),h=n(`BaseIcon`),g=n(`router-link`),_=n(`BaseButton`);return d(),u(`form`,{id:`loginForm`,class:`space-y-6`,action:`#`,method:`POST`,onSubmit:c(j,[`prevent`])},[t(m,{error:l(A).loginData.email.$error&&l(A).loginData.email.$errors[0].$message,label:a.$t(`login.email`),class:`mb-4`,required:``},{default:e(()=>[t(p,{modelValue:l(T).loginData.email,"onUpdate:modelValue":s[0]||=e=>l(T).loginData.email=e,type:`email`,invalid:l(A).loginData.email.$error,onInput:s[1]||=e=>l(A).loginData.email.$touch()},null,8,[`modelValue`,`invalid`])]),_:1},8,[`error`,`label`]),t(m,{error:l(A).loginData.password.$error&&l(A).loginData.password.$errors[0].$message,label:a.$t(`login.password`),class:`mb-4`,required:``},{default:e(()=>[t(p,{modelValue:l(T).loginData.password,"onUpdate:modelValue":s[3]||=e=>l(T).loginData.password=e,type:k.value,invalid:l(A).loginData.password.$error,onInput:s[4]||=e=>l(A).loginData.password.$touch()},{right:e(()=>[t(h,{name:O.value?`EyeIcon`:`EyeSlashIcon`,class:`mr-1 text-gray-500 cursor-pointer`,onClick:s[2]||=e=>O.value=!O.value},null,8,[`name`])]),_:1},8,[`modelValue`,`type`,`invalid`])]),_:1},8,[`error`,`label`]),o(`div`,x,[t(g,{to:{name:`customer.forgot-password`},class:`text-sm text-primary-600 hover:text-gray-500`},{default:e(()=>[r(i(a.$t(`login.forgot_password`)),1)]),_:1})]),o(`div`,null,[t(_,{loading:l(D),disabled:l(D),type:`submit`,class:`w-full justify-center`},{left:e(e=>[t(h,{name:`LockClosedIcon`,class:f(e.class)},null,8,[`class`])]),default:e(()=>[r(` `+i(a.$t(`login.login`)),1)]),_:1},8,[`loading`,`disabled`])])],32)}}};export{S as default};