@chaibuilder/sdk 1.2.65 → 1.2.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/AddBlocks-TVOOPK2w.cjs +1 -0
- package/dist/AddBlocks-mbuhydG3.js +123 -0
- package/dist/CanvasArea-KJMcis97.cjs +1 -0
- package/dist/CanvasArea-kg3Rgg9t.js +136 -0
- package/dist/CodeEditor-QP6l0mv4.cjs +1 -0
- package/dist/{CodeEditor-Qff4q7sx.js → CodeEditor-q5unEaUI.js} +60 -46
- package/dist/STRINGS--j49GZJP.js +7 -0
- package/dist/STRINGS-gPz7CUOk.cjs +1 -0
- package/dist/SettingsPanel-MWeQjDWs.cjs +1 -0
- package/dist/SettingsPanel-pomLrOxB.js +81 -0
- package/dist/SidePanels-9sbERNEv.cjs +1 -0
- package/dist/{SidePanels-ijaUKSek.js → SidePanels-YpRrvfiH.js} +87 -93
- package/dist/{Topbar-vHlnfxPs.js → Topbar-kVBx7pp4.js} +56 -61
- package/dist/Topbar-veJ2_blW.cjs +1 -0
- package/dist/{UILibrariesPanel-NVUMUPUj.js → UILibrariesPanel-ES8YzN9C.js} +92 -101
- package/dist/UILibrariesPanel-H8t36R6M.cjs +1 -0
- package/dist/UnsplashImages--MXx-DYM.cjs +1 -0
- package/dist/{UnsplashImages-UkHihhA5.js → UnsplashImages-sotLcz6r.js} +72 -57
- package/dist/{UploadImages-HtuJZJlo.js → UploadImages-I0QQ6vj1.js} +57 -44
- package/dist/UploadImages-xhxeYKkl.cjs +1 -0
- package/dist/badge-7BVT3zxN.cjs +1 -0
- package/dist/badge-pJqQSA13.js +23 -0
- package/dist/context-menu-_8TFbFEJ.cjs +1 -0
- package/dist/context-menu-sks9vdzC.js +906 -0
- package/dist/core.cjs +1 -1
- package/dist/core.d.ts +45 -20
- package/dist/core.js +85 -87
- package/dist/iconBase-vJD0OXxU.cjs +1 -0
- package/dist/iconBase-zweRWSz0.js +323 -0
- package/dist/index-5hfuDpYs.cjs +223 -0
- package/dist/index-Zu-K_BX7.js +33933 -0
- package/dist/jsx-runtime-JYMCiFoE.cjs +27 -0
- package/dist/{jsx-runtime-WbnYoNE9.js → jsx-runtime-Sp0orL4X.js} +106 -109
- package/dist/plugin-P0tpo_XZ.cjs +1 -0
- package/dist/plugin-_F-KZp1i.cjs +1 -0
- package/dist/plugin-f5uJtdXY.js +43 -0
- package/dist/plugin-sJ3Hzvpv.js +57 -0
- package/dist/render.cjs +3 -1
- package/dist/render.d.ts +19 -52
- package/dist/render.js +136 -183
- package/dist/select-JW3OMYm-.js +75 -0
- package/dist/select-fXj5tdMX.cjs +1 -0
- package/dist/separator-hT24N-xp.cjs +1 -0
- package/dist/separator-sgwOa1FE.js +18 -0
- package/dist/style.css +1 -1
- package/dist/tailwind.cjs +1 -1
- package/dist/tailwind.d.ts +41 -1
- package/dist/tailwind.js +16 -8
- package/dist/ui.cjs +1 -1
- package/dist/ui.d.ts +0 -10
- package/dist/ui.js +345 -163
- package/dist/web-blocks.cjs +1 -1
- package/dist/web-blocks.d.ts +1 -1
- package/dist/web-blocks.js +489 -724
- package/package.json +15 -45
- package/dist/CanvasArea-fSdH_RiN.cjs +0 -1
- package/dist/CanvasArea-ut5yknzX.js +0 -168
- package/dist/CodeEditor-ypUx3RAV.cjs +0 -1
- package/dist/CurrentPage-jHSVy3hq.js +0 -120
- package/dist/CurrentPage-p_AM4lrF.cjs +0 -1
- package/dist/Functions-7jnEwJyw.js +0 -15
- package/dist/Functions-N3yhPYKY.cjs +0 -1
- package/dist/MODIFIERS-fd5XOmum.js +0 -60
- package/dist/MODIFIERS-mVmfEGgo.cjs +0 -1
- package/dist/PagesPanel-U3InJ9Db.js +0 -78
- package/dist/PagesPanel-wqDb4D-x.cjs +0 -1
- package/dist/ProjectPanel-XODJTO4J.js +0 -99
- package/dist/ProjectPanel-fWESzHr6.cjs +0 -1
- package/dist/SidePanels-lrMQqc0h.cjs +0 -1
- package/dist/Topbar-RrCDxd0i.cjs +0 -1
- package/dist/UILibrariesPanel-7btHgBD0.cjs +0 -1
- package/dist/UnsplashImages-6UjgojvF.cjs +0 -1
- package/dist/UploadImages-3h0cRsvr.cjs +0 -1
- package/dist/_commonjsHelpers-UyOWmZb0.js +0 -8
- package/dist/_commonjsHelpers-wDK0ZLPo.cjs +0 -1
- package/dist/add-page-modal-RwIj1FxH.cjs +0 -1
- package/dist/add-page-modal-TOfMfmPA.js +0 -115
- package/dist/confirm-alert-eIp2cAkc.js +0 -60
- package/dist/confirm-alert-v1lG8ex4.cjs +0 -1
- package/dist/controls-rRZhz0vu.cjs +0 -1
- package/dist/controls-yjgoZzB6.js +0 -199
- package/dist/delete-page-modal-4bxjpVBD.js +0 -97
- package/dist/delete-page-modal-qYDZmpgT.cjs +0 -1
- package/dist/email-blocks.cjs +0 -1
- package/dist/email-blocks.d.ts +0 -3
- package/dist/email-blocks.js +0 -294
- package/dist/email.cjs +0 -1
- package/dist/email.d.ts +0 -171
- package/dist/email.js +0 -90
- package/dist/empty-slot-Lsxjts7Q.js +0 -6
- package/dist/empty-slot-Sy930lX6.cjs +0 -1
- package/dist/form-4jTocVbZ.cjs +0 -1
- package/dist/form-NAzFjGs0.js +0 -125
- package/dist/functions--tdNWQDW.js +0 -30
- package/dist/functions-EVUeSwX1.cjs +0 -1
- package/dist/html-to-json-NqRjgFqp.cjs +0 -1
- package/dist/html-to-json-l_mw5y-e.js +0 -243
- package/dist/index--k2M8kzI.cjs +0 -1
- package/dist/index--mLLy7QQ.cjs +0 -1
- package/dist/index-5XyNUAjc.cjs +0 -290
- package/dist/index-C7mB4XFm.js +0 -3141
- package/dist/index-VBXQixVm.js +0 -117
- package/dist/index-YZhtVcj_.js +0 -2201
- package/dist/index-aeDphKpP.cjs +0 -1
- package/dist/index-lFgDm1oa.js +0 -83780
- package/dist/jsx-runtime-Z_BpKhVy.cjs +0 -27
- package/dist/lib.cjs +0 -3
- package/dist/lib.d.ts +0 -80
- package/dist/lib.js +0 -1350
- package/dist/page-viewer-4wrnWnK0.js +0 -124
- package/dist/page-viewer-ra0GLx1p.cjs +0 -1
- package/dist/project-general-setting-IwZUkYF3.js +0 -90
- package/dist/project-general-setting-lFjTUhHD.cjs +0 -1
- package/dist/project-seo-setting-e1fTqVsd.js +0 -83
- package/dist/project-seo-setting-o0V9acCV.cjs +0 -1
- package/dist/server.cjs +0 -1
- package/dist/server.d.ts +0 -299
- package/dist/server.js +0 -216
- package/dist/single-page-detail-ZNWFKqLW.js +0 -229
- package/dist/single-page-detail-g55Anu7R.cjs +0 -1
- package/dist/studio.cjs +0 -1
- package/dist/studio.d.ts +0 -176
- package/dist/studio.js +0 -67
- package/dist/utils-D_vtk3zK.cjs +0 -1
- package/dist/utils-VpVqnC9m.js +0 -1075
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
import { g as P } from "./_commonjsHelpers-UyOWmZb0.js";
|
|
2
|
-
import { stringify as y, parse as k } from "himalaya";
|
|
3
|
-
import { g as S, c as M } from "./Functions-7jnEwJyw.js";
|
|
4
|
-
import { isEmpty as g, includes as m, get as l, forEach as A, find as o, set as u, capitalize as C, flatMapDeep as B, filter as E, flatten as R } from "lodash-es";
|
|
5
|
-
import { a as p } from "./MODIFIERS-fd5XOmum.js";
|
|
6
|
-
import { has as H, startsWith as I } from "lodash";
|
|
7
|
-
var d = {}, b = {};
|
|
8
|
-
(function(t) {
|
|
9
|
-
"use strict";
|
|
10
|
-
Object.defineProperty(t, "__esModule", {
|
|
11
|
-
value: !0
|
|
12
|
-
}), Object.defineProperty(t, "default", {
|
|
13
|
-
enumerable: !0,
|
|
14
|
-
get: function() {
|
|
15
|
-
return r;
|
|
16
|
-
}
|
|
17
|
-
});
|
|
18
|
-
function e(a, s) {
|
|
19
|
-
return {
|
|
20
|
-
handler: a,
|
|
21
|
-
config: s
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
e.withOptions = function(a, s = () => ({})) {
|
|
25
|
-
const c = function(n) {
|
|
26
|
-
return {
|
|
27
|
-
__options: n,
|
|
28
|
-
handler: a(n),
|
|
29
|
-
config: s(n)
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
return c.__isOptionsFunction = !0, c.__pluginFunction = a, c.__configFunction = s, c;
|
|
33
|
-
};
|
|
34
|
-
const r = e;
|
|
35
|
-
})(b);
|
|
36
|
-
(function(t) {
|
|
37
|
-
"use strict";
|
|
38
|
-
Object.defineProperty(t, "__esModule", {
|
|
39
|
-
value: !0
|
|
40
|
-
}), Object.defineProperty(t, "default", {
|
|
41
|
-
enumerable: !0,
|
|
42
|
-
get: function() {
|
|
43
|
-
return a;
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
const e = /* @__PURE__ */ r(b);
|
|
47
|
-
function r(s) {
|
|
48
|
-
return s && s.__esModule ? s : {
|
|
49
|
-
default: s
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
const a = e.default;
|
|
53
|
-
})(d);
|
|
54
|
-
let f = d;
|
|
55
|
-
var q = (f.__esModule ? f : { default: f }).default;
|
|
56
|
-
const X = /* @__PURE__ */ P(q), F = (t) => {
|
|
57
|
-
const e = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, r = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
|
|
58
|
-
return e.test(t) || r.test(t);
|
|
59
|
-
}, O = (t) => {
|
|
60
|
-
if (g(t))
|
|
61
|
-
return t;
|
|
62
|
-
const e = /<video[^>]+src=['"]([^'">]+)['"]/, r = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = t.match(e), s = t.match(r), c = a ? a[1] : s ? s[1] : null, n = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, i = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
|
|
63
|
-
return c && (n.test(c) || i.test(c)) ? c : t;
|
|
64
|
-
}, v = "$name", U = {
|
|
65
|
-
img: { alt: "alt", width: "width", height: "height", src: "image" },
|
|
66
|
-
video: {
|
|
67
|
-
src: "url",
|
|
68
|
-
autoplay: "controls.autoPlay",
|
|
69
|
-
muted: "controls.muted",
|
|
70
|
-
loop: "controls.loop",
|
|
71
|
-
controls: "controls.widgets"
|
|
72
|
-
},
|
|
73
|
-
a: {
|
|
74
|
-
href: "link.href",
|
|
75
|
-
target: "link.target",
|
|
76
|
-
type: ""
|
|
77
|
-
// @TODO: Detect here what to url, email, phone, elementId
|
|
78
|
-
},
|
|
79
|
-
input: {
|
|
80
|
-
placeholder: "placeholder",
|
|
81
|
-
required: "required",
|
|
82
|
-
type: "inputType",
|
|
83
|
-
name: "fieldName"
|
|
84
|
-
},
|
|
85
|
-
textarea: {
|
|
86
|
-
placeholder: "placeholder",
|
|
87
|
-
required: "required",
|
|
88
|
-
type: "inputType",
|
|
89
|
-
name: "fieldName"
|
|
90
|
-
},
|
|
91
|
-
select: {
|
|
92
|
-
placeholder: "placeholder",
|
|
93
|
-
required: "required",
|
|
94
|
-
multiple: "multiple",
|
|
95
|
-
name: "fieldName"
|
|
96
|
-
}
|
|
97
|
-
}, z = (t, e) => t.children.length === 1 && m(["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link"], e._type), T = (t) => t.map((e) => e.type === "text" ? l(e, "content", "") : g(e.children) ? "" : T(e.children)).join(""), h = (t) => t === null ? "" : t, _ = (t) => {
|
|
98
|
-
if (t.tagName === "svg")
|
|
99
|
-
return {};
|
|
100
|
-
const e = {}, r = U[t.tagName] || {}, a = t.attributes;
|
|
101
|
-
return A(a, ({ key: s, value: c }) => {
|
|
102
|
-
if (s !== v)
|
|
103
|
-
if (r[s]) {
|
|
104
|
-
if (t.tagName === "img" && s === "src" && !c.startsWith("http")) {
|
|
105
|
-
const n = o(t.attributes, { key: "width" }), i = o(t.attributes, { key: "height" });
|
|
106
|
-
n && i ? c = `https://via.placeholder.com/${n == null ? void 0 : n.value}x${i == null ? void 0 : i.value}` : c = "https://via.placeholder.com/150x150";
|
|
107
|
-
}
|
|
108
|
-
u(e, r[s], h(c));
|
|
109
|
-
} else
|
|
110
|
-
m(["style", "class", "srcset"], s) || (H(e, "styles_attrs") || (e.styles_attrs = {}), I(s, "@") && (s = s.replace("@", "x-on:")), e.styles_attrs[`${s}`] = h(c));
|
|
111
|
-
}), delete e.class, e;
|
|
112
|
-
}, D = (t, e = "styles") => {
|
|
113
|
-
if (!t.attributes)
|
|
114
|
-
return { [e]: `${p},` };
|
|
115
|
-
const r = o(t.attributes, { key: "class" });
|
|
116
|
-
if (r) {
|
|
117
|
-
const a = r.value;
|
|
118
|
-
return { [e]: `${p},${a}` };
|
|
119
|
-
}
|
|
120
|
-
return { [e]: `${p},` };
|
|
121
|
-
}, V = (t) => {
|
|
122
|
-
switch (t.tagName) {
|
|
123
|
-
case "img":
|
|
124
|
-
return { _type: "Image" };
|
|
125
|
-
case "input":
|
|
126
|
-
return { _type: "Input", showLabel: !1 };
|
|
127
|
-
case "hr":
|
|
128
|
-
return { _type: "Divider" };
|
|
129
|
-
case "br":
|
|
130
|
-
return { _type: "LineBreak" };
|
|
131
|
-
case "textarea":
|
|
132
|
-
return { _type: "TextArea", showLabel: !1 };
|
|
133
|
-
case "audio":
|
|
134
|
-
return { _type: "Audio" };
|
|
135
|
-
case "canvas":
|
|
136
|
-
return { _type: "Canvas" };
|
|
137
|
-
case "video":
|
|
138
|
-
case "iframe":
|
|
139
|
-
return { _type: "CustomHTML" };
|
|
140
|
-
case "svg":
|
|
141
|
-
return { _type: "Icon" };
|
|
142
|
-
case "select":
|
|
143
|
-
return { _type: "Select", options: [] };
|
|
144
|
-
case "option":
|
|
145
|
-
return { _type: "Option" };
|
|
146
|
-
case "ul":
|
|
147
|
-
case "ol":
|
|
148
|
-
case "dl":
|
|
149
|
-
return {
|
|
150
|
-
_type: "List",
|
|
151
|
-
tag: t.tagName,
|
|
152
|
-
_listType: t.tagName === "ol" ? "list-decimal" : "list-none"
|
|
153
|
-
};
|
|
154
|
-
case "li":
|
|
155
|
-
case "dt":
|
|
156
|
-
return { _type: "ListItem", tag: t.tagName };
|
|
157
|
-
case "span":
|
|
158
|
-
case "figcaption":
|
|
159
|
-
case "legend":
|
|
160
|
-
return { _type: "Span", tag: t.tagName };
|
|
161
|
-
case "p":
|
|
162
|
-
return { _type: "Paragraph", content: "" };
|
|
163
|
-
case "a":
|
|
164
|
-
return { _type: "Link" };
|
|
165
|
-
case "form":
|
|
166
|
-
return { _type: "Form" };
|
|
167
|
-
case "label":
|
|
168
|
-
return { _type: "Label" };
|
|
169
|
-
case "button":
|
|
170
|
-
return { _type: "Button" };
|
|
171
|
-
case "code":
|
|
172
|
-
return { _type: "Code" };
|
|
173
|
-
case "h1":
|
|
174
|
-
case "h2":
|
|
175
|
-
case "h3":
|
|
176
|
-
case "h4":
|
|
177
|
-
case "h5":
|
|
178
|
-
case "h6":
|
|
179
|
-
return { _type: "Heading", tag: t.tagName };
|
|
180
|
-
case "table":
|
|
181
|
-
return { _type: "Table" };
|
|
182
|
-
case "tr":
|
|
183
|
-
return { _type: "TableRow" };
|
|
184
|
-
case "td":
|
|
185
|
-
case "th":
|
|
186
|
-
return { _type: "TableCell", tag: t.tagName };
|
|
187
|
-
case "thead":
|
|
188
|
-
return { _type: "TableHead" };
|
|
189
|
-
case "tbody":
|
|
190
|
-
return { _type: "TableBody" };
|
|
191
|
-
case "tfoot":
|
|
192
|
-
return { _type: "TableFooter" };
|
|
193
|
-
default:
|
|
194
|
-
const e = l(t, "children", []).length > 0 ? "Box" : "EmptyBox";
|
|
195
|
-
return {
|
|
196
|
-
_type: e,
|
|
197
|
-
tag: t.tagName,
|
|
198
|
-
_name: e == "EmptyBox" || t.tagName === "div" ? e : C(t.tagName)
|
|
199
|
-
};
|
|
200
|
-
}
|
|
201
|
-
}, x = (t, e = null) => B(t, (r) => {
|
|
202
|
-
var c;
|
|
203
|
-
if (r.type === "comment")
|
|
204
|
-
return [];
|
|
205
|
-
let a = { _id: S() };
|
|
206
|
-
if (e && (a._parent = e.block._id), r.type === "text")
|
|
207
|
-
return g(l(r, "content", "")) ? [] : e && z(e.node, e.block) ? (u(e, "block.content", l(r, "content", "")), []) : { ...a, _type: "Text", content: l(r, "content", "") };
|
|
208
|
-
if (a = {
|
|
209
|
-
...a,
|
|
210
|
-
...V(r),
|
|
211
|
-
..._(r),
|
|
212
|
-
...D(r)
|
|
213
|
-
}, r.attributes) {
|
|
214
|
-
const n = r.attributes.find((i) => i.key === v);
|
|
215
|
-
n && (a._name = n.value);
|
|
216
|
-
}
|
|
217
|
-
if (a._type === "Input") {
|
|
218
|
-
const n = a.inputType || "text";
|
|
219
|
-
n === "checkbox" ? u(a, "_type", "Checkbox") : n === "radio" && u(a, "_type", "Radio");
|
|
220
|
-
} else if (r.tagName === "video" || r.tagName === "iframe") {
|
|
221
|
-
const n = y([r]);
|
|
222
|
-
return F(n) && (u(a, "_type", "Video"), u(a, "url", O(n)), u(a, "styles", `${p},absolute top-0 left-0 w-full h-full`), u(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = n, [a];
|
|
223
|
-
} else if (r.tagName === "svg") {
|
|
224
|
-
const n = o(r.attributes, { key: "height" }), i = o(r.attributes, { key: "width" }), w = l(n, "value") ? `[${l(n, "value")}px]` : "24px", N = l(i, "value") ? `[${l(i, "value")}px]` : "24px", $ = l(o(r.attributes, { key: "class" }), "value", "w-full h-full");
|
|
225
|
-
return a.styles = `${p}, ${M(`w-${N} h-${w}`, $)}`.trim(), r.attributes = E(r.attributes, (L) => !m(["style", "width", "height", "class"], L.key)), a.icon = y([r]), [a];
|
|
226
|
-
} else if (r.tagName == "option" && e && ((c = e.block) == null ? void 0 : c._type) === "Select")
|
|
227
|
-
return e.block.options.push({
|
|
228
|
-
label: T(r.children),
|
|
229
|
-
..._(r)
|
|
230
|
-
}), [];
|
|
231
|
-
const s = x(r.children, { block: a, node: r });
|
|
232
|
-
return [a, ...s];
|
|
233
|
-
}), j = (t) => {
|
|
234
|
-
const e = t.match(/<body[^>]*>[\s\S]*?<\/body>/);
|
|
235
|
-
return (e && e.length > 0 ? e[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : t).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
|
|
236
|
-
}, K = (t) => {
|
|
237
|
-
const e = k(j(t));
|
|
238
|
-
return g(t) ? [] : R(x(e));
|
|
239
|
-
};
|
|
240
|
-
export {
|
|
241
|
-
K as g,
|
|
242
|
-
X as p
|
|
243
|
-
};
|
package/dist/index--k2M8kzI.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";var H2=(h,t,c)=>{if(!t.has(h))throw TypeError("Cannot "+c)};var n=(h,t,c)=>(H2(h,t,"read from private field"),c?c.call(h):t.get(h)),e=(h,t,c)=>{if(t.has(h))throw TypeError("Cannot add the same private member more than once");t instanceof WeakSet?t.add(h):t.set(h,c)},v=(h,t,c,a)=>(H2(h,t,"write to private field"),a?a.call(h,c):t.set(h,c),c);var i2=(h,t,c,a)=>({set _(l){v(h,t,l,c)},get _(){return n(h,t,a)}}),M=(h,t,c)=>(H2(h,t,"access private method"),c);const d=require("./jsx-runtime-Z_BpKhVy.cjs"),T=require("react"),s0=require("./index-5XyNUAjc.cjs"),r2=require("@radix-ui/react-icons"),q=require("./index-aeDphKpP.cjs"),h1=require("sonner"),p0=require("react-i18next"),c1=require("lodash-es"),V0=require("./html-to-json-NqRjgFqp.cjs"),S2=require("lucide-react"),t0=require("./index--mLLy7QQ.cjs");function f0(h){const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(h){for(const c in h)if(c!=="default"){const a=Object.getOwnPropertyDescriptor(h,c);Object.defineProperty(t,c,a.get?a:{enumerable:!0,get:()=>h[c]})}}return t.default=h,Object.freeze(t)}const A=f0(T);var W1=class{constructor(){this.listeners=new Set,this.subscribe=this.subscribe.bind(this)}subscribe(h){return this.listeners.add(h),this.onSubscribe(),()=>{this.listeners.delete(h),this.onUnsubscribe()}}hasListeners(){return this.listeners.size>0}onSubscribe(){}onUnsubscribe(){}},N1=typeof window>"u"||"Deno"in window;function _(){}function m0(h,t){return typeof h=="function"?h(t):h}function s2(h){return typeof h=="number"&&h>=0&&h!==1/0}function h0(h,t){return Math.max(h+(t||0)-Date.now(),0)}function R2(h,t){const{type:c="all",exact:a,fetchStatus:l,predicate:i,queryKey:r,stale:z}=h;if(r){if(a){if(t.queryHash!==A2(r,t.options))return!1}else if(!Q1(t.queryKey,r))return!1}if(c!=="all"){const s=t.isActive();if(c==="active"&&!s||c==="inactive"&&s)return!1}return!(typeof z=="boolean"&&t.isStale()!==z||typeof l<"u"&&l!==t.state.fetchStatus||i&&!i(t))}function F2(h,t){const{exact:c,status:a,predicate:l,mutationKey:i}=h;if(i){if(!t.options.mutationKey)return!1;if(c){if(U1(t.options.mutationKey)!==U1(i))return!1}else if(!Q1(t.options.mutationKey,i))return!1}return!(a&&t.state.status!==a||l&&!l(t))}function A2(h,t){return((t==null?void 0:t.queryKeyHashFn)||U1)(h)}function U1(h){return JSON.stringify(h,(t,c)=>p2(c)?Object.keys(c).sort().reduce((a,l)=>(a[l]=c[l],a),{}):c)}function Q1(h,t){return h===t?!0:typeof h!=typeof t?!1:h&&t&&typeof h=="object"&&typeof t=="object"?!Object.keys(t).some(c=>!Q1(h[c],t[c])):!1}function c0(h,t){if(h===t)return h;const c=k2(h)&&k2(t);if(c||p2(h)&&p2(t)){const a=c?h.length:Object.keys(h).length,l=c?t:Object.keys(t),i=l.length,r=c?[]:{};let z=0;for(let s=0;s<i;s++){const p=c?s:l[s];r[p]=c0(h[p],t[p]),r[p]===h[p]&&z++}return a===i&&z===a?h:r}return t}function e2(h,t){if(h&&!t||t&&!h)return!1;for(const c in h)if(h[c]!==t[c])return!1;return!0}function k2(h){return Array.isArray(h)&&h.length===Object.keys(h).length}function p2(h){if(!D2(h))return!1;const t=h.constructor;if(typeof t>"u")return!0;const c=t.prototype;return!(!D2(c)||!c.hasOwnProperty("isPrototypeOf"))}function D2(h){return Object.prototype.toString.call(h)==="[object Object]"}function a0(h){return new Promise(t=>{setTimeout(t,h)})}function E2(h){a0(0).then(h)}function V2(h,t,c){return typeof c.structuralSharing=="function"?c.structuralSharing(h,t):c.structuralSharing!==!1?c0(h,t):t}function x0(h,t,c=0){const a=[...h,t];return c&&a.length>c?a.slice(1):a}function L0(h,t,c=0){const a=[t,...h];return c&&a.length>c?a.slice(0,-1):a}var u1,v1,B1,U2,w0=(U2=class extends W1{constructor(){super();e(this,u1,void 0);e(this,v1,void 0);e(this,B1,void 0);v(this,B1,t=>{if(!N1&&window.addEventListener){const c=()=>t();return window.addEventListener("visibilitychange",c,!1),()=>{window.removeEventListener("visibilitychange",c)}}})}onSubscribe(){n(this,v1)||this.setEventListener(n(this,B1))}onUnsubscribe(){var t;this.hasListeners()||((t=n(this,v1))==null||t.call(this),v(this,v1,void 0))}setEventListener(t){var c;v(this,B1,t),(c=n(this,v1))==null||c.call(this),v(this,v1,t(a=>{typeof a=="boolean"?this.setFocused(a):this.onFocus()}))}setFocused(t){n(this,u1)!==t&&(v(this,u1,t),this.onFocus())}onFocus(){this.listeners.forEach(t=>{t()})}isFocused(){var t;return typeof n(this,u1)=="boolean"?n(this,u1):((t=globalThis.document)==null?void 0:t.visibilityState)!=="hidden"}},u1=new WeakMap,v1=new WeakMap,B1=new WeakMap,U2),o2=new w0,I1,d1,G1,Q2,B0=(Q2=class extends W1{constructor(){super();e(this,I1,!0);e(this,d1,void 0);e(this,G1,void 0);v(this,G1,t=>{if(!N1&&window.addEventListener){const c=()=>t(!0),a=()=>t(!1);return window.addEventListener("online",c,!1),window.addEventListener("offline",a,!1),()=>{window.removeEventListener("online",c),window.removeEventListener("offline",a)}}})}onSubscribe(){n(this,d1)||this.setEventListener(n(this,G1))}onUnsubscribe(){var t;this.hasListeners()||((t=n(this,d1))==null||t.call(this),v(this,d1,void 0))}setEventListener(t){var c;v(this,G1,t),(c=n(this,d1))==null||c.call(this),v(this,d1,t(this.setOnline.bind(this)))}setOnline(t){n(this,I1)!==t&&(v(this,I1,t),this.listeners.forEach(a=>{a(t)}))}isOnline(){return n(this,I1)}},I1=new WeakMap,d1=new WeakMap,G1=new WeakMap,Q2),z2=new B0;function I0(h){return Math.min(1e3*2**h,3e4)}function M2(h){return(h??"online")==="online"?z2.isOnline():!0}var n0=class{constructor(h){this.revert=h==null?void 0:h.revert,this.silent=h==null?void 0:h.silent}};function u2(h){return h instanceof n0}function l0(h){let t=!1,c=0,a=!1,l,i,r;const z=new Promise((g,u)=>{i=g,r=u}),s=g=>{var u;a||(H(new n0(g)),(u=h.abort)==null||u.call(h))},p=()=>{t=!0},o=()=>{t=!1},L=()=>!o2.isFocused()||h.networkMode!=="always"&&!z2.isOnline(),b=g=>{var u;a||(a=!0,(u=h.onSuccess)==null||u.call(h,g),l==null||l(),i(g))},H=g=>{var u;a||(a=!0,(u=h.onError)==null||u.call(h,g),l==null||l(),r(g))},V=()=>new Promise(g=>{var u;l=G=>{const f=a||!L();return f&&g(G),f},(u=h.onPause)==null||u.call(h)}).then(()=>{var g;l=void 0,a||(g=h.onContinue)==null||g.call(h)}),B=()=>{if(a)return;let g;try{g=h.fn()}catch(u){g=Promise.reject(u)}Promise.resolve(g).then(b).catch(u=>{var F;if(a)return;const G=h.retry??(N1?0:3),f=h.retryDelay??I0,m=typeof f=="function"?f(c,u):f,y=G===!0||typeof G=="number"&&c<G||typeof G=="function"&&G(c,u);if(t||!y){H(u);return}c++,(F=h.onFail)==null||F.call(h,c,u),a0(m).then(()=>{if(L())return V()}).then(()=>{t?H(u):B()})})};return M2(h.networkMode)?B():V().then(B),{promise:z,cancel:s,continue:()=>(l==null?void 0:l())?z:Promise.resolve(),cancelRetry:p,continueRetry:o}}function G0(){let h=[],t=0,c=o=>{o()},a=o=>{o()};const l=o=>{let L;t++;try{L=o()}finally{t--,t||z()}return L},i=o=>{t?h.push(o):E2(()=>{c(o)})},r=o=>(...L)=>{i(()=>{o(...L)})},z=()=>{const o=h;h=[],o.length&&E2(()=>{a(()=>{o.forEach(L=>{c(L)})})})};return{batch:l,batchCalls:r,schedule:i,setNotifyFunction:o=>{c=o},setBatchNotifyFunction:o=>{a=o}}}var O=G0(),s1,K2,i0=(K2=class{constructor(){e(this,s1,void 0)}destroy(){this.clearGcTimeout()}scheduleGc(){this.clearGcTimeout(),s2(this.gcTime)&&v(this,s1,setTimeout(()=>{this.optionalRemove()},this.gcTime))}updateGcTime(h){this.gcTime=Math.max(this.gcTime||0,h??(N1?1/0:5*60*1e3))}clearGcTimeout(){n(this,s1)&&(clearTimeout(n(this,s1)),v(this,s1,void 0))}},s1=new WeakMap,K2),C1,O1,j,r1,U,S,K1,p1,S1,v2,$,n1,q2,C0=(q2=class extends i0{constructor(t){super();e(this,S1);e(this,$);e(this,C1,void 0);e(this,O1,void 0);e(this,j,void 0);e(this,r1,void 0);e(this,U,void 0);e(this,S,void 0);e(this,K1,void 0);e(this,p1,void 0);v(this,p1,!1),v(this,K1,t.defaultOptions),M(this,S1,v2).call(this,t.options),v(this,S,[]),v(this,j,t.cache),this.queryKey=t.queryKey,this.queryHash=t.queryHash,v(this,C1,t.state||O0(this.options)),this.state=n(this,C1),this.scheduleGc()}get meta(){return this.options.meta}optionalRemove(){!n(this,S).length&&this.state.fetchStatus==="idle"&&n(this,j).remove(this)}setData(t,c){const a=V2(this.state.data,t,this.options);return M(this,$,n1).call(this,{data:a,type:"success",dataUpdatedAt:c==null?void 0:c.updatedAt,manual:c==null?void 0:c.manual}),a}setState(t,c){M(this,$,n1).call(this,{type:"setState",state:t,setStateOptions:c})}cancel(t){var a;const c=n(this,r1);return(a=n(this,U))==null||a.cancel(t),c?c.then(_).catch(_):Promise.resolve()}destroy(){super.destroy(),this.cancel({silent:!0})}reset(){this.destroy(),this.setState(n(this,C1))}isActive(){return n(this,S).some(t=>t.options.enabled!==!1)}isDisabled(){return this.getObserversCount()>0&&!this.isActive()}isStale(){return this.state.isInvalidated||!this.state.dataUpdatedAt||n(this,S).some(t=>t.getCurrentResult().isStale)}isStaleByTime(t=0){return this.state.isInvalidated||!this.state.dataUpdatedAt||!h0(this.state.dataUpdatedAt,t)}onFocus(){var c;const t=n(this,S).find(a=>a.shouldFetchOnWindowFocus());t==null||t.refetch({cancelRefetch:!1}),(c=n(this,U))==null||c.continue()}onOnline(){var c;const t=n(this,S).find(a=>a.shouldFetchOnReconnect());t==null||t.refetch({cancelRefetch:!1}),(c=n(this,U))==null||c.continue()}addObserver(t){n(this,S).includes(t)||(n(this,S).push(t),this.clearGcTimeout(),n(this,j).notify({type:"observerAdded",query:this,observer:t}))}removeObserver(t){n(this,S).includes(t)&&(v(this,S,n(this,S).filter(c=>c!==t)),n(this,S).length||(n(this,U)&&(n(this,p1)?n(this,U).cancel({revert:!0}):n(this,U).cancelRetry()),this.scheduleGc()),n(this,j).notify({type:"observerRemoved",query:this,observer:t}))}getObserversCount(){return n(this,S).length}invalidate(){this.state.isInvalidated||M(this,$,n1).call(this,{type:"invalidate"})}fetch(t,c){var p,o,L,b;if(this.state.fetchStatus!=="idle"){if(this.state.dataUpdatedAt&&(c!=null&&c.cancelRefetch))this.cancel({silent:!0});else if(n(this,r1))return(p=n(this,U))==null||p.continueRetry(),n(this,r1)}if(t&&M(this,S1,v2).call(this,t),!this.options.queryFn){const H=n(this,S).find(V=>V.options.queryFn);H&&M(this,S1,v2).call(this,H.options)}process.env.NODE_ENV!=="production"&&(Array.isArray(this.options.queryKey)||console.error("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']"));const a=new AbortController,l={queryKey:this.queryKey,meta:this.meta},i=H=>{Object.defineProperty(H,"signal",{enumerable:!0,get:()=>(v(this,p1,!0),a.signal)})};i(l);const r=()=>this.options.queryFn?(v(this,p1,!1),this.options.persister?this.options.persister(this.options.queryFn,l,this):this.options.queryFn(l)):Promise.reject(new Error(`Missing queryFn: '${this.options.queryHash}'`)),z={fetchOptions:c,options:this.options,queryKey:this.queryKey,state:this.state,fetchFn:r};i(z),(o=this.options.behavior)==null||o.onFetch(z,this),v(this,O1,this.state),(this.state.fetchStatus==="idle"||this.state.fetchMeta!==((L=z.fetchOptions)==null?void 0:L.meta))&&M(this,$,n1).call(this,{type:"fetch",meta:(b=z.fetchOptions)==null?void 0:b.meta});const s=H=>{var V,B,g,u;u2(H)&&H.silent||M(this,$,n1).call(this,{type:"error",error:H}),u2(H)||((B=(V=n(this,j).config).onError)==null||B.call(V,H,this),(u=(g=n(this,j).config).onSettled)==null||u.call(g,this.state.data,H,this)),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1};return v(this,U,l0({fn:z.fetchFn,abort:a.abort.bind(a),onSuccess:H=>{var V,B,g,u;if(typeof H>"u"){process.env.NODE_ENV!=="production"&&console.error(`Query data cannot be undefined. Please make sure to return a value other than undefined from your query function. Affected query key: ${this.queryHash}`),s(new Error(`${this.queryHash} data is undefined`));return}this.setData(H),(B=(V=n(this,j).config).onSuccess)==null||B.call(V,H,this),(u=(g=n(this,j).config).onSettled)==null||u.call(g,H,this.state.error,this),this.isFetchingOptimistic||this.scheduleGc(),this.isFetchingOptimistic=!1},onError:s,onFail:(H,V)=>{M(this,$,n1).call(this,{type:"failed",failureCount:H,error:V})},onPause:()=>{M(this,$,n1).call(this,{type:"pause"})},onContinue:()=>{M(this,$,n1).call(this,{type:"continue"})},retry:z.options.retry,retryDelay:z.options.retryDelay,networkMode:z.options.networkMode})),v(this,r1,n(this,U).promise),n(this,r1)}},C1=new WeakMap,O1=new WeakMap,j=new WeakMap,r1=new WeakMap,U=new WeakMap,S=new WeakMap,K1=new WeakMap,p1=new WeakMap,S1=new WeakSet,v2=function(t){this.options={...n(this,K1),...t},this.updateGcTime(this.options.gcTime)},$=new WeakSet,n1=function(t){const c=a=>{switch(t.type){case"failed":return{...a,fetchFailureCount:t.failureCount,fetchFailureReason:t.error};case"pause":return{...a,fetchStatus:"paused"};case"continue":return{...a,fetchStatus:"fetching"};case"fetch":return{...a,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:t.meta??null,fetchStatus:M2(this.options.networkMode)?"fetching":"paused",...!a.dataUpdatedAt&&{error:null,status:"pending"}};case"success":return{...a,data:t.data,dataUpdateCount:a.dataUpdateCount+1,dataUpdatedAt:t.dataUpdatedAt??Date.now(),error:null,isInvalidated:!1,status:"success",...!t.manual&&{fetchStatus:"idle",fetchFailureCount:0,fetchFailureReason:null}};case"error":const l=t.error;return u2(l)&&l.revert&&n(this,O1)?{...n(this,O1),fetchStatus:"idle"}:{...a,error:l,errorUpdateCount:a.errorUpdateCount+1,errorUpdatedAt:Date.now(),fetchFailureCount:a.fetchFailureCount+1,fetchFailureReason:l,fetchStatus:"idle",status:"error"};case"invalidate":return{...a,isInvalidated:!0};case"setState":return{...a,...t.state}}};this.state=c(this.state),O.batch(()=>{n(this,S).forEach(a=>{a.onQueryUpdate()}),n(this,j).notify({query:this,type:"updated",action:t})})},q2);function O0(h){const t=typeof h.initialData=="function"?h.initialData():h.initialData,c=typeof t<"u",a=c?typeof h.initialDataUpdatedAt=="function"?h.initialDataUpdatedAt():h.initialDataUpdatedAt:0;return{data:t,dataUpdateCount:0,dataUpdatedAt:c?a??Date.now():0,error:null,errorUpdateCount:0,errorUpdatedAt:0,fetchFailureCount:0,fetchFailureReason:null,fetchMeta:null,isInvalidated:!1,status:c?"success":"pending",fetchStatus:"idle"}}var Z,_2,S0=(_2=class extends W1{constructor(t={}){super();e(this,Z,void 0);this.config=t,v(this,Z,new Map)}build(t,c,a){const l=c.queryKey,i=c.queryHash??A2(l,c);let r=this.get(i);return r||(r=new C0({cache:this,queryKey:l,queryHash:i,options:t.defaultQueryOptions(c),state:a,defaultOptions:t.getQueryDefaults(l)}),this.add(r)),r}add(t){n(this,Z).has(t.queryHash)||(n(this,Z).set(t.queryHash,t),this.notify({type:"added",query:t}))}remove(t){const c=n(this,Z).get(t.queryHash);c&&(t.destroy(),c===t&&n(this,Z).delete(t.queryHash),this.notify({type:"removed",query:t}))}clear(){O.batch(()=>{this.getAll().forEach(t=>{this.remove(t)})})}get(t){return n(this,Z).get(t)}getAll(){return[...n(this,Z).values()]}find(t){const c={exact:!0,...t};return this.getAll().find(a=>R2(c,a))}findAll(t={}){const c=this.getAll();return Object.keys(t).length>0?c.filter(a=>R2(t,a)):c}notify(t){O.batch(()=>{this.listeners.forEach(c=>{c(t)})})}onFocus(){O.batch(()=>{this.getAll().forEach(t=>{t.onFocus()})})}onOnline(){O.batch(()=>{this.getAll().forEach(t=>{t.onOnline()})})}},Z=new WeakMap,_2),Y,q1,E,A1,X,i1,$2,A0=($2=class extends i0{constructor(t){super();e(this,X);e(this,Y,void 0);e(this,q1,void 0);e(this,E,void 0);e(this,A1,void 0);this.mutationId=t.mutationId,v(this,q1,t.defaultOptions),v(this,E,t.mutationCache),v(this,Y,[]),this.state=t.state||v0(),this.setOptions(t.options),this.scheduleGc()}setOptions(t){this.options={...n(this,q1),...t},this.updateGcTime(this.options.gcTime)}get meta(){return this.options.meta}addObserver(t){n(this,Y).includes(t)||(n(this,Y).push(t),this.clearGcTimeout(),n(this,E).notify({type:"observerAdded",mutation:this,observer:t}))}removeObserver(t){v(this,Y,n(this,Y).filter(c=>c!==t)),this.scheduleGc(),n(this,E).notify({type:"observerRemoved",mutation:this,observer:t})}optionalRemove(){n(this,Y).length||(this.state.status==="pending"?this.scheduleGc():n(this,E).remove(this))}continue(){var t;return((t=n(this,A1))==null?void 0:t.continue())??this.execute(this.state.variables)}async execute(t){var l,i,r,z,s,p,o,L,b,H,V,B,g,u,G,f,m,y,F,I;const c=()=>(v(this,A1,l0({fn:()=>this.options.mutationFn?this.options.mutationFn(t):Promise.reject(new Error("No mutationFn found")),onFail:(w,a1)=>{M(this,X,i1).call(this,{type:"failed",failureCount:w,error:a1})},onPause:()=>{M(this,X,i1).call(this,{type:"pause"})},onContinue:()=>{M(this,X,i1).call(this,{type:"continue"})},retry:this.options.retry??0,retryDelay:this.options.retryDelay,networkMode:this.options.networkMode})),n(this,A1).promise),a=this.state.status==="pending";try{if(!a){M(this,X,i1).call(this,{type:"pending",variables:t}),await((i=(l=n(this,E).config).onMutate)==null?void 0:i.call(l,t,this));const a1=await((z=(r=this.options).onMutate)==null?void 0:z.call(r,t));a1!==this.state.context&&M(this,X,i1).call(this,{type:"pending",context:a1,variables:t})}const w=await c();return await((p=(s=n(this,E).config).onSuccess)==null?void 0:p.call(s,w,t,this.state.context,this)),await((L=(o=this.options).onSuccess)==null?void 0:L.call(o,w,t,this.state.context)),await((H=(b=n(this,E).config).onSettled)==null?void 0:H.call(b,w,null,this.state.variables,this.state.context,this)),await((B=(V=this.options).onSettled)==null?void 0:B.call(V,w,null,t,this.state.context)),M(this,X,i1).call(this,{type:"success",data:w}),w}catch(w){try{throw await((u=(g=n(this,E).config).onError)==null?void 0:u.call(g,w,t,this.state.context,this)),await((f=(G=this.options).onError)==null?void 0:f.call(G,w,t,this.state.context)),await((y=(m=n(this,E).config).onSettled)==null?void 0:y.call(m,void 0,w,this.state.variables,this.state.context,this)),await((I=(F=this.options).onSettled)==null?void 0:I.call(F,void 0,w,t,this.state.context)),w}finally{M(this,X,i1).call(this,{type:"error",error:w})}}}},Y=new WeakMap,q1=new WeakMap,E=new WeakMap,A1=new WeakMap,X=new WeakSet,i1=function(t){const c=a=>{switch(t.type){case"failed":return{...a,failureCount:t.failureCount,failureReason:t.error};case"pause":return{...a,isPaused:!0};case"continue":return{...a,isPaused:!1};case"pending":return{...a,context:t.context,data:void 0,failureCount:0,failureReason:null,error:null,isPaused:!M2(this.options.networkMode),status:"pending",variables:t.variables,submittedAt:Date.now()};case"success":return{...a,data:t.data,failureCount:0,failureReason:null,error:null,status:"success",isPaused:!1};case"error":return{...a,data:void 0,error:t.error,failureCount:a.failureCount+1,failureReason:t.error,isPaused:!1,status:"error"}}};this.state=c(this.state),O.batch(()=>{n(this,Y).forEach(a=>{a.onMutationUpdate(t)}),n(this,E).notify({mutation:this,type:"updated",action:t})})},$2);function v0(){return{context:void 0,data:void 0,error:null,failureCount:0,failureReason:null,isPaused:!1,status:"idle",variables:void 0,submittedAt:0}}var Q,_1,V1,J2,y0=(J2=class extends W1{constructor(t={}){super();e(this,Q,void 0);e(this,_1,void 0);e(this,V1,void 0);this.config=t,v(this,Q,[]),v(this,_1,0)}build(t,c,a){const l=new A0({mutationCache:this,mutationId:++i2(this,_1)._,options:t.defaultMutationOptions(c),state:a});return this.add(l),l}add(t){n(this,Q).push(t),this.notify({type:"added",mutation:t})}remove(t){v(this,Q,n(this,Q).filter(c=>c!==t)),this.notify({type:"removed",mutation:t})}clear(){O.batch(()=>{n(this,Q).forEach(t=>{this.remove(t)})})}getAll(){return n(this,Q)}find(t){const c={exact:!0,...t};return n(this,Q).find(a=>F2(c,a))}findAll(t={}){return n(this,Q).filter(c=>F2(t,c))}notify(t){O.batch(()=>{this.listeners.forEach(c=>{c(t)})})}resumePausedMutations(){return v(this,V1,(n(this,V1)??Promise.resolve()).then(()=>{const t=n(this,Q).filter(c=>c.state.isPaused);return O.batch(()=>t.reduce((c,a)=>c.then(()=>a.continue().catch(_)),Promise.resolve()))}).then(()=>{v(this,V1,void 0)})),n(this,V1)}},Q=new WeakMap,_1=new WeakMap,V1=new WeakMap,J2);function b0(h){return{onFetch:(t,c)=>{const a=async()=>{var V,B,g,u,G;const l=t.options,i=(g=(B=(V=t.fetchOptions)==null?void 0:V.meta)==null?void 0:B.fetchMore)==null?void 0:g.direction,r=((u=t.state.data)==null?void 0:u.pages)||[],z=((G=t.state.data)==null?void 0:G.pageParams)||[],s={pages:[],pageParams:[]};let p=!1;const o=f=>{Object.defineProperty(f,"signal",{enumerable:!0,get:()=>(t.signal.aborted?p=!0:t.signal.addEventListener("abort",()=>{p=!0}),t.signal)})},L=t.options.queryFn||(()=>Promise.reject(new Error(`Missing queryFn: '${t.options.queryHash}'`))),b=async(f,m,y)=>{if(p)return Promise.reject();if(m==null&&f.pages.length)return Promise.resolve(f);const F={queryKey:t.queryKey,pageParam:m,direction:y?"backward":"forward",meta:t.options.meta};o(F);const I=await L(F),{maxPages:w}=t.options,a1=y?L0:x0;return{pages:a1(f.pages,I,w),pageParams:a1(f.pageParams,m,w)}};let H;if(i&&r.length){const f=i==="backward",m=f?P0:T2,y={pages:r,pageParams:z},F=m(l,y);H=await b(y,F,f)}else{H=await b(s,z[0]??l.initialPageParam);const f=h??r.length;for(let m=1;m<f;m++){const y=T2(l,H);H=await b(H,y)}}return H};t.options.persister?t.fetchFn=()=>{var l,i;return(i=(l=t.options).persister)==null?void 0:i.call(l,a,{queryKey:t.queryKey,meta:t.options.meta,signal:t.signal},c)}:t.fetchFn=a}}}function T2(h,{pages:t,pageParams:c}){const a=t.length-1;return h.getNextPageParam(t[a],t,c[a],c)}function P0(h,{pages:t,pageParams:c}){var a;return(a=h.getPreviousPageParam)==null?void 0:a.call(h,t[0],t,c[0],c)}var C,e1,o1,y1,b1,z1,P1,R1,Z2,R0=(Z2=class{constructor(h={}){e(this,C,void 0);e(this,e1,void 0);e(this,o1,void 0);e(this,y1,void 0);e(this,b1,void 0);e(this,z1,void 0);e(this,P1,void 0);e(this,R1,void 0);v(this,C,h.queryCache||new S0),v(this,e1,h.mutationCache||new y0),v(this,o1,h.defaultOptions||{}),v(this,y1,new Map),v(this,b1,new Map),v(this,z1,0)}mount(){i2(this,z1)._++,n(this,z1)===1&&(v(this,P1,o2.subscribe(()=>{o2.isFocused()&&(this.resumePausedMutations(),n(this,C).onFocus())})),v(this,R1,z2.subscribe(()=>{z2.isOnline()&&(this.resumePausedMutations(),n(this,C).onOnline())})))}unmount(){var h,t;i2(this,z1)._--,n(this,z1)===0&&((h=n(this,P1))==null||h.call(this),v(this,P1,void 0),(t=n(this,R1))==null||t.call(this),v(this,R1,void 0))}isFetching(h){return n(this,C).findAll({...h,fetchStatus:"fetching"}).length}isMutating(h){return n(this,e1).findAll({...h,status:"pending"}).length}getQueryData(h){var t;return(t=n(this,C).find({queryKey:h}))==null?void 0:t.state.data}ensureQueryData(h){const t=this.getQueryData(h.queryKey);return t!==void 0?Promise.resolve(t):this.fetchQuery(h)}getQueriesData(h){return this.getQueryCache().findAll(h).map(({queryKey:t,state:c})=>{const a=c.data;return[t,a]})}setQueryData(h,t,c){const a=n(this,C).find({queryKey:h}),l=a==null?void 0:a.state.data,i=m0(t,l);if(typeof i>"u")return;const r=this.defaultQueryOptions({queryKey:h});return n(this,C).build(this,r).setData(i,{...c,manual:!0})}setQueriesData(h,t,c){return O.batch(()=>this.getQueryCache().findAll(h).map(({queryKey:a})=>[a,this.setQueryData(a,t,c)]))}getQueryState(h){var t;return(t=n(this,C).find({queryKey:h}))==null?void 0:t.state}removeQueries(h){const t=n(this,C);O.batch(()=>{t.findAll(h).forEach(c=>{t.remove(c)})})}resetQueries(h,t){const c=n(this,C),a={type:"active",...h};return O.batch(()=>(c.findAll(h).forEach(l=>{l.reset()}),this.refetchQueries(a,t)))}cancelQueries(h={},t={}){const c={revert:!0,...t},a=O.batch(()=>n(this,C).findAll(h).map(l=>l.cancel(c)));return Promise.all(a).then(_).catch(_)}invalidateQueries(h={},t={}){return O.batch(()=>{if(n(this,C).findAll(h).forEach(a=>{a.invalidate()}),h.refetchType==="none")return Promise.resolve();const c={...h,type:h.refetchType??h.type??"active"};return this.refetchQueries(c,t)})}refetchQueries(h={},t){const c={...t,cancelRefetch:(t==null?void 0:t.cancelRefetch)??!0},a=O.batch(()=>n(this,C).findAll(h).filter(l=>!l.isDisabled()).map(l=>{let i=l.fetch(void 0,c);return c.throwOnError||(i=i.catch(_)),l.state.fetchStatus==="paused"?Promise.resolve():i}));return Promise.all(a).then(_)}fetchQuery(h){const t=this.defaultQueryOptions(h);typeof t.retry>"u"&&(t.retry=!1);const c=n(this,C).build(this,t);return c.isStaleByTime(t.staleTime)?c.fetch(t):Promise.resolve(c.state.data)}prefetchQuery(h){return this.fetchQuery(h).then(_).catch(_)}fetchInfiniteQuery(h){return h.behavior=b0(h.pages),this.fetchQuery(h)}prefetchInfiniteQuery(h){return this.fetchInfiniteQuery(h).then(_).catch(_)}resumePausedMutations(){return n(this,e1).resumePausedMutations()}getQueryCache(){return n(this,C)}getMutationCache(){return n(this,e1)}getDefaultOptions(){return n(this,o1)}setDefaultOptions(h){v(this,o1,h)}setQueryDefaults(h,t){n(this,y1).set(U1(h),{queryKey:h,defaultOptions:t})}getQueryDefaults(h){const t=[...n(this,y1).values()];let c={};return t.forEach(a=>{Q1(h,a.queryKey)&&(c={...c,...a.defaultOptions})}),c}setMutationDefaults(h,t){n(this,b1).set(U1(h),{mutationKey:h,defaultOptions:t})}getMutationDefaults(h){const t=[...n(this,b1).values()];let c={};return t.forEach(a=>{Q1(h,a.mutationKey)&&(c={...c,...a.defaultOptions})}),c}defaultQueryOptions(h){if(h!=null&&h._defaulted)return h;const t={...n(this,o1).queries,...(h==null?void 0:h.queryKey)&&this.getQueryDefaults(h.queryKey),...h,_defaulted:!0};return t.queryHash||(t.queryHash=A2(t.queryKey,t)),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}defaultMutationOptions(h){return h!=null&&h._defaulted?h:{...n(this,o1).mutations,...(h==null?void 0:h.mutationKey)&&this.getMutationDefaults(h.mutationKey),...h,_defaulted:!0}}clear(){n(this,C).clear(),n(this,e1).clear()}},C=new WeakMap,e1=new WeakMap,o1=new WeakMap,y1=new WeakMap,b1=new WeakMap,z1=new WeakMap,P1=new WeakMap,R1=new WeakMap,Z2),D,x,F1,P,f1,k1,t1,$1,D1,E1,m1,x1,g1,L1,w1,j1,J1,f2,Z1,m2,Y1,x2,X1,L2,t2,w2,h2,B2,c2,I2,g2,d0,Y2,F0=(Y2=class extends W1{constructor(t,c){super();e(this,w1);e(this,J1);e(this,Z1);e(this,Y1);e(this,X1);e(this,t2);e(this,h2);e(this,c2);e(this,g2);e(this,D,void 0);e(this,x,void 0);e(this,F1,void 0);e(this,P,void 0);e(this,f1,void 0);e(this,k1,void 0);e(this,t1,void 0);e(this,$1,void 0);e(this,D1,void 0);e(this,E1,void 0);e(this,m1,void 0);e(this,x1,void 0);e(this,g1,void 0);e(this,L1,void 0);v(this,x,void 0),v(this,F1,void 0),v(this,P,void 0),v(this,L1,new Set),v(this,D,t),this.options=c,v(this,t1,null),this.bindMethods(),this.setOptions(c)}bindMethods(){this.refetch=this.refetch.bind(this)}onSubscribe(){this.listeners.size===1&&(n(this,x).addObserver(this),N2(n(this,x),this.options)?M(this,w1,j1).call(this):this.updateResult(),M(this,X1,L2).call(this))}onUnsubscribe(){this.hasListeners()||this.destroy()}shouldFetchOnReconnect(){return G2(n(this,x),this.options,this.options.refetchOnReconnect)}shouldFetchOnWindowFocus(){return G2(n(this,x),this.options,this.options.refetchOnWindowFocus)}destroy(){this.listeners=new Set,M(this,t2,w2).call(this),M(this,h2,B2).call(this),n(this,x).removeObserver(this)}setOptions(t,c){const a=this.options,l=n(this,x);if(this.options=n(this,D).defaultQueryOptions(t),e2(a,this.options)||n(this,D).getQueryCache().notify({type:"observerOptionsUpdated",query:n(this,x),observer:this}),typeof this.options.enabled<"u"&&typeof this.options.enabled!="boolean")throw new Error("Expected enabled to be a boolean");this.options.queryKey||(this.options.queryKey=a.queryKey),M(this,c2,I2).call(this);const i=this.hasListeners();i&&W2(n(this,x),l,this.options,a)&&M(this,w1,j1).call(this),this.updateResult(c),i&&(n(this,x)!==l||this.options.enabled!==a.enabled||this.options.staleTime!==a.staleTime)&&M(this,J1,f2).call(this);const r=M(this,Z1,m2).call(this);i&&(n(this,x)!==l||this.options.enabled!==a.enabled||r!==n(this,g1))&&M(this,Y1,x2).call(this,r)}getOptimisticResult(t){const c=n(this,D).getQueryCache().build(n(this,D),t),a=this.createResult(c,t);return D0(this,a)&&(v(this,P,a),v(this,k1,this.options),v(this,f1,n(this,x).state)),a}getCurrentResult(){return n(this,P)}trackResult(t){const c={};return Object.keys(t).forEach(a=>{Object.defineProperty(c,a,{configurable:!1,enumerable:!0,get:()=>(n(this,L1).add(a),t[a])})}),c}getCurrentQuery(){return n(this,x)}refetch({...t}={}){return this.fetch({...t})}fetchOptimistic(t){const c=n(this,D).defaultQueryOptions(t),a=n(this,D).getQueryCache().build(n(this,D),c);return a.isFetchingOptimistic=!0,a.fetch().then(()=>this.createResult(a,c))}fetch(t){return M(this,w1,j1).call(this,{...t,cancelRefetch:t.cancelRefetch??!0}).then(()=>(this.updateResult(),n(this,P)))}createResult(t,c){var F;const a=n(this,x),l=this.options,i=n(this,P),r=n(this,f1),z=n(this,k1),p=t!==a?t.state:n(this,F1),{state:o}=t;let{error:L,errorUpdatedAt:b,fetchStatus:H,status:V}=o,B=!1,g;if(c._optimisticResults){const I=this.hasListeners(),w=!I&&N2(t,c),a1=I&&W2(t,a,c,l);(w||a1)&&(H=M2(t.options.networkMode)?"fetching":"paused",o.dataUpdatedAt||(V="pending")),c._optimisticResults==="isRestoring"&&(H="idle")}if(c.select&&typeof o.data<"u")if(i&&o.data===(r==null?void 0:r.data)&&c.select===n(this,$1))g=n(this,D1);else try{v(this,$1,c.select),g=c.select(o.data),g=V2(i==null?void 0:i.data,g,c),v(this,D1,g),v(this,t1,null)}catch(I){v(this,t1,I)}else g=o.data;if(typeof c.placeholderData<"u"&&typeof g>"u"&&V==="pending"){let I;if(i!=null&&i.isPlaceholderData&&c.placeholderData===(z==null?void 0:z.placeholderData))I=i.data;else if(I=typeof c.placeholderData=="function"?c.placeholderData((F=n(this,E1))==null?void 0:F.state.data,n(this,E1)):c.placeholderData,c.select&&typeof I<"u")try{I=c.select(I),v(this,t1,null)}catch(w){v(this,t1,w)}typeof I<"u"&&(V="success",g=V2(i==null?void 0:i.data,I,c),B=!0)}n(this,t1)&&(L=n(this,t1),g=n(this,D1),b=Date.now(),V="error");const u=H==="fetching",G=V==="pending",f=V==="error",m=G&&u;return{status:V,fetchStatus:H,isPending:G,isSuccess:V==="success",isError:f,isInitialLoading:m,isLoading:m,data:g,dataUpdatedAt:o.dataUpdatedAt,error:L,errorUpdatedAt:b,failureCount:o.fetchFailureCount,failureReason:o.fetchFailureReason,errorUpdateCount:o.errorUpdateCount,isFetched:o.dataUpdateCount>0||o.errorUpdateCount>0,isFetchedAfterMount:o.dataUpdateCount>p.dataUpdateCount||o.errorUpdateCount>p.errorUpdateCount,isFetching:u,isRefetching:u&&!G,isLoadingError:f&&o.dataUpdatedAt===0,isPaused:H==="paused",isPlaceholderData:B,isRefetchError:f&&o.dataUpdatedAt!==0,isStale:y2(t,c),refetch:this.refetch}}updateResult(t){const c=n(this,P),a=this.createResult(n(this,x),this.options);if(v(this,f1,n(this,x).state),v(this,k1,this.options),n(this,f1).data!==void 0&&v(this,E1,n(this,x)),e2(a,c))return;v(this,P,a);const l={},i=()=>{if(!c)return!0;const{notifyOnChangeProps:r}=this.options,z=typeof r=="function"?r():r;if(z==="all"||!z&&!n(this,L1).size)return!0;const s=new Set(z??n(this,L1));return this.options.throwOnError&&s.add("error"),Object.keys(n(this,P)).some(p=>{const o=p;return n(this,P)[o]!==c[o]&&s.has(o)})};(t==null?void 0:t.listeners)!==!1&&i()&&(l.listeners=!0),M(this,g2,d0).call(this,{...l,...t})}onQueryUpdate(){this.updateResult(),this.hasListeners()&&M(this,X1,L2).call(this)}},D=new WeakMap,x=new WeakMap,F1=new WeakMap,P=new WeakMap,f1=new WeakMap,k1=new WeakMap,t1=new WeakMap,$1=new WeakMap,D1=new WeakMap,E1=new WeakMap,m1=new WeakMap,x1=new WeakMap,g1=new WeakMap,L1=new WeakMap,w1=new WeakSet,j1=function(t){M(this,c2,I2).call(this);let c=n(this,x).fetch(this.options,t);return t!=null&&t.throwOnError||(c=c.catch(_)),c},J1=new WeakSet,f2=function(){if(M(this,t2,w2).call(this),N1||n(this,P).isStale||!s2(this.options.staleTime))return;const c=h0(n(this,P).dataUpdatedAt,this.options.staleTime)+1;v(this,m1,setTimeout(()=>{n(this,P).isStale||this.updateResult()},c))},Z1=new WeakSet,m2=function(){return(typeof this.options.refetchInterval=="function"?this.options.refetchInterval(n(this,x)):this.options.refetchInterval)??!1},Y1=new WeakSet,x2=function(t){M(this,h2,B2).call(this),v(this,g1,t),!(N1||this.options.enabled===!1||!s2(n(this,g1))||n(this,g1)===0)&&v(this,x1,setInterval(()=>{(this.options.refetchIntervalInBackground||o2.isFocused())&&M(this,w1,j1).call(this)},n(this,g1)))},X1=new WeakSet,L2=function(){M(this,J1,f2).call(this),M(this,Y1,x2).call(this,M(this,Z1,m2).call(this))},t2=new WeakSet,w2=function(){n(this,m1)&&(clearTimeout(n(this,m1)),v(this,m1,void 0))},h2=new WeakSet,B2=function(){n(this,x1)&&(clearInterval(n(this,x1)),v(this,x1,void 0))},c2=new WeakSet,I2=function(){const t=n(this,D).getQueryCache().build(n(this,D),this.options);if(t===n(this,x))return;const c=n(this,x);v(this,x,t),v(this,F1,t.state),this.hasListeners()&&(c==null||c.removeObserver(this),t.addObserver(this))},g2=new WeakSet,d0=function(t){O.batch(()=>{t.listeners&&this.listeners.forEach(c=>{c(n(this,P))}),n(this,D).getQueryCache().notify({query:n(this,x),type:"observerResultsUpdated"})})},Y2);function k0(h,t){return t.enabled!==!1&&!h.state.dataUpdatedAt&&!(h.state.status==="error"&&t.retryOnMount===!1)}function N2(h,t){return k0(h,t)||h.state.dataUpdatedAt>0&&G2(h,t,t.refetchOnMount)}function G2(h,t,c){if(t.enabled!==!1){const a=typeof c=="function"?c(h):c;return a==="always"||a!==!1&&y2(h,t)}return!1}function W2(h,t,c,a){return c.enabled!==!1&&(h!==t||a.enabled===!1)&&(!c.suspense||h.state.status!=="error")&&y2(h,c)}function y2(h,t){return h.isStaleByTime(t.staleTime)}function D0(h,t){return!e2(h.getCurrentResult(),t)}var M1,k,K,l1,T1,d2,a2,C2,X2,E0=(X2=class extends W1{constructor(t,c){super();e(this,T1);e(this,a2);e(this,M1,void 0);e(this,k,void 0);e(this,K,void 0);e(this,l1,void 0);v(this,k,void 0),v(this,M1,t),this.setOptions(c),this.bindMethods(),M(this,T1,d2).call(this)}bindMethods(){this.mutate=this.mutate.bind(this),this.reset=this.reset.bind(this)}setOptions(t){var a;const c=this.options;this.options=n(this,M1).defaultMutationOptions(t),e2(c,this.options)||n(this,M1).getMutationCache().notify({type:"observerOptionsUpdated",mutation:n(this,K),observer:this}),(a=n(this,K))==null||a.setOptions(this.options)}onUnsubscribe(){var t;this.hasListeners()||(t=n(this,K))==null||t.removeObserver(this)}onMutationUpdate(t){M(this,T1,d2).call(this),M(this,a2,C2).call(this,t)}getCurrentResult(){return n(this,k)}reset(){v(this,K,void 0),M(this,T1,d2).call(this),M(this,a2,C2).call(this)}mutate(t,c){var a;return v(this,l1,c),(a=n(this,K))==null||a.removeObserver(this),v(this,K,n(this,M1).getMutationCache().build(n(this,M1),this.options)),n(this,K).addObserver(this),n(this,K).execute(t)}},M1=new WeakMap,k=new WeakMap,K=new WeakMap,l1=new WeakMap,T1=new WeakSet,d2=function(){var c;const t=((c=n(this,K))==null?void 0:c.state)??v0();v(this,k,{...t,isPending:t.status==="pending",isSuccess:t.status==="success",isError:t.status==="error",isIdle:t.status==="idle",mutate:this.mutate,reset:this.reset})},a2=new WeakSet,C2=function(t){O.batch(()=>{var c,a,l,i,r,z,s,p;n(this,l1)&&this.hasListeners()&&((t==null?void 0:t.type)==="success"?((a=(c=n(this,l1)).onSuccess)==null||a.call(c,t.data,n(this,k).variables,n(this,k).context),(i=(l=n(this,l1)).onSettled)==null||i.call(l,t.data,null,n(this,k).variables,n(this,k).context)):(t==null?void 0:t.type)==="error"&&((z=(r=n(this,l1)).onError)==null||z.call(r,t.error,n(this,k).variables,n(this,k).context),(p=(s=n(this,l1)).onSettled)==null||p.call(s,void 0,t.error,n(this,k).variables,n(this,k).context))),this.listeners.forEach(o=>{o(n(this,k))})})},X2);var r0=A.createContext(void 0),N=h=>{const t=A.useContext(r0);if(h)return h;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t},T0=({client:h,children:t})=>(A.useEffect(()=>(h.mount(),()=>{h.unmount()}),[h]),A.createElement(r0.Provider,{value:h},t)),e0=A.createContext(!1),N0=()=>A.useContext(e0),C4=e0.Provider;function W0(){let h=!1;return{clearReset:()=>{h=!1},reset:()=>{h=!0},isReset:()=>h}}var j0=A.createContext(W0()),U0=()=>A.useContext(j0);function o0(h,t){return typeof h=="function"?h(...t):!!h}var Q0=(h,t)=>{(h.suspense||h.throwOnError)&&(t.isReset()||(h.retryOnMount=!1))},K0=h=>{A.useEffect(()=>{h.clearReset()},[h])},q0=({result:h,errorResetBoundary:t,throwOnError:c,query:a})=>h.isError&&!t.isReset()&&!h.isFetching&&o0(c,[h.error,a]);var _0=h=>{h.suspense&&typeof h.staleTime!="number"&&(h.staleTime=1e3)};var $0=(h,t)=>(h==null?void 0:h.suspense)&&t.isPending,J0=(h,t,c)=>t.fetchOptimistic(h).catch(()=>{c.clearReset()});function Z0(h,t,c){if(process.env.NODE_ENV!=="production"&&(typeof h!="object"||Array.isArray(h)))throw new Error('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');const a=N(c),l=N0(),i=U0(),r=a.defaultQueryOptions(h);r._optimisticResults=l?"isRestoring":"optimistic",_0(r),Q0(r,i),K0(i);const[z]=A.useState(()=>new t(a,r)),s=z.getOptimisticResult(r);if(A.useSyncExternalStore(A.useCallback(p=>{const o=l?()=>{}:z.subscribe(O.batchCalls(p));return z.updateResult(),o},[z,l]),()=>z.getCurrentResult(),()=>z.getCurrentResult()),A.useEffect(()=>{z.setOptions(r,{listeners:!1})},[r,z]),$0(r,s))throw J0(r,z,i);if(q0({result:s,errorResetBoundary:i,throwOnError:r.throwOnError,query:z.getCurrentQuery()}))throw s.error;return r.notifyOnChangeProps?s:z.trackResult(s)}function n2(h,t){return Z0(h,F0,t)}function J(h,t){const c=N(t),[a]=A.useState(()=>new E0(c,h));A.useEffect(()=>{a.setOptions(h)},[a,h]);const l=A.useSyncExternalStore(A.useCallback(r=>a.subscribe(O.batchCalls(r)),[a]),()=>a.getCurrentResult(),()=>a.getCurrentResult()),i=A.useCallback((r,z)=>{a.mutate(r,z).catch(Y0)},[a]);if(l.error&&o0(a.options.throwOnError,[l.error]))throw l.error;return{...l,mutate:i,mutateAsync:l.mutate}}function Y0(){}function R(){return N().getQueryData(["apiBaseUrl"])||"/api/chaibuilder"}const H1=()=>{const{data:h,refetch:t}=n2({queryKey:["currentPage"],queryFn:()=>localStorage.getItem("currentPage")||""});return[h,c=>{c&&(localStorage.setItem("currentPage",c||""),t())}]};let j2="";const l2=()=>(j2=localStorage.getItem("__chai_at"),j2);function X0(h){const t={method:"GET",headers:{"x-chai-access-token":l2()}};return fetch(h,t)}function t4(h,t){const c={method:"POST",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}function h4(h,t){const c={method:"PUT",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}function c4(h,t){const c={method:"DELETE",headers:{"x-chai-access-token":l2()},body:JSON.stringify(t)};return fetch(h,c)}const W={get:X0,post:t4,put:h4,delete:c4},b2=()=>{const[h,t]=H1(),c=R();return n2({queryKey:["project"],queryFn:async()=>{const{data:a}=await W.get(`${c}/project`).then(l=>l.json());if(!h&&a){const l=localStorage.getItem("currentPage");t(l||(a==null?void 0:a.homepage))}return a}})},P2=()=>{const h=R();return n2({queryKey:["pages"],queryFn:async()=>{const{data:t}=await W.get(`${h}/pages`).then(c=>c.json());return t||[]}})},z0=()=>{const[h]=H1(),t=R();return n2({queryKey:["page_data",h],queryFn:async()=>{const{data:c}=await W.get(`${t}/page?uuid=${h}`).then(a=>a.json());return c},enabled:!!h,staleTime:3e3})},O2=()=>d.jsxRuntimeExports.jsx("div",{className:"h-screen w-screen bg-gray-200",children:d.jsxRuntimeExports.jsxs("div",{className:"flex flex-col h-full w-full justify-center items-center",children:[d.jsxRuntimeExports.jsxs("div",{className:"flex flex-row gap-2",children:[d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-orange-600 animate-bounce [animation-delay:.6s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-blue-600 animate-bounce [animation-delay:.4s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-green-600 animate-bounce [animation-delay:.2s]"}),d.jsxRuntimeExports.jsx("div",{className:"w-4 h-4 rounded-full bg-yellow-600 animate-bounce [animation-delay:.0s]"})]}),d.jsxRuntimeExports.jsx("div",{className:"text-gray-700 font-thin",children:"Loading Builder..."})]})}),g0=(h="Project updated successfully.")=>{const t=N(),c=R();return J({mutationFn:async a=>await W.put(`${c}/project`,a).then(l=>l.json()),onSuccess:()=>{t.invalidateQueries({queryKey:["project"]}),h1.toast.success(h)}})},M0=()=>{const[h]=["SAVED"],[t,c]=H1(),a=q.useBuilderReset(),{t:l}=p0.useTranslation();return i=>h!=="SAVED"?(h1.toast.error(l("You have unsaved changes. Please save before changing the page.")),!1):t===i.uuid?!1:(a(),setTimeout(()=>c(i.uuid),100),!0)},a4=()=>{const h=N(),t=M0(),c=R();return J({mutationFn:async a=>W.post(`${c}/pages`,a).then(l=>l.json()),onSuccess:a=>{h.invalidateQueries({queryKey:["pages"]}),t({uuid:a.uuid,slug:a.slug}),h1.toast.success("Page added successfully.")}})},H0=()=>{const h=R(),[t]=H1(),c=N();return J({mutationFn:async a=>W.put(`${h}/page`,a).then(l=>l.json()),onSuccess:async a=>{var l;if(a.result==="error"&&((l=a.error)==null?void 0:l.code)=="PAGE_LOCKED"){c.invalidateQueries({queryKey:["page_data",t]});return}h1.toast.success("Page saved successfully.")}})},n4=()=>{const h=R(),{data:t}=P2(),[c]=H1(),{data:a}=b2(),l=N();return J({mutationFn:async()=>{const i=t.find(r=>r.uuid===c).slug;return await W.post(`${h}/publish`,{slug:i,uuid:c,isHomepage:(a==null?void 0:a.homepage)===c}).then(r=>r.json())},onSuccess:async i=>{var r;if(i.result==="error"&&((r=i.error)==null?void 0:r.code)=="PAGE_LOCKED"){l.invalidateQueries({queryKey:["page_data",c]});return}h1.toast.success("Page published successfully.",{position:"bottom-right",duration:2e3})}})},l4=()=>{const h=N(),t=R();return J({mutationFn:async c=>W.delete(`${t}/page`,c).then(a=>a.json()),onSuccess:()=>{h1.toast.success("Page deleted successfully."),h.invalidateQueries({queryKey:["pages"]})}})},i4=()=>{const h=N(),t=R();return J({mutationFn:async c=>W.post(`${t}/take-control`,{uuid:c}).then(a=>a.json()),onSuccess:(c,a)=>{h.invalidateQueries({queryKey:["page_data",a]})}})},v4=()=>{const h=R();return J({mutationFn:async()=>{const{data:t}=await W.get(`${h}/library`).then(c=>c.json());return c1.sortBy(c1.filter(t,c=>!c1.has(c,"hidden")),"group")}})},d4=()=>{const h=R();return J({mutationFn:async t=>{if(!t||!t.uuid)return[];try{const{data:c}=await W.get(`${h}/block?uuid=${t.uuid}&format=${t.format}`).then(async a=>t.format==="html"?V0.getBlocksFromHTML(await a.text()):await a.json());return c1.set(c,"0._name",c1.capitalize(t.group)),c||[]}catch{return[]}}})},r4=()=>{const h=R();return J({mutationFn:async t=>{const c=new FormData;c.append("file",t);const{data:a}=await fetch(`${h}/upload`,{method:"POST",headers:{"x-chai-access-token":l2()},body:c}).then(l=>l.json());return a}})};function u0(h){return t0.GenIcon({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)}function e4(h){return t0.GenIcon({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)}const o4=()=>{const{mutate:h,isPending:t}=i4(),[c]=H1(),{data:a}=z0(),l=c1.get(a,"lockedBy.name",""),i=c1.get(a,"lockedBy.email","");return d.jsxRuntimeExports.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:[d.jsxRuntimeExports.jsxs("h2",{className:"text-2xl font-bold",children:["Page is ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"locked"})]}),d.jsxRuntimeExports.jsxs("div",{className:"text-gray-500 dark:text-gray-400 font-light",children:["This page is currently being edited by ",d.jsxRuntimeExports.jsx("br",{}),d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-3 w-max mx-auto font-medium text-gray-700 mt-2 text-sm",children:[d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md",children:[d.jsxRuntimeExports.jsx(e4,{className:"w-4 h-4 text-gray-500"})," ",l]}),d.jsxRuntimeExports.jsxs("div",{className:"flex items-center gap-x-2 bg-gray-100 py-1 px-2 rounded-md lowercase",children:[d.jsxRuntimeExports.jsx(u0,{className:"w-4 h-4 text-gray-500"})," ",i]})]}),d.jsxRuntimeExports.jsxs("div",{className:"pt-4",children:["If you take control, ",l," will be ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"restricted"})," from making additional edits."]})]}),d.jsxRuntimeExports.jsx(q.Button,{disabled:t,onClick:()=>h(c),className:`w-36 ${t?"bg-transparent shadow-none hover:bg-transparent":""}`,children:t?d.jsxRuntimeExports.jsx(S2.Loader,{className:"text-sm animate-spin text-gray-500"}):"Take Over"})]})},z4=()=>{const h=R(),t=N();return J({mutationFn:async c=>{const a=await fetch(`${h}/login`,{method:"POST",body:JSON.stringify(c)});if(a.ok)return await a.json();throw a.status===401?new Error("Invalid login credentials"):new Error("Invalid")},onSuccess:c=>{const{data:a}=c;if(!a.accessToken){h1.toast.error("Something went wrong. Please try again.",{position:"top-center"});return}localStorage.setItem("__chai_at",a.accessToken),localStorage.setItem("__chai_ur",JSON.stringify(c1.omit(a,["accessToken"]))),t.invalidateQueries({queryKey:["verify"]}),h1.toast.success("Logged in successfully.")},onError:()=>{h1.toast.error("Invalid login credentials. Please try again.",{position:"top-center"})}})},g4=()=>{const h=R();return n2({queryKey:["verify"],queryFn:async()=>{const t=await W.get(`${h}/verify`);return t.ok?(await t.json()).result==="success"?{valid:!0}:(localStorage.removeItem("__chai_at"),{valid:!1}):(localStorage.removeItem("__chai_at"),{valid:!0})}})},M4=()=>{const h=R(),t=N();return J({mutationFn:async()=>{const{result:c}=await W.post(`${h}/logout`).then(a=>a.json());if(c==="success")return localStorage.clear(),t.invalidateQueries({queryKey:["verify"]}),{logout:!0};throw new Error("Invalid session")}})},H4=({children:h})=>{const t=M4();return d.jsxRuntimeExports.jsxs(q.AlertDialog,{children:[d.jsxRuntimeExports.jsx(q.AlertDialogTrigger,{asChild:!0,children:h}),d.jsxRuntimeExports.jsxs(q.AlertDialogContent,{children:[d.jsxRuntimeExports.jsxs(q.AlertDialogHeader,{children:[d.jsxRuntimeExports.jsxs(q.AlertDialogTitle,{children:["Are you sure, you want to ",d.jsxRuntimeExports.jsx("span",{className:"text-red-500",children:"Sign Out"}),"?"]}),d.jsxRuntimeExports.jsx(q.AlertDialogDescription,{children:"Kindly ensure that all your data is saved before proceeding with the sign-out process to prevent any potential loss of unsaved information"})]}),d.jsxRuntimeExports.jsxs(q.AlertDialogFooter,{children:[d.jsxRuntimeExports.jsx(q.AlertDialogCancel,{disabled:t.isPending,children:"Cancel"}),d.jsxRuntimeExports.jsxs("button",{disabled:t.isPending,onClick:()=>t.mutate(),className:"rounded-md text-white w-28 text-center justify-center bg-red-600 hover:bg-red-700 flex items-center gap-x-2",children:[t.isPending&&d.jsxRuntimeExports.jsx(S2.Loader2,{className:"animate-spin w-5 h-5"}),"Sign Out"]})]})]})]})},u4=()=>d.jsxRuntimeExports.jsx(H4,{children:d.jsxRuntimeExports.jsx("button",{className:"border-gray-200 rounded-md p-2 mb-2 border",children:d.jsxRuntimeExports.jsx(S2.LogOutIcon,{className:"w-4 h-4 text-red-500 cursor-pointer hover:text-red-300 duration-300"})})}),s4=T.lazy(()=>Promise.resolve().then(()=>require("./PagesPanel-wqDb4D-x.cjs"))),p4=T.lazy(()=>Promise.resolve().then(()=>require("./ProjectPanel-fWESzHr6.cjs"))),V4=T.lazy(()=>Promise.resolve().then(()=>require("./CurrentPage-p_AM4lrF.cjs"))),f4=()=>d.jsxRuntimeExports.jsx("h2",{children:"Your Logo"}),m4=()=>{const{mutate:h}=n4();return q.useBuilderProp("editable",!0)?d.jsxRuntimeExports.jsx(q.Button,{onClick:h,className:"bg-blue-600 text-white",children:"Publish"}):null},x4=h=>{var f;const{data:t,isLoading:c}=b2(),{data:a,isLoading:l}=P2(),{data:i}=z0(),{mutate:r}=g0(),{mutate:z}=H0(),[s]=H1(),p=r4(),o=v4(),L=d4(),b=R(),H=T.useCallback(async m=>await p.mutateAsync(m),[p]),V=T.useCallback(async()=>await o.mutateAsync(),[o]),B=T.useCallback(async m=>await L.mutateAsync(m),[L]),g=async(m=20,y=0)=>{const F=`limit=${m}&offset=${y}`,I=await fetch(`${b}/assets?${F}`).then(w=>w.json());return I.result==="success"?I.data:[]},{logo:u=f4}=h;if(c||!t)return d.jsxRuntimeExports.jsx(O2,{});if(l||!a)return d.jsxRuntimeExports.jsx(O2,{});const G={...h,editable:i!=null&&i.lockedBy?i==null?void 0:i.lockedBy.self:!0,nonEditableComponent:o4,blocks:(i==null?void 0:i.blocks)||[],brandingOptions:t.brandingOptions,darkMode:h.darkMode||!1,dataProviders:(i==null?void 0:i.providers)||[],onSavePage:async({blocks:m,providers:y})=>(await z({blocks:m,providers:y,uuid:s}),!0),onSaveBrandingOptions:async m=>(await r({brandingOptions:m}),!0),topBarComponents:{left:[u],center:[V4],right:[m4]},sideBarComponents:{top:[{icon:r2.FileTextIcon,name:"pages",panel:s4},{icon:r2.GearIcon,name:"settings",panel:p4},...((f=h.sideBarComponents)==null?void 0:f.top)||[]],bottom:[u4]},uploadMediaCallback:H,fetchMediaCallback:g,getUILibraryBlocks:V,getExternalPredefinedBlock:B,getPages:()=>a};return d.jsxRuntimeExports.jsx(s0.ChaiBuilderEditor,{...G})},L4=({logo:h})=>{const[t,c]=T.useState(!1),[a,l]=T.useState(""),[i,r]=T.useState(""),{mutate:z,isPending:s}=z4(),p=o=>{o.preventDefault(),z({email:a,password:i})};return d.jsxRuntimeExports.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:d.jsxRuntimeExports.jsx("div",{className:"overflow-hidden bg-white rounded-xl w-96 drop-shadow-2xl duration-300",children:d.jsxRuntimeExports.jsxs("div",{className:"p-12",children:[d.jsxRuntimeExports.jsxs("div",{className:"max-w-2xl mx-auto text-center",children:[d.jsxRuntimeExports.jsx(T.Suspense,{children:h?T.createElement(h):""}),d.jsxRuntimeExports.jsx("p",{className:"max-w-xl mx-auto text-base leading-relaxed text-gray-700 font-thin",children:"Enter your login credential to continue"})]}),d.jsxRuntimeExports.jsx("div",{className:"mt-8",children:d.jsxRuntimeExports.jsxs("form",{method:"POST",onSubmit:p,className:"space-y-5",children:[d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[d.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:d.jsxRuntimeExports.jsx(u0,{})}),d.jsxRuntimeExports.jsx("input",{value:a,onChange:o=>l(o.target.value),type:"email",id:"email",placeholder:"Enter email",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"})]})}),d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsxs("div",{className:"mt-2.5 relative text-gray-400 focus-within:text-gray-600",children:[d.jsxRuntimeExports.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:d.jsxRuntimeExports.jsx("svg",{className:"w-5 h-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:d.jsxRuntimeExports.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",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"})})}),d.jsxRuntimeExports.jsx("input",{value:i,onChange:o=>r(o.target.value),type:t?"text":"password",id:"pwd",placeholder:"Enter password",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"}),d.jsxRuntimeExports.jsx("button",{type:"button",className:"absolute inset-y-0 right-4 flex items-center pl-3 cursor-pointer",onClick:()=>c(!t),children:t?d.jsxRuntimeExports.jsx(r2.EyeClosedIcon,{}):d.jsxRuntimeExports.jsx(r2.EyeOpenIcon,{})})]})}),d.jsxRuntimeExports.jsx("div",{children:d.jsxRuntimeExports.jsx("button",{disabled:s||c1.size(a)<2||c1.size(i)<2,type:"submit",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",children:s?"Signing in...":"Login"})})]})}),d.jsxRuntimeExports.jsx("div",{className:"mt-4 flex items-center justify-end gap-x-2 text-sm",children:d.jsxRuntimeExports.jsx("a",{href:"https://apps.chaibuilder.com/settings",target:"_blank",className:"text-gray-500 hover:text-blue-400",children:"Forget your password?"})})]})})})},w4=h=>{const{data:t,isLoading:c}=g4(),a=N();return T.useEffect(()=>{a.setQueryData(["apiBaseUrl"],h.apiBaseUrl||"/api/chaibuilder")},[h.apiBaseUrl,a]),c?d.jsxRuntimeExports.jsx(O2,{}):t!=null&&t.valid?d.jsxRuntimeExports.jsx(x4,{...h}):d.jsxRuntimeExports.jsx(L4,{logo:h.logo})},B4=new R0,I4=h=>d.jsxRuntimeExports.jsxs(T0,{client:B4,children:[d.jsxRuntimeExports.jsx(h1.Toaster,{richColors:!0}),d.jsxRuntimeExports.jsx(w4,{...h})]});exports.ChaiBuilderStudio=I4;exports.useAddPage=a4;exports.useChangePage=M0;exports.useCurrentPage=H1;exports.useDeletePage=l4;exports.usePages=P2;exports.useProject=b2;exports.useQueryClient=N;exports.useUpdatePage=H0;exports.useUpdateProject=g0;
|
package/dist/index--mLLy7QQ.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";const s=require("react");var u={color:void 0,size:void 0,className:void 0,style:void 0,attr:void 0},p=s.createContext&&s.createContext(u),d=["attr","size","title"];function I(e,t){if(e==null)return{};var i=f(e,t),n,o;if(Object.getOwnPropertySymbols){var c=Object.getOwnPropertySymbols(e);for(o=0;o<c.length;o++)n=c[o],!(t.indexOf(n)>=0)&&Object.prototype.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function f(e,t){if(e==null)return{};var i={};for(var n in e)if(Object.prototype.hasOwnProperty.call(e,n)){if(t.indexOf(n)>=0)continue;i[n]=e[n]}return i}function l(){return l=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var i=arguments[t];for(var n in i)Object.prototype.hasOwnProperty.call(i,n)&&(e[n]=i[n])}return e},l.apply(this,arguments)}function h(e,t){var i=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(o){return Object.getOwnPropertyDescriptor(e,o).enumerable})),i.push.apply(i,n)}return i}function a(e){for(var t=1;t<arguments.length;t++){var i=arguments[t]!=null?arguments[t]:{};t%2?h(Object(i),!0).forEach(function(n){U(e,n,i[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(i)):h(Object(i)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(i,n))})}return e}function U(e,t,i){return t=j(t),t in e?Object.defineProperty(e,t,{value:i,enumerable:!0,configurable:!0,writable:!0}):e[t]=i,e}function j(e){var t=v(e,"string");return typeof t=="symbol"?t:t+""}function v(e,t){if(typeof e!="object"||!e)return e;var i=e[Symbol.toPrimitive];if(i!==void 0){var n=i.call(e,t||"default");if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function b(e){return e&&e.map((t,i)=>s.createElement(t.tag,a({key:i},t.attr),b(t.child)))}function y(e){return t=>s.createElement(w,l({attr:a({},e.attr)},t),b(e.child))}function w(e){var t=i=>{var{attr:n,size:o,title:c}=e,g=I(e,d),m=o||i.size||"1em",r;return i.className&&(r=i.className),e.className&&(r=(r?r+" ":"")+e.className),s.createElement("svg",l({stroke:"currentColor",fill:"currentColor",strokeWidth:"0"},i.attr,n,g,{className:r,style:a(a({color:e.color||i.color},i.style),e.style),height:m,width:m,xmlns:"http://www.w3.org/2000/svg"}),c&&s.createElement("title",null,c),e.children)};return p!==void 0?s.createElement(p.Consumer,null,i=>t(i)):t(u)}exports.GenIcon=y;
|