1import{_ as te}from"./CD3OIexP.js";import{J as j,a3 as U,a5 as ae,a6 as c,O as z,af as g,a9 as re,ar as m,aC as P,a8 as i,as as R,a2 as se,e as u,ac as w,u as oe,ad as ne,r as y,az as ie,ae as O,b as N}from"./CPHMDxSy.js";import{q as le,r as de,i as me,n as B,R as F}from"./BCVOGkAC.js";import{_ as ue}from"./DTKt8JxR.js";import{T as ce}from"./D2kax4VM.js";import{B as ge}from"./CwmQBgaN.js";import{F as fe}from"./DnPoj8m2.js";import{u as ve,M as pe}from"./DVHtKt2p.js";import{s as we,v as ye}from"./CB2b_Em4.js";import{v as he,r as Ee}from"./CSJFWBTC.js";import"./CdwwiKBJ.js";import{a as V,b as A}from"./B7I8KK-k.js";import{u as q}from"./CKXoXd47.js";import"./CIpF2gQE.js";import"./C2g_QCx2.js";import"./CKT0FQZm.js";import"./DDQlkgxm.js";const ke=["textContent"],Ce=["textContent"],Pe=["textContent"],Re=["textContent"],_e=["textContent"],be=["textContent"],xe=j({__name:"FormCustomerRegistrationData",props:{firstname:{},lastname:{},email:{},password:{},confirmPassword:{},validationErrors:{},globalError:{}},emits:["update:firstname","update:lastname","update:email","update:password","update:confirmPassword"],setup(s,{emit:h}){const f=s,v=h,_=u({get:()=>f.firstname,set:r=>v("update:firstname",r)}),b=u({get:()=>f.lastname,set:r=>v("update:lastname",r)}),k=u({get:()=>f.email,set:r=>v("update:email",r)}),a=u({get:()=>f.password,set:r=>v("update:password",r)}),p=u({get:()=>f.confirmPassword,set:r=>v("update:confirmPassword",r)});return(r,l)=>(U(),ae(fe,null,{default:c(()=>[s.globalError.length>0?(U(),z("span",{key:0,class:"errors",textContent:g(s.globalError)},null,8,ke)):re("",!0),m(i("span",{class:"errors",textContent:g(s.validationErrors.firstname)},null,8,Ce),[[P,s.validationErrors.firstname]]),m(i("input",{id:"firstname",type:"text",name:"firstname","onUpdate:modelValue":l[0]||(l[0]=o=>_.value=o),autocomplete:"given-name",placeholder:"First Name",minLength:"2",required:""},null,512),[[R,_.value]]),m(i("span",{class:"errors",textContent:g(s.validationErrors.lastname)},null,8,Pe),[[P,s.validationErrors.lastname]]),m(i("input",{id:"lastname",type:"text",name:"lastname","onUpdate:modelValue":l[1]||(l[1]=o=>b.value=o),autocomplete:"family-name",placeholder:"Last Name",minLength:"2",required:""},null,512),[[R,b.value]]),m(i("span",{class:"errors",textContent:g(s.validationErrors.email)},null,8,Re),[[P,s.validationErrors.email]]),m(i("input",{id:"email",type:"email",name:"email","onUpdate:modelValue":l[2]||(l[2]=o=>k.value=o),autocomplete:"username",placeholder:"Email",required:""},null,512),[[R,k.value]]),m(i("span",{class:"errors",textContent:g(s.validationErrors.password)},null,8,_e),[[P,s.validationErrors.password]]),m(i("input",{type:"password",name:"password","onUpdate:modelValue":l[3]||(l[3]=o=>a.value=o),autocomplete:"new-password",placeholder:"Password",minLength:"8",required:""},null,512),[[R,a.value]]),m(i("span",{class:"errors",textContent:g(s.validationErrors.password)},null,8,be),[[P,s.validationErrors.password]]),m(i("input",{type:"password",name:"new-password","onUpdate:modelValue":l[4]||(l[4]=o=>p.value=o),autocomplete:"new-password",placeholder:"Confirm Password",minLength:"8",required:""},null,512),[[R,p.value]]),se(r.$slots,"default")]),_:3}))}}),Te={id:"register-container"},Oe={class:"center green"},Ve={class:"errors center"},Ae="An account already exists with this email address. Please login or reset your password. If you have not registered and have been a customer in the past, click 'Activate Existing Account' below.",Ge=j({__name:"register",setup(s){le("Customer Registration");const h=de("customer-auth"),{loggedIn:f,fetch:v}=me(),{modalController:_,showVerifyOTP:b,closeVerifyOTP:k}=ve();f.value&&B({name:"Account Orders"});const a=N({email:"",firstname:"",lastname:"",password:""}),p=y(""),r=N({firstname:null,lastname:null,email:null,password:null}),l=y(""),o=y(""),x=y(!1),H=y(!1),L=y(!1),S=u(()=>!W.value||x.value),T=u(()=>x.value||H.value||L.value),W=u(()=>!(a.firstname?.length===0||a.lastname?.length===0||a.email?.length===0||a.password.length===0||p.value.length===0||a.password!==p.value)),D=(t,e,d)=>{h.debug({event:e,message:d,other:{errorKey:t.key}})},I=t=>t instanceof F&&(t.key==="email"||t.key==="request")?(r.email="Enter a valid email address",D(t,"customer_auth.registration.start.validation_failed","Customer registration start validation failed"),!0):!1,J=t=>t instanceof F&&(t.key==="OTP"||t.key==="email"||t.key==="token"||t.key==="request")?(E.value="Invalid or expired code",D(t,"customer_auth.registration.complete.validation_failed","Customer registration completion validation failed"),!0):!1,K=t=>t.key==="email"&&t.message.toLowerCase().includes("already exists")?Ae:t.message,$=async()=>{G(),await q(x,async()=>{await V(async()=>{await A(async()=>{E.value="";let t;try{t=await he(a)}catch(e){if(I(e))return;throw e}if(t.length>
10){t.forEach(e=>{r[e.key]=K(e)});return}try{o.value=await we(a.email)}catch(e){if(I(e))return;throw e}b()},{logger:h,log:{server:{event:"customer_auth.registration.start.server_error_handled",message:"Handled customer registration start server error"},network:{event:"customer_auth.registration.start.network_error_handled",message:"Handled customer registration start network error"},unknown:{event:"customer_auth.registration.start.unknown_error_handled",message:"Handled customer registration start unknown error"}}})})})},G=()=>{r.firstname=null,r.lastname=null,r.email=null,r.password=null},E=y(""),M=()=>{o.value="",E.value=""},Q=()=>{T.value||(M(),k())},X=async t=>{await q(H,async()=>{await V(async()=>{await A(async()=>{if(E.value="",!await ye(a.email,o.value,t)){E.value="Invalid Code";return}await Y(t)},{logger:h,log:{server:{event:"customer_auth.registration.otp_verify.server_error_handled",message:"Handled registration OTP verification server error"},network:{event:"customer_auth.registration.otp_verify.network_error_handled",message:"Handled registration OTP verification network error"},unknown:{event:"customer_auth.registration.otp_verify.unknown_error_handled",message:"Handled registration OTP verification unknown error"}}})})})},Y=async t=>{await q(L,async()=>{await V(async()=>{await A(async()=>{await Z(t)},{logger:h,log:{server:{event:"customer_auth.registration.complete.server_error_handled",message:"Handled customer registration completion server error"},network:{event:"customer_auth.registration.complete.network_error_handled",message:"Handled customer registration completion network error"},unknown:{event:"customer_auth.registration.complete.unknown_error_handled",message:"Handled customer registration completion unknown error"}}})})})},Z=async t=>{let e;try{e=await Ee(o.value,t,a)}catch(C){if(J(C))return;throw C}const{customer:d,validationErrors:n}=e;if(n.length>0){n.forEach(C=>{r[C.key]=C.message});return}else d&&(await v(),M(),k(),await B({name:"Account Orders"}))},ee=u(()=>{const t="[email protected]",e=encodeURI("Activate Customer Account Request");let d=`Please activate my account using email address: 2 3`;return a.email?d+=a.email:d+="[provide your email address here]",d=encodeURI(d),`mailto:${t}?subject=${e}&body=${d}`});return(t,e)=>{const d=te;return U(),z(ne,null,[w(ue,null,{header:c(()=>[w(ce,{title:"Register"})]),default:c(()=>[i("div",Te,[w(xe,{firstname:a.firstname,"onUpdate:firstname":e[0]||(e[0]=n=>a.firstname=n),lastname:a.lastname,"onUpdate:lastname":e[1]||(e[1]=n=>a.lastname=n),email:a.email,"onUpdate:email":e[2]||(e[2]=n=>a.email=n),password:a.password,"onUpdate:password":e[3]||(e[3]=n=>a.password=n),confirmPassword:p.value,"onUpdate:confirmPassword":e[4]||(e[4]=n=>p.value=n),validationErrors:r,globalError:l.value,"onUpdate:globalError":e[5]||(e[5]=n=>l.value=n)},{default:c(()=>[w(ge,{onClick:$,disabled:S.value,class:ie({disabled:S.value})},{default:c(()=>[...e[6]||(e[6]=[O("Submit",-1)])]),_:1},8,["disabled","class"]),w(d,{class:"formSimple-link",to:{name:"Customer Login"}},{default:c(()=>[...e[7]||(e[7]=[O("Already have an account?",-1)])]),_:1}),w(d,{class:"formSimple-link",href:ee.value},{default:c(()=>[...e[8]||(e[8]=[O("Activate Existing Account",-1)])]),_:1},8,["href"])]),_:1},8,["firstname","lastname","email","password","confirmPassword","validationErrors","globalError"])])]),_:1}),w(pe,{modalController:oe(_),isCancelDisabled:T.value,isResendDisabled:T.value,onCancel:Q,onOnOTPComplete:X,onResendOTP:$},{default:c(()=>[i("h4",Oe,g(a.email),1),e[9]||(e[9]=i("p",null,"We sent a 4-digit code to the email address you provided. Please enter it below to verify your email address.",-1)),i("p",Ve,g(E.value),1)]),_:1},8,["modalController","isCancelDisabled","isResendDisabled"])],64)}}});export{Ge as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.