import{onCLS as d,onFID as u,onLCP as m}from"web-vitals";import{debounce as s}from"../../../../utils/time/debounce.js";const c=new Set,b=(n,t)=>{const e=t?.analytics?.gtm;if(!e||process.env.NODE_ENV!=="production"&&!e.includeInDevelopment)return;e.enableWebVitalsTracking&&!n.prevLocation&&p(e.dataLayerName);const a=e.dataLayerName?window[e.dataLayerName]:window.dataLayer,o=e.pageViewEventName?e.pageViewEventName:"pageView";a.push({event:o})};function p(n="dataLayer"){const t=window;function e(i){c.has(i.name)||(c.add(i.name),w(i,t[n]))}const a=s(e,3e3),o=e,r=s(e,3e3);d(a),u(o),m(r)}function w({name:n,value:t,id:e},a){a.push({event:"core-web-vitals",webVitalsMeasurement:{name:n,id:e,value:Math.round(n==="CLS"?t*1e3:t),nonInteraction:!0}})}export{b as onRouteChange};
