@chaibuilder/sdk 3.1.8 → 3.1.9

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.
@@ -223,16 +223,16 @@ function insertBlocksAtPosition(o, n, r, a) {
223
223
  const l = [...n];
224
224
  let i = [...o];
225
225
  if (r) {
226
- const d = o.find((g) => g._id === r);
227
- if (d && d.content !== void 0 && d.content !== "" && !o.some((m) => m._parent === r)) {
226
+ const u = o.find((g) => g._id === r);
227
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
228
228
  const h = {
229
229
  _id: generateUUID(),
230
230
  _parent: r,
231
231
  _type: "Text",
232
- content: d.content
232
+ content: u.content
233
233
  };
234
- Object.keys(d).forEach((f) => {
235
- f.startsWith("content-") && (h[f] = d[f]);
234
+ Object.keys(u).forEach((f) => {
235
+ f.startsWith("content-") && (h[f] = u[f]);
236
236
  }), l.unshift(h), i = i.map((f) => {
237
237
  if (f._id === r) {
238
238
  const x = { ...f, content: "" };
@@ -244,14 +244,14 @@ function insertBlocksAtPosition(o, n, r, a) {
244
244
  });
245
245
  }
246
246
  }
247
- let c = i.filter((d) => !d._parent);
248
- r && (c = i.filter((d) => d._parent === r));
249
- const u = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
247
+ let c = i.filter((u) => !u._parent);
248
+ r && (c = i.filter((u) => u._parent === r));
249
+ const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
250
250
  let p = i.length;
251
- for (let d = 0, g = 0; d < i.length; d++)
252
- if (r !== void 0 ? i[d]._parent === r : !i[d]._parent) {
253
- if (g === u) {
254
- p = d;
251
+ for (let u = 0, g = 0; u < i.length; u++)
252
+ if (r !== void 0 ? i[u]._parent === r : !i[u]._parent) {
253
+ if (g === d) {
254
+ p = u;
255
255
  break;
256
256
  }
257
257
  g++;
@@ -269,11 +269,11 @@ function findNodeById(o, n) {
269
269
  return o.first((r) => r.model._id === n) || null;
270
270
  }
271
271
  function moveNode(o, n, r, a) {
272
- var d, g;
272
+ var u, g;
273
273
  const l = findNodeById(o, n), i = findNodeById(o, r);
274
274
  if (!l || !i) return !1;
275
275
  i.children || (i.model.children = []);
276
- let c = (d = i == null ? void 0 : i.children) == null ? void 0 : d.findIndex((m) => m.model._id === n);
276
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
277
277
  l.drop(), c = Math.max(c, 0);
278
278
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
279
279
  try {
@@ -291,15 +291,15 @@ function handleOldParentTextBlock(o, n) {
291
291
  if (l.length === 2) {
292
292
  const i = l.find((c) => c._id !== n._id);
293
293
  if (i && i._type === "Text" && "content" in a)
294
- return o.map((u) => {
295
- if (u._id === r) {
296
- const p = { ...u, content: i.content };
297
- return Object.keys(i).forEach((d) => {
298
- d.startsWith("content-") && (p[d] = i[d]);
294
+ return o.map((d) => {
295
+ if (d._id === r) {
296
+ const p = { ...d, content: i.content };
297
+ return Object.keys(i).forEach((u) => {
298
+ u.startsWith("content-") && (p[u] = i[u]);
299
299
  }), p;
300
300
  }
301
- return u;
302
- }).filter((u) => u._id !== i._id);
301
+ return d;
302
+ }).filter((d) => d._id !== i._id);
303
303
  }
304
304
  return o;
305
305
  }
@@ -314,32 +314,32 @@ function handleNewParentTextBlock(o, n, r) {
314
314
  _type: "Text",
315
315
  content: a.content
316
316
  };
317
- Object.keys(a).forEach((d) => {
318
- d.startsWith("content-") && (c[d] = a[d]);
317
+ Object.keys(a).forEach((u) => {
318
+ u.startsWith("content-") && (c[u] = a[u]);
319
319
  });
320
- const u = o.map((d) => {
321
- if (d._id === r) {
322
- const g = { ...d, content: "" };
320
+ const d = o.map((u) => {
321
+ if (u._id === r) {
322
+ const g = { ...u, content: "" };
323
323
  return Object.keys(g).forEach((m) => {
324
324
  m.startsWith("content-") && (g[m] = "");
325
325
  }), g;
326
326
  }
327
- return d;
328
- }), p = u.findIndex((d) => d._id === n._id);
329
- return p !== -1 ? [...u.slice(0, p), c, ...u.slice(p)] : [c, ...u];
327
+ return u;
328
+ }), p = d.findIndex((u) => u._id === n._id);
329
+ return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
330
330
  }
331
331
  return o;
332
332
  }
333
333
  function moveBlocksWithChildren(o, n, r, a) {
334
334
  if (!n) return o;
335
- const l = o.find((d) => d._id === n);
335
+ const l = o.find((u) => u._id === n);
336
336
  if (!l) return o;
337
337
  let i = handleOldParentTextBlock(o, l);
338
338
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
339
339
  if (moveNode(p, n, c, a)) {
340
- let d = flattenTree(p);
341
- const g = d.find((m) => m._id === n);
342
- return g && (g._parent = c === "root" ? null : c), d.shift(), r && (d = handleNewParentTextBlock(d, l, r)), d;
340
+ let u = flattenTree(p);
341
+ const g = u.find((m) => m._id === n);
342
+ return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
343
343
  }
344
344
  return i;
345
345
  }
@@ -361,16 +361,16 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
361
361
  }), [o, n]);
362
362
  }, removeNestedBlocks = (o, n) => {
363
363
  let r = [...o], a = [];
364
- n.forEach((u) => {
365
- const p = r.find((m) => m._id === u);
364
+ n.forEach((d) => {
365
+ const p = r.find((m) => m._id === d);
366
366
  if (!p || !p._parent) return;
367
- const d = p._parent, g = r.filter((m) => m._parent === d);
367
+ const u = p._parent, g = r.filter((m) => m._parent === u);
368
368
  if (g.length === 2) {
369
- const m = g.find((h) => h._id !== u);
369
+ const m = g.find((h) => h._id !== d);
370
370
  if (m && m._type === "Text") {
371
- const h = r.find((f) => f._id === d);
371
+ const h = r.find((f) => f._id === u);
372
372
  h && "content" in h && (r = r.map((f) => {
373
- if (f._id === d) {
373
+ if (f._id === u) {
374
374
  const x = { ...f, content: m.content };
375
375
  return Object.keys(m).forEach((b) => {
376
376
  b.startsWith("content-") && (x[b] = m[b]);
@@ -381,15 +381,15 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
381
381
  }
382
382
  }
383
383
  });
384
- const l = [...n, ...a], i = [], c = filter(r, (u) => includes(l, u._id) || includes(l, u._parent) ? (i.push(u._id), !1) : !0);
384
+ const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
385
385
  return isEmpty(i) ? c : removeNestedBlocks(c, i);
386
386
  }, useRemoveBlocks = () => {
387
387
  const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions(), { hasPermission: l } = usePermissions();
388
388
  return useCallback(
389
389
  (i) => {
390
- var u;
390
+ var d;
391
391
  if (!l(PERMISSIONS.DELETE_BLOCK)) return;
392
- const c = ((u = find(o, { _id: i[0] })) == null ? void 0 : u._parent) || null;
392
+ const c = ((d = find(o, { _id: i[0] })) == null ? void 0 : d._parent) || null;
393
393
  a(removeNestedBlocks(o, i)), setTimeout(() => r(c ? [c] : []), 200);
394
394
  },
395
395
  [o, r, n, l]
@@ -424,8 +424,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
424
424
  },
425
425
  addBlocks: (a, l, i) => {
426
426
  o((c) => {
427
- const u = insertBlocksAtPosition(c, a, l, i);
428
- return n({ type: "blocks-updated", blocks: u }), u;
427
+ const d = insertBlocksAtPosition(c, a, l, i);
428
+ return n({ type: "blocks-updated", blocks: d }), d;
429
429
  });
430
430
  },
431
431
  removeBlocks: (a) => {
@@ -436,13 +436,13 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
436
436
  },
437
437
  moveBlocks: (a, l, i) => {
438
438
  o((c) => {
439
- let u = [...c];
439
+ let d = [...c];
440
440
  for (let p = 0; p < a.length; p++)
441
- u = moveBlocksWithChildren(u, a[p], l, i);
441
+ d = moveBlocksWithChildren(d, a[p], l, i);
442
442
  return each(a, (p) => {
443
- const d = find(u, (g) => g._id === p);
444
- d && r({ id: p, props: { _parent: d._parent || null } });
445
- }), n({ type: "blocks-updated", blocks: u }), u;
443
+ const u = find(d, (g) => g._id === p);
444
+ u && r({ id: p, props: { _parent: u._parent || null } });
445
+ }), n({ type: "blocks-updated", blocks: d }), d;
446
446
  });
447
447
  },
448
448
  updateBlocksProps: (a) => {
@@ -459,7 +459,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
459
459
  status: "idle",
460
460
  props: {},
461
461
  error: void 0
462
- }), c = useUpdateBlocksPropsRealtime(), u = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), d = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
462
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (f) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
463
463
  return useEffect(() => {
464
464
  if (n === "mock") {
465
465
  if (isFunction(a)) {
@@ -471,7 +471,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
471
471
  }
472
472
  return;
473
473
  }
474
- n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), u({ block: o }).then((f = {}) => {
474
+ n === "live" && (!g && !m || (i((f) => ({ ...f, status: "loading", props: {} })), d({ block: o }).then((f = {}) => {
475
475
  g ? (p((x) => ({
476
476
  ...x,
477
477
  [o._id]: {
@@ -486,7 +486,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
486
486
  [o._id]: { status: "error", error: f, props: [] }
487
487
  })), i((x) => ({ ...x, status: "error", error: f, props: {} }))) : i((x) => ({ ...x, status: "error", error: f, props: {} }));
488
488
  })));
489
- }, [o == null ? void 0 : o._id, d, g, m, a, n]), {
489
+ }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
490
490
  $loading: get(l, "status") === "loading",
491
491
  ...o ? get(l, "props", {}) : {}
492
492
  };
@@ -640,13 +640,13 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
640
640
  }
641
641
  }) : !1, useSavePage = () => {
642
642
  const [o, n] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSave", async (f) => {
643
- }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: u, fallbackLang: p } = useLanguages(), [d] = useIsPageLoaded(), g = () => {
643
+ }), a = useBuilderProp("onSaveStateChange", noop), l = useGetPageData(), [i] = useTheme(), { hasPermission: c } = usePermissions(), { selectedLang: d, fallbackLang: p } = useLanguages(), [u] = useIsPageLoaded(), g = () => {
644
644
  const f = l();
645
- return !u || u === p ? !1 : checkMissingTranslations(f.blocks || [], u);
645
+ return !d || d === p ? !1 : checkMissingTranslations(f.blocks || [], d);
646
646
  };
647
647
  return { savePage: useThrottledCallback(
648
648
  async (f = !1) => {
649
- if (!c("save_page") || !d)
649
+ if (!c("save_page") || !u)
650
650
  return;
651
651
  n("SAVING"), a("SAVING");
652
652
  const x = l();
@@ -659,11 +659,11 @@ const checkMissingTranslations = (o, n) => n ? o.some((r) => {
659
659
  n("SAVED"), a("SAVED");
660
660
  }, 100), !0;
661
661
  },
662
- [l, n, i, r, a, d],
662
+ [l, n, i, r, a, u],
663
663
  3e3
664
664
  // save only every 5 seconds
665
665
  ), savePageAsync: async () => {
666
- if (!c("save_page") || !d)
666
+ if (!c("save_page") || !u)
667
667
  return;
668
668
  n("SAVING"), a("SAVING");
669
669
  const f = l();
@@ -683,23 +683,23 @@ const undoRedoStateAtom = atom({
683
683
  canRedo: !1
684
684
  }), useUndoManager = () => {
685
685
  const [, o] = useAtom$1(builderSaveStateAtom), [n, r] = useAtom$1(undoRedoStateAtom), a = useBuilderProp("onSaveStateChange", noop), l = useCallback(() => {
686
- const d = {
686
+ const u = {
687
687
  canUndo: undoManager.hasUndo(),
688
688
  canRedo: undoManager.hasRedo()
689
689
  };
690
- r(d), o("UNSAVED"), a("UNSAVED");
690
+ r(u), o("UNSAVED"), a("UNSAVED");
691
691
  }, [r, o, a]);
692
692
  useEffect(() => (undoManager.setCallback(l), () => {
693
693
  undoManager.setCallback(noop);
694
694
  }), [l]);
695
695
  const i = useCallback(
696
- (d) => {
697
- undoManager.add(d), l();
696
+ (u) => {
697
+ undoManager.add(u), l();
698
698
  },
699
699
  [l]
700
700
  ), c = useCallback(() => {
701
701
  undoManager.undo(), l();
702
- }, [l]), u = useCallback(() => {
702
+ }, [l]), d = useCallback(() => {
703
703
  undoManager.redo(), l();
704
704
  }, [l]), p = useCallback(() => {
705
705
  undoManager.clear(), r({
@@ -711,12 +711,12 @@ const undoRedoStateAtom = atom({
711
711
  () => ({
712
712
  add: i,
713
713
  undo: c,
714
- redo: u,
714
+ redo: d,
715
715
  hasUndo: () => n.canUndo,
716
716
  hasRedo: () => n.canRedo,
717
717
  clear: p
718
718
  }),
719
- [i, c, u, n.canUndo, n.canRedo, p]
719
+ [i, c, d, n.canUndo, n.canRedo, p]
720
720
  );
721
721
  }, useBlocksStore = () => useAtom$1(presentBlocksAtom), useBlocksStoreUndoableActions = () => {
722
722
  const { add: o } = useUndoManager(), [n] = useBlocksStore(), {
@@ -728,13 +728,13 @@ const undoRedoStateAtom = atom({
728
728
  } = useBlocksStoreManager();
729
729
  return {
730
730
  moveBlocks: (x, b, y) => {
731
- const C = map(x, (w) => {
732
- const B = n.find((A) => A._id === w)._parent || null, k = n.filter((A) => B ? A._parent === B : !A._parent).map((A) => A._id).indexOf(w);
733
- return { _id: w, oldParent: B, oldPosition: k };
734
- }), S = C.find(({ _id: w }) => w === x[0]);
735
- S && S.oldParent === b && S.oldPosition === y || (i(x, b, y), o({
736
- undo: () => each(C, ({ _id: w, oldParent: _, oldPosition: B }) => {
737
- i([w], _, B);
731
+ const S = map(x, (v) => {
732
+ const B = n.find((A) => A._id === v)._parent || null, k = n.filter((A) => B ? A._parent === B : !A._parent).map((A) => A._id).indexOf(v);
733
+ return { _id: v, oldParent: B, oldPosition: k };
734
+ }), C = S.find(({ _id: v }) => v === x[0]);
735
+ C && C.oldParent === b && C.oldPosition === y || (i(x, b, y), o({
736
+ undo: () => each(S, ({ _id: v, oldParent: _, oldPosition: B }) => {
737
+ i([v], _, B);
738
738
  }),
739
739
  redo: () => i(x, b, y)
740
740
  }));
@@ -746,27 +746,27 @@ const undoRedoStateAtom = atom({
746
746
  });
747
747
  },
748
748
  removeBlocks: (x) => {
749
- var S;
750
- const b = (S = first(x)) == null ? void 0 : S._parent, C = n.filter((w) => b ? w._parent === b : !w._parent).indexOf(first(x));
749
+ var C;
750
+ const b = (C = first(x)) == null ? void 0 : C._parent, S = n.filter((v) => b ? v._parent === b : !v._parent).indexOf(first(x));
751
751
  l(map(x, "_id")), o({
752
- undo: () => a(x, b, C),
752
+ undo: () => a(x, b, S),
753
753
  redo: () => l(map(x, "_id"))
754
754
  });
755
755
  },
756
756
  updateBlocks: (x, b, y) => {
757
- let C = [];
757
+ let S = [];
758
758
  if (y)
759
- C = map(x, (S) => ({ _id: S, ...y }));
759
+ S = map(x, (C) => ({ _id: C, ...y }));
760
760
  else {
761
- const S = keys(b);
762
- C = map(x, (w) => {
763
- const _ = n.find((I) => I._id === w), B = { _id: w };
764
- return each(S, (I) => B[I] = _[I]), B;
761
+ const C = keys(b);
762
+ S = map(x, (v) => {
763
+ const _ = n.find((I) => I._id === v), B = { _id: v };
764
+ return each(C, (I) => B[I] = _[I]), B;
765
765
  });
766
766
  }
767
- c(map(x, (S) => ({ _id: S, ...b }))), o({
768
- undo: () => c(C),
769
- redo: () => c(map(x, (S) => ({ _id: S, ...b })))
767
+ c(map(x, (C) => ({ _id: C, ...b }))), o({
768
+ undo: () => c(S),
769
+ redo: () => c(map(x, (C) => ({ _id: C, ...b })))
770
770
  });
771
771
  },
772
772
  updateBlocksRuntime: (x, b) => {
@@ -781,8 +781,8 @@ const undoRedoStateAtom = atom({
781
781
  updateMultipleBlocksProps: (x) => {
782
782
  let b = [];
783
783
  b = map(x, (y) => {
784
- const C = keys(y), S = n.find((_) => _._id === y._id), w = {};
785
- return each(C, (_) => w[_] = S[_]), w;
784
+ const S = keys(y), C = n.find((_) => _._id === y._id), v = {};
785
+ return each(S, (_) => v[_] = C[_]), v;
786
786
  }), c(x), o({
787
787
  undo: () => c(b),
788
788
  redo: () => c(x)
@@ -820,7 +820,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
820
820
  });
821
821
  const useAddBlock = () => {
822
822
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
823
- (i, c, u) => {
823
+ (i, c, d) => {
824
824
  var h;
825
825
  for (let f = 0; f < i.length; f++) {
826
826
  const { _id: x } = i[f];
@@ -830,26 +830,26 @@ const useAddBlock = () => {
830
830
  b[y]._parent = i[f]._id;
831
831
  }
832
832
  const p = first(i);
833
- let d, g;
834
- return c && (d = find(o, { _id: c }), i[0]._parent = c, g = c), !(d ? canAcceptChildBlock(d == null ? void 0 : d._type, p._type) : !0) && d && (i[0]._parent = d._parent, g = d._parent), r(i, g, u), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
833
+ let u, g;
834
+ 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);
835
835
  },
836
836
  [r, o, n]
837
837
  );
838
838
  return { addCoreBlock: useCallback(
839
- (i, c, u) => {
839
+ (i, c, d) => {
840
840
  if (has(i, "blocks")) {
841
841
  const b = i.blocks;
842
- return a(b, c, u);
842
+ return a(b, c, d);
843
843
  }
844
- const p = generateUUID(), d = getDefaultBlockProps(i.type), g = {
844
+ const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
845
845
  _type: i.type,
846
846
  _id: p,
847
- ...d,
847
+ ...u,
848
848
  ...has(i, "_name") && { _name: i._name },
849
849
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
850
850
  };
851
851
  let m, h;
852
- 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, u), n([g._id]), g;
852
+ 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;
853
853
  },
854
854
  [r, a, o, n]
855
855
  ), addPredefinedBlock: a };
@@ -1959,11 +1959,11 @@ function removeDuplicateClasses(o) {
1959
1959
  if (r.length === 1) return r[0].fullCls;
1960
1960
  for (const l of r) {
1961
1961
  const i = l.property, c = n.indexOf(l.mq);
1962
- for (let u = c + 1; u < n.length; u++) {
1963
- const p = n[u], d = r.find((g) => g.property === i && g.mq === p);
1964
- if (d && d.cls === l.cls)
1965
- a = a.replace(d.fullCls, "");
1966
- else if (d && d.cls !== l.cls)
1962
+ for (let d = c + 1; d < n.length; d++) {
1963
+ const p = n[d], u = r.find((g) => g.property === i && g.mq === p);
1964
+ if (u && u.cls === l.cls)
1965
+ a = a.replace(u.fullCls, "");
1966
+ else if (u && u.cls !== l.cls)
1967
1967
  break;
1968
1968
  }
1969
1969
  }
@@ -1983,12 +1983,12 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
1983
1983
  )
1984
1984
  ), i = first(o(selectedStylingBlocksAtom));
1985
1985
  return map(l, (c) => {
1986
- const u = o(c), p = get(u, i.prop, `${STYLES_KEY},`), { classes: d } = getSplitChaiClasses(p);
1986
+ const d = o(c), p = get(d, i.prop, `${STYLES_KEY},`), { classes: u } = getSplitChaiClasses(p);
1987
1987
  return {
1988
- ids: [u._id],
1988
+ ids: [d._id],
1989
1989
  props: {
1990
1990
  [i.prop]: `${STYLES_KEY},${orderClassesByBreakpoint(
1991
- removeDuplicateClasses(twMerge(d, a))
1991
+ removeDuplicateClasses(twMerge(u, a))
1992
1992
  )}`
1993
1993
  }
1994
1994
  };
@@ -2229,11 +2229,11 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), add
2229
2229
  for (const i of l) {
2230
2230
  const c = r[i];
2231
2231
  if (isString(c)) {
2232
- const u = chunk(c.split(""), 12);
2232
+ const d = chunk(c.split(""), 12);
2233
2233
  let p = "";
2234
2234
  o([n], { [i]: "" });
2235
- for (let d = 0; d < u.length; d++)
2236
- p += u[d].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2235
+ for (let u = 0; u < d.length; u++)
2236
+ p += d[u].join(""), o([n], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2237
2237
  }
2238
2238
  }
2239
2239
  },
@@ -2271,22 +2271,22 @@ const getBlockWithChildren = (o, n) => {
2271
2271
  return r = flattenDeep([...r, ...getChildBlocks(n, o, r)]), r;
2272
2272
  }, pickOnlyAIProps = (o, n, r) => compact(
2273
2273
  o.map((a) => {
2274
- const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), u = {}, p = get(c, "aiProps", []);
2275
- for (const d in a)
2276
- if (!l.includes(d) && p.includes(d)) {
2277
- const g = get(a, `${d}-${n}`, ""), m = get(a, d, "");
2278
- u[d] = isString(g) && g.trim() || m, r && (u[d] = m);
2274
+ const l = ["_id", "_type", "_parent"], i = pick(a, l), c = getRegisteredChaiBlock(a._type), d = {}, p = get(c, "aiProps", []);
2275
+ for (const u in a)
2276
+ if (!l.includes(u) && p.includes(u)) {
2277
+ const g = get(a, `${u}-${n}`, ""), m = get(a, u, "");
2278
+ d[u] = isString(g) && g.trim() || m, r && (d[u] = m);
2279
2279
  }
2280
- return isEmpty(u) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...u });
2280
+ return isEmpty(d) ? !1 : (has(i, "_parent") && isEmpty(i._parent) && delete i._parent, { ...i, ...d });
2281
2281
  })
2282
2282
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2283
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [u] = useBlocksStore(), { selectedLang: p, fallbackLang: d } = useLanguages(), g = p.length ? p : d, m = (h, f) => {
2283
+ 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) => {
2284
2284
  const x = cloneDeep(f.find((b) => b._id === h));
2285
2285
  for (const b in x) {
2286
2286
  const y = x[b];
2287
2287
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2288
- const { baseClasses: C, classes: S } = getSplitChaiClasses(y);
2289
- x[b] = compact(flattenDeep([C, S])).join(" ");
2288
+ const { baseClasses: S, classes: C } = getSplitChaiClasses(y);
2289
+ x[b] = compact(flattenDeep([S, C])).join(" ");
2290
2290
  } else
2291
2291
  b !== "_id" && delete x[b];
2292
2292
  }
@@ -2298,7 +2298,7 @@ const getBlockWithChildren = (o, n) => {
2298
2298
  if (l) {
2299
2299
  n(!0), a(null);
2300
2300
  try {
2301
- const y = p === d ? "" : p, C = x.toLowerCase().includes("translate the content"), S = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, u)), p, C) : [m(f, u)], w = await l(h, addLangToPrompt(x, g, h), S, y), { blocks: _, error: B } = w;
2301
+ const y = p === u ? "" : p, S = x.toLowerCase().includes("translate the content"), C = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p, S) : [m(f, d)], v = await l(h, addLangToPrompt(x, g, h), C, y), { blocks: _, error: B } = v;
2302
2302
  if (B) {
2303
2303
  a(B);
2304
2304
  return;
@@ -2312,7 +2312,7 @@ const getBlockWithChildren = (o, n) => {
2312
2312
  c(I);
2313
2313
  } else
2314
2314
  i(_);
2315
- b && b(w);
2315
+ b && b(v);
2316
2316
  } catch (y) {
2317
2317
  a(y);
2318
2318
  } finally {
@@ -2324,8 +2324,8 @@ const getBlockWithChildren = (o, n) => {
2324
2324
  l,
2325
2325
  n,
2326
2326
  p,
2327
- d,
2328
2327
  u,
2328
+ d,
2329
2329
  g,
2330
2330
  c,
2331
2331
  i
@@ -2338,18 +2338,18 @@ const getBlockWithChildren = (o, n) => {
2338
2338
  const [o, n] = useAtom$1(partialBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
2339
2339
  return { getPartailBlocks: r, reset: a };
2340
2340
  }, useWatchPartailBlocks = () => {
2341
- const [o] = useBlocksStore(), [n, r] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (u) => []), c = useMemo(() => o.filter((u) => u._type === "PartialBlock" || u._type === "GlobalBlock").map((u) => get(u, "partialBlockId", get(u, "globalBlock", ""))), [o]);
2341
+ const [o] = useBlocksStore(), [n, r] = useAtom$1(partialBlocksStoreAtom), [a, l] = useAtom$1(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (d) => []), c = useMemo(() => o.filter((d) => d._type === "PartialBlock" || d._type === "GlobalBlock").map((d) => get(d, "partialBlockId", get(d, "globalBlock", ""))), [o]);
2342
2342
  useEffect(() => {
2343
- forEach(c, (u) => {
2344
- has(n, u) || get(a, `${u}.loading`, !1) || (l((p) => ({ ...p, [u]: { loading: !0, error: null } })), i(u).then((p) => {
2345
- r((d) => ({ ...d, [u]: p })), l((d) => ({
2346
- ...d,
2347
- [u]: { loading: !1, error: null }
2343
+ forEach(c, (d) => {
2344
+ has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
2345
+ r((u) => ({ ...u, [d]: p })), l((u) => ({
2346
+ ...u,
2347
+ [d]: { loading: !1, error: null }
2348
2348
  }));
2349
2349
  }).catch((p) => {
2350
- l((d) => ({
2351
- ...d,
2352
- [u]: { loading: !1, error: p.message }
2350
+ l((u) => ({
2351
+ ...u,
2352
+ [d]: { loading: !1, error: p.message }
2353
2353
  }));
2354
2354
  }));
2355
2355
  });
@@ -2362,7 +2362,7 @@ const getBlockWithChildren = (o, n) => {
2362
2362
  c
2363
2363
  ]);
2364
2364
  }, partialBlocksListAtom = atom({}), usePartialBlocksList = () => {
2365
- const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), u = useCallback(async () => {
2365
+ const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom$1(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
2366
2366
  n(!0), a(null);
2367
2367
  try {
2368
2368
  const p = await c();
@@ -2372,12 +2372,12 @@ const getBlockWithChildren = (o, n) => {
2372
2372
  }
2373
2373
  }, [c, i]);
2374
2374
  return useEffect(() => {
2375
- u();
2376
- }, []), { data: l, isLoading: o, refetch: u, error: r };
2375
+ d();
2376
+ }, []), { data: l, isLoading: o, refetch: d, error: r };
2377
2377
  }, useBuilderReset = () => {
2378
- const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, u] = useBlockRepeaterDataAtom();
2378
+ const { clear: o } = useUndoManager(), [, n] = useSelectedBlockIds(), { clearHighlight: r } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, d] = useBlockRepeaterDataAtom();
2379
2379
  return () => {
2380
- u({}), n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
2380
+ d({}), n([]), a([]), r(), o(), l(!1), i(), c("SAVED");
2381
2381
  };
2382
2382
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom([]), useCutBlockIds = () => {
2383
2383
  const [o, n] = useAtom$1(cutBlockIdsAtom), r = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -2389,17 +2389,17 @@ const getBlockWithChildren = (o, n) => {
2389
2389
  return [o, a];
2390
2390
  }, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
2391
2391
  const [o] = useBlocksStore(), [n, r] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useBuilderProp("flags.copyPaste", !0), c = useCallback(
2392
- (p) => p.some((d) => getDuplicatedBlocks(o, d, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2392
+ (p) => p.some((u) => getDuplicatedBlocks(o, u, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2393
2393
  [o]
2394
- ), u = useCallback(
2395
- async (p, d = !1) => {
2394
+ ), d = useCallback(
2395
+ async (p, u = !1) => {
2396
2396
  try {
2397
2397
  if (isEmpty(p)) return;
2398
2398
  r(p), a([]);
2399
2399
  const g = {
2400
2400
  _chai_copied_blocks: p.flatMap((m) => {
2401
2401
  const h = getDuplicatedBlocks(o, m, null);
2402
- if (!d)
2402
+ if (!u)
2403
2403
  return h;
2404
2404
  let f = [];
2405
2405
  for (const x of h)
@@ -2427,7 +2427,7 @@ const getBlockWithChildren = (o, n) => {
2427
2427
  },
2428
2428
  [r, a, o]
2429
2429
  );
2430
- return [n, u, c];
2430
+ return [n, d, c];
2431
2431
  }, useCopyToClipboard = () => {
2432
2432
  const [o, n] = useState(null), r = useBuilderProp("flags.copyPaste", !0), a = useCallback(async (l) => {
2433
2433
  if (!r)
@@ -2450,12 +2450,12 @@ const getBlockWithChildren = (o, n) => {
2450
2450
  (a, l = null) => {
2451
2451
  const i = [];
2452
2452
  each(a, (c) => {
2453
- const u = o.find((h) => h._id === c);
2454
- l ? l === "root" && (l = null) : l = u._parent;
2453
+ const d = o.find((h) => h._id === c);
2454
+ l ? l === "root" && (l = null) : l = d._parent;
2455
2455
  const g = filter(
2456
2456
  o,
2457
2457
  (h) => isString(l) ? h._parent === l : !h._parent
2458
- ).indexOf(u) + 1, m = getDuplicatedBlocks(o, c, l);
2458
+ ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
2459
2459
  r(m, l, g), i.push(get(m, "0._id", ""));
2460
2460
  }), n(i);
2461
2461
  },
@@ -2471,27 +2471,27 @@ const getBlockWithChildren = (o, n) => {
2471
2471
  c.current = "loading", r((p) => ({ ...p, [o == null ? void 0 : o.id]: { loading: "loading", blocks: [] } }));
2472
2472
  try {
2473
2473
  const p = await a(o);
2474
- c.current = "idle", r((d) => ({ ...d, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
2474
+ c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: p || [] } }));
2475
2475
  } catch {
2476
- c.current = "idle", r((d) => ({ ...d, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
2476
+ c.current = "idle", r((u) => ({ ...u, [o == null ? void 0 : o.id]: { loading: "complete", blocks: [] } }));
2477
2477
  }
2478
2478
  }
2479
2479
  })();
2480
2480
  }, [o, l, i, c, r, a]);
2481
- const u = useCallback(
2481
+ const d = useCallback(
2482
2482
  (p) => {
2483
- r((d) => ({ ...d, [p]: { loading: "idle", blocks: [] } }));
2483
+ r((u) => ({ ...u, [p]: { loading: "idle", blocks: [] } }));
2484
2484
  },
2485
2485
  [r]
2486
2486
  );
2487
- return { data: l || [], isLoading: i === "loading", resetLibrary: u };
2487
+ return { data: l || [], isLoading: i === "loading", resetLibrary: d };
2488
2488
  }, useCanPaste = () => {
2489
2489
  const [o] = useBlocksStore();
2490
2490
  return (n, r) => {
2491
2491
  var i;
2492
2492
  const a = ((i = find(o, { _id: r })) == null ? void 0 : i._type) || null, l = first(n.map((c) => {
2493
- var u;
2494
- return (u = find(o, { _id: c })) == null ? void 0 : u._type;
2493
+ var d;
2494
+ return (d = find(o, { _id: c })) == null ? void 0 : d._type;
2495
2495
  }));
2496
2496
  return canAcceptChildBlock(a, l);
2497
2497
  };
@@ -2518,9 +2518,9 @@ const getBlockWithChildren = (o, n) => {
2518
2518
  if (o.length > 0)
2519
2519
  return l(o, c);
2520
2520
  try {
2521
- const u = await navigator.clipboard.readText();
2522
- if (u) {
2523
- const p = JSON.parse(u);
2521
+ const d = await navigator.clipboard.readText();
2522
+ if (d) {
2523
+ const p = JSON.parse(d);
2524
2524
  return has(p, "_chai_copied_blocks");
2525
2525
  }
2526
2526
  } catch {
@@ -2532,7 +2532,7 @@ const getBlockWithChildren = (o, n) => {
2532
2532
  ),
2533
2533
  pasteBlocks: useCallback(
2534
2534
  async (c) => {
2535
- const u = Array.isArray(c) ? c[0] : c;
2535
+ const d = Array.isArray(c) ? c[0] : c;
2536
2536
  if (!(navigator != null && navigator.permissions)) {
2537
2537
  toast.error("Cannot check clipboard permissions.");
2538
2538
  return;
@@ -2554,9 +2554,9 @@ const getBlockWithChildren = (o, n) => {
2554
2554
  async () => {
2555
2555
  const p = await navigator.clipboard.readText();
2556
2556
  if (p) {
2557
- const d = JSON.parse(p);
2558
- if (has(d, "_chai_copied_blocks"))
2559
- a(d._chai_copied_blocks, u === "root" ? null : u);
2557
+ const u = JSON.parse(p);
2558
+ if (has(u, "_chai_copied_blocks"))
2559
+ a(u._chai_copied_blocks, d === "root" ? null : d);
2560
2560
  else
2561
2561
  throw new Error("Nothing to paste");
2562
2562
  } else
@@ -2583,20 +2583,20 @@ const getBlockWithChildren = (o, n) => {
2583
2583
  )
2584
2584
  );
2585
2585
  return map(i, (c) => {
2586
- const u = o(c), p = a;
2587
- let { classes: d, baseClasses: g } = getSplitChaiClasses(get(u, l.prop, `${STYLES_KEY},`));
2586
+ const d = o(c), p = a;
2587
+ let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2588
2588
  return each(p, (m) => {
2589
2589
  const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2590
- d = d.replace(f, " ").replace(/\s+/g, " ").trim();
2590
+ u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2591
2591
  const x = first(m.split(":"));
2592
2592
  includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
2593
2593
  }), each(p, (m) => {
2594
2594
  const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2595
2595
  g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2596
2596
  }), {
2597
- ids: [u._id],
2597
+ ids: [d._id],
2598
2598
  props: {
2599
- [l.prop]: `${STYLES_KEY}${g},${d}`
2599
+ [l.prop]: `${STYLES_KEY}${g},${u}`
2600
2600
  }
2601
2601
  };
2602
2602
  });
@@ -2627,7 +2627,7 @@ const getBlockWithChildren = (o, n) => {
2627
2627
  );
2628
2628
  }, useResetBlockStyles = () => {
2629
2629
  const o = useSelectedBlock(), n = useUpdateBlocksProps(), r = useCallback((c) => getDefaultBlockProps(c) || {}, []), a = useCallback((c) => Object.keys(c).filter(
2630
- (u) => typeof c[u] == "string" && c[u].startsWith("#styles:")
2630
+ (d) => typeof c[d] == "string" && c[d].startsWith("#styles:")
2631
2631
  ), []), l = useCallback(
2632
2632
  (c) => {
2633
2633
  if (!o) return;
@@ -2640,7 +2640,7 @@ const getBlockWithChildren = (o, n) => {
2640
2640
  if (!o) return;
2641
2641
  const c = a(o);
2642
2642
  if (c.length === 0) return;
2643
- const u = r(o._type), p = pick(u, c);
2643
+ const d = r(o._type), p = pick(d, c);
2644
2644
  n([o._id], p);
2645
2645
  }, [o, a, r, n]), reset: l };
2646
2646
  }, useStylingBreakpoint = () => useAtom$1(styleBreakpointAtom), canvasWidthAtom = atomWithStorage("canvasWidth", 800), canvasDisplayWidthAtom = atomWithStorage("canvasDisplayWidth", 800), canvasBreakpointAtom = atom((o) => {
@@ -2662,7 +2662,7 @@ const getBlockWithChildren = (o, n) => {
2662
2662
  }), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom((o) => {
2663
2663
  const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
2664
2664
  let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
2665
- return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, u) => MQ[c.mq] - MQ[u.mq]), a || (i = filter(i, { dark: !1 })), i;
2665
+ return startsWith(r, "_") || (i = filter(i, (c) => l.includes(c.mq))), i = i.sort((c, d) => MQ[c.mq] - MQ[d.mq]), a || (i = filter(i, { dark: !1 })), i;
2666
2666
  }), getQueries = (o) => {
2667
2667
  let n = [];
2668
2668
  switch (o) {
@@ -2700,11 +2700,11 @@ const getBlockWithChildren = (o, n) => {
2700
2700
  if (!l) return null;
2701
2701
  let i = l._parent;
2702
2702
  for (; i; ) {
2703
- const u = find(n, { _id: i });
2704
- if (!u) return null;
2705
- if ((c = getRegisteredChaiBlock(u._type)) != null && c.wrapper)
2706
- return u;
2707
- i = u._parent;
2703
+ const d = find(n, { _id: i });
2704
+ if (!d) return null;
2705
+ if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
2706
+ return d;
2707
+ i = d._parent;
2708
2708
  }
2709
2709
  return null;
2710
2710
  });
@@ -2737,18 +2737,18 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2737
2737
  var i;
2738
2738
  if (o.type !== "element" || !o.attributes)
2739
2739
  return o;
2740
- o.tagName === "span" && o.attributes.find((u) => u.key === "role" && u.value === "link") && (o.tagName = "a", o.attributes = o.attributes.filter((u) => u.key !== "role"));
2740
+ o.tagName === "span" && o.attributes.find((d) => d.key === "role" && d.value === "link") && (o.tagName = "a", o.attributes = o.attributes.filter((d) => d.key !== "role"));
2741
2741
  const a = o.attributes.find((c) => c.key === "data-block-type"), l = o.attributes.find((c) => c.key === "data-block-id");
2742
2742
  if (a) {
2743
2743
  const c = a.value;
2744
2744
  if (CORE_BLOCKS$1.includes(c) || (i = r == null ? void 0 : r.EXTRA_CORE_BLOCKS) != null && i.includes(c))
2745
- o.attributes = o.attributes.filter((u) => u.key !== "data-block-type"), o.children && (o.children = o.children.map((u) => transformNode(u, n, r)));
2745
+ o.attributes = o.attributes.filter((d) => d.key !== "data-block-type"), o.children && (o.children = o.children.map((d) => transformNode(d, n, r)));
2746
2746
  else {
2747
- const u = `chai-${kebabCase(c)}`;
2748
- o.tagName = u, l ? o.attributes = [{ key: "id", value: l.value }] : o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
2749
- const p = getRegisteredChaiBlock(c), d = n.find((g) => g._id === (l == null ? void 0 : l.value));
2750
- if (d && o.attributes.push(
2751
- ...Object.entries(d).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
2747
+ const d = `chai-${kebabCase(c)}`;
2748
+ o.tagName = d, l ? o.attributes = [{ key: "id", value: l.value }] : o.attributes = [], o.attributes.push({ key: "chai-type", value: c });
2749
+ const p = getRegisteredChaiBlock(c), u = n.find((g) => g._id === (l == null ? void 0 : l.value));
2750
+ if (u && o.attributes.push(
2751
+ ...Object.entries(u).filter(([g]) => !["_id", "_type", "_parent", "_index", "_name"].includes(g)).map(([g, m]) => ({
2752
2752
  key: g,
2753
2753
  value: typeof m == "string" ? m : JSON.stringify(m)
2754
2754
  }))
@@ -2785,8 +2785,8 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2785
2785
  const l = o != null && o._id ? `[data-block-id="${o._id}"]` : "#canvas", i = (m = (g = r.contentDocument) == null ? void 0 : g.querySelector(l)) == null ? void 0 : m[l === "#canvas" ? "innerHTML" : "outerHTML"];
2786
2786
  if (!i) return "";
2787
2787
  const p = parse(i).map(cleanNode).filter((h) => h !== null).map((h) => transformNode(h, n, a));
2788
- let d = stringify(p);
2789
- return d = d.replace(/#styles:,/g, "#styles:"), d.replace(/\s+/g, " ").trim();
2788
+ let u = stringify(p);
2789
+ return u = u.replace(/#styles:,/g, "#styles:"), u.replace(/\s+/g, " ").trim();
2790
2790
  },
2791
2791
  [o, r]
2792
2792
  );
@@ -2796,14 +2796,14 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2796
2796
  const l = a.i18nProps;
2797
2797
  if (!l) return r;
2798
2798
  const i = filter(n, { _type: r._type }), c = pick(r, l);
2799
- return each(c, (u, p) => {
2800
- const d = find(i, (g) => {
2799
+ return each(c, (d, p) => {
2800
+ const u = find(i, (g) => {
2801
2801
  var f;
2802
- const m = typeof g[p] == "string" ? (f = g[p]) == null ? void 0 : f.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof u == "string" ? u.trim().toLowerCase() : JSON.stringify(u);
2802
+ const m = typeof g[p] == "string" ? (f = g[p]) == null ? void 0 : f.trim().toLowerCase() : JSON.stringify(g[p]), h = typeof d == "string" ? d.trim().toLowerCase() : JSON.stringify(d);
2803
2803
  return m === h;
2804
2804
  });
2805
- if (d) {
2806
- const g = filter(Object.keys(d), (h) => startsWith(h, `${p}-`)), m = pick(d, g);
2805
+ if (u) {
2806
+ const g = filter(Object.keys(u), (h) => startsWith(h, `${p}-`)), m = pick(u, g);
2807
2807
  r = { ...r, ...m };
2808
2808
  }
2809
2809
  }), r;
@@ -2835,9 +2835,9 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
2835
2835
  if (!i) return null;
2836
2836
  const c = (i == null ? void 0 : i.i18nProps) ?? [];
2837
2837
  if (c.length === 0) return null;
2838
- const u = r === "ALL" ? Object.keys(l).filter((d) => c.find((g) => d.startsWith(g))) : c.map((d) => r ? `${d}-${r}` : d), p = pick$1(l, ["_id"]);
2839
- return each$1(u, (d) => {
2840
- p[d] = get$1(l, d, get$1(l, d.replace(`-${r}`, "")));
2838
+ const d = r === "ALL" ? Object.keys(l).filter((u) => c.find((g) => u.startsWith(g))) : c.map((u) => r ? `${u}-${r}` : u), p = pick$1(l, ["_id"]);
2839
+ return each$1(d, (u) => {
2840
+ p[u] = get$1(l, u, get$1(l, u.replace(`-${r}`, "")));
2841
2841
  }), p;
2842
2842
  })
2843
2843
  ) : [];
@@ -2885,11 +2885,11 @@ const getAllDescendantIds = (o, n) => {
2885
2885
  }, replaceBlock = (o, n, r) => {
2886
2886
  const a = find(o, { _id: n });
2887
2887
  if (!a) return o;
2888
- const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), u = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), d = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
2888
+ const l = o.findIndex((m) => m._id === n), i = getAllDescendantIds(o, n), c = /* @__PURE__ */ new Set([n, ...i]), d = o.filter((m) => !c.has(m._id)), p = new Set(r.map((m) => m._id)), u = r.map((m) => !m._parent || !p.has(m._parent) ? { ...m, _parent: a._parent } : m);
2889
2889
  return [
2890
- ...u.slice(0, l),
2891
- ...d,
2892
- ...u.slice(l)
2890
+ ...d.slice(0, l),
2891
+ ...u,
2892
+ ...d.slice(l)
2893
2893
  ];
2894
2894
  }, useReplaceBlock = () => {
2895
2895
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { setNewBlocks: r } = useBlocksStoreUndoableActions(), { hasPermission: a } = usePermissions();
@@ -2979,12 +2979,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), ScalePerc
2979
2979
  // Export Code
2980
2980
  OPEN_EXPORT_CODE: "OPEN_EXPORT_CODE"
2981
2981
  }, AddBlockDropdown = ({ block: o, children: n }) => {
2982
- const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), u = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), d = findIndex(u, { _id: i }), g = (m) => {
2982
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
2983
2983
  if (m === "CHILD")
2984
2984
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
2985
2985
  else {
2986
- const h = { _id: c || "", position: u == null ? void 0 : u.length };
2987
- m === "BEFORE" ? h.position = Math.max(d, 0) : m === "AFTER" && (h.position = d + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
2986
+ const h = { _id: c || "", position: d == null ? void 0 : d.length };
2987
+ m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
2988
2988
  }
2989
2989
  };
2990
2990
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
@@ -3003,9 +3003,9 @@ function getOrientation(o, n = null) {
3003
3003
  const c = r.flexDirection;
3004
3004
  return c === "column" || c === "column-reverse" ? "vertical" : "horizontal";
3005
3005
  } else if (l === "grid") {
3006
- const c = r.gridAutoFlow, u = r.gridTemplateColumns;
3007
- return c.includes("column") || u && u !== "none" && u !== "" && !u.includes("calc") && // Handle calc expressions
3008
- u.split(" ").length <= 1 ? "vertical" : "horizontal";
3006
+ const c = r.gridAutoFlow, d = r.gridTemplateColumns;
3007
+ return c.includes("column") || d && d !== "none" && d !== "" && !d.includes("calc") && // Handle calc expressions
3008
+ d.split(" ").length <= 1 ? "vertical" : "horizontal";
3009
3009
  } else if (i === "inline-block" || i === "inline")
3010
3010
  return "horizontal";
3011
3011
  return "vertical";
@@ -3031,11 +3031,11 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
3031
3031
  return "VERTICAL";
3032
3032
  }
3033
3033
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
3034
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), u = filter(r, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (u == null ? void 0 : u.length) <= 1, d = findIndex(u, { _id: i }), g = d <= 0, m = d + 1 === (u == null ? void 0 : u.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
3034
+ 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, i, a), f = useCallback(
3035
3035
  (x) => {
3036
- isDisabledControl(g, m, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, d - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, d + 2), n());
3036
+ 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());
3037
3037
  },
3038
- [g, m, p, d, i, c, n]
3038
+ [g, m, p, u, i, c, n]
3039
3039
  );
3040
3040
  return useHotkeys(
3041
3041
  "shift+up, shift+down, shift+left, shift+right",
@@ -3051,13 +3051,13 @@ const FrameContext = React__default.createContext({ document: doc, window: win }
3051
3051
  o,
3052
3052
  n
3053
3053
  );
3054
- return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: u, dir: p, key: d }) => c !== p || isDisabledControl(a, l, d) ? null : /* @__PURE__ */ jsx(
3055
- u,
3054
+ return r ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => c !== p || isDisabledControl(a, l, u) ? null : /* @__PURE__ */ jsx(
3055
+ d,
3056
3056
  {
3057
- onClick: () => i(d),
3057
+ onClick: () => i(u),
3058
3058
  className: "rounded p-px hover:bg-white hover:text-blue-500"
3059
3059
  },
3060
- d
3060
+ u
3061
3061
  )) });
3062
3062
  }, AiIcon = ({
3063
3063
  className: o = "h-full w-full",
@@ -3085,15 +3085,15 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3085
3085
  const { editingBlockId: o, setEditingBlockId: n, setEditingItemIndex: r } = useInlineEditing();
3086
3086
  return useCallback(
3087
3087
  (a) => {
3088
- var u;
3088
+ var d;
3089
3089
  if (a == null || a.preventDefault(), a == null || a.stopPropagation(), o) return;
3090
3090
  const l = getTargetedBlock(a.target);
3091
3091
  if (!isInlineEditable(l)) return;
3092
3092
  const i = l.getAttribute("data-block-id");
3093
3093
  if (!i || !l) return;
3094
3094
  const c = l.closest('[data-block-type="Repeater"]');
3095
- c ? (u = c == null ? void 0 : c.childNodes) == null || u.forEach((p, d) => {
3096
- p.contains(l) && r(d);
3095
+ c ? (d = c == null ? void 0 : c.childNodes) == null || d.forEach((p, u) => {
3096
+ p.contains(l) && r(u);
3097
3097
  }) : r(-1), n(i);
3098
3098
  },
3099
3099
  [o, n, r]
@@ -3110,11 +3110,11 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3110
3110
  return;
3111
3111
  }
3112
3112
  if (c != null && c.getAttribute("data-block-parent")) {
3113
- const u = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), d = c.getAttribute("data-block-parent");
3114
- pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: d, styleId: p, styleProp: u });
3113
+ const d = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), u = c.getAttribute("data-block-parent");
3114
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: p, styleProp: d });
3115
3115
  } else if (c != null && c.getAttribute("data-block-id")) {
3116
- const u = c.getAttribute("data-block-id");
3117
- pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, u === "canvas" ? [] : [u]);
3116
+ const d = c.getAttribute("data-block-id");
3117
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, d === "canvas" ? [] : [d]);
3118
3118
  }
3119
3119
  n(), r.current = (/* @__PURE__ */ new Date()).getTime();
3120
3120
  },
@@ -3165,29 +3165,29 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3165
3165
  }
3166
3166
  );
3167
3167
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), BlockSelectionHighlighter = () => {
3168
- const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), c = (u, p = 0) => {
3169
- const { top: d } = u.getBoundingClientRect();
3170
- return d + p >= 0 && d - p <= window.innerHeight;
3168
+ const o = useSelectedBlock(), { document: n } = useFrame(), [r] = useSelectedStylingBlocks(), [a, l] = useState([]), [, i] = useState([]), c = (d, p = 0) => {
3169
+ const { top: u } = d.getBoundingClientRect();
3170
+ return u + p >= 0 && u - p <= window.innerHeight;
3171
3171
  };
3172
3172
  return useEffect(() => {
3173
- var u;
3173
+ var d;
3174
3174
  if (o != null && o._id && o.type !== "Multiple" && n) {
3175
3175
  const p = getElementByDataBlockId(n, o._id);
3176
- p && (c(p) || (u = n.defaultView) == null || u.scrollTo({ top: p.offsetTop, behavior: "smooth" }), l([p]));
3176
+ p && (c(p) || (d = n.defaultView) == null || d.scrollTo({ top: p.offsetTop, behavior: "smooth" }), l([p]));
3177
3177
  }
3178
3178
  }, [o == null ? void 0 : o._id, o == null ? void 0 : o.type, n]), useEffect(() => {
3179
3179
  if (!isEmpty(r) && n) {
3180
- const u = getElementByStyleId(n, first(r).id);
3181
- i(u ? [u] : [null]);
3180
+ const d = getElementByStyleId(n, first(r).id);
3181
+ i(d ? [d] : [null]);
3182
3182
  } else
3183
3183
  i([null]);
3184
3184
  }, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
3185
3185
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
3186
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: u } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: d } = useFrame(), g = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: m, refs: h, update: f } = useFloating({
3186
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), g = useBuilderProp("flags.gotoSettings", !1), { floatingStyles: m, refs: h, update: f } = useFloating({
3187
3187
  placement: "top-start",
3188
3188
  middleware: [
3189
3189
  shift({
3190
- boundary: d == null ? void 0 : d.body,
3190
+ boundary: u == null ? void 0 : u.body,
3191
3191
  limiter: limitShift({
3192
3192
  offset: 8,
3193
3193
  mainAxis: !0,
@@ -3195,27 +3195,27 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3195
3195
  })
3196
3196
  }),
3197
3197
  flip({
3198
- boundary: d == null ? void 0 : d.body,
3198
+ boundary: u == null ? void 0 : u.body,
3199
3199
  fallbackPlacements: ["bottom-start", "top-end", "bottom-end", "inside"]
3200
3200
  }),
3201
3201
  size({
3202
- boundary: d == null ? void 0 : d.body,
3203
- apply({ availableWidth: C, availableHeight: S, elements: w }) {
3204
- Object.assign(w.floating.style, {
3205
- maxWidth: `${Math.max(200, C)}px`,
3206
- maxHeight: `${Math.max(100, S)}px`
3202
+ boundary: u == null ? void 0 : u.body,
3203
+ apply({ availableWidth: S, availableHeight: C, elements: v }) {
3204
+ Object.assign(v.floating.style, {
3205
+ maxWidth: `${Math.max(200, S)}px`,
3206
+ maxHeight: `${Math.max(100, C)}px`
3207
3207
  });
3208
3208
  }
3209
3209
  })
3210
3210
  ],
3211
3211
  elements: { reference: n }
3212
3212
  });
3213
- useResizeObserver(n, () => f(), n !== null), useResizeObserver(d == null ? void 0 : d.body, () => f(), (d == null ? void 0 : d.body) !== null);
3213
+ useResizeObserver(n, () => f(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => f(), (u == null ? void 0 : u.body) !== null);
3214
3214
  const x = get(o, "_parent", null), b = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3215
3215
  useEffect(() => {
3216
3216
  if (n) {
3217
- const C = setTimeout(() => f(), 500);
3218
- return () => clearTimeout(C);
3217
+ const S = setTimeout(() => f(), 500);
3218
+ return () => clearTimeout(S);
3219
3219
  } else
3220
3220
  f();
3221
3221
  }, [n]);
@@ -3227,13 +3227,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3227
3227
  tabIndex: 0,
3228
3228
  ref: h.setFloating,
3229
3229
  style: m,
3230
- onClick: (C) => {
3231
- C.stopPropagation(), C.preventDefault();
3230
+ onClick: (S) => {
3231
+ S.stopPropagation(), S.preventDefault();
3232
3232
  },
3233
- onMouseEnter: (C) => {
3234
- C.stopPropagation(), i(null);
3233
+ onMouseEnter: (S) => {
3234
+ S.stopPropagation(), i(null);
3235
3235
  },
3236
- onKeyDown: (C) => C.stopPropagation(),
3236
+ onKeyDown: (S) => S.stopPropagation(),
3237
3237
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3238
3238
  children: [
3239
3239
  x && /* @__PURE__ */ jsx(
@@ -3247,7 +3247,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3247
3247
  ),
3248
3248
  /* @__PURE__ */ jsx(BlockActionLabel, { label: b, block: o }),
3249
3249
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pl-1 pr-1.5", children: [
3250
- u(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
3250
+ d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
3251
3251
  AiIcon,
3252
3252
  {
3253
3253
  className: "h-4 w-4 rounded hover:bg-white hover:text-blue-500",
@@ -3262,21 +3262,21 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
3262
3262
  }
3263
3263
  ),
3264
3264
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500" }) }),
3265
- canDuplicateBlock(get(o, "_type", "")) && u(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
3265
+ canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(
3266
3266
  CopyIcon,
3267
3267
  {
3268
3268
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
3269
3269
  onClick: () => a([o == null ? void 0 : o._id])
3270
3270
  }
3271
3271
  ) : null,
3272
- canDeleteBlock(get(o, "_type", "")) && u(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
3272
+ canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(
3273
3273
  TrashIcon,
3274
3274
  {
3275
3275
  className: "h-4 w-4 rounded p-px hover:bg-white hover:text-blue-500",
3276
3276
  onClick: () => r([o == null ? void 0 : o._id])
3277
3277
  }
3278
3278
  ) : null,
3279
- u(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: f })
3279
+ d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: f })
3280
3280
  ] })
3281
3281
  ]
3282
3282
  }
@@ -3453,8 +3453,8 @@ class Frame extends Component {
3453
3453
  const r = this.getDoc();
3454
3454
  if (!r)
3455
3455
  return null;
3456
- const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = r.defaultView || r.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: r, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), u = this.getMountTarget();
3457
- return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, u)];
3456
+ const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = r.defaultView || r.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: r, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), d = this.getMountTarget();
3457
+ return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, d)];
3458
3458
  }
3459
3459
  render() {
3460
3460
  const r = {
@@ -3478,12 +3478,12 @@ $(Frame, "defaultProps", {
3478
3478
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
3479
3479
  });
3480
3480
  const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
3481
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: u } = useUndoManager(), [, p] = useCutBlockIds(), [, d] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3482
- useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => u(), {}, [u]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
3481
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3482
+ useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
3483
3483
  "ctrl+c,command+c",
3484
- () => d(n),
3484
+ () => u(n),
3485
3485
  { ...h, enabled: !isEmpty(n), preventDefault: !0 },
3486
- [n, d]
3486
+ [n, u]
3487
3487
  ), useHotkeys(
3488
3488
  "ctrl+v,command+v",
3489
3489
  () => {
@@ -3590,7 +3590,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3590
3590
  heading: get(o, "fontFamily.heading"),
3591
3591
  body: get(o, "fontFamily.body")
3592
3592
  };
3593
- return n.filter((u) => u.family === i || u.family === c);
3593
+ return n.filter((d) => d.family === i || d.family === c);
3594
3594
  }, [o == null ? void 0 : o.fontFamily, n]), a = useMemo(() => getThemeFontsUrls(filter(r, (i) => has(i, "url"))), [r]), l = useMemo(
3595
3595
  () => getThemeCustomFontFace(filter(r, (i) => has(i, "src"))),
3596
3596
  [r]
@@ -3612,14 +3612,14 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3612
3612
  const { clientWidth: p } = i.current;
3613
3613
  n(p);
3614
3614
  }, []);
3615
- const u = useCallback(() => {
3615
+ const d = useCallback(() => {
3616
3616
  a([]), l([]);
3617
3617
  }, [a, l]);
3618
3618
  return /* @__PURE__ */ jsx(
3619
3619
  "div",
3620
3620
  {
3621
3621
  id: "main-content",
3622
- onClick: u,
3622
+ onClick: d,
3623
3623
  className: "h-full w-full border-l-4 border-r-4 pb-0",
3624
3624
  ref: i,
3625
3625
  children: o
@@ -3633,9 +3633,9 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3633
3633
  return useCallback(
3634
3634
  (n, r) => isEmpty(r) ? {} : Object.entries(r).reduce((a, [l, i]) => {
3635
3635
  const c = [];
3636
- let u = find(o, { _id: n });
3637
- for (; u; )
3638
- c.push(u), u = find(o, { _id: u._parent });
3636
+ let d = find(o, { _id: n });
3637
+ for (; d; )
3638
+ c.push(d), d = find(o, { _id: d._parent });
3639
3639
  const p = find(c, { _type: i.block });
3640
3640
  return p && (a[l] = get(p, get(i, "prop"), null)), a;
3641
3641
  }, {}),
@@ -3701,22 +3701,22 @@ const RteDropdownMenu = ({
3701
3701
  from: a,
3702
3702
  menuRef: l
3703
3703
  }) => {
3704
- const { document: i } = useFrame(), [c, u] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, d] = useState(!1), g = useRef(null);
3704
+ const { document: i } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [p, u] = useState(!1), g = useRef(null);
3705
3705
  if (useEffect(() => {
3706
- var C, S;
3706
+ var S, C;
3707
3707
  if (!p) {
3708
- u({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
3708
+ d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
3709
3709
  return;
3710
3710
  }
3711
- const m = (C = g.current) == null ? void 0 : C.getBoundingClientRect(), h = (S = l.current) == null ? void 0 : S.getBoundingClientRect();
3711
+ const m = (S = g.current) == null ? void 0 : S.getBoundingClientRect(), h = (C = l.current) == null ? void 0 : C.getBoundingClientRect();
3712
3712
  let f = m == null ? void 0 : m.left, x = (m == null ? void 0 : m.bottom) + 4, b, y;
3713
- (h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), u({ left: f, top: x, right: b, bottom: y });
3713
+ (h == null ? void 0 : h.left) + (h == null ? void 0 : h.width) + 50 >= i.body.offsetWidth && (f = void 0, b = i.body.offsetWidth - (m == null ? void 0 : m.right)), x + 202 >= i.body.clientHeight && (x = null, y = i.body.clientHeight - (m == null ? void 0 : m.bottom) + (h == null ? void 0 : h.height)), d({ left: f, top: x, right: b, bottom: y });
3714
3714
  }, [p]), a === "canvas") {
3715
3715
  const m = () => {
3716
- d(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
3716
+ u(!1), o && (o == null || o.view.focus(), o == null || o.chain().focus().run());
3717
3717
  };
3718
3718
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3719
- /* @__PURE__ */ jsx("div", { ref: g, onClick: () => d((h) => !h), className: "cursor-pointer", children: n }),
3719
+ /* @__PURE__ */ jsx("div", { ref: g, onClick: () => u((h) => !h), className: "cursor-pointer", children: n }),
3720
3720
  p && (c.left !== void 0 || c.top !== void 0 || c.right !== void 0 || c.bottom !== void 0) && createPortal(
3721
3721
  /* @__PURE__ */ jsx(
3722
3722
  "div",
@@ -3743,9 +3743,9 @@ const RteDropdownMenu = ({
3743
3743
  )
3744
3744
  ] });
3745
3745
  }
3746
- return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: d, children: [
3746
+ return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(DropdownMenu, { open: p, onOpenChange: u, children: [
3747
3747
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { className: "relative outline-none", asChild: !0, children: n }),
3748
- /* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() => d(!1)) : r) })
3748
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: "z-50 rounded-md border bg-white p-1 text-xs shadow-xl", children: p && (typeof r == "function" ? r(() => u(!1)) : r) })
3749
3749
  ] }) });
3750
3750
  };
3751
3751
  atomWithStorage("chai-builder-blocks", []);
@@ -3817,7 +3817,7 @@ const getActiveClasses$1 = (o, n, r) => {
3817
3817
  onRemoveHighlightColor: i,
3818
3818
  onClose: c
3819
3819
  }) => {
3820
- const [u] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), d = (p == null ? void 0 : p.colors) || {}, g = Object.values(d).map((f) => get(f, u ? "1" : "0")), [m, h] = useState("TEXT");
3820
+ const [d] = useDarkMode(), [p] = useAtom$1(lsThemeAtom), u = (p == null ? void 0 : p.colors) || {}, g = Object.values(u).map((f) => get(f, d ? "1" : "0")), [m, h] = useState("TEXT");
3821
3821
  return /* @__PURE__ */ jsxs("div", { id: "rte-widget-color-picker", className: "px-1", children: [
3822
3822
  /* @__PURE__ */ jsxs("div", { className: "mb-2 flex items-center justify-between rounded-md border bg-muted", children: [
3823
3823
  /* @__PURE__ */ jsx(
@@ -3858,8 +3858,8 @@ const getActiveClasses$1 = (o, n, r) => {
3858
3858
  )
3859
3859
  ] });
3860
3860
  }, RteColorPicker = ({ editor: o, from: n, menuRef: r }) => {
3861
- var S, w;
3862
- const a = (S = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : S.color, l = (w = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : w.color, [i, c] = useState(a || "#000000F2"), [u, p] = useState(l || "#00000057"), [d, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(u, 150), f = (_, B) => {
3861
+ var C, v;
3862
+ const a = (C = o == null ? void 0 : o.getAttributes("textStyle")) == null ? void 0 : C.color, l = (v = o == null ? void 0 : o.getAttributes("highlight")) == null ? void 0 : v.color, [i, c] = useState(a || "#000000F2"), [d, p] = useState(l || "#00000057"), [u, g] = useDebouncedState(i, 150), [m, h] = useDebouncedState(d, 150), f = (_, B) => {
3863
3863
  B ? (c(_), g(_)) : (o == null || o.chain().setColor(_).run(), c(_));
3864
3864
  }, x = (_, B) => {
3865
3865
  B ? (p(_), h(_)) : (o == null || o.chain().setHighlight({ color: _ }).run(), p(_));
@@ -3873,8 +3873,8 @@ const getActiveClasses$1 = (o, n, r) => {
3873
3873
  }, [l]), useEffect(() => {
3874
3874
  m != null && m.includes("#") && (m == null ? void 0 : m.length) >= 3 && (o == null || o.chain().setHighlight({ color: m }).run());
3875
3875
  }, [m]), useEffect(() => {
3876
- d != null && d.includes("#") && (d == null ? void 0 : d.length) >= 3 && (o == null || o.chain().setColor(d).run());
3877
- }, [d]), /* @__PURE__ */ jsx(
3876
+ u != null && u.includes("#") && (u == null ? void 0 : u.length) >= 3 && (o == null || o.chain().setColor(u).run());
3877
+ }, [u]), /* @__PURE__ */ jsx(
3878
3878
  RteDropdownMenu,
3879
3879
  {
3880
3880
  editor: o,
@@ -3896,7 +3896,7 @@ const getActiveClasses$1 = (o, n, r) => {
3896
3896
  ColorPickerContent,
3897
3897
  {
3898
3898
  textColor: i,
3899
- highlightColor: u,
3899
+ highlightColor: d,
3900
3900
  onChangeTextColor: f,
3901
3901
  onChangeHighlightColor: x,
3902
3902
  onRemoveTextColor: b,
@@ -4168,35 +4168,35 @@ const RichTextEditor = memo(
4168
4168
  value: o,
4169
4169
  blockId: "active-inline-editing-element",
4170
4170
  placeholder: "Enter text here",
4171
- onUpdate: ({ editor: d }) => a((d == null ? void 0 : d.getHTML()) || ""),
4172
- onBlur: ({ editor: d, event: g }) => {
4173
- const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m), C = x == null ? void 0 : x.contains(m), S = window.document.getElementById("rte-widget-color-picker");
4174
- if (!b && !y && !C && !S) {
4175
- const w = (d == null ? void 0 : d.getHTML()) || "";
4176
- r(w);
4171
+ onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
4172
+ onBlur: ({ editor: u, event: g }) => {
4173
+ const m = g == null ? void 0 : g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = i.querySelector("#chai-rich-text-menu-bar"), b = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m), S = x == null ? void 0 : x.contains(m), C = window.document.getElementById("rte-widget-color-picker");
4174
+ if (!b && !y && !S && !C) {
4175
+ const v = (u == null ? void 0 : u.getHTML()) || "";
4176
+ r(v);
4177
4177
  }
4178
4178
  },
4179
4179
  from: "canvas"
4180
4180
  });
4181
4181
  useEffect(() => {
4182
4182
  var g, m;
4183
- const d = getInitialTextAlign(n);
4184
- d && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(d)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
4183
+ const u = getInitialTextAlign(n);
4184
+ u && ((g = c == null ? void 0 : c.commands) == null || g.setTextAlign(u)), (m = c == null ? void 0 : c.commands) == null || m.focus(), c == null || c.emit("focus", {
4185
4185
  editor: c,
4186
4186
  event: new FocusEvent("focus"),
4187
4187
  transaction: []
4188
4188
  });
4189
4189
  }, [c]);
4190
- const u = useMemo(() => {
4190
+ const d = useMemo(() => {
4191
4191
  var m;
4192
- const d = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
4193
- if (!n) return d;
4192
+ const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
4193
+ if (!n) return u;
4194
4194
  const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
4195
- return `${d} ${g}`;
4196
- }, [n]), p = (d) => {
4197
- d.key === "Escape" && l(d);
4195
+ return `${u} ${g}`;
4196
+ }, [n]), p = (u) => {
4197
+ u.key === "Escape" && l(u);
4198
4198
  };
4199
- return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (d) => d.stopPropagation(), className: "relative", children: [
4199
+ return c && /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (u) => u.stopPropagation(), className: "relative", children: [
4200
4200
  /* @__PURE__ */ jsx(
4201
4201
  BubbleMenu,
4202
4202
  {
@@ -4207,7 +4207,7 @@ const RichTextEditor = memo(
4207
4207
  children: /* @__PURE__ */ jsx(RteMenubar, { editor: c, from: "canvas" })
4208
4208
  }
4209
4209
  ),
4210
- /* @__PURE__ */ jsx(EditorContent, { onKeyDown: p, value: o, editor: c, className: u })
4210
+ /* @__PURE__ */ jsx(EditorContent, { onKeyDown: p, value: o, editor: c, className: d })
4211
4211
  ] });
4212
4212
  }
4213
4213
  ), MemoizedEditor = memo(
@@ -4219,20 +4219,20 @@ const RichTextEditor = memo(
4219
4219
  onChange: l,
4220
4220
  onEscape: i
4221
4221
  }) => {
4222
- const { document: c, window: u } = useFrame();
4222
+ const { document: c, window: d } = useFrame();
4223
4223
  useEffect(() => {
4224
4224
  if (a.current) {
4225
4225
  a.current.innerHTML = n, a.current.focus();
4226
- const h = c.createRange(), f = u.getSelection();
4226
+ const h = c.createRange(), f = d.getSelection();
4227
4227
  h.selectNodeContents(a.current), h.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(h), a.current.focus();
4228
4228
  } else
4229
4229
  r();
4230
- }, [c, u]);
4230
+ }, [c, d]);
4231
4231
  const p = useMemo(() => {
4232
4232
  var f;
4233
4233
  const h = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
4234
4234
  return h === "button" ? "div" : h;
4235
- }, [o]), d = useCallback(
4235
+ }, [o]), u = useCallback(
4236
4236
  (h) => {
4237
4237
  (h.key === "Enter" || h.key === "Escape") && i(h);
4238
4238
  },
@@ -4258,23 +4258,23 @@ const RichTextEditor = memo(
4258
4258
  return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
4259
4259
  ref: a,
4260
4260
  onBlur: g,
4261
- onKeyDown: d,
4261
+ onKeyDown: u,
4262
4262
  ...m
4263
4263
  }) });
4264
4264
  }
4265
4265
  ), WithBlockTextEditor = memo(
4266
4266
  ({ block: o, children: n }) => {
4267
- const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: u } = useInlineEditing(), [p, d] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: C, blockType: S } = useMemo(() => {
4267
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: f } = useLanguages(), [, x] = useSelectedBlockIds(), b = useRef(null), y = l, { blockContent: S, blockType: C } = useMemo(() => {
4268
4268
  var j;
4269
4269
  const k = o._type;
4270
4270
  let A = o[r];
4271
- const v = getRegisteredChaiBlock(o._type);
4272
- return f && ((j = v == null ? void 0 : v.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (A = get(o, `${r}-${f}`)), { blockContent: A, blockType: k };
4273
- }, [o, f]), w = useCallback(
4271
+ const w = getRegisteredChaiBlock(o._type);
4272
+ return f && ((j = w == null ? void 0 : w.i18nProps) == null ? void 0 : j.includes(r)) && has(o, `${r}-${f}`) && (A = get(o, `${r}-${f}`)), { blockContent: A, blockType: k };
4273
+ }, [o, f]), v = useCallback(
4274
4274
  (k) => {
4275
- var v;
4276
- const A = k || ((v = g.current) == null ? void 0 : v.innerText);
4277
- h([y], { [r]: A }), d(null), c(null), u(-1), x([]), y && setTimeout(() => x([y]), 100);
4275
+ var w;
4276
+ const A = k || ((w = g.current) == null ? void 0 : w.innerText);
4277
+ h([y], { [r]: A }), u(null), c(null), d(-1), x([]), y && setTimeout(() => x([y]), 100);
4278
4278
  },
4279
4279
  [y, h, c, x, f]
4280
4280
  ), _ = useDebouncedCallback(
@@ -4285,7 +4285,7 @@ const RichTextEditor = memo(
4285
4285
  1e3
4286
4286
  ), B = useCallback(
4287
4287
  (k) => {
4288
- k.preventDefault(), y && (b.current = y), w(), setTimeout(() => {
4288
+ k.preventDefault(), y && (b.current = y), v(), setTimeout(() => {
4289
4289
  const A = b.current;
4290
4290
  b.current = null, x([A]);
4291
4291
  }, 100);
@@ -4295,29 +4295,29 @@ const RichTextEditor = memo(
4295
4295
  useEffect(() => {
4296
4296
  var E;
4297
4297
  if (!y) return;
4298
- const k = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "", v = a.querySelector(`${k}${A}`);
4299
- v && ((E = v == null ? void 0 : v.classList) == null || E.add("sr-only"), d(v));
4300
- }, [y, S, a, i]);
4301
- const I = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(S) ? /* @__PURE__ */ jsx(
4298
+ const k = `[data-block-id="${y}"]`, A = i >= 0 ? `[data-block-index="${i}"]` : "", w = a.querySelector(`${k}${A}`);
4299
+ w && ((E = w == null ? void 0 : w.classList) == null || E.add("sr-only"), u(w));
4300
+ }, [y, C, a, i]);
4301
+ const I = useMemo(() => p ? (m(), ["RichText", "Paragraph"].includes(C) ? /* @__PURE__ */ jsx(
4302
4302
  RichTextEditor,
4303
4303
  {
4304
- blockContent: C,
4304
+ blockContent: S,
4305
4305
  editingElement: p,
4306
4306
  onChange: _,
4307
- onClose: w,
4307
+ onClose: v,
4308
4308
  onEscape: B
4309
4309
  }
4310
4310
  ) : /* @__PURE__ */ jsx(
4311
4311
  MemoizedEditor,
4312
4312
  {
4313
4313
  editorRef: g,
4314
- blockContent: C,
4314
+ blockContent: S,
4315
4315
  editingElement: p,
4316
- onClose: w,
4316
+ onClose: v,
4317
4317
  onChange: _,
4318
4318
  onEscape: B
4319
4319
  }
4320
- )) : null, [p, y, S, C, w, f]);
4320
+ )) : null, [p, y, C, S, v, f]);
4321
4321
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4322
4322
  I,
4323
4323
  n
@@ -4355,40 +4355,40 @@ const RichTextEditor = memo(
4355
4355
  blockAtom: n,
4356
4356
  children: r
4357
4357
  }) => {
4358
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: u, fallbackLang: p } = useLanguages(), d = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useMemo(
4359
- () => m ? applyBindingToBlockProps(applyLanguage(i, u, c), g, {
4358
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useAtom$1(dataBindingActiveAtom), h = get(c, "component", null), { index: f, key: x } = useContext(RepeaterContext), { mode: b } = useEditorMode(), y = useMemo(
4359
+ () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
4360
4360
  index: f,
4361
4361
  key: x
4362
- }) : applyLanguage(i, u, c),
4363
- [i, u, c, g, m, f, x]
4364
- ), C = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), S = useMemo(
4365
- () => d(i._id, getBlockRuntimeProps(i._type)),
4366
- [i._id, i._type, d, getBlockRuntimeProps]
4367
- ), w = useMemo(
4362
+ }) : applyLanguage(i, d, c),
4363
+ [i, d, c, g, m, f, x]
4364
+ ), S = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), C = useMemo(
4365
+ () => u(i._id, getBlockRuntimeProps(i._type)),
4366
+ [i._id, i._type, u, getBlockRuntimeProps]
4367
+ ), v = useMemo(
4368
4368
  () => ({
4369
4369
  blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
4370
4370
  inBuilder: b === "edit",
4371
- lang: u || p,
4371
+ lang: d || p,
4372
4372
  ...y,
4373
- ...C,
4374
4373
  ...S,
4374
+ ...C,
4375
4375
  ...o
4376
4376
  }),
4377
4377
  [
4378
4378
  b,
4379
4379
  i._id,
4380
4380
  i._type,
4381
- u,
4381
+ d,
4382
4382
  p,
4383
4383
  y,
4384
- C,
4385
4384
  S,
4385
+ C,
4386
4386
  o
4387
4387
  ]
4388
4388
  ), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]), B = useMemo(() => get(i, "_show", !0), [i]);
4389
4389
  if (isNull(h) || !B) return null;
4390
4390
  let I = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
4391
- ...w,
4391
+ ...v,
4392
4392
  children: r({
4393
4393
  _id: i._id,
4394
4394
  _type: i._type,
@@ -4404,8 +4404,8 @@ const RichTextEditor = memo(
4404
4404
  return _ ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: k }) : k;
4405
4405
  }, PartialWrapper$1 = ({ children: o, partialBlockId: n }) => {
4406
4406
  const r = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
4407
- (u) => {
4408
- if (u.stopPropagation(), a !== "SAVED") {
4407
+ (d) => {
4408
+ if (d.stopPropagation(), a !== "SAVED") {
4409
4409
  toast.error("You have unsaved changes. Please save the page first.");
4410
4410
  return;
4411
4411
  }
@@ -4435,16 +4435,16 @@ const RichTextEditor = memo(
4435
4435
  }) => {
4436
4436
  const l = useGetBlockAtom(r);
4437
4437
  let i = useMemo(
4438
- () => filter(o, (u) => has(u, "_id") && (isEmpty(n) ? !u._parent : u._parent === n)),
4438
+ () => filter(o, (d) => has(d, "_id") && (isEmpty(n) ? !d._parent : d._parent === n)),
4439
4439
  [o, n]
4440
4440
  );
4441
4441
  const c = useCallback(
4442
- (u) => filter(o, (p) => p._parent === u).length > 0,
4442
+ (d) => filter(o, (p) => p._parent === d).length > 0,
4443
4443
  [o]
4444
4444
  );
4445
- return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (u) => {
4446
- const p = l(u._id);
4447
- return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: u, children: (d) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: d, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: u._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: u._id, type: m }) : null }) }, u._id) : null;
4445
+ return c && (a === "Heading" || a === "Paragraph" || a === "Link") && (i = adjustSpacingInContentBlocks(i)), map(i, (d) => {
4446
+ const p = l(d._id);
4447
+ return p ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: d, children: (u) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: p, asyncProps: u, children: ({ _id: g, _type: m, partialBlockId: h, repeaterItems: f, $repeaterItemsKey: x }) => m === "Repeater" ? isArray(f) && f.map((b, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) }, `${g}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : c(g) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: d._id, type: m }) : null }) }, d._id) : null;
4448
4448
  });
4449
4449
  }, PageBlocksRenderer = () => {
4450
4450
  const [o] = useBlocksStore();
@@ -4454,24 +4454,24 @@ const RichTextEditor = memo(
4454
4454
  return /* @__PURE__ */ jsx(Fragment, { children: n });
4455
4455
  }, useCanvasScale = (o) => {
4456
4456
  const [n] = useCanvasDisplayWidth(), [, r] = useCanvasZoom(), a = useBuilderProp("htmlDir", "ltr"), [l, i] = useState({}), c = useCallback(() => {
4457
- const { width: u, height: p } = o;
4458
- if (u < n) {
4459
- const d = parseFloat((u / n).toFixed(2).toString());
4457
+ const { width: d, height: p } = o;
4458
+ if (d < n) {
4459
+ const u = parseFloat((d / n).toFixed(2).toString());
4460
4460
  let g = {};
4461
- const m = p * d, h = u * d;
4461
+ const m = p * u, h = d * u;
4462
4462
  p && (g = {
4463
4463
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
4464
4464
  height: 100 + (p - m) / m * 100 + "%",
4465
- width: 100 + (u - h) / h * 100 + "%"
4465
+ width: 100 + (d - h) / h * 100 + "%"
4466
4466
  }), i({
4467
4467
  position: "relative",
4468
4468
  top: 0,
4469
- transform: `scale(${d})`,
4469
+ transform: `scale(${u})`,
4470
4470
  transformOrigin: a === "rtl" ? "top right" : "top left",
4471
4471
  ...g,
4472
4472
  maxWidth: "none"
4473
4473
  // TODO: Add max-width to the wrapper
4474
- }), r(d * 100);
4474
+ }), r(u * 100);
4475
4475
  } else
4476
4476
  i({}), r(100);
4477
4477
  }, [n, o, a, r]);
@@ -4484,26 +4484,26 @@ const RichTextEditor = memo(
4484
4484
  setTimeout(() => {
4485
4485
  if (!isEmpty(n))
4486
4486
  return;
4487
- const u = getElementByDataBlockId(a, first(i));
4488
- if (u) {
4489
- const p = u.getAttribute("data-style-prop");
4487
+ const d = getElementByDataBlockId(a, first(i));
4488
+ if (d) {
4489
+ const p = d.getAttribute("data-style-prop");
4490
4490
  if (p) {
4491
- const d = u.getAttribute("data-style-id"), g = u.getAttribute("data-block-parent");
4492
- r([{ id: d, prop: p, blockId: g }]);
4491
+ const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
4492
+ r([{ id: u, prop: p, blockId: g }]);
4493
4493
  }
4494
4494
  }
4495
4495
  }, 100);
4496
- }, [a, i, r, n]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (u) => {
4497
- u && (!isEmpty(u) && !includes(i, first(u)) && (c == null || c.closeAll()), o(u));
4498
- }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (u) => {
4499
- if (!u) return;
4500
- const { blockId: p, styleId: d, styleProp: g } = u;
4501
- p && (includes(i, p) || c == null || c.closeAll(), r([{ id: d, prop: g, blockId: p }]), o([p]));
4496
+ }, [a, i, r, n]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (d) => {
4497
+ d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
4498
+ }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
4499
+ if (!d) return;
4500
+ const { blockId: p, styleId: u, styleProp: g } = d;
4501
+ p && (includes(i, p) || c == null || c.closeAll(), r([{ id: u, prop: g, blockId: p }]), o([p]));
4502
4502
  }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
4503
4503
  l(), o([]), r([]);
4504
4504
  }), null;
4505
4505
  }, StaticCanvas = () => {
4506
- const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, u] = useCanvasIframe(), p = useBuilderProp("loading", !1), d = useBuilderProp("htmlDir", "ltr"), g = useCallback(
4506
+ const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useCanvasIframe(), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
4507
4507
  (h) => {
4508
4508
  i((f) => ({ ...f, width: h }));
4509
4509
  },
@@ -4516,8 +4516,8 @@ const RichTextEditor = memo(
4516
4516
  }, [a, o]);
4517
4517
  const m = useMemo(() => {
4518
4518
  let h = IframeInitialContent;
4519
- return h = h.replace("__HTML_DIR__", d), h;
4520
- }, [d]);
4519
+ return h = h.replace("__HTML_DIR__", u), h;
4520
+ }, [u]);
4521
4521
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
4522
4522
  "div",
4523
4523
  {
@@ -4527,7 +4527,7 @@ const RichTextEditor = memo(
4527
4527
  children: /* @__PURE__ */ jsxs(
4528
4528
  ChaiFrame,
4529
4529
  {
4530
- contentDidMount: () => u(r.current),
4530
+ contentDidMount: () => d(r.current),
4531
4531
  ref: r,
4532
4532
  id: "canvas-iframe",
4533
4533
  style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
@@ -4562,7 +4562,7 @@ const RichTextEditor = memo(
4562
4562
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: o("Oops! Something went wrong.") }),
4563
4563
  /* @__PURE__ */ jsx("p", { children: o("Please try again.") })
4564
4564
  ] }) });
4565
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-CihZ_PJK.js")), CanvasArea = () => {
4565
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-B1G67AXy.js")), CanvasArea = () => {
4566
4566
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4567
4567
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
4568
4568
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4602,9 +4602,9 @@ const RichTextEditor = memo(
4602
4602
  useEffect(() => {
4603
4603
  i(o || "");
4604
4604
  }, [o]);
4605
- const c = (u) => {
4606
- i(u);
4607
- const p = sanitizeSvg(u);
4605
+ const c = (d) => {
4606
+ i(d);
4607
+ const p = sanitizeSvg(d);
4608
4608
  n(p);
4609
4609
  };
4610
4610
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex flex-col gap-2", id: "icon-picker-field", children: [
@@ -4618,7 +4618,7 @@ const RichTextEditor = memo(
4618
4618
  autoCorrect: "off",
4619
4619
  spellCheck: "false",
4620
4620
  value: l,
4621
- onChange: (u) => c(u.target.value),
4621
+ onChange: (d) => c(d.target.value),
4622
4622
  placeholder: a("SVG_code"),
4623
4623
  rows: 2,
4624
4624
  className: "no-scrollbar w-full rounded-md border border-border bg-background px-3 py-1.5 text-xs shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50"
@@ -4631,7 +4631,7 @@ const RichTextEditor = memo(
4631
4631
  ] })
4632
4632
  ] });
4633
4633
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
4634
- const [a, l] = useState(""), [i, c] = useState(!1), [u, p] = useState(!1), [d, g] = useState(null), m = async (f) => {
4634
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (f) => {
4635
4635
  if (!f.trim()) {
4636
4636
  p(!1), g("Please enter a URL");
4637
4637
  return;
@@ -4646,9 +4646,9 @@ const RichTextEditor = memo(
4646
4646
  }, { t: h } = useTranslation();
4647
4647
  return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
4648
4648
  /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: h(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
4649
- d && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
4649
+ u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
4650
4650
  /* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-4 w-4" }),
4651
- /* @__PURE__ */ jsx(AlertDescription, { children: d })
4651
+ /* @__PURE__ */ jsx(AlertDescription, { children: u })
4652
4652
  ] }),
4653
4653
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-4", children: [
4654
4654
  /* @__PURE__ */ jsx(
@@ -4666,7 +4666,7 @@ const RichTextEditor = memo(
4666
4666
  Button,
4667
4667
  {
4668
4668
  onClick: () => n({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
4669
- disabled: !u || i,
4669
+ disabled: !d || i,
4670
4670
  children: h("Insert")
4671
4671
  }
4672
4672
  )
@@ -4701,31 +4701,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4701
4701
  const n = ((l = o.split("/").pop()) == null ? void 0 : l.split("?")[0]) || "";
4702
4702
  return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((i) => n.toLowerCase().endsWith(i)) ? n : "";
4703
4703
  }, ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4704
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), u = useUpdateBlocksProps(), p = usePageExternalData(), d = r.split(".").pop() || "", g = i ? `_${d}Id-${i}` : `_${d}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
4704
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = usePageExternalData(), u = r.split(".").pop() || "", g = i ? `_${u}Id-${i}` : `_${u}Id`, m = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, g, m ? c == null ? void 0 : c.assetId : ""), f = useMemo(() => {
4705
4705
  if (!o || !c || !/\{\{.*?\}\}/.test(o)) return o;
4706
- const w = { ...c, [d]: o }, _ = applyBindingToBlockProps(w, p, { index: -1, key: "" });
4707
- return get(_, d, o);
4708
- }, [o, c, p, d]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (S) => {
4709
- const w = isArray(S) ? first(S) : S;
4710
- if (w) {
4711
- n(w == null ? void 0 : w.url);
4712
- const _ = w == null ? void 0 : w.width, B = w == null ? void 0 : w.height, I = g.includes("mobile");
4706
+ const v = { ...c, [u]: o }, _ = applyBindingToBlockProps(v, p, { index: -1, key: "" });
4707
+ return get(_, u, o);
4708
+ }, [o, c, p, u]), x = !!h || f !== PLACEHOLDER_IMAGE, b = (C) => {
4709
+ const v = isArray(C) ? first(C) : C;
4710
+ if (v) {
4711
+ n(v == null ? void 0 : v.url);
4712
+ const _ = v == null ? void 0 : v.width, B = v == null ? void 0 : v.height, I = g.includes("mobile");
4713
4713
  if (c != null && c._id) {
4714
4714
  const k = {
4715
4715
  ..._ && { [I ? "mobileWidth" : "width"]: _ },
4716
4716
  ...B && { [I ? "mobileHeight" : "height"]: B },
4717
- ...w.description && { alt: w.description }
4717
+ ...v.description && { alt: v.description }
4718
4718
  };
4719
- if (set(k, g, w.id), isEmpty(k)) return;
4720
- u([c._id], k);
4719
+ if (set(k, g, v.id), isEmpty(k)) return;
4720
+ d([c._id], k);
4721
4721
  }
4722
4722
  }
4723
4723
  }, y = useCallback(() => {
4724
4724
  if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
4725
- const S = {}, w = g.includes("mobile");
4726
- set(S, g, ""), set(S, w ? "mobileWidth" : "width", ""), set(S, w ? "mobileHeight" : "height", ""), u([c._id], S);
4725
+ const C = {}, v = g.includes("mobile");
4726
+ set(C, g, ""), set(C, v ? "mobileWidth" : "width", ""), set(C, v ? "mobileHeight" : "height", ""), d([c._id], C);
4727
4727
  }
4728
- }, [n, c == null ? void 0 : c._id, u, g]), C = getFileName(f);
4728
+ }, [n, c == null ? void 0 : c._id, d, g]), S = getFileName(f);
4729
4729
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
4730
4730
  f ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
4731
4731
  /* @__PURE__ */ jsx(
@@ -4756,7 +4756,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4756
4756
  ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, mode: "image", assetId: h, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
4757
4757
  /* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
4758
4758
  /* @__PURE__ */ jsxs(Fragment, { children: [
4759
- /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: C }),
4759
+ /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: S }),
4760
4760
  /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: b, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(f) && f !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) }),
4761
4761
  /* @__PURE__ */ jsx("div", { className: "text-center text-xs text-gray-400", children: "OR" })
4762
4762
  ] }),
@@ -4771,31 +4771,31 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4771
4771
  className: "h-6 text-xs",
4772
4772
  placeholder: l("Enter image URL"),
4773
4773
  value: o === PLACEHOLDER_IMAGE ? "" : o,
4774
- onBlur: ({ target: { value: S } }) => a(r, S),
4775
- onChange: (S) => n(S.target.value)
4774
+ onBlur: ({ target: { value: C } }) => a(r, C),
4775
+ onChange: (C) => n(C.target.value)
4776
4776
  }
4777
4777
  )
4778
4778
  ] })
4779
4779
  ] });
4780
4780
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
4781
- const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), u = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4781
+ const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4782
4782
  (m) => {
4783
4783
  const h = (f) => r === "value" ? f === "value" || f === "object" : r === "array" ? f === "array" : f === r;
4784
4784
  m.type === "object" ? (l((f) => [...f, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
4785
4785
  },
4786
4786
  [a, n, r]
4787
- ), d = React__default.useCallback(() => {
4787
+ ), u = React__default.useCallback(() => {
4788
4788
  if (a.length > 0) {
4789
4789
  const m = a.slice(0, -1);
4790
4790
  l(m), c(m.reduce((h, f) => h[f], o));
4791
4791
  }
4792
- }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: u(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4792
+ }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4793
4793
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4794
4794
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4795
4795
  /* @__PURE__ */ jsxs(CommandList, { children: [
4796
4796
  /* @__PURE__ */ jsx(CommandEmpty, { children: t("No option found.") }),
4797
4797
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4798
- a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: d, className: "flex items-center text-sm", children: [
4798
+ a.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: u, className: "flex items-center text-sm", children: [
4799
4799
  /* @__PURE__ */ jsx(ChevronLeftIcon, { className: "mr-2 h-4 w-4" }),
4800
4800
  t("Back")
4801
4801
  ] }),
@@ -4835,7 +4835,7 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4835
4835
  ] });
4836
4836
  };
4837
4837
  function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4838
- const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...i.map((p) => p.id).reduce((p, d) => ({ ...p, [COLLECTION_PREFIX + d]: [] }), {}), ...o } : o, [o, i, r]);
4838
+ const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => r === "array" ? { ...i.map((p) => p.id).reduce((p, u) => ({ ...p, [COLLECTION_PREFIX + u]: [] }), {}), ...o } : o, [o, i, r]);
4839
4839
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4840
4840
  /* @__PURE__ */ jsxs(Tooltip, { children: [
4841
4841
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -4864,8 +4864,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4864
4864
  PathDropdown,
4865
4865
  {
4866
4866
  data: c,
4867
- onSelect: (u, p) => {
4868
- n(u, p), l(!1);
4867
+ onSelect: (d, p) => {
4868
+ n(d, p), l(!1);
4869
4869
  },
4870
4870
  dataType: r
4871
4871
  }
@@ -4878,21 +4878,21 @@ const DataBindingSelector = ({
4878
4878
  id: r,
4879
4879
  formData: a
4880
4880
  }) => {
4881
- const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), u = useSelectedBlock(), p = useMemo(() => {
4881
+ const l = usePageExternalData(), i = useBuilderProp("flags.dataBinding", !0), c = useSelectedBlockHierarchy(), d = useSelectedBlock(), p = useMemo(() => {
4882
4882
  if (c.length === 1) return "";
4883
4883
  const m = c.find((x) => x._type === "Repeater"), f = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4884
4884
  return `${REPEATER_PREFIX}${startsWith(f, COLLECTION_PREFIX) ? `${f}/${m._id}` : f}`;
4885
- }, [c]), d = useMemo(() => first(get(l, p.replace(REPEATER_PREFIX, ""), [])), [p, l]), g = useCallback(
4885
+ }, [c]), u = useMemo(() => first(get(l, p.replace(REPEATER_PREFIX, ""), [])), [p, l]), g = useCallback(
4886
4886
  (m, h) => {
4887
4887
  if (m = isEmpty(p) ? m : m.replace(`${p}`, "$index"), h === "array" || h === "object") {
4888
4888
  n(`{{${m}}}`, {}, r);
4889
4889
  return;
4890
4890
  }
4891
- const f = (C) => /[.,!?;:]/.test(C), x = (C, S, w) => {
4891
+ const f = (S) => /[.,!?;:]/.test(S), x = (S, C, v) => {
4892
4892
  let _ = "", B = "";
4893
- const I = S > 0 ? C[S - 1] : "", k = S < C.length ? C[S] : "";
4894
- return S > 0 && (I === "." || !f(I) && I !== " ") && (_ = " "), S < C.length && !f(k) && k !== " " && (B = " "), {
4895
- text: _ + w + B,
4893
+ const I = C > 0 ? S[C - 1] : "", k = C < S.length ? S[C] : "";
4894
+ return C > 0 && (I === "." || !f(I) && I !== " ") && (_ = " "), C < S.length && !f(k) && k !== " " && (B = " "), {
4895
+ text: _ + v + B,
4896
4896
  prefixLength: _.length,
4897
4897
  suffixLength: B.length
4898
4898
  };
@@ -4900,41 +4900,41 @@ const DataBindingSelector = ({
4900
4900
  if (!b) return;
4901
4901
  const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4902
4902
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4903
- const C = y.__chaiRTE;
4904
- if (C) {
4905
- const S = `{{${m}}}`;
4906
- C.commands.focus();
4907
- const { from: w, to: _ } = C.state.selection;
4908
- if (w !== _)
4909
- C.chain().deleteSelection().insertContent(S).run();
4903
+ const S = y.__chaiRTE;
4904
+ if (S) {
4905
+ const C = `{{${m}}}`;
4906
+ S.commands.focus();
4907
+ const { from: v, to: _ } = S.state.selection;
4908
+ if (v !== _)
4909
+ S.chain().deleteSelection().insertContent(C).run();
4910
4910
  else {
4911
- const { state: I } = C, k = I.selection.from, A = I.doc.textBetween(Math.max(0, k - 1), k), v = I.doc.textBetween(k, Math.min(k + 1, I.doc.content.size));
4911
+ const { state: I } = S, k = I.selection.from, A = I.doc.textBetween(Math.max(0, k - 1), k), w = I.doc.textBetween(k, Math.min(k + 1, I.doc.content.size));
4912
4912
  let E = "";
4913
4913
  k > 0 && A !== " " && !f(A) && (E = " ");
4914
4914
  let j = "";
4915
- v && v !== " " && !f(v) && (j = " "), C.chain().insertContent(E + S + j).run();
4915
+ w && w !== " " && !f(w) && (j = " "), S.chain().insertContent(E + C + j).run();
4916
4916
  }
4917
- setTimeout(() => n(C.getHTML(), {}, r), 100);
4917
+ setTimeout(() => n(S.getHTML(), {}, r), 100);
4918
4918
  return;
4919
4919
  }
4920
4920
  } else {
4921
- const C = b, S = C.selectionStart || 0, w = C.value || "", _ = C.selectionEnd || S;
4922
- if (_ > S) {
4923
- const v = `{{${m}}}`, { text: E } = x(w, S, v), j = w.slice(0, S) + E + w.slice(_);
4921
+ const S = b, C = S.selectionStart || 0, v = S.value || "", _ = S.selectionEnd || C;
4922
+ if (_ > C) {
4923
+ const w = `{{${m}}}`, { text: E } = x(v, C, w), j = v.slice(0, C) + E + v.slice(_);
4924
4924
  n(j, {}, r);
4925
4925
  return;
4926
4926
  }
4927
- const I = `{{${m}}}`, { text: k } = x(w, S, I), A = w.slice(0, S) + k + w.slice(S);
4927
+ const I = `{{${m}}}`, { text: k } = x(v, C, I), A = v.slice(0, C) + k + v.slice(C);
4928
4928
  n(A, {}, r);
4929
4929
  }
4930
4930
  },
4931
- [r, n, a, u == null ? void 0 : u._id, p]
4931
+ [r, n, a, d == null ? void 0 : d._id, p]
4932
4932
  );
4933
4933
  return i ? /* @__PURE__ */ jsx(
4934
4934
  NestedPathSelector,
4935
4935
  {
4936
4936
  data: {
4937
- ...d && { [p]: d },
4937
+ ...u && { [p]: u },
4938
4938
  ...l
4939
4939
  },
4940
4940
  onSelect: g,
@@ -4947,104 +4947,104 @@ const DataBindingSelector = ({
4947
4947
  onChange: r
4948
4948
  }) => {
4949
4949
  var A;
4950
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, E) => []), [i, c] = useState(!1), [u, p] = useState(!1), [d, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), C = useRef(null), S = (A = n == null ? void 0 : n.find((v) => v.key === d)) == null ? void 0 : A.name;
4950
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (w, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [b, y] = useState(-1), S = useRef(null), C = (A = n == null ? void 0 : n.find((w) => w.key === u)) == null ? void 0 : A.name;
4951
4951
  useEffect(() => {
4952
4952
  if (h(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4953
- const v = split(o, ":"), E = get(v, 1, "page") || "page";
4953
+ const w = split(o, ":"), E = get(w, 1, "page") || "page";
4954
4954
  g(E), (async () => {
4955
- const j = await l(E, [get(v, 2, "page")]);
4955
+ const j = await l(E, [get(w, 2, "page")]);
4956
4956
  j && Array.isArray(j) && h(get(j, [0, "name"], ""));
4957
4957
  })();
4958
4958
  }, [o]);
4959
- const w = useDebouncedCallback(
4960
- async (v) => {
4961
- if (isEmpty(v))
4959
+ const v = useDebouncedCallback(
4960
+ async (w) => {
4961
+ if (isEmpty(w))
4962
4962
  x([]);
4963
4963
  else {
4964
- const E = await l(d, v);
4964
+ const E = await l(u, w);
4965
4965
  x(E);
4966
4966
  }
4967
4967
  c(!1), y(-1);
4968
4968
  },
4969
- [d],
4969
+ [u],
4970
4970
  300
4971
- ), _ = (v) => {
4972
- const E = ["pageType", d, v.id];
4973
- E[1] && (r(E.join(":")), h(v.name), p(!1), x([]), y(-1));
4974
- }, B = (v) => {
4975
- switch (v.key) {
4971
+ ), _ = (w) => {
4972
+ const E = ["pageType", u, w.id];
4973
+ E[1] && (r(E.join(":")), h(w.name), p(!1), x([]), y(-1));
4974
+ }, B = (w) => {
4975
+ switch (w.key) {
4976
4976
  case "ArrowDown":
4977
- v.preventDefault(), y((E) => E < f.length - 1 ? E + 1 : E);
4977
+ w.preventDefault(), y((E) => E < f.length - 1 ? E + 1 : E);
4978
4978
  break;
4979
4979
  case "ArrowUp":
4980
- v.preventDefault(), y((E) => E > 0 ? E - 1 : E);
4980
+ w.preventDefault(), y((E) => E > 0 ? E - 1 : E);
4981
4981
  break;
4982
4982
  case "Enter":
4983
- if (v.preventDefault(), f.length === 0) return;
4983
+ if (w.preventDefault(), f.length === 0) return;
4984
4984
  b >= 0 && _(f[b]);
4985
4985
  break;
4986
4986
  case "Escape":
4987
- v.preventDefault(), I();
4987
+ w.preventDefault(), I();
4988
4988
  break;
4989
4989
  }
4990
4990
  };
4991
4991
  useEffect(() => {
4992
- if (b >= 0 && C.current) {
4993
- const v = C.current.children[b];
4994
- v == null || v.scrollIntoView({ block: "nearest" });
4992
+ if (b >= 0 && S.current) {
4993
+ const w = S.current.children[b];
4994
+ w == null || w.scrollIntoView({ block: "nearest" });
4995
4995
  }
4996
4996
  }, [b]);
4997
4997
  const I = () => {
4998
4998
  h(""), x([]), y(-1), p(!1), r("");
4999
- }, k = (v) => {
5000
- h(v), p(!isEmpty(v)), c(!0), w(v);
4999
+ }, k = (w) => {
5000
+ h(w), p(!isEmpty(w)), c(!0), v(w);
5001
5001
  };
5002
5002
  return /* @__PURE__ */ jsxs("div", { children: [
5003
- /* @__PURE__ */ jsx("select", { name: "pageType", value: d, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
5004
- d && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
5003
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (w) => g(w.target.value), children: map(n, (w) => /* @__PURE__ */ jsx("option", { value: w.key, children: w.name }, w.key)) }),
5004
+ u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
5005
5005
  /* @__PURE__ */ jsx(
5006
5006
  "input",
5007
5007
  {
5008
5008
  type: "text",
5009
5009
  value: m,
5010
- onChange: (v) => k(v.target.value),
5010
+ onChange: (w) => k(w.target.value),
5011
5011
  onKeyDown: B,
5012
- placeholder: a(`Search ${S ?? ""}`),
5012
+ placeholder: a(`Search ${C ?? ""}`),
5013
5013
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
5014
5014
  }
5015
5015
  ),
5016
5016
  /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: I, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-4 w-4" }) }) })
5017
5017
  ] }),
5018
- (i || !isEmpty(f) || u && 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: [
5018
+ (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: [
5019
5019
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
5020
5020
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
5021
- ] }) : u && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5021
+ ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5022
5022
  a("No results found for"),
5023
5023
  ' "',
5024
5024
  m,
5025
5025
  '"'
5026
- ] }) : /* @__PURE__ */ jsx("ul", { ref: C, children: map(f == null ? void 0 : f.slice(0, 20), (v, E) => /* @__PURE__ */ jsxs(
5026
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (w, E) => /* @__PURE__ */ jsxs(
5027
5027
  "li",
5028
5028
  {
5029
- onClick: () => _(v),
5030
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : E === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
5029
+ onClick: () => _(w),
5030
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(w.id) ? "bg-blue-200" : E === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
5031
5031
  children: [
5032
- v.name,
5032
+ w.name,
5033
5033
  " ",
5034
- v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
5034
+ w.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
5035
5035
  "( ",
5036
- v.slug,
5036
+ w.slug,
5037
5037
  " )"
5038
5038
  ] })
5039
5039
  ]
5040
5040
  },
5041
- v.id
5041
+ w.id
5042
5042
  )) }) })
5043
5043
  ] });
5044
5044
  }, LinkField = ({ schema: o, formData: n, onChange: r, name: a }) => {
5045
- const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: u = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: d, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
5046
- () => isEmpty(m) ? "" : isEmpty(d) ? g : d,
5047
- [m, d, g]
5045
+ const { t: l } = useTranslation(), { type: i = "pageType", href: c = "", target: d = "self" } = n ?? {}, p = useBuilderProp("pageTypes", []), { selectedLang: u, fallbackLang: g, languages: m } = useLanguages(), h = useMemo(
5046
+ () => isEmpty(m) ? "" : isEmpty(u) ? g : u,
5047
+ [m, u, g]
5048
5048
  ), f = useMemo(() => get(LANGUAGES, h, h), [h]), x = i === "pageType" && isEmpty(p) ? "url" : i;
5049
5049
  return /* @__PURE__ */ jsxs("div", { children: [
5050
5050
  /* @__PURE__ */ jsxs("span", { className: "flex items-center justify-between gap-x-2 text-xs font-medium", children: [
@@ -5107,9 +5107,9 @@ const DataBindingSelector = ({
5107
5107
  autoCorrect: "off",
5108
5108
  spellCheck: "false",
5109
5109
  type: "checkbox",
5110
- defaultChecked: u === "_blank",
5110
+ defaultChecked: d === "_blank",
5111
5111
  className: "!w-fit cursor-pointer rounded-md border border-border",
5112
- onChange: () => r({ ...n, target: u === "_blank" ? "_self" : "_blank" })
5112
+ onChange: () => r({ ...n, target: d === "_blank" ? "_self" : "_blank" })
5113
5113
  }
5114
5114
  ),
5115
5115
  /* @__PURE__ */ jsx("span", { className: "pt-1 text-xs", children: l("Open in new tab") })
@@ -5132,8 +5132,8 @@ const DataBindingSelector = ({
5132
5132
  ]
5133
5133
  }
5134
5134
  ) });
5135
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-DpWQvFjm.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
5136
- const c = useRef(null), [u, p] = useState(!1), d = useRTEditor({
5135
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-BiZPyPF3.js")), RichTextEditorFieldComp = ({ blockId: o, id: n, placeholder: r, value: a, onChange: l, onBlur: i }) => {
5136
+ const c = useRef(null), [d, p] = useState(!1), u = useRTEditor({
5137
5137
  blockId: o,
5138
5138
  value: a,
5139
5139
  placeholder: r,
@@ -5147,26 +5147,26 @@ const DataBindingSelector = ({
5147
5147
  }
5148
5148
  });
5149
5149
  useEffect(() => {
5150
- c.current && d && (c.current.__chaiRTE = d);
5151
- }, [o, d]);
5150
+ c.current && u && (c.current.__chaiRTE = u);
5151
+ }, [o, u]);
5152
5152
  const g = () => {
5153
5153
  p(!1);
5154
5154
  }, m = /* @__PURE__ */ jsxs("div", { id: `chai-rte-${n}`, ref: c, className: "mt-1 rounded-md border border-input", children: [
5155
- /* @__PURE__ */ jsx(RteMenubar, { editor: d, onExpand: () => p(!0) }),
5155
+ /* @__PURE__ */ jsx(RteMenubar, { editor: u, onExpand: () => p(!0) }),
5156
5156
  /* @__PURE__ */ jsx(
5157
5157
  EditorContent,
5158
5158
  {
5159
- editor: d,
5159
+ editor: u,
5160
5160
  id: n,
5161
5161
  placeholder: r,
5162
- className: `overflow-auto ${u ? "max-h-[500px] min-h-[400px]" : "max-h-[200px] min-h-[100px]"}`
5162
+ className: `overflow-auto ${d ? "max-h-[500px] min-h-[400px]" : "max-h-[200px] min-h-[100px]"}`
5163
5163
  },
5164
5164
  n
5165
5165
  )
5166
5166
  ] });
5167
5167
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5168
- u && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: u, onClose: g, editor: d, rteElement: m }) }),
5169
- u ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
5168
+ d && /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: /* @__PURE__ */ jsx(RTEModal, { isOpen: d, onClose: g, editor: u, rteElement: m }) }),
5169
+ d ? /* @__PURE__ */ jsx("div", { children: "Open in modal" }) : /* @__PURE__ */ jsx("div", { className: "relative", children: m })
5170
5170
  ] });
5171
5171
  }, RichTextEditorField = (o) => {
5172
5172
  const { editingBlockId: n } = useInlineEditing(), [r, a] = useState(null), l = useSelectedBlock(), i = l == null ? void 0 : l._id;
@@ -5176,25 +5176,25 @@ const DataBindingSelector = ({
5176
5176
  }, SliderField = ({ formData: o, onChange: n }) => {
5177
5177
  const [r] = useBlocksStore(), a = useSelectedBlock(), l = useWrapperBlock(), { addCoreBlock: i } = useAddBlock(), [, c] = useSelectedBlockIds();
5178
5178
  if (!a && !l) return null;
5179
- const u = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: u == null ? void 0 : u._id, _type: "Slides" });
5179
+ const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(r, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
5180
5180
  if (!p) return null;
5181
- const d = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(d, "0._id");
5181
+ const u = filter(r, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
5182
5182
  useEffect(() => {
5183
5183
  (a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && n({ ...o, currentSlide: a == null ? void 0 : a._id });
5184
5184
  }, [a]), useEffect(() => {
5185
- d != null && d.length && !find(d, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(d, "0._id") });
5186
- }, [o, d]);
5185
+ u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
5186
+ }, [o, u]);
5187
5187
  const m = () => {
5188
- const x = findIndex(d, { _id: g });
5188
+ const x = findIndex(u, { _id: g });
5189
5189
  if (x > -1) {
5190
- const b = (x + 1) % d.length, y = get(d, [b, "_id"]);
5190
+ const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
5191
5191
  if (!y) return;
5192
5192
  n({ ...o, currentSlide: y }), c([y]);
5193
5193
  }
5194
5194
  }, h = () => {
5195
- const x = findIndex(d, { _id: g });
5195
+ const x = findIndex(u, { _id: g });
5196
5196
  if (x > -1) {
5197
- const b = (x - 1 + d.length) % d.length, y = get(d, [b, "_id"]);
5197
+ const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
5198
5198
  if (!y) return;
5199
5199
  n({ ...o, currentSlide: y }), c([y]);
5200
5200
  }
@@ -5211,10 +5211,10 @@ const DataBindingSelector = ({
5211
5211
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
5212
5212
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
5213
5213
  " ",
5214
- findIndex(d, { _id: g }) + 1
5214
+ findIndex(u, { _id: g }) + 1
5215
5215
  ] }),
5216
5216
  "/",
5217
- d.length
5217
+ u.length
5218
5218
  ] }) : "-" }),
5219
5219
  /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) }),
5220
5220
  /* @__PURE__ */ jsxs(
@@ -5291,15 +5291,15 @@ const DataBindingSelector = ({
5291
5291
  ] }) })
5292
5292
  ] });
5293
5293
  }, SourcesField = ({ formData: o, onChange: n }) => {
5294
- const r = get(o, "srcsets", []) || [], a = (c, u) => {
5295
- const p = c.target.name, d = c.target.value;
5294
+ const r = get(o, "srcsets", []) || [], a = (c, d) => {
5295
+ const p = c.target.name, u = c.target.value;
5296
5296
  n({
5297
- srcsets: map(r, (g, m) => m === u ? { ...g, [p]: d } : g)
5297
+ srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
5298
5298
  });
5299
5299
  }, l = () => {
5300
5300
  n({ srcsets: [...r, {}] });
5301
5301
  }, i = (c) => {
5302
- n({ srcsets: reject(r, (u, p) => p === c) });
5302
+ n({ srcsets: reject(r, (d, p) => p === c) });
5303
5303
  };
5304
5304
  return /* @__PURE__ */ jsxs("div", { children: [
5305
5305
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between pb-2", children: [
@@ -5314,12 +5314,12 @@ const DataBindingSelector = ({
5314
5314
  }
5315
5315
  )
5316
5316
  ] }),
5317
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: r.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500", children: "Add additional sources to create responsive videos" }) : map(r, (c, u) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
5317
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: r.length === 0 ? /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-gray-200 p-2 text-xs italic text-gray-500", children: "Add additional sources to create responsive videos" }) : map(r, (c, d) => /* @__PURE__ */ jsxs("div", { className: "group relative space-y-1.5 rounded border border-gray-200 px-2 pb-1.5", children: [
5318
5318
  /* @__PURE__ */ jsx(
5319
5319
  "button",
5320
5320
  {
5321
5321
  type: "button",
5322
- onClick: () => i(u),
5322
+ onClick: () => i(d),
5323
5323
  className: "absolute -right-px -top-0 -translate-y-1/2 rounded-full bg-red-100 p-1 opacity-0 hover:bg-red-200 group-hover:opacity-100",
5324
5324
  children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-2.5 w-2.5 text-red-500" })
5325
5325
  }
@@ -5333,7 +5333,7 @@ const DataBindingSelector = ({
5333
5333
  placeholder: "Enter width (in px)",
5334
5334
  type: "number",
5335
5335
  value: get(c, "width"),
5336
- onChange: (p) => a(p, u),
5336
+ onChange: (p) => a(p, d),
5337
5337
  className: "!placeholder:text-gray-100 !mt-0 !rounded-none !border-0 !p-0 !text-xs"
5338
5338
  }
5339
5339
  )
@@ -5347,16 +5347,16 @@ const DataBindingSelector = ({
5347
5347
  placeholder: "Enter url",
5348
5348
  className: "!mt-0 !rounded-none !border-0 !p-0 !text-xs !shadow-none",
5349
5349
  value: get(c, "url", ""),
5350
- onChange: (p) => a(p, u)
5350
+ onChange: (p) => a(p, d)
5351
5351
  }
5352
5352
  )
5353
5353
  ] })
5354
- ] }, u)) })
5354
+ ] }, d)) })
5355
5355
  ] });
5356
5356
  }, CodeEditor = ({ id: o, placeholder: n }) => {
5357
5357
  const { t: r } = useTranslation(), [, a] = useCodeEditor(), l = useSelectedBlock();
5358
5358
  if (typeof window > "u") return null;
5359
- const i = o.replace("root.", ""), c = get(l, i, ""), u = () => {
5359
+ const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
5360
5360
  const p = l == null ? void 0 : l._id;
5361
5361
  a({ blockId: p, blockProp: i, placeholder: n, initialCode: get(l, i, c) });
5362
5362
  };
@@ -5364,35 +5364,35 @@ const DataBindingSelector = ({
5364
5364
  /* @__PURE__ */ jsx(
5365
5365
  "button",
5366
5366
  {
5367
- onClick: u,
5367
+ onClick: d,
5368
5368
  className: "w-[90%] max-w-full cursor-default truncate text-pretty rounded border border-border bg-background p-2 text-left text-[10px]",
5369
5369
  children: c.trim().length > 0 ? c.substring(0, 46) : n || "Eg: <script>console.log('Hello, world!');<\/script>"
5370
5370
  }
5371
5371
  ),
5372
- /* @__PURE__ */ jsx(Button, { onClick: u, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
5372
+ /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
5373
5373
  ] });
5374
5374
  }, CollectionFilterSortField = ({ id: o, value: n, onChange: r, onBlur: a }) => {
5375
- const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), u = find(l, { id: c }), d = get(u, o === "root.filter" ? "filters" : "sorts", []);
5375
+ const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
5376
5376
  return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: n, onChange: (g) => r(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
5377
5377
  /* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
5378
- d.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
5378
+ u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
5379
5379
  ] }) });
5380
5380
  }, JSONFormFieldTemplate = (o) => {
5381
- const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: u, required: p, schema: d, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
5381
+ const { id: n, classNames: r, label: a, children: l, errors: i, help: c, hidden: d, required: p, schema: u, formData: g, onChange: m } = o, { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), b = useMemo(
5382
5382
  () => isEmpty(x) ? "" : isEmpty(h) ? f : h,
5383
5383
  [x, h, f]
5384
- ), y = useMemo(() => get(LANGUAGES, b, b), [b]), C = usePageExternalData(), S = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
5385
- () => get(w, [S == null ? void 0 : S._type, "i18nProps"], []),
5386
- [w, S == null ? void 0 : S._type]
5384
+ ), y = useMemo(() => get(LANGUAGES, b, b), [b]), S = usePageExternalData(), C = useSelectedBlock(), v = useRegisteredChaiBlocks(), _ = useMemo(
5385
+ () => get(v, [C == null ? void 0 : C._type, "i18nProps"], []),
5386
+ [v, C == null ? void 0 : C._type]
5387
5387
  ), [B, I] = useState(null);
5388
- if (u)
5388
+ if (d)
5389
5389
  return null;
5390
- if (d.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
5390
+ if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: l });
5391
5391
  const A = _ == null ? void 0 : _.includes(n.replace("root.", ""));
5392
- if (d.type === "array") {
5392
+ if (u.type === "array") {
5393
5393
  const j = B === n;
5394
5394
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
5395
- d.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
5395
+ u.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
5396
5396
  "label",
5397
5397
  {
5398
5398
  htmlFor: n,
@@ -5404,7 +5404,7 @@ const DataBindingSelector = ({
5404
5404
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: a }),
5405
5405
  " ",
5406
5406
  /* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: g == null ? void 0 : g.length }) }),
5407
- d.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5407
+ u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5408
5408
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5409
5409
  InfoCircledIcon,
5410
5410
  {
@@ -5413,7 +5413,7 @@ const DataBindingSelector = ({
5413
5413
  onMouseDown: (N) => N.stopPropagation()
5414
5414
  }
5415
5415
  ) }),
5416
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: d.description })
5416
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
5417
5417
  ] }) })
5418
5418
  ]
5419
5419
  }
@@ -5425,25 +5425,25 @@ const DataBindingSelector = ({
5425
5425
  ] })
5426
5426
  ] });
5427
5427
  }
5428
- const v = n.replace("root.", ""), E = _.includes(v) && !isEmpty(h) && isEmpty(g);
5428
+ const w = n.replace("root.", ""), E = _.includes(w) && !isEmpty(h) && isEmpty(g);
5429
5429
  return /* @__PURE__ */ jsxs("div", { className: r, children: [
5430
- d.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
5430
+ u.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
5431
5431
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
5432
- /* @__PURE__ */ jsxs("label", { htmlFor: n, className: d.type === "object" ? "pb-2" : "", children: [
5432
+ /* @__PURE__ */ jsxs("label", { htmlFor: n, className: u.type === "object" ? "pb-2" : "", children: [
5433
5433
  a,
5434
5434
  " ",
5435
5435
  A && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5436
5436
  " ",
5437
5437
  y
5438
5438
  ] }),
5439
- p && d.type !== "object" ? " *" : null
5439
+ p && u.type !== "object" ? " *" : null
5440
5440
  ] }),
5441
- d.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5441
+ u.description && /* @__PURE__ */ jsx(TooltipProvider, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5442
5442
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(InfoCircledIcon, { className: "h-3 w-3 text-muted-foreground/70" }) }),
5443
- /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: d.description })
5443
+ /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: u.description })
5444
5444
  ] }) })
5445
5445
  ] }),
5446
- !d.enum && !d.oneOf && C && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
5446
+ !u.enum && !u.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
5447
5447
  E ? /* @__PURE__ */ jsxs(Tooltip, { children: [
5448
5448
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5449
5449
  "svg",
@@ -5474,7 +5474,7 @@ const DataBindingSelector = ({
5474
5474
  /* @__PURE__ */ jsx(
5475
5475
  DataBindingSelector,
5476
5476
  {
5477
- schema: d,
5477
+ schema: u,
5478
5478
  onChange: (j) => {
5479
5479
  m(j, g, n);
5480
5480
  },
@@ -5525,7 +5525,7 @@ const DataBindingSelector = ({
5525
5525
  " ",
5526
5526
  /* @__PURE__ */ jsx("span", { children: "Add" })
5527
5527
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5528
- const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), u = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), d = useThrottledCallback(
5528
+ const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
5529
5529
  async ({ formData: g }, m) => {
5530
5530
  get(g, m) === void 0 && set(g, m, ""), l({ formData: g }, m);
5531
5531
  },
@@ -5550,7 +5550,7 @@ const DataBindingSelector = ({
5550
5550
  link: LinkField,
5551
5551
  slider: SliderField,
5552
5552
  sources: SourcesField,
5553
- ...u
5553
+ ...d
5554
5554
  },
5555
5555
  templates: {
5556
5556
  FieldTemplate: JSONFormFieldTemplate,
@@ -5571,7 +5571,7 @@ const DataBindingSelector = ({
5571
5571
  onChange: ({ formData: g }, m) => {
5572
5572
  if (!m || o !== (g == null ? void 0 : g._id)) return;
5573
5573
  const h = take(m.split("."), 2).join(".").replace("root.", "");
5574
- d({ formData: g }, h);
5574
+ u({ formData: g }, h);
5575
5575
  }
5576
5576
  },
5577
5577
  i
@@ -5583,18 +5583,18 @@ const DataBindingSelector = ({
5583
5583
  }), a;
5584
5584
  };
5585
5585
  function BlockSettings() {
5586
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, u] = useState(i), [p, d] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: B }, I, k) => {
5586
+ 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: B }, I, k) => {
5587
5587
  I && (c == null ? void 0 : c._id) === n._id && a([n._id], { [I]: get(B, I) }, k);
5588
5588
  }, x = useCallback(
5589
5589
  debounce(({ formData: B }, I, k) => {
5590
- f({ formData: B }, I, k), u(B);
5590
+ f({ formData: B }, I, k), d(B);
5591
5591
  }, 1500),
5592
5592
  [n == null ? void 0 : n._id, o]
5593
5593
  ), b = ({ formData: B }, I) => {
5594
5594
  I && (r([n._id], { [I]: get(B, I) }), x({ formData: B }, I, { [I]: get(c, I) }));
5595
5595
  }, y = ({ formData: B }, I) => {
5596
5596
  I && (r([g._id], { [I]: get(B, I) }), x({ formData: B }, I, { [I]: get(c, I) }));
5597
- }, { schema: C, uiSchema: S } = useMemo(() => {
5597
+ }, { schema: S, uiSchema: C } = useMemo(() => {
5598
5598
  const B = n == null ? void 0 : n._type;
5599
5599
  if (!B)
5600
5600
  return { schema: {}, uiSchema: {} };
@@ -5608,7 +5608,7 @@ function BlockSettings() {
5608
5608
  } catch {
5609
5609
  return { schema: {}, uiSchema: {} };
5610
5610
  }
5611
- }, [n]), { wrapperSchema: w, wrapperUiSchema: _ } = useMemo(() => {
5611
+ }, [n]), { wrapperSchema: v, wrapperUiSchema: _ } = useMemo(() => {
5612
5612
  if (!g || !(g != null && g._type))
5613
5613
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5614
5614
  const B = g == null ? void 0 : g._type, { schema: I = {}, uiSchema: k = {} } = getBlockFormSchemas(B);
@@ -5619,7 +5619,7 @@ function BlockSettings() {
5619
5619
  /* @__PURE__ */ jsxs(
5620
5620
  "div",
5621
5621
  {
5622
- onClick: () => d((B) => !B),
5622
+ onClick: () => u((B) => !B),
5623
5623
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5624
5624
  children: [
5625
5625
  p ? /* @__PURE__ */ jsx(ChevronDownIcon, { className: "h-4 w-4 text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-4 w-4 text-slate-400" }),
@@ -5640,19 +5640,19 @@ function BlockSettings() {
5640
5640
  blockId: g == null ? void 0 : g._id,
5641
5641
  onChange: y,
5642
5642
  formData: h,
5643
- schema: w,
5643
+ schema: v,
5644
5644
  uiSchema: _
5645
5645
  }
5646
5646
  ) })
5647
5647
  ] }),
5648
- isEmpty(C) ? null : /* @__PURE__ */ jsx(
5648
+ isEmpty(S) ? null : /* @__PURE__ */ jsx(
5649
5649
  JSONForm,
5650
5650
  {
5651
5651
  blockId: n == null ? void 0 : n._id,
5652
5652
  onChange: b,
5653
5653
  formData: i,
5654
- schema: C,
5655
- uiSchema: S
5654
+ schema: S,
5655
+ uiSchema: C
5656
5656
  }
5657
5657
  )
5658
5658
  ] });
@@ -5663,7 +5663,7 @@ const BlockStylingProps = () => {
5663
5663
  if (!o) return null;
5664
5664
  const c = Object.keys(o).filter(
5665
5665
  (x) => typeof o[x] == "string" && o[x].startsWith("#styles:")
5666
- ), { reset: u } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, d = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(d) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
5666
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (f = n[0]) == null ? void 0 : f.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, m = g ? g.split(" ").filter((x) => !isEmpty(x)) : [], h = (x) => find(n, (b) => b.prop === x);
5667
5667
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5668
5668
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5669
5669
  i("Style element"),
@@ -5695,7 +5695,7 @@ const BlockStylingProps = () => {
5695
5695
  {
5696
5696
  className: "text-xs",
5697
5697
  onClick: () => {
5698
- u(x);
5698
+ d(x);
5699
5699
  },
5700
5700
  children: i("Reset style")
5701
5701
  }
@@ -5827,13 +5827,13 @@ const BlockStylingProps = () => {
5827
5827
  negative: i,
5828
5828
  cssProperty: c
5829
5829
  }) => {
5830
- const { setDragData: u } = useContext(BlockSettingsContext);
5830
+ const { setDragData: d } = useContext(BlockSettingsContext);
5831
5831
  return /* @__PURE__ */ jsx(
5832
5832
  "button",
5833
5833
  {
5834
5834
  type: "button",
5835
5835
  onMouseDown: (p) => {
5836
- const d = {
5836
+ const u = {
5837
5837
  onDrag: r,
5838
5838
  onDragEnd: a,
5839
5839
  dragging: !0,
@@ -5843,7 +5843,7 @@ const BlockStylingProps = () => {
5843
5843
  negative: i,
5844
5844
  cssProperty: c
5845
5845
  };
5846
- l(d), u(d);
5846
+ l(u), d(u);
5847
5847
  },
5848
5848
  color: void 0,
5849
5849
  className: "relative z-50 ml-1 hidden h-6 cursor-row-resize rounded bg-background/70 px-2 group-hover:inline",
@@ -5863,50 +5863,50 @@ const BlockStylingProps = () => {
5863
5863
  },
5864
5864
  a
5865
5865
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5866
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: u, cssProperty: p, units: d, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : d[0]), [f, x] = useState(!1), [b, y] = useState(""), [C, S] = useState(!1), [w, _] = useState(!1);
5866
+ 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(""), [S, C] = useState(!1), [v, _] = useState(!1);
5867
5867
  useEffect(() => {
5868
- const { value: v, unit: E } = getClassValueAndUnit(i);
5868
+ const { value: w, unit: E } = getClassValueAndUnit(i);
5869
5869
  if (E === "") {
5870
- l(v), h(p != null && p.toLowerCase().includes("width") ? "%" : first(d));
5870
+ l(w), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5871
5871
  return;
5872
5872
  }
5873
- h(E), l(E === "class" || isEmpty(v) ? "" : v);
5874
- }, [i, p, d]);
5875
- const B = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), I = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), k = useCallback(
5876
- (v = !1) => {
5877
- const E = getUserInputValues(`${a}`, d);
5873
+ h(E), l(E === "class" || isEmpty(w) ? "" : w);
5874
+ }, [i, p, u]);
5875
+ const B = useThrottledCallback((w) => c(w), [c], THROTTLE_TIME), I = useThrottledCallback((w) => c(w, !1), [c], THROTTLE_TIME), k = useCallback(
5876
+ (w = !1) => {
5877
+ const E = getUserInputValues(`${a}`, u);
5878
5878
  if (get(E, "error", !1)) {
5879
5879
  x(!0);
5880
5880
  return;
5881
5881
  }
5882
5882
  const j = get(E, "unit") !== "" ? get(E, "unit") : m;
5883
5883
  if (j === "auto" || j === "none") {
5884
- B(`${u}${j}`);
5884
+ B(`${d}${j}`);
5885
5885
  return;
5886
5886
  }
5887
5887
  if (get(E, "value") === "")
5888
5888
  return;
5889
- const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${u}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5890
- v ? I(T) : B(T);
5889
+ const T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5890
+ w ? I(T) : B(T);
5891
5891
  },
5892
- [B, I, a, m, u, d]
5892
+ [B, I, a, m, d, u]
5893
5893
  ), A = useCallback(
5894
- (v) => {
5895
- const E = getUserInputValues(`${a}`, d);
5894
+ (w) => {
5895
+ const E = getUserInputValues(`${a}`, u);
5896
5896
  if (get(E, "error", !1)) {
5897
5897
  x(!0);
5898
5898
  return;
5899
5899
  }
5900
- if (v === "auto" || v === "none") {
5901
- B(`${u}${v}`);
5900
+ if (w === "auto" || w === "none") {
5901
+ B(`${d}${w}`);
5902
5902
  return;
5903
5903
  }
5904
5904
  if (get(E, "value") === "")
5905
5905
  return;
5906
- const j = get(E, "unit") !== "" ? get(E, "unit") : v, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${u}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5906
+ const j = get(E, "unit") !== "" ? get(E, "unit") : w, T = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5907
5907
  B(T);
5908
5908
  },
5909
- [B, a, u, d]
5909
+ [B, a, d, u]
5910
5910
  );
5911
5911
  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: [
5912
5912
  /* @__PURE__ */ jsx(
@@ -5921,37 +5921,37 @@ const BlockStylingProps = () => {
5921
5921
  /* @__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, {}) }) }),
5922
5922
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
5923
5923
  ] })
5924
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${C ? "z-auto" : ""}`, children: [
5924
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
5925
5925
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5926
5926
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
5927
5927
  "input",
5928
5928
  {
5929
5929
  readOnly: m === "class",
5930
- onKeyPress: (v) => {
5931
- v.key === "Enter" && k();
5930
+ onKeyPress: (w) => {
5931
+ w.key === "Enter" && k();
5932
5932
  },
5933
- onKeyDown: (v) => {
5934
- if (v.keyCode !== 38 && v.keyCode !== 40)
5933
+ onKeyDown: (w) => {
5934
+ if (w.keyCode !== 38 && w.keyCode !== 40)
5935
5935
  return;
5936
- v.preventDefault(), _(!0);
5937
- const E = parseInt$1(v.target.value);
5936
+ w.preventDefault(), _(!0);
5937
+ const E = parseInt$1(w.target.value);
5938
5938
  let j = isNaN$1(E) ? 0 : E;
5939
- v.keyCode === 38 && (j += 1), v.keyCode === 40 && (j -= 1);
5940
- const N = `${j}`, P = `${N.startsWith("-") ? "-" : ""}${u}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
5939
+ w.keyCode === 38 && (j += 1), w.keyCode === 40 && (j -= 1);
5940
+ const N = `${j}`, P = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${m === "-" ? "" : m}]`;
5941
5941
  I(P);
5942
5942
  },
5943
- onKeyUp: (v) => {
5944
- w && (v.preventDefault(), _(!1));
5943
+ onKeyUp: (w) => {
5944
+ v && (w.preventDefault(), _(!1));
5945
5945
  },
5946
5946
  onBlur: () => k(),
5947
- onChange: (v) => {
5948
- x(!1), l(v.target.value);
5947
+ onChange: (w) => {
5948
+ x(!1), l(w.target.value);
5949
5949
  },
5950
- onClick: (v) => {
5950
+ onClick: (w) => {
5951
5951
  var E;
5952
- (E = v == null ? void 0 : v.target) == null || E.select(), r(!1);
5952
+ (E = w == null ? void 0 : w.target) == null || E.select(), r(!1);
5953
5953
  },
5954
- value: C ? b : a,
5954
+ value: S ? b : a,
5955
5955
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5956
5956
  " ",
5957
5957
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5966,38 +5966,38 @@ const BlockStylingProps = () => {
5966
5966
  onClick: () => r(!n),
5967
5967
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
5968
5968
  children: [
5969
- /* @__PURE__ */ jsx("span", { className: `inline-block ${d.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
5970
- d.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5969
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
5970
+ u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5971
5971
  ]
5972
5972
  }
5973
5973
  ) }),
5974
5974
  /* @__PURE__ */ jsx(TooltipContent, { className: "bg-background", children: /* @__PURE__ */ jsx(
5975
5975
  UnitSelection,
5976
5976
  {
5977
- units: d,
5977
+ units: u,
5978
5978
  current: m,
5979
- onSelect: (v) => {
5980
- r(!1), h(v), A(v);
5979
+ onSelect: (w) => {
5980
+ r(!1), h(w), A(w);
5981
5981
  }
5982
5982
  }
5983
5983
  ) })
5984
5984
  ] })
5985
5985
  ] }),
5986
- ["none", "auto"].indexOf(m) !== -1 || C ? null : /* @__PURE__ */ jsx(
5986
+ ["none", "auto"].indexOf(m) !== -1 || S ? null : /* @__PURE__ */ jsx(
5987
5987
  DragStyleButton,
5988
5988
  {
5989
- onDragStart: () => S(!0),
5990
- onDragEnd: (v) => {
5991
- if (y(() => ""), S(!1), isEmpty(v))
5989
+ onDragStart: () => C(!0),
5990
+ onDragEnd: (w) => {
5991
+ if (y(() => ""), C(!1), isEmpty(w))
5992
5992
  return;
5993
- const E = `${v}`, N = `${E.startsWith("-") ? "-" : ""}${u}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
5993
+ const E = `${w}`, N = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
5994
5994
  B(N);
5995
5995
  },
5996
- onDrag: (v) => {
5997
- if (isEmpty(v))
5996
+ onDrag: (w) => {
5997
+ if (isEmpty(w))
5998
5998
  return;
5999
- y(v);
6000
- const E = `${v}`, N = `${E.startsWith("-") ? "-" : ""}${u}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
5999
+ y(w);
6000
+ const E = `${w}`, N = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${m === "-" ? "" : m}]`;
6001
6001
  I(N);
6002
6002
  },
6003
6003
  currentValue: a,
@@ -6011,7 +6011,7 @@ const BlockStylingProps = () => {
6011
6011
  // eslint-disable-next-line react/jsx-no-constructed-context-values
6012
6012
  /* @__PURE__ */ jsx(StyleContext.Provider, { value: { canReset: n, canChange: r }, children: o })
6013
6013
  ), DropDownChoices = ({ label: o, property: n, onChange: r }) => {
6014
- const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: u } = useContext(StyleContext), p = /\[.*\]/g.test(c);
6014
+ const { getClasses: a } = useTailwindClassList(), l = a(n), i = useCurrentClassByProperty(n), c = useMemo(() => get(i, "cls", ""), [i]), { canChange: d } = useContext(StyleContext), p = /\[.*\]/g.test(c);
6015
6015
  return /* @__PURE__ */ jsx("div", { className: o ? "w-full rounded" : "grow", children: p ? /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
6016
6016
  /* @__PURE__ */ jsx(Input$1, { className: "w-[70%] rounded py-1", readOnly: !0, value: c }),
6017
6017
  /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
@@ -6022,15 +6022,15 @@ const BlockStylingProps = () => {
6022
6022
  DropDown,
6023
6023
  {
6024
6024
  rounded: o,
6025
- onChange: (d) => r(d, n),
6025
+ onChange: (u) => r(u, n),
6026
6026
  selected: c,
6027
6027
  options: l,
6028
- disabled: !u
6028
+ disabled: !d
6029
6029
  }
6030
6030
  ) });
6031
6031
  };
6032
6032
  function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disabled: l = !1 }) {
6033
- const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: u } = useUndoManager();
6033
+ const i = o.replace(/.*:/g, "").trim(), { undo: c, redo: d } = useUndoManager();
6034
6034
  return /* @__PURE__ */ jsxs(
6035
6035
  "select",
6036
6036
  {
@@ -6038,12 +6038,12 @@ function DropDown({ selected: o, onChange: n, rounded: r = !1, options: a, disab
6038
6038
  className: `${r ? "rounded-md border border-border" : "border-0"} disable:bg-gray-500 h-full w-full truncate rounded bg-background px-2 py-1 text-xs outline-none disabled:cursor-not-allowed`,
6039
6039
  onChange: (p) => n(p.target.value),
6040
6040
  onKeyDown: (p) => {
6041
- p.ctrlKey && (p.key === "z" && c(), p.key === "y" && u());
6041
+ p.ctrlKey && (p.key === "z" && c(), p.key === "y" && d());
6042
6042
  },
6043
6043
  value: i,
6044
6044
  children: [
6045
6045
  /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: "" }),
6046
- a.map((p, d) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${d}`))
6046
+ a.map((p, u) => /* @__PURE__ */ jsx("option", { className: "bg-transparent", value: p, children: p }, `option-${u}`))
6047
6047
  ]
6048
6048
  }
6049
6049
  );
@@ -6061,7 +6061,7 @@ const COLOR_PROP = {
6061
6061
  ringColor: "ring",
6062
6062
  ringOffsetColor: "ring-offset"
6063
6063
  }, ColorChoice = ({ property: o, onChange: n }) => {
6064
- const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [u, p] = useState({ color: "", shade: "" }), d = a.split("-"), g = get(d, "1", ""), m = get(d, "2", ""), h = useCallback(
6064
+ 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(
6065
6065
  // eslint-disable-next-line no-shadow
6066
6066
  (b) => {
6067
6067
  ["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" })));
@@ -6085,9 +6085,9 @@ const COLOR_PROP = {
6085
6085
  }, [r]);
6086
6086
  const { match: x } = useTailwindClassList();
6087
6087
  return useEffect(() => {
6088
- const y = `${get(COLOR_PROP, o, "")}-${u.color}${u.shade ? `-${u.shade}` : ""}`;
6088
+ const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6089
6089
  x(o, y) && n(y, o);
6090
- }, [x, u, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6090
+ }, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6091
6091
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6092
6092
  DropDown,
6093
6093
  {
@@ -6325,29 +6325,29 @@ const COLOR_PROP = {
6325
6325
  static: Cross1Icon
6326
6326
  }, IconChoices = ({ property: o, onChange: n }) => {
6327
6327
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
6328
- return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (u) => /* @__PURE__ */ jsxs(Tooltip, { children: [
6328
+ return /* @__PURE__ */ jsx("div", { className: "flex grow flex-wrap gap-1", children: map(a, (d) => /* @__PURE__ */ jsxs(Tooltip, { children: [
6329
6329
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6330
6330
  "button",
6331
6331
  {
6332
6332
  type: "button",
6333
6333
  disabled: !l,
6334
- onClick: () => n(u, o),
6335
- className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === u ? "bg-primary text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
6336
- children: React__default.createElement(get(EDITOR_ICONS, u, BoxIcon))
6334
+ onClick: () => n(d, o),
6335
+ className: `cursor-pointer rounded border border-border p-1 disabled:cursor-not-allowed ${c === d ? "bg-primary text-white" : "disabled:bg-gray-600 disabled:text-gray-400"}`,
6336
+ children: React__default.createElement(get(EDITOR_ICONS, d, BoxIcon))
6337
6337
  }
6338
6338
  ) }),
6339
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(u)) })
6339
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(d)) })
6340
6340
  ] })) });
6341
6341
  }, RangeChoices = ({ property: o, onChange: n }) => {
6342
- const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), u = c(o, [""]), p = u.indexOf(i) > -1 ? u.indexOf(i) : 0, d = /\[.*\]/g.test(i);
6343
- return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: d ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6342
+ const { canReset: r, canChange: a } = useContext(StyleContext), l = useCurrentClassByProperty(o), i = useMemo(() => get(l, "cls", ""), [l]), { getClasses: c } = useTailwindClassList(), d = c(o, [""]), p = d.indexOf(i) > -1 ? d.indexOf(i) : 0, u = /\[.*\]/g.test(i);
6343
+ return /* @__PURE__ */ jsx("div", { className: "flex flex-row divide-x divide-solid divide-border rounded border border-border text-xs", children: u ? /* @__PURE__ */ jsx("div", { className: "px-2 py-[5px]", children: i }) : /* @__PURE__ */ jsxs(Fragment, { children: [
6344
6344
  /* @__PURE__ */ jsx(
6345
6345
  "button",
6346
6346
  {
6347
6347
  type: "button",
6348
6348
  className: "hover:bg-bg-gray-700 box-border w-2/12 rounded-bl rounded-tl bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
6349
6349
  disabled: !a && (!r || p - 1 < 0),
6350
- onClick: () => n(nth(u, p - 1), o),
6350
+ onClick: () => n(nth(d, p - 1), o),
6351
6351
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
6352
6352
  MinusIcon,
6353
6353
  {
@@ -6362,12 +6362,12 @@ const COLOR_PROP = {
6362
6362
  {
6363
6363
  type: "button",
6364
6364
  className: "hover:bg-bg-gray-700 w-2/12 rounded-br rounded-tr bg-background px-1 text-center disabled:cursor-not-allowed disabled:bg-gray-600",
6365
- disabled: !a && (!r || p + 1 >= u.length),
6366
- onClick: () => n(nth(u, p + 1), o),
6365
+ disabled: !a && (!r || p + 1 >= d.length),
6366
+ onClick: () => n(nth(d, p + 1), o),
6367
6367
  children: /* @__PURE__ */ jsx("span", { className: "flex items-center justify-center", children: /* @__PURE__ */ jsx(
6368
6368
  PlusIcon,
6369
6369
  {
6370
- className: !a && (!r || p + 1 >= u.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
6370
+ className: !a && (!r || p + 1 >= d.length) ? "text-gray-500" : "text-black/60 dark:text-white/60"
6371
6371
  }
6372
6372
  ) })
6373
6373
  }
@@ -6461,23 +6461,23 @@ const COLOR_PROP = {
6461
6461
  "2xl": "1536px"
6462
6462
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6463
6463
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6464
- }, units: c, negative: u = !1 } = o, [p] = useDarkMode(), [d] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6464
+ }, 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(
6465
6465
  (I, k = !0) => {
6466
- const A = { dark: p, mq: g, mod: d, cls: I, property: l, fullCls: "" };
6467
- (p || d !== "") && (A.mq = "xs");
6468
- const v = generateFullClsName(A);
6469
- h(x, [v], k);
6466
+ const A = { dark: p, mq: g, mod: u, cls: I, property: l, fullCls: "" };
6467
+ (p || u !== "") && (A.mq = "xs");
6468
+ const w = generateFullClsName(A);
6469
+ h(x, [w], k);
6470
6470
  },
6471
- [x, p, g, d, l, h]
6472
- ), C = useCallback(() => {
6471
+ [x, p, g, u, l, h]
6472
+ ), S = useCallback(() => {
6473
6473
  f(x, [b], !0);
6474
- }, [x, b, f]), S = useMemo(() => canChangeClass(m, g), [m, g]);
6474
+ }, [x, b, f]), C = useMemo(() => canChangeClass(m, g), [m, g]);
6475
6475
  useEffect(() => {
6476
- i(S, m);
6477
- }, [S, i, m]);
6478
- const [, , w] = useScreenSizeWidth(), _ = useCallback(
6476
+ i(C, m);
6477
+ }, [C, i, m]);
6478
+ const [, , v] = useScreenSizeWidth(), _ = useCallback(
6479
6479
  (I) => {
6480
- w({
6480
+ v({
6481
6481
  xs: 400,
6482
6482
  sm: 640,
6483
6483
  md: 800,
@@ -6486,9 +6486,9 @@ const COLOR_PROP = {
6486
6486
  "2xl": 1920
6487
6487
  }[I]);
6488
6488
  },
6489
- [w]
6490
- ), B = get(m, "dark", null) === p && get(m, "mod", null) === d && get(m, "mq", null) === g;
6491
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6489
+ [v]
6490
+ ), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6491
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: C, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6492
6492
  /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
6493
6493
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6494
6494
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
@@ -6499,7 +6499,7 @@ const COLOR_PROP = {
6499
6499
  classPrefix: get(CLASS_PREFIXES, l, ""),
6500
6500
  units: c || [],
6501
6501
  onChange: y,
6502
- negative: u,
6502
+ negative: d,
6503
6503
  cssProperty: l
6504
6504
  }
6505
6505
  ) : null,
@@ -6508,7 +6508,7 @@ const COLOR_PROP = {
6508
6508
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6509
6509
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6510
6510
  ] }),
6511
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => C(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6511
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : C && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6512
6512
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6513
6513
  "button",
6514
6514
  {
@@ -6549,20 +6549,20 @@ const COLOR_PROP = {
6549
6549
  units: i = basicUnits,
6550
6550
  negative: c = !1
6551
6551
  }) => {
6552
- const { t: u } = useTranslation(), [p, d] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6552
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
6553
6553
  return /* @__PURE__ */ jsxs(
6554
6554
  "div",
6555
6555
  {
6556
6556
  className: `mb-2 border-border py-2 first:pt-0 last:pb-0 ${r ? "border-b" : ""} ${a ? "border-t" : ""}`,
6557
6557
  children: [
6558
6558
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6559
- o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: u(o) }),
6559
+ o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6560
6560
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6561
6561
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6562
6562
  "button",
6563
6563
  {
6564
6564
  type: "button",
6565
- onClick: () => d(f),
6565
+ onClick: () => u(f),
6566
6566
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6567
6567
  children: [
6568
6568
  React__default.createElement("div", {
@@ -6591,11 +6591,11 @@ const COLOR_PROP = {
6591
6591
  }, NestedOptions = ({ heading: o, items: n }) => {
6592
6592
  const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useMemo(() => {
6593
6593
  const i = (p) => flatten(
6594
- p.map((d) => d.styleType === "multiple" ? map(d.options, "key") : d.property)
6594
+ p.map((u) => u.styleType === "multiple" ? map(u.options, "key") : u.property)
6595
6595
  ), c = flatten(
6596
6596
  n.map((p) => p.styleType === "accordion" ? i(p.items) : p.styleType === "multiple" ? map(p.options, "key") : p.property)
6597
- ), u = map(a, "property");
6598
- return intersection(c, u).length > 0;
6597
+ ), d = map(a, "property");
6598
+ return intersection(c, d).length > 0;
6599
6599
  }, [a, n]);
6600
6600
  return /* @__PURE__ */ jsxs("details", { children: [
6601
6601
  /* @__PURE__ */ jsx("summary", { className: "my-px cursor-default rounded-md bg-gray-50 p-px px-2 text-[11px] text-foreground dark:bg-gray-800", children: /* @__PURE__ */ jsxs("div", { className: "inline", children: [
@@ -6612,12 +6612,12 @@ const COLOR_PROP = {
6612
6612
  }, SectionContext = createContext({}), StylingGroup = ({ section: o, showAccordian: n }) => {
6613
6613
  const { t: r } = useTranslation(), a = useSelectedBlockCurrentClasses(), l = useCallback(
6614
6614
  (c = []) => {
6615
- const u = {};
6616
- for (let d = 0; d < a.length; d++)
6617
- u[a[d].property] = a[d].cls;
6615
+ const d = {};
6616
+ for (let u = 0; u < a.length; u++)
6617
+ d[a[u].property] = a[u].cls;
6618
6618
  let p = !0;
6619
- for (const d in c)
6620
- if (!has(u, d) || u[d] !== c[d]) {
6619
+ for (const u in c)
6620
+ if (!has(d, u) || d[u] !== c[u]) {
6621
6621
  p = !1;
6622
6622
  break;
6623
6623
  }
@@ -6628,7 +6628,7 @@ const COLOR_PROP = {
6628
6628
  return /* @__PURE__ */ jsx(SectionContext.Provider, { value: i, children: n ? /* @__PURE__ */ jsxs(AccordionItem, { value: o.heading, className: "border-none", children: [
6629
6629
  /* @__PURE__ */ jsx(AccordionTrigger, { className: "border-slate-150 border-t py-2 text-xs", children: /* @__PURE__ */ jsx("div", { className: "flex items-center py-2", children: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-x-2 text-xs font-medium", children: startCase(r(o.heading)) }) }) }),
6630
6630
  /* @__PURE__ */ jsx(AccordionContent, { className: "py-2", children: o.items.map((c) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices") : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options") : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style")) })
6631
- ] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c, u) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices" + u) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options" + u) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style" + u)) }) });
6631
+ ] }) : /* @__PURE__ */ jsx("div", { className: "py-2", children: o.items.map((c, d) => has(c, "component") ? React__default.createElement(c.component, { key: c.label }) : has(c, "styleType") ? c.styleType === "multiple" ? /* @__PURE__ */ jsx(MultipleChoices, { ...c }, c.label + "multiple-choices" + d) : c.styleType === "accordion" && l(c == null ? void 0 : c.conditions) ? /* @__PURE__ */ jsx(NestedOptions, { ...c }, c.label + "nested-options" + d) : null : /* @__PURE__ */ jsx(BlockStyle, { ...c }, c.label + "block-style" + d)) }) });
6632
6632
  }, TabletIcon = ({ landscape: o = !1, className: n = "" }) => /* @__PURE__ */ jsx(
6633
6633
  "svg",
6634
6634
  {
@@ -6691,30 +6691,32 @@ const COLOR_PROP = {
6691
6691
  content: l,
6692
6692
  currentBreakpoint: i,
6693
6693
  breakpoint: c,
6694
- width: u,
6694
+ width: d,
6695
6695
  icon: p,
6696
- onClick: d
6696
+ onClick: u,
6697
+ buttonClass: g = "",
6698
+ activeButtonClass: m = ""
6697
6699
  }) => {
6698
- const { t: g } = useTranslation();
6700
+ const { t: h } = useTranslation();
6699
6701
  return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
6700
6702
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6701
6703
  Button,
6702
6704
  {
6703
- onClick: () => d(u),
6705
+ onClick: () => u(d),
6704
6706
  size: "sm",
6705
- className: "h-7 w-7 rounded-md p-1",
6707
+ className: cn$1("h-7 w-7 rounded-md p-1", c === i ? m : g),
6706
6708
  variant: c === i ? "outline" : "ghost",
6707
6709
  children: p
6708
6710
  }
6709
6711
  ) }),
6710
6712
  /* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
6711
- /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: g(a) }),
6712
- o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: g(l) })
6713
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: h(a) }),
6714
+ o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: h(l) })
6713
6715
  ] }) }) })
6714
6716
  ] }) : /* @__PURE__ */ jsx(
6715
6717
  Button,
6716
6718
  {
6717
- onClick: () => d(u),
6719
+ onClick: () => u(d),
6718
6720
  size: "sm",
6719
6721
  className: "h-7 w-7 rounded-md p-1",
6720
6722
  variant: c === i ? "outline" : "ghost",
@@ -6724,53 +6726,57 @@ const COLOR_PROP = {
6724
6726
  }, Breakpoints$1 = ({
6725
6727
  openDelay: o = 400,
6726
6728
  canvas: n = !1,
6727
- tooltip: r = !0
6729
+ tooltip: r = !0,
6730
+ buttonClass: a = "",
6731
+ activeButtonClass: l = ""
6728
6732
  }) => {
6729
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [u, p] = useSelectedBreakpoints(), d = u, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (y) => {
6730
- d.includes(y) ? d.length > 2 && g(d.filter((C) => C !== y)) : g((C) => [...C, y]);
6731
- }, x = (y) => {
6732
- n || l(y), c(y);
6733
- }, b = getBreakpointValue(n ? i : a).toLowerCase();
6734
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (y) => /* @__PURE__ */ createElement(
6733
+ const [i, , c] = useScreenSizeWidth(), [d, p] = useCanvasDisplayWidth(), [u, g] = useSelectedBreakpoints(), m = u, h = g, { t: f } = useTranslation(), x = useBuilderProp("breakpoints", WEB_BREAKPOINTS), b = (C) => {
6734
+ m.includes(C) ? m.length > 2 && h(m.filter((v) => v !== C)) : h((v) => [...v, C]);
6735
+ }, y = (C) => {
6736
+ n || c(C), p(C);
6737
+ }, S = getBreakpointValue(n ? d : i).toLowerCase();
6738
+ return x.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(x, (C) => /* @__PURE__ */ createElement(
6735
6739
  BreakpointCard,
6736
6740
  {
6737
6741
  canvas: n,
6738
- ...y,
6739
- onClick: x,
6740
- key: y.breakpoint,
6741
- currentBreakpoint: b
6742
+ ...C,
6743
+ onClick: y,
6744
+ key: C.breakpoint,
6745
+ currentBreakpoint: S
6742
6746
  }
6743
6747
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6744
6748
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
6745
- h.filter((y) => includes(d, toUpper(y.breakpoint))),
6746
- (y) => /* @__PURE__ */ createElement(
6749
+ x.filter((C) => includes(m, toUpper(C.breakpoint))),
6750
+ (C) => /* @__PURE__ */ createElement(
6747
6751
  BreakpointCard,
6748
6752
  {
6749
6753
  canvas: n,
6750
6754
  openDelay: o,
6751
6755
  tooltip: r,
6752
- ...y,
6753
- onClick: x,
6754
- key: y.breakpoint,
6755
- currentBreakpoint: b
6756
+ ...C,
6757
+ onClick: y,
6758
+ key: C.breakpoint,
6759
+ currentBreakpoint: S,
6760
+ buttonClass: a,
6761
+ activeButtonClass: l
6756
6762
  }
6757
6763
  )
6758
6764
  ) }),
6759
6765
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
6760
6766
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer rounded-md p-1 hover:bg-background", children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "scale-90 transform" }) }) }),
6761
6767
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
6762
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
6768
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
6763
6769
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6764
- map(h, (y) => /* @__PURE__ */ jsx(
6770
+ map(x, (C) => /* @__PURE__ */ jsx(
6765
6771
  DropdownMenuCheckboxItem,
6766
6772
  {
6767
- disabled: y.breakpoint === "xs",
6768
- onCheckedChange: () => f(toUpper(y.breakpoint)),
6769
- checked: includes(d, toUpper(y.breakpoint)),
6770
- onSelect: (C) => C.preventDefault(),
6771
- children: m(y.title)
6773
+ disabled: C.breakpoint === "xs",
6774
+ onCheckedChange: () => b(toUpper(C.breakpoint)),
6775
+ checked: includes(m, toUpper(C.breakpoint)),
6776
+ onSelect: (v) => v.preventDefault(),
6777
+ children: f(C.title)
6772
6778
  },
6773
- y.breakpoint
6779
+ C.breakpoint
6774
6780
  ))
6775
6781
  ] })
6776
6782
  ] })
@@ -6795,10 +6801,10 @@ function BreakpointSelector() {
6795
6801
  }
6796
6802
  function ManualClasses() {
6797
6803
  var N;
6798
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [u] = useSelectedStylingBlocks(), p = useSelectedBlock(), d = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), [h, f] = useState(""), x = (N = first(u)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((T) => !isEmpty(T)), C = useBuilderProp("flags.copyPaste", !0), S = () => {
6804
+ 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, f] = useState(""), x = (N = first(d)) == null ? void 0 : N.prop, { classes: b } = getSplitChaiClasses(get(p, x, "")), y = b.split(" ").filter((T) => !isEmpty(T)), S = useBuilderProp("flags.copyPaste", !0), C = () => {
6799
6805
  const T = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6800
- d(m, T, !0), f("");
6801
- }, [w, _] = useState([]), B = ({ value: T }) => {
6806
+ u(m, T, !0), f("");
6807
+ }, [v, _] = useState([]), B = ({ value: T }) => {
6802
6808
  const P = T.trim().toLowerCase(), R = P.match(/.+:/g);
6803
6809
  let D = [];
6804
6810
  if (R && R.length > 0) {
@@ -6812,7 +6818,7 @@ function ManualClasses() {
6812
6818
  return _(map(D, "item"));
6813
6819
  }, I = () => {
6814
6820
  _([]);
6815
- }, k = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), v = useMemo(
6821
+ }, k = (T) => T.name, A = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), w = useMemo(
6816
6822
  () => ({
6817
6823
  ref: o,
6818
6824
  autoComplete: "off",
@@ -6827,7 +6833,7 @@ function ManualClasses() {
6827
6833
  }, 0);
6828
6834
  },
6829
6835
  onKeyDown: (T) => {
6830
- T.key === "Enter" && h.trim() !== "" && S();
6836
+ T.key === "Enter" && h.trim() !== "" && C();
6831
6837
  },
6832
6838
  onChange: (T, { newValue: P }) => f(P),
6833
6839
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
@@ -6836,7 +6842,7 @@ function ManualClasses() {
6836
6842
  ), E = (T) => {
6837
6843
  debugger;
6838
6844
  const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6839
- g(m, [T]), d(m, P, !0), r(""), l(-1);
6845
+ g(m, [T]), u(m, P, !0), r(""), l(-1);
6840
6846
  }, j = () => {
6841
6847
  if (navigator.clipboard === void 0) {
6842
6848
  toast.error(c("Clipboard not supported"));
@@ -6847,7 +6853,7 @@ function ManualClasses() {
6847
6853
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
6848
6854
  /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
6849
6855
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
6850
- C && /* @__PURE__ */ jsxs(Tooltip, { children: [
6856
+ S && /* @__PURE__ */ jsxs(Tooltip, { children: [
6851
6857
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
6852
6858
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6853
6859
  ] })
@@ -6856,12 +6862,12 @@ function ManualClasses() {
6856
6862
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
6857
6863
  Autosuggest,
6858
6864
  {
6859
- suggestions: w,
6865
+ suggestions: v,
6860
6866
  onSuggestionsFetchRequested: B,
6861
6867
  onSuggestionsClearRequested: I,
6862
6868
  getSuggestionValue: k,
6863
6869
  renderSuggestion: A,
6864
- inputProps: v,
6870
+ inputProps: w,
6865
6871
  containerProps: {
6866
6872
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6867
6873
  },
@@ -6877,7 +6883,7 @@ function ManualClasses() {
6877
6883
  {
6878
6884
  variant: "outline",
6879
6885
  className: "h-6 border-border",
6880
- onClick: S,
6886
+ onClick: C,
6881
6887
  disabled: h.trim() === "",
6882
6888
  size: "sm",
6883
6889
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -7052,30 +7058,30 @@ const MAPPER = {
7052
7058
  };
7053
7059
  function BlockStyling() {
7054
7060
  const { flexChild: o, gridChild: n } = useSelectedBlocksDisplayChild(), [r] = useSelectedStylingBlocks(), [a, l] = React__default.useState(""), [i, c] = React__default.useState({
7055
- onDrag: (d) => d,
7056
- onDragEnd: (d) => d,
7061
+ onDrag: (u) => u,
7062
+ onDragEnd: (u) => u,
7057
7063
  dragStartY: 0,
7058
7064
  dragging: !1,
7059
7065
  dragStartValue: 0,
7060
7066
  dragUnit: "",
7061
7067
  negative: !1,
7062
7068
  cssProperty: ""
7063
- }), u = useThrottledCallback(
7064
- (d) => {
7069
+ }), d = useThrottledCallback(
7070
+ (u) => {
7065
7071
  const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
7066
7072
  let h = parseFloat(i.dragStartValue);
7067
7073
  h = isNaN(h) ? 0 : h;
7068
7074
  let f = MAPPER[i.dragUnit];
7069
7075
  (startsWith(m, "scale") || m === "opacity") && (f = 10);
7070
- let b = (i.dragStartY - d.pageY) / f + h;
7076
+ let b = (i.dragStartY - u.pageY) / f + h;
7071
7077
  g && b < 0 && (b = 0), m === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
7072
7078
  },
7073
7079
  [i],
7074
7080
  50
7075
7081
  ), p = useCallback(() => {
7076
7082
  setTimeout(() => i.onDragEnd(`${a}`), 100), c({
7077
- onDrag: (d) => d,
7078
- onDragEnd: (d) => d,
7083
+ onDrag: (u) => u,
7084
+ onDragEnd: (u) => u,
7079
7085
  dragStartY: 0,
7080
7086
  dragging: !1,
7081
7087
  dragStartValue: 0,
@@ -7088,7 +7094,7 @@ function BlockStyling() {
7088
7094
  i.dragging ? /* @__PURE__ */ jsx(
7089
7095
  "div",
7090
7096
  {
7091
- onMouseMove: u,
7097
+ onMouseMove: d,
7092
7098
  onMouseUp: () => p(),
7093
7099
  className: "absolute inset-0 z-30 cursor-row-resize bg-gray-300/10"
7094
7100
  }
@@ -7098,7 +7104,7 @@ function BlockStyling() {
7098
7104
  /* @__PURE__ */ jsxs(Accordion, { defaultValue: ["Styles"], type: "multiple", className: "w-full", children: [
7099
7105
  o && /* @__PURE__ */ jsx(StylingGroup, { section: FLEX_CHILD_SECTION, showAccordian: o || n }),
7100
7106
  n && /* @__PURE__ */ jsx(StylingGroup, { section: GRID_CHILD_SECTION, showAccordian: o || n }),
7101
- SETTINGS_SECTIONS.map((d) => /* @__PURE__ */ jsx(StylingGroup, { section: d, showAccordian: o || n }, d.heading))
7107
+ SETTINGS_SECTIONS.map((u) => /* @__PURE__ */ jsx(StylingGroup, { section: u, showAccordian: o || n }, u.heading))
7102
7108
  ] })
7103
7109
  ] })
7104
7110
  ] });
@@ -7109,10 +7115,10 @@ const CoreBlock = ({
7109
7115
  parentId: r,
7110
7116
  position: a
7111
7117
  }) => {
7112
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: u } = o, { addCoreBlock: p, addPredefinedBlock: d } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
7118
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
7113
7119
  if (has(o, "blocks")) {
7114
7120
  const b = isFunction(o.blocks) ? o.blocks() : o.blocks;
7115
- d(syncBlocksWithDefaults(b), r || null, a);
7121
+ u(syncBlocksWithDefaults(b), r || null, a);
7116
7122
  } else
7117
7123
  p(o, r || null, a);
7118
7124
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -7133,11 +7139,11 @@ const CoreBlock = ({
7133
7139
  className: `${kebabCase$1(`chai-block-${i}`)} cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground ${n ? "opacity-50" : ""}`,
7134
7140
  children: [
7135
7141
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
7136
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(u || i)) })
7142
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
7137
7143
  ]
7138
7144
  }
7139
7145
  ) }),
7140
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(u || i) }) })
7146
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
7141
7147
  ] }) });
7142
7148
  }, DefaultChaiBlocks = ({
7143
7149
  parentId: o,
@@ -7162,10 +7168,10 @@ let PRE_IMPORT_HTML_HOOK = async (o) => o;
7162
7168
  const registerChaiPreImportHTMLHook = (o) => {
7163
7169
  PRE_IMPORT_HTML_HOOK = o;
7164
7170
  }, getPreImportHTML = async (o) => await PRE_IMPORT_HTML_HOOK(o), ImportHTML = ({ parentId: o, position: n }) => {
7165
- const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, u] = useState(!1), p = async () => {
7166
- u(!0);
7167
- const d = await getPreImportHTML(a), g = getBlocksFromHTML(d);
7168
- i([...g], o, n), l(""), u(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7171
+ const { t: r } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), [c, d] = useState(!1), p = async () => {
7172
+ d(!0);
7173
+ const u = await getPreImportHTML(a), g = getBlocksFromHTML(u);
7174
+ i([...g], o, n), l(""), d(!1), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7169
7175
  };
7170
7176
  return /* @__PURE__ */ jsxs(Card, { className: "border-border/0 p-0 shadow-none", children: [
7171
7177
  /* @__PURE__ */ jsx(CardHeader, { className: "p-3", children: /* @__PURE__ */ jsx(CardDescription, { children: r("Use HTML snippets from Tailwind CSS component libraries") }) }),
@@ -7176,8 +7182,8 @@ const registerChaiPreImportHTMLHook = (o) => {
7176
7182
  {
7177
7183
  autoFocus: !0,
7178
7184
  tabIndex: 1,
7179
- ref: (d) => d && d.focus(),
7180
- onChange: (d) => l(d.target.value),
7185
+ ref: (u) => u && u.focus(),
7186
+ onChange: (u) => l(u.target.value),
7181
7187
  rows: 12,
7182
7188
  value: a,
7183
7189
  placeholder: r("Enter your code snippet here"),
@@ -7199,9 +7205,9 @@ const registerChaiPreImportHTMLHook = (o) => {
7199
7205
  className: l = "",
7200
7206
  height: i = ""
7201
7207
  }) => {
7202
- const [c, u] = useState(o), p = (d) => {
7203
- const g = d.target.value;
7204
- u(g), n(g);
7208
+ const [c, d] = useState(o), p = (u) => {
7209
+ const g = u.target.value;
7210
+ d(g), n(g);
7205
7211
  };
7206
7212
  return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
7207
7213
  "select",
@@ -7214,7 +7220,7 @@ const registerChaiPreImportHTMLHook = (o) => {
7214
7220
  onChange: p,
7215
7221
  children: [
7216
7222
  /* @__PURE__ */ jsx("option", { value: "", disabled: !0, children: a }),
7217
- r.map((d) => /* @__PURE__ */ jsx("option", { value: d.value, children: d.label }, d.value))
7223
+ r.map((u) => /* @__PURE__ */ jsx("option", { value: u.value, children: u.label }, u.value))
7218
7224
  ]
7219
7225
  }
7220
7226
  ) });
@@ -7250,20 +7256,20 @@ const registerChaiLibrary = (o, n) => {
7250
7256
  parentId: r = void 0,
7251
7257
  position: a = -1
7252
7258
  }) => {
7253
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: u, addPredefinedBlock: p } = useAddBlock(), [, d] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (S) => {
7254
- const w = has(S, "styles_attrs.data-page-section");
7255
- return S._type === "Box" && w;
7259
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), b = (C) => {
7260
+ const v = has(C, "styles_attrs.data-page-section");
7261
+ return C._type === "Box" && v;
7256
7262
  }, y = useCallback(
7257
- async (S) => {
7258
- if (S.stopPropagation(), has(o, "component")) {
7259
- u(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7263
+ async (C) => {
7264
+ if (C.stopPropagation(), has(o, "component")) {
7265
+ d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7260
7266
  return;
7261
7267
  }
7262
7268
  i(!0);
7263
- let w = await c({ library: n, block: o });
7264
- typeof w == "string" && (w = getBlocksFromHTML(w)), isEmpty(w) || p(syncBlocksWithDefaults(w), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7269
+ let v = await c({ library: n, block: o });
7270
+ typeof v == "string" && (v = getBlocksFromHTML(v)), isEmpty(v) || p(syncBlocksWithDefaults(v), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7265
7271
  },
7266
- [u, p, o, c, n, r, a]
7272
+ [d, p, o, c, n, r, a]
7267
7273
  );
7268
7274
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
7269
7275
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
@@ -7272,20 +7278,20 @@ const registerChaiLibrary = (o, n) => {
7272
7278
  onClick: l ? () => {
7273
7279
  } : y,
7274
7280
  draggable: f ? "true" : "false",
7275
- onDragStart: async (S) => {
7276
- const w = await c({ library: n, block: o });
7281
+ onDragStart: async (C) => {
7282
+ const v = await c({ library: n, block: o });
7277
7283
  let _ = r;
7278
- if (b(first(w)) && (_ = null), !isEmpty(w)) {
7279
- const B = { blocks: w, uiLibrary: !0, parent: _ };
7280
- if (S.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
7284
+ if (b(first(v)) && (_ = null), !isEmpty(v)) {
7285
+ const B = { blocks: v, uiLibrary: !0, parent: _ };
7286
+ if (C.dataTransfer.setData("text/plain", JSON.stringify(B)), o.preview) {
7281
7287
  const I = new Image();
7282
7288
  I.src = o.preview, I.onload = () => {
7283
- S.dataTransfer.setDragImage(I, 0, 0);
7289
+ C.dataTransfer.setDragImage(I, 0, 0);
7284
7290
  };
7285
7291
  } else
7286
- S.dataTransfer.setDragImage(new Image(), 0, 0);
7292
+ C.dataTransfer.setDragImage(new Image(), 0, 0);
7287
7293
  x(B), setTimeout(() => {
7288
- d([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7294
+ u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7289
7295
  }, 200);
7290
7296
  }
7291
7297
  },
@@ -7307,7 +7313,7 @@ const registerChaiLibrary = (o, n) => {
7307
7313
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "max-w-xs", children: /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }) }) })
7308
7314
  ] });
7309
7315
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7310
- const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((E) => E.id === r) || first(l), { data: c, isLoading: u, resetLibrary: p } = useLibraryBlocks(i), [d, g] = useState(""), [m, h] = useState([]), f = useRef(null);
7316
+ const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((E) => E.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
7311
7317
  useEffect(() => {
7312
7318
  c && c.length > 0 && (f.current = new Fuse(c, {
7313
7319
  keys: ["name", "label", "description", "group"],
@@ -7315,39 +7321,39 @@ const registerChaiLibrary = (o, n) => {
7315
7321
  ignoreLocation: !0
7316
7322
  }));
7317
7323
  }, [c]), useEffect(() => {
7318
- if (!d.trim() || !f.current) {
7324
+ if (!u.trim() || !f.current) {
7319
7325
  h([]);
7320
7326
  return;
7321
7327
  }
7322
- const E = f.current.search(d).map((j) => j.item);
7328
+ const E = f.current.search(u).map((j) => j.item);
7323
7329
  h(E);
7324
- }, [d]);
7325
- const x = d.trim() && !isEmpty(m) ? m : c, b = groupBy(x, "group"), [y, C] = useState(null);
7330
+ }, [u]);
7331
+ const x = u.trim() && !isEmpty(m) ? m : c, b = groupBy(x, "group"), [y, S] = useState(null);
7326
7332
  useEffect(() => {
7327
7333
  if (isEmpty(keys(b))) {
7328
- C(null);
7334
+ S(null);
7329
7335
  return;
7330
7336
  }
7331
7337
  if (!y || !b[y]) {
7332
- C(first(keys(b)));
7338
+ S(first(keys(b)));
7333
7339
  return;
7334
7340
  }
7335
7341
  }, [b, y]);
7336
- const S = get(b, y, []), w = useRef(null), { t: _ } = useTranslation(), B = (E) => {
7337
- w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7338
- w.current && C(E);
7342
+ const C = get(b, y, []), v = useRef(null), { t: _ } = useTranslation(), B = (E) => {
7343
+ v.current && (clearTimeout(v.current), v.current = null), v.current = setTimeout(() => {
7344
+ v.current && S(E);
7339
7345
  }, 400);
7340
7346
  }, I = () => {
7341
7347
  i != null && i.id && p(i.id);
7342
7348
  }, k = () => {
7343
7349
  g("");
7344
7350
  };
7345
- if (u)
7351
+ if (d)
7346
7352
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
7347
7353
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7348
7354
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7349
7355
  ] });
7350
- const A = filter(S, (E, j) => j % 2 === 0), v = filter(S, (E, j) => j % 2 === 1);
7356
+ const A = filter(C, (E, j) => j % 2 === 0), w = filter(C, (E, j) => j % 2 === 1);
7351
7357
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7352
7358
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7353
7359
  /* @__PURE__ */ jsx(MagnifyingGlassIcon, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7355,12 +7361,12 @@ const registerChaiLibrary = (o, n) => {
7355
7361
  Input$1,
7356
7362
  {
7357
7363
  placeholder: _("Search blocks..."),
7358
- value: d,
7364
+ value: u,
7359
7365
  onChange: (E) => g(E.target.value),
7360
7366
  className: "w-full pl-8 pr-8"
7361
7367
  }
7362
7368
  ),
7363
- d && /* @__PURE__ */ jsx(
7369
+ u && /* @__PURE__ */ jsx(
7364
7370
  "button",
7365
7371
  {
7366
7372
  onClick: k,
@@ -7375,7 +7381,7 @@ const registerChaiLibrary = (o, n) => {
7375
7381
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7376
7382
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7377
7383
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7378
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: d ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7384
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7379
7385
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7380
7386
  /* @__PURE__ */ jsxs(Button, { onClick: I, variant: "outline", size: "sm", className: "gap-2", children: [
7381
7387
  /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
@@ -7385,9 +7391,9 @@ const registerChaiLibrary = (o, n) => {
7385
7391
  "div",
7386
7392
  {
7387
7393
  onMouseEnter: () => B(j),
7388
- onMouseLeave: () => clearTimeout(w.current),
7394
+ onMouseLeave: () => clearTimeout(v.current),
7389
7395
  role: "button",
7390
- onClick: () => C(j),
7396
+ onClick: () => S(j),
7391
7397
  className: cn$1(
7392
7398
  "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",
7393
7399
  j === y ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
@@ -7404,10 +7410,10 @@ const registerChaiLibrary = (o, n) => {
7404
7410
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
7405
7411
  ScrollArea,
7406
7412
  {
7407
- onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
7413
+ onMouseEnter: () => v.current ? clearTimeout(v.current) : null,
7408
7414
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7409
7415
  children: [
7410
- isEmpty(S) && !isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7416
+ isEmpty(C) && !isEmpty(b) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7411
7417
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: A.map((E, j) => /* @__PURE__ */ jsx(
7412
7418
  BlockCard,
7413
7419
  {
@@ -7418,7 +7424,7 @@ const registerChaiLibrary = (o, n) => {
7418
7424
  },
7419
7425
  `block-${j}`
7420
7426
  )) }),
7421
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((E, j) => /* @__PURE__ */ jsx(
7427
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: w.map((E, j) => /* @__PURE__ */ jsx(
7422
7428
  BlockCard,
7423
7429
  {
7424
7430
  parentId: o,
@@ -7451,9 +7457,9 @@ const registerChaiLibrary = (o, n) => {
7451
7457
  position: n,
7452
7458
  gridCols: r = "grid-cols-2"
7453
7459
  }) => {
7454
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [u, p] = useAtom$1(partialBlocksDataAtom), [d, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7460
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7455
7461
  useEffect(() => {
7456
- if (!d || Object.keys(u.blocks).length === 0)
7462
+ if (!u || Object.keys(d.blocks).length === 0)
7457
7463
  if (c)
7458
7464
  p({
7459
7465
  blocks: [],
@@ -7463,14 +7469,14 @@ const registerChaiLibrary = (o, n) => {
7463
7469
  }), g(!0);
7464
7470
  else if (!l && Object.keys(a || {}).length > 0) {
7465
7471
  const h = Object.entries(a).map(([x, b]) => {
7466
- const y = b, C = y.type || "partial", S = formatReadableName(C);
7472
+ const y = b, S = y.type || "partial", C = formatReadableName(S);
7467
7473
  return {
7468
7474
  type: "PartialBlock",
7469
7475
  // Set the type to PartialBlock
7470
7476
  label: formatReadableName(y.name || x),
7471
7477
  description: y.description || "",
7472
7478
  icon: FrameIcon,
7473
- group: S,
7479
+ group: C,
7474
7480
  // Use formatted type as group
7475
7481
  category: "partial",
7476
7482
  partialBlockId: x,
@@ -7493,17 +7499,17 @@ const registerChaiLibrary = (o, n) => {
7493
7499
  }, [
7494
7500
  l,
7495
7501
  a,
7496
- d,
7502
+ u,
7497
7503
  g,
7498
7504
  p,
7499
- u.blocks,
7505
+ d.blocks,
7500
7506
  c
7501
7507
  ]);
7502
7508
  const m = () => {
7503
7509
  p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7504
7510
  };
7505
- return u.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : u.error || u.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7506
- /* @__PURE__ */ jsx("p", { children: u.error || "No partial blocks available" }),
7511
+ 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: [
7512
+ /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7507
7513
  /* @__PURE__ */ jsx(
7508
7514
  "button",
7509
7515
  {
@@ -7518,15 +7524,15 @@ const registerChaiLibrary = (o, n) => {
7518
7524
  gridCols: r,
7519
7525
  parentId: o,
7520
7526
  position: n,
7521
- groups: u.groups,
7522
- blocks: u.blocks
7527
+ groups: d.groups,
7528
+ blocks: d.blocks
7523
7529
  }
7524
7530
  );
7525
7531
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, n) => {
7526
7532
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7527
7533
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4", disableBlockGroupsSidebar: i }) => {
7528
7534
  var E;
7529
- const { t: c } = useTranslation(), [u] = useBlocksStore(), [p, d] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), h = (E = find(u, (j) => j._id === r)) == null ? void 0 : E._type, [f, x] = useState("all"), [b, y] = useState(null), C = useRef(null);
7535
+ const { t: c } = useTranslation(), [d] = useBlocksStore(), [p, u] = useState(""), g = useRef(null), [m] = useAtom$1(addBlockTabAtom), h = (E = find(d, (j) => j._id === r)) == null ? void 0 : E._type, [f, x] = useState("all"), [b, y] = useState(null), S = useRef(null);
7530
7536
  useEffect(() => {
7531
7537
  const j = setTimeout(() => {
7532
7538
  var N;
@@ -7535,17 +7541,17 @@ const registerChaiLibrary = (o, n) => {
7535
7541
  return () => clearTimeout(j);
7536
7542
  }, [m]), useEffect(() => {
7537
7543
  p && (x("all"), y(null));
7538
- }, [p]), useEffect(() => (C.current = debounce((j) => {
7544
+ }, [p]), useEffect(() => (S.current = debounce((j) => {
7539
7545
  x(j);
7540
7546
  }, 500), () => {
7541
- C.current && C.current.cancel();
7547
+ S.current && S.current.cancel();
7542
7548
  }), []);
7543
- const S = useCallback((j) => {
7544
- y(j), C.current && C.current(j);
7545
- }, []), w = useCallback(() => {
7546
- y(null), C.current && C.current.cancel();
7549
+ const C = useCallback((j) => {
7550
+ y(j), S.current && S.current(j);
7551
+ }, []), v = useCallback(() => {
7552
+ y(null), S.current && S.current.cancel();
7547
7553
  }, []), _ = useCallback((j) => {
7548
- C.current && C.current.cancel(), x(j), y(null);
7554
+ S.current && S.current.cancel(), x(j), y(null);
7549
7555
  }, []), B = useMemo(
7550
7556
  () => p ? values(n).filter(
7551
7557
  (j) => {
@@ -7562,7 +7568,7 @@ const registerChaiLibrary = (o, n) => {
7562
7568
  ), k = useMemo(
7563
7569
  () => sortBy(I, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
7564
7570
  [I]
7565
- ), A = useMemo(() => f === "all" ? B : filter(values(B), { group: f }), [B, f]), v = useMemo(() => f === "all" ? k : [f], [k, f]);
7571
+ ), A = useMemo(() => f === "all" ? B : filter(values(B), { group: f }), [B, f]), w = useMemo(() => f === "all" ? k : [f], [k, f]);
7566
7572
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7567
7573
  /* @__PURE__ */ jsx("div", { className: `${i ? "px-2" : "px-4"} sticky top-0 py-2 z-10 bg-background/80 backdrop-blur-sm`, children: /* @__PURE__ */ jsx(
7568
7574
  Input$1,
@@ -7572,7 +7578,7 @@ const registerChaiLibrary = (o, n) => {
7572
7578
  placeholder: c("Search blocks..."),
7573
7579
  value: p,
7574
7580
  className: "-ml-2",
7575
- onChange: (j) => d(j.target.value)
7581
+ onChange: (j) => u(j.target.value)
7576
7582
  }
7577
7583
  ) }),
7578
7584
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7581,8 +7587,8 @@ const registerChaiLibrary = (o, n) => {
7581
7587
  "button",
7582
7588
  {
7583
7589
  onClick: () => _("all"),
7584
- onMouseEnter: () => S("all"),
7585
- onMouseLeave: w,
7590
+ onMouseEnter: () => C("all"),
7591
+ onMouseLeave: v,
7586
7592
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${f === "all" || b === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7587
7593
  children: c("All")
7588
7594
  },
@@ -7592,8 +7598,8 @@ const registerChaiLibrary = (o, n) => {
7592
7598
  "button",
7593
7599
  {
7594
7600
  onClick: () => _(j),
7595
- onMouseEnter: () => S(j),
7596
- onMouseLeave: w,
7601
+ onMouseEnter: () => C(j),
7602
+ onMouseLeave: v,
7597
7603
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${f === j || b === j ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7598
7604
  children: capitalize(c(j.toLowerCase()))
7599
7605
  },
@@ -7609,7 +7615,7 @@ const registerChaiLibrary = (o, n) => {
7609
7615
  ' "',
7610
7616
  p,
7611
7617
  '"'
7612
- ] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: v.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7618
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: `${i ? "p-0" : "p-4"} space-y-6`, children: w.map((j) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7613
7619
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(j.toLowerCase())) }),
7614
7620
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7615
7621
  f === "all" ? filter(values(A), { group: j }) : values(A),
@@ -7635,7 +7641,7 @@ const registerChaiLibrary = (o, n) => {
7635
7641
  parentId: r = void 0,
7636
7642
  position: a = -1
7637
7643
  }) => {
7638
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, u] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("flags.importHtml", !0), { data: d } = usePartialBlocksList(), g = Object.keys(d || {}).length > 0, { hasPermission: m } = usePermissions();
7644
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("flags.importHtml", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: m } = usePermissions();
7639
7645
  useEffect(() => {
7640
7646
  i === "partials" && !g && c("library");
7641
7647
  }, [i, g, c]);
@@ -7652,8 +7658,8 @@ const registerChaiLibrary = (o, n) => {
7652
7658
  /* @__PURE__ */ jsxs(
7653
7659
  Tabs,
7654
7660
  {
7655
- onValueChange: (C) => {
7656
- u(""), c(C);
7661
+ onValueChange: (S) => {
7662
+ d(""), c(S);
7657
7663
  },
7658
7664
  value: i,
7659
7665
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7663,13 +7669,13 @@ const registerChaiLibrary = (o, n) => {
7663
7669
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7664
7670
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7665
7671
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7666
- map(f, (C) => /* @__PURE__ */ jsx(TabsTrigger, { value: C.id, children: React__default.createElement(C.tab) }, `tab-add-block-${C.id}`))
7672
+ map(f, (S) => /* @__PURE__ */ jsx(TabsTrigger, { value: S.id, children: React__default.createElement(S.tab) }, `tab-add-block-${S.id}`))
7667
7673
  ] }),
7668
7674
  /* @__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 }) }) }) }),
7669
7675
  y && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7670
7676
  g && /* @__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 }) }) }) }),
7671
7677
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7672
- map(f, (C) => /* @__PURE__ */ jsx(TabsContent, { value: C.id, children: React__default.createElement(C.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${C.id}`))
7678
+ map(f, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${S.id}`))
7673
7679
  ]
7674
7680
  }
7675
7681
  )
@@ -7779,10 +7785,10 @@ const registerChaiSaveToLibrary = (o) => {
7779
7785
  }, SaveToLibraryModal = () => {
7780
7786
  const [o, n] = useAtom$1(saveToLibraryModalAtom), { t: r } = useTranslation(), [a] = useBlocksStore(), l = () => n({ isOpen: !1, blockId: null }), i = useSaveToLibraryComponent(), c = useMemo(() => {
7781
7787
  if (!o.blockId) return [];
7782
- const u = find(a, { _id: o.blockId });
7783
- return u == null || delete u._parent, [u, ...getBlocks(a, u == null ? void 0 : u._id)];
7788
+ const d = find(a, { _id: o.blockId });
7789
+ return d == null || delete d._parent, [d, ...getBlocks(a, d == null ? void 0 : d._id)];
7784
7790
  }, [o.blockId, a]);
7785
- return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (u) => !u && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
7791
+ return /* @__PURE__ */ jsx(Dialog, { open: o.isOpen, onOpenChange: (d) => !d && l(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-4 sm:max-w-[450px]", children: [
7786
7792
  /* @__PURE__ */ jsx(DialogHeader, { className: "pb-2", children: /* @__PURE__ */ jsx(DialogTitle, { children: r("Save to Library") }) }),
7787
7793
  i && !isEmpty(o.blockId) && /* @__PURE__ */ jsx(i, { blockId: o.blockId, blocks: c, close: l })
7788
7794
  ] }) });
@@ -7824,35 +7830,35 @@ const registerChaiSaveToLibrary = (o) => {
7824
7830
  }
7825
7831
  ) : null;
7826
7832
  }, CopyPasteBlocks = () => {
7827
- const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), u = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
7828
- const d = n.map((g) => {
7833
+ const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useBuilderProp("flags.copyPaste", !0), p = useCallback(() => {
7834
+ const u = n.map((g) => {
7829
7835
  const m = o.find((h) => h._id === g);
7830
7836
  return {
7831
7837
  id: g,
7832
7838
  data: m
7833
7839
  };
7834
7840
  });
7835
- l(d.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
7841
+ l(u.map((g) => g.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
7836
7842
  cancel: {
7837
7843
  label: i("No"),
7838
7844
  onClick: () => {
7839
- a(d.map((g) => g.id)), toast.dismiss();
7845
+ a(u.map((g) => g.id)), toast.dismiss();
7840
7846
  }
7841
7847
  },
7842
7848
  action: {
7843
7849
  label: i("Yes"),
7844
7850
  onClick: () => {
7845
7851
  a(
7846
- d.map((g) => g.id),
7852
+ u.map((g) => g.id),
7847
7853
  !0
7848
7854
  ), toast.dismiss();
7849
7855
  }
7850
7856
  },
7851
7857
  position: "top-center"
7852
- }) : a(d.map((g) => g.id));
7858
+ }) : a(u.map((g) => g.id));
7853
7859
  }, [n, o, a, l]);
7854
7860
  return /* @__PURE__ */ jsxs(Fragment, { children: [
7855
- u && /* @__PURE__ */ jsxs(
7861
+ d && /* @__PURE__ */ jsxs(
7856
7862
  DropdownMenuItem,
7857
7863
  {
7858
7864
  disabled: !canDuplicateBlock(c == null ? void 0 : c._type),
@@ -7865,7 +7871,7 @@ const registerChaiSaveToLibrary = (o) => {
7865
7871
  ]
7866
7872
  }
7867
7873
  ),
7868
- u && /* @__PURE__ */ jsxs(
7874
+ d && /* @__PURE__ */ jsxs(
7869
7875
  DropdownMenuItem,
7870
7876
  {
7871
7877
  className: "flex items-center gap-x-4 text-xs",
@@ -7919,7 +7925,7 @@ const registerChaiSaveToLibrary = (o) => {
7919
7925
  }
7920
7926
  );
7921
7927
  }, BlockContextMenuContent = ({ node: o }) => {
7922
- const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), u = useCallback(() => {
7928
+ const { t: n } = useTranslation(), [r] = useSelectedBlockIds(), a = useDuplicateBlocks(), l = useSelectedBlock(), { hasPermission: i } = usePermissions(), { librarySite: c } = useBuilderProp("flags", { librarySite: !1 }), d = useCallback(() => {
7923
7929
  a(r);
7924
7930
  }, [r, a]), p = useMemo(() => has(l, "_libBlockId") && !isEmpty(l._libBlockId), [l == null ? void 0 : l._libBlockId]);
7925
7931
  return o === "BODY" ? /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: i(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -7941,7 +7947,7 @@ const registerChaiSaveToLibrary = (o) => {
7941
7947
  DropdownMenuItem,
7942
7948
  {
7943
7949
  disabled: !1,
7944
- onClick: (d) => d.preventDefault(),
7950
+ onClick: (u) => u.preventDefault(),
7945
7951
  className: "flex items-center gap-x-4 text-xs",
7946
7952
  children: /* @__PURE__ */ jsx(ClearCanvas, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-4 text-xs", children: [
7947
7953
  /* @__PURE__ */ jsx(EraserIcon, {}),
@@ -7970,7 +7976,7 @@ const registerChaiSaveToLibrary = (o) => {
7970
7976
  {
7971
7977
  disabled: !canDuplicateBlock(l == null ? void 0 : l._type),
7972
7978
  className: "flex items-center gap-x-4 text-xs",
7973
- onClick: u,
7979
+ onClick: d,
7974
7980
  children: [
7975
7981
  /* @__PURE__ */ jsx(CardStackPlusIcon, {}),
7976
7982
  " ",
@@ -8042,24 +8048,24 @@ const Input = ({ node: o }) => {
8042
8048
  }, truncateText = (o, n) => o.length > n ? o.substring(0, n) + "..." : o, Node$1 = memo(({ node: o, style: n, dragHandle: r }) => {
8043
8049
  var D;
8044
8050
  const { t: a } = useTranslation(), l = useUpdateBlocksProps(), [i] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
8045
- let u = null;
8046
- const p = o.children.length > 0, { highlightBlock: d, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: C } = o, S = get(h, "_show", !0), w = (L) => {
8047
- L.stopPropagation(), S && o.toggle();
8051
+ let d = null;
8052
+ const p = o.children.length > 0, { highlightBlock: u, clearHighlight: g } = useBlockHighlight(), { id: m, data: h, isSelected: f, willReceiveDrop: x, isDragging: b, isEditing: y, handleClick: S } = o, C = get(h, "_show", !0), v = (L) => {
8053
+ L.stopPropagation(), C && o.toggle();
8048
8054
  }, _ = (L) => {
8049
- L.isInternal && (u = L.isOpen, L.isOpen && L.close());
8055
+ L.isInternal && (d = L.isOpen, L.isOpen && L.close());
8050
8056
  }, B = (L) => {
8051
- L.isInternal && u !== null && (u ? L.open() : L.close(), u = null);
8057
+ L.isInternal && d !== null && (d ? L.open() : L.close(), d = null);
8052
8058
  }, [I, k] = useAtom$1(currentAddSelection), A = () => {
8053
8059
  var L;
8054
- v(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
8055
- }, v = () => {
8060
+ w(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
8061
+ }, w = () => {
8056
8062
  k(null);
8057
8063
  }, E = (L) => {
8058
- v(), L.stopPropagation(), !o.isOpen && S && o.toggle(), C(L);
8064
+ w(), L.stopPropagation(), !o.isOpen && C && o.toggle(), S(L);
8059
8065
  };
8060
8066
  useEffect(() => {
8061
8067
  const L = setTimeout(() => {
8062
- x && !o.isOpen && !b && S && o.toggle();
8068
+ x && !o.isOpen && !b && C && o.toggle();
8063
8069
  }, 500);
8064
8070
  return () => clearTimeout(L);
8065
8071
  }, [x, o, b]);
@@ -8069,7 +8075,7 @@ const Input = ({ node: o }) => {
8069
8075
  const V = M.getBoundingClientRect(), H = i.getBoundingClientRect();
8070
8076
  V.top >= H.top && V.left >= H.left && V.bottom <= H.bottom && V.right <= H.right || (F.documentElement.scrollTop = M.offsetTop - H.top);
8071
8077
  }, N = (L) => {
8072
- v();
8078
+ w();
8073
8079
  const O = get(o, "parent.id");
8074
8080
  O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
8075
8081
  };
@@ -8095,7 +8101,7 @@ const Input = ({ node: o }) => {
8095
8101
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
8096
8102
  "div",
8097
8103
  {
8098
- onMouseEnter: () => d(m),
8104
+ onMouseEnter: () => u(m),
8099
8105
  onMouseLeave: () => g(),
8100
8106
  onClick: E,
8101
8107
  style: n,
@@ -8120,7 +8126,7 @@ const Input = ({ node: o }) => {
8120
8126
  L.stopPropagation(), N(o.childIndex);
8121
8127
  },
8122
8128
  onMouseEnter: A,
8123
- onMouseLeave: v,
8129
+ onMouseLeave: w,
8124
8130
  className: "absolute -top-0.5 h-0.5 w-[90%] rounded bg-primary/80 opacity-0 delay-200 duration-200 group-hover:opacity-100",
8125
8131
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary/80 p-1 outline outline-2 outline-white hover:bg-primary/80", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[2] text-white" }) })
8126
8132
  }
@@ -8134,7 +8140,7 @@ const Input = ({ node: o }) => {
8134
8140
  x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
8135
8141
  (o == null ? void 0 : o.id) === I ? "bg-primary/10" : "",
8136
8142
  b && "opacity-20",
8137
- S ? "" : "line-through opacity-50",
8143
+ C ? "" : "line-through opacity-50",
8138
8144
  P && f && "bg-primary/20 text-primary"
8139
8145
  ),
8140
8146
  children: [
@@ -8143,7 +8149,7 @@ const Input = ({ node: o }) => {
8143
8149
  "div",
8144
8150
  {
8145
8151
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
8146
- children: p && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
8152
+ children: p && /* @__PURE__ */ jsx("button", { onClick: v, type: "button", children: /* @__PURE__ */ jsx(ChevronRightIcon, { className: "h-3 w-3" }) })
8147
8153
  }
8148
8154
  ),
8149
8155
  /* @__PURE__ */ jsxs(
@@ -8173,7 +8179,7 @@ const Input = ({ node: o }) => {
8173
8179
  )
8174
8180
  ] }),
8175
8181
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-px group-hover:visible", children: [
8176
- canAddChildBlock(h == null ? void 0 : h._type) && S && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8182
+ canAddChildBlock(h == null ? void 0 : h._type) && C && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8177
8183
  /* @__PURE__ */ jsx(
8178
8184
  TooltipTrigger,
8179
8185
  {
@@ -8190,14 +8196,14 @@ const Input = ({ node: o }) => {
8190
8196
  TooltipTrigger,
8191
8197
  {
8192
8198
  onClick: (L) => {
8193
- L.stopPropagation(), l([m], { _show: !S }), o.isOpen && o.toggle();
8199
+ L.stopPropagation(), l([m], { _show: !C }), o.isOpen && o.toggle();
8194
8200
  },
8195
8201
  className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
8196
8202
  asChild: !0,
8197
- children: S ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
8203
+ children: C ? /* @__PURE__ */ jsx(EyeClosedIcon, { className: "h-4 w-4" }) : /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-4 w-4" })
8198
8204
  }
8199
8205
  ),
8200
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(S ? "Hide the block from page" : "Show the block on page") })
8206
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999] text-xs", side: "bottom", children: a(C ? "Hide the block from page" : "Show the block on page") })
8201
8207
  ] }),
8202
8208
  /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded bg-transparent p-px hover:bg-primary/10", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "h-3 w-3" }) }) })
8203
8209
  ] })
@@ -8240,8 +8246,8 @@ const Input = ({ node: o }) => {
8240
8246
  return (n, r) => {
8241
8247
  var i;
8242
8248
  const a = (i = find(o, { _id: r })) == null ? void 0 : i._type, l = first(n.map((c) => {
8243
- var u;
8244
- return (u = find(o, { _id: c })) == null ? void 0 : u._type;
8249
+ var d;
8250
+ return (d = find(o, { _id: c })) == null ? void 0 : d._type;
8245
8251
  }));
8246
8252
  return canAcceptChildBlock(a, l);
8247
8253
  };
@@ -8642,12 +8648,12 @@ const Input = ({ node: o }) => {
8642
8648
  console.warn("Failed to clear previous theme from localStorage:", o);
8643
8649
  }
8644
8650
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8645
- const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), u = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0);
8646
- if (u) {
8647
- const k = u.map((A) => Object.keys(A)[0]);
8651
+ const [n, r] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions(), g = useBuilderProp("flags.importTheme", !0), m = useBuilderProp("flags.darkMode", !0);
8652
+ if (d) {
8653
+ const k = d.map((A) => Object.keys(A)[0]);
8648
8654
  DEFAULT_THEME_PRESET.forEach((A) => {
8649
- const v = Object.keys(A)[0];
8650
- k.includes(v) || u.push(A);
8655
+ const w = Object.keys(A)[0];
8656
+ k.includes(w) || d.push(A);
8651
8657
  });
8652
8658
  }
8653
8659
  const [h, f] = useTheme(), x = useThemeOptions(), { t: b } = useTranslation(), y = React.useCallback(
@@ -8668,16 +8674,16 @@ const Input = ({ node: o }) => {
8668
8674
  });
8669
8675
  },
8670
8676
  [h, f]
8671
- ), C = () => {
8672
- const k = u.find((A) => Object.keys(A)[0] === a);
8677
+ ), S = () => {
8678
+ const k = d.find((A) => Object.keys(A)[0] === a);
8673
8679
  if (k) {
8674
8680
  const A = Object.values(k)[0];
8675
8681
  A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? (y(A), l("")) : console.error("Invalid preset structure:", A);
8676
8682
  } else
8677
8683
  console.error("Preset not found:", a);
8678
- }, S = (k) => {
8684
+ }, C = (k) => {
8679
8685
  y(k), l("");
8680
- }, w = useDebouncedCallback(
8686
+ }, v = useDebouncedCallback(
8681
8687
  (k, A) => {
8682
8688
  f(() => ({
8683
8689
  ...h,
@@ -8700,12 +8706,12 @@ const Input = ({ node: o }) => {
8700
8706
  ), B = useDebouncedCallback(
8701
8707
  (k, A) => {
8702
8708
  f(() => {
8703
- const v = get(h, `colors.${k}`);
8704
- return n ? set(v, 1, A) : set(v, 0, A), {
8709
+ const w = get(h, `colors.${k}`);
8710
+ return n ? set(w, 1, A) : set(w, 0, A), {
8705
8711
  ...h,
8706
8712
  colors: {
8707
8713
  ...h.colors,
8708
- [k]: v
8714
+ [k]: w
8709
8715
  }
8710
8716
  };
8711
8717
  });
@@ -8713,21 +8719,21 @@ const Input = ({ node: o }) => {
8713
8719
  [h],
8714
8720
  200
8715
8721
  ), I = (k) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(k.items).map(([A]) => {
8716
- const v = get(h, `colors.${A}.${n ? 1 : 0}`);
8717
- return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8722
+ const w = get(h, `colors.${A}.${n ? 1 : 0}`);
8723
+ return w ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8718
8724
  /* @__PURE__ */ jsx(
8719
8725
  ColorPickerInput,
8720
8726
  {
8721
- value: v,
8727
+ value: w,
8722
8728
  onChange: (E) => B(A, E)
8723
8729
  }
8724
8730
  ),
8725
8731
  /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
8726
8732
  ] }, A) : null;
8727
8733
  }) });
8728
- return d("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8734
+ return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8729
8735
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8730
- u.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
8736
+ d.length > 0 && /* @__PURE__ */ jsxs("div", { className: "mx-0 my-2 flex flex-col gap-1 py-2", children: [
8731
8737
  /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between", children: [
8732
8738
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: b("Presets") }),
8733
8739
  /* @__PURE__ */ jsx("div", { className: "flex gap-2", children: g && /* @__PURE__ */ jsxs(Button, { className: "px-1", variant: "link", size: "sm", onClick: () => c(!0), children: [
@@ -8738,12 +8744,12 @@ const Input = ({ node: o }) => {
8738
8744
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8739
8745
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8740
8746
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: b("Select preset") }) }),
8741
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(u) && u.map((k) => {
8742
- const A = Object.keys(k)[0], v = A.replaceAll("_", " ");
8743
- return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(v) }, A);
8747
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((k) => {
8748
+ const A = Object.keys(k)[0], w = A.replaceAll("_", " ");
8749
+ return /* @__PURE__ */ jsx(SelectItem, { value: A, children: capitalize(w) }, A);
8744
8750
  }) })
8745
8751
  ] }) }),
8746
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: C, children: b("Apply") }) })
8752
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: S, children: b("Apply") }) })
8747
8753
  ] })
8748
8754
  ] }),
8749
8755
  /* @__PURE__ */ jsx(Separator, {}),
@@ -8757,7 +8763,7 @@ const Input = ({ node: o }) => {
8757
8763
  {
8758
8764
  label: k,
8759
8765
  value: h.fontFamily[k.replace(/font-/g, "")] || A[Object.keys(A)[0]],
8760
- onChange: (v) => w(k, v)
8766
+ onChange: (w) => v(k, w)
8761
8767
  },
8762
8768
  k
8763
8769
  )) }),
@@ -8800,7 +8806,7 @@ const Input = ({ node: o }) => {
8800
8806
  {
8801
8807
  open: i,
8802
8808
  onOpenChange: c,
8803
- onImport: S
8809
+ onImport: C
8804
8810
  }
8805
8811
  ) })
8806
8812
  ] }),
@@ -9314,17 +9320,17 @@ function QuickPrompts({ onClick: o }) {
9314
9320
  lang: get(LANGUAGES, a, a)
9315
9321
  })
9316
9322
  }), /* @__PURE__ */ jsx("div", { className: n ? "pointer-events-none opacity-50" : "", children: /* @__PURE__ */ jsx("ul", { className: "space-y-1", children: c.map(
9317
- ({ name: u, icon: p, subMenus: d, prompt: g }) => d ? /* @__PURE__ */ jsxs(Popover, { children: [
9323
+ ({ name: d, icon: p, subMenus: u, prompt: g }) => u ? /* @__PURE__ */ jsxs(Popover, { children: [
9318
9324
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
9319
9325
  "li",
9320
9326
  {
9321
9327
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 pl-2 text-sm hover:bg-gray-100 dark:hover:bg-gray-800",
9322
9328
  children: [
9323
9329
  /* @__PURE__ */ jsx(p, { className: "h-4 w-4" }),
9324
- /* @__PURE__ */ jsx("span", { children: u })
9330
+ /* @__PURE__ */ jsx("span", { children: d })
9325
9331
  ]
9326
9332
  },
9327
- u
9333
+ d
9328
9334
  ) }),
9329
9335
  /* @__PURE__ */ jsx(PopoverContent, { side: "right", children: /* @__PURE__ */ jsx("ul", { children: /* @__PURE__ */ jsx("li", { children: r("Happy") }) }) })
9330
9336
  ] }) : /* @__PURE__ */ jsxs(
@@ -9334,28 +9340,28 @@ function QuickPrompts({ onClick: o }) {
9334
9340
  className: "flex cursor-pointer items-center space-x-2 rounded p-1 text-xs hover:bg-primary/10 hover:text-primary dark:hover:bg-gray-800",
9335
9341
  children: [
9336
9342
  /* @__PURE__ */ jsx(p, { className: "h-3.5 w-3.5" }),
9337
- /* @__PURE__ */ jsx("span", { children: r(u) })
9343
+ /* @__PURE__ */ jsx("span", { children: r(d) })
9338
9344
  ]
9339
9345
  },
9340
- u
9346
+ d
9341
9347
  )
9342
9348
  ) }) });
9343
9349
  }
9344
9350
  const AIUserPrompt = ({ blockId: o }) => {
9345
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), u = useRef(null), p = useRef(null), d = useSelectedBlock();
9351
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), u = useSelectedBlock();
9346
9352
  useEffect(() => {
9347
9353
  var m;
9348
- (m = u.current) == null || m.focus();
9354
+ (m = d.current) == null || m.focus();
9349
9355
  }, []);
9350
9356
  const g = () => {
9351
9357
  l || c("");
9352
9358
  };
9353
9359
  return /* @__PURE__ */ jsx("div", { className: "", children: o ? /* @__PURE__ */ jsxs("div", { className: "", children: [
9354
9360
  /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Selected block" }),
9355
- d && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary", children: [
9356
- /* @__PURE__ */ jsx(TypeIcon, { type: d._type }),
9361
+ u && /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-1 rounded border border-primary/20 bg-primary/10 p-1.5 text-xs text-primary", children: [
9362
+ /* @__PURE__ */ jsx(TypeIcon, { type: u._type }),
9357
9363
  " ",
9358
- /* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: d._name || d._type })
9364
+ /* @__PURE__ */ jsx("p", { className: "truncate whitespace-nowrap leading-none", children: u._name || u._type })
9359
9365
  ] }),
9360
9366
  /* @__PURE__ */ jsx("br", {}),
9361
9367
  /* @__PURE__ */ jsx("label", { className: "text-xs font-medium text-gray-500", children: "Quick actions" }),
@@ -9373,7 +9379,7 @@ const AIUserPrompt = ({ blockId: o }) => {
9373
9379
  /* @__PURE__ */ jsx(
9374
9380
  Textarea,
9375
9381
  {
9376
- ref: u,
9382
+ ref: d,
9377
9383
  value: i,
9378
9384
  onChange: (m) => c(m.target.value),
9379
9385
  placeholder: n("Ask AI to edit content"),
@@ -9452,7 +9458,7 @@ const UndoRedo = () => {
9452
9458
  /* @__PURE__ */ jsxs("div", { className: "flex h-full items-center", children: [
9453
9459
  n ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
9454
9460
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { size: "sm", variant: "ghost", className: "h-7 w-7 rounded-md p-1", children: /* @__PURE__ */ jsx(DotsHorizontalIcon, { className: "h-4 w-4" }) }) }),
9455
- /* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56 border-border text-xs", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-2", onSelect: (u) => u.preventDefault(), children: [
9461
+ /* @__PURE__ */ jsx(DropdownMenuContent, { className: "w-56 border-border text-xs", children: /* @__PURE__ */ jsxs(DropdownMenuItem, { className: "flex items-center gap-2", onSelect: (d) => d.preventDefault(), children: [
9456
9462
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "h-4 w-4 text-gray-500" }),
9457
9463
  /* @__PURE__ */ jsx("span", { className: "flex-1", children: l("Data Binding") }),
9458
9464
  /* @__PURE__ */ jsx(Switch, { checked: r, onCheckedChange: () => a(!r) })
@@ -9463,8 +9469,8 @@ const UndoRedo = () => {
9463
9469
  ] });
9464
9470
  }, AddBlocksDialog = () => {
9465
9471
  const { t: o } = useTranslation(), [n, r] = useState(""), [a, l] = useState(-1), [i, c] = useState(!1);
9466
- return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (u) => {
9467
- r(u ? u._id : null), l(isNaN(u == null ? void 0 : u.position) ? -1 : u == null ? void 0 : u.position), c(!0);
9472
+ return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (d) => {
9473
+ r(d ? d._id : null), l(isNaN(d == null ? void 0 : d.position) ? -1 : d == null ? void 0 : d.position), c(!0);
9468
9474
  }), usePubSub(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK, () => {
9469
9475
  r(""), l(-1), c(!1);
9470
9476
  }), /* @__PURE__ */ jsx(AlertDialog, { open: i, onOpenChange: () => i ? c(!1) : "", children: /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-5xl overflow-hidden border-border", children: [
@@ -9485,37 +9491,37 @@ const UndoRedo = () => {
9485
9491
  preloadedAttributes: n = [],
9486
9492
  onAttributesChange: r
9487
9493
  }) {
9488
- const [a, l] = useState([]), [i, c] = useState(""), [u, p] = useState(""), [d, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), b = usePageExternalData(), { t: y } = useTranslation();
9494
+ 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(), { t: y } = useTranslation();
9489
9495
  useEffect(() => {
9490
9496
  l(n);
9491
9497
  }, [n]);
9492
- const C = () => {
9498
+ const S = () => {
9493
9499
  if (i.startsWith("@")) {
9494
9500
  h("Attribute keys cannot start with '@'");
9495
9501
  return;
9496
9502
  }
9497
9503
  if (i) {
9498
- const k = [...a, { key: i, value: u }];
9504
+ const k = [...a, { key: i, value: d }];
9499
9505
  r(k), l(a), c(""), p(""), h("");
9500
9506
  }
9501
- }, S = (k) => {
9502
- const A = a.filter((v, E) => E !== k);
9507
+ }, C = (k) => {
9508
+ const A = a.filter((w, E) => E !== k);
9503
9509
  r(A), l(A);
9504
- }, w = (k) => {
9510
+ }, v = (k) => {
9505
9511
  g(k), c(a[k].key), p(a[k].value);
9506
9512
  }, _ = () => {
9507
9513
  if (i.startsWith("@")) {
9508
9514
  h("Attribute keys cannot start with '@'");
9509
9515
  return;
9510
9516
  }
9511
- if (d !== null && i) {
9517
+ if (u !== null && i) {
9512
9518
  const k = [...a];
9513
- k[d] = { key: i, value: u }, r(k), l(k), g(null), c(""), p(""), h("");
9519
+ k[u] = { key: i, value: d }, r(k), l(k), g(null), c(""), p(""), h("");
9514
9520
  }
9515
9521
  }, B = (k) => {
9516
- k.key === "Enter" && !k.shiftKey && (k.preventDefault(), d !== null ? _() : C());
9522
+ k.key === "Enter" && !k.shiftKey && (k.preventDefault(), u !== null ? _() : S());
9517
9523
  }, I = useCallback((k) => {
9518
- const A = (j) => /[.,!?;:]/.test(j), v = (j, N, T) => {
9524
+ const A = (j) => /[.,!?;:]/.test(j), w = (j, N, T) => {
9519
9525
  let P = "", R = "";
9520
9526
  const D = N > 0 ? j[N - 1] : "", L = N < j.length ? j[N] : "";
9521
9527
  return N > 0 && (D === "." || !A(D) && D !== " ") && (P = " "), N < j.length && !A(L) && L !== " " && (R = " "), {
@@ -9527,11 +9533,11 @@ const UndoRedo = () => {
9527
9533
  if (E) {
9528
9534
  const j = E.selectionStart || 0, N = E.value || "", T = E.selectionEnd || j;
9529
9535
  if (T > j) {
9530
- const O = `{{${k}}}`, { text: F } = v(N, j, O), M = N.slice(0, j) + F + N.slice(T);
9536
+ const O = `{{${k}}}`, { text: F } = w(N, j, O), M = N.slice(0, j) + F + N.slice(T);
9531
9537
  p(M);
9532
9538
  return;
9533
9539
  }
9534
- const R = `{{${k}}}`, { text: D } = v(N, j, R), L = N.slice(0, j) + D + N.slice(j);
9540
+ const R = `{{${k}}}`, { text: D } = w(N, j, R), L = N.slice(0, j) + D + N.slice(j);
9535
9541
  p(L);
9536
9542
  }
9537
9543
  }, []);
@@ -9540,7 +9546,7 @@ const UndoRedo = () => {
9540
9546
  "form",
9541
9547
  {
9542
9548
  onSubmit: (k) => {
9543
- k.preventDefault(), d !== null ? _() : C();
9549
+ k.preventDefault(), u !== null ? _() : S();
9544
9550
  },
9545
9551
  className: "space-y-3",
9546
9552
  children: [
@@ -9576,7 +9582,7 @@ const UndoRedo = () => {
9576
9582
  id: "attrValue",
9577
9583
  rows: 2,
9578
9584
  ref: x,
9579
- value: u,
9585
+ value: d,
9580
9586
  onChange: (k) => p(k.target.value),
9581
9587
  onKeyDown: B,
9582
9588
  placeholder: "Enter Value",
@@ -9585,7 +9591,7 @@ const UndoRedo = () => {
9585
9591
  )
9586
9592
  ] })
9587
9593
  ] }),
9588
- /* @__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: d !== null ? "Save" : "Add" }) }),
9594
+ /* @__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" }) }),
9589
9595
  m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9590
9596
  ]
9591
9597
  }
@@ -9596,22 +9602,22 @@ const UndoRedo = () => {
9596
9602
  /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: k.value.toString() })
9597
9603
  ] }),
9598
9604
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9599
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9600
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9605
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
9606
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
9601
9607
  ] })
9602
9608
  ] }, A)) })
9603
9609
  ] });
9604
9610
  }), BlockAttributesEditor = React.memo(() => {
9605
9611
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
9606
9612
  React.useEffect(() => {
9607
- const u = map(get(o, i), (p, d) => ({ key: d, value: p }));
9608
- isEmpty(u) ? r([]) : r(u);
9613
+ const d = map(get(o, i), (p, u) => ({ key: u, value: p }));
9614
+ isEmpty(d) ? r([]) : r(d);
9609
9615
  }, [get(o, i)]);
9610
9616
  const c = React.useCallback(
9611
- (u = []) => {
9617
+ (d = []) => {
9612
9618
  const p = {};
9613
- forEach(u, (d) => {
9614
- isEmpty(d.key) || set(p, d.key, d.value);
9619
+ forEach(d, (u) => {
9620
+ isEmpty(u.key) || set(p, u.key, u.value);
9615
9621
  }), l([get(o, "_id")], { [i]: p });
9616
9622
  },
9617
9623
  [o, l, i]
@@ -9757,28 +9763,28 @@ registerChaiSidebarPanel("outline", {
9757
9763
  panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
9758
9764
  });
9759
9765
  const RootLayout = () => {
9760
- const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, u] = useRightPanel(), p = useChaiSidebarPanels("top"), d = useChaiSidebarPanels("bottom"), g = reverse([...d ?? []]), m = useCallback((k) => {
9766
+ const o = useTopBarComponent(), [n, r] = useSidebarActivePanel(), a = useRef("outline"), [l, i] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = reverse([...u ?? []]), m = useCallback((k) => {
9761
9767
  k.preventDefault();
9762
9768
  }, []), h = useMemo(() => {
9763
- const k = [p].flat(), A = k.find((E) => E.id === "chai-chat-panel"), v = k.filter((E) => E.id !== "chai-chat-panel");
9764
- return A ? [A, ...v] : k;
9769
+ const k = [p].flat(), A = k.find((E) => E.id === "chai-chat-panel"), w = k.filter((E) => E.id !== "chai-chat-panel");
9770
+ return A ? [A, ...w] : k;
9765
9771
  }, [p]), f = useCallback(
9766
9772
  (k) => {
9767
9773
  console.log("handleMenuItemClick", k, n), r(n === k ? null : k);
9768
9774
  },
9769
9775
  [n, r]
9770
- ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...d], [p, d]), y = useBuilderProp("htmlDir", "ltr"), C = find(b, { id: n }) ?? first(b), S = get(C, "width", DEFAULT_PANEL_WIDTH);
9776
+ ), { t: x } = useTranslation(), b = useMemo(() => [...p, ...u], [p, u]), y = useBuilderProp("htmlDir", "ltr"), S = find(b, { id: n }) ?? first(b), C = get(S, "width", DEFAULT_PANEL_WIDTH);
9771
9777
  useEffect(() => {
9772
9778
  if (n !== null) {
9773
9779
  const k = find(b, { id: n });
9774
9780
  k && get(k, "view", "standard") === "standard" && (a.current = n, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
9775
9781
  }
9776
9782
  }, [n, b]);
9777
- const w = useMemo(() => {
9783
+ const v = useMemo(() => {
9778
9784
  if (n === null) return 0;
9779
9785
  const k = find(b, { id: n });
9780
- return get(k, "view", "standard") === "standard" ? S : l;
9781
- }, [n, S, l, b]), _ = useCallback(() => {
9786
+ return get(k, "view", "standard") === "standard" ? C : l;
9787
+ }, [n, C, l, b]), _ = useCallback(() => {
9782
9788
  r(a.current);
9783
9789
  }, [r, n]), B = useCallback(() => {
9784
9790
  r("outline");
@@ -9827,18 +9833,18 @@ const RootLayout = () => {
9827
9833
  {
9828
9834
  id: "left-panel",
9829
9835
  className: "h-full max-h-full border-r border-border",
9830
- initial: { width: w },
9831
- animate: { width: w },
9836
+ initial: { width: v },
9837
+ animate: { width: v },
9832
9838
  transition: { duration: 0.3, ease: "easeInOut" },
9833
- children: n !== null && get(C, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9839
+ children: n !== null && get(S, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9834
9840
  /* @__PURE__ */ jsx(
9835
9841
  "div",
9836
9842
  {
9837
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(C, "isInternal", !1) ? "" : "w-64"}`,
9838
- children: /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9843
+ className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(S, "isInternal", !1) ? "" : "w-64"}`,
9844
+ children: /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9839
9845
  }
9840
9846
  ),
9841
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {}) }) })
9847
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {}) }) })
9842
9848
  ] })
9843
9849
  }
9844
9850
  ),
@@ -9867,7 +9873,7 @@ const RootLayout = () => {
9867
9873
  /* @__PURE__ */ jsx(
9868
9874
  Button,
9869
9875
  {
9870
- onClick: () => u("block"),
9876
+ onClick: () => d("block"),
9871
9877
  variant: "ghost",
9872
9878
  size: "icon",
9873
9879
  className: "text-xs",
@@ -9884,34 +9890,34 @@ const RootLayout = () => {
9884
9890
  }
9885
9891
  ),
9886
9892
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9887
- n !== null && get(C, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9893
+ n !== null && get(S, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9888
9894
  SheetContent,
9889
9895
  {
9890
9896
  side: "left",
9891
9897
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9892
- style: { width: `${S}px` },
9898
+ style: { width: `${C}px` },
9893
9899
  children: [
9894
9900
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9895
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
9896
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9901
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
9902
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9897
9903
  ] }) }),
9898
- /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9904
+ /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9899
9905
  close: B
9900
9906
  }) }) })
9901
9907
  ]
9902
9908
  }
9903
9909
  ) }),
9904
9910
  " ",
9905
- n !== null && get(C, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${S}px` }, children: [
9911
+ n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${C}px` }, children: [
9906
9912
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9907
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(C, "icon", null) }),
9908
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9913
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
9914
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9909
9915
  ] }) }),
9910
- /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9916
+ /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9911
9917
  close: B
9912
9918
  }) }) })
9913
9919
  ] }) }),
9914
- n !== null && get(C, "view") === "overlay" && /* @__PURE__ */ jsx(
9920
+ n !== null && get(S, "view") === "overlay" && /* @__PURE__ */ jsx(
9915
9921
  motion.div,
9916
9922
  {
9917
9923
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -9930,12 +9936,12 @@ const RootLayout = () => {
9930
9936
  children: [
9931
9937
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9932
9938
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
9933
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(C, "icon", null) }),
9934
- /* @__PURE__ */ jsx("span", { children: x(get(C, "label", "")) })
9939
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(S, "icon", null) }),
9940
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
9935
9941
  ] }),
9936
9942
  /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
9937
9943
  ] }),
9938
- /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(C, "panel", NoopComponent), {
9944
+ /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {
9939
9945
  close: B
9940
9946
  }) }) })
9941
9947
  ]
@@ -9991,30 +9997,30 @@ const RootLayout = () => {
9991
9997
  position: n,
9992
9998
  updatePosition: r
9993
9999
  }) => {
9994
- const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, u] = useState(!1), [p, d] = useState({ x: 0, y: 0 }), g = useMemo(() => {
10000
+ const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9995
10001
  if (!l.trim()) return a;
9996
10002
  const x = l.toLowerCase();
9997
10003
  return Object.fromEntries(
9998
10004
  Object.entries(a).filter(([b, y]) => {
9999
- var C;
10000
- return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((C = y == null ? void 0 : y.description) == null ? void 0 : C.toLowerCase().includes(x));
10005
+ var S;
10006
+ return (b == null ? void 0 : b.toLowerCase().includes(x)) || ((S = y == null ? void 0 : y.description) == null ? void 0 : S.toLowerCase().includes(x));
10001
10007
  })
10002
10008
  );
10003
10009
  }, [a, l]), m = (x) => {
10004
- u(!0), d({
10010
+ d(!0), u({
10005
10011
  x: x.clientX - n.x,
10006
10012
  y: x.clientY - n.y
10007
10013
  });
10008
10014
  }, h = (x) => {
10009
10015
  if (!c) return;
10010
- const b = x.clientX - p.x, y = x.clientY - p.y, C = x.currentTarget, S = C.offsetWidth, w = C.offsetHeight, _ = window.innerWidth - S, B = window.innerHeight - w, I = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, B));
10016
+ const b = x.clientX - p.x, y = x.clientY - p.y, S = x.currentTarget, C = S.offsetWidth, v = S.offsetHeight, _ = window.innerWidth - C, B = window.innerHeight - v, I = Math.max(0, Math.min(b, _)), k = Math.max(0, Math.min(y, B));
10011
10017
  r(I, k);
10012
10018
  }, f = () => {
10013
- u(!1);
10019
+ d(!1);
10014
10020
  };
10015
10021
  return useEffect(() => {
10016
10022
  const x = () => {
10017
- c && u(!1);
10023
+ c && d(!1);
10018
10024
  };
10019
10025
  return window.addEventListener("mouseup", x), () => window.removeEventListener("mouseup", x);
10020
10026
  }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
@@ -10203,7 +10209,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10203
10209
  let i = a.get(n);
10204
10210
  return i || (i = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, a.set(n, i), l == null || l(o, n)), i;
10205
10211
  }, flushCallbacks = (o) => {
10206
- const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], u = n[13], p = [], d = (g) => {
10212
+ const n = getBuildingBlocks(o), r = n[1], a = n[3], l = n[4], i = n[5], c = n[6], d = n[13], p = [], u = (g) => {
10207
10213
  try {
10208
10214
  g();
10209
10215
  } catch (m) {
@@ -10211,30 +10217,30 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10211
10217
  }
10212
10218
  };
10213
10219
  do {
10214
- c.f && d(c.f);
10220
+ c.f && u(c.f);
10215
10221
  const g = /* @__PURE__ */ new Set(), m = g.add.bind(g);
10216
10222
  a.forEach((h) => {
10217
10223
  var f;
10218
10224
  return (f = r.get(h)) == null ? void 0 : f.l.forEach(m);
10219
- }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(d), a.size && u(o);
10225
+ }), a.clear(), i.forEach(m), i.clear(), l.forEach(m), l.clear(), g.forEach(u), a.size && d(o);
10220
10226
  } while (a.size || i.size || l.size);
10221
10227
  if (p.length)
10222
10228
  throw new AggregateError(p);
10223
10229
  }, recomputeInvalidatedAtoms = (o) => {
10224
- const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], u = n[17], p = [], d = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
10230
+ const n = getBuildingBlocks(o), r = n[1], a = n[2], l = n[3], i = n[11], c = n[14], d = n[17], p = [], u = /* @__PURE__ */ new WeakSet(), g = /* @__PURE__ */ new WeakSet(), m = Array.from(l);
10225
10231
  for (; m.length; ) {
10226
10232
  const h = m[m.length - 1], f = i(o, h);
10227
10233
  if (g.has(h)) {
10228
10234
  m.pop();
10229
10235
  continue;
10230
10236
  }
10231
- if (d.has(h)) {
10237
+ if (u.has(h)) {
10232
10238
  a.get(h) === f.n && p.push([h, f]), g.add(h), m.pop();
10233
10239
  continue;
10234
10240
  }
10235
- d.add(h);
10241
+ u.add(h);
10236
10242
  for (const x of getMountedOrPendingDependents(h, f, r))
10237
- d.has(x) || m.push(x);
10243
+ u.has(x) || m.push(x);
10238
10244
  }
10239
10245
  for (let h = p.length - 1; h >= 0; --h) {
10240
10246
  const [f, x] = p[h];
@@ -10244,11 +10250,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10244
10250
  b = !0;
10245
10251
  break;
10246
10252
  }
10247
- b && (c(o, f), u(o, f)), a.delete(f);
10253
+ b && (c(o, f), d(o, f)), a.delete(f);
10248
10254
  }
10249
10255
  }, readAtomState = (o, n) => {
10250
10256
  var r;
10251
- const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], u = a[6], p = a[7], d = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], b = d(o, n);
10257
+ const a = getBuildingBlocks(o), l = a[1], i = a[2], c = a[3], d = a[6], p = a[7], u = a[11], g = a[12], m = a[13], h = a[14], f = a[16], x = a[17], b = u(o, n);
10252
10258
  if (isAtomStateInitialized(b) && (l.has(n) && i.get(n) !== b.n || Array.from(b.d).every(
10253
10259
  ([k, A]) => (
10254
10260
  // Recursively, read the atom state of the dependency, and
@@ -10259,13 +10265,13 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10259
10265
  return b;
10260
10266
  b.d.clear();
10261
10267
  let y = !0;
10262
- function C() {
10268
+ function S() {
10263
10269
  l.has(n) && (x(o, n), m(o), g(o));
10264
10270
  }
10265
- function S(k) {
10271
+ function C(k) {
10266
10272
  var A;
10267
10273
  if (isSelfAtom(n, k)) {
10268
- const E = d(o, k);
10274
+ const E = u(o, k);
10269
10275
  if (!isAtomStateInitialized(E))
10270
10276
  if (hasInitialValue(k))
10271
10277
  setAtomStateValueOrPromise(o, k, k.init);
@@ -10273,17 +10279,17 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10273
10279
  throw new Error("no atom init");
10274
10280
  return returnAtomValue(E);
10275
10281
  }
10276
- const v = h(o, k);
10282
+ const w = h(o, k);
10277
10283
  try {
10278
- return returnAtomValue(v);
10284
+ return returnAtomValue(w);
10279
10285
  } finally {
10280
- b.d.set(k, v.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, v), (A = l.get(k)) == null || A.t.add(n), y || C();
10286
+ b.d.set(k, w.n), isPendingPromise(b.v) && addPendingPromiseToDependency(n, b.v, w), (A = l.get(k)) == null || A.t.add(n), y || S();
10281
10287
  }
10282
10288
  }
10283
- let w, _;
10289
+ let v, _;
10284
10290
  const B = {
10285
10291
  get signal() {
10286
- return w || (w = new AbortController()), w.signal;
10292
+ return v || (v = new AbortController()), v.signal;
10287
10293
  },
10288
10294
  get setSelf() {
10289
10295
  return !_ && isActuallyWritableAtom(n) && (_ = (...k) => {
@@ -10297,39 +10303,39 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10297
10303
  }
10298
10304
  }, I = b.n;
10299
10305
  try {
10300
- const k = p(o, n, S, B);
10301
- return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => w == null ? void 0 : w.abort()), k.then(C, C)), b;
10306
+ const k = p(o, n, C, B);
10307
+ return setAtomStateValueOrPromise(o, n, k), isPromiseLike$1(k) && (registerAbortHandler(k, () => v == null ? void 0 : v.abort()), k.then(S, S)), b;
10302
10308
  } catch (k) {
10303
10309
  return delete b.v, b.e = k, ++b.n, b;
10304
10310
  } finally {
10305
- y = !1, I !== b.n && i.get(n) === I && (i.set(n, b.n), c.add(n), (r = u.c) == null || r.call(u, n));
10311
+ y = !1, I !== b.n && i.get(n) === I && (i.set(n, b.n), c.add(n), (r = d.c) == null || r.call(d, n));
10306
10312
  }
10307
10313
  }, invalidateDependents = (o, n) => {
10308
10314
  const r = getBuildingBlocks(o), a = r[1], l = r[2], i = r[11], c = [n];
10309
10315
  for (; c.length; ) {
10310
- const u = c.pop(), p = i(o, u);
10311
- for (const d of getMountedOrPendingDependents(u, p, a)) {
10312
- const g = i(o, d);
10313
- l.set(d, g.n), c.push(d);
10316
+ const d = c.pop(), p = i(o, d);
10317
+ for (const u of getMountedOrPendingDependents(d, p, a)) {
10318
+ const g = i(o, u);
10319
+ l.set(u, g.n), c.push(u);
10314
10320
  }
10315
10321
  }
10316
10322
  }, writeAtomState = (o, n, ...r) => {
10317
- const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], u = a[11], p = a[12], d = a[13], g = a[14], m = a[15], h = a[17];
10323
+ const a = getBuildingBlocks(o), l = a[3], i = a[6], c = a[8], d = a[11], p = a[12], u = a[13], g = a[14], m = a[15], h = a[17];
10318
10324
  let f = !0;
10319
- const x = (y) => returnAtomValue(g(o, y)), b = (y, ...C) => {
10320
- var S;
10321
- const w = u(o, y);
10325
+ const x = (y) => returnAtomValue(g(o, y)), b = (y, ...S) => {
10326
+ var C;
10327
+ const v = d(o, y);
10322
10328
  try {
10323
10329
  if (isSelfAtom(n, y)) {
10324
10330
  if (!hasInitialValue(y))
10325
10331
  throw new Error("atom not writable");
10326
- const _ = w.n, B = C[0];
10327
- setAtomStateValueOrPromise(o, y, B), h(o, y), _ !== w.n && (l.add(y), (S = i.c) == null || S.call(i, y), m(o, y));
10332
+ const _ = v.n, B = S[0];
10333
+ setAtomStateValueOrPromise(o, y, B), h(o, y), _ !== v.n && (l.add(y), (C = i.c) == null || C.call(i, y), m(o, y));
10328
10334
  return;
10329
10335
  } else
10330
- return writeAtomState(o, y, ...C);
10336
+ return writeAtomState(o, y, ...S);
10331
10337
  } finally {
10332
- f || (d(o), p(o));
10338
+ f || (u(o), p(o));
10333
10339
  }
10334
10340
  };
10335
10341
  try {
@@ -10339,12 +10345,12 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10339
10345
  }
10340
10346
  }, mountDependencies = (o, n) => {
10341
10347
  var r;
10342
- const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], u = a[11], p = a[15], d = a[18], g = a[19], m = u(o, n), h = l.get(n);
10348
+ const a = getBuildingBlocks(o), l = a[1], i = a[3], c = a[6], d = a[11], p = a[15], u = a[18], g = a[19], m = d(o, n), h = l.get(n);
10343
10349
  if (h && !isPendingPromise(m.v)) {
10344
10350
  for (const [f, x] of m.d)
10345
10351
  if (!h.d.has(f)) {
10346
- const b = u(o, f);
10347
- d(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
10352
+ const b = d(o, f);
10353
+ u(o, f).t.add(n), h.d.add(f), x !== b.n && (i.add(f), (r = c.c) == null || r.call(c, f), p(o, f));
10348
10354
  }
10349
10355
  for (const f of h.d || [])
10350
10356
  if (!m.d.has(f)) {
@@ -10355,7 +10361,7 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10355
10361
  }
10356
10362
  }, mountAtom = (o, n) => {
10357
10363
  var r;
10358
- const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], u = a[10], p = a[11], d = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
10364
+ const a = getBuildingBlocks(o), l = a[1], i = a[4], c = a[6], d = a[10], p = a[11], u = a[12], g = a[13], m = a[14], h = a[16], f = p(o, n);
10359
10365
  let x = l.get(n);
10360
10366
  if (!x) {
10361
10367
  m(o, n);
@@ -10368,19 +10374,19 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10368
10374
  }, l.set(n, x), (r = c.m) == null || r.call(c, n), isActuallyWritableAtom(n)) {
10369
10375
  const b = () => {
10370
10376
  let y = !0;
10371
- const C = (...S) => {
10377
+ const S = (...C) => {
10372
10378
  try {
10373
- return h(o, n, ...S);
10379
+ return h(o, n, ...C);
10374
10380
  } finally {
10375
- y || (g(o), d(o));
10381
+ y || (g(o), u(o));
10376
10382
  }
10377
10383
  };
10378
10384
  try {
10379
- const S = u(o, n, C);
10380
- S && (x.u = () => {
10385
+ const C = d(o, n, S);
10386
+ C && (x.u = () => {
10381
10387
  y = !0;
10382
10388
  try {
10383
- S();
10389
+ C();
10384
10390
  } finally {
10385
10391
  y = !1;
10386
10392
  }
@@ -10395,14 +10401,14 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10395
10401
  return x;
10396
10402
  }, unmountAtom = (o, n) => {
10397
10403
  var r;
10398
- const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], u = a[11], p = a[19], d = u(o, n);
10404
+ const a = getBuildingBlocks(o), l = a[1], i = a[5], c = a[6], d = a[11], p = a[19], u = d(o, n);
10399
10405
  let g = l.get(n);
10400
10406
  if (g && !g.l.size && !Array.from(g.t).some((m) => {
10401
10407
  var h;
10402
10408
  return (h = l.get(m)) == null ? void 0 : h.d.has(n);
10403
10409
  })) {
10404
10410
  g.u && i.add(g.u), g = void 0, l.delete(n), (r = c.u) == null || r.call(c, n);
10405
- for (const m of d.d.keys()) {
10411
+ for (const m of u.d.keys()) {
10406
10412
  const h = p(o, m);
10407
10413
  h == null || h.t.delete(n);
10408
10414
  }
@@ -10412,11 +10418,11 @@ const atomRead = (o, n, ...r) => n.read(...r), atomWrite = (o, n, ...r) => n.wri
10412
10418
  }, setAtomStateValueOrPromise = (o, n, r) => {
10413
10419
  const a = getBuildingBlocks(o)[11], l = a(o, n), i = "v" in l, c = l.v;
10414
10420
  if (isPromiseLike$1(r))
10415
- for (const u of l.d.keys())
10421
+ for (const d of l.d.keys())
10416
10422
  addPendingPromiseToDependency(
10417
10423
  n,
10418
10424
  r,
10419
- a(o, u)
10425
+ a(o, d)
10420
10426
  );
10421
10427
  l.v = r, delete l.e, (!i || !Object.is(c, l.v)) && (++l.n, isPromiseLike$1(c) && abortPromise(c));
10422
10428
  }, storeGet = (o, n) => {
@@ -10523,23 +10529,23 @@ const isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function",
10523
10529
  let r = continuablePromiseMap.get(o);
10524
10530
  return r || (r = new Promise((a, l) => {
10525
10531
  let i = o;
10526
- const c = (d) => (g) => {
10527
- i === d && a(g);
10528
- }, u = (d) => (g) => {
10529
- i === d && l(g);
10532
+ const c = (u) => (g) => {
10533
+ i === u && a(g);
10534
+ }, d = (u) => (g) => {
10535
+ i === u && l(g);
10530
10536
  }, p = () => {
10531
10537
  try {
10532
- const d = n();
10533
- isPromiseLike(d) ? (continuablePromiseMap.set(d, r), i = d, d.then(c(d), u(d)), registerAbortHandler(d, p)) : a(d);
10534
- } catch (d) {
10535
- l(d);
10538
+ const u = n();
10539
+ isPromiseLike(u) ? (continuablePromiseMap.set(u, r), i = u, u.then(c(u), d(u)), registerAbortHandler(u, p)) : a(u);
10540
+ } catch (u) {
10541
+ l(u);
10536
10542
  }
10537
10543
  };
10538
- o.then(c(o), u(o)), registerAbortHandler(o, p);
10544
+ o.then(c(o), d(o)), registerAbortHandler(o, p);
10539
10545
  }), continuablePromiseMap.set(o, r)), r;
10540
10546
  };
10541
10547
  function useAtomValue(o, n) {
10542
- const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, u], p] = useReducer(
10548
+ const { delay: r, unstable_promiseStatus: a = !React__default.use } = {}, l = useStore(), [[i, c, d], p] = useReducer(
10543
10549
  (g) => {
10544
10550
  const m = l.get(o);
10545
10551
  return Object.is(g[0], m) && g[1] === l && g[2] === o ? g : [m, l, o];
@@ -10547,8 +10553,8 @@ function useAtomValue(o, n) {
10547
10553
  void 0,
10548
10554
  () => [l.get(o), l, o]
10549
10555
  );
10550
- let d = i;
10551
- if ((c !== l || u !== o) && (p(), d = l.get(o)), useEffect(() => {
10556
+ let u = i;
10557
+ if ((c !== l || d !== o) && (p(), u = l.get(o)), useEffect(() => {
10552
10558
  const g = l.sub(o, () => {
10553
10559
  if (a)
10554
10560
  try {
@@ -10565,11 +10571,11 @@ function useAtomValue(o, n) {
10565
10571
  p();
10566
10572
  });
10567
10573
  return p(), g;
10568
- }, [l, o, r, a]), useDebugValue(d), isPromiseLike(d)) {
10569
- const g = createContinuablePromise(d, () => l.get(o));
10574
+ }, [l, o, r, a]), useDebugValue(u), isPromiseLike(u)) {
10575
+ const g = createContinuablePromise(u, () => l.get(o));
10570
10576
  return a && attachPromiseStatus(g), use(g);
10571
10577
  }
10572
- return d;
10578
+ return u;
10573
10579
  }
10574
10580
  function useSetAtom(o, n) {
10575
10581
  const r = useStore();
@@ -10586,10 +10592,10 @@ function useAtom(o, n) {
10586
10592
  ];
10587
10593
  }
10588
10594
  function domToJsx(o, n = 0) {
10589
- var d;
10595
+ var u;
10590
10596
  const r = " ".repeat(n);
10591
10597
  if (o.nodeType === Node.TEXT_NODE) {
10592
- const g = (d = o.textContent) == null ? void 0 : d.trim();
10598
+ const g = (u = o.textContent) == null ? void 0 : u.trim();
10593
10599
  return g ? `${r}${g}
10594
10600
  ` : "";
10595
10601
  }
@@ -10623,10 +10629,10 @@ function domToJsx(o, n = 0) {
10623
10629
  } else if (h.name === "style" && h.value) {
10624
10630
  const f = h.value.split(";").reduce(
10625
10631
  (x, b) => {
10626
- const [y, C] = b.split(":").map((S) => S.trim());
10627
- if (y && C) {
10628
- const S = y.replace(/-([a-z])/g, (w) => w[1].toUpperCase());
10629
- x[S] = C.replace(/['"]/g, "");
10632
+ const [y, S] = b.split(":").map((C) => C.trim());
10633
+ if (y && S) {
10634
+ const C = y.replace(/-([a-z])/g, (v) => v[1].toUpperCase());
10635
+ x[C] = S.replace(/['"]/g, "");
10630
10636
  }
10631
10637
  return x;
10632
10638
  },
@@ -10654,7 +10660,7 @@ function domToJsx(o, n = 0) {
10654
10660
  (h, f) => {
10655
10661
  const [x, b] = f.split(":").map((y) => y.trim());
10656
10662
  if (x && b) {
10657
- const y = x.replace(/-([a-z])/g, (C) => C[1].toUpperCase());
10663
+ const y = x.replace(/-([a-z])/g, (S) => S[1].toUpperCase());
10658
10664
  h[y] = b.replace(/['"]/g, "");
10659
10665
  }
10660
10666
  return h;
@@ -10665,8 +10671,8 @@ function domToJsx(o, n = 0) {
10665
10671
  } else
10666
10672
  c.push(`${g.name}="${g.value}"`);
10667
10673
  c.length > 0 && (i += " " + c.join(" "));
10668
- const u = Array.from(o.childNodes);
10669
- if (!u.some((g) => {
10674
+ const d = Array.from(o.childNodes);
10675
+ if (!d.some((g) => {
10670
10676
  var m;
10671
10677
  return g.nodeType === Node.TEXT_NODE ? (m = g.textContent) == null ? void 0 : m.trim() : !0;
10672
10678
  }))
@@ -10675,7 +10681,7 @@ function domToJsx(o, n = 0) {
10675
10681
  else {
10676
10682
  i += `>
10677
10683
  `;
10678
- for (const g of u)
10684
+ for (const g of d)
10679
10685
  i += domToJsx(g, n + 1);
10680
10686
  i += `${r}</${a}>
10681
10687
  `;
@@ -10710,7 +10716,7 @@ const getExportedCoded = async ({
10710
10716
  isTypeScript: r = !1
10711
10717
  }) => {
10712
10718
  let a = (o == null ? void 0 : o._name) || (o == null ? void 0 : o._type) || "Component";
10713
- a = camelCase(a).replace(/^./, (d) => d.toUpperCase());
10719
+ a = camelCase(a).replace(/^./, (u) => u.toUpperCase());
10714
10720
  const l = " ";
10715
10721
  let { jsx: i, html: c } = await convertHtmlToJsx(n);
10716
10722
  return i = i == null ? void 0 : i.split(`
@@ -10723,8 +10729,8 @@ ${l}${l}${i == null ? void 0 : i.trimEnd()}
10723
10729
  ${l})
10724
10730
  }`, { jsx: i, html: formatHtml(c), componentName: a };
10725
10731
  }, ExportCodeModalContent = ({ tab: o }) => {
10726
- var C;
10727
- const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c, u] = useState(""), [p, d] = useState(!1), g = () => {
10732
+ var S;
10733
+ const { t: n } = useTranslation(), [r, a] = useState({ html: "", jsx: "" }), l = useSelectedBlock(), i = useBlocksHtmlForAi(), [c, d] = useState(""), [p, u] = useState(!1), g = () => {
10728
10734
  switch (o) {
10729
10735
  case "js":
10730
10736
  return `${c}.jsx`;
@@ -10747,51 +10753,51 @@ ${l})
10747
10753
  }
10748
10754
  }, h = useCallback(async () => {
10749
10755
  try {
10750
- d(!1), await new Promise((k) => setTimeout(k, 1e3));
10751
- const S = i({ EXTRA_CORE_BLOCKS: ["Icon"] }), w = o === "ts", {
10756
+ u(!1), await new Promise((k) => setTimeout(k, 1e3));
10757
+ const C = i({ EXTRA_CORE_BLOCKS: ["Icon"] }), v = o === "ts", {
10752
10758
  jsx: _,
10753
10759
  html: B,
10754
10760
  componentName: I
10755
10761
  } = await getExportedCoded({
10756
10762
  selectedBlock: l,
10757
- html: S,
10758
- isTypeScript: w
10763
+ html: C,
10764
+ isTypeScript: v
10759
10765
  });
10760
- a({ html: B, jsx: _ }), u(I), d(!0);
10766
+ a({ html: B, jsx: _ }), d(I), u(!0);
10761
10767
  } catch {
10762
- const w = "<div>Export failed. Close the modal and try again.</div>";
10763
- a({ html: w, jsx: w }), toast.error(n("Failed to generate export HTML"));
10768
+ const v = "<div>Export failed. Close the modal and try again.</div>";
10769
+ a({ html: v, jsx: v }), toast.error(n("Failed to generate export HTML"));
10764
10770
  }
10765
10771
  }, [n, o, l, i]);
10766
10772
  useEffect(() => {
10767
10773
  h();
10768
10774
  }, [h, o]);
10769
10775
  const f = useCallback(
10770
- async (S) => {
10776
+ async (C) => {
10771
10777
  try {
10772
- navigator.clipboard.writeText(S), toast.success(n("Export code copied!"));
10778
+ navigator.clipboard.writeText(C), toast.success(n("Export code copied!"));
10773
10779
  } catch {
10774
10780
  toast.error(n("Failed to copy export code"));
10775
10781
  }
10776
10782
  },
10777
10783
  [n]
10778
- ), x = (S) => {
10779
- const w = new Blob([S], { type: "text/jsx" }), _ = URL.createObjectURL(w), B = document.createElement("a");
10784
+ ), x = (C) => {
10785
+ const v = new Blob([C], { type: "text/jsx" }), _ = URL.createObjectURL(v), B = document.createElement("a");
10780
10786
  B.href = _, B.download = g(), document.body.appendChild(B), B.click(), URL.revokeObjectURL(_), document.body.removeChild(B), toast.success(n("Export code downloaded successfully!"));
10781
10787
  }, b = /* @__PURE__ */ jsxs("span", { children: [
10782
10788
  "Download ",
10783
10789
  /* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-light text-gray-300", children: g() })
10784
10790
  ] }), y = useMemo(() => {
10785
- const S = { extend: shadcnTheme() }, w = JSON.stringify(S, null, 2);
10791
+ const C = { extend: shadcnTheme() }, v = JSON.stringify(C, null, 2);
10786
10792
  return `{
10787
10793
  // Your tailwind config ...
10788
10794
 
10789
- "theme": ${w == null ? void 0 : w.split(`
10795
+ "theme": ${v == null ? void 0 : v.split(`
10790
10796
  `).join(`
10791
10797
  `)},
10792
10798
  }`;
10793
10799
  }, []);
10794
- return ((C = r == null ? void 0 : r.jsx) == null ? void 0 : C.length) > 0 && p ? /* @__PURE__ */ jsx(
10800
+ return ((S = r == null ? void 0 : r.jsx) == null ? void 0 : S.length) > 0 && p ? /* @__PURE__ */ jsx(
10795
10801
  CodeDisplay,
10796
10802
  {
10797
10803
  onCopy: f,
@@ -10857,8 +10863,8 @@ ${l})
10857
10863
  }, [o.locale]), useEffect(() => {
10858
10864
  setDebugLogs(o.debugLogs);
10859
10865
  }, [o.debugLogs]), useEffect(() => {
10860
- o.translations && each(o.translations, (c, u) => {
10861
- i18n.addResourceBundle(u, "translation", c, !0, !0);
10866
+ o.translations && each(o.translations, (c, d) => {
10867
+ i18n.addResourceBundle(d, "translation", c, !0, !0);
10862
10868
  });
10863
10869
  }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
10864
10870
  window.onbeforeunload = null;