@levo-so/react 0.1.35 → 0.1.37

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 (86) hide show
  1. package/dist/{CheckboxWidget-BrVNbP0R.js → CheckboxWidget-BR6g2qCr.js} +1 -1
  2. package/dist/{CollectionFormBuilder-CkD8uVKZ.js → CollectionFormBuilder-KNHR7ngy.js} +18 -18
  3. package/dist/{CurrencyWidget-D_q2AYWu.js → CurrencyWidget-XHAkyPjV.js} +1 -1
  4. package/dist/{DateTimeWidget-CsuCisSs.js → DateTimeWidget-UaUunQAK.js} +1 -1
  5. package/dist/{DefaultFormVariant-rv38sBOZ.js → DefaultFormVariant-C8hqkuxx.js} +3 -3
  6. package/dist/{DropdownWidget-CsTQ0Ojo.js → DropdownWidget-DvObQQMp.js} +1 -1
  7. package/dist/{EmailWidget-Did2OUyB.js → EmailWidget-7L0S6tat.js} +2 -2
  8. package/dist/{FormCaptcha-C_DxR2za.js → FormCaptcha-CgYoGiya.js} +3 -3
  9. package/dist/{GeocoderWidget-CyzcaWxa.js → GeocoderWidget-DfghAiuD.js} +3 -3
  10. package/dist/{MultiGeocoderWidget-DgwiZ330.js → MultiGeocoderWidget-CqwjH855.js} +3 -3
  11. package/dist/{MultiTextWidget-Dic46WBU.js → MultiTextWidget-BMp9xdSv.js} +1 -1
  12. package/dist/{PhoneWidget-DKH-Wzgz.js → PhoneWidget-DFP4giY9.js} +1 -1
  13. package/dist/{RadioWidget-CTgWKCg2.js → RadioWidget-DMWMo2Mj.js} +2 -2
  14. package/dist/{RichTextWidget-C30H7mVF.js → RichTextWidget-DOCSDDib.js} +2 -2
  15. package/dist/{Spinner-BcBoT-J5.js → Spinner-B4CjY8aw.js} +20 -19
  16. package/dist/{StepsFormVariant-myT97AwJ.js → StepsFormVariant-CUFLCpGE.js} +3 -3
  17. package/dist/{SwitchWidget-BS-rmHiq.js → SwitchWidget-BjpxXOcZ.js} +1 -1
  18. package/dist/{TextWidget-aNB-0vc-.js → TextWidget-Cgk_TFqD.js} +1 -1
  19. package/dist/{TextareaWidget-CEH-97Oj.js → TextareaWidget-DGU_Xhrx.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-C0buyS29.js → ToggleCheckboxWidget-bhmeasG_.js} +1 -1
  21. package/dist/{URLWidget-DrZlRAD7.js → URLWidget-B20QysNc.js} +2 -2
  22. package/dist/{UploadWidget-Bw7urh-7.js → UploadWidget-SQ1MLpbO.js} +2 -2
  23. package/dist/audience/components/block.d.ts.map +1 -1
  24. package/dist/audience/components/component.d.ts +2 -2
  25. package/dist/audience/components/component.d.ts.map +1 -1
  26. package/dist/audience/components/page.d.ts +3 -4
  27. package/dist/audience/components/page.d.ts.map +1 -1
  28. package/dist/audience/hooks/useBounce.d.ts +4 -0
  29. package/dist/audience/hooks/useBounce.d.ts.map +1 -0
  30. package/dist/audience/hooks/useCurrentTab.d.ts.map +1 -1
  31. package/dist/audience/hooks/useIdentifyAudience.d.ts +7 -0
  32. package/dist/audience/hooks/useIdentifyAudience.d.ts.map +1 -0
  33. package/dist/audience/hooks/useOpenTabs.d.ts.map +1 -1
  34. package/dist/audience/index.js +1 -1
  35. package/dist/collection/index.js +1 -1
  36. package/dist/components/button/buttonVariants.d.ts +1 -1
  37. package/dist/components/button/buttonVariants.d.ts.map +1 -1
  38. package/dist/components/index.js +1 -1
  39. package/dist/index.css +1 -1
  40. package/dist/index.js +3 -3
  41. package/dist/membership/index.js +70 -69
  42. package/dist/page-BVVduzWl.js +626 -0
  43. package/dist/providers/LevoProvider.d.ts +4 -19
  44. package/dist/providers/LevoProvider.d.ts.map +1 -1
  45. package/dist/providers/index.js +8 -164
  46. package/package.json +4 -4
  47. package/dist/Checbox-sq-atGlJ.js.map +0 -1
  48. package/dist/CheckboxWidget-BrVNbP0R.js.map +0 -1
  49. package/dist/CollectionFormBuilder-CkD8uVKZ.js.map +0 -1
  50. package/dist/CurrencyWidget-D_q2AYWu.js.map +0 -1
  51. package/dist/DateTimeWidget-CsuCisSs.js.map +0 -1
  52. package/dist/DefaultFormVariant-rv38sBOZ.js.map +0 -1
  53. package/dist/DropdownWidget-CsTQ0Ojo.js.map +0 -1
  54. package/dist/EmailWidget-Did2OUyB.js.map +0 -1
  55. package/dist/FormCaptcha-C_DxR2za.js.map +0 -1
  56. package/dist/GeocoderWidget-CyzcaWxa.js.map +0 -1
  57. package/dist/Input-Vv7mKQFt.js.map +0 -1
  58. package/dist/MultiGeocoderWidget-DgwiZ330.js.map +0 -1
  59. package/dist/MultiTextWidget-Dic46WBU.js.map +0 -1
  60. package/dist/PhoneWidget-DKH-Wzgz.js.map +0 -1
  61. package/dist/RadioWidget-CTgWKCg2.js.map +0 -1
  62. package/dist/RichTextWidget-C30H7mVF.js.map +0 -1
  63. package/dist/Sonner-t6JVKA0a.js.map +0 -1
  64. package/dist/Spinner-BcBoT-J5.js.map +0 -1
  65. package/dist/StepsFormVariant-myT97AwJ.js.map +0 -1
  66. package/dist/SwitchWidget-BS-rmHiq.js.map +0 -1
  67. package/dist/TextWidget-aNB-0vc-.js.map +0 -1
  68. package/dist/TextareaWidget-CEH-97Oj.js.map +0 -1
  69. package/dist/ToggleCheckboxWidget-C0buyS29.js.map +0 -1
  70. package/dist/Tooltip-DoWyn3Ho.js.map +0 -1
  71. package/dist/URLWidget-DrZlRAD7.js.map +0 -1
  72. package/dist/UploadWidget-Bw7urh-7.js.map +0 -1
  73. package/dist/audience/index.js.map +0 -1
  74. package/dist/byteToSize-BFKZSBu1.js.map +0 -1
  75. package/dist/cn-C9QoOYNG.js.map +0 -1
  76. package/dist/collection/index.js.map +0 -1
  77. package/dist/components/index.js.map +0 -1
  78. package/dist/errorHandler-_34Yv8wA.js.map +0 -1
  79. package/dist/index.js.map +0 -1
  80. package/dist/isEmptyObject-C5s4GzLE.js.map +0 -1
  81. package/dist/jsx-runtime-B6kdoens.js.map +0 -1
  82. package/dist/membership/index.js.map +0 -1
  83. package/dist/page-t8PpNiSB.js +0 -567
  84. package/dist/page-t8PpNiSB.js.map +0 -1
  85. package/dist/providers/index.js.map +0 -1
  86. package/dist/utils/index.js.map +0 -1
@@ -1,567 +0,0 @@
1
- "use client";
2
- var rt = Object.defineProperty;
3
- var st = (t, e, n) => e in t ? rt(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n;
4
- var H = (t, e, n) => st(t, typeof e != "symbol" ? e + "" : e, n);
5
- import { j as it } from "./jsx-runtime-B6kdoens.js";
6
- import { useEffect as f, useState as h } from "react";
7
- import { useInView as ct } from "react-intersection-observer";
8
- import { useLevo as y } from "./providers/index.js";
9
- import { usePageLifecycle as at, LifecycleState as C } from "use-page-lifecycle";
10
- import { LocalStorageLock as ut } from "@levo-so/core";
11
- const be = ({ id: t, properties: e = {} }) => {
12
- const { audience: n } = y(), { ref: o, inView: r } = ct({
13
- triggerOnce: !0
14
- });
15
- return f(() => {
16
- n != null && n.instance && r && (n == null || n.track("block.view", {
17
- ...e,
18
- resource: "block",
19
- identifier: t
20
- }));
21
- }, [r]), /* @__PURE__ */ it.jsx("div", { ref: o, style: { height: "0px" } });
22
- }, ve = ({ event: t, properties: e }) => {
23
- const { audience: n } = y();
24
- return f(() => {
25
- n != null && n.instance && (n == null || n.track(t, e));
26
- }, [n == null ? void 0 : n.instance, t, e]), null;
27
- };
28
- function P(t) {
29
- var e = typeof t;
30
- return t != null && (e == "object" || e == "function");
31
- }
32
- var lt = typeof global == "object" && global && global.Object === Object && global, dt = typeof self == "object" && self && self.Object === Object && self, J = lt || dt || Function("return this")(), M = function() {
33
- return J.Date.now();
34
- }, ft = /\s/;
35
- function mt(t) {
36
- for (var e = t.length; e-- && ft.test(t.charAt(e)); )
37
- ;
38
- return e;
39
- }
40
- var pt = /^\s+/;
41
- function gt(t) {
42
- return t && t.slice(0, mt(t) + 1).replace(pt, "");
43
- }
44
- var _ = J.Symbol, z = Object.prototype, ht = z.hasOwnProperty, wt = z.toString, L = _ ? _.toStringTag : void 0;
45
- function bt(t) {
46
- var e = ht.call(t, L), n = t[L];
47
- try {
48
- t[L] = void 0;
49
- var o = !0;
50
- } catch {
51
- }
52
- var r = wt.call(t);
53
- return o && (e ? t[L] = n : delete t[L]), r;
54
- }
55
- var vt = Object.prototype, yt = vt.toString;
56
- function St(t) {
57
- return yt.call(t);
58
- }
59
- var Tt = "[object Null]", Et = "[object Undefined]", Y = _ ? _.toStringTag : void 0;
60
- function Lt(t) {
61
- return t == null ? t === void 0 ? Et : Tt : Y && Y in Object(t) ? bt(t) : St(t);
62
- }
63
- function kt(t) {
64
- return t != null && typeof t == "object";
65
- }
66
- var Ct = "[object Symbol]";
67
- function xt(t) {
68
- return typeof t == "symbol" || kt(t) && Lt(t) == Ct;
69
- }
70
- var W = NaN, _t = /^[-+]0x[0-9a-f]+$/i, Nt = /^0b[01]+$/i, Ot = /^0o[0-7]+$/i, It = parseInt;
71
- function K(t) {
72
- if (typeof t == "number")
73
- return t;
74
- if (xt(t))
75
- return W;
76
- if (P(t)) {
77
- var e = typeof t.valueOf == "function" ? t.valueOf() : t;
78
- t = P(e) ? e + "" : e;
79
- }
80
- if (typeof t != "string")
81
- return t === 0 ? t : +t;
82
- t = gt(t);
83
- var n = Nt.test(t);
84
- return n || Ot.test(t) ? It(t.slice(2), n ? 2 : 8) : _t.test(t) ? W : +t;
85
- }
86
- var Rt = "Expected a function", At = Math.max, jt = Math.min;
87
- function Mt(t, e, n) {
88
- var o, r, s, u, a, i, c = 0, l = !1, d = !1, p = !0;
89
- if (typeof t != "function")
90
- throw new TypeError(Rt);
91
- e = K(e) || 0, P(n) && (l = !!n.leading, d = "maxWait" in n, s = d ? At(K(n.maxWait) || 0, e) : s, p = "trailing" in n ? !!n.trailing : p);
92
- function g(m) {
93
- var w = o, E = r;
94
- return o = r = void 0, c = m, u = t.apply(E, w), u;
95
- }
96
- function I(m) {
97
- return c = m, a = setTimeout(v, e), l ? g(m) : u;
98
- }
99
- function S(m) {
100
- var w = m - i, E = m - c, B = e - w;
101
- return d ? jt(B, s - E) : B;
102
- }
103
- function T(m) {
104
- var w = m - i, E = m - c;
105
- return i === void 0 || w >= e || w < 0 || d && E >= s;
106
- }
107
- function v() {
108
- var m = M();
109
- if (T(m))
110
- return R(m);
111
- a = setTimeout(v, S(m));
112
- }
113
- function R(m) {
114
- return a = void 0, p && o ? g(m) : (o = r = void 0, u);
115
- }
116
- function A() {
117
- a !== void 0 && clearTimeout(a), c = 0, o = i = r = a = void 0;
118
- }
119
- function ot() {
120
- return a === void 0 ? u : R(M());
121
- }
122
- function j() {
123
- var m = M(), w = T(m);
124
- if (o = arguments, r = this, i = m, w) {
125
- if (a === void 0)
126
- return I(i);
127
- if (d)
128
- return clearTimeout(a), a = setTimeout(v, e), g(i);
129
- }
130
- return a === void 0 && (a = setTimeout(v, e)), u;
131
- }
132
- return j.cancel = A, j.flush = ot, j;
133
- }
134
- const Dt = () => {
135
- const [t, e] = h(0), [n, o] = h(0), [r, s] = h(0), [u, a] = h(Date.now()), [i, c] = h("read"), l = Mt(() => {
136
- const d = window.scrollY, p = document.documentElement.scrollHeight, g = window.innerHeight, I = Math.round(
137
- d / (p - g) * 100
138
- ), S = Math.floor(I / 5) * 5;
139
- if (S <= n)
140
- return;
141
- const T = Date.now(), v = (T - u) / 1e3, A = Math.abs(d - r) / v;
142
- c(A > 300 ? "scan" : "read"), s(d), a(T), o(S), e(S);
143
- }, 250);
144
- return f(() => (window.addEventListener("scroll", l), () => window.removeEventListener("scroll", l)), []), { depth: t, speedCategory: i };
145
- }, k = "lv_insights_ot", $t = () => {
146
- const [t, e] = h(0);
147
- return f(() => {
148
- const n = Number(localStorage.getItem(k)) || 0;
149
- e(n), localStorage.setItem(k, (n + 1).toString());
150
- const o = (s) => {
151
- s.key === k && e(Number(s.newValue) || 0);
152
- };
153
- window.addEventListener("storage", o);
154
- const r = () => {
155
- const s = Number(localStorage.getItem(k)) || 0;
156
- s > 0 && localStorage.setItem(k, (s - 1).toString());
157
- };
158
- return window.addEventListener("beforeunload", r), () => {
159
- window.removeEventListener("storage", o), window.removeEventListener("beforeunload", r);
160
- };
161
- }, []), t;
162
- }, G = "lv_insights_ct", D = "lv_insights_at", Pt = () => {
163
- const [t, e] = h(null);
164
- return f(() => {
165
- let n = sessionStorage.getItem(G);
166
- const o = JSON.parse(
167
- localStorage.getItem(D) || "[]"
168
- );
169
- n && o.includes(n) && (n = null), n || (n = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(G, n)), o.includes(n) || (o.push(n), localStorage.setItem(
170
- D,
171
- JSON.stringify(o)
172
- )), e(n);
173
- const r = () => {
174
- const s = o.filter(
175
- (u) => u !== n
176
- );
177
- localStorage.setItem(
178
- D,
179
- JSON.stringify(s)
180
- );
181
- };
182
- return window.addEventListener("beforeunload", r), () => {
183
- window.removeEventListener("beforeunload", r);
184
- };
185
- }, []), t;
186
- }, N = (t) => Object.prototype.toString.call(t) == "[object String]", Ft = (t, e) => t.indexOf(e) !== -1, O = (t) => t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), X = (t) => t === void 0, Ut = (t) => t === null, q = (t) => X(t) || Ut(t), Z = (t) => !!t && (t == null ? void 0 : t.nodeType) === 3;
187
- function Bt(t) {
188
- return !!t && (t == null ? void 0 : t.nodeType) === 1;
189
- }
190
- function Ht(t, e) {
191
- return !!t && !!(t != null && t.tagName) && (t == null ? void 0 : t.tagName.toLowerCase()) === e.toLowerCase();
192
- }
193
- function Yt(t) {
194
- return t ? O(t).split(/\s+/) : [];
195
- }
196
- function Wt(t) {
197
- let e = "";
198
- switch (typeof (t == null ? void 0 : t.className)) {
199
- case "string":
200
- e = t == null ? void 0 : t.className;
201
- break;
202
- case "object":
203
- e = (t != null && t.className && "baseVal" in (t == null ? void 0 : t.className) ? (t == null ? void 0 : t.className).baseVal : null) || (t == null ? void 0 : t.getAttribute("class")) || "";
204
- break;
205
- default:
206
- e = "";
207
- }
208
- return Yt(e);
209
- }
210
- const b = (t, e = 255) => q(t) ? "" : O(t).split(/(\s+)/).filter((n) => U(n)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, e), F = (t) => {
211
- let e = "";
212
- if (Vt(t) && // !isSensitiveElement(el) &&
213
- (t != null && t.childNodes) && (t != null && t.childNodes.length))
214
- for (const n of t == null ? void 0 : t.childNodes)
215
- Z(n) && n.textContent && (e += b(n.textContent) ?? "");
216
- return O(e);
217
- }, Kt = (t) => {
218
- var e, n;
219
- return X(t.target) ? (t == null ? void 0 : t.srcElement) || null : (e = t == null ? void 0 : t.target) != null && e.shadowRoot ? ((n = t == null ? void 0 : t.composedPath()) == null ? void 0 : n[0]) || null : (t == null ? void 0 : t.target) || null;
220
- }, Gt = (t, e) => {
221
- if (!window || !t || Ht(t, "html") || !Bt(t))
222
- return !1;
223
- const n = window.getComputedStyle(t);
224
- if (n && n.getPropertyValue("cursor") === "pointer" && e.type === "click")
225
- return !0;
226
- switch (t == null ? void 0 : t.tagName.toLowerCase()) {
227
- case "html":
228
- return !1;
229
- case "form":
230
- return e.type === "submit";
231
- case "input":
232
- case "select":
233
- case "textarea":
234
- return ["change", "click"].includes(e.type);
235
- default:
236
- return e.type === "click";
237
- }
238
- };
239
- function Vt(t) {
240
- if (Ft(Wt(t), "ph-include"))
241
- return !0;
242
- const e = t.type || "";
243
- if (N(e))
244
- switch (e.toLowerCase()) {
245
- case "hidden":
246
- return !1;
247
- case "password":
248
- return !1;
249
- }
250
- const n = t.name || (t == null ? void 0 : t.id) || "";
251
- return !(N(n) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g, "")));
252
- }
253
- const Q = "(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})", Jt = new RegExp(`^(?:${Q})$`), zt = new RegExp(Q), tt = "\\d{3}-?\\d{2}-?\\d{4}", Xt = new RegExp(`^(${tt})$`), qt = new RegExp(`(${tt})`), U = (t, e = !0) => !(q(t) || N(t) && (t = O(t), (e ? Jt : zt).test((t || "").replace(/[- ]/g, "")) || (e ? Xt : qt).test(t))), Zt = (t) => N(t) ? t.substring(0, 10) === "_ngcontent" || t.substring(0, 7) === "_nghost" : !1, Qt = (t) => {
254
- let e = F(t);
255
- return e = `${e} ${et(t)}`.trim(), U(e) ? e : "";
256
- };
257
- function et(t) {
258
- var n;
259
- let e = "";
260
- if (t != null && t.childNodes.length) {
261
- for (const o of t.childNodes)
262
- if (o && ((n = o.tagName) == null ? void 0 : n.toLowerCase()) === "span")
263
- try {
264
- const r = F(o);
265
- e = `${e} ${r}`.trim(), o != null && o.childNodes.length && (e = `${e} ${et(o)}`.trim());
266
- } catch {
267
- }
268
- }
269
- return e;
270
- }
271
- const te = ["input", "textarea", "select"], nt = (t) => {
272
- var r, s, u, a;
273
- const e = (r = t == null ? void 0 : t.tagName) == null ? void 0 : r.toLowerCase(), n = {
274
- element: e
275
- };
276
- (e == null ? void 0 : e.toLowerCase()) === "a" || (e == null ? void 0 : e.toLowerCase()) === "button" ? n.text = Qt(t) : n.text = F(t);
277
- const o = Array.from(t.attributes).reduce(
278
- (i, c) => {
279
- if (U(c.value) && !Zt(c.name)) {
280
- if (c.name === "class")
281
- return i;
282
- i[c.name] = typeof (c == null ? void 0 : c.value) == "string" ? b(c.value) : c.value;
283
- }
284
- return i;
285
- },
286
- {}
287
- );
288
- if (n.attributes = o, te.includes(e) || (t == null ? void 0 : t.getAttribute("contenteditable")) === "true") {
289
- let i;
290
- t.matches('input[type="checkbox"], input[type="radio"]') ? i = t.checked : t.matches("input, select, textarea") && !t.matches('input[type="password"]') && (i = t.value), i !== void 0 && (n.value = typeof i == "string" || i === null ? b(i, 1024) : i);
291
- let c = "";
292
- n != null && n.attributes.id && (c = b(
293
- ((u = (s = document.querySelector(`label[for="${n == null ? void 0 : n.attributes.id}"]`)) == null ? void 0 : s.textContent) == null ? void 0 : u.trim()) || ""
294
- ));
295
- const l = t.closest("label");
296
- c || (c = b(((a = l == null ? void 0 : l.textContent) == null ? void 0 : a.trim()) || "")), c && (n.label = c);
297
- }
298
- return n;
299
- }, ee = (t, e) => {
300
- var r;
301
- let n = Kt(t);
302
- Z(n) && (n = n.parentNode || null);
303
- const o = ["copy", "cut"].includes(e);
304
- if (n && (o || Gt(n, t))) {
305
- const s = nt(n);
306
- if (o) {
307
- const u = b((r = window == null ? void 0 : window.getSelection()) == null ? void 0 : r.toString()), a = (t == null ? void 0 : t.type) || "clipboard";
308
- s.copy_text = u ?? "", s.copy_type = a ?? "";
309
- }
310
- return s;
311
- }
312
- return null;
313
- }, ne = 30, oe = 1e3, re = 3;
314
- class se {
315
- constructor() {
316
- H(this, "clicks");
317
- this.clicks = [];
318
- }
319
- isRageClick(e, n, o) {
320
- const r = this.clicks[this.clicks.length - 1];
321
- if (r && Math.abs(e - r.x) + Math.abs(n - r.y) < ne && o - r.timestamp < oe) {
322
- if (this.clicks.push({ x: e, y: n, timestamp: o }), this.clicks.length === re)
323
- return !0;
324
- } else
325
- this.clicks = [{ x: e, y: n, timestamp: o }];
326
- return !1;
327
- }
328
- }
329
- const $ = new se(), ie = () => {
330
- const { audience: t } = y();
331
- f(() => {
332
- let e = null;
333
- const n = (s) => {
334
- if (e) {
335
- clearTimeout(e), e = null;
336
- return;
337
- }
338
- e = setTimeout(() => {
339
- r(s, !1), e = null;
340
- }, 250);
341
- }, o = (s) => {
342
- e && (clearTimeout(e), e = null), r(s, !0);
343
- }, r = (s, u = !1) => {
344
- var a;
345
- try {
346
- let i = {
347
- hostname: window.location.hostname,
348
- pathname: window.location.pathname,
349
- page_title: document.title,
350
- url: window.location.href,
351
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
352
- event_type: u ? "dblclick" : "click",
353
- button_type: s.button
354
- };
355
- if (s.target instanceof HTMLElement) {
356
- const c = s.target;
357
- i.rage_click = $ == null ? void 0 : $.isRageClick(
358
- s.clientX,
359
- s.clientY,
360
- (/* @__PURE__ */ new Date()).getTime()
361
- ), i = {
362
- ...i,
363
- ...nt(c)
364
- };
365
- let l = c == null ? void 0 : c.getAttribute("href");
366
- if (!l) {
367
- let d = c.parentNode, p = 0;
368
- for (; d && p < 8; ) {
369
- const g = (a = d == null ? void 0 : d.parentElement) == null ? void 0 : a.getAttribute("href");
370
- if (g) {
371
- l = g;
372
- break;
373
- }
374
- d = d.parentNode, p++;
375
- }
376
- }
377
- t == null || t.track("page.click", {
378
- ...i,
379
- href: l || void 0
380
- });
381
- }
382
- } catch {
383
- }
384
- };
385
- return document.addEventListener("click", n), document.addEventListener("dblclick", o), () => {
386
- document.removeEventListener("click", n), document.removeEventListener("dblclick", o);
387
- };
388
- }, [t]);
389
- }, x = (t) => Number(t.toFixed(0)), ce = (t) => {
390
- const { audience: e } = y(), [n] = h({
391
- value: x(performance.now()),
392
- timestamp: x(Date.now())
393
- }), [o, r] = h({
394
- value: null,
395
- timestamp: null
396
- }), [s, u] = h({
397
- value: null,
398
- timestamp: null
399
- });
400
- return f(() => {
401
- let a = !0;
402
- const i = (d, p) => {
403
- a && d({ value: x(p), timestamp: x(Date.now()) });
404
- }, c = new PerformanceObserver((d) => {
405
- for (const p of d.getEntries())
406
- p.name === "first-contentful-paint" && i(r, p.startTime);
407
- });
408
- c.observe({ type: "paint", buffered: !0 });
409
- const l = () => i(u, performance.now());
410
- return document.readyState === "complete" ? i(u, performance.now()) : window.addEventListener("load", l), () => {
411
- a = !1, c.disconnect(), window.removeEventListener("load", l);
412
- };
413
- }, []), f(() => {
414
- n && e && (e == null || e.track("page.metrics", {
415
- script_load: n.value,
416
- script_load_at: n.timestamp,
417
- version: 2
418
- }));
419
- }, [n, e]), f(() => {
420
- o.value !== null && e && (e == null || e.track("page.metrics", {
421
- first_contentful_paint: o.value,
422
- first_contentful_paint_at: o.timestamp,
423
- version: 2
424
- }));
425
- }, [o, e]), f(() => {
426
- s.value !== null && e && (e == null || e.track("page.metrics", {
427
- window_onload: s.value,
428
- window_onload_at: s.timestamp,
429
- version: 2
430
- }));
431
- }, [s, e]), { script: n, fcp: o, window_onload: s };
432
- }, ae = () => {
433
- const { audience: t } = y();
434
- f(() => {
435
- let e;
436
- const n = () => {
437
- clearTimeout(e), e = setTimeout(() => {
438
- const o = window.getSelection();
439
- if (o && (o == null ? void 0 : o.rangeCount) > 0) {
440
- const r = o == null ? void 0 : o.toString();
441
- r && (t == null || t.track("page.selection", {
442
- text: b(r)
443
- }));
444
- }
445
- }, 1e3);
446
- };
447
- return document.addEventListener("selectionchange", n), () => {
448
- clearTimeout(e), document.removeEventListener("selectionchange", n);
449
- };
450
- }, []);
451
- }, V = "lv_insights_st", ue = 15 * 60 * 1e3, le = (t = "https://cachefly.cachefly.net/1mb.test") => {
452
- const [e, n] = h(null);
453
- return f(() => {
454
- const o = localStorage.getItem(V);
455
- if (o) {
456
- const { speed: a, timestamp: i } = JSON.parse(o);
457
- if (Date.now() - i < ue) {
458
- n(a);
459
- return;
460
- }
461
- }
462
- let r = null;
463
- const s = async () => {
464
- const a = new ut("download_speed");
465
- if (a.acquireLock())
466
- try {
467
- const c = performance.now();
468
- await fetch(t, { cache: "no-store" });
469
- const d = (performance.now() - c) / 1e3, p = Math.round(8 / d);
470
- n(p), localStorage.setItem(
471
- V,
472
- JSON.stringify({ speed: p, timestamp: Date.now() })
473
- );
474
- } catch {
475
- } finally {
476
- a.releaseLock();
477
- }
478
- }, u = () => {
479
- document.removeEventListener("mousemove", u), document.removeEventListener("keydown", u), document.removeEventListener("scroll", u), r = setTimeout(s, 5e3);
480
- };
481
- return document.addEventListener("mousemove", u, { once: !0 }), document.addEventListener("keydown", u, { once: !0 }), document.addEventListener("scroll", u, { once: !0 }), () => {
482
- r && clearTimeout(r), document.removeEventListener("mousemove", u), document.removeEventListener("keydown", u), document.removeEventListener("scroll", u);
483
- };
484
- }, [t]), e;
485
- }, ye = ({ id: t, properties: e = {} }) => {
486
- const n = typeof window < "u" ? window.location.href : "", { client: o, audience: r } = y();
487
- f(() => {
488
- o && typeof window < "u" && (window.levo_client = o);
489
- }, [o]), f(() => {
490
- r && typeof window < "u" && (window.levo_audience = r);
491
- }, [r]), $t(), Pt(), ie();
492
- const s = le();
493
- f(() => {
494
- r != null && r.instance && s && r.track("user.speedtest", {
495
- speed: s,
496
- unit: "Mbps"
497
- });
498
- }, [r == null ? void 0 : r.instance, s]);
499
- const u = Dt();
500
- f(() => {
501
- r != null && r.instance && r.track("page.scroll", {
502
- resource: "page",
503
- identifier: t,
504
- percent: u.depth,
505
- speed_category: u.speedCategory
506
- });
507
- }, [
508
- r == null ? void 0 : r.instance,
509
- u.depth,
510
- u.speedCategory,
511
- t
512
- ]), ce(), ae(), f(() => {
513
- const i = () => {
514
- r == null || r.bounce({
515
- resource: "page",
516
- identifier: t
517
- });
518
- };
519
- return window && window.addEventListener("beforeunload", i), () => {
520
- window && window.removeEventListener("beforeunload", i);
521
- };
522
- }, [r, t]);
523
- const [a] = at();
524
- return f(() => {
525
- (a === C.TERMINATED || a === C.HIDDEN || a === C.UNKNOWN || a === C.FROZEN) && (r == null || r.bounce({
526
- resource: "page",
527
- identifier: t,
528
- state: a
529
- }));
530
- }, [a, r, t]), f(() => {
531
- (() => {
532
- o != null && o.insightsUrl && o.workspace && n && (r != null && r.instance ? r.instance.page({
533
- resource: "page",
534
- identifier: t
535
- }) : r == null || r.initiate({
536
- ...e,
537
- id: t,
538
- created_at: (/* @__PURE__ */ new Date()).toISOString()
539
- }));
540
- })();
541
- }, [o == null ? void 0 : o.insightsUrl, o == null ? void 0 : o.workspace, n]), f(() => {
542
- const i = {
543
- change: "form.change",
544
- submit: "form.submit",
545
- copy: "page.copy",
546
- cut: "page.copy"
547
- }, c = (d) => (p) => {
548
- const g = ee(p, d);
549
- g && (r == null || r.track(i[d], g));
550
- }, l = {
551
- change: c("change"),
552
- copy: c("copy"),
553
- cut: c("cut"),
554
- submit: c("submit")
555
- };
556
- return document.addEventListener("change", l.change), document.addEventListener("copy", l.copy), document.addEventListener("cut", l.cut), document.addEventListener("submit", l.submit), () => {
557
- document.removeEventListener("change", l.change), document.removeEventListener("copy", l.copy), document.removeEventListener("cut", l.cut), document.removeEventListener("submit", l.submit);
558
- };
559
- }, []), (!(o != null && o.insightsUrl) || !o.workspace || !o.workspace.startsWith("W")) && console.error(
560
- "[@levo-so/react] The utility could not be initialized, due to missing workspace, or endpoint for insights."
561
- ), null;
562
- };
563
- export {
564
- be as L,
565
- ve as a,
566
- ye as b
567
- };