@chaibuilder/sdk 2.3.0 → 2.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -3,15 +3,15 @@ var V = (o, n, r) => n in o ? U(o, n, { enumerable: !0, configurable: !0, writab
3
3
  var F = (o, n, r) => V(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
- import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, ResetIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
6
+ import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
7
7
  import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
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
- 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";
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-DW7GHkUt.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 } 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";
@@ -32,13 +32,12 @@ import { useEditor, BubbleMenu as BubbleMenu$1, EditorContent } from "@tiptap/re
32
32
  import StarterKit from "@tiptap/starter-kit";
33
33
  import RjForm from "@rjsf/core";
34
34
  import validator from "@rjsf/validator-ajv8";
35
- import "next-themes";
36
35
  import Autosuggest from "react-autosuggest";
37
36
  import { useFeature } from "flagged";
38
37
  import { parse, stringify } from "himalaya";
39
38
  import { Tree } from "react-arborist";
40
39
  import i18n from "i18next";
41
- import { default as We } from "i18next";
40
+ import { default as ze } from "i18next";
42
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
43
42
  import tailwindForms from "@tailwindcss/forms";
44
43
  import tailwindTypography from "@tailwindcss/typography";
@@ -47,6 +46,7 @@ import "@mhsdesign/jit-browser-tailwindcss";
47
46
  import twContainer from "@tailwindcss/container-queries";
48
47
  import { ErrorBoundary } from "react-error-boundary";
49
48
  import { motion } from "framer-motion";
49
+ import "next-themes";
50
50
  import { useHotkeys } from "react-hotkeys-hook";
51
51
  import { flip } from "@floating-ui/dom";
52
52
  import { useFloating, shift } from "@floating-ui/react-dom";
@@ -297,12 +297,12 @@ class PubSub {
297
297
  }
298
298
  }
299
299
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: n }) => {
300
- const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (m) => c ? get(m, "_parent") === c : !get(m, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (m) => {
301
- if (m === "CHILD")
300
+ const { t: r } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (h) => {
301
+ if (h === "CHILD")
302
302
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
303
303
  else {
304
- const h = { _id: c || "", position: d == null ? void 0 : d.length };
305
- m === "BEFORE" ? h.position = Math.max(u, 0) : m === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
304
+ const m = { _id: c || "", position: d == null ? void 0 : d.length };
305
+ h === "BEFORE" ? m.position = Math.max(u, 0) : h === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
306
306
  }
307
307
  };
308
308
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
@@ -337,20 +337,20 @@ function insertBlocksAtPosition(o, n, r, a) {
337
337
  let i = [...o];
338
338
  if (r) {
339
339
  const u = o.find((g) => g._id === r);
340
- if (u && u.content !== void 0 && u.content !== "" && !o.some((m) => m._parent === r)) {
341
- const h = {
340
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === r)) {
341
+ const m = {
342
342
  _id: generateUUID(),
343
343
  _parent: r,
344
344
  _type: "Text",
345
345
  content: u.content
346
346
  };
347
347
  Object.keys(u).forEach((x) => {
348
- x.startsWith("content-") && (h[x] = u[x]);
349
- }), l.unshift(h), i = i.map((x) => {
348
+ x.startsWith("content-") && (m[x] = u[x]);
349
+ }), l.unshift(m), 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;
@@ -386,13 +386,13 @@ function moveNode(o, n, r, a) {
386
386
  const l = findNodeById(o, n), i = findNodeById(o, r);
387
387
  if (!l || !i) return !1;
388
388
  i.children || (i.model.children = []);
389
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((m) => m.model._id === n);
389
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === n);
390
390
  l.drop(), c = Math.max(c, 0);
391
391
  const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === r && c <= a ? a - 1 : a;
392
392
  try {
393
393
  i.addChildAtIndex(l, p);
394
- } catch (m) {
395
- return console.error("Error adding child to parent:", m), !1;
394
+ } catch (h) {
395
+ return console.error("Error adding child to parent:", h), !1;
396
396
  }
397
397
  return !0;
398
398
  }
@@ -433,8 +433,8 @@ function handleNewParentTextBlock(o, n, r) {
433
433
  const d = o.map((u) => {
434
434
  if (u._id === r) {
435
435
  const g = { ...u, content: "" };
436
- return Object.keys(g).forEach((m) => {
437
- m.startsWith("content-") && (g[m] = "");
436
+ return Object.keys(g).forEach((h) => {
437
+ h.startsWith("content-") && (g[h] = "");
438
438
  }), g;
439
439
  }
440
440
  return u;
@@ -451,7 +451,7 @@ function moveBlocksWithChildren(o, n, r, a) {
451
451
  const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
452
452
  if (moveNode(p, n, c, a)) {
453
453
  let u = flattenTree(p);
454
- const g = u.find((m) => m._id === n);
454
+ const g = u.find((h) => h._id === n);
455
455
  return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
456
456
  }
457
457
  return i;
@@ -475,22 +475,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
475
475
  }, removeNestedBlocks = (o, n) => {
476
476
  let r = [...o], a = [];
477
477
  n.forEach((d) => {
478
- const p = r.find((m) => m._id === d);
478
+ const p = r.find((h) => h._id === d);
479
479
  if (!p || !p._parent) return;
480
- const u = p._parent, g = r.filter((m) => m._parent === u);
480
+ const u = p._parent, g = r.filter((h) => h._parent === u);
481
481
  if (g.length === 2) {
482
- const m = g.find((h) => h._id !== d);
483
- if (m && m._type === "Text") {
484
- const h = r.find((x) => x._id === u);
485
- h && "content" in h && (r = r.map((x) => {
482
+ const h = g.find((m) => m._id !== d);
483
+ if (h && h._type === "Text") {
484
+ const m = r.find((x) => x._id === u);
485
+ m && "content" in m && (r = r.map((x) => {
486
486
  if (x._id === u) {
487
- const f = { ...x, content: m.content };
488
- return Object.keys(m).forEach((k) => {
489
- k.startsWith("content-") && (f[k] = m[k]);
487
+ const f = { ...x, content: h.content };
488
+ return Object.keys(h).forEach((y) => {
489
+ y.startsWith("content-") && (f[y] = h[y]);
490
490
  }), f;
491
491
  }
492
492
  return x;
493
- }), a.push(m._id));
493
+ }), a.push(h._id));
494
494
  }
495
495
  }
496
496
  });
@@ -572,7 +572,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
572
572
  status: "idle",
573
573
  props: {},
574
574
  error: void 0
575
- }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), m = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
575
+ }), c = useUpdateBlocksPropsRealtime(), d = useBuilderProp("getBlockAsyncProps", async (x) => ({})), p = useSetAtom$1(blockRepeaterDataAtom), u = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), g = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), h = (o == null ? void 0 : o._type) !== "Repeater" && n === "live";
576
576
  return useEffect(() => {
577
577
  if (n === "mock") {
578
578
  if (isFunction(a)) {
@@ -584,7 +584,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
584
584
  }
585
585
  return;
586
586
  }
587
- n === "live" && (!g && !m || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
587
+ n === "live" && (!g && !h || (i((x) => ({ ...x, status: "loading", props: {} })), d({ block: o }).then((x = {}) => {
588
588
  g ? (p((f) => ({
589
589
  ...f,
590
590
  [o._id]: {
@@ -599,7 +599,7 @@ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyn
599
599
  [o._id]: { status: "error", error: x, props: [] }
600
600
  })), i((f) => ({ ...f, status: "error", error: x, props: {} }))) : i((f) => ({ ...f, status: "error", error: x, props: {} }));
601
601
  })));
602
- }, [o == null ? void 0 : o._id, u, g, m, a, n]), {
602
+ }, [o == null ? void 0 : o._id, u, g, h, a, n]), {
603
603
  $loading: get(l, "status") === "loading",
604
604
  ...o ? get(l, "props", {}) : {}
605
605
  };
@@ -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
  }
@@ -864,25 +864,25 @@ const undoRedoStateAtom = atom({
864
864
  }, useAddBlock = () => {
865
865
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
866
866
  (i, c, d) => {
867
- var h;
867
+ var m;
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;
877
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(h = first(i)) == null ? void 0 : h._id]), first(i);
877
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
878
878
  },
879
879
  [r, o, n]
880
880
  );
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,
@@ -891,8 +891,8 @@ const undoRedoStateAtom = atom({
891
891
  ...has(i, "_name") && { _name: i._name },
892
892
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
893
893
  };
894
- let m, h;
895
- return c && (m = find(o, { _id: c }), g._parent = c, h = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, h = m._parent), r([g], h, d), n([g._id]), g;
894
+ let h, m;
895
+ return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), r([g], m, d), n([g._id]), g;
896
896
  },
897
897
  [r, a, o, n]
898
898
  ), addPredefinedBlock: a };
@@ -2332,30 +2332,30 @@ const getBlockWithChildren = (o, n) => {
2332
2332
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
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
- 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];
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, h = (m, x) => {
2336
+ const f = cloneDeep(x.find((y) => y._id === m));
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 (m, x, f, y) => {
2350
2350
  if (l) {
2351
2351
  n(!0), a(null);
2352
2352
  try {
2353
- const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [m(x, d)], B = await l(h, addLangToPrompt(f, g, h), v, b), { blocks: w, error: _ } = B;
2353
+ const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p) : [h(x, d)], B = await l(m, addLangToPrompt(f, g, m), v, b), { blocks: w, error: _ } = B;
2354
2354
  if (_) {
2355
2355
  a(_);
2356
2356
  return;
2357
2357
  }
2358
- if (h === "styles") {
2358
+ if (m === "styles") {
2359
2359
  const E = w.map((S) => {
2360
2360
  for (const A in S)
2361
2361
  A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
@@ -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
  },
@@ -2458,17 +2458,17 @@ const getBlockWithChildren = (o, n) => {
2458
2458
  r(d), a([]);
2459
2459
  const u = {
2460
2460
  _chai_copied_blocks: d.flatMap((g) => {
2461
- const m = getDuplicatedBlocks(o, g, null);
2461
+ const h = getDuplicatedBlocks(o, g, null);
2462
2462
  if (!p)
2463
- return m;
2464
- let h = [];
2465
- for (const x of m)
2463
+ return h;
2464
+ let m = [];
2465
+ for (const x of h)
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))), m = [...m, ...f];
2469
2469
  } else
2470
- h.push(x);
2471
- return h;
2470
+ m.push(x);
2471
+ return m;
2472
2472
  })
2473
2473
  };
2474
2474
  if (!navigator.clipboard) {
@@ -2506,13 +2506,13 @@ const getBlockWithChildren = (o, n) => {
2506
2506
  (a, l = null) => {
2507
2507
  const i = [];
2508
2508
  each(a, (c) => {
2509
- const d = o.find((h) => h._id === c);
2509
+ const d = o.find((m) => m._id === c);
2510
2510
  l ? l === "root" && (l = null) : l = d._parent;
2511
2511
  const g = filter(
2512
2512
  o,
2513
- (h) => isString(l) ? h._parent === l : !h._parent
2514
- ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
2515
- r(m, l, g), i.push(get(m, "0._id", ""));
2513
+ (m) => isString(l) ? m._parent === l : !m._parent
2514
+ ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
2515
+ r(h, l, g), i.push(get(h, "0._id", ""));
2516
2516
  }), n(i);
2517
2517
  },
2518
2518
  [o, n]
@@ -2649,13 +2649,13 @@ const getBlockWithChildren = (o, n) => {
2649
2649
  return map(i, (c) => {
2650
2650
  const d = o(c), p = a;
2651
2651
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2652
- return each(p, (m) => {
2653
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2652
+ return each(p, (h) => {
2653
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2654
2654
  u = u.replace(x, " ").replace(/\s+/g, " ").trim();
2655
- const f = first(m.split(":"));
2656
- includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(m.split(":").pop().trim());
2657
- }), each(p, (m) => {
2658
- const h = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2655
+ const f = first(h.split(":"));
2656
+ includes(["2xl", "xl", "lg", "md", "sm"], f) && p.push(h.split(":").pop().trim());
2657
+ }), each(p, (h) => {
2658
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), x = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2659
2659
  g = g.replace(x, " ").replace(/\s+/g, " ").trim();
2660
2660
  }), {
2661
2661
  ids: [d._id],
@@ -2789,21 +2789,21 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2789
2789
  return "VERTICAL";
2790
2790
  }
2791
2791
  }, isDisabledControl = (o, n, r) => !!(o && (r === "UP" || r === "LEFT") || n && (r === "DOWN" || r === "RIGHT")), useBlockController = (o, n) => {
2792
- const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, m = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), x = useCallback(
2792
+ const [r] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(r, (f) => c ? get(f, "_parent") === c : !get(f, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), x = useCallback(
2793
2793
  (f) => {
2794
- isDisabledControl(g, m, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
2794
+ isDisabledControl(g, h, f) || p || (f === "UP" || f === "LEFT" ? l([i], c || null, u - 1) : (f === "DOWN" || f === "RIGHT") && l([i], c || null, u + 2), n());
2795
2795
  },
2796
- [g, m, p, u, i, c, n]
2796
+ [g, h, p, u, i, c, n]
2797
2797
  );
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]
2806
- ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: m, moveBlock: x, orientation: h };
2806
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: x, orientation: m };
2807
2807
  }, BlockController = ({ block: o, updateFloatingBar: n }) => {
2808
2808
  const { isOnlyChild: r, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
2809
2809
  o,
@@ -2943,27 +2943,27 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2943
2943
  i([null]);
2944
2944
  }, [r, n]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
2945
2945
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: n }) => {
2946
- const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: m, update: h } = useFloating({
2946
+ const r = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), { editingBlockId: p } = useInlineEditing(), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
2947
2947
  placement: "top-start",
2948
2948
  middleware: [shift(), flip()],
2949
2949
  elements: { reference: n }
2950
2950
  });
2951
- useResizeObserver(n, () => h(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
2951
+ useResizeObserver(n, () => m(), n !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
2952
2952
  const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
2953
2953
  return !n || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
2954
2954
  "div",
2955
2955
  {
2956
2956
  role: "button",
2957
2957
  tabIndex: 0,
2958
- ref: m.setFloating,
2958
+ ref: h.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(
@@ -2980,7 +2980,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2980
2980
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
2981
2981
  canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
2982
2982
  canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => r([o == null ? void 0 : o._id]) }) : null,
2983
- d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: h })
2983
+ d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: m })
2984
2984
  ] })
2985
2985
  ]
2986
2986
  }
@@ -3115,20 +3115,20 @@ F(Frame, "defaultProps", {
3115
3115
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
3116
3116
  });
3117
3117
  const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: n })), useKeyEventWatcher = (o) => {
3118
- const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), h = o ? { document: o } : {};
3118
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
3119
3119
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys(
3120
3120
  "ctrl+c,command+c",
3121
3121
  () => u(n),
3122
- { ...h, enabled: !isEmpty(n), preventDefault: !0 },
3122
+ { ...m, enabled: !isEmpty(n), preventDefault: !0 },
3123
3123
  [n, u]
3124
3124
  ), useHotkeys(
3125
3125
  "ctrl+v,command+v",
3126
3126
  () => {
3127
- g(n[0]) && m(n);
3127
+ g(n[0]) && h(n);
3128
3128
  },
3129
- { ...h, enabled: !isEmpty(n), preventDefault: !0 },
3130
- [n, g, m]
3131
- ), useHotkeys("esc", () => r([]), h, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...h, enabled: !isEmpty(n), preventDefault: !0 }, [
3129
+ { ...m, enabled: !isEmpty(n), preventDefault: !0 },
3130
+ [n, g, h]
3131
+ ), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, enabled: !isEmpty(n), preventDefault: !0 }, [
3132
3132
  n,
3133
3133
  i
3134
3134
  ]), useHotkeys(
@@ -3136,7 +3136,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3136
3136
  (x) => {
3137
3137
  x.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3138
3138
  },
3139
- h,
3139
+ m,
3140
3140
  [n, l]
3141
3141
  );
3142
3142
  }, KeyboardHandler = () => {
@@ -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 h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), y = x == null ? void 0 : x.contains(h);
3431
+ if (!f && !y) {
3432
3432
  const b = (u == null ? void 0 : u.getHTML()) || "";
3433
3433
  r(b);
3434
3434
  }
@@ -3445,10 +3445,10 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3445
3445
  });
3446
3446
  }, [c]);
3447
3447
  const d = useMemo(() => {
3448
- var m;
3448
+ var h;
3449
3449
  const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
3450
3450
  if (!n) return u;
3451
- const g = ((m = n == null ? void 0 : n.className) == null ? void 0 : m.replace("sr-only", "")) || "";
3451
+ const g = ((h = n == null ? void 0 : n.className) == null ? void 0 : h.replace("sr-only", "")) || "";
3452
3452
  return `${u} ${g}`;
3453
3453
  }, [n]), p = useCallback(
3454
3454
  (u) => {
@@ -3483,28 +3483,28 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3483
3483
  useEffect(() => {
3484
3484
  if (a.current) {
3485
3485
  a.current.innerText = n, a.current.focus();
3486
- const h = c.createRange(), x = d.getSelection();
3487
- h.selectNodeContents(a.current), h.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(h), a.current.focus();
3486
+ const m = c.createRange(), x = d.getSelection();
3487
+ m.selectNodeContents(a.current), m.collapse(!1), x == null || x.removeAllRanges(), x == null || x.addRange(m), a.current.focus();
3488
3488
  } else
3489
3489
  r();
3490
3490
  }, [c, d]);
3491
3491
  const p = useMemo(() => {
3492
3492
  var x;
3493
- const h = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
3494
- return h === "button" ? "div" : h;
3493
+ const m = ((x = o == null ? void 0 : o.tagName) == null ? void 0 : x.toLowerCase()) || "div";
3494
+ return m === "button" ? "div" : m;
3495
3495
  }, [o]), u = useCallback(
3496
- (h) => {
3497
- (h.key === "Enter" || h.key === "Escape") && i(h);
3496
+ (m) => {
3497
+ (m.key === "Enter" || m.key === "Escape") && i(m);
3498
3498
  },
3499
3499
  [i]
3500
3500
  ), g = useCallback(() => {
3501
3501
  r();
3502
- }, [r]), m = useMemo(() => {
3503
- var h;
3502
+ }, [r]), h = useMemo(() => {
3503
+ var m;
3504
3504
  return {
3505
3505
  id: "active-inline-editing-element",
3506
3506
  contentEditable: !0,
3507
- className: `${((h = o == null ? void 0 : o.className) == null ? void 0 : h.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
3507
+ className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
3508
3508
  style: cloneDeep(o == null ? void 0 : o.style) || {},
3509
3509
  onInput: (x) => {
3510
3510
  const f = x.target;
@@ -3519,12 +3519,12 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3519
3519
  ref: a,
3520
3520
  onBlur: g,
3521
3521
  onKeyDown: u,
3522
- ...m
3522
+ ...h
3523
3523
  }) });
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: h } = useBlockHighlight(), m = 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];
@@ -3534,31 +3534,31 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3534
3534
  (A) => {
3535
3535
  var C;
3536
3536
  const N = A || ((C = g.current) == null ? void 0 : C.innerText);
3537
- h([b], { [r]: N }), u(null), c(null), d(-1), f([]);
3537
+ m([b], { [r]: N }), u(null), c(null), d(-1), f([]);
3538
3538
  },
3539
- [b, h, c, f, x]
3539
+ [b, m, c, f, x]
3540
3540
  ), _ = useDebouncedCallback(
3541
3541
  (A) => {
3542
- h([b], { [r]: A });
3542
+ m([b], { [r]: A });
3543
3543
  },
3544
- [b, o, h, x],
3544
+ [b, o, m, x],
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
- const S = useMemo(() => p ? (m(), B === "RichText" ? /* @__PURE__ */ jsx(
3561
+ const S = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
3562
3562
  RichTextEditor,
3563
3563
  {
3564
3564
  blockContent: v,
@@ -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(
3616
- () => h ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
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(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
3616
+ () => m ? 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, m, 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]
@@ -3642,7 +3642,7 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3642
3642
  o
3643
3643
  ]
3644
3644
  ), _ = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3645
- if (isNull(x) || m.includes(i._id)) return null;
3645
+ if (isNull(x) || h.includes(i._id)) return null;
3646
3646
  let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
3647
3647
  ...w,
3648
3648
  children: r({
@@ -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: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.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: h }) }) : 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();
@@ -3711,11 +3711,11 @@ const ChaiFrame = React__default.forwardRef((o, n) => /* @__PURE__ */ jsx(Frame,
3711
3711
  if (d < n) {
3712
3712
  const u = parseFloat((d / n).toFixed(2).toString());
3713
3713
  let g = {};
3714
- const m = p * u, h = d * u;
3714
+ const h = p * u, m = d * u;
3715
3715
  p && (g = {
3716
3716
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3717
- height: 100 + (p - m) / m * 100 + "%",
3718
- width: 100 + (d - h) / h * 100 + "%"
3717
+ height: 100 + (p - h) / h * 100 + "%",
3718
+ width: 100 + (d - m) / m * 100 + "%"
3719
3719
  }), i({
3720
3720
  position: "relative",
3721
3721
  top: 0,
@@ -3764,19 +3764,19 @@ const CanvasEventsWatcher = () => {
3764
3764
  }), null;
3765
3765
  }, StaticCanvas = () => {
3766
3766
  const [o] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), r = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
3767
- (h) => {
3768
- i((x) => ({ ...x, width: h }));
3767
+ (m) => {
3768
+ i((x) => ({ ...x, width: m }));
3769
3769
  },
3770
3770
  [i]
3771
3771
  );
3772
3772
  useEffect(() => {
3773
3773
  if (!a.current) return;
3774
- const { clientWidth: h, clientHeight: x } = a.current;
3775
- i({ width: h, height: x });
3774
+ const { clientWidth: m, clientHeight: x } = a.current;
3775
+ i({ width: m, height: x });
3776
3776
  }, [a, o]);
3777
- const m = useMemo(() => {
3778
- let h = IframeInitialContent;
3779
- return h = h.replace("__HTML_DIR__", u), h;
3777
+ const h = useMemo(() => {
3778
+ let m = IframeInitialContent;
3779
+ return m = m.replace("__HTML_DIR__", u), m;
3780
3780
  }, [u]);
3781
3781
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
3782
3782
  "div",
@@ -3792,7 +3792,7 @@ const CanvasEventsWatcher = () => {
3792
3792
  id: "canvas-iframe",
3793
3793
  style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
3794
3794
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
3795
- initialContent: m,
3795
+ initialContent: h,
3796
3796
  children: [
3797
3797
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
3798
3798
  /* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
@@ -3822,7 +3822,7 @@ const CanvasEventsWatcher = () => {
3822
3822
  }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3823
3823
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3824
3824
  /* @__PURE__ */ jsx("p", { children: "Please try again." })
3825
- ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-DCGe1BPZ.js")), CanvasArea = () => {
3825
+ ] }) }), CodeEditor$1 = React__default.lazy(() => import("./code-editor-BqhH_IQC.js")), CanvasArea = () => {
3826
3826
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
3827
3827
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
3828
3828
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -3887,7 +3887,7 @@ const CanvasEventsWatcher = () => {
3887
3887
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
3888
3888
  ] });
3889
3889
  }, DefaultMediaManager = ({ close: o, onSelect: n, mode: r = "image" }) => {
3890
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), m = async (x) => {
3890
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (x) => {
3891
3891
  if (!x.trim()) {
3892
3892
  p(!1), g("Please enter a URL");
3893
3893
  return;
@@ -3899,9 +3899,9 @@ const CanvasEventsWatcher = () => {
3899
3899
  } finally {
3900
3900
  c(!1);
3901
3901
  }
3902
- }, { t: h } = useTranslation();
3902
+ }, { t: m } = useTranslation();
3903
3903
  return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
3904
- /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: h(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
3904
+ /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: m(`${r.charAt(0).toUpperCase() + r.slice(1)} Manager`) }),
3905
3905
  u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
3906
3906
  /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
3907
3907
  /* @__PURE__ */ jsx(AlertDescription, { children: u })
@@ -3910,20 +3910,20 @@ const CanvasEventsWatcher = () => {
3910
3910
  /* @__PURE__ */ jsx(
3911
3911
  Input$1,
3912
3912
  {
3913
- placeholder: h(`Enter ${r} URL`),
3913
+ placeholder: m(`Enter ${r} URL`),
3914
3914
  value: a,
3915
3915
  onChange: (x) => l(x.target.value),
3916
- onKeyUp: () => m(a)
3916
+ onKeyUp: () => h(a)
3917
3917
  }
3918
3918
  ),
3919
3919
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
3920
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: h("Cancel") }),
3920
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: m("Cancel") }),
3921
3921
  /* @__PURE__ */ jsx(
3922
3922
  Button,
3923
3923
  {
3924
3924
  onClick: () => n({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
3925
3925
  disabled: !d || i,
3926
- children: h("Insert")
3926
+ children: m("Insert")
3927
3927
  }
3928
3928
  )
3929
3929
  ] })
@@ -3950,16 +3950,16 @@ const CanvasEventsWatcher = () => {
3950
3950
  MediaManagerModal.displayName = "MediaManagerModal";
3951
3951
  const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
3952
3952
  const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (g) => {
3953
- const m = isArray(g) ? first(g) : g;
3954
- if (m) {
3955
- n(m == null ? void 0 : m.url);
3956
- const h = m == null ? void 0 : m.width, x = m == null ? void 0 : m.height;
3953
+ const h = isArray(g) ? first(g) : g;
3954
+ if (h) {
3955
+ n(h == null ? void 0 : h.url);
3956
+ const m = h == null ? void 0 : h.width, x = h == null ? void 0 : h.height;
3957
3957
  if (i != null && i._id) {
3958
3958
  const f = {
3959
- ...h && { width: h },
3959
+ ...m && { width: m },
3960
3960
  ...x && { height: x },
3961
- ...m.description && { alt: m.description },
3962
- ...m.id && { assetId: m.id }
3961
+ ...h.description && { alt: h.description },
3962
+ ...h.id && { assetId: h.id }
3963
3963
  };
3964
3964
  if (isEmpty(f)) return;
3965
3965
  c([i._id], f);
@@ -4004,18 +4004,18 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4004
4004
  ] })
4005
4005
  ] });
4006
4006
  }, PathDropdown = ({ data: o, onSelect: n, dataType: r }) => {
4007
- const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React__default.useCallback(
4008
- (m) => {
4009
- const h = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
4010
- m.type === "object" ? (l((x) => [...x, m.key]), c(m.value)) : h(m.type) && n([...a, m.key].join("."), r);
4007
+ const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
4008
+ (h) => {
4009
+ const m = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
4010
+ h.type === "object" ? (l((x) => [...x, h.key]), c(h.value)) : m(h.type) && n([...a, h.key].join("."), r);
4011
4011
  },
4012
4012
  [a, n, r]
4013
4013
  ), u = React__default.useCallback(() => {
4014
4014
  if (a.length > 0) {
4015
- const m = a.slice(0, -1);
4016
- l(m), c(m.reduce((h, x) => h[x], o));
4015
+ const h = a.slice(0, -1);
4016
+ l(h), c(h.reduce((m, x) => m[x], o));
4017
4017
  }
4018
- }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({ key: m, value: h, type: d(h) })).filter((m) => !startsWith(m.key, REPEATER_PREFIX) && m.key.includes("/") ? !1 : r === "value" ? m.type === "value" || m.type === "object" : r === "array" ? m.type === "array" || m.type === "object" : r === "object" ? m.type === "object" : !0) : [], [i, r]);
4018
+ }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0) : [], [i, r]);
4019
4019
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4020
4020
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4021
4021
  /* @__PURE__ */ jsxs(CommandList, { children: [
@@ -4025,36 +4025,36 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4025
4025
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4026
4026
  "Back"
4027
4027
  ] }),
4028
- g.map((m) => /* @__PURE__ */ jsxs(
4028
+ g.map((h) => /* @__PURE__ */ jsxs(
4029
4029
  CommandItem,
4030
4030
  {
4031
- value: m.key,
4031
+ value: h.key,
4032
4032
  disabled: !1,
4033
- onSelect: () => p(m),
4033
+ onSelect: () => p(h),
4034
4034
  className: "flex items-center justify-between",
4035
4035
  children: [
4036
4036
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
4037
- startsWith(m.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(m.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
4038
- startsWith(m.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
4037
+ startsWith(h.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(h.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
4038
+ startsWith(h.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(h.key, COLLECTION_PREFIX) ? h.key.replace(COLLECTION_PREFIX, "") : h.key
4039
4039
  ] }),
4040
4040
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4041
- r === "object" && m.type === "object" && /* @__PURE__ */ jsx(
4041
+ r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
4042
4042
  Button,
4043
4043
  {
4044
4044
  size: "sm",
4045
4045
  variant: "ghost",
4046
4046
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4047
- onClick: (h) => {
4048
- h.stopPropagation(), n([...a, m.key].join("."), r);
4047
+ onClick: (m) => {
4048
+ m.stopPropagation(), n([...a, h.key].join("."), r);
4049
4049
  },
4050
4050
  children: "Select"
4051
4051
  }
4052
4052
  ),
4053
- m.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" }) })
4053
+ 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" }) })
4054
4054
  ] })
4055
4055
  ]
4056
4056
  },
4057
- m.key
4057
+ h.key
4058
4058
  ))
4059
4059
  ] })
4060
4060
  ] })
@@ -4106,27 +4106,27 @@ const DataBindingSelector = ({
4106
4106
  }) => {
4107
4107
  const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
4108
4108
  if (i.length === 1) return "";
4109
- const g = i.find((x) => x._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4110
- return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
4109
+ const g = i.find((x) => x._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4110
+ return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
4111
4111
  }, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
4112
- (g, m) => {
4113
- if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), m === "array" || m === "object") {
4112
+ (g, h) => {
4113
+ if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), h === "array" || h === "object") {
4114
4114
  n(`{{${g}}}`, {}, r);
4115
4115
  return;
4116
4116
  }
4117
- const h = (b) => /[.,!?;:]/.test(b), x = (b, v, B) => {
4117
+ const m = (b) => /[.,!?;:]/.test(b), x = (b, v, B) => {
4118
4118
  let w = "", _ = "";
4119
4119
  const E = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
4120
- return v > 0 && (E === "." || !h(E) && E !== " ") && (w = " "), v < b.length && !h(S) && S !== " " && (_ = " "), {
4120
+ return v > 0 && (E === "." || !m(E) && E !== " ") && (w = " "), v < b.length && !m(S) && S !== " " && (_ = " "), {
4121
4121
  text: w + B + _,
4122
4122
  prefixLength: w.length,
4123
4123
  suffixLength: _.length
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();
@@ -4136,9 +4136,9 @@ const DataBindingSelector = ({
4136
4136
  else {
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
- S > 0 && A !== " " && !h(A) && (C = " ");
4140
- let y = "";
4141
- N && N !== " " && !h(N) && (y = " "), b.chain().insertContent(C + v + y).run();
4139
+ S > 0 && A !== " " && !m(A) && (C = " ");
4140
+ let k = "";
4141
+ N && N !== " " && !m(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,13 +4173,13 @@ 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"), [h, m] = 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
- 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")]);
4182
- j && Array.isArray(j) && h(get(j, [0, "name"], ""));
4178
+ if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
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
+ j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4183
4183
  })();
4184
4184
  }, [o]);
4185
4185
  const w = useDebouncedCallback(
@@ -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(":")), m(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,15 +4215,15 @@ 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
- h(""), f([]), b(-1), p(!1), r("");
4224
+ m(""), f([]), b(-1), p(!1), r("");
4225
4225
  }, A = (C) => {
4226
- h(C), p(!isEmpty(C)), c(!0), w(C);
4226
+ m(C), p(!isEmpty(C)), c(!0), w(C);
4227
4227
  };
4228
4228
  return /* @__PURE__ */ jsxs("div", { children: [
4229
4229
  /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
@@ -4232,14 +4232,14 @@ const DataBindingSelector = ({
4232
4232
  "input",
4233
4233
  {
4234
4234
  type: "text",
4235
- value: m,
4235
+ value: h,
4236
4236
  onChange: (C) => A(C.target.value),
4237
4237
  onKeyDown: E,
4238
4238
  placeholder: a(`Search ${B ?? ""}`),
4239
4239
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4240
4240
  }
4241
4241
  ),
4242
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4242
+ /* @__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" }) }) })
4243
4243
  ] }),
4244
4244
  (i || !isEmpty(x) || d && isEmpty(x)) && /* @__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: [
4245
4245
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4247,13 +4247,13 @@ const DataBindingSelector = ({
4247
4247
  ] }) : d && isEmpty(x) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4248
4248
  a("No results found for"),
4249
4249
  ' "',
4250
- m,
4250
+ h,
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
  " ",
@@ -4505,16 +4505,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4505
4505
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4506
4506
  useEffect(() => {
4507
4507
  if (o) {
4508
- const m = document.createElement("style");
4509
- return m.id = "rte-modal-styles", m.innerHTML = `
4508
+ const h = document.createElement("style");
4509
+ return h.id = "rte-modal-styles", h.innerHTML = `
4510
4510
  /* Ensure the NestedPathSelector popover appears above the dialog */
4511
4511
  .rte-path-selector + [data-radix-popper-content-wrapper],
4512
4512
  [data-radix-popper-content-wrapper] {
4513
4513
  z-index: 9999 !important;
4514
4514
  }
4515
- `, document.head.appendChild(m), () => {
4516
- const h = document.getElementById("rte-modal-styles");
4517
- h && h.remove();
4515
+ `, document.head.appendChild(h), () => {
4516
+ const m = document.getElementById("rte-modal-styles");
4517
+ m && m.remove();
4518
4518
  };
4519
4519
  }
4520
4520
  }, [o]);
@@ -4539,13 +4539,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4539
4539
  })
4540
4540
  ],
4541
4541
  content: a || "",
4542
- onUpdate: ({ editor: m }) => {
4543
- const h = m.getHTML();
4544
- l(h);
4542
+ onUpdate: ({ editor: h }) => {
4543
+ const m = h.getHTML();
4544
+ l(m);
4545
4545
  },
4546
- onBlur: ({ editor: m }) => {
4547
- const h = m.getHTML();
4548
- i(r, h);
4546
+ onBlur: ({ editor: h }) => {
4547
+ const m = h.getHTML();
4548
+ i(r, m);
4549
4549
  },
4550
4550
  editorProps: {
4551
4551
  attributes: {
@@ -4560,22 +4560,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4560
4560
  }, [o, u]), useEffect(() => {
4561
4561
  c.current && u && (c.current.__chaiRTE = u);
4562
4562
  }, [u, o]);
4563
- const g = (m) => {
4563
+ const g = (h) => {
4564
4564
  if (!u) return;
4565
- const h = `{{${m}}}`;
4565
+ const m = `{{${h}}}`;
4566
4566
  u.commands.focus();
4567
4567
  const { from: x, to: f } = u.state.selection;
4568
4568
  if (x !== f)
4569
- u.chain().deleteSelection().insertContent(h).run();
4569
+ u.chain().deleteSelection().insertContent(m).run();
4570
4570
  else {
4571
4571
  const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
4572
4572
  let _ = "";
4573
4573
  v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (_ = " ");
4574
4574
  let E = "";
4575
- w && w !== " " && !/[.,!?;:]/.test(w) && (E = " "), u.chain().insertContent(_ + h + E).run();
4575
+ w && w !== " " && !/[.,!?;:]/.test(w) && (E = " "), u.chain().insertContent(_ + m + E).run();
4576
4576
  }
4577
4577
  };
4578
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4578
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4579
4579
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4580
4580
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4581
4581
  Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4630,9 +4630,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4630
4630
  }, [g]), useEffect(() => {
4631
4631
  u(r || "");
4632
4632
  }, [r]);
4633
- const m = (x) => {
4633
+ const h = (x) => {
4634
4634
  a(x);
4635
- }, h = () => {
4635
+ }, m = () => {
4636
4636
  d(!1), g && g.commands.setContent(p);
4637
4637
  };
4638
4638
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4644,10 +4644,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4644
4644
  RTEModal,
4645
4645
  {
4646
4646
  isOpen: c,
4647
- onClose: h,
4647
+ onClose: m,
4648
4648
  id: o,
4649
4649
  value: p,
4650
- onChange: m,
4650
+ onChange: h,
4651
4651
  onBlur: l
4652
4652
  }
4653
4653
  )
@@ -4663,17 +4663,17 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4663
4663
  }, [a]), useEffect(() => {
4664
4664
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4665
4665
  }, [o, u]);
4666
- const m = () => {
4666
+ const h = () => {
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
- }, h = () => {
4673
+ }, m = () => {
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,12 +4681,12 @@ 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: [
4689
- /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4689
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4690
4690
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4691
4691
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
4692
4692
  " ",
@@ -4695,7 +4695,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4695
4695
  "/",
4696
4696
  u.length
4697
4697
  ] }) : "-" }),
4698
- /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4698
+ /* @__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]" }) }),
4699
4699
  /* @__PURE__ */ jsxs(
4700
4700
  "button",
4701
4701
  {
@@ -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
  )
@@ -4773,7 +4773,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4773
4773
  const r = get(o, "srcsets", []) || [], a = (c, d) => {
4774
4774
  const p = c.target.name, u = c.target.value;
4775
4775
  n({
4776
- srcsets: map(r, (g, m) => m === d ? { ...g, [p]: u } : g)
4776
+ srcsets: map(r, (g, h) => h === d ? { ...g, [p]: u } : g)
4777
4777
  });
4778
4778
  }, l = () => {
4779
4779
  n({ srcsets: [...r, {}] });
@@ -4868,12 +4868,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4868
4868
  required: p,
4869
4869
  schema: u,
4870
4870
  formData: g,
4871
- onChange: m
4871
+ onChange: h
4872
4872
  }) => {
4873
- const { selectedLang: h, fallbackLang: x, languages: f } = useLanguages(), k = useMemo(
4874
- () => isEmpty(f) ? "" : isEmpty(h) ? x : h,
4875
- [f, h, x]
4876
- ), b = useMemo(() => get(LANGUAGES, k, k), [k]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), _ = useMemo(
4873
+ const { selectedLang: m, fallbackLang: x, languages: f } = useLanguages(), y = useMemo(
4874
+ () => isEmpty(f) ? "" : isEmpty(m) ? x : m,
4875
+ [f, m, x]
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);
@@ -4923,7 +4923,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4923
4923
  {
4924
4924
  schema: u,
4925
4925
  onChange: (C) => {
4926
- m(C, g, o);
4926
+ h(C, g, o);
4927
4927
  },
4928
4928
  id: o,
4929
4929
  formData: g
@@ -4970,8 +4970,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4970
4970
  /* @__PURE__ */ jsx("span", { children: "Add" })
4971
4971
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
4972
4972
  const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
4973
- async ({ formData: g }, m) => {
4974
- l({ formData: g }, m);
4973
+ async ({ formData: g }, h) => {
4974
+ l({ formData: g }, h);
4975
4975
  },
4976
4976
  [l, i],
4977
4977
  400
@@ -5012,10 +5012,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5012
5012
  uiSchema: r,
5013
5013
  schema: n,
5014
5014
  formData: a,
5015
- onChange: ({ formData: g }, m) => {
5016
- if (!m || o !== (g == null ? void 0 : g._id)) return;
5017
- const h = take(m.split("."), 2).join(".").replace("root.", "");
5018
- u({ formData: g }, h);
5015
+ onChange: ({ formData: g }, h) => {
5016
+ if (!h || o !== (g == null ? void 0 : g._id)) return;
5017
+ const m = take(h.split("."), 2).join(".").replace("root.", "");
5018
+ u({ formData: g }, m);
5019
5019
  }
5020
5020
  },
5021
5021
  i
@@ -5027,14 +5027,14 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5027
5027
  }), a;
5028
5028
  };
5029
5029
  function BlockSettings() {
5030
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), x = ({ formData: E }, S, A) => {
5030
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: E }, S, A) => {
5031
5031
  S && (c == null ? void 0 : c._id) === n._id && a([n._id], { [S]: get(E, S) }, A);
5032
5032
  }, f = useCallback(
5033
5033
  debounce(({ formData: E }, S, A) => {
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) }));
@@ -5083,7 +5083,7 @@ function BlockSettings() {
5083
5083
  {
5084
5084
  blockId: g == null ? void 0 : g._id,
5085
5085
  onChange: b,
5086
- formData: h,
5086
+ formData: m,
5087
5087
  schema: w,
5088
5088
  uiSchema: _
5089
5089
  }
@@ -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
@@ -5105,56 +5105,50 @@ const BlockStylingProps = () => {
5105
5105
  const o = useSelectedBlock(), [n, r] = useSelectedStylingBlocks(), { t: a } = useTranslation();
5106
5106
  if (!o) return null;
5107
5107
  const l = Object.keys(o).filter(
5108
- (g) => typeof o[g] == "string" && o[g].startsWith("#styles:")
5109
- ), { reset: i, resetAll: c } = useResetBlockStyles(), d = !isEmpty(l) && l.length > 1, p = /* @__PURE__ */ jsxs(Button, { className: "h-6 w-full", variant: "outline", size: "sm", onClick: () => c(), children: [
5110
- /* @__PURE__ */ jsx(ResetIcon, {}),
5111
- a("Reset styles")
5112
- ] }), u = (g) => find(n, (m) => m.prop === g);
5113
- return /* @__PURE__ */ jsxs(Fragment, { children: [
5114
- p,
5115
- d && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5116
- /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5117
- a("Style element"),
5118
- ":"
5119
- ] }),
5120
- /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (g) => /* @__PURE__ */ jsxs(
5121
- Badge,
5122
- {
5123
- className: "flex cursor-pointer items-center gap-1 pr-1",
5124
- variant: u(g) ? "default" : "secondary",
5125
- onClick: () => {
5126
- r([{ id: `${g}-${o._id}`, blockId: o._id, prop: g }]);
5127
- },
5128
- children: [
5129
- startCase(g),
5130
- /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5131
- /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5132
- "button",
5133
- {
5134
- type: "button",
5135
- className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
5136
- onClick: (m) => m.stopPropagation(),
5137
- children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
5138
- }
5139
- ) }),
5140
- /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: /* @__PURE__ */ jsx(
5141
- DropdownMenuItem,
5142
- {
5143
- className: "text-xs",
5144
- onClick: () => {
5145
- i(g);
5146
- },
5147
- children: a("Reset style")
5148
- }
5149
- ) })
5150
- ] })
5151
- ]
5108
+ (p) => typeof o[p] == "string" && o[p].startsWith("#styles:")
5109
+ ), { reset: i } = useResetBlockStyles(), c = !isEmpty(l) && l.length > 1, d = (p) => find(n, (u) => u.prop === p);
5110
+ return /* @__PURE__ */ jsx(Fragment, { children: c && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5111
+ /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5112
+ a("Style element"),
5113
+ ":"
5114
+ ] }),
5115
+ /* @__PURE__ */ jsx("div", { className: "flex flex-wrap gap-2", children: map(l, (p) => /* @__PURE__ */ jsxs(
5116
+ Badge,
5117
+ {
5118
+ className: "flex cursor-pointer items-center gap-1 pr-1",
5119
+ variant: d(p) ? "default" : "secondary",
5120
+ onClick: () => {
5121
+ r([{ id: `${p}-${o._id}`, blockId: o._id, prop: p }]);
5152
5122
  },
5153
- g
5154
- )) }),
5155
- /* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
5156
- ] })
5157
- ] });
5123
+ children: [
5124
+ startCase(p),
5125
+ /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5126
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5127
+ "button",
5128
+ {
5129
+ type: "button",
5130
+ className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
5131
+ onClick: (u) => u.stopPropagation(),
5132
+ children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
5133
+ }
5134
+ ) }),
5135
+ /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: /* @__PURE__ */ jsx(
5136
+ DropdownMenuItem,
5137
+ {
5138
+ className: "text-xs",
5139
+ onClick: () => {
5140
+ i(p);
5141
+ },
5142
+ children: a("Reset style")
5143
+ }
5144
+ ) })
5145
+ ] })
5146
+ ]
5147
+ },
5148
+ p
5149
+ )) }),
5150
+ /* @__PURE__ */ jsx("div", { className: "my-2 h-[1px] w-full bg-border" })
5151
+ ] }) });
5158
5152
  }, BlockSettingsContext = React__default.createContext({
5159
5153
  setDragData: () => {
5160
5154
  }
@@ -5300,37 +5294,37 @@ const BlockStylingProps = () => {
5300
5294
  },
5301
5295
  a
5302
5296
  )) }), 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);
5297
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, _] = useState(!1);
5304
5298
  useEffect(() => {
5305
- const { value: C, unit: y } = getClassValueAndUnit(i);
5306
- if (y === "") {
5307
- l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5299
+ const { value: C, unit: k } = getClassValueAndUnit(i);
5300
+ if (k === "") {
5301
+ l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5308
5302
  return;
5309
5303
  }
5310
- h(y), l(y === "class" || isEmpty(C) ? "" : C);
5304
+ m(k), l(k === "class" || isEmpty(C) ? "" : C);
5311
5305
  }, [i, p, u]);
5312
5306
  const E = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
5313
5307
  (C = !1) => {
5314
- const y = getUserInputValues(`${a}`, u);
5315
- if (get(y, "error", !1)) {
5308
+ const k = getUserInputValues(`${a}`, u);
5309
+ if (get(k, "error", !1)) {
5316
5310
  f(!0);
5317
5311
  return;
5318
5312
  }
5319
- const j = get(y, "unit") !== "" ? get(y, "unit") : m;
5313
+ const j = get(k, "unit") !== "" ? get(k, "unit") : h;
5320
5314
  if (j === "auto" || j === "none") {
5321
5315
  E(`${d}${j}`);
5322
5316
  return;
5323
5317
  }
5324
- if (get(y, "value") === "")
5318
+ if (get(k, "value") === "")
5325
5319
  return;
5326
- const L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5320
+ const L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5327
5321
  C ? S(L) : E(L);
5328
5322
  },
5329
- [E, S, a, m, d, u]
5323
+ [E, S, a, h, d, u]
5330
5324
  ), N = useCallback(
5331
5325
  (C) => {
5332
- const y = getUserInputValues(`${a}`, u);
5333
- if (get(y, "error", !1)) {
5326
+ const k = getUserInputValues(`${a}`, u);
5327
+ if (get(k, "error", !1)) {
5334
5328
  f(!0);
5335
5329
  return;
5336
5330
  }
@@ -5338,14 +5332,14 @@ const BlockStylingProps = () => {
5338
5332
  E(`${d}${C}`);
5339
5333
  return;
5340
5334
  }
5341
- if (get(y, "value") === "")
5335
+ if (get(k, "value") === "")
5342
5336
  return;
5343
- const j = get(y, "unit") !== "" ? get(y, "unit") : C, L = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5337
+ const j = get(k, "unit") !== "" ? get(k, "unit") : C, L = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5344
5338
  E(L);
5345
5339
  },
5346
5340
  [E, a, d, u]
5347
5341
  );
5348
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5342
+ 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: [
5349
5343
  /* @__PURE__ */ jsx(
5350
5344
  "input",
5351
5345
  {
@@ -5360,10 +5354,10 @@ const BlockStylingProps = () => {
5360
5354
  ] })
5361
5355
  ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
5362
5356
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5363
- ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
5357
+ ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
5364
5358
  "input",
5365
5359
  {
5366
- readOnly: m === "class",
5360
+ readOnly: h === "class",
5367
5361
  onKeyPress: (C) => {
5368
5362
  C.key === "Enter" && A();
5369
5363
  },
@@ -5371,10 +5365,10 @@ const BlockStylingProps = () => {
5371
5365
  if (C.keyCode !== 38 && C.keyCode !== 40)
5372
5366
  return;
5373
5367
  C.preventDefault(), _(!0);
5374
- const y = parseInt$1(C.target.value);
5375
- let j = isNaN$1(y) ? 0 : y;
5368
+ const k = parseInt$1(C.target.value);
5369
+ let j = isNaN$1(k) ? 0 : k;
5376
5370
  C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
5377
- const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
5371
+ const I = `${j}`, R = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5378
5372
  S(R);
5379
5373
  },
5380
5374
  onKeyUp: (C) => {
@@ -5385,10 +5379,10 @@ const BlockStylingProps = () => {
5385
5379
  f(!1), l(C.target.value);
5386
5380
  },
5387
5381
  onClick: (C) => {
5388
- var y;
5389
- (y = C == null ? void 0 : C.target) == null || y.select(), r(!1);
5382
+ var k;
5383
+ (k = C == null ? void 0 : C.target) == null || k.select(), r(!1);
5390
5384
  },
5391
- value: v ? k : a,
5385
+ value: v ? y : a,
5392
5386
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5393
5387
  " ",
5394
5388
  x ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5403,7 +5397,7 @@ const BlockStylingProps = () => {
5403
5397
  onClick: () => r(!n),
5404
5398
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
5405
5399
  children: [
5406
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
5400
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
5407
5401
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5408
5402
  ]
5409
5403
  }
@@ -5412,33 +5406,33 @@ const BlockStylingProps = () => {
5412
5406
  UnitSelection,
5413
5407
  {
5414
5408
  units: u,
5415
- current: m,
5409
+ current: h,
5416
5410
  onSelect: (C) => {
5417
- r(!1), h(C), N(C);
5411
+ r(!1), m(C), N(C);
5418
5412
  }
5419
5413
  }
5420
5414
  ) })
5421
5415
  ] })
5422
5416
  ] }),
5423
- ["none", "auto"].indexOf(m) !== -1 || v ? null : /* @__PURE__ */ jsx(
5417
+ ["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsx(
5424
5418
  DragStyleButton,
5425
5419
  {
5426
5420
  onDragStart: () => B(!0),
5427
5421
  onDragEnd: (C) => {
5428
5422
  if (b(() => ""), B(!1), isEmpty(C))
5429
5423
  return;
5430
- const y = `${C}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
5424
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5431
5425
  E(I);
5432
5426
  },
5433
5427
  onDrag: (C) => {
5434
5428
  if (isEmpty(C))
5435
5429
  return;
5436
5430
  b(C);
5437
- const y = `${C}`, I = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
5431
+ const k = `${C}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5438
5432
  S(I);
5439
5433
  },
5440
5434
  currentValue: a,
5441
- unit: m,
5435
+ unit: h,
5442
5436
  negative: g,
5443
5437
  cssProperty: p
5444
5438
  }
@@ -5498,10 +5492,10 @@ const COLOR_PROP = {
5498
5492
  ringColor: "ring",
5499
5493
  ringOffsetColor: "ring-offset"
5500
5494
  }, ColorChoice = ({ property: o, onChange: n }) => {
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(
5495
+ const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
5502
5496
  // 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" })));
5497
+ (y) => {
5498
+ ["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
5499
  },
5506
5500
  [c, p]
5507
5501
  );
@@ -5512,8 +5506,8 @@ const COLOR_PROP = {
5512
5506
  }, [g]);
5513
5507
  const x = useCallback(
5514
5508
  // eslint-disable-next-line no-shadow
5515
- (k) => {
5516
- p({ color: g, shade: k });
5509
+ (y) => {
5510
+ p({ color: g, shade: y });
5517
5511
  },
5518
5512
  [g]
5519
5513
  );
@@ -5531,7 +5525,7 @@ const COLOR_PROP = {
5531
5525
  disabled: !l,
5532
5526
  rounded: !0,
5533
5527
  selected: g,
5534
- onChange: h,
5528
+ onChange: m,
5535
5529
  options: [
5536
5530
  "current",
5537
5531
  "transparent",
@@ -5564,7 +5558,7 @@ const COLOR_PROP = {
5564
5558
  ]
5565
5559
  }
5566
5560
  ) }),
5567
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: x, options: i }) })
5561
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: x, options: i }) })
5568
5562
  ] });
5569
5563
  }, EDITOR_ICONS = {
5570
5564
  "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" }) }),
@@ -5898,20 +5892,20 @@ const COLOR_PROP = {
5898
5892
  "2xl": "1536px"
5899
5893
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5900
5894
  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(
5895
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5902
5896
  (S, A = !0) => {
5903
5897
  const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5904
5898
  (p || u !== "") && (N.mq = "xs");
5905
5899
  const C = generateFullClsName(N);
5906
- h(f, [C], A);
5900
+ m(f, [C], A);
5907
5901
  },
5908
- [f, p, g, u, l, h]
5902
+ [f, p, g, u, l, m]
5909
5903
  ), v = useCallback(() => {
5910
- x(f, [k], !0);
5911
- }, [f, k, x]), B = useMemo(() => canChangeClass(m, g), [m, g]);
5904
+ x(f, [y], !0);
5905
+ }, [f, y, x]), B = useMemo(() => canChangeClass(h, g), [h, g]);
5912
5906
  useEffect(() => {
5913
- i(B, m);
5914
- }, [B, i, m]);
5907
+ i(B, h);
5908
+ }, [B, i, h]);
5915
5909
  const [, , w] = useScreenSizeWidth(), _ = useCallback(
5916
5910
  (S) => {
5917
5911
  w({
@@ -5924,15 +5918,15 @@ const COLOR_PROP = {
5924
5918
  }[S]);
5925
5919
  },
5926
5920
  [w]
5927
- ), E = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
5928
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: m && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5929
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !E ? "text-foreground" : ""}`, children: n(a) }) }),
5921
+ ), E = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
5922
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5923
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !E ? "text-foreground" : ""}`, children: n(a) }) }),
5930
5924
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5931
5925
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5932
5926
  r === "arbitrary" ? /* @__PURE__ */ jsx(
5933
5927
  AdvanceChoices,
5934
5928
  {
5935
- currentClass: get(m, "cls", ""),
5929
+ currentClass: get(h, "cls", ""),
5936
5930
  classPrefix: get(CLASS_PREFIXES, l, ""),
5937
5931
  units: c || [],
5938
5932
  onChange: b,
@@ -5945,7 +5939,7 @@ const COLOR_PROP = {
5945
5939
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5946
5940
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5947
5941
  ] }),
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: [
5942
+ /* @__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 && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5949
5943
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5950
5944
  "button",
5951
5945
  {
@@ -5957,19 +5951,19 @@ const COLOR_PROP = {
5957
5951
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
5958
5952
  "Current style is set at  ",
5959
5953
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
5960
- getBreakpoint(get(m, "mq")),
5961
- p && !m.dark ? "(Light mode)" : ""
5954
+ getBreakpoint(get(h, "mq")),
5955
+ p && !h.dark ? "(Light mode)" : ""
5962
5956
  ] }),
5963
5957
  /* @__PURE__ */ jsx("br", {}),
5964
5958
  /* @__PURE__ */ jsxs(
5965
5959
  "button",
5966
5960
  {
5967
5961
  type: "button",
5968
- onClick: () => _(get(m, "mq")),
5962
+ onClick: () => _(get(h, "mq")),
5969
5963
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
5970
5964
  children: [
5971
5965
  "Switch to ",
5972
- get(m, "mq").toUpperCase()
5966
+ get(h, "mq").toUpperCase()
5973
5967
  ]
5974
5968
  }
5975
5969
  )
@@ -5986,7 +5980,7 @@ const COLOR_PROP = {
5986
5980
  units: i = basicUnits,
5987
5981
  negative: c = !1
5988
5982
  }) => {
5989
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((h) => map(g, "property").includes(h), [g]);
5983
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
5990
5984
  return /* @__PURE__ */ jsxs(
5991
5985
  "div",
5992
5986
  {
@@ -5994,7 +5988,7 @@ const COLOR_PROP = {
5994
5988
  children: [
5995
5989
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
5996
5990
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
5997
- /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: h, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5991
+ /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: n.map(({ label: m, key: x }, f) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5998
5992
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5999
5993
  "button",
6000
5994
  {
@@ -6003,13 +5997,13 @@ const COLOR_PROP = {
6003
5997
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${x === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6004
5998
  children: [
6005
5999
  React__default.createElement("div", {
6006
- className: m(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6000
+ className: h(x) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6007
6001
  }),
6008
6002
  React__default.createElement(get(EDITOR_ICONS, x, BoxIcon), { className: "text-inherit w-3 h-3" })
6009
6003
  ]
6010
6004
  }
6011
6005
  ) }),
6012
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
6006
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
6013
6007
  ] }) }, `option-${f}`)) })
6014
6008
  ] }),
6015
6009
  /* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
@@ -6165,23 +6159,23 @@ const COLOR_PROP = {
6165
6159
  canvas: n = !1,
6166
6160
  tooltip: r = !0
6167
6161
  }) => {
6168
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
6162
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
6169
6163
  u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
6170
6164
  }, f = (b) => {
6171
6165
  n || l(b), c(b);
6172
- }, k = getBreakpointValue(n ? i : a).toLowerCase();
6173
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
6166
+ }, y = getBreakpointValue(n ? i : a).toLowerCase();
6167
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
6174
6168
  BreakpointCard,
6175
6169
  {
6176
6170
  canvas: n,
6177
6171
  ...b,
6178
6172
  onClick: f,
6179
6173
  key: b.breakpoint,
6180
- currentBreakpoint: k
6174
+ currentBreakpoint: y
6181
6175
  }
6182
6176
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6183
6177
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
6184
- h.filter((b) => includes(u, toUpper(b.breakpoint))),
6178
+ m.filter((b) => includes(u, toUpper(b.breakpoint))),
6185
6179
  (b) => /* @__PURE__ */ createElement(
6186
6180
  BreakpointCard,
6187
6181
  {
@@ -6191,22 +6185,22 @@ const COLOR_PROP = {
6191
6185
  ...b,
6192
6186
  onClick: f,
6193
6187
  key: b.breakpoint,
6194
- currentBreakpoint: k
6188
+ currentBreakpoint: y
6195
6189
  }
6196
6190
  )
6197
6191
  ) }),
6198
6192
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
6199
6193
  /* @__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" }) }) }),
6200
6194
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
6201
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: m("Screen sizes") }),
6195
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
6202
6196
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6203
- map(h, (b) => /* @__PURE__ */ jsx(
6197
+ map(m, (b) => /* @__PURE__ */ jsx(
6204
6198
  DropdownMenuCheckboxItem,
6205
6199
  {
6206
6200
  disabled: b.breakpoint === "xs",
6207
6201
  onCheckedChange: () => x(toUpper(b.breakpoint)),
6208
6202
  checked: includes(u, toUpper(b.breakpoint)),
6209
- children: m(b.title)
6203
+ children: h(b.title)
6210
6204
  },
6211
6205
  b.breakpoint
6212
6206
  ))
@@ -6285,11 +6279,11 @@ function Countdown() {
6285
6279
  const AskAIStyles = ({ blockId: o }) => {
6286
6280
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
6287
6281
  useEffect(() => {
6288
- var h;
6289
- (h = d.current) == null || h.focus();
6282
+ var m;
6283
+ (m = d.current) == null || m.focus();
6290
6284
  }, []);
6291
- const m = (h) => {
6292
- const { usage: x } = h || {};
6285
+ const h = (m) => {
6286
+ const { usage: x } = m || {};
6293
6287
  !l && x && g(x), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6294
6288
  };
6295
6289
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -6299,12 +6293,12 @@ const AskAIStyles = ({ blockId: o }) => {
6299
6293
  {
6300
6294
  ref: d,
6301
6295
  value: i,
6302
- onChange: (h) => c(h.target.value),
6296
+ onChange: (m) => c(m.target.value),
6303
6297
  placeholder: n("Ask AI to edit styles"),
6304
6298
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
6305
6299
  rows: 4,
6306
- onKeyDown: (h) => {
6307
- h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
6300
+ onKeyDown: (m) => {
6301
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h));
6308
6302
  }
6309
6303
  }
6310
6304
  ),
@@ -6314,7 +6308,7 @@ const AskAIStyles = ({ blockId: o }) => {
6314
6308
  {
6315
6309
  disabled: i.trim().length < 5 || a,
6316
6310
  onClick: () => {
6317
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
6311
+ p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, h);
6318
6312
  },
6319
6313
  variant: "default",
6320
6314
  className: "w-fit",
@@ -6346,9 +6340,9 @@ const AskAIStyles = ({ blockId: o }) => {
6346
6340
  };
6347
6341
  function ManualClasses() {
6348
6342
  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 = () => {
6343
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [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
6344
  const L = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6351
- u(m, L, !0), f("");
6345
+ u(h, L, !0), f("");
6352
6346
  }, [w, _] = useState([]), E = ({ value: L }) => {
6353
6347
  const R = L.trim().toLowerCase(), T = R.match(/.+:/g);
6354
6348
  let D = [];
@@ -6384,10 +6378,10 @@ function ManualClasses() {
6384
6378
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6385
6379
  }),
6386
6380
  [x, c, o]
6387
- ), y = (L) => {
6381
+ ), k = (L) => {
6388
6382
  debugger;
6389
6383
  const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6390
- g(m, [L]), u(m, R, !0), r(""), l(-1);
6384
+ g(h, [L]), u(h, R, !0), r(""), l(-1);
6391
6385
  }, j = () => {
6392
6386
  if (navigator.clipboard === void 0) {
6393
6387
  toast.error(c("Clipboard not supported"));
@@ -6404,7 +6398,7 @@ function ManualClasses() {
6404
6398
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6405
6399
  ] })
6406
6400
  ] }),
6407
- h ? /* @__PURE__ */ jsxs(Popover, { children: [
6401
+ m ? /* @__PURE__ */ jsxs(Popover, { children: [
6408
6402
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
6409
6403
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
6410
6404
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -6452,10 +6446,10 @@ function ManualClasses() {
6452
6446
  value: n,
6453
6447
  onChange: (T) => r(T.target.value),
6454
6448
  onBlur: () => {
6455
- y(L);
6449
+ k(L);
6456
6450
  },
6457
6451
  onKeyDown: (T) => {
6458
- T.key === "Enter" && y(L);
6452
+ T.key === "Enter" && k(L);
6459
6453
  },
6460
6454
  onFocus: (T) => {
6461
6455
  setTimeout(() => {
@@ -6469,7 +6463,7 @@ function ManualClasses() {
6469
6463
  "button",
6470
6464
  {
6471
6465
  onDoubleClick: () => {
6472
- f(L), g(m, [L]), setTimeout(() => {
6466
+ f(L), g(h, [L]), setTimeout(() => {
6473
6467
  o.current && o.current.focus();
6474
6468
  }, 10);
6475
6469
  },
@@ -6479,7 +6473,7 @@ function ManualClasses() {
6479
6473
  n !== L && /* @__PURE__ */ jsx(
6480
6474
  Cross2Icon,
6481
6475
  {
6482
- onClick: () => g(m, [L], !0),
6476
+ onClick: () => g(h, [L], !0),
6483
6477
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
6484
6478
  }
6485
6479
  )
@@ -6599,13 +6593,13 @@ function BlockStyling() {
6599
6593
  cssProperty: ""
6600
6594
  }), d = useThrottledCallback(
6601
6595
  (u) => {
6602
- const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6603
- let h = parseFloat(i.dragStartValue);
6604
- h = isNaN(h) ? 0 : h;
6596
+ const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6597
+ let m = parseFloat(i.dragStartValue);
6598
+ m = isNaN(m) ? 0 : m;
6605
6599
  let x = MAPPER[i.dragUnit];
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}`);
6600
+ (startsWith(h, "scale") || h === "opacity") && (x = 10);
6601
+ let y = (i.dragStartY - u.pageY) / x + m;
6602
+ g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6609
6603
  },
6610
6604
  [i],
6611
6605
  50
@@ -6646,10 +6640,10 @@ const CoreBlock = ({
6646
6640
  parentId: r,
6647
6641
  position: a
6648
6642
  }) => {
6649
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6643
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6650
6644
  if (has(o, "blocks")) {
6651
- const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6652
- u(syncBlocksWithDefaults(k), r || null, a);
6645
+ const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6646
+ u(syncBlocksWithDefaults(y), r || null, a);
6653
6647
  } else
6654
6648
  p(o, r || null, a);
6655
6649
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6659,11 +6653,11 @@ const CoreBlock = ({
6659
6653
  "button",
6660
6654
  {
6661
6655
  disabled: n,
6662
- onClick: h,
6656
+ onClick: m,
6663
6657
  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(() => {
6666
- g([]), m();
6658
+ onDragStart: (y) => {
6659
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6660
+ g([]), h();
6667
6661
  }, 200);
6668
6662
  },
6669
6663
  draggable: x ? "true" : "false",
@@ -6862,7 +6856,7 @@ const CoreBlock = ({
6862
6856
  }
6863
6857
  }
6864
6858
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
6865
- var m, h, x, f, k, b, v, B;
6859
+ var h, m, x, f, y, b, v, B;
6866
6860
  if (r.type === "comment") return [];
6867
6861
  let a = { _id: generateUUID() };
6868
6862
  if (n && (a._parent = n.block._id), r.type === "text")
@@ -6902,10 +6896,10 @@ const CoreBlock = ({
6902
6896
  ];
6903
6897
  a = {
6904
6898
  ...a,
6905
- href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
6906
- hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6899
+ href: ((h = l.find((_) => _.key === "href")) == null ? void 0 : h.value) || "",
6900
+ hrefType: ((m = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6907
6901
  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", "")) || "",
6902
+ maxWidth: ((y = (f = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
6909
6903
  backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
6910
6904
  galleryName: ((v = l.find((_) => _.key === "data-gall")) == null ? void 0 : v.value) || ""
6911
6905
  }, forEach(w, (_) => {
@@ -7046,7 +7040,7 @@ const registerChaiLibrary = (o, n) => {
7046
7040
  parentId: r = void 0,
7047
7041
  position: a = -1
7048
7042
  }) => {
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) => {
7043
+ const [l, i] = useState(!1), c = useMemo(() => (n == null ? void 0 : n.getBlock) || (() => []), [n]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
7050
7044
  const w = has(B, "styles_attrs.data-page-section");
7051
7045
  return B._type === "Box" && w;
7052
7046
  }, b = useCallback(
@@ -7071,7 +7065,7 @@ const registerChaiLibrary = (o, n) => {
7071
7065
  onDragStart: async (B) => {
7072
7066
  const w = await c({ library: n, block: o });
7073
7067
  let _ = r;
7074
- if (k(first(w)) && (_ = null), !isEmpty(w)) {
7068
+ if (y(first(w)) && (_ = null), !isEmpty(w)) {
7075
7069
  const E = { blocks: w, uiLibrary: !0, parent: _ };
7076
7070
  if (B.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
7077
7071
  const S = new Image();
@@ -7093,20 +7087,20 @@ const registerChaiLibrary = (o, n) => {
7093
7087
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
7094
7088
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7095
7089
  ] }),
7096
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__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: [
7097
- /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: m }),
7098
- h && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: h })
7090
+ 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: [
7091
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
7092
+ m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
7099
7093
  ] })
7100
7094
  ]
7101
7095
  }
7102
7096
  ) }),
7103
7097
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
7104
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: m }),
7105
- h && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: h })
7098
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
7099
+ m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
7106
7100
  ] }) })
7107
7101
  ] });
7108
7102
  }, 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);
7103
+ 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(""), [h, m] = useState([]), x = useRef(null);
7110
7104
  useEffect(() => {
7111
7105
  c && c.length > 0 && (x.current = new Fuse(c, {
7112
7106
  keys: ["name", "label", "description", "group"],
@@ -7115,26 +7109,26 @@ const registerChaiLibrary = (o, n) => {
7115
7109
  }));
7116
7110
  }, [c]), useEffect(() => {
7117
7111
  if (!u.trim() || !x.current) {
7118
- h([]);
7112
+ m([]);
7119
7113
  return;
7120
7114
  }
7121
- const y = x.current.search(u).map((j) => j.item);
7122
- h(y);
7115
+ const k = x.current.search(u).map((j) => j.item);
7116
+ m(k);
7123
7117
  }, [u]);
7124
- const f = u.trim() && !isEmpty(m) ? m : c, k = groupBy(f, "group"), [b, v] = useState(null);
7118
+ const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, v] = useState(null);
7125
7119
  useEffect(() => {
7126
- if (isEmpty(keys(k))) {
7120
+ if (isEmpty(keys(y))) {
7127
7121
  v(null);
7128
7122
  return;
7129
7123
  }
7130
- if (!b || !k[b]) {
7131
- v(first(keys(k)));
7124
+ if (!b || !y[b]) {
7125
+ v(first(keys(y)));
7132
7126
  return;
7133
7127
  }
7134
- }, [k, b]);
7135
- const B = get(k, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (y) => {
7128
+ }, [y, b]);
7129
+ const B = get(y, b, []), w = useRef(null), { t: _ } = useTranslation(), E = (k) => {
7136
7130
  w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7137
- w.current && v(y);
7131
+ w.current && v(k);
7138
7132
  }, 400);
7139
7133
  }, S = () => {
7140
7134
  i != null && i.id && p(i.id);
@@ -7146,7 +7140,7 @@ const registerChaiLibrary = (o, n) => {
7146
7140
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7147
7141
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7148
7142
  ] });
7149
- const N = filter(B, (y, j) => j % 2 === 0), C = filter(B, (y, j) => j % 2 === 1);
7143
+ const N = filter(B, (k, j) => j % 2 === 0), C = filter(B, (k, j) => j % 2 === 1);
7150
7144
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7151
7145
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7152
7146
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7155,7 +7149,7 @@ const registerChaiLibrary = (o, n) => {
7155
7149
  {
7156
7150
  placeholder: _("Search blocks..."),
7157
7151
  value: u,
7158
- onChange: (y) => g(y.target.value),
7152
+ onChange: (k) => g(k.target.value),
7159
7153
  className: "w-full pl-8 pr-8"
7160
7154
  }
7161
7155
  ),
@@ -7174,13 +7168,13 @@ const registerChaiLibrary = (o, n) => {
7174
7168
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7175
7169
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7176
7170
  /* @__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: [
7171
+ /* @__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
7172
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
7179
7173
  /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7180
7174
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7181
7175
  _("Retry")
7182
7176
  ] })
7183
- ] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
7177
+ ] }) }) : map(y, (k, j) => /* @__PURE__ */ jsxs(
7184
7178
  "div",
7185
7179
  {
7186
7180
  onMouseEnter: () => E(j),
@@ -7206,23 +7200,23 @@ const registerChaiLibrary = (o, n) => {
7206
7200
  onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
7207
7201
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7208
7202
  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(
7203
+ 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: [
7204
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
7211
7205
  BlockCard,
7212
7206
  {
7213
7207
  parentId: o,
7214
7208
  position: n,
7215
- block: y,
7209
+ block: k,
7216
7210
  library: i
7217
7211
  },
7218
7212
  `block-${j}`
7219
7213
  )) }),
7220
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((y, j) => /* @__PURE__ */ jsx(
7214
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((k, j) => /* @__PURE__ */ jsx(
7221
7215
  BlockCard,
7222
7216
  {
7223
7217
  parentId: o,
7224
7218
  position: n,
7225
- block: y,
7219
+ block: k,
7226
7220
  library: i
7227
7221
  },
7228
7222
  `block-second-${j}`
@@ -7261,8 +7255,8 @@ const registerChaiLibrary = (o, n) => {
7261
7255
  error: c
7262
7256
  }), g(!0);
7263
7257
  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);
7258
+ const m = Object.entries(a).map(([f, y]) => {
7259
+ const b = y, v = b.type || "partial", B = formatReadableName(v);
7266
7260
  return {
7267
7261
  type: "PartialBlock",
7268
7262
  // Set the type to PartialBlock
@@ -7276,14 +7270,14 @@ const registerChaiLibrary = (o, n) => {
7276
7270
  // Store the original ID as partialBlockId
7277
7271
  _name: b.name
7278
7272
  };
7279
- }), x = uniq(map(h, "group"));
7273
+ }), x = uniq(map(m, "group"));
7280
7274
  p({
7281
- blocks: h,
7275
+ blocks: m,
7282
7276
  groups: x,
7283
7277
  isLoading: !1,
7284
7278
  error: null
7285
7279
  }), g(!0);
7286
- } else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7280
+ } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7287
7281
  blocks: [],
7288
7282
  groups: [],
7289
7283
  isLoading: !1,
@@ -7298,15 +7292,15 @@ const registerChaiLibrary = (o, n) => {
7298
7292
  d.blocks,
7299
7293
  c
7300
7294
  ]);
7301
- const m = () => {
7302
- p((h) => ({ ...h, isLoading: !0, error: null })), g(!1), i();
7295
+ const h = () => {
7296
+ p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7303
7297
  };
7304
7298
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7305
7299
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7306
7300
  /* @__PURE__ */ jsx(
7307
7301
  "button",
7308
7302
  {
7309
- onClick: m,
7303
+ onClick: h,
7310
7304
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7311
7305
  children: "Refresh"
7312
7306
  }
@@ -7325,43 +7319,43 @@ const registerChaiLibrary = (o, n) => {
7325
7319
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...n });
7326
7320
  }, 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
7321
  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);
7322
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(c, (k) => k._id === r)) == null ? void 0 : C._type, [m, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7329
7323
  useEffect(() => {
7330
- const y = setTimeout(() => {
7324
+ const k = setTimeout(() => {
7331
7325
  var j;
7332
7326
  (j = u.current) == null || j.focus();
7333
7327
  }, 0);
7334
- return () => clearTimeout(y);
7328
+ return () => clearTimeout(k);
7335
7329
  }, [g]), useEffect(() => {
7336
- d && (x("all"), k(null));
7337
- }, [d]), useEffect(() => (b.current = debounce((y) => {
7338
- x(y);
7330
+ d && (x("all"), y(null));
7331
+ }, [d]), useEffect(() => (b.current = debounce((k) => {
7332
+ x(k);
7339
7333
  }, 500), () => {
7340
7334
  b.current && b.current.cancel();
7341
7335
  }), []);
7342
- const v = useCallback((y) => {
7343
- k(y), b.current && b.current(y);
7336
+ const v = useCallback((k) => {
7337
+ y(k), b.current && b.current(k);
7344
7338
  }, []), B = useCallback(() => {
7345
- k(null), b.current && b.current.cancel();
7346
- }, []), w = useCallback((y) => {
7347
- b.current && b.current.cancel(), x(y), k(null);
7339
+ y(null), b.current && b.current.cancel();
7340
+ }, []), w = useCallback((k) => {
7341
+ b.current && b.current.cancel(), x(k), y(null);
7348
7342
  }, []), _ = useMemo(
7349
7343
  () => d ? values(n).filter(
7350
- (y) => {
7344
+ (k) => {
7351
7345
  var j, I;
7352
- return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = y.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7346
+ return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = k.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7353
7347
  }
7354
7348
  ) : n,
7355
7349
  [n, d]
7356
7350
  ), E = useMemo(
7357
7351
  () => 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),
7352
+ (k) => reject(filter(values(_), { group: k }), { hidden: !0 }).length > 0
7353
+ ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7360
7354
  [n, _, o, d]
7361
7355
  ), S = useMemo(
7362
- () => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
7356
+ () => sortBy(E, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7363
7357
  [E]
7364
- ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
7358
+ ), A = useMemo(() => m === "all" ? _ : filter(values(_), { group: m }), [_, m]), N = useMemo(() => m === "all" ? S : [m], [S, m]);
7365
7359
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7366
7360
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7367
7361
  Input$1,
@@ -7371,7 +7365,7 @@ const registerChaiLibrary = (o, n) => {
7371
7365
  placeholder: i("Search blocks..."),
7372
7366
  value: d,
7373
7367
  className: "-ml-2",
7374
- onChange: (y) => p(y.target.value)
7368
+ onChange: (k) => p(k.target.value)
7375
7369
  }
7376
7370
  ) }),
7377
7371
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
@@ -7382,21 +7376,21 @@ const registerChaiLibrary = (o, n) => {
7382
7376
  onClick: () => w("all"),
7383
7377
  onMouseEnter: () => v("all"),
7384
7378
  onMouseLeave: B,
7385
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7379
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7386
7380
  children: i("All")
7387
7381
  },
7388
7382
  "sidebar-all"
7389
7383
  ),
7390
- S.map((y) => /* @__PURE__ */ jsx(
7384
+ S.map((k) => /* @__PURE__ */ jsx(
7391
7385
  "button",
7392
7386
  {
7393
- onClick: () => w(y),
7394
- onMouseEnter: () => v(y),
7387
+ onClick: () => w(k),
7388
+ onMouseEnter: () => v(k),
7395
7389
  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()))
7390
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || f === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7391
+ children: capitalize(i(k.toLowerCase()))
7398
7392
  },
7399
- `sidebar-${y}`
7393
+ `sidebar-${k}`
7400
7394
  ))
7401
7395
  ] }) }) }),
7402
7396
  /* @__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 +7398,10 @@ const registerChaiLibrary = (o, n) => {
7404
7398
  ' "',
7405
7399
  d,
7406
7400
  '"'
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())) }),
7401
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7402
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7409
7403
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7410
- h === "all" ? filter(values(A), { group: y }) : values(A),
7404
+ m === "all" ? filter(values(A), { group: k }) : values(A),
7411
7405
  { hidden: !0 }
7412
7406
  ).map((j) => /* @__PURE__ */ jsx(
7413
7407
  CoreBlock,
@@ -7415,11 +7409,11 @@ const registerChaiLibrary = (o, n) => {
7415
7409
  parentId: r,
7416
7410
  position: a,
7417
7411
  block: j,
7418
- disabled: !canAcceptChildBlock(m, j.type) || !canBeNestedInside(m, j.type)
7412
+ disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
7419
7413
  },
7420
7414
  j.type
7421
7415
  )) })
7422
- ] }, y)) }) }) })
7416
+ ] }, k)) }) }) })
7423
7417
  ] })
7424
7418
  ] });
7425
7419
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7428,13 +7422,13 @@ const registerChaiLibrary = (o, n) => {
7428
7422
  parentId: r = void 0,
7429
7423
  position: a = -1
7430
7424
  }) => {
7431
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: m } = usePermissions();
7425
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: h } = usePermissions();
7432
7426
  useEffect(() => {
7433
7427
  i === "partials" && !g && c("library");
7434
7428
  }, [i, g, c]);
7435
- const h = useCallback(() => {
7429
+ const m = useCallback(() => {
7436
7430
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7437
- }, []), x = useChaiAddBlockTabs(), f = p && m(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
7431
+ }, []), x = useChaiAddBlockTabs(), f = p && h(PERMISSIONS.IMPORT_HTML), b = useChaiLibraries().length > 0;
7438
7432
  return useEffect(() => {
7439
7433
  i === "library" && !b && c("core");
7440
7434
  }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7462,7 +7456,7 @@ const registerChaiLibrary = (o, n) => {
7462
7456
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7463
7457
  g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7464
7458
  f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7465
- map(x, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: h, parentId: r, position: a }) }, `panel-add-block-${v.id}`))
7459
+ map(x, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: r, position: a }) }, `panel-add-block-${v.id}`))
7466
7460
  ]
7467
7461
  }
7468
7462
  )
@@ -7584,7 +7578,7 @@ const registerChaiSaveToLibrary = (o) => {
7584
7578
  }, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
7585
7579
  const [o] = useBlocksStore(), [n] = useSelectedBlockIds(), { pasteBlocks: r } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
7586
7580
  const p = n.map((u) => {
7587
- const g = o.find((m) => m._id === u);
7581
+ const g = o.find((h) => h._id === u);
7588
7582
  return {
7589
7583
  id: u,
7590
7584
  data: g
@@ -7769,8 +7763,8 @@ const Input = ({ node: o }) => {
7769
7763
  var R;
7770
7764
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7771
7765
  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) => {
7773
- T.stopPropagation(), !l.includes(h) && o.toggle();
7766
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (T) => {
7767
+ T.stopPropagation(), !l.includes(m) && o.toggle();
7774
7768
  }, _ = (T) => {
7775
7769
  T.isInternal && (p = T.isOpen, T.isOpen && T.close());
7776
7770
  }, E = (T) => {
@@ -7780,15 +7774,15 @@ const Input = ({ node: o }) => {
7780
7774
  C(), o.parent.isSelected || A((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
7781
7775
  }, C = () => {
7782
7776
  A(null);
7783
- }, y = (T) => {
7784
- C(), T.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(T);
7777
+ }, k = (T) => {
7778
+ C(), T.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(T);
7785
7779
  };
7786
7780
  useEffect(() => {
7787
7781
  const T = setTimeout(() => {
7788
- k && !o.isOpen && !b && !l.includes(h) && o.toggle();
7782
+ y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7789
7783
  }, 500);
7790
7784
  return () => clearTimeout(T);
7791
- }, [k, o, b]);
7785
+ }, [y, o, b]);
7792
7786
  const j = (T, D) => {
7793
7787
  const O = c.contentDocument || c.contentWindow.document, P = O.querySelector(`[data-block-id=${T}]`);
7794
7788
  P && P.setAttribute("data-drop", D);
@@ -7799,7 +7793,7 @@ const Input = ({ node: o }) => {
7799
7793
  const D = get(o, "parent.id");
7800
7794
  D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
7801
7795
  };
7802
- if (h === ROOT_TEMP_KEY)
7796
+ if (m === ROOT_TEMP_KEY)
7803
7797
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7804
7798
  /* @__PURE__ */ jsx("br", {}),
7805
7799
  d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
@@ -7821,22 +7815,22 @@ const Input = ({ node: o }) => {
7821
7815
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7822
7816
  "div",
7823
7817
  {
7824
- onMouseEnter: () => g(h),
7825
- onMouseLeave: () => m(),
7826
- onClick: y,
7818
+ onMouseEnter: () => g(m),
7819
+ onMouseLeave: () => h(),
7820
+ onClick: k,
7827
7821
  style: n,
7828
- "data-node-id": h,
7829
- ref: l.includes(h) ? null : r,
7822
+ "data-node-id": m,
7823
+ ref: l.includes(m) ? null : r,
7830
7824
  onDragStart: () => _(o),
7831
7825
  onDragEnd: () => E(o),
7832
7826
  onDragOver: (T) => {
7833
- T.preventDefault(), j(h, "yes");
7827
+ T.preventDefault(), j(m, "yes");
7834
7828
  },
7835
7829
  onDragLeave: (T) => {
7836
- T.preventDefault(), j(h, "no");
7830
+ T.preventDefault(), j(m, "no");
7837
7831
  },
7838
7832
  onDrop: (T) => {
7839
- T.preventDefault(), j(h, "no");
7833
+ T.preventDefault(), j(m, "no");
7840
7834
  },
7841
7835
  children: [
7842
7836
  d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
@@ -7857,10 +7851,10 @@ const Input = ({ node: o }) => {
7857
7851
  className: cn(
7858
7852
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7859
7853
  f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7860
- k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7854
+ y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
7861
7855
  (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7862
7856
  b && "opacity-20",
7863
- l.includes(h) ? "opacity-50" : "",
7857
+ l.includes(m) ? "opacity-50" : "",
7864
7858
  L && f && "bg-primary/20 text-primary"
7865
7859
  ),
7866
7860
  children: [
@@ -7897,11 +7891,11 @@ const Input = ({ node: o }) => {
7897
7891
  )
7898
7892
  ] }),
7899
7893
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7900
- canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(h) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7894
+ canAddChildBlock(x == null ? void 0 : x._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7901
7895
  /* @__PURE__ */ jsx(
7902
7896
  TooltipTrigger,
7903
7897
  {
7904
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
7898
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
7905
7899
  className: "cursor-pointer rounded bg-transparent",
7906
7900
  asChild: !0,
7907
7901
  children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3" })
@@ -7914,7 +7908,7 @@ const Input = ({ node: o }) => {
7914
7908
  TooltipTrigger,
7915
7909
  {
7916
7910
  onClick: (T) => {
7917
- T.stopPropagation(), i(h), o.isOpen && o.toggle();
7911
+ T.stopPropagation(), i(m), o.isOpen && o.toggle();
7918
7912
  },
7919
7913
  className: "cursor-pointer rounded bg-transparent",
7920
7914
  asChild: !0,
@@ -7923,7 +7917,7 @@ const Input = ({ node: o }) => {
7923
7917
  ),
7924
7918
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "bottom", children: a("Hide block") })
7925
7919
  ] }),
7926
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
7920
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
7927
7921
  ] })
7928
7922
  ]
7929
7923
  }
@@ -8188,9 +8182,9 @@ const Input = ({ node: o }) => {
8188
8182
  )
8189
8183
  ] });
8190
8184
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8191
- const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (v) => {
8185
+ const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), h = (v) => {
8192
8186
  a(v);
8193
- }, h = () => {
8187
+ }, m = () => {
8194
8188
  const v = l.find((B) => Object.keys(B)[0] === r);
8195
8189
  if (v) {
8196
8190
  const B = Object.values(v)[0];
@@ -8218,7 +8212,7 @@ const Input = ({ node: o }) => {
8218
8212
  },
8219
8213
  [d],
8220
8214
  200
8221
- ), k = useDebouncedCallback(
8215
+ ), y = useDebouncedCallback(
8222
8216
  (v, B) => {
8223
8217
  p(() => {
8224
8218
  const w = get(d, `colors.${v}`);
@@ -8240,7 +8234,7 @@ const Input = ({ node: o }) => {
8240
8234
  ColorPickerInput,
8241
8235
  {
8242
8236
  value: w,
8243
- onChange: (_) => k(B, _)
8237
+ onChange: (_) => y(B, _)
8244
8238
  }
8245
8239
  ),
8246
8240
  /* @__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" : "") })
@@ -8255,7 +8249,7 @@ const Input = ({ node: o }) => {
8255
8249
  "select",
8256
8250
  {
8257
8251
  value: r,
8258
- onChange: (v) => m(v.target.value),
8252
+ onChange: (v) => h(v.target.value),
8259
8253
  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",
8260
8254
  children: [
8261
8255
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
@@ -8270,7 +8264,7 @@ const Input = ({ node: o }) => {
8270
8264
  className: "w-full text-sm",
8271
8265
  disabled: r === "",
8272
8266
  variant: "default",
8273
- onClick: h,
8267
+ onClick: m,
8274
8268
  children: g("Apply")
8275
8269
  }
8276
8270
  ) })
@@ -8764,14 +8758,14 @@ function QuickPrompts({ onClick: o }) {
8764
8758
  ) }) });
8765
8759
  }
8766
8760
  const AIUserPrompt = ({ blockId: o }) => {
8767
- const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), h = useRef(null);
8761
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
8768
8762
  useEffect(() => {
8769
8763
  var f;
8770
- (f = m.current) == null || f.focus();
8764
+ (f = h.current) == null || f.focus();
8771
8765
  }, []);
8772
8766
  const x = (f) => {
8773
- const { usage: k } = f || {};
8774
- !l && k && g(k), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8767
+ const { usage: y } = f || {};
8768
+ !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8775
8769
  };
8776
8770
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8777
8771
  /* @__PURE__ */ jsxs(
@@ -8789,14 +8783,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8789
8783
  /* @__PURE__ */ jsx(
8790
8784
  Textarea,
8791
8785
  {
8792
- ref: m,
8786
+ ref: h,
8793
8787
  value: i,
8794
8788
  onChange: (f) => c(f.target.value),
8795
8789
  placeholder: n("Ask AI to edit content"),
8796
8790
  className: "w-full",
8797
8791
  rows: 3,
8798
8792
  onKeyDown: (f) => {
8799
- f.key === "Enter" && (f.preventDefault(), h.current && clearTimeout(h.current), g(void 0), r("content", o, i, x));
8793
+ f.key === "Enter" && (f.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, x));
8800
8794
  }
8801
8795
  }
8802
8796
  ),
@@ -8806,7 +8800,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8806
8800
  {
8807
8801
  disabled: i.trim().length < 5 || a,
8808
8802
  onClick: () => {
8809
- h.current && clearTimeout(h.current), g(void 0), r("content", o, i, x);
8803
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, i, x);
8810
8804
  },
8811
8805
  variant: "default",
8812
8806
  className: "w-fit",
@@ -8839,7 +8833,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8839
8833
  QuickPrompts,
8840
8834
  {
8841
8835
  onClick: (f) => {
8842
- h.current && clearTimeout(h.current), g(void 0), r("content", o, f, x);
8836
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, f, x);
8843
8837
  }
8844
8838
  }
8845
8839
  )
@@ -8849,13 +8843,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8849
8843
  ] }) }) : null
8850
8844
  ] });
8851
8845
  }, AISetContext = () => {
8852
- const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
8846
+ const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
8853
8847
  useEffect(() => {
8854
8848
  n && a(n);
8855
8849
  }, [n]);
8856
- const h = async () => {
8850
+ const m = async () => {
8857
8851
  try {
8858
- d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8852
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), h.current.click();
8859
8853
  } catch (x) {
8860
8854
  u(x);
8861
8855
  } finally {
@@ -8871,7 +8865,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8871
8865
  type: "single",
8872
8866
  collapsible: !0,
8873
8867
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8874
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8868
+ /* @__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") }) }) }),
8875
8869
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8876
8870
  /* @__PURE__ */ jsx(
8877
8871
  Textarea,
@@ -8883,7 +8877,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8883
8877
  className: "mt-1 w-full",
8884
8878
  rows: 10,
8885
8879
  onKeyDown: (x) => {
8886
- x.key === "Enter" && (x.preventDefault(), h());
8880
+ x.key === "Enter" && (x.preventDefault(), m());
8887
8881
  }
8888
8882
  }
8889
8883
  ),
@@ -8895,7 +8889,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8895
8889
  Button,
8896
8890
  {
8897
8891
  disabled: r.trim().length < 5,
8898
- onClick: () => h(),
8892
+ onClick: () => m(),
8899
8893
  variant: "default",
8900
8894
  className: "w-fit",
8901
8895
  size: "sm",
@@ -8924,7 +8918,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8924
8918
  AlertDialogAction,
8925
8919
  {
8926
8920
  onClick: () => {
8927
- a(""), h();
8921
+ a(""), m();
8928
8922
  },
8929
8923
  children: o("Yes, Delete")
8930
8924
  }
@@ -8985,7 +8979,7 @@ function AIChatPanel() {
8985
8979
  }, [o]), useEffect(() => {
8986
8980
  g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
8987
8981
  }, [r]);
8988
- const m = async () => {
8982
+ const h = async () => {
8989
8983
  if (!r.trim() && !c) return;
8990
8984
  const b = {
8991
8985
  id: Date.now().toString(),
@@ -9002,8 +8996,8 @@ function AIChatPanel() {
9002
8996
  };
9003
8997
  n((B) => [...B, v]), i(!1), d(null);
9004
8998
  }, 1500);
9005
- }, h = (b) => {
9006
- b.key === "Enter" && !b.shiftKey && (b.preventDefault(), m());
8999
+ }, m = (b) => {
9000
+ b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
9007
9001
  }, x = (b) => {
9008
9002
  var B;
9009
9003
  const v = (B = b.target.files) == null ? void 0 : B[0];
@@ -9017,7 +9011,7 @@ function AIChatPanel() {
9017
9011
  }, f = () => {
9018
9012
  var b;
9019
9013
  (b = p.current) == null || b.click();
9020
- }, k = () => {
9014
+ }, y = () => {
9021
9015
  d(null), p.current && (p.current.value = "");
9022
9016
  };
9023
9017
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -9063,7 +9057,7 @@ function AIChatPanel() {
9063
9057
  size: "icon",
9064
9058
  variant: "destructive",
9065
9059
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9066
- onClick: k,
9060
+ onClick: y,
9067
9061
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9068
9062
  }
9069
9063
  )
@@ -9076,7 +9070,7 @@ function AIChatPanel() {
9076
9070
  ref: g,
9077
9071
  value: r,
9078
9072
  onChange: (b) => a(b.target.value),
9079
- onKeyDown: h,
9073
+ onKeyDown: m,
9080
9074
  placeholder: "Ask something...",
9081
9075
  className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
9082
9076
  }
@@ -9098,7 +9092,7 @@ function AIChatPanel() {
9098
9092
  {
9099
9093
  size: "sm",
9100
9094
  className: "h-10 px-3",
9101
- onClick: m,
9095
+ onClick: h,
9102
9096
  disabled: l || !r.trim() && !c,
9103
9097
  children: [
9104
9098
  /* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
@@ -9206,18 +9200,18 @@ const AiAssistant = () => {
9206
9200
  preloadedAttributes: n = [],
9207
9201
  onAttributesChange: r
9208
9202
  }) {
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();
9203
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9210
9204
  useEffect(() => {
9211
9205
  l(n);
9212
9206
  }, [n]);
9213
9207
  const b = () => {
9214
9208
  if (i.startsWith("@")) {
9215
- h("Attribute keys cannot start with '@'");
9209
+ m("Attribute keys cannot start with '@'");
9216
9210
  return;
9217
9211
  }
9218
9212
  if (i) {
9219
9213
  const S = [...a, { key: i, value: d }];
9220
- r(S), l(a), c(""), p(""), h("");
9214
+ r(S), l(a), c(""), p(""), m("");
9221
9215
  }
9222
9216
  }, v = (S) => {
9223
9217
  const A = a.filter((N, C) => C !== S);
@@ -9226,33 +9220,33 @@ const AiAssistant = () => {
9226
9220
  g(S), c(a[S].key), p(a[S].value);
9227
9221
  }, w = () => {
9228
9222
  if (i.startsWith("@")) {
9229
- h("Attribute keys cannot start with '@'");
9223
+ m("Attribute keys cannot start with '@'");
9230
9224
  return;
9231
9225
  }
9232
9226
  if (u !== null && i) {
9233
9227
  const S = [...a];
9234
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), h("");
9228
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
9235
9229
  }
9236
9230
  }, _ = (S) => {
9237
9231
  S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
9238
9232
  }, E = useCallback((S) => {
9239
- const A = (y) => /[.,!?;:]/.test(y), N = (y, j, I) => {
9233
+ const A = (k) => /[.,!?;:]/.test(k), N = (k, j, I) => {
9240
9234
  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 = " "), {
9235
+ const T = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
9236
+ return j > 0 && (T === "." || !A(T) && T !== " ") && (L = " "), j < k.length && !A(D) && D !== " " && (R = " "), {
9243
9237
  text: L + I + R,
9244
9238
  prefixLength: L.length,
9245
9239
  suffixLength: R.length
9246
9240
  };
9247
9241
  }, C = f.current;
9248
9242
  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);
9243
+ const k = C.selectionStart || 0, j = C.value || "", I = C.selectionEnd || k;
9244
+ if (I > k) {
9245
+ const O = `{{${S}}}`, { text: P } = N(j, k, O), $ = j.slice(0, k) + P + j.slice(I);
9252
9246
  p($);
9253
9247
  return;
9254
9248
  }
9255
- const R = `{{${S}}}`, { text: T } = N(j, y, R), D = j.slice(0, y) + T + j.slice(y);
9249
+ const R = `{{${S}}}`, { text: T } = N(j, k, R), D = j.slice(0, k) + T + j.slice(k);
9256
9250
  p(D);
9257
9251
  }
9258
9252
  }, []);
@@ -9286,7 +9280,7 @@ const AiAssistant = () => {
9286
9280
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9287
9281
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9288
9282
  /* @__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 })
9283
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: E })
9290
9284
  ] }),
9291
9285
  /* @__PURE__ */ jsx(
9292
9286
  Textarea,
@@ -9307,7 +9301,7 @@ const AiAssistant = () => {
9307
9301
  ] })
9308
9302
  ] }),
9309
9303
  /* @__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" }) }),
9310
- m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9304
+ h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
9311
9305
  ]
9312
9306
  }
9313
9307
  ),
@@ -9338,7 +9332,33 @@ const AiAssistant = () => {
9338
9332
  [o, l, i]
9339
9333
  );
9340
9334
  return /* @__PURE__ */ jsx("div", { className: "flex-col gap-y-2", children: /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsx(AttrsEditor, { preloadedAttributes: n, onAttributesChange: c }) }) }) });
9341
- }), NoopComponent = () => null;
9335
+ }), NoopComponent = () => null, ResetStylesButton = () => {
9336
+ const { resetAll: o } = useResetBlockStyles(), { t: n } = useTranslation();
9337
+ return /* @__PURE__ */ jsxs(DropdownMenu, { children: [
9338
+ /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9339
+ "button",
9340
+ {
9341
+ type: "button",
9342
+ className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
9343
+ onClick: (r) => r.stopPropagation(),
9344
+ children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
9345
+ }
9346
+ ) }),
9347
+ /* @__PURE__ */ jsx(DropdownMenuContent, { side: "bottom", className: "border-border text-xs", children: /* @__PURE__ */ jsxs(
9348
+ DropdownMenuItem,
9349
+ {
9350
+ className: "flex items-center gap-1 text-xs",
9351
+ onClick: () => {
9352
+ o();
9353
+ },
9354
+ children: [
9355
+ /* @__PURE__ */ jsx(ResetIcon, { className: "h-3 w-3" }),
9356
+ n("Reset styles")
9357
+ ]
9358
+ }
9359
+ ) })
9360
+ ] });
9361
+ };
9342
9362
  function BlockAttributesToggle() {
9343
9363
  const { t: o } = useTranslation(), [n, r] = useState(!0), [a] = useSelectedStylingBlocks();
9344
9364
  return isEmpty(a) ? null : /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -9372,16 +9392,20 @@ const SettingsPanel = () => {
9372
9392
  /* @__PURE__ */ jsx("br", {}),
9373
9393
  /* @__PURE__ */ jsx("br", {})
9374
9394
  ] }) }) : l ? /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs("div", { className: "no-scrollbar h-full max-h-min w-full overflow-y-auto overflow-x-hidden", children: [
9395
+ /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-end", children: /* @__PURE__ */ jsx(ResetStylesButton, {}) }),
9375
9396
  /* @__PURE__ */ jsx(BlockStyling, {}),
9376
9397
  /* @__PURE__ */ jsx(BlockAttributesToggle, {}),
9377
9398
  /* @__PURE__ */ jsx("br", {}),
9378
9399
  /* @__PURE__ */ jsx("br", {}),
9379
9400
  /* @__PURE__ */ jsx("br", {})
9380
9401
  ] }) }) : /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxs(Tabs, { defaultValue: "settings", className: "flex flex-1 flex-col", children: [
9381
- /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
9402
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(TabsList, { className: "grid h-auto w-full grid-cols-2 p-1 py-1", children: [
9382
9403
  /* @__PURE__ */ jsx(TabsTrigger, { value: "settings", className: "text-xs", children: "Settings" }),
9383
- /* @__PURE__ */ jsx(TabsTrigger, { value: "styles", className: "text-xs", children: "Styles" })
9384
- ] }),
9404
+ /* @__PURE__ */ jsxs(TabsTrigger, { value: "styles", className: "flex items-center justify-between text-xs", children: [
9405
+ "Styles",
9406
+ /* @__PURE__ */ jsx(ResetStylesButton, {})
9407
+ ] })
9408
+ ] }) }),
9385
9409
  /* @__PURE__ */ jsxs(TabsContent, { value: "settings", className: "no-scrollbar h-full max-h-min overflow-y-auto", children: [
9386
9410
  /* @__PURE__ */ jsx(BlockSettings, {}),
9387
9411
  /* @__PURE__ */ jsx("br", {}),
@@ -9438,9 +9462,9 @@ const RootLayout = () => {
9438
9462
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9439
9463
  r("outline");
9440
9464
  });
9441
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), m = useCallback((S) => {
9465
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((S) => {
9442
9466
  S.preventDefault();
9443
- }, []), h = useCallback(
9467
+ }, []), m = useCallback(
9444
9468
  (S) => {
9445
9469
  r(n === S ? null : S);
9446
9470
  },
@@ -9448,7 +9472,7 @@ const RootLayout = () => {
9448
9472
  ), { t: x } = useTranslation(), f = useMemo(
9449
9473
  () => [...p, ...u, ...g],
9450
9474
  [p, u, g]
9451
- ), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9475
+ ), y = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: n }) ?? first(f), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9452
9476
  useEffect(() => {
9453
9477
  if (n !== null) {
9454
9478
  const S = find(f, { id: n });
@@ -9469,15 +9493,15 @@ const RootLayout = () => {
9469
9493
  }, [n, f]);
9470
9494
  const E = useCallback(
9471
9495
  (S) => {
9472
- h(S);
9496
+ m(S);
9473
9497
  },
9474
- [h]
9498
+ [m]
9475
9499
  );
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: [
9500
+ 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
9501
  /* @__PURE__ */ jsxs(
9478
9502
  "div",
9479
9503
  {
9480
- onContextMenu: m,
9504
+ onContextMenu: h,
9481
9505
  className: "flex h-screen max-h-full flex-col bg-background text-foreground",
9482
9506
  children: [
9483
9507
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
@@ -9657,25 +9681,122 @@ const RootLayout = () => {
9657
9681
  options: n
9658
9682
  }) => {
9659
9683
  const r = useToggleChaiFeatureFlag(o), a = useChaiFeatureFlag(o);
9660
- return /* @__PURE__ */ jsxs("div", { className: "flex items-center space-x-2", children: [
9684
+ 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
9685
  /* @__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 })
9686
+ /* @__PURE__ */ jsxs("div", { className: "flex-1", children: [
9687
+ /* @__PURE__ */ jsx("p", { className: "text-sm font-medium text-gray-900 dark:text-gray-100", children: n.key }),
9688
+ n.description && /* @__PURE__ */ jsx("p", { className: "mt-0.5 text-xs text-gray-500 dark:text-gray-400", children: n.description })
9665
9689
  ] })
9666
9690
  ] });
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;
9691
+ }, showFeatureFlagAtom = atomWithStorage(
9692
+ "show-feature-flag",
9693
+ null
9694
+ ), ChaiFeatureFlagsWidgetComponent = ({
9695
+ close: o,
9696
+ position: n,
9697
+ updatePosition: r
9698
+ }) => {
9699
+ const a = useChaiFeatureFlags(), [l, i] = useState(""), [c, d] = useState(!1), [p, u] = useState({ x: 0, y: 0 }), g = useMemo(() => {
9700
+ if (!l.trim()) return a;
9701
+ const f = l.toLowerCase();
9702
+ return Object.fromEntries(
9703
+ Object.entries(a).filter(([y, b]) => {
9704
+ var v;
9705
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((v = b == null ? void 0 : b.description) == null ? void 0 : v.toLowerCase().includes(f));
9706
+ })
9707
+ );
9708
+ }, [a, l]), h = (f) => {
9709
+ d(!0), u({
9710
+ x: f.clientX - n.x,
9711
+ y: f.clientY - n.y
9712
+ });
9713
+ }, m = (f) => {
9714
+ if (!c) return;
9715
+ 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));
9716
+ r(S, A);
9717
+ }, x = () => {
9718
+ d(!1);
9719
+ };
9720
+ return useEffect(() => {
9721
+ const f = () => {
9722
+ c && d(!1);
9723
+ };
9724
+ return window.addEventListener("mouseup", f), () => window.removeEventListener("mouseup", f);
9725
+ }, [c]), !n || n.x < 0 || n.y < 0 ? null : /* @__PURE__ */ jsxs(
9726
+ "div",
9727
+ {
9728
+ onMouseDown: h,
9729
+ onMouseMove: m,
9730
+ onMouseUp: x,
9731
+ className: "fixed z-[9999999] select-none rounded-md border border-gray-300 bg-white p-3 shadow-2xl",
9732
+ style: {
9733
+ left: n.x,
9734
+ top: n.y,
9735
+ cursor: c ? "grabbing" : "grab",
9736
+ userSelect: "none"
9737
+ },
9738
+ children: [
9739
+ /* @__PURE__ */ jsxs("div", { className: "relative sticky top-0 rounded-t-lg bg-white", children: [
9740
+ /* @__PURE__ */ jsxs("div", { className: "mb-3 flex items-center justify-between", children: [
9741
+ /* @__PURE__ */ jsxs("div", { children: [
9742
+ /* @__PURE__ */ jsxs("h3", { className: "flex items-center gap-x-2 text-base font-semibold text-gray-900 dark:text-gray-100", children: [
9743
+ /* @__PURE__ */ jsx(DragHandleDots2Icon, {}),
9744
+ " Feature Flags"
9745
+ ] }),
9746
+ /* @__PURE__ */ jsxs("p", { className: "text-xs text-gray-400 dark:text-gray-400", children: [
9747
+ "Toggle experimental features (",
9748
+ /* @__PURE__ */ jsx("span", { className: "font-mono", children: "Ctrl+Shift+1" }),
9749
+ " to toggle)"
9750
+ ] })
9751
+ ] }),
9752
+ /* @__PURE__ */ jsx(
9753
+ Button,
9754
+ {
9755
+ variant: "ghost",
9756
+ size: "sm",
9757
+ onClick: o,
9758
+ className: "absolute -right-2 -top-2 p-1 text-gray-500 hover:text-gray-700 dark:text-gray-400 dark:hover:text-gray-200",
9759
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
9760
+ }
9761
+ )
9762
+ ] }),
9763
+ /* @__PURE__ */ jsxs("div", { className: "relative", children: [
9764
+ /* @__PURE__ */ jsx(Search, { className: "absolute left-2.5 top-2.5 h-4 w-4 text-gray-400" }),
9765
+ /* @__PURE__ */ jsx(
9766
+ Input$1,
9767
+ {
9768
+ type: "search",
9769
+ placeholder: "Search features...",
9770
+ className: "w-full pl-8",
9771
+ value: l,
9772
+ onChange: (f) => i(f.target.value),
9773
+ autoFocus: !0
9774
+ }
9775
+ )
9776
+ ] })
9777
+ ] }),
9778
+ /* @__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: [
9779
+ 'No features found matching "',
9780
+ l,
9781
+ '"'
9782
+ ] }) }) })
9783
+ ]
9784
+ }
9785
+ );
9786
+ }, ChaiFeatureFlagsWidget = () => {
9787
+ const [o, n] = useAtom$1(showFeatureFlagAtom);
9788
+ return useHotkeys(
9789
+ "ctrl+shift+1,command+shift+1",
9790
+ () => n((r) => r ? { ...r, show: !r.show } : { x: 0, y: 0, show: !0 }),
9791
+ { enableOnFormTags: !0 }
9792
+ ), o != null && o.show ? /* @__PURE__ */ jsx(
9793
+ ChaiFeatureFlagsWidgetComponent,
9794
+ {
9795
+ position: o,
9796
+ close: () => n((r) => ({ ...r, show: !1 })),
9797
+ updatePosition: (r, a) => n((l) => ({ ...l, x: r, y: a }))
9798
+ }
9799
+ ) : null;
9679
9800
  }, setDebugLogs = (o) => {
9680
9801
  }, getParentNodeIds = (o, n) => {
9681
9802
  const r = [];
@@ -9765,50 +9886,50 @@ const RootLayout = () => {
9765
9886
  for (const i of n.p)
9766
9887
  l.add(i);
9767
9888
  return l;
9768
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...x) => h.read(...x), p = (h, ...x) => h.write(...x), u = (h, x) => {
9889
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...x) => m.read(...x), p = (m, ...x) => m.write(...x), u = (m, x) => {
9769
9890
  var f;
9770
- return (f = h.unstable_onInit) == null ? void 0 : f.call(h, x);
9771
- }, g = (h, x) => {
9891
+ return (f = m.unstable_onInit) == null ? void 0 : f.call(m, x);
9892
+ }, g = (m, x) => {
9772
9893
  var f;
9773
- return (f = h.onMount) == null ? void 0 : f.call(h, x);
9774
- }, ...m) => {
9775
- const h = m[0] || ((A) => {
9894
+ return (f = m.onMount) == null ? void 0 : f.call(m, x);
9895
+ }, ...h) => {
9896
+ const m = h[0] || ((A) => {
9776
9897
  let N = o.get(A);
9777
9898
  return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
9778
- }), x = m[1] || (() => {
9899
+ }), x = h[1] || (() => {
9779
9900
  let A, N;
9780
- const C = (y) => {
9901
+ const C = (k) => {
9781
9902
  try {
9782
- y();
9903
+ k();
9783
9904
  } catch (j) {
9784
9905
  A || (A = !0, N = j);
9785
9906
  }
9786
9907
  };
9787
9908
  do {
9788
9909
  c.f && C(c.f);
9789
- const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
9910
+ const k = /* @__PURE__ */ new Set(), j = k.add.bind(k);
9790
9911
  a.forEach((I) => {
9791
9912
  var L;
9792
9913
  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();
9914
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && f();
9794
9915
  } while (a.size || i.size || l.size);
9795
9916
  if (A)
9796
9917
  throw N;
9797
- }), 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);
9918
+ }), f = h[2] || (() => {
9919
+ const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9920
+ for (; k.length; ) {
9921
+ const j = k[k.length - 1], I = m(j);
9801
9922
  if (C.has(j)) {
9802
- y.pop();
9923
+ k.pop();
9803
9924
  continue;
9804
9925
  }
9805
9926
  if (N.has(j)) {
9806
- r.get(j) === I.n && A.push([j, I]), C.add(j), y.pop();
9927
+ r.get(j) === I.n && A.push([j, I]), C.add(j), k.pop();
9807
9928
  continue;
9808
9929
  }
9809
9930
  N.add(j);
9810
9931
  for (const L of getMountedOrPendingDependents(j, I, n))
9811
- N.has(L) || y.push(L);
9932
+ N.has(L) || k.push(L);
9812
9933
  }
9813
9934
  for (let j = A.length - 1; j >= 0; --j) {
9814
9935
  const [I, L] = A[j];
@@ -9818,39 +9939,39 @@ const RootLayout = () => {
9818
9939
  R = !0;
9819
9940
  break;
9820
9941
  }
9821
- R && (k(I), B(I)), r.delete(I);
9942
+ R && (y(I), B(I)), r.delete(I);
9822
9943
  }
9823
- }), k = m[3] || ((A) => {
9944
+ }), y = h[3] || ((A) => {
9824
9945
  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(
9946
+ const k = m(A);
9947
+ if (isAtomStateInitialized(k) && (n.has(A) && r.get(A) !== k.n || Array.from(k.d).every(
9827
9948
  ([P, $]) => (
9828
9949
  // Recursively, read the atom state of the dependency, and
9829
9950
  // check if the atom epoch number is unchanged
9830
- k(P).n === $
9951
+ y(P).n === $
9831
9952
  )
9832
9953
  )))
9833
- return y;
9834
- y.d.clear();
9954
+ return k;
9955
+ k.d.clear();
9835
9956
  let j = !0;
9836
9957
  const I = () => {
9837
9958
  n.has(A) && (B(A), f(), x());
9838
9959
  }, L = (P) => {
9839
9960
  var $;
9840
9961
  if (isSelfAtom(A, P)) {
9841
- const H = h(P);
9962
+ const H = m(P);
9842
9963
  if (!isAtomStateInitialized(H))
9843
9964
  if (hasInitialValue(P))
9844
- setAtomStateValueOrPromise(P, P.init, h);
9965
+ setAtomStateValueOrPromise(P, P.init, m);
9845
9966
  else
9846
9967
  throw new Error("no atom init");
9847
9968
  return returnAtomValue(H);
9848
9969
  }
9849
- const M = k(P);
9970
+ const M = y(P);
9850
9971
  try {
9851
9972
  return returnAtomValue(M);
9852
9973
  } 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();
9974
+ k.d.set(P, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(A, k.v, M), ($ = n.get(P)) == null || $.t.add(A), j || I();
9854
9975
  }
9855
9976
  };
9856
9977
  let R, T;
@@ -9868,38 +9989,38 @@ const RootLayout = () => {
9868
9989
  }
9869
9990
  }), T;
9870
9991
  }
9871
- }, O = y.n;
9992
+ }, O = k.n;
9872
9993
  try {
9873
9994
  const P = d(A, L, D);
9874
- return setAtomStateValueOrPromise(A, P, h), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
9995
+ return setAtomStateValueOrPromise(A, P, m), isPromiseLike$1(P) && ((N = P.onCancel) == null || N.call(P, () => R == null ? void 0 : R.abort()), P.then(
9875
9996
  I,
9876
9997
  I
9877
- )), y;
9998
+ )), k;
9878
9999
  } catch (P) {
9879
- return delete y.v, y.e = P, ++y.n, y;
10000
+ return delete k.v, k.e = P, ++k.n, k;
9880
10001
  } 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));
10002
+ 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
10003
  }
9883
- }), b = m[4] || ((A) => {
10004
+ }), b = h[4] || ((A) => {
9884
10005
  const N = [A];
9885
10006
  for (; N.length; ) {
9886
- const C = N.pop(), y = h(C);
9887
- for (const j of getMountedOrPendingDependents(C, y, n)) {
9888
- const I = h(j);
10007
+ const C = N.pop(), k = m(C);
10008
+ for (const j of getMountedOrPendingDependents(C, k, n)) {
10009
+ const I = m(j);
9889
10010
  r.set(j, I.n), N.push(j);
9890
10011
  }
9891
10012
  }
9892
- }), v = m[5] || ((A, ...N) => {
10013
+ }), v = h[5] || ((A, ...N) => {
9893
10014
  let C = !0;
9894
- const y = (I) => returnAtomValue(k(I)), j = (I, ...L) => {
10015
+ const k = (I) => returnAtomValue(y(I)), j = (I, ...L) => {
9895
10016
  var R;
9896
- const T = h(I);
10017
+ const T = m(I);
9897
10018
  try {
9898
10019
  if (isSelfAtom(A, I)) {
9899
10020
  if (!hasInitialValue(I))
9900
10021
  throw new Error("atom not writable");
9901
10022
  const D = T.n, O = L[0];
9902
- setAtomStateValueOrPromise(I, O, h), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
10023
+ setAtomStateValueOrPromise(I, O, m), B(I), D !== T.n && (a.add(I), (R = c.c) == null || R.call(c, I), b(I));
9903
10024
  return;
9904
10025
  } else
9905
10026
  return v(I, ...L);
@@ -9908,39 +10029,39 @@ const RootLayout = () => {
9908
10029
  }
9909
10030
  };
9910
10031
  try {
9911
- return p(A, y, j, ...N);
10032
+ return p(A, k, j, ...N);
9912
10033
  } finally {
9913
10034
  C = !1;
9914
10035
  }
9915
- }), B = m[6] || ((A) => {
10036
+ }), B = h[6] || ((A) => {
9916
10037
  var N;
9917
- const C = h(A), y = n.get(A);
9918
- if (y && !isPendingPromise(C.v)) {
10038
+ const C = m(A), k = n.get(A);
10039
+ if (k && !isPendingPromise(C.v)) {
9919
10040
  for (const [j, I] of C.d)
9920
- if (!y.d.has(j)) {
9921
- 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));
10041
+ if (!k.d.has(j)) {
10042
+ const L = m(j);
10043
+ 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
10044
  }
9924
- for (const j of y.d || [])
10045
+ for (const j of k.d || [])
9925
10046
  if (!C.d.has(j)) {
9926
- y.d.delete(j);
10047
+ k.d.delete(j);
9927
10048
  const I = _(j);
9928
10049
  I == null || I.t.delete(A);
9929
10050
  }
9930
10051
  }
9931
- }), w = m[7] || ((A) => {
10052
+ }), w = h[7] || ((A) => {
9932
10053
  var N;
9933
- const C = h(A);
9934
- let y = n.get(A);
9935
- if (!y) {
9936
- k(A);
10054
+ const C = m(A);
10055
+ let k = n.get(A);
10056
+ if (!k) {
10057
+ y(A);
9937
10058
  for (const j of C.d.keys())
9938
10059
  w(j).t.add(A);
9939
- if (y = {
10060
+ if (k = {
9940
10061
  l: /* @__PURE__ */ new Set(),
9941
10062
  d: new Set(C.d.keys()),
9942
10063
  t: /* @__PURE__ */ new Set()
9943
- }, n.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
10064
+ }, n.set(A, k), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9944
10065
  const j = () => {
9945
10066
  let I = !0;
9946
10067
  const L = (...R) => {
@@ -9952,7 +10073,7 @@ const RootLayout = () => {
9952
10073
  };
9953
10074
  try {
9954
10075
  const R = g(A, L);
9955
- R && (y.u = () => {
10076
+ R && (k.u = () => {
9956
10077
  I = !0;
9957
10078
  try {
9958
10079
  R();
@@ -9967,23 +10088,23 @@ const RootLayout = () => {
9967
10088
  l.add(j);
9968
10089
  }
9969
10090
  }
9970
- return y;
9971
- }), _ = m[8] || ((A) => {
10091
+ return k;
10092
+ }), _ = h[8] || ((A) => {
9972
10093
  var N;
9973
- const C = h(A);
9974
- let y = n.get(A);
9975
- if (y && !y.l.size && !Array.from(y.t).some((j) => {
10094
+ const C = m(A);
10095
+ let k = n.get(A);
10096
+ if (k && !k.l.size && !Array.from(k.t).some((j) => {
9976
10097
  var I;
9977
10098
  return (I = n.get(j)) == null ? void 0 : I.d.has(A);
9978
10099
  })) {
9979
- y.u && i.add(y.u), y = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
10100
+ k.u && i.add(k.u), k = void 0, n.delete(A), (N = c.u) == null || N.call(c, A);
9980
10101
  for (const j of C.d.keys()) {
9981
10102
  const I = _(j);
9982
10103
  I == null || I.t.delete(A);
9983
10104
  }
9984
10105
  return;
9985
10106
  }
9986
- return y;
10107
+ return k;
9987
10108
  }), E = [
9988
10109
  // store state
9989
10110
  o,
@@ -9999,17 +10120,17 @@ const RootLayout = () => {
9999
10120
  u,
10000
10121
  g,
10001
10122
  // building-block functions
10002
- h,
10123
+ m,
10003
10124
  x,
10004
10125
  f,
10005
- k,
10126
+ y,
10006
10127
  b,
10007
10128
  v,
10008
10129
  B,
10009
10130
  w,
10010
10131
  _
10011
10132
  ], S = {
10012
- get: (A) => returnAtomValue(k(A)),
10133
+ get: (A) => returnAtomValue(y(A)),
10013
10134
  set: (A, ...N) => {
10014
10135
  try {
10015
10136
  return v(A, ...N);
@@ -10018,9 +10139,9 @@ const RootLayout = () => {
10018
10139
  }
10019
10140
  },
10020
10141
  sub: (A, N) => {
10021
- const y = w(A).l;
10022
- return y.add(N), x(), () => {
10023
- y.delete(N), _(A), x();
10142
+ const k = w(A).l;
10143
+ return k.add(N), x(), () => {
10144
+ k.delete(N), _(A), x();
10024
10145
  };
10025
10146
  }
10026
10147
  };
@@ -10142,7 +10263,7 @@ const useAutoSave = () => {
10142
10263
  /* @__PURE__ */ jsx(ChaiWatchers, { ...o }),
10143
10264
  /* @__PURE__ */ jsx(PreviewScreen, {}),
10144
10265
  /* @__PURE__ */ jsx(Toaster, { richColors: !0 }),
10145
- /* @__PURE__ */ jsx("div", { className: "fixed bottom-4 left-4 z-50", children: /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {}) })
10266
+ /* @__PURE__ */ jsx(ChaiFeatureFlagsWidget, {})
10146
10267
  ] }) });
10147
10268
  };
10148
10269
  if (typeof window > "u")
@@ -10170,7 +10291,7 @@ export {
10170
10291
  getBlocksFromHTML as convertHTMLToChaiBlocks,
10171
10292
  generateUUID as generateBlockId,
10172
10293
  getBlocksFromHTML,
10173
- We as i18n,
10294
+ ze as i18n,
10174
10295
  cn$2 as mergeClasses,
10175
10296
  registerBlockSettingField,
10176
10297
  registerBlockSettingTemplate,