@levo-so/react 0.1.25 → 0.1.27

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 (35) hide show
  1. package/dist/{CheckboxWidget-DZIHdYf_.js → CheckboxWidget-Bug2FXpG.js} +1 -1
  2. package/dist/{CollectionFormBuilder-C9clUECd.js → CollectionFormBuilder-DxViQE0w.js} +18 -18
  3. package/dist/{CurrencyWidget-BPjhIZC3.js → CurrencyWidget-BtjxmXgj.js} +1 -1
  4. package/dist/{DateTimeWidget-BHPInVmB.js → DateTimeWidget-Ds8g90-j.js} +1 -1
  5. package/dist/{DefaultFormVariant-DfM-Rnjm.js → DefaultFormVariant-ChnisPj2.js} +3 -3
  6. package/dist/{DropdownWidget-C0XD8XNO.js → DropdownWidget-B2o6wz-C.js} +1 -1
  7. package/dist/{EmailWidget-lfSEQ6Pw.js → EmailWidget-Cfyfy5OH.js} +2 -2
  8. package/dist/{FormCaptcha-QTqyITqd.js → FormCaptcha-BOjVusbv.js} +1 -1
  9. package/dist/{GeocoderWidget-PKGgCyAq.js → GeocoderWidget-B5TnEwp-.js} +2 -2
  10. package/dist/{MultiGeocoderWidget-B6tJY_NH.js → MultiGeocoderWidget-CF4HGkCg.js} +3 -3
  11. package/dist/{MultiTextWidget-BSlDBIxt.js → MultiTextWidget-fnzlopnN.js} +1 -1
  12. package/dist/{PhoneWidget-CZ613uWl.js → PhoneWidget-BVk5mhOm.js} +10 -10
  13. package/dist/{RadioWidget-q0_ddtou.js → RadioWidget-CouCg5aG.js} +2 -2
  14. package/dist/{RichTextWidget-D2D9-g4e.js → RichTextWidget-dqN--eKc.js} +2 -2
  15. package/dist/{Spinner-BnrQ9e_i.js → Spinner-CDMNP44S.js} +43 -39
  16. package/dist/{StepsFormVariant-eQuIooBH.js → StepsFormVariant-Buw3v2UB.js} +3 -3
  17. package/dist/{SwitchWidget-DJJNsK2d.js → SwitchWidget-BkBgr_nQ.js} +1 -1
  18. package/dist/{TextWidget-BUKw__Xy.js → TextWidget-I9pwxamg.js} +1 -1
  19. package/dist/{TextareaWidget-CImcGtRi.js → TextareaWidget-takl2qqW.js} +1 -1
  20. package/dist/{ToggleCheckboxWidget-BHJmd8lZ.js → ToggleCheckboxWidget-B8hL0ZhV.js} +1 -1
  21. package/dist/Tooltip-DoWyn3Ho.js +37 -0
  22. package/dist/{URLWidget-HUj8G1oS.js → URLWidget-C1S_yZ9J.js} +2 -2
  23. package/dist/{UploadWidget-Bzamcq6F.js → UploadWidget-D7USwx7q.js} +3 -3
  24. package/dist/audience/components/page.d.ts.map +1 -1
  25. package/dist/audience/index.js +1 -1
  26. package/dist/collection/index.js +1 -1
  27. package/dist/components/Dialog.d.ts.map +1 -1
  28. package/dist/components/Tooltip.d.ts.map +1 -1
  29. package/dist/components/index.js +2 -2
  30. package/dist/index.css +1 -1
  31. package/dist/index.js +4 -4
  32. package/dist/page-DgYcBSCH.js +273 -0
  33. package/package.json +4 -4
  34. package/dist/Tooltip-DPzkfrjl.js +0 -37
  35. package/dist/page-nOk3Od6l.js +0 -230
@@ -0,0 +1,273 @@
1
+ "use client";
2
+ import { j as W } from "./jsx-runtime-B6kdoens.js";
3
+ import { useEffect as g, useState as E } from "react";
4
+ import { useInView as G } from "react-intersection-observer";
5
+ import { u as _ } from "./LevoProvider-BAZy7_tP.js";
6
+ import { usePageLifecycle as F, LifecycleState as k } from "use-page-lifecycle";
7
+ const Oe = ({ id: e, properties: r = {} }) => {
8
+ const { audience: t } = _(), { ref: n, inView: o } = G({
9
+ triggerOnce: !0
10
+ });
11
+ return g(() => {
12
+ t != null && t.instance && o && (t == null || t.track("block.view", {
13
+ ...r,
14
+ resource: "block",
15
+ identifier: e
16
+ }));
17
+ }, [o]), /* @__PURE__ */ W.jsx("div", { ref: n, style: { height: "0px" } });
18
+ }, Ie = ({ event: e, properties: r }) => {
19
+ const { audience: t } = _();
20
+ return g(() => {
21
+ t != null && t.instance && (t == null || t.track(e, r));
22
+ }, [t == null ? void 0 : t.instance, e, r]), null;
23
+ };
24
+ function x(e) {
25
+ var r = typeof e;
26
+ return e != null && (r == "object" || r == "function");
27
+ }
28
+ var Y = typeof global == "object" && global && global.Object === Object && global, J = typeof self == "object" && self && self.Object === Object && self, $ = Y || J || Function("return this")(), j = function() {
29
+ return $.Date.now();
30
+ }, K = /\s/;
31
+ function V(e) {
32
+ for (var r = e.length; r-- && K.test(e.charAt(r)); )
33
+ ;
34
+ return r;
35
+ }
36
+ var z = /^\s+/;
37
+ function X(e) {
38
+ return e && e.slice(0, V(e) + 1).replace(z, "");
39
+ }
40
+ var L = $.Symbol, H = Object.prototype, Z = H.hasOwnProperty, q = H.toString, S = L ? L.toStringTag : void 0;
41
+ function Q(e) {
42
+ var r = Z.call(e, S), t = e[S];
43
+ try {
44
+ e[S] = void 0;
45
+ var n = !0;
46
+ } catch {
47
+ }
48
+ var o = q.call(e);
49
+ return n && (r ? e[S] = t : delete e[S]), o;
50
+ }
51
+ var ee = Object.prototype, te = ee.toString;
52
+ function ne(e) {
53
+ return te.call(e);
54
+ }
55
+ var re = "[object Null]", oe = "[object Undefined]", R = L ? L.toStringTag : void 0;
56
+ function ie(e) {
57
+ return e == null ? e === void 0 ? oe : re : R && R in Object(e) ? Q(e) : ne(e);
58
+ }
59
+ function se(e) {
60
+ return e != null && typeof e == "object";
61
+ }
62
+ var ae = "[object Symbol]";
63
+ function ce(e) {
64
+ return typeof e == "symbol" || se(e) && ie(e) == ae;
65
+ }
66
+ var D = NaN, le = /^[-+]0x[0-9a-f]+$/i, fe = /^0b[01]+$/i, ue = /^0o[0-7]+$/i, de = parseInt;
67
+ function U(e) {
68
+ if (typeof e == "number")
69
+ return e;
70
+ if (ce(e))
71
+ return D;
72
+ if (x(e)) {
73
+ var r = typeof e.valueOf == "function" ? e.valueOf() : e;
74
+ e = x(r) ? r + "" : r;
75
+ }
76
+ if (typeof e != "string")
77
+ return e === 0 ? e : +e;
78
+ e = X(e);
79
+ var t = fe.test(e);
80
+ return t || ue.test(e) ? de(e.slice(2), t ? 2 : 8) : le.test(e) ? D : +e;
81
+ }
82
+ var ge = "Expected a function", me = Math.max, be = Math.min;
83
+ function he(e, r, t) {
84
+ var n, o, i, f, a, l, u = 0, b = !1, h = !1, v = !0;
85
+ if (typeof e != "function")
86
+ throw new TypeError(ge);
87
+ r = U(r) || 0, x(t) && (b = !!t.leading, h = "maxWait" in t, i = h ? me(U(t.maxWait) || 0, r) : i, v = "trailing" in t ? !!t.trailing : v);
88
+ function d(s) {
89
+ var p = n, w = o;
90
+ return n = o = void 0, u = s, f = e.apply(w, p), f;
91
+ }
92
+ function T(s) {
93
+ return u = s, a = setTimeout(c, r), b ? d(s) : f;
94
+ }
95
+ function O(s) {
96
+ var p = s - l, w = s - u, N = r - p;
97
+ return h ? be(N, i - w) : N;
98
+ }
99
+ function m(s) {
100
+ var p = s - l, w = s - u;
101
+ return l === void 0 || p >= r || p < 0 || h && w >= i;
102
+ }
103
+ function c() {
104
+ var s = j();
105
+ if (m(s))
106
+ return C(s);
107
+ a = setTimeout(c, O(s));
108
+ }
109
+ function C(s) {
110
+ return a = void 0, v && n ? d(s) : (n = o = void 0, f);
111
+ }
112
+ function M() {
113
+ a !== void 0 && clearTimeout(a), u = 0, n = l = o = a = void 0;
114
+ }
115
+ function P() {
116
+ return a === void 0 ? f : C(j());
117
+ }
118
+ function I() {
119
+ var s = j(), p = m(s);
120
+ if (n = arguments, o = this, l = s, p) {
121
+ if (a === void 0)
122
+ return T(l);
123
+ if (h)
124
+ return clearTimeout(a), a = setTimeout(c, r), d(l);
125
+ }
126
+ return a === void 0 && (a = setTimeout(c, r)), f;
127
+ }
128
+ return I.cancel = M, I.flush = P, I;
129
+ }
130
+ const pe = () => {
131
+ const [e, r] = E(0), [t, n] = E(0), o = he((i) => {
132
+ n(i), r(i);
133
+ }, 250);
134
+ return g(() => {
135
+ const i = () => {
136
+ const f = window.scrollY, a = document.documentElement.scrollHeight, l = window.innerHeight, u = Math.round(
137
+ f / (a - l) * 100
138
+ );
139
+ u % 10 === 0 && u > t && o(u);
140
+ };
141
+ return window.addEventListener("scroll", i), () => window.removeEventListener("scroll", i);
142
+ }, [t]), e;
143
+ }, y = "lv_insights_ot", Te = () => {
144
+ const [e, r] = E(0);
145
+ return g(() => {
146
+ const t = Number(localStorage.getItem(y)) || 0;
147
+ r(t), localStorage.setItem(y, (t + 1).toString());
148
+ const n = (i) => {
149
+ i.key === y && r(Number(i.newValue) || 0);
150
+ };
151
+ window.addEventListener("storage", n);
152
+ const o = () => {
153
+ const i = Number(localStorage.getItem(y)) || 0;
154
+ i > 0 && localStorage.setItem(y, (i - 1).toString());
155
+ };
156
+ return window.addEventListener("beforeunload", o), () => {
157
+ window.removeEventListener("storage", n), window.removeEventListener("beforeunload", o);
158
+ };
159
+ }, []), e;
160
+ }, B = "lv_insights_ct", A = "lv_insights_at", ve = () => {
161
+ const [e, r] = E(null);
162
+ return g(() => {
163
+ let t = sessionStorage.getItem(B);
164
+ const n = JSON.parse(
165
+ localStorage.getItem(A) || "[]"
166
+ );
167
+ t && n.includes(t) && (t = null), t || (t = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(B, t)), n.includes(t) || (n.push(t), localStorage.setItem(
168
+ A,
169
+ JSON.stringify(n)
170
+ )), r(t);
171
+ const o = () => {
172
+ const i = n.filter(
173
+ (f) => f !== t
174
+ );
175
+ localStorage.setItem(
176
+ A,
177
+ JSON.stringify(i)
178
+ );
179
+ };
180
+ return window.addEventListener("beforeunload", o), () => {
181
+ window.removeEventListener("beforeunload", o);
182
+ };
183
+ }, []), e;
184
+ }, ke = ({ id: e, properties: r = {} }) => {
185
+ const { client: t, audience: n } = _(), [o, i] = E(), f = pe(), a = typeof window < "u" ? window.location.href : void 0;
186
+ Te(), ve(), g(() => {
187
+ a && i(a);
188
+ }, [a]), g(() => {
189
+ n != null && n.instance && f > 0 && n.track("page.scroll", {
190
+ resource: "page",
191
+ identifier: e,
192
+ percent: f
193
+ });
194
+ }, [n == null ? void 0 : n.instance, f, e]), g(() => {
195
+ const b = () => {
196
+ n == null || n.track("page.bounce", {
197
+ resource: "page",
198
+ identifier: e
199
+ });
200
+ };
201
+ return window && window.addEventListener("beforeunload", b), () => {
202
+ window && window.removeEventListener("beforeunload", b);
203
+ };
204
+ }, [n, e]);
205
+ const [l] = F();
206
+ g(() => {
207
+ (l === k.TERMINATED || l === k.HIDDEN || l === k.FROZEN) && (n == null || n.track("page.bounce", {
208
+ resource: "page",
209
+ identifier: e,
210
+ state: l
211
+ }));
212
+ }, [l, n, e]), g(() => {
213
+ (() => {
214
+ t != null && t.insightsUrl && t.workspace && o && (n != null && n.instance ? n.instance.page({
215
+ resource: "page",
216
+ identifier: e
217
+ }) : n == null || n.initiate({
218
+ ...r,
219
+ id: e
220
+ }));
221
+ })();
222
+ }, [t == null ? void 0 : t.insightsUrl, t == null ? void 0 : t.workspace, o]);
223
+ let u = !1;
224
+ return g(() => {
225
+ const b = (h) => {
226
+ if (u)
227
+ return;
228
+ if (u = !0, h.target instanceof HTMLElement) {
229
+ const d = h.target;
230
+ let T = "";
231
+ try {
232
+ if (T = d == null ? void 0 : d.getAttribute("href"), !T) {
233
+ let m = 0, c = d.parentNode;
234
+ for (; c && m < 10; ) {
235
+ if (c != null && c.getAttribute("href")) {
236
+ T = c == null ? void 0 : c.getAttribute("href");
237
+ break;
238
+ }
239
+ c = c.parentNode, m++;
240
+ }
241
+ }
242
+ } catch {
243
+ }
244
+ const O = Array.from(d.attributes).reduce(
245
+ (m, c) => (["class"].includes(c.name) || (m[c.name] = c.value), m),
246
+ {}
247
+ );
248
+ n == null || n.track("page.click", {
249
+ element: d.tagName,
250
+ text: d.innerText,
251
+ href: T || void 0,
252
+ attributes: O
253
+ });
254
+ }
255
+ const v = setTimeout(() => {
256
+ u = !1;
257
+ }, 0);
258
+ return () => {
259
+ clearTimeout(v);
260
+ };
261
+ };
262
+ return document.addEventListener("click", b), () => {
263
+ document.removeEventListener("click", b);
264
+ };
265
+ }, [n]), (!(t != null && t.insightsUrl) || !t.workspace || !t.workspace.startsWith("W")) && console.error(
266
+ "[@levo-so/audience] The utility could not be initialized, due to missing workspace, or endpoint for insights."
267
+ ), null;
268
+ };
269
+ export {
270
+ Oe as L,
271
+ Ie as a,
272
+ ke as b
273
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/react",
3
- "version": "0.1.25",
3
+ "version": "0.1.27",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo suite for React based applications",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "peerDependencies": {
17
17
  "react": ">=18",
18
18
  "react-dom": ">=18",
19
- "@levo-so/core": "0.1.25"
19
+ "@levo-so/core": "0.1.27"
20
20
  },
21
21
  "dependencies": {
22
22
  "@radix-ui/react-checkbox": "1.1.1",
@@ -90,9 +90,9 @@
90
90
  "typescript": "5.5.4",
91
91
  "vite": "5.4.3",
92
92
  "vite-plugin-dts": "4.1.0",
93
+ "@levo/eslint-config": "0.0.0",
93
94
  "@levo/tw-config": "0.0.0",
94
- "@levo/ts-config": "0.0.0",
95
- "@levo/eslint-config": "0.0.0"
95
+ "@levo/ts-config": "0.0.0"
96
96
  },
97
97
  "main": "./dist/index.js",
98
98
  "module": "./dist/index.js",
@@ -1,37 +0,0 @@
1
- "use client";
2
- import { j as t } from "./jsx-runtime-B6kdoens.js";
3
- import * as o from "@radix-ui/react-tooltip";
4
- import * as m from "react";
5
- import { c as l } from "./cn-C9QoOYNG.js";
6
- const T = o.Provider, p = o.Root, c = o.Trigger, u = o.Portal, r = m.forwardRef(({ className: a, sideOffset: e = 4, ...s }, i) => /* @__PURE__ */ t.jsx(
7
- o.Content,
8
- {
9
- ref: i,
10
- sideOffset: e,
11
- className: l(
12
- "z-50 overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-xs text-popover-foreground shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2",
13
- a
14
- ),
15
- ...s
16
- }
17
- ));
18
- r.displayName = o.Content.displayName;
19
- const g = ({
20
- children: a,
21
- label: e,
22
- labelClassName: s,
23
- contentClassName: i,
24
- asChild: d = !0,
25
- contentProps: n = {}
26
- }) => /* @__PURE__ */ t.jsxs(p, { children: [
27
- e && /* @__PURE__ */ t.jsx(r, { className: s, ...n, children: /* @__PURE__ */ t.jsx("p", { className: i, children: e }) }),
28
- /* @__PURE__ */ t.jsx(c, { asChild: d, children: a })
29
- ] });
30
- export {
31
- g as S,
32
- p as T,
33
- c as a,
34
- r as b,
35
- T as c,
36
- u as d
37
- };
@@ -1,230 +0,0 @@
1
- "use client";
2
- import { j as H } from "./jsx-runtime-B6kdoens.js";
3
- import { useEffect as u, useState as h } from "react";
4
- import { useInView as G } from "react-intersection-observer";
5
- import { u as j } from "./LevoProvider-BAZy7_tP.js";
6
- import { usePageLifecycle as F, LifecycleState as O } from "use-page-lifecycle";
7
- const Le = ({ id: e, properties: r = {} }) => {
8
- const { audience: t } = j(), { ref: n, inView: o } = G({
9
- triggerOnce: !0
10
- });
11
- return u(() => {
12
- t != null && t.instance && o && (t == null || t.track("block.view", {
13
- ...r,
14
- resource: "block",
15
- identifier: e
16
- }));
17
- }, [o]), /* @__PURE__ */ H.jsx("div", { ref: n, style: { height: "0px" } });
18
- }, Ie = ({ event: e, properties: r }) => {
19
- const { audience: t } = j();
20
- return u(() => {
21
- t != null && t.instance && (t == null || t.track(e, r));
22
- }, [t == null ? void 0 : t.instance, e, r]), null;
23
- };
24
- function I(e) {
25
- var r = typeof e;
26
- return e != null && (r == "object" || r == "function");
27
- }
28
- var Y = typeof global == "object" && global && global.Object === Object && global, J = typeof self == "object" && self && self.Object === Object && self, U = Y || J || Function("return this")(), E = function() {
29
- return U.Date.now();
30
- }, K = /\s/;
31
- function V(e) {
32
- for (var r = e.length; r-- && K.test(e.charAt(r)); )
33
- ;
34
- return r;
35
- }
36
- var z = /^\s+/;
37
- function X(e) {
38
- return e && e.slice(0, V(e) + 1).replace(z, "");
39
- }
40
- var w = U.Symbol, B = Object.prototype, Z = B.hasOwnProperty, q = B.toString, b = w ? w.toStringTag : void 0;
41
- function Q(e) {
42
- var r = Z.call(e, b), t = e[b];
43
- try {
44
- e[b] = void 0;
45
- var n = !0;
46
- } catch {
47
- }
48
- var o = q.call(e);
49
- return n && (r ? e[b] = t : delete e[b]), o;
50
- }
51
- var ee = Object.prototype, te = ee.toString;
52
- function ne(e) {
53
- return te.call(e);
54
- }
55
- var re = "[object Null]", oe = "[object Undefined]", N = w ? w.toStringTag : void 0;
56
- function ie(e) {
57
- return e == null ? e === void 0 ? oe : re : N && N in Object(e) ? Q(e) : ne(e);
58
- }
59
- function se(e) {
60
- return e != null && typeof e == "object";
61
- }
62
- var ae = "[object Symbol]";
63
- function ce(e) {
64
- return typeof e == "symbol" || se(e) && ie(e) == ae;
65
- }
66
- var R = NaN, fe = /^[-+]0x[0-9a-f]+$/i, le = /^0b[01]+$/i, ue = /^0o[0-7]+$/i, de = parseInt;
67
- function C(e) {
68
- if (typeof e == "number")
69
- return e;
70
- if (ce(e))
71
- return R;
72
- if (I(e)) {
73
- var r = typeof e.valueOf == "function" ? e.valueOf() : e;
74
- e = I(r) ? r + "" : r;
75
- }
76
- if (typeof e != "string")
77
- return e === 0 ? e : +e;
78
- e = X(e);
79
- var t = le.test(e);
80
- return t || ue.test(e) ? de(e.slice(2), t ? 2 : 8) : fe.test(e) ? R : +e;
81
- }
82
- var ge = "Expected a function", me = Math.max, be = Math.min;
83
- function pe(e, r, t) {
84
- var n, o, i, f, a, c, l = 0, k = !1, g = !1, v = !0;
85
- if (typeof e != "function")
86
- throw new TypeError(ge);
87
- r = C(r) || 0, I(t) && (k = !!t.leading, g = "maxWait" in t, i = g ? me(C(t.maxWait) || 0, r) : i, v = "trailing" in t ? !!t.trailing : v);
88
- function S(s) {
89
- var d = n, m = o;
90
- return n = o = void 0, l = s, f = e.apply(m, d), f;
91
- }
92
- function $(s) {
93
- return l = s, a = setTimeout(T, r), k ? S(s) : f;
94
- }
95
- function P(s) {
96
- var d = s - c, m = s - l, A = r - d;
97
- return g ? be(A, i - m) : A;
98
- }
99
- function x(s) {
100
- var d = s - c, m = s - l;
101
- return c === void 0 || d >= r || d < 0 || g && m >= i;
102
- }
103
- function T() {
104
- var s = E();
105
- if (x(s))
106
- return _(s);
107
- a = setTimeout(T, P(s));
108
- }
109
- function _(s) {
110
- return a = void 0, v && n ? S(s) : (n = o = void 0, f);
111
- }
112
- function W() {
113
- a !== void 0 && clearTimeout(a), l = 0, n = c = o = a = void 0;
114
- }
115
- function M() {
116
- return a === void 0 ? f : _(E());
117
- }
118
- function y() {
119
- var s = E(), d = x(s);
120
- if (n = arguments, o = this, c = s, d) {
121
- if (a === void 0)
122
- return $(c);
123
- if (g)
124
- return clearTimeout(a), a = setTimeout(T, r), S(c);
125
- }
126
- return a === void 0 && (a = setTimeout(T, r)), f;
127
- }
128
- return y.cancel = W, y.flush = M, y;
129
- }
130
- const he = () => {
131
- const [e, r] = h(0), [t, n] = h(0), o = pe((i) => {
132
- n(i), r(i);
133
- }, 250);
134
- return u(() => {
135
- const i = () => {
136
- const f = window.scrollY, a = document.documentElement.scrollHeight, c = window.innerHeight, l = Math.round(
137
- f / (a - c) * 100
138
- );
139
- l % 10 === 0 && l > t && o(l);
140
- };
141
- return window.addEventListener("scroll", i), () => window.removeEventListener("scroll", i);
142
- }, [t]), e;
143
- }, p = "lv_insights_ot", Te = () => {
144
- const [e, r] = h(0);
145
- return u(() => {
146
- const t = Number(localStorage.getItem(p)) || 0;
147
- r(t), localStorage.setItem(p, (t + 1).toString());
148
- const n = (i) => {
149
- i.key === p && r(Number(i.newValue) || 0);
150
- };
151
- window.addEventListener("storage", n);
152
- const o = () => {
153
- const i = Number(localStorage.getItem(p)) || 0;
154
- i > 0 && localStorage.setItem(p, (i - 1).toString());
155
- };
156
- return window.addEventListener("beforeunload", o), () => {
157
- window.removeEventListener("storage", n), window.removeEventListener("beforeunload", o);
158
- };
159
- }, []), e;
160
- }, D = "lv_insights_ct", L = "lv_insights_at", we = () => {
161
- const [e, r] = h(null);
162
- return u(() => {
163
- let t = sessionStorage.getItem(D);
164
- const n = JSON.parse(
165
- localStorage.getItem(L) || "[]"
166
- );
167
- t && n.includes(t) && (t = null), t || (t = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(D, t)), n.includes(t) || (n.push(t), localStorage.setItem(
168
- L,
169
- JSON.stringify(n)
170
- )), r(t);
171
- const o = () => {
172
- const i = n.filter(
173
- (f) => f !== t
174
- );
175
- localStorage.setItem(
176
- L,
177
- JSON.stringify(i)
178
- );
179
- };
180
- return window.addEventListener("beforeunload", o), () => {
181
- window.removeEventListener("beforeunload", o);
182
- };
183
- }, []), e;
184
- }, je = ({ id: e, properties: r = {} }) => {
185
- const { client: t, audience: n } = j(), [o, i] = h(), f = he(), a = typeof window < "u" ? window.location.href : void 0;
186
- Te(), we(), u(() => {
187
- a && i(a);
188
- }, [a]), u(() => {
189
- n != null && n.instance && f > 0 && n.track("page.scroll", {
190
- resource: "page",
191
- identifier: e,
192
- percent: f
193
- });
194
- }, [n == null ? void 0 : n.instance, f, e]), u(() => {
195
- const l = () => {
196
- n == null || n.bounce({
197
- resource: "page",
198
- identifier: e
199
- });
200
- };
201
- return window && window.addEventListener("beforeunload", l), () => {
202
- window && window.removeEventListener("beforeunload", l);
203
- };
204
- }, [n, e]);
205
- const [c] = F();
206
- return u(() => {
207
- (c === O.TERMINATED || c === O.HIDDEN || c === O.FROZEN) && (n == null || n.bounce({
208
- resource: "page",
209
- identifier: e,
210
- state: c
211
- }));
212
- }, [c, n, e]), u(() => {
213
- (() => {
214
- t != null && t.insightsUrl && t.workspace && o && (n != null && n.instance ? n.instance.page({
215
- resource: "page",
216
- identifier: e
217
- }) : n == null || n.initiate({
218
- ...r,
219
- id: e
220
- }));
221
- })();
222
- }, [t == null ? void 0 : t.insightsUrl, t == null ? void 0 : t.workspace, o]), (!(t != null && t.insightsUrl) || !t.workspace || !t.workspace.startsWith("W")) && console.error(
223
- "[@levo-so/audience] The utility could not be initialized, due to missing workspace, or endpoint for insights."
224
- ), null;
225
- };
226
- export {
227
- Le as L,
228
- Ie as a,
229
- je as b
230
- };