import{_ as ee}from"./CNIrc0EA.js";import{_ as te}from"./DrAtu1a1.js";import{_ as ae}from"./DuhDFJjj.js";import{A as oe}from"./AmaTRG5a.js";import{n as ne,p as se,l as U,q as le,v as re,x as ie,c as v,y as ue,z as ce,s as me,A as de,i as pe,B as fe,k as V,j as p,d as ve,w as A,r as _e,C as ge,o as f,b as o,D as M,m as t,E,f as h,t as l,e as R,G as P,H as q,I as be,J as N,K as he,L as ke,M as ye}from"./Bgmy51Qv.js";import{u as Se}from"./7pZkuj9N.js";import{u as we}from"./LR-3m_fG.js";const $e=Symbol.for("nuxt:client-only"),Ce=ne({name:"ClientOnly",inheritAttrs:!1,props:["fallback","placeholder","placeholderTag","fallbackTag"],setup(_,{slots:r,attrs:g}){const k=se(!1);U(()=>{k.value=!0});const y=le();return y&&(y._nuxtClientOnly=!0),ue($e,!0),()=>{var w;if(k.value){const c=(w=r.default)==null?void 0:w.call(r);return c&&c.length===1?[re(c[0],g)]:c}const S=r.fallback||r.placeholder;if(S)return ie(S);const $=_.fallback||_.placeholder||"",B=_.fallbackTag||_.placeholderTag||"span";return v(B,g,$)}}}),xe={class:"mb-30 mb-sm-15"},Te={class:"input-wrapper"},Ve={class:"icon-input"},Ae=["placeholder"],Ee={key:0,class:"error"},Re={key:1,class:"error"},Be={class:"input-wrapper"},De={key:0,class:"error"},Ie={key:1,class:"error"},Me={class:"sided mt-15"},Pe={class:"checkbox"},qe={key:0},He={__name:"login",setup(_){const r=ce(),{setErrors:g,settingRemember:k}=r,{rememberMe:y}=me(r),S=Se(),{getRequest:$,setRequest:B,unAuthPost:w}=S,c=de(),{settingSiteData:j}=c,L=pe(),{setProfile:O}=L,z=fe(),{setToken:F}=z,H=V(()=>ge().public.isDemo),n=p(""),s=p(""),u=p(""),i=p(!1),m=p(!1),C=p(""),{isValidEmail:G,isValidLength:J}=we(),x=V(()=>n.value&&!G(n.value)),T=V(()=>s.value&&!J(s.value)),K=e=>{s.value=e},D=e=>{e<0?(n.value="admin@mail.com",s.value="123456"):(n.value="vendor@mail.com",s.value="123456"),I()},I=async()=>{if(i.value=!1,!n.value||!s.value||x.value||T.value)return i.value=!0,!1;k(u.value),m.value=!0;const e=await w({params:{remember_token:u.value,password:s.value,email:n.value},api:"login"});if(m.value=!1,(e==null?void 0:e.status)===201)return;F(e.token);const a=ke("remember_expires",{maxAge:60*60*24*7});a.value=u.value?7:null,m.value=!0;const b=await $({params:{},api:"profile"});if(m.value=!1,b)return await j(b),O(b),i.value=!1,g(),ye(C.value||"/");m.value=!1};return U(()=>{C.value=localStorage.getItem("redirection_url",""),C.value,u.value=y.value==="true"?!0:"",g()}),(e,a)=>{const b=ee,Q=te,W=ae,X=oe,Y=Ce,Z=_e("login-layout");return f(),ve(Z,null,{default:A(()=>[o("form",{ref:"loginForm",onSubmit:a[4]||(a[4]=E(d=>I(),["prevent"])),class:M([{"has-error":t(i)},"login-form"])},[o("h4",xe,l(e.$t("profile.wb")),1),h(b),o("div",Te,[o("div",Ve,[a[5]||(a[5]=o("i",{class:"icon email-icon"},null,-1)),P(o("input",{type:"text",placeholder:e.$t("fSale.email"),"onUpdate:modelValue":a[0]||(a[0]=d=>q(n)?n.value=d:null),class:M({invalid:!t(n)||t(x)})},null,10,Ae),[[be,t(n),void 0,{trim:!0}]])]),!t(n)&&t(i)?(f(),v("span",Ee,l(e.$t("category.req",{type:e.$t("fSale.email")})),1)):t(x)&&t(i)?(f(),v("span",Re,l(e.$t("user.isValid",{type:e.$t("fSale.email")})),1)):R("",!0)]),o("div",Be,[h(Q,{value:t(s),"is-invalid":t(T),onChangePassword:K},null,8,["value","is-invalid"]),!t(s)&&t(i)?(f(),v("span",De,l(e.$t("category.req",{type:e.$t("user.pass")})),1)):t(T)&&t(i)?(f(),v("span",Ie,l(e.$t("user.inPass")),1)):R("",!0)]),o("div",Me,[o("label",Pe,[P(o("input",{type:"checkbox","onUpdate:modelValue":a[1]||(a[1]=d=>q(u)?u.value=d:null)},null,512),[[he,t(u)]]),N(" "+l(e.$t("profile.rm")),1)]),h(W,{to:"/forgot-password",class:"link"},{default:A(()=>[N(l(e.$t("profile.fp")),1)]),_:1})]),h(X,{"activate-btn":!0,class:"mt-20 primary-btn","fetching-data":t(m),"loading-text":e.$t("dataPage.logging"),text:e.$t("dataPage.sign")},null,8,["fetching-data","loading-text","text"]),h(Y,null,{default:A(()=>[t(H)?(f(),v("div",qe,[o("button",{onClick:a[2]||(a[2]=E(d=>D(-1),["prevent"])),class:"outline-btn block mtb-15 w-100"},l(e.$t("profile.laa")),1),o("button",{onClick:a[3]||(a[3]=E(d=>D(1),["prevent"])),class:"outline-btn block w-100"},l(e.$t("profile.lav")),1)])):R("",!0)]),_:1})],34)]),_:1})}}};export{He as default};
