import{F as w,I as F,b as d,n as p,d as u,w as S}from"./bootstrap-BsWQM_6D.js";import{_ as a}from"./currency-Dtag6qPd.js";import{_ as T}from"./_plugin-vue_export-helper-DlAUqK2U.js";import{r as f,o as s,c as t,a as i,F as V,b as B,g as v,e as l,f as _,t as h,w as y,i as R}from"./runtime-core.esm-bundler-VrNrzzXC.js";import"./chart-CAYz1qzV.js";const X={name:"ns-login",props:["showRecoveryLink","showRegisterButton"],data(){return{fields:[],xXsrfToken:null,validation:new w,isSubitting:!1}},mounted(){F({login:d.get("/api/fields/ns.login"),csrf:d.get("/sanctum/csrf-cookie")}).subscribe({next:n=>{this.fields=this.validation.createFields(n.login),this.xXsrfToken=d.response.config.headers["X-XSRF-TOKEN"],setTimeout(()=>p.doAction("ns-login-mounted",this),100)},error:n=>{u.error(n.message||a("An unexpected error occurred."),a("OK"),{duration:0}).subscribe()}})},methods:{__:a,signIn(){if(!this.validation.validateFields(this.fields))return u.error(a("Unable to proceed the form is not valid.")).subscribe();this.validation.disableFields(this.fields),p.applyFilters("ns-login-submit",!0)&&(this.isSubitting=!0,d.post("/auth/sign-in",this.validation.getValue(this.fields),{headers:{"X-XSRF-TOKEN":this.xXsrfToken}}).subscribe({next:e=>{document.location=e.data.redirectTo},error:e=>{this.isSubitting=!1,this.validation.enableFields(this.fields),e.data&&this.validation.triggerFieldsErrors(this.fields,e.data),u.error(e.message||a("An unexpected error occured.")).subscribe()}}))}}},N={class:"ns-box rounded shadow overflow-hidden transition-all duration-100"},C={class:"ns-box-body"},I={class:"p-3 -my-2"},K={key:0,class:"flex items-center justify-center py-10"},j={key:1,class:"flex w-full items-center justify-center py-4"},E={href:"/password-lost",class:"hover:underline text-blue-600 text-sm"},L={class:"flex justify-between items-center border-t ns-box-footer p-3"},A={key:0};function O(n,e,m,z,o,r){const k=f("ns-field"),g=f("ns-spinner"),b=f("ns-button");return s(),t("div",N,[i("div",C,[i("div",I,[o.fields.length>0?(s(),t("div",{key:0,class:"py-2 fade-in-entrance anim-duration-300",onKeyup:e[0]||(e[0]=S(c=>r.signIn(),["enter"]))},[(s(!0),t(V,null,B(o.fields,(c,x)=>(s(),v(k,{key:x,field:c},null,8,["field"]))),128))],32)):l("",!0)]),o.fields.length===0?(s(),t("div",K,[_(g,{border:"4",size:"16"})])):l("",!0),m.showRecoveryLink?(s(),t("div",j,[i("a",E,h(r.__("Password Forgotten ?")),1)])):l("",!0)]),i("div",L,[i("div",null,[_(b,{disabled:o.isSubitting,onClick:e[1]||(e[1]=c=>r.signIn()),class:"justify-between",type:"info"},{default:y(()=>[o.isSubitting?(s(),v(g,{key:0,class:"mr-2",size:"6"})):l("",!0),i("span",null,h(r.__("Sign In")),1)]),_:1},8,["disabled"])]),m.showRegisterButton?(s(),t("div",A,[_(b,{link:!0,href:"/sign-up",type:"success"},{default:y(()=>[R(h(r.__("Register")),1)]),_:1})])):l("",!0)])])}const q=T(X,[["render",O]]);export{q as default};
