import{_ as x,F as V,a as F}from"./footerB-DAi6c01a.js";import{i as d,u as S,j as B,k as I,l as L,m as s,o as c,c as m,t as n,b as e,w as h,v as g,f as A,a as p,F as M}from"./index-DccGIixi.js";const R={key:0},q={key:1,class:"logout"},C={key:2,class:"login-form"},D={class:"form-group"},E={for:"email"},N=["placeholder"],U={class:"form-group"},$={for:"password"},j=["placeholder"],G={type:"submit"},H={__name:"inout",setup(v){const l=d("");d(!0);const a=d("");d(!0);const{t:r}=S(),_=B(),i=I();let t=d(!1);L(async()=>{t=!0,i.checkAuth().catch(o=>console.error("Check auth failed",o)),t=!1});async function w(){if(t=!0,!b(l.value)||!y(a.value)){alert("Пожалуйста, заполните все поля корректно."),t=!1;return}try{await i.login({email:l.value,password:a.value}),t=!1,_.push("/")}catch(o){console.error(o),alert("Неверный email или пароль. Попробуйте снова.")}}function y(o){return!(a.length===0||a.length<6)}function b(o){return!(o.length===0||!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(o))}function k(){t=!0,i.logout(),t=!1,_.push("/")}return(o,u)=>s(t)?(c(),m("div",R,n(s(r)("messages.load"))+" . . .",1)):s(i).isAuthenticated?(c(),m("div",q,[e("div",null,[e("p",null,"Good by "+n(s(i).user.name)+"!",1),e("button",{onClick:k},"Logout")])])):(c(),m("div",C,[e("h1",null,n(s(r)("messages.inout.login")),1),e("form",{onSubmit:A(w,["prevent"])},[e("div",D,[e("label",E,n(s(r)("messages.inout.email"))+": ",1),h(e("input",{"onUpdate:modelValue":u[0]||(u[0]=f=>l.value=f),type:"email",id:"email",required:"",placeholder:s(r)("messages.inout.email")},null,8,N),[[g,l.value,void 0,{trim:!0}]])]),e("div",U,[e("label",$,n(s(r)("messages.inout.password"))+": ",1),h(e("input",{"onUpdate:modelValue":u[1]||(u[1]=f=>a.value=f),type:"password",id:"password",required:"",placeholder:s(r)("messages.inout.password")},null,8,j),[[g,a.value,void 0,{trim:!0}]])]),e("button",G,n(s(r)("messages.inout.login")),1)],32)]))}},P=x(H,[["__scopeId","data-v-1bd59691"]]),J={__name:"LogInView",setup(v){return(l,a)=>(c(),m(M,null,[p(V),p(P),p(F)],64))}};export{J as default};
