(function () { // Don't block re-execution globally; only guard per-element const apiUrlNL = "https://api.medspacircle.com/api/v1/";//update const remoteCssNL = "https://api.medspacircle.com/embed/1/newleads.css";//update const serviceTokenNL="xGVmcrAcPDufdp1RAEkbM74TMkHuP5TQ";//update const fontFamilyNL = "Montserrat"; const linkUrlNLBase = "https://godev2.medspacircle.com/clinics/"; const loadStyles = () => { if (document.getElementById("__newleads_style")) return; const styleElement = document.createElement('style'); styleElement.id = "__newleads_style"; styleElement.textContent = ` #NewLeadsMCLoader { margin: 0 auto; width: 400px; } .formnewleads { text-align: left; } .invalid-feedback { display: none; } .invalid-feedback-show { color: #FFFFFF; background: #ca2c5b; margin-bottom: 5px; padding: 0 13px; } .rownewleads p { font-size: 115%; } .form-control.is-invalid, .was-validated .form-control:invalid { border-color: #dc3545; padding-right: calc(1.5em + .75rem); } .alert-success { color: #0f5132; background-color: #d1e7dd; border-color: #badbcc; } `; document.head.appendChild(styleElement); const googleFont = document.createElement('link'); googleFont.rel = 'stylesheet'; googleFont.href = `https://fonts.googleapis.com/css2?family=${encodeURIComponent(fontFamilyNL)}`; document.head.appendChild(googleFont); }; const cleanPhoneNumber = (phone) => { return phone.trim().replace(/^\+?1/, '').replace(/\D/g, ''); }; const createForm = (targetDiv) => { if (targetDiv.getAttribute('data-loaded') === 'true') return; targetDiv.setAttribute('data-loaded', 'true'); const slugNL = targetDiv.getAttribute("data-slug-id"); const clinicidNL = parseInt(targetDiv.getAttribute("data-clinic-id"), 10); const currentURL = window.location.href; targetDiv.innerHTML = `
`; const form = targetDiv.querySelector("#formMcNewLeads"); form.addEventListener("submit", function (event) { event.preventDefault(); const name = targetDiv.querySelector("#fmnl_name"); const email = targetDiv.querySelector("#fmnl_email"); const phone = targetDiv.querySelector("#fmnl_phone_number"); const resultDiv = targetDiv.querySelector("#formMcNewLeadsResult"); let valid = true; const validateField = (field, invalidId) => { if (!field.value.trim() || (field.id === 'fmnl_phone_number' && field.value.length < 9)) { field.classList.add("is-invalid"); targetDiv.querySelector(`#${invalidId}`).classList.remove("invalid-feedback"); targetDiv.querySelector(`#${invalidId}`).classList.add("invalid-feedback-show"); valid = false; } else { field.classList.remove("is-invalid"); targetDiv.querySelector(`#${invalidId}`).classList.add("invalid-feedback"); targetDiv.querySelector(`#${invalidId}`).classList.remove("invalid-feedback-show"); } }; validateField(name, "fmnl_name_invalid"); validateField(email, "fmnl_email_invalid"); validateField(phone, "fmnl_phone_number_invalid"); if (!valid) return; resultDiv.innerHTML = `