var contact={isPhoneValid:!1,onReady(){contact.refreshCaptcha(),contact.submitForm(),contact.phoneValidation()},getFormError(){let firstname=jQuery('#contactUs input[name="firstName"]').val(),lastname=jQuery('#contactUs input[name="lastName"]').val(),email=jQuery('#contactUs input[name="email"]').val(),message=jQuery("#contactUs textarea").val(),captcha=jQuery('#contactUs input[name="defaultRealInput"]').val();return firstname?lastname?email?contact.isPhoneValid?message?captcha?"success":"Enter the captcha.":"Enter a message.":"Enter a valid phone number.":"Enter an email address.":"Enter a last name.":"Enter a first name."},submitForm(){jQuery("#contactUs").on("submit",(function(e){e.preventDefault();var formError=contact.getFormError();if("success"!==formError)return AlertUtils.showAlert("error","Error!",formError),!1;loadingUtils.setLoading("SubmitForm",!0);let form=jQuery(this),formData=new FormData,fields=form.serializeArray();jQuery("input:file").val();fields.push({name:"defaultRealHash",value:$(form).find(".defaultRealCaptcha").realperson("getHash")}),fields.push({name:"locationId",value:window.pageInfo.locationID}),jQuery.each(fields,(function(key,input){formData.append(input.name,input.value)})),jQuery.ajax({url:"/api/async.php?t=email&m=contactus&a=submit_contact_form",method:"POST",contentType:!1,processData:!1,dataType:"json",data:formData,context:form,success(data){data.status?(AlertUtils.showAlert("success","Success",data.msg),contact.submissionTracking(formData),contact.resetForm(form)):AlertUtils.showAlert("error","Error",data.msg)},complete(){loadingUtils.setLoading("SubmitForm",!1)}})}))},submissionTracking(formData){if(window.hasOwnProperty("useGA4")&&window.useGA4?gtag("event","submit_contact_form",{locationID:window.pageInfo.locationID}):"function"==typeof ga&&ga.getAll().length?ga(ga.getAll()[0].get("name")+".send","event","site","contactFormSubmit",""):console.log("no ga function defined"),"function"==typeof fbq&&(fbq("track","ContactFormSubmit"),console.log("fired contact form fb event")),"object"==typeof klaviyo){console.log("firing klaviyo contact form event...");let emailAddress=formData.has("email")?formData.get("email"):"",firstName=formData.has("firstName")?formData.get("firstName"):"",lastName=formData.has("lastName")?formData.get("lastName"):"",phoneNumber=formData.has("telephone")&&formData.has("dialCode")?"+"+formData.get("dialCode")+formData.get("telephone").replace(/\D/g,""):"";klaviyo.identify({email:emailAddress,first_name:firstName,last_name:lastName});let data={EmailAddress:emailAddress,FirstName:firstName,LastName:lastName,PhoneNumber:phoneNumber};klaviyo.push(["track","Contact Form Submit",data])}},phoneValidation(){jQuery("body").on("isValidPhoneNumber",(function(response){contact.isPhoneValid=response.isPossibleNumber}))},refreshCaptcha(){jQuery("#contactUs .rp-refresh.btn").click()},resetForm(form){jQuery(form).find("input[type=text], input[type=email], input[type=tel], textarea").val(""),contact.refreshCaptcha()}};jQuery(document).ready((function($){contact.onReady()}));