import{z as b,A as C,C as U,B as M,D as T}from"./bundle.js";const l=new Map,k=e=>{var t;if(!((t=e.applyToUrls)!=null&&t.length))return!0;if(l.has(e.identifier))return l.get(e.identifier);if(!e.applyToUrls)return l.set(e.identifier,!0),!0;for(const n of e.applyToUrls){const r=n.value??"";let c;try{c=new URL(r).pathname.replace(/^\/+|\/+$/g,"")}catch{c=r.replace(/^\/+|\/+$/g,"")}if(b({value:c,actual:e.pathname,matchBy:n.matchBy}))return l.set(e.identifier,!0),!0}return l.set(e.identifier,!1),!1},m=e=>{const t=e.url.pathname.replace(/^\/+|\/+$/g,"");if(!k({pathname:t,applyToUrls:e.applyToUrls,identifier:e.identifier}))return;const r=e.selectors.join(",");e.callback(r)},u=async(e,t)=>{var n;await((n=window.igEvents)==null?void 0:n.push({type:"track",event:t,source:void 0,properties:{id:C(),type:e,identifier:t}}))};window.__igce=u;const S=new Map,_=new Map,f=new Map,L=(e,t=50)=>{const n=Date.now(),r=f.get(e);if(r&&n-r<=t){f.set(e,n+t);return}u("clickEvent",e),f.set(e,n+t)},j=(e,t)=>{var n;for(;e;){if((n=e.matches)!=null&&n.call(e,t))return e;e=e.parentElement}return null},B=e=>{document.addEventListener("click",t=>{const n=t.target;j(n,e.selectors)&&L(e.customEvent.identifier)},{capture:!0})},I=e=>{m({url:e.url,applyToUrls:e.customEvent.applyToUrls,identifier:e.customEvent.identifier,selectors:e.customEvent.settings.selectors,selectorCache:S,elementCache:_,callback:t=>{B({...e,selectors:t})}})},$=new Map,o=new Map;let a=null;const h=new Map;let g=null;function V(e){if(!e.target.isConnected)return d(e.target),!1;const t=window.getComputedStyle(e.target,null);return t.display!=="none"&&t.visibility!=="hidden"&&t.opacity!=="0"&&t.height!=="0px"&&t.width!=="0px"&&e.target.getBoundingClientRect().width>0&&e.target.getBoundingClientRect().height>0}function d(e){a&&a.unobserve(e),o.delete(e)}function w(e,t){return Array.from(e.querySelectorAll(t))}function x(e){for(const t of e){let n=null;for(const[r,c]of h)if(t.target.matches(r)){n=c;break}if(n)if(t.isIntersecting)V(t)&&n.selectorCallback();else{const r=o.get(t.target);r&&(r.delete(n.customEvent.identifier),r.size===0&&d(t.target))}}}function E(e,t,n=50){a||(a=new IntersectionObserver(x,{root:null,rootMargin:`${n}px`,threshold:[0,.1,.5,1]}));let r=o.get(e);r||(r=new Set,o.set(e,r)),r.add(t.identifier),a.observe(e)}function D(){g||(g=new MutationObserver(e=>{let t=!1;e.forEach(n=>{n.removedNodes.forEach(r=>{r instanceof Element&&(d(r),r.querySelectorAll("*").forEach(d))}),(n.addedNodes.length>0||n.type==="attributes"||n.type==="childList")&&(t=!0)}),t&&h.forEach(({customEvent:n},r)=>{w(document,r).filter(s=>!o.has(s)).forEach(s=>{E(s,n)})})}),g.observe(document.body,{childList:!0,subtree:!0,attributes:!0}))}const p=new Set;function O(e){p.has(e.identifier)||(u("elementViewed",e.identifier),p.add(e.identifier))}function A(e){D();const t=e.settings.selectors.join(",");h.set(t,{customEvent:e,selectorCallback:()=>O(e)}),w(document,t).forEach(n=>{E(n,e)})}const P=e=>{const{url:t,customEvent:n}=e;m({url:t,applyToUrls:n.applyToUrls,identifier:n.identifier,selectors:n.settings.selectors,selectorCache:$,elementCache:o,callback:()=>A(n)})},R=e=>{const t=`function sendEvent(){window?.__igce && window.__igce("javascriptEvent", "${e.customEvent.identifier}");}`,n=document.createElement("script");n.innerHTML=t+e.customEvent.settings.code,n.type="text/javascript",n.id=`${U.CUSTOM_JS_ID_KEY}-${e.customEvent.identifier}`,document.head.appendChild(n)};function J(e,t){const n=async()=>{const r=window.scrollY,c=window.innerHeight,s=document.documentElement.scrollHeight;(r+c)/s*100>=e&&(t(),window.removeEventListener("scroll",n))};window.addEventListener("scroll",n)}const z=window.matchMedia("(max-width: 767px)"),K=e=>{const t=()=>J(z.matches?e.customEvent.settings.mobile.percentage:e.customEvent.settings.desktop.percentage,()=>void u("scrollDepth",e.customEvent.identifier));document.readyState==="complete"?t():window.addEventListener("load",()=>{t()})},v=new URL(window.location.href);let i;function q(){if(!i){const e=window.location.pathname,t=(y._configFileCustomEvents||[]).filter(n=>{var r;return(r=n.applyToUrls)!=null&&r.length?n.applyToUrls.some(c=>M(e,{value:c.value,filter:c.matchBy})):!0});i=T(t,n=>n.type)}}const G=()=>{q();for(const e of(i==null?void 0:i.clickEvent)||[])I({url:v,customEvent:e});for(const e of(i==null?void 0:i.scrollDepth)||[])K({customEvent:e});for(const e of(i==null?void 0:i.javascriptEvent)||[])R({customEvent:e});for(const e of(i==null?void 0:i.elementViewed)||[])P({url:v,customEvent:e})},F=Object.freeze(Object.defineProperty({__proto__:null,registerCustomEventsAtPageLoad:G},Symbol.toStringTag,{value:"Module"}));let y;const Q=e=>{y=e};export{y as CustomEventConfig,F as CustomEventRegistration,Q as init}; //# sourceMappingURL=ig_standard_1761066027570.index.DLC-wj3F.js.map