@chaibuilder/sdk 1.2.16 → 1.2.17

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