@chaibuilder/sdk 2.0.1 → 2.0.2

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/core.js CHANGED
@@ -9,7 +9,7 @@ import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, g
9
9
  import { find, filter, flatten, map, omit, isString, has, isObject, memoize, get, compact, isEmpty, noop, includes, without, each, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, findIndex, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
- import { useTranslation as He } from "react-i18next";
12
+ import { useTranslation as Ve } from "react-i18next";
13
13
  import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./Functions-BGzDsf1z.js";
14
14
  import { flip } from "@floating-ui/dom";
15
15
  import { useFloating, shift } from "@floating-ui/react-dom";
@@ -17,7 +17,7 @@ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, Plus
17
17
  import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
18
18
  import { useFeature, FlagsProvider } from "flagged";
19
19
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
20
- import { registerChaiBlock as Ue } from "@chaibuilder/runtime";
20
+ import { registerChaiBlock as Fe } from "@chaibuilder/runtime";
21
21
  import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
22
22
  import TreeModel from "tree-model";
23
23
  import { useHotkeys } from "react-hotkeys-hook";
@@ -36,6 +36,7 @@ import { ErrorBoundary } from "react-error-boundary";
36
36
  import { Resizable } from "re-resizable";
37
37
  import RjForm from "@rjsf/core";
38
38
  import validator from "@rjsf/validator-ajv8";
39
+ import { isEmpty as isEmpty$1, get as get$1 } from "lodash";
39
40
  import Link from "@tiptap/extension-link";
40
41
  import TextAlign from "@tiptap/extension-text-align";
41
42
  import Underline from "@tiptap/extension-underline";
@@ -45,7 +46,7 @@ import Fuse from "fuse.js";
45
46
  import { parse, stringify } from "himalaya";
46
47
  import { Tree } from "react-arborist";
47
48
  import i18n from "i18next";
48
- import { default as ze } from "i18next";
49
+ import { default as We } from "i18next";
49
50
  import { motion } from "framer-motion";
50
51
  const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
51
52
  if ("e" in o)
@@ -93,53 +94,53 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
93
94
  for (const i of n.p)
94
95
  l.add(i);
95
96
  return l;
96
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
97
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
97
98
  var x;
98
- return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
99
- }, g = (m, f) => {
99
+ return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
100
+ }, g = (h, f) => {
100
101
  var x;
101
- return (x = m.onMount) == null ? void 0 : x.call(m, f);
102
- }, ...h) => {
103
- const m = h[0] || ((C) => {
102
+ return (x = h.onMount) == null ? void 0 : x.call(h, f);
103
+ }, ...m) => {
104
+ const h = m[0] || ((C) => {
104
105
  let L = o.get(C);
105
106
  return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, L), u == null || u(C, S)), L;
106
- }), f = h[1] || (() => {
107
+ }), f = m[1] || (() => {
107
108
  let C, L;
108
109
  const v = (k) => {
109
110
  try {
110
111
  k();
111
- } catch (B) {
112
- C || (C = !0, L = B);
112
+ } catch (A) {
113
+ C || (C = !0, L = A);
113
114
  }
114
115
  };
115
116
  do {
116
117
  c.f && v(c.f);
117
- const k = /* @__PURE__ */ new Set(), B = k.add.bind(k);
118
+ const k = /* @__PURE__ */ new Set(), A = k.add.bind(k);
118
119
  a.forEach((T) => {
119
120
  var I;
120
- return (I = n.get(T)) == null ? void 0 : I.l.forEach(B);
121
- }), a.clear(), i.forEach(B), i.clear(), l.forEach(B), l.clear(), k.forEach(v), a.size && x();
121
+ return (I = n.get(T)) == null ? void 0 : I.l.forEach(A);
122
+ }), a.clear(), i.forEach(A), i.clear(), l.forEach(A), l.clear(), k.forEach(v), a.size && x();
122
123
  } while (a.size || i.size || l.size);
123
124
  if (C)
124
125
  throw L;
125
- }), x = h[2] || (() => {
126
+ }), x = m[2] || (() => {
126
127
  const C = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
127
128
  for (; k.length; ) {
128
- const B = k[k.length - 1], T = m(B);
129
- if (v.has(B)) {
129
+ const A = k[k.length - 1], T = h(A);
130
+ if (v.has(A)) {
130
131
  k.pop();
131
132
  continue;
132
133
  }
133
- if (L.has(B)) {
134
- r.get(B) === T.n && C.push([B, T]), v.add(B), k.pop();
134
+ if (L.has(A)) {
135
+ r.get(A) === T.n && C.push([A, T]), v.add(A), k.pop();
135
136
  continue;
136
137
  }
137
- L.add(B);
138
- for (const I of getMountedOrPendingDependents(B, T, n))
138
+ L.add(A);
139
+ for (const I of getMountedOrPendingDependents(A, T, n))
139
140
  L.has(I) || k.push(I);
140
141
  }
141
- for (let B = C.length - 1; B >= 0; --B) {
142
- const [T, I] = C[B];
142
+ for (let A = C.length - 1; A >= 0; --A) {
143
+ const [T, I] = C[A];
143
144
  let P = !1;
144
145
  for (const N of I.d.keys())
145
146
  if (N !== T && a.has(N)) {
@@ -148,9 +149,9 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
148
149
  }
149
150
  P && (b(T), E(T)), r.delete(T);
150
151
  }
151
- }), b = h[3] || ((C) => {
152
+ }), b = m[3] || ((C) => {
152
153
  var L, v;
153
- const k = m(C);
154
+ const k = h(C);
154
155
  if (isAtomStateInitialized(k) && (n.has(C) && r.get(C) !== k.n || Array.from(k.d).every(
155
156
  ([R, O]) => (
156
157
  // Recursively, read the atom state of the dependency, and
@@ -160,25 +161,25 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
160
161
  )))
161
162
  return k;
162
163
  k.d.clear();
163
- let B = !0;
164
+ let A = !0;
164
165
  const T = () => {
165
166
  n.has(C) && (E(C), x(), f());
166
167
  }, I = (R) => {
167
168
  var O;
168
169
  if (isSelfAtom(C, R)) {
169
- const H = m(R);
170
+ const H = h(R);
170
171
  if (!isAtomStateInitialized(H))
171
172
  if (hasInitialValue(R))
172
- setAtomStateValueOrPromise(R, R.init, m);
173
+ setAtomStateValueOrPromise(R, R.init, h);
173
174
  else
174
175
  throw new Error("no atom init");
175
176
  return returnAtomValue(H);
176
177
  }
177
- const $ = b(R);
178
+ const M = b(R);
178
179
  try {
179
- return returnAtomValue($);
180
+ return returnAtomValue(M);
180
181
  } finally {
181
- k.d.set(R, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, $), (O = n.get(R)) == null || O.t.add(C), B || T();
182
+ k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(C, k.v, M), (O = n.get(R)) == null || O.t.add(C), A || T();
182
183
  }
183
184
  };
184
185
  let P, N;
@@ -188,92 +189,92 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
188
189
  },
189
190
  get setSelf() {
190
191
  return !N && isActuallyWritableAtom(C) && (N = (...R) => {
191
- if (!B)
192
+ if (!A)
192
193
  try {
193
- return A(C, ...R);
194
+ return B(C, ...R);
194
195
  } finally {
195
196
  x(), f();
196
197
  }
197
198
  }), N;
198
199
  }
199
- }, M = k.n;
200
+ }, $ = k.n;
200
201
  try {
201
202
  const R = d(C, I, D);
202
- return setAtomStateValueOrPromise(C, R, m), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
203
+ return setAtomStateValueOrPromise(C, R, h), isPromiseLike$2(R) && ((L = R.onCancel) == null || L.call(R, () => P == null ? void 0 : P.abort()), R.then(
203
204
  T,
204
205
  T
205
206
  )), k;
206
207
  } catch (R) {
207
208
  return delete k.v, k.e = R, ++k.n, k;
208
209
  } finally {
209
- B = !1, M !== k.n && r.get(C) === M && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
210
+ A = !1, $ !== k.n && r.get(C) === $ && (r.set(C, k.n), a.add(C), (v = c.c) == null || v.call(c, C));
210
211
  }
211
- }), y = h[4] || ((C) => {
212
+ }), y = m[4] || ((C) => {
212
213
  const L = [C];
213
214
  for (; L.length; ) {
214
- const v = L.pop(), k = m(v);
215
- for (const B of getMountedOrPendingDependents(v, k, n)) {
216
- const T = m(B);
217
- r.set(B, T.n), L.push(B);
215
+ const v = L.pop(), k = h(v);
216
+ for (const A of getMountedOrPendingDependents(v, k, n)) {
217
+ const T = h(A);
218
+ r.set(A, T.n), L.push(A);
218
219
  }
219
220
  }
220
- }), A = h[5] || ((C, ...L) => {
221
+ }), B = m[5] || ((C, ...L) => {
221
222
  let v = !0;
222
- const k = (T) => returnAtomValue(b(T)), B = (T, ...I) => {
223
+ const k = (T) => returnAtomValue(b(T)), A = (T, ...I) => {
223
224
  var P;
224
- const N = m(T);
225
+ const N = h(T);
225
226
  try {
226
227
  if (isSelfAtom(C, T)) {
227
228
  if (!hasInitialValue(T))
228
229
  throw new Error("atom not writable");
229
- const D = N.n, M = I[0];
230
- setAtomStateValueOrPromise(T, M, m), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), y(T));
230
+ const D = N.n, $ = I[0];
231
+ setAtomStateValueOrPromise(T, $, h), E(T), D !== N.n && (a.add(T), (P = c.c) == null || P.call(c, T), y(T));
231
232
  return;
232
233
  } else
233
- return A(T, ...I);
234
+ return B(T, ...I);
234
235
  } finally {
235
236
  v || (x(), f());
236
237
  }
237
238
  };
238
239
  try {
239
- return p(C, k, B, ...L);
240
+ return p(C, k, A, ...L);
240
241
  } finally {
241
242
  v = !1;
242
243
  }
243
- }), E = h[6] || ((C) => {
244
+ }), E = m[6] || ((C) => {
244
245
  var L;
245
- const v = m(C), k = n.get(C);
246
+ const v = h(C), k = n.get(C);
246
247
  if (k && !isPendingPromise(v.v)) {
247
- for (const [B, T] of v.d)
248
- if (!k.d.has(B)) {
249
- const I = m(B);
250
- w(B).t.add(C), k.d.add(B), T !== I.n && (a.add(B), (L = c.c) == null || L.call(c, B), y(B));
248
+ for (const [A, T] of v.d)
249
+ if (!k.d.has(A)) {
250
+ const I = h(A);
251
+ w(A).t.add(C), k.d.add(A), T !== I.n && (a.add(A), (L = c.c) == null || L.call(c, A), y(A));
251
252
  }
252
- for (const B of k.d || [])
253
- if (!v.d.has(B)) {
254
- k.d.delete(B);
255
- const T = _(B);
253
+ for (const A of k.d || [])
254
+ if (!v.d.has(A)) {
255
+ k.d.delete(A);
256
+ const T = _(A);
256
257
  T == null || T.t.delete(C);
257
258
  }
258
259
  }
259
- }), w = h[7] || ((C) => {
260
+ }), w = m[7] || ((C) => {
260
261
  var L;
261
- const v = m(C);
262
+ const v = h(C);
262
263
  let k = n.get(C);
263
264
  if (!k) {
264
265
  b(C);
265
- for (const B of v.d.keys())
266
- w(B).t.add(C);
266
+ for (const A of v.d.keys())
267
+ w(A).t.add(C);
267
268
  if (k = {
268
269
  l: /* @__PURE__ */ new Set(),
269
270
  d: new Set(v.d.keys()),
270
271
  t: /* @__PURE__ */ new Set()
271
272
  }, n.set(C, k), (L = c.m) == null || L.call(c, C), isActuallyWritableAtom(C)) {
272
- const B = () => {
273
+ const A = () => {
273
274
  let T = !0;
274
275
  const I = (...P) => {
275
276
  try {
276
- return A(C, ...P);
277
+ return B(C, ...P);
277
278
  } finally {
278
279
  T || (x(), f());
279
280
  }
@@ -292,21 +293,21 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
292
293
  T = !1;
293
294
  }
294
295
  };
295
- l.add(B);
296
+ l.add(A);
296
297
  }
297
298
  }
298
299
  return k;
299
- }), _ = h[8] || ((C) => {
300
+ }), _ = m[8] || ((C) => {
300
301
  var L;
301
- const v = m(C);
302
+ const v = h(C);
302
303
  let k = n.get(C);
303
- if (k && !k.l.size && !Array.from(k.t).some((B) => {
304
+ if (k && !k.l.size && !Array.from(k.t).some((A) => {
304
305
  var T;
305
- return (T = n.get(B)) == null ? void 0 : T.d.has(C);
306
+ return (T = n.get(A)) == null ? void 0 : T.d.has(C);
306
307
  })) {
307
308
  k.u && i.add(k.u), k = void 0, n.delete(C), (L = c.u) == null || L.call(c, C);
308
- for (const B of v.d.keys()) {
309
- const T = _(B);
309
+ for (const A of v.d.keys()) {
310
+ const T = _(A);
310
311
  T == null || T.t.delete(C);
311
312
  }
312
313
  return;
@@ -327,12 +328,12 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
327
328
  u,
328
329
  g,
329
330
  // building-block functions
330
- m,
331
+ h,
331
332
  f,
332
333
  x,
333
334
  b,
334
335
  y,
335
- A,
336
+ B,
336
337
  E,
337
338
  w,
338
339
  _
@@ -340,7 +341,7 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
340
341
  get: (C) => returnAtomValue(b(C)),
341
342
  set: (C, ...L) => {
342
343
  try {
343
- return A(C, ...L);
344
+ return B(C, ...L);
344
345
  } finally {
345
346
  x(), f();
346
347
  }
@@ -387,10 +388,10 @@ function splitAtom(o, n) {
387
388
  let p = r.get(c);
388
389
  if (p)
389
390
  return p;
390
- const u = d && r.get(d), g = [], h = [];
391
- return c.forEach((m, f) => {
391
+ const u = d && r.get(d), g = [], m = [];
392
+ return c.forEach((h, f) => {
392
393
  const x = f;
393
- h[f] = x;
394
+ m[f] = x;
394
395
  const b = u && u.atomList[u.keyList.indexOf(x)];
395
396
  if (b) {
396
397
  g[f] = b;
@@ -405,7 +406,7 @@ function splitAtom(o, n) {
405
406
  throw new Error("splitAtom: index out of bounds for read");
406
407
  }
407
408
  return _[S];
408
- }, A = (E, w, _) => {
409
+ }, B = (E, w, _) => {
409
410
  const j = E(l), S = E(o), L = a(S, j == null ? void 0 : j.arr).keyList.indexOf(x);
410
411
  if (L < 0 || L >= S.length)
411
412
  throw new Error("splitAtom: index out of bounds for write");
@@ -416,8 +417,8 @@ function splitAtom(o, n) {
416
417
  ...S.slice(L + 1)
417
418
  ]);
418
419
  };
419
- g[f] = isWritable(o) ? atom(y, A) : atom(y);
420
- }), u && u.keyList.length === h.length && u.keyList.every((m, f) => m === h[f]) ? p = u : p = { arr: c, atomList: g, keyList: h }, r.set(c, p), p;
420
+ g[f] = isWritable(o) ? atom(y, B) : atom(y);
421
+ }), u && u.keyList.length === m.length && u.keyList.every((h, f) => h === m[f]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
421
422
  }, l = atom((c) => {
422
423
  const d = c(l), p = c(o);
423
424
  return a(p, d == null ? void 0 : d.arr);
@@ -453,17 +454,17 @@ function splitAtom(o, n) {
453
454
  case "move": {
454
455
  const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
455
456
  if (u >= 0 && g >= 0) {
456
- const h = c(o);
457
+ const m = c(o);
457
458
  u < g ? d(o, [
458
- ...h.slice(0, u),
459
- ...h.slice(u + 1, g),
460
- h[u],
461
- ...h.slice(g)
459
+ ...m.slice(0, u),
460
+ ...m.slice(u + 1, g),
461
+ m[u],
462
+ ...m.slice(g)
462
463
  ]) : d(o, [
463
- ...h.slice(0, g),
464
- h[u],
465
- ...h.slice(g, u),
466
- ...h.slice(u + 1)
464
+ ...m.slice(0, g),
465
+ m[u],
466
+ ...m.slice(g, u),
467
+ ...m.slice(u + 1)
467
468
  ]);
468
469
  }
469
470
  break;
@@ -489,8 +490,8 @@ function createJSONStorage(o = () => {
489
490
  let a, l;
490
491
  const i = {
491
492
  getItem: (p, u) => {
492
- var g, h;
493
- const m = (x) => {
493
+ var g, m;
494
+ const h = (x) => {
494
495
  if (x = x || "", a !== x) {
495
496
  try {
496
497
  l = JSON.parse(x, n == null ? void 0 : n.reviver);
@@ -500,8 +501,8 @@ function createJSONStorage(o = () => {
500
501
  a = x;
501
502
  }
502
503
  return l;
503
- }, f = (h = (g = o()) == null ? void 0 : g.getItem(p)) != null ? h : null;
504
- return isPromiseLike$1(f) ? f.then(m) : m(f);
504
+ }, f = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
+ return isPromiseLike$1(f) ? f.then(h) : h(f);
505
506
  },
506
507
  setItem: (p, u) => {
507
508
  var g;
@@ -514,12 +515,12 @@ function createJSONStorage(o = () => {
514
515
  var u;
515
516
  return (u = o()) == null ? void 0 : u.removeItem(p);
516
517
  }
517
- }, c = (p) => (u, g, h) => p(u, (m) => {
518
+ }, c = (p) => (u, g, m) => p(u, (h) => {
518
519
  let f;
519
520
  try {
520
- f = JSON.parse(m || "");
521
+ f = JSON.parse(h || "");
521
522
  } catch {
522
- f = h;
523
+ f = m;
523
524
  }
524
525
  g(f);
525
526
  });
@@ -532,8 +533,8 @@ function createJSONStorage(o = () => {
532
533
  if (!(o() instanceof window.Storage))
533
534
  return () => {
534
535
  };
535
- const g = (h) => {
536
- h.storageArea === o() && h.key === p && u(h.newValue);
536
+ const g = (m) => {
537
+ m.storageArea === o() && m.key === p && u(m.newValue);
537
538
  };
538
539
  return window.addEventListener("storage", g), () => {
539
540
  window.removeEventListener("storage", g);
@@ -1147,22 +1148,22 @@ const useSelectedBlocksDisplayChild = () => ({
1147
1148
  }, removeNestedBlocks = (o, n) => {
1148
1149
  let r = [...o], a = [];
1149
1150
  n.forEach((d) => {
1150
- const p = r.find((h) => h._id === d);
1151
+ const p = r.find((m) => m._id === d);
1151
1152
  if (!p || !p._parent) return;
1152
- const u = p._parent, g = r.filter((h) => h._parent === u);
1153
+ const u = p._parent, g = r.filter((m) => m._parent === u);
1153
1154
  if (g.length === 2) {
1154
- const h = g.find((m) => m._id !== d);
1155
- if (h && h._type === "Text") {
1156
- const m = r.find((f) => f._id === u);
1157
- m && "content" in m && (r = r.map((f) => {
1155
+ const m = g.find((h) => h._id !== d);
1156
+ if (m && m._type === "Text") {
1157
+ const h = r.find((f) => f._id === u);
1158
+ h && "content" in h && (r = r.map((f) => {
1158
1159
  if (f._id === u) {
1159
- const x = { ...f, content: h.content };
1160
- return Object.keys(h).forEach((b) => {
1161
- b.startsWith("content-") && (x[b] = h[b]);
1160
+ const x = { ...f, content: m.content };
1161
+ return Object.keys(m).forEach((b) => {
1162
+ b.startsWith("content-") && (x[b] = m[b]);
1162
1163
  }), x;
1163
1164
  }
1164
1165
  return f;
1165
- }), a.push(h._id));
1166
+ }), a.push(m._id));
1166
1167
  }
1167
1168
  }
1168
1169
  });
@@ -1225,16 +1226,16 @@ function insertBlocksAtPosition(o, n, r, a) {
1225
1226
  let i = [...o];
1226
1227
  if (r) {
1227
1228
  const u = o.find((g) => g._id === r);
1228
- if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
1229
- const m = {
1229
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
1230
+ const h = {
1230
1231
  _id: generateUUID(),
1231
1232
  _parent: r,
1232
1233
  _type: "Text",
1233
1234
  content: u.content
1234
1235
  };
1235
1236
  Object.keys(u).forEach((f) => {
1236
- f.startsWith("content-") && (m[f] = u[f]);
1237
- }), l.unshift(m), i = i.map((f) => {
1237
+ f.startsWith("content-") && (h[f] = u[f]);
1238
+ }), l.unshift(h), i = i.map((f) => {
1238
1239
  if (f._id === r) {
1239
1240
  const x = { ...f, content: "" };
1240
1241
  return Object.keys(x).forEach((b) => {
@@ -1274,13 +1275,13 @@ function moveNode(o, n, r, a) {
1274
1275
  const l = findNodeById(o, n), i = findNodeById(o, r);
1275
1276
  if (!l || !i) return !1;
1276
1277
  i.children || (i.model.children = []);
1277
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
1278
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
1278
1279
  l.drop(), c = Math.max(c, 0);
1279
1280
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
1280
1281
  try {
1281
1282
  i.addChildAtIndex(l, p);
1282
- } catch (h) {
1283
- return console.error("Error adding child to parent:", h), !1;
1283
+ } catch (m) {
1284
+ return console.error("Error adding child to parent:", m), !1;
1284
1285
  }
1285
1286
  return !0;
1286
1287
  }
@@ -1321,8 +1322,8 @@ function handleNewParentTextBlock(o, n, r) {
1321
1322
  const d = o.map((u) => {
1322
1323
  if (u._id === r) {
1323
1324
  const g = { ...u, content: "" };
1324
- return Object.keys(g).forEach((h) => {
1325
- h.startsWith("content-") && (g[h] = "");
1325
+ return Object.keys(g).forEach((m) => {
1326
+ m.startsWith("content-") && (g[m] = "");
1326
1327
  }), g;
1327
1328
  }
1328
1329
  return u;
@@ -1339,7 +1340,7 @@ function moveBlocksWithChildren(o, n, r, a) {
1339
1340
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
1340
1341
  if (moveNode(p, n, c, a)) {
1341
1342
  let u = flattenTree(p);
1342
- const g = u.find((h) => h._id === n);
1343
+ const g = u.find((m) => m._id === n);
1343
1344
  return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
1344
1345
  }
1345
1346
  return i;
@@ -1390,12 +1391,12 @@ const useBlocksStoreManager = () => {
1390
1391
  } = useBlocksStoreManager();
1391
1392
  return {
1392
1393
  moveBlocks: (x, b, y) => {
1393
- const A = map(x, (w) => {
1394
+ const B = map(x, (w) => {
1394
1395
  const j = n.find((L) => L._id === w)._parent || null, C = n.filter((L) => j ? L._parent === j : !L._parent).map((L) => L._id).indexOf(w);
1395
1396
  return { _id: w, oldParent: j, oldPosition: C };
1396
- }), E = A.find(({ _id: w }) => w === x[0]);
1397
+ }), E = B.find(({ _id: w }) => w === x[0]);
1397
1398
  E && E.oldParent === b && E.oldPosition === y || (i(x, b, y), o({
1398
- undo: () => each(A, ({ _id: w, oldParent: _, oldPosition: j }) => {
1399
+ undo: () => each(B, ({ _id: w, oldParent: _, oldPosition: j }) => {
1399
1400
  i([w], _, j);
1400
1401
  }),
1401
1402
  redo: () => i(x, b, y)
@@ -1409,25 +1410,25 @@ const useBlocksStoreManager = () => {
1409
1410
  },
1410
1411
  removeBlocks: (x) => {
1411
1412
  var E;
1412
- const b = (E = first(x)) == null ? void 0 : E._parent, A = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
1413
+ const b = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
1413
1414
  l(map(x, "_id")), o({
1414
- undo: () => a(x, b, A),
1415
+ undo: () => a(x, b, B),
1415
1416
  redo: () => l(map(x, "_id"))
1416
1417
  });
1417
1418
  },
1418
1419
  updateBlocks: (x, b, y) => {
1419
- let A = [];
1420
+ let B = [];
1420
1421
  if (y)
1421
- A = map(x, (E) => ({ _id: E, ...y }));
1422
+ B = map(x, (E) => ({ _id: E, ...y }));
1422
1423
  else {
1423
1424
  const E = keys(b);
1424
- A = map(x, (w) => {
1425
+ B = map(x, (w) => {
1425
1426
  const _ = n.find((S) => S._id === w), j = { _id: w };
1426
1427
  return each(E, (S) => j[S] = _[S]), j;
1427
1428
  });
1428
1429
  }
1429
1430
  c(map(x, (E) => ({ _id: E, ...b }))), o({
1430
- undo: () => c(A),
1431
+ undo: () => c(B),
1431
1432
  redo: () => c(map(x, (E) => ({ _id: E, ...b })))
1432
1433
  });
1433
1434
  },
@@ -1443,8 +1444,8 @@ const useBlocksStoreManager = () => {
1443
1444
  updateMultipleBlocksProps: (x) => {
1444
1445
  let b = [];
1445
1446
  b = map(x, (y) => {
1446
- const A = keys(y), E = n.find((_) => _._id === y._id), w = {};
1447
- return each(A, (_) => w[_] = E[_]), w;
1447
+ const B = keys(y), E = n.find((_) => _._id === y._id), w = {};
1448
+ return each(B, (_) => w[_] = E[_]), w;
1448
1449
  }), c(x), o({
1449
1450
  undo: () => c(b),
1450
1451
  redo: () => c(x)
@@ -1483,7 +1484,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
1483
1484
  const useAddBlock = () => {
1484
1485
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1485
1486
  (i, c, d) => {
1486
- var m;
1487
+ var h;
1487
1488
  for (let f = 0; f < i.length; f++) {
1488
1489
  const { _id: x } = i[f];
1489
1490
  i[f]._id = generateUUID();
@@ -1493,7 +1494,7 @@ const useAddBlock = () => {
1493
1494
  }
1494
1495
  const p = first(i);
1495
1496
  let u, g;
1496
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
1497
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
1497
1498
  },
1498
1499
  [r, o, n]
1499
1500
  );
@@ -1510,8 +1511,8 @@ const useAddBlock = () => {
1510
1511
  ...has(i, "_name") && { _name: i._name },
1511
1512
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1512
1513
  };
1513
- let h, m;
1514
- return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), r([g], m, d), n([g._id]), g;
1514
+ let m, h;
1515
+ return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
1515
1516
  },
1516
1517
  [r, a, o, n]
1517
1518
  ), addPredefinedBlock: a };
@@ -2957,13 +2958,13 @@ const getBlockWithChildren = (o, n) => {
2957
2958
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2958
2959
  })
2959
2960
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2960
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
2961
- const x = cloneDeep(f.find((b) => b._id === m));
2961
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
2962
+ const x = cloneDeep(f.find((b) => b._id === h));
2962
2963
  for (const b in x) {
2963
2964
  const y = x[b];
2964
2965
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2965
- const { baseClasses: A, classes: E } = getSplitChaiClasses(y);
2966
- x[b] = compact(flattenDeep([A, E])).join(" ");
2966
+ const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
2967
+ x[b] = compact(flattenDeep([B, E])).join(" ");
2967
2968
  } else
2968
2969
  b !== "_id" && delete x[b];
2969
2970
  }
@@ -2971,16 +2972,16 @@ const getBlockWithChildren = (o, n) => {
2971
2972
  };
2972
2973
  return {
2973
2974
  askAi: useCallback(
2974
- async (m, f, x, b) => {
2975
+ async (h, f, x, b) => {
2975
2976
  if (l) {
2976
2977
  n(!0), a(null);
2977
2978
  try {
2978
- const y = p === u ? "" : p, A = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], E = await l(m, addLangToPrompt(x, g, m), A, y), { blocks: w, error: _ } = E;
2979
+ const y = p === u ? "" : p, B = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], E = await l(h, addLangToPrompt(x, g, h), B, y), { blocks: w, error: _ } = E;
2979
2980
  if (_) {
2980
2981
  a(_);
2981
2982
  return;
2982
2983
  }
2983
- if (m === "styles") {
2984
+ if (h === "styles") {
2984
2985
  const j = w.map((S) => {
2985
2986
  for (const C in S)
2986
2987
  C !== "_id" && (S[C] = `${STYLES_KEY},${S[C]}`);
@@ -3130,13 +3131,13 @@ const useBlockHighlight = () => {
3130
3131
  (a, l = null) => {
3131
3132
  const i = [];
3132
3133
  each(a, (c) => {
3133
- const d = o.find((m) => m._id === c);
3134
+ const d = o.find((h) => h._id === c);
3134
3135
  l ? l === "root" && (l = null) : l = d._parent;
3135
3136
  const g = filter(
3136
3137
  o,
3137
- (m) => isString(l) ? m._parent === l : !m._parent
3138
- ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
3139
- r(h, l, g), i.push(get(h, "0._id", ""));
3138
+ (h) => isString(l) ? h._parent === l : !h._parent
3139
+ ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
3140
+ r(m, l, g), i.push(get(m, "0._id", ""));
3140
3141
  }), n(i);
3141
3142
  },
3142
3143
  [o, n]
@@ -3229,13 +3230,13 @@ const useBlockHighlight = () => {
3229
3230
  return map(i, (c) => {
3230
3231
  const d = o(c), p = a;
3231
3232
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3232
- return each(p, (h) => {
3233
- const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3233
+ return each(p, (m) => {
3234
+ const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
3234
3235
  u = u.replace(f, " ").replace(/\s+/g, " ").trim();
3235
- const x = first(h.split(":"));
3236
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
3237
- }), each(p, (h) => {
3238
- const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3236
+ const x = first(m.split(":"));
3237
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
3238
+ }), each(p, (m) => {
3239
+ const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
3239
3240
  g = g.replace(f, " ").replace(/\s+/g, " ").trim();
3240
3241
  }), {
3241
3242
  ids: [d._id],
@@ -3339,20 +3340,20 @@ class PubSub {
3339
3340
  }
3340
3341
  }
3341
3342
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
3342
- const [r] = useBlocksStore(), a = get(o, "_id"), l = get(o, "_parent"), i = filter(r, (u) => l ? get(u, "_parent") === l : !get(u, "_parent")), c = canAddChildBlock(get(o, "_type", "")), d = findIndex(i, { _id: a }), p = (u) => {
3343
- if (u === "CHILD")
3343
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), l = get(o, "_id"), i = get(o, "_parent"), c = filter(a, (g) => i ? get(g, "_parent") === i : !get(g, "_parent")), d = canAddChildBlock(get(o, "_type", "")), p = findIndex(c, { _id: l }), u = (g) => {
3344
+ if (g === "CHILD")
3344
3345
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
3345
3346
  else {
3346
- const g = { _id: l || "", position: i == null ? void 0 : i.length };
3347
- u === "BEFORE" ? g.position = Math.max(d, 0) : u === "AFTER" && (g.position = d + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, g);
3347
+ const m = { _id: i || "", position: c == null ? void 0 : c.length };
3348
+ g === "BEFORE" ? m.position = Math.max(p, 0) : g === "AFTER" && (m.position = p + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
3348
3349
  }
3349
3350
  };
3350
3351
  return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
3351
3352
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: n }),
3352
- /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-200 shadow-2xl", children: [
3353
- c && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("CHILD"), children: "Add child block" }),
3354
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("BEFORE"), children: "Add block before" }),
3355
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer", onClick: () => p("AFTER"), children: "Add block after" })
3353
+ /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-blue-500 text-white shadow-2xl", children: [
3354
+ d && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("CHILD"), children: r("Add inside") }),
3355
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("BEFORE"), children: r("Add before") }),
3356
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => u("AFTER"), children: r("Add after") })
3356
3357
  ] })
3357
3358
  ] });
3358
3359
  };
@@ -3362,12 +3363,67 @@ function getOrientation(o) {
3362
3363
  const a = n.flexDirection;
3363
3364
  return a === "column" || a === "column-reverse" ? "vertical" : "horizontal";
3364
3365
  } else if (r === "grid") {
3365
- const a = n.gridAutoFlow, l = n.gridTemplateRows, i = n.gridTemplateColumns;
3366
- return a.includes("column") || l.split(" ").length > i.split(" ").length ? "vertical" : "horizontal";
3366
+ const a = n.gridAutoFlow, l = n.gridTemplateColumns;
3367
+ return a.includes("column") || l && l !== "none" && l !== "" && !l.includes("calc") && // Handle calc expressions
3368
+ l.split(" ").length <= 1 ? "vertical" : "horizontal";
3367
3369
  } else if (r === "block" || r === "inline-block")
3368
3370
  return "vertical";
3369
3371
  return "horizontal";
3370
3372
  }
3373
+ if (import.meta.vitest) {
3374
+ const { test: o, expect: n } = import.meta.vitest;
3375
+ o("getOrientation default div should be vertical", () => {
3376
+ n(getOrientation(document.createElement("div"))).toBe("vertical");
3377
+ }), o("getOrientation flex with default direction should be horizontal", () => {
3378
+ const r = document.createElement("div");
3379
+ r.style.display = "flex", n(getOrientation(r)).toBe("horizontal");
3380
+ }), o("getOrientation inline-flex with default direction should be horizontal", () => {
3381
+ const r = document.createElement("div");
3382
+ r.style.display = "inline-flex", n(getOrientation(r)).toBe("horizontal");
3383
+ }), o("getOrientation flex with row direction should be horizontal", () => {
3384
+ const r = document.createElement("div");
3385
+ r.style.display = "flex", r.style.flexDirection = "row", n(getOrientation(r)).toBe("horizontal");
3386
+ }), o("getOrientation flex with row-reverse direction should be horizontal", () => {
3387
+ const r = document.createElement("div");
3388
+ r.style.display = "flex", r.style.flexDirection = "row-reverse", n(getOrientation(r)).toBe("horizontal");
3389
+ }), o("getOrientation flex with column direction should be vertical", () => {
3390
+ const r = document.createElement("div");
3391
+ r.style.display = "flex", r.style.flexDirection = "column", n(getOrientation(r)).toBe("vertical");
3392
+ }), o("getOrientation flex with column-reverse direction should be vertical", () => {
3393
+ const r = document.createElement("div");
3394
+ r.style.display = "flex", r.style.flexDirection = "column-reverse", n(getOrientation(r)).toBe("vertical");
3395
+ }), o("getOrientation grid with default settings should be horizontal", () => {
3396
+ const r = document.createElement("div");
3397
+ r.style.display = "grid", n(getOrientation(r)).toBe("horizontal");
3398
+ }), o("getOrientation grid with row auto-flow should be horizontal", () => {
3399
+ const r = document.createElement("div");
3400
+ r.style.display = "grid", r.style.gridAutoFlow = "row", n(getOrientation(r)).toBe("horizontal");
3401
+ }), o("getOrientation grid with column auto-flow should be vertical", () => {
3402
+ const r = document.createElement("div");
3403
+ r.style.display = "grid", r.style.gridAutoFlow = "column", n(getOrientation(r)).toBe("vertical");
3404
+ }), o("getOrientation grid with dense column auto-flow should be vertical", () => {
3405
+ const r = document.createElement("div");
3406
+ r.style.display = "grid", r.style.gridAutoFlow = "column dense", n(getOrientation(r)).toBe("vertical");
3407
+ }), o("getOrientation grid with single column should be vertical", () => {
3408
+ const r = document.createElement("div");
3409
+ r.style.display = "grid", r.style.gridTemplateColumns = "1fr", n(getOrientation(r)).toBe("vertical");
3410
+ }), o("getOrientation grid with multiple columns should be horizontal", () => {
3411
+ const r = document.createElement("div");
3412
+ r.style.display = "grid", r.style.gridTemplateColumns = "1fr 1fr", n(getOrientation(r)).toBe("horizontal");
3413
+ }), o("getOrientation block should be vertical", () => {
3414
+ const r = document.createElement("div");
3415
+ r.style.display = "block", n(getOrientation(r)).toBe("vertical");
3416
+ }), o("getOrientation inline-block should be vertical", () => {
3417
+ const r = document.createElement("div");
3418
+ r.style.display = "inline-block", n(getOrientation(r)).toBe("vertical");
3419
+ }), o("getOrientation inline should be horizontal", () => {
3420
+ const r = document.createElement("div");
3421
+ r.style.display = "inline", n(getOrientation(r)).toBe("horizontal");
3422
+ }), o("getOrientation table should be horizontal", () => {
3423
+ const r = document.createElement("div");
3424
+ r.style.display = "table", n(getOrientation(r)).toBe("horizontal");
3425
+ });
3426
+ }
3371
3427
  const CONTROLS = [
3372
3428
  { ControlIcon: PinTopIcon, dir: "VERTICAL", key: "UP" },
3373
3429
  { ControlIcon: PinBottomIcon, dir: "VERTICAL", key: "DOWN" },
@@ -3382,11 +3438,11 @@ const CONTROLS = [
3382
3438
  return "VERTICAL";
3383
3439
  }
3384
3440
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3385
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, a), f = useCallback(
3441
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, a), f = useCallback(
3386
3442
  (x) => {
3387
- isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3443
+ isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), n());
3388
3444
  },
3389
- [g, h, p, u, i, c, n]
3445
+ [g, m, p, u, i, c, n]
3390
3446
  );
3391
3447
  return useHotkeys(
3392
3448
  "shift+up, shift+down, shift+left, shift+right",
@@ -3396,27 +3452,24 @@ const CONTROLS = [
3396
3452
  },
3397
3453
  { document: a == null ? void 0 : a.contentDocument },
3398
3454
  [f]
3399
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
3455
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: f, orientation: h };
3400
3456
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
3401
3457
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
3402
3458
  o,
3403
3459
  n
3404
3460
  );
3405
- return r ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
3406
- /* @__PURE__ */ jsx("div", { className: "mx-1 h-3 w-px bg-white/50" }),
3407
- CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
3408
- if (c !== p) return null;
3409
- const g = isDisabledControl(a, l, u);
3410
- return /* @__PURE__ */ jsx(
3411
- d,
3412
- {
3413
- onClick: () => i(u),
3414
- className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
3415
- },
3416
- u
3417
- );
3418
- })
3419
- ] });
3461
+ return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
3462
+ if (c !== p) return null;
3463
+ const g = isDisabledControl(a, l, u);
3464
+ return g ? null : /* @__PURE__ */ jsx(
3465
+ d,
3466
+ {
3467
+ onClick: () => i(u),
3468
+ className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
3469
+ },
3470
+ u
3471
+ );
3472
+ }) });
3420
3473
  }, BlockActionLabel = ({ block: o, label: n }) => {
3421
3474
  const [, r] = useSelectedBlockIds(), [, a] = useHighlightBlockId(), [, l] = useAtom$1(draggedBlockAtom), i = useFeature("dnd");
3422
3475
  return /* @__PURE__ */ jsxs(
@@ -3436,15 +3489,15 @@ const CONTROLS = [
3436
3489
  }
3437
3490
  );
3438
3491
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: n }) => {
3439
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: h } = useFloating({
3492
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), [d] = useAtom$1(inlineEditingActiveAtom), { document: p } = useFrame(), { floatingStyles: u, refs: g, update: m } = useFloating({
3440
3493
  placement: "top-start",
3441
3494
  middleware: [shift(), flip()],
3442
3495
  elements: {
3443
3496
  reference: o
3444
3497
  }
3445
3498
  });
3446
- useResizeObserver(o, () => h(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => h(), (p == null ? void 0 : p.body) !== null);
3447
- const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3499
+ useResizeObserver(o, () => m(), o !== null), useResizeObserver(p == null ? void 0 : p.body, () => m(), (p == null ? void 0 : p.body) !== null);
3500
+ const h = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3448
3501
  return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3449
3502
  "div",
3450
3503
  {
@@ -3461,12 +3514,12 @@ const CONTROLS = [
3461
3514
  onKeyDown: (x) => x.stopPropagation(),
3462
3515
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3463
3516
  children: [
3464
- m && /* @__PURE__ */ jsx(
3517
+ h && /* @__PURE__ */ jsx(
3465
3518
  ArrowUpIcon,
3466
3519
  {
3467
3520
  className: "hover:scale-105",
3468
3521
  onClick: () => {
3469
- c([]), l([m]);
3522
+ c([]), l([h]);
3470
3523
  }
3471
3524
  }
3472
3525
  ),
@@ -3475,7 +3528,7 @@ const CONTROLS = [
3475
3528
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: n, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
3476
3529
  canDuplicateBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([n == null ? void 0 : n._id]) }) : null,
3477
3530
  canDeleteBlock(get(n, "_type", "")) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([n == null ? void 0 : n._id]) }) : null,
3478
- /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: h })
3531
+ /* @__PURE__ */ jsx(BlockController, { block: n, updateFloatingBar: m })
3479
3532
  ] })
3480
3533
  ]
3481
3534
  }
@@ -3536,15 +3589,15 @@ const CONTROLS = [
3536
3589
  <div class="frame-root h-full"></div>
3537
3590
  </body>
3538
3591
  </html>`, useKeyEventWatcher = (o) => {
3539
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
3592
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3540
3593
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
3541
3594
  "ctrl+v,command+v",
3542
3595
  () => {
3543
- g(n[0]) && h(n);
3596
+ g(n[0]) && m(n);
3544
3597
  },
3545
- { ...m, preventDefault: !0 },
3546
- [n, g, h]
3547
- ), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
3598
+ { ...h, preventDefault: !0 },
3599
+ [n, g, m]
3600
+ ), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, preventDefault: !0 }, [
3548
3601
  n,
3549
3602
  i
3550
3603
  ]), useHotkeys(
@@ -3552,7 +3605,7 @@ const CONTROLS = [
3552
3605
  (f) => {
3553
3606
  f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3554
3607
  },
3555
- m,
3608
+ h,
3556
3609
  [n, l]
3557
3610
  );
3558
3611
  }, KeyboardHandler = () => {
@@ -3630,38 +3683,38 @@ function removeDataDrop() {
3630
3683
  const useDnd = () => {
3631
3684
  const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
3632
3685
  if (!useFeature("dnd")) return {};
3633
- const h = () => {
3686
+ const m = () => {
3634
3687
  removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
3635
3688
  };
3636
3689
  return iframeDocument = o, {
3637
3690
  isDragging: n,
3638
- onDragOver: (m) => {
3639
- m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
3691
+ onDragOver: (h) => {
3692
+ h.preventDefault(), h.stopPropagation(), throttledDragOver(h);
3640
3693
  },
3641
- onDrop: (m) => {
3694
+ onDrop: (h) => {
3642
3695
  var _;
3643
- const f = dropTarget, b = getOrientation(f) === "vertical" ? m.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : m.clientX;
3696
+ const f = dropTarget, b = getOrientation(f) === "vertical" ? h.clientY + ((_ = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : _.scrollY) : h.clientX;
3644
3697
  dropIndex = calculateDropIndex(b, possiblePositions);
3645
- const y = d, A = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3646
- if ((y == null ? void 0 : y._id) === A || !E) {
3647
- h();
3698
+ const y = d, B = f.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3699
+ if ((y == null ? void 0 : y._id) === B || !E) {
3700
+ m();
3648
3701
  return;
3649
3702
  }
3650
3703
  if (!has(y, "_id")) {
3651
- a(y, A === "canvas" ? null : A, dropIndex), setTimeout(h, 300);
3704
+ a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
3652
3705
  return;
3653
3706
  }
3654
3707
  let w = f.getAttribute("data-block-id");
3655
- w === null && (w = m.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), h(), setTimeout(removePlaceholder, 300);
3708
+ w === null && (w = h.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), setTimeout(removePlaceholder, 300);
3656
3709
  },
3657
- onDragEnter: (m) => {
3658
- const f = m, x = f.target;
3710
+ onDragEnter: (h) => {
3711
+ const f = h, x = f.target;
3659
3712
  dropTarget = x;
3660
3713
  const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3661
3714
  u(b), f.stopPropagation(), f.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3662
3715
  },
3663
- onDragLeave: (m) => {
3664
- m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3716
+ onDragLeave: (h) => {
3717
+ h.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3665
3718
  }
3666
3719
  };
3667
3720
  };
@@ -3683,17 +3736,17 @@ const useHandleCanvasDblClick = (o, n) => {
3683
3736
  const g = u.getAttribute("data-block-type");
3684
3737
  if (!g || !r.includes(g))
3685
3738
  return;
3686
- const h = u.getAttribute("data-block-id");
3687
- if (!h) return;
3739
+ const m = u.getAttribute("data-block-id");
3740
+ if (!m) return;
3688
3741
  o.on("update", ({ editor: f }) => {
3689
3742
  console.log(f.getHTML());
3690
3743
  }), o.on("blur", () => {
3691
3744
  console.log("blur");
3692
3745
  const f = o.getHTML();
3693
- a([h], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3694
- }), i(h);
3695
- const m = d(h).content;
3696
- o.commands.setContent(m), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3746
+ a([m], { content: f }), n.style.display = "none", u.style.visibility = "visible";
3747
+ }), i(m);
3748
+ const h = d(m).content;
3749
+ o.commands.setContent(h), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3697
3750
  },
3698
3751
  [l, c, d, i, a, o, n]
3699
3752
  );
@@ -3744,7 +3797,7 @@ const useHandleCanvasDblClick = (o, n) => {
3744
3797
  }, [n, r, l, a]);
3745
3798
  const c = useEditor({
3746
3799
  extensions: [StarterKit]
3747
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), h = useHandleMouseLeave(), m = useDnd();
3800
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), h = useDnd();
3748
3801
  return /* @__PURE__ */ jsx(
3749
3802
  "div",
3750
3803
  {
@@ -3753,18 +3806,18 @@ const useHandleCanvasDblClick = (o, n) => {
3753
3806
  onClick: u,
3754
3807
  onDoubleClick: p,
3755
3808
  onMouseMove: g,
3756
- onMouseLeave: h,
3757
- ...omit(m, "isDragging"),
3758
- className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
3809
+ onMouseLeave: m,
3810
+ ...omit(h, "isDragging"),
3811
+ className: "relative h-full max-w-full p-px " + (h.isDragging ? "dragging" : ""),
3759
3812
  children: o
3760
3813
  }
3761
3814
  );
3762
3815
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
3763
3816
  const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3764
3817
  d == null ? void 0 : d.getElementById("selected-block")
3765
- ), [h] = useState(
3766
- d == null ? void 0 : d.getElementById("selected-styling-block")
3767
3818
  ), [m] = useState(
3819
+ d == null ? void 0 : d.getElementById("selected-styling-block")
3820
+ ), [h] = useState(
3768
3821
  d == null ? void 0 : d.getElementById("dragged-block")
3769
3822
  );
3770
3823
  useEffect(() => {
@@ -3808,14 +3861,14 @@ const useHandleCanvasDblClick = (o, n) => {
3808
3861
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3809
3862
  }`);
3810
3863
  }, [r, g]), useEffect(() => {
3811
- m.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3812
- }, [i, m]), useEffect(() => {
3864
+ h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3865
+ }, [i, h]), useEffect(() => {
3813
3866
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3814
3867
  }, [u]), useEffect(() => {
3815
- h && (h.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3868
+ m && (m.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3816
3869
  outline: 1px solid orange !important; outline-offset: -1px;
3817
3870
  }`);
3818
- }, [l, h]), useEffect(() => {
3871
+ }, [l, m]), useEffect(() => {
3819
3872
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3820
3873
  }, [c, d]);
3821
3874
  const f = useMemo(
@@ -3901,10 +3954,10 @@ const getBlockRuntimeProps = memoize((o) => {
3901
3954
  [o]
3902
3955
  );
3903
3956
  }, BlockRenderer = ({ blockAtom: o, children: n }) => {
3904
- const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), h = useMemo(
3957
+ const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
3905
3958
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3906
3959
  [r, l, a, d, u]
3907
- ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3960
+ ), h = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), f = useMemo(
3908
3961
  () => c(r._id, getBlockRuntimeProps(r._type)),
3909
3962
  [r._id, r._type, c, getBlockRuntimeProps]
3910
3963
  ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
@@ -3915,8 +3968,8 @@ const getBlockRuntimeProps = memoize((o) => {
3915
3968
  },
3916
3969
  inBuilder: !0,
3917
3970
  lang: l || i,
3918
- ...h,
3919
3971
  ...m,
3972
+ ...h,
3920
3973
  ...f,
3921
3974
  ...x
3922
3975
  }),
@@ -3925,8 +3978,8 @@ const getBlockRuntimeProps = memoize((o) => {
3925
3978
  r._type,
3926
3979
  l,
3927
3980
  i,
3928
- h,
3929
3981
  m,
3982
+ h,
3930
3983
  f,
3931
3984
  x
3932
3985
  ]
@@ -3960,11 +4013,11 @@ const getBlockRuntimeProps = memoize((o) => {
3960
4013
  if (d < n) {
3961
4014
  const u = parseFloat((d / n).toFixed(2).toString());
3962
4015
  let g = {};
3963
- const h = p * u, m = d * u;
4016
+ const m = p * u, h = d * u;
3964
4017
  p && (g = {
3965
4018
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3966
- height: 100 + (p - h) / h * 100 + "%",
3967
- width: 100 + (d - m) / m * 100 + "%"
4019
+ height: 100 + (p - m) / m * 100 + "%",
4020
+ width: 100 + (d - h) / h * 100 + "%"
3968
4021
  }), i({
3969
4022
  position: "relative",
3970
4023
  top: 0,
@@ -3981,7 +4034,7 @@ const getBlockRuntimeProps = memoize((o) => {
3981
4034
  c();
3982
4035
  }, [n, o, r, c]), l;
3983
4036
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3984
- const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, h] = useState([]), [, m] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), E = (j) => {
4037
+ const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, h] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (j) => {
3985
4038
  p((S) => ({ ...S, width: j }));
3986
4039
  };
3987
4040
  useEffect(() => {
@@ -3997,7 +4050,7 @@ const getBlockRuntimeProps = memoize((o) => {
3997
4050
  var j, S;
3998
4051
  if (a && a.type !== "Multiple" && i.current) {
3999
4052
  const C = getElementByDataBlockId(i.current.contentDocument, a._id);
4000
- C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), h([C]));
4053
+ C && (w(C) || (S = (j = i.current) == null ? void 0 : j.contentWindow) == null || S.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([C]));
4001
4054
  }
4002
4055
  }, [a]), useEffect(() => {
4003
4056
  if (!isEmpty(x) && i.current) {
@@ -4005,14 +4058,14 @@ const getBlockRuntimeProps = memoize((o) => {
4005
4058
  i.current.contentDocument,
4006
4059
  first(x).id
4007
4060
  );
4008
- m(j ? [j] : [null]);
4061
+ h(j ? [j] : [null]);
4009
4062
  } else
4010
- m([null]);
4063
+ h([null]);
4011
4064
  }, [x]);
4012
4065
  const _ = useMemo(() => {
4013
4066
  let j = IframeInitialContent;
4014
- return j = j.replace("__HTML_DIR__", A), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4015
- }, [o, A]);
4067
+ return j = j.replace("__HTML_DIR__", B), o === "offline" && (j = j.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), j;
4068
+ }, [o, B]);
4016
4069
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
4017
4070
  "div",
4018
4071
  {
@@ -4205,20 +4258,20 @@ const getBlockRuntimeProps = memoize((o) => {
4205
4258
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4206
4259
  const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4207
4260
  a(y);
4208
- }, h = () => {
4209
- const y = l.find((A) => Object.keys(A)[0] === r);
4261
+ }, m = () => {
4262
+ const y = l.find((B) => Object.keys(B)[0] === r);
4210
4263
  if (y) {
4211
- const A = Object.values(y)[0];
4212
- A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
4264
+ const B = Object.values(y)[0];
4265
+ B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
4213
4266
  } else
4214
4267
  console.error("Preset not found:", r);
4215
- }, m = useDebouncedCallback(
4216
- (y, A) => {
4268
+ }, h = useDebouncedCallback(
4269
+ (y, B) => {
4217
4270
  d(() => ({
4218
4271
  ...c,
4219
4272
  fontFamily: {
4220
4273
  ...c.fontFamily,
4221
- [y.replace(/font-/g, "")]: A
4274
+ [y.replace(/font-/g, "")]: B
4222
4275
  }
4223
4276
  }));
4224
4277
  },
@@ -4234,10 +4287,10 @@ const getBlockRuntimeProps = memoize((o) => {
4234
4287
  [c],
4235
4288
  200
4236
4289
  ), x = useDebouncedCallback(
4237
- (y, A) => {
4290
+ (y, B) => {
4238
4291
  d(() => {
4239
4292
  const E = get(c, `colors.${y}`);
4240
- return n ? set(E, 1, A) : set(E, 0, A), {
4293
+ return n ? set(E, 1, B) : set(E, 0, B), {
4241
4294
  ...c,
4242
4295
  colors: {
4243
4296
  ...c.colors,
@@ -4248,18 +4301,18 @@ const getBlockRuntimeProps = memoize((o) => {
4248
4301
  },
4249
4302
  [c],
4250
4303
  200
4251
- ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
4252
- const E = get(c, `colors.${A}.${n ? 1 : 0}`);
4304
+ ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4305
+ const E = get(c, `colors.${B}.${n ? 1 : 0}`);
4253
4306
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4254
4307
  /* @__PURE__ */ jsx(
4255
4308
  ColorPickerInput,
4256
4309
  {
4257
4310
  value: E,
4258
- onChange: (w) => x(A, w)
4311
+ onChange: (w) => x(B, w)
4259
4312
  }
4260
4313
  ),
4261
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
4262
- ] }, A);
4314
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4315
+ ] }, B);
4263
4316
  }) });
4264
4317
  return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4265
4318
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -4285,18 +4338,18 @@ const getBlockRuntimeProps = memoize((o) => {
4285
4338
  className: "w-full text-sm",
4286
4339
  disabled: r === "",
4287
4340
  variant: "default",
4288
- onClick: h,
4341
+ onClick: m,
4289
4342
  children: u("Apply")
4290
4343
  }
4291
4344
  ) })
4292
4345
  ] }),
4293
4346
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4294
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
4347
+ (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
4295
4348
  FontSelector,
4296
4349
  {
4297
4350
  label: y,
4298
- value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4299
- onChange: (E) => m(y, E)
4351
+ value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4352
+ onChange: (E) => h(y, E)
4300
4353
  },
4301
4354
  y
4302
4355
  )) }),
@@ -4406,12 +4459,12 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4406
4459
  f.type === "object" ? (c((b) => [...b, f.key]), p(f.value)) : x(f.type) && (n([...i, f.key].join(".")), l(!1));
4407
4460
  },
4408
4461
  [i, n, r]
4409
- ), h = React.useCallback(() => {
4462
+ ), m = React.useCallback(() => {
4410
4463
  if (i.length > 0) {
4411
4464
  const f = i.slice(0, -1);
4412
4465
  c(f), p(f.reduce((x, b) => x[b], o));
4413
4466
  }
4414
- }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
4467
+ }, [i, o]), h = React.useMemo(() => Object.entries(d).map(([f, x]) => ({
4415
4468
  key: f,
4416
4469
  value: x,
4417
4470
  type: u(x)
@@ -4436,11 +4489,11 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4436
4489
  /* @__PURE__ */ jsxs(CommandList, { children: [
4437
4490
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4438
4491
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4439
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: h, className: "flex items-center text-sm", children: [
4492
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
4440
4493
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4441
4494
  "Back"
4442
4495
  ] }),
4443
- m.map((f) => /* @__PURE__ */ jsxs(
4496
+ h.map((f) => /* @__PURE__ */ jsxs(
4444
4497
  CommandItem,
4445
4498
  {
4446
4499
  value: f.key,
@@ -4625,16 +4678,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4625
4678
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4626
4679
  useEffect(() => {
4627
4680
  if (o) {
4628
- const h = document.createElement("style");
4629
- return h.id = "rte-modal-styles", h.innerHTML = `
4681
+ const m = document.createElement("style");
4682
+ return m.id = "rte-modal-styles", m.innerHTML = `
4630
4683
  /* Ensure the NestedPathSelector popover appears above the dialog */
4631
4684
  .rte-path-selector + [data-radix-popper-content-wrapper],
4632
4685
  [data-radix-popper-content-wrapper] {
4633
4686
  z-index: 9999 !important;
4634
4687
  }
4635
- `, document.head.appendChild(h), () => {
4636
- const m = document.getElementById("rte-modal-styles");
4637
- m && m.remove();
4688
+ `, document.head.appendChild(m), () => {
4689
+ const h = document.getElementById("rte-modal-styles");
4690
+ h && h.remove();
4638
4691
  };
4639
4692
  }
4640
4693
  }, [o]);
@@ -4655,13 +4708,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4655
4708
  Underline
4656
4709
  ],
4657
4710
  content: a || "",
4658
- onUpdate: ({ editor: h }) => {
4659
- const m = h.getHTML();
4660
- l(m);
4711
+ onUpdate: ({ editor: m }) => {
4712
+ const h = m.getHTML();
4713
+ l(h);
4661
4714
  },
4662
- onBlur: ({ editor: h }) => {
4663
- const m = h.getHTML();
4664
- i(r, m);
4715
+ onBlur: ({ editor: m }) => {
4716
+ const h = m.getHTML();
4717
+ i(r, h);
4665
4718
  },
4666
4719
  editorProps: {
4667
4720
  attributes: {
@@ -4676,22 +4729,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4676
4729
  }, [o, u]), useEffect(() => {
4677
4730
  c.current && u && (c.current.__chaiRTE = u);
4678
4731
  }, [u, o]);
4679
- const g = (h) => {
4732
+ const g = (m) => {
4680
4733
  if (!u) return;
4681
- const m = `{{${h}}}`;
4734
+ const h = `{{${m}}}`;
4682
4735
  u.commands.focus();
4683
4736
  const { from: f, to: x } = u.state.selection;
4684
4737
  if (f !== x)
4685
- u.chain().deleteSelection().insertContent(m).run();
4738
+ u.chain().deleteSelection().insertContent(h).run();
4686
4739
  else {
4687
- const { state: y } = u, A = y.selection.from, E = y.doc.textBetween(Math.max(0, A - 1), A), w = y.doc.textBetween(A, Math.min(A + 1, y.doc.content.size));
4740
+ const { state: y } = u, B = y.selection.from, E = y.doc.textBetween(Math.max(0, B - 1), B), w = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
4688
4741
  let _ = "";
4689
- A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
4742
+ B > 0 && E !== " " && !/[.,!?;:]/.test(E) && (_ = " ");
4690
4743
  let j = "";
4691
- w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + m + j).run();
4744
+ w && w !== " " && !/[.,!?;:]/.test(w) && (j = " "), u.chain().insertContent(_ + h + j).run();
4692
4745
  }
4693
4746
  };
4694
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4747
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4695
4748
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4696
4749
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4697
4750
  p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4742,9 +4795,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4742
4795
  }, [g]), useEffect(() => {
4743
4796
  u(r || "");
4744
4797
  }, [r]);
4745
- const h = (f) => {
4798
+ const m = (f) => {
4746
4799
  a(f);
4747
- }, m = () => {
4800
+ }, h = () => {
4748
4801
  d(!1), g && g.commands.setContent(p);
4749
4802
  };
4750
4803
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4756,10 +4809,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4756
4809
  RTEModal,
4757
4810
  {
4758
4811
  isOpen: c,
4759
- onClose: m,
4812
+ onClose: h,
4760
4813
  id: o,
4761
4814
  value: p,
4762
- onChange: h,
4815
+ onChange: m,
4763
4816
  onBlur: l
4764
4817
  }
4765
4818
  )
@@ -4770,13 +4823,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4770
4823
  onChange: r
4771
4824
  }) => {
4772
4825
  var L;
4773
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), A = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4826
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), B = useRef(null), E = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4774
4827
  useEffect(() => {
4775
- if (m(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4828
+ if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4776
4829
  const v = split(o, ":"), k = get(v, 1, "page") || "page";
4777
4830
  g(k), (async () => {
4778
- const B = await l(k, [get(v, 2, "page")]);
4779
- B && Array.isArray(B) && m(get(B, [0, "name"], ""));
4831
+ const A = await l(k, [get(v, 2, "page")]);
4832
+ A && Array.isArray(A) && h(get(A, [0, "name"], ""));
4780
4833
  })();
4781
4834
  }, [o]);
4782
4835
  const w = useDebouncedCallback(
@@ -4793,7 +4846,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4793
4846
  300
4794
4847
  ), _ = (v) => {
4795
4848
  const k = ["pageType", u, v.id];
4796
- k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), y(-1));
4849
+ k[1] && (r(k.join(":")), h(v.name), p(!1), x([]), y(-1));
4797
4850
  }, j = (v) => {
4798
4851
  switch (v.key) {
4799
4852
  case "ArrowDown":
@@ -4812,15 +4865,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4812
4865
  }
4813
4866
  };
4814
4867
  useEffect(() => {
4815
- if (b >= 0 && A.current) {
4816
- const v = A.current.children[b];
4868
+ if (b >= 0 && B.current) {
4869
+ const v = B.current.children[b];
4817
4870
  v == null || v.scrollIntoView({ block: "nearest" });
4818
4871
  }
4819
4872
  }, [b]);
4820
4873
  const S = () => {
4821
- m(""), x([]), y(-1), p(!1), r("");
4874
+ h(""), x([]), y(-1), p(!1), r("");
4822
4875
  }, C = (v) => {
4823
- m(v), p(!isEmpty(v)), c(!0), w(v);
4876
+ h(v), p(!isEmpty(v)), c(!0), w(v);
4824
4877
  };
4825
4878
  return /* @__PURE__ */ jsxs("div", { children: [
4826
4879
  /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
@@ -4829,14 +4882,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4829
4882
  "input",
4830
4883
  {
4831
4884
  type: "text",
4832
- value: h,
4885
+ value: m,
4833
4886
  onChange: (v) => C(v.target.value),
4834
4887
  onKeyDown: j,
4835
4888
  placeholder: a(`Search ${E ?? ""}`),
4836
4889
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4837
4890
  }
4838
4891
  ),
4839
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4892
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4840
4893
  ] }),
4841
4894
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4842
4895
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4844,9 +4897,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4844
4897
  ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4845
4898
  a("No results found for"),
4846
4899
  ' "',
4847
- h,
4900
+ m,
4848
4901
  '"'
4849
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(f == null ? void 0 : f.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4902
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(f == null ? void 0 : f.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4850
4903
  "li",
4851
4904
  {
4852
4905
  onClick: () => _(v),
@@ -4943,14 +4996,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4943
4996
  }, [a]), useEffect(() => {
4944
4997
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4945
4998
  }, [o, u]);
4946
- const h = () => {
4999
+ const m = () => {
4947
5000
  const x = findIndex(u, { _id: g });
4948
5001
  if (x > -1) {
4949
5002
  const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4950
5003
  if (!y) return;
4951
5004
  n({ ...o, currentSlide: y }), c([y]);
4952
5005
  }
4953
- }, m = () => {
5006
+ }, h = () => {
4954
5007
  const x = findIndex(u, { _id: g });
4955
5008
  if (x > -1) {
4956
5009
  const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
@@ -4966,7 +5019,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4966
5019
  };
4967
5020
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4968
5021
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
4969
- /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
5022
+ /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4970
5023
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4971
5024
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
4972
5025
  " ",
@@ -4975,7 +5028,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4975
5028
  "/",
4976
5029
  u.length
4977
5030
  ] }) : "-" }),
4978
- /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
5031
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4979
5032
  /* @__PURE__ */ jsxs(
4980
5033
  "button",
4981
5034
  {
@@ -5067,7 +5120,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5067
5120
  ),
5068
5121
  /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
5069
5122
  ] });
5070
- }, CustomFieldTemplate = ({
5123
+ }, JSONFormFieldTemplate = ({
5071
5124
  id: o,
5072
5125
  classNames: n,
5073
5126
  label: r,
@@ -5079,15 +5132,15 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5079
5132
  required: p,
5080
5133
  schema: u,
5081
5134
  formData: g,
5082
- onChange: h
5135
+ onChange: m
5083
5136
  }) => {
5084
- const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(m) ? f : m, y = get(LANGUAGES, b, b), A = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5137
+ const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = isEmpty$1(x) ? "" : isEmpty$1(h) ? f : h, y = get$1(LANGUAGES, b, b), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = get$1(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [j, S] = useState(null), C = useCallback(
5085
5138
  (k) => {
5086
- const B = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5139
+ const A = (N) => /[.,!?;:]/.test(N), T = (N, D, $) => {
5087
5140
  let R = "", O = "";
5088
- const $ = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5089
- return D > 0 && ($ === "." || !B($) && $ !== " ") && (R = " "), D < N.length && !B(H) && H !== " " && (O = " "), {
5090
- text: R + M + O,
5141
+ const M = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5142
+ return D > 0 && (M === "." || !A(M) && M !== " ") && (R = " "), D < N.length && !A(H) && H !== " " && (O = " "), {
5143
+ text: R + $ + O,
5091
5144
  prefixLength: R.length,
5092
5145
  suffixLength: O.length
5093
5146
  };
@@ -5099,31 +5152,31 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5099
5152
  if (N) {
5100
5153
  const D = `{{${k}}}`;
5101
5154
  N.commands.focus();
5102
- const { from: M, to: R } = N.state.selection;
5103
- if (M !== R)
5155
+ const { from: $, to: R } = N.state.selection;
5156
+ if ($ !== R)
5104
5157
  N.chain().deleteSelection().insertContent(D).run();
5105
5158
  else {
5106
- const { state: $ } = N, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5159
+ const { state: M } = N, H = M.selection.from, F = M.doc.textBetween(Math.max(0, H - 1), H), U = M.doc.textBetween(H, Math.min(H + 1, M.doc.content.size));
5107
5160
  let z = "";
5108
- H > 0 && F !== " " && !B(F) && (z = " ");
5161
+ H > 0 && F !== " " && !A(F) && (z = " ");
5109
5162
  let W = "";
5110
- U && U !== " " && !B(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5163
+ U && U !== " " && !A(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5111
5164
  }
5112
- setTimeout(() => h(N.getHTML(), {}, o), 100);
5165
+ setTimeout(() => m(N.getHTML(), {}, o), 100);
5113
5166
  return;
5114
5167
  }
5115
5168
  } else {
5116
- const N = I, D = N.selectionStart || 0, M = N.value || "", R = N.selectionEnd || D;
5169
+ const N = I, D = N.selectionStart || 0, $ = N.value || "", R = N.selectionEnd || D;
5117
5170
  if (R > D) {
5118
- const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(R);
5119
- h(W, {}, o);
5171
+ const U = `{{${k}}}`, { text: z } = T($, D, U), W = $.slice(0, D) + z + $.slice(R);
5172
+ m(W, {}, o);
5120
5173
  return;
5121
5174
  }
5122
- const $ = `{{${k}}}`, { text: H } = T(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5123
- h(F, {}, o);
5175
+ const M = `{{${k}}}`, { text: H } = T($, D, M), F = $.slice(0, D) + H + $.slice(D);
5176
+ m(F, {}, o);
5124
5177
  }
5125
5178
  },
5126
- [o, h, g, E == null ? void 0 : E._id]
5179
+ [o, m, g, E == null ? void 0 : E._id]
5127
5180
  );
5128
5181
  if (d)
5129
5182
  return null;
@@ -5166,7 +5219,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5166
5219
  ] }),
5167
5220
  p && u.type !== "object" ? " *" : null
5168
5221
  ] }),
5169
- u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: C, dataType: "value" })
5222
+ u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: C, dataType: "value" })
5170
5223
  ] }),
5171
5224
  c,
5172
5225
  a,
@@ -5179,8 +5232,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5179
5232
  /* @__PURE__ */ jsx("span", { children: "Add" })
5180
5233
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5181
5234
  const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
5182
- async ({ formData: g }, h) => {
5183
- l({ formData: g }, h);
5235
+ async ({ formData: g }, m) => {
5236
+ l({ formData: g }, m);
5184
5237
  },
5185
5238
  [l, i],
5186
5239
  400
@@ -5204,7 +5257,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5204
5257
  ...d
5205
5258
  },
5206
5259
  templates: {
5207
- FieldTemplate: CustomFieldTemplate,
5260
+ FieldTemplate: JSONFormFieldTemplate,
5208
5261
  ButtonTemplates: {
5209
5262
  AddButton: CustomAddButton
5210
5263
  },
@@ -5219,10 +5272,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5219
5272
  uiSchema: r,
5220
5273
  schema: n,
5221
5274
  formData: a,
5222
- onChange: ({ formData: g }, h) => {
5223
- if (!h || o !== (g == null ? void 0 : g._id)) return;
5224
- const m = take(h.split("."), 2).join(".").replace("root.", "");
5225
- u({ formData: g }, m);
5275
+ onChange: ({ formData: g }, m) => {
5276
+ if (!m || o !== (g == null ? void 0 : g._id)) return;
5277
+ const h = take(m.split("."), 2).join(".").replace("root.", "");
5278
+ u({ formData: g }, h);
5226
5279
  }
5227
5280
  },
5228
5281
  i
@@ -5265,7 +5318,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5265
5318
  }), a;
5266
5319
  };
5267
5320
  function BlockSettings() {
5268
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: j }, S, C) => {
5321
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: j }, S, C) => {
5269
5322
  S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(j, S) }, C);
5270
5323
  }, x = useCallback(
5271
5324
  debounce(({ formData: j }, S, C) => {
@@ -5278,7 +5331,7 @@ function BlockSettings() {
5278
5331
  S && (r([g._id], { [S]: get(j, S) }), x({ formData: j }, S, { [S]: get(c, S) }));
5279
5332
  };
5280
5333
  keys(get(i, "_bindings", {}));
5281
- const { schema: A, uiSchema: E } = useMemo(() => {
5334
+ const { schema: B, uiSchema: E } = useMemo(() => {
5282
5335
  const j = n == null ? void 0 : n._type;
5283
5336
  if (j)
5284
5337
  return getBlockFormSchemas(j);
@@ -5313,19 +5366,19 @@ function BlockSettings() {
5313
5366
  {
5314
5367
  blockId: g == null ? void 0 : g._id,
5315
5368
  onChange: y,
5316
- formData: m,
5369
+ formData: h,
5317
5370
  schema: w,
5318
5371
  uiSchema: _
5319
5372
  }
5320
5373
  ) })
5321
5374
  ] }),
5322
- isEmpty(A) ? null : /* @__PURE__ */ jsx(
5375
+ isEmpty(B) ? null : /* @__PURE__ */ jsx(
5323
5376
  JSONForm,
5324
5377
  {
5325
5378
  blockId: n == null ? void 0 : n._id,
5326
5379
  onChange: b,
5327
5380
  formData: i,
5328
- schema: A,
5381
+ schema: B,
5329
5382
  uiSchema: E
5330
5383
  }
5331
5384
  ),
@@ -5431,12 +5484,12 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5431
5484
  canvas: n = !1,
5432
5485
  tooltip: r = !0
5433
5486
  }) => {
5434
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5435
- u.includes(y) ? u.length > 2 && g(u.filter((A) => A !== y)) : g((A) => [...A, y]);
5487
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
5488
+ u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
5436
5489
  }, x = (y) => {
5437
5490
  n || l(y), c(y);
5438
5491
  }, b = getBreakpointValue(n ? i : a).toLowerCase();
5439
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (y) => /* @__PURE__ */ createElement(
5492
+ return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
5440
5493
  BreakpointCard,
5441
5494
  {
5442
5495
  canvas: n,
@@ -5447,7 +5500,7 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5447
5500
  }
5448
5501
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5449
5502
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5450
- m.filter((y) => includes(u, toUpper(y.breakpoint))),
5503
+ h.filter((y) => includes(u, toUpper(y.breakpoint))),
5451
5504
  (y) => /* @__PURE__ */ createElement(
5452
5505
  BreakpointCard,
5453
5506
  {
@@ -5464,15 +5517,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5464
5517
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5465
5518
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
5466
5519
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5467
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
5520
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
5468
5521
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5469
- map(m, (y) => /* @__PURE__ */ jsx(
5522
+ map(h, (y) => /* @__PURE__ */ jsx(
5470
5523
  DropdownMenuCheckboxItem,
5471
5524
  {
5472
5525
  disabled: y.breakpoint === "xs",
5473
5526
  onCheckedChange: () => f(toUpper(y.breakpoint)),
5474
5527
  checked: includes(u, toUpper(y.breakpoint)),
5475
- children: h(y.title)
5528
+ children: m(y.title)
5476
5529
  },
5477
5530
  y.breakpoint
5478
5531
  ))
@@ -5551,11 +5604,11 @@ function Countdown() {
5551
5604
  const AskAIStyles = ({ blockId: o }) => {
5552
5605
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
5553
5606
  useEffect(() => {
5554
- var m;
5555
- (m = d.current) == null || m.focus();
5607
+ var h;
5608
+ (h = d.current) == null || h.focus();
5556
5609
  }, []);
5557
- const h = (m) => {
5558
- const { usage: f } = m || {};
5610
+ const m = (h) => {
5611
+ const { usage: f } = h || {};
5559
5612
  !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5560
5613
  };
5561
5614
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -5565,12 +5618,12 @@ const AskAIStyles = ({ blockId: o }) => {
5565
5618
  {
5566
5619
  ref: d,
5567
5620
  value: i,
5568
- onChange: (m) => c(m.target.value),
5621
+ onChange: (h) => c(h.target.value),
5569
5622
  placeholder: n("Ask AI to edit styles"),
5570
5623
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5571
5624
  rows: 4,
5572
- onKeyDown: (m) => {
5573
- m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h));
5625
+ onKeyDown: (h) => {
5626
+ h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5574
5627
  }
5575
5628
  }
5576
5629
  ),
@@ -5580,7 +5633,7 @@ const AskAIStyles = ({ blockId: o }) => {
5580
5633
  {
5581
5634
  disabled: i.trim().length < 5 || a,
5582
5635
  onClick: () => {
5583
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h);
5636
+ p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
5584
5637
  },
5585
5638
  variant: "default",
5586
5639
  className: "w-fit",
@@ -5612,17 +5665,17 @@ const AskAIStyles = ({ blockId: o }) => {
5612
5665
  };
5613
5666
  function ManualClasses() {
5614
5667
  var T;
5615
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), A = y.split(" ").filter((I) => !isEmpty(I)), E = () => {
5668
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), B = y.split(" ").filter((I) => !isEmpty(I)), E = () => {
5616
5669
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5617
- u(h, I, !0), x("");
5670
+ u(m, I, !0), x("");
5618
5671
  }, [w, _] = useState([]), j = ({ value: I }) => {
5619
5672
  const P = I.trim().toLowerCase(), N = P.match(/.+:/g);
5620
5673
  let D = [];
5621
5674
  if (N && N.length > 0) {
5622
- const [M] = N, R = P.replace(M, "");
5623
- D = i.search(R).map(($) => ({
5624
- ...$,
5625
- item: { ...$.item, name: M + $.item.name }
5675
+ const [$] = N, R = P.replace($, "");
5676
+ D = i.search(R).map((M) => ({
5677
+ ...M,
5678
+ item: { ...M.item, name: $ + M.item.name }
5626
5679
  }));
5627
5680
  } else
5628
5681
  D = i.search(P);
@@ -5648,24 +5701,24 @@ function ManualClasses() {
5648
5701
  ), k = (I) => {
5649
5702
  debugger;
5650
5703
  const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5651
- g(h, [I]), u(h, P, !0), r(""), l(-1);
5652
- }, B = () => {
5704
+ g(m, [I]), u(m, P, !0), r(""), l(-1);
5705
+ }, A = () => {
5653
5706
  if (navigator.clipboard === void 0) {
5654
5707
  toast.error(c("Clipboard not supported"));
5655
5708
  return;
5656
5709
  }
5657
- navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
5710
+ navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
5658
5711
  };
5659
5712
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5660
5713
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5661
5714
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5662
5715
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5663
5716
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5664
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: B, className: "cursor-pointer" }) }),
5717
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: A, className: "cursor-pointer" }) }),
5665
5718
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5666
5719
  ] })
5667
5720
  ] }),
5668
- m ? /* @__PURE__ */ jsxs(Popover, { children: [
5721
+ h ? /* @__PURE__ */ jsxs(Popover, { children: [
5669
5722
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
5670
5723
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
5671
5724
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -5705,7 +5758,7 @@ function ManualClasses() {
5705
5758
  }
5706
5759
  )
5707
5760
  ] }),
5708
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5761
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
5709
5762
  (I, P) => a === P ? /* @__PURE__ */ jsx(
5710
5763
  "input",
5711
5764
  {
@@ -5730,7 +5783,7 @@ function ManualClasses() {
5730
5783
  n !== I && /* @__PURE__ */ jsx(
5731
5784
  Cross2Icon,
5732
5785
  {
5733
- onClick: () => g(h, [I], !0),
5786
+ onClick: () => g(m, [I], !0),
5734
5787
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5735
5788
  }
5736
5789
  )
@@ -6076,7 +6129,7 @@ const COLOR_PROP = {
6076
6129
  ringColor: "ring",
6077
6130
  ringOffsetColor: "ring-offset"
6078
6131
  }, ColorChoice = ({ property: o, onChange: n }) => {
6079
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
6132
+ const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
6080
6133
  // eslint-disable-next-line no-shadow
6081
6134
  (b) => {
6082
6135
  ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
@@ -6109,7 +6162,7 @@ const COLOR_PROP = {
6109
6162
  disabled: !l,
6110
6163
  rounded: !0,
6111
6164
  selected: g,
6112
- onChange: m,
6165
+ onChange: h,
6113
6166
  options: [
6114
6167
  "current",
6115
6168
  "transparent",
@@ -6142,7 +6195,7 @@ const COLOR_PROP = {
6142
6195
  ]
6143
6196
  }
6144
6197
  ) }),
6145
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
6198
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: f, options: i }) })
6146
6199
  ] });
6147
6200
  }, IconChoices = ({ property: o, onChange: n }) => {
6148
6201
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
@@ -6339,14 +6392,14 @@ const COLOR_PROP = {
6339
6392
  },
6340
6393
  a
6341
6394
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6342
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [A, E] = useState(!1), [w, _] = useState(!1);
6395
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [b, y] = useState(""), [B, E] = useState(!1), [w, _] = useState(!1);
6343
6396
  useEffect(() => {
6344
6397
  const { value: v, unit: k } = getClassValueAndUnit(i);
6345
6398
  if (k === "") {
6346
- l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6399
+ l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6347
6400
  return;
6348
6401
  }
6349
- m(k), l(k === "class" || isEmpty(v) ? "" : v);
6402
+ h(k), l(k === "class" || isEmpty(v) ? "" : v);
6350
6403
  }, [i, p, u]);
6351
6404
  const j = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), S = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), C = useCallback(
6352
6405
  (v = !1) => {
@@ -6355,17 +6408,17 @@ const COLOR_PROP = {
6355
6408
  x(!0);
6356
6409
  return;
6357
6410
  }
6358
- const B = get(k, "unit") !== "" ? get(k, "unit") : h;
6359
- if (B === "auto" || B === "none") {
6360
- j(`${d}${B}`);
6411
+ const A = get(k, "unit") !== "" ? get(k, "unit") : m;
6412
+ if (A === "auto" || A === "none") {
6413
+ j(`${d}${A}`);
6361
6414
  return;
6362
6415
  }
6363
6416
  if (get(k, "value") === "")
6364
6417
  return;
6365
- const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6418
+ const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6366
6419
  v ? S(I) : j(I);
6367
6420
  },
6368
- [j, S, a, h, d, u]
6421
+ [j, S, a, m, d, u]
6369
6422
  ), L = useCallback(
6370
6423
  (v) => {
6371
6424
  const k = getUserInputValues(`${a}`, u);
@@ -6379,12 +6432,12 @@ const COLOR_PROP = {
6379
6432
  }
6380
6433
  if (get(k, "value") === "")
6381
6434
  return;
6382
- const B = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6435
+ const A = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${A === "-" ? "" : A}]`;
6383
6436
  j(I);
6384
6437
  },
6385
6438
  [j, a, d, u]
6386
6439
  );
6387
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6440
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6388
6441
  /* @__PURE__ */ jsx(
6389
6442
  "input",
6390
6443
  {
@@ -6397,12 +6450,12 @@ const COLOR_PROP = {
6397
6450
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
6398
6451
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6399
6452
  ] })
6400
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6453
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
6401
6454
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6402
- ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
6455
+ ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6403
6456
  "input",
6404
6457
  {
6405
- readOnly: h === "class",
6458
+ readOnly: m === "class",
6406
6459
  onKeyPress: (v) => {
6407
6460
  v.key === "Enter" && C();
6408
6461
  },
@@ -6411,9 +6464,9 @@ const COLOR_PROP = {
6411
6464
  return;
6412
6465
  v.preventDefault(), _(!0);
6413
6466
  const k = parseInt$1(v.target.value);
6414
- let B = isNaN$1(k) ? 0 : k;
6415
- v.keyCode === 38 && (B += 1), v.keyCode === 40 && (B -= 1);
6416
- const T = `${B}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
6467
+ let A = isNaN$1(k) ? 0 : k;
6468
+ v.keyCode === 38 && (A += 1), v.keyCode === 40 && (A -= 1);
6469
+ const T = `${A}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
6417
6470
  S(P);
6418
6471
  },
6419
6472
  onKeyUp: (v) => {
@@ -6427,7 +6480,7 @@ const COLOR_PROP = {
6427
6480
  var k;
6428
6481
  (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6429
6482
  },
6430
- value: A ? b : a,
6483
+ value: B ? b : a,
6431
6484
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6432
6485
  " ",
6433
6486
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6442,7 +6495,7 @@ const COLOR_PROP = {
6442
6495
  onClick: () => r(!n),
6443
6496
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
6444
6497
  children: [
6445
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
6498
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
6446
6499
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
6447
6500
  ]
6448
6501
  }
@@ -6451,33 +6504,33 @@ const COLOR_PROP = {
6451
6504
  UnitSelection,
6452
6505
  {
6453
6506
  units: u,
6454
- current: h,
6507
+ current: m,
6455
6508
  onSelect: (v) => {
6456
- r(!1), m(v), L(v);
6509
+ r(!1), h(v), L(v);
6457
6510
  }
6458
6511
  }
6459
6512
  ) }) })
6460
6513
  ] })
6461
6514
  ] }),
6462
- ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
6515
+ ["none", "auto"].indexOf(m) !== -1 || B ? null : /* @__PURE__ */ jsx(
6463
6516
  DragStyleButton,
6464
6517
  {
6465
6518
  onDragStart: () => E(!0),
6466
6519
  onDragEnd: (v) => {
6467
6520
  if (y(() => ""), E(!1), isEmpty(v))
6468
6521
  return;
6469
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
6522
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6470
6523
  j(T);
6471
6524
  },
6472
6525
  onDrag: (v) => {
6473
6526
  if (isEmpty(v))
6474
6527
  return;
6475
6528
  y(v);
6476
- const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
6529
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
6477
6530
  S(T);
6478
6531
  },
6479
6532
  currentValue: a,
6480
- unit: h,
6533
+ unit: m,
6481
6534
  negative: g,
6482
6535
  cssProperty: p
6483
6536
  }
@@ -6571,20 +6624,20 @@ const COLOR_PROP = {
6571
6624
  "2xl": "1536px"
6572
6625
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6573
6626
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6574
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(h, "fullCls", ""), [h]), y = useCallback(
6627
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6575
6628
  (S, C = !0) => {
6576
6629
  const L = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6577
6630
  (p || u !== "") && (L.mq = "xs");
6578
6631
  const v = generateFullClsName(L);
6579
- m(x, [v], C);
6632
+ h(x, [v], C);
6580
6633
  },
6581
- [x, p, g, u, l, m]
6582
- ), A = useCallback(() => {
6634
+ [x, p, g, u, l, h]
6635
+ ), B = useCallback(() => {
6583
6636
  f(x, [b], !0);
6584
- }, [x, b, f]), E = useMemo(() => canChangeClass(h, g), [h, g]);
6637
+ }, [x, b, f]), E = useMemo(() => canChangeClass(m, g), [m, g]);
6585
6638
  useEffect(() => {
6586
- i(E, h);
6587
- }, [E, i, h]);
6639
+ i(E, m);
6640
+ }, [E, i, m]);
6588
6641
  const [, , w] = useScreenSizeWidth(), _ = useCallback(
6589
6642
  (S) => {
6590
6643
  w({
@@ -6597,15 +6650,15 @@ const COLOR_PROP = {
6597
6650
  }[S]);
6598
6651
  },
6599
6652
  [w]
6600
- ), j = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6601
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6602
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6653
+ ), j = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6654
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: m && j, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6655
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !j ? "text-foreground" : ""}`, children: n(a) }) }),
6603
6656
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6604
6657
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6605
6658
  r === "arbitrary" ? /* @__PURE__ */ jsx(
6606
6659
  AdvanceChoices,
6607
6660
  {
6608
- currentClass: get(h, "cls", ""),
6661
+ currentClass: get(m, "cls", ""),
6609
6662
  classPrefix: get(CLASS_PREFIXES, l, ""),
6610
6663
  units: c || [],
6611
6664
  onChange: y,
@@ -6618,7 +6671,7 @@ const COLOR_PROP = {
6618
6671
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6619
6672
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6620
6673
  ] }),
6621
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6674
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: j ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6622
6675
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6623
6676
  "button",
6624
6677
  {
@@ -6630,19 +6683,19 @@ const COLOR_PROP = {
6630
6683
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
6631
6684
  "Current style is set at  ",
6632
6685
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
6633
- getBreakpoint(get(h, "mq")),
6634
- p && !h.dark ? "(Light mode)" : ""
6686
+ getBreakpoint(get(m, "mq")),
6687
+ p && !m.dark ? "(Light mode)" : ""
6635
6688
  ] }),
6636
6689
  /* @__PURE__ */ jsx("br", {}),
6637
6690
  /* @__PURE__ */ jsxs(
6638
6691
  "button",
6639
6692
  {
6640
6693
  type: "button",
6641
- onClick: () => _(get(h, "mq")),
6694
+ onClick: () => _(get(m, "mq")),
6642
6695
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6643
6696
  children: [
6644
6697
  "Switch to ",
6645
- get(h, "mq").toUpperCase()
6698
+ get(m, "mq").toUpperCase()
6646
6699
  ]
6647
6700
  }
6648
6701
  )
@@ -6659,7 +6712,7 @@ const COLOR_PROP = {
6659
6712
  units: i = basicUnits,
6660
6713
  negative: c = !1
6661
6714
  }) => {
6662
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
6715
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6663
6716
  return /* @__PURE__ */ jsxs(
6664
6717
  "div",
6665
6718
  {
@@ -6668,7 +6721,7 @@ const COLOR_PROP = {
6668
6721
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6669
6722
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6670
6723
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6671
- n.map(({ label: m, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6724
+ n.map(({ label: h, key: f }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6672
6725
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6673
6726
  "button",
6674
6727
  {
@@ -6677,13 +6730,13 @@ const COLOR_PROP = {
6677
6730
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6678
6731
  children: [
6679
6732
  React__default.createElement("div", {
6680
- className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6733
+ className: m(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6681
6734
  }),
6682
6735
  React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
6683
6736
  ]
6684
6737
  }
6685
6738
  ) }),
6686
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
6739
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
6687
6740
  ] }) }))
6688
6741
  ) })
6689
6742
  ] }),
@@ -6822,13 +6875,13 @@ function BlockStyling() {
6822
6875
  cssProperty: ""
6823
6876
  }), d = useThrottledCallback(
6824
6877
  (u) => {
6825
- const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6826
- let m = parseFloat(i.dragStartValue);
6827
- m = isNaN(m) ? 0 : m;
6878
+ const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6879
+ let h = parseFloat(i.dragStartValue);
6880
+ h = isNaN(h) ? 0 : h;
6828
6881
  let f = MAPPER[i.dragUnit];
6829
- (startsWith(h, "scale") || h === "opacity") && (f = 10);
6830
- let b = (i.dragStartY - u.pageY) / f + m;
6831
- g && b < 0 && (b = 0), h === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6882
+ (startsWith(m, "scale") || m === "opacity") && (f = 10);
6883
+ let b = (i.dragStartY - u.pageY) / f + h;
6884
+ g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6832
6885
  },
6833
6886
  [i],
6834
6887
  50
@@ -6870,7 +6923,7 @@ const CoreBlock = ({
6870
6923
  parentId: r,
6871
6924
  position: a
6872
6925
  }) => {
6873
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6926
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6874
6927
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6875
6928
  const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6876
6929
  u(syncBlocksWithDefaults(b), r || null, a);
@@ -6883,11 +6936,11 @@ const CoreBlock = ({
6883
6936
  "button",
6884
6937
  {
6885
6938
  disabled: n,
6886
- onClick: m,
6939
+ onClick: h,
6887
6940
  type: "button",
6888
6941
  onDragStart: (b) => {
6889
6942
  b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6890
- g([]), h();
6943
+ g([]), m();
6891
6944
  }, 200);
6892
6945
  },
6893
6946
  draggable: f ? "true" : "false",
@@ -7086,7 +7139,7 @@ const CoreBlock = ({
7086
7139
  }
7087
7140
  }
7088
7141
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7089
- var h, m, f, x, b, y, A, E;
7142
+ var m, h, f, x, b, y, B, E;
7090
7143
  if (r.type === "comment") return [];
7091
7144
  console.log("node ===>", r);
7092
7145
  let a = { _id: generateUUID() };
@@ -7127,12 +7180,12 @@ const CoreBlock = ({
7127
7180
  ];
7128
7181
  a = {
7129
7182
  ...a,
7130
- href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
7131
- hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7183
+ href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
7184
+ hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
7132
7185
  autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
7133
7186
  maxWidth: ((b = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7134
7187
  backdropColor: ((y = l.find((_) => _.key === "data-overlay")) == null ? void 0 : y.value) || "",
7135
- galleryName: ((A = l.find((_) => _.key === "data-gall")) == null ? void 0 : A.value) || ""
7188
+ galleryName: ((B = l.find((_) => _.key === "data-gall")) == null ? void 0 : B.value) || ""
7136
7189
  }, forEach(w, (_) => {
7137
7190
  has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
7138
7191
  });
@@ -7237,8 +7290,8 @@ const CoreBlock = ({
7237
7290
  error: c
7238
7291
  }), g(!0);
7239
7292
  else if (!l && Object.keys(a || {}).length > 0) {
7240
- const m = Object.entries(a).map(([x, b]) => {
7241
- const y = b, A = y.type || "partial", E = formatReadableName(A);
7293
+ const h = Object.entries(a).map(([x, b]) => {
7294
+ const y = b, B = y.type || "partial", E = formatReadableName(B);
7242
7295
  return {
7243
7296
  type: "PartialBlock",
7244
7297
  // Set the type to PartialBlock
@@ -7252,14 +7305,14 @@ const CoreBlock = ({
7252
7305
  // Store the original ID as partialBlockId
7253
7306
  _name: y.name
7254
7307
  };
7255
- }), f = uniq(map(m, "group"));
7308
+ }), f = uniq(map(h, "group"));
7256
7309
  p({
7257
- blocks: m,
7310
+ blocks: h,
7258
7311
  groups: f,
7259
7312
  isLoading: !1,
7260
7313
  error: null
7261
7314
  }), g(!0);
7262
- } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7315
+ } else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7263
7316
  blocks: [],
7264
7317
  groups: [],
7265
7318
  isLoading: !1,
@@ -7274,15 +7327,15 @@ const CoreBlock = ({
7274
7327
  d.blocks,
7275
7328
  c
7276
7329
  ]);
7277
- const h = () => {
7278
- p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7330
+ const m = () => {
7331
+ p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7279
7332
  };
7280
7333
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7281
7334
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7282
7335
  /* @__PURE__ */ jsx(
7283
7336
  "button",
7284
7337
  {
7285
- onClick: h,
7338
+ onClick: m,
7286
7339
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7287
7340
  children: "Refresh"
7288
7341
  }
@@ -7299,11 +7352,11 @@ const CoreBlock = ({
7299
7352
  );
7300
7353
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7301
7354
  var v;
7302
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7355
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [h, f] = useState("all"), [x, b] = useState(null), y = useRef(null);
7303
7356
  useEffect(() => {
7304
7357
  const k = setTimeout(() => {
7305
- var B;
7306
- (B = u.current) == null || B.focus();
7358
+ var A;
7359
+ (A = u.current) == null || A.focus();
7307
7360
  }, 0);
7308
7361
  return () => clearTimeout(k);
7309
7362
  }, [g]), useEffect(() => {
@@ -7313,7 +7366,7 @@ const CoreBlock = ({
7313
7366
  }, 500), () => {
7314
7367
  y.current && y.current.cancel();
7315
7368
  }), []);
7316
- const A = useCallback((k) => {
7369
+ const B = useCallback((k) => {
7317
7370
  b(k), y.current && y.current(k);
7318
7371
  }, []), E = useCallback(() => {
7319
7372
  b(null), y.current && y.current.cancel();
@@ -7322,8 +7375,8 @@ const CoreBlock = ({
7322
7375
  }, []), _ = useMemo(
7323
7376
  () => d ? values(n).filter(
7324
7377
  (k) => {
7325
- var B, T;
7326
- return (((B = k.label) == null ? void 0 : B.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7378
+ var A, T;
7379
+ return (((A = k.label) == null ? void 0 : A.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7327
7380
  }
7328
7381
  ) : n,
7329
7382
  [n, d]
@@ -7335,7 +7388,7 @@ const CoreBlock = ({
7335
7388
  ), S = useMemo(
7336
7389
  () => sortBy(j, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7337
7390
  [j]
7338
- ), C = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), L = useMemo(() => m === "all" ? S : [m], [S, m]);
7391
+ ), C = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), L = useMemo(() => h === "all" ? S : [h], [S, h]);
7339
7392
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7340
7393
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7341
7394
  Input$1,
@@ -7354,9 +7407,9 @@ const CoreBlock = ({
7354
7407
  "button",
7355
7408
  {
7356
7409
  onClick: () => w("all"),
7357
- onMouseEnter: () => A("all"),
7410
+ onMouseEnter: () => B("all"),
7358
7411
  onMouseLeave: E,
7359
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7412
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7360
7413
  children: i("All")
7361
7414
  },
7362
7415
  "sidebar-all"
@@ -7365,9 +7418,9 @@ const CoreBlock = ({
7365
7418
  "button",
7366
7419
  {
7367
7420
  onClick: () => w(k),
7368
- onMouseEnter: () => A(k),
7421
+ onMouseEnter: () => B(k),
7369
7422
  onMouseLeave: E,
7370
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7423
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7371
7424
  children: capitalize(i(k.toLowerCase()))
7372
7425
  },
7373
7426
  `sidebar-${k}`
@@ -7382,17 +7435,17 @@ const CoreBlock = ({
7382
7435
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7383
7436
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7384
7437
  reject(
7385
- m === "all" ? filter(values(C), { group: k }) : values(C),
7438
+ h === "all" ? filter(values(C), { group: k }) : values(C),
7386
7439
  { hidden: !0 }
7387
- ).map((B) => /* @__PURE__ */ jsx(
7440
+ ).map((A) => /* @__PURE__ */ jsx(
7388
7441
  CoreBlock,
7389
7442
  {
7390
7443
  parentId: r,
7391
7444
  position: a,
7392
- block: B,
7393
- disabled: !canAcceptChildBlock(h, B.type) || !canBeNestedInside(h, B.type)
7445
+ block: A,
7446
+ disabled: !canAcceptChildBlock(m, A.type) || !canBeNestedInside(m, A.type)
7394
7447
  },
7395
- B.type
7448
+ A.type
7396
7449
  ))
7397
7450
  ) })
7398
7451
  ] }, k)) }) }) })
@@ -7404,11 +7457,11 @@ const CoreBlock = ({
7404
7457
  parentId: r = void 0,
7405
7458
  position: a = -1
7406
7459
  }) => {
7407
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), h = Object.keys(g || {}).length > 0;
7460
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), m = Object.keys(g || {}).length > 0;
7408
7461
  useEffect(() => {
7409
- i === "partials" && !h && c("library");
7410
- }, [i, h, c]);
7411
- const m = useCallback(() => {
7462
+ i === "partials" && !m && c("library");
7463
+ }, [i, m, c]);
7464
+ const h = useCallback(() => {
7412
7465
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7413
7466
  }, []);
7414
7467
  return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7428,15 +7481,15 @@ const CoreBlock = ({
7428
7481
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7429
7482
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7430
7483
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7431
- h && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7484
+ m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7432
7485
  p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7433
7486
  map(u, (f) => /* @__PURE__ */ jsx(TabsTrigger, { value: f.key, children: React__default.createElement(f.tab) }))
7434
7487
  ] }),
7435
7488
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7436
7489
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7437
- h && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7490
+ m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7438
7491
  p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7439
- map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: m, parentId: r, position: a }) }))
7492
+ map(u, (f) => /* @__PURE__ */ jsx(TabsContent, { value: f.key, children: React__default.createElement(f.tabContent, { close: h, parentId: r, position: a }) }))
7440
7493
  ]
7441
7494
  }
7442
7495
  )
@@ -7493,12 +7546,12 @@ const BlockCard = ({
7493
7546
  parentId: r = void 0,
7494
7547
  position: a = -1
7495
7548
  }) => {
7496
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (A) => {
7497
- const E = has(A, "styles_attrs.data-page-section");
7498
- return A._type === "Box" && E;
7549
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), x = (B) => {
7550
+ const E = has(B, "styles_attrs.data-page-section");
7551
+ return B._type === "Box" && E;
7499
7552
  }, b = useCallback(
7500
- async (A) => {
7501
- if (A.stopPropagation(), has(o, "component")) {
7553
+ async (B) => {
7554
+ if (B.stopPropagation(), has(o, "component")) {
7502
7555
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7503
7556
  return;
7504
7557
  }
@@ -7514,19 +7567,19 @@ const BlockCard = ({
7514
7567
  {
7515
7568
  onClick: l ? () => {
7516
7569
  } : b,
7517
- draggable: m ? "true" : "false",
7518
- onDragStart: async (A) => {
7570
+ draggable: h ? "true" : "false",
7571
+ onDragStart: async (B) => {
7519
7572
  const E = await c(n, o);
7520
7573
  let w = r;
7521
7574
  if (x(first(E)) && (w = null), !isEmpty(E)) {
7522
7575
  const _ = { blocks: E, uiLibrary: !0, parent: w };
7523
- if (A.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
7576
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
7524
7577
  const j = new Image();
7525
7578
  j.src = o.preview, j.onload = () => {
7526
- A.dataTransfer.setDragImage(j, 0, 0);
7579
+ B.dataTransfer.setDragImage(j, 0, 0);
7527
7580
  };
7528
7581
  } else
7529
- A.dataTransfer.setDragImage(new Image(), 0, 0);
7582
+ B.dataTransfer.setDragImage(new Image(), 0, 0);
7530
7583
  f(_), setTimeout(() => {
7531
7584
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7532
7585
  }, 200);
@@ -7540,11 +7593,11 @@ const BlockCard = ({
7540
7593
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
7541
7594
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7542
7595
  ] }),
7543
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: h }) })
7596
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
7544
7597
  ]
7545
7598
  }
7546
7599
  ) }),
7547
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: h }) })
7600
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
7548
7601
  ] });
7549
7602
  }, libraryBlocksAtom = atom$1(
7550
7603
  {}
@@ -7559,9 +7612,9 @@ const BlockCard = ({
7559
7612
  })();
7560
7613
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7561
7614
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7562
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [h, m] = useState("Hero"), f = get(g, h, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
7615
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, h] = useState("Hero"), f = get(g, m, []), x = useRef(null), { t: b } = useTranslation(), y = (w) => {
7563
7616
  x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7564
- x.current && m(w);
7617
+ x.current && h(w);
7565
7618
  }, 300);
7566
7619
  };
7567
7620
  if (u)
@@ -7569,7 +7622,7 @@ const BlockCard = ({
7569
7622
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7570
7623
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7571
7624
  ] });
7572
- const A = filter(f, (w, _) => _ % 2 === 0), E = filter(f, (w, _) => _ % 2 === 1);
7625
+ const B = filter(f, (w, _) => _ % 2 === 0), E = filter(f, (w, _) => _ % 2 === 1);
7573
7626
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
7574
7627
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7575
7628
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
@@ -7582,10 +7635,10 @@ const BlockCard = ({
7582
7635
  {
7583
7636
  onMouseEnter: () => y(_),
7584
7637
  onMouseLeave: () => clearTimeout(x.current),
7585
- onClick: () => m(_),
7638
+ onClick: () => h(_),
7586
7639
  className: cn$1(
7587
7640
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7588
- _ === h ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7641
+ _ === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7589
7642
  ),
7590
7643
  children: [
7591
7644
  /* @__PURE__ */ jsx("span", { children: capitalize(b(_.toLowerCase())) }),
@@ -7605,7 +7658,7 @@ const BlockCard = ({
7605
7658
  children: [
7606
7659
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7607
7660
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7608
- A.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7661
+ B.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7609
7662
  ) }),
7610
7663
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7611
7664
  E.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
@@ -7703,11 +7756,11 @@ const BlockCard = ({
7703
7756
  );
7704
7757
  }, RenameBlock = ({ node: o }) => {
7705
7758
  const { t: n } = useTranslation();
7706
- return console.log(o), /* @__PURE__ */ jsxs(
7759
+ return /* @__PURE__ */ jsxs(
7707
7760
  DropdownMenuItem,
7708
7761
  {
7709
7762
  onClick: (r) => {
7710
- r.stopPropagation(), console.log(o), o.edit(), o.deselect();
7763
+ r.stopPropagation(), o.edit(), o.deselect();
7711
7764
  },
7712
7765
  className: "flex items-center gap-x-4 text-xs",
7713
7766
  children: [
@@ -7718,7 +7771,7 @@ const BlockCard = ({
7718
7771
  }
7719
7772
  );
7720
7773
  }, BlockContextMenuContent = ({ node: o }) => {
7721
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useCallback(() => {
7774
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), i = useBuilderProp("blockMoreOptions", []), c = useCallback(() => {
7722
7775
  a(r);
7723
7776
  }, [r, a]);
7724
7777
  return /* @__PURE__ */ jsxs(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: [
@@ -7740,7 +7793,7 @@ const BlockCard = ({
7740
7793
  {
7741
7794
  disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7742
7795
  className: "flex items-center gap-x-4 text-xs",
7743
- onClick: i,
7796
+ onClick: c,
7744
7797
  children: [
7745
7798
  /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7746
7799
  " ",
@@ -7751,7 +7804,8 @@ const BlockCard = ({
7751
7804
  /* @__PURE__ */ jsx(RenameBlock, { node: o }),
7752
7805
  /* @__PURE__ */ jsx(CutBlocks, {}),
7753
7806
  /* @__PURE__ */ jsx(CopyPasteBlocks, {}),
7754
- /* @__PURE__ */ jsx(RemoveBlocks, {})
7807
+ /* @__PURE__ */ jsx(RemoveBlocks, {}),
7808
+ i.map((d, p) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("span", { children: "Loading..." }), children: React__default.createElement(d, { block: l }) }, `more-${p}`))
7755
7809
  ] });
7756
7810
  }, BlockMoreOptions = ({ children: o, id: n, node: r }) => {
7757
7811
  const [, a] = useSelectedBlockIds();
@@ -7838,8 +7892,8 @@ const selectParent = (o, n) => {
7838
7892
  var P;
7839
7893
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7840
7894
  let p = null;
7841
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: A, handleClick: E } = o, w = (N) => {
7842
- N.stopPropagation(), !i.includes(m) && o.toggle();
7895
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: E } = o, w = (N) => {
7896
+ N.stopPropagation(), !i.includes(h) && o.toggle();
7843
7897
  }, _ = (N) => {
7844
7898
  N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7845
7899
  }, j = (N) => {
@@ -7850,33 +7904,33 @@ const selectParent = (o, n) => {
7850
7904
  }, v = () => {
7851
7905
  C(null);
7852
7906
  }, k = (N) => {
7853
- v(), N.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), E(N);
7907
+ v(), N.stopPropagation(), !o.isOpen && !i.includes(h) && o.toggle(), E(N);
7854
7908
  };
7855
7909
  useEffect(() => {
7856
7910
  const N = setTimeout(() => {
7857
- b && !o.isOpen && !y && !i.includes(m) && o.toggle();
7911
+ b && !o.isOpen && !y && !i.includes(h) && o.toggle();
7858
7912
  }, 500);
7859
7913
  return () => clearTimeout(N);
7860
7914
  }, [b, o, y]);
7861
- const B = useMemo(() => {
7915
+ const A = useMemo(() => {
7862
7916
  const N = Object.keys(f), D = [];
7863
- for (let M = 0; M < N.length; M++)
7864
- if (N[M].endsWith("_attrs")) {
7865
- const R = f[N[M]], O = Object.keys(R).join("|");
7917
+ for (let $ = 0; $ < N.length; $++)
7918
+ if (N[$].endsWith("_attrs")) {
7919
+ const R = f[N[$]], O = Object.keys(R).join("|");
7866
7920
  O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7867
7921
  }
7868
7922
  return D;
7869
7923
  }, [f]), T = (N, D) => {
7870
- const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${N}]`);
7924
+ const $ = d.contentDocument || d.contentWindow.document, R = $.querySelector(`[data-block-id=${N}]`);
7871
7925
  R && R.setAttribute("data-drop", D);
7872
- const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
7873
- O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
7926
+ const O = R.getBoundingClientRect(), M = d.getBoundingClientRect();
7927
+ O.top >= M.top && O.left >= M.left && O.bottom <= M.bottom && O.right <= M.right || ($.documentElement.scrollTop = R.offsetTop - M.top);
7874
7928
  }, I = (N) => {
7875
7929
  v();
7876
7930
  const D = get(o, "parent.id");
7877
7931
  D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7878
7932
  };
7879
- return m === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7933
+ return h === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7880
7934
  /* @__PURE__ */ jsx("br", {}),
7881
7935
  /* @__PURE__ */ jsx(
7882
7936
  "div",
@@ -7894,22 +7948,22 @@ const selectParent = (o, n) => {
7894
7948
  ] }) : /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7895
7949
  "div",
7896
7950
  {
7897
- onMouseEnter: () => g(m),
7898
- onMouseLeave: () => h(),
7951
+ onMouseEnter: () => g(h),
7952
+ onMouseLeave: () => m(),
7899
7953
  onClick: k,
7900
7954
  style: n,
7901
- "data-node-id": m,
7902
- ref: i.includes(m) ? null : r,
7955
+ "data-node-id": h,
7956
+ ref: i.includes(h) ? null : r,
7903
7957
  onDragStart: () => _(o),
7904
7958
  onDragEnd: () => j(o),
7905
7959
  onDragOver: (N) => {
7906
- N.preventDefault(), T(m, "yes");
7960
+ N.preventDefault(), T(h, "yes");
7907
7961
  },
7908
7962
  onDragLeave: (N) => {
7909
- N.preventDefault(), T(m, "no");
7963
+ N.preventDefault(), T(h, "no");
7910
7964
  },
7911
7965
  onDrop: (N) => {
7912
- N.preventDefault(), T(m, "no");
7966
+ N.preventDefault(), T(h, "no");
7913
7967
  },
7914
7968
  children: [
7915
7969
  (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
@@ -7933,7 +7987,7 @@ const selectParent = (o, n) => {
7933
7987
  b && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7934
7988
  (o == null ? void 0 : o.id) === S ? "bg-purple-100" : "",
7935
7989
  y && "opacity-20",
7936
- i.includes(m) ? "opacity-50" : ""
7990
+ i.includes(h) ? "opacity-50" : ""
7937
7991
  ),
7938
7992
  children: [
7939
7993
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7946,7 +8000,7 @@ const selectParent = (o, n) => {
7946
8000
  ),
7947
8001
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
7948
8002
  /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7949
- A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
8003
+ B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7950
8004
  "div",
7951
8005
  {
7952
8006
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -7955,31 +8009,31 @@ const selectParent = (o, n) => {
7955
8009
  },
7956
8010
  children: [
7957
8011
  /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) }),
7958
- B.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
7959
- B.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
7960
- B.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
8012
+ A.includes("data") && /* @__PURE__ */ jsx(FileJson, { className: "h-3 w-3 text-orange-600" }),
8013
+ A.includes("event") && /* @__PURE__ */ jsx(Zap, { className: "h-3 w-3 text-yellow-500" }),
8014
+ A.includes("show") && /* @__PURE__ */ jsx(EyeOff, { className: "h-3 w-3 text-orange-600" })
7961
8015
  ]
7962
8016
  }
7963
8017
  )
7964
8018
  ] })
7965
8019
  ] }),
7966
8020
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7967
- !i.includes(m) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8021
+ !i.includes(h) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7968
8022
  /* @__PURE__ */ jsx(
7969
8023
  TooltipTrigger,
7970
8024
  {
7971
8025
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
7972
8026
  asChild: !0,
7973
- children: React__default.createElement(N.item, { blockId: m })
8027
+ children: React__default.createElement(N.item, { blockId: h })
7974
8028
  }
7975
8029
  ),
7976
8030
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
7977
8031
  ] })),
7978
- canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(m) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8032
+ canAddChildBlock(f == null ? void 0 : f._type) && !i.includes(h) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7979
8033
  /* @__PURE__ */ jsx(
7980
8034
  TooltipTrigger,
7981
8035
  {
7982
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
8036
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
7983
8037
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7984
8038
  asChild: !0,
7985
8039
  children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
@@ -7992,7 +8046,7 @@ const selectParent = (o, n) => {
7992
8046
  TooltipTrigger,
7993
8047
  {
7994
8048
  onClick: (N) => {
7995
- N.stopPropagation(), c(m), o.isOpen && o.toggle();
8049
+ N.stopPropagation(), c(h), o.isOpen && o.toggle();
7996
8050
  },
7997
8051
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7998
8052
  asChild: !0,
@@ -8001,7 +8055,7 @@ const selectParent = (o, n) => {
8001
8055
  ),
8002
8056
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "left", children: l("Hide block") })
8003
8057
  ] }),
8004
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8058
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
8005
8059
  ] })
8006
8060
  ]
8007
8061
  }
@@ -8650,14 +8704,14 @@ function QuickPrompts({ onClick: o }) {
8650
8704
  ) }) });
8651
8705
  }
8652
8706
  const AIUserPrompt = ({ blockId: o }) => {
8653
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
8707
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
8654
8708
  useEffect(() => {
8655
8709
  var x;
8656
- (x = h.current) == null || x.focus();
8710
+ (x = m.current) == null || x.focus();
8657
8711
  }, []);
8658
8712
  const f = (x) => {
8659
8713
  const { usage: b } = x || {};
8660
- !l && b && g(b), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8714
+ !l && b && g(b), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8661
8715
  };
8662
8716
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8663
8717
  /* @__PURE__ */ jsxs(
@@ -8675,14 +8729,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8675
8729
  /* @__PURE__ */ jsx(
8676
8730
  Textarea,
8677
8731
  {
8678
- ref: h,
8732
+ ref: m,
8679
8733
  value: i,
8680
8734
  onChange: (x) => c(x.target.value),
8681
8735
  placeholder: n("Ask AI to edit content"),
8682
8736
  className: "w-full",
8683
8737
  rows: 3,
8684
8738
  onKeyDown: (x) => {
8685
- x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f));
8739
+ x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f));
8686
8740
  }
8687
8741
  }
8688
8742
  ),
@@ -8692,7 +8746,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8692
8746
  {
8693
8747
  disabled: i.trim().length < 5 || a,
8694
8748
  onClick: () => {
8695
- m.current && clearTimeout(m.current), g(void 0), r("content", o, i, f);
8749
+ h.current && clearTimeout(h.current), g(void 0), r("content", o, i, f);
8696
8750
  },
8697
8751
  variant: "default",
8698
8752
  className: "w-fit",
@@ -8725,7 +8779,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8725
8779
  QuickPrompts,
8726
8780
  {
8727
8781
  onClick: (x) => {
8728
- m.current && clearTimeout(m.current), g(void 0), r("content", o, x, f);
8782
+ h.current && clearTimeout(h.current), g(void 0), r("content", o, x, f);
8729
8783
  }
8730
8784
  }
8731
8785
  )
@@ -8735,13 +8789,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8735
8789
  ] }) }) : null
8736
8790
  ] });
8737
8791
  }, AISetContext = () => {
8738
- const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
8792
+ const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
8739
8793
  useEffect(() => {
8740
8794
  n && a(n);
8741
8795
  }, [n]);
8742
- const m = async () => {
8796
+ const h = async () => {
8743
8797
  try {
8744
- d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), h.current.click();
8798
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8745
8799
  } catch (f) {
8746
8800
  u(f);
8747
8801
  } finally {
@@ -8757,7 +8811,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8757
8811
  type: "single",
8758
8812
  collapsible: !0,
8759
8813
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8760
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8814
+ /* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8761
8815
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8762
8816
  /* @__PURE__ */ jsx(
8763
8817
  Textarea,
@@ -8769,7 +8823,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8769
8823
  className: "mt-1 w-full",
8770
8824
  rows: 10,
8771
8825
  onKeyDown: (f) => {
8772
- f.key === "Enter" && (f.preventDefault(), m());
8826
+ f.key === "Enter" && (f.preventDefault(), h());
8773
8827
  }
8774
8828
  }
8775
8829
  ),
@@ -8781,7 +8835,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8781
8835
  Button,
8782
8836
  {
8783
8837
  disabled: r.trim().length < 5,
8784
- onClick: () => m(),
8838
+ onClick: () => h(),
8785
8839
  variant: "default",
8786
8840
  className: "w-fit",
8787
8841
  size: "sm",
@@ -8810,7 +8864,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8810
8864
  AlertDialogAction,
8811
8865
  {
8812
8866
  onClick: () => {
8813
- a(""), m();
8867
+ a(""), h();
8814
8868
  },
8815
8869
  children: o("Yes, Delete")
8816
8870
  }
@@ -8967,53 +9021,53 @@ const AiAssistant = () => {
8967
9021
  preloadedAttributes: n = [],
8968
9022
  onAttributesChange: r
8969
9023
  }) {
8970
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
9024
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData();
8971
9025
  useEffect(() => {
8972
9026
  l(n);
8973
9027
  }, [n]);
8974
9028
  const y = () => {
8975
9029
  if (i.startsWith("@")) {
8976
- m("Attribute keys cannot start with '@'");
9030
+ h("Attribute keys cannot start with '@'");
8977
9031
  return;
8978
9032
  }
8979
9033
  if (i) {
8980
9034
  const S = [...a, { key: i, value: d }];
8981
- r(S), l(a), c(""), p(""), m("");
9035
+ r(S), l(a), c(""), p(""), h("");
8982
9036
  }
8983
- }, A = (S) => {
9037
+ }, B = (S) => {
8984
9038
  const C = a.filter((L, v) => v !== S);
8985
9039
  r(C), l(C);
8986
9040
  }, E = (S) => {
8987
9041
  g(S), c(a[S].key), p(a[S].value);
8988
9042
  }, w = () => {
8989
9043
  if (i.startsWith("@")) {
8990
- m("Attribute keys cannot start with '@'");
9044
+ h("Attribute keys cannot start with '@'");
8991
9045
  return;
8992
9046
  }
8993
9047
  if (u !== null && i) {
8994
9048
  const S = [...a];
8995
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
9049
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
8996
9050
  }
8997
9051
  }, _ = (S) => {
8998
9052
  S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : y());
8999
9053
  }, j = useCallback((S) => {
9000
- const C = (k) => /[.,!?;:]/.test(k), L = (k, B, T) => {
9054
+ const C = (k) => /[.,!?;:]/.test(k), L = (k, A, T) => {
9001
9055
  let I = "", P = "";
9002
- const N = B > 0 ? k[B - 1] : "", D = B < k.length ? k[B] : "";
9003
- return B > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), B < k.length && !C(D) && D !== " " && (P = " "), {
9056
+ const N = A > 0 ? k[A - 1] : "", D = A < k.length ? k[A] : "";
9057
+ return A > 0 && (N === "." || !C(N) && N !== " ") && (I = " "), A < k.length && !C(D) && D !== " " && (P = " "), {
9004
9058
  text: I + T + P,
9005
9059
  prefixLength: I.length,
9006
9060
  suffixLength: P.length
9007
9061
  };
9008
9062
  }, v = x.current;
9009
9063
  if (v) {
9010
- const k = v.selectionStart || 0, B = v.value || "", T = v.selectionEnd || k;
9064
+ const k = v.selectionStart || 0, A = v.value || "", T = v.selectionEnd || k;
9011
9065
  if (T > k) {
9012
- const M = `{{${S}}}`, { text: R } = L(B, k, M), O = B.slice(0, k) + R + B.slice(T);
9066
+ const $ = `{{${S}}}`, { text: R } = L(A, k, $), O = A.slice(0, k) + R + A.slice(T);
9013
9067
  p(O);
9014
9068
  return;
9015
9069
  }
9016
- const P = `{{${S}}}`, { text: N } = L(B, k, P), D = B.slice(0, k) + N + B.slice(k);
9070
+ const P = `{{${S}}}`, { text: N } = L(A, k, P), D = A.slice(0, k) + N + A.slice(k);
9017
9071
  p(D);
9018
9072
  }
9019
9073
  }, []);
@@ -9068,7 +9122,7 @@ const AiAssistant = () => {
9068
9122
  ] })
9069
9123
  ] }),
9070
9124
  /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
9071
- h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
9125
+ m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9072
9126
  ]
9073
9127
  }
9074
9128
  ),
@@ -9079,7 +9133,7 @@ const AiAssistant = () => {
9079
9133
  ] }),
9080
9134
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9081
9135
  /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => E(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9082
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9136
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9083
9137
  ] })
9084
9138
  ] }, C)) })
9085
9139
  ] });
@@ -9279,7 +9333,7 @@ const RootLayout = () => {
9279
9333
  x.preventDefault();
9280
9334
  }, u = (x) => {
9281
9335
  n(o === x ? null : x);
9282
- }, g = useSidebarMenuItems(), { t: h } = useTranslation(), m = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9336
+ }, g = useSidebarMenuItems(), { t: m } = useTranslation(), h = [...g, ...c], f = useBuilderProp("htmlDir", "ltr");
9283
9337
  return /* @__PURE__ */ jsx("div", { dir: f, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9284
9338
  /* @__PURE__ */ jsxs(
9285
9339
  "div",
@@ -9290,7 +9344,7 @@ const RootLayout = () => {
9290
9344
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9291
9345
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9292
9346
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9293
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9347
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9294
9348
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9295
9349
  Button,
9296
9350
  {
@@ -9301,7 +9355,7 @@ const RootLayout = () => {
9301
9355
  },
9302
9356
  b
9303
9357
  ) }),
9304
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(x.label) }) })
9358
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
9305
9359
  ] }, "button" + b)) }),
9306
9360
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9307
9361
  /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
@@ -9317,14 +9371,14 @@ const RootLayout = () => {
9317
9371
  /* @__PURE__ */ jsxs(
9318
9372
  "div",
9319
9373
  {
9320
- className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(m, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9374
+ className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(h, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9321
9375
  children: [
9322
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
9323
- /* @__PURE__ */ jsx("span", { children: h(m[o].label) })
9376
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
9377
+ /* @__PURE__ */ jsx("span", { children: m(h[o].label) })
9324
9378
  ]
9325
9379
  }
9326
9380
  ),
9327
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
9381
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(h, `${o}.component`, null), {}) }) })
9328
9382
  ] })
9329
9383
  }
9330
9384
  ),
@@ -9343,11 +9397,11 @@ const RootLayout = () => {
9343
9397
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9344
9398
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9345
9399
  " ",
9346
- h("AI Assistant")
9400
+ m("AI Assistant")
9347
9401
  ] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9348
9402
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9349
9403
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9350
- h("Theme Settings")
9404
+ m("Theme Settings")
9351
9405
  ] }),
9352
9406
  /* @__PURE__ */ jsx(
9353
9407
  Button,
@@ -9469,9 +9523,9 @@ export {
9469
9523
  generateUUID as generateBlockId,
9470
9524
  getBlocksFromHTML,
9471
9525
  getClassValueAndUnit,
9472
- ze as i18n,
9526
+ We as i18n,
9473
9527
  cn$1 as mergeClasses,
9474
- Ue as registerChaiBlock,
9528
+ Fe as registerChaiBlock,
9475
9529
  useAddBlock,
9476
9530
  useAddClassesToBlocks,
9477
9531
  useAskAi,
@@ -9514,7 +9568,7 @@ export {
9514
9568
  useStylingState,
9515
9569
  useTheme,
9516
9570
  useThemeOptions,
9517
- He as useTranslation,
9571
+ Ve as useTranslation,
9518
9572
  useUILibraryBlocks,
9519
9573
  useUndoManager,
9520
9574
  useUpdateBlocksProps,