"use strict";(self.webpackChunkNexoPOS_4x=self.webpackChunkNexoPOS_4x||[]).push([[411],{411:(e,s,i)=>{i.r(s),i.d(s,{default:()=>l});var t=i(2277),n=i(7266),r=i(9671),o=i(7389);const a={name:"ns-login",props:["showRecoveryLink"],data:function(){return{fields:[],xXsrfToken:null,validation:new n.Z,isSubitting:!1}},mounted:function(){var e=this;(0,t.D)([r.ih.get("/api/nexopos/v4/fields/ns.login"),r.ih.get("/sanctum/csrf-cookie")]).subscribe({next:function(s){e.fields=e.validation.createFields(s[0]),e.xXsrfToken=r.ih.response.config.headers["X-XSRF-TOKEN"],setTimeout((function(){return r.kq.doAction("ns-login-mounted",e)}),100)},error:function(e){r.kX.error(e.message||(0,o.__)("An unexpected error occured."),(0,o.__)("OK"),{duration:0}).subscribe()}})},methods:{__:o.__,signIn:function(){var e=this;if(!this.validation.validateFields(this.fields))return r.kX.error((0,o.__)("Unable to proceed the form is not valid.")).subscribe();this.validation.disableFields(this.fields),r.kq.applyFilters("ns-login-submit",!0)&&(this.isSubitting=!0,r.ih.post("/auth/sign-in",this.validation.getValue(this.fields),{headers:{"X-XSRF-TOKEN":this.xXsrfToken}}).subscribe((function(e){document.location=e.data.redirectTo}),(function(s){e.isSubitting=!1,e.validation.enableFields(e.fields),s.data&&e.validation.triggerFieldsErrors(e.fields,s.data),r.kX.error(s.message).subscribe()})))}}};const l=(0,i(1900).Z)(a,(function(){var e=this,s=e.$createElement,i=e._self._c||s;return i("div",{staticClass:"ns-box rounded shadow overflow-hidden transition-all duration-100"},[i("div",{staticClass:"p-3 -my-2"},[e.fields.length>0?i("div",{staticClass:"py-2 fade-in-entrance anim-duration-300"},e._l(e.fields,(function(e,s){return i("ns-field",{key:s,attrs:{field:e}})})),1):e._e()]),e._v(" "),0===e.fields.length?i("div",{staticClass:"flex items-center justify-center py-10"},[i("ns-spinner",{attrs:{border:"4",size:"16"}})],1):e._e(),e._v(" "),e.showRecoveryLink?i("div",{staticClass:"flex w-full items-center justify-center py-4"},[i("a",{staticClass:"hover:underline text-blue-600 text-sm",attrs:{href:"/password-lost"}},[e._v(e._s(e.__("Password Forgotten ?")))])]):e._e(),e._v(" "),i("div",{staticClass:"flex justify-between items-center login-footer p-3"},[i("div",[i("ns-button",{staticClass:"justify-between",attrs:{type:"info"},on:{click:function(s){return e.signIn()}}},[e.isSubitting?i("ns-spinner",{staticClass:"mr-2",attrs:{size:"6",border:"2"}}):e._e(),e._v(" "),i("span",[e._v(e._s(e.__("Sign In")))])],1)],1),e._v(" "),i("div",[i("ns-link",{attrs:{href:"/sign-up",type:"success"}},[e._v(e._s(e.__("Register")))])],1)])])}),[],!1,null,null,null).exports}}]);