1import{Combobox as D}from"./combobox-BIZlKaGA.js";import{a as T}from"./input-mask-BEBFWImt.js";import{t as y,a as C}from"./track-BjSCo8vP.js";import{e as F}from"./turnstile-loader-B8ke1ZFV.js";const g=new Map,M=/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;function _(e){return e?M.test(e)&&e.length>=6:!1}function q(e){if(!e)return!1;const t=/^[0-9()\-.\s]+$/,o=e.replace(/\D/g,"");return t.test(e)&&o.length>=10}function O(e,t){switch(e){case 1:return t%4===0&&t%100||t%400===0?29:28;case 8:case 3:case 5:case 10:return 30;default:return 31}}function I(e){if(!e)return!1;const t=e.split("/");if(t.length===3){let o=parseInt(t[0],10)-1;const r=Number(t[1]),a=t[2];return a.length===4&&o>=0&&o<12&&r>0&&r<=O(o,Number(a))&&new Date(e)<new Date&&new Date(e).getFullYear()>=1900}return!1}function b(e){const o=e.parentElement?.querySelector("span.error");o&&o.remove(),e.classList.remove("error")}function m(e,t=""){b(e),e.classList.remove("error"),e.classList.add("error");const o=document.createElement("span");o.classList.add("error"),o.innerText=t===""?"Field is required":"Field is not a valid "+t,e.after(o)}function w(e){const t=e.target;t.required&&t.value.trim()===""?m(t):t.value.trim()!==""&&t.type==="email"&&!_(t.value.trim())?m(t,"email"):t.value.trim()!==""&&t.type==="tel"&&!q(t.value.trim())?m(t,"phone"):b(t)}function A(e){const t=e.target,o=t.value;o.trim()!==""&&o.length===10&&(b(t),I(o)||m(t,"date"))}function k(e){if(!e.config.isOrganization)return;const t=document.getElementById("select-location"),o=t?t.closest(".v-select")||t.parentNode:null;if(!(!o||!(o instanceof Element)))if(e.locationSelected){const r=o.parentElement?.querySelector("span.error");r&&r.remove()}else{const r=document.createElement("span");r.classList.add("error"),r.innerText="Please select a location.",o.classList.add("error"),o.after(r)}}function j(e){document.querySelectorAll(".entry span.error").forEach(r=>r.remove()),document.querySelectorAll(".error").forEach(r=>r.classList.remove("error"));let t=!0;Array.from(e.elements).forEach(r=>{const a=r;if(a.required===!0&&a.value.trim()==="")m(a),t=!1;else if(a.type==="search"){const n=a.closest(".entry .v-select");if(n){const s=n.querySelector(".vs__selected-options .vs__selected");n.classList.contains("required")&&s==null&&(m(n),t=!1)}}else a.value.trim()!==""&&a.type==="email"&&!_(a.value.trim())?(m(a,"email"),t=!1):a.value.trim()!==""&&a.type==="tel"&&!q(a.value.trim())&&(m(a,"phone"),t=!1)});const o=document.querySelector(".error");return o&&o.scrollIntoView({behavior:"smooth"}),t}function z(e){return"tel:+"+e.replace(/\D/g,"")}function B(e){const t=document.createElement("div");if(t.className="confirmation",t.setAttribute("role","status"),t.setAttribute("aria-live","polite"),e.config.isOrganization&&e.selectedLocation){const o=document.createElement("h3");
1o.textContent="Thank you";const r=document.createElement("p");r.textContent=`Thanks for contacting ${e.selectedLocation.name}. Our team has received your message and will get back to you soon.`;const a=document.createElement("p");a.append("Should you require immediate assistance, please contact us directly at ");const n=document.createElement("a");n.className="cta text underline",n.href=z(e.selectedLocation.phone_number),n.textContent=e.selectedLocation.phone_number,a.append(n),t.append(o,r,a)}else t.innerHTML=e.config.confirmationMessage??"";e.form.replaceWith(t)}async function P(e){const{form:t,config:o}=e,r=o.formName??t.getAttribute("name")??"";y("Form","Submit Clicked",r,{page_path:window.location.pathname});const a=t.querySelector('input[type="submit"]'),n=new FormData(t),s=j(t);for(const h of Object.keys(e.selectData))n.append(h,e.selectData[h]);k(e);const f=t.querySelector("[type='email']");if(f&&n.append("reply_to",f.value),!s)return;a&&(a.disabled=!0),n.append("_formName",t.getAttribute("name")??""),e.selectedLocation&&n.append("location",JSON.stringify(e.selectedLocation));const l=window;await F(),await l.turnstile.render("#"+t.getAttribute("name"),{sitekey:o.turnstileKey??void 0,callback:h=>{n.append("turnstile_token",h);const u={};for(const[c,i]of n.entries()){const d=u[c];d!==void 0?Array.isArray(d)?d.push(i):u[c]=[d,i]:u[c]=i}if(o.organizationId===78&&(t.getAttribute("name")??"").toLowerCase()==="contact"){const c=l.UTMTracker?.get?.();if(c)for(const i of["utm_source","utm_medium","utm_campaign","utm_content","utm_term","gclid","fbclid"])c[i]&&(u[i]=c[i])}fetch("/api/form/submit",{method:"POST",headers:{"g-path":window.location.pathname,"Content-Type":"application/json",Accept:"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({data:u})}).then(c=>c.json()).then(c=>{a&&(a.disabled=!1);const i=t.querySelector("#form-error-summary");if(i&&(i.textContent=""),t.querySelector("#form-error")?.remove(),c==="success")l.turnstile?.remove(),l.dataLayer=l.dataLayer||[],l.dataLayer.push({event:"contact_form"}),y("Form","Submit",r,{page_path:window.location.pathname}),C(2),B(e);else{const d=c?.errors;d&&d.length&&(d.forEach(E=>{const L=Object.keys(E).toString(),v=document.getElementById(L);if(!v)return;const x=v.parentElement,N=Object.values(E).toString();v.classList.add("error"),v.setAttribute("aria-invalid","true");const S=`${L}-error`;v.setAttribute("aria-describedby",S);let p=x.getElementsByTagName("span")[0];p||(p=document.createElement("span")),p.classList.add("error"),p.id=S,p.setAttribute("role","alert"),p.innerText=N,v.after(p)}),i&&(i.textContent="We are unable to process your form at this time. Please correct the highlighted fields and try again, or give us a call.",i.focus()))}})}})}function $(e){const t=[...e.config.locations??[]].sort((o,r)=>o.name.localeCompare(r.name));e.form.querySelectorAll("[data-combobox]").forEach(o=>{const a=o.querySelector(".vs__dropdown-toggle")?.id.match(/^vs(\d+)__combobox$/),n=a?Number(a[1]):1,s=o.hasAttribute("data-location"),f=o.dataset.comboboxName??o.getAttribute("name")??"";let l;if(s)l=t.map(u=>u.name);else try{l=JSON.parse(o.dataset.options??"[]")}catch{l=[]}const h=new D({root:o,uid:n,options:l,appendToBody:!1,showSelected:!0,callbacks:{onSelect:u=>{s?(e.selectedLocation=t.find(c=>c.name===u)??null,e.locationSelected=!0,k(e),y("Form","Location Selected",e.config.formName??"",{location_name:u,page_path:window.location.pathname})):(e.selectData[f]=u,b(o))}}});e.comboboxes.push(h)})}function W(e,t={}){if(!(e instanceof HTMLFormElement)||g.has(e))return;const o={form:e,config:t,comboboxes:[],selectData:{},selectedLocation:null,locationSelected:!1,detach:[]};g.set(e,o);const r=t.formName??e.getAttribute("name")??"",a=()=>{y("Form","Started",r,{page_path:window.location.pathname})};e.addEventListener("focusin",a,{once:!0}),o.detach.push(()=>e.removeEventListener("focusin",a)),$(o),e.querySelectorAll("[data-vfield]").forEach(s=>{s.addEventListener("focusout",w),o.detach.push(()=>s.removeEventListener("focusout",w))}),e.querySelectorAll("[data-vdate]").forEach(s=>{s.addEventListener("keyup",A),o.detach.push(()=>s.removeEventListener("keyup",A))}),e.querySelectorAll("[data-mask]").forEach(s=>{const f=s.dataset.mask;f&&o.detach.push(T(s,f))});const n=s=>{s.preventDefault(),P(o)};e.addEventListener("submit",n),o.detach.push(()=>e.removeEventListener("submit",n))}
1function X(){g.forEach(e=>{e.detach.forEach(t=>t()),e.comboboxes.forEach(t=>t.destroy())}),g.clear()}export{X as destroy,W as initialize};
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.