@chaibuilder/sdk 3.2.7 → 3.2.8

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.
@@ -1,6 +1,6 @@
1
- var J = Object.defineProperty;
2
- var X = (r, n, o) => n in r ? J(r, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[n] = o;
3
- var G = (r, n, o) => X(r, typeof n != "symbol" ? n + "" : n, o);
1
+ var ne = Object.defineProperty;
2
+ var se = (r, n, o) => n in r ? ne(r, n, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[n] = o;
3
+ var X = (r, n, o) => se(r, typeof n != "symbol" ? n + "" : n, o);
4
4
  import { jsxs, jsx, Fragment as Fragment$1 } from "react/jsx-runtime";
5
5
  import { getRegisteredChaiBlock, getDefaultBlockProps, syncBlocksWithDefaults, useRegisteredFonts, useRegisteredChaiBlocks, getBlockFormSchemas } from "@chaibuilder/runtime";
6
6
  import { has, get, filter, findIndex, find, flatten, map, includes, without, compact, isEmpty, isString, each, omit, values, pick, startsWith, isFunction as isFunction$1, isObject as isObject$1, memoize, noop, first as first$1, keys as keys$1, forEach as forEach$1, range, flattenDeep, set, unset, chunk, cloneDeep, isNull, kebabCase, throttle, some, uniq, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, sortBy, round, reverse, camelCase } from "lodash-es";
@@ -8,21 +8,21 @@ import { g as generateUUID, a as getBreakpointValue, c as cn$1 } from "./common-
8
8
  import { atom, getDefaultStore as getDefaultStore$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
9
  import { splitAtom, atomWithStorage, useAtomCallback } from "jotai/utils";
10
10
  import clsx$1, { clsx } from "clsx";
11
- import { nanoid } from "nanoid";
11
+ import "nanoid";
12
12
  import { twMerge } from "tailwind-merge";
13
13
  import TreeModel from "tree-model";
14
14
  import * as React from "react";
15
15
  import React__default, { useEffect, useCallback, useState, useMemo, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
16
- import { C as COLLECTION_PREFIX, S as STYLES_KEY, j as getSplitChaiClasses, h as getBlocksFromHTML, m as mergeBlocksWithExisting, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, D as DESIGN_TOKEN_PREFIX, k as ROOT_TEMP_KEY } from "./apply-binding-IFVE37dG.js";
16
+ import { C as COLLECTION_PREFIX, S as STYLES_KEY, j as getSplitChaiClasses, h as getBlocksFromHTML, m as mergeBlocksWithExisting, e as adjustSpacingInContentBlocks, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, D as DESIGN_TOKEN_PREFIX, k as ROOT_TEMP_KEY } from "./apply-binding-DLaiD20q.js";
17
17
  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";
18
18
  import { isObject } from "@rjsf/utils";
19
+ import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useDebouncedState } from "@react-hookz/web";
19
20
  import { toast, Toaster } from "sonner";
20
21
  import { useTranslation, initReactI18next } from "react-i18next";
21
- import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useDebouncedState } from "@react-hookz/web";
22
22
  import Fuse from "fuse.js";
23
23
  import UndoManager from "undo-manager";
24
- import { ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, at as Input$1, aW as Skeleton, d as Alert, e as AlertDescription, v as Button, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, au as Label, b1 as Textarea, z as CardFooter, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, b8 as cn$2, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, a6 as DialogHeader, aX as Slider, aL as Separator, aY as Switch, a4 as DialogDescription, a5 as DialogFooter, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./tooltip-DUosa-uC.js";
25
- import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, GearIcon, DragHandleDots2Icon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, ChevronRightIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, FontStyleIcon, CircleIcon, MagnifyingGlassIcon, ReloadIcon, CaretRightIcon, FrameIcon, SquareIcon, EraserIcon, CheckIcon, DownloadIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, StackIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, ZoomInIcon, DotsHorizontalIcon, LightningBoltIcon, GlobeIcon, Pencil1Icon } from "@radix-ui/react-icons";
24
+ import { ab as DropdownMenu, ap as DropdownMenuTrigger, ad as DropdownMenuContent, af as DropdownMenuItem, at as Input$1, aW as Skeleton, d as Alert, e as AlertDescription, v as Button, a1 as Dialog, aa as DialogTrigger, a3 as DialogContent, a9 as DialogTitle, av as Popover, b4 as Tooltip, b7 as TooltipTrigger, ay as PopoverTrigger, b5 as TooltipContent, ax as PopoverContent, F as Command, H as CommandInput, I as CommandList, J as CommandEmpty, K as CommandGroup, L as CommandItem, B as Badge, b6 as TooltipProvider, a as AccordionItem, b as AccordionTrigger, c as AccordionContent, ag as DropdownMenuLabel, ak as DropdownMenuSeparator, ac as DropdownMenuCheckboxItem, aq as HoverCard, as as HoverCardTrigger, ar as HoverCardContent, au as Label, A as Accordion, C as Card, D as CardHeader, y as CardDescription, x as CardContent, b1 as Textarea, z as CardFooter, aB as Select$1, aJ as SelectTrigger, aK as SelectValue, aC as SelectContent, aE as SelectItem, b8 as cn$2, az as ScrollArea, aZ as Tabs, a$ as TabsList, b0 as TabsTrigger, a_ as TabsContent, g as AlertDialog, q as AlertDialogTrigger, j as AlertDialogContent, m as AlertDialogHeader, p as AlertDialogTitle, k as AlertDialogDescription, l as AlertDialogFooter, i as AlertDialogCancel, h as AlertDialogAction, a6 as DialogHeader, aX as Slider, aL as Separator, aY as Switch, aM as Sheet, aO as SheetContent, aR as SheetHeader, aU as SheetTitle } from "./tooltip-DUosa-uC.js";
25
+ import { PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, GearIcon, DragHandleDots2Icon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, CaretDownIcon, Cross1Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, ListBulletIcon, ValueIcon, TextAlignCenterIcon, TextAlignRightIcon, TextAlignLeftIcon, Link2Icon, LinkBreak2Icon, EnterFullScreenIcon, ExclamationTriangleIcon, Pencil2Icon, ChevronLeftIcon, LoopIcon, IdCardIcon, ChevronRightIcon, PlusCircledIcon, ChevronDownIcon, InfoCircledIcon, FileIcon, DotsVerticalIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, BoxIcon, MinusIcon, CrossCircledIcon, MobileIcon, LaptopIcon, DesktopIcon, TokensIcon, CheckIcon, CircleIcon, MagnifyingGlassIcon, ReloadIcon, CaretRightIcon, FrameIcon, SquareIcon, EraserIcon, DownloadIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, StackIcon, DoubleArrowDownIcon, DoubleArrowUpIcon, ResetIcon, UploadIcon, TextIcon, CornerTopRightIcon, MixerHorizontalIcon, SunIcon, MoonIcon, FaceIcon, ShuffleIcon, ChatBubbleIcon, StopIcon, ZoomInIcon, DotsHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
26
26
  import i18n, { t } from "i18next";
27
27
  import ReactDOM, { createPortal } from "react-dom";
28
28
  import { HexAlphaColorPicker } from "react-colorful";
@@ -95,7 +95,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
95
95
  });
96
96
  class PubSub {
97
97
  constructor() {
98
- G(this, "subscribers", /* @__PURE__ */ new Map());
98
+ X(this, "subscribers", /* @__PURE__ */ new Map());
99
99
  }
100
100
  subscribe(n, o) {
101
101
  return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(o), () => {
@@ -688,7 +688,7 @@ const useSelectedBlocksDisplayChild = () => ({
688
688
  ];
689
689
  class StructureRuleRegistry {
690
690
  constructor() {
691
- G(this, "rules", [...CORE_STRUCTURE_RULES]);
691
+ X(this, "rules", [...CORE_STRUCTURE_RULES]);
692
692
  }
693
693
  addRule(n) {
694
694
  this.rules.push(n);
@@ -708,23 +708,22 @@ class StructureRuleRegistry {
708
708
  }
709
709
  }
710
710
  const defaultRuleRegistry = new StructureRuleRegistry(), useCheckStructure = (r = {}) => {
711
- const n = useBuilderProp("flags.validateStructure", !0), o = useSetAtom$1(structureErrorsAtom), a = useSetAtom$1(structureValidationValidAtom), i = useSetAtom$1(hasStructureErrorsAtom), l = useSetAtom$1(hasStructureWarningsAtom);
712
- return useCallback(
713
- (d) => {
714
- const u = d;
715
- if (!n || u.length === 0) return;
716
- const p = convertToBlocksTree(u), h = [];
717
- let f = defaultRuleRegistry.getRules();
718
- r.enableAccessibilityRules && (defaultRuleRegistry.enableAccessibilityRules(), f = defaultRuleRegistry.getRules()), r.customRules && r.customRules.length > 0 && f.push(...r.customRules), f.forEach((x) => {
711
+ const n = useBuilderProp("flags.validateStructure", !0), o = useSetAtom$1(structureErrorsAtom), a = useSetAtom$1(structureValidationValidAtom), i = useSetAtom$1(hasStructureErrorsAtom), l = useSetAtom$1(hasStructureWarningsAtom), c = useCallback(
712
+ (u) => {
713
+ const p = u;
714
+ if (!n || !p || p.length === 0) return;
715
+ const h = convertToBlocksTree(p), f = [];
716
+ let m = defaultRuleRegistry.getRules();
717
+ r.enableAccessibilityRules && (defaultRuleRegistry.enableAccessibilityRules(), m = defaultRuleRegistry.getRules()), r.customRules && r.customRules.length > 0 && m.push(...r.customRules), m.forEach((y) => {
719
718
  try {
720
- const y = x.validate(u, p);
721
- h.push(...y);
722
- } catch (y) {
723
- console.error(`Error running structure rule "${x.name}":`, y);
719
+ const k = y.validate(p, h);
720
+ f.push(...k);
721
+ } catch (k) {
722
+ console.error(`Error running structure rule "${y.name}":`, k);
724
723
  }
725
724
  });
726
- const m = h.filter((x) => x.severity === "error").length > 0, g = h.filter((x) => x.severity === "warning").length > 0, b = !m;
727
- o(h), a(b), i(m), l(g);
725
+ const g = f.filter((y) => y.severity === "error").length > 0, b = f.filter((y) => y.severity === "warning").length > 0, x = !g;
726
+ o(f), a(x), i(g), l(b);
728
727
  },
729
728
  [
730
729
  n,
@@ -735,6 +734,18 @@ const defaultRuleRegistry = new StructureRuleRegistry(), useCheckStructure = (r
735
734
  l
736
735
  ]
737
736
  );
737
+ return useDebouncedCallback(
738
+ c,
739
+ [
740
+ n,
741
+ r,
742
+ o,
743
+ a,
744
+ i,
745
+ l
746
+ ],
747
+ 1e3
748
+ );
738
749
  }, useBlocksStoreManager = () => {
739
750
  const [, r] = useBlocksStore(), { postMessage: n } = useBroadcastChannel(), o = useUpdateBlockAtom(), a = useCheckStructure(), i = useIncrementActionsCount();
740
751
  return {
@@ -768,7 +779,7 @@ const defaultRuleRegistry = new StructureRuleRegistry(), useCheckStructure = (r
768
779
  l.forEach((c) => {
769
780
  const d = omit(c, "_id");
770
781
  o({ id: c._id, props: d });
771
- }), n({ type: "blocks-props-updated", blocks: l }), i();
782
+ }), n({ type: "blocks-props-updated", blocks: l }), r((c) => (a(c), c)), i();
772
783
  }
773
784
  };
774
785
  }, blockRepeaterDataAtom = atom({});
@@ -966,13 +977,13 @@ const checkMissingTranslations = (r, n) => n ? r.some((o) => {
966
977
  return !d || d === u ? !1 : checkMissingTranslations(y.blocks || [], d);
967
978
  };
968
979
  return { savePage: useThrottledCallback(
969
- async (y = !1, S = !1) => {
970
- if (!S && (!c("save_page") || !p))
980
+ async (y = !1, k = !1) => {
981
+ if (!k && (!c("save_page") || !p))
971
982
  return;
972
- const k = i();
973
- return k != null && k.blocks && f(k.blocks), n("SAVING"), a("SAVING"), m(0), await o({
983
+ const S = i();
984
+ return S != null && S.blocks && f(S.blocks), n("SAVING"), a("SAVING"), m(0), await o({
974
985
  autoSave: y,
975
- blocks: k.blocks,
986
+ blocks: S.blocks,
976
987
  theme: l,
977
988
  needTranslations: g(),
978
989
  designTokens: h
@@ -997,10 +1008,10 @@ const checkMissingTranslations = (r, n) => n ? r.some((o) => {
997
1008
  if (!y && (!c("save_page") || !p))
998
1009
  return;
999
1010
  n("SAVING"), a("SAVING");
1000
- const S = i();
1011
+ const k = i();
1001
1012
  return m(0), await o({
1002
1013
  autoSave: !0,
1003
- blocks: S.blocks,
1014
+ blocks: k.blocks,
1004
1015
  theme: l,
1005
1016
  needTranslations: g(),
1006
1017
  designTokens: h
@@ -1060,13 +1071,13 @@ const undoRedoStateAtom = atom({
1060
1071
  } = useBlocksStoreManager();
1061
1072
  return {
1062
1073
  moveBlocks: (g, b, x) => {
1063
- const y = builderStore.get(presentBlocksAtom), S = map(g, (C) => {
1064
- const B = y.find((A) => A._id === C)._parent || null, w = y.filter((A) => B ? A._parent === B : !A._parent).map((A) => A._id).indexOf(C);
1065
- return { _id: C, oldParent: B, oldPosition: w };
1066
- }), k = S.find(({ _id: C }) => C === g[0]);
1067
- k && k.oldParent === b && k.oldPosition === x || (i(g, b, x), r({
1068
- undo: () => each(S, ({ _id: C, oldParent: E, oldPosition: B }) => {
1069
- i([C], E, B);
1074
+ const y = builderStore.get(presentBlocksAtom), k = map(g, (v) => {
1075
+ const B = y.find((w) => w._id === v)._parent || null, A = y.filter((w) => B ? w._parent === B : !w._parent).map((w) => w._id).indexOf(v);
1076
+ return { _id: v, oldParent: B, oldPosition: A };
1077
+ }), S = k.find(({ _id: v }) => v === g[0]);
1078
+ S && S.oldParent === b && S.oldPosition === x || (i(g, b, x), r({
1079
+ undo: () => each(k, ({ _id: v, oldParent: E, oldPosition: B }) => {
1080
+ i([v], E, B);
1070
1081
  }),
1071
1082
  redo: () => i(g, b, x)
1072
1083
  }));
@@ -1078,28 +1089,28 @@ const undoRedoStateAtom = atom({
1078
1089
  });
1079
1090
  },
1080
1091
  removeBlocks: (g) => {
1081
- var k;
1082
- const b = builderStore.get(presentBlocksAtom), x = (k = first$1(g)) == null ? void 0 : k._parent, S = b.filter((C) => x ? C._parent === x : !C._parent).indexOf(first$1(g));
1092
+ var S;
1093
+ const b = builderStore.get(presentBlocksAtom), x = (S = first$1(g)) == null ? void 0 : S._parent, k = b.filter((v) => x ? v._parent === x : !v._parent).indexOf(first$1(g));
1083
1094
  a(map(g, "_id")), r({
1084
- undo: () => o(g, x, S),
1095
+ undo: () => o(g, x, k),
1085
1096
  redo: () => a(map(g, "_id"))
1086
1097
  });
1087
1098
  },
1088
1099
  updateBlocks: (g, b, x) => {
1089
1100
  const y = builderStore.get(presentBlocksAtom);
1090
- let S = [];
1101
+ let k = [];
1091
1102
  if (x)
1092
- S = map(g, (k) => ({ _id: k, ...x }));
1103
+ k = map(g, (S) => ({ _id: S, ...x }));
1093
1104
  else {
1094
- const k = keys$1(b);
1095
- S = map(g, (C) => {
1096
- const E = y.find((I) => I._id === C), B = { _id: C };
1097
- return each(k, (I) => B[I] = E[I]), B;
1105
+ const S = keys$1(b);
1106
+ k = map(g, (v) => {
1107
+ const E = y.find((I) => I._id === v), B = { _id: v };
1108
+ return each(S, (I) => B[I] = E[I]), B;
1098
1109
  });
1099
1110
  }
1100
- l(map(g, (k) => ({ _id: k, ...b }))), r({
1101
- undo: () => l(S),
1102
- redo: () => l(map(g, (k) => ({ _id: k, ...b })))
1111
+ l(map(g, (S) => ({ _id: S, ...b }))), r({
1112
+ undo: () => l(k),
1113
+ redo: () => l(map(g, (S) => ({ _id: S, ...b })))
1103
1114
  });
1104
1115
  },
1105
1116
  updateBlocksRuntime: (g, b) => {
@@ -1116,8 +1127,8 @@ const undoRedoStateAtom = atom({
1116
1127
  const b = builderStore.get(presentBlocksAtom);
1117
1128
  let x = [];
1118
1129
  x = map(g, (y) => {
1119
- const S = keys$1(y), k = b.find((E) => E._id === y._id), C = {};
1120
- return each(S, (E) => C[E] = k[E]), C;
1130
+ const k = keys$1(y), S = b.find((E) => E._id === y._id), v = {};
1131
+ return each(k, (E) => v[E] = S[E]), v;
1121
1132
  }), l(g), r({
1122
1133
  undo: () => l(x),
1123
1134
  redo: () => l(g)
@@ -2593,8 +2604,8 @@ const getBlockWithChildren = (r, n) => {
2593
2604
  for (const x in b) {
2594
2605
  const y = b[x];
2595
2606
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2596
- const { baseClasses: S, classes: k } = getSplitChaiClasses(y);
2597
- b[x] = compact(flattenDeep([S, k])).join(" ");
2607
+ const { baseClasses: k, classes: S } = getSplitChaiClasses(y);
2608
+ b[x] = compact(flattenDeep([k, S])).join(" ");
2598
2609
  } else
2599
2610
  x !== "_id" && delete b[x];
2600
2611
  }
@@ -2606,21 +2617,21 @@ const getBlockWithChildren = (r, n) => {
2606
2617
  if (i) {
2607
2618
  n(!0), a(null);
2608
2619
  try {
2609
- const y = u === p ? "" : u, S = b.toLowerCase().includes("translate the content"), k = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(g, d)), u, S) : [f(g, d)], C = await i(m, addLangToPrompt(b, h, m), k, y), { blocks: E, error: B } = C;
2620
+ const y = u === p ? "" : u, k = b.toLowerCase().includes("translate the content"), S = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(g, d)), u, k) : [f(g, d)], v = await i(m, addLangToPrompt(b, h, m), S, y), { blocks: E, error: B } = v;
2610
2621
  if (B) {
2611
2622
  a(B);
2612
2623
  return;
2613
2624
  }
2614
2625
  if (m === "styles") {
2615
- const I = E.map((w) => {
2616
- for (const A in w)
2617
- A !== "_id" && (w[A] = `${STYLES_KEY},${w[A]}`);
2618
- return w;
2626
+ const I = E.map((A) => {
2627
+ for (const w in A)
2628
+ w !== "_id" && (A[w] = `${STYLES_KEY},${A[w]}`);
2629
+ return A;
2619
2630
  });
2620
2631
  c(I);
2621
2632
  } else
2622
2633
  l(E);
2623
- x && x(C);
2634
+ x && x(v);
2624
2635
  } catch (y) {
2625
2636
  a(y);
2626
2637
  } finally {
@@ -3018,6 +3029,9 @@ const useBlockHighlight = () => {
3018
3029
  }, useCanvasDisplayWidth = () => {
3019
3030
  const [r, n] = useAtom$1(canvasDisplayWidthAtom);
3020
3031
  return [r, n];
3032
+ }, getQueries = (r) => {
3033
+ const n = ["xs", "sm", "md", "lg", "xl", "2xl"], o = n.indexOf(r);
3034
+ return o === -1 ? ["xs"] : n.slice(0, o + 1);
3021
3035
  }, selectedBlockAllClassesAtom = atom((r) => {
3022
3036
  const n = first$1(r(selectedStylingBlocksAtom)), o = r(selectedBlockAtom);
3023
3037
  if (!n || n.blockId !== get(o, "_id", null)) return [];
@@ -3027,33 +3041,7 @@ const useBlockHighlight = () => {
3027
3041
  const n = r(canvasBreakpointAtom), o = r(styleStateAtom), a = r(darkModeAtom), i = getQueries(n);
3028
3042
  let l = filter(r(selectedBlockAllClassesAtom), { mod: o });
3029
3043
  return startsWith(o, "_") || (l = filter(l, (c) => i.includes(c.mq))), l = l.sort((c, d) => MQ[c.mq] - MQ[d.mq]), a || (l = filter(l, { dark: !1 })), l;
3030
- }), getQueries = (r) => {
3031
- let n = [];
3032
- switch (r) {
3033
- case "xs":
3034
- n = ["xs"];
3035
- break;
3036
- case "sm":
3037
- n = ["xs", "sm"];
3038
- break;
3039
- case "md":
3040
- n = ["xs", "sm", "md"];
3041
- break;
3042
- case "lg":
3043
- n = ["xs", "sm", "md", "lg"];
3044
- break;
3045
- case "xl":
3046
- n = ["xs", "sm", "md", "lg", "xl"];
3047
- break;
3048
- case "2xl":
3049
- n = ["xs", "sm", "md", "lg", "xl", "2xl"];
3050
- break;
3051
- default:
3052
- n = ["xs"];
3053
- break;
3054
- }
3055
- return n;
3056
- }, useSelectedBlockCurrentClasses = () => useAtomValue$1(selectedBlockCurrentClassesAtom), selectedBreakpointsAtom = atomWithStorage("selectedBreakpoints", ["XS", "MD", "XL"]), useSelectedBreakpoints = () => {
3044
+ }), useSelectedBlockCurrentClasses = () => useAtomValue$1(selectedBlockCurrentClassesAtom), selectedBreakpointsAtom = atomWithStorage("selectedBreakpoints", ["XS", "MD", "XL"]), useSelectedBreakpoints = () => {
3057
3045
  const [r, n] = useAtom$1(selectedBreakpointsAtom);
3058
3046
  return [r, n];
3059
3047
  }, useStylingState = () => useAtom$1(styleStateAtom), wrapperBlockAtom = atom((r) => {
@@ -3190,7 +3178,7 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), useCanvasIframe
3190
3178
  const [r] = useBlocksStore();
3191
3179
  return useCallback(
3192
3180
  (n) => {
3193
- const o = syncBlocksWithDefaults(getBlocksFromHTML(n)), a = mergeBlocksWithExisting(o, r);
3181
+ const o = getBlocksFromHTML(n), a = mergeBlocksWithExisting(o, r);
3194
3182
  return handlei18N(a, r);
3195
3183
  },
3196
3184
  [r]
@@ -3546,29 +3534,29 @@ function calculateElementZone(r, n, o, a, i) {
3546
3534
  }
3547
3535
  }
3548
3536
  function detectDropZone(r, n, o, a, i) {
3549
- var C, E, B, I;
3537
+ var v, E, B, I;
3550
3538
  const l = r.getAttribute("data-block-id"), c = r.getAttribute("data-block-type") || "Box";
3551
3539
  if (!l)
3552
3540
  return null;
3553
3541
  let d = r.parentElement;
3554
3542
  for (; d && !d.hasAttribute("data-block-id"); )
3555
3543
  d = d.parentElement;
3556
- const u = l === "canvas" ? l : d == null ? void 0 : d.getAttribute("data-block-id"), p = d ? getOrientation(d) : "vertical", h = getOrientation(r), f = isLeafBlock(c), m = !f && canAcceptChildBlock(c, a), g = ((C = i.defaultView) == null ? void 0 : C.scrollY) || 0, b = ((E = i.defaultView) == null ? void 0 : E.scrollX) || 0;
3544
+ const u = l === "canvas" ? l : d == null ? void 0 : d.getAttribute("data-block-id"), p = d ? getOrientation(d) : "vertical", h = getOrientation(r), f = isLeafBlock(c), m = !f && canAcceptChildBlock(c, a), g = ((v = i.defaultView) == null ? void 0 : v.scrollY) || 0, b = ((E = i.defaultView) == null ? void 0 : E.scrollX) || 0;
3557
3545
  if (l === "canvas" && hasChildBlocks(r)) {
3558
- const w = getChildBlocks(r), A = w[w.length - 1];
3559
- if (A) {
3560
- const v = A.getBoundingClientRect(), T = r.getBoundingClientRect(), N = window.getComputedStyle(r), j = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, L = T.width - j - P, D = T.left + b + j;
3546
+ const A = getChildBlocks(r), w = A[A.length - 1];
3547
+ if (w) {
3548
+ const C = w.getBoundingClientRect(), T = r.getBoundingClientRect(), N = window.getComputedStyle(r), j = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, L = T.width - j - P, D = T.left + b + j;
3561
3549
  return {
3562
3550
  position: "after",
3563
3551
  placeholderOrientation: "horizontal",
3564
3552
  rect: {
3565
- top: v.bottom + g,
3553
+ top: C.bottom + g,
3566
3554
  left: D,
3567
3555
  width: L,
3568
3556
  height: 4
3569
3557
  },
3570
- targetElement: A,
3571
- targetBlockId: A.getAttribute("data-block-id"),
3558
+ targetElement: w,
3559
+ targetBlockId: w.getAttribute("data-block-id"),
3572
3560
  targetParentId: "canvas",
3573
3561
  isEmpty: !1,
3574
3562
  confidence: 1
@@ -3576,44 +3564,44 @@ function detectDropZone(r, n, o, a, i) {
3576
3564
  }
3577
3565
  }
3578
3566
  if (m && !f && hasChildBlocks(r)) {
3579
- const w = detectGapZone(r, n, o, h);
3580
- if (w) {
3581
- const A = w.before.getBoundingClientRect(), v = w.after.getBoundingClientRect(), T = r.getBoundingClientRect(), N = window.getComputedStyle(r), j = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, L = getChildBlocks(r), D = getSiblingsInSameRow(L, w.before, h);
3582
- let F = 0;
3583
- if (D.forEach((H) => {
3584
- const O = H.getBoundingClientRect();
3585
- O.height > F && (F = O.height);
3567
+ const A = detectGapZone(r, n, o, h);
3568
+ if (A) {
3569
+ const w = A.before.getBoundingClientRect(), C = A.after.getBoundingClientRect(), T = r.getBoundingClientRect(), N = window.getComputedStyle(r), j = parseFloat(N.paddingLeft) || 0, P = parseFloat(N.paddingRight) || 0, L = getChildBlocks(r), D = getSiblingsInSameRow(L, A.before, h);
3570
+ let $ = 0;
3571
+ if (D.forEach((M) => {
3572
+ const O = M.getBoundingClientRect();
3573
+ O.height > $ && ($ = O.height);
3586
3574
  }), h === "vertical") {
3587
- const H = T.width - j - P, O = T.left + b + j;
3575
+ const M = T.width - j - P, O = T.left + b + j;
3588
3576
  return {
3589
3577
  position: "after",
3590
3578
  placeholderOrientation: "horizontal",
3591
3579
  rect: {
3592
- top: A.bottom + g,
3580
+ top: w.bottom + g,
3593
3581
  left: O,
3594
- width: H,
3582
+ width: M,
3595
3583
  height: 4
3596
3584
  },
3597
- targetElement: w.before,
3598
- targetBlockId: w.before.getAttribute("data-block-id"),
3585
+ targetElement: A.before,
3586
+ targetBlockId: A.before.getAttribute("data-block-id"),
3599
3587
  targetParentId: l,
3600
3588
  isGapZone: !0,
3601
3589
  confidence: 1
3602
3590
  // High confidence for gap zones
3603
3591
  };
3604
3592
  } else {
3605
- const H = A.top + g, O = F > 0 ? F : Math.max(A.height, v.height);
3593
+ const M = w.top + g, O = $ > 0 ? $ : Math.max(w.height, C.height);
3606
3594
  return {
3607
3595
  position: "after",
3608
3596
  placeholderOrientation: "vertical",
3609
3597
  rect: {
3610
- top: H,
3611
- left: A.right + b,
3598
+ top: M,
3599
+ left: w.right + b,
3612
3600
  width: 4,
3613
3601
  height: O
3614
3602
  },
3615
- targetElement: w.before,
3616
- targetBlockId: w.before.getAttribute("data-block-id"),
3603
+ targetElement: A.before,
3604
+ targetBlockId: A.before.getAttribute("data-block-id"),
3617
3605
  targetParentId: l,
3618
3606
  isGapZone: !0,
3619
3607
  confidence: 1
@@ -3622,22 +3610,22 @@ function detectDropZone(r, n, o, a, i) {
3622
3610
  }
3623
3611
  }
3624
3612
  if (d && u) {
3625
- const w = detectParentEdgeProximity(d, n, o, p);
3626
- if (w) {
3627
- const A = d.getBoundingClientRect(), v = window.getComputedStyle(d), T = parseFloat(v.paddingLeft) || 0, N = parseFloat(v.paddingRight) || 0, j = parseFloat(v.paddingTop) || 0, P = parseFloat(v.paddingBottom) || 0, L = ((B = i.defaultView) == null ? void 0 : B.scrollY) || 0, D = ((I = i.defaultView) == null ? void 0 : I.scrollX) || 0, F = p === "vertical" ? "horizontal" : "vertical", H = getMaxSiblingDimensions(d);
3628
- if (w === "start") {
3613
+ const A = detectParentEdgeProximity(d, n, o, p);
3614
+ if (A) {
3615
+ const w = d.getBoundingClientRect(), C = window.getComputedStyle(d), T = parseFloat(C.paddingLeft) || 0, N = parseFloat(C.paddingRight) || 0, j = parseFloat(C.paddingTop) || 0, P = parseFloat(C.paddingBottom) || 0, L = ((B = i.defaultView) == null ? void 0 : B.scrollY) || 0, D = ((I = i.defaultView) == null ? void 0 : I.scrollX) || 0, $ = p === "vertical" ? "horizontal" : "vertical", M = getMaxSiblingDimensions(d);
3616
+ if (A === "start") {
3629
3617
  const O = getChildBlocks(d)[0];
3630
3618
  if (O) {
3631
- const R = O.getBoundingClientRect();
3619
+ const H = O.getBoundingClientRect();
3632
3620
  if (p === "vertical") {
3633
- const _ = A.width - T - N, M = A.left + D + T;
3621
+ const R = w.width - T - N, V = w.left + D + T;
3634
3622
  return {
3635
3623
  position: "before",
3636
- placeholderOrientation: F,
3624
+ placeholderOrientation: $,
3637
3625
  rect: {
3638
- top: R.top + L - 2,
3639
- left: M,
3640
- width: _,
3626
+ top: H.top + L - 2,
3627
+ left: V,
3628
+ width: R,
3641
3629
  height: 4
3642
3630
  },
3643
3631
  targetElement: O,
@@ -3646,15 +3634,15 @@ function detectDropZone(r, n, o, a, i) {
3646
3634
  confidence: 0.9
3647
3635
  };
3648
3636
  } else {
3649
- const _ = A.top + L + j, M = H.maxHeight > 0 ? H.maxHeight : A.height - j - P;
3637
+ const R = w.top + L + j, V = M.maxHeight > 0 ? M.maxHeight : w.height - j - P;
3650
3638
  return {
3651
3639
  position: "before",
3652
- placeholderOrientation: F,
3640
+ placeholderOrientation: $,
3653
3641
  rect: {
3654
- top: _,
3655
- left: R.left + D - 2,
3642
+ top: R,
3643
+ left: H.left + D - 2,
3656
3644
  width: 4,
3657
- height: M
3645
+ height: V
3658
3646
  },
3659
3647
  targetElement: O,
3660
3648
  targetBlockId: O.getAttribute("data-block-id"),
@@ -3664,38 +3652,38 @@ function detectDropZone(r, n, o, a, i) {
3664
3652
  }
3665
3653
  }
3666
3654
  } else {
3667
- const O = getChildBlocks(d), R = O[O.length - 1];
3668
- if (R) {
3669
- const _ = R.getBoundingClientRect();
3655
+ const O = getChildBlocks(d), H = O[O.length - 1];
3656
+ if (H) {
3657
+ const R = H.getBoundingClientRect();
3670
3658
  if (p === "vertical") {
3671
- const M = A.width - T - N, $ = A.left + D + T;
3659
+ const V = w.width - T - N, W = w.left + D + T;
3672
3660
  return {
3673
3661
  position: "after",
3674
- placeholderOrientation: F,
3662
+ placeholderOrientation: $,
3675
3663
  rect: {
3676
- top: _.bottom + L - 2,
3677
- left: $,
3678
- width: M,
3664
+ top: R.bottom + L - 2,
3665
+ left: W,
3666
+ width: V,
3679
3667
  height: 4
3680
3668
  },
3681
- targetElement: R,
3682
- targetBlockId: R.getAttribute("data-block-id"),
3669
+ targetElement: H,
3670
+ targetBlockId: H.getAttribute("data-block-id"),
3683
3671
  targetParentId: u,
3684
3672
  confidence: 0.9
3685
3673
  };
3686
3674
  } else {
3687
- const M = A.top + L + j, $ = H.maxHeight > 0 ? H.maxHeight : A.height - j - P;
3675
+ const V = w.top + L + j, W = M.maxHeight > 0 ? M.maxHeight : w.height - j - P;
3688
3676
  return {
3689
3677
  position: "after",
3690
- placeholderOrientation: F,
3678
+ placeholderOrientation: $,
3691
3679
  rect: {
3692
- top: M,
3693
- left: _.right + D - 2,
3680
+ top: V,
3681
+ left: R.right + D - 2,
3694
3682
  width: 4,
3695
- height: $
3683
+ height: W
3696
3684
  },
3697
- targetElement: R,
3698
- targetBlockId: R.getAttribute("data-block-id"),
3685
+ targetElement: H,
3686
+ targetBlockId: H.getAttribute("data-block-id"),
3699
3687
  targetParentId: u,
3700
3688
  confidence: 0.9
3701
3689
  };
@@ -3706,31 +3694,31 @@ function detectDropZone(r, n, o, a, i) {
3706
3694
  }
3707
3695
  let x = calculateElementZone(r, n, o, m, p);
3708
3696
  if (f && x.position === "inside") {
3709
- const w = r.getBoundingClientRect();
3697
+ const A = r.getBoundingClientRect();
3710
3698
  p === "vertical" ? x = {
3711
- position: (o - w.top) / w.height < 0.5 ? "before" : "after",
3699
+ position: (o - A.top) / A.height < 0.5 ? "before" : "after",
3712
3700
  confidence: x.confidence
3713
3701
  } : x = {
3714
- position: (n - w.left) / w.width < 0.5 ? "before" : "after",
3702
+ position: (n - A.left) / A.width < 0.5 ? "before" : "after",
3715
3703
  confidence: x.confidence
3716
3704
  };
3717
3705
  }
3718
3706
  let y;
3719
3707
  x.position === "inside" ? y = h === "vertical" ? "horizontal" : "vertical" : y = p === "vertical" ? "horizontal" : "vertical";
3720
- const S = calculatePlaceholderRect(
3708
+ const k = calculatePlaceholderRect(
3721
3709
  r,
3722
3710
  d,
3723
3711
  x.position,
3724
3712
  y,
3725
3713
  i
3726
- ), k = x.position === "inside" ? l : u;
3714
+ ), S = x.position === "inside" ? l : u;
3727
3715
  return {
3728
3716
  position: x.position,
3729
3717
  placeholderOrientation: y,
3730
- rect: S,
3718
+ rect: k,
3731
3719
  targetElement: r,
3732
3720
  targetBlockId: l,
3733
- targetParentId: k,
3721
+ targetParentId: S,
3734
3722
  isEmpty: x.position === "inside" && !hasChildBlocks(r),
3735
3723
  confidence: x.confidence
3736
3724
  };
@@ -3779,14 +3767,14 @@ function getSiblingsInSameRow(r, n, o) {
3779
3767
  }
3780
3768
  function calculatePlaceholderRect(r, n, o, a, i) {
3781
3769
  var j, P;
3782
- const l = r.getBoundingClientRect(), c = window.getComputedStyle(r), d = ((j = i.defaultView) == null ? void 0 : j.scrollY) || 0, u = ((P = i.defaultView) == null ? void 0 : P.scrollX) || 0, p = parseFloat(c.marginTop) || 0, h = parseFloat(c.marginBottom) || 0, f = parseFloat(c.marginLeft) || 0, m = parseFloat(c.marginRight) || 0, g = parseFloat(c.paddingTop) || 0, b = parseFloat(c.paddingBottom) || 0, x = parseFloat(c.paddingLeft) || 0, y = parseFloat(c.paddingRight) || 0, S = n == null ? void 0 : n.getBoundingClientRect(), k = n && parseFloat(window.getComputedStyle(n).paddingLeft) || 0, C = n && parseFloat(window.getComputedStyle(n).paddingRight) || 0, E = n && parseFloat(window.getComputedStyle(n).paddingTop) || 0, B = n && parseFloat(window.getComputedStyle(n).paddingBottom) || 0, I = n ? getMaxSiblingDimensions(n) : { maxWidth: 0, maxHeight: 0 }, w = n ? getOrientation(n) : "vertical", A = n ? getChildBlocks(n) : [], v = getSiblingsInSameRow(A, r, w);
3770
+ const l = r.getBoundingClientRect(), c = window.getComputedStyle(r), d = ((j = i.defaultView) == null ? void 0 : j.scrollY) || 0, u = ((P = i.defaultView) == null ? void 0 : P.scrollX) || 0, p = parseFloat(c.marginTop) || 0, h = parseFloat(c.marginBottom) || 0, f = parseFloat(c.marginLeft) || 0, m = parseFloat(c.marginRight) || 0, g = parseFloat(c.paddingTop) || 0, b = parseFloat(c.paddingBottom) || 0, x = parseFloat(c.paddingLeft) || 0, y = parseFloat(c.paddingRight) || 0, k = n == null ? void 0 : n.getBoundingClientRect(), S = n && parseFloat(window.getComputedStyle(n).paddingLeft) || 0, v = n && parseFloat(window.getComputedStyle(n).paddingRight) || 0, E = n && parseFloat(window.getComputedStyle(n).paddingTop) || 0, B = n && parseFloat(window.getComputedStyle(n).paddingBottom) || 0, I = n ? getMaxSiblingDimensions(n) : { maxWidth: 0, maxHeight: 0 }, A = n ? getOrientation(n) : "vertical", w = n ? getChildBlocks(n) : [], C = getSiblingsInSameRow(w, r, A);
3783
3771
  let T = 0, N = 0;
3784
- if (v.forEach((L) => {
3772
+ if (C.forEach((L) => {
3785
3773
  const D = L.getBoundingClientRect();
3786
3774
  D.height > T && (T = D.height), D.width > N && (N = D.width);
3787
3775
  }), o === "before")
3788
3776
  if (a === "horizontal") {
3789
- const L = S ? S.width - k - C : l.width, D = S ? S.left + u + k : l.left + u;
3777
+ const L = k ? k.width - S - v : l.width, D = k ? k.left + u + S : l.left + u;
3790
3778
  return {
3791
3779
  top: l.top + d - p - 2,
3792
3780
  left: D,
@@ -3794,7 +3782,7 @@ function calculatePlaceholderRect(r, n, o, a, i) {
3794
3782
  height: 4
3795
3783
  };
3796
3784
  } else {
3797
- const L = l.top + d, D = w === "horizontal" && T > 0 ? T : I.maxHeight > 0 ? I.maxHeight : S ? S.height - E - B : l.height;
3785
+ const L = l.top + d, D = A === "horizontal" && T > 0 ? T : I.maxHeight > 0 ? I.maxHeight : k ? k.height - E - B : l.height;
3798
3786
  return {
3799
3787
  top: L,
3800
3788
  left: l.left + u - f - 2,
@@ -3804,7 +3792,7 @@ function calculatePlaceholderRect(r, n, o, a, i) {
3804
3792
  }
3805
3793
  else if (o === "after")
3806
3794
  if (a === "horizontal") {
3807
- const L = S ? S.width - k - C : l.width, D = S ? S.left + u + k : l.left + u;
3795
+ const L = k ? k.width - S - v : l.width, D = k ? k.left + u + S : l.left + u;
3808
3796
  return {
3809
3797
  top: l.bottom + d + h - 2,
3810
3798
  left: D,
@@ -3812,7 +3800,7 @@ function calculatePlaceholderRect(r, n, o, a, i) {
3812
3800
  height: 4
3813
3801
  };
3814
3802
  } else {
3815
- const L = l.top + d, D = w === "horizontal" && T > 0 ? T : I.maxHeight > 0 ? I.maxHeight : S ? S.height - E - B : l.height;
3803
+ const L = l.top + d, D = A === "horizontal" && T > 0 ? T : I.maxHeight > 0 ? I.maxHeight : k ? k.height - E - B : l.height;
3816
3804
  return {
3817
3805
  top: L,
3818
3806
  left: l.right + u + m - 2,
@@ -3896,31 +3884,31 @@ const useBlockDrop = () => {
3896
3884
  return;
3897
3885
  }
3898
3886
  n(null);
3899
- const S = o.targetBlockId, k = o.targetParentId;
3900
- if (!S)
3887
+ const k = o.targetBlockId, S = o.targetParentId;
3888
+ if (!k)
3901
3889
  return;
3902
- const { parentId: C, index: E, replaceImageUrl: B } = calculateInsertionIndex(
3890
+ const { parentId: v, index: E, replaceImageUrl: B } = calculateInsertionIndex(
3903
3891
  i,
3904
- S,
3905
3892
  k,
3893
+ S,
3906
3894
  o.position,
3907
3895
  r
3908
3896
  ), I = r._id !== void 0;
3909
3897
  if (B && isDraggingOnlyImageBlock(r)) {
3910
- b([S], { image: get(r, "blocks.0.image") }), setTimeout(() => {
3898
+ b([k], { image: get(r, "blocks.0.image") }), setTimeout(() => {
3911
3899
  g(m + 1);
3912
3900
  }, 50);
3913
3901
  return;
3914
3902
  }
3915
3903
  if (I)
3916
- d([r._id], C === null ? void 0 : C, E), h(), p([]), u([r._id]);
3904
+ d([r._id], v === null ? void 0 : v, E), h(), p([]), u([r._id]);
3917
3905
  else {
3918
- const w = r._type || r.type, A = r != null && r.blocks ? isFunction$1(r == null ? void 0 : r.blocks) ? syncBlocksWithDefaults(r == null ? void 0 : r.blocks()) : r == null ? void 0 : r.blocks : null;
3906
+ const A = r._type || r.type, w = r != null && r.blocks ? isFunction$1(r == null ? void 0 : r.blocks) ? syncBlocksWithDefaults(r == null ? void 0 : r.blocks()) : r == null ? void 0 : r.blocks : null;
3919
3907
  c(
3920
- w === "PartialBlock" ? {
3921
- blocks: [{ _type: w, _id: "partial-block", partialBlockId: r.partialBlockId }]
3922
- } : (A == null ? void 0 : A.length) > 0 ? { blocks: [...A] } : { type: w },
3923
- C,
3908
+ A === "PartialBlock" ? {
3909
+ blocks: [{ _type: A, _id: "partial-block", partialBlockId: r.partialBlockId }]
3910
+ } : (w == null ? void 0 : w.length) > 0 ? { blocks: [...w] } : { type: A },
3911
+ v,
3924
3912
  E
3925
3913
  );
3926
3914
  }
@@ -4025,24 +4013,24 @@ const LEAF_BLOCK_TYPES = [
4025
4013
  if (!(c != null && c.defaultView)) return;
4026
4014
  const m = c.defaultView, g = m.innerHeight, b = m.scrollY, x = c.documentElement.scrollHeight;
4027
4015
  u.current = f;
4028
- const y = f, S = g - f;
4029
- let k = !1, C = null, E = 0;
4030
- if (y < AUTO_SCROLL_CONFIG.EDGE_ZONE && b > 0 ? (k = !0, C = "up", E = y) : S < AUTO_SCROLL_CONFIG.EDGE_ZONE && b + g < x && (k = !0, C = "down", E = S), !k && d.current !== null) {
4016
+ const y = f, k = g - f;
4017
+ let S = !1, v = null, E = 0;
4018
+ if (y < AUTO_SCROLL_CONFIG.EDGE_ZONE && b > 0 ? (S = !0, v = "up", E = y) : k < AUTO_SCROLL_CONFIG.EDGE_ZONE && b + g < x && (S = !0, v = "down", E = k), !S && d.current !== null) {
4031
4019
  cancelAnimationFrame(d.current), d.current = null;
4032
4020
  return;
4033
4021
  }
4034
- if (k && C) {
4035
- const B = 1 - E / AUTO_SCROLL_CONFIG.EDGE_ZONE, I = AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED + (AUTO_SCROLL_CONFIG.MAX_SCROLL_SPEED - AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED) * B, w = () => {
4022
+ if (S && v) {
4023
+ const B = 1 - E / AUTO_SCROLL_CONFIG.EDGE_ZONE, I = AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED + (AUTO_SCROLL_CONFIG.MAX_SCROLL_SPEED - AUTO_SCROLL_CONFIG.MIN_SCROLL_SPEED) * B, A = () => {
4036
4024
  if (!isDragging || !m) {
4037
4025
  d.current = null;
4038
4026
  return;
4039
4027
  }
4040
- const A = C === "up" ? -I : I;
4041
- m.scrollBy(0, A);
4042
- const v = m.scrollY, T = v > 0, N = v + g < x, j = u.current, P = g - u.current;
4043
- C === "up" && T && j < AUTO_SCROLL_CONFIG.EDGE_ZONE || C === "down" && N && P < AUTO_SCROLL_CONFIG.EDGE_ZONE ? d.current = requestAnimationFrame(w) : d.current = null;
4028
+ const w = v === "up" ? -I : I;
4029
+ m.scrollBy(0, w);
4030
+ const C = m.scrollY, T = C > 0, N = C + g < x, j = u.current, P = g - u.current;
4031
+ v === "up" && T && j < AUTO_SCROLL_CONFIG.EDGE_ZONE || v === "down" && N && P < AUTO_SCROLL_CONFIG.EDGE_ZONE ? d.current = requestAnimationFrame(A) : d.current = null;
4044
4032
  };
4045
- d.current === null && (d.current = requestAnimationFrame(w));
4033
+ d.current === null && (d.current = requestAnimationFrame(A));
4046
4034
  }
4047
4035
  },
4048
4036
  [c]
@@ -4063,18 +4051,18 @@ const LEAF_BLOCK_TYPES = [
4063
4051
  const y = r._id;
4064
4052
  if (y && (b === y || isDescendantOf(b, y, l)))
4065
4053
  return;
4066
- const S = r._type || r.type;
4067
- if (!S)
4054
+ const k = r._type || r.type;
4055
+ if (!k)
4068
4056
  return;
4069
- const k = f.clientX, C = f.clientY;
4070
- p(C);
4071
- const E = detectDropZone(g, k, C, S, c);
4057
+ const S = f.clientX, v = f.clientY;
4058
+ p(v);
4059
+ const E = detectDropZone(g, S, v, k, c);
4072
4060
  if (!E)
4073
4061
  return;
4074
4062
  const B = g.getAttribute("data-block-type") || "Box";
4075
4063
  let I = !1;
4076
- const w = LEAF_BLOCK_TYPES.includes(B);
4077
- if (B === "Image" && S === "Image" && isDraggingOnlyImageBlock(r)) {
4064
+ const A = LEAF_BLOCK_TYPES.includes(B);
4065
+ if (B === "Image" && k === "Image" && isDraggingOnlyImageBlock(r)) {
4078
4066
  i(b), o({
4079
4067
  isVisible: !0,
4080
4068
  isValid: !0,
@@ -4091,21 +4079,21 @@ const LEAF_BLOCK_TYPES = [
4091
4079
  return;
4092
4080
  }
4093
4081
  if (E.position === "inside") {
4094
- if (w || y && !canDropWithoutCircularReference(y, b, l))
4082
+ if (A || y && !canDropWithoutCircularReference(y, b, l))
4095
4083
  return;
4096
- I = canAcceptChildBlock(B, S);
4084
+ I = canAcceptChildBlock(B, k);
4097
4085
  } else {
4098
- let v = g.parentElement, T = "Box";
4099
- for (; v && !v.hasAttribute("data-block-id"); )
4100
- v = v.parentElement;
4101
- if (v && (T = v.getAttribute("data-block-type") || "Box"), y && !canDropAsSiblingWithoutCircularReference(y, b, l))
4086
+ let C = g.parentElement, T = "Box";
4087
+ for (; C && !C.hasAttribute("data-block-id"); )
4088
+ C = C.parentElement;
4089
+ if (C && (T = C.getAttribute("data-block-type") || "Box"), y && !canDropAsSiblingWithoutCircularReference(y, b, l))
4102
4090
  return;
4103
- I = canAcceptChildBlock(T, S);
4091
+ I = canAcceptChildBlock(T, k);
4104
4092
  }
4105
4093
  if (!I)
4106
4094
  return;
4107
4095
  i(E.targetParentId);
4108
- const A = E.targetParentId || x;
4096
+ const w = E.targetParentId || x;
4109
4097
  o({
4110
4098
  isVisible: !0,
4111
4099
  isValid: !0,
@@ -4117,7 +4105,7 @@ const LEAF_BLOCK_TYPES = [
4117
4105
  width: E.rect.width,
4118
4106
  height: E.rect.height,
4119
4107
  targetBlockId: E.targetBlockId,
4120
- targetParentId: A
4108
+ targetParentId: w
4121
4109
  }), removeDropTargetAttributes(c), E.targetElement.setAttribute("data-drop-target", "true");
4122
4110
  }, 300),
4123
4111
  [c, r, o, a, i, l, p]
@@ -4437,9 +4425,9 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4437
4425
  }),
4438
4426
  size({
4439
4427
  boundary: h == null ? void 0 : h.body,
4440
- apply({ availableWidth: C, availableHeight: E, elements: B }) {
4428
+ apply({ availableWidth: v, availableHeight: E, elements: B }) {
4441
4429
  Object.assign(B.floating.style, {
4442
- maxWidth: `${Math.max(200, C)}px`,
4430
+ maxWidth: `${Math.max(200, v)}px`,
4443
4431
  maxHeight: `${Math.max(100, E)}px`
4444
4432
  });
4445
4433
  }
@@ -4448,16 +4436,16 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4448
4436
  elements: { reference: o }
4449
4437
  });
4450
4438
  useResizeObserver(o, () => x(), o !== null), useResizeObserver(h == null ? void 0 : h.body, () => x(), (h == null ? void 0 : h.body) !== null);
4451
- const y = get(r, "_parent", null), S = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
4439
+ const y = get(r, "_parent", null), k = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
4452
4440
  useEffect(() => {
4453
- let C = null;
4454
- return o ? (C = setTimeout(() => x(), 500), () => {
4455
- C && clearTimeout(C);
4441
+ let v = null;
4442
+ return o ? (v = setTimeout(() => x(), 500), () => {
4443
+ v && clearTimeout(v);
4456
4444
  }) : (x(), () => {
4457
- C && clearTimeout(C);
4445
+ v && clearTimeout(v);
4458
4446
  });
4459
4447
  }, [o, r == null ? void 0 : r._id]);
4460
- const [, k] = useSidebarActivePanel();
4448
+ const [, S] = useSidebarActivePanel();
4461
4449
  return !n && (!o || !r || p) ? null : /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsx(
4462
4450
  "div",
4463
4451
  {
@@ -4465,13 +4453,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4465
4453
  tabIndex: 0,
4466
4454
  ref: b.setFloating,
4467
4455
  style: g,
4468
- onClick: (C) => {
4469
- C.stopPropagation(), C.preventDefault();
4456
+ onClick: (v) => {
4457
+ v.stopPropagation(), v.preventDefault();
4470
4458
  },
4471
- onMouseEnter: (C) => {
4472
- C.stopPropagation(), c(null);
4459
+ onMouseEnter: (v) => {
4460
+ v.stopPropagation(), c(null);
4473
4461
  },
4474
- onKeyDown: (C) => C.stopPropagation(),
4462
+ onKeyDown: (v) => v.stopPropagation(),
4475
4463
  className: `isolate z-[999] flex h-6 items-center justify-between bg-blue-500 py-2 text-xs text-white ${n ? "opacity-0" : ""}`,
4476
4464
  children: /* @__PURE__ */ jsxs(Fragment$1, { children: [
4477
4465
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4486,14 +4474,14 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span",
4486
4474
  }
4487
4475
  )
4488
4476
  ] }),
4489
- /* @__PURE__ */ jsx("div", { className: `w-full ${f ? "cursor-grab active:cursor-grabbing" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "mr-10 w-full items-center space-x-1 px-1 leading-tight", children: S }) }),
4477
+ /* @__PURE__ */ jsx("div", { className: `w-full ${f ? "cursor-grab active:cursor-grabbing" : ""}`, children: /* @__PURE__ */ jsx("div", { className: "mr-10 w-full items-center space-x-1 px-1 leading-tight", children: k }) }),
4490
4478
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-1 pl-1 pr-1.5", children: [
4491
4479
  u(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
4492
4480
  AiIcon,
4493
4481
  {
4494
4482
  className: "h-4 w-4 rounded hover:bg-white hover:text-blue-500",
4495
4483
  onClick: () => {
4496
- k("chai-chat-panel"), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_AI_PANEL);
4484
+ S("chai-chat-panel"), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_AI_PANEL);
4497
4485
  }
4498
4486
  }
4499
4487
  ),
@@ -4663,17 +4651,17 @@ class Content extends Component {
4663
4651
  class Frame extends Component {
4664
4652
  constructor(o, a) {
4665
4653
  super(o, a);
4666
- G(this, "setRef", (o) => {
4654
+ X(this, "setRef", (o) => {
4667
4655
  this.nodeRef.current = o;
4668
4656
  const { forwardedRef: a } = this.props;
4669
4657
  typeof a == "function" ? a(o) : a && (a.current = o);
4670
4658
  });
4671
- G(this, "handleLoad", () => {
4659
+ X(this, "handleLoad", () => {
4672
4660
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
4673
4661
  });
4674
4662
  // In certain situations on a cold cache DOMContentLoaded never gets called
4675
4663
  // fallback to an interval to check if that's the case
4676
- G(this, "loadCheck", () => setInterval(() => {
4664
+ X(this, "loadCheck", () => setInterval(() => {
4677
4665
  this.handleLoad();
4678
4666
  }, 500));
4679
4667
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -4710,7 +4698,7 @@ class Frame extends Component {
4710
4698
  return delete o.head, delete o.initialContent, delete o.mountTarget, delete o.contentDidMount, delete o.contentDidUpdate, delete o.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...o, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
4711
4699
  }
4712
4700
  }
4713
- G(Frame, "defaultProps", {
4701
+ X(Frame, "defaultProps", {
4714
4702
  style: {},
4715
4703
  head: null,
4716
4704
  children: void 0,
@@ -4898,7 +4886,7 @@ const ChaiFrame = React__default.forwardRef((r, n) => /* @__PURE__ */ jsx(Frame,
4898
4886
  }, useDirectBlockDrag = () => {
4899
4887
  const [, r] = useSelectedBlockIds(), { onDragStart: n, onDragEnd: o } = useDragAndDrop(), [a] = useBlocksStore(), i = useRef(null), [l, c] = useAtom$1(lastClickTimeAtom), [d, u] = useAtom$1(clickCountAtom), p = useCallback(
4900
4888
  (m) => {
4901
- var S;
4889
+ var k;
4902
4890
  if (m.button !== 0) return;
4903
4891
  const g = Date.now(), b = g - l;
4904
4892
  if (b < 400 && b > 0) {
@@ -4906,7 +4894,7 @@ const ChaiFrame = React__default.forwardRef((r, n) => /* @__PURE__ */ jsx(Frame,
4906
4894
  return;
4907
4895
  }
4908
4896
  c(g);
4909
- const y = (S = m.target.closest("[data-block-id]")) == null ? void 0 : S.getAttribute("data-block-id");
4897
+ const y = (k = m.target.closest("[data-block-id]")) == null ? void 0 : k.getAttribute("data-block-id");
4910
4898
  y && (r([y]), i.current = y);
4911
4899
  },
4912
4900
  [r, l, c, d, u]
@@ -4957,12 +4945,12 @@ const RteDropdownMenu = ({
4957
4945
  }) => {
4958
4946
  const { document: l } = useFrame(), [c, d] = useState({ left: void 0, right: void 0, top: void 0, bottom: void 0 }), [u, p] = useState(!1), h = useRef(null);
4959
4947
  if (useEffect(() => {
4960
- var S, k;
4948
+ var k, S;
4961
4949
  if (!u) {
4962
4950
  d({ left: void 0, right: void 0, top: void 0, bottom: void 0 });
4963
4951
  return;
4964
4952
  }
4965
- const f = (S = h.current) == null ? void 0 : S.getBoundingClientRect(), m = (k = i.current) == null ? void 0 : k.getBoundingClientRect();
4953
+ const f = (k = h.current) == null ? void 0 : k.getBoundingClientRect(), m = (S = i.current) == null ? void 0 : S.getBoundingClientRect();
4966
4954
  let g = f == null ? void 0 : f.left, b = (f == null ? void 0 : f.bottom) + 4, x, y;
4967
4955
  (m == null ? void 0 : m.left) + (m == null ? void 0 : m.width) + 50 >= l.body.offsetWidth && (g = void 0, x = l.body.offsetWidth - (f == null ? void 0 : f.right)), b + 202 >= l.body.clientHeight && (b = null, y = l.body.clientHeight - (f == null ? void 0 : f.bottom) + (m == null ? void 0 : m.height)), d({ left: g, top: b, right: x, bottom: y });
4968
4956
  }, [u]), a === "canvas") {
@@ -5113,8 +5101,8 @@ const getActiveClasses$1 = (r, n, o) => {
5113
5101
  )
5114
5102
  ] });
5115
5103
  }, RteColorPicker = ({ editor: r, from: n, menuRef: o }) => {
5116
- var k, C;
5117
- const a = (k = r == null ? void 0 : r.getAttributes("textStyle")) == null ? void 0 : k.color, i = (C = r == null ? void 0 : r.getAttributes("highlight")) == null ? void 0 : C.color, [l, c] = useState(a || "#000000F2"), [d, u] = useState(i || "#00000057"), [p, h] = useDebouncedState(l, 150), [f, m] = useDebouncedState(d, 150), g = (E, B) => {
5104
+ var S, v;
5105
+ const a = (S = r == null ? void 0 : r.getAttributes("textStyle")) == null ? void 0 : S.color, i = (v = r == null ? void 0 : r.getAttributes("highlight")) == null ? void 0 : v.color, [l, c] = useState(a || "#000000F2"), [d, u] = useState(i || "#00000057"), [p, h] = useDebouncedState(l, 150), [f, m] = useDebouncedState(d, 150), g = (E, B) => {
5118
5106
  B ? (c(E), h(E)) : (r == null || r.chain().setColor(E).run(), c(E));
5119
5107
  }, b = (E, B) => {
5120
5108
  B ? (u(E), m(E)) : (r == null || r.chain().setHighlight({ color: E }).run(), u(E));
@@ -6395,7 +6383,7 @@ class NodeRange {
6395
6383
  }
6396
6384
  }
6397
6385
  const emptyAttrs = /* @__PURE__ */ Object.create(null);
6398
- let Node$2 = class Y {
6386
+ let Node$2 = class ee {
6399
6387
  /**
6400
6388
  @internal
6401
6389
  */
@@ -6520,14 +6508,14 @@ let Node$2 = class Y {
6520
6508
  the given content (or empty, if no content is given).
6521
6509
  */
6522
6510
  copy(n = null) {
6523
- return n == this.content ? this : new Y(this.type, this.attrs, n, this.marks);
6511
+ return n == this.content ? this : new ee(this.type, this.attrs, n, this.marks);
6524
6512
  }
6525
6513
  /**
6526
6514
  Create a copy of this node, with the given set of marks instead
6527
6515
  of the node's own marks.
6528
6516
  */
6529
6517
  mark(n) {
6530
- return n == this.marks ? this : new Y(this.type, this.attrs, this.content, n);
6518
+ return n == this.marks ? this : new ee(this.type, this.attrs, this.content, n);
6531
6519
  }
6532
6520
  /**
6533
6521
  Create a copy of this node with only the content between the
@@ -8737,8 +8725,8 @@ class Fitter {
8737
8725
  let b = p == d.childCount;
8738
8726
  b || (g = -1), this.placed = addToFragment(this.placed, o, Fragment.from(h)), this.frontier[o].match = f, b && g < 0 && a && a.type == this.frontier[this.depth].type && this.frontier.length > 1 && this.closeFrontierNode();
8739
8727
  for (let x = 0, y = d; x < g; x++) {
8740
- let S = y.lastChild;
8741
- this.frontier.push({ type: S.type, match: S.contentMatchAt(S.childCount) }), y = S.content;
8728
+ let k = y.lastChild;
8729
+ this.frontier.push({ type: k.type, match: k.contentMatchAt(k.childCount) }), y = k.content;
8742
8730
  }
8743
8731
  this.unplaced = b ? n == 0 ? Slice.empty : new Slice(dropFromFragment(c.content, n - 1, 1), n - 1, g < 0 ? c.openEnd : n - 1) : new Slice(dropFromFragment(c.content, n, p), c.openStart, c.openEnd);
8744
8732
  }
@@ -9617,8 +9605,8 @@ function deleteBarrier(r, n, o, a) {
9617
9605
  if (p && (c = (d = i.contentMatchAt(i.childCount)).findWrapping(l.type)) && d.matchType(c[0] || l.type).validEnd) {
9618
9606
  if (o) {
9619
9607
  let g = n.pos + l.nodeSize, b = Fragment.empty;
9620
- for (let S = c.length - 1; S >= 0; S--)
9621
- b = Fragment.from(c[S].create(null, b));
9608
+ for (let k = c.length - 1; k >= 0; k--)
9609
+ b = Fragment.from(c[k].create(null, b));
9622
9610
  b = Fragment.from(i.copy(b));
9623
9611
  let x = r.tr.step(new ReplaceAroundStep(n.pos - 1, g, n.pos, g, new Slice(b, 1, 0), c.length, !0)), y = x.doc.resolve(g + 2 * c.length);
9624
9612
  y.nodeAfter && y.nodeAfter.type == i.type && canJoin(x.doc, y.pos) && x.join(y.pos), o(x.scrollIntoView());
@@ -9637,11 +9625,11 @@ function deleteBarrier(r, n, o, a) {
9637
9625
  y++;
9638
9626
  if (g.canReplace(g.childCount, g.childCount, x.content)) {
9639
9627
  if (o) {
9640
- let S = Fragment.empty;
9641
- for (let C = b.length - 1; C >= 0; C--)
9642
- S = Fragment.from(b[C].copy(S));
9643
- let k = r.tr.step(new ReplaceAroundStep(n.pos - b.length, n.pos + l.nodeSize, n.pos + y, n.pos + l.nodeSize - y, new Slice(S, b.length, 0), 0, !0));
9644
- o(k.scrollIntoView());
9628
+ let k = Fragment.empty;
9629
+ for (let v = b.length - 1; v >= 0; v--)
9630
+ k = Fragment.from(b[v].copy(k));
9631
+ let S = r.tr.step(new ReplaceAroundStep(n.pos - b.length, n.pos + l.nodeSize, n.pos + y, n.pos + l.nodeSize - y, new Slice(k, b.length, 0), 0, !0));
9632
+ o(S.scrollIntoView());
9645
9633
  }
9646
9634
  return !0;
9647
9635
  }
@@ -9828,8 +9816,8 @@ class CommandManager {
9828
9816
  createChain(n, o = !0) {
9829
9817
  const { rawCommands: a, editor: i, state: l } = this, { view: c } = i, d = [], u = !!n, p = n || l.tr, h = () => (!u && o && !p.getMeta("preventDispatch") && !this.hasCustomState && c.dispatch(p), d.every((m) => m === !0)), f = {
9830
9818
  ...Object.fromEntries(Object.entries(a).map(([m, g]) => [m, (...x) => {
9831
- const y = this.buildProps(p, o), S = g(...x)(y);
9832
- return d.push(S), f;
9819
+ const y = this.buildProps(p, o), k = g(...x)(y);
9820
+ return d.push(k), f;
9833
9821
  }])),
9834
9822
  run: h
9835
9823
  };
@@ -10270,8 +10258,8 @@ const isFragment = (r) => !("type" in r), insertContentAt = (r, n, o) => ({ tr:
10270
10258
  x = n.map((y) => y.text || "").join("");
10271
10259
  else if (n instanceof Fragment) {
10272
10260
  let y = "";
10273
- n.forEach((S) => {
10274
- S.text && (y += S.text);
10261
+ n.forEach((k) => {
10262
+ k.text && (y += k.text);
10275
10263
  }), x = y;
10276
10264
  } else typeof n == "object" && n && n.text ? x = n.text : x = n;
10277
10265
  a.insertText(x, h, f);
@@ -10452,11 +10440,11 @@ function isMarkActive(r, n, o = {}) {
10452
10440
  r.doc.nodesBetween(g, b, (x, y) => {
10453
10441
  if (!x.isText && !x.marks.length)
10454
10442
  return;
10455
- const S = Math.max(g, y), k = Math.min(b, y + x.nodeSize), C = k - S;
10456
- c += C, d.push(...x.marks.map((E) => ({
10443
+ const k = Math.max(g, y), S = Math.min(b, y + x.nodeSize), v = S - k;
10444
+ c += v, d.push(...x.marks.map((E) => ({
10457
10445
  mark: E,
10458
- from: S,
10459
- to: k
10446
+ from: k,
10447
+ to: S
10460
10448
  })));
10461
10449
  });
10462
10450
  }), c === 0)
@@ -10533,9 +10521,9 @@ const setMark = (r, n = {}) => ({ tr: o, state: a, dispatch: i }) => {
10533
10521
  const h = p.$from.pos, f = p.$to.pos;
10534
10522
  a.doc.nodesBetween(h, f, (m, g) => {
10535
10523
  const b = Math.max(g, h), x = Math.min(g + m.nodeSize, f);
10536
- m.marks.find((S) => S.type === u) ? m.marks.forEach((S) => {
10537
- u === S.type && o.addMark(b, x, u.create({
10538
- ...S.attrs,
10524
+ m.marks.find((k) => k.type === u) ? m.marks.forEach((k) => {
10525
+ u === k.type && o.addMark(b, x, u.create({
10526
+ ...k.attrs,
10539
10527
  ...n
10540
10528
  }));
10541
10529
  }) : o.addMark(b, x, u.create(n));
@@ -10608,23 +10596,23 @@ const splitBlock = ({ keepMarks: r = !0 } = {}) => ({ tr: n, state: o, dispatch:
10608
10596
  if (u.depth === 2 || u.node(-3).type !== d || u.index(-2) !== u.node(-2).childCount - 1)
10609
10597
  return !1;
10610
10598
  if (i) {
10611
- let S = Fragment.empty;
10612
- const k = u.index(-1) ? 1 : u.index(-2) ? 2 : 3;
10613
- for (let A = u.depth - k; A >= u.depth - 3; A -= 1)
10614
- S = Fragment.from(u.node(A).copy(S));
10615
- const C = u.indexAfter(-1) < u.node(-2).childCount ? 1 : u.indexAfter(-2) < u.node(-3).childCount ? 2 : 3, E = {
10599
+ let k = Fragment.empty;
10600
+ const S = u.index(-1) ? 1 : u.index(-2) ? 2 : 3;
10601
+ for (let w = u.depth - S; w >= u.depth - 3; w -= 1)
10602
+ k = Fragment.from(u.node(w).copy(k));
10603
+ const v = u.indexAfter(-1) < u.node(-2).childCount ? 1 : u.indexAfter(-2) < u.node(-3).childCount ? 2 : 3, E = {
10616
10604
  ...getSplittedAttributes(m, u.node().type.name, u.node().attrs),
10617
10605
  ...n
10618
10606
  }, B = ((c = d.contentMatch.defaultType) === null || c === void 0 ? void 0 : c.createAndFill(E)) || void 0;
10619
- S = S.append(Fragment.from(d.createAndFill(null, B) || void 0));
10620
- const I = u.before(u.depth - (k - 1));
10621
- o.replace(I, u.after(-C), new Slice(S, 4 - k, 0));
10622
- let w = -1;
10623
- o.doc.nodesBetween(I, o.doc.content.size, (A, v) => {
10624
- if (w > -1)
10607
+ k = k.append(Fragment.from(d.createAndFill(null, B) || void 0));
10608
+ const I = u.before(u.depth - (S - 1));
10609
+ o.replace(I, u.after(-v), new Slice(k, 4 - S, 0));
10610
+ let A = -1;
10611
+ o.doc.nodesBetween(I, o.doc.content.size, (w, C) => {
10612
+ if (A > -1)
10625
10613
  return !1;
10626
- A.isTextblock && A.content.size === 0 && (w = v + 1);
10627
- }), w > -1 && o.setSelection(TextSelection.near(o.doc.resolve(w))), o.scrollIntoView();
10614
+ w.isTextblock && w.content.size === 0 && (A = C + 1);
10615
+ }), A > -1 && o.setSelection(TextSelection.near(o.doc.resolve(A))), o.scrollIntoView();
10628
10616
  }
10629
10617
  return !0;
10630
10618
  }
@@ -10643,10 +10631,10 @@ const splitBlock = ({ keepMarks: r = !0 } = {}) => ({ tr: n, state: o, dispatch:
10643
10631
  if (!canSplit(o.doc, u.pos, 2))
10644
10632
  return !1;
10645
10633
  if (i) {
10646
- const { selection: S, storedMarks: k } = a, { splittableMarks: C } = l.extensionManager, E = k || S.$to.parentOffset && S.$from.marks();
10634
+ const { selection: k, storedMarks: S } = a, { splittableMarks: v } = l.extensionManager, E = S || k.$to.parentOffset && k.$from.marks();
10647
10635
  if (o.split(u.pos, 2, y).scrollIntoView(), !E || !i)
10648
10636
  return !0;
10649
- const B = E.filter((I) => C.includes(I.type.name));
10637
+ const B = E.filter((I) => v.includes(I.type.name));
10650
10638
  o.ensureMarks(B);
10651
10639
  }
10652
10640
  return !0;
@@ -10669,19 +10657,19 @@ const splitBlock = ({ keepMarks: r = !0 } = {}) => ({ tr: n, state: o, dispatch:
10669
10657
  const i = r.doc.nodeAt(a);
10670
10658
  return o.node.type === (i == null ? void 0 : i.type) && canJoin(r.doc, a) && r.join(a), !0;
10671
10659
  }, toggleList = (r, n, o, a = {}) => ({ editor: i, tr: l, state: c, dispatch: d, chain: u, commands: p, can: h }) => {
10672
- const { extensions: f, splittableMarks: m } = i.extensionManager, g = getNodeType(r, c.schema), b = getNodeType(n, c.schema), { selection: x, storedMarks: y } = c, { $from: S, $to: k } = x, C = S.blockRange(k), E = y || x.$to.parentOffset && x.$from.marks();
10673
- if (!C)
10660
+ const { extensions: f, splittableMarks: m } = i.extensionManager, g = getNodeType(r, c.schema), b = getNodeType(n, c.schema), { selection: x, storedMarks: y } = c, { $from: k, $to: S } = x, v = k.blockRange(S), E = y || x.$to.parentOffset && x.$from.marks();
10661
+ if (!v)
10674
10662
  return !1;
10675
10663
  const B = findParentNode((I) => isList(I.type.name, f))(x);
10676
- if (C.depth >= 1 && B && C.depth - B.depth <= 1) {
10664
+ if (v.depth >= 1 && B && v.depth - B.depth <= 1) {
10677
10665
  if (B.node.type === g)
10678
10666
  return p.liftListItem(b);
10679
10667
  if (isList(B.node.type.name, f) && g.validContent(B.node.content) && d)
10680
10668
  return u().command(() => (l.setNodeMarkup(B.pos, g), !0)).command(() => joinListBackwards(l, g)).command(() => joinListForwards(l, g)).run();
10681
10669
  }
10682
10670
  return !o || !E || !d ? u().command(() => h().wrapInList(g, a) ? !0 : p.clearNodes()).wrapInList(g, a).command(() => joinListBackwards(l, g)).command(() => joinListForwards(l, g)).run() : u().command(() => {
10683
- const I = h().wrapInList(g, a), w = E.filter((A) => m.includes(A.type.name));
10684
- return l.ensureMarks(w), I ? !0 : p.clearNodes();
10671
+ const I = h().wrapInList(g, a), A = E.filter((w) => m.includes(w.type.name));
10672
+ return l.ensureMarks(A), I ? !0 : p.clearNodes();
10685
10673
  }).wrapInList(g, a).command(() => joinListBackwards(l, g)).command(() => joinListForwards(l, g)).run();
10686
10674
  }, toggleMark = (r, n = {}, o = {}) => ({ state: a, commands: i }) => {
10687
10675
  const { extendEmptyMarkRange: l = !1 } = o, c = getMarkType(r, a.schema);
@@ -10744,11 +10732,11 @@ const splitBlock = ({ keepMarks: r = !0 } = {}) => ({ tr: n, state: o, dispatch:
10744
10732
  y < p && l && l === x.type && (g = Math.max(y, p), b = Math.min(y + x.nodeSize, h), f = y, m = x), y >= p && y <= h && (l && l === x.type && o.setNodeMarkup(y, void 0, {
10745
10733
  ...x.attrs,
10746
10734
  ...n
10747
- }), c && x.marks.length && x.marks.forEach((S) => {
10748
- if (c === S.type) {
10749
- const k = Math.max(y, p), C = Math.min(y + x.nodeSize, h);
10750
- o.addMark(k, C, c.create({
10751
- ...S.attrs,
10735
+ }), c && x.marks.length && x.marks.forEach((k) => {
10736
+ if (c === k.type) {
10737
+ const S = Math.max(y, p), v = Math.min(y + x.nodeSize, h);
10738
+ o.addMark(S, v, c.create({
10739
+ ...k.attrs,
10752
10740
  ...n
10753
10741
  }));
10754
10742
  }
@@ -10905,8 +10893,8 @@ Extension.create({
10905
10893
  () => c.undoInputRule(),
10906
10894
  // maybe convert first text block node to default node
10907
10895
  () => c.command(({ tr: d }) => {
10908
- const { selection: u, doc: p } = d, { empty: h, $anchor: f } = u, { pos: m, parent: g } = f, b = f.parent.isTextblock && m > 0 ? d.doc.resolve(m - 1) : f, x = b.parent.type.spec.isolating, y = f.pos - f.parentOffset, S = x && b.parent.childCount === 1 ? y === f.pos : Selection.atStart(p).from === m;
10909
- return !h || !g.type.isTextblock || g.textContent.length || !S || S && f.parent.type.name === "paragraph" ? !1 : c.clearNodes();
10896
+ const { selection: u, doc: p } = d, { empty: h, $anchor: f } = u, { pos: m, parent: g } = f, b = f.parent.isTextblock && m > 0 ? d.doc.resolve(m - 1) : f, x = b.parent.type.spec.isolating, y = f.pos - f.parentOffset, k = x && b.parent.childCount === 1 ? y === f.pos : Selection.atStart(p).from === m;
10897
+ return !h || !g.type.isTextblock || g.textContent.length || !k || k && f.parent.type.name === "paragraph" ? !1 : c.clearNodes();
10910
10898
  }),
10911
10899
  () => c.deleteSelection(),
10912
10900
  () => c.joinBackward(),
@@ -11117,10 +11105,10 @@ const RichTextEditor = memo(
11117
11105
  placeholder: "Enter text here",
11118
11106
  onUpdate: ({ editor: p }) => a((p == null ? void 0 : p.getHTML()) || ""),
11119
11107
  onBlur: ({ editor: p, event: h }) => {
11120
- const f = h == null ? void 0 : h.relatedTarget, m = l.querySelector(".ProseMirror"), g = l.querySelector(".tippy-box"), b = l.querySelector("#chai-rich-text-menu-bar"), x = m == null ? void 0 : m.contains(f), y = g == null ? void 0 : g.contains(f), S = b == null ? void 0 : b.contains(f), k = window.document.getElementById("rte-widget-color-picker");
11121
- if (!x && !y && !S && !k) {
11122
- const C = (p == null ? void 0 : p.getHTML()) || "";
11123
- o(C);
11108
+ const f = h == null ? void 0 : h.relatedTarget, m = l.querySelector(".ProseMirror"), g = l.querySelector(".tippy-box"), b = l.querySelector("#chai-rich-text-menu-bar"), x = m == null ? void 0 : m.contains(f), y = g == null ? void 0 : g.contains(f), k = b == null ? void 0 : b.contains(f), S = window.document.getElementById("rte-widget-color-picker");
11109
+ if (!x && !y && !k && !S) {
11110
+ const v = (p == null ? void 0 : p.getHTML()) || "";
11111
+ o(v);
11124
11112
  }
11125
11113
  },
11126
11114
  from: "canvas"
@@ -11220,30 +11208,30 @@ const RichTextEditor = memo(
11220
11208
  }
11221
11209
  ), WithBlockTextEditor = memo(
11222
11210
  ({ block: r, children: n }) => {
11223
- const o = "content", { document: a } = useFrame(), { editingBlockId: i, editingItemIndex: l, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [u, p] = useState(null), h = useRef(null), { clearHighlight: f } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: g } = useLanguages(), [, b] = useSelectedBlockIds(), x = useRef(null), y = i, { blockContent: S, blockType: k } = useMemo(() => {
11211
+ const o = "content", { document: a } = useFrame(), { editingBlockId: i, editingItemIndex: l, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [u, p] = useState(null), h = useRef(null), { clearHighlight: f } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: g } = useLanguages(), [, b] = useSelectedBlockIds(), x = useRef(null), y = i, { blockContent: k, blockType: S } = useMemo(() => {
11224
11212
  var N;
11225
- const w = r._type;
11226
- let A = r[o];
11227
- const v = getRegisteredChaiBlock(r._type);
11228
- return g && ((N = v == null ? void 0 : v.i18nProps) == null ? void 0 : N.includes(o)) && has(r, `${o}-${g}`) && (A = get(r, `${o}-${g}`)), { blockContent: A, blockType: w };
11229
- }, [r, g]), C = useCallback(
11230
- (w) => {
11231
- var v;
11232
- const A = w || ((v = h.current) == null ? void 0 : v.innerText);
11233
- m([y], { [o]: A }), p(null), c(null), d(-1), b([]), y && setTimeout(() => b([y]), 100);
11213
+ const A = r._type;
11214
+ let w = r[o];
11215
+ const C = getRegisteredChaiBlock(r._type);
11216
+ return g && ((N = C == null ? void 0 : C.i18nProps) == null ? void 0 : N.includes(o)) && has(r, `${o}-${g}`) && (w = get(r, `${o}-${g}`)), { blockContent: w, blockType: A };
11217
+ }, [r, g]), v = useCallback(
11218
+ (A) => {
11219
+ var C;
11220
+ const w = A || ((C = h.current) == null ? void 0 : C.innerText);
11221
+ m([y], { [o]: w }), p(null), c(null), d(-1), b([]), y && setTimeout(() => b([y]), 100);
11234
11222
  },
11235
11223
  [y, m, c, b, g]
11236
11224
  ), E = useDebouncedCallback(
11237
- (w) => {
11238
- m([y], { [o]: w });
11225
+ (A) => {
11226
+ m([y], { [o]: A });
11239
11227
  },
11240
11228
  [y, r, m, g],
11241
11229
  1e3
11242
11230
  ), B = useCallback(
11243
- (w) => {
11244
- w.preventDefault(), y && (x.current = y), C(), setTimeout(() => {
11245
- const A = x.current;
11246
- x.current = null, b([A]);
11231
+ (A) => {
11232
+ A.preventDefault(), y && (x.current = y), v(), setTimeout(() => {
11233
+ const w = x.current;
11234
+ x.current = null, b([w]);
11247
11235
  }, 100);
11248
11236
  },
11249
11237
  [b, y, g]
@@ -11251,29 +11239,29 @@ const RichTextEditor = memo(
11251
11239
  useEffect(() => {
11252
11240
  var T;
11253
11241
  if (!y) return;
11254
- const w = `[data-block-id="${y}"]`, A = l >= 0 ? `[data-block-index="${l}"]` : "", v = a.querySelector(`${w}${A}`);
11255
- v && ((T = v == null ? void 0 : v.classList) == null || T.add("sr-only"), p(v));
11256
- }, [y, k, a, l]);
11257
- const I = useMemo(() => u ? (f(), ["RichText", "Paragraph"].includes(k) ? /* @__PURE__ */ jsx(
11242
+ const A = `[data-block-id="${y}"]`, w = l >= 0 ? `[data-block-index="${l}"]` : "", C = a.querySelector(`${A}${w}`);
11243
+ C && ((T = C == null ? void 0 : C.classList) == null || T.add("sr-only"), p(C));
11244
+ }, [y, S, a, l]);
11245
+ const I = useMemo(() => u ? (f(), ["RichText", "Paragraph"].includes(S) ? /* @__PURE__ */ jsx(
11258
11246
  RichTextEditor,
11259
11247
  {
11260
- blockContent: S,
11248
+ blockContent: k,
11261
11249
  editingElement: u,
11262
11250
  onChange: E,
11263
- onClose: C,
11251
+ onClose: v,
11264
11252
  onEscape: B
11265
11253
  }
11266
11254
  ) : /* @__PURE__ */ jsx(
11267
11255
  MemoizedEditor,
11268
11256
  {
11269
11257
  editorRef: h,
11270
- blockContent: S,
11258
+ blockContent: k,
11271
11259
  editingElement: u,
11272
- onClose: C,
11260
+ onClose: v,
11273
11261
  onChange: E,
11274
11262
  onEscape: B
11275
11263
  }
11276
- )) : null, [u, y, k, S, C, g]);
11264
+ )) : null, [u, y, S, k, v, g]);
11277
11265
  return /* @__PURE__ */ jsxs(Fragment$1, { children: [
11278
11266
  I,
11279
11267
  n
@@ -11308,7 +11296,7 @@ const RichTextEditor = memo(
11308
11296
  blockAtom: n,
11309
11297
  children: o
11310
11298
  }) => {
11311
- const { editingBlockId: a, editingItemIndex: i } = useInlineEditing(), [l] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: d, fallbackLang: u } = useLanguages(), p = useBlockRuntimeProps(), h = usePageExternalData(), [f] = useAtom$1(dataBindingActiveAtom), m = get(c, "component", null), { index: g, key: b } = useContext(RepeaterContext), { mode: x } = useEditorMode(), y = useAtomValue$1(chaiDesignTokensAtom), S = useIsDragAndDropEnabled(), k = x === "edit", C = useDirectBlockDrag(), E = useMemo(
11299
+ const { editingBlockId: a, editingItemIndex: i } = useInlineEditing(), [l] = useAtom$1(n), c = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: d, fallbackLang: u } = useLanguages(), p = useBlockRuntimeProps(), h = usePageExternalData(), [f] = useAtom$1(dataBindingActiveAtom), m = get(c, "component", null), { index: g, key: b } = useContext(RepeaterContext), { mode: x } = useEditorMode(), y = useAtomValue$1(chaiDesignTokensAtom), k = useIsDragAndDropEnabled(), S = x === "edit", v = useDirectBlockDrag(), E = useMemo(
11312
11300
  () => f ? applyBindingToBlockProps(applyLanguage(l, d, c), h, {
11313
11301
  index: g,
11314
11302
  key: b
@@ -11320,22 +11308,22 @@ const RichTextEditor = memo(
11320
11308
  ), I = useMemo(
11321
11309
  () => p(l._id, getBlockRuntimeProps(l._type)),
11322
11310
  [l._id, l._type, p, getBlockRuntimeProps]
11323
- ), w = useMemo(() => {
11311
+ ), A = useMemo(() => {
11324
11312
  const P = {
11325
11313
  "data-block-id": l._id,
11326
11314
  "data-block-type": l._type,
11327
11315
  "data-block-index": g
11328
11316
  };
11329
- return k && S ? {
11317
+ return S && k ? {
11330
11318
  ...P,
11331
11319
  draggable: !a,
11332
- onMouseDown: C.onMouseDown,
11333
- onDragStart: C.onDragStart,
11334
- onDragEnd: C.onDragEnd
11320
+ onMouseDown: v.onMouseDown,
11321
+ onDragStart: v.onDragStart,
11322
+ onDragEnd: v.onDragEnd
11335
11323
  } : P;
11336
- }, [l._id, l._type, g, k, S, C, a]), A = useMemo(
11324
+ }, [l._id, l._type, g, S, k, v, a]), w = useMemo(
11337
11325
  () => ({
11338
- blockProps: w,
11326
+ blockProps: A,
11339
11327
  inBuilder: x === "edit",
11340
11328
  lang: d || u,
11341
11329
  pageData: h,
@@ -11344,11 +11332,11 @@ const RichTextEditor = memo(
11344
11332
  ...I,
11345
11333
  ...r
11346
11334
  }),
11347
- [x, w, d, u, E, B, I, r]
11348
- ), v = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]), T = useMemo(() => get(l, "_show", !0), [l]);
11335
+ [x, A, d, u, E, B, I, r]
11336
+ ), C = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]), T = useMemo(() => get(l, "_show", !0), [l]);
11349
11337
  if (isNull(m) || !T) return null;
11350
11338
  let N = /* @__PURE__ */ jsx(Suspense, { children: createElement(m, {
11351
- ...A,
11339
+ ...w,
11352
11340
  children: o({
11353
11341
  _id: l._id,
11354
11342
  _type: l._type,
@@ -11361,7 +11349,7 @@ const RichTextEditor = memo(
11361
11349
  })
11362
11350
  }) });
11363
11351
  const j = a === l._id && (i === g || g < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: l, children: N }) : N;
11364
- return v ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: j }) : j;
11352
+ return C ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: j }) : j;
11365
11353
  }, PartialWrapper$1 = ({ children: r, partialBlockId: n }) => {
11366
11354
  const o = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: i, fallbackLang: l } = useLanguages(), c = useCallback(
11367
11355
  (d) => {
@@ -11465,14 +11453,14 @@ const RichTextEditor = memo(
11465
11453
  }, StaticCanvas = () => {
11466
11454
  const [r] = useCanvasDisplayWidth(), [, n] = useHighlightBlockId(), o = useRef(null), a = useRef(null), [i, l] = useState({ width: 0, height: 0 }), c = useCanvasScale(i), [, d] = useCanvasIframe(), u = useBuilderProp("loading", !1), p = useBuilderProp("htmlDir", "ltr"), { onDragOver: h, onDrop: f, onDragEnd: m } = useDragAndDrop(), g = useDropIndicator(), b = useCallback(
11467
11455
  (y) => {
11468
- l((S) => ({ ...S, width: y }));
11456
+ l((k) => ({ ...k, width: y }));
11469
11457
  },
11470
11458
  [l]
11471
11459
  );
11472
11460
  useEffect(() => {
11473
11461
  if (!a.current) return;
11474
- const { clientWidth: y, clientHeight: S } = a.current;
11475
- l({ width: y, height: S });
11462
+ const { clientWidth: y, clientHeight: k } = a.current;
11463
+ l({ width: y, height: k });
11476
11464
  }, [a, r]);
11477
11465
  const x = useMemo(() => {
11478
11466
  let y = IframeInitialContent;
@@ -11531,7 +11519,7 @@ const RichTextEditor = memo(
11531
11519
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: r("Oops! Something went wrong.") }),
11532
11520
  /* @__PURE__ */ jsx("p", { children: r("Please try again.") })
11533
11521
  ] }) });
11534
- }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-Bbeel8oa.js")), CanvasArea = () => {
11522
+ }, CodeEditor$1 = React__default.lazy(() => import("./code-editor-vpbOSO05.js")), CanvasArea = () => {
11535
11523
  const [r] = useCodeEditor(), n = useBuilderProp("onError", noop);
11536
11524
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40", children: [
11537
11525
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -11668,52 +11656,52 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
11668
11656
  if (!r || startsWith(r, "data")) return "";
11669
11657
  const n = ((i = r.split("/").pop()) == null ? void 0 : i.split("?")[0]) || "";
11670
11658
  return [".jpg", ".jpeg", ".png", ".gif", ".webp", ".svg", ".bmp", ".ico", ".avif"].some((l) => n.toLowerCase().endsWith(l)) ? n : "";
11671
- }, ImagePickerField = ({ value: r, onChange: n, id: o, onBlur: a }) => {
11672
- const { t: i } = useTranslation(), { selectedLang: l } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), u = usePageExternalData(), p = o.split(".").pop() || "", h = l ? `_${p}Id-${l}` : `_${p}Id`, f = isEmpty(l) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), m = get(c, h, f ? c == null ? void 0 : c.assetId : ""), g = useMemo(() => {
11673
- if (!r || !c || !/\{\{.*?\}\}/.test(r)) return r;
11674
- const C = { ...c, [p]: r }, E = applyBindingToBlockProps(C, u, { index: -1, key: "" });
11675
- return get(E, p, r);
11676
- }, [r, c, u, p]), b = !!m || g !== PLACEHOLDER_IMAGE, x = (k) => {
11677
- const C = isArray(k) ? first$1(k) : k;
11678
- if (C) {
11679
- n(C == null ? void 0 : C.url);
11680
- const E = C == null ? void 0 : C.width, B = C == null ? void 0 : C.height, I = h.includes("mobile");
11681
- if (c != null && c._id) {
11682
- const w = {
11683
- ...E && { [I ? "mobileWidth" : "width"]: E },
11684
- ...B && { [I ? "mobileHeight" : "height"]: B },
11685
- ...C.description && { alt: C.description }
11659
+ }, ImagePickerField = ({ value: r, onChange: n, id: o, onBlur: a, uiSchema: i }) => {
11660
+ const { t: l } = useTranslation(), { selectedLang: c } = useLanguages(), d = useSelectedBlock(), u = useUpdateBlocksProps(), p = usePageExternalData(), h = (i == null ? void 0 : i["ui:allowEmpty"]) === !0, f = o.split(".").pop() || "", m = c ? `_${f}Id-${c}` : `_${f}Id`, g = isEmpty(c) && (d == null ? void 0 : d._type) === "Image" && has(d, "assetId"), b = get(d, m, g ? d == null ? void 0 : d.assetId : ""), x = useMemo(() => {
11661
+ if (!r || !d || !/\{\{.*?\}\}/.test(r)) return r;
11662
+ const B = { ...d, [f]: r }, I = applyBindingToBlockProps(B, p, { index: -1, key: "" });
11663
+ return get(I, f, r);
11664
+ }, [r, d, p, f]), y = !!b || x !== PLACEHOLDER_IMAGE && x !== "", k = (E) => {
11665
+ const B = isArray(E) ? first$1(E) : E;
11666
+ if (B) {
11667
+ n(B == null ? void 0 : B.url);
11668
+ const I = B == null ? void 0 : B.width, A = B == null ? void 0 : B.height, w = m.includes("mobile");
11669
+ if (d != null && d._id) {
11670
+ const C = {
11671
+ ...I && { [w ? "mobileWidth" : "width"]: I },
11672
+ ...A && { [w ? "mobileHeight" : "height"]: A },
11673
+ ...B.description && { alt: B.description }
11686
11674
  };
11687
- if (set(w, h, C.id), isEmpty(w)) return;
11688
- d([c._id], w);
11675
+ if (set(C, m, B.id), isEmpty(C)) return;
11676
+ u([d._id], C);
11689
11677
  }
11690
11678
  }
11691
- }, y = useCallback(() => {
11692
- if (n(PLACEHOLDER_IMAGE), c != null && c._id) {
11693
- const k = {}, C = h.includes("mobile");
11694
- set(k, h, ""), set(k, C ? "mobileWidth" : "width", ""), set(k, C ? "mobileHeight" : "height", ""), d([c._id], k);
11679
+ }, S = useCallback(() => {
11680
+ if (n(h ? "" : PLACEHOLDER_IMAGE), d != null && d._id) {
11681
+ const B = {}, I = m.includes("mobile");
11682
+ set(B, m, ""), set(B, I ? "mobileWidth" : "width", ""), set(B, I ? "mobileHeight" : "height", ""), u([d._id], B);
11695
11683
  }
11696
- }, [n, c == null ? void 0 : c._id, d, h]), S = getFileName(g);
11684
+ }, [n, d == null ? void 0 : d._id, u, m, h]), v = getFileName(x);
11697
11685
  return /* @__PURE__ */ jsxs("div", { className: "mt-1.5 flex items-start gap-x-3", children: [
11698
- g ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
11686
+ x ? /* @__PURE__ */ jsxs("div", { className: "group relative", children: [
11699
11687
  /* @__PURE__ */ jsx(
11700
11688
  "img",
11701
11689
  {
11702
- src: g,
11703
- className: "h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (m && m !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
11690
+ src: x,
11691
+ className: "h-14 w-14 overflow-hidden rounded-md border border-border object-cover transition duration-200 " + (b && b !== "" ? "cursor-pointer group-hover:blur-sm" : ""),
11704
11692
  alt: ""
11705
11693
  }
11706
11694
  ),
11707
- b && /* @__PURE__ */ jsx(
11695
+ y && /* @__PURE__ */ jsx(
11708
11696
  "button",
11709
11697
  {
11710
11698
  type: "button",
11711
- onClick: y,
11699
+ onClick: S,
11712
11700
  className: "absolute -right-2 -top-2 z-20 rounded-full bg-destructive p-1 text-destructive-foreground hover:bg-destructive/90",
11713
11701
  children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" })
11714
11702
  }
11715
11703
  ),
11716
- m && m !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: m, children: /* @__PURE__ */ jsx(
11704
+ b && b !== "" && /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: k, assetId: b, children: /* @__PURE__ */ jsx(
11717
11705
  "button",
11718
11706
  {
11719
11707
  type: "button",
@@ -11721,11 +11709,11 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
11721
11709
  children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-4 w-4 text-white" })
11722
11710
  }
11723
11711
  ) })
11724
- ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, mode: "image", assetId: m, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
11712
+ ] }) : /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: k, mode: "image", assetId: b, children: /* @__PURE__ */ jsx("div", { className: "h-14 w-14 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
11725
11713
  /* @__PURE__ */ jsxs("div", { className: "flex w-3/5 flex-col", children: [
11726
11714
  /* @__PURE__ */ jsxs(Fragment$1, { children: [
11727
- /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: S }),
11728
- /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: x, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(g) && g !== PLACEHOLDER_IMAGE ? i("Replace image") : i("Choose image") }) }),
11715
+ /* @__PURE__ */ jsx("p", { className: "max-w-[250px] truncate pr-2 text-xs text-gray-400", children: v }),
11716
+ /* @__PURE__ */ jsx(MediaManagerModal, { onSelect: k, assetId: "", children: /* @__PURE__ */ jsx("small", { className: "h-6 mb-1 w-full cursor-pointer rounded-md bg-secondary px-1 py-1 text-center text-xs text-secondary-foreground hover:bg-secondary/80", children: !isEmpty(x) && x !== PLACEHOLDER_IMAGE ? l("Replace image") : l("Choose image") }) }),
11729
11717
  /* @__PURE__ */ jsx("div", { className: "text-center text-xs text-gray-400", children: "OR" })
11730
11718
  ] }),
11731
11719
  /* @__PURE__ */ jsx(
@@ -11737,10 +11725,10 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
11737
11725
  spellCheck: "false",
11738
11726
  type: "url",
11739
11727
  className: "h-6 text-xs",
11740
- placeholder: i("Enter image URL"),
11728
+ placeholder: l("Enter image URL"),
11741
11729
  value: r === PLACEHOLDER_IMAGE ? "" : r,
11742
- onBlur: ({ target: { value: k } }) => a(o, k),
11743
- onChange: (k) => n(k.target.value)
11730
+ onBlur: ({ target: { value: E } }) => a(o, E),
11731
+ onChange: (E) => n(E.target.value)
11744
11732
  }
11745
11733
  )
11746
11734
  ] })
@@ -11856,11 +11844,11 @@ const DataBindingSelector = ({
11856
11844
  n(`{{${f}}}`, {}, o);
11857
11845
  return;
11858
11846
  }
11859
- const g = (S) => /[.,!?;:]/.test(S), b = (S, k, C) => {
11847
+ const g = (k) => /[.,!?;:]/.test(k), b = (k, S, v) => {
11860
11848
  let E = "", B = "";
11861
- const I = k > 0 ? S[k - 1] : "", w = k < S.length ? S[k] : "";
11862
- return k > 0 && (I === "." || !g(I) && I !== " ") && (E = " "), k < S.length && !g(w) && w !== " " && (B = " "), {
11863
- text: E + C + B,
11849
+ const I = S > 0 ? k[S - 1] : "", A = S < k.length ? k[S] : "";
11850
+ return S > 0 && (I === "." || !g(I) && I !== " ") && (E = " "), S < k.length && !g(A) && A !== " " && (B = " "), {
11851
+ text: E + v + B,
11864
11852
  prefixLength: E.length,
11865
11853
  suffixLength: B.length
11866
11854
  };
@@ -11868,32 +11856,32 @@ const DataBindingSelector = ({
11868
11856
  if (!x) return;
11869
11857
  const y = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
11870
11858
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
11871
- const S = y.__chaiRTE;
11872
- if (S) {
11873
- const k = `{{${f}}}`;
11874
- S.commands.focus();
11875
- const { from: C, to: E } = S.state.selection;
11876
- if (C !== E)
11877
- S.chain().deleteSelection().insertContent(k).run();
11859
+ const k = y.__chaiRTE;
11860
+ if (k) {
11861
+ const S = `{{${f}}}`;
11862
+ k.commands.focus();
11863
+ const { from: v, to: E } = k.state.selection;
11864
+ if (v !== E)
11865
+ k.chain().deleteSelection().insertContent(S).run();
11878
11866
  else {
11879
- const { state: I } = S, w = I.selection.from, A = I.doc.textBetween(Math.max(0, w - 1), w), v = I.doc.textBetween(w, Math.min(w + 1, I.doc.content.size));
11867
+ const { state: I } = k, A = I.selection.from, w = I.doc.textBetween(Math.max(0, A - 1), A), C = I.doc.textBetween(A, Math.min(A + 1, I.doc.content.size));
11880
11868
  let T = "";
11881
- w > 0 && A !== " " && !g(A) && (T = " ");
11869
+ A > 0 && w !== " " && !g(w) && (T = " ");
11882
11870
  let N = "";
11883
- v && v !== " " && !g(v) && (N = " "), S.chain().insertContent(T + k + N).run();
11871
+ C && C !== " " && !g(C) && (N = " "), k.chain().insertContent(T + S + N).run();
11884
11872
  }
11885
- setTimeout(() => n(S.getHTML(), {}, o), 100);
11873
+ setTimeout(() => n(k.getHTML(), {}, o), 100);
11886
11874
  return;
11887
11875
  }
11888
11876
  } else {
11889
- const S = x, k = S.selectionStart || 0, C = S.value || "", E = S.selectionEnd || k;
11890
- if (E > k) {
11891
- const v = `{{${f}}}`, { text: T } = b(C, k, v), N = C.slice(0, k) + T + C.slice(E);
11877
+ const k = x, S = k.selectionStart || 0, v = k.value || "", E = k.selectionEnd || S;
11878
+ if (E > S) {
11879
+ const C = `{{${f}}}`, { text: T } = b(v, S, C), N = v.slice(0, S) + T + v.slice(E);
11892
11880
  n(N, {}, o);
11893
11881
  return;
11894
11882
  }
11895
- const I = `{{${f}}}`, { text: w } = b(C, k, I), A = C.slice(0, k) + w + C.slice(k);
11896
- n(A, {}, o);
11883
+ const I = `{{${f}}}`, { text: A } = b(v, S, I), w = v.slice(0, S) + A + v.slice(S);
11884
+ n(w, {}, o);
11897
11885
  }
11898
11886
  },
11899
11887
  [o, n, a, d == null ? void 0 : d._id, u]
@@ -11914,70 +11902,70 @@ const DataBindingSelector = ({
11914
11902
  pageTypes: n,
11915
11903
  onChange: o
11916
11904
  }) => {
11917
- var A;
11918
- const { t: a } = useTranslation(), i = useBuilderProp("searchPageTypeItems", (v, T) => []), [l, c] = useState(!1), [d, u] = useState(!1), [p, h] = useState("page"), [f, m] = useState(""), [g, b] = useState([]), [x, y] = useState(-1), S = useRef(null), k = (A = n == null ? void 0 : n.find((v) => v.key === p)) == null ? void 0 : A.name;
11905
+ var w;
11906
+ const { t: a } = useTranslation(), i = useBuilderProp("searchPageTypeItems", (C, T) => []), [l, c] = useState(!1), [d, u] = useState(!1), [p, h] = useState("page"), [f, m] = useState(""), [g, b] = useState([]), [x, y] = useState(-1), k = useRef(null), S = (w = n == null ? void 0 : n.find((C) => C.key === p)) == null ? void 0 : w.name;
11919
11907
  useEffect(() => {
11920
11908
  if (m(""), b([]), y(-1), u(!1), !r || l || !startsWith(r, "pageType:")) return;
11921
- const v = split(r, ":"), T = get(v, 1, "page") || "page";
11909
+ const C = split(r, ":"), T = get(C, 1, "page") || "page";
11922
11910
  h(T), (async () => {
11923
- const N = await i(T, [get(v, 2, "page")]);
11911
+ const N = await i(T, [get(C, 2, "page")]);
11924
11912
  N && Array.isArray(N) && m(get(N, [0, "name"], ""));
11925
11913
  })();
11926
11914
  }, [r]);
11927
- const C = useDebouncedCallback(
11928
- async (v) => {
11929
- if (isEmpty(v))
11915
+ const v = useDebouncedCallback(
11916
+ async (C) => {
11917
+ if (isEmpty(C))
11930
11918
  b([]);
11931
11919
  else {
11932
- const T = await i(p, v);
11920
+ const T = await i(p, C);
11933
11921
  b(T);
11934
11922
  }
11935
11923
  c(!1), y(-1);
11936
11924
  },
11937
11925
  [p],
11938
11926
  300
11939
- ), E = (v) => {
11940
- const T = ["pageType", p, v.id];
11941
- T[1] && (o(T.join(":")), m(v.name), u(!1), b([]), y(-1));
11942
- }, B = (v) => {
11943
- switch (v.key) {
11927
+ ), E = (C) => {
11928
+ const T = ["pageType", p, C.id];
11929
+ T[1] && (o(T.join(":")), m(C.name), u(!1), b([]), y(-1));
11930
+ }, B = (C) => {
11931
+ switch (C.key) {
11944
11932
  case "ArrowDown":
11945
- v.preventDefault(), y((T) => T < g.length - 1 ? T + 1 : T);
11933
+ C.preventDefault(), y((T) => T < g.length - 1 ? T + 1 : T);
11946
11934
  break;
11947
11935
  case "ArrowUp":
11948
- v.preventDefault(), y((T) => T > 0 ? T - 1 : T);
11936
+ C.preventDefault(), y((T) => T > 0 ? T - 1 : T);
11949
11937
  break;
11950
11938
  case "Enter":
11951
- if (v.preventDefault(), g.length === 0) return;
11939
+ if (C.preventDefault(), g.length === 0) return;
11952
11940
  x >= 0 && E(g[x]);
11953
11941
  break;
11954
11942
  case "Escape":
11955
- v.preventDefault(), I();
11943
+ C.preventDefault(), I();
11956
11944
  break;
11957
11945
  }
11958
11946
  };
11959
11947
  useEffect(() => {
11960
- if (x >= 0 && S.current) {
11961
- const v = S.current.children[x];
11962
- v == null || v.scrollIntoView({ block: "nearest" });
11948
+ if (x >= 0 && k.current) {
11949
+ const C = k.current.children[x];
11950
+ C == null || C.scrollIntoView({ block: "nearest" });
11963
11951
  }
11964
11952
  }, [x]);
11965
11953
  const I = () => {
11966
11954
  m(""), b([]), y(-1), u(!1), o("");
11967
- }, w = (v) => {
11968
- m(v), u(!isEmpty(v)), c(!0), C(v);
11955
+ }, A = (C) => {
11956
+ m(C), u(!isEmpty(C)), c(!0), v(C);
11969
11957
  };
11970
11958
  return /* @__PURE__ */ jsxs("div", { children: [
11971
- /* @__PURE__ */ jsx("select", { name: "pageType", value: p, onChange: (v) => h(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
11959
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: p, onChange: (C) => h(C.target.value), children: map(n, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
11972
11960
  p && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
11973
11961
  /* @__PURE__ */ jsx(
11974
11962
  "input",
11975
11963
  {
11976
11964
  type: "text",
11977
11965
  value: f,
11978
- onChange: (v) => w(v.target.value),
11966
+ onChange: (C) => A(C.target.value),
11979
11967
  onKeyDown: B,
11980
- placeholder: a(`Search ${k ?? ""}`),
11968
+ placeholder: a(`Search ${S ?? ""}`),
11981
11969
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
11982
11970
  }
11983
11971
  ),
@@ -11991,22 +11979,22 @@ const DataBindingSelector = ({
11991
11979
  ' "',
11992
11980
  f,
11993
11981
  '"'
11994
- ] }) : /* @__PURE__ */ jsx("ul", { ref: S, children: map(g == null ? void 0 : g.slice(0, 20), (v, T) => /* @__PURE__ */ jsxs(
11982
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: k, children: map(g == null ? void 0 : g.slice(0, 20), (C, T) => /* @__PURE__ */ jsxs(
11995
11983
  "li",
11996
11984
  {
11997
- onClick: () => E(v),
11998
- className: `cursor-pointer p-2 text-xs ${r != null && r.includes(v.id) ? "bg-blue-200" : T === x ? "bg-gray-100" : "hover:bg-gray-100"}`,
11985
+ onClick: () => E(C),
11986
+ className: `cursor-pointer p-2 text-xs ${r != null && r.includes(C.id) ? "bg-blue-200" : T === x ? "bg-gray-100" : "hover:bg-gray-100"}`,
11999
11987
  children: [
12000
- v.name,
11988
+ C.name,
12001
11989
  " ",
12002
- v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
11990
+ C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
12003
11991
  "( ",
12004
- v.slug,
11992
+ C.slug,
12005
11993
  " )"
12006
11994
  ] })
12007
11995
  ]
12008
11996
  },
12009
- v.id
11997
+ C.id
12010
11998
  )) }) })
12011
11999
  ] });
12012
12000
  }, LinkField = ({ schema: r, formData: n, onChange: o, name: a }) => {
@@ -12100,7 +12088,7 @@ const DataBindingSelector = ({
12100
12088
  ]
12101
12089
  }
12102
12090
  ) });
12103
- }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-DbOJAIEv.js")), RichTextEditorFieldComp = ({ blockId: r, id: n, placeholder: o, value: a, onChange: i, onBlur: l }) => {
12091
+ }, RTEModal = React__default.lazy(() => import("./rte-widget-modal-CXbmmhcb.js")), RichTextEditorFieldComp = ({ blockId: r, id: n, placeholder: o, value: a, onChange: i, onBlur: l }) => {
12104
12092
  const c = useRef(null), [d, u] = useState(!1), p = useRTEditor({
12105
12093
  blockId: r,
12106
12094
  value: a,
@@ -12349,14 +12337,14 @@ const DataBindingSelector = ({
12349
12337
  const { id: n, classNames: o, label: a, children: i, errors: l, help: c, hidden: d, required: u, schema: p, formData: h, onChange: f } = r, { selectedLang: m, fallbackLang: g, languages: b } = useLanguages(), x = useMemo(
12350
12338
  () => isEmpty(b) ? "" : isEmpty(m) ? g : m,
12351
12339
  [b, m, g]
12352
- ), y = useMemo(() => get(LANGUAGES, x, x), [x]), S = usePageExternalData(), k = useSelectedBlock(), C = useRegisteredChaiBlocks(), E = useMemo(
12353
- () => get(C, [k == null ? void 0 : k._type, "i18nProps"], []),
12354
- [C, k == null ? void 0 : k._type]
12340
+ ), y = useMemo(() => get(LANGUAGES, x, x), [x]), k = usePageExternalData(), S = useSelectedBlock(), v = useRegisteredChaiBlocks(), E = useMemo(
12341
+ () => get(v, [S == null ? void 0 : S._type, "i18nProps"], []),
12342
+ [v, S == null ? void 0 : S._type]
12355
12343
  ), [B, I] = useState(null);
12356
12344
  if (d)
12357
12345
  return null;
12358
12346
  if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: o, children: i });
12359
- const A = E == null ? void 0 : E.includes(n.replace("root.", ""));
12347
+ const w = E == null ? void 0 : E.includes(n.replace("root.", ""));
12360
12348
  if (p.type === "array") {
12361
12349
  const N = B === n;
12362
12350
  return /* @__PURE__ */ jsxs("div", { className: `${o} relative`, children: [
@@ -12393,14 +12381,14 @@ const DataBindingSelector = ({
12393
12381
  ] })
12394
12382
  ] });
12395
12383
  }
12396
- const v = n.replace("root.", ""), T = E.includes(v) && !isEmpty(m) && isEmpty(h);
12384
+ const C = n.replace("root.", ""), T = E.includes(C) && !isEmpty(m) && isEmpty(h);
12397
12385
  return /* @__PURE__ */ jsxs("div", { className: o, children: [
12398
12386
  p.title && /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
12399
12387
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
12400
12388
  /* @__PURE__ */ jsxs("label", { htmlFor: n, className: p.type === "object" ? "pb-2" : "", children: [
12401
12389
  a,
12402
12390
  " ",
12403
- A && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
12391
+ w && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
12404
12392
  " ",
12405
12393
  y
12406
12394
  ] }),
@@ -12411,7 +12399,7 @@ const DataBindingSelector = ({
12411
12399
  /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
12412
12400
  ] }) })
12413
12401
  ] }),
12414
- !p.enum && !p.oneOf && S && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
12402
+ !p.enum && !p.oneOf && k && /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-1", children: [
12415
12403
  T ? /* @__PURE__ */ jsxs(Tooltip, { children: [
12416
12404
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
12417
12405
  "svg",
@@ -12551,36 +12539,36 @@ const DataBindingSelector = ({
12551
12539
  }), a;
12552
12540
  };
12553
12541
  function BlockSettings() {
12554
- const { selectedLang: r } = useLanguages(), n = useSelectedBlock(), o = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), i = getRegisteredChaiBlock(n == null ? void 0 : n._type), l = formDataWithSelectedLang(n, r, i), [c, d] = useState(l), [u, p] = useState(!1), h = useWrapperBlock(), f = getRegisteredChaiBlock(h == null ? void 0 : h._type), m = formDataWithSelectedLang(h, r, f), g = ({ formData: B }, I, w) => {
12555
- I && (c == null ? void 0 : c._id) === n._id && a([n._id], { [I]: get(B, I) }, w);
12542
+ const { selectedLang: r } = useLanguages(), n = useSelectedBlock(), o = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), i = getRegisteredChaiBlock(n == null ? void 0 : n._type), l = formDataWithSelectedLang(n, r, i), [c, d] = useState(l), [u, p] = useState(!1), h = useWrapperBlock(), f = getRegisteredChaiBlock(h == null ? void 0 : h._type), m = formDataWithSelectedLang(h, r, f), g = ({ formData: B }, I, A) => {
12543
+ I && (c == null ? void 0 : c._id) === n._id && a([n._id], { [I]: get(B, I) }, A);
12556
12544
  }, b = useCallback(
12557
- debounce(({ formData: B }, I, w) => {
12558
- g({ formData: B }, I, w), d(B);
12545
+ debounce(({ formData: B }, I, A) => {
12546
+ g({ formData: B }, I, A), d(B);
12559
12547
  }, 1500),
12560
12548
  [n == null ? void 0 : n._id, r]
12561
12549
  ), x = ({ formData: B }, I) => {
12562
12550
  I && (o([n._id], { [I]: get(B, I) }), b({ formData: B }, I, { [I]: get(c, I) }));
12563
12551
  }, y = ({ formData: B }, I) => {
12564
12552
  I && (o([h._id], { [I]: get(B, I) }), b({ formData: B }, I, { [I]: get(c, I) }));
12565
- }, { schema: S, uiSchema: k } = useMemo(() => {
12553
+ }, { schema: k, uiSchema: S } = useMemo(() => {
12566
12554
  const B = n == null ? void 0 : n._type;
12567
12555
  if (!B)
12568
12556
  return { schema: {}, uiSchema: {} };
12569
12557
  try {
12570
- const { schema: I, uiSchema: w } = getBlockFormSchemas(B);
12558
+ const { schema: I, uiSchema: A } = getBlockFormSchemas(B);
12571
12559
  if (B === "Repeater") {
12572
- const A = get(n, "repeaterItems", "");
12573
- startsWith(A, `{{${COLLECTION_PREFIX}`) ? (set(w, "filter", { "ui:widget": "collectionSelect" }), set(w, "sort", { "ui:widget": "collectionSelect" })) : (set(w, "filter", { "ui:widget": "hidden" }), set(w, "sort", { "ui:widget": "hidden" }));
12560
+ const w = get(n, "repeaterItems", "");
12561
+ startsWith(w, `{{${COLLECTION_PREFIX}`) ? (set(A, "filter", { "ui:widget": "collectionSelect" }), set(A, "sort", { "ui:widget": "collectionSelect" })) : (set(A, "filter", { "ui:widget": "hidden" }), set(A, "sort", { "ui:widget": "hidden" }));
12574
12562
  }
12575
- return { schema: I, uiSchema: w };
12563
+ return { schema: I, uiSchema: A };
12576
12564
  } catch {
12577
12565
  return { schema: {}, uiSchema: {} };
12578
12566
  }
12579
- }, [n]), { wrapperSchema: C, wrapperUiSchema: E } = useMemo(() => {
12567
+ }, [n]), { wrapperSchema: v, wrapperUiSchema: E } = useMemo(() => {
12580
12568
  if (!h || !(h != null && h._type))
12581
12569
  return { wrapperSchema: {}, wrapperUiSchema: {} };
12582
- const B = h == null ? void 0 : h._type, { schema: I = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
12583
- return { wrapperSchema: I, wrapperUiSchema: w };
12570
+ const B = h == null ? void 0 : h._type, { schema: I = {}, uiSchema: A = {} } = getBlockFormSchemas(B);
12571
+ return { wrapperSchema: I, wrapperUiSchema: A };
12584
12572
  }, [h]);
12585
12573
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
12586
12574
  !isEmpty(h) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
@@ -12608,19 +12596,19 @@ function BlockSettings() {
12608
12596
  blockId: h == null ? void 0 : h._id,
12609
12597
  onChange: y,
12610
12598
  formData: m,
12611
- schema: C,
12599
+ schema: v,
12612
12600
  uiSchema: E
12613
12601
  }
12614
12602
  ) })
12615
12603
  ] }),
12616
- isEmpty(S) ? null : /* @__PURE__ */ jsx(
12604
+ isEmpty(k) ? null : /* @__PURE__ */ jsx(
12617
12605
  JSONForm,
12618
12606
  {
12619
12607
  blockId: n == null ? void 0 : n._id,
12620
12608
  onChange: x,
12621
12609
  formData: l,
12622
- schema: S,
12623
- uiSchema: k
12610
+ schema: k,
12611
+ uiSchema: S
12624
12612
  }
12625
12613
  )
12626
12614
  ] });
@@ -12831,17 +12819,17 @@ const BlockStylingProps = () => {
12831
12819
  },
12832
12820
  a
12833
12821
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (r) => {
12834
- const [n, o] = useState(!1), [a, i] = useState(""), { currentClass: l, onChange: c, classPrefix: d, cssProperty: u, units: p, negative: h } = r, [f, m] = useState(u != null && u.toLowerCase().includes("width") ? "%" : p[0]), [g, b] = useState(!1), [x, y] = useState(""), [S, k] = useState(!1), [C, E] = useState(!1);
12822
+ const [n, o] = useState(!1), [a, i] = useState(""), { currentClass: l, onChange: c, classPrefix: d, cssProperty: u, units: p, negative: h } = r, [f, m] = useState(u != null && u.toLowerCase().includes("width") ? "%" : p[0]), [g, b] = useState(!1), [x, y] = useState(""), [k, S] = useState(!1), [v, E] = useState(!1);
12835
12823
  useEffect(() => {
12836
- const { value: v, unit: T } = getClassValueAndUnit(l);
12824
+ const { value: C, unit: T } = getClassValueAndUnit(l);
12837
12825
  if (T === "") {
12838
- i(v), m(u != null && u.toLowerCase().includes("width") ? "%" : first$1(p));
12826
+ i(C), m(u != null && u.toLowerCase().includes("width") ? "%" : first$1(p));
12839
12827
  return;
12840
12828
  }
12841
- m(T), i(T === "class" || isEmpty(v) ? "" : v);
12829
+ m(T), i(T === "class" || isEmpty(C) ? "" : C);
12842
12830
  }, [l, u, p]);
12843
- const B = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), I = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
12844
- (v = !1) => {
12831
+ const B = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), I = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
12832
+ (C = !1) => {
12845
12833
  const T = getUserInputValues(`${a}`, p);
12846
12834
  if (get(T, "error", !1)) {
12847
12835
  b(!0);
@@ -12855,23 +12843,23 @@ const BlockStylingProps = () => {
12855
12843
  if (get(T, "value") === "")
12856
12844
  return;
12857
12845
  const P = `${get(T, "value", "").startsWith("-") ? "-" : ""}${d}[${get(T, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
12858
- v ? I(P) : B(P);
12846
+ C ? I(P) : B(P);
12859
12847
  },
12860
12848
  [B, I, a, f, d, p]
12861
- ), A = useCallback(
12862
- (v) => {
12849
+ ), w = useCallback(
12850
+ (C) => {
12863
12851
  const T = getUserInputValues(`${a}`, p);
12864
12852
  if (get(T, "error", !1)) {
12865
12853
  b(!0);
12866
12854
  return;
12867
12855
  }
12868
- if (v === "auto" || v === "none") {
12869
- B(`${d}${v}`);
12856
+ if (C === "auto" || C === "none") {
12857
+ B(`${d}${C}`);
12870
12858
  return;
12871
12859
  }
12872
12860
  if (get(T, "value") === "")
12873
12861
  return;
12874
- const N = get(T, "unit") !== "" ? get(T, "unit") : v, P = `${get(T, "value", "").startsWith("-") ? "-" : ""}${d}[${get(T, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
12862
+ const N = get(T, "unit") !== "" ? get(T, "unit") : C, P = `${get(T, "value", "").startsWith("-") ? "-" : ""}${d}[${get(T, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
12875
12863
  B(P);
12876
12864
  },
12877
12865
  [B, a, d, p]
@@ -12889,37 +12877,37 @@ const BlockStylingProps = () => {
12889
12877
  /* @__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, {}) }) }),
12890
12878
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
12891
12879
  ] })
12892
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${S ? "z-auto" : ""}`, children: [
12880
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${k ? "z-auto" : ""}`, children: [
12893
12881
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
12894
12882
  ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
12895
12883
  "input",
12896
12884
  {
12897
12885
  readOnly: f === "class",
12898
- onKeyPress: (v) => {
12899
- v.key === "Enter" && w();
12886
+ onKeyPress: (C) => {
12887
+ C.key === "Enter" && A();
12900
12888
  },
12901
- onKeyDown: (v) => {
12902
- if (v.keyCode !== 38 && v.keyCode !== 40)
12889
+ onKeyDown: (C) => {
12890
+ if (C.keyCode !== 38 && C.keyCode !== 40)
12903
12891
  return;
12904
- v.preventDefault(), E(!0);
12905
- const T = parseInt$1(v.target.value);
12892
+ C.preventDefault(), E(!0);
12893
+ const T = parseInt$1(C.target.value);
12906
12894
  let N = isNaN$1(T) ? 0 : T;
12907
- v.keyCode === 38 && (N += 1), v.keyCode === 40 && (N -= 1);
12895
+ C.keyCode === 38 && (N += 1), C.keyCode === 40 && (N -= 1);
12908
12896
  const j = `${N}`, L = `${j.startsWith("-") ? "-" : ""}${d}[${j.replace("-", "")}${f === "-" ? "" : f}]`;
12909
12897
  I(L);
12910
12898
  },
12911
- onKeyUp: (v) => {
12912
- C && (v.preventDefault(), E(!1));
12899
+ onKeyUp: (C) => {
12900
+ v && (C.preventDefault(), E(!1));
12913
12901
  },
12914
- onBlur: () => w(),
12915
- onChange: (v) => {
12916
- b(!1), i(v.target.value);
12902
+ onBlur: () => A(),
12903
+ onChange: (C) => {
12904
+ b(!1), i(C.target.value);
12917
12905
  },
12918
- onClick: (v) => {
12906
+ onClick: (C) => {
12919
12907
  var T;
12920
- (T = v == null ? void 0 : v.target) == null || T.select(), o(!1);
12908
+ (T = C == null ? void 0 : C.target) == null || T.select(), o(!1);
12921
12909
  },
12922
- value: S ? x : a,
12910
+ value: k ? x : a,
12923
12911
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
12924
12912
  " ",
12925
12913
  g ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -12944,28 +12932,28 @@ const BlockStylingProps = () => {
12944
12932
  {
12945
12933
  units: p,
12946
12934
  current: f,
12947
- onSelect: (v) => {
12948
- o(!1), m(v), A(v);
12935
+ onSelect: (C) => {
12936
+ o(!1), m(C), w(C);
12949
12937
  }
12950
12938
  }
12951
12939
  ) })
12952
12940
  ] })
12953
12941
  ] }),
12954
- ["none", "auto"].indexOf(f) !== -1 || S ? null : /* @__PURE__ */ jsx(
12942
+ ["none", "auto"].indexOf(f) !== -1 || k ? null : /* @__PURE__ */ jsx(
12955
12943
  DragStyleButton,
12956
12944
  {
12957
- onDragStart: () => k(!0),
12958
- onDragEnd: (v) => {
12959
- if (y(() => ""), k(!1), isEmpty(v))
12945
+ onDragStart: () => S(!0),
12946
+ onDragEnd: (C) => {
12947
+ if (y(() => ""), S(!1), isEmpty(C))
12960
12948
  return;
12961
- const T = `${v}`, j = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
12949
+ const T = `${C}`, j = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
12962
12950
  B(j);
12963
12951
  },
12964
- onDrag: (v) => {
12965
- if (isEmpty(v))
12952
+ onDrag: (C) => {
12953
+ if (isEmpty(C))
12966
12954
  return;
12967
- y(v);
12968
- const T = `${v}`, j = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
12955
+ y(C);
12956
+ const T = `${C}`, j = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
12969
12957
  I(j);
12970
12958
  },
12971
12959
  currentValue: a,
@@ -13430,22 +13418,22 @@ const COLOR_PROP = {
13430
13418
  }, getBreakpoint = (r) => `${r.toUpperCase()} ${BREAKPOINTS[r] ? `(${BREAKPOINTS[r]} & up)` : ""}`, BlockStyle = (r) => {
13431
13419
  const { t: n } = useTranslation(), { type: o = "icons", label: a, property: i, onEmitChange: l = () => {
13432
13420
  }, units: c, negative: d = !1 } = r, [u] = useDarkMode(), [p] = useStylingState(), [, h] = useScreenSizeWidth(), f = useCurrentClassByProperty(i), m = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), x = useMemo(() => get(f, "fullCls", ""), [f]), y = useCallback(
13433
- (I, w = !0) => {
13434
- const A = { dark: u, mq: h, mod: p, cls: I, property: i, fullCls: "" };
13435
- (u || p !== "") && (A.mq = "xs");
13436
- const v = generateFullClsName(A);
13437
- m(b, [v], w);
13421
+ (I, A = !0) => {
13422
+ const w = { dark: u, mq: h, mod: p, cls: I, property: i, fullCls: "" };
13423
+ (u || p !== "") && (w.mq = "xs");
13424
+ const C = generateFullClsName(w);
13425
+ m(b, [C], A);
13438
13426
  },
13439
13427
  [b, u, h, p, i, m]
13440
- ), S = useCallback(() => {
13428
+ ), k = useCallback(() => {
13441
13429
  g(b, [x], !0);
13442
- }, [b, x, g]), k = useMemo(() => canChangeClass(f, h), [f, h]);
13430
+ }, [b, x, g]), S = useMemo(() => canChangeClass(f, h), [f, h]);
13443
13431
  useEffect(() => {
13444
- l(k, f);
13445
- }, [k, l, f]);
13446
- const [, , C] = useScreenSizeWidth(), E = useCallback(
13432
+ l(S, f);
13433
+ }, [S, l, f]);
13434
+ const [, , v] = useScreenSizeWidth(), E = useCallback(
13447
13435
  (I) => {
13448
- C({
13436
+ v({
13449
13437
  xs: 400,
13450
13438
  sm: 640,
13451
13439
  md: 800,
@@ -13454,9 +13442,9 @@ const COLOR_PROP = {
13454
13442
  "2xl": 1920
13455
13443
  }[I]);
13456
13444
  },
13457
- [C]
13445
+ [v]
13458
13446
  ), B = get(f, "dark", null) === u && get(f, "mod", null) === p && get(f, "mq", null) === h;
13459
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: k, canReset: f && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
13447
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: S, canReset: f && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
13460
13448
  /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !B ? "text-foreground" : ""}`, children: n(a) }) }),
13461
13449
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
13462
13450
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
@@ -13476,7 +13464,7 @@ const COLOR_PROP = {
13476
13464
  o === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: i, onChange: y }),
13477
13465
  o === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: i, onChange: y })
13478
13466
  ] }),
13479
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: B ? /* @__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" }) }) : k && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
13467
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => k(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : S && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
13480
13468
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
13481
13469
  "button",
13482
13470
  {
@@ -13698,33 +13686,33 @@ const COLOR_PROP = {
13698
13686
  buttonClass: a = "",
13699
13687
  activeButtonClass: i = ""
13700
13688
  }) => {
13701
- const [l, , c] = useScreenSizeWidth(), [d, u] = useCanvasDisplayWidth(), [p, h] = useSelectedBreakpoints(), f = p, m = h, { t: g } = useTranslation(), b = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (k) => {
13702
- f.includes(k) ? f.length > 2 && m(f.filter((C) => C !== k)) : m((C) => [...C, k]);
13703
- }, y = (k) => {
13704
- n || c(k), u(k);
13705
- }, S = getBreakpointValue(n ? d : l).toLowerCase();
13706
- return b.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(b, (k) => /* @__PURE__ */ createElement(
13689
+ const [l, , c] = useScreenSizeWidth(), [d, u] = useCanvasDisplayWidth(), [p, h] = useSelectedBreakpoints(), f = p, m = h, { t: g } = useTranslation(), b = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (S) => {
13690
+ f.includes(S) ? f.length > 2 && m(f.filter((v) => v !== S)) : m((v) => [...v, S]);
13691
+ }, y = (S) => {
13692
+ n || c(S), u(S);
13693
+ }, k = getBreakpointValue(n ? d : l).toLowerCase();
13694
+ return b.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(b, (S) => /* @__PURE__ */ createElement(
13707
13695
  BreakpointCard,
13708
13696
  {
13709
13697
  canvas: n,
13710
- ...k,
13698
+ ...S,
13711
13699
  onClick: y,
13712
- key: k.breakpoint,
13713
- currentBreakpoint: S
13700
+ key: S.breakpoint,
13701
+ currentBreakpoint: k
13714
13702
  }
13715
13703
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
13716
13704
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
13717
- b.filter((k) => includes(f, toUpper(k.breakpoint))),
13718
- (k) => /* @__PURE__ */ createElement(
13705
+ b.filter((S) => includes(f, toUpper(S.breakpoint))),
13706
+ (S) => /* @__PURE__ */ createElement(
13719
13707
  BreakpointCard,
13720
13708
  {
13721
13709
  canvas: n,
13722
13710
  openDelay: r,
13723
13711
  tooltip: o,
13724
- ...k,
13712
+ ...S,
13725
13713
  onClick: y,
13726
- key: k.breakpoint,
13727
- currentBreakpoint: S,
13714
+ key: S.breakpoint,
13715
+ currentBreakpoint: k,
13728
13716
  buttonClass: a,
13729
13717
  activeButtonClass: i
13730
13718
  }
@@ -13735,16 +13723,16 @@ const COLOR_PROP = {
13735
13723
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
13736
13724
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
13737
13725
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
13738
- map(b, (k) => /* @__PURE__ */ jsx(
13726
+ map(b, (S) => /* @__PURE__ */ jsx(
13739
13727
  DropdownMenuCheckboxItem,
13740
13728
  {
13741
- disabled: k.breakpoint === "xs",
13742
- onCheckedChange: () => x(toUpper(k.breakpoint)),
13743
- checked: includes(f, toUpper(k.breakpoint)),
13744
- onSelect: (C) => C.preventDefault(),
13745
- children: g(k.title)
13729
+ disabled: S.breakpoint === "xs",
13730
+ onCheckedChange: () => x(toUpper(S.breakpoint)),
13731
+ checked: includes(f, toUpper(S.breakpoint)),
13732
+ onSelect: (v) => v.preventDefault(),
13733
+ children: g(S.title)
13746
13734
  },
13747
- k.breakpoint
13735
+ S.breakpoint
13748
13736
  ))
13749
13737
  ] })
13750
13738
  ] })
@@ -13770,205 +13758,218 @@ function BreakpointSelector() {
13770
13758
  ] }) }) })
13771
13759
  ] });
13772
13760
  }
13773
- const DesignTokensIcon = ({ className: r = "" }) => /* @__PURE__ */ jsx(FontStyleIcon, { className: r });
13774
- function ManualClasses() {
13775
- var O;
13776
- const r = useRef(null), [n, o] = useState(""), [a, i] = useState(-1), [, l] = useRightPanel(), c = useFuseSearch(), { t: d } = useTranslation(), [u] = useSelectedStylingBlocks(), p = useSelectedBlock(), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), [g, b] = useState(""), x = useAtomValue$1(chaiDesignTokensAtom), y = (O = first$1(u)) == null ? void 0 : O.prop, { classes: S } = getSplitChaiClasses(get(p, y, "")), k = S.split(" ").filter((R) => !isEmpty(R)), C = useMemo(() => [...k].sort((R, _) => {
13777
- const M = R.startsWith(DESIGN_TOKEN_PREFIX), $ = _.startsWith(DESIGN_TOKEN_PREFIX);
13778
- return M && !$ ? -1 : !M && $ ? 1 : 0;
13779
- }), [k]), E = useBuilderProp("flags.copyPaste", !0), B = (R) => {
13780
- if (R.startsWith(DESIGN_TOKEN_PREFIX)) {
13781
- const _ = x[R];
13782
- return _ ? _.name : R;
13761
+ const DesignTokensIcon = ({ className: r = "" }) => /* @__PURE__ */ jsx(TokensIcon, { className: r });
13762
+ function ManualClasses({
13763
+ from: r = "default",
13764
+ classFromProps: n,
13765
+ onAddNew: o,
13766
+ onRemove: a
13767
+ }) {
13768
+ var G;
13769
+ const i = useRef(null), [l, c] = useState(""), [d, u] = useState(!1), [p, h] = useState(-1), [, f] = useRightPanel(), m = useFuseSearch(), { t: g } = useTranslation(), [b] = useSelectedStylingBlocks(), x = useSelectedBlock(), y = useAddClassesToBlocks(), k = useRemoveClassesFromBlocks(), [S] = useSelectedBlockIds(), [v, E] = useState(""), B = useAtomValue$1(chaiDesignTokensAtom), I = (G = first$1(b)) == null ? void 0 : G.prop, { classes: A } = getSplitChaiClasses(get(x, I, "")), C = (r === "default" ? A : n ?? "").split(" ").filter((_) => !isEmpty(_)), T = useMemo(() => [...C].sort((_, F) => {
13770
+ const z = _.startsWith(DESIGN_TOKEN_PREFIX), U = F.startsWith(DESIGN_TOKEN_PREFIX);
13771
+ return z && !U ? -1 : !z && U ? 1 : 0;
13772
+ }), [C]), N = useBuilderProp("flags.copyPaste", !0), j = (_) => {
13773
+ if (_.startsWith(DESIGN_TOKEN_PREFIX)) {
13774
+ const F = B[_];
13775
+ return F ? F.name : _;
13783
13776
  }
13784
- return R;
13785
- }, I = (R) => {
13786
- const _ = Object.entries(x).find(([M, $]) => $.name === R);
13787
- return _ ? `${_[0]}` : R;
13788
- }, w = () => {
13789
- const R = g.trim().replace(/ +(?= )/g, "").split(" ").map(I);
13790
- h(m, R, !0), b("");
13791
- }, [A, v] = useState([]), T = useBuilderProp("flags.designTokens", !1), N = ({ value: R }) => {
13792
- const _ = R.trim().toLowerCase(), M = _.match(/.+:/g);
13793
- let $ = [], U = [];
13794
- if (T && (_ === "" ? U = Object.entries(x).map(([V, z]) => ({
13795
- name: z.name,
13796
- id: `${V}`,
13777
+ return _;
13778
+ }, P = (_) => {
13779
+ const F = Object.entries(B).find(([z, U]) => U.name === _);
13780
+ return F ? `${F[0]}` : _;
13781
+ }, L = () => {
13782
+ const _ = v.trim().replace(/ +(?= )/g, "").split(" ").map(P);
13783
+ r === "designToken" ? isFunction$1(o) && o(_) : y(S, _, !0), E("");
13784
+ }, [D, $] = useState([]), M = useBuilderProp("flags.designTokens", !1), O = ({ value: _ }) => {
13785
+ const F = _.trim().toLowerCase(), z = F.match(/.+:/g);
13786
+ let U = [], q = [];
13787
+ if (M && (F === "" ? q = Object.entries(B).map(([J, Y]) => ({
13788
+ name: Y.name,
13789
+ id: `${J}`,
13797
13790
  isDesignToken: !0
13798
- })) : U = Object.entries(x).filter(([V, z]) => z.name.toLowerCase().includes(_)).map(([V, z]) => ({
13799
- name: z.name,
13800
- id: `${V}`,
13791
+ })) : q = Object.entries(B).filter(([J, Y]) => Y.name.toLowerCase().includes(F)).map(([J, Y]) => ({
13792
+ name: Y.name,
13793
+ id: `${J}`,
13801
13794
  isDesignToken: !0
13802
- }))), M && M.length > 0) {
13803
- const [V] = M, z = _.replace(V, "");
13804
- $ = c.search(z).map((K) => ({
13805
- ...K,
13806
- item: { ...K.item, name: V + K.item.name }
13795
+ }))), z && z.length > 0) {
13796
+ const [J] = z, Y = F.replace(J, "");
13797
+ U = m.search(Y).map((Q) => ({
13798
+ ...Q,
13799
+ item: { ...Q.item, name: J + Q.item.name }
13807
13800
  }));
13808
13801
  } else
13809
- $ = c.search(_);
13810
- const W = [...U, ...map($, "item")];
13811
- return v(W);
13812
- }, j = () => {
13813
- v([]);
13814
- }, P = (R) => R.name, L = (R) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md p-1", children: [
13815
- R.isDesignToken && /* @__PURE__ */ jsx(DesignTokensIcon, { className: "h-4 w-4 text-gray-600" }),
13816
- /* @__PURE__ */ jsx("span", { children: R.name })
13817
- ] }), D = useMemo(
13802
+ U = m.search(F);
13803
+ const te = [...q, ...map(U, "item")];
13804
+ return $(te);
13805
+ }, H = () => {
13806
+ $([]);
13807
+ }, R = (_) => _.name, V = (_) => /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 rounded-md p-1", children: [
13808
+ _.isDesignToken && /* @__PURE__ */ jsx(DesignTokensIcon, { className: "h-4 w-4 text-gray-600" }),
13809
+ /* @__PURE__ */ jsx("span", { children: _.name })
13810
+ ] }), W = useMemo(
13818
13811
  () => ({
13819
- ref: r,
13812
+ ref: i,
13820
13813
  autoComplete: "off",
13821
13814
  autoCorrect: "off",
13822
13815
  autoCapitalize: "off",
13823
13816
  spellCheck: !1,
13824
- placeholder: d("Enter classes separated by space"),
13825
- value: g,
13826
- onFocus: (R) => {
13817
+ placeholder: g("Enter classes separated by space"),
13818
+ value: v,
13819
+ onFocus: (_) => {
13827
13820
  setTimeout(() => {
13828
- R.target && R.target.select();
13821
+ _.target && _.target.select();
13829
13822
  }, 0);
13830
13823
  },
13831
- onKeyDown: (R) => {
13832
- if (R.key === "Enter" && g.trim() !== "" && (R.preventDefault(), w()), R.key === "Tab" && A.length > 0) {
13833
- R.preventDefault();
13834
- const _ = new KeyboardEvent("keydown", {
13824
+ onKeyDown: (_) => {
13825
+ if (_.key === "Enter" && v.trim() !== "" && (_.preventDefault(), L()), _.key === "Tab" && D.length > 0) {
13826
+ _.preventDefault();
13827
+ const F = new KeyboardEvent("keydown", {
13835
13828
  key: "ArrowDown",
13836
13829
  code: "ArrowDown",
13837
13830
  keyCode: 40,
13838
13831
  bubbles: !0
13839
13832
  });
13840
- R.target.dispatchEvent(_);
13833
+ _.target.dispatchEvent(F);
13841
13834
  }
13842
13835
  },
13843
- onChange: (R, { newValue: _ }) => b(_),
13844
- className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
13836
+ onChange: (_, { newValue: F }) => E(F),
13837
+ className: `w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border ${r === "default" ? "py-1" : "py-1.5"}`
13845
13838
  }),
13846
- [g, d, r, A.length]
13847
- ), F = (R) => {
13848
- const _ = n.trim().replace(/ +(?= )/g, "").split(" ").map(I);
13849
- f(m, [R]), h(m, _, !0), o(""), i(-1);
13850
- }, H = () => {
13839
+ [v, g, i, D.length]
13840
+ ), K = (_) => {
13841
+ const F = l.trim().replace(/ +(?= )/g, "").split(" ").map(P);
13842
+ k(S, [_]), y(S, F, !0), c(""), h(-1);
13843
+ }, Z = () => {
13851
13844
  if (navigator.clipboard === void 0) {
13852
- toast.error(d("Clipboard not supported"));
13845
+ toast.error(g("Clipboard not supported"));
13853
13846
  return;
13854
13847
  }
13855
- navigator.clipboard.writeText(k.join(" ")), toast.success(d("Classes copied to clipboard"));
13848
+ navigator.clipboard.writeText(C.join(" ")), toast.success(g("Classes copied to clipboard")), u(!0), setTimeout(() => u(!1), 2e3);
13856
13849
  };
13857
- return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
13858
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-x-2 text-muted-foreground", children: [
13859
- /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-1", children: [
13860
- /* @__PURE__ */ jsx("span", { children: d(T ? "Styles" : "Classes") }),
13861
- E && /* @__PURE__ */ jsxs(Tooltip, { children: [
13862
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: H, className: "cursor-pointer" }) }),
13863
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: d("Copy classes to clipboard") }) })
13864
- ] })
13865
- ] }),
13866
- T && /* @__PURE__ */ jsx(Button, { variant: "link", className: "underline", onClick: () => l("design-tokens"), children: d("Design Tokens") })
13867
- ] }) }),
13868
- /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-x-3", children: [
13869
- /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
13870
- Autosuggest,
13871
- {
13872
- suggestions: A,
13873
- onSuggestionsFetchRequested: N,
13874
- onSuggestionsClearRequested: j,
13875
- getSuggestionValue: P,
13876
- renderSuggestion: L,
13877
- inputProps: D,
13878
- onSuggestionSelected: (R, { suggestionValue: _ }) => {
13879
- const M = I(_);
13880
- h(m, [M], !0), b("");
13881
- },
13882
- containerProps: {
13883
- className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
13884
- },
13885
- theme: {
13886
- suggestion: "bg-transparent",
13887
- suggestionHighlighted: "!bg-gray-300 dark:!bg-gray-800 cursor-pointer",
13888
- suggestionsContainerOpen: "absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"
13889
- }
13890
- }
13891
- ) }),
13892
- /* @__PURE__ */ jsx(
13893
- Button,
13894
- {
13895
- variant: "outline",
13896
- className: "h-6 border-border",
13897
- onClick: w,
13898
- disabled: g.trim() === "",
13899
- size: "sm",
13900
- children: /* @__PURE__ */ jsx(PlusIcon, {})
13901
- }
13902
- )
13903
- ] }),
13904
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: C.map(
13905
- (R, _) => a === _ ? /* @__PURE__ */ jsx(
13906
- "input",
13907
- {
13908
- ref: r,
13909
- value: n,
13910
- onChange: (M) => o(M.target.value),
13911
- onBlur: () => {
13912
- F(R);
13913
- },
13914
- onKeyDown: (M) => {
13915
- M.key === "Enter" && F(R);
13916
- },
13917
- onFocus: (M) => {
13918
- setTimeout(() => {
13919
- M.target.select();
13920
- }, 0);
13921
- },
13922
- className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
13923
- },
13924
- R
13925
- ) : /* @__PURE__ */ jsx("div", { className: "group relative flex max-w-[260px] items-center", children: /* @__PURE__ */ jsxs(
13926
- "button",
13927
- {
13928
- onDoubleClick: () => {
13929
- b(B(R)), f(m, [R]), setTimeout(() => {
13930
- r.current && r.current.focus();
13931
- }, 10);
13932
- },
13933
- className: "flex h-max cursor-default items-center gap-x-1 truncate break-words rounded bg-gray-200 py-px pl-0.5 pr-1 text-[11px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",
13934
- children: [
13935
- /* @__PURE__ */ jsxs("div", { className: "z-10 flex h-full w-max items-center justify-center", children: [
13936
- /* @__PURE__ */ jsx(
13937
- Cross2Icon,
13938
- {
13939
- onClick: () => f(m, [R], !0),
13940
- className: "hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"
13941
- }
13942
- ),
13943
- R.startsWith(DESIGN_TOKEN_PREFIX) ? /* @__PURE__ */ jsx(DesignTokensIcon, { className: "text-[rgba(55, 65, 81, 0.4)] h-3.5 w-3.5 group-hover:hidden" }) : /* @__PURE__ */ jsxs(
13944
- "svg",
13945
- {
13946
- className: "h-3.5 w-3.5 group-hover:hidden",
13947
- fill: "rgba(55, 65, 81, 0.4)",
13948
- viewBox: "0 0 24 24",
13949
- xmlns: "http://www.w3.org/2000/svg",
13950
- xmlSpace: "preserve",
13951
- children: [
13952
- /* @__PURE__ */ jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
13953
- /* @__PURE__ */ jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
13954
- /* @__PURE__ */ jsx("g", { id: "SVGRepo_iconCarrier", children: /* @__PURE__ */ jsx(
13955
- "path",
13956
- {
13957
- fillRule: "evenodd",
13958
- clipRule: "evenodd",
13959
- d: "M12 6.036c-2.667 0-4.333 1.325-5 3.976 1-1.325 2.167-1.822 3.5-1.491.761.189 1.305.738 1.906 1.345C13.387 10.855 14.522 12 17 12c2.667 0 4.333-1.325 5-3.976-1 1.325-2.166 1.822-3.5 1.491-.761-.189-1.305-.738-1.907-1.345-.98-.99-2.114-2.134-4.593-2.134zM7 12c-2.667 0-4.333 1.325-5 3.976 1-1.326 2.167-1.822 3.5-1.491.761.189 1.305.738 1.907 1.345.98.989 2.115 2.134 4.594 2.134 2.667 0 4.333-1.325 5-3.976-1 1.325-2.167 1.822-3.5 1.491-.761-.189-1.305-.738-1.906-1.345C10.613 13.145 9.478 12 7 12z"
13960
- }
13961
- ) })
13962
- ]
13963
- }
13964
- )
13965
- ] }),
13966
- /* @__PURE__ */ jsx("div", { children: B(R) })
13967
- ]
13968
- }
13969
- ) }, R)
13970
- ) })
13971
- ] });
13850
+ return /* @__PURE__ */ jsxs(
13851
+ "div",
13852
+ {
13853
+ className: `flex w-full flex-col gap-y-1.5 pb-4 ${r === "designToken" ? "border-none" : "border-b border-border"}`,
13854
+ children: [
13855
+ /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-x-2", children: /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-x-2 text-muted-foreground", children: [
13856
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-1", children: [
13857
+ /* @__PURE__ */ jsx("span", { children: r === "designToken" ? /* @__PURE__ */ jsx(Label, { className: "text-sm font-medium leading-tight text-gray-900 peer-disabled:cursor-not-allowed peer-disabled:opacity-70", children: g("Token Classes") }) : g(M ? "Styles" : "Classes") }),
13858
+ N && /* @__PURE__ */ jsxs(Tooltip, { children: [
13859
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: d ? /* @__PURE__ */ jsx(CheckIcon, { className: "rounded-full border border-green-500 bg-green-500/10 text-green-500" }) : /* @__PURE__ */ jsx(CopyIcon, { onClick: Z, className: "cursor-pointer" }) }),
13860
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: g("Copy classes to clipboard") }) })
13861
+ ] })
13862
+ ] }),
13863
+ M && r === "default" && /* @__PURE__ */ jsx(Button, { variant: "link", className: "underline", onClick: () => f("design-tokens"), children: g("Design Tokens") })
13864
+ ] }) }),
13865
+ /* @__PURE__ */ jsxs("div", { className: "relative flex items-center gap-x-3", children: [
13866
+ /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
13867
+ Autosuggest,
13868
+ {
13869
+ suggestions: D,
13870
+ onSuggestionsFetchRequested: O,
13871
+ onSuggestionsClearRequested: H,
13872
+ getSuggestionValue: R,
13873
+ renderSuggestion: V,
13874
+ inputProps: W,
13875
+ onSuggestionSelected: (_, { suggestionValue: F }) => {
13876
+ const U = [P(F)];
13877
+ r === "designToken" ? isFunction$1(o) && o(U) : y(S, U, !0), E("");
13878
+ },
13879
+ containerProps: {
13880
+ className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
13881
+ },
13882
+ theme: {
13883
+ suggestion: "bg-transparent",
13884
+ suggestionHighlighted: "!bg-gray-300 dark:!bg-gray-800 cursor-pointer",
13885
+ suggestionsContainerOpen: "absolute bg-background no-scrollbar z-50 max-h-[230px] overflow-y-auto w-full border border-border rounded-md"
13886
+ }
13887
+ }
13888
+ ) }),
13889
+ /* @__PURE__ */ jsx(
13890
+ Button,
13891
+ {
13892
+ variant: "outline",
13893
+ className: `border-border ${r === "default" ? "h-6" : "mt-1 h-7"}`,
13894
+ onClick: L,
13895
+ disabled: v.trim() === "",
13896
+ size: "sm",
13897
+ children: /* @__PURE__ */ jsx(PlusIcon, {})
13898
+ }
13899
+ )
13900
+ ] }),
13901
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: T.map(
13902
+ (_, F) => p === F ? /* @__PURE__ */ jsx(
13903
+ "input",
13904
+ {
13905
+ ref: i,
13906
+ value: l,
13907
+ onChange: (z) => c(z.target.value),
13908
+ onBlur: () => {
13909
+ K(_);
13910
+ },
13911
+ onKeyDown: (z) => {
13912
+ z.key === "Enter" && K(_);
13913
+ },
13914
+ onFocus: (z) => {
13915
+ setTimeout(() => {
13916
+ z.target.select();
13917
+ }, 0);
13918
+ },
13919
+ className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
13920
+ },
13921
+ _
13922
+ ) : /* @__PURE__ */ jsx("div", { className: "group relative flex max-w-[260px] items-center", children: /* @__PURE__ */ jsxs(
13923
+ "button",
13924
+ {
13925
+ onDoubleClick: () => {
13926
+ E(j(_)), r === "default" ? k(S, [_]) : (isFunction$1(a) && a(_), E(_)), setTimeout(() => {
13927
+ i.current && i.current.focus();
13928
+ }, 10);
13929
+ },
13930
+ className: "flex h-max cursor-default items-center gap-x-1 truncate break-words rounded bg-gray-200 py-px pl-0.5 pr-1 text-[11px] text-gray-600 dark:bg-gray-800 dark:text-gray-300",
13931
+ children: [
13932
+ /* @__PURE__ */ jsxs("div", { className: "z-10 flex h-full w-max items-center justify-center", children: [
13933
+ /* @__PURE__ */ jsx(
13934
+ Cross2Icon,
13935
+ {
13936
+ onClick: () => {
13937
+ r === "default" ? k(S, [_]) : isFunction$1(a) && a(_);
13938
+ },
13939
+ className: "hidden h-max w-3.5 cursor-pointer rounded bg-gray-100 p-0.5 text-red-500 hover:bg-gray-50 group-hover:block"
13940
+ }
13941
+ ),
13942
+ _.startsWith(DESIGN_TOKEN_PREFIX) ? /* @__PURE__ */ jsx(DesignTokensIcon, { className: "text-[rgba(55, 65, 81, 0.4)] h-3.5 w-3.5 group-hover:hidden" }) : /* @__PURE__ */ jsxs(
13943
+ "svg",
13944
+ {
13945
+ className: "h-3.5 w-3.5 group-hover:hidden",
13946
+ fill: "rgba(55, 65, 81, 0.4)",
13947
+ viewBox: "0 0 24 24",
13948
+ xmlns: "http://www.w3.org/2000/svg",
13949
+ xmlSpace: "preserve",
13950
+ children: [
13951
+ /* @__PURE__ */ jsx("g", { id: "SVGRepo_bgCarrier", strokeWidth: "0" }),
13952
+ /* @__PURE__ */ jsx("g", { id: "SVGRepo_tracerCarrier", strokeLinecap: "round", strokeLinejoin: "round" }),
13953
+ /* @__PURE__ */ jsx("g", { id: "SVGRepo_iconCarrier", children: /* @__PURE__ */ jsx(
13954
+ "path",
13955
+ {
13956
+ fillRule: "evenodd",
13957
+ clipRule: "evenodd",
13958
+ d: "M12 6.036c-2.667 0-4.333 1.325-5 3.976 1-1.325 2.167-1.822 3.5-1.491.761.189 1.305.738 1.906 1.345C13.387 10.855 14.522 12 17 12c2.667 0 4.333-1.325 5-3.976-1 1.325-2.166 1.822-3.5 1.491-.761-.189-1.305-.738-1.907-1.345-.98-.99-2.114-2.134-4.593-2.134zM7 12c-2.667 0-4.333 1.325-5 3.976 1-1.326 2.167-1.822 3.5-1.491.761.189 1.305.738 1.907 1.345.98.989 2.115 2.134 4.594 2.134 2.667 0 4.333-1.325 5-3.976-1 1.325-2.167 1.822-3.5 1.491-.761-.189-1.305-.738-1.906-1.345C10.613 13.145 9.478 12 7 12z"
13959
+ }
13960
+ ) })
13961
+ ]
13962
+ }
13963
+ )
13964
+ ] }),
13965
+ /* @__PURE__ */ jsx("div", { children: j(_) })
13966
+ ]
13967
+ }
13968
+ ) }, _)
13969
+ ) })
13970
+ ]
13971
+ }
13972
+ );
13972
13973
  }
13973
13974
  const BASIC_UNITS = ["px", "%", "em", "rem", "ch", "vh", "vw"], FLEX_CHILD_SECTION = {
13974
13975
  heading: "flex.heading",
@@ -14275,16 +14276,16 @@ const registerChaiLibrary = (r, n) => {
14275
14276
  "div",
14276
14277
  {
14277
14278
  draggable: b,
14278
- onDragStart: async (S) => {
14279
+ onDragStart: async (k) => {
14279
14280
  try {
14280
14281
  if (i) {
14281
- i(S);
14282
+ i(k);
14282
14283
  return;
14283
14284
  }
14284
- let k = null;
14285
+ let S = null;
14285
14286
  if (u === "Image") {
14286
14287
  if (!(r != null && r.image)) return;
14287
- k = {
14288
+ S = {
14288
14289
  type: "Image",
14289
14290
  blocks: [
14290
14291
  {
@@ -14297,35 +14298,35 @@ const registerChaiLibrary = (r, n) => {
14297
14298
  ]
14298
14299
  };
14299
14300
  } else if (n) {
14300
- const C = typeof n == "function" ? await n() : n, E = getBlocksFromHTML(C);
14301
+ const v = typeof n == "function" ? await n() : n, E = getBlocksFromHTML(v);
14301
14302
  if (isEmpty(E)) return;
14302
- k = {
14303
+ S = {
14303
14304
  type: "Box",
14304
14305
  blocks: E,
14305
14306
  name: get(E, "0._type", "Block")
14306
14307
  };
14307
14308
  } else if (o) {
14308
- const C = typeof o == "function" ? await o() : o;
14309
- if (isEmpty(C)) return;
14310
- k = {
14309
+ const v = typeof o == "function" ? await o() : o;
14310
+ if (isEmpty(v)) return;
14311
+ S = {
14311
14312
  type: "Box",
14312
- blocks: C,
14313
- name: get(C, "0._type", "Block")
14313
+ blocks: v,
14314
+ name: get(v, "0._type", "Block")
14314
14315
  };
14315
14316
  } else if (r) {
14316
- const C = typeof r == "function" ? await r() : r;
14317
- k = typeof C == "object" ? omit(C, ["component", "icon"]) : C;
14317
+ const v = typeof r == "function" ? await r() : r;
14318
+ S = typeof v == "object" ? omit(v, ["component", "icon"]) : v;
14318
14319
  }
14319
- if (!k) return;
14320
- p(S, k, !0), setTimeout(() => {
14320
+ if (!S) return;
14321
+ p(k, S, !0), setTimeout(() => {
14321
14322
  m([]), g();
14322
14323
  }, 200);
14323
- } catch (k) {
14324
- console.error("Error in ChaiDraggableBlock drag start:", k);
14324
+ } catch (S) {
14325
+ console.error("Error in ChaiDraggableBlock drag start:", S);
14325
14326
  }
14326
14327
  },
14327
- onDragEnd: (S) => {
14328
- l ? l(S) : h();
14328
+ onDragEnd: (k) => {
14329
+ l ? l(k) : h();
14329
14330
  },
14330
14331
  className: `${b ? "cursor-grab active:cursor-grabbing" : ""} ${d}`.trim(),
14331
14332
  children: a
@@ -14370,16 +14371,16 @@ const BlockCard = ({
14370
14371
  return;
14371
14372
  }
14372
14373
  l(!0);
14373
- let S = await c({ library: n, block: r });
14374
- typeof S == "string" && (S = getBlocksFromHTML(S)), isEmpty(S) || u(syncBlocksWithDefaults(S), o, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK), setTimeout(() => l(!1), 1e3);
14374
+ let k = await c({ library: n, block: r });
14375
+ typeof k == "string" && (k = getBlocksFromHTML(k)), isEmpty(k) || u(syncBlocksWithDefaults(k), o, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK), setTimeout(() => l(!1), 1e3);
14375
14376
  },
14376
14377
  [d, u, r, c, n, o, a]
14377
14378
  );
14378
14379
  return /* @__PURE__ */ jsxs(Tooltip, { children: [
14379
14380
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(ChaiDraggableBlock, { draggable: g, onDragStart: async (y) => {
14380
14381
  if (!g) return;
14381
- let S = await c({ library: n, block: r });
14382
- typeof S == "string" && (S = getBlocksFromHTML(S)), f(y, { type: "Box", blocks: S, name: p }, !0);
14382
+ let k = await c({ library: n, block: r });
14383
+ typeof k == "string" && (k = getBlocksFromHTML(k)), f(y, { type: "Box", blocks: k, name: p }, !0);
14383
14384
  }, onDragEnd: m, children: /* @__PURE__ */ jsxs(
14384
14385
  "div",
14385
14386
  {
@@ -14423,28 +14424,28 @@ const BlockCard = ({
14423
14424
  const N = b.current.search(h).map((j) => j.item);
14424
14425
  g(N);
14425
14426
  }, [h]);
14426
- const x = h.trim() && !isEmpty(m) ? m : d, y = groupBy(x, "group"), [S, k] = useState(null);
14427
+ const x = h.trim() && !isEmpty(m) ? m : d, y = groupBy(x, "group"), [k, S] = useState(null);
14427
14428
  useEffect(() => {
14428
14429
  if (isEmpty(keys$1(y))) {
14429
- k(null);
14430
+ S(null);
14430
14431
  return;
14431
14432
  }
14432
- if (!S || !y[S]) {
14433
- k(first$1(keys$1(y)));
14433
+ if (!k || !y[k]) {
14434
+ S(first$1(keys$1(y)));
14434
14435
  return;
14435
14436
  }
14436
- }, [y, S]);
14437
- const C = get(y, S, []), E = useRef(null), { t: B } = useTranslation(), I = useRef(null);
14437
+ }, [y, k]);
14438
+ const v = get(y, k, []), E = useRef(null), { t: B } = useTranslation(), I = useRef(null);
14438
14439
  useEffect(() => {
14439
14440
  var j;
14440
14441
  const N = (j = I.current) == null ? void 0 : j.querySelector("[data-radix-scroll-area-viewport]");
14441
14442
  N && N.scrollTo({ top: 0, behavior: "smooth" });
14442
- }, [c, S]);
14443
- const w = (N) => {
14443
+ }, [c, k]);
14444
+ const A = (N) => {
14444
14445
  E.current && (clearTimeout(E.current), E.current = null), E.current = setTimeout(() => {
14445
- E.current && k(N);
14446
+ E.current && S(N);
14446
14447
  }, 400);
14447
- }, A = () => {
14448
+ }, w = () => {
14448
14449
  c != null && c.id && p(c.id);
14449
14450
  };
14450
14451
  if (u)
@@ -14452,7 +14453,7 @@ const BlockCard = ({
14452
14453
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
14453
14454
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
14454
14455
  ] });
14455
- const v = filter(C, (N, j) => j % 2 === 0), T = filter(C, (N, j) => j % 2 === 1);
14456
+ const C = filter(v, (N, j) => j % 2 === 0), T = filter(v, (N, j) => j % 2 === 1);
14456
14457
  return /* @__PURE__ */ jsx(Fragment$1, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
14457
14458
  /* @__PURE__ */ jsx(SearchInput, { value: h, setValue: f }),
14458
14459
  /* @__PURE__ */ jsx("div", { className: "relative flex h-full max-h-full flex-1 overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: `flex h-full flex-1 pt-2 ${o ? "flex-col" : ""}`, children: [
@@ -14471,23 +14472,23 @@ const BlockCard = ({
14471
14472
  className: `no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto ${o ? "" : "pb-20"}`,
14472
14473
  children: isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: h ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: B("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
14473
14474
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: B("Failed to load the UI library. Try again") }),
14474
- /* @__PURE__ */ jsxs(Button, { onClick: A, variant: "outline", size: "sm", className: "gap-2", children: [
14475
+ /* @__PURE__ */ jsxs(Button, { onClick: w, variant: "outline", size: "sm", className: "gap-2", children: [
14475
14476
  /* @__PURE__ */ jsx(ReloadIcon, { className: "h-4 w-4" }),
14476
14477
  B("Retry")
14477
14478
  ] })
14478
- ] }) }) : o ? /* @__PURE__ */ jsxs(Select$1, { value: S, onValueChange: k, children: [
14479
+ ] }) }) : o ? /* @__PURE__ */ jsxs(Select$1, { value: k, onValueChange: S, children: [
14479
14480
  /* @__PURE__ */ jsx(SelectTrigger, { className: "w-full", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: B("Select a group") }) }),
14480
14481
  /* @__PURE__ */ jsx(SelectContent, { children: map(y, (N, j) => /* @__PURE__ */ jsx(SelectItem, { value: j, children: capitalize(B(j.toLowerCase())) }, j)) })
14481
14482
  ] }) : map(y, (N, j) => /* @__PURE__ */ jsxs(
14482
14483
  "div",
14483
14484
  {
14484
- onMouseEnter: () => w(j),
14485
+ onMouseEnter: () => A(j),
14485
14486
  onMouseLeave: () => clearTimeout(E.current),
14486
14487
  role: "button",
14487
- onClick: () => k(j),
14488
+ onClick: () => S(j),
14488
14489
  className: cn$2(
14489
14490
  "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",
14490
- j === S ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
14491
+ j === k ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
14491
14492
  ),
14492
14493
  children: [
14493
14494
  /* @__PURE__ */ jsx("span", { children: capitalize(B(j.toLowerCase())) }),
@@ -14509,8 +14510,8 @@ const BlockCard = ({
14509
14510
  onMouseEnter: () => E.current ? clearTimeout(E.current) : null,
14510
14511
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
14511
14512
  children: [
14512
- isEmpty(C) && !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: B("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: `grid w-full gap-2 ${o ? "grid-cols-1 pb-20" : "grid-cols-2 px-2"}`, children: [
14513
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: v.map((N, j) => /* @__PURE__ */ jsx(
14513
+ isEmpty(v) && !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: B("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: `grid w-full gap-2 ${o ? "grid-cols-1 pb-20" : "grid-cols-2 px-2"}`, children: [
14514
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((N, j) => /* @__PURE__ */ jsx(
14514
14515
  BlockCard,
14515
14516
  {
14516
14517
  parentId: r,
@@ -14570,19 +14571,19 @@ const BlockCard = ({
14570
14571
  }), f(!0);
14571
14572
  else if (!l && Object.keys(i || {}).length > 0) {
14572
14573
  const g = Object.entries(i).map(([x, y]) => {
14573
- const S = y, k = S.type || "partial", C = formatReadableName(k);
14574
+ const k = y, S = k.type || "partial", v = formatReadableName(S);
14574
14575
  return {
14575
14576
  type: "PartialBlock",
14576
14577
  // Set the type to PartialBlock
14577
- label: formatReadableName(S.name || x),
14578
- description: S.description || "",
14578
+ label: formatReadableName(k.name || x),
14579
+ description: k.description || "",
14579
14580
  icon: FrameIcon,
14580
- group: C,
14581
+ group: v,
14581
14582
  // Use formatted type as group
14582
14583
  category: "partial",
14583
14584
  partialBlockId: x,
14584
14585
  // Store the original ID as partialBlockId
14585
- _name: S.name
14586
+ _name: k.name
14586
14587
  };
14587
14588
  }), b = uniq(map(g, "group"));
14588
14589
  p({
@@ -14641,7 +14642,7 @@ const BlockCard = ({
14641
14642
  disableBlockGroupsSidebar: l
14642
14643
  }) => {
14643
14644
  var N;
14644
- const { t: c } = useTranslation(), [d] = useBlocksStore(), [u, p] = useState(""), h = useRef(null), [f] = useAtom$1(addBlockTabAtom), m = (N = find(d, (j) => j._id === o)) == null ? void 0 : N._type, [g, b] = useState("all"), [x, y] = useState(null), S = useRef(null), k = useBuilderProp("flags.dragAndDrop", !1);
14645
+ const { t: c } = useTranslation(), [d] = useBlocksStore(), [u, p] = useState(""), h = useRef(null), [f] = useAtom$1(addBlockTabAtom), m = (N = find(d, (j) => j._id === o)) == null ? void 0 : N._type, [g, b] = useState("all"), [x, y] = useState(null), k = useRef(null), S = useBuilderProp("flags.dragAndDrop", !1);
14645
14646
  useEffect(() => {
14646
14647
  const j = setTimeout(() => {
14647
14648
  var P;
@@ -14650,17 +14651,17 @@ const BlockCard = ({
14650
14651
  return () => clearTimeout(j);
14651
14652
  }, [f]), useEffect(() => {
14652
14653
  u && (b("all"), y(null));
14653
- }, [u]), useEffect(() => (S.current = debounce((j) => {
14654
+ }, [u]), useEffect(() => (k.current = debounce((j) => {
14654
14655
  b(j);
14655
14656
  }, 500), () => {
14656
- S.current && S.current.cancel();
14657
+ k.current && k.current.cancel();
14657
14658
  }), []);
14658
- const C = useCallback((j) => {
14659
- y(j), S.current && S.current(j);
14659
+ const v = useCallback((j) => {
14660
+ y(j), k.current && k.current(j);
14660
14661
  }, []), E = useCallback(() => {
14661
- y(null), S.current && S.current.cancel();
14662
+ y(null), k.current && k.current.cancel();
14662
14663
  }, []), B = useCallback((j) => {
14663
- S.current && S.current.cancel(), b(j), y(null);
14664
+ k.current && k.current.cancel(), b(j), y(null);
14664
14665
  }, []), I = useMemo(
14665
14666
  () => u ? values(n).filter(
14666
14667
  (j) => {
@@ -14669,35 +14670,35 @@ const BlockCard = ({
14669
14670
  }
14670
14671
  ) : n,
14671
14672
  [n, u]
14672
- ), w = useMemo(
14673
+ ), A = useMemo(
14673
14674
  () => u ? r.filter(
14674
14675
  (j) => reject(filter(values(I), { group: j }), { hidden: !0 }).length > 0
14675
14676
  ) : r.filter((j) => reject(filter(values(n), { group: j }), { hidden: !0 }).length > 0),
14676
14677
  [n, I, r, u]
14677
- ), A = useMemo(
14678
- () => sortBy(w, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
14679
- [w]
14680
- ), v = useMemo(() => g === "all" ? I : filter(values(I), { group: g }), [I, g]), T = useMemo(() => g === "all" ? A : [g], [A, g]);
14678
+ ), w = useMemo(
14679
+ () => sortBy(A, (j) => CORE_GROUPS.indexOf(j) === -1 ? 99 : CORE_GROUPS.indexOf(j)),
14680
+ [A]
14681
+ ), C = useMemo(() => g === "all" ? I : filter(values(I), { group: g }), [I, g]), T = useMemo(() => g === "all" ? w : [g], [w, g]);
14681
14682
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full flex-col", children: [
14682
14683
  /* @__PURE__ */ jsx(SearchInput, { value: u, setValue: p }),
14683
14684
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden pt-2", children: [
14684
- !l && A.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", children: [
14685
+ !l && w.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", children: [
14685
14686
  /* @__PURE__ */ jsx(
14686
14687
  "button",
14687
14688
  {
14688
14689
  onClick: () => B("all"),
14689
- onMouseEnter: () => C("all"),
14690
+ onMouseEnter: () => v("all"),
14690
14691
  onMouseLeave: E,
14691
14692
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${g === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
14692
14693
  children: c("All")
14693
14694
  },
14694
14695
  "sidebar-all"
14695
14696
  ),
14696
- A.map((j) => /* @__PURE__ */ jsx(
14697
+ w.map((j) => /* @__PURE__ */ jsx(
14697
14698
  "button",
14698
14699
  {
14699
14700
  onClick: () => B(j),
14700
- onMouseEnter: () => C(j),
14701
+ onMouseEnter: () => v(j),
14701
14702
  onMouseLeave: E,
14702
14703
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${g === j || x === j ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
14703
14704
  children: capitalize(c(j.toLowerCase()))
@@ -14708,8 +14709,8 @@ const BlockCard = ({
14708
14709
  /* @__PURE__ */ jsx(
14709
14710
  "div",
14710
14711
  {
14711
- className: `h-full flex-1 overflow-hidden ${!l && A.length > 0 ? "w-3/4" : "w-full"}`,
14712
- children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar h-full", children: w.length === 0 && u ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
14712
+ className: `h-full flex-1 overflow-hidden ${!l && w.length > 0 ? "w-3/4" : "w-full"}`,
14713
+ children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar h-full", children: A.length === 0 && u ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
14713
14714
  c("No blocks found matching"),
14714
14715
  ' "',
14715
14716
  u,
@@ -14717,7 +14718,7 @@ const BlockCard = ({
14717
14718
  ] }) }) : /* @__PURE__ */ jsx("div", { className: `${l ? "p-0" : "p-4"} space-y-6`, children: T.map((j, P) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
14718
14719
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(c(j.toLowerCase())) }),
14719
14720
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + i, children: reject(
14720
- g === "all" ? filter(values(v), { group: j }) : values(v),
14721
+ g === "all" ? filter(values(C), { group: j }) : values(C),
14721
14722
  { hidden: !0 }
14722
14723
  ).map((L, D) => /* @__PURE__ */ jsx(
14723
14724
  CoreBlock,
@@ -14725,7 +14726,7 @@ const BlockCard = ({
14725
14726
  parentId: o,
14726
14727
  position: a,
14727
14728
  block: L,
14728
- disabled: !k && (!canAcceptChildBlock(m, L.type) || !canBeNestedInside(m, L.type))
14729
+ disabled: !S && (!canAcceptChildBlock(m, L.type) || !canBeNestedInside(m, L.type))
14729
14730
  },
14730
14731
  L.type + "-" + P + "-" + D
14731
14732
  )) })
@@ -14747,10 +14748,10 @@ const BlockCard = ({
14747
14748
  }, [c, f, d]);
14748
14749
  const g = useCallback(() => {
14749
14750
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
14750
- }, []), b = useChaiAddBlockTabs(), x = p && m(PERMISSIONS.IMPORT_HTML), S = useChaiLibraries().length > 0;
14751
+ }, []), b = useChaiAddBlockTabs(), x = p && m(PERMISSIONS.IMPORT_HTML), k = useChaiLibraries().length > 0;
14751
14752
  return useEffect(() => {
14752
- c === "library" && !S && d("core");
14753
- }, [c, S, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", r), children: [
14753
+ c === "library" && !k && d("core");
14754
+ }, [c, k, d]), /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", r), children: [
14754
14755
  n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
14755
14756
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
14756
14757
  /* @__PURE__ */ jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: l(c === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
@@ -14758,25 +14759,25 @@ const BlockCard = ({
14758
14759
  /* @__PURE__ */ jsxs(
14759
14760
  Tabs,
14760
14761
  {
14761
- onValueChange: (k) => {
14762
- u(""), d(k);
14762
+ onValueChange: (S) => {
14763
+ u(""), d(S);
14763
14764
  },
14764
14765
  value: c,
14765
14766
  className: "flex h-full max-h-full flex-col overflow-hidden",
14766
14767
  children: [
14767
14768
  /* @__PURE__ */ jsxs(TabsList, { className: `flex items-center ${i ? "h-max w-max justify-start p-1" : "w-full"}`, children: [
14768
- S && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", className: i ? "h-5 px-2 text-xs" : "", children: l("Library") }),
14769
+ k && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", className: i ? "h-5 px-2 text-xs" : "", children: l("Library") }),
14769
14770
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", className: i ? "h-5 px-2 text-xs" : "", children: l("Blocks") }),
14770
14771
  f && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", className: i ? "h-5 px-2 text-xs" : "", children: l("Partials") }),
14771
14772
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", className: i ? "h-5 px-2 text-xs" : "", children: l("Import") }) : null,
14772
- map(b, (k) => /* @__PURE__ */ jsx(
14773
+ map(b, (S) => /* @__PURE__ */ jsx(
14773
14774
  TabsTrigger,
14774
14775
  {
14775
- value: k.id,
14776
+ value: S.id,
14776
14777
  className: i ? "h-5 px-2 text-xs" : "",
14777
- children: React__default.createElement(k.tab)
14778
+ children: React__default.createElement(S.tab)
14778
14779
  },
14779
- `tab-add-block-${k.id}`
14780
+ `tab-add-block-${S.id}`
14780
14781
  ))
14781
14782
  ] }),
14782
14783
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(
@@ -14788,7 +14789,7 @@ const BlockCard = ({
14788
14789
  disableBlockGroupsSidebar: i
14789
14790
  }
14790
14791
  ) }) }) }),
14791
- S && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { fromSidebar: i, parentId: o, position: a }) }),
14792
+ k && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { fromSidebar: i, parentId: o, position: a }) }),
14792
14793
  f && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "h-full w-full", children: /* @__PURE__ */ jsx(
14793
14794
  PartialBlocks,
14794
14795
  {
@@ -14799,7 +14800,7 @@ const BlockCard = ({
14799
14800
  }
14800
14801
  ) }) }) }),
14801
14802
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20 ", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: o, position: a, fromSidebar: i }) }) : null,
14802
- map(b, (k) => /* @__PURE__ */ jsx(TabsContent, { value: k.id, children: React__default.createElement(k.tabContent, { close: g, parentId: o, position: a }) }, `panel-add-block-${k.id}`))
14803
+ map(b, (S) => /* @__PURE__ */ jsx(TabsContent, { value: S.id, children: React__default.createElement(S.tabContent, { close: g, parentId: o, position: a }) }, `panel-add-block-${S.id}`))
14803
14804
  ]
14804
14805
  }
14805
14806
  )
@@ -15201,38 +15202,38 @@ const useStructureValidation = () => {
15201
15202
  var n;
15202
15203
  return r != null && r._name ? r._name : (r == null ? void 0 : r._type) === "Box" && (r != null && r.tag) && (r == null ? void 0 : r.tag) !== "div" ? startCase(r.tag) : ((n = r == null ? void 0 : r._type) == null ? void 0 : n.split("/").pop()) || "";
15203
15204
  }, truncateText = (r, n) => r.length > n ? r.substring(0, n) + "..." : r, Node$1 = memo(({ node: r, style: n, dragHandle: o }) => {
15204
- var R;
15205
+ var H;
15205
15206
  const { t: a } = useTranslation(), i = useUpdateBlocksProps(), [l] = useAtom$1(canvasIframeAtom), { hasPermission: c } = usePermissions();
15206
15207
  let d = null;
15207
- const u = r.children.length > 0, { highlightBlock: p, clearHighlight: h } = useBlockHighlight(), f = useIsDragAndDropEnabled(), { id: m, data: g, isSelected: b, willReceiveDrop: x, isDragging: y, isEditing: S, handleClick: k } = r, C = useStructureValidation(), E = useMemo(() => C.getBlockErrors(m), [C, m]), B = get(g, "_show", !0), I = (_) => {
15208
- _.stopPropagation(), B && r.toggle();
15209
- }, w = (_) => {
15210
- _.isInternal && (d = _.isOpen, _.isOpen && _.close());
15211
- }, A = (_) => {
15212
- _.isInternal && d !== null && (d ? _.open() : _.close(), d = null);
15213
- }, [v, T] = useAtom$1(currentAddSelection), N = () => {
15214
- var _;
15215
- j(), r.parent.isSelected || T((_ = r == null ? void 0 : r.parent) == null ? void 0 : _.id);
15208
+ const u = r.children.length > 0, { highlightBlock: p, clearHighlight: h } = useBlockHighlight(), f = useIsDragAndDropEnabled(), { id: m, data: g, isSelected: b, willReceiveDrop: x, isDragging: y, isEditing: k, handleClick: S } = r, v = useStructureValidation(), E = useMemo(() => v.getBlockErrors(m), [v, m]), B = get(g, "_show", !0), I = (R) => {
15209
+ R.stopPropagation(), B && r.toggle();
15210
+ }, A = (R) => {
15211
+ R.isInternal && (d = R.isOpen, R.isOpen && R.close());
15212
+ }, w = (R) => {
15213
+ R.isInternal && d !== null && (d ? R.open() : R.close(), d = null);
15214
+ }, [C, T] = useAtom$1(currentAddSelection), N = () => {
15215
+ var R;
15216
+ j(), r.parent.isSelected || T((R = r == null ? void 0 : r.parent) == null ? void 0 : R.id);
15216
15217
  }, j = () => {
15217
15218
  T(null);
15218
- }, P = (_) => {
15219
- j(), _.stopPropagation(), !r.isOpen && B && r.toggle(), k(_);
15219
+ }, P = (R) => {
15220
+ j(), R.stopPropagation(), !r.isOpen && B && r.toggle(), S(R);
15220
15221
  };
15221
15222
  useEffect(() => {
15222
- const _ = setTimeout(() => {
15223
+ const R = setTimeout(() => {
15223
15224
  x && !r.isOpen && !y && B && r.toggle();
15224
15225
  }, 500);
15225
- return () => clearTimeout(_);
15226
+ return () => clearTimeout(R);
15226
15227
  }, [x, r, y]);
15227
- const L = (_, M) => {
15228
- const $ = l.contentDocument || l.contentWindow.document, U = $.querySelector(`[data-block-id=${_}]`);
15229
- U && U.setAttribute("data-drop", M);
15230
- const W = U.getBoundingClientRect(), V = l.getBoundingClientRect();
15231
- W.top >= V.top && W.left >= V.left && W.bottom <= V.bottom && W.right <= V.right || ($.documentElement.scrollTop = U.offsetTop - V.top);
15232
- }, D = (_) => {
15228
+ const L = (R, V) => {
15229
+ const W = l.contentDocument || l.contentWindow.document, K = W.querySelector(`[data-block-id=${R}]`);
15230
+ K && K.setAttribute("data-drop", V);
15231
+ const Z = K.getBoundingClientRect(), G = l.getBoundingClientRect();
15232
+ Z.top >= G.top && Z.left >= G.left && Z.bottom <= G.bottom && Z.right <= G.right || (W.documentElement.scrollTop = K.offsetTop - G.top);
15233
+ }, D = (R) => {
15233
15234
  j();
15234
- const M = get(r, "parent.id");
15235
- M !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: M, position: _ }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: _ });
15235
+ const V = get(r, "parent.id");
15236
+ V !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: V, position: R }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: R });
15236
15237
  };
15237
15238
  if (m === ROOT_TEMP_KEY)
15238
15239
  return /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 w-full cursor-pointer", children: [
@@ -15252,7 +15253,7 @@ const useStructureValidation = () => {
15252
15253
  ),
15253
15254
  /* @__PURE__ */ jsx("br", {})
15254
15255
  ] });
15255
- const { librarySite: F } = useBuilderProp("flags", { librarySite: !1 }), H = useMemo(() => F && has(g, "_libBlockId") && !isEmpty(g._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [g, c, F]), O = useMemo(() => (g == null ? void 0 : g._type) === "PartialBlock" || (g == null ? void 0 : g._type) === "GlobalBlock", [g]);
15256
+ const { librarySite: $ } = useBuilderProp("flags", { librarySite: !1 }), M = useMemo(() => $ && has(g, "_libBlockId") && !isEmpty(g._libBlockId) && (c(PERMISSIONS.CREATE_LIBRARY_BLOCK) || c(PERMISSIONS.EDIT_LIBRARY_BLOCK)), [g, c, $]), O = useMemo(() => (g == null ? void 0 : g._type) === "PartialBlock" || (g == null ? void 0 : g._type) === "GlobalBlock", [g]);
15256
15257
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
15257
15258
  "div",
15258
15259
  {
@@ -15262,23 +15263,23 @@ const useStructureValidation = () => {
15262
15263
  style: n,
15263
15264
  "data-node-id": m,
15264
15265
  ref: o,
15265
- onDragStart: () => w(r),
15266
- onDragEnd: () => A(r),
15267
- onDragOver: (_) => {
15268
- _.preventDefault(), L(m, "yes");
15266
+ onDragStart: () => A(r),
15267
+ onDragEnd: () => w(r),
15268
+ onDragOver: (R) => {
15269
+ R.preventDefault(), L(m, "yes");
15269
15270
  },
15270
- onDragLeave: (_) => {
15271
- _.preventDefault(), L(m, "no");
15271
+ onDragLeave: (R) => {
15272
+ R.preventDefault(), L(m, "no");
15272
15273
  },
15273
- onDrop: (_) => {
15274
- _.preventDefault(), L(m, "no");
15274
+ onDrop: (R) => {
15275
+ R.preventDefault(), L(m, "no");
15275
15276
  },
15276
15277
  children: [
15277
- c(PERMISSIONS.ADD_BLOCK) && !f && (r == null ? void 0 : r.rowIndex) > 0 && (r.parent.isOpen && canAddChildBlock(get(r, "parent.data._type")) || ((R = r == null ? void 0 : r.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
15278
+ c(PERMISSIONS.ADD_BLOCK) && !f && (r == null ? void 0 : r.rowIndex) > 0 && (r.parent.isOpen && canAddChildBlock(get(r, "parent.data._type")) || ((H = r == null ? void 0 : r.parent) == null ? void 0 : H.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
15278
15279
  "div",
15279
15280
  {
15280
- onClick: (_) => {
15281
- _.stopPropagation(), D(r.childIndex);
15281
+ onClick: (R) => {
15282
+ R.stopPropagation(), D(r.childIndex);
15282
15283
  },
15283
15284
  onMouseEnter: N,
15284
15285
  onMouseLeave: j,
@@ -15293,10 +15294,10 @@ const useStructureValidation = () => {
15293
15294
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 py-0 outline-none",
15294
15295
  b ? "bg-primary/20" : "hover:bg-primary/10",
15295
15296
  x && canAcceptChildBlock(g._type, "Icon") ? "bg-green-200" : "",
15296
- (r == null ? void 0 : r.id) === v ? "bg-primary/10" : "",
15297
+ (r == null ? void 0 : r.id) === C ? "bg-primary/10" : "",
15297
15298
  y && "opacity-20",
15298
15299
  B ? "" : "line-through opacity-50",
15299
- H && b && "bg-primary/20 text-primary"
15300
+ M && b && "bg-primary/20 text-primary"
15300
15301
  ),
15301
15302
  children: [
15302
15303
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -15312,19 +15313,19 @@ const useStructureValidation = () => {
15312
15313
  {
15313
15314
  className: cn(
15314
15315
  "leading-1 flex items-center",
15315
- H && "text-orange-600/90",
15316
- H && b && "text-orange-800",
15316
+ M && "text-orange-600/90",
15317
+ M && b && "text-orange-800",
15317
15318
  O && "text-purple-600/90",
15318
15319
  O && b && "text-purple-800"
15319
15320
  ),
15320
15321
  children: [
15321
15322
  E.length > 0 ? /* @__PURE__ */ jsx("div", { className: "text-red-500", children: /* @__PURE__ */ jsx(ExclamationTriangleIcon, { className: "h-3 w-3" }) }) : /* @__PURE__ */ jsx(TypeIcon, { type: g == null ? void 0 : g._type }),
15322
- S ? /* @__PURE__ */ jsx(Input, { node: r }) : /* @__PURE__ */ jsx(
15323
+ k ? /* @__PURE__ */ jsx(Input, { node: r }) : /* @__PURE__ */ jsx(
15323
15324
  "div",
15324
15325
  {
15325
15326
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
15326
- onDoubleClick: (_) => {
15327
- _.stopPropagation(), r.edit(), r.deselect();
15327
+ onDoubleClick: (R) => {
15328
+ R.stopPropagation(), r.edit(), r.deselect();
15328
15329
  },
15329
15330
  children: /* @__PURE__ */ jsx("span", { title: getBlockDisplayName(g).length > 17 ? getBlockDisplayName(g) : "", children: truncateText(getBlockDisplayName(g), 17) })
15330
15331
  }
@@ -15350,8 +15351,8 @@ const useStructureValidation = () => {
15350
15351
  /* @__PURE__ */ jsx(
15351
15352
  TooltipTrigger,
15352
15353
  {
15353
- onClick: (_) => {
15354
- _.stopPropagation(), i([m], { _show: !B }), r.isOpen && r.toggle();
15354
+ onClick: (R) => {
15355
+ R.stopPropagation(), i([m], { _show: !B }), r.isOpen && r.toggle();
15355
15356
  },
15356
15357
  className: "cursor-pointer rounded bg-transparent p-0.5 hover:bg-primary/10",
15357
15358
  asChild: !0,
@@ -15804,20 +15805,20 @@ const useStructureValidation = () => {
15804
15805
  }
15805
15806
  }, ThemeConfigPanel = React.memo(({ className: r = "" }) => {
15806
15807
  const [n, o] = useDarkMode(), [a, i] = React.useState(""), [l, c] = React.useState(!1), d = useBuilderProp("themePresets", []), u = useBuilderProp("themePanelComponent", null), { hasPermission: p } = usePermissions(), h = useBuilderProp("flags.importTheme", !0), f = useBuilderProp("flags.darkMode", !0), m = useIncrementActionsCount();
15807
- (!d || d.length === 0) && DEFAULT_THEME_PRESET.map((A) => {
15808
- d.push(A);
15808
+ (!d || d.length === 0) && DEFAULT_THEME_PRESET.map((w) => {
15809
+ d.push(w);
15809
15810
  });
15810
- const [g, b] = useTheme(), x = useThemeOptions(), { t: y } = useTranslation(), S = React.useCallback(
15811
- (A) => {
15812
- const v = { ...g };
15813
- setPreviousTheme(v), b(A), m(), toast.success("Theme updated", {
15811
+ const [g, b] = useTheme(), x = useThemeOptions(), { t: y } = useTranslation(), k = React.useCallback(
15812
+ (w) => {
15813
+ const C = { ...g };
15814
+ setPreviousTheme(C), b(w), m(), toast.success("Theme updated", {
15814
15815
  action: {
15815
15816
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
15816
15817
  /* @__PURE__ */ jsx(ResetIcon, { className: "h-4 w-4" }),
15817
15818
  " Undo"
15818
15819
  ] }),
15819
15820
  onClick: () => {
15820
- b(v), clearPreviousTheme(), toast.dismiss();
15821
+ b(C), clearPreviousTheme(), toast.dismiss();
15821
15822
  }
15822
15823
  },
15823
15824
  closeButton: !0,
@@ -15825,62 +15826,62 @@ const useStructureValidation = () => {
15825
15826
  });
15826
15827
  },
15827
15828
  [g, b, m]
15828
- ), k = () => {
15829
- const A = d.find((v) => Object.keys(v)[0] === a);
15830
- if (A) {
15831
- const v = Object.values(A)[0];
15832
- v && typeof v == "object" && "fontFamily" in v && "borderRadius" in v && "colors" in v ? (S(v), i(""), m()) : console.error("Invalid preset structure:", v);
15829
+ ), S = () => {
15830
+ const w = d.find((C) => Object.keys(C)[0] === a);
15831
+ if (w) {
15832
+ const C = Object.values(w)[0];
15833
+ C && typeof C == "object" && "fontFamily" in C && "borderRadius" in C && "colors" in C ? (k(C), i(""), m()) : console.error("Invalid preset structure:", C);
15833
15834
  } else
15834
15835
  console.error("Preset not found:", a);
15835
- }, C = (A) => {
15836
- S(A), i(""), m();
15836
+ }, v = (w) => {
15837
+ k(w), i(""), m();
15837
15838
  }, E = useDebouncedCallback(
15838
- (A, v) => {
15839
+ (w, C) => {
15839
15840
  b(() => ({
15840
15841
  ...g,
15841
15842
  fontFamily: {
15842
15843
  ...g.fontFamily,
15843
- [A.replace(/font-/g, "")]: v
15844
+ [w.replace(/font-/g, "")]: C
15844
15845
  }
15845
15846
  })), m();
15846
15847
  },
15847
15848
  [g, m],
15848
15849
  200
15849
15850
  ), B = React.useCallback(
15850
- (A) => {
15851
+ (w) => {
15851
15852
  b(() => ({
15852
15853
  ...g,
15853
- borderRadius: `${A}px`
15854
+ borderRadius: `${w}px`
15854
15855
  })), m();
15855
15856
  },
15856
15857
  [g, m]
15857
15858
  ), I = useDebouncedCallback(
15858
- (A, v) => {
15859
+ (w, C) => {
15859
15860
  b(() => {
15860
- const T = get(g, `colors.${A}`);
15861
- return n ? set(T, 1, v) : set(T, 0, v), m(), {
15861
+ const T = get(g, `colors.${w}`);
15862
+ return n ? set(T, 1, C) : set(T, 0, C), m(), {
15862
15863
  ...g,
15863
15864
  colors: {
15864
15865
  ...g.colors,
15865
- [A]: T
15866
+ [w]: T
15866
15867
  }
15867
15868
  };
15868
15869
  });
15869
15870
  },
15870
15871
  [g, m],
15871
15872
  200
15872
- ), w = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([v]) => {
15873
- const T = get(g, `colors.${v}.${n ? 1 : 0}`);
15874
- return T ? /* @__PURE__ */ jsxs("div", { id: `theme-${v}`, className: "mt-1 flex items-center gap-x-2", children: [
15873
+ ), A = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([C]) => {
15874
+ const T = get(g, `colors.${C}.${n ? 1 : 0}`);
15875
+ return T ? /* @__PURE__ */ jsxs("div", { id: `theme-${C}`, className: "mt-1 flex items-center gap-x-2", children: [
15875
15876
  /* @__PURE__ */ jsx(
15876
15877
  ColorPickerInput,
15877
15878
  {
15878
15879
  value: T,
15879
- onChange: (N) => I(v, N)
15880
+ onChange: (N) => I(C, N)
15880
15881
  }
15881
15882
  ),
15882
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: v.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((N) => N.charAt(0).toUpperCase() + N.slice(1)).join(" ") + (!v.toLowerCase().includes("foreground") && !v.toLowerCase().includes("border") && !v.toLowerCase().includes("input") && !v.toLowerCase().includes("ring") && !v.toLowerCase().includes("background") ? " Background" : "") })
15883
- ] }, v) : null;
15883
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: C.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((N) => N.charAt(0).toUpperCase() + N.slice(1)).join(" ") + (!C.toLowerCase().includes("foreground") && !C.toLowerCase().includes("border") && !C.toLowerCase().includes("input") && !C.toLowerCase().includes("ring") && !C.toLowerCase().includes("background") ? " Background" : "") })
15884
+ ] }, C) : null;
15884
15885
  }) });
15885
15886
  return p("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
15886
15887
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", r), children: [
@@ -15895,12 +15896,12 @@ const useStructureValidation = () => {
15895
15896
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
15896
15897
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: i, children: [
15897
15898
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: y("Select preset") }) }),
15898
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((A) => {
15899
- const v = Object.keys(A)[0], T = v.replaceAll("_", " ");
15900
- return /* @__PURE__ */ jsx(SelectItem, { value: v, children: capitalize(T) }, v);
15899
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
15900
+ const C = Object.keys(w)[0], T = C.replaceAll("_", " ");
15901
+ return /* @__PURE__ */ jsx(SelectItem, { value: C, children: capitalize(T) }, C);
15901
15902
  }) })
15902
15903
  ] }) }),
15903
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: y("Apply") }) })
15904
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: S, children: y("Apply") }) })
15904
15905
  ] })
15905
15906
  ] }),
15906
15907
  /* @__PURE__ */ jsx(Separator, {}),
@@ -15909,14 +15910,14 @@ const useStructureValidation = () => {
15909
15910
  /* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 text-gray-600" }),
15910
15911
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: y("Typography") })
15911
15912
  ] }),
15912
- (x == null ? void 0 : x.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(x.fontFamily).map(([A, v]) => /* @__PURE__ */ jsx(
15913
+ (x == null ? void 0 : x.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(x.fontFamily).map(([w, C]) => /* @__PURE__ */ jsx(
15913
15914
  FontSelector,
15914
15915
  {
15915
- label: A,
15916
- value: g.fontFamily[A.replace(/font-/g, "")] || v[Object.keys(v)[0]],
15917
- onChange: (T) => E(A, T)
15916
+ label: w,
15917
+ value: g.fontFamily[w.replace(/font-/g, "")] || C[Object.keys(C)[0]],
15918
+ onChange: (T) => E(w, T)
15918
15919
  },
15919
- A
15920
+ w
15920
15921
  )) }),
15921
15922
  /* @__PURE__ */ jsx(Separator, {}),
15922
15923
  (x == null ? void 0 : x.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
@@ -15942,7 +15943,7 @@ const useStructureValidation = () => {
15942
15943
  Switch,
15943
15944
  {
15944
15945
  checked: n,
15945
- onCheckedChange: (A) => o(A),
15946
+ onCheckedChange: (w) => o(w),
15946
15947
  "aria-label": y("Toggle dark mode"),
15947
15948
  className: "mx-1"
15948
15949
  }
@@ -15950,14 +15951,14 @@ const useStructureValidation = () => {
15950
15951
  /* @__PURE__ */ jsx(MoonIcon, { className: "h-4 w-4" })
15951
15952
  ] })
15952
15953
  ] }),
15953
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: x.colors.map((A) => w(A)) })
15954
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: x.colors.map((w) => A(w)) })
15954
15955
  ] }),
15955
15956
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: y("Loading...") }), children: l && h && /* @__PURE__ */ jsx(
15956
15957
  LazyCssImportModal,
15957
15958
  {
15958
15959
  open: l,
15959
15960
  onOpenChange: c,
15960
- onImport: C
15961
+ onImport: v
15961
15962
  }
15962
15963
  ) })
15963
15964
  ] }),
@@ -16700,36 +16701,36 @@ const UndoRedo = () => {
16700
16701
  useEffect(() => {
16701
16702
  i(n);
16702
16703
  }, [n]);
16703
- const S = () => {
16704
+ const k = () => {
16704
16705
  if (l.startsWith("@")) {
16705
16706
  m(y("Attribute keys cannot start with @"));
16706
16707
  return;
16707
16708
  }
16708
16709
  if (l) {
16709
- const w = [...a, { key: l, value: d }];
16710
- o(w), i(a), c(""), u(""), m("");
16710
+ const A = [...a, { key: l, value: d }];
16711
+ o(A), i(a), c(""), u(""), m("");
16711
16712
  }
16712
- }, k = (w) => {
16713
- const A = a.filter((v, T) => T !== w);
16714
- o(A), i(A);
16715
- }, C = (w) => {
16716
- h(w), c(a[w].key), u(a[w].value);
16713
+ }, S = (A) => {
16714
+ const w = a.filter((C, T) => T !== A);
16715
+ o(w), i(w);
16716
+ }, v = (A) => {
16717
+ h(A), c(a[A].key), u(a[A].value);
16717
16718
  }, E = () => {
16718
16719
  if (l.startsWith("@")) {
16719
16720
  m(y("Attribute keys cannot start with @"));
16720
16721
  return;
16721
16722
  }
16722
16723
  if (p !== null && l) {
16723
- const w = [...a];
16724
- w[p] = { key: l, value: d }, o(w), i(w), h(null), c(""), u(""), m("");
16724
+ const A = [...a];
16725
+ A[p] = { key: l, value: d }, o(A), i(A), h(null), c(""), u(""), m("");
16725
16726
  }
16726
- }, B = (w) => {
16727
- w.key === "Enter" && !w.shiftKey && (w.preventDefault(), p !== null ? E() : S());
16728
- }, I = useCallback((w) => {
16729
- const A = (N) => /[.,!?;:]/.test(N), v = (N, j, P) => {
16727
+ }, B = (A) => {
16728
+ A.key === "Enter" && !A.shiftKey && (A.preventDefault(), p !== null ? E() : k());
16729
+ }, I = useCallback((A) => {
16730
+ const w = (N) => /[.,!?;:]/.test(N), C = (N, j, P) => {
16730
16731
  let L = "", D = "";
16731
- const F = j > 0 ? N[j - 1] : "", H = j < N.length ? N[j] : "";
16732
- return j > 0 && (F === "." || !A(F) && F !== " ") && (L = " "), j < N.length && !A(H) && H !== " " && (D = " "), {
16732
+ const $ = j > 0 ? N[j - 1] : "", M = j < N.length ? N[j] : "";
16733
+ return j > 0 && ($ === "." || !w($) && $ !== " ") && (L = " "), j < N.length && !w(M) && M !== " " && (D = " "), {
16733
16734
  text: L + P + D,
16734
16735
  prefixLength: L.length,
16735
16736
  suffixLength: D.length
@@ -16738,20 +16739,20 @@ const UndoRedo = () => {
16738
16739
  if (T) {
16739
16740
  const N = T.selectionStart || 0, j = T.value || "", P = T.selectionEnd || N;
16740
16741
  if (P > N) {
16741
- const O = `{{${w}}}`, { text: R } = v(j, N, O), _ = j.slice(0, N) + R + j.slice(P);
16742
- u(_);
16742
+ const O = `{{${A}}}`, { text: H } = C(j, N, O), R = j.slice(0, N) + H + j.slice(P);
16743
+ u(R);
16743
16744
  return;
16744
16745
  }
16745
- const D = `{{${w}}}`, { text: F } = v(j, N, D), H = j.slice(0, N) + F + j.slice(N);
16746
- u(H);
16746
+ const D = `{{${A}}}`, { text: $ } = C(j, N, D), M = j.slice(0, N) + $ + j.slice(N);
16747
+ u(M);
16747
16748
  }
16748
16749
  }, []);
16749
16750
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
16750
16751
  /* @__PURE__ */ jsxs(
16751
16752
  "form",
16752
16753
  {
16753
- onSubmit: (w) => {
16754
- w.preventDefault(), p !== null ? E() : S();
16754
+ onSubmit: (A) => {
16755
+ A.preventDefault(), p !== null ? E() : k();
16755
16756
  },
16756
16757
  className: "space-y-3",
16757
16758
  children: [
@@ -16767,7 +16768,7 @@ const UndoRedo = () => {
16767
16768
  id: "attrKey",
16768
16769
  ref: g,
16769
16770
  value: l,
16770
- onChange: (w) => c(w.target.value),
16771
+ onChange: (A) => c(A.target.value),
16771
16772
  placeholder: y("Enter key"),
16772
16773
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
16773
16774
  }
@@ -16787,7 +16788,7 @@ const UndoRedo = () => {
16787
16788
  id: "attrValue",
16788
16789
  ref: b,
16789
16790
  value: d,
16790
- onChange: (w) => u(w.target.value),
16791
+ onChange: (A) => u(A.target.value),
16791
16792
  onKeyDown: B,
16792
16793
  placeholder: y("Enter value"),
16793
16794
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -16800,16 +16801,16 @@ const UndoRedo = () => {
16800
16801
  ]
16801
16802
  }
16802
16803
  ),
16803
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((w, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
16804
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((A, w) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
16804
16805
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
16805
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: w.key }),
16806
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: w.value.toString() })
16806
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: A.key }),
16807
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: A.value.toString() })
16807
16808
  ] }),
16808
16809
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
16809
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => C(A), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
16810
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => k(A), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
16810
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(w), children: /* @__PURE__ */ jsx(Pencil2Icon, { className: "h-3 w-3" }) }),
16811
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => S(w), children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-3 w-3" }) })
16811
16812
  ] })
16812
- ] }, A)) })
16813
+ ] }, w)) })
16813
16814
  ] });
16814
16815
  }), BlockAttributesEditor = React.memo(() => {
16815
16816
  const r = useSelectedBlock(), [n, o] = useState([]), [a] = useSelectedStylingBlocks(), i = useUpdateBlocksProps(), l = `${get(a, "0.prop")}_attrs`;
@@ -16951,336 +16952,7 @@ const PartialWrapper = ({ partialBlockId: r }) => {
16951
16952
  component: DefaultTopBar
16952
16953
  }, registerChaiTopBar = (r) => {
16953
16954
  TOP_BAR.component = r;
16954
- }, useTopBarComponent = () => useMemo(() => TOP_BAR.component, []), TokenUsageSection = ({ title: r, items: n, emptyLabel: o, onSelect: a, icon: i }) => /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
16955
- /* @__PURE__ */ jsx("p", { className: "text-[11px] font-semibold uppercase tracking-wide text-muted-foreground", children: r }),
16956
- n.length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: n.map((l) => /* @__PURE__ */ jsx(
16957
- "button",
16958
- {
16959
- type: "button",
16960
- onClick: () => a(l.id),
16961
- className: cn$2(
16962
- "group flex w-full items-center justify-between rounded-md border border-transparent bg-muted/40 px-3 py-1 text-left text-xs transition",
16963
- "hover:border-muted-foreground/20 hover:bg-muted/70 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-offset-1",
16964
- l.isSelected && "border-primary/40 bg-primary/10 text-primary"
16965
- ),
16966
- children: /* @__PURE__ */ jsxs("span", { className: "flex items-center space-x-2", children: [
16967
- i && i,
16968
- /* @__PURE__ */ jsx("span", { className: "truncate", children: l.label })
16969
- ] })
16970
- },
16971
- l.id
16972
- )) }) : /* @__PURE__ */ jsx("div", { className: "rounded border border-dashed border-muted px-3 py-1 text-xs text-muted-foreground", children: o })
16973
- ] }), STYLES_PREFIX = "#styles:", getBlockLabel = (r) => {
16974
- const o = [
16975
- typeof r._name == "string" ? r._name : void 0,
16976
- typeof r._type == "string" ? r._type : void 0
16977
- ].filter(Boolean).find((a) => a.trim().length > 0);
16978
- return o ? o.length > 40 ? `${o.slice(0, 37)}...` : o : r._id;
16979
- }, collectTokenUsageOnPage = (r, n) => {
16980
- const o = `${n}`;
16981
- return r.filter((a) => Object.values(a).some((i) => typeof i != "string" || !i.startsWith(STYLES_PREFIX) ? !1 : i.includes(o))).map((a) => ({
16982
- id: a._id,
16983
- label: getBlockLabel(a)
16984
- }));
16985
- }, TokenUsagePopover = ({ tokenId: r, tokenName: n }) => {
16986
- const { t: o } = useTranslation(), [a] = useBlocksStore(), [i, l] = useSelectedBlockIds(), c = useBuilderProp("pageId"), d = useBuilderProp("siteWideUsage"), u = useMemo(() => collectTokenUsageOnPage(a, r), [a, r]), p = useMemo(
16987
- () => u.map((C) => ({
16988
- id: C.id,
16989
- label: C.label,
16990
- isSelected: i.includes(C.id)
16991
- })),
16992
- [u, i]
16993
- ), h = useMemo(() => d ? Object.entries(d).reduce(
16994
- (C, [E, B]) => (E === c || !(B != null && B.designTokens) || !Object.keys(B.designTokens).some((w) => typeof w != "string" ? !1 : w === r) || C.push({ id: E, name: B.name || E, isPartial: !!B.isPartial }), C),
16995
- []
16996
- ) : [], [d, n, r, c]), f = useMemo(
16997
- () => h.filter((C) => !C.isPartial).map((C) => ({
16998
- id: C.id,
16999
- label: C.name
17000
- })),
17001
- [h]
17002
- ), m = useMemo(
17003
- () => h.filter((C) => C.isPartial).map((C) => ({
17004
- id: C.id,
17005
- label: C.name
17006
- })),
17007
- [h]
17008
- ), g = useCallback(
17009
- (C) => {
17010
- l([C]);
17011
- },
17012
- [l]
17013
- ), b = useBuilderProp("gotoPage", noop), { selectedLang: x, fallbackLang: y } = useLanguages(), { savePageAsync: S } = useSavePage(), k = async (C) => {
17014
- C && (await S(!0), b({ pageId: C, lang: x || y }));
17015
- };
17016
- return /* @__PURE__ */ jsxs(Popover, { children: [
17017
- /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "sm", className: "h-6 w-6 p-0", children: /* @__PURE__ */ jsx(EyeOpenIcon, { className: "h-3 w-3" }) }) }),
17018
- /* @__PURE__ */ jsxs(PopoverContent, { side: "bottom", align: "end", className: "w-80 p-0", children: [
17019
- /* @__PURE__ */ jsxs("div", { className: "space-y-1 px-4 py-3", children: [
17020
- /* @__PURE__ */ jsx("p", { className: "text-xs font-semibold", children: n }),
17021
- /* @__PURE__ */ jsx("p", { className: "text-[11px] text-muted-foreground", children: o("Usage summary for this design token across your site.") })
17022
- ] }),
17023
- /* @__PURE__ */ jsxs("div", { className: "no-scrollbar max-h-64 space-y-4 overflow-y-auto px-4 pb-4", children: [
17024
- /* @__PURE__ */ jsx(
17025
- TokenUsageSection,
17026
- {
17027
- title: o("Blocks affected on this page"),
17028
- items: p,
17029
- emptyLabel: o("None"),
17030
- onSelect: g,
17031
- icon: /* @__PURE__ */ jsx(ArrowRightIcon, { fontSize: 4 })
17032
- }
17033
- ),
17034
- /* @__PURE__ */ jsx(
17035
- TokenUsageSection,
17036
- {
17037
- title: o("Blocks affected on other pages"),
17038
- items: f,
17039
- emptyLabel: o("None"),
17040
- onSelect: k,
17041
- icon: /* @__PURE__ */ jsx(FileIcon, { fontSize: 8 })
17042
- }
17043
- ),
17044
- /* @__PURE__ */ jsx(
17045
- TokenUsageSection,
17046
- {
17047
- title: o("Blocks affected on partial blocks"),
17048
- items: m,
17049
- emptyLabel: o("None"),
17050
- onSelect: k,
17051
- icon: /* @__PURE__ */ jsx(GlobeIcon, { fontSize: 8 })
17052
- }
17053
- )
17054
- ] })
17055
- ] })
17056
- ] });
17057
- }, ManageDesignTokens = ({}) => {
17058
- const { t: r } = useTranslation(), [n, o] = useAtom$1(chaiDesignTokensAtom), [a, i] = useState(!1), [l, c] = useState(null), [d, u] = useState(!1), [p, h] = useState(!1), [f, m] = useState(""), [g, b] = useState(""), [x, y] = useState(""), [S, k] = useState(""), [C, E] = useState(""), [B, I] = useState(""), w = useIncrementActionsCount(), A = (R) => {
17059
- const _ = R.trim();
17060
- return _.length === 0 || _.length > 25 ? !1 : /^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test(_);
17061
- }, v = (R, _ = !1, M) => {
17062
- const $ = R.trim();
17063
- return $.length === 0 ? "" : $.length > 25 ? r("Token name must be 25 characters or less") : /^[a-zA-Z0-9]+(-[a-zA-Z0-9]+)*$/.test($) ? Object.entries(n).find(
17064
- ([V, z]) => z.name === $ && (!_ || V !== M)
17065
- ) ? r("Token name already exists") : "" : r("Only alphanumeric characters and hyphens allowed");
17066
- }, T = () => {
17067
- if (!f.trim() || !g.trim()) {
17068
- toast.error(r("Please fill in both token name and classes"));
17069
- return;
17070
- }
17071
- if (!A(f)) {
17072
- toast.error(r("Invalid design token name format"));
17073
- return;
17074
- }
17075
- if (Object.values(n).find(($) => $.name === f.trim())) {
17076
- toast.error(r("Token already exists"));
17077
- return;
17078
- }
17079
- const _ = `${DESIGN_TOKEN_PREFIX}${nanoid(12)}`, M = {
17080
- ...n,
17081
- [_]: {
17082
- name: f.trim(),
17083
- value: g.trim()
17084
- }
17085
- };
17086
- o(M), m(""), b(""), i(!1), u(!1), w(), toast.success(r("Token added successfully"));
17087
- }, N = () => {
17088
- if (!x.trim() || !S.trim()) {
17089
- toast.error(r("Please fill in both token name and classes"));
17090
- return;
17091
- }
17092
- if (!A(x)) {
17093
- toast.error(r("Invalid design token name format"));
17094
- return;
17095
- }
17096
- if (Object.entries(n).find(
17097
- ([M, $]) => $.name === x.trim() && M !== l
17098
- )) {
17099
- toast.error(r("Token already exists"));
17100
- return;
17101
- }
17102
- if (!l)
17103
- return;
17104
- const _ = {
17105
- ...n,
17106
- [l]: {
17107
- name: x.trim(),
17108
- value: S.trim()
17109
- }
17110
- };
17111
- o(_), c(null), y(""), k(""), h(!1), w(), toast.success(r("Token updated successfully"));
17112
- }, j = (R) => {
17113
- const _ = { ...n };
17114
- delete _[R], o(_), w(), toast.success(r("Token deleted successfully"));
17115
- }, P = (R) => {
17116
- const _ = n[R];
17117
- _ && (c(R), y(_.name), k(_.value), i(!1), h(!0));
17118
- }, L = () => {
17119
- i(!0), c(null), m(""), b(""), E(""), u(!0);
17120
- }, D = () => {
17121
- c(null), y(""), k(""), I(""), h(!1);
17122
- }, F = () => {
17123
- i(!1), m(""), b(""), E(""), u(!1);
17124
- }, H = (R) => {
17125
- const _ = R.replace(/\s+/g, "-");
17126
- m(_), E(v(_));
17127
- }, O = (R) => {
17128
- const _ = R.replace(/\s+/g, "-");
17129
- y(_), I(v(_, !0, l || void 0));
17130
- };
17131
- return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col", children: [
17132
- /* @__PURE__ */ jsx("div", { className: "", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between", children: /* @__PURE__ */ jsxs(
17133
- Button,
17134
- {
17135
- variant: "outline",
17136
- onClick: L,
17137
- disabled: a || l !== null,
17138
- size: "sm",
17139
- className: "h-7 text-xs",
17140
- children: [
17141
- /* @__PURE__ */ jsx(PlusIcon, { className: "mr-1 h-3 w-3" }),
17142
- r("Add")
17143
- ]
17144
- }
17145
- ) }) }),
17146
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar flex flex-1 flex-col overflow-hidden pt-2", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full flex-1", children: /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(n).length === 0 ? /* @__PURE__ */ jsxs("div", { className: "py-6 text-center text-muted-foreground", children: [
17147
- /* @__PURE__ */ jsx("div", { className: "mb-1 text-2xl", children: "🎨" }),
17148
- /* @__PURE__ */ jsx("p", { className: "text-xs", children: r("No design tokens defined") })
17149
- ] }) : Object.entries(n).map(([R, _]) => /* @__PURE__ */ jsxs(
17150
- "div",
17151
- {
17152
- className: `group flex items-center justify-between hover:bg-muted/90 ${l === R ? "bg-primary/10" : ""}`,
17153
- children: [
17154
- /* @__PURE__ */ jsx("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsx("span", { className: "flex items-center break-all pl-1 text-xs font-semibold", children: _.name }) }),
17155
- /* @__PURE__ */ jsxs("div", { className: "flex flex-shrink-0 items-center opacity-0 group-hover:opacity-100", children: [
17156
- /* @__PURE__ */ jsx(TokenUsagePopover, { tokenId: R, tokenName: _.name }),
17157
- /* @__PURE__ */ jsx(
17158
- Button,
17159
- {
17160
- variant: "ghost",
17161
- size: "sm",
17162
- onClick: () => P(R),
17163
- disabled: a || l !== null,
17164
- className: "h-6 w-6 p-0",
17165
- children: /* @__PURE__ */ jsx(Pencil1Icon, { className: "h-3 w-3" })
17166
- }
17167
- ),
17168
- /* @__PURE__ */ jsxs(AlertDialog, { children: [
17169
- /* @__PURE__ */ jsx(AlertDialogTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
17170
- Button,
17171
- {
17172
- variant: "ghost",
17173
- size: "sm",
17174
- disabled: a || l !== null,
17175
- className: "h-6 w-6 p-0",
17176
- children: /* @__PURE__ */ jsx(TrashIcon, { className: "h-3 w-3 text-destructive" })
17177
- }
17178
- ) }),
17179
- /* @__PURE__ */ jsxs(AlertDialogContent, { className: "max-w-md", children: [
17180
- /* @__PURE__ */ jsxs(AlertDialogHeader, { children: [
17181
- /* @__PURE__ */ jsx(AlertDialogTitle, { className: "text-base", children: r("Delete Token") }),
17182
- /* @__PURE__ */ jsxs(AlertDialogDescription, { className: "text-sm", children: [
17183
- r("Delete this token?"),
17184
- /* @__PURE__ */ jsx("br", {}),
17185
- /* @__PURE__ */ jsx("code", { className: "mt-1 inline-block rounded bg-muted px-1 py-0.5 font-mono text-xs", children: _.name })
17186
- ] })
17187
- ] }),
17188
- /* @__PURE__ */ jsxs(AlertDialogFooter, { children: [
17189
- /* @__PURE__ */ jsx(AlertDialogCancel, { className: "h-7 text-xs", children: r("Cancel") }),
17190
- /* @__PURE__ */ jsx(
17191
- AlertDialogAction,
17192
- {
17193
- onClick: () => j(R),
17194
- className: "h-7 bg-destructive text-xs text-destructive-foreground hover:bg-destructive/90",
17195
- children: r("Delete")
17196
- }
17197
- )
17198
- ] })
17199
- ] })
17200
- ] })
17201
- ] })
17202
- ]
17203
- },
17204
- R
17205
- )) }) }) }),
17206
- /* @__PURE__ */ jsx(Dialog, { open: d, onOpenChange: F, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-md", children: [
17207
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
17208
- /* @__PURE__ */ jsx(DialogTitle, { className: "text-base", children: r("Add Design Token") }),
17209
- /* @__PURE__ */ jsx(DialogDescription, { className: "text-sm", children: r("Create a new reusable design token with Tailwind classes.") })
17210
- ] }),
17211
- /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
17212
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
17213
- /* @__PURE__ */ jsx(Label, { htmlFor: "new-selector", className: "text-sm", children: r("Token Name") }),
17214
- /* @__PURE__ */ jsx(
17215
- Input$1,
17216
- {
17217
- id: "new-selector",
17218
- placeholder: "Button-Primary",
17219
- value: f,
17220
- onChange: (R) => H(R.target.value),
17221
- className: "text-sm"
17222
- }
17223
- ),
17224
- C ? /* @__PURE__ */ jsx("span", { className: "text-sm text-destructive", children: C }) : /* @__PURE__ */ jsx("span", { className: "text-sm text-muted-foreground", children: r("Button-Primary, Card-Header, Text-Large") })
17225
- ] }),
17226
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
17227
- /* @__PURE__ */ jsx(Label, { htmlFor: "new-classes", className: "text-sm", children: r("Tailwind Classes") }),
17228
- /* @__PURE__ */ jsx(
17229
- Textarea,
17230
- {
17231
- id: "new-classes",
17232
- placeholder: "bg-blue-500 text-white px-4 py-2",
17233
- value: g,
17234
- onChange: (R) => b(R.target.value),
17235
- className: "min-h-[80px] resize-none font-mono text-xs"
17236
- }
17237
- )
17238
- ] })
17239
- ] }),
17240
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
17241
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: F, className: "h-8 text-sm", children: r("Cancel") }),
17242
- /* @__PURE__ */ jsx(Button, { onClick: T, className: "h-8 text-sm", children: r("Add Token") })
17243
- ] })
17244
- ] }) }),
17245
- /* @__PURE__ */ jsx(Dialog, { open: p, onOpenChange: D, children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-w-md", children: [
17246
- /* @__PURE__ */ jsxs(DialogHeader, { children: [
17247
- /* @__PURE__ */ jsx(DialogTitle, { className: "text-base", children: r("Edit Design Token") }),
17248
- /* @__PURE__ */ jsx(DialogDescription, { className: "text-sm", children: r("Update the design token name and classes.") })
17249
- ] }),
17250
- /* @__PURE__ */ jsxs("div", { className: "space-y-4", children: [
17251
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
17252
- /* @__PURE__ */ jsx(Label, { htmlFor: "edit-selector", className: "text-sm", children: r("Token Name") }),
17253
- /* @__PURE__ */ jsx(
17254
- Input$1,
17255
- {
17256
- id: "edit-selector",
17257
- value: x,
17258
- onChange: (R) => O(R.target.value),
17259
- className: "text-sm"
17260
- }
17261
- ),
17262
- B && /* @__PURE__ */ jsx("span", { className: "text-sm text-destructive", children: B })
17263
- ] }),
17264
- /* @__PURE__ */ jsxs("div", { className: "space-y-2", children: [
17265
- /* @__PURE__ */ jsx(Label, { htmlFor: "edit-classes", className: "text-sm", children: r("Classes") }),
17266
- /* @__PURE__ */ jsx(
17267
- Textarea,
17268
- {
17269
- id: "edit-classes",
17270
- value: S,
17271
- onChange: (R) => k(R.target.value),
17272
- className: "min-h-[80px] resize-none font-mono text-xs"
17273
- }
17274
- )
17275
- ] })
17276
- ] }),
17277
- /* @__PURE__ */ jsxs(DialogFooter, { children: [
17278
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: D, className: "h-8 text-sm", children: r("Cancel") }),
17279
- /* @__PURE__ */ jsx(Button, { onClick: N, className: "h-8 text-sm", children: r("Update Token") })
17280
- ] })
17281
- ] }) })
17282
- ] });
17283
- }, DEFAULT_PANEL_WIDTH = 280, OutlineButton = ({ isActive: r, show: n }) => /* @__PURE__ */ jsx(Button, { variant: r ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(StackIcon, { className: "h-5 w-5" }) }), AddBlocksButton = ({ isActive: r, show: n }) => useIsDragAndDropEnabled() && /* @__PURE__ */ jsx(Button, { variant: r ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(PlusCircledIcon, { className: "h-5 w-5" }) }), AskAiButton = ({ isActive: r, show: n }) => /* @__PURE__ */ jsx(Button, { variant: r ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(AiIcon, {}) });
16955
+ }, useTopBarComponent = () => useMemo(() => TOP_BAR.component, []), ManageDesignTokens = React__default.lazy(() => import("./manage-design-tokens-DUoMdCBl.js")), DEFAULT_PANEL_WIDTH = 280, OutlineButton = ({ isActive: r, show: n }) => /* @__PURE__ */ jsx(Button, { variant: r ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(StackIcon, { className: "h-5 w-5" }) }), AddBlocksButton = ({ isActive: r, show: n }) => useIsDragAndDropEnabled() && /* @__PURE__ */ jsx(Button, { variant: r ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(PlusCircledIcon, { className: "h-5 w-5" }) }), AskAiButton = ({ isActive: r, show: n }) => /* @__PURE__ */ jsx(Button, { variant: r ? "default" : "ghost", size: "icon", onClick: n, children: /* @__PURE__ */ jsx(AiIcon, {}) });
17284
16956
  registerChaiSidebarPanel("add-block", {
17285
16957
  button: AddBlocksButton,
17286
16958
  label: "Add Blocks",
@@ -17306,25 +16978,25 @@ registerChaiSidebarPanel("outline", {
17306
16978
  panel: () => /* @__PURE__ */ jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsx(ListTree, {}) })
17307
16979
  });
17308
16980
  const RootLayout = () => {
17309
- const r = useTopBarComponent(), [n, o] = useSidebarActivePanel(), a = useRef("outline"), [i, l] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), [, u] = useActiveSettingsTab(), p = useChaiSidebarPanels("top"), h = useChaiSidebarPanels("bottom"), f = reverse([...h ?? []]), m = useCallback((A) => {
17310
- A.preventDefault();
16981
+ const r = useTopBarComponent(), [n, o] = useSidebarActivePanel(), a = useRef("outline"), [i, l] = useState(DEFAULT_PANEL_WIDTH), [c, d] = useRightPanel(), [, u] = useActiveSettingsTab(), p = useChaiSidebarPanels("top"), h = useChaiSidebarPanels("bottom"), f = reverse([...h ?? []]), m = useCallback((w) => {
16982
+ w.preventDefault();
17311
16983
  }, []), g = useMemo(() => [p].flat(), [p]), b = useCallback(
17312
- (A) => {
17313
- console.log("handleMenuItemClick", A, n), o(n === A ? null : A);
16984
+ (w) => {
16985
+ console.log("handleMenuItemClick", w, n), o(n === w ? null : w);
17314
16986
  },
17315
16987
  [n, o]
17316
- ), { t: x } = useTranslation(), y = useMemo(() => [...p, ...h], [p, h]), S = useBuilderProp("htmlDir", "ltr"), k = find(y, { id: n }) ?? first$1(y), C = get(k, "width", DEFAULT_PANEL_WIDTH);
16988
+ ), { t: x } = useTranslation(), y = useMemo(() => [...p, ...h], [p, h]), k = useBuilderProp("htmlDir", "ltr"), S = find(y, { id: n }) ?? first$1(y), v = get(S, "width", DEFAULT_PANEL_WIDTH);
17317
16989
  useEffect(() => {
17318
16990
  if (n !== null) {
17319
- const A = find(y, { id: n });
17320
- A && get(A, "view", "standard") === "standard" && (a.current = n, l(get(A, "width", DEFAULT_PANEL_WIDTH)));
16991
+ const w = find(y, { id: n });
16992
+ w && get(w, "view", "standard") === "standard" && (a.current = n, l(get(w, "width", DEFAULT_PANEL_WIDTH)));
17321
16993
  }
17322
16994
  }, [n, y]);
17323
16995
  const E = useMemo(() => {
17324
16996
  if (n === null) return 0;
17325
- const A = find(y, { id: n });
17326
- return get(A, "view", "standard") === "standard" ? C : i;
17327
- }, [n, C, i, y]), B = useCallback(() => {
16997
+ const w = find(y, { id: n });
16998
+ return get(w, "view", "standard") === "standard" ? v : i;
16999
+ }, [n, v, i, y]), B = useCallback(() => {
17328
17000
  o(a.current);
17329
17001
  }, [o, n]), I = useCallback(() => {
17330
17002
  o("outline");
@@ -17332,13 +17004,13 @@ const RootLayout = () => {
17332
17004
  useEffect(() => {
17333
17005
  n !== null && !find(y, { id: n }) && o("outline");
17334
17006
  }, [n, y]);
17335
- const w = useCallback(
17336
- (A) => {
17337
- b(A);
17007
+ const A = useCallback(
17008
+ (w) => {
17009
+ b(w);
17338
17010
  },
17339
17011
  [b]
17340
17012
  );
17341
- return /* @__PURE__ */ jsx("div", { dir: S, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
17013
+ 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: [
17342
17014
  /* @__PURE__ */ jsxs(
17343
17015
  "div",
17344
17016
  {
@@ -17348,25 +17020,25 @@ const RootLayout = () => {
17348
17020
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(r, {}) }) }),
17349
17021
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
17350
17022
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
17351
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: g.map((A, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
17352
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(A, "button", NoopComponent), {
17023
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: g.map((w, C) => /* @__PURE__ */ jsxs(Tooltip, { children: [
17024
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
17353
17025
  position: "top",
17354
- panelId: A.id,
17355
- isActive: n === A.id,
17356
- show: () => w(A.id)
17026
+ panelId: w.id,
17027
+ isActive: n === w.id,
17028
+ show: () => A(w.id)
17357
17029
  }) }),
17358
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(A.label) }) })
17359
- ] }, "button-top-" + v)) }),
17030
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
17031
+ ] }, "button-top-" + C)) }),
17360
17032
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
17361
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f == null ? void 0 : f.map((A, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
17362
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(A, "button", NoopComponent), {
17033
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f == null ? void 0 : f.map((w, C) => /* @__PURE__ */ jsxs(Tooltip, { children: [
17034
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(w, "button", NoopComponent), {
17363
17035
  position: "bottom",
17364
- panelId: A.id,
17365
- isActive: n === A.id,
17366
- show: () => w(A.id)
17036
+ panelId: w.id,
17037
+ isActive: n === w.id,
17038
+ show: () => A(w.id)
17367
17039
  }) }),
17368
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(A.label) }) })
17369
- ] }, "button-bottom-" + v)) })
17040
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(w.label) }) })
17041
+ ] }, "button-bottom-" + C)) })
17370
17042
  ] }),
17371
17043
  /* @__PURE__ */ jsx(
17372
17044
  motion.div,
@@ -17376,15 +17048,15 @@ const RootLayout = () => {
17376
17048
  initial: { width: E },
17377
17049
  animate: { width: E },
17378
17050
  transition: { duration: 0.3, ease: "easeInOut" },
17379
- children: n !== null && get(k, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
17051
+ children: n !== null && get(S, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
17380
17052
  /* @__PURE__ */ jsx(
17381
17053
  "div",
17382
17054
  {
17383
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(k, "isInternal", !1) ? "" : "w-64"}`,
17384
- children: /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
17055
+ className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(S, "isInternal", !1) ? "" : "w-64"}`,
17056
+ children: /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
17385
17057
  }
17386
17058
  ),
17387
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(k, "panel", NoopComponent), {}) }) })
17059
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar h-full max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(S, "panel", NoopComponent), {}) }) })
17388
17060
  ] })
17389
17061
  }
17390
17062
  ),
@@ -17438,7 +17110,7 @@ const RootLayout = () => {
17438
17110
  }
17439
17111
  )
17440
17112
  ] }) : null }) }) }),
17441
- /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: c === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : c === "design-tokens" ? /* @__PURE__ */ jsx(ManageDesignTokens, {}) : c === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
17113
+ /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: c === "ai" ? /* @__PURE__ */ jsx(AskAI, {}) : c === "design-tokens" ? /* @__PURE__ */ jsx(React__default.Suspense, { fallback: /* @__PURE__ */ jsx("div", { className: "h-1/2 w-full animate-pulse" }), children: /* @__PURE__ */ jsx(ManageDesignTokens, {}) }) : c === "theme" ? /* @__PURE__ */ jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsx(SettingsPanel, {}) }) })
17442
17114
  ] }) })
17443
17115
  }
17444
17116
  )
@@ -17447,34 +17119,34 @@ const RootLayout = () => {
17447
17119
  }
17448
17120
  ),
17449
17121
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
17450
- n !== null && get(k, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(
17122
+ n !== null && get(S, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(
17451
17123
  SheetContent,
17452
17124
  {
17453
17125
  side: "left",
17454
17126
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
17455
- style: { width: `${C}px` },
17127
+ style: { width: `${v}px` },
17456
17128
  children: [
17457
17129
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
17458
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(k, "icon", null) }),
17459
- /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
17130
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
17131
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
17460
17132
  ] }) }),
17461
- /* @__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(k, "panel", NoopComponent), {
17133
+ /* @__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(S, "panel", NoopComponent), {
17462
17134
  close: I
17463
17135
  }) }) })
17464
17136
  ]
17465
17137
  }
17466
17138
  ) }),
17467
17139
  " ",
17468
- n !== null && get(k, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${C}px` }, children: [
17140
+ n !== null && get(S, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => B(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${v}px` }, children: [
17469
17141
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
17470
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(k, "icon", null) }),
17471
- /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
17142
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(S, "icon", null) }),
17143
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
17472
17144
  ] }) }),
17473
- /* @__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(k, "panel", NoopComponent), {
17145
+ /* @__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(S, "panel", NoopComponent), {
17474
17146
  close: I
17475
17147
  }) }) })
17476
17148
  ] }) }),
17477
- n !== null && get(k, "view") === "overlay" && /* @__PURE__ */ jsx(
17149
+ n !== null && get(S, "view") === "overlay" && /* @__PURE__ */ jsx(
17478
17150
  motion.div,
17479
17151
  {
17480
17152
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -17493,12 +17165,12 @@ const RootLayout = () => {
17493
17165
  children: [
17494
17166
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
17495
17167
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
17496
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(k, "icon", null) }),
17497
- /* @__PURE__ */ jsx("span", { children: x(get(k, "label", "")) })
17168
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(S, "icon", null) }),
17169
+ /* @__PURE__ */ jsx("span", { children: x(get(S, "label", "")) })
17498
17170
  ] }),
17499
17171
  /* @__PURE__ */ jsx(Button, { onClick: () => B(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(Cross1Icon, { className: "h-5 w-5" }) })
17500
17172
  ] }),
17501
- /* @__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(k, "panel", NoopComponent), {
17173
+ /* @__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(S, "panel", NoopComponent), {
17502
17174
  close: I
17503
17175
  }) }) })
17504
17176
  ]
@@ -17559,8 +17231,8 @@ const RootLayout = () => {
17559
17231
  const b = i.toLowerCase();
17560
17232
  return Object.fromEntries(
17561
17233
  Object.entries(a).filter(([x, y]) => {
17562
- var S;
17563
- return (x == null ? void 0 : x.toLowerCase().includes(b)) || ((S = y == null ? void 0 : y.description) == null ? void 0 : S.toLowerCase().includes(b));
17234
+ var k;
17235
+ return (x == null ? void 0 : x.toLowerCase().includes(b)) || ((k = y == null ? void 0 : y.description) == null ? void 0 : k.toLowerCase().includes(b));
17564
17236
  })
17565
17237
  );
17566
17238
  }, [a, i]), f = (b) => {
@@ -17570,8 +17242,8 @@ const RootLayout = () => {
17570
17242
  });
17571
17243
  }, m = (b) => {
17572
17244
  if (!c) return;
17573
- const x = b.clientX - u.x, y = b.clientY - u.y, S = b.currentTarget, k = S.offsetWidth, C = S.offsetHeight, E = window.innerWidth - k, B = window.innerHeight - C, I = Math.max(0, Math.min(x, E)), w = Math.max(0, Math.min(y, B));
17574
- o(I, w);
17245
+ const x = b.clientX - u.x, y = b.clientY - u.y, k = b.currentTarget, S = k.offsetWidth, v = k.offsetHeight, E = window.innerWidth - S, B = window.innerHeight - v, I = Math.max(0, Math.min(x, E)), A = Math.max(0, Math.min(y, B));
17246
+ o(I, A);
17575
17247
  }, g = () => {
17576
17248
  d(!1);
17577
17249
  };
@@ -17816,46 +17488,46 @@ const atomRead = (r, n, ...o) => n.read(...o), atomWrite = (r, n, ...o) => n.wri
17816
17488
  var o;
17817
17489
  const a = getBuildingBlocks(r), i = a[1], l = a[2], c = a[3], d = a[6], u = a[7], p = a[11], h = a[12], f = a[13], m = a[14], g = a[16], b = a[17], x = p(r, n);
17818
17490
  if (isAtomStateInitialized(x) && (i.has(n) && l.get(n) !== x.n || Array.from(x.d).every(
17819
- ([w, A]) => (
17491
+ ([A, w]) => (
17820
17492
  // Recursively, read the atom state of the dependency, and
17821
17493
  // check if the atom epoch number is unchanged
17822
- m(r, w).n === A
17494
+ m(r, A).n === w
17823
17495
  )
17824
17496
  )))
17825
17497
  return x;
17826
17498
  x.d.clear();
17827
17499
  let y = !0;
17828
- function S() {
17500
+ function k() {
17829
17501
  i.has(n) && (b(r, n), f(r), h(r));
17830
17502
  }
17831
- function k(w) {
17832
- var A;
17833
- if (isSelfAtom(n, w)) {
17834
- const T = p(r, w);
17503
+ function S(A) {
17504
+ var w;
17505
+ if (isSelfAtom(n, A)) {
17506
+ const T = p(r, A);
17835
17507
  if (!isAtomStateInitialized(T))
17836
- if (hasInitialValue(w))
17837
- setAtomStateValueOrPromise(r, w, w.init);
17508
+ if (hasInitialValue(A))
17509
+ setAtomStateValueOrPromise(r, A, A.init);
17838
17510
  else
17839
17511
  throw new Error("no atom init");
17840
17512
  return returnAtomValue(T);
17841
17513
  }
17842
- const v = m(r, w);
17514
+ const C = m(r, A);
17843
17515
  try {
17844
- return returnAtomValue(v);
17516
+ return returnAtomValue(C);
17845
17517
  } finally {
17846
- x.d.set(w, v.n), isPendingPromise(x.v) && addPendingPromiseToDependency(n, x.v, v), (A = i.get(w)) == null || A.t.add(n), y || S();
17518
+ x.d.set(A, C.n), isPendingPromise(x.v) && addPendingPromiseToDependency(n, x.v, C), (w = i.get(A)) == null || w.t.add(n), y || k();
17847
17519
  }
17848
17520
  }
17849
- let C, E;
17521
+ let v, E;
17850
17522
  const B = {
17851
17523
  get signal() {
17852
- return C || (C = new AbortController()), C.signal;
17524
+ return v || (v = new AbortController()), v.signal;
17853
17525
  },
17854
17526
  get setSelf() {
17855
- return !E && isActuallyWritableAtom(n) && (E = (...w) => {
17527
+ return !E && isActuallyWritableAtom(n) && (E = (...A) => {
17856
17528
  if (!y)
17857
17529
  try {
17858
- return g(r, n, ...w);
17530
+ return g(r, n, ...A);
17859
17531
  } finally {
17860
17532
  f(r), h(r);
17861
17533
  }
@@ -17863,10 +17535,10 @@ const atomRead = (r, n, ...o) => n.read(...o), atomWrite = (r, n, ...o) => n.wri
17863
17535
  }
17864
17536
  }, I = x.n;
17865
17537
  try {
17866
- const w = u(r, n, k, B);
17867
- return setAtomStateValueOrPromise(r, n, w), isPromiseLike$1(w) && (registerAbortHandler(w, () => C == null ? void 0 : C.abort()), w.then(S, S)), x;
17868
- } catch (w) {
17869
- return delete x.v, x.e = w, ++x.n, x;
17538
+ const A = u(r, n, S, B);
17539
+ return setAtomStateValueOrPromise(r, n, A), isPromiseLike$1(A) && (registerAbortHandler(A, () => v == null ? void 0 : v.abort()), A.then(k, k)), x;
17540
+ } catch (A) {
17541
+ return delete x.v, x.e = A, ++x.n, x;
17870
17542
  } finally {
17871
17543
  y = !1, I !== x.n && l.get(n) === I && (l.set(n, x.n), c.add(n), (o = d.c) == null || o.call(d, n));
17872
17544
  }
@@ -17882,18 +17554,18 @@ const atomRead = (r, n, ...o) => n.read(...o), atomWrite = (r, n, ...o) => n.wri
17882
17554
  }, writeAtomState = (r, n, ...o) => {
17883
17555
  const a = getBuildingBlocks(r), i = a[3], l = a[6], c = a[8], d = a[11], u = a[12], p = a[13], h = a[14], f = a[15], m = a[17];
17884
17556
  let g = !0;
17885
- const b = (y) => returnAtomValue(h(r, y)), x = (y, ...S) => {
17886
- var k;
17887
- const C = d(r, y);
17557
+ const b = (y) => returnAtomValue(h(r, y)), x = (y, ...k) => {
17558
+ var S;
17559
+ const v = d(r, y);
17888
17560
  try {
17889
17561
  if (isSelfAtom(n, y)) {
17890
17562
  if (!hasInitialValue(y))
17891
17563
  throw new Error("atom not writable");
17892
- const E = C.n, B = S[0];
17893
- setAtomStateValueOrPromise(r, y, B), m(r, y), E !== C.n && (i.add(y), (k = l.c) == null || k.call(l, y), f(r, y));
17564
+ const E = v.n, B = k[0];
17565
+ setAtomStateValueOrPromise(r, y, B), m(r, y), E !== v.n && (i.add(y), (S = l.c) == null || S.call(l, y), f(r, y));
17894
17566
  return;
17895
17567
  } else
17896
- return writeAtomState(r, y, ...S);
17568
+ return writeAtomState(r, y, ...k);
17897
17569
  } finally {
17898
17570
  g || (p(r), u(r));
17899
17571
  }
@@ -17934,19 +17606,19 @@ const atomRead = (r, n, ...o) => n.read(...o), atomWrite = (r, n, ...o) => n.wri
17934
17606
  }, i.set(n, b), (o = c.m) == null || o.call(c, n), isActuallyWritableAtom(n)) {
17935
17607
  const x = () => {
17936
17608
  let y = !0;
17937
- const S = (...k) => {
17609
+ const k = (...S) => {
17938
17610
  try {
17939
- return m(r, n, ...k);
17611
+ return m(r, n, ...S);
17940
17612
  } finally {
17941
17613
  y || (h(r), p(r));
17942
17614
  }
17943
17615
  };
17944
17616
  try {
17945
- const k = d(r, n, S);
17946
- k && (b.u = () => {
17617
+ const S = d(r, n, k);
17618
+ S && (b.u = () => {
17947
17619
  y = !0;
17948
17620
  try {
17949
- k();
17621
+ S();
17950
17622
  } finally {
17951
17623
  y = !1;
17952
17624
  }
@@ -18299,10 +17971,10 @@ function domToJsx(r, n = 0) {
18299
17971
  } else if (m.name === "style" && m.value) {
18300
17972
  const g = m.value.split(";").reduce(
18301
17973
  (b, x) => {
18302
- const [y, S] = x.split(":").map((k) => k.trim());
18303
- if (y && S) {
18304
- const k = y.replace(/-([a-z])/g, (C) => C[1].toUpperCase());
18305
- b[k] = S.replace(/['"]/g, "");
17974
+ const [y, k] = x.split(":").map((S) => S.trim());
17975
+ if (y && k) {
17976
+ const S = y.replace(/-([a-z])/g, (v) => v[1].toUpperCase());
17977
+ b[S] = k.replace(/['"]/g, "");
18306
17978
  }
18307
17979
  return b;
18308
17980
  },
@@ -18328,7 +18000,7 @@ function domToJsx(r, n = 0) {
18328
18000
  (m, g) => {
18329
18001
  const [b, x] = g.split(":").map((y) => y.trim());
18330
18002
  if (b && x) {
18331
- const y = b.replace(/-([a-z])/g, (S) => S[1].toUpperCase());
18003
+ const y = b.replace(/-([a-z])/g, (k) => k[1].toUpperCase());
18332
18004
  m[y] = x.replace(/['"]/g, "");
18333
18005
  }
18334
18006
  return m;
@@ -18401,7 +18073,7 @@ ${i}${i}${l == null ? void 0 : l.trimEnd()}
18401
18073
  ${i})
18402
18074
  }`, { jsx: l, html: formatHtml(c), componentName: a };
18403
18075
  }, ExportCodeModalContent = ({ tab: r }) => {
18404
- var S;
18076
+ var k;
18405
18077
  const { t: n } = useTranslation(), [o, a] = useState({ html: "", jsx: "" }), i = useSelectedBlock(), l = useBlocksHtmlForAi(), [c, d] = useState(""), [u, p] = useState(!1), h = () => {
18406
18078
  switch (r) {
18407
18079
  case "js":
@@ -18426,52 +18098,52 @@ ${i})
18426
18098
  }, m = useCallback(async () => {
18427
18099
  try {
18428
18100
  p(!1);
18429
- let k = l({ blockId: i == null ? void 0 : i._id, additionalCoreBlocks: ["Icon"] });
18430
- k = k.replace(/\s*bid=["'][^"']*["']/g, "");
18431
- const C = r === "ts", {
18101
+ let S = l({ blockId: i == null ? void 0 : i._id, additionalCoreBlocks: ["Icon"] });
18102
+ S = S.replace(/\s*bid=["'][^"']*["']/g, "");
18103
+ const v = r === "ts", {
18432
18104
  jsx: E,
18433
18105
  html: B,
18434
18106
  componentName: I
18435
18107
  } = await getExportedCoded({
18436
18108
  selectedBlock: i,
18437
- html: k,
18438
- isTypeScript: C
18109
+ html: S,
18110
+ isTypeScript: v
18439
18111
  });
18440
18112
  a({ html: B, jsx: E }), d(I), p(!0);
18441
18113
  } catch {
18442
- const C = "<div>Export failed. Close the modal and try again.</div>";
18443
- a({ html: C, jsx: C }), toast.error(n("Failed to generate export HTML"));
18114
+ const v = "<div>Export failed. Close the modal and try again.</div>";
18115
+ a({ html: v, jsx: v }), toast.error(n("Failed to generate export HTML"));
18444
18116
  }
18445
18117
  }, [n, r, i, l]);
18446
18118
  useEffect(() => {
18447
18119
  m();
18448
18120
  }, [m, r]);
18449
18121
  const g = useCallback(
18450
- async (k) => {
18122
+ async (S) => {
18451
18123
  try {
18452
- navigator.clipboard.writeText(k), toast.success(n("Export code copied!"));
18124
+ navigator.clipboard.writeText(S), toast.success(n("Export code copied!"));
18453
18125
  } catch {
18454
18126
  toast.error(n("Failed to copy export code"));
18455
18127
  }
18456
18128
  },
18457
18129
  [n]
18458
- ), b = (k) => {
18459
- const C = new Blob([k], { type: "text/jsx" }), E = URL.createObjectURL(C), B = document.createElement("a");
18130
+ ), b = (S) => {
18131
+ const v = new Blob([S], { type: "text/jsx" }), E = URL.createObjectURL(v), B = document.createElement("a");
18460
18132
  B.href = E, B.download = h(), document.body.appendChild(B), B.click(), URL.revokeObjectURL(E), document.body.removeChild(B), toast.success(n("Export code downloaded successfully!"));
18461
18133
  }, x = /* @__PURE__ */ jsxs("span", { children: [
18462
18134
  "Download ",
18463
18135
  /* @__PURE__ */ jsx("span", { className: "font-mono text-xs font-light text-gray-300", children: h() })
18464
18136
  ] }), y = useMemo(() => {
18465
- const k = { extend: shadcnTheme() }, C = JSON.stringify(k, null, 2);
18137
+ const S = { extend: shadcnTheme() }, v = JSON.stringify(S, null, 2);
18466
18138
  return `{
18467
18139
  // Your tailwind config ...
18468
18140
 
18469
- "theme": ${C == null ? void 0 : C.split(`
18141
+ "theme": ${v == null ? void 0 : v.split(`
18470
18142
  `).join(`
18471
18143
  `)},
18472
18144
  }`;
18473
18145
  }, []);
18474
- return ((S = o == null ? void 0 : o.jsx) == null ? void 0 : S.length) > 0 && u ? /* @__PURE__ */ jsx(
18146
+ return ((k = o == null ? void 0 : o.jsx) == null ? void 0 : k.length) > 0 && u ? /* @__PURE__ */ jsx(
18475
18147
  CodeDisplay,
18476
18148
  {
18477
18149
  onCopy: g,
@@ -18559,103 +18231,108 @@ ${i})
18559
18231
  if (typeof window > "u")
18560
18232
  throw new Error("@chaibuilder/sdk is only supported in the browser. Avoid using it in the server side.");
18561
18233
  export {
18562
- useCanvasZoom as $,
18234
+ useAddBlock as $,
18563
18235
  AddBlocksPanel as A,
18564
18236
  BlockSettings as B,
18565
18237
  CanvasArea as C,
18566
18238
  DarkMode as D,
18567
18239
  ExportCodeModal as E,
18568
- registerChaiFeatureFlag as F,
18569
- registerChaiFeatureFlags as G,
18570
- useChaiFeatureFlag as H,
18240
+ registerBlockSettingWidget as F,
18241
+ registerChaiPreImportHTMLHook as G,
18242
+ registerChaiLibrary as H,
18571
18243
  ImportHTML as I,
18572
- useChaiFeatureFlags as J,
18573
- useToggleChaiFeatureFlag as K,
18244
+ registerChaiMediaManager as J,
18245
+ registerChaiSaveToLibrary as K,
18574
18246
  ListTree as L,
18575
- useMediaManagerComponent as M,
18247
+ ManualClasses as M,
18576
18248
  NestedPathSelector as N,
18577
- useActiveSettingsTab as O,
18578
- PERMISSIONS as P,
18579
- useAddBlock as Q,
18580
- useAddClassesToBlocks as R,
18581
- useAskAi as S,
18249
+ registerChaiSidebarPanel as O,
18250
+ registerChaiTopBar as P,
18251
+ IfChaiFeatureFlag as Q,
18252
+ registerChaiFeatureFlag as R,
18253
+ registerChaiFeatureFlags as S,
18582
18254
  ThemeConfigPanel as T,
18583
18255
  UILibrariesPanel as U,
18584
- useBlockHighlight as V,
18585
- useBlocksHtmlForAi as W,
18586
- useBlocksStore as X,
18587
- useBrandingOptions as Y,
18588
- useBuilderProp as Z,
18589
- useBuilderReset as _,
18256
+ useChaiFeatureFlag as V,
18257
+ useChaiFeatureFlags as W,
18258
+ useToggleChaiFeatureFlag as X,
18259
+ useMediaManagerComponent as Y,
18260
+ PERMISSIONS as Z,
18261
+ useActiveSettingsTab as _,
18590
18262
  useSelectedBlockIds as a,
18591
- useCopyBlocks as a0,
18592
- useCopyToClipboard as a1,
18593
- useCurrentPage as a2,
18594
- useCutBlockIds as a3,
18595
- useDarkMode as a4,
18596
- useDuplicateBlocks as a5,
18597
- useHighlightBlockId as a6,
18598
- useHtmlToBlocks as a7,
18599
- useI18nBlocks as a8,
18600
- useInlineEditing as a9,
18601
- useThemeOptions as aA,
18602
- useUndoManager as aB,
18603
- useWrapperBlock as aC,
18604
- useBlocksStoreUndoableActions as aD,
18605
- useCanvasWidth as aE,
18606
- useCanvasDisplayWidth as aF,
18607
- useScreenSizeWidth as aG,
18608
- useSelectedLibrary as aH,
18609
- useSidebarActivePanel as aI,
18610
- useIsPageLoaded as aa,
18611
- useLanguages as ab,
18612
- useLibraryBlocks as ac,
18613
- usePartialBlocksStore as ad,
18614
- usePartialBlocksList as ae,
18615
- usePasteBlocks as af,
18616
- usePermissions as ag,
18617
- usePreviewMode as ah,
18618
- usePubSub as ai,
18619
- useRemoveAllClassesForBlock as aj,
18620
- useRemoveBlocks as ak,
18621
- useRemoveClassesFromBlocks as al,
18622
- useReplaceBlock as am,
18623
- useResetBlockStyles as an,
18624
- useRightPanel as ao,
18625
- useSavePage as ap,
18626
- useSelectedBlock as aq,
18627
- useSelectedBlockAllClasses as ar,
18628
- useSelectedBlockCurrentClasses as as,
18629
- useSelectedBlocksDisplayChild as at,
18630
- useSelectedBreakpoints as au,
18631
- useSelectedStylingBlocks as av,
18632
- useStreamMultipleBlocksProps as aw,
18633
- useStylingBreakpoint as ax,
18634
- useStylingState as ay,
18635
- useTheme as az,
18263
+ useAddClassesToBlocks as a0,
18264
+ useAskAi as a1,
18265
+ useBlockHighlight as a2,
18266
+ useBlocksHtmlForAi as a3,
18267
+ useBrandingOptions as a4,
18268
+ useBuilderReset as a5,
18269
+ useCanvasZoom as a6,
18270
+ useCopyBlocks as a7,
18271
+ useCopyToClipboard as a8,
18272
+ useCurrentPage as a9,
18273
+ useSelectedStylingBlocks as aA,
18274
+ useStreamMultipleBlocksProps as aB,
18275
+ useStylingBreakpoint as aC,
18276
+ useStylingState as aD,
18277
+ useTheme as aE,
18278
+ useThemeOptions as aF,
18279
+ useUndoManager as aG,
18280
+ useWrapperBlock as aH,
18281
+ useBlocksStoreUndoableActions as aI,
18282
+ useCanvasWidth as aJ,
18283
+ useCanvasDisplayWidth as aK,
18284
+ useScreenSizeWidth as aL,
18285
+ useSelectedLibrary as aM,
18286
+ useSidebarActivePanel as aN,
18287
+ useCutBlockIds as aa,
18288
+ useDarkMode as ab,
18289
+ useDuplicateBlocks as ac,
18290
+ useHighlightBlockId as ad,
18291
+ useHtmlToBlocks as ae,
18292
+ useI18nBlocks as af,
18293
+ useInlineEditing as ag,
18294
+ useIsPageLoaded as ah,
18295
+ useLibraryBlocks as ai,
18296
+ usePartialBlocksStore as aj,
18297
+ usePartialBlocksList as ak,
18298
+ usePasteBlocks as al,
18299
+ usePermissions as am,
18300
+ usePreviewMode as an,
18301
+ usePubSub as ao,
18302
+ useRemoveAllClassesForBlock as ap,
18303
+ useRemoveBlocks as aq,
18304
+ useRemoveClassesFromBlocks as ar,
18305
+ useReplaceBlock as as,
18306
+ useResetBlockStyles as at,
18307
+ useRightPanel as au,
18308
+ useSelectedBlock as av,
18309
+ useSelectedBlockAllClasses as aw,
18310
+ useSelectedBlockCurrentClasses as ax,
18311
+ useSelectedBlocksDisplayChild as ay,
18312
+ useSelectedBreakpoints as az,
18636
18313
  useUpdateBlocksProps as b,
18637
18314
  useUpdateBlocksPropsRealtime as c,
18638
18315
  usePageExternalData as d,
18639
- BlockStyling as e,
18640
- AIUserPrompt as f,
18641
- Breakpoints$1 as g,
18642
- UndoRedo as h,
18643
- ChaiBuilderEditor as i,
18644
- AddBlocksDialog as j,
18645
- BlockAttributesEditor as k,
18646
- DefaultChaiBlocks as l,
18647
- ChaiDraggableBlock as m,
18648
- getClassValueAndUnit as n,
18649
- registerBlockSettingField as o,
18650
- registerBlockSettingTemplate as p,
18651
- registerBlockSettingWidget as q,
18652
- registerChaiAddBlockTab as r,
18653
- registerChaiPreImportHTMLHook as s,
18654
- registerChaiLibrary as t,
18316
+ chaiDesignTokensAtom as e,
18317
+ useIncrementActionsCount as f,
18318
+ useBlocksStore as g,
18319
+ useBuilderProp as h,
18320
+ useLanguages as i,
18321
+ useSavePage as j,
18322
+ BlockStyling as k,
18323
+ AIUserPrompt as l,
18324
+ Breakpoints$1 as m,
18325
+ UndoRedo as n,
18326
+ orderClassesByBreakpoint as o,
18327
+ ChaiBuilderEditor as p,
18328
+ AddBlocksDialog as q,
18329
+ removeDuplicateClasses as r,
18330
+ BlockAttributesEditor as s,
18331
+ DefaultChaiBlocks as t,
18655
18332
  useCodeEditor as u,
18656
- registerChaiMediaManager as v,
18657
- registerChaiSaveToLibrary as w,
18658
- registerChaiSidebarPanel as x,
18659
- registerChaiTopBar as y,
18660
- IfChaiFeatureFlag as z
18333
+ ChaiDraggableBlock as v,
18334
+ getClassValueAndUnit as w,
18335
+ registerChaiAddBlockTab as x,
18336
+ registerBlockSettingField as y,
18337
+ registerBlockSettingTemplate as z
18661
18338
  };