import{_ as ie,a0 as me,a1 as ue,aJ as n,$ as fe,aK as ge,a2 as X,S as Ve,a as Z,r as ce,b as R,c as be,m as he,aa as pe,ab as f,aE as ye,f as E,i as s,w as r,V as we,j as T,o as k,z as W,l as Y,A as h,t as V,g as C,N as I,y as v,C as ke,s as p,h as U,n as D,al as ve,ao as c,an as g,am as L,ap as Ce,as as Ue,ae as Pe,q as Se,at as qe,x as Me,au as Te,aw as Ae}from"./index-Bmj_12NV.js";import{V as Fe}from"./VatDialog-Dt9yM3E9.js";import{F as Re}from"./Footer-HZwtkbtN.js";import{f as Ee}from"./format-address-U80pFLm7.js";const Ie={name:"Register",components:{VatDialog:Fe,Footer:Re,Form:me,Field:ue},setup(){let o=n(!1),e=n(!1),i=n(!1),l=n(""),y=n(""),b=n(""),m=n(""),P=n(""),S=n(""),q=n(""),w=n(""),M=n(""),a=n(null),d=n(""),u=n(""),t=n(""),x=n(""),B=n(null),N=n(!1),H=n(null),Q=n(!1),_=n(!1);const $=n(["Mr","Mrs","Miss","Ms","Dr","Rev","Mx"]),ee=n([{name:"English",code:"en"},{name:"Czech",code:"cs"},{name:"Dutch",code:"nl"},{name:"Finish",code:"fi"},{name:"French",code:"fr"},{name:"German",code:"de"},{name:"Italian",code:"it"},{name:"Japanese",code:"ja"},{name:"Russian",code:"ru"},{name:"Spanish",code:"es"}]);let le=n([]),K=n(!1),ae=n([]),oe=n(null),z=n(!1),G=n(""),j=n(null);const J=n(null),{t:O}=fe(),{executeRecaptcha:se,recaptchaLoaded:re}=ge(),te=async()=>{await re();const A=await se("login");ne(A)},de=X();function ne(A){de.register(l.value,y.value,m.value,P.value,S.value,M.value,a.value,d.value,u.value,t.value,x.value,q.value,w.value,B.value,N.value,H.value,A,b.value).then(F=>{document.getElementById("scrolling-content").scrollTop=0,o.value=!1}).catch(F=>{z.value=!0,G.value="error",j.value=O("Please check the form for errors"),o.value=!1,F.response.data.errors.recaptchaToken&&(console.log("recaptchaFailed"),K=!0),J.value.setErrors(F.response.data.errors)})}return{loading:o,sent:e,dialog:i,email:l,password:y,password_confirmation:b,title:m,first_name:P,last_name:S,phone:q,mobile:w,address1:M,address2:a,town:d,county:u,postcode:t,country:x,language:B,newsletter:N,vat_number:H,valid:Q,showPassword:_,titles:$,languages:ee,countries:le,recaptchaFailed:K,addresses:ae,address:oe,snackbar:z,snackText:j,snackColor:G,registerForm:J,recaptcha:te,t:O}},beforeRouteEnter(o,e,i){i(l=>{const y=o.params.locale;Ve.includes(y)&&(l.$i18n.locale=y,Z().$patch({locale:y})),l.$i18n.locale!==null&&o.path.startsWith("/"+l.$i18n.locale)===!1&&(l.$i18n.locale!=="en"||y)?ce.push("/"+l.$i18n.locale+"/"+l.$t("routes.register")).catch(()=>{}):i()})},mounted(){this.$gtag.pageview({page_path:this.$route.path}),document.getElementById("scrolling-content").scrollTop=0,document.title="Helios - Register",setTimeout(function(){window.prerenderReady=!0},1e3),R.get("https://api.helios.co.uk/api/countries").then(o=>{this.countries=o.data.data}).catch(o=>{console.log(o)})},watch:{address(o){console.log(o),o&&this.setDeliveryAddress(o)}},methods:{...be(X,["register"]),setDeliveryAddress(o){console.log(o);let e=o.split(","),i=Ee(e);this.address1=i.address1,this.address2=i.address2,this.town=i.town,this.county=i.county,this.country=i.country},onInvalidSubmit({values:o,errors:e,results:i}){console.log(o),console.log(e),console.log(i),this.snackbar=!0,this.snackColor="error",this.snackText=this.$t("Please check the form for errors")},resendVerification(){this.loading=!0,this.loader="loading",this.sent=!1,R.create({baseURL:"https://api.helios.co.uk",withCredentials:!0,withXSRFToken:!0}).post("https://api.helios.co.uk/email/verification-notification").then(e=>{this.loading=!1,(e.status===204||e.status===202)&&(this.sent=!0,this.snackbar=!0,this.snackColor="success",this.snackText=this.$t("Verification email sent"))}).catch(e=>{console.log(e),this.loading=!1,this.snackbar=!0,this.snackColor="error",this.snackText=e.response.data.error})},navigate(o){this.$router.push({name:o}).catch(()=>{})},async handleSubmit(){(await this.$refs.registerForm.validate()).valid?(this.loading=!0,await this.recaptcha()):(this.loading=!1,this.snackbar=!0,this.snackColor="error",this.snackText=this.$t("Please check the form for errors"))},resetRecaptcha(){this.recaptchaFailed=!1},postcodeLookup(o){o&&(this.addresses=[],R.get("https://api.getAddress.io/find/"+o+"?api-key=SmrsNX5wDE2i2TobX-cubw40057").then(e=>{console.log(e.data),this.addresses=e.data.addresses}).catch(e=>{console.log(e)}))},setAddress(o){console.log(o),this.addresses=[];let e=o.split(",");this.address1=e[0].trim(),this.address2=e[1].trim(),e[6].trim()==="Channel Isles"?(this.town=e[4].trim(),this.county=""):(this.town=e[5].trim(),this.county=e[6].trim());let i=!1;for(let l in e)e[l].trim()==="Guernsey"?(this.country="GG",i=!0):e[l].trim()==="Jersey"?(this.country="JE",i=!0):e[l].trim()==="Isle of Man"&&(this.country="IM",i=!0);i||(this.country="GB")}},computed:{...he(Z,["locale","authenticated"]),countriesList(){return this.countries},vatHint(){return this.$t("fields.If you are in the EU, AND you are registered for VAT, please enter your Country Code and EU VAT number.")+" "+this.$t("hints.Please note that you cannot enter a UK or Isle of Man VAT number for delivery to elsewhere in Europe")},enforcePostcodeRequired(){return this.country!=="HK"},registerSchema(o){return pe({email:f().required().nullable().email().label(this.$t("fields.Email")),password:f().required().nullable().label(this.$t("fields.Password")),password_confirmation:f().required().label(this.$t("fields.Confirm password")).oneOf([ye("password"),null],"Passwords must match"),title:f().required().nullable().label(this.$t("fields.Title")),first_name:f().required().nullable().max(45).label(this.$t("fields.First name")),last_name:f().required().nullable().max(45).label(this.$t("fields.Last name")),postcode:f().when("country",{is:e=>!["HK","IE"].includes(e),then:e=>e.required().min(3).max(16),otherwise:e=>e.nullable()}).label(this.$t("fields.Postcode / ZIP code")),address1:f().required().nullable().max(35).label(this.$t("fields.Address line 1")),address2:f().nullable().max(35).label(this.$t("fields.Address line 2")),town:f().required().nullable().max(35).label(this.$t("fields.Town")),county:f().nullable().max(50).label(this.$t("fields.Province / County / State")),country:f().required().nullable().label(this.$t("fields.Country")),phone:f().required().nullable().max(45).label(this.$t("fields.Phone number")),mobile:f().nullable().max(45).label(this.$t("fields.Mobile number")),language:f().required().nullable().label(this.$t("fields.Preferred language"))})}}},De={id:"content"},Le={class:"md-display-2 mb-6"},xe={class:"text-h5"},Be={key:0},Ne={key:1},He=h("p",null,"* Required fields",-1),Ke={class:"text-right"},ze={class:"d-flex justify-end"};function Ge(o,e,i,l,y,b){const m=T("Field"),P=T("VatDialog"),S=T("Form"),q=T("Footer");return k(),E("div",De,[s(we,null,{default:r(()=>[s(W,null,{default:r(()=>[s(Y,{md:"6","offset-md":"3",class:"login-form"},{default:r(()=>[h("h1",Le,V(o.$t("headings.Register")),1),o.authenticated?(k(),C(D,{key:0,class:"mx-auto",outlined:""},{default:r(()=>[s(I,null,{default:r(()=>[h("p",xe,V(o.$t("headings.Please verify your email address to complete registration")),1),h("p",null,V(o.$t("An email has been sent to {email}",{email:l.email})),1),h("p",null,V(o.$t("You must verify your email address to continue.")),1),h("p",null,V(o.$t("Please make sure you are logged in on the same device and browser, that the email link opens in.")),1),h("p",null,V(o.$t("Please check your spam/junk folder if you can't find it. Alternatively you can request a new verification email below.")),1),s(v,{class:"ma-2",loading:l.loading,disabled:l.loading,tile:"",elevation:"0",color:"primary",onClick:b.resendVerification},{default:r(()=>[l.sent?(k(),E("span",Be,V(o.$t("buttons.Please check your email")),1)):(k(),E("span",Ne,V(o.$t("Request a new verification email.")),1)),l.sent?(k(),C(ke,{key:2},{default:r(()=>[p("mdi-check")]),_:1})):U("",!0)]),_:1},8,["loading","disabled","onClick"])]),_:1})]),_:1})):U("",!0),o.authenticated===!1?(k(),C(D,{key:1,class:"mx-auto form-card",outlined:""},{default:r(()=>[s(I,{class:"text--primary"},{default:r(()=>[He,s(S,{ref:"registerForm",onSubmit:ve(b.handleSubmit,["prevent"]),onInvalidSubmit:b.onInvalidSubmit,"validation-schema":b.registerSchema},{default:r(({errors:w,setFieldError:M})=>[s(m,{modelValue:l.email,"onUpdate:modelValue":e[1]||(e[1]=a=>l.email=a),name:"email"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.email,"onUpdate:modelValue":e[0]||(e[0]=t=>l.email=t)},a,{"error-messages":d[0],label:o.$t("fields.Email"),required:"",autocapitalize:"none"}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.password,"onUpdate:modelValue":e[4]||(e[4]=a=>l.password=a),name:"password"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.password,"onUpdate:modelValue":e[2]||(e[2]=t=>l.password=t)},a,{"append-icon":l.showPassword?"mdi-eye":"mdi-eye-off",type:l.showPassword?"text":"password","error-messages":d[0],label:o.$t("fields.Password"),required:"",autocapitalize:"none","onClick:append":e[3]||(e[3]=t=>l.showPassword=!l.showPassword)}),null,16,["modelValue","append-icon","type","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.password_confirmation,"onUpdate:modelValue":e[6]||(e[6]=a=>l.password_confirmation=a),name:"password_confirmation"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.password_confirmation,"onUpdate:modelValue":e[5]||(e[5]=t=>l.password_confirmation=t)},a,{type:l.showPassword?"text":"password","error-messages":d[0],label:o.$t("fields.Confirm password"),required:"",autocapitalize:"none"}),null,16,["modelValue","type","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.title,"onUpdate:modelValue":e[8]||(e[8]=a=>l.title=a),name:"title"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(L,g({modelValue:l.title,"onUpdate:modelValue":e[7]||(e[7]=t=>l.title=t)},a,{"error-messages":d[0],items:l.titles,label:o.$t("fields.Title")+" *"}),null,16,["modelValue","error-messages","items","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.first_name,"onUpdate:modelValue":e[10]||(e[10]=a=>l.first_name=a),name:"first_name"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.first_name,"onUpdate:modelValue":e[9]||(e[9]=t=>l.first_name=t)},a,{"error-messages":d[0],label:o.$t("fields.First name")+" *",required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.last_name,"onUpdate:modelValue":e[12]||(e[12]=a=>l.last_name=a),name:"last_name"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.last_name,"onUpdate:modelValue":e[11]||(e[11]=t=>l.last_name=t)},a,{"error-messages":d[0],label:o.$t("fields.Last name")+" *",required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.postcode,"onUpdate:modelValue":e[15]||(e[15]=a=>l.postcode=a),name:"postcode"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.postcode,"onUpdate:modelValue":e[13]||(e[13]=t=>l.postcode=t)},a,{"error-messages":d[0],label:o.$t("fields.Postcode / ZIP code")+" *"}),null,16,["modelValue","error-messages","label"]),s(v,{onClick:e[14]||(e[14]=t=>b.postcodeLookup(l.postcode)),class:"mb-6"},{default:r(()=>[p(V(o.$t("buttons.Find address by UK postcode")),1)]),_:1})]),_:2},1032,["modelValue"]),l.addresses.length>0?(k(),C(L,{key:0,modelValue:l.address,"onUpdate:modelValue":e[16]||(e[16]=a=>l.address=a),items:l.addresses,label:"Choose address",autofocus:"",placeholder:"Select from addresses found"},null,8,["modelValue","items"])):U("",!0),s(m,{modelValue:l.address1,"onUpdate:modelValue":e[18]||(e[18]=a=>l.address1=a),name:"address1"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.address1,"onUpdate:modelValue":e[17]||(e[17]=t=>l.address1=t)},a,{"error-messages":d[0],label:o.$t("fields.Address line 1")+" *",required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.address2,"onUpdate:modelValue":e[20]||(e[20]=a=>l.address2=a),name:"address2"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.address2,"onUpdate:modelValue":e[19]||(e[19]=t=>l.address2=t)},a,{"error-messages":d[0],label:o.$t("fields.Address line 2"),required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.town,"onUpdate:modelValue":e[22]||(e[22]=a=>l.town=a),name:"town"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.town,"onUpdate:modelValue":e[21]||(e[21]=t=>l.town=t)},a,{"error-messages":d[0],label:o.$t("fields.Town")+" *",required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.county,"onUpdate:modelValue":e[24]||(e[24]=a=>l.county=a),name:"county"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.county,"onUpdate:modelValue":e[23]||(e[23]=t=>l.county=t)},a,{"error-messages":d[0],label:o.$t("fields.Province / County / State")}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.country,"onUpdate:modelValue":e[26]||(e[26]=a=>l.country=a),name:"country"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(Ce,{modelValue:l.country,"onUpdate:modelValue":e[25]||(e[25]=t=>l.country=t),items:b.countriesList,"item-title":"name","item-value":"code","error-messages":d[0],placeholder:o.$t("placeholder.Start typing to search")},{label:r(()=>[h("div",null,V(o.$t("fields.Country"))+" * ",1)]),_:2},1032,["modelValue","items","error-messages","placeholder"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.phone,"onUpdate:modelValue":e[28]||(e[28]=a=>l.phone=a),name:"phone"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.phone,"onUpdate:modelValue":e[27]||(e[27]=t=>l.phone=t)},a,{"error-messages":d[0],label:o.$t("fields.Phone number")+" *",required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.mobile,"onUpdate:modelValue":e[30]||(e[30]=a=>l.mobile=a),name:"mobile"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(c,g({modelValue:l.mobile,"onUpdate:modelValue":e[29]||(e[29]=t=>l.mobile=t)},a,{"error-messages":d[0],label:o.$t("fields.Mobile number"),required:""}),null,16,["modelValue","error-messages","label"])]),_:2},1032,["modelValue"]),s(m,{modelValue:l.language,"onUpdate:modelValue":e[32]||(e[32]=a=>l.language=a),name:"language"},{default:r(({field:a,errors:d,errorMessage:u})=>[s(L,g({modelValue:l.language,"onUpdate:modelValue":e[31]||(e[31]=t=>l.language=t)},a,{"error-messages":d[0],items:l.languages,"item-title":"name","item-value":"code",label:o.$t("fields.Preferred language")+" *"}),null,16,["modelValue","error-messages","items","label"])]),_:2},1032,["modelValue"]),s(Ue,{modelValue:l.newsletter,"onUpdate:modelValue":e[33]||(e[33]=a=>l.newsletter=a),"error-messages":w[0],label:o.$t("fields.Keep me updated with all the latest news from Helios"),required:""},null,8,["modelValue","error-messages","label"]),s(Pe,{modelValue:l.dialog,"onUpdate:modelValue":e[36]||(e[36]=a=>l.dialog=a),width:"600"},{default:r(()=>[s(D,null,{default:r(()=>[s(Se,{class:"text-h5 grey lighten-2"},{default:r(()=>[p(" EU Country Codes and VAT number formats ")]),_:1}),h("div",Ke,[s(v,{color:"primary",class:"ma-3",text:"",onClick:e[34]||(e[34]=a=>l.dialog=!1)},{default:r(()=>[p(V(o.$t("buttons.Close")),1)]),_:1})]),s(I,null,{default:r(()=>[s(P)]),_:1}),s(qe),s(Me,null,{default:r(()=>[s(Te),s(v,{color:"primary",text:"",onClick:e[35]||(e[35]=a=>l.dialog=!1)},{default:r(()=>[p(V(o.$t("buttons.Close")),1)]),_:1})]),_:1})]),_:1})]),_:1},8,["modelValue"]),h("div",ze,[l.recaptchaFailed?(k(),C(v,{key:0,onClick:b.resetRecaptcha,color:"error"},{default:r(()=>[p("reCAPTCHA failed: reset")]),_:1},8,["onClick"])):U("",!0),s(v,{tile:"",color:"primary",elevation:"0",loading:l.loading,onClick:b.handleSubmit},{default:r(()=>[p("submit")]),_:1},8,["loading","onClick"])])]),_:1},8,["onSubmit","onInvalidSubmit","validation-schema"]),s(W,null,{default:r(()=>[s(Y,{md:"6","offset-md":"3"})]),_:1})]),_:1})]),_:1})):U("",!0)]),_:1})]),_:1}),s(Ae,{modelValue:l.snackbar,"onUpdate:modelValue":e[38]||(e[38]=w=>l.snackbar=w),color:l.snackColor},{action:r(({attrs:w})=>[s(v,g({color:"#fff",text:""},w,{onClick:e[37]||(e[37]=M=>l.snackbar=!1)}),{default:r(()=>[p(V(o.$t("buttons.Close")),1)]),_:2},1040)]),default:r(()=>[p(V(l.snackText)+" ",1)]),_:1},8,["modelValue","color"])]),_:1}),s(q)])}const Ze=ie(Ie,[["render",Ge]]);export{Ze as default}; //# sourceMappingURL=Register-BplCowM5.js.map