@chaibuilder/sdk 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/dist/{AddBlocks-e23baf9a.cjs → AddBlocks-0916e841.cjs} +1 -1
  2. package/dist/{AddBlocks-b5f37f2f.js → AddBlocks-c195f577.js} +19 -19
  3. package/dist/{BrandingOptions-3d1bd24a.cjs → BrandingOptions-742992b6.cjs} +1 -1
  4. package/dist/{BrandingOptions-cfd1b740.js → BrandingOptions-766c19c6.js} +27 -27
  5. package/dist/{CanvasArea-a065a586.js → CanvasArea-25800a3e.js} +19 -18
  6. package/dist/CanvasArea-e855c4a2.cjs +60 -0
  7. package/dist/Class-7d6aadbc.cjs +1 -0
  8. package/dist/{Class-e6b07b79.js → Class-e34b2337.js} +9 -9
  9. package/dist/{ImagesPanel-eccf9a56.js → ImagesPanel-8ccab6d9.js} +1 -1
  10. package/dist/{ImagesPanel-cc136c92.cjs → ImagesPanel-addb2bf9.cjs} +1 -1
  11. package/dist/{Layers-f002ba1a.cjs → Layers-a2169d0b.cjs} +1 -1
  12. package/dist/{Layers-f935e07b.js → Layers-f7e792f6.js} +3 -3
  13. package/dist/{MarkAsGlobalBlock-5f435dd5.cjs → MarkAsGlobalBlock-6187e6fd.cjs} +1 -1
  14. package/dist/{MarkAsGlobalBlock-613bfdab.js → MarkAsGlobalBlock-6bac1842.js} +2 -2
  15. package/dist/PagesPanel-0827c264.js +46 -0
  16. package/dist/PagesPanel-5698953d.cjs +1 -0
  17. package/dist/ProjectPanel-a3cb7396.cjs +1 -0
  18. package/dist/ProjectPanel-e577029a.js +66 -0
  19. package/dist/{Settings-a19fbb69.js → Settings-b214f859.js} +25 -24
  20. package/dist/Settings-bee21026.cjs +1 -0
  21. package/dist/{SidePanels-67ebbcb4.js → SidePanels-03fa10e8.js} +3 -3
  22. package/dist/{SidePanels-af222189.cjs → SidePanels-934159a4.cjs} +1 -1
  23. package/dist/{Topbar-fcb01371.js → Topbar-9bc8c9cf.js} +2 -2
  24. package/dist/{Topbar-e92351cc.cjs → Topbar-c083cc2a.cjs} +1 -1
  25. package/dist/UnsplashImages-68492dc9.cjs +1 -0
  26. package/dist/{UnsplashImages-fda2f29a.js → UnsplashImages-afaa7706.js} +19 -28
  27. package/dist/add-page-modal-63858244.js +92 -0
  28. package/dist/add-page-modal-cb367c9d.cjs +1 -0
  29. package/dist/alert-dialog-4ce6ed22.cjs +1 -0
  30. package/dist/alert-dialog-ee98f47e.js +64 -0
  31. package/dist/confirm-alert-4f50caa7.cjs +1 -0
  32. package/dist/confirm-alert-f2a47cc7.js +36 -0
  33. package/dist/core.cjs +1 -1
  34. package/dist/core.d.ts +20 -12
  35. package/dist/core.js +53 -52
  36. package/dist/delete-page-modal-1e3914e3.cjs +1 -0
  37. package/dist/delete-page-modal-def9012d.js +64 -0
  38. package/dist/dropdown-menu-84b2439e.cjs +1 -0
  39. package/dist/dropdown-menu-ae3ed09b.js +164 -0
  40. package/dist/form-5d5c5c9e.js +125 -0
  41. package/dist/form-6eac0287.cjs +1 -0
  42. package/dist/{html-to-json-7510f587.js → html-to-json-9304dbda.js} +1 -1
  43. package/dist/{html-to-json-7eba915f.cjs → html-to-json-9c9961da.cjs} +1 -1
  44. package/dist/index-207f2cbf.cjs +2 -0
  45. package/dist/index-390f7bef.js +4749 -0
  46. package/dist/index-824a7bd0.js +188 -0
  47. package/dist/index-ebd86d7f.cjs +2 -0
  48. package/dist/input-42acea7e.cjs +1 -0
  49. package/dist/input-a0ea2bc7.js +19 -0
  50. package/dist/lib.cjs +1 -1
  51. package/dist/lib.js +3 -3
  52. package/dist/link-86c532b5.cjs +1 -0
  53. package/dist/{link-e406254f.js → link-f80a947d.js} +44 -60
  54. package/dist/mockServiceWorker.js +292 -0
  55. package/dist/page-viewer-41cbb548.js +88 -0
  56. package/dist/page-viewer-83ce2c70.cjs +1 -0
  57. package/dist/project-general-setting-0262fe62.js +65 -0
  58. package/dist/project-general-setting-2c8bed74.cjs +1 -0
  59. package/dist/project-seo-setting-01536592.js +67 -0
  60. package/dist/project-seo-setting-e3924578.cjs +1 -0
  61. package/dist/single-page-detail-924d57fc.js +206 -0
  62. package/dist/single-page-detail-cfeae896.cjs +1 -0
  63. package/dist/ui.cjs +1 -1
  64. package/dist/ui.js +124 -122
  65. package/dist/usePageActions-3bed2330.cjs +1 -0
  66. package/dist/usePageActions-f86f6f65.js +36 -0
  67. package/dist/useProjectActions-1de05f63.js +17 -0
  68. package/dist/useProjectActions-5092ed79.cjs +1 -0
  69. package/package.json +14 -1
  70. package/dist/CanvasArea-c4554d61.cjs +0 -60
  71. package/dist/Class-0801d193.cjs +0 -1
  72. package/dist/Settings-05b9b5fe.cjs +0 -1
  73. package/dist/UnsplashImages-cca34e45.cjs +0 -1
  74. package/dist/dropdown-menu-a9b096f9.cjs +0 -1
  75. package/dist/dropdown-menu-d912a52e.js +0 -223
  76. package/dist/index-73cf645f.cjs +0 -2
  77. package/dist/index-7e212fbc.js +0 -2657
  78. package/dist/link-1ee70bca.cjs +0 -1
@@ -0,0 +1,4749 @@
1
+ var Yn = (e, t, n) => {
2
+ if (!t.has(e))
3
+ throw TypeError("Cannot " + n);
4
+ };
5
+ var c = (e, t, n) => (Yn(e, t, "read from private field"), n ? n.call(e) : t.get(e)), L = (e, t, n) => {
6
+ if (t.has(e))
7
+ throw TypeError("Cannot add the same private member more than once");
8
+ t instanceof WeakSet ? t.add(e) : t.set(e, n);
9
+ }, P = (e, t, n, s) => (Yn(e, t, "write to private field"), s ? s.call(e, n) : t.set(e, n), n);
10
+ var wn = (e, t, n, s) => ({
11
+ set _(r) {
12
+ P(e, t, r, n);
13
+ },
14
+ get _() {
15
+ return c(e, t, s);
16
+ }
17
+ }), K = (e, t, n) => (Yn(e, t, "access private method"), n);
18
+ import { j as _ } from "./jsx-runtime-944c88e2.js";
19
+ import ho from "i18next";
20
+ import { initReactI18next as po } from "react-i18next";
21
+ import { FlagsProvider as mo } from "flagged";
22
+ import * as pe from "react";
23
+ import Es, { createContext as go, useReducer as yo, useEffect as ke, useDebugValue as vo, useCallback as X, useContext as bo, useMemo as wo, useState as So, Suspense as Gt, lazy as $t } from "react";
24
+ import { DndProvider as xo } from "react-dnd";
25
+ import { flatten as be, find as Ae, filter as te, map as ue, omit as Tn, isEmpty as Me, isString as Ps, set as ut, get as ee, has as Os, includes as de, without as Yr, forIn as Zr, findIndex as Sn, last as ko, startsWith as ei, first as je, isNull as os, each as We, pick as Gs, sortBy as Ws, isObject as Ao } from "lodash";
26
+ import { getBackendOptions as Eo, MultiBackend as Po } from "@minoru/react-dnd-treeview";
27
+ import { u as en, c as ti, B as Oo, S as _o, T as Co, a as Io } from "./useBuilderProp-81a14920.js";
28
+ import { atom as N, useAtomValue as ne, useAtom as Y, useSetAtom as Xe, getDefaultStore as Bo } from "jotai";
29
+ import { c as jo } from "./utils-ac68b2c8.js";
30
+ import { useHotkeys as Le } from "react-hotkeys-hook";
31
+ import ni from "flat-to-nested";
32
+ import { g as He, c as Cn, B as as, a as Ro } from "./Class-e34b2337.js";
33
+ import Do, { excludeAction as Mo, ActionCreators as Zn } from "redux-undo";
34
+ import { useThrottledCallback as Lo } from "@react-hookz/web";
35
+ import { useChaiBlocks as No, syncBlocksWithDefaults as To } from "@chaibuilder/blocks";
36
+ import { FileTextIcon as Fo, GearIcon as Uo } from "@radix-ui/react-icons";
37
+ import { S as lt, I as si, a as cs } from "./CONTROLS-442caee5.js";
38
+ const qo = "Dark mode", $o = "This page has no blocks. Add a block by clicking the + button", Qo = "This page is empty", Vo = "Please select a block to edit settings or styles", Ko = "Please select a styling block", zo = "Drop your block here", Go = {
39
+ dark_mode: qo,
40
+ tree_view_no_blocks: $o,
41
+ canvas_empty: Qo,
42
+ no_block_selected_for_styling: Vo,
43
+ no_styling_block_selected: Ko,
44
+ drop_here_message: zo
45
+ };
46
+ ho.use(po).init({
47
+ // the translations
48
+ // (tip move them in a JSON file and import them,
49
+ // or even better, manage them via a UI: https://react.i18next.com/guides/multiple-translation-files#manage-your-translations-with-a-management-gui)
50
+ resources: {
51
+ en: {
52
+ translation: Go
53
+ }
54
+ },
55
+ lng: "en",
56
+ // if you're using a language detector, do not define the lng option
57
+ fallbackLng: "en",
58
+ interpolation: {
59
+ escapeValue: !1
60
+ // react already safes from xss => https://www.i18next.com/translation-function/interpolation#unescape
61
+ }
62
+ });
63
+ const Wo = "";
64
+ const Ho = {};
65
+ class Jo extends Es.Component {
66
+ constructor(t) {
67
+ super(t), this.state = { hasError: !1 };
68
+ }
69
+ /**
70
+ * A static method that returns an object to update the state when an error is caught.
71
+ * @returns {object} An object to update the state when an error is caught.
72
+ */
73
+ static getDerivedStateFromError(t) {
74
+ return console.error(t), { hasError: !0 };
75
+ }
76
+ render() {
77
+ return this.state.hasError ? /* @__PURE__ */ _.jsx("h1", { children: "Something went wrong." }) : this.props.children;
78
+ }
79
+ }
80
+ const Xo = (e) => {
81
+ const t = e.replace(lt, "").split(",");
82
+ return { baseClasses: t[0], classes: t[1] };
83
+ };
84
+ let Yo = 0;
85
+ function Fe(e, t) {
86
+ const n = `atom${++Yo}`, s = {
87
+ toString: () => n
88
+ };
89
+ return typeof e == "function" ? s.read = e : (s.init = e, s.read = (r) => r(s), s.write = (r, o, i) => o(
90
+ s,
91
+ typeof i == "function" ? i(r(s)) : i
92
+ )), t && (s.write = t), s;
93
+ }
94
+ const Hs = (e) => "init" in e, Js = (e) => !!e.write, jn = /* @__PURE__ */ new WeakMap(), Zo = (e, t) => {
95
+ jn.set(e, t), e.catch(() => {
96
+ }).finally(() => jn.delete(e));
97
+ }, Xs = (e, t) => {
98
+ const n = jn.get(e);
99
+ n && (jn.delete(e), n(t));
100
+ }, Ys = (e, t) => {
101
+ e.status = "fulfilled", e.value = t;
102
+ }, Zs = (e, t) => {
103
+ e.status = "rejected", e.reason = t;
104
+ }, ea = (e) => typeof (e == null ? void 0 : e.then) == "function", zt = (e, t) => "v" in e && "v" in t && Object.is(e.v, t.v), er = (e, t) => "e" in e && "e" in t && Object.is(e.e, t.e), gt = (e) => "v" in e && e.v instanceof Promise, ta = (e, t) => "v" in e && "v" in t && e.v.orig && e.v.orig === t.v.orig, xn = (e) => {
105
+ if ("e" in e)
106
+ throw e.e;
107
+ return e.v;
108
+ }, na = () => {
109
+ const e = /* @__PURE__ */ new WeakMap(), t = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map();
110
+ let s, r, o;
111
+ const i = (p) => e.get(p), a = (p, v) => {
112
+ const I = e.get(p);
113
+ if (e.set(p, v), n.has(p) || n.set(p, I), I && gt(I)) {
114
+ const w = "v" in v ? v.v instanceof Promise ? v.v : Promise.resolve(v.v) : Promise.reject(v.e);
115
+ Xs(I.v, w);
116
+ }
117
+ }, d = (p, v, I) => {
118
+ const w = /* @__PURE__ */ new Map();
119
+ let B = !1;
120
+ I.forEach((E, S) => {
121
+ !E && S === p && (E = v), E && (w.set(S, E), v.d.get(S) !== E && (B = !0));
122
+ }), (B || v.d.size !== w.size) && (v.d = w);
123
+ }, u = (p, v, I) => {
124
+ const w = i(p), B = {
125
+ d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
126
+ v
127
+ };
128
+ if (I && d(p, B, I), w && zt(w, B) && w.d === B.d)
129
+ return w;
130
+ if (w && gt(w) && gt(B) && ta(w, B)) {
131
+ if (w.d === B.d)
132
+ return w;
133
+ B.v = w.v;
134
+ }
135
+ return a(p, B), B;
136
+ }, f = (p, v, I, w) => {
137
+ if (ea(v)) {
138
+ let B;
139
+ const E = new Promise((S, Q) => {
140
+ let $ = !1;
141
+ v.then(
142
+ (G) => {
143
+ if (!$) {
144
+ $ = !0;
145
+ const l = i(p), h = u(
146
+ p,
147
+ E,
148
+ I
149
+ );
150
+ Ys(E, G), S(G), (l == null ? void 0 : l.d) !== h.d && F(p, h, l == null ? void 0 : l.d);
151
+ }
152
+ },
153
+ (G) => {
154
+ if (!$) {
155
+ $ = !0;
156
+ const l = i(p), h = u(
157
+ p,
158
+ E,
159
+ I
160
+ );
161
+ Zs(E, G), Q(G), (l == null ? void 0 : l.d) !== h.d && F(p, h, l == null ? void 0 : l.d);
162
+ }
163
+ }
164
+ ), B = (G) => {
165
+ $ || ($ = !0, G.then(
166
+ (l) => Ys(E, l),
167
+ (l) => Zs(E, l)
168
+ ), S(G));
169
+ };
170
+ });
171
+ return E.orig = v, E.status = "pending", Zo(E, (S) => {
172
+ S && B(S), w == null || w();
173
+ }), u(p, E, I);
174
+ }
175
+ return u(p, v, I);
176
+ }, m = (p, v, I) => {
177
+ const w = i(p), B = {
178
+ d: (w == null ? void 0 : w.d) || /* @__PURE__ */ new Map(),
179
+ e: v
180
+ };
181
+ return I && d(p, B, I), w && er(w, B) && w.d === B.d ? w : (a(p, B), B);
182
+ }, b = (p) => {
183
+ const v = i(p);
184
+ if (v && (v.d.forEach(($, G) => {
185
+ G !== p && !t.has(G) && b(G);
186
+ }), Array.from(v.d).every(([$, G]) => {
187
+ const l = i($);
188
+ return $ === p || l === G || // TODO This is a hack, we should find a better solution.
189
+ l && !gt(l) && zt(l, G);
190
+ })))
191
+ return v;
192
+ const I = /* @__PURE__ */ new Map();
193
+ let w = !0;
194
+ const B = ($) => {
195
+ if ($ === p) {
196
+ const l = i($);
197
+ if (l)
198
+ return I.set($, l), xn(l);
199
+ if (Hs($))
200
+ return I.set($, void 0), $.init;
201
+ throw new Error("no atom init");
202
+ }
203
+ const G = b($);
204
+ return I.set($, G), xn(G);
205
+ };
206
+ let E, S;
207
+ const Q = {
208
+ get signal() {
209
+ return E || (E = new AbortController()), E.signal;
210
+ },
211
+ get setSelf() {
212
+ return !S && Js(p) && (S = (...$) => {
213
+ if (!w)
214
+ return j(p, ...$);
215
+ }), S;
216
+ }
217
+ };
218
+ try {
219
+ const $ = p.read(B, Q);
220
+ return f(
221
+ p,
222
+ $,
223
+ I,
224
+ () => E == null ? void 0 : E.abort()
225
+ );
226
+ } catch ($) {
227
+ return m(p, $, I);
228
+ } finally {
229
+ w = !1;
230
+ }
231
+ }, g = (p) => xn(b(p)), O = (p) => {
232
+ let v = t.get(p);
233
+ return v || (v = x(p)), v;
234
+ }, C = (p, v) => !v.l.size && (!v.t.size || v.t.size === 1 && v.t.has(p)), y = (p) => {
235
+ const v = t.get(p);
236
+ v && C(p, v) && k(p);
237
+ }, A = (p) => {
238
+ const v = /* @__PURE__ */ new Map(), I = /* @__PURE__ */ new WeakMap(), w = (E) => {
239
+ const S = t.get(E);
240
+ S == null || S.t.forEach((Q) => {
241
+ Q !== E && (v.set(
242
+ Q,
243
+ (v.get(Q) || /* @__PURE__ */ new Set()).add(E)
244
+ ), I.set(Q, (I.get(Q) || 0) + 1), w(Q));
245
+ });
246
+ };
247
+ w(p);
248
+ const B = (E) => {
249
+ const S = t.get(E);
250
+ S == null || S.t.forEach((Q) => {
251
+ var $;
252
+ if (Q !== E) {
253
+ let G = I.get(Q);
254
+ if (G && I.set(Q, --G), !G) {
255
+ let l = !!(($ = v.get(Q)) != null && $.size);
256
+ if (l) {
257
+ const h = i(Q), M = b(Q);
258
+ l = !h || !zt(h, M);
259
+ }
260
+ l || v.forEach((h) => h.delete(Q));
261
+ }
262
+ B(Q);
263
+ }
264
+ });
265
+ };
266
+ B(p);
267
+ }, D = (p, ...v) => {
268
+ let I = !0;
269
+ const w = (S) => xn(b(S)), B = (S, ...Q) => {
270
+ let $;
271
+ if (S === p) {
272
+ if (!Hs(S))
273
+ throw new Error("atom not writable");
274
+ const G = i(S), l = f(S, Q[0]);
275
+ (!G || !zt(G, l)) && A(S);
276
+ } else
277
+ $ = D(S, ...Q);
278
+ if (!I) {
279
+ const G = T();
280
+ }
281
+ return $;
282
+ }, E = p.write(w, B, ...v);
283
+ return I = !1, E;
284
+ }, j = (p, ...v) => {
285
+ const I = D(p, ...v), w = T();
286
+ return I;
287
+ }, x = (p, v) => {
288
+ const I = {
289
+ t: new Set(v && [v]),
290
+ l: /* @__PURE__ */ new Set()
291
+ };
292
+ if (t.set(p, I), b(p).d.forEach((w, B) => {
293
+ const E = t.get(B);
294
+ E ? E.t.add(p) : B !== p && x(B, p);
295
+ }), b(p), Js(p) && p.onMount) {
296
+ const w = p.onMount((...B) => j(p, ...B));
297
+ w && (I.u = w);
298
+ }
299
+ return I;
300
+ }, k = (p) => {
301
+ var v;
302
+ const I = (v = t.get(p)) == null ? void 0 : v.u;
303
+ I && I(), t.delete(p);
304
+ const w = i(p);
305
+ w && (gt(w) && Xs(w.v), w.d.forEach((B, E) => {
306
+ if (E !== p) {
307
+ const S = t.get(E);
308
+ S && (S.t.delete(p), C(E, S) && k(E));
309
+ }
310
+ }));
311
+ }, F = (p, v, I) => {
312
+ const w = new Set(v.d.keys());
313
+ I == null || I.forEach((B, E) => {
314
+ if (w.has(E)) {
315
+ w.delete(E);
316
+ return;
317
+ }
318
+ const S = t.get(E);
319
+ S && (S.t.delete(p), C(E, S) && k(E));
320
+ }), w.forEach((B) => {
321
+ const E = t.get(B);
322
+ E ? E.t.add(p) : t.has(p) && x(B, p);
323
+ });
324
+ }, T = () => {
325
+ let p;
326
+ for (; n.size; ) {
327
+ const v = Array.from(n);
328
+ n.clear(), v.forEach(([I, w]) => {
329
+ const B = i(I);
330
+ if (B) {
331
+ B.d !== (w == null ? void 0 : w.d) && F(I, B, w == null ? void 0 : w.d);
332
+ const E = t.get(I);
333
+ E && !// TODO This seems pretty hacky. Hope to fix it.
334
+ // Maybe we could `mountDependencies` in `setAtomState`?
335
+ (w && !gt(w) && (zt(w, B) || er(w, B))) && E.l.forEach((S) => S());
336
+ }
337
+ });
338
+ }
339
+ };
340
+ return {
341
+ get: g,
342
+ set: j,
343
+ sub: (p, v) => {
344
+ const I = O(p), w = T(), B = I.l;
345
+ return B.add(v), () => {
346
+ B.delete(v), y(p);
347
+ };
348
+ }
349
+ };
350
+ };
351
+ let es;
352
+ const sa = () => (es || (es = na()), es), ra = Symbol();
353
+ function ia(e, t) {
354
+ const n = Fe(
355
+ e,
356
+ (s, r, o) => r(n, t(s(n), o))
357
+ );
358
+ return n;
359
+ }
360
+ const tr = (e, t, n) => (t.has(n) ? t : t.set(n, e())).get(n), oa = /* @__PURE__ */ new WeakMap(), aa = (e, t, n) => {
361
+ const s = tr(() => /* @__PURE__ */ new WeakMap(), oa, t);
362
+ return tr(e, s, n);
363
+ }, ca = {}, nr = (e) => !!e.write, ua = (e) => typeof e == "function";
364
+ function la(e, t) {
365
+ return aa(
366
+ () => {
367
+ const n = /* @__PURE__ */ new WeakMap(), s = (i, a) => {
368
+ let d = n.get(i);
369
+ if (d)
370
+ return d;
371
+ const u = a && n.get(a), f = [], m = [];
372
+ return i.forEach((b, g) => {
373
+ const O = t ? t(b) : g;
374
+ m[g] = O;
375
+ const C = u && u.atomList[u.keyList.indexOf(O)];
376
+ if (C) {
377
+ f[g] = C;
378
+ return;
379
+ }
380
+ const y = (D) => {
381
+ const j = D(r), x = D(e), F = s(x, j == null ? void 0 : j.arr).keyList.indexOf(O);
382
+ if (F < 0 || F >= x.length) {
383
+ const T = i[s(i).keyList.indexOf(O)];
384
+ if (T)
385
+ return T;
386
+ throw new Error("splitAtom: index out of bounds for read");
387
+ }
388
+ return x[F];
389
+ }, A = (D, j, x) => {
390
+ const k = D(r), F = D(e), R = s(F, k == null ? void 0 : k.arr).keyList.indexOf(O);
391
+ if (R < 0 || R >= F.length)
392
+ throw new Error("splitAtom: index out of bounds for write");
393
+ const p = ua(x) ? x(F[R]) : x;
394
+ j(e, [
395
+ ...F.slice(0, R),
396
+ p,
397
+ ...F.slice(R + 1)
398
+ ]);
399
+ };
400
+ f[g] = nr(e) ? Fe(y, A) : Fe(y);
401
+ }), u && u.keyList.length === m.length && u.keyList.every((b, g) => b === m[g]) ? d = u : d = { arr: i, atomList: f, keyList: m }, n.set(i, d), d;
402
+ }, r = Fe((i) => {
403
+ const a = i(r), d = i(e);
404
+ return s(d, a == null ? void 0 : a.arr);
405
+ });
406
+ r.init = void 0;
407
+ const o = nr(e) ? Fe(
408
+ (i) => i(r).atomList,
409
+ (i, a, d) => {
410
+ switch (d.type) {
411
+ case "remove": {
412
+ const u = i(o).indexOf(d.atom);
413
+ if (u >= 0) {
414
+ const f = i(e);
415
+ a(e, [
416
+ ...f.slice(0, u),
417
+ ...f.slice(u + 1)
418
+ ]);
419
+ }
420
+ break;
421
+ }
422
+ case "insert": {
423
+ const u = d.before ? i(o).indexOf(d.before) : i(o).length;
424
+ if (u >= 0) {
425
+ const f = i(e);
426
+ a(e, [
427
+ ...f.slice(0, u),
428
+ d.value,
429
+ ...f.slice(u)
430
+ ]);
431
+ }
432
+ break;
433
+ }
434
+ case "move": {
435
+ const u = i(o).indexOf(d.atom), f = d.before ? i(o).indexOf(d.before) : i(o).length;
436
+ if (u >= 0 && f >= 0) {
437
+ const m = i(e);
438
+ u < f ? a(e, [
439
+ ...m.slice(0, u),
440
+ ...m.slice(u + 1, f),
441
+ m[u],
442
+ ...m.slice(f)
443
+ ]) : a(e, [
444
+ ...m.slice(0, f),
445
+ m[u],
446
+ ...m.slice(f, u),
447
+ ...m.slice(u + 1)
448
+ ]);
449
+ }
450
+ break;
451
+ }
452
+ }
453
+ }
454
+ ) : Fe((i) => i(r).atomList);
455
+ return o;
456
+ },
457
+ e,
458
+ t || ca
459
+ );
460
+ }
461
+ const da = (e) => typeof (e == null ? void 0 : e.then) == "function";
462
+ function fa(e) {
463
+ let t, n;
464
+ const s = {
465
+ getItem: (r, o) => {
466
+ var i, a;
467
+ const d = (f) => {
468
+ if (f = f || "", t !== f) {
469
+ try {
470
+ n = JSON.parse(f);
471
+ } catch {
472
+ return o;
473
+ }
474
+ t = f;
475
+ }
476
+ return n;
477
+ }, u = (a = (i = e()) == null ? void 0 : i.getItem(r)) != null ? a : null;
478
+ return da(u) ? u.then(d) : d(u);
479
+ },
480
+ setItem: (r, o) => {
481
+ var i;
482
+ return (i = e()) == null ? void 0 : i.setItem(r, JSON.stringify(o));
483
+ },
484
+ removeItem: (r) => {
485
+ var o;
486
+ return (o = e()) == null ? void 0 : o.removeItem(r);
487
+ }
488
+ };
489
+ return typeof window < "u" && typeof window.addEventListener == "function" && (s.subscribe = (r, o, i) => {
490
+ if (!(e() instanceof window.Storage))
491
+ return () => {
492
+ };
493
+ const a = (d) => {
494
+ if (d.storageArea === e() && d.key === r) {
495
+ let u;
496
+ try {
497
+ u = JSON.parse(d.newValue || "");
498
+ } catch {
499
+ u = i;
500
+ }
501
+ o(u);
502
+ }
503
+ };
504
+ return window.addEventListener("storage", a), () => {
505
+ window.removeEventListener("storage", a);
506
+ };
507
+ }), s;
508
+ }
509
+ const ha = fa(
510
+ () => typeof window < "u" ? window.localStorage : void 0
511
+ );
512
+ function pt(e, t, n = ha, s) {
513
+ const r = s == null ? void 0 : s.unstable_getOnInit, o = Fe(
514
+ r ? n.getItem(e, t) : t
515
+ );
516
+ return o.onMount = (a) => {
517
+ r || a(n.getItem(e, t));
518
+ let d;
519
+ return n.subscribe && (d = n.subscribe(e, a, t)), d;
520
+ }, Fe(
521
+ (a) => a(o),
522
+ (a, d, u) => {
523
+ const f = typeof u == "function" ? u(a(o)) : u;
524
+ return f === ra ? (d(o, t), n.removeItem(e)) : f instanceof Promise ? f.then((m) => (d(o, m), n.setItem(e, m))) : (d(o, f), n.setItem(e, f));
525
+ }
526
+ );
527
+ }
528
+ const pa = go(void 0), ri = (e) => {
529
+ const t = bo(pa);
530
+ return (e == null ? void 0 : e.store) || t || sa();
531
+ }, ma = (e) => typeof (e == null ? void 0 : e.then) == "function", ga = Es.use || ((e) => {
532
+ if (e.status === "pending")
533
+ throw e;
534
+ if (e.status === "fulfilled")
535
+ return e.value;
536
+ throw e.status === "rejected" ? e.reason : (e.status = "pending", e.then(
537
+ (t) => {
538
+ e.status = "fulfilled", e.value = t;
539
+ },
540
+ (t) => {
541
+ e.status = "rejected", e.reason = t;
542
+ }
543
+ ), e);
544
+ });
545
+ function ya(e, t) {
546
+ const n = ri(t), [[s, r, o], i] = yo(
547
+ (u) => {
548
+ const f = n.get(e);
549
+ return Object.is(u[0], f) && u[1] === n && u[2] === e ? u : [f, n, e];
550
+ },
551
+ void 0,
552
+ () => [n.get(e), n, e]
553
+ );
554
+ let a = s;
555
+ (r !== n || o !== e) && (i(), a = n.get(e));
556
+ const d = t == null ? void 0 : t.delay;
557
+ return ke(() => {
558
+ const u = n.sub(e, () => {
559
+ if (typeof d == "number") {
560
+ setTimeout(i, d);
561
+ return;
562
+ }
563
+ i();
564
+ });
565
+ return i(), u;
566
+ }, [n, e, d]), vo(a), ma(a) ? ga(a) : a;
567
+ }
568
+ function va(e, t) {
569
+ const n = ri(t);
570
+ return X(
571
+ (...r) => n.set(e, ...r),
572
+ [n, e]
573
+ );
574
+ }
575
+ function ba(e, t) {
576
+ return [
577
+ ya(e, t),
578
+ // We do wrong type assertion here, which results in throwing an error.
579
+ va(e, t)
580
+ ];
581
+ }
582
+ const wa = new ni({ children: "blockNodes" }), ii = (e, t = null) => be(
583
+ e.map((n) => {
584
+ if (n = t !== null ? { ...n, parent: t } : n, n.children && n.children.length) {
585
+ const s = [...n.children];
586
+ return delete n.children, be([n, ...ii(s, n._id)]);
587
+ }
588
+ return n;
589
+ })
590
+ );
591
+ function oi(e, t, n) {
592
+ const s = te(e, (o) => o._parent === t), r = [];
593
+ for (let o = 0; o < s.length; o++) {
594
+ const i = ai(s[o]);
595
+ if (Object.keys(i).length > 0 && Object.keys(i).forEach((a) => {
596
+ s[o][a] = `slot:${He()}`;
597
+ }), te(e, { _parent: s[o]._id }).length > 0) {
598
+ const a = He();
599
+ r.push({ ...s[o], oldId: s[o]._id, _id: a, _parent: n }), r.push(be(oi(e, s[o]._id, a)));
600
+ } else
601
+ r.push({
602
+ ...s[o],
603
+ oldId: s[o]._id,
604
+ _id: He(),
605
+ _parent: n
606
+ });
607
+ }
608
+ return be(r);
609
+ }
610
+ function Sa(e) {
611
+ let t = wa.convert(e.map((n) => Tn(n, ["settings"])));
612
+ return t = !t.type && t.blockNodes ? t.blockNodes : Me(t) ? [] : [t], t;
613
+ }
614
+ const ai = (e) => {
615
+ const t = {};
616
+ return Object.keys(e).forEach((n) => {
617
+ Ps(e[n]) && e[n].startsWith("slot") && (t[n] = e[n].replace("slot:", ""));
618
+ }), t;
619
+ }, xa = (e, t, n = null) => {
620
+ let s = Ae(e, { _id: t });
621
+ s = { ...s, oldId: s._id, _id: He() }, n && (s = { ...s, _parent: n });
622
+ const r = [s];
623
+ te(e, { _parent: t }).length > 0 && r.push(be(oi(e, t, s._id)));
624
+ const o = be(r);
625
+ return ue(o, (i) => {
626
+ const a = i, d = ai(a);
627
+ return Object.keys(d).length > 0 && Object.keys(d).forEach((u) => {
628
+ const f = Ae(o, { oldId: d[u].replace("slot:", "") });
629
+ a[u] = `slot:${f._id}`;
630
+ }), Tn(a, ["global", "oldId"]);
631
+ });
632
+ }, ka = Do(
633
+ // eslint-disable-next-line default-param-last
634
+ (e = [], t) => {
635
+ switch (t.type) {
636
+ case "add_new_blocks":
637
+ case "add_duplicate_blocks":
638
+ return [...e, ...t.payload];
639
+ case "create_snapshot":
640
+ return [...e];
641
+ case "set_blocks":
642
+ case "set_page_blocks":
643
+ return [...t.payload];
644
+ case "update_props":
645
+ case "update_props_realtime":
646
+ const { payload: n } = t;
647
+ return e.map((s) => (n.ids.includes(s._id) && !Me(t.payload.props) && Object.keys(t.payload.props).forEach((r) => {
648
+ ut(s, r, t.payload.props[r]);
649
+ }), s));
650
+ default:
651
+ return e;
652
+ }
653
+ },
654
+ {
655
+ debug: !1,
656
+ ignoreInitialState: !1,
657
+ limit: 30,
658
+ filter: Mo(["update_props_realtime", "add_duplicate_blocks", "set_page_blocks"])
659
+ }
660
+ ), Fn = ia(
661
+ {
662
+ past: [],
663
+ present: [],
664
+ future: []
665
+ },
666
+ ka
667
+ );
668
+ Fn.debugLabel = "pageBlocksAtom";
669
+ const we = N((e) => {
670
+ var t;
671
+ return (t = e(Fn)) == null ? void 0 : t.present;
672
+ });
673
+ we.debugLabel = "presentBlocksAtom";
674
+ const _s = la(we);
675
+ _s.debugLabel = "pageBlocksAtomsAtom";
676
+ const ci = N((e) => Sa(e(we)));
677
+ ci.debugLabel = "pageBlocksTreeAtom";
678
+ const Aa = N("");
679
+ Aa.debugLabel = "builderActivePageAtom";
680
+ const Ea = N(-1);
681
+ Ea.debugLabel = "destinationDropIndexAtom";
682
+ const Pa = N(!1);
683
+ Pa.debugLabel = "addBlocksModalAtom";
684
+ const Se = () => {
685
+ const [, e] = Y(Fn);
686
+ return e;
687
+ }, rd = () => {
688
+ const e = Se(), t = ne(ci), n = X(
689
+ (s) => {
690
+ const r = ii(s);
691
+ e({ type: "set_page_blocks", payload: r });
692
+ },
693
+ [e]
694
+ );
695
+ return [t, n];
696
+ }, Oa = () => {
697
+ const e = Se();
698
+ return [X(
699
+ (n) => {
700
+ e({ type: "set_page_blocks", payload: n });
701
+ },
702
+ [e]
703
+ )];
704
+ }, us = (e) => ["Box", "Slot", "Form", "DataContext", "Link", "List", "ListItem", "Row", "Column", "Table", "TableCell"].includes(
705
+ e
706
+ ), id = (e) => !["Slot"].includes(e), od = (e) => !["Slot"].includes(e);
707
+ function _a(e, t) {
708
+ return e === "Slot" || t === "List" && e !== "ListItem" || t === "Row" && e !== "Column" ? !1 : us(t);
709
+ }
710
+ const ad = (e, { dragSource: t, dropTarget: n }) => {
711
+ const s = ee(t, "data._type", ""), r = ee(n, "data._type", "");
712
+ return s === "Slot" || ee(t, "id") && ee(t, "id") === ee(n, "id") ? !1 : Me(r) ? !0 : _a(s, r);
713
+ }, ui = N([]);
714
+ ui.debugLabel = "buildingBlocksAtom";
715
+ const Ca = N((e) => {
716
+ const t = e(ui);
717
+ return te(t, (n) => Os(n, "blockId"));
718
+ }), Ia = () => {
719
+ }, li = () => {
720
+ const e = No(), t = ne(Ca), n = () => {
721
+ }, s = X(() => Ia(), []);
722
+ return [e, t, n, s];
723
+ }, Cs = N([]);
724
+ Cs.debugLabel = "selectedBlockIdsAtom";
725
+ const Is = N((e) => {
726
+ const t = e(we), n = e(Cs);
727
+ return ue(
728
+ te(t, ({ _id: s }) => de(n, s)),
729
+ (s) => ({ ...s })
730
+ );
731
+ });
732
+ Is.debugLabel = "selectedBlocksAtom";
733
+ const Bs = N((e) => {
734
+ const t = e(Is);
735
+ return t.length === 0 ? null : t.length === 1 ? t[0] : {
736
+ type: "Multiple",
737
+ id: ue(t, "id")
738
+ };
739
+ });
740
+ Bs.debugLabel = "selectedBlockAtom";
741
+ const Ba = (e) => ee(e, "parent", null), ja = N((e) => {
742
+ const t = e(Is), n = ue(t, Ba);
743
+ return te(e(we), (s) => de(n, s._id));
744
+ });
745
+ ja.debugLabel = "selectedBlocksParentsAtom";
746
+ const di = N(() => !1);
747
+ di.debugLabel = "selectedBlockFlexChildAtom";
748
+ const fi = N(() => !1);
749
+ fi.debugLabel = "selectedBlockGridChildAtom";
750
+ const js = N("");
751
+ js.debugLabel = "styleStateAtom";
752
+ const hi = pt("styleBreakpoint", "xs");
753
+ hi.debugLabel = "styleBreakpointAtom";
754
+ const cd = () => ({
755
+ flexChild: ne(di),
756
+ gridChild: ne(fi)
757
+ }), ud = () => ne(Bs), mt = () => {
758
+ const [e, t] = Y(Cs), n = X(
759
+ (s) => {
760
+ t((r) => de(r, s) ? Yr(r, s) : [...r, s]);
761
+ },
762
+ [t]
763
+ );
764
+ return [e, t, n];
765
+ }, sr = (e, t = "") => {
766
+ switch (e.type) {
767
+ case "singular":
768
+ return e.uiSchema;
769
+ case "model":
770
+ const { properties: n } = e, s = {};
771
+ return Object.keys(n).forEach((i) => {
772
+ const a = n[i];
773
+ if (de(["slot", "styles"], a.type))
774
+ return;
775
+ const d = ee(a, "i18n", !1) ? `${i}-${t}` : i;
776
+ s[d] = sr(a, t);
777
+ }), s;
778
+ case "list":
779
+ const { itemProperties: r } = e, o = {
780
+ items: {}
781
+ };
782
+ return Object.keys(r).forEach((i) => {
783
+ const a = r[i];
784
+ if (de(["slot", "styles"], a.type))
785
+ return;
786
+ const d = ee(a, "i18n", !1) ? `${i}-${t}` : i;
787
+ o.items[d] = sr(a, t);
788
+ }), o;
789
+ default:
790
+ return {};
791
+ }
792
+ }, rr = (e, t = "") => {
793
+ switch (e.type) {
794
+ case "singular":
795
+ return e.schema;
796
+ case "model":
797
+ const { properties: n, title: s } = e, r = {
798
+ title: s,
799
+ type: "object",
800
+ properties: {}
801
+ };
802
+ return Object.keys(n).forEach((d) => {
803
+ const u = n[d];
804
+ if (de(["slot", "styles"], u.type))
805
+ return;
806
+ const f = ee(u, "i18n", !1) ? `${d}-${t}` : d;
807
+ r.properties[f] = rr(u, t);
808
+ }), r;
809
+ case "list":
810
+ const { itemProperties: o, title: i } = e, a = {
811
+ title: i,
812
+ type: "array",
813
+ items: {
814
+ type: "object",
815
+ properties: {}
816
+ }
817
+ };
818
+ return Object.keys(o).forEach((d) => {
819
+ const u = o[d];
820
+ if (de(["slot", "styles"], u.type))
821
+ return;
822
+ const f = ee(u, "i18n", !1) ? `${d}-${t}` : d;
823
+ a.items.properties[f] = rr(u, t), ut(a.items, "title", ee(u, "itemTitle", `${i} item`));
824
+ }), a;
825
+ default:
826
+ return {};
827
+ }
828
+ }, pi = (e) => {
829
+ const t = {};
830
+ return Object.keys(e).forEach((n) => {
831
+ t[n] = Da(e[n]);
832
+ }), t;
833
+ }, Ra = (e) => {
834
+ if (Me(e.default))
835
+ return [];
836
+ const { itemProperties: t } = e;
837
+ return ue(e.default, (n) => {
838
+ const s = { ...n };
839
+ return Zr(n, (r, o) => {
840
+ Os(t, o) && ee(t[o], "i18n", !1) && (s[o] = si);
841
+ }), s;
842
+ });
843
+ }, Da = (e) => {
844
+ switch (e.type) {
845
+ case "styles":
846
+ return e.default;
847
+ case "slot":
848
+ return `${cs}${He()}`;
849
+ case "singular":
850
+ const { i18n: t, schema: n } = e;
851
+ return t ? si : ee(n, "default", "");
852
+ case "model":
853
+ return pi(e.properties);
854
+ case "list":
855
+ return Ra(e);
856
+ default:
857
+ return "";
858
+ }
859
+ }, Ma = () => ne(we);
860
+ function ir(e, t, n, s, r) {
861
+ if (t === null)
862
+ return [...e, ...s];
863
+ if (n !== null) {
864
+ const d = Sn(e, { _parent: t }), u = (d === -1 ? 0 : d) + n;
865
+ return e.splice(u, 0, ...s), e;
866
+ }
867
+ if (!r) {
868
+ const u = Sn(e, { _id: t }) + 1;
869
+ return e.splice(u, 0, ...s), e;
870
+ }
871
+ let o = Sn(e, { _id: t });
872
+ const i = te(e, { _parent: t });
873
+ Me(i) || (o = Sn(e, { _id: ko(i)._id }));
874
+ const a = o + 1;
875
+ return e.splice(a, 0, ...s), e;
876
+ }
877
+ const ld = () => {
878
+ const e = Se(), t = Ma(), [, n] = li(), [, s] = mt(), r = X(
879
+ (i, a, d) => {
880
+ if (Os(i, "blocks")) {
881
+ const y = i.blocks;
882
+ return o(y, a, d);
883
+ }
884
+ const u = He(), f = pi(i.props), m = [];
885
+ Zr(f, (y, A) => {
886
+ if (ei(y, cs)) {
887
+ const D = y.replace(cs, "");
888
+ m.push({
889
+ _id: D,
890
+ _type: "Slot",
891
+ _parent: u,
892
+ _name: i.props[A].name,
893
+ _styles: i.props[A].styles,
894
+ _emptyStyles: i.props[A].emptyStyles
895
+ });
896
+ }
897
+ });
898
+ const b = {
899
+ _type: i.type,
900
+ _id: u,
901
+ ...f
902
+ };
903
+ let g;
904
+ a && (g = Ae(t, { _id: a }), b._parent = a);
905
+ const O = g ? us(g._type) : !0;
906
+ !O && g && (b._parent = g._parent);
907
+ const C = [b, ...m];
908
+ return e({
909
+ type: "set_blocks",
910
+ payload: ir(t, a || null, d || null, C, O)
911
+ }), s([b._id]), b;
912
+ },
913
+ [t, e, s]
914
+ ), o = X(
915
+ (i, a, d) => {
916
+ var m;
917
+ for (let b = 0; b < i.length; b++) {
918
+ const { _id: g } = i[b];
919
+ i[b]._id = He();
920
+ const O = te(i, { _parent: g });
921
+ for (let C = 0; C < O.length; C++)
922
+ O[C]._parent = i[b]._id;
923
+ }
924
+ let u;
925
+ a && (u = Ae(t, { _id: a }), i[0]._parent = a);
926
+ const f = u ? us(u._type) : !0;
927
+ return !f && u && (i[0]._parent = u._parent), e({
928
+ type: "set_blocks",
929
+ payload: ir(t, a || null, d || null, i, f)
930
+ }), s([(m = je(i)) == null ? void 0 : m._id]), je(i);
931
+ },
932
+ [t, e, s, n]
933
+ );
934
+ return { addCoreBlock: r, addPredefinedBlock: o };
935
+ }, or = {
936
+ xs: 420,
937
+ sm: 620,
938
+ md: 768,
939
+ lg: 1024,
940
+ xl: 1280,
941
+ "2xl": 1536
942
+ }, ar = ["xs", "sm", "md", "lg", "xl", "2xl"];
943
+ function La(e, t) {
944
+ if (t === null)
945
+ return "baseClasses";
946
+ const n = t.mq;
947
+ if (n === "xs" || t.dark || t.mod !== "")
948
+ return "classes";
949
+ let s = "baseClasses", r = ar.indexOf(n);
950
+ for (; r > 0; ) {
951
+ const o = ar[r - 1];
952
+ if (Ae(e, {
953
+ mq: o,
954
+ property: t.property
955
+ })) {
956
+ s = "classes";
957
+ break;
958
+ }
959
+ r--;
960
+ }
961
+ return s;
962
+ }
963
+ const cr = [];
964
+ function Na(e = "", t = "", n = []) {
965
+ e = e.trim().replace(/ +/g, "");
966
+ let s = te(
967
+ ue(e.split(" "), Cn),
968
+ (u) => !os(u)
969
+ ), r = te(ue(t.split(" "), Cn), (u) => !os(u));
970
+ r = te(
971
+ r,
972
+ (u) => !de(cr, u.property)
973
+ );
974
+ const o = [], i = [];
975
+ We(n, (u) => {
976
+ const f = Cn(u), m = Ae(s, Gs(f, ["dark", "mq", "mod", "property"]));
977
+ if (m && (s = te(
978
+ s,
979
+ (b) => b.fullCls !== (m == null ? void 0 : m.fullCls)
980
+ )), o.push(f), f.mq === "xs" && !f.dark && f.mod === "" && (r = te(r, (b) => b.property !== f.property)), La(s, f) === "baseClasses" && !de(cr, f.property)) {
981
+ const b = Ae(r, Gs(f, ["property"]));
982
+ m && (r = te(
983
+ r,
984
+ (g) => g.fullCls !== (b == null ? void 0 : b.fullCls)
985
+ )), i.push({
986
+ ...f,
987
+ fullCls: f.cls,
988
+ mq: "xs"
989
+ });
990
+ }
991
+ });
992
+ const a = ue(
993
+ Ws([...s, ...o], (u) => or[u.mq]),
994
+ "fullCls"
995
+ ).join(" ");
996
+ return `${ue(
997
+ Ws([...r, ...i], (u) => or[u.mq]),
998
+ "fullCls"
999
+ ).join(" ").trim()},${a.trim()}`.trim().replace(/ +/g, "");
1000
+ }
1001
+ const gn = N([]);
1002
+ gn.debugLabel = "selectedStylingBlocksAtom";
1003
+ const mi = () => Y(gn), Ta = (e) => {
1004
+ const t = e.replace(lt, "").split(",");
1005
+ return { baseClasses: t[0], classes: t[1] };
1006
+ }, Fa = N(null, (e, t, { blockIds: n, newClasses: s, dispatch: r }) => {
1007
+ const o = te(
1008
+ e(_s),
1009
+ (a) => (
1010
+ // @ts-ignore
1011
+ n.includes(e(a)._id)
1012
+ )
1013
+ ), i = je(e(gn));
1014
+ We(o, (a) => {
1015
+ const d = e(a), u = ee(d, i.prop, `${lt},`), { baseClasses: f, classes: m } = Ta(u);
1016
+ r({
1017
+ type: "update_props_realtime",
1018
+ payload: {
1019
+ ids: [d._id],
1020
+ props: { [i.prop]: `${lt}${Na(m, f, s)}` }
1021
+ }
1022
+ });
1023
+ });
1024
+ }), dd = () => {
1025
+ const e = Se(), t = Xe(Fa);
1026
+ return X(
1027
+ (n, s, r) => {
1028
+ t({ blockIds: n, newClasses: s, dispatch: e }), r && setTimeout(() => e({ type: "create_snapshot" }), 500);
1029
+ },
1030
+ [e, t]
1031
+ );
1032
+ }, Ua = N(!1), gi = () => {
1033
+ const [e, t] = Y(Ua);
1034
+ return [e, t];
1035
+ }, qa = N(as), yi = () => {
1036
+ const [e, t] = Y(qa);
1037
+ return [
1038
+ Ao(e) ? { ...e, ...as } : as,
1039
+ t
1040
+ ];
1041
+ }, $a = N(null), Qa = () => ({ currentPage: ne($a) }), vi = new ni({});
1042
+ function Va(e) {
1043
+ let t = vi.convert(e);
1044
+ return t = !t.type && t.children && t.children.length ? t.children : Me(t) ? [] : [t], t;
1045
+ }
1046
+ const Rs = (e, t) => be(
1047
+ e.map((n) => {
1048
+ if (n = t ? { ...n, parent: t } : { ...n }, n.children) {
1049
+ const s = [...n.children];
1050
+ return delete n.children, be([n, ...Rs(s, n._id)]);
1051
+ }
1052
+ return n;
1053
+ })
1054
+ );
1055
+ function Ds(e, t = !1) {
1056
+ for (let n = 0; n < e.length; n++) {
1057
+ const s = e[n];
1058
+ s.global && !t ? e[n] = {
1059
+ type: "GlobalBlock",
1060
+ _parent: ee(s, "parent", null),
1061
+ blockId: s.blockId,
1062
+ _id: s._id
1063
+ } : s.children && s.children.length && Ds(s.children);
1064
+ }
1065
+ }
1066
+ function bi(e) {
1067
+ let t = [], n = te(e, { type: "GlobalBlock" });
1068
+ return n.length > 0 && (n = ue(n, wi), We(n, (s) => {
1069
+ t = [...t, ...Ka(s)];
1070
+ })), t;
1071
+ }
1072
+ function Ka(e) {
1073
+ let t = [];
1074
+ const n = ee(je(e), "parent", null);
1075
+ ut(je(e), "parent", null);
1076
+ const s = [vi.convert(Si(e))];
1077
+ Ds(s, !0);
1078
+ let r = Rs(s, e[0]._id);
1079
+ return r = ut(r, "0.parent", n), t = [...t, r, ...bi(r)], t;
1080
+ }
1081
+ function wi(e) {
1082
+ const t = Ae(ls, { _id: e._id });
1083
+ if (!t)
1084
+ return [];
1085
+ const n = [t], s = te(ls, { _parent: e._id });
1086
+ return s.length ? be([...n, ...be(ue(s, wi))]) : be(n);
1087
+ }
1088
+ const Si = (e) => JSON.parse(JSON.stringify(e));
1089
+ let ls = [];
1090
+ function za(e) {
1091
+ ls = e;
1092
+ const t = Va(Si(e));
1093
+ Ds(t);
1094
+ const n = Rs(t, null), s = bi(n), r = {};
1095
+ return We(s, (o) => ut(r, je(o).blockId, o)), [n, r];
1096
+ }
1097
+ const xi = () => {
1098
+ const [e] = yi(), { currentPage: t } = Qa(), n = ne(we);
1099
+ return X(() => {
1100
+ const s = ue(
1101
+ n,
1102
+ (i) => Tn(i, ["expanded", "order", "title", "siblings", "tempClasses"])
1103
+ ), [r = [], o = []] = za(s);
1104
+ return {
1105
+ currentPage: t,
1106
+ blocks: r,
1107
+ globalBlocks: o
1108
+ };
1109
+ }, [e, t, n]);
1110
+ };
1111
+ pt("blockStylingActiveTab", 1);
1112
+ N([]);
1113
+ const ki = N(!1);
1114
+ ki.debugLabel = "readOnlyModeAtom";
1115
+ const Ga = N(!1);
1116
+ Ga.debugLabel = "inlineEditingActiveAtom";
1117
+ const Wa = N(!1);
1118
+ Wa.debugLabel = "advanceStylingOpenAtom";
1119
+ const Ha = N("online");
1120
+ Ha.debugLabel = "networkModeAtom";
1121
+ pt("currentUiLibrary", "");
1122
+ const Ja = N(!1);
1123
+ Ja.debugLabel = "codeEditorOpenAtom";
1124
+ const Xa = N(!1);
1125
+ Xa.debugLabel = "editLayerNameAtom";
1126
+ const Ya = N("");
1127
+ Ya.debugLabel = "activeLanguageAtom";
1128
+ const Za = N("");
1129
+ Za.debugLabel = "primaryLanguageAtom";
1130
+ const ec = N(null);
1131
+ ec.debugLabel = "canvasIframeAtom";
1132
+ const tc = N("layers");
1133
+ tc.debugLabel = "activePanelAtom";
1134
+ const nc = N(!1);
1135
+ nc.debugLabel = "addBlockOffCanvasAtom";
1136
+ const sc = N("");
1137
+ sc.debugLabel = "showPredefinedBlockCategoryAtom";
1138
+ const Un = N({ undoCount: 0, redoCount: 0 });
1139
+ Un.debugLabel = "historyStatesAtom";
1140
+ const qn = N("SAVED");
1141
+ qn.debugLabel = "pageSyncStateAtom";
1142
+ const fd = () => {
1143
+ const [e, t] = Y(qn), n = en("onSaveBlocks", async () => {
1144
+ }), s = en("onSyncStatusChange", () => {
1145
+ }), r = xi(), o = Xe(Un), { undoCount: i, redoCount: a } = $n();
1146
+ return { savePage: Lo(
1147
+ async () => {
1148
+ t("SAVING"), s("SAVING");
1149
+ const u = r();
1150
+ return await n({ blocks: u.blocks, globalBlocks: u.globalBlocks }), setTimeout(() => {
1151
+ o({ undoCount: i, redoCount: a }), t("SAVED"), s("SAVED");
1152
+ }, 100), !0;
1153
+ },
1154
+ [r, t, s, n],
1155
+ 5e3
1156
+ // save only every 5 seconds
1157
+ ), syncState: e, setSyncState: t };
1158
+ }, $n = () => {
1159
+ const e = ne(Fn), [{ undoCount: t, redoCount: n }] = Y(Un), s = Se(), [r] = gi(), [, o] = mt(), [, i] = mi(), [, a] = Y(qn), d = en("onSyncStatusChange", () => {
1160
+ }), u = X(() => {
1161
+ s({ type: "create_snapshot" });
1162
+ }, [s]);
1163
+ return ke(() => {
1164
+ t !== (e == null ? void 0 : e.past.length) || n !== (e == null ? void 0 : e.future.length) ? (a("UNSAVED"), d("UNSAVED")) : t === (e == null ? void 0 : e.past.length) && n === (e == null ? void 0 : e.future.length) && (a("SAVED"), d("SAVED"));
1165
+ }, [e == null ? void 0 : e.past.length, e == null ? void 0 : e.future.length, t, n, d, a]), {
1166
+ undoCount: e == null ? void 0 : e.past.length,
1167
+ redoCount: e == null ? void 0 : e.future.length,
1168
+ undo: X(() => {
1169
+ r || (s(Zn.undo()), setTimeout(() => {
1170
+ i([]), o([]);
1171
+ }, 200));
1172
+ }, [s, r, a]),
1173
+ redo: X(() => {
1174
+ r || (s(Zn.redo()), setTimeout(() => {
1175
+ i([]), o([]);
1176
+ }, 200));
1177
+ }, [r, s]),
1178
+ clear: () => {
1179
+ s(Zn.clearHistory());
1180
+ },
1181
+ createSnapshot: u
1182
+ };
1183
+ }, rc = () => Y(hi), Ai = pt("canvasWidth", 360), Ei = N((e) => {
1184
+ const t = e(Ai);
1185
+ return Ro(t).toLowerCase();
1186
+ }), hd = () => {
1187
+ const [e, t] = Y(Ai), n = ne(Ei), [s, r] = rc();
1188
+ return ke(() => {
1189
+ s !== "xs" && r(n);
1190
+ }, [n, s, r]), [e, n, t];
1191
+ }, ic = pt("canvasZoom", 100), pd = () => Y(ic), Pi = N([]), Oi = () => {
1192
+ const [e, t] = Y(Pi), n = Xe(Ms), s = X(
1193
+ (r) => {
1194
+ t(r), n([]);
1195
+ },
1196
+ [t, n]
1197
+ );
1198
+ return [e, s];
1199
+ }, Ms = N([]), oc = () => {
1200
+ const [e, t] = Y(Ms), n = Xe(Pi), s = X(
1201
+ (r) => {
1202
+ t(r), n([]);
1203
+ },
1204
+ [t, n]
1205
+ );
1206
+ return [e, s];
1207
+ }, _i = pt("darkMode", !1), md = () => {
1208
+ const [e, t] = Y(_i);
1209
+ return [e, t];
1210
+ }, ac = N(!1), gd = () => {
1211
+ const [e, t] = Y(ac);
1212
+ return [e, t];
1213
+ }, Ci = () => {
1214
+ const e = Se(), t = ne(we), [, n] = mt();
1215
+ return X(
1216
+ (s, r = null) => {
1217
+ const o = [];
1218
+ We(s, (i) => {
1219
+ const d = xa(t, i, r === i ? null : r);
1220
+ o.push(ee(d, "0._id", "")), e({ type: "add_duplicate_blocks", payload: d });
1221
+ }), n(o), e({ type: "create_snapshot" });
1222
+ },
1223
+ [t, n, e]
1224
+ );
1225
+ }, cc = N([]), yd = () => {
1226
+ const [e, t] = Y(cc), n = X(
1227
+ (s) => {
1228
+ t((r) => de(r, s) ? Yr(r, s) : [...r, s]);
1229
+ },
1230
+ [t]
1231
+ );
1232
+ return [e, t, n];
1233
+ }, uc = N(""), lc = () => Y(uc), vd = () => {
1234
+ const e = ne(we), t = Se(), n = xi(), [, , s] = li();
1235
+ return X(
1236
+ async (r, o) => {
1237
+ const i = He(16), a = ue(e, (d) => (d._id === r && (d._globalBlockId = i, d._name = o), d));
1238
+ t({ type: "set_page_blocks", payload: a }), s();
1239
+ },
1240
+ [e, t, n, s]
1241
+ );
1242
+ }, bd = () => ({}), dc = () => {
1243
+ const e = ne(we), t = Se();
1244
+ return X(
1245
+ (n, s) => {
1246
+ const r = ue(e, (o) => (de(n, ee(o, "_id")) && ut(o, "_parent", s), o));
1247
+ t({ type: "set_blocks", payload: r });
1248
+ },
1249
+ [e, t]
1250
+ );
1251
+ }, fc = () => {
1252
+ const e = ne(Ms), [t, n] = Oi(), s = Ci(), r = dc();
1253
+ return {
1254
+ canPaste: wo(
1255
+ () => t.length > 0 || e.length > 0,
1256
+ [e, t]
1257
+ ),
1258
+ pasteBlocks: X(
1259
+ (i) => {
1260
+ Me(e) ? r(t, i) : s(e, i), n(() => []);
1261
+ },
1262
+ [t, e, s, r, n]
1263
+ )
1264
+ };
1265
+ }, hc = N(""), wd = () => {
1266
+ const e = ne(hc), t = X(() => {
1267
+ }, []), n = X(() => {
1268
+ }, []), s = X(() => {
1269
+ }, []);
1270
+ return { currentProject: e, createProject: s, deleteProject: t, updateProject: n };
1271
+ }, Ii = (e, t) => {
1272
+ const n = [], s = te(e, (r) => de(t, r._id) || de(t, r._parent) ? (n.push(r._id), !1) : !0);
1273
+ return Me(n) ? s : Ii(s, n);
1274
+ }, pc = () => {
1275
+ const e = Se(), t = ne(we), [n, s] = mt();
1276
+ return X(
1277
+ (r) => {
1278
+ var a;
1279
+ const o = ((a = Ae(t, { _id: r[0] })) == null ? void 0 : a._parent) || null, i = Ii(t, r);
1280
+ e({ type: "set_blocks", payload: i }), s(o ? [o] : []);
1281
+ },
1282
+ [t, s, e, n]
1283
+ );
1284
+ }, mc = N(null, (e, t, { blockIds: n, fullClasses: s, dispatch: r }) => {
1285
+ const o = je(e(gn)), i = te(
1286
+ e(_s),
1287
+ (a) => (
1288
+ // @ts-ignore
1289
+ n.includes(e(a)._id)
1290
+ )
1291
+ );
1292
+ We(i, (a) => {
1293
+ const d = e(a), u = s;
1294
+ let { classes: f, baseClasses: m } = Xo(ee(d, o.prop, "styles:,"));
1295
+ We(u, (b) => {
1296
+ const g = new RegExp(`(^| )${b.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
1297
+ f = f.replace(g, " ").replace(/ +/g, " ").trim();
1298
+ const O = je(b.split(":"));
1299
+ de(["2xl", "xl", "lg", "md", "sm"], O) && u.push(b.split(":").pop().trim());
1300
+ }), We(u, (b) => {
1301
+ const g = new RegExp(`(^| )${b.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
1302
+ m = m.replace(g, " ").replace(/ +/g, " ").trim();
1303
+ }), r({
1304
+ type: "update_props_realtime",
1305
+ payload: {
1306
+ ids: [d._id],
1307
+ props: {
1308
+ [o.prop]: `${lt}${m},${f}`
1309
+ }
1310
+ }
1311
+ });
1312
+ });
1313
+ }), Sd = () => {
1314
+ const e = Se(), t = Xe(mc);
1315
+ return X(
1316
+ (n, s) => {
1317
+ t({ blockIds: n, fullClasses: s, dispatch: e }), setTimeout(() => e({ type: "create_snapshot" }));
1318
+ },
1319
+ [e, t]
1320
+ );
1321
+ }, Bi = N((e) => {
1322
+ const t = je(e(gn)), n = e(Bs);
1323
+ if (!t || t.blockId !== ee(n, "_id", null))
1324
+ return [];
1325
+ const r = ee(n, t.prop, `${lt},`).replace(lt, "").split(",").join(" ");
1326
+ return te(ue(r.trim().split(" "), Cn), (o) => !os(o));
1327
+ }), xd = () => ne(Bi), ur = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, gc = N((e) => {
1328
+ const t = e(Ei), n = e(js), s = e(_i), r = yc(t);
1329
+ let o = te(e(Bi), { mod: n });
1330
+ return ei(n, "_") || (o = te(o, (i) => r.includes(i.mq))), o = o.sort((i, a) => ur[i.mq] - ur[a.mq]), s || (o = te(o, { dark: !1 })), o;
1331
+ }), yc = (e) => {
1332
+ let t = [];
1333
+ switch (e) {
1334
+ case "xs":
1335
+ t = ["xs"];
1336
+ break;
1337
+ case "sm":
1338
+ t = ["xs", "sm"];
1339
+ break;
1340
+ case "md":
1341
+ t = ["xs", "sm", "md"];
1342
+ break;
1343
+ case "lg":
1344
+ t = ["xs", "sm", "md", "lg"];
1345
+ break;
1346
+ case "xl":
1347
+ t = ["xs", "sm", "md", "lg", "xl"];
1348
+ break;
1349
+ case "2xl":
1350
+ t = ["xs", "sm", "md", "lg", "xl", "2xl"];
1351
+ break;
1352
+ default:
1353
+ t = ["xs"];
1354
+ break;
1355
+ }
1356
+ return t;
1357
+ }, kd = () => ne(gc), Ad = () => Y(js), ji = N(null, (e, t, { blockIds: n, props: s, dispatch: r }) => {
1358
+ r({
1359
+ type: "update_props_realtime",
1360
+ payload: { ids: n, props: s }
1361
+ });
1362
+ }), Ed = () => {
1363
+ const { createSnapshot: e } = $n(), t = Se(), n = Xe(ji);
1364
+ return X(
1365
+ (s, r) => {
1366
+ n({ blockIds: s, props: r, dispatch: t }), e();
1367
+ },
1368
+ [e, t, n]
1369
+ );
1370
+ }, Pd = () => {
1371
+ const e = Se(), t = Xe(ji);
1372
+ return X(
1373
+ (n, s) => {
1374
+ t({ blockIds: n, props: s, dispatch: e });
1375
+ },
1376
+ [e, t]
1377
+ );
1378
+ }, Ri = {
1379
+ name: "",
1380
+ props: {},
1381
+ modalProps: {},
1382
+ backdropClose: !0
1383
+ }, vc = N(Ri), Od = () => {
1384
+ const [e, t] = Y(vc), n = X(
1385
+ (r, o = {}, i = {}) => {
1386
+ t({ name: r, props: o, modalProps: i });
1387
+ },
1388
+ [t]
1389
+ ), s = X(
1390
+ (...r) => {
1391
+ ee(e, "props.onClose", () => {
1392
+ })(...r), t(Ri);
1393
+ },
1394
+ [t, e]
1395
+ );
1396
+ return {
1397
+ activeModal: e,
1398
+ openModal: n,
1399
+ closeModal: s
1400
+ };
1401
+ }, _d = () => ne(ki), bc = N(""), wc = N(null), Cd = () => Y(bc), Id = () => Y(wc), Sc = pt("selectedBreakpoints", ["XS", "MD", "XL"]), Bd = () => {
1402
+ const [e, t] = Y(Sc);
1403
+ return [e, t];
1404
+ }, xc = () => {
1405
+ const e = Xe(Un), { clear: t } = $n(), [, n] = mt(), [, s] = lc(), [, r] = mi();
1406
+ return () => {
1407
+ n([]), r([]), s(""), t(), e({ undoCount: 0, redoCount: 0 });
1408
+ };
1409
+ }, kc = N({ en: {} }), jd = () => {
1410
+ const [e, t] = Y(kc), n = X(
1411
+ (s, r, o) => {
1412
+ ut(e, `${s}.${r}`, o), t(e);
1413
+ },
1414
+ [e, t]
1415
+ );
1416
+ return [e, n];
1417
+ }, Rd = (e, t) => {
1418
+ const [n] = Y(ti);
1419
+ return ee(n, e, t);
1420
+ }, Ac = N([]), Dd = () => {
1421
+ const [e, t] = So(!1), [n, s] = Y(Ac), r = en("getUILibraryBlocks", () => []);
1422
+ return ke(() => {
1423
+ (async () => n.length > 0 || (t(!0), s(await r()), t(!1)))();
1424
+ }, []), { data: n, isLoading: e };
1425
+ }, Ec = N("en"), Pc = N("en"), Oc = N(["en"]), _c = () => Y(Ec), Md = () => Y(Pc), Ld = () => Y(Oc), Nd = (e, t) => {
1426
+ const [n] = _c(), s = `${e}${n ? `-${n}` : ""}`;
1427
+ return { content: ee(t, s, ee(t, e, "")), propKey: e };
1428
+ }, Cc = () => {
1429
+ const [e, t] = gi(), n = en("previewComponent");
1430
+ return /* @__PURE__ */ _.jsxs("div", { className: jo("fixed inset-0 z-[999] bg-background", e ? "block" : "hidden"), children: [
1431
+ /* @__PURE__ */ _.jsx(Oo, { size: "sm", className: "absolute right-0 top-0 m-4", onClick: () => t(!1), children: "Close Preview" }),
1432
+ /* @__PURE__ */ _.jsx("div", { children: n ? /* @__PURE__ */ _.jsx(Gt, { fallback: /* @__PURE__ */ _.jsx(_o, { className: "h-96 w-full" }), children: Es.createElement(n) }) : null })
1433
+ ] });
1434
+ }, Ic = () => {
1435
+ const [e, t] = mt(), [, n] = oc(), s = pc(), r = Ci(), [, o] = Oi(), { pasteBlocks: i } = fc(), { undo: a, redo: d } = $n();
1436
+ Le("esc", () => t([]), {}, [t]), Le("ctrl+c,command+c", () => n(e), {}, [e, n]), Le("ctrl+d,command+d", () => r(e), { preventDefault: !0 }, [e, r]), Le("ctrl+x,command+x", () => o(e), {}, [e, o]), Le("ctrl+v,command+v", () => e.length === 1 ? i(e[0]) : null, {}, [e, i]), Le("ctrl+z,command+z", () => a(), {}, [a]), Le("ctrl+y,command+y", () => d(), {}, [d]), Le(
1437
+ "del, backspace",
1438
+ (u) => {
1439
+ u.preventDefault(), s(e);
1440
+ },
1441
+ {},
1442
+ [e, s]
1443
+ );
1444
+ }, Bc = (e, t) => {
1445
+ const n = [];
1446
+ let s = Ae(e, { _id: t }), r = ee(s, "_parent", "");
1447
+ for (; Ps(r) && !Me(r); )
1448
+ n.push(s == null ? void 0 : s._parent), s = Ae(e, { _id: r }), r = s == null ? void 0 : s._parent;
1449
+ return be(n);
1450
+ }, Di = N([]), jc = () => {
1451
+ const [e] = mt(), t = ne(we), [, n] = Y(Di);
1452
+ ke(() => {
1453
+ let s = [];
1454
+ const r = je(e);
1455
+ Ps(r) && (s = [r, ...Bc(t, r)]), n(s);
1456
+ }, [e, t, n]);
1457
+ }, Td = () => ne(Di), Rc = $t(() => import("./SidePanels-03fa10e8.js")), Dc = $t(() => import("./Topbar-9bc8c9cf.js")), Mc = $t(() => import("./CanvasArea-25800a3e.js")), Lc = $t(() => import("./Settings-b214f859.js")), Nc = () => {
1458
+ const [e] = ba(qn), t = (n) => {
1459
+ n.preventDefault();
1460
+ };
1461
+ return Ic(), jc(), ke(() => (e !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
1462
+ window.onbeforeunload = null;
1463
+ }), [e]), /* @__PURE__ */ _.jsx("div", { className: "h-screen w-screen bg-background text-foreground", children: /* @__PURE__ */ _.jsxs(Co, { children: [
1464
+ /* @__PURE__ */ _.jsxs(
1465
+ "div",
1466
+ {
1467
+ onContextMenu: t,
1468
+ className: "flex h-screen flex-col overflow-hidden bg-background text-foreground",
1469
+ children: [
1470
+ /* @__PURE__ */ _.jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ _.jsx(Gt, { children: /* @__PURE__ */ _.jsx(Dc, {}) }) }),
1471
+ /* @__PURE__ */ _.jsxs("main", { className: "flex h-full flex-row", children: [
1472
+ /* @__PURE__ */ _.jsx("div", { className: "flex h-full w-fit border-border", children: /* @__PURE__ */ _.jsx(Gt, { children: /* @__PURE__ */ _.jsx(Rc, {}) }) }),
1473
+ /* @__PURE__ */ _.jsx("div", { className: "h-full flex-1 bg-slate-800/20", children: /* @__PURE__ */ _.jsx(Gt, { children: /* @__PURE__ */ _.jsx(Mc, {}) }) }),
1474
+ /* @__PURE__ */ _.jsx("div", { className: "flex h-full w-[280px] min-w-[280px] border-l border-border", children: /* @__PURE__ */ _.jsx(Gt, { children: /* @__PURE__ */ _.jsx(Lc, {}) }) })
1475
+ ] })
1476
+ ]
1477
+ }
1478
+ ),
1479
+ /* @__PURE__ */ _.jsx(Cc, {})
1480
+ ] }) });
1481
+ }, Tc = Bo();
1482
+ N({});
1483
+ function lr(e, t, n, s, r) {
1484
+ for (t = t.split ? t.split(".") : t, s = 0; s < t.length; s++)
1485
+ e = e ? e[t[s]] : r;
1486
+ return e === r ? n : e;
1487
+ }
1488
+ var kn = "undefined", dr = "object", Mi = "any", Li = "*", dt = "__", Rn = typeof process < "u" ? process : {};
1489
+ Rn.env && Rn.env.NODE_ENV;
1490
+ var Ee = typeof document < "u";
1491
+ Rn.versions != null && Rn.versions.node != null;
1492
+ typeof Deno < "u" && Deno.core;
1493
+ Ee && window.name === "nodejs" || typeof navigator < "u" && navigator.userAgent !== void 0 && (navigator.userAgent.includes("Node.js") || navigator.userAgent.includes("jsdom"));
1494
+ function Ni(e, t) {
1495
+ return t.charAt(0)[e]() + t.slice(1);
1496
+ }
1497
+ var Fc = Ni.bind(null, "toUpperCase"), Uc = Ni.bind(null, "toLowerCase");
1498
+ function qc(e) {
1499
+ return Ti(e) ? Fc("null") : typeof e == "object" ? zc(e) : Object.prototype.toString.call(e).slice(8, -1);
1500
+ }
1501
+ function Dn(e, t) {
1502
+ t === void 0 && (t = !0);
1503
+ var n = qc(e);
1504
+ return t ? Uc(n) : n;
1505
+ }
1506
+ function yn(e, t) {
1507
+ return typeof t === e;
1508
+ }
1509
+ var Be = yn.bind(null, "function"), bt = yn.bind(null, "string"), yt = yn.bind(null, "undefined"), $c = yn.bind(null, "boolean");
1510
+ yn.bind(null, "symbol");
1511
+ function Ti(e) {
1512
+ return e === null;
1513
+ }
1514
+ function Qc(e) {
1515
+ return Dn(e) === "number" && !isNaN(e);
1516
+ }
1517
+ function Vc(e) {
1518
+ return Dn(e) === "array";
1519
+ }
1520
+ function he(e) {
1521
+ if (!Kc(e))
1522
+ return !1;
1523
+ for (var t = e; Object.getPrototypeOf(t) !== null; )
1524
+ t = Object.getPrototypeOf(t);
1525
+ return Object.getPrototypeOf(e) === t;
1526
+ }
1527
+ function Kc(e) {
1528
+ return e && (typeof e == "object" || e !== null);
1529
+ }
1530
+ function zc(e) {
1531
+ return Be(e.constructor) ? e.constructor.name : null;
1532
+ }
1533
+ function Gc(e) {
1534
+ return e instanceof Error || bt(e.message) && e.constructor && Qc(e.constructor.stackTraceLimit);
1535
+ }
1536
+ function Fi(e, t) {
1537
+ if (typeof t != "object" || Ti(t))
1538
+ return !1;
1539
+ if (t instanceof e)
1540
+ return !0;
1541
+ var n = Dn(new e(""));
1542
+ if (Gc(t))
1543
+ for (; t; ) {
1544
+ if (Dn(t) === n)
1545
+ return !0;
1546
+ t = Object.getPrototypeOf(t);
1547
+ }
1548
+ return !1;
1549
+ }
1550
+ Fi.bind(null, TypeError);
1551
+ Fi.bind(null, SyntaxError);
1552
+ function Qn(e, t) {
1553
+ var n = e instanceof Element || e instanceof HTMLDocument;
1554
+ return n && t ? Wc(e, t) : n;
1555
+ }
1556
+ function Wc(e, t) {
1557
+ return t === void 0 && (t = ""), e && e.nodeName === t.toUpperCase();
1558
+ }
1559
+ function Vn(e) {
1560
+ var t = [].slice.call(arguments, 1);
1561
+ return function() {
1562
+ return e.apply(void 0, [].slice.call(arguments).concat(t));
1563
+ };
1564
+ }
1565
+ Vn(Qn, "form");
1566
+ Vn(Qn, "button");
1567
+ Vn(Qn, "input");
1568
+ Vn(Qn, "select");
1569
+ function fr(e) {
1570
+ try {
1571
+ return decodeURIComponent(e.replace(/\+/g, " "));
1572
+ } catch {
1573
+ return null;
1574
+ }
1575
+ }
1576
+ function Hc() {
1577
+ if (Ee) {
1578
+ var e = navigator, t = e.languages;
1579
+ return e.userLanguage || (t && t.length ? t[0] : e.language);
1580
+ }
1581
+ }
1582
+ function Jc() {
1583
+ try {
1584
+ return Intl.DateTimeFormat().resolvedOptions().timeZone;
1585
+ } catch {
1586
+ }
1587
+ }
1588
+ function Xc(e) {
1589
+ return function(t) {
1590
+ for (var n, s = /* @__PURE__ */ Object.create(null), r = /([^&=]+)=?([^&]*)/g; n = r.exec(t); ) {
1591
+ var o = fr(n[1]), i = fr(n[2]);
1592
+ o.substring(o.length - 2) === "[]" ? (s[o = o.substring(0, o.length - 2)] || (s[o] = [])).push(i) : s[o] = i === "" || i;
1593
+ }
1594
+ for (var a in s) {
1595
+ var d = a.split("[");
1596
+ d.length > 1 && (Yc(s, d.map(function(u) {
1597
+ return u.replace(/[?[\]\\ ]/g, "");
1598
+ }), s[a]), delete s[a]);
1599
+ }
1600
+ return s;
1601
+ }(function(t) {
1602
+ if (t) {
1603
+ var n = t.match(/\?(.*)/);
1604
+ return n && n[1] ? n[1].split("#")[0] : "";
1605
+ }
1606
+ return Ee && window.location.search.substring(1);
1607
+ }(e));
1608
+ }
1609
+ function Yc(e, t, n) {
1610
+ for (var s = t.length - 1, r = 0; r < s; ++r) {
1611
+ var o = t[r];
1612
+ if (o === "__proto__" || o === "constructor")
1613
+ break;
1614
+ o in e || (e[o] = {}), e = e[o];
1615
+ }
1616
+ e[t[s]] = n;
1617
+ }
1618
+ function Kn() {
1619
+ for (var e = "", t = 0, n = 4294967295 * Math.random() | 0; t++ < 36; ) {
1620
+ var s = "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx"[t - 1], r = 15 & n;
1621
+ e += s == "-" || s == "4" ? s : (s == "x" ? r : 3 & r | 8).toString(16), n = t % 8 == 0 ? 4294967295 * Math.random() | 0 : n >> 4;
1622
+ }
1623
+ return e;
1624
+ }
1625
+ var Jt = "global", Tt = dt + "global" + dt, Ft = typeof self === dr && self.self === self && self || typeof global === dr && global.global === global && global || void 0;
1626
+ function ft(e) {
1627
+ return Ft[Tt][e];
1628
+ }
1629
+ function ht(e, t) {
1630
+ return Ft[Tt][e] = t;
1631
+ }
1632
+ function Qt(e) {
1633
+ delete Ft[Tt][e];
1634
+ }
1635
+ function Vt(e, t, n) {
1636
+ var s;
1637
+ try {
1638
+ if (Ls(e)) {
1639
+ var r = window[e];
1640
+ s = r[t].bind(r);
1641
+ }
1642
+ } catch {
1643
+ }
1644
+ return s || n;
1645
+ }
1646
+ Ft[Tt] || (Ft[Tt] = {});
1647
+ var An = {};
1648
+ function Ls(e) {
1649
+ if (typeof An[e] !== kn)
1650
+ return An[e];
1651
+ try {
1652
+ var t = window[e];
1653
+ t.setItem(kn, kn), t.removeItem(kn);
1654
+ } catch {
1655
+ return An[e] = !1;
1656
+ }
1657
+ return An[e] = !0;
1658
+ }
1659
+ function q() {
1660
+ return q = Object.assign || function(e) {
1661
+ for (var t = 1; t < arguments.length; t++) {
1662
+ var n = arguments[t];
1663
+ for (var s in n)
1664
+ Object.prototype.hasOwnProperty.call(n, s) && (e[s] = n[s]);
1665
+ }
1666
+ return e;
1667
+ }, q.apply(this, arguments);
1668
+ }
1669
+ var Ue = "function", De = "undefined", Zc = "@@redux/" + Math.random().toString(36), hr = /* @__PURE__ */ function() {
1670
+ return typeof Symbol === Ue && Symbol.observable || "@@observable";
1671
+ }(), En = " != " + Ue;
1672
+ function Ui(e, t, n) {
1673
+ var s;
1674
+ if (typeof t === Ue && typeof n === De && (n = t, t = void 0), typeof n !== De) {
1675
+ if (typeof n !== Ue)
1676
+ throw new Error("enhancer" + En);
1677
+ return n(Ui)(e, t);
1678
+ }
1679
+ if (typeof e !== Ue)
1680
+ throw new Error("reducer" + En);
1681
+ var r = e, o = t, i = [], a = i, d = !1;
1682
+ function u() {
1683
+ a === i && (a = i.slice());
1684
+ }
1685
+ function f() {
1686
+ return o;
1687
+ }
1688
+ function m(g) {
1689
+ if (typeof g !== Ue)
1690
+ throw new Error("Listener" + En);
1691
+ var O = !0;
1692
+ return u(), a.push(g), function() {
1693
+ if (O) {
1694
+ O = !1, u();
1695
+ var C = a.indexOf(g);
1696
+ a.splice(C, 1);
1697
+ }
1698
+ };
1699
+ }
1700
+ function b(g) {
1701
+ if (!he(g))
1702
+ throw new Error("Act != obj");
1703
+ if (typeof g.type === De)
1704
+ throw new Error("ActType " + De);
1705
+ if (d)
1706
+ throw new Error("Dispatch in reducer");
1707
+ try {
1708
+ d = !0, o = r(o, g);
1709
+ } finally {
1710
+ d = !1;
1711
+ }
1712
+ for (var O = i = a, C = 0; C < O.length; C++)
1713
+ (0, O[C])();
1714
+ return g;
1715
+ }
1716
+ return b({ type: "@@redux/INIT" }), (s = { dispatch: b, subscribe: m, getState: f, replaceReducer: function(g) {
1717
+ if (typeof g !== Ue)
1718
+ throw new Error("next reducer" + En);
1719
+ r = g, b({ type: "@@redux/INIT" });
1720
+ } })[hr] = function() {
1721
+ var g, O = m;
1722
+ return (g = { subscribe: function(C) {
1723
+ if (typeof C != "object")
1724
+ throw new TypeError("Observer != obj");
1725
+ function y() {
1726
+ C.next && C.next(f());
1727
+ }
1728
+ return y(), { unsubscribe: O(y) };
1729
+ } })[hr] = function() {
1730
+ return this;
1731
+ }, g;
1732
+ }, s;
1733
+ }
1734
+ function eu(e, t) {
1735
+ var n = t && t.type;
1736
+ return "action " + (n && n.toString() || "?") + "reducer " + e + " returns " + De;
1737
+ }
1738
+ function Ut() {
1739
+ var e = [].slice.call(arguments);
1740
+ return e.length === 0 ? function(t) {
1741
+ return t;
1742
+ } : e.length === 1 ? e[0] : e.reduce(function(t, n) {
1743
+ return function() {
1744
+ return t(n.apply(void 0, [].slice.call(arguments)));
1745
+ };
1746
+ });
1747
+ }
1748
+ function tu() {
1749
+ var e = arguments;
1750
+ return function(t) {
1751
+ return function(n, s, r) {
1752
+ var o, i = t(n, s, r), a = i.dispatch, d = { getState: i.getState, dispatch: function(u) {
1753
+ return a(u);
1754
+ } };
1755
+ return o = [].slice.call(e).map(function(u) {
1756
+ return u(d);
1757
+ }), q({}, i, { dispatch: a = Ut.apply(void 0, o)(i.dispatch) });
1758
+ };
1759
+ };
1760
+ }
1761
+ var Je = dt + "anon_id", ct = dt + "user_id", wt = dt + "user_traits", Te = "userId", vt = "anonymousId", In = ["bootstrap", "params", "campaign", "initializeStart", "initialize", "initializeEnd", "ready", "resetStart", "reset", "resetEnd", "pageStart", "page", "pageEnd", "pageAborted", "trackStart", "track", "trackEnd", "trackAborted", "identifyStart", "identify", "identifyEnd", "identifyAborted", "userIdChanged", "registerPlugins", "enablePlugin", "disablePlugin", "online", "offline", "setItemStart", "setItem", "setItemEnd", "setItemAborted", "removeItemStart", "removeItem", "removeItemEnd", "removeItemAborted"], ds = ["name", "EVENTS", "config", "loaded"], U = In.reduce(function(e, t) {
1762
+ return e[t] = t, e;
1763
+ }, { registerPluginType: function(e) {
1764
+ return "registerPlugin:" + e;
1765
+ }, pluginReadyType: function(e) {
1766
+ return "ready:" + e;
1767
+ } }), pr = /^utm_/, mr = /^an_prop_/, gr = /^an_trait_/;
1768
+ function nu(e) {
1769
+ var t = e.storage.setItem;
1770
+ return function(n) {
1771
+ return function(s) {
1772
+ return function(r) {
1773
+ if (r.type === U.bootstrap) {
1774
+ var o = r.params, i = r.user, a = r.persistedUser, d = r.initialUser, u = a.userId === i.userId;
1775
+ a.anonymousId !== i.anonymousId && t(Je, i.anonymousId), u || t(ct, i.userId), d.traits && t(wt, q({}, u && a.traits ? a.traits : {}, d.traits));
1776
+ var f = Object.keys(r.params);
1777
+ if (f.length) {
1778
+ var m = o.an_uid, b = o.an_event, g = f.reduce(function(O, C) {
1779
+ if (C.match(pr) || C.match(/^(d|g)clid/)) {
1780
+ var y = C.replace(pr, "");
1781
+ O.campaign[y === "campaign" ? "name" : y] = o[C];
1782
+ }
1783
+ return C.match(mr) && (O.props[C.replace(mr, "")] = o[C]), C.match(gr) && (O.traits[C.replace(gr, "")] = o[C]), O;
1784
+ }, { campaign: {}, props: {}, traits: {} });
1785
+ n.dispatch(q({ type: U.params, raw: o }, g, m ? { userId: m } : {})), m && setTimeout(function() {
1786
+ return e.identify(m, g.traits);
1787
+ }, 0), b && setTimeout(function() {
1788
+ return e.track(b, g.props);
1789
+ }, 0), Object.keys(g.campaign).length && n.dispatch({ type: U.campaign, campaign: g.campaign });
1790
+ }
1791
+ }
1792
+ return s(r);
1793
+ };
1794
+ };
1795
+ };
1796
+ }
1797
+ function su(e) {
1798
+ return function(t, n) {
1799
+ if (t === void 0 && (t = {}), n === void 0 && (n = {}), n.type === U.setItemEnd) {
1800
+ if (n.key === Je)
1801
+ return q({}, t, { anonymousId: n.value });
1802
+ if (n.key === ct)
1803
+ return q({}, t, { userId: n.value });
1804
+ }
1805
+ switch (n.type) {
1806
+ case U.identify:
1807
+ return Object.assign({}, t, { userId: n.userId, traits: q({}, t.traits, n.traits) });
1808
+ case U.reset:
1809
+ return [ct, Je, wt].forEach(function(s) {
1810
+ e.removeItem(s);
1811
+ }), Object.assign({}, t, { userId: null, anonymousId: null, traits: {} });
1812
+ default:
1813
+ return t;
1814
+ }
1815
+ };
1816
+ }
1817
+ function yr(e) {
1818
+ return { userId: e.getItem(ct), anonymousId: e.getItem(Je), traits: e.getItem(wt) };
1819
+ }
1820
+ var fs = function(e) {
1821
+ return dt + "TEMP" + dt + e;
1822
+ };
1823
+ function ru(e) {
1824
+ var t = e.storage, n = t.setItem, s = t.removeItem, r = t.getItem;
1825
+ return function(o) {
1826
+ return function(i) {
1827
+ return function(a) {
1828
+ var d = a.userId, u = a.traits, f = a.options;
1829
+ if (a.type === U.reset && ([ct, wt, Je].forEach(function(g) {
1830
+ s(g);
1831
+ }), [Te, vt, "traits"].forEach(function(g) {
1832
+ Qt(fs(g));
1833
+ })), a.type === U.identify) {
1834
+ r(Je) || n(Je, Kn());
1835
+ var m = r(ct), b = r(wt) || {};
1836
+ m && m !== d && o.dispatch({ type: U.userIdChanged, old: { userId: m, traits: b }, new: { userId: d, traits: u }, options: f }), d && n(ct, d), u && n(wt, q({}, b, u));
1837
+ }
1838
+ return i(a);
1839
+ };
1840
+ };
1841
+ };
1842
+ }
1843
+ var Wt = {};
1844
+ function vr(e, t) {
1845
+ Wt[e] && Be(Wt[e]) && (Wt[e](t), delete Wt[e]);
1846
+ }
1847
+ function qi(e, t, n) {
1848
+ return new Promise(function(s, r) {
1849
+ return t() ? s(e) : n < 1 ? r(q({}, e, { queue: !0 })) : new Promise(function(o) {
1850
+ return setTimeout(o, 10);
1851
+ }).then(function(o) {
1852
+ return qi(e, t, n - 10).then(s, r);
1853
+ });
1854
+ });
1855
+ }
1856
+ function $i(e, t, n) {
1857
+ var s = t(), r = e.getState(), o = r.plugins, i = r.queue, a = r.user;
1858
+ if (!r.context.offline && i && i.actions && i.actions.length) {
1859
+ var d = i.actions.reduce(function(f, m, b) {
1860
+ return o[m.plugin].loaded ? (f.process.push(m), f.processIndex.push(b)) : (f.requeue.push(m), f.requeueIndex.push(b)), f;
1861
+ }, { processIndex: [], process: [], requeue: [], requeueIndex: [] });
1862
+ if (d.processIndex && d.processIndex.length) {
1863
+ d.processIndex.forEach(function(f) {
1864
+ var m = i.actions[f], b = m.plugin, g = m.payload.type, O = s[b][g];
1865
+ if (O && Be(O)) {
1866
+ var C = function(A, D) {
1867
+ return A === void 0 && (A = {}), D === void 0 && (D = {}), [Te, vt].reduce(function(j, x) {
1868
+ return A.hasOwnProperty(x) && D[x] && D[x] !== A[x] && (j[x] = D[x]), j;
1869
+ }, A);
1870
+ }(m.payload, a);
1871
+ O({ payload: C, config: o[b].config, instance: n });
1872
+ var y = g + ":" + b;
1873
+ e.dispatch(q({}, C, { type: y, _: { called: y, from: "queueDrain" } }));
1874
+ }
1875
+ });
1876
+ var u = i.actions.filter(function(f, m) {
1877
+ return !~d.processIndex.indexOf(m);
1878
+ });
1879
+ i.actions = u;
1880
+ }
1881
+ }
1882
+ }
1883
+ var ts = function(e) {
1884
+ var t = e.data, n = e.action, s = e.instance, r = e.state, o = e.allPlugins, i = e.allMatches, a = e.store, d = e.EVENTS;
1885
+ try {
1886
+ var u = r.plugins, f = r.context, m = n.type, b = m.match(St), g = t.exact.map(function(y) {
1887
+ return y.pluginName;
1888
+ });
1889
+ b && (g = i.during.map(function(y) {
1890
+ return y.pluginName;
1891
+ }));
1892
+ var O = function(y, A) {
1893
+ return function(D, j, x) {
1894
+ var k = j.config, F = j.name, T = F + "." + D.type;
1895
+ x && (T = x.event);
1896
+ var R = D.type.match(St) ? function(p, v, I, w, B) {
1897
+ return function(E, S) {
1898
+ var Q = w ? w.name : p, $ = S && tn(S) ? S : I;
1899
+ if (w && (!($ = S && tn(S) ? S : [p]).includes(p) || $.length !== 1))
1900
+ throw new Error("Method " + v + " can only abort " + p + " plugin. " + JSON.stringify($) + " input valid");
1901
+ return q({}, B, { abort: { reason: E, plugins: $, caller: v, _: Q } });
1902
+ };
1903
+ }(F, T, A, x, D) : function(p, v) {
1904
+ return function() {
1905
+ throw new Error(p.type + " action not cancellable. Remove abort in " + v);
1906
+ };
1907
+ }(D, T);
1908
+ return { payload: iu(D), instance: y, config: k || {}, abort: R };
1909
+ };
1910
+ }(s, g), C = t.exact.reduce(function(y, A) {
1911
+ var D = A.pluginName, j = A.methodName, x = !1;
1912
+ return j.match(/^initialize/) || j.match(/^reset/) || (x = !u[D].loaded), f.offline && j.match(/^(page|track|identify)/) && (x = !0), y["" + D] = x, y;
1913
+ }, {});
1914
+ return Promise.resolve(t.exact.reduce(function(y, A, D) {
1915
+ try {
1916
+ var j = A.pluginName;
1917
+ return Promise.resolve(y).then(function(x) {
1918
+ function k() {
1919
+ return Promise.resolve(x);
1920
+ }
1921
+ var F = function() {
1922
+ if (t.namespaced && t.namespaced[j])
1923
+ return Promise.resolve(t.namespaced[j].reduce(function(T, R, p) {
1924
+ try {
1925
+ return Promise.resolve(T).then(function(v) {
1926
+ return R.method && Be(R.method) ? (function(E, S) {
1927
+ var Q = Er(E);
1928
+ if (Q && Q.name === S) {
1929
+ var $ = Er(Q.method);
1930
+ throw new Error([S + " plugin is calling method " + E, "Plugins cant call self", "Use " + Q.method + " " + ($ ? "or " + $.method : "") + " in " + S + " plugin insteadof " + E].join(`
1931
+ `));
1932
+ }
1933
+ }(R.methodName, R.pluginName), Promise.resolve(R.method({ payload: v, instance: s, abort: (I = v, w = j, B = R.pluginName, function(E, S) {
1934
+ return q({}, I, { abort: { reason: E, plugins: S || [w], caller: m, from: B || w } });
1935
+ }), config: Sr(R.pluginName, u, o), plugins: u })).then(function(E) {
1936
+ var S = he(E) ? E : {};
1937
+ return Promise.resolve(q({}, v, S));
1938
+ })) : v;
1939
+ var I, w, B;
1940
+ });
1941
+ } catch (v) {
1942
+ return Promise.reject(v);
1943
+ }
1944
+ }, Promise.resolve(n))).then(function(T) {
1945
+ x[j] = T;
1946
+ });
1947
+ x[j] = n;
1948
+ }();
1949
+ return F && F.then ? F.then(k) : k();
1950
+ });
1951
+ } catch (x) {
1952
+ return Promise.reject(x);
1953
+ }
1954
+ }, Promise.resolve({}))).then(function(y) {
1955
+ return Promise.resolve(t.exact.reduce(function(A, D, j) {
1956
+ try {
1957
+ var x = t.exact.length === j + 1, k = D.pluginName, F = o[k];
1958
+ return Promise.resolve(A).then(function(T) {
1959
+ var R = y[k] ? y[k] : {};
1960
+ if (b && (R = T), ss(R, k))
1961
+ return ns({ data: R, method: m, instance: s, pluginName: k, store: a }), Promise.resolve(T);
1962
+ if (ss(T, k))
1963
+ return x && ns({ data: T, method: m, instance: s, store: a }), Promise.resolve(T);
1964
+ if (C.hasOwnProperty(k) && C[k] === !0)
1965
+ return a.dispatch({ type: "queue", plugin: k, payload: R, _: { called: "queue", from: "queueMechanism" } }), Promise.resolve(T);
1966
+ var p = O(y[k], o[k]);
1967
+ return Promise.resolve(F[m]({ abort: p.abort, payload: R, instance: s, config: Sr(k, u, o), plugins: u })).then(function(v) {
1968
+ var I = he(v) ? v : {}, w = q({}, T, I), B = y[k];
1969
+ if (ss(B, k))
1970
+ ns({ data: B, method: m, instance: s, pluginName: k, store: a });
1971
+ else {
1972
+ var E = m + ":" + k;
1973
+ (E.match(/:/g) || []).length < 2 && !m.match(br) && !m.match(wr) && s.dispatch(q({}, b ? w : R, { type: E, _: { called: E, from: "submethod" } }));
1974
+ }
1975
+ return Promise.resolve(w);
1976
+ });
1977
+ });
1978
+ } catch (T) {
1979
+ return Promise.reject(T);
1980
+ }
1981
+ }, Promise.resolve(n))).then(function(A) {
1982
+ if (!(m.match(St) || m.match(/^registerPlugin/) || m.match(wr) || m.match(br) || m.match(/^params/) || m.match(/^userIdChanged/))) {
1983
+ if (d.plugins.includes(m), A._ && A._.originalAction === m)
1984
+ return A;
1985
+ var D = q({}, A, { _: { originalAction: A.type, called: A.type, from: "engineEnd" } });
1986
+ Qi(A, t.exact.length) && !m.match(/End$/) && (D = q({}, D, { type: A.type + "Aborted" })), a.dispatch(D);
1987
+ }
1988
+ return A;
1989
+ });
1990
+ });
1991
+ } catch (y) {
1992
+ return Promise.reject(y);
1993
+ }
1994
+ }, St = /Start$/, br = /^bootstrap/, wr = /^ready/;
1995
+ function ns(e) {
1996
+ var t = e.pluginName, n = e.method + "Aborted" + (t ? ":" + t : "");
1997
+ e.store.dispatch(q({}, e.data, { type: n, _: { called: n, from: "abort" } }));
1998
+ }
1999
+ function Sr(e, t, n) {
2000
+ var s = t[e] || n[e];
2001
+ return s && s.config ? s.config : {};
2002
+ }
2003
+ function xr(e, t) {
2004
+ return t.reduce(function(n, s) {
2005
+ return s[e] ? n.concat({ methodName: e, pluginName: s.name, method: s[e] }) : n;
2006
+ }, []);
2007
+ }
2008
+ function kr(e, t) {
2009
+ var n = e.replace(St, ""), s = t ? ":" + t : "";
2010
+ return ["" + e + s, "" + n + s, n + "End" + s];
2011
+ }
2012
+ function ss(e, t) {
2013
+ var n = e.abort;
2014
+ return !!n && (n === !0 || Ar(n, t) || n && Ar(n.plugins, t));
2015
+ }
2016
+ function Qi(e, t) {
2017
+ var n = e.abort;
2018
+ if (!n)
2019
+ return !1;
2020
+ if (n === !0 || bt(n))
2021
+ return !0;
2022
+ var s = n.plugins;
2023
+ return tn(n) && n.length === t || tn(s) && s.length === t;
2024
+ }
2025
+ function tn(e) {
2026
+ return Array.isArray(e);
2027
+ }
2028
+ function Ar(e, t) {
2029
+ return !(!e || !tn(e)) && e.includes(t);
2030
+ }
2031
+ function Er(e) {
2032
+ var t = e.match(/(.*):(.*)/);
2033
+ return !!t && { method: t[1], name: t[2] };
2034
+ }
2035
+ function iu(e) {
2036
+ return Object.keys(e).reduce(function(t, n) {
2037
+ return n === "type" || (t[n] = he(e[n]) ? Object.assign({}, e[n]) : e[n]), t;
2038
+ }, {});
2039
+ }
2040
+ function ou(e, t, n) {
2041
+ var s = {};
2042
+ return function(r) {
2043
+ return function(o) {
2044
+ return function(i) {
2045
+ try {
2046
+ var a, d = function(x) {
2047
+ return a ? x : o(m);
2048
+ }, u = i.type, f = i.plugins, m = i;
2049
+ if (i.abort)
2050
+ return Promise.resolve(o(i));
2051
+ if (u === U.enablePlugin && r.dispatch({ type: U.initializeStart, plugins: f, disabled: [], fromEnable: !0, meta: i.meta }), u === U.disablePlugin && setTimeout(function() {
2052
+ return vr(i.meta.rid, { payload: i });
2053
+ }, 0), u === U.initializeEnd) {
2054
+ var b = t(), g = Object.keys(b), O = g.filter(function(x) {
2055
+ return f.includes(x);
2056
+ }).map(function(x) {
2057
+ return b[x];
2058
+ }), C = [], y = [], A = i.disabled, D = O.map(function(x) {
2059
+ var k = x.loaded, F = x.name, T = x.config;
2060
+ return qi(x, function() {
2061
+ return k({ config: T });
2062
+ }, 1e4).then(function(R) {
2063
+ return s[F] || (r.dispatch({ type: U.pluginReadyType(F), name: F, events: Object.keys(x).filter(function(p) {
2064
+ return !ds.includes(p);
2065
+ }) }), s[F] = !0), C = C.concat(F), x;
2066
+ }).catch(function(R) {
2067
+ if (R instanceof Error)
2068
+ throw new Error(R);
2069
+ return y = y.concat(R.name), R;
2070
+ });
2071
+ });
2072
+ Promise.all(D).then(function(x) {
2073
+ var k = { plugins: C, failed: y, disabled: A };
2074
+ setTimeout(function() {
2075
+ g.length === D.length + A.length && r.dispatch(q({}, { type: U.ready }, k));
2076
+ }, 0);
2077
+ });
2078
+ }
2079
+ var j = function() {
2080
+ if (u !== U.bootstrap)
2081
+ return /^ready:([^:]*)$/.test(u) && setTimeout(function() {
2082
+ return $i(r, t, e);
2083
+ }, 0), Promise.resolve(function(x, k, F, T, R) {
2084
+ try {
2085
+ var p = Be(k) ? k() : k, v = x.type, I = v.replace(St, "");
2086
+ if (x._ && x._.called)
2087
+ return Promise.resolve(x);
2088
+ var w = F.getState(), B = (Q = p, ($ = w.plugins) === void 0 && ($ = {}), (G = x.options) === void 0 && (G = {}), Object.keys(Q).filter(function(l) {
2089
+ var h = G.plugins || {};
2090
+ return $c(h[l]) ? h[l] : h.all !== !1 && (!$[l] || $[l].enabled !== !1);
2091
+ }).map(function(l) {
2092
+ return Q[l];
2093
+ }));
2094
+ v === U.initializeStart && x.fromEnable && (B = Object.keys(w.plugins).filter(function(l) {
2095
+ var h = w.plugins[l];
2096
+ return x.plugins.includes(l) && !h.initialized;
2097
+ }).map(function(l) {
2098
+ return p[l];
2099
+ }));
2100
+ var E = B.map(function(l) {
2101
+ return l.name;
2102
+ }), S = function(l, h, M) {
2103
+ var V = kr(l).map(function(z) {
2104
+ return xr(z, h);
2105
+ });
2106
+ return h.reduce(function(z, W) {
2107
+ var oe = W.name, J = kr(l, oe).map(function(Kt) {
2108
+ return xr(Kt, h);
2109
+ }), se = J[0], H = J[1], Pe = J[2];
2110
+ return se.length && (z.beforeNS[oe] = se), H.length && (z.duringNS[oe] = H), Pe.length && (z.afterNS[oe] = Pe), z;
2111
+ }, { before: V[0], beforeNS: {}, during: V[1], duringNS: {}, after: V[2], afterNS: {} });
2112
+ }(v, B);
2113
+ return Promise.resolve(ts({ action: x, data: { exact: S.before, namespaced: S.beforeNS }, state: w, allPlugins: p, allMatches: S, instance: F, store: T, EVENTS: R })).then(function(l) {
2114
+ function h() {
2115
+ var z = function() {
2116
+ if (v.match(St))
2117
+ return Promise.resolve(ts({ action: q({}, M, { type: I + "End" }), data: { exact: S.after, namespaced: S.afterNS }, state: w, allPlugins: p, allMatches: S, instance: F, store: T, EVENTS: R })).then(function(W) {
2118
+ W.meta && W.meta.hasCallback && vr(W.meta.rid, { payload: W });
2119
+ });
2120
+ }();
2121
+ return z && z.then ? z.then(function() {
2122
+ return l;
2123
+ }) : l;
2124
+ }
2125
+ if (Qi(l, E.length))
2126
+ return l;
2127
+ var M, V = function() {
2128
+ if (v !== I)
2129
+ return Promise.resolve(ts({ action: q({}, l, { type: I }), data: { exact: S.during, namespaced: S.duringNS }, state: w, allPlugins: p, allMatches: S, instance: F, store: T, EVENTS: R })).then(function(z) {
2130
+ M = z;
2131
+ });
2132
+ M = l;
2133
+ }();
2134
+ return V && V.then ? V.then(h) : h();
2135
+ });
2136
+ } catch (l) {
2137
+ return Promise.reject(l);
2138
+ }
2139
+ var Q, $, G;
2140
+ }(i, t, e, r, n)).then(function(x) {
2141
+ return a = 1, o(x);
2142
+ });
2143
+ }();
2144
+ return Promise.resolve(j && j.then ? j.then(d) : d(j));
2145
+ } catch (x) {
2146
+ return Promise.reject(x);
2147
+ }
2148
+ };
2149
+ };
2150
+ };
2151
+ }
2152
+ function au(e) {
2153
+ return function(t) {
2154
+ return function(n) {
2155
+ return function(s) {
2156
+ var r = s.type, o = s.key, i = s.value, a = s.options;
2157
+ if (r === U.setItem || r === U.removeItem) {
2158
+ if (s.abort)
2159
+ return n(s);
2160
+ r === U.setItem ? e.setItem(o, i, a) : e.removeItem(o, a);
2161
+ }
2162
+ return n(s);
2163
+ };
2164
+ };
2165
+ };
2166
+ }
2167
+ var cu = function() {
2168
+ var e = this;
2169
+ this.before = [], this.after = [], this.addMiddleware = function(t, n) {
2170
+ e[n] = e[n].concat(t);
2171
+ }, this.removeMiddleware = function(t, n) {
2172
+ var s = e[n].findIndex(function(r) {
2173
+ return r === t;
2174
+ });
2175
+ s !== -1 && (e[n] = [].concat(e[n].slice(0, s), e[n].slice(s + 1)));
2176
+ }, this.dynamicMiddlewares = function(t) {
2177
+ return function(n) {
2178
+ return function(s) {
2179
+ return function(r) {
2180
+ var o = { getState: n.getState, dispatch: function(a) {
2181
+ return n.dispatch(a);
2182
+ } }, i = e[t].map(function(a) {
2183
+ return a(o);
2184
+ });
2185
+ return Ut.apply(void 0, i)(s)(r);
2186
+ };
2187
+ };
2188
+ };
2189
+ };
2190
+ };
2191
+ function uu(e) {
2192
+ return function(t, n) {
2193
+ t === void 0 && (t = {});
2194
+ var s = {};
2195
+ if (n.type === "initialize:aborted")
2196
+ return t;
2197
+ if (/^registerPlugin:([^:]*)$/.test(n.type)) {
2198
+ var r = Pr(n.type, "registerPlugin"), o = e()[r];
2199
+ if (!o || !r)
2200
+ return t;
2201
+ var i = n.enabled, a = o.config;
2202
+ return s[r] = { enabled: i, initialized: !!i && !o.initialize, loaded: !!i && !!o.loaded({ config: a }), config: a }, q({}, t, s);
2203
+ }
2204
+ if (/^initialize:([^:]*)$/.test(n.type)) {
2205
+ var d = Pr(n.type, U.initialize), u = e()[d];
2206
+ return u && d ? (s[d] = q({}, t[d], { initialized: !0, loaded: !!u.loaded({ config: u.config }) }), q({}, t, s)) : t;
2207
+ }
2208
+ if (/^ready:([^:]*)$/.test(n.type))
2209
+ return s[n.name] = q({}, t[n.name], { loaded: !0 }), q({}, t, s);
2210
+ switch (n.type) {
2211
+ case U.disablePlugin:
2212
+ return q({}, t, Or(n.plugins, !1, t));
2213
+ case U.enablePlugin:
2214
+ return q({}, t, Or(n.plugins, !0, t));
2215
+ default:
2216
+ return t;
2217
+ }
2218
+ };
2219
+ }
2220
+ function Pr(e, t) {
2221
+ return e.substring(t.length + 1, e.length);
2222
+ }
2223
+ function Or(e, t, n) {
2224
+ return e.reduce(function(s, r) {
2225
+ return s[r] = q({}, n[r], { enabled: t }), s;
2226
+ }, n);
2227
+ }
2228
+ function Vi(e) {
2229
+ try {
2230
+ return JSON.parse(JSON.stringify(e));
2231
+ } catch {
2232
+ }
2233
+ return e;
2234
+ }
2235
+ var lu = { last: {}, history: [] };
2236
+ function du(e, t) {
2237
+ e === void 0 && (e = lu);
2238
+ var n = t.options, s = t.meta;
2239
+ if (t.type === U.track) {
2240
+ var r = Vi(q({ event: t.event, properties: t.properties }, Object.keys(n).length && { options: n }, { meta: s }));
2241
+ return q({}, e, { last: r, history: e.history.concat(r) });
2242
+ }
2243
+ return e;
2244
+ }
2245
+ var fu = { actions: [] };
2246
+ function hu(e, t) {
2247
+ e === void 0 && (e = fu);
2248
+ var n = t.payload;
2249
+ switch (t.type) {
2250
+ case "queue":
2251
+ var s;
2252
+ return s = n && n.type && n.type === U.identify ? [t].concat(e.actions) : e.actions.concat(t), q({}, e, { actions: s });
2253
+ case "dequeue":
2254
+ return [];
2255
+ default:
2256
+ return e;
2257
+ }
2258
+ }
2259
+ var Ki = /#.*$/;
2260
+ function pu(e) {
2261
+ var t = /(http[s]?:\/\/)?([^\/\s]+\/)(.*)/g.exec(e);
2262
+ return "/" + (t && t[3] ? t[3].split("?")[0].replace(Ki, "") : "");
2263
+ }
2264
+ var zi, Gi, Wi, Hi, mu = function(e) {
2265
+ if (e === void 0 && (e = {}), !Ee)
2266
+ return e;
2267
+ var t = document, n = t.title, s = t.referrer, r = window, o = r.location, i = r.innerWidth, a = r.innerHeight, d = o.hash, u = o.search, f = function(b) {
2268
+ var g = function() {
2269
+ if (Ee) {
2270
+ for (var O, C = document.getElementsByTagName("link"), y = 0; O = C[y]; y++)
2271
+ if (O.getAttribute("rel") === "canonical")
2272
+ return O.getAttribute("href");
2273
+ }
2274
+ }();
2275
+ return g ? g.match(/\?/) ? g : g + b : window.location.href.replace(Ki, "");
2276
+ }(u), m = { title: n, url: f, path: pu(f), hash: d, search: u, width: i, height: a };
2277
+ return s && s !== "" && (m.referrer = s), q({}, m, e);
2278
+ }, gu = { last: {}, history: [] };
2279
+ function yu(e, t) {
2280
+ e === void 0 && (e = gu);
2281
+ var n = t.options;
2282
+ if (t.type === U.page) {
2283
+ var s = Vi(q({ properties: t.properties, meta: t.meta }, Object.keys(n).length && { options: n }));
2284
+ return q({}, e, { last: s, history: e.history.concat(s) });
2285
+ }
2286
+ return e;
2287
+ }
2288
+ zi = function() {
2289
+ if (!Ee)
2290
+ return !1;
2291
+ var e = navigator.appVersion;
2292
+ return ~e.indexOf("Win") ? "Windows" : ~e.indexOf("Mac") ? "MacOS" : ~e.indexOf("X11") ? "UNIX" : ~e.indexOf("Linux") ? "Linux" : "Unknown OS";
2293
+ }(), Gi = Ee ? document.referrer : null, Wi = Hc(), Hi = Jc();
2294
+ var _r = { initialized: !1, sessionId: Kn(), app: null, version: null, debug: !1, offline: !!Ee && !navigator.onLine, os: { name: zi }, userAgent: Ee ? navigator.userAgent : "node", library: { name: "analytics", version: "0.12.5" }, timezone: Hi, locale: Wi, campaign: {}, referrer: Gi };
2295
+ function vu(e, t) {
2296
+ e === void 0 && (e = _r);
2297
+ var n = e.initialized, s = t.campaign;
2298
+ switch (t.type) {
2299
+ case U.campaign:
2300
+ return q({}, e, { campaign: s });
2301
+ case U.offline:
2302
+ return q({}, e, { offline: !0 });
2303
+ case U.online:
2304
+ return q({}, e, { offline: !1 });
2305
+ default:
2306
+ return n ? e : q({}, _r, e, { initialized: !0 });
2307
+ }
2308
+ }
2309
+ var bu = ["plugins", "reducers", "storage"];
2310
+ function wu(e, t, n) {
2311
+ if (Ee) {
2312
+ var s = window[(n ? "add" : "remove") + "EventListener"];
2313
+ e.split(" ").forEach(function(r) {
2314
+ s(r, t);
2315
+ });
2316
+ }
2317
+ }
2318
+ function Su(e) {
2319
+ var t = wu.bind(null, "online offline", function(n) {
2320
+ return Promise.resolve(!navigator.onLine).then(e);
2321
+ });
2322
+ return t(!0), function(n) {
2323
+ return t(!1);
2324
+ };
2325
+ }
2326
+ function Ji() {
2327
+ return ht("analytics", []), function(e) {
2328
+ return function(t, n, s) {
2329
+ var r = e(t, n, s), o = r.dispatch;
2330
+ return Object.assign(r, { dispatch: function(i) {
2331
+ return Ft[Tt].analytics.push(i.action || i), o(i);
2332
+ } });
2333
+ };
2334
+ };
2335
+ }
2336
+ function Cr(e) {
2337
+ return function() {
2338
+ return Ut(Ut.apply(null, arguments), Ji());
2339
+ };
2340
+ }
2341
+ function rs(e) {
2342
+ return e ? Vc(e) ? e : [e] : [];
2343
+ }
2344
+ function Ir(e, t, n) {
2345
+ e === void 0 && (e = {});
2346
+ var s, r, o = Kn();
2347
+ return t && (Wt[o] = (s = t, r = function(i) {
2348
+ for (var a, d = i || Array.prototype.slice.call(arguments), u = 0; u < d.length; u++)
2349
+ if (Be(d[u])) {
2350
+ a = d[u];
2351
+ break;
2352
+ }
2353
+ return a;
2354
+ }(n), function(i) {
2355
+ r && r(i), s(i);
2356
+ })), q({}, e, { rid: o, ts: (/* @__PURE__ */ new Date()).getTime() }, t ? { hasCallback: !0 } : {});
2357
+ }
2358
+ function xu(e) {
2359
+ e === void 0 && (e = {});
2360
+ var t = e.reducers || {}, n = e.initialUser || {}, s = (e.plugins || []).reduce(function(l, h) {
2361
+ if (Be(h))
2362
+ return l.middlewares = l.middlewares.concat(h), l;
2363
+ if (h.NAMESPACE && (h.name = h.NAMESPACE), !h.name)
2364
+ throw new Error("https://lytics.dev/errors/1");
2365
+ h.config || (h.config = {});
2366
+ var M = h.EVENTS ? Object.keys(h.EVENTS).map(function(W) {
2367
+ return h.EVENTS[W];
2368
+ }) : [];
2369
+ l.pluginEnabled[h.name] = !(h.enabled === !1 || h.config.enabled === !1), delete h.enabled, h.methods && (l.methods[h.name] = Object.keys(h.methods).reduce(function(W, oe) {
2370
+ var J;
2371
+ return W[oe] = (J = h.methods[oe], function() {
2372
+ for (var se = Array.prototype.slice.call(arguments), H = new Array(J.length), Pe = 0; Pe < se.length; Pe++)
2373
+ H[Pe] = se[Pe];
2374
+ return H[H.length] = k, J.apply({ instance: k }, H);
2375
+ }), W;
2376
+ }, {}), delete h.methods);
2377
+ var V = Object.keys(h).concat(M), z = new Set(l.events.concat(V));
2378
+ if (l.events = Array.from(z), l.pluginsArray = l.pluginsArray.concat(h), l.plugins[h.name])
2379
+ throw new Error(h.name + "AlreadyLoaded");
2380
+ return l.plugins[h.name] = h, l.plugins[h.name].loaded || (l.plugins[h.name].loaded = function() {
2381
+ return !0;
2382
+ }), l;
2383
+ }, { plugins: {}, pluginEnabled: {}, methods: {}, pluginsArray: [], middlewares: [], events: [] }), r = e.storage ? e.storage : { getItem: ft, setItem: ht, removeItem: Qt }, o = function(l) {
2384
+ return function(h, M, V) {
2385
+ return M.getState("user")[h] || (V && he(V) && V[h] ? V[h] : yr(l)[h] || ft(fs(h)) || null);
2386
+ };
2387
+ }(r), i = s.plugins, a = s.events.filter(function(l) {
2388
+ return !ds.includes(l);
2389
+ }).sort(), d = new Set(a.concat(In).filter(function(l) {
2390
+ return !ds.includes(l);
2391
+ })), u = Array.from(d).sort(), f = function() {
2392
+ return i;
2393
+ }, m = new cu(), b = m.addMiddleware, g = m.removeMiddleware, O = m.dynamicMiddlewares, C = function() {
2394
+ throw new Error("Abort disabled inListener");
2395
+ }, y = Xc(), A = yr(r), D = q({}, A, n, y.an_uid ? { userId: y.an_uid } : {}, y.an_aid ? { anonymousId: y.an_aid } : {});
2396
+ D.anonymousId || (D.anonymousId = Kn());
2397
+ var j = q({ enable: function(l, h) {
2398
+ return new Promise(function(M) {
2399
+ S.dispatch({ type: U.enablePlugin, plugins: rs(l), _: { originalAction: U.enablePlugin } }, M, [h]);
2400
+ });
2401
+ }, disable: function(l, h) {
2402
+ return new Promise(function(M) {
2403
+ S.dispatch({ type: U.disablePlugin, plugins: rs(l), _: { originalAction: U.disablePlugin } }, M, [h]);
2404
+ });
2405
+ } }, s.methods), x = !1, k = { identify: function(l, h, M, V) {
2406
+ try {
2407
+ var z = bt(l) ? l : null, W = he(l) ? l : h, oe = M || {}, J = k.user();
2408
+ ht(fs(Te), z);
2409
+ var se = z || W.userId || o(Te, k, W);
2410
+ return Promise.resolve(new Promise(function(H) {
2411
+ S.dispatch(q({ type: U.identifyStart, userId: se, traits: W || {}, options: oe, anonymousId: J.anonymousId }, J.id && J.id !== z && { previousId: J.id }), H, [h, M, V]);
2412
+ }));
2413
+ } catch (H) {
2414
+ return Promise.reject(H);
2415
+ }
2416
+ }, track: function(l, h, M, V) {
2417
+ try {
2418
+ var z = he(l) ? l.event : l;
2419
+ if (!z || !bt(z))
2420
+ throw new Error("EventMissing");
2421
+ var W = he(l) ? l : h || {}, oe = he(M) ? M : {};
2422
+ return Promise.resolve(new Promise(function(J) {
2423
+ S.dispatch({ type: U.trackStart, event: z, properties: W, options: oe, userId: o(Te, k, h), anonymousId: o(vt, k, h) }, J, [h, M, V]);
2424
+ }));
2425
+ } catch (J) {
2426
+ return Promise.reject(J);
2427
+ }
2428
+ }, page: function(l, h, M) {
2429
+ try {
2430
+ var V = he(l) ? l : {}, z = he(h) ? h : {};
2431
+ return Promise.resolve(new Promise(function(W) {
2432
+ S.dispatch({ type: U.pageStart, properties: mu(V), options: z, userId: o(Te, k, V), anonymousId: o(vt, k, V) }, W, [l, h, M]);
2433
+ }));
2434
+ } catch (W) {
2435
+ return Promise.reject(W);
2436
+ }
2437
+ }, user: function(l) {
2438
+ if (l === Te || l === "id")
2439
+ return o(Te, k);
2440
+ if (l === vt || l === "anonId")
2441
+ return o(vt, k);
2442
+ var h = k.getState("user");
2443
+ return l ? lr(h, l) : h;
2444
+ }, reset: function(l) {
2445
+ return new Promise(function(h) {
2446
+ S.dispatch({ type: U.resetStart }, h, l);
2447
+ });
2448
+ }, ready: function(l) {
2449
+ return x && l({ plugins: j, instance: k }), k.on(U.ready, function(h) {
2450
+ l(h), x = !0;
2451
+ });
2452
+ }, on: function(l, h) {
2453
+ if (!l || !Be(h))
2454
+ return !1;
2455
+ if (l === U.bootstrap)
2456
+ throw new Error(".on disabled for " + l);
2457
+ var M = /Start$|Start:/;
2458
+ if (l === "*") {
2459
+ var V = function(J) {
2460
+ return function(se) {
2461
+ return function(H) {
2462
+ return H.type.match(M) && h({ payload: H, instance: k, plugins: i }), se(H);
2463
+ };
2464
+ };
2465
+ }, z = function(J) {
2466
+ return function(se) {
2467
+ return function(H) {
2468
+ return H.type.match(M) || h({ payload: H, instance: k, plugins: i }), se(H);
2469
+ };
2470
+ };
2471
+ };
2472
+ return b(V, Pn), b(z, On), function() {
2473
+ g(V, Pn), g(z, On);
2474
+ };
2475
+ }
2476
+ var W = l.match(M) ? Pn : On, oe = function(J) {
2477
+ return function(se) {
2478
+ return function(H) {
2479
+ return H.type === l && h({ payload: H, instance: k, plugins: i, abort: C }), se(H);
2480
+ };
2481
+ };
2482
+ };
2483
+ return b(oe, W), function() {
2484
+ return g(oe, W);
2485
+ };
2486
+ }, once: function(l, h) {
2487
+ if (!l || !Be(h))
2488
+ return !1;
2489
+ if (l === U.bootstrap)
2490
+ throw new Error(".once disabled for " + l);
2491
+ var M = k.on(l, function(V) {
2492
+ h({ payload: V.payload, instance: k, plugins: i, abort: C }), M();
2493
+ });
2494
+ return M;
2495
+ }, getState: function(l) {
2496
+ var h = S.getState();
2497
+ return l ? lr(h, l) : Object.assign({}, h);
2498
+ }, dispatch: function(l) {
2499
+ var h = bt(l) ? { type: l } : l;
2500
+ if (In.includes(h.type))
2501
+ throw new Error("reserved action " + h.type);
2502
+ var M = q({}, h, { _: q({ originalAction: h.type }, l._ || {}) });
2503
+ S.dispatch(M);
2504
+ }, enablePlugin: j.enable, disablePlugin: j.disable, plugins: j, storage: { getItem: r.getItem, setItem: function(l, h, M) {
2505
+ S.dispatch({ type: U.setItemStart, key: l, value: h, options: M });
2506
+ }, removeItem: function(l, h) {
2507
+ S.dispatch({ type: U.removeItemStart, key: l, options: h });
2508
+ } }, setAnonymousId: function(l, h) {
2509
+ k.storage.setItem(Je, l, h);
2510
+ }, events: { core: In, plugins: a } }, F = s.middlewares.concat([function(l) {
2511
+ return function(h) {
2512
+ return function(M) {
2513
+ return M.meta || (M.meta = Ir()), h(M);
2514
+ };
2515
+ };
2516
+ }, O(Pn), ou(k, f, { all: u, plugins: a }), au(r), nu(k), ru(k), O(On)]), T = { context: vu, user: su(r), page: yu, track: du, plugins: uu(f), queue: hu }, R = Ut, p = Ut;
2517
+ if (Ee && e.debug) {
2518
+ var v = window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__;
2519
+ v && (R = v({ trace: !0, traceLimit: 25 })), p = function() {
2520
+ return arguments.length === 0 ? Ji() : he(typeof arguments[0]) ? Cr() : Cr().apply(null, arguments);
2521
+ };
2522
+ }
2523
+ var I, w = function(l) {
2524
+ return Object.keys(l).reduce(function(h, M) {
2525
+ return bu.includes(M) || (h[M] = l[M]), h;
2526
+ }, {});
2527
+ }(e), B = s.pluginsArray.reduce(function(l, h) {
2528
+ var M = h.name, V = h.config, z = h.loaded, W = s.pluginEnabled[M];
2529
+ return l[M] = { enabled: W, initialized: !!W && !h.initialize, loaded: !!z({ config: V }), config: V }, l;
2530
+ }, {}), E = { context: w, user: D, plugins: B }, S = Ui(function(l) {
2531
+ for (var h = Object.keys(l), M = {}, V = 0; V < h.length; V++) {
2532
+ var z = h[V];
2533
+ typeof l[z] === Ue && (M[z] = l[z]);
2534
+ }
2535
+ var W, oe = Object.keys(M);
2536
+ try {
2537
+ (function(J) {
2538
+ Object.keys(J).forEach(function(se) {
2539
+ var H = J[se];
2540
+ if (typeof H(void 0, { type: "@@redux/INIT" }) === De || typeof H(void 0, { type: Zc }) === De)
2541
+ throw new Error("reducer " + se + " " + De);
2542
+ });
2543
+ })(M);
2544
+ } catch (J) {
2545
+ W = J;
2546
+ }
2547
+ return function(J, se) {
2548
+ if (J === void 0 && (J = {}), W)
2549
+ throw W;
2550
+ for (var H = !1, Pe = {}, Kt = 0; Kt < oe.length; Kt++) {
2551
+ var bn = oe[Kt], zs = J[bn], Xn = (0, M[bn])(zs, se);
2552
+ if (typeof Xn === De) {
2553
+ var fo = eu(bn, se);
2554
+ throw new Error(fo);
2555
+ }
2556
+ Pe[bn] = Xn, H = H || Xn !== zs;
2557
+ }
2558
+ return H ? Pe : J;
2559
+ };
2560
+ }(q({}, T, t)), E, p(R(tu.apply(void 0, F))));
2561
+ S.dispatch = (I = S.dispatch, function(l, h, M) {
2562
+ var V = q({}, l, { meta: Ir(l.meta, h, rs(M)) });
2563
+ return I.apply(null, [V]);
2564
+ });
2565
+ var Q = Object.keys(i);
2566
+ S.dispatch({ type: U.bootstrap, plugins: Q, config: w, params: y, user: D, initialUser: n, persistedUser: A });
2567
+ var $ = Q.filter(function(l) {
2568
+ return s.pluginEnabled[l];
2569
+ }), G = Q.filter(function(l) {
2570
+ return !s.pluginEnabled[l];
2571
+ });
2572
+ return S.dispatch({ type: U.registerPlugins, plugins: Q, enabled: s.pluginEnabled }), s.pluginsArray.map(function(l, h) {
2573
+ var M = l.bootstrap, V = l.config, z = l.name;
2574
+ M && Be(M) && M({ instance: k, config: V, payload: l }), S.dispatch({ type: U.registerPluginType(z), name: z, enabled: s.pluginEnabled[z], plugin: l }), s.pluginsArray.length === h + 1 && S.dispatch({ type: U.initializeStart, plugins: $, disabled: G });
2575
+ }), Su(function(l) {
2576
+ S.dispatch({ type: l ? U.offline : U.online });
2577
+ }), function(l, h, M) {
2578
+ setInterval(function() {
2579
+ return $i(l, h, M);
2580
+ }, 3e3);
2581
+ }(S, f, k), k;
2582
+ }
2583
+ var Pn = "before", On = "after", Xt = "cookie", Ye = Zi(), Xi = zn, ku = zn;
2584
+ function Yi(e) {
2585
+ return Ye ? zn(e, "", -1) : Qt(e);
2586
+ }
2587
+ function Zi() {
2588
+ if (Ye !== void 0)
2589
+ return Ye;
2590
+ var e = "cookiecookie";
2591
+ try {
2592
+ zn(e, e), Ye = document.cookie.indexOf(e) !== -1, Yi(e);
2593
+ } catch {
2594
+ Ye = !1;
2595
+ }
2596
+ return Ye;
2597
+ }
2598
+ function zn(e, t, n, s, r, o) {
2599
+ if (typeof window < "u") {
2600
+ var i = arguments.length > 1;
2601
+ return Ye === !1 && (i ? ht(e, t) : ft(e)), i ? document.cookie = e + "=" + encodeURIComponent(t) + (n ? "; expires=" + new Date(+/* @__PURE__ */ new Date() + 1e3 * n).toUTCString() + (s ? "; path=" + s : "") + (r ? "; domain=" + r : "") + (o ? "; secure" : "") : "") : decodeURIComponent((("; " + document.cookie).split("; " + e + "=")[1] || "").split(";")[0]);
2602
+ }
2603
+ }
2604
+ var Yt = "localStorage", Au = Ls.bind(null, "localStorage");
2605
+ Vt("localStorage", "getItem", ft);
2606
+ Vt("localStorage", "setItem", ht);
2607
+ Vt("localStorage", "removeItem", Qt);
2608
+ var Zt = "sessionStorage", Eu = Ls.bind(null, "sessionStorage");
2609
+ Vt("sessionStorage", "getItem", ft);
2610
+ Vt("sessionStorage", "setItem", ht);
2611
+ Vt("sessionStorage", "removeItem", Qt);
2612
+ function xt(e) {
2613
+ var t = e;
2614
+ try {
2615
+ if ((t = JSON.parse(e)) === "true")
2616
+ return !0;
2617
+ if (t === "false")
2618
+ return !1;
2619
+ if (he(t))
2620
+ return t;
2621
+ parseFloat(t) === t && (t = parseFloat(t));
2622
+ } catch {
2623
+ }
2624
+ if (t !== null && t !== "")
2625
+ return t;
2626
+ }
2627
+ var Pu = Au(), Ou = Eu(), _u = Zi();
2628
+ function eo(e, t) {
2629
+ if (e) {
2630
+ var n = Ns(t), s = !qs(n), r = Ts(n) ? xt(localStorage.getItem(e)) : void 0;
2631
+ if (s && !yt(r))
2632
+ return r;
2633
+ var o = Fs(n) ? xt(Xi(e)) : void 0;
2634
+ if (s && o)
2635
+ return o;
2636
+ var i = Us(n) ? xt(sessionStorage.getItem(e)) : void 0;
2637
+ if (s && i)
2638
+ return i;
2639
+ var a = ft(e);
2640
+ return s ? a : { localStorage: r, sessionStorage: i, cookie: o, global: a };
2641
+ }
2642
+ }
2643
+ function Cu(e, t, n) {
2644
+ if (e && !yt(t)) {
2645
+ var s = {}, r = Ns(n), o = JSON.stringify(t), i = !qs(r);
2646
+ return Ts(r) && (s[Yt] = _n(Yt, t, xt(localStorage.getItem(e))), localStorage.setItem(e, o), i) ? s[Yt] : Fs(r) && (s[Xt] = _n(Xt, t, xt(Xi(e))), ku(e, o), i) ? s[Xt] : Us(r) && (s[Zt] = _n(Zt, t, xt(sessionStorage.getItem(e))), sessionStorage.setItem(e, o), i) ? s[Zt] : (s[Jt] = _n(Jt, t, ft(e)), ht(e, t), i ? s[Jt] : s);
2647
+ }
2648
+ }
2649
+ function Iu(e, t) {
2650
+ if (e) {
2651
+ var n = Ns(t), s = eo(e, Li), r = {};
2652
+ return !yt(s.localStorage) && Ts(n) && (localStorage.removeItem(e), r[Yt] = s.localStorage), !yt(s.cookie) && Fs(n) && (Yi(e), r[Xt] = s.cookie), !yt(s.sessionStorage) && Us(n) && (sessionStorage.removeItem(e), r[Zt] = s.sessionStorage), !yt(s.global) && Gn(n, Jt) && (Qt(e), r[Jt] = s.global), r;
2653
+ }
2654
+ }
2655
+ function Ns(e) {
2656
+ return e ? bt(e) ? e : e.storage : Mi;
2657
+ }
2658
+ function Ts(e) {
2659
+ return Pu && Gn(e, Yt);
2660
+ }
2661
+ function Fs(e) {
2662
+ return _u && Gn(e, Xt);
2663
+ }
2664
+ function Us(e) {
2665
+ return Ou && Gn(e, Zt);
2666
+ }
2667
+ function qs(e) {
2668
+ return e === Li || e === "all";
2669
+ }
2670
+ function Gn(e, t) {
2671
+ return e === Mi || e === t || qs(e);
2672
+ }
2673
+ function _n(e, t, n) {
2674
+ return { location: e, current: t, previous: n };
2675
+ }
2676
+ var Bu = { setItem: Cu, getItem: eo, removeItem: Iu };
2677
+ function ju(e, t, n) {
2678
+ return t in e ? Object.defineProperty(e, t, {
2679
+ value: n,
2680
+ enumerable: !0,
2681
+ configurable: !0,
2682
+ writable: !0
2683
+ }) : e[t] = n, e;
2684
+ }
2685
+ function Br(e, t) {
2686
+ var n = Object.keys(e);
2687
+ if (Object.getOwnPropertySymbols) {
2688
+ var s = Object.getOwnPropertySymbols(e);
2689
+ t && (s = s.filter(function(r) {
2690
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
2691
+ })), n.push.apply(n, s);
2692
+ }
2693
+ return n;
2694
+ }
2695
+ function jr(e) {
2696
+ for (var t = 1; t < arguments.length; t++) {
2697
+ var n = arguments[t] != null ? arguments[t] : {};
2698
+ t % 2 ? Br(Object(n), !0).forEach(function(s) {
2699
+ ju(e, s, n[s]);
2700
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(n)) : Br(Object(n)).forEach(function(s) {
2701
+ Object.defineProperty(e, s, Object.getOwnPropertyDescriptor(n, s));
2702
+ });
2703
+ }
2704
+ return e;
2705
+ }
2706
+ function Ru() {
2707
+ var e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, t = {
2708
+ storage: Bu
2709
+ };
2710
+ return xu(jr(jr({}, t), e));
2711
+ }
2712
+ const Du = "@chaibuilder/sdk", Mu = "0.1.3", Lu = "module", Nu = [
2713
+ "dist"
2714
+ ], Tu = "dist/core.js", Fu = !1, Uu = {
2715
+ ".": {
2716
+ import: "./dist/core.js",
2717
+ require: "./dist/core.cjs",
2718
+ types: "./dist/core.d.ts"
2719
+ },
2720
+ "./render": {
2721
+ import: "./dist/render.js",
2722
+ require: "./dist/render.cjs",
2723
+ types: "./dist/render.d.ts"
2724
+ },
2725
+ "./ui": {
2726
+ import: "./dist/ui.js",
2727
+ require: "./dist/ui.cjs",
2728
+ types: "./dist/ui.d.ts"
2729
+ },
2730
+ "./lib": {
2731
+ import: "./dist/lib.js",
2732
+ require: "./dist/lib.cjs",
2733
+ types: "./dist/lib.d.ts"
2734
+ },
2735
+ "./styles": {
2736
+ import: "./dist/style.css",
2737
+ require: "./dist/style.css"
2738
+ }
2739
+ }, qu = {
2740
+ dev: "vite",
2741
+ build: "tsc && vite build",
2742
+ lint: "eslint . --ext ts,tsx --report-unused-disable-directives --max-warnings 0",
2743
+ preview: "vite preview",
2744
+ test: "jest --colors",
2745
+ "test:watch": "jest --watch --colors",
2746
+ "test:coverage": "jest --coverage --colors",
2747
+ e2e: "playwright test",
2748
+ "e2e:report": "playwright show-report",
2749
+ "e2e:ui": "playwright test --ui",
2750
+ docs: "jsdoc -c jsdoc.conf.json"
2751
+ }, $u = {
2752
+ "@analytics/google-analytics": "^1.0.7",
2753
+ "@bobthered/tailwindcss-palette-generator": "3.1.1",
2754
+ "@chaibuilder/blocks": "^0.1.0",
2755
+ "@floating-ui/dom": "1.4.5",
2756
+ "@floating-ui/react-dom": "2.0.1",
2757
+ "@mhsdesign/jit-browser-tailwindcss": "0.3.0",
2758
+ "@minoru/react-dnd-treeview": "3.4.4",
2759
+ "@radix-ui/react-accordion": "^1.1.2",
2760
+ "@radix-ui/react-alert-dialog": "^1.0.4",
2761
+ "@radix-ui/react-context-menu": "^2.1.4",
2762
+ "@radix-ui/react-dialog": "^1.0.4",
2763
+ "@radix-ui/react-dropdown-menu": "^2.0.5",
2764
+ "@radix-ui/react-hover-card": "^1.0.6",
2765
+ "@radix-ui/react-icons": "^1.3.0",
2766
+ "@radix-ui/react-label": "^2.0.2",
2767
+ "@radix-ui/react-menubar": "^1.0.3",
2768
+ "@radix-ui/react-navigation-menu": "^1.1.3",
2769
+ "@radix-ui/react-popover": "^1.0.6",
2770
+ "@radix-ui/react-scroll-area": "^1.0.4",
2771
+ "@radix-ui/react-select": "^1.2.2",
2772
+ "@radix-ui/react-separator": "^1.0.3",
2773
+ "@radix-ui/react-slot": "^1.0.2",
2774
+ "@radix-ui/react-switch": "^1.0.3",
2775
+ "@radix-ui/react-tabs": "^1.0.4",
2776
+ "@radix-ui/react-toast": "^1.1.4",
2777
+ "@radix-ui/react-toggle": "^1.0.3",
2778
+ "@radix-ui/react-tooltip": "^1.0.6",
2779
+ "@react-hookz/web": "23.1.0",
2780
+ "@rjsf/core": "5.11.2",
2781
+ "@rjsf/utils": "5.11.2",
2782
+ "@rjsf/validator-ajv8": "5.11.2",
2783
+ "@tailwindcss/aspect-ratio": "0.4.2",
2784
+ "@tailwindcss/forms": "^0.5.6",
2785
+ "@tailwindcss/line-clamp": "^0.4.4",
2786
+ "@tailwindcss/typography": "^0.5.10",
2787
+ "@tanstack/react-query": "^5.8.4",
2788
+ analytics: "^0.8.9",
2789
+ "class-variance-authority": "0.6.1",
2790
+ clsx: "1.2.1",
2791
+ cmdk: "0.2.0",
2792
+ "date-fns": "^2.30.0",
2793
+ flagged: "2.0.9",
2794
+ "flat-to-nested": "1.1.1",
2795
+ "focus-trap-react": "^10.2.1",
2796
+ "forgiving-xml-parser": "1.4.0",
2797
+ "framer-motion": "^10.12.18",
2798
+ "fuse.js": "6.6.2",
2799
+ "gray-matter": "^4.0.3",
2800
+ himalaya: "^1.1.0",
2801
+ "html-formatter": "0.1.9",
2802
+ i18next: "^23.2.8",
2803
+ jotai: "2.2.2",
2804
+ lodash: "4.17.21",
2805
+ "lucide-react": "^0.244.0",
2806
+ nanoid: "^4.0.2",
2807
+ "post-robot": "10.0.46",
2808
+ react: "^18.2.0",
2809
+ "react-autosuggest": "10.1.0",
2810
+ "react-colorful": "5.6.1",
2811
+ "react-dnd": "16.0.1",
2812
+ "react-dnd-html5-backend": "16.0.1",
2813
+ "react-dom": "^18.2.0",
2814
+ "react-hotkeys-hook": "4.4.1",
2815
+ "react-i18next": "13.0.1",
2816
+ "react-icons": "^4.10.1",
2817
+ "react-icons-picker": "^1.0.9",
2818
+ "react-quill": "^2.0.0",
2819
+ "react-textarea-autosize": "^8.5.2",
2820
+ "react-wrap-balancer": "^1.0.0",
2821
+ "redux-undo": "1.1.0",
2822
+ sonner: "^1.2.0",
2823
+ "tailwind-merge": "1.13.2",
2824
+ "tailwindcss-animate": "1.0.6",
2825
+ "tippy.js": "^6.3.7",
2826
+ "unist-util-visit": "^4.1.2",
2827
+ "unsplash-js": "^7.0.18"
2828
+ }, Qu = {
2829
+ "@commitlint/cli": "17.7.1",
2830
+ "@commitlint/config-conventional": "17.7.0",
2831
+ "@faker-js/faker": "^8.3.1",
2832
+ "@nozbe/watermelondb": "^0.27.1",
2833
+ "@playwright/test": "^1.39.0",
2834
+ "@tanstack/eslint-plugin-query": "^5.8.4",
2835
+ "@types/better-sqlite3": "^7.6.7",
2836
+ "@types/jest": "^29.5.7",
2837
+ "@types/lodash": "^4.14.200",
2838
+ "@types/node": "^20.8.10",
2839
+ "@types/react": "^18.2.15",
2840
+ "@types/react-dom": "^18.2.7",
2841
+ "@typescript-eslint/eslint-plugin": "^6.0.0",
2842
+ "@typescript-eslint/parser": "^6.0.0",
2843
+ "@vitejs/plugin-react-swc": "^3.3.2",
2844
+ autoprefixer: "^10.4.16",
2845
+ "better-docs": "^2.7.2",
2846
+ "better-sqlite3": "^9.1.1",
2847
+ "drizzle-kit": "^0.20.4",
2848
+ "drizzle-orm": "^0.29.0",
2849
+ eslint: "^8.45.0",
2850
+ "eslint-plugin-react-hooks": "^4.6.0",
2851
+ "eslint-plugin-react-refresh": "^0.4.3",
2852
+ jest: "^29.7.0",
2853
+ "jest-environment-jsdom": "^29.7.0",
2854
+ jsdoc: "^4.0.2",
2855
+ msw: "^2.0.8",
2856
+ postcss: "^8.4.31",
2857
+ prettier: "^3.0.3",
2858
+ "prettier-plugin-tailwindcss": "^0.5.6",
2859
+ "prop-types": "^15.8.1",
2860
+ tailwindcss: "^3.3.5",
2861
+ "ts-jest": "^29.1.1",
2862
+ typescript: "^5.0.2",
2863
+ vite: "^4.4.5",
2864
+ "vite-plugin-dts": "^3.6.3"
2865
+ }, Vu = {
2866
+ workerDirectory: "public"
2867
+ }, Ku = {
2868
+ name: Du,
2869
+ private: !1,
2870
+ version: Mu,
2871
+ type: Lu,
2872
+ files: Nu,
2873
+ main: Tu,
2874
+ sideEffects: Fu,
2875
+ exports: Uu,
2876
+ scripts: qu,
2877
+ dependencies: $u,
2878
+ devDependencies: Qu,
2879
+ msw: Vu
2880
+ }, Rr = "https://api.chaibuilder.com", Dr = () => typeof window > "u" ? !1 : window.location.href.includes("localhost");
2881
+ function zu() {
2882
+ return {
2883
+ /* All plugins require a name */
2884
+ name: "chaibuilder-analytics",
2885
+ /* Everything else below this is optional depending on your plugin requirements */
2886
+ config: {},
2887
+ initialize: () => {
2888
+ if (typeof window > "u")
2889
+ return !1;
2890
+ window.chaibuilderAnalyticsLoaded = !0;
2891
+ },
2892
+ page: (e) => {
2893
+ if (typeof window > "u")
2894
+ return !1;
2895
+ if (Dr())
2896
+ return;
2897
+ const { payload: t } = e;
2898
+ fetch(`${Rr}/v1/log`, { method: "post", body: JSON.stringify(t) }).then((n) => n.json());
2899
+ },
2900
+ track: ({ payload: e }) => {
2901
+ if (typeof window > "u")
2902
+ return !1;
2903
+ Dr() || fetch(`${Rr}/v1/log`, { method: "post", body: JSON.stringify(e) });
2904
+ },
2905
+ loaded: () => typeof window > "u" ? !0 : !!window.chaibuilderAnalyticsLoaded
2906
+ };
2907
+ }
2908
+ const Gu = Ru({
2909
+ app: "chaibuilder",
2910
+ version: Ku.version,
2911
+ plugins: [zu()]
2912
+ });
2913
+ ({}).NODE_ENV === "development" && console.log("Chai Builder:", Wo);
2914
+ const Wu = (e) => /* @__PURE__ */ _.jsx(_.Fragment, { children: e.children }), Hu = (e) => {
2915
+ const { dndOptions: t = { backend: Po } } = e, [n] = Oa(), [, s] = yi(), r = xc();
2916
+ return ke(() => {
2917
+ Tc.set(
2918
+ // @ts-ignore
2919
+ ti,
2920
+ Tn(e, ["blocks", "globalBlocks", "brandingOptions"])
2921
+ );
2922
+ }, [e]), ke(() => {
2923
+ n(To(e.blocks || [])), r();
2924
+ }, [e.blocks]), ke(() => {
2925
+ s(e.brandingOptions);
2926
+ }, [e.brandingOptions]), ke(() => {
2927
+ Gu.page();
2928
+ }, []), /* @__PURE__ */ _.jsx(xo, { ...t, options: Eo(), children: /* @__PURE__ */ _.jsx(Wu, { children: /* @__PURE__ */ _.jsx(Nc, {}) }) });
2929
+ }, Ju = (e) => /* @__PURE__ */ _.jsxs(Jo, { children: [
2930
+ /* @__PURE__ */ _.jsx(mo, { features: Ho, children: /* @__PURE__ */ _.jsx(Hu, { ...e }) }),
2931
+ /* @__PURE__ */ _.jsx(Io, {})
2932
+ ] });
2933
+ var vn = class {
2934
+ constructor() {
2935
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
2936
+ }
2937
+ subscribe(e) {
2938
+ return this.listeners.add(e), this.onSubscribe(), () => {
2939
+ this.listeners.delete(e), this.onUnsubscribe();
2940
+ };
2941
+ }
2942
+ hasListeners() {
2943
+ return this.listeners.size > 0;
2944
+ }
2945
+ onSubscribe() {
2946
+ }
2947
+ onUnsubscribe() {
2948
+ }
2949
+ }, qt = typeof window > "u" || "Deno" in window;
2950
+ function ve() {
2951
+ }
2952
+ function Xu(e, t) {
2953
+ return typeof e == "function" ? e(t) : e;
2954
+ }
2955
+ function hs(e) {
2956
+ return typeof e == "number" && e >= 0 && e !== 1 / 0;
2957
+ }
2958
+ function to(e, t) {
2959
+ return Math.max(e + (t || 0) - Date.now(), 0);
2960
+ }
2961
+ function Mr(e, t) {
2962
+ const {
2963
+ type: n = "all",
2964
+ exact: s,
2965
+ fetchStatus: r,
2966
+ predicate: o,
2967
+ queryKey: i,
2968
+ stale: a
2969
+ } = e;
2970
+ if (i) {
2971
+ if (s) {
2972
+ if (t.queryHash !== $s(i, t.options))
2973
+ return !1;
2974
+ } else if (!sn(t.queryKey, i))
2975
+ return !1;
2976
+ }
2977
+ if (n !== "all") {
2978
+ const d = t.isActive();
2979
+ if (n === "active" && !d || n === "inactive" && d)
2980
+ return !1;
2981
+ }
2982
+ return !(typeof a == "boolean" && t.isStale() !== a || typeof r < "u" && r !== t.state.fetchStatus || o && !o(t));
2983
+ }
2984
+ function Lr(e, t) {
2985
+ const { exact: n, status: s, predicate: r, mutationKey: o } = e;
2986
+ if (o) {
2987
+ if (!t.options.mutationKey)
2988
+ return !1;
2989
+ if (n) {
2990
+ if (nn(t.options.mutationKey) !== nn(o))
2991
+ return !1;
2992
+ } else if (!sn(t.options.mutationKey, o))
2993
+ return !1;
2994
+ }
2995
+ return !(s && t.state.status !== s || r && !r(t));
2996
+ }
2997
+ function $s(e, t) {
2998
+ return ((t == null ? void 0 : t.queryKeyHashFn) || nn)(e);
2999
+ }
3000
+ function nn(e) {
3001
+ return JSON.stringify(
3002
+ e,
3003
+ (t, n) => ms(n) ? Object.keys(n).sort().reduce((s, r) => (s[r] = n[r], s), {}) : n
3004
+ );
3005
+ }
3006
+ function sn(e, t) {
3007
+ return e === t ? !0 : typeof e != typeof t ? !1 : e && t && typeof e == "object" && typeof t == "object" ? !Object.keys(t).some((n) => !sn(e[n], t[n])) : !1;
3008
+ }
3009
+ function no(e, t) {
3010
+ if (e === t)
3011
+ return e;
3012
+ const n = Nr(e) && Nr(t);
3013
+ if (n || ms(e) && ms(t)) {
3014
+ const s = n ? e.length : Object.keys(e).length, r = n ? t : Object.keys(t), o = r.length, i = n ? [] : {};
3015
+ let a = 0;
3016
+ for (let d = 0; d < o; d++) {
3017
+ const u = n ? d : r[d];
3018
+ i[u] = no(e[u], t[u]), i[u] === e[u] && a++;
3019
+ }
3020
+ return s === o && a === s ? e : i;
3021
+ }
3022
+ return t;
3023
+ }
3024
+ function ps(e, t) {
3025
+ if (e && !t || t && !e)
3026
+ return !1;
3027
+ for (const n in e)
3028
+ if (e[n] !== t[n])
3029
+ return !1;
3030
+ return !0;
3031
+ }
3032
+ function Nr(e) {
3033
+ return Array.isArray(e) && e.length === Object.keys(e).length;
3034
+ }
3035
+ function ms(e) {
3036
+ if (!Tr(e))
3037
+ return !1;
3038
+ const t = e.constructor;
3039
+ if (typeof t > "u")
3040
+ return !0;
3041
+ const n = t.prototype;
3042
+ return !(!Tr(n) || !n.hasOwnProperty("isPrototypeOf"));
3043
+ }
3044
+ function Tr(e) {
3045
+ return Object.prototype.toString.call(e) === "[object Object]";
3046
+ }
3047
+ function so(e) {
3048
+ return new Promise((t) => {
3049
+ setTimeout(t, e);
3050
+ });
3051
+ }
3052
+ function Fr(e) {
3053
+ so(0).then(e);
3054
+ }
3055
+ function gs(e, t, n) {
3056
+ return typeof n.structuralSharing == "function" ? n.structuralSharing(e, t) : n.structuralSharing !== !1 ? no(e, t) : t;
3057
+ }
3058
+ function Yu(e, t, n = 0) {
3059
+ const s = [...e, t];
3060
+ return n && s.length > n ? s.slice(1) : s;
3061
+ }
3062
+ function Zu(e, t, n = 0) {
3063
+ const s = [t, ...e];
3064
+ return n && s.length > n ? s.slice(0, -1) : s;
3065
+ }
3066
+ var Ze, qe, kt, Qr, el = (Qr = class extends vn {
3067
+ constructor() {
3068
+ super();
3069
+ L(this, Ze, void 0);
3070
+ L(this, qe, void 0);
3071
+ L(this, kt, void 0);
3072
+ P(this, kt, (t) => {
3073
+ if (!qt && window.addEventListener) {
3074
+ const n = () => t();
3075
+ return window.addEventListener("visibilitychange", n, !1), () => {
3076
+ window.removeEventListener("visibilitychange", n);
3077
+ };
3078
+ }
3079
+ });
3080
+ }
3081
+ onSubscribe() {
3082
+ c(this, qe) || this.setEventListener(c(this, kt));
3083
+ }
3084
+ onUnsubscribe() {
3085
+ var t;
3086
+ this.hasListeners() || ((t = c(this, qe)) == null || t.call(this), P(this, qe, void 0));
3087
+ }
3088
+ setEventListener(t) {
3089
+ var n;
3090
+ P(this, kt, t), (n = c(this, qe)) == null || n.call(this), P(this, qe, t((s) => {
3091
+ typeof s == "boolean" ? this.setFocused(s) : this.onFocus();
3092
+ }));
3093
+ }
3094
+ setFocused(t) {
3095
+ c(this, Ze) !== t && (P(this, Ze, t), this.onFocus());
3096
+ }
3097
+ onFocus() {
3098
+ this.listeners.forEach((t) => {
3099
+ t();
3100
+ });
3101
+ }
3102
+ isFocused() {
3103
+ var t;
3104
+ return typeof c(this, Ze) == "boolean" ? c(this, Ze) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
3105
+ }
3106
+ }, Ze = new WeakMap(), qe = new WeakMap(), kt = new WeakMap(), Qr), Mn = new el(), At, $e, Et, Vr, tl = (Vr = class extends vn {
3107
+ constructor() {
3108
+ super();
3109
+ L(this, At, !0);
3110
+ L(this, $e, void 0);
3111
+ L(this, Et, void 0);
3112
+ P(this, Et, (t) => {
3113
+ if (!qt && window.addEventListener) {
3114
+ const n = () => t(!0), s = () => t(!1);
3115
+ return window.addEventListener("online", n, !1), window.addEventListener("offline", s, !1), () => {
3116
+ window.removeEventListener("online", n), window.removeEventListener("offline", s);
3117
+ };
3118
+ }
3119
+ });
3120
+ }
3121
+ onSubscribe() {
3122
+ c(this, $e) || this.setEventListener(c(this, Et));
3123
+ }
3124
+ onUnsubscribe() {
3125
+ var t;
3126
+ this.hasListeners() || ((t = c(this, $e)) == null || t.call(this), P(this, $e, void 0));
3127
+ }
3128
+ setEventListener(t) {
3129
+ var n;
3130
+ P(this, Et, t), (n = c(this, $e)) == null || n.call(this), P(this, $e, t(this.setOnline.bind(this)));
3131
+ }
3132
+ setOnline(t) {
3133
+ c(this, At) !== t && (P(this, At, t), this.listeners.forEach((s) => {
3134
+ s(t);
3135
+ }));
3136
+ }
3137
+ isOnline() {
3138
+ return c(this, At);
3139
+ }
3140
+ }, At = new WeakMap(), $e = new WeakMap(), Et = new WeakMap(), Vr), Ln = new tl();
3141
+ function nl(e) {
3142
+ return Math.min(1e3 * 2 ** e, 3e4);
3143
+ }
3144
+ function Wn(e) {
3145
+ return (e ?? "online") === "online" ? Ln.isOnline() : !0;
3146
+ }
3147
+ var ro = class {
3148
+ constructor(e) {
3149
+ this.revert = e == null ? void 0 : e.revert, this.silent = e == null ? void 0 : e.silent;
3150
+ }
3151
+ };
3152
+ function is(e) {
3153
+ return e instanceof ro;
3154
+ }
3155
+ function io(e) {
3156
+ let t = !1, n = 0, s = !1, r, o, i;
3157
+ const a = new Promise((y, A) => {
3158
+ o = y, i = A;
3159
+ }), d = (y) => {
3160
+ var A;
3161
+ s || (g(new ro(y)), (A = e.abort) == null || A.call(e));
3162
+ }, u = () => {
3163
+ t = !0;
3164
+ }, f = () => {
3165
+ t = !1;
3166
+ }, m = () => !Mn.isFocused() || e.networkMode !== "always" && !Ln.isOnline(), b = (y) => {
3167
+ var A;
3168
+ s || (s = !0, (A = e.onSuccess) == null || A.call(e, y), r == null || r(), o(y));
3169
+ }, g = (y) => {
3170
+ var A;
3171
+ s || (s = !0, (A = e.onError) == null || A.call(e, y), r == null || r(), i(y));
3172
+ }, O = () => new Promise((y) => {
3173
+ var A;
3174
+ r = (D) => {
3175
+ const j = s || !m();
3176
+ return j && y(D), j;
3177
+ }, (A = e.onPause) == null || A.call(e);
3178
+ }).then(() => {
3179
+ var y;
3180
+ r = void 0, s || (y = e.onContinue) == null || y.call(e);
3181
+ }), C = () => {
3182
+ if (s)
3183
+ return;
3184
+ let y;
3185
+ try {
3186
+ y = e.fn();
3187
+ } catch (A) {
3188
+ y = Promise.reject(A);
3189
+ }
3190
+ Promise.resolve(y).then(b).catch((A) => {
3191
+ var F;
3192
+ if (s)
3193
+ return;
3194
+ const D = e.retry ?? (qt ? 0 : 3), j = e.retryDelay ?? nl, x = typeof j == "function" ? j(n, A) : j, k = D === !0 || typeof D == "number" && n < D || typeof D == "function" && D(n, A);
3195
+ if (t || !k) {
3196
+ g(A);
3197
+ return;
3198
+ }
3199
+ n++, (F = e.onFail) == null || F.call(e, n, A), so(x).then(() => {
3200
+ if (m())
3201
+ return O();
3202
+ }).then(() => {
3203
+ t ? g(A) : C();
3204
+ });
3205
+ });
3206
+ };
3207
+ return Wn(e.networkMode) ? C() : O().then(C), {
3208
+ promise: a,
3209
+ cancel: d,
3210
+ continue: () => (r == null ? void 0 : r()) ? a : Promise.resolve(),
3211
+ cancelRetry: u,
3212
+ continueRetry: f
3213
+ };
3214
+ }
3215
+ function sl() {
3216
+ let e = [], t = 0, n = (f) => {
3217
+ f();
3218
+ }, s = (f) => {
3219
+ f();
3220
+ };
3221
+ const r = (f) => {
3222
+ let m;
3223
+ t++;
3224
+ try {
3225
+ m = f();
3226
+ } finally {
3227
+ t--, t || a();
3228
+ }
3229
+ return m;
3230
+ }, o = (f) => {
3231
+ t ? e.push(f) : Fr(() => {
3232
+ n(f);
3233
+ });
3234
+ }, i = (f) => (...m) => {
3235
+ o(() => {
3236
+ f(...m);
3237
+ });
3238
+ }, a = () => {
3239
+ const f = e;
3240
+ e = [], f.length && Fr(() => {
3241
+ s(() => {
3242
+ f.forEach((m) => {
3243
+ n(m);
3244
+ });
3245
+ });
3246
+ });
3247
+ };
3248
+ return {
3249
+ batch: r,
3250
+ batchCalls: i,
3251
+ schedule: o,
3252
+ setNotifyFunction: (f) => {
3253
+ n = f;
3254
+ },
3255
+ setBatchNotifyFunction: (f) => {
3256
+ s = f;
3257
+ }
3258
+ };
3259
+ }
3260
+ var ae = sl(), et, Kr, oo = (Kr = class {
3261
+ constructor() {
3262
+ L(this, et, void 0);
3263
+ }
3264
+ destroy() {
3265
+ this.clearGcTimeout();
3266
+ }
3267
+ scheduleGc() {
3268
+ this.clearGcTimeout(), hs(this.gcTime) && P(this, et, setTimeout(() => {
3269
+ this.optionalRemove();
3270
+ }, this.gcTime));
3271
+ }
3272
+ updateGcTime(e) {
3273
+ this.gcTime = Math.max(
3274
+ this.gcTime || 0,
3275
+ e ?? (qt ? 1 / 0 : 5 * 60 * 1e3)
3276
+ );
3277
+ }
3278
+ clearGcTimeout() {
3279
+ c(this, et) && (clearTimeout(c(this, et)), P(this, et, void 0));
3280
+ }
3281
+ }, et = new WeakMap(), Kr), Pt, Ot, me, Qe, ge, ie, rn, tt, _t, Bn, xe, Re, zr, rl = (zr = class extends oo {
3282
+ constructor(t) {
3283
+ super();
3284
+ L(this, _t);
3285
+ L(this, xe);
3286
+ L(this, Pt, void 0);
3287
+ L(this, Ot, void 0);
3288
+ L(this, me, void 0);
3289
+ L(this, Qe, void 0);
3290
+ L(this, ge, void 0);
3291
+ L(this, ie, void 0);
3292
+ L(this, rn, void 0);
3293
+ L(this, tt, void 0);
3294
+ P(this, tt, !1), P(this, rn, t.defaultOptions), K(this, _t, Bn).call(this, t.options), P(this, ie, []), P(this, me, t.cache), this.queryKey = t.queryKey, this.queryHash = t.queryHash, P(this, Pt, t.state || il(this.options)), this.state = c(this, Pt), this.scheduleGc();
3295
+ }
3296
+ get meta() {
3297
+ return this.options.meta;
3298
+ }
3299
+ optionalRemove() {
3300
+ !c(this, ie).length && this.state.fetchStatus === "idle" && c(this, me).remove(this);
3301
+ }
3302
+ setData(t, n) {
3303
+ const s = gs(this.state.data, t, this.options);
3304
+ return K(this, xe, Re).call(this, {
3305
+ data: s,
3306
+ type: "success",
3307
+ dataUpdatedAt: n == null ? void 0 : n.updatedAt,
3308
+ manual: n == null ? void 0 : n.manual
3309
+ }), s;
3310
+ }
3311
+ setState(t, n) {
3312
+ K(this, xe, Re).call(this, { type: "setState", state: t, setStateOptions: n });
3313
+ }
3314
+ cancel(t) {
3315
+ var s;
3316
+ const n = c(this, Qe);
3317
+ return (s = c(this, ge)) == null || s.cancel(t), n ? n.then(ve).catch(ve) : Promise.resolve();
3318
+ }
3319
+ destroy() {
3320
+ super.destroy(), this.cancel({ silent: !0 });
3321
+ }
3322
+ reset() {
3323
+ this.destroy(), this.setState(c(this, Pt));
3324
+ }
3325
+ isActive() {
3326
+ return c(this, ie).some(
3327
+ (t) => t.options.enabled !== !1
3328
+ );
3329
+ }
3330
+ isDisabled() {
3331
+ return this.getObserversCount() > 0 && !this.isActive();
3332
+ }
3333
+ isStale() {
3334
+ return this.state.isInvalidated || !this.state.dataUpdatedAt || c(this, ie).some((t) => t.getCurrentResult().isStale);
3335
+ }
3336
+ isStaleByTime(t = 0) {
3337
+ return this.state.isInvalidated || !this.state.dataUpdatedAt || !to(this.state.dataUpdatedAt, t);
3338
+ }
3339
+ onFocus() {
3340
+ var n;
3341
+ const t = c(this, ie).find((s) => s.shouldFetchOnWindowFocus());
3342
+ t == null || t.refetch({ cancelRefetch: !1 }), (n = c(this, ge)) == null || n.continue();
3343
+ }
3344
+ onOnline() {
3345
+ var n;
3346
+ const t = c(this, ie).find((s) => s.shouldFetchOnReconnect());
3347
+ t == null || t.refetch({ cancelRefetch: !1 }), (n = c(this, ge)) == null || n.continue();
3348
+ }
3349
+ addObserver(t) {
3350
+ c(this, ie).includes(t) || (c(this, ie).push(t), this.clearGcTimeout(), c(this, me).notify({ type: "observerAdded", query: this, observer: t }));
3351
+ }
3352
+ removeObserver(t) {
3353
+ c(this, ie).includes(t) && (P(this, ie, c(this, ie).filter((n) => n !== t)), c(this, ie).length || (c(this, ge) && (c(this, tt) ? c(this, ge).cancel({ revert: !0 }) : c(this, ge).cancelRetry()), this.scheduleGc()), c(this, me).notify({ type: "observerRemoved", query: this, observer: t }));
3354
+ }
3355
+ getObserversCount() {
3356
+ return c(this, ie).length;
3357
+ }
3358
+ invalidate() {
3359
+ this.state.isInvalidated || K(this, xe, Re).call(this, { type: "invalidate" });
3360
+ }
3361
+ fetch(t, n) {
3362
+ var u, f, m, b;
3363
+ if (this.state.fetchStatus !== "idle") {
3364
+ if (this.state.dataUpdatedAt && (n != null && n.cancelRefetch))
3365
+ this.cancel({ silent: !0 });
3366
+ else if (c(this, Qe))
3367
+ return (u = c(this, ge)) == null || u.continueRetry(), c(this, Qe);
3368
+ }
3369
+ if (t && K(this, _t, Bn).call(this, t), !this.options.queryFn) {
3370
+ const g = c(this, ie).find((O) => O.options.queryFn);
3371
+ g && K(this, _t, Bn).call(this, g.options);
3372
+ }
3373
+ process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
3374
+ "As of v4, queryKey needs to be an Array. If you are using a string like 'repoData', please change it to an Array, e.g. ['repoData']"
3375
+ ));
3376
+ const s = new AbortController(), r = {
3377
+ queryKey: this.queryKey,
3378
+ meta: this.meta
3379
+ }, o = (g) => {
3380
+ Object.defineProperty(g, "signal", {
3381
+ enumerable: !0,
3382
+ get: () => (P(this, tt, !0), s.signal)
3383
+ });
3384
+ };
3385
+ o(r);
3386
+ const i = () => this.options.queryFn ? (P(this, tt, !1), this.options.persister ? this.options.persister(
3387
+ this.options.queryFn,
3388
+ r,
3389
+ this
3390
+ ) : this.options.queryFn(
3391
+ r
3392
+ )) : Promise.reject(
3393
+ new Error(`Missing queryFn: '${this.options.queryHash}'`)
3394
+ ), a = {
3395
+ fetchOptions: n,
3396
+ options: this.options,
3397
+ queryKey: this.queryKey,
3398
+ state: this.state,
3399
+ fetchFn: i
3400
+ };
3401
+ o(a), (f = this.options.behavior) == null || f.onFetch(
3402
+ a,
3403
+ this
3404
+ ), P(this, Ot, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((m = a.fetchOptions) == null ? void 0 : m.meta)) && K(this, xe, Re).call(this, { type: "fetch", meta: (b = a.fetchOptions) == null ? void 0 : b.meta });
3405
+ const d = (g) => {
3406
+ var O, C, y, A;
3407
+ is(g) && g.silent || K(this, xe, Re).call(this, {
3408
+ type: "error",
3409
+ error: g
3410
+ }), is(g) || ((C = (O = c(this, me).config).onError) == null || C.call(
3411
+ O,
3412
+ g,
3413
+ this
3414
+ ), (A = (y = c(this, me).config).onSettled) == null || A.call(
3415
+ y,
3416
+ this.state.data,
3417
+ g,
3418
+ this
3419
+ )), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1;
3420
+ };
3421
+ return P(this, ge, io({
3422
+ fn: a.fetchFn,
3423
+ abort: s.abort.bind(s),
3424
+ onSuccess: (g) => {
3425
+ var O, C, y, A;
3426
+ if (typeof g > "u") {
3427
+ process.env.NODE_ENV !== "production" && console.error(
3428
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
3429
+ ), d(new Error(`${this.queryHash} data is undefined`));
3430
+ return;
3431
+ }
3432
+ this.setData(g), (C = (O = c(this, me).config).onSuccess) == null || C.call(O, g, this), (A = (y = c(this, me).config).onSettled) == null || A.call(
3433
+ y,
3434
+ g,
3435
+ this.state.error,
3436
+ this
3437
+ ), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1;
3438
+ },
3439
+ onError: d,
3440
+ onFail: (g, O) => {
3441
+ K(this, xe, Re).call(this, { type: "failed", failureCount: g, error: O });
3442
+ },
3443
+ onPause: () => {
3444
+ K(this, xe, Re).call(this, { type: "pause" });
3445
+ },
3446
+ onContinue: () => {
3447
+ K(this, xe, Re).call(this, { type: "continue" });
3448
+ },
3449
+ retry: a.options.retry,
3450
+ retryDelay: a.options.retryDelay,
3451
+ networkMode: a.options.networkMode
3452
+ })), P(this, Qe, c(this, ge).promise), c(this, Qe);
3453
+ }
3454
+ }, Pt = new WeakMap(), Ot = new WeakMap(), me = new WeakMap(), Qe = new WeakMap(), ge = new WeakMap(), ie = new WeakMap(), rn = new WeakMap(), tt = new WeakMap(), _t = new WeakSet(), Bn = function(t) {
3455
+ this.options = { ...c(this, rn), ...t }, this.updateGcTime(this.options.gcTime);
3456
+ }, xe = new WeakSet(), Re = function(t) {
3457
+ const n = (s) => {
3458
+ switch (t.type) {
3459
+ case "failed":
3460
+ return {
3461
+ ...s,
3462
+ fetchFailureCount: t.failureCount,
3463
+ fetchFailureReason: t.error
3464
+ };
3465
+ case "pause":
3466
+ return {
3467
+ ...s,
3468
+ fetchStatus: "paused"
3469
+ };
3470
+ case "continue":
3471
+ return {
3472
+ ...s,
3473
+ fetchStatus: "fetching"
3474
+ };
3475
+ case "fetch":
3476
+ return {
3477
+ ...s,
3478
+ fetchFailureCount: 0,
3479
+ fetchFailureReason: null,
3480
+ fetchMeta: t.meta ?? null,
3481
+ fetchStatus: Wn(this.options.networkMode) ? "fetching" : "paused",
3482
+ ...!s.dataUpdatedAt && {
3483
+ error: null,
3484
+ status: "pending"
3485
+ }
3486
+ };
3487
+ case "success":
3488
+ return {
3489
+ ...s,
3490
+ data: t.data,
3491
+ dataUpdateCount: s.dataUpdateCount + 1,
3492
+ dataUpdatedAt: t.dataUpdatedAt ?? Date.now(),
3493
+ error: null,
3494
+ isInvalidated: !1,
3495
+ status: "success",
3496
+ ...!t.manual && {
3497
+ fetchStatus: "idle",
3498
+ fetchFailureCount: 0,
3499
+ fetchFailureReason: null
3500
+ }
3501
+ };
3502
+ case "error":
3503
+ const r = t.error;
3504
+ return is(r) && r.revert && c(this, Ot) ? { ...c(this, Ot), fetchStatus: "idle" } : {
3505
+ ...s,
3506
+ error: r,
3507
+ errorUpdateCount: s.errorUpdateCount + 1,
3508
+ errorUpdatedAt: Date.now(),
3509
+ fetchFailureCount: s.fetchFailureCount + 1,
3510
+ fetchFailureReason: r,
3511
+ fetchStatus: "idle",
3512
+ status: "error"
3513
+ };
3514
+ case "invalidate":
3515
+ return {
3516
+ ...s,
3517
+ isInvalidated: !0
3518
+ };
3519
+ case "setState":
3520
+ return {
3521
+ ...s,
3522
+ ...t.state
3523
+ };
3524
+ }
3525
+ };
3526
+ this.state = n(this.state), ae.batch(() => {
3527
+ c(this, ie).forEach((s) => {
3528
+ s.onQueryUpdate();
3529
+ }), c(this, me).notify({ query: this, type: "updated", action: t });
3530
+ });
3531
+ }, zr);
3532
+ function il(e) {
3533
+ const t = typeof e.initialData == "function" ? e.initialData() : e.initialData, n = typeof t < "u", s = n ? typeof e.initialDataUpdatedAt == "function" ? e.initialDataUpdatedAt() : e.initialDataUpdatedAt : 0;
3534
+ return {
3535
+ data: t,
3536
+ dataUpdateCount: 0,
3537
+ dataUpdatedAt: n ? s ?? Date.now() : 0,
3538
+ error: null,
3539
+ errorUpdateCount: 0,
3540
+ errorUpdatedAt: 0,
3541
+ fetchFailureCount: 0,
3542
+ fetchFailureReason: null,
3543
+ fetchMeta: null,
3544
+ isInvalidated: !1,
3545
+ status: n ? "success" : "pending",
3546
+ fetchStatus: "idle"
3547
+ };
3548
+ }
3549
+ var Oe, Gr, ol = (Gr = class extends vn {
3550
+ constructor(t = {}) {
3551
+ super();
3552
+ L(this, Oe, void 0);
3553
+ this.config = t, P(this, Oe, /* @__PURE__ */ new Map());
3554
+ }
3555
+ build(t, n, s) {
3556
+ const r = n.queryKey, o = n.queryHash ?? $s(r, n);
3557
+ let i = this.get(o);
3558
+ return i || (i = new rl({
3559
+ cache: this,
3560
+ queryKey: r,
3561
+ queryHash: o,
3562
+ options: t.defaultQueryOptions(n),
3563
+ state: s,
3564
+ defaultOptions: t.getQueryDefaults(r)
3565
+ }), this.add(i)), i;
3566
+ }
3567
+ add(t) {
3568
+ c(this, Oe).has(t.queryHash) || (c(this, Oe).set(t.queryHash, t), this.notify({
3569
+ type: "added",
3570
+ query: t
3571
+ }));
3572
+ }
3573
+ remove(t) {
3574
+ const n = c(this, Oe).get(t.queryHash);
3575
+ n && (t.destroy(), n === t && c(this, Oe).delete(t.queryHash), this.notify({ type: "removed", query: t }));
3576
+ }
3577
+ clear() {
3578
+ ae.batch(() => {
3579
+ this.getAll().forEach((t) => {
3580
+ this.remove(t);
3581
+ });
3582
+ });
3583
+ }
3584
+ get(t) {
3585
+ return c(this, Oe).get(t);
3586
+ }
3587
+ getAll() {
3588
+ return [...c(this, Oe).values()];
3589
+ }
3590
+ find(t) {
3591
+ const n = { exact: !0, ...t };
3592
+ return this.getAll().find(
3593
+ (s) => Mr(n, s)
3594
+ );
3595
+ }
3596
+ findAll(t = {}) {
3597
+ const n = this.getAll();
3598
+ return Object.keys(t).length > 0 ? n.filter((s) => Mr(t, s)) : n;
3599
+ }
3600
+ notify(t) {
3601
+ ae.batch(() => {
3602
+ this.listeners.forEach((n) => {
3603
+ n(t);
3604
+ });
3605
+ });
3606
+ }
3607
+ onFocus() {
3608
+ ae.batch(() => {
3609
+ this.getAll().forEach((t) => {
3610
+ t.onFocus();
3611
+ });
3612
+ });
3613
+ }
3614
+ onOnline() {
3615
+ ae.batch(() => {
3616
+ this.getAll().forEach((t) => {
3617
+ t.onOnline();
3618
+ });
3619
+ });
3620
+ }
3621
+ }, Oe = new WeakMap(), Gr), _e, on, fe, Ct, Ce, Ne, Wr, al = (Wr = class extends oo {
3622
+ constructor(t) {
3623
+ super();
3624
+ L(this, Ce);
3625
+ L(this, _e, void 0);
3626
+ L(this, on, void 0);
3627
+ L(this, fe, void 0);
3628
+ L(this, Ct, void 0);
3629
+ this.mutationId = t.mutationId, P(this, on, t.defaultOptions), P(this, fe, t.mutationCache), P(this, _e, []), this.state = t.state || cl(), this.setOptions(t.options), this.scheduleGc();
3630
+ }
3631
+ setOptions(t) {
3632
+ this.options = { ...c(this, on), ...t }, this.updateGcTime(this.options.gcTime);
3633
+ }
3634
+ get meta() {
3635
+ return this.options.meta;
3636
+ }
3637
+ addObserver(t) {
3638
+ c(this, _e).includes(t) || (c(this, _e).push(t), this.clearGcTimeout(), c(this, fe).notify({
3639
+ type: "observerAdded",
3640
+ mutation: this,
3641
+ observer: t
3642
+ }));
3643
+ }
3644
+ removeObserver(t) {
3645
+ P(this, _e, c(this, _e).filter((n) => n !== t)), this.scheduleGc(), c(this, fe).notify({
3646
+ type: "observerRemoved",
3647
+ mutation: this,
3648
+ observer: t
3649
+ });
3650
+ }
3651
+ optionalRemove() {
3652
+ c(this, _e).length || (this.state.status === "pending" ? this.scheduleGc() : c(this, fe).remove(this));
3653
+ }
3654
+ continue() {
3655
+ var t;
3656
+ return ((t = c(this, Ct)) == null ? void 0 : t.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
3657
+ this.execute(this.state.variables);
3658
+ }
3659
+ async execute(t) {
3660
+ var r, o, i, a, d, u, f, m, b, g, O, C, y, A, D, j, x, k, F, T;
3661
+ const n = () => (P(this, Ct, io({
3662
+ fn: () => this.options.mutationFn ? this.options.mutationFn(t) : Promise.reject(new Error("No mutationFn found")),
3663
+ onFail: (R, p) => {
3664
+ K(this, Ce, Ne).call(this, { type: "failed", failureCount: R, error: p });
3665
+ },
3666
+ onPause: () => {
3667
+ K(this, Ce, Ne).call(this, { type: "pause" });
3668
+ },
3669
+ onContinue: () => {
3670
+ K(this, Ce, Ne).call(this, { type: "continue" });
3671
+ },
3672
+ retry: this.options.retry ?? 0,
3673
+ retryDelay: this.options.retryDelay,
3674
+ networkMode: this.options.networkMode
3675
+ })), c(this, Ct).promise), s = this.state.status === "pending";
3676
+ try {
3677
+ if (!s) {
3678
+ K(this, Ce, Ne).call(this, { type: "pending", variables: t }), await ((o = (r = c(this, fe).config).onMutate) == null ? void 0 : o.call(
3679
+ r,
3680
+ t,
3681
+ this
3682
+ ));
3683
+ const p = await ((a = (i = this.options).onMutate) == null ? void 0 : a.call(i, t));
3684
+ p !== this.state.context && K(this, Ce, Ne).call(this, {
3685
+ type: "pending",
3686
+ context: p,
3687
+ variables: t
3688
+ });
3689
+ }
3690
+ const R = await n();
3691
+ return await ((u = (d = c(this, fe).config).onSuccess) == null ? void 0 : u.call(
3692
+ d,
3693
+ R,
3694
+ t,
3695
+ this.state.context,
3696
+ this
3697
+ )), await ((m = (f = this.options).onSuccess) == null ? void 0 : m.call(f, R, t, this.state.context)), await ((g = (b = c(this, fe).config).onSettled) == null ? void 0 : g.call(
3698
+ b,
3699
+ R,
3700
+ null,
3701
+ this.state.variables,
3702
+ this.state.context,
3703
+ this
3704
+ )), await ((C = (O = this.options).onSettled) == null ? void 0 : C.call(O, R, null, t, this.state.context)), K(this, Ce, Ne).call(this, { type: "success", data: R }), R;
3705
+ } catch (R) {
3706
+ try {
3707
+ throw await ((A = (y = c(this, fe).config).onError) == null ? void 0 : A.call(
3708
+ y,
3709
+ R,
3710
+ t,
3711
+ this.state.context,
3712
+ this
3713
+ )), await ((j = (D = this.options).onError) == null ? void 0 : j.call(
3714
+ D,
3715
+ R,
3716
+ t,
3717
+ this.state.context
3718
+ )), await ((k = (x = c(this, fe).config).onSettled) == null ? void 0 : k.call(
3719
+ x,
3720
+ void 0,
3721
+ R,
3722
+ this.state.variables,
3723
+ this.state.context,
3724
+ this
3725
+ )), await ((T = (F = this.options).onSettled) == null ? void 0 : T.call(
3726
+ F,
3727
+ void 0,
3728
+ R,
3729
+ t,
3730
+ this.state.context
3731
+ )), R;
3732
+ } finally {
3733
+ K(this, Ce, Ne).call(this, { type: "error", error: R });
3734
+ }
3735
+ }
3736
+ }
3737
+ }, _e = new WeakMap(), on = new WeakMap(), fe = new WeakMap(), Ct = new WeakMap(), Ce = new WeakSet(), Ne = function(t) {
3738
+ const n = (s) => {
3739
+ switch (t.type) {
3740
+ case "failed":
3741
+ return {
3742
+ ...s,
3743
+ failureCount: t.failureCount,
3744
+ failureReason: t.error
3745
+ };
3746
+ case "pause":
3747
+ return {
3748
+ ...s,
3749
+ isPaused: !0
3750
+ };
3751
+ case "continue":
3752
+ return {
3753
+ ...s,
3754
+ isPaused: !1
3755
+ };
3756
+ case "pending":
3757
+ return {
3758
+ ...s,
3759
+ context: t.context,
3760
+ data: void 0,
3761
+ failureCount: 0,
3762
+ failureReason: null,
3763
+ error: null,
3764
+ isPaused: !Wn(this.options.networkMode),
3765
+ status: "pending",
3766
+ variables: t.variables,
3767
+ submittedAt: Date.now()
3768
+ };
3769
+ case "success":
3770
+ return {
3771
+ ...s,
3772
+ data: t.data,
3773
+ failureCount: 0,
3774
+ failureReason: null,
3775
+ error: null,
3776
+ status: "success",
3777
+ isPaused: !1
3778
+ };
3779
+ case "error":
3780
+ return {
3781
+ ...s,
3782
+ data: void 0,
3783
+ error: t.error,
3784
+ failureCount: s.failureCount + 1,
3785
+ failureReason: t.error,
3786
+ isPaused: !1,
3787
+ status: "error"
3788
+ };
3789
+ }
3790
+ };
3791
+ this.state = n(this.state), ae.batch(() => {
3792
+ c(this, _e).forEach((s) => {
3793
+ s.onMutationUpdate(t);
3794
+ }), c(this, fe).notify({
3795
+ mutation: this,
3796
+ type: "updated",
3797
+ action: t
3798
+ });
3799
+ });
3800
+ }, Wr);
3801
+ function cl() {
3802
+ return {
3803
+ context: void 0,
3804
+ data: void 0,
3805
+ error: null,
3806
+ failureCount: 0,
3807
+ failureReason: null,
3808
+ isPaused: !1,
3809
+ status: "idle",
3810
+ variables: void 0,
3811
+ submittedAt: 0
3812
+ };
3813
+ }
3814
+ var ye, an, nt, Hr, ul = (Hr = class extends vn {
3815
+ constructor(t = {}) {
3816
+ super();
3817
+ L(this, ye, void 0);
3818
+ L(this, an, void 0);
3819
+ L(this, nt, void 0);
3820
+ this.config = t, P(this, ye, []), P(this, an, 0);
3821
+ }
3822
+ build(t, n, s) {
3823
+ const r = new al({
3824
+ mutationCache: this,
3825
+ mutationId: ++wn(this, an)._,
3826
+ options: t.defaultMutationOptions(n),
3827
+ state: s
3828
+ });
3829
+ return this.add(r), r;
3830
+ }
3831
+ add(t) {
3832
+ c(this, ye).push(t), this.notify({ type: "added", mutation: t });
3833
+ }
3834
+ remove(t) {
3835
+ P(this, ye, c(this, ye).filter((n) => n !== t)), this.notify({ type: "removed", mutation: t });
3836
+ }
3837
+ clear() {
3838
+ ae.batch(() => {
3839
+ c(this, ye).forEach((t) => {
3840
+ this.remove(t);
3841
+ });
3842
+ });
3843
+ }
3844
+ getAll() {
3845
+ return c(this, ye);
3846
+ }
3847
+ find(t) {
3848
+ const n = { exact: !0, ...t };
3849
+ return c(this, ye).find(
3850
+ (s) => Lr(n, s)
3851
+ );
3852
+ }
3853
+ findAll(t = {}) {
3854
+ return c(this, ye).filter(
3855
+ (n) => Lr(t, n)
3856
+ );
3857
+ }
3858
+ notify(t) {
3859
+ ae.batch(() => {
3860
+ this.listeners.forEach((n) => {
3861
+ n(t);
3862
+ });
3863
+ });
3864
+ }
3865
+ resumePausedMutations() {
3866
+ return P(this, nt, (c(this, nt) ?? Promise.resolve()).then(() => {
3867
+ const t = c(this, ye).filter((n) => n.state.isPaused);
3868
+ return ae.batch(
3869
+ () => t.reduce(
3870
+ (n, s) => n.then(() => s.continue().catch(ve)),
3871
+ Promise.resolve()
3872
+ )
3873
+ );
3874
+ }).then(() => {
3875
+ P(this, nt, void 0);
3876
+ })), c(this, nt);
3877
+ }
3878
+ }, ye = new WeakMap(), an = new WeakMap(), nt = new WeakMap(), Hr);
3879
+ function ll(e) {
3880
+ return {
3881
+ onFetch: (t, n) => {
3882
+ const s = async () => {
3883
+ var O, C, y, A, D;
3884
+ const r = t.options, o = (y = (C = (O = t.fetchOptions) == null ? void 0 : O.meta) == null ? void 0 : C.fetchMore) == null ? void 0 : y.direction, i = ((A = t.state.data) == null ? void 0 : A.pages) || [], a = ((D = t.state.data) == null ? void 0 : D.pageParams) || [], d = { pages: [], pageParams: [] };
3885
+ let u = !1;
3886
+ const f = (j) => {
3887
+ Object.defineProperty(j, "signal", {
3888
+ enumerable: !0,
3889
+ get: () => (t.signal.aborted ? u = !0 : t.signal.addEventListener("abort", () => {
3890
+ u = !0;
3891
+ }), t.signal)
3892
+ });
3893
+ }, m = t.options.queryFn || (() => Promise.reject(
3894
+ new Error(`Missing queryFn: '${t.options.queryHash}'`)
3895
+ )), b = async (j, x, k) => {
3896
+ if (u)
3897
+ return Promise.reject();
3898
+ if (x == null && j.pages.length)
3899
+ return Promise.resolve(j);
3900
+ const F = {
3901
+ queryKey: t.queryKey,
3902
+ pageParam: x,
3903
+ direction: k ? "backward" : "forward",
3904
+ meta: t.options.meta
3905
+ };
3906
+ f(F);
3907
+ const T = await m(
3908
+ F
3909
+ ), { maxPages: R } = t.options, p = k ? Zu : Yu;
3910
+ return {
3911
+ pages: p(j.pages, T, R),
3912
+ pageParams: p(j.pageParams, x, R)
3913
+ };
3914
+ };
3915
+ let g;
3916
+ if (o && i.length) {
3917
+ const j = o === "backward", x = j ? dl : Ur, k = {
3918
+ pages: i,
3919
+ pageParams: a
3920
+ }, F = x(r, k);
3921
+ g = await b(k, F, j);
3922
+ } else {
3923
+ g = await b(
3924
+ d,
3925
+ a[0] ?? r.initialPageParam
3926
+ );
3927
+ const j = e ?? i.length;
3928
+ for (let x = 1; x < j; x++) {
3929
+ const k = Ur(r, g);
3930
+ g = await b(g, k);
3931
+ }
3932
+ }
3933
+ return g;
3934
+ };
3935
+ t.options.persister ? t.fetchFn = () => {
3936
+ var r, o;
3937
+ return (o = (r = t.options).persister) == null ? void 0 : o.call(
3938
+ r,
3939
+ s,
3940
+ {
3941
+ queryKey: t.queryKey,
3942
+ meta: t.options.meta,
3943
+ signal: t.signal
3944
+ },
3945
+ n
3946
+ );
3947
+ } : t.fetchFn = s;
3948
+ }
3949
+ };
3950
+ }
3951
+ function Ur(e, { pages: t, pageParams: n }) {
3952
+ const s = t.length - 1;
3953
+ return e.getNextPageParam(
3954
+ t[s],
3955
+ t,
3956
+ n[s],
3957
+ n
3958
+ );
3959
+ }
3960
+ function dl(e, { pages: t, pageParams: n }) {
3961
+ var s;
3962
+ return (s = e.getPreviousPageParam) == null ? void 0 : s.call(
3963
+ e,
3964
+ t[0],
3965
+ t,
3966
+ n[0],
3967
+ n
3968
+ );
3969
+ }
3970
+ var re, Ve, Ke, It, Bt, ze, jt, Rt, Jr, fl = (Jr = class {
3971
+ constructor(e = {}) {
3972
+ L(this, re, void 0);
3973
+ L(this, Ve, void 0);
3974
+ L(this, Ke, void 0);
3975
+ L(this, It, void 0);
3976
+ L(this, Bt, void 0);
3977
+ L(this, ze, void 0);
3978
+ L(this, jt, void 0);
3979
+ L(this, Rt, void 0);
3980
+ P(this, re, e.queryCache || new ol()), P(this, Ve, e.mutationCache || new ul()), P(this, Ke, e.defaultOptions || {}), P(this, It, /* @__PURE__ */ new Map()), P(this, Bt, /* @__PURE__ */ new Map()), P(this, ze, 0);
3981
+ }
3982
+ mount() {
3983
+ wn(this, ze)._++, c(this, ze) === 1 && (P(this, jt, Mn.subscribe(() => {
3984
+ Mn.isFocused() && (this.resumePausedMutations(), c(this, re).onFocus());
3985
+ })), P(this, Rt, Ln.subscribe(() => {
3986
+ Ln.isOnline() && (this.resumePausedMutations(), c(this, re).onOnline());
3987
+ })));
3988
+ }
3989
+ unmount() {
3990
+ var e, t;
3991
+ wn(this, ze)._--, c(this, ze) === 0 && ((e = c(this, jt)) == null || e.call(this), P(this, jt, void 0), (t = c(this, Rt)) == null || t.call(this), P(this, Rt, void 0));
3992
+ }
3993
+ isFetching(e) {
3994
+ return c(this, re).findAll({ ...e, fetchStatus: "fetching" }).length;
3995
+ }
3996
+ isMutating(e) {
3997
+ return c(this, Ve).findAll({ ...e, status: "pending" }).length;
3998
+ }
3999
+ getQueryData(e) {
4000
+ var t;
4001
+ return (t = c(this, re).find({ queryKey: e })) == null ? void 0 : t.state.data;
4002
+ }
4003
+ ensureQueryData(e) {
4004
+ const t = this.getQueryData(e.queryKey);
4005
+ return t !== void 0 ? Promise.resolve(t) : this.fetchQuery(e);
4006
+ }
4007
+ getQueriesData(e) {
4008
+ return this.getQueryCache().findAll(e).map(({ queryKey: t, state: n }) => {
4009
+ const s = n.data;
4010
+ return [t, s];
4011
+ });
4012
+ }
4013
+ setQueryData(e, t, n) {
4014
+ const s = c(this, re).find({ queryKey: e }), r = s == null ? void 0 : s.state.data, o = Xu(t, r);
4015
+ if (typeof o > "u")
4016
+ return;
4017
+ const i = this.defaultQueryOptions({ queryKey: e });
4018
+ return c(this, re).build(this, i).setData(o, { ...n, manual: !0 });
4019
+ }
4020
+ setQueriesData(e, t, n) {
4021
+ return ae.batch(
4022
+ () => this.getQueryCache().findAll(e).map(({ queryKey: s }) => [
4023
+ s,
4024
+ this.setQueryData(s, t, n)
4025
+ ])
4026
+ );
4027
+ }
4028
+ getQueryState(e) {
4029
+ var t;
4030
+ return (t = c(this, re).find({ queryKey: e })) == null ? void 0 : t.state;
4031
+ }
4032
+ removeQueries(e) {
4033
+ const t = c(this, re);
4034
+ ae.batch(() => {
4035
+ t.findAll(e).forEach((n) => {
4036
+ t.remove(n);
4037
+ });
4038
+ });
4039
+ }
4040
+ resetQueries(e, t) {
4041
+ const n = c(this, re), s = {
4042
+ type: "active",
4043
+ ...e
4044
+ };
4045
+ return ae.batch(() => (n.findAll(e).forEach((r) => {
4046
+ r.reset();
4047
+ }), this.refetchQueries(s, t)));
4048
+ }
4049
+ cancelQueries(e = {}, t = {}) {
4050
+ const n = { revert: !0, ...t }, s = ae.batch(
4051
+ () => c(this, re).findAll(e).map((r) => r.cancel(n))
4052
+ );
4053
+ return Promise.all(s).then(ve).catch(ve);
4054
+ }
4055
+ invalidateQueries(e = {}, t = {}) {
4056
+ return ae.batch(() => {
4057
+ if (c(this, re).findAll(e).forEach((s) => {
4058
+ s.invalidate();
4059
+ }), e.refetchType === "none")
4060
+ return Promise.resolve();
4061
+ const n = {
4062
+ ...e,
4063
+ type: e.refetchType ?? e.type ?? "active"
4064
+ };
4065
+ return this.refetchQueries(n, t);
4066
+ });
4067
+ }
4068
+ refetchQueries(e = {}, t) {
4069
+ const n = {
4070
+ ...t,
4071
+ cancelRefetch: (t == null ? void 0 : t.cancelRefetch) ?? !0
4072
+ }, s = ae.batch(
4073
+ () => c(this, re).findAll(e).filter((r) => !r.isDisabled()).map((r) => {
4074
+ let o = r.fetch(void 0, n);
4075
+ return n.throwOnError || (o = o.catch(ve)), r.state.fetchStatus === "paused" ? Promise.resolve() : o;
4076
+ })
4077
+ );
4078
+ return Promise.all(s).then(ve);
4079
+ }
4080
+ fetchQuery(e) {
4081
+ const t = this.defaultQueryOptions(e);
4082
+ typeof t.retry > "u" && (t.retry = !1);
4083
+ const n = c(this, re).build(this, t);
4084
+ return n.isStaleByTime(t.staleTime) ? n.fetch(t) : Promise.resolve(n.state.data);
4085
+ }
4086
+ prefetchQuery(e) {
4087
+ return this.fetchQuery(e).then(ve).catch(ve);
4088
+ }
4089
+ fetchInfiniteQuery(e) {
4090
+ return e.behavior = ll(e.pages), this.fetchQuery(e);
4091
+ }
4092
+ prefetchInfiniteQuery(e) {
4093
+ return this.fetchInfiniteQuery(e).then(ve).catch(ve);
4094
+ }
4095
+ resumePausedMutations() {
4096
+ return c(this, Ve).resumePausedMutations();
4097
+ }
4098
+ getQueryCache() {
4099
+ return c(this, re);
4100
+ }
4101
+ getMutationCache() {
4102
+ return c(this, Ve);
4103
+ }
4104
+ getDefaultOptions() {
4105
+ return c(this, Ke);
4106
+ }
4107
+ setDefaultOptions(e) {
4108
+ P(this, Ke, e);
4109
+ }
4110
+ setQueryDefaults(e, t) {
4111
+ c(this, It).set(nn(e), {
4112
+ queryKey: e,
4113
+ defaultOptions: t
4114
+ });
4115
+ }
4116
+ getQueryDefaults(e) {
4117
+ const t = [...c(this, It).values()];
4118
+ let n = {};
4119
+ return t.forEach((s) => {
4120
+ sn(e, s.queryKey) && (n = { ...n, ...s.defaultOptions });
4121
+ }), n;
4122
+ }
4123
+ setMutationDefaults(e, t) {
4124
+ c(this, Bt).set(nn(e), {
4125
+ mutationKey: e,
4126
+ defaultOptions: t
4127
+ });
4128
+ }
4129
+ getMutationDefaults(e) {
4130
+ const t = [...c(this, Bt).values()];
4131
+ let n = {};
4132
+ return t.forEach((s) => {
4133
+ sn(e, s.mutationKey) && (n = { ...n, ...s.defaultOptions });
4134
+ }), n;
4135
+ }
4136
+ defaultQueryOptions(e) {
4137
+ if (e != null && e._defaulted)
4138
+ return e;
4139
+ const t = {
4140
+ ...c(this, Ke).queries,
4141
+ ...(e == null ? void 0 : e.queryKey) && this.getQueryDefaults(e.queryKey),
4142
+ ...e,
4143
+ _defaulted: !0
4144
+ };
4145
+ return t.queryHash || (t.queryHash = $s(
4146
+ t.queryKey,
4147
+ t
4148
+ )), typeof t.refetchOnReconnect > "u" && (t.refetchOnReconnect = t.networkMode !== "always"), typeof t.throwOnError > "u" && (t.throwOnError = !!t.suspense), typeof t.networkMode > "u" && t.persister && (t.networkMode = "offlineFirst"), t;
4149
+ }
4150
+ defaultMutationOptions(e) {
4151
+ return e != null && e._defaulted ? e : {
4152
+ ...c(this, Ke).mutations,
4153
+ ...(e == null ? void 0 : e.mutationKey) && this.getMutationDefaults(e.mutationKey),
4154
+ ...e,
4155
+ _defaulted: !0
4156
+ };
4157
+ }
4158
+ clear() {
4159
+ c(this, re).clear(), c(this, Ve).clear();
4160
+ }
4161
+ }, re = new WeakMap(), Ve = new WeakMap(), Ke = new WeakMap(), It = new WeakMap(), Bt = new WeakMap(), ze = new WeakMap(), jt = new WeakMap(), Rt = new WeakMap(), Jr), le, Z, Dt, ce, st, Mt, Ie, cn, Lt, Nt, rt, it, Ge, ot, at, Ht, un, ys, ln, vs, dn, bs, fn, ws, hn, Ss, pn, xs, mn, ks, Nn, ao, Xr, hl = (Xr = class extends vn {
4162
+ constructor(t, n) {
4163
+ super();
4164
+ L(this, at);
4165
+ L(this, un);
4166
+ L(this, ln);
4167
+ L(this, dn);
4168
+ L(this, fn);
4169
+ L(this, hn);
4170
+ L(this, pn);
4171
+ L(this, mn);
4172
+ L(this, Nn);
4173
+ L(this, le, void 0);
4174
+ L(this, Z, void 0);
4175
+ L(this, Dt, void 0);
4176
+ L(this, ce, void 0);
4177
+ L(this, st, void 0);
4178
+ L(this, Mt, void 0);
4179
+ L(this, Ie, void 0);
4180
+ L(this, cn, void 0);
4181
+ L(this, Lt, void 0);
4182
+ // This property keeps track of the last query with defined data.
4183
+ // It will be used to pass the previous data and query to the placeholder function between renders.
4184
+ L(this, Nt, void 0);
4185
+ L(this, rt, void 0);
4186
+ L(this, it, void 0);
4187
+ L(this, Ge, void 0);
4188
+ L(this, ot, void 0);
4189
+ P(this, Z, void 0), P(this, Dt, void 0), P(this, ce, void 0), P(this, ot, /* @__PURE__ */ new Set()), P(this, le, t), this.options = n, P(this, Ie, null), this.bindMethods(), this.setOptions(n);
4190
+ }
4191
+ bindMethods() {
4192
+ this.refetch = this.refetch.bind(this);
4193
+ }
4194
+ onSubscribe() {
4195
+ this.listeners.size === 1 && (c(this, Z).addObserver(this), qr(c(this, Z), this.options) ? K(this, at, Ht).call(this) : this.updateResult(), K(this, fn, ws).call(this));
4196
+ }
4197
+ onUnsubscribe() {
4198
+ this.hasListeners() || this.destroy();
4199
+ }
4200
+ shouldFetchOnReconnect() {
4201
+ return As(
4202
+ c(this, Z),
4203
+ this.options,
4204
+ this.options.refetchOnReconnect
4205
+ );
4206
+ }
4207
+ shouldFetchOnWindowFocus() {
4208
+ return As(
4209
+ c(this, Z),
4210
+ this.options,
4211
+ this.options.refetchOnWindowFocus
4212
+ );
4213
+ }
4214
+ destroy() {
4215
+ this.listeners = /* @__PURE__ */ new Set(), K(this, hn, Ss).call(this), K(this, pn, xs).call(this), c(this, Z).removeObserver(this);
4216
+ }
4217
+ setOptions(t, n) {
4218
+ const s = this.options, r = c(this, Z);
4219
+ if (this.options = c(this, le).defaultQueryOptions(t), ps(s, this.options) || c(this, le).getQueryCache().notify({
4220
+ type: "observerOptionsUpdated",
4221
+ query: c(this, Z),
4222
+ observer: this
4223
+ }), typeof this.options.enabled < "u" && typeof this.options.enabled != "boolean")
4224
+ throw new Error("Expected enabled to be a boolean");
4225
+ this.options.queryKey || (this.options.queryKey = s.queryKey), K(this, mn, ks).call(this);
4226
+ const o = this.hasListeners();
4227
+ o && $r(
4228
+ c(this, Z),
4229
+ r,
4230
+ this.options,
4231
+ s
4232
+ ) && K(this, at, Ht).call(this), this.updateResult(n), o && (c(this, Z) !== r || this.options.enabled !== s.enabled || this.options.staleTime !== s.staleTime) && K(this, un, ys).call(this);
4233
+ const i = K(this, ln, vs).call(this);
4234
+ o && (c(this, Z) !== r || this.options.enabled !== s.enabled || i !== c(this, Ge)) && K(this, dn, bs).call(this, i);
4235
+ }
4236
+ getOptimisticResult(t) {
4237
+ const n = c(this, le).getQueryCache().build(c(this, le), t), s = this.createResult(n, t);
4238
+ return ml(this, s) && (P(this, ce, s), P(this, Mt, this.options), P(this, st, c(this, Z).state)), s;
4239
+ }
4240
+ getCurrentResult() {
4241
+ return c(this, ce);
4242
+ }
4243
+ trackResult(t) {
4244
+ const n = {};
4245
+ return Object.keys(t).forEach((s) => {
4246
+ Object.defineProperty(n, s, {
4247
+ configurable: !1,
4248
+ enumerable: !0,
4249
+ get: () => (c(this, ot).add(s), t[s])
4250
+ });
4251
+ }), n;
4252
+ }
4253
+ getCurrentQuery() {
4254
+ return c(this, Z);
4255
+ }
4256
+ refetch({ ...t } = {}) {
4257
+ return this.fetch({
4258
+ ...t
4259
+ });
4260
+ }
4261
+ fetchOptimistic(t) {
4262
+ const n = c(this, le).defaultQueryOptions(t), s = c(this, le).getQueryCache().build(c(this, le), n);
4263
+ return s.isFetchingOptimistic = !0, s.fetch().then(() => this.createResult(s, n));
4264
+ }
4265
+ fetch(t) {
4266
+ return K(this, at, Ht).call(this, {
4267
+ ...t,
4268
+ cancelRefetch: t.cancelRefetch ?? !0
4269
+ }).then(() => (this.updateResult(), c(this, ce)));
4270
+ }
4271
+ createResult(t, n) {
4272
+ var F;
4273
+ const s = c(this, Z), r = this.options, o = c(this, ce), i = c(this, st), a = c(this, Mt), u = t !== s ? t.state : c(this, Dt), { state: f } = t;
4274
+ let { error: m, errorUpdatedAt: b, fetchStatus: g, status: O } = f, C = !1, y;
4275
+ if (n._optimisticResults) {
4276
+ const T = this.hasListeners(), R = !T && qr(t, n), p = T && $r(t, s, n, r);
4277
+ (R || p) && (g = Wn(t.options.networkMode) ? "fetching" : "paused", f.dataUpdatedAt || (O = "pending")), n._optimisticResults === "isRestoring" && (g = "idle");
4278
+ }
4279
+ if (n.select && typeof f.data < "u")
4280
+ if (o && f.data === (i == null ? void 0 : i.data) && n.select === c(this, cn))
4281
+ y = c(this, Lt);
4282
+ else
4283
+ try {
4284
+ P(this, cn, n.select), y = n.select(f.data), y = gs(o == null ? void 0 : o.data, y, n), P(this, Lt, y), P(this, Ie, null);
4285
+ } catch (T) {
4286
+ P(this, Ie, T);
4287
+ }
4288
+ else
4289
+ y = f.data;
4290
+ if (typeof n.placeholderData < "u" && typeof y > "u" && O === "pending") {
4291
+ let T;
4292
+ if (o != null && o.isPlaceholderData && n.placeholderData === (a == null ? void 0 : a.placeholderData))
4293
+ T = o.data;
4294
+ else if (T = typeof n.placeholderData == "function" ? n.placeholderData(
4295
+ (F = c(this, Nt)) == null ? void 0 : F.state.data,
4296
+ c(this, Nt)
4297
+ ) : n.placeholderData, n.select && typeof T < "u")
4298
+ try {
4299
+ T = n.select(T), P(this, Ie, null);
4300
+ } catch (R) {
4301
+ P(this, Ie, R);
4302
+ }
4303
+ typeof T < "u" && (O = "success", y = gs(
4304
+ o == null ? void 0 : o.data,
4305
+ T,
4306
+ n
4307
+ ), C = !0);
4308
+ }
4309
+ c(this, Ie) && (m = c(this, Ie), y = c(this, Lt), b = Date.now(), O = "error");
4310
+ const A = g === "fetching", D = O === "pending", j = O === "error", x = D && A;
4311
+ return {
4312
+ status: O,
4313
+ fetchStatus: g,
4314
+ isPending: D,
4315
+ isSuccess: O === "success",
4316
+ isError: j,
4317
+ isInitialLoading: x,
4318
+ isLoading: x,
4319
+ data: y,
4320
+ dataUpdatedAt: f.dataUpdatedAt,
4321
+ error: m,
4322
+ errorUpdatedAt: b,
4323
+ failureCount: f.fetchFailureCount,
4324
+ failureReason: f.fetchFailureReason,
4325
+ errorUpdateCount: f.errorUpdateCount,
4326
+ isFetched: f.dataUpdateCount > 0 || f.errorUpdateCount > 0,
4327
+ isFetchedAfterMount: f.dataUpdateCount > u.dataUpdateCount || f.errorUpdateCount > u.errorUpdateCount,
4328
+ isFetching: A,
4329
+ isRefetching: A && !D,
4330
+ isLoadingError: j && f.dataUpdatedAt === 0,
4331
+ isPaused: g === "paused",
4332
+ isPlaceholderData: C,
4333
+ isRefetchError: j && f.dataUpdatedAt !== 0,
4334
+ isStale: Qs(t, n),
4335
+ refetch: this.refetch
4336
+ };
4337
+ }
4338
+ updateResult(t) {
4339
+ const n = c(this, ce), s = this.createResult(c(this, Z), this.options);
4340
+ if (P(this, st, c(this, Z).state), P(this, Mt, this.options), c(this, st).data !== void 0 && P(this, Nt, c(this, Z)), ps(s, n))
4341
+ return;
4342
+ P(this, ce, s);
4343
+ const r = {}, o = () => {
4344
+ if (!n)
4345
+ return !0;
4346
+ const { notifyOnChangeProps: i } = this.options, a = typeof i == "function" ? i() : i;
4347
+ if (a === "all" || !a && !c(this, ot).size)
4348
+ return !0;
4349
+ const d = new Set(
4350
+ a ?? c(this, ot)
4351
+ );
4352
+ return this.options.throwOnError && d.add("error"), Object.keys(c(this, ce)).some((u) => {
4353
+ const f = u;
4354
+ return c(this, ce)[f] !== n[f] && d.has(f);
4355
+ });
4356
+ };
4357
+ (t == null ? void 0 : t.listeners) !== !1 && o() && (r.listeners = !0), K(this, Nn, ao).call(this, { ...r, ...t });
4358
+ }
4359
+ onQueryUpdate() {
4360
+ this.updateResult(), this.hasListeners() && K(this, fn, ws).call(this);
4361
+ }
4362
+ }, le = new WeakMap(), Z = new WeakMap(), Dt = new WeakMap(), ce = new WeakMap(), st = new WeakMap(), Mt = new WeakMap(), Ie = new WeakMap(), cn = new WeakMap(), Lt = new WeakMap(), Nt = new WeakMap(), rt = new WeakMap(), it = new WeakMap(), Ge = new WeakMap(), ot = new WeakMap(), at = new WeakSet(), Ht = function(t) {
4363
+ K(this, mn, ks).call(this);
4364
+ let n = c(this, Z).fetch(
4365
+ this.options,
4366
+ t
4367
+ );
4368
+ return t != null && t.throwOnError || (n = n.catch(ve)), n;
4369
+ }, un = new WeakSet(), ys = function() {
4370
+ if (K(this, hn, Ss).call(this), qt || c(this, ce).isStale || !hs(this.options.staleTime))
4371
+ return;
4372
+ const n = to(
4373
+ c(this, ce).dataUpdatedAt,
4374
+ this.options.staleTime
4375
+ ) + 1;
4376
+ P(this, rt, setTimeout(() => {
4377
+ c(this, ce).isStale || this.updateResult();
4378
+ }, n));
4379
+ }, ln = new WeakSet(), vs = function() {
4380
+ return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(c(this, Z)) : this.options.refetchInterval) ?? !1;
4381
+ }, dn = new WeakSet(), bs = function(t) {
4382
+ K(this, pn, xs).call(this), P(this, Ge, t), !(qt || this.options.enabled === !1 || !hs(c(this, Ge)) || c(this, Ge) === 0) && P(this, it, setInterval(() => {
4383
+ (this.options.refetchIntervalInBackground || Mn.isFocused()) && K(this, at, Ht).call(this);
4384
+ }, c(this, Ge)));
4385
+ }, fn = new WeakSet(), ws = function() {
4386
+ K(this, un, ys).call(this), K(this, dn, bs).call(this, K(this, ln, vs).call(this));
4387
+ }, hn = new WeakSet(), Ss = function() {
4388
+ c(this, rt) && (clearTimeout(c(this, rt)), P(this, rt, void 0));
4389
+ }, pn = new WeakSet(), xs = function() {
4390
+ c(this, it) && (clearInterval(c(this, it)), P(this, it, void 0));
4391
+ }, mn = new WeakSet(), ks = function() {
4392
+ const t = c(this, le).getQueryCache().build(c(this, le), this.options);
4393
+ if (t === c(this, Z))
4394
+ return;
4395
+ const n = c(this, Z);
4396
+ P(this, Z, t), P(this, Dt, t.state), this.hasListeners() && (n == null || n.removeObserver(this), t.addObserver(this));
4397
+ }, Nn = new WeakSet(), ao = function(t) {
4398
+ ae.batch(() => {
4399
+ t.listeners && this.listeners.forEach((n) => {
4400
+ n(c(this, ce));
4401
+ }), c(this, le).getQueryCache().notify({
4402
+ query: c(this, Z),
4403
+ type: "observerResultsUpdated"
4404
+ });
4405
+ });
4406
+ }, Xr);
4407
+ function pl(e, t) {
4408
+ return t.enabled !== !1 && !e.state.dataUpdatedAt && !(e.state.status === "error" && t.retryOnMount === !1);
4409
+ }
4410
+ function qr(e, t) {
4411
+ return pl(e, t) || e.state.dataUpdatedAt > 0 && As(e, t, t.refetchOnMount);
4412
+ }
4413
+ function As(e, t, n) {
4414
+ if (t.enabled !== !1) {
4415
+ const s = typeof n == "function" ? n(e) : n;
4416
+ return s === "always" || s !== !1 && Qs(e, t);
4417
+ }
4418
+ return !1;
4419
+ }
4420
+ function $r(e, t, n, s) {
4421
+ return n.enabled !== !1 && (e !== t || s.enabled === !1) && (!n.suspense || e.state.status !== "error") && Qs(e, n);
4422
+ }
4423
+ function Qs(e, t) {
4424
+ return e.isStaleByTime(t.staleTime);
4425
+ }
4426
+ function ml(e, t) {
4427
+ return !ps(e.getCurrentResult(), t);
4428
+ }
4429
+ var co = pe.createContext(
4430
+ void 0
4431
+ ), Hn = (e) => {
4432
+ const t = pe.useContext(co);
4433
+ if (e)
4434
+ return e;
4435
+ if (!t)
4436
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
4437
+ return t;
4438
+ }, gl = ({
4439
+ client: e,
4440
+ children: t
4441
+ }) => (pe.useEffect(() => (e.mount(), () => {
4442
+ e.unmount();
4443
+ }), [e]), /* @__PURE__ */ pe.createElement(co.Provider, { value: e }, t)), uo = pe.createContext(!1), yl = () => pe.useContext(uo);
4444
+ uo.Provider;
4445
+ function vl() {
4446
+ let e = !1;
4447
+ return {
4448
+ clearReset: () => {
4449
+ e = !1;
4450
+ },
4451
+ reset: () => {
4452
+ e = !0;
4453
+ },
4454
+ isReset: () => e
4455
+ };
4456
+ }
4457
+ var bl = pe.createContext(vl()), wl = () => pe.useContext(bl);
4458
+ function Sl(e, t) {
4459
+ return typeof e == "function" ? e(...t) : !!e;
4460
+ }
4461
+ var xl = (e, t) => {
4462
+ (e.suspense || e.throwOnError) && (t.isReset() || (e.retryOnMount = !1));
4463
+ }, kl = (e) => {
4464
+ pe.useEffect(() => {
4465
+ e.clearReset();
4466
+ }, [e]);
4467
+ }, Al = ({
4468
+ result: e,
4469
+ errorResetBoundary: t,
4470
+ throwOnError: n,
4471
+ query: s
4472
+ }) => e.isError && !t.isReset() && !e.isFetching && Sl(n, [e.error, s]), El = (e) => {
4473
+ e.suspense && typeof e.staleTime != "number" && (e.staleTime = 1e3);
4474
+ }, Pl = (e, t) => (e == null ? void 0 : e.suspense) && t.isPending, Ol = (e, t, n) => t.fetchOptimistic(e).catch(() => {
4475
+ n.clearReset();
4476
+ });
4477
+ function _l(e, t, n) {
4478
+ if (process.env.NODE_ENV !== "production" && (typeof e != "object" || Array.isArray(e)))
4479
+ throw new Error(
4480
+ 'Bad argument type. Starting with v5, only the "Object" form is allowed when calling query related functions. Please use the error stack to find the culprit call. More info here: https://tanstack.com/query/latest/docs/react/guides/migrating-to-v5#supports-a-single-signature-one-object'
4481
+ );
4482
+ const s = Hn(n), r = yl(), o = wl(), i = s.defaultQueryOptions(e);
4483
+ i._optimisticResults = r ? "isRestoring" : "optimistic", El(i), xl(i, o), kl(o);
4484
+ const [a] = pe.useState(
4485
+ () => new t(
4486
+ s,
4487
+ i
4488
+ )
4489
+ ), d = a.getOptimisticResult(i);
4490
+ if (pe.useSyncExternalStore(
4491
+ pe.useCallback(
4492
+ (u) => {
4493
+ const f = r ? () => {
4494
+ } : a.subscribe(ae.batchCalls(u));
4495
+ return a.updateResult(), f;
4496
+ },
4497
+ [a, r]
4498
+ ),
4499
+ () => a.getCurrentResult(),
4500
+ () => a.getCurrentResult()
4501
+ ), pe.useEffect(() => {
4502
+ a.setOptions(i, { listeners: !1 });
4503
+ }, [i, a]), Pl(i, d))
4504
+ throw Ol(i, a, o);
4505
+ if (Al({
4506
+ result: d,
4507
+ errorResetBoundary: o,
4508
+ throwOnError: i.throwOnError,
4509
+ query: a.getCurrentQuery()
4510
+ }))
4511
+ throw d.error;
4512
+ return i.notifyOnChangeProps ? d : a.trackResult(d);
4513
+ }
4514
+ function Jn(e, t) {
4515
+ return _l(e, hl, t);
4516
+ }
4517
+ const Cl = () => Jn({
4518
+ queryKey: ["user"],
4519
+ queryFn: async () => await localStorage.getItem("__nano_id")
4520
+ }), Il = () => /* @__PURE__ */ _.jsx("section", { className: "py-10 h-screen bg-gray-50 sm:py-16 lg:py-24", children: /* @__PURE__ */ _.jsxs("div", { className: "px-4 mx-auto max-w-7xl sm:px-6 lg:px-8", children: [
4521
+ /* @__PURE__ */ _.jsxs("div", { className: "max-w-2xl mx-auto text-center", children: [
4522
+ /* @__PURE__ */ _.jsx("h2", { className: "text-3xl font-bold leading-tight text-black sm:text-4xl lg:text-5xl", children: "Welcome Back!" }),
4523
+ /* @__PURE__ */ _.jsx("p", { className: "max-w-xl mx-auto mt-4 text-base leading-relaxed text-gray-600", children: "Login to your account" })
4524
+ ] }),
4525
+ /* @__PURE__ */ _.jsx("div", { className: "relative max-w-md mx-auto mt-8 md:mt-16", children: /* @__PURE__ */ _.jsx("div", { className: "overflow-hidden bg-white rounded-md shadow-md", children: /* @__PURE__ */ _.jsx("div", { className: "px-4 py-6 sm:px-8 sm:py-7", children: /* @__PURE__ */ _.jsx("form", { action: "#", method: "POST", children: /* @__PURE__ */ _.jsxs("div", { className: "space-y-5", children: [
4526
+ /* @__PURE__ */ _.jsxs("div", { children: [
4527
+ /* @__PURE__ */ _.jsx("label", { htmlFor: "", className: "text-base font-medium text-gray-900", children: "Email address" }),
4528
+ /* @__PURE__ */ _.jsxs("div", { className: "mt-2.5 relative text-gray-400 focus-within:text-gray-600", children: [
4529
+ /* @__PURE__ */ _.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none", children: /* @__PURE__ */ _.jsx(
4530
+ "svg",
4531
+ {
4532
+ className: "w-5 h-5",
4533
+ xmlns: "http://www.w3.org/2000/svg",
4534
+ fill: "none",
4535
+ viewBox: "0 0 24 24",
4536
+ stroke: "currentColor",
4537
+ children: /* @__PURE__ */ _.jsx(
4538
+ "path",
4539
+ {
4540
+ strokeLinecap: "round",
4541
+ strokeLinejoin: "round",
4542
+ strokeWidth: "2",
4543
+ d: "M16 12a4 4 0 10-8 0 4 4 0 008 0zm0 0v1.5a2.5 2.5 0 005 0V12a9 9 0 10-9 9m4.5-1.206a8.959 8.959 0 01-4.5 1.207"
4544
+ }
4545
+ )
4546
+ }
4547
+ ) }),
4548
+ /* @__PURE__ */ _.jsx(
4549
+ "input",
4550
+ {
4551
+ type: "email",
4552
+ name: "",
4553
+ id: "",
4554
+ placeholder: "Enter email to get started",
4555
+ className: "block w-full py-4 pl-10 pr-4 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"
4556
+ }
4557
+ )
4558
+ ] })
4559
+ ] }),
4560
+ /* @__PURE__ */ _.jsxs("div", { children: [
4561
+ /* @__PURE__ */ _.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ _.jsx("label", { htmlFor: "", className: "text-base font-medium text-gray-900", children: "Password" }) }),
4562
+ /* @__PURE__ */ _.jsxs("div", { className: "mt-2.5 relative text-gray-400 focus-within:text-gray-600", children: [
4563
+ /* @__PURE__ */ _.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none", children: /* @__PURE__ */ _.jsx(
4564
+ "svg",
4565
+ {
4566
+ className: "w-5 h-5",
4567
+ xmlns: "http://www.w3.org/2000/svg",
4568
+ fill: "none",
4569
+ viewBox: "0 0 24 24",
4570
+ stroke: "currentColor",
4571
+ children: /* @__PURE__ */ _.jsx(
4572
+ "path",
4573
+ {
4574
+ strokeLinecap: "round",
4575
+ strokeLinejoin: "round",
4576
+ strokeWidth: "2",
4577
+ d: "M12 11c0 3.517-1.009 6.799-2.753 9.571m-3.44-2.04l.054-.09A13.916 13.916 0 008 11a4 4 0 118 0c0 1.017-.07 2.019-.203 3m-2.118 6.844A21.88 21.88 0 0015.171 17m3.839 1.132c.645-2.266.99-4.659.99-7.132A8 8 0 008 4.07M3 15.364c.64-1.319 1-2.8 1-4.364 0-1.457.39-2.823 1.07-4"
4578
+ }
4579
+ )
4580
+ }
4581
+ ) }),
4582
+ /* @__PURE__ */ _.jsx(
4583
+ "input",
4584
+ {
4585
+ type: "password",
4586
+ name: "",
4587
+ id: "",
4588
+ placeholder: "Enter your password",
4589
+ className: "block w-full py-4 pl-10 pr-4 text-black placeholder-gray-500 transition-all duration-200 bg-white border border-gray-200 rounded-md focus:outline-none focus:border-blue-600 caret-blue-600"
4590
+ }
4591
+ )
4592
+ ] })
4593
+ ] }),
4594
+ /* @__PURE__ */ _.jsx("div", { children: /* @__PURE__ */ _.jsx(
4595
+ "button",
4596
+ {
4597
+ type: "submit",
4598
+ className: "inline-flex items-center justify-center w-full px-4 py-4 text-base font-semibold text-white transition-all duration-200 bg-blue-600 border border-transparent rounded-md focus:outline-none hover:bg-blue-700 focus:bg-blue-700",
4599
+ children: "Log in"
4600
+ }
4601
+ ) })
4602
+ ] }) }) }) }) })
4603
+ ] }) });
4604
+ function Vs() {
4605
+ return Hn().getQueryData(["apiBaseUrl"]) || "/api/chaibuilder";
4606
+ }
4607
+ const lo = () => {
4608
+ const e = Hn();
4609
+ let t = e.getQueryData(["currentPage"]);
4610
+ return t || (t = localStorage.getItem("currentPage")), [
4611
+ t || "",
4612
+ (n) => {
4613
+ localStorage.setItem("currentPage", n), e.setQueryData(["currentPage"], n);
4614
+ }
4615
+ ];
4616
+ }, Ks = () => {
4617
+ const [e, t] = lo(), n = Vs();
4618
+ return Jn({
4619
+ queryKey: ["project"],
4620
+ queryFn: async () => {
4621
+ const s = await fetch(`${n}/project`).then((r) => r.json());
4622
+ return !e && s && t(s.homepage), s;
4623
+ }
4624
+ });
4625
+ }, Bl = () => {
4626
+ const { data: e } = Ks(), t = Vs(), n = e == null ? void 0 : e.uuid;
4627
+ return Jn({
4628
+ queryKey: ["pages", n],
4629
+ queryFn: async () => await fetch(`${t}/pages`).then((r) => r.json()) || [],
4630
+ enabled: !!n
4631
+ });
4632
+ }, jl = () => {
4633
+ const [e, t] = lo(), { data: n } = Ks(), s = Vs();
4634
+ return Jn({
4635
+ queryKey: ["page_data", e],
4636
+ queryFn: async () => {
4637
+ const r = await fetch(`${s}/page?uuid=${e}`);
4638
+ return r.ok ? r.json() : (t(n.homepage), null);
4639
+ },
4640
+ enabled: !!e
4641
+ });
4642
+ }, Rl = $t(() => import("./PagesPanel-0827c264.js")), Dl = $t(() => import("./ProjectPanel-e577029a.js")), Ml = () => {
4643
+ const { data: e, isLoading: t } = Ks(), { data: n, isLoading: s } = Bl(), { data: r } = jl();
4644
+ return t || !e ? /* @__PURE__ */ _.jsx("div", { children: "Loading..." }) : s || !n ? /* @__PURE__ */ _.jsx("div", { children: "Loading..." }) : r ? /* @__PURE__ */ _.jsx("div", { className: "bg-background text-foreground", children: /* @__PURE__ */ _.jsx(
4645
+ Ju,
4646
+ {
4647
+ blocks: r.blocks,
4648
+ brandingOptions: e.brandingOptions,
4649
+ darkMode: !0,
4650
+ onSaveBlocks: async () => {
4651
+ },
4652
+ onSaveBrandingOptions: async () => {
4653
+ },
4654
+ sideBarComponents: {
4655
+ top: [
4656
+ { icon: Fo, name: "pages", panel: Rl },
4657
+ { icon: Uo, name: "settings", panel: Dl }
4658
+ ]
4659
+ }
4660
+ }
4661
+ ) }) : /* @__PURE__ */ _.jsx("div", { children: "Loading..." });
4662
+ }, Ll = (e) => {
4663
+ const { data: t } = Cl(), n = Hn();
4664
+ return ke(() => {
4665
+ n.setQueryData(["apiBaseUrl"], e.apiBaseUrl || "/api/chaibuilder");
4666
+ }, [e.apiBaseUrl, n]), t ? /* @__PURE__ */ _.jsx(Ml, {}) : /* @__PURE__ */ _.jsx(Il, {});
4667
+ }, Nl = new fl(), Fd = (e) => /* @__PURE__ */ _.jsx(gl, { client: Nl, children: /* @__PURE__ */ _.jsx(Ll, { ...e }) }), Ud = (e) => ({ ...e }), qd = (e) => ({ ...e });
4668
+ export {
4669
+ cl as $,
4670
+ ud as A,
4671
+ ec as B,
4672
+ Pd as C,
4673
+ _c as D,
4674
+ Jo as E,
4675
+ rr as F,
4676
+ sr as G,
4677
+ dd as H,
4678
+ Sd as I,
4679
+ Ad as J,
4680
+ kd as K,
4681
+ cd as L,
4682
+ Wa as M,
4683
+ Bl as N,
4684
+ Ks as O,
4685
+ yd as P,
4686
+ ld as Q,
4687
+ Td as R,
4688
+ ad as S,
4689
+ Dd as T,
4690
+ nc as U,
4691
+ sc as V,
4692
+ vd as W,
4693
+ Hn as X,
4694
+ Vs as Y,
4695
+ vn as Z,
4696
+ ps as _,
4697
+ tc as a,
4698
+ ae as a0,
4699
+ Sl as a1,
4700
+ lo as a2,
4701
+ xc as a3,
4702
+ Ud as a4,
4703
+ qd as a5,
4704
+ Ju as a6,
4705
+ _d as a7,
4706
+ Od as a8,
4707
+ li as a9,
4708
+ Qa as aa,
4709
+ gd as ab,
4710
+ xi as ac,
4711
+ bd as ad,
4712
+ wd as ae,
4713
+ jd as af,
4714
+ xd as ag,
4715
+ rc as ah,
4716
+ rd as ai,
4717
+ Ed as aj,
4718
+ Cd as ak,
4719
+ Id as al,
4720
+ Md as am,
4721
+ Ld as an,
4722
+ Nd as ao,
4723
+ Fd as ap,
4724
+ Pa as b,
4725
+ $n as c,
4726
+ md as d,
4727
+ hd as e,
4728
+ Bd as f,
4729
+ Oa as g,
4730
+ mt as h,
4731
+ mi as i,
4732
+ Rd as j,
4733
+ pd as k,
4734
+ Ci as l,
4735
+ Oi as m,
4736
+ oc as n,
4737
+ fc as o,
4738
+ gi as p,
4739
+ pc as q,
4740
+ Ga as r,
4741
+ Xa as s,
4742
+ id as t,
4743
+ fd as u,
4744
+ od as v,
4745
+ yi as w,
4746
+ lc as x,
4747
+ Ma as y,
4748
+ Ha as z
4749
+ };