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