document.addEventListener("DOMContentLoaded", () => {
    window.addEventListener("message", (event) => {
        if("hsFormCallback"===event.data.type&&"onFormSubmit"===event.data.eventName){let t=event.data.data,e="";t.forEach(t=>{"email"===t.name&&(e=t.value)}),fetch("/wp-json/digtective/v1/form-submission",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({email:e,sessionId:sessionStorage.getItem("sessionId")})}).then(t=>{console.log("Form submission sent to API",t)}).catch(t=>{console.error("Error submitting form to API:",t)})}
    });
});
