@usermaven/sdk-js 1.4.1-rc.59 → 1.4.1-rc.61

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,5 +1,5 @@
1
- var v = /* @__PURE__ */ ((s) => (s[s.DEBUG = 0] = "DEBUG", s[s.INFO = 1] = "INFO", s[s.WARN = 2] = "WARN", s[s.ERROR = 3] = "ERROR", s))(v || {});
2
- class J {
1
+ 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 || {});
2
+ class V {
3
3
  constructor(e) {
4
4
  this.level = e;
5
5
  }
@@ -16,8 +16,8 @@ class J {
16
16
  this.level <= 3 && console.error("[Usermaven Error]:", e, ...t);
17
17
  }
18
18
  }
19
- function h(s = 0) {
20
- return new J(s);
19
+ function h(i = 0) {
20
+ return new V(i);
21
21
  }
22
22
  const I = {
23
23
  logLevel: v.ERROR,
@@ -47,19 +47,18 @@ const I = {
47
47
  };
48
48
  class Q {
49
49
  constructor(e) {
50
- this.domain = e, this.cookieDomain = this.getCookieDomain(), console.log(this.cookieDomain);
50
+ this.domain = e, this.cookieDomain = this.getCookieDomain();
51
51
  }
52
- set(e, t, i = 365, n = !0, r = !1) {
53
- console.log("Setting cookie", e, t, i, n, r);
52
+ set(e, t, s = 365, n = !0, r = !1) {
54
53
  const o = /* @__PURE__ */ new Date();
55
- o.setTime(o.getTime() + i * 24 * 60 * 60 * 1e3);
54
+ o.setTime(o.getTime() + s * 24 * 60 * 60 * 1e3);
56
55
  const c = `expires=${o.toUTCString()}`, l = n ? "; Secure" : "", a = r ? "; HttpOnly" : "";
57
56
  document.cookie = `${e}=${t};${c};path=/;domain=${this.cookieDomain}${l}${a}`;
58
57
  }
59
58
  get(e) {
60
- const t = e + "=", i = document.cookie.split(";");
61
- for (let n = 0; n < i.length; n++) {
62
- let r = i[n].trim();
59
+ const t = e + "=", s = document.cookie.split(";");
60
+ for (let n = 0; n < s.length; n++) {
61
+ let r = s[n].trim();
63
62
  if (r.indexOf(t) === 0)
64
63
  return decodeURIComponent(r.substring(t.length));
65
64
  }
@@ -79,7 +78,7 @@ class Q {
79
78
  }
80
79
  isIpAddress(e) {
81
80
  const t = e.split(".");
82
- return t.length === 4 && t.every((i) => !isNaN(Number(i)));
81
+ return t.length === 4 && t.every((s) => !isNaN(Number(s)));
83
82
  }
84
83
  extractHostname(e) {
85
84
  let t;
@@ -87,110 +86,110 @@ class Q {
87
86
  }
88
87
  extractRootDomain(e) {
89
88
  let t = this.extractHostname(e);
90
- const i = t.split("."), n = i.length;
91
- return n > 2 && (i[n - 1].length == 2 ? (t = i[n - 2] + "." + i[n - 1], i[n - 2].length == 2 && (t = i[n - 3] + "." + t)) : t = i[n - 2] + "." + i[n - 1]), t;
89
+ const s = t.split("."), n = s.length;
90
+ 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;
92
91
  }
93
92
  extractTopLevelDomain(e) {
94
- const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, i = e.match(t);
95
- return i ? i[0] : "";
93
+ const t = /[a-z0-9][a-z0-9-]+\.[a-z.]{2,6}$/i, s = e.match(t);
94
+ return s ? s[0] : "";
96
95
  }
97
96
  }
98
- const W = Object.prototype, X = W.hasOwnProperty, K = Array.prototype, b = K.forEach, $ = {};
99
- function Z(s, e, t) {
100
- if (Array.isArray(s)) {
101
- if (b && s.forEach === b)
102
- s.forEach(e, t);
103
- else if ("length" in s && s.length === +s.length) {
104
- for (let i = 0, n = s.length; i < n; i++)
105
- if (i in s && e.call(t, s[i], i) === $)
97
+ const W = Object.prototype, X = W.hasOwnProperty, K = Array.prototype, E = K.forEach, T = {};
98
+ function Z(i, e, t) {
99
+ if (Array.isArray(i)) {
100
+ if (E && i.forEach === E)
101
+ i.forEach(e, t);
102
+ else if ("length" in i && i.length === +i.length) {
103
+ for (let s = 0, n = i.length; s < n; s++)
104
+ if (s in i && e.call(t, i[s], s) === T)
106
105
  return;
107
106
  }
108
107
  }
109
108
  }
110
- const T = function(s) {
111
- return s.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
112
- }, G = function(s) {
113
- for (const e in s)
114
- typeof s[e] == "function" && (s[e] = s[e].bind(s));
109
+ const A = function(i) {
110
+ return i.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, "");
111
+ }, G = function(i) {
112
+ for (const e in i)
113
+ typeof i[e] == "function" && (i[e] = i[e].bind(i));
115
114
  };
116
- function A(s, e, t) {
117
- if (s != null) {
118
- if (b && Array.isArray(s) && s.forEach === b)
119
- s.forEach(e, t);
120
- else if ("length" in s && s.length === +s.length) {
121
- for (let i = 0, n = s.length; i < n; i++)
122
- if (i in s && e.call(t, s[i], i) === $)
115
+ function S(i, e, t) {
116
+ if (i != null) {
117
+ if (E && Array.isArray(i) && i.forEach === E)
118
+ i.forEach(e, t);
119
+ else if ("length" in i && i.length === +i.length) {
120
+ for (let s = 0, n = i.length; s < n; s++)
121
+ if (s in i && e.call(t, i[s], s) === T)
123
122
  return;
124
123
  } else
125
- for (const i in s)
126
- if (X.call(s, i) && e.call(t, s[i], i) === $)
124
+ for (const s in i)
125
+ if (X.call(i, s) && e.call(t, i[s], s) === T)
127
126
  return;
128
127
  }
129
128
  }
130
- const Y = function(s, ...e) {
129
+ const Y = function(i, ...e) {
131
130
  return Z(e, function(t) {
132
- for (const i in t)
133
- t[i] !== void 0 && (s[i] = t[i]);
134
- }), s;
131
+ for (const s in t)
132
+ t[s] !== void 0 && (i[s] = t[s]);
133
+ }), i;
135
134
  };
136
- function _(s, e) {
137
- return s.indexOf(e) !== -1;
135
+ function _(i, e) {
136
+ return i.indexOf(e) !== -1;
138
137
  }
139
- const D = function(s) {
138
+ const F = function(i) {
140
139
  try {
141
- return /^\s*\bfunction\b/.test(s);
140
+ return /^\s*\bfunction\b/.test(i);
142
141
  } catch {
143
142
  return !1;
144
143
  }
145
- }, j = function(s) {
146
- return s === void 0;
144
+ }, j = function(i) {
145
+ return i === void 0;
147
146
  }, p = function() {
148
- const s = function(i, n, r, o, c) {
149
- if (!i) {
147
+ const i = function(s, n, r, o, c) {
148
+ if (!s) {
150
149
  h().error("No valid element provided to register_event");
151
150
  return;
152
151
  }
153
- if (i.addEventListener && !o)
154
- i.addEventListener(n, r, !!c);
152
+ if (s.addEventListener && !o)
153
+ s.addEventListener(n, r, !!c);
155
154
  else {
156
- const l = "on" + n, a = i[l];
157
- i[l] = e(i, r, a);
155
+ const l = "on" + n, a = s[l];
156
+ s[l] = e(s, r, a);
158
157
  }
159
158
  };
160
- function e(i, n, r) {
159
+ function e(s, n, r) {
161
160
  return function(o) {
162
161
  if (o = o || t(window.event), !o)
163
162
  return;
164
163
  let c = !0, l;
165
- D(r) && (l = r(o));
166
- const a = n.call(i, o);
164
+ F(r) && (l = r(o));
165
+ const a = n.call(s, o);
167
166
  return (l === !1 || a === !1) && (c = !1), c;
168
167
  };
169
168
  }
170
- function t(i) {
171
- return i && (i.preventDefault = t.preventDefault, i.stopPropagation = t.stopPropagation), i;
169
+ function t(s) {
170
+ return s && (s.preventDefault = t.preventDefault, s.stopPropagation = t.stopPropagation), s;
172
171
  }
173
172
  return t.preventDefault = function() {
174
173
  this.returnValue = !1;
175
174
  }, t.stopPropagation = function() {
176
175
  this.cancelBubble = !0;
177
- }, s;
178
- }(), ee = function(s) {
176
+ }, i;
177
+ }(), ee = function(i) {
179
178
  return function(...e) {
180
179
  try {
181
- return s.apply(this, e);
180
+ return i.apply(this, e);
182
181
  } catch (t) {
183
182
  h().error("Implementation error. Please turn on debug and contact support@usermaven.com.", t);
184
183
  }
185
184
  };
186
- }, F = function(s) {
187
- for (const e in s)
188
- typeof s[e] == "function" && (s[e] = ee(s[e]));
185
+ }, z = function(i) {
186
+ for (const e in i)
187
+ typeof i[e] == "function" && (i[e] = ee(i[e]));
189
188
  };
190
- function R(s) {
191
- for (let e in s)
192
- (s[e] === "" || s[e] === null || s[e] === void 0 || typeof s[e] == "object" && Object.keys(s[e]).length === 0) && delete s[e];
193
- return s;
189
+ function N(i) {
190
+ for (let e in i)
191
+ (i[e] === "" || i[e] === null || i[e] === void 0 || typeof i[e] == "object" && Object.keys(i[e]).length === 0) && delete i[e];
192
+ return i;
194
193
  }
195
194
  function u() {
196
195
  try {
@@ -199,76 +198,81 @@ function u() {
199
198
  return h().warn("window is not available"), !1;
200
199
  }
201
200
  }
202
- function f(s = 5) {
203
- const e = new Uint8Array(s);
204
- return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, s);
201
+ function f(i = 5) {
202
+ const e = new Uint8Array(i);
203
+ return crypto.getRandomValues(e), Array.from(e, (t) => t.toString(36).padStart(2, "0")).join("").slice(0, i);
205
204
  }
206
- function te(s) {
207
- return s.replace(
205
+ function te(i) {
206
+ return i.replace(
208
207
  /([-_][a-z])/g,
209
208
  (e) => e.toUpperCase().replace("-", "").replace("_", "")
210
209
  );
211
210
  }
212
- function S(s) {
213
- return typeof s != "object" || s === null ? s : Array.isArray(s) ? s.map(S) : Object.keys(s).reduce((e, t) => {
214
- const i = te(t);
215
- return e[i] = S(s[t]), e;
211
+ function C(i) {
212
+ return typeof i != "object" || i === null ? i : Array.isArray(i) ? i.map(C) : Object.keys(i).reduce((e, t) => {
213
+ const s = te(t);
214
+ return e[s] = C(i[t]), e;
216
215
  }, {});
217
216
  }
218
- function E(s) {
219
- switch (typeof s.className) {
217
+ function P(i) {
218
+ switch (typeof i.className) {
220
219
  case "string":
221
- return s.className;
220
+ return i.className;
222
221
  case "object":
223
- return ("baseVal" in s.className ? s.className.baseVal : null) || s.getAttribute("class") || "";
222
+ return ("baseVal" in i.className ? i.className.baseVal : null) || i.getAttribute("class") || "";
224
223
  default:
225
224
  return "";
226
225
  }
227
226
  }
228
- function N(s) {
227
+ function O(i) {
229
228
  let e = "";
230
- return M(s) && !q(s) && s.childNodes && s.childNodes.length && A(s.childNodes, function(t) {
231
- z(t) && t.textContent && (e += T(t.textContent).split(/(\s+)/).filter(x).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
232
- }), T(e);
229
+ return M(i) && !q(i) && i.childNodes && i.childNodes.length && S(i.childNodes, function(t) {
230
+ B(t) && t.textContent && (e += A(t.textContent).split(/(\s+)/).filter(H).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255));
231
+ }), A(e);
233
232
  }
234
- function H(s) {
235
- return !!s && s.nodeType === 1;
233
+ function R(i) {
234
+ return !!i && i.nodeType === 1;
236
235
  }
237
- function d(s, e) {
238
- return !!s && !!s.tagName && s.tagName.toLowerCase() === e.toLowerCase();
236
+ function d(i, e) {
237
+ return !!i && !!i.tagName && i.tagName.toLowerCase() === e.toLowerCase();
239
238
  }
240
- function z(s) {
241
- return !!s && s.nodeType === 3;
239
+ function B(i) {
240
+ return !!i && i.nodeType === 3;
242
241
  }
243
- function B(s) {
244
- return !!s && s.nodeType === 11;
242
+ function x(i) {
243
+ return !!i && i.nodeType === 11;
245
244
  }
246
- const C = ["a", "button", "form", "input", "select", "textarea", "label"];
247
- function ie(s, e) {
248
- if (!s || d(s, "html") || !H(s) || s.classList && s.classList.contains("um-no-capture"))
245
+ const b = ["a", "button", "form", "input", "select", "textarea", "label"];
246
+ function ie(i, e) {
247
+ if (!i || d(i, "html") || !R(i))
249
248
  return !1;
250
- let t = !1;
251
- const i = [s];
252
- let n = !0, r = s;
253
- for (; r.parentNode && !d(r, "body"); ) {
254
- if (B(r.parentNode)) {
255
- i.push(r.parentNode.host), r = r.parentNode.host;
249
+ let t = i;
250
+ for (; t && !d(t, "body"); ) {
251
+ if (t.classList && t.classList.contains("um-no-capture"))
252
+ return !1;
253
+ t.parentNode && x(t.parentNode) ? t = t.parentNode.host : t = t.parentNode;
254
+ }
255
+ let s = !1;
256
+ for (t = i; t && !d(t, "body"); ) {
257
+ if (t.parentNode && x(t.parentNode)) {
258
+ t = t.parentNode.host, t && b.indexOf(t.tagName.toLowerCase()) > -1 && (s = !0);
256
259
  continue;
257
260
  }
258
- if (n = r.parentNode || !1, !n) break;
259
- if (C.indexOf(n.tagName.toLowerCase()) > -1)
260
- t = !0;
261
+ const o = t.parentNode;
262
+ if (!o) break;
263
+ if (b.indexOf(o.tagName.toLowerCase()) > -1)
264
+ s = !0;
261
265
  else {
262
- const l = window.getComputedStyle(n);
263
- l && l.getPropertyValue("cursor") === "pointer" && (t = !0);
266
+ const c = window.getComputedStyle(o);
267
+ c && c.getPropertyValue("cursor") === "pointer" && (s = !0);
264
268
  }
265
- i.push(n), r = n;
269
+ t = o;
266
270
  }
267
- const o = window.getComputedStyle(s);
268
- if (o && o.getPropertyValue("cursor") === "pointer" && e.type === "click")
271
+ const n = window.getComputedStyle(i);
272
+ if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
269
273
  return !0;
270
- const c = s.tagName.toLowerCase();
271
- switch (c) {
274
+ const r = i.tagName.toLowerCase();
275
+ switch (r) {
272
276
  case "html":
273
277
  return !1;
274
278
  case "form":
@@ -279,80 +283,80 @@ function ie(s, e) {
279
283
  case "textarea":
280
284
  return e.type === "change" || e.type === "click";
281
285
  default:
282
- return t ? e.type === "click" : e.type === "click" && (C.indexOf(c) > -1 || s.getAttribute("contenteditable") === "true");
286
+ return s ? e.type === "click" : e.type === "click" && (b.indexOf(r) > -1 || i.getAttribute("contenteditable") === "true");
283
287
  }
284
288
  }
285
- function M(s) {
286
- if (!s || !H(s))
289
+ function M(i) {
290
+ if (!i || !R(i))
287
291
  return !1;
288
- if (typeof s.hasAttribute == "function") {
289
- if (s.hasAttribute(w.FORCE_CAPTURE_ATTR))
292
+ if (typeof i.hasAttribute == "function") {
293
+ if (i.hasAttribute(w.FORCE_CAPTURE_ATTR))
290
294
  return !0;
291
- if (s.hasAttribute(w.PREVENT_CAPTURE_ATTR))
295
+ if (i.hasAttribute(w.PREVENT_CAPTURE_ATTR))
292
296
  return !1;
293
297
  }
294
- let e = s;
298
+ let e = i;
295
299
  for (; e && e.parentElement && !d(e, "body"); ) {
296
- const n = E(e).split(" ");
300
+ const n = P(e).split(" ");
297
301
  if (_(n, "ph-sensitive") || _(n, "ph-no-capture"))
298
302
  return !1;
299
303
  e = e.parentElement;
300
304
  }
301
- if (_(E(s).split(" "), "ph-include"))
305
+ if (_(P(i).split(" "), "ph-include"))
302
306
  return !0;
303
- const t = s.type;
307
+ const t = i.type;
304
308
  if (typeof t == "string")
305
309
  switch (t.toLowerCase()) {
306
310
  case "hidden":
307
311
  case "password":
308
312
  return !1;
309
313
  }
310
- const i = s.name || s.id || "";
311
- return !(typeof i == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(i.replace(/[^a-zA-Z0-9]/g, "")));
314
+ const s = i.name || i.id || "";
315
+ return !(typeof s == "string" && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(s.replace(/[^a-zA-Z0-9]/g, "")));
312
316
  }
313
- function q(s) {
317
+ function q(i) {
314
318
  const e = ["button", "checkbox", "submit", "reset"];
315
- return !!(d(s, "input") && !e.includes(s.type) || d(s, "select") || d(s, "textarea") || s.getAttribute("contenteditable") === "true");
319
+ return !!(d(i, "input") && !e.includes(i.type) || d(i, "select") || d(i, "textarea") || i.getAttribute("contenteditable") === "true");
316
320
  }
317
- function x(s) {
318
- return !(s === null || j(s) || typeof s == "string" && (s = T(s), /^(?:(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((s || "").replace(/[- ]/g, "")) || /(^\d{3}-?\d{2}-?\d{4}$)/.test(s)));
321
+ function H(i) {
322
+ return !(i === null || j(i) || typeof i == "string" && (i = A(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)));
319
323
  }
320
- function se(s) {
321
- return typeof s == "string" ? s.substring(0, 10) === "_ngcontent" || s.substring(0, 7) === "_nghost" : !1;
324
+ function se(i) {
325
+ return typeof i == "string" ? i.substring(0, 10) === "_ngcontent" || i.substring(0, 7) === "_nghost" : !1;
322
326
  }
323
- function P() {
327
+ function $() {
324
328
  return f(10);
325
329
  }
326
- function ne(s) {
327
- 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(s).toLowerCase());
330
+ function ne(i) {
331
+ 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());
328
332
  }
329
- function re(s, e) {
333
+ function re(i, e) {
330
334
  let t;
331
- return function(...i) {
335
+ return function(...s) {
332
336
  const n = () => {
333
- clearTimeout(t), s(...i);
337
+ clearTimeout(t), i(...s);
334
338
  };
335
339
  clearTimeout(t), t = setTimeout(n, e);
336
340
  };
337
341
  }
338
- function oe(s) {
339
- const e = {}, t = s.replace(/^\?/, "").split("&");
340
- for (let i = 0; i < t.length; i++) {
341
- const n = t[i].split("=");
342
+ function oe(i) {
343
+ const e = {}, t = i.replace(/^\?/, "").split("&");
344
+ for (let s = 0; s < t.length; s++) {
345
+ const n = t[s].split("=");
342
346
  n[0] !== "" && (e[decodeURIComponent(n[0])] = decodeURIComponent(n[1] || ""));
343
347
  }
344
348
  return e;
345
349
  }
346
- function O(s) {
347
- return typeof s == "string" || s instanceof String;
350
+ function L(i) {
351
+ return typeof i == "string" || i instanceof String;
348
352
  }
349
- function k(s) {
350
- return s !== null && typeof s == "object" && s.constructor === Object;
353
+ function k(i) {
354
+ return i !== null && typeof i == "object" && i.constructor === Object;
351
355
  }
352
- function ae(s) {
353
- if (s === null)
356
+ function ae(i) {
357
+ if (i === null)
354
358
  return v.ERROR;
355
- const e = s.toUpperCase(), t = v[e];
359
+ const e = i.toUpperCase(), t = v[e];
356
360
  return t || t === 0 ? t : v.ERROR;
357
361
  }
358
362
  class ce {
@@ -367,6 +371,8 @@ class ce {
367
371
  e > this.lastScrollDepth && (this.lastScrollDepth = e, this.checkMilestones(e));
368
372
  }
369
373
  send(e = "$scroll") {
374
+ if (!this.lastScrollDepth)
375
+ return;
370
376
  const t = {
371
377
  percent: this.lastScrollDepth,
372
378
  window_height: this.getWindowHeight(),
@@ -379,8 +385,8 @@ class ce {
379
385
  this.track();
380
386
  }
381
387
  getScrollDepth() {
382
- const e = this.getWindowHeight(), t = this.getDocumentHeight(), i = this.getScrollDistance(), n = t - e;
383
- return Math.min(100, Math.floor(i / n * 100));
388
+ const e = this.getWindowHeight(), t = this.getDocumentHeight(), s = this.getScrollDistance(), n = t - e;
389
+ return Math.min(100, Math.floor(s / n * 100));
384
390
  }
385
391
  getWindowHeight() {
386
392
  return window.innerHeight || this.documentElement.clientHeight || document.body.clientHeight || 0;
@@ -399,14 +405,14 @@ class ce {
399
405
  return window.pageYOffset || this.documentElement.scrollTop || document.body.scrollTop || 0;
400
406
  }
401
407
  checkMilestones(e) {
402
- this.milestones.filter((i) => e >= i).forEach((i) => {
403
- this.send(), this.milestones = this.milestones.filter((n) => n !== i);
408
+ this.milestones.filter((s) => e >= s).forEach((s) => {
409
+ this.send(), this.milestones = this.milestones.filter((n) => n !== s);
404
410
  });
405
411
  }
406
412
  }
407
413
  const y = class y {
408
- constructor(e, t, i = h()) {
409
- this.logger = i, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new ce(e), G(this), F(this);
414
+ constructor(e, t, s = h()) {
415
+ this.logger = s, this.scrollDepth = null, this.client = e, this.options = t, this.scrollDepth = new ce(e), G(this), z(this);
410
416
  }
411
417
  init() {
412
418
  if (!(document && document.body)) {
@@ -430,10 +436,10 @@ const y = class y {
430
436
  return performance.navigation && performance.navigation.type === 1;
431
437
  }
432
438
  captureEvent(e) {
433
- var i, n;
439
+ var s, n;
434
440
  let t = this.getEventTarget(e);
435
- if (z(t) && (t = t.parentNode || null), e.type === "scroll")
436
- return (i = this.scrollDepth) == null || i.track(), !0;
441
+ if (B(t) && (t = t.parentNode || null), e.type === "scroll")
442
+ return (s = this.scrollDepth) == null || s.track(), !0;
437
443
  if (e.type === "visibilitychange" && document.visibilityState === "hidden" || e.type === "popstate")
438
444
  return this.isPageRefresh() || (n = this.scrollDepth) == null || n.send(), !0;
439
445
  if (t && this.shouldCaptureElement(t, e)) {
@@ -455,31 +461,31 @@ const y = class y {
455
461
  }
456
462
  getElementList(e) {
457
463
  const t = [e];
458
- let i = e;
459
- for (; i.parentNode && !d(i, "body"); )
460
- B(i.parentNode) ? (t.push(i.parentNode.host), i = i.parentNode.host) : (t.push(i.parentNode), i = i.parentNode);
464
+ let s = e;
465
+ for (; s.parentNode && !d(s, "body"); )
466
+ x(s.parentNode) ? (t.push(s.parentNode.host), s = s.parentNode.host) : (t.push(s.parentNode), s = s.parentNode);
461
467
  return t;
462
468
  }
463
469
  getElementsJson(e, t) {
464
- const i = [];
470
+ const s = [];
465
471
  let n = null, r = !1;
466
- return A(e, (o) => {
472
+ return S(e, (o) => {
467
473
  if (d(o, "a")) {
468
474
  const l = o.getAttribute("href");
469
- l !== null && M(o) && x(l) && (n = l);
475
+ l !== null && M(o) && H(l) && (n = l);
470
476
  }
471
- const c = E(o).split(" ");
472
- _(c, "ph-no-capture") && (r = !0), i.push(this.getPropertiesFromElement(o));
473
- }), this.options.maskAllText || (i[0].$el_text = this.sanitizeText(N(e[0]))), n !== null && (i[0].attr__href = n), r ? [] : i;
477
+ const c = P(o).split(" ");
478
+ _(c, "ph-no-capture") && (r = !0), s.push(this.getPropertiesFromElement(o));
479
+ }), this.options.maskAllText || (s[0].$el_text = this.sanitizeText(O(e[0]))), n !== null && (s[0].attr__href = n), r ? [] : s;
474
480
  }
475
481
  getPropertiesFromElement(e) {
476
482
  const t = {
477
483
  tag_name: e.tagName.toLowerCase()
478
484
  };
479
- C.indexOf(t.tag_name) > -1 && !this.options.maskAllText && (t.$el_text = this.sanitizeText(N(e)));
480
- const i = E(e);
481
- i.length > 0 && (t.classes = i.split(" ").filter((c) => c !== "")), A(e.attributes, (c) => {
482
- q(e) && ["name", "id", "class"].indexOf(c.name) === -1 || !this.options.maskAllElementAttributes && x(c.value) && !se(c.name) && (t["attr__" + c.name] = this.sanitizeAttributeValue(c.name, c.value));
485
+ b.indexOf(t.tag_name) > -1 && !this.options.maskAllText && (t.$el_text = this.sanitizeText(O(e)));
486
+ const s = P(e);
487
+ s.length > 0 && (t.classes = s.split(" ").filter((c) => c !== "")), S(e.attributes, (c) => {
488
+ q(e) && ["name", "id", "class"].indexOf(c.name) === -1 || !this.options.maskAllElementAttributes && H(c.value) && !se(c.name) && (t["attr__" + c.name] = this.sanitizeAttributeValue(c.name, c.value));
483
489
  });
484
490
  let n = 1, r = 1, o = e;
485
491
  for (; o = this.previousElementSibling(o); )
@@ -491,7 +497,7 @@ const y = class y {
491
497
  return e.previousElementSibling;
492
498
  do
493
499
  e = e.previousSibling;
494
- while (e && !H(e));
500
+ while (e && !R(e));
495
501
  return e;
496
502
  }
497
503
  getDefaultProperties(e) {
@@ -527,16 +533,16 @@ const y = class y {
527
533
  encodeHtml(e) {
528
534
  return e.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
529
535
  }
530
- static enabledForProject(e, t = 10, i = 10) {
536
+ static enabledForProject(e, t = 10, s = 10) {
531
537
  if (!e)
532
538
  return !1;
533
539
  let n = 0;
534
540
  for (let r = 0; r < e.length; r++)
535
541
  n += e.charCodeAt(r);
536
- return n % t < i;
542
+ return n % t < s;
537
543
  }
538
544
  static isBrowserSupported() {
539
- return D(document.querySelectorAll);
545
+ return F(document.querySelectorAll);
540
546
  }
541
547
  };
542
548
  y.FORCE_CAPTURE_ATTR = "data-um-force-capture", y.PREVENT_CAPTURE_ATTR = "data-um-no-capture";
@@ -571,32 +577,32 @@ class le {
571
577
  }
572
578
  }
573
579
  class ue {
574
- constructor(e, t, i = h()) {
575
- this.trackingHost = e, this.logger = i, this.config = t;
580
+ constructor(e, t, s = h()) {
581
+ this.trackingHost = e, this.logger = s, this.config = t;
576
582
  }
577
583
  async send(e) {
578
- const t = this.config.key, i = this.constructUrl(t), n = new Blob([JSON.stringify(e)], { type: "application/json" });
579
- if (navigator.sendBeacon(i, n))
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))
580
586
  this.logger.debug(`Successfully queued ${e.length} event(s) via Beacon API`);
581
587
  else
582
588
  throw new Error("Failed to queue events via Beacon API");
583
589
  }
584
590
  constructUrl(e) {
585
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
586
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
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.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
587
593
  }
588
594
  // Note: Beacon API doesn't support custom headers, so we can't use them here.
589
595
  // If custom headers are crucial, you might want to fall back to XHR or Fetch in those cases.
590
596
  }
591
- class L {
592
- constructor(e, t, i = h()) {
593
- this.trackingHost = e, this.logger = i, this.config = t;
597
+ class U {
598
+ constructor(e, t, s = h()) {
599
+ this.trackingHost = e, this.logger = s, this.config = t;
594
600
  }
595
601
  async send(e) {
596
- const t = this.config.key, i = this.constructUrl(t), n = JSON.stringify(e), r = {
602
+ const t = this.config.key, s = this.constructUrl(t), n = JSON.stringify(e), r = {
597
603
  "Content-Type": "application/json",
598
604
  ...this.getCustomHeaders()
599
- }, o = await fetch(i, {
605
+ }, o = await fetch(s, {
600
606
  method: "POST",
601
607
  headers: r,
602
608
  body: n
@@ -606,8 +612,8 @@ class L {
606
612
  this.logger.debug(`Successfully sent ${e.length} event(s)`), this.postHandle(o.status, await o.text());
607
613
  }
608
614
  constructUrl(e) {
609
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
610
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
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.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
611
617
  }
612
618
  getCustomHeaders() {
613
619
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -617,26 +623,26 @@ class L {
617
623
  }
618
624
  }
619
625
  class he {
620
- constructor(e, t, i = h()) {
621
- this.trackingHost = e, this.logger = i, this.config = t;
626
+ constructor(e, t, s = h()) {
627
+ this.trackingHost = e, this.logger = s, this.config = t;
622
628
  }
623
629
  send(e) {
624
- return new Promise((t, i) => {
630
+ return new Promise((t, s) => {
625
631
  const n = new XMLHttpRequest(), r = this.config.key, o = this.constructUrl(r);
626
632
  n.open("POST", o, !0), n.setRequestHeader("Content-Type", "application/json");
627
633
  const c = this.getCustomHeaders();
628
634
  Object.keys(c).forEach((l) => {
629
635
  n.setRequestHeader(l, c[l]);
630
636
  }), n.onload = () => {
631
- n.status >= 200 && n.status < 300 ? (this.logger.debug(`Successfully sent ${e.length} event(s)`), t()) : i(new Error(`HTTP error! status: ${n.status}`));
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}`));
632
638
  }, n.onerror = () => {
633
- i(new Error("Network error"));
639
+ s(new Error("Network error"));
634
640
  }, n.send(JSON.stringify(e));
635
641
  });
636
642
  }
637
643
  constructUrl(e) {
638
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "", n = u() ? "/api/v1/event" : "/api/v1/s2s/event";
639
- return this.config.randomizeUrl ? `${this.trackingHost}/api.${f()}?p_${f()}=${e}${t}${i}` : `${this.trackingHost}${n}?token=${e}${t}${i}`;
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.${f()}?p_${f()}=${e}${t}${s}` : `${this.trackingHost}${n}?token=${e}${t}${s}`;
640
646
  }
641
647
  getCustomHeaders() {
642
648
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
@@ -645,7 +651,7 @@ class he {
645
651
  this.logger.debug(`Response received. Status: ${e}, Body: ${t}`);
646
652
  }
647
653
  }
648
- class V {
654
+ class J {
649
655
  constructor(e, t) {
650
656
  this.storage = {}, this.prefix = `usermaven_${e}_`, this.load(), this.logger = t || h();
651
657
  }
@@ -704,10 +710,10 @@ class ge {
704
710
  this.storage = {};
705
711
  }
706
712
  }
707
- class U {
713
+ class D {
708
714
  // Default to true for server-side
709
- constructor(e, t = 3, i = 1e3, n = 10, r = 1e3, o = h()) {
710
- this.transport = e, this.maxRetries = t, this.retryInterval = i, 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"), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
715
+ constructor(e, t = 3, s = 1e3, n = 10, r = 1e3, o = h()) {
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 J("offline_queue"), u() && (this.isOnline = navigator.onLine, this.loadQueueFromStorage(), this.initNetworkListeners(), this.scheduleBatch());
711
717
  }
712
718
  add(e) {
713
719
  const t = { payload: e, retries: 0, timestamp: Date.now() };
@@ -726,11 +732,11 @@ class U {
726
732
  async processBatch() {
727
733
  if ((!u() || this.isOnline) && !this.processing && this.queue.length > 0) {
728
734
  this.processing = !0;
729
- const e = this.queue.splice(0, this.batchSize), t = e.map((i) => i.payload);
735
+ const e = this.queue.splice(0, this.batchSize), t = e.map((s) => s.payload);
730
736
  try {
731
737
  await this.transport.send(t), this.logger.debug(`Successfully sent batch of ${e.length} payloads`), u() && this.saveQueueToStorage();
732
- } catch (i) {
733
- this.logger.error("Failed to send batch", i), await this.handleBatchFailure(e);
738
+ } catch (s) {
739
+ this.logger.error("Failed to send batch", s), await this.handleBatchFailure(e);
734
740
  }
735
741
  this.processing = !1;
736
742
  }
@@ -753,7 +759,7 @@ class U {
753
759
  }
754
760
  class de {
755
761
  constructor(e) {
756
- this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), F(this);
762
+ this.clicks = [], this.threshold = 3, this.timeWindow = 2e3, this.distanceThreshold = 30, this.client = e, this.initializeEventListener(), z(this);
757
763
  }
758
764
  initializeEventListener() {
759
765
  document.addEventListener("click", this.handleClick.bind(this));
@@ -765,17 +771,17 @@ class de {
765
771
  shouldCaptureElement(e) {
766
772
  return !e.closest(".um-no-capture");
767
773
  }
768
- click(e, t, i) {
769
- const n = { x: e, y: t, timestamp: i };
770
- this.clicks.push(n), this.clicks = this.clicks.filter((r) => i - r.timestamp < this.timeWindow), this.clicks.length >= this.threshold && this.checkRageClick();
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();
771
777
  }
772
778
  checkRageClick() {
773
- const e = this.clicks[0], i = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
779
+ const e = this.clicks[0], s = (this.clicks[this.clicks.length - 1].timestamp - e.timestamp) / 1e3;
774
780
  this.clicks.every((r, o) => {
775
781
  if (o === 0) return !0;
776
782
  const c = this.clicks[o - 1];
777
783
  return Math.sqrt(Math.pow(r.x - c.x, 2) + Math.pow(r.y - c.y, 2)) < this.distanceThreshold;
778
- }) && this.sendRageClickEvent(i);
784
+ }) && this.sendRageClickEvent(s);
779
785
  }
780
786
  sendRageClickEvent(e) {
781
787
  const t = this.clicks[this.clicks.length - 1];
@@ -786,14 +792,14 @@ class de {
786
792
  }
787
793
  }
788
794
  class fe {
789
- constructor(e, t, i = h()) {
790
- this.trackingHost = e, this.logger = i, this.config = t;
795
+ constructor(e, t, s = h()) {
796
+ this.trackingHost = e, this.logger = s, this.config = t;
791
797
  }
792
798
  async send(e) {
793
- const t = this.config.key, i = new (void 0)(this.constructUrl(t)), n = {
794
- hostname: i.hostname,
799
+ const t = this.config.key, s = new (void 0)(this.constructUrl(t)), n = {
800
+ hostname: s.hostname,
795
801
  port: 443,
796
- path: `${i.pathname}${i.search}`,
802
+ path: `${s.pathname}${s.search}`,
797
803
  method: "POST",
798
804
  headers: {
799
805
  "Content-Type": "application/json",
@@ -814,16 +820,16 @@ class fe {
814
820
  });
815
821
  }
816
822
  constructUrl(e) {
817
- const t = this.config.cookiePolicy !== "keep" ? `&cookie_policy=${this.config.cookiePolicy}` : "", i = this.config.ipPolicy !== "keep" ? `&ip_policy=${this.config.ipPolicy}` : "";
818
- return `${this.trackingHost}/api/v1/s2s/event?token=${e}${t}${i}`;
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}`;
819
825
  }
820
826
  getCustomHeaders() {
821
827
  return typeof this.config.customHeaders == "function" ? this.config.customHeaders() : this.config.customHeaders ? this.config.customHeaders : {};
822
828
  }
823
829
  }
824
830
  class m {
825
- constructor(e, t = "all", i = {}) {
826
- this.instance = e, this.trackingType = t, this.options = i, document.readyState === "loading" ? document.addEventListener("DOMContentLoaded", this.initialize.bind(this)) : this.initialize();
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();
827
833
  }
828
834
  initialize() {
829
835
  this.trackingType !== "none" && this.setupFormTracking();
@@ -835,19 +841,19 @@ class m {
835
841
  });
836
842
  }
837
843
  handleFormSubmit(e) {
838
- const t = e.target, i = this._getFormDetails(t);
839
- this.instance.track("$form", R(i)), this.options.trackFieldChanges && this.trackFieldChanges(t);
844
+ const t = e.target, s = this._getFormDetails(t);
845
+ this.instance.track("$form", N(s)), this.options.trackFieldChanges && this.trackFieldChanges(t);
840
846
  }
841
847
  trackFieldChanges(e) {
842
- e.querySelectorAll("input, select, textarea").forEach((i) => {
843
- i.addEventListener("change", (n) => {
848
+ e.querySelectorAll("input, select, textarea").forEach((s) => {
849
+ s.addEventListener("change", (n) => {
844
850
  const r = this._getFieldProps(n.target, 0);
845
- this.instance.track("$form_field_change", R(r));
851
+ this.instance.track("$form_field_change", N(r));
846
852
  });
847
853
  });
848
854
  }
849
- static getInstance(e, t = "all", i = {}) {
850
- return m.instance || (m.instance = new m(e, t, i)), m.instance;
855
+ static getInstance(e, t = "all", s = {}) {
856
+ return m.instance || (m.instance = new m(e, t, s)), m.instance;
851
857
  }
852
858
  _getFormDetails(e) {
853
859
  const t = {
@@ -857,18 +863,18 @@ class m {
857
863
  form_method: e.method,
858
864
  form_class: e.className,
859
865
  form_attributes: this._getElementAttributes(e)
860
- }, i = e.querySelectorAll("input, select, textarea");
861
- return Array.from(i).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
866
+ }, s = e.querySelectorAll("input, select, textarea");
867
+ return Array.from(s).filter((r) => !r.classList.contains("um-no-capture")).forEach((r, o) => {
862
868
  const c = this._getFieldProps(r, o);
863
869
  Object.assign(t, c);
864
870
  }), t;
865
871
  }
866
872
  _getFieldProps(e, t) {
867
- const i = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, n = this.getSafeText(e);
873
+ const s = Object.keys(e.dataset).length ? JSON.stringify(e.dataset) : void 0, n = this.getSafeText(e);
868
874
  return {
869
875
  [`field_${t + 1}_tag`]: e.tagName.toLowerCase(),
870
876
  [`field_${t + 1}_type`]: e instanceof HTMLInputElement ? e.type : void 0,
871
- [`field_${t + 1}_data_attributes`]: i,
877
+ [`field_${t + 1}_data_attributes`]: s,
872
878
  [`field_${t + 1}_id`]: e.id,
873
879
  [`field_${t + 1}_value`]: n,
874
880
  [`field_${t + 1}_class`]: e.className,
@@ -877,12 +883,7 @@ class m {
877
883
  };
878
884
  }
879
885
  _getElementAttributes(e) {
880
- const t = {};
881
- for (let i = 0; i < e.attributes.length; i++) {
882
- const n = e.attributes[i];
883
- n.name !== "value" && !n.name.startsWith("data-") && (t[n.name] = n.value);
884
- }
885
- return t;
886
+ return Object.keys(e.dataset).length ? JSON.parse(JSON.stringify(e.dataset)) : {};
886
887
  }
887
888
  getSafeText(e) {
888
889
  let t = "";
@@ -905,7 +906,7 @@ class m {
905
906
  _trim(e) {
906
907
  if (typeof String.prototype.trim == "function")
907
908
  return e.trim();
908
- let t = 0, i = e.length - 1;
909
+ let t = 0, s = e.length - 1;
909
910
  const n = [
910
911
  " ",
911
912
  `
@@ -933,16 +934,16 @@ class m {
933
934
  " ",
934
935
  " "
935
936
  ].join("");
936
- for (; t <= i && n.indexOf(e[t]) > -1; )
937
+ for (; t <= s && n.indexOf(e[t]) > -1; )
937
938
  t++;
938
- for (; i >= t && n.indexOf(e[i]) > -1; )
939
- i--;
940
- return e.slice(t, i + 1);
939
+ for (; s >= t && n.indexOf(e[s]) > -1; )
940
+ s--;
941
+ return e.slice(t, s + 1);
941
942
  }
942
943
  }
943
944
  class pe {
944
945
  constructor(e) {
945
- this.config = this.mergeConfig(e, I), this.logger = h(this.config.logLevel), this.namespace = e.namespace || "usermaven", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new U(
946
+ this.config = this.mergeConfig(e, I), this.logger = h(this.config.logLevel), this.namespace = e.namespace || "usermaven", this.transport = this.initializeTransport(this.config), this.persistence = this.initializePersistence(), this.retryQueue = new D(
946
947
  this.transport,
947
948
  this.config.maxSendAttempts || 3,
948
949
  this.config.minSendTimeout || 1e3,
@@ -967,14 +968,14 @@ class pe {
967
968
  * @param defaultConfig
968
969
  */
969
970
  mergeConfig(e, t) {
970
- const i = JSON.parse(JSON.stringify(e));
971
- let n = { ...t, ...i };
971
+ const s = JSON.parse(JSON.stringify(e));
972
+ let n = { ...t, ...s };
972
973
  return Object.keys(t).forEach((r) => {
973
974
  k(t[r]) && (n[r] = this.mergeConfig(e[r], t[r]));
974
975
  }), n;
975
976
  }
976
977
  init(e) {
977
- this.config = { ...this.config, ...e }, this.logger = h(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new U(
978
+ this.config = { ...this.config, ...e }, this.logger = h(this.config.logLevel), this.namespace = e.namespace || this.namespace, this.transport = this.initializeTransport(e), this.persistence = this.initializePersistence(), this.retryQueue = new D(
978
979
  this.transport,
979
980
  this.config.maxSendAttempts || 3,
980
981
  this.config.minSendTimeout || 1e3,
@@ -987,10 +988,10 @@ class pe {
987
988
  manageCrossDomainLinking() {
988
989
  if (!this.config.crossDomainLinking || !this.config.domains)
989
990
  return;
990
- const e = this.config.domains.split(",").map((i) => i.trim()), t = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
991
- document.addEventListener("click", (i) => {
991
+ const e = this.config.domains.split(",").map((s) => s.trim()), t = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
992
+ document.addEventListener("click", (s) => {
992
993
  var c;
993
- const n = this.findClosestLink(i.target);
994
+ const n = this.findClosestLink(s.target);
994
995
  if (!n) return;
995
996
  const r = n.getAttribute("href");
996
997
  if (!r || !r.startsWith("http")) return;
@@ -1009,47 +1010,47 @@ class pe {
1009
1010
  initializeTransport(e) {
1010
1011
  if (!u())
1011
1012
  return new fe(e.trackingHost, e);
1012
- const t = "XMLHttpRequest" in window, i = typeof fetch < "u", n = typeof navigator < "u" && "sendBeacon" in navigator;
1013
+ const t = "XMLHttpRequest" in window, s = typeof fetch < "u", n = typeof navigator < "u" && "sendBeacon" in navigator;
1013
1014
  if (e.useBeaconApi && n)
1014
1015
  return new ue(e.trackingHost, e, this.logger);
1015
- if (e.forceUseFetch && i)
1016
- return new L(e.trackingHost, e, this.logger);
1016
+ if (e.forceUseFetch && s)
1017
+ return new U(e.trackingHost, e, this.logger);
1017
1018
  if (t)
1018
1019
  return new he(e.trackingHost, e, this.logger);
1019
- if (i)
1020
- return new L(e.trackingHost, e, this.logger);
1020
+ if (s)
1021
+ return new U(e.trackingHost, e, this.logger);
1021
1022
  throw new Error("No suitable transport method available");
1022
1023
  }
1023
1024
  initializePersistence() {
1024
- return this.config.disableEventPersistence || !u() ? new ge() : new V(`${this.namespace}_${this.config.key}`, this.logger);
1025
+ return this.config.disableEventPersistence || !u() ? new ge() : new J(`${this.namespace}_${this.config.key}`, this.logger);
1025
1026
  }
1026
1027
  getOrCreateAnonymousId() {
1027
- var i, n;
1028
+ var s, n;
1028
1029
  if (!u())
1029
- return P();
1030
+ return $();
1030
1031
  if (this.config.privacyPolicy === "strict" || this.config.cookiePolicy === "strict")
1031
1032
  return this.generateFingerprint();
1032
1033
  const e = this.config.cookieName || `${this.namespace}_id_${this.config.key}`;
1033
- let t = (i = this.cookieManager) == null ? void 0 : i.get(e);
1034
+ let t = (s = this.cookieManager) == null ? void 0 : s.get(e);
1034
1035
  if (!t) {
1035
1036
  if (this.config.crossDomainLinking) {
1036
1037
  const c = new URLSearchParams(window.location.search).get("_um"), a = window.location.hash.substring(1).split("~"), g = a.length > 1 ? a[1] : void 0;
1037
- t = c || g || P();
1038
+ t = c || g || $();
1038
1039
  }
1039
- t || (t = P());
1040
+ t || (t = $());
1040
1041
  const r = 365 * 10;
1041
1042
  (n = this.cookieManager) == null || n.set(e, t, r, document.location.protocol !== "http:", !1);
1042
1043
  }
1043
1044
  return t;
1044
1045
  }
1045
1046
  generateFingerprint() {
1046
- const e = navigator.userAgent, t = `${screen.width}x${screen.height}`, i = screen.colorDepth, n = Intl.DateTimeFormat().resolvedOptions().timeZone, r = `${e}|${t}|${i}|${n}`;
1047
+ const e = navigator.userAgent, t = `${screen.width}x${screen.height}`, s = screen.colorDepth, n = Intl.DateTimeFormat().resolvedOptions().timeZone, r = `${e}|${t}|${s}|${n}`;
1047
1048
  return this.hashString(r);
1048
1049
  }
1049
1050
  hashString(e) {
1050
1051
  let t = 0;
1051
- for (let i = 0; i < e.length; i++) {
1052
- const n = e.charCodeAt(i);
1052
+ for (let s = 0; s < e.length; s++) {
1053
+ const n = e.charCodeAt(s);
1053
1054
  t = (t << 5) - t + n, t = t & t;
1054
1055
  }
1055
1056
  return t.toString(36);
@@ -1059,10 +1060,10 @@ class pe {
1059
1060
  throw new Error("User data must be an object");
1060
1061
  if (e.email && !ne(e.email))
1061
1062
  throw new Error("Invalid email provided");
1062
- if (!e.id || !O(e.id))
1063
+ if (!e.id || !L(e.id))
1063
1064
  throw new Error("User ID must be a string");
1064
- const i = e.id;
1065
- if (this.persistence.set("userId", i), this.persistence.set("userProps", e), !t) {
1065
+ const s = e.id;
1066
+ if (this.persistence.set("userId", s), this.persistence.set("userProps", e), !t) {
1066
1067
  const n = {
1067
1068
  ...e,
1068
1069
  anonymous_id: this.anonymousId
@@ -1071,17 +1072,17 @@ class pe {
1071
1072
  }
1072
1073
  this.logger.info("User identified:", e);
1073
1074
  }
1074
- track(e, t, i = !1) {
1075
- this.trackInternal(e, t, i);
1075
+ track(e, t, s = !1) {
1076
+ this.trackInternal(e, t, s);
1076
1077
  }
1077
- trackInternal(e, t, i = !1) {
1078
- if (!O(e))
1078
+ trackInternal(e, t, s = !1) {
1079
+ if (!L(e))
1079
1080
  throw new Error("Event name must be a string");
1080
1081
  if (t !== void 0 && (typeof t != "object" || t === null || Array.isArray(t)))
1081
1082
  throw new Error("Event payload must be a non-null object and not an array");
1082
1083
  const n = this.createEventPayload(e, t);
1083
1084
  try {
1084
- if (i) {
1085
+ if (s) {
1085
1086
  this.transport.send(n), this.logger.debug(`Event sent: ${e}`, [n]);
1086
1087
  return;
1087
1088
  }
@@ -1103,14 +1104,14 @@ class pe {
1103
1104
  this.persistence.set("companyProps", e), t || await this.track("group", e), this.logger.info("Company identified:", e);
1104
1105
  }
1105
1106
  createEventPayload(e, t) {
1106
- const i = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || void 0, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1107
+ const s = this.persistence.get("userProps") || {}, n = this.persistence.get("companyProps") || void 0, r = this.persistence.get("userId"), o = this.persistence.get("global_props") || {}, c = this.persistence.get(`props_${e}`) || {};
1107
1108
  let l = t || {};
1108
1109
  const a = {
1109
1110
  event_id: "",
1110
1111
  user: {
1111
1112
  anonymous_id: this.anonymousId,
1112
1113
  id: r,
1113
- ...i
1114
+ ...s
1114
1115
  },
1115
1116
  ...n && { company: n },
1116
1117
  ids: this.getThirdPartyIds(),
@@ -1134,8 +1135,8 @@ class pe {
1134
1135
  }
1135
1136
  processAutocaptureAttributes(e) {
1136
1137
  let t = {};
1137
- const i = e.$elements || [];
1138
- 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((n) => {
1138
+ const s = e.$elements || [];
1139
+ 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) => {
1139
1140
  delete t[n];
1140
1141
  }), delete t.$el_text, delete t.nth_child, delete t.nth_of_type, t;
1141
1142
  }
@@ -1167,7 +1168,7 @@ class pe {
1167
1168
  setupPageLeaveTracking() {
1168
1169
  if (!u()) return;
1169
1170
  let e = !1, t = !1;
1170
- const i = () => {
1171
+ const s = () => {
1171
1172
  !e && !t && (e = !0, this.track("$pageleave", {
1172
1173
  url: window.location.href,
1173
1174
  referrer: document.referrer,
@@ -1179,12 +1180,12 @@ class pe {
1179
1180
  t = !1;
1180
1181
  }, 100);
1181
1182
  }), document.addEventListener("visibilitychange", () => {
1182
- document.visibilityState === "hidden" && !t && i();
1183
+ document.visibilityState === "hidden" && !t && s();
1183
1184
  });
1184
1185
  const n = history.pushState;
1185
1186
  history.pushState = function() {
1186
- return i(), n.apply(this, arguments);
1187
- }, window.addEventListener("popstate", i);
1187
+ return s(), n.apply(this, arguments);
1188
+ }, window.addEventListener("popstate", s);
1188
1189
  }
1189
1190
  getConfig() {
1190
1191
  return this.config;
@@ -1202,17 +1203,17 @@ class pe {
1202
1203
  set(e, t) {
1203
1204
  if (!k(e))
1204
1205
  throw new Error("Properties must be an object");
1205
- const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1206
- if (i) {
1207
- let r = this.persistence.get(`props_${i}`) || {};
1208
- r = { ...r, ...e }, this.persistence.set(`props_${i}`, r);
1206
+ const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1207
+ if (s) {
1208
+ let r = this.persistence.get(`props_${s}`) || {};
1209
+ r = { ...r, ...e }, this.persistence.set(`props_${s}`, r);
1209
1210
  } else {
1210
1211
  let r = this.persistence.get("global_props") || {};
1211
1212
  r = { ...r, ...e }, this.persistence.set("global_props", r);
1212
1213
  }
1213
1214
  n && this.persistence.save(), this.logger.debug("Properties set", {
1214
1215
  properties: e,
1215
- eventType: i || "global",
1216
+ eventType: s || "global",
1216
1217
  persist: n
1217
1218
  });
1218
1219
  }
@@ -1222,100 +1223,100 @@ class pe {
1222
1223
  t.id = e, this.persistence.set("userProps", t), this.persistence.save();
1223
1224
  }
1224
1225
  unset(e, t) {
1225
- const i = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1226
- if (i) {
1227
- let r = this.persistence.get(`props_${i}`) || {};
1228
- delete r[e], this.persistence.set(`props_${i}`, r);
1226
+ const s = t == null ? void 0 : t.eventType, n = (t == null ? void 0 : t.persist) ?? !0;
1227
+ if (s) {
1228
+ let r = this.persistence.get(`props_${s}`) || {};
1229
+ delete r[e], this.persistence.set(`props_${s}`, r);
1229
1230
  } else {
1230
1231
  let r = this.persistence.get("global_props") || {};
1231
1232
  delete r[e], this.persistence.set("global_props", r);
1232
1233
  }
1233
- n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${i || "global"}`);
1234
+ n && this.persistence.save(), this.logger.debug(`Property unset: ${e}`, `Event type: ${s || "global"}`);
1234
1235
  }
1235
1236
  }
1236
- function me(s) {
1237
- const e = JSON.parse(JSON.stringify(s)), t = S(e), i = { ...I, ...t };
1238
- if (!i.key)
1237
+ function me(i) {
1238
+ const e = JSON.parse(JSON.stringify(i)), t = C(e), s = { ...I, ...t };
1239
+ if (!s.key)
1239
1240
  throw new Error("API key is required!");
1240
- if (!i.trackingHost)
1241
+ if (!s.trackingHost)
1241
1242
  throw new Error("Tracking host is required!");
1242
- return new pe(i);
1243
+ return new pe(s);
1243
1244
  }
1244
- function ye(s) {
1245
+ function ye(i) {
1245
1246
  var n;
1246
1247
  const e = {
1247
- key: s.getAttribute("data-key") || void 0,
1248
- trackingHost: s.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1249
- logLevel: ae(s.getAttribute("data-log-level")),
1250
- autocapture: s.getAttribute("data-autocapture") === "true",
1251
- formTracking: s.getAttribute("data-form-tracking") === "true" ? "all" : !1,
1252
- autoPageview: s.getAttribute("data-auto-pageview") === "true",
1253
- useBeaconApi: s.getAttribute("data-use-beacon-api") === "true",
1254
- forceUseFetch: s.getAttribute("data-force-use-fetch") === "true",
1255
- gaHook: s.getAttribute("data-ga-hook") === "true",
1256
- segmentHook: s.getAttribute("data-segment-hook") === "true",
1257
- randomizeUrl: s.getAttribute("data-randomize-url") === "true",
1258
- capture3rdPartyCookies: s.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1259
- idMethod: s.getAttribute("data-id-method") || void 0,
1260
- privacyPolicy: s.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1261
- ipPolicy: s.getAttribute("data-ip-policy") || void 0,
1262
- cookiePolicy: s.getAttribute("data-cookie-policy") || void 0,
1263
- minSendTimeout: parseInt(s.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1264
- maxSendTimeout: parseInt(s.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1265
- maxSendAttempts: parseInt(s.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1266
- propertiesStringMaxLength: parseInt(s.getAttribute("data-properties-string-max-length") || "", 10) || null,
1267
- propertyBlacklist: ((n = s.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
1268
- exclude: s.getAttribute("data-exclude") || void 0,
1269
- namespace: s.getAttribute("data-namespace") || void 0,
1270
- crossDomainLinking: s.getAttribute("data-cross-domain-linking") !== "false",
1271
- domains: s.getAttribute("data-domains") || void 0,
1272
- maskAllText: s.getAttribute("data-mask-all-text") === "true",
1273
- maskAllElementAttributes: s.getAttribute("data-mask-all-element-attributes") === "true"
1274
- }, t = me(e), i = e.namespace || "usermaven";
1275
- u() && t.pageview(), we(i, t);
1248
+ key: i.getAttribute("data-key") || void 0,
1249
+ trackingHost: i.getAttribute("data-tracking-host") || "https://events.usermaven.com",
1250
+ logLevel: ae(i.getAttribute("data-log-level")),
1251
+ autocapture: i.getAttribute("data-autocapture") === "true",
1252
+ formTracking: i.getAttribute("data-form-tracking") === "false" ? !1 : i.getAttribute("data-form-tracking") === "true" ? "all" : i.getAttribute("data-form-tracking"),
1253
+ autoPageview: i.getAttribute("data-auto-pageview") === "true",
1254
+ useBeaconApi: i.getAttribute("data-use-beacon-api") === "true",
1255
+ forceUseFetch: i.getAttribute("data-force-use-fetch") === "true",
1256
+ gaHook: i.getAttribute("data-ga-hook") === "true",
1257
+ segmentHook: i.getAttribute("data-segment-hook") === "true",
1258
+ randomizeUrl: i.getAttribute("data-randomize-url") === "true",
1259
+ capture3rdPartyCookies: i.getAttribute("data-capture-3rd-party-cookies") === "false" ? !1 : void 0,
1260
+ idMethod: i.getAttribute("data-id-method") || void 0,
1261
+ privacyPolicy: i.getAttribute("data-privacy-policy") === "strict" ? "strict" : void 0,
1262
+ ipPolicy: i.getAttribute("data-ip-policy") || void 0,
1263
+ cookiePolicy: i.getAttribute("data-cookie-policy") || void 0,
1264
+ minSendTimeout: parseInt(i.getAttribute("data-min-send-timeout") || "", 10) || void 0,
1265
+ maxSendTimeout: parseInt(i.getAttribute("data-max-send-timeout") || "", 10) || void 0,
1266
+ maxSendAttempts: parseInt(i.getAttribute("data-max-send-attempts") || "", 10) || void 0,
1267
+ propertiesStringMaxLength: parseInt(i.getAttribute("data-properties-string-max-length") || "", 10) || null,
1268
+ propertyBlacklist: ((n = i.getAttribute("data-property-blacklist")) == null ? void 0 : n.split(",")) || void 0,
1269
+ exclude: i.getAttribute("data-exclude") || void 0,
1270
+ namespace: i.getAttribute("data-namespace") || void 0,
1271
+ crossDomainLinking: i.getAttribute("data-cross-domain-linking") !== "false",
1272
+ domains: i.getAttribute("data-domains") || void 0,
1273
+ maskAllText: i.getAttribute("data-mask-all-text") === "true",
1274
+ maskAllElementAttributes: i.getAttribute("data-mask-all-element-attributes") === "true"
1275
+ }, t = me(e), s = e.namespace || "usermaven";
1276
+ u() && t.pageview(), we(s, t);
1276
1277
  }
1277
- function we(s, e) {
1278
+ function we(i, e) {
1278
1279
  let t = !1;
1279
- const i = [], n = [];
1280
+ const s = [], n = [];
1280
1281
  function r() {
1281
- for (; i.length > 0; ) {
1282
- const a = i.shift();
1283
- a && window[s].apply(null, a);
1282
+ for (; s.length > 0; ) {
1283
+ const a = s.shift();
1284
+ a && window[i].apply(null, a);
1284
1285
  }
1285
1286
  }
1286
1287
  function o() {
1287
1288
  n.forEach((a) => a()), n.length = 0;
1288
1289
  }
1289
- window[s] = function(...a) {
1290
+ window[i] = function(...a) {
1290
1291
  const g = a[0];
1291
1292
  if (g === "onLoad") {
1292
1293
  typeof a[1] == "function" && (t ? a[1]() : n.push(a[1]));
1293
1294
  return;
1294
1295
  }
1295
1296
  if (!t) {
1296
- i.push(a);
1297
+ s.push(a);
1297
1298
  return;
1298
1299
  }
1299
1300
  if (typeof e[g] == "function")
1300
1301
  return e[g].apply(e, a.slice(1));
1301
1302
  console.error(`Method ${g} not found on UsermavenClient`);
1302
1303
  };
1303
- const c = `${s}Q`, l = window[c] || [];
1304
+ const c = `${i}Q`, l = window[c] || [];
1304
1305
  for (window[c] = l, l.push = function(...a) {
1305
- return window[s].apply(null, a), Array.prototype.push.apply(this, a);
1306
+ return window[i].apply(null, a), Array.prototype.push.apply(this, a);
1306
1307
  }, setTimeout(() => {
1307
- t = !0, r(), o(), console.log(`Usermaven client for namespace ${s} is ready`);
1308
+ t = !0, r(), o(), console.log(`Usermaven client for namespace ${i} is ready`);
1308
1309
  }, 0); l.length > 0; ) {
1309
1310
  const a = l.shift();
1310
- a && i.push(a);
1311
+ a && s.push(a);
1311
1312
  }
1312
1313
  }
1313
- u() && function(s, e) {
1314
- const t = s.currentScript;
1315
- function i() {
1314
+ u() && function(i, e) {
1315
+ const t = i.currentScript;
1316
+ function s() {
1316
1317
  t && t.src.includes("lib.js") && ye(t);
1317
1318
  }
1318
- typeof e < "u" && (s.readyState === "loading" ? s.addEventListener("DOMContentLoaded", i) : i());
1319
+ typeof e < "u" && (i.readyState === "loading" ? i.addEventListener("DOMContentLoaded", s) : s());
1319
1320
  }(document, window);
1320
1321
  export {
1321
1322
  v as LogLevel,