@usermaven/nextjs 1.5.4 → 1.5.5-rc.100

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.
Files changed (2) hide show
  1. package/lib/index.es.js +460 -409
  2. package/package.json +2 -2
package/lib/index.es.js CHANGED
@@ -8,8 +8,8 @@ const UsermavenProvider = function ({ children, client }) {
8
8
  return React.createElement(Context.Provider, { value: client }, children);
9
9
  };
10
10
 
11
- var v = /* @__PURE__ */ ((i) => (i[i.DEBUG = 0] = "DEBUG", i[i.INFO = 1] = "INFO", i[i.WARN = 2] = "WARN", i[i.ERROR = 3] = "ERROR", i))(v || {});
12
- class W {
11
+ var p = /* @__PURE__ */ ((n) => (n[n.DEBUG = 0] = "DEBUG", n[n.INFO = 1] = "INFO", n[n.WARN = 2] = "WARN", n[n.ERROR = 3] = "ERROR", n))(p || {});
12
+ class G {
13
13
  constructor(e) {
14
14
  this.level = e;
15
15
  }
@@ -26,11 +26,11 @@ class W {
26
26
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
27
27
  }
28
28
  }
29
- function d(i = 0) {
30
- return new W(i);
29
+ function d(n = 0) {
30
+ return new G(n);
31
31
  }
32
- const U = {
33
- logLevel: v.ERROR,
32
+ const q = {
33
+ logLevel: p.ERROR,
34
34
  useBeaconApi: !1,
35
35
  forceUseFetch: !1,
36
36
  trackingHost: "t.usermaven.com",
@@ -55,20 +55,20 @@ const U = {
55
55
  maskAllText: !1,
56
56
  maskAllElementAttributes: !1
57
57
  };
58
- class X {
58
+ class j {
59
59
  constructor(e) {
60
60
  this.domain = e, this.cookieDomain = this.getCookieDomain();
61
61
  }
62
- set(e, t, s = 365, n = !0, r = !1) {
62
+ set(e, t, i = 365, s = !0, r = !1) {
63
63
  const o = /* @__PURE__ */ new Date();
64
- o.setTime(o.getTime() + s * 24 * 60 * 60 * 1e3);
65
- const c = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", a = r ? "; HttpOnly" : "";
64
+ o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
65
+ const c = `expires=${o.toUTCString()}`, l = s ? "; Secure" : "", a = r ? "; HttpOnly" : "";
66
66
  document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
67
67
  }
68
68
  get(e) {
69
- const t = e + "=", s = document.cookie.split(";");
70
- for (let n = 0; n < s.length; n++) {
71
- let r = s[n].trim();
69
+ const t = e + "=", i = document.cookie.split(";");
70
+ for (let s = 0; s < i.length; s++) {
71
+ let r = i[s].trim();
72
72
  if (r.indexOf(t) === 0)
73
73
  return decodeURIComponent(r.substring(t.length));
74
74
  }
@@ -88,7 +88,7 @@ class X {
88
88
  }
89
89
  isIpAddress(e) {
90
90
  const t = e.split(".");
91
- return t.length === 4 && t.every((s) => !isNaN(Number(s)));
91
+ return t.length === 4 && t.every((i) => !isNaN(Number(i)));
92
92
  }
93
93
  extractHostname(e) {
94
94
  let t;
@@ -96,110 +96,110 @@ class X {
96
96
  }
97
97
  extractRootDomain(e) {
98
98
  let t = this.extractHostname(e);
99
- const s = t.split("."), n = s.length;
100
- return n > 2 && (s[n - 1].length == 2 ? (t = s[n - 2] + "." + s[n - 1], s[n - 2].length == 2 && (t = s[n - 3] + "." + t)) : t = s[n - 2] + "." + s[n - 1]), t;
99
+ const i = t.split("."), s = i.length;
100
+ return s > 2 && (i[s - 1].length == 2 ? (t = i[s - 2] + "." + i[s - 1], i[s - 2].length == 2 && (t = i[s - 3] + "." + t)) : t = i[s - 2] + "." + i[s - 1]), t;
101
101
  }
102
102
  extractTopLevelDomain(e) {
103
- const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, s = e.match(t);
104
- return s ? s[0] : "";
103
+ const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
104
+ return i ? i[0] : "";
105
105
  }
106
106
  }
107
- const K = Object.prototype, G = K.hasOwnProperty, Y = Array.prototype, E = Y.forEach, A = {};
108
- function Z(i, e, t) {
109
- if (Array.isArray(i)) {
110
- if (E && i.forEach === E)
111
- i.forEach(e, t);
112
- else if ("length" in i && i.length === +i.length) {
113
- for (let s = 0, n = i.length; s < n; s++)
114
- if (s in i && e.call(t, i[s], s) === A)
107
+ const ee = Object.prototype, te = ee.hasOwnProperty, ie = Array.prototype, P = ie.forEach, N = {};
108
+ function ne(n, e, t) {
109
+ if (Array.isArray(n)) {
110
+ if (P && n.forEach === P)
111
+ n.forEach(e, t);
112
+ else if ("length" in n && n.length === +n.length) {
113
+ for (let i = 0, s = n.length; i < s; i++)
114
+ if (i in n && e.call(t, n[i], i) === N)
115
115
  return;
116
116
  }
117
117
  }
118
118
  }
119
- const x = function(i) {
120
- return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
- }, j = function(i) {
122
- for (const e in i)
123
- typeof i[e] == "function" && (i[e] = i[e].bind(i));
119
+ const R = function(n) {
120
+ return n.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
121
+ }, se = function(n) {
122
+ for (const e in n)
123
+ typeof n[e] == "function" && (n[e] = n[e].bind(n));
124
124
  };
125
- function f(i, e, t) {
126
- if (i != null) {
127
- if (E && Array.isArray(i) && i.forEach === E)
128
- i.forEach(e, t);
129
- else if ("length" in i && i.length === +i.length) {
130
- for (let s = 0, n = i.length; s < n; s++)
131
- if (s in i && e.call(t, i[s], s) === A)
125
+ function g(n, e, t) {
126
+ if (n != null) {
127
+ if (P && Array.isArray(n) && n.forEach === P)
128
+ n.forEach(e, t);
129
+ else if ("length" in n && n.length === +n.length) {
130
+ for (let i = 0, s = n.length; i < s; i++)
131
+ if (i in n && e.call(t, n[i], i) === N)
132
132
  return;
133
133
  } else
134
- for (const s in i)
135
- if (G.call(i, s) && e.call(t, i[s], s) === A)
134
+ for (const i in n)
135
+ if (te.call(n, i) && e.call(t, n[i], i) === N)
136
136
  return;
137
137
  }
138
138
  }
139
- const ee = function(i, ...e) {
140
- return Z(e, function(t) {
141
- for (const s in t)
142
- t[s] !== void 0 && (i[s] = t[s]);
143
- }), i;
139
+ const re = function(n, ...e) {
140
+ return ne(e, function(t) {
141
+ for (const i in t)
142
+ t[i] !== void 0 && (n[i] = t[i]);
143
+ }), n;
144
144
  };
145
- function _(i, e) {
146
- return i.indexOf(e) !== -1;
145
+ function _(n, e) {
146
+ return n.indexOf(e) !== -1;
147
147
  }
148
- const te = function(i) {
148
+ const oe = function(n) {
149
149
  try {
150
- return /^\s*\bfunction\b/.test(i);
150
+ return /^\s*\bfunction\b/.test(n);
151
151
  } catch {
152
152
  return !1;
153
153
  }
154
- }, ie = function(i) {
155
- return i === void 0;
156
- }, m = function() {
157
- const i = function(s, n, r, o, c) {
158
- if (!s) {
154
+ }, ae = function(n) {
155
+ return n === void 0;
156
+ }, y = function() {
157
+ const n = function(i, s, r, o, c) {
158
+ if (!i) {
159
159
  d().error("No valid element provided to register_event");
160
160
  return;
161
161
  }
162
- if (s.addEventListener && !o)
163
- s.addEventListener(n, r, !!c);
162
+ if (i.addEventListener && !o)
163
+ i.addEventListener(s, r, !!c);
164
164
  else {
165
- const l = "on" + n, a = s[l];
166
- s[l] = e(s, r, a);
165
+ const l = "on" + s, a = i[l];
166
+ i[l] = e(i, r, a);
167
167
  }
168
168
  };
169
- function e(s, n, r) {
169
+ function e(i, s, r) {
170
170
  return function(o) {
171
171
  if (o = o || t(window.event), !o)
172
172
  return;
173
173
  let c = !0, l;
174
- te(r) && (l = r(o));
175
- const a = n.call(s, o);
174
+ oe(r) && (l = r(o));
175
+ const a = s.call(i, o);
176
176
  return (l === !1 || a === !1) && (c = !1), c;
177
177
  };
178
178
  }
179
- function t(s) {
180
- return s && (s.preventDefault = t.preventDefault, s.stopPropagation = t.stopPropagation), s;
179
+ function t(i) {
180
+ return i && (i.preventDefault = t.preventDefault, i.stopPropagation = t.stopPropagation), i;
181
181
  }
182
182
  return t.preventDefault = function() {
183
183
  this.returnValue = !1;
184
184
  }, t.stopPropagation = function() {
185
185
  this.cancelBubble = !0;
186
- }, i;
187
- }(), se = function(i) {
186
+ }, n;
187
+ }(), ce = function(n) {
188
188
  return function(...e) {
189
189
  try {
190
- return i.apply(this, e);
190
+ return n.apply(this, e);
191
191
  } catch (t) {
192
192
  d().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
193
193
  }
194
194
  };
195
- }, z = function(i) {
196
- for (const e in i)
197
- typeof i[e] == "function" && (i[e] = se(i[e]));
195
+ }, V = function(n) {
196
+ for (const e in n)
197
+ typeof n[e] == "function" && (n[e] = ce(n[e]));
198
198
  };
199
- function R(i) {
200
- for (let e in i)
201
- (i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
202
- return i;
199
+ function U(n) {
200
+ for (let e in n)
201
+ (n[e] === "" || n[e] === null || n[e] === void 0 || typeof n[e] == "object" && Object.keys(n[e]).length === 0) && delete n[e];
202
+ return n;
203
203
  }
204
204
  function u() {
205
205
  try {
@@ -208,80 +208,80 @@ function u() {
208
208
  return d().warn("window is not available"), !1;
209
209
  }
210
210
  }
211
- function p(i = 5) {
212
- const e = new Uint8Array(i);
213
- return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
211
+ function m(n = 5) {
212
+ const e = new Uint8Array(n);
213
+ return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, n);
214
214
  }
215
- function ne(i) {
216
- return i.replace(
215
+ function le(n) {
216
+ return n.replace(
217
217
  /([-_][a-z])/g,
218
218
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
219
219
  );
220
220
  }
221
- function H(i) {
222
- return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(H) : Object.keys(i).reduce((e, t) => {
223
- const s = ne(t);
224
- return e[s] = H(i[t]), e;
221
+ function I(n) {
222
+ return typeof n != "object" || n === null ? n : Array.isArray(n) ? n.map(I) : Object.keys(n).reduce((e, t) => {
223
+ const i = le(t);
224
+ return e[i] = I(n[t]), e;
225
225
  }, {});
226
226
  }
227
- function $(i) {
228
- switch (typeof i.className) {
227
+ function A(n) {
228
+ switch (typeof n.className) {
229
229
  case "string":
230
- return i.className;
230
+ return n.className;
231
231
  case "object":
232
- return ("baseVal" in i.className ? i.className.baseVal : null) || i.getAttribute("class") || "";
232
+ return ("baseVal" in n.className ? n.className.baseVal : null) || n.getAttribute("class") || "";
233
233
  default:
234
234
  return "";
235
235
  }
236
236
  }
237
- function L(i) {
237
+ function D(n) {
238
238
  let e = "";
239
- return O(i) && !M(i) && i.childNodes && i.childNodes.length && f(i.childNodes, function(t) {
240
- q(t) && t.textContent && (e += x(t.textContent).split(/(\s+)/).filter(P).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
- }), x(e);
239
+ return L(n) && !W(n) && n.childNodes && n.childNodes.length && g(n.childNodes, function(t) {
240
+ Q(t) && t.textContent && (e += R(t.textContent).split(/(\s+)/).filter(E).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
241
+ }), R(e);
242
242
  }
243
- function B(i) {
244
- return !!i && i.nodeType === 1;
243
+ function J(n) {
244
+ return !!n && n.nodeType === 1;
245
245
  }
246
- function g(i, e) {
247
- return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
246
+ function f(n, e) {
247
+ return !!n && !!n.tagName && n.tagName.toLowerCase() === e.toLowerCase();
248
248
  }
249
- function q(i) {
250
- return !!i && i.nodeType === 3;
249
+ function Q(n) {
250
+ return !!n && n.nodeType === 3;
251
251
  }
252
- function N(i) {
253
- return !!i && i.nodeType === 11;
252
+ function O(n) {
253
+ return !!n && n.nodeType === 11;
254
254
  }
255
255
  const b = ["a", "button", "form", "input", "select", "textarea", "label"];
256
- function re(i, e) {
257
- if (!i || g(i, "html") || !B(i))
256
+ function ue(n, e) {
257
+ if (!n || f(n, "html") || !J(n))
258
258
  return !1;
259
- let t = i;
260
- for (; t && !g(t, "body"); ) {
259
+ let t = n;
260
+ for (; t && !f(t, "body"); ) {
261
261
  if (t.classList && t.classList.contains("um-no-capture"))
262
262
  return !1;
263
- t.parentNode && N(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
263
+ t.parentNode && O(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
264
264
  }
265
- let s = !1;
266
- for (t = i; t && !g(t, "body"); ) {
267
- if (t.parentNode && N(t.parentNode)) {
268
- t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
265
+ let i = !1;
266
+ for (t = n; t && !f(t, "body"); ) {
267
+ if (t.parentNode && O(t.parentNode)) {
268
+ t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (i = !0);
269
269
  continue;
270
270
  }
271
271
  const o = t.parentNode;
272
272
  if (!o) break;
273
273
  if (b.indexOf(o.tagName.toLowerCase()) > -1)
274
- s = !0;
274
+ i = !0;
275
275
  else {
276
276
  const c = window.getComputedStyle(o);
277
- c && c.getPropertyValue("cursor") === "pointer" && (s = !0);
277
+ c && c.getPropertyValue("cursor") === "pointer" && (i = !0);
278
278
  }
279
279
  t = o;
280
280
  }
281
- const n = window.getComputedStyle(i);
282
- if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
281
+ const s = window.getComputedStyle(n);
282
+ if (s && s.getPropertyValue("cursor") === "pointer" && e.type === "click")
283
283
  return !0;
284
- const r = i.tagName.toLowerCase();
284
+ const r = n.tagName.toLowerCase();
285
285
  switch (r) {
286
286
  case "html":
287
287
  return !1;
@@ -293,18 +293,18 @@ function re(i, e) {
293
293
  case "textarea":
294
294
  return e.type === "change" || e.type === "click";
295
295
  default:
296
- return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
296
+ return i ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || n.getAttribute("contenteditable") === "true");
297
297
  }
298
298
  }
299
- function O(i) {
300
- for (let s = i; s.parentNode && !g(s, "body"); s = s.parentNode) {
301
- const n = $(s).split(" ");
302
- if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
299
+ function L(n) {
300
+ for (let i = n; i.parentNode && !f(i, "body"); i = i.parentNode) {
301
+ const s = A(i).split(" ");
302
+ if (_(s, "ph-sensitive") || _(s, "ph-no-capture"))
303
303
  return !1;
304
304
  }
305
- if (_($(i).split(" "), "ph-include"))
305
+ if (_(A(n).split(" "), "ph-include"))
306
306
  return !0;
307
- const e = i.type || "";
307
+ const e = n.type || "";
308
308
  if (typeof e == "string")
309
309
  switch (e.toLowerCase()) {
310
310
  case "hidden":
@@ -312,57 +312,61 @@ function O(i) {
312
312
  case "password":
313
313
  return !1;
314
314
  }
315
- const t = i.name || i.id || "";
315
+ const t = n.name || n.id || "";
316
316
  return !(typeof t == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
317
317
  }
318
- function M(i) {
318
+ function W(n) {
319
319
  const e = ["button", "checkbox", "submit", "reset"];
320
- return !!(g(i, "input") && !e.includes(i.type) || g(i, "select") || g(i, "textarea") || i.getAttribute("contenteditable") === "true");
320
+ return !!(f(n, "input") && !e.includes(n.type) || f(n, "select") || f(n, "textarea") || n.getAttribute("contenteditable") === "true");
321
321
  }
322
- function P(i) {
323
- return !(i === null || ie(i) || typeof i == "string" && (i = x(i), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((i || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(i)));
322
+ function E(n) {
323
+ return !(n === null || ae(n) || typeof n == "string" && (n = R(n), /^(?:(4[0-9]{12}(?:[0-9]{3})?)|(5[1-5][0-9]{14})|(6(?:011|5[0-9]{2})[0-9]{12})|(3[47][0-9]{13})|(3(?:0[0-5]|[68][0-9])[0-9]{11})|((?:2131|1800|35[0-9]{3})[0-9]{11}))$/.test((n || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(n)));
324
324
  }
325
- function oe(i) {
326
- return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
325
+ function he(n) {
326
+ return typeof n == "string" ? n.substring(0, 10) === "_ngcontent" || n.substring(0, 7) === "_nghost" : !1;
327
327
  }
328
- function T() {
329
- return p(10);
328
+ function x() {
329
+ return m(10);
330
330
  }
331
- function ae(i) {
332
- return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(i).toLowerCase());
331
+ function de(n) {
332
+ return /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(n).toLowerCase());
333
333
  }
334
- function ce(i, e) {
334
+ function fe(n, e) {
335
335
  let t;
336
- return function(...s) {
337
- const n = () => {
338
- clearTimeout(t), i(...s);
336
+ return function(...i) {
337
+ const s = () => {
338
+ clearTimeout(t), n(...i);
339
339
  };
340
- clearTimeout(t), t = setTimeout(n, e);
340
+ clearTimeout(t), t = setTimeout(s, e);
341
341
  };
342
342
  }
343
- function le(i) {
344
- const e = {}, t = i.replace(/^\?/, "").split("&");
345
- for (let s = 0; s < t.length; s++) {
346
- const n = t[s].split("=");
347
- n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
343
+ function ge(n) {
344
+ const e = {}, t = n.replace(/^\?/, "").split("&");
345
+ for (let i = 0; i < t.length; i++) {
346
+ const s = t[i].split("=");
347
+ s[0] !== "" && (e[decodeURIComponent(s[0])] = decodeURIComponent(s[1] || ""));
348
348
  }
349
349
  return e;
350
350
  }
351
- function I(i) {
352
- return typeof i == "string" || i instanceof String;
351
+ function F(n) {
352
+ return typeof n == "string" || n instanceof String;
353
353
  }
354
- function k(i) {
355
- return i !== null && typeof i == "object" && i.constructor === Object;
354
+ function v(n) {
355
+ return n !== null && typeof n == "object" && n.constructor === Object;
356
356
  }
357
- function ue(i) {
358
- if (i === null)
359
- return v.ERROR;
360
- const e = i.toUpperCase(), t = v[e];
361
- return t || t === 0 ? t : v.ERROR;
357
+ function pe(n) {
358
+ if (n === null)
359
+ return p.ERROR;
360
+ const e = n.toUpperCase(), t = p[e];
361
+ return t || t === 0 ? t : p.ERROR;
362
362
  }
363
- class he {
363
+ const me = () => {
364
+ let n = "false";
365
+ return typeof window < "u" && window.localStorage && (n = localStorage.getItem("um_exclusion")), !(n == null || n === "false");
366
+ };
367
+ class ye {
364
368
  constructor(e) {
365
- this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = ce(this.handleScroll.bind(this), 250), this.initializeEventListener();
369
+ this.maxScrollDepth = 0, this.milestones = [25, 50, 75, 90], this.lastScrollDepth = 0, this.client = e, this.documentElement = document.documentElement, this.debouncedHandleScroll = fe(this.handleScroll.bind(this), 250), this.initializeEventListener();
366
370
  }
367
371
  initializeEventListener() {
368
372
  window.addEventListener("scroll", this.debouncedHandleScroll);
@@ -386,8 +390,8 @@ class he {
386
390
  this.track();
387
391
  }
388
392
  getScrollDepth() {
389
- const e = this.getWindowHeight(), t = this.getDocumentHeight(), s = this.getScrollDistance(), n = t - e;
390
- return Math.min(100, Math.floor(s / n * 100));
393
+ const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), s = t - e;
394
+ return Math.min(100, Math.floor(i / s * 100));
391
395
  }
392
396
  getWindowHeight() {
393
397
  return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
@@ -406,27 +410,38 @@ class he {
406
410
  return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
407
411
  }
408
412
  checkMilestones(e) {
409
- this.milestones.filter((s) => e >= s).forEach((s) => {
410
- this.send(), this.milestones = this.milestones.filter((n) => n !== s);
413
+ this.milestones.filter((i) => e >= i).forEach((i) => {
414
+ this.send(), this.milestones = this.milestones.filter((s) => s !== i);
411
415
  });
412
416
  }
413
417
  }
414
- const C = class C {
415
- constructor(e, t, s = d()) {
416
- this.logger = s, this.scrollDepth = null, this.customProperties = [], this.client = e, this.options = t, this.scrollDepth = new he(e), j(this), z(this);
418
+ const T = class T {
419
+ constructor(e, t, i = d()) {
420
+ this.logger = i, this.scrollDepth = null, this.customProperties = [], this.domHandlersAttached = !1, this.client = e, this.options = t, this.scrollDepth = new ye(e), se(this), V(this);
421
+ }
422
+ isBrowserSupported() {
423
+ return typeof document < "u" && typeof document.addEventListener == "function";
417
424
  }
418
425
  init() {
426
+ if (!this.isBrowserSupported()) {
427
+ this.logger.debug("Browser not supported for autocapture");
428
+ return;
429
+ }
430
+ if (this.domHandlersAttached) {
431
+ this.logger.debug("Autocapture already initialized.");
432
+ return;
433
+ }
419
434
  if (!(document && document.body)) {
420
435
  this.logger.debug("Document not ready yet, trying again in 500 milliseconds..."), setTimeout(() => this.init(), 500);
421
436
  return;
422
437
  }
423
- this.addDomEventHandlers();
438
+ this.addDomEventHandlers(), this.domHandlersAttached = !0;
424
439
  }
425
440
  addDomEventHandlers() {
426
441
  const e = (t) => {
427
442
  t = t || window.event, this.captureEvent(t);
428
443
  };
429
- m(document, "submit", e, !1, !0), m(document, "change", e, !1, !0), m(document, "click", e, !1, !0), m(document, "visibilitychange", e, !1, !0), m(document, "scroll", e, !1, !0), m(window, "popstate", e, !1, !0);
444
+ y(document, "submit", e, !1, !0), y(document, "change", e, !1, !0), y(document, "click", e, !1, !0), y(document, "visibilitychange", e, !1, !0), y(document, "scroll", e, !1, !0), y(window, "popstate", e, !1, !0);
430
445
  }
431
446
  isPageRefresh() {
432
447
  if ("PerformanceNavigationTiming" in window) {
@@ -437,17 +452,17 @@ const C = class C {
437
452
  return performance.navigation && performance.navigation.type === 1;
438
453
  }
439
454
  captureEvent(e) {
440
- var s, n;
455
+ var i, s;
441
456
  let t = this.getEventTarget(e);
442
- if (q(t) && (t = t.parentNode || null), e.type === "scroll")
443
- return (s = this.scrollDepth) == null || s.track(), !0;
457
+ if (Q(t) && (t = t.parentNode || null), e.type === "scroll")
458
+ return (i = this.scrollDepth) == null || i.track(), !0;
444
459
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
445
- return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
446
- if (t && re(t, e)) {
460
+ return this.isPageRefresh() || (s = this.scrollDepth) == null || s.send(), !0;
461
+ if (t && ue(t, e)) {
447
462
  const r = [t];
448
463
  let o = t;
449
- for (; o.parentNode && !g(o, "body"); ) {
450
- if (N(o.parentNode)) {
464
+ for (; o.parentNode && !f(o, "body"); ) {
465
+ if (O(o.parentNode)) {
451
466
  r.push(o.parentNode.host), o = o.parentNode.host;
452
467
  continue;
453
468
  }
@@ -455,20 +470,20 @@ const C = class C {
455
470
  }
456
471
  const c = [];
457
472
  let l, a = !1;
458
- if (f(r, (w) => {
459
- const J = O(w);
460
- w.tagName.toLowerCase() === "a" && (l = w.getAttribute("href"), l = J && P(l) && l);
461
- const Q = $(w).split(" ");
462
- _(Q, "ph-no-capture") && (a = !0), c.push(
473
+ if (g(r, (k) => {
474
+ const Z = L(k);
475
+ k.tagName.toLowerCase() === "a" && (l = k.getAttribute("href"), l = Z && E(l) && l);
476
+ const Y = A(k).split(" ");
477
+ _(Y, "ph-no-capture") && (a = !0), c.push(
463
478
  this.getPropertiesFromElement(
464
- w,
479
+ k,
465
480
  this.options.maskAllElementAttributes ?? !1,
466
481
  this.options.maskAllText ?? !1
467
482
  )
468
483
  );
469
- }), this.options.maskAllText || (c[0].$el_text = L(t)), l && (c[0].attr__href = l), a)
484
+ }), this.options.maskAllText || (c[0].$el_text = D(t)), l && (c[0].attr__href = l), a)
470
485
  return !1;
471
- const h = ee(
486
+ const h = re(
472
487
  this.getDefaultProperties(e.type),
473
488
  {
474
489
  $elements: c
@@ -480,36 +495,36 @@ const C = class C {
480
495
  }
481
496
  getCustomProperties(e) {
482
497
  const t = {};
483
- return f(this.customProperties, (s) => {
484
- f(s.event_selectors, (n) => {
485
- const r = document.querySelectorAll(n);
486
- f(r, (o) => {
487
- _(e, o) && O(o) && (t[s.name] = this.extractCustomPropertyValue(s));
498
+ return g(this.customProperties, (i) => {
499
+ g(i.event_selectors, (s) => {
500
+ const r = document.querySelectorAll(s);
501
+ g(r, (o) => {
502
+ _(e, o) && L(o) && (t[i.name] = this.extractCustomPropertyValue(i));
488
503
  });
489
504
  });
490
505
  }), t;
491
506
  }
492
507
  extractCustomPropertyValue(e) {
493
508
  const t = [];
494
- return f(document.querySelectorAll(e.css_selector), function(s) {
495
- let n;
496
- ["input", "select"].indexOf(s.tagName.toLowerCase()) > -1 ? n = s.value : s.textContent && (n = s.textContent), P(n) && t.push(n);
509
+ return g(document.querySelectorAll(e.css_selector), function(i) {
510
+ let s;
511
+ ["input", "select"].indexOf(i.tagName.toLowerCase()) > -1 ? s = i.value : i.textContent && (s = i.textContent), E(s) && t.push(s);
497
512
  }), t.join(", ");
498
513
  }
499
514
  getEventTarget(e) {
500
515
  var t;
501
516
  return typeof e.target > "u" ? e.srcElement || null : (t = e.target) != null && t.shadowRoot ? e.composedPath()[0] || null : e.target || null;
502
517
  }
503
- getPropertiesFromElement(e, t, s) {
504
- const n = e.tagName.toLowerCase(), r = {
505
- tag_name: n
518
+ getPropertiesFromElement(e, t, i) {
519
+ const s = e.tagName.toLowerCase(), r = {
520
+ tag_name: s
506
521
  };
507
- b.indexOf(n) > -1 && !s && (r.$el_text = L(e));
508
- const o = $(e);
522
+ b.indexOf(s) > -1 && !i && (r.$el_text = D(e));
523
+ const o = A(e);
509
524
  o.length > 0 && (r.classes = o.split(" ").filter(function(h) {
510
525
  return h !== "";
511
- })), f(e.attributes, function(h) {
512
- M(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && P(h.value) && !oe(h.name) && (r["attr__" + h.name] = h.value);
526
+ })), g(e.attributes, function(h) {
527
+ W(e) && ["name", "id", "class"].indexOf(h.name) === -1 || !t && E(h.value) && !he(h.name) && (r["attr__" + h.name] = h.value);
513
528
  });
514
529
  let c = 1, l = 1, a = e;
515
530
  for (; a = this.previousElementSibling(a); )
@@ -523,7 +538,7 @@ const C = class C {
523
538
  let t = e;
524
539
  do
525
540
  t = t.previousSibling;
526
- while (t && !B(t));
541
+ while (t && !J(t));
527
542
  return t;
528
543
  }
529
544
  }
@@ -536,18 +551,18 @@ const C = class C {
536
551
  encodeHtml(e) {
537
552
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
538
553
  }
539
- static enabledForProject(e, t = 10, s = 10) {
554
+ static enabledForProject(e, t = 10, i = 10) {
540
555
  if (!e)
541
556
  return !1;
542
- let n = 0;
557
+ let s = 0;
543
558
  for (let r = 0; r < e.length; r++)
544
- n += e.charCodeAt(r);
545
- return n % t < s;
559
+ s += e.charCodeAt(r);
560
+ return s % t < i;
546
561
  }
547
562
  };
548
- C.FORCE_CAPTURE_ATTR = "data-um-force-capture", C.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
549
- let S = C;
550
- class de {
563
+ T.FORCE_CAPTURE_ATTR = "data-um-force-capture", T.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
564
+ let $ = T;
565
+ class we {
551
566
  constructor(e) {
552
567
  this.client = e, this.lastPageUrl = window.location.href, this.trackInitialPageview(), this.initializePageviewTracking();
553
568
  }
@@ -576,44 +591,44 @@ class de {
576
591
  }));
577
592
  }
578
593
  }
579
- class ge {
580
- constructor(e, t, s = d()) {
581
- this.trackingHost = e, this.logger = s, this.config = t;
594
+ class ke {
595
+ constructor(e, t, i = d()) {
596
+ this.trackingHost = e, this.logger = i, this.config = t;
582
597
  }
583
598
  async send(e) {
584
- const t = this.config.key, s = this.constructUrl(t), n = new Blob([JSON.stringify(e)], { type: "application/json" });
585
- if (navigator.sendBeacon(s, n))
599
+ const t = this.config.key, i = this.constructUrl(t), s = new Blob([JSON.stringify(e)], { type: "application/json" });
600
+ if (navigator.sendBeacon(i, s))
586
601
  this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
587
602
  else
588
603
  throw new Error("Failed to queue events via Beacon API");
589
604
  }
590
605
  constructUrl(e) {
591
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
592
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
606
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
607
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
593
608
  }
594
609
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
595
610
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
596
611
  }
597
- class D {
598
- constructor(e, t, s = d()) {
599
- this.trackingHost = e, this.logger = s, this.config = t;
612
+ class z {
613
+ constructor(e, t, i = d()) {
614
+ this.trackingHost = e, this.logger = i, this.config = t;
600
615
  }
601
616
  async send(e) {
602
- const t = this.config.key, s = this.constructUrl(t), n = JSON.stringify(e), r = {
617
+ const t = this.config.key, i = this.constructUrl(t), s = JSON.stringify(e), r = {
603
618
  "Content-Type": "application/json",
604
619
  ...this.getCustomHeaders()
605
- }, o = await fetch(s, {
620
+ }, o = await fetch(i, {
606
621
  method: "POST",
607
622
  headers: r,
608
- body: n
623
+ body: s
609
624
  });
610
625
  if (!o.ok)
611
626
  throw new Error(`HTTP error! status: ${o.status}`);
612
627
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
613
628
  }
614
629
  constructUrl(e) {
615
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
616
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
630
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
631
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
617
632
  }
618
633
  getCustomHeaders() {
619
634
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -622,27 +637,27 @@ class D {
622
637
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
623
638
  }
624
639
  }
625
- class fe {
626
- constructor(e, t, s = d()) {
627
- this.trackingHost = e, this.logger = s, this.config = t;
640
+ class ve {
641
+ constructor(e, t, i = d()) {
642
+ this.trackingHost = e, this.logger = i, this.config = t;
628
643
  }
629
644
  send(e) {
630
- return new Promise((t, s) => {
631
- const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
632
- n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
645
+ return new Promise((t, i) => {
646
+ const s = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
647
+ s.open("POST", o, !0), s.setRequestHeader("Content-Type", "application/json");
633
648
  const c = this.getCustomHeaders();
634
649
  Object.keys(c).forEach((l) => {
635
- n.setRequestHeader(l, c[l]);
636
- }), n.onload = () => {
637
- n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : s(new Error(`HTTP error! status: ${n.status}`));
638
- }, n.onerror = () => {
639
- s(new Error("Network error"));
640
- }, n.send(JSON.stringify(e));
650
+ s.setRequestHeader(l, c[l]);
651
+ }), s.onload = () => {
652
+ s.status >= 200 && s.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${s.status}`));
653
+ }, s.onerror = () => {
654
+ i(new Error("Network error"));
655
+ }, s.send(JSON.stringify(e));
641
656
  });
642
657
  }
643
658
  constructUrl(e) {
644
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
645
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${p()}?p_${p()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
659
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", s = u() ? "/api/v1/event" : "/api/v1/s2s/event";
660
+ return this.config.randomizeUrl ? `${this.trackingHost}/api.${m()}?p_${m()}=${e}${t}${i}` : `${this.trackingHost}${s}?token=${e}${t}${i}`;
646
661
  }
647
662
  getCustomHeaders() {
648
663
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -651,7 +666,7 @@ class fe {
651
666
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
652
667
  }
653
668
  }
654
- class V {
669
+ class K {
655
670
  constructor(e, t) {
656
671
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || d();
657
672
  }
@@ -691,7 +706,7 @@ class V {
691
706
  }
692
707
  }
693
708
  }
694
- class pe {
709
+ class _e {
695
710
  constructor() {
696
711
  this.storage = {};
697
712
  }
@@ -710,10 +725,10 @@ class pe {
710
725
  this.storage = {};
711
726
  }
712
727
  }
713
- class F {
728
+ class B {
714
729
  // Default to true for server-side
715
- constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = d(), c = "default") {
716
- this.transport = e, this.maxRetries = t, this.retryInterval = s, this.batchSize = n, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new V(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
730
+ constructor(e, t = 3, i = 1e3, s = 10, r = 1e3, o = d(), c = "default") {
731
+ this.transport = e, this.maxRetries = t, this.retryInterval = i, this.batchSize = s, this.batchInterval = r, this.logger = o, this.queue = [], this.processing = !1, this.batchTimeoutId = null, this.isOnline = !0, this.persistence = new K(`offline_queue_${c}`), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
717
732
  }
718
733
  add(e) {
719
734
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -732,11 +747,11 @@ class F {
732
747
  async processBatch() {
733
748
  if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
734
749
  this.processing = !0;
735
- const e = this.queue.splice(0, this.batchSize), t = e.map((s) => s.payload);
750
+ const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
736
751
  try {
737
752
  await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
738
- } catch (s) {
739
- this.logger.error("Failed to send batch", s), await this.handleBatchFailure(e);
753
+ } catch (i) {
754
+ this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
740
755
  }
741
756
  this.processing = !1;
742
757
  }
@@ -757,9 +772,9 @@ class F {
757
772
  u() && this.persistence.set("queue", JSON.stringify(this.queue));
758
773
  }
759
774
  }
760
- class me {
775
+ class be {
761
776
  constructor(e) {
762
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
777
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), V(this);
763
778
  }
764
779
  initializeEventListener() {
765
780
  document.addEventListener("click", this.handleClick.bind(this));
@@ -771,17 +786,17 @@ class me {
771
786
  shouldCaptureElement(e) {
772
787
  return !e.closest(".um-no-capture");
773
788
  }
774
- click(e, t, s) {
775
- const n = { x: e, y: t, timestamp: s };
776
- this.clicks.push(n), this.clicks = this.clicks.filter((r) => s - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
789
+ click(e, t, i) {
790
+ const s = { x: e, y: t, timestamp: i };
791
+ this.clicks.push(s), this.clicks = this.clicks.filter((r) => i - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
777
792
  }
778
793
  checkRageClick() {
779
- const e = this.clicks[0], s = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
794
+ const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
780
795
  this.clicks.every((r, o) => {
781
796
  if (o === 0) return !0;
782
797
  const c = this.clicks[o - 1];
783
798
  return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
784
- }) && this.sendRageClickEvent(s);
799
+ }) && this.sendRageClickEvent(i);
785
800
  }
786
801
  sendRageClickEvent(e) {
787
802
  const t = this.clicks[this.clicks.length - 1];
@@ -791,15 +806,15 @@ class me {
791
806
  }), this.clicks = [];
792
807
  }
793
808
  }
794
- class ye {
795
- constructor(e, t, s = d()) {
796
- this.trackingHost = e, this.logger = s, this.config = t;
809
+ class Ee {
810
+ constructor(e, t, i = d()) {
811
+ this.trackingHost = e, this.logger = i, this.config = t;
797
812
  }
798
813
  async send(e) {
799
- const t = this.config.key, s = new (void 0)(this.constructUrl(t)), n = {
800
- hostname: s.hostname,
814
+ const t = this.config.key, i = new (void 0)(this.constructUrl(t)), s = {
815
+ hostname: i.hostname,
801
816
  port: 443,
802
- path: `${s.pathname}${s.search}`,
817
+ path: `${i.pathname}${i.search}`,
803
818
  method: "POST",
804
819
  headers: {
805
820
  "Content-Type": "application/json",
@@ -807,7 +822,7 @@ class ye {
807
822
  }
808
823
  };
809
824
  return new Promise((r, o) => {
810
- const c = (void 0)(n, (l) => {
825
+ const c = (void 0)(s, (l) => {
811
826
  l.on("data", (a) => {
812
827
  }), l.on("end", () => {
813
828
  const a = l.statusCode || 0;
@@ -820,16 +835,16 @@ class ye {
820
835
  });
821
836
  }
822
837
  constructUrl(e) {
823
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", s = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
824
- return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${s}`;
838
+ const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
839
+ return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${i}`;
825
840
  }
826
841
  getCustomHeaders() {
827
842
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
828
843
  }
829
844
  }
830
- class y {
831
- constructor(e, t = "all", s = {}) {
832
- this.instance = e, this.trackingType = t, this.options = s, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
845
+ class w {
846
+ constructor(e, t = "all", i = {}) {
847
+ this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
833
848
  }
834
849
  initialize() {
835
850
  this.trackingType !== "none" && this.setupFormTracking();
@@ -841,19 +856,19 @@ class y {
841
856
  });
842
857
  }
843
858
  handleFormSubmit(e) {
844
- const t = e.target, s = this._getFormDetails(t);
845
- this.instance.track("$form", R(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
859
+ const t = e.target, i = this._getFormDetails(t);
860
+ this.instance.track("$form", U(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
846
861
  }
847
862
  trackFieldChanges(e) {
848
- e.querySelectorAll("input, select, textarea").forEach((s) => {
849
- s.addEventListener("change", (n) => {
850
- const r = this._getFieldProps(n.target, 0);
851
- this.instance.track("$form_field_change", R(r));
863
+ e.querySelectorAll("input, select, textarea").forEach((i) => {
864
+ i.addEventListener("change", (s) => {
865
+ const r = this._getFieldProps(s.target, 0);
866
+ this.instance.track("$form_field_change", U(r));
852
867
  });
853
868
  });
854
869
  }
855
- static getInstance(e, t = "all", s = {}) {
856
- return y.instance || (y.instance = new y(e, t, s)), y.instance;
870
+ static getInstance(e, t = "all", i = {}) {
871
+ return w.instance || (w.instance = new w(e, t, i)), w.instance;
857
872
  }
858
873
  _getFormDetails(e) {
859
874
  const t = {
@@ -863,20 +878,20 @@ class y {
863
878
  form_method: e.method,
864
879
  form_class: e.className,
865
880
  form_attributes: this._getElementAttributes(e)
866
- }, s = e.querySelectorAll("input, select, textarea");
867
- return Array.from(s).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
881
+ }, i = e.querySelectorAll("input, select, textarea");
882
+ return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
868
883
  const c = this._getFieldProps(r, o);
869
884
  Object.assign(t, c);
870
885
  }), t;
871
886
  }
872
887
  _getFieldProps(e, t) {
873
- const s = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, n = this.getSafeText(e);
888
+ const i = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, s = this.getSafeText(e);
874
889
  return {
875
890
  [`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
876
891
  [`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
877
- [`field_${t + 1}_data_attributes`]: s,
892
+ [`field_${t + 1}_data_attributes`]: i,
878
893
  [`field_${t + 1}_id`]: e.id,
879
- [`field_${t + 1}_value`]: n,
894
+ [`field_${t + 1}_value`]: s,
880
895
  [`field_${t + 1}_class`]: e.className,
881
896
  [`field_${t + 1}_name`]: e.name,
882
897
  [`field_${t + 1}_attributes`]: this._getElementAttributes(e)
@@ -888,8 +903,8 @@ class y {
888
903
  getSafeText(e) {
889
904
  let t = "";
890
905
  return "value" in e && e.type !== "password" ? t = e.value : e.hasChildNodes() ? t = Array.from(e.childNodes).filter(
891
- (n) => n.nodeType === Node.TEXT_NODE
892
- ).map((n) => n.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
906
+ (s) => s.nodeType === Node.TEXT_NODE
907
+ ).map((s) => s.textContent).join("") : t = e.textContent || "", this._scrubPotentiallySensitiveValues(t);
893
908
  }
894
909
  _scrubPotentiallySensitiveValues(e) {
895
910
  return this._shouldCaptureValue(e) ? e : "<redacted>";
@@ -906,8 +921,8 @@ class y {
906
921
  _trim(e) {
907
922
  if (typeof String.prototype.trim == "function")
908
923
  return e.trim();
909
- let t = 0, s = e.length - 1;
910
- const n = [
924
+ let t = 0, i = e.length - 1;
925
+ const s = [
911
926
  " ",
912
927
  `
913
928
  `,
@@ -934,16 +949,16 @@ class y {
934
949
  " ",
935
950
  " "
936
951
  ].join("");
937
- for (; t <= s && n.indexOf(e[t]) > -1; )
952
+ for (; t <= i && s.indexOf(e[t]) > -1; )
938
953
  t++;
939
- for (; s >= t && n.indexOf(e[s]) > -1; )
940
- s--;
941
- return e.slice(t, s + 1);
954
+ for (; i >= t && s.indexOf(e[i]) > -1; )
955
+ i--;
956
+ return e.slice(t, i + 1);
942
957
  }
943
958
  }
944
- class we {
959
+ class S {
945
960
  constructor(e) {
946
- this.config = this.mergeConfig(e, U), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new F(
961
+ this.config = this.mergeConfig(e, q), this.logger = d(this.config.logLevel), this.namespace = e.namespace || "default", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new B(
947
962
  this.transport,
948
963
  this.config.maxSendAttempts || 3,
949
964
  this.config.minSendTimeout || 1e3,
@@ -955,13 +970,13 @@ class we {
955
970
  ), u() && this.initializeBrowserFeatures(), this.anonymousId = this.getOrCreateAnonymousId(), this.logger.info(`Usermaven client initialized for namespace: ${this.namespace}`);
956
971
  }
957
972
  initializeBrowserFeatures() {
958
- if (this.cookieManager = new X(this.config.cookieDomain), this.config.autocapture && S.enabledForProject(this.config.key) && (this.autoCapture = new S(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
973
+ if (this.cookieManager = new j(this.config.cookieDomain), this.config.autocapture && $.enabledForProject(this.config.key) && !this.config.disableAutocaptureListenerRegistration && (this.autoCapture = new $(this, this.config, this.logger), this.autoCapture.init()), this.config.formTracking) {
959
974
  const e = this.config.formTracking === !0 ? "all" : this.config.formTracking;
960
- this.formTracking = y.getInstance(this, e || "none", {
975
+ this.formTracking = w.getInstance(this, e || "none", {
961
976
  trackFieldChanges: !1
962
977
  });
963
978
  }
964
- this.config.autoPageview && (this.pageviewTracking = new de(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new me(this)), this.setupPageLeaveTracking();
979
+ this.config.autoPageview && (this.pageviewTracking = new we(this)), this.config.crossDomainLinking && this.manageCrossDomainLinking(), this.config.rageClick && (this.rageClick = new be(this)), this.setupPageLeaveTracking();
965
980
  }
966
981
  /**
967
982
  * Recursively merge the provided configuration with the existing defaultConfig
@@ -969,14 +984,14 @@ class we {
969
984
  * @param defaultConfig
970
985
  */
971
986
  mergeConfig(e, t) {
972
- const s = JSON.parse(JSON.stringify(e));
973
- let n = { ...t, ...s };
987
+ const i = JSON.parse(JSON.stringify(e));
988
+ let s = { ...t, ...i };
974
989
  return Object.keys(t).forEach((r) => {
975
- k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
976
- }), n;
990
+ v(t[r]) && (s[r] = this.mergeConfig(e[r], t[r]));
991
+ }), s;
977
992
  }
978
993
  init(e) {
979
- this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new F(
994
+ this.config = { ...this.config, ...e }, this.logger = d(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new B(
980
995
  this.transport,
981
996
  this.config.maxSendAttempts || 3,
982
997
  this.config.minSendTimeout || 1e3,
@@ -990,17 +1005,17 @@ class we {
990
1005
  manageCrossDomainLinking() {
991
1006
  if (!this.config.crossDomainLinking || !this.config.domains)
992
1007
  return;
993
- const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
994
- document.addEventListener("click", (s) => {
1008
+ const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `__eventn_id_${this.config.key}`;
1009
+ document.addEventListener("click", (i) => {
995
1010
  var c;
996
- const n = this.findClosestLink(s.target);
997
- if (!n) return;
998
- const r = n.getAttribute("href");
1011
+ const s = this.findClosestLink(i.target);
1012
+ if (!s) return;
1013
+ const r = s.getAttribute("href");
999
1014
  if (!r || !r.startsWith("http")) return;
1000
1015
  const o = new URL(r);
1001
1016
  if (o.hostname !== window.location.hostname && e.includes(o.hostname)) {
1002
1017
  const l = (c = this.cookieManager) == null ? void 0 : c.get(t);
1003
- l && (o.searchParams.append("_um", l), n.setAttribute("href", o.toString()));
1018
+ l && (o.searchParams.append("_um", l), s.setAttribute("href", o.toString()));
1004
1019
  }
1005
1020
  }), this.logger.debug("Cross-domain linking initialized");
1006
1021
  }
@@ -1012,99 +1027,103 @@ class we {
1012
1027
  initializeTransport(e) {
1013
1028
  const t = "https://events.usermaven.com";
1014
1029
  if (!u())
1015
- return new ye(e.trackingHost || t, e);
1016
- const s = "XMLHttpRequest" in window, n = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1030
+ return new Ee(e.trackingHost || t, e);
1031
+ const i = "XMLHttpRequest" in window, s = typeof fetch < "u", r = typeof navigator < "u" && "sendBeacon" in navigator;
1017
1032
  if (e.useBeaconApi && r)
1018
- return new ge(e.trackingHost || t, e, this.logger);
1019
- if (e.forceUseFetch && n)
1020
- return new D(e.trackingHost || t, e, this.logger);
1033
+ return new ke(e.trackingHost || t, e, this.logger);
1034
+ if (e.forceUseFetch && s)
1035
+ return new z(e.trackingHost || t, e, this.logger);
1036
+ if (i)
1037
+ return new ve(e.trackingHost || t, e, this.logger);
1021
1038
  if (s)
1022
- return new fe(e.trackingHost || t, e, this.logger);
1023
- if (n)
1024
- return new D(e.trackingHost || t, e, this.logger);
1039
+ return new z(e.trackingHost || t, e, this.logger);
1025
1040
  throw new Error("No suitable transport method available");
1026
1041
  }
1027
1042
  initializePersistence() {
1028
- return this.config.disableEventPersistence || !u() ? new pe() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1043
+ return this.config.disableEventPersistence || !u() ? new _e() : new K(`${this.namespace}_${this.config.key}`, this.logger);
1029
1044
  }
1030
1045
  getOrCreateAnonymousId() {
1031
- var s, n;
1046
+ var i, s;
1032
1047
  if (!u())
1033
- return T();
1048
+ return x();
1034
1049
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1035
1050
  return "";
1036
1051
  const e = this.config.cookieName || `__eventn_id_${this.config.key}`;
1037
- let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
1052
+ let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1038
1053
  if (!t) {
1039
1054
  if (this.config.crossDomainLinking) {
1040
1055
  const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), h = a.length > 1 ? a[1] : void 0;
1041
- t = c || h || T();
1056
+ t = c || h || x();
1042
1057
  }
1043
- t || (t = T());
1058
+ t || (t = x());
1044
1059
  const r = 365 * 10;
1045
- (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1060
+ (s = this.cookieManager) == null || s.set(e, t, r, document.location.protocol !== "http:", !1);
1046
1061
  }
1047
1062
  return t;
1048
1063
  }
1049
1064
  async id(e, t = !1) {
1050
- if (!k(e))
1065
+ if (!v(e))
1051
1066
  throw new Error("User data must be an object");
1052
- if (e.email && !ae(e.email))
1067
+ if (e.email && !de(e.email))
1053
1068
  throw new Error("Invalid email provided");
1054
- if (!e.id || !I(e.id))
1069
+ if (!e.id || !F(e.id))
1055
1070
  throw new Error("User ID must be a string");
1056
- const s = e.id;
1057
- if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
1058
- const n = {
1071
+ const i = e.id;
1072
+ if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
1073
+ const s = {
1059
1074
  ...e,
1060
1075
  anonymous_id: this.anonymousId
1061
1076
  };
1062
- await this.track("user_identify", n);
1077
+ await this.track("user_identify", s);
1063
1078
  }
1064
1079
  this.logger.info("User identified:", e);
1065
1080
  }
1066
- track(e, t, s = !1) {
1067
- this.trackInternal(e, t, s);
1081
+ track(e, t, i = !1) {
1082
+ this.trackInternal(e, t, i);
1068
1083
  }
1069
- trackInternal(e, t, s = !1) {
1070
- if (!I(e))
1084
+ trackInternal(e, t, i = !1) {
1085
+ if (me()) {
1086
+ this.logger.debug("Tracking disabled due to um_exclusion setting");
1087
+ return;
1088
+ }
1089
+ if (!F(e))
1071
1090
  throw new Error("Event name must be a string");
1072
1091
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1073
1092
  throw new Error("Event payload must be a non-null object and not an array");
1074
- const n = this.createEventPayload(e, t);
1093
+ const r = this.createEventPayload(e, t);
1075
1094
  try {
1076
- if (s) {
1077
- this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
1095
+ if (i) {
1096
+ this.transport.send(r), this.logger.debug(`Event sent: ${e}`, [r]);
1078
1097
  return;
1079
1098
  }
1080
- this.retryQueue.add(n), this.logger.debug(`Event tracked: ${e}`, [n]);
1081
- } catch (r) {
1082
- throw this.logger.error(`Failed to track event: ${e}`, r), new Error(`Failed to track event: ${e}`);
1099
+ this.retryQueue.add(r), this.logger.debug(`Event tracked: ${e}`, [r]);
1100
+ } catch (o) {
1101
+ throw this.logger.error(`Failed to track event: ${e}`, o), new Error(`Failed to track event: ${e}`);
1083
1102
  }
1084
1103
  }
1085
1104
  rawTrack(e) {
1086
- if (!k(e))
1105
+ if (!v(e))
1087
1106
  throw new Error("Event payload must be an object");
1088
1107
  this.track("raw", e);
1089
1108
  }
1090
1109
  async group(e, t = !1) {
1091
- if (!k(e))
1110
+ if (!v(e))
1092
1111
  throw new Error("Company properties must be an object");
1093
1112
  if (!e.id || !e.name || !e.created_at)
1094
1113
  throw new Error("Company properties must include id, name, and created_at");
1095
1114
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1096
1115
  }
1097
1116
  createEventPayload(e, t) {
1098
- const s = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || (s == null ? void 0 : s.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1117
+ const i = this.persistence.get("userProps") || {}, s = this.persistence.get("companyProps") || (i == null ? void 0 : i.company) || {}, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1099
1118
  let l = t || {};
1100
1119
  const a = {
1101
1120
  event_id: "",
1102
1121
  user: {
1103
1122
  anonymous_id: this.anonymousId,
1104
1123
  id: r,
1105
- ...s
1124
+ ...i
1106
1125
  },
1107
- ...n && { company: n },
1126
+ ...s && { company: s },
1108
1127
  ids: this.getThirdPartyIds(),
1109
1128
  utc_time: (/* @__PURE__ */ new Date()).toISOString(),
1110
1129
  local_tz_offset: (/* @__PURE__ */ new Date()).getTimezoneOffset(),
@@ -1125,9 +1144,9 @@ class we {
1125
1144
  }
1126
1145
  processAutocaptureAttributes(e) {
1127
1146
  let t = {};
1128
- const s = e.$elements || [];
1129
- return s.length && (t = { ...s[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", ["$ce_version", "$event_type", "$initial_referrer", "$initial_referring_domain", "$referrer", "$referring_domain", "$elements"].forEach((n) => {
1130
- delete t[n];
1147
+ const i = e.$elements || [];
1148
+ return i.length && (t = { ...i[0] }), t.el_text = t.$el_text || "", t.event_type = e.$event_type || "", ["$ce_version", "$event_type", "$initial_referrer", "$initial_referring_domain", "$referrer", "$referring_domain", "$elements"].forEach((s) => {
1149
+ delete t[s];
1131
1150
  }), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
1132
1151
  }
1133
1152
  getCookie(e) {
@@ -1143,9 +1162,9 @@ class we {
1143
1162
  return e;
1144
1163
  }
1145
1164
  getUtmParams() {
1146
- const e = {}, t = le(window.location.search);
1147
- return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((n) => {
1148
- t[n] && (e[n.replace("utm_", "")] = t[n]);
1165
+ const e = {}, t = ge(window.location.search);
1166
+ return ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"].forEach((s) => {
1167
+ t[s] && (e[s.replace("utm_", "")] = t[s]);
1149
1168
  }), e;
1150
1169
  }
1151
1170
  pageview() {
@@ -1158,7 +1177,7 @@ class we {
1158
1177
  setupPageLeaveTracking() {
1159
1178
  if (!u()) return;
1160
1179
  let e = !1, t = !1;
1161
- const s = () => {
1180
+ const i = () => {
1162
1181
  !e && !t && (e = !0, this.track("$pageleave", {
1163
1182
  url: window.location.href,
1164
1183
  referrer: document.referrer,
@@ -1170,12 +1189,12 @@ class we {
1170
1189
  t = !1;
1171
1190
  }, 100);
1172
1191
  }), document.addEventListener("visibilitychange", () => {
1173
- document.visibilityState === "hidden" && !t && s();
1192
+ document.visibilityState === "hidden" && !t && i();
1174
1193
  });
1175
- const n = history.pushState;
1194
+ const s = history.pushState;
1176
1195
  history.pushState = function() {
1177
- return s(), n.apply(this, arguments);
1178
- }, window.addEventListener("popstate", s);
1196
+ return i(), s.apply(this, arguments);
1197
+ }, window.addEventListener("popstate", i);
1179
1198
  }
1180
1199
  getConfig() {
1181
1200
  return this.config;
@@ -1191,20 +1210,20 @@ class we {
1191
1210
  this.logger.info("core state reset", { resetAnonId: e, namespace: this.namespace });
1192
1211
  }
1193
1212
  set(e, t) {
1194
- if (!k(e))
1213
+ if (!v(e))
1195
1214
  throw new Error("Properties must be an object");
1196
- const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1197
- if (s) {
1198
- let r = this.persistence.get(`props_${s}`) || {};
1199
- r = { ...r, ...e }, this.persistence.set(`props_${s}`, r);
1215
+ const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1216
+ if (i) {
1217
+ let r = this.persistence.get(`props_${i}`) || {};
1218
+ r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
1200
1219
  } else {
1201
1220
  let r = this.persistence.get("global_props") || {};
1202
1221
  r = { ...r, ...e }, this.persistence.set("global_props", r);
1203
1222
  }
1204
- n && this.persistence.save(), this.logger.debug("Properties set", {
1223
+ s && this.persistence.save(), this.logger.debug("Properties set", {
1205
1224
  properties: e,
1206
- eventType: s || "global",
1207
- persist: n
1225
+ eventType: i || "global",
1226
+ persist: s
1208
1227
  });
1209
1228
  }
1210
1229
  setUserId(e) {
@@ -1213,109 +1232,141 @@ class we {
1213
1232
  t.id = e, this.persistence.set("userProps", t), this.persistence.save();
1214
1233
  }
1215
1234
  unset(e, t) {
1216
- const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1217
- if (s) {
1218
- let r = this.persistence.get(`props_${s}`) || {};
1219
- delete r[e], this.persistence.set(`props_${s}`, r);
1235
+ const i = t == null ? void 0 : t.eventType, s = (t == null ? void 0 : t.persist) ?? !0;
1236
+ if (i) {
1237
+ let r = this.persistence.get(`props_${i}`) || {};
1238
+ delete r[e], this.persistence.set(`props_${i}`, r);
1220
1239
  } else {
1221
1240
  let r = this.persistence.get("global_props") || {};
1222
1241
  delete r[e], this.persistence.set("global_props", r);
1223
1242
  }
1224
- n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1243
+ s && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1225
1244
  }
1226
1245
  }
1227
- function ke(i) {
1228
- const e = JSON.parse(JSON.stringify(i)), t = H(e), s = { ...U, ...t };
1229
- if (!s.key)
1246
+ function X() {
1247
+ return typeof window < "u" && typeof window.define == "function" && window.define.amd;
1248
+ }
1249
+ function Pe() {
1250
+ return X() ? window.define : void 0;
1251
+ }
1252
+ const Ae = "__USERMAVEN_AUTOCAPTURE_INITIALIZED__";
1253
+ function C(n) {
1254
+ const e = JSON.parse(JSON.stringify(n)), t = I(e), i = { ...q, ...t };
1255
+ if (!i.key)
1230
1256
  throw new Error("API key is required!");
1231
- if (!s.trackingHost)
1257
+ if (!i.trackingHost)
1232
1258
  throw new Error("Tracking host is required!");
1233
- return new we(s);
1259
+ const s = i.key || "", r = `${Ae}${s}`;
1260
+ return u() && i.autocapture && window[r] && (console.warn("Usermaven: Autocapture already initialized in another instance, skipping duplicate initialization."), i.disableAutocaptureListenerRegistration = !0), u() && i.autocapture && !i.disableAutocaptureListenerRegistration && (window[r] = !0), new S(i);
1234
1261
  }
1235
- function ve(i) {
1236
- var n;
1262
+ function $e(n) {
1263
+ var s;
1237
1264
  const e = {
1238
- key: i.getAttribute("data-key") || void 0,
1239
- trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1240
- logLevel: ue(i.getAttribute("data-log-level")),
1241
- autocapture: i.getAttribute("data-autocapture") === "true",
1242
- formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
1243
- autoPageview: i.getAttribute("data-auto-pageview") === "true",
1244
- useBeaconApi: i.getAttribute("data-use-beacon-api") === "true",
1245
- forceUseFetch: i.getAttribute("data-force-use-fetch") === "true",
1246
- gaHook: i.getAttribute("data-ga-hook") === "true",
1247
- segmentHook: i.getAttribute("data-segment-hook") === "true",
1248
- randomizeUrl: i.getAttribute("data-randomize-url") === "true",
1249
- capture3rdPartyCookies: i.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1250
- idMethod: i.getAttribute("data-id-method") || void 0,
1251
- privacyPolicy: i.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1252
- ipPolicy: i.getAttribute("data-ip-policy") || void 0,
1253
- cookiePolicy: i.getAttribute("data-cookie-policy") || void 0,
1254
- minSendTimeout: parseInt(i.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1255
- maxSendTimeout: parseInt(i.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1256
- maxSendAttempts: parseInt(i.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1257
- propertiesStringMaxLength: parseInt(i.getAttribute("data-properties-string-max-length") || "", 10) || null,
1258
- propertyBlacklist: ((n = i.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
1259
- exclude: i.getAttribute("data-exclude") || void 0,
1260
- namespace: i.getAttribute("data-namespace") || void 0,
1261
- crossDomainLinking: i.getAttribute("data-cross-domain-linking") !== "false",
1262
- domains: i.getAttribute("data-domains") || void 0,
1263
- maskAllText: i.getAttribute("data-mask-all-text") === "true",
1264
- maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1265
+ key: n.getAttribute("data-key") || void 0,
1266
+ trackingHost: n.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1267
+ logLevel: pe(n.getAttribute("data-log-level")),
1268
+ autocapture: n.getAttribute("data-autocapture") === "true",
1269
+ formTracking: n.getAttribute("data-form-tracking") === "false" ? !1 : n.getAttribute("data-form-tracking") === "true" ? "all" : n.getAttribute("data-form-tracking"),
1270
+ autoPageview: n.getAttribute("data-auto-pageview") === "true",
1271
+ useBeaconApi: n.getAttribute("data-use-beacon-api") === "true",
1272
+ forceUseFetch: n.getAttribute("data-force-use-fetch") === "true",
1273
+ gaHook: n.getAttribute("data-ga-hook") === "true",
1274
+ segmentHook: n.getAttribute("data-segment-hook") === "true",
1275
+ randomizeUrl: n.getAttribute("data-randomize-url") === "true",
1276
+ capture3rdPartyCookies: n.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1277
+ idMethod: n.getAttribute("data-id-method") || void 0,
1278
+ privacyPolicy: n.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1279
+ ipPolicy: n.getAttribute("data-ip-policy") || void 0,
1280
+ cookiePolicy: n.getAttribute("data-cookie-policy") || void 0,
1281
+ minSendTimeout: parseInt(n.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1282
+ maxSendTimeout: parseInt(n.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1283
+ maxSendAttempts: parseInt(n.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1284
+ propertiesStringMaxLength: parseInt(n.getAttribute("data-properties-string-max-length") || "", 10) || null,
1285
+ propertyBlacklist: ((s = n.getAttribute("data-property-blacklist")) == null ? void 0 : s.split(",")) || void 0,
1286
+ exclude: n.getAttribute("data-exclude") || void 0,
1287
+ namespace: n.getAttribute("data-namespace") || void 0,
1288
+ crossDomainLinking: n.getAttribute("data-cross-domain-linking") !== "false",
1289
+ domains: n.getAttribute("data-domains") || void 0,
1290
+ maskAllText: n.getAttribute("data-mask-all-text") === "true",
1291
+ maskAllElementAttributes: n.getAttribute("data-mask-all-element-attributes") === "true"
1265
1292
  };
1266
1293
  e.privacyPolicy === "strict" && (e.cookiePolicy = "strict", e.ipPolicy = "strict"), e.cookiePolicy === "comply" && e.useBeaconApi && (e.cookiePolicy = "strict");
1267
- const t = ke(e), s = e.namespace || "usermaven";
1268
- u() && t.pageview(), _e(s, t);
1294
+ const t = C(e), i = e.namespace || "usermaven";
1295
+ return u() && e.autoPageview !== !1 && t.pageview(), Se(i, t), t;
1269
1296
  }
1270
- function _e(i, e) {
1297
+ function Se(n, e) {
1271
1298
  let t = !1;
1272
- const s = [], n = [];
1299
+ const i = [], s = [];
1273
1300
  function r() {
1274
- for (; s.length > 0; ) {
1275
- const a = s.shift();
1276
- a && window[i].apply(null, a);
1301
+ for (; i.length > 0; ) {
1302
+ const a = i.shift();
1303
+ a && window[n].apply(null, a);
1277
1304
  }
1278
1305
  }
1279
1306
  function o() {
1280
- n.forEach((a) => a()), n.length = 0;
1307
+ s.forEach((a) => a()), s.length = 0;
1281
1308
  }
1282
- window[i] = function(...a) {
1309
+ window[n] = function(...a) {
1283
1310
  const h = a[0];
1284
1311
  if (h === "onLoad") {
1285
- typeof a[1] == "function" && (t ? a[1]() : n.push(a[1]));
1312
+ typeof a[1] == "function" && (t ? a[1]() : s.push(a[1]));
1286
1313
  return;
1287
1314
  }
1288
1315
  if (!t) {
1289
- s.push(a);
1316
+ i.push(a);
1290
1317
  return;
1291
1318
  }
1292
1319
  if (typeof e[h] == "function")
1293
1320
  return e[h].apply(e, a.slice(1));
1294
1321
  console.error(`Method ${h} not found on UsermavenClient`);
1295
1322
  };
1296
- const c = `${i}Q`, l = window[c] || [];
1323
+ const c = `${n}Q`, l = window[c] || [];
1297
1324
  for (window[c] = l, l.push = function(...a) {
1298
- return window[i].apply(null, a), Array.prototype.push.apply(this, a);
1325
+ return window[n].apply(null, a), Array.prototype.push.apply(this, a);
1299
1326
  }, setTimeout(() => {
1300
- t = !0, r(), o(), console.log(`Usermaven client for namespace ${i} is ready`);
1327
+ t = !0, r(), o(), console.log(`Usermaven client for namespace ${n} is ready`);
1301
1328
  }, 0); l.length > 0; ) {
1302
1329
  const a = l.shift();
1303
- a && s.push(a);
1330
+ a && i.push(a);
1304
1331
  }
1305
1332
  }
1306
- u() && function(i, e) {
1307
- const t = i.currentScript;
1308
- function s() {
1309
- t && t.src.includes("lib.js") && ve(t);
1310
- }
1311
- typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
1312
- }(document, window);
1333
+ let M = !1, H = null;
1334
+ if (u()) {
1335
+ const n = Pe();
1336
+ n && n("usermaven", [], function() {
1337
+ return {
1338
+ usermavenClient: C,
1339
+ UsermavenClient: S,
1340
+ LogLevel: p,
1341
+ // Expose the script tag client if it exists
1342
+ getScriptTagClient: () => H
1343
+ };
1344
+ }), typeof window < "u" && (window.usermavenClient = C, window.UsermavenClient = S, window.usermavenScriptTagClient = () => H), function(e, t) {
1345
+ const i = e.currentScript;
1346
+ function s() {
1347
+ return M || !i || !i.hasAttribute("data-key") || i.getAttribute("data-no-auto-init") === "true" ? !1 : i.src.includes("lib.js");
1348
+ }
1349
+ function r() {
1350
+ s() && (console.log("[Usermaven] Auto-initializing from script tag"), H = $e(i), M = !0);
1351
+ }
1352
+ typeof t < "u" && i && (e.readyState === "loading" ? e.addEventListener("DOMContentLoaded", r) : r());
1353
+ }(document, window);
1354
+ }
1355
+ typeof module < "u" && module.exports && !X() && (module.exports = {
1356
+ usermavenClient: C,
1357
+ UsermavenClient: S,
1358
+ Config: void 0,
1359
+ UserProps: void 0,
1360
+ EventPayload: void 0,
1361
+ LogLevel: p,
1362
+ ClientProperties: void 0
1363
+ });
1313
1364
 
1314
1365
  function createClient(params) {
1315
1366
  if (typeof window === 'undefined') {
1316
1367
  return null;
1317
1368
  }
1318
- return ke(params);
1369
+ return C(params);
1319
1370
  }
1320
1371
 
1321
1372
  /******************************************************************************