@levo-so/react 0.1.30 → 0.1.32
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.
- package/dist/audience/components/page.d.ts.map +1 -1
- package/dist/audience/hooks/usePerformanceMetrics.d.ts +9 -0
- package/dist/audience/hooks/usePerformanceMetrics.d.ts.map +1 -0
- package/dist/audience/index.js +1 -1
- package/dist/audience/utils/autocapture.d.ts +1 -2
- package/dist/audience/utils/autocapture.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/page-BjcgPmsH.js +478 -0
- package/package.json +3 -3
- package/dist/page-CgK_Cgps.js +0 -453
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAUlE,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,WAAW,CAAC,EAAE,UAAU,CAAC;QACzB,aAAa,CAAC,EAAE,YAAY,CAAC;KAC9B;CACF;AAED,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CA8KA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
type PerformanceMetrics = {
|
|
2
|
+
page_loaded_at: number;
|
|
3
|
+
script_load: number;
|
|
4
|
+
first_contentful_paint: number | null;
|
|
5
|
+
window_onload: number | null;
|
|
6
|
+
};
|
|
7
|
+
declare const usePerformanceMetrics: (href: string) => PerformanceMetrics | null;
|
|
8
|
+
export default usePerformanceMetrics;
|
|
9
|
+
//# sourceMappingURL=usePerformanceMetrics.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePerformanceMetrics.d.ts","sourceRoot":"","sources":["../../../src/audience/hooks/usePerformanceMetrics.tsx"],"names":[],"mappings":"AAIA,KAAK,kBAAkB,GAAG;IACxB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,MAAM,CAAC;IACpB,sBAAsB,EAAE,MAAM,GAAG,IAAI,CAAC;IACtC,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AAEF,QAAA,MAAM,qBAAqB,SAAU,MAAM,KAAG,kBAAkB,GAAG,IA4DlE,CAAC;AAEF,eAAe,qBAAqB,CAAC"}
|
package/dist/audience/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
export declare const isTextNode: (el: Element | undefined | null) => el is HTMLElement;
|
|
2
|
-
export declare const makeSafeText: (s: string | null | undefined) => string
|
|
2
|
+
export declare const makeSafeText: (s: string | null | undefined, length?: number) => string;
|
|
3
3
|
export declare const getSafeText: (el: Element) => string;
|
|
4
4
|
export declare const getEventTarget: (e: Event) => Element | null;
|
|
5
5
|
export declare const shouldCaptureDomEvent: (el: Element, event: Event) => boolean;
|
|
6
|
-
export declare const isSensitiveElement: (el: Element) => boolean;
|
|
7
6
|
export declare const shouldCaptureValue: (value: string, anchorRegexes?: boolean) => boolean;
|
|
8
7
|
export declare const isAngularStyleAttr: (attributeName: string) => boolean;
|
|
9
8
|
export declare const getDirectAndNestedSpanText: (target: Element) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"autocapture.d.ts","sourceRoot":"","sources":["../../../src/audience/utils/autocapture.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,UAAU,OACjB,OAAO,GAAG,SAAS,GAAG,IAAI,KAC7B,EAAE,IAAI,WAER,CAAC;
|
|
1
|
+
{"version":3,"file":"autocapture.d.ts","sourceRoot":"","sources":["../../../src/audience/utils/autocapture.ts"],"names":[],"mappings":"AAgCA,eAAO,MAAM,UAAU,OACjB,OAAO,GAAG,SAAS,GAAG,IAAI,KAC7B,EAAE,IAAI,WAER,CAAC;AA2DF,eAAO,MAAM,YAAY,MACpB,MAAM,GAAG,IAAI,GAAG,SAAS,sBAE3B,MAiBF,CAAC;AAWF,eAAO,MAAM,WAAW,OAAQ,OAAO,KAAG,MAiBzC,CAAC;AAEF,eAAO,MAAM,cAAc,MAAO,KAAK,KAAG,OAAO,GAAG,IASnD,CAAC;AAYF,eAAO,MAAM,qBAAqB,OAAQ,OAAO,SAAS,KAAK,KAAG,OA2BjE,CAAC;AAoFF,eAAO,MAAM,kBAAkB,UACtB,MAAM,8BAEZ,OAuBF,CAAC;AASF,eAAO,MAAM,kBAAkB,kBAAmB,MAAM,KAAG,OAQ1D,CAAC;AASF,eAAO,MAAM,0BAA0B,WAAY,OAAO,KAAG,MAI5D,CAAC;AA6BF,MAAM,MAAM,QAAQ,GAAG,GAAG,CAAC;AAC3B,MAAM,MAAM,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AAIlD,eAAO,MAAM,aAAa,YAAa,OAAO,KAAG,UAsFhD,CAAC;AAEF,eAAO,MAAM,sBAAsB,MAAO,KAAK,aAAa,MAAM,sBA2BjE,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { L as s, u as o } from "./LevoProvider-BAZy7_tP.js";
|
|
2
|
-
import { L as t, a as r, b as l } from "./page-
|
|
2
|
+
import { L as t, a as r, b as l } from "./page-BjcgPmsH.js";
|
|
3
3
|
import { C as m, F as p, x as d, y as g, m as T, r as f, j as u, n as c, e as x, b, c as D, f as y, g as F, d as v, k as h, o as L, i as M, a as E, w as P, t as B, p as C, h as O, s as V, u as j, v as I, l as S, q as K } from "./CollectionFormBuilder-BPzVyGLq.js";
|
|
4
4
|
import { LevoOAuth as U } from "./membership/index.js";
|
|
5
5
|
import { B as H, D as N, j as q, e as w, i as z, g as A, f as R, c as G, a as J, h as Q, d as X, k as Y, S as Z, T as _, n as $, l as aa, m as ea, b as sa } from "./Spinner-BcBoT-J5.js";
|
|
@@ -0,0 +1,478 @@
|
|
|
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 P = (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 b } from "react";
|
|
7
|
+
import { useInView as st } from "react-intersection-observer";
|
|
8
|
+
import { u as S } from "./LevoProvider-BAZy7_tP.js";
|
|
9
|
+
import { usePageLifecycle as it, LifecycleState as E } from "use-page-lifecycle";
|
|
10
|
+
const de = ({ id: t, properties: n = {} }) => {
|
|
11
|
+
const { audience: e } = S(), { 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
|
+
}, le = ({ event: t, properties: n }) => {
|
|
22
|
+
const { audience: e } = S();
|
|
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")(), N = 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 L = W.Symbol, G = Object.prototype, gt = G.hasOwnProperty, pt = G.toString, y = L ? L.toStringTag : void 0;
|
|
44
|
+
function mt(t) {
|
|
45
|
+
var n = gt.call(t, y), e = t[y];
|
|
46
|
+
try {
|
|
47
|
+
t[y] = void 0;
|
|
48
|
+
var r = !0;
|
|
49
|
+
} catch {
|
|
50
|
+
}
|
|
51
|
+
var o = pt.call(t);
|
|
52
|
+
return r && (n ? t[y] = e : delete t[y]), 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]", vt = "[object Undefined]", U = L ? L.toStringTag : void 0;
|
|
59
|
+
function St(t) {
|
|
60
|
+
return t == null ? t === void 0 ? vt : yt : U && U 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) && St(t) == Et;
|
|
68
|
+
}
|
|
69
|
+
var F = NaN, xt = /^[-+]0x[0-9a-f]+$/i, Ct = /^0b[01]+$/i, _t = /^0o[0-7]+$/i, kt = parseInt;
|
|
70
|
+
function H(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 || _t.test(t) ? kt(t.slice(2), e ? 2 : 8) : xt.test(t) ? F : +t;
|
|
84
|
+
}
|
|
85
|
+
var Nt = "Expected a function", Ot = Math.max, It = Math.min;
|
|
86
|
+
function Rt(t, n, e) {
|
|
87
|
+
var r, o, c, a, s, i, u = 0, g = !1, l = !1, p = !0;
|
|
88
|
+
if (typeof t != "function")
|
|
89
|
+
throw new TypeError(Nt);
|
|
90
|
+
n = H(n) || 0, R(e) && (g = !!e.leading, l = "maxWait" in e, c = l ? Ot(H(e.maxWait) || 0, n) : c, p = "trailing" in e ? !!e.trailing : p);
|
|
91
|
+
function _(f) {
|
|
92
|
+
var m = r, w = o;
|
|
93
|
+
return r = o = void 0, u = f, a = t.apply(w, m), a;
|
|
94
|
+
}
|
|
95
|
+
function q(f) {
|
|
96
|
+
return u = f, s = setTimeout(T, n), g ? _(f) : a;
|
|
97
|
+
}
|
|
98
|
+
function Q(f) {
|
|
99
|
+
var m = f - i, w = f - u, D = n - m;
|
|
100
|
+
return l ? It(D, c - w) : D;
|
|
101
|
+
}
|
|
102
|
+
function $(f) {
|
|
103
|
+
var m = f - i, w = f - u;
|
|
104
|
+
return i === void 0 || m >= n || m < 0 || l && w >= c;
|
|
105
|
+
}
|
|
106
|
+
function T() {
|
|
107
|
+
var f = N();
|
|
108
|
+
if ($(f))
|
|
109
|
+
return M(f);
|
|
110
|
+
s = setTimeout(T, Q(f));
|
|
111
|
+
}
|
|
112
|
+
function M(f) {
|
|
113
|
+
return s = void 0, p && r ? _(f) : (r = o = void 0, a);
|
|
114
|
+
}
|
|
115
|
+
function tt() {
|
|
116
|
+
s !== void 0 && clearTimeout(s), u = 0, r = i = o = s = void 0;
|
|
117
|
+
}
|
|
118
|
+
function et() {
|
|
119
|
+
return s === void 0 ? a : M(N());
|
|
120
|
+
}
|
|
121
|
+
function k() {
|
|
122
|
+
var f = N(), m = $(f);
|
|
123
|
+
if (r = arguments, o = this, i = f, m) {
|
|
124
|
+
if (s === void 0)
|
|
125
|
+
return q(i);
|
|
126
|
+
if (l)
|
|
127
|
+
return clearTimeout(s), s = setTimeout(T, n), _(i);
|
|
128
|
+
}
|
|
129
|
+
return s === void 0 && (s = setTimeout(T, n)), a;
|
|
130
|
+
}
|
|
131
|
+
return k.cancel = tt, k.flush = et, k;
|
|
132
|
+
}
|
|
133
|
+
const At = () => {
|
|
134
|
+
const [t, n] = b(0), [e, r] = b(0), o = Rt((c) => {
|
|
135
|
+
r(c), n(c);
|
|
136
|
+
}, 250);
|
|
137
|
+
return d(() => {
|
|
138
|
+
const c = () => {
|
|
139
|
+
const a = window.scrollY, s = document.documentElement.scrollHeight, i = window.innerHeight, u = Math.round(
|
|
140
|
+
a / (s - i) * 100
|
|
141
|
+
);
|
|
142
|
+
u % 10 === 0 && u > e && o(u);
|
|
143
|
+
};
|
|
144
|
+
return window.addEventListener("scroll", c), () => window.removeEventListener("scroll", c);
|
|
145
|
+
}, [e]), t;
|
|
146
|
+
}, v = "lv_insights_ot", jt = () => {
|
|
147
|
+
const [t, n] = b(0);
|
|
148
|
+
return d(() => {
|
|
149
|
+
const e = Number(localStorage.getItem(v)) || 0;
|
|
150
|
+
n(e), localStorage.setItem(v, (e + 1).toString());
|
|
151
|
+
const r = (c) => {
|
|
152
|
+
c.key === v && n(Number(c.newValue) || 0);
|
|
153
|
+
};
|
|
154
|
+
window.addEventListener("storage", r);
|
|
155
|
+
const o = () => {
|
|
156
|
+
const c = Number(localStorage.getItem(v)) || 0;
|
|
157
|
+
c > 0 && localStorage.setItem(v, (c - 1).toString());
|
|
158
|
+
};
|
|
159
|
+
return window.addEventListener("beforeunload", o), () => {
|
|
160
|
+
window.removeEventListener("storage", r), window.removeEventListener("beforeunload", o);
|
|
161
|
+
};
|
|
162
|
+
}, []), t;
|
|
163
|
+
}, B = "lv_insights_ct", O = "lv_insights_at", $t = () => {
|
|
164
|
+
const [t, n] = b(null);
|
|
165
|
+
return d(() => {
|
|
166
|
+
let e = sessionStorage.getItem(B);
|
|
167
|
+
const r = JSON.parse(
|
|
168
|
+
localStorage.getItem(O) || "[]"
|
|
169
|
+
);
|
|
170
|
+
e && r.includes(e) && (e = null), e || (e = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(B, e)), r.includes(e) || (r.push(e), localStorage.setItem(
|
|
171
|
+
O,
|
|
172
|
+
JSON.stringify(r)
|
|
173
|
+
)), n(e);
|
|
174
|
+
const o = () => {
|
|
175
|
+
const c = r.filter(
|
|
176
|
+
(a) => a !== e
|
|
177
|
+
);
|
|
178
|
+
localStorage.setItem(
|
|
179
|
+
O,
|
|
180
|
+
JSON.stringify(c)
|
|
181
|
+
);
|
|
182
|
+
};
|
|
183
|
+
return window.addEventListener("beforeunload", o), () => {
|
|
184
|
+
window.removeEventListener("beforeunload", o);
|
|
185
|
+
};
|
|
186
|
+
}, []), t;
|
|
187
|
+
}, x = (t) => Object.prototype.toString.call(t) == "[object String]", Mt = (t, n) => t.indexOf(n) !== -1, C = (t) => t.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), K = (t) => t === void 0, Dt = (t) => t === null, V = (t) => K(t) || Dt(t), Y = (t) => !!t && (t == null ? void 0 : t.nodeType) === 3;
|
|
188
|
+
function Pt(t) {
|
|
189
|
+
return !!t && (t == null ? void 0 : t.nodeType) === 1;
|
|
190
|
+
}
|
|
191
|
+
function Ut(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 Ht(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 h = (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 += h(e.textContent) ?? "");
|
|
217
|
+
return C(n);
|
|
218
|
+
}, Bt = (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 || Ut(t, "html") || !Pt(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 (Mt(Ht(t), "ph-include"))
|
|
242
|
+
return !0;
|
|
243
|
+
const n = t.type || "";
|
|
244
|
+
if (x(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 !(x(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) || x(t) && (t = C(t), (n ? Kt : Vt).test((t || "").replace(/[- ]/g, "")) || (n ? Yt : Jt).test(t))), Xt = (t) => x(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, c, 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, i) => {
|
|
280
|
+
if (j(i.value) && !Xt(i.name)) {
|
|
281
|
+
if (i.name === "class")
|
|
282
|
+
return s;
|
|
283
|
+
s[i.name] = typeof (i == null ? void 0 : i.value) == "string" ? h(i.value) : i.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.checked : t.matches("input, select, textarea") && !t.matches('input[type="password"]') && (s = t.value), s !== void 0 && (e.value = typeof s == "string" || s === null ? h(s, 1024) : s);
|
|
292
|
+
let i = "";
|
|
293
|
+
e != null && e.attributes.id && (i = h(
|
|
294
|
+
((c = (o = document.querySelector(`label[for="${e == null ? void 0 : e.attributes.id}"]`)) == null ? void 0 : o.textContent) == null ? void 0 : c.trim()) || ""
|
|
295
|
+
));
|
|
296
|
+
const u = t.closest("label");
|
|
297
|
+
i || (i = h(((a = u == null ? void 0 : u.textContent) == null ? void 0 : a.trim()) || "")), i && (e.label = i);
|
|
298
|
+
}
|
|
299
|
+
return e;
|
|
300
|
+
}, qt = (t, n) => {
|
|
301
|
+
var o;
|
|
302
|
+
let e = Bt(t);
|
|
303
|
+
Y(e) && (e = e.parentNode || null);
|
|
304
|
+
const r = ["copy", "cut"].includes(n);
|
|
305
|
+
if (e && (Wt(e, t) || r)) {
|
|
306
|
+
const c = Z(e);
|
|
307
|
+
if (r) {
|
|
308
|
+
const a = h((o = window == null ? void 0 : window.getSelection()) == null ? void 0 : o.toString()), s = (t == null ? void 0 : t.type) || "clipboard";
|
|
309
|
+
c.copy_text = a ?? "", c.copy_type = s ?? "";
|
|
310
|
+
}
|
|
311
|
+
return c;
|
|
312
|
+
}
|
|
313
|
+
return null;
|
|
314
|
+
}, Qt = 30, te = 1e3, ee = 3;
|
|
315
|
+
class ne {
|
|
316
|
+
constructor() {
|
|
317
|
+
P(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 } = S();
|
|
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 c = o == null ? void 0 : o.getAttribute("href");
|
|
355
|
+
if (!c) {
|
|
356
|
+
let a = o.parentNode, s = 0;
|
|
357
|
+
for (; a && s < 8; ) {
|
|
358
|
+
const i = a == null ? void 0 : a.getAttribute(
|
|
359
|
+
"href"
|
|
360
|
+
);
|
|
361
|
+
if (i) {
|
|
362
|
+
c = i;
|
|
363
|
+
break;
|
|
364
|
+
}
|
|
365
|
+
a = a.parentNode, s++;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
t == null || t.track("page.click", {
|
|
369
|
+
...r,
|
|
370
|
+
href: c || 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
|
+
}, oe = (t) => {
|
|
382
|
+
const { audience: n } = S(), [, e] = b({
|
|
383
|
+
page_loaded_at: performance.timeOrigin,
|
|
384
|
+
script_load: performance.now(),
|
|
385
|
+
first_contentful_paint: null,
|
|
386
|
+
window_onload: null
|
|
387
|
+
}), [r, o] = b(
|
|
388
|
+
null
|
|
389
|
+
);
|
|
390
|
+
return d(() => {
|
|
391
|
+
let c = !0;
|
|
392
|
+
const a = (u) => {
|
|
393
|
+
c && e((g) => {
|
|
394
|
+
const l = { ...g, ...u };
|
|
395
|
+
return Object.values(l).every((p) => p !== null) && o(l), l;
|
|
396
|
+
});
|
|
397
|
+
}, s = new PerformanceObserver((u) => {
|
|
398
|
+
for (const g of u.getEntries())
|
|
399
|
+
g.name === "first-contentful-paint" && a({ first_contentful_paint: g.startTime });
|
|
400
|
+
});
|
|
401
|
+
s.observe({ type: "paint", buffered: !0 });
|
|
402
|
+
const i = () => a({ window_onload: performance.now() });
|
|
403
|
+
return document.readyState === "complete" ? i() : window.addEventListener("load", i), () => {
|
|
404
|
+
c = !1, s.disconnect(), window.removeEventListener("load", i);
|
|
405
|
+
};
|
|
406
|
+
}, [t]), d(() => {
|
|
407
|
+
r && n && (n == null || n.track("page.metrics", r));
|
|
408
|
+
}, [r, n]), r;
|
|
409
|
+
}, ge = ({ id: t, properties: n = {} }) => {
|
|
410
|
+
const e = typeof window < "u" ? window.location.href : "", { client: r, audience: o } = S();
|
|
411
|
+
d(() => {
|
|
412
|
+
r && typeof window < "u" && (window.levo_client = r);
|
|
413
|
+
}, [r]), d(() => {
|
|
414
|
+
o && typeof window < "u" && (window.levo_audience = o);
|
|
415
|
+
}, [o]), jt(), $t(), re();
|
|
416
|
+
const c = At();
|
|
417
|
+
d(() => {
|
|
418
|
+
o != null && o.instance && o.track("page.scroll", {
|
|
419
|
+
resource: "page",
|
|
420
|
+
identifier: t,
|
|
421
|
+
percent: c
|
|
422
|
+
});
|
|
423
|
+
}, [o == null ? void 0 : o.instance, c, t]), oe(e), d(() => {
|
|
424
|
+
const s = () => {
|
|
425
|
+
o == null || o.bounce({
|
|
426
|
+
resource: "page",
|
|
427
|
+
identifier: t
|
|
428
|
+
});
|
|
429
|
+
};
|
|
430
|
+
return window && window.addEventListener("beforeunload", s), () => {
|
|
431
|
+
window && window.removeEventListener("beforeunload", s);
|
|
432
|
+
};
|
|
433
|
+
}, [o, t]);
|
|
434
|
+
const [a] = it();
|
|
435
|
+
return d(() => {
|
|
436
|
+
(a === E.TERMINATED || a === E.HIDDEN || a === E.UNKNOWN || a === E.FROZEN) && (o == null || o.bounce({
|
|
437
|
+
resource: "page",
|
|
438
|
+
identifier: t,
|
|
439
|
+
state: a
|
|
440
|
+
}));
|
|
441
|
+
}, [a, o, t]), d(() => {
|
|
442
|
+
(() => {
|
|
443
|
+
r != null && r.insightsUrl && r.workspace && e && (o != null && o.instance ? o.instance.page({
|
|
444
|
+
resource: "page",
|
|
445
|
+
identifier: t
|
|
446
|
+
}) : o == null || o.initiate({
|
|
447
|
+
...n,
|
|
448
|
+
id: t,
|
|
449
|
+
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
450
|
+
}));
|
|
451
|
+
})();
|
|
452
|
+
}, [r == null ? void 0 : r.insightsUrl, r == null ? void 0 : r.workspace, e]), d(() => {
|
|
453
|
+
const s = {
|
|
454
|
+
change: "form.change",
|
|
455
|
+
submit: "form.submit",
|
|
456
|
+
copy: "page.copy",
|
|
457
|
+
cut: "page.copy"
|
|
458
|
+
}, i = (g) => (l) => {
|
|
459
|
+
const p = qt(l, g);
|
|
460
|
+
p && (o == null || o.track(s[g], p));
|
|
461
|
+
}, u = {
|
|
462
|
+
change: i("change"),
|
|
463
|
+
copy: i("copy"),
|
|
464
|
+
cut: i("cut"),
|
|
465
|
+
submit: i("submit")
|
|
466
|
+
};
|
|
467
|
+
return document.addEventListener("change", u.change), document.addEventListener("copy", u.copy), document.addEventListener("cut", u.cut), document.addEventListener("submit", u.submit), () => {
|
|
468
|
+
document.removeEventListener("change", u.change), document.removeEventListener("copy", u.copy), document.removeEventListener("cut", u.cut), document.removeEventListener("submit", u.submit);
|
|
469
|
+
};
|
|
470
|
+
}, []), (!(r != null && r.insightsUrl) || !r.workspace || !r.workspace.startsWith("W")) && console.error(
|
|
471
|
+
"[@levo-so/react] The utility could not be initialized, due to missing workspace, or endpoint for insights."
|
|
472
|
+
), null;
|
|
473
|
+
};
|
|
474
|
+
export {
|
|
475
|
+
de as L,
|
|
476
|
+
le as a,
|
|
477
|
+
ge as b
|
|
478
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@levo-so/react",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.32",
|
|
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.
|
|
19
|
+
"@levo-so/core": "0.1.32"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@radix-ui/react-checkbox": "1.1.1",
|
|
@@ -90,8 +90,8 @@
|
|
|
90
90
|
"typescript": "5.5.4",
|
|
91
91
|
"vite": "5.4.3",
|
|
92
92
|
"vite-plugin-dts": "4.1.0",
|
|
93
|
-
"@levo/tw-config": "0.0.0",
|
|
94
93
|
"@levo/ts-config": "0.0.0",
|
|
94
|
+
"@levo/tw-config": "0.0.0",
|
|
95
95
|
"@levo/eslint-config": "0.0.0"
|
|
96
96
|
},
|
|
97
97
|
"main": "./dist/index.js",
|
package/dist/page-CgK_Cgps.js
DELETED
|
@@ -1,453 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
var se = Object.defineProperty;
|
|
3
|
-
var ie = (e, n, t) => n in e ? se(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t;
|
|
4
|
-
var U = (e, n, t) => ie(e, typeof n != "symbol" ? n + "" : n, t);
|
|
5
|
-
import { j as ce } from "./jsx-runtime-B6kdoens.js";
|
|
6
|
-
import { useEffect as f, useState as T } from "react";
|
|
7
|
-
import { useInView as ae } from "react-intersection-observer";
|
|
8
|
-
import { u as x } from "./LevoProvider-BAZy7_tP.js";
|
|
9
|
-
import { usePageLifecycle as ue, LifecycleState as S } from "use-page-lifecycle";
|
|
10
|
-
const ft = ({ id: e, properties: n = {} }) => {
|
|
11
|
-
const { audience: t } = x(), { ref: r, inView: o } = ae({
|
|
12
|
-
triggerOnce: !0
|
|
13
|
-
});
|
|
14
|
-
return f(() => {
|
|
15
|
-
t != null && t.instance && o && (t == null || t.track("block.view", {
|
|
16
|
-
...n,
|
|
17
|
-
resource: "block",
|
|
18
|
-
identifier: e
|
|
19
|
-
}));
|
|
20
|
-
}, [o]), /* @__PURE__ */ ce.jsx("div", { ref: r, style: { height: "0px" } });
|
|
21
|
-
}, dt = ({ event: e, properties: n }) => {
|
|
22
|
-
const { audience: t } = x();
|
|
23
|
-
return f(() => {
|
|
24
|
-
t != null && t.instance && (t == null || t.track(e, n));
|
|
25
|
-
}, [t == null ? void 0 : t.instance, e, n]), null;
|
|
26
|
-
};
|
|
27
|
-
function A(e) {
|
|
28
|
-
var n = typeof e;
|
|
29
|
-
return e != null && (n == "object" || n == "function");
|
|
30
|
-
}
|
|
31
|
-
var le = typeof global == "object" && global && global.Object === Object && global, fe = typeof self == "object" && self && self.Object === Object && self, G = le || fe || Function("return this")(), _ = function() {
|
|
32
|
-
return G.Date.now();
|
|
33
|
-
}, de = /\s/;
|
|
34
|
-
function ge(e) {
|
|
35
|
-
for (var n = e.length; n-- && de.test(e.charAt(n)); )
|
|
36
|
-
;
|
|
37
|
-
return n;
|
|
38
|
-
}
|
|
39
|
-
var me = /^\s+/;
|
|
40
|
-
function pe(e) {
|
|
41
|
-
return e && e.slice(0, ge(e) + 1).replace(me, "");
|
|
42
|
-
}
|
|
43
|
-
var E = G.Symbol, K = Object.prototype, he = K.hasOwnProperty, be = K.toString, b = E ? E.toStringTag : void 0;
|
|
44
|
-
function we(e) {
|
|
45
|
-
var n = he.call(e, b), t = e[b];
|
|
46
|
-
try {
|
|
47
|
-
e[b] = void 0;
|
|
48
|
-
var r = !0;
|
|
49
|
-
} catch {
|
|
50
|
-
}
|
|
51
|
-
var o = be.call(e);
|
|
52
|
-
return r && (n ? e[b] = t : delete e[b]), o;
|
|
53
|
-
}
|
|
54
|
-
var ye = Object.prototype, Se = ye.toString;
|
|
55
|
-
function ve(e) {
|
|
56
|
-
return Se.call(e);
|
|
57
|
-
}
|
|
58
|
-
var Te = "[object Null]", Ee = "[object Undefined]", M = E ? E.toStringTag : void 0;
|
|
59
|
-
function Le(e) {
|
|
60
|
-
return e == null ? e === void 0 ? Ee : Te : M && M in Object(e) ? we(e) : ve(e);
|
|
61
|
-
}
|
|
62
|
-
function Ce(e) {
|
|
63
|
-
return e != null && typeof e == "object";
|
|
64
|
-
}
|
|
65
|
-
var xe = "[object Symbol]";
|
|
66
|
-
function Ne(e) {
|
|
67
|
-
return typeof e == "symbol" || Ce(e) && Le(e) == xe;
|
|
68
|
-
}
|
|
69
|
-
var F = NaN, ke = /^[-+]0x[0-9a-f]+$/i, Oe = /^0b[01]+$/i, _e = /^0o[0-7]+$/i, Ie = parseInt;
|
|
70
|
-
function B(e) {
|
|
71
|
-
if (typeof e == "number")
|
|
72
|
-
return e;
|
|
73
|
-
if (Ne(e))
|
|
74
|
-
return F;
|
|
75
|
-
if (A(e)) {
|
|
76
|
-
var n = typeof e.valueOf == "function" ? e.valueOf() : e;
|
|
77
|
-
e = A(n) ? n + "" : n;
|
|
78
|
-
}
|
|
79
|
-
if (typeof e != "string")
|
|
80
|
-
return e === 0 ? e : +e;
|
|
81
|
-
e = pe(e);
|
|
82
|
-
var t = Oe.test(e);
|
|
83
|
-
return t || _e.test(e) ? Ie(e.slice(2), t ? 2 : 8) : ke.test(e) ? F : +e;
|
|
84
|
-
}
|
|
85
|
-
var Re = "Expected a function", Ae = Math.max, je = Math.min;
|
|
86
|
-
function $e(e, n, t) {
|
|
87
|
-
var r, o, i, c, s, a, l = 0, p = !1, g = !1, m = !0;
|
|
88
|
-
if (typeof e != "function")
|
|
89
|
-
throw new TypeError(Re);
|
|
90
|
-
n = B(n) || 0, A(t) && (p = !!t.leading, g = "maxWait" in t, i = g ? Ae(B(t.maxWait) || 0, n) : i, m = "trailing" in t ? !!t.trailing : m);
|
|
91
|
-
function k(u) {
|
|
92
|
-
var d = r, h = o;
|
|
93
|
-
return r = o = void 0, l = u, c = e.apply(h, d), c;
|
|
94
|
-
}
|
|
95
|
-
function te(u) {
|
|
96
|
-
return l = u, s = setTimeout(y, n), p ? k(u) : c;
|
|
97
|
-
}
|
|
98
|
-
function ne(u) {
|
|
99
|
-
var d = u - a, h = u - l, P = n - d;
|
|
100
|
-
return g ? je(P, i - h) : P;
|
|
101
|
-
}
|
|
102
|
-
function $(u) {
|
|
103
|
-
var d = u - a, h = u - l;
|
|
104
|
-
return a === void 0 || d >= n || d < 0 || g && h >= i;
|
|
105
|
-
}
|
|
106
|
-
function y() {
|
|
107
|
-
var u = _();
|
|
108
|
-
if ($(u))
|
|
109
|
-
return D(u);
|
|
110
|
-
s = setTimeout(y, ne(u));
|
|
111
|
-
}
|
|
112
|
-
function D(u) {
|
|
113
|
-
return s = void 0, m && r ? k(u) : (r = o = void 0, c);
|
|
114
|
-
}
|
|
115
|
-
function re() {
|
|
116
|
-
s !== void 0 && clearTimeout(s), l = 0, r = a = o = s = void 0;
|
|
117
|
-
}
|
|
118
|
-
function oe() {
|
|
119
|
-
return s === void 0 ? c : D(_());
|
|
120
|
-
}
|
|
121
|
-
function O() {
|
|
122
|
-
var u = _(), d = $(u);
|
|
123
|
-
if (r = arguments, o = this, a = u, d) {
|
|
124
|
-
if (s === void 0)
|
|
125
|
-
return te(a);
|
|
126
|
-
if (g)
|
|
127
|
-
return clearTimeout(s), s = setTimeout(y, n), k(a);
|
|
128
|
-
}
|
|
129
|
-
return s === void 0 && (s = setTimeout(y, n)), c;
|
|
130
|
-
}
|
|
131
|
-
return O.cancel = re, O.flush = oe, O;
|
|
132
|
-
}
|
|
133
|
-
const De = () => {
|
|
134
|
-
const [e, n] = T(0), [t, r] = T(0), o = $e((i) => {
|
|
135
|
-
r(i), n(i);
|
|
136
|
-
}, 250);
|
|
137
|
-
return f(() => {
|
|
138
|
-
const i = () => {
|
|
139
|
-
const c = window.scrollY, s = document.documentElement.scrollHeight, a = window.innerHeight, l = Math.round(
|
|
140
|
-
c / (s - a) * 100
|
|
141
|
-
);
|
|
142
|
-
l % 10 === 0 && l > t && o(l);
|
|
143
|
-
};
|
|
144
|
-
return window.addEventListener("scroll", i), () => window.removeEventListener("scroll", i);
|
|
145
|
-
}, [t]), e;
|
|
146
|
-
}, w = "lv_insights_ot", Pe = () => {
|
|
147
|
-
const [e, n] = T(0);
|
|
148
|
-
return f(() => {
|
|
149
|
-
const t = Number(localStorage.getItem(w)) || 0;
|
|
150
|
-
n(t), localStorage.setItem(w, (t + 1).toString());
|
|
151
|
-
const r = (i) => {
|
|
152
|
-
i.key === w && n(Number(i.newValue) || 0);
|
|
153
|
-
};
|
|
154
|
-
window.addEventListener("storage", r);
|
|
155
|
-
const o = () => {
|
|
156
|
-
const i = Number(localStorage.getItem(w)) || 0;
|
|
157
|
-
i > 0 && localStorage.setItem(w, (i - 1).toString());
|
|
158
|
-
};
|
|
159
|
-
return window.addEventListener("beforeunload", o), () => {
|
|
160
|
-
window.removeEventListener("storage", r), window.removeEventListener("beforeunload", o);
|
|
161
|
-
};
|
|
162
|
-
}, []), e;
|
|
163
|
-
}, H = "lv_insights_ct", I = "lv_insights_at", Ue = () => {
|
|
164
|
-
const [e, n] = T(null);
|
|
165
|
-
return f(() => {
|
|
166
|
-
let t = sessionStorage.getItem(H);
|
|
167
|
-
const r = JSON.parse(
|
|
168
|
-
localStorage.getItem(I) || "[]"
|
|
169
|
-
);
|
|
170
|
-
t && r.includes(t) && (t = null), t || (t = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(H, t)), r.includes(t) || (r.push(t), localStorage.setItem(
|
|
171
|
-
I,
|
|
172
|
-
JSON.stringify(r)
|
|
173
|
-
)), n(t);
|
|
174
|
-
const o = () => {
|
|
175
|
-
const i = r.filter(
|
|
176
|
-
(c) => c !== t
|
|
177
|
-
);
|
|
178
|
-
localStorage.setItem(
|
|
179
|
-
I,
|
|
180
|
-
JSON.stringify(i)
|
|
181
|
-
);
|
|
182
|
-
};
|
|
183
|
-
return window.addEventListener("beforeunload", o), () => {
|
|
184
|
-
window.removeEventListener("beforeunload", o);
|
|
185
|
-
};
|
|
186
|
-
}, []), e;
|
|
187
|
-
}, L = (e) => Object.prototype.toString.call(e) == "[object String]", Me = (e, n) => e.indexOf(n) !== -1, N = (e) => e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), V = (e) => e === void 0, Fe = (e) => e === null, Y = (e) => V(e) || Fe(e), J = (e) => !!e && e.nodeType === 3;
|
|
188
|
-
function Be(e) {
|
|
189
|
-
return !!e && e.nodeType === 1;
|
|
190
|
-
}
|
|
191
|
-
function v(e, n) {
|
|
192
|
-
return !!e && !!e.tagName && e.tagName.toLowerCase() === n.toLowerCase();
|
|
193
|
-
}
|
|
194
|
-
function He(e) {
|
|
195
|
-
return e ? N(e).split(/\s+/) : [];
|
|
196
|
-
}
|
|
197
|
-
function We(e) {
|
|
198
|
-
let n = "";
|
|
199
|
-
switch (typeof e.className) {
|
|
200
|
-
case "string":
|
|
201
|
-
n = e.className;
|
|
202
|
-
break;
|
|
203
|
-
case "object":
|
|
204
|
-
n = (e.className && "baseVal" in e.className ? e.className.baseVal : null) || (e == null ? void 0 : e.getAttribute("class")) || "";
|
|
205
|
-
break;
|
|
206
|
-
default:
|
|
207
|
-
n = "";
|
|
208
|
-
}
|
|
209
|
-
return He(n);
|
|
210
|
-
}
|
|
211
|
-
const X = (e) => Y(e) ? null : N(e).split(/(\s+)/).filter((n) => j(n)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, 255), C = (e) => {
|
|
212
|
-
let n = "";
|
|
213
|
-
if (Ve(e) && !z(e) && e.childNodes && e.childNodes.length)
|
|
214
|
-
for (const t of e.childNodes)
|
|
215
|
-
J(t) && t.textContent && (n += X(t.textContent) ?? "");
|
|
216
|
-
return N(n);
|
|
217
|
-
}, Ge = (e) => {
|
|
218
|
-
var n;
|
|
219
|
-
return V(e.target) ? e.srcElement || null : (n = e.target) != null && n.shadowRoot ? e.composedPath()[0] || null : e.target || null;
|
|
220
|
-
}, Ke = (e, n) => {
|
|
221
|
-
if (!window || !e || v(e, "html") || !Be(e))
|
|
222
|
-
return !1;
|
|
223
|
-
const t = window.getComputedStyle(e);
|
|
224
|
-
if (t && t.getPropertyValue("cursor") === "pointer" && n.type === "click")
|
|
225
|
-
return !0;
|
|
226
|
-
switch (e.tagName.toLowerCase()) {
|
|
227
|
-
case "html":
|
|
228
|
-
return !1;
|
|
229
|
-
case "form":
|
|
230
|
-
return n.type === "submit";
|
|
231
|
-
case "input":
|
|
232
|
-
case "select":
|
|
233
|
-
case "textarea":
|
|
234
|
-
return ["change", "click"].includes(n.type);
|
|
235
|
-
default:
|
|
236
|
-
return n.type === "click";
|
|
237
|
-
}
|
|
238
|
-
};
|
|
239
|
-
function Ve(e) {
|
|
240
|
-
if (Me(We(e), "ph-include"))
|
|
241
|
-
return !0;
|
|
242
|
-
const n = e.type || "";
|
|
243
|
-
if (L(n))
|
|
244
|
-
switch (n.toLowerCase()) {
|
|
245
|
-
case "hidden":
|
|
246
|
-
return !1;
|
|
247
|
-
case "password":
|
|
248
|
-
return !1;
|
|
249
|
-
}
|
|
250
|
-
const t = e.name || e.id || "";
|
|
251
|
-
return !(L(t) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(t.replace(/[^a-zA-Z0-9]/g, "")));
|
|
252
|
-
}
|
|
253
|
-
const z = (e) => {
|
|
254
|
-
const n = ["button", "checkbox", "submit", "reset"];
|
|
255
|
-
return !!(v(e, "input") && !n.includes(e.type) || v(e, "select") || v(e, "textarea") || (e == null ? void 0 : e.getAttribute("contenteditable")) === "true");
|
|
256
|
-
}, Z = "(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})", Ye = new RegExp(`^(?:${Z})$`), Je = new RegExp(Z), q = "\\d{3}-?\\d{2}-?\\d{4}", Xe = new RegExp(`^(${q})$`), ze = new RegExp(`(${q})`), j = (e, n = !0) => !(Y(e) || L(e) && (e = N(e), (n ? Ye : Je).test((e || "").replace(/[- ]/g, "")) || (n ? Xe : ze).test(e))), Ze = (e) => L(e) ? e.substring(0, 10) === "_ngcontent" || e.substring(0, 7) === "_nghost" : !1, W = (e) => {
|
|
257
|
-
let n = C(e);
|
|
258
|
-
return n = `${n} ${Q(e)}`.trim(), j(n) ? n : "";
|
|
259
|
-
};
|
|
260
|
-
function Q(e) {
|
|
261
|
-
var t;
|
|
262
|
-
let n = "";
|
|
263
|
-
if (e != null && e.childNodes.length) {
|
|
264
|
-
for (const r of e.childNodes)
|
|
265
|
-
if (r && ((t = r.tagName) == null ? void 0 : t.toLowerCase()) === "span")
|
|
266
|
-
try {
|
|
267
|
-
const o = C(r);
|
|
268
|
-
n = `${n} ${o}`.trim(), r != null && r.childNodes.length && (n = `${n} ${Q(r)}`.trim());
|
|
269
|
-
} catch (o) {
|
|
270
|
-
console.error("[AutoCapture]", o);
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
return n;
|
|
274
|
-
}
|
|
275
|
-
const qe = ["input", "textarea", "select"], ee = (e) => {
|
|
276
|
-
var o, i, c;
|
|
277
|
-
const n = e.tagName.toLowerCase(), t = {
|
|
278
|
-
element: n
|
|
279
|
-
};
|
|
280
|
-
n.toLowerCase() === "a" || n.toLowerCase() === "button" ? t.text = W(e) : t.text = C(e);
|
|
281
|
-
const r = Array.from(e.attributes).reduce(
|
|
282
|
-
(s, a) => {
|
|
283
|
-
if (z(e) && !["name", "id", "class", "aria-label"].includes(a.name))
|
|
284
|
-
return s;
|
|
285
|
-
if (j(a.value) && !Ze(a.name)) {
|
|
286
|
-
if (a.name === "class")
|
|
287
|
-
return s;
|
|
288
|
-
s[a.name] = a.value;
|
|
289
|
-
}
|
|
290
|
-
return s;
|
|
291
|
-
},
|
|
292
|
-
{}
|
|
293
|
-
);
|
|
294
|
-
if (t.attributes = r, e.tagName.toLowerCase() === "a" || e.tagName.toLowerCase() === "button" ? t.text = W(e) || void 0 : t.text = C(e) || void 0, qe.includes(n)) {
|
|
295
|
-
let s = "";
|
|
296
|
-
t != null && t.attributes.id && (s = ((i = (o = document.querySelector(`label[for="${t == null ? void 0 : t.attributes.id}"]`)) == null ? void 0 : o.textContent) == null ? void 0 : i.trim()) || "");
|
|
297
|
-
const a = e.closest("label");
|
|
298
|
-
s || (s = ((c = a == null ? void 0 : a.textContent) == null ? void 0 : c.trim()) || ""), t.label = s || void 0;
|
|
299
|
-
}
|
|
300
|
-
return t;
|
|
301
|
-
}, Qe = (e, n) => {
|
|
302
|
-
var o;
|
|
303
|
-
let t = Ge(e);
|
|
304
|
-
J(t) && (t = t.parentNode || null);
|
|
305
|
-
const r = ["copy", "cut"].includes(n);
|
|
306
|
-
if (t && (Ke(t, e) || r)) {
|
|
307
|
-
const i = ee(t);
|
|
308
|
-
if (r) {
|
|
309
|
-
const c = X((o = window == null ? void 0 : window.getSelection()) == null ? void 0 : o.toString()), s = e.type || "clipboard";
|
|
310
|
-
i.copy_text = c ?? "", i.copy_type = s ?? "";
|
|
311
|
-
}
|
|
312
|
-
return i;
|
|
313
|
-
}
|
|
314
|
-
return null;
|
|
315
|
-
}, et = 30, tt = 1e3, nt = 3;
|
|
316
|
-
class rt {
|
|
317
|
-
constructor() {
|
|
318
|
-
U(this, "clicks");
|
|
319
|
-
this.clicks = [];
|
|
320
|
-
}
|
|
321
|
-
isRageClick(n, t, r) {
|
|
322
|
-
const o = this.clicks[this.clicks.length - 1];
|
|
323
|
-
if (o && Math.abs(n - o.x) + Math.abs(t - o.y) < et && r - o.timestamp < tt) {
|
|
324
|
-
if (this.clicks.push({ x: n, y: t, timestamp: r }), this.clicks.length === nt)
|
|
325
|
-
return !0;
|
|
326
|
-
} else
|
|
327
|
-
this.clicks = [{ x: n, y: t, timestamp: r }];
|
|
328
|
-
return !1;
|
|
329
|
-
}
|
|
330
|
-
}
|
|
331
|
-
const R = new rt(), ot = () => {
|
|
332
|
-
const { audience: e } = x();
|
|
333
|
-
f(() => {
|
|
334
|
-
const n = (t) => {
|
|
335
|
-
try {
|
|
336
|
-
let r = {
|
|
337
|
-
hostname: window.location.hostname,
|
|
338
|
-
pathname: window.location.pathname,
|
|
339
|
-
page_title: document.title,
|
|
340
|
-
url: window.location.href,
|
|
341
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString(),
|
|
342
|
-
event_type: t.type,
|
|
343
|
-
button_type: t.button
|
|
344
|
-
};
|
|
345
|
-
if (t.target instanceof HTMLElement) {
|
|
346
|
-
const o = t.target;
|
|
347
|
-
r.rage_click = R == null ? void 0 : R.isRageClick(
|
|
348
|
-
t.clientX,
|
|
349
|
-
t.clientY,
|
|
350
|
-
(/* @__PURE__ */ new Date()).getTime()
|
|
351
|
-
), r = {
|
|
352
|
-
...r,
|
|
353
|
-
...ee(o)
|
|
354
|
-
};
|
|
355
|
-
let i = o == null ? void 0 : o.getAttribute("href");
|
|
356
|
-
if (!i) {
|
|
357
|
-
let c = o.parentNode, s = 0;
|
|
358
|
-
for (; c && s < 8; ) {
|
|
359
|
-
const a = c == null ? void 0 : c.getAttribute(
|
|
360
|
-
"href"
|
|
361
|
-
);
|
|
362
|
-
if (a) {
|
|
363
|
-
i = a;
|
|
364
|
-
break;
|
|
365
|
-
}
|
|
366
|
-
c = c.parentNode, s++;
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
e == null || e.track("page.click", {
|
|
370
|
-
...r,
|
|
371
|
-
href: i || void 0
|
|
372
|
-
});
|
|
373
|
-
}
|
|
374
|
-
} catch (r) {
|
|
375
|
-
console.error(r);
|
|
376
|
-
}
|
|
377
|
-
};
|
|
378
|
-
return document.addEventListener("click", n), () => {
|
|
379
|
-
document.removeEventListener("click", n);
|
|
380
|
-
};
|
|
381
|
-
}, [e]);
|
|
382
|
-
}, gt = ({ id: e, properties: n = {} }) => {
|
|
383
|
-
const { client: t, audience: r } = x();
|
|
384
|
-
f(() => {
|
|
385
|
-
t && typeof window < "u" && (window.levo_client = t);
|
|
386
|
-
}, [t]), f(() => {
|
|
387
|
-
r && typeof window < "u" && (window.levo_audience = r);
|
|
388
|
-
}, [r]);
|
|
389
|
-
const o = typeof window < "u" ? window.location.href : void 0;
|
|
390
|
-
Pe(), Ue(), ot();
|
|
391
|
-
const i = De();
|
|
392
|
-
f(() => {
|
|
393
|
-
r != null && r.instance && i > 0 && r.track("page.scroll", {
|
|
394
|
-
resource: "page",
|
|
395
|
-
identifier: e,
|
|
396
|
-
percent: i
|
|
397
|
-
});
|
|
398
|
-
}, [r == null ? void 0 : r.instance, i, e]), f(() => {
|
|
399
|
-
const s = () => {
|
|
400
|
-
r == null || r.track("page.bounce", {
|
|
401
|
-
resource: "page",
|
|
402
|
-
identifier: e
|
|
403
|
-
});
|
|
404
|
-
};
|
|
405
|
-
return window && window.addEventListener("beforeunload", s), () => {
|
|
406
|
-
window && window.removeEventListener("beforeunload", s);
|
|
407
|
-
};
|
|
408
|
-
}, [r, e]);
|
|
409
|
-
const [c] = ue();
|
|
410
|
-
return f(() => {
|
|
411
|
-
(c === S.TERMINATED || c === S.HIDDEN || c === S.UNKNOWN || c === S.FROZEN) && (r == null || r.track("page.bounce", {
|
|
412
|
-
resource: "page",
|
|
413
|
-
identifier: e,
|
|
414
|
-
state: c
|
|
415
|
-
}));
|
|
416
|
-
}, [c, r, e]), f(() => {
|
|
417
|
-
(() => {
|
|
418
|
-
t != null && t.insightsUrl && t.workspace && o && (r != null && r.instance ? r.instance.page({
|
|
419
|
-
resource: "page",
|
|
420
|
-
identifier: e
|
|
421
|
-
}) : r == null || r.initiate({
|
|
422
|
-
...n,
|
|
423
|
-
id: e,
|
|
424
|
-
created_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
425
|
-
}));
|
|
426
|
-
})();
|
|
427
|
-
}, [t == null ? void 0 : t.insightsUrl, t == null ? void 0 : t.workspace, o]), f(() => {
|
|
428
|
-
const s = {
|
|
429
|
-
change: "form.change",
|
|
430
|
-
submit: "form.submit",
|
|
431
|
-
copy: "page.copy",
|
|
432
|
-
cut: "page.copy"
|
|
433
|
-
}, a = (p) => (g) => {
|
|
434
|
-
const m = Qe(g, p);
|
|
435
|
-
m && (r == null || r.track(s[p], m));
|
|
436
|
-
}, l = {
|
|
437
|
-
change: a("change"),
|
|
438
|
-
copy: a("copy"),
|
|
439
|
-
cut: a("cut"),
|
|
440
|
-
submit: a("submit")
|
|
441
|
-
};
|
|
442
|
-
return document.addEventListener("change", l.change), document.addEventListener("copy", l.copy), document.addEventListener("cut", l.cut), document.addEventListener("submit", l.submit), () => {
|
|
443
|
-
document.removeEventListener("change", l.change), document.removeEventListener("copy", l.copy), document.removeEventListener("cut", l.cut), document.removeEventListener("submit", l.submit);
|
|
444
|
-
};
|
|
445
|
-
}, []), (!(t != null && t.insightsUrl) || !t.workspace || !t.workspace.startsWith("W")) && console.error(
|
|
446
|
-
"[@levo-so/react] The utility could not be initialized, due to missing workspace, or endpoint for insights."
|
|
447
|
-
), null;
|
|
448
|
-
};
|
|
449
|
-
export {
|
|
450
|
-
ft as L,
|
|
451
|
-
dt as a,
|
|
452
|
-
gt as b
|
|
453
|
-
};
|