@levo-so/react 0.1.31 → 0.1.33

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 (36) 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/usePerformanceMetrics.d.ts +9 -0
  24. package/dist/audience/hooks/usePerformanceMetrics.d.ts.map +1 -0
  25. package/dist/audience/index.js +1 -1
  26. package/dist/audience/utils/autocapture.d.ts.map +1 -1
  27. package/dist/collection/index.js +1 -1
  28. package/dist/index.js +9 -9
  29. package/dist/membership/index.js +1 -1
  30. package/dist/page-BVeU7Dl9.js +478 -0
  31. package/dist/providers/LevoProvider.d.ts.map +1 -1
  32. package/dist/providers/index.d.ts +2 -0
  33. package/dist/providers/index.js +169 -0
  34. package/package.json +8 -4
  35. package/dist/LevoProvider-BAZy7_tP.js +0 -223
  36. package/dist/page-jWvzWjyk.js +0 -452
@@ -1,223 +0,0 @@
1
- "use client";
2
- var j = Object.defineProperty;
3
- var D = (l, o, t) => o in l ? j(l, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[o] = t;
4
- var p = (l, o, t) => D(l, typeof o != "symbol" ? o + "" : o, t);
5
- import { j as B } from "./jsx-runtime-B6kdoens.js";
6
- import k from "wretch";
7
- import { createContext as G, useContext as W } from "react";
8
- var q = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
- function z(l) {
10
- return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l;
11
- }
12
- var T = class {
13
- constructor(l) {
14
- p(this, "client");
15
- this.client = l;
16
- }
17
- }, F = { exports: {} };
18
- (function(l) {
19
- (function(o, t) {
20
- l.exports ? l.exports = t() : o.log = t();
21
- })(q, function() {
22
- var o = function() {
23
- }, t = "undefined", L = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), g = [
24
- "trace",
25
- "debug",
26
- "info",
27
- "warn",
28
- "error"
29
- ], f = {}, a = null;
30
- function b(n, i) {
31
- var e = n[i];
32
- if (typeof e.bind == "function")
33
- return e.bind(n);
34
- try {
35
- return Function.prototype.bind.call(e, n);
36
- } catch {
37
- return function() {
38
- return Function.prototype.apply.apply(e, [n, arguments]);
39
- };
40
- }
41
- }
42
- function S() {
43
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
44
- }
45
- function U(n) {
46
- return n === "debug" && (n = "log"), typeof console === t ? !1 : n === "trace" && L ? S : console[n] !== void 0 ? b(console, n) : console.log !== void 0 ? b(console, "log") : o;
47
- }
48
- function d() {
49
- for (var n = this.getLevel(), i = 0; i < g.length; i++) {
50
- var e = g[i];
51
- this[e] = i < n ? o : this.methodFactory(e, n, this.name);
52
- }
53
- if (this.log = this.debug, typeof console === t && n < this.levels.SILENT)
54
- return "No console available for logging";
55
- }
56
- function A(n) {
57
- return function() {
58
- typeof console !== t && (d.call(this), this[n].apply(this, arguments));
59
- };
60
- }
61
- function M(n, i, e) {
62
- return U(n) || A.apply(this, arguments);
63
- }
64
- function E(n, i) {
65
- var e = this, y, m, c, u = "loglevel";
66
- typeof n == "string" ? u += ":" + n : typeof n == "symbol" && (u = void 0);
67
- function O(r) {
68
- var s = (g[r] || "silent").toUpperCase();
69
- if (!(typeof window === t || !u)) {
70
- try {
71
- window.localStorage[u] = s;
72
- return;
73
- } catch {
74
- }
75
- try {
76
- window.document.cookie = encodeURIComponent(u) + "=" + s + ";";
77
- } catch {
78
- }
79
- }
80
- }
81
- function C() {
82
- var r;
83
- if (!(typeof window === t || !u)) {
84
- try {
85
- r = window.localStorage[u];
86
- } catch {
87
- }
88
- if (typeof r === t)
89
- try {
90
- var s = window.document.cookie, h = encodeURIComponent(u), I = s.indexOf(h + "=");
91
- I !== -1 && (r = /^([^;]+)/.exec(
92
- s.slice(I + h.length + 1)
93
- )[1]);
94
- } catch {
95
- }
96
- return e.levels[r] === void 0 && (r = void 0), r;
97
- }
98
- }
99
- function P() {
100
- if (!(typeof window === t || !u)) {
101
- try {
102
- window.localStorage.removeItem(u);
103
- } catch {
104
- }
105
- try {
106
- window.document.cookie = encodeURIComponent(u) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
107
- } catch {
108
- }
109
- }
110
- }
111
- function v(r) {
112
- var s = r;
113
- if (typeof s == "string" && e.levels[s.toUpperCase()] !== void 0 && (s = e.levels[s.toUpperCase()]), typeof s == "number" && s >= 0 && s <= e.levels.SILENT)
114
- return s;
115
- throw new TypeError("log.setLevel() called with invalid level: " + r);
116
- }
117
- e.name = n, e.levels = {
118
- TRACE: 0,
119
- DEBUG: 1,
120
- INFO: 2,
121
- WARN: 3,
122
- ERROR: 4,
123
- SILENT: 5
124
- }, e.methodFactory = i || M, e.getLevel = function() {
125
- return c ?? m ?? y;
126
- }, e.setLevel = function(r, s) {
127
- return c = v(r), s !== !1 && O(c), d.call(e);
128
- }, e.setDefaultLevel = function(r) {
129
- m = v(r), C() || e.setLevel(r, !1);
130
- }, e.resetLevel = function() {
131
- c = null, P(), d.call(e);
132
- }, e.enableAll = function(r) {
133
- e.setLevel(e.levels.TRACE, r);
134
- }, e.disableAll = function(r) {
135
- e.setLevel(e.levels.SILENT, r);
136
- }, e.rebuild = function() {
137
- if (a !== e && (y = v(a.getLevel())), d.call(e), a === e)
138
- for (var r in f)
139
- f[r].rebuild();
140
- }, y = v(
141
- a ? a.getLevel() : "WARN"
142
- );
143
- var x = C();
144
- x != null && (c = v(x)), d.call(e);
145
- }
146
- a = new E(), a.getLogger = function(i) {
147
- if (typeof i != "symbol" && typeof i != "string" || i === "")
148
- throw new TypeError("You must supply a name when creating a logger.");
149
- var e = f[i];
150
- return e || (e = f[i] = new E(
151
- i,
152
- a.methodFactory
153
- )), e;
154
- };
155
- var N = typeof window !== t ? window.log : void 0;
156
- return a.noConflict = function() {
157
- return typeof window !== t && window.log === a && (window.log = N), a;
158
- }, a.getLoggers = function() {
159
- return f;
160
- }, a.default = a, a;
161
- });
162
- })(F);
163
- var J = F.exports;
164
- const w = /* @__PURE__ */ z(J);
165
- var K = class extends T {
166
- constructor(o) {
167
- super(o);
168
- p(this, "logger", w);
169
- w.setLevel(
170
- this.client.NODE_ENV === "production" ? w.levels.INFO : w.levels.DEBUG
171
- ), w.methodFactory = (t) => (L, g = {}) => {
172
- k().url(`${this.client.apiUrl}/v1/apm/logs/json`).post({
173
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
174
- level: t,
175
- message: L,
176
- ...g
177
- }).res().catch((f) => console.error(f));
178
- };
179
- }
180
- error(...o) {
181
- return this.logger.error(...o);
182
- }
183
- log(...o) {
184
- return this.logger.debug(...o);
185
- }
186
- info(...o) {
187
- return this.logger.info(...o);
188
- }
189
- warn(...o) {
190
- return this.logger.warn(...o);
191
- }
192
- }, V = class extends T {
193
- constructor() {
194
- super(...arguments);
195
- p(this, "mediaBulkUpload", (o, t = {}) => this.client.fetch.url("/v1/assets/media/bulk").options(t).post(o).json());
196
- p(this, "getAllMedia", async (o = {}) => await this.client.fetch.url("/v1/assets/media/query").post(o).json());
197
- }
198
- };
199
- const R = G(null), X = ({
200
- children: l,
201
- client: o,
202
- ...t
203
- }) => /* @__PURE__ */ B.jsx(
204
- R.Provider,
205
- {
206
- value: {
207
- client: o,
208
- media: new V(o),
209
- logger: new K(o),
210
- ...t
211
- },
212
- children: l
213
- }
214
- ), Z = () => {
215
- const l = W(R);
216
- if (!l)
217
- throw new Error("useLevo must be used within LevoProvider");
218
- return l;
219
- };
220
- export {
221
- X as L,
222
- Z as u
223
- };
@@ -1,452 +0,0 @@
1
- "use client";
2
- var nt = Object.defineProperty;
3
- var rt = (t, n, e) => n in t ? nt(t, n, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[n] = e;
4
- var U = (t, n, e) => rt(t, typeof n != "symbol" ? n + "" : n, e);
5
- import { j as ot } from "./jsx-runtime-B6kdoens.js";
6
- import { useEffect as d, useState as T } from "react";
7
- import { useInView as st } from "react-intersection-observer";
8
- import { u as x } from "./LevoProvider-BAZy7_tP.js";
9
- import { usePageLifecycle as it, LifecycleState as v } from "use-page-lifecycle";
10
- const fe = ({ id: t, properties: n = {} }) => {
11
- const { audience: e } = x(), { ref: r, inView: o } = st({
12
- triggerOnce: !0
13
- });
14
- return d(() => {
15
- e != null && e.instance && o && (e == null || e.track("block.view", {
16
- ...n,
17
- resource: "block",
18
- identifier: t
19
- }));
20
- }, [o]), /* @__PURE__ */ ot.jsx("div", { ref: r, style: { height: "0px" } });
21
- }, de = ({ event: t, properties: n }) => {
22
- const { audience: e } = x();
23
- return d(() => {
24
- e != null && e.instance && (e == null || e.track(t, n));
25
- }, [e == null ? void 0 : e.instance, t, n]), null;
26
- };
27
- function R(t) {
28
- var n = typeof t;
29
- return t != null && (n == "object" || n == "function");
30
- }
31
- var ct = typeof global == "object" && global && global.Object === Object && global, at = typeof self == "object" && self && self.Object === Object && self, W = ct || at || Function("return this")(), O = function() {
32
- return W.Date.now();
33
- }, ut = /\s/;
34
- function ft(t) {
35
- for (var n = t.length; n-- && ut.test(t.charAt(n)); )
36
- ;
37
- return n;
38
- }
39
- var dt = /^\s+/;
40
- function lt(t) {
41
- return t && t.slice(0, ft(t) + 1).replace(dt, "");
42
- }
43
- var E = W.Symbol, G = Object.prototype, gt = G.hasOwnProperty, pt = G.toString, w = E ? E.toStringTag : void 0;
44
- function mt(t) {
45
- var n = gt.call(t, w), e = t[w];
46
- try {
47
- t[w] = void 0;
48
- var r = !0;
49
- } catch {
50
- }
51
- var o = pt.call(t);
52
- return r && (n ? t[w] = e : delete t[w]), o;
53
- }
54
- var ht = Object.prototype, bt = ht.toString;
55
- function wt(t) {
56
- return bt.call(t);
57
- }
58
- var yt = "[object Null]", St = "[object Undefined]", M = E ? E.toStringTag : void 0;
59
- function vt(t) {
60
- return t == null ? t === void 0 ? St : yt : M && M in Object(t) ? mt(t) : wt(t);
61
- }
62
- function Tt(t) {
63
- return t != null && typeof t == "object";
64
- }
65
- var Et = "[object Symbol]";
66
- function Lt(t) {
67
- return typeof t == "symbol" || Tt(t) && vt(t) == Et;
68
- }
69
- var F = NaN, xt = /^[-+]0x[0-9a-f]+$/i, Ct = /^0b[01]+$/i, kt = /^0o[0-7]+$/i, Nt = parseInt;
70
- function B(t) {
71
- if (typeof t == "number")
72
- return t;
73
- if (Lt(t))
74
- return F;
75
- if (R(t)) {
76
- var n = typeof t.valueOf == "function" ? t.valueOf() : t;
77
- t = R(n) ? n + "" : n;
78
- }
79
- if (typeof t != "string")
80
- return t === 0 ? t : +t;
81
- t = lt(t);
82
- var e = Ct.test(t);
83
- return e || kt.test(t) ? Nt(t.slice(2), e ? 2 : 8) : xt.test(t) ? F : +t;
84
- }
85
- var Ot = "Expected a function", _t = Math.max, It = Math.min;
86
- function Rt(t, n, e) {
87
- var r, o, i, a, s, c, u = 0, h = !1, g = !1, p = !0;
88
- if (typeof t != "function")
89
- throw new TypeError(Ot);
90
- n = B(n) || 0, R(e) && (h = !!e.leading, g = "maxWait" in e, i = g ? _t(B(e.maxWait) || 0, n) : i, p = "trailing" in e ? !!e.trailing : p);
91
- function k(f) {
92
- var l = r, b = o;
93
- return r = o = void 0, u = f, a = t.apply(b, l), a;
94
- }
95
- function q(f) {
96
- return u = f, s = setTimeout(S, n), h ? k(f) : a;
97
- }
98
- function Q(f) {
99
- var l = f - c, b = f - u, P = n - l;
100
- return g ? It(P, i - b) : P;
101
- }
102
- function $(f) {
103
- var l = f - c, b = f - u;
104
- return c === void 0 || l >= n || l < 0 || g && b >= i;
105
- }
106
- function S() {
107
- var f = O();
108
- if ($(f))
109
- return D(f);
110
- s = setTimeout(S, Q(f));
111
- }
112
- function D(f) {
113
- return s = void 0, p && r ? k(f) : (r = o = void 0, a);
114
- }
115
- function tt() {
116
- s !== void 0 && clearTimeout(s), u = 0, r = c = o = s = void 0;
117
- }
118
- function et() {
119
- return s === void 0 ? a : D(O());
120
- }
121
- function N() {
122
- var f = O(), l = $(f);
123
- if (r = arguments, o = this, c = f, l) {
124
- if (s === void 0)
125
- return q(c);
126
- if (g)
127
- return clearTimeout(s), s = setTimeout(S, n), k(c);
128
- }
129
- return s === void 0 && (s = setTimeout(S, n)), a;
130
- }
131
- return N.cancel = tt, N.flush = et, N;
132
- }
133
- const At = () => {
134
- const [t, n] = T(0), [e, r] = T(0), o = Rt((i) => {
135
- r(i), n(i);
136
- }, 250);
137
- return d(() => {
138
- const i = () => {
139
- const a = window.scrollY, s = document.documentElement.scrollHeight, c = window.innerHeight, u = Math.round(
140
- a / (s - c) * 100
141
- );
142
- u % 10 === 0 && u > e && o(u);
143
- };
144
- return window.addEventListener("scroll", i), () => window.removeEventListener("scroll", i);
145
- }, [e]), t;
146
- }, y = "lv_insights_ot", jt = () => {
147
- const [t, n] = T(0);
148
- return d(() => {
149
- const e = Number(localStorage.getItem(y)) || 0;
150
- n(e), localStorage.setItem(y, (e + 1).toString());
151
- const r = (i) => {
152
- i.key === y && n(Number(i.newValue) || 0);
153
- };
154
- window.addEventListener("storage", r);
155
- const o = () => {
156
- const i = Number(localStorage.getItem(y)) || 0;
157
- i > 0 && localStorage.setItem(y, (i - 1).toString());
158
- };
159
- return window.addEventListener("beforeunload", o), () => {
160
- window.removeEventListener("storage", r), window.removeEventListener("beforeunload", o);
161
- };
162
- }, []), t;
163
- }, H = "lv_insights_ct", _ = "lv_insights_at", $t = () => {
164
- const [t, n] = T(null);
165
- return d(() => {
166
- let e = sessionStorage.getItem(H);
167
- const r = JSON.parse(
168
- localStorage.getItem(_) || "[]"
169
- );
170
- e && r.includes(e) && (e = null), e || (e = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(H, e)), r.includes(e) || (r.push(e), localStorage.setItem(
171
- _,
172
- JSON.stringify(r)
173
- )), n(e);
174
- const o = () => {
175
- const i = r.filter(
176
- (a) => a !== e
177
- );
178
- localStorage.setItem(
179
- _,
180
- JSON.stringify(i)
181
- );
182
- };
183
- return window.addEventListener("beforeunload", o), () => {
184
- window.removeEventListener("beforeunload", o);
185
- };
186
- }, []), t;
187
- }, L = (t) => Object.prototype.toString.call(t) == "[object String]", Dt = (t, n) => t.indexOf(n) !== -1, C = (t) => t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), K = (t) => t === void 0, Pt = (t) => t === null, V = (t) => K(t) || Pt(t), Y = (t) => !!t && (t == null ? void 0 : t.nodeType) === 3;
188
- function Ut(t) {
189
- return !!t && (t == null ? void 0 : t.nodeType) === 1;
190
- }
191
- function Mt(t, n) {
192
- return !!t && !!(t != null && t.tagName) && (t == null ? void 0 : t.tagName.toLowerCase()) === n.toLowerCase();
193
- }
194
- function Ft(t) {
195
- return t ? C(t).split(/\s+/) : [];
196
- }
197
- function Bt(t) {
198
- let n = "";
199
- switch (typeof (t == null ? void 0 : t.className)) {
200
- case "string":
201
- n = t == null ? void 0 : t.className;
202
- break;
203
- case "object":
204
- n = (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")) || "";
205
- break;
206
- default:
207
- n = "";
208
- }
209
- return Ft(n);
210
- }
211
- const m = (t, n = 255) => V(t) ? "" : C(t).split(/(\s+)/).filter((e) => j(e)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, n), A = (t) => {
212
- let n = "";
213
- if (Gt(t) && // !isSensitiveElement(el) &&
214
- (t != null && t.childNodes) && (t != null && t.childNodes.length))
215
- for (const e of t == null ? void 0 : t.childNodes)
216
- Y(e) && e.textContent && (n += m(e.textContent) ?? "");
217
- return C(n);
218
- }, Ht = (t) => {
219
- var n, e;
220
- return K(t.target) ? (t == null ? void 0 : t.srcElement) || null : (n = t == null ? void 0 : t.target) != null && n.shadowRoot ? ((e = t == null ? void 0 : t.composedPath()) == null ? void 0 : e[0]) || null : (t == null ? void 0 : t.target) || null;
221
- }, Wt = (t, n) => {
222
- if (!window || !t || Mt(t, "html") || !Ut(t))
223
- return !1;
224
- const e = window.getComputedStyle(t);
225
- if (e && e.getPropertyValue("cursor") === "pointer" && n.type === "click")
226
- return !0;
227
- switch (t == null ? void 0 : t.tagName.toLowerCase()) {
228
- case "html":
229
- return !1;
230
- case "form":
231
- return n.type === "submit";
232
- case "input":
233
- case "select":
234
- case "textarea":
235
- return ["change", "click"].includes(n.type);
236
- default:
237
- return n.type === "click";
238
- }
239
- };
240
- function Gt(t) {
241
- if (Dt(Bt(t), "ph-include"))
242
- return !0;
243
- const n = t.type || "";
244
- if (L(n))
245
- switch (n.toLowerCase()) {
246
- case "hidden":
247
- return !1;
248
- case "password":
249
- return !1;
250
- }
251
- const e = t.name || (t == null ? void 0 : t.id) || "";
252
- return !(L(e) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(e.replace(/[^a-zA-Z0-9]/g, "")));
253
- }
254
- const J = "(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})", Kt = new RegExp(`^(?:${J})$`), Vt = new RegExp(J), X = "\\d{3}-?\\d{2}-?\\d{4}", Yt = new RegExp(`^(${X})$`), Jt = new RegExp(`(${X})`), j = (t, n = !0) => !(V(t) || L(t) && (t = C(t), (n ? Kt : Vt).test((t || "").replace(/[- ]/g, "")) || (n ? Yt : Jt).test(t))), Xt = (t) => L(t) ? t.substring(0, 10) === "_ngcontent" || t.substring(0, 7) === "_nghost" : !1, zt = (t) => {
255
- let n = A(t);
256
- return n = `${n} ${z(t)}`.trim(), j(n) ? n : "";
257
- };
258
- function z(t) {
259
- var e;
260
- let n = "";
261
- if (t != null && t.childNodes.length) {
262
- for (const r of t.childNodes)
263
- if (r && ((e = r.tagName) == null ? void 0 : e.toLowerCase()) === "span")
264
- try {
265
- const o = A(r);
266
- n = `${n} ${o}`.trim(), r != null && r.childNodes.length && (n = `${n} ${z(r)}`.trim());
267
- } catch {
268
- }
269
- }
270
- return n;
271
- }
272
- const Zt = ["input", "textarea", "select"], Z = (t) => {
273
- var o, i, a;
274
- const n = t.tagName.toLowerCase(), e = {
275
- element: n
276
- };
277
- n.toLowerCase() === "a" || n.toLowerCase() === "button" ? e.text = zt(t) : e.text = A(t);
278
- const r = Array.from(t.attributes).reduce(
279
- (s, c) => {
280
- if (j(c.value) && !Xt(c.name)) {
281
- if (c.name === "class")
282
- return s;
283
- s[c.name] = typeof (c == null ? void 0 : c.value) == "string" ? m(c.value) : c.value;
284
- }
285
- return s;
286
- },
287
- {}
288
- );
289
- if (e.attributes = r, Zt.includes(n) || (t == null ? void 0 : t.getAttribute("contenteditable")) === "true") {
290
- let s;
291
- t.matches('input[type="checkbox"], input[type="radio"]') ? s = t == null ? void 0 : t.checked : t.matches("input, select, textarea") && (s = t == null ? void 0 : t.value), s !== void 0 && (e.value = typeof s == "string" || s === null ? m(s, 1024) : s);
292
- let c = "";
293
- e != null && e.attributes.id && (c = m(
294
- ((i = (o = document.querySelector(`label[for="${e == null ? void 0 : e.attributes.id}"]`)) == null ? void 0 : o.textContent) == null ? void 0 : i.trim()) || ""
295
- ));
296
- const u = t.closest("label");
297
- c || (c = m(((a = u == null ? void 0 : u.textContent) == null ? void 0 : a.trim()) || "")), c && (e.label = c);
298
- }
299
- return e;
300
- }, qt = (t, n) => {
301
- var o;
302
- let e = Ht(t);
303
- Y(e) && (e = e.parentNode || null);
304
- const r = ["copy", "cut"].includes(n);
305
- if (e && (Wt(e, t) || r)) {
306
- const i = Z(e);
307
- if (r) {
308
- const a = m((o = window == null ? void 0 : window.getSelection()) == null ? void 0 : o.toString()), s = (t == null ? void 0 : t.type) || "clipboard";
309
- i.copy_text = a ?? "", i.copy_type = s ?? "";
310
- }
311
- return i;
312
- }
313
- return null;
314
- }, Qt = 30, te = 1e3, ee = 3;
315
- class ne {
316
- constructor() {
317
- U(this, "clicks");
318
- this.clicks = [];
319
- }
320
- isRageClick(n, e, r) {
321
- const o = this.clicks[this.clicks.length - 1];
322
- if (o && Math.abs(n - o.x) + Math.abs(e - o.y) < Qt && r - o.timestamp < te) {
323
- if (this.clicks.push({ x: n, y: e, timestamp: r }), this.clicks.length === ee)
324
- return !0;
325
- } else
326
- this.clicks = [{ x: n, y: e, timestamp: r }];
327
- return !1;
328
- }
329
- }
330
- const I = new ne(), re = () => {
331
- const { audience: t } = x();
332
- d(() => {
333
- const n = (e) => {
334
- try {
335
- let r = {
336
- hostname: window.location.hostname,
337
- pathname: window.location.pathname,
338
- page_title: document.title,
339
- url: window.location.href,
340
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
341
- event_type: e.type,
342
- button_type: e.button
343
- };
344
- if (e.target instanceof HTMLElement) {
345
- const o = e.target;
346
- r.rage_click = I == null ? void 0 : I.isRageClick(
347
- e.clientX,
348
- e.clientY,
349
- (/* @__PURE__ */ new Date()).getTime()
350
- ), r = {
351
- ...r,
352
- ...Z(o)
353
- };
354
- let i = o == null ? void 0 : o.getAttribute("href");
355
- if (!i) {
356
- let a = o.parentNode, s = 0;
357
- for (; a && s < 8; ) {
358
- const c = a == null ? void 0 : a.getAttribute(
359
- "href"
360
- );
361
- if (c) {
362
- i = c;
363
- break;
364
- }
365
- a = a.parentNode, s++;
366
- }
367
- }
368
- t == null || t.track("page.click", {
369
- ...r,
370
- href: i || void 0
371
- });
372
- }
373
- } catch (r) {
374
- console.error(r);
375
- }
376
- };
377
- return document.addEventListener("click", n), () => {
378
- document.removeEventListener("click", n);
379
- };
380
- }, [t]);
381
- }, le = ({ id: t, properties: n = {} }) => {
382
- const { client: e, audience: r } = x();
383
- d(() => {
384
- e && typeof window < "u" && (window.levo_client = e);
385
- }, [e]), d(() => {
386
- r && typeof window < "u" && (window.levo_audience = r);
387
- }, [r]);
388
- const o = typeof window < "u" ? window.location.href : void 0;
389
- jt(), $t(), re();
390
- const i = At();
391
- d(() => {
392
- r != null && r.instance && i > 0 && r.track("page.scroll", {
393
- resource: "page",
394
- identifier: t,
395
- percent: i
396
- });
397
- }, [r == null ? void 0 : r.instance, i, t]), d(() => {
398
- const s = () => {
399
- r == null || r.track("page.bounce", {
400
- resource: "page",
401
- identifier: t
402
- });
403
- };
404
- return window && window.addEventListener("beforeunload", s), () => {
405
- window && window.removeEventListener("beforeunload", s);
406
- };
407
- }, [r, t]);
408
- const [a] = it();
409
- return d(() => {
410
- (a === v.TERMINATED || a === v.HIDDEN || a === v.UNKNOWN || a === v.FROZEN) && (r == null || r.track("page.bounce", {
411
- resource: "page",
412
- identifier: t,
413
- state: a
414
- }));
415
- }, [a, r, t]), d(() => {
416
- (() => {
417
- e != null && e.insightsUrl && e.workspace && o && (r != null && r.instance ? r.instance.page({
418
- resource: "page",
419
- identifier: t
420
- }) : r == null || r.initiate({
421
- ...n,
422
- id: t,
423
- created_at: (/* @__PURE__ */ new Date()).toISOString()
424
- }));
425
- })();
426
- }, [e == null ? void 0 : e.insightsUrl, e == null ? void 0 : e.workspace, o]), d(() => {
427
- const s = {
428
- change: "form.change",
429
- submit: "form.submit",
430
- copy: "page.copy",
431
- cut: "page.copy"
432
- }, c = (h) => (g) => {
433
- const p = qt(g, h);
434
- p && (r == null || r.track(s[h], p));
435
- }, u = {
436
- change: c("change"),
437
- copy: c("copy"),
438
- cut: c("cut"),
439
- submit: c("submit")
440
- };
441
- return document.addEventListener("change", u.change), document.addEventListener("copy", u.copy), document.addEventListener("cut", u.cut), document.addEventListener("submit", u.submit), () => {
442
- document.removeEventListener("change", u.change), document.removeEventListener("copy", u.copy), document.removeEventListener("cut", u.cut), document.removeEventListener("submit", u.submit);
443
- };
444
- }, []), (!(e != null && e.insightsUrl) || !e.workspace || !e.workspace.startsWith("W")) && console.error(
445
- "[@levo-so/react] The utility could not be initialized, due to missing workspace, or endpoint for insights."
446
- ), null;
447
- };
448
- export {
449
- fe as L,
450
- de as a,
451
- le as b
452
- };