@levo-so/react 0.1.59 → 0.1.61

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/index.js CHANGED
@@ -1,1027 +1,604 @@
1
1
  "use client";
2
- var at = Object.defineProperty;
3
- var ct = (e, t, n) => t in e ? at(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
4
- var J = (e, t, n) => ct(e, typeof t != "symbol" ? t + "" : t, n);
5
2
  import * as D from "react";
6
- import A, { createContext as ut, useContext as Pe, useState as x, useEffect as b, useMemo as Ie, useRef as Ae, useCallback as fe } from "react";
7
- import { clsx as lt } from "clsx";
8
- import { twMerge as De } from "tailwind-merge";
9
- import { getLevoError as Me, LocalStorageLock as dt } from "@levo-so/core";
10
- import { usePageLifecycle as ft, LifecycleState as ue } from "use-page-lifecycle";
11
- import { Slot as mt, Dialog as j, Tabs as F, Tooltip as Y } from "radix-ui";
12
- import { cva as gt } from "class-variance-authority";
13
- import { X as pt } from "lucide-react";
14
- import { Toaster as bt, toast as me } from "sonner";
15
- import { toast as Br } from "sonner";
16
- const vt = [
17
- "pdf",
18
- "txt",
19
- "xml",
20
- "xls",
21
- "xlsx",
22
- "ods",
23
- "odt",
24
- "doc",
25
- "docx",
26
- "csv",
27
- "odp",
28
- "ppt",
29
- "pptx"
30
- ], ht = [
31
- "svg",
32
- "png",
33
- "jpg",
34
- "jpeg",
35
- "gif",
36
- "webp",
37
- "avif"
38
- ], wt = ["mp4", "ogv", "webm"], yt = ["mp3", "ogg", "opus"], xt = {
39
- "application/xml": [".xml"],
40
- "text/plain": [".txt"],
41
- "application/pdf": [".pdf"],
42
- "application/msword": [".doc"],
43
- "application/vnd.ms-excel": [".xls"],
44
- "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [
45
- ".xlsx"
46
- ],
47
- "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [
48
- ".docx"
49
- ],
50
- "text/csv": [".csv"]
51
- }, Tt = {
52
- "image/jpeg": [".jpeg", ".jpg"],
53
- "image/jpg": [".jpg"],
54
- "image/png": [".png"],
55
- "image/gif": [".gif"],
56
- "image/svg": [".svg"],
57
- "image/svg+xml": [".svg"],
58
- "image/webp": [".webp"],
59
- "image/avif": [".avif"]
60
- }, Et = {
61
- "video/mp4": [".mp4"],
62
- "video/mpeg": [".mpeg"],
63
- "video/webm": [".webm"]
64
- }, kt = {
65
- "audio/mpeg": [".mp3"],
66
- "audio/ogg": [".oga"],
67
- "audio/opus": [".opus"]
68
- }, X = {
69
- audio: kt,
70
- document: xt,
71
- image: Tt,
72
- video: Et
73
- }, q = {
74
- audio: yt,
75
- document: vt,
76
- image: ht,
77
- video: wt
78
- }, yr = [
79
- ...q.audio,
80
- ...q.document,
81
- ...q.image,
82
- ...q.video
83
- ], xr = {
84
- ...X.audio,
85
- ...X.document,
86
- ...X.image,
87
- ...X.video
88
- };
89
- var K = { exports: {} }, z = {};
90
- /**
91
- * @license React
92
- * react-jsx-runtime.production.js
93
- *
94
- * Copyright (c) Meta Platforms, Inc. and affiliates.
95
- *
96
- * This source code is licensed under the MIT license found in the
97
- * LICENSE file in the root directory of this source tree.
98
- */
99
- var Ee;
100
- function _t() {
101
- if (Ee) return z;
102
- Ee = 1;
3
+ import I, { createContext as ot, useContext as ge, useState as N, useEffect as k, useRef as H, useCallback as ee, useMemo as me } from "react";
4
+ import { clsx as st } from "clsx";
5
+ import { twMerge as Pe } from "tailwind-merge";
6
+ import { getLevoError as U } from "@levo-so/core";
7
+ import { usePageLifecycle as it, LifecycleState as ke } from "use-page-lifecycle";
8
+ import { Slot as at, Dialog as j, Tabs as W, Tooltip as z } from "radix-ui";
9
+ import { cva as ct } from "class-variance-authority";
10
+ import { X as lt } from "lucide-react";
11
+ import { Toaster as ut, toast as de } from "sonner";
12
+ import { toast as In } from "sonner";
13
+ var K = { exports: {} }, G = {};
14
+ var _e;
15
+ function dt() {
16
+ if (_e) return G;
17
+ _e = 1;
103
18
  var e = Symbol.for("react.transitional.element"), t = Symbol.for("react.fragment");
104
- function n(r, o, s) {
105
- var c = null;
106
- if (s !== void 0 && (c = "" + s), o.key !== void 0 && (c = "" + o.key), "key" in o) {
107
- s = {};
108
- for (var a in o)
109
- a !== "key" && (s[a] = o[a]);
110
- } else s = o;
111
- return o = s.ref, {
19
+ function r(n, o, i) {
20
+ var l = null;
21
+ if (i !== void 0 && (l = "" + i), o.key !== void 0 && (l = "" + o.key), "key" in o) {
22
+ i = {};
23
+ for (var c in o)
24
+ c !== "key" && (i[c] = o[c]);
25
+ } else i = o;
26
+ return o = i.ref, {
112
27
  $$typeof: e,
113
- type: r,
114
- key: c,
28
+ type: n,
29
+ key: l,
115
30
  ref: o !== void 0 ? o : null,
116
- props: s
31
+ props: i
117
32
  };
118
33
  }
119
- return z.Fragment = t, z.jsx = n, z.jsxs = n, z;
34
+ return G.Fragment = t, G.jsx = r, G.jsxs = r, G;
120
35
  }
121
- var H = {};
122
- /**
123
- * @license React
124
- * react-jsx-runtime.development.js
125
- *
126
- * Copyright (c) Meta Platforms, Inc. and affiliates.
127
- *
128
- * This source code is licensed under the MIT license found in the
129
- * LICENSE file in the root directory of this source tree.
130
- */
131
- var ke;
132
- function St() {
133
- return ke || (ke = 1, process.env.NODE_ENV !== "production" && function() {
134
- function e(i) {
135
- if (i == null) return null;
136
- if (typeof i == "function")
137
- return i.$$typeof === ot ? null : i.displayName || i.name || null;
138
- if (typeof i == "string") return i;
139
- switch (i) {
140
- case S:
36
+ var X = {};
37
+ var Se;
38
+ function ft() {
39
+ return Se || (Se = 1, process.env.NODE_ENV !== "production" && function() {
40
+ function e(s) {
41
+ if (s == null) return null;
42
+ if (typeof s == "function")
43
+ return s.$$typeof === tt ? null : s.displayName || s.name || null;
44
+ if (typeof s == "string") return s;
45
+ switch (s) {
46
+ case x:
141
47
  return "Fragment";
142
- case C:
48
+ case w:
143
49
  return "Profiler";
144
- case N:
50
+ case C:
145
51
  return "StrictMode";
146
- case M:
52
+ case v:
147
53
  return "Suspense";
148
- case w:
54
+ case L:
149
55
  return "SuspenseList";
150
- case G:
56
+ case et:
151
57
  return "Activity";
152
58
  }
153
- if (typeof i == "object")
154
- switch (typeof i.tag == "number" && console.error(
59
+ if (typeof s == "object")
60
+ switch (typeof s.tag == "number" && console.error(
155
61
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
156
- ), i.$$typeof) {
157
- case _:
158
- return "Portal";
159
- case y:
160
- return (i.displayName || "Context") + ".Provider";
161
- case T:
162
- return (i._context.displayName || "Context") + ".Consumer";
62
+ ), s.$$typeof) {
163
63
  case O:
164
- var g = i.render;
165
- return i = i.displayName, i || (i = g.displayName || g.name || "", i = i !== "" ? "ForwardRef(" + i + ")" : "ForwardRef"), i;
64
+ return "Portal";
166
65
  case P:
167
- return g = i.displayName || null, g !== null ? g : e(i.type) || "Memo";
168
- case $:
169
- g = i._payload, i = i._init;
66
+ return s.displayName || "Context";
67
+ case _:
68
+ return (s._context.displayName || "Context") + ".Consumer";
69
+ case M:
70
+ var f = s.render;
71
+ return s = s.displayName, s || (s = f.displayName || f.name || "", s = s !== "" ? "ForwardRef(" + s + ")" : "ForwardRef"), s;
72
+ case A:
73
+ return f = s.displayName || null, f !== null ? f : e(s.type) || "Memo";
74
+ case F:
75
+ f = s._payload, s = s._init;
170
76
  try {
171
- return e(i(g));
77
+ return e(s(f));
172
78
  } catch {
173
79
  }
174
80
  }
175
81
  return null;
176
82
  }
177
- function t(i) {
178
- return "" + i;
83
+ function t(s) {
84
+ return "" + s;
179
85
  }
180
- function n(i) {
86
+ function r(s) {
181
87
  try {
182
- t(i);
183
- var g = !1;
88
+ t(s);
89
+ var f = !1;
184
90
  } catch {
185
- g = !0;
91
+ f = !0;
186
92
  }
187
- if (g) {
188
- g = console;
189
- var h = g.error, E = typeof Symbol == "function" && Symbol.toStringTag && i[Symbol.toStringTag] || i.constructor.name || "Object";
190
- return h.call(
191
- g,
93
+ if (f) {
94
+ f = console;
95
+ var y = f.error, T = typeof Symbol == "function" && Symbol.toStringTag && s[Symbol.toStringTag] || s.constructor.name || "Object";
96
+ return y.call(
97
+ f,
192
98
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
193
- E
194
- ), t(i);
99
+ T
100
+ ), t(s);
195
101
  }
196
102
  }
197
- function r(i) {
198
- if (i === S) return "<>";
199
- if (typeof i == "object" && i !== null && i.$$typeof === $)
103
+ function n(s) {
104
+ if (s === x) return "<>";
105
+ if (typeof s == "object" && s !== null && s.$$typeof === F)
200
106
  return "<...>";
201
107
  try {
202
- var g = e(i);
203
- return g ? "<" + g + ">" : "<...>";
108
+ var f = e(s);
109
+ return f ? "<" + f + ">" : "<...>";
204
110
  } catch {
205
111
  return "<...>";
206
112
  }
207
113
  }
208
114
  function o() {
209
- var i = oe.A;
210
- return i === null ? null : i.getOwner();
115
+ var s = se.A;
116
+ return s === null ? null : s.getOwner();
211
117
  }
212
- function s() {
118
+ function i() {
213
119
  return Error("react-stack-top-frame");
214
120
  }
215
- function c(i) {
216
- if (ve.call(i, "key")) {
217
- var g = Object.getOwnPropertyDescriptor(i, "key").get;
218
- if (g && g.isReactWarning) return !1;
121
+ function l(s) {
122
+ if (ve.call(s, "key")) {
123
+ var f = Object.getOwnPropertyDescriptor(s, "key").get;
124
+ if (f && f.isReactWarning) return !1;
219
125
  }
220
- return i.key !== void 0;
126
+ return s.key !== void 0;
221
127
  }
222
- function a(i, g) {
223
- function h() {
224
- he || (he = !0, console.error(
128
+ function c(s, f) {
129
+ function y() {
130
+ ye || (ye = !0, console.error(
225
131
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
226
- g
132
+ f
227
133
  ));
228
134
  }
229
- h.isReactWarning = !0, Object.defineProperty(i, "key", {
230
- get: h,
135
+ y.isReactWarning = !0, Object.defineProperty(s, "key", {
136
+ get: y,
231
137
  configurable: !0
232
138
  });
233
139
  }
234
- function u() {
235
- var i = e(this.type);
236
- return we[i] || (we[i] = !0, console.error(
140
+ function a() {
141
+ var s = e(this.type);
142
+ return we[s] || (we[s] = !0, console.error(
237
143
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
238
- )), i = this.props.ref, i !== void 0 ? i : null;
144
+ )), s = this.props.ref, s !== void 0 ? s : null;
239
145
  }
240
- function l(i, g, h, E, W, I, ie, ae) {
241
- return h = I.ref, i = {
242
- $$typeof: v,
243
- type: i,
244
- key: g,
245
- props: I,
246
- _owner: W
247
- }, (h !== void 0 ? h : null) !== null ? Object.defineProperty(i, "ref", {
146
+ function d(s, f, y, T, q, ae) {
147
+ var E = y.ref;
148
+ return s = {
149
+ $$typeof: h,
150
+ type: s,
151
+ key: f,
152
+ props: y,
153
+ _owner: T
154
+ }, (E !== void 0 ? E : null) !== null ? Object.defineProperty(s, "ref", {
248
155
  enumerable: !1,
249
- get: u
250
- }) : Object.defineProperty(i, "ref", { enumerable: !1, value: null }), i._store = {}, Object.defineProperty(i._store, "validated", {
156
+ get: a
157
+ }) : Object.defineProperty(s, "ref", { enumerable: !1, value: null }), s._store = {}, Object.defineProperty(s._store, "validated", {
251
158
  configurable: !1,
252
159
  enumerable: !1,
253
160
  writable: !0,
254
161
  value: 0
255
- }), Object.defineProperty(i, "_debugInfo", {
162
+ }), Object.defineProperty(s, "_debugInfo", {
256
163
  configurable: !1,
257
164
  enumerable: !1,
258
165
  writable: !0,
259
166
  value: null
260
- }), Object.defineProperty(i, "_debugStack", {
167
+ }), Object.defineProperty(s, "_debugStack", {
261
168
  configurable: !1,
262
169
  enumerable: !1,
263
170
  writable: !0,
264
- value: ie
265
- }), Object.defineProperty(i, "_debugTask", {
171
+ value: q
172
+ }), Object.defineProperty(s, "_debugTask", {
266
173
  configurable: !1,
267
174
  enumerable: !1,
268
175
  writable: !0,
269
176
  value: ae
270
- }), Object.freeze && (Object.freeze(i.props), Object.freeze(i)), i;
177
+ }), Object.freeze && (Object.freeze(s.props), Object.freeze(s)), s;
271
178
  }
272
- function f(i, g, h, E, W, I, ie, ae) {
273
- var k = g.children;
274
- if (k !== void 0)
275
- if (E)
276
- if (st(k)) {
277
- for (E = 0; E < k.length; E++)
278
- d(k[E]);
279
- Object.freeze && Object.freeze(k);
179
+ function p(s, f, y, T, q, ae) {
180
+ var E = f.children;
181
+ if (E !== void 0)
182
+ if (T)
183
+ if (rt(E)) {
184
+ for (T = 0; T < E.length; T++)
185
+ u(E[T]);
186
+ Object.freeze && Object.freeze(E);
280
187
  } else
281
188
  console.error(
282
189
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
283
190
  );
284
- else d(k);
285
- if (ve.call(g, "key")) {
286
- k = e(i);
287
- var U = Object.keys(g).filter(function(it) {
288
- return it !== "key";
191
+ else u(E);
192
+ if (ve.call(f, "key")) {
193
+ E = e(s);
194
+ var B = Object.keys(f).filter(function(nt) {
195
+ return nt !== "key";
289
196
  });
290
- E = 0 < U.length ? "{key: someKey, " + U.join(": ..., ") + ": ...}" : "{key: someKey}", Te[k + E] || (U = 0 < U.length ? "{" + U.join(": ..., ") + ": ...}" : "{}", console.error(
197
+ T = 0 < B.length ? "{key: someKey, " + B.join(": ..., ") + ": ...}" : "{key: someKey}", Ee[E + T] || (B = 0 < B.length ? "{" + B.join(": ..., ") + ": ...}" : "{}", console.error(
291
198
  `A props object containing a "key" prop is being spread into JSX:
292
199
  let props = %s;
293
200
  <%s {...props} />
294
201
  React keys must be passed directly to JSX without using spread:
295
202
  let props = %s;
296
203
  <%s key={someKey} {...props} />`,
204
+ T,
297
205
  E,
298
- k,
299
- U,
300
- k
301
- ), Te[k + E] = !0);
206
+ B,
207
+ E
208
+ ), Ee[E + T] = !0);
302
209
  }
303
- if (k = null, h !== void 0 && (n(h), k = "" + h), c(g) && (n(g.key), k = "" + g.key), "key" in g) {
304
- h = {};
305
- for (var ce in g)
306
- ce !== "key" && (h[ce] = g[ce]);
307
- } else h = g;
308
- return k && a(
309
- h,
310
- typeof i == "function" ? i.displayName || i.name || "Unknown" : i
311
- ), l(
312
- i,
313
- k,
314
- I,
315
- W,
210
+ if (E = null, y !== void 0 && (r(y), E = "" + y), l(f) && (r(f.key), E = "" + f.key), "key" in f) {
211
+ y = {};
212
+ for (var ce in f)
213
+ ce !== "key" && (y[ce] = f[ce]);
214
+ } else y = f;
215
+ return E && c(
216
+ y,
217
+ typeof s == "function" ? s.displayName || s.name || "Unknown" : s
218
+ ), d(
219
+ s,
220
+ E,
221
+ y,
316
222
  o(),
317
- h,
318
- ie,
223
+ q,
319
224
  ae
320
225
  );
321
226
  }
322
- function d(i) {
323
- typeof i == "object" && i !== null && i.$$typeof === v && i._store && (i._store.validated = 1);
227
+ function u(s) {
228
+ m(s) ? s._store && (s._store.validated = 1) : typeof s == "object" && s !== null && s.$$typeof === F && (s._payload.status === "fulfilled" ? m(s._payload.value) && s._payload.value._store && (s._payload.value._store.validated = 1) : s._store && (s._store.validated = 1));
324
229
  }
325
- var m = A, v = Symbol.for("react.transitional.element"), _ = Symbol.for("react.portal"), S = Symbol.for("react.fragment"), N = Symbol.for("react.strict_mode"), C = Symbol.for("react.profiler"), T = Symbol.for("react.consumer"), y = Symbol.for("react.context"), O = Symbol.for("react.forward_ref"), M = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), P = Symbol.for("react.memo"), $ = Symbol.for("react.lazy"), G = Symbol.for("react.activity"), ot = Symbol.for("react.client.reference"), oe = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ve = Object.prototype.hasOwnProperty, st = Array.isArray, se = console.createTask ? console.createTask : function() {
230
+ function m(s) {
231
+ return typeof s == "object" && s !== null && s.$$typeof === h;
232
+ }
233
+ var b = I, h = Symbol.for("react.transitional.element"), O = Symbol.for("react.portal"), x = Symbol.for("react.fragment"), C = Symbol.for("react.strict_mode"), w = Symbol.for("react.profiler"), _ = Symbol.for("react.consumer"), P = Symbol.for("react.context"), M = Symbol.for("react.forward_ref"), v = Symbol.for("react.suspense"), L = Symbol.for("react.suspense_list"), A = Symbol.for("react.memo"), F = Symbol.for("react.lazy"), et = Symbol.for("react.activity"), tt = Symbol.for("react.client.reference"), se = b.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ve = Object.prototype.hasOwnProperty, rt = Array.isArray, ie = console.createTask ? console.createTask : function() {
326
234
  return null;
327
235
  };
328
- m = {
329
- react_stack_bottom_frame: function(i) {
330
- return i();
236
+ b = {
237
+ react_stack_bottom_frame: function(s) {
238
+ return s();
331
239
  }
332
240
  };
333
- var he, we = {}, ye = m.react_stack_bottom_frame.bind(
334
- m,
335
- s
336
- )(), xe = se(r(s)), Te = {};
337
- H.Fragment = S, H.jsx = function(i, g, h, E, W) {
338
- var I = 1e4 > oe.recentlyCreatedOwnerStacks++;
339
- return f(
340
- i,
341
- g,
342
- h,
241
+ var ye, we = {}, xe = b.react_stack_bottom_frame.bind(
242
+ b,
243
+ i
244
+ )(), Te = ie(n(i)), Ee = {};
245
+ X.Fragment = x, X.jsx = function(s, f, y) {
246
+ var T = 1e4 > se.recentlyCreatedOwnerStacks++;
247
+ return p(
248
+ s,
249
+ f,
250
+ y,
343
251
  !1,
344
- E,
345
- W,
346
- I ? Error("react-stack-top-frame") : ye,
347
- I ? se(r(i)) : xe
252
+ T ? Error("react-stack-top-frame") : xe,
253
+ T ? ie(n(s)) : Te
348
254
  );
349
- }, H.jsxs = function(i, g, h, E, W) {
350
- var I = 1e4 > oe.recentlyCreatedOwnerStacks++;
351
- return f(
352
- i,
353
- g,
354
- h,
255
+ }, X.jsxs = function(s, f, y) {
256
+ var T = 1e4 > se.recentlyCreatedOwnerStacks++;
257
+ return p(
258
+ s,
259
+ f,
260
+ y,
355
261
  !0,
356
- E,
357
- W,
358
- I ? Error("react-stack-top-frame") : ye,
359
- I ? se(r(i)) : xe
262
+ T ? Error("react-stack-top-frame") : xe,
263
+ T ? ie(n(s)) : Te
360
264
  );
361
265
  };
362
- }()), H;
363
- }
364
- var _e;
365
- function Ot() {
366
- return _e || (_e = 1, process.env.NODE_ENV === "production" ? K.exports = _t() : K.exports = St()), K.exports;
266
+ }()), X;
367
267
  }
368
- var p = Ot(), $e = {
369
- color: void 0,
370
- size: void 0,
371
- className: void 0,
372
- style: void 0,
373
- attr: void 0
374
- }, Se = A.createContext && /* @__PURE__ */ A.createContext($e), jt = ["attr", "size", "title"];
375
- function Nt(e, t) {
376
- if (e == null) return {};
377
- var n = Ct(e, t), r, o;
378
- if (Object.getOwnPropertySymbols) {
379
- var s = Object.getOwnPropertySymbols(e);
380
- for (o = 0; o < s.length; o++)
381
- r = s[o], !(t.indexOf(r) >= 0) && Object.prototype.propertyIsEnumerable.call(e, r) && (n[r] = e[r]);
382
- }
383
- return n;
268
+ var Oe;
269
+ function gt() {
270
+ return Oe || (Oe = 1, process.env.NODE_ENV === "production" ? K.exports = dt() : K.exports = ft()), K.exports;
384
271
  }
385
- function Ct(e, t) {
386
- if (e == null) return {};
387
- var n = {};
388
- for (var r in e)
389
- if (Object.prototype.hasOwnProperty.call(e, r)) {
390
- if (t.indexOf(r) >= 0) continue;
391
- n[r] = e[r];
272
+ var g = gt();
273
+ const pe = ot({
274
+ client: null,
275
+ insights: null
276
+ }), mn = ({ children: e, client: t, insights: r = null }) => /* @__PURE__ */ g.jsx(pe.Provider, { value: { client: t, insights: r }, children: e }), V = () => {
277
+ const e = ge(pe);
278
+ if (!e.client)
279
+ throw new Error(
280
+ "useLevo must be used within a LevoProvider. Please ensure you have wrapped your component tree with LevoProvider."
281
+ );
282
+ return e.client;
283
+ }, $ = () => ge(pe).insights, pn = ({ id: e, properties: t = {} }) => {
284
+ const r = $(), [n, o] = N(!1);
285
+ return k(() => {
286
+ if (n || typeof r?.track != "function") return;
287
+ const i = document.getElementById(e);
288
+ if (!i) return;
289
+ const l = () => {
290
+ n || (r?.track("block.view", {
291
+ ...t,
292
+ resource: "block",
293
+ identifier: e
294
+ }), o(!0));
295
+ };
296
+ if (((d) => {
297
+ const p = d.getBoundingClientRect();
298
+ return p.top >= 0 && p.left >= 0 && p.bottom <= (window.innerHeight || document.documentElement.clientHeight) && p.right <= (window.innerWidth || document.documentElement.clientWidth);
299
+ })(i)) {
300
+ l();
301
+ return;
392
302
  }
393
- return n;
303
+ const a = new IntersectionObserver(
304
+ (d) => {
305
+ d.forEach((p) => {
306
+ p.isIntersecting && (l(), a.disconnect());
307
+ });
308
+ },
309
+ { threshold: 0 }
310
+ );
311
+ return a.observe(i), () => {
312
+ a.disconnect();
313
+ };
314
+ }, [r, e, t, n]), null;
315
+ }, bn = ({ event: e, properties: t }) => {
316
+ const r = $();
317
+ return k(() => {
318
+ r?.instance && r?.track(e, t);
319
+ }, [r, e, t]), null;
320
+ }, mt = ({ id: e }) => {
321
+ const { logger: t } = V(), r = $(), n = H(!1), o = ee(
322
+ (l) => {
323
+ if (!n.current) {
324
+ n.current = !0;
325
+ try {
326
+ r?.bounce({
327
+ resource: "page",
328
+ identifier: e,
329
+ ...l
330
+ });
331
+ } catch (c) {
332
+ t?.error("Failed to send bounce event", U(c));
333
+ }
334
+ }
335
+ },
336
+ [r, e, t]
337
+ );
338
+ k(() => {
339
+ n.current = !1;
340
+ const l = () => {
341
+ const c = performance.getEntriesByType("navigation")?.[0];
342
+ let a = !1;
343
+ if (c)
344
+ c.type === "navigate" && (a = !0);
345
+ else
346
+ try {
347
+ const d = document.activeElement;
348
+ d?.tagName === "A" && d.href && new URL(d.href).origin !== window.location.origin && (a = !0);
349
+ } catch {
350
+ }
351
+ o({
352
+ is_navigating_away: a,
353
+ navigation_type: c?.type,
354
+ trigger: "beforeunload"
355
+ });
356
+ };
357
+ return window.addEventListener("beforeunload", l), () => {
358
+ window.removeEventListener("beforeunload", l);
359
+ };
360
+ }, [o]);
361
+ const [i] = it();
362
+ k(() => {
363
+ (i === ke.FROZEN || i === ke.TERMINATED) && o({
364
+ state: i,
365
+ trigger: "lifecycle"
366
+ });
367
+ }, [i, o]);
368
+ }, pt = () => {
369
+ const e = $(), [t, r] = N(null);
370
+ return k(() => {
371
+ if (!e) return;
372
+ let n = sessionStorage.getItem(e.storage_keys.current_tab);
373
+ const o = JSON.parse(localStorage.getItem(e.storage_keys.all_tabs) || "[]");
374
+ n && o.includes(n) && (n = null), n || (n = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(e.storage_keys.current_tab, n)), o.includes(n) || (o.push(n), localStorage.setItem(e.storage_keys.all_tabs, JSON.stringify(o))), r(n);
375
+ const i = () => {
376
+ const l = o.filter((c) => c !== n);
377
+ localStorage.setItem(e.storage_keys.all_tabs, JSON.stringify(l));
378
+ };
379
+ return window.addEventListener("beforeunload", i), () => {
380
+ window.removeEventListener("beforeunload", i);
381
+ };
382
+ }, [e]), t;
383
+ }, bt = ({
384
+ id: e,
385
+ properties: t = {},
386
+ href: r
387
+ }) => {
388
+ const n = V(), o = $();
389
+ k(() => {
390
+ (() => {
391
+ o?.insightsUrl && n.workspace && r && (o?.instance ? o.instance.page({
392
+ resource: "page",
393
+ identifier: e
394
+ }) : o?.initiate({
395
+ ...t,
396
+ id: e,
397
+ created_at: (/* @__PURE__ */ new Date()).toISOString()
398
+ }));
399
+ })();
400
+ }, [o, n?.workspace, r]);
401
+ }, ht = () => {
402
+ const e = $(), [t, r] = N(0);
403
+ return k(() => {
404
+ if (!e) return;
405
+ const n = Number(localStorage.getItem(e?.storage_keys.open_tabs)) || 0;
406
+ r(n), localStorage.setItem(e?.storage_keys.open_tabs, (n + 1).toString());
407
+ const o = (l) => {
408
+ l.key === e?.storage_keys.open_tabs && r(Number(l.newValue) || 0);
409
+ };
410
+ window.addEventListener("storage", o);
411
+ const i = () => {
412
+ const l = Number(localStorage.getItem(e?.storage_keys.open_tabs)) || 0;
413
+ l > 0 && localStorage.setItem(e?.storage_keys.open_tabs, (l - 1).toString());
414
+ };
415
+ return window.addEventListener("beforeunload", i), () => {
416
+ window.removeEventListener("storage", o), window.removeEventListener("beforeunload", i);
417
+ };
418
+ }, [e]), t;
419
+ };
420
+ function fe(e) {
421
+ var t = typeof e;
422
+ return e != null && (t == "object" || t == "function");
394
423
  }
395
- function Q() {
396
- return Q = Object.assign ? Object.assign.bind() : function(e) {
397
- for (var t = 1; t < arguments.length; t++) {
398
- var n = arguments[t];
399
- for (var r in n)
400
- Object.prototype.hasOwnProperty.call(n, r) && (e[r] = n[r]);
401
- }
402
- return e;
403
- }, Q.apply(this, arguments);
424
+ var vt = typeof global == "object" && global && global.Object === Object && global, yt = typeof self == "object" && self && self.Object === Object && self, Ae = vt || yt || Function("return this")(), le = function() {
425
+ return Ae.Date.now();
426
+ }, wt = /\s/;
427
+ function xt(e) {
428
+ for (var t = e.length; t-- && wt.test(e.charAt(t)); )
429
+ ;
430
+ return t;
404
431
  }
405
- function Oe(e, t) {
406
- var n = Object.keys(e);
407
- if (Object.getOwnPropertySymbols) {
408
- var r = Object.getOwnPropertySymbols(e);
409
- t && (r = r.filter(function(o) {
410
- return Object.getOwnPropertyDescriptor(e, o).enumerable;
411
- })), n.push.apply(n, r);
412
- }
413
- return n;
432
+ var Tt = /^\s+/;
433
+ function Et(e) {
434
+ return e && e.slice(0, xt(e) + 1).replace(Tt, "");
414
435
  }
415
- function ee(e) {
416
- for (var t = 1; t < arguments.length; t++) {
417
- var n = arguments[t] != null ? arguments[t] : {};
418
- t % 2 ? Oe(Object(n), !0).forEach(function(r) {
419
- Rt(e, r, n[r]);
420
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Oe(Object(n)).forEach(function(r) {
421
- Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(n, r));
422
- });
436
+ var te = Ae.Symbol, Ie = Object.prototype, kt = Ie.hasOwnProperty, _t = Ie.toString, J = te ? te.toStringTag : void 0;
437
+ function St(e) {
438
+ var t = kt.call(e, J), r = e[J];
439
+ try {
440
+ e[J] = void 0;
441
+ var n = !0;
442
+ } catch {
423
443
  }
424
- return e;
444
+ var o = _t.call(e);
445
+ return n && (t ? e[J] = r : delete e[J]), o;
425
446
  }
426
- function Rt(e, t, n) {
427
- return t = Lt(t), t in e ? Object.defineProperty(e, t, { value: n, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = n, e;
447
+ var Ot = Object.prototype, Nt = Ot.toString;
448
+ function jt(e) {
449
+ return Nt.call(e);
428
450
  }
451
+ var Ct = "[object Null]", Rt = "[object Undefined]", Ne = te ? te.toStringTag : void 0;
429
452
  function Lt(e) {
430
- var t = Pt(e, "string");
431
- return typeof t == "symbol" ? t : t + "";
432
- }
433
- function Pt(e, t) {
434
- if (typeof e != "object" || !e) return e;
435
- var n = e[Symbol.toPrimitive];
436
- if (n !== void 0) {
437
- var r = n.call(e, t);
438
- if (typeof r != "object") return r;
439
- throw new TypeError("@@toPrimitive must return a primitive value.");
440
- }
441
- return (t === "string" ? String : Number)(e);
453
+ return e == null ? e === void 0 ? Rt : Ct : Ne && Ne in Object(e) ? St(e) : jt(e);
442
454
  }
443
- function We(e) {
444
- return e && e.map((t, n) => /* @__PURE__ */ A.createElement(t.tag, ee({
445
- key: n
446
- }, t.attr), We(t.child)));
455
+ function Pt(e) {
456
+ return e != null && typeof e == "object";
447
457
  }
458
+ var At = "[object Symbol]";
448
459
  function It(e) {
449
- return (t) => /* @__PURE__ */ A.createElement(At, Q({
450
- attr: ee({}, e.attr)
451
- }, t), We(e.child));
452
- }
453
- function At(e) {
454
- var t = (n) => {
455
- var {
456
- attr: r,
457
- size: o,
458
- title: s
459
- } = e, c = Nt(e, jt), a = o || n.size || "1em", u;
460
- return n.className && (u = n.className), e.className && (u = (u ? u + " " : "") + e.className), /* @__PURE__ */ A.createElement("svg", Q({
461
- stroke: "currentColor",
462
- fill: "currentColor",
463
- strokeWidth: "0"
464
- }, n.attr, r, c, {
465
- className: u,
466
- style: ee(ee({
467
- color: e.color || n.color
468
- }, n.style), e.style),
469
- height: a,
470
- width: a,
471
- xmlns: "http://www.w3.org/2000/svg"
472
- }), s && /* @__PURE__ */ A.createElement("title", null, s), e.children);
473
- };
474
- return Se !== void 0 ? /* @__PURE__ */ A.createElement(Se.Consumer, null, (n) => t(n)) : t($e);
460
+ return typeof e == "symbol" || Pt(e) && Lt(e) == At;
475
461
  }
476
- function Be(e) {
477
- return It({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M12 22c5.421 0 10-4.579 10-10h-2c0 4.337-3.663 8-8 8s-8-3.663-8-8c0-4.336 3.663-8 8-8V2C6.579 2 2 6.58 2 12c0 5.421 4.579 10 10 10z" }, child: [] }] })(e);
462
+ var je = NaN, Dt = /^[-+]0x[0-9a-f]+$/i, $t = /^0b[01]+$/i, Mt = /^0o[0-7]+$/i, Wt = parseInt;
463
+ function Ce(e) {
464
+ if (typeof e == "number")
465
+ return e;
466
+ if (It(e))
467
+ return je;
468
+ if (fe(e)) {
469
+ var t = typeof e.valueOf == "function" ? e.valueOf() : e;
470
+ e = fe(t) ? t + "" : t;
471
+ }
472
+ if (typeof e != "string")
473
+ return e === 0 ? e : +e;
474
+ e = Et(e);
475
+ var r = $t.test(e);
476
+ return r || Mt.test(e) ? Wt(e.slice(2), r ? 2 : 8) : Dt.test(e) ? je : +e;
478
477
  }
479
- const R = (...e) => De(lt(e)), Dt = gt(
480
- "inline-flex items-center justify-center text-sm font-medium ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 disabled:cursor-not-allowed",
481
- {
482
- variants: {
483
- variant: {
484
- default: "bg-primary text-primary-foreground hover:bg-primary/90",
485
- destructive: "bg-destructive text-white hover:bg-destructive/90",
486
- destructiveOutline: "border border-red-500 text-destructive bg-transparent shadow-sm hover:bg-destructive hover:text-white",
487
- outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
488
- secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
489
- secondaryOutline: "bg-transparent border border-solid border-white hover:bg-white hover:border-input",
490
- ghost: "hover:bg-accent hover:text-accent-foreground",
491
- link: "text-primary underline-offset-4 hover:underline"
492
- },
493
- size: {
494
- default: "h-10 px-4 py-2",
495
- xs: "h-8 px-3 text-xs",
496
- sm: "h-9 px-3",
497
- lg: "h-11 px-8",
498
- icon: "h-10 w-10",
499
- "icon-small": "h-8 w-8"
500
- },
501
- rounded: {
502
- small: "rounded",
503
- default: "rounded-md",
504
- large: "rounded-lg",
505
- full: "rounded-full"
506
- }
507
- },
508
- defaultVariants: {
509
- variant: "default",
510
- size: "default",
511
- rounded: "default"
512
- }
478
+ var Ft = "Expected a function", Bt = Math.max, Ut = Math.min;
479
+ function Yt(e, t, r) {
480
+ var n, o, i, l, c, a, d = 0, p = !1, u = !1, m = !0;
481
+ if (typeof e != "function")
482
+ throw new TypeError(Ft);
483
+ t = Ce(t) || 0, fe(r) && (p = !!r.leading, u = "maxWait" in r, i = u ? Bt(Ce(r.maxWait) || 0, t) : i, m = "trailing" in r ? !!r.trailing : m);
484
+ function b(v) {
485
+ var L = n, A = o;
486
+ return n = o = void 0, d = v, l = e.apply(A, L), l;
513
487
  }
514
- ), Mt = D.forwardRef(
515
- ({
516
- className: e,
517
- variant: t,
518
- size: n,
519
- rounded: r,
520
- asChild: o = !1,
521
- isLoading: s = !1,
522
- loadingText: c,
523
- disabled: a,
524
- ...u
525
- }, l) => {
526
- const f = o ? mt.Root : "button";
527
- return /* @__PURE__ */ p.jsx(
528
- f,
529
- {
530
- className: R(Dt({ variant: t, size: n, rounded: r, className: e })),
531
- ref: l,
532
- disabled: a || s,
533
- type: "button",
534
- ...u,
535
- children: s ? /* @__PURE__ */ p.jsxs(p.Fragment, { children: [
536
- /* @__PURE__ */ p.jsx(
537
- Be,
538
- {
539
- className: De(
540
- "h-4 w-4 animate-spin",
541
- c ? "mr-2" : ""
542
- )
543
- }
544
- ),
545
- c
546
- ] }) : u.children
547
- }
548
- );
488
+ function h(v) {
489
+ return d = v, c = setTimeout(C, t), p ? b(v) : l;
549
490
  }
550
- );
551
- Mt.displayName = "Button";
552
- const $t = j.Root, Tr = j.Trigger, Wt = j.Portal, Er = j.Close, Fe = D.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p.jsx(
553
- j.Overlay,
554
- {
555
- ref: n,
556
- className: R(
557
- "bg-background/80 data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 grid max-h-screen place-items-center overflow-y-auto py-10 backdrop-blur-sm",
558
- e
559
- ),
560
- ...t
491
+ function O(v) {
492
+ var L = v - a, A = v - d, F = t - L;
493
+ return u ? Ut(F, i - A) : F;
561
494
  }
562
- ));
563
- Fe.displayName = j.Overlay.displayName;
564
- const Ue = D.forwardRef(
565
- ({
566
- className: e,
567
- children: t,
568
- container: n,
569
- hideCloseButton: r,
570
- overlayStyles: o,
571
- ...s
572
- }, c) => /* @__PURE__ */ p.jsx(Wt, { container: n, children: /* @__PURE__ */ p.jsx(Fe, { className: o, children: /* @__PURE__ */ p.jsxs(
573
- j.Content,
574
- {
575
- ref: c,
576
- className: R(
577
- "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-50 grid w-full max-w-lg gap-4 border p-6 shadow-lg duration-200 sm:rounded-lg",
578
- e
579
- ),
580
- ...s,
581
- children: [
582
- t,
583
- !r && /* @__PURE__ */ p.jsxs(
584
- j.Close,
585
- {
586
- type: "button",
587
- className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-sm p-1 opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-none disabled:pointer-events-none",
588
- children: [
589
- /* @__PURE__ */ p.jsx(pt, { className: "h-4 w-4" }),
590
- /* @__PURE__ */ p.jsx("span", { className: "sr-only", children: "Close" })
591
- ]
592
- }
593
- )
594
- ]
595
- }
596
- ) }) })
597
- );
598
- Ue.displayName = j.Content.displayName;
599
- const Ye = ({
600
- className: e,
601
- ...t
602
- }) => /* @__PURE__ */ p.jsx(
603
- "div",
604
- {
605
- className: R(
606
- "flex flex-col space-y-1.5 text-center sm:text-left",
607
- e
608
- ),
609
- ...t
495
+ function x(v) {
496
+ var L = v - a, A = v - d;
497
+ return a === void 0 || L >= t || L < 0 || u && A >= i;
610
498
  }
611
- );
612
- Ye.displayName = "DialogHeader";
613
- const Bt = ({
614
- className: e,
615
- ...t
616
- }) => /* @__PURE__ */ p.jsx(
617
- "div",
618
- {
619
- className: R(
620
- "flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2",
621
- e
622
- ),
623
- ...t
499
+ function C() {
500
+ var v = le();
501
+ if (x(v))
502
+ return w(v);
503
+ c = setTimeout(C, O(v));
624
504
  }
625
- );
626
- Bt.displayName = "DialogFooter";
627
- const ze = D.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p.jsx(
628
- j.Title,
629
- {
630
- ref: n,
631
- className: R(
632
- "text-lg leading-none font-semibold tracking-tight",
633
- e
634
- ),
635
- ...t
505
+ function w(v) {
506
+ return c = void 0, m && n ? b(v) : (n = o = void 0, l);
636
507
  }
637
- ));
638
- ze.displayName = j.Title.displayName;
639
- const He = D.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p.jsx(
640
- j.Description,
641
- {
642
- ref: n,
643
- className: R("text-muted-foreground text-sm", e),
644
- ...t
508
+ function _() {
509
+ c !== void 0 && clearTimeout(c), d = 0, n = a = o = c = void 0;
645
510
  }
646
- ));
647
- He.displayName = j.Description.displayName;
648
- const kr = ({
649
- isOpen: e,
650
- onClose: t,
651
- children: n,
652
- title: r,
653
- description: o = "",
654
- contentClassName: s,
655
- modal: c = !0
656
- }) => /* @__PURE__ */ p.jsx($t, { open: e, onOpenChange: t, modal: c, children: /* @__PURE__ */ p.jsxs(Ue, { className: s, children: [
657
- r && /* @__PURE__ */ p.jsxs(Ye, { className: "flex-1 font-medium", children: [
658
- /* @__PURE__ */ p.jsx(ze, { children: r }),
659
- /* @__PURE__ */ p.jsx(He, { children: o })
660
- ] }),
661
- /* @__PURE__ */ p.jsx("div", { className: "w-full", children: n })
662
- ] }) }), _r = ({ ...e }) => /* @__PURE__ */ p.jsx(
663
- bt,
664
- {
665
- closeButton: !0,
666
- richColors: !0,
667
- className: "toaster group",
668
- toastOptions: {
669
- classNames: {
670
- toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
671
- description: "group-[.toast]:text-muted-foreground",
672
- actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
673
- cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"
674
- }
675
- },
676
- ...e
677
- }
678
- ), Ft = (e, t = "Error", n = {}) => {
679
- me.error(t, {
680
- description: e,
681
- duration: 4e3,
682
- position: "bottom-right",
683
- ...n
684
- });
685
- }, Sr = (e, t = "Success", n = {}) => {
686
- n != null && n.id && me.dismiss(n == null ? void 0 : n.id), me.success(t, {
687
- description: e,
688
- duration: 4e3,
689
- position: "bottom-right",
690
- ...n
691
- });
692
- }, Ut = ({ className: e }) => /* @__PURE__ */ p.jsx(Be, { className: R("h-8 w-8 animate-spin font-light", e) }), Or = F.Root, Yt = D.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p.jsx(
693
- F.List,
694
- {
695
- ref: n,
696
- className: R(
697
- "bg-muted text-muted-foreground inline-flex h-10 items-center justify-center rounded-md p-1",
698
- e
699
- ),
700
- ...t
701
- }
702
- ));
703
- Yt.displayName = F.List.displayName;
704
- const zt = D.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p.jsx(
705
- F.Trigger,
706
- {
707
- ref: n,
708
- className: R(
709
- "ring-offset-background focus-visible:ring-ring data-[state=active]:bg-background data-[state=active]:text-foreground inline-flex items-center justify-center rounded-sm px-3 py-1.5 text-sm font-medium whitespace-nowrap transition-all focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm",
710
- e
711
- ),
712
- "data-levo-studio-interactive": "true",
713
- ...t
714
- }
715
- ));
716
- zt.displayName = F.Trigger.displayName;
717
- const Ht = D.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ p.jsx(
718
- F.Content,
719
- {
720
- ref: n,
721
- className: R(
722
- "ring-offset-background focus-visible:ring-ring mt-2 focus-visible:ring-2 focus-visible:ring-offset-2 focus-visible:outline-none",
723
- e
724
- ),
725
- ...t
726
- }
727
- ));
728
- Ht.displayName = F.Content.displayName;
729
- const jr = Y.Provider, Vt = Y.Root, Gt = Y.Trigger, Jt = Y.Portal, Ve = D.forwardRef(({ className: e, sideOffset: t = 4, ...n }, r) => /* @__PURE__ */ p.jsx(
730
- Y.Content,
731
- {
732
- ref: r,
733
- sideOffset: t,
734
- className: R(
735
- "bg-popover text-popover-foreground 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 z-50 overflow-hidden rounded-md border px-3 py-1.5 text-xs shadow-md",
736
- e
737
- ),
738
- ...n
739
- }
740
- ));
741
- Ve.displayName = Y.Content.displayName;
742
- const Nr = ({
743
- children: e,
744
- label: t,
745
- labelClassName: n,
746
- asChild: r = !0,
747
- contentProps: o = {},
748
- side: s
749
- }) => /* @__PURE__ */ p.jsxs(Vt, { children: [
750
- t && /* @__PURE__ */ p.jsx(Jt, { children: /* @__PURE__ */ p.jsx(
751
- Ve,
752
- {
753
- side: s,
754
- className: n,
755
- ...o,
756
- children: t
757
- }
758
- ) }),
759
- /* @__PURE__ */ p.jsx(Gt, { asChild: r, children: e })
760
- ] }), Cr = (e, t = 2) => {
761
- if (e === 0) return "0 B";
762
- const n = 1024, r = t < 0 ? 0 : t, o = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], s = Math.floor(Math.log(e) / Math.log(n));
763
- return `${Number.parseFloat((e / n ** s).toFixed(r))} ${o[s]}`;
764
- }, Rr = (e) => {
765
- const t = Me(e);
766
- return Ft((t == null ? void 0 : t.message) || "", (t == null ? void 0 : t.title) || "Error", {
767
- id: `${(t == null ? void 0 : t.title) || ""}-${(t == null ? void 0 : t.message) || ""}`
768
- }), t;
769
- }, Xt = (e) => e instanceof Date, qt = (e) => e == null, Kt = (e) => typeof e == "object", Zt = (e) => !qt(e) && !Array.isArray(e) && Kt(e) && !Xt(e), Lr = (e) => Zt(e) && !Object.keys(e).length, Ge = ut(null), Pr = ({ children: e, client: t }) => /* @__PURE__ */ p.jsx(Ge.Provider, { value: t, children: e }), L = () => {
770
- const e = Pe(Ge);
771
- if (!e)
772
- throw new Error(
773
- "useLevo must be used within a LevoProvider. Please ensure you have wrapped your component tree with LevoProvider."
774
- );
775
- return e;
776
- }, Ir = ({ id: e, properties: t = {} }) => {
777
- const { audience: n } = L(), [r, o] = x(!1);
778
- return b(() => {
779
- if (r || typeof (n == null ? void 0 : n.track) != "function") return;
780
- const s = document.getElementById(e);
781
- if (!s) return;
782
- const c = () => {
783
- r || (n == null || n.track("block.view", {
784
- ...t,
785
- resource: "block",
786
- identifier: e
787
- }), o(!0));
788
- };
789
- if (((l) => {
790
- const f = l.getBoundingClientRect();
791
- return f.top >= 0 && f.left >= 0 && f.bottom <= (window.innerHeight || document.documentElement.clientHeight) && f.right <= (window.innerWidth || document.documentElement.clientWidth);
792
- })(s)) {
793
- c();
794
- return;
795
- }
796
- const u = new IntersectionObserver(
797
- (l) => {
798
- l.forEach((f) => {
799
- f.isIntersecting && (c(), u.disconnect());
800
- });
801
- },
802
- { threshold: 0 }
803
- );
804
- return u.observe(s), () => {
805
- u.disconnect();
806
- };
807
- }, [n, e, t, r]), null;
808
- }, Ar = ({ event: e, properties: t }) => {
809
- const { audience: n } = L();
810
- return b(() => {
811
- n != null && n.instance && (n == null || n.track(e, t));
812
- }, [n == null ? void 0 : n.instance, e, t]), null;
813
- };
814
- function ge(e) {
815
- var t = typeof e;
816
- return e != null && (t == "object" || t == "function");
817
- }
818
- var Qt = typeof global == "object" && global && global.Object === Object && global, en = typeof self == "object" && self && self.Object === Object && self, Je = Qt || en || Function("return this")(), le = function() {
819
- return Je.Date.now();
820
- }, tn = /\s/;
821
- function nn(e) {
822
- for (var t = e.length; t-- && tn.test(e.charAt(t)); )
823
- ;
824
- return t;
825
- }
826
- var rn = /^\s+/;
827
- function on(e) {
828
- return e && e.slice(0, nn(e) + 1).replace(rn, "");
829
- }
830
- var te = Je.Symbol, Xe = Object.prototype, sn = Xe.hasOwnProperty, an = Xe.toString, V = te ? te.toStringTag : void 0;
831
- function cn(e) {
832
- var t = sn.call(e, V), n = e[V];
833
- try {
834
- e[V] = void 0;
835
- var r = !0;
836
- } catch {
837
- }
838
- var o = an.call(e);
839
- return r && (t ? e[V] = n : delete e[V]), o;
840
- }
841
- var un = Object.prototype, ln = un.toString;
842
- function dn(e) {
843
- return ln.call(e);
844
- }
845
- var fn = "[object Null]", mn = "[object Undefined]", je = te ? te.toStringTag : void 0;
846
- function gn(e) {
847
- return e == null ? e === void 0 ? mn : fn : je && je in Object(e) ? cn(e) : dn(e);
848
- }
849
- function pn(e) {
850
- return e != null && typeof e == "object";
851
- }
852
- var bn = "[object Symbol]";
853
- function vn(e) {
854
- return typeof e == "symbol" || pn(e) && gn(e) == bn;
855
- }
856
- var Ne = NaN, hn = /^[-+]0x[0-9a-f]+$/i, wn = /^0b[01]+$/i, yn = /^0o[0-7]+$/i, xn = parseInt;
857
- function Ce(e) {
858
- if (typeof e == "number")
859
- return e;
860
- if (vn(e))
861
- return Ne;
862
- if (ge(e)) {
863
- var t = typeof e.valueOf == "function" ? e.valueOf() : e;
864
- e = ge(t) ? t + "" : t;
865
- }
866
- if (typeof e != "string")
867
- return e === 0 ? e : +e;
868
- e = on(e);
869
- var n = wn.test(e);
870
- return n || yn.test(e) ? xn(e.slice(2), n ? 2 : 8) : hn.test(e) ? Ne : +e;
871
- }
872
- var Tn = "Expected a function", En = Math.max, kn = Math.min;
873
- function _n(e, t, n) {
874
- var r, o, s, c, a, u, l = 0, f = !1, d = !1, m = !0;
875
- if (typeof e != "function")
876
- throw new TypeError(Tn);
877
- t = Ce(t) || 0, ge(n) && (f = !!n.leading, d = "maxWait" in n, s = d ? En(Ce(n.maxWait) || 0, t) : s, m = "trailing" in n ? !!n.trailing : m);
878
- function v(w) {
879
- var P = r, $ = o;
880
- return r = o = void 0, l = w, c = e.apply($, P), c;
881
- }
882
- function _(w) {
883
- return l = w, a = setTimeout(C, t), f ? v(w) : c;
884
- }
885
- function S(w) {
886
- var P = w - u, $ = w - l, G = t - P;
887
- return d ? kn(G, s - $) : G;
888
- }
889
- function N(w) {
890
- var P = w - u, $ = w - l;
891
- return u === void 0 || P >= t || P < 0 || d && $ >= s;
892
- }
893
- function C() {
894
- var w = le();
895
- if (N(w))
896
- return T(w);
897
- a = setTimeout(C, S(w));
898
- }
899
- function T(w) {
900
- return a = void 0, m && r ? v(w) : (r = o = void 0, c);
901
- }
902
- function y() {
903
- a !== void 0 && clearTimeout(a), l = 0, r = u = o = a = void 0;
904
- }
905
- function O() {
906
- return a === void 0 ? c : T(le());
511
+ function P() {
512
+ return c === void 0 ? l : w(le());
907
513
  }
908
514
  function M() {
909
- var w = le(), P = N(w);
910
- if (r = arguments, o = this, u = w, P) {
911
- if (a === void 0)
912
- return _(u);
913
- if (d)
914
- return clearTimeout(a), a = setTimeout(C, t), v(u);
515
+ var v = le(), L = x(v);
516
+ if (n = arguments, o = this, a = v, L) {
517
+ if (c === void 0)
518
+ return h(a);
519
+ if (u)
520
+ return clearTimeout(c), c = setTimeout(C, t), b(a);
915
521
  }
916
- return a === void 0 && (a = setTimeout(C, t)), c;
522
+ return c === void 0 && (c = setTimeout(C, t)), l;
917
523
  }
918
- return M.cancel = y, M.flush = O, M;
524
+ return M.cancel = _, M.flush = P, M;
919
525
  }
920
- const Sn = () => {
921
- const [e, t] = x(0), [n, r] = x(0), [o, s] = x(0), [c, a] = x(Date.now()), [u, l] = x("read"), f = _n(() => {
922
- const d = window.scrollY, m = document.documentElement.scrollHeight, v = window.innerHeight, _ = Math.round(
923
- d / (m - v) * 100
924
- ), S = Math.floor(_ / 5) * 5;
925
- if (S <= n)
926
- return;
927
- const N = Date.now(), C = (N - c) / 1e3, y = Math.abs(d - o) / C;
928
- l(y > 300 ? "scan" : "read"), s(d), a(N), r(S), t(S);
929
- }, 250);
930
- return b(() => (window.addEventListener("scroll", f), () => window.removeEventListener("scroll", f)), []), { depth: e, speedCategory: u };
931
- }, On = () => {
932
- const e = L(), [t, n] = x(0);
933
- return b(() => {
934
- const r = Number(localStorage.getItem(e.audience.storage_keys.open_tabs)) || 0;
935
- n(r), localStorage.setItem(
936
- e.audience.storage_keys.open_tabs,
937
- (r + 1).toString()
938
- );
939
- const o = (c) => {
940
- c.key === e.audience.storage_keys.open_tabs && n(Number(c.newValue) || 0);
941
- };
942
- window.addEventListener("storage", o);
943
- const s = () => {
944
- const c = Number(localStorage.getItem(e.audience.storage_keys.open_tabs)) || 0;
945
- c > 0 && localStorage.setItem(
946
- e.audience.storage_keys.open_tabs,
947
- (c - 1).toString()
948
- );
949
- };
950
- return window.addEventListener("beforeunload", s), () => {
951
- window.removeEventListener("storage", o), window.removeEventListener("beforeunload", s);
952
- };
953
- }, []), t;
954
- }, jn = () => {
955
- const e = L(), [t, n] = x(null);
956
- return b(() => {
957
- let r = sessionStorage.getItem(
958
- e.audience.storage_keys.current_tab
959
- );
960
- const o = JSON.parse(
961
- localStorage.getItem(e.audience.storage_keys.all_tabs) || "[]"
962
- );
963
- r && o.includes(r) && (r = null), r || (r = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(
964
- e.audience.storage_keys.current_tab,
965
- r
966
- )), o.includes(r) || (o.push(r), localStorage.setItem(
967
- e.audience.storage_keys.all_tabs,
968
- JSON.stringify(o)
969
- )), n(r);
970
- const s = () => {
971
- const c = o.filter(
972
- (a) => a !== r
973
- );
974
- localStorage.setItem(
975
- e.audience.storage_keys.all_tabs,
976
- JSON.stringify(c)
977
- );
978
- };
979
- return window.addEventListener("beforeunload", s), () => {
980
- window.removeEventListener("beforeunload", s);
981
- };
982
- }, []), t;
983
- }, ne = (e) => Object.prototype.toString.call(e) == "[object String]", Nn = (e, t) => e.indexOf(t) !== -1, re = (e) => e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), qe = (e) => e === void 0, Cn = (e) => e === null, Ke = (e) => qe(e) || Cn(e), Ze = (e) => !!e && (e == null ? void 0 : e.nodeType) === 3;
984
- function Rn(e) {
985
- return !!e && (e == null ? void 0 : e.nodeType) === 1;
526
+ const Ht = () => {
527
+ const [e, t] = N(0), [r, n] = N("read"), [o, i] = N("down"), l = H({
528
+ prevMilestone: 0,
529
+ prevScrollY: 0,
530
+ prevTime: Date.now()
531
+ }), c = H({ setDepth: t, setSpeedCategory: n, setDirection: i });
532
+ c.current = { setDepth: t, setSpeedCategory: n, setDirection: i };
533
+ const a = me(
534
+ () => Yt(() => {
535
+ const d = window.scrollY, p = document.documentElement.scrollHeight, u = window.innerHeight, m = p - u;
536
+ if (m <= 0) return;
537
+ const b = Math.round(d / m * 100), h = Math.max(0, Math.min(100, b)), O = Math.floor(h / 5) * 5, { prevMilestone: x, prevScrollY: C, prevTime: w } = l.current, _ = O > x ? "down" : "up";
538
+ if (O === x)
539
+ return;
540
+ const P = Date.now(), M = (P - w) / 1e3, v = Math.abs(d - C), A = (M > 0 ? v / M : 0) > 300 ? "scan" : "read";
541
+ l.current = {
542
+ prevMilestone: O,
543
+ prevScrollY: d,
544
+ prevTime: P
545
+ }, c.current.setDepth(O), c.current.setSpeedCategory(A), c.current.setDirection(_);
546
+ }, 250),
547
+ []
548
+ );
549
+ return k(() => (window.addEventListener("scroll", a), () => {
550
+ window.removeEventListener("scroll", a), a.cancel();
551
+ }), [a]), { depth: e, speedCategory: r, direction: o };
552
+ }, re = (e) => Object.prototype.toString.call(e) == "[object String]", zt = (e, t) => e.indexOf(t) !== -1, Y = (e) => e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, ""), De = (e) => e === void 0, Vt = (e) => e === null, $e = (e) => De(e) || Vt(e), Me = (e) => !!e && e?.nodeType === 3;
553
+ function Gt(e) {
554
+ return !!e && e?.nodeType === 1;
986
555
  }
987
- function Ln(e, t) {
988
- return !!e && !!(e != null && e.tagName) && (e == null ? void 0 : e.tagName.toLowerCase()) === t.toLowerCase();
556
+ function Xt(e, t) {
557
+ return !!e && !!e?.tagName && e?.tagName.toLowerCase() === t.toLowerCase();
989
558
  }
990
- function Pn(e) {
991
- return e ? re(e).split(/\s+/) : [];
559
+ function Jt(e) {
560
+ return e ? Y(e).split(/\s+/) : [];
992
561
  }
993
- function In(e) {
562
+ function qt(e) {
994
563
  let t = "";
995
- switch (typeof (e == null ? void 0 : e.className)) {
564
+ switch (typeof e?.className) {
996
565
  case "string":
997
- t = e == null ? void 0 : e.className;
566
+ t = e?.className;
998
567
  break;
999
568
  // TODO: when is this ever used?
1000
569
  case "object":
1001
- t = (e != null && e.className && "baseVal" in (e == null ? void 0 : e.className) ? (e == null ? void 0 : e.className).baseVal : null) || (e == null ? void 0 : e.getAttribute("class")) || "";
570
+ t = (e?.className && "baseVal" in e?.className ? (e?.className).baseVal : null) || e?.getAttribute("class") || "";
1002
571
  break;
1003
572
  default:
1004
573
  t = "";
1005
574
  }
1006
- return Pn(t);
575
+ return Jt(t);
1007
576
  }
1008
- const B = (e, t = 255) => Ke(e) ? "" : re(e).split(/(\s+)/).filter((n) => be(n)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, t), pe = (e) => {
577
+ const S = (e, t = 255) => $e(e) ? "" : Y(e).split(/(\s+)/).filter((r) => he(r)).join("").replace(/[\r\n]/g, " ").replace(/[ ]+/g, " ").substring(0, t), We = ["span", "strong", "em", "i", "b", "mark", "code", "small", "sub", "sup", "label"], be = (e) => {
1009
578
  let t = "";
1010
- if (Mn(e) && // !isSensitiveElement(el) &&
1011
- (e != null && e.childNodes) && (e != null && e.childNodes.length))
1012
- for (const n of e == null ? void 0 : e.childNodes)
1013
- Ze(n) && n.textContent && (t += B(n.textContent) ?? "");
1014
- return re(t);
1015
- }, An = (e) => {
1016
- var t, n;
1017
- return qe(e.target) ? (e == null ? void 0 : e.srcElement) || null : (t = e == null ? void 0 : e.target) != null && t.shadowRoot ? ((n = e == null ? void 0 : e.composedPath()) == null ? void 0 : n[0]) || null : (e == null ? void 0 : e.target) || null;
1018
- }, Dn = (e, t) => {
1019
- if (!window || !e || Ln(e, "html") || !Rn(e))
579
+ if (er(e) && e?.childNodes && e?.childNodes.length) {
580
+ for (const r of e?.childNodes)
581
+ Me(r) && r.textContent && (t += S(r.textContent) ?? "");
582
+ if (!Y(t)) {
583
+ const r = e.querySelectorAll(We.join(", "));
584
+ for (const n of r) {
585
+ const o = n.textContent;
586
+ o && (t += `${S(o)} `);
587
+ }
588
+ }
589
+ if (!Y(t) && e instanceof HTMLElement) {
590
+ const r = e.innerText;
591
+ r && (t = S(r.substring(0, 500)));
592
+ }
593
+ }
594
+ return Y(t);
595
+ }, Kt = (e) => De(e.target) ? e?.srcElement || null : e?.target?.shadowRoot ? e?.composedPath()?.[0] || null : e?.target || null, Zt = (e, t) => {
596
+ if (!window || !e || Xt(e, "html") || !Gt(e))
1020
597
  return !1;
1021
- const n = window.getComputedStyle(e);
1022
- if (n && n.getPropertyValue("cursor") === "pointer" && t.type === "click")
598
+ const r = window.getComputedStyle(e);
599
+ if (r && r.getPropertyValue("cursor") === "pointer" && t.type === "click")
1023
600
  return !0;
1024
- switch (e == null ? void 0 : e.tagName.toLowerCase()) {
601
+ switch (e?.tagName.toLowerCase()) {
1025
602
  case "html":
1026
603
  return !1;
1027
604
  case "form":
@@ -1033,379 +610,740 @@ const B = (e, t = 255) => Ke(e) ? "" : re(e).split(/(\s+)/).filter((n) => be(n))
1033
610
  default:
1034
611
  return t.type === "click";
1035
612
  }
1036
- };
1037
- function Mn(e) {
1038
- if (Nn(In(e), "ph-include"))
613
+ }, Qt = /* @__PURE__ */ new Set([
614
+ "password",
615
+ "passwd",
616
+ "pwd",
617
+ "creditcard",
618
+ "cardnumber",
619
+ "ccnum",
620
+ "ccnumber",
621
+ "cvv",
622
+ "cvc",
623
+ "csc",
624
+ "securitycode",
625
+ "ssn",
626
+ "socialsecurity",
627
+ "routingnumber",
628
+ "accountnumber",
629
+ "bankaccount",
630
+ "secretkey",
631
+ "apikey",
632
+ "accesstoken"
633
+ ]);
634
+ function er(e) {
635
+ if (zt(qt(e), "ph-include"))
1039
636
  return !0;
1040
637
  const t = e.type || "";
1041
- if (ne(t))
638
+ if (re(t))
1042
639
  switch (t.toLowerCase()) {
1043
640
  case "hidden":
1044
641
  return !1;
1045
642
  case "password":
1046
643
  return !1;
1047
644
  }
1048
- const n = e.name || (e == null ? void 0 : e.id) || "";
1049
- return !(ne(n) && /^cc|cardnum|ccnum|creditcard|csc|cvc|cvv|exp|pass|pwd|routing|seccode|securitycode|securitynum|socialsec|socsec|ssn/i.test(n.replace(/[^a-zA-Z0-9]/g, "")));
645
+ const r = e.name || e?.id || "";
646
+ if (re(r)) {
647
+ const n = r.toLowerCase().replace(/[^a-z]/g, "");
648
+ if (Qt.has(n))
649
+ return !1;
650
+ }
651
+ return !0;
1050
652
  }
1051
- const Qe = "(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})", $n = new RegExp(`^(?:${Qe})$`), Wn = new RegExp(Qe), et = "\\d{3}-?\\d{2}-?\\d{4}", Bn = new RegExp(`^(${et})$`), Fn = new RegExp(`(${et})`), be = (e, t = !0) => !(Ke(e) || ne(e) && (e = re(e), (t ? $n : Wn).test((e || "").replace(/[- ]/g, "")) || (t ? Bn : Fn).test(e))), Un = (e) => ne(e) ? e.substring(0, 10) === "_ngcontent" || e.substring(0, 7) === "_nghost" : !1, Yn = (e) => {
1052
- let t = pe(e);
1053
- return t = `${t} ${tt(e)}`.trim(), be(t) ? t : "";
653
+ const Fe = "(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})", tr = new RegExp(`^(?:${Fe})$`), rr = new RegExp(Fe), Be = "\\d{3}-?\\d{2}-?\\d{4}", nr = new RegExp(`^(${Be})$`), or = new RegExp(`(${Be})`), he = (e, t = !0) => !($e(e) || re(e) && (e = Y(e), (t ? tr : rr).test((e || "").replace(/[- ]/g, "")) || (t ? nr : or).test(e))), sr = (e) => re(e) ? e.substring(0, 10) === "_ngcontent" || e.substring(0, 7) === "_nghost" : !1, ir = (e) => {
654
+ let t = be(e);
655
+ return t = `${t} ${Ue(e)}`.trim(), he(t) ? t : "";
1054
656
  };
1055
- function tt(e) {
1056
- var n;
657
+ function Ue(e) {
1057
658
  let t = "";
1058
- if (e != null && e.childNodes.length) {
1059
- for (const r of e.childNodes)
1060
- if (r && ((n = r.tagName) == null ? void 0 : n.toLowerCase()) === "span")
659
+ if (e?.childNodes.length)
660
+ for (const r of e.childNodes) {
661
+ const n = r.tagName?.toLowerCase();
662
+ if (r && n && We.includes(n))
1061
663
  try {
1062
- const o = pe(r);
1063
- t = `${t} ${o}`.trim(), r != null && r.childNodes.length && (t = `${t} ${tt(r)}`.trim());
664
+ const o = be(r);
665
+ t = `${t} ${o}`.trim(), r?.childNodes.length && (t = `${t} ${Ue(r)}`.trim());
1064
666
  } catch {
1065
667
  }
1066
- }
668
+ }
1067
669
  return t;
1068
670
  }
1069
- const zn = ["input", "textarea", "select"], nt = (e) => {
1070
- var o, s, c, a;
1071
- const t = (o = e == null ? void 0 : e.tagName) == null ? void 0 : o.toLowerCase(), n = {
671
+ const ar = (e) => {
672
+ const t = e.tagName?.toLowerCase(), r = t === "a" || t === "button" ? ir(e) : be(e);
673
+ if (r) return { text: r, source: "text" };
674
+ const n = e.getAttribute("aria-label");
675
+ if (n) return { text: S(n), source: "aria-label" };
676
+ const o = e.getAttribute("title");
677
+ if (o) return { text: S(o), source: "title" };
678
+ const i = e.getAttribute("data-track-label");
679
+ if (i) return { text: S(i), source: "data-track-label" };
680
+ const l = e.querySelector("img[alt], svg[aria-label]");
681
+ if (l) {
682
+ const a = l.getAttribute("alt") || l.getAttribute("aria-label");
683
+ if (a) return { text: S(a), source: "alt" };
684
+ }
685
+ const c = e.getAttribute("placeholder");
686
+ if (c) return { text: S(c), source: "placeholder" };
687
+ if (e instanceof HTMLElement && e.innerText) {
688
+ const a = e.innerText.substring(0, 500);
689
+ if (a.trim())
690
+ return { text: S(a), source: "innerText" };
691
+ }
692
+ return { text: "", source: "none" };
693
+ }, cr = ["input", "textarea", "select"], Ye = (e) => {
694
+ const t = e?.tagName?.toLowerCase(), r = {
1072
695
  element: t
1073
- };
1074
- (t == null ? void 0 : t.toLowerCase()) === "a" || (t == null ? void 0 : t.toLowerCase()) === "button" ? n.text = Yn(e) : n.text = pe(e);
1075
- const r = Array.from(e.attributes).reduce(
1076
- (u, l) => {
1077
- if (be(l.value) && !Un(l.name)) {
1078
- if (l.name === "class")
1079
- return u;
1080
- u[l.name] = typeof (l == null ? void 0 : l.value) == "string" ? B(l.value) : l.value;
696
+ }, n = ar(e);
697
+ r.text = n.text, r.text_source = n.source;
698
+ const o = e.getAttribute("aria-label");
699
+ o && (r.aria_label = S(o));
700
+ const i = e.getAttribute("role");
701
+ i && (r.role = i);
702
+ const l = {};
703
+ for (const a of e.attributes)
704
+ (a.name.startsWith("data-track-") || a.name.startsWith("data-analytics-")) && (l[a.name] = S(a.value));
705
+ Object.keys(l).length && (r.tracking_data = l);
706
+ const c = Array.from(e.attributes).reduce(
707
+ (a, d) => {
708
+ if (he(d.value) && !sr(d.name)) {
709
+ if (d.name === "class" || d.name.startsWith("data-track-") || d.name.startsWith("data-analytics-"))
710
+ return a;
711
+ a[d.name] = typeof d?.value == "string" ? S(d.value) : d.value;
1081
712
  }
1082
- return u;
713
+ return a;
1083
714
  },
1084
715
  {}
1085
716
  );
1086
- if (n.attributes = r, zn.includes(t) || (e == null ? void 0 : e.getAttribute("contenteditable")) === "true") {
1087
- let u;
1088
- e.matches('input[type="checkbox"], input[type="radio"]') ? u = e.checked : e.matches("input, select, textarea") && !e.matches('input[type="password"]') && (u = e.value), u !== void 0 && (n.value = typeof u == "string" || u === null ? B(u, 1024) : u);
1089
- let l = "";
1090
- n != null && n.attributes.id && (l = B(
1091
- ((c = (s = document.querySelector(`label[for="${n == null ? void 0 : n.attributes.id}"]`)) == null ? void 0 : s.textContent) == null ? void 0 : c.trim()) || ""
717
+ if (r.attributes = c, cr.includes(t) || e?.getAttribute("contenteditable") === "true") {
718
+ let a;
719
+ e.matches('input[type="checkbox"], input[type="radio"]') ? a = e.checked : e.matches("input, select, textarea") && !e.matches('input[type="password"]') && (a = e.value), a !== void 0 && (r.value = typeof a == "string" || a === null ? S(a, 1024) : a);
720
+ let d = "";
721
+ r?.attributes.id && (d = S(
722
+ document.querySelector(`label[for="${r?.attributes.id}"]`)?.textContent?.trim() || ""
1092
723
  ));
1093
- const f = e.closest("label");
1094
- l || (l = B(((a = f == null ? void 0 : f.textContent) == null ? void 0 : a.trim()) || "")), l && (n.label = l);
724
+ const p = e.closest("label");
725
+ d || (d = S(p?.textContent?.trim() || "")), d && (r.label = d);
1095
726
  }
1096
- return n;
1097
- }, Hn = (e, t) => {
1098
- var o;
1099
- let n = An(e);
1100
- Ze(n) && (n = n.parentNode || null);
1101
- const r = ["copy", "cut"].includes(t);
1102
- if (n && (r || Dn(n, e))) {
1103
- const s = nt(n);
1104
- if (r) {
1105
- const c = B((o = window == null ? void 0 : window.getSelection()) == null ? void 0 : o.toString()), a = (e == null ? void 0 : e.type) || "clipboard";
1106
- s.copy_text = c ?? "", s.copy_type = a;
727
+ return r;
728
+ }, lr = (e, t) => {
729
+ let r = Kt(e);
730
+ Me(r) && (r = r.parentNode || null);
731
+ const n = ["copy", "cut"].includes(t);
732
+ if (r && (n || Zt(r, e))) {
733
+ const o = Ye(r);
734
+ if (n) {
735
+ const i = S(window?.getSelection()?.toString()), l = e?.type || "clipboard";
736
+ o.copy_text = i ?? "", o.copy_type = l;
1107
737
  }
1108
- return s;
738
+ return o;
1109
739
  }
1110
740
  return null;
1111
- }, Vn = 30, Gn = 1e3, Jn = 3;
1112
- class Xn {
741
+ }, ur = () => {
742
+ const e = $();
743
+ k(() => {
744
+ let t;
745
+ const r = () => {
746
+ clearTimeout(t), t = setTimeout(() => {
747
+ const n = window.getSelection();
748
+ if (n && n?.rangeCount > 0) {
749
+ const o = n?.toString();
750
+ o && e?.track("page.selection", {
751
+ text: S(o)
752
+ });
753
+ }
754
+ }, 1e3);
755
+ };
756
+ return document.addEventListener("selectionchange", r), () => {
757
+ clearTimeout(t), document.removeEventListener("selectionchange", r);
758
+ };
759
+ }, []);
760
+ }, dr = 30, fr = 1e3, gr = 3;
761
+ class mr {
762
+ clicks;
1113
763
  constructor() {
1114
- J(this, "clicks");
1115
764
  this.clicks = [];
1116
765
  }
1117
- isRageClick(t, n, r) {
766
+ /**
767
+ * Check if the current click is part of a rage click sequence.
768
+ * Returns true for 3+ consecutive clicks within threshold.
769
+ */
770
+ isRageClick(t, r, n) {
1118
771
  const o = this.clicks[this.clicks.length - 1];
1119
- if (o && Math.abs(t - o.x) + Math.abs(n - o.y) < Vn && r - o.timestamp < Gn) {
1120
- if (this.clicks.push({ x: t, y: n, timestamp: r }), this.clicks.length === Jn)
772
+ if (o && Math.abs(t - o.x) + Math.abs(r - o.y) < dr && n - o.timestamp < fr) {
773
+ if (this.clicks.push({ x: t, y: r, timestamp: n }), this.clicks.length >= gr)
1121
774
  return !0;
1122
775
  } else
1123
- this.clicks = [{ x: t, y: n, timestamp: r }];
776
+ this.clicks = [{ x: t, y: r, timestamp: n }];
1124
777
  return !1;
1125
778
  }
779
+ /**
780
+ * Reset the click sequence (useful for testing)
781
+ */
782
+ reset() {
783
+ this.clicks = [];
784
+ }
1126
785
  }
1127
- const de = new Xn(), qn = () => {
1128
- const { audience: e } = L();
1129
- b(() => {
1130
- let t = null;
1131
- const n = (s) => {
1132
- if (t) {
1133
- clearTimeout(t), t = null;
786
+ const pr = new mr(), br = (e) => {
787
+ let t = e, r = 0;
788
+ for (; t && r < 10; ) {
789
+ const n = t.getAttribute?.("href");
790
+ if (n)
791
+ return n;
792
+ t = t.parentElement, r++;
793
+ }
794
+ return null;
795
+ }, ue = (e) => {
796
+ const t = e.closest("a[href]"), r = t?.getAttribute("href") || br(e);
797
+ if (!r) return { type: null, href: null };
798
+ if (t?.hasAttribute("download"))
799
+ return { type: "download", href: r };
800
+ if (r.startsWith("tel:")) return { type: "tel", href: r };
801
+ if (r.startsWith("mailto:")) return { type: "mailto", href: r };
802
+ if (r.startsWith("#")) return { type: "anchor", href: r };
803
+ try {
804
+ return {
805
+ type: new URL(r, window.location.origin).origin === window.location.origin ? "internal" : "external",
806
+ href: r
807
+ };
808
+ } catch {
809
+ return { type: "internal", href: r };
810
+ }
811
+ }, hr = () => {
812
+ const e = $(), { workspace: t, logger: r } = V(), n = H(0);
813
+ k(() => {
814
+ let o = null;
815
+ const i = (u, m = !1) => {
816
+ const b = u.target, h = "clientX" in u ? u.clientX : u.changedTouches?.[0]?.clientX ?? 0, O = "clientY" in u ? u.clientY : u.changedTouches?.[0]?.clientY ?? 0;
817
+ let x = {
818
+ hostname: window.location.hostname,
819
+ pathname: window.location.pathname,
820
+ page_title: document.title,
821
+ url: window.location.href,
822
+ created_at: (/* @__PURE__ */ new Date()).toISOString(),
823
+ event_type: m ? "dblclick" : "click",
824
+ button_type: "button" in u ? u.button : 0
825
+ };
826
+ return b instanceof HTMLElement && (x.rage_click = pr?.isRageClick(h, O, Date.now()), x = {
827
+ ...x,
828
+ ...Ye(b)
829
+ }), x;
830
+ }, l = (u, m) => {
831
+ try {
832
+ if (Date.now() - n.current < 300) return;
833
+ const b = i(u);
834
+ if (!e?.insightsUrl || !t) {
835
+ r?.warn("Cannot track navigation click: missing insightsUrl or workspace");
836
+ return;
837
+ }
838
+ e?.track("page.click", {
839
+ ...b,
840
+ href: m.href || void 0,
841
+ link_type: m.type,
842
+ is_navigation: !0
843
+ });
844
+ } catch (b) {
845
+ r?.error("Failed to track navigation click", U(b));
846
+ }
847
+ }, c = (u, m = !1) => {
848
+ try {
849
+ if (!(u.target instanceof HTMLElement) || Date.now() - n.current < 300) return;
850
+ const b = i(u, m), h = ue(u.target);
851
+ e?.track("page.click", {
852
+ ...b,
853
+ href: h.href || void 0,
854
+ link_type: h.type || void 0
855
+ });
856
+ } catch (b) {
857
+ r?.error("Failed to track click", U(b));
858
+ }
859
+ }, a = (u) => {
860
+ if (!(u.target instanceof HTMLElement)) return;
861
+ const m = ue(u.target);
862
+ if (m.type === "external" || m.type === "download") {
863
+ l(u, m);
1134
864
  return;
1135
865
  }
1136
- t = setTimeout(() => {
1137
- o(s, !1), t = null;
866
+ if (o) {
867
+ clearTimeout(o), o = null;
868
+ return;
869
+ }
870
+ o = setTimeout(() => {
871
+ c(u, !1), o = null;
1138
872
  }, 250);
1139
- }, r = (s) => {
1140
- t && (clearTimeout(t), t = null), o(s, !0);
1141
- }, o = (s, c = !1) => {
1142
- var a;
873
+ }, d = (u) => {
874
+ o && (clearTimeout(o), o = null), c(u, !0);
875
+ }, p = (u) => {
1143
876
  try {
1144
- let u = {
1145
- hostname: window.location.hostname,
1146
- pathname: window.location.pathname,
1147
- page_title: document.title,
1148
- url: window.location.href,
1149
- created_at: (/* @__PURE__ */ new Date()).toISOString(),
1150
- event_type: c ? "dblclick" : "click",
1151
- button_type: s.button
1152
- };
1153
- if (s.target instanceof HTMLElement) {
1154
- const l = s.target;
1155
- u.rage_click = de == null ? void 0 : de.isRageClick(
1156
- s.clientX,
1157
- s.clientY,
1158
- (/* @__PURE__ */ new Date()).getTime()
1159
- ), u = {
1160
- ...u,
1161
- ...nt(l)
1162
- };
1163
- let f = l == null ? void 0 : l.getAttribute("href");
1164
- if (!f) {
1165
- let d = l.parentNode, m = 0;
1166
- for (; d && m < 8; ) {
1167
- const v = (a = d == null ? void 0 : d.parentElement) == null ? void 0 : a.getAttribute("href");
1168
- if (v) {
1169
- f = v;
1170
- break;
1171
- }
1172
- d = d.parentNode, m++;
1173
- }
1174
- }
1175
- e == null || e.track("page.click", {
1176
- ...u,
1177
- href: f || void 0
877
+ if (!(u.target instanceof HTMLElement)) return;
878
+ n.current = Date.now();
879
+ const m = ue(u.target);
880
+ if (m.type === "external" || m.type === "download") {
881
+ const h = i(u);
882
+ e?.track("page.click", {
883
+ ...h,
884
+ href: m.href || void 0,
885
+ link_type: m.type,
886
+ is_navigation: !0,
887
+ is_touch: !0
1178
888
  });
889
+ return;
1179
890
  }
1180
- } catch {
1181
- }
1182
- };
1183
- return document.addEventListener("click", n), document.addEventListener("dblclick", r), () => {
1184
- document.removeEventListener("click", n), document.removeEventListener("dblclick", r);
1185
- };
1186
- }, [e]);
1187
- }, Z = (e) => Number(e.toFixed(0)), Kn = (e) => {
1188
- const { audience: t } = L(), [n] = x({
1189
- value: Z(performance.now()),
1190
- timestamp: Z(Date.now())
1191
- }), [r, o] = x({
1192
- value: null,
1193
- timestamp: null
1194
- }), [s, c] = x({
1195
- value: null,
1196
- timestamp: null
1197
- });
1198
- return b(() => {
1199
- let a = !0;
1200
- const u = (d, m) => {
1201
- a && d({ value: Z(m), timestamp: Z(Date.now()) });
1202
- }, l = new PerformanceObserver((d) => {
1203
- for (const m of d.getEntries())
1204
- m.name === "first-contentful-paint" && u(o, m.startTime);
1205
- });
1206
- l.observe({ type: "paint", buffered: !0 });
1207
- const f = () => u(c, performance.now());
1208
- return document.readyState === "complete" ? u(c, performance.now()) : window.addEventListener("load", f), () => {
1209
- a = !1, l.disconnect(), window.removeEventListener("load", f);
1210
- };
1211
- }, []), b(() => {
1212
- n && t && (t == null || t.track("page.metrics", {
1213
- script_load: n.value,
1214
- script_load_at: n.timestamp,
1215
- version: 2
1216
- }));
1217
- }, [n, t]), b(() => {
1218
- r.value !== null && t && (t == null || t.track("page.metrics", {
1219
- first_contentful_paint: r.value,
1220
- first_contentful_paint_at: r.timestamp,
1221
- version: 2
1222
- }));
1223
- }, [r, t]), b(() => {
1224
- s.value !== null && t && (t == null || t.track("page.metrics", {
1225
- window_onload: s.value,
1226
- window_onload_at: s.timestamp,
1227
- version: 2
1228
- }));
1229
- }, [s, t]), { script: n, fcp: r, window_onload: s };
1230
- }, Zn = () => {
1231
- const { audience: e } = L();
1232
- b(() => {
1233
- let t;
1234
- const n = () => {
1235
- clearTimeout(t), t = setTimeout(() => {
1236
- const r = window.getSelection();
1237
- if (r && (r == null ? void 0 : r.rangeCount) > 0) {
1238
- const o = r == null ? void 0 : r.toString();
1239
- o && (e == null || e.track("page.selection", {
1240
- text: B(o)
1241
- }));
1242
- }
1243
- }, 1e3);
1244
- };
1245
- return document.addEventListener("selectionchange", n), () => {
1246
- clearTimeout(t), document.removeEventListener("selectionchange", n);
1247
- };
1248
- }, []);
1249
- }, Re = "lv_insights_st", Qn = 15 * 60 * 1e3, er = (e = "https://cachefly.cachefly.net/1mb.test") => {
1250
- const [t, n] = x(null);
1251
- return b(() => {
1252
- const r = localStorage.getItem(Re);
1253
- if (r) {
1254
- const { speed: a, timestamp: u } = JSON.parse(r);
1255
- if (Date.now() - u < Qn) {
1256
- n(a);
1257
- return;
891
+ const b = i(u);
892
+ e?.track("page.click", {
893
+ ...b,
894
+ href: m.href || void 0,
895
+ link_type: m.type || void 0,
896
+ is_touch: !0
897
+ });
898
+ } catch (m) {
899
+ r?.error("Failed to track touch", U(m));
1258
900
  }
1259
- }
1260
- let o = null;
1261
- const s = async () => {
1262
- const a = new dt("download_speed");
1263
- if (a.acquireLock())
1264
- try {
1265
- const l = performance.now();
1266
- await fetch(e, { cache: "no-store" });
1267
- const d = (performance.now() - l) / 1e3, m = Math.round(8 / d);
1268
- n(m), localStorage.setItem(
1269
- Re,
1270
- JSON.stringify({ speed: m, timestamp: Date.now() })
1271
- );
1272
- } catch {
1273
- } finally {
1274
- a.releaseLock();
1275
- }
1276
- }, c = () => {
1277
- document.removeEventListener("mousemove", c), document.removeEventListener("keydown", c), document.removeEventListener("scroll", c), o = setTimeout(s, 5e3);
1278
- };
1279
- return document.addEventListener("mousemove", c, { once: !0 }), document.addEventListener("keydown", c, { once: !0 }), document.addEventListener("scroll", c, { once: !0 }), () => {
1280
- o && clearTimeout(o), document.removeEventListener("mousemove", c), document.removeEventListener("keydown", c), document.removeEventListener("scroll", c);
1281
- };
1282
- }, [e]), t;
1283
- }, tr = ({
1284
- id: e,
1285
- properties: t = {},
1286
- href: n
1287
- }) => {
1288
- const r = L();
1289
- b(() => {
1290
- (() => {
1291
- var s, c;
1292
- r != null && r.insightsUrl && r.workspace && n && ((s = r == null ? void 0 : r.audience) != null && s.instance ? r == null || r.audience.instance.page({
1293
- resource: "page",
1294
- identifier: e
1295
- }) : (c = r == null ? void 0 : r.audience) == null || c.initiate({
1296
- ...t,
1297
- id: e,
1298
- created_at: (/* @__PURE__ */ new Date()).toISOString()
1299
- }));
1300
- })();
1301
- }, [r == null ? void 0 : r.insightsUrl, r == null ? void 0 : r.workspace, n]), b(() => {
1302
- const o = (s) => {
1303
- var a;
1304
- const c = localStorage.getItem(
1305
- r.audience.storage_keys.identify
1306
- );
1307
- s.key === r.audience.storage_keys.identify && !(r != null && r.audience.is_identified) && !c && ((a = r == null ? void 0 : r.audience) == null || a.identify({
1308
- withLock: !1
1309
- }));
1310
- };
1311
- return window.addEventListener("storage", o), () => {
1312
- window.removeEventListener("storage", o);
1313
901
  };
1314
- }, []);
1315
- }, nr = ({ id: e }) => {
1316
- const t = L();
1317
- b(() => {
1318
- const r = () => {
1319
- var c, a;
1320
- const o = (c = performance.getEntriesByType(
1321
- "navigation"
1322
- )) == null ? void 0 : c[0];
1323
- let s = !1;
1324
- if (o)
1325
- o.type === "navigate" && (s = !0);
1326
- else
1327
- try {
1328
- const u = document.activeElement;
1329
- (u == null ? void 0 : u.tagName) === "A" && u.href && (new URL(u.href).origin !== window.location.origin ? s = !0 : s = !1);
1330
- } catch {
1331
- }
1332
- (a = t == null ? void 0 : t.audience) == null || a.bounce({
1333
- resource: "page",
1334
- identifier: e,
1335
- is_navigating_away: s,
1336
- navigation_type: o == null ? void 0 : o.type
1337
- });
1338
- };
1339
- return window.addEventListener("beforeunload", r), () => {
1340
- window.removeEventListener("beforeunload", r);
902
+ return document.addEventListener("click", a), document.addEventListener("dblclick", d), document.addEventListener("touchend", p, { passive: !0 }), () => {
903
+ document.removeEventListener("click", a), document.removeEventListener("dblclick", d), document.removeEventListener("touchend", p), o && clearTimeout(o);
1341
904
  };
1342
- }, [t == null ? void 0 : t.audience, e]);
1343
- const [n] = ft();
1344
- b(() => {
1345
- var r;
1346
- (n === ue.HIDDEN || n === ue.UNKNOWN || n === ue.FROZEN) && ((r = t == null ? void 0 : t.audience) == null || r.bounce({
1347
- resource: "page",
1348
- identifier: e,
1349
- state: n
1350
- }));
1351
- }, [n, t == null ? void 0 : t.audience, e]);
1352
- }, Dr = ({ id: e, properties: t = {} }) => {
1353
- var c;
1354
- const n = typeof window < "u" ? window.location.href : "", r = L();
1355
- b(() => {
1356
- r && typeof window < "u" && (window.levo_client = r);
1357
- }, [r]), b(() => {
1358
- r != null && r.audience && typeof window < "u" && (window.levo_audience = r == null ? void 0 : r.audience);
1359
- }, []), On(), jn(), qn();
1360
- const o = er();
1361
- b(() => {
1362
- var a;
1363
- (a = r == null ? void 0 : r.audience) != null && a.instance && o && (r == null || r.audience.track("user.speedtest", {
1364
- speed: o,
1365
- unit: "Mbps"
1366
- }));
1367
- }, [o]);
1368
- const s = Sn();
1369
- return b(() => {
1370
- var a;
1371
- (a = r == null ? void 0 : r.audience) != null && a.instance && (r == null || r.audience.track("page.scroll", {
905
+ }, [e, t, r]);
906
+ }, hn = ({ id: e, properties: t = {} }) => {
907
+ const r = typeof window < "u" ? window.location.href : "", n = V(), o = $();
908
+ k(() => {
909
+ n && typeof window < "u" && (window.levo_client = n);
910
+ }, [n]), k(() => {
911
+ o && typeof window < "u" && (window.levo_insights = o);
912
+ }, []), ht(), pt(), hr();
913
+ const i = Ht();
914
+ return k(() => {
915
+ o?.instance && o?.track("page.scroll", {
1372
916
  resource: "page",
1373
917
  identifier: e,
1374
- percent: s.depth,
1375
- speed_category: s.speedCategory
1376
- }));
1377
- }, [
1378
- (c = r == null ? void 0 : r.audience) == null ? void 0 : c.instance,
1379
- s.depth,
1380
- s.speedCategory,
1381
- e
1382
- ]), Kn(), Zn(), tr({
1383
- href: n,
918
+ percent: i.depth,
919
+ speed_category: i.speedCategory
920
+ });
921
+ }, [o, i.depth, i.speedCategory, e]), ur(), bt({
922
+ href: r,
1384
923
  id: e,
1385
924
  properties: t
1386
- }), nr({ id: e }), b(() => {
1387
- const a = {
925
+ }), mt({ id: e }), k(() => {
926
+ const l = {
1388
927
  change: "form.change",
1389
928
  submit: "form.submit",
1390
929
  copy: "page.copy",
1391
930
  cut: "page.copy"
1392
- }, u = (f) => (d) => {
1393
- var v;
1394
- const m = Hn(d, f);
1395
- m && a[f] && ((v = r == null ? void 0 : r.audience) == null || v.track(a[f], m));
1396
- }, l = {
1397
- change: u("change"),
1398
- copy: u("copy"),
1399
- cut: u("cut"),
1400
- submit: u("submit")
931
+ }, c = (d) => (p) => {
932
+ const u = lr(p, d);
933
+ u && l[d] && o?.track(l[d], u);
934
+ }, a = {
935
+ change: c("change"),
936
+ copy: c("copy"),
937
+ cut: c("cut"),
938
+ submit: c("submit")
1401
939
  };
1402
- return document.addEventListener("change", l.change), document.addEventListener("copy", l.copy), document.addEventListener("cut", l.cut), document.addEventListener("submit", l.submit), () => {
1403
- document.removeEventListener("change", l.change), document.removeEventListener("copy", l.copy), document.removeEventListener("cut", l.cut), document.removeEventListener("submit", l.submit);
940
+ return document.addEventListener("change", a.change), document.addEventListener("copy", a.copy), document.addEventListener("cut", a.cut), document.addEventListener("submit", a.submit), () => {
941
+ document.removeEventListener("change", a.change), document.removeEventListener("copy", a.copy), document.removeEventListener("cut", a.cut), document.removeEventListener("submit", a.submit);
1404
942
  };
1405
- }, []), (!(r != null && r.insightsUrl) || !r.workspace || !r.workspace.startsWith("W")) && console.error(
943
+ }, []), (!o?.insightsUrl || !n.workspace || !n.workspace.startsWith("W")) && console.error(
1406
944
  "[@levo-so/react] The utility could not be initialized, due to missing workspace, or endpoint for insights."
1407
945
  ), null;
1408
- }, rt = A.createContext({
946
+ };
947
+ var He = {
948
+ color: void 0,
949
+ size: void 0,
950
+ className: void 0,
951
+ style: void 0,
952
+ attr: void 0
953
+ }, Re = I.createContext && /* @__PURE__ */ I.createContext(He), vr = ["attr", "size", "title"];
954
+ function yr(e, t) {
955
+ if (e == null) return {};
956
+ var r = wr(e, t), n, o;
957
+ if (Object.getOwnPropertySymbols) {
958
+ var i = Object.getOwnPropertySymbols(e);
959
+ for (o = 0; o < i.length; o++)
960
+ n = i[o], !(t.indexOf(n) >= 0) && Object.prototype.propertyIsEnumerable.call(e, n) && (r[n] = e[n]);
961
+ }
962
+ return r;
963
+ }
964
+ function wr(e, t) {
965
+ if (e == null) return {};
966
+ var r = {};
967
+ for (var n in e)
968
+ if (Object.prototype.hasOwnProperty.call(e, n)) {
969
+ if (t.indexOf(n) >= 0) continue;
970
+ r[n] = e[n];
971
+ }
972
+ return r;
973
+ }
974
+ function ne() {
975
+ return ne = Object.assign ? Object.assign.bind() : function(e) {
976
+ for (var t = 1; t < arguments.length; t++) {
977
+ var r = arguments[t];
978
+ for (var n in r)
979
+ Object.prototype.hasOwnProperty.call(r, n) && (e[n] = r[n]);
980
+ }
981
+ return e;
982
+ }, ne.apply(this, arguments);
983
+ }
984
+ function Le(e, t) {
985
+ var r = Object.keys(e);
986
+ if (Object.getOwnPropertySymbols) {
987
+ var n = Object.getOwnPropertySymbols(e);
988
+ t && (n = n.filter(function(o) {
989
+ return Object.getOwnPropertyDescriptor(e, o).enumerable;
990
+ })), r.push.apply(r, n);
991
+ }
992
+ return r;
993
+ }
994
+ function oe(e) {
995
+ for (var t = 1; t < arguments.length; t++) {
996
+ var r = arguments[t] != null ? arguments[t] : {};
997
+ t % 2 ? Le(Object(r), !0).forEach(function(n) {
998
+ xr(e, n, r[n]);
999
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(r)) : Le(Object(r)).forEach(function(n) {
1000
+ Object.defineProperty(e, n, Object.getOwnPropertyDescriptor(r, n));
1001
+ });
1002
+ }
1003
+ return e;
1004
+ }
1005
+ function xr(e, t, r) {
1006
+ return t = Tr(t), t in e ? Object.defineProperty(e, t, { value: r, enumerable: !0, configurable: !0, writable: !0 }) : e[t] = r, e;
1007
+ }
1008
+ function Tr(e) {
1009
+ var t = Er(e, "string");
1010
+ return typeof t == "symbol" ? t : t + "";
1011
+ }
1012
+ function Er(e, t) {
1013
+ if (typeof e != "object" || !e) return e;
1014
+ var r = e[Symbol.toPrimitive];
1015
+ if (r !== void 0) {
1016
+ var n = r.call(e, t);
1017
+ if (typeof n != "object") return n;
1018
+ throw new TypeError("@@toPrimitive must return a primitive value.");
1019
+ }
1020
+ return (t === "string" ? String : Number)(e);
1021
+ }
1022
+ function ze(e) {
1023
+ return e && e.map((t, r) => /* @__PURE__ */ I.createElement(t.tag, oe({
1024
+ key: r
1025
+ }, t.attr), ze(t.child)));
1026
+ }
1027
+ function kr(e) {
1028
+ return (t) => /* @__PURE__ */ I.createElement(_r, ne({
1029
+ attr: oe({}, e.attr)
1030
+ }, t), ze(e.child));
1031
+ }
1032
+ function _r(e) {
1033
+ var t = (r) => {
1034
+ var {
1035
+ attr: n,
1036
+ size: o,
1037
+ title: i
1038
+ } = e, l = yr(e, vr), c = o || r.size || "1em", a;
1039
+ return r.className && (a = r.className), e.className && (a = (a ? a + " " : "") + e.className), /* @__PURE__ */ I.createElement("svg", ne({
1040
+ stroke: "currentColor",
1041
+ fill: "currentColor",
1042
+ strokeWidth: "0"
1043
+ }, r.attr, n, l, {
1044
+ className: a,
1045
+ style: oe(oe({
1046
+ color: e.color || r.color
1047
+ }, r.style), e.style),
1048
+ height: c,
1049
+ width: c,
1050
+ xmlns: "http://www.w3.org/2000/svg"
1051
+ }), i && /* @__PURE__ */ I.createElement("title", null, i), e.children);
1052
+ };
1053
+ return Re !== void 0 ? /* @__PURE__ */ I.createElement(Re.Consumer, null, (r) => t(r)) : t(He);
1054
+ }
1055
+ function Ve(e) {
1056
+ return kr({ attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "M12 22c5.421 0 10-4.579 10-10h-2c0 4.337-3.663 8-8 8s-8-3.663-8-8c0-4.336 3.663-8 8-8V2C6.579 2 2 6.58 2 12c0 5.421 4.579 10 10 10z" }, child: [] }] })(e);
1057
+ }
1058
+ const R = (...e) => Pe(st(e)), Sr = ct(
1059
+ "inline-flex items-center justify-center font-medium text-sm ring-offset-background transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
1060
+ {
1061
+ variants: {
1062
+ variant: {
1063
+ default: "bg-primary text-primary-foreground hover:bg-primary/90",
1064
+ destructive: "bg-destructive text-white hover:bg-destructive/90",
1065
+ destructiveOutline: "border border-red-500 bg-transparent text-destructive shadow-sm hover:bg-destructive hover:text-white",
1066
+ outline: "border border-input bg-background hover:bg-accent hover:text-accent-foreground",
1067
+ secondary: "bg-secondary text-secondary-foreground hover:bg-secondary/80",
1068
+ secondaryOutline: "border border-white border-solid bg-transparent hover:border-input hover:bg-white",
1069
+ ghost: "hover:bg-accent hover:text-accent-foreground",
1070
+ link: "text-primary underline-offset-4 hover:underline"
1071
+ },
1072
+ size: {
1073
+ default: "h-10 px-4 py-2",
1074
+ xs: "h-8 px-3 text-xs",
1075
+ sm: "h-9 px-3",
1076
+ lg: "h-11 px-8",
1077
+ icon: "h-10 w-10",
1078
+ "icon-small": "h-8 w-8"
1079
+ },
1080
+ rounded: {
1081
+ small: "rounded",
1082
+ default: "rounded-md",
1083
+ large: "rounded-lg",
1084
+ full: "rounded-full"
1085
+ }
1086
+ },
1087
+ defaultVariants: {
1088
+ variant: "default",
1089
+ size: "default",
1090
+ rounded: "default"
1091
+ }
1092
+ }
1093
+ ), Or = D.forwardRef(
1094
+ ({
1095
+ className: e,
1096
+ variant: t,
1097
+ size: r,
1098
+ rounded: n,
1099
+ asChild: o = !1,
1100
+ isLoading: i = !1,
1101
+ loadingText: l,
1102
+ disabled: c,
1103
+ ...a
1104
+ }, d) => {
1105
+ const p = o ? at.Root : "button";
1106
+ return /* @__PURE__ */ g.jsx(
1107
+ p,
1108
+ {
1109
+ className: R(Sr({ variant: t, size: r, rounded: n, className: e })),
1110
+ ref: d,
1111
+ disabled: c || i,
1112
+ type: "button",
1113
+ ...a,
1114
+ children: i ? /* @__PURE__ */ g.jsxs(g.Fragment, { children: [
1115
+ /* @__PURE__ */ g.jsx(Ve, { className: Pe("h-4 w-4 animate-spin", l ? "mr-2" : "") }),
1116
+ l
1117
+ ] }) : a.children
1118
+ }
1119
+ );
1120
+ }
1121
+ );
1122
+ Or.displayName = "Button";
1123
+ const Nr = j.Root, vn = j.Trigger, jr = j.Portal, yn = j.Close, Ge = D.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ g.jsx(
1124
+ j.Overlay,
1125
+ {
1126
+ ref: r,
1127
+ className: R(
1128
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 grid max-h-screen place-items-center overflow-y-auto bg-background/80 py-10 backdrop-blur-sm data-[state=closed]:animate-out data-[state=open]:animate-in",
1129
+ e
1130
+ ),
1131
+ ...t
1132
+ }
1133
+ ));
1134
+ Ge.displayName = j.Overlay.displayName;
1135
+ const Xe = D.forwardRef(({ className: e, children: t, container: r, hideCloseButton: n, overlayStyles: o, ...i }, l) => /* @__PURE__ */ g.jsx(jr, { container: r, children: /* @__PURE__ */ g.jsx(Ge, { className: o, children: /* @__PURE__ */ g.jsxs(
1136
+ j.Content,
1137
+ {
1138
+ ref: l,
1139
+ className: R(
1140
+ "data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 relative z-50 grid w-full max-w-lg gap-4 border bg-background p-6 shadow-lg duration-200 data-[state=closed]:animate-out data-[state=open]:animate-in sm:rounded-lg",
1141
+ e
1142
+ ),
1143
+ ...i,
1144
+ children: [
1145
+ t,
1146
+ !n && /* @__PURE__ */ g.jsxs(
1147
+ j.Close,
1148
+ {
1149
+ type: "button",
1150
+ className: "absolute top-4 right-4 rounded-sm p-1 opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground",
1151
+ children: [
1152
+ /* @__PURE__ */ g.jsx(lt, { className: "h-4 w-4" }),
1153
+ /* @__PURE__ */ g.jsx("span", { className: "sr-only", children: "Close" })
1154
+ ]
1155
+ }
1156
+ )
1157
+ ]
1158
+ }
1159
+ ) }) }));
1160
+ Xe.displayName = j.Content.displayName;
1161
+ const Je = ({ className: e, ...t }) => /* @__PURE__ */ g.jsx("div", { className: R("flex flex-col space-y-1.5 text-center sm:text-left", e), ...t });
1162
+ Je.displayName = "DialogHeader";
1163
+ const Cr = ({ className: e, ...t }) => /* @__PURE__ */ g.jsx(
1164
+ "div",
1165
+ {
1166
+ className: R("flex flex-col-reverse sm:flex-row sm:justify-end sm:space-x-2", e),
1167
+ ...t
1168
+ }
1169
+ );
1170
+ Cr.displayName = "DialogFooter";
1171
+ const qe = D.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ g.jsx(
1172
+ j.Title,
1173
+ {
1174
+ ref: r,
1175
+ className: R("font-semibold text-lg leading-none tracking-tight", e),
1176
+ ...t
1177
+ }
1178
+ ));
1179
+ qe.displayName = j.Title.displayName;
1180
+ const Ke = D.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ g.jsx(
1181
+ j.Description,
1182
+ {
1183
+ ref: r,
1184
+ className: R("text-muted-foreground text-sm", e),
1185
+ ...t
1186
+ }
1187
+ ));
1188
+ Ke.displayName = j.Description.displayName;
1189
+ const wn = ({
1190
+ isOpen: e,
1191
+ onClose: t,
1192
+ children: r,
1193
+ title: n,
1194
+ description: o = "",
1195
+ contentClassName: i,
1196
+ modal: l = !0
1197
+ }) => /* @__PURE__ */ g.jsx(Nr, { open: e, onOpenChange: t, modal: l, children: /* @__PURE__ */ g.jsxs(Xe, { className: i, children: [
1198
+ n && /* @__PURE__ */ g.jsxs(Je, { className: "flex-1 font-medium", children: [
1199
+ /* @__PURE__ */ g.jsx(qe, { children: n }),
1200
+ /* @__PURE__ */ g.jsx(Ke, { children: o })
1201
+ ] }),
1202
+ /* @__PURE__ */ g.jsx("div", { className: "w-full", children: r })
1203
+ ] }) }), xn = ({ ...e }) => /* @__PURE__ */ g.jsx(
1204
+ ut,
1205
+ {
1206
+ closeButton: !0,
1207
+ richColors: !0,
1208
+ className: "toaster group",
1209
+ toastOptions: {
1210
+ classNames: {
1211
+ toast: "group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",
1212
+ description: "group-[.toast]:text-muted-foreground",
1213
+ actionButton: "group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",
1214
+ cancelButton: "group-[.toast]:bg-muted group-[.toast]:text-muted-foreground"
1215
+ }
1216
+ },
1217
+ ...e
1218
+ }
1219
+ ), Rr = (e, t = "Error", r = {}) => {
1220
+ de.error(t, {
1221
+ description: e,
1222
+ duration: 4e3,
1223
+ position: "bottom-right",
1224
+ ...r
1225
+ });
1226
+ }, Tn = (e, t = "Success", r = {}) => {
1227
+ r?.id && de.dismiss(r?.id), de.success(t, {
1228
+ description: e,
1229
+ duration: 4e3,
1230
+ position: "bottom-right",
1231
+ ...r
1232
+ });
1233
+ }, Lr = ({ className: e }) => /* @__PURE__ */ g.jsx(Ve, { className: R("h-8 w-8 animate-spin font-light", e) }), En = W.Root, Pr = D.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ g.jsx(
1234
+ W.List,
1235
+ {
1236
+ ref: r,
1237
+ className: R(
1238
+ "inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
1239
+ e
1240
+ ),
1241
+ ...t
1242
+ }
1243
+ ));
1244
+ Pr.displayName = W.List.displayName;
1245
+ const Ar = D.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ g.jsx(
1246
+ W.Trigger,
1247
+ {
1248
+ ref: r,
1249
+ className: R(
1250
+ "inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 font-medium text-sm ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
1251
+ e
1252
+ ),
1253
+ "data-levo-studio-interactive": "true",
1254
+ ...t
1255
+ }
1256
+ ));
1257
+ Ar.displayName = W.Trigger.displayName;
1258
+ const Ir = D.forwardRef(({ className: e, ...t }, r) => /* @__PURE__ */ g.jsx(
1259
+ W.Content,
1260
+ {
1261
+ ref: r,
1262
+ className: R(
1263
+ "mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
1264
+ e
1265
+ ),
1266
+ ...t
1267
+ }
1268
+ ));
1269
+ Ir.displayName = W.Content.displayName;
1270
+ const kn = z.Provider, Dr = z.Root, $r = z.Trigger, Mr = z.Portal, Ze = D.forwardRef(({ className: e, sideOffset: t = 4, ...r }, n) => /* @__PURE__ */ g.jsx(
1271
+ z.Content,
1272
+ {
1273
+ ref: n,
1274
+ sideOffset: t,
1275
+ className: R(
1276
+ "fade-in-0 zoom-in-95 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 z-50 animate-in overflow-hidden rounded-md border bg-popover px-3 py-1.5 text-popover-foreground text-xs shadow-md data-[state=closed]:animate-out",
1277
+ e
1278
+ ),
1279
+ ...r
1280
+ }
1281
+ ));
1282
+ Ze.displayName = z.Content.displayName;
1283
+ const _n = ({ children: e, label: t, labelClassName: r, asChild: n = !0, contentProps: o = {}, side: i }) => /* @__PURE__ */ g.jsxs(Dr, { children: [
1284
+ t && /* @__PURE__ */ g.jsx(Mr, { children: /* @__PURE__ */ g.jsx(Ze, { side: i, className: r, ...o, children: t }) }),
1285
+ /* @__PURE__ */ g.jsx($r, { asChild: n, children: e })
1286
+ ] }), Wr = [
1287
+ "pdf",
1288
+ "txt",
1289
+ "xml",
1290
+ "xls",
1291
+ "xlsx",
1292
+ "ods",
1293
+ "odt",
1294
+ "doc",
1295
+ "docx",
1296
+ "csv",
1297
+ "odp",
1298
+ "ppt",
1299
+ "pptx"
1300
+ ], Fr = ["svg", "png", "jpg", "jpeg", "gif", "webp", "avif"], Br = ["mp4", "ogv", "webm"], Ur = ["mp3", "ogg", "opus"], Yr = {
1301
+ "application/xml": [".xml"],
1302
+ "text/plain": [".txt"],
1303
+ "application/pdf": [".pdf"],
1304
+ "application/msword": [".doc"],
1305
+ "application/vnd.ms-excel": [".xls"],
1306
+ "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet": [".xlsx"],
1307
+ "application/vnd.openxmlformats-officedocument.wordprocessingml.document": [".docx"],
1308
+ "text/csv": [".csv"]
1309
+ }, Hr = {
1310
+ "image/jpeg": [".jpeg", ".jpg"],
1311
+ "image/jpg": [".jpg"],
1312
+ "image/png": [".png"],
1313
+ "image/gif": [".gif"],
1314
+ "image/svg": [".svg"],
1315
+ "image/svg+xml": [".svg"],
1316
+ "image/webp": [".webp"],
1317
+ "image/avif": [".avif"]
1318
+ }, zr = {
1319
+ "video/mp4": [".mp4"],
1320
+ "video/mpeg": [".mpeg"],
1321
+ "video/webm": [".webm"]
1322
+ }, Vr = {
1323
+ "audio/mpeg": [".mp3"],
1324
+ "audio/ogg": [".oga"],
1325
+ "audio/opus": [".opus"]
1326
+ }, Z = {
1327
+ audio: Vr,
1328
+ document: Yr,
1329
+ image: Hr,
1330
+ video: zr
1331
+ }, Q = {
1332
+ audio: Ur,
1333
+ document: Wr,
1334
+ image: Fr,
1335
+ video: Br
1336
+ }, Sn = [
1337
+ ...Q.audio,
1338
+ ...Q.document,
1339
+ ...Q.image,
1340
+ ...Q.video
1341
+ ], On = {
1342
+ ...Z.audio,
1343
+ ...Z.document,
1344
+ ...Z.image,
1345
+ ...Z.video
1346
+ }, Qe = I.createContext({
1409
1347
  urls: null,
1410
1348
  title: "",
1411
1349
  isLoading: !1,
@@ -1413,263 +1351,257 @@ const de = new Xn(), qn = () => {
1413
1351
  },
1414
1352
  onError: () => {
1415
1353
  }
1416
- }), rr = ({
1417
- title: e,
1418
- onSuccess: t,
1419
- onError: n,
1420
- children: r
1421
- }) => {
1422
- const o = L(), s = typeof window < "u" ? window.location.href : "", [c, a] = x(null), [u, l] = x(!1);
1423
- b(() => {
1424
- var d;
1425
- o.membership && (l(!0), (d = o.membership) == null || d.getOAuthURL().then((m) => {
1426
- a(m);
1427
- }).catch((m) => {
1428
- n({
1429
- code: (m == null ? void 0 : m.code) || "SOMETHING_WENT_WRONG",
1430
- message: (m == null ? void 0 : m.message) || "We could not connect with our service for your sign-in."
1354
+ }), Gr = ({ title: e, onSuccess: t, onError: r, children: n }) => {
1355
+ const o = V(), i = typeof window < "u" ? window.location.href : "", [l, c] = N(null), [a, d] = N(!1);
1356
+ k(() => {
1357
+ o.membership && (d(!0), o.membership?.getOAuthURL().then((u) => {
1358
+ c(u);
1359
+ }).catch((u) => {
1360
+ r({
1361
+ code: u?.code || "SOMETHING_WENT_WRONG",
1362
+ message: u?.message || "We could not connect with our service for your sign-in."
1431
1363
  });
1432
1364
  }).finally(() => {
1433
- l(!1);
1365
+ d(!1);
1434
1366
  }));
1435
1367
  }, []);
1436
- const f = Ie(
1437
- () => ({ title: e, urls: c, isLoading: u, onSuccess: t, onError: n }),
1438
- [e, c, t, n, u]
1368
+ const p = me(
1369
+ () => ({ title: e, urls: l, isLoading: a, onSuccess: t, onError: r }),
1370
+ [e, l, t, r, a]
1439
1371
  );
1440
- return b(() => {
1441
- if (c && s) {
1442
- const d = {}, m = Object.keys(c);
1443
- for (const v of m)
1372
+ return k(() => {
1373
+ if (l && i) {
1374
+ const u = {}, m = Object.keys(l);
1375
+ for (const b of m)
1444
1376
  try {
1445
- const _ = c[v];
1446
- if (_) {
1447
- const S = new URL(_), N = S.searchParams;
1448
- N.set("redirect_uri", s);
1377
+ const h = l[b];
1378
+ if (h) {
1379
+ const O = new URL(h), x = O.searchParams;
1380
+ x.set("redirect_uri", i);
1449
1381
  const C = o.pageContext;
1450
- C && N.set("page_context", JSON.stringify(C)), d[v] = S.toString();
1382
+ C && x.set("page_context", JSON.stringify(C)), u[b] = O.toString();
1451
1383
  }
1452
1384
  } catch {
1453
1385
  }
1454
- a(d);
1386
+ c(u);
1455
1387
  }
1456
- }, [s]), /* @__PURE__ */ p.jsx(rt.Provider, { value: f, children: r });
1457
- }, or = () => Pe(rt), sr = ({ url: e, title: t, height: n, width: r }) => {
1458
- const o = window.screenX + (window.outerWidth - r) / 2, s = window.screenY + (window.outerHeight - n) / 2.5;
1388
+ }, [i]), /* @__PURE__ */ g.jsx(Qe.Provider, { value: p, children: n });
1389
+ }, Xr = () => ge(Qe), Jr = ({ url: e, title: t, height: r, width: n }) => {
1390
+ const o = window.screenX + (window.outerWidth - n) / 2, i = window.screenY + (window.outerHeight - r) / 2.5;
1459
1391
  return window.open(
1460
1392
  e,
1461
1393
  t,
1462
- `width=${r},height=${n},left=${o},top=${s}`
1394
+ `width=${n},height=${r},left=${o},top=${i}`
1463
1395
  );
1464
- }, ir = ({
1396
+ }, qr = ({
1465
1397
  title: e = "",
1466
1398
  width: t = 500,
1467
- height: n = 500,
1468
- url: r,
1399
+ height: r = 500,
1400
+ url: n,
1469
1401
  children: o,
1470
- onCode: s,
1471
- onClose: c
1402
+ onCode: i,
1403
+ onClose: l
1472
1404
  }) => {
1473
- const [a, u] = x(), l = Ae(void 0), f = () => {
1474
- window.clearInterval(l.current);
1475
- }, d = () => {
1476
- u(
1477
- sr({
1478
- url: r,
1405
+ const [c, a] = N(), d = H(void 0), p = () => {
1406
+ window.clearInterval(d.current);
1407
+ }, u = () => {
1408
+ a(
1409
+ Jr({
1410
+ url: n,
1479
1411
  title: e,
1480
1412
  width: t,
1481
- height: n
1413
+ height: r
1482
1414
  })
1483
1415
  );
1484
1416
  };
1485
- return b(() => (a && (l.current = window.setInterval(() => {
1417
+ return k(() => (c && (d.current = window.setInterval(() => {
1486
1418
  try {
1487
- const m = a.location.href, v = new URL(m).searchParams, _ = v.get("code");
1488
- if (!_)
1419
+ const m = c.location.href, b = new URL(m).searchParams, h = b.get("code");
1420
+ if (!h)
1489
1421
  return;
1490
- s(_, v), f(), a.close();
1422
+ i(h, b), p(), c.close();
1491
1423
  } catch {
1492
1424
  } finally {
1493
- (!a || a.closed) && (c(), f());
1425
+ (!c || c.closed) && (l(), p());
1494
1426
  }
1495
1427
  }, 700)), () => {
1496
- a && a.close(), c && c();
1497
- }), [a]), /* @__PURE__ */ p.jsx(
1428
+ c && c.close(), l && l();
1429
+ }), [c]), /* @__PURE__ */ g.jsx(
1498
1430
  "div",
1499
1431
  {
1500
1432
  onClick: () => {
1501
- d();
1433
+ u();
1502
1434
  },
1503
1435
  children: o
1504
1436
  }
1505
1437
  );
1506
- }, ar = ({
1438
+ }, Kr = ({
1507
1439
  title: e = "Levo",
1508
1440
  url: t,
1509
- children: n,
1510
- onSuccess: r,
1441
+ children: r,
1442
+ onSuccess: n,
1511
1443
  onError: o,
1512
- width: s = 500,
1513
- height: c = 700
1444
+ width: i = 500,
1445
+ height: l = 700
1514
1446
  }) => {
1515
- const a = fe((u, l) => {
1516
- u.toLowerCase() === "success" ? r(l) : o(l);
1447
+ const c = ee((a, d) => {
1448
+ a.toLowerCase() === "success" ? n(d) : o(d);
1517
1449
  }, []);
1518
- return /* @__PURE__ */ p.jsx(
1519
- ir,
1450
+ return /* @__PURE__ */ g.jsx(
1451
+ qr,
1520
1452
  {
1521
1453
  title: e,
1522
- width: s,
1523
- height: c,
1454
+ width: i,
1455
+ height: l,
1524
1456
  onClose: () => {
1525
1457
  },
1526
1458
  url: t,
1527
- onCode: a,
1528
- children: n
1459
+ onCode: c,
1460
+ children: r
1529
1461
  }
1530
1462
  );
1531
- }, cr = ({ children: e, provider: t }) => {
1532
- const { title: n, urls: r, isLoading: o, onSuccess: s, onError: c } = or(), a = r == null ? void 0 : r[t];
1533
- return a ? /* @__PURE__ */ p.jsx(
1534
- ar,
1535
- {
1536
- title: n,
1537
- provider: t,
1538
- url: a,
1539
- onSuccess: s,
1540
- onError: c,
1541
- children: o ? /* @__PURE__ */ p.jsx("div", { className: "w-full items-center justify-center", children: /* @__PURE__ */ p.jsx(Ut, { className: "bg-brand h-5 w-5" }) }) : e
1542
- }
1543
- ) : null;
1544
- }, ur = ({ url: e, title: t, height: n, width: r }) => {
1545
- const o = window.screenX + (window.outerWidth - r) / 2, s = window.screenY + (window.outerHeight - n) / 2.5;
1463
+ }, Zr = ({ children: e, provider: t }) => {
1464
+ const { title: r, urls: n, isLoading: o, onSuccess: i, onError: l } = Xr(), c = n?.[t];
1465
+ return c ? /* @__PURE__ */ g.jsx(Kr, { title: r, provider: t, url: c, onSuccess: i, onError: l, children: o ? /* @__PURE__ */ g.jsx("div", { className: "w-full items-center justify-center", children: /* @__PURE__ */ g.jsx(Lr, { className: "h-5 w-5 bg-brand" }) }) : e }) : null;
1466
+ }, Qr = ({ url: e, title: t, height: r, width: n }) => {
1467
+ const o = window.screenX + (window.outerWidth - n) / 2, i = window.screenY + (window.outerHeight - r) / 2.5;
1546
1468
  return window.open(
1547
1469
  e,
1548
1470
  t,
1549
- `width=${r},height=${n},left=${o},top=${s}`
1471
+ `width=${n},height=${r},left=${o},top=${i}`
1550
1472
  );
1551
- }, Mr = ({
1473
+ }, Nn = ({
1552
1474
  title: e = "Levo",
1553
1475
  width: t = 500,
1554
- height: n = 700,
1555
- onSuccess: r
1476
+ height: r = 700,
1477
+ onSuccess: n
1556
1478
  }) => {
1557
- const o = L(), [s, c] = x(!1), [a, u] = x(null), [l, f] = x(null), [d, m] = x(), v = Ae(void 0), _ = () => {
1558
- window.clearInterval(v.current);
1559
- }, S = fe((T, y) => {
1560
- T.toLowerCase() === "success" ? (f(null), r(y)) : f(y);
1479
+ const o = V(), [i, l] = N(!1), [c, a] = N(null), [d, p] = N(null), [u, m] = N(), b = H(void 0), h = () => {
1480
+ window.clearInterval(b.current);
1481
+ }, O = ee((w, _) => {
1482
+ w.toLowerCase() === "success" ? (p(null), n(_)) : p(_);
1561
1483
  }, []);
1562
- b(() => {
1563
- var T;
1564
- o.membership && (c(!0), (T = o.membership) == null || T.getOAuthURL().then((y) => {
1565
- if (y)
1566
- return u(y), y;
1484
+ k(() => {
1485
+ o.membership && (l(!0), o.membership?.getOAuthURL().then((w) => {
1486
+ if (w)
1487
+ return a(w), w;
1567
1488
  throw new Error();
1568
- }).catch((y) => {
1569
- var M;
1570
- const O = Me(y);
1571
- (M = o.logger) == null || M.error("Failed to get OAuth URL", O.message), f({
1572
- code: (O == null ? void 0 : O.code) || "SOMETHING_WENT_WRONG",
1573
- message: (O == null ? void 0 : O.message) || "We could not connect with our service for your sign-in."
1489
+ }).catch((w) => {
1490
+ const _ = U(w);
1491
+ o.logger?.error("Failed to get OAuth URL", _.message), p({
1492
+ code: _?.code || "SOMETHING_WENT_WRONG",
1493
+ message: _?.message || "We could not connect with our service for your sign-in."
1574
1494
  });
1575
1495
  }).finally(() => {
1576
- c(!1);
1496
+ l(!1);
1577
1497
  }));
1578
- }, []), b(() => (d && (v.current = window.setInterval(() => {
1498
+ }, []), k(() => (u && (b.current = window.setInterval(() => {
1579
1499
  try {
1580
- const T = d.location.href, y = new URL(T).searchParams, O = y.get("code");
1581
- if (!O)
1500
+ const w = u.location.href, _ = new URL(w).searchParams, P = _.get("code");
1501
+ if (!P)
1582
1502
  return;
1583
- S(O, y), _(), d.close();
1503
+ O(P, _), h(), u.close();
1584
1504
  } catch {
1585
1505
  } finally {
1586
- (!d || d.closed) && (_(), f(null));
1506
+ (!u || u.closed) && (h(), p(null));
1587
1507
  }
1588
1508
  }, 700)), () => {
1589
- d && d.close();
1590
- }), [d]);
1591
- const N = fe(
1592
- (T) => {
1593
- if (T && a !== null) {
1594
- const y = a == null ? void 0 : a[T];
1595
- y && (d && d.close(), m(
1596
- ur({
1597
- url: y,
1509
+ u && u.close();
1510
+ }), [u]);
1511
+ const x = ee(
1512
+ (w) => {
1513
+ if (w && c !== null) {
1514
+ const _ = c?.[w];
1515
+ _ && (u && u.close(), m(
1516
+ Qr({
1517
+ url: _,
1598
1518
  title: e,
1599
1519
  width: t,
1600
- height: n
1520
+ height: r
1601
1521
  })
1602
1522
  ));
1603
1523
  }
1604
1524
  },
1605
- [a, d]
1525
+ [c, u]
1606
1526
  );
1607
1527
  return {
1608
- providers: Ie(() => a !== null ? Object.keys(a).filter(
1609
- (T) => !!a[T]
1610
- ) : [], [a]),
1611
- isLoading: s,
1612
- error: l,
1613
- launchPopup: N
1528
+ providers: me(() => c !== null ? Object.keys(c).filter(
1529
+ (w) => !!c[w]
1530
+ ) : [], [c]),
1531
+ isLoading: i,
1532
+ error: d,
1533
+ launchPopup: x
1614
1534
  };
1615
1535
  };
1616
- class Le {
1536
+ class jn {
1537
+ static Container = Gr;
1538
+ static Button = Zr;
1617
1539
  }
1618
- J(Le, "Container", rr), J(Le, "Button", cr);
1540
+ const Cn = (e, t = 2) => {
1541
+ if (e === 0) return "0 B";
1542
+ const r = 1024, n = t < 0 ? 0 : t, o = ["Bytes", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], i = Math.floor(Math.log(e) / Math.log(r));
1543
+ return `${Number.parseFloat((e / r ** i).toFixed(n))} ${o[i]}`;
1544
+ }, Rn = (e) => {
1545
+ const t = U(e);
1546
+ return t?.code === "REQUEST_TIMEOUT" || t?.code === "NETWORK_ERROR" || t?.status === 408 || t?.status === 0 || Rr(t?.message || "", t?.title || "Error", {
1547
+ id: `${t?.title || ""}-${t?.message || ""}`
1548
+ }), t;
1549
+ }, en = (e) => e instanceof Date, tn = (e) => e == null, rn = (e) => typeof e == "object", nn = (e) => !tn(e) && !Array.isArray(e) && rn(e) && !en(e), Ln = (e) => nn(e) && !Object.keys(e).length;
1619
1550
  export {
1620
- Mt as Button,
1621
- $t as Dialog,
1622
- Er as DialogClose,
1623
- Ue as DialogContent,
1624
- He as DialogDescription,
1625
- Bt as DialogFooter,
1626
- Ye as DialogHeader,
1627
- Fe as DialogOverlay,
1628
- Wt as DialogPortal,
1629
- ze as DialogTitle,
1630
- Tr as DialogTrigger,
1631
- kr as DialogWrapper,
1632
- Ir as LevoInsightsBlock,
1633
- Ar as LevoInsightsComponent,
1634
- Dr as LevoInsightsPage,
1635
- Le as LevoOAuth,
1636
- Pr as LevoProvider,
1637
- Nr as SimpleTooltipWrapper,
1638
- Ut as Spinner,
1639
- Or as Tabs,
1640
- Ht as TabsContent,
1641
- Yt as TabsList,
1642
- zt as TabsTrigger,
1643
- _r as Toaster,
1644
- Vt as Tooltip,
1645
- Ve as TooltipContent,
1646
- Jt as TooltipPortal,
1647
- jr as TooltipProvider,
1648
- Gt as TooltipTrigger,
1649
- yr as allMediaFileExtensions,
1650
- xr as allMediaMimetypes,
1651
- yt as audioFileExtensions,
1652
- kt as audioMimetype,
1653
- Dt as buttonVariants,
1654
- Cr as byteToSize,
1551
+ Or as Button,
1552
+ Nr as Dialog,
1553
+ yn as DialogClose,
1554
+ Xe as DialogContent,
1555
+ Ke as DialogDescription,
1556
+ Cr as DialogFooter,
1557
+ Je as DialogHeader,
1558
+ Ge as DialogOverlay,
1559
+ jr as DialogPortal,
1560
+ qe as DialogTitle,
1561
+ vn as DialogTrigger,
1562
+ wn as DialogWrapper,
1563
+ pn as LevoInsightsBlock,
1564
+ bn as LevoInsightsComponent,
1565
+ hn as LevoInsightsPage,
1566
+ jn as LevoOAuth,
1567
+ mn as LevoProvider,
1568
+ _n as SimpleTooltipWrapper,
1569
+ Lr as Spinner,
1570
+ En as Tabs,
1571
+ Ir as TabsContent,
1572
+ Pr as TabsList,
1573
+ Ar as TabsTrigger,
1574
+ xn as Toaster,
1575
+ Dr as Tooltip,
1576
+ Ze as TooltipContent,
1577
+ Mr as TooltipPortal,
1578
+ kn as TooltipProvider,
1579
+ $r as TooltipTrigger,
1580
+ Sn as allMediaFileExtensions,
1581
+ On as allMediaMimetypes,
1582
+ Ur as audioFileExtensions,
1583
+ Vr as audioMimetype,
1584
+ Sr as buttonVariants,
1585
+ Cn as byteToSize,
1655
1586
  R as cn,
1656
- vt as documentFileExtensions,
1657
- xt as documentMimetype,
1658
- Rr as errorHandler,
1659
- Ft as errorToast,
1660
- ht as imageFileExtensions,
1661
- Tt as imageMimetype,
1662
- Xt as isDateObject,
1663
- Lr as isEmptyObject,
1664
- qt as isNullOrUndefined,
1665
- Zt as isObject,
1666
- Kt as isObjectType,
1667
- q as mediaExtensionsByKind,
1668
- X as mediaMimetypeByKind,
1669
- Sr as successToast,
1670
- Br as toast,
1671
- L as useLevo,
1672
- Mr as useLevoOAuth,
1673
- wt as videoFileExtensions,
1674
- Et as videoMimetype
1587
+ Wr as documentFileExtensions,
1588
+ Yr as documentMimetype,
1589
+ Rn as errorHandler,
1590
+ Rr as errorToast,
1591
+ Fr as imageFileExtensions,
1592
+ Hr as imageMimetype,
1593
+ en as isDateObject,
1594
+ Ln as isEmptyObject,
1595
+ tn as isNullOrUndefined,
1596
+ nn as isObject,
1597
+ rn as isObjectType,
1598
+ Q as mediaExtensionsByKind,
1599
+ Z as mediaMimetypeByKind,
1600
+ Tn as successToast,
1601
+ In as toast,
1602
+ V as useLevo,
1603
+ $ as useLevoInsights,
1604
+ Nn as useLevoOAuth,
1605
+ Br as videoFileExtensions,
1606
+ zr as videoMimetype
1675
1607
  };