1const SELECTORS=window.SELECTORS||{container:"[data-register-container]",countryWrapper:"[data-countries-wrapper]",firstnameInput:"#FirstName",lastnameInput:"#LastName",emailInput:"#Email",passwordInput:"#CreatePassword",passwordLengthError:"[data-password-error]",birthDayInput:"#birth_day",birthMonthInput:"#birth_month",form:"form",submitButton:"[data-button]",noLabelsFix:"[data-nolabel-fix]",birthdayHiddenInput:"[data-birthday]",phoneInput:"#Phone",countryValue:"#AddressCountry"},FORM_KEYS={email:"customer[email]",firstName:"customer[first_name]",lastName:"customer[last_name]",password:"customer[password]",countryCode:"country_code",birthDay:"birth_day",birthMonth:"birth_month",phone:"customer[phone]"};document.addEventListener("DOMContentLoaded",()=>{const container=document.querySelector(SELECTORS.container);addFormSubmission(container)});const INVALID_DATES=["30-02","31-02","31-04","31-06","31-09","31-11"];function addFormSubmission(container){const form=container.querySelector(SELECTORS.form),button=container.querySelector(SELECTORS.submitButton);button.addEventListener("click",async event=>{event.preventDefault(),form.removeAttribute("onsubmit");const[passwordInput,passwordLengthError,dayInput,monthInput,phoneInput,countryInput,...requiredInputs]=[SELECTORS.passwordInput,SELECTORS.passwordLengthError,SELECTORS.birthDayInput,SELECTORS.birthMonthInput,SELECTORS.phoneInput,SELECTORS.countryValue,SELECTORS.firstnameInput,SELECTORS.lastnameInput,SELECTORS.emailInput].map(selector=>container.querySelector(selector));if(showOrHideValidations(requiredInputs,passwordInput,passwordLengthError,dayInput,monthInput,phoneInput,countryInput),formIsValid(requiredInputs,passwordInput,dayInput,monthInput,phoneInput,countryInput)){console.log("isValid"),button.setAttribute("disabled",!0),button.innerText="Joining the Beach Club...";var customerValid;try{customerValid=await checkProfileCompletion(container.dataset.klaviyoCustomerListId,form)}catch(e){console.log("error",e)}if(!customerValid)form.querySelector('[name="return_to"]').value="/account/login";else try{await sendToKlaviyo(container.dataset.klaviyoCustomerListId,form)}catch(e){console.log("error",e)}form.submit()}}),form.addEventListener("change",event=>{const requiredInputs=[SELECTORS.firstnameInput,SELECTORS.lastnameInput,SELECTORS.emailInput,SELECTORS.passwordInput].map(selector=>container.querySelector(selector));allMandatoryFields(requiredInputs)?form.querySelector(SELECTORS.submitButton).removeAttribute("disabled"):form.querySelector(SELECTORS.submitButton).setAttribute("disabled",!0)})}function showOrHideValidations(requiredInputs,passwordInput,passwordLengthError,dayInput,monthInput,phoneInput,countryInput){passwordInput.value?passwordInput.value.length<5?(passwordInput.classList.add("input-error"),passwordInput.nextElementSibling.classList.add("hide"),passwordLengthError.classList.remove("hide")):(passwordInput.classList.remove("input-error"),passwordInput.nextElementSibling.classList.add("hide"),passwordLengthError.classList.add("hide")):(passwordInput.classList.add("input-error"),passwordInput.nextElementSibling.classList.remove("hide"),passwordLengthError.classList.add("hide")),dayInput.value&&!monthInput.value?(dayInput.classList.remove("input-error"),monthInput.classList.add("input-error"),dayInput.parentElement.nextElementSibling.classList.remove("hide")):!dayInput.value&&monthInput.value||INVALID_DATES.includes(`${dayInput.value}-${monthInput.value}`)?(dayInput.classList.add("input-error"),monthInput.classList.remove("input-error"),dayInput.parentElement.nextElementSibling.classList.remove("hide")):(dayInput.classList.remove("input-error"),monthInput.classList.remove("input-error"),dayInput.parentElement.nextElementSibling.classList.add("hide")),requiredInputs.forEach(input=>{input.value?(input.classList.remove("input-error"),input.nextElementSibling.classList.add("hide")):(input.classList.add("input-error"),input.nextElementSibling.classList.remove("hide"))}),phoneInput.value.length>0&&(validatePhone(phoneInput.value,countryInput)?(phoneInput.classList.remove("input-error"),phoneInput.closest(".phone-input-container").nextElementSibling.classList.add("hide")):(phoneInput.classList.add("input-error"),phoneInput.closest(".phone-input-container").nextElementSibling.classList.remove("hide")))}const formIsValid=(requiredInputs,passwordInput,dayInput,monthInput,phoneInput,countryInput)=>requiredInputs.every(({value})=>!!value)&&passwordInput.value&&passwordInput.value.length>=5&&(dayInput.value&&monthInput.value||!dayInput.value&&!monthInput.value)&&!INVALID_DATES.includes(`${dayInput.value}-${monthInput.value}`)&&(validatePhone(phoneInput.value,countryInput)||phoneInput.value.length===0),allMandatoryFields=requiredInputs=>requiredInputs.every(({value})=>!!value);async function checkProfileCompletion(listId,form){const formData=new FormData(form);let response;if(!listId)return console.log("no list ID"),reportKlaviyoSubmissionFailure(form,formData),!1;try{const data=await(await fetch(window.datajetUrl,{method:"POST",body:formData})).json();return console.log(data),data.status==="ok"}catch{return console.log("error",error),!1}}async function sendToKlaviyo(listId,form,retryCount=1){const formData=Object.fromEntries(new FormData(form));let response;if(!listId){console.log("no list ID"),reportKlaviyoSubmissionFailure(form,formData);return}try{response=await fetch("https://manage.kmail-lists.com/ajax/subscriptions/subscribe",{method:"POST",headers:{"content-type":"application/x-www-form-urlencoded","cache-control":"no-cache"},body:new URLSearchParams(Object.entries({g:listId,email:formData[FORM_KEYS.email],phone_number:formatPhoneNumber(formData[FORM_KEYS.phone],formData[FORM_KEYS.countryCode]),$fields:"$source, $first_name, $last_name, $birthday, $countryCode, $phone",$source:"Account Creation",$first_name:formData[FORM_KEYS.firstName],$last_name:formData[FORM_KEYS.lastName],$birthday:formatBirthday(formData),$countryCode:formData[FORM_KEYS.countryCode]})).toString()})}catch(error2){console.log("error",error2),window.console.error(error2)}if((!response||!response.ok)&&(retryCount<3?await sendToKlaviyo(listId,form,retryCount+1):reportKlaviyoSubmissionFailure(form,formData)),formData[FORM_KEYS.phone].length>
10){const note=document.createElement("input");note.setAttribute("name","customer[note][phone]"),note.style.display="none",note.setAttribute("value",`${formatPhoneNumber(formData[FORM_KEYS.phone],formData[FORM_KEYS.countryCode])}`),form.appendChild(note)}console.log(formData)}function reportKlaviyoSubmissionFailure(form,formData){const note=document.createElement("input");note.setAttribute("name","customer[note][signup_error]"),note.style.display="none",note.setAttribute("value",`This customer was unsuccessfully submitted to Klaviyo with the following additional information: 2 ${formatBirthday(formData)&&`- $birthday: ${formatBirthday(formData)}`} 3 - $countryCode: ${formData[FORM_KEYS.countryCode]}`),form.appendChild(note)}function formatPhoneNumber(input,country){if(input.replace(/-|\s/g,""),country==="AU")return"+61"+input;if(country==="NZ")return"+64"+input;if(country==="SG")return"+65"+input;if(country==="US"||country==="US")return"+1"+input;if(country==="GB")return"+44"+input}function validatePhone(input,country){console.log(country.value);let regex;return country.value==="AU"?regex=/^(?:\d{9}|\d{3}-\d{3}-\d{3}|\d{3} \d{3} \d{3})$/:country.value==="NZ"||country.value==="US"||country.value==="CA"?regex=/^(?:\d{10}|\d{3}-\d{3}-\d{3}|\d{3} \d{3} \d{3})$/:country.value==="SG"?regex=/^(?:\d{8}|\d{3}-\d{3}-\d{3}|\d{3} \d{3} \d{3})$/:country.value==="GB"&&(regex=/^(?:\d{10}|\d{3}-\d{3}-\d{3}|\d{3} \d{3} \d{3})$/),regex.test(input)}function formatBirthday(formData){return`${new Date().getFullYear()}-${formData[FORM_KEYS.birthMonth]}-${formData[FORM_KEYS.birthDay]}`} 4//# sourceMappingURL=/cdn/shop/t/611/assets/register.js.map?v=86264862324854591621790236889
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.