@chaibuilder/sdk 2.2.8 → 2.2.10

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
@@ -15,7 +15,7 @@ import { ChevronRight, PlusIcon as PlusIcon$1, DatabaseIcon, ChevronLeft, Chevro
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
17
17
  import TreeModel from "tree-model";
18
- import { S as STYLES_KEY, e as getSplitChaiClasses, a as applyBinding, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as ROOT_TEMP_KEY } from "./new-blocks-render-helpers-BrYtxlrw.js";
18
+ import { S as STYLES_KEY, e as getSplitChaiClasses, a as applyBinding, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as ROOT_TEMP_KEY } from "./new-blocks-render-helpers-DIG03xaR.js";
19
19
  import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, e as getThemeFontsLinkMarkup, h as getThemeCustomFontFace } from "./plugin-fnBB3TCm.js";
20
20
  import Fuse from "fuse.js";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
@@ -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
  });
@@ -760,7 +760,7 @@ const useUndoManager = () => {
760
760
  return {
761
761
  moveBlocks: (x, y, b) => {
762
762
  const v = map(x, (A) => {
763
- const _ = r.find((N) => N._id === A)._parent || null, B = r.filter((N) => _ ? N._parent === _ : !N._parent).map((N) => N._id).indexOf(A);
763
+ const _ = r.find((T) => T._id === A)._parent || null, B = r.filter((T) => _ ? T._parent === _ : !T._parent).map((T) => T._id).indexOf(A);
764
764
  return { _id: A, oldParent: _, oldPosition: B };
765
765
  }), w = v.find(({ _id: A }) => A === x[0]);
766
766
  w && w.oldParent === y && w.oldPosition === b || (i(x, y, b), o({
@@ -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(), T = useMemo(() => B.length === 1 ? "" : `#${get(
3565
3565
  B.find((L) => L._type === "Repeater"),
3566
3566
  "repeaterItems",
3567
3567
  ""
3568
- ).replace(/\{\{(.*)\}\}/g, "$1")}`, [B]), C = useMemo(() => first(get(v, N.replace("#", ""), [])), [N, v]), k = useCallback(
3569
- (I, P) => {
3570
- if (I = isEmpty(N) ? I : I.replace(`${N}.`, "$index."), P === "array" || P === "object") {
3571
- f(`{{${I}}}`, {}, o);
3568
+ ).replace(/\{\{(.*)\}\}/g, "$1")}`, [B]), C = useMemo(() => first(get(v, T.replace("#", ""), [])), [T, v]), k = useCallback(
3569
+ (N, P) => {
3570
+ if (N = isEmpty(T) ? N : N.replace(`${T}.`, "$index."), P === "array" || P === "object") {
3571
+ h(`{{${N}}}`, {}, o);
3572
3572
  return;
3573
3573
  }
3574
3574
  const L = (D) => /[.,!?;:]/.test(D), O = (D, M, H) => {
@@ -3585,7 +3585,7 @@ const JSONFormFieldTemplate = ({
3585
3585
  if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
3586
3586
  const D = R.__chaiRTE;
3587
3587
  if (D) {
3588
- const M = `{{${I}}}`;
3588
+ const M = `{{${N}}}`;
3589
3589
  D.commands.focus();
3590
3590
  const { from: H, to: F } = D.state.selection;
3591
3591
  if (H !== F)
@@ -3597,37 +3597,37 @@ 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
- const G = `{{${I}}}`, { text: Y } = O(H, M, G), q = H.slice(0, M) + Y + H.slice(F);
3607
- f(q, {}, o);
3606
+ const G = `{{${N}}}`, { text: Y } = O(H, M, G), q = H.slice(0, M) + Y + H.slice(F);
3607
+ h(q, {}, o);
3608
3608
  return;
3609
3609
  }
3610
- const U = `{{${I}}}`, { text: V } = O(H, M, U), K = H.slice(0, M) + V + H.slice(M);
3611
- f(K, {}, o);
3610
+ const U = `{{${N}}}`, { text: V } = O(H, M, U), K = H.slice(0, M) + V + H.slice(M);
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, T]
3615
3615
  );
3616
3616
  if (c)
3617
3617
  return null;
3618
3618
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
3619
- const T = E == null ? void 0 : E.includes(o.replace("root.", ""));
3619
+ const I = E == null ? void 0 : E.includes(o.replace("root.", ""));
3620
3620
  if (u.type === "array") {
3621
- const I = _ === o;
3621
+ const N = _ === o;
3622
3622
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
3623
3623
  u.title && /* @__PURE__ */ jsxs(
3624
3624
  "label",
3625
3625
  {
3626
3626
  htmlFor: o,
3627
- onClick: () => S(I ? null : o),
3627
+ onClick: () => S(N ? null : o),
3628
3628
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
3629
3629
  children: [
3630
- I ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
3630
+ N ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
3631
3631
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
3632
3632
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
3633
3633
  " ",
@@ -3635,7 +3635,7 @@ const JSONFormFieldTemplate = ({
3635
3635
  ]
3636
3636
  }
3637
3637
  ),
3638
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${I ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
3638
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${N ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
3639
3639
  d,
3640
3640
  a,
3641
3641
  l,
@@ -3648,7 +3648,7 @@ const JSONFormFieldTemplate = ({
3648
3648
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
3649
3649
  n,
3650
3650
  " ",
3651
- T && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
3651
+ I && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
3652
3652
  " ",
3653
3653
  b
3654
3654
  ] }),
@@ -3658,7 +3658,7 @@ const JSONFormFieldTemplate = ({
3658
3658
  NestedPathSelector,
3659
3659
  {
3660
3660
  data: {
3661
- ...C && { [N]: C },
3661
+ ...C && { [T]: C },
3662
3662
  ...v
3663
3663
  },
3664
3664
  onSelect: k,
@@ -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
  ] })
@@ -3831,8 +3850,8 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3831
3850
  pageTypes: r,
3832
3851
  onChange: n
3833
3852
  }) => {
3834
- 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;
3853
+ var T;
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 = (T = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : T.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,18 +4822,18 @@ 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;
4810
4829
  }
4811
4830
  if (get(k, "value") === "")
4812
4831
  return;
4813
- const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${c}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4814
- C ? S(I) : _(I);
4832
+ const N = `${get(k, "value", "").startsWith("-") ? "-" : ""}${c}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4833
+ C ? S(N) : _(N);
4815
4834
  },
4816
- [_, S, a, f, c, u]
4817
- ), N = useCallback(
4835
+ [_, S, a, h, c, u]
4836
+ ), T = useCallback(
4818
4837
  (C) => {
4819
4838
  const k = getUserInputValues(`${a}`, u);
4820
4839
  if (get(k, "error", !1)) {
@@ -4827,12 +4846,12 @@ const BlockStylingProps = () => {
4827
4846
  }
4828
4847
  if (get(k, "value") === "")
4829
4848
  return;
4830
- const j = get(k, "unit") !== "" ? get(k, "unit") : C, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${c}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4831
- _(I);
4849
+ const j = get(k, "unit") !== "" ? get(k, "unit") : C, N = `${get(k, "value", "").startsWith("-") ? "-" : ""}${c}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4850
+ _(N);
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 I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${c}[${I.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,33 +4918,33 @@ const BlockStylingProps = () => {
4899
4918
  UnitSelection,
4900
4919
  {
4901
4920
  units: u,
4902
- current: f,
4921
+ current: h,
4903
4922
  onSelect: (C) => {
4904
- n(!1), m(C), N(C);
4923
+ n(!1), m(C), T(C);
4905
4924
  }
4906
4925
  }
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}]`;
4918
- _(T);
4936
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
4937
+ _(I);
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}]`;
4925
- S(T);
4943
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${c}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
4944
+ S(I);
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,20 +5404,20 @@ 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
- const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5391
- (p || u !== "") && (N.mq = "xs");
5392
- const C = generateFullClsName(N);
5409
+ const T = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5410
+ (p || u !== "") && (T.mq = "xs");
5411
+ const C = generateFullClsName(T);
5393
5412
  m(x, [C], B);
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",
@@ -5832,12 +5851,12 @@ const AskAIStyles = ({ blockId: o }) => {
5832
5851
  ] });
5833
5852
  };
5834
5853
  function ManualClasses() {
5835
- 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("");
5839
- }, [A, E] = useState([]), _ = ({ value: I }) => {
5840
- const P = I.trim().toLowerCase(), L = P.match(/.+:/g);
5854
+ var I;
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 = (I = first(c)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((N) => !isEmpty(N)), w = () => {
5856
+ const N = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5857
+ u(h, N, !0), x("");
5858
+ }, [A, E] = useState([]), _ = ({ value: N }) => {
5859
+ const P = N.trim().toLowerCase(), L = P.match(/.+:/g);
5841
5860
  let O = [];
5842
5861
  if (L && L.length > 0) {
5843
5862
  const [$] = L, R = P.replace($, "");
@@ -5850,7 +5869,7 @@ function ManualClasses() {
5850
5869
  return E(map(O, "item"));
5851
5870
  }, S = () => {
5852
5871
  E([]);
5853
- }, B = (I) => I.name, N = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), C = useMemo(
5872
+ }, B = (N) => N.name, T = (N) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: N.name }), C = useMemo(
5854
5873
  () => ({
5855
5874
  ref: o,
5856
5875
  autoComplete: "off",
@@ -5858,18 +5877,23 @@ function ManualClasses() {
5858
5877
  autoCapitalize: "off",
5859
5878
  spellCheck: !1,
5860
5879
  placeholder: d("Enter classes separated by space"),
5861
- value: h,
5862
- onKeyDown: (I) => {
5863
- I.key === "Enter" && h.trim() !== "" && w();
5880
+ value: f,
5881
+ onFocus: (N) => {
5882
+ setTimeout(() => {
5883
+ N.target && N.target.select();
5884
+ }, 0);
5885
+ },
5886
+ onKeyDown: (N) => {
5887
+ N.key === "Enter" && f.trim() !== "" && w();
5864
5888
  },
5865
- onChange: (I, { newValue: P }) => x(P),
5889
+ onChange: (N, { newValue: P }) => x(P),
5866
5890
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5867
5891
  }),
5868
- [h, d, o]
5869
- ), k = (I) => {
5892
+ [f, d, o]
5893
+ ), k = (N) => {
5870
5894
  debugger;
5871
5895
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5872
- g(f, [I]), u(f, P, !0), n(""), l(-1);
5896
+ g(h, [N]), u(h, P, !0), n(""), l(-1);
5873
5897
  }, j = () => {
5874
5898
  if (navigator.clipboard === void 0) {
5875
5899
  toast.error(d("Clipboard not supported"));
@@ -5902,7 +5926,7 @@ function ManualClasses() {
5902
5926
  onSuggestionsFetchRequested: _,
5903
5927
  onSuggestionsClearRequested: S,
5904
5928
  getSuggestionValue: B,
5905
- renderSuggestion: N,
5929
+ renderSuggestion: T,
5906
5930
  inputProps: C,
5907
5931
  containerProps: {
5908
5932
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
@@ -5920,44 +5944,54 @@ function ManualClasses() {
5920
5944
  variant: "outline",
5921
5945
  className: "h-6 border-border",
5922
5946
  onClick: w,
5923
- disabled: h.trim() === "",
5947
+ disabled: f.trim() === "",
5924
5948
  size: "sm",
5925
5949
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5926
5950
  }
5927
5951
  )
5928
5952
  ] }),
5929
5953
  /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
5930
- (I, P) => a === P ? /* @__PURE__ */ jsx(
5954
+ (N, P) => a === P ? /* @__PURE__ */ jsx(
5931
5955
  "input",
5932
5956
  {
5933
5957
  ref: o,
5934
5958
  value: r,
5935
5959
  onChange: (L) => n(L.target.value),
5936
5960
  onBlur: () => {
5937
- k(I);
5961
+ k(N);
5938
5962
  },
5939
5963
  onKeyDown: (L) => {
5940
- L.key === "Enter" && k(I);
5964
+ L.key === "Enter" && k(N);
5965
+ },
5966
+ onFocus: (L) => {
5967
+ setTimeout(() => {
5968
+ L.target.select();
5969
+ }, 0);
5941
5970
  },
5942
5971
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
5943
5972
  },
5944
- I
5973
+ N
5945
5974
  ) : /* @__PURE__ */ jsxs(
5946
5975
  "button",
5947
5976
  {
5977
+ onDoubleClick: () => {
5978
+ x(N), g(h, [N]), setTimeout(() => {
5979
+ o.current && o.current.focus();
5980
+ }, 10);
5981
+ },
5948
5982
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
5949
5983
  children: [
5950
- I,
5951
- r !== I && /* @__PURE__ */ jsx(
5984
+ N,
5985
+ r !== N && /* @__PURE__ */ jsx(
5952
5986
  Cross2Icon,
5953
5987
  {
5954
- onClick: () => g(f, [I], !0),
5988
+ onClick: () => g(h, [N], !0),
5955
5989
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5956
5990
  }
5957
5991
  )
5958
5992
  ]
5959
5993
  },
5960
- I
5994
+ N
5961
5995
  )
5962
5996
  ) })
5963
5997
  ] });
@@ -6071,13 +6105,13 @@ function BlockStyling() {
6071
6105
  cssProperty: ""
6072
6106
  }), c = useThrottledCallback(
6073
6107
  (u) => {
6074
- const g = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6108
+ const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6075
6109
  let m = parseFloat(i.dragStartValue);
6076
6110
  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}`);
6111
+ let f = MAPPER[i.dragUnit];
6112
+ (startsWith(h, "scale") || h === "opacity") && (f = 10);
6113
+ let y = (i.dragStartY - u.pageY) / f + m;
6114
+ g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6081
6115
  },
6082
6116
  [i],
6083
6117
  50
@@ -6118,14 +6152,14 @@ const CoreBlock = ({
6118
6152
  parentId: n,
6119
6153
  position: a
6120
6154
  }) => {
6121
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6155
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: d, label: c } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6122
6156
  if (console.log("addBlockToPage", o), has(o, "blocks")) {
6123
6157
  const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6124
6158
  u(syncBlocksWithDefaults(y), n || null, a);
6125
6159
  } else
6126
6160
  p(o, n || null, a);
6127
6161
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6128
- }, h = useFeature("dnd"), { t: x } = useTranslation();
6162
+ }, f = useFeature("dnd"), { t: x } = useTranslation();
6129
6163
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6130
6164
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6131
6165
  "button",
@@ -6135,10 +6169,10 @@ const CoreBlock = ({
6135
6169
  type: "button",
6136
6170
  onDragStart: (y) => {
6137
6171
  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();
6172
+ g([]), h();
6139
6173
  }, 200);
6140
6174
  },
6141
- draggable: h ? "true" : "false",
6175
+ draggable: f ? "true" : "false",
6142
6176
  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
6177
  children: [
6144
6178
  createElement(d || BoxIcon, { className: "w-4 h-4 mx-auto" }),
@@ -6334,7 +6368,7 @@ const CoreBlock = ({
6334
6368
  }
6335
6369
  }
6336
6370
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6337
- var f, m, h, x, y, b, v, w;
6371
+ var h, m, f, x, y, b, v, w;
6338
6372
  if (n.type === "comment") return [];
6339
6373
  console.log("node ===>", n);
6340
6374
  let a = { _id: generateUUID() };
@@ -6375,9 +6409,9 @@ const CoreBlock = ({
6375
6409
  ];
6376
6410
  a = {
6377
6411
  ...a,
6378
- href: ((f = l.find((E) => E.key === "href")) == null ? void 0 : f.value) || "",
6412
+ href: ((h = l.find((E) => E.key === "href")) == null ? void 0 : h.value) || "",
6379
6413
  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",
6414
+ autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6381
6415
  maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
6382
6416
  backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
6383
6417
  galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
@@ -6411,7 +6445,7 @@ const CoreBlock = ({
6411
6445
  return hasVideoEmbed(A) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(A)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = A, [a];
6412
6446
  } else if (n.tagName === "svg") {
6413
6447
  const A = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), _ = get(A, "value") ? `[${get(A, "value")}px]` : "24px", S = get(E, "value") ? `[${get(E, "value")}px]` : "24px", B = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
6414
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${_}`, B)}`.trim(), n.attributes = filter(n.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([n]), [a];
6448
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${S} h-${_}`, B)}`.trim(), n.attributes = filter(n.attributes, (T) => !includes(["style", "width", "height", "class"], T.key)), a.icon = stringify([n]), [a];
6415
6449
  } else if (n.tagName == "option" && r && ((w = r.block) == null ? void 0 : w._type) === "Select")
6416
6450
  return r.block.options.push({
6417
6451
  label: getTextContent(n.children),
@@ -6516,7 +6550,7 @@ const BlockCard = ({
6516
6550
  parentId: n = void 0,
6517
6551
  position: a = -1
6518
6552
  }) => {
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) => {
6553
+ 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
6554
  const A = has(w, "styles_attrs.data-page-section");
6521
6555
  return w._type === "Box" && A;
6522
6556
  }, b = useCallback(
@@ -6537,7 +6571,7 @@ const BlockCard = ({
6537
6571
  {
6538
6572
  onClick: l ? () => {
6539
6573
  } : b,
6540
- draggable: h ? "true" : "false",
6574
+ draggable: f ? "true" : "false",
6541
6575
  onDragStart: async (w) => {
6542
6576
  const A = await d(r, o);
6543
6577
  let E = n;
@@ -6563,35 +6597,35 @@ const BlockCard = ({
6563
6597
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
6564
6598
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
6565
6599
  ] }),
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 }),
6600
+ 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: [
6601
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
6568
6602
  m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
6569
6603
  ] })
6570
6604
  ]
6571
6605
  }
6572
6606
  ) }),
6573
6607
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
6574
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: f }),
6608
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
6575
6609
  m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
6576
6610
  ] }) })
6577
6611
  ] });
6578
6612
  }, 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);
6613
+ 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
6614
  useEffect(() => {
6581
- d && d.length > 0 && (h.current = new Fuse(d, {
6615
+ d && d.length > 0 && (f.current = new Fuse(d, {
6582
6616
  keys: ["name", "label", "description", "group"],
6583
6617
  threshold: 0.4,
6584
6618
  ignoreLocation: !0
6585
6619
  }));
6586
6620
  }, [d]), useEffect(() => {
6587
- if (!u.trim() || !h.current) {
6621
+ if (!u.trim() || !f.current) {
6588
6622
  m([]);
6589
6623
  return;
6590
6624
  }
6591
- const k = h.current.search(u).map((j) => j.item);
6625
+ const k = f.current.search(u).map((j) => j.item);
6592
6626
  m(k);
6593
6627
  }, [u]);
6594
- const x = u.trim() && !isEmpty(f) ? f : d, y = groupBy(x, "group"), [b, v] = useState(null);
6628
+ const x = u.trim() && !isEmpty(h) ? h : d, y = groupBy(x, "group"), [b, v] = useState(null);
6595
6629
  useEffect(() => {
6596
6630
  if (isEmpty(keys(y))) {
6597
6631
  v(null);
@@ -6616,7 +6650,7 @@ const BlockCard = ({
6616
6650
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
6617
6651
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
6618
6652
  ] });
6619
- const N = filter(w, (k, j) => j % 2 === 0), C = filter(w, (k, j) => j % 2 === 1);
6653
+ const T = filter(w, (k, j) => j % 2 === 0), C = filter(w, (k, j) => j % 2 === 1);
6620
6654
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
6621
6655
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
6622
6656
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -6677,7 +6711,7 @@ const BlockCard = ({
6677
6711
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
6678
6712
  children: [
6679
6713
  isEmpty(w) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
6680
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
6714
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: T.map((k, j) => /* @__PURE__ */ jsx(
6681
6715
  BlockCard,
6682
6716
  {
6683
6717
  parentId: o,
@@ -6746,10 +6780,10 @@ const BlockCard = ({
6746
6780
  // Store the original ID as partialBlockId
6747
6781
  _name: b.name
6748
6782
  };
6749
- }), h = uniq(map(m, "group"));
6783
+ }), f = uniq(map(m, "group"));
6750
6784
  p({
6751
6785
  blocks: m,
6752
- groups: h,
6786
+ groups: f,
6753
6787
  isLoading: !1,
6754
6788
  error: null
6755
6789
  }), g(!0);
@@ -6768,7 +6802,7 @@ const BlockCard = ({
6768
6802
  c.blocks,
6769
6803
  d
6770
6804
  ]);
6771
- const f = () => {
6805
+ const h = () => {
6772
6806
  p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
6773
6807
  };
6774
6808
  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 +6810,7 @@ const BlockCard = ({
6776
6810
  /* @__PURE__ */ jsx(
6777
6811
  "button",
6778
6812
  {
6779
- onClick: f,
6813
+ onClick: h,
6780
6814
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
6781
6815
  children: "Refresh"
6782
6816
  }
@@ -6795,7 +6829,7 @@ const BlockCard = ({
6795
6829
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
6796
6830
  }, 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
6831
  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);
6832
+ 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
6833
  useEffect(() => {
6800
6834
  const k = setTimeout(() => {
6801
6835
  var j;
@@ -6803,9 +6837,9 @@ const BlockCard = ({
6803
6837
  }, 0);
6804
6838
  return () => clearTimeout(k);
6805
6839
  }, [g]), useEffect(() => {
6806
- c && (h("all"), y(null));
6840
+ c && (f("all"), y(null));
6807
6841
  }, [c]), useEffect(() => (b.current = debounce((k) => {
6808
- h(k);
6842
+ f(k);
6809
6843
  }, 500), () => {
6810
6844
  b.current && b.current.cancel();
6811
6845
  }), []);
@@ -6814,12 +6848,12 @@ const BlockCard = ({
6814
6848
  }, []), w = useCallback(() => {
6815
6849
  y(null), b.current && b.current.cancel();
6816
6850
  }, []), A = useCallback((k) => {
6817
- b.current && b.current.cancel(), h(k), y(null);
6851
+ b.current && b.current.cancel(), f(k), y(null);
6818
6852
  }, []), E = useMemo(
6819
6853
  () => c ? values(r).filter(
6820
6854
  (k) => {
6821
- var j, T;
6822
- return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(c.toLowerCase());
6855
+ var j, I;
6856
+ return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = k.type) == null ? void 0 : I.toLowerCase())).includes(c.toLowerCase());
6823
6857
  }
6824
6858
  ) : r,
6825
6859
  [r, c]
@@ -6831,7 +6865,7 @@ const BlockCard = ({
6831
6865
  ), S = useMemo(
6832
6866
  () => sortBy(_, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
6833
6867
  [_]
6834
- ), B = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), N = useMemo(() => m === "all" ? S : [m], [S, m]);
6868
+ ), B = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), T = useMemo(() => m === "all" ? S : [m], [S, m]);
6835
6869
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
6836
6870
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
6837
6871
  Input$1,
@@ -6874,7 +6908,7 @@ const BlockCard = ({
6874
6908
  ' "',
6875
6909
  c,
6876
6910
  '"'
6877
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6911
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: T.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6878
6912
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
6879
6913
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
6880
6914
  m === "all" ? filter(values(B), { group: k }) : values(B),
@@ -6885,7 +6919,7 @@ const BlockCard = ({
6885
6919
  parentId: n,
6886
6920
  position: a,
6887
6921
  block: j,
6888
- disabled: !canAcceptChildBlock(f, j.type) || !canBeNestedInside(f, j.type)
6922
+ disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
6889
6923
  },
6890
6924
  j.type
6891
6925
  )) })
@@ -6898,13 +6932,13 @@ const BlockCard = ({
6898
6932
  parentId: n = void 0,
6899
6933
  position: a = -1
6900
6934
  }) => {
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();
6935
+ 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
6936
  useEffect(() => {
6903
6937
  i === "partials" && !g && d("library");
6904
6938
  }, [i, g, d]);
6905
6939
  const m = useCallback(() => {
6906
6940
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6907
- }, []), h = useChaiAddBlockTabs(), x = p && f(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
6941
+ }, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
6908
6942
  return useEffect(() => {
6909
6943
  i === "library" && !b && d("core");
6910
6944
  }, [i, b, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -6926,13 +6960,13 @@ const BlockCard = ({
6926
6960
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
6927
6961
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
6928
6962
  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}`))
6963
+ map(f, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
6930
6964
  ] }),
6931
6965
  /* @__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
6966
  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
6967
  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
6968
  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}`))
6969
+ 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
6970
  ]
6937
6971
  }
6938
6972
  )
@@ -7054,7 +7088,7 @@ const registerChaiSaveToLibrary = (o) => {
7054
7088
  }, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
7055
7089
  const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), d = useSelectedBlock(), c = useCallback(() => {
7056
7090
  const p = r.map((u) => {
7057
- const g = o.find((f) => f._id === u);
7091
+ const g = o.find((h) => h._id === u);
7058
7092
  return {
7059
7093
  id: u,
7060
7094
  data: g
@@ -7239,13 +7273,13 @@ const Input = ({ node: o }) => {
7239
7273
  var P;
7240
7274
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
7241
7275
  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) => {
7276
+ 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
7277
  L.stopPropagation(), !l.includes(m) && o.toggle();
7244
7278
  }, E = (L) => {
7245
7279
  L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7246
7280
  }, _ = (L) => {
7247
7281
  L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
7248
- }, [S, B] = useAtom$1(currentAddSelection), N = () => {
7282
+ }, [S, B] = useAtom$1(currentAddSelection), T = () => {
7249
7283
  var L;
7250
7284
  C(), o.parent.isSelected || B((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7251
7285
  }, C = () => {
@@ -7264,7 +7298,7 @@ const Input = ({ node: o }) => {
7264
7298
  R && R.setAttribute("data-drop", O);
7265
7299
  const D = R.getBoundingClientRect(), M = d.getBoundingClientRect();
7266
7300
  D.top >= M.top && D.left >= M.left && D.bottom <= M.bottom && D.right <= M.right || ($.documentElement.scrollTop = R.offsetTop - M.top);
7267
- }, T = (L) => {
7301
+ }, I = (L) => {
7268
7302
  C();
7269
7303
  const O = get(o, "parent.id");
7270
7304
  O !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: O, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
@@ -7276,7 +7310,7 @@ const Input = ({ node: o }) => {
7276
7310
  "div",
7277
7311
  {
7278
7312
  role: "button",
7279
- onClick: () => T(-1),
7313
+ onClick: () => I(-1),
7280
7314
  className: "h-1 rounded bg-primary opacity-0 duration-200 group-hover:opacity-100",
7281
7315
  children: /* @__PURE__ */ jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-primary px-3 py-1 text-[9px] leading-tight text-white hover:bg-primary", children: [
7282
7316
  /* @__PURE__ */ jsx(PlusIcon, { className: "h-2 w-2 stroke-[3]" }),
@@ -7287,12 +7321,12 @@ const Input = ({ node: o }) => {
7287
7321
  ),
7288
7322
  /* @__PURE__ */ jsx("br", {})
7289
7323
  ] });
7290
- const I = useMemo(() => has(h, "_libBlockId") && !isEmpty(h._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [h, c]);
7324
+ const N = useMemo(() => has(f, "_libBlockId") && !isEmpty(f._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [f, c]);
7291
7325
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7292
7326
  "div",
7293
7327
  {
7294
7328
  onMouseEnter: () => g(m),
7295
- onMouseLeave: () => f(),
7329
+ onMouseLeave: () => h(),
7296
7330
  onClick: k,
7297
7331
  style: r,
7298
7332
  "data-node-id": m,
@@ -7313,9 +7347,9 @@ const Input = ({ node: o }) => {
7313
7347
  "div",
7314
7348
  {
7315
7349
  onClick: (L) => {
7316
- L.stopPropagation(), T(o.childIndex);
7350
+ L.stopPropagation(), I(o.childIndex);
7317
7351
  },
7318
- onMouseEnter: N,
7352
+ onMouseEnter: T,
7319
7353
  onMouseLeave: C,
7320
7354
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
7321
7355
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
@@ -7327,11 +7361,11 @@ const Input = ({ node: o }) => {
7327
7361
  className: cn(
7328
7362
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7329
7363
  x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7330
- y && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7364
+ y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7331
7365
  (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7332
7366
  b && "opacity-20",
7333
7367
  l.includes(m) ? "opacity-50" : "",
7334
- I && x && "bg-primary/20 text-primary"
7368
+ N && x && "bg-primary/20 text-primary"
7335
7369
  ),
7336
7370
  children: [
7337
7371
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7347,11 +7381,11 @@ const Input = ({ node: o }) => {
7347
7381
  {
7348
7382
  className: cn(
7349
7383
  "leading-1 flex items-center",
7350
- I && "text-primary/60",
7351
- I && x && "text-primary/80"
7384
+ N && "text-primary/60",
7385
+ N && x && "text-primary/80"
7352
7386
  ),
7353
7387
  children: [
7354
- /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7388
+ /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7355
7389
  v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7356
7390
  "div",
7357
7391
  {
@@ -7359,7 +7393,7 @@ const Input = ({ node: o }) => {
7359
7393
  onDoubleClick: (L) => {
7360
7394
  L.stopPropagation(), o.edit(), o.deselect();
7361
7395
  },
7362
- children: /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) })
7396
+ children: /* @__PURE__ */ jsx("span", { children: (f == null ? void 0 : f._name) || (f == null ? void 0 : f._type.split("/").pop()) })
7363
7397
  }
7364
7398
  )
7365
7399
  ]
@@ -7367,7 +7401,7 @@ const Input = ({ node: o }) => {
7367
7401
  )
7368
7402
  ] }),
7369
7403
  /* @__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: [
7404
+ canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && c(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7371
7405
  /* @__PURE__ */ jsx(
7372
7406
  TooltipTrigger,
7373
7407
  {
@@ -7658,7 +7692,7 @@ const Input = ({ node: o }) => {
7658
7692
  )
7659
7693
  ] });
7660
7694
  }, 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) => {
7695
+ 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
7696
  a(v);
7663
7697
  }, m = () => {
7664
7698
  const v = l.find((w) => Object.keys(w)[0] === n);
@@ -7667,7 +7701,7 @@ const Input = ({ node: o }) => {
7667
7701
  w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? p(w) : console.error("Invalid preset structure:", w);
7668
7702
  } else
7669
7703
  console.error("Preset not found:", n);
7670
- }, h = useDebouncedCallback(
7704
+ }, f = useDebouncedCallback(
7671
7705
  (v, w) => {
7672
7706
  p(() => ({
7673
7707
  ...c,
@@ -7725,7 +7759,7 @@ const Input = ({ node: o }) => {
7725
7759
  "select",
7726
7760
  {
7727
7761
  value: n,
7728
- onChange: (v) => f(v.target.value),
7762
+ onChange: (v) => h(v.target.value),
7729
7763
  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
7764
  children: [
7731
7765
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
@@ -7751,7 +7785,7 @@ const Input = ({ node: o }) => {
7751
7785
  {
7752
7786
  label: v,
7753
7787
  value: c.fontFamily[v.replace(/font-/g, "")] || w[Object.keys(w)[0]],
7754
- onChange: (A) => h(v, A)
7788
+ onChange: (A) => f(v, A)
7755
7789
  },
7756
7790
  v
7757
7791
  )) }),
@@ -8234,12 +8268,12 @@ function QuickPrompts({ onClick: o }) {
8234
8268
  ) }) });
8235
8269
  }
8236
8270
  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);
8271
+ 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
8272
  useEffect(() => {
8239
8273
  var x;
8240
- (x = f.current) == null || x.focus();
8274
+ (x = h.current) == null || x.focus();
8241
8275
  }, []);
8242
- const h = (x) => {
8276
+ const f = (x) => {
8243
8277
  const { usage: y } = x || {};
8244
8278
  !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || d("");
8245
8279
  };
@@ -8259,14 +8293,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8259
8293
  /* @__PURE__ */ jsx(
8260
8294
  Textarea,
8261
8295
  {
8262
- ref: f,
8296
+ ref: h,
8263
8297
  value: i,
8264
8298
  onChange: (x) => d(x.target.value),
8265
8299
  placeholder: r("Ask AI to edit content"),
8266
8300
  className: "w-full",
8267
8301
  rows: 3,
8268
8302
  onKeyDown: (x) => {
8269
- x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, h));
8303
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
8270
8304
  }
8271
8305
  }
8272
8306
  ),
@@ -8276,7 +8310,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8276
8310
  {
8277
8311
  disabled: i.trim().length < 5 || a,
8278
8312
  onClick: () => {
8279
- m.current && clearTimeout(m.current), g(void 0), n("content", o, i, h);
8313
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
8280
8314
  },
8281
8315
  variant: "default",
8282
8316
  className: "w-fit",
@@ -8309,7 +8343,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8309
8343
  QuickPrompts,
8310
8344
  {
8311
8345
  onClick: (x) => {
8312
- m.current && clearTimeout(m.current), g(void 0), n("content", o, x, h);
8346
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
8313
8347
  }
8314
8348
  }
8315
8349
  )
@@ -8319,15 +8353,15 @@ const AIUserPrompt = ({ blockId: o }) => {
8319
8353
  ] }) }) : null
8320
8354
  ] });
8321
8355
  }, 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);
8356
+ 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
8357
  useEffect(() => {
8324
8358
  r && a(r);
8325
8359
  }, [r]);
8326
8360
  const m = async () => {
8327
8361
  try {
8328
- c(!0), u(null), await i(n), toast.success(o("Updated AI Context")), f.current.click();
8329
- } catch (h) {
8330
- u(h);
8362
+ c(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
8363
+ } catch (f) {
8364
+ u(f);
8331
8365
  } finally {
8332
8366
  c(!1);
8333
8367
  }
@@ -8335,25 +8369,25 @@ const AIUserPrompt = ({ blockId: o }) => {
8335
8369
  return /* @__PURE__ */ jsx(
8336
8370
  Accordion,
8337
8371
  {
8338
- onValueChange: (h) => {
8339
- g(h !== "");
8372
+ onValueChange: (f) => {
8373
+ g(f !== "");
8340
8374
  },
8341
8375
  type: "single",
8342
8376
  collapsible: !0,
8343
8377
  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") }) }) }),
8378
+ /* @__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
8379
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8346
8380
  /* @__PURE__ */ jsx(
8347
8381
  Textarea,
8348
8382
  {
8349
8383
  ref: l,
8350
8384
  value: n,
8351
- onChange: (h) => a(h.target.value),
8385
+ onChange: (f) => a(f.target.value),
8352
8386
  placeholder: o("Tell about this page eg this page is about"),
8353
8387
  className: "mt-1 w-full",
8354
8388
  rows: 10,
8355
- onKeyDown: (h) => {
8356
- h.key === "Enter" && (h.preventDefault(), m());
8389
+ onKeyDown: (f) => {
8390
+ f.key === "Enter" && (f.preventDefault(), m());
8357
8391
  }
8358
8392
  }
8359
8393
  ),
@@ -8455,7 +8489,7 @@ function AIChatPanel() {
8455
8489
  }, [o]), useEffect(() => {
8456
8490
  g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
8457
8491
  }, [n]);
8458
- const f = async () => {
8492
+ const h = async () => {
8459
8493
  if (!n.trim() && !d) return;
8460
8494
  const b = {
8461
8495
  id: Date.now().toString(),
@@ -8473,8 +8507,8 @@ function AIChatPanel() {
8473
8507
  r((w) => [...w, v]), i(!1), c(null);
8474
8508
  }, 1500);
8475
8509
  }, m = (b) => {
8476
- b.key === "Enter" && !b.shiftKey && (b.preventDefault(), f());
8477
- }, h = (b) => {
8510
+ b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
8511
+ }, f = (b) => {
8478
8512
  var w;
8479
8513
  const v = (w = b.target.files) == null ? void 0 : w[0];
8480
8514
  if (v) {
@@ -8551,7 +8585,7 @@ function AIChatPanel() {
8551
8585
  className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
8552
8586
  }
8553
8587
  ),
8554
- /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: h, accept: "image/*", className: "hidden" }),
8588
+ /* @__PURE__ */ jsx("input", { type: "file", ref: p, onChange: f, accept: "image/*", className: "hidden" }),
8555
8589
  /* @__PURE__ */ jsx(
8556
8590
  Button,
8557
8591
  {
@@ -8568,7 +8602,7 @@ function AIChatPanel() {
8568
8602
  {
8569
8603
  size: "sm",
8570
8604
  className: "h-10 px-3",
8571
- onClick: f,
8605
+ onClick: h,
8572
8606
  disabled: l || !n.trim() && !d,
8573
8607
  children: [
8574
8608
  /* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
@@ -8683,7 +8717,7 @@ const AddBlocksDialog = () => {
8683
8717
  preloadedAttributes: r = [],
8684
8718
  onAttributesChange: n
8685
8719
  }) {
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();
8720
+ 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
8721
  useEffect(() => {
8688
8722
  l(r);
8689
8723
  }, [r]);
@@ -8697,7 +8731,7 @@ const AddBlocksDialog = () => {
8697
8731
  n(S), l(a), d(""), p(""), m("");
8698
8732
  }
8699
8733
  }, v = (S) => {
8700
- const B = a.filter((N, C) => C !== S);
8734
+ const B = a.filter((T, C) => C !== S);
8701
8735
  n(B), l(B);
8702
8736
  }, w = (S) => {
8703
8737
  g(S), d(a[S].key), p(a[S].value);
@@ -8713,23 +8747,23 @@ const AddBlocksDialog = () => {
8713
8747
  }, E = (S) => {
8714
8748
  S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? A() : b());
8715
8749
  }, _ = useCallback((S) => {
8716
- const B = (k) => /[.,!?;:]/.test(k), N = (k, j, T) => {
8717
- let I = "", P = "";
8750
+ const B = (k) => /[.,!?;:]/.test(k), T = (k, j, I) => {
8751
+ let N = "", P = "";
8718
8752
  const L = j > 0 ? k[j - 1] : "", O = j < k.length ? k[j] : "";
8719
- return j > 0 && (L === "." || !B(L) && L !== " ") && (I = " "), j < k.length && !B(O) && O !== " " && (P = " "), {
8720
- text: I + T + P,
8721
- prefixLength: I.length,
8753
+ return j > 0 && (L === "." || !B(L) && L !== " ") && (N = " "), j < k.length && !B(O) && O !== " " && (P = " "), {
8754
+ text: N + I + P,
8755
+ prefixLength: N.length,
8722
8756
  suffixLength: P.length
8723
8757
  };
8724
8758
  }, C = x.current;
8725
8759
  if (C) {
8726
- const k = C.selectionStart || 0, j = C.value || "", T = C.selectionEnd || k;
8727
- if (T > k) {
8728
- const $ = `{{${S}}}`, { text: R } = N(j, k, $), D = j.slice(0, k) + R + j.slice(T);
8760
+ const k = C.selectionStart || 0, j = C.value || "", I = C.selectionEnd || k;
8761
+ if (I > k) {
8762
+ const $ = `{{${S}}}`, { text: R } = T(j, k, $), D = j.slice(0, k) + R + j.slice(I);
8729
8763
  p(D);
8730
8764
  return;
8731
8765
  }
8732
- const P = `{{${S}}}`, { text: L } = N(j, k, P), O = j.slice(0, k) + L + j.slice(k);
8766
+ const P = `{{${S}}}`, { text: L } = T(j, k, P), O = j.slice(0, k) + L + j.slice(k);
8733
8767
  p(O);
8734
8768
  }
8735
8769
  }, []);
@@ -8752,7 +8786,7 @@ const AddBlocksDialog = () => {
8752
8786
  autoCorrect: "off",
8753
8787
  spellCheck: "false",
8754
8788
  id: "attrKey",
8755
- ref: h,
8789
+ ref: f,
8756
8790
  value: i,
8757
8791
  onChange: (S) => d(S.target.value),
8758
8792
  placeholder: "Enter Key",
@@ -8784,7 +8818,7 @@ const AddBlocksDialog = () => {
8784
8818
  ] })
8785
8819
  ] }),
8786
8820
  /* @__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 })
8821
+ h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
8788
8822
  ]
8789
8823
  }
8790
8824
  ),
@@ -8917,9 +8951,9 @@ const RootLayout = () => {
8917
8951
  });
8918
8952
  const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = (S) => {
8919
8953
  S.preventDefault();
8920
- }, f = (S) => {
8954
+ }, h = (S) => {
8921
8955
  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);
8956
+ }, 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
8957
  useEffect(() => {
8924
8958
  if (r !== null) {
8925
8959
  const S = find(x, { id: r });
@@ -8940,9 +8974,9 @@ const RootLayout = () => {
8940
8974
  }, [r, x]);
8941
8975
  const _ = useCallback(
8942
8976
  (S) => {
8943
- f(S);
8977
+ h(S);
8944
8978
  },
8945
- [f]
8979
+ [h]
8946
8980
  );
8947
8981
  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
8982
  /* @__PURE__ */ jsxs(
@@ -8961,7 +8995,7 @@ const RootLayout = () => {
8961
8995
  isActive: r === S.id,
8962
8996
  show: () => _(S.id)
8963
8997
  }) }),
8964
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(S.label) }) })
8998
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
8965
8999
  ] }, "button-top-" + B)) }),
8966
9000
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
8967
9001
  /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((S, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -8971,7 +9005,7 @@ const RootLayout = () => {
8971
9005
  isActive: r === S.id,
8972
9006
  show: () => _(S.id)
8973
9007
  }) }),
8974
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: h(S.label) }) })
9008
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
8975
9009
  ] }, "button-bottom-" + B)) })
8976
9010
  ] }),
8977
9011
  /* @__PURE__ */ jsx(
@@ -8987,7 +9021,7 @@ const RootLayout = () => {
8987
9021
  "div",
8988
9022
  {
8989
9023
  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", "")) })
9024
+ children: /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
8991
9025
  }
8992
9026
  ),
8993
9027
  /* @__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 +9044,11 @@ const RootLayout = () => {
9010
9044
  /* @__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
9045
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9012
9046
  " ",
9013
- h("AI Assistant")
9047
+ f("AI Assistant")
9014
9048
  ] }) }) : d === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9015
9049
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9016
9050
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9017
- h("Theme Settings")
9051
+ f("Theme Settings")
9018
9052
  ] }),
9019
9053
  /* @__PURE__ */ jsx(
9020
9054
  Button,
@@ -9034,7 +9068,7 @@ const RootLayout = () => {
9034
9068
  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
9069
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9036
9070
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9037
- /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9071
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9038
9072
  ] }) }),
9039
9073
  /* @__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
9074
  close: E
@@ -9044,7 +9078,7 @@ const RootLayout = () => {
9044
9078
  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
9079
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9046
9080
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9047
- /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9081
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9048
9082
  ] }) }),
9049
9083
  /* @__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
9084
  close: E
@@ -9070,7 +9104,7 @@ const RootLayout = () => {
9070
9104
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between border-b border-border p-4 py-2", children: [
9071
9105
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 text-lg font-bold", children: [
9072
9106
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9073
- /* @__PURE__ */ jsx("span", { children: h(get(b, "label", "")) })
9107
+ /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9074
9108
  ] }),
9075
9109
  /* @__PURE__ */ jsx(Button, { onClick: () => A(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9076
9110
  ] }),
@@ -9177,63 +9211,63 @@ const FEATURE_TOGGLES = {
9177
9211
  for (const i of r.p)
9178
9212
  l.add(i);
9179
9213
  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) => {
9214
+ }, 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
9215
  var x;
9182
- return (x = m.unstable_onInit) == null ? void 0 : x.call(m, h);
9183
- }, g = (m, h) => {
9216
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
9217
+ }, g = (m, f) => {
9184
9218
  var x;
9185
- return (x = m.onMount) == null ? void 0 : x.call(m, h);
9186
- }, ...f) => {
9187
- const m = f[0] || ((B) => {
9188
- let N = o.get(B);
9189
- 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] || (() => {
9191
- let B, N;
9219
+ return (x = m.onMount) == null ? void 0 : x.call(m, f);
9220
+ }, ...h) => {
9221
+ const m = h[0] || ((B) => {
9222
+ let T = o.get(B);
9223
+ return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, T), u == null || u(B, S)), T;
9224
+ }), f = h[1] || (() => {
9225
+ let B, T;
9192
9226
  const C = (k) => {
9193
9227
  try {
9194
9228
  k();
9195
9229
  } catch (j) {
9196
- B || (B = !0, N = j);
9230
+ B || (B = !0, T = j);
9197
9231
  }
9198
9232
  };
9199
9233
  do {
9200
9234
  d.f && C(d.f);
9201
9235
  const k = /* @__PURE__ */ new Set(), j = k.add.bind(k);
9202
- a.forEach((T) => {
9203
- var I;
9204
- return (I = r.get(T)) == null ? void 0 : I.l.forEach(j);
9236
+ a.forEach((I) => {
9237
+ var N;
9238
+ return (N = r.get(I)) == null ? void 0 : N.l.forEach(j);
9205
9239
  }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && x();
9206
9240
  } while (a.size || i.size || l.size);
9207
9241
  if (B)
9208
- throw N;
9209
- }), x = f[2] || (() => {
9210
- const B = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9242
+ throw T;
9243
+ }), x = h[2] || (() => {
9244
+ const B = [], T = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9211
9245
  for (; k.length; ) {
9212
- const j = k[k.length - 1], T = m(j);
9246
+ const j = k[k.length - 1], I = m(j);
9213
9247
  if (C.has(j)) {
9214
9248
  k.pop();
9215
9249
  continue;
9216
9250
  }
9217
- if (N.has(j)) {
9218
- n.get(j) === T.n && B.push([j, T]), C.add(j), k.pop();
9251
+ if (T.has(j)) {
9252
+ n.get(j) === I.n && B.push([j, I]), C.add(j), k.pop();
9219
9253
  continue;
9220
9254
  }
9221
- N.add(j);
9222
- for (const I of getMountedOrPendingDependents(j, T, r))
9223
- N.has(I) || k.push(I);
9255
+ T.add(j);
9256
+ for (const N of getMountedOrPendingDependents(j, I, r))
9257
+ T.has(N) || k.push(N);
9224
9258
  }
9225
9259
  for (let j = B.length - 1; j >= 0; --j) {
9226
- const [T, I] = B[j];
9260
+ const [I, N] = B[j];
9227
9261
  let P = !1;
9228
- for (const L of I.d.keys())
9229
- if (L !== T && a.has(L)) {
9262
+ for (const L of N.d.keys())
9263
+ if (L !== I && a.has(L)) {
9230
9264
  P = !0;
9231
9265
  break;
9232
9266
  }
9233
- P && (y(T), w(T)), n.delete(T);
9267
+ P && (y(I), w(I)), n.delete(I);
9234
9268
  }
9235
- }), y = f[3] || ((B) => {
9236
- var N, C;
9269
+ }), y = h[3] || ((B) => {
9270
+ var T, C;
9237
9271
  const k = m(B);
9238
9272
  if (isAtomStateInitialized(k) && (r.has(B) && n.get(B) !== k.n || Array.from(k.d).every(
9239
9273
  ([R, D]) => (
@@ -9245,9 +9279,9 @@ const FEATURE_TOGGLES = {
9245
9279
  return k;
9246
9280
  k.d.clear();
9247
9281
  let j = !0;
9248
- const T = () => {
9249
- r.has(B) && (w(B), x(), h());
9250
- }, I = (R) => {
9282
+ const I = () => {
9283
+ r.has(B) && (w(B), x(), f());
9284
+ }, N = (R) => {
9251
9285
  var D;
9252
9286
  if (isSelfAtom(B, R)) {
9253
9287
  const H = m(R);
@@ -9262,7 +9296,7 @@ const FEATURE_TOGGLES = {
9262
9296
  try {
9263
9297
  return returnAtomValue(M);
9264
9298
  } finally {
9265
- k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(B, k.v, M), (D = r.get(R)) == null || D.t.add(B), j || T();
9299
+ k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(B, k.v, M), (D = r.get(R)) == null || D.t.add(B), j || I();
9266
9300
  }
9267
9301
  };
9268
9302
  let P, L;
@@ -9276,72 +9310,72 @@ const FEATURE_TOGGLES = {
9276
9310
  try {
9277
9311
  return v(B, ...R);
9278
9312
  } finally {
9279
- x(), h();
9313
+ x(), f();
9280
9314
  }
9281
9315
  }), L;
9282
9316
  }
9283
9317
  }, $ = k.n;
9284
9318
  try {
9285
- const R = c(B, I, O);
9286
- return setAtomStateValueOrPromise(B, R, m), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
9287
- T,
9288
- T
9319
+ const R = c(B, N, O);
9320
+ return setAtomStateValueOrPromise(B, R, m), isPromiseLike$1(R) && ((T = R.onCancel) == null || T.call(R, () => P == null ? void 0 : P.abort()), R.then(
9321
+ I,
9322
+ I
9289
9323
  )), k;
9290
9324
  } catch (R) {
9291
9325
  return delete k.v, k.e = R, ++k.n, k;
9292
9326
  } finally {
9293
9327
  j = !1, $ !== k.n && n.get(B) === $ && (n.set(B, k.n), a.add(B), (C = d.c) == null || C.call(d, B));
9294
9328
  }
9295
- }), b = f[4] || ((B) => {
9296
- const N = [B];
9297
- for (; N.length; ) {
9298
- const C = N.pop(), k = m(C);
9329
+ }), b = h[4] || ((B) => {
9330
+ const T = [B];
9331
+ for (; T.length; ) {
9332
+ const C = T.pop(), k = m(C);
9299
9333
  for (const j of getMountedOrPendingDependents(C, k, r)) {
9300
- const T = m(j);
9301
- n.set(j, T.n), N.push(j);
9334
+ const I = m(j);
9335
+ n.set(j, I.n), T.push(j);
9302
9336
  }
9303
9337
  }
9304
- }), v = f[5] || ((B, ...N) => {
9338
+ }), v = h[5] || ((B, ...T) => {
9305
9339
  let C = !0;
9306
- const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
9340
+ const k = (I) => returnAtomValue(y(I)), j = (I, ...N) => {
9307
9341
  var P;
9308
- const L = m(T);
9342
+ const L = m(I);
9309
9343
  try {
9310
- if (isSelfAtom(B, T)) {
9311
- if (!hasInitialValue(T))
9344
+ if (isSelfAtom(B, I)) {
9345
+ if (!hasInitialValue(I))
9312
9346
  throw new Error("atom not writable");
9313
- const O = L.n, $ = I[0];
9314
- setAtomStateValueOrPromise(T, $, m), w(T), O !== L.n && (a.add(T), (P = d.c) == null || P.call(d, T), b(T));
9347
+ const O = L.n, $ = N[0];
9348
+ setAtomStateValueOrPromise(I, $, m), w(I), O !== L.n && (a.add(I), (P = d.c) == null || P.call(d, I), b(I));
9315
9349
  return;
9316
9350
  } else
9317
- return v(T, ...I);
9351
+ return v(I, ...N);
9318
9352
  } finally {
9319
- C || (x(), h());
9353
+ C || (x(), f());
9320
9354
  }
9321
9355
  };
9322
9356
  try {
9323
- return p(B, k, j, ...N);
9357
+ return p(B, k, j, ...T);
9324
9358
  } finally {
9325
9359
  C = !1;
9326
9360
  }
9327
- }), w = f[6] || ((B) => {
9328
- var N;
9361
+ }), w = h[6] || ((B) => {
9362
+ var T;
9329
9363
  const C = m(B), k = r.get(B);
9330
9364
  if (k && !isPendingPromise(C.v)) {
9331
- for (const [j, T] of C.d)
9365
+ for (const [j, I] of C.d)
9332
9366
  if (!k.d.has(j)) {
9333
- const I = m(j);
9334
- A(j).t.add(B), k.d.add(j), T !== I.n && (a.add(j), (N = d.c) == null || N.call(d, j), b(j));
9367
+ const N = m(j);
9368
+ A(j).t.add(B), k.d.add(j), I !== N.n && (a.add(j), (T = d.c) == null || T.call(d, j), b(j));
9335
9369
  }
9336
9370
  for (const j of k.d || [])
9337
9371
  if (!C.d.has(j)) {
9338
9372
  k.d.delete(j);
9339
- const T = E(j);
9340
- T == null || T.t.delete(B);
9373
+ const I = E(j);
9374
+ I == null || I.t.delete(B);
9341
9375
  }
9342
9376
  }
9343
- }), A = f[7] || ((B) => {
9344
- var N;
9377
+ }), A = h[7] || ((B) => {
9378
+ var T;
9345
9379
  const C = m(B);
9346
9380
  let k = r.get(B);
9347
9381
  if (!k) {
@@ -9352,46 +9386,46 @@ const FEATURE_TOGGLES = {
9352
9386
  l: /* @__PURE__ */ new Set(),
9353
9387
  d: new Set(C.d.keys()),
9354
9388
  t: /* @__PURE__ */ new Set()
9355
- }, r.set(B, k), (N = d.m) == null || N.call(d, B), isActuallyWritableAtom(B)) {
9389
+ }, r.set(B, k), (T = d.m) == null || T.call(d, B), isActuallyWritableAtom(B)) {
9356
9390
  const j = () => {
9357
- let T = !0;
9358
- const I = (...P) => {
9391
+ let I = !0;
9392
+ const N = (...P) => {
9359
9393
  try {
9360
9394
  return v(B, ...P);
9361
9395
  } finally {
9362
- T || (x(), h());
9396
+ I || (x(), f());
9363
9397
  }
9364
9398
  };
9365
9399
  try {
9366
- const P = g(B, I);
9400
+ const P = g(B, N);
9367
9401
  P && (k.u = () => {
9368
- T = !0;
9402
+ I = !0;
9369
9403
  try {
9370
9404
  P();
9371
9405
  } finally {
9372
- T = !1;
9406
+ I = !1;
9373
9407
  }
9374
9408
  });
9375
9409
  } finally {
9376
- T = !1;
9410
+ I = !1;
9377
9411
  }
9378
9412
  };
9379
9413
  l.add(j);
9380
9414
  }
9381
9415
  }
9382
9416
  return k;
9383
- }), E = f[8] || ((B) => {
9384
- var N;
9417
+ }), E = h[8] || ((B) => {
9418
+ var T;
9385
9419
  const C = m(B);
9386
9420
  let k = r.get(B);
9387
9421
  if (k && !k.l.size && !Array.from(k.t).some((j) => {
9388
- var T;
9389
- return (T = r.get(j)) == null ? void 0 : T.d.has(B);
9422
+ var I;
9423
+ return (I = r.get(j)) == null ? void 0 : I.d.has(B);
9390
9424
  })) {
9391
- k.u && i.add(k.u), k = void 0, r.delete(B), (N = d.u) == null || N.call(d, B);
9425
+ k.u && i.add(k.u), k = void 0, r.delete(B), (T = d.u) == null || T.call(d, B);
9392
9426
  for (const j of C.d.keys()) {
9393
- const T = E(j);
9394
- T == null || T.t.delete(B);
9427
+ const I = E(j);
9428
+ I == null || I.t.delete(B);
9395
9429
  }
9396
9430
  return;
9397
9431
  }
@@ -9412,7 +9446,7 @@ const FEATURE_TOGGLES = {
9412
9446
  g,
9413
9447
  // building-block functions
9414
9448
  m,
9415
- h,
9449
+ f,
9416
9450
  x,
9417
9451
  y,
9418
9452
  b,
@@ -9422,17 +9456,17 @@ const FEATURE_TOGGLES = {
9422
9456
  E
9423
9457
  ], S = {
9424
9458
  get: (B) => returnAtomValue(y(B)),
9425
- set: (B, ...N) => {
9459
+ set: (B, ...T) => {
9426
9460
  try {
9427
- return v(B, ...N);
9461
+ return v(B, ...T);
9428
9462
  } finally {
9429
- x(), h();
9463
+ x(), f();
9430
9464
  }
9431
9465
  },
9432
- sub: (B, N) => {
9466
+ sub: (B, T) => {
9433
9467
  const k = A(B).l;
9434
- return k.add(N), h(), () => {
9435
- k.delete(N), E(B), h();
9468
+ return k.add(T), f(), () => {
9469
+ k.delete(T), E(B), f();
9436
9470
  };
9437
9471
  }
9438
9472
  };