@chaibuilder/pages 0.1.0-beta.13 → 0.1.0-beta.131

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,2187 +1,11 @@
1
- import wt, { useCallback as Ct, useState as A, useEffect as qe, useMemo as ne, useRef as St } from "react";
2
- import { loadWebBlocks as ca } from "@chaibuilder/sdk/web-blocks";
3
- import { getBlocksFromHTML as ua, useLanguages as $e, ChaiBuilderEditor as da } from "@chaibuilder/sdk";
4
- import { useQueryClient as J, useQuery as Y, useMutation as re, QueryClient as ha, QueryClientProvider as fa } from "@tanstack/react-query";
5
- import { useToast as H, Accordion as ma, AccordionItem as ge, AccordionTrigger as pe, AccordionContent as xe, Label as R, Input as G, Textarea as ve, Button as _, Popover as ga, PopoverTrigger as pa, PopoverContent as xa, Dialog as be, DialogContent as ye, DialogHeader as je, DialogTitle as we, DialogDescription as Ce, DialogFooter as Se, Tabs as va, TabsList as ba, TabsTrigger as pt, SheetHeader as ya, SheetDescription as ja, DropdownMenu as wa, DropdownMenuTrigger as Ca, DropdownMenuContent as Sa, DropdownMenuItem as Be, Sheet as ka, SheetContent as Ea } from "@chaibuilder/sdk/ui";
6
- import { StarIcon as Na, PencilIcon as kt, TrashIcon as Et, Plus as Ta, GlobeIcon as Nt, File as Tt, MoreVertical as Pa, Power as _a, ArrowLeftRightIcon as Oa, RocketIcon as Ra } from "lucide-react";
7
- import { get as M, find as ie, isEmpty as q, filter as Ke, includes as Pt, startCase as Da, reverse as Aa, sortBy as Fa, isEqual as Ge, map as We, startsWith as xt, toLower as La, trim as Ia, orderBy as Ua, isString as vt } from "lodash-es";
8
- var Me = { exports: {} }, te = {};
9
- /**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */
18
- var bt;
19
- function Ba() {
20
- if (bt) return te;
21
- bt = 1;
22
- var a = wt, i = Symbol.for("react.element"), l = Symbol.for("react.fragment"), n = Object.prototype.hasOwnProperty, s = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, d = { key: !0, ref: !0, __self: !0, __source: !0 };
23
- function c(p, h, b) {
24
- var w, f = {}, C = null, T = null;
25
- b !== void 0 && (C = "" + b), h.key !== void 0 && (C = "" + h.key), h.ref !== void 0 && (T = h.ref);
26
- for (w in h) n.call(h, w) && !d.hasOwnProperty(w) && (f[w] = h[w]);
27
- if (p && p.defaultProps) for (w in h = p.defaultProps, h) f[w] === void 0 && (f[w] = h[w]);
28
- return { $$typeof: i, type: p, key: C, ref: T, props: f, _owner: s.current };
29
- }
30
- return te.Fragment = l, te.jsx = c, te.jsxs = c, te;
31
- }
32
- var ae = {};
33
- /**
34
- * @license React
35
- * react-jsx-runtime.development.js
36
- *
37
- * Copyright (c) Facebook, Inc. and its affiliates.
38
- *
39
- * This source code is licensed under the MIT license found in the
40
- * LICENSE file in the root directory of this source tree.
41
- */
42
- var yt;
43
- function Ga() {
44
- return yt || (yt = 1, process.env.NODE_ENV !== "production" && function() {
45
- var a = wt, i = Symbol.for("react.element"), l = Symbol.for("react.portal"), n = Symbol.for("react.fragment"), s = Symbol.for("react.strict_mode"), d = Symbol.for("react.profiler"), c = Symbol.for("react.provider"), p = Symbol.for("react.context"), h = Symbol.for("react.forward_ref"), b = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), f = Symbol.for("react.memo"), C = Symbol.for("react.lazy"), T = Symbol.for("react.offscreen"), m = Symbol.iterator, v = "@@iterator";
46
- function F(t) {
47
- if (t === null || typeof t != "object")
48
- return null;
49
- var r = m && t[m] || t[v];
50
- return typeof r == "function" ? r : null;
51
- }
52
- var y = a.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;
53
- function k(t) {
54
- {
55
- for (var r = arguments.length, o = new Array(r > 1 ? r - 1 : 0), u = 1; u < r; u++)
56
- o[u - 1] = arguments[u];
57
- ke("error", t, o);
58
- }
59
- }
60
- function ke(t, r, o) {
61
- {
62
- var u = y.ReactDebugCurrentFrame, j = u.getStackAddendum();
63
- j !== "" && (r += "%s", o = o.concat([j]));
64
- var S = o.map(function(x) {
65
- return String(x);
66
- });
67
- S.unshift("Warning: " + r), Function.prototype.apply.call(console[t], console, S);
68
- }
69
- }
70
- var Ee = !1, oe = !1, Q = !1, Ne = !1, Te = !1, X;
71
- X = Symbol.for("react.module.reference");
72
- function K(t) {
73
- return !!(typeof t == "string" || typeof t == "function" || t === n || t === d || Te || t === s || t === b || t === w || Ne || t === T || Ee || oe || Q || typeof t == "object" && t !== null && (t.$$typeof === C || t.$$typeof === f || t.$$typeof === c || t.$$typeof === p || t.$$typeof === h || // This needs to include all possible module reference object
74
- // types supported by any Flight configuration anywhere since
75
- // we don't know which Flight build this will end up being used
76
- // with.
77
- t.$$typeof === X || t.getModuleId !== void 0));
78
- }
79
- function Pe(t, r, o) {
80
- var u = t.displayName;
81
- if (u)
82
- return u;
83
- var j = r.displayName || r.name || "";
84
- return j !== "" ? o + "(" + j + ")" : o;
85
- }
86
- function ce(t) {
87
- return t.displayName || "Context";
88
- }
89
- function I(t) {
90
- if (t == null)
91
- return null;
92
- if (typeof t.tag == "number" && k("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), typeof t == "function")
93
- return t.displayName || t.name || null;
94
- if (typeof t == "string")
95
- return t;
96
- switch (t) {
97
- case n:
98
- return "Fragment";
99
- case l:
100
- return "Portal";
101
- case d:
102
- return "Profiler";
103
- case s:
104
- return "StrictMode";
105
- case b:
106
- return "Suspense";
107
- case w:
108
- return "SuspenseList";
109
- }
110
- if (typeof t == "object")
111
- switch (t.$$typeof) {
112
- case p:
113
- var r = t;
114
- return ce(r) + ".Consumer";
115
- case c:
116
- var o = t;
117
- return ce(o._context) + ".Provider";
118
- case h:
119
- return Pe(t, t.render, "ForwardRef");
120
- case f:
121
- var u = t.displayName || null;
122
- return u !== null ? u : I(t.type) || "Memo";
123
- case C: {
124
- var j = t, S = j._payload, x = j._init;
125
- try {
126
- return I(x(S));
127
- } catch {
128
- return null;
129
- }
130
- }
131
- }
132
- return null;
133
- }
134
- var E = Object.assign, U = 0, W, ue, He, Qe, Xe, Ze, et;
135
- function tt() {
136
- }
137
- tt.__reactDisabledLog = !0;
138
- function Lt() {
139
- {
140
- if (U === 0) {
141
- W = console.log, ue = console.info, He = console.warn, Qe = console.error, Xe = console.group, Ze = console.groupCollapsed, et = console.groupEnd;
142
- var t = {
143
- configurable: !0,
144
- enumerable: !0,
145
- value: tt,
146
- writable: !0
147
- };
148
- Object.defineProperties(console, {
149
- info: t,
150
- log: t,
151
- warn: t,
152
- error: t,
153
- group: t,
154
- groupCollapsed: t,
155
- groupEnd: t
156
- });
157
- }
158
- U++;
159
- }
160
- }
161
- function It() {
162
- {
163
- if (U--, U === 0) {
164
- var t = {
165
- configurable: !0,
166
- enumerable: !0,
167
- writable: !0
168
- };
169
- Object.defineProperties(console, {
170
- log: E({}, t, {
171
- value: W
172
- }),
173
- info: E({}, t, {
174
- value: ue
175
- }),
176
- warn: E({}, t, {
177
- value: He
178
- }),
179
- error: E({}, t, {
180
- value: Qe
181
- }),
182
- group: E({}, t, {
183
- value: Xe
184
- }),
185
- groupCollapsed: E({}, t, {
186
- value: Ze
187
- }),
188
- groupEnd: E({}, t, {
189
- value: et
190
- })
191
- });
192
- }
193
- U < 0 && k("disabledDepth fell below zero. This is a bug in React. Please file an issue.");
194
- }
195
- }
196
- var _e = y.ReactCurrentDispatcher, Oe;
197
- function de(t, r, o) {
198
- {
199
- if (Oe === void 0)
200
- try {
201
- throw Error();
202
- } catch (j) {
203
- var u = j.stack.trim().match(/\n( *(at )?)/);
204
- Oe = u && u[1] || "";
205
- }
206
- return `
207
- ` + Oe + t;
208
- }
209
- }
210
- var Re = !1, he;
211
- {
212
- var Ut = typeof WeakMap == "function" ? WeakMap : Map;
213
- he = new Ut();
214
- }
215
- function at(t, r) {
216
- if (!t || Re)
217
- return "";
218
- {
219
- var o = he.get(t);
220
- if (o !== void 0)
221
- return o;
222
- }
223
- var u;
224
- Re = !0;
225
- var j = Error.prepareStackTrace;
226
- Error.prepareStackTrace = void 0;
227
- var S;
228
- S = _e.current, _e.current = null, Lt();
229
- try {
230
- if (r) {
231
- var x = function() {
232
- throw Error();
233
- };
234
- if (Object.defineProperty(x.prototype, "props", {
235
- set: function() {
236
- throw Error();
237
- }
238
- }), typeof Reflect == "object" && Reflect.construct) {
239
- try {
240
- Reflect.construct(x, []);
241
- } catch (D) {
242
- u = D;
243
- }
244
- Reflect.construct(t, [], x);
245
- } else {
246
- try {
247
- x.call();
248
- } catch (D) {
249
- u = D;
250
- }
251
- t.call(x.prototype);
252
- }
253
- } else {
254
- try {
255
- throw Error();
256
- } catch (D) {
257
- u = D;
258
- }
259
- t();
260
- }
261
- } catch (D) {
262
- if (D && u && typeof D.stack == "string") {
263
- for (var g = D.stack.split(`
264
- `), O = u.stack.split(`
265
- `), N = g.length - 1, P = O.length - 1; N >= 1 && P >= 0 && g[N] !== O[P]; )
266
- P--;
267
- for (; N >= 1 && P >= 0; N--, P--)
268
- if (g[N] !== O[P]) {
269
- if (N !== 1 || P !== 1)
270
- do
271
- if (N--, P--, P < 0 || g[N] !== O[P]) {
272
- var B = `
273
- ` + g[N].replace(" at new ", " at ");
274
- return t.displayName && B.includes("<anonymous>") && (B = B.replace("<anonymous>", t.displayName)), typeof t == "function" && he.set(t, B), B;
275
- }
276
- while (N >= 1 && P >= 0);
277
- break;
278
- }
279
- }
280
- } finally {
281
- Re = !1, _e.current = S, It(), Error.prepareStackTrace = j;
282
- }
283
- var z = t ? t.displayName || t.name : "", $ = z ? de(z) : "";
284
- return typeof t == "function" && he.set(t, $), $;
285
- }
286
- function Bt(t, r, o) {
287
- return at(t, !1);
288
- }
289
- function Gt(t) {
290
- var r = t.prototype;
291
- return !!(r && r.isReactComponent);
292
- }
293
- function fe(t, r, o) {
294
- if (t == null)
295
- return "";
296
- if (typeof t == "function")
297
- return at(t, Gt(t));
298
- if (typeof t == "string")
299
- return de(t);
300
- switch (t) {
301
- case b:
302
- return de("Suspense");
303
- case w:
304
- return de("SuspenseList");
305
- }
306
- if (typeof t == "object")
307
- switch (t.$$typeof) {
308
- case h:
309
- return Bt(t.render);
310
- case f:
311
- return fe(t.type, r, o);
312
- case C: {
313
- var u = t, j = u._payload, S = u._init;
314
- try {
315
- return fe(S(j), r, o);
316
- } catch {
317
- }
318
- }
319
- }
320
- return "";
321
- }
322
- var Z = Object.prototype.hasOwnProperty, nt = {}, st = y.ReactDebugCurrentFrame;
323
- function me(t) {
324
- if (t) {
325
- var r = t._owner, o = fe(t.type, t._source, r ? r.type : null);
326
- st.setExtraStackFrame(o);
327
- } else
328
- st.setExtraStackFrame(null);
329
- }
330
- function Mt(t, r, o, u, j) {
331
- {
332
- var S = Function.call.bind(Z);
333
- for (var x in t)
334
- if (S(t, x)) {
335
- var g = void 0;
336
- try {
337
- if (typeof t[x] != "function") {
338
- var O = Error((u || "React class") + ": " + o + " type `" + x + "` is invalid; it must be a function, usually from the `prop-types` package, but received `" + typeof t[x] + "`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");
339
- throw O.name = "Invariant Violation", O;
340
- }
341
- g = t[x](r, x, u, o, null, "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED");
342
- } catch (N) {
343
- g = N;
344
- }
345
- g && !(g instanceof Error) && (me(j), k("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).", u || "React class", o, x, typeof g), me(null)), g instanceof Error && !(g.message in nt) && (nt[g.message] = !0, me(j), k("Failed %s type: %s", o, g.message), me(null));
346
- }
347
- }
348
- }
349
- var qt = Array.isArray;
350
- function De(t) {
351
- return qt(t);
352
- }
353
- function $t(t) {
354
- {
355
- var r = typeof Symbol == "function" && Symbol.toStringTag, o = r && t[Symbol.toStringTag] || t.constructor.name || "Object";
356
- return o;
357
- }
358
- }
359
- function Kt(t) {
360
- try {
361
- return rt(t), !1;
362
- } catch {
363
- return !0;
364
- }
365
- }
366
- function rt(t) {
367
- return "" + t;
368
- }
369
- function it(t) {
370
- if (Kt(t))
371
- return k("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", $t(t)), rt(t);
372
- }
373
- var ee = y.ReactCurrentOwner, Wt = {
374
- key: !0,
375
- ref: !0,
376
- __self: !0,
377
- __source: !0
378
- }, lt, ot, Ae;
379
- Ae = {};
380
- function Vt(t) {
381
- if (Z.call(t, "ref")) {
382
- var r = Object.getOwnPropertyDescriptor(t, "ref").get;
383
- if (r && r.isReactWarning)
384
- return !1;
385
- }
386
- return t.ref !== void 0;
387
- }
388
- function zt(t) {
389
- if (Z.call(t, "key")) {
390
- var r = Object.getOwnPropertyDescriptor(t, "key").get;
391
- if (r && r.isReactWarning)
392
- return !1;
393
- }
394
- return t.key !== void 0;
395
- }
396
- function Jt(t, r) {
397
- if (typeof t.ref == "string" && ee.current && r && ee.current.stateNode !== r) {
398
- var o = I(ee.current.type);
399
- Ae[o] || (k('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref', I(ee.current.type), t.ref), Ae[o] = !0);
400
- }
401
- }
402
- function Yt(t, r) {
403
- {
404
- var o = function() {
405
- lt || (lt = !0, k("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
406
- };
407
- o.isReactWarning = !0, Object.defineProperty(t, "key", {
408
- get: o,
409
- configurable: !0
410
- });
411
- }
412
- }
413
- function Ht(t, r) {
414
- {
415
- var o = function() {
416
- ot || (ot = !0, k("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)", r));
417
- };
418
- o.isReactWarning = !0, Object.defineProperty(t, "ref", {
419
- get: o,
420
- configurable: !0
421
- });
422
- }
423
- }
424
- var Qt = function(t, r, o, u, j, S, x) {
425
- var g = {
426
- // This tag allows us to uniquely identify this as a React Element
427
- $$typeof: i,
428
- // Built-in properties that belong on the element
429
- type: t,
430
- key: r,
431
- ref: o,
432
- props: x,
433
- // Record the component responsible for creating this element.
434
- _owner: S
435
- };
436
- return g._store = {}, Object.defineProperty(g._store, "validated", {
437
- configurable: !1,
438
- enumerable: !1,
439
- writable: !0,
440
- value: !1
441
- }), Object.defineProperty(g, "_self", {
442
- configurable: !1,
443
- enumerable: !1,
444
- writable: !1,
445
- value: u
446
- }), Object.defineProperty(g, "_source", {
447
- configurable: !1,
448
- enumerable: !1,
449
- writable: !1,
450
- value: j
451
- }), Object.freeze && (Object.freeze(g.props), Object.freeze(g)), g;
452
- };
453
- function Xt(t, r, o, u, j) {
454
- {
455
- var S, x = {}, g = null, O = null;
456
- o !== void 0 && (it(o), g = "" + o), zt(r) && (it(r.key), g = "" + r.key), Vt(r) && (O = r.ref, Jt(r, j));
457
- for (S in r)
458
- Z.call(r, S) && !Wt.hasOwnProperty(S) && (x[S] = r[S]);
459
- if (t && t.defaultProps) {
460
- var N = t.defaultProps;
461
- for (S in N)
462
- x[S] === void 0 && (x[S] = N[S]);
463
- }
464
- if (g || O) {
465
- var P = typeof t == "function" ? t.displayName || t.name || "Unknown" : t;
466
- g && Yt(x, P), O && Ht(x, P);
467
- }
468
- return Qt(t, g, O, j, u, ee.current, x);
469
- }
470
- }
471
- var Fe = y.ReactCurrentOwner, ct = y.ReactDebugCurrentFrame;
472
- function V(t) {
473
- if (t) {
474
- var r = t._owner, o = fe(t.type, t._source, r ? r.type : null);
475
- ct.setExtraStackFrame(o);
476
- } else
477
- ct.setExtraStackFrame(null);
478
- }
479
- var Le;
480
- Le = !1;
481
- function Ie(t) {
482
- return typeof t == "object" && t !== null && t.$$typeof === i;
483
- }
484
- function ut() {
485
- {
486
- if (Fe.current) {
487
- var t = I(Fe.current.type);
488
- if (t)
489
- return `
490
-
491
- Check the render method of \`` + t + "`.";
492
- }
493
- return "";
494
- }
495
- }
496
- function Zt(t) {
497
- return "";
498
- }
499
- var dt = {};
500
- function ea(t) {
501
- {
502
- var r = ut();
503
- if (!r) {
504
- var o = typeof t == "string" ? t : t.displayName || t.name;
505
- o && (r = `
506
-
507
- Check the top-level render call using <` + o + ">.");
508
- }
509
- return r;
510
- }
511
- }
512
- function ht(t, r) {
513
- {
514
- if (!t._store || t._store.validated || t.key != null)
515
- return;
516
- t._store.validated = !0;
517
- var o = ea(r);
518
- if (dt[o])
519
- return;
520
- dt[o] = !0;
521
- var u = "";
522
- t && t._owner && t._owner !== Fe.current && (u = " It was passed a child from " + I(t._owner.type) + "."), V(t), k('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.', o, u), V(null);
523
- }
524
- }
525
- function ft(t, r) {
526
- {
527
- if (typeof t != "object")
528
- return;
529
- if (De(t))
530
- for (var o = 0; o < t.length; o++) {
531
- var u = t[o];
532
- Ie(u) && ht(u, r);
533
- }
534
- else if (Ie(t))
535
- t._store && (t._store.validated = !0);
536
- else if (t) {
537
- var j = F(t);
538
- if (typeof j == "function" && j !== t.entries)
539
- for (var S = j.call(t), x; !(x = S.next()).done; )
540
- Ie(x.value) && ht(x.value, r);
541
- }
542
- }
543
- }
544
- function ta(t) {
545
- {
546
- var r = t.type;
547
- if (r == null || typeof r == "string")
548
- return;
549
- var o;
550
- if (typeof r == "function")
551
- o = r.propTypes;
552
- else if (typeof r == "object" && (r.$$typeof === h || // Note: Memo only checks outer props here.
553
- // Inner props are checked in the reconciler.
554
- r.$$typeof === f))
555
- o = r.propTypes;
556
- else
557
- return;
558
- if (o) {
559
- var u = I(r);
560
- Mt(o, t.props, "prop", u, t);
561
- } else if (r.PropTypes !== void 0 && !Le) {
562
- Le = !0;
563
- var j = I(r);
564
- k("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?", j || "Unknown");
565
- }
566
- typeof r.getDefaultProps == "function" && !r.getDefaultProps.isReactClassApproved && k("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.");
567
- }
568
- }
569
- function aa(t) {
570
- {
571
- for (var r = Object.keys(t.props), o = 0; o < r.length; o++) {
572
- var u = r[o];
573
- if (u !== "children" && u !== "key") {
574
- V(t), k("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.", u), V(null);
575
- break;
576
- }
577
- }
578
- t.ref !== null && (V(t), k("Invalid attribute `ref` supplied to `React.Fragment`."), V(null));
579
- }
580
- }
581
- var mt = {};
582
- function gt(t, r, o, u, j, S) {
583
- {
584
- var x = K(t);
585
- if (!x) {
586
- var g = "";
587
- (t === void 0 || typeof t == "object" && t !== null && Object.keys(t).length === 0) && (g += " You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");
588
- var O = Zt();
589
- O ? g += O : g += ut();
590
- var N;
591
- t === null ? N = "null" : De(t) ? N = "array" : t !== void 0 && t.$$typeof === i ? (N = "<" + (I(t.type) || "Unknown") + " />", g = " Did you accidentally export a JSX literal instead of a component?") : N = typeof t, k("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", N, g);
592
- }
593
- var P = Xt(t, r, o, j, S);
594
- if (P == null)
595
- return P;
596
- if (x) {
597
- var B = r.children;
598
- if (B !== void 0)
599
- if (u)
600
- if (De(B)) {
601
- for (var z = 0; z < B.length; z++)
602
- ft(B[z], t);
603
- Object.freeze && Object.freeze(B);
604
- } else
605
- k("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
606
- else
607
- ft(B, t);
608
- }
609
- if (Z.call(r, "key")) {
610
- var $ = I(t), D = Object.keys(r).filter(function(oa) {
611
- return oa !== "key";
612
- }), Ue = D.length > 0 ? "{key: someKey, " + D.join(": ..., ") + ": ...}" : "{key: someKey}";
613
- if (!mt[$ + Ue]) {
614
- var la = D.length > 0 ? "{" + D.join(": ..., ") + ": ...}" : "{}";
615
- k(`A props object containing a "key" prop is being spread into JSX:
616
- let props = %s;
617
- <%s {...props} />
618
- React keys must be passed directly to JSX without using spread:
619
- let props = %s;
620
- <%s key={someKey} {...props} />`, Ue, $, la, $), mt[$ + Ue] = !0;
621
- }
622
- }
623
- return t === n ? aa(P) : ta(P), P;
624
- }
625
- }
626
- function na(t, r, o) {
627
- return gt(t, r, o, !0);
628
- }
629
- function sa(t, r, o) {
630
- return gt(t, r, o, !1);
631
- }
632
- var ra = sa, ia = na;
633
- ae.Fragment = n, ae.jsx = ra, ae.jsxs = ia;
634
- }()), ae;
635
- }
636
- process.env.NODE_ENV === "production" ? Me.exports = Ba() : Me.exports = Ga();
637
- var e = Me.exports;
638
- const Ma = (a, i) => {
639
- const n = J().getQueryData(["builder_props"]);
640
- return M(n, a, i);
641
- }, L = () => Ma("apiUrl", "/chai"), Ve = () => {
642
- const a = J(), { data: i } = Y({
643
- queryKey: ["ai-context"],
644
- initialData: "",
645
- queryFn: () => ""
646
- });
647
- return { setAiContext: Ct((n) => {
648
- a.setQueryData(["ai-context"], n);
649
- }, []), aiContext: i };
650
- }, qa = () => {
651
- const a = L(), { aiContext: i } = Ve();
652
- return Ct(
653
- async (l, n, s, d) => {
654
- const p = await (await fetch(a, {
655
- method: "POST",
656
- headers: {
657
- "Content-Type": "application/json"
658
- },
659
- body: JSON.stringify({
660
- action: "ASK_AI",
661
- data: { type: l, prompt: n, blocks: s, aiContext: i, lang: d }
662
- })
663
- })).json();
664
- return console.log("data", p), p.error ? { error: new Error(p.error) } : p;
665
- },
666
- [a, i]
667
- );
668
- }, $a = () => {
669
- const a = L(), { toast: i } = H();
670
- return { getUILibraryBlock: async (d, c) => {
671
- const b = (await (await fetch(
672
- d.url + (c.path ? "/blocks/" + c.path : "/" + c.uuid + ".html")
673
- )).text()).replace(/---([\s\S]*?)---/g, "");
674
- return ua(`${b}`);
675
- }, getUILibraryBlocks: async (d) => {
676
- try {
677
- return (await (await fetch(d.url + "/blocks.json")).json()).map((h) => ({
678
- ...h,
679
- preview: d.url.replace("chaiblocks", "") + h.preview
680
- }));
681
- } catch (c) {
682
- return console.error(c), [];
683
- }
684
- }, onSave: async ({
685
- page: d,
686
- blocks: c
687
- }) => {
688
- try {
689
- return (await fetch(a, {
690
- method: "POST",
691
- headers: { "Content-Type": "application/json" },
692
- body: JSON.stringify({
693
- action: "UPDATE_PAGE",
694
- data: { id: d, blocks: c }
695
- })
696
- })).ok ? (i({
697
- title: "Success",
698
- description: "Page saved successfully",
699
- variant: "default"
700
- }), !0) : new Error("Failed to save blocks");
701
- } catch (p) {
702
- return p;
703
- }
704
- } };
705
- };
706
- function le() {
707
- const [a, i] = A(
708
- new URLSearchParams(window.location.search)
709
- );
710
- return qe(() => {
711
- const l = () => {
712
- i(new URLSearchParams(window.location.search));
713
- };
714
- return window.addEventListener("popstate", l), () => {
715
- window.removeEventListener("popstate", l);
716
- };
717
- }, []), [a, i];
718
- }
719
- const ze = () => {
720
- const a = L();
721
- return Y({
722
- queryKey: ["project-pages"],
723
- staleTime: 1e3 * 60 * 5,
724
- queryFn: async () => await (await fetch(a, {
725
- method: "POST",
726
- headers: {
727
- "Content-Type": "application/json"
728
- },
729
- body: JSON.stringify({
730
- action: "GET_PROJECT_PAGES"
731
- })
732
- })).json()
733
- });
734
- }, _t = () => {
735
- const [a] = le(), i = a.get("page"), { data: l, isFetching: n } = ze();
736
- return { data: ne(
737
- () => ie(l, { id: i }) || {},
738
- [l, i]
739
- ), isFetching: n };
740
- }, Ka = () => Y({
741
- queryKey: ["uiLibraries"],
742
- initialData: [],
743
- queryFn: async () => [
744
- {
745
- uuid: "meraki-ui",
746
- name: "Meraki UI",
747
- url: "https://chai-ui-blocks.vercel.app"
748
- },
749
- {
750
- uuid: "chaiblocks",
751
- name: "UI Blocks",
752
- url: "https://chaibuilder.com/chaiblocks"
753
- }
754
- ]
755
- }), Wa = () => {
756
- const [a] = le(), i = a.get("page"), l = L(), { setAiContext: n } = Ve();
757
- return Y({
758
- queryKey: ["page", i],
759
- initialData: [],
760
- queryFn: async () => {
761
- const c = (await (await fetch(`${l}`, {
762
- method: "POST",
763
- headers: { "Content-Type": "application/json" },
764
- body: JSON.stringify({
765
- action: "GET_PAGE",
766
- data: { id: i, draft: !0 }
767
- })
768
- })).json()).blocks ?? [], p = ie(c, { _type: "@chai/ai-context" });
769
- return n(M(p, "_value", "") || ""), c;
770
- },
771
- enabled: !!i
772
- });
773
- }, Va = (a) => ne(() => {
774
- if (!a || q(a))
775
- return {
776
- blocks: [],
777
- theme: {}
778
- };
779
- const i = ie(a, { _type: "@chai/theme" }), l = M(i, "_value", {}) || {}, n = Ke(
780
- a,
781
- (s) => !Pt(s == null ? void 0 : s._type, "@chai/")
782
- );
783
- return { theme: l, blocks: n };
784
- }, [a]), Ot = () => {
785
- const a = L();
786
- return Y({
787
- queryKey: ["project-config"],
788
- initialData: {
789
- theme: {},
790
- fallbackLang: "",
791
- languages: []
792
- },
793
- queryFn: async () => {
794
- try {
795
- const l = await (await fetch(a, {
796
- method: "POST",
797
- headers: {
798
- "Content-Type": "application/json"
799
- },
800
- body: JSON.stringify({ action: "GET_PROJECT_CONFIG" })
801
- })).json();
802
- if (l != null && l.error) throw "";
803
- return l;
804
- } catch {
805
- return {
806
- fallbackLang: "fr",
807
- languages: ["en"],
808
- theme: {}
809
- };
810
- }
811
- }
812
- });
813
- }, za = () => {
814
- const { data: a } = ze(), i = L();
815
- return {
816
- getGlobalBlocks: async () => {
817
- const l = {};
818
- for (const n of a ?? [])
819
- q(n == null ? void 0 : n.slug) && (l[n.id] = {
820
- name: Da(n.name ?? n.slug),
821
- description: ""
822
- });
823
- return l;
824
- },
825
- getGlobalBlockBlocks: async (l) => l ? (await (await fetch(`${i}`, {
826
- method: "POST",
827
- headers: { "Content-Type": "application/json" },
828
- body: JSON.stringify({
829
- action: "GET_PAGE",
830
- data: { id: l, draft: !0 }
831
- })
832
- })).json()).blocks : []
833
- };
834
- }, Ja = () => {
835
- const a = L();
836
- return { uploadFile: async (l) => {
837
- const n = new FormData();
838
- return n.append("action", "UPLOAD_FILE"), n.append("file", l), (await fetch(a, {
839
- method: "POST",
840
- body: n
841
- })).json();
842
- } };
843
- }, Ya = () => {
844
- const a = L(), { toast: i } = H();
845
- return re({
846
- mutationFn: async (l) => (await fetch(`${a}`, {
847
- method: "POST",
848
- headers: { "Content-Type": "application/json" },
849
- body: JSON.stringify({
850
- action: "PUBLISH_PAGE",
851
- data: { id: l }
852
- })
853
- })).json(),
854
- onSuccess: () => {
855
- i({
856
- title: "Pages published",
857
- description: "Your page has been published"
858
- });
859
- }
860
- });
861
- }, Je = () => {
862
- const a = L(), [i] = le(), l = i.get("page");
863
- return Y({
864
- queryKey: ["language-pages", l],
865
- initialData: [],
866
- queryFn: async () => {
867
- if (!l) return null;
868
- const s = await (await fetch(a, {
869
- method: "POST",
870
- headers: { "Content-Type": "application/json" },
871
- body: JSON.stringify({
872
- action: "GET_LANGUAGE_PAGES",
873
- data: { id: l }
874
- })
875
- })).json();
876
- return Aa(Fa(s, "primaryPage"));
877
- }
878
- });
879
- }, se = {
880
- ab: "Abkhazian",
881
- aa: "Afar",
882
- af: "Afrikaans",
883
- ak: "Akan",
884
- sq: "Albanian",
885
- am: "Amharic",
886
- ar: "Arabic",
887
- an: "Aragonese",
888
- hy: "Armenian",
889
- as: "Assamese",
890
- av: "Avaric",
891
- ae: "Avestan",
892
- ay: "Aymara",
893
- az: "Azerbaijani",
894
- bm: "Bambara",
895
- ba: "Bashkir",
896
- eu: "Basque",
897
- be: "Belarusian",
898
- bn: "Bengali",
899
- bh: "Bihari",
900
- bi: "Bislama",
901
- bs: "Bosnian",
902
- br: "Breton",
903
- bg: "Bulgarian",
904
- my: "Burmese",
905
- ca: "Catalan",
906
- ch: "Chamorro",
907
- ce: "Chechen",
908
- ny: "Chichewa",
909
- zh: "Chinese",
910
- "zh-Hans": "Chinese (Simplified)",
911
- "zh-Hant": "Chinese (Traditional)",
912
- cv: "Chuvash",
913
- kw: "Cornish",
914
- co: "Corsican",
915
- cr: "Cree",
916
- hr: "Croatian",
917
- cs: "Czech",
918
- da: "Danish",
919
- dv: "Maldivian",
920
- nl: "Dutch",
921
- dz: "Dzongkha",
922
- en: "English",
923
- eo: "Esperanto",
924
- et: "Estonian",
925
- ee: "Ewe",
926
- fo: "Faroese",
927
- fj: "Fijian",
928
- fi: "Finnish",
929
- fr: "French",
930
- ff: "Fula, Pular",
931
- gl: "Galician",
932
- gd: "Gaelic (Scottish)",
933
- gv: "Manx",
934
- ka: "Georgian",
935
- de: "German",
936
- el: "Greek",
937
- kl: "Kalaallisut",
938
- gn: "Guarani",
939
- gu: "Gujarati",
940
- ht: "Haitian Creole",
941
- ha: "Hausa",
942
- he: "Hebrew",
943
- hz: "Herero",
944
- hi: "Hindi",
945
- ho: "Hiri Motu",
946
- hu: "Hungarian",
947
- is: "Icelandic",
948
- io: "Ido",
949
- ig: "Igbo",
950
- id: "Indonesian",
951
- ia: "Interlingua",
952
- ie: "Interlingue",
953
- iu: "Inuktitut",
954
- ik: "Inupiak",
955
- ga: "Irish",
956
- it: "Italian",
957
- ja: "Japanese",
958
- jv: "Javanese",
959
- kn: "Kannada",
960
- kr: "Kanuri",
961
- ks: "Kashmiri",
962
- kk: "Kazakh",
963
- km: "Khmer",
964
- ki: "Kikuyu",
965
- rw: "Kinyarwanda",
966
- rn: "Kirundi",
967
- ky: "Kyrgyz",
968
- kv: "Komi",
969
- kg: "Kongo",
970
- ko: "Korean",
971
- ku: "Kurdish",
972
- kj: "Kwanyama",
973
- lo: "Lao",
974
- la: "Latin",
975
- lv: "Latvian",
976
- li: "Limburgish",
977
- ln: "Lingala",
978
- lt: "Lithuanian",
979
- lu: "Luga-Katanga",
980
- lg: "Luganda, Ganda",
981
- lb: "Luxembourgish",
982
- mk: "Macedonian",
983
- mg: "Malagasy",
984
- ms: "Malay",
985
- ml: "Malayalam",
986
- mt: "Maltese",
987
- mi: "Maori",
988
- mr: "Marathi",
989
- mh: "Marshallese",
990
- mo: "Moldavian",
991
- mn: "Mongolian",
992
- na: "Nauru",
993
- nv: "Navajo",
994
- ng: "Ndonga",
995
- nd: "Northern Ndebele",
996
- ne: "Nepali",
997
- no: "Norwegian",
998
- nb: "Norwegian bokmål",
999
- nn: "Norwegian nynorsk",
1000
- ii: "Sichuan Yi",
1001
- oc: "Occitan",
1002
- oj: "Ojibwe",
1003
- cu: "Old Church Slavonic",
1004
- or: "Oriya",
1005
- om: "Oromo",
1006
- os: "Ossetian",
1007
- pi: "Pāli",
1008
- ps: "Pashto, Pushto",
1009
- fa: "Persian (Farsi)",
1010
- pl: "Polish",
1011
- pt: "Portuguese",
1012
- pa: "Punjabi (Eastern)",
1013
- qu: "Quechua",
1014
- rm: "Romansh",
1015
- ro: "Romanian",
1016
- ru: "Russian",
1017
- se: "Sami",
1018
- sm: "Samoan",
1019
- sg: "Sango",
1020
- sa: "Sanskrit",
1021
- sr: "Serbian",
1022
- sh: "Serbo-Croatian",
1023
- st: "Sesotho",
1024
- tn: "Setswana",
1025
- sn: "Shona",
1026
- sd: "Sindhi",
1027
- si: "Sinhalese",
1028
- ss: "Swati",
1029
- sk: "Slovak",
1030
- sl: "Slovenian",
1031
- so: "Somali",
1032
- nr: "Southern Ndebele",
1033
- es: "Spanish",
1034
- su: "Sundanese",
1035
- sw: "Swahili (Kiswahili)",
1036
- sv: "Swedish",
1037
- tl: "Tagalog",
1038
- ty: "Tahitian",
1039
- tg: "Tajik",
1040
- ta: "Tamil",
1041
- tt: "Tatar",
1042
- te: "Telugu",
1043
- th: "Thai",
1044
- bo: "Tibetan",
1045
- ti: "Tigrinya",
1046
- to: "Tonga",
1047
- ts: "Tsonga",
1048
- tr: "Turkish",
1049
- tk: "Turkmen",
1050
- tw: "Twi",
1051
- ug: "Uyghur",
1052
- uk: "Ukrainian",
1053
- ur: "Urdu",
1054
- uz: "Uzbek",
1055
- ve: "Venda",
1056
- vi: "Vietnamese",
1057
- vo: "Volapük",
1058
- wa: "Wallon",
1059
- cy: "Welsh",
1060
- wo: "Wolof",
1061
- fy: "Western Frisian",
1062
- xh: "Xhosa",
1063
- yi: "Yiddish",
1064
- yo: "Yoruba",
1065
- za: "Zhuang, Chuang",
1066
- zu: "Zulu"
1067
- }, Rt = () => {
1068
- const a = L(), i = J(), { toast: l } = H();
1069
- return re({
1070
- mutationFn: async (n) => {
1071
- var c;
1072
- const d = await (await fetch(a, {
1073
- method: "POST",
1074
- headers: {
1075
- "Content-Type": "application/json"
1076
- },
1077
- body: JSON.stringify({
1078
- action: "CREATE_PAGE",
1079
- data: n
1080
- })
1081
- })).json();
1082
- if (d != null && d.error)
1083
- throw new Error(((c = d == null ? void 0 : d.error) == null ? void 0 : c.message) || "Something went wrong.");
1084
- return d;
1085
- },
1086
- onSuccess: (n, s) => {
1087
- s && (s != null && s.primaryPage) ? i.invalidateQueries({
1088
- queryKey: ["language-pages", s == null ? void 0 : s.primaryPage]
1089
- }) : i.invalidateQueries({ queryKey: ["project-pages"] }), l({
1090
- title: `New ${s.global ? "global block" : "page"} added successfully.`
1091
- });
1092
- },
1093
- onError: (n, s) => {
1094
- l({
1095
- variant: "destructive",
1096
- title: `Failed to add new ${s.global ? "global block" : "page"}.`,
1097
- description: n.message
1098
- });
1099
- }
1100
- });
1101
- }, Ye = () => {
1102
- const a = L(), i = J(), { toast: l } = H();
1103
- return re({
1104
- mutationFn: async (n) => (await fetch(a, {
1105
- method: "POST",
1106
- headers: {
1107
- "Content-Type": "application/json"
1108
- },
1109
- body: JSON.stringify({
1110
- action: "UPDATE_PAGE",
1111
- data: n
1112
- })
1113
- })).json(),
1114
- onSuccess: (n, s) => {
1115
- s && (s != null && s.primaryPage || s != null && s.seo) ? i.invalidateQueries({
1116
- queryKey: ["language-pages", s == null ? void 0 : s.primaryPage]
1117
- }) : i.invalidateQueries({ queryKey: ["project-pages"] }), s != null && s.seo ? l({
1118
- title: "SEO Settings updated successfully."
1119
- }) : l({
1120
- title: `${s.global ? "Global block" : "Page"} updated successfully.`
1121
- });
1122
- },
1123
- onError: (n, s) => {
1124
- l({
1125
- variant: "destructive",
1126
- title: `Failed to update ${s.global ? "global block" : "page"}.`,
1127
- description: n.message
1128
- });
1129
- }
1130
- });
1131
- }, Dt = () => {
1132
- const a = L(), i = J(), { toast: l } = H();
1133
- return re({
1134
- mutationFn: async (n) => (await fetch(a, {
1135
- method: "POST",
1136
- headers: {
1137
- "Content-Type": "application/json"
1138
- },
1139
- body: JSON.stringify({
1140
- action: "DELETE_PAGE",
1141
- data: { id: n == null ? void 0 : n.id }
1142
- })
1143
- })).json(),
1144
- onSuccess: (n, s) => {
1145
- s && (s != null && s.primaryPage) ? i.invalidateQueries({
1146
- queryKey: ["language-pages", s == null ? void 0 : s.primaryPage]
1147
- }) : i.invalidateQueries({ queryKey: ["project-pages"] }), l({
1148
- title: `${s.global ? "Global block" : "Page"} deleted successfully.`
1149
- });
1150
- },
1151
- onError: (n, s) => {
1152
- l({
1153
- variant: "destructive",
1154
- title: `Failed to delete ${s.global ? "global block" : "page"}.`,
1155
- description: n.message
1156
- });
1157
- }
1158
- });
1159
- }, Ha = () => {
1160
- const a = L(), i = J(), { toast: l } = H();
1161
- return re({
1162
- mutationFn: async (n) => (await fetch(a, {
1163
- method: "POST",
1164
- headers: {
1165
- "Content-Type": "application/json"
1166
- },
1167
- body: JSON.stringify({
1168
- action: "UNPUBLISH_PAGE",
1169
- data: { id: n == null ? void 0 : n.id }
1170
- })
1171
- })).json(),
1172
- onSuccess: (n, s) => {
1173
- s && (s != null && s.primaryPage) ? i.invalidateQueries({
1174
- queryKey: ["language-pages", s == null ? void 0 : s.primaryPage]
1175
- }) : i.invalidateQueries({ queryKey: ["project-pages"] }), l({
1176
- title: `${s.global ? "Global block" : "Page"} unpublished successfully.`
1177
- });
1178
- },
1179
- onError: (n, s) => {
1180
- l({
1181
- variant: "destructive",
1182
- title: `Failed to unpublish ${s.global ? "global block" : "page"}.`,
1183
- description: n.message
1184
- });
1185
- }
1186
- });
1187
- }, At = () => {
1188
- const { selectedLang: a } = $e(), { data: i, isFetching: l } = Je();
1189
- return { data: ne(() => ie(i, { lang: a || "" }) || {}, [i, a]), isFetching: l };
1190
- }, Ft = () => {
1191
- const { data: a, isFetching: i } = At(), l = a == null ? void 0 : a.seo, [n, s] = A({
1192
- title: "",
1193
- description: "",
1194
- cononicalUrl: "",
1195
- noIndex: !1,
1196
- noFollow: "",
1197
- ogTitle: "",
1198
- ogDescription: "",
1199
- ogImage: "",
1200
- searchTitle: "",
1201
- searchDescription: "",
1202
- jsonLD: "",
1203
- ...l
1204
- }), d = St({ initial: n, updated: n }), { selectedLang: c, fallbackLang: p } = $e(), h = c.length ? c : p, { mutate: b, isPending: w } = Ye(), f = w;
1205
- qe(() => {
1206
- !i && l && s({
1207
- title: "",
1208
- description: "",
1209
- cononicalUrl: "",
1210
- noIndex: !1,
1211
- noFollow: "",
1212
- ogTitle: "",
1213
- ogDescription: "",
1214
- ogImage: "",
1215
- searchTitle: "",
1216
- searchDescription: "",
1217
- jsonLD: "",
1218
- ...l
1219
- });
1220
- }, [i, l]);
1221
- const C = async () => {
1222
- b({ id: a == null ? void 0 : a.id, seo: n }), d.current.initial = n, d.current.updated = n;
1223
- }, T = () => {
1224
- s({
1225
- ...n,
1226
- ogTitle: n.title,
1227
- ogDescription: n.description
1228
- });
1229
- }, m = () => {
1230
- s({
1231
- ...n,
1232
- searchTitle: n.ogTitle,
1233
- searchDescription: n.ogDescription
1234
- });
1235
- }, v = (F) => {
1236
- const y = {
1237
- ...n,
1238
- [F.target.name]: F.target.name === "noIndex" || F.target.name === "noFollow" ? F.target.checked : F.target.value
1239
- };
1240
- s(y), d.current.updated = y;
1241
- };
1242
- return /* @__PURE__ */ e.jsxs("div", { className: "relative pb-40", children: [
1243
- /* @__PURE__ */ e.jsxs("div", { className: "text-xs bg-gray-100 p-2 rounded-md text-center", children: [
1244
- "Current language:",
1245
- " ",
1246
- /* @__PURE__ */ e.jsx("span", { className: "text-blue-500 font-semibold", children: M(se, h, h) }),
1247
- /* @__PURE__ */ e.jsxs("span", { className: "text-[11px] text-gray-500", children: [
1248
- " ",
1249
- "( ",
1250
- a == null ? void 0 : a.slug,
1251
- " )"
1252
- ] })
1253
- ] }),
1254
- /* @__PURE__ */ e.jsx("form", { className: "space-y-8", children: /* @__PURE__ */ e.jsxs(ma, { type: "multiple", defaultValue: ["page"], children: [
1255
- /* @__PURE__ */ e.jsxs(ge, { value: "page", children: [
1256
- /* @__PURE__ */ e.jsx(pe, { className: "text-blue-500", children: "Seo Page" }),
1257
- /* @__PURE__ */ e.jsx(xe, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1258
- /* @__PURE__ */ e.jsxs("div", { children: [
1259
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "title", children: "SEO Title" }),
1260
- /* @__PURE__ */ e.jsx(
1261
- G,
1262
- {
1263
- type: "text",
1264
- id: "title",
1265
- name: "title",
1266
- value: n.title,
1267
- onChange: v,
1268
- disabled: f,
1269
- placeholder: "Enter SEO title"
1270
- }
1271
- ),
1272
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "The title should be between 10 and 60 characters." })
1273
- ] }),
1274
- /* @__PURE__ */ e.jsxs("div", { children: [
1275
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "description", children: "SEO Description" }),
1276
- /* @__PURE__ */ e.jsx(
1277
- ve,
1278
- {
1279
- id: "description",
1280
- name: "description",
1281
- value: n.description,
1282
- onChange: v,
1283
- disabled: f,
1284
- placeholder: "Enter SEO description"
1285
- }
1286
- ),
1287
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "The description should be between 50 and 160 characters." })
1288
- ] }),
1289
- /* @__PURE__ */ e.jsxs("div", { children: [
1290
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "title", children: "Canonical URL" }),
1291
- /* @__PURE__ */ e.jsx(
1292
- G,
1293
- {
1294
- type: "text",
1295
- id: "canonicalUrl",
1296
- name: "canonicalUrl",
1297
- value: n.canonicalUrl,
1298
- onChange: v,
1299
- disabled: f,
1300
- placeholder: "Enter Canonical URL"
1301
- }
1302
- )
1303
- ] }),
1304
- /* @__PURE__ */ e.jsxs("div", { className: "", children: [
1305
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-x-2", children: [
1306
- /* @__PURE__ */ e.jsx(
1307
- G,
1308
- {
1309
- type: "checkbox",
1310
- id: "noIndex",
1311
- name: "noIndex",
1312
- checked: n.noIndex,
1313
- onChange: v,
1314
- disabled: f,
1315
- className: "h-4 w-4"
1316
- }
1317
- ),
1318
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "noIndex", children: "No Index" })
1319
- ] }),
1320
- /* @__PURE__ */ e.jsx("p", { className: "mt-2 text-[10px] font-light text-gray-400", children: "Check this if you don't want search engines to index this page." })
1321
- ] }),
1322
- /* @__PURE__ */ e.jsxs("div", { className: "", children: [
1323
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-x-2", children: [
1324
- /* @__PURE__ */ e.jsx(
1325
- G,
1326
- {
1327
- type: "checkbox",
1328
- id: "noFollow",
1329
- name: "noFollow",
1330
- checked: n.noFollow,
1331
- onChange: v,
1332
- disabled: f,
1333
- className: "h-4 w-4"
1334
- }
1335
- ),
1336
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "noIndex", children: "No Follow" })
1337
- ] }),
1338
- /* @__PURE__ */ e.jsx("p", { className: "mt-2 text-[10px] font-light text-gray-400", children: "Check this if you don't want search engines to follow links on this page." })
1339
- ] })
1340
- ] }) })
1341
- ] }),
1342
- /* @__PURE__ */ e.jsxs(ge, { value: "og", children: [
1343
- /* @__PURE__ */ e.jsx(pe, { className: "text-blue-500", children: "OG" }),
1344
- /* @__PURE__ */ e.jsx(xe, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1345
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ e.jsx(
1346
- _,
1347
- {
1348
- type: "button",
1349
- variant: "outline",
1350
- size: "sm",
1351
- onClick: T,
1352
- children: "Copy from SEO Settings"
1353
- }
1354
- ) }),
1355
- /* @__PURE__ */ e.jsxs("div", { children: [
1356
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "ogTitle", children: "OG Title" }),
1357
- /* @__PURE__ */ e.jsx(
1358
- G,
1359
- {
1360
- type: "text",
1361
- id: "ogTitle",
1362
- name: "ogTitle",
1363
- value: n.ogTitle,
1364
- onChange: v,
1365
- disabled: f,
1366
- placeholder: "Enter OG title"
1367
- }
1368
- ),
1369
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "The OG title should be between 10 and 60 characters." })
1370
- ] }),
1371
- /* @__PURE__ */ e.jsxs("div", { className: "mt-4", children: [
1372
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "ogDescription", children: "OG Description" }),
1373
- /* @__PURE__ */ e.jsx(
1374
- ve,
1375
- {
1376
- id: "ogDescription",
1377
- name: "ogDescription",
1378
- value: n.ogDescription,
1379
- onChange: v,
1380
- disabled: f,
1381
- placeholder: "Enter OG description"
1382
- }
1383
- ),
1384
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "The OG description should be between 50 and 160 characters." })
1385
- ] }),
1386
- /* @__PURE__ */ e.jsxs("div", { className: "mt-4", children: [
1387
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "ogImage", children: "OG Image URL" }),
1388
- /* @__PURE__ */ e.jsx(
1389
- G,
1390
- {
1391
- type: "text",
1392
- id: "ogImage",
1393
- name: "ogImage",
1394
- value: n.ogImage,
1395
- onChange: v,
1396
- disabled: f,
1397
- placeholder: "Enter OG image URL"
1398
- }
1399
- ),
1400
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "Enter a valid URL for the OG image." })
1401
- ] })
1402
- ] }) })
1403
- ] }),
1404
- /* @__PURE__ */ e.jsxs(ge, { value: "search", children: [
1405
- /* @__PURE__ */ e.jsx(pe, { className: "text-blue-500", children: "Search" }),
1406
- /* @__PURE__ */ e.jsx(xe, { children: /* @__PURE__ */ e.jsxs("div", { className: "space-y-4", children: [
1407
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ e.jsx(
1408
- _,
1409
- {
1410
- type: "button",
1411
- variant: "outline",
1412
- size: "sm",
1413
- onClick: m,
1414
- children: "Copy from OG Settings"
1415
- }
1416
- ) }),
1417
- /* @__PURE__ */ e.jsxs("div", { children: [
1418
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "searchTitle", children: "Search Title" }),
1419
- /* @__PURE__ */ e.jsx(
1420
- G,
1421
- {
1422
- type: "text",
1423
- id: "searchTitle",
1424
- name: "searchTitle",
1425
- value: n.searchTitle,
1426
- onChange: v,
1427
- disabled: f,
1428
- placeholder: "Enter search title"
1429
- }
1430
- ),
1431
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "The search title should be between 10 and 60 characters." })
1432
- ] }),
1433
- /* @__PURE__ */ e.jsxs("div", { children: [
1434
- /* @__PURE__ */ e.jsx(R, { className: "text-xs pb-1", htmlFor: "searchDescription", children: "Search Description" }),
1435
- /* @__PURE__ */ e.jsx(
1436
- ve,
1437
- {
1438
- id: "searchDescription",
1439
- name: "searchDescription",
1440
- value: n.searchDescription,
1441
- onChange: v,
1442
- placeholder: "Enter search description"
1443
- }
1444
- ),
1445
- /* @__PURE__ */ e.jsx("p", { className: "mt-1 text-[10px] font-light text-gray-400", children: "The search description should be between 50 and 160 characters." })
1446
- ] })
1447
- ] }) })
1448
- ] }),
1449
- /* @__PURE__ */ e.jsxs(ge, { value: "jsonLD", children: [
1450
- /* @__PURE__ */ e.jsx(pe, { className: "text-blue-500", children: "JSON-LD" }),
1451
- /* @__PURE__ */ e.jsx(xe, { children: /* @__PURE__ */ e.jsx("div", { className: "space-y-4", children: /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
1452
- ve,
1453
- {
1454
- id: "jsonLD",
1455
- name: "jsonLD",
1456
- rows: 3,
1457
- value: n.jsonLD,
1458
- onChange: v,
1459
- placeholder: "Enter JSON-LD"
1460
- }
1461
- ) }) }) })
1462
- ] })
1463
- ] }) }),
1464
- /* @__PURE__ */ e.jsx("div", { className: "w-full flex items-center justify-end mt-4", children: /* @__PURE__ */ e.jsx(
1465
- _,
1466
- {
1467
- size: "lg",
1468
- variant: "default",
1469
- onClick: C,
1470
- disabled: Ge(d.current.initial, n) || f,
1471
- children: w ? "Saving..." : "Save"
1472
- }
1473
- ) })
1474
- ] });
1475
- };
1476
- Ft.displayName = "SeoPanel";
1477
- const Qa = ({
1478
- langProps: a,
1479
- onClose: i,
1480
- languages: l
1481
- }) => {
1482
- const { data: n } = _t(), [s, d] = A(a.name || ""), [c, p] = A(a.edit ? a.lang : ""), [h, b] = A(a.edit ? a.slug : ""), { mutate: w, isPending: f } = Rt(), { mutate: C, isPending: T } = Ye(), m = !!(n != null && n.global), v = f || T, F = () => {
1483
- const y = { name: s, lang: c, primaryPage: n == null ? void 0 : n.id, slug: h };
1484
- m || (y.global = !0), a.edit && (y.id = a == null ? void 0 : a.id), a.edit ? C(y, { onSuccess: i }) : w(y, { onSuccess: i });
1485
- };
1486
- return /* @__PURE__ */ e.jsx(be, { open: !!a, onOpenChange: i, children: /* @__PURE__ */ e.jsxs(ye, { className: "sm:max-w-[425px]", children: [
1487
- /* @__PURE__ */ e.jsxs(je, { children: [
1488
- /* @__PURE__ */ e.jsx(we, { children: a.edit ? "Edit language" : "Add New language" }),
1489
- /* @__PURE__ */ e.jsx(Ce, { children: "Enter the details for the language" })
1490
- ] }),
1491
- /* @__PURE__ */ e.jsxs("form", { children: [
1492
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4 py-4", children: [
1493
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1494
- /* @__PURE__ */ e.jsx(R, { htmlFor: "lang", className: "text-right", children: "Language" }),
1495
- /* @__PURE__ */ e.jsxs(
1496
- "select",
1497
- {
1498
- value: c,
1499
- disabled: a.edit || q(l),
1500
- onChange: (y) => {
1501
- const k = y.target.value;
1502
- p(k), !m && b(`/${k}`);
1503
- },
1504
- className: "flex h-9 w-full rounded-md border border-border bg-background px-3 py-1 text-sm shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 col-span-3",
1505
- children: [
1506
- /* @__PURE__ */ e.jsx("option", { value: "", disabled: !0, selected: !0, children: a.edit ? M(se, a.lang, a.lang) : q(l) ? "All available language page is created." : "Choose language" }),
1507
- We(l, (y) => /* @__PURE__ */ e.jsx("option", { value: y, children: M(se, y, y) }, y))
1508
- ]
1509
- }
1510
- )
1511
- ] }),
1512
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1513
- /* @__PURE__ */ e.jsx(R, { htmlFor: "slug", className: "text-right", children: "Page Name" }),
1514
- /* @__PURE__ */ e.jsx(
1515
- G,
1516
- {
1517
- id: "name",
1518
- value: s,
1519
- onChange: (y) => d(y.target.value),
1520
- className: "col-span-3",
1521
- required: !0,
1522
- placeholder: "Enter page name"
1523
- }
1524
- )
1525
- ] }),
1526
- !m && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1527
- /* @__PURE__ */ e.jsxs(R, { htmlFor: "slug", className: "text-right", children: [
1528
- "Slug",
1529
- " ",
1530
- /* @__PURE__ */ e.jsxs("small", { className: "font-light", children: [
1531
- "(Slug should start with /",
1532
- c,
1533
- ")"
1534
- ] })
1535
- ] }),
1536
- /* @__PURE__ */ e.jsx(
1537
- G,
1538
- {
1539
- id: "slug",
1540
- value: h,
1541
- onChange: (y) => {
1542
- const k = y.target.value;
1543
- xt(k, `/${c}`) && b(La(Ia(k)));
1544
- },
1545
- className: "col-span-3",
1546
- required: !0,
1547
- pattern: "^/.*",
1548
- disabled: q(c),
1549
- title: "Slug must start with /",
1550
- placeholder: q(c) ? "Choose language to add slug" : "Enter page slug"
1551
- }
1552
- )
1553
- ] })
1554
- ] }),
1555
- /* @__PURE__ */ e.jsx(Se, { children: /* @__PURE__ */ e.jsx(
1556
- _,
1557
- {
1558
- onClick: F,
1559
- type: "button",
1560
- disabled: v || !c || !m && !xt(h, `/${c}`),
1561
- children: v ? a.edit ? "Updating..." : "Adding..." : a.edit ? "Update" : "Add new language"
1562
- }
1563
- ) })
1564
- ] })
1565
- ] }) });
1566
- }, Xa = () => {
1567
- const [a, i] = A(null), { selectedLang: l, fallbackLang: n, setSelectedLang: s } = $e(), { data: d, isFetching: c } = Je(), { mutate: p, isPending: h } = Dt(), { data: b } = At(), { data: w } = Ot(), f = Ke(
1568
- M(w, "languages") || ["en"],
1569
- (C) => !ie(d, { lang: C }) && C !== M(w, "fallbackLang")
1570
- );
1571
- return /* @__PURE__ */ e.jsxs("div", { className: "space-y-4 pt-2", children: [
1572
- /* @__PURE__ */ e.jsx("ul", { className: "space-y-2 mt-4", children: c ? /* @__PURE__ */ e.jsxs("div", { className: "w-full space-y-3 py-4", children: [
1573
- /* @__PURE__ */ e.jsx("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" }),
1574
- /* @__PURE__ */ e.jsx("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" }),
1575
- /* @__PURE__ */ e.jsx("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" })
1576
- ] }) : We(d, (C) => {
1577
- const T = C.lang, m = C.slug, v = !C.primaryPage, F = T === l;
1578
- return v ? null : /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1579
- /* @__PURE__ */ e.jsxs(
1580
- "li",
1581
- {
1582
- className: `w-full p-2 rounded cursor-pointer flex items-center justify-between ${F ? "bg-gray-200" : "hover:bg-gray-100"}`,
1583
- onClick: () => s(T),
1584
- children: [
1585
- /* @__PURE__ */ e.jsxs("div", { className: " flex-1 gap-x-3", children: [
1586
- /* @__PURE__ */ e.jsx("div", { className: "text-[13px]", children: M(se, v ? n : T, T) }),
1587
- /* @__PURE__ */ e.jsxs("div", { children: [
1588
- /* @__PURE__ */ e.jsxs("div", { className: "text-[11px] text-gray-500", children: [
1589
- "Slug:",
1590
- /* @__PURE__ */ e.jsxs("b", { children: [
1591
- " ",
1592
- m
1593
- ] })
1594
- ] }),
1595
- /* @__PURE__ */ e.jsxs("div", { className: "text-[11px] text-gray-500", children: [
1596
- "Name:",
1597
- /* @__PURE__ */ e.jsxs("b", { children: [
1598
- " ",
1599
- C.name,
1600
- " "
1601
- ] })
1602
- ] })
1603
- ] })
1604
- ] }),
1605
- v ? /* @__PURE__ */ e.jsxs("div", { className: "flex items-center text-[11px] text-orange-500 gap-x-1", children: [
1606
- /* @__PURE__ */ e.jsx(Na, { fill: "orange", className: "w-3 h-3" }),
1607
- /* @__PURE__ */ e.jsx("b", { children: " Default" })
1608
- ] }) : /* @__PURE__ */ e.jsxs("div", { className: "flex items-center gap-x-3", children: [
1609
- /* @__PURE__ */ e.jsx(
1610
- kt,
1611
- {
1612
- onClick: (y) => {
1613
- y.stopPropagation(), i({ ...C, edit: !0 });
1614
- },
1615
- className: "w-3 h-3 hover:text-blue-500"
1616
- }
1617
- ),
1618
- /* @__PURE__ */ e.jsxs(ga, { children: [
1619
- /* @__PURE__ */ e.jsx(pa, { children: /* @__PURE__ */ e.jsx(Et, { className: "w-3 h-3 hover:text-red-500" }) }),
1620
- /* @__PURE__ */ e.jsx(xa, { children: /* @__PURE__ */ e.jsxs("div", { children: [
1621
- /* @__PURE__ */ e.jsxs("p", { className: "pb-2 text-sm", children: [
1622
- "Are you sure you want to remove",
1623
- " ",
1624
- /* @__PURE__ */ e.jsx("b", { children: M(se, T, T) }),
1625
- " language?"
1626
- ] }),
1627
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center justify-end w-full", children: /* @__PURE__ */ e.jsx(
1628
- _,
1629
- {
1630
- size: "sm",
1631
- variant: "destructive",
1632
- disabled: h,
1633
- onClick: () => p(C),
1634
- children: h ? "Deleting..." : "Delete"
1635
- }
1636
- ) })
1637
- ] }) })
1638
- ] })
1639
- ] })
1640
- ]
1641
- },
1642
- C.id
1643
- ),
1644
- /* @__PURE__ */ e.jsx("div", { className: "h-1 w-full border-b" })
1645
- ] });
1646
- }) }),
1647
- /* @__PURE__ */ e.jsx("div", { className: "flex justify-center w-full", children: /* @__PURE__ */ e.jsx(
1648
- _,
1649
- {
1650
- variant: "default",
1651
- size: "sm",
1652
- disabled: q(f),
1653
- onClick: () => i({
1654
- name: b == null ? void 0 : b.name,
1655
- lang: "",
1656
- slug: "",
1657
- edit: !1
1658
- }),
1659
- children: "+ Add new language"
1660
- }
1661
- ) }),
1662
- a && /* @__PURE__ */ e.jsx(
1663
- Qa,
1664
- {
1665
- languages: f,
1666
- langProps: a,
1667
- onClose: () => i(null)
1668
- }
1669
- )
1670
- ] });
1671
- };
1672
- function Za({
1673
- page: a,
1674
- onClose: i,
1675
- onDelete: l
1676
- }) {
1677
- const { mutate: n, isPending: s } = Dt(), d = () => {
1678
- n(a, {
1679
- onSuccess: () => {
1680
- l();
1681
- }
1682
- });
1683
- };
1684
- return /* @__PURE__ */ e.jsx(be, { open: !!a, onOpenChange: i, children: /* @__PURE__ */ e.jsxs(ye, { children: [
1685
- /* @__PURE__ */ e.jsxs(je, { children: [
1686
- /* @__PURE__ */ e.jsx(we, { children: "Confirm Deletion" }),
1687
- /* @__PURE__ */ e.jsxs(Ce, { children: [
1688
- "Are you sure you want to remove ",
1689
- /* @__PURE__ */ e.jsx("b", { children: (a == null ? void 0 : a.name) ?? (a == null ? void 0 : a.slug) }),
1690
- " ",
1691
- a != null && a.global ? "global block?" : "page? This will also delete all associated language pages."
1692
- ] })
1693
- ] }),
1694
- /* @__PURE__ */ e.jsxs(Se, { children: [
1695
- /* @__PURE__ */ e.jsx(_, { variant: "outline", onClick: i, children: "Cancel" }),
1696
- /* @__PURE__ */ e.jsx(_, { variant: "destructive", disabled: s, onClick: d, children: s ? "Deleting..." : "Delete" })
1697
- ] })
1698
- ] }) });
1699
- }
1700
- const en = ({
1701
- page: a,
1702
- onClose: i,
1703
- onUnpublish: l
1704
- }) => {
1705
- const { mutate: n, isPending: s } = Ha(), d = async () => {
1706
- n(a, {
1707
- onSuccess: () => {
1708
- l();
1709
- }
1710
- });
1711
- };
1712
- return /* @__PURE__ */ e.jsx(be, { open: !!a, onOpenChange: i, children: /* @__PURE__ */ e.jsxs(ye, { children: [
1713
- /* @__PURE__ */ e.jsxs(je, { children: [
1714
- /* @__PURE__ */ e.jsx(we, { children: "Confirm Unpublish" }),
1715
- /* @__PURE__ */ e.jsxs(Ce, { children: [
1716
- "Are you sure you want to unpublish ",
1717
- /* @__PURE__ */ e.jsx("b", { children: (a == null ? void 0 : a.name) ?? (a == null ? void 0 : a.slug) }),
1718
- "?"
1719
- ] })
1720
- ] }),
1721
- /* @__PURE__ */ e.jsxs(Se, { children: [
1722
- /* @__PURE__ */ e.jsx(_, { variant: "outline", onClick: i, children: "Cancel" }),
1723
- /* @__PURE__ */ e.jsx(
1724
- _,
1725
- {
1726
- variant: "destructive",
1727
- disabled: s,
1728
- onClick: d,
1729
- children: s ? "Unpublishing..." : "Unpublish"
1730
- }
1731
- )
1732
- ] })
1733
- ] }) });
1734
- }, tn = ({
1735
- activePage: a,
1736
- editPage: i,
1737
- onShowUpsertPage: l
1738
- }) => {
1739
- const [n, s] = A("pages"), { data: d, isFetching: c } = ze(), [p, h] = A(
1740
- null
1741
- ), [b, w] = A(null), f = (C) => Ua(
1742
- Ke(C, (m) => n === "pages" ? m.slug : !m.slug),
1743
- "name",
1744
- "asc"
1745
- ).map((m) => /* @__PURE__ */ e.jsxs(
1746
- _,
1747
- {
1748
- onClick: () => i(m.id),
1749
- variant: m.id === a ? "default" : "ghost",
1750
- className: "flex justify-between items-center w-full space-x-2 py-1",
1751
- children: [
1752
- /* @__PURE__ */ e.jsxs("div", { className: "flex items-center space-x-2", children: [
1753
- m.global ? /* @__PURE__ */ e.jsx(Nt, { className: "h-4 w-4" }) : /* @__PURE__ */ e.jsx(Tt, { className: "h-4 w-4" }),
1754
- /* @__PURE__ */ e.jsx("span", { children: m.name ?? m.slug }),
1755
- (m == null ? void 0 : m.slug) && /* @__PURE__ */ e.jsxs("span", { className: "text-xs font-light", children: [
1756
- "( ",
1757
- m.slug,
1758
- " )"
1759
- ] })
1760
- ] }),
1761
- /* @__PURE__ */ e.jsx("div", { className: "flex items-center space-x-4", children: /* @__PURE__ */ e.jsxs(wa, { children: [
1762
- /* @__PURE__ */ e.jsx(Ca, { asChild: !0, onClick: (v) => v.stopPropagation(), children: /* @__PURE__ */ e.jsx(
1763
- _,
1764
- {
1765
- variant: "ghost",
1766
- size: "sm",
1767
- className: `h-8 w-8 p-0 hover:bg-transparent ${m.id === a ? " hover:text-gray-200" : "bg-transparent "}`,
1768
- children: /* @__PURE__ */ e.jsx(Pa, { className: "h-4 w-4" })
1769
- }
1770
- ) }),
1771
- /* @__PURE__ */ e.jsxs(Sa, { align: "end", className: "text-sm font-medium", children: [
1772
- /* @__PURE__ */ e.jsxs(
1773
- Be,
1774
- {
1775
- className: "flex items-center gap-2",
1776
- onClick: (v) => {
1777
- v.stopPropagation(), l({ ...m, global: n === "globalBlocks" });
1778
- },
1779
- children: [
1780
- /* @__PURE__ */ e.jsx(kt, { className: "size-3", strokeWidth: 3 }),
1781
- "Edit"
1782
- ]
1783
- }
1784
- ),
1785
- /* @__PURE__ */ e.jsxs(
1786
- Be,
1787
- {
1788
- className: "flex items-center gap-2",
1789
- onClick: (v) => {
1790
- v.stopPropagation(), h(m);
1791
- },
1792
- children: [
1793
- /* @__PURE__ */ e.jsx(Et, { className: "size-3", strokeWidth: 3 }),
1794
- "Delete"
1795
- ]
1796
- }
1797
- ),
1798
- /* @__PURE__ */ e.jsxs(
1799
- Be,
1800
- {
1801
- className: "flex items-center gap-2",
1802
- onClick: (v) => {
1803
- v.stopPropagation(), w(m);
1804
- },
1805
- children: [
1806
- /* @__PURE__ */ e.jsx(_a, { className: "size-3", strokeWidth: 3 }),
1807
- "Unpublish"
1808
- ]
1809
- }
1810
- )
1811
- ] })
1812
- ] }) })
1813
- ]
1814
- },
1815
- m.id
1816
- ));
1817
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
1818
- /* @__PURE__ */ e.jsx("br", {}),
1819
- /* @__PURE__ */ e.jsxs(va, { value: n, className: "w-full", onValueChange: s, children: [
1820
- /* @__PURE__ */ e.jsxs(ba, { className: "w-full", children: [
1821
- /* @__PURE__ */ e.jsx(pt, { value: "pages", className: "w-full", children: /* @__PURE__ */ e.jsx("div", { className: "px-4", children: "Pages" }) }),
1822
- /* @__PURE__ */ e.jsx(pt, { value: "globalBlocks", className: "w-full", children: /* @__PURE__ */ e.jsx("div", { className: "px-4", children: "Global Blocks" }) })
1823
- ] }),
1824
- c ? /* @__PURE__ */ e.jsxs("div", { className: "w-full space-y-3 py-4", children: [
1825
- /* @__PURE__ */ e.jsx("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" }),
1826
- /* @__PURE__ */ e.jsx("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" }),
1827
- /* @__PURE__ */ e.jsx("div", { className: "w-full h-8 rounded bg-gray-300 animate-pulse" })
1828
- ] }) : /* @__PURE__ */ e.jsxs("div", { className: "py-4 space-y-3", children: [
1829
- /* @__PURE__ */ e.jsx(ya, { children: /* @__PURE__ */ e.jsxs(ja, { className: "text-xs text-muted-foreground text-center text-light", children: [
1830
- "Manage your ",
1831
- n === "pages" ? "pages" : "global blocks"
1832
- ] }) }),
1833
- /* @__PURE__ */ e.jsx("div", { className: "w-full flex justify-center", children: /* @__PURE__ */ e.jsxs(
1834
- _,
1835
- {
1836
- variant: "default",
1837
- size: "sm",
1838
- disabled: c,
1839
- onClick: () => l({
1840
- slug: "",
1841
- name: "",
1842
- global: n === "globalBlocks"
1843
- }),
1844
- className: "mb-4 w-1/2 bg-blue-500 hover:bg-blue-400",
1845
- children: [
1846
- /* @__PURE__ */ e.jsx(Ta, { className: "h-4 w-4 mr-2" }),
1847
- c ? "Loading..." : `Add new ${n === "pages" ? "page" : "global block"}`
1848
- ]
1849
- }
1850
- ) }),
1851
- /* @__PURE__ */ e.jsx("div", { className: "pt-4", children: /* @__PURE__ */ e.jsx("div", { className: "space-y-2", children: c ? /* @__PURE__ */ e.jsx(an, {}) : f(d) }) })
1852
- ] })
1853
- ] }),
1854
- /* @__PURE__ */ e.jsx(
1855
- Za,
1856
- {
1857
- page: p,
1858
- onClose: () => h(null),
1859
- onDelete: () => {
1860
- h(null);
1861
- }
1862
- }
1863
- ),
1864
- /* @__PURE__ */ e.jsx(
1865
- en,
1866
- {
1867
- page: b,
1868
- onClose: () => w(null),
1869
- onUnpublish: () => {
1870
- w(null);
1871
- }
1872
- }
1873
- )
1874
- ] });
1875
- };
1876
- function an() {
1877
- return /* @__PURE__ */ e.jsx("div", { className: "h-32 w-full flex justify-center items-center text-sm animate-pulse", children: "Loading..." });
1878
- }
1879
- const nn = ({
1880
- editPage: a,
1881
- showUpsertPage: i,
1882
- setShowUpsertPage: l
1883
- }) => {
1884
- const n = i.id, [s, d] = A(n && i.name || ""), [c, p] = A(n && i.slug || ""), { mutate: h, isPending: b } = Rt(), { mutate: w, isPending: f } = Ye(), C = b || f, T = () => {
1885
- n ? w(
1886
- {
1887
- name: s,
1888
- slug: c,
1889
- id: i.id,
1890
- global: !!i.global
1891
- },
1892
- {
1893
- onSuccess: () => {
1894
- l(void 0);
1895
- }
1896
- }
1897
- ) : h(
1898
- {
1899
- name: s,
1900
- slug: c,
1901
- global: !!i.global
1902
- },
1903
- {
1904
- onSuccess: (m) => {
1905
- a(m.id);
1906
- }
1907
- }
1908
- );
1909
- };
1910
- return /* @__PURE__ */ e.jsx(
1911
- be,
1912
- {
1913
- open: !!i,
1914
- onOpenChange: () => l(void 0),
1915
- children: /* @__PURE__ */ e.jsxs(ye, { className: "sm:max-w-[425px]", children: [
1916
- /* @__PURE__ */ e.jsxs(je, { children: [
1917
- /* @__PURE__ */ e.jsxs(we, { children: [
1918
- n ? "Edit" : "Add New",
1919
- " ",
1920
- i.global ? "Global Block" : "Page"
1921
- ] }),
1922
- /* @__PURE__ */ e.jsxs(Ce, { children: [
1923
- "Enter the details for the new",
1924
- " ",
1925
- i.global ? "global block. Identifier should be unique." : "page. Slug must start with /"
1926
- ] })
1927
- ] }),
1928
- /* @__PURE__ */ e.jsxs("form", { children: [
1929
- /* @__PURE__ */ e.jsxs("div", { className: "grid gap-4 py-4", children: [
1930
- /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1931
- /* @__PURE__ */ e.jsx(R, { htmlFor: "name", className: "text-right", children: "Name" }),
1932
- /* @__PURE__ */ e.jsx(
1933
- G,
1934
- {
1935
- id: "name",
1936
- value: s,
1937
- placeholder: `Enter ${i.global ? "global block" : "page"} name`,
1938
- onChange: (m) => d(m.target.value),
1939
- className: "col-span-3",
1940
- required: !0
1941
- }
1942
- )
1943
- ] }),
1944
- !i.global && /* @__PURE__ */ e.jsxs("div", { className: "space-y-1", children: [
1945
- /* @__PURE__ */ e.jsx(R, { htmlFor: "slug", className: "text-right", children: i.global ? "Identifier" : "Slug" }),
1946
- /* @__PURE__ */ e.jsx(
1947
- G,
1948
- {
1949
- id: "slug",
1950
- value: c,
1951
- onChange: (m) => {
1952
- var v;
1953
- return p((v = m.target.value) == null ? void 0 : v.trim().toLowerCase());
1954
- },
1955
- className: "col-span-3",
1956
- required: !0,
1957
- pattern: "^/.*",
1958
- title: "Slug must start with /",
1959
- placeholder: "Enter page slug"
1960
- }
1961
- )
1962
- ] })
1963
- ] }),
1964
- /* @__PURE__ */ e.jsx(Se, { children: /* @__PURE__ */ e.jsx(
1965
- _,
1966
- {
1967
- onClick: T,
1968
- type: "button",
1969
- disabled: C || !s || !i.global && !c.startsWith("/") || Ge(i.name, s) && Ge(i.slug, c),
1970
- children: C ? n ? "Updating..." : "Adding..." : i.global ? `${n ? "Update" : "Add"} global block` : `${n ? "Update" : "Add"} Page`
1971
- }
1972
- ) })
1973
- ] })
1974
- ] })
1975
- }
1976
- );
1977
- };
1978
- function sn(a) {
1979
- const { activePage: i, canClose: l, open: n, close: s } = a, [, d] = le(), [c, p] = A(), h = (b) => {
1980
- window.history.pushState({}, "", `?page=${b}`), d(new URLSearchParams({ page: b })), window.dispatchEvent(new PopStateEvent("popstate")), p(void 0), s();
1981
- };
1982
- return /* @__PURE__ */ e.jsx(
1983
- ka,
1984
- {
1985
- open: n,
1986
- onOpenChange: (b) => {
1987
- !b && l && s();
1988
- },
1989
- children: /* @__PURE__ */ e.jsxs(
1990
- Ea,
1991
- {
1992
- side: "left",
1993
- className: `border-border w-full ${l ? "" : "sheet-hide-close-btn"}`,
1994
- children: [
1995
- /* @__PURE__ */ e.jsx("div", { children: /* @__PURE__ */ e.jsx(
1996
- tn,
1997
- {
1998
- onShowUpsertPage: (b) => p(b),
1999
- activePage: i,
2000
- editPage: h
2001
- }
2002
- ) }),
2003
- c && /* @__PURE__ */ e.jsx(
2004
- nn,
2005
- {
2006
- editPage: h,
2007
- showUpsertPage: c,
2008
- setShowUpsertPage: p
2009
- }
2010
- )
2011
- ]
2012
- }
2013
- )
2014
- }
2015
- );
2016
- }
2017
- ca();
2018
- const rn = (a) => {
2019
- const i = St([]), [l] = le(), n = l.get("page"), { data: s, isFetching: d } = _t(), { data: c } = Ka(), { data: p, isFetching: h } = Wa(), { blocks: b, theme: w } = Va(p), { data: f } = Ot(), { data: C } = Je(), T = qa(), { uploadFile: m } = Ja(), { getUILibraryBlock: v, getUILibraryBlocks: F, onSave: y } = $a(), { getGlobalBlocks: k, getGlobalBlockBlocks: ke } = za(), { mutate: Ee, isPending: oe } = Ya(), { aiContext: Q, setAiContext: Ne } = Ve();
2020
- i.current = b;
2021
- const [Te, X] = A(!1), [K, Pe] = A("SAVED");
2022
- qe(() => {
2023
- const E = (U) => {
2024
- K === "UNSAVED" && (U.preventDefault(), U.returnValue = !1);
2025
- };
2026
- return K === "UNSAVED" && window.addEventListener("beforeunload", E), () => {
2027
- window.removeEventListener("beforeunload", E);
2028
- };
2029
- }, [K]);
2030
- const ce = ne(() => {
2031
- const E = {};
2032
- return f != null && f.theme && (E.brandingOptions = f.theme), E;
2033
- }, [f]), I = ne(() => Array.isArray(a == null ? void 0 : a.uiLibraries) ? [...c, ...a == null ? void 0 : a.uiLibraries] : c, [c, a == null ? void 0 : a.uiLibraries]);
2034
- return /* @__PURE__ */ e.jsxs(e.Fragment, { children: [
2035
- /* @__PURE__ */ e.jsx(
2036
- da,
2037
- {
2038
- loading: h,
2039
- ...a.fallbackLang && {
2040
- fallbackLang: a.fallbackLang || "en"
2041
- },
2042
- ...a.languages && {
2043
- languages: We(C, "lang") || []
2044
- },
2045
- translations: a.translations || {},
2046
- locale: a.locale || "en",
2047
- htmlDir: a.htmlDir || "ltr",
2048
- autoSaveSupport: a.autoSaveSupport || !1,
2049
- autoSaveInterval: a.autoSaveInterval || 15,
2050
- uploadMediaCallback: m,
2051
- onError: a.onError || console.error,
2052
- getGlobalBlockBlocks: ke,
2053
- getGlobalBlocks: k,
2054
- blocks: b,
2055
- getUILibraryBlock: v,
2056
- getUILibraryBlocks: F,
2057
- brandingOptions: w,
2058
- uiLibraries: I,
2059
- saveAiContextCallback: async (E) => {
2060
- if (!n) return !0;
2061
- const U = i.current, W = {
2062
- _type: "@chai/ai-context",
2063
- _value: vt(E) ? E : ""
2064
- }, ue = [...U, W];
2065
- return await y({ page: n, blocks: ue }), Ne(E), !0;
2066
- },
2067
- onSaveStateChange: (E) => Pe(E),
2068
- aiContext: Q,
2069
- askAiCallBack: T,
2070
- onSave: async ({ blocks: E }) => {
2071
- if (!n) return !0;
2072
- i.current = E;
2073
- const U = {
2074
- _type: "@chai/ai-context",
2075
- _value: vt(Q) ? Q : ""
2076
- }, W = [...E, U];
2077
- return await y({ page: n, blocks: W }), i.current = E, !0;
2078
- },
2079
- topBarComponents: {
2080
- left: [
2081
- () => /* @__PURE__ */ e.jsxs(
2082
- _,
2083
- {
2084
- variant: "default",
2085
- className: "flex justify-start max-w-[250px] items-center w-full space-x-2 py-1",
2086
- onClick: () => X(!0),
2087
- children: [
2088
- Pt(s.slug, "/") ? /* @__PURE__ */ e.jsx(Tt, { className: "h-4 w-4" }) : /* @__PURE__ */ e.jsx(Nt, { className: "h-4 w-4" }),
2089
- /* @__PURE__ */ e.jsx("span", { className: "truncate", children: (s == null ? void 0 : s.name) ?? "" }),
2090
- /* @__PURE__ */ e.jsx(Oa, { className: "h-4 w-4" })
2091
- ]
2092
- },
2093
- "template-viewer"
2094
- )
2095
- ],
2096
- right: [
2097
- () => /* @__PURE__ */ e.jsxs(
2098
- _,
2099
- {
2100
- disabled: oe || K !== "SAVED",
2101
- size: "sm",
2102
- variant: "default",
2103
- onClick: () => Ee(n),
2104
- children: [
2105
- /* @__PURE__ */ e.jsx(Ra, { className: "h-4 w-4" }),
2106
- "  ",
2107
- " ",
2108
- oe ? "Publishing..." : "Publish"
2109
- ]
2110
- }
2111
- )
2112
- ]
2113
- },
2114
- sideBarComponents: {
2115
- top: [
2116
- ...s != null && s.global ? [] : [
2117
- {
2118
- label: "SEO Setting",
2119
- component: Ft,
2120
- icon: /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsxs(
2121
- "svg",
2122
- {
2123
- xmlns: "http://www.w3.org/2000/svg",
2124
- viewBox: "0 0 21 21",
2125
- fill: "currentColor",
2126
- width: "21",
2127
- height: "21",
2128
- children: [
2129
- /* @__PURE__ */ e.jsx("path", { d: "M9.931 6.818c-1.238 0-2.136.925-2.136 2.2 0 1.279.898 2.207 2.136 2.207.664 0 1.257-.246 1.67-.694a.15.15 0 0 0-.009-.213l-.311-.286a.15.15 0 0 0-.213.009c-.273.297-.677.46-1.137.46-.699 0-1.233-.444-1.375-1.12h3.295a.15.15 0 0 0 .151-.151v-.211c0-1.295-.852-2.2-2.072-2.2m0 .724c.697 0 1.188.422 1.315 1.113h-2.69c.142-.673.676-1.113 1.374-1.113m4.332-.724c-1.246 0-2.15.925-2.15 2.2 0 1.279.904 2.207 2.15 2.207.596 0 1.143-.223 1.538-.628s.612-.965.612-1.579c0-1.275-.904-2.2-2.15-2.2m0 3.683c-.826 0-1.426-.624-1.426-1.483 0-.855.6-1.475 1.426-1.475s1.426.621 1.426 1.476c0 .423-.144.804-.406 1.073-.258.264-.62.41-1.019.41M6.318 8.71c-.665-.206-.902-.335-.902-.645 0-.47.564-.521.806-.521.29 0 .552.07.801.215a.15.15 0 0 0 .206-.055l.212-.366a.15.15 0 0 0-.055-.206 2.27 2.27 0 0 0-1.165-.312c-.915 0-1.53.501-1.53 1.245 0 .899.816 1.152 1.411 1.336.655.203.812.307.804.53-.016.398-.567.429-.735.429-.386 0-.722-.129-.972-.374q-.043-.042-.107-.043a.15.15 0 0 0-.106.045l-.295.302a.15.15 0 0 0 .002.213c.383.374.908.58 1.478.58.859 0 1.432-.441 1.459-1.125.031-.833-.746-1.074-1.313-1.249" }),
2130
- /* @__PURE__ */ e.jsx("path", { d: "M20.396 2.049H.604A.604.604 0 0 0 0 2.653v12.7c0 .333.27.604.604.604h6.941c-.266 1.296-.881 1.966-.886 1.971a.604.604 0 0 0 .434 1.024h6.815a.604.604 0 0 0 .434-1.024c-.007-.007-.621-.675-.886-1.971h6.941c.333 0 .604-.27.604-.604V2.652a.604.604 0 0 0-.604-.604m-.604 12.701h-.985v-.17a.604.604 0 0 0-1.208 0v.17h-.63v-.17a.604.604 0 0 0-1.208 0v.17H1.207V3.256h18.585z" })
2131
- ]
2132
- }
2133
- ) })
2134
- }
2135
- ],
2136
- ...(f == null ? void 0 : f.languages.length) > 0 ? [
2137
- {
2138
- label: "Language Pages",
2139
- component: Xa,
2140
- icon: /* @__PURE__ */ e.jsx(e.Fragment, { children: /* @__PURE__ */ e.jsx(
2141
- "svg",
2142
- {
2143
- width: "21",
2144
- height: "21",
2145
- viewBox: "0 0 21 21",
2146
- fill: "currentColor",
2147
- children: /* @__PURE__ */ e.jsxs(
2148
- "g",
2149
- {
2150
- fill: "none",
2151
- "fill-rule": "evenodd",
2152
- stroke: "currentColor",
2153
- "stroke-linecap": "round",
2154
- "stroke-linejoin": "round",
2155
- children: [
2156
- /* @__PURE__ */ e.jsx("path", { d: "M18.5 10.5v-6a2 2 0 0 0-2-2h-6a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2" }),
2157
- /* @__PURE__ */ e.jsx("path", { d: "M6.5 8.503h-2a2 2 0 0 0-2 2v6a2 2 0 0 0 2 2h.003l6-.01a2 2 0 0 0 1.997-2V14.5" }),
2158
- /* @__PURE__ */ e.jsx("path", { d: "M7.5 12.503h-3M9 14l-1 1q-.5.5-2.5 1.5" }),
2159
- /* @__PURE__ */ e.jsx("path", { d: "M5.5 12.503q.501 1.75 1.5 2.499c1 .749 1.5.999 2.5 1.498m4-12-3 6m3-6 3 6m-1-2h-4" })
2160
- ]
2161
- }
2162
- )
2163
- }
2164
- ) })
2165
- }
2166
- ] : []
2167
- ]
2168
- },
2169
- ...ce
2170
- }
2171
- ),
2172
- /* @__PURE__ */ e.jsx(
2173
- sn,
2174
- {
2175
- activePage: n || "",
2176
- canClose: !!n && !q(s),
2177
- open: !n || !d && q(s) || Te,
2178
- close: () => X(!1)
2179
- }
2180
- )
2181
- ] });
2182
- }, jt = new ha({
2183
- defaultOptions: { queries: { refetchOnWindowFocus: !1 } }
2184
- }), mn = (a) => (jt.setQueryData(["builder_props"], a), /* @__PURE__ */ e.jsx(fa, { client: jt, children: /* @__PURE__ */ e.jsx(rn, { ...a }) }));
1
+ import "react/jsx-runtime";
2
+ import "@chaibuilder/sdk";
3
+ import { W as d } from "./ChaiBuilderPages-DYaYUYo3.js";
4
+ import "@chaibuilder/sdk/web-blocks";
5
+ import "@tanstack/react-query";
6
+ import "lodash-es";
7
+ import "lucide-react";
8
+ import "react";
2185
9
  export {
2186
- mn as default
10
+ d as default
2187
11
  };