@chaibuilder/sdk 1.2.50 → 1.2.52

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 (88) hide show
  1. package/dist/{AddBlocks-IX7HKzSe.js → AddBlocks-GxEmM16E.js} +18 -18
  2. package/dist/{AddBlocks-zwZ63DdP.cjs → AddBlocks-fozauzIV.cjs} +1 -1
  3. package/dist/CanvasArea-NRtblq5d.cjs +56 -0
  4. package/dist/{CanvasArea-ehmBje_E.js → CanvasArea-rdY6SFYn.js} +57 -57
  5. package/dist/{ChaiBuilderEditor-ZRHqW7Gd.cjs → ChaiBuilderEditor-Pga_zJgw.cjs} +55 -55
  6. package/dist/{ChaiBuilderEditor-3xIN-AP_.js → ChaiBuilderEditor-bNZZWYMh.js} +14537 -14544
  7. package/dist/CodeEditor-tqtgia3I.js +115 -0
  8. package/dist/CodeEditor-ye3IXW3i.cjs +1 -0
  9. package/dist/{CurrentPage-qhBjm7th.js → CurrentPage-7NM90y76.js} +8 -8
  10. package/dist/{CurrentPage-HOPNdQZ-.cjs → CurrentPage-sx7KVTmt.cjs} +1 -1
  11. package/dist/ListTree-7Pz6H6eE.cjs +1 -0
  12. package/dist/ListTree-oRbeDNod.js +25724 -0
  13. package/dist/{PagesPanel-kdl4A0IN.cjs → PagesPanel-Nr-908vy.cjs} +1 -1
  14. package/dist/{PagesPanel-5iVsbDP1.js → PagesPanel-XiTUaiq_.js} +5 -5
  15. package/dist/{ProjectPanel-mXPBI-TU.cjs → ProjectPanel-SuFYN60H.cjs} +1 -1
  16. package/dist/{ProjectPanel-c8oTzhQd.js → ProjectPanel-XfknsGkz.js} +5 -5
  17. package/dist/Settings-22Hy7jUT.cjs +1 -0
  18. package/dist/{Settings-0uSGoECC.js → Settings-dJ72rwnH.js} +408 -401
  19. package/dist/{SidePanels-kKram02Q.cjs → SidePanels-5dnRAsJh.cjs} +1 -1
  20. package/dist/{SidePanels-YLWdBer9.js → SidePanels-t9oUA51J.js} +38 -38
  21. package/dist/{ThemeConfiguration-8W1CM4tW.cjs → ThemeConfiguration-2Sbh29qi.cjs} +1 -1
  22. package/dist/{ThemeConfiguration-AAGFJieC.js → ThemeConfiguration-pcHbYiIP.js} +9 -9
  23. package/dist/{Topbar-nX9Muoem.js → Topbar-0DmS6VpB.js} +4 -4
  24. package/dist/{Topbar-CLNUPx7K.cjs → Topbar-ID6Ipphd.cjs} +1 -1
  25. package/dist/{UILibrariesPanel-fKn2nlgI.js → UILibrariesPanel-G9J4KUsZ.js} +6 -6
  26. package/dist/{UILibrariesPanel-cp0Mkaq_.cjs → UILibrariesPanel-sXY6hozJ.cjs} +1 -1
  27. package/dist/{UnsplashImages-56HoW_ZA.cjs → UnsplashImages-HK4_1VVL.cjs} +1 -1
  28. package/dist/{UnsplashImages-zTZa3LjG.js → UnsplashImages-MeS5Cu7a.js} +4 -4
  29. package/dist/{UploadImages-SnfaTrlz.js → UploadImages-AIKATqfP.js} +2 -2
  30. package/dist/{UploadImages-okNGjkXb.cjs → UploadImages-LSnxByGV.cjs} +1 -1
  31. package/dist/{add-page-modal-uDoO0zws.js → add-page-modal-JkD45moJ.js} +9 -9
  32. package/dist/{add-page-modal-Y2RY3x01.cjs → add-page-modal-krxKdX7-.cjs} +1 -1
  33. package/dist/{confirm-alert-aD7AMK_6.cjs → confirm-alert--QTC21Z2.cjs} +1 -1
  34. package/dist/{confirm-alert-9XiVxCc0.js → confirm-alert-NHxthdRK.js} +2 -2
  35. package/dist/core.cjs +1 -1
  36. package/dist/core.d.ts +9 -0
  37. package/dist/core.js +32 -31
  38. package/dist/{delete-page-modal-7sfoFf9r.js → delete-page-modal-8rjPEchH.js} +4 -4
  39. package/dist/{delete-page-modal-ieJ367JA.cjs → delete-page-modal-BIe0kYNH.cjs} +1 -1
  40. package/dist/email.cjs +1 -1
  41. package/dist/email.js +2 -2
  42. package/dist/{form-KWYHDVIf.cjs → form-6OLp5uEG.cjs} +1 -1
  43. package/dist/{form-PQSmqcIl.js → form-PQYPrD_Q.js} +5 -5
  44. package/dist/functions--tdNWQDW.js +30 -0
  45. package/dist/functions-EVUeSwX1.cjs +1 -0
  46. package/dist/html-to-json-9uiQ2Dp2.cjs +1 -0
  47. package/dist/html-to-json-ofq1N3tB.js +186 -0
  48. package/dist/index--mLLy7QQ.cjs +1 -0
  49. package/dist/index-9_b2eou7.js +2201 -0
  50. package/dist/index-VBXQixVm.js +117 -0
  51. package/dist/index-seU0_UZX.cjs +1 -0
  52. package/dist/lib.cjs +1 -1
  53. package/dist/lib.js +11 -11
  54. package/dist/{page-viewer-aoro5JxT.cjs → page-viewer-WwwMC1Kq.cjs} +1 -1
  55. package/dist/{page-viewer-qkwZJ6e-.js → page-viewer-sKluQ_e1.js} +10 -10
  56. package/dist/{project-general-setting-3gkaXq1F.js → project-general-setting-Lc2ByvTt.js} +7 -7
  57. package/dist/{project-general-setting-arXitV5_.cjs → project-general-setting-pRO1ikDV.cjs} +1 -1
  58. package/dist/{project-seo-setting-X8pykTmc.js → project-seo-setting-530_6o9S.js} +3 -3
  59. package/dist/{project-seo-setting-kjtUt-er.cjs → project-seo-setting-BzSrXFVv.cjs} +1 -1
  60. package/dist/render.cjs +1 -1
  61. package/dist/render.js +2 -2
  62. package/dist/{single-page-detail-UsWG0gfh.cjs → single-page-detail-_VP4zaCI.cjs} +1 -1
  63. package/dist/{single-page-detail-ZXZX6Xmw.js → single-page-detail-qDxxtedN.js} +6 -6
  64. package/dist/studio.cjs +1 -1
  65. package/dist/studio.js +4 -4
  66. package/dist/ui.cjs +1 -1
  67. package/dist/ui.js +98 -98
  68. package/dist/useCanvasSettings-5y2fSCpN.js +6 -0
  69. package/dist/useCanvasSettings-pURFQG4q.cjs +1 -0
  70. package/dist/web-blocks.cjs +1 -1
  71. package/dist/web-blocks.js +320 -320
  72. package/package.json +3 -2
  73. package/dist/CanvasArea-URgoG1jc.cjs +0 -56
  74. package/dist/CodeEditor-0F7Dz3AB.js +0 -97
  75. package/dist/CodeEditor-1vu-qNgT.cjs +0 -1
  76. package/dist/ListTree-DkbFFDXB.cjs +0 -1
  77. package/dist/ListTree-sTwXvXST.js +0 -409
  78. package/dist/Settings-3kBSStO6.cjs +0 -1
  79. package/dist/functions-JO0EW8GX.js +0 -30
  80. package/dist/functions-ZZVUnIjD.cjs +0 -1
  81. package/dist/html-to-json-GJ6RioQf.js +0 -221
  82. package/dist/html-to-json-O1OpqICe.cjs +0 -1
  83. package/dist/index-VOrp9ZpX.cjs +0 -1
  84. package/dist/index-YpnaudSM.js +0 -63
  85. package/dist/index-ecnGWzh9.cjs +0 -1
  86. package/dist/index-i2kgLkjC.js +0 -2201
  87. package/dist/useCodeEditor-CtjbxWLf.cjs +0 -1
  88. package/dist/useCodeEditor-yl5V3Hte.js +0 -7
@@ -0,0 +1,2201 @@
1
+ var z2 = (h, t, a) => {
2
+ if (!t.has(h))
3
+ throw TypeError("Cannot " + a);
4
+ };
5
+ var l = (h, t, a) => (z2(h, t, "read from private field"), a ? a.call(h) : t.get(h)), e = (h, t, a) => {
6
+ if (t.has(h))
7
+ throw TypeError("Cannot add the same private member more than once");
8
+ t instanceof WeakSet ? t.add(h) : t.set(h, a);
9
+ }, d = (h, t, a, c) => (z2(h, t, "write to private field"), c ? c.call(h, a) : t.set(h, a), a);
10
+ var c2 = (h, t, a, c) => ({
11
+ set _(i) {
12
+ d(h, t, i, a);
13
+ },
14
+ get _() {
15
+ return l(h, t, c);
16
+ }
17
+ }), M = (h, t, a) => (z2(h, t, "access private method"), a);
18
+ import { j as r } from "./jsx-runtime-WbnYoNE9.js";
19
+ import * as b from "react";
20
+ import H0, { lazy as A2, useCallback as g2, useState as o2, Suspense as u0, useEffect as s0 } from "react";
21
+ import "./core.js";
22
+ import { FileTextIcon as p0, GearIcon as V0, EyeClosedIcon as f0, EyeOpenIcon as m0 } from "@radix-ui/react-icons";
23
+ import { u as L0, B as Y2, A as x0, a as w0, b as B0, c as C0, d as O0, e as A0, f as S0, g as y0, h as b0, C as P0 } from "./ChaiBuilderEditor-bNZZWYMh.js";
24
+ import { toast as a1, Toaster as F0 } from "sonner";
25
+ import { useTranslation as k0 } from "react-i18next";
26
+ import { sortBy as R0, filter as D0, has as T0, set as E0, capitalize as N0, get as b2, omit as I0, size as P2 } from "lodash-es";
27
+ import { g as W0 } from "./html-to-json-ofq1N3tB.js";
28
+ import { Loader as U0, Loader2 as j0, LogOutIcon as Q0 } from "lucide-react";
29
+ import { G as X2 } from "./index-VBXQixVm.js";
30
+ var N1 = class {
31
+ constructor() {
32
+ this.listeners = /* @__PURE__ */ new Set(), this.subscribe = this.subscribe.bind(this);
33
+ }
34
+ subscribe(h) {
35
+ return this.listeners.add(h), this.onSubscribe(), () => {
36
+ this.listeners.delete(h), this.onUnsubscribe();
37
+ };
38
+ }
39
+ hasListeners() {
40
+ return this.listeners.size > 0;
41
+ }
42
+ onSubscribe() {
43
+ }
44
+ onUnsubscribe() {
45
+ }
46
+ }, E1 = typeof window > "u" || "Deno" in window;
47
+ function K() {
48
+ }
49
+ function K0(h, t) {
50
+ return typeof h == "function" ? h(t) : h;
51
+ }
52
+ function H2(h) {
53
+ return typeof h == "number" && h >= 0 && h !== 1 / 0;
54
+ }
55
+ function t0(h, t) {
56
+ return Math.max(h + (t || 0) - Date.now(), 0);
57
+ }
58
+ function F2(h, t) {
59
+ const {
60
+ type: a = "all",
61
+ exact: c,
62
+ fetchStatus: i,
63
+ predicate: v,
64
+ queryKey: n,
65
+ stale: g
66
+ } = h;
67
+ if (n) {
68
+ if (c) {
69
+ if (t.queryHash !== S2(n, t.options))
70
+ return !1;
71
+ } else if (!U1(t.queryKey, n))
72
+ return !1;
73
+ }
74
+ if (a !== "all") {
75
+ const s = t.isActive();
76
+ if (a === "active" && !s || a === "inactive" && s)
77
+ return !1;
78
+ }
79
+ return !(typeof g == "boolean" && t.isStale() !== g || typeof i < "u" && i !== t.state.fetchStatus || v && !v(t));
80
+ }
81
+ function k2(h, t) {
82
+ const { exact: a, status: c, predicate: i, mutationKey: v } = h;
83
+ if (v) {
84
+ if (!t.options.mutationKey)
85
+ return !1;
86
+ if (a) {
87
+ if (W1(t.options.mutationKey) !== W1(v))
88
+ return !1;
89
+ } else if (!U1(t.options.mutationKey, v))
90
+ return !1;
91
+ }
92
+ return !(c && t.state.status !== c || i && !i(t));
93
+ }
94
+ function S2(h, t) {
95
+ return ((t == null ? void 0 : t.queryKeyHashFn) || W1)(h);
96
+ }
97
+ function W1(h) {
98
+ return JSON.stringify(
99
+ h,
100
+ (t, a) => u2(a) ? Object.keys(a).sort().reduce((c, i) => (c[i] = a[i], c), {}) : a
101
+ );
102
+ }
103
+ function U1(h, t) {
104
+ return h === t ? !0 : typeof h != typeof t ? !1 : h && t && typeof h == "object" && typeof t == "object" ? !Object.keys(t).some((a) => !U1(h[a], t[a])) : !1;
105
+ }
106
+ function h0(h, t) {
107
+ if (h === t)
108
+ return h;
109
+ const a = R2(h) && R2(t);
110
+ if (a || u2(h) && u2(t)) {
111
+ const c = a ? h.length : Object.keys(h).length, i = a ? t : Object.keys(t), v = i.length, n = a ? [] : {};
112
+ let g = 0;
113
+ for (let s = 0; s < v; s++) {
114
+ const p = a ? s : i[s];
115
+ n[p] = h0(h[p], t[p]), n[p] === h[p] && g++;
116
+ }
117
+ return c === v && g === c ? h : n;
118
+ }
119
+ return t;
120
+ }
121
+ function v2(h, t) {
122
+ if (h && !t || t && !h)
123
+ return !1;
124
+ for (const a in h)
125
+ if (h[a] !== t[a])
126
+ return !1;
127
+ return !0;
128
+ }
129
+ function R2(h) {
130
+ return Array.isArray(h) && h.length === Object.keys(h).length;
131
+ }
132
+ function u2(h) {
133
+ if (!D2(h))
134
+ return !1;
135
+ const t = h.constructor;
136
+ if (typeof t > "u")
137
+ return !0;
138
+ const a = t.prototype;
139
+ return !(!D2(a) || !a.hasOwnProperty("isPrototypeOf"));
140
+ }
141
+ function D2(h) {
142
+ return Object.prototype.toString.call(h) === "[object Object]";
143
+ }
144
+ function a0(h) {
145
+ return new Promise((t) => {
146
+ setTimeout(t, h);
147
+ });
148
+ }
149
+ function T2(h) {
150
+ a0(0).then(h);
151
+ }
152
+ function s2(h, t, a) {
153
+ return typeof a.structuralSharing == "function" ? a.structuralSharing(h, t) : a.structuralSharing !== !1 ? h0(h, t) : t;
154
+ }
155
+ function G0(h, t, a = 0) {
156
+ const c = [...h, t];
157
+ return a && c.length > a ? c.slice(1) : c;
158
+ }
159
+ function q0(h, t, a = 0) {
160
+ const c = [t, ...h];
161
+ return a && c.length > a ? c.slice(0, -1) : c;
162
+ }
163
+ var g1, l1, L1, U2, _0 = (U2 = class extends N1 {
164
+ constructor() {
165
+ super();
166
+ e(this, g1, void 0);
167
+ e(this, l1, void 0);
168
+ e(this, L1, void 0);
169
+ d(this, L1, (t) => {
170
+ if (!E1 && window.addEventListener) {
171
+ const a = () => t();
172
+ return window.addEventListener("visibilitychange", a, !1), () => {
173
+ window.removeEventListener("visibilitychange", a);
174
+ };
175
+ }
176
+ });
177
+ }
178
+ onSubscribe() {
179
+ l(this, l1) || this.setEventListener(l(this, L1));
180
+ }
181
+ onUnsubscribe() {
182
+ var t;
183
+ this.hasListeners() || ((t = l(this, l1)) == null || t.call(this), d(this, l1, void 0));
184
+ }
185
+ setEventListener(t) {
186
+ var a;
187
+ d(this, L1, t), (a = l(this, l1)) == null || a.call(this), d(this, l1, t((c) => {
188
+ typeof c == "boolean" ? this.setFocused(c) : this.onFocus();
189
+ }));
190
+ }
191
+ setFocused(t) {
192
+ l(this, g1) !== t && (d(this, g1, t), this.onFocus());
193
+ }
194
+ onFocus() {
195
+ this.listeners.forEach((t) => {
196
+ t();
197
+ });
198
+ }
199
+ isFocused() {
200
+ var t;
201
+ return typeof l(this, g1) == "boolean" ? l(this, g1) : ((t = globalThis.document) == null ? void 0 : t.visibilityState) !== "hidden";
202
+ }
203
+ }, g1 = new WeakMap(), l1 = new WeakMap(), L1 = new WeakMap(), U2), d2 = new _0(), x1, i1, w1, j2, $0 = (j2 = class extends N1 {
204
+ constructor() {
205
+ super();
206
+ e(this, x1, !0);
207
+ e(this, i1, void 0);
208
+ e(this, w1, void 0);
209
+ d(this, w1, (t) => {
210
+ if (!E1 && window.addEventListener) {
211
+ const a = () => t(!0), c = () => t(!1);
212
+ return window.addEventListener("online", a, !1), window.addEventListener("offline", c, !1), () => {
213
+ window.removeEventListener("online", a), window.removeEventListener("offline", c);
214
+ };
215
+ }
216
+ });
217
+ }
218
+ onSubscribe() {
219
+ l(this, i1) || this.setEventListener(l(this, w1));
220
+ }
221
+ onUnsubscribe() {
222
+ var t;
223
+ this.hasListeners() || ((t = l(this, i1)) == null || t.call(this), d(this, i1, void 0));
224
+ }
225
+ setEventListener(t) {
226
+ var a;
227
+ d(this, w1, t), (a = l(this, i1)) == null || a.call(this), d(this, i1, t(this.setOnline.bind(this)));
228
+ }
229
+ setOnline(t) {
230
+ l(this, x1) !== t && (d(this, x1, t), this.listeners.forEach((c) => {
231
+ c(t);
232
+ }));
233
+ }
234
+ isOnline() {
235
+ return l(this, x1);
236
+ }
237
+ }, x1 = new WeakMap(), i1 = new WeakMap(), w1 = new WeakMap(), j2), r2 = new $0();
238
+ function J0(h) {
239
+ return Math.min(1e3 * 2 ** h, 3e4);
240
+ }
241
+ function e2(h) {
242
+ return (h ?? "online") === "online" ? r2.isOnline() : !0;
243
+ }
244
+ var c0 = class {
245
+ constructor(h) {
246
+ this.revert = h == null ? void 0 : h.revert, this.silent = h == null ? void 0 : h.silent;
247
+ }
248
+ };
249
+ function M2(h) {
250
+ return h instanceof c0;
251
+ }
252
+ function l0(h) {
253
+ let t = !1, a = 0, c = !1, i, v, n;
254
+ const g = new Promise((o, u) => {
255
+ v = o, n = u;
256
+ }), s = (o) => {
257
+ var u;
258
+ c || (H(new c0(o)), (u = h.abort) == null || u.call(h));
259
+ }, p = () => {
260
+ t = !0;
261
+ }, z = () => {
262
+ t = !1;
263
+ }, x = () => !d2.isFocused() || h.networkMode !== "always" && !r2.isOnline(), F = (o) => {
264
+ var u;
265
+ c || (c = !0, (u = h.onSuccess) == null || u.call(h, o), i == null || i(), v(o));
266
+ }, H = (o) => {
267
+ var u;
268
+ c || (c = !0, (u = h.onError) == null || u.call(h, o), i == null || i(), n(o));
269
+ }, V = () => new Promise((o) => {
270
+ var u;
271
+ i = (O) => {
272
+ const f = c || !x();
273
+ return f && o(O), f;
274
+ }, (u = h.onPause) == null || u.call(h);
275
+ }).then(() => {
276
+ var o;
277
+ i = void 0, c || (o = h.onContinue) == null || o.call(h);
278
+ }), B = () => {
279
+ if (c)
280
+ return;
281
+ let o;
282
+ try {
283
+ o = h.fn();
284
+ } catch (u) {
285
+ o = Promise.reject(u);
286
+ }
287
+ Promise.resolve(o).then(F).catch((u) => {
288
+ var D;
289
+ if (c)
290
+ return;
291
+ const O = h.retry ?? (E1 ? 0 : 3), f = h.retryDelay ?? J0, m = typeof f == "function" ? f(a, u) : f, P = O === !0 || typeof O == "number" && a < O || typeof O == "function" && O(a, u);
292
+ if (t || !P) {
293
+ H(u);
294
+ return;
295
+ }
296
+ a++, (D = h.onFail) == null || D.call(h, a, u), a0(m).then(() => {
297
+ if (x())
298
+ return V();
299
+ }).then(() => {
300
+ t ? H(u) : B();
301
+ });
302
+ });
303
+ };
304
+ return e2(h.networkMode) ? B() : V().then(B), {
305
+ promise: g,
306
+ cancel: s,
307
+ continue: () => (i == null ? void 0 : i()) ? g : Promise.resolve(),
308
+ cancelRetry: p,
309
+ continueRetry: z
310
+ };
311
+ }
312
+ function Z0() {
313
+ let h = [], t = 0, a = (z) => {
314
+ z();
315
+ }, c = (z) => {
316
+ z();
317
+ };
318
+ const i = (z) => {
319
+ let x;
320
+ t++;
321
+ try {
322
+ x = z();
323
+ } finally {
324
+ t--, t || g();
325
+ }
326
+ return x;
327
+ }, v = (z) => {
328
+ t ? h.push(z) : T2(() => {
329
+ a(z);
330
+ });
331
+ }, n = (z) => (...x) => {
332
+ v(() => {
333
+ z(...x);
334
+ });
335
+ }, g = () => {
336
+ const z = h;
337
+ h = [], z.length && T2(() => {
338
+ c(() => {
339
+ z.forEach((x) => {
340
+ a(x);
341
+ });
342
+ });
343
+ });
344
+ };
345
+ return {
346
+ batch: i,
347
+ batchCalls: n,
348
+ schedule: v,
349
+ setNotifyFunction: (z) => {
350
+ a = z;
351
+ },
352
+ setBatchNotifyFunction: (z) => {
353
+ c = z;
354
+ }
355
+ };
356
+ }
357
+ var S = Z0(), o1, Q2, i0 = (Q2 = class {
358
+ constructor() {
359
+ e(this, o1, void 0);
360
+ }
361
+ destroy() {
362
+ this.clearGcTimeout();
363
+ }
364
+ scheduleGc() {
365
+ this.clearGcTimeout(), H2(this.gcTime) && d(this, o1, setTimeout(() => {
366
+ this.optionalRemove();
367
+ }, this.gcTime));
368
+ }
369
+ updateGcTime(h) {
370
+ this.gcTime = Math.max(
371
+ this.gcTime || 0,
372
+ h ?? (E1 ? 1 / 0 : 5 * 60 * 1e3)
373
+ );
374
+ }
375
+ clearGcTimeout() {
376
+ l(this, o1) && (clearTimeout(l(this, o1)), d(this, o1, void 0));
377
+ }
378
+ }, o1 = new WeakMap(), Q2), B1, C1, W, v1, U, y, j1, M1, O1, l2, q, t1, K2, Y0 = (K2 = class extends i0 {
379
+ constructor(t) {
380
+ super();
381
+ e(this, O1);
382
+ e(this, q);
383
+ e(this, B1, void 0);
384
+ e(this, C1, void 0);
385
+ e(this, W, void 0);
386
+ e(this, v1, void 0);
387
+ e(this, U, void 0);
388
+ e(this, y, void 0);
389
+ e(this, j1, void 0);
390
+ e(this, M1, void 0);
391
+ d(this, M1, !1), d(this, j1, t.defaultOptions), M(this, O1, l2).call(this, t.options), d(this, y, []), d(this, W, t.cache), this.queryKey = t.queryKey, this.queryHash = t.queryHash, d(this, B1, t.state || X0(this.options)), this.state = l(this, B1), this.scheduleGc();
392
+ }
393
+ get meta() {
394
+ return this.options.meta;
395
+ }
396
+ optionalRemove() {
397
+ !l(this, y).length && this.state.fetchStatus === "idle" && l(this, W).remove(this);
398
+ }
399
+ setData(t, a) {
400
+ const c = s2(this.state.data, t, this.options);
401
+ return M(this, q, t1).call(this, {
402
+ data: c,
403
+ type: "success",
404
+ dataUpdatedAt: a == null ? void 0 : a.updatedAt,
405
+ manual: a == null ? void 0 : a.manual
406
+ }), c;
407
+ }
408
+ setState(t, a) {
409
+ M(this, q, t1).call(this, { type: "setState", state: t, setStateOptions: a });
410
+ }
411
+ cancel(t) {
412
+ var c;
413
+ const a = l(this, v1);
414
+ return (c = l(this, U)) == null || c.cancel(t), a ? a.then(K).catch(K) : Promise.resolve();
415
+ }
416
+ destroy() {
417
+ super.destroy(), this.cancel({ silent: !0 });
418
+ }
419
+ reset() {
420
+ this.destroy(), this.setState(l(this, B1));
421
+ }
422
+ isActive() {
423
+ return l(this, y).some(
424
+ (t) => t.options.enabled !== !1
425
+ );
426
+ }
427
+ isDisabled() {
428
+ return this.getObserversCount() > 0 && !this.isActive();
429
+ }
430
+ isStale() {
431
+ return this.state.isInvalidated || !this.state.dataUpdatedAt || l(this, y).some((t) => t.getCurrentResult().isStale);
432
+ }
433
+ isStaleByTime(t = 0) {
434
+ return this.state.isInvalidated || !this.state.dataUpdatedAt || !t0(this.state.dataUpdatedAt, t);
435
+ }
436
+ onFocus() {
437
+ var a;
438
+ const t = l(this, y).find((c) => c.shouldFetchOnWindowFocus());
439
+ t == null || t.refetch({ cancelRefetch: !1 }), (a = l(this, U)) == null || a.continue();
440
+ }
441
+ onOnline() {
442
+ var a;
443
+ const t = l(this, y).find((c) => c.shouldFetchOnReconnect());
444
+ t == null || t.refetch({ cancelRefetch: !1 }), (a = l(this, U)) == null || a.continue();
445
+ }
446
+ addObserver(t) {
447
+ l(this, y).includes(t) || (l(this, y).push(t), this.clearGcTimeout(), l(this, W).notify({ type: "observerAdded", query: this, observer: t }));
448
+ }
449
+ removeObserver(t) {
450
+ l(this, y).includes(t) && (d(this, y, l(this, y).filter((a) => a !== t)), l(this, y).length || (l(this, U) && (l(this, M1) ? l(this, U).cancel({ revert: !0 }) : l(this, U).cancelRetry()), this.scheduleGc()), l(this, W).notify({ type: "observerRemoved", query: this, observer: t }));
451
+ }
452
+ getObserversCount() {
453
+ return l(this, y).length;
454
+ }
455
+ invalidate() {
456
+ this.state.isInvalidated || M(this, q, t1).call(this, { type: "invalidate" });
457
+ }
458
+ fetch(t, a) {
459
+ var p, z, x, F;
460
+ if (this.state.fetchStatus !== "idle") {
461
+ if (this.state.dataUpdatedAt && (a != null && a.cancelRefetch))
462
+ this.cancel({ silent: !0 });
463
+ else if (l(this, v1))
464
+ return (p = l(this, U)) == null || p.continueRetry(), l(this, v1);
465
+ }
466
+ if (t && M(this, O1, l2).call(this, t), !this.options.queryFn) {
467
+ const H = l(this, y).find((V) => V.options.queryFn);
468
+ H && M(this, O1, l2).call(this, H.options);
469
+ }
470
+ process.env.NODE_ENV !== "production" && (Array.isArray(this.options.queryKey) || console.error(
471
+ "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']"
472
+ ));
473
+ const c = new AbortController(), i = {
474
+ queryKey: this.queryKey,
475
+ meta: this.meta
476
+ }, v = (H) => {
477
+ Object.defineProperty(H, "signal", {
478
+ enumerable: !0,
479
+ get: () => (d(this, M1, !0), c.signal)
480
+ });
481
+ };
482
+ v(i);
483
+ const n = () => this.options.queryFn ? (d(this, M1, !1), this.options.persister ? this.options.persister(
484
+ this.options.queryFn,
485
+ i,
486
+ this
487
+ ) : this.options.queryFn(
488
+ i
489
+ )) : Promise.reject(
490
+ new Error(`Missing queryFn: '${this.options.queryHash}'`)
491
+ ), g = {
492
+ fetchOptions: a,
493
+ options: this.options,
494
+ queryKey: this.queryKey,
495
+ state: this.state,
496
+ fetchFn: n
497
+ };
498
+ v(g), (z = this.options.behavior) == null || z.onFetch(
499
+ g,
500
+ this
501
+ ), d(this, C1, this.state), (this.state.fetchStatus === "idle" || this.state.fetchMeta !== ((x = g.fetchOptions) == null ? void 0 : x.meta)) && M(this, q, t1).call(this, { type: "fetch", meta: (F = g.fetchOptions) == null ? void 0 : F.meta });
502
+ const s = (H) => {
503
+ var V, B, o, u;
504
+ M2(H) && H.silent || M(this, q, t1).call(this, {
505
+ type: "error",
506
+ error: H
507
+ }), M2(H) || ((B = (V = l(this, W).config).onError) == null || B.call(
508
+ V,
509
+ H,
510
+ this
511
+ ), (u = (o = l(this, W).config).onSettled) == null || u.call(
512
+ o,
513
+ this.state.data,
514
+ H,
515
+ this
516
+ )), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1;
517
+ };
518
+ return d(this, U, l0({
519
+ fn: g.fetchFn,
520
+ abort: c.abort.bind(c),
521
+ onSuccess: (H) => {
522
+ var V, B, o, u;
523
+ if (typeof H > "u") {
524
+ process.env.NODE_ENV !== "production" && console.error(
525
+ `Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`
526
+ ), s(new Error(`${this.queryHash} data is undefined`));
527
+ return;
528
+ }
529
+ this.setData(H), (B = (V = l(this, W).config).onSuccess) == null || B.call(V, H, this), (u = (o = l(this, W).config).onSettled) == null || u.call(
530
+ o,
531
+ H,
532
+ this.state.error,
533
+ this
534
+ ), this.isFetchingOptimistic || this.scheduleGc(), this.isFetchingOptimistic = !1;
535
+ },
536
+ onError: s,
537
+ onFail: (H, V) => {
538
+ M(this, q, t1).call(this, { type: "failed", failureCount: H, error: V });
539
+ },
540
+ onPause: () => {
541
+ M(this, q, t1).call(this, { type: "pause" });
542
+ },
543
+ onContinue: () => {
544
+ M(this, q, t1).call(this, { type: "continue" });
545
+ },
546
+ retry: g.options.retry,
547
+ retryDelay: g.options.retryDelay,
548
+ networkMode: g.options.networkMode
549
+ })), d(this, v1, l(this, U).promise), l(this, v1);
550
+ }
551
+ }, B1 = new WeakMap(), C1 = new WeakMap(), W = new WeakMap(), v1 = new WeakMap(), U = new WeakMap(), y = new WeakMap(), j1 = new WeakMap(), M1 = new WeakMap(), O1 = new WeakSet(), l2 = function(t) {
552
+ this.options = { ...l(this, j1), ...t }, this.updateGcTime(this.options.gcTime);
553
+ }, q = new WeakSet(), t1 = function(t) {
554
+ const a = (c) => {
555
+ switch (t.type) {
556
+ case "failed":
557
+ return {
558
+ ...c,
559
+ fetchFailureCount: t.failureCount,
560
+ fetchFailureReason: t.error
561
+ };
562
+ case "pause":
563
+ return {
564
+ ...c,
565
+ fetchStatus: "paused"
566
+ };
567
+ case "continue":
568
+ return {
569
+ ...c,
570
+ fetchStatus: "fetching"
571
+ };
572
+ case "fetch":
573
+ return {
574
+ ...c,
575
+ fetchFailureCount: 0,
576
+ fetchFailureReason: null,
577
+ fetchMeta: t.meta ?? null,
578
+ fetchStatus: e2(this.options.networkMode) ? "fetching" : "paused",
579
+ ...!c.dataUpdatedAt && {
580
+ error: null,
581
+ status: "pending"
582
+ }
583
+ };
584
+ case "success":
585
+ return {
586
+ ...c,
587
+ data: t.data,
588
+ dataUpdateCount: c.dataUpdateCount + 1,
589
+ dataUpdatedAt: t.dataUpdatedAt ?? Date.now(),
590
+ error: null,
591
+ isInvalidated: !1,
592
+ status: "success",
593
+ ...!t.manual && {
594
+ fetchStatus: "idle",
595
+ fetchFailureCount: 0,
596
+ fetchFailureReason: null
597
+ }
598
+ };
599
+ case "error":
600
+ const i = t.error;
601
+ return M2(i) && i.revert && l(this, C1) ? { ...l(this, C1), fetchStatus: "idle" } : {
602
+ ...c,
603
+ error: i,
604
+ errorUpdateCount: c.errorUpdateCount + 1,
605
+ errorUpdatedAt: Date.now(),
606
+ fetchFailureCount: c.fetchFailureCount + 1,
607
+ fetchFailureReason: i,
608
+ fetchStatus: "idle",
609
+ status: "error"
610
+ };
611
+ case "invalidate":
612
+ return {
613
+ ...c,
614
+ isInvalidated: !0
615
+ };
616
+ case "setState":
617
+ return {
618
+ ...c,
619
+ ...t.state
620
+ };
621
+ }
622
+ };
623
+ this.state = a(this.state), S.batch(() => {
624
+ l(this, y).forEach((c) => {
625
+ c.onQueryUpdate();
626
+ }), l(this, W).notify({ query: this, type: "updated", action: t });
627
+ });
628
+ }, K2);
629
+ function X0(h) {
630
+ const t = typeof h.initialData == "function" ? h.initialData() : h.initialData, a = typeof t < "u", c = a ? typeof h.initialDataUpdatedAt == "function" ? h.initialDataUpdatedAt() : h.initialDataUpdatedAt : 0;
631
+ return {
632
+ data: t,
633
+ dataUpdateCount: 0,
634
+ dataUpdatedAt: a ? c ?? Date.now() : 0,
635
+ error: null,
636
+ errorUpdateCount: 0,
637
+ errorUpdatedAt: 0,
638
+ fetchFailureCount: 0,
639
+ fetchFailureReason: null,
640
+ fetchMeta: null,
641
+ isInvalidated: !1,
642
+ status: a ? "success" : "pending",
643
+ fetchStatus: "idle"
644
+ };
645
+ }
646
+ var $, G2, t4 = (G2 = class extends N1 {
647
+ constructor(t = {}) {
648
+ super();
649
+ e(this, $, void 0);
650
+ this.config = t, d(this, $, /* @__PURE__ */ new Map());
651
+ }
652
+ build(t, a, c) {
653
+ const i = a.queryKey, v = a.queryHash ?? S2(i, a);
654
+ let n = this.get(v);
655
+ return n || (n = new Y0({
656
+ cache: this,
657
+ queryKey: i,
658
+ queryHash: v,
659
+ options: t.defaultQueryOptions(a),
660
+ state: c,
661
+ defaultOptions: t.getQueryDefaults(i)
662
+ }), this.add(n)), n;
663
+ }
664
+ add(t) {
665
+ l(this, $).has(t.queryHash) || (l(this, $).set(t.queryHash, t), this.notify({
666
+ type: "added",
667
+ query: t
668
+ }));
669
+ }
670
+ remove(t) {
671
+ const a = l(this, $).get(t.queryHash);
672
+ a && (t.destroy(), a === t && l(this, $).delete(t.queryHash), this.notify({ type: "removed", query: t }));
673
+ }
674
+ clear() {
675
+ S.batch(() => {
676
+ this.getAll().forEach((t) => {
677
+ this.remove(t);
678
+ });
679
+ });
680
+ }
681
+ get(t) {
682
+ return l(this, $).get(t);
683
+ }
684
+ getAll() {
685
+ return [...l(this, $).values()];
686
+ }
687
+ find(t) {
688
+ const a = { exact: !0, ...t };
689
+ return this.getAll().find(
690
+ (c) => F2(a, c)
691
+ );
692
+ }
693
+ findAll(t = {}) {
694
+ const a = this.getAll();
695
+ return Object.keys(t).length > 0 ? a.filter((c) => F2(t, c)) : a;
696
+ }
697
+ notify(t) {
698
+ S.batch(() => {
699
+ this.listeners.forEach((a) => {
700
+ a(t);
701
+ });
702
+ });
703
+ }
704
+ onFocus() {
705
+ S.batch(() => {
706
+ this.getAll().forEach((t) => {
707
+ t.onFocus();
708
+ });
709
+ });
710
+ }
711
+ onOnline() {
712
+ S.batch(() => {
713
+ this.getAll().forEach((t) => {
714
+ t.onOnline();
715
+ });
716
+ });
717
+ }
718
+ }, $ = new WeakMap(), G2), J, Q1, N, A1, Z, c1, q2, h4 = (q2 = class extends i0 {
719
+ constructor(t) {
720
+ super();
721
+ e(this, Z);
722
+ e(this, J, void 0);
723
+ e(this, Q1, void 0);
724
+ e(this, N, void 0);
725
+ e(this, A1, void 0);
726
+ this.mutationId = t.mutationId, d(this, Q1, t.defaultOptions), d(this, N, t.mutationCache), d(this, J, []), this.state = t.state || v0(), this.setOptions(t.options), this.scheduleGc();
727
+ }
728
+ setOptions(t) {
729
+ this.options = { ...l(this, Q1), ...t }, this.updateGcTime(this.options.gcTime);
730
+ }
731
+ get meta() {
732
+ return this.options.meta;
733
+ }
734
+ addObserver(t) {
735
+ l(this, J).includes(t) || (l(this, J).push(t), this.clearGcTimeout(), l(this, N).notify({
736
+ type: "observerAdded",
737
+ mutation: this,
738
+ observer: t
739
+ }));
740
+ }
741
+ removeObserver(t) {
742
+ d(this, J, l(this, J).filter((a) => a !== t)), this.scheduleGc(), l(this, N).notify({
743
+ type: "observerRemoved",
744
+ mutation: this,
745
+ observer: t
746
+ });
747
+ }
748
+ optionalRemove() {
749
+ l(this, J).length || (this.state.status === "pending" ? this.scheduleGc() : l(this, N).remove(this));
750
+ }
751
+ continue() {
752
+ var t;
753
+ return ((t = l(this, A1)) == null ? void 0 : t.continue()) ?? // continuing a mutation assumes that variables are set, mutation must have been dehydrated before
754
+ this.execute(this.state.variables);
755
+ }
756
+ async execute(t) {
757
+ var i, v, n, g, s, p, z, x, F, H, V, B, o, u, O, f, m, P, D, C;
758
+ const a = () => (d(this, A1, l0({
759
+ fn: () => this.options.mutationFn ? this.options.mutationFn(t) : Promise.reject(new Error("No mutationFn found")),
760
+ onFail: (w, X) => {
761
+ M(this, Z, c1).call(this, { type: "failed", failureCount: w, error: X });
762
+ },
763
+ onPause: () => {
764
+ M(this, Z, c1).call(this, { type: "pause" });
765
+ },
766
+ onContinue: () => {
767
+ M(this, Z, c1).call(this, { type: "continue" });
768
+ },
769
+ retry: this.options.retry ?? 0,
770
+ retryDelay: this.options.retryDelay,
771
+ networkMode: this.options.networkMode
772
+ })), l(this, A1).promise), c = this.state.status === "pending";
773
+ try {
774
+ if (!c) {
775
+ M(this, Z, c1).call(this, { type: "pending", variables: t }), await ((v = (i = l(this, N).config).onMutate) == null ? void 0 : v.call(
776
+ i,
777
+ t,
778
+ this
779
+ ));
780
+ const X = await ((g = (n = this.options).onMutate) == null ? void 0 : g.call(n, t));
781
+ X !== this.state.context && M(this, Z, c1).call(this, {
782
+ type: "pending",
783
+ context: X,
784
+ variables: t
785
+ });
786
+ }
787
+ const w = await a();
788
+ return await ((p = (s = l(this, N).config).onSuccess) == null ? void 0 : p.call(
789
+ s,
790
+ w,
791
+ t,
792
+ this.state.context,
793
+ this
794
+ )), await ((x = (z = this.options).onSuccess) == null ? void 0 : x.call(z, w, t, this.state.context)), await ((H = (F = l(this, N).config).onSettled) == null ? void 0 : H.call(
795
+ F,
796
+ w,
797
+ null,
798
+ this.state.variables,
799
+ this.state.context,
800
+ this
801
+ )), await ((B = (V = this.options).onSettled) == null ? void 0 : B.call(V, w, null, t, this.state.context)), M(this, Z, c1).call(this, { type: "success", data: w }), w;
802
+ } catch (w) {
803
+ try {
804
+ throw await ((u = (o = l(this, N).config).onError) == null ? void 0 : u.call(
805
+ o,
806
+ w,
807
+ t,
808
+ this.state.context,
809
+ this
810
+ )), await ((f = (O = this.options).onError) == null ? void 0 : f.call(
811
+ O,
812
+ w,
813
+ t,
814
+ this.state.context
815
+ )), await ((P = (m = l(this, N).config).onSettled) == null ? void 0 : P.call(
816
+ m,
817
+ void 0,
818
+ w,
819
+ this.state.variables,
820
+ this.state.context,
821
+ this
822
+ )), await ((C = (D = this.options).onSettled) == null ? void 0 : C.call(
823
+ D,
824
+ void 0,
825
+ w,
826
+ t,
827
+ this.state.context
828
+ )), w;
829
+ } finally {
830
+ M(this, Z, c1).call(this, { type: "error", error: w });
831
+ }
832
+ }
833
+ }
834
+ }, J = new WeakMap(), Q1 = new WeakMap(), N = new WeakMap(), A1 = new WeakMap(), Z = new WeakSet(), c1 = function(t) {
835
+ const a = (c) => {
836
+ switch (t.type) {
837
+ case "failed":
838
+ return {
839
+ ...c,
840
+ failureCount: t.failureCount,
841
+ failureReason: t.error
842
+ };
843
+ case "pause":
844
+ return {
845
+ ...c,
846
+ isPaused: !0
847
+ };
848
+ case "continue":
849
+ return {
850
+ ...c,
851
+ isPaused: !1
852
+ };
853
+ case "pending":
854
+ return {
855
+ ...c,
856
+ context: t.context,
857
+ data: void 0,
858
+ failureCount: 0,
859
+ failureReason: null,
860
+ error: null,
861
+ isPaused: !e2(this.options.networkMode),
862
+ status: "pending",
863
+ variables: t.variables,
864
+ submittedAt: Date.now()
865
+ };
866
+ case "success":
867
+ return {
868
+ ...c,
869
+ data: t.data,
870
+ failureCount: 0,
871
+ failureReason: null,
872
+ error: null,
873
+ status: "success",
874
+ isPaused: !1
875
+ };
876
+ case "error":
877
+ return {
878
+ ...c,
879
+ data: void 0,
880
+ error: t.error,
881
+ failureCount: c.failureCount + 1,
882
+ failureReason: t.error,
883
+ isPaused: !1,
884
+ status: "error"
885
+ };
886
+ }
887
+ };
888
+ this.state = a(this.state), S.batch(() => {
889
+ l(this, J).forEach((c) => {
890
+ c.onMutationUpdate(t);
891
+ }), l(this, N).notify({
892
+ mutation: this,
893
+ type: "updated",
894
+ action: t
895
+ });
896
+ });
897
+ }, q2);
898
+ function v0() {
899
+ return {
900
+ context: void 0,
901
+ data: void 0,
902
+ error: null,
903
+ failureCount: 0,
904
+ failureReason: null,
905
+ isPaused: !1,
906
+ status: "idle",
907
+ variables: void 0,
908
+ submittedAt: 0
909
+ };
910
+ }
911
+ var j, K1, H1, _2, a4 = (_2 = class extends N1 {
912
+ constructor(t = {}) {
913
+ super();
914
+ e(this, j, void 0);
915
+ e(this, K1, void 0);
916
+ e(this, H1, void 0);
917
+ this.config = t, d(this, j, []), d(this, K1, 0);
918
+ }
919
+ build(t, a, c) {
920
+ const i = new h4({
921
+ mutationCache: this,
922
+ mutationId: ++c2(this, K1)._,
923
+ options: t.defaultMutationOptions(a),
924
+ state: c
925
+ });
926
+ return this.add(i), i;
927
+ }
928
+ add(t) {
929
+ l(this, j).push(t), this.notify({ type: "added", mutation: t });
930
+ }
931
+ remove(t) {
932
+ d(this, j, l(this, j).filter((a) => a !== t)), this.notify({ type: "removed", mutation: t });
933
+ }
934
+ clear() {
935
+ S.batch(() => {
936
+ l(this, j).forEach((t) => {
937
+ this.remove(t);
938
+ });
939
+ });
940
+ }
941
+ getAll() {
942
+ return l(this, j);
943
+ }
944
+ find(t) {
945
+ const a = { exact: !0, ...t };
946
+ return l(this, j).find(
947
+ (c) => k2(a, c)
948
+ );
949
+ }
950
+ findAll(t = {}) {
951
+ return l(this, j).filter(
952
+ (a) => k2(t, a)
953
+ );
954
+ }
955
+ notify(t) {
956
+ S.batch(() => {
957
+ this.listeners.forEach((a) => {
958
+ a(t);
959
+ });
960
+ });
961
+ }
962
+ resumePausedMutations() {
963
+ return d(this, H1, (l(this, H1) ?? Promise.resolve()).then(() => {
964
+ const t = l(this, j).filter((a) => a.state.isPaused);
965
+ return S.batch(
966
+ () => t.reduce(
967
+ (a, c) => a.then(() => c.continue().catch(K)),
968
+ Promise.resolve()
969
+ )
970
+ );
971
+ }).then(() => {
972
+ d(this, H1, void 0);
973
+ })), l(this, H1);
974
+ }
975
+ }, j = new WeakMap(), K1 = new WeakMap(), H1 = new WeakMap(), _2);
976
+ function c4(h) {
977
+ return {
978
+ onFetch: (t, a) => {
979
+ const c = async () => {
980
+ var V, B, o, u, O;
981
+ const i = t.options, v = (o = (B = (V = t.fetchOptions) == null ? void 0 : V.meta) == null ? void 0 : B.fetchMore) == null ? void 0 : o.direction, n = ((u = t.state.data) == null ? void 0 : u.pages) || [], g = ((O = t.state.data) == null ? void 0 : O.pageParams) || [], s = { pages: [], pageParams: [] };
982
+ let p = !1;
983
+ const z = (f) => {
984
+ Object.defineProperty(f, "signal", {
985
+ enumerable: !0,
986
+ get: () => (t.signal.aborted ? p = !0 : t.signal.addEventListener("abort", () => {
987
+ p = !0;
988
+ }), t.signal)
989
+ });
990
+ }, x = t.options.queryFn || (() => Promise.reject(
991
+ new Error(`Missing queryFn: '${t.options.queryHash}'`)
992
+ )), F = async (f, m, P) => {
993
+ if (p)
994
+ return Promise.reject();
995
+ if (m == null && f.pages.length)
996
+ return Promise.resolve(f);
997
+ const D = {
998
+ queryKey: t.queryKey,
999
+ pageParam: m,
1000
+ direction: P ? "backward" : "forward",
1001
+ meta: t.options.meta
1002
+ };
1003
+ z(D);
1004
+ const C = await x(
1005
+ D
1006
+ ), { maxPages: w } = t.options, X = P ? q0 : G0;
1007
+ return {
1008
+ pages: X(f.pages, C, w),
1009
+ pageParams: X(f.pageParams, m, w)
1010
+ };
1011
+ };
1012
+ let H;
1013
+ if (v && n.length) {
1014
+ const f = v === "backward", m = f ? l4 : E2, P = {
1015
+ pages: n,
1016
+ pageParams: g
1017
+ }, D = m(i, P);
1018
+ H = await F(P, D, f);
1019
+ } else {
1020
+ H = await F(
1021
+ s,
1022
+ g[0] ?? i.initialPageParam
1023
+ );
1024
+ const f = h ?? n.length;
1025
+ for (let m = 1; m < f; m++) {
1026
+ const P = E2(i, H);
1027
+ H = await F(H, P);
1028
+ }
1029
+ }
1030
+ return H;
1031
+ };
1032
+ t.options.persister ? t.fetchFn = () => {
1033
+ var i, v;
1034
+ return (v = (i = t.options).persister) == null ? void 0 : v.call(
1035
+ i,
1036
+ c,
1037
+ {
1038
+ queryKey: t.queryKey,
1039
+ meta: t.options.meta,
1040
+ signal: t.signal
1041
+ },
1042
+ a
1043
+ );
1044
+ } : t.fetchFn = c;
1045
+ }
1046
+ };
1047
+ }
1048
+ function E2(h, { pages: t, pageParams: a }) {
1049
+ const c = t.length - 1;
1050
+ return h.getNextPageParam(
1051
+ t[c],
1052
+ t,
1053
+ a[c],
1054
+ a
1055
+ );
1056
+ }
1057
+ function l4(h, { pages: t, pageParams: a }) {
1058
+ var c;
1059
+ return (c = h.getPreviousPageParam) == null ? void 0 : c.call(
1060
+ h,
1061
+ t[0],
1062
+ t,
1063
+ a[0],
1064
+ a
1065
+ );
1066
+ }
1067
+ var A, d1, r1, S1, y1, n1, b1, P1, $2, i4 = ($2 = class {
1068
+ constructor(h = {}) {
1069
+ e(this, A, void 0);
1070
+ e(this, d1, void 0);
1071
+ e(this, r1, void 0);
1072
+ e(this, S1, void 0);
1073
+ e(this, y1, void 0);
1074
+ e(this, n1, void 0);
1075
+ e(this, b1, void 0);
1076
+ e(this, P1, void 0);
1077
+ d(this, A, h.queryCache || new t4()), d(this, d1, h.mutationCache || new a4()), d(this, r1, h.defaultOptions || {}), d(this, S1, /* @__PURE__ */ new Map()), d(this, y1, /* @__PURE__ */ new Map()), d(this, n1, 0);
1078
+ }
1079
+ mount() {
1080
+ c2(this, n1)._++, l(this, n1) === 1 && (d(this, b1, d2.subscribe(() => {
1081
+ d2.isFocused() && (this.resumePausedMutations(), l(this, A).onFocus());
1082
+ })), d(this, P1, r2.subscribe(() => {
1083
+ r2.isOnline() && (this.resumePausedMutations(), l(this, A).onOnline());
1084
+ })));
1085
+ }
1086
+ unmount() {
1087
+ var h, t;
1088
+ c2(this, n1)._--, l(this, n1) === 0 && ((h = l(this, b1)) == null || h.call(this), d(this, b1, void 0), (t = l(this, P1)) == null || t.call(this), d(this, P1, void 0));
1089
+ }
1090
+ isFetching(h) {
1091
+ return l(this, A).findAll({ ...h, fetchStatus: "fetching" }).length;
1092
+ }
1093
+ isMutating(h) {
1094
+ return l(this, d1).findAll({ ...h, status: "pending" }).length;
1095
+ }
1096
+ getQueryData(h) {
1097
+ var t;
1098
+ return (t = l(this, A).find({ queryKey: h })) == null ? void 0 : t.state.data;
1099
+ }
1100
+ ensureQueryData(h) {
1101
+ const t = this.getQueryData(h.queryKey);
1102
+ return t !== void 0 ? Promise.resolve(t) : this.fetchQuery(h);
1103
+ }
1104
+ getQueriesData(h) {
1105
+ return this.getQueryCache().findAll(h).map(({ queryKey: t, state: a }) => {
1106
+ const c = a.data;
1107
+ return [t, c];
1108
+ });
1109
+ }
1110
+ setQueryData(h, t, a) {
1111
+ const c = l(this, A).find({ queryKey: h }), i = c == null ? void 0 : c.state.data, v = K0(t, i);
1112
+ if (typeof v > "u")
1113
+ return;
1114
+ const n = this.defaultQueryOptions({ queryKey: h });
1115
+ return l(this, A).build(this, n).setData(v, { ...a, manual: !0 });
1116
+ }
1117
+ setQueriesData(h, t, a) {
1118
+ return S.batch(
1119
+ () => this.getQueryCache().findAll(h).map(({ queryKey: c }) => [
1120
+ c,
1121
+ this.setQueryData(c, t, a)
1122
+ ])
1123
+ );
1124
+ }
1125
+ getQueryState(h) {
1126
+ var t;
1127
+ return (t = l(this, A).find({ queryKey: h })) == null ? void 0 : t.state;
1128
+ }
1129
+ removeQueries(h) {
1130
+ const t = l(this, A);
1131
+ S.batch(() => {
1132
+ t.findAll(h).forEach((a) => {
1133
+ t.remove(a);
1134
+ });
1135
+ });
1136
+ }
1137
+ resetQueries(h, t) {
1138
+ const a = l(this, A), c = {
1139
+ type: "active",
1140
+ ...h
1141
+ };
1142
+ return S.batch(() => (a.findAll(h).forEach((i) => {
1143
+ i.reset();
1144
+ }), this.refetchQueries(c, t)));
1145
+ }
1146
+ cancelQueries(h = {}, t = {}) {
1147
+ const a = { revert: !0, ...t }, c = S.batch(
1148
+ () => l(this, A).findAll(h).map((i) => i.cancel(a))
1149
+ );
1150
+ return Promise.all(c).then(K).catch(K);
1151
+ }
1152
+ invalidateQueries(h = {}, t = {}) {
1153
+ return S.batch(() => {
1154
+ if (l(this, A).findAll(h).forEach((c) => {
1155
+ c.invalidate();
1156
+ }), h.refetchType === "none")
1157
+ return Promise.resolve();
1158
+ const a = {
1159
+ ...h,
1160
+ type: h.refetchType ?? h.type ?? "active"
1161
+ };
1162
+ return this.refetchQueries(a, t);
1163
+ });
1164
+ }
1165
+ refetchQueries(h = {}, t) {
1166
+ const a = {
1167
+ ...t,
1168
+ cancelRefetch: (t == null ? void 0 : t.cancelRefetch) ?? !0
1169
+ }, c = S.batch(
1170
+ () => l(this, A).findAll(h).filter((i) => !i.isDisabled()).map((i) => {
1171
+ let v = i.fetch(void 0, a);
1172
+ return a.throwOnError || (v = v.catch(K)), i.state.fetchStatus === "paused" ? Promise.resolve() : v;
1173
+ })
1174
+ );
1175
+ return Promise.all(c).then(K);
1176
+ }
1177
+ fetchQuery(h) {
1178
+ const t = this.defaultQueryOptions(h);
1179
+ typeof t.retry > "u" && (t.retry = !1);
1180
+ const a = l(this, A).build(this, t);
1181
+ return a.isStaleByTime(t.staleTime) ? a.fetch(t) : Promise.resolve(a.state.data);
1182
+ }
1183
+ prefetchQuery(h) {
1184
+ return this.fetchQuery(h).then(K).catch(K);
1185
+ }
1186
+ fetchInfiniteQuery(h) {
1187
+ return h.behavior = c4(h.pages), this.fetchQuery(h);
1188
+ }
1189
+ prefetchInfiniteQuery(h) {
1190
+ return this.fetchInfiniteQuery(h).then(K).catch(K);
1191
+ }
1192
+ resumePausedMutations() {
1193
+ return l(this, d1).resumePausedMutations();
1194
+ }
1195
+ getQueryCache() {
1196
+ return l(this, A);
1197
+ }
1198
+ getMutationCache() {
1199
+ return l(this, d1);
1200
+ }
1201
+ getDefaultOptions() {
1202
+ return l(this, r1);
1203
+ }
1204
+ setDefaultOptions(h) {
1205
+ d(this, r1, h);
1206
+ }
1207
+ setQueryDefaults(h, t) {
1208
+ l(this, S1).set(W1(h), {
1209
+ queryKey: h,
1210
+ defaultOptions: t
1211
+ });
1212
+ }
1213
+ getQueryDefaults(h) {
1214
+ const t = [...l(this, S1).values()];
1215
+ let a = {};
1216
+ return t.forEach((c) => {
1217
+ U1(h, c.queryKey) && (a = { ...a, ...c.defaultOptions });
1218
+ }), a;
1219
+ }
1220
+ setMutationDefaults(h, t) {
1221
+ l(this, y1).set(W1(h), {
1222
+ mutationKey: h,
1223
+ defaultOptions: t
1224
+ });
1225
+ }
1226
+ getMutationDefaults(h) {
1227
+ const t = [...l(this, y1).values()];
1228
+ let a = {};
1229
+ return t.forEach((c) => {
1230
+ U1(h, c.mutationKey) && (a = { ...a, ...c.defaultOptions });
1231
+ }), a;
1232
+ }
1233
+ defaultQueryOptions(h) {
1234
+ if (h != null && h._defaulted)
1235
+ return h;
1236
+ const t = {
1237
+ ...l(this, r1).queries,
1238
+ ...(h == null ? void 0 : h.queryKey) && this.getQueryDefaults(h.queryKey),
1239
+ ...h,
1240
+ _defaulted: !0
1241
+ };
1242
+ return t.queryHash || (t.queryHash = S2(
1243
+ t.queryKey,
1244
+ t
1245
+ )), 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;
1246
+ }
1247
+ defaultMutationOptions(h) {
1248
+ return h != null && h._defaulted ? h : {
1249
+ ...l(this, r1).mutations,
1250
+ ...(h == null ? void 0 : h.mutationKey) && this.getMutationDefaults(h.mutationKey),
1251
+ ...h,
1252
+ _defaulted: !0
1253
+ };
1254
+ }
1255
+ clear() {
1256
+ l(this, A).clear(), l(this, d1).clear();
1257
+ }
1258
+ }, A = new WeakMap(), d1 = new WeakMap(), r1 = new WeakMap(), S1 = new WeakMap(), y1 = new WeakMap(), n1 = new WeakMap(), b1 = new WeakMap(), P1 = new WeakMap(), $2), E, L, F1, k, u1, k1, Y, G1, R1, D1, s1, p1, e1, V1, f1, I1, q1, p2, _1, V2, $1, f2, J1, m2, Z1, L2, Y1, x2, X1, w2, n2, d0, J2, v4 = (J2 = class extends N1 {
1259
+ constructor(t, a) {
1260
+ super();
1261
+ e(this, f1);
1262
+ e(this, q1);
1263
+ e(this, _1);
1264
+ e(this, $1);
1265
+ e(this, J1);
1266
+ e(this, Z1);
1267
+ e(this, Y1);
1268
+ e(this, X1);
1269
+ e(this, n2);
1270
+ e(this, E, void 0);
1271
+ e(this, L, void 0);
1272
+ e(this, F1, void 0);
1273
+ e(this, k, void 0);
1274
+ e(this, u1, void 0);
1275
+ e(this, k1, void 0);
1276
+ e(this, Y, void 0);
1277
+ e(this, G1, void 0);
1278
+ e(this, R1, void 0);
1279
+ // This property keeps track of the last query with defined data.
1280
+ // It will be used to pass the previous data and query to the placeholder function between renders.
1281
+ e(this, D1, void 0);
1282
+ e(this, s1, void 0);
1283
+ e(this, p1, void 0);
1284
+ e(this, e1, void 0);
1285
+ e(this, V1, void 0);
1286
+ d(this, L, void 0), d(this, F1, void 0), d(this, k, void 0), d(this, V1, /* @__PURE__ */ new Set()), d(this, E, t), this.options = a, d(this, Y, null), this.bindMethods(), this.setOptions(a);
1287
+ }
1288
+ bindMethods() {
1289
+ this.refetch = this.refetch.bind(this);
1290
+ }
1291
+ onSubscribe() {
1292
+ this.listeners.size === 1 && (l(this, L).addObserver(this), N2(l(this, L), this.options) ? M(this, f1, I1).call(this) : this.updateResult(), M(this, J1, m2).call(this));
1293
+ }
1294
+ onUnsubscribe() {
1295
+ this.hasListeners() || this.destroy();
1296
+ }
1297
+ shouldFetchOnReconnect() {
1298
+ return B2(
1299
+ l(this, L),
1300
+ this.options,
1301
+ this.options.refetchOnReconnect
1302
+ );
1303
+ }
1304
+ shouldFetchOnWindowFocus() {
1305
+ return B2(
1306
+ l(this, L),
1307
+ this.options,
1308
+ this.options.refetchOnWindowFocus
1309
+ );
1310
+ }
1311
+ destroy() {
1312
+ this.listeners = /* @__PURE__ */ new Set(), M(this, Z1, L2).call(this), M(this, Y1, x2).call(this), l(this, L).removeObserver(this);
1313
+ }
1314
+ setOptions(t, a) {
1315
+ const c = this.options, i = l(this, L);
1316
+ if (this.options = l(this, E).defaultQueryOptions(t), v2(c, this.options) || l(this, E).getQueryCache().notify({
1317
+ type: "observerOptionsUpdated",
1318
+ query: l(this, L),
1319
+ observer: this
1320
+ }), typeof this.options.enabled < "u" && typeof this.options.enabled != "boolean")
1321
+ throw new Error("Expected enabled to be a boolean");
1322
+ this.options.queryKey || (this.options.queryKey = c.queryKey), M(this, X1, w2).call(this);
1323
+ const v = this.hasListeners();
1324
+ v && I2(
1325
+ l(this, L),
1326
+ i,
1327
+ this.options,
1328
+ c
1329
+ ) && M(this, f1, I1).call(this), this.updateResult(a), v && (l(this, L) !== i || this.options.enabled !== c.enabled || this.options.staleTime !== c.staleTime) && M(this, q1, p2).call(this);
1330
+ const n = M(this, _1, V2).call(this);
1331
+ v && (l(this, L) !== i || this.options.enabled !== c.enabled || n !== l(this, e1)) && M(this, $1, f2).call(this, n);
1332
+ }
1333
+ getOptimisticResult(t) {
1334
+ const a = l(this, E).getQueryCache().build(l(this, E), t), c = this.createResult(a, t);
1335
+ return r4(this, c) && (d(this, k, c), d(this, k1, this.options), d(this, u1, l(this, L).state)), c;
1336
+ }
1337
+ getCurrentResult() {
1338
+ return l(this, k);
1339
+ }
1340
+ trackResult(t) {
1341
+ const a = {};
1342
+ return Object.keys(t).forEach((c) => {
1343
+ Object.defineProperty(a, c, {
1344
+ configurable: !1,
1345
+ enumerable: !0,
1346
+ get: () => (l(this, V1).add(c), t[c])
1347
+ });
1348
+ }), a;
1349
+ }
1350
+ getCurrentQuery() {
1351
+ return l(this, L);
1352
+ }
1353
+ refetch({ ...t } = {}) {
1354
+ return this.fetch({
1355
+ ...t
1356
+ });
1357
+ }
1358
+ fetchOptimistic(t) {
1359
+ const a = l(this, E).defaultQueryOptions(t), c = l(this, E).getQueryCache().build(l(this, E), a);
1360
+ return c.isFetchingOptimistic = !0, c.fetch().then(() => this.createResult(c, a));
1361
+ }
1362
+ fetch(t) {
1363
+ return M(this, f1, I1).call(this, {
1364
+ ...t,
1365
+ cancelRefetch: t.cancelRefetch ?? !0
1366
+ }).then(() => (this.updateResult(), l(this, k)));
1367
+ }
1368
+ createResult(t, a) {
1369
+ var D;
1370
+ const c = l(this, L), i = this.options, v = l(this, k), n = l(this, u1), g = l(this, k1), p = t !== c ? t.state : l(this, F1), { state: z } = t;
1371
+ let { error: x, errorUpdatedAt: F, fetchStatus: H, status: V } = z, B = !1, o;
1372
+ if (a._optimisticResults) {
1373
+ const C = this.hasListeners(), w = !C && N2(t, a), X = C && I2(t, c, a, i);
1374
+ (w || X) && (H = e2(t.options.networkMode) ? "fetching" : "paused", z.dataUpdatedAt || (V = "pending")), a._optimisticResults === "isRestoring" && (H = "idle");
1375
+ }
1376
+ if (a.select && typeof z.data < "u")
1377
+ if (v && z.data === (n == null ? void 0 : n.data) && a.select === l(this, G1))
1378
+ o = l(this, R1);
1379
+ else
1380
+ try {
1381
+ d(this, G1, a.select), o = a.select(z.data), o = s2(v == null ? void 0 : v.data, o, a), d(this, R1, o), d(this, Y, null);
1382
+ } catch (C) {
1383
+ d(this, Y, C);
1384
+ }
1385
+ else
1386
+ o = z.data;
1387
+ if (typeof a.placeholderData < "u" && typeof o > "u" && V === "pending") {
1388
+ let C;
1389
+ if (v != null && v.isPlaceholderData && a.placeholderData === (g == null ? void 0 : g.placeholderData))
1390
+ C = v.data;
1391
+ else if (C = typeof a.placeholderData == "function" ? a.placeholderData(
1392
+ (D = l(this, D1)) == null ? void 0 : D.state.data,
1393
+ l(this, D1)
1394
+ ) : a.placeholderData, a.select && typeof C < "u")
1395
+ try {
1396
+ C = a.select(C), d(this, Y, null);
1397
+ } catch (w) {
1398
+ d(this, Y, w);
1399
+ }
1400
+ typeof C < "u" && (V = "success", o = s2(
1401
+ v == null ? void 0 : v.data,
1402
+ C,
1403
+ a
1404
+ ), B = !0);
1405
+ }
1406
+ l(this, Y) && (x = l(this, Y), o = l(this, R1), F = Date.now(), V = "error");
1407
+ const u = H === "fetching", O = V === "pending", f = V === "error", m = O && u;
1408
+ return {
1409
+ status: V,
1410
+ fetchStatus: H,
1411
+ isPending: O,
1412
+ isSuccess: V === "success",
1413
+ isError: f,
1414
+ isInitialLoading: m,
1415
+ isLoading: m,
1416
+ data: o,
1417
+ dataUpdatedAt: z.dataUpdatedAt,
1418
+ error: x,
1419
+ errorUpdatedAt: F,
1420
+ failureCount: z.fetchFailureCount,
1421
+ failureReason: z.fetchFailureReason,
1422
+ errorUpdateCount: z.errorUpdateCount,
1423
+ isFetched: z.dataUpdateCount > 0 || z.errorUpdateCount > 0,
1424
+ isFetchedAfterMount: z.dataUpdateCount > p.dataUpdateCount || z.errorUpdateCount > p.errorUpdateCount,
1425
+ isFetching: u,
1426
+ isRefetching: u && !O,
1427
+ isLoadingError: f && z.dataUpdatedAt === 0,
1428
+ isPaused: H === "paused",
1429
+ isPlaceholderData: B,
1430
+ isRefetchError: f && z.dataUpdatedAt !== 0,
1431
+ isStale: y2(t, a),
1432
+ refetch: this.refetch
1433
+ };
1434
+ }
1435
+ updateResult(t) {
1436
+ const a = l(this, k), c = this.createResult(l(this, L), this.options);
1437
+ if (d(this, u1, l(this, L).state), d(this, k1, this.options), l(this, u1).data !== void 0 && d(this, D1, l(this, L)), v2(c, a))
1438
+ return;
1439
+ d(this, k, c);
1440
+ const i = {}, v = () => {
1441
+ if (!a)
1442
+ return !0;
1443
+ const { notifyOnChangeProps: n } = this.options, g = typeof n == "function" ? n() : n;
1444
+ if (g === "all" || !g && !l(this, V1).size)
1445
+ return !0;
1446
+ const s = new Set(
1447
+ g ?? l(this, V1)
1448
+ );
1449
+ return this.options.throwOnError && s.add("error"), Object.keys(l(this, k)).some((p) => {
1450
+ const z = p;
1451
+ return l(this, k)[z] !== a[z] && s.has(z);
1452
+ });
1453
+ };
1454
+ (t == null ? void 0 : t.listeners) !== !1 && v() && (i.listeners = !0), M(this, n2, d0).call(this, { ...i, ...t });
1455
+ }
1456
+ onQueryUpdate() {
1457
+ this.updateResult(), this.hasListeners() && M(this, J1, m2).call(this);
1458
+ }
1459
+ }, E = new WeakMap(), L = new WeakMap(), F1 = new WeakMap(), k = new WeakMap(), u1 = new WeakMap(), k1 = new WeakMap(), Y = new WeakMap(), G1 = new WeakMap(), R1 = new WeakMap(), D1 = new WeakMap(), s1 = new WeakMap(), p1 = new WeakMap(), e1 = new WeakMap(), V1 = new WeakMap(), f1 = new WeakSet(), I1 = function(t) {
1460
+ M(this, X1, w2).call(this);
1461
+ let a = l(this, L).fetch(
1462
+ this.options,
1463
+ t
1464
+ );
1465
+ return t != null && t.throwOnError || (a = a.catch(K)), a;
1466
+ }, q1 = new WeakSet(), p2 = function() {
1467
+ if (M(this, Z1, L2).call(this), E1 || l(this, k).isStale || !H2(this.options.staleTime))
1468
+ return;
1469
+ const a = t0(
1470
+ l(this, k).dataUpdatedAt,
1471
+ this.options.staleTime
1472
+ ) + 1;
1473
+ d(this, s1, setTimeout(() => {
1474
+ l(this, k).isStale || this.updateResult();
1475
+ }, a));
1476
+ }, _1 = new WeakSet(), V2 = function() {
1477
+ return (typeof this.options.refetchInterval == "function" ? this.options.refetchInterval(l(this, L)) : this.options.refetchInterval) ?? !1;
1478
+ }, $1 = new WeakSet(), f2 = function(t) {
1479
+ M(this, Y1, x2).call(this), d(this, e1, t), !(E1 || this.options.enabled === !1 || !H2(l(this, e1)) || l(this, e1) === 0) && d(this, p1, setInterval(() => {
1480
+ (this.options.refetchIntervalInBackground || d2.isFocused()) && M(this, f1, I1).call(this);
1481
+ }, l(this, e1)));
1482
+ }, J1 = new WeakSet(), m2 = function() {
1483
+ M(this, q1, p2).call(this), M(this, $1, f2).call(this, M(this, _1, V2).call(this));
1484
+ }, Z1 = new WeakSet(), L2 = function() {
1485
+ l(this, s1) && (clearTimeout(l(this, s1)), d(this, s1, void 0));
1486
+ }, Y1 = new WeakSet(), x2 = function() {
1487
+ l(this, p1) && (clearInterval(l(this, p1)), d(this, p1, void 0));
1488
+ }, X1 = new WeakSet(), w2 = function() {
1489
+ const t = l(this, E).getQueryCache().build(l(this, E), this.options);
1490
+ if (t === l(this, L))
1491
+ return;
1492
+ const a = l(this, L);
1493
+ d(this, L, t), d(this, F1, t.state), this.hasListeners() && (a == null || a.removeObserver(this), t.addObserver(this));
1494
+ }, n2 = new WeakSet(), d0 = function(t) {
1495
+ S.batch(() => {
1496
+ t.listeners && this.listeners.forEach((a) => {
1497
+ a(l(this, k));
1498
+ }), l(this, E).getQueryCache().notify({
1499
+ query: l(this, L),
1500
+ type: "observerResultsUpdated"
1501
+ });
1502
+ });
1503
+ }, J2);
1504
+ function d4(h, t) {
1505
+ return t.enabled !== !1 && !h.state.dataUpdatedAt && !(h.state.status === "error" && t.retryOnMount === !1);
1506
+ }
1507
+ function N2(h, t) {
1508
+ return d4(h, t) || h.state.dataUpdatedAt > 0 && B2(h, t, t.refetchOnMount);
1509
+ }
1510
+ function B2(h, t, a) {
1511
+ if (t.enabled !== !1) {
1512
+ const c = typeof a == "function" ? a(h) : a;
1513
+ return c === "always" || c !== !1 && y2(h, t);
1514
+ }
1515
+ return !1;
1516
+ }
1517
+ function I2(h, t, a, c) {
1518
+ return a.enabled !== !1 && (h !== t || c.enabled === !1) && (!a.suspense || h.state.status !== "error") && y2(h, a);
1519
+ }
1520
+ function y2(h, t) {
1521
+ return h.isStaleByTime(t.staleTime);
1522
+ }
1523
+ function r4(h, t) {
1524
+ return !v2(h.getCurrentResult(), t);
1525
+ }
1526
+ var z1, T, Q, h1, T1, i2, t2, C2, Z2, n4 = (Z2 = class extends N1 {
1527
+ constructor(t, a) {
1528
+ super();
1529
+ e(this, T1);
1530
+ e(this, t2);
1531
+ e(this, z1, void 0);
1532
+ e(this, T, void 0);
1533
+ e(this, Q, void 0);
1534
+ e(this, h1, void 0);
1535
+ d(this, T, void 0), d(this, z1, t), this.setOptions(a), this.bindMethods(), M(this, T1, i2).call(this);
1536
+ }
1537
+ bindMethods() {
1538
+ this.mutate = this.mutate.bind(this), this.reset = this.reset.bind(this);
1539
+ }
1540
+ setOptions(t) {
1541
+ var c;
1542
+ const a = this.options;
1543
+ this.options = l(this, z1).defaultMutationOptions(t), v2(a, this.options) || l(this, z1).getMutationCache().notify({
1544
+ type: "observerOptionsUpdated",
1545
+ mutation: l(this, Q),
1546
+ observer: this
1547
+ }), (c = l(this, Q)) == null || c.setOptions(this.options);
1548
+ }
1549
+ onUnsubscribe() {
1550
+ var t;
1551
+ this.hasListeners() || (t = l(this, Q)) == null || t.removeObserver(this);
1552
+ }
1553
+ onMutationUpdate(t) {
1554
+ M(this, T1, i2).call(this), M(this, t2, C2).call(this, t);
1555
+ }
1556
+ getCurrentResult() {
1557
+ return l(this, T);
1558
+ }
1559
+ reset() {
1560
+ d(this, Q, void 0), M(this, T1, i2).call(this), M(this, t2, C2).call(this);
1561
+ }
1562
+ mutate(t, a) {
1563
+ var c;
1564
+ return d(this, h1, a), (c = l(this, Q)) == null || c.removeObserver(this), d(this, Q, l(this, z1).getMutationCache().build(l(this, z1), this.options)), l(this, Q).addObserver(this), l(this, Q).execute(t);
1565
+ }
1566
+ }, z1 = new WeakMap(), T = new WeakMap(), Q = new WeakMap(), h1 = new WeakMap(), T1 = new WeakSet(), i2 = function() {
1567
+ var a;
1568
+ const t = ((a = l(this, Q)) == null ? void 0 : a.state) ?? v0();
1569
+ d(this, T, {
1570
+ ...t,
1571
+ isPending: t.status === "pending",
1572
+ isSuccess: t.status === "success",
1573
+ isError: t.status === "error",
1574
+ isIdle: t.status === "idle",
1575
+ mutate: this.mutate,
1576
+ reset: this.reset
1577
+ });
1578
+ }, t2 = new WeakSet(), C2 = function(t) {
1579
+ S.batch(() => {
1580
+ var a, c, i, v, n, g, s, p;
1581
+ l(this, h1) && this.hasListeners() && ((t == null ? void 0 : t.type) === "success" ? ((c = (a = l(this, h1)).onSuccess) == null || c.call(
1582
+ a,
1583
+ t.data,
1584
+ l(this, T).variables,
1585
+ l(this, T).context
1586
+ ), (v = (i = l(this, h1)).onSettled) == null || v.call(
1587
+ i,
1588
+ t.data,
1589
+ null,
1590
+ l(this, T).variables,
1591
+ l(this, T).context
1592
+ )) : (t == null ? void 0 : t.type) === "error" && ((g = (n = l(this, h1)).onError) == null || g.call(
1593
+ n,
1594
+ t.error,
1595
+ l(this, T).variables,
1596
+ l(this, T).context
1597
+ ), (p = (s = l(this, h1)).onSettled) == null || p.call(
1598
+ s,
1599
+ void 0,
1600
+ t.error,
1601
+ l(this, T).variables,
1602
+ l(this, T).context
1603
+ ))), this.listeners.forEach((z) => {
1604
+ z(l(this, T));
1605
+ });
1606
+ });
1607
+ }, Z2);
1608
+ var r0 = b.createContext(
1609
+ void 0
1610
+ ), G = (h) => {
1611
+ const t = b.useContext(r0);
1612
+ if (h)
1613
+ return h;
1614
+ if (!t)
1615
+ throw new Error("No QueryClient set, use QueryClientProvider to set one");
1616
+ return t;
1617
+ }, e4 = ({
1618
+ client: h,
1619
+ children: t
1620
+ }) => (b.useEffect(() => (h.mount(), () => {
1621
+ h.unmount();
1622
+ }), [h]), /* @__PURE__ */ b.createElement(r0.Provider, { value: h }, t)), n0 = b.createContext(!1), z4 = () => b.useContext(n0), nt = n0.Provider;
1623
+ function g4() {
1624
+ let h = !1;
1625
+ return {
1626
+ clearReset: () => {
1627
+ h = !1;
1628
+ },
1629
+ reset: () => {
1630
+ h = !0;
1631
+ },
1632
+ isReset: () => h
1633
+ };
1634
+ }
1635
+ var o4 = b.createContext(g4()), M4 = () => b.useContext(o4);
1636
+ function e0(h, t) {
1637
+ return typeof h == "function" ? h(...t) : !!h;
1638
+ }
1639
+ var H4 = (h, t) => {
1640
+ (h.suspense || h.throwOnError) && (t.isReset() || (h.retryOnMount = !1));
1641
+ }, u4 = (h) => {
1642
+ b.useEffect(() => {
1643
+ h.clearReset();
1644
+ }, [h]);
1645
+ }, s4 = ({
1646
+ result: h,
1647
+ errorResetBoundary: t,
1648
+ throwOnError: a,
1649
+ query: c
1650
+ }) => h.isError && !t.isReset() && !h.isFetching && e0(a, [h.error, c]);
1651
+ var p4 = (h) => {
1652
+ h.suspense && typeof h.staleTime != "number" && (h.staleTime = 1e3);
1653
+ };
1654
+ var V4 = (h, t) => (h == null ? void 0 : h.suspense) && t.isPending, f4 = (h, t, a) => t.fetchOptimistic(h).catch(() => {
1655
+ a.clearReset();
1656
+ });
1657
+ function m4(h, t, a) {
1658
+ if (process.env.NODE_ENV !== "production" && (typeof h != "object" || Array.isArray(h)))
1659
+ throw new Error(
1660
+ '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'
1661
+ );
1662
+ const c = G(a), i = z4(), v = M4(), n = c.defaultQueryOptions(h);
1663
+ n._optimisticResults = i ? "isRestoring" : "optimistic", p4(n), H4(n, v), u4(v);
1664
+ const [g] = b.useState(
1665
+ () => new t(
1666
+ c,
1667
+ n
1668
+ )
1669
+ ), s = g.getOptimisticResult(n);
1670
+ if (b.useSyncExternalStore(
1671
+ b.useCallback(
1672
+ (p) => {
1673
+ const z = i ? () => {
1674
+ } : g.subscribe(S.batchCalls(p));
1675
+ return g.updateResult(), z;
1676
+ },
1677
+ [g, i]
1678
+ ),
1679
+ () => g.getCurrentResult(),
1680
+ () => g.getCurrentResult()
1681
+ ), b.useEffect(() => {
1682
+ g.setOptions(n, { listeners: !1 });
1683
+ }, [n, g]), V4(n, s))
1684
+ throw f4(n, g, v);
1685
+ if (s4({
1686
+ result: s,
1687
+ errorResetBoundary: v,
1688
+ throwOnError: n.throwOnError,
1689
+ query: g.getCurrentQuery()
1690
+ }))
1691
+ throw s.error;
1692
+ return n.notifyOnChangeProps ? s : g.trackResult(s);
1693
+ }
1694
+ function h2(h, t) {
1695
+ return m4(h, v4, t);
1696
+ }
1697
+ function _(h, t) {
1698
+ const a = G(t), [c] = b.useState(
1699
+ () => new n4(
1700
+ a,
1701
+ h
1702
+ )
1703
+ );
1704
+ b.useEffect(() => {
1705
+ c.setOptions(h);
1706
+ }, [c, h]);
1707
+ const i = b.useSyncExternalStore(
1708
+ b.useCallback(
1709
+ (n) => c.subscribe(S.batchCalls(n)),
1710
+ [c]
1711
+ ),
1712
+ () => c.getCurrentResult(),
1713
+ () => c.getCurrentResult()
1714
+ ), v = b.useCallback(
1715
+ (n, g) => {
1716
+ c.mutate(n, g).catch(L4);
1717
+ },
1718
+ [c]
1719
+ );
1720
+ if (i.error && e0(c.options.throwOnError, [i.error]))
1721
+ throw i.error;
1722
+ return { ...i, mutate: v, mutateAsync: i.mutate };
1723
+ }
1724
+ function L4() {
1725
+ }
1726
+ function R() {
1727
+ return G().getQueryData(["apiBaseUrl"]) || "/api/chaibuilder";
1728
+ }
1729
+ const m1 = () => {
1730
+ const { data: h, refetch: t } = h2({
1731
+ queryKey: ["currentPage"],
1732
+ queryFn: () => localStorage.getItem("currentPage") || ""
1733
+ });
1734
+ return [
1735
+ h,
1736
+ (a) => {
1737
+ a && (localStorage.setItem("currentPage", a || ""), t());
1738
+ }
1739
+ ];
1740
+ };
1741
+ let W2 = "";
1742
+ const a2 = () => (W2 = localStorage.getItem("__chai_at"), W2);
1743
+ function x4(h) {
1744
+ const t = {
1745
+ method: "GET",
1746
+ headers: { "x-chai-access-token": a2() }
1747
+ };
1748
+ return fetch(h, t);
1749
+ }
1750
+ function w4(h, t) {
1751
+ const a = {
1752
+ method: "POST",
1753
+ headers: { "x-chai-access-token": a2() },
1754
+ body: JSON.stringify(t)
1755
+ };
1756
+ return fetch(h, a);
1757
+ }
1758
+ function B4(h, t) {
1759
+ const a = {
1760
+ method: "PUT",
1761
+ headers: { "x-chai-access-token": a2() },
1762
+ body: JSON.stringify(t)
1763
+ };
1764
+ return fetch(h, a);
1765
+ }
1766
+ function C4(h, t) {
1767
+ const a = {
1768
+ method: "DELETE",
1769
+ headers: { "x-chai-access-token": a2() },
1770
+ body: JSON.stringify(t)
1771
+ };
1772
+ return fetch(h, a);
1773
+ }
1774
+ const I = {
1775
+ get: x4,
1776
+ post: w4,
1777
+ put: B4,
1778
+ delete: C4
1779
+ }, z0 = () => {
1780
+ const [h, t] = m1(), a = R();
1781
+ return h2({
1782
+ queryKey: ["project"],
1783
+ queryFn: async () => {
1784
+ const { data: c } = await I.get(`${a}/project`).then((i) => i.json());
1785
+ if (!h && c) {
1786
+ const i = localStorage.getItem("currentPage");
1787
+ t(i || (c == null ? void 0 : c.homepage));
1788
+ }
1789
+ return c;
1790
+ }
1791
+ });
1792
+ }, g0 = () => {
1793
+ const h = R();
1794
+ return h2({
1795
+ queryKey: ["pages"],
1796
+ queryFn: async () => {
1797
+ const { data: t } = await I.get(`${h}/pages`).then((a) => a.json());
1798
+ return t || [];
1799
+ }
1800
+ });
1801
+ }, o0 = () => {
1802
+ const [h] = m1(), t = R();
1803
+ return h2({
1804
+ queryKey: ["page_data", h],
1805
+ queryFn: async () => {
1806
+ const { data: a } = await I.get(`${t}/page?uuid=${h}`).then((c) => c.json());
1807
+ return a;
1808
+ },
1809
+ enabled: !!h,
1810
+ staleTime: 3e3
1811
+ });
1812
+ }, O2 = () => /* @__PURE__ */ r.jsx("div", { className: "h-screen w-screen bg-gray-200", children: /* @__PURE__ */ r.jsxs("div", { className: "flex flex-col h-full w-full justify-center items-center", children: [
1813
+ /* @__PURE__ */ r.jsxs("div", { className: "flex flex-row gap-2", children: [
1814
+ /* @__PURE__ */ r.jsx("div", { className: "w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]" }),
1815
+ /* @__PURE__ */ r.jsx("div", { className: "w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]" }),
1816
+ /* @__PURE__ */ r.jsx("div", { className: "w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]" }),
1817
+ /* @__PURE__ */ r.jsx("div", { className: "w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]" })
1818
+ ] }),
1819
+ /* @__PURE__ */ r.jsx("div", { className: "text-gray-700 font-thin", children: "Loading Builder..." })
1820
+ ] }) }), O4 = (h = "Project updated successfully.") => {
1821
+ const t = G(), a = R();
1822
+ return _({
1823
+ mutationFn: async (c) => await I.put(`${a}/project`, c).then((i) => i.json()),
1824
+ onSuccess: () => {
1825
+ t.invalidateQueries({ queryKey: ["project"] }), a1.success(h);
1826
+ }
1827
+ });
1828
+ }, A4 = () => {
1829
+ const [h] = ["SAVED"], [t, a] = m1(), c = L0(), { t: i } = k0();
1830
+ return (v) => h !== "SAVED" ? (a1.error(i("You have unsaved changes. Please save before changing the page.")), !1) : t === v.uuid ? !1 : (c(), setTimeout(() => a(v.uuid), 100), !0);
1831
+ }, et = () => {
1832
+ const h = G(), t = A4(), a = R();
1833
+ return _({
1834
+ mutationFn: async (c) => I.post(`${a}/pages`, c).then((i) => i.json()),
1835
+ onSuccess: (c) => {
1836
+ h.invalidateQueries({ queryKey: ["pages"] }), t({ uuid: c.uuid, slug: c.slug }), a1.success("Page added successfully.");
1837
+ }
1838
+ });
1839
+ }, S4 = () => {
1840
+ const h = R(), [t] = m1(), a = G();
1841
+ return _({
1842
+ mutationFn: async (c) => I.put(`${h}/page`, c).then((i) => i.json()),
1843
+ onSuccess: async (c) => {
1844
+ var i;
1845
+ if (c.result === "error" && ((i = c.error) == null ? void 0 : i.code) == "PAGE_LOCKED") {
1846
+ a.invalidateQueries({ queryKey: ["page_data", t] });
1847
+ return;
1848
+ }
1849
+ a1.success("Page saved successfully.");
1850
+ }
1851
+ });
1852
+ }, y4 = () => {
1853
+ const h = R(), { data: t } = g0(), [a] = m1(), { data: c } = z0(), i = G();
1854
+ return _({
1855
+ mutationFn: async () => {
1856
+ const v = t.find((n) => n.uuid === a).slug;
1857
+ return await I.post(`${h}/publish`, {
1858
+ slug: v,
1859
+ uuid: a,
1860
+ isHomepage: (c == null ? void 0 : c.homepage) === a
1861
+ }).then((n) => n.json());
1862
+ },
1863
+ onSuccess: async (v) => {
1864
+ var n;
1865
+ if (v.result === "error" && ((n = v.error) == null ? void 0 : n.code) == "PAGE_LOCKED") {
1866
+ i.invalidateQueries({ queryKey: ["page_data", a] });
1867
+ return;
1868
+ }
1869
+ a1.success("Page published successfully.", {
1870
+ position: "bottom-right",
1871
+ duration: 2e3
1872
+ });
1873
+ }
1874
+ });
1875
+ }, zt = () => {
1876
+ const h = G(), t = R();
1877
+ return _({
1878
+ mutationFn: async (a) => I.delete(`${t}/page`, a).then((c) => c.json()),
1879
+ onSuccess: () => {
1880
+ a1.success("Page deleted successfully."), h.invalidateQueries({ queryKey: ["pages"] });
1881
+ }
1882
+ });
1883
+ }, b4 = () => {
1884
+ const h = G(), t = R();
1885
+ return _({
1886
+ mutationFn: async (a) => I.post(`${t}/take-control`, { uuid: a }).then((c) => c.json()),
1887
+ onSuccess: (a, c) => {
1888
+ h.invalidateQueries({ queryKey: ["page_data", c] });
1889
+ }
1890
+ });
1891
+ }, P4 = () => {
1892
+ const h = R();
1893
+ return _({
1894
+ mutationFn: async () => {
1895
+ const { data: t } = await I.get(`${h}/library`).then((a) => a.json());
1896
+ return R0(
1897
+ D0(t, (a) => !T0(a, "hidden")),
1898
+ "group"
1899
+ );
1900
+ }
1901
+ });
1902
+ }, F4 = () => {
1903
+ const h = R();
1904
+ return _({
1905
+ mutationFn: async (t) => {
1906
+ if (!t || !t.uuid)
1907
+ return [];
1908
+ try {
1909
+ const { data: a } = await I.get(`${h}/block?uuid=${t.uuid}&format=${t.format}`).then(async (c) => t.format === "html" ? W0(await c.text()) : await c.json());
1910
+ return E0(a, "0._name", N0(t.group)), a || [];
1911
+ } catch {
1912
+ return [];
1913
+ }
1914
+ }
1915
+ });
1916
+ }, k4 = () => {
1917
+ const h = R();
1918
+ return _({
1919
+ mutationFn: async (t) => {
1920
+ const a = new FormData();
1921
+ a.append("file", t);
1922
+ const { data: c } = await fetch(`${h}/upload`, {
1923
+ method: "POST",
1924
+ headers: { "x-chai-access-token": a2() },
1925
+ body: a
1926
+ }).then((i) => i.json());
1927
+ return c;
1928
+ }
1929
+ });
1930
+ };
1931
+ function M0(h) {
1932
+ return X2({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M20 4H4c-1.1 0-1.99.9-1.99 2L2 18c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V6c0-1.1-.9-2-2-2zm0 4-8 5-8-5V6l8 5 8-5v2z" }, child: [] }] })(h);
1933
+ }
1934
+ function R4(h) {
1935
+ return X2({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { fill: "none", d: "M0 0h24v24H0z" }, child: [] }, { tag: "path", attr: { d: "M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z" }, child: [] }] })(h);
1936
+ }
1937
+ const D4 = () => {
1938
+ const { mutate: h, isPending: t } = b4(), [a] = m1(), { data: c } = o0(), i = b2(c, "lockedBy.name", ""), v = b2(c, "lockedBy.email", "");
1939
+ return /* @__PURE__ */ r.jsxs("div", { className: "bg-white dark:bg-gray-800 rounded-lg drop-shadow-2xl mx-auto p-10 space-y-4 text-center max-w-xl", children: [
1940
+ /* @__PURE__ */ r.jsxs("h2", { className: "text-2xl font-bold", children: [
1941
+ "Page is ",
1942
+ /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "locked" })
1943
+ ] }),
1944
+ /* @__PURE__ */ r.jsxs("div", { className: "text-gray-500 dark:text-gray-400 font-light", children: [
1945
+ "This page is currently being edited by ",
1946
+ /* @__PURE__ */ r.jsx("br", {}),
1947
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm", children: [
1948
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md", children: [
1949
+ /* @__PURE__ */ r.jsx(R4, { className: "w-4 h-4 text-gray-500" }),
1950
+ " ",
1951
+ i
1952
+ ] }),
1953
+ /* @__PURE__ */ r.jsxs("div", { className: "flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase", children: [
1954
+ /* @__PURE__ */ r.jsx(M0, { className: "w-4 h-4 text-gray-500" }),
1955
+ " ",
1956
+ v
1957
+ ] })
1958
+ ] }),
1959
+ /* @__PURE__ */ r.jsxs("div", { className: "pt-4", children: [
1960
+ "If you take control, ",
1961
+ i,
1962
+ " will be ",
1963
+ /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "restricted" }),
1964
+ " from making additional edits."
1965
+ ] })
1966
+ ] }),
1967
+ /* @__PURE__ */ r.jsx(
1968
+ Y2,
1969
+ {
1970
+ disabled: t,
1971
+ onClick: () => h(a),
1972
+ className: `w-36 ${t ? "bg-transparent shadow-none hover:bg-transparent" : ""}`,
1973
+ children: t ? /* @__PURE__ */ r.jsx(U0, { className: "text-sm animate-spin text-gray-500" }) : "Take Over"
1974
+ }
1975
+ )
1976
+ ] });
1977
+ }, T4 = () => {
1978
+ const h = R(), t = G();
1979
+ return _({
1980
+ mutationFn: async (a) => {
1981
+ const c = await fetch(`${h}/login`, { method: "POST", body: JSON.stringify(a) });
1982
+ if (c.ok)
1983
+ return await c.json();
1984
+ throw c.status === 401 ? new Error("Invalid login credentials") : new Error("Invalid");
1985
+ },
1986
+ onSuccess: (a) => {
1987
+ const { data: c } = a;
1988
+ if (!c.accessToken) {
1989
+ a1.error("Something went wrong. Please try again.", { position: "top-center" });
1990
+ return;
1991
+ }
1992
+ localStorage.setItem("__chai_at", c.accessToken), localStorage.setItem("__chai_ur", JSON.stringify(I0(c, ["accessToken"]))), t.invalidateQueries({ queryKey: ["verify"] }), a1.success("Logged in successfully.");
1993
+ },
1994
+ onError: () => {
1995
+ a1.error("Invalid login credentials. Please try again.", { position: "top-center" });
1996
+ }
1997
+ });
1998
+ }, E4 = () => {
1999
+ const h = R();
2000
+ return h2({
2001
+ queryKey: ["verify"],
2002
+ queryFn: async () => {
2003
+ const t = await I.get(`${h}/verify`);
2004
+ return t.ok ? (await t.json()).result === "success" ? { valid: !0 } : (localStorage.removeItem("__chai_at"), { valid: !1 }) : (localStorage.removeItem("__chai_at"), { valid: !0 });
2005
+ }
2006
+ });
2007
+ }, N4 = () => {
2008
+ const h = R(), t = G();
2009
+ return _({
2010
+ mutationFn: async () => {
2011
+ const { result: a } = await I.post(`${h}/logout`).then((c) => c.json());
2012
+ if (a === "success")
2013
+ return localStorage.clear(), t.invalidateQueries({ queryKey: ["verify"] }), { logout: !0 };
2014
+ throw new Error("Invalid session");
2015
+ }
2016
+ });
2017
+ }, I4 = ({ children: h }) => {
2018
+ const t = N4();
2019
+ return /* @__PURE__ */ r.jsxs(x0, { children: [
2020
+ /* @__PURE__ */ r.jsx(w0, { asChild: !0, children: h }),
2021
+ /* @__PURE__ */ r.jsxs(B0, { children: [
2022
+ /* @__PURE__ */ r.jsxs(C0, { children: [
2023
+ /* @__PURE__ */ r.jsxs(O0, { children: [
2024
+ "Are you sure, you want to ",
2025
+ /* @__PURE__ */ r.jsx("span", { className: "text-red-500", children: "Sign Out" }),
2026
+ "?"
2027
+ ] }),
2028
+ /* @__PURE__ */ r.jsx(A0, { children: "Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information" })
2029
+ ] }),
2030
+ /* @__PURE__ */ r.jsxs(S0, { children: [
2031
+ /* @__PURE__ */ r.jsx(y0, { disabled: t.isPending, children: "Cancel" }),
2032
+ /* @__PURE__ */ r.jsxs(
2033
+ "button",
2034
+ {
2035
+ disabled: t.isPending,
2036
+ onClick: () => t.mutate(),
2037
+ className: "rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",
2038
+ children: [
2039
+ t.isPending && /* @__PURE__ */ r.jsx(j0, { className: "animate-spin w-5 h-5" }),
2040
+ "Sign Out"
2041
+ ]
2042
+ }
2043
+ )
2044
+ ] })
2045
+ ] })
2046
+ ] });
2047
+ }, W4 = () => /* @__PURE__ */ r.jsx(I4, { children: /* @__PURE__ */ r.jsx("button", { className: "border-gray-200 rounded-md p-2 mb-2 border", children: /* @__PURE__ */ r.jsx(Q0, { className: "w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300" }) }) }), U4 = A2(() => import("./PagesPanel-XiTUaiq_.js")), j4 = A2(() => import("./ProjectPanel-XfknsGkz.js")), Q4 = A2(() => import("./CurrentPage-7NM90y76.js")), K4 = () => /* @__PURE__ */ r.jsx("h2", { children: "Your Logo" }), G4 = () => {
2048
+ const { mutate: h } = y4();
2049
+ return b0("editable", !0) ? /* @__PURE__ */ r.jsx(Y2, { onClick: h, className: "bg-blue-600 text-white", children: "Publish" }) : null;
2050
+ }, q4 = (h) => {
2051
+ var f;
2052
+ const { data: t, isLoading: a } = z0(), { data: c, isLoading: i } = g0(), { data: v } = o0(), { mutate: n } = O4(), { mutate: g } = S4(), [s] = m1(), p = k4(), z = P4(), x = F4(), F = R(), H = g2(
2053
+ async (m) => await p.mutateAsync(m),
2054
+ [p]
2055
+ ), V = g2(async () => await z.mutateAsync(), [z]), B = g2(
2056
+ async (m) => await x.mutateAsync(m),
2057
+ [x]
2058
+ ), o = async (m = 20, P = 0) => {
2059
+ const D = `limit=${m}&offset=${P}`, C = await fetch(`${F}/assets?${D}`).then((w) => w.json());
2060
+ return C.result === "success" ? C.data : [];
2061
+ }, { logo: u = K4 } = h;
2062
+ if (a || !t)
2063
+ return /* @__PURE__ */ r.jsx(O2, {});
2064
+ if (i || !c)
2065
+ return /* @__PURE__ */ r.jsx(O2, {});
2066
+ const O = {
2067
+ ...h,
2068
+ editable: v != null && v.lockedBy ? v == null ? void 0 : v.lockedBy.self : !0,
2069
+ nonEditableComponent: D4,
2070
+ blocks: (v == null ? void 0 : v.blocks) || [],
2071
+ brandingOptions: t.brandingOptions,
2072
+ darkMode: h.darkMode || !1,
2073
+ dataProviders: (v == null ? void 0 : v.providers) || [],
2074
+ onSavePage: async ({ blocks: m, providers: P }) => (await g({ blocks: m, providers: P, uuid: s }), !0),
2075
+ onSaveBrandingOptions: async (m) => (await n({ brandingOptions: m }), !0),
2076
+ topBarComponents: {
2077
+ left: [u],
2078
+ center: [Q4],
2079
+ right: [G4]
2080
+ },
2081
+ sideBarComponents: {
2082
+ top: [
2083
+ { icon: p0, name: "pages", panel: U4 },
2084
+ { icon: V0, name: "settings", panel: j4 },
2085
+ ...((f = h.sideBarComponents) == null ? void 0 : f.top) || []
2086
+ ],
2087
+ bottom: [W4]
2088
+ },
2089
+ uploadMediaCallback: H,
2090
+ fetchMediaCallback: o,
2091
+ getUILibraryBlocks: V,
2092
+ getExternalPredefinedBlock: B,
2093
+ getPages: () => c
2094
+ };
2095
+ return /* @__PURE__ */ r.jsx(P0, { ...O });
2096
+ }, _4 = ({ logo: h }) => {
2097
+ const [t, a] = o2(!1), [c, i] = o2(""), [v, n] = o2(""), { mutate: g, isPending: s } = T4(), p = (z) => {
2098
+ z.preventDefault(), g({ email: c, password: v });
2099
+ };
2100
+ return /* @__PURE__ */ r.jsx("section", { className: "h-screen w-screen flex items-center justify-center bg-[radial-gradient(#AAA,transparent_0.5px)] duration-300 [background-size:6px_6px]", children: /* @__PURE__ */ r.jsx("div", { className: "overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300", children: /* @__PURE__ */ r.jsxs("div", { className: "p-12", children: [
2101
+ /* @__PURE__ */ r.jsxs("div", { className: "max-w-2xl mx-auto text-center", children: [
2102
+ /* @__PURE__ */ r.jsx(u0, { children: h ? H0.createElement(h) : "" }),
2103
+ /* @__PURE__ */ r.jsx("p", { className: "max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin", children: "Enter your login credential to continue" })
2104
+ ] }),
2105
+ /* @__PURE__ */ r.jsx("div", { className: "mt-8", children: /* @__PURE__ */ r.jsxs("form", { method: "POST", onSubmit: p, className: "space-y-5", children: [
2106
+ /* @__PURE__ */ r.jsx("div", { children: /* @__PURE__ */ r.jsxs("div", { className: "mt-2.5 relative text-gray-400 focus-within:text-gray-600", children: [
2107
+ /* @__PURE__ */ r.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none", children: /* @__PURE__ */ r.jsx(M0, {}) }),
2108
+ /* @__PURE__ */ r.jsx(
2109
+ "input",
2110
+ {
2111
+ value: c,
2112
+ onChange: (z) => i(z.target.value),
2113
+ type: "email",
2114
+ id: "email",
2115
+ placeholder: "Enter email",
2116
+ className: "block w-full py-4 px-10 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"
2117
+ }
2118
+ )
2119
+ ] }) }),
2120
+ /* @__PURE__ */ r.jsx("div", { children: /* @__PURE__ */ r.jsxs("div", { className: "mt-2.5 relative text-gray-400 focus-within:text-gray-600", children: [
2121
+ /* @__PURE__ */ r.jsx("div", { className: "absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none", children: /* @__PURE__ */ r.jsx(
2122
+ "svg",
2123
+ {
2124
+ className: "w-5 h-5",
2125
+ xmlns: "http://www.w3.org/2000/svg",
2126
+ fill: "none",
2127
+ viewBox: "0 0 24 24",
2128
+ stroke: "currentColor",
2129
+ children: /* @__PURE__ */ r.jsx(
2130
+ "path",
2131
+ {
2132
+ strokeLinecap: "round",
2133
+ strokeLinejoin: "round",
2134
+ strokeWidth: "2",
2135
+ 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"
2136
+ }
2137
+ )
2138
+ }
2139
+ ) }),
2140
+ /* @__PURE__ */ r.jsx(
2141
+ "input",
2142
+ {
2143
+ value: v,
2144
+ onChange: (z) => n(z.target.value),
2145
+ type: t ? "text" : "password",
2146
+ id: "pwd",
2147
+ placeholder: "Enter password",
2148
+ className: "block w-full py-4 px-10 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"
2149
+ }
2150
+ ),
2151
+ /* @__PURE__ */ r.jsx(
2152
+ "button",
2153
+ {
2154
+ type: "button",
2155
+ className: "absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",
2156
+ onClick: () => a(!t),
2157
+ children: t ? /* @__PURE__ */ r.jsx(f0, {}) : /* @__PURE__ */ r.jsx(m0, {})
2158
+ }
2159
+ )
2160
+ ] }) }),
2161
+ /* @__PURE__ */ r.jsx("div", { children: /* @__PURE__ */ r.jsx(
2162
+ "button",
2163
+ {
2164
+ disabled: s || P2(c) < 2 || P2(v) < 2,
2165
+ type: "submit",
2166
+ className: "inline-flex disabled:bg-gray-400 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",
2167
+ children: s ? "Signing in..." : "Login"
2168
+ }
2169
+ ) })
2170
+ ] }) }),
2171
+ /* @__PURE__ */ r.jsx("div", { className: "mt-4 flex items-center justify-end gap-x-2 text-sm", children: /* @__PURE__ */ r.jsx(
2172
+ "a",
2173
+ {
2174
+ href: "https://apps.chaibuilder.com/settings",
2175
+ target: "_blank",
2176
+ className: "text-gray-500 hover:text-blue-400",
2177
+ children: "Forget your password?"
2178
+ }
2179
+ ) })
2180
+ ] }) }) });
2181
+ }, $4 = (h) => {
2182
+ const { data: t, isLoading: a } = E4(), c = G();
2183
+ return s0(() => {
2184
+ c.setQueryData(["apiBaseUrl"], h.apiBaseUrl || "/api/chaibuilder");
2185
+ }, [h.apiBaseUrl, c]), a ? /* @__PURE__ */ r.jsx(O2, {}) : t != null && t.valid ? /* @__PURE__ */ r.jsx(q4, { ...h }) : /* @__PURE__ */ r.jsx(_4, { logo: h.logo });
2186
+ }, J4 = new i4(), gt = (h) => /* @__PURE__ */ r.jsxs(e4, { client: J4, children: [
2187
+ /* @__PURE__ */ r.jsx(F0, { richColors: !0 }),
2188
+ /* @__PURE__ */ r.jsx($4, { ...h })
2189
+ ] });
2190
+ export {
2191
+ gt as C,
2192
+ z0 as a,
2193
+ O4 as b,
2194
+ A4 as c,
2195
+ m1 as d,
2196
+ et as e,
2197
+ G as f,
2198
+ S4 as g,
2199
+ zt as h,
2200
+ g0 as u
2201
+ };