(()=>{function T(R){let $=`; ${document.cookie}`.split(`; ${R}=`);if($.length===2)return $.pop()?.split(";").shift()||null;return null}function x(R,C,$=30){let U=new Date;U.setTime(U.getTime()+$*24*60*60*1000);let _=`expires=${U.toUTCString()}`;document.cookie=`${R}=${C};${_};path=/`}async function H({apiUrl:R,urlParams:C,url:$}){let U=T("dni_visitor_id");return fetch(R,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({urlParams:C,visitorId:U||void 0,url:$})}).then((z)=>z.json())}function w(R,C=document){let{swapTargets:$,phoneNumber:U}=R,_=(y)=>y.replace(/\D/g,""),z=new Set,v=new Set;$.forEach((y)=>{z.add(_(y.nationalNumber)),v.add(_(y.e164))});let B=_(U.nationalNumber),Z=_(U.e164),K=/(\+?1?[-.\s]?)?\(?\d{3}\)?[-.\s\w]*\d{3}[-.\s\w]*\d{4}|\+?1?\d{10}/g,q=(y)=>{if(z.has(y)||v.has(y))return!0;for(let L of z)if(y.endsWith(L)){for(let M of v)if(y.length===M.length)return!0}for(let L of z)if(y.includes(L))return!0;return!1},O=(y)=>{let L=_(y);if(!q(L))return y;let M;if(L.length>=11)M=Z;else M=B;let V="",X=0;for(let j=0;j{if(K.lastIndex=0,y.textContent)y.textContent=y.textContent.replace(K,O)}),C.querySelectorAll('a[href^="tel:"]').forEach((y)=>{let L=_(y.href);if(q(L))y.href="tel:"+U.e164})}function b(R){return"fbp"in R&&"ev"in R}function E(R){let C=Object.fromEntries(new FormData(R).entries());if(b(C))return null;return C}function P(R,C){if(C.dni)C.dni.forEach((q)=>w(q));N(C.sessionId);let $=new WeakSet,U=new WeakSet,_=()=>{return(q)=>{let O=q.target;if(!O?.reportValidity())return;if($.has(O))return;$.add(O);let A=E(O);if(!A)return;W(R,C.sessionId,A)}};document.addEventListener("submit",_(),!0);let z=HTMLFormElement.prototype.submit;HTMLFormElement.prototype.submit=function(){if(this.reportValidity()&&!$.has(this)){$.add(this);let q=E(this);if(q)W(R,C.sessionId,q)}return z.call(this)};let v=(q)=>{if(U.has(q))return;try{let O=q.contentDocument||q.contentWindow?.document;if(!O)return;if(U.add(q),O.addEventListener("submit",_(),!0),C.dni)C.dni.forEach((A)=>w(A,O))}catch{}};document.querySelectorAll("iframe").forEach((q)=>{if(q.contentDocument?.readyState==="complete")v(q);else q.addEventListener("load",()=>v(q))}),new MutationObserver((q)=>{for(let O of q)O.addedNodes.forEach((A)=>{if(A instanceof HTMLIFrameElement)if(A.contentDocument?.readyState==="complete")v(A);else A.addEventListener("load",()=>v(A));if(A instanceof HTMLFormElement)G(A,C.sessionId);if(A instanceof HTMLElement)A.querySelectorAll("iframe").forEach((J)=>{if(J.contentDocument?.readyState==="complete")v(J);else J.addEventListener("load",()=>v(J))}),A.querySelectorAll("form").forEach((J)=>{G(J,C.sessionId)})})}).observe(document.body,{childList:!0,subtree:!0});let Z=!1,K=()=>{if(Z)return;if(typeof window.jQuery<"u"&&typeof window.gform<"u")Z=!0,window.jQuery(document).on("gform_confirmation_loaded",function(q,O){let A=document.getElementById(`gform_${O}`);if(A&&!$.has(A)){$.add(A);let J=E(A);if(J)W(R,C.sessionId,J)}})};if(K(),document.readyState==="loading")document.addEventListener("DOMContentLoaded",K);setTimeout(K,1000)}function G(R,C){if(R.querySelector('input[name="aim_session_id"]'))return;let $=document.createElement("input");$.type="hidden",$.name="aim_session_id",$.value=C,R.appendChild($)}function N(R){document.querySelectorAll("form").forEach((C)=>{G(C,R)})}function W(R,C,$){fetch(`${R}/form-submission`,{method:"POST",keepalive:!0,headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:C,formData:$,submissionUrl:window.location.href})})}var F=document.currentScript;(async()=>{let R=F?.getAttribute("src");if(!R)return;let C=R.substring(0,R.lastIndexOf("/")),$=await H({apiUrl:`${C}/session`,urlParams:window.location.search.substring(1),url:window.location.href});if(!$.success)return;x("dni_visitor_id",$.visitorId),P(C,$)})();})();