import{Q as p,_ as g}from"./logo-eHoYB6sL.js";import{R as h,S as w,T as i,U as t,W as a,X as d,j as c,ab as y,a4 as m,aY as u,V as $,a8 as b}from"./index-CRkL0E25.js";import{Q as V}from"./QForm-Bt9zuRZK.js";import{Q as v}from"./QPage-BQvLN6qt.js";import{b as Q,c as q}from"./QLayout-DrzGiLUc.js";import{a as R,M as k}from"./main-B2ajQvEX.js";import{_}from"./_plugin-vue_export-helper-DlAUqK2U.js";import"./index-JQkw9yeP.js";const N=R.create({baseURL:"/admin-api"});class P{register(s){return new Promise((l,f)=>{N.post("/register",s).then(n=>{l(n.data)}).catch(n=>{f(n)})})}}const o=k(),U=b({name:"RegisterPage",data(){return{form:{email:"",fullName:"",password:""},loading:!1,error:""}},methods:{async register(){if(await this.$refs.form.validate()){this.loading=!0,this.error="";try{const l=await new P().register(this.form);o.branding.registrationCompleted=!0,await o.saveAuthData(l.access_token,l.username),o.changePage("/")}catch(s){s.code==="ERR_NETWORK"?this.error=o.translate("network_error"):s.response&&s.response.data&&s.response.data.code_error?this.error=o.translate(s.response.data.code_error):this.error=o.translate("unknown_error")}finally{this.loading=!1}}}}}),C={class:"row full-width"},S={class:"col-10 offset-1 col-sm-8 offset-sm-2 col-md-4 offset-md-4 col-lg-2 offset-lg-5"},z={class:"text-h5 text-center q-my-md text-grey-9"},B={class:"row"},K={class:"col-12 q-mt-md q-mb-lg"},A={class:"q-mr-xs"};function D(e,s,l,f,n,L){return h(),w(q,{class:"bg-white",view:"lHh Lpr lFf"},{default:i(()=>[t(Q,null,{default:i(()=>[t(v,{class:"flex flex-center"},{default:i(()=>[a("div",C,[a("div",S,[t(V,{ref:"form",greedy:""},{default:i(()=>[t(p,{"error-src":g,src:e.$store.branding.logoUrl,class:"items-center",style:{height:"80px","max-width":"80px",display:"block","margin-left":"auto","margin-right":"auto"}},null,8,["src"]),a("div",z,d(e.$t("register_title")),1),c(a("p",{class:"text-negative text-center"},d(e.error),513),[[y,e.error]]),t(m,{modelValue:e.form.email,"onUpdate:modelValue":s[0]||(s[0]=r=>e.form.email=r),type:"email",label:e.$t("email")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field"),r=>/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(r)||e.$t("invalid_email")]},null,8,["modelValue","label","rules"]),t(m,{modelValue:e.form.fullName,"onUpdate:modelValue":s[1]||(s[1]=r=>e.form.fullName=r),label:e.$t("full_name")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field")]},null,8,["modelValue","label","rules"]),t(m,{modelValue:e.form.password,"onUpdate:modelValue":s[2]||(s[2]=r=>e.form.password=r),type:"password",label:e.$t("password")+" *","lazy-rules":"",rules:[r=>r&&r.length>0||e.$t("required_field"),r=>r&&r.length>=8&&/[A-Z]/.test(r)&&/[a-z]/.test(r)&&/[0-9]/.test(r)||e.$t("password_policy")],onKeyup:s[3]||(s[3]=u(r=>e.register(),["enter"]))},null,8,["modelValue","label","rules"]),a("div",B,[a("div",K,[t($,{onClick:s[4]||(s[4]=r=>e.register()),class:"full-width q-mt-md",color:"primary",loading:e.loading,onKeyup:s[5]||(s[5]=u(r=>e.register(),["enter"]))},{default:i(()=>[a("span",A,d(e.$t("register")),1)]),_:1},8,["loading"])])])]),_:1},512)])])]),_:1})]),_:1})]),_:1})}const O=_(U,[["render",D]]);export{O as default};
