@levo-so/react 0.1.32 → 0.1.34

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