@chaibuilder/sdk 2.6.2 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -4,7 +4,7 @@ var F = (o, r, n) => V(o, typeof r != "symbol" ? r + "" : r, n);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
6
  import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
7
- import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, trim, sortBy, round } from "lodash-es";
7
+ import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, isArray, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, lazy, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
@@ -15,7 +15,7 @@ import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, Edit2Icon, Chevro
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
17
17
  import TreeModel from "tree-model";
18
- import { C as COLLECTION_PREFIX, S as STYLES_KEY, f as getSplitChaiClasses, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, h as ROOT_TEMP_KEY } from "./apply-binding-BL-JPMms.js";
18
+ import { C as COLLECTION_PREFIX, S as STYLES_KEY, h as getSplitChaiClasses, a as applyBindingToBlockProps, b as applyLanguage, g as getBlockTagAttributes, c as getBlockRuntimeProps, d as applyLimit, R as REPEATER_PREFIX, f as getBlocksFromHTML, i as ROOT_TEMP_KEY } from "./apply-binding-OTp8TO_7.js";
19
19
  import { d as defaultThemeOptions, f as defaultThemeValues, a as getChaiThemeCssVariables, g as getChaiThemeOptions, p as plugin, h as getThemeFontsUrls, i as getThemeCustomFontFace } from "./plugin-BOcGV_IY.js";
20
20
  import { isObject } from "@rjsf/utils";
21
21
  import { useDebouncedCallback, useThrottledCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
@@ -34,10 +34,10 @@ import RjForm from "@rjsf/core";
34
34
  import validator from "@rjsf/validator-ajv8";
35
35
  import Autosuggest from "react-autosuggest";
36
36
  import { useFeature } from "flagged";
37
- import { parse, stringify } from "himalaya";
38
37
  import { Tree } from "react-arborist";
39
38
  import i18n from "i18next";
40
39
  import { default as Ue } from "i18next";
40
+ import "himalaya";
41
41
  import tailwindAspectRatio from "@tailwindcss/aspect-ratio";
42
42
  import tailwindForms from "@tailwindcss/forms";
43
43
  import tailwindTypography from "@tailwindcss/typography";
@@ -839,13 +839,13 @@ const undoRedoStateAtom = atom({
839
839
  } = useBlocksStoreManager();
840
840
  return {
841
841
  moveBlocks: (f, y, b) => {
842
- const A = map(f, (E) => {
843
- const w = r.find((j) => j._id === E)._parent || null, k = r.filter((j) => w ? j._parent === w : !j._parent).map((j) => j._id).indexOf(E);
844
- return { _id: E, oldParent: w, oldPosition: k };
845
- }), _ = A.find(({ _id: E }) => E === f[0]);
846
- _ && _.oldParent === y && _.oldPosition === b || (i(f, y, b), o({
847
- undo: () => each(A, ({ _id: E, oldParent: N, oldPosition: w }) => {
848
- i([E], N, w);
842
+ const w = map(f, (_) => {
843
+ const A = r.find((E) => E._id === _)._parent || null, C = r.filter((E) => A ? E._parent === A : !E._parent).map((E) => E._id).indexOf(_);
844
+ return { _id: _, oldParent: A, oldPosition: C };
845
+ }), B = w.find(({ _id: _ }) => _ === f[0]);
846
+ B && B.oldParent === y && B.oldPosition === b || (i(f, y, b), o({
847
+ undo: () => each(w, ({ _id: _, oldParent: N, oldPosition: A }) => {
848
+ i([_], N, A);
849
849
  }),
850
850
  redo: () => i(f, y, b)
851
851
  }));
@@ -857,27 +857,27 @@ const undoRedoStateAtom = atom({
857
857
  });
858
858
  },
859
859
  removeBlocks: (f) => {
860
- var _;
861
- const y = (_ = first(f)) == null ? void 0 : _._parent, A = r.filter((E) => y ? E._parent === y : !E._parent).indexOf(first(f));
860
+ var B;
861
+ const y = (B = first(f)) == null ? void 0 : B._parent, w = r.filter((_) => y ? _._parent === y : !_._parent).indexOf(first(f));
862
862
  l(map(f, "_id")), o({
863
- undo: () => a(f, y, A),
863
+ undo: () => a(f, y, w),
864
864
  redo: () => l(map(f, "_id"))
865
865
  });
866
866
  },
867
867
  updateBlocks: (f, y, b) => {
868
- let A = [];
868
+ let w = [];
869
869
  if (b)
870
- A = map(f, (_) => ({ _id: _, ...b }));
870
+ w = map(f, (B) => ({ _id: B, ...b }));
871
871
  else {
872
- const _ = keys(y);
873
- A = map(f, (E) => {
874
- const N = r.find((S) => S._id === E), w = { _id: E };
875
- return each(_, (S) => w[S] = N[S]), w;
872
+ const B = keys(y);
873
+ w = map(f, (_) => {
874
+ const N = r.find((v) => v._id === _), A = { _id: _ };
875
+ return each(B, (v) => A[v] = N[v]), A;
876
876
  });
877
877
  }
878
- c(map(f, (_) => ({ _id: _, ...y }))), o({
879
- undo: () => c(A),
880
- redo: () => c(map(f, (_) => ({ _id: _, ...y })))
878
+ c(map(f, (B) => ({ _id: B, ...y }))), o({
879
+ undo: () => c(w),
880
+ redo: () => c(map(f, (B) => ({ _id: B, ...y })))
881
881
  });
882
882
  },
883
883
  updateBlocksRuntime: (f, y) => {
@@ -892,8 +892,8 @@ const undoRedoStateAtom = atom({
892
892
  updateMultipleBlocksProps: (f) => {
893
893
  let y = [];
894
894
  y = map(f, (b) => {
895
- const A = keys(b), _ = r.find((N) => N._id === b._id), E = {};
896
- return each(A, (N) => E[N] = _[N]), E;
895
+ const w = keys(b), B = r.find((N) => N._id === b._id), _ = {};
896
+ return each(w, (N) => _[N] = B[N]), _;
897
897
  }), c(f), o({
898
898
  undo: () => c(y),
899
899
  redo: () => c(f)
@@ -2367,8 +2367,8 @@ const getBlockWithChildren = (o, r) => {
2367
2367
  for (const y in f) {
2368
2368
  const b = f[y];
2369
2369
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2370
- const { baseClasses: A, classes: _ } = getSplitChaiClasses(b);
2371
- f[y] = compact(flattenDeep([A, _])).join(" ");
2370
+ const { baseClasses: w, classes: B } = getSplitChaiClasses(b);
2371
+ f[y] = compact(flattenDeep([w, B])).join(" ");
2372
2372
  } else
2373
2373
  y !== "_id" && delete f[y];
2374
2374
  }
@@ -2382,21 +2382,21 @@ const getBlockWithChildren = (o, r) => {
2382
2382
  try {
2383
2383
  const b = p === u ? "" : p;
2384
2384
  console.log("prompt", f);
2385
- const A = f.toLowerCase().includes("translate the content"), _ = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, A) : [h(x, d)], E = await l(m, addLangToPrompt(f, g, m), _, b), { blocks: N, error: w } = E;
2386
- if (w) {
2387
- a(w);
2385
+ const w = f.toLowerCase().includes("translate the content"), B = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, w) : [h(x, d)], _ = await l(m, addLangToPrompt(f, g, m), B, b), { blocks: N, error: A } = _;
2386
+ if (A) {
2387
+ a(A);
2388
2388
  return;
2389
2389
  }
2390
2390
  if (m === "styles") {
2391
- const S = N.map((k) => {
2392
- for (const j in k)
2393
- j !== "_id" && (k[j] = `${STYLES_KEY},${k[j]}`);
2394
- return k;
2391
+ const v = N.map((C) => {
2392
+ for (const E in C)
2393
+ E !== "_id" && (C[E] = `${STYLES_KEY},${C[E]}`);
2394
+ return C;
2395
2395
  });
2396
- c(S);
2396
+ c(v);
2397
2397
  } else
2398
2398
  i(N);
2399
- y && y(E);
2399
+ y && y(_);
2400
2400
  } catch (b) {
2401
2401
  a(b);
2402
2402
  } finally {
@@ -3008,8 +3008,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3008
3008
  }),
3009
3009
  size({
3010
3010
  boundary: u == null ? void 0 : u.body,
3011
- apply({ availableWidth: y, availableHeight: b, elements: A }) {
3012
- Object.assign(A.floating.style, {
3011
+ apply({ availableWidth: y, availableHeight: b, elements: w }) {
3012
+ Object.assign(w.floating.style, {
3013
3013
  maxWidth: `${Math.max(200, y)}px`,
3014
3014
  maxHeight: `${Math.max(100, b)}px`
3015
3015
  });
@@ -3600,62 +3600,62 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3600
3600
  }
3601
3601
  ), WithBlockTextEditor = memo(
3602
3602
  ({ block: o, children: r }) => {
3603
- const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: A, blockType: _ } = useMemo(() => {
3604
- var B;
3605
- const k = o._type;
3606
- let j = o[n];
3607
- const C = getRegisteredChaiBlock(o._type);
3608
- return x && ((B = C == null ? void 0 : C.i18nProps) == null ? void 0 : B.includes(n)) && has(o, `${n}-${x}`) && (j = get(o, `${n}-${x}`)), { blockContent: j, blockType: k };
3609
- }, [o, x]), E = useCallback(
3610
- (k) => {
3611
- var C;
3612
- const j = k || ((C = g.current) == null ? void 0 : C.innerText);
3613
- m([b], { [n]: j }), u(null), c(null), d(-1), f(b ? [b] : []);
3603
+ const n = "content", { document: a } = useFrame(), { editingBlockId: l, editingItemIndex: i, setEditingBlockId: c, setEditingItemIndex: d } = useInlineEditing(), [p, u] = useState(null), g = useRef(null), { clearHighlight: h } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: x } = useLanguages(), [, f] = useSelectedBlockIds(), y = useRef(null), b = l, { blockContent: w, blockType: B } = useMemo(() => {
3604
+ var j;
3605
+ const C = o._type;
3606
+ let E = o[n];
3607
+ const S = getRegisteredChaiBlock(o._type);
3608
+ return x && ((j = S == null ? void 0 : S.i18nProps) == null ? void 0 : j.includes(n)) && has(o, `${n}-${x}`) && (E = get(o, `${n}-${x}`)), { blockContent: E, blockType: C };
3609
+ }, [o, x]), _ = useCallback(
3610
+ (C) => {
3611
+ var S;
3612
+ const E = C || ((S = g.current) == null ? void 0 : S.innerText);
3613
+ m([b], { [n]: E }), u(null), c(null), d(-1), f(b ? [b] : []);
3614
3614
  },
3615
3615
  [b, m, c, f, x]
3616
3616
  ), N = useDebouncedCallback(
3617
- (k) => {
3618
- m([b], { [n]: k });
3617
+ (C) => {
3618
+ m([b], { [n]: C });
3619
3619
  },
3620
3620
  [b, o, m, x],
3621
3621
  1e3
3622
- ), w = useCallback(
3623
- (k) => {
3624
- k.preventDefault(), b && (y.current = b), E(), setTimeout(() => {
3625
- const j = y.current;
3626
- y.current = null, f([j]);
3622
+ ), A = useCallback(
3623
+ (C) => {
3624
+ C.preventDefault(), b && (y.current = b), _(), setTimeout(() => {
3625
+ const E = y.current;
3626
+ y.current = null, f([E]);
3627
3627
  }, 100);
3628
3628
  },
3629
3629
  [f, b, x]
3630
3630
  );
3631
3631
  useEffect(() => {
3632
- var v;
3632
+ var k;
3633
3633
  if (!b) return;
3634
- const k = `[data-block-id="${b}"]`, j = i >= 0 ? `[data-block-index="${i}"]` : "", C = a.querySelector(`${k}${j}`);
3635
- C && ((v = C == null ? void 0 : C.classList) == null || v.add("sr-only"), u(C));
3636
- }, [b, _, a, i]);
3637
- const S = useMemo(() => p ? (h(), _ === "RichText" ? /* @__PURE__ */ jsx(
3634
+ const C = `[data-block-id="${b}"]`, E = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${C}${E}`);
3635
+ S && ((k = S == null ? void 0 : S.classList) == null || k.add("sr-only"), u(S));
3636
+ }, [b, B, a, i]);
3637
+ const v = useMemo(() => p ? (h(), B === "RichText" ? /* @__PURE__ */ jsx(
3638
3638
  RichTextEditor,
3639
3639
  {
3640
- blockContent: A,
3640
+ blockContent: w,
3641
3641
  editingElement: p,
3642
3642
  onChange: N,
3643
- onClose: E,
3644
- onEscape: w
3643
+ onClose: _,
3644
+ onEscape: A
3645
3645
  }
3646
3646
  ) : /* @__PURE__ */ jsx(
3647
3647
  MemoizedEditor,
3648
3648
  {
3649
3649
  editorRef: g,
3650
- blockContent: A,
3650
+ blockContent: w,
3651
3651
  editingElement: p,
3652
- onClose: E,
3652
+ onClose: _,
3653
3653
  onChange: N,
3654
- onEscape: w
3654
+ onEscape: A
3655
3655
  }
3656
- )) : null, [p, b, _, A, E, x]);
3656
+ )) : null, [p, b, B, w, _, x]);
3657
3657
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3658
- S,
3658
+ v,
3659
3659
  r
3660
3660
  ] });
3661
3661
  },
@@ -3694,17 +3694,17 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3694
3694
  key: y
3695
3695
  }) : applyLanguage(i, d, c),
3696
3696
  [i, d, c, g, m, f, y]
3697
- ), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), _ = useMemo(
3697
+ ), w = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), B = useMemo(
3698
3698
  () => u(i._id, getBlockRuntimeProps(i._type)),
3699
3699
  [i._id, i._type, u, getBlockRuntimeProps]
3700
- ), E = useMemo(
3700
+ ), _ = useMemo(
3701
3701
  () => ({
3702
3702
  blockProps: { "data-block-id": i._id, "data-block-type": i._type, "data-block-index": f },
3703
3703
  inBuilder: !0,
3704
3704
  lang: d || p,
3705
3705
  ...b,
3706
- ...A,
3707
- ..._,
3706
+ ...w,
3707
+ ...B,
3708
3708
  ...o
3709
3709
  }),
3710
3710
  [
@@ -3713,14 +3713,14 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3713
3713
  d,
3714
3714
  p,
3715
3715
  b,
3716
- A,
3717
- _,
3716
+ w,
3717
+ B,
3718
3718
  o
3719
3719
  ]
3720
3720
  ), N = useMemo(() => !CORE_BLOCKS.includes(i._type), [i._type]);
3721
3721
  if (isNull(x) || h.includes(i._id)) return null;
3722
- let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
3723
- ...E,
3722
+ let A = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
3723
+ ..._,
3724
3724
  children: n({
3725
3725
  _id: i._id,
3726
3726
  _type: i._type,
@@ -3732,8 +3732,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3732
3732
  ...i.globalBlock ? { partialBlockId: i.globalBlock } : ""
3733
3733
  })
3734
3734
  }) });
3735
- const S = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3736
- return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: S }) : S;
3735
+ const v = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: A }) : A;
3736
+ return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: v }) : v;
3737
3737
  }, PartialWrapper = ({ children: o, partialBlockId: r }) => {
3738
3738
  const n = useBuilderProp("gotoPage", noop), { saveState: a } = useSavePage(), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useCallback(
3739
3739
  (d) => {
@@ -4032,15 +4032,15 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4032
4032
  const b = isArray(y) ? first(y) : y;
4033
4033
  if (b) {
4034
4034
  r(b == null ? void 0 : b.url);
4035
- const A = b == null ? void 0 : b.width, _ = b == null ? void 0 : b.height;
4035
+ const w = b == null ? void 0 : b.width, B = b == null ? void 0 : b.height;
4036
4036
  if (c != null && c._id) {
4037
- const E = {
4038
- ...A && { width: A },
4039
- ..._ && { height: _ },
4037
+ const _ = {
4038
+ ...w && { width: w },
4039
+ ...B && { height: B },
4040
4040
  ...b.description && { alt: b.description }
4041
4041
  };
4042
- if (set(E, u, b.id), isEmpty(E)) return;
4043
- d([c._id], E);
4042
+ if (set(_, u, b.id), isEmpty(_)) return;
4043
+ d([c._id], _);
4044
4044
  }
4045
4045
  }
4046
4046
  }, f = useCallback(() => {
@@ -4207,12 +4207,12 @@ const DataBindingSelector = ({
4207
4207
  r(`{{${g}}}`, {}, n);
4208
4208
  return;
4209
4209
  }
4210
- const m = (b) => /[.,!?;:]/.test(b), x = (b, A, _) => {
4211
- let E = "", N = "";
4212
- const w = A > 0 ? b[A - 1] : "", S = A < b.length ? b[A] : "";
4213
- return A > 0 && (w === "." || !m(w) && w !== " ") && (E = " "), A < b.length && !m(S) && S !== " " && (N = " "), {
4214
- text: E + _ + N,
4215
- prefixLength: E.length,
4210
+ const m = (b) => /[.,!?;:]/.test(b), x = (b, w, B) => {
4211
+ let _ = "", N = "";
4212
+ const A = w > 0 ? b[w - 1] : "", v = w < b.length ? b[w] : "";
4213
+ return w > 0 && (A === "." || !m(A) && A !== " ") && (_ = " "), w < b.length && !m(v) && v !== " " && (N = " "), {
4214
+ text: _ + B + N,
4215
+ prefixLength: _.length,
4216
4216
  suffixLength: N.length
4217
4217
  };
4218
4218
  }, f = document.getElementById(n);
@@ -4221,30 +4221,30 @@ const DataBindingSelector = ({
4221
4221
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4222
4222
  const b = y.__chaiRTE;
4223
4223
  if (b) {
4224
- const A = `{{${g}}}`;
4224
+ const w = `{{${g}}}`;
4225
4225
  b.commands.focus();
4226
- const { from: _, to: E } = b.state.selection;
4227
- if (_ !== E)
4228
- b.chain().deleteSelection().insertContent(A).run();
4226
+ const { from: B, to: _ } = b.state.selection;
4227
+ if (B !== _)
4228
+ b.chain().deleteSelection().insertContent(w).run();
4229
4229
  else {
4230
- const { state: w } = b, S = w.selection.from, k = w.doc.textBetween(Math.max(0, S - 1), S), j = w.doc.textBetween(S, Math.min(S + 1, w.doc.content.size));
4231
- let C = "";
4232
- S > 0 && k !== " " && !m(k) && (C = " ");
4233
- let v = "";
4234
- j && j !== " " && !m(j) && (v = " "), b.chain().insertContent(C + A + v).run();
4230
+ const { state: A } = b, v = A.selection.from, C = A.doc.textBetween(Math.max(0, v - 1), v), E = A.doc.textBetween(v, Math.min(v + 1, A.doc.content.size));
4231
+ let S = "";
4232
+ v > 0 && C !== " " && !m(C) && (S = " ");
4233
+ let k = "";
4234
+ E && E !== " " && !m(E) && (k = " "), b.chain().insertContent(S + w + k).run();
4235
4235
  }
4236
4236
  setTimeout(() => r(b.getHTML(), {}, n), 100);
4237
4237
  return;
4238
4238
  }
4239
4239
  } else {
4240
- const b = f, A = b.selectionStart || 0, _ = b.value || "", E = b.selectionEnd || A;
4241
- if (E > A) {
4242
- const j = `{{${g}}}`, { text: C } = x(_, A, j), v = _.slice(0, A) + C + _.slice(E);
4243
- r(v, {}, n);
4240
+ const b = f, w = b.selectionStart || 0, B = b.value || "", _ = b.selectionEnd || w;
4241
+ if (_ > w) {
4242
+ const E = `{{${g}}}`, { text: S } = x(B, w, E), k = B.slice(0, w) + S + B.slice(_);
4243
+ r(k, {}, n);
4244
4244
  return;
4245
4245
  }
4246
- const w = `{{${g}}}`, { text: S } = x(_, A, w), k = _.slice(0, A) + S + _.slice(A);
4247
- r(k, {}, n);
4246
+ const A = `{{${g}}}`, { text: v } = x(B, w, A), C = B.slice(0, w) + v + B.slice(w);
4247
+ r(C, {}, n);
4248
4248
  }
4249
4249
  },
4250
4250
  [n, r, a, c == null ? void 0 : c._id, d]
@@ -4265,74 +4265,74 @@ const DataBindingSelector = ({
4265
4265
  pageTypes: r,
4266
4266
  onChange: n
4267
4267
  }) => {
4268
- var j;
4269
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), A = useRef(null), _ = (j = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : j.name;
4268
+ var E;
4269
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [y, b] = useState(-1), w = useRef(null), B = (E = r == null ? void 0 : r.find((S) => S.key === u)) == null ? void 0 : E.name;
4270
4270
  useEffect(() => {
4271
4271
  if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4272
- const C = split(o, ":"), v = get(C, 1, "page") || "page";
4273
- g(v), (async () => {
4274
- const B = await l(v, [get(C, 2, "page")]);
4275
- B && Array.isArray(B) && m(get(B, [0, "name"], ""));
4272
+ const S = split(o, ":"), k = get(S, 1, "page") || "page";
4273
+ g(k), (async () => {
4274
+ const j = await l(k, [get(S, 2, "page")]);
4275
+ j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4276
4276
  })();
4277
4277
  }, [o]);
4278
- const E = useDebouncedCallback(
4279
- async (C) => {
4280
- if (isEmpty(C))
4278
+ const _ = useDebouncedCallback(
4279
+ async (S) => {
4280
+ if (isEmpty(S))
4281
4281
  f([]);
4282
4282
  else {
4283
- const v = await l(u, C);
4284
- f(v);
4283
+ const k = await l(u, S);
4284
+ f(k);
4285
4285
  }
4286
4286
  c(!1), b(-1);
4287
4287
  },
4288
4288
  [u],
4289
4289
  300
4290
- ), N = (C) => {
4291
- const v = ["pageType", u, C.id];
4292
- v[1] && (n(v.join(":")), m(C.name), p(!1), f([]), b(-1));
4293
- }, w = (C) => {
4294
- switch (C.key) {
4290
+ ), N = (S) => {
4291
+ const k = ["pageType", u, S.id];
4292
+ k[1] && (n(k.join(":")), m(S.name), p(!1), f([]), b(-1));
4293
+ }, A = (S) => {
4294
+ switch (S.key) {
4295
4295
  case "ArrowDown":
4296
- C.preventDefault(), b((v) => v < x.length - 1 ? v + 1 : v);
4296
+ S.preventDefault(), b((k) => k < x.length - 1 ? k + 1 : k);
4297
4297
  break;
4298
4298
  case "ArrowUp":
4299
- C.preventDefault(), b((v) => v > 0 ? v - 1 : v);
4299
+ S.preventDefault(), b((k) => k > 0 ? k - 1 : k);
4300
4300
  break;
4301
4301
  case "Enter":
4302
- if (C.preventDefault(), x.length === 0) return;
4302
+ if (S.preventDefault(), x.length === 0) return;
4303
4303
  y >= 0 && N(x[y]);
4304
4304
  break;
4305
4305
  case "Escape":
4306
- C.preventDefault(), S();
4306
+ S.preventDefault(), v();
4307
4307
  break;
4308
4308
  }
4309
4309
  };
4310
4310
  useEffect(() => {
4311
- if (y >= 0 && A.current) {
4312
- const C = A.current.children[y];
4313
- C == null || C.scrollIntoView({ block: "nearest" });
4311
+ if (y >= 0 && w.current) {
4312
+ const S = w.current.children[y];
4313
+ S == null || S.scrollIntoView({ block: "nearest" });
4314
4314
  }
4315
4315
  }, [y]);
4316
- const S = () => {
4316
+ const v = () => {
4317
4317
  m(""), f([]), b(-1), p(!1), n("");
4318
- }, k = (C) => {
4319
- m(C), p(!isEmpty(C)), c(!0), E(C);
4318
+ }, C = (S) => {
4319
+ m(S), p(!isEmpty(S)), c(!0), _(S);
4320
4320
  };
4321
4321
  return /* @__PURE__ */ jsxs("div", { children: [
4322
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => g(C.target.value), children: map(r, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
4322
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (S) => g(S.target.value), children: map(r, (S) => /* @__PURE__ */ jsx("option", { value: S.key, children: S.name }, S.key)) }),
4323
4323
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4324
4324
  /* @__PURE__ */ jsx(
4325
4325
  "input",
4326
4326
  {
4327
4327
  type: "text",
4328
4328
  value: h,
4329
- onChange: (C) => k(C.target.value),
4330
- onKeyDown: w,
4331
- placeholder: a(`Search ${_ ?? ""}`),
4329
+ onChange: (S) => C(S.target.value),
4330
+ onKeyDown: A,
4331
+ placeholder: a(`Search ${B ?? ""}`),
4332
4332
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4333
4333
  }
4334
4334
  ),
4335
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: S, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4335
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsx("button", { onClick: v, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4336
4336
  ] }),
4337
4337
  (i || !isEmpty(x) || d && isEmpty(x)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4338
4338
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4342,22 +4342,22 @@ const DataBindingSelector = ({
4342
4342
  ' "',
4343
4343
  h,
4344
4344
  '"'
4345
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(x == null ? void 0 : x.slice(0, 20), (C, v) => /* @__PURE__ */ jsxs(
4345
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: w, children: map(x == null ? void 0 : x.slice(0, 20), (S, k) => /* @__PURE__ */ jsxs(
4346
4346
  "li",
4347
4347
  {
4348
- onClick: () => N(C),
4349
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(C.id) ? "bg-blue-200" : v === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4348
+ onClick: () => N(S),
4349
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : k === y ? "bg-gray-100" : "hover:bg-gray-100"}`,
4350
4350
  children: [
4351
- C.name,
4351
+ S.name,
4352
4352
  " ",
4353
- C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4353
+ S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4354
4354
  "( ",
4355
- C.slug,
4355
+ S.slug,
4356
4356
  " )"
4357
4357
  ] })
4358
4358
  ]
4359
4359
  },
4360
- C.id
4360
+ S.id
4361
4361
  )) }) })
4362
4362
  ] });
4363
4363
  }, LinkField = ({ schema: o, formData: r, onChange: n, name: a }) => {
@@ -4661,11 +4661,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4661
4661
  if (x !== f)
4662
4662
  u.chain().deleteSelection().insertContent(m).run();
4663
4663
  else {
4664
- const { state: b } = u, A = b.selection.from, _ = b.doc.textBetween(Math.max(0, A - 1), A), E = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
4664
+ const { state: b } = u, w = b.selection.from, B = b.doc.textBetween(Math.max(0, w - 1), w), _ = b.doc.textBetween(w, Math.min(w + 1, b.doc.content.size));
4665
4665
  let N = "";
4666
- A > 0 && _ !== " " && !/[.,!?;:]/.test(_) && (N = " ");
4667
- let w = "";
4668
- E && E !== " " && !/[.,!?;:]/.test(E) && (w = " "), u.chain().insertContent(N + m + w).run();
4666
+ w > 0 && B !== " " && !/[.,!?;:]/.test(B) && (N = " ");
4667
+ let A = "";
4668
+ _ && _ !== " " && !/[.,!?;:]/.test(_) && (A = " "), u.chain().insertContent(N + m + A).run();
4669
4669
  }
4670
4670
  };
4671
4671
  return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (h) => !h && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
@@ -4965,25 +4965,25 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4965
4965
  const { selectedLang: h, fallbackLang: m, languages: x } = useLanguages(), f = useMemo(
4966
4966
  () => isEmpty(x) ? "" : isEmpty(h) ? m : h,
4967
4967
  [x, h, m]
4968
- ), y = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), A = useSelectedBlock(), _ = useRegisteredChaiBlocks(), E = useMemo(
4969
- () => get(_, [A == null ? void 0 : A._type, "i18nProps"], []),
4970
- [_, A == null ? void 0 : A._type]
4971
- ), [N, w] = useState(null);
4968
+ ), y = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), w = useSelectedBlock(), B = useRegisteredChaiBlocks(), _ = useMemo(
4969
+ () => get(B, [w == null ? void 0 : w._type, "i18nProps"], []),
4970
+ [B, w == null ? void 0 : w._type]
4971
+ ), [N, A] = useState(null);
4972
4972
  if (c)
4973
4973
  return null;
4974
4974
  if (p.type === "boolean") return /* @__PURE__ */ jsx("div", { className: r, children: a });
4975
- const k = E == null ? void 0 : E.includes(o.replace("root.", ""));
4975
+ const C = _ == null ? void 0 : _.includes(o.replace("root.", ""));
4976
4976
  if (p.type === "array") {
4977
- const j = N === o;
4977
+ const E = N === o;
4978
4978
  return /* @__PURE__ */ jsxs("div", { className: `${r} relative`, children: [
4979
4979
  p.title && /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between gap-1", children: /* @__PURE__ */ jsxs(
4980
4980
  "label",
4981
4981
  {
4982
4982
  htmlFor: o,
4983
- onClick: () => w(j ? null : o),
4983
+ onClick: () => A(E ? null : o),
4984
4984
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
4985
4985
  children: [
4986
- j ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4986
+ E ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4987
4987
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4988
4988
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
4989
4989
  " ",
@@ -4993,8 +4993,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4993
4993
  Info,
4994
4994
  {
4995
4995
  className: "h-3 w-3 text-muted-foreground/70",
4996
- onClick: (C) => C.stopPropagation(),
4997
- onMouseDown: (C) => C.stopPropagation()
4996
+ onClick: (S) => S.stopPropagation(),
4997
+ onMouseDown: (S) => S.stopPropagation()
4998
4998
  }
4999
4999
  ) }),
5000
5000
  /* @__PURE__ */ jsx(TooltipContent, { className: "max-w-xs", children: p.description })
@@ -5002,7 +5002,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5002
5002
  ]
5003
5003
  }
5004
5004
  ) }),
5005
- (u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${j ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5005
+ (u == null ? void 0 : u.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${E ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5006
5006
  a,
5007
5007
  l,
5008
5008
  i
@@ -5015,7 +5015,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5015
5015
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: p.type === "object" ? "pb-2" : "", children: [
5016
5016
  n,
5017
5017
  " ",
5018
- k && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5018
+ C && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5019
5019
  " ",
5020
5020
  y
5021
5021
  ] }),
@@ -5030,8 +5030,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5030
5030
  DataBindingSelector,
5031
5031
  {
5032
5032
  schema: p,
5033
- onChange: (j) => {
5034
- g(j, u, o);
5033
+ onChange: (E) => {
5034
+ g(E, u, o);
5035
5035
  },
5036
5036
  id: o,
5037
5037
  formData: u
@@ -5137,43 +5137,43 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5137
5137
  }), a;
5138
5138
  };
5139
5139
  function BlockSettings() {
5140
- const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: w }, S, k) => {
5141
- S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(w, S) }, k);
5140
+ const { selectedLang: o } = useLanguages(), r = useSelectedBlock(), n = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(r == null ? void 0 : r._type), i = formDataWithSelectedLang(r, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), h = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, h), x = ({ formData: A }, v, C) => {
5141
+ v && (c == null ? void 0 : c._id) === r._id && a([r._id], { [v]: get(A, v) }, C);
5142
5142
  }, f = useCallback(
5143
- debounce(({ formData: w }, S, k) => {
5144
- x({ formData: w }, S, k), d(w);
5143
+ debounce(({ formData: A }, v, C) => {
5144
+ x({ formData: A }, v, C), d(A);
5145
5145
  }, 1500),
5146
5146
  [r == null ? void 0 : r._id, o]
5147
- ), y = ({ formData: w }, S) => {
5148
- S && (n([r._id], { [S]: get(w, S) }), f({ formData: w }, S, { [S]: get(c, S) }));
5149
- }, b = ({ formData: w }, S) => {
5150
- S && (n([g._id], { [S]: get(w, S) }), f({ formData: w }, S, { [S]: get(c, S) }));
5151
- }, { schema: A, uiSchema: _ } = useMemo(() => {
5152
- const w = r == null ? void 0 : r._type;
5153
- if (!w)
5147
+ ), y = ({ formData: A }, v) => {
5148
+ v && (n([r._id], { [v]: get(A, v) }), f({ formData: A }, v, { [v]: get(c, v) }));
5149
+ }, b = ({ formData: A }, v) => {
5150
+ v && (n([g._id], { [v]: get(A, v) }), f({ formData: A }, v, { [v]: get(c, v) }));
5151
+ }, { schema: w, uiSchema: B } = useMemo(() => {
5152
+ const A = r == null ? void 0 : r._type;
5153
+ if (!A)
5154
5154
  return { schema: {}, uiSchema: {} };
5155
5155
  try {
5156
- const { schema: S, uiSchema: k } = getBlockFormSchemas(w);
5157
- if (w === "Repeater") {
5158
- const j = get(r, "repeaterItems", "");
5159
- startsWith(j, `{{${COLLECTION_PREFIX}`) ? (set(k, "filter", { "ui:widget": "collectionSelect" }), set(k, "sort", { "ui:widget": "collectionSelect" })) : (set(k, "filter", { "ui:widget": "hidden" }), set(k, "sort", { "ui:widget": "hidden" }));
5156
+ const { schema: v, uiSchema: C } = getBlockFormSchemas(A);
5157
+ if (A === "Repeater") {
5158
+ const E = get(r, "repeaterItems", "");
5159
+ startsWith(E, `{{${COLLECTION_PREFIX}`) ? (set(C, "filter", { "ui:widget": "collectionSelect" }), set(C, "sort", { "ui:widget": "collectionSelect" })) : (set(C, "filter", { "ui:widget": "hidden" }), set(C, "sort", { "ui:widget": "hidden" }));
5160
5160
  }
5161
- return { schema: S, uiSchema: k };
5161
+ return { schema: v, uiSchema: C };
5162
5162
  } catch {
5163
5163
  return { schema: {}, uiSchema: {} };
5164
5164
  }
5165
- }, [r]), { wrapperSchema: E, wrapperUiSchema: N } = useMemo(() => {
5165
+ }, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
5166
5166
  if (!g || !(g != null && g._type))
5167
5167
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5168
- const w = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: k = {} } = getBlockFormSchemas(w);
5169
- return { wrapperSchema: S, wrapperUiSchema: k };
5168
+ const A = g == null ? void 0 : g._type, { schema: v = {}, uiSchema: C = {} } = getBlockFormSchemas(A);
5169
+ return { wrapperSchema: v, wrapperUiSchema: C };
5170
5170
  }, [g]);
5171
5171
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5172
5172
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5173
5173
  /* @__PURE__ */ jsxs(
5174
5174
  "div",
5175
5175
  {
5176
- onClick: () => u((w) => !w),
5176
+ onClick: () => u((A) => !A),
5177
5177
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5178
5178
  children: [
5179
5179
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5194,19 +5194,19 @@ function BlockSettings() {
5194
5194
  blockId: g == null ? void 0 : g._id,
5195
5195
  onChange: b,
5196
5196
  formData: m,
5197
- schema: E,
5197
+ schema: _,
5198
5198
  uiSchema: N
5199
5199
  }
5200
5200
  ) })
5201
5201
  ] }),
5202
- isEmpty(A) ? null : /* @__PURE__ */ jsx(
5202
+ isEmpty(w) ? null : /* @__PURE__ */ jsx(
5203
5203
  JSONForm,
5204
5204
  {
5205
5205
  blockId: r == null ? void 0 : r._id,
5206
5206
  onChange: y,
5207
5207
  formData: i,
5208
- schema: A,
5209
- uiSchema: _
5208
+ schema: w,
5209
+ uiSchema: B
5210
5210
  }
5211
5211
  )
5212
5212
  ] });
@@ -5417,50 +5417,50 @@ const BlockStylingProps = () => {
5417
5417
  },
5418
5418
  a
5419
5419
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5420
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [A, _] = useState(!1), [E, N] = useState(!1);
5420
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [x, f] = useState(!1), [y, b] = useState(""), [w, B] = useState(!1), [_, N] = useState(!1);
5421
5421
  useEffect(() => {
5422
- const { value: C, unit: v } = getClassValueAndUnit(i);
5423
- if (v === "") {
5424
- l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5422
+ const { value: S, unit: k } = getClassValueAndUnit(i);
5423
+ if (k === "") {
5424
+ l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5425
5425
  return;
5426
5426
  }
5427
- m(v), l(v === "class" || isEmpty(C) ? "" : C);
5427
+ m(k), l(k === "class" || isEmpty(S) ? "" : S);
5428
5428
  }, [i, p, u]);
5429
- const w = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), k = useCallback(
5430
- (C = !1) => {
5431
- const v = getUserInputValues(`${a}`, u);
5432
- if (get(v, "error", !1)) {
5429
+ const A = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), v = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), C = useCallback(
5430
+ (S = !1) => {
5431
+ const k = getUserInputValues(`${a}`, u);
5432
+ if (get(k, "error", !1)) {
5433
5433
  f(!0);
5434
5434
  return;
5435
5435
  }
5436
- const B = get(v, "unit") !== "" ? get(v, "unit") : h;
5437
- if (B === "auto" || B === "none") {
5438
- w(`${d}${B}`);
5436
+ const j = get(k, "unit") !== "" ? get(k, "unit") : h;
5437
+ if (j === "auto" || j === "none") {
5438
+ A(`${d}${j}`);
5439
5439
  return;
5440
5440
  }
5441
- if (get(v, "value") === "")
5441
+ if (get(k, "value") === "")
5442
5442
  return;
5443
- const T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
5444
- C ? S(T) : w(T);
5443
+ const T = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5444
+ S ? v(T) : A(T);
5445
5445
  },
5446
- [w, S, a, h, d, u]
5447
- ), j = useCallback(
5448
- (C) => {
5449
- const v = getUserInputValues(`${a}`, u);
5450
- if (get(v, "error", !1)) {
5446
+ [A, v, a, h, d, u]
5447
+ ), E = useCallback(
5448
+ (S) => {
5449
+ const k = getUserInputValues(`${a}`, u);
5450
+ if (get(k, "error", !1)) {
5451
5451
  f(!0);
5452
5452
  return;
5453
5453
  }
5454
- if (C === "auto" || C === "none") {
5455
- w(`${d}${C}`);
5454
+ if (S === "auto" || S === "none") {
5455
+ A(`${d}${S}`);
5456
5456
  return;
5457
5457
  }
5458
- if (get(v, "value") === "")
5458
+ if (get(k, "value") === "")
5459
5459
  return;
5460
- const B = get(v, "unit") !== "" ? get(v, "unit") : C, T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
5461
- w(T);
5460
+ const j = get(k, "unit") !== "" ? get(k, "unit") : S, T = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5461
+ A(T);
5462
5462
  },
5463
- [w, a, d, u]
5463
+ [A, a, d, u]
5464
5464
  );
5465
5465
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5466
5466
  /* @__PURE__ */ jsx(
@@ -5475,37 +5475,37 @@ const BlockStylingProps = () => {
5475
5475
  /* @__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, {}) }) }),
5476
5476
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
5477
5477
  ] })
5478
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
5478
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${w ? "z-auto" : ""}`, children: [
5479
5479
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5480
5480
  ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
5481
5481
  "input",
5482
5482
  {
5483
5483
  readOnly: h === "class",
5484
- onKeyPress: (C) => {
5485
- C.key === "Enter" && k();
5484
+ onKeyPress: (S) => {
5485
+ S.key === "Enter" && C();
5486
5486
  },
5487
- onKeyDown: (C) => {
5488
- if (C.keyCode !== 38 && C.keyCode !== 40)
5487
+ onKeyDown: (S) => {
5488
+ if (S.keyCode !== 38 && S.keyCode !== 40)
5489
5489
  return;
5490
- C.preventDefault(), N(!0);
5491
- const v = parseInt$1(C.target.value);
5492
- let B = isNaN$1(v) ? 0 : v;
5493
- C.keyCode === 38 && (B += 1), C.keyCode === 40 && (B -= 1);
5494
- const I = `${B}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5495
- S(P);
5490
+ S.preventDefault(), N(!0);
5491
+ const k = parseInt$1(S.target.value);
5492
+ let j = isNaN$1(k) ? 0 : k;
5493
+ S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5494
+ const I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5495
+ v(P);
5496
5496
  },
5497
- onKeyUp: (C) => {
5498
- E && (C.preventDefault(), N(!1));
5497
+ onKeyUp: (S) => {
5498
+ _ && (S.preventDefault(), N(!1));
5499
5499
  },
5500
- onBlur: () => k(),
5501
- onChange: (C) => {
5502
- f(!1), l(C.target.value);
5500
+ onBlur: () => C(),
5501
+ onChange: (S) => {
5502
+ f(!1), l(S.target.value);
5503
5503
  },
5504
- onClick: (C) => {
5505
- var v;
5506
- (v = C == null ? void 0 : C.target) == null || v.select(), n(!1);
5504
+ onClick: (S) => {
5505
+ var k;
5506
+ (k = S == null ? void 0 : S.target) == null || k.select(), n(!1);
5507
5507
  },
5508
- value: A ? y : a,
5508
+ value: w ? y : a,
5509
5509
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
5510
5510
  " ",
5511
5511
  x ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -5530,29 +5530,29 @@ const BlockStylingProps = () => {
5530
5530
  {
5531
5531
  units: u,
5532
5532
  current: h,
5533
- onSelect: (C) => {
5534
- n(!1), m(C), j(C);
5533
+ onSelect: (S) => {
5534
+ n(!1), m(S), E(S);
5535
5535
  }
5536
5536
  }
5537
5537
  ) })
5538
5538
  ] })
5539
5539
  ] }),
5540
- ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
5540
+ ["none", "auto"].indexOf(h) !== -1 || w ? null : /* @__PURE__ */ jsx(
5541
5541
  DragStyleButton,
5542
5542
  {
5543
- onDragStart: () => _(!0),
5544
- onDragEnd: (C) => {
5545
- if (b(() => ""), _(!1), isEmpty(C))
5543
+ onDragStart: () => B(!0),
5544
+ onDragEnd: (S) => {
5545
+ if (b(() => ""), B(!1), isEmpty(S))
5546
5546
  return;
5547
- const v = `${C}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${h === "-" ? "" : h}]`;
5548
- w(I);
5547
+ const k = `${S}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5548
+ A(I);
5549
5549
  },
5550
- onDrag: (C) => {
5551
- if (isEmpty(C))
5550
+ onDrag: (S) => {
5551
+ if (isEmpty(S))
5552
5552
  return;
5553
- b(C);
5554
- const v = `${C}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${h === "-" ? "" : h}]`;
5555
- S(I);
5553
+ b(S);
5554
+ const k = `${S}`, I = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5555
+ v(I);
5556
5556
  },
5557
5557
  currentValue: a,
5558
5558
  unit: h,
@@ -6016,34 +6016,34 @@ const COLOR_PROP = {
6016
6016
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6017
6017
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
6018
6018
  }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
6019
- (S, k = !0) => {
6020
- const j = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
6021
- (p || u !== "") && (j.mq = "xs");
6022
- const C = generateFullClsName(j);
6023
- m(f, [C], k);
6019
+ (v, C = !0) => {
6020
+ const E = { dark: p, mq: g, mod: u, cls: v, property: l, fullCls: "" };
6021
+ (p || u !== "") && (E.mq = "xs");
6022
+ const S = generateFullClsName(E);
6023
+ m(f, [S], C);
6024
6024
  },
6025
6025
  [f, p, g, u, l, m]
6026
- ), A = useCallback(() => {
6026
+ ), w = useCallback(() => {
6027
6027
  x(f, [y], !0);
6028
- }, [f, y, x]), _ = useMemo(() => canChangeClass(h, g), [h, g]);
6028
+ }, [f, y, x]), B = useMemo(() => canChangeClass(h, g), [h, g]);
6029
6029
  useEffect(() => {
6030
- i(_, h);
6031
- }, [_, i, h]);
6032
- const [, , E] = useScreenSizeWidth(), N = useCallback(
6033
- (S) => {
6034
- E({
6030
+ i(B, h);
6031
+ }, [B, i, h]);
6032
+ const [, , _] = useScreenSizeWidth(), N = useCallback(
6033
+ (v) => {
6034
+ _({
6035
6035
  xs: 400,
6036
6036
  sm: 640,
6037
6037
  md: 800,
6038
6038
  lg: 1024,
6039
6039
  xl: 1420,
6040
6040
  "2xl": 1920
6041
- }[S]);
6041
+ }[v]);
6042
6042
  },
6043
- [E]
6044
- ), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6045
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: _, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6046
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !w ? "text-foreground" : ""}`, children: r(a) }) }),
6043
+ [_]
6044
+ ), A = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6045
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6046
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !A ? "text-foreground" : ""}`, children: r(a) }) }),
6047
6047
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6048
6048
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6049
6049
  n === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6062,7 +6062,7 @@ const COLOR_PROP = {
6062
6062
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
6063
6063
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
6064
6064
  ] }),
6065
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: w ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : _ && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6065
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => w(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6066
6066
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6067
6067
  "button",
6068
6068
  {
@@ -6283,7 +6283,7 @@ const COLOR_PROP = {
6283
6283
  tooltip: n = !0
6284
6284
  }) => {
6285
6285
  const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), x = (b) => {
6286
- u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
6286
+ u.includes(b) ? u.length > 2 && g(u.filter((w) => w !== b)) : g((w) => [...w, b]);
6287
6287
  }, f = (b) => {
6288
6288
  r || l(b), c(b);
6289
6289
  }, y = getBreakpointValue(r ? i : a).toLowerCase();
@@ -6463,10 +6463,10 @@ const AskAIStyles = ({ blockId: o }) => {
6463
6463
  };
6464
6464
  function ManualClasses() {
6465
6465
  var I;
6466
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), A = b.split(" ").filter((T) => !isEmpty(T)), _ = () => {
6466
+ const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [h] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [x, f] = useState(""), y = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), w = b.split(" ").filter((T) => !isEmpty(T)), B = () => {
6467
6467
  const T = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6468
6468
  u(h, T, !0), f("");
6469
- }, [E, N] = useState([]), w = ({ value: T }) => {
6469
+ }, [_, N] = useState([]), A = ({ value: T }) => {
6470
6470
  const P = T.trim().toLowerCase(), L = P.match(/.+:/g);
6471
6471
  let D = [];
6472
6472
  if (L && L.length > 0) {
@@ -6478,9 +6478,9 @@ function ManualClasses() {
6478
6478
  } else
6479
6479
  D = i.search(P);
6480
6480
  return N(map(D, "item"));
6481
- }, S = () => {
6481
+ }, v = () => {
6482
6482
  N([]);
6483
- }, k = (T) => T.name, j = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), C = useMemo(
6483
+ }, C = (T) => T.name, E = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6484
6484
  () => ({
6485
6485
  ref: o,
6486
6486
  autoComplete: "off",
@@ -6495,29 +6495,29 @@ function ManualClasses() {
6495
6495
  }, 0);
6496
6496
  },
6497
6497
  onKeyDown: (T) => {
6498
- T.key === "Enter" && x.trim() !== "" && _();
6498
+ T.key === "Enter" && x.trim() !== "" && B();
6499
6499
  },
6500
6500
  onChange: (T, { newValue: P }) => f(P),
6501
6501
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
6502
6502
  }),
6503
6503
  [x, c, o]
6504
- ), v = (T) => {
6504
+ ), k = (T) => {
6505
6505
  debugger;
6506
6506
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6507
6507
  g(h, [T]), u(h, P, !0), n(""), l(-1);
6508
- }, B = () => {
6508
+ }, j = () => {
6509
6509
  if (navigator.clipboard === void 0) {
6510
6510
  toast.error(c("Clipboard not supported"));
6511
6511
  return;
6512
6512
  }
6513
- navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
6513
+ navigator.clipboard.writeText(w.join(" ")), toast.success(c("Classes copied to clipboard"));
6514
6514
  };
6515
6515
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
6516
6516
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
6517
6517
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
6518
6518
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
6519
6519
  /* @__PURE__ */ jsxs(Tooltip, { children: [
6520
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: B, className: "cursor-pointer" }) }),
6520
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: j, className: "cursor-pointer" }) }),
6521
6521
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6522
6522
  ] })
6523
6523
  ] }),
@@ -6533,12 +6533,12 @@ function ManualClasses() {
6533
6533
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
6534
6534
  Autosuggest,
6535
6535
  {
6536
- suggestions: E,
6537
- onSuggestionsFetchRequested: w,
6538
- onSuggestionsClearRequested: S,
6539
- getSuggestionValue: k,
6540
- renderSuggestion: j,
6541
- inputProps: C,
6536
+ suggestions: _,
6537
+ onSuggestionsFetchRequested: A,
6538
+ onSuggestionsClearRequested: v,
6539
+ getSuggestionValue: C,
6540
+ renderSuggestion: E,
6541
+ inputProps: S,
6542
6542
  containerProps: {
6543
6543
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6544
6544
  },
@@ -6554,14 +6554,14 @@ function ManualClasses() {
6554
6554
  {
6555
6555
  variant: "outline",
6556
6556
  className: "h-6 border-border",
6557
- onClick: _,
6557
+ onClick: B,
6558
6558
  disabled: x.trim() === "",
6559
6559
  size: "sm",
6560
6560
  children: /* @__PURE__ */ jsx(PlusIcon, {})
6561
6561
  }
6562
6562
  )
6563
6563
  ] }),
6564
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
6564
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: w.map(
6565
6565
  (T, P) => a === P ? /* @__PURE__ */ jsx(
6566
6566
  "input",
6567
6567
  {
@@ -6569,10 +6569,10 @@ function ManualClasses() {
6569
6569
  value: r,
6570
6570
  onChange: (L) => n(L.target.value),
6571
6571
  onBlur: () => {
6572
- v(T);
6572
+ k(T);
6573
6573
  },
6574
6574
  onKeyDown: (L) => {
6575
- L.key === "Enter" && v(T);
6575
+ L.key === "Enter" && k(T);
6576
6576
  },
6577
6577
  onFocus: (L) => {
6578
6578
  setTimeout(() => {
@@ -6832,306 +6832,6 @@ const CoreBlock = ({
6832
6832
  blocks: l.core
6833
6833
  }
6834
6834
  );
6835
- }, hasVideoEmbed = (o) => {
6836
- const r = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, n = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
6837
- return r.test(o) || n.test(o);
6838
- }, getVideoURLFromHTML = (o) => {
6839
- if (isEmpty(o)) return o;
6840
- const r = /<video[^>]+src=['"]([^'">]+)['"]/, n = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = o.match(r), l = o.match(n), i = a ? a[1] : l ? l[1] : null, c = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, d = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
6841
- return i && (c.test(i) || d.test(i)) ? i : o;
6842
- }, NAME_ATTRIBUTES = ["chai-name", "data-chai-name"], ATTRIBUTE_MAP = {
6843
- img: { alt: "alt", width: "width", height: "height", src: "image" },
6844
- video: {
6845
- src: "url",
6846
- autoplay: "controls.autoPlay",
6847
- muted: "controls.muted",
6848
- loop: "controls.loop",
6849
- controls: "controls.widgets"
6850
- },
6851
- a: {
6852
- href: "link.href",
6853
- target: "link.target",
6854
- type: ""
6855
- // @TODO: Detect here what to url, email, phone, elementId
6856
- },
6857
- input: {
6858
- placeholder: "placeholder",
6859
- required: "required",
6860
- type: "inputType",
6861
- name: "fieldName"
6862
- },
6863
- textarea: {
6864
- placeholder: "placeholder",
6865
- required: "required",
6866
- type: "inputType",
6867
- name: "fieldName"
6868
- },
6869
- select: {
6870
- placeholder: "placeholder",
6871
- required: "required",
6872
- multiple: "multiple",
6873
- name: "fieldName"
6874
- },
6875
- form: {
6876
- action: "action"
6877
- }
6878
- }, shouldAddText = (o, r) => o.children.length === 1 && includes(
6879
- ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
6880
- r._type
6881
- ), getTextContent = (o) => o.map((r) => r.type === "text" ? get(r, "content", "") : isEmpty(r.children) ? "" : getTextContent(r.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o, getHeightAndWidthFromClass = (o) => {
6882
- const r = compact(map(o.split(/\s+/), trim)), n = find(r, (d) => /^w-/.test(d)), a = find(r, (d) => /^h-/.test(d));
6883
- if (!a || !n) return { height: "", width: "" };
6884
- const l = (d) => {
6885
- if (!d) return;
6886
- const p = d.match(/^[wh]-(?:\[(.*?)\]|(.+))$/);
6887
- if (!p) return;
6888
- if (p[1]) return p[1];
6889
- const u = p[2];
6890
- return /^\d+(\.\d+)?$/.test(u) ? `${Number(u) * 4}px` : u === "auto" || includes(u, "%") ? u : "16px";
6891
- }, i = l(n), c = l(a);
6892
- return {
6893
- width: includes(i, "px") ? i : "16px",
6894
- height: includes(c, "px") ? c : "16px"
6895
- };
6896
- }, getAttrs = (o) => {
6897
- if (o.tagName === "svg") return {};
6898
- const r = {}, n = ATTRIBUTE_MAP[o.tagName] || {}, a = o.attributes;
6899
- return forEach(a, ({ key: l, value: i }) => {
6900
- if (!includes(NAME_ATTRIBUTES, l))
6901
- if (n[l]) {
6902
- if (o.tagName === "img" && l === "src" && !i.startsWith("http")) {
6903
- const c = find(o.attributes, { key: "width" }), d = find(o.attributes, { key: "height" });
6904
- c && d ? i = `https://via.placeholder.com/${c == null ? void 0 : c.value}x${d == null ? void 0 : d.value}` : i = "https://via.placeholder.com/150x150";
6905
- }
6906
- set(r, n[l], getSanitizedValue(i));
6907
- } else includes(["style", "class", "srcset"], l) || (has(r, "styles_attrs") || (r.styles_attrs = {}), startsWith(l, "@") && (l = l.replace("@", "x-on:")), r.styles_attrs[`${l}`] = getSanitizedValue(i));
6908
- }), delete r.class, r;
6909
- }, getStyles = (o, r = "styles") => {
6910
- if (!o.attributes) return { [r]: `${STYLES_KEY},` };
6911
- const n = find(o.attributes, { key: "class" });
6912
- if (n) {
6913
- const a = n.value;
6914
- return { [r]: `${STYLES_KEY},${a}` };
6915
- }
6916
- return { [r]: `${STYLES_KEY},` };
6917
- }, getBlockProps = (o) => {
6918
- const r = get(o, "attributes", []), n = r.find((d) => d.key === "data-chai-richtext" || d.key === "chai-richtext"), a = r.find((d) => d.key === "data-chai-lightbox" || d.key === "chai-lightbox"), l = r.find((d) => d.key === "data-chai-dropdown" || d.key === "chai-dropdown"), i = r.find(
6919
- (d) => d.key === "data-chai-dropdown-button" || d.key === "chai-dropdown-button"
6920
- ), c = r.find(
6921
- (d) => d.key === "data-chai-dropdown-content" || d.key === "chai-dropdown-content"
6922
- );
6923
- if (l)
6924
- return { _type: "Dropdown" };
6925
- if (i)
6926
- return { _type: "DropdownButton" };
6927
- if (c)
6928
- return { _type: "DropdownContent" };
6929
- if (n)
6930
- return { _type: "RichText" };
6931
- if (a)
6932
- return { _type: "LightBoxLink" };
6933
- switch (o.tagName) {
6934
- // self closing tags
6935
- case "img":
6936
- return { _type: "Image" };
6937
- case "input":
6938
- return { _type: "Input", showLabel: !1 };
6939
- // showLabel: hiding default block label
6940
- case "hr":
6941
- return { _type: "Divider" };
6942
- case "br":
6943
- return { _type: "LineBreak" };
6944
- case "textarea":
6945
- return { _type: "TextArea", showLabel: !1 };
6946
- case "audio":
6947
- return { _type: "Audio" };
6948
- case "canvas":
6949
- return { _type: "Canvas" };
6950
- case "video":
6951
- case "iframe":
6952
- return { _type: "CustomHTML" };
6953
- case "svg":
6954
- return { _type: "Icon" };
6955
- // non self closing tags
6956
- // fixed structure
6957
- case "select":
6958
- return { _type: "Select", options: [] };
6959
- case "option":
6960
- return { _type: "Option" };
6961
- case "ul":
6962
- case "ol":
6963
- case "dl":
6964
- return {
6965
- _type: "List",
6966
- tag: o.tagName,
6967
- _listType: o.tagName === "ol" ? "list-decimal" : "list-none"
6968
- };
6969
- case "li":
6970
- case "dt":
6971
- return { _type: "ListItem", tag: o.tagName };
6972
- // non self closing tags
6973
- // free flow structure
6974
- case "span":
6975
- case "figcaption":
6976
- case "legend":
6977
- return { _type: "Span", tag: o.tagName };
6978
- case "p":
6979
- return { _type: "Paragraph", content: "" };
6980
- case "a":
6981
- return { _type: "Link" };
6982
- case "form":
6983
- return { _type: "Form" };
6984
- case "label":
6985
- return { _type: "Label" };
6986
- case "button":
6987
- return { _type: "Button" };
6988
- case "code":
6989
- return { _type: "Box", _name: "Code" };
6990
- case "h1":
6991
- case "h2":
6992
- case "h3":
6993
- case "h4":
6994
- case "h5":
6995
- case "h6":
6996
- return { _type: "Heading", tag: o.tagName };
6997
- case "table":
6998
- return { _type: "Table" };
6999
- case "tr":
7000
- return { _type: "TableRow" };
7001
- case "td":
7002
- case "th":
7003
- return { _type: "TableCell", tag: o.tagName };
7004
- case "thead":
7005
- return { _type: "TableHead" };
7006
- case "tbody":
7007
- return { _type: "TableBody" };
7008
- case "tfoot":
7009
- return { _type: "TableFooter" };
7010
- default: {
7011
- const d = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
7012
- return {
7013
- _type: d,
7014
- tag: o.tagName,
7015
- _name: d == "EmptyBox" || o.tagName === "div" ? d : capitalize(o.tagName)
7016
- };
7017
- }
7018
- }
7019
- }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
7020
- var h, m, x, f, y, b, A, _, E, N;
7021
- if (n.type === "comment") return [];
7022
- let a = { _id: generateUUID() };
7023
- if (r && (a._parent = r.block._id), n.type === "text")
7024
- return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
7025
- const l = get(n, "attributes", []), i = l.find(
7026
- (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
7027
- ), c = l.find(
7028
- (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
7029
- ), d = l.find(
7030
- (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
7031
- ), p = l.find(
7032
- (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
7033
- ), u = l.find(
7034
- (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
7035
- );
7036
- if (a = {
7037
- ...a,
7038
- ...getBlockProps(n),
7039
- ...getAttrs(n),
7040
- ...getStyles(n)
7041
- }, n.attributes) {
7042
- const w = n.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
7043
- w && (a._name = w.value);
7044
- }
7045
- if (i)
7046
- return a.content = stringify(n.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
7047
- if (c) {
7048
- const w = [
7049
- "data-chai-lightbox",
7050
- "chai-lightbox",
7051
- "data-vbtype",
7052
- "data-autoplay",
7053
- "data-maxwidth",
7054
- "data-overlay",
7055
- "data-gall",
7056
- "href"
7057
- ];
7058
- a = {
7059
- ...a,
7060
- href: ((h = l.find((S) => S.key === "href")) == null ? void 0 : h.value) || "",
7061
- hrefType: ((m = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7062
- autoplay: ((x = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
7063
- maxWidth: ((y = (f = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : y.replace("px", "")) || "",
7064
- backdropColor: ((b = l.find((S) => S.key === "data-overlay")) == null ? void 0 : b.value) || "",
7065
- galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
7066
- }, forEach(w, (S) => {
7067
- has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
7068
- });
7069
- }
7070
- if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7071
- delete a.styles_attrs;
7072
- const w = filter(n.children || [], (k) => (k == null ? void 0 : k.tagName) !== "span");
7073
- a.content = getTextContent(w);
7074
- const S = find(
7075
- n.children || [],
7076
- (k) => (k == null ? void 0 : k.tagName) === "span" && some(k.children || [], (j) => (j == null ? void 0 : j.tagName) === "svg")
7077
- );
7078
- if (S) {
7079
- const k = find(S.children || [], (j) => (j == null ? void 0 : j.tagName) === "svg");
7080
- if (k) {
7081
- a.icon = stringify([k]);
7082
- const { height: j, width: C } = getSvgDimensions(k, "16px", "16px");
7083
- a.iconHeight = j, a.iconWidth = C;
7084
- }
7085
- }
7086
- return [a];
7087
- }
7088
- if (a._type === "Input") {
7089
- const w = a.inputType || "text";
7090
- w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
7091
- } else if (n.tagName === "video" || n.tagName === "iframe") {
7092
- const w = stringify([n]);
7093
- return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7094
- } else if (n.tagName === "svg") {
7095
- const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: S, width: k } = getHeightAndWidthFromClass(w);
7096
- if (S && k)
7097
- a.styles = `${STYLES_KEY}, ${cn$2(`w-${k} h-${S}`, w)}`.trim(), a.height = S == null ? void 0 : S.replace("px", ""), a.width = k == null ? void 0 : k.replace("px", "");
7098
- else {
7099
- const j = (_ = find(n.attributes, { key: "height" })) == null ? void 0 : _.value, C = (E = find(n.attributes, { key: "width" })) == null ? void 0 : E.value;
7100
- j && C ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${C}px] h-[${j}px]`, w)}`.trim(), a.height = j, a.width = C) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
7101
- }
7102
- return n.attributes = filter(n.attributes, (j) => !includes(["style", "width", "height", "class"], j.key)), a.icon = stringify([n]), [a];
7103
- } else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
7104
- return r.block.options.push({
7105
- label: getTextContent(n.children),
7106
- ...getAttrs(n)
7107
- }), [];
7108
- const g = traverseNodes(n.children, { block: a, node: n });
7109
- return [a, ...g];
7110
- }), getSvgDimensions = (o, r, n) => {
7111
- var p, u;
7112
- const a = get(o, "attributes", []), { height: l, width: i } = getHeightAndWidthFromClass(
7113
- get(find(a, { key: "class" }), "value", "")
7114
- );
7115
- if (l && i)
7116
- return {
7117
- height: `[${l}px]`,
7118
- width: `[${i}px]`
7119
- };
7120
- const c = (p = find(a, { key: "height" })) == null ? void 0 : p.value, d = (u = find(a, { key: "width" })) == null ? void 0 : u.value;
7121
- return {
7122
- height: c ? `[${c}px]` : n,
7123
- width: d ? `[${d}px]` : r
7124
- };
7125
- }, getSanitizedHTML = (o) => {
7126
- o = o.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, l, i) => {
7127
- let c = i.replace(/\\"/g, '"');
7128
- return c = c.replace(/{([^}]+)}/g, (d) => d.replace(/"/g, '\\"')), `${l}="${c.replace(/\\"/g, '"')}"`;
7129
- }), o = o.replace(/\\n/g, "").replace(/\\\\/g, "").replace(/\\([/<>])/g, "$1").replace(/\\./g, "").replace(/[\n\r\t\f\v]/g, ""), o = o.replace(/\$name="[^"]*"/g, "");
7130
- const r = o.match(/<body[^>]*>[\s\S]*?<\/body>/);
7131
- return (r && r.length > 0 ? r[0].replace(/<body/, "<div").replace(/<\/body>/, "</div>") : o).replace(/\s+/g, " ").replaceAll("> <", "><").replace(/<script\b[^<]*(?:(?!<\/script>)<[^<]*)*<\/script>/gi, "").trim();
7132
- }, getBlocksFromHTML = (o) => {
7133
- const r = parse(getSanitizedHTML(o));
7134
- return isEmpty(o) ? [] : flatten(traverseNodes(r));
7135
6835
  }, ImportHTML = ({ parentId: o, position: r }) => {
7136
6836
  const { t: n } = useTranslation(), [a, l] = useState(""), { addPredefinedBlock: i } = useAddBlock(), c = () => {
7137
6837
  const d = getBlocksFromHTML(a);
@@ -7216,18 +6916,18 @@ const registerChaiLibrary = (o, r) => {
7216
6916
  parentId: n = void 0,
7217
6917
  position: a = -1
7218
6918
  }) => {
7219
- const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (_) => {
7220
- const E = has(_, "styles_attrs.data-page-section");
7221
- return _._type === "Box" && E;
6919
+ const [l, i] = useState(!1), c = useMemo(() => (r == null ? void 0 : r.getBlock) || (() => []), [r]), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), x = useFeature("dnd"), [, f] = useAtom$1(draggedBlockAtom), y = (B) => {
6920
+ const _ = has(B, "styles_attrs.data-page-section");
6921
+ return B._type === "Box" && _;
7222
6922
  }, b = useCallback(
7223
- async (_) => {
7224
- if (_.stopPropagation(), has(o, "component")) {
6923
+ async (B) => {
6924
+ if (B.stopPropagation(), has(o, "component")) {
7225
6925
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7226
6926
  return;
7227
6927
  }
7228
6928
  i(!0);
7229
- let E = await c({ library: r, block: o });
7230
- typeof E == "string" && (E = getBlocksFromHTML(E)), isEmpty(E) || p(syncBlocksWithDefaults(E), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6929
+ let _ = await c({ library: r, block: o });
6930
+ typeof _ == "string" && (_ = getBlocksFromHTML(_)), isEmpty(_) || p(syncBlocksWithDefaults(_), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7231
6931
  },
7232
6932
  [d, p, o, c, r, n, a]
7233
6933
  );
@@ -7238,19 +6938,19 @@ const registerChaiLibrary = (o, r) => {
7238
6938
  onClick: l ? () => {
7239
6939
  } : b,
7240
6940
  draggable: x ? "true" : "false",
7241
- onDragStart: async (_) => {
7242
- const E = await c({ library: r, block: o });
6941
+ onDragStart: async (B) => {
6942
+ const _ = await c({ library: r, block: o });
7243
6943
  let N = n;
7244
- if (y(first(E)) && (N = null), !isEmpty(E)) {
7245
- const w = { blocks: E, uiLibrary: !0, parent: N };
7246
- if (_.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7247
- const S = new Image();
7248
- S.src = o.preview, S.onload = () => {
7249
- _.dataTransfer.setDragImage(S, 0, 0);
6944
+ if (y(first(_)) && (N = null), !isEmpty(_)) {
6945
+ const A = { blocks: _, uiLibrary: !0, parent: N };
6946
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(A)), o.preview) {
6947
+ const v = new Image();
6948
+ v.src = o.preview, v.onload = () => {
6949
+ B.dataTransfer.setDragImage(v, 0, 0);
7250
6950
  };
7251
6951
  } else
7252
- _.dataTransfer.setDragImage(new Image(), 0, 0);
7253
- f(w), setTimeout(() => {
6952
+ B.dataTransfer.setDragImage(new Image(), 0, 0);
6953
+ f(A), setTimeout(() => {
7254
6954
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7255
6955
  }, 200);
7256
6956
  }
@@ -7276,7 +6976,7 @@ const registerChaiLibrary = (o, r) => {
7276
6976
  ] }) })
7277
6977
  ] });
7278
6978
  }, UILibrarySection = ({ parentId: o, position: r }) => {
7279
- const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((v) => v.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
6979
+ const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
7280
6980
  useEffect(() => {
7281
6981
  c && c.length > 0 && (x.current = new Fuse(c, {
7282
6982
  keys: ["name", "label", "description", "group"],
@@ -7288,27 +6988,27 @@ const registerChaiLibrary = (o, r) => {
7288
6988
  m([]);
7289
6989
  return;
7290
6990
  }
7291
- const v = x.current.search(u).map((B) => B.item);
7292
- m(v);
6991
+ const k = x.current.search(u).map((j) => j.item);
6992
+ m(k);
7293
6993
  }, [u]);
7294
- const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, A] = useState(null);
6994
+ const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, w] = useState(null);
7295
6995
  useEffect(() => {
7296
6996
  if (isEmpty(keys(y))) {
7297
- A(null);
6997
+ w(null);
7298
6998
  return;
7299
6999
  }
7300
7000
  if (!b || !y[b]) {
7301
- A(first(keys(y)));
7001
+ w(first(keys(y)));
7302
7002
  return;
7303
7003
  }
7304
7004
  }, [y, b]);
7305
- const _ = get(y, b, []), E = useRef(null), { t: N } = useTranslation(), w = (v) => {
7306
- E.current && (clearTimeout(E.current), E.current = null), E.current = setTimeout(() => {
7307
- E.current && A(v);
7005
+ const B = get(y, b, []), _ = useRef(null), { t: N } = useTranslation(), A = (k) => {
7006
+ _.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
7007
+ _.current && w(k);
7308
7008
  }, 400);
7309
- }, S = () => {
7009
+ }, v = () => {
7310
7010
  i != null && i.id && p(i.id);
7311
- }, k = () => {
7011
+ }, C = () => {
7312
7012
  g("");
7313
7013
  };
7314
7014
  if (d)
@@ -7316,7 +7016,7 @@ const registerChaiLibrary = (o, r) => {
7316
7016
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7317
7017
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7318
7018
  ] });
7319
- const j = filter(_, (v, B) => B % 2 === 0), C = filter(_, (v, B) => B % 2 === 1);
7019
+ const E = filter(B, (k, j) => j % 2 === 0), S = filter(B, (k, j) => j % 2 === 1);
7320
7020
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7321
7021
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7322
7022
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7325,14 +7025,14 @@ const registerChaiLibrary = (o, r) => {
7325
7025
  {
7326
7026
  placeholder: N("Search blocks..."),
7327
7027
  value: u,
7328
- onChange: (v) => g(v.target.value),
7028
+ onChange: (k) => g(k.target.value),
7329
7029
  className: "w-full pl-8 pr-8"
7330
7030
  }
7331
7031
  ),
7332
7032
  u && /* @__PURE__ */ jsx(
7333
7033
  "button",
7334
7034
  {
7335
- onClick: k,
7035
+ onClick: C,
7336
7036
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7337
7037
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7338
7038
  }
@@ -7346,56 +7046,56 @@ const registerChaiLibrary = (o, r) => {
7346
7046
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7347
7047
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7348
7048
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
7349
- /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7049
+ /* @__PURE__ */ jsxs(Button, { onClick: v, variant: "outline", size: "sm", className: "gap-2", children: [
7350
7050
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7351
7051
  N("Retry")
7352
7052
  ] })
7353
- ] }) }) : map(y, (v, B) => /* @__PURE__ */ jsxs(
7053
+ ] }) }) : map(y, (k, j) => /* @__PURE__ */ jsxs(
7354
7054
  "div",
7355
7055
  {
7356
- onMouseEnter: () => w(B),
7357
- onMouseLeave: () => clearTimeout(E.current),
7056
+ onMouseEnter: () => A(j),
7057
+ onMouseLeave: () => clearTimeout(_.current),
7358
7058
  role: "button",
7359
- onClick: () => A(B),
7059
+ onClick: () => w(j),
7360
7060
  className: cn$2(
7361
7061
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7362
- B === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7062
+ j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7363
7063
  ),
7364
7064
  children: [
7365
- /* @__PURE__ */ jsx("span", { children: capitalize(N(B.toLowerCase())) }),
7065
+ /* @__PURE__ */ jsx("span", { children: capitalize(N(j.toLowerCase())) }),
7366
7066
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7367
7067
  ]
7368
7068
  },
7369
- B
7069
+ j
7370
7070
  )) })
7371
7071
  ] })
7372
7072
  ] }),
7373
7073
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
7374
7074
  ScrollArea,
7375
7075
  {
7376
- onMouseEnter: () => E.current ? clearTimeout(E.current) : null,
7076
+ onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
7377
7077
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7378
7078
  children: [
7379
- isEmpty(_) && !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: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7380
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: j.map((v, B) => /* @__PURE__ */ jsx(
7079
+ isEmpty(B) && !isEmpty(y) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No blocks found in this group") }) }) : /* @__PURE__ */ jsxs("div", { className: "grid w-full grid-cols-2 gap-2 px-2", children: [
7080
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: E.map((k, j) => /* @__PURE__ */ jsx(
7381
7081
  BlockCard,
7382
7082
  {
7383
7083
  parentId: o,
7384
7084
  position: r,
7385
- block: v,
7085
+ block: k,
7386
7086
  library: i
7387
7087
  },
7388
- `block-${B}`
7088
+ `block-${j}`
7389
7089
  )) }),
7390
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((v, B) => /* @__PURE__ */ jsx(
7090
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((k, j) => /* @__PURE__ */ jsx(
7391
7091
  BlockCard,
7392
7092
  {
7393
7093
  parentId: o,
7394
7094
  position: r,
7395
- block: v,
7095
+ block: k,
7396
7096
  library: i
7397
7097
  },
7398
- `block-second-${B}`
7098
+ `block-second-${j}`
7399
7099
  )) })
7400
7100
  ] }),
7401
7101
  /* @__PURE__ */ jsx("br", {}),
@@ -7432,14 +7132,14 @@ const registerChaiLibrary = (o, r) => {
7432
7132
  }), g(!0);
7433
7133
  else if (!l && Object.keys(a || {}).length > 0) {
7434
7134
  const m = Object.entries(a).map(([f, y]) => {
7435
- const b = y, A = b.type || "partial", _ = formatReadableName(A);
7135
+ const b = y, w = b.type || "partial", B = formatReadableName(w);
7436
7136
  return {
7437
7137
  type: "PartialBlock",
7438
7138
  // Set the type to PartialBlock
7439
7139
  label: formatReadableName(b.name || f),
7440
7140
  description: b.description || "",
7441
7141
  icon: Globe,
7442
- group: _,
7142
+ group: B,
7443
7143
  // Use formatted type as group
7444
7144
  category: "partial",
7445
7145
  partialBlockId: f,
@@ -7494,44 +7194,44 @@ const registerChaiLibrary = (o, r) => {
7494
7194
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
7495
7195
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7496
7196
  }, useChaiAddBlockTabs = () => useMemo(() => values(ADD_BLOCK_TABS), []), CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: r, parentId: n, position: a, gridCols: l = "grid-cols-4" }) => {
7497
- var C;
7498
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(c, (v) => v._id === n)) == null ? void 0 : C._type, [m, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7197
+ var S;
7198
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (k) => k._id === n)) == null ? void 0 : S._type, [m, x] = useState("all"), [f, y] = useState(null), b = useRef(null);
7499
7199
  useEffect(() => {
7500
- const v = setTimeout(() => {
7501
- var B;
7502
- (B = u.current) == null || B.focus();
7200
+ const k = setTimeout(() => {
7201
+ var j;
7202
+ (j = u.current) == null || j.focus();
7503
7203
  }, 0);
7504
- return () => clearTimeout(v);
7204
+ return () => clearTimeout(k);
7505
7205
  }, [g]), useEffect(() => {
7506
7206
  d && (x("all"), y(null));
7507
- }, [d]), useEffect(() => (b.current = debounce((v) => {
7508
- x(v);
7207
+ }, [d]), useEffect(() => (b.current = debounce((k) => {
7208
+ x(k);
7509
7209
  }, 500), () => {
7510
7210
  b.current && b.current.cancel();
7511
7211
  }), []);
7512
- const A = useCallback((v) => {
7513
- y(v), b.current && b.current(v);
7514
- }, []), _ = useCallback(() => {
7212
+ const w = useCallback((k) => {
7213
+ y(k), b.current && b.current(k);
7214
+ }, []), B = useCallback(() => {
7515
7215
  y(null), b.current && b.current.cancel();
7516
- }, []), E = useCallback((v) => {
7517
- b.current && b.current.cancel(), x(v), y(null);
7216
+ }, []), _ = useCallback((k) => {
7217
+ b.current && b.current.cancel(), x(k), y(null);
7518
7218
  }, []), N = useMemo(
7519
7219
  () => d ? values(r).filter(
7520
- (v) => {
7521
- var B, I;
7522
- return (((B = v.label) == null ? void 0 : B.toLowerCase()) + " " + ((I = v.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7220
+ (k) => {
7221
+ var j, I;
7222
+ return (((j = k.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = k.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
7523
7223
  }
7524
7224
  ) : r,
7525
7225
  [r, d]
7526
- ), w = useMemo(
7226
+ ), A = useMemo(
7527
7227
  () => d ? o.filter(
7528
- (v) => reject(filter(values(N), { group: v }), { hidden: !0 }).length > 0
7529
- ) : o.filter((v) => reject(filter(values(r), { group: v }), { hidden: !0 }).length > 0),
7228
+ (k) => reject(filter(values(N), { group: k }), { hidden: !0 }).length > 0
7229
+ ) : o.filter((k) => reject(filter(values(r), { group: k }), { hidden: !0 }).length > 0),
7530
7230
  [r, N, o, d]
7531
- ), S = useMemo(
7532
- () => sortBy(w, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7533
- [w]
7534
- ), k = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), j = useMemo(() => m === "all" ? S : [m], [S, m]);
7231
+ ), v = useMemo(
7232
+ () => sortBy(A, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7233
+ [A]
7234
+ ), C = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), E = useMemo(() => m === "all" ? v : [m], [v, m]);
7535
7235
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7536
7236
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7537
7237
  Input$1,
@@ -7541,55 +7241,55 @@ const registerChaiLibrary = (o, r) => {
7541
7241
  placeholder: i("Search blocks..."),
7542
7242
  value: d,
7543
7243
  className: "-ml-2",
7544
- onChange: (v) => p(v.target.value)
7244
+ onChange: (k) => p(k.target.value)
7545
7245
  }
7546
7246
  ) }),
7547
7247
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7548
- S.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7248
+ v.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r border-border", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7549
7249
  /* @__PURE__ */ jsx(
7550
7250
  "button",
7551
7251
  {
7552
- onClick: () => E("all"),
7553
- onMouseEnter: () => A("all"),
7554
- onMouseLeave: _,
7252
+ onClick: () => _("all"),
7253
+ onMouseEnter: () => w("all"),
7254
+ onMouseLeave: B,
7555
7255
  className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || f === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7556
7256
  children: i("All")
7557
7257
  },
7558
7258
  "sidebar-all"
7559
7259
  ),
7560
- S.map((v) => /* @__PURE__ */ jsx(
7260
+ v.map((k) => /* @__PURE__ */ jsx(
7561
7261
  "button",
7562
7262
  {
7563
- onClick: () => E(v),
7564
- onMouseEnter: () => A(v),
7565
- onMouseLeave: _,
7566
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === v || f === v ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7567
- children: capitalize(i(v.toLowerCase()))
7263
+ onClick: () => _(k),
7264
+ onMouseEnter: () => w(k),
7265
+ onMouseLeave: B,
7266
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || f === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7267
+ children: capitalize(i(k.toLowerCase()))
7568
7268
  },
7569
- `sidebar-${v}`
7269
+ `sidebar-${k}`
7570
7270
  ))
7571
7271
  ] }) }) }),
7572
- /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: w.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7272
+ /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: A.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7573
7273
  i("No blocks found matching"),
7574
7274
  ' "',
7575
7275
  d,
7576
7276
  '"'
7577
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: j.map((v) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7578
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(v.toLowerCase())) }),
7277
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: E.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7278
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7579
7279
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7580
- m === "all" ? filter(values(k), { group: v }) : values(k),
7280
+ m === "all" ? filter(values(C), { group: k }) : values(C),
7581
7281
  { hidden: !0 }
7582
- ).map((B) => /* @__PURE__ */ jsx(
7282
+ ).map((j) => /* @__PURE__ */ jsx(
7583
7283
  CoreBlock,
7584
7284
  {
7585
7285
  parentId: n,
7586
7286
  position: a,
7587
- block: B,
7588
- disabled: !canAcceptChildBlock(h, B.type) || !canBeNestedInside(h, B.type)
7287
+ block: j,
7288
+ disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
7589
7289
  },
7590
- B.type
7290
+ j.type
7591
7291
  )) })
7592
- ] }, v)) }) }) })
7292
+ ] }, k)) }) }) })
7593
7293
  ] })
7594
7294
  ] });
7595
7295
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7615,8 +7315,8 @@ const registerChaiLibrary = (o, r) => {
7615
7315
  /* @__PURE__ */ jsxs(
7616
7316
  Tabs,
7617
7317
  {
7618
- onValueChange: (A) => {
7619
- d(""), c(A);
7318
+ onValueChange: (w) => {
7319
+ d(""), c(w);
7620
7320
  },
7621
7321
  value: i,
7622
7322
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7626,13 +7326,13 @@ const registerChaiLibrary = (o, r) => {
7626
7326
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7627
7327
  g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7628
7328
  f ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7629
- map(x, (A) => /* @__PURE__ */ jsx(TabsTrigger, { value: A.id, children: React__default.createElement(A.tab) }, `tab-add-block-${A.id}`))
7329
+ map(x, (w) => /* @__PURE__ */ jsx(TabsTrigger, { value: w.id, children: React__default.createElement(w.tab) }, `tab-add-block-${w.id}`))
7630
7330
  ] }),
7631
7331
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
7632
7332
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
7633
7333
  g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
7634
7334
  f ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
7635
- map(x, (A) => /* @__PURE__ */ jsx(TabsContent, { value: A.id, children: React__default.createElement(A.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${A.id}`))
7335
+ map(x, (w) => /* @__PURE__ */ jsx(TabsContent, { value: w.id, children: React__default.createElement(w.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${w.id}`))
7636
7336
  ]
7637
7337
  }
7638
7338
  )
@@ -7942,19 +7642,19 @@ const Input = ({ node: o }) => {
7942
7642
  var P;
7943
7643
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7944
7644
  let p = null;
7945
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: A, handleClick: _ } = o, E = (L) => {
7645
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: y, isDragging: b, isEditing: w, handleClick: B } = o, _ = (L) => {
7946
7646
  L.stopPropagation(), !l.includes(m) && o.toggle();
7947
7647
  }, N = (L) => {
7948
7648
  L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7949
- }, w = (L) => {
7649
+ }, A = (L) => {
7950
7650
  L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
7951
- }, [S, k] = useAtom$1(currentAddSelection), j = () => {
7651
+ }, [v, C] = useAtom$1(currentAddSelection), E = () => {
7952
7652
  var L;
7953
- C(), o.parent.isSelected || k((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7954
- }, C = () => {
7955
- k(null);
7956
- }, v = (L) => {
7957
- C(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), _(L);
7653
+ S(), o.parent.isSelected || C((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7654
+ }, S = () => {
7655
+ C(null);
7656
+ }, k = (L) => {
7657
+ S(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(L);
7958
7658
  };
7959
7659
  useEffect(() => {
7960
7660
  const L = setTimeout(() => {
@@ -7962,13 +7662,13 @@ const Input = ({ node: o }) => {
7962
7662
  }, 500);
7963
7663
  return () => clearTimeout(L);
7964
7664
  }, [y, o, b]);
7965
- const B = (L, D) => {
7665
+ const j = (L, D) => {
7966
7666
  const R = c.contentDocument || c.contentWindow.document, M = R.querySelector(`[data-block-id=${L}]`);
7967
7667
  M && M.setAttribute("data-drop", D);
7968
7668
  const $ = M.getBoundingClientRect(), O = c.getBoundingClientRect();
7969
7669
  $.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (R.documentElement.scrollTop = M.offsetTop - O.top);
7970
7670
  }, I = (L) => {
7971
- C();
7671
+ S();
7972
7672
  const D = get(o, "parent.id");
7973
7673
  D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: L }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: L });
7974
7674
  };
@@ -7996,20 +7696,20 @@ const Input = ({ node: o }) => {
7996
7696
  {
7997
7697
  onMouseEnter: () => g(m),
7998
7698
  onMouseLeave: () => h(),
7999
- onClick: v,
7699
+ onClick: k,
8000
7700
  style: r,
8001
7701
  "data-node-id": m,
8002
7702
  ref: l.includes(m) ? null : n,
8003
7703
  onDragStart: () => N(o),
8004
- onDragEnd: () => w(o),
7704
+ onDragEnd: () => A(o),
8005
7705
  onDragOver: (L) => {
8006
- L.preventDefault(), B(m, "yes");
7706
+ L.preventDefault(), j(m, "yes");
8007
7707
  },
8008
7708
  onDragLeave: (L) => {
8009
- L.preventDefault(), B(m, "no");
7709
+ L.preventDefault(), j(m, "no");
8010
7710
  },
8011
7711
  onDrop: (L) => {
8012
- L.preventDefault(), B(m, "no");
7712
+ L.preventDefault(), j(m, "no");
8013
7713
  },
8014
7714
  children: [
8015
7715
  d(PERMISSIONS.ADD_BLOCK) && (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
@@ -8018,8 +7718,8 @@ const Input = ({ node: o }) => {
8018
7718
  onClick: (L) => {
8019
7719
  L.stopPropagation(), I(o.childIndex);
8020
7720
  },
8021
- onMouseEnter: j,
8022
- onMouseLeave: C,
7721
+ onMouseEnter: E,
7722
+ onMouseLeave: S,
8023
7723
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
8024
7724
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-primary p-1 outline outline-2 outline-white hover:bg-primary", children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3 stroke-[4] text-white" }) })
8025
7725
  }
@@ -8031,7 +7731,7 @@ const Input = ({ node: o }) => {
8031
7731
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
8032
7732
  f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
8033
7733
  y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
8034
- (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7734
+ (o == null ? void 0 : o.id) === v ? "bg-primary/10" : "",
8035
7735
  b && "opacity-20",
8036
7736
  l.includes(m) ? "opacity-50" : "",
8037
7737
  T && f && "bg-primary/20 text-primary"
@@ -8042,7 +7742,7 @@ const Input = ({ node: o }) => {
8042
7742
  "div",
8043
7743
  {
8044
7744
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
8045
- children: u && /* @__PURE__ */ jsx("button", { onClick: E, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
7745
+ children: u && /* @__PURE__ */ jsx("button", { onClick: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
8046
7746
  }
8047
7747
  ),
8048
7748
  /* @__PURE__ */ jsxs(
@@ -8055,7 +7755,7 @@ const Input = ({ node: o }) => {
8055
7755
  ),
8056
7756
  children: [
8057
7757
  /* @__PURE__ */ jsx(TypeIcon, { type: x == null ? void 0 : x._type }),
8058
- A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
7758
+ w ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsx(
8059
7759
  "div",
8060
7760
  {
8061
7761
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
@@ -8526,23 +8226,23 @@ const Input = ({ node: o }) => {
8526
8226
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8527
8227
  const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
8528
8228
  if (d) {
8529
- const w = d.map((S) => Object.keys(S)[0]);
8530
- DEFAULT_THEME_PRESET.forEach((S) => {
8531
- const k = Object.keys(S)[0];
8532
- w.includes(k) || d.push(S);
8229
+ const A = d.map((v) => Object.keys(v)[0]);
8230
+ DEFAULT_THEME_PRESET.forEach((v) => {
8231
+ const C = Object.keys(v)[0];
8232
+ A.includes(C) || d.push(v);
8533
8233
  });
8534
8234
  }
8535
8235
  const [g, h] = useTheme(), m = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
8536
- (w) => {
8537
- const S = { ...g };
8538
- setPreviousTheme(S), h(w), toast.success("Theme updated", {
8236
+ (A) => {
8237
+ const v = { ...g };
8238
+ setPreviousTheme(v), h(A), toast.success("Theme updated", {
8539
8239
  action: {
8540
8240
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8541
8241
  /* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
8542
8242
  " Undo"
8543
8243
  ] }),
8544
8244
  onClick: () => {
8545
- h(S), clearPreviousTheme(), toast.dismiss();
8245
+ h(v), clearPreviousTheme(), toast.dismiss();
8546
8246
  }
8547
8247
  },
8548
8248
  closeButton: !0,
@@ -8551,61 +8251,61 @@ const Input = ({ node: o }) => {
8551
8251
  },
8552
8252
  [g, h]
8553
8253
  ), y = () => {
8554
- const w = d.find((S) => Object.keys(S)[0] === a);
8555
- if (w) {
8556
- const S = Object.values(w)[0];
8557
- S && typeof S == "object" && "fontFamily" in S && "borderRadius" in S && "colors" in S ? (f(S), l("")) : console.error("Invalid preset structure:", S);
8254
+ const A = d.find((v) => Object.keys(v)[0] === a);
8255
+ if (A) {
8256
+ const v = Object.values(A)[0];
8257
+ v && typeof v == "object" && "fontFamily" in v && "borderRadius" in v && "colors" in v ? (f(v), l("")) : console.error("Invalid preset structure:", v);
8558
8258
  } else
8559
8259
  console.error("Preset not found:", a);
8560
- }, b = (w) => {
8561
- f(w), l("");
8562
- }, A = useDebouncedCallback(
8563
- (w, S) => {
8260
+ }, b = (A) => {
8261
+ f(A), l("");
8262
+ }, w = useDebouncedCallback(
8263
+ (A, v) => {
8564
8264
  h(() => ({
8565
8265
  ...g,
8566
8266
  fontFamily: {
8567
8267
  ...g.fontFamily,
8568
- [w.replace(/font-/g, "")]: S
8268
+ [A.replace(/font-/g, "")]: v
8569
8269
  }
8570
8270
  }));
8571
8271
  },
8572
8272
  [g],
8573
8273
  200
8574
- ), _ = React.useCallback(
8575
- (w) => {
8274
+ ), B = React.useCallback(
8275
+ (A) => {
8576
8276
  h(() => ({
8577
8277
  ...g,
8578
- borderRadius: `${w}px`
8278
+ borderRadius: `${A}px`
8579
8279
  }));
8580
8280
  },
8581
8281
  [g]
8582
- ), E = useDebouncedCallback(
8583
- (w, S) => {
8282
+ ), _ = useDebouncedCallback(
8283
+ (A, v) => {
8584
8284
  h(() => {
8585
- const k = get(g, `colors.${w}`);
8586
- return r ? set(k, 1, S) : set(k, 0, S), {
8285
+ const C = get(g, `colors.${A}`);
8286
+ return r ? set(C, 1, v) : set(C, 0, v), {
8587
8287
  ...g,
8588
8288
  colors: {
8589
8289
  ...g.colors,
8590
- [w]: k
8290
+ [A]: C
8591
8291
  }
8592
8292
  };
8593
8293
  });
8594
8294
  },
8595
8295
  [g],
8596
8296
  200
8597
- ), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([S]) => {
8598
- const k = get(g, `colors.${S}.${r ? 1 : 0}`);
8599
- return k ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8297
+ ), N = (A) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(A.items).map(([v]) => {
8298
+ const C = get(g, `colors.${v}.${r ? 1 : 0}`);
8299
+ return C ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
8600
8300
  /* @__PURE__ */ jsx(
8601
8301
  ColorPickerInput,
8602
8302
  {
8603
- value: k,
8604
- onChange: (j) => E(S, j)
8303
+ value: C,
8304
+ onChange: (E) => _(v, E)
8605
8305
  }
8606
8306
  ),
8607
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: S.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((j) => j.charAt(0).toUpperCase() + j.slice(1)).join(" ") + (!S.toLowerCase().includes("foreground") && !S.toLowerCase().includes("border") && !S.toLowerCase().includes("input") && !S.toLowerCase().includes("ring") && !S.toLowerCase().includes("background") ? " Background" : "") })
8608
- ] }, S) : null;
8307
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: v.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((E) => E.charAt(0).toUpperCase() + E.slice(1)).join(" ") + (!v.toLowerCase().includes("foreground") && !v.toLowerCase().includes("border") && !v.toLowerCase().includes("input") && !v.toLowerCase().includes("ring") && !v.toLowerCase().includes("background") ? " Background" : "") })
8308
+ ] }, v) : null;
8609
8309
  }) });
8610
8310
  return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8611
8311
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -8620,9 +8320,9 @@ const Input = ({ node: o }) => {
8620
8320
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2 px-0", children: [
8621
8321
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8622
8322
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8623
- /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8624
- const S = Object.keys(w)[0], k = S.replaceAll("_", " ");
8625
- return /* @__PURE__ */ jsx(SelectItem, { value: S, children: capitalize(k) }, S);
8323
+ /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((A) => {
8324
+ const v = Object.keys(A)[0], C = v.replaceAll("_", " ");
8325
+ return /* @__PURE__ */ jsx(SelectItem, { value: v, children: capitalize(C) }, v);
8626
8326
  }) })
8627
8327
  ] }) }),
8628
8328
  /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: x("Apply") }) })
@@ -8634,14 +8334,14 @@ const Input = ({ node: o }) => {
8634
8334
  /* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
8635
8335
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8636
8336
  ] }),
8637
- (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, S]) => /* @__PURE__ */ jsx(
8337
+ (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([A, v]) => /* @__PURE__ */ jsx(
8638
8338
  FontSelector,
8639
8339
  {
8640
- label: w,
8641
- value: g.fontFamily[w.replace(/font-/g, "")] || S[Object.keys(S)[0]],
8642
- onChange: (k) => A(w, k)
8340
+ label: A,
8341
+ value: g.fontFamily[A.replace(/font-/g, "")] || v[Object.keys(v)[0]],
8342
+ onChange: (C) => w(A, C)
8643
8343
  },
8644
- w
8344
+ A
8645
8345
  )) }),
8646
8346
  /* @__PURE__ */ jsx(Separator, {}),
8647
8347
  (m == null ? void 0 : m.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5", children: [
@@ -8652,7 +8352,7 @@ const Input = ({ node: o }) => {
8652
8352
  ] }),
8653
8353
  /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
8654
8354
  ] }),
8655
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: _ }) })
8355
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: B }) })
8656
8356
  ] }),
8657
8357
  /* @__PURE__ */ jsx(Separator, {}),
8658
8358
  (m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
@@ -8667,7 +8367,7 @@ const Input = ({ node: o }) => {
8667
8367
  Switch,
8668
8368
  {
8669
8369
  checked: r,
8670
- onCheckedChange: (w) => n(w),
8370
+ onCheckedChange: (A) => n(A),
8671
8371
  "aria-label": "Toggle dark mode",
8672
8372
  className: "mx-1"
8673
8373
  }
@@ -8675,7 +8375,7 @@ const Input = ({ node: o }) => {
8675
8375
  /* @__PURE__ */ jsx(Moon, { className: "h-4 w-4" })
8676
8376
  ] }) })
8677
8377
  ] }),
8678
- /* @__PURE__ */ jsx("div", { className: "space-y-2", children: m.colors.map((w) => N(w)) })
8378
+ /* @__PURE__ */ jsx("div", { className: "space-y-2", children: m.colors.map((A) => N(A)) })
8679
8379
  ] }),
8680
8380
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: i && /* @__PURE__ */ jsx(
8681
8381
  LazyCssImportModal,
@@ -9298,26 +8998,26 @@ function AIChatPanel() {
9298
8998
  content: n,
9299
8999
  timestamp: /* @__PURE__ */ new Date()
9300
9000
  };
9301
- r((A) => [...A, b]), a(""), i(!0), setTimeout(() => {
9302
- const A = {
9001
+ r((w) => [...w, b]), a(""), i(!0), setTimeout(() => {
9002
+ const w = {
9303
9003
  id: (Date.now() + 1).toString(),
9304
9004
  role: "assistant",
9305
9005
  content: "This is a sample response from the AI assistant. In a real implementation, this would be replaced with an actual response from the AI model.",
9306
9006
  timestamp: /* @__PURE__ */ new Date()
9307
9007
  };
9308
- r((_) => [..._, A]), i(!1), d(null);
9008
+ r((B) => [...B, w]), i(!1), d(null);
9309
9009
  }, 1500);
9310
9010
  }, m = (b) => {
9311
9011
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
9312
9012
  }, x = (b) => {
9313
- var _;
9314
- const A = (_ = b.target.files) == null ? void 0 : _[0];
9315
- if (A) {
9316
- const E = new FileReader();
9317
- E.onload = (N) => {
9318
- var w;
9319
- d((w = N.target) == null ? void 0 : w.result);
9320
- }, E.readAsDataURL(A);
9013
+ var B;
9014
+ const w = (B = b.target.files) == null ? void 0 : B[0];
9015
+ if (w) {
9016
+ const _ = new FileReader();
9017
+ _.onload = (N) => {
9018
+ var A;
9019
+ d((A = N.target) == null ? void 0 : A.result);
9020
+ }, _.readAsDataURL(w);
9321
9021
  }
9322
9022
  }, f = () => {
9323
9023
  var b;
@@ -9521,43 +9221,43 @@ const AiAssistant = () => {
9521
9221
  return;
9522
9222
  }
9523
9223
  if (i) {
9524
- const S = [...a, { key: i, value: d }];
9525
- n(S), l(a), c(""), p(""), m("");
9224
+ const v = [...a, { key: i, value: d }];
9225
+ n(v), l(a), c(""), p(""), m("");
9526
9226
  }
9527
- }, A = (S) => {
9528
- const k = a.filter((j, C) => C !== S);
9529
- n(k), l(k);
9530
- }, _ = (S) => {
9531
- g(S), c(a[S].key), p(a[S].value);
9532
- }, E = () => {
9227
+ }, w = (v) => {
9228
+ const C = a.filter((E, S) => S !== v);
9229
+ n(C), l(C);
9230
+ }, B = (v) => {
9231
+ g(v), c(a[v].key), p(a[v].value);
9232
+ }, _ = () => {
9533
9233
  if (i.startsWith("@")) {
9534
9234
  m("Attribute keys cannot start with '@'");
9535
9235
  return;
9536
9236
  }
9537
9237
  if (u !== null && i) {
9538
- const S = [...a];
9539
- S[u] = { key: i, value: d }, n(S), l(S), g(null), c(""), p(""), m("");
9238
+ const v = [...a];
9239
+ v[u] = { key: i, value: d }, n(v), l(v), g(null), c(""), p(""), m("");
9540
9240
  }
9541
- }, N = (S) => {
9542
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? E() : b());
9543
- }, w = useCallback((S) => {
9544
- const k = (v) => /[.,!?;:]/.test(v), j = (v, B, I) => {
9241
+ }, N = (v) => {
9242
+ v.key === "Enter" && !v.shiftKey && (v.preventDefault(), u !== null ? _() : b());
9243
+ }, A = useCallback((v) => {
9244
+ const C = (k) => /[.,!?;:]/.test(k), E = (k, j, I) => {
9545
9245
  let T = "", P = "";
9546
- const L = B > 0 ? v[B - 1] : "", D = B < v.length ? v[B] : "";
9547
- return B > 0 && (L === "." || !k(L) && L !== " ") && (T = " "), B < v.length && !k(D) && D !== " " && (P = " "), {
9246
+ const L = j > 0 ? k[j - 1] : "", D = j < k.length ? k[j] : "";
9247
+ return j > 0 && (L === "." || !C(L) && L !== " ") && (T = " "), j < k.length && !C(D) && D !== " " && (P = " "), {
9548
9248
  text: T + I + P,
9549
9249
  prefixLength: T.length,
9550
9250
  suffixLength: P.length
9551
9251
  };
9552
- }, C = f.current;
9553
- if (C) {
9554
- const v = C.selectionStart || 0, B = C.value || "", I = C.selectionEnd || v;
9555
- if (I > v) {
9556
- const R = `{{${S}}}`, { text: M } = j(B, v, R), $ = B.slice(0, v) + M + B.slice(I);
9252
+ }, S = f.current;
9253
+ if (S) {
9254
+ const k = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || k;
9255
+ if (I > k) {
9256
+ const R = `{{${v}}}`, { text: M } = E(j, k, R), $ = j.slice(0, k) + M + j.slice(I);
9557
9257
  p($);
9558
9258
  return;
9559
9259
  }
9560
- const P = `{{${S}}}`, { text: L } = j(B, v, P), D = B.slice(0, v) + L + B.slice(v);
9260
+ const P = `{{${v}}}`, { text: L } = E(j, k, P), D = j.slice(0, k) + L + j.slice(k);
9561
9261
  p(D);
9562
9262
  }
9563
9263
  }, []);
@@ -9565,8 +9265,8 @@ const AiAssistant = () => {
9565
9265
  /* @__PURE__ */ jsxs(
9566
9266
  "form",
9567
9267
  {
9568
- onSubmit: (S) => {
9569
- S.preventDefault(), u !== null ? E() : b();
9268
+ onSubmit: (v) => {
9269
+ v.preventDefault(), u !== null ? _() : b();
9570
9270
  },
9571
9271
  className: "space-y-3",
9572
9272
  children: [
@@ -9582,7 +9282,7 @@ const AiAssistant = () => {
9582
9282
  id: "attrKey",
9583
9283
  ref: x,
9584
9284
  value: i,
9585
- onChange: (S) => c(S.target.value),
9285
+ onChange: (v) => c(v.target.value),
9586
9286
  placeholder: "Enter Key",
9587
9287
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9588
9288
  }
@@ -9591,7 +9291,7 @@ const AiAssistant = () => {
9591
9291
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9592
9292
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9593
9293
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9594
- !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9294
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: A })
9595
9295
  ] }),
9596
9296
  /* @__PURE__ */ jsx(
9597
9297
  Textarea,
@@ -9603,7 +9303,7 @@ const AiAssistant = () => {
9603
9303
  rows: 2,
9604
9304
  ref: f,
9605
9305
  value: d,
9606
- onChange: (S) => p(S.target.value),
9306
+ onChange: (v) => p(v.target.value),
9607
9307
  onKeyDown: N,
9608
9308
  placeholder: "Enter Value",
9609
9309
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9616,16 +9316,16 @@ const AiAssistant = () => {
9616
9316
  ]
9617
9317
  }
9618
9318
  ),
9619
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, k) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9319
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((v, C) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
9620
9320
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
9621
- /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
9622
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: S.value.toString() })
9321
+ /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: v.key }),
9322
+ /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: v.value.toString() })
9623
9323
  ] }),
9624
9324
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
9625
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(k), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9626
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(k), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9325
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(C), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9326
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => w(C), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9627
9327
  ] })
9628
- ] }, k)) })
9328
+ ] }, C)) })
9629
9329
  ] });
9630
9330
  }), BlockAttributesEditor = React.memo(() => {
9631
9331
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9787,38 +9487,38 @@ const RootLayout = () => {
9787
9487
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9788
9488
  n("outline");
9789
9489
  });
9790
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = reverse([...g ?? []]), m = useCallback((k) => {
9791
- k.preventDefault();
9490
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = reverse([...g ?? []]), m = useCallback((C) => {
9491
+ C.preventDefault();
9792
9492
  }, []), x = useCallback(
9793
- (k) => {
9794
- n(r === k ? null : k);
9493
+ (C) => {
9494
+ n(r === C ? null : C);
9795
9495
  },
9796
9496
  [r]
9797
9497
  ), { t: f } = useTranslation(), y = useMemo(
9798
9498
  () => [...p, ...u, ...g],
9799
9499
  [p, u, g]
9800
- ), b = useBuilderProp("htmlDir", "ltr"), A = find(y, { id: r }) ?? first(y), _ = get(A, "width", DEFAULT_PANEL_WIDTH);
9500
+ ), b = useBuilderProp("htmlDir", "ltr"), w = find(y, { id: r }) ?? first(y), B = get(w, "width", DEFAULT_PANEL_WIDTH);
9801
9501
  useEffect(() => {
9802
9502
  if (r !== null) {
9803
- const k = find(y, { id: r });
9804
- k && get(k, "view", "standard") === "standard" && (a.current = r, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
9503
+ const C = find(y, { id: r });
9504
+ C && get(C, "view", "standard") === "standard" && (a.current = r, i(get(C, "width", DEFAULT_PANEL_WIDTH)));
9805
9505
  }
9806
9506
  }, [r, y]);
9807
- const E = useMemo(() => {
9507
+ const _ = useMemo(() => {
9808
9508
  if (r === null) return 0;
9809
- const k = find(y, { id: r });
9810
- return get(k, "view", "standard") === "standard" ? _ : l;
9811
- }, [r, _, l, y]), N = useCallback(() => {
9509
+ const C = find(y, { id: r });
9510
+ return get(C, "view", "standard") === "standard" ? B : l;
9511
+ }, [r, B, l, y]), N = useCallback(() => {
9812
9512
  n(a.current);
9813
- }, [n]), w = useCallback(() => {
9513
+ }, [n]), A = useCallback(() => {
9814
9514
  n("outline");
9815
9515
  }, [n]);
9816
9516
  useEffect(() => {
9817
9517
  find(y, { id: r }) || n("outline");
9818
9518
  }, [r, y]);
9819
- const S = useCallback(
9820
- (k) => {
9821
- x(k);
9519
+ const v = useCallback(
9520
+ (C) => {
9521
+ x(C);
9822
9522
  },
9823
9523
  [x]
9824
9524
  );
@@ -9832,43 +9532,43 @@ const RootLayout = () => {
9832
9532
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9833
9533
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9834
9534
  /* @__PURE__ */ jsxs("div", { id: "sidebar", className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9835
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((k, j) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9836
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9535
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-y-1", children: [p, u].flat().map((C, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9536
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9837
9537
  position: "top",
9838
- panelId: k.id,
9839
- isActive: r === k.id,
9840
- show: () => S(k.id)
9538
+ panelId: C.id,
9539
+ isActive: r === C.id,
9540
+ show: () => v(C.id)
9841
9541
  }) }),
9842
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9843
- ] }, "button-top-" + j)) }),
9542
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(C.label) }) })
9543
+ ] }, "button-top-" + E)) }),
9844
9544
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9845
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h == null ? void 0 : h.map((k, j) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9846
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(k, "button", NoopComponent), {
9545
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: h == null ? void 0 : h.map((C, E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9546
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(C, "button", NoopComponent), {
9847
9547
  position: "bottom",
9848
- panelId: k.id,
9849
- isActive: r === k.id,
9850
- show: () => S(k.id)
9548
+ panelId: C.id,
9549
+ isActive: r === C.id,
9550
+ show: () => v(C.id)
9851
9551
  }) }),
9852
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9853
- ] }, "button-bottom-" + j)) })
9552
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(C.label) }) })
9553
+ ] }, "button-bottom-" + E)) })
9854
9554
  ] }),
9855
9555
  /* @__PURE__ */ jsx(
9856
9556
  motion.div,
9857
9557
  {
9858
9558
  id: "left-panel",
9859
9559
  className: "h-full max-h-full border-r border-border",
9860
- initial: { width: E },
9861
- animate: { width: E },
9560
+ initial: { width: _ },
9561
+ animate: { width: _ },
9862
9562
  transition: { duration: 0.3, ease: "easeInOut" },
9863
- children: r !== null && get(A, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9563
+ children: r !== null && get(w, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
9864
9564
  /* @__PURE__ */ jsx(
9865
9565
  "div",
9866
9566
  {
9867
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(A, "isInternal", !1) ? "" : "w-64"}`,
9868
- children: /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9567
+ className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(w, "isInternal", !1) ? "" : "w-64"}`,
9568
+ children: /* @__PURE__ */ jsx("span", { children: f(get(w, "label", "")) })
9869
9569
  }
9870
9570
  ),
9871
- /* @__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(A, "panel", NoopComponent), {}) }) })
9571
+ /* @__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(w, "panel", NoopComponent), {}) }) })
9872
9572
  ] })
9873
9573
  }
9874
9574
  ),
@@ -9914,34 +9614,34 @@ const RootLayout = () => {
9914
9614
  }
9915
9615
  ),
9916
9616
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9917
- r !== null && get(A, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(
9617
+ r !== null && get(w, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(
9918
9618
  SheetContent,
9919
9619
  {
9920
9620
  side: "left",
9921
9621
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9922
- style: { width: `${_}px` },
9622
+ style: { width: `${B}px` },
9923
9623
  children: [
9924
9624
  /* @__PURE__ */ jsx(SheetHeader, { className: "border-b border-border px-2 py-2.5", children: /* @__PURE__ */ jsxs(SheetTitle, { className: "flex items-center gap-2", children: [
9925
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(A, "icon", null) }),
9926
- /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9625
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(w, "icon", null) }),
9626
+ /* @__PURE__ */ jsx("span", { children: f(get(w, "label", "")) })
9927
9627
  ] }) }),
9928
- /* @__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(A, "panel", NoopComponent), {
9929
- close: w
9628
+ /* @__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(w, "panel", NoopComponent), {
9629
+ close: A
9930
9630
  }) }) })
9931
9631
  ]
9932
9632
  }
9933
9633
  ) }),
9934
9634
  " ",
9935
- r !== null && get(A, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${_}px` }, children: [
9635
+ r !== null && get(w, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${B}px` }, children: [
9936
9636
  /* @__PURE__ */ jsx(DialogHeader, { className: "border-b border-border px-2 py-3.5", children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center gap-2", children: [
9937
- /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(A, "icon", null) }),
9938
- /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9637
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(w, "icon", null) }),
9638
+ /* @__PURE__ */ jsx("span", { children: f(get(w, "label", "")) })
9939
9639
  ] }) }),
9940
- /* @__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(A, "panel", NoopComponent), {
9941
- close: w
9640
+ /* @__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(w, "panel", NoopComponent), {
9641
+ close: A
9942
9642
  }) }) })
9943
9643
  ] }) }),
9944
- r !== null && get(A, "view") === "overlay" && /* @__PURE__ */ jsx(
9644
+ r !== null && get(w, "view") === "overlay" && /* @__PURE__ */ jsx(
9945
9645
  motion.div,
9946
9646
  {
9947
9647
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -9960,13 +9660,13 @@ const RootLayout = () => {
9960
9660
  children: [
9961
9661
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9962
9662
  /* @__PURE__ */ jsxs("div", { className: "-ml-2 flex items-center gap-2 text-lg font-bold", children: [
9963
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(A, "icon", null) }),
9964
- /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9663
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(w, "icon", null) }),
9664
+ /* @__PURE__ */ jsx("span", { children: f(get(w, "label", "")) })
9965
9665
  ] }),
9966
9666
  /* @__PURE__ */ jsx(Button, { onClick: () => N(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9967
9667
  ] }),
9968
- /* @__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(A, "panel", NoopComponent), {
9969
- close: w
9668
+ /* @__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(w, "panel", NoopComponent), {
9669
+ close: A
9970
9670
  }) }) })
9971
9671
  ]
9972
9672
  }
@@ -10008,8 +9708,8 @@ const RootLayout = () => {
10008
9708
  const f = l.toLowerCase();
10009
9709
  return Object.fromEntries(
10010
9710
  Object.entries(a).filter(([y, b]) => {
10011
- var A;
10012
- return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
9711
+ var w;
9712
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((w = b == null ? void 0 : b.description) == null ? void 0 : w.toLowerCase().includes(f));
10013
9713
  })
10014
9714
  );
10015
9715
  }, [a, l]), h = (f) => {
@@ -10019,8 +9719,8 @@ const RootLayout = () => {
10019
9719
  });
10020
9720
  }, m = (f) => {
10021
9721
  if (!c) return;
10022
- const y = f.clientX - p.x, b = f.clientY - p.y, A = f.currentTarget, _ = A.offsetWidth, E = A.offsetHeight, N = window.innerWidth - _, w = window.innerHeight - E, S = Math.max(0, Math.min(y, N)), k = Math.max(0, Math.min(b, w));
10023
- n(S, k);
9722
+ const y = f.clientX - p.x, b = f.clientY - p.y, w = f.currentTarget, B = w.offsetWidth, _ = w.offsetHeight, N = window.innerWidth - B, A = window.innerHeight - _, v = Math.max(0, Math.min(y, N)), C = Math.max(0, Math.min(b, A));
9723
+ n(v, C);
10024
9724
  }, x = () => {
10025
9725
  d(!1);
10026
9726
  };
@@ -10197,71 +9897,71 @@ const RootLayout = () => {
10197
9897
  var f;
10198
9898
  return (f = m.onMount) == null ? void 0 : f.call(m, x);
10199
9899
  }, ...h) => {
10200
- const m = h[0] || ((k) => {
10201
- let j = o.get(k);
10202
- return j || (j = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(k, j), u == null || u(k, S)), j;
9900
+ const m = h[0] || ((C) => {
9901
+ let E = o.get(C);
9902
+ return E || (E = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, E), u == null || u(C, v)), E;
10203
9903
  }), x = h[1] || (() => {
10204
- const k = [], j = (C) => {
9904
+ const C = [], E = (S) => {
10205
9905
  try {
10206
- C();
10207
- } catch (v) {
10208
- k.push(v);
9906
+ S();
9907
+ } catch (k) {
9908
+ C.push(k);
10209
9909
  }
10210
9910
  };
10211
9911
  do {
10212
- c.f && j(c.f);
10213
- const C = /* @__PURE__ */ new Set(), v = C.add.bind(C);
10214
- a.forEach((B) => {
9912
+ c.f && E(c.f);
9913
+ const S = /* @__PURE__ */ new Set(), k = S.add.bind(S);
9914
+ a.forEach((j) => {
10215
9915
  var I;
10216
- return (I = r.get(B)) == null ? void 0 : I.l.forEach(v);
10217
- }), a.clear(), i.forEach(v), i.clear(), l.forEach(v), l.clear(), C.forEach(j), a.size && f();
9916
+ return (I = r.get(j)) == null ? void 0 : I.l.forEach(k);
9917
+ }), a.clear(), i.forEach(k), i.clear(), l.forEach(k), l.clear(), S.forEach(E), a.size && f();
10218
9918
  } while (a.size || i.size || l.size);
10219
- if (k.length)
10220
- throw new AggregateError(k);
9919
+ if (C.length)
9920
+ throw new AggregateError(C);
10221
9921
  }), f = h[2] || (() => {
10222
- const k = [], j = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
10223
- for (; v.length; ) {
10224
- const B = v[v.length - 1], I = m(B);
10225
- if (C.has(B)) {
10226
- v.pop();
9922
+ const C = [], E = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9923
+ for (; k.length; ) {
9924
+ const j = k[k.length - 1], I = m(j);
9925
+ if (S.has(j)) {
9926
+ k.pop();
10227
9927
  continue;
10228
9928
  }
10229
- if (j.has(B)) {
10230
- n.get(B) === I.n && k.push([B, I]), C.add(B), v.pop();
9929
+ if (E.has(j)) {
9930
+ n.get(j) === I.n && C.push([j, I]), S.add(j), k.pop();
10231
9931
  continue;
10232
9932
  }
10233
- j.add(B);
10234
- for (const T of getMountedOrPendingDependents(B, I, r))
10235
- j.has(T) || v.push(T);
9933
+ E.add(j);
9934
+ for (const T of getMountedOrPendingDependents(j, I, r))
9935
+ E.has(T) || k.push(T);
10236
9936
  }
10237
- for (let B = k.length - 1; B >= 0; --B) {
10238
- const [I, T] = k[B];
9937
+ for (let j = C.length - 1; j >= 0; --j) {
9938
+ const [I, T] = C[j];
10239
9939
  let P = !1;
10240
9940
  for (const L of T.d.keys())
10241
9941
  if (L !== I && a.has(L)) {
10242
9942
  P = !0;
10243
9943
  break;
10244
9944
  }
10245
- P && (y(I), _(I)), n.delete(I);
9945
+ P && (y(I), B(I)), n.delete(I);
10246
9946
  }
10247
- }), y = h[3] || ((k) => {
10248
- var j;
10249
- const C = m(k);
10250
- if (isAtomStateInitialized(C) && (r.has(k) && n.get(k) !== C.n || Array.from(C.d).every(
9947
+ }), y = h[3] || ((C) => {
9948
+ var E;
9949
+ const S = m(C);
9950
+ if (isAtomStateInitialized(S) && (r.has(C) && n.get(C) !== S.n || Array.from(S.d).every(
10251
9951
  ([R, M]) => (
10252
9952
  // Recursively, read the atom state of the dependency, and
10253
9953
  // check if the atom epoch number is unchanged
10254
9954
  y(R).n === M
10255
9955
  )
10256
9956
  )))
10257
- return C;
10258
- C.d.clear();
10259
- let v = !0;
10260
- const B = () => {
10261
- r.has(k) && (_(k), f(), x());
9957
+ return S;
9958
+ S.d.clear();
9959
+ let k = !0;
9960
+ const j = () => {
9961
+ r.has(C) && (B(C), f(), x());
10262
9962
  }, I = (R) => {
10263
9963
  var M;
10264
- if (isSelfAtom(k, R)) {
9964
+ if (isSelfAtom(C, R)) {
10265
9965
  const O = m(R);
10266
9966
  if (!isAtomStateInitialized(O))
10267
9967
  if (hasInitialValue(R))
@@ -10274,7 +9974,7 @@ const RootLayout = () => {
10274
9974
  try {
10275
9975
  return returnAtomValue($);
10276
9976
  } finally {
10277
- C.d.set(R, $.n), isPendingPromise(C.v) && addPendingPromiseToDependency(k, C.v, $), (M = r.get(R)) == null || M.t.add(k), v || B();
9977
+ S.d.set(R, $.n), isPendingPromise(S.v) && addPendingPromiseToDependency(C, S.v, $), (M = r.get(R)) == null || M.t.add(C), k || j();
10278
9978
  }
10279
9979
  };
10280
9980
  let T, P;
@@ -10283,100 +9983,100 @@ const RootLayout = () => {
10283
9983
  return T || (T = new AbortController()), T.signal;
10284
9984
  },
10285
9985
  get setSelf() {
10286
- return !P && isActuallyWritableAtom(k) && (P = (...R) => {
10287
- if (!v)
9986
+ return !P && isActuallyWritableAtom(C) && (P = (...R) => {
9987
+ if (!k)
10288
9988
  try {
10289
- return A(k, ...R);
9989
+ return w(C, ...R);
10290
9990
  } finally {
10291
9991
  f(), x();
10292
9992
  }
10293
9993
  }), P;
10294
9994
  }
10295
- }, D = C.n;
9995
+ }, D = S.n;
10296
9996
  try {
10297
- const R = d(k, I, L);
10298
- return setAtomStateValueOrPromise(k, R, m), isPromiseLike$1(R) && (registerAbortHandler(R, () => T == null ? void 0 : T.abort()), R.then(
10299
- B,
10300
- B
10301
- )), C;
9997
+ const R = d(C, I, L);
9998
+ return setAtomStateValueOrPromise(C, R, m), isPromiseLike$1(R) && (registerAbortHandler(R, () => T == null ? void 0 : T.abort()), R.then(
9999
+ j,
10000
+ j
10001
+ )), S;
10302
10002
  } catch (R) {
10303
- return delete C.v, C.e = R, ++C.n, C;
10003
+ return delete S.v, S.e = R, ++S.n, S;
10304
10004
  } finally {
10305
- v = !1, D !== C.n && n.get(k) === D && (n.set(k, C.n), a.add(k), (j = c.c) == null || j.call(c, k));
10005
+ k = !1, D !== S.n && n.get(C) === D && (n.set(C, S.n), a.add(C), (E = c.c) == null || E.call(c, C));
10306
10006
  }
10307
- }), b = h[4] || ((k) => {
10308
- const j = [k];
10309
- for (; j.length; ) {
10310
- const C = j.pop(), v = m(C);
10311
- for (const B of getMountedOrPendingDependents(C, v, r)) {
10312
- const I = m(B);
10313
- n.set(B, I.n), j.push(B);
10007
+ }), b = h[4] || ((C) => {
10008
+ const E = [C];
10009
+ for (; E.length; ) {
10010
+ const S = E.pop(), k = m(S);
10011
+ for (const j of getMountedOrPendingDependents(S, k, r)) {
10012
+ const I = m(j);
10013
+ n.set(j, I.n), E.push(j);
10314
10014
  }
10315
10015
  }
10316
- }), A = h[5] || ((k, ...j) => {
10317
- let C = !0;
10318
- const v = (I) => returnAtomValue(y(I)), B = (I, ...T) => {
10016
+ }), w = h[5] || ((C, ...E) => {
10017
+ let S = !0;
10018
+ const k = (I) => returnAtomValue(y(I)), j = (I, ...T) => {
10319
10019
  var P;
10320
10020
  const L = m(I);
10321
10021
  try {
10322
- if (isSelfAtom(k, I)) {
10022
+ if (isSelfAtom(C, I)) {
10323
10023
  if (!hasInitialValue(I))
10324
10024
  throw new Error("atom not writable");
10325
10025
  const D = L.n, R = T[0];
10326
- setAtomStateValueOrPromise(I, R, m), _(I), D !== L.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
10026
+ setAtomStateValueOrPromise(I, R, m), B(I), D !== L.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
10327
10027
  return;
10328
10028
  } else
10329
- return A(I, ...T);
10029
+ return w(I, ...T);
10330
10030
  } finally {
10331
- C || (f(), x());
10031
+ S || (f(), x());
10332
10032
  }
10333
10033
  };
10334
10034
  try {
10335
- return p(k, v, B, ...j);
10035
+ return p(C, k, j, ...E);
10336
10036
  } finally {
10337
- C = !1;
10037
+ S = !1;
10338
10038
  }
10339
- }), _ = h[6] || ((k) => {
10340
- var j;
10341
- const C = m(k), v = r.get(k);
10342
- if (v && !isPendingPromise(C.v)) {
10343
- for (const [B, I] of C.d)
10344
- if (!v.d.has(B)) {
10345
- const T = m(B);
10346
- E(B).t.add(k), v.d.add(B), I !== T.n && (a.add(B), (j = c.c) == null || j.call(c, B), b(B));
10039
+ }), B = h[6] || ((C) => {
10040
+ var E;
10041
+ const S = m(C), k = r.get(C);
10042
+ if (k && !isPendingPromise(S.v)) {
10043
+ for (const [j, I] of S.d)
10044
+ if (!k.d.has(j)) {
10045
+ const T = m(j);
10046
+ _(j).t.add(C), k.d.add(j), I !== T.n && (a.add(j), (E = c.c) == null || E.call(c, j), b(j));
10347
10047
  }
10348
- for (const B of v.d || [])
10349
- if (!C.d.has(B)) {
10350
- v.d.delete(B);
10351
- const I = N(B);
10352
- I == null || I.t.delete(k);
10048
+ for (const j of k.d || [])
10049
+ if (!S.d.has(j)) {
10050
+ k.d.delete(j);
10051
+ const I = N(j);
10052
+ I == null || I.t.delete(C);
10353
10053
  }
10354
10054
  }
10355
- }), E = h[7] || ((k) => {
10356
- var j;
10357
- const C = m(k);
10358
- let v = r.get(k);
10359
- if (!v) {
10360
- y(k);
10361
- for (const B of C.d.keys())
10362
- E(B).t.add(k);
10363
- if (v = {
10055
+ }), _ = h[7] || ((C) => {
10056
+ var E;
10057
+ const S = m(C);
10058
+ let k = r.get(C);
10059
+ if (!k) {
10060
+ y(C);
10061
+ for (const j of S.d.keys())
10062
+ _(j).t.add(C);
10063
+ if (k = {
10364
10064
  l: /* @__PURE__ */ new Set(),
10365
- d: new Set(C.d.keys()),
10065
+ d: new Set(S.d.keys()),
10366
10066
  t: /* @__PURE__ */ new Set()
10367
- }, r.set(k, v), (j = c.m) == null || j.call(c, k), isActuallyWritableAtom(k)) {
10368
- const B = () => {
10067
+ }, r.set(C, k), (E = c.m) == null || E.call(c, C), isActuallyWritableAtom(C)) {
10068
+ const j = () => {
10369
10069
  let I = !0;
10370
10070
  const T = (...P) => {
10371
10071
  try {
10372
- return A(k, ...P);
10072
+ return w(C, ...P);
10373
10073
  } finally {
10374
10074
  I || (f(), x());
10375
10075
  }
10376
10076
  };
10377
10077
  try {
10378
- const P = g(k, T);
10379
- P && (v.u = () => {
10078
+ const P = g(C, T);
10079
+ P && (k.u = () => {
10380
10080
  I = !0;
10381
10081
  try {
10382
10082
  P();
@@ -10388,27 +10088,27 @@ const RootLayout = () => {
10388
10088
  I = !1;
10389
10089
  }
10390
10090
  };
10391
- l.add(B);
10091
+ l.add(j);
10392
10092
  }
10393
10093
  }
10394
- return v;
10395
- }), N = h[8] || ((k) => {
10396
- var j;
10397
- const C = m(k);
10398
- let v = r.get(k);
10399
- if (v && !v.l.size && !Array.from(v.t).some((B) => {
10094
+ return k;
10095
+ }), N = h[8] || ((C) => {
10096
+ var E;
10097
+ const S = m(C);
10098
+ let k = r.get(C);
10099
+ if (k && !k.l.size && !Array.from(k.t).some((j) => {
10400
10100
  var I;
10401
- return (I = r.get(B)) == null ? void 0 : I.d.has(k);
10101
+ return (I = r.get(j)) == null ? void 0 : I.d.has(C);
10402
10102
  })) {
10403
- v.u && i.add(v.u), v = void 0, r.delete(k), (j = c.u) == null || j.call(c, k);
10404
- for (const B of C.d.keys()) {
10405
- const I = N(B);
10406
- I == null || I.t.delete(k);
10103
+ k.u && i.add(k.u), k = void 0, r.delete(C), (E = c.u) == null || E.call(c, C);
10104
+ for (const j of S.d.keys()) {
10105
+ const I = N(j);
10106
+ I == null || I.t.delete(C);
10407
10107
  }
10408
10108
  return;
10409
10109
  }
10410
- return v;
10411
- }), w = [
10110
+ return k;
10111
+ }), A = [
10412
10112
  // store state
10413
10113
  o,
10414
10114
  r,
@@ -10428,27 +10128,27 @@ const RootLayout = () => {
10428
10128
  f,
10429
10129
  y,
10430
10130
  b,
10431
- A,
10131
+ w,
10132
+ B,
10432
10133
  _,
10433
- E,
10434
10134
  N
10435
- ], S = {
10436
- get: (k) => returnAtomValue(y(k)),
10437
- set: (k, ...j) => {
10135
+ ], v = {
10136
+ get: (C) => returnAtomValue(y(C)),
10137
+ set: (C, ...E) => {
10438
10138
  try {
10439
- return A(k, ...j);
10139
+ return w(C, ...E);
10440
10140
  } finally {
10441
10141
  f(), x();
10442
10142
  }
10443
10143
  },
10444
- sub: (k, j) => {
10445
- const v = E(k).l;
10446
- return v.add(j), x(), () => {
10447
- v.delete(j), N(k), x();
10144
+ sub: (C, E) => {
10145
+ const k = _(C).l;
10146
+ return k.add(E), x(), () => {
10147
+ k.delete(E), N(C), x();
10448
10148
  };
10449
10149
  }
10450
10150
  };
10451
- return Object.defineProperty(S, BUILDING_BLOCKS, { value: w }), S;
10151
+ return Object.defineProperty(v, BUILDING_BLOCKS, { value: A }), v;
10452
10152
  }, INTERNAL_buildStoreRev1 = buildStore, INTERNAL_registerAbortHandler = registerAbortHandler;
10453
10153
  function createStore() {
10454
10154
  return INTERNAL_buildStoreRev1();