@chaibuilder/sdk 2.2.18 → 2.2.19

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,30 +3,32 @@ var F = (o, r, n) => r in o ? V(o, r, { enumerable: !0, configurable: !0, writab
3
3
  var H = (o, r, n) => F(o, typeof r != "symbol" ? r + "" : r, n);
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, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, 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
- import { get, find, filter, flatten, has, isString, map, includes, without, compact, reverse, findIndex, isEmpty, each, omit, isObject, memoize, noop, first, keys, range, values, flattenDeep, set, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, isArray, isFunction, 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";
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
+ import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, isFunction, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
- import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, createContext, useContext, Suspense, createElement, memo, useReducer, useDebugValue } from "react";
10
- import { atom, useAtom as useAtom$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, useAtomValue as useAtomValue$1, Provider } from "jotai";
9
+ import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
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
- import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./common-functions-BGzDsf1z.js";
13
- import { B as Button, Z as DropdownMenu, ab as DropdownMenuTrigger, $ as DropdownMenuContent, a1 as DropdownMenuItem, ay as Skeleton, e as Alert, f as AlertDescription, af as Input$1, P as Dialog, Y as DialogTrigger, R as DialogContent, ah as Popover, aG as Tooltip, aJ as TooltipTrigger, ak as PopoverTrigger, aH as TooltipContent, aj as PopoverContent, G as Command, I as CommandInput, J as CommandList, K as CommandEmpty, L as CommandGroup, M as CommandItem, U as DialogHeader, X as DialogTitle, v as Badge, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, a2 as DropdownMenuLabel, a6 as DropdownMenuSeparator, _ as DropdownMenuCheckboxItem, ac as HoverCard, ae as HoverCardTrigger, ad as HoverCardContent, aF as Textarea, A as Accordion, C as Card, E as CardHeader, z as CardDescription, y as CardContent, ag as Label, D as CardFooter, al as ScrollArea, aB as Tabs, aD as TabsList, aE as TabsTrigger, aC as TabsContent, h as AlertDialog, r as AlertDialogTrigger, k as AlertDialogContent, n as AlertDialogHeader, q as AlertDialogTitle, l as AlertDialogDescription, m as AlertDialogFooter, j as AlertDialogCancel, i as AlertDialogAction, aA as Switch, c as cn$2, s as Avatar, an as Separator, aI as TooltipProvider, ao as Sheet, aq as SheetContent, at as SheetHeader, aw as SheetTitle, az as Toaster } from "./sooner-H65duPYc.js";
14
- import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, DatabaseIcon, ChevronLeft, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
12
+ import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
13
+ import { B as Button, Z as DropdownMenu, ab as DropdownMenuTrigger, $ as DropdownMenuContent, a1 as DropdownMenuItem, c as cn$1, ay as Skeleton, e as Alert, f as AlertDescription, af as Input$1, P as Dialog, Y as DialogTrigger, R as DialogContent, ah as Popover, aG as Tooltip, aJ as TooltipTrigger, ak as PopoverTrigger, aH as TooltipContent, aj as PopoverContent, G as Command, I as CommandInput, J as CommandList, K as CommandEmpty, L as CommandGroup, M as CommandItem, U as DialogHeader, X as DialogTitle, v as Badge, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, a2 as DropdownMenuLabel, a6 as DropdownMenuSeparator, _ as DropdownMenuCheckboxItem, ac as HoverCard, ae as HoverCardTrigger, ad as HoverCardContent, aF as Textarea, A as Accordion, C as Card, E as CardHeader, z as CardDescription, y as CardContent, ag as Label, D as CardFooter, al as ScrollArea, aB as Tabs, aD as TabsList, aE as TabsTrigger, aC as TabsContent, h as AlertDialog, r as AlertDialogTrigger, k as AlertDialogContent, n as AlertDialogHeader, q as AlertDialogTitle, l as AlertDialogDescription, m as AlertDialogFooter, j as AlertDialogCancel, i as AlertDialogAction, aA as Switch, s as Avatar, an as Separator, aI as TooltipProvider, ao as Sheet, aq as SheetContent, at as SheetHeader, aw as SheetTitle, az as Toaster } from "./sooner-H65duPYc.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, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, 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";
18
- import { S as STYLES_KEY, f as getSplitChaiClasses, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as ROOT_TEMP_KEY } from "./apply-binding-Z9D6RXG4.js";
19
- import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, e as getThemeFontsLinkMarkup, h as getThemeCustomFontFace } from "./plugin-fnBB3TCm.js";
20
- import Fuse from "fuse.js";
18
+ import { C as COLLECTION_PREFIX, S as STYLES_KEY, f as getSplitChaiClasses, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, h as ROOT_TEMP_KEY } from "./apply-binding-CkrtJykq.js";
19
+ import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, h as getThemeFontsUrls, i as getThemeCustomFontFace } from "./plugin-BOcGV_IY.js";
20
+ import { isObject } from "@rjsf/utils";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
22
22
  import { toast } from "sonner";
23
23
  import { useTranslation, initReactI18next } from "react-i18next";
24
- import { useTranslation as Ue } from "react-i18next";
24
+ import { useTranslation as Fe } from "react-i18next";
25
+ import Fuse from "fuse.js";
25
26
  import UndoManager from "undo-manager";
26
27
  import Link from "@tiptap/extension-link";
27
28
  import TextAlign from "@tiptap/extension-text-align";
28
29
  import Underline from "@tiptap/extension-underline";
29
- import { useEditor, EditorContent } from "@tiptap/react";
30
+ import Placeholder from "@tiptap/extension-placeholder";
31
+ import { useEditor, BubbleMenu as BubbleMenu$1, EditorContent } from "@tiptap/react";
30
32
  import StarterKit from "@tiptap/starter-kit";
31
33
  import RjForm from "@rjsf/core";
32
34
  import validator from "@rjsf/validator-ajv8";
@@ -35,7 +37,7 @@ import { useFeature, FlagsProvider } from "flagged";
35
37
  import { parse, stringify } from "himalaya";
36
38
  import { Tree } from "react-arborist";
37
39
  import i18n from "i18next";
38
- import { default as Fe } from "i18next";
40
+ import { default as We } from "i18next";
39
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
40
42
  import tailwindForms from "@tailwindcss/forms";
41
43
  import tailwindTypography from "@tailwindcss/typography";
@@ -167,44 +169,7 @@ const globalBlocksAtom = atom((o) => {
167
169
  return filter(r, (n) => has(n, "blockId"));
168
170
  });
169
171
  globalBlocksAtom.debugLabel = "globalBlocksAtom";
170
- const builderStore = getDefaultStore$1(), writeAtomValue = atom(
171
- null,
172
- // it's a convention to pass `null` for the first argument
173
- (o, r, { id: n, props: a }) => {
174
- const l = o(pageBlocksAtomsAtom), i = find(l, (c) => o(c)._id === n);
175
- return i ? r(i, { ...o(i), ...a }) : null;
176
- }
177
- ), useUpdateBlockAtom = () => useSetAtom$1(writeAtomValue), useGetBlockAtomValue = (o) => useAtomCallback(
178
- useCallback(
179
- (r, n, a) => {
180
- const l = r(o);
181
- if (!l || !l.length)
182
- return null;
183
- const i = find(
184
- l,
185
- (c) => r(c)._id === (isString(a) ? a : r(a)._id)
186
- );
187
- return i ? r(i) : null;
188
- },
189
- [o]
190
- ),
191
- { store: builderStore }
192
- ), useGetBlockAtom = (o) => useAtomCallback(
193
- useCallback(
194
- (r, n, a) => {
195
- const l = r(o);
196
- if (!l || !l.length)
197
- return console.warn("No blocks available in splitAtoms"), null;
198
- const i = find(
199
- l,
200
- (c) => r(c)._id === (isString(a) ? a : r(a)._id)
201
- );
202
- return i || (console.warn(`Block with id ${a} not found`), null);
203
- },
204
- [o]
205
- ),
206
- { store: builderStore }
207
- ), selectedBlockIdsAtom = atom([]);
172
+ const selectedBlockIdsAtom = atom([]);
208
173
  selectedBlockIdsAtom.debugLabel = "selectedBlockIdsAtom";
209
174
  const selectedBlocksAtom = atom((o) => {
210
175
  const r = o(presentBlocksAtom), n = o(selectedBlockIdsAtom);
@@ -222,7 +187,7 @@ const selectedBlockAtom = atom((o) => {
222
187
  return r[0];
223
188
  });
224
189
  selectedBlockAtom.debugLabel = "selectedBlockAtom";
225
- const getParentId = (o) => get(o, "_parent", null), selectedBlocksParentsAtom = atom((o) => {
190
+ const useSelectedBlock = () => useAtomValue$1(selectedBlockAtom), getParentId = (o) => get(o, "_parent", null), selectedBlocksParentsAtom = atom((o) => {
226
191
  const r = o(selectedBlocksAtom), n = map(r, getParentId);
227
192
  return filter(o(presentBlocksAtom), (a) => includes(n, a._id));
228
193
  });
@@ -238,10 +203,7 @@ styleBreakpointAtom.debugLabel = "styleBreakpointAtom";
238
203
  const useSelectedBlocksDisplayChild = () => ({
239
204
  flexChild: useAtomValue$1(selectedBlockFlexChildAtom),
240
205
  gridChild: useAtomValue$1(selectedBlockGridChildAtom)
241
- }), useSelectedBlock = () => {
242
- const [o] = useSelectedBlockIds(), r = useGetBlockAtomValue(pageBlocksAtomsAtom);
243
- return o.length > 0 ? r(o[0]) : null;
244
- }, selectedBlockHierarchy = atom((o) => {
206
+ }), selectedBlockHierarchy = atom((o) => {
245
207
  const r = o(selectedBlockAtom), n = o(presentBlocksAtom);
246
208
  let a = r;
247
209
  const l = [r];
@@ -287,7 +249,11 @@ const useSelectedBlocksDisplayChild = () => ({
287
249
  }, CHAI_BUILDER_EVENTS = {
288
250
  OPEN_ADD_BLOCK: "OPEN_ADD_BLOCK",
289
251
  CLOSE_ADD_BLOCK: "CLOSE_ADD_BLOCK",
290
- SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS"
252
+ SHOW_BLOCK_SETTINGS: "SHOW_BLOCK_SETTINGS",
253
+ //CANVAS Events
254
+ CLEAR_CANVAS_SELECTION: "CLEAR_CANVAS_SELECTION",
255
+ CANVAS_BLOCK_SELECTED: "CANVAS_BLOCK_SELECTED",
256
+ CANVAS_BLOCK_STYLE_SELECTED: "CANVAS_BLOCK_STYLE_SELECTED"
291
257
  }, canAcceptChildBlock = (o, r) => {
292
258
  if (!o) return !0;
293
259
  const n = getRegisteredChaiBlock(o);
@@ -349,7 +315,8 @@ const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
349
315
  /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: n("Add after") })
350
316
  ] })
351
317
  ] }) : null;
352
- }, draggedBlockAtom = atom(null), dropTargetBlockIdAtom = atom(null);
318
+ }, draggedBlockAtom = atom(null);
319
+ atom(null);
353
320
  function getOrientation(o, r = null) {
354
321
  const n = window.getComputedStyle(o), a = r ? window.getComputedStyle(r) : null, l = n.display, i = a ? a.display : null;
355
322
  if (l === "flex" || l === "inline-flex") {
@@ -384,8 +351,8 @@ function insertBlocksAtPosition(o, r, n, a) {
384
351
  }), l.unshift(h), i = i.map((f) => {
385
352
  if (f._id === n) {
386
353
  const x = { ...f, content: "" };
387
- return Object.keys(x).forEach((k) => {
388
- k.startsWith("content-") && (x[k] = "");
354
+ return Object.keys(x).forEach((y) => {
355
+ y.startsWith("content-") && (x[y] = "");
389
356
  }), x;
390
357
  }
391
358
  return f;
@@ -520,8 +487,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
520
487
  h && "content" in h && (n = n.map((f) => {
521
488
  if (f._id === u) {
522
489
  const x = { ...f, content: m.content };
523
- return Object.keys(m).forEach((k) => {
524
- k.startsWith("content-") && (x[k] = m[k]);
490
+ return Object.keys(m).forEach((y) => {
491
+ y.startsWith("content-") && (x[y] = m[y]);
525
492
  }), x;
526
493
  }
527
494
  return f;
@@ -542,7 +509,29 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
542
509
  },
543
510
  [o, n, r, l]
544
511
  );
545
- }, useBlocksStoreManager = () => {
512
+ }, builderStore = getDefaultStore$1(), writeAtomValue = atom(
513
+ null,
514
+ // it's a convention to pass `null` for the first argument
515
+ (o, r, { id: n, props: a }) => {
516
+ const l = o(pageBlocksAtomsAtom), i = find(l, (c) => o(c)._id === n);
517
+ return i ? r(i, { ...o(i), ...a }) : null;
518
+ }
519
+ ), useUpdateBlockAtom = () => useSetAtom$1(writeAtomValue), useGetBlockAtom = (o) => useAtomCallback(
520
+ useCallback(
521
+ (r, n, a) => {
522
+ const l = r(o);
523
+ if (!l || !l.length)
524
+ return console.warn("No blocks available in splitAtoms"), null;
525
+ const i = find(
526
+ l,
527
+ (c) => r(c)._id === (isString(a) ? a : r(a)._id)
528
+ );
529
+ return i || (console.warn(`Block with id ${a} not found`), null);
530
+ },
531
+ [o]
532
+ ),
533
+ { store: builderStore }
534
+ ), useBlocksStoreManager = () => {
546
535
  const [, o] = useBlocksStore(), { postMessage: r } = useBroadcastChannel(), n = useUpdateBlockAtom();
547
536
  return {
548
537
  setNewBlocks: (a) => {
@@ -578,6 +567,30 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
578
567
  }), r({ type: "blocks-props-updated", blocks: a });
579
568
  }
580
569
  };
570
+ }, blockRepeaterDataAtom = atom({});
571
+ blockRepeaterDataAtom.debugLabel = "blockRepeaterDataAtom";
572
+ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyncProps = (o, r = []) => {
573
+ const [n, a] = useState({
574
+ status: "idle",
575
+ props: {},
576
+ error: void 0
577
+ }), l = useBuilderProp("getBlockAsyncProps", async (u) => ({})), i = useSetAtom$1(blockRepeaterDataAtom), c = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r))]), d = get(n, "status"), p = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`);
578
+ return useEffect(() => {
579
+ o && (a((u) => ({ ...u, status: "loading", props: {} })), l(o).then((u = {}) => {
580
+ p ? i((g) => ({
581
+ ...g,
582
+ [o._id]: { status: "loaded", props: isArray(u) ? u : {}, repeaterItems: o.repeaterItems }
583
+ })) : a((g) => ({ ...g, status: "loaded", props: isObject(u) ? u : {} }));
584
+ }).catch((u) => {
585
+ p ? i((g) => ({
586
+ ...g,
587
+ [o._id]: { status: "error", error: u, props: {} }
588
+ })) : a((g) => ({ ...g, status: "error", error: u, props: {} }));
589
+ }));
590
+ }, [o == null ? void 0 : o._id, c, p]), {
591
+ $loading: d === "loading",
592
+ ...o ? get(n, "props", {}) : {}
593
+ };
581
594
  }, chaiBuilderPropsAtom = atom(null);
582
595
  chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
583
596
  const chaiExternalDataAtom = atom({});
@@ -590,7 +603,15 @@ const chaiRjsfTemplatesAtom = atom({});
590
603
  chaiRjsfTemplatesAtom.debugLabel = "chaiRjsfTemplatesAtom";
591
604
  const chaiPageExternalDataAtom = atom({});
592
605
  chaiPageExternalDataAtom.debugLabel = "chaiPageExternalDataAtom";
593
- const usePageExternalData = () => useAtomValue$1(chaiPageExternalDataAtom), useBuilderProp = (o, r = void 0) => {
606
+ const usePageExternalData = () => {
607
+ const [o] = useBlockRepeaterDataAtom(), r = useMemo(() => {
608
+ const a = {};
609
+ return Object.entries(o).forEach(([l, i]) => {
610
+ i.status === "loaded" && (a[i.repeaterItems.replace("}}", `/${l}`).replace("{{", "")] = i.props);
611
+ }), a;
612
+ }, [o]);
613
+ return { ...useAtomValue$1(chaiPageExternalDataAtom), ...r };
614
+ }, useBuilderProp = (o, r = void 0) => {
594
615
  const n = useAtomValue$1(chaiBuilderPropsAtom);
595
616
  return useMemo(() => get(n, o, r), [n, o, r]);
596
617
  }, MODIFIERS = [
@@ -649,7 +670,7 @@ atom(null);
649
670
  const useBrandingOptions = () => {
650
671
  const [o, r] = useAtom$1(brandingOptionsAtom);
651
672
  return [
652
- isObject(o) ? { ...BRANDING_OPTIONS_DEFAULTS, ...o } : BRANDING_OPTIONS_DEFAULTS,
673
+ isObject$1(o) ? { ...BRANDING_OPTIONS_DEFAULTS, ...o } : BRANDING_OPTIONS_DEFAULTS,
653
674
  r
654
675
  ];
655
676
  }, currentPageAtom = atom(null), useCurrentPage = () => ({ currentPage: useAtomValue$1(currentPageAtom) }), getBlockBuilderProps = memoize((o) => {
@@ -717,20 +738,46 @@ const useSavePage = () => {
717
738
  ), saveState: o, setSaveState: r };
718
739
  }, undoManager = new UndoManager();
719
740
  undoManager.setLimit(50);
720
- const useUndoManager = () => {
721
- const [, o] = useAtom$1(builderSaveStateAtom), r = useBuilderProp("onSaveStateChange", noop);
722
- return useEffect(() => (undoManager.setCallback(() => {
723
- o("UNSAVED"), r("UNSAVED");
724
- }), () => {
741
+ const undoRedoStateAtom = atom({
742
+ canUndo: !1,
743
+ canRedo: !1
744
+ }), useUndoManager = () => {
745
+ const [, o] = useAtom$1(builderSaveStateAtom), [r, n] = useAtom$1(undoRedoStateAtom), a = useBuilderProp("onSaveStateChange", noop), l = useCallback(() => {
746
+ const u = {
747
+ canUndo: undoManager.hasUndo(),
748
+ canRedo: undoManager.hasRedo()
749
+ };
750
+ n(u), o("UNSAVED"), a("UNSAVED");
751
+ }, [n, o, a]);
752
+ useEffect(() => (undoManager.setCallback(l), () => {
725
753
  undoManager.setCallback(noop);
726
- }), []), {
727
- add: undoManager.add,
728
- undo: undoManager.undo,
729
- redo: undoManager.redo,
730
- hasRedo: undoManager.hasRedo,
731
- hasUndo: undoManager.hasUndo,
732
- clear: undoManager.clear
733
- };
754
+ }), [l]);
755
+ const i = useCallback(
756
+ (u) => {
757
+ undoManager.add(u), l();
758
+ },
759
+ [l]
760
+ ), c = useCallback(() => {
761
+ undoManager.undo(), l();
762
+ }, [l]), d = useCallback(() => {
763
+ undoManager.redo(), l();
764
+ }, [l]), p = useCallback(() => {
765
+ undoManager.clear(), n({
766
+ canUndo: !1,
767
+ canRedo: !1
768
+ });
769
+ }, [n]);
770
+ return useMemo(
771
+ () => ({
772
+ add: i,
773
+ undo: c,
774
+ redo: d,
775
+ hasUndo: () => r.canUndo,
776
+ hasRedo: () => r.canRedo,
777
+ clear: p
778
+ }),
779
+ [i, c, d, r.canUndo, r.canRedo, p]
780
+ );
734
781
  }, useBlocksStore = () => useAtom$1(presentBlocksAtom), useBlocksStoreUndoableActions = () => {
735
782
  const { add: o } = useUndoManager(), [r] = useBlocksStore(), {
736
783
  setNewBlocks: n,
@@ -740,50 +787,50 @@ const useUndoManager = () => {
740
787
  updateBlocksProps: c
741
788
  } = useBlocksStoreManager();
742
789
  return {
743
- moveBlocks: (x, k, b) => {
744
- const S = map(x, (B) => {
745
- const E = r.find((N) => N._id === B)._parent || null, A = r.filter((N) => E ? N._parent === E : !N._parent).map((N) => N._id).indexOf(B);
746
- return { _id: B, oldParent: E, oldPosition: A };
747
- }), w = S.find(({ _id: B }) => B === x[0]);
748
- w && w.oldParent === k && w.oldPosition === b || (i(x, k, b), o({
749
- undo: () => each(S, ({ _id: B, oldParent: _, oldPosition: E }) => {
750
- i([B], _, E);
790
+ moveBlocks: (x, y, b) => {
791
+ const v = map(x, (w) => {
792
+ const _ = r.find((N) => N._id === w)._parent || null, B = r.filter((N) => _ ? N._parent === _ : !N._parent).map((N) => N._id).indexOf(w);
793
+ return { _id: w, oldParent: _, oldPosition: B };
794
+ }), A = v.find(({ _id: w }) => w === x[0]);
795
+ A && A.oldParent === y && A.oldPosition === b || (i(x, y, b), o({
796
+ undo: () => each(v, ({ _id: w, oldParent: E, oldPosition: _ }) => {
797
+ i([w], E, _);
751
798
  }),
752
- redo: () => i(x, k, b)
799
+ redo: () => i(x, y, b)
753
800
  }));
754
801
  },
755
- addBlocks: (x, k, b) => {
756
- a(x, k, b), o({
802
+ addBlocks: (x, y, b) => {
803
+ a(x, y, b), o({
757
804
  undo: () => l(map(x, "_id")),
758
- redo: () => a(x, k, b)
805
+ redo: () => a(x, y, b)
759
806
  });
760
807
  },
761
808
  removeBlocks: (x) => {
762
- var w;
763
- const k = (w = first(x)) == null ? void 0 : w._parent, S = r.filter((B) => k ? B._parent === k : !B._parent).indexOf(first(x));
809
+ var A;
810
+ const y = (A = first(x)) == null ? void 0 : A._parent, v = r.filter((w) => y ? w._parent === y : !w._parent).indexOf(first(x));
764
811
  l(map(x, "_id")), o({
765
- undo: () => a(x, k, S),
812
+ undo: () => a(x, y, v),
766
813
  redo: () => l(map(x, "_id"))
767
814
  });
768
815
  },
769
- updateBlocks: (x, k, b) => {
770
- let S = [];
816
+ updateBlocks: (x, y, b) => {
817
+ let v = [];
771
818
  if (b)
772
- S = map(x, (w) => ({ _id: w, ...b }));
819
+ v = map(x, (A) => ({ _id: A, ...b }));
773
820
  else {
774
- const w = keys(k);
775
- S = map(x, (B) => {
776
- const _ = r.find((v) => v._id === B), E = { _id: B };
777
- return each(w, (v) => E[v] = _[v]), E;
821
+ const A = keys(y);
822
+ v = map(x, (w) => {
823
+ const E = r.find((S) => S._id === w), _ = { _id: w };
824
+ return each(A, (S) => _[S] = E[S]), _;
778
825
  });
779
826
  }
780
- c(map(x, (w) => ({ _id: w, ...k }))), o({
781
- undo: () => c(S),
782
- redo: () => c(map(x, (w) => ({ _id: w, ...k })))
827
+ c(map(x, (A) => ({ _id: A, ...y }))), o({
828
+ undo: () => c(v),
829
+ redo: () => c(map(x, (A) => ({ _id: A, ...y })))
783
830
  });
784
831
  },
785
- updateBlocksRuntime: (x, k) => {
786
- c(map(x, (b) => ({ _id: b, ...k })));
832
+ updateBlocksRuntime: (x, y) => {
833
+ c(map(x, (b) => ({ _id: b, ...y })));
787
834
  },
788
835
  setNewBlocks: (x) => {
789
836
  n(x), o({
@@ -792,12 +839,12 @@ const useUndoManager = () => {
792
839
  });
793
840
  },
794
841
  updateMultipleBlocksProps: (x) => {
795
- let k = [];
796
- k = map(x, (b) => {
797
- const S = keys(b), w = r.find((_) => _._id === b._id), B = {};
798
- return each(S, (_) => B[_] = w[_]), B;
842
+ let y = [];
843
+ y = map(x, (b) => {
844
+ const v = keys(b), A = r.find((E) => E._id === b._id), w = {};
845
+ return each(v, (E) => w[E] = A[E]), w;
799
846
  }), c(x), o({
800
- undo: () => c(k),
847
+ undo: () => c(y),
801
848
  redo: () => c(x)
802
849
  });
803
850
  }
@@ -809,9 +856,9 @@ const useUndoManager = () => {
809
856
  for (let f = 0; f < i.length; f++) {
810
857
  const { _id: x } = i[f];
811
858
  i[f]._id = generateUUID();
812
- const k = filter(i, { _parent: x });
813
- for (let b = 0; b < k.length; b++)
814
- k[b]._parent = i[f]._id;
859
+ const y = filter(i, { _parent: x });
860
+ for (let b = 0; b < y.length; b++)
861
+ y[b]._parent = i[f]._id;
815
862
  }
816
863
  const p = first(i);
817
864
  let u, g;
@@ -822,8 +869,8 @@ const useUndoManager = () => {
822
869
  return { addCoreBlock: useCallback(
823
870
  (i, c, d) => {
824
871
  if (has(i, "blocks")) {
825
- const k = i.blocks;
826
- return a(k, c, d);
872
+ const y = i.blocks;
873
+ return a(y, c, d);
827
874
  }
828
875
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
829
876
  _type: i.type,
@@ -2280,42 +2327,42 @@ const getBlockWithChildren = (o, r) => {
2280
2327
  })
2281
2328
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2282
2329
  const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (h, f) => {
2283
- const x = cloneDeep(f.find((k) => k._id === h));
2284
- for (const k in x) {
2285
- const b = x[k];
2330
+ const x = cloneDeep(f.find((y) => y._id === h));
2331
+ for (const y in x) {
2332
+ const b = x[y];
2286
2333
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2287
- const { baseClasses: S, classes: w } = getSplitChaiClasses(b);
2288
- x[k] = compact(flattenDeep([S, w])).join(" ");
2334
+ const { baseClasses: v, classes: A } = getSplitChaiClasses(b);
2335
+ x[y] = compact(flattenDeep([v, A])).join(" ");
2289
2336
  } else
2290
- k !== "_id" && delete x[k];
2337
+ y !== "_id" && delete x[y];
2291
2338
  }
2292
2339
  return x;
2293
2340
  };
2294
2341
  return {
2295
2342
  askAi: useCallback(
2296
- async (h, f, x, k) => {
2343
+ async (h, f, x, y) => {
2297
2344
  if (l) {
2298
2345
  r(!0), a(null);
2299
2346
  try {
2300
- const b = p === u ? "" : p, S = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], w = await l(h, addLangToPrompt(x, g, h), S, b), { blocks: B, error: _ } = w;
2301
- if (_) {
2302
- a(_);
2347
+ const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [m(f, d)], A = await l(h, addLangToPrompt(x, g, h), v, b), { blocks: w, error: E } = A;
2348
+ if (E) {
2349
+ a(E);
2303
2350
  return;
2304
2351
  }
2305
2352
  if (h === "styles") {
2306
- const E = B.map((v) => {
2307
- for (const A in v)
2308
- A !== "_id" && (v[A] = `${STYLES_KEY},${v[A]}`);
2309
- return v;
2353
+ const _ = w.map((S) => {
2354
+ for (const B in S)
2355
+ B !== "_id" && (S[B] = `${STYLES_KEY},${S[B]}`);
2356
+ return S;
2310
2357
  });
2311
- c(E);
2358
+ c(_);
2312
2359
  } else
2313
- i(B);
2314
- k && k(w);
2360
+ i(w);
2361
+ y && y(A);
2315
2362
  } catch (b) {
2316
2363
  a(b);
2317
2364
  } finally {
2318
- r(!1), k && k();
2365
+ r(!1), y && y();
2319
2366
  }
2320
2367
  }
2321
2368
  },
@@ -2382,9 +2429,9 @@ const getBlockWithChildren = (o, r) => {
2382
2429
  d();
2383
2430
  }, []), { data: l, isLoading: o, refetch: d, error: n };
2384
2431
  }, useBuilderReset = () => {
2385
- const { clear: o } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: n } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage();
2432
+ const { clear: o } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: n } = useBlockHighlight(), [, a] = useSelectedStylingBlocks(), [, l] = useAtom$1(aiAssistantActiveAtom), { reset: i } = usePartialBlocksStore(), { setSaveState: c } = useSavePage(), [, d] = useBlockRepeaterDataAtom();
2386
2433
  return () => {
2387
- r([]), a([]), n(), o(), l(!1), i(), c("SAVED");
2434
+ d({}), r([]), a([]), n(), o(), l(!1), i(), c("SAVED");
2388
2435
  };
2389
2436
  }, canvasZoomAtom = atomWithStorage("canvasZoom", 100), useCanvasZoom = () => useAtom$1(canvasZoomAtom), codeEditorAtom = atom(null), useCodeEditor = () => useAtom$1(codeEditorAtom), cutBlockIdsAtom = atom([]), useCutBlockIds = () => {
2390
2437
  const [o, r] = useAtom$1(cutBlockIdsAtom), n = useSetAtom$1(copiedBlockIdsAtom), a = useCallback(
@@ -2411,7 +2458,7 @@ const getBlockWithChildren = (o, r) => {
2411
2458
  for (const f of m)
2412
2459
  if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2413
2460
  let x = l(f.partialBlockId);
2414
- f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((k) => (isEmpty(k._parent) && set(k, "_parent", f._parent), k))), h = [...h, ...x];
2461
+ f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), h = [...h, ...x];
2415
2462
  } else
2416
2463
  h.push(f);
2417
2464
  return h;
@@ -2714,8 +2761,8 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2714
2761
  return useHotkeys(
2715
2762
  "shift+up, shift+down, shift+left, shift+right",
2716
2763
  ({ key: x }) => {
2717
- var k;
2718
- f((k = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2764
+ var y;
2765
+ f((y = x == null ? void 0 : x.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2719
2766
  },
2720
2767
  { document: a == null ? void 0 : a.contentDocument },
2721
2768
  [f]
@@ -2738,79 +2785,6 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2738
2785
  );
2739
2786
  }) });
2740
2787
  };
2741
- class Content extends Component {
2742
- componentDidMount() {
2743
- this.props.contentDidMount();
2744
- }
2745
- componentDidUpdate() {
2746
- this.props.contentDidUpdate();
2747
- }
2748
- render() {
2749
- return Children.only(this.props.children);
2750
- }
2751
- }
2752
- class Frame extends Component {
2753
- constructor(n, a) {
2754
- super(n, a);
2755
- H(this, "setRef", (n) => {
2756
- this.nodeRef.current = n;
2757
- const { forwardedRef: a } = this.props;
2758
- typeof a == "function" ? a(n) : a && (a.current = n);
2759
- });
2760
- H(this, "handleLoad", () => {
2761
- clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
2762
- });
2763
- // In certain situations on a cold cache DOMContentLoaded never gets called
2764
- // fallback to an interval to check if that's the case
2765
- H(this, "loadCheck", () => setInterval(() => {
2766
- this.handleLoad();
2767
- }, 500));
2768
- this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
2769
- }
2770
- componentDidMount() {
2771
- this._isMounted = !0, this.getDoc() && this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded", this.handleLoad);
2772
- }
2773
- componentWillUnmount() {
2774
- this._isMounted = !1, this.nodeRef.current.removeEventListener("DOMContentLoaded", this.handleLoad);
2775
- }
2776
- getDoc() {
2777
- return this.nodeRef.current ? this.nodeRef.current.contentDocument : null;
2778
- }
2779
- getMountTarget() {
2780
- const n = this.getDoc();
2781
- return this.props.mountTarget ? n.querySelector(this.props.mountTarget) : n.body.children[0];
2782
- }
2783
- renderFrameContents() {
2784
- if (!this._isMounted)
2785
- return null;
2786
- const n = this.getDoc();
2787
- if (!n)
2788
- return null;
2789
- const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = n.defaultView || n.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: n, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), d = this.getMountTarget();
2790
- return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, d)];
2791
- }
2792
- render() {
2793
- const n = {
2794
- ...this.props,
2795
- srcDoc: this.props.initialContent,
2796
- children: void 0
2797
- // The iframe isn't ready so we drop children from props here. #12, #17
2798
- };
2799
- return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
2800
- }
2801
- }
2802
- H(Frame, "defaultProps", {
2803
- style: {},
2804
- head: null,
2805
- children: void 0,
2806
- mountTarget: void 0,
2807
- contentDidMount: () => {
2808
- },
2809
- contentDidUpdate: () => {
2810
- },
2811
- initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
2812
- });
2813
- const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r }));
2814
2788
  function getTargetedBlock(o) {
2815
2789
  if (o.getAttribute("data-block-id") === "canvas")
2816
2790
  return null;
@@ -2819,27 +2793,47 @@ function getTargetedBlock(o) {
2819
2793
  const r = o.closest("[data-block-id]");
2820
2794
  return (r == null ? void 0 : r.getAttribute("data-block-id")) === "canvas" ? null : r;
2821
2795
  }
2822
- const useHandleCanvasClick = () => {
2823
- const [, o] = useSelectedStylingBlocks(), [r, n] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
2796
+ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"], isRichTextParent = (o) => {
2797
+ var r;
2798
+ return (o == null ? void 0 : o.getAttribute("data-block-type")) === "RichText" || ((r = o == null ? void 0 : o.parentElement) == null ? void 0 : r.getAttribute("data-block-type")) === "RichText";
2799
+ }, isInlineEditable = (o, r) => {
2800
+ if (isRichTextParent(o))
2801
+ return !0;
2802
+ const n = o == null ? void 0 : o.getAttribute("data-block-type");
2803
+ return !n || o && o.children.length > 0 || n === "Button" ? !1 : INLINE_EDITABLE_BLOCKS.includes(n);
2804
+ }, useHandleCanvasDblClick = () => {
2805
+ const [o, r] = useAtom$1(inlineEditingActiveAtom);
2806
+ return useCallback(
2807
+ (n) => {
2808
+ if (n == null || n.preventDefault(), n == null || n.stopPropagation(), o) return;
2809
+ const a = getTargetedBlock(n.target);
2810
+ if (!isInlineEditable(a)) return;
2811
+ const l = a.getAttribute("data-block-id");
2812
+ l && r(l);
2813
+ },
2814
+ [o, r]
2815
+ );
2816
+ }, useHandleCanvasClick = () => {
2817
+ const [o] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: r } = useBlockHighlight(), n = useRef(0);
2824
2818
  return useCallback(
2825
- (c) => {
2826
- if (a) return;
2827
- c.stopPropagation();
2828
- const d = getTargetedBlock(c.target);
2829
- if (d != null && d.getAttribute("data-block-id") && (d == null ? void 0 : d.getAttribute("data-block-id")) === "container") {
2830
- n([]), o([]), i();
2819
+ (a) => {
2820
+ const l = (/* @__PURE__ */ new Date()).getTime();
2821
+ if (o || (a.stopPropagation(), l - n.current < 400)) return;
2822
+ const c = getTargetedBlock(a.target);
2823
+ if (c != null && c.getAttribute("data-block-id") && (c == null ? void 0 : c.getAttribute("data-block-id")) === "container") {
2824
+ pubsub.publish(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION);
2831
2825
  return;
2832
2826
  }
2833
- if (d != null && d.getAttribute("data-block-parent")) {
2834
- const p = d.getAttribute("data-style-prop"), u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
2835
- r.includes(g) || l == null || l.closeAll(), o([{ id: u, prop: p, blockId: g }]), n([g]);
2836
- } else if (d != null && d.getAttribute("data-block-id")) {
2837
- const p = d.getAttribute("data-block-id");
2838
- r.includes(p) || l == null || l.closeAll(), o([]), n(p === "canvas" ? [] : [p]);
2827
+ if (c != null && c.getAttribute("data-block-parent")) {
2828
+ const d = c.getAttribute("data-style-prop"), p = c.getAttribute("data-style-id"), u = c.getAttribute("data-block-parent");
2829
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, { blockId: u, styleId: p, styleProp: d });
2830
+ } else if (c != null && c.getAttribute("data-block-id")) {
2831
+ const d = c.getAttribute("data-block-id");
2832
+ pubsub.publish(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, { blockId: d === "canvas" ? [] : [d] });
2839
2833
  }
2840
- i();
2834
+ r(), n.current = (/* @__PURE__ */ new Date()).getTime();
2841
2835
  },
2842
- [r, l, n, o]
2836
+ [o]
2843
2837
  );
2844
2838
  }, useHandleMouseMove = () => {
2845
2839
  const [o] = useAtom$1(inlineEditingActiveAtom), { highlightBlock: r } = useBlockHighlight();
@@ -2850,37 +2844,22 @@ const useHandleCanvasClick = () => {
2850
2844
  a && r(a);
2851
2845
  },
2852
2846
  [o, r],
2853
- 20
2847
+ 100
2854
2848
  );
2855
2849
  }, useHandleMouseLeave = () => {
2856
2850
  const { clearHighlight: o } = useBlockHighlight();
2857
2851
  return useCallback(() => o(), [o]);
2858
- }, StylingBlockSelectWatcher = () => {
2859
- const [o, r] = useSelectedStylingBlocks(), { document: n } = useFrame(), { clearHighlight: a } = useBlockHighlight(), [l] = useSelectedBlockIds();
2860
- return useEffect(() => {
2861
- setTimeout(() => {
2862
- if (!isEmpty(o))
2863
- return;
2864
- const i = getElementByDataBlockId(n, first(l));
2865
- if (i) {
2866
- const c = i.getAttribute("data-style-prop");
2867
- if (c) {
2868
- const d = i.getAttribute("data-style-id"), p = i.getAttribute("data-block-parent");
2869
- r([{ id: d, prop: c, blockId: p }]);
2870
- }
2871
- }
2872
- }, 100);
2873
- }, [n, l, r, o]), useEffect(() => () => a(), [a]), null;
2874
2852
  }, Canvas = ({ children: o }) => {
2875
- const r = useHandleCanvasClick(), n = useHandleMouseMove(), a = useHandleMouseLeave();
2853
+ const r = useHandleCanvasDblClick(), n = useHandleCanvasClick(), a = useHandleMouseMove(), l = useHandleMouseLeave();
2876
2854
  return /* @__PURE__ */ jsx(
2877
2855
  "div",
2878
2856
  {
2879
2857
  "data-block-id": "canvas",
2880
2858
  id: "canvas",
2881
- onClick: r,
2882
- onMouseMove: n,
2883
- onMouseLeave: a,
2859
+ onClick: n,
2860
+ onDoubleClick: r,
2861
+ onMouseMove: a,
2862
+ onMouseLeave: l,
2884
2863
  className: "relative h-full max-w-full p-px",
2885
2864
  children: o
2886
2865
  }
@@ -2936,13 +2915,13 @@ const useHandleCanvasClick = () => {
2936
2915
  tabIndex: 0,
2937
2916
  ref: m.setFloating,
2938
2917
  style: g,
2939
- onClick: (k) => {
2940
- k.stopPropagation(), k.preventDefault();
2918
+ onClick: (y) => {
2919
+ y.stopPropagation(), y.preventDefault();
2941
2920
  },
2942
- onMouseEnter: (k) => {
2943
- k.stopPropagation(), i(null);
2921
+ onMouseEnter: (y) => {
2922
+ y.stopPropagation(), i(null);
2944
2923
  },
2945
- onKeyDown: (k) => k.stopPropagation(),
2924
+ onKeyDown: (y) => y.stopPropagation(),
2946
2925
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
2947
2926
  children: [
2948
2927
  f && /* @__PURE__ */ jsx(
@@ -3008,18 +2987,90 @@ const useHandleCanvasClick = () => {
3008
2987
  [force-show] { display: block !important; }
3009
2988
  [data-cut-block="yes"] { pointer-events: none !important; display: none !important; }
3010
2989
  </style>
3011
- <style id="hidden-blocks"></style>
3012
- <style id="selected-styling-block"></style>
3013
- <style id="highlighted-block"></style>
3014
- <style id="dragged-block"></style>
3015
- <style id="drop-target-block"></style>
3016
- <style id="selected-block"></style>
2990
+ <style id="highlighted-block">
2991
+ [data-highlighted]{
2992
+ outline: 1px solid #42a1fc !important; outline-offset: -1px;
2993
+ }
2994
+ </style>
3017
2995
 
3018
2996
  </head>
3019
2997
  <body class="font-body antialiased h-full">
3020
2998
  <div class="frame-root h-full"></div>
3021
2999
  </body>
3022
- </html>`, useKeyEventWatcher = (o) => {
3000
+ </html>`;
3001
+ class Content extends Component {
3002
+ componentDidMount() {
3003
+ this.props.contentDidMount();
3004
+ }
3005
+ componentDidUpdate() {
3006
+ this.props.contentDidUpdate();
3007
+ }
3008
+ render() {
3009
+ return Children.only(this.props.children);
3010
+ }
3011
+ }
3012
+ class Frame extends Component {
3013
+ constructor(n, a) {
3014
+ super(n, a);
3015
+ H(this, "setRef", (n) => {
3016
+ this.nodeRef.current = n;
3017
+ const { forwardedRef: a } = this.props;
3018
+ typeof a == "function" ? a(n) : a && (a.current = n);
3019
+ });
3020
+ H(this, "handleLoad", () => {
3021
+ clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3022
+ });
3023
+ // In certain situations on a cold cache DOMContentLoaded never gets called
3024
+ // fallback to an interval to check if that's the case
3025
+ H(this, "loadCheck", () => setInterval(() => {
3026
+ this.handleLoad();
3027
+ }, 500));
3028
+ this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
3029
+ }
3030
+ componentDidMount() {
3031
+ this._isMounted = !0, this.getDoc() && this.nodeRef.current.contentWindow.addEventListener("DOMContentLoaded", this.handleLoad);
3032
+ }
3033
+ componentWillUnmount() {
3034
+ this._isMounted = !1, this.nodeRef.current.removeEventListener("DOMContentLoaded", this.handleLoad);
3035
+ }
3036
+ getDoc() {
3037
+ return this.nodeRef.current ? this.nodeRef.current.contentDocument : null;
3038
+ }
3039
+ getMountTarget() {
3040
+ const n = this.getDoc();
3041
+ return this.props.mountTarget ? n.querySelector(this.props.mountTarget) : n.body.children[0];
3042
+ }
3043
+ renderFrameContents() {
3044
+ if (!this._isMounted)
3045
+ return null;
3046
+ const n = this.getDoc();
3047
+ if (!n)
3048
+ return null;
3049
+ const a = this.props.contentDidMount, l = this.props.contentDidUpdate, i = n.defaultView || n.parentView, c = /* @__PURE__ */ jsx(Content, { contentDidMount: a, contentDidUpdate: l, children: /* @__PURE__ */ jsx(FrameContextProvider, { value: { document: n, window: i }, children: /* @__PURE__ */ jsx("div", { className: "frame-content", children: this.props.children }) }) }), d = this.getMountTarget();
3050
+ return [ReactDOM.createPortal(this.props.head, this.getDoc().head), ReactDOM.createPortal(c, d)];
3051
+ }
3052
+ render() {
3053
+ const n = {
3054
+ ...this.props,
3055
+ srcDoc: this.props.initialContent,
3056
+ children: void 0
3057
+ // The iframe isn't ready so we drop children from props here. #12, #17
3058
+ };
3059
+ return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
3060
+ }
3061
+ }
3062
+ H(Frame, "defaultProps", {
3063
+ style: {},
3064
+ head: null,
3065
+ children: void 0,
3066
+ mountTarget: void 0,
3067
+ contentDidMount: () => {
3068
+ },
3069
+ contentDidUpdate: () => {
3070
+ },
3071
+ initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
3072
+ });
3073
+ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r })), useKeyEventWatcher = (o) => {
3023
3074
  const [r, n] = 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 } : {};
3024
3075
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
3025
3076
  "ctrl+v,command+v",
@@ -3065,19 +3116,11 @@ const useHandleCanvasClick = () => {
3065
3116
  const r = useMemo(() => getChaiThemeCssVariables(o), [o]);
3066
3117
  return /* @__PURE__ */ jsx("style", { id: "chai-theme", children: r });
3067
3118
  }, HeadTags = () => {
3068
- const [o] = useTheme(), r = useThemeOptions(), [n] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3069
- d == null ? void 0 : d.getElementById("selected-block")
3070
- ), [m] = useState(
3071
- d == null ? void 0 : d.getElementById("selected-styling-block")
3072
- ), [h] = useState(
3073
- d == null ? void 0 : d.getElementById("dragged-block")
3074
- );
3075
- useEffect(() => {
3076
- a ? d == null || d.documentElement.classList.add("dark") : d == null || d.documentElement.classList.remove("dark");
3077
- }, [a, d]);
3078
- const f = useRegisteredFonts();
3079
- useEffect(() => {
3080
- !p || !p.tailwind || (p.tailwind.config = {
3119
+ const [o] = useTheme(), r = useThemeOptions(), [n] = useDarkMode(), { document: a, window: l } = useFrame();
3120
+ return useEffect(() => {
3121
+ n ? a == null || a.documentElement.classList.add("dark") : a == null || a.documentElement.classList.remove("dark");
3122
+ }, [n, a]), useEffect(() => {
3123
+ !l || !l.tailwind || (l.tailwind.config = {
3081
3124
  darkMode: "class",
3082
3125
  theme: {
3083
3126
  extend: {
@@ -3096,49 +3139,50 @@ const useHandleCanvasClick = () => {
3096
3139
  tailwindForms,
3097
3140
  tailwindAspectRatio,
3098
3141
  twContainer,
3099
- plugin(function({ addBase: S, theme: w }) {
3100
- S({
3142
+ plugin(function({ addBase: i, theme: c }) {
3143
+ i({
3101
3144
  "h1,h2,h3,h4,h5,h6": {
3102
- fontFamily: w("fontFamily.heading")
3145
+ fontFamily: c("fontFamily.heading")
3103
3146
  },
3104
3147
  body: {
3105
- fontFamily: w("fontFamily.body"),
3106
- color: w("colors.foreground"),
3107
- backgroundColor: w("colors.background")
3148
+ fontFamily: c("fontFamily.body"),
3149
+ color: c("colors.foreground"),
3150
+ backgroundColor: c("colors.background")
3108
3151
  }
3109
3152
  });
3110
3153
  })
3111
3154
  ]
3112
3155
  });
3113
- }, [o, r, p]), useEffect(() => {
3114
- g && (g.textContent = `${map(n, (S) => `[data-block-id="${S}"]`).join(",")}{
3115
- outline: 1px solid ${n.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3116
- }`);
3117
- }, [n, g]), useEffect(() => {
3118
- h.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3119
- }, [i, h]), useEffect(() => {
3120
- u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3121
- }, [u]), useEffect(() => {
3122
- m && (m.textContent = `${map(l, ({ id: S }) => `[data-style-id="${S}"]`).join(",")}{
3123
- outline: 1px solid orange !important; outline-offset: -1px;
3124
- }`);
3125
- }, [l, m]), useEffect(() => {
3126
- d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3127
- }, [c, d]);
3128
- const x = useMemo(() => {
3129
- const { heading: S, body: w } = {
3156
+ }, [o, r, l]), /* @__PURE__ */ jsxs(Fragment, { children: [
3157
+ /* @__PURE__ */ jsx(CssThemeVariables, { theme: o }),
3158
+ /* @__PURE__ */ jsx(Fonts, {}),
3159
+ /* @__PURE__ */ jsx(SelectedBlocks, {}),
3160
+ /* @__PURE__ */ jsx(SelectedStylingBlocks, {})
3161
+ ] });
3162
+ }, SelectedStylingBlocks = () => {
3163
+ const [o] = useSelectedStylingBlocks(), [r] = useSelectedBlockIds(), n = useMemo(() => `${map(o, ({ id: a }) => `[data-style-id="${a}"]`).join(",")}{
3164
+ outline: 1px solid ${r.length > 0 ? "#42a1fc" : "#de8f09"} !important; outline-offset: -1px;
3165
+ }`, [o, r]);
3166
+ return /* @__PURE__ */ jsx("style", { id: "selected-styling-blocks", dangerouslySetInnerHTML: { __html: n } });
3167
+ }, SelectedBlocks = () => {
3168
+ const [o] = useSelectedBlockIds(), r = useMemo(() => `${map(o, (n) => `[data-block-id="${n}"]`).join(",")}{
3169
+ outline: 1px solid #42a1fc !important; outline-offset: -1px;
3170
+ }`, [o]);
3171
+ return /* @__PURE__ */ jsx("style", { id: "selected-blocks", dangerouslySetInnerHTML: { __html: r } });
3172
+ }, Fonts = () => {
3173
+ const [o] = useTheme(), r = useRegisteredFonts(), n = useMemo(() => {
3174
+ const { heading: i, body: c } = {
3130
3175
  heading: get(o, "fontFamily.heading"),
3131
3176
  body: get(o, "fontFamily.body")
3132
3177
  };
3133
- return f.filter((B) => B.family === S || B.family === w);
3134
- }, [o == null ? void 0 : o.fontFamily, f]), k = useMemo(() => getThemeFontsLinkMarkup(filter(x, (S) => has(S, "url"))), [x]), b = useMemo(
3135
- () => getThemeCustomFontFace(filter(x, (S) => has(S, "src"))),
3136
- [x]
3178
+ return r.filter((d) => d.family === i || d.family === c);
3179
+ }, [o == null ? void 0 : o.fontFamily, r]), a = useMemo(() => getThemeFontsUrls(filter(n, (i) => has(i, "url"))), [n]), l = useMemo(
3180
+ () => getThemeCustomFontFace(filter(n, (i) => has(i, "src"))),
3181
+ [n]
3137
3182
  );
3138
3183
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3139
- /* @__PURE__ */ jsx(CssThemeVariables, { theme: o }),
3140
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: k } }),
3141
- /* @__PURE__ */ jsx("style", { id: "chai-custom-fonts", dangerouslySetInnerHTML: { __html: b } })
3184
+ a.map((i, c) => /* @__PURE__ */ jsx("link", { rel: "stylesheet", href: i }, `google-font-${c}`)),
3185
+ /* @__PURE__ */ jsx("style", { id: "chai-custom-fonts", dangerouslySetInnerHTML: { __html: l } })
3142
3186
  ] });
3143
3187
  }, ResizableCanvasWrapper = ({ children: o, onMount: r, onResize: n }) => {
3144
3188
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3157,6 +3201,12 @@ const useHandleCanvasClick = () => {
3157
3201
  a([]), l([]);
3158
3202
  }, [a, l]);
3159
3203
  return /* @__PURE__ */ jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
3204
+ }, MayBeAsyncPropsWrapper = ({ children: o, block: r }) => {
3205
+ const n = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), a = has(n, "asyncProps"), l = useAsyncProps(
3206
+ a ? r : void 0,
3207
+ get(n, "asyncProps", [])
3208
+ );
3209
+ return o(l);
3160
3210
  }, ErrorFallback = () => /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500", children: "Something went wrong." }), useBlockRuntimeProps = () => {
3161
3211
  const [o] = useBlocksStore();
3162
3212
  return useCallback(
@@ -3170,7 +3220,325 @@ const useHandleCanvasClick = () => {
3170
3220
  }, {}),
3171
3221
  [o]
3172
3222
  );
3173
- }, RepeaterContext = createContext({
3223
+ }, BUBBLE_MENU_ICONS = {
3224
+ bold: FontBoldIcon,
3225
+ italic: FontItalicIcon,
3226
+ underline: UnderlineIcon,
3227
+ strikethrough: StrikethroughIcon,
3228
+ code: CodeIcon,
3229
+ link: Link1Icon,
3230
+ bulletList: ListBulletIcon,
3231
+ orderedList: ListBulletIcon,
3232
+ heading1: HeadingIcon,
3233
+ heading2: HeadingIcon,
3234
+ heading3: HeadingIcon,
3235
+ quote: QuoteIcon,
3236
+ alignLeft: TextAlignLeftIcon,
3237
+ alignCenter: TextAlignCenterIcon,
3238
+ alignRight: TextAlignRightIcon
3239
+ }, BubbleMenuButton = ({ icon: o, title: r, onClick: n, isActive: a }) => {
3240
+ const l = BUBBLE_MENU_ICONS[o];
3241
+ return /* @__PURE__ */ jsx(
3242
+ "button",
3243
+ {
3244
+ onClick: n,
3245
+ className: cn$1("rounded-md p-1.5 transition-colors duration-200", a ? "bg-white/20" : "hover:bg-white/10"),
3246
+ title: r,
3247
+ children: /* @__PURE__ */ jsx(l, { className: "h-4 w-4" })
3248
+ }
3249
+ );
3250
+ }, BubbleMenu = ({ editor: o }) => {
3251
+ if (!o) return null;
3252
+ const r = () => {
3253
+ const n = window.prompt("Enter URL");
3254
+ n && o.chain().focus().setLink({ href: n }).run();
3255
+ };
3256
+ return /* @__PURE__ */ jsx("div", { className: "flex items-center overflow-hidden rounded-lg border border-blue-500/20 bg-blue-600 text-white shadow-lg", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center p-1", children: [
3257
+ /* @__PURE__ */ jsx(
3258
+ BubbleMenuButton,
3259
+ {
3260
+ icon: "bold",
3261
+ title: "Bold",
3262
+ onClick: () => o.chain().focus().toggleBold().run(),
3263
+ isActive: o.isActive("bold")
3264
+ }
3265
+ ),
3266
+ /* @__PURE__ */ jsx(
3267
+ BubbleMenuButton,
3268
+ {
3269
+ icon: "italic",
3270
+ title: "Italic",
3271
+ onClick: () => o.chain().focus().toggleItalic().run(),
3272
+ isActive: o.isActive("italic")
3273
+ }
3274
+ ),
3275
+ /* @__PURE__ */ jsx(
3276
+ BubbleMenuButton,
3277
+ {
3278
+ icon: "underline",
3279
+ title: "Underline",
3280
+ onClick: () => o.chain().focus().toggleUnderline().run(),
3281
+ isActive: o.isActive("underline")
3282
+ }
3283
+ ),
3284
+ /* @__PURE__ */ jsx(
3285
+ BubbleMenuButton,
3286
+ {
3287
+ icon: "strikethrough",
3288
+ title: "Strikethrough",
3289
+ onClick: () => o.chain().focus().toggleStrike().run(),
3290
+ isActive: o.isActive("strike")
3291
+ }
3292
+ ),
3293
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-4 w-[1px] bg-white/20" }),
3294
+ /* @__PURE__ */ jsx(
3295
+ BubbleMenuButton,
3296
+ {
3297
+ icon: "link",
3298
+ title: o.isActive("link") ? "Remove link" : "Add link",
3299
+ onClick: () => {
3300
+ o.isActive("link") ? o.chain().focus().unsetLink().run() : r();
3301
+ },
3302
+ isActive: o.isActive("link")
3303
+ }
3304
+ ),
3305
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-4 w-[1px] bg-white/20" }),
3306
+ /* @__PURE__ */ jsx(
3307
+ BubbleMenuButton,
3308
+ {
3309
+ icon: "bulletList",
3310
+ title: "Bullet list",
3311
+ onClick: () => o.chain().focus().toggleBulletList().run(),
3312
+ isActive: o.isActive("bulletList")
3313
+ }
3314
+ ),
3315
+ /* @__PURE__ */ jsx(
3316
+ BubbleMenuButton,
3317
+ {
3318
+ icon: "orderedList",
3319
+ title: "Numbered list",
3320
+ onClick: () => o.chain().focus().toggleOrderedList().run(),
3321
+ isActive: o.isActive("orderedList")
3322
+ }
3323
+ ),
3324
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-4 w-[1px] bg-white/20" }),
3325
+ /* @__PURE__ */ jsx(
3326
+ BubbleMenuButton,
3327
+ {
3328
+ icon: "alignLeft",
3329
+ title: "Align left",
3330
+ onClick: () => o.chain().focus().setTextAlign("left").run(),
3331
+ isActive: o.isActive({ textAlign: "left" })
3332
+ }
3333
+ ),
3334
+ /* @__PURE__ */ jsx(
3335
+ BubbleMenuButton,
3336
+ {
3337
+ icon: "alignCenter",
3338
+ title: "Align center",
3339
+ onClick: () => o.chain().focus().setTextAlign("center").run(),
3340
+ isActive: o.isActive({ textAlign: "center" })
3341
+ }
3342
+ ),
3343
+ /* @__PURE__ */ jsx(
3344
+ BubbleMenuButton,
3345
+ {
3346
+ icon: "alignRight",
3347
+ title: "Align right",
3348
+ onClick: () => o.chain().focus().setTextAlign("right").run(),
3349
+ isActive: o.isActive({ textAlign: "right" })
3350
+ }
3351
+ )
3352
+ ] }) });
3353
+ }, RichTextEditor = memo(
3354
+ ({
3355
+ blockContent: o,
3356
+ editingElement: r,
3357
+ onClose: n,
3358
+ onChange: a,
3359
+ onEscape: l
3360
+ }) => {
3361
+ const { document: i } = useFrame(), c = useEditor(
3362
+ {
3363
+ editable: !0,
3364
+ content: o,
3365
+ extensions: [
3366
+ StarterKit,
3367
+ Underline,
3368
+ TextAlign.configure({
3369
+ types: ["heading", "paragraph"]
3370
+ }),
3371
+ Link.configure({
3372
+ openOnClick: !1,
3373
+ HTMLAttributes: {
3374
+ class: "text-blue-500 hover:text-blue-600 underline"
3375
+ }
3376
+ }),
3377
+ Placeholder.configure({
3378
+ placeholder: "Enter text here",
3379
+ emptyEditorClass: "cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"
3380
+ })
3381
+ ],
3382
+ onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3383
+ onBlur: ({ editor: u, event: g }) => {
3384
+ const m = g.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = h == null ? void 0 : h.contains(m), y = f == null ? void 0 : f.contains(m);
3385
+ if (!x && !y) {
3386
+ const b = (u == null ? void 0 : u.getHTML()) || "";
3387
+ n(b);
3388
+ }
3389
+ }
3390
+ },
3391
+ []
3392
+ );
3393
+ useEffect(() => {
3394
+ var u;
3395
+ (u = c == null ? void 0 : c.commands) == null || u.focus(), c == null || c.emit("focus", {
3396
+ editor: c,
3397
+ event: new FocusEvent("focus"),
3398
+ transaction: []
3399
+ });
3400
+ }, [c]);
3401
+ const d = useMemo(() => {
3402
+ var m;
3403
+ const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
3404
+ if (!r) return u;
3405
+ const g = ((m = r == null ? void 0 : r.className) == null ? void 0 : m.replace("sr-only", "")) || "";
3406
+ return `${u} ${g}`;
3407
+ }, [r]), p = useCallback(
3408
+ (u) => {
3409
+ u.key === "Escape" && l(u);
3410
+ },
3411
+ [l]
3412
+ );
3413
+ return /* @__PURE__ */ jsxs("div", { onKeyDown: p, onClick: (u) => u.stopPropagation(), children: [
3414
+ c && /* @__PURE__ */ jsx(
3415
+ BubbleMenu$1,
3416
+ {
3417
+ editor: c,
3418
+ tippyOptions: {
3419
+ duration: 100
3420
+ },
3421
+ children: /* @__PURE__ */ jsx(BubbleMenu, { editor: c })
3422
+ }
3423
+ ),
3424
+ /* @__PURE__ */ jsx(EditorContent, { editor: c, className: d })
3425
+ ] });
3426
+ }
3427
+ ), MemoizedEditor = memo(
3428
+ ({
3429
+ editingElement: o,
3430
+ blockContent: r,
3431
+ onClose: n,
3432
+ editorRef: a,
3433
+ onChange: l,
3434
+ onEscape: i
3435
+ }) => {
3436
+ const { document: c, window: d } = useFrame();
3437
+ useEffect(() => {
3438
+ if (a.current) {
3439
+ a.current.innerText = r, a.current.focus();
3440
+ const h = c.createRange(), f = d.getSelection();
3441
+ h.selectNodeContents(a.current), h.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(h), a.current.focus();
3442
+ } else
3443
+ n();
3444
+ }, [c, d]);
3445
+ const p = useMemo(() => {
3446
+ var f;
3447
+ const h = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
3448
+ return h === "button" ? "div" : h;
3449
+ }, [o]), u = useCallback(
3450
+ (h) => {
3451
+ (h.key === "Enter" || h.key === "Escape") && i(h);
3452
+ },
3453
+ [i]
3454
+ ), g = useCallback(() => {
3455
+ n();
3456
+ }, [n]), m = useMemo(() => {
3457
+ var h;
3458
+ return {
3459
+ id: "active-inline-editing-element",
3460
+ contentEditable: !0,
3461
+ 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]`,
3462
+ style: cloneDeep(o == null ? void 0 : o.style) || {},
3463
+ onInput: (f) => {
3464
+ const x = f.target;
3465
+ x && (x.innerText.trim() === "" ? (x.setAttribute("data-placeholder", "Enter text here"), x.children.length > 0 && x.children[0].remove()) : f.target.removeAttribute("data-placeholder"), l(f.target.innerText));
3466
+ },
3467
+ onClick: (f) => {
3468
+ f.stopPropagation(), f.preventDefault();
3469
+ }
3470
+ };
3471
+ }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
3472
+ return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
3473
+ ref: a,
3474
+ onBlur: g,
3475
+ onKeyDown: u,
3476
+ ...m
3477
+ }) });
3478
+ }
3479
+ ), WithBlockTextEditor = memo(
3480
+ ({ block: o, children: r }) => {
3481
+ const n = "content", { document: a } = useFrame(), [l, i] = useAtom$1(inlineEditingActiveAtom), [c, d] = useState(null), p = useRef(null), { clearHighlight: u } = useBlockHighlight(), g = useUpdateBlocksProps(), { selectedLang: m } = useLanguages(), [, h] = useSelectedBlockIds(), f = useRef(null), x = l, { blockContent: y, blockType: b } = useMemo(() => {
3482
+ var C;
3483
+ const _ = o._type;
3484
+ let S = o[n];
3485
+ const B = getRegisteredChaiBlock(o._type);
3486
+ return m && ((C = B == null ? void 0 : B.i18nProps) == null ? void 0 : C.includes(n)) && has(o, `${n}-${m}`) && (S = get(o, `${n}-${m}`)), { blockContent: S, blockType: _ };
3487
+ }, [o, m]), v = useCallback(
3488
+ (_) => {
3489
+ var B;
3490
+ const S = _ || ((B = p.current) == null ? void 0 : B.innerText);
3491
+ g([x], { [n]: S }), d(null), i(null), h([]);
3492
+ },
3493
+ [x, g, i, h, m]
3494
+ ), A = useDebouncedCallback(
3495
+ (_) => {
3496
+ g([x], { [n]: _ });
3497
+ },
3498
+ [x, o, g, m],
3499
+ 1e3
3500
+ ), w = useCallback(
3501
+ (_) => {
3502
+ _.preventDefault(), x && (f.current = x), v(), setTimeout(() => {
3503
+ const S = f.current;
3504
+ f.current = null, h([S]);
3505
+ }, 100);
3506
+ },
3507
+ [h, x, m]
3508
+ );
3509
+ useEffect(() => {
3510
+ var S;
3511
+ if (!x) return;
3512
+ const _ = getElementByDataBlockId(a, x);
3513
+ (S = _ == null ? void 0 : _.classList) == null || S.add("sr-only"), d(_);
3514
+ }, [x, b, a]);
3515
+ const E = useMemo(() => c ? (u(), b === "RichText" ? /* @__PURE__ */ jsx(
3516
+ RichTextEditor,
3517
+ {
3518
+ blockContent: y,
3519
+ editingElement: c,
3520
+ onChange: A,
3521
+ onClose: v,
3522
+ onEscape: w
3523
+ }
3524
+ ) : /* @__PURE__ */ jsx(
3525
+ MemoizedEditor,
3526
+ {
3527
+ editorRef: p,
3528
+ blockContent: y,
3529
+ editingElement: c,
3530
+ onClose: v,
3531
+ onChange: A,
3532
+ onEscape: w
3533
+ }
3534
+ )) : null, [c, x, b, y, v, m]);
3535
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3536
+ E,
3537
+ r
3538
+ ] });
3539
+ },
3540
+ (o, r) => o.block._id === r.block._id && o.block.content === r.block.content
3541
+ ), RepeaterContext = createContext({
3174
3542
  index: -1,
3175
3543
  key: ""
3176
3544
  }), CORE_BLOCKS = [
@@ -3194,63 +3562,56 @@ const useHandleCanvasClick = () => {
3194
3562
  "CustomScript",
3195
3563
  "CustomHTML"
3196
3564
  ], BlockRenderer = ({
3197
- blockAtom: o,
3198
- children: r
3565
+ asyncProps: o,
3566
+ blockAtom: r,
3567
+ children: n
3199
3568
  }) => {
3200
- const [n] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(n._type), [n._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), { index: m, key: h } = useContext(RepeaterContext), f = useMemo(
3201
- () => u ? applyBindingToBlockProps(applyLanguage(n, l, a), d, {
3202
- index: m,
3203
- key: h
3204
- }) : applyLanguage(n, l, a),
3205
- [n, l, a, d, u, m, h]
3206
- ), x = useMemo(() => getBlockTagAttributes(n), [n, getBlockTagAttributes]), k = useMemo(
3207
- () => c(n._id, getBlockRuntimeProps(n._type)),
3208
- [n._id, n._type, c, getBlockRuntimeProps]
3209
- ), b = useMemo(() => !has(a, "dataProvider") || !isFunction(a.dataProvider) ? {} : a.dataProvider({
3210
- block: n,
3211
- draft: !0,
3212
- inBuilder: !0,
3213
- lang: l || i,
3214
- pageProps: {}
3215
- }), [n, l, i, a, d]), S = useMemo(
3569
+ const [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(r), i = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: c, fallbackLang: d } = useLanguages(), p = useBlockRuntimeProps(), u = usePageExternalData(), [g] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), h = get(i, "component", null), { index: f, key: x } = useContext(RepeaterContext), y = useMemo(
3570
+ () => m ? applyBindingToBlockProps(applyLanguage(l, c, i), u, {
3571
+ index: f,
3572
+ key: x
3573
+ }) : applyLanguage(l, c, i),
3574
+ [l, c, i, u, m, f, x]
3575
+ ), b = useMemo(() => getBlockTagAttributes(l), [l, getBlockTagAttributes]), v = useMemo(
3576
+ () => p(l._id, getBlockRuntimeProps(l._type)),
3577
+ [l._id, l._type, p, getBlockRuntimeProps]
3578
+ ), A = useMemo(
3216
3579
  () => ({
3217
- blockProps: {
3218
- "data-block-id": n._id,
3219
- "data-block-type": n._type
3220
- },
3580
+ blockProps: { "data-block-id": l._id, "data-block-type": l._type },
3221
3581
  inBuilder: !0,
3222
- lang: l || i,
3223
- ...f,
3224
- ...x,
3225
- ...k,
3226
- ...b
3582
+ lang: c || d,
3583
+ ...y,
3584
+ ...b,
3585
+ ...v,
3586
+ ...o
3227
3587
  }),
3228
3588
  [
3229
- n._id,
3230
- n._type,
3231
- l,
3232
- i,
3233
- f,
3234
- x,
3235
- k,
3236
- b
3589
+ l._id,
3590
+ l._type,
3591
+ c,
3592
+ d,
3593
+ y,
3594
+ b,
3595
+ v,
3596
+ o
3237
3597
  ]
3238
- ), w = useMemo(() => !CORE_BLOCKS.includes(n._type), [n._type]);
3239
- if (isNull(g) || p.includes(n._id)) return null;
3240
- const B = /* @__PURE__ */ jsx(Suspense, { children: createElement(g, {
3241
- ...S,
3242
- children: r({
3243
- _id: n._id,
3244
- _type: n._type,
3245
- ...isArray(f.repeaterItems) ? {
3246
- repeaterItems: applyLimit(f.repeaterItems, n),
3247
- repeaterItemsBinding: f.repeaterItemsBinding
3598
+ ), w = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]);
3599
+ if (isNull(h) || g.includes(l._id)) return null;
3600
+ let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
3601
+ ...A,
3602
+ children: n({
3603
+ _id: l._id,
3604
+ _type: l._type,
3605
+ ...isArray(y.repeaterItems) ? {
3606
+ repeaterItems: applyLimit(y.repeaterItems, l),
3607
+ $repeaterItemsKey: y.$repeaterItemsKey
3248
3608
  } : {},
3249
- ...n.partialBlockId ? { partialBlockId: n.partialBlockId } : "",
3250
- ...n.globalBlock ? { partialBlockId: n.globalBlock } : ""
3609
+ ...l.partialBlockId ? { partialBlockId: l.partialBlockId } : "",
3610
+ ...l.globalBlock ? { partialBlockId: l.globalBlock } : ""
3251
3611
  })
3252
3612
  }) });
3253
- return w ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: B }) : B;
3613
+ const _ = a === l._id ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: l, children: E }) : E;
3614
+ return w ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: _ }) : _;
3254
3615
  }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3255
3616
  const { getPartailBlocks: r } = usePartialBlocksStore(), n = useMemo(() => r(o), [r, o]), a = useMemo(() => splitAtom(atom(n)), [n]);
3256
3617
  return isEmpty(n) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: n });
@@ -3268,7 +3629,7 @@ const useHandleCanvasClick = () => {
3268
3629
  );
3269
3630
  return map(l, (c) => {
3270
3631
  const d = a(c._id);
3271
- return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: ({ _id: p, _type: u, partialBlockId: g, repeaterItems: m, repeaterItemsBinding: h }) => u === "Repeater" ? isArray(m) && m.map((f, x) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: x, key: h }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${p}-${x}`)) : u === "GlobalBlock" || u === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: g }) }) : i(p) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }, c._id) : null;
3632
+ 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: f }) => g === "Repeater" ? isArray(h) && h.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: m }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3272
3633
  });
3273
3634
  }, PageBlocksRenderer = () => {
3274
3635
  const [o] = useBlocksStore();
@@ -3302,6 +3663,39 @@ const useHandleCanvasClick = () => {
3302
3663
  return useEffect(() => {
3303
3664
  c();
3304
3665
  }, [r, o, n, c]), l;
3666
+ };
3667
+ function usePubSub(o, r) {
3668
+ useEffect(() => {
3669
+ const n = pubsub.subscribe(o, r);
3670
+ return () => n();
3671
+ }, [o, r]);
3672
+ }
3673
+ const CanvasEventsWatcher = () => {
3674
+ const [, o] = useSelectedBlockIds(), [r, n] = useSelectedStylingBlocks(), { document: a } = useFrame(), { clearHighlight: l } = useBlockHighlight(), [i] = useSelectedBlockIds(), [c] = useAtom$1(treeRefAtom);
3675
+ return useEffect(() => {
3676
+ setTimeout(() => {
3677
+ if (!isEmpty(r))
3678
+ return;
3679
+ const d = getElementByDataBlockId(a, first(i));
3680
+ if (d) {
3681
+ const p = d.getAttribute("data-style-prop");
3682
+ if (p) {
3683
+ const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
3684
+ n([{ id: u, prop: p, blockId: g }]);
3685
+ }
3686
+ }
3687
+ }, 100);
3688
+ }, [a, i, n, r]), useEffect(() => () => l(), [l]), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_SELECTED, (d) => {
3689
+ if (!d) return;
3690
+ const { blockId: p } = d;
3691
+ i.includes(p) || c == null || c.closeAll(), o([p]);
3692
+ }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
3693
+ if (!d) return;
3694
+ const { blockId: p, styleId: u, styleProp: g } = d;
3695
+ p && (i.includes(p) || c == null || c.closeAll(), n([{ id: u, prop: g, blockId: p }]), o([p]));
3696
+ }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
3697
+ l(), o([]), n([]);
3698
+ }), null;
3305
3699
  }, StaticCanvas = () => {
3306
3700
  const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = 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(
3307
3701
  (h) => {
@@ -3345,7 +3739,7 @@ const useHandleCanvasClick = () => {
3345
3739
  /* @__PURE__ */ jsx("br", {}),
3346
3740
  /* @__PURE__ */ jsx("br", {})
3347
3741
  ] }),
3348
- /* @__PURE__ */ jsx(StylingBlockSelectWatcher, {})
3742
+ /* @__PURE__ */ jsx(CanvasEventsWatcher, {})
3349
3743
  ] }),
3350
3744
  /* @__PURE__ */ jsx(
3351
3745
  "div",
@@ -3544,22 +3938,18 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3544
3938
  ] })
3545
3939
  ] });
3546
3940
  }, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
3547
- const [a, l] = React.useState([]), [i, c] = React.useState(o), d = (m) => Array.isArray(m) ? "array" : typeof m == "object" && m !== null ? "object" : "value", p = React.useCallback(
3941
+ 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(
3548
3942
  (m) => {
3549
3943
  const h = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
3550
3944
  m.type === "object" ? (l((f) => [...f, m.key]), c(m.value)) : h(m.type) && r([...a, m.key].join("."), n);
3551
3945
  },
3552
3946
  [a, r, n]
3553
- ), u = React.useCallback(() => {
3947
+ ), u = React__default.useCallback(() => {
3554
3948
  if (a.length > 0) {
3555
3949
  const m = a.slice(0, -1);
3556
3950
  l(m), c(m.reduce((h, f) => h[f], o));
3557
3951
  }
3558
- }, [a, o]), g = React.useMemo(() => i ? Object.entries(i).map(([m, h]) => ({
3559
- key: m,
3560
- value: h,
3561
- type: d(h)
3562
- })).filter((m) => n === "value" ? m.type === "value" || m.type === "object" : n === "array" ? m.type === "array" || m.type === "object" : n === "object" ? m.type === "object" : !0) : [], [i, n]);
3952
+ }, [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 : n === "value" ? m.type === "value" || m.type === "object" : n === "array" ? m.type === "array" || m.type === "object" : n === "object" ? m.type === "object" : !0) : [], [i, n]);
3563
3953
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
3564
3954
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
3565
3955
  /* @__PURE__ */ jsxs(CommandList, { children: [
@@ -3578,8 +3968,8 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3578
3968
  className: "flex items-center justify-between",
3579
3969
  children: [
3580
3970
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
3581
- startsWith(m.key, "#") ? /* @__PURE__ */ jsx(LoopIcon, {}) : null,
3582
- startsWith(m.key, "#") ? "Repeater Data" : m.key
3971
+ startsWith(m.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(m.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
3972
+ startsWith(m.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(m.key, COLLECTION_PREFIX) ? m.key.replace(COLLECTION_PREFIX, "") : m.key
3583
3973
  ] }),
3584
3974
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3585
3975
  n === "object" && m.type === "object" && /* @__PURE__ */ jsx(
@@ -3605,7 +3995,7 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3605
3995
  ] });
3606
3996
  };
3607
3997
  function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3608
- const [a, l] = React.useState(!1);
3998
+ const [a, l] = React__default.useState(!1), i = useBuilderProp("collections", []), c = React__default.useMemo(() => n === "array" ? { ...i.map((p) => p.id).reduce((p, u) => ({ ...p, [COLLECTION_PREFIX + u]: [] }), {}), ...o } : o, [o, i, n]);
3609
3999
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
3610
4000
  /* @__PURE__ */ jsxs(Tooltip, { children: [
3611
4001
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
@@ -3616,7 +4006,16 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3616
4006
  className: "h-5 rounded-sm px-1 py-0 text-[9px] text-muted-foreground",
3617
4007
  role: "combobox",
3618
4008
  "aria-expanded": a,
3619
- children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-2.5 w-2.5" })
4009
+ children: /* @__PURE__ */ jsx("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24px", height: "24px", viewBox: "0 0 24 24", fill: "none", children: /* @__PURE__ */ jsx(
4010
+ "path",
4011
+ {
4012
+ d: "M9.5 5H9C7.89543 5 7 5.89543 7 7V9C7 10 6.4 12 4 12C5 12 7 12.6 7 15V17.0002C7 18.1048 7.89543 19 9 19H9.5M14.5 5H15C16.1046 5 17 5.89543 17 7V9C17 10 17.6 12 20 12C19 12 17 12.6 17 15V17.0002C17 18.1048 16.1046 19 15 19H14.5",
4013
+ stroke: "#000000",
4014
+ strokeLinecap: "round",
4015
+ strokeLinejoin: "round",
4016
+ strokeWidth: "2"
4017
+ }
4018
+ ) })
3620
4019
  }
3621
4020
  ) }) }),
3622
4021
  /* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
@@ -3624,9 +4023,9 @@ function NestedPathSelector({ data: o, onSelect: r, dataType: n = "value" }) {
3624
4023
  /* @__PURE__ */ jsx(PopoverContent, { className: "z-[1000]! relative mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsx(
3625
4024
  PathDropdown,
3626
4025
  {
3627
- data: o,
3628
- onSelect: (i, c) => {
3629
- r(i, c), l(!1);
4026
+ data: c,
4027
+ onSelect: (d, p) => {
4028
+ r(d, p), l(!1);
3630
4029
  },
3631
4030
  dataType: n
3632
4031
  }
@@ -3639,54 +4038,54 @@ const DataBindingSelector = ({
3639
4038
  id: n,
3640
4039
  formData: a
3641
4040
  }) => {
3642
- const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => i.length === 1 ? "" : `#${get(
3643
- i.find((h) => h._type === "Repeater"),
3644
- "repeaterItems",
3645
- ""
3646
- ).replace(/\{\{(.*)\}\}/g, "$1")}`, [i]), p = useMemo(() => first(get(l, d.replace("#", ""), [])), [d, l]), u = useCallback(
4041
+ const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
4042
+ if (i.length === 1) return "";
4043
+ const g = i.find((f) => f._type === "Repeater"), h = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4044
+ return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${g._id}` : h}`;
4045
+ }, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
3647
4046
  (g, m) => {
3648
4047
  if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), m === "array" || m === "object") {
3649
4048
  r(`{{${g}}}`, {}, n);
3650
4049
  return;
3651
4050
  }
3652
- const h = (b) => /[.,!?;:]/.test(b), f = (b, S, w) => {
3653
- let B = "", _ = "";
3654
- const E = S > 0 ? b[S - 1] : "", v = S < b.length ? b[S] : "";
3655
- return S > 0 && (E === "." || !h(E) && E !== " ") && (B = " "), S < b.length && !h(v) && v !== " " && (_ = " "), {
3656
- text: B + w + _,
3657
- prefixLength: B.length,
3658
- suffixLength: _.length
4051
+ const h = (b) => /[.,!?;:]/.test(b), f = (b, v, A) => {
4052
+ let w = "", E = "";
4053
+ const _ = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
4054
+ return v > 0 && (_ === "." || !h(_) && _ !== " ") && (w = " "), v < b.length && !h(S) && S !== " " && (E = " "), {
4055
+ text: w + A + E,
4056
+ prefixLength: w.length,
4057
+ suffixLength: E.length
3659
4058
  };
3660
4059
  }, x = document.getElementById(n);
3661
4060
  if (!x) return;
3662
- const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
3663
- if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
3664
- const b = k.__chaiRTE;
4061
+ const y = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4062
+ if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4063
+ const b = y.__chaiRTE;
3665
4064
  if (b) {
3666
- const S = `{{${g}}}`;
4065
+ const v = `{{${g}}}`;
3667
4066
  b.commands.focus();
3668
- const { from: w, to: B } = b.state.selection;
3669
- if (w !== B)
3670
- b.chain().deleteSelection().insertContent(S).run();
4067
+ const { from: A, to: w } = b.state.selection;
4068
+ if (A !== w)
4069
+ b.chain().deleteSelection().insertContent(v).run();
3671
4070
  else {
3672
- const { state: E } = b, v = E.selection.from, A = E.doc.textBetween(Math.max(0, v - 1), v), N = E.doc.textBetween(v, Math.min(v + 1, E.doc.content.size));
4071
+ const { state: _ } = b, S = _.selection.from, B = _.doc.textBetween(Math.max(0, S - 1), S), N = _.doc.textBetween(S, Math.min(S + 1, _.doc.content.size));
3673
4072
  let C = "";
3674
- v > 0 && A !== " " && !h(A) && (C = " ");
3675
- let y = "";
3676
- N && N !== " " && !h(N) && (y = " "), b.chain().insertContent(C + S + y).run();
4073
+ S > 0 && B !== " " && !h(B) && (C = " ");
4074
+ let k = "";
4075
+ N && N !== " " && !h(N) && (k = " "), b.chain().insertContent(C + v + k).run();
3677
4076
  }
3678
4077
  setTimeout(() => r(b.getHTML(), {}, n), 100);
3679
4078
  return;
3680
4079
  }
3681
4080
  } else {
3682
- const b = x, S = b.selectionStart || 0, w = b.value || "", B = b.selectionEnd || S;
3683
- if (B > S) {
3684
- const N = `{{${g}}}`, { text: C } = f(w, S, N), y = w.slice(0, S) + C + w.slice(B);
3685
- r(y, {}, n);
4081
+ const b = x, v = b.selectionStart || 0, A = b.value || "", w = b.selectionEnd || v;
4082
+ if (w > v) {
4083
+ const N = `{{${g}}}`, { text: C } = f(A, v, N), k = A.slice(0, v) + C + A.slice(w);
4084
+ r(k, {}, n);
3686
4085
  return;
3687
4086
  }
3688
- const E = `{{${g}}}`, { text: v } = f(w, S, E), A = w.slice(0, S) + v + w.slice(S);
3689
- r(A, {}, n);
4087
+ const _ = `{{${g}}}`, { text: S } = f(A, v, _), B = A.slice(0, v) + S + A.slice(v);
4088
+ r(B, {}, n);
3690
4089
  }
3691
4090
  },
3692
4091
  [n, r, a, c == null ? void 0 : c._id, d]
@@ -3708,57 +4107,57 @@ const DataBindingSelector = ({
3708
4107
  onChange: n
3709
4108
  }) => {
3710
4109
  var N;
3711
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, y) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [k, b] = useState(-1), S = useRef(null), w = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
4110
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, h] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), A = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
3712
4111
  useEffect(() => {
3713
4112
  if (h(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
3714
- const C = split(o, ":"), y = get(C, 1, "page") || "page";
3715
- g(y), (async () => {
3716
- const j = await l(y, [get(C, 2, "page")]);
4113
+ const C = split(o, ":"), k = get(C, 1, "page") || "page";
4114
+ g(k), (async () => {
4115
+ const j = await l(k, [get(C, 2, "page")]);
3717
4116
  j && Array.isArray(j) && h(get(j, [0, "name"], ""));
3718
4117
  })();
3719
4118
  }, [o]);
3720
- const B = useDebouncedCallback(
4119
+ const w = useDebouncedCallback(
3721
4120
  async (C) => {
3722
4121
  if (isEmpty(C))
3723
4122
  x([]);
3724
4123
  else {
3725
- const y = await l(u, C);
3726
- x(y);
4124
+ const k = await l(u, C);
4125
+ x(k);
3727
4126
  }
3728
4127
  c(!1), b(-1);
3729
4128
  },
3730
4129
  [u],
3731
4130
  300
3732
- ), _ = (C) => {
3733
- const y = ["pageType", u, C.id];
3734
- y[1] && (n(y.join(":")), h(C.name), p(!1), x([]), b(-1));
3735
- }, E = (C) => {
4131
+ ), E = (C) => {
4132
+ const k = ["pageType", u, C.id];
4133
+ k[1] && (n(k.join(":")), h(C.name), p(!1), x([]), b(-1));
4134
+ }, _ = (C) => {
3736
4135
  switch (C.key) {
3737
4136
  case "ArrowDown":
3738
- C.preventDefault(), b((y) => y < f.length - 1 ? y + 1 : y);
4137
+ C.preventDefault(), b((k) => k < f.length - 1 ? k + 1 : k);
3739
4138
  break;
3740
4139
  case "ArrowUp":
3741
- C.preventDefault(), b((y) => y > 0 ? y - 1 : y);
4140
+ C.preventDefault(), b((k) => k > 0 ? k - 1 : k);
3742
4141
  break;
3743
4142
  case "Enter":
3744
4143
  if (C.preventDefault(), f.length === 0) return;
3745
- k >= 0 && _(f[k]);
4144
+ y >= 0 && E(f[y]);
3746
4145
  break;
3747
4146
  case "Escape":
3748
- C.preventDefault(), v();
4147
+ C.preventDefault(), S();
3749
4148
  break;
3750
4149
  }
3751
4150
  };
3752
4151
  useEffect(() => {
3753
- if (k >= 0 && S.current) {
3754
- const C = S.current.children[k];
4152
+ if (y >= 0 && v.current) {
4153
+ const C = v.current.children[y];
3755
4154
  C == null || C.scrollIntoView({ block: "nearest" });
3756
4155
  }
3757
- }, [k]);
3758
- const v = () => {
4156
+ }, [y]);
4157
+ const S = () => {
3759
4158
  h(""), x([]), b(-1), p(!1), n("");
3760
- }, A = (C) => {
3761
- h(C), p(!isEmpty(C)), c(!0), B(C);
4159
+ }, B = (C) => {
4160
+ h(C), p(!isEmpty(C)), c(!0), w(C);
3762
4161
  };
3763
4162
  return /* @__PURE__ */ jsxs("div", { children: [
3764
4163
  /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(r, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
@@ -3768,13 +4167,13 @@ const DataBindingSelector = ({
3768
4167
  {
3769
4168
  type: "text",
3770
4169
  value: m,
3771
- onChange: (C) => A(C.target.value),
3772
- onKeyDown: E,
3773
- placeholder: a(`Search ${w ?? ""}`),
4170
+ onChange: (C) => B(C.target.value),
4171
+ onKeyDown: _,
4172
+ placeholder: a(`Search ${A ?? ""}`),
3774
4173
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
3775
4174
  }
3776
4175
  ),
3777
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: v, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4176
+ /* @__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" }) }) })
3778
4177
  ] }),
3779
4178
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
3780
4179
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -3784,11 +4183,11 @@ const DataBindingSelector = ({
3784
4183
  ' "',
3785
4184
  m,
3786
4185
  '"'
3787
- ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(f == null ? void 0 : f.slice(0, 20), (C, y) => /* @__PURE__ */ jsxs(
4186
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
3788
4187
  "li",
3789
4188
  {
3790
- onClick: () => _(C),
3791
- 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"}`,
4189
+ onClick: () => E(C),
4190
+ 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"}`,
3792
4191
  children: [
3793
4192
  C.name,
3794
4193
  " ",
@@ -4067,7 +4466,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4067
4466
  alignments: ["left", "center", "right"],
4068
4467
  defaultAlignment: "left"
4069
4468
  }),
4070
- Underline
4469
+ Underline,
4470
+ Placeholder.configure({
4471
+ placeholder: "Enter text here",
4472
+ emptyEditorClass: "cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"
4473
+ })
4071
4474
  ],
4072
4475
  content: a || "",
4073
4476
  onUpdate: ({ editor: m }) => {
@@ -4099,17 +4502,17 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4099
4502
  if (f !== x)
4100
4503
  u.chain().deleteSelection().insertContent(h).run();
4101
4504
  else {
4102
- const { state: b } = u, S = b.selection.from, w = b.doc.textBetween(Math.max(0, S - 1), S), B = b.doc.textBetween(S, Math.min(S + 1, b.doc.content.size));
4103
- let _ = "";
4104
- S > 0 && w !== " " && !/[.,!?;:]/.test(w) && (_ = " ");
4505
+ const { state: b } = u, v = b.selection.from, A = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
4105
4506
  let E = "";
4106
- B && B !== " " && !/[.,!?;:]/.test(B) && (E = " "), u.chain().insertContent(_ + h + E).run();
4507
+ v > 0 && A !== " " && !/[.,!?;:]/.test(A) && (E = " ");
4508
+ let _ = "";
4509
+ w && w !== " " && !/[.,!?;:]/.test(w) && (_ = " "), u.chain().insertContent(E + h + _).run();
4107
4510
  }
4108
4511
  };
4109
4512
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4110
4513
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4111
4514
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4112
- p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
4515
+ Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
4113
4516
  /* @__PURE__ */ jsx("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
4114
4517
  /* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: g }) })
4115
4518
  ] })
@@ -4135,7 +4538,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4135
4538
  alignments: ["left", "center", "right"],
4136
4539
  defaultAlignment: "left"
4137
4540
  }),
4138
- Underline
4541
+ Underline,
4542
+ Placeholder.configure({
4543
+ placeholder: r || "Enter text here",
4544
+ emptyEditorClass: "cursor-text before:content-[attr(data-placeholder)] before:absolute before:opacity-50 before:pointer-events-none"
4545
+ })
4139
4546
  ],
4140
4547
  content: n || "",
4141
4548
  onUpdate: ({ editor: f }) => {
@@ -4193,14 +4600,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4193
4600
  const m = () => {
4194
4601
  const x = findIndex(u, { _id: g });
4195
4602
  if (x > -1) {
4196
- const k = (x + 1) % u.length, b = get(u, [k, "_id"]);
4603
+ const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4197
4604
  if (!b) return;
4198
4605
  r({ ...o, currentSlide: b }), c([b]);
4199
4606
  }
4200
4607
  }, h = () => {
4201
4608
  const x = findIndex(u, { _id: g });
4202
4609
  if (x > -1) {
4203
- const k = (x - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4610
+ const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4204
4611
  if (!b) return;
4205
4612
  r({ ...o, currentSlide: b }), c([b]);
4206
4613
  }
@@ -4208,8 +4615,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4208
4615
  const x = i(
4209
4616
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4210
4617
  p == null ? void 0 : p._id
4211
- ), k = x == null ? void 0 : x._id;
4212
- k && (r({ ...o, currentSlide: k }), c([k]));
4618
+ ), y = x == null ? void 0 : x._id;
4619
+ y && (r({ ...o, currentSlide: y }), c([y]));
4213
4620
  };
4214
4621
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4215
4622
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4288,8 +4695,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4288
4695
  className: "text-xs",
4289
4696
  pattern: "[0-9]*",
4290
4697
  onChange: (x) => {
4291
- let k = x.target.value;
4292
- k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
4698
+ let y = x.target.value;
4699
+ y.length && (y = y.replace("-", "")), r({ ...o, autoplayInterval: y });
4293
4700
  }
4294
4701
  }
4295
4702
  )
@@ -4377,6 +4784,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4377
4784
  ),
4378
4785
  /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: n("Open code editor") })
4379
4786
  ] });
4787
+ }, CollectionFilterSortField = ({ id: o, value: r, onChange: n, onBlur: a }) => {
4788
+ const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
4789
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: r, onChange: (g) => n(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
4790
+ /* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
4791
+ u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
4792
+ ] }) });
4380
4793
  }, JSONFormFieldTemplate = ({
4381
4794
  id: o,
4382
4795
  classNames: r,
@@ -4391,25 +4804,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4391
4804
  formData: g,
4392
4805
  onChange: m
4393
4806
  }) => {
4394
- const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), k = useMemo(
4807
+ const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), y = useMemo(
4395
4808
  () => isEmpty(x) ? "" : isEmpty(h) ? f : h,
4396
4809
  [x, h, f]
4397
- ), b = useMemo(() => get(LANGUAGES, k, k), [k]), S = usePageExternalData(), w = useSelectedBlock(), B = useRegisteredChaiBlocks(), _ = useMemo(
4398
- () => get(B, [w == null ? void 0 : w._type, "i18nProps"], []),
4399
- [B, w == null ? void 0 : w._type]
4400
- ), [E, v] = useState(null);
4810
+ ), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), A = useSelectedBlock(), w = useRegisteredChaiBlocks(), E = useMemo(
4811
+ () => get(w, [A == null ? void 0 : A._type, "i18nProps"], []),
4812
+ [w, A == null ? void 0 : A._type]
4813
+ ), [_, S] = useState(null);
4401
4814
  if (d)
4402
4815
  return null;
4403
4816
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4404
- const N = _ == null ? void 0 : _.includes(o.replace("root.", ""));
4817
+ const N = E == null ? void 0 : E.includes(o.replace("root.", ""));
4405
4818
  if (u.type === "array") {
4406
- const C = E === o;
4819
+ const C = _ === o;
4407
4820
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
4408
4821
  u.title && /* @__PURE__ */ jsxs(
4409
4822
  "label",
4410
4823
  {
4411
4824
  htmlFor: o,
4412
- onClick: () => v(C ? null : o),
4825
+ onClick: () => S(C ? null : o),
4413
4826
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4414
4827
  children: [
4415
4828
  C ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
@@ -4439,7 +4852,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4439
4852
  ] }),
4440
4853
  p && u.type !== "object" ? " *" : null
4441
4854
  ] }),
4442
- !u.enum && !u.oneOf && S && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4855
+ !u.enum && !u.oneOf && v && /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx(
4443
4856
  DataBindingSelector,
4444
4857
  {
4445
4858
  schema: u,
@@ -4478,6 +4891,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4478
4891
  image: ImagePickerField,
4479
4892
  code: CodeEditor,
4480
4893
  colCount: RowColField,
4894
+ collectionSelect: CollectionFilterSortField,
4481
4895
  ...c
4482
4896
  },
4483
4897
  fields: {
@@ -4517,38 +4931,38 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4517
4931
  }), a;
4518
4932
  };
4519
4933
  function BlockSettings() {
4520
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: E }, v, A) => {
4521
- v && (c == null ? void 0 : c._id) === r._id && a([r._id], { [v]: get(E, v) }, A);
4934
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), h = formDataWithSelectedLang(g, o, m), f = ({ formData: _ }, S, B) => {
4935
+ S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(_, S) }, B);
4522
4936
  }, x = useCallback(
4523
- debounce(({ formData: E }, v, A) => {
4524
- f({ formData: E }, v, A), d(E);
4937
+ debounce(({ formData: _ }, S, B) => {
4938
+ f({ formData: _ }, S, B), d(_);
4525
4939
  }, 1500),
4526
4940
  [r == null ? void 0 : r._id, o]
4527
- ), k = ({ formData: E }, v) => {
4528
- v && (n([r._id], { [v]: get(E, v) }), x({ formData: E }, v, { [v]: get(c, v) }));
4529
- }, b = ({ formData: E }, v) => {
4530
- v && (n([g._id], { [v]: get(E, v) }), x({ formData: E }, v, { [v]: get(c, v) }));
4531
- }, { schema: S, uiSchema: w } = useMemo(() => {
4532
- const E = r == null ? void 0 : r._type;
4533
- if (!E)
4941
+ ), y = ({ formData: _ }, S) => {
4942
+ S && (n([r._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4943
+ }, b = ({ formData: _ }, S) => {
4944
+ S && (n([g._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4945
+ }, { schema: v, uiSchema: A } = useMemo(() => {
4946
+ const _ = r == null ? void 0 : r._type;
4947
+ if (!_)
4534
4948
  return { schema: {}, uiSchema: {} };
4535
4949
  try {
4536
- return getBlockFormSchemas(E);
4950
+ return getBlockFormSchemas(_);
4537
4951
  } catch {
4538
4952
  return { schema: {}, uiSchema: {} };
4539
4953
  }
4540
- }, [r]), { wrapperSchema: B, wrapperUiSchema: _ } = useMemo(() => {
4954
+ }, [r]), { wrapperSchema: w, wrapperUiSchema: E } = useMemo(() => {
4541
4955
  if (!g || !(g != null && g._type))
4542
4956
  return { wrapperSchema: {}, wrapperUiSchema: {} };
4543
- const E = g == null ? void 0 : g._type, { schema: v = {}, uiSchema: A = {} } = getBlockFormSchemas(E);
4544
- return { wrapperSchema: v, wrapperUiSchema: A };
4957
+ const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: B = {} } = getBlockFormSchemas(_);
4958
+ return { wrapperSchema: S, wrapperUiSchema: B };
4545
4959
  }, [g]);
4546
4960
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
4547
4961
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
4548
4962
  /* @__PURE__ */ jsxs(
4549
4963
  "div",
4550
4964
  {
4551
- onClick: () => u((E) => !E),
4965
+ onClick: () => u((_) => !_),
4552
4966
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
4553
4967
  children: [
4554
4968
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -4569,19 +4983,19 @@ function BlockSettings() {
4569
4983
  blockId: g == null ? void 0 : g._id,
4570
4984
  onChange: b,
4571
4985
  formData: h,
4572
- schema: B,
4573
- uiSchema: _
4986
+ schema: w,
4987
+ uiSchema: E
4574
4988
  }
4575
4989
  ) })
4576
4990
  ] }),
4577
- isEmpty(S) ? null : /* @__PURE__ */ jsx(
4991
+ isEmpty(v) ? null : /* @__PURE__ */ jsx(
4578
4992
  JSONForm,
4579
4993
  {
4580
4994
  blockId: r == null ? void 0 : r._id,
4581
- onChange: k,
4995
+ onChange: y,
4582
4996
  formData: i,
4583
- schema: S,
4584
- uiSchema: w
4997
+ schema: v,
4998
+ uiSchema: A
4585
4999
  }
4586
5000
  )
4587
5001
  ] });
@@ -4758,50 +5172,50 @@ const BlockStylingProps = () => {
4758
5172
  },
4759
5173
  a
4760
5174
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
4761
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [k, b] = useState(""), [S, w] = useState(!1), [B, _] = useState(!1);
5175
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v, A] = useState(!1), [w, E] = useState(!1);
4762
5176
  useEffect(() => {
4763
- const { value: C, unit: y } = getClassValueAndUnit(i);
4764
- if (y === "") {
5177
+ const { value: C, unit: k } = getClassValueAndUnit(i);
5178
+ if (k === "") {
4765
5179
  l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
4766
5180
  return;
4767
5181
  }
4768
- h(y), l(y === "class" || isEmpty(C) ? "" : C);
5182
+ h(k), l(k === "class" || isEmpty(C) ? "" : C);
4769
5183
  }, [i, p, u]);
4770
- const E = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), v = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
5184
+ const _ = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), B = useCallback(
4771
5185
  (C = !1) => {
4772
- const y = getUserInputValues(`${a}`, u);
4773
- if (get(y, "error", !1)) {
5186
+ const k = getUserInputValues(`${a}`, u);
5187
+ if (get(k, "error", !1)) {
4774
5188
  x(!0);
4775
5189
  return;
4776
5190
  }
4777
- const j = get(y, "unit") !== "" ? get(y, "unit") : m;
5191
+ const j = get(k, "unit") !== "" ? get(k, "unit") : m;
4778
5192
  if (j === "auto" || j === "none") {
4779
- E(`${d}${j}`);
5193
+ _(`${d}${j}`);
4780
5194
  return;
4781
5195
  }
4782
- if (get(y, "value") === "")
5196
+ if (get(k, "value") === "")
4783
5197
  return;
4784
- const I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4785
- C ? v(I) : E(I);
5198
+ const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5199
+ C ? S(I) : _(I);
4786
5200
  },
4787
- [E, v, a, m, d, u]
5201
+ [_, S, a, m, d, u]
4788
5202
  ), N = useCallback(
4789
5203
  (C) => {
4790
- const y = getUserInputValues(`${a}`, u);
4791
- if (get(y, "error", !1)) {
5204
+ const k = getUserInputValues(`${a}`, u);
5205
+ if (get(k, "error", !1)) {
4792
5206
  x(!0);
4793
5207
  return;
4794
5208
  }
4795
5209
  if (C === "auto" || C === "none") {
4796
- E(`${d}${C}`);
5210
+ _(`${d}${C}`);
4797
5211
  return;
4798
5212
  }
4799
- if (get(y, "value") === "")
5213
+ if (get(k, "value") === "")
4800
5214
  return;
4801
- const j = get(y, "unit") !== "" ? get(y, "unit") : C, I = `${get(y, "value", "").startsWith("-") ? "-" : ""}${d}[${get(y, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
4802
- E(I);
5215
+ const j = get(k, "unit") !== "" ? get(k, "unit") : C, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5216
+ _(I);
4803
5217
  },
4804
- [E, a, d, u]
5218
+ [_, a, d, u]
4805
5219
  );
4806
5220
  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: [
4807
5221
  /* @__PURE__ */ jsx(
@@ -4816,37 +5230,37 @@ const BlockStylingProps = () => {
4816
5230
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
4817
5231
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
4818
5232
  ] })
4819
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
5233
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
4820
5234
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
4821
5235
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
4822
5236
  "input",
4823
5237
  {
4824
5238
  readOnly: m === "class",
4825
5239
  onKeyPress: (C) => {
4826
- C.key === "Enter" && A();
5240
+ C.key === "Enter" && B();
4827
5241
  },
4828
5242
  onKeyDown: (C) => {
4829
5243
  if (C.keyCode !== 38 && C.keyCode !== 40)
4830
5244
  return;
4831
- C.preventDefault(), _(!0);
4832
- const y = parseInt$1(C.target.value);
4833
- let j = isNaN$1(y) ? 0 : y;
5245
+ C.preventDefault(), E(!0);
5246
+ const k = parseInt$1(C.target.value);
5247
+ let j = isNaN$1(k) ? 0 : k;
4834
5248
  C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
4835
5249
  const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${m === "-" ? "" : m}]`;
4836
- v(P);
5250
+ S(P);
4837
5251
  },
4838
5252
  onKeyUp: (C) => {
4839
- B && (C.preventDefault(), _(!1));
5253
+ w && (C.preventDefault(), E(!1));
4840
5254
  },
4841
- onBlur: () => A(),
5255
+ onBlur: () => B(),
4842
5256
  onChange: (C) => {
4843
5257
  x(!1), l(C.target.value);
4844
5258
  },
4845
5259
  onClick: (C) => {
4846
- var y;
4847
- (y = C == null ? void 0 : C.target) == null || y.select(), n(!1);
5260
+ var k;
5261
+ (k = C == null ? void 0 : C.target) == null || k.select(), n(!1);
4848
5262
  },
4849
- value: S ? k : a,
5263
+ value: v ? y : a,
4850
5264
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
4851
5265
  " ",
4852
5266
  f ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -4878,22 +5292,22 @@ const BlockStylingProps = () => {
4878
5292
  ) })
4879
5293
  ] })
4880
5294
  ] }),
4881
- ["none", "auto"].indexOf(m) !== -1 || S ? null : /* @__PURE__ */ jsx(
5295
+ ["none", "auto"].indexOf(m) !== -1 || v ? null : /* @__PURE__ */ jsx(
4882
5296
  DragStyleButton,
4883
5297
  {
4884
- onDragStart: () => w(!0),
5298
+ onDragStart: () => A(!0),
4885
5299
  onDragEnd: (C) => {
4886
- if (b(() => ""), w(!1), isEmpty(C))
5300
+ if (b(() => ""), A(!1), isEmpty(C))
4887
5301
  return;
4888
- const y = `${C}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
4889
- E(T);
5302
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
5303
+ _(T);
4890
5304
  },
4891
5305
  onDrag: (C) => {
4892
5306
  if (isEmpty(C))
4893
5307
  return;
4894
5308
  b(C);
4895
- const y = `${C}`, T = `${y.startsWith("-") ? "-" : ""}${d}[${y.replace("-", "")}${m === "-" ? "" : m}]`;
4896
- v(T);
5309
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${m === "-" ? "" : m}]`;
5310
+ S(T);
4897
5311
  },
4898
5312
  currentValue: a,
4899
5313
  unit: m,
@@ -4958,8 +5372,8 @@ const COLOR_PROP = {
4958
5372
  }, ColorChoice = ({ property: o, onChange: r }) => {
4959
5373
  const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { 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(
4960
5374
  // eslint-disable-next-line no-shadow
4961
- (k) => {
4962
- ["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" })));
5375
+ (y) => {
5376
+ ["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" })));
4963
5377
  },
4964
5378
  [c, p]
4965
5379
  );
@@ -4970,8 +5384,8 @@ const COLOR_PROP = {
4970
5384
  }, [g]);
4971
5385
  const f = useCallback(
4972
5386
  // eslint-disable-next-line no-shadow
4973
- (k) => {
4974
- p({ color: g, shade: k });
5387
+ (y) => {
5388
+ p({ color: g, shade: y });
4975
5389
  },
4976
5390
  [g]
4977
5391
  );
@@ -5356,35 +5770,35 @@ const COLOR_PROP = {
5356
5770
  "2xl": "1536px"
5357
5771
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5358
5772
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5359
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), k = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
5360
- (v, A = !0) => {
5361
- const N = { dark: p, mq: g, mod: u, cls: v, property: l, fullCls: "" };
5773
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(m, "fullCls", ""), [m]), b = useCallback(
5774
+ (S, B = !0) => {
5775
+ const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5362
5776
  (p || u !== "") && (N.mq = "xs");
5363
5777
  const C = generateFullClsName(N);
5364
- h(x, [C], A);
5778
+ h(x, [C], B);
5365
5779
  },
5366
5780
  [x, p, g, u, l, h]
5367
- ), S = useCallback(() => {
5368
- f(x, [k], !0);
5369
- }, [x, k, f]), w = useMemo(() => canChangeClass(m, g), [m, g]);
5781
+ ), v = useCallback(() => {
5782
+ f(x, [y], !0);
5783
+ }, [x, y, f]), A = useMemo(() => canChangeClass(m, g), [m, g]);
5370
5784
  useEffect(() => {
5371
- i(w, m);
5372
- }, [w, i, m]);
5373
- const [, , B] = useScreenSizeWidth(), _ = useCallback(
5374
- (v) => {
5375
- B({
5785
+ i(A, m);
5786
+ }, [A, i, m]);
5787
+ const [, , w] = useScreenSizeWidth(), E = useCallback(
5788
+ (S) => {
5789
+ w({
5376
5790
  xs: 400,
5377
5791
  sm: 640,
5378
5792
  md: 800,
5379
5793
  lg: 1024,
5380
5794
  xl: 1420,
5381
5795
  "2xl": 1920
5382
- }[v]);
5796
+ }[S]);
5383
5797
  },
5384
- [B]
5385
- ), E = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
5386
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: w, canReset: m && E, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5387
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !E ? "text-foreground" : ""}`, children: r(a) }) }),
5798
+ [w]
5799
+ ), _ = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
5800
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: A, canReset: m && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5801
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
5388
5802
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5389
5803
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5390
5804
  n === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -5403,7 +5817,7 @@ const COLOR_PROP = {
5403
5817
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5404
5818
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5405
5819
  ] }),
5406
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${k ? "visible" : "invisible"}`, children: E ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => S(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : w && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5820
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : A && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5407
5821
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5408
5822
  "button",
5409
5823
  {
@@ -5423,7 +5837,7 @@ const COLOR_PROP = {
5423
5837
  "button",
5424
5838
  {
5425
5839
  type: "button",
5426
- onClick: () => _(get(m, "mq")),
5840
+ onClick: () => E(get(m, "mq")),
5427
5841
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
5428
5842
  children: [
5429
5843
  "Switch to ",
@@ -5624,10 +6038,10 @@ const COLOR_PROP = {
5624
6038
  tooltip: n = !0
5625
6039
  }) => {
5626
6040
  const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: m } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
5627
- u.includes(b) ? u.length > 2 && g(u.filter((S) => S !== b)) : g((S) => [...S, b]);
6041
+ u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
5628
6042
  }, x = (b) => {
5629
6043
  r || l(b), c(b);
5630
- }, k = getBreakpointValue(r ? i : a).toLowerCase();
6044
+ }, y = getBreakpointValue(r ? i : a).toLowerCase();
5631
6045
  return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
5632
6046
  BreakpointCard,
5633
6047
  {
@@ -5635,7 +6049,7 @@ const COLOR_PROP = {
5635
6049
  ...b,
5636
6050
  onClick: x,
5637
6051
  key: b.breakpoint,
5638
- currentBreakpoint: k
6052
+ currentBreakpoint: y
5639
6053
  }
5640
6054
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5641
6055
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -5649,7 +6063,7 @@ const COLOR_PROP = {
5649
6063
  ...b,
5650
6064
  onClick: x,
5651
6065
  key: b.breakpoint,
5652
- currentBreakpoint: k
6066
+ currentBreakpoint: y
5653
6067
  }
5654
6068
  )
5655
6069
  ) }),
@@ -5804,10 +6218,10 @@ const AskAIStyles = ({ blockId: o }) => {
5804
6218
  };
5805
6219
  function ManualClasses() {
5806
6220
  var T;
5807
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), k = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), S = b.split(" ").filter((I) => !isEmpty(I)), w = () => {
6221
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), A = () => {
5808
6222
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5809
6223
  u(m, I, !0), x("");
5810
- }, [B, _] = useState([]), E = ({ value: I }) => {
6224
+ }, [w, E] = useState([]), _ = ({ value: I }) => {
5811
6225
  const P = I.trim().toLowerCase(), L = P.match(/.+:/g);
5812
6226
  let D = [];
5813
6227
  if (L && L.length > 0) {
@@ -5818,10 +6232,10 @@ function ManualClasses() {
5818
6232
  }));
5819
6233
  } else
5820
6234
  D = i.search(P);
5821
- return _(map(D, "item"));
5822
- }, v = () => {
5823
- _([]);
5824
- }, A = (I) => I.name, N = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), C = useMemo(
6235
+ return E(map(D, "item"));
6236
+ }, S = () => {
6237
+ E([]);
6238
+ }, B = (I) => I.name, N = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), C = useMemo(
5825
6239
  () => ({
5826
6240
  ref: o,
5827
6241
  autoComplete: "off",
@@ -5836,13 +6250,13 @@ function ManualClasses() {
5836
6250
  }, 0);
5837
6251
  },
5838
6252
  onKeyDown: (I) => {
5839
- I.key === "Enter" && f.trim() !== "" && w();
6253
+ I.key === "Enter" && f.trim() !== "" && A();
5840
6254
  },
5841
6255
  onChange: (I, { newValue: P }) => x(P),
5842
6256
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5843
6257
  }),
5844
6258
  [f, c, o]
5845
- ), y = (I) => {
6259
+ ), k = (I) => {
5846
6260
  debugger;
5847
6261
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5848
6262
  g(m, [I]), u(m, P, !0), n(""), l(-1);
@@ -5851,7 +6265,7 @@ function ManualClasses() {
5851
6265
  toast.error(c("Clipboard not supported"));
5852
6266
  return;
5853
6267
  }
5854
- navigator.clipboard.writeText(S.join(" ")), toast.success(c("Classes copied to clipboard"));
6268
+ navigator.clipboard.writeText(v.join(" ")), toast.success(c("Classes copied to clipboard"));
5855
6269
  };
5856
6270
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5857
6271
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
@@ -5874,10 +6288,10 @@ function ManualClasses() {
5874
6288
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5875
6289
  Autosuggest,
5876
6290
  {
5877
- suggestions: B,
5878
- onSuggestionsFetchRequested: E,
5879
- onSuggestionsClearRequested: v,
5880
- getSuggestionValue: A,
6291
+ suggestions: w,
6292
+ onSuggestionsFetchRequested: _,
6293
+ onSuggestionsClearRequested: S,
6294
+ getSuggestionValue: B,
5881
6295
  renderSuggestion: N,
5882
6296
  inputProps: C,
5883
6297
  containerProps: {
@@ -5895,14 +6309,14 @@ function ManualClasses() {
5895
6309
  {
5896
6310
  variant: "outline",
5897
6311
  className: "h-6 border-border",
5898
- onClick: w,
6312
+ onClick: A,
5899
6313
  disabled: f.trim() === "",
5900
6314
  size: "sm",
5901
6315
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5902
6316
  }
5903
6317
  )
5904
6318
  ] }),
5905
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: S.map(
6319
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: v.map(
5906
6320
  (I, P) => a === P ? /* @__PURE__ */ jsx(
5907
6321
  "input",
5908
6322
  {
@@ -5910,10 +6324,10 @@ function ManualClasses() {
5910
6324
  value: r,
5911
6325
  onChange: (L) => n(L.target.value),
5912
6326
  onBlur: () => {
5913
- y(I);
6327
+ k(I);
5914
6328
  },
5915
6329
  onKeyDown: (L) => {
5916
- L.key === "Enter" && y(I);
6330
+ L.key === "Enter" && k(I);
5917
6331
  },
5918
6332
  onFocus: (L) => {
5919
6333
  setTimeout(() => {
@@ -6062,8 +6476,8 @@ function BlockStyling() {
6062
6476
  h = isNaN(h) ? 0 : h;
6063
6477
  let f = MAPPER[i.dragUnit];
6064
6478
  (startsWith(m, "scale") || m === "opacity") && (f = 10);
6065
- let k = (i.dragStartY - u.pageY) / f + h;
6066
- g && k < 0 && (k = 0), m === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6479
+ let y = (i.dragStartY - u.pageY) / f + h;
6480
+ g && y < 0 && (y = 0), m === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6067
6481
  },
6068
6482
  [i],
6069
6483
  50
@@ -6106,8 +6520,8 @@ const CoreBlock = ({
6106
6520
  }) => {
6107
6521
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), h = () => {
6108
6522
  if (has(o, "blocks")) {
6109
- const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6110
- u(syncBlocksWithDefaults(k), n || null, a);
6523
+ const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6524
+ u(syncBlocksWithDefaults(y), n || null, a);
6111
6525
  } else
6112
6526
  p(o, n || null, a);
6113
6527
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6119,8 +6533,8 @@ const CoreBlock = ({
6119
6533
  disabled: r,
6120
6534
  onClick: h,
6121
6535
  type: "button",
6122
- onDragStart: (k) => {
6123
- k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6536
+ onDragStart: (y) => {
6537
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6124
6538
  g([]), m();
6125
6539
  }, 200);
6126
6540
  },
@@ -6320,22 +6734,22 @@ const CoreBlock = ({
6320
6734
  }
6321
6735
  }
6322
6736
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6323
- var m, h, f, x, k, b, S, w;
6737
+ var m, h, f, x, y, b, v, A;
6324
6738
  if (n.type === "comment") return [];
6325
6739
  console.log("node ===>", n);
6326
6740
  let a = { _id: generateUUID() };
6327
6741
  if (r && (a._parent = r.block._id), n.type === "text")
6328
6742
  return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
6329
6743
  const l = get(n, "attributes", []), i = l.find(
6330
- (B) => B.key === "data-chai-richtext" || B.key === "chai-richtext"
6744
+ (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
6331
6745
  ), c = l.find(
6332
- (B) => B.key === "data-chai-lightbox" || B.key === "chai-lightbox"
6746
+ (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
6333
6747
  ), d = l.find(
6334
- (B) => B.key === "data-chai-dropdown" || B.key === "chai-dropdown"
6748
+ (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
6335
6749
  ), p = l.find(
6336
- (B) => B.key === "data-chai-dropdown-button" || B.key === "chai-dropdown-button"
6750
+ (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
6337
6751
  ), u = l.find(
6338
- (B) => B.key === "data-chai-dropdown-content" || B.key === "chai-dropdown-content"
6752
+ (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
6339
6753
  );
6340
6754
  if (a = {
6341
6755
  ...a,
@@ -6343,13 +6757,13 @@ const CoreBlock = ({
6343
6757
  ...getAttrs(n),
6344
6758
  ...getStyles(n)
6345
6759
  }, n.attributes) {
6346
- const B = n.attributes.find((_) => includes(NAME_ATTRIBUTES, _.key));
6347
- B && (a._name = B.value);
6760
+ const w = n.attributes.find((E) => includes(NAME_ATTRIBUTES, E.key));
6761
+ w && (a._name = w.value);
6348
6762
  }
6349
6763
  if (i)
6350
6764
  return a.content = stringify(n.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
6351
6765
  if (c) {
6352
- const B = [
6766
+ const w = [
6353
6767
  "data-chai-lightbox",
6354
6768
  "chai-lightbox",
6355
6769
  "data-vbtype",
@@ -6361,44 +6775,44 @@ const CoreBlock = ({
6361
6775
  ];
6362
6776
  a = {
6363
6777
  ...a,
6364
- href: ((m = l.find((_) => _.key === "href")) == null ? void 0 : m.value) || "",
6365
- hrefType: ((h = l.find((_) => _.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6366
- autoplay: ((f = l.find((_) => _.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6367
- maxWidth: ((k = (x = l.find((_) => _.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : k.replace("px", "")) || "",
6368
- backdropColor: ((b = l.find((_) => _.key === "data-overlay")) == null ? void 0 : b.value) || "",
6369
- galleryName: ((S = l.find((_) => _.key === "data-gall")) == null ? void 0 : S.value) || ""
6370
- }, forEach(B, (_) => {
6371
- has(a, `styles_attrs.${_}`) && delete a.styles_attrs[_];
6778
+ href: ((m = l.find((E) => E.key === "href")) == null ? void 0 : m.value) || "",
6779
+ hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6780
+ autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6781
+ maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
6782
+ backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
6783
+ galleryName: ((v = l.find((E) => E.key === "data-gall")) == null ? void 0 : v.value) || ""
6784
+ }, forEach(w, (E) => {
6785
+ has(a, `styles_attrs.${E}`) && delete a.styles_attrs[E];
6372
6786
  });
6373
6787
  }
6374
6788
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6375
6789
  delete a.styles_attrs;
6376
- const B = filter(n.children || [], (E) => (E == null ? void 0 : E.tagName) !== "span");
6377
- a.content = getTextContent(B);
6378
- const _ = find(
6790
+ const w = filter(n.children || [], (_) => (_ == null ? void 0 : _.tagName) !== "span");
6791
+ a.content = getTextContent(w);
6792
+ const E = find(
6379
6793
  n.children || [],
6380
- (E) => (E == null ? void 0 : E.tagName) === "span" && some(E.children || [], (v) => (v == null ? void 0 : v.tagName) === "svg")
6794
+ (_) => (_ == null ? void 0 : _.tagName) === "span" && some(_.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg")
6381
6795
  );
6382
- if (_) {
6383
- const E = find(_.children || [], (v) => (v == null ? void 0 : v.tagName) === "svg");
6384
- if (E) {
6385
- a.icon = stringify([E]);
6386
- const { height: v, width: A } = getSvgDimensions(E, "16px", "16px");
6387
- a.iconHeight = v, a.iconWidth = A;
6796
+ if (E) {
6797
+ const _ = find(E.children || [], (S) => (S == null ? void 0 : S.tagName) === "svg");
6798
+ if (_) {
6799
+ a.icon = stringify([_]);
6800
+ const { height: S, width: B } = getSvgDimensions(_, "16px", "16px");
6801
+ a.iconHeight = S, a.iconWidth = B;
6388
6802
  }
6389
6803
  }
6390
6804
  return [a];
6391
6805
  }
6392
6806
  if (a._type === "Input") {
6393
- const B = a.inputType || "text";
6394
- B === "checkbox" ? set(a, "_type", "Checkbox") : B === "radio" && set(a, "_type", "Radio");
6807
+ const w = a.inputType || "text";
6808
+ w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
6395
6809
  } else if (n.tagName === "video" || n.tagName === "iframe") {
6396
- const B = stringify([n]);
6397
- return hasVideoEmbed(B) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(B)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = B, [a];
6810
+ const w = stringify([n]);
6811
+ return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
6398
6812
  } else if (n.tagName === "svg") {
6399
- const B = find(n.attributes, { key: "height" }), _ = find(n.attributes, { key: "width" }), E = get(B, "value") ? `[${get(B, "value")}px]` : "24px", v = get(_, "value") ? `[${get(_, "value")}px]` : "24px", A = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
6400
- return a.styles = `${STYLES_KEY}, ${cn$1(`w-${v} h-${E}`, A)}`.trim(), n.attributes = filter(n.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([n]), [a];
6401
- } else if (n.tagName == "option" && r && ((w = r.block) == null ? void 0 : w._type) === "Select")
6813
+ const w = find(n.attributes, { key: "height" }), E = find(n.attributes, { key: "width" }), _ = get(w, "value") ? `[${get(w, "value")}px]` : "24px", S = get(E, "value") ? `[${get(E, "value")}px]` : "24px", B = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
6814
+ return a.styles = `${STYLES_KEY}, ${cn$2(`w-${S} h-${_}`, B)}`.trim(), n.attributes = filter(n.attributes, (N) => !includes(["style", "width", "height", "class"], N.key)), a.icon = stringify([n]), [a];
6815
+ } else if (n.tagName == "option" && r && ((A = r.block) == null ? void 0 : A._type) === "Select")
6402
6816
  return r.block.options.push({
6403
6817
  label: getTextContent(n.children),
6404
6818
  ...getAttrs(n)
@@ -6458,10 +6872,10 @@ const CoreBlock = ({
6458
6872
  const g = u.target.value;
6459
6873
  d(g), r(g);
6460
6874
  };
6461
- return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
6875
+ return /* @__PURE__ */ jsx("div", { className: cn$2("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
6462
6876
  "select",
6463
6877
  {
6464
- className: cn$1(
6878
+ className: cn$2(
6465
6879
  "mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
6466
6880
  i
6467
6881
  ),
@@ -6502,18 +6916,18 @@ const BlockCard = ({
6502
6916
  parentId: n = void 0,
6503
6917
  position: a = -1
6504
6918
  }) => {
6505
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), k = (w) => {
6506
- const B = has(w, "styles_attrs.data-page-section");
6507
- return w._type === "Box" && B;
6919
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (A) => {
6920
+ const w = has(A, "styles_attrs.data-page-section");
6921
+ return A._type === "Box" && w;
6508
6922
  }, b = useCallback(
6509
- async (w) => {
6510
- if (w.stopPropagation(), has(o, "component")) {
6923
+ async (A) => {
6924
+ if (A.stopPropagation(), has(o, "component")) {
6511
6925
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6512
6926
  return;
6513
6927
  }
6514
6928
  i(!0);
6515
- const B = await c(r, o);
6516
- isEmpty(B) || p(syncBlocksWithDefaults(B), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6929
+ const w = await c(r, o);
6930
+ isEmpty(w) || p(syncBlocksWithDefaults(w), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6517
6931
  },
6518
6932
  [d, p, o, c, r, n, a]
6519
6933
  );
@@ -6524,19 +6938,19 @@ const BlockCard = ({
6524
6938
  onClick: l ? () => {
6525
6939
  } : b,
6526
6940
  draggable: f ? "true" : "false",
6527
- onDragStart: async (w) => {
6528
- const B = await c(r, o);
6529
- let _ = n;
6530
- if (k(first(B)) && (_ = null), !isEmpty(B)) {
6531
- const E = { blocks: B, uiLibrary: !0, parent: _ };
6532
- if (w.dataTransfer.setData("text/plain", JSON.stringify(E)), o.preview) {
6533
- const v = new Image();
6534
- v.src = o.preview, v.onload = () => {
6535
- w.dataTransfer.setDragImage(v, 0, 0);
6941
+ onDragStart: async (A) => {
6942
+ const w = await c(r, o);
6943
+ let E = n;
6944
+ if (y(first(w)) && (E = null), !isEmpty(w)) {
6945
+ const _ = { blocks: w, uiLibrary: !0, parent: E };
6946
+ if (A.dataTransfer.setData("text/plain", JSON.stringify(_)), o.preview) {
6947
+ const S = new Image();
6948
+ S.src = o.preview, S.onload = () => {
6949
+ A.dataTransfer.setDragImage(S, 0, 0);
6536
6950
  };
6537
6951
  } else
6538
- w.dataTransfer.setDragImage(new Image(), 0, 0);
6539
- x(E), setTimeout(() => {
6952
+ A.dataTransfer.setDragImage(new Image(), 0, 0);
6953
+ x(_), setTimeout(() => {
6540
6954
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6541
6955
  }, 200);
6542
6956
  }
@@ -6562,7 +6976,7 @@ const BlockCard = ({
6562
6976
  ] }) })
6563
6977
  ] });
6564
6978
  }, UILibrarySection = ({ parentId: o, position: r }) => {
6565
- const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((y) => y.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
6979
+ const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [m, h] = useState([]), f = useRef(null);
6566
6980
  useEffect(() => {
6567
6981
  c && c.length > 0 && (f.current = new Fuse(c, {
6568
6982
  keys: ["name", "label", "description", "group"],
@@ -6574,27 +6988,27 @@ const BlockCard = ({
6574
6988
  h([]);
6575
6989
  return;
6576
6990
  }
6577
- const y = f.current.search(u).map((j) => j.item);
6578
- h(y);
6991
+ const k = f.current.search(u).map((j) => j.item);
6992
+ h(k);
6579
6993
  }, [u]);
6580
- const x = u.trim() && !isEmpty(m) ? m : c, k = groupBy(x, "group"), [b, S] = useState(null);
6994
+ const x = u.trim() && !isEmpty(m) ? m : c, y = groupBy(x, "group"), [b, v] = useState(null);
6581
6995
  useEffect(() => {
6582
- if (isEmpty(keys(k))) {
6583
- S(null);
6996
+ if (isEmpty(keys(y))) {
6997
+ v(null);
6584
6998
  return;
6585
6999
  }
6586
- if (!b || !k[b]) {
6587
- S(first(keys(k)));
7000
+ if (!b || !y[b]) {
7001
+ v(first(keys(y)));
6588
7002
  return;
6589
7003
  }
6590
- }, [k, b]);
6591
- const w = get(k, b, []), B = useRef(null), { t: _ } = useTranslation(), E = (y) => {
6592
- B.current && (clearTimeout(B.current), B.current = null), B.current = setTimeout(() => {
6593
- B.current && S(y);
7004
+ }, [y, b]);
7005
+ const A = get(y, b, []), w = useRef(null), { t: E } = useTranslation(), _ = (k) => {
7006
+ w.current && (clearTimeout(w.current), w.current = null), w.current = setTimeout(() => {
7007
+ w.current && v(k);
6594
7008
  }, 400);
6595
- }, v = () => {
7009
+ }, S = () => {
6596
7010
  i != null && i.id && p(i.id);
6597
- }, A = () => {
7011
+ }, B = () => {
6598
7012
  g("");
6599
7013
  };
6600
7014
  if (d)
@@ -6602,23 +7016,23 @@ const BlockCard = ({
6602
7016
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
6603
7017
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
6604
7018
  ] });
6605
- const N = filter(w, (y, j) => j % 2 === 0), C = filter(w, (y, j) => j % 2 === 1);
7019
+ const N = filter(A, (k, j) => j % 2 === 0), C = filter(A, (k, j) => j % 2 === 1);
6606
7020
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
6607
7021
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
6608
7022
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
6609
7023
  /* @__PURE__ */ jsx(
6610
7024
  Input$1,
6611
7025
  {
6612
- placeholder: _("Search blocks..."),
7026
+ placeholder: E("Search blocks..."),
6613
7027
  value: u,
6614
- onChange: (y) => g(y.target.value),
7028
+ onChange: (k) => g(k.target.value),
6615
7029
  className: "w-full pl-8 pr-8"
6616
7030
  }
6617
7031
  ),
6618
7032
  u && /* @__PURE__ */ jsx(
6619
7033
  "button",
6620
7034
  {
6621
- onClick: A,
7035
+ onClick: B,
6622
7036
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
6623
7037
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
6624
7038
  }
@@ -6628,27 +7042,27 @@ const BlockCard = ({
6628
7042
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 min-w-60 max-w-60 flex-col gap-1 px-1 pr-2", children: [
6629
7043
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: i == null ? void 0 : i.id, setLibrary: a, uiLibraries: l }),
6630
7044
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
6631
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: _("Groups") }),
7045
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: E("Groups") }),
6632
7046
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
6633
- /* @__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: [
6634
- /* @__PURE__ */ jsx("p", { className: "text-sm", children: _("Failed to load the UI library. Try again") }),
6635
- /* @__PURE__ */ jsxs(Button, { onClick: v, variant: "outline", size: "sm", className: "gap-2", children: [
7047
+ /* @__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: E("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7048
+ /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("Failed to load the UI library. Try again") }),
7049
+ /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
6636
7050
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
6637
- _("Retry")
7051
+ E("Retry")
6638
7052
  ] })
6639
- ] }) }) : map(k, (y, j) => /* @__PURE__ */ jsxs(
7053
+ ] }) }) : map(y, (k, j) => /* @__PURE__ */ jsxs(
6640
7054
  "div",
6641
7055
  {
6642
- onMouseEnter: () => E(j),
6643
- onMouseLeave: () => clearTimeout(B.current),
7056
+ onMouseEnter: () => _(j),
7057
+ onMouseLeave: () => clearTimeout(w.current),
6644
7058
  role: "button",
6645
- onClick: () => S(j),
6646
- className: cn$1(
7059
+ onClick: () => v(j),
7060
+ className: cn$2(
6647
7061
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
6648
7062
  j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
6649
7063
  ),
6650
7064
  children: [
6651
- /* @__PURE__ */ jsx("span", { children: capitalize(_(j.toLowerCase())) }),
7065
+ /* @__PURE__ */ jsx("span", { children: capitalize(E(j.toLowerCase())) }),
6652
7066
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
6653
7067
  ]
6654
7068
  },
@@ -6659,26 +7073,26 @@ const BlockCard = ({
6659
7073
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
6660
7074
  ScrollArea,
6661
7075
  {
6662
- onMouseEnter: () => B.current ? clearTimeout(B.current) : null,
7076
+ onMouseEnter: () => w.current ? clearTimeout(w.current) : null,
6663
7077
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
6664
7078
  children: [
6665
- isEmpty(w) && !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: [
6666
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((y, j) => /* @__PURE__ */ jsx(
7079
+ isEmpty(A) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: E("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7080
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: N.map((k, j) => /* @__PURE__ */ jsx(
6667
7081
  BlockCard,
6668
7082
  {
6669
7083
  parentId: o,
6670
7084
  position: r,
6671
- block: y,
7085
+ block: k,
6672
7086
  library: i
6673
7087
  },
6674
7088
  `block-${j}`
6675
7089
  )) }),
6676
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((y, j) => /* @__PURE__ */ jsx(
7090
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((k, j) => /* @__PURE__ */ jsx(
6677
7091
  BlockCard,
6678
7092
  {
6679
7093
  parentId: o,
6680
7094
  position: r,
6681
- block: y,
7095
+ block: k,
6682
7096
  library: i
6683
7097
  },
6684
7098
  `block-second-${j}`
@@ -6717,15 +7131,15 @@ const BlockCard = ({
6717
7131
  error: c
6718
7132
  }), g(!0);
6719
7133
  else if (!l && Object.keys(a || {}).length > 0) {
6720
- const h = Object.entries(a).map(([x, k]) => {
6721
- const b = k, S = b.type || "partial", w = formatReadableName(S);
7134
+ const h = Object.entries(a).map(([x, y]) => {
7135
+ const b = y, v = b.type || "partial", A = formatReadableName(v);
6722
7136
  return {
6723
7137
  type: "PartialBlock",
6724
7138
  // Set the type to PartialBlock
6725
7139
  label: formatReadableName(b.name || x),
6726
7140
  description: b.description || "",
6727
7141
  icon: Globe,
6728
- group: w,
7142
+ group: A,
6729
7143
  // Use formatted type as group
6730
7144
  category: "partial",
6731
7145
  partialBlockId: x,
@@ -6781,43 +7195,43 @@ const BlockCard = ({
6781
7195
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
6782
7196
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
6783
7197
  var C;
6784
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (y) => y._id === n)) == null ? void 0 : C._type, [h, f] = useState("all"), [x, k] = useState(null), b = useRef(null);
7198
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (C = find(c, (k) => k._id === n)) == null ? void 0 : C._type, [h, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
6785
7199
  useEffect(() => {
6786
- const y = setTimeout(() => {
7200
+ const k = setTimeout(() => {
6787
7201
  var j;
6788
7202
  (j = u.current) == null || j.focus();
6789
7203
  }, 0);
6790
- return () => clearTimeout(y);
7204
+ return () => clearTimeout(k);
6791
7205
  }, [g]), useEffect(() => {
6792
- d && (f("all"), k(null));
6793
- }, [d]), useEffect(() => (b.current = debounce((y) => {
6794
- f(y);
7206
+ d && (f("all"), y(null));
7207
+ }, [d]), useEffect(() => (b.current = debounce((k) => {
7208
+ f(k);
6795
7209
  }, 500), () => {
6796
7210
  b.current && b.current.cancel();
6797
7211
  }), []);
6798
- const S = useCallback((y) => {
6799
- k(y), b.current && b.current(y);
6800
- }, []), w = useCallback(() => {
6801
- k(null), b.current && b.current.cancel();
6802
- }, []), B = useCallback((y) => {
6803
- b.current && b.current.cancel(), f(y), k(null);
6804
- }, []), _ = useMemo(
7212
+ const v = useCallback((k) => {
7213
+ y(k), b.current && b.current(k);
7214
+ }, []), A = useCallback(() => {
7215
+ y(null), b.current && b.current.cancel();
7216
+ }, []), w = useCallback((k) => {
7217
+ b.current && b.current.cancel(), f(k), y(null);
7218
+ }, []), E = useMemo(
6805
7219
  () => d ? values(r).filter(
6806
- (y) => {
7220
+ (k) => {
6807
7221
  var j, T;
6808
- return (((j = y.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = y.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7222
+ return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
6809
7223
  }
6810
7224
  ) : r,
6811
7225
  [r, d]
6812
- ), E = useMemo(
7226
+ ), _ = useMemo(
6813
7227
  () => d ? o.filter(
6814
- (y) => reject(filter(values(_), { group: y }), { hidden: !0 }).length > 0
6815
- ) : o.filter((y) => reject(filter(values(r), { group: y }), { hidden: !0 }).length > 0),
6816
- [r, _, o, d]
6817
- ), v = useMemo(
6818
- () => sortBy(E, (y) => CORE_GROUPS.indexOf(y) === -1 ? 99 : CORE_GROUPS.indexOf(y)),
6819
- [E]
6820
- ), A = useMemo(() => h === "all" ? _ : filter(values(_), { group: h }), [_, h]), N = useMemo(() => h === "all" ? v : [h], [v, h]);
7228
+ (k) => reject(filter(values(E), { group: k }), { hidden: !0 }).length > 0
7229
+ ) : o.filter((k) => reject(filter(values(r), { group: k }), { hidden: !0 }).length > 0),
7230
+ [r, E, o, d]
7231
+ ), S = useMemo(
7232
+ () => sortBy(_, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7233
+ [_]
7234
+ ), B = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
6821
7235
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
6822
7236
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
6823
7237
  Input$1,
@@ -6827,43 +7241,43 @@ const BlockCard = ({
6827
7241
  placeholder: i("Search blocks..."),
6828
7242
  value: d,
6829
7243
  className: "-ml-2",
6830
- onChange: (y) => p(y.target.value)
7244
+ onChange: (k) => p(k.target.value)
6831
7245
  }
6832
7246
  ) }),
6833
7247
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
6834
- v.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7248
+ S.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
6835
7249
  /* @__PURE__ */ jsx(
6836
7250
  "button",
6837
7251
  {
6838
- onClick: () => B("all"),
6839
- onMouseEnter: () => S("all"),
6840
- onMouseLeave: w,
7252
+ onClick: () => w("all"),
7253
+ onMouseEnter: () => v("all"),
7254
+ onMouseLeave: A,
6841
7255
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
6842
7256
  children: i("All")
6843
7257
  },
6844
7258
  "sidebar-all"
6845
7259
  ),
6846
- v.map((y) => /* @__PURE__ */ jsx(
7260
+ S.map((k) => /* @__PURE__ */ jsx(
6847
7261
  "button",
6848
7262
  {
6849
- onClick: () => B(y),
6850
- onMouseEnter: () => S(y),
6851
- onMouseLeave: w,
6852
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === y || x === y ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
6853
- children: capitalize(i(y.toLowerCase()))
7263
+ onClick: () => w(k),
7264
+ onMouseEnter: () => v(k),
7265
+ onMouseLeave: A,
7266
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7267
+ children: capitalize(i(k.toLowerCase()))
6854
7268
  },
6855
- `sidebar-${y}`
7269
+ `sidebar-${k}`
6856
7270
  ))
6857
7271
  ] }) }) }),
6858
- /* @__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: [
7272
+ /* @__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: _.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: [
6859
7273
  i("No blocks found matching"),
6860
7274
  ' "',
6861
7275
  d,
6862
7276
  '"'
6863
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((y) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
6864
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(y.toLowerCase())) }),
7277
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7278
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
6865
7279
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
6866
- h === "all" ? filter(values(A), { group: y }) : values(A),
7280
+ h === "all" ? filter(values(B), { group: k }) : values(B),
6867
7281
  { hidden: !0 }
6868
7282
  ).map((j) => /* @__PURE__ */ jsx(
6869
7283
  CoreBlock,
@@ -6875,7 +7289,7 @@ const BlockCard = ({
6875
7289
  },
6876
7290
  j.type
6877
7291
  )) })
6878
- ] }, y)) }) }) })
7292
+ ] }, k)) }) }) })
6879
7293
  ] })
6880
7294
  ] });
6881
7295
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -6893,7 +7307,7 @@ const BlockCard = ({
6893
7307
  }, []), f = useChaiAddBlockTabs(), x = p && m(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
6894
7308
  return useEffect(() => {
6895
7309
  i === "library" && !b && c("core");
6896
- }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
7310
+ }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
6897
7311
  r ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
6898
7312
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
6899
7313
  /* @__PURE__ */ jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: l(i === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
@@ -6901,8 +7315,8 @@ const BlockCard = ({
6901
7315
  /* @__PURE__ */ jsxs(
6902
7316
  Tabs,
6903
7317
  {
6904
- onValueChange: (S) => {
6905
- d(""), c(S);
7318
+ onValueChange: (v) => {
7319
+ d(""), c(v);
6906
7320
  },
6907
7321
  value: i,
6908
7322
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -6912,13 +7326,13 @@ const BlockCard = ({
6912
7326
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
6913
7327
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
6914
7328
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
6915
- map(f, (S) => /* @__PURE__ */ jsx(TabsTrigger, { value: S.id, children: React__default.createElement(S.tab) }, `tab-add-block-${S.id}`))
7329
+ map(f, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
6916
7330
  ] }),
6917
7331
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
6918
7332
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
6919
7333
  g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
6920
7334
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
6921
- map(f, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: h, parentId: n, position: a }) }, `panel-add-block-${S.id}`))
7335
+ map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: h, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
6922
7336
  ]
6923
7337
  }
6924
7338
  )
@@ -7225,26 +7639,26 @@ const Input = ({ node: o }) => {
7225
7639
  var P;
7226
7640
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7227
7641
  let p = null;
7228
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: k, isDragging: b, isEditing: S, handleClick: w } = o, B = (L) => {
7642
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: A } = o, w = (L) => {
7229
7643
  L.stopPropagation(), !l.includes(h) && o.toggle();
7230
- }, _ = (L) => {
7231
- L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7232
7644
  }, E = (L) => {
7645
+ L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7646
+ }, _ = (L) => {
7233
7647
  L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
7234
- }, [v, A] = useAtom$1(currentAddSelection), N = () => {
7648
+ }, [S, B] = useAtom$1(currentAddSelection), N = () => {
7235
7649
  var L;
7236
- C(), o.parent.isSelected || A((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7650
+ C(), o.parent.isSelected || B((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7237
7651
  }, C = () => {
7238
- A(null);
7239
- }, y = (L) => {
7240
- C(), L.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), w(L);
7652
+ B(null);
7653
+ }, k = (L) => {
7654
+ C(), L.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), A(L);
7241
7655
  };
7242
7656
  useEffect(() => {
7243
7657
  const L = setTimeout(() => {
7244
- k && !o.isOpen && !b && !l.includes(h) && o.toggle();
7658
+ y && !o.isOpen && !b && !l.includes(h) && o.toggle();
7245
7659
  }, 500);
7246
7660
  return () => clearTimeout(L);
7247
- }, [k, o, b]);
7661
+ }, [y, o, b]);
7248
7662
  const j = (L, D) => {
7249
7663
  const O = c.contentDocument || c.contentWindow.document, R = O.querySelector(`[data-block-id=${L}]`);
7250
7664
  R && R.setAttribute("data-drop", D);
@@ -7279,12 +7693,12 @@ const Input = ({ node: o }) => {
7279
7693
  {
7280
7694
  onMouseEnter: () => g(h),
7281
7695
  onMouseLeave: () => m(),
7282
- onClick: y,
7696
+ onClick: k,
7283
7697
  style: r,
7284
7698
  "data-node-id": h,
7285
7699
  ref: l.includes(h) ? null : n,
7286
- onDragStart: () => _(o),
7287
- onDragEnd: () => E(o),
7700
+ onDragStart: () => E(o),
7701
+ onDragEnd: () => _(o),
7288
7702
  onDragOver: (L) => {
7289
7703
  L.preventDefault(), j(h, "yes");
7290
7704
  },
@@ -7313,8 +7727,8 @@ const Input = ({ node: o }) => {
7313
7727
  className: cn(
7314
7728
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
7315
7729
  x ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
7316
- k && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7317
- (o == null ? void 0 : o.id) === v ? "bg-primary/10" : "",
7730
+ y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7731
+ (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7318
7732
  b && "opacity-20",
7319
7733
  l.includes(h) ? "opacity-50" : "",
7320
7734
  I && x && "bg-primary/20 text-primary"
@@ -7325,7 +7739,7 @@ const Input = ({ node: o }) => {
7325
7739
  "div",
7326
7740
  {
7327
7741
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7328
- children: u && /* @__PURE__ */ jsx("button", { onClick: B, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-white" : "text-slate-400"}` }) })
7742
+ children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${x ? "text-white" : "text-slate-400"}` }) })
7329
7743
  }
7330
7744
  ),
7331
7745
  /* @__PURE__ */ jsxs(
@@ -7338,7 +7752,7 @@ const Input = ({ node: o }) => {
7338
7752
  ),
7339
7753
  children: [
7340
7754
  /* @__PURE__ */ jsx(TypeIcon, { type: f == null ? void 0 : f._type }),
7341
- S ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7755
+ v ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7342
7756
  "div",
7343
7757
  {
7344
7758
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -7512,7 +7926,7 @@ const Input = ({ node: o }) => {
7512
7926
  }
7513
7927
  )
7514
7928
  ] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7515
- /* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
7929
+ /* @__PURE__ */ jsx("div", { className: cn$2("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
7516
7930
  "div",
7517
7931
  {
7518
7932
  id: "outline-view ",
@@ -7644,66 +8058,66 @@ const Input = ({ node: o }) => {
7644
8058
  )
7645
8059
  ] });
7646
8060
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
7647
- const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (S) => {
7648
- a(S);
8061
+ const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), m = (v) => {
8062
+ a(v);
7649
8063
  }, h = () => {
7650
- const S = l.find((w) => Object.keys(w)[0] === n);
7651
- if (S) {
7652
- const w = Object.values(S)[0];
7653
- w && typeof w == "object" && "fontFamily" in w && "borderRadius" in w && "colors" in w ? p(w) : console.error("Invalid preset structure:", w);
8064
+ const v = l.find((A) => Object.keys(A)[0] === n);
8065
+ if (v) {
8066
+ const A = Object.values(v)[0];
8067
+ A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? p(A) : console.error("Invalid preset structure:", A);
7654
8068
  } else
7655
8069
  console.error("Preset not found:", n);
7656
8070
  }, f = useDebouncedCallback(
7657
- (S, w) => {
8071
+ (v, A) => {
7658
8072
  p(() => ({
7659
8073
  ...d,
7660
8074
  fontFamily: {
7661
8075
  ...d.fontFamily,
7662
- [S.replace(/font-/g, "")]: w
8076
+ [v.replace(/font-/g, "")]: A
7663
8077
  }
7664
8078
  }));
7665
8079
  },
7666
8080
  [d],
7667
8081
  200
7668
8082
  ), x = useDebouncedCallback(
7669
- (S) => {
8083
+ (v) => {
7670
8084
  p(() => ({
7671
8085
  ...d,
7672
- borderRadius: `${S}px`
8086
+ borderRadius: `${v}px`
7673
8087
  }));
7674
8088
  },
7675
8089
  [d],
7676
8090
  200
7677
- ), k = useDebouncedCallback(
7678
- (S, w) => {
8091
+ ), y = useDebouncedCallback(
8092
+ (v, A) => {
7679
8093
  p(() => {
7680
- const B = get(d, `colors.${S}`);
7681
- return r ? set(B, 1, w) : set(B, 0, w), {
8094
+ const w = get(d, `colors.${v}`);
8095
+ return r ? set(w, 1, A) : set(w, 0, A), {
7682
8096
  ...d,
7683
8097
  colors: {
7684
8098
  ...d.colors,
7685
- [S]: B
8099
+ [v]: w
7686
8100
  }
7687
8101
  };
7688
8102
  });
7689
8103
  },
7690
8104
  [d],
7691
8105
  200
7692
- ), b = (S) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(S.items).map(([w]) => {
7693
- const B = get(d, `colors.${w}.${r ? 1 : 0}`);
8106
+ ), b = (v) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(v.items).map(([A]) => {
8107
+ const w = get(d, `colors.${A}.${r ? 1 : 0}`);
7694
8108
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
7695
8109
  /* @__PURE__ */ jsx(
7696
8110
  ColorPickerInput,
7697
8111
  {
7698
- value: B,
7699
- onChange: (_) => k(w, _)
8112
+ value: w,
8113
+ onChange: (E) => y(A, E)
7700
8114
  }
7701
8115
  ),
7702
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: w.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((_) => _.charAt(0).toUpperCase() + _.slice(1)).join(" ") + (!w.toLowerCase().includes("foreground") && !w.toLowerCase().includes("border") && !w.toLowerCase().includes("input") && !w.toLowerCase().includes("ring") && !w.toLowerCase().includes("background") ? " Background" : "") })
7703
- ] }, w);
8116
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
8117
+ ] }, A);
7704
8118
  }) });
7705
8119
  return c("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7706
- /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8120
+ /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
7707
8121
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
7708
8122
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
7709
8123
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Presets") }),
@@ -7711,11 +8125,11 @@ const Input = ({ node: o }) => {
7711
8125
  "select",
7712
8126
  {
7713
8127
  value: n,
7714
- onChange: (S) => m(S.target.value),
8128
+ onChange: (v) => m(v.target.value),
7715
8129
  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",
7716
8130
  children: [
7717
8131
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
7718
- Array.isArray(l) && l.map((S) => /* @__PURE__ */ jsx("option", { value: Object.keys(S)[0], children: capitalize(Object.keys(S)[0]) }, Object.keys(S)[0]))
8132
+ Array.isArray(l) && l.map((v) => /* @__PURE__ */ jsx("option", { value: Object.keys(v)[0], children: capitalize(Object.keys(v)[0]) }, Object.keys(v)[0]))
7719
8133
  ]
7720
8134
  }
7721
8135
  )
@@ -7731,15 +8145,15 @@ const Input = ({ node: o }) => {
7731
8145
  }
7732
8146
  ) })
7733
8147
  ] }),
7734
- /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
7735
- (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([S, w]) => /* @__PURE__ */ jsx(
8148
+ /* @__PURE__ */ jsxs("div", { className: cn$2("space-y-2", o), children: [
8149
+ (u == null ? void 0 : u.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(u.fontFamily).map(([v, A]) => /* @__PURE__ */ jsx(
7736
8150
  FontSelector,
7737
8151
  {
7738
- label: S,
7739
- value: d.fontFamily[S.replace(/font-/g, "")] || w[Object.keys(w)[0]],
7740
- onChange: (B) => f(S, B)
8152
+ label: v,
8153
+ value: d.fontFamily[v.replace(/font-/g, "")] || A[Object.keys(A)[0]],
8154
+ onChange: (w) => f(v, w)
7741
8155
  },
7742
- S
8156
+ v
7743
8157
  )) }),
7744
8158
  (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
7745
8159
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Border Radius") }),
@@ -7750,7 +8164,7 @@ const Input = ({ node: o }) => {
7750
8164
  ] }),
7751
8165
  (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
7752
8166
  /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Colors") }),
7753
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((S) => b(S)) }, r ? "dark" : "light")
8167
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((v) => b(v)) }, r ? "dark" : "light")
7754
8168
  ] })
7755
8169
  ] }),
7756
8170
  /* @__PURE__ */ jsx("br", {}),
@@ -7759,7 +8173,7 @@ const Input = ({ node: o }) => {
7759
8173
  /* @__PURE__ */ jsx("br", {})
7760
8174
  ] }),
7761
8175
  i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
7762
- ] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
8176
+ ] }) : /* @__PURE__ */ jsx("div", { className: "relative w-full", children: /* @__PURE__ */ jsx("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto text-center", o), children: /* @__PURE__ */ jsx("div", { className: "mt-10 h-full items-center justify-center gap-2 text-muted-foreground", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: "You don't have permission to edit the theme. Please contact your administrator to get access." }) }) }) });
7763
8177
  }), Core = "Core", Import = "Import", Breakpoints = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = { heading_font: "Heading Font", body_font: "Body Font", rounded_corner: "Rounded Corners", primary: "Primary", secondary: "Secondary", background: "Background", text_color: "Text Color", background_dark_mode: "Background (Dark Mode)", text_color_dark_mode: "Text Color (Dark Mode)" }, web_blocks = { box: "box", tag: "Tag", div: "div", level: "Level", header: "header", footer: "footer", section: "section", article: "article", aside: "aside", main: "main", nav: "navigation", figure: "figure", details: "details", summary: "summary", dialog: "dialog", strike: "strike", caption: "caption", legend: "legend", figcaption: "figure caption", mark: "mark", background_image: "Background Image", label: "Label", default: "default", icon_size: "Icon Size", icon_position: "Icon Position", start: "Start", end: "End", button: "Button", custom_html: "Custom HTML", html_code: "HTML Code", default_snippet: "The HTML snippet goes here...", placeholder: "Enter custom HTML code here", custom_script: "Custom Script", dark_mode: "Dark Mode", divider: "Divider", empty_box: "Empty Box", heading: "Heading", image: "Image", alt: "Alt", width: "Width", height: "Height", video: "Video", span: "Span", content: "Content", icon: "Icon", richtext: "Rich Text", list: "List", list_type: "List Type", listitem: "List Item", link: "Link", list_item: "List Item", none: "None", disc: "Disc", number: "Number", paragraph: "Paragraph", lightbox_link: "Lightbox Link", href: "Link", type: "Type", iframe: "iframe", inline: "inline", ajax: "ajax", autoplay: "Video autoplay", max_width: "Max Width", backdrop_color: "Background Color", gallery_name: "Gallery Name", slot: "Slot", empty_slot: "Empty Slot", text: "Text", video_url: "Video URL", controls: "Show Controls", loop: "Loop", muted: "Muted", checkbox: "Checkbox", required: "Required", checked: "Checked", submit_button: "Submit Button", form: "Form", submit_url: "Submit URL", error_message: "Error Message", success_message: "Success Message", input: "Input", value: "Value", show_label: "Show Label", field_name: "Field Name", radio: "Radio", multiple: "Multiple", options: "Options", select: "Select", multiple_choice: "Multiple Choice", textarea: "Textarea", rows: "Rows" }, Undo = "Undo", Redo = "Redo", Duplicate = "Duplicate", Close = "Close", Selected = "Selected", Select = "Select", Attributes = "Attributes", apply = "apply", presets = "presets", Orientation = "Orientation", Color = "Color", Upload = "Upload", lngEn = {
7764
8178
  "Add block": "Add Block",
7765
8179
  "Add blocks": "Add blocks",
@@ -8226,8 +8640,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8226
8640
  (x = m.current) == null || x.focus();
8227
8641
  }, []);
8228
8642
  const f = (x) => {
8229
- const { usage: k } = x || {};
8230
- !l && k && g(k), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8643
+ const { usage: y } = x || {};
8644
+ !l && y && g(y), h.current = setTimeout(() => g(void 0), 1e4), l || c("");
8231
8645
  };
8232
8646
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8233
8647
  /* @__PURE__ */ jsxs(
@@ -8449,31 +8863,31 @@ function AIChatPanel() {
8449
8863
  content: n,
8450
8864
  timestamp: /* @__PURE__ */ new Date()
8451
8865
  };
8452
- r((S) => [...S, b]), a(""), i(!0), setTimeout(() => {
8453
- const S = {
8866
+ r((v) => [...v, b]), a(""), i(!0), setTimeout(() => {
8867
+ const v = {
8454
8868
  id: (Date.now() + 1).toString(),
8455
8869
  role: "assistant",
8456
8870
  content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
8457
8871
  timestamp: /* @__PURE__ */ new Date()
8458
8872
  };
8459
- r((w) => [...w, S]), i(!1), d(null);
8873
+ r((A) => [...A, v]), i(!1), d(null);
8460
8874
  }, 1500);
8461
8875
  }, h = (b) => {
8462
8876
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), m());
8463
8877
  }, f = (b) => {
8464
- var w;
8465
- const S = (w = b.target.files) == null ? void 0 : w[0];
8466
- if (S) {
8467
- const B = new FileReader();
8468
- B.onload = (_) => {
8469
- var E;
8470
- d((E = _.target) == null ? void 0 : E.result);
8471
- }, B.readAsDataURL(S);
8878
+ var A;
8879
+ const v = (A = b.target.files) == null ? void 0 : A[0];
8880
+ if (v) {
8881
+ const w = new FileReader();
8882
+ w.onload = (E) => {
8883
+ var _;
8884
+ d((_ = E.target) == null ? void 0 : _.result);
8885
+ }, w.readAsDataURL(v);
8472
8886
  }
8473
8887
  }, x = () => {
8474
8888
  var b;
8475
8889
  (b = p.current) == null || b.click();
8476
- }, k = () => {
8890
+ }, y = () => {
8477
8891
  d(null), p.current && (p.current.value = "");
8478
8892
  };
8479
8893
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -8484,7 +8898,7 @@ function AIChatPanel() {
8484
8898
  o.map((b) => /* @__PURE__ */ jsxs(
8485
8899
  "div",
8486
8900
  {
8487
- className: cn$2(
8901
+ className: cn$1(
8488
8902
  "flex max-w-full gap-2",
8489
8903
  b.role === "assistant" ? "items-start" : "items-start justify-end"
8490
8904
  ),
@@ -8493,7 +8907,7 @@ function AIChatPanel() {
8493
8907
  /* @__PURE__ */ jsx(
8494
8908
  "div",
8495
8909
  {
8496
- className: cn$2(
8910
+ className: cn$1(
8497
8911
  "rounded-lg px-3 py-2 text-sm",
8498
8912
  b.role === "assistant" ? "bg-muted text-foreground" : "bg-primary text-primary-foreground"
8499
8913
  ),
@@ -8519,7 +8933,7 @@ function AIChatPanel() {
8519
8933
  size: "icon",
8520
8934
  variant: "destructive",
8521
8935
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
8522
- onClick: k,
8936
+ onClick: y,
8523
8937
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
8524
8938
  }
8525
8939
  )
@@ -8608,7 +9022,7 @@ const AiAssistant = () => {
8608
9022
  }, DataBinding = () => {
8609
9023
  const o = usePageExternalData(), [r, n] = useAtom$1(dataBindingActiveAtom), { t: a } = useTranslation();
8610
9024
  return isEmpty(o) ? null : /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
8611
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "rounded-full", variant: "ghost", onClick: () => n(!r), children: /* @__PURE__ */ jsx(DatabaseZapIcon, { className: cn$1("h-4 w-4", r ? "text-green-500" : "text-gray-500") }) }) }),
9025
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "rounded-full", variant: "ghost", onClick: () => n(!r), children: /* @__PURE__ */ jsx(DatabaseZapIcon, { className: cn$2("h-4 w-4", r ? "text-green-500" : "text-gray-500") }) }) }),
8612
9026
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
8613
9027
  ] }) });
8614
9028
  }, CanvasTopBar = () => {
@@ -8638,14 +9052,7 @@ const AiAssistant = () => {
8638
9052
  r ? null : /* @__PURE__ */ jsx(AiAssistant, {})
8639
9053
  ] })
8640
9054
  ] });
8641
- };
8642
- function usePubSub(o, r) {
8643
- useEffect(() => {
8644
- const n = pubsub.subscribe(o, r);
8645
- return () => n();
8646
- }, [o, r]);
8647
- }
8648
- const AddBlocksDialog = () => {
9055
+ }, AddBlocksDialog = () => {
8649
9056
  const { t: o } = useTranslation(), [r, n] = useState(""), [a, l] = useState(-1), [i, c] = useState(!1);
8650
9057
  return usePubSub(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, (d) => {
8651
9058
  n(d ? d._id : null), l(isNaN(d == null ? void 0 : d.position) ? -1 : d == null ? void 0 : d.position), c(!0);
@@ -8669,7 +9076,7 @@ const AddBlocksDialog = () => {
8669
9076
  preloadedAttributes: r = [],
8670
9077
  onAttributesChange: n
8671
9078
  }) {
8672
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), k = usePageExternalData();
9079
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, h] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
8673
9080
  useEffect(() => {
8674
9081
  l(r);
8675
9082
  }, [r]);
@@ -8679,43 +9086,43 @@ const AddBlocksDialog = () => {
8679
9086
  return;
8680
9087
  }
8681
9088
  if (i) {
8682
- const v = [...a, { key: i, value: d }];
8683
- n(v), l(a), c(""), p(""), h("");
9089
+ const S = [...a, { key: i, value: d }];
9090
+ n(S), l(a), c(""), p(""), h("");
8684
9091
  }
8685
- }, S = (v) => {
8686
- const A = a.filter((N, C) => C !== v);
8687
- n(A), l(A);
8688
- }, w = (v) => {
8689
- g(v), c(a[v].key), p(a[v].value);
8690
- }, B = () => {
9092
+ }, v = (S) => {
9093
+ const B = a.filter((N, C) => C !== S);
9094
+ n(B), l(B);
9095
+ }, A = (S) => {
9096
+ g(S), c(a[S].key), p(a[S].value);
9097
+ }, w = () => {
8691
9098
  if (i.startsWith("@")) {
8692
9099
  h("Attribute keys cannot start with '@'");
8693
9100
  return;
8694
9101
  }
8695
9102
  if (u !== null && i) {
8696
- const v = [...a];
8697
- v[u] = { key: i, value: d }, n(v), l(v), g(null), c(""), p(""), h("");
9103
+ const S = [...a];
9104
+ S[u] = { key: i, value: d }, n(S), l(S), g(null), c(""), p(""), h("");
8698
9105
  }
8699
- }, _ = (v) => {
8700
- v.key === "Enter" && !v.shiftKey && (v.preventDefault(), u !== null ? B() : b());
8701
- }, E = useCallback((v) => {
8702
- const A = (y) => /[.,!?;:]/.test(y), N = (y, j, T) => {
9106
+ }, E = (S) => {
9107
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
9108
+ }, _ = useCallback((S) => {
9109
+ const B = (k) => /[.,!?;:]/.test(k), N = (k, j, T) => {
8703
9110
  let I = "", P = "";
8704
- const L = j > 0 ? y[j - 1] : "", D = j < y.length ? y[j] : "";
8705
- return j > 0 && (L === "." || !A(L) && L !== " ") && (I = " "), j < y.length && !A(D) && D !== " " && (P = " "), {
9111
+ const L = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
9112
+ return j > 0 && (L === "." || !B(L) && L !== " ") && (I = " "), j < k.length && !B(D) && D !== " " && (P = " "), {
8706
9113
  text: I + T + P,
8707
9114
  prefixLength: I.length,
8708
9115
  suffixLength: P.length
8709
9116
  };
8710
9117
  }, C = x.current;
8711
9118
  if (C) {
8712
- const y = C.selectionStart || 0, j = C.value || "", T = C.selectionEnd || y;
8713
- if (T > y) {
8714
- const O = `{{${v}}}`, { text: R } = N(j, y, O), $ = j.slice(0, y) + R + j.slice(T);
9119
+ const k = C.selectionStart || 0, j = C.value || "", T = C.selectionEnd || k;
9120
+ if (T > k) {
9121
+ const O = `{{${S}}}`, { text: R } = N(j, k, O), $ = j.slice(0, k) + R + j.slice(T);
8715
9122
  p($);
8716
9123
  return;
8717
9124
  }
8718
- const P = `{{${v}}}`, { text: L } = N(j, y, P), D = j.slice(0, y) + L + j.slice(y);
9125
+ const P = `{{${S}}}`, { text: L } = N(j, k, P), D = j.slice(0, k) + L + j.slice(k);
8719
9126
  p(D);
8720
9127
  }
8721
9128
  }, []);
@@ -8723,8 +9130,8 @@ const AddBlocksDialog = () => {
8723
9130
  /* @__PURE__ */ jsxs(
8724
9131
  "form",
8725
9132
  {
8726
- onSubmit: (v) => {
8727
- v.preventDefault(), u !== null ? B() : b();
9133
+ onSubmit: (S) => {
9134
+ S.preventDefault(), u !== null ? w() : b();
8728
9135
  },
8729
9136
  className: "space-y-3",
8730
9137
  children: [
@@ -8740,7 +9147,7 @@ const AddBlocksDialog = () => {
8740
9147
  id: "attrKey",
8741
9148
  ref: f,
8742
9149
  value: i,
8743
- onChange: (v) => c(v.target.value),
9150
+ onChange: (S) => c(S.target.value),
8744
9151
  placeholder: "Enter Key",
8745
9152
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
8746
9153
  }
@@ -8749,7 +9156,7 @@ const AddBlocksDialog = () => {
8749
9156
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
8750
9157
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
8751
9158
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
8752
- !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: E })
9159
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: _ })
8753
9160
  ] }),
8754
9161
  /* @__PURE__ */ jsx(
8755
9162
  Textarea,
@@ -8761,8 +9168,8 @@ const AddBlocksDialog = () => {
8761
9168
  rows: 2,
8762
9169
  ref: x,
8763
9170
  value: d,
8764
- onChange: (v) => p(v.target.value),
8765
- onKeyDown: _,
9171
+ onChange: (S) => p(S.target.value),
9172
+ onKeyDown: E,
8766
9173
  placeholder: "Enter Value",
8767
9174
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
8768
9175
  }
@@ -8774,16 +9181,16 @@ const AddBlocksDialog = () => {
8774
9181
  ]
8775
9182
  }
8776
9183
  ),
8777
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((v, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9184
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8778
9185
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
8779
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: v.key }),
8780
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: v.value.toString() })
9186
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9187
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
8781
9188
  ] }),
8782
9189
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
8783
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
8784
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9190
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9191
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
8785
9192
  ] })
8786
- ] }, A)) })
9193
+ ] }, B)) })
8787
9194
  ] });
8788
9195
  }), BlockAttributesEditor = React.memo(() => {
8789
9196
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -8901,36 +9308,36 @@ const RootLayout = () => {
8901
9308
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
8902
9309
  n("outline");
8903
9310
  });
8904
- const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = useCallback((v) => {
8905
- v.preventDefault();
8906
- }, []), m = useCallback((v) => {
8907
- n(r === v ? null : v);
8908
- }, []), h = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...h, ...p], [h, p]), k = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), S = get(b, "width", DEFAULT_PANEL_WIDTH);
9311
+ const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = useCallback((S) => {
9312
+ S.preventDefault();
9313
+ }, []), m = useCallback((S) => {
9314
+ n(r === S ? null : S);
9315
+ }, []), h = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...h, ...p], [h, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
8909
9316
  useEffect(() => {
8910
9317
  if (r !== null) {
8911
- const v = find(x, { id: r });
8912
- v && get(v, "view", "standard") === "standard" && (a.current = r, i(get(v, "width", DEFAULT_PANEL_WIDTH)));
9318
+ const S = find(x, { id: r });
9319
+ S && get(S, "view", "standard") === "standard" && (a.current = r, i(get(S, "width", DEFAULT_PANEL_WIDTH)));
8913
9320
  }
8914
9321
  }, [r, x]);
8915
- const w = useMemo(() => {
9322
+ const A = useMemo(() => {
8916
9323
  if (r === null) return 0;
8917
- const v = find(x, { id: r });
8918
- return get(v, "view", "standard") === "standard" ? S : l;
8919
- }, [r, S, l, x]), B = useCallback(() => {
9324
+ const S = find(x, { id: r });
9325
+ return get(S, "view", "standard") === "standard" ? v : l;
9326
+ }, [r, v, l, x]), w = useCallback(() => {
8920
9327
  n(a.current);
8921
- }, [n]), _ = useCallback(() => {
9328
+ }, [n]), E = useCallback(() => {
8922
9329
  n("outline");
8923
9330
  }, [n]);
8924
9331
  useEffect(() => {
8925
9332
  find(x, { id: r }) || n("outline");
8926
9333
  }, [r, x]);
8927
- const E = useCallback(
8928
- (v) => {
8929
- m(v);
9334
+ const _ = useCallback(
9335
+ (S) => {
9336
+ m(S);
8930
9337
  },
8931
9338
  [m]
8932
9339
  );
8933
- 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: [
9340
+ 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: [
8934
9341
  /* @__PURE__ */ jsxs(
8935
9342
  "div",
8936
9343
  {
@@ -8940,33 +9347,33 @@ const RootLayout = () => {
8940
9347
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
8941
9348
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
8942
9349
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
8943
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((v, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8944
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(v, "button", NoopComponent), {
9350
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: x.map((S, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9351
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
8945
9352
  position: "top",
8946
- panelId: v.id,
8947
- isActive: r === v.id,
8948
- show: () => E(v.id)
9353
+ panelId: S.id,
9354
+ isActive: r === S.id,
9355
+ show: () => _(S.id)
8949
9356
  }) }),
8950
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(v.label) }) })
8951
- ] }, "button-top-" + A)) }),
9357
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
9358
+ ] }, "button-top-" + B)) }),
8952
9359
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
8953
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((v, A) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8954
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(v, "button", NoopComponent), {
9360
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: u == null ? void 0 : u.map((S, B) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9361
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(S, "button", NoopComponent), {
8955
9362
  position: "bottom",
8956
- panelId: v.id,
8957
- isActive: r === v.id,
8958
- show: () => E(v.id)
9363
+ panelId: S.id,
9364
+ isActive: r === S.id,
9365
+ show: () => _(S.id)
8959
9366
  }) }),
8960
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(v.label) }) })
8961
- ] }, "button-bottom-" + A)) })
9367
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(S.label) }) })
9368
+ ] }, "button-bottom-" + B)) })
8962
9369
  ] }),
8963
9370
  /* @__PURE__ */ jsx(
8964
9371
  motion.div,
8965
9372
  {
8966
9373
  id: "left-panel",
8967
9374
  className: "h-full max-h-full border-r border-border",
8968
- initial: { width: w },
8969
- animate: { width: w },
9375
+ initial: { width: A },
9376
+ animate: { width: A },
8970
9377
  transition: { duration: 0.3, ease: "easeInOut" },
8971
9378
  children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
8972
9379
  /* @__PURE__ */ jsx(
@@ -9017,23 +9424,23 @@ const RootLayout = () => {
9017
9424
  ] }) })
9018
9425
  }
9019
9426
  ),
9020
- r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${S}px` }, children: [
9427
+ r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(SheetContent, { side: "left", className: "p-0 sm:max-w-full", style: { width: `${v}px` }, children: [
9021
9428
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9022
9429
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9023
9430
  /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9024
9431
  ] }) }),
9025
9432
  /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9026
- close: _
9433
+ close: E
9027
9434
  }) }) })
9028
9435
  ] }) }),
9029
9436
  " ",
9030
- r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${S}px` }, children: [
9437
+ r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => w(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "p-0", style: { maxWidth: `${v}px` }, children: [
9031
9438
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border p-4 pb-2", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9032
9439
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9033
9440
  /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9034
9441
  ] }) }),
9035
9442
  /* @__PURE__ */ jsx("div", { className: "max-h-[70vh] overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9036
- close: _
9443
+ close: E
9037
9444
  }) }) })
9038
9445
  ] }) }),
9039
9446
  r !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
@@ -9058,10 +9465,10 @@ const RootLayout = () => {
9058
9465
  /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(b, "icon", null) }),
9059
9466
  /* @__PURE__ */ jsx("span", { children: f(get(b, "label", "")) })
9060
9467
  ] }),
9061
- /* @__PURE__ */ jsx(Button, { onClick: () => B(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9468
+ /* @__PURE__ */ jsx(Button, { onClick: () => w(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9062
9469
  ] }),
9063
9470
  /* @__PURE__ */ jsx("div", { className: "flex-1 overflow-y-auto p-4", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(b, "panel", NoopComponent), {
9064
- close: _
9471
+ close: E
9065
9472
  }) }) })
9066
9473
  ]
9067
9474
  }
@@ -9076,7 +9483,7 @@ const RootLayout = () => {
9076
9483
  ] }) });
9077
9484
  }, PreviewScreen = () => {
9078
9485
  const [o, r] = usePreviewMode(), { t: n } = useTranslation(), a = useBuilderProp("previewComponent", null);
9079
- return o ? /* @__PURE__ */ jsxs("div", { className: cn$1("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
9486
+ return o ? /* @__PURE__ */ jsxs("div", { className: cn$2("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
9080
9487
  /* @__PURE__ */ jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => r(!1), children: [
9081
9488
  /* @__PURE__ */ jsx(EyeClosedIcon, {}),
9082
9489
  /* @__PURE__ */ jsx("span", { children: n("Close Preview") })
@@ -9170,72 +9577,72 @@ const FEATURE_TOGGLES = {
9170
9577
  var x;
9171
9578
  return (x = h.onMount) == null ? void 0 : x.call(h, f);
9172
9579
  }, ...m) => {
9173
- const h = m[0] || ((A) => {
9174
- let N = o.get(A);
9175
- return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, v)), N;
9580
+ const h = m[0] || ((B) => {
9581
+ let N = o.get(B);
9582
+ return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(B, N), u == null || u(B, S)), N;
9176
9583
  }), f = m[1] || (() => {
9177
- let A, N;
9178
- const C = (y) => {
9584
+ let B, N;
9585
+ const C = (k) => {
9179
9586
  try {
9180
- y();
9587
+ k();
9181
9588
  } catch (j) {
9182
- A || (A = !0, N = j);
9589
+ B || (B = !0, N = j);
9183
9590
  }
9184
9591
  };
9185
9592
  do {
9186
9593
  c.f && C(c.f);
9187
- const y = /* @__PURE__ */ new Set(), j = y.add.bind(y);
9594
+ const k = /* @__PURE__ */ new Set(), j = k.add.bind(k);
9188
9595
  a.forEach((T) => {
9189
9596
  var I;
9190
9597
  return (I = r.get(T)) == null ? void 0 : I.l.forEach(j);
9191
- }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), y.forEach(C), a.size && x();
9598
+ }), a.clear(), i.forEach(j), i.clear(), l.forEach(j), l.clear(), k.forEach(C), a.size && x();
9192
9599
  } while (a.size || i.size || l.size);
9193
- if (A)
9600
+ if (B)
9194
9601
  throw N;
9195
9602
  }), x = m[2] || (() => {
9196
- const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), y = Array.from(a);
9197
- for (; y.length; ) {
9198
- const j = y[y.length - 1], T = h(j);
9603
+ const B = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9604
+ for (; k.length; ) {
9605
+ const j = k[k.length - 1], T = h(j);
9199
9606
  if (C.has(j)) {
9200
- y.pop();
9607
+ k.pop();
9201
9608
  continue;
9202
9609
  }
9203
9610
  if (N.has(j)) {
9204
- n.get(j) === T.n && A.push([j, T]), C.add(j), y.pop();
9611
+ n.get(j) === T.n && B.push([j, T]), C.add(j), k.pop();
9205
9612
  continue;
9206
9613
  }
9207
9614
  N.add(j);
9208
9615
  for (const I of getMountedOrPendingDependents(j, T, r))
9209
- N.has(I) || y.push(I);
9616
+ N.has(I) || k.push(I);
9210
9617
  }
9211
- for (let j = A.length - 1; j >= 0; --j) {
9212
- const [T, I] = A[j];
9618
+ for (let j = B.length - 1; j >= 0; --j) {
9619
+ const [T, I] = B[j];
9213
9620
  let P = !1;
9214
9621
  for (const L of I.d.keys())
9215
9622
  if (L !== T && a.has(L)) {
9216
9623
  P = !0;
9217
9624
  break;
9218
9625
  }
9219
- P && (k(T), w(T)), n.delete(T);
9626
+ P && (y(T), A(T)), n.delete(T);
9220
9627
  }
9221
- }), k = m[3] || ((A) => {
9628
+ }), y = m[3] || ((B) => {
9222
9629
  var N, C;
9223
- const y = h(A);
9224
- if (isAtomStateInitialized(y) && (r.has(A) && n.get(A) !== y.n || Array.from(y.d).every(
9630
+ const k = h(B);
9631
+ if (isAtomStateInitialized(k) && (r.has(B) && n.get(B) !== k.n || Array.from(k.d).every(
9225
9632
  ([R, $]) => (
9226
9633
  // Recursively, read the atom state of the dependency, and
9227
9634
  // check if the atom epoch number is unchanged
9228
- k(R).n === $
9635
+ y(R).n === $
9229
9636
  )
9230
9637
  )))
9231
- return y;
9232
- y.d.clear();
9638
+ return k;
9639
+ k.d.clear();
9233
9640
  let j = !0;
9234
9641
  const T = () => {
9235
- r.has(A) && (w(A), x(), f());
9642
+ r.has(B) && (A(B), x(), f());
9236
9643
  }, I = (R) => {
9237
9644
  var $;
9238
- if (isSelfAtom(A, R)) {
9645
+ if (isSelfAtom(B, R)) {
9239
9646
  const U = h(R);
9240
9647
  if (!isAtomStateInitialized(U))
9241
9648
  if (hasInitialValue(R))
@@ -9244,11 +9651,11 @@ const FEATURE_TOGGLES = {
9244
9651
  throw new Error("no atom init");
9245
9652
  return returnAtomValue(U);
9246
9653
  }
9247
- const M = k(R);
9654
+ const M = y(R);
9248
9655
  try {
9249
9656
  return returnAtomValue(M);
9250
9657
  } finally {
9251
- y.d.set(R, M.n), isPendingPromise(y.v) && addPendingPromiseToDependency(A, y.v, M), ($ = r.get(R)) == null || $.t.add(A), j || T();
9658
+ k.d.set(R, M.n), isPendingPromise(k.v) && addPendingPromiseToDependency(B, k.v, M), ($ = r.get(R)) == null || $.t.add(B), j || T();
9252
9659
  }
9253
9660
  };
9254
9661
  let P, L;
@@ -9257,100 +9664,100 @@ const FEATURE_TOGGLES = {
9257
9664
  return P || (P = new AbortController()), P.signal;
9258
9665
  },
9259
9666
  get setSelf() {
9260
- return !L && isActuallyWritableAtom(A) && (L = (...R) => {
9667
+ return !L && isActuallyWritableAtom(B) && (L = (...R) => {
9261
9668
  if (!j)
9262
9669
  try {
9263
- return S(A, ...R);
9670
+ return v(B, ...R);
9264
9671
  } finally {
9265
9672
  x(), f();
9266
9673
  }
9267
9674
  }), L;
9268
9675
  }
9269
- }, O = y.n;
9676
+ }, O = k.n;
9270
9677
  try {
9271
- const R = d(A, I, D);
9272
- return setAtomStateValueOrPromise(A, R, h), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
9678
+ const R = d(B, I, D);
9679
+ return setAtomStateValueOrPromise(B, R, h), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
9273
9680
  T,
9274
9681
  T
9275
- )), y;
9682
+ )), k;
9276
9683
  } catch (R) {
9277
- return delete y.v, y.e = R, ++y.n, y;
9684
+ return delete k.v, k.e = R, ++k.n, k;
9278
9685
  } finally {
9279
- j = !1, O !== y.n && n.get(A) === O && (n.set(A, y.n), a.add(A), (C = c.c) == null || C.call(c, A));
9686
+ j = !1, O !== k.n && n.get(B) === O && (n.set(B, k.n), a.add(B), (C = c.c) == null || C.call(c, B));
9280
9687
  }
9281
- }), b = m[4] || ((A) => {
9282
- const N = [A];
9688
+ }), b = m[4] || ((B) => {
9689
+ const N = [B];
9283
9690
  for (; N.length; ) {
9284
- const C = N.pop(), y = h(C);
9285
- for (const j of getMountedOrPendingDependents(C, y, r)) {
9691
+ const C = N.pop(), k = h(C);
9692
+ for (const j of getMountedOrPendingDependents(C, k, r)) {
9286
9693
  const T = h(j);
9287
9694
  n.set(j, T.n), N.push(j);
9288
9695
  }
9289
9696
  }
9290
- }), S = m[5] || ((A, ...N) => {
9697
+ }), v = m[5] || ((B, ...N) => {
9291
9698
  let C = !0;
9292
- const y = (T) => returnAtomValue(k(T)), j = (T, ...I) => {
9699
+ const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
9293
9700
  var P;
9294
9701
  const L = h(T);
9295
9702
  try {
9296
- if (isSelfAtom(A, T)) {
9703
+ if (isSelfAtom(B, T)) {
9297
9704
  if (!hasInitialValue(T))
9298
9705
  throw new Error("atom not writable");
9299
9706
  const D = L.n, O = I[0];
9300
- setAtomStateValueOrPromise(T, O, h), w(T), D !== L.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
9707
+ setAtomStateValueOrPromise(T, O, h), A(T), D !== L.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
9301
9708
  return;
9302
9709
  } else
9303
- return S(T, ...I);
9710
+ return v(T, ...I);
9304
9711
  } finally {
9305
9712
  C || (x(), f());
9306
9713
  }
9307
9714
  };
9308
9715
  try {
9309
- return p(A, y, j, ...N);
9716
+ return p(B, k, j, ...N);
9310
9717
  } finally {
9311
9718
  C = !1;
9312
9719
  }
9313
- }), w = m[6] || ((A) => {
9720
+ }), A = m[6] || ((B) => {
9314
9721
  var N;
9315
- const C = h(A), y = r.get(A);
9316
- if (y && !isPendingPromise(C.v)) {
9722
+ const C = h(B), k = r.get(B);
9723
+ if (k && !isPendingPromise(C.v)) {
9317
9724
  for (const [j, T] of C.d)
9318
- if (!y.d.has(j)) {
9725
+ if (!k.d.has(j)) {
9319
9726
  const I = h(j);
9320
- B(j).t.add(A), y.d.add(j), T !== I.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9727
+ w(j).t.add(B), k.d.add(j), T !== I.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9321
9728
  }
9322
- for (const j of y.d || [])
9729
+ for (const j of k.d || [])
9323
9730
  if (!C.d.has(j)) {
9324
- y.d.delete(j);
9325
- const T = _(j);
9326
- T == null || T.t.delete(A);
9731
+ k.d.delete(j);
9732
+ const T = E(j);
9733
+ T == null || T.t.delete(B);
9327
9734
  }
9328
9735
  }
9329
- }), B = m[7] || ((A) => {
9736
+ }), w = m[7] || ((B) => {
9330
9737
  var N;
9331
- const C = h(A);
9332
- let y = r.get(A);
9333
- if (!y) {
9334
- k(A);
9738
+ const C = h(B);
9739
+ let k = r.get(B);
9740
+ if (!k) {
9741
+ y(B);
9335
9742
  for (const j of C.d.keys())
9336
- B(j).t.add(A);
9337
- if (y = {
9743
+ w(j).t.add(B);
9744
+ if (k = {
9338
9745
  l: /* @__PURE__ */ new Set(),
9339
9746
  d: new Set(C.d.keys()),
9340
9747
  t: /* @__PURE__ */ new Set()
9341
- }, r.set(A, y), (N = c.m) == null || N.call(c, A), isActuallyWritableAtom(A)) {
9748
+ }, r.set(B, k), (N = c.m) == null || N.call(c, B), isActuallyWritableAtom(B)) {
9342
9749
  const j = () => {
9343
9750
  let T = !0;
9344
9751
  const I = (...P) => {
9345
9752
  try {
9346
- return S(A, ...P);
9753
+ return v(B, ...P);
9347
9754
  } finally {
9348
9755
  T || (x(), f());
9349
9756
  }
9350
9757
  };
9351
9758
  try {
9352
- const P = g(A, I);
9353
- P && (y.u = () => {
9759
+ const P = g(B, I);
9760
+ P && (k.u = () => {
9354
9761
  T = !0;
9355
9762
  try {
9356
9763
  P();
@@ -9365,24 +9772,24 @@ const FEATURE_TOGGLES = {
9365
9772
  l.add(j);
9366
9773
  }
9367
9774
  }
9368
- return y;
9369
- }), _ = m[8] || ((A) => {
9775
+ return k;
9776
+ }), E = m[8] || ((B) => {
9370
9777
  var N;
9371
- const C = h(A);
9372
- let y = r.get(A);
9373
- if (y && !y.l.size && !Array.from(y.t).some((j) => {
9778
+ const C = h(B);
9779
+ let k = r.get(B);
9780
+ if (k && !k.l.size && !Array.from(k.t).some((j) => {
9374
9781
  var T;
9375
- return (T = r.get(j)) == null ? void 0 : T.d.has(A);
9782
+ return (T = r.get(j)) == null ? void 0 : T.d.has(B);
9376
9783
  })) {
9377
- y.u && i.add(y.u), y = void 0, r.delete(A), (N = c.u) == null || N.call(c, A);
9784
+ k.u && i.add(k.u), k = void 0, r.delete(B), (N = c.u) == null || N.call(c, B);
9378
9785
  for (const j of C.d.keys()) {
9379
- const T = _(j);
9380
- T == null || T.t.delete(A);
9786
+ const T = E(j);
9787
+ T == null || T.t.delete(B);
9381
9788
  }
9382
9789
  return;
9383
9790
  }
9384
- return y;
9385
- }), E = [
9791
+ return k;
9792
+ }), _ = [
9386
9793
  // store state
9387
9794
  o,
9388
9795
  r,
@@ -9400,29 +9807,29 @@ const FEATURE_TOGGLES = {
9400
9807
  h,
9401
9808
  f,
9402
9809
  x,
9403
- k,
9810
+ y,
9404
9811
  b,
9405
- S,
9812
+ v,
9813
+ A,
9406
9814
  w,
9407
- B,
9408
- _
9409
- ], v = {
9410
- get: (A) => returnAtomValue(k(A)),
9411
- set: (A, ...N) => {
9815
+ E
9816
+ ], S = {
9817
+ get: (B) => returnAtomValue(y(B)),
9818
+ set: (B, ...N) => {
9412
9819
  try {
9413
- return S(A, ...N);
9820
+ return v(B, ...N);
9414
9821
  } finally {
9415
9822
  x(), f();
9416
9823
  }
9417
9824
  },
9418
- sub: (A, N) => {
9419
- const y = B(A).l;
9420
- return y.add(N), f(), () => {
9421
- y.delete(N), _(A), f();
9825
+ sub: (B, N) => {
9826
+ const k = w(B).l;
9827
+ return k.add(N), f(), () => {
9828
+ k.delete(N), E(B), f();
9422
9829
  };
9423
9830
  }
9424
9831
  };
9425
- return Object.defineProperty(v, BUILDING_BLOCKS, { value: E }), v;
9832
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: _ }), S;
9426
9833
  }, INTERNAL_buildStoreRev1 = buildStore, createStore = () => INTERNAL_buildStoreRev1();
9427
9834
  let defaultStore;
9428
9835
  const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), StoreContext = createContext(
@@ -9566,8 +9973,8 @@ export {
9566
9973
  getBlocksFromHTML as convertHTMLToChaiBlocks,
9567
9974
  generateUUID as generateBlockId,
9568
9975
  getBlocksFromHTML,
9569
- Fe as i18n,
9570
- cn$1 as mergeClasses,
9976
+ We as i18n,
9977
+ cn$2 as mergeClasses,
9571
9978
  registerBlockSettingField,
9572
9979
  registerBlockSettingTemplate,
9573
9980
  registerBlockSettingWidget,
@@ -9622,7 +10029,7 @@ export {
9622
10029
  useStylingState,
9623
10030
  useTheme,
9624
10031
  useThemeOptions,
9625
- Ue as useTranslation,
10032
+ Fe as useTranslation,
9626
10033
  useUILibraryBlocks,
9627
10034
  useUndoManager,
9628
10035
  useUpdateBlocksProps,