@chaibuilder/sdk 2.3.0 → 2.3.1

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.
Files changed (3) hide show
  1. package/dist/core.cjs +3 -3
  2. package/dist/core.js +369 -272
  3. package/package.json +1 -1
package/dist/core.js CHANGED
@@ -11,7 +11,7 @@ import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultS
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
13
13
  import { v as Button, ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, b9 as cn$1, aW as Skeleton, d as Alert, e as AlertDescription, at as Input$1, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, av as Popover, b5 as Tooltip, b8 as TooltipTrigger, ay as PopoverTrigger, b6 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, a6 as DialogHeader, a9 as DialogTitle, B as Badge, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, b2 as Textarea, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, z as CardFooter, az as ScrollArea, a_ as Tabs, b0 as TabsList, b1 as TabsTrigger, a$ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, aZ as Switch, r as Avatar, aL as Separator, b7 as TooltipProvider, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle, aY as Toaster } from "./toggle-BFR6fqvM.js";
14
- import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers, Settings as Settings$1 } from "lucide-react";
14
+ import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, MoreVertical, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, Eye, ChevronsUpDown, ChevronsDownUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
17
17
  import TreeModel from "tree-model";
@@ -38,7 +38,7 @@ import { useFeature } from "flagged";
38
38
  import { parse, stringify } from "himalaya";
39
39
  import { Tree } from "react-arborist";
40
40
  import i18n from "i18next";
41
- import { default as We } from "i18next";
41
+ import { default as ze } from "i18next";
42
42
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
43
43
  import tailwindForms from "@tailwindcss/forms";
44
44
  import tailwindTypography from "@tailwindcss/typography";
@@ -349,8 +349,8 @@ function insertBlocksAtPosition(o, n, r, a) {
349
349
  }), l.unshift(h), i = i.map((x) => {
350
350
  if (x._id === r) {
351
351
  const f = { ...x, content: "" };
352
- return Object.keys(f).forEach((k) => {
353
- k.startsWith("content-") && (f[k] = "");
352
+ return Object.keys(f).forEach((y) => {
353
+ y.startsWith("content-") && (f[y] = "");
354
354
  }), f;
355
355
  }
356
356
  return x;
@@ -485,8 +485,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
485
485
  h && "content" in h && (r = r.map((x) => {
486
486
  if (x._id === u) {
487
487
  const f = { ...x, content: m.content };
488
- return Object.keys(m).forEach((k) => {
489
- k.startsWith("content-") && (f[k] = m[k]);
488
+ return Object.keys(m).forEach((y) => {
489
+ y.startsWith("content-") && (f[y] = m[y]);
490
490
  }), f;
491
491
  }
492
492
  return x;
@@ -799,50 +799,50 @@ const undoRedoStateAtom = atom({
799
799
  updateBlocksProps: c
800
800
  } = useBlocksStoreManager();
801
801
  return {
802
- moveBlocks: (f, k, b) => {
802
+ moveBlocks: (f, y, b) => {
803
803
  const v = map(f, (w) => {
804
804
  const E = n.find((N) => N._id === w)._parent || null, A = n.filter((N) => E ? N._parent === E : !N._parent).map((N) => N._id).indexOf(w);
805
805
  return { _id: w, oldParent: E, oldPosition: A };
806
806
  }), B = v.find(({ _id: w }) => w === f[0]);
807
- B && B.oldParent === k && B.oldPosition === b || (i(f, k, b), o({
807
+ B && B.oldParent === y && B.oldPosition === b || (i(f, y, b), o({
808
808
  undo: () => each(v, ({ _id: w, oldParent: _, oldPosition: E }) => {
809
809
  i([w], _, E);
810
810
  }),
811
- redo: () => i(f, k, b)
811
+ redo: () => i(f, y, b)
812
812
  }));
813
813
  },
814
- addBlocks: (f, k, b) => {
815
- a(f, k, b), o({
814
+ addBlocks: (f, y, b) => {
815
+ a(f, y, b), o({
816
816
  undo: () => l(map(f, "_id")),
817
- redo: () => a(f, k, b)
817
+ redo: () => a(f, y, b)
818
818
  });
819
819
  },
820
820
  removeBlocks: (f) => {
821
821
  var B;
822
- const k = (B = first(f)) == null ? void 0 : B._parent, v = n.filter((w) => k ? w._parent === k : !w._parent).indexOf(first(f));
822
+ const y = (B = first(f)) == null ? void 0 : B._parent, v = n.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(f));
823
823
  l(map(f, "_id")), o({
824
- undo: () => a(f, k, v),
824
+ undo: () => a(f, y, v),
825
825
  redo: () => l(map(f, "_id"))
826
826
  });
827
827
  },
828
- updateBlocks: (f, k, b) => {
828
+ updateBlocks: (f, y, b) => {
829
829
  let v = [];
830
830
  if (b)
831
831
  v = map(f, (B) => ({ _id: B, ...b }));
832
832
  else {
833
- const B = keys(k);
833
+ const B = keys(y);
834
834
  v = map(f, (w) => {
835
835
  const _ = n.find((S) => S._id === w), E = { _id: w };
836
836
  return each(B, (S) => E[S] = _[S]), E;
837
837
  });
838
838
  }
839
- c(map(f, (B) => ({ _id: B, ...k }))), o({
839
+ c(map(f, (B) => ({ _id: B, ...y }))), o({
840
840
  undo: () => c(v),
841
- redo: () => c(map(f, (B) => ({ _id: B, ...k })))
841
+ redo: () => c(map(f, (B) => ({ _id: B, ...y })))
842
842
  });
843
843
  },
844
- updateBlocksRuntime: (f, k) => {
845
- c(map(f, (b) => ({ _id: b, ...k })));
844
+ updateBlocksRuntime: (f, y) => {
845
+ c(map(f, (b) => ({ _id: b, ...y })));
846
846
  },
847
847
  setNewBlocks: (f) => {
848
848
  r(f), o({
@@ -851,12 +851,12 @@ const undoRedoStateAtom = atom({
851
851
  });
852
852
  },
853
853
  updateMultipleBlocksProps: (f) => {
854
- let k = [];
855
- k = map(f, (b) => {
854
+ let y = [];
855
+ y = map(f, (b) => {
856
856
  const v = keys(b), B = n.find((_) => _._id === b._id), w = {};
857
857
  return each(v, (_) => w[_] = B[_]), w;
858
858
  }), c(f), o({
859
- undo: () => c(k),
859
+ undo: () => c(y),
860
860
  redo: () => c(f)
861
861
  });
862
862
  }
@@ -868,9 +868,9 @@ const undoRedoStateAtom = atom({
868
868
  for (let x = 0; x < i.length; x++) {
869
869
  const { _id: f } = i[x];
870
870
  i[x]._id = generateUUID();
871
- const k = filter(i, { _parent: f });
872
- for (let b = 0; b < k.length; b++)
873
- k[b]._parent = i[x]._id;
871
+ const y = filter(i, { _parent: f });
872
+ for (let b = 0; b < y.length; b++)
873
+ y[b]._parent = i[x]._id;
874
874
  }
875
875
  const p = first(i);
876
876
  let u, g;
@@ -881,8 +881,8 @@ const undoRedoStateAtom = atom({
881
881
  return { addCoreBlock: useCallback(
882
882
  (i, c, d) => {
883
883
  if (has(i, "blocks")) {
884
- const k = i.blocks;
885
- return a(k, c, d);
884
+ const y = i.blocks;
885
+ return a(y, c, d);
886
886
  }
887
887
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
888
888
  _type: i.type,
@@ -2333,20 +2333,20 @@ const getBlockWithChildren = (o, n) => {
2333
2333
  })
2334
2334
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2335
2335
  const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, x) => {
2336
- const f = cloneDeep(x.find((k) => k._id === h));
2337
- for (const k in f) {
2338
- const b = f[k];
2336
+ const f = cloneDeep(x.find((y) => y._id === h));
2337
+ for (const y in f) {
2338
+ const b = f[y];
2339
2339
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2340
2340
  const { baseClasses: v, classes: B } = getSplitChaiClasses(b);
2341
- f[k] = compact(flattenDeep([v, B])).join(" ");
2341
+ f[y] = compact(flattenDeep([v, B])).join(" ");
2342
2342
  } else
2343
- k !== "_id" && delete f[k];
2343
+ y !== "_id" && delete f[y];
2344
2344
  }
2345
2345
  return f;
2346
2346
  };
2347
2347
  return {
2348
2348
  askAi: useCallback(
2349
- async (h, x, f, k) => {
2349
+ async (h, x, f, y) => {
2350
2350
  if (l) {
2351
2351
  n(!0), a(null);
2352
2352
  try {
@@ -2364,11 +2364,11 @@ const getBlockWithChildren = (o, n) => {
2364
2364
  c(E);
2365
2365
  } else
2366
2366
  i(w);
2367
- k && k(B);
2367
+ y && y(B);
2368
2368
  } catch (b) {
2369
2369
  a(b);
2370
2370
  } finally {
2371
- n(!1), k && k();
2371
+ n(!1), y && y();
2372
2372
  }
2373
2373
  }
2374
2374
  },
@@ -2465,7 +2465,7 @@ const getBlockWithChildren = (o, n) => {
2465
2465
  for (const x of m)
2466
2466
  if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2467
2467
  let f = l(x.partialBlockId);
2468
- x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((k) => (isEmpty(k._parent) && set(k, "_parent", x._parent), k))), h = [...h, ...f];
2468
+ x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), h = [...h, ...f];
2469
2469
  } else
2470
2470
  h.push(x);
2471
2471
  return h;
@@ -2798,8 +2798,8 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2798
2798
  return useHotkeys(
2799
2799
  "shift+up, shift+down, shift+left, shift+right",
2800
2800
  ({ key: f }) => {
2801
- var k;
2802
- x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2801
+ var y;
2802
+ x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2803
2803
  },
2804
2804
  { document: a == null ? void 0 : a.contentDocument },
2805
2805
  [x]
@@ -2957,13 +2957,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2957
2957
  tabIndex: 0,
2958
2958
  ref: m.setFloating,
2959
2959
  style: g,
2960
- onClick: (k) => {
2961
- k.stopPropagation(), k.preventDefault();
2960
+ onClick: (y) => {
2961
+ y.stopPropagation(), y.preventDefault();
2962
2962
  },
2963
- onMouseEnter: (k) => {
2964
- k.stopPropagation(), i(null);
2963
+ onMouseEnter: (y) => {
2964
+ y.stopPropagation(), i(null);
2965
2965
  },
2966
- onKeyDown: (k) => k.stopPropagation(),
2966
+ onKeyDown: (y) => y.stopPropagation(),
2967
2967
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
2968
2968
  children: [
2969
2969
  x && /* @__PURE__ */ jsx(
@@ -3427,8 +3427,8 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3427
3427
  ],
3428
3428
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3429
3429
  onBlur: ({ editor: u, event: g }) => {
3430
- const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), k = x == null ? void 0 : x.contains(m);
3431
- if (!f && !k) {
3430
+ const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = h == null ? void 0 : h.contains(m), y = x == null ? void 0 : x.contains(m);
3431
+ if (!f && !y) {
3432
3432
  const b = (u == null ? void 0 : u.getHTML()) || "";
3433
3433
  r(b);
3434
3434
  }
@@ -3524,7 +3524,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3524
3524
  }
3525
3525
  ), WithBlockTextEditor = memo(
3526
3526
  ({ block: o, children: n }) => {
3527
- const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), k = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
3527
+ const r = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: m } = useBlockHighlight(), h = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: v, blockType: B } = useMemo(() => {
3528
3528
  var j;
3529
3529
  const A = o._type;
3530
3530
  let N = o[r];
@@ -3545,18 +3545,18 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3545
3545
  1e3
3546
3546
  ), E = useCallback(
3547
3547
  (A) => {
3548
- A.preventDefault(), b && (k.current = b), w(), setTimeout(() => {
3549
- const N = k.current;
3550
- k.current = null, f([N]);
3548
+ A.preventDefault(), b && (y.current = b), w(), setTimeout(() => {
3549
+ const N = y.current;
3550
+ y.current = null, f([N]);
3551
3551
  }, 100);
3552
3552
  },
3553
3553
  [f, b, x]
3554
3554
  );
3555
3555
  useEffect(() => {
3556
- var y;
3556
+ var k;
3557
3557
  if (!b) return;
3558
3558
  const A = `[data-block-id="${b}"]`, N = i >= 0 ? `[data-block-index="${i}"]` : "", C = a.querySelector(`${A}${N}`);
3559
- C && ((y = C == null ? void 0 : C.classList) == null || y.add("sr-only"), u(C));
3559
+ C && ((k = C == null ? void 0 : C.classList) == null || k.add("sr-only"), u(C));
3560
3560
  }, [b, B, a, i]);
3561
3561
  const S = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
3562
3562
  RichTextEditor,
@@ -3612,12 +3612,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3612
3612
  blockAtom: n,
3613
3613
  children: r
3614
3614
  }) => {
3615
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: k } = useContext(RepeaterContext), b = useMemo(
3615
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [m] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
3616
3616
  () => h ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3617
3617
  index: f,
3618
- key: k
3618
+ key: y
3619
3619
  }) : applyLanguage(i, d, c),
3620
- [i, d, c, g, h, f, k]
3620
+ [i, d, c, g, h, f, y]
3621
3621
  ), v = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
3622
3622
  () => u(i._id, getBlockRuntimeProps(i._type)),
3623
3623
  [i._id, i._type, u, getBlockRuntimeProps]
@@ -3697,7 +3697,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3697
3697
  );
3698
3698
  return map(l, (c) => {
3699
3699
  const d = a(c._id);
3700
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(h) && h.map((f, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3700
+ return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: m, repeaterItems: h, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(h) && h.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3701
3701
  });
3702
3702
  }, PageBlocksRenderer = () => {
3703
3703
  const [o] = useBlocksStore();
@@ -4124,9 +4124,9 @@ const DataBindingSelector = ({
4124
4124
  };
4125
4125
  }, f = document.getElementById(r);
4126
4126
  if (!f) return;
4127
- const k = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4128
- if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
4129
- const b = k.__chaiRTE;
4127
+ const y = document.getElementById(`chai-rte-${r}`) || document.getElementById(`chai-rte-modal-${r}`);
4128
+ if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4129
+ const b = y.__chaiRTE;
4130
4130
  if (b) {
4131
4131
  const v = `{{${g}}}`;
4132
4132
  b.commands.focus();
@@ -4137,8 +4137,8 @@ const DataBindingSelector = ({
4137
4137
  const { state: E } = b, S = E.selection.from, A = E.doc.textBetween(Math.max(0, S - 1), S), N = E.doc.textBetween(S, Math.min(S + 1, E.doc.content.size));
4138
4138
  let C = "";
4139
4139
  S > 0 && A !== " " && !h(A) && (C = " ");
4140
- let y = "";
4141
- N && N !== " " && !h(N) && (y = " "), b.chain().insertContent(C + v + y).run();
4140
+ let k = "";
4141
+ N && N !== " " && !h(N) && (k = " "), b.chain().insertContent(C + v + k).run();
4142
4142
  }
4143
4143
  setTimeout(() => n(b.getHTML(), {}, r), 100);
4144
4144
  return;
@@ -4146,8 +4146,8 @@ const DataBindingSelector = ({
4146
4146
  } else {
4147
4147
  const b = f, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
4148
4148
  if (w > v) {
4149
- const N = `{{${g}}}`, { text: C } = x(B, v, N), y = B.slice(0, v) + C + B.slice(w);
4150
- n(y, {}, r);
4149
+ const N = `{{${g}}}`, { text: C } = x(B, v, N), k = B.slice(0, v) + C + B.slice(w);
4150
+ n(k, {}, r);
4151
4151
  return;
4152
4152
  }
4153
4153
  const E = `{{${g}}}`, { text: S } = x(B, v, E), A = B.slice(0, v) + S + B.slice(v);
@@ -4173,12 +4173,12 @@ const DataBindingSelector = ({
4173
4173
  onChange: r
4174
4174
  }) => {
4175
4175
  var N;
4176
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = useState([]), [k, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : N.name;
4176
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), v = useRef(null), B = (N = n == null ? void 0 : n.find((C) => C.key === u)) == null ? void 0 : N.name;
4177
4177
  useEffect(() => {
4178
4178
  if (h(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4179
- const C = split(o, ":"), y = get(C, 1, "page") || "page";
4180
- g(y), (async () => {
4181
- const j = await l(y, [get(C, 2, "page")]);
4179
+ const C = split(o, ":"), k = get(C, 1, "page") || "page";
4180
+ g(k), (async () => {
4181
+ const j = await l(k, [get(C, 2, "page")]);
4182
4182
  j && Array.isArray(j) && h(get(j, [0, "name"], ""));
4183
4183
  })();
4184
4184
  }, [o]);
@@ -4187,27 +4187,27 @@ const DataBindingSelector = ({
4187
4187
  if (isEmpty(C))
4188
4188
  f([]);
4189
4189
  else {
4190
- const y = await l(u, C);
4191
- f(y);
4190
+ const k = await l(u, C);
4191
+ f(k);
4192
4192
  }
4193
4193
  c(!1), b(-1);
4194
4194
  },
4195
4195
  [u],
4196
4196
  300
4197
4197
  ), _ = (C) => {
4198
- const y = ["pageType", u, C.id];
4199
- y[1] && (r(y.join(":")), h(C.name), p(!1), f([]), b(-1));
4198
+ const k = ["pageType", u, C.id];
4199
+ k[1] && (r(k.join(":")), h(C.name), p(!1), f([]), b(-1));
4200
4200
  }, E = (C) => {
4201
4201
  switch (C.key) {
4202
4202
  case "ArrowDown":
4203
- C.preventDefault(), b((y) => y < x.length - 1 ? y + 1 : y);
4203
+ C.preventDefault(), b((k) => k < x.length - 1 ? k + 1 : k);
4204
4204
  break;
4205
4205
  case "ArrowUp":
4206
- C.preventDefault(), b((y) => y > 0 ? y - 1 : y);
4206
+ C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4207
4207
  break;
4208
4208
  case "Enter":
4209
4209
  if (C.preventDefault(), x.length === 0) return;
4210
- k >= 0 && _(x[k]);
4210
+ y >= 0 && _(x[y]);
4211
4211
  break;
4212
4212
  case "Escape":
4213
4213
  C.preventDefault(), S();
@@ -4215,11 +4215,11 @@ const DataBindingSelector = ({
4215
4215
  }
4216
4216
  };
4217
4217
  useEffect(() => {
4218
- if (k >= 0 && v.current) {
4219
- const C = v.current.children[k];
4218
+ if (y >= 0 && v.current) {
4219
+ const C = v.current.children[y];
4220
4220
  C == null || C.scrollIntoView({ block: "nearest" });
4221
4221
  }
4222
- }, [k]);
4222
+ }, [y]);
4223
4223
  const S = () => {
4224
4224
  h(""), f([]), b(-1), p(!1), r("");
4225
4225
  }, A = (C) => {
@@ -4249,11 +4249,11 @@ const DataBindingSelector = ({
4249
4249
  ' "',
4250
4250
  m,
4251
4251
  '"'
4252
- ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(x == null ? void 0 : x.slice(0, 20), (C, y) => /* @__PURE__ */ jsxs(
4252
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(x == null ? void 0 : x.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
4253
4253
  "li",
4254
4254
  {
4255
4255
  onClick: () => _(C),
4256
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : y === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
4256
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4257
4257
  children: [
4258
4258
  C.name,
4259
4259
  " ",
@@ -4666,14 +4666,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4666
4666
  const m = () => {
4667
4667
  const f = findIndex(u, { _id: g });
4668
4668
  if (f > -1) {
4669
- const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
4669
+ const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
4670
4670
  if (!b) return;
4671
4671
  n({ ...o, currentSlide: b }), c([b]);
4672
4672
  }
4673
4673
  }, h = () => {
4674
4674
  const f = findIndex(u, { _id: g });
4675
4675
  if (f > -1) {
4676
- const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4676
+ const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4677
4677
  if (!b) return;
4678
4678
  n({ ...o, currentSlide: b }), c([b]);
4679
4679
  }
@@ -4681,8 +4681,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4681
4681
  const f = i(
4682
4682
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4683
4683
  p == null ? void 0 : p._id
4684
- ), k = f == null ? void 0 : f._id;
4685
- k && (n({ ...o, currentSlide: k }), c([k]));
4684
+ ), y = f == null ? void 0 : f._id;
4685
+ y && (n({ ...o, currentSlide: y }), c([y]));
4686
4686
  };
4687
4687
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4688
4688
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4761,8 +4761,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4761
4761
  className: "text-xs",
4762
4762
  pattern: "[0-9]*",
4763
4763
  onChange: (f) => {
4764
- let k = f.target.value;
4765
- k.length && (k = k.replace("-", "")), n({ ...o, autoplayInterval: k });
4764
+ let y = f.target.value;
4765
+ y.length && (y = y.replace("-", "")), n({ ...o, autoplayInterval: y });
4766
4766
  }
4767
4767
  }
4768
4768
  )
@@ -4870,10 +4870,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4870
4870
  formData: g,
4871
4871
  onChange: m
4872
4872
  }) => {
4873
- const { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), k = useMemo(
4873
+ const { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), y = useMemo(
4874
4874
  () => isEmpty(f) ? "" : isEmpty(h) ? x : h,
4875
4875
  [f, h, x]
4876
- ), b = useMemo(() => get(LANGUAGES, k, k), [k]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
4876
+ ), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
4877
4877
  () => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
4878
4878
  [w, B == null ? void 0 : B._type]
4879
4879
  ), [E, S] = useState(null);
@@ -5034,7 +5034,7 @@ function BlockSettings() {
5034
5034
  x({ formData: E }, S, A), d(E);
5035
5035
  }, 1500),
5036
5036
  [n == null ? void 0 : n._id, o]
5037
- ), k = ({ formData: E }, S) => {
5037
+ ), y = ({ formData: E }, S) => {
5038
5038
  S && (r([n._id], { [S]: get(E, S) }), f({ formData: E }, S, { [S]: get(c, S) }));
5039
5039
  }, b = ({ formData: E }, S) => {
5040
5040
  S && (r([g._id], { [S]: get(E, S) }), f({ formData: E }, S, { [S]: get(c, S) }));
@@ -5093,7 +5093,7 @@ function BlockSettings() {
5093
5093
  JSONForm,
5094
5094
  {
5095
5095
  blockId: n == null ? void 0 : n._id,
5096
- onChange: k,
5096
+ onChange: y,
5097
5097
  formData: i,
5098
5098
  schema: v,
5099
5099
  uiSchema: B
@@ -5300,37 +5300,37 @@ const BlockStylingProps = () => {
5300
5300
  },
5301
5301
  a
5302
5302
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5303
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [k, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
5303
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
5304
5304
  useEffect(() => {
5305
- const { value: C, unit: y } = getClassValueAndUnit(i);
5306
- if (y === "") {
5305
+ const { value: C, unit: k } = getClassValueAndUnit(i);
5306
+ if (k === "") {
5307
5307
  l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5308
5308
  return;
5309
5309
  }
5310
- h(y), l(y === "class" || isEmpty(C) ? "" : C);
5310
+ h(k), l(k === "class" || isEmpty(C) ? "" : C);
5311
5311
  }, [i, p, u]);
5312
5312
  const E = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
5313
5313
  (C = !1) => {
5314
- const y = getUserInputValues(`${a}`, u);
5315
- if (get(y, "error", !1)) {
5314
+ const k = getUserInputValues(`${a}`, u);
5315
+ if (get(k, "error", !1)) {
5316
5316
  f(!0);
5317
5317
  return;
5318
5318
  }
5319
- const j = get(y, "unit") !== "" ? get(y, "unit") : m;
5319
+ const j = get(k, "unit") !== "" ? get(k, "unit") : m;
5320
5320
  if (j === "auto" || j === "none") {
5321
5321
  E(`${d}${j}`);
5322
5322
  return;
5323
5323
  }
5324
- if (get(y, "value") === "")
5324
+ if (get(k, "value") === "")
5325
5325
  return;
5326
- const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5326
+ const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5327
5327
  C ? S(L) : E(L);
5328
5328
  },
5329
5329
  [E, S, a, m, d, u]
5330
5330
  ), N = useCallback(
5331
5331
  (C) => {
5332
- const y = getUserInputValues(`${a}`, u);
5333
- if (get(y, "error", !1)) {
5332
+ const k = getUserInputValues(`${a}`, u);
5333
+ if (get(k, "error", !1)) {
5334
5334
  f(!0);
5335
5335
  return;
5336
5336
  }
@@ -5338,9 +5338,9 @@ const BlockStylingProps = () => {
5338
5338
  E(`${d}${C}`);
5339
5339
  return;
5340
5340
  }
5341
- if (get(y, "value") === "")
5341
+ if (get(k, "value") === "")
5342
5342
  return;
5343
- const j = get(y, "unit") !== "" ? get(y, "unit") : C, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5343
+ const j = get(k, "unit") !== "" ? get(k, "unit") : C, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5344
5344
  E(L);
5345
5345
  },
5346
5346
  [E, a, d, u]
@@ -5371,8 +5371,8 @@ const BlockStylingProps = () => {
5371
5371
  if (C.keyCode !== 38 && C.keyCode !== 40)
5372
5372
  return;
5373
5373
  C.preventDefault(), _(!0);
5374
- const y = parseInt$1(C.target.value);
5375
- let j = isNaN$1(y) ? 0 : y;
5374
+ const k = parseInt$1(C.target.value);
5375
+ let j = isNaN$1(k) ? 0 : k;
5376
5376
  C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
5377
5377
  const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
5378
5378
  S(R);
@@ -5385,10 +5385,10 @@ const BlockStylingProps = () => {
5385
5385
  f(!1), l(C.target.value);
5386
5386
  },
5387
5387
  onClick: (C) => {
5388
- var y;
5389
- (y = C == null ? void 0 : C.target) == null || y.select(), r(!1);
5388
+ var k;
5389
+ (k = C == null ? void 0 : C.target) == null || k.select(), r(!1);
5390
5390
  },
5391
- value: v ? k : a,
5391
+ value: v ? y : a,
5392
5392
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5393
5393
  " ",
5394
5394
  x ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5427,14 +5427,14 @@ const BlockStylingProps = () => {
5427
5427
  onDragEnd: (C) => {
5428
5428
  if (b(() => ""), B(!1), isEmpty(C))
5429
5429
  return;
5430
- const y = `${C}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
5430
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
5431
5431
  E(I);
5432
5432
  },
5433
5433
  onDrag: (C) => {
5434
5434
  if (isEmpty(C))
5435
5435
  return;
5436
5436
  b(C);
5437
- const y = `${C}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
5437
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
5438
5438
  S(I);
5439
5439
  },
5440
5440
  currentValue: a,
@@ -5500,8 +5500,8 @@ const COLOR_PROP = {
5500
5500
  }, ColorChoice = ({ property: o, onChange: n }) => {
5501
5501
  const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), h = useCallback(
5502
5502
  // eslint-disable-next-line no-shadow
5503
- (k) => {
5504
- ["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5503
+ (y) => {
5504
+ ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
5505
5505
  },
5506
5506
  [c, p]
5507
5507
  );
@@ -5512,8 +5512,8 @@ const COLOR_PROP = {
5512
5512
  }, [g]);
5513
5513
  const x = useCallback(
5514
5514
  // eslint-disable-next-line no-shadow
5515
- (k) => {
5516
- p({ color: g, shade: k });
5515
+ (y) => {
5516
+ p({ color: g, shade: y });
5517
5517
  },
5518
5518
  [g]
5519
5519
  );
@@ -5898,7 +5898,7 @@ const COLOR_PROP = {
5898
5898
  "2xl": "1536px"
5899
5899
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5900
5900
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
5901
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), k = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
5901
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
5902
5902
  (S, A = !0) => {
5903
5903
  const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5904
5904
  (p || u !== "") && (N.mq = "xs");
@@ -5907,8 +5907,8 @@ const COLOR_PROP = {
5907
5907
  },
5908
5908
  [f, p, g, u, l, h]
5909
5909
  ), v = useCallback(() => {
5910
- x(f, [k], !0);
5911
- }, [f, k, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
5910
+ x(f, [y], !0);
5911
+ }, [f, y, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
5912
5912
  useEffect(() => {
5913
5913
  i(B, m);
5914
5914
  }, [B, i, m]);
@@ -5945,7 +5945,7 @@ const COLOR_PROP = {
5945
5945
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5946
5946
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5947
5947
  ] }),
5948
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: E ? /* @__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" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5948
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: E ? /* @__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" }) }) : B && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5949
5949
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5950
5950
  "button",
5951
5951
  {
@@ -6169,7 +6169,7 @@ const COLOR_PROP = {
6169
6169
  u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
6170
6170
  }, f = (b) => {
6171
6171
  n || l(b), c(b);
6172
- }, k = getBreakpointValue(n ? i : a).toLowerCase();
6172
+ }, y = getBreakpointValue(n ? i : a).toLowerCase();
6173
6173
  return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
6174
6174
  BreakpointCard,
6175
6175
  {
@@ -6177,7 +6177,7 @@ const COLOR_PROP = {
6177
6177
  ...b,
6178
6178
  onClick: f,
6179
6179
  key: b.breakpoint,
6180
- currentBreakpoint: k
6180
+ currentBreakpoint: y
6181
6181
  }
6182
6182
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6183
6183
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -6191,7 +6191,7 @@ const COLOR_PROP = {
6191
6191
  ...b,
6192
6192
  onClick: f,
6193
6193
  key: b.breakpoint,
6194
- currentBreakpoint: k
6194
+ currentBreakpoint: y
6195
6195
  }
6196
6196
  )
6197
6197
  ) }),
@@ -6346,7 +6346,7 @@ const AskAIStyles = ({ blockId: o }) => {
6346
6346
  };
6347
6347
  function ManualClasses() {
6348
6348
  var I;
6349
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6349
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((L) => !isEmpty(L)), B = () => {
6350
6350
  const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6351
6351
  u(m, L, !0), f("");
6352
6352
  }, [w, _] = useState([]), E = ({ value: L }) => {
@@ -6384,7 +6384,7 @@ function ManualClasses() {
6384
6384
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6385
6385
  }),
6386
6386
  [x, c, o]
6387
- ), y = (L) => {
6387
+ ), k = (L) => {
6388
6388
  debugger;
6389
6389
  const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6390
6390
  g(m, [L]), u(m, R, !0), r(""), l(-1);
@@ -6452,10 +6452,10 @@ function ManualClasses() {
6452
6452
  value: n,
6453
6453
  onChange: (T) => r(T.target.value),
6454
6454
  onBlur: () => {
6455
- y(L);
6455
+ k(L);
6456
6456
  },
6457
6457
  onKeyDown: (T) => {
6458
- T.key === "Enter" && y(L);
6458
+ T.key === "Enter" && k(L);
6459
6459
  },
6460
6460
  onFocus: (T) => {
6461
6461
  setTimeout(() => {
@@ -6604,8 +6604,8 @@ function BlockStyling() {
6604
6604
  h = isNaN(h) ? 0 : h;
6605
6605
  let x = MAPPER[i.dragUnit];
6606
6606
  (startsWith(m, "scale") || m === "opacity") && (x = 10);
6607
- let k = (i.dragStartY - u.pageY) / x + h;
6608
- g && k < 0 && (k = 0), m === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6607
+ let y = (i.dragStartY - u.pageY) / x + h;
6608
+ g && y < 0 && (y = 0), m === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6609
6609
  },
6610
6610
  [i],
6611
6611
  50
@@ -6648,8 +6648,8 @@ const CoreBlock = ({
6648
6648
  }) => {
6649
6649
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6650
6650
  if (has(o, "blocks")) {
6651
- const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6652
- u(syncBlocksWithDefaults(k), r || null, a);
6651
+ const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6652
+ u(syncBlocksWithDefaults(y), r || null, a);
6653
6653
  } else
6654
6654
  p(o, r || null, a);
6655
6655
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6661,8 +6661,8 @@ const CoreBlock = ({
6661
6661
  disabled: n,
6662
6662
  onClick: h,
6663
6663
  type: "button",
6664
- onDragStart: (k) => {
6665
- k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6664
+ onDragStart: (y) => {
6665
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6666
6666
  g([]), m();
6667
6667
  }, 200);
6668
6668
  },
@@ -6862,7 +6862,7 @@ const CoreBlock = ({
6862
6862
  }
6863
6863
  }
6864
6864
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
6865
- var m, h, x, f, k, b, v, B;
6865
+ var m, h, x, f, y, b, v, B;
6866
6866
  if (r.type === "comment") return [];
6867
6867
  let a = { _id: generateUUID() };
6868
6868
  if (n && (a._parent = n.block._id), r.type === "text")
@@ -6905,7 +6905,7 @@ const CoreBlock = ({
6905
6905
  href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
6906
6906
  hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6907
6907
  autoplay: ((x = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
6908
- maxWidth: ((k = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
6908
+ maxWidth: ((y = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
6909
6909
  backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
6910
6910
  galleryName: ((v = l.find((_) => _.key === "data-gall")) == null ? void 0 : v.value) || ""
6911
6911
  }, forEach(w, (_) => {
@@ -7046,7 +7046,7 @@ const registerChaiLibrary = (o, n) => {
7046
7046
  parentId: r = void 0,
7047
7047
  position: a = -1
7048
7048
  }) => {
7049
- const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), k = (B) => {
7049
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
7050
7050
  const w = has(B, "styles_attrs.data-page-section");
7051
7051
  return B._type === "Box" && w;
7052
7052
  }, b = useCallback(
@@ -7071,7 +7071,7 @@ const registerChaiLibrary = (o, n) => {
7071
7071
  onDragStart: async (B) => {
7072
7072
  const w = await c({ library: n, block: o });
7073
7073
  let _ = r;
7074
- if (k(first(w)) && (_ = null), !isEmpty(w)) {
7074
+ if (y(first(w)) && (_ = null), !isEmpty(w)) {
7075
7075
  const E = { blocks: w, uiLibrary: !0, parent: _ };
7076
7076
  if (B.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
7077
7077
  const S = new Image();
@@ -7106,7 +7106,7 @@ const registerChaiLibrary = (o, n) => {
7106
7106
  ] }) })
7107
7107
  ] });
7108
7108
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7109
- const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((y) => y.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), x = useRef(null);
7109
+ const [r, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((k) => k.id === r) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), x = useRef(null);
7110
7110
  useEffect(() => {
7111
7111
  c && c.length > 0 && (x.current = new Fuse(c, {
7112
7112
  keys: ["name", "label", "description", "group"],
@@ -7118,23 +7118,23 @@ const registerChaiLibrary = (o, n) => {
7118
7118
  h([]);
7119
7119
  return;
7120
7120
  }
7121
- const y = x.current.search(u).map((j) => j.item);
7122
- h(y);
7121
+ const k = x.current.search(u).map((j) => j.item);
7122
+ h(k);
7123
7123
  }, [u]);
7124
- const f = u.trim() && !isEmpty(m) ? m : c, k = groupBy(f, "group"), [b, v] = useState(null);
7124
+ const f = u.trim() && !isEmpty(m) ? m : c, y = groupBy(f, "group"), [b, v] = useState(null);
7125
7125
  useEffect(() => {
7126
- if (isEmpty(keys(k))) {
7126
+ if (isEmpty(keys(y))) {
7127
7127
  v(null);
7128
7128
  return;
7129
7129
  }
7130
- if (!b || !k[b]) {
7131
- v(first(keys(k)));
7130
+ if (!b || !y[b]) {
7131
+ v(first(keys(y)));
7132
7132
  return;
7133
7133
  }
7134
- }, [k, b]);
7135
- const B = get(k, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (y) => {
7134
+ }, [y, b]);
7135
+ const B = get(y, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (k) => {
7136
7136
  w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7137
- w.current && v(y);
7137
+ w.current && v(k);
7138
7138
  }, 400);
7139
7139
  }, S = () => {
7140
7140
  i != null && i.id && p(i.id);
@@ -7146,7 +7146,7 @@ const registerChaiLibrary = (o, n) => {
7146
7146
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7147
7147
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7148
7148
  ] });
7149
- const N = filter(B, (y, j) => j % 2 === 0), C = filter(B, (y, j) => j % 2 === 1);
7149
+ const N = filter(B, (k, j) => j % 2 === 0), C = filter(B, (k, j) => j % 2 === 1);
7150
7150
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7151
7151
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7152
7152
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7155,7 +7155,7 @@ const registerChaiLibrary = (o, n) => {
7155
7155
  {
7156
7156
  placeholder: _("Search blocks..."),
7157
7157
  value: u,
7158
- onChange: (y) => g(y.target.value),
7158
+ onChange: (k) => g(k.target.value),
7159
7159
  className: "w-full pl-8 pr-8"
7160
7160
  }
7161
7161
  ),
@@ -7174,13 +7174,13 @@ const registerChaiLibrary = (o, n) => {
7174
7174
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7175
7175
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7176
7176
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7177
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7177
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7178
7178
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7179
7179
  /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7180
7180
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7181
7181
  _("Retry")
7182
7182
  ] })
7183
- ] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
7183
+ ] }) }) : map(y, (k, j) => /* @__PURE__ */ jsxs(
7184
7184
  "div",
7185
7185
  {
7186
7186
  onMouseEnter: () => E(j),
@@ -7206,23 +7206,23 @@ const registerChaiLibrary = (o, n) => {
7206
7206
  onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
7207
7207
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7208
7208
  children: [
7209
- isEmpty(B) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7210
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((y, j) => /* @__PURE__ */ jsx(
7209
+ isEmpty(B) && !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: _("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7210
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
7211
7211
  BlockCard,
7212
7212
  {
7213
7213
  parentId: o,
7214
7214
  position: n,
7215
- block: y,
7215
+ block: k,
7216
7216
  library: i
7217
7217
  },
7218
7218
  `block-${j}`
7219
7219
  )) }),
7220
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((y, j) => /* @__PURE__ */ jsx(
7220
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((k, j) => /* @__PURE__ */ jsx(
7221
7221
  BlockCard,
7222
7222
  {
7223
7223
  parentId: o,
7224
7224
  position: n,
7225
- block: y,
7225
+ block: k,
7226
7226
  library: i
7227
7227
  },
7228
7228
  `block-second-${j}`
@@ -7261,8 +7261,8 @@ const registerChaiLibrary = (o, n) => {
7261
7261
  error: c
7262
7262
  }), g(!0);
7263
7263
  else if (!l && Object.keys(a || {}).length > 0) {
7264
- const h = Object.entries(a).map(([f, k]) => {
7265
- const b = k, v = b.type || "partial", B = formatReadableName(v);
7264
+ const h = Object.entries(a).map(([f, y]) => {
7265
+ const b = y, v = b.type || "partial", B = formatReadableName(v);
7266
7266
  return {
7267
7267
  type: "PartialBlock",
7268
7268
  // Set the type to PartialBlock
@@ -7325,41 +7325,41 @@ const registerChaiLibrary = (o, n) => {
7325
7325
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7326
7326
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7327
7327
  var C;
7328
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (y) => y._id === r)) == null ? void 0 : C._type, [h, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
7328
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [h, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7329
7329
  useEffect(() => {
7330
- const y = setTimeout(() => {
7330
+ const k = setTimeout(() => {
7331
7331
  var j;
7332
7332
  (j = u.current) == null || j.focus();
7333
7333
  }, 0);
7334
- return () => clearTimeout(y);
7334
+ return () => clearTimeout(k);
7335
7335
  }, [g]), useEffect(() => {
7336
- d && (x("all"), k(null));
7337
- }, [d]), useEffect(() => (b.current = debounce((y) => {
7338
- x(y);
7336
+ d && (x("all"), y(null));
7337
+ }, [d]), useEffect(() => (b.current = debounce((k) => {
7338
+ x(k);
7339
7339
  }, 500), () => {
7340
7340
  b.current && b.current.cancel();
7341
7341
  }), []);
7342
- const v = useCallback((y) => {
7343
- k(y), b.current && b.current(y);
7342
+ const v = useCallback((k) => {
7343
+ y(k), b.current && b.current(k);
7344
7344
  }, []), B = useCallback(() => {
7345
- k(null), b.current && b.current.cancel();
7346
- }, []), w = useCallback((y) => {
7347
- b.current && b.current.cancel(), x(y), k(null);
7345
+ y(null), b.current && b.current.cancel();
7346
+ }, []), w = useCallback((k) => {
7347
+ b.current && b.current.cancel(), x(k), y(null);
7348
7348
  }, []), _ = useMemo(
7349
7349
  () => d ? values(n).filter(
7350
- (y) => {
7350
+ (k) => {
7351
7351
  var j, I;
7352
- return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = y.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7352
+ return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = k.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7353
7353
  }
7354
7354
  ) : n,
7355
7355
  [n, d]
7356
7356
  ), E = useMemo(
7357
7357
  () => d ? o.filter(
7358
- (y) => reject(filter(values(_), { group: y }), { hidden: !0 }).length > 0
7359
- ) : o.filter((y) => reject(filter(values(n), { group: y }), { hidden: !0 }).length > 0),
7358
+ (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7359
+ ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7360
7360
  [n, _, o, d]
7361
7361
  ), S = useMemo(
7362
- () => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7362
+ () => sortBy(E, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7363
7363
  [E]
7364
7364
  ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
7365
7365
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
@@ -7371,7 +7371,7 @@ const registerChaiLibrary = (o, n) => {
7371
7371
  placeholder: i("Search blocks..."),
7372
7372
  value: d,
7373
7373
  className: "-ml-2",
7374
- onChange: (y) => p(y.target.value)
7374
+ onChange: (k) => p(k.target.value)
7375
7375
  }
7376
7376
  ) }),
7377
7377
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7387,16 +7387,16 @@ const registerChaiLibrary = (o, n) => {
7387
7387
  },
7388
7388
  "sidebar-all"
7389
7389
  ),
7390
- S.map((y) => /* @__PURE__ */ jsx(
7390
+ S.map((k) => /* @__PURE__ */ jsx(
7391
7391
  "button",
7392
7392
  {
7393
- onClick: () => w(y),
7394
- onMouseEnter: () => v(y),
7393
+ onClick: () => w(k),
7394
+ onMouseEnter: () => v(k),
7395
7395
  onMouseLeave: B,
7396
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || f === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7397
- children: capitalize(i(y.toLowerCase()))
7396
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || f === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7397
+ children: capitalize(i(k.toLowerCase()))
7398
7398
  },
7399
- `sidebar-${y}`
7399
+ `sidebar-${k}`
7400
7400
  ))
7401
7401
  ] }) }) }),
7402
7402
  /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: E.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
@@ -7404,10 +7404,10 @@ const registerChaiLibrary = (o, n) => {
7404
7404
  ' "',
7405
7405
  d,
7406
7406
  '"'
7407
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7408
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7407
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7408
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7409
7409
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7410
- h === "all" ? filter(values(A), { group: y }) : values(A),
7410
+ h === "all" ? filter(values(A), { group: k }) : values(A),
7411
7411
  { hidden: !0 }
7412
7412
  ).map((j) => /* @__PURE__ */ jsx(
7413
7413
  CoreBlock,
@@ -7419,7 +7419,7 @@ const registerChaiLibrary = (o, n) => {
7419
7419
  },
7420
7420
  j.type
7421
7421
  )) })
7422
- ] }, y)) }) }) })
7422
+ ] }, k)) }) }) })
7423
7423
  ] })
7424
7424
  ] });
7425
7425
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7769,7 +7769,7 @@ const Input = ({ node: o }) => {
7769
7769
  var R;
7770
7770
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7771
7771
  let p = null;
7772
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: x, isSelected: f, willReceiveDrop: k, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
7772
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
7773
7773
  T.stopPropagation(), !l.includes(h) && o.toggle();
7774
7774
  }, _ = (T) => {
7775
7775
  T.isInternal && (p = T.isOpen, T.isOpen && T.close());
@@ -7780,15 +7780,15 @@ const Input = ({ node: o }) => {
7780
7780
  C(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7781
7781
  }, C = () => {
7782
7782
  A(null);
7783
- }, y = (T) => {
7783
+ }, k = (T) => {
7784
7784
  C(), T.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(T);
7785
7785
  };
7786
7786
  useEffect(() => {
7787
7787
  const T = setTimeout(() => {
7788
- k && !o.isOpen && !b && !l.includes(h) && o.toggle();
7788
+ y && !o.isOpen && !b && !l.includes(h) && o.toggle();
7789
7789
  }, 500);
7790
7790
  return () => clearTimeout(T);
7791
- }, [k, o, b]);
7791
+ }, [y, o, b]);
7792
7792
  const j = (T, D) => {
7793
7793
  const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7794
7794
  P && P.setAttribute("data-drop", D);
@@ -7823,7 +7823,7 @@ const Input = ({ node: o }) => {
7823
7823
  {
7824
7824
  onMouseEnter: () => g(h),
7825
7825
  onMouseLeave: () => m(),
7826
- onClick: y,
7826
+ onClick: k,
7827
7827
  style: n,
7828
7828
  "data-node-id": h,
7829
7829
  ref: l.includes(h) ? null : r,
@@ -7857,7 +7857,7 @@ const Input = ({ node: o }) => {
7857
7857
  className: cn(
7858
7858
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7859
7859
  f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7860
- k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7860
+ y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7861
7861
  (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7862
7862
  b && "opacity-20",
7863
7863
  l.includes(h) ? "opacity-50" : "",
@@ -8218,7 +8218,7 @@ const Input = ({ node: o }) => {
8218
8218
  },
8219
8219
  [d],
8220
8220
  200
8221
- ), k = useDebouncedCallback(
8221
+ ), y = useDebouncedCallback(
8222
8222
  (v, B) => {
8223
8223
  p(() => {
8224
8224
  const w = get(d, `colors.${v}`);
@@ -8240,7 +8240,7 @@ const Input = ({ node: o }) => {
8240
8240
  ColorPickerInput,
8241
8241
  {
8242
8242
  value: w,
8243
- onChange: (_) => k(B, _)
8243
+ onChange: (_) => y(B, _)
8244
8244
  }
8245
8245
  ),
8246
8246
  /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((_) => _.charAt(0).toUpperCase() + _.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
@@ -8770,8 +8770,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8770
8770
  (f = m.current) == null || f.focus();
8771
8771
  }, []);
8772
8772
  const x = (f) => {
8773
- const { usage: k } = f || {};
8774
- !l && k && g(k), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8773
+ const { usage: y } = f || {};
8774
+ !l && y && g(y), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8775
8775
  };
8776
8776
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8777
8777
  /* @__PURE__ */ jsxs(
@@ -9017,7 +9017,7 @@ function AIChatPanel() {
9017
9017
  }, f = () => {
9018
9018
  var b;
9019
9019
  (b = p.current) == null || b.click();
9020
- }, k = () => {
9020
+ }, y = () => {
9021
9021
  d(null), p.current && (p.current.value = "");
9022
9022
  };
9023
9023
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -9063,7 +9063,7 @@ function AIChatPanel() {
9063
9063
  size: "icon",
9064
9064
  variant: "destructive",
9065
9065
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9066
- onClick: k,
9066
+ onClick: y,
9067
9067
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9068
9068
  }
9069
9069
  )
@@ -9206,7 +9206,7 @@ const AiAssistant = () => {
9206
9206
  preloadedAttributes: n = [],
9207
9207
  onAttributesChange: r
9208
9208
  }) {
9209
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), k = usePageExternalData();
9209
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9210
9210
  useEffect(() => {
9211
9211
  l(n);
9212
9212
  }, [n]);
@@ -9236,23 +9236,23 @@ const AiAssistant = () => {
9236
9236
  }, _ = (S) => {
9237
9237
  S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
9238
9238
  }, E = useCallback((S) => {
9239
- const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
9239
+ const A = (k) => /[.,!?;:]/.test(k), N = (k, j, I) => {
9240
9240
  let L = "", R = "";
9241
- const T = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
9242
- return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < y.length && !A(D) && D !== " " && (R = " "), {
9241
+ const T = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
9242
+ return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < k.length && !A(D) && D !== " " && (R = " "), {
9243
9243
  text: L + I + R,
9244
9244
  prefixLength: L.length,
9245
9245
  suffixLength: R.length
9246
9246
  };
9247
9247
  }, C = f.current;
9248
9248
  if (C) {
9249
- const y = C.selectionStart || 0, j = C.value || "", I = C.selectionEnd || y;
9250
- if (I > y) {
9251
- const O = `{{${S}}}`, { text: P } = N(j, y, O), $ = j.slice(0, y) + P + j.slice(I);
9249
+ const k = C.selectionStart || 0, j = C.value || "", I = C.selectionEnd || k;
9250
+ if (I > k) {
9251
+ const O = `{{${S}}}`, { text: P } = N(j, k, O), $ = j.slice(0, k) + P + j.slice(I);
9252
9252
  p($);
9253
9253
  return;
9254
9254
  }
9255
- const R = `{{${S}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
9255
+ const R = `{{${S}}}`, { text: T } = N(j, k, R), D = j.slice(0, k) + T + j.slice(k);
9256
9256
  p(D);
9257
9257
  }
9258
9258
  }, []);
@@ -9286,7 +9286,7 @@ const AiAssistant = () => {
9286
9286
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9287
9287
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9288
9288
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9289
- !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: E })
9289
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: E })
9290
9290
  ] }),
9291
9291
  /* @__PURE__ */ jsx(
9292
9292
  Textarea,
@@ -9448,7 +9448,7 @@ const RootLayout = () => {
9448
9448
  ), { t: x } = useTranslation(), f = useMemo(
9449
9449
  () => [...p, ...u, ...g],
9450
9450
  [p, u, g]
9451
- ), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9451
+ ), y = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9452
9452
  useEffect(() => {
9453
9453
  if (n !== null) {
9454
9454
  const S = find(f, { id: n });
@@ -9473,7 +9473,7 @@ const RootLayout = () => {
9473
9473
  },
9474
9474
  [h]
9475
9475
  );
9476
- return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9476
+ 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: [
9477
9477
  /* @__PURE__ */ jsxs(
9478
9478
  "div",
9479
9479
  {
@@ -9657,25 +9657,122 @@ const RootLayout = () => {
9657
9657
  options: n
9658
9658
  }) => {
9659
9659
  const r = useToggleChaiFeatureFlag(o), a = useChaiFeatureFlag(o);
9660
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
9660
+ return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-3 rounded-md p-2 transition-colors hover:bg-gray-50 dark:hover:bg-gray-800", children: [
9661
9661
  /* @__PURE__ */ jsx(Switch, { checked: a, onCheckedChange: r }),
9662
- /* @__PURE__ */ jsxs("div", { className: "flex flex-col", children: [
9663
- /* @__PURE__ */ jsx("p", { className: "text-sm font-medium", children: n.key }),
9664
- /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: n.description })
9662
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
9663
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: n.key }),
9664
+ n.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: n.description })
9665
9665
  ] })
9666
9666
  ] });
9667
- }, showFeatureFlagAtom = atomWithStorage("show-feature-flag", !1), ChaiFeatureFlagsWidget = () => {
9668
- const o = useChaiFeatureFlags(), [n, r] = useAtom$1(showFeatureFlagAtom);
9669
- return useHotkeys("ctrl+shift+1,command+shift+1", () => r(!n)), n ? /* @__PURE__ */ jsxs(Popover, { open: !0, children: [
9670
- /* @__PURE__ */ jsx(PopoverTrigger, { children: /* @__PURE__ */ jsx(Settings$1, {}) }),
9671
- /* @__PURE__ */ jsx(PopoverContent, { children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col space-y-1", children: [
9672
- /* @__PURE__ */ jsxs("div", { className: "mb-2 px-1", children: [
9673
- /* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: "Feature Flags" }),
9674
- /* @__PURE__ */ jsx("p", { className: "text-xs text-gray-500 dark:text-gray-400", children: "Enable or disable experimental features" })
9675
- ] }),
9676
- /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-3 pt-2", children: Object.entries(o).map(([a, l]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: a, options: l }, a)) })
9677
- ] }) })
9678
- ] }) : null;
9667
+ }, showFeatureFlagAtom = atomWithStorage(
9668
+ "show-feature-flag",
9669
+ null
9670
+ ), ChaiFeatureFlagsWidgetComponent = ({
9671
+ close: o,
9672
+ position: n,
9673
+ updatePosition: r
9674
+ }) => {
9675
+ const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9676
+ if (!l.trim()) return a;
9677
+ const f = l.toLowerCase();
9678
+ return Object.fromEntries(
9679
+ Object.entries(a).filter(([y, b]) => {
9680
+ var v;
9681
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((v = b == null ? void 0 : b.description) == null ? void 0 : v.toLowerCase().includes(f));
9682
+ })
9683
+ );
9684
+ }, [a, l]), m = (f) => {
9685
+ d(!0), u({
9686
+ x: f.clientX - n.x,
9687
+ y: f.clientY - n.y
9688
+ });
9689
+ }, h = (f) => {
9690
+ if (!c) return;
9691
+ const y = f.clientX - p.x, b = f.clientY - p.y, v = f.currentTarget, B = v.offsetWidth, w = v.offsetHeight, _ = window.innerWidth - B, E = window.innerHeight - w, S = Math.max(0, Math.min(y, _)), A = Math.max(0, Math.min(b, E));
9692
+ r(S, A);
9693
+ }, x = () => {
9694
+ d(!1);
9695
+ };
9696
+ return useEffect(() => {
9697
+ const f = () => {
9698
+ c && d(!1);
9699
+ };
9700
+ return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
9701
+ }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
9702
+ "div",
9703
+ {
9704
+ onMouseDown: m,
9705
+ onMouseMove: h,
9706
+ onMouseUp: x,
9707
+ className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
9708
+ style: {
9709
+ left: n.x,
9710
+ top: n.y,
9711
+ cursor: c ? "grabbing" : "grab",
9712
+ userSelect: "none"
9713
+ },
9714
+ children: [
9715
+ /* @__PURE__ */ jsxs("div", { className: "relative sticky top-0 rounded-t-lg bg-white", children: [
9716
+ /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center justify-between", children: [
9717
+ /* @__PURE__ */ jsxs("div", { children: [
9718
+ /* @__PURE__ */ jsxs("h3", { className: "flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100", children: [
9719
+ /* @__PURE__ */ jsx(DragHandleDots2Icon, {}),
9720
+ " Feature Flags"
9721
+ ] }),
9722
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-gray-400 dark:text-gray-400", children: [
9723
+ "Toggle experimental features (",
9724
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: "Ctrl+Shift+1" }),
9725
+ " to toggle)"
9726
+ ] })
9727
+ ] }),
9728
+ /* @__PURE__ */ jsx(
9729
+ Button,
9730
+ {
9731
+ variant: "ghost",
9732
+ size: "sm",
9733
+ onClick: o,
9734
+ className: "absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",
9735
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
9736
+ }
9737
+ )
9738
+ ] }),
9739
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
9740
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-gray-400" }),
9741
+ /* @__PURE__ */ jsx(
9742
+ Input$1,
9743
+ {
9744
+ type: "search",
9745
+ placeholder: "Search features...",
9746
+ className: "w-full pl-8",
9747
+ value: l,
9748
+ onChange: (f) => i(f.target.value),
9749
+ autoFocus: !0
9750
+ }
9751
+ )
9752
+ ] })
9753
+ ] }),
9754
+ /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: y }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
9755
+ 'No features found matching "',
9756
+ l,
9757
+ '"'
9758
+ ] }) }) })
9759
+ ]
9760
+ }
9761
+ );
9762
+ }, ChaiFeatureFlagsWidget = () => {
9763
+ const [o, n] = useAtom$1(showFeatureFlagAtom);
9764
+ return useHotkeys(
9765
+ "ctrl+shift+1,command+shift+1",
9766
+ () => n((r) => r ? { ...r, show: !r.show } : { x: 0, y: 0, show: !0 }),
9767
+ { enableOnFormTags: !0 }
9768
+ ), o != null && o.show ? /* @__PURE__ */ jsx(
9769
+ ChaiFeatureFlagsWidgetComponent,
9770
+ {
9771
+ position: o,
9772
+ close: () => n((r) => ({ ...r, show: !1 })),
9773
+ updatePosition: (r, a) => n((l) => ({ ...l, x: r, y: a }))
9774
+ }
9775
+ ) : null;
9679
9776
  }, setDebugLogs = (o) => {
9680
9777
  }, getParentNodeIds = (o, n) => {
9681
9778
  const r = [];
@@ -9777,38 +9874,38 @@ const RootLayout = () => {
9777
9874
  return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
9778
9875
  }), x = m[1] || (() => {
9779
9876
  let A, N;
9780
- const C = (y) => {
9877
+ const C = (k) => {
9781
9878
  try {
9782
- y();
9879
+ k();
9783
9880
  } catch (j) {
9784
9881
  A || (A = !0, N = j);
9785
9882
  }
9786
9883
  };
9787
9884
  do {
9788
9885
  c.f && C(c.f);
9789
- const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
9886
+ const k = /* @__PURE__ */ new Set(), j = k.add.bind(k);
9790
9887
  a.forEach((I) => {
9791
9888
  var L;
9792
9889
  return (L = n.get(I)) == null ? void 0 : L.l.forEach(j);
9793
- }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(C), a.size && f();
9890
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && f();
9794
9891
  } while (a.size || i.size || l.size);
9795
9892
  if (A)
9796
9893
  throw N;
9797
9894
  }), f = m[2] || (() => {
9798
- const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
9799
- for (; y.length; ) {
9800
- const j = y[y.length - 1], I = h(j);
9895
+ const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9896
+ for (; k.length; ) {
9897
+ const j = k[k.length - 1], I = h(j);
9801
9898
  if (C.has(j)) {
9802
- y.pop();
9899
+ k.pop();
9803
9900
  continue;
9804
9901
  }
9805
9902
  if (N.has(j)) {
9806
- r.get(j) === I.n && A.push([j, I]), C.add(j), y.pop();
9903
+ r.get(j) === I.n && A.push([j, I]), C.add(j), k.pop();
9807
9904
  continue;
9808
9905
  }
9809
9906
  N.add(j);
9810
9907
  for (const L of getMountedOrPendingDependents(j, I, n))
9811
- N.has(L) || y.push(L);
9908
+ N.has(L) || k.push(L);
9812
9909
  }
9813
9910
  for (let j = A.length - 1; j >= 0; --j) {
9814
9911
  const [I, L] = A[j];
@@ -9818,20 +9915,20 @@ const RootLayout = () => {
9818
9915
  R = !0;
9819
9916
  break;
9820
9917
  }
9821
- R && (k(I), B(I)), r.delete(I);
9918
+ R && (y(I), B(I)), r.delete(I);
9822
9919
  }
9823
- }), k = m[3] || ((A) => {
9920
+ }), y = m[3] || ((A) => {
9824
9921
  var N, C;
9825
- const y = h(A);
9826
- if (isAtomStateInitialized(y) && (n.has(A) && r.get(A) !== y.n || Array.from(y.d).every(
9922
+ const k = h(A);
9923
+ if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
9827
9924
  ([P, $]) => (
9828
9925
  // Recursively, read the atom state of the dependency, and
9829
9926
  // check if the atom epoch number is unchanged
9830
- k(P).n === $
9927
+ y(P).n === $
9831
9928
  )
9832
9929
  )))
9833
- return y;
9834
- y.d.clear();
9930
+ return k;
9931
+ k.d.clear();
9835
9932
  let j = !0;
9836
9933
  const I = () => {
9837
9934
  n.has(A) && (B(A), f(), x());
@@ -9846,11 +9943,11 @@ const RootLayout = () => {
9846
9943
  throw new Error("no atom init");
9847
9944
  return returnAtomValue(H);
9848
9945
  }
9849
- const M = k(P);
9946
+ const M = y(P);
9850
9947
  try {
9851
9948
  return returnAtomValue(M);
9852
9949
  } finally {
9853
- y.d.set(P, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9950
+ k.d.set(P, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9854
9951
  }
9855
9952
  };
9856
9953
  let R, T;
@@ -9868,30 +9965,30 @@ const RootLayout = () => {
9868
9965
  }
9869
9966
  }), T;
9870
9967
  }
9871
- }, O = y.n;
9968
+ }, O = k.n;
9872
9969
  try {
9873
9970
  const P = d(A, L, D);
9874
9971
  return setAtomStateValueOrPromise(A, P, h), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
9875
9972
  I,
9876
9973
  I
9877
- )), y;
9974
+ )), k;
9878
9975
  } catch (P) {
9879
- return delete y.v, y.e = P, ++y.n, y;
9976
+ return delete k.v, k.e = P, ++k.n, k;
9880
9977
  } finally {
9881
- j = !1, O !== y.n && r.get(A) === O && (r.set(A, y.n), a.add(A), (C = c.c) == null || C.call(c, A));
9978
+ j = !1, O !== k.n && r.get(A) === O && (r.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
9882
9979
  }
9883
9980
  }), b = m[4] || ((A) => {
9884
9981
  const N = [A];
9885
9982
  for (; N.length; ) {
9886
- const C = N.pop(), y = h(C);
9887
- for (const j of getMountedOrPendingDependents(C, y, n)) {
9983
+ const C = N.pop(), k = h(C);
9984
+ for (const j of getMountedOrPendingDependents(C, k, n)) {
9888
9985
  const I = h(j);
9889
9986
  r.set(j, I.n), N.push(j);
9890
9987
  }
9891
9988
  }
9892
9989
  }), v = m[5] || ((A, ...N) => {
9893
9990
  let C = !0;
9894
- const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
9991
+ const k = (I) => returnAtomValue(y(I)), j = (I, ...L) => {
9895
9992
  var R;
9896
9993
  const T = h(I);
9897
9994
  try {
@@ -9908,22 +10005,22 @@ const RootLayout = () => {
9908
10005
  }
9909
10006
  };
9910
10007
  try {
9911
- return p(A, y, j, ...N);
10008
+ return p(A, k, j, ...N);
9912
10009
  } finally {
9913
10010
  C = !1;
9914
10011
  }
9915
10012
  }), B = m[6] || ((A) => {
9916
10013
  var N;
9917
- const C = h(A), y = n.get(A);
9918
- if (y && !isPendingPromise(C.v)) {
10014
+ const C = h(A), k = n.get(A);
10015
+ if (k && !isPendingPromise(C.v)) {
9919
10016
  for (const [j, I] of C.d)
9920
- if (!y.d.has(j)) {
10017
+ if (!k.d.has(j)) {
9921
10018
  const L = h(j);
9922
- w(j).t.add(A), y.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
10019
+ w(j).t.add(A), k.d.add(j), I !== L.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9923
10020
  }
9924
- for (const j of y.d || [])
10021
+ for (const j of k.d || [])
9925
10022
  if (!C.d.has(j)) {
9926
- y.d.delete(j);
10023
+ k.d.delete(j);
9927
10024
  const I = _(j);
9928
10025
  I == null || I.t.delete(A);
9929
10026
  }
@@ -9931,16 +10028,16 @@ const RootLayout = () => {
9931
10028
  }), w = m[7] || ((A) => {
9932
10029
  var N;
9933
10030
  const C = h(A);
9934
- let y = n.get(A);
9935
- if (!y) {
9936
- k(A);
10031
+ let k = n.get(A);
10032
+ if (!k) {
10033
+ y(A);
9937
10034
  for (const j of C.d.keys())
9938
10035
  w(j).t.add(A);
9939
- if (y = {
10036
+ if (k = {
9940
10037
  l: /* @__PURE__ */ new Set(),
9941
10038
  d: new Set(C.d.keys()),
9942
10039
  t: /* @__PURE__ */ new Set()
9943
- }, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
10040
+ }, n.set(A, k), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9944
10041
  const j = () => {
9945
10042
  let I = !0;
9946
10043
  const L = (...R) => {
@@ -9952,7 +10049,7 @@ const RootLayout = () => {
9952
10049
  };
9953
10050
  try {
9954
10051
  const R = g(A, L);
9955
- R && (y.u = () => {
10052
+ R && (k.u = () => {
9956
10053
  I = !0;
9957
10054
  try {
9958
10055
  R();
@@ -9967,23 +10064,23 @@ const RootLayout = () => {
9967
10064
  l.add(j);
9968
10065
  }
9969
10066
  }
9970
- return y;
10067
+ return k;
9971
10068
  }), _ = m[8] || ((A) => {
9972
10069
  var N;
9973
10070
  const C = h(A);
9974
- let y = n.get(A);
9975
- if (y && !y.l.size && !Array.from(y.t).some((j) => {
10071
+ let k = n.get(A);
10072
+ if (k && !k.l.size && !Array.from(k.t).some((j) => {
9976
10073
  var I;
9977
10074
  return (I = n.get(j)) == null ? void 0 : I.d.has(A);
9978
10075
  })) {
9979
- y.u && i.add(y.u), y = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
10076
+ k.u && i.add(k.u), k = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
9980
10077
  for (const j of C.d.keys()) {
9981
10078
  const I = _(j);
9982
10079
  I == null || I.t.delete(A);
9983
10080
  }
9984
10081
  return;
9985
10082
  }
9986
- return y;
10083
+ return k;
9987
10084
  }), E = [
9988
10085
  // store state
9989
10086
  o,
@@ -10002,14 +10099,14 @@ const RootLayout = () => {
10002
10099
  h,
10003
10100
  x,
10004
10101
  f,
10005
- k,
10102
+ y,
10006
10103
  b,
10007
10104
  v,
10008
10105
  B,
10009
10106
  w,
10010
10107
  _
10011
10108
  ], S = {
10012
- get: (A) => returnAtomValue(k(A)),
10109
+ get: (A) => returnAtomValue(y(A)),
10013
10110
  set: (A, ...N) => {
10014
10111
  try {
10015
10112
  return v(A, ...N);
@@ -10018,9 +10115,9 @@ const RootLayout = () => {
10018
10115
  }
10019
10116
  },
10020
10117
  sub: (A, N) => {
10021
- const y = w(A).l;
10022
- return y.add(N), x(), () => {
10023
- y.delete(N), _(A), x();
10118
+ const k = w(A).l;
10119
+ return k.add(N), x(), () => {
10120
+ k.delete(N), _(A), x();
10024
10121
  };
10025
10122
  }
10026
10123
  };
@@ -10142,7 +10239,7 @@ const useAutoSave = () => {
10142
10239
  /* @__PURE__ */ jsx(ChaiWatchers, { ...o }),
10143
10240
  /* @__PURE__ */ jsx(PreviewScreen, {}),
10144
10241
  /* @__PURE__ */ jsx(Toaster, { richColors: !0 }),
10145
- /* @__PURE__ */ jsx("div", { className: "fixed bottom-4 left-4 z-50", children: /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {}) })
10242
+ /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {})
10146
10243
  ] }) });
10147
10244
  };
10148
10245
  if (typeof window > "u")
@@ -10170,7 +10267,7 @@ export {
10170
10267
  getBlocksFromHTML as convertHTMLToChaiBlocks,
10171
10268
  generateUUID as generateBlockId,
10172
10269
  getBlocksFromHTML,
10173
- We as i18n,
10270
+ ze as i18n,
10174
10271
  cn$2 as mergeClasses,
10175
10272
  registerBlockSettingField,
10176
10273
  registerBlockSettingTemplate,