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