@chaibuilder/sdk 2.2.8 → 2.2.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.
package/dist/core.js CHANGED
@@ -310,12 +310,12 @@ class PubSub {
310
310
  }
311
311
  }
312
312
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
313
- const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(a, (f) => d ? get(f, "_parent") === d : !get(f, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(c, { _id: i }), g = (f) => {
314
- if (f === "CHILD")
313
+ const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(a, (h) => d ? get(h, "_parent") === d : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(c, { _id: i }), g = (h) => {
314
+ if (h === "CHILD")
315
315
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
316
316
  else {
317
317
  const m = { _id: d || "", position: c == null ? void 0 : c.length };
318
- f === "BEFORE" ? m.position = Math.max(u, 0) : f === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
318
+ h === "BEFORE" ? m.position = Math.max(u, 0) : h === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
319
319
  }
320
320
  };
321
321
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
@@ -349,23 +349,23 @@ function insertBlocksAtPosition(o, r, n, a) {
349
349
  let i = [...o];
350
350
  if (n) {
351
351
  const u = o.find((g) => g._id === n);
352
- if (u && u.content !== void 0 && u.content !== "" && !o.some((f) => f._parent === n)) {
352
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === n)) {
353
353
  const m = {
354
354
  _id: generateUUID(),
355
355
  _parent: n,
356
356
  _type: "Text",
357
357
  content: u.content
358
358
  };
359
- Object.keys(u).forEach((h) => {
360
- h.startsWith("content-") && (m[h] = u[h]);
361
- }), l.unshift(m), i = i.map((h) => {
362
- if (h._id === n) {
363
- const x = { ...h, content: "" };
359
+ Object.keys(u).forEach((f) => {
360
+ f.startsWith("content-") && (m[f] = u[f]);
361
+ }), l.unshift(m), i = i.map((f) => {
362
+ if (f._id === n) {
363
+ const x = { ...f, content: "" };
364
364
  return Object.keys(x).forEach((y) => {
365
365
  y.startsWith("content-") && (x[y] = "");
366
366
  }), x;
367
367
  }
368
- return h;
368
+ return f;
369
369
  });
370
370
  }
371
371
  }
@@ -398,13 +398,13 @@ function moveNode(o, r, n, a) {
398
398
  const l = findNodeById(o, r), i = findNodeById(o, n);
399
399
  if (!l || !i) return !1;
400
400
  i.children || (i.model.children = []);
401
- let d = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((f) => f.model._id === r);
401
+ let d = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === r);
402
402
  l.drop(), d = Math.max(d, 0);
403
403
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === n && d <= a ? a - 1 : a;
404
404
  try {
405
405
  i.addChildAtIndex(l, p);
406
- } catch (f) {
407
- return console.error("Error adding child to parent:", f), !1;
406
+ } catch (h) {
407
+ return console.error("Error adding child to parent:", h), !1;
408
408
  }
409
409
  return !0;
410
410
  }
@@ -445,8 +445,8 @@ function handleNewParentTextBlock(o, r, n) {
445
445
  const c = o.map((u) => {
446
446
  if (u._id === n) {
447
447
  const g = { ...u, content: "" };
448
- return Object.keys(g).forEach((f) => {
449
- f.startsWith("content-") && (g[f] = "");
448
+ return Object.keys(g).forEach((h) => {
449
+ h.startsWith("content-") && (g[h] = "");
450
450
  }), g;
451
451
  }
452
452
  return u;
@@ -463,7 +463,7 @@ function moveBlocksWithChildren(o, r, n, a) {
463
463
  const d = n || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
464
464
  if (moveNode(p, r, d, a)) {
465
465
  let u = flattenTree(p);
466
- const g = u.find((f) => f._id === r);
466
+ const g = u.find((h) => h._id === r);
467
467
  return g && (g._parent = d === "root" ? null : d), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
468
468
  }
469
469
  return i;
@@ -487,22 +487,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
487
487
  }, removeNestedBlocks = (o, r) => {
488
488
  let n = [...o], a = [];
489
489
  r.forEach((c) => {
490
- const p = n.find((f) => f._id === c);
490
+ const p = n.find((h) => h._id === c);
491
491
  if (!p || !p._parent) return;
492
- const u = p._parent, g = n.filter((f) => f._parent === u);
492
+ const u = p._parent, g = n.filter((h) => h._parent === u);
493
493
  if (g.length === 2) {
494
- const f = g.find((m) => m._id !== c);
495
- if (f && f._type === "Text") {
496
- const m = n.find((h) => h._id === u);
497
- m && "content" in m && (n = n.map((h) => {
498
- if (h._id === u) {
499
- const x = { ...h, content: f.content };
500
- return Object.keys(f).forEach((y) => {
501
- y.startsWith("content-") && (x[y] = f[y]);
494
+ const h = g.find((m) => m._id !== c);
495
+ if (h && h._type === "Text") {
496
+ const m = n.find((f) => f._id === u);
497
+ m && "content" in m && (n = n.map((f) => {
498
+ if (f._id === u) {
499
+ const x = { ...f, content: h.content };
500
+ return Object.keys(h).forEach((y) => {
501
+ y.startsWith("content-") && (x[y] = h[y]);
502
502
  }), x;
503
503
  }
504
- return h;
505
- }), a.push(f._id));
504
+ return f;
505
+ }), a.push(h._id));
506
506
  }
507
507
  }
508
508
  });
@@ -824,12 +824,12 @@ const useUndoManager = () => {
824
824
  const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
825
825
  (i, d, c) => {
826
826
  var m;
827
- for (let h = 0; h < i.length; h++) {
828
- const { _id: x } = i[h];
829
- i[h]._id = generateUUID();
827
+ for (let f = 0; f < i.length; f++) {
828
+ const { _id: x } = i[f];
829
+ i[f]._id = generateUUID();
830
830
  const y = filter(i, { _parent: x });
831
831
  for (let b = 0; b < y.length; b++)
832
- y[b]._parent = i[h]._id;
832
+ y[b]._parent = i[f]._id;
833
833
  }
834
834
  const p = first(i);
835
835
  let u, g;
@@ -850,8 +850,8 @@ const useUndoManager = () => {
850
850
  ...has(i, "_name") && { _name: i._name },
851
851
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
852
852
  };
853
- let f, m;
854
- return d && (f = find(o, { _id: d }), g._parent = d, m = d), !canAcceptChildBlock(f == null ? void 0 : f._type, g._type) && f && (g._parent = f._parent, m = f._parent), n([g], m, c), r([g._id]), g;
853
+ let h, m;
854
+ return d && (h = find(o, { _id: d }), g._parent = d, m = d), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), n([g], m, c), r([g._id]), g;
855
855
  },
856
856
  [n, a, o, r]
857
857
  ), addPredefinedBlock: a };
@@ -2297,8 +2297,8 @@ const getBlockWithChildren = (o, r) => {
2297
2297
  return isEmpty(d) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...d });
2298
2298
  })
2299
2299
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2300
- const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, f = (m, h) => {
2301
- const x = cloneDeep(h.find((y) => y._id === m));
2300
+ const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), d = useUpdateMultipleBlocksProps(), [c] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, f) => {
2301
+ const x = cloneDeep(f.find((y) => y._id === m));
2302
2302
  for (const y in x) {
2303
2303
  const b = x[y];
2304
2304
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
@@ -2311,11 +2311,11 @@ const getBlockWithChildren = (o, r) => {
2311
2311
  };
2312
2312
  return {
2313
2313
  askAi: useCallback(
2314
- async (m, h, x, y) => {
2314
+ async (m, f, x, y) => {
2315
2315
  if (l) {
2316
2316
  r(!0), a(null);
2317
2317
  try {
2318
- const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, c)), p) : [f(h, c)], w = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: A, error: E } = w;
2318
+ const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, c)), p) : [h(f, c)], w = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: A, error: E } = w;
2319
2319
  if (E) {
2320
2320
  a(E);
2321
2321
  return;
@@ -2422,16 +2422,16 @@ const getBlockWithChildren = (o, r) => {
2422
2422
  n(c), a([]);
2423
2423
  const u = {
2424
2424
  _chai_copied_blocks: c.flatMap((g) => {
2425
- const f = getDuplicatedBlocks(o, g, null);
2425
+ const h = getDuplicatedBlocks(o, g, null);
2426
2426
  if (!p)
2427
- return f;
2427
+ return h;
2428
2428
  let m = [];
2429
- for (const h of f)
2430
- if (h._type === "PartialBlock" || h._type === "GlobalBlock") {
2431
- const x = l(h.partialBlockId);
2432
- set(x, "0._parent", h._parent), m = [...m, ...x];
2429
+ for (const f of h)
2430
+ if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2431
+ const x = l(f.partialBlockId);
2432
+ set(x, "0._parent", f._parent), m = [...m, ...x];
2433
2433
  } else
2434
- m.push(h);
2434
+ m.push(f);
2435
2435
  return m;
2436
2436
  })
2437
2437
  };
@@ -2475,8 +2475,8 @@ const getBlockWithChildren = (o, r) => {
2475
2475
  const g = filter(
2476
2476
  o,
2477
2477
  (m) => isString(l) ? m._parent === l : !m._parent
2478
- ).indexOf(c) + 1, f = getDuplicatedBlocks(o, d, l);
2479
- n(f, l, g), i.push(get(f, "0._id", ""));
2478
+ ).indexOf(c) + 1, h = getDuplicatedBlocks(o, d, l);
2479
+ n(h, l, g), i.push(get(h, "0._id", ""));
2480
2480
  }), r(i);
2481
2481
  },
2482
2482
  [o, r]
@@ -2613,14 +2613,14 @@ const getBlockWithChildren = (o, r) => {
2613
2613
  return map(i, (d) => {
2614
2614
  const c = o(d), p = a;
2615
2615
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(c, l.prop, `${STYLES_KEY},`));
2616
- return each(p, (f) => {
2617
- const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2618
- u = u.replace(h, " ").replace(/\s+/g, " ").trim();
2619
- const x = first(f.split(":"));
2620
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(f.split(":").pop().trim());
2621
- }), each(p, (f) => {
2622
- const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2623
- g = g.replace(h, " ").replace(/\s+/g, " ").trim();
2616
+ return each(p, (h) => {
2617
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2618
+ u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2619
+ const x = first(h.split(":"));
2620
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
2621
+ }), each(p, (h) => {
2622
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2623
+ g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2624
2624
  }), {
2625
2625
  ids: [c._id],
2626
2626
  props: {
@@ -2723,21 +2723,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2723
2723
  return "VERTICAL";
2724
2724
  }
2725
2725
  }, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
2726
- const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(n, (x) => d ? get(x, "_parent") === d : !get(x, "_parent")), p = (c == null ? void 0 : c.length) <= 1, u = findIndex(c, { _id: i }), g = u <= 0, f = u + 1 === (c == null ? void 0 : c.length), m = getParentBlockOrientation(d, i, a), h = useCallback(
2726
+ const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), d = get(o, "_parent"), c = filter(n, (x) => d ? get(x, "_parent") === d : !get(x, "_parent")), p = (c == null ? void 0 : c.length) <= 1, u = findIndex(c, { _id: i }), g = u <= 0, h = u + 1 === (c == null ? void 0 : c.length), m = getParentBlockOrientation(d, i, a), f = useCallback(
2727
2727
  (x) => {
2728
- isDisabledControl(g, f, x) || p || (x === "UP" || x === "LEFT" ? l([i], d || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], d || null, u + 2), r());
2728
+ isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], d || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], d || null, u + 2), r());
2729
2729
  },
2730
- [g, f, p, u, i, d, r]
2730
+ [g, h, p, u, i, d, r]
2731
2731
  );
2732
2732
  return useHotkeys(
2733
2733
  "shift+up, shift+down, shift+left, shift+right",
2734
2734
  ({ key: x }) => {
2735
2735
  var y;
2736
- h((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2736
+ f((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2737
2737
  },
2738
2738
  { document: a == null ? void 0 : a.contentDocument },
2739
- [h]
2740
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: f, moveBlock: h, orientation: m };
2739
+ [f]
2740
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
2741
2741
  }, BlockController = ({ block: o, updateFloatingBar: r }) => {
2742
2742
  const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: d } = useBlockController(
2743
2743
  o,
@@ -2774,7 +2774,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2774
2774
  }
2775
2775
  );
2776
2776
  }, BlockFloatingSelector = ({ selectedBlockElement: o, block: r }) => {
2777
- const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: c } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: f, update: m } = useFloating({
2777
+ const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, d] = useSelectedStylingBlocks(), { hasPermission: c } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
2778
2778
  placement: "top-start",
2779
2779
  middleware: [shift(), flip()],
2780
2780
  elements: {
@@ -2782,13 +2782,13 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2782
2782
  }
2783
2783
  });
2784
2784
  useResizeObserver(o, () => m(), o !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
2785
- const h = get(r, "_parent", null), x = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
2785
+ const f = get(r, "_parent", null), x = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
2786
2786
  return !o || !r || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
2787
2787
  "div",
2788
2788
  {
2789
2789
  role: "button",
2790
2790
  tabIndex: 0,
2791
- ref: f.setFloating,
2791
+ ref: h.setFloating,
2792
2792
  style: g,
2793
2793
  onClick: (y) => {
2794
2794
  y.stopPropagation(), y.preventDefault();
@@ -2799,12 +2799,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2799
2799
  onKeyDown: (y) => y.stopPropagation(),
2800
2800
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
2801
2801
  children: [
2802
- h && /* @__PURE__ */ jsx(
2802
+ f && /* @__PURE__ */ jsx(
2803
2803
  ArrowUpIcon,
2804
2804
  {
2805
2805
  className: "hover:scale-105",
2806
2806
  onClick: () => {
2807
- d([]), l([h]);
2807
+ d([]), l([f]);
2808
2808
  }
2809
2809
  }
2810
2810
  ),
@@ -2947,21 +2947,21 @@ z(Frame, "defaultProps", {
2947
2947
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
2948
2948
  });
2949
2949
  const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r })), useKeyEventWatcher = (o) => {
2950
- const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: f } = usePasteBlocks(), m = o ? { document: o } : {};
2950
+ const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: d, redo: c } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
2951
2951
  useHotkeys("ctrl+z,command+z", () => d(), {}, [d]), useHotkeys("ctrl+y,command+y", () => c(), {}, [c]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
2952
2952
  "ctrl+v,command+v",
2953
2953
  () => {
2954
- g(r[0]) && f(r);
2954
+ g(r[0]) && h(r);
2955
2955
  },
2956
2956
  { ...m, preventDefault: !0 },
2957
- [r, g, f]
2957
+ [r, g, h]
2958
2958
  ), useHotkeys("esc", () => n([]), m, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...m, preventDefault: !0 }, [
2959
2959
  r,
2960
2960
  i
2961
2961
  ]), useHotkeys(
2962
2962
  "del, backspace",
2963
- (h) => {
2964
- h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
2963
+ (f) => {
2964
+ f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
2965
2965
  },
2966
2966
  m,
2967
2967
  [r, l]
@@ -3038,7 +3038,7 @@ function removeDataDrop() {
3038
3038
  const useDnd = () => {
3039
3039
  const { document: o } = useFrame(), [r, n] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: d } = useBlocksStoreUndoableActions(), [c, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
3040
3040
  if (!useFeature("dnd")) return {};
3041
- const f = () => {
3041
+ const h = () => {
3042
3042
  removePlaceholder(), n(!1), p(null), u(null), possiblePositions = [];
3043
3043
  };
3044
3044
  return iframeDocument = o, {
@@ -3048,25 +3048,25 @@ const useDnd = () => {
3048
3048
  },
3049
3049
  onDrop: (m) => {
3050
3050
  var E;
3051
- const h = dropTarget, y = getOrientation(h) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
3051
+ const f = dropTarget, y = getOrientation(f) === "vertical" ? m.clientY + ((E = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : E.scrollY) : m.clientX;
3052
3052
  dropIndex = calculateDropIndex(y, possiblePositions);
3053
- const b = c, v = h.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3053
+ const b = c, v = f.getAttribute("data-block-id"), w = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3054
3054
  if ((b == null ? void 0 : b._id) === v || !w) {
3055
- f();
3055
+ h();
3056
3056
  return;
3057
3057
  }
3058
3058
  if (!has(b, "_id")) {
3059
- a(b, v === "canvas" ? null : v, dropIndex), setTimeout(f, 300);
3059
+ a(b, v === "canvas" ? null : v, dropIndex), setTimeout(h, 300);
3060
3060
  return;
3061
3061
  }
3062
- let A = h.getAttribute("data-block-id");
3063
- A === null && (A = m.target.parentElement.getAttribute("data-block-id")), d([b._id], A === "canvas" ? null : A, dropIndex), f(), setTimeout(removePlaceholder, 300);
3062
+ let A = f.getAttribute("data-block-id");
3063
+ A === null && (A = m.target.parentElement.getAttribute("data-block-id")), d([b._id], A === "canvas" ? null : A, dropIndex), h(), setTimeout(removePlaceholder, 300);
3064
3064
  },
3065
3065
  onDragEnter: (m) => {
3066
- const h = m, x = h.target;
3066
+ const f = m, x = f.target;
3067
3067
  dropTarget = x;
3068
3068
  const y = x.getAttribute("data-block-id"), b = x.getAttribute("data-dnd-dragged") !== "yes";
3069
- u(y), h.stopPropagation(), h.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), n(!0), l(""), i([]);
3069
+ u(y), f.stopPropagation(), f.preventDefault(), possiblePositions = [], b && calculatePossiblePositions(x), n(!0), l(""), i([]);
3070
3070
  },
3071
3071
  onDragLeave: (m) => {
3072
3072
  m.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
@@ -3091,16 +3091,16 @@ const useHandleCanvasDblClick = (o, r) => {
3091
3091
  const g = u.getAttribute("data-block-type");
3092
3092
  if (!g || !n.includes(g))
3093
3093
  return;
3094
- const f = u.getAttribute("data-block-id");
3095
- if (!f) return;
3096
- o.on("update", ({ editor: h }) => {
3097
- console.log(h.getHTML());
3094
+ const h = u.getAttribute("data-block-id");
3095
+ if (!h) return;
3096
+ o.on("update", ({ editor: f }) => {
3097
+ console.log(f.getHTML());
3098
3098
  }), o.on("blur", () => {
3099
3099
  console.log("blur");
3100
- const h = o.getHTML();
3101
- a([f], { content: h }), r.style.display = "none", u.style.visibility = "visible";
3102
- }), i(f);
3103
- const m = c(f).content;
3100
+ const f = o.getHTML();
3101
+ a([h], { content: f }), r.style.display = "none", u.style.visibility = "visible";
3102
+ }), i(h);
3103
+ const m = c(h).content;
3104
3104
  o.commands.setContent(m), r.style.display = "block", u.style.visibility = "hidden", r.style.position = "absolute", r.style.top = `${u.offsetTop}px`, r.style.left = `${u.offsetLeft}px`, r.style.width = `${u.offsetWidth}px`, r.style.height = `${u.offsetHeight}px`, r.classList.add(...u.classList);
3105
3105
  },
3106
3106
  [l, d, c, i, a, o, r]
@@ -3140,11 +3140,11 @@ const useHandleCanvasDblClick = (o, r) => {
3140
3140
  setTimeout(() => {
3141
3141
  if (!isEmpty(a))
3142
3142
  return;
3143
- const h = getElementByDataBlockId(r, first(n));
3144
- if (h) {
3145
- const x = h.getAttribute("data-style-prop");
3143
+ const f = getElementByDataBlockId(r, first(n));
3144
+ if (f) {
3145
+ const x = f.getAttribute("data-style-prop");
3146
3146
  if (x) {
3147
- const y = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3147
+ const y = f.getAttribute("data-style-id"), b = f.getAttribute("data-block-parent");
3148
3148
  l([{ id: y, prop: x, blockId: b }]);
3149
3149
  }
3150
3150
  }
@@ -3152,7 +3152,7 @@ const useHandleCanvasDblClick = (o, r) => {
3152
3152
  }, [r, n, l, a]);
3153
3153
  const d = useEditor({
3154
3154
  extensions: [StarterKit]
3155
- }), c = useRef(null), p = useHandleCanvasDblClick(d, c.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), f = useHandleMouseLeave(), m = useDnd();
3155
+ }), c = useRef(null), p = useHandleCanvasDblClick(d, c.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), h = useHandleMouseLeave(), m = useDnd();
3156
3156
  return /* @__PURE__ */ jsx(
3157
3157
  "div",
3158
3158
  {
@@ -3161,7 +3161,7 @@ const useHandleCanvasDblClick = (o, r) => {
3161
3161
  onClick: u,
3162
3162
  onDoubleClick: p,
3163
3163
  onMouseMove: g,
3164
- onMouseLeave: f,
3164
+ onMouseLeave: h,
3165
3165
  ...omit(m, "isDragging"),
3166
3166
  className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
3167
3167
  children: o
@@ -3173,7 +3173,7 @@ const useHandleCanvasDblClick = (o, r) => {
3173
3173
  }, HeadTags = () => {
3174
3174
  const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [d] = useAtom$1(dropTargetBlockIdAtom), { document: c, window: p } = useFrame(), [u] = useState(c == null ? void 0 : c.getElementById("highlighted-block")), [g] = useState(
3175
3175
  c == null ? void 0 : c.getElementById("selected-block")
3176
- ), [f] = useState(
3176
+ ), [h] = useState(
3177
3177
  c == null ? void 0 : c.getElementById("selected-styling-block")
3178
3178
  ), [m] = useState(
3179
3179
  c == null ? void 0 : c.getElementById("dragged-block")
@@ -3181,7 +3181,7 @@ const useHandleCanvasDblClick = (o, r) => {
3181
3181
  useEffect(() => {
3182
3182
  a ? c == null || c.documentElement.classList.add("dark") : c == null || c.documentElement.classList.remove("dark");
3183
3183
  }, [a, c]);
3184
- const h = useRegisteredFonts();
3184
+ const f = useRegisteredFonts();
3185
3185
  useEffect(() => {
3186
3186
  !p || !p.tailwind || (p.tailwind.config = {
3187
3187
  darkMode: "class",
@@ -3225,10 +3225,10 @@ const useHandleCanvasDblClick = (o, r) => {
3225
3225
  }, [i, m]), useEffect(() => {
3226
3226
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3227
3227
  }, [u]), useEffect(() => {
3228
- f && (f.textContent = `${map(l, ({ id: v }) => `[data-style-id="${v}"]`).join(",")}{
3228
+ h && (h.textContent = `${map(l, ({ id: v }) => `[data-style-id="${v}"]`).join(",")}{
3229
3229
  outline: 1px solid orange !important; outline-offset: -1px;
3230
3230
  }`);
3231
- }, [l, f]), useEffect(() => {
3231
+ }, [l, h]), useEffect(() => {
3232
3232
  c.querySelector("#drop-target-block").innerHTML = d ? `[data-block-id="${d}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3233
3233
  }, [d, c]);
3234
3234
  const x = useMemo(() => {
@@ -3236,8 +3236,8 @@ const useHandleCanvasDblClick = (o, r) => {
3236
3236
  heading: get(o, "fontFamily.heading"),
3237
3237
  body: get(o, "fontFamily.body")
3238
3238
  };
3239
- return h.filter((A) => A.family === v || A.family === w);
3240
- }, [o == null ? void 0 : o.fontFamily, h]), y = useMemo(() => getThemeFontsLinkMarkup(filter(x, (v) => has(v, "url"))), [x]), b = useMemo(
3239
+ return f.filter((A) => A.family === v || A.family === w);
3240
+ }, [o == null ? void 0 : o.fontFamily, f]), y = useMemo(() => getThemeFontsLinkMarkup(filter(x, (v) => has(v, "url"))), [x]), b = useMemo(
3241
3241
  () => getThemeCustomFontFace(filter(x, (v) => has(v, "src"))),
3242
3242
  [x]
3243
3243
  );
@@ -3281,9 +3281,9 @@ const useHandleCanvasDblClick = (o, r) => {
3281
3281
  blockAtom: o,
3282
3282
  children: r
3283
3283
  }) => {
3284
- const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), d = useBlockRuntimeProps(), c = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), { index: f, key: m } = useContext(RepeaterContext), h = useMemo(
3285
- () => u ? applyBinding(applyLanguage(n, l, a), c, { index: f, key: m }) : applyLanguage(n, l, a),
3286
- [n, l, a, c, u, f, m]
3284
+ const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), d = useBlockRuntimeProps(), c = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), { index: h, key: m } = useContext(RepeaterContext), f = useMemo(
3285
+ () => u ? applyBinding(applyLanguage(n, l, a), c, { index: h, key: m }) : applyLanguage(n, l, a),
3286
+ [n, l, a, c, u, h, m]
3287
3287
  ), x = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), y = useMemo(
3288
3288
  () => d(n._id, getBlockRuntimeProps(n._type)),
3289
3289
  [n._id, n._type, d, getBlockRuntimeProps]
@@ -3295,7 +3295,7 @@ const useHandleCanvasDblClick = (o, r) => {
3295
3295
  },
3296
3296
  inBuilder: !0,
3297
3297
  lang: l || i,
3298
- ...h,
3298
+ ...f,
3299
3299
  ...x,
3300
3300
  ...y,
3301
3301
  ...b
@@ -3305,7 +3305,7 @@ const useHandleCanvasDblClick = (o, r) => {
3305
3305
  n._type,
3306
3306
  l,
3307
3307
  i,
3308
- h,
3308
+ f,
3309
3309
  x,
3310
3310
  y,
3311
3311
  b
@@ -3316,9 +3316,9 @@ const useHandleCanvasDblClick = (o, r) => {
3316
3316
  children: r({
3317
3317
  _id: n._id,
3318
3318
  _type: n._type,
3319
- ...isArray(h.repeaterItems) ? {
3320
- repeaterItems: applyLimit(h.repeaterItems, n),
3321
- repeaterItemsBinding: h.repeaterItemsBinding
3319
+ ...isArray(f.repeaterItems) ? {
3320
+ repeaterItems: applyLimit(f.repeaterItems, n),
3321
+ repeaterItemsBinding: f.repeaterItemsBinding
3322
3322
  } : {},
3323
3323
  ...n.partialBlockId ? { partialBlockId: n.partialBlockId } : "",
3324
3324
  ...n.globalBlock ? { partialBlockId: n.globalBlock } : ""
@@ -3341,7 +3341,7 @@ const useHandleCanvasDblClick = (o, r) => {
3341
3341
  );
3342
3342
  return map(l, (d) => {
3343
3343
  const c = a(d._id);
3344
- return c ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: c, children: ({ _id: p, _type: u, partialBlockId: g, repeaterItems: f, repeaterItemsBinding: m }) => u === "Repeater" ? isArray(f) && f.map((h, x) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: x, key: m }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) })) : u === "GlobalBlock" || u === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: g }) }) : i(p) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) : null }, d._id) : null;
3344
+ return c ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: c, children: ({ _id: p, _type: u, partialBlockId: g, repeaterItems: h, repeaterItemsBinding: m }) => u === "Repeater" ? isArray(h) && h.map((f, x) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: x, key: m }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) })) : u === "GlobalBlock" || u === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: g }) }) : i(p) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: d._id }) : null }, d._id) : null;
3345
3345
  });
3346
3346
  }, PageBlocksRenderer = () => {
3347
3347
  const [o] = useBlocksStore();
@@ -3355,10 +3355,10 @@ const useHandleCanvasDblClick = (o, r) => {
3355
3355
  if (c < r) {
3356
3356
  const u = parseFloat((c / r).toFixed(2).toString());
3357
3357
  let g = {};
3358
- const f = p * u, m = c * u;
3358
+ const h = p * u, m = c * u;
3359
3359
  p && (g = {
3360
3360
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3361
- height: 100 + (p - f) / f * 100 + "%",
3361
+ height: 100 + (p - h) / h * 100 + "%",
3362
3362
  width: 100 + (c - m) / m * 100 + "%"
3363
3363
  }), i({
3364
3364
  position: "relative",
@@ -3376,7 +3376,7 @@ const useHandleCanvasDblClick = (o, r) => {
3376
3376
  d();
3377
3377
  }, [r, o, n, d]), l;
3378
3378
  }, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
3379
- const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, y] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), w = (_) => {
3379
+ const [o] = useAtom$1(networkModeAtom), [r] = useCanvasDisplayWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), d = useRef(null), [c, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(c), [g, h] = useState([]), [, m] = useState([]), [, f] = useAtom$1(canvasIframeAtom), [x, y] = useSelectedStylingBlocks(), b = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), w = (_) => {
3380
3380
  p((S) => ({ ...S, width: _ }));
3381
3381
  };
3382
3382
  useEffect(() => {
@@ -3392,7 +3392,7 @@ const useHandleCanvasDblClick = (o, r) => {
3392
3392
  var _, S;
3393
3393
  if (a != null && a._id && a.type !== "Multiple" && i.current) {
3394
3394
  const B = getElementByDataBlockId(i.current.contentDocument, a._id);
3395
- B && (A(B) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: B.offsetTop, behavior: "smooth" }), f([B]));
3395
+ B && (A(B) || (S = (_ = i.current) == null ? void 0 : _.contentWindow) == null || S.scrollTo({ top: B.offsetTop, behavior: "smooth" }), h([B]));
3396
3396
  }
3397
3397
  }, [a == null ? void 0 : a._id, a == null ? void 0 : a.type]), useEffect(() => {
3398
3398
  if (!isEmpty(x) && i.current) {
@@ -3420,7 +3420,7 @@ const useHandleCanvasDblClick = (o, r) => {
3420
3420
  children: /* @__PURE__ */ jsxs(
3421
3421
  ChaiFrame,
3422
3422
  {
3423
- contentDidMount: () => h(i.current),
3423
+ contentDidMount: () => f(i.current),
3424
3424
  ref: i,
3425
3425
  id: "canvas-iframe",
3426
3426
  style: { ...u, ...isEmpty(u) ? { width: `${r}px` } : {} },
@@ -3471,22 +3471,22 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3471
3471
  useEffect(() => {
3472
3472
  a || d([]), p(o);
3473
3473
  }, [a, o]);
3474
- const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
3475
- (h) => {
3474
+ const u = (f) => Array.isArray(f) ? "array" : typeof f == "object" && f !== null ? "object" : "value", g = React.useCallback(
3475
+ (f) => {
3476
3476
  const x = (y) => n === "value" ? y === "value" || y === "object" : n === "array" ? y === "array" : y === n;
3477
- h.type === "object" ? (d((y) => [...y, h.key]), p(h.value)) : x(h.type) && (r([...i, h.key].join("."), n), l(!1));
3477
+ f.type === "object" ? (d((y) => [...y, f.key]), p(f.value)) : x(f.type) && (r([...i, f.key].join("."), n), l(!1));
3478
3478
  },
3479
3479
  [i, r, n]
3480
- ), f = React.useCallback(() => {
3480
+ ), h = React.useCallback(() => {
3481
3481
  if (i.length > 0) {
3482
- const h = i.slice(0, -1);
3483
- d(h), p(h.reduce((x, y) => x[y], o));
3482
+ const f = i.slice(0, -1);
3483
+ d(f), p(f.reduce((x, y) => x[y], o));
3484
3484
  }
3485
- }, [i, o]), m = React.useMemo(() => Object.entries(c).map(([h, x]) => ({
3486
- key: h,
3485
+ }, [i, o]), m = React.useMemo(() => Object.entries(c).map(([f, x]) => ({
3486
+ key: f,
3487
3487
  value: x,
3488
3488
  type: u(x)
3489
- })).filter((h) => n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0), [c, n]);
3489
+ })).filter((f) => n === "value" ? f.type === "value" || f.type === "object" : n === "array" ? f.type === "array" || f.type === "object" : n === "object" ? f.type === "object" : !0), [c, n]);
3490
3490
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
3491
3491
  /* @__PURE__ */ jsxs(Tooltip, { children: [
3492
3492
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -3507,40 +3507,40 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3507
3507
  /* @__PURE__ */ jsxs(CommandList, { children: [
3508
3508
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
3509
3509
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
3510
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: f, className: "flex items-center text-sm", children: [
3510
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: h, className: "flex items-center text-sm", children: [
3511
3511
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
3512
3512
  "Back"
3513
3513
  ] }),
3514
- m.map((h) => /* @__PURE__ */ jsxs(
3514
+ m.map((f) => /* @__PURE__ */ jsxs(
3515
3515
  CommandItem,
3516
3516
  {
3517
- value: h.key,
3517
+ value: f.key,
3518
3518
  disabled: !1,
3519
- onSelect: () => g(h),
3519
+ onSelect: () => g(f),
3520
3520
  className: "flex items-center justify-between",
3521
3521
  children: [
3522
3522
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
3523
- startsWith(h.key, "#") ? /* @__PURE__ */ jsx(LoopIcon, {}) : null,
3524
- startsWith(h.key, "#") ? "Repeater Data" : h.key
3523
+ startsWith(f.key, "#") ? /* @__PURE__ */ jsx(LoopIcon, {}) : null,
3524
+ startsWith(f.key, "#") ? "Repeater Data" : f.key
3525
3525
  ] }),
3526
3526
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3527
- n === "object" && h.type === "object" && /* @__PURE__ */ jsx(
3527
+ n === "object" && f.type === "object" && /* @__PURE__ */ jsx(
3528
3528
  Button,
3529
3529
  {
3530
3530
  size: "sm",
3531
3531
  variant: "ghost",
3532
3532
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
3533
3533
  onClick: (x) => {
3534
- x.stopPropagation(), r([...i, h.key].join("."), n), l(!1);
3534
+ x.stopPropagation(), r([...i, f.key].join("."), n), l(!1);
3535
3535
  },
3536
3536
  children: "Select"
3537
3537
  }
3538
3538
  ),
3539
- h.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
3539
+ f.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
3540
3540
  ] })
3541
3541
  ]
3542
3542
  },
3543
- h.key
3543
+ f.key
3544
3544
  ))
3545
3545
  ] })
3546
3546
  ] })
@@ -3559,16 +3559,16 @@ const JSONFormFieldTemplate = ({
3559
3559
  required: p,
3560
3560
  schema: u,
3561
3561
  formData: g,
3562
- onChange: f
3562
+ onChange: h
3563
3563
  }) => {
3564
- const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), y = isEmpty(x) ? "" : isEmpty(m) ? h : m, b = get(LANGUAGES, y, y), v = usePageExternalData(), w = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [w == null ? void 0 : w._type, "i18nProps"], []) || [], [_, S] = useState(null), B = useSelectedBlockHierarchy(), N = useMemo(() => B.length === 1 ? "" : `#${get(
3564
+ const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), y = isEmpty(x) ? "" : isEmpty(m) ? f : m, b = get(LANGUAGES, y, y), v = usePageExternalData(), w = useSelectedBlock(), A = useRegisteredChaiBlocks(), E = get(A, [w == null ? void 0 : w._type, "i18nProps"], []) || [], [_, S] = useState(null), B = useSelectedBlockHierarchy(), N = useMemo(() => B.length === 1 ? "" : `#${get(
3565
3565
  B.find((L) => L._type === "Repeater"),
3566
3566
  "repeaterItems",
3567
3567
  ""
3568
3568
  ).replace(/\{\{(.*)\}\}/g, "$1")}`, [B]), C = useMemo(() => first(get(v, N.replace("#", ""), [])), [N, v]), k = useCallback(
3569
3569
  (I, P) => {
3570
3570
  if (I = isEmpty(N) ? I : I.replace(`${N}.`, "$index."), P === "array" || P === "object") {
3571
- f(`{{${I}}}`, {}, o);
3571
+ h(`{{${I}}}`, {}, o);
3572
3572
  return;
3573
3573
  }
3574
3574
  const L = (D) => /[.,!?;:]/.test(D), O = (D, M, H) => {
@@ -3597,21 +3597,21 @@ const JSONFormFieldTemplate = ({
3597
3597
  let q = "";
3598
3598
  G && G !== " " && !L(G) && (q = " "), D.chain().insertContent(Y + M + q).run();
3599
3599
  }
3600
- setTimeout(() => f(D.getHTML(), {}, o), 100);
3600
+ setTimeout(() => h(D.getHTML(), {}, o), 100);
3601
3601
  return;
3602
3602
  }
3603
3603
  } else {
3604
3604
  const D = $, M = D.selectionStart || 0, H = D.value || "", F = D.selectionEnd || M;
3605
3605
  if (F > M) {
3606
3606
  const G = `{{${I}}}`, { text: Y } = O(H, M, G), q = H.slice(0, M) + Y + H.slice(F);
3607
- f(q, {}, o);
3607
+ h(q, {}, o);
3608
3608
  return;
3609
3609
  }
3610
3610
  const U = `{{${I}}}`, { text: V } = O(H, M, U), K = H.slice(0, M) + V + H.slice(M);
3611
- f(K, {}, o);
3611
+ h(K, {}, o);
3612
3612
  }
3613
3613
  },
3614
- [o, f, g, w == null ? void 0 : w._id, N]
3614
+ [o, h, g, w == null ? void 0 : w._id, N]
3615
3615
  );
3616
3616
  if (c)
3617
3617
  return null;
@@ -3729,8 +3729,8 @@ const JSONFormFieldTemplate = ({
3729
3729
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
3730
3730
  ] });
3731
3731
  }, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
3732
- const [a, l] = useState(""), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState(null), f = async (h) => {
3733
- if (!h.trim()) {
3732
+ const [a, l] = useState(""), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
3733
+ if (!f.trim()) {
3734
3734
  p(!1), g("Please enter a URL");
3735
3735
  return;
3736
3736
  }
@@ -3754,8 +3754,8 @@ const JSONFormFieldTemplate = ({
3754
3754
  {
3755
3755
  placeholder: m(`Enter ${n} URL`),
3756
3756
  value: a,
3757
- onChange: (h) => l(h.target.value),
3758
- onBlur: () => f(a)
3757
+ onChange: (f) => l(f.target.value),
3758
+ onKeyUp: () => h(a)
3759
3759
  }
3760
3760
  ),
3761
3761
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
@@ -3763,7 +3763,7 @@ const JSONFormFieldTemplate = ({
3763
3763
  /* @__PURE__ */ jsx(
3764
3764
  Button,
3765
3765
  {
3766
- onClick: () => r({ url: a, width: 600, height: 400, description: "This is image description" }),
3766
+ onClick: () => r({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
3767
3767
  disabled: !c || i,
3768
3768
  children: m("Insert")
3769
3769
  }
@@ -3776,37 +3776,56 @@ const JSONFormFieldTemplate = ({
3776
3776
  }, registerChaiMediaManager = (o) => {
3777
3777
  MEDIA_MANAGER.component = o;
3778
3778
  }, useMediaManagerComponent = () => useMemo(() => MEDIA_MANAGER.component, []), MediaManagerModal = ({
3779
- children: o,
3780
- onSelect: r,
3781
- mode: n = "image"
3779
+ assetId: o,
3780
+ children: r,
3781
+ onSelect: n,
3782
+ mode: a = "image"
3782
3783
  }) => {
3783
- const [a, l] = useState(!1), i = useMediaManagerComponent();
3784
- return /* @__PURE__ */ jsxs(Dialog, { open: a, onOpenChange: (c) => l(c), children: [
3785
- /* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: o }),
3786
- /* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: i ? /* @__PURE__ */ jsx(i, { close: () => l(!1), onSelect: (...c) => {
3787
- r.call(void 0, ...c), l(!1);
3788
- }, mode: n }) : null }) })
3784
+ const [l, i] = useState(!1), d = useMediaManagerComponent();
3785
+ return /* @__PURE__ */ jsxs(Dialog, { open: l, onOpenChange: (p) => i(p), children: [
3786
+ /* @__PURE__ */ jsx(DialogTrigger, { asChild: !0, children: r }),
3787
+ /* @__PURE__ */ jsx(DialogContent, { className: "flex max-h-[90vh] max-w-7xl border-border md:w-fit", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: d ? /* @__PURE__ */ jsx(d, { close: () => i(!1), onSelect: (...p) => {
3788
+ n.call(void 0, ...p), i(!1);
3789
+ }, mode: a, assetId: o }) : null }) })
3789
3790
  ] });
3790
3791
  };
3791
3792
  MediaManagerModal.displayName = "MediaManagerModal";
3792
3793
  const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3793
- const { t: l } = useTranslation(), i = useSelectedBlock(), d = useUpdateBlocksProps(), c = (p) => {
3794
- const u = isArray(p) ? first(p) : p;
3795
- if (u) {
3796
- r(u == null ? void 0 : u.url);
3797
- const g = u == null ? void 0 : u.width, f = u == null ? void 0 : u.height;
3798
- g && f && (i != null && i._id) && d([i._id], {
3799
- width: g,
3800
- height: f,
3801
- ...u.description && { alt: u.description }
3802
- });
3794
+ const { t: l } = useTranslation(), i = useSelectedBlock(), d = useUpdateBlocksProps(), c = (g) => {
3795
+ const h = isArray(g) ? first(g) : g;
3796
+ if (h) {
3797
+ r(h == null ? void 0 : h.url);
3798
+ const m = h == null ? void 0 : h.width, f = h == null ? void 0 : h.height;
3799
+ if (i != null && i._id) {
3800
+ const x = {
3801
+ ...m && { width: m },
3802
+ ...f && { height: f },
3803
+ ...h.description && { alt: h.description },
3804
+ ...h.id && { assetId: h.id }
3805
+ };
3806
+ if (isEmpty(x)) return;
3807
+ d([i._id], x);
3808
+ }
3803
3809
  }
3804
- };
3810
+ }, p = useCallback(() => {
3811
+ r("https://placehold.co/400"), i != null && i._id && d([i._id], { assetId: "" });
3812
+ }, [r, i == null ? void 0 : i._id, d]), u = get(i, "assetId", "");
3805
3813
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
3806
- o ? /* @__PURE__ */ jsx("img", { src: o, className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover", alt: "" }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, mode: "image", children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
3814
+ o ? /* @__PURE__ */ jsxs("div", { className: "relative", children: [
3815
+ /* @__PURE__ */ jsx("img", { src: o, className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover", alt: "" }),
3816
+ /* @__PURE__ */ jsx(
3817
+ "button",
3818
+ {
3819
+ type: "button",
3820
+ onClick: p,
3821
+ className: "absolute -right-2 -top-2 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
3822
+ children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
3823
+ }
3824
+ )
3825
+ ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, mode: "image", assetId: u, children: /* @__PURE__ */ jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
3807
3826
  /* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
3808
3827
  /* @__PURE__ */ jsxs(Fragment, { children: [
3809
- /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
3828
+ /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: c, assetId: u, children: /* @__PURE__ */ jsx("small", { className: "h-6 cursor-pointer rounded-md bg-secondary px-2 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: o || !isEmpty(o) ? l("Replace image") : l("Choose image") }) }),
3810
3829
  /* @__PURE__ */ jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-secondary-foreground", children: "OR" })
3811
3830
  ] }),
3812
3831
  /* @__PURE__ */ jsx(
@@ -3820,8 +3839,8 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3820
3839
  className: "text-xs",
3821
3840
  placeholder: l("Enter image URL"),
3822
3841
  value: o,
3823
- onBlur: ({ target: { value: p } }) => a(n, p),
3824
- onChange: (p) => r(p.target.value)
3842
+ onBlur: ({ target: { value: g } }) => a(n, g),
3843
+ onChange: (g) => r(g.target.value)
3825
3844
  }
3826
3845
  )
3827
3846
  ] })
@@ -3832,7 +3851,7 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3832
3851
  onChange: n
3833
3852
  }) => {
3834
3853
  var N;
3835
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [y, b] = useState(-1), v = useRef(null), w = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
3854
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, d] = useState(!1), [c, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), w = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
3836
3855
  useEffect(() => {
3837
3856
  if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
3838
3857
  const C = split(o, ":"), k = get(C, 1, "page") || "page";
@@ -3859,14 +3878,14 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3859
3878
  }, _ = (C) => {
3860
3879
  switch (C.key) {
3861
3880
  case "ArrowDown":
3862
- C.preventDefault(), b((k) => k < h.length - 1 ? k + 1 : k);
3881
+ C.preventDefault(), b((k) => k < f.length - 1 ? k + 1 : k);
3863
3882
  break;
3864
3883
  case "ArrowUp":
3865
3884
  C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
3866
3885
  break;
3867
3886
  case "Enter":
3868
- if (C.preventDefault(), h.length === 0) return;
3869
- y >= 0 && E(h[y]);
3887
+ if (C.preventDefault(), f.length === 0) return;
3888
+ y >= 0 && E(f[y]);
3870
3889
  break;
3871
3890
  case "Escape":
3872
3891
  C.preventDefault(), S();
@@ -3891,24 +3910,24 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3891
3910
  "input",
3892
3911
  {
3893
3912
  type: "text",
3894
- value: f,
3913
+ value: h,
3895
3914
  onChange: (C) => B(C.target.value),
3896
3915
  onKeyDown: _,
3897
3916
  placeholder: a(`Search ${w ?? ""}`),
3898
3917
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
3899
3918
  }
3900
3919
  ),
3901
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
3920
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
3902
3921
  ] }),
3903
- (i || !isEmpty(h) || c && isEmpty(h)) && /* @__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: [
3922
+ (i || !isEmpty(f) || c && 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: [
3904
3923
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
3905
3924
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
3906
- ] }) : c && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
3925
+ ] }) : c && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
3907
3926
  a("No results found for"),
3908
3927
  ' "',
3909
- f,
3928
+ h,
3910
3929
  '"'
3911
- ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(h == null ? void 0 : h.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
3930
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
3912
3931
  "li",
3913
3932
  {
3914
3933
  onClick: () => E(C),
@@ -4147,14 +4166,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4147
4166
  const d = useRef(null), c = useRef(a || ""), p = usePageExternalData();
4148
4167
  useEffect(() => {
4149
4168
  if (o) {
4150
- const f = document.createElement("style");
4151
- return f.id = "rte-modal-styles", f.innerHTML = `
4169
+ const h = document.createElement("style");
4170
+ return h.id = "rte-modal-styles", h.innerHTML = `
4152
4171
  /* Ensure the NestedPathSelector popover appears above the dialog */
4153
4172
  .rte-path-selector + [data-radix-popper-content-wrapper],
4154
4173
  [data-radix-popper-content-wrapper] {
4155
4174
  z-index: 9999 !important;
4156
4175
  }
4157
- `, document.head.appendChild(f), () => {
4176
+ `, document.head.appendChild(h), () => {
4158
4177
  const m = document.getElementById("rte-modal-styles");
4159
4178
  m && m.remove();
4160
4179
  };
@@ -4177,12 +4196,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4177
4196
  Underline
4178
4197
  ],
4179
4198
  content: a || "",
4180
- onUpdate: ({ editor: f }) => {
4181
- const m = f.getHTML();
4199
+ onUpdate: ({ editor: h }) => {
4200
+ const m = h.getHTML();
4182
4201
  l(m);
4183
4202
  },
4184
- onBlur: ({ editor: f }) => {
4185
- const m = f.getHTML();
4203
+ onBlur: ({ editor: h }) => {
4204
+ const m = h.getHTML();
4186
4205
  i(n, m);
4187
4206
  },
4188
4207
  editorProps: {
@@ -4198,12 +4217,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4198
4217
  }, [o, u]), useEffect(() => {
4199
4218
  d.current && u && (d.current.__chaiRTE = u);
4200
4219
  }, [u, o]);
4201
- const g = (f) => {
4220
+ const g = (h) => {
4202
4221
  if (!u) return;
4203
- const m = `{{${f}}}`;
4222
+ const m = `{{${h}}}`;
4204
4223
  u.commands.focus();
4205
- const { from: h, to: x } = u.state.selection;
4206
- if (h !== x)
4224
+ const { from: f, to: x } = u.state.selection;
4225
+ if (f !== x)
4207
4226
  u.chain().deleteSelection().insertContent(m).run();
4208
4227
  else {
4209
4228
  const { state: b } = u, v = b.selection.from, w = b.doc.textBetween(Math.max(0, v - 1), v), A = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
@@ -4213,7 +4232,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4213
4232
  A && A !== " " && !/[.,!?;:]/.test(A) && (_ = " "), u.chain().insertContent(E + m + _).run();
4214
4233
  }
4215
4234
  };
4216
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (f) => !f && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4235
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4217
4236
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4218
4237
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4219
4238
  p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4245,12 +4264,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4245
4264
  Underline
4246
4265
  ],
4247
4266
  content: n || "",
4248
- onUpdate: ({ editor: h }) => {
4249
- const x = h.getHTML();
4267
+ onUpdate: ({ editor: f }) => {
4268
+ const x = f.getHTML();
4250
4269
  a(x), d || u(x);
4251
4270
  },
4252
- onBlur: ({ editor: h }) => {
4253
- const x = h.getHTML();
4271
+ onBlur: ({ editor: f }) => {
4272
+ const x = f.getHTML();
4254
4273
  l(o, x);
4255
4274
  },
4256
4275
  editorProps: {
@@ -4264,8 +4283,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4264
4283
  }, [g]), useEffect(() => {
4265
4284
  u(n || "");
4266
4285
  }, [n]);
4267
- const f = (h) => {
4268
- a(h);
4286
+ const h = (f) => {
4287
+ a(f);
4269
4288
  }, m = () => {
4270
4289
  c(!1), g && g.commands.setContent(p);
4271
4290
  };
@@ -4281,7 +4300,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4281
4300
  onClose: m,
4282
4301
  id: o,
4283
4302
  value: p,
4284
- onChange: f,
4303
+ onChange: h,
4285
4304
  onBlur: l
4286
4305
  }
4287
4306
  )
@@ -4297,7 +4316,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4297
4316
  }, [a]), useEffect(() => {
4298
4317
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
4299
4318
  }, [o, u]);
4300
- const f = () => {
4319
+ const h = () => {
4301
4320
  const x = findIndex(u, { _id: g });
4302
4321
  if (x > -1) {
4303
4322
  const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
@@ -4311,7 +4330,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4311
4330
  if (!b) return;
4312
4331
  r({ ...o, currentSlide: b }), d([b]);
4313
4332
  }
4314
- }, h = () => {
4333
+ }, f = () => {
4315
4334
  const x = i(
4316
4335
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4317
4336
  p == null ? void 0 : p._id
@@ -4329,11 +4348,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4329
4348
  "/",
4330
4349
  u.length
4331
4350
  ] }) : "-" }),
4332
- /* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4351
+ /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4333
4352
  /* @__PURE__ */ jsxs(
4334
4353
  "button",
4335
4354
  {
4336
- onClick: h,
4355
+ onClick: f,
4337
4356
  className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
4338
4357
  children: [
4339
4358
  /* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
@@ -4407,7 +4426,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4407
4426
  const n = get(o, "srcsets", []) || [], a = (d, c) => {
4408
4427
  const p = d.target.name, u = d.target.value;
4409
4428
  r({
4410
- srcsets: map(n, (g, f) => f === c ? { ...g, [p]: u } : g)
4429
+ srcsets: map(n, (g, h) => h === c ? { ...g, [p]: u } : g)
4411
4430
  });
4412
4431
  }, l = () => {
4413
4432
  r({ srcsets: [...n, {}] });
@@ -4490,8 +4509,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4490
4509
  /* @__PURE__ */ jsx("span", { children: "Add" })
4491
4510
  ] }) }), JSONForm = memo(({ blockId: o, schema: r, uiSchema: n, formData: a, onChange: l }) => {
4492
4511
  const { selectedLang: i } = useLanguages(), d = useBlockSettingComponents("widget"), c = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
4493
- async ({ formData: g }, f) => {
4494
- l({ formData: g }, f);
4512
+ async ({ formData: g }, h) => {
4513
+ l({ formData: g }, h);
4495
4514
  },
4496
4515
  [l, i],
4497
4516
  400
@@ -4531,9 +4550,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4531
4550
  uiSchema: n,
4532
4551
  schema: r,
4533
4552
  formData: a,
4534
- onChange: ({ formData: g }, f) => {
4535
- if (!f || o !== (g == null ? void 0 : g._id)) return;
4536
- const m = take(f.split("."), 2).join(".").replace("root.", "");
4553
+ onChange: ({ formData: g }, h) => {
4554
+ if (!h || o !== (g == null ? void 0 : g._id)) return;
4555
+ const m = take(h.split("."), 2).join(".").replace("root.", "");
4537
4556
  u({ formData: g }, m);
4538
4557
  }
4539
4558
  },
@@ -4546,11 +4565,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4546
4565
  }), a;
4547
4566
  };
4548
4567
  function BlockSettings() {
4549
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: _ }, S, B) => {
4568
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [d, c] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), f = ({ formData: _ }, S, B) => {
4550
4569
  S && (d == null ? void 0 : d._id) === r._id && a([r._id], { [S]: get(_, S) }, B);
4551
4570
  }, x = useCallback(
4552
4571
  debounce(({ formData: _ }, S, B) => {
4553
- h({ formData: _ }, S, B), c(_);
4572
+ f({ formData: _ }, S, B), c(_);
4554
4573
  }, 1500),
4555
4574
  [r == null ? void 0 : r._id, o]
4556
4575
  ), y = ({ formData: _ }, S) => {
@@ -4787,7 +4806,7 @@ const BlockStylingProps = () => {
4787
4806
  },
4788
4807
  a
4789
4808
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
4790
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [y, b] = useState(""), [v, w] = useState(!1), [A, E] = useState(!1);
4809
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: d, classPrefix: c, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v, w] = useState(!1), [A, E] = useState(!1);
4791
4810
  useEffect(() => {
4792
4811
  const { value: C, unit: k } = getClassValueAndUnit(i);
4793
4812
  if (k === "") {
@@ -4803,7 +4822,7 @@ const BlockStylingProps = () => {
4803
4822
  x(!0);
4804
4823
  return;
4805
4824
  }
4806
- const j = get(k, "unit") !== "" ? get(k, "unit") : f;
4825
+ const j = get(k, "unit") !== "" ? get(k, "unit") : h;
4807
4826
  if (j === "auto" || j === "none") {
4808
4827
  _(`${c}${j}`);
4809
4828
  return;
@@ -4813,7 +4832,7 @@ const BlockStylingProps = () => {
4813
4832
  const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${c}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4814
4833
  C ? S(I) : _(I);
4815
4834
  },
4816
- [_, S, a, f, c, u]
4835
+ [_, S, a, h, c, u]
4817
4836
  ), N = useCallback(
4818
4837
  (C) => {
4819
4838
  const k = getUserInputValues(`${a}`, u);
@@ -4832,7 +4851,7 @@ const BlockStylingProps = () => {
4832
4851
  },
4833
4852
  [_, a, c, u]
4834
4853
  );
4835
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
4854
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
4836
4855
  /* @__PURE__ */ jsx(
4837
4856
  "input",
4838
4857
  {
@@ -4847,10 +4866,10 @@ const BlockStylingProps = () => {
4847
4866
  ] })
4848
4867
  ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
4849
4868
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
4850
- ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
4869
+ ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
4851
4870
  "input",
4852
4871
  {
4853
- readOnly: f === "class",
4872
+ readOnly: h === "class",
4854
4873
  onKeyPress: (C) => {
4855
4874
  C.key === "Enter" && B();
4856
4875
  },
@@ -4861,7 +4880,7 @@ const BlockStylingProps = () => {
4861
4880
  const k = parseInt$1(C.target.value);
4862
4881
  let j = isNaN$1(k) ? 0 : k;
4863
4882
  C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
4864
- const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${c}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
4883
+ const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${c}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
4865
4884
  S(P);
4866
4885
  },
4867
4886
  onKeyUp: (C) => {
@@ -4878,7 +4897,7 @@ const BlockStylingProps = () => {
4878
4897
  value: v ? y : a,
4879
4898
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
4880
4899
  " ",
4881
- h ? "border-red-500 text-red-500" : "border-foreground/20"
4900
+ f ? "border-red-500 text-red-500" : "border-foreground/20"
4882
4901
  )
4883
4902
  }
4884
4903
  ),
@@ -4890,7 +4909,7 @@ const BlockStylingProps = () => {
4890
4909
  onClick: () => n(!r),
4891
4910
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
4892
4911
  children: [
4893
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: f }),
4912
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
4894
4913
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
4895
4914
  ]
4896
4915
  }
@@ -4899,7 +4918,7 @@ const BlockStylingProps = () => {
4899
4918
  UnitSelection,
4900
4919
  {
4901
4920
  units: u,
4902
- current: f,
4921
+ current: h,
4903
4922
  onSelect: (C) => {
4904
4923
  n(!1), m(C), N(C);
4905
4924
  }
@@ -4907,25 +4926,25 @@ const BlockStylingProps = () => {
4907
4926
  ) })
4908
4927
  ] })
4909
4928
  ] }),
4910
- ["none", "auto"].indexOf(f) !== -1 || v ? null : /* @__PURE__ */ jsx(
4929
+ ["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsx(
4911
4930
  DragStyleButton,
4912
4931
  {
4913
4932
  onDragStart: () => w(!0),
4914
4933
  onDragEnd: (C) => {
4915
4934
  if (b(() => ""), w(!1), isEmpty(C))
4916
4935
  return;
4917
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
4936
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
4918
4937
  _(T);
4919
4938
  },
4920
4939
  onDrag: (C) => {
4921
4940
  if (isEmpty(C))
4922
4941
  return;
4923
4942
  b(C);
4924
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
4943
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
4925
4944
  S(T);
4926
4945
  },
4927
4946
  currentValue: a,
4928
- unit: f,
4947
+ unit: h,
4929
4948
  negative: g,
4930
4949
  cssProperty: p
4931
4950
  }
@@ -4985,7 +5004,7 @@ const COLOR_PROP = {
4985
5004
  ringColor: "ring",
4986
5005
  ringOffsetColor: "ring-offset"
4987
5006
  }, ColorChoice = ({ property: o, onChange: r }) => {
4988
- const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), f = get(u, "2", ""), m = useCallback(
5007
+ const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, d] = useState([]), [c, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
4989
5008
  // eslint-disable-next-line no-shadow
4990
5009
  (y) => {
4991
5010
  ["current", "inherit", "transparent", "black", "white"].includes(y) ? (d([]), p({ color: y })) : (d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
@@ -4997,7 +5016,7 @@ const COLOR_PROP = {
4997
5016
  return d([]);
4998
5017
  d(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
4999
5018
  }, [g]);
5000
- const h = useCallback(
5019
+ const f = useCallback(
5001
5020
  // eslint-disable-next-line no-shadow
5002
5021
  (y) => {
5003
5022
  p({ color: g, shade: y });
@@ -5051,7 +5070,7 @@ const COLOR_PROP = {
5051
5070
  ]
5052
5071
  }
5053
5072
  ) }),
5054
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: f, disabled: !g || !l, onChange: h, options: i }) })
5073
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
5055
5074
  ] });
5056
5075
  }, EDITOR_ICONS = {
5057
5076
  "not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
@@ -5385,7 +5404,7 @@ const COLOR_PROP = {
5385
5404
  "2xl": "1536px"
5386
5405
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5387
5406
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5388
- }, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(f, "fullCls", ""), [f]), b = useCallback(
5407
+ }, units: d, negative: c = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5389
5408
  (S, B = !0) => {
5390
5409
  const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5391
5410
  (p || u !== "") && (N.mq = "xs");
@@ -5394,11 +5413,11 @@ const COLOR_PROP = {
5394
5413
  },
5395
5414
  [x, p, g, u, l, m]
5396
5415
  ), v = useCallback(() => {
5397
- h(x, [y], !0);
5398
- }, [x, y, h]), w = useMemo(() => canChangeClass(f, g), [f, g]);
5416
+ f(x, [y], !0);
5417
+ }, [x, y, f]), w = useMemo(() => canChangeClass(h, g), [h, g]);
5399
5418
  useEffect(() => {
5400
- i(w, f);
5401
- }, [w, i, f]);
5419
+ i(w, h);
5420
+ }, [w, i, h]);
5402
5421
  const [, , A] = useScreenSizeWidth(), E = useCallback(
5403
5422
  (S) => {
5404
5423
  A({
@@ -5411,15 +5430,15 @@ const COLOR_PROP = {
5411
5430
  }[S]);
5412
5431
  },
5413
5432
  [A]
5414
- ), _ = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
5415
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: w, canReset: f && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5416
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
5433
+ ), _ = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
5434
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: w, canReset: h && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5435
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
5417
5436
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5418
5437
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5419
5438
  n === "arbitrary" ? /* @__PURE__ */ jsx(
5420
5439
  AdvanceChoices,
5421
5440
  {
5422
- currentClass: get(f, "cls", ""),
5441
+ currentClass: get(h, "cls", ""),
5423
5442
  classPrefix: get(CLASS_PREFIXES, l, ""),
5424
5443
  units: d || [],
5425
5444
  onChange: b,
@@ -5432,7 +5451,7 @@ const COLOR_PROP = {
5432
5451
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5433
5452
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5434
5453
  ] }),
5435
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5454
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5436
5455
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5437
5456
  "button",
5438
5457
  {
@@ -5444,19 +5463,19 @@ const COLOR_PROP = {
5444
5463
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
5445
5464
  "Current style is set at  ",
5446
5465
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
5447
- getBreakpoint(get(f, "mq")),
5448
- p && !f.dark ? "(Light mode)" : ""
5466
+ getBreakpoint(get(h, "mq")),
5467
+ p && !h.dark ? "(Light mode)" : ""
5449
5468
  ] }),
5450
5469
  /* @__PURE__ */ jsx("br", {}),
5451
5470
  /* @__PURE__ */ jsxs(
5452
5471
  "button",
5453
5472
  {
5454
5473
  type: "button",
5455
- onClick: () => E(get(f, "mq")),
5474
+ onClick: () => E(get(h, "mq")),
5456
5475
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
5457
5476
  children: [
5458
5477
  "Switch to ",
5459
- get(f, "mq").toUpperCase()
5478
+ get(h, "mq").toUpperCase()
5460
5479
  ]
5461
5480
  }
5462
5481
  )
@@ -5473,7 +5492,7 @@ const COLOR_PROP = {
5473
5492
  units: i = basicUnits,
5474
5493
  negative: d = !1
5475
5494
  }) => {
5476
- const { t: c } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(), f = useCallback((m) => map(g, "property").includes(m), [g]);
5495
+ const { t: c } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
5477
5496
  return /* @__PURE__ */ jsxs(
5478
5497
  "div",
5479
5498
  {
@@ -5481,18 +5500,18 @@ const COLOR_PROP = {
5481
5500
  children: [
5482
5501
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
5483
5502
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: c(o) }),
5484
- /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: h }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5503
+ /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5485
5504
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5486
5505
  "button",
5487
5506
  {
5488
5507
  type: "button",
5489
- onClick: () => u(h),
5490
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
5508
+ onClick: () => u(f),
5509
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
5491
5510
  children: [
5492
5511
  React__default.createElement("div", {
5493
- className: f(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
5512
+ className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
5494
5513
  }),
5495
- React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
5514
+ React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
5496
5515
  ]
5497
5516
  }
5498
5517
  ) }),
@@ -5652,7 +5671,7 @@ const COLOR_PROP = {
5652
5671
  canvas: r = !1,
5653
5672
  tooltip: n = !0
5654
5673
  }) => {
5655
- const [a, , l] = useScreenSizeWidth(), [i, d] = useCanvasDisplayWidth(), [c, p] = useSelectedBreakpoints(), u = c, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (b) => {
5674
+ const [a, , l] = useScreenSizeWidth(), [i, d] = useCanvasDisplayWidth(), [c, p] = useSelectedBreakpoints(), u = c, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
5656
5675
  u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
5657
5676
  }, x = (b) => {
5658
5677
  r || l(b), d(b);
@@ -5685,15 +5704,15 @@ const COLOR_PROP = {
5685
5704
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5686
5705
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
5687
5706
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5688
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
5707
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
5689
5708
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5690
5709
  map(m, (b) => /* @__PURE__ */ jsx(
5691
5710
  DropdownMenuCheckboxItem,
5692
5711
  {
5693
5712
  disabled: b.breakpoint === "xs",
5694
- onCheckedChange: () => h(toUpper(b.breakpoint)),
5713
+ onCheckedChange: () => f(toUpper(b.breakpoint)),
5695
5714
  checked: includes(u, toUpper(b.breakpoint)),
5696
- children: f(b.title)
5715
+ children: h(b.title)
5697
5716
  },
5698
5717
  b.breakpoint
5699
5718
  ))
@@ -5775,9 +5794,9 @@ const AskAIStyles = ({ blockId: o }) => {
5775
5794
  var m;
5776
5795
  (m = c.current) == null || m.focus();
5777
5796
  }, []);
5778
- const f = (m) => {
5779
- const { usage: h } = m || {};
5780
- !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || d("");
5797
+ const h = (m) => {
5798
+ const { usage: f } = m || {};
5799
+ !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || d("");
5781
5800
  };
5782
5801
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
5783
5802
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
@@ -5791,7 +5810,7 @@ const AskAIStyles = ({ blockId: o }) => {
5791
5810
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5792
5811
  rows: 4,
5793
5812
  onKeyDown: (m) => {
5794
- m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, f));
5813
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, h));
5795
5814
  }
5796
5815
  }
5797
5816
  ),
@@ -5801,7 +5820,7 @@ const AskAIStyles = ({ blockId: o }) => {
5801
5820
  {
5802
5821
  disabled: i.trim().length < 5 || a,
5803
5822
  onClick: () => {
5804
- p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, f);
5823
+ p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, h);
5805
5824
  },
5806
5825
  variant: "default",
5807
5826
  className: "w-fit",
@@ -5833,9 +5852,9 @@ const AskAIStyles = ({ blockId: o }) => {
5833
5852
  };
5834
5853
  function ManualClasses() {
5835
5854
  var T;
5836
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: d } = useTranslation(), [c] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), y = (T = first(c)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), w = () => {
5837
- const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5838
- u(f, I, !0), x("");
5855
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: d } = useTranslation(), [c] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(c)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), w = () => {
5856
+ const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5857
+ u(h, I, !0), x("");
5839
5858
  }, [A, E] = useState([]), _ = ({ value: I }) => {
5840
5859
  const P = I.trim().toLowerCase(), L = P.match(/.+:/g);
5841
5860
  let O = [];
@@ -5858,18 +5877,18 @@ function ManualClasses() {
5858
5877
  autoCapitalize: "off",
5859
5878
  spellCheck: !1,
5860
5879
  placeholder: d("Enter classes separated by space"),
5861
- value: h,
5880
+ value: f,
5862
5881
  onKeyDown: (I) => {
5863
- I.key === "Enter" && h.trim() !== "" && w();
5882
+ I.key === "Enter" && f.trim() !== "" && w();
5864
5883
  },
5865
5884
  onChange: (I, { newValue: P }) => x(P),
5866
5885
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5867
5886
  }),
5868
- [h, d, o]
5887
+ [f, d, o]
5869
5888
  ), k = (I) => {
5870
5889
  debugger;
5871
5890
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5872
- g(f, [I]), u(f, P, !0), n(""), l(-1);
5891
+ g(h, [I]), u(h, P, !0), n(""), l(-1);
5873
5892
  }, j = () => {
5874
5893
  if (navigator.clipboard === void 0) {
5875
5894
  toast.error(d("Clipboard not supported"));
@@ -5920,7 +5939,7 @@ function ManualClasses() {
5920
5939
  variant: "outline",
5921
5940
  className: "h-6 border-border",
5922
5941
  onClick: w,
5923
- disabled: h.trim() === "",
5942
+ disabled: f.trim() === "",
5924
5943
  size: "sm",
5925
5944
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5926
5945
  }
@@ -5951,7 +5970,7 @@ function ManualClasses() {
5951
5970
  r !== I && /* @__PURE__ */ jsx(
5952
5971
  Cross2Icon,
5953
5972
  {
5954
- onClick: () => g(f, [I], !0),
5973
+ onClick: () => g(h, [I], !0),
5955
5974
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5956
5975
  }
5957
5976
  )
@@ -6071,13 +6090,13 @@ function BlockStyling() {
6071
6090
  cssProperty: ""
6072
6091
  }), c = useThrottledCallback(
6073
6092
  (u) => {
6074
- const g = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6093
+ const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6075
6094
  let m = parseFloat(i.dragStartValue);
6076
6095
  m = isNaN(m) ? 0 : m;
6077
- let h = MAPPER[i.dragUnit];
6078
- (startsWith(f, "scale") || f === "opacity") && (h = 10);
6079
- let y = (i.dragStartY - u.pageY) / h + m;
6080
- g && y < 0 && (y = 0), f === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6096
+ let f = MAPPER[i.dragUnit];
6097
+ (startsWith(h, "scale") || h === "opacity") && (f = 10);
6098
+ let y = (i.dragStartY - u.pageY) / f + m;
6099
+ g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6081
6100
  },
6082
6101
  [i],
6083
6102
  50
@@ -6118,14 +6137,14 @@ const CoreBlock = ({
6118
6137
  parentId: n,
6119
6138
  position: a
6120
6139
  }) => {
6121
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6140
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6122
6141
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6123
6142
  const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6124
6143
  u(syncBlocksWithDefaults(y), n || null, a);
6125
6144
  } else
6126
6145
  p(o, n || null, a);
6127
6146
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6128
- }, h = useFeature("dnd"), { t: x } = useTranslation();
6147
+ }, f = useFeature("dnd"), { t: x } = useTranslation();
6129
6148
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6130
6149
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6131
6150
  "button",
@@ -6135,10 +6154,10 @@ const CoreBlock = ({
6135
6154
  type: "button",
6136
6155
  onDragStart: (y) => {
6137
6156
  y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6138
- g([]), f();
6157
+ g([]), h();
6139
6158
  }, 200);
6140
6159
  },
6141
- draggable: h ? "true" : "false",
6160
+ draggable: f ? "true" : "false",
6142
6161
  className: "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",
6143
6162
  children: [
6144
6163
  createElement(d || BoxIcon, { className: "w-4 h-4 mx-auto" }),
@@ -6334,7 +6353,7 @@ const CoreBlock = ({
6334
6353
  }
6335
6354
  }
6336
6355
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6337
- var f, m, h, x, y, b, v, w;
6356
+ var h, m, f, x, y, b, v, w;
6338
6357
  if (n.type === "comment") return [];
6339
6358
  console.log("node ===>", n);
6340
6359
  let a = { _id: generateUUID() };
@@ -6375,9 +6394,9 @@ const CoreBlock = ({
6375
6394
  ];
6376
6395
  a = {
6377
6396
  ...a,
6378
- href: ((f = l.find((E) => E.key === "href")) == null ? void 0 : f.value) || "",
6397
+ href: ((h = l.find((E) => E.key === "href")) == null ? void 0 : h.value) || "",
6379
6398
  hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6380
- autoplay: ((h = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
6399
+ autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6381
6400
  maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
6382
6401
  backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
6383
6402
  galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
@@ -6516,7 +6535,7 @@ const BlockCard = ({
6516
6535
  parentId: n = void 0,
6517
6536
  position: a = -1
6518
6537
  }) => {
6519
- const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = get(o, "description", ""), h = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (w) => {
6538
+ const [l, i] = useState(!1), d = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: c, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (w) => {
6520
6539
  const A = has(w, "styles_attrs.data-page-section");
6521
6540
  return w._type === "Box" && A;
6522
6541
  }, b = useCallback(
@@ -6537,7 +6556,7 @@ const BlockCard = ({
6537
6556
  {
6538
6557
  onClick: l ? () => {
6539
6558
  } : b,
6540
- draggable: h ? "true" : "false",
6559
+ draggable: f ? "true" : "false",
6541
6560
  onDragStart: async (w) => {
6542
6561
  const A = await d(r, o);
6543
6562
  let E = n;
@@ -6563,35 +6582,35 @@ const BlockCard = ({
6563
6582
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
6564
6583
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
6565
6584
  ] }),
6566
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: f }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
6567
- /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: f }),
6585
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
6586
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
6568
6587
  m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
6569
6588
  ] })
6570
6589
  ]
6571
6590
  }
6572
6591
  ) }),
6573
6592
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
6574
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: f }),
6593
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
6575
6594
  m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
6576
6595
  ] }) })
6577
6596
  ] });
6578
6597
  }, UILibrarySection = ({ parentId: o, position: r }) => {
6579
- const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: d, isLoading: c, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [f, m] = useState([]), h = useRef(null);
6598
+ const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: d, isLoading: c, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
6580
6599
  useEffect(() => {
6581
- d && d.length > 0 && (h.current = new Fuse(d, {
6600
+ d && d.length > 0 && (f.current = new Fuse(d, {
6582
6601
  keys: ["name", "label", "description", "group"],
6583
6602
  threshold: 0.4,
6584
6603
  ignoreLocation: !0
6585
6604
  }));
6586
6605
  }, [d]), useEffect(() => {
6587
- if (!u.trim() || !h.current) {
6606
+ if (!u.trim() || !f.current) {
6588
6607
  m([]);
6589
6608
  return;
6590
6609
  }
6591
- const k = h.current.search(u).map((j) => j.item);
6610
+ const k = f.current.search(u).map((j) => j.item);
6592
6611
  m(k);
6593
6612
  }, [u]);
6594
- const x = u.trim() && !isEmpty(f) ? f : d, y = groupBy(x, "group"), [b, v] = useState(null);
6613
+ const x = u.trim() && !isEmpty(h) ? h : d, y = groupBy(x, "group"), [b, v] = useState(null);
6595
6614
  useEffect(() => {
6596
6615
  if (isEmpty(keys(y))) {
6597
6616
  v(null);
@@ -6746,10 +6765,10 @@ const BlockCard = ({
6746
6765
  // Store the original ID as partialBlockId
6747
6766
  _name: b.name
6748
6767
  };
6749
- }), h = uniq(map(m, "group"));
6768
+ }), f = uniq(map(m, "group"));
6750
6769
  p({
6751
6770
  blocks: m,
6752
- groups: h,
6771
+ groups: f,
6753
6772
  isLoading: !1,
6754
6773
  error: null
6755
6774
  }), g(!0);
@@ -6768,7 +6787,7 @@ const BlockCard = ({
6768
6787
  c.blocks,
6769
6788
  d
6770
6789
  ]);
6771
- const f = () => {
6790
+ const h = () => {
6772
6791
  p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
6773
6792
  };
6774
6793
  return c.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : c.error || c.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
@@ -6776,7 +6795,7 @@ const BlockCard = ({
6776
6795
  /* @__PURE__ */ jsx(
6777
6796
  "button",
6778
6797
  {
6779
- onClick: f,
6798
+ onClick: h,
6780
6799
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
6781
6800
  children: "Refresh"
6782
6801
  }
@@ -6795,7 +6814,7 @@ const BlockCard = ({
6795
6814
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
6796
6815
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
6797
6816
  var C;
6798
- const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (C = find(d, (k) => k._id === n)) == null ? void 0 : C._type, [m, h] = useState("all"), [x, y] = useState(null), b = useRef(null);
6817
+ const { t: i } = useTranslation(), [d] = useBlocksStore(), [c, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(d, (k) => k._id === n)) == null ? void 0 : C._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
6799
6818
  useEffect(() => {
6800
6819
  const k = setTimeout(() => {
6801
6820
  var j;
@@ -6803,9 +6822,9 @@ const BlockCard = ({
6803
6822
  }, 0);
6804
6823
  return () => clearTimeout(k);
6805
6824
  }, [g]), useEffect(() => {
6806
- c && (h("all"), y(null));
6825
+ c && (f("all"), y(null));
6807
6826
  }, [c]), useEffect(() => (b.current = debounce((k) => {
6808
- h(k);
6827
+ f(k);
6809
6828
  }, 500), () => {
6810
6829
  b.current && b.current.cancel();
6811
6830
  }), []);
@@ -6814,7 +6833,7 @@ const BlockCard = ({
6814
6833
  }, []), w = useCallback(() => {
6815
6834
  y(null), b.current && b.current.cancel();
6816
6835
  }, []), A = useCallback((k) => {
6817
- b.current && b.current.cancel(), h(k), y(null);
6836
+ b.current && b.current.cancel(), f(k), y(null);
6818
6837
  }, []), E = useMemo(
6819
6838
  () => c ? values(r).filter(
6820
6839
  (k) => {
@@ -6885,7 +6904,7 @@ const BlockCard = ({
6885
6904
  parentId: n,
6886
6905
  position: a,
6887
6906
  block: j,
6888
- disabled: !canAcceptChildBlock(f, j.type) || !canBeNestedInside(f, j.type)
6907
+ disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
6889
6908
  },
6890
6909
  j.type
6891
6910
  )) })
@@ -6898,13 +6917,13 @@ const BlockCard = ({
6898
6917
  parentId: n = void 0,
6899
6918
  position: a = -1
6900
6919
  }) => {
6901
- const { t: l } = useTranslation(), [i, d] = useAtom$1(addBlockTabAtom), [, c] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: f } = usePermissions();
6920
+ const { t: l } = useTranslation(), [i, d] = useAtom$1(addBlockTabAtom), [, c] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: h } = usePermissions();
6902
6921
  useEffect(() => {
6903
6922
  i === "partials" && !g && d("library");
6904
6923
  }, [i, g, d]);
6905
6924
  const m = useCallback(() => {
6906
6925
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6907
- }, []), h = useChaiAddBlockTabs(), x = p && f(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
6926
+ }, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
6908
6927
  return useEffect(() => {
6909
6928
  i === "library" && !b && d("core");
6910
6929
  }, [i, b, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -6926,13 +6945,13 @@ const BlockCard = ({
6926
6945
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
6927
6946
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
6928
6947
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
6929
- map(h, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
6948
+ map(f, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
6930
6949
  ] }),
6931
6950
  /* @__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: n, position: a }) }) }) }),
6932
6951
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
6933
6952
  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: n, position: a }) }) }) }),
6934
6953
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
6935
- map(h, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
6954
+ map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
6936
6955
  ]
6937
6956
  }
6938
6957
  )
@@ -7054,7 +7073,7 @@ const registerChaiSaveToLibrary = (o) => {
7054
7073
  }, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
7055
7074
  const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), d = useSelectedBlock(), c = useCallback(() => {
7056
7075
  const p = r.map((u) => {
7057
- const g = o.find((f) => f._id === u);
7076
+ const g = o.find((h) => h._id === u);
7058
7077
  return {
7059
7078
  id: u,
7060
7079
  data: g
@@ -7239,7 +7258,7 @@ const Input = ({ node: o }) => {
7239
7258
  var P;
7240
7259
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
7241
7260
  let p = null;
7242
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: w } = o, A = (L) => {
7261
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: w } = o, A = (L) => {
7243
7262
  L.stopPropagation(), !l.includes(m) && o.toggle();
7244
7263
  }, E = (L) => {
7245
7264
  L.isInternal && (p = L.isOpen, L.isOpen && L.close());
@@ -7287,12 +7306,12 @@ const Input = ({ node: o }) => {
7287
7306
  ),
7288
7307
  /* @__PURE__ */ jsx("br", {})
7289
7308
  ] });
7290
- const I = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, c]);
7309
+ const I = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, c]);
7291
7310
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7292
7311
  "div",
7293
7312
  {
7294
7313
  onMouseEnter: () => g(m),
7295
- onMouseLeave: () => f(),
7314
+ onMouseLeave: () => h(),
7296
7315
  onClick: k,
7297
7316
  style: r,
7298
7317
  "data-node-id": m,
@@ -7327,7 +7346,7 @@ const Input = ({ node: o }) => {
7327
7346
  className: cn(
7328
7347
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7329
7348
  x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7330
- y && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7349
+ y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7331
7350
  (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7332
7351
  b && "opacity-20",
7333
7352
  l.includes(m) ? "opacity-50" : "",
@@ -7351,7 +7370,7 @@ const Input = ({ node: o }) => {
7351
7370
  I && x && "text-primary/80"
7352
7371
  ),
7353
7372
  children: [
7354
- /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7373
+ /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7355
7374
  v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7356
7375
  "div",
7357
7376
  {
@@ -7359,7 +7378,7 @@ const Input = ({ node: o }) => {
7359
7378
  onDoubleClick: (L) => {
7360
7379
  L.stopPropagation(), o.edit(), o.deselect();
7361
7380
  },
7362
- children: /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) })
7381
+ children: /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) })
7363
7382
  }
7364
7383
  )
7365
7384
  ]
@@ -7367,7 +7386,7 @@ const Input = ({ node: o }) => {
7367
7386
  )
7368
7387
  ] }),
7369
7388
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7370
- canAddChildBlock(h == null ? void 0 : h._type) && !l.includes(m) && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7389
+ canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7371
7390
  /* @__PURE__ */ jsx(
7372
7391
  TooltipTrigger,
7373
7392
  {
@@ -7658,7 +7677,7 @@ const Input = ({ node: o }) => {
7658
7677
  )
7659
7678
  ] });
7660
7679
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
7661
- const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), [c, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), f = (v) => {
7680
+ const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: d } = usePermissions(), [c, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), h = (v) => {
7662
7681
  a(v);
7663
7682
  }, m = () => {
7664
7683
  const v = l.find((w) => Object.keys(w)[0] === n);
@@ -7667,7 +7686,7 @@ const Input = ({ node: o }) => {
7667
7686
  w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? p(w) : console.error("Invalid preset structure:", w);
7668
7687
  } else
7669
7688
  console.error("Preset not found:", n);
7670
- }, h = useDebouncedCallback(
7689
+ }, f = useDebouncedCallback(
7671
7690
  (v, w) => {
7672
7691
  p(() => ({
7673
7692
  ...c,
@@ -7725,7 +7744,7 @@ const Input = ({ node: o }) => {
7725
7744
  "select",
7726
7745
  {
7727
7746
  value: n,
7728
- onChange: (v) => f(v.target.value),
7747
+ onChange: (v) => h(v.target.value),
7729
7748
  className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
7730
7749
  children: [
7731
7750
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
@@ -7751,7 +7770,7 @@ const Input = ({ node: o }) => {
7751
7770
  {
7752
7771
  label: v,
7753
7772
  value: c.fontFamily[v.replace(/font-/g, "")] || w[Object.keys(w)[0]],
7754
- onChange: (A) => h(v, A)
7773
+ onChange: (A) => f(v, A)
7755
7774
  },
7756
7775
  v
7757
7776
  )) }),
@@ -8234,12 +8253,12 @@ function QuickPrompts({ onClick: o }) {
8234
8253
  ) }) });
8235
8254
  }
8236
8255
  const AIUserPrompt = ({ blockId: o }) => {
8237
- const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(), f = useRef(null), m = useRef(null);
8256
+ const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, d] = useState(""), [c, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
8238
8257
  useEffect(() => {
8239
8258
  var x;
8240
- (x = f.current) == null || x.focus();
8259
+ (x = h.current) == null || x.focus();
8241
8260
  }, []);
8242
- const h = (x) => {
8261
+ const f = (x) => {
8243
8262
  const { usage: y } = x || {};
8244
8263
  !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || d("");
8245
8264
  };
@@ -8259,14 +8278,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8259
8278
  /* @__PURE__ */ jsx(
8260
8279
  Textarea,
8261
8280
  {
8262
- ref: f,
8281
+ ref: h,
8263
8282
  value: i,
8264
8283
  onChange: (x) => d(x.target.value),
8265
8284
  placeholder: r("Ask AI to edit content"),
8266
8285
  className: "w-full",
8267
8286
  rows: 3,
8268
8287
  onKeyDown: (x) => {
8269
- x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, h));
8288
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
8270
8289
  }
8271
8290
  }
8272
8291
  ),
@@ -8276,7 +8295,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8276
8295
  {
8277
8296
  disabled: i.trim().length < 5 || a,
8278
8297
  onClick: () => {
8279
- m.current && clearTimeout(m.current), g(void 0), n("content", o, i, h);
8298
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
8280
8299
  },
8281
8300
  variant: "default",
8282
8301
  className: "w-fit",
@@ -8309,7 +8328,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8309
8328
  QuickPrompts,
8310
8329
  {
8311
8330
  onClick: (x) => {
8312
- m.current && clearTimeout(m.current), g(void 0), n("content", o, x, h);
8331
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
8313
8332
  }
8314
8333
  }
8315
8334
  )
@@ -8319,15 +8338,15 @@ const AIUserPrompt = ({ blockId: o }) => {
8319
8338
  ] }) }) : null
8320
8339
  ] });
8321
8340
  }, AISetContext = () => {
8322
- const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), f = useRef(null);
8341
+ const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [d, c] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
8323
8342
  useEffect(() => {
8324
8343
  r && a(r);
8325
8344
  }, [r]);
8326
8345
  const m = async () => {
8327
8346
  try {
8328
- c(!0), u(null), await i(n), toast.success(o("Updated AI Context")), f.current.click();
8329
- } catch (h) {
8330
- u(h);
8347
+ c(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
8348
+ } catch (f) {
8349
+ u(f);
8331
8350
  } finally {
8332
8351
  c(!1);
8333
8352
  }
@@ -8335,25 +8354,25 @@ const AIUserPrompt = ({ blockId: o }) => {
8335
8354
  return /* @__PURE__ */ jsx(
8336
8355
  Accordion,
8337
8356
  {
8338
- onValueChange: (h) => {
8339
- g(h !== "");
8357
+ onValueChange: (f) => {
8358
+ g(f !== "");
8340
8359
  },
8341
8360
  type: "single",
8342
8361
  collapsible: !0,
8343
8362
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8344
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: f, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8363
+ /* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8345
8364
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8346
8365
  /* @__PURE__ */ jsx(
8347
8366
  Textarea,
8348
8367
  {
8349
8368
  ref: l,
8350
8369
  value: n,
8351
- onChange: (h) => a(h.target.value),
8370
+ onChange: (f) => a(f.target.value),
8352
8371
  placeholder: o("Tell about this page eg this page is about"),
8353
8372
  className: "mt-1 w-full",
8354
8373
  rows: 10,
8355
- onKeyDown: (h) => {
8356
- h.key === "Enter" && (h.preventDefault(), m());
8374
+ onKeyDown: (f) => {
8375
+ f.key === "Enter" && (f.preventDefault(), m());
8357
8376
  }
8358
8377
  }
8359
8378
  ),
@@ -8455,7 +8474,7 @@ function AIChatPanel() {
8455
8474
  }, [o]), useEffect(() => {
8456
8475
  g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
8457
8476
  }, [n]);
8458
- const f = async () => {
8477
+ const h = async () => {
8459
8478
  if (!n.trim() && !d) return;
8460
8479
  const b = {
8461
8480
  id: Date.now().toString(),
@@ -8473,8 +8492,8 @@ function AIChatPanel() {
8473
8492
  r((w) => [...w, v]), i(!1), c(null);
8474
8493
  }, 1500);
8475
8494
  }, m = (b) => {
8476
- b.key === "Enter" && !b.shiftKey && (b.preventDefault(), f());
8477
- }, h = (b) => {
8495
+ b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
8496
+ }, f = (b) => {
8478
8497
  var w;
8479
8498
  const v = (w = b.target.files) == null ? void 0 : w[0];
8480
8499
  if (v) {
@@ -8551,7 +8570,7 @@ function AIChatPanel() {
8551
8570
  className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
8552
8571
  }
8553
8572
  ),
8554
- /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: h, accept: "image/*", className: "hidden" }),
8573
+ /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
8555
8574
  /* @__PURE__ */ jsx(
8556
8575
  Button,
8557
8576
  {
@@ -8568,7 +8587,7 @@ function AIChatPanel() {
8568
8587
  {
8569
8588
  size: "sm",
8570
8589
  className: "h-10 px-3",
8571
- onClick: f,
8590
+ onClick: h,
8572
8591
  disabled: l || !n.trim() && !d,
8573
8592
  children: [
8574
8593
  /* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
@@ -8683,7 +8702,7 @@ const AddBlocksDialog = () => {
8683
8702
  preloadedAttributes: r = [],
8684
8703
  onAttributesChange: n
8685
8704
  }) {
8686
- const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null), y = usePageExternalData();
8705
+ const [a, l] = useState([]), [i, d] = useState(""), [c, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
8687
8706
  useEffect(() => {
8688
8707
  l(r);
8689
8708
  }, [r]);
@@ -8752,7 +8771,7 @@ const AddBlocksDialog = () => {
8752
8771
  autoCorrect: "off",
8753
8772
  spellCheck: "false",
8754
8773
  id: "attrKey",
8755
- ref: h,
8774
+ ref: f,
8756
8775
  value: i,
8757
8776
  onChange: (S) => d(S.target.value),
8758
8777
  placeholder: "Enter Key",
@@ -8784,7 +8803,7 @@ const AddBlocksDialog = () => {
8784
8803
  ] })
8785
8804
  ] }),
8786
8805
  /* @__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" }) }),
8787
- f && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: f })
8806
+ h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
8788
8807
  ]
8789
8808
  }
8790
8809
  ),
@@ -8917,9 +8936,9 @@ const RootLayout = () => {
8917
8936
  });
8918
8937
  const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = (S) => {
8919
8938
  S.preventDefault();
8920
- }, f = (S) => {
8939
+ }, h = (S) => {
8921
8940
  n(r === S ? null : S);
8922
- }, m = useSidebarMenuItems(), { t: h } = useTranslation(), x = useMemo(() => [...m, ...p], [m, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
8941
+ }, m = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...m, ...p], [m, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
8923
8942
  useEffect(() => {
8924
8943
  if (r !== null) {
8925
8944
  const S = find(x, { id: r });
@@ -8940,9 +8959,9 @@ const RootLayout = () => {
8940
8959
  }, [r, x]);
8941
8960
  const _ = useCallback(
8942
8961
  (S) => {
8943
- f(S);
8962
+ h(S);
8944
8963
  },
8945
- [f]
8964
+ [h]
8946
8965
  );
8947
8966
  return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
8948
8967
  /* @__PURE__ */ jsxs(
@@ -8961,7 +8980,7 @@ const RootLayout = () => {
8961
8980
  isActive: r === S.id,
8962
8981
  show: () => _(S.id)
8963
8982
  }) }),
8964
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(S.label) }) })
8983
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
8965
8984
  ] }, "button-top-" + B)) }),
8966
8985
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
8967
8986
  /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((S, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -8971,7 +8990,7 @@ const RootLayout = () => {
8971
8990
  isActive: r === S.id,
8972
8991
  show: () => _(S.id)
8973
8992
  }) }),
8974
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(S.label) }) })
8993
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
8975
8994
  ] }, "button-bottom-" + B)) })
8976
8995
  ] }),
8977
8996
  /* @__PURE__ */ jsx(
@@ -8987,7 +9006,7 @@ const RootLayout = () => {
8987
9006
  "div",
8988
9007
  {
8989
9008
  className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
8990
- children: /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9009
+ children: /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
8991
9010
  }
8992
9011
  ),
8993
9012
  /* @__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(b, "panel", NoopComponent), {}) }) })
@@ -9010,11 +9029,11 @@ const RootLayout = () => {
9010
9029
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: d === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9011
9030
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9012
9031
  " ",
9013
- h("AI Assistant")
9032
+ f("AI Assistant")
9014
9033
  ] }) }) : d === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9015
9034
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9016
9035
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9017
- h("Theme Settings")
9036
+ f("Theme Settings")
9018
9037
  ] }),
9019
9038
  /* @__PURE__ */ jsx(
9020
9039
  Button,
@@ -9034,7 +9053,7 @@ const RootLayout = () => {
9034
9053
  r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${v}px` }, children: [
9035
9054
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9036
9055
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9037
- /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9056
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9038
9057
  ] }) }),
9039
9058
  /* @__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(b, "panel", NoopComponent), {
9040
9059
  close: E
@@ -9044,7 +9063,7 @@ const RootLayout = () => {
9044
9063
  r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => A(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${v}px` }, children: [
9045
9064
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9046
9065
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9047
- /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9066
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9048
9067
  ] }) }),
9049
9068
  /* @__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(b, "panel", NoopComponent), {
9050
9069
  close: E
@@ -9070,7 +9089,7 @@ const RootLayout = () => {
9070
9089
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-border p-4 py-2", children: [
9071
9090
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-lg font-bold", children: [
9072
9091
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9073
- /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9092
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9074
9093
  ] }),
9075
9094
  /* @__PURE__ */ jsx(Button, { onClick: () => A(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9076
9095
  ] }),
@@ -9177,17 +9196,17 @@ const FEATURE_TOGGLES = {
9177
9196
  for (const i of r.p)
9178
9197
  l.add(i);
9179
9198
  return l;
9180
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), d = {}, c = (m, ...h) => m.read(...h), p = (m, ...h) => m.write(...h), u = (m, h) => {
9199
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), d = {}, c = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
9181
9200
  var x;
9182
- return (x = m.unstable_onInit) == null ? void 0 : x.call(m, h);
9183
- }, g = (m, h) => {
9201
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
9202
+ }, g = (m, f) => {
9184
9203
  var x;
9185
- return (x = m.onMount) == null ? void 0 : x.call(m, h);
9186
- }, ...f) => {
9187
- const m = f[0] || ((B) => {
9204
+ return (x = m.onMount) == null ? void 0 : x.call(m, f);
9205
+ }, ...h) => {
9206
+ const m = h[0] || ((B) => {
9188
9207
  let N = o.get(B);
9189
9208
  return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, N), u == null || u(B, S)), N;
9190
- }), h = f[1] || (() => {
9209
+ }), f = h[1] || (() => {
9191
9210
  let B, N;
9192
9211
  const C = (k) => {
9193
9212
  try {
@@ -9206,7 +9225,7 @@ const FEATURE_TOGGLES = {
9206
9225
  } while (a.size || i.size || l.size);
9207
9226
  if (B)
9208
9227
  throw N;
9209
- }), x = f[2] || (() => {
9228
+ }), x = h[2] || (() => {
9210
9229
  const B = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9211
9230
  for (; k.length; ) {
9212
9231
  const j = k[k.length - 1], T = m(j);
@@ -9232,7 +9251,7 @@ const FEATURE_TOGGLES = {
9232
9251
  }
9233
9252
  P && (y(T), w(T)), n.delete(T);
9234
9253
  }
9235
- }), y = f[3] || ((B) => {
9254
+ }), y = h[3] || ((B) => {
9236
9255
  var N, C;
9237
9256
  const k = m(B);
9238
9257
  if (isAtomStateInitialized(k) && (r.has(B) && n.get(B) !== k.n || Array.from(k.d).every(
@@ -9246,7 +9265,7 @@ const FEATURE_TOGGLES = {
9246
9265
  k.d.clear();
9247
9266
  let j = !0;
9248
9267
  const T = () => {
9249
- r.has(B) && (w(B), x(), h());
9268
+ r.has(B) && (w(B), x(), f());
9250
9269
  }, I = (R) => {
9251
9270
  var D;
9252
9271
  if (isSelfAtom(B, R)) {
@@ -9276,7 +9295,7 @@ const FEATURE_TOGGLES = {
9276
9295
  try {
9277
9296
  return v(B, ...R);
9278
9297
  } finally {
9279
- x(), h();
9298
+ x(), f();
9280
9299
  }
9281
9300
  }), L;
9282
9301
  }
@@ -9292,7 +9311,7 @@ const FEATURE_TOGGLES = {
9292
9311
  } finally {
9293
9312
  j = !1, $ !== k.n && n.get(B) === $ && (n.set(B, k.n), a.add(B), (C = d.c) == null || C.call(d, B));
9294
9313
  }
9295
- }), b = f[4] || ((B) => {
9314
+ }), b = h[4] || ((B) => {
9296
9315
  const N = [B];
9297
9316
  for (; N.length; ) {
9298
9317
  const C = N.pop(), k = m(C);
@@ -9301,7 +9320,7 @@ const FEATURE_TOGGLES = {
9301
9320
  n.set(j, T.n), N.push(j);
9302
9321
  }
9303
9322
  }
9304
- }), v = f[5] || ((B, ...N) => {
9323
+ }), v = h[5] || ((B, ...N) => {
9305
9324
  let C = !0;
9306
9325
  const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
9307
9326
  var P;
@@ -9316,7 +9335,7 @@ const FEATURE_TOGGLES = {
9316
9335
  } else
9317
9336
  return v(T, ...I);
9318
9337
  } finally {
9319
- C || (x(), h());
9338
+ C || (x(), f());
9320
9339
  }
9321
9340
  };
9322
9341
  try {
@@ -9324,7 +9343,7 @@ const FEATURE_TOGGLES = {
9324
9343
  } finally {
9325
9344
  C = !1;
9326
9345
  }
9327
- }), w = f[6] || ((B) => {
9346
+ }), w = h[6] || ((B) => {
9328
9347
  var N;
9329
9348
  const C = m(B), k = r.get(B);
9330
9349
  if (k && !isPendingPromise(C.v)) {
@@ -9340,7 +9359,7 @@ const FEATURE_TOGGLES = {
9340
9359
  T == null || T.t.delete(B);
9341
9360
  }
9342
9361
  }
9343
- }), A = f[7] || ((B) => {
9362
+ }), A = h[7] || ((B) => {
9344
9363
  var N;
9345
9364
  const C = m(B);
9346
9365
  let k = r.get(B);
@@ -9359,7 +9378,7 @@ const FEATURE_TOGGLES = {
9359
9378
  try {
9360
9379
  return v(B, ...P);
9361
9380
  } finally {
9362
- T || (x(), h());
9381
+ T || (x(), f());
9363
9382
  }
9364
9383
  };
9365
9384
  try {
@@ -9380,7 +9399,7 @@ const FEATURE_TOGGLES = {
9380
9399
  }
9381
9400
  }
9382
9401
  return k;
9383
- }), E = f[8] || ((B) => {
9402
+ }), E = h[8] || ((B) => {
9384
9403
  var N;
9385
9404
  const C = m(B);
9386
9405
  let k = r.get(B);
@@ -9412,7 +9431,7 @@ const FEATURE_TOGGLES = {
9412
9431
  g,
9413
9432
  // building-block functions
9414
9433
  m,
9415
- h,
9434
+ f,
9416
9435
  x,
9417
9436
  y,
9418
9437
  b,
@@ -9426,13 +9445,13 @@ const FEATURE_TOGGLES = {
9426
9445
  try {
9427
9446
  return v(B, ...N);
9428
9447
  } finally {
9429
- x(), h();
9448
+ x(), f();
9430
9449
  }
9431
9450
  },
9432
9451
  sub: (B, N) => {
9433
9452
  const k = A(B).l;
9434
- return k.add(N), h(), () => {
9435
- k.delete(N), E(B), h();
9453
+ return k.add(N), f(), () => {
9454
+ k.delete(N), E(B), f();
9436
9455
  };
9437
9456
  }
9438
9457
  };