@tracelog/lib 2.8.3 → 2.8.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  const ur = 9e5;
2
- const dr = 120, hr = 49152, fr = 100, mr = 500, gr = 200;
3
- const Er = 1e3, pr = 500, Sr = 1e3;
2
+ const hr = 120, fr = 49152, mr = 100, gr = 500, Er = 200;
3
+ const pr = 1e3, Sr = 500, Tr = 1e3;
4
4
  const b = "data-tlog", bt = [
5
5
  "button",
6
6
  "a",
@@ -33,7 +33,7 @@ const b = "data-tlog", bt = [
33
33
  ".menu-item",
34
34
  "[data-testid]",
35
35
  '[tabindex="0"]'
36
- ], At = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], Lt = [
36
+ ], Lt = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"], At = [
37
37
  "token",
38
38
  "auth",
39
39
  "key",
@@ -79,8 +79,8 @@ const E = {
79
79
  /<iframe\b[^<]*(?:(?!<\/iframe>)<[^<]*)*<\/iframe>/gi,
80
80
  /<embed\b[^>]*>/gi,
81
81
  /<object\b[^<]*(?:(?!<\/object>)<[^<]*)*<\/object>/gi
82
- ], I = "tlog", X = `${I}:qa_mode`, Te = `${I}:uid`, rt = "tlog_mode", Ue = "qa", He = "qa_off", Ct = (r) => r ? `${I}:${r}:queue` : `${I}:queue`, Rt = (r) => r ? `${I}:${r}:session` : `${I}:session`, Nt = (r) => r ? `${I}:${r}:broadcast` : `${I}:broadcast`, Fe = (r, e) => `${I}:${r}:session_counts:${e}`, xe = 10080 * 60 * 1e3, $e = `${I}:session_counts_last_cleanup`, Be = 3600 * 1e3, fe = (r) => r ? `${I}:${r}:identity` : `${I}:identity`, U = `${I}:pending_identity`;
83
- var $ = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))($ || {}), L = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(L || {}), se = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(se || {});
82
+ ], S = "tlog", X = `${S}:qa_mode`, Te = `${S}:uid`, rt = "tlog_mode", Ue = "qa", Fe = "qa_off", Ct = (r) => r ? `${S}:${r}:queue` : `${S}:queue`, Rt = (r) => r ? `${S}:${r}:rate_limit` : `${S}:rate_limit`, Nt = (r) => r ? `${S}:${r}:session` : `${S}:session`, Ot = (r) => r ? `${S}:${r}:broadcast` : `${S}:broadcast`, He = (r, e) => `${S}:${r}:session_counts:${e}`, xe = 10080 * 60 * 1e3, $e = `${S}:session_counts_last_cleanup`, Be = 3600 * 1e3, fe = (r) => r ? `${S}:${r}:identity` : `${S}:identity`, U = `${S}:pending_identity`;
83
+ var $ = /* @__PURE__ */ ((r) => (r.Localhost = "localhost:8080", r.Fail = "localhost:9999", r))($ || {}), A = /* @__PURE__ */ ((r) => (r.Mobile = "mobile", r.Tablet = "tablet", r.Desktop = "desktop", r.Unknown = "unknown", r))(A || {}), se = /* @__PURE__ */ ((r) => (r.EVENT = "event", r.QUEUE = "queue", r))(se || {});
84
84
  class O extends Error {
85
85
  constructor(e, t) {
86
86
  super(e), this.statusCode = t, this.name = "PermanentError", Error.captureStackTrace && Error.captureStackTrace(this, O);
@@ -92,13 +92,13 @@ class re extends Error {
92
92
  super(e), this.name = "RateLimitError", Error.captureStackTrace && Error.captureStackTrace(this, re);
93
93
  }
94
94
  }
95
- class ne extends Error {
95
+ class ie extends Error {
96
96
  constructor(e) {
97
- super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ne);
97
+ super(e), this.name = "TimeoutError", Error.captureStackTrace && Error.captureStackTrace(this, ie);
98
98
  }
99
99
  }
100
- var d = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r.VIEWPORT_VISIBLE = "viewport_visible", r))(d || {}), Z = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(Z || {}), B = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(B || {}), ie = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(ie || {});
101
- const Tr = (r) => r.type === d.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !0, Ir = (r) => r.type === d.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !1;
100
+ var u = /* @__PURE__ */ ((r) => (r.PAGE_VIEW = "page_view", r.CLICK = "click", r.SCROLL = "scroll", r.SESSION_START = "session_start", r.CUSTOM = "custom", r.WEB_VITALS = "web_vitals", r.ERROR = "error", r.VIEWPORT_VISIBLE = "viewport_visible", r))(u || {}), Z = /* @__PURE__ */ ((r) => (r.UP = "up", r.DOWN = "down", r))(Z || {}), B = /* @__PURE__ */ ((r) => (r.JS_ERROR = "js_error", r.PROMISE_REJECTION = "promise_rejection", r))(B || {}), ne = /* @__PURE__ */ ((r) => (r.QA = "qa", r))(ne || {});
101
+ const Ir = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !0, vr = (r) => r.type === u.SCROLL && "scroll_data" in r && r.scroll_data.is_primary === !1;
102
102
  class j extends Error {
103
103
  constructor(e, t, s) {
104
104
  super(e), this.errorCode = t, this.layer = s, this.name = this.constructor.name, Error.captureStackTrace && Error.captureStackTrace(this, this.constructor);
@@ -111,7 +111,7 @@ class m extends j {
111
111
  super(e, "APP_CONFIG_INVALID", t);
112
112
  }
113
113
  }
114
- class Ot extends j {
114
+ class Pt extends j {
115
115
  constructor(e, t = "config") {
116
116
  super(e, "SESSION_TIMEOUT_INVALID", t);
117
117
  }
@@ -126,13 +126,13 @@ class N extends j {
126
126
  super(e, "INTEGRATION_INVALID", t);
127
127
  }
128
128
  }
129
- class vr extends j {
129
+ class _r extends j {
130
130
  constructor(e, t, s = "runtime") {
131
131
  super(e, "INITIALIZATION_TIMEOUT", s), this.timeoutMs = t;
132
132
  }
133
133
  timeoutMs;
134
134
  }
135
- const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", it = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Pt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Dt = (r, e) => {
135
+ const it = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", nt = "background: #9e9e9e; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", Dt = "background: #d32f2f; color: white; font-weight: bold; padding: 2px 8px; border-radius: 3px;", kt = (r, e) => {
136
136
  if (e) {
137
137
  if (e instanceof Error) {
138
138
  const t = e.message.replace(/\s+at\s+.*$/gm, "").replace(/\s*\([^()]+:\d+:\d+\)/g, "");
@@ -151,7 +151,7 @@ const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
151
151
  return `[TraceLog] ${r}: ${String(e)}`;
152
152
  }
153
153
  return `[TraceLog] ${r}`;
154
- }, kt = () => {
154
+ }, Vt = () => {
155
155
  if (typeof window > "u" || typeof sessionStorage > "u")
156
156
  return !1;
157
157
  try {
@@ -160,32 +160,32 @@ const nt = "background: #ff9800; color: white; font-weight: bold; padding: 2px 8
160
160
  return !1;
161
161
  }
162
162
  }, a = (r, e, t) => {
163
- const { error: s, data: n, showToClient: i = !1, style: o, visibility: l } = t ?? {}, c = s ? Dt(e, s) : `[TraceLog] ${e}`, u = r === "error" ? "error" : r === "warn" ? "warn" : "log";
164
- if (!Vt(l, i))
163
+ const { error: s, data: i, showToClient: n = !1, style: o, visibility: l } = t ?? {}, c = s ? kt(e, s) : `[TraceLog] ${e}`, d = r === "error" ? "error" : r === "warn" ? "warn" : "log";
164
+ if (!Ut(l, n))
165
165
  return;
166
- const g = Ut(l, o), T = n !== void 0 ? Ie(n) : void 0;
167
- Ht(u, c, g, T);
168
- }, Vt = (r, e) => r === "critical" ? !0 : r === "qa" || e ? kt() : !1, Ut = (r, e) => e !== void 0 && e !== "" ? e : r === "critical" ? Pt : "", Ht = (r, e, t, s) => {
169
- const n = t !== void 0 && t !== "", i = n ? `%c${e}` : e;
170
- s !== void 0 ? n ? console[r](i, t, s) : console[r](i, s) : n ? console[r](i, t) : console[r](i);
166
+ const g = Ft(l, o), I = i !== void 0 ? Ie(i) : void 0;
167
+ Ht(d, c, g, I);
168
+ }, Ut = (r, e) => r === "critical" ? !0 : r === "qa" || e ? Vt() : !1, Ft = (r, e) => e !== void 0 && e !== "" ? e : r === "critical" ? Dt : "", Ht = (r, e, t, s) => {
169
+ const i = t !== void 0 && t !== "", n = i ? `%c${e}` : e;
170
+ s !== void 0 ? i ? console[r](n, t, s) : console[r](n, s) : i ? console[r](n, t) : console[r](n);
171
171
  }, Ie = (r) => {
172
172
  const e = {}, t = ["token", "password", "secret", "key", "apikey", "api_key", "sessionid", "session_id"];
173
- for (const [s, n] of Object.entries(r)) {
174
- const i = s.toLowerCase();
175
- if (t.some((o) => i.includes(o))) {
173
+ for (const [s, i] of Object.entries(r)) {
174
+ const n = s.toLowerCase();
175
+ if (t.some((o) => n.includes(o))) {
176
176
  e[s] = "[REDACTED]";
177
177
  continue;
178
178
  }
179
- n !== null && typeof n == "object" && !Array.isArray(n) ? e[s] = Ie(n) : Array.isArray(n) ? e[s] = n.map(
179
+ i !== null && typeof i == "object" && !Array.isArray(i) ? e[s] = Ie(i) : Array.isArray(i) ? e[s] = i.map(
180
180
  (o) => o !== null && typeof o == "object" && !Array.isArray(o) ? Ie(o) : o
181
- ) : e[s] = n;
181
+ ) : e[s] = i;
182
182
  }
183
183
  return e;
184
184
  };
185
185
  let ve, ot;
186
- const Ft = () => {
186
+ const xt = () => {
187
187
  typeof window < "u" && !ve && (ve = window.matchMedia("(pointer: coarse)"), ot = window.matchMedia("(hover: none)"));
188
- }, oe = "Unknown", xt = (r) => {
188
+ }, oe = "Unknown", $t = (r) => {
189
189
  const e = r.userAgentData?.platform;
190
190
  if (e != null && e !== "") {
191
191
  if (/windows/i.test(e)) return "Windows";
@@ -197,41 +197,41 @@ const Ft = () => {
197
197
  }
198
198
  const t = navigator.userAgent;
199
199
  return /Windows/i.test(t) ? "Windows" : /iPhone|iPad|iPod/i.test(t) ? "iOS" : /Mac OS X|Macintosh/i.test(t) ? "macOS" : /Android/i.test(t) ? "Android" : /CrOS/i.test(t) ? "ChromeOS" : /Linux/i.test(t) ? "Linux" : oe;
200
- }, $t = (r) => {
200
+ }, Bt = (r) => {
201
201
  const e = r.userAgentData?.brands;
202
202
  if (e != null && e.length > 0) {
203
- const n = e.filter((i) => !/not.?a.?brand|chromium/i.test(i.brand))[0];
204
- if (n != null) {
205
- const i = n.brand;
206
- return /google chrome/i.test(i) ? "Chrome" : /microsoft edge/i.test(i) ? "Edge" : /opera/i.test(i) ? "Opera" : i;
203
+ const i = e.filter((n) => !/not.?a.?brand|chromium/i.test(n.brand))[0];
204
+ if (i != null) {
205
+ const n = i.brand;
206
+ return /google chrome/i.test(n) ? "Chrome" : /microsoft edge/i.test(n) ? "Edge" : /opera/i.test(n) ? "Opera" : n;
207
207
  }
208
208
  }
209
209
  const t = navigator.userAgent;
210
210
  return /Edg\//i.test(t) ? "Edge" : /OPR\//i.test(t) ? "Opera" : /Chrome/i.test(t) ? "Chrome" : /Firefox/i.test(t) ? "Firefox" : /Safari/i.test(t) && !/Chrome/i.test(t) ? "Safari" : oe;
211
- }, Bt = () => {
211
+ }, Wt = () => {
212
212
  try {
213
213
  const r = navigator;
214
214
  if (r.userAgentData != null && typeof r.userAgentData.mobile == "boolean") {
215
215
  const c = r.userAgentData.platform;
216
- return c != null && c !== "" && /ipad|tablet/i.test(c) ? L.Tablet : r.userAgentData.mobile ? L.Mobile : L.Desktop;
216
+ return c != null && c !== "" && /ipad|tablet/i.test(c) ? A.Tablet : r.userAgentData.mobile ? A.Mobile : A.Desktop;
217
217
  }
218
- Ft();
219
- const e = window.innerWidth, t = ve?.matches ?? !1, s = ot?.matches ?? !1, n = "ontouchstart" in window || navigator.maxTouchPoints > 0, i = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(i), l = /tablet|ipad|android(?!.*mobile)/.test(i);
220
- return e <= 767 || o && n ? L.Mobile : e >= 768 && e <= 1024 || l || t && s && n ? L.Tablet : L.Desktop;
218
+ xt();
219
+ const e = window.innerWidth, t = ve?.matches ?? !1, s = ot?.matches ?? !1, i = "ontouchstart" in window || navigator.maxTouchPoints > 0, n = navigator.userAgent.toLowerCase(), o = /mobile|android|iphone|ipod|blackberry|iemobile|opera mini/.test(n), l = /tablet|ipad|android(?!.*mobile)/.test(n);
220
+ return e <= 767 || o && i ? A.Mobile : e >= 768 && e <= 1024 || l || t && s && i ? A.Tablet : A.Desktop;
221
221
  } catch (r) {
222
- return a("debug", "Device detection failed, defaulting to desktop", { error: r }), L.Desktop;
222
+ return a("debug", "Device detection failed, defaulting to desktop", { error: r }), A.Desktop;
223
223
  }
224
- }, Wt = () => {
224
+ }, Xt = () => {
225
225
  try {
226
226
  const r = navigator;
227
227
  return {
228
- type: Bt(),
229
- os: xt(r),
230
- browser: $t(r)
228
+ type: Wt(),
229
+ os: $t(r),
230
+ browser: Bt(r)
231
231
  };
232
232
  } catch (r) {
233
233
  return a("debug", "Device info detection failed, using defaults", { error: r }), {
234
- type: L.Desktop,
234
+ type: A.Desktop,
235
235
  os: oe,
236
236
  browser: oe
237
237
  };
@@ -253,7 +253,7 @@ const Ft = () => {
253
253
  /:\/\/[^:/]+:([^@]+)@/gi,
254
254
  // Sensitive URL query parameters (token=, password=, auth=, secret=, api_key=, etc.)
255
255
  /[?&](token|password|passwd|auth|secret|secret_key|private_key|auth_key|api_key|apikey|access_token)=[^&\s]+/gi
256
- ], Xe = 500, Ge = 2e3, je = 5e3, ee = 50, Xt = ee * 2, lt = 1, Gt = 1e3, jt = 10, ze = 5e3, zt = 6e4, _r = {
256
+ ], Xe = 500, Ge = 2e3, je = 5e3, ee = 50, Gt = ee * 2, lt = 1, jt = 1e3, zt = 10, ze = 5e3, Kt = 6e4, yr = {
257
257
  LCP: 2500,
258
258
  // Good: ≤ 2.5s
259
259
  FCP: 1800,
@@ -265,7 +265,7 @@ const Ft = () => {
265
265
  TTFB: 800,
266
266
  // Good: ≤ 800ms
267
267
  LONG_TASK: 50
268
- }, Qe = {
268
+ }, Ke = {
269
269
  LCP: 2500,
270
270
  // Needs improvement: > 2.5s (same as good boundary)
271
271
  FCP: 1800,
@@ -289,19 +289,19 @@ const Ft = () => {
289
289
  TTFB: 1800,
290
290
  // Poor: > 1800ms
291
291
  LONG_TASK: 50
292
- }, _e = "needs-improvement", Ke = (r = _e) => {
292
+ }, _e = "needs-improvement", Qe = (r = _e) => {
293
293
  switch (r) {
294
294
  case "all":
295
295
  return { LCP: 0, FCP: 0, CLS: 0, INP: 0, TTFB: 0, LONG_TASK: 0 };
296
296
  // Track everything
297
297
  case "needs-improvement":
298
- return Qe;
298
+ return Ke;
299
299
  case "poor":
300
300
  return Qt;
301
301
  default:
302
- return Qe;
302
+ return Ke;
303
303
  }
304
- }, Kt = 1e3, Yt = 50, qt = "2.8.2", Jt = qt, ct = () => typeof window < "u" && typeof sessionStorage < "u", Zt = () => {
304
+ }, Yt = 1e3, qt = 50, Jt = "2.8.3", Zt = Jt, ct = () => typeof window < "u" && typeof sessionStorage < "u", es = () => {
305
305
  try {
306
306
  const r = new URLSearchParams(window.location.search);
307
307
  r.delete(rt);
@@ -309,33 +309,33 @@ const Ft = () => {
309
309
  window.history.replaceState({}, "", t);
310
310
  } catch {
311
311
  }
312
- }, es = () => {
312
+ }, ts = () => {
313
313
  if (!ct())
314
314
  return !1;
315
315
  try {
316
316
  const e = new URLSearchParams(window.location.search).get(rt), t = sessionStorage.getItem(X);
317
317
  let s = null;
318
318
  return e === Ue ? (s = !0, sessionStorage.setItem(X, "true"), a("info", "QA Mode ACTIVE", {
319
- visibility: "qa",
320
- style: nt
321
- })) : e === He && (s = !1, sessionStorage.setItem(X, "false"), a("info", "QA Mode DISABLED", {
322
319
  visibility: "qa",
323
320
  style: it
324
- })), (e === Ue || e === He) && Zt(), s ?? t === "true";
321
+ })) : e === Fe && (s = !1, sessionStorage.setItem(X, "false"), a("info", "QA Mode DISABLED", {
322
+ visibility: "qa",
323
+ style: nt
324
+ })), (e === Ue || e === Fe) && es(), s ?? t === "true";
325
325
  } catch {
326
326
  return !1;
327
327
  }
328
- }, ts = (r) => {
328
+ }, ss = (r) => {
329
329
  if (ct())
330
330
  try {
331
331
  sessionStorage.setItem(X, r ? "true" : "false"), a("info", r ? "QA Mode ACTIVE" : "QA Mode DISABLED", {
332
332
  visibility: "qa",
333
- style: r ? nt : it
333
+ style: r ? it : nt
334
334
  });
335
335
  } catch {
336
336
  a("debug", "Cannot set QA mode: sessionStorage unavailable");
337
337
  }
338
- }, ss = [
338
+ }, rs = [
339
339
  "co.uk",
340
340
  "org.uk",
341
341
  "com.au",
@@ -352,27 +352,27 @@ const Ft = () => {
352
352
  if (e.length <= 2)
353
353
  return r.toLowerCase();
354
354
  const t = e.slice(-2).join(".");
355
- return ss.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
356
- }, rs = (r, e) => r === e ? !0 : Ye(r) === Ye(e), me = () => {
355
+ return rs.includes(t) ? e.slice(-3).join(".") : e.slice(-2).join(".");
356
+ }, is = (r, e) => r === e ? !0 : Ye(r) === Ye(e), me = () => {
357
357
  const r = document.referrer;
358
358
  if (!r)
359
359
  return "Direct";
360
360
  try {
361
361
  const e = new URL(r).hostname.toLowerCase(), t = window.location.hostname.toLowerCase();
362
- return rs(e, t) ? "Direct" : r;
362
+ return is(e, t) ? "Direct" : r;
363
363
  } catch (e) {
364
364
  return a("debug", "Failed to parse referrer URL, using raw value", { error: e, data: { referrer: r } }), r;
365
365
  }
366
366
  }, ge = () => {
367
367
  const r = new URLSearchParams(window.location.search), e = {};
368
- return At.forEach((s) => {
369
- const n = r.get(s);
370
- if (n) {
371
- const i = s.split("utm_")[1];
372
- e[i] = n;
368
+ return Lt.forEach((s) => {
369
+ const i = r.get(s);
370
+ if (i) {
371
+ const n = s.split("utm_")[1];
372
+ e[n] = i;
373
373
  }
374
374
  }), Object.keys(e).length ? e : void 0;
375
- }, ut = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
375
+ }, dt = () => typeof crypto < "u" && crypto.randomUUID ? crypto.randomUUID() : "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (r) => {
376
376
  const e = Math.random() * 16 | 0;
377
377
  return (r === "x" ? e : e & 3 | 8).toString(16);
378
378
  });
@@ -385,19 +385,19 @@ const ns = () => {
385
385
  try {
386
386
  if (typeof crypto < "u" && crypto.getRandomValues) {
387
387
  const s = crypto.getRandomValues(new Uint8Array(3));
388
- s && (t = Array.from(s, (n) => n.toString(16).padStart(2, "0")).join(""));
388
+ s && (t = Array.from(s, (i) => i.toString(16).padStart(2, "0")).join(""));
389
389
  }
390
390
  } catch {
391
391
  }
392
392
  return t || (t = Math.floor(Math.random() * 16777215).toString(16).padStart(6, "0")), `${r}-${e}-${t}`;
393
- }, dt = (r, e = !1) => {
393
+ }, ut = (r, e = !1) => {
394
394
  try {
395
- const t = new URL(r), s = t.protocol === "https:", n = t.protocol === "http:";
396
- return s || e && n;
395
+ const t = new URL(r), s = t.protocol === "https:", i = t.protocol === "http:";
396
+ return s || e && i;
397
397
  } catch {
398
398
  return !1;
399
399
  }
400
- }, is = (r) => {
400
+ }, os = (r) => {
401
401
  try {
402
402
  const t = new URL(window.location.href).hostname;
403
403
  if (!t || typeof t != "string")
@@ -411,23 +411,23 @@ const ns = () => {
411
411
  throw new Error("Invalid hostname structure");
412
412
  if (s.length === 1)
413
413
  throw new Error("Single-part domain not supported for SaaS integration");
414
- let n;
415
- if (s.length === 2 ? n = s.join(".") : n = s.slice(-2).join("."), !n || n.split(".").length < 2)
414
+ let i;
415
+ if (s.length === 2 ? i = s.join(".") : i = s.slice(-2).join("."), !i || i.split(".").length < 2)
416
416
  throw new Error("Invalid domain structure for SaaS");
417
- const i = `https://${r}.${n}/collect`;
418
- if (!dt(i))
417
+ const n = `https://${r}.${i}/collect`;
418
+ if (!ut(n))
419
419
  throw new Error("Generated URL failed validation");
420
- return i;
420
+ return n;
421
421
  } catch (e) {
422
422
  throw new Error(`Invalid SaaS URL configuration: ${e instanceof Error ? e.message : String(e)}`);
423
423
  }
424
- }, os = (r) => {
424
+ }, as = (r) => {
425
425
  const e = {};
426
- r.integrations?.tracelog?.projectId && (e.saas = is(r.integrations.tracelog.projectId));
426
+ r.integrations?.tracelog?.projectId && (e.saas = os(r.integrations.tracelog.projectId));
427
427
  const t = r.integrations?.custom?.collectApiUrl;
428
428
  if (t) {
429
429
  const s = r.integrations?.custom?.allowHttp ?? !1;
430
- if (!dt(t, s))
430
+ if (!ut(t, s))
431
431
  throw new Error("Invalid custom API URL");
432
432
  e.custom = t;
433
433
  }
@@ -436,12 +436,12 @@ const ns = () => {
436
436
  if (!r || typeof r != "string")
437
437
  return a("warn", "Invalid URL provided to normalizeUrl", { data: { type: typeof r } }), r || "";
438
438
  try {
439
- const t = new URL(r), s = t.searchParams, n = [.../* @__PURE__ */ new Set([...Lt, ...e])];
440
- let i = !1;
439
+ const t = new URL(r), s = t.searchParams, i = [.../* @__PURE__ */ new Set([...At, ...e])];
440
+ let n = !1;
441
441
  const o = [];
442
- return n.forEach((c) => {
443
- s.has(c) && (s.delete(c), i = !0, o.push(c));
444
- }), !i && r.includes("?") ? r : (t.search = s.toString(), t.toString());
442
+ return i.forEach((c) => {
443
+ s.has(c) && (s.delete(c), n = !0, o.push(c));
444
+ }), !n && r.includes("?") ? r : (t.search = s.toString(), t.toString());
445
445
  } catch (t) {
446
446
  return a("warn", "URL normalization failed, returning original", { error: t, data: { urlLength: r?.length } }), r;
447
447
  }
@@ -451,9 +451,9 @@ const ns = () => {
451
451
  let e = r;
452
452
  r.length > 1e3 && (e = r.slice(0, Math.max(0, 1e3)));
453
453
  let t = 0;
454
- for (const n of Mt) {
455
- const i = e;
456
- e = e.replace(n, ""), i !== e && t++;
454
+ for (const i of Mt) {
455
+ const n = e;
456
+ e = e.replace(i, ""), n !== e && t++;
457
457
  }
458
458
  return t > 0 && a("warn", "XSS patterns detected and removed", {
459
459
  data: {
@@ -473,11 +473,11 @@ const ns = () => {
473
473
  if (e > 10)
474
474
  return null;
475
475
  if (Array.isArray(r))
476
- return r.slice(0, 1e3).map((n) => we(n, e + 1)).filter((n) => n !== null);
476
+ return r.slice(0, 1e3).map((i) => we(i, e + 1)).filter((i) => i !== null);
477
477
  if (typeof r == "object") {
478
- const t = {}, n = Object.entries(r).slice(0, 200);
479
- for (const [i, o] of n) {
480
- const l = qe(i);
478
+ const t = {}, i = Object.entries(r).slice(0, 200);
479
+ for (const [n, o] of i) {
480
+ const l = qe(n);
481
481
  if (l) {
482
482
  const c = we(o, e + 1);
483
483
  c !== null && (t[l] = c);
@@ -486,7 +486,7 @@ const ns = () => {
486
486
  return t;
487
487
  }
488
488
  return null;
489
- }, as = (r) => {
489
+ }, ls = (r) => {
490
490
  if (typeof r != "object" || r === null)
491
491
  return {};
492
492
  try {
@@ -496,12 +496,12 @@ const ns = () => {
496
496
  const t = e instanceof Error ? e.message : String(e);
497
497
  throw new Error(`[TraceLog] Metadata sanitization failed: ${t}`);
498
498
  }
499
- }, ls = (r) => {
499
+ }, cs = (r) => {
500
500
  if (r !== void 0 && (r === null || typeof r != "object"))
501
501
  throw new m("Configuration must be an object", "config");
502
502
  if (r) {
503
503
  if (r.sessionTimeout !== void 0 && (typeof r.sessionTimeout != "number" || r.sessionTimeout < 3e4 || r.sessionTimeout > 864e5))
504
- throw new Ot(E.INVALID_SESSION_TIMEOUT, "config");
504
+ throw new Pt(E.INVALID_SESSION_TIMEOUT, "config");
505
505
  if (r.globalMetadata !== void 0 && (typeof r.globalMetadata != "object" || r.globalMetadata === null))
506
506
  throw new m(E.INVALID_GLOBAL_METADATA, "config");
507
507
  if (r.integrations && us(r.integrations), r.sensitiveQueryParams !== void 0) {
@@ -536,7 +536,7 @@ const ns = () => {
536
536
  throw new m(E.INVALID_MAX_SAME_EVENT_PER_MINUTE, "config");
537
537
  if (r.sendIntervalMs !== void 0 && (!Number.isFinite(r.sendIntervalMs) || r.sendIntervalMs < 1e3 || r.sendIntervalMs > 6e4))
538
538
  throw new m(E.INVALID_SEND_INTERVAL, "config");
539
- if (r.viewport !== void 0 && cs(r.viewport), r.webVitalsMode !== void 0) {
539
+ if (r.viewport !== void 0 && ds(r.viewport), r.webVitalsMode !== void 0) {
540
540
  if (typeof r.webVitalsMode != "string")
541
541
  throw new m(
542
542
  `Invalid webVitalsMode type: ${typeof r.webVitalsMode}. Must be a string`,
@@ -567,7 +567,7 @@ const ns = () => {
567
567
  }
568
568
  }
569
569
  }
570
- }, cs = (r) => {
570
+ }, ds = (r) => {
571
571
  if (typeof r != "object" || r === null)
572
572
  throw new m(E.INVALID_VIEWPORT_CONFIG, "config");
573
573
  if (!r.elements || !Array.isArray(r.elements))
@@ -620,8 +620,8 @@ const ns = () => {
620
620
  if (r.tracelog?.shopify !== void 0 && typeof r.tracelog.shopify != "boolean")
621
621
  throw new N("tracelog.shopify must be a boolean", "config");
622
622
  }
623
- }, ds = (r) => {
624
- ls(r);
623
+ }, hs = (r) => {
624
+ cs(r);
625
625
  const e = {
626
626
  ...r ?? {},
627
627
  sessionTimeout: r?.sessionTimeout ?? 9e5,
@@ -649,13 +649,13 @@ const ns = () => {
649
649
  return !0;
650
650
  const t = typeof r;
651
651
  return t === "string" || t === "number" || t === "boolean" ? !0 : t === "function" || t === "symbol" || t === "bigint" || e.has(r) ? !1 : (e.add(r), Array.isArray(r) ? r.every((s) => be(s, e)) : t === "object" ? Object.values(r).every((s) => be(s, e)) : !1);
652
- }, hs = (r) => typeof r != "object" || r === null ? !1 : be(r), ht = (r) => {
652
+ }, fs = (r) => typeof r != "object" || r === null ? !1 : be(r), ht = (r) => {
653
653
  if (typeof r != "object" || r === null || Array.isArray(r)) return;
654
654
  const e = {};
655
655
  for (const [t, s] of Object.entries(r))
656
656
  typeof s == "string" && (e[t] = s);
657
657
  return Object.keys(e).length > 0 ? e : void 0;
658
- }, fs = (r) => typeof r != "string" ? {
658
+ }, ms = (r) => typeof r != "string" ? {
659
659
  valid: !1,
660
660
  error: "Event name must be a string"
661
661
  } : r.length === 0 ? {
@@ -671,49 +671,49 @@ const ns = () => {
671
671
  valid: !1,
672
672
  error: "Event name cannot be a reserved word"
673
673
  } : { valid: !0 }, Je = (r, e, t) => {
674
- const s = as(e), n = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
675
- if (!hs(s))
674
+ const s = ls(e), i = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
675
+ if (!fs(s))
676
676
  return {
677
677
  valid: !1,
678
- error: `${n}: object has invalid types. Valid types are string, number, boolean or string arrays.`
678
+ error: `${i}: object has invalid types. Valid types are string, number, boolean or string arrays.`
679
679
  };
680
- let i;
680
+ let n;
681
681
  try {
682
- i = JSON.stringify(s);
682
+ n = JSON.stringify(s);
683
683
  } catch {
684
684
  return {
685
685
  valid: !1,
686
- error: `${n}: object contains circular references or cannot be serialized.`
686
+ error: `${i}: object contains circular references or cannot be serialized.`
687
687
  };
688
688
  }
689
- if (new TextEncoder().encode(i).byteLength > 49152)
689
+ if (new TextEncoder().encode(n).byteLength > 49152)
690
690
  return {
691
691
  valid: !1,
692
- error: `${n}: object is too large (max ${49152 / 1024} KB).`
692
+ error: `${i}: object is too large (max ${49152 / 1024} KB).`
693
693
  };
694
694
  if (Object.keys(s).length > 100)
695
695
  return {
696
696
  valid: !1,
697
- error: `${n}: object has too many keys (max 100 keys).`
697
+ error: `${i}: object has too many keys (max 100 keys).`
698
698
  };
699
- for (const [c, u] of Object.entries(s)) {
700
- if (Array.isArray(u)) {
701
- if (u.length > 500)
699
+ for (const [c, d] of Object.entries(s)) {
700
+ if (Array.isArray(d)) {
701
+ if (d.length > 500)
702
702
  return {
703
703
  valid: !1,
704
- error: `${n}: array property "${c}" is too large (max 500 items).`
704
+ error: `${i}: array property "${c}" is too large (max 500 items).`
705
705
  };
706
- for (const f of u)
706
+ for (const f of d)
707
707
  if (typeof f == "string" && f.length > 500)
708
708
  return {
709
709
  valid: !1,
710
- error: `${n}: array property "${c}" contains strings that are too long (max 500 characters).`
710
+ error: `${i}: array property "${c}" contains strings that are too long (max 500 characters).`
711
711
  };
712
712
  }
713
- if (typeof u == "string" && u.length > 1e3)
713
+ if (typeof d == "string" && d.length > 1e3)
714
714
  return {
715
715
  valid: !1,
716
- error: `${n}: property "${c}" is too long (max 1000 characters).`
716
+ error: `${i}: property "${c}" is too long (max 1000 characters).`
717
717
  };
718
718
  }
719
719
  return {
@@ -722,19 +722,19 @@ const ns = () => {
722
722
  };
723
723
  }, ft = (r, e, t) => {
724
724
  if (Array.isArray(e)) {
725
- const s = [], n = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
726
- for (let i = 0; i < e.length; i++) {
727
- const o = e[i];
725
+ const s = [], i = t && t === "customEvent" ? `${t} "${r}" metadata error` : `${r} metadata error`;
726
+ for (let n = 0; n < e.length; n++) {
727
+ const o = e[n];
728
728
  if (typeof o != "object" || o === null || Array.isArray(o))
729
729
  return {
730
730
  valid: !1,
731
- error: `${n}: array item at index ${i} must be an object.`
731
+ error: `${i}: array item at index ${n} must be an object.`
732
732
  };
733
733
  const l = Je(r, o, t);
734
734
  if (!l.valid)
735
735
  return {
736
736
  valid: !1,
737
- error: `${n}: array item at index ${i} is invalid: ${l.error}`
737
+ error: `${i}: array item at index ${n} is invalid: ${l.error}`
738
738
  };
739
739
  l.sanitizedMetadata && s.push(l.sanitizedMetadata);
740
740
  }
@@ -744,8 +744,8 @@ const ns = () => {
744
744
  };
745
745
  }
746
746
  return Je(r, e, t);
747
- }, ms = (r, e) => {
748
- const t = fs(r);
747
+ }, gs = (r, e) => {
748
+ const t = ms(r);
749
749
  if (!t.valid)
750
750
  return a("error", "Event name validation failed", {
751
751
  data: { eventName: r, error: t.error }
@@ -760,7 +760,7 @@ const ns = () => {
760
760
  }
761
761
  }), s;
762
762
  };
763
- class gs {
763
+ class Es {
764
764
  listeners = /* @__PURE__ */ new Map();
765
765
  /**
766
766
  * Subscribes to an event channel
@@ -813,8 +813,8 @@ class gs {
813
813
  off(e, t) {
814
814
  const s = this.listeners.get(e);
815
815
  if (s) {
816
- const n = s.indexOf(t);
817
- n > -1 && s.splice(n, 1);
816
+ const i = s.indexOf(t);
817
+ i > -1 && s.splice(i, 1);
818
818
  }
819
819
  }
820
820
  /**
@@ -847,8 +847,8 @@ class gs {
847
847
  */
848
848
  emit(e, t) {
849
849
  const s = this.listeners.get(e);
850
- s && s.forEach((n) => {
851
- n(t);
850
+ s && s.forEach((i) => {
851
+ i(t);
852
852
  });
853
853
  }
854
854
  /**
@@ -888,7 +888,7 @@ function mt(r, e, t) {
888
888
  }), r;
889
889
  }
890
890
  }
891
- function Es(r, e, t) {
891
+ function ps(r, e, t) {
892
892
  return r.map((s) => mt(s, e, t)).filter((s) => s !== null);
893
893
  }
894
894
  function gt(r, e, t) {
@@ -987,6 +987,20 @@ class Ze extends _ {
987
987
  */
988
988
  consecutiveNetworkFailures = 0;
989
989
  circuitOpenedAt = 0;
990
+ /**
991
+ * Timestamp (epoch ms) before which `send()` must skip fetch() calls due to
992
+ * a prior 429 response. Mirrored to `localStorage` (keyed by userId) so the
993
+ * cooldown survives page navigations on traditional server-rendered sites
994
+ * and is discoverable by other tabs on the same origin.
995
+ */
996
+ rateLimitedUntil = 0;
997
+ /**
998
+ * Storage key used when the current in-memory cooldown was armed. Captured
999
+ * at arm time so `resetIdentity()` (which changes `userId` mid-cooldown)
1000
+ * can't make persist/clear operations target the wrong key or leave the
1001
+ * old user's cooldown orphaned in storage.
1002
+ */
1003
+ rateLimitStorageKeyAtArm = null;
990
1004
  /**
991
1005
  * Creates a SenderManager instance.
992
1006
  *
@@ -1001,10 +1015,10 @@ class Ze extends _ {
1001
1015
  * @param customHeadersProvider - Optional callback for dynamic headers
1002
1016
  * @throws Error if integrationId and apiUrl are not both provided or both undefined
1003
1017
  */
1004
- constructor(e, t, s, n = {}, i = {}, o, l = "include") {
1018
+ constructor(e, t, s, i = {}, n = {}, o, l = "include") {
1005
1019
  if (super(), t && !s || !t && s)
1006
1020
  throw new Error("SenderManager: integrationId and apiUrl must either both be provided or both be undefined");
1007
- this.storeManager = e, this.integrationId = t, this.apiUrl = s, this.transformers = n, this.staticHeaders = i, this.customHeadersProvider = o, this.fetchCredentials = l;
1021
+ this.storeManager = e, this.integrationId = t, this.apiUrl = s, this.transformers = i, this.staticHeaders = n, this.customHeadersProvider = o, this.fetchCredentials = l, this.rateLimitedUntil = this.loadRateLimitCooldown();
1008
1022
  }
1009
1023
  /**
1010
1024
  * Get the integration ID for this sender
@@ -1054,6 +1068,64 @@ class Ze extends _ {
1054
1068
  const e = this.get("userId") || "anonymous", t = Ct(e);
1055
1069
  return this.integrationId ? `${t}:${this.integrationId}` : t;
1056
1070
  }
1071
+ getRateLimitStorageKey() {
1072
+ const e = this.get("userId") || "anonymous", t = Rt(e);
1073
+ return this.integrationId ? `${t}:${this.integrationId}` : t;
1074
+ }
1075
+ /**
1076
+ * Returns the storage key bound to the *current* in-memory cooldown. Falls
1077
+ * back to the current-userId key when no cooldown is armed (first read) so
1078
+ * discovery-from-storage paths can still resolve a key.
1079
+ */
1080
+ getActiveRateLimitKey() {
1081
+ return this.rateLimitStorageKeyAtArm ?? this.getRateLimitStorageKey();
1082
+ }
1083
+ armRateLimitCooldown(e) {
1084
+ this.rateLimitedUntil = e, this.rateLimitStorageKeyAtArm = this.getRateLimitStorageKey(), this.persistRateLimitCooldown(e);
1085
+ }
1086
+ loadRateLimitCooldown() {
1087
+ const e = this.getRateLimitStorageKey();
1088
+ try {
1089
+ const t = this.storeManager.getItem(e);
1090
+ if (!t) return 0;
1091
+ const s = Number(t);
1092
+ return !Number.isFinite(s) || s <= Date.now() ? (this.storeManager.removeItem(e), 0) : (this.rateLimitStorageKeyAtArm = e, s);
1093
+ } catch {
1094
+ return 0;
1095
+ }
1096
+ }
1097
+ persistRateLimitCooldown(e) {
1098
+ const t = this.getActiveRateLimitKey();
1099
+ try {
1100
+ const s = this.storeManager.getItem(t);
1101
+ if (s) {
1102
+ const i = Number(s);
1103
+ if (Number.isFinite(i) && i >= e)
1104
+ return;
1105
+ }
1106
+ this.storeManager.setItem(t, String(e));
1107
+ } catch {
1108
+ }
1109
+ }
1110
+ clearRateLimitCooldown() {
1111
+ const e = this.getActiveRateLimitKey();
1112
+ try {
1113
+ const t = this.storeManager.getItem(e);
1114
+ if (t) {
1115
+ const s = Number(t);
1116
+ if (Number.isFinite(s) && s > Date.now()) {
1117
+ this.rateLimitedUntil = s;
1118
+ return;
1119
+ }
1120
+ }
1121
+ this.storeManager.removeItem(e);
1122
+ } catch {
1123
+ }
1124
+ this.rateLimitedUntil = 0, this.rateLimitStorageKeyAtArm = null;
1125
+ }
1126
+ isRateLimited() {
1127
+ return this.rateLimitedUntil === 0 && (this.rateLimitedUntil = this.loadRateLimitCooldown()), !(this.rateLimitedUntil === 0 || Date.now() >= this.rateLimitedUntil && (this.clearRateLimitCooldown(), this.rateLimitedUntil === 0));
1128
+ }
1057
1129
  /**
1058
1130
  * Sends events synchronously using `navigator.sendBeacon()`.
1059
1131
  *
@@ -1072,7 +1144,8 @@ class Ze extends _ {
1072
1144
  *
1073
1145
  * **Return Values**:
1074
1146
  * - `true`: Send succeeded OR skipped (standalone mode)
1075
- * - `false`: Send failed (network error, browser rejected beacon)
1147
+ * - `false`: Send failed (network error, browser rejected beacon) OR skipped
1148
+ * due to active rate-limit cooldown (events persisted for later recovery)
1076
1149
  *
1077
1150
  * **Important**: No retry mechanism. Failed events are persisted to localStorage for
1078
1151
  * recovery on next page load via `recoverPersistedEvents()`.
@@ -1094,7 +1167,23 @@ class Ze extends _ {
1094
1167
  * @see src/managers/README.md (lines 82-139) for send details
1095
1168
  */
1096
1169
  sendEventsQueueSync(e) {
1097
- return this.shouldSkipSend() ? !0 : this.apiUrl?.includes($.Fail) ? (a(
1170
+ if (this.shouldSkipSend())
1171
+ return !0;
1172
+ if (this.isRateLimited()) {
1173
+ a(
1174
+ "debug",
1175
+ `Rate-limit cooldown active, skipping sync send${this.integrationId ? ` [${this.integrationId}]` : ""}`,
1176
+ {
1177
+ data: {
1178
+ cooldownRemainingMs: this.rateLimitedUntil - Date.now(),
1179
+ events: e.events.length
1180
+ }
1181
+ }
1182
+ );
1183
+ const t = this.ensureBatchMetadata(e), s = this.getPersistedData(), i = typeof s?.recoveryFailures == "number" && Number.isFinite(s.recoveryFailures) ? s.recoveryFailures : 0;
1184
+ return this.persistEventsWithFailureCount(t, i, !0), !1;
1185
+ }
1186
+ return this.apiUrl?.includes($.Fail) ? (a(
1098
1187
  "warn",
1099
1188
  `Fail mode: simulating network failure (sync)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
1100
1189
  {
@@ -1156,10 +1245,10 @@ class Ze extends _ {
1156
1245
  async sendEventsQueue(e, t) {
1157
1246
  const s = this.ensureBatchMetadata(e);
1158
1247
  try {
1159
- const n = await this.send(s);
1160
- return n ? (this.clearPersistedEvents(), t?.onSuccess?.(s.events.length, s.events, s)) : (this.persistEvents(s), t?.onFailure?.()), n;
1161
- } catch (n) {
1162
- return n instanceof O ? (this.logPermanentError("Permanent error, not retrying", n), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(s), t?.onFailure?.(), !1);
1248
+ const i = await this.send(s);
1249
+ return i ? (this.clearPersistedEvents(), t?.onSuccess?.(s.events.length, s.events, s)) : (this.persistEvents(s), t?.onFailure?.()), i;
1250
+ } catch (i) {
1251
+ return i instanceof O ? (this.logPermanentError("Permanent error, not retrying", i), this.clearPersistedEvents(), t?.onFailure?.(), !1) : (this.persistEvents(s), t?.onFailure?.(), !1);
1163
1252
  }
1164
1253
  }
1165
1254
  /**
@@ -1219,26 +1308,36 @@ class Ze extends _ {
1219
1308
  this.recoveryInProgress = !0;
1220
1309
  let t = null, s = 0;
1221
1310
  try {
1222
- const n = this.getPersistedData();
1223
- if (!n || !this.isDataRecent(n) || n.events.length === 0) {
1311
+ const i = this.getPersistedData();
1312
+ if (!i || !this.isDataRecent(i) || i.events.length === 0) {
1224
1313
  this.clearPersistedEvents();
1225
1314
  return;
1226
1315
  }
1227
- const i = n.recoveryFailures;
1228
- if (s = typeof i == "number" && Number.isFinite(i) && i >= 0 ? i : 0, s >= 3) {
1316
+ const n = i.recoveryFailures;
1317
+ if (s = typeof n == "number" && Number.isFinite(n) && n >= 0 ? n : 0, s >= 3) {
1229
1318
  a(
1230
1319
  "debug",
1231
1320
  `Discarding persisted events after ${s} failed recovery attempts${this.integrationId ? ` [${this.integrationId}]` : ""}`
1232
1321
  ), this.clearPersistedEvents(), e?.onFailure?.();
1233
1322
  return;
1234
1323
  }
1235
- t = this.ensureBatchMetadata(this.createRecoveryBody(n)), await this.send(t) ? (this.clearPersistedEvents(), e?.onSuccess?.(n.events.length, n.events, t)) : (this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.());
1236
- } catch (n) {
1237
- if (n instanceof O) {
1238
- this.logPermanentError("Permanent error during recovery, clearing persisted events", n), this.clearPersistedEvents(), e?.onFailure?.();
1324
+ if (this.isRateLimited()) {
1325
+ a(
1326
+ "debug",
1327
+ `Rate-limit cooldown active, deferring recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`,
1328
+ {
1329
+ data: { cooldownRemainingMs: this.rateLimitedUntil - Date.now() }
1330
+ }
1331
+ ), e?.onFailure?.();
1239
1332
  return;
1240
1333
  }
1241
- a("error", "Failed to recover persisted events", { error: n }), t && this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.();
1334
+ t = this.ensureBatchMetadata(this.createRecoveryBody(i)), await this.send(t) ? (this.clearPersistedEvents(), e?.onSuccess?.(i.events.length, i.events, t)) : (this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.());
1335
+ } catch (i) {
1336
+ if (i instanceof O) {
1337
+ this.logPermanentError("Permanent error during recovery, clearing persisted events", i), this.clearPersistedEvents(), e?.onFailure?.();
1338
+ return;
1339
+ }
1340
+ a("error", "Failed to recover persisted events", { error: i }), t && this.persistEventsWithFailureCount(t, s + 1, !0), e?.onFailure?.();
1242
1341
  } finally {
1243
1342
  this.recoveryInProgress = !1;
1244
1343
  }
@@ -1288,7 +1387,7 @@ class Ze extends _ {
1288
1387
  const t = this.transformers.beforeSend;
1289
1388
  if (!t)
1290
1389
  return e;
1291
- const s = Es(
1390
+ const s = ps(
1292
1391
  e.events,
1293
1392
  t,
1294
1393
  this.integrationId || "SenderManager"
@@ -1355,8 +1454,8 @@ class Ze extends _ {
1355
1454
  * @returns Promise that resolves after calculated delay
1356
1455
  */
1357
1456
  async backoffDelay(e) {
1358
- const t = 100 * Math.pow(2, e), s = Math.random() * 100, n = t + s;
1359
- return new Promise((i) => setTimeout(i, n));
1457
+ const t = 100 * Math.pow(2, e), s = Math.random() * 100, i = t + s;
1458
+ return new Promise((n) => setTimeout(n, i));
1360
1459
  }
1361
1460
  /**
1362
1461
  * Sends event queue with automatic retry logic for transient failures.
@@ -1401,67 +1500,74 @@ class Ze extends _ {
1401
1500
  const s = this.applyBeforeBatchTransformer(t);
1402
1501
  if (!s)
1403
1502
  return !0;
1404
- const n = this.ensureBatchMetadata(s, e._metadata?.idempotency_token);
1503
+ const i = this.ensureBatchMetadata(s, e._metadata?.idempotency_token);
1405
1504
  if (this.apiUrl?.includes($.Fail))
1406
1505
  return a("debug", `Fail mode: simulating network failure${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1407
- data: { events: n.events.length }
1506
+ data: { events: i.events.length }
1408
1507
  }), !1;
1409
1508
  if (this.apiUrl?.includes($.Localhost))
1410
1509
  return a("debug", `Success mode: simulating successful send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1411
- data: { events: n.events.length }
1510
+ data: { events: i.events.length }
1412
1511
  }), !0;
1512
+ if (this.isRateLimited())
1513
+ return a("debug", `Rate-limit cooldown active, skipping send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1514
+ data: {
1515
+ cooldownRemainingMs: this.rateLimitedUntil - Date.now(),
1516
+ events: i.events.length
1517
+ }
1518
+ }), !1;
1413
1519
  if (this.consecutiveNetworkFailures >= 3) {
1414
- const u = Date.now() - this.circuitOpenedAt;
1415
- if (u < 12e4)
1520
+ const d = Date.now() - this.circuitOpenedAt;
1521
+ if (d < 12e4)
1416
1522
  return a("debug", `Network circuit open, skipping send${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1417
1523
  data: {
1418
1524
  consecutiveNetworkFailures: this.consecutiveNetworkFailures,
1419
- cooldownRemainingMs: 12e4 - u
1525
+ cooldownRemainingMs: 12e4 - d
1420
1526
  }
1421
1527
  }), !1;
1422
1528
  }
1423
- const { url: i, payload: o } = this.prepareRequest(n);
1529
+ const { url: n, payload: o } = this.prepareRequest(i);
1424
1530
  let l = !0, c = !1;
1425
- for (let u = 1; u <= 3; u++)
1531
+ for (let d = 1; d <= 3; d++)
1426
1532
  try {
1427
- return (await this.sendWithTimeout(i, o)).ok ? (u > 1 && a(
1533
+ return (await this.sendWithTimeout(n, o)).ok ? (d > 1 && a(
1428
1534
  "info",
1429
- `Send succeeded after ${u - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
1535
+ `Send succeeded after ${d - 1} retry attempt(s)${this.integrationId ? ` [${this.integrationId}]` : ""}`,
1430
1536
  {
1431
- data: { events: n.events.length, attempt: u }
1537
+ data: { events: i.events.length, attempt: d }
1432
1538
  }
1433
1539
  ), this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, !0) : !1;
1434
1540
  } catch (f) {
1435
- const g = u === 3;
1541
+ const g = d === 3;
1436
1542
  if (f instanceof O)
1437
1543
  throw this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, f;
1438
1544
  if (f instanceof re) {
1439
- this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l = !1, c = !0, a("warn", `Rate limited, skipping retries${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1440
- data: { events: e.events.length, attempt: u }
1545
+ this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0, l = !1, c = !0, this.armRateLimitCooldown(Date.now() + 6e4), a("warn", `Rate limited, skipping retries${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1546
+ data: { events: e.events.length, attempt: d, cooldownMs: 6e4 }
1441
1547
  });
1442
1548
  break;
1443
1549
  }
1444
- if (f instanceof ne || (l = !1), f instanceof TypeError || (c = !0), a(
1550
+ if (f instanceof ie || (l = !1), f instanceof TypeError || (c = !0), a(
1445
1551
  g ? "error" : "warn",
1446
- `Send attempt ${u} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${g ? " (all retries exhausted)" : ", will retry"}`,
1552
+ `Send attempt ${d} failed${this.integrationId ? ` [${this.integrationId}]` : ""}${g ? " (all retries exhausted)" : ", will retry"}`,
1447
1553
  {
1448
1554
  error: f,
1449
1555
  data: {
1450
1556
  events: e.events.length,
1451
- url: i.replace(/\/\/[^/]+/, "//[DOMAIN]"),
1452
- attempt: u,
1557
+ url: n.replace(/\/\/[^/]+/, "//[DOMAIN]"),
1558
+ attempt: d,
1453
1559
  maxAttempts: 3
1454
1560
  }
1455
1561
  }
1456
1562
  ), !g) {
1457
- await this.backoffDelay(u);
1563
+ await this.backoffDelay(d);
1458
1564
  continue;
1459
1565
  }
1460
1566
  return l ? (a(
1461
1567
  "debug",
1462
1568
  `All retry attempts timed out, preserving batch for retry${this.integrationId ? ` [${this.integrationId}]` : ""}`,
1463
1569
  {
1464
- data: { events: n.events.length }
1570
+ data: { events: i.events.length }
1465
1571
  }
1466
1572
  ), !1) : (c ? (this.consecutiveNetworkFailures = 0, this.circuitOpenedAt = 0) : (this.consecutiveNetworkFailures = Math.min(
1467
1573
  this.consecutiveNetworkFailures + 1,
@@ -1496,9 +1602,9 @@ class Ze extends _ {
1496
1602
  async sendWithTimeout(e, t) {
1497
1603
  const s = new AbortController();
1498
1604
  this.pendingControllers.add(s);
1499
- let n = !1;
1500
- const i = setTimeout(() => {
1501
- n = !0, s.abort();
1605
+ let i = !1;
1606
+ const n = setTimeout(() => {
1607
+ i = !0, s.abort();
1502
1608
  }, 15e3);
1503
1609
  try {
1504
1610
  const o = this.getCustomHeaders(), l = await fetch(e, {
@@ -1516,9 +1622,9 @@ class Ze extends _ {
1516
1622
  throw l.status >= 400 && l.status < 500 && l.status !== 408 && l.status !== 429 ? new O(`HTTP ${l.status}: ${l.statusText}`, l.status) : l.status === 429 ? new re(`HTTP 429: ${l.statusText}`) : new Error(`HTTP ${l.status}: ${l.statusText}`);
1517
1623
  return l;
1518
1624
  } catch (o) {
1519
- throw o instanceof O ? o : n ? new ne("Request timed out") : o;
1625
+ throw o instanceof O ? o : i ? new ie("Request timed out") : o;
1520
1626
  } finally {
1521
- clearTimeout(i), this.pendingControllers.delete(s);
1627
+ clearTimeout(n), this.pendingControllers.delete(s);
1522
1628
  }
1523
1629
  }
1524
1630
  /**
@@ -1545,10 +1651,10 @@ class Ze extends _ {
1545
1651
  const t = this.ensureBatchMetadata(e), s = this.applyBeforeSendTransformer(t);
1546
1652
  if (!s)
1547
1653
  return !0;
1548
- const n = this.applyBeforeBatchTransformer(s);
1549
- if (!n)
1654
+ const i = this.applyBeforeBatchTransformer(s);
1655
+ if (!i)
1550
1656
  return !0;
1551
- const i = this.ensureBatchMetadata(n, t._metadata?.idempotency_token), { url: o, payload: l } = this.prepareRequest(i);
1657
+ const n = this.ensureBatchMetadata(i, t._metadata?.idempotency_token), { url: o, payload: l } = this.prepareRequest(n);
1552
1658
  if (l.length > 65536)
1553
1659
  return a(
1554
1660
  "warn",
@@ -1557,7 +1663,7 @@ class Ze extends _ {
1557
1663
  data: {
1558
1664
  size: l.length,
1559
1665
  limit: 65536,
1560
- events: i.events.length
1666
+ events: n.events.length
1561
1667
  }
1562
1668
  }
1563
1669
  ), this.persistEvents(t), !1;
@@ -1567,11 +1673,11 @@ class Ze extends _ {
1567
1673
  "warn",
1568
1674
  `sendBeacon not available, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
1569
1675
  ), this.persistEvents(t), !1;
1570
- const u = navigator.sendBeacon(o, c);
1571
- return u || (a(
1676
+ const d = navigator.sendBeacon(o, c);
1677
+ return d || (a(
1572
1678
  "warn",
1573
1679
  `sendBeacon rejected request, persisting events for recovery${this.integrationId ? ` [${this.integrationId}]` : ""}`
1574
- ), this.persistEvents(t)), u;
1680
+ ), this.persistEvents(t)), d;
1575
1681
  }
1576
1682
  /**
1577
1683
  * Prepares request by enriching payload with metadata and serializing to JSON.
@@ -1602,7 +1708,7 @@ class Ze extends _ {
1602
1708
  idempotency_token: e._metadata?.idempotency_token ?? this.computeContentToken(e),
1603
1709
  referer: typeof window < "u" ? window.location.href : void 0,
1604
1710
  timestamp: t,
1605
- client_version: Jt
1711
+ client_version: Zt
1606
1712
  }
1607
1713
  };
1608
1714
  return {
@@ -1639,11 +1745,11 @@ class Ze extends _ {
1639
1745
  * @private
1640
1746
  */
1641
1747
  computeContentToken(e) {
1642
- const t = e.events.map((i) => i.id).sort().join(","), s = `${e.user_id}|${e.session_id}|${t}`;
1643
- let n = 2166136261;
1644
- for (let i = 0; i < s.length; i++)
1645
- n ^= s.charCodeAt(i), n = Math.imul(n, 16777619) >>> 0;
1646
- return n.toString(16).padStart(8, "0");
1748
+ const t = e.events.map((n) => n.id).sort().join(","), s = `${e.user_id}|${e.session_id}|${t}`;
1749
+ let i = 2166136261;
1750
+ for (let n = 0; n < s.length; n++)
1751
+ i ^= s.charCodeAt(n), i = Math.imul(i, 16777619) >>> 0;
1752
+ return i.toString(16).padStart(8, "0");
1647
1753
  }
1648
1754
  /**
1649
1755
  * Retrieves persisted events from localStorage with error recovery.
@@ -1693,8 +1799,8 @@ class Ze extends _ {
1693
1799
  * @private
1694
1800
  */
1695
1801
  createRecoveryBody(e) {
1696
- const { timestamp: t, recoveryFailures: s, ...n } = e;
1697
- return n;
1802
+ const { timestamp: t, recoveryFailures: s, ...i } = e;
1803
+ return i;
1698
1804
  }
1699
1805
  /**
1700
1806
  * Persists failed events to localStorage for next-page-load recovery.
@@ -1714,7 +1820,8 @@ class Ze extends _ {
1714
1820
  * @private
1715
1821
  */
1716
1822
  persistEvents(e) {
1717
- return this.persistEventsWithFailureCount(e, 0);
1823
+ const t = this.getPersistedData(), s = typeof t?.recoveryFailures == "number" && Number.isFinite(t.recoveryFailures) ? t.recoveryFailures : 0;
1824
+ return this.persistEventsWithFailureCount(e, s);
1718
1825
  }
1719
1826
  /**
1720
1827
  * Persists failed events to localStorage, recording how many consecutive
@@ -1732,9 +1839,9 @@ class Ze extends _ {
1732
1839
  */
1733
1840
  persistEventsWithFailureCount(e, t, s = !1) {
1734
1841
  try {
1735
- const n = this.getPersistedData();
1736
- if (!s && n && n.timestamp) {
1737
- const l = Date.now() - n.timestamp;
1842
+ const i = this.getPersistedData();
1843
+ if (!s && i && i.timestamp) {
1844
+ const l = Date.now() - i.timestamp;
1738
1845
  if (l < 1e3)
1739
1846
  return a(
1740
1847
  "debug",
@@ -1744,14 +1851,14 @@ class Ze extends _ {
1744
1851
  }
1745
1852
  ), !0;
1746
1853
  }
1747
- const i = {
1854
+ const n = {
1748
1855
  ...e,
1749
1856
  timestamp: Date.now(),
1750
1857
  ...t > 0 && { recoveryFailures: t }
1751
1858
  }, o = this.getQueueStorageKey();
1752
- return this.storeManager.setItem(o, JSON.stringify(i)), !!this.storeManager.getItem(o);
1753
- } catch (n) {
1754
- return a("debug", `Failed to persist events${this.integrationId ? ` [${this.integrationId}]` : ""}`, { error: n }), !1;
1859
+ return this.storeManager.setItem(o, JSON.stringify(n)), !!this.storeManager.getItem(o);
1860
+ } catch (i) {
1861
+ return a("debug", `Failed to persist events${this.integrationId ? ` [${this.integrationId}]` : ""}`, { error: i }), !1;
1755
1862
  }
1756
1863
  }
1757
1864
  clearPersistedEvents() {
@@ -1776,12 +1883,12 @@ class Ze extends _ {
1776
1883
  }
1777
1884
  logPermanentError(e, t) {
1778
1885
  const s = Date.now();
1779
- (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= zt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1886
+ (!this.lastPermanentErrorLog || this.lastPermanentErrorLog.statusCode !== t.statusCode || s - this.lastPermanentErrorLog.timestamp >= Kt) && (a("error", `${e}${this.integrationId ? ` [${this.integrationId}]` : ""}`, {
1780
1887
  data: { status: t.statusCode, message: t.message }
1781
1888
  }), this.lastPermanentErrorLog = { statusCode: t.statusCode, timestamp: s });
1782
1889
  }
1783
1890
  }
1784
- class ps extends _ {
1891
+ class Ss extends _ {
1785
1892
  bootTime;
1786
1893
  bootTimestamp;
1787
1894
  hasPerformanceNow;
@@ -1908,10 +2015,10 @@ class ps extends _ {
1908
2015
  * ```
1909
2016
  */
1910
2017
  validateTimestamp(e) {
1911
- const s = this.now(), n = e - s;
1912
- return n > 12e4 ? {
2018
+ const s = this.now(), i = e - s;
2019
+ return i > 12e4 ? {
1913
2020
  valid: !1,
1914
- error: `Timestamp is ${(n / 1e3 / 60).toFixed(2)} minutes in the future (max allowed: 2 minutes)`
2021
+ error: `Timestamp is ${(i / 1e3 / 60).toFixed(2)} minutes in the future (max allowed: 2 minutes)`
1915
2022
  } : { valid: !0 };
1916
2023
  }
1917
2024
  /**
@@ -1930,8 +2037,8 @@ class ps extends _ {
1930
2037
  };
1931
2038
  }
1932
2039
  }
1933
- const Ss = new Set(Object.values(d));
1934
- class Ts extends _ {
2040
+ const Ts = new Set(Object.values(u));
2041
+ class Is extends _ {
1935
2042
  dataSenders;
1936
2043
  emitter;
1937
2044
  transformers;
@@ -1948,11 +2055,11 @@ class Ts extends _ {
1948
2055
  lastSessionId = null;
1949
2056
  sessionEventCounts = {
1950
2057
  total: 0,
1951
- [d.CLICK]: 0,
1952
- [d.PAGE_VIEW]: 0,
1953
- [d.CUSTOM]: 0,
1954
- [d.VIEWPORT_VISIBLE]: 0,
1955
- [d.SCROLL]: 0
2058
+ [u.CLICK]: 0,
2059
+ [u.PAGE_VIEW]: 0,
2060
+ [u.CUSTOM]: 0,
2061
+ [u.VIEWPORT_VISIBLE]: 0,
2062
+ [u.SCROLL]: 0
1956
2063
  };
1957
2064
  saveSessionCountsDebounced = null;
1958
2065
  /**
@@ -1969,8 +2076,8 @@ class Ts extends _ {
1969
2076
  * @param customHeadersProvider - Optional callback for dynamic headers
1970
2077
  * @param fetchCredentials - Fetch credentials mode for custom backend. @default 'include'
1971
2078
  */
1972
- constructor(e, t = null, s = {}, n = {}, i, o = "include") {
1973
- super(), this.emitter = t, this.transformers = s, this.timeManager = new ps(), this.dataSenders = [];
2079
+ constructor(e, t = null, s = {}, i = {}, n, o = "include") {
2080
+ super(), this.emitter = t, this.transformers = s, this.timeManager = new Ss(), this.dataSenders = [];
1974
2081
  const l = this.get("collectApiUrls");
1975
2082
  l?.saas && this.dataSenders.push(new Ze(e, "saas", l.saas, s)), l?.custom && this.dataSenders.push(
1976
2083
  new Ze(
@@ -1978,8 +2085,8 @@ class Ts extends _ {
1978
2085
  "custom",
1979
2086
  l.custom,
1980
2087
  s,
1981
- n,
1982
2088
  i,
2089
+ n,
1983
2090
  o
1984
2091
  )
1985
2092
  ), this.saveSessionCountsDebounced = this.debounce((c) => {
@@ -2013,10 +2120,10 @@ class Ts extends _ {
2013
2120
  async recoverPersistedEvents() {
2014
2121
  const e = this.dataSenders.map(
2015
2122
  async (t) => t.recoverPersistedEvents({
2016
- onSuccess: (s, n, i) => {
2017
- if (n && n.length > 0) {
2018
- const o = n.map((l) => l.id);
2019
- this.removeProcessedEvents(o), i && this.emitEventsQueue(i);
2123
+ onSuccess: (s, i, n) => {
2124
+ if (i && i.length > 0) {
2125
+ const o = i.map((l) => l.id);
2126
+ this.removeProcessedEvents(o), n && this.emitEventsQueue(n);
2020
2127
  }
2021
2128
  },
2022
2129
  onFailure: () => {
@@ -2089,19 +2196,19 @@ class Ts extends _ {
2089
2196
  type: e,
2090
2197
  page_url: t,
2091
2198
  from_page_url: s,
2092
- scroll_data: n,
2093
- click_data: i,
2199
+ scroll_data: i,
2200
+ click_data: n,
2094
2201
  custom_event: o,
2095
2202
  web_vitals: l,
2096
2203
  error_data: c,
2097
- viewport_data: u,
2204
+ viewport_data: d,
2098
2205
  page_view: f
2099
2206
  }) {
2100
2207
  if (!e) {
2101
2208
  a("error", "Event type is required - event will be ignored");
2102
2209
  return;
2103
2210
  }
2104
- if (!Ss.has(e)) {
2211
+ if (!Ts.has(e)) {
2105
2212
  a("error", "Invalid event type - event will be ignored", {
2106
2213
  data: { type: e }
2107
2214
  });
@@ -2115,24 +2222,24 @@ class Ts extends _ {
2115
2222
  type: e,
2116
2223
  page_url: t,
2117
2224
  from_page_url: s,
2118
- scroll_data: n,
2119
- click_data: i,
2225
+ scroll_data: i,
2226
+ click_data: n,
2120
2227
  custom_event: o,
2121
2228
  web_vitals: l,
2122
2229
  error_data: c,
2123
- viewport_data: u,
2230
+ viewport_data: d,
2124
2231
  page_view: f
2125
2232
  });
2126
2233
  return;
2127
2234
  }
2128
2235
  this.lastSessionId !== g && (this.lastSessionId = g, this.sessionEventCounts = this.loadSessionCounts(g));
2129
- const T = e === d.SESSION_START;
2130
- if (T && a("debug", "Processing SESSION_START event", {
2236
+ const I = e === u.SESSION_START;
2237
+ if (I && a("debug", "Processing SESSION_START event", {
2131
2238
  data: { sessionId: g }
2132
- }), !T && !this.checkRateLimit())
2239
+ }), !I && !this.checkRateLimit())
2133
2240
  return;
2134
2241
  const p = e;
2135
- if (!T) {
2242
+ if (!I) {
2136
2243
  if (this.sessionEventCounts.total >= 1e3) {
2137
2244
  a("warn", "Session event limit reached", {
2138
2245
  data: {
@@ -2158,24 +2265,24 @@ class Ts extends _ {
2158
2265
  }
2159
2266
  }
2160
2267
  }
2161
- if (p === d.CUSTOM && o?.name) {
2268
+ if (p === u.CUSTOM && o?.name) {
2162
2269
  const v = this.get("config")?.maxSameEventPerMinute ?? 60;
2163
2270
  if (!this.checkPerEventRateLimit(o.name, v))
2164
2271
  return;
2165
2272
  }
2166
- const Ve = p === d.SESSION_START, K = t || this.get("pageUrl"), x = this.buildEventPayload({
2273
+ const Ve = p === u.SESSION_START, Q = t || this.get("pageUrl"), x = this.buildEventPayload({
2167
2274
  type: p,
2168
- page_url: K,
2275
+ page_url: Q,
2169
2276
  from_page_url: s,
2170
- scroll_data: n,
2171
- click_data: i,
2277
+ scroll_data: i,
2278
+ click_data: n,
2172
2279
  custom_event: o,
2173
2280
  web_vitals: l,
2174
2281
  error_data: c,
2175
- viewport_data: u,
2282
+ viewport_data: d,
2176
2283
  page_view: f
2177
2284
  });
2178
- if (x && !(!T && !this.shouldSample())) {
2285
+ if (x && !(!I && !this.shouldSample())) {
2179
2286
  if (Ve) {
2180
2287
  const v = this.get("sessionId");
2181
2288
  if (!v) {
@@ -2191,8 +2298,8 @@ class Ts extends _ {
2191
2298
  this.set("hasStartSession", !0);
2192
2299
  }
2193
2300
  if (!this.isDuplicateEvent(x)) {
2194
- if (this.get("mode") === ie.QA) {
2195
- if (p === d.CUSTOM && o) {
2301
+ if (this.get("mode") === ne.QA) {
2302
+ if (p === u.CUSTOM && o) {
2196
2303
  a("info", `Custom Event: ${o.name}`, {
2197
2304
  visibility: "qa",
2198
2305
  data: {
@@ -2202,22 +2309,22 @@ class Ts extends _ {
2202
2309
  }), this.emitEvent(x);
2203
2310
  return;
2204
2311
  }
2205
- if (p === d.VIEWPORT_VISIBLE && u) {
2206
- const v = u.name || u.id || u.selector;
2312
+ if (p === u.VIEWPORT_VISIBLE && d) {
2313
+ const v = d.name || d.id || d.selector;
2207
2314
  a("info", `Viewport Visible: ${v}`, {
2208
2315
  visibility: "qa",
2209
2316
  data: {
2210
- selector: u.selector,
2211
- ...u.name && { name: u.name },
2212
- ...u.id && { id: u.id },
2213
- visibilityRatio: u.visibilityRatio,
2214
- dwellTime: u.dwellTime
2317
+ selector: d.selector,
2318
+ ...d.name && { name: d.name },
2319
+ ...d.id && { id: d.id },
2320
+ visibilityRatio: d.visibilityRatio,
2321
+ dwellTime: d.dwellTime
2215
2322
  }
2216
2323
  }), this.emitEvent(x);
2217
2324
  return;
2218
2325
  }
2219
2326
  }
2220
- if (this.addToQueue(x), !T) {
2327
+ if (this.addToQueue(x), !I) {
2221
2328
  this.sessionEventCounts.total++, this.sessionEventCounts[p] !== void 0 && this.sessionEventCounts[p]++;
2222
2329
  const v = this.get("sessionId");
2223
2330
  v && this.saveSessionCountsDebounced && this.saveSessionCountsDebounced(v);
@@ -2264,11 +2371,11 @@ class Ts extends _ {
2264
2371
  const e = this.get("sessionId");
2265
2372
  e && this.saveSessionCounts(e), this.eventsQueue = [], this.pendingEventsBuffer = [], this.recentEventFingerprints.clear(), this.rateLimitCounter = 0, this.rateLimitWindowStart = 0, this.perEventRateLimits.clear(), this.sessionEventCounts = {
2266
2373
  total: 0,
2267
- [d.CLICK]: 0,
2268
- [d.PAGE_VIEW]: 0,
2269
- [d.CUSTOM]: 0,
2270
- [d.VIEWPORT_VISIBLE]: 0,
2271
- [d.SCROLL]: 0
2374
+ [u.CLICK]: 0,
2375
+ [u.PAGE_VIEW]: 0,
2376
+ [u.CUSTOM]: 0,
2377
+ [u.VIEWPORT_VISIBLE]: 0,
2378
+ [u.SCROLL]: 0
2272
2379
  }, this.lastSessionId = null, this.set("hasStartSession", !1), this.dataSenders.forEach((t) => {
2273
2380
  t.stop();
2274
2381
  });
@@ -2484,23 +2591,23 @@ class Ts extends _ {
2484
2591
  return e ? !0 : Promise.resolve(!0);
2485
2592
  if (!e && this.sendInProgress)
2486
2593
  return a("debug", "Async flush skipped: send already in progress"), Promise.resolve(!1);
2487
- const t = this.buildEventsPayload(), s = [...this.eventsQueue], n = s.map((i) => i.id);
2594
+ const t = this.buildEventsPayload(), s = [...this.eventsQueue], i = s.map((n) => n.id);
2488
2595
  if (this.dataSenders.length === 0)
2489
- return this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
2596
+ return this.removeProcessedEvents(i), this.clearSendTimeout(), this.emitEventsQueue(t), e ? !0 : Promise.resolve(!0);
2490
2597
  if (e && this.sendInProgress) {
2491
- for (const i of this.dataSenders)
2492
- i.persistForRecovery(t);
2598
+ for (const n of this.dataSenders)
2599
+ n.persistForRecovery(t);
2493
2600
  return a("debug", "Sync flush deferred: async send in progress, events persisted for recovery", {
2494
- data: { eventCount: n.length }
2601
+ data: { eventCount: i.length }
2495
2602
  }), !0;
2496
2603
  }
2497
2604
  if (e) {
2498
2605
  const o = this.dataSenders.map((l) => l.sendEventsQueueSync(t)).some((l) => l);
2499
- return o ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : (this.clearSendTimeout(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
2500
- data: { eventCount: n.length }
2606
+ return o ? (this.removeProcessedEvents(i), this.clearSendTimeout(), this.emitEventsQueue(t)) : (this.clearSendTimeout(), a("debug", "Sync flush complete failure, events kept in queue for retry", {
2607
+ data: { eventCount: i.length }
2501
2608
  })), o;
2502
2609
  } else {
2503
- const i = this.dataSenders.map(
2610
+ const n = this.dataSenders.map(
2504
2611
  async (o) => o.sendEventsQueue(t, {
2505
2612
  onSuccess: () => {
2506
2613
  },
@@ -2508,9 +2615,9 @@ class Ts extends _ {
2508
2615
  }
2509
2616
  })
2510
2617
  );
2511
- return Promise.allSettled(i).then((o) => {
2618
+ return Promise.allSettled(n).then((o) => {
2512
2619
  const l = o.some((c) => this.isSuccessfulResult(c));
2513
- return l ? (this.removeProcessedEvents(n), this.clearSendTimeout(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
2620
+ return l ? (this.removeProcessedEvents(i), this.clearSendTimeout(), this.emitEventsQueue(t)) : a("debug", "Async flush complete failure, events kept in queue for retry", {
2514
2621
  data: { eventCount: s.length }
2515
2622
  }), l;
2516
2623
  });
@@ -2525,17 +2632,17 @@ class Ts extends _ {
2525
2632
  this.emitEventsQueue(e);
2526
2633
  return;
2527
2634
  }
2528
- const t = [...this.eventsQueue], s = t.map((l) => l.id), n = this.dataSenders.map(
2635
+ const t = [...this.eventsQueue], s = t.map((l) => l.id), i = this.dataSenders.map(
2529
2636
  async (l) => l.sendEventsQueue(e, {
2530
2637
  onSuccess: () => {
2531
2638
  },
2532
2639
  onFailure: () => {
2533
2640
  }
2534
2641
  })
2535
- ), i = await Promise.allSettled(n);
2536
- if (i.some((l) => this.isSuccessfulResult(l))) {
2642
+ ), n = await Promise.allSettled(i);
2643
+ if (n.some((l) => this.isSuccessfulResult(l))) {
2537
2644
  this.consecutiveSendFailures = 0, this.removeProcessedEvents(s), this.emitEventsQueue(e);
2538
- const l = i.filter((c) => !this.isSuccessfulResult(c)).length;
2645
+ const l = n.filter((c) => !this.isSuccessfulResult(c)).length;
2539
2646
  l > 0 && a("debug", "Periodic send completed with some failures, removed from queue and persisted per-integration", {
2540
2647
  data: { eventCount: t.length, failedCount: l }
2541
2648
  });
@@ -2552,11 +2659,11 @@ class Ts extends _ {
2552
2659
  buildEventsPayload() {
2553
2660
  const e = /* @__PURE__ */ new Map(), t = [];
2554
2661
  for (const c of this.eventsQueue) {
2555
- const u = this.createEventSignature(c);
2556
- e.has(u) || t.push(u), e.set(u, c);
2662
+ const d = this.createEventSignature(c);
2663
+ e.has(d) || t.push(d), e.set(d, c);
2557
2664
  }
2558
- const s = t.map((c) => e.get(c)).filter((c) => !!c).sort((c, u) => c.type === d.SESSION_START && u.type !== d.SESSION_START ? -1 : u.type === d.SESSION_START && c.type !== d.SESSION_START ? 1 : c.timestamp - u.timestamp);
2559
- let n = {
2665
+ const s = t.map((c) => e.get(c)).filter((c) => !!c).sort((c, d) => c.type === u.SESSION_START && d.type !== u.SESSION_START ? -1 : d.type === u.SESSION_START && c.type !== u.SESSION_START ? 1 : c.timestamp - d.timestamp);
2666
+ let i = {
2560
2667
  user_id: this.get("userId"),
2561
2668
  session_id: this.get("sessionId"),
2562
2669
  device: this.get("device"),
@@ -2564,25 +2671,25 @@ class Ts extends _ {
2564
2671
  ...this.get("config")?.globalMetadata && { global_metadata: this.get("config")?.globalMetadata },
2565
2672
  ...this.get("identity") && { identify: this.get("identity") }
2566
2673
  };
2567
- const i = this.get("collectApiUrls"), o = !!(i?.custom || i?.saas), l = this.transformers.beforeBatch;
2674
+ const n = this.get("collectApiUrls"), o = !!(n?.custom || n?.saas), l = this.transformers.beforeBatch;
2568
2675
  if (!o && l) {
2569
- const c = gt(n, l, "EventManager");
2570
- c !== null && (n = c);
2676
+ const c = gt(i, l, "EventManager");
2677
+ c !== null && (i = c);
2571
2678
  }
2572
- return n;
2679
+ return i;
2573
2680
  }
2574
2681
  buildEventPayload(e) {
2575
- const t = e.page_url ?? this.get("pageUrl"), s = this.timeManager.now(), n = this.timeManager.validateTimestamp(s);
2576
- n.valid || a("warn", "Event timestamp validation failed", {
2577
- data: { type: e.type, error: n.error }
2682
+ const t = e.page_url ?? this.get("pageUrl"), s = this.timeManager.now(), i = this.timeManager.validateTimestamp(s);
2683
+ i.valid || a("warn", "Event timestamp validation failed", {
2684
+ data: { type: e.type, error: i.error }
2578
2685
  });
2579
- const i = this.get("sessionReferrer"), o = this.get("sessionUtm");
2686
+ const n = this.get("sessionReferrer"), o = this.get("sessionUtm");
2580
2687
  let l = {
2581
2688
  id: ns(),
2582
2689
  type: e.type,
2583
2690
  page_url: t,
2584
2691
  timestamp: s,
2585
- ...i && { referrer: i },
2692
+ ...n && { referrer: n },
2586
2693
  ...e.from_page_url && { from_page_url: e.from_page_url },
2587
2694
  ...e.scroll_data && { scroll_data: e.scroll_data },
2588
2695
  ...e.click_data && { click_data: e.click_data },
@@ -2593,25 +2700,25 @@ class Ts extends _ {
2593
2700
  ...e.page_view && { page_view: e.page_view },
2594
2701
  ...o && { utm: o }
2595
2702
  };
2596
- const c = this.get("collectApiUrls"), u = !!c?.custom, f = !!c?.saas, g = u || f, T = u && f, p = this.transformers.beforeSend;
2597
- if (p && (!g || u && !T)) {
2598
- const K = mt(l, p, "EventManager");
2599
- if (K === null)
2703
+ const c = this.get("collectApiUrls"), d = !!c?.custom, f = !!c?.saas, g = d || f, I = d && f, p = this.transformers.beforeSend;
2704
+ if (p && (!g || d && !I)) {
2705
+ const Q = mt(l, p, "EventManager");
2706
+ if (Q === null)
2600
2707
  return null;
2601
- l = K;
2708
+ l = Q;
2602
2709
  }
2603
2710
  return l;
2604
2711
  }
2605
2712
  isDuplicateEvent(e) {
2606
- const t = Date.now(), s = this.createEventFingerprint(e), n = this.recentEventFingerprints.get(s);
2607
- return n && t - n < 1e3 ? (this.recentEventFingerprints.set(s, t), !0) : (this.recentEventFingerprints.set(s, t), this.recentEventFingerprints.size > 1500 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 3e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(s, t), a("debug", "Event fingerprint cache exceeded hard limit, cleared", {
2713
+ const t = Date.now(), s = this.createEventFingerprint(e), i = this.recentEventFingerprints.get(s);
2714
+ return i && t - i < 1e3 ? (this.recentEventFingerprints.set(s, t), !0) : (this.recentEventFingerprints.set(s, t), this.recentEventFingerprints.size > 1500 && this.pruneOldFingerprints(), this.recentEventFingerprints.size > 3e3 && (this.recentEventFingerprints.clear(), this.recentEventFingerprints.set(s, t), a("debug", "Event fingerprint cache exceeded hard limit, cleared", {
2608
2715
  data: { hardLimit: 3e3 }
2609
2716
  })), !1);
2610
2717
  }
2611
2718
  pruneOldFingerprints() {
2612
2719
  const e = Date.now(), t = 1e3 * 10;
2613
- for (const [s, n] of this.recentEventFingerprints.entries())
2614
- e - n > t && this.recentEventFingerprints.delete(s);
2720
+ for (const [s, i] of this.recentEventFingerprints.entries())
2721
+ e - i > t && this.recentEventFingerprints.delete(s);
2615
2722
  a("debug", "Pruned old event fingerprints", {
2616
2723
  data: {
2617
2724
  remaining: this.recentEventFingerprints.size,
@@ -2622,8 +2729,8 @@ class Ts extends _ {
2622
2729
  createEventFingerprint(e) {
2623
2730
  let t = `${e.type}_${e.page_url}`;
2624
2731
  if (e.click_data) {
2625
- const s = Math.round((e.click_data.x || 0) / 10) * 10, n = Math.round((e.click_data.y || 0) / 10) * 10;
2626
- t += `_click_${s}_${n}`;
2732
+ const s = Math.round((e.click_data.x || 0) / 10) * 10, i = Math.round((e.click_data.y || 0) / 10) * 10;
2733
+ t += `_click_${s}_${i}`;
2627
2734
  }
2628
2735
  return e.scroll_data && (t += `_scroll_${e.scroll_data.depth}_${e.scroll_data.direction}`), e.custom_event && (t += `_custom_${e.custom_event.name}`, e.custom_event.metadata && (t += `_${this.stableStringify(e.custom_event.metadata)}`)), e.web_vitals && (t += `_vitals_${e.web_vitals.type}`), e.error_data && (t += `_error_${e.error_data.type}_${e.error_data.message}`), t;
2629
2736
  }
@@ -2632,17 +2739,17 @@ class Ts extends _ {
2632
2739
  }
2633
2740
  /** Deterministic JSON string with sorted keys to ensure consistent fingerprints regardless of property insertion order */
2634
2741
  stableStringify(e) {
2635
- return JSON.stringify(e, (t, s) => s && typeof s == "object" && !Array.isArray(s) ? Object.keys(s).sort().reduce((n, i) => (n[i] = s[i], n), {}) : s);
2742
+ return JSON.stringify(e, (t, s) => s && typeof s == "object" && !Array.isArray(s) ? Object.keys(s).sort().reduce((i, n) => (i[n] = s[n], i), {}) : s);
2636
2743
  }
2637
2744
  addToQueue(e) {
2638
2745
  if (this.emitEvent(e), this.eventsQueue.push(e), this.eventsQueue.length > 100) {
2639
- const t = this.eventsQueue.findIndex((n) => n.type !== d.SESSION_START), s = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
2746
+ const t = this.eventsQueue.findIndex((i) => i.type !== u.SESSION_START), s = t >= 0 ? this.eventsQueue.splice(t, 1)[0] : this.eventsQueue.shift();
2640
2747
  a("warn", "Event queue overflow, oldest non-critical event removed", {
2641
2748
  data: {
2642
2749
  maxLength: 100,
2643
2750
  currentLength: this.eventsQueue.length,
2644
2751
  removedEventType: s?.type,
2645
- wasCritical: s?.type === d.SESSION_START
2752
+ wasCritical: s?.type === u.SESSION_START
2646
2753
  }
2647
2754
  });
2648
2755
  }
@@ -2670,22 +2777,22 @@ class Ts extends _ {
2670
2777
  return e - this.rateLimitWindowStart > 1e3 && (this.rateLimitCounter = 0, this.rateLimitWindowStart = e), this.rateLimitCounter >= 50 ? !1 : (this.rateLimitCounter++, !0);
2671
2778
  }
2672
2779
  checkPerEventRateLimit(e, t) {
2673
- const s = Date.now(), i = (this.perEventRateLimits.get(e) ?? []).filter((o) => s - o < 6e4);
2674
- return i.length >= t ? (a("warn", "Per-event rate limit exceeded for custom event", {
2780
+ const s = Date.now(), n = (this.perEventRateLimits.get(e) ?? []).filter((o) => s - o < 6e4);
2781
+ return n.length >= t ? (a("warn", "Per-event rate limit exceeded for custom event", {
2675
2782
  data: {
2676
2783
  eventName: e,
2677
2784
  limit: t,
2678
2785
  window: `${6e4 / 1e3}s`
2679
2786
  }
2680
- }), !1) : (i.push(s), this.perEventRateLimits.set(e, i), !0);
2787
+ }), !1) : (n.push(s), this.perEventRateLimits.set(e, n), !0);
2681
2788
  }
2682
2789
  getTypeLimitForEvent(e) {
2683
2790
  return {
2684
- [d.CLICK]: 500,
2685
- [d.PAGE_VIEW]: 100,
2686
- [d.CUSTOM]: 500,
2687
- [d.VIEWPORT_VISIBLE]: 200,
2688
- [d.SCROLL]: 120
2791
+ [u.CLICK]: 500,
2792
+ [u.PAGE_VIEW]: 100,
2793
+ [u.CUSTOM]: 500,
2794
+ [u.VIEWPORT_VISIBLE]: 200,
2795
+ [u.SCROLL]: 120
2689
2796
  }[e] ?? null;
2690
2797
  }
2691
2798
  removeProcessedEvents(e) {
@@ -2720,9 +2827,9 @@ class Ts extends _ {
2720
2827
  */
2721
2828
  debounce(e, t) {
2722
2829
  let s = null;
2723
- return ((...n) => {
2830
+ return ((...i) => {
2724
2831
  s !== null && clearTimeout(s), s = setTimeout(() => {
2725
- e(...n), s = null;
2832
+ e(...i), s = null;
2726
2833
  }, t);
2727
2834
  });
2728
2835
  }
@@ -2739,11 +2846,11 @@ class Ts extends _ {
2739
2846
  getInitialCounts() {
2740
2847
  return {
2741
2848
  total: 0,
2742
- [d.CLICK]: 0,
2743
- [d.PAGE_VIEW]: 0,
2744
- [d.CUSTOM]: 0,
2745
- [d.VIEWPORT_VISIBLE]: 0,
2746
- [d.SCROLL]: 0
2849
+ [u.CLICK]: 0,
2850
+ [u.PAGE_VIEW]: 0,
2851
+ [u.CUSTOM]: 0,
2852
+ [u.VIEWPORT_VISIBLE]: 0,
2853
+ [u.SCROLL]: 0
2747
2854
  };
2748
2855
  }
2749
2856
  /**
@@ -2772,29 +2879,29 @@ class Ts extends _ {
2772
2879
  loadSessionCounts(e) {
2773
2880
  if (typeof window > "u" || typeof localStorage > "u")
2774
2881
  return this.getInitialCounts();
2775
- const t = this.get("userId") || "anonymous", s = Fe(t, e);
2882
+ const t = this.get("userId") || "anonymous", s = He(t, e);
2776
2883
  try {
2777
- const n = localStorage.getItem(s);
2778
- if (!n)
2884
+ const i = localStorage.getItem(s);
2885
+ if (!i)
2779
2886
  return this.getInitialCounts();
2780
- const i = JSON.parse(n);
2781
- return i._timestamp && Date.now() - i._timestamp > xe ? (a("debug", "Session counts expired, clearing", {
2782
- data: { sessionId: e, age: Date.now() - i._timestamp }
2783
- }), localStorage.removeItem(s), this.getInitialCounts()) : typeof i.total == "number" && typeof i[d.CLICK] == "number" && typeof i[d.PAGE_VIEW] == "number" && typeof i[d.CUSTOM] == "number" && typeof i[d.VIEWPORT_VISIBLE] == "number" && typeof i[d.SCROLL] == "number" ? {
2784
- total: i.total,
2785
- [d.CLICK]: i[d.CLICK],
2786
- [d.PAGE_VIEW]: i[d.PAGE_VIEW],
2787
- [d.CUSTOM]: i[d.CUSTOM],
2788
- [d.VIEWPORT_VISIBLE]: i[d.VIEWPORT_VISIBLE],
2789
- [d.SCROLL]: i[d.SCROLL]
2887
+ const n = JSON.parse(i);
2888
+ return n._timestamp && Date.now() - n._timestamp > xe ? (a("debug", "Session counts expired, clearing", {
2889
+ data: { sessionId: e, age: Date.now() - n._timestamp }
2890
+ }), localStorage.removeItem(s), this.getInitialCounts()) : typeof n.total == "number" && typeof n[u.CLICK] == "number" && typeof n[u.PAGE_VIEW] == "number" && typeof n[u.CUSTOM] == "number" && typeof n[u.VIEWPORT_VISIBLE] == "number" && typeof n[u.SCROLL] == "number" ? {
2891
+ total: n.total,
2892
+ [u.CLICK]: n[u.CLICK],
2893
+ [u.PAGE_VIEW]: n[u.PAGE_VIEW],
2894
+ [u.CUSTOM]: n[u.CUSTOM],
2895
+ [u.VIEWPORT_VISIBLE]: n[u.VIEWPORT_VISIBLE],
2896
+ [u.SCROLL]: n[u.SCROLL]
2790
2897
  } : (a("warn", "Invalid session counts structure in localStorage, resetting", {
2791
- data: { sessionId: e, parsed: i }
2898
+ data: { sessionId: e, parsed: n }
2792
2899
  }), localStorage.removeItem(s), a("debug", "Session counts removed due to invalid/corrupted data", {
2793
- data: { sessionId: e, parsed: i }
2900
+ data: { sessionId: e, parsed: n }
2794
2901
  }), this.getInitialCounts());
2795
- } catch (n) {
2902
+ } catch (i) {
2796
2903
  return a("warn", "Failed to load session counts from localStorage", {
2797
- error: n,
2904
+ error: i,
2798
2905
  data: { sessionId: e }
2799
2906
  }), this.getInitialCounts();
2800
2907
  }
@@ -2825,30 +2932,30 @@ class Ts extends _ {
2825
2932
  try {
2826
2933
  const e = localStorage.getItem($e);
2827
2934
  if (e) {
2828
- const i = Date.now() - parseInt(e, 10);
2829
- if (i < Be) {
2935
+ const n = Date.now() - parseInt(e, 10);
2936
+ if (n < Be) {
2830
2937
  a("debug", "Skipping session counts cleanup (throttled)", {
2831
- data: { timeSinceLastCleanup: i, throttleMs: Be }
2938
+ data: { timeSinceLastCleanup: n, throttleMs: Be }
2832
2939
  });
2833
2940
  return;
2834
2941
  }
2835
2942
  }
2836
- const t = this.get("userId") || "anonymous", s = `${I}:${t}:session_counts:`, n = [];
2837
- for (let i = 0; i < localStorage.length; i++) {
2838
- const o = localStorage.key(i);
2943
+ const t = this.get("userId") || "anonymous", s = `${S}:${t}:session_counts:`, i = [];
2944
+ for (let n = 0; n < localStorage.length; n++) {
2945
+ const o = localStorage.key(n);
2839
2946
  if (o?.startsWith(s))
2840
2947
  try {
2841
2948
  const l = localStorage.getItem(o);
2842
2949
  if (l) {
2843
2950
  const c = JSON.parse(l);
2844
- c._timestamp && Date.now() - c._timestamp > xe && n.push(o);
2951
+ c._timestamp && Date.now() - c._timestamp > xe && i.push(o);
2845
2952
  }
2846
2953
  } catch {
2847
2954
  }
2848
2955
  }
2849
- n.forEach((i) => {
2850
- localStorage.removeItem(i), a("debug", "Cleaned up expired session counts", { data: { key: i } });
2851
- }), n.length > 0 && a("info", `Cleaned up ${n.length} expired session counts entries`), localStorage.setItem($e, Date.now().toString());
2956
+ i.forEach((n) => {
2957
+ localStorage.removeItem(n), a("debug", "Cleaned up expired session counts", { data: { key: n } });
2958
+ }), i.length > 0 && a("info", `Cleaned up ${i.length} expired session counts entries`), localStorage.setItem($e, Date.now().toString());
2852
2959
  } catch (e) {
2853
2960
  a("warn", "Failed to cleanup expired session counts", { error: e });
2854
2961
  }
@@ -2882,23 +2989,23 @@ class Ts extends _ {
2882
2989
  * @internal
2883
2990
  */
2884
2991
  saveSessionCounts(e) {
2885
- const t = this.get("userId") || "anonymous", s = Fe(t, e);
2992
+ const t = this.get("userId") || "anonymous", s = He(t, e);
2886
2993
  try {
2887
- const n = {
2994
+ const i = {
2888
2995
  ...this.sessionEventCounts,
2889
2996
  _timestamp: Date.now(),
2890
2997
  _version: 1
2891
2998
  };
2892
- localStorage.setItem(s, JSON.stringify(n));
2893
- } catch (n) {
2999
+ localStorage.setItem(s, JSON.stringify(i));
3000
+ } catch (i) {
2894
3001
  a("warn", "Failed to persist session counts to localStorage", {
2895
- error: n,
3002
+ error: i,
2896
3003
  data: { sessionId: e }
2897
3004
  });
2898
3005
  }
2899
3006
  }
2900
3007
  }
2901
- class Is {
3008
+ class vs {
2902
3009
  /**
2903
3010
  * Gets or creates a unique user ID.
2904
3011
  *
@@ -2919,12 +3026,12 @@ class Is {
2919
3026
  const t = e.getItem(Te);
2920
3027
  if (t)
2921
3028
  return t;
2922
- const s = ut();
3029
+ const s = dt();
2923
3030
  return e.setItem(Te, s), s;
2924
3031
  }
2925
3032
  }
2926
- const vs = /^\d{13}-[a-z0-9]{9}$/;
2927
- class _s extends _ {
3033
+ const _s = /^\d{13}-[a-z0-9]{9}$/;
3034
+ class ys extends _ {
2928
3035
  storageManager;
2929
3036
  eventManager;
2930
3037
  projectId;
@@ -2950,9 +3057,9 @@ class _s extends _ {
2950
3057
  return;
2951
3058
  }
2952
3059
  const e = this.getProjectId();
2953
- this.broadcastChannel = new BroadcastChannel(Nt(e)), this.broadcastChannel.onmessage = (t) => {
2954
- const { action: s, sessionId: n, timestamp: i, projectId: o } = t.data ?? {};
2955
- o === e && (s === "session_start" && n && typeof i == "number" && i > Date.now() - 5e3 ? (this.set("sessionId", n), this.persistSession(n, i), this.isTracking && this.setupSessionTimeout()) : s && s !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: s } }));
3060
+ this.broadcastChannel = new BroadcastChannel(Ot(e)), this.broadcastChannel.onmessage = (t) => {
3061
+ const { action: s, sessionId: i, timestamp: n, projectId: o } = t.data ?? {};
3062
+ o === e && (s === "session_start" && i && typeof n == "number" && n > Date.now() - 5e3 ? (this.set("sessionId", i), this.persistSession(i, n), this.isTracking && this.setupSessionTimeout()) : s && s !== "session_start" && a("debug", "Ignored BroadcastChannel message with unknown action", { data: { action: s } }));
2956
3063
  };
2957
3064
  }
2958
3065
  shareSession(e) {
@@ -2970,19 +3077,19 @@ class _s extends _ {
2970
3077
  const e = this.loadStoredSession();
2971
3078
  if (!e)
2972
3079
  return null;
2973
- if (!vs.test(e.id))
3080
+ if (!_s.test(e.id))
2974
3081
  return a("warn", "Invalid session ID format recovered from storage, clearing", {
2975
3082
  data: { sessionId: e.id }
2976
3083
  }), this.clearStoredSession(), null;
2977
3084
  const t = this.get("config")?.sessionTimeout ?? 9e5;
2978
3085
  return Date.now() - e.lastActivity > t ? (this.clearStoredSession(), null) : e.id;
2979
3086
  }
2980
- persistSession(e, t = Date.now(), s, n) {
3087
+ persistSession(e, t = Date.now(), s, i) {
2981
3088
  this.saveStoredSession({
2982
3089
  id: e,
2983
3090
  lastActivity: t,
2984
3091
  ...s && { referrer: s },
2985
- ...n && { utm: n }
3092
+ ...i && { utm: i }
2986
3093
  });
2987
3094
  }
2988
3095
  clearStoredSession() {
@@ -2993,18 +3100,18 @@ class _s extends _ {
2993
3100
  const e = this.getSessionStorageKey(), t = this.storageManager.getItem(e);
2994
3101
  if (t !== null)
2995
3102
  try {
2996
- const n = JSON.parse(t);
2997
- if (n.id && typeof n.lastActivity == "number")
2998
- return n;
3103
+ const i = JSON.parse(t);
3104
+ if (i.id && typeof i.lastActivity == "number")
3105
+ return i;
2999
3106
  } catch {
3000
3107
  this.storageManager.removeItem(e);
3001
3108
  }
3002
3109
  const s = this.storageManager.getSessionItem(e);
3003
3110
  if (s !== null)
3004
3111
  try {
3005
- const n = JSON.parse(s);
3006
- if (n.id && typeof n.lastActivity == "number")
3007
- return n;
3112
+ const i = JSON.parse(s);
3113
+ if (i.id && typeof i.lastActivity == "number")
3114
+ return i;
3008
3115
  } catch {
3009
3116
  this.storageManager.removeSessionItem(e);
3010
3117
  }
@@ -3015,7 +3122,7 @@ class _s extends _ {
3015
3122
  this.storageManager.setItem(t, s), this.storageManager.setSessionItem(t, s);
3016
3123
  }
3017
3124
  getSessionStorageKey() {
3018
- return Rt(this.getProjectId());
3125
+ return Nt(this.getProjectId());
3019
3126
  }
3020
3127
  getProjectId() {
3021
3128
  return this.projectId;
@@ -3078,31 +3185,31 @@ class _s extends _ {
3078
3185
  return;
3079
3186
  }
3080
3187
  const e = this.recoverSession(), t = e ?? this.generateSessionId();
3081
- let s, n;
3188
+ let s, i;
3082
3189
  if (e) {
3083
- const i = this.loadStoredSession();
3084
- s = i?.referrer ?? me(), n = i?.utm ?? ge();
3190
+ const n = this.loadStoredSession();
3191
+ s = n?.referrer ?? me(), i = n?.utm ?? ge();
3085
3192
  } else
3086
- s = me(), n = ge();
3193
+ s = me(), i = ge();
3087
3194
  a("debug", "Session tracking initialized", {
3088
3195
  data: {
3089
3196
  sessionId: t,
3090
3197
  wasRecovered: !!e,
3091
3198
  willEmitSessionStart: !e,
3092
3199
  sessionReferrer: s,
3093
- hasUtm: !!n
3200
+ hasUtm: !!i
3094
3201
  }
3095
3202
  }), this.isTracking = !0;
3096
3203
  try {
3097
- this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", n), this.persistSession(t, Date.now(), s, n), this.initCrossTabSync(), this.shareSession(t), e ? a("debug", "Session recovered, skipping SESSION_START", {
3204
+ this.set("sessionId", t), this.set("sessionReferrer", s), this.set("sessionUtm", i), this.persistSession(t, Date.now(), s, i), this.initCrossTabSync(), this.shareSession(t), e ? a("debug", "Session recovered, skipping SESSION_START", {
3098
3205
  data: { sessionId: t }
3099
3206
  }) : (a("debug", "Emitting SESSION_START event", {
3100
3207
  data: { sessionId: t }
3101
3208
  }), this.eventManager.track({
3102
- type: d.SESSION_START
3209
+ type: u.SESSION_START
3103
3210
  })), this.setupSessionTimeout(), this.setupActivityListeners(), this.setupLifecycleListeners();
3104
- } catch (i) {
3105
- throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), i;
3211
+ } catch (n) {
3212
+ throw this.isTracking = !1, this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupLifecycleListeners(), this.cleanupCrossTabSync(), this.set("sessionId", null), n;
3106
3213
  }
3107
3214
  }
3108
3215
  generateSessionId() {
@@ -3138,7 +3245,7 @@ class _s extends _ {
3138
3245
  a("debug", "Renewing session after timeout", {
3139
3246
  data: { newSessionId: e }
3140
3247
  }), this.set("sessionId", e), this.set("sessionReferrer", t), this.set("sessionUtm", s), this.persistSession(e, Date.now(), t, s), this.cleanupCrossTabSync(), this.initCrossTabSync(), this.shareSession(e), this.eventManager.track({
3141
- type: d.SESSION_START
3248
+ type: u.SESSION_START
3142
3249
  }), this.eventManager.flushPendingEvents(), this.setupSessionTimeout();
3143
3250
  }
3144
3251
  cleanupActivityListeners() {
@@ -3255,7 +3362,7 @@ class _s extends _ {
3255
3362
  this.clearSessionTimeout(), this.cleanupActivityListeners(), this.cleanupCrossTabSync(), this.cleanupLifecycleListeners(), this.isTracking = !1, this.needsRenewal = !1, this.set("hasStartSession", !1);
3256
3363
  }
3257
3364
  }
3258
- class ys extends _ {
3365
+ class ws extends _ {
3259
3366
  eventManager;
3260
3367
  storageManager;
3261
3368
  sessionManager = null;
@@ -3290,7 +3397,7 @@ class ys extends _ {
3290
3397
  }
3291
3398
  const t = this.get("config")?.integrations?.tracelog?.projectId ?? "custom";
3292
3399
  try {
3293
- this.sessionManager = new _s(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
3400
+ this.sessionManager = new ys(this.storageManager, this.eventManager, t), this.sessionManager.startTracking(), this.eventManager.flushPendingEvents();
3294
3401
  } catch (s) {
3295
3402
  if (this.sessionManager) {
3296
3403
  try {
@@ -3343,7 +3450,7 @@ class ys extends _ {
3343
3450
  this.destroyed || (this.sessionManager && (this.sessionManager.destroy(), this.sessionManager = null), this.destroyed = !0);
3344
3451
  }
3345
3452
  }
3346
- class ws extends _ {
3453
+ class bs extends _ {
3347
3454
  eventManager;
3348
3455
  onTrack;
3349
3456
  originalPushState;
@@ -3386,40 +3493,40 @@ class ws extends _ {
3386
3493
  const e = window.location.href, t = ye(e, this.get("config").sensitiveQueryParams);
3387
3494
  if (this.get("pageUrl") === t)
3388
3495
  return;
3389
- const s = Date.now(), n = this.get("config").pageViewThrottleMs ?? 1e3;
3390
- if (s - this.lastPageViewTime < n)
3496
+ const s = Date.now(), i = this.get("config").pageViewThrottleMs ?? 1e3;
3497
+ if (s - this.lastPageViewTime < i)
3391
3498
  return;
3392
3499
  this.lastPageViewTime = s, this.onTrack();
3393
- const i = this.get("pageUrl");
3500
+ const n = this.get("pageUrl");
3394
3501
  this.set("pageUrl", t);
3395
3502
  const o = this.extractPageViewData();
3396
3503
  this.eventManager.track({
3397
- type: d.PAGE_VIEW,
3504
+ type: u.PAGE_VIEW,
3398
3505
  page_url: this.get("pageUrl"),
3399
- from_page_url: i,
3506
+ from_page_url: n,
3400
3507
  ...o && { page_view: o }
3401
3508
  });
3402
3509
  };
3403
3510
  trackInitialPageView() {
3404
3511
  const e = ye(window.location.href, this.get("config").sensitiveQueryParams), t = this.extractPageViewData();
3405
3512
  this.lastPageViewTime = Date.now(), this.eventManager.track({
3406
- type: d.PAGE_VIEW,
3513
+ type: u.PAGE_VIEW,
3407
3514
  page_url: e,
3408
3515
  ...t && { page_view: t }
3409
3516
  }), this.onTrack();
3410
3517
  }
3411
3518
  extractPageViewData() {
3412
- const { pathname: e, search: t, hash: s } = window.location, { referrer: n } = document, { title: i } = document;
3413
- return !n && !i && !e && !t && !s ? void 0 : {
3414
- ...n && { referrer: n },
3415
- ...i && { title: i },
3519
+ const { pathname: e, search: t, hash: s } = window.location, { referrer: i } = document, { title: n } = document;
3520
+ return !i && !n && !e && !t && !s ? void 0 : {
3521
+ ...i && { referrer: i },
3522
+ ...n && { title: n },
3416
3523
  ...e && { pathname: e },
3417
3524
  ...t && { search: t },
3418
3525
  ...s && { hash: s }
3419
3526
  };
3420
3527
  }
3421
3528
  }
3422
- class bs extends _ {
3529
+ class Ls extends _ {
3423
3530
  eventManager;
3424
3531
  lastClickTimes = /* @__PURE__ */ new Map();
3425
3532
  clickHandler;
@@ -3442,23 +3549,23 @@ class bs extends _ {
3442
3549
  */
3443
3550
  startTracking() {
3444
3551
  this.clickHandler || (this.clickHandler = (e) => {
3445
- const t = e, s = t.target, n = typeof HTMLElement < "u" && s instanceof HTMLElement ? s : typeof HTMLElement < "u" && s instanceof Node && s.parentElement instanceof HTMLElement ? s.parentElement : null;
3446
- if (!n) {
3552
+ const t = e, s = t.target, i = typeof HTMLElement < "u" && s instanceof HTMLElement ? s : typeof HTMLElement < "u" && s instanceof Node && s.parentElement instanceof HTMLElement ? s.parentElement : null;
3553
+ if (!i) {
3447
3554
  a("debug", "Click target not found or not an element");
3448
3555
  return;
3449
3556
  }
3450
- if (this.shouldIgnoreElement(n))
3557
+ if (this.shouldIgnoreElement(i))
3451
3558
  return;
3452
- const i = this.get("config")?.clickThrottleMs ?? 300;
3453
- if (i > 0 && !this.checkClickThrottle(n, i))
3559
+ const n = this.get("config")?.clickThrottleMs ?? 300;
3560
+ if (n > 0 && !this.checkClickThrottle(i, n))
3454
3561
  return;
3455
- const o = this.findTrackingElement(n), l = this.getRelevantClickElement(n), c = this.calculateClickCoordinates(t, n);
3562
+ const o = this.findTrackingElement(i), l = this.getRelevantClickElement(i), c = this.calculateClickCoordinates(t, i);
3456
3563
  if (o) {
3457
3564
  const f = this.extractTrackingData(o);
3458
3565
  if (f) {
3459
3566
  const g = this.createCustomEventData(f);
3460
3567
  this.eventManager.track({
3461
- type: d.CUSTOM,
3568
+ type: u.CUSTOM,
3462
3569
  custom_event: {
3463
3570
  name: g.name,
3464
3571
  ...g.value && { metadata: { value: g.value } }
@@ -3466,10 +3573,10 @@ class bs extends _ {
3466
3573
  });
3467
3574
  }
3468
3575
  }
3469
- const u = this.generateClickData(n, l, c);
3576
+ const d = this.generateClickData(i, l, c);
3470
3577
  this.eventManager.track({
3471
- type: d.CLICK,
3472
- click_data: u
3578
+ type: u.CLICK,
3579
+ click_data: d
3473
3580
  });
3474
3581
  }, window.addEventListener("click", this.clickHandler, !0));
3475
3582
  }
@@ -3490,15 +3597,15 @@ class bs extends _ {
3490
3597
  * Returns true if the click should be tracked, false if throttled
3491
3598
  */
3492
3599
  checkClickThrottle(e, t) {
3493
- const s = this.getElementSignature(e), n = Date.now();
3494
- this.pruneThrottleCache(n);
3495
- const i = this.lastClickTimes.get(s);
3496
- return i !== void 0 && n - i < t ? (a("debug", "ClickHandler: Click suppressed by throttle", {
3600
+ const s = this.getElementSignature(e), i = Date.now();
3601
+ this.pruneThrottleCache(i);
3602
+ const n = this.lastClickTimes.get(s);
3603
+ return n !== void 0 && i - n < t ? (a("debug", "ClickHandler: Click suppressed by throttle", {
3497
3604
  data: {
3498
3605
  signature: s,
3499
- throttleRemaining: t - (n - i)
3606
+ throttleRemaining: t - (i - n)
3500
3607
  }
3501
- }), !1) : (this.lastClickTimes.set(s, n), !0);
3608
+ }), !1) : (this.lastClickTimes.set(s, i), !0);
3502
3609
  }
3503
3610
  /**
3504
3611
  * Prunes stale entries from the throttle cache to prevent memory leaks
@@ -3510,15 +3617,15 @@ class bs extends _ {
3510
3617
  return;
3511
3618
  this.lastPruneTime = e;
3512
3619
  const t = e - 3e5;
3513
- for (const [s, n] of this.lastClickTimes.entries())
3514
- n < t && this.lastClickTimes.delete(s);
3620
+ for (const [s, i] of this.lastClickTimes.entries())
3621
+ i < t && this.lastClickTimes.delete(s);
3515
3622
  if (this.lastClickTimes.size > 1e3) {
3516
- const s = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]), n = this.lastClickTimes.size - 1e3, i = s.slice(0, n);
3517
- for (const [o] of i)
3623
+ const s = Array.from(this.lastClickTimes.entries()).sort((o, l) => o[1] - l[1]), i = this.lastClickTimes.size - 1e3, n = s.slice(0, i);
3624
+ for (const [o] of n)
3518
3625
  this.lastClickTimes.delete(o);
3519
3626
  a("debug", "ClickHandler: Pruned throttle cache", {
3520
3627
  data: {
3521
- removed: i.length,
3628
+ removed: n.length,
3522
3629
  remaining: this.lastClickTimes.size
3523
3630
  }
3524
3631
  });
@@ -3544,12 +3651,12 @@ class bs extends _ {
3544
3651
  const t = [];
3545
3652
  let s = e;
3546
3653
  for (; s && s !== document.body; ) {
3547
- let n = s.tagName.toLowerCase();
3654
+ let i = s.tagName.toLowerCase();
3548
3655
  if (s.className) {
3549
- const i = s.className.split(" ")[0];
3550
- i && (n += `.${i}`);
3656
+ const n = s.className.split(" ")[0];
3657
+ n && (i += `.${n}`);
3551
3658
  }
3552
- t.unshift(n), s = s.parentElement;
3659
+ t.unshift(i), s = s.parentElement;
3553
3660
  }
3554
3661
  return t.join(">") || "unknown";
3555
3662
  }
@@ -3585,8 +3692,8 @@ class bs extends _ {
3585
3692
  return Math.max(0, Math.min(1, Number(e.toFixed(3))));
3586
3693
  }
3587
3694
  calculateClickCoordinates(e, t) {
3588
- const s = t.getBoundingClientRect(), n = e.clientX, i = e.clientY, o = s.width > 0 ? this.clamp((n - s.left) / s.width) : 0, l = s.height > 0 ? this.clamp((i - s.top) / s.height) : 0;
3589
- return { x: n, y: i, relativeX: o, relativeY: l };
3695
+ const s = t.getBoundingClientRect(), i = e.clientX, n = e.clientY, o = s.width > 0 ? this.clamp((i - s.left) / s.width) : 0, l = s.height > 0 ? this.clamp((n - s.top) / s.height) : 0;
3696
+ return { x: i, y: n, relativeX: o, relativeY: l };
3590
3697
  }
3591
3698
  extractTrackingData(e) {
3592
3699
  const t = e.getAttribute(`${b}-name`), s = e.getAttribute(`${b}-value`);
@@ -3598,22 +3705,22 @@ class bs extends _ {
3598
3705
  };
3599
3706
  }
3600
3707
  generateClickData(e, t, s) {
3601
- const { x: n, y: i, relativeX: o, relativeY: l } = s, c = this.getRelevantText(e, t), u = this.extractElementAttributes(t);
3708
+ const { x: i, y: n, relativeX: o, relativeY: l } = s, c = this.getRelevantText(e, t), d = this.extractElementAttributes(t);
3602
3709
  return {
3603
- x: n,
3604
- y: i,
3710
+ x: i,
3711
+ y: n,
3605
3712
  relativeX: o,
3606
3713
  relativeY: l,
3607
3714
  tag: t.tagName.toLowerCase(),
3608
3715
  ...t.id && { id: t.id },
3609
3716
  ...t.className && { class: t.className },
3610
3717
  ...c && { text: c },
3611
- ...u.href && { href: u.href },
3612
- ...u.title && { title: u.title },
3613
- ...u.alt && { alt: u.alt },
3614
- ...u.role && { role: u.role },
3615
- ...u["aria-label"] && { ariaLabel: u["aria-label"] },
3616
- ...Object.keys(u).length > 0 && { dataAttributes: u }
3718
+ ...d.href && { href: d.href },
3719
+ ...d.title && { title: d.title },
3720
+ ...d.alt && { alt: d.alt },
3721
+ ...d.role && { role: d.role },
3722
+ ...d["aria-label"] && { ariaLabel: d["aria-label"] },
3723
+ ...Object.keys(d).length > 0 && { dataAttributes: d }
3617
3724
  };
3618
3725
  }
3619
3726
  /**
@@ -3638,17 +3745,17 @@ class bs extends _ {
3638
3745
  sanitizeText(e) {
3639
3746
  let t = e;
3640
3747
  for (const s of at) {
3641
- const n = new RegExp(s.source, s.flags);
3642
- t = t.replace(n, "[REDACTED]");
3748
+ const i = new RegExp(s.source, s.flags);
3749
+ t = t.replace(i, "[REDACTED]");
3643
3750
  }
3644
3751
  return t;
3645
3752
  }
3646
3753
  getRelevantText(e, t) {
3647
- const s = e.textContent?.trim() ?? "", n = t.textContent?.trim() ?? "";
3648
- if (!s && !n)
3754
+ const s = e.textContent?.trim() ?? "", i = t.textContent?.trim() ?? "";
3755
+ if (!s && !i)
3649
3756
  return "";
3650
- let i = "";
3651
- return s && s.length <= 255 ? i = s : n.length <= 255 ? i = n : i = n.slice(0, 252) + "...", this.sanitizeText(i);
3757
+ let n = "";
3758
+ return s && s.length <= 255 ? n = s : i.length <= 255 ? n = i : n = i.slice(0, 252) + "...", this.sanitizeText(n);
3652
3759
  }
3653
3760
  extractElementAttributes(e) {
3654
3761
  const t = [
@@ -3663,9 +3770,9 @@ class bs extends _ {
3663
3770
  "alt",
3664
3771
  "role"
3665
3772
  ], s = {};
3666
- for (const n of t) {
3667
- const i = e.getAttribute(n);
3668
- i && (s[n] = i);
3773
+ for (const i of t) {
3774
+ const n = e.getAttribute(i);
3775
+ n && (s[i] = n);
3669
3776
  }
3670
3777
  return s;
3671
3778
  }
@@ -3723,8 +3830,8 @@ class As extends _ {
3723
3830
  const t = this.findScrollableElements();
3724
3831
  if (this.isWindowScrollable() && this.setupScrollContainer(window, "window"), t.length > 0) {
3725
3832
  for (const s of t) {
3726
- const n = this.getElementSelector(s);
3727
- this.setupScrollContainer(s, n);
3833
+ const i = this.getElementSelector(s);
3834
+ this.setupScrollContainer(s, i);
3728
3835
  }
3729
3836
  this.applyPrimaryScrollSelectorIfConfigured();
3730
3837
  return;
@@ -3745,18 +3852,18 @@ class As extends _ {
3745
3852
  if (!document.body)
3746
3853
  return [];
3747
3854
  const e = [], t = document.createTreeWalker(document.body, NodeFilter.SHOW_ELEMENT, {
3748
- acceptNode: (n) => {
3749
- const i = n;
3750
- if (!i.isConnected || !i.offsetParent)
3855
+ acceptNode: (i) => {
3856
+ const n = i;
3857
+ if (!n.isConnected || !n.offsetParent)
3751
3858
  return NodeFilter.FILTER_SKIP;
3752
- const o = getComputedStyle(i);
3859
+ const o = getComputedStyle(n);
3753
3860
  return o.overflowY === "auto" || o.overflowY === "scroll" || o.overflow === "auto" || o.overflow === "scroll" ? NodeFilter.FILTER_ACCEPT : NodeFilter.FILTER_SKIP;
3754
3861
  }
3755
3862
  });
3756
3863
  let s;
3757
3864
  for (; (s = t.nextNode()) && e.length < 10; ) {
3758
- const n = s;
3759
- this.isElementScrollable(n) && e.push(n);
3865
+ const i = s;
3866
+ this.isElementScrollable(i) && e.push(i);
3760
3867
  }
3761
3868
  return e;
3762
3869
  }
@@ -3767,7 +3874,7 @@ class As extends _ {
3767
3874
  if (t.id)
3768
3875
  return `#${t.id}`;
3769
3876
  if (t.className && typeof t.className == "string") {
3770
- const s = t.className.split(" ").filter((n) => n.trim())[0];
3877
+ const s = t.className.split(" ").filter((i) => i.trim())[0];
3771
3878
  if (s)
3772
3879
  return `.${s}`;
3773
3880
  }
@@ -3777,30 +3884,30 @@ class As extends _ {
3777
3884
  return this.isWindowScrollable() ? e === window : this.containers.length === 0;
3778
3885
  }
3779
3886
  setupScrollContainer(e, t) {
3780
- if (this.containers.some((u) => u.element === e) || e !== window && !this.isElementScrollable(e))
3887
+ if (this.containers.some((d) => d.element === e) || e !== window && !this.isElementScrollable(e))
3781
3888
  return;
3782
- const n = this.getScrollTop(e), i = this.calculateScrollDepth(
3783
- n,
3889
+ const i = this.getScrollTop(e), n = this.calculateScrollDepth(
3890
+ i,
3784
3891
  this.getScrollHeight(e),
3785
3892
  this.getViewportHeight(e)
3786
3893
  ), o = this.determineIfPrimary(e), l = {
3787
3894
  element: e,
3788
3895
  selector: t,
3789
3896
  isPrimary: o,
3790
- lastScrollPos: n,
3791
- lastDepth: i,
3897
+ lastScrollPos: i,
3898
+ lastDepth: n,
3792
3899
  lastDirection: Z.DOWN,
3793
3900
  lastEventTime: 0,
3794
3901
  firstScrollEventTime: null,
3795
- maxDepthReached: i,
3902
+ maxDepthReached: n,
3796
3903
  debounceTimer: null,
3797
3904
  listener: null
3798
3905
  }, c = () => {
3799
3906
  this.get("suppressNextScroll") || (l.firstScrollEventTime === null && (l.firstScrollEventTime = Date.now()), this.clearContainerTimer(l), l.debounceTimer = window.setTimeout(() => {
3800
- const u = this.calculateScrollData(l);
3801
- if (u) {
3907
+ const d = this.calculateScrollData(l);
3908
+ if (d) {
3802
3909
  const f = Date.now();
3803
- this.processScrollEvent(l, u, f);
3910
+ this.processScrollEvent(l, d, f);
3804
3911
  }
3805
3912
  l.debounceTimer = null;
3806
3913
  }, 250));
@@ -3811,9 +3918,9 @@ class As extends _ {
3811
3918
  if (!this.shouldEmitScrollEvent(e, t, s))
3812
3919
  return;
3813
3920
  e.lastEventTime = s, e.lastDepth = t.depth, e.lastDirection = t.direction;
3814
- const n = this.get("scrollEventCount") ?? 0;
3815
- this.set("scrollEventCount", n + 1), this.eventManager.track({
3816
- type: d.SCROLL,
3921
+ const i = this.get("scrollEventCount") ?? 0;
3922
+ this.set("scrollEventCount", i + 1), this.eventManager.track({
3923
+ type: u.SCROLL,
3817
3924
  scroll_data: {
3818
3925
  ...t,
3819
3926
  container_selector: e.selector,
@@ -3853,18 +3960,18 @@ class As extends _ {
3853
3960
  calculateScrollDepth(e, t, s) {
3854
3961
  if (t <= s)
3855
3962
  return 0;
3856
- const n = t - s;
3857
- return Math.min(100, Math.max(0, Math.floor(e / n * 100)));
3963
+ const i = t - s;
3964
+ return Math.min(100, Math.max(0, Math.floor(e / i * 100)));
3858
3965
  }
3859
3966
  calculateScrollData(e) {
3860
- const { element: t, lastScrollPos: s, lastEventTime: n } = e, i = this.getScrollTop(t), o = Date.now(), l = Math.abs(i - s);
3967
+ const { element: t, lastScrollPos: s, lastEventTime: i } = e, n = this.getScrollTop(t), o = Date.now(), l = Math.abs(n - s);
3861
3968
  if (l < 10 || t === window && !this.isWindowScrollable())
3862
3969
  return null;
3863
- const c = this.getViewportHeight(t), u = this.getScrollHeight(t), f = this.getScrollDirection(i, s), g = this.calculateScrollDepth(i, u, c);
3864
- let T;
3865
- n > 0 ? T = o - n : e.firstScrollEventTime !== null ? T = o - e.firstScrollEventTime : T = 250;
3866
- const p = Math.round(l / T * 1e3);
3867
- return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = i, {
3970
+ const c = this.getViewportHeight(t), d = this.getScrollHeight(t), f = this.getScrollDirection(n, s), g = this.calculateScrollDepth(n, d, c);
3971
+ let I;
3972
+ i > 0 ? I = o - i : e.firstScrollEventTime !== null ? I = o - e.firstScrollEventTime : I = 250;
3973
+ const p = Math.round(l / I * 1e3);
3974
+ return g > e.maxDepthReached && (e.maxDepthReached = g), e.lastScrollPos = n, {
3868
3975
  depth: g,
3869
3976
  direction: f,
3870
3977
  velocity: p,
@@ -3881,30 +3988,30 @@ class As extends _ {
3881
3988
  return e === window ? document.documentElement.scrollHeight : e.scrollHeight;
3882
3989
  }
3883
3990
  isElementScrollable(e) {
3884
- const t = getComputedStyle(e), s = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll", n = e.scrollHeight > e.clientHeight;
3885
- return s && n;
3991
+ const t = getComputedStyle(e), s = t.overflowY === "auto" || t.overflowY === "scroll" || t.overflow === "auto" || t.overflow === "scroll", i = e.scrollHeight > e.clientHeight;
3992
+ return s && i;
3886
3993
  }
3887
3994
  applyPrimaryScrollSelector(e) {
3888
3995
  let t;
3889
3996
  if (e === "window")
3890
3997
  t = window;
3891
3998
  else {
3892
- const n = document.querySelector(e);
3893
- if (!(n instanceof HTMLElement)) {
3999
+ const i = document.querySelector(e);
4000
+ if (!(i instanceof HTMLElement)) {
3894
4001
  a("debug", `Selector "${e}" did not match an HTMLElement`);
3895
4002
  return;
3896
4003
  }
3897
- t = n;
4004
+ t = i;
3898
4005
  }
3899
- this.containers.forEach((n) => {
3900
- this.updateContainerPrimary(n, n.element === t);
3901
- }), !this.containers.some((n) => n.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
4006
+ this.containers.forEach((i) => {
4007
+ this.updateContainerPrimary(i, i.element === t);
4008
+ }), !this.containers.some((i) => i.element === t) && t instanceof HTMLElement && this.isElementScrollable(t) && this.setupScrollContainer(t, e);
3902
4009
  }
3903
4010
  updateContainerPrimary(e, t) {
3904
4011
  e.isPrimary = t;
3905
4012
  }
3906
4013
  }
3907
- class Ls extends _ {
4014
+ class Ms extends _ {
3908
4015
  eventManager;
3909
4016
  trackedElements = /* @__PURE__ */ new Map();
3910
4017
  observer = null;
@@ -3956,8 +4063,8 @@ class Ls extends _ {
3956
4063
  let t = this.trackedElements.size;
3957
4064
  for (const s of this.config.elements)
3958
4065
  try {
3959
- const n = document.querySelectorAll(s.selector);
3960
- for (const i of Array.from(n)) {
4066
+ const i = document.querySelectorAll(s.selector);
4067
+ for (const n of Array.from(i)) {
3961
4068
  if (t >= e) {
3962
4069
  a("debug", "ViewportHandler: Maximum tracked elements reached", {
3963
4070
  data: {
@@ -3968,18 +4075,18 @@ class Ls extends _ {
3968
4075
  });
3969
4076
  return;
3970
4077
  }
3971
- i.hasAttribute(`${b}-ignore`) || this.trackedElements.has(i) || (this.trackedElements.set(i, {
3972
- element: i,
4078
+ n.hasAttribute(`${b}-ignore`) || this.trackedElements.has(n) || (this.trackedElements.set(n, {
4079
+ element: n,
3973
4080
  selector: s.selector,
3974
4081
  id: s.id,
3975
4082
  name: s.name,
3976
4083
  startTime: null,
3977
4084
  timeoutId: null,
3978
4085
  lastFiredTime: null
3979
- }), this.observer?.observe(i), t++);
4086
+ }), this.observer?.observe(n), t++);
3980
4087
  }
3981
- } catch (n) {
3982
- a("debug", `ViewportHandler: Invalid selector "${s.selector}"`, { error: n });
4088
+ } catch (i) {
4089
+ a("debug", `ViewportHandler: Invalid selector "${s.selector}"`, { error: i });
3983
4090
  }
3984
4091
  a("debug", "ViewportHandler: Elements tracked", {
3985
4092
  data: { count: t, limit: e }
@@ -3992,11 +4099,11 @@ class Ls extends _ {
3992
4099
  if (!this.config) return;
3993
4100
  const t = this.config.minDwellTime ?? 1e3;
3994
4101
  for (const s of e) {
3995
- const n = this.trackedElements.get(s.target);
3996
- n && (s.isIntersecting ? n.startTime === null && (n.startTime = performance.now(), n.timeoutId = window.setTimeout(() => {
3997
- const i = Math.round(s.intersectionRatio * 100) / 100;
3998
- this.fireViewportEvent(n, i);
3999
- }, t)) : n.startTime !== null && (n.timeoutId !== null && (window.clearTimeout(n.timeoutId), n.timeoutId = null), n.startTime = null));
4102
+ const i = this.trackedElements.get(s.target);
4103
+ i && (s.isIntersecting ? i.startTime === null && (i.startTime = performance.now(), i.timeoutId = window.setTimeout(() => {
4104
+ const n = Math.round(s.intersectionRatio * 100) / 100;
4105
+ this.fireViewportEvent(i, n);
4106
+ }, t)) : i.startTime !== null && (i.timeoutId !== null && (window.clearTimeout(i.timeoutId), i.timeoutId = null), i.startTime = null));
4000
4107
  }
4001
4108
  };
4002
4109
  /**
@@ -4007,12 +4114,12 @@ class Ls extends _ {
4007
4114
  const s = Math.round(performance.now() - e.startTime);
4008
4115
  if (e.element.hasAttribute(`${b}-ignore`))
4009
4116
  return;
4010
- const n = this.config?.cooldownPeriod ?? 6e4, i = Date.now();
4011
- if (e.lastFiredTime !== null && i - e.lastFiredTime < n) {
4117
+ const i = this.config?.cooldownPeriod ?? 6e4, n = Date.now();
4118
+ if (e.lastFiredTime !== null && n - e.lastFiredTime < i) {
4012
4119
  a("debug", "ViewportHandler: Event suppressed by cooldown period", {
4013
4120
  data: {
4014
4121
  selector: e.selector,
4015
- cooldownRemaining: n - (i - e.lastFiredTime)
4122
+ cooldownRemaining: i - (n - e.lastFiredTime)
4016
4123
  }
4017
4124
  }), e.startTime = null, e.timeoutId = null;
4018
4125
  return;
@@ -4025,9 +4132,9 @@ class Ls extends _ {
4025
4132
  ...e.name !== void 0 && { name: e.name }
4026
4133
  };
4027
4134
  this.eventManager.track({
4028
- type: d.VIEWPORT_VISIBLE,
4135
+ type: u.VIEWPORT_VISIBLE,
4029
4136
  viewport_data: o
4030
- }), e.startTime = null, e.timeoutId = null, e.lastFiredTime = i;
4137
+ }), e.startTime = null, e.timeoutId = null, e.lastFiredTime = n;
4031
4138
  }
4032
4139
  /**
4033
4140
  * Sets up MutationObserver to detect dynamically added elements
@@ -4057,16 +4164,16 @@ class Ls extends _ {
4057
4164
  cleanupRemovedNodes(e) {
4058
4165
  e.forEach((t) => {
4059
4166
  if (t.nodeType !== 1) return;
4060
- const s = t, n = this.trackedElements.get(s);
4061
- n && (n.timeoutId !== null && window.clearTimeout(n.timeoutId), this.observer?.unobserve(s), this.trackedElements.delete(s)), Array.from(this.trackedElements.keys()).filter((o) => s.contains(o)).forEach((o) => {
4167
+ const s = t, i = this.trackedElements.get(s);
4168
+ i && (i.timeoutId !== null && window.clearTimeout(i.timeoutId), this.observer?.unobserve(s), this.trackedElements.delete(s)), Array.from(this.trackedElements.keys()).filter((o) => s.contains(o)).forEach((o) => {
4062
4169
  const l = this.trackedElements.get(o);
4063
4170
  l && l.timeoutId !== null && window.clearTimeout(l.timeoutId), this.observer?.unobserve(o), this.trackedElements.delete(o);
4064
4171
  });
4065
4172
  });
4066
4173
  }
4067
4174
  }
4068
- const Ms = "tracelog_session_id";
4069
- class Cs extends _ {
4175
+ const Cs = "tracelog_session_id";
4176
+ class Rs extends _ {
4070
4177
  visibilityHandler = null;
4071
4178
  lastSyncedSessionId = null;
4072
4179
  activate() {
@@ -4088,7 +4195,7 @@ class Cs extends _ {
4088
4195
  fetch("/cart/update.js", {
4089
4196
  method: "POST",
4090
4197
  headers: { "Content-Type": "application/json" },
4091
- body: JSON.stringify({ attributes: { [Ms]: e } }),
4198
+ body: JSON.stringify({ attributes: { [Cs]: e } }),
4092
4199
  credentials: "same-origin"
4093
4200
  }).then((t) => {
4094
4201
  t.ok || (this.lastSyncedSessionId = null, a("debug", "Shopify cart attribute update failed", { data: { status: t.status } }));
@@ -4108,7 +4215,7 @@ class Cs extends _ {
4108
4215
  this.visibilityHandler && (document.removeEventListener("visibilitychange", this.visibilityHandler), this.visibilityHandler = null);
4109
4216
  }
4110
4217
  }
4111
- class Rs {
4218
+ class Ns {
4112
4219
  storage;
4113
4220
  sessionStorageRef;
4114
4221
  fallbackStorage = /* @__PURE__ */ new Map();
@@ -4277,19 +4384,19 @@ class Rs {
4277
4384
  return !1;
4278
4385
  try {
4279
4386
  const e = [], t = [];
4280
- for (let i = 0; i < this.storage.length; i++) {
4281
- const o = this.storage.key(i);
4387
+ for (let n = 0; n < this.storage.length; n++) {
4388
+ const o = this.storage.key(n);
4282
4389
  o?.startsWith("tracelog_") && (e.push(o), o.startsWith("tracelog_persisted_events_") && t.push(o));
4283
4390
  }
4284
4391
  if (t.length > 0)
4285
- return t.forEach((i) => {
4392
+ return t.forEach((n) => {
4286
4393
  try {
4287
- this.storage.removeItem(i);
4394
+ this.storage.removeItem(n);
4288
4395
  } catch {
4289
4396
  }
4290
4397
  }), !0;
4291
- const s = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], n = e.filter((i) => !s.some((o) => i.startsWith(o)));
4292
- return n.length > 0 ? (n.slice(0, 5).forEach((o) => {
4398
+ const s = ["tracelog_session_", "tracelog_user_id", "tracelog_device_id", "tracelog_config"], i = e.filter((n) => !s.some((o) => n.startsWith(o)));
4399
+ return i.length > 0 ? (i.slice(0, 5).forEach((o) => {
4293
4400
  try {
4294
4401
  this.storage.removeItem(o);
4295
4402
  } catch {
@@ -4391,7 +4498,7 @@ class Rs {
4391
4498
  this.fallbackSessionStorage.delete(e);
4392
4499
  }
4393
4500
  }
4394
- class Ns extends _ {
4501
+ class Os extends _ {
4395
4502
  eventManager;
4396
4503
  reportedByNav = /* @__PURE__ */ new Map();
4397
4504
  navigationHistory = [];
@@ -4402,7 +4509,7 @@ class Ns extends _ {
4402
4509
  navigationCounter = 0;
4403
4510
  // Counter for handling simultaneous navigations edge case
4404
4511
  constructor(e) {
4405
- super(), this.eventManager = e, this.vitalThresholds = Ke(_e);
4512
+ super(), this.eventManager = e, this.vitalThresholds = Qe(_e);
4406
4513
  }
4407
4514
  /**
4408
4515
  * Starts tracking Web Vitals and performance metrics.
@@ -4420,7 +4527,7 @@ class Ns extends _ {
4420
4527
  */
4421
4528
  async startTracking() {
4422
4529
  const e = this.get("config"), t = e?.webVitalsMode ?? _e;
4423
- this.vitalThresholds = Ke(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
4530
+ this.vitalThresholds = Qe(t), e?.webVitalsThresholds && (this.vitalThresholds = { ...this.vitalThresholds, ...e.webVitalsThresholds }), await this.initWebVitals(), this.observeLongTasks();
4424
4531
  }
4425
4532
  /**
4426
4533
  * Stops tracking Web Vitals and cleans up resources.
@@ -4444,8 +4551,8 @@ class Ns extends _ {
4444
4551
  this.reportTTFB(), this.safeObserve(
4445
4552
  "largest-contentful-paint",
4446
4553
  (s) => {
4447
- const n = s.getEntries(), i = n[n.length - 1];
4448
- i && this.sendVital({ type: "LCP", value: Number(i.startTime.toFixed(2)) });
4554
+ const i = s.getEntries(), n = i[i.length - 1];
4555
+ n && this.sendVital({ type: "LCP", value: Number(n.startTime.toFixed(2)) });
4449
4556
  },
4450
4557
  { type: "largest-contentful-paint", buffered: !0 },
4451
4558
  !0
@@ -4454,10 +4561,10 @@ class Ns extends _ {
4454
4561
  this.safeObserve(
4455
4562
  "layout-shift",
4456
4563
  (s) => {
4457
- const n = this.getNavigationId();
4458
- n !== t && (e = 0, t = n);
4459
- const i = s.getEntries();
4460
- for (const o of i) {
4564
+ const i = this.getNavigationId();
4565
+ i !== t && (e = 0, t = i);
4566
+ const n = s.getEntries();
4567
+ for (const o of n) {
4461
4568
  if (o.hadRecentInput === !0)
4462
4569
  continue;
4463
4570
  const l = typeof o.value == "number" ? o.value : 0;
@@ -4469,32 +4576,32 @@ class Ns extends _ {
4469
4576
  ), this.safeObserve(
4470
4577
  "paint",
4471
4578
  (s) => {
4472
- for (const n of s.getEntries())
4473
- n.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(n.startTime.toFixed(2)) });
4579
+ for (const i of s.getEntries())
4580
+ i.name === "first-contentful-paint" && this.sendVital({ type: "FCP", value: Number(i.startTime.toFixed(2)) });
4474
4581
  },
4475
4582
  { type: "paint", buffered: !0 },
4476
4583
  !0
4477
4584
  ), this.safeObserve(
4478
4585
  "event",
4479
4586
  (s) => {
4480
- let n = 0;
4481
- const i = s.getEntries();
4482
- for (const o of i) {
4587
+ let i = 0;
4588
+ const n = s.getEntries();
4589
+ for (const o of n) {
4483
4590
  const l = (o.processingEnd ?? 0) - (o.startTime ?? 0);
4484
- n = Math.max(n, l);
4591
+ i = Math.max(i, l);
4485
4592
  }
4486
- n > 0 && this.sendVital({ type: "INP", value: Number(n.toFixed(2)) });
4593
+ i > 0 && this.sendVital({ type: "INP", value: Number(i.toFixed(2)) });
4487
4594
  },
4488
4595
  { type: "event", buffered: !0 }
4489
4596
  );
4490
4597
  }
4491
4598
  async initWebVitals() {
4492
4599
  try {
4493
- const { onLCP: e, onCLS: t, onFCP: s, onTTFB: n, onINP: i } = await Promise.resolve().then(() => cr), o = (l) => (c) => {
4494
- const u = Number(c.value.toFixed(2));
4495
- this.sendVital({ type: l, value: u });
4600
+ const { onLCP: e, onCLS: t, onFCP: s, onTTFB: i, onINP: n } = await Promise.resolve().then(() => dr), o = (l) => (c) => {
4601
+ const d = Number(c.value.toFixed(2));
4602
+ this.sendVital({ type: l, value: d });
4496
4603
  };
4497
- e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), s(o("FCP"), { reportAllChanges: !1 }), n(o("TTFB"), { reportAllChanges: !1 }), i(o("INP"), { reportAllChanges: !1 });
4604
+ e(o("LCP"), { reportAllChanges: !1 }), t(o("CLS"), { reportAllChanges: !1 }), s(o("FCP"), { reportAllChanges: !1 }), i(o("TTFB"), { reportAllChanges: !1 }), n(o("INP"), { reportAllChanges: !1 });
4498
4605
  } catch (e) {
4499
4606
  a("debug", "Failed to load web-vitals library, using fallback", { error: e }), this.observeWebVitalsFallback();
4500
4607
  }
@@ -4516,8 +4623,8 @@ class Ns extends _ {
4516
4623
  (e) => {
4517
4624
  const t = e.getEntries();
4518
4625
  for (const s of t) {
4519
- const n = Number(s.duration.toFixed(2)), i = Date.now();
4520
- i - this.lastLongTaskSentAt >= Kt && (this.shouldSendVital("LONG_TASK", n) && this.trackWebVital("LONG_TASK", n), this.lastLongTaskSentAt = i);
4626
+ const i = Number(s.duration.toFixed(2)), n = Date.now();
4627
+ n - this.lastLongTaskSentAt >= Yt && (this.shouldSendVital("LONG_TASK", i) && this.trackWebVital("LONG_TASK", i), this.lastLongTaskSentAt = n);
4521
4628
  }
4522
4629
  },
4523
4630
  { type: "longtask", buffered: !0 }
@@ -4533,9 +4640,9 @@ class Ns extends _ {
4533
4640
  return;
4534
4641
  if (s)
4535
4642
  s.add(e.type);
4536
- else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > Yt) {
4537
- const i = this.navigationHistory.shift();
4538
- i && this.reportedByNav.delete(i);
4643
+ else if (this.reportedByNav.set(t, /* @__PURE__ */ new Set([e.type])), this.navigationHistory.push(t), this.navigationHistory.length > qt) {
4644
+ const n = this.navigationHistory.shift();
4645
+ n && this.reportedByNav.delete(n);
4539
4646
  }
4540
4647
  }
4541
4648
  this.trackWebVital(e.type, e.value);
@@ -4546,7 +4653,7 @@ class Ns extends _ {
4546
4653
  return;
4547
4654
  }
4548
4655
  this.eventManager.track({
4549
- type: d.WEB_VITALS,
4656
+ type: u.WEB_VITALS,
4550
4657
  web_vitals: {
4551
4658
  type: e,
4552
4659
  value: t
@@ -4579,8 +4686,8 @@ class Ns extends _ {
4579
4686
  const e = performance.getEntriesByType("navigation")[0];
4580
4687
  if (!e)
4581
4688
  return null;
4582
- const t = e.startTime || performance.now(), s = ++this.navigationCounter, n = `${t.toFixed(2)}_${window.location.pathname}`;
4583
- return s > 1 ? `${n}_${s}` : n;
4689
+ const t = e.startTime || performance.now(), s = ++this.navigationCounter, i = `${t.toFixed(2)}_${window.location.pathname}`;
4690
+ return s > 1 ? `${i}_${s}` : i;
4584
4691
  } catch (e) {
4585
4692
  return a("debug", "Failed to get navigation ID", { error: e }), null;
4586
4693
  }
@@ -4590,11 +4697,11 @@ class Ns extends _ {
4590
4697
  const t = PerformanceObserver.supportedEntryTypes;
4591
4698
  return !t || t.includes(e);
4592
4699
  }
4593
- safeObserve(e, t, s, n = !1) {
4700
+ safeObserve(e, t, s, i = !1) {
4594
4701
  try {
4595
4702
  if (!this.isObserverSupported(e))
4596
4703
  return !1;
4597
- const i = new PerformanceObserver((o, l) => {
4704
+ const n = new PerformanceObserver((o, l) => {
4598
4705
  try {
4599
4706
  t(o, l);
4600
4707
  } catch (c) {
@@ -4603,16 +4710,16 @@ class Ns extends _ {
4603
4710
  data: { type: e }
4604
4711
  });
4605
4712
  }
4606
- if (n)
4713
+ if (i)
4607
4714
  try {
4608
4715
  l.disconnect();
4609
4716
  } catch {
4610
4717
  }
4611
4718
  });
4612
- return i.observe(s ?? { type: e, buffered: !0 }), n || this.observers.push(i), !0;
4613
- } catch (i) {
4719
+ return n.observe(s ?? { type: e, buffered: !0 }), i || this.observers.push(n), !0;
4720
+ } catch (n) {
4614
4721
  return a("debug", "Failed to create performance observer", {
4615
- error: i,
4722
+ error: n,
4616
4723
  data: { type: e }
4617
4724
  }), !1;
4618
4725
  }
@@ -4660,7 +4767,7 @@ class ae extends _ {
4660
4767
  const e = Date.now();
4661
4768
  if (e < this.burstBackoffUntil)
4662
4769
  return !1;
4663
- if (e - this.burstWindowStart > Gt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > jt)
4770
+ if (e - this.burstWindowStart > jt && (this.errorBurstCounter = 0, this.burstWindowStart = e), this.errorBurstCounter++, this.errorBurstCounter > zt)
4664
4771
  return this.burstBackoffUntil = e + ze, a("debug", "Error burst detected - entering cooldown", {
4665
4772
  data: {
4666
4773
  errorsInWindow: this.errorBurstCounter,
@@ -4678,7 +4785,7 @@ class ae extends _ {
4678
4785
  return;
4679
4786
  const s = typeof e.error?.stack == "string" ? this.truncateStack(e.error.stack) : void 0;
4680
4787
  this.eventManager.track({
4681
- type: d.ERROR,
4788
+ type: u.ERROR,
4682
4789
  error_data: {
4683
4790
  type: B.JS_ERROR,
4684
4791
  message: t,
@@ -4695,13 +4802,13 @@ class ae extends _ {
4695
4802
  const t = this.extractRejectionMessage(e.reason), s = this.sanitize(t);
4696
4803
  if (this.shouldSuppressError(B.PROMISE_REJECTION, s))
4697
4804
  return;
4698
- const n = e.reason instanceof Error && typeof e.reason.stack == "string" ? this.truncateStack(e.reason.stack) : void 0;
4805
+ const i = e.reason instanceof Error && typeof e.reason.stack == "string" ? this.truncateStack(e.reason.stack) : void 0;
4699
4806
  this.eventManager.track({
4700
- type: d.ERROR,
4807
+ type: u.ERROR,
4701
4808
  error_data: {
4702
4809
  type: B.PROMISE_REJECTION,
4703
4810
  message: s,
4704
- ...n !== void 0 && { stack: n }
4811
+ ...i !== void 0 && { stack: i }
4705
4812
  }
4706
4813
  });
4707
4814
  };
@@ -4725,14 +4832,14 @@ class ae extends _ {
4725
4832
  sanitizePii(e) {
4726
4833
  let t = e;
4727
4834
  for (const s of at) {
4728
- const n = new RegExp(s.source, s.flags);
4729
- t = t.replace(n, "[REDACTED]");
4835
+ const i = new RegExp(s.source, s.flags);
4836
+ t = t.replace(i, "[REDACTED]");
4730
4837
  }
4731
4838
  return t;
4732
4839
  }
4733
4840
  shouldSuppressError(e, t) {
4734
- const s = Date.now(), n = `${e}:${t}`, i = this.recentErrors.get(n);
4735
- return i !== void 0 && s - i < je ? (this.recentErrors.set(n, s), !0) : (this.recentErrors.set(n, s), this.recentErrors.size > Xt ? (this.recentErrors.clear(), this.recentErrors.set(n, s), !1) : (this.recentErrors.size > ee && this.pruneOldErrors(), !1));
4841
+ const s = Date.now(), i = `${e}:${t}`, n = this.recentErrors.get(i);
4842
+ return n !== void 0 && s - n < je ? (this.recentErrors.set(i, s), !0) : (this.recentErrors.set(i, s), this.recentErrors.size > Gt ? (this.recentErrors.clear(), this.recentErrors.set(i, s), !1) : (this.recentErrors.size > ee && this.pruneOldErrors(), !1));
4736
4843
  }
4737
4844
  static TRUNCATION_SUFFIX = `
4738
4845
  ...truncated`;
@@ -4743,22 +4850,22 @@ class ae extends _ {
4743
4850
  }
4744
4851
  pruneOldErrors() {
4745
4852
  const e = Date.now();
4746
- for (const [n, i] of this.recentErrors.entries())
4747
- e - i > je && this.recentErrors.delete(n);
4853
+ for (const [i, n] of this.recentErrors.entries())
4854
+ e - n > je && this.recentErrors.delete(i);
4748
4855
  if (this.recentErrors.size <= ee)
4749
4856
  return;
4750
- const t = Array.from(this.recentErrors.entries()).sort((n, i) => n[1] - i[1]), s = this.recentErrors.size - ee;
4751
- for (let n = 0; n < s; n += 1) {
4752
- const i = t[n];
4753
- i && this.recentErrors.delete(i[0]);
4857
+ const t = Array.from(this.recentErrors.entries()).sort((i, n) => i[1] - n[1]), s = this.recentErrors.size - ee;
4858
+ for (let i = 0; i < s; i += 1) {
4859
+ const n = t[i];
4860
+ n && this.recentErrors.delete(n[0]);
4754
4861
  }
4755
4862
  }
4756
4863
  }
4757
- class Os extends _ {
4864
+ class Ps extends _ {
4758
4865
  isInitialized = !1;
4759
4866
  suppressNextScrollTimer = null;
4760
4867
  pageUnloadHandler = null;
4761
- emitter = new gs();
4868
+ emitter = new Es();
4762
4869
  transformers = {};
4763
4870
  customHeadersProvider;
4764
4871
  managers = {};
@@ -4777,19 +4884,19 @@ class Os extends _ {
4777
4884
  async init(e = {}) {
4778
4885
  if (this.isInitialized)
4779
4886
  return { sessionId: this.get("sessionId") ?? "" };
4780
- this.managers.storage = new Rs();
4887
+ this.managers.storage = new Ns();
4781
4888
  try {
4782
4889
  this.setupState(e);
4783
4890
  const t = e.integrations?.custom?.headers ?? {}, s = e.integrations?.custom?.fetchCredentials ?? "include";
4784
- return this.managers.event = new Ts(
4891
+ return this.managers.event = new Is(
4785
4892
  this.managers.storage,
4786
4893
  this.emitter,
4787
4894
  this.transformers,
4788
4895
  t,
4789
4896
  this.customHeadersProvider,
4790
4897
  s
4791
- ), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((n) => {
4792
- a("warn", "Failed to recover persisted events", { error: n });
4898
+ ), this.loadPersistedIdentity(), this.initializeHandlers(), this.setupPageLifecycleListeners(), await this.managers.event.recoverPersistedEvents().catch((i) => {
4899
+ a("warn", "Failed to recover persisted events", { error: i });
4793
4900
  }), this.isInitialized = !0, { sessionId: this.get("sessionId") ?? "" };
4794
4901
  } catch (t) {
4795
4902
  this.destroy(!0);
@@ -4811,15 +4918,15 @@ class Os extends _ {
4811
4918
  }
4812
4919
  let s = t;
4813
4920
  t && typeof t == "object" && !Array.isArray(t) && Object.getPrototypeOf(t) !== Object.prototype && (s = Object.assign({}, t));
4814
- const { valid: n, error: i, sanitizedMetadata: o } = ms(e, s);
4815
- if (!n) {
4816
- if (this.get("mode") === ie.QA)
4817
- throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${i}`);
4818
- a("warn", `Custom event "${e}" dropped: ${i}`);
4921
+ const { valid: i, error: n, sanitizedMetadata: o } = gs(e, s);
4922
+ if (!i) {
4923
+ if (this.get("mode") === ne.QA)
4924
+ throw new Error(`[TraceLog] Custom event "${e}" validation failed: ${n}`);
4925
+ a("warn", `Custom event "${e}" dropped: ${n}`);
4819
4926
  return;
4820
4927
  }
4821
4928
  this.managers.event.track({
4822
- type: d.CUSTOM,
4929
+ type: u.CUSTOM,
4823
4930
  custom_event: {
4824
4931
  name: e,
4825
4932
  ...o && { metadata: o }
@@ -4881,14 +4988,14 @@ class Os extends _ {
4881
4988
  }
4882
4989
  setupState(e = {}) {
4883
4990
  this.set("config", e);
4884
- const t = Is.getId(this.managers.storage);
4991
+ const t = vs.getId(this.managers.storage);
4885
4992
  this.set("userId", t);
4886
- const s = os(e);
4993
+ const s = as(e);
4887
4994
  this.set("collectApiUrls", s);
4888
- const n = Wt();
4889
- this.set("device", n);
4890
- const i = ye(window.location.href, e.sensitiveQueryParams);
4891
- this.set("pageUrl", i), es() && this.set("mode", ie.QA);
4995
+ const i = Xt();
4996
+ this.set("device", i);
4997
+ const n = ye(window.location.href, e.sensitiveQueryParams);
4998
+ this.set("pageUrl", n), ts() && this.set("mode", ne.QA);
4892
4999
  }
4893
5000
  /**
4894
5001
  * Returns the current configuration object.
@@ -4956,11 +5063,11 @@ class Os extends _ {
4956
5063
  const t = this.validateGlobalMetadata(e);
4957
5064
  if (!t.valid)
4958
5065
  throw new Error(`[TraceLog] Invalid global metadata: ${t.error}`);
4959
- const n = {
5066
+ const i = {
4960
5067
  ...this.get("config"),
4961
5068
  globalMetadata: e
4962
5069
  };
4963
- this.set("config", n), a("debug", "Global metadata updated (replaced)", { data: { keys: Object.keys(e) } });
5070
+ this.set("config", i), a("debug", "Global metadata updated (replaced)", { data: { keys: Object.keys(e) } });
4964
5071
  }
4965
5072
  /**
4966
5073
  * Merges new metadata with existing global metadata.
@@ -4973,12 +5080,12 @@ class Os extends _ {
4973
5080
  const t = this.validateGlobalMetadata(e);
4974
5081
  if (!t.valid)
4975
5082
  throw new Error(`[TraceLog] Invalid global metadata: ${t.error}`);
4976
- const s = this.get("config"), i = {
5083
+ const s = this.get("config"), n = {
4977
5084
  ...s.globalMetadata ?? {},
4978
5085
  ...e
4979
5086
  }, o = {
4980
5087
  ...s,
4981
- globalMetadata: i
5088
+ globalMetadata: n
4982
5089
  };
4983
5090
  this.set("config", o), a("debug", "Global metadata updated (merged)", { data: { keys: Object.keys(e) } });
4984
5091
  }
@@ -5006,12 +5113,12 @@ class Os extends _ {
5006
5113
  a("warn", "identify() userId exceeds 256 characters", { data: { length: e.trim().length } });
5007
5114
  return;
5008
5115
  }
5009
- const s = e.trim(), n = ht(t), i = {
5116
+ const s = e.trim(), i = ht(t), n = {
5010
5117
  userId: s,
5011
- ...n ? { traits: n } : {}
5118
+ ...i ? { traits: i } : {}
5012
5119
  };
5013
- this.set("identity", i), this.persistIdentity(i), a("debug", "Visitor identified", {
5014
- data: { userIdLength: s.length, traitKeys: n ? Object.keys(n) : [] }
5120
+ this.set("identity", n), this.persistIdentity(n), a("debug", "Visitor identified", {
5121
+ data: { userIdLength: s.length, traitKeys: i ? Object.keys(i) : [] }
5015
5122
  });
5016
5123
  }
5017
5124
  /**
@@ -5025,7 +5132,7 @@ class Os extends _ {
5025
5132
  */
5026
5133
  async resetIdentity() {
5027
5134
  await this.managers.event?.flushImmediately(), this.set("identity", void 0), this.clearPersistedIdentity();
5028
- const e = ut();
5135
+ const e = dt();
5029
5136
  this.managers.storage.setItem(Te, e), this.set("userId", e), this.set("hasStartSession", !1), this.set("sessionId", null), this.handlers.session?.stopTracking(), this.handlers.session?.startTracking(), a("debug", "Identity reset, new UUID generated");
5030
5137
  }
5031
5138
  /**
@@ -5053,14 +5160,14 @@ class Os extends _ {
5053
5160
  loadPersistedIdentity() {
5054
5161
  const e = this.managers.storage, t = this.getProjectId(), s = fe(t);
5055
5162
  try {
5056
- const n = e.getItem(U);
5057
- if (n) {
5058
- const i = JSON.parse(n);
5059
- if (e.removeItem(U), !this.isValidIdentityData(i)) {
5163
+ const i = e.getItem(U);
5164
+ if (i) {
5165
+ const n = JSON.parse(i);
5166
+ if (e.removeItem(U), !this.isValidIdentityData(n)) {
5060
5167
  a("debug", "Invalid pending identity in localStorage, discarded");
5061
5168
  return;
5062
5169
  }
5063
- const o = { ...i, userId: i.userId.trim() };
5170
+ const o = { ...n, userId: n.userId.trim() };
5064
5171
  e.setItem(s, JSON.stringify(o)), this.set("identity", o), a("debug", "Migrated pending identity to project-scoped key");
5065
5172
  return;
5066
5173
  }
@@ -5068,14 +5175,14 @@ class Os extends _ {
5068
5175
  e.removeItem(U);
5069
5176
  }
5070
5177
  try {
5071
- const n = e.getItem(s);
5072
- if (n) {
5073
- const i = JSON.parse(n);
5074
- if (!this.isValidIdentityData(i)) {
5178
+ const i = e.getItem(s);
5179
+ if (i) {
5180
+ const n = JSON.parse(i);
5181
+ if (!this.isValidIdentityData(n)) {
5075
5182
  e.removeItem(s), a("debug", "Invalid persisted identity in localStorage, discarded");
5076
5183
  return;
5077
5184
  }
5078
- const o = { ...i, userId: i.userId.trim() };
5185
+ const o = { ...n, userId: n.userId.trim() };
5079
5186
  this.set("identity", o), a("debug", "Loaded persisted identity");
5080
5187
  }
5081
5188
  } catch {
@@ -5092,8 +5199,8 @@ class Os extends _ {
5092
5199
  if (typeof t != "string" || t.trim().length === 0 || t.trim().length > 256) return !1;
5093
5200
  if (s !== void 0) {
5094
5201
  if (typeof s != "object" || s === null || Array.isArray(s)) return !1;
5095
- for (const n of Object.values(s))
5096
- if (typeof n != "string") return !1;
5202
+ for (const i of Object.values(s))
5203
+ if (typeof i != "string") return !1;
5097
5204
  }
5098
5205
  return !0;
5099
5206
  }
@@ -5115,7 +5222,7 @@ class Os extends _ {
5115
5222
  }
5116
5223
  initializeHandlers() {
5117
5224
  const e = this.get("config");
5118
- this.handlers.session = new ys(
5225
+ this.handlers.session = new ws(
5119
5226
  this.managers.storage,
5120
5227
  this.managers.event
5121
5228
  ), this.handlers.session.startTracking();
@@ -5124,38 +5231,38 @@ class Os extends _ {
5124
5231
  this.set("suppressNextScroll", !1);
5125
5232
  }, 500);
5126
5233
  };
5127
- if (this.handlers.pageView = new ws(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new bs(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new As(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new Ns(this.managers.event), this.handlers.performance.startTracking().catch((s) => {
5234
+ if (this.handlers.pageView = new bs(this.managers.event, t), this.handlers.pageView.startTracking(), this.handlers.click = new Ls(this.managers.event), this.handlers.click.startTracking(), this.handlers.scroll = new As(this.managers.event), this.handlers.scroll.startTracking(), this.handlers.performance = new Os(this.managers.event), this.handlers.performance.startTracking().catch((s) => {
5128
5235
  a("warn", "Failed to start performance tracking", { error: s });
5129
- }), this.handlers.error = new ae(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new Ls(this.managers.event), this.handlers.viewport.startTracking()), e.integrations?.tracelog?.shopify) {
5130
- const s = new Cs();
5131
- s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(se.EVENT, (n) => {
5132
- n.type === d.SESSION_START && s.onSessionChange();
5236
+ }), this.handlers.error = new ae(this.managers.event), this.handlers.error.startTracking(), e.viewport && (this.handlers.viewport = new Ms(this.managers.event), this.handlers.viewport.startTracking()), e.integrations?.tracelog?.shopify) {
5237
+ const s = new Rs();
5238
+ s.activate(), this.integrationInstances.shopifyCartLinker = s, this.emitter.on(se.EVENT, (i) => {
5239
+ i.type === u.SESSION_START && s.onSessionChange();
5133
5240
  });
5134
5241
  }
5135
5242
  }
5136
5243
  }
5137
5244
  const k = [], M = [];
5138
- let D = null, h = null, R = !1, S = !1, P = null;
5139
- const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (S = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R && P || (R = !0, P = (async () => {
5245
+ let D = null, h = null, R = !1, T = !1, P = null;
5246
+ const Ds = async (r) => typeof window > "u" || typeof document > "u" ? { sessionId: "" } : (T = !1, window.__traceLogDisabled === !0 ? { sessionId: "" } : h ? { sessionId: h.getSessionId() ?? "" } : (R && P || (R = !0, P = (async () => {
5140
5247
  try {
5141
- const e = ds(r ?? {}), t = new Os();
5248
+ const e = hs(r ?? {}), t = new Ps();
5142
5249
  try {
5143
5250
  k.forEach(({ event: o, callback: l }) => {
5144
5251
  t.on(o, l);
5145
5252
  }), k.length = 0, M.forEach(({ hook: o, fn: l }) => {
5146
5253
  o === "beforeSend" ? t.setTransformer("beforeSend", l) : t.setTransformer("beforeBatch", l);
5147
5254
  }), M.length = 0, D && (t.setCustomHeaders(D), D = null);
5148
- const s = t.init(e), n = new Promise((o, l) => {
5255
+ const s = t.init(e), i = new Promise((o, l) => {
5149
5256
  setTimeout(() => {
5150
5257
  l(new Error("[TraceLog] Initialization timeout after 10000ms"));
5151
5258
  }, 1e4);
5152
- }), i = await Promise.race([s, n]);
5153
- return h = t, i;
5259
+ }), n = await Promise.race([s, i]);
5260
+ return h = t, n;
5154
5261
  } catch (s) {
5155
5262
  try {
5156
5263
  t.destroy(!0);
5157
- } catch (n) {
5158
- a("error", "Failed to cleanup partially initialized app", { error: n });
5264
+ } catch (i) {
5265
+ a("error", "Failed to cleanup partially initialized app", { error: i });
5159
5266
  }
5160
5267
  throw s;
5161
5268
  }
@@ -5164,15 +5271,15 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
5164
5271
  } finally {
5165
5272
  R = !1, P = null;
5166
5273
  }
5167
- })()), P)), Ds = (r, e) => {
5274
+ })()), P)), ks = (r, e) => {
5168
5275
  if (!(typeof window > "u" || typeof document > "u")) {
5169
5276
  if (!h)
5170
5277
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
5171
- if (S)
5278
+ if (T)
5172
5279
  throw new Error("[TraceLog] Cannot send events while TraceLog is being destroyed");
5173
5280
  h.sendCustomEvent(r, e);
5174
5281
  }
5175
- }, ks = (r, e) => {
5282
+ }, Vs = (r, e) => {
5176
5283
  if (!(typeof window > "u" || typeof document > "u")) {
5177
5284
  if (!h || R) {
5178
5285
  k.push({ event: r, callback: e });
@@ -5180,7 +5287,7 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
5180
5287
  }
5181
5288
  h.on(r, e);
5182
5289
  }
5183
- }, Vs = (r, e) => {
5290
+ }, Us = (r, e) => {
5184
5291
  if (!(typeof window > "u" || typeof document > "u")) {
5185
5292
  if (!h) {
5186
5293
  const t = k.findIndex((s) => s.event === r && s.callback === e);
@@ -5190,7 +5297,7 @@ const Ps = async (r) => typeof window > "u" || typeof document > "u" ? { session
5190
5297
  h.off(r, e);
5191
5298
  }
5192
5299
  };
5193
- function Us(r, e) {
5300
+ function Fs(r, e) {
5194
5301
  if (!(typeof window > "u" || typeof document > "u")) {
5195
5302
  if (typeof e != "function")
5196
5303
  throw new Error(`[TraceLog] Transformer must be a function, received: ${typeof e}`);
@@ -5199,7 +5306,7 @@ function Us(r, e) {
5199
5306
  t !== -1 && M.splice(t, 1), M.push({ hook: r, fn: e });
5200
5307
  return;
5201
5308
  }
5202
- if (S)
5309
+ if (T)
5203
5310
  throw new Error("[TraceLog] Cannot set transformers while TraceLog is being destroyed");
5204
5311
  r === "beforeSend" ? h.setTransformer("beforeSend", e) : h.setTransformer("beforeBatch", e);
5205
5312
  }
@@ -5211,11 +5318,11 @@ const Hs = (r) => {
5211
5318
  e !== -1 && M.splice(e, 1);
5212
5319
  return;
5213
5320
  }
5214
- if (S)
5321
+ if (T)
5215
5322
  throw new Error("[TraceLog] Cannot remove transformers while TraceLog is being destroyed");
5216
5323
  h.removeTransformer(r);
5217
5324
  }
5218
- }, Fs = (r) => {
5325
+ }, xs = (r) => {
5219
5326
  if (!(typeof window > "u" || typeof document > "u")) {
5220
5327
  if (typeof r != "function")
5221
5328
  throw new Error(`[TraceLog] Custom headers provider must be a function, received: ${typeof r}`);
@@ -5223,54 +5330,54 @@ const Hs = (r) => {
5223
5330
  D = r;
5224
5331
  return;
5225
5332
  }
5226
- if (S)
5333
+ if (T)
5227
5334
  throw new Error("[TraceLog] Cannot set custom headers while TraceLog is being destroyed");
5228
5335
  h.setCustomHeaders(r);
5229
5336
  }
5230
- }, xs = () => {
5337
+ }, $s = () => {
5231
5338
  if (!(typeof window > "u" || typeof document > "u")) {
5232
5339
  if (!h) {
5233
5340
  D = null;
5234
5341
  return;
5235
5342
  }
5236
- if (S)
5343
+ if (T)
5237
5344
  throw new Error("[TraceLog] Cannot remove custom headers while TraceLog is being destroyed");
5238
5345
  h.removeCustomHeaders();
5239
5346
  }
5240
- }, $s = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Bs = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Ws = () => {
5347
+ }, Bs = () => typeof window > "u" || typeof document > "u" ? !1 : h !== null, Ws = () => typeof window > "u" || typeof document > "u" || !h ? null : h.getSessionId(), Xs = () => {
5241
5348
  if (!(typeof window > "u" || typeof document > "u")) {
5242
- if (S)
5349
+ if (T)
5243
5350
  throw new Error("[TraceLog] Destroy operation already in progress");
5244
5351
  if (!h) {
5245
- S = !1;
5352
+ T = !1;
5246
5353
  return;
5247
5354
  }
5248
- S = !0;
5355
+ T = !0;
5249
5356
  try {
5250
- h.destroy(), h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, S = !1;
5357
+ h.destroy(), h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, T = !1;
5251
5358
  } catch (r) {
5252
- h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, S = !1, a("warn", "Error during destroy, forced cleanup completed", { error: r });
5359
+ h = null, R = !1, P = null, k.length = 0, M.length = 0, D = null, T = !1, a("warn", "Error during destroy, forced cleanup completed", { error: r });
5253
5360
  }
5254
5361
  }
5255
- }, Xs = (r) => {
5256
- typeof window > "u" || typeof document > "u" || ts(r);
5257
5362
  }, Gs = (r) => {
5363
+ typeof window > "u" || typeof document > "u" || ss(r);
5364
+ }, js = (r) => {
5258
5365
  if (!(typeof window > "u" || typeof document > "u")) {
5259
5366
  if (!h)
5260
5367
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
5261
- if (S)
5368
+ if (T)
5262
5369
  throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
5263
5370
  h.updateGlobalMetadata(r);
5264
5371
  }
5265
- }, js = (r) => {
5372
+ }, zs = (r) => {
5266
5373
  if (!(typeof window > "u" || typeof document > "u")) {
5267
5374
  if (!h)
5268
5375
  throw new Error("[TraceLog] TraceLog not initialized. Please call init() first.");
5269
- if (S)
5376
+ if (T)
5270
5377
  throw new Error("[TraceLog] Cannot update metadata while TraceLog is being destroyed");
5271
5378
  h.mergeGlobalMetadata(r);
5272
5379
  }
5273
- }, zs = (r, e) => {
5380
+ }, Ks = (r, e) => {
5274
5381
  if (!(typeof window > "u" || typeof document > "u")) {
5275
5382
  if (!r || typeof r != "string" || r.trim().length === 0) {
5276
5383
  a("warn", "identify() called with invalid userId");
@@ -5280,7 +5387,7 @@ const Hs = (r) => {
5280
5387
  a("warn", "identify() userId exceeds 256 characters");
5281
5388
  return;
5282
5389
  }
5283
- if (S) {
5390
+ if (T) {
5284
5391
  a("warn", "Cannot identify while TraceLog is being destroyed");
5285
5392
  return;
5286
5393
  }
@@ -5307,47 +5414,47 @@ const Hs = (r) => {
5307
5414
  }
5308
5415
  return;
5309
5416
  }
5310
- if (S)
5417
+ if (T)
5311
5418
  throw new Error("[TraceLog] Cannot reset identity while TraceLog is being destroyed");
5312
5419
  await h.resetIdentity();
5313
5420
  }
5314
- }, yr = {
5315
- init: Ps,
5316
- event: Ds,
5317
- on: ks,
5318
- off: Vs,
5319
- setTransformer: Us,
5421
+ }, wr = {
5422
+ init: Ds,
5423
+ event: ks,
5424
+ on: Vs,
5425
+ off: Us,
5426
+ setTransformer: Fs,
5320
5427
  removeTransformer: Hs,
5321
- setCustomHeaders: Fs,
5322
- removeCustomHeaders: xs,
5323
- isInitialized: $s,
5324
- getSessionId: Bs,
5325
- destroy: Ws,
5326
- setQaMode: Xs,
5327
- updateGlobalMetadata: Gs,
5328
- mergeGlobalMetadata: js,
5329
- identify: zs,
5428
+ setCustomHeaders: xs,
5429
+ removeCustomHeaders: $s,
5430
+ isInitialized: Bs,
5431
+ getSessionId: Ws,
5432
+ destroy: Xs,
5433
+ setQaMode: Gs,
5434
+ updateGlobalMetadata: js,
5435
+ mergeGlobalMetadata: zs,
5436
+ identify: Ks,
5330
5437
  resetIdentity: Qs
5331
5438
  };
5332
- var Ae, C, G, Et, le, pt = -1, V = function(r) {
5439
+ var Le, C, G, Et, le, pt = -1, V = function(r) {
5333
5440
  addEventListener("pageshow", (function(e) {
5334
5441
  e.persisted && (pt = e.timeStamp, r(e));
5335
5442
  }), !0);
5336
5443
  }, Pe = function() {
5337
5444
  var r = self.performance && performance.getEntriesByType && performance.getEntriesByType("navigation")[0];
5338
5445
  if (r && r.responseStart > 0 && r.responseStart < performance.now()) return r;
5339
- }, ue = function() {
5446
+ }, de = function() {
5340
5447
  var r = Pe();
5341
5448
  return r && r.activationStart || 0;
5342
5449
  }, y = function(r, e) {
5343
5450
  var t = Pe(), s = "navigate";
5344
- return pt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || ue() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: r, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
5345
- }, F = function(r, e, t) {
5451
+ return pt >= 0 ? s = "back-forward-cache" : t && (document.prerendering || de() > 0 ? s = "prerender" : document.wasDiscarded ? s = "restore" : t.type && (s = t.type.replace(/_/g, "-"))), { name: r, value: e === void 0 ? -1 : e, rating: "good", delta: 0, entries: [], id: "v4-".concat(Date.now(), "-").concat(Math.floor(8999999999999 * Math.random()) + 1e12), navigationType: s };
5452
+ }, H = function(r, e, t) {
5346
5453
  try {
5347
5454
  if (PerformanceObserver.supportedEntryTypes.includes(r)) {
5348
- var s = new PerformanceObserver((function(n) {
5455
+ var s = new PerformanceObserver((function(i) {
5349
5456
  Promise.resolve().then((function() {
5350
- e(n.getEntries());
5457
+ e(i.getEntries());
5351
5458
  }));
5352
5459
  }));
5353
5460
  return s.observe(Object.assign({ type: r, buffered: !0 }, t || {})), s;
@@ -5355,9 +5462,9 @@ var Ae, C, G, Et, le, pt = -1, V = function(r) {
5355
5462
  } catch {
5356
5463
  }
5357
5464
  }, w = function(r, e, t, s) {
5358
- var n, i;
5465
+ var i, n;
5359
5466
  return function(o) {
5360
- e.value >= 0 && (o || s) && ((i = e.value - (n || 0)) || n === void 0) && (n = e.value, e.delta = i, e.rating = (function(l, c) {
5467
+ e.value >= 0 && (o || s) && ((n = e.value - (i || 0)) || i === void 0) && (i = e.value, e.delta = n, e.rating = (function(l, c) {
5361
5468
  return l > c[1] ? "poor" : l > c[0] ? "needs-improvement" : "good";
5362
5469
  })(e.value, t), r(e));
5363
5470
  };
@@ -5371,239 +5478,239 @@ var Ae, C, G, Et, le, pt = -1, V = function(r) {
5371
5478
  document.addEventListener("visibilitychange", (function() {
5372
5479
  document.visibilityState === "hidden" && r();
5373
5480
  }));
5374
- }, de = function(r) {
5481
+ }, ue = function(r) {
5375
5482
  var e = !1;
5376
5483
  return function() {
5377
5484
  e || (r(), e = !0);
5378
5485
  };
5379
- }, H = -1, et = function() {
5486
+ }, F = -1, et = function() {
5380
5487
  return document.visibilityState !== "hidden" || document.prerendering ? 1 / 0 : 0;
5381
5488
  }, ce = function(r) {
5382
- document.visibilityState === "hidden" && H > -1 && (H = r.type === "visibilitychange" ? r.timeStamp : 0, Ks());
5489
+ document.visibilityState === "hidden" && F > -1 && (F = r.type === "visibilitychange" ? r.timeStamp : 0, Ys());
5383
5490
  }, tt = function() {
5384
5491
  addEventListener("visibilitychange", ce, !0), addEventListener("prerenderingchange", ce, !0);
5385
- }, Ks = function() {
5492
+ }, Ys = function() {
5386
5493
  removeEventListener("visibilitychange", ce, !0), removeEventListener("prerenderingchange", ce, !0);
5387
5494
  }, ke = function() {
5388
- return H < 0 && (H = et(), tt(), V((function() {
5495
+ return F < 0 && (F = et(), tt(), V((function() {
5389
5496
  setTimeout((function() {
5390
- H = et(), tt();
5497
+ F = et(), tt();
5391
5498
  }), 0);
5392
5499
  }))), { get firstHiddenTime() {
5393
- return H;
5500
+ return F;
5394
5501
  } };
5395
- }, Q = function(r) {
5502
+ }, K = function(r) {
5396
5503
  document.prerendering ? addEventListener("prerenderingchange", (function() {
5397
5504
  return r();
5398
5505
  }), !0) : r();
5399
- }, Le = [1800, 3e3], St = function(r, e) {
5400
- e = e || {}, Q((function() {
5401
- var t, s = ke(), n = y("FCP"), i = F("paint", (function(o) {
5506
+ }, Ae = [1800, 3e3], St = function(r, e) {
5507
+ e = e || {}, K((function() {
5508
+ var t, s = ke(), i = y("FCP"), n = H("paint", (function(o) {
5402
5509
  o.forEach((function(l) {
5403
- l.name === "first-contentful-paint" && (i.disconnect(), l.startTime < s.firstHiddenTime && (n.value = Math.max(l.startTime - ue(), 0), n.entries.push(l), t(!0)));
5510
+ l.name === "first-contentful-paint" && (n.disconnect(), l.startTime < s.firstHiddenTime && (i.value = Math.max(l.startTime - de(), 0), i.entries.push(l), t(!0)));
5404
5511
  }));
5405
5512
  }));
5406
- i && (t = w(r, n, Le, e.reportAllChanges), V((function(o) {
5407
- n = y("FCP"), t = w(r, n, Le, e.reportAllChanges), De((function() {
5408
- n.value = performance.now() - o.timeStamp, t(!0);
5513
+ n && (t = w(r, i, Ae, e.reportAllChanges), V((function(o) {
5514
+ i = y("FCP"), t = w(r, i, Ae, e.reportAllChanges), De((function() {
5515
+ i.value = performance.now() - o.timeStamp, t(!0);
5409
5516
  }));
5410
5517
  })));
5411
5518
  }));
5412
- }, Me = [0.1, 0.25], Ys = function(r, e) {
5413
- e = e || {}, St(de((function() {
5414
- var t, s = y("CLS", 0), n = 0, i = [], o = function(c) {
5415
- c.forEach((function(u) {
5416
- if (!u.hadRecentInput) {
5417
- var f = i[0], g = i[i.length - 1];
5418
- n && u.startTime - g.startTime < 1e3 && u.startTime - f.startTime < 5e3 ? (n += u.value, i.push(u)) : (n = u.value, i = [u]);
5519
+ }, Me = [0.1, 0.25], qs = function(r, e) {
5520
+ e = e || {}, St(ue((function() {
5521
+ var t, s = y("CLS", 0), i = 0, n = [], o = function(c) {
5522
+ c.forEach((function(d) {
5523
+ if (!d.hadRecentInput) {
5524
+ var f = n[0], g = n[n.length - 1];
5525
+ i && d.startTime - g.startTime < 1e3 && d.startTime - f.startTime < 5e3 ? (i += d.value, n.push(d)) : (i = d.value, n = [d]);
5419
5526
  }
5420
- })), n > s.value && (s.value = n, s.entries = i, t());
5421
- }, l = F("layout-shift", o);
5527
+ })), i > s.value && (s.value = i, s.entries = n, t());
5528
+ }, l = H("layout-shift", o);
5422
5529
  l && (t = w(r, s, Me, e.reportAllChanges), z((function() {
5423
5530
  o(l.takeRecords()), t(!0);
5424
5531
  })), V((function() {
5425
- n = 0, s = y("CLS", 0), t = w(r, s, Me, e.reportAllChanges), De((function() {
5532
+ i = 0, s = y("CLS", 0), t = w(r, s, Me, e.reportAllChanges), De((function() {
5426
5533
  return t();
5427
5534
  }));
5428
5535
  })), setTimeout(t, 0));
5429
5536
  })));
5430
- }, Tt = 0, pe = 1 / 0, J = 0, qs = function(r) {
5537
+ }, Tt = 0, pe = 1 / 0, J = 0, Js = function(r) {
5431
5538
  r.forEach((function(e) {
5432
5539
  e.interactionId && (pe = Math.min(pe, e.interactionId), J = Math.max(J, e.interactionId), Tt = J ? (J - pe) / 7 + 1 : 0);
5433
5540
  }));
5434
5541
  }, It = function() {
5435
- return Ae ? Tt : performance.interactionCount || 0;
5436
- }, Js = function() {
5437
- "interactionCount" in performance || Ae || (Ae = F("event", qs, { type: "event", buffered: !0, durationThreshold: 0 }));
5438
- }, A = [], te = /* @__PURE__ */ new Map(), vt = 0, Zs = function() {
5439
- var r = Math.min(A.length - 1, Math.floor((It() - vt) / 50));
5440
- return A[r];
5441
- }, er = [], tr = function(r) {
5442
- if (er.forEach((function(n) {
5443
- return n(r);
5542
+ return Le ? Tt : performance.interactionCount || 0;
5543
+ }, Zs = function() {
5544
+ "interactionCount" in performance || Le || (Le = H("event", Js, { type: "event", buffered: !0, durationThreshold: 0 }));
5545
+ }, L = [], te = /* @__PURE__ */ new Map(), vt = 0, er = function() {
5546
+ var r = Math.min(L.length - 1, Math.floor((It() - vt) / 50));
5547
+ return L[r];
5548
+ }, tr = [], sr = function(r) {
5549
+ if (tr.forEach((function(i) {
5550
+ return i(r);
5444
5551
  })), r.interactionId || r.entryType === "first-input") {
5445
- var e = A[A.length - 1], t = te.get(r.interactionId);
5446
- if (t || A.length < 10 || r.duration > e.latency) {
5552
+ var e = L[L.length - 1], t = te.get(r.interactionId);
5553
+ if (t || L.length < 10 || r.duration > e.latency) {
5447
5554
  if (t) r.duration > t.latency ? (t.entries = [r], t.latency = r.duration) : r.duration === t.latency && r.startTime === t.entries[0].startTime && t.entries.push(r);
5448
5555
  else {
5449
5556
  var s = { id: r.interactionId, latency: r.duration, entries: [r] };
5450
- te.set(s.id, s), A.push(s);
5557
+ te.set(s.id, s), L.push(s);
5451
5558
  }
5452
- A.sort((function(n, i) {
5453
- return i.latency - n.latency;
5454
- })), A.length > 10 && A.splice(10).forEach((function(n) {
5455
- return te.delete(n.id);
5559
+ L.sort((function(i, n) {
5560
+ return n.latency - i.latency;
5561
+ })), L.length > 10 && L.splice(10).forEach((function(i) {
5562
+ return te.delete(i.id);
5456
5563
  }));
5457
5564
  }
5458
5565
  }
5459
5566
  }, _t = function(r) {
5460
5567
  var e = self.requestIdleCallback || self.setTimeout, t = -1;
5461
- return r = de(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
5462
- }, Ce = [200, 500], sr = function(r, e) {
5463
- "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, Q((function() {
5568
+ return r = ue(r), document.visibilityState === "hidden" ? r() : (t = e(r), z(r)), t;
5569
+ }, Ce = [200, 500], rr = function(r, e) {
5570
+ "PerformanceEventTiming" in self && "interactionId" in PerformanceEventTiming.prototype && (e = e || {}, K((function() {
5464
5571
  var t;
5465
- Js();
5466
- var s, n = y("INP"), i = function(l) {
5572
+ Zs();
5573
+ var s, i = y("INP"), n = function(l) {
5467
5574
  _t((function() {
5468
- l.forEach(tr);
5469
- var c = Zs();
5470
- c && c.latency !== n.value && (n.value = c.latency, n.entries = c.entries, s());
5575
+ l.forEach(sr);
5576
+ var c = er();
5577
+ c && c.latency !== i.value && (i.value = c.latency, i.entries = c.entries, s());
5471
5578
  }));
5472
- }, o = F("event", i, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
5473
- s = w(r, n, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), z((function() {
5474
- i(o.takeRecords()), s(!0);
5579
+ }, o = H("event", n, { durationThreshold: (t = e.durationThreshold) !== null && t !== void 0 ? t : 40 });
5580
+ s = w(r, i, Ce, e.reportAllChanges), o && (o.observe({ type: "first-input", buffered: !0 }), z((function() {
5581
+ n(o.takeRecords()), s(!0);
5475
5582
  })), V((function() {
5476
- vt = It(), A.length = 0, te.clear(), n = y("INP"), s = w(r, n, Ce, e.reportAllChanges);
5583
+ vt = It(), L.length = 0, te.clear(), i = y("INP"), s = w(r, i, Ce, e.reportAllChanges);
5477
5584
  })));
5478
5585
  })));
5479
- }, Re = [2500, 4e3], Se = {}, rr = function(r, e) {
5480
- e = e || {}, Q((function() {
5481
- var t, s = ke(), n = y("LCP"), i = function(c) {
5482
- e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(u) {
5483
- u.startTime < s.firstHiddenTime && (n.value = Math.max(u.startTime - ue(), 0), n.entries = [u], t());
5586
+ }, Re = [2500, 4e3], Se = {}, ir = function(r, e) {
5587
+ e = e || {}, K((function() {
5588
+ var t, s = ke(), i = y("LCP"), n = function(c) {
5589
+ e.reportAllChanges || (c = c.slice(-1)), c.forEach((function(d) {
5590
+ d.startTime < s.firstHiddenTime && (i.value = Math.max(d.startTime - de(), 0), i.entries = [d], t());
5484
5591
  }));
5485
- }, o = F("largest-contentful-paint", i);
5592
+ }, o = H("largest-contentful-paint", n);
5486
5593
  if (o) {
5487
- t = w(r, n, Re, e.reportAllChanges);
5488
- var l = de((function() {
5489
- Se[n.id] || (i(o.takeRecords()), o.disconnect(), Se[n.id] = !0, t(!0));
5594
+ t = w(r, i, Re, e.reportAllChanges);
5595
+ var l = ue((function() {
5596
+ Se[i.id] || (n(o.takeRecords()), o.disconnect(), Se[i.id] = !0, t(!0));
5490
5597
  }));
5491
5598
  ["keydown", "click"].forEach((function(c) {
5492
5599
  addEventListener(c, (function() {
5493
5600
  return _t(l);
5494
5601
  }), { once: !0, capture: !0 });
5495
5602
  })), z(l), V((function(c) {
5496
- n = y("LCP"), t = w(r, n, Re, e.reportAllChanges), De((function() {
5497
- n.value = performance.now() - c.timeStamp, Se[n.id] = !0, t(!0);
5603
+ i = y("LCP"), t = w(r, i, Re, e.reportAllChanges), De((function() {
5604
+ i.value = performance.now() - c.timeStamp, Se[i.id] = !0, t(!0);
5498
5605
  }));
5499
5606
  }));
5500
5607
  }
5501
5608
  }));
5502
5609
  }, Ne = [800, 1800], nr = function r(e) {
5503
- document.prerendering ? Q((function() {
5610
+ document.prerendering ? K((function() {
5504
5611
  return r(e);
5505
5612
  })) : document.readyState !== "complete" ? addEventListener("load", (function() {
5506
5613
  return r(e);
5507
5614
  }), !0) : setTimeout(e, 0);
5508
- }, ir = function(r, e) {
5615
+ }, or = function(r, e) {
5509
5616
  e = e || {};
5510
5617
  var t = y("TTFB"), s = w(r, t, Ne, e.reportAllChanges);
5511
5618
  nr((function() {
5512
- var n = Pe();
5513
- n && (t.value = Math.max(n.responseStart - ue(), 0), t.entries = [n], s(!0), V((function() {
5619
+ var i = Pe();
5620
+ i && (t.value = Math.max(i.responseStart - de(), 0), t.entries = [i], s(!0), V((function() {
5514
5621
  t = y("TTFB", 0), (s = w(r, t, Ne, e.reportAllChanges))(!0);
5515
5622
  })));
5516
5623
  }));
5517
- }, W = { passive: !0, capture: !0 }, or = /* @__PURE__ */ new Date(), st = function(r, e) {
5624
+ }, W = { passive: !0, capture: !0 }, ar = /* @__PURE__ */ new Date(), st = function(r, e) {
5518
5625
  C || (C = e, G = r, Et = /* @__PURE__ */ new Date(), wt(removeEventListener), yt());
5519
5626
  }, yt = function() {
5520
- if (G >= 0 && G < Et - or) {
5627
+ if (G >= 0 && G < Et - ar) {
5521
5628
  var r = { entryType: "first-input", name: C.type, target: C.target, cancelable: C.cancelable, startTime: C.timeStamp, processingStart: C.timeStamp + G };
5522
5629
  le.forEach((function(e) {
5523
5630
  e(r);
5524
5631
  })), le = [];
5525
5632
  }
5526
- }, ar = function(r) {
5633
+ }, lr = function(r) {
5527
5634
  if (r.cancelable) {
5528
5635
  var e = (r.timeStamp > 1e12 ? /* @__PURE__ */ new Date() : performance.now()) - r.timeStamp;
5529
5636
  r.type == "pointerdown" ? (function(t, s) {
5530
- var n = function() {
5637
+ var i = function() {
5531
5638
  st(t, s), o();
5532
- }, i = function() {
5639
+ }, n = function() {
5533
5640
  o();
5534
5641
  }, o = function() {
5535
- removeEventListener("pointerup", n, W), removeEventListener("pointercancel", i, W);
5642
+ removeEventListener("pointerup", i, W), removeEventListener("pointercancel", n, W);
5536
5643
  };
5537
- addEventListener("pointerup", n, W), addEventListener("pointercancel", i, W);
5644
+ addEventListener("pointerup", i, W), addEventListener("pointercancel", n, W);
5538
5645
  })(e, r) : st(e, r);
5539
5646
  }
5540
5647
  }, wt = function(r) {
5541
5648
  ["mousedown", "keydown", "touchstart", "pointerdown"].forEach((function(e) {
5542
- return r(e, ar, W);
5649
+ return r(e, lr, W);
5543
5650
  }));
5544
- }, Oe = [100, 300], lr = function(r, e) {
5545
- e = e || {}, Q((function() {
5546
- var t, s = ke(), n = y("FID"), i = function(c) {
5547
- c.startTime < s.firstHiddenTime && (n.value = c.processingStart - c.startTime, n.entries.push(c), t(!0));
5651
+ }, Oe = [100, 300], cr = function(r, e) {
5652
+ e = e || {}, K((function() {
5653
+ var t, s = ke(), i = y("FID"), n = function(c) {
5654
+ c.startTime < s.firstHiddenTime && (i.value = c.processingStart - c.startTime, i.entries.push(c), t(!0));
5548
5655
  }, o = function(c) {
5549
- c.forEach(i);
5550
- }, l = F("first-input", o);
5551
- t = w(r, n, Oe, e.reportAllChanges), l && (z(de((function() {
5656
+ c.forEach(n);
5657
+ }, l = H("first-input", o);
5658
+ t = w(r, i, Oe, e.reportAllChanges), l && (z(ue((function() {
5552
5659
  o(l.takeRecords()), l.disconnect();
5553
5660
  }))), V((function() {
5554
5661
  var c;
5555
- n = y("FID"), t = w(r, n, Oe, e.reportAllChanges), le = [], G = -1, C = null, wt(addEventListener), c = i, le.push(c), yt();
5662
+ i = y("FID"), t = w(r, i, Oe, e.reportAllChanges), le = [], G = -1, C = null, wt(addEventListener), c = n, le.push(c), yt();
5556
5663
  })));
5557
5664
  }));
5558
5665
  };
5559
- const cr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5666
+ const dr = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
5560
5667
  __proto__: null,
5561
5668
  CLSThresholds: Me,
5562
- FCPThresholds: Le,
5669
+ FCPThresholds: Ae,
5563
5670
  FIDThresholds: Oe,
5564
5671
  INPThresholds: Ce,
5565
5672
  LCPThresholds: Re,
5566
5673
  TTFBThresholds: Ne,
5567
- onCLS: Ys,
5674
+ onCLS: qs,
5568
5675
  onFCP: St,
5569
- onFID: lr,
5570
- onINP: sr,
5571
- onLCP: rr,
5572
- onTTFB: ir
5676
+ onFID: cr,
5677
+ onINP: rr,
5678
+ onLCP: ir,
5679
+ onTTFB: or
5573
5680
  }, Symbol.toStringTag, { value: "Module" }));
5574
5681
  export {
5575
5682
  m as AppConfigValidationError,
5576
5683
  ur as DEFAULT_SESSION_TIMEOUT,
5577
5684
  _e as DEFAULT_WEB_VITALS_MODE,
5578
- L as DeviceType,
5685
+ A as DeviceType,
5579
5686
  se as EmitterEvent,
5580
5687
  B as ErrorType,
5581
- d as EventType,
5582
- vr as InitializationTimeoutError,
5688
+ u as EventType,
5689
+ _r as InitializationTimeoutError,
5583
5690
  N as IntegrationValidationError,
5584
- Sr as MAX_ARRAY_LENGTH,
5585
- mr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
5586
- fr as MAX_CUSTOM_EVENT_KEYS,
5587
- dr as MAX_CUSTOM_EVENT_NAME_LENGTH,
5588
- hr as MAX_CUSTOM_EVENT_STRING_SIZE,
5589
- gr as MAX_NESTED_OBJECT_KEYS,
5590
- Er as MAX_STRING_LENGTH,
5591
- pr as MAX_STRING_LENGTH_IN_ARRAY,
5592
- ie as Mode,
5691
+ Tr as MAX_ARRAY_LENGTH,
5692
+ gr as MAX_CUSTOM_EVENT_ARRAY_SIZE,
5693
+ mr as MAX_CUSTOM_EVENT_KEYS,
5694
+ hr as MAX_CUSTOM_EVENT_NAME_LENGTH,
5695
+ fr as MAX_CUSTOM_EVENT_STRING_SIZE,
5696
+ Er as MAX_NESTED_OBJECT_KEYS,
5697
+ pr as MAX_STRING_LENGTH,
5698
+ Sr as MAX_STRING_LENGTH_IN_ARRAY,
5699
+ ne as Mode,
5593
5700
  at as PII_PATTERNS,
5594
5701
  O as PermanentError,
5595
5702
  re as RateLimitError,
5596
5703
  We as SamplingRateValidationError,
5597
5704
  Z as ScrollDirection,
5598
- Ot as SessionTimeoutValidationError,
5705
+ Pt as SessionTimeoutValidationError,
5599
5706
  $ as SpecialApiUrl,
5600
- ne as TimeoutError,
5707
+ ie as TimeoutError,
5601
5708
  j as TraceLogValidationError,
5602
- _r as WEB_VITALS_GOOD_THRESHOLDS,
5603
- Qe as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
5709
+ yr as WEB_VITALS_GOOD_THRESHOLDS,
5710
+ Ke as WEB_VITALS_NEEDS_IMPROVEMENT_THRESHOLDS,
5604
5711
  Qt as WEB_VITALS_POOR_THRESHOLDS,
5605
- Ke as getWebVitalsThresholds,
5606
- Tr as isPrimaryScrollEvent,
5607
- Ir as isSecondaryScrollEvent,
5608
- yr as tracelog
5712
+ Qe as getWebVitalsThresholds,
5713
+ Ir as isPrimaryScrollEvent,
5714
+ vr as isSecondaryScrollEvent,
5715
+ wr as tracelog
5609
5716
  };