document.addEventListener("DOMContentLoaded",(function(){const e=document.getElementById("contactForm"),t=document.getElementById("contact-module"),n=document.getElementById("phone");n.addEventListener("input",(function(){this.value=(e=>{let t=this.value.replace(/\D/g,"");t=t.substring(0,10);const n=t.substring(0,3),s=t.substring(3,6),o=t.substring(6,10);return t.length>6?`(${n}) ${s}-${o}`:t.length>3?`(${n}) ${s}`:t.length>0?`(${n}`:""})()})),e.addEventListener("submit",(async function(e){e.preventDefault();const s=document.getElementById("name").value,o=document.getElementById("email").value,r=n.value,u=document.getElementById("subject").value,a=document.getElementById("message").value,i={name:s,email:o,phone:r,subject:u,message:a};try{const e=await fetch("/api/contact",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(i)});if(e.ok){t.innerHTML="",t.innerHTML=`
\n
\n

Thank you ${s}, your message has been sent.

Preview:
Email: ${o}
Phone: ${r}
Subject: ${u}
Message: ${a}

\n
\n

Please allow up to 48 hours for a response!

\n
\n
`;var m=window._paq||[];m.push(["setCustomDimension",1,s]),m.push(["setCustomDimension",2,o]),m.push(["setCustomDimension",3,r]),m.push(["setCustomDimension",4,u]),m.push(["setCustomDimension",5,a]),m.push(["trackEvent","Contact Form Submitted","Hire Me",u])}else console.error("Error submitting the form:",e.status)}catch(e){console.error("Network error:",e)}}))}));