@chaibuilder/sdk 2.6.1 → 2.6.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/dist/core.cjs +3 -3
  2. package/dist/core.js +715 -715
  3. package/package.json +1 -1
package/dist/core.js CHANGED
@@ -347,8 +347,8 @@ function insertBlocksAtPosition(o, r, n, a) {
347
347
  }), l.unshift(m), i = i.map((x) => {
348
348
  if (x._id === n) {
349
349
  const f = { ...x, content: "" };
350
- return Object.keys(f).forEach((k) => {
351
- k.startsWith("content-") && (f[k] = "");
350
+ return Object.keys(f).forEach((y) => {
351
+ y.startsWith("content-") && (f[y] = "");
352
352
  }), f;
353
353
  }
354
354
  return x;
@@ -483,8 +483,8 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
483
483
  m && "content" in m && (n = n.map((x) => {
484
484
  if (x._id === u) {
485
485
  const f = { ...x, content: h.content };
486
- return Object.keys(h).forEach((k) => {
487
- k.startsWith("content-") && (f[k] = h[k]);
486
+ return Object.keys(h).forEach((y) => {
487
+ y.startsWith("content-") && (f[y] = h[y]);
488
488
  }), f;
489
489
  }
490
490
  return x;
@@ -838,50 +838,50 @@ const undoRedoStateAtom = atom({
838
838
  updateBlocksProps: c
839
839
  } = useBlocksStoreManager();
840
840
  return {
841
- moveBlocks: (f, k, b) => {
842
- const A = map(f, (_) => {
843
- const w = r.find((B) => B._id === _)._parent || null, v = r.filter((B) => w ? B._parent === w : !B._parent).map((B) => B._id).indexOf(_);
844
- return { _id: _, oldParent: w, oldPosition: v };
845
- }), E = A.find(({ _id: _ }) => _ === f[0]);
846
- E && E.oldParent === k && E.oldPosition === b || (i(f, k, b), o({
847
- undo: () => each(A, ({ _id: _, oldParent: N, oldPosition: w }) => {
848
- i([_], N, w);
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);
849
849
  }),
850
- redo: () => i(f, k, b)
850
+ redo: () => i(f, y, b)
851
851
  }));
852
852
  },
853
- addBlocks: (f, k, b) => {
854
- a(f, k, b), o({
853
+ addBlocks: (f, y, b) => {
854
+ a(f, y, b), o({
855
855
  undo: () => l(map(f, "_id")),
856
- redo: () => a(f, k, b)
856
+ redo: () => a(f, y, b)
857
857
  });
858
858
  },
859
859
  removeBlocks: (f) => {
860
- var E;
861
- const k = (E = first(f)) == null ? void 0 : E._parent, A = r.filter((_) => k ? _._parent === k : !_._parent).indexOf(first(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));
862
862
  l(map(f, "_id")), o({
863
- undo: () => a(f, k, A),
863
+ undo: () => a(f, y, A),
864
864
  redo: () => l(map(f, "_id"))
865
865
  });
866
866
  },
867
- updateBlocks: (f, k, b) => {
867
+ updateBlocks: (f, y, b) => {
868
868
  let A = [];
869
869
  if (b)
870
- A = map(f, (E) => ({ _id: E, ...b }));
870
+ A = map(f, (_) => ({ _id: _, ...b }));
871
871
  else {
872
- const E = keys(k);
873
- A = map(f, (_) => {
874
- const N = r.find((y) => y._id === _), w = { _id: _ };
875
- return each(E, (y) => w[y] = N[y]), w;
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;
876
876
  });
877
877
  }
878
- c(map(f, (E) => ({ _id: E, ...k }))), o({
878
+ c(map(f, (_) => ({ _id: _, ...y }))), o({
879
879
  undo: () => c(A),
880
- redo: () => c(map(f, (E) => ({ _id: E, ...k })))
880
+ redo: () => c(map(f, (_) => ({ _id: _, ...y })))
881
881
  });
882
882
  },
883
- updateBlocksRuntime: (f, k) => {
884
- c(map(f, (b) => ({ _id: b, ...k })));
883
+ updateBlocksRuntime: (f, y) => {
884
+ c(map(f, (b) => ({ _id: b, ...y })));
885
885
  },
886
886
  setNewBlocks: (f) => {
887
887
  n(f), o({
@@ -890,12 +890,12 @@ const undoRedoStateAtom = atom({
890
890
  });
891
891
  },
892
892
  updateMultipleBlocksProps: (f) => {
893
- let k = [];
894
- k = map(f, (b) => {
895
- const A = keys(b), E = r.find((N) => N._id === b._id), _ = {};
896
- return each(A, (N) => _[N] = E[N]), _;
893
+ let y = [];
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;
897
897
  }), c(f), o({
898
- undo: () => c(k),
898
+ undo: () => c(y),
899
899
  redo: () => c(f)
900
900
  });
901
901
  }
@@ -907,9 +907,9 @@ const undoRedoStateAtom = atom({
907
907
  for (let x = 0; x < i.length; x++) {
908
908
  const { _id: f } = i[x];
909
909
  i[x]._id = generateUUID();
910
- const k = filter(i, { _parent: f });
911
- for (let b = 0; b < k.length; b++)
912
- k[b]._parent = i[x]._id;
910
+ const y = filter(i, { _parent: f });
911
+ for (let b = 0; b < y.length; b++)
912
+ y[b]._parent = i[x]._id;
913
913
  }
914
914
  const p = first(i);
915
915
  let u, g;
@@ -920,8 +920,8 @@ const undoRedoStateAtom = atom({
920
920
  return { addCoreBlock: useCallback(
921
921
  (i, c, d) => {
922
922
  if (has(i, "blocks")) {
923
- const k = i.blocks;
924
- return a(k, c, d);
923
+ const y = i.blocks;
924
+ return a(y, c, d);
925
925
  }
926
926
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
927
927
  _type: i.type,
@@ -2363,44 +2363,44 @@ const getBlockWithChildren = (o, r) => {
2363
2363
  })
2364
2364
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2365
2365
  const [o, r] = useAtom$1(askAiProcessingAtom), [n, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, h = (m, x) => {
2366
- const f = cloneDeep(x.find((k) => k._id === m));
2367
- for (const k in f) {
2368
- const b = f[k];
2366
+ const f = cloneDeep(x.find((y) => y._id === m));
2367
+ for (const y in f) {
2368
+ const b = f[y];
2369
2369
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
2370
- const { baseClasses: A, classes: E } = getSplitChaiClasses(b);
2371
- f[k] = compact(flattenDeep([A, E])).join(" ");
2370
+ const { baseClasses: A, classes: _ } = getSplitChaiClasses(b);
2371
+ f[y] = compact(flattenDeep([A, _])).join(" ");
2372
2372
  } else
2373
- k !== "_id" && delete f[k];
2373
+ y !== "_id" && delete f[y];
2374
2374
  }
2375
2375
  return f;
2376
2376
  };
2377
2377
  return {
2378
2378
  askAi: useCallback(
2379
- async (m, x, f, k) => {
2379
+ async (m, x, f, y) => {
2380
2380
  if (l) {
2381
2381
  r(!0), a(null);
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"), E = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(x, d)), p, A) : [h(x, d)], _ = await l(m, addLangToPrompt(f, g, m), E, b), { blocks: N, error: w } = _;
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
2386
  if (w) {
2387
2387
  a(w);
2388
2388
  return;
2389
2389
  }
2390
2390
  if (m === "styles") {
2391
- const y = N.map((v) => {
2392
- for (const B in v)
2393
- B !== "_id" && (v[B] = `${STYLES_KEY},${v[B]}`);
2394
- return v;
2391
+ const S = N.map((k) => {
2392
+ for (const j in k)
2393
+ j !== "_id" && (k[j] = `${STYLES_KEY},${k[j]}`);
2394
+ return k;
2395
2395
  });
2396
- c(y);
2396
+ c(S);
2397
2397
  } else
2398
2398
  i(N);
2399
- k && k(_);
2399
+ y && y(E);
2400
2400
  } catch (b) {
2401
2401
  a(b);
2402
2402
  } finally {
2403
- r(!1), k && k();
2403
+ r(!1), y && y();
2404
2404
  }
2405
2405
  }
2406
2406
  },
@@ -2497,7 +2497,7 @@ const getBlockWithChildren = (o, r) => {
2497
2497
  for (const x of h)
2498
2498
  if (x._type === "PartialBlock" || x._type === "GlobalBlock") {
2499
2499
  let f = l(x.partialBlockId);
2500
- x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((k) => (isEmpty(k._parent) && set(k, "_parent", x._parent), k))), m = [...m, ...f];
2500
+ x._parent && (f == null ? void 0 : f.length) > 0 && (f = f.map((y) => (isEmpty(y._parent) && set(y, "_parent", x._parent), y))), m = [...m, ...f];
2501
2501
  } else
2502
2502
  m.push(x);
2503
2503
  return m;
@@ -2846,8 +2846,8 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2846
2846
  return useHotkeys(
2847
2847
  "shift+up, shift+down, shift+left, shift+right",
2848
2848
  ({ key: f }) => {
2849
- var k;
2850
- x((k = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : k.toUpperCase());
2849
+ var y;
2850
+ x((y = f == null ? void 0 : f.replace("Arrow", "")) == null ? void 0 : y.toUpperCase());
2851
2851
  },
2852
2852
  { document: a == null ? void 0 : a.contentDocument },
2853
2853
  [x]
@@ -3008,9 +3008,9 @@ 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: k, availableHeight: b, elements: A }) {
3011
+ apply({ availableWidth: y, availableHeight: b, elements: A }) {
3012
3012
  Object.assign(A.floating.style, {
3013
- maxWidth: `${Math.max(200, k)}px`,
3013
+ maxWidth: `${Math.max(200, y)}px`,
3014
3014
  maxHeight: `${Math.max(100, b)}px`
3015
3015
  });
3016
3016
  }
@@ -3022,8 +3022,8 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3022
3022
  const x = get(o, "_parent", null), f = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
3023
3023
  return useEffect(() => {
3024
3024
  if (r) {
3025
- const k = setTimeout(() => m(), 500);
3026
- return () => clearTimeout(k);
3025
+ const y = setTimeout(() => m(), 500);
3026
+ return () => clearTimeout(y);
3027
3027
  } else
3028
3028
  m();
3029
3029
  }, [r]), !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
@@ -3033,13 +3033,13 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
3033
3033
  tabIndex: 0,
3034
3034
  ref: h.setFloating,
3035
3035
  style: g,
3036
- onClick: (k) => {
3037
- k.stopPropagation(), k.preventDefault();
3036
+ onClick: (y) => {
3037
+ y.stopPropagation(), y.preventDefault();
3038
3038
  },
3039
- onMouseEnter: (k) => {
3040
- k.stopPropagation(), i(null);
3039
+ onMouseEnter: (y) => {
3040
+ y.stopPropagation(), i(null);
3041
3041
  },
3042
- onKeyDown: (k) => k.stopPropagation(),
3042
+ onKeyDown: (y) => y.stopPropagation(),
3043
3043
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3044
3044
  children: [
3045
3045
  x && /* @__PURE__ */ jsx(
@@ -3503,8 +3503,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3503
3503
  ],
3504
3504
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3505
3505
  onBlur: ({ editor: u, event: g }) => {
3506
- const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), k = x == null ? void 0 : x.contains(h);
3507
- if (!f && !k) {
3506
+ const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), x = i.querySelector(".tippy-box"), f = m == null ? void 0 : m.contains(h), y = x == null ? void 0 : x.contains(h);
3507
+ if (!f && !y) {
3508
3508
  const b = (u == null ? void 0 : u.getHTML()) || "";
3509
3509
  n(b);
3510
3510
  }
@@ -3600,47 +3600,47 @@ 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(), k = useRef(null), b = l, { blockContent: A, blockType: E } = useMemo(() => {
3604
- var j;
3605
- const v = o._type;
3606
- let B = 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}`) && (B = get(o, `${n}-${x}`)), { blockContent: B, blockType: v };
3609
- }, [o, x]), _ = useCallback(
3610
- (v) => {
3611
- var S;
3612
- const B = v || ((S = g.current) == null ? void 0 : S.innerText);
3613
- m([b], { [n]: B }), 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: 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] : []);
3614
3614
  },
3615
3615
  [b, m, c, f, x]
3616
3616
  ), N = useDebouncedCallback(
3617
- (v) => {
3618
- m([b], { [n]: v });
3617
+ (k) => {
3618
+ m([b], { [n]: k });
3619
3619
  },
3620
3620
  [b, o, m, x],
3621
3621
  1e3
3622
3622
  ), w = useCallback(
3623
- (v) => {
3624
- v.preventDefault(), b && (k.current = b), _(), setTimeout(() => {
3625
- const B = k.current;
3626
- k.current = null, f([B]);
3623
+ (k) => {
3624
+ k.preventDefault(), b && (y.current = b), E(), setTimeout(() => {
3625
+ const j = y.current;
3626
+ y.current = null, f([j]);
3627
3627
  }, 100);
3628
3628
  },
3629
3629
  [f, b, x]
3630
3630
  );
3631
3631
  useEffect(() => {
3632
- var C;
3632
+ var v;
3633
3633
  if (!b) return;
3634
- const v = `[data-block-id="${b}"]`, B = i >= 0 ? `[data-block-index="${i}"]` : "", S = a.querySelector(`${v}${B}`);
3635
- S && ((C = S == null ? void 0 : S.classList) == null || C.add("sr-only"), u(S));
3636
- }, [b, E, a, i]);
3637
- const y = useMemo(() => p ? (h(), E === "RichText" ? /* @__PURE__ */ jsx(
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(
3638
3638
  RichTextEditor,
3639
3639
  {
3640
3640
  blockContent: A,
3641
3641
  editingElement: p,
3642
3642
  onChange: N,
3643
- onClose: _,
3643
+ onClose: E,
3644
3644
  onEscape: w
3645
3645
  }
3646
3646
  ) : /* @__PURE__ */ jsx(
@@ -3649,13 +3649,13 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3649
3649
  editorRef: g,
3650
3650
  blockContent: A,
3651
3651
  editingElement: p,
3652
- onClose: _,
3652
+ onClose: E,
3653
3653
  onChange: N,
3654
3654
  onEscape: w
3655
3655
  }
3656
- )) : null, [p, b, E, A, _, x]);
3656
+ )) : null, [p, b, _, A, E, x]);
3657
3657
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3658
- y,
3658
+ S,
3659
3659
  r
3660
3660
  ] });
3661
3661
  },
@@ -3688,23 +3688,23 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3688
3688
  blockAtom: r,
3689
3689
  children: n
3690
3690
  }) => {
3691
- const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: k } = useContext(RepeaterContext), b = useMemo(
3691
+ const { editingBlockId: a, editingItemIndex: l } = useInlineEditing(), [i] = useAtom$1(r), c = useMemo(() => getRegisteredChaiBlock(i._type), [i._type]), { selectedLang: d, fallbackLang: p } = useLanguages(), u = useBlockRuntimeProps(), g = usePageExternalData(), [h] = useHiddenBlockIds(), [m] = useAtom$1(dataBindingActiveAtom), x = get(c, "component", null), { index: f, key: y } = useContext(RepeaterContext), b = useMemo(
3692
3692
  () => m ? applyBindingToBlockProps(applyLanguage(i, d, c), g, {
3693
3693
  index: f,
3694
- key: k
3694
+ key: y
3695
3695
  }) : applyLanguage(i, d, c),
3696
- [i, d, c, g, m, f, k]
3697
- ), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), E = useMemo(
3696
+ [i, d, c, g, m, f, y]
3697
+ ), A = useMemo(() => getBlockTagAttributes(i), [i, getBlockTagAttributes]), _ = useMemo(
3698
3698
  () => u(i._id, getBlockRuntimeProps(i._type)),
3699
3699
  [i._id, i._type, u, getBlockRuntimeProps]
3700
- ), _ = useMemo(
3700
+ ), E = 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
3706
  ...A,
3707
- ...E,
3707
+ ..._,
3708
3708
  ...o
3709
3709
  }),
3710
3710
  [
@@ -3714,13 +3714,13 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3714
3714
  p,
3715
3715
  b,
3716
3716
  A,
3717
- E,
3717
+ _,
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
3722
  let w = /* @__PURE__ */ jsx(Suspense, { children: createElement(x, {
3723
- ..._,
3723
+ ...E,
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 y = a === i._id && (l === f || f < 0) ? /* @__PURE__ */ jsx(WithBlockTextEditor, { block: i, children: w }) : w;
3736
- return N ? /* @__PURE__ */ jsx(ErrorBoundary, { fallbackRender: ErrorFallback, children: y }) : y;
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;
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) => {
@@ -3773,7 +3773,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3773
3773
  );
3774
3774
  return map(l, (c) => {
3775
3775
  const d = a(c._id);
3776
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, k) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: k, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${k}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3776
+ return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: g, partialBlockId: h, repeaterItems: m, $repeaterItemsKey: x }) => g === "Repeater" ? isArray(m) && m.map((f, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: x }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3777
3777
  });
3778
3778
  }, PageBlocksRenderer = () => {
3779
3779
  const [o] = useBlocksStore();
@@ -4028,19 +4028,19 @@ const CanvasEventsWatcher = () => {
4028
4028
  };
4029
4029
  MediaManagerModal.displayName = "MediaManagerModal";
4030
4030
  const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWlnaHQ9IjQwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj48cmVjdCB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiBmaWxsPSIjZjNmNGY2Ii8+PHRleHQgeD0iNTAlIiB5PSI1MCUiIGZvbnQtZmFtaWx5PSJBcmlhbCwgc2Fucy1zZXJpZiIgZm9udC1zaXplPSIxNiIgZmlsbD0iI2Q1ZDdkYSIgdGV4dC1hbmNob3I9Im1pZGRsZSIgZHk9Ii4zZW0iPkltYWdlIFBsYWNlaG9sZGVyPC90ZXh0Pjwvc3ZnPg==", ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
4031
- const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, x = (k) => {
4032
- const b = isArray(k) ? first(k) : k;
4031
+ const { t: l } = useTranslation(), { selectedLang: i } = useLanguages(), c = useSelectedBlock(), d = useUpdateBlocksProps(), p = n.split(".").pop() || "", u = i ? `_${p}Id-${i}` : `_${p}Id`, g = isEmpty(i) && (c == null ? void 0 : c._type) === "Image" && has(c, "assetId"), h = get(c, u, g ? c == null ? void 0 : c.assetId : ""), m = !!h, x = (y) => {
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, E = b == null ? void 0 : b.height;
4035
+ const A = b == null ? void 0 : b.width, _ = b == null ? void 0 : b.height;
4036
4036
  if (c != null && c._id) {
4037
- const _ = {
4037
+ const E = {
4038
4038
  ...A && { width: A },
4039
- ...E && { height: E },
4039
+ ..._ && { height: _ },
4040
4040
  ...b.description && { alt: b.description }
4041
4041
  };
4042
- if (set(_, u, b.id), isEmpty(_)) return;
4043
- d([c._id], _);
4042
+ if (set(E, u, b.id), isEmpty(E)) return;
4043
+ d([c._id], E);
4044
4044
  }
4045
4045
  }
4046
4046
  }, f = useCallback(() => {
@@ -4090,8 +4090,8 @@ const PLACEHOLDER_IMAGE = "data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTAwIiBoZWl
4090
4090
  className: "text-xs",
4091
4091
  placeholder: l("Enter image URL"),
4092
4092
  value: o,
4093
- onBlur: ({ target: { value: k } }) => a(n, k),
4094
- onChange: (k) => r(k.target.value)
4093
+ onBlur: ({ target: { value: y } }) => a(n, y),
4094
+ onChange: (y) => r(y.target.value)
4095
4095
  }
4096
4096
  )
4097
4097
  ] })
@@ -4207,44 +4207,44 @@ const DataBindingSelector = ({
4207
4207
  r(`{{${g}}}`, {}, n);
4208
4208
  return;
4209
4209
  }
4210
- const m = (b) => /[.,!?;:]/.test(b), x = (b, A, E) => {
4211
- let _ = "", N = "";
4212
- const w = A > 0 ? b[A - 1] : "", y = A < b.length ? b[A] : "";
4213
- return A > 0 && (w === "." || !m(w) && w !== " ") && (_ = " "), A < b.length && !m(y) && y !== " " && (N = " "), {
4214
- text: _ + E + N,
4215
- prefixLength: _.length,
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,
4216
4216
  suffixLength: N.length
4217
4217
  };
4218
4218
  }, f = document.getElementById(n);
4219
4219
  if (!f) return;
4220
- const k = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4221
- if (k && (k.querySelector(".ProseMirror") || k.__chaiRTE)) {
4222
- const b = k.__chaiRTE;
4220
+ const y = document.getElementById(`chai-rte-${n}`) || document.getElementById(`chai-rte-modal-${n}`);
4221
+ if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4222
+ const b = y.__chaiRTE;
4223
4223
  if (b) {
4224
4224
  const A = `{{${g}}}`;
4225
4225
  b.commands.focus();
4226
- const { from: E, to: _ } = b.state.selection;
4227
- if (E !== _)
4226
+ const { from: _, to: E } = b.state.selection;
4227
+ if (_ !== E)
4228
4228
  b.chain().deleteSelection().insertContent(A).run();
4229
4229
  else {
4230
- const { state: w } = b, y = w.selection.from, v = w.doc.textBetween(Math.max(0, y - 1), y), B = w.doc.textBetween(y, Math.min(y + 1, w.doc.content.size));
4231
- let S = "";
4232
- y > 0 && v !== " " && !m(v) && (S = " ");
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));
4233
4231
  let C = "";
4234
- B && B !== " " && !m(B) && (C = " "), b.chain().insertContent(S + A + C).run();
4232
+ S > 0 && k !== " " && !m(k) && (C = " ");
4233
+ let v = "";
4234
+ j && j !== " " && !m(j) && (v = " "), b.chain().insertContent(C + A + v).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, E = b.value || "", _ = b.selectionEnd || A;
4241
- if (_ > A) {
4242
- const B = `{{${g}}}`, { text: S } = x(E, A, B), C = E.slice(0, A) + S + E.slice(_);
4243
- r(C, {}, n);
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);
4244
4244
  return;
4245
4245
  }
4246
- const w = `{{${g}}}`, { text: y } = x(E, A, w), v = E.slice(0, A) + y + E.slice(A);
4247
- r(v, {}, n);
4246
+ const w = `{{${g}}}`, { text: S } = x(_, A, w), k = _.slice(0, A) + S + _.slice(A);
4247
+ r(k, {}, 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 B;
4269
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (S, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [x, f] = useState([]), [k, b] = useState(-1), A = useRef(null), E = (B = r == null ? void 0 : r.find((S) => S.key === u)) == null ? void 0 : B.name;
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;
4270
4270
  useEffect(() => {
4271
4271
  if (m(""), f([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4272
- const S = split(o, ":"), C = get(S, 1, "page") || "page";
4273
- g(C), (async () => {
4274
- const j = await l(C, [get(S, 2, "page")]);
4275
- j && Array.isArray(j) && m(get(j, [0, "name"], ""));
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"], ""));
4276
4276
  })();
4277
4277
  }, [o]);
4278
- const _ = useDebouncedCallback(
4279
- async (S) => {
4280
- if (isEmpty(S))
4278
+ const E = useDebouncedCallback(
4279
+ async (C) => {
4280
+ if (isEmpty(C))
4281
4281
  f([]);
4282
4282
  else {
4283
- const C = await l(u, S);
4284
- f(C);
4283
+ const v = await l(u, C);
4284
+ f(v);
4285
4285
  }
4286
4286
  c(!1), b(-1);
4287
4287
  },
4288
4288
  [u],
4289
4289
  300
4290
- ), N = (S) => {
4291
- const C = ["pageType", u, S.id];
4292
- C[1] && (n(C.join(":")), m(S.name), p(!1), f([]), b(-1));
4293
- }, w = (S) => {
4294
- switch (S.key) {
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) {
4295
4295
  case "ArrowDown":
4296
- S.preventDefault(), b((C) => C < x.length - 1 ? C + 1 : C);
4296
+ C.preventDefault(), b((v) => v < x.length - 1 ? v + 1 : v);
4297
4297
  break;
4298
4298
  case "ArrowUp":
4299
- S.preventDefault(), b((C) => C > 0 ? C - 1 : C);
4299
+ C.preventDefault(), b((v) => v > 0 ? v - 1 : v);
4300
4300
  break;
4301
4301
  case "Enter":
4302
- if (S.preventDefault(), x.length === 0) return;
4303
- k >= 0 && N(x[k]);
4302
+ if (C.preventDefault(), x.length === 0) return;
4303
+ y >= 0 && N(x[y]);
4304
4304
  break;
4305
4305
  case "Escape":
4306
- S.preventDefault(), y();
4306
+ C.preventDefault(), S();
4307
4307
  break;
4308
4308
  }
4309
4309
  };
4310
4310
  useEffect(() => {
4311
- if (k >= 0 && A.current) {
4312
- const S = A.current.children[k];
4313
- S == null || S.scrollIntoView({ block: "nearest" });
4311
+ if (y >= 0 && A.current) {
4312
+ const C = A.current.children[y];
4313
+ C == null || C.scrollIntoView({ block: "nearest" });
4314
4314
  }
4315
- }, [k]);
4316
- const y = () => {
4315
+ }, [y]);
4316
+ const S = () => {
4317
4317
  m(""), f([]), b(-1), p(!1), n("");
4318
- }, v = (S) => {
4319
- m(S), p(!isEmpty(S)), c(!0), _(S);
4318
+ }, k = (C) => {
4319
+ m(C), p(!isEmpty(C)), c(!0), E(C);
4320
4320
  };
4321
4321
  return /* @__PURE__ */ jsxs("div", { children: [
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)) }),
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)) }),
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: (S) => v(S.target.value),
4329
+ onChange: (C) => k(C.target.value),
4330
4330
  onKeyDown: w,
4331
- placeholder: a(`Search ${E ?? ""}`),
4331
+ placeholder: a(`Search ${_ ?? ""}`),
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: y, 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: S, 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), (S, C) => /* @__PURE__ */ jsxs(
4345
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(x == null ? void 0 : x.slice(0, 20), (C, v) => /* @__PURE__ */ jsxs(
4346
4346
  "li",
4347
4347
  {
4348
- onClick: () => N(S),
4349
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(S.id) ? "bg-blue-200" : C === k ? "bg-gray-100" : "hover:bg-gray-100"}`,
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"}`,
4350
4350
  children: [
4351
- S.name,
4351
+ C.name,
4352
4352
  " ",
4353
- S.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4353
+ C.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4354
4354
  "( ",
4355
- S.slug,
4355
+ C.slug,
4356
4356
  " )"
4357
4357
  ] })
4358
4358
  ]
4359
4359
  },
4360
- S.id
4360
+ C.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, E = b.doc.textBetween(Math.max(0, A - 1), A), _ = b.doc.textBetween(A, Math.min(A + 1, b.doc.content.size));
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));
4665
4665
  let N = "";
4666
- A > 0 && E !== " " && !/[.,!?;:]/.test(E) && (N = " ");
4666
+ A > 0 && _ !== " " && !/[.,!?;:]/.test(_) && (N = " ");
4667
4667
  let w = "";
4668
- _ && _ !== " " && !/[.,!?;:]/.test(_) && (w = " "), u.chain().insertContent(N + m + w).run();
4668
+ E && E !== " " && !/[.,!?;:]/.test(E) && (w = " "), u.chain().insertContent(N + m + w).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: [
@@ -4759,14 +4759,14 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4759
4759
  const h = () => {
4760
4760
  const f = findIndex(u, { _id: g });
4761
4761
  if (f > -1) {
4762
- const k = (f + 1) % u.length, b = get(u, [k, "_id"]);
4762
+ const y = (f + 1) % u.length, b = get(u, [y, "_id"]);
4763
4763
  if (!b) return;
4764
4764
  r({ ...o, currentSlide: b }), c([b]);
4765
4765
  }
4766
4766
  }, m = () => {
4767
4767
  const f = findIndex(u, { _id: g });
4768
4768
  if (f > -1) {
4769
- const k = (f - 1 + u.length) % u.length, b = get(u, [k, "_id"]);
4769
+ const y = (f - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4770
4770
  if (!b) return;
4771
4771
  r({ ...o, currentSlide: b }), c([b]);
4772
4772
  }
@@ -4774,8 +4774,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4774
4774
  const f = i(
4775
4775
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4776
4776
  p == null ? void 0 : p._id
4777
- ), k = f == null ? void 0 : f._id;
4778
- k && (r({ ...o, currentSlide: k }), c([k]));
4777
+ ), y = f == null ? void 0 : f._id;
4778
+ y && (r({ ...o, currentSlide: y }), c([y]));
4779
4779
  };
4780
4780
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4781
4781
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4854,8 +4854,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4854
4854
  className: "text-xs",
4855
4855
  pattern: "[0-9]*",
4856
4856
  onChange: (f) => {
4857
- let k = f.target.value;
4858
- k.length && (k = k.replace("-", "")), r({ ...o, autoplayInterval: k });
4857
+ let y = f.target.value;
4858
+ y.length && (y = y.replace("-", "")), r({ ...o, autoplayInterval: y });
4859
4859
  }
4860
4860
  }
4861
4861
  )
@@ -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
- ), k = useMemo(() => get(LANGUAGES, f, f), [f]), b = usePageExternalData(), A = useSelectedBlock(), E = useRegisteredChaiBlocks(), _ = useMemo(
4969
- () => get(E, [A == null ? void 0 : A._type, "i18nProps"], []),
4970
- [E, A == null ? void 0 : A._type]
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
4971
  ), [N, w] = 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 v = _ == null ? void 0 : _.includes(o.replace("root.", ""));
4975
+ const k = E == null ? void 0 : E.includes(o.replace("root.", ""));
4976
4976
  if (p.type === "array") {
4977
- const B = N === o;
4977
+ const j = 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(B ? null : o),
4983
+ onClick: () => w(j ? 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
- B ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
4986
+ j ? /* @__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: (S) => S.stopPropagation(),
4997
- onMouseDown: (S) => S.stopPropagation()
4996
+ onClick: (C) => C.stopPropagation(),
4997
+ onMouseDown: (C) => C.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: `${B ? "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: `${j ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5006
5006
  a,
5007
5007
  l,
5008
5008
  i
@@ -5015,9 +5015,9 @@ 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
- v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5018
+ k && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5019
5019
  " ",
5020
- k
5020
+ y
5021
5021
  ] }),
5022
5022
  d && p.type !== "object" ? " *" : null
5023
5023
  ] }),
@@ -5030,8 +5030,8 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
5030
5030
  DataBindingSelector,
5031
5031
  {
5032
5032
  schema: p,
5033
- onChange: (B) => {
5034
- g(B, u, o);
5033
+ onChange: (j) => {
5034
+ g(j, u, o);
5035
5035
  },
5036
5036
  id: o,
5037
5037
  formData: u
@@ -5137,36 +5137,36 @@ 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 }, y, v) => {
5141
- y && (c == null ? void 0 : c._id) === r._id && a([r._id], { [y]: get(w, y) }, v);
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);
5142
5142
  }, f = useCallback(
5143
- debounce(({ formData: w }, y, v) => {
5144
- x({ formData: w }, y, v), d(w);
5143
+ debounce(({ formData: w }, S, k) => {
5144
+ x({ formData: w }, S, k), d(w);
5145
5145
  }, 1500),
5146
5146
  [r == null ? void 0 : r._id, o]
5147
- ), k = ({ formData: w }, y) => {
5148
- y && (n([r._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
5149
- }, b = ({ formData: w }, y) => {
5150
- y && (n([g._id], { [y]: get(w, y) }), f({ formData: w }, y, { [y]: get(c, y) }));
5151
- }, { schema: A, uiSchema: E } = useMemo(() => {
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
5152
  const w = r == null ? void 0 : r._type;
5153
5153
  if (!w)
5154
5154
  return { schema: {}, uiSchema: {} };
5155
5155
  try {
5156
- const { schema: y, uiSchema: v } = getBlockFormSchemas(w);
5156
+ const { schema: S, uiSchema: k } = getBlockFormSchemas(w);
5157
5157
  if (w === "Repeater") {
5158
- const B = get(r, "repeaterItems", "");
5159
- startsWith(B, `{{${COLLECTION_PREFIX}`) ? (set(v, "filter", { "ui:widget": "collectionSelect" }), set(v, "sort", { "ui:widget": "collectionSelect" })) : (set(v, "filter", { "ui:widget": "hidden" }), set(v, "sort", { "ui:widget": "hidden" }));
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" }));
5160
5160
  }
5161
- return { schema: y, uiSchema: v };
5161
+ return { schema: S, uiSchema: k };
5162
5162
  } catch {
5163
5163
  return { schema: {}, uiSchema: {} };
5164
5164
  }
5165
- }, [r]), { wrapperSchema: _, wrapperUiSchema: N } = useMemo(() => {
5165
+ }, [r]), { wrapperSchema: E, 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: y = {}, uiSchema: v = {} } = getBlockFormSchemas(w);
5169
- return { wrapperSchema: y, wrapperUiSchema: v };
5168
+ const w = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: k = {} } = getBlockFormSchemas(w);
5169
+ return { wrapperSchema: S, wrapperUiSchema: k };
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: [
@@ -5194,7 +5194,7 @@ function BlockSettings() {
5194
5194
  blockId: g == null ? void 0 : g._id,
5195
5195
  onChange: b,
5196
5196
  formData: m,
5197
- schema: _,
5197
+ schema: E,
5198
5198
  uiSchema: N
5199
5199
  }
5200
5200
  ) })
@@ -5203,10 +5203,10 @@ function BlockSettings() {
5203
5203
  JSONForm,
5204
5204
  {
5205
5205
  blockId: r == null ? void 0 : r._id,
5206
- onChange: k,
5206
+ onChange: y,
5207
5207
  formData: i,
5208
5208
  schema: A,
5209
- uiSchema: E
5209
+ uiSchema: _
5210
5210
  }
5211
5211
  )
5212
5212
  ] });
@@ -5217,7 +5217,7 @@ const BlockStylingProps = () => {
5217
5217
  if (!o) return null;
5218
5218
  const c = Object.keys(o).filter(
5219
5219
  (f) => typeof o[f] == "string" && o[f].startsWith("#styles:")
5220
- ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = r[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], m = (f) => find(r, (k) => k.prop === f);
5220
+ ), { reset: d } = useResetBlockStyles(), p = !isEmpty(c) && c.length > 1, u = get(o, (x = r[0]) == null ? void 0 : x.prop, ""), { classes: g = "" } = getSplitChaiClasses(u) || {}, h = g ? g.split(" ").filter((f) => !isEmpty(f)) : [], m = (f) => find(r, (y) => y.prop === f);
5221
5221
  return /* @__PURE__ */ jsx(Fragment, { children: p && /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-1", children: [
5222
5222
  /* @__PURE__ */ jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
5223
5223
  i("Style element"),
@@ -5239,7 +5239,7 @@ const BlockStylingProps = () => {
5239
5239
  {
5240
5240
  type: "button",
5241
5241
  className: "ml-1 rounded-sm p-0.5 hover:bg-blue-300 hover:text-blue-600",
5242
- onClick: (k) => k.stopPropagation(),
5242
+ onClick: (y) => y.stopPropagation(),
5243
5243
  children: /* @__PURE__ */ jsx(MoreVertical, { className: "h-3 w-3" })
5244
5244
  }
5245
5245
  ) }),
@@ -5417,47 +5417,47 @@ 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), [k, b] = useState(""), [A, E] = useState(!1), [_, 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(""), [A, _] = useState(!1), [E, N] = useState(!1);
5421
5421
  useEffect(() => {
5422
- const { value: S, unit: C } = getClassValueAndUnit(i);
5423
- if (C === "") {
5424
- l(S), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5422
+ const { value: C, unit: v } = getClassValueAndUnit(i);
5423
+ if (v === "") {
5424
+ l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5425
5425
  return;
5426
5426
  }
5427
- m(C), l(C === "class" || isEmpty(S) ? "" : S);
5427
+ m(v), l(v === "class" || isEmpty(C) ? "" : C);
5428
5428
  }, [i, p, u]);
5429
- const w = useThrottledCallback((S) => c(S), [c], THROTTLE_TIME), y = useThrottledCallback((S) => c(S, !1), [c], THROTTLE_TIME), v = useCallback(
5430
- (S = !1) => {
5431
- const C = getUserInputValues(`${a}`, u);
5432
- if (get(C, "error", !1)) {
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)) {
5433
5433
  f(!0);
5434
5434
  return;
5435
5435
  }
5436
- const j = get(C, "unit") !== "" ? get(C, "unit") : h;
5437
- if (j === "auto" || j === "none") {
5438
- w(`${d}${j}`);
5436
+ const B = get(v, "unit") !== "" ? get(v, "unit") : h;
5437
+ if (B === "auto" || B === "none") {
5438
+ w(`${d}${B}`);
5439
5439
  return;
5440
5440
  }
5441
- if (get(C, "value") === "")
5441
+ if (get(v, "value") === "")
5442
5442
  return;
5443
- const T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5444
- S ? y(T) : w(T);
5443
+ const T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
5444
+ C ? S(T) : w(T);
5445
5445
  },
5446
- [w, y, a, h, d, u]
5447
- ), B = useCallback(
5448
- (S) => {
5449
- const C = getUserInputValues(`${a}`, u);
5450
- if (get(C, "error", !1)) {
5446
+ [w, S, a, h, d, u]
5447
+ ), j = useCallback(
5448
+ (C) => {
5449
+ const v = getUserInputValues(`${a}`, u);
5450
+ if (get(v, "error", !1)) {
5451
5451
  f(!0);
5452
5452
  return;
5453
5453
  }
5454
- if (S === "auto" || S === "none") {
5455
- w(`${d}${S}`);
5454
+ if (C === "auto" || C === "none") {
5455
+ w(`${d}${C}`);
5456
5456
  return;
5457
5457
  }
5458
- if (get(C, "value") === "")
5458
+ if (get(v, "value") === "")
5459
5459
  return;
5460
- const j = get(C, "unit") !== "" ? get(C, "unit") : S, T = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5460
+ const B = get(v, "unit") !== "" ? get(v, "unit") : C, T = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
5461
5461
  w(T);
5462
5462
  },
5463
5463
  [w, a, d, u]
@@ -5481,31 +5481,31 @@ const BlockStylingProps = () => {
5481
5481
  "input",
5482
5482
  {
5483
5483
  readOnly: h === "class",
5484
- onKeyPress: (S) => {
5485
- S.key === "Enter" && v();
5484
+ onKeyPress: (C) => {
5485
+ C.key === "Enter" && k();
5486
5486
  },
5487
- onKeyDown: (S) => {
5488
- if (S.keyCode !== 38 && S.keyCode !== 40)
5487
+ onKeyDown: (C) => {
5488
+ if (C.keyCode !== 38 && C.keyCode !== 40)
5489
5489
  return;
5490
- S.preventDefault(), N(!0);
5491
- const C = parseInt$1(S.target.value);
5492
- let j = isNaN$1(C) ? 0 : C;
5493
- S.keyCode === 38 && (j += 1), S.keyCode === 40 && (j -= 1);
5494
- const I = `${j}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${h === "-" ? "" : h}]`;
5495
- y(P);
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);
5496
5496
  },
5497
- onKeyUp: (S) => {
5498
- _ && (S.preventDefault(), N(!1));
5497
+ onKeyUp: (C) => {
5498
+ E && (C.preventDefault(), N(!1));
5499
5499
  },
5500
- onBlur: () => v(),
5501
- onChange: (S) => {
5502
- f(!1), l(S.target.value);
5500
+ onBlur: () => k(),
5501
+ onChange: (C) => {
5502
+ f(!1), l(C.target.value);
5503
5503
  },
5504
- onClick: (S) => {
5505
- var C;
5506
- (C = S == null ? void 0 : S.target) == null || C.select(), n(!1);
5504
+ onClick: (C) => {
5505
+ var v;
5506
+ (v = C == null ? void 0 : C.target) == null || v.select(), n(!1);
5507
5507
  },
5508
- value: A ? k : a,
5508
+ value: A ? 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,8 +5530,8 @@ const BlockStylingProps = () => {
5530
5530
  {
5531
5531
  units: u,
5532
5532
  current: h,
5533
- onSelect: (S) => {
5534
- n(!1), m(S), B(S);
5533
+ onSelect: (C) => {
5534
+ n(!1), m(C), j(C);
5535
5535
  }
5536
5536
  }
5537
5537
  ) })
@@ -5540,19 +5540,19 @@ const BlockStylingProps = () => {
5540
5540
  ["none", "auto"].indexOf(h) !== -1 || A ? null : /* @__PURE__ */ jsx(
5541
5541
  DragStyleButton,
5542
5542
  {
5543
- onDragStart: () => E(!0),
5544
- onDragEnd: (S) => {
5545
- if (b(() => ""), E(!1), isEmpty(S))
5543
+ onDragStart: () => _(!0),
5544
+ onDragEnd: (C) => {
5545
+ if (b(() => ""), _(!1), isEmpty(C))
5546
5546
  return;
5547
- const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5547
+ const v = `${C}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${h === "-" ? "" : h}]`;
5548
5548
  w(I);
5549
5549
  },
5550
- onDrag: (S) => {
5551
- if (isEmpty(S))
5550
+ onDrag: (C) => {
5551
+ if (isEmpty(C))
5552
5552
  return;
5553
- b(S);
5554
- const C = `${S}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
5555
- y(I);
5553
+ b(C);
5554
+ const v = `${C}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${h === "-" ? "" : h}]`;
5555
+ S(I);
5556
5556
  },
5557
5557
  currentValue: a,
5558
5558
  unit: h,
@@ -5617,8 +5617,8 @@ const COLOR_PROP = {
5617
5617
  }, ColorChoice = ({ property: o, onChange: r }) => {
5618
5618
  const n = useCurrentClassByProperty(o), a = useMemo(() => get(n, "cls", ""), [n]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
5619
5619
  // eslint-disable-next-line no-shadow
5620
- (k) => {
5621
- ["current", "inherit", "transparent", "black", "white"].includes(k) ? (c([]), p({ color: k })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: k, shade: b.shade ? b.shade : "500" })));
5620
+ (y) => {
5621
+ ["current", "inherit", "transparent", "black", "white"].includes(y) ? (c([]), p({ color: y })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((b) => ({ ...b, color: y, shade: b.shade ? b.shade : "500" })));
5622
5622
  },
5623
5623
  [c, p]
5624
5624
  );
@@ -5629,8 +5629,8 @@ const COLOR_PROP = {
5629
5629
  }, [g]);
5630
5630
  const x = useCallback(
5631
5631
  // eslint-disable-next-line no-shadow
5632
- (k) => {
5633
- p({ color: g, shade: k });
5632
+ (y) => {
5633
+ p({ color: g, shade: y });
5634
5634
  },
5635
5635
  [g]
5636
5636
  );
@@ -6015,34 +6015,34 @@ const COLOR_PROP = {
6015
6015
  "2xl": "1536px"
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
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), x = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), k = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
6019
- (y, v = !0) => {
6020
- const B = { dark: p, mq: g, mod: u, cls: y, property: l, fullCls: "" };
6021
- (p || u !== "") && (B.mq = "xs");
6022
- const S = generateFullClsName(B);
6023
- m(f, [S], v);
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);
6024
6024
  },
6025
6025
  [f, p, g, u, l, m]
6026
6026
  ), A = useCallback(() => {
6027
- x(f, [k], !0);
6028
- }, [f, k, x]), E = useMemo(() => canChangeClass(h, g), [h, g]);
6027
+ x(f, [y], !0);
6028
+ }, [f, y, x]), _ = useMemo(() => canChangeClass(h, g), [h, g]);
6029
6029
  useEffect(() => {
6030
- i(E, h);
6031
- }, [E, i, h]);
6032
- const [, , _] = useScreenSizeWidth(), N = useCallback(
6033
- (y) => {
6034
- _({
6030
+ i(_, h);
6031
+ }, [_, i, h]);
6032
+ const [, , E] = useScreenSizeWidth(), N = useCallback(
6033
+ (S) => {
6034
+ E({
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
- }[y]);
6041
+ }[S]);
6042
6042
  },
6043
- [_]
6043
+ [E]
6044
6044
  ), w = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
6045
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: h && w, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
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
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) }) }),
6047
6047
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6048
6048
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
@@ -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 ${k ? "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" }) }) : E && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
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: [
6066
6066
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6067
6067
  "button",
6068
6068
  {
@@ -6286,7 +6286,7 @@ const COLOR_PROP = {
6286
6286
  u.includes(b) ? u.length > 2 && g(u.filter((A) => A !== b)) : g((A) => [...A, b]);
6287
6287
  }, f = (b) => {
6288
6288
  r || l(b), c(b);
6289
- }, k = getBreakpointValue(r ? i : a).toLowerCase();
6289
+ }, y = getBreakpointValue(r ? i : a).toLowerCase();
6290
6290
  return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
6291
6291
  BreakpointCard,
6292
6292
  {
@@ -6294,7 +6294,7 @@ const COLOR_PROP = {
6294
6294
  ...b,
6295
6295
  onClick: f,
6296
6296
  key: b.breakpoint,
6297
- currentBreakpoint: k
6297
+ currentBreakpoint: y
6298
6298
  }
6299
6299
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6300
6300
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
@@ -6308,7 +6308,7 @@ const COLOR_PROP = {
6308
6308
  ...b,
6309
6309
  onClick: f,
6310
6310
  key: b.breakpoint,
6311
- currentBreakpoint: k
6311
+ currentBreakpoint: y
6312
6312
  }
6313
6313
  )
6314
6314
  ) }),
@@ -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(""), k = (I = first(d)) == null ? void 0 : I.prop, { classes: b } = getSplitChaiClasses(get(p, k, "")), A = b.split(" ").filter((T) => !isEmpty(T)), E = () => {
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)), _ = () => {
6467
6467
  const T = x.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6468
6468
  u(h, T, !0), f("");
6469
- }, [_, N] = useState([]), w = ({ value: T }) => {
6469
+ }, [E, N] = useState([]), w = ({ 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
- }, y = () => {
6481
+ }, S = () => {
6482
6482
  N([]);
6483
- }, v = (T) => T.name, B = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), S = useMemo(
6483
+ }, k = (T) => T.name, j = (T) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: T.name }), C = useMemo(
6484
6484
  () => ({
6485
6485
  ref: o,
6486
6486
  autoComplete: "off",
@@ -6495,17 +6495,17 @@ function ManualClasses() {
6495
6495
  }, 0);
6496
6496
  },
6497
6497
  onKeyDown: (T) => {
6498
- T.key === "Enter" && x.trim() !== "" && E();
6498
+ T.key === "Enter" && x.trim() !== "" && _();
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
- ), C = (T) => {
6504
+ ), v = (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
- }, j = () => {
6508
+ }, B = () => {
6509
6509
  if (navigator.clipboard === void 0) {
6510
6510
  toast.error(c("Clipboard not supported"));
6511
6511
  return;
@@ -6517,7 +6517,7 @@ function ManualClasses() {
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: j, className: "cursor-pointer" }) }),
6520
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: B, 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: _,
6536
+ suggestions: E,
6537
6537
  onSuggestionsFetchRequested: w,
6538
- onSuggestionsClearRequested: y,
6539
- getSuggestionValue: v,
6540
- renderSuggestion: B,
6541
- inputProps: S,
6538
+ onSuggestionsClearRequested: S,
6539
+ getSuggestionValue: k,
6540
+ renderSuggestion: j,
6541
+ inputProps: C,
6542
6542
  containerProps: {
6543
6543
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
6544
6544
  },
@@ -6554,7 +6554,7 @@ function ManualClasses() {
6554
6554
  {
6555
6555
  variant: "outline",
6556
6556
  className: "h-6 border-border",
6557
- onClick: E,
6557
+ onClick: _,
6558
6558
  disabled: x.trim() === "",
6559
6559
  size: "sm",
6560
6560
  children: /* @__PURE__ */ jsx(PlusIcon, {})
@@ -6569,10 +6569,10 @@ function ManualClasses() {
6569
6569
  value: r,
6570
6570
  onChange: (L) => n(L.target.value),
6571
6571
  onBlur: () => {
6572
- C(T);
6572
+ v(T);
6573
6573
  },
6574
6574
  onKeyDown: (L) => {
6575
- L.key === "Enter" && C(T);
6575
+ L.key === "Enter" && v(T);
6576
6576
  },
6577
6577
  onFocus: (L) => {
6578
6578
  setTimeout(() => {
@@ -6744,8 +6744,8 @@ function BlockStyling() {
6744
6744
  m = isNaN(m) ? 0 : m;
6745
6745
  let x = MAPPER[i.dragUnit];
6746
6746
  (startsWith(h, "scale") || h === "opacity") && (x = 10);
6747
- let k = (i.dragStartY - u.pageY) / x + m;
6748
- g && k < 0 && (k = 0), h === "opacity" && k > 1 && (k = 1), i.onDrag(`${k}`), l(`${k}`);
6747
+ let y = (i.dragStartY - u.pageY) / x + m;
6748
+ g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6749
6749
  },
6750
6750
  [i],
6751
6751
  50
@@ -6788,8 +6788,8 @@ const CoreBlock = ({
6788
6788
  }) => {
6789
6789
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6790
6790
  if (has(o, "blocks")) {
6791
- const k = isFunction(o.blocks) ? o.blocks() : o.blocks;
6792
- u(syncBlocksWithDefaults(k), n || null, a);
6791
+ const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6792
+ u(syncBlocksWithDefaults(y), n || null, a);
6793
6793
  } else
6794
6794
  p(o, n || null, a);
6795
6795
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
@@ -6801,8 +6801,8 @@ const CoreBlock = ({
6801
6801
  disabled: r,
6802
6802
  onClick: m,
6803
6803
  type: "button",
6804
- onDragStart: (k) => {
6805
- k.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), k.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6804
+ onDragStart: (y) => {
6805
+ y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6806
6806
  g([]), h();
6807
6807
  }, 200);
6808
6808
  },
@@ -7017,7 +7017,7 @@ const CoreBlock = ({
7017
7017
  }
7018
7018
  }
7019
7019
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
7020
- var h, m, x, f, k, b, A, E, _, N;
7020
+ var h, m, x, f, y, b, A, _, E, N;
7021
7021
  if (n.type === "comment") return [];
7022
7022
  let a = { _id: generateUUID() };
7023
7023
  if (r && (a._parent = r.block._id), n.type === "text")
@@ -7039,7 +7039,7 @@ const CoreBlock = ({
7039
7039
  ...getAttrs(n),
7040
7040
  ...getStyles(n)
7041
7041
  }, n.attributes) {
7042
- const w = n.attributes.find((y) => includes(NAME_ATTRIBUTES, y.key));
7042
+ const w = n.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
7043
7043
  w && (a._name = w.value);
7044
7044
  }
7045
7045
  if (i)
@@ -7057,30 +7057,30 @@ const CoreBlock = ({
7057
7057
  ];
7058
7058
  a = {
7059
7059
  ...a,
7060
- href: ((h = l.find((y) => y.key === "href")) == null ? void 0 : h.value) || "",
7061
- hrefType: ((m = l.find((y) => y.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7062
- autoplay: ((x = l.find((y) => y.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
7063
- maxWidth: ((k = (f = l.find((y) => y.key === "data-maxwidth")) == null ? void 0 : f.value) == null ? void 0 : k.replace("px", "")) || "",
7064
- backdropColor: ((b = l.find((y) => y.key === "data-overlay")) == null ? void 0 : b.value) || "",
7065
- galleryName: ((A = l.find((y) => y.key === "data-gall")) == null ? void 0 : A.value) || ""
7066
- }, forEach(w, (y) => {
7067
- has(a, `styles_attrs.${y}`) && delete a.styles_attrs[y];
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
7068
  });
7069
7069
  }
7070
7070
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7071
7071
  delete a.styles_attrs;
7072
- const w = filter(n.children || [], (v) => (v == null ? void 0 : v.tagName) !== "span");
7072
+ const w = filter(n.children || [], (k) => (k == null ? void 0 : k.tagName) !== "span");
7073
7073
  a.content = getTextContent(w);
7074
- const y = find(
7074
+ const S = find(
7075
7075
  n.children || [],
7076
- (v) => (v == null ? void 0 : v.tagName) === "span" && some(v.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg")
7076
+ (k) => (k == null ? void 0 : k.tagName) === "span" && some(k.children || [], (j) => (j == null ? void 0 : j.tagName) === "svg")
7077
7077
  );
7078
- if (y) {
7079
- const v = find(y.children || [], (B) => (B == null ? void 0 : B.tagName) === "svg");
7080
- if (v) {
7081
- a.icon = stringify([v]);
7082
- const { height: B, width: S } = getSvgDimensions(v, "16px", "16px");
7083
- a.iconHeight = B, a.iconWidth = S;
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
7084
  }
7085
7085
  }
7086
7086
  return [a];
@@ -7092,14 +7092,14 @@ const CoreBlock = ({
7092
7092
  const w = stringify([n]);
7093
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
7094
  } else if (n.tagName === "svg") {
7095
- const w = get(find(n.attributes, { key: "class" }), "value", ""), { height: y, width: v } = getHeightAndWidthFromClass(w);
7096
- if (y && v)
7097
- a.styles = `${STYLES_KEY}, ${cn$2(`w-${v} h-${y}`, w)}`.trim(), a.height = y == null ? void 0 : y.replace("px", ""), a.width = v == null ? void 0 : v.replace("px", "");
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
7098
  else {
7099
- const B = (E = find(n.attributes, { key: "height" })) == null ? void 0 : E.value, S = (_ = find(n.attributes, { key: "width" })) == null ? void 0 : _.value;
7100
- B && S ? (a.styles = `${STYLES_KEY}, ${cn$2(`w-[${S}px] h-[${B}px]`, w)}`.trim(), a.height = B, a.width = S) : a.styles = `${STYLES_KEY}, ${cn$2("w-full h-full", w)}`.trim();
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
7101
  }
7102
- return n.attributes = filter(n.attributes, (B) => !includes(["style", "width", "height", "class"], B.key)), a.icon = stringify([n]), [a];
7102
+ return n.attributes = filter(n.attributes, (j) => !includes(["style", "width", "height", "class"], j.key)), a.icon = stringify([n]), [a];
7103
7103
  } else if (n.tagName == "option" && r && ((N = r.block) == null ? void 0 : N._type) === "Select")
7104
7104
  return r.block.options.push({
7105
7105
  label: getTextContent(n.children),
@@ -7216,18 +7216,18 @@ const registerChaiLibrary = (o, r) => {
7216
7216
  parentId: n = void 0,
7217
7217
  position: a = -1
7218
7218
  }) => {
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), k = (E) => {
7220
- const _ = has(E, "styles_attrs.data-page-section");
7221
- return E._type === "Box" && _;
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;
7222
7222
  }, b = useCallback(
7223
- async (E) => {
7224
- if (E.stopPropagation(), has(o, "component")) {
7223
+ async (_) => {
7224
+ if (_.stopPropagation(), has(o, "component")) {
7225
7225
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7226
7226
  return;
7227
7227
  }
7228
7228
  i(!0);
7229
- let _ = await c({ library: r, block: o });
7230
- typeof _ == "string" && (_ = getBlocksFromHTML(_)), isEmpty(_) || p(syncBlocksWithDefaults(_), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
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);
7231
7231
  },
7232
7232
  [d, p, o, c, r, n, a]
7233
7233
  );
@@ -7238,18 +7238,18 @@ const registerChaiLibrary = (o, r) => {
7238
7238
  onClick: l ? () => {
7239
7239
  } : b,
7240
7240
  draggable: x ? "true" : "false",
7241
- onDragStart: async (E) => {
7242
- const _ = await c({ library: r, block: o });
7241
+ onDragStart: async (_) => {
7242
+ const E = await c({ library: r, block: o });
7243
7243
  let N = n;
7244
- if (k(first(_)) && (N = null), !isEmpty(_)) {
7245
- const w = { blocks: _, uiLibrary: !0, parent: N };
7246
- if (E.dataTransfer.setData("text/plain", JSON.stringify(w)), o.preview) {
7247
- const y = new Image();
7248
- y.src = o.preview, y.onload = () => {
7249
- E.dataTransfer.setDragImage(y, 0, 0);
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);
7250
7250
  };
7251
7251
  } else
7252
- E.dataTransfer.setDragImage(new Image(), 0, 0);
7252
+ _.dataTransfer.setDragImage(new Image(), 0, 0);
7253
7253
  f(w), setTimeout(() => {
7254
7254
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7255
7255
  }, 200);
@@ -7276,7 +7276,7 @@ const registerChaiLibrary = (o, r) => {
7276
7276
  ] }) })
7277
7277
  ] });
7278
7278
  }, UILibrarySection = ({ parentId: o, position: r }) => {
7279
- const [n, a] = useSelectedLibrary(), l = useChaiLibraries(), i = l.find((C) => C.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), x = useRef(null);
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);
7280
7280
  useEffect(() => {
7281
7281
  c && c.length > 0 && (x.current = new Fuse(c, {
7282
7282
  keys: ["name", "label", "description", "group"],
@@ -7288,27 +7288,27 @@ const registerChaiLibrary = (o, r) => {
7288
7288
  m([]);
7289
7289
  return;
7290
7290
  }
7291
- const C = x.current.search(u).map((j) => j.item);
7292
- m(C);
7291
+ const v = x.current.search(u).map((B) => B.item);
7292
+ m(v);
7293
7293
  }, [u]);
7294
- const f = u.trim() && !isEmpty(h) ? h : c, k = groupBy(f, "group"), [b, A] = useState(null);
7294
+ const f = u.trim() && !isEmpty(h) ? h : c, y = groupBy(f, "group"), [b, A] = useState(null);
7295
7295
  useEffect(() => {
7296
- if (isEmpty(keys(k))) {
7296
+ if (isEmpty(keys(y))) {
7297
7297
  A(null);
7298
7298
  return;
7299
7299
  }
7300
- if (!b || !k[b]) {
7301
- A(first(keys(k)));
7300
+ if (!b || !y[b]) {
7301
+ A(first(keys(y)));
7302
7302
  return;
7303
7303
  }
7304
- }, [k, b]);
7305
- const E = get(k, b, []), _ = useRef(null), { t: N } = useTranslation(), w = (C) => {
7306
- _.current && (clearTimeout(_.current), _.current = null), _.current = setTimeout(() => {
7307
- _.current && A(C);
7304
+ }, [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);
7308
7308
  }, 400);
7309
- }, y = () => {
7309
+ }, S = () => {
7310
7310
  i != null && i.id && p(i.id);
7311
- }, v = () => {
7311
+ }, k = () => {
7312
7312
  g("");
7313
7313
  };
7314
7314
  if (d)
@@ -7316,7 +7316,7 @@ const registerChaiLibrary = (o, r) => {
7316
7316
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7317
7317
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7318
7318
  ] });
7319
- const B = filter(E, (C, j) => j % 2 === 0), S = filter(E, (C, j) => j % 2 === 1);
7319
+ const j = filter(_, (v, B) => B % 2 === 0), C = filter(_, (v, B) => B % 2 === 1);
7320
7320
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full flex-col", children: [
7321
7321
  /* @__PURE__ */ jsx("div", { className: "flex items-center gap-2 border-border py-2", children: /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
7322
7322
  /* @__PURE__ */ jsx(Search, { className: "absolute left-2 top-2.5 h-4 w-4 text-muted-foreground" }),
@@ -7325,14 +7325,14 @@ const registerChaiLibrary = (o, r) => {
7325
7325
  {
7326
7326
  placeholder: N("Search blocks..."),
7327
7327
  value: u,
7328
- onChange: (C) => g(C.target.value),
7328
+ onChange: (v) => g(v.target.value),
7329
7329
  className: "w-full pl-8 pr-8"
7330
7330
  }
7331
7331
  ),
7332
7332
  u && /* @__PURE__ */ jsx(
7333
7333
  "button",
7334
7334
  {
7335
- onClick: v,
7335
+ onClick: k,
7336
7336
  className: "absolute right-2 top-2.5 text-muted-foreground hover:text-foreground",
7337
7337
  children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
7338
7338
  }
@@ -7344,58 +7344,58 @@ const registerChaiLibrary = (o, r) => {
7344
7344
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7345
7345
  /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: N("Groups") }),
7346
7346
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7347
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "mt-4 flex flex-col items-center justify-center gap-3 p-4 text-center", children: u ? /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("No matching blocks found") }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7347
+ /* @__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
7348
  /* @__PURE__ */ jsx("p", { className: "text-sm", children: N("Failed to load the UI library. Try again") }),
7349
- /* @__PURE__ */ jsxs(Button, { onClick: y, variant: "outline", size: "sm", className: "gap-2", children: [
7349
+ /* @__PURE__ */ jsxs(Button, { onClick: S, variant: "outline", size: "sm", className: "gap-2", children: [
7350
7350
  /* @__PURE__ */ jsx(RefreshCw, { className: "h-4 w-4" }),
7351
7351
  N("Retry")
7352
7352
  ] })
7353
- ] }) }) : map(k, (C, j) => /* @__PURE__ */ jsxs(
7353
+ ] }) }) : map(y, (v, B) => /* @__PURE__ */ jsxs(
7354
7354
  "div",
7355
7355
  {
7356
- onMouseEnter: () => w(j),
7357
- onMouseLeave: () => clearTimeout(_.current),
7356
+ onMouseEnter: () => w(B),
7357
+ onMouseLeave: () => clearTimeout(E.current),
7358
7358
  role: "button",
7359
- onClick: () => A(j),
7359
+ onClick: () => A(B),
7360
7360
  className: cn$2(
7361
7361
  "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
- j === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7362
+ B === b ? "bg-primary text-primary-foreground hover:bg-primary/80" : ""
7363
7363
  ),
7364
7364
  children: [
7365
- /* @__PURE__ */ jsx("span", { children: capitalize(N(j.toLowerCase())) }),
7365
+ /* @__PURE__ */ jsx("span", { children: capitalize(N(B.toLowerCase())) }),
7366
7366
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7367
7367
  ]
7368
7368
  },
7369
- j
7369
+ B
7370
7370
  )) })
7371
7371
  ] })
7372
7372
  ] }),
7373
7373
  /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-col border-l border-border", children: /* @__PURE__ */ jsxs(
7374
7374
  ScrollArea,
7375
7375
  {
7376
- onMouseEnter: () => _.current ? clearTimeout(_.current) : null,
7376
+ onMouseEnter: () => E.current ? clearTimeout(E.current) : null,
7377
7377
  className: "z-10 flex h-full max-h-full w-full flex-col gap-2 transition-all ease-linear",
7378
7378
  children: [
7379
- isEmpty(E) && !isEmpty(k) ? /* @__PURE__ */ jsx("div", { className: "flex h-full flex-col items-center justify-center p-6 text-center", children: /* @__PURE__ */ jsx("p", { className: "text-sm", children: 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: B.map((C, j) => /* @__PURE__ */ jsx(
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(
7381
7381
  BlockCard,
7382
7382
  {
7383
7383
  parentId: o,
7384
7384
  position: r,
7385
- block: C,
7385
+ block: v,
7386
7386
  library: i
7387
7387
  },
7388
- `block-${j}`
7388
+ `block-${B}`
7389
7389
  )) }),
7390
- /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: S.map((C, j) => /* @__PURE__ */ jsx(
7390
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: C.map((v, B) => /* @__PURE__ */ jsx(
7391
7391
  BlockCard,
7392
7392
  {
7393
7393
  parentId: o,
7394
7394
  position: r,
7395
- block: C,
7395
+ block: v,
7396
7396
  library: i
7397
7397
  },
7398
- `block-second-${j}`
7398
+ `block-second-${B}`
7399
7399
  )) })
7400
7400
  ] }),
7401
7401
  /* @__PURE__ */ jsx("br", {}),
@@ -7431,15 +7431,15 @@ const registerChaiLibrary = (o, r) => {
7431
7431
  error: c
7432
7432
  }), g(!0);
7433
7433
  else if (!l && Object.keys(a || {}).length > 0) {
7434
- const m = Object.entries(a).map(([f, k]) => {
7435
- const b = k, A = b.type || "partial", E = formatReadableName(A);
7434
+ const m = Object.entries(a).map(([f, y]) => {
7435
+ const b = y, A = b.type || "partial", _ = formatReadableName(A);
7436
7436
  return {
7437
7437
  type: "PartialBlock",
7438
7438
  // Set the type to PartialBlock
7439
7439
  label: formatReadableName(b.name || f),
7440
7440
  description: b.description || "",
7441
7441
  icon: Globe,
7442
- group: E,
7442
+ group: _,
7443
7443
  // Use formatted type as group
7444
7444
  category: "partial",
7445
7445
  partialBlockId: f,
@@ -7494,44 +7494,44 @@ const registerChaiLibrary = (o, r) => {
7494
7494
  }, ADD_BLOCK_TABS = {}, registerChaiAddBlockTab = (o, r) => {
7495
7495
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7496
7496
  }, 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 S;
7498
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (S = find(c, (C) => C._id === n)) == null ? void 0 : S._type, [m, x] = useState("all"), [f, k] = useState(null), b = useRef(null);
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);
7499
7499
  useEffect(() => {
7500
- const C = setTimeout(() => {
7501
- var j;
7502
- (j = u.current) == null || j.focus();
7500
+ const v = setTimeout(() => {
7501
+ var B;
7502
+ (B = u.current) == null || B.focus();
7503
7503
  }, 0);
7504
- return () => clearTimeout(C);
7504
+ return () => clearTimeout(v);
7505
7505
  }, [g]), useEffect(() => {
7506
- d && (x("all"), k(null));
7507
- }, [d]), useEffect(() => (b.current = debounce((C) => {
7508
- x(C);
7506
+ d && (x("all"), y(null));
7507
+ }, [d]), useEffect(() => (b.current = debounce((v) => {
7508
+ x(v);
7509
7509
  }, 500), () => {
7510
7510
  b.current && b.current.cancel();
7511
7511
  }), []);
7512
- const A = useCallback((C) => {
7513
- k(C), b.current && b.current(C);
7514
- }, []), E = useCallback(() => {
7515
- k(null), b.current && b.current.cancel();
7516
- }, []), _ = useCallback((C) => {
7517
- b.current && b.current.cancel(), x(C), k(null);
7512
+ const A = useCallback((v) => {
7513
+ y(v), b.current && b.current(v);
7514
+ }, []), _ = useCallback(() => {
7515
+ y(null), b.current && b.current.cancel();
7516
+ }, []), E = useCallback((v) => {
7517
+ b.current && b.current.cancel(), x(v), y(null);
7518
7518
  }, []), N = useMemo(
7519
7519
  () => d ? values(r).filter(
7520
- (C) => {
7521
- var j, I;
7522
- return (((j = C.label) == null ? void 0 : j.toLowerCase()) + " " + ((I = C.type) == null ? void 0 : I.toLowerCase())).includes(d.toLowerCase());
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());
7523
7523
  }
7524
7524
  ) : r,
7525
7525
  [r, d]
7526
7526
  ), w = useMemo(
7527
7527
  () => d ? o.filter(
7528
- (C) => reject(filter(values(N), { group: C }), { hidden: !0 }).length > 0
7529
- ) : o.filter((C) => reject(filter(values(r), { group: C }), { hidden: !0 }).length > 0),
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),
7530
7530
  [r, N, o, d]
7531
- ), y = useMemo(
7532
- () => sortBy(w, (C) => CORE_GROUPS.indexOf(C) === -1 ? 99 : CORE_GROUPS.indexOf(C)),
7531
+ ), S = useMemo(
7532
+ () => sortBy(w, (v) => CORE_GROUPS.indexOf(v) === -1 ? 99 : CORE_GROUPS.indexOf(v)),
7533
7533
  [w]
7534
- ), v = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), B = useMemo(() => m === "all" ? y : [m], [y, m]);
7534
+ ), k = useMemo(() => m === "all" ? N : filter(values(N), { group: m }), [N, m]), j = useMemo(() => m === "all" ? S : [m], [S, m]);
7535
7535
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7536
7536
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7537
7537
  Input$1,
@@ -7541,32 +7541,32 @@ const registerChaiLibrary = (o, r) => {
7541
7541
  placeholder: i("Search blocks..."),
7542
7542
  value: d,
7543
7543
  className: "-ml-2",
7544
- onChange: (C) => p(C.target.value)
7544
+ onChange: (v) => p(v.target.value)
7545
7545
  }
7546
7546
  ) }),
7547
7547
  /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7548
- y.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: [
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: [
7549
7549
  /* @__PURE__ */ jsx(
7550
7550
  "button",
7551
7551
  {
7552
- onClick: () => _("all"),
7552
+ onClick: () => E("all"),
7553
7553
  onMouseEnter: () => A("all"),
7554
- onMouseLeave: E,
7554
+ onMouseLeave: _,
7555
7555
  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
7556
  children: i("All")
7557
7557
  },
7558
7558
  "sidebar-all"
7559
7559
  ),
7560
- y.map((C) => /* @__PURE__ */ jsx(
7560
+ S.map((v) => /* @__PURE__ */ jsx(
7561
7561
  "button",
7562
7562
  {
7563
- onClick: () => _(C),
7564
- onMouseEnter: () => A(C),
7565
- onMouseLeave: E,
7566
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === C || f === C ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7567
- children: capitalize(i(C.toLowerCase()))
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()))
7568
7568
  },
7569
- `sidebar-${C}`
7569
+ `sidebar-${v}`
7570
7570
  ))
7571
7571
  ] }) }) }),
7572
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: [
@@ -7574,22 +7574,22 @@ const registerChaiLibrary = (o, r) => {
7574
7574
  ' "',
7575
7575
  d,
7576
7576
  '"'
7577
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: B.map((C) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7578
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(C.toLowerCase())) }),
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())) }),
7579
7579
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7580
- m === "all" ? filter(values(v), { group: C }) : values(v),
7580
+ m === "all" ? filter(values(k), { group: v }) : values(k),
7581
7581
  { hidden: !0 }
7582
- ).map((j) => /* @__PURE__ */ jsx(
7582
+ ).map((B) => /* @__PURE__ */ jsx(
7583
7583
  CoreBlock,
7584
7584
  {
7585
7585
  parentId: n,
7586
7586
  position: a,
7587
- block: j,
7588
- disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
7587
+ block: B,
7588
+ disabled: !canAcceptChildBlock(h, B.type) || !canBeNestedInside(h, B.type)
7589
7589
  },
7590
- j.type
7590
+ B.type
7591
7591
  )) })
7592
- ] }, C)) }) }) })
7592
+ ] }, v)) }) }) })
7593
7593
  ] })
7594
7594
  ] });
7595
7595
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
@@ -7942,33 +7942,33 @@ const Input = ({ node: o }) => {
7942
7942
  var P;
7943
7943
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7944
7944
  let p = null;
7945
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: x, isSelected: f, willReceiveDrop: k, isDragging: b, isEditing: A, handleClick: E } = o, _ = (L) => {
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) => {
7946
7946
  L.stopPropagation(), !l.includes(m) && o.toggle();
7947
7947
  }, N = (L) => {
7948
7948
  L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7949
7949
  }, w = (L) => {
7950
7950
  L.isInternal && p !== null && (p ? L.open() : L.close(), p = null);
7951
- }, [y, v] = useAtom$1(currentAddSelection), B = () => {
7951
+ }, [S, k] = useAtom$1(currentAddSelection), j = () => {
7952
7952
  var L;
7953
- S(), o.parent.isSelected || v((L = o == null ? void 0 : o.parent) == null ? void 0 : L.id);
7954
- }, S = () => {
7955
- v(null);
7956
- }, C = (L) => {
7957
- S(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), E(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);
7958
7958
  };
7959
7959
  useEffect(() => {
7960
7960
  const L = setTimeout(() => {
7961
- k && !o.isOpen && !b && !l.includes(m) && o.toggle();
7961
+ y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7962
7962
  }, 500);
7963
7963
  return () => clearTimeout(L);
7964
- }, [k, o, b]);
7965
- const j = (L, D) => {
7964
+ }, [y, o, b]);
7965
+ const B = (L, D) => {
7966
7966
  const R = c.contentDocument || c.contentWindow.document, M = R.querySelector(`[data-block-id=${L}]`);
7967
7967
  M && M.setAttribute("data-drop", D);
7968
7968
  const $ = M.getBoundingClientRect(), O = c.getBoundingClientRect();
7969
7969
  $.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (R.documentElement.scrollTop = M.offsetTop - O.top);
7970
7970
  }, I = (L) => {
7971
- S();
7971
+ C();
7972
7972
  const D = get(o, "parent.id");
7973
7973
  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
7974
  };
@@ -7996,20 +7996,20 @@ const Input = ({ node: o }) => {
7996
7996
  {
7997
7997
  onMouseEnter: () => g(m),
7998
7998
  onMouseLeave: () => h(),
7999
- onClick: C,
7999
+ onClick: v,
8000
8000
  style: r,
8001
8001
  "data-node-id": m,
8002
8002
  ref: l.includes(m) ? null : n,
8003
8003
  onDragStart: () => N(o),
8004
8004
  onDragEnd: () => w(o),
8005
8005
  onDragOver: (L) => {
8006
- L.preventDefault(), j(m, "yes");
8006
+ L.preventDefault(), B(m, "yes");
8007
8007
  },
8008
8008
  onDragLeave: (L) => {
8009
- L.preventDefault(), j(m, "no");
8009
+ L.preventDefault(), B(m, "no");
8010
8010
  },
8011
8011
  onDrop: (L) => {
8012
- L.preventDefault(), j(m, "no");
8012
+ L.preventDefault(), B(m, "no");
8013
8013
  },
8014
8014
  children: [
8015
8015
  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 +8018,8 @@ const Input = ({ node: o }) => {
8018
8018
  onClick: (L) => {
8019
8019
  L.stopPropagation(), I(o.childIndex);
8020
8020
  },
8021
- onMouseEnter: B,
8022
- onMouseLeave: S,
8021
+ onMouseEnter: j,
8022
+ onMouseLeave: C,
8023
8023
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-primary opacity-0 delay-200 duration-200 group-hover:opacity-100",
8024
8024
  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
8025
  }
@@ -8030,8 +8030,8 @@ const Input = ({ node: o }) => {
8030
8030
  className: cn(
8031
8031
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 outline-none",
8032
8032
  f ? "bg-primary text-primary-foreground" : "hover:bg-primary/10 dark:hover:bg-gray-800",
8033
- k && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
8034
- (o == null ? void 0 : o.id) === y ? "bg-primary/10" : "",
8033
+ y && canAcceptChildBlock(x._type, "Icon") ? "bg-green-200" : "",
8034
+ (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
8035
8035
  b && "opacity-20",
8036
8036
  l.includes(m) ? "opacity-50" : "",
8037
8037
  T && f && "bg-primary/20 text-primary"
@@ -8042,7 +8042,7 @@ const Input = ({ node: o }) => {
8042
8042
  "div",
8043
8043
  {
8044
8044
  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: _, type: "button", children: /* @__PURE__ */ jsx(ChevronRight, { className: `h-3 w-3 stroke-[3] ${f ? "text-white" : "text-slate-400"}` }) })
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"}` }) })
8046
8046
  }
8047
8047
  ),
8048
8048
  /* @__PURE__ */ jsxs(
@@ -8526,23 +8526,23 @@ const Input = ({ node: o }) => {
8526
8526
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8527
8527
  const [r, n] = useDarkMode(), [a, l] = React.useState(""), [i, c] = React.useState(!1), d = useBuilderProp("themePresets", []), p = useBuilderProp("themePanelComponent", null), { hasPermission: u } = usePermissions();
8528
8528
  if (d) {
8529
- const w = d.map((y) => Object.keys(y)[0]);
8530
- DEFAULT_THEME_PRESET.forEach((y) => {
8531
- const v = Object.keys(y)[0];
8532
- w.includes(v) || d.push(y);
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);
8533
8533
  });
8534
8534
  }
8535
8535
  const [g, h] = useTheme(), m = useThemeOptions(), { t: x } = useTranslation(), f = React.useCallback(
8536
8536
  (w) => {
8537
- const y = { ...g };
8538
- setPreviousTheme(y), h(w), toast.success("Theme updated", {
8537
+ const S = { ...g };
8538
+ setPreviousTheme(S), h(w), toast.success("Theme updated", {
8539
8539
  action: {
8540
8540
  label: /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
8541
8541
  /* @__PURE__ */ jsx(Undo$1, { className: "h-4 w-4" }),
8542
8542
  " Undo"
8543
8543
  ] }),
8544
8544
  onClick: () => {
8545
- h(y), clearPreviousTheme(), toast.dismiss();
8545
+ h(S), clearPreviousTheme(), toast.dismiss();
8546
8546
  }
8547
8547
  },
8548
8548
  closeButton: !0,
@@ -8550,28 +8550,28 @@ const Input = ({ node: o }) => {
8550
8550
  });
8551
8551
  },
8552
8552
  [g, h]
8553
- ), k = () => {
8554
- const w = d.find((y) => Object.keys(y)[0] === a);
8553
+ ), y = () => {
8554
+ const w = d.find((S) => Object.keys(S)[0] === a);
8555
8555
  if (w) {
8556
- const y = Object.values(w)[0];
8557
- y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? (f(y), l("")) : console.error("Invalid preset structure:", y);
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);
8558
8558
  } else
8559
8559
  console.error("Preset not found:", a);
8560
8560
  }, b = (w) => {
8561
8561
  f(w), l("");
8562
8562
  }, A = useDebouncedCallback(
8563
- (w, y) => {
8563
+ (w, S) => {
8564
8564
  h(() => ({
8565
8565
  ...g,
8566
8566
  fontFamily: {
8567
8567
  ...g.fontFamily,
8568
- [w.replace(/font-/g, "")]: y
8568
+ [w.replace(/font-/g, "")]: S
8569
8569
  }
8570
8570
  }));
8571
8571
  },
8572
8572
  [g],
8573
8573
  200
8574
- ), E = React.useCallback(
8574
+ ), _ = React.useCallback(
8575
8575
  (w) => {
8576
8576
  h(() => ({
8577
8577
  ...g,
@@ -8579,33 +8579,33 @@ const Input = ({ node: o }) => {
8579
8579
  }));
8580
8580
  },
8581
8581
  [g]
8582
- ), _ = useDebouncedCallback(
8583
- (w, y) => {
8582
+ ), E = useDebouncedCallback(
8583
+ (w, S) => {
8584
8584
  h(() => {
8585
- const v = get(g, `colors.${w}`);
8586
- return r ? set(v, 1, y) : set(v, 0, y), {
8585
+ const k = get(g, `colors.${w}`);
8586
+ return r ? set(k, 1, S) : set(k, 0, S), {
8587
8587
  ...g,
8588
8588
  colors: {
8589
8589
  ...g.colors,
8590
- [w]: v
8590
+ [w]: k
8591
8591
  }
8592
8592
  };
8593
8593
  });
8594
8594
  },
8595
8595
  [g],
8596
8596
  200
8597
- ), N = (w) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(w.items).map(([y]) => {
8598
- const v = get(g, `colors.${y}.${r ? 1 : 0}`);
8599
- return v ? /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
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: [
8600
8600
  /* @__PURE__ */ jsx(
8601
8601
  ColorPickerInput,
8602
8602
  {
8603
- value: v,
8604
- onChange: (B) => _(y, B)
8603
+ value: k,
8604
+ onChange: (j) => E(S, j)
8605
8605
  }
8606
8606
  ),
8607
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
8608
- ] }, y) : null;
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;
8609
8609
  }) });
8610
8610
  return u("edit_theme") ? /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
8611
8611
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -8621,11 +8621,11 @@ const Input = ({ node: o }) => {
8621
8621
  /* @__PURE__ */ jsx("div", { className: "w-[70%]", children: /* @__PURE__ */ jsxs(Select$1, { value: a, onValueChange: l, children: [
8622
8622
  /* @__PURE__ */ jsx(SelectTrigger, { className: "h-9 w-full text-sm", children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "Select preset" }) }),
8623
8623
  /* @__PURE__ */ jsx(SelectContent, { children: Array.isArray(d) && d.map((w) => {
8624
- const y = Object.keys(w)[0], v = y.replaceAll("_", " ");
8625
- return /* @__PURE__ */ jsx(SelectItem, { value: y, children: capitalize(v) }, y);
8624
+ const S = Object.keys(w)[0], k = S.replaceAll("_", " ");
8625
+ return /* @__PURE__ */ jsx(SelectItem, { value: S, children: capitalize(k) }, S);
8626
8626
  }) })
8627
8627
  ] }) }),
8628
- /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: k, children: x("Apply") }) })
8628
+ /* @__PURE__ */ jsx("div", { className: "w-[25%]", children: /* @__PURE__ */ jsx(Button, { className: "w-full text-sm", disabled: !a, onClick: y, children: x("Apply") }) })
8629
8629
  ] })
8630
8630
  ] }),
8631
8631
  /* @__PURE__ */ jsx(Separator, {}),
@@ -8634,12 +8634,12 @@ const Input = ({ node: o }) => {
8634
8634
  /* @__PURE__ */ jsx(Type, { className: "h-3 w-3 text-gray-600" }),
8635
8635
  /* @__PURE__ */ jsx("span", { className: "text-xs font-medium text-gray-700", children: "Typography" })
8636
8636
  ] }),
8637
- (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, y]) => /* @__PURE__ */ jsx(
8637
+ (m == null ? void 0 : m.fontFamily) && /* @__PURE__ */ jsx("div", { className: "space-y-2", children: Object.entries(m.fontFamily).map(([w, S]) => /* @__PURE__ */ jsx(
8638
8638
  FontSelector,
8639
8639
  {
8640
8640
  label: w,
8641
- value: g.fontFamily[w.replace(/font-/g, "")] || y[Object.keys(y)[0]],
8642
- onChange: (v) => A(w, v)
8641
+ value: g.fontFamily[w.replace(/font-/g, "")] || S[Object.keys(S)[0]],
8642
+ onChange: (k) => A(w, k)
8643
8643
  },
8644
8644
  w
8645
8645
  )) }),
@@ -8652,7 +8652,7 @@ const Input = ({ node: o }) => {
8652
8652
  ] }),
8653
8653
  /* @__PURE__ */ jsx(Badge, { variant: "secondary", className: "text-xs", children: g.borderRadius })
8654
8654
  ] }),
8655
- /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: E }) })
8655
+ /* @__PURE__ */ jsx("div", { className: "flex items-center gap-4 py-2", children: /* @__PURE__ */ jsx(BorderRadiusInput, { value: g.borderRadius, onChange: _ }) })
8656
8656
  ] }),
8657
8657
  /* @__PURE__ */ jsx(Separator, {}),
8658
8658
  (m == null ? void 0 : m.colors) && /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
@@ -9305,24 +9305,24 @@ function AIChatPanel() {
9305
9305
  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
9306
  timestamp: /* @__PURE__ */ new Date()
9307
9307
  };
9308
- r((E) => [...E, A]), i(!1), d(null);
9308
+ r((_) => [..._, A]), i(!1), d(null);
9309
9309
  }, 1500);
9310
9310
  }, m = (b) => {
9311
9311
  b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
9312
9312
  }, x = (b) => {
9313
- var E;
9314
- const A = (E = b.target.files) == null ? void 0 : E[0];
9313
+ var _;
9314
+ const A = (_ = b.target.files) == null ? void 0 : _[0];
9315
9315
  if (A) {
9316
- const _ = new FileReader();
9317
- _.onload = (N) => {
9316
+ const E = new FileReader();
9317
+ E.onload = (N) => {
9318
9318
  var w;
9319
9319
  d((w = N.target) == null ? void 0 : w.result);
9320
- }, _.readAsDataURL(A);
9320
+ }, E.readAsDataURL(A);
9321
9321
  }
9322
9322
  }, f = () => {
9323
9323
  var b;
9324
9324
  (b = p.current) == null || b.click();
9325
- }, k = () => {
9325
+ }, y = () => {
9326
9326
  d(null), p.current && (p.current.value = "");
9327
9327
  };
9328
9328
  return /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col rounded-lg bg-background shadow-sm", children: [
@@ -9368,7 +9368,7 @@ function AIChatPanel() {
9368
9368
  size: "icon",
9369
9369
  variant: "destructive",
9370
9370
  className: "absolute right-0 top-0 h-5 w-5 rounded-full p-0",
9371
- onClick: k,
9371
+ onClick: y,
9372
9372
  children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" })
9373
9373
  }
9374
9374
  )
@@ -9511,7 +9511,7 @@ const AiAssistant = () => {
9511
9511
  preloadedAttributes: r = [],
9512
9512
  onAttributesChange: n
9513
9513
  }) {
9514
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), k = usePageExternalData();
9514
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), x = useRef(null), f = useRef(null), y = usePageExternalData();
9515
9515
  useEffect(() => {
9516
9516
  l(r);
9517
9517
  }, [r]);
@@ -9521,43 +9521,43 @@ const AiAssistant = () => {
9521
9521
  return;
9522
9522
  }
9523
9523
  if (i) {
9524
- const y = [...a, { key: i, value: d }];
9525
- n(y), l(a), c(""), p(""), m("");
9524
+ const S = [...a, { key: i, value: d }];
9525
+ n(S), l(a), c(""), p(""), m("");
9526
9526
  }
9527
- }, A = (y) => {
9528
- const v = a.filter((B, S) => S !== y);
9529
- n(v), l(v);
9530
- }, E = (y) => {
9531
- g(y), c(a[y].key), p(a[y].value);
9532
- }, _ = () => {
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 = () => {
9533
9533
  if (i.startsWith("@")) {
9534
9534
  m("Attribute keys cannot start with '@'");
9535
9535
  return;
9536
9536
  }
9537
9537
  if (u !== null && i) {
9538
- const y = [...a];
9539
- y[u] = { key: i, value: d }, n(y), l(y), g(null), c(""), p(""), m("");
9538
+ const S = [...a];
9539
+ S[u] = { key: i, value: d }, n(S), l(S), g(null), c(""), p(""), m("");
9540
9540
  }
9541
- }, N = (y) => {
9542
- y.key === "Enter" && !y.shiftKey && (y.preventDefault(), u !== null ? _() : b());
9543
- }, w = useCallback((y) => {
9544
- const v = (C) => /[.,!?;:]/.test(C), B = (C, j, I) => {
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) => {
9545
9545
  let T = "", P = "";
9546
- const L = j > 0 ? C[j - 1] : "", D = j < C.length ? C[j] : "";
9547
- return j > 0 && (L === "." || !v(L) && L !== " ") && (T = " "), j < C.length && !v(D) && D !== " " && (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 = " "), {
9548
9548
  text: T + I + P,
9549
9549
  prefixLength: T.length,
9550
9550
  suffixLength: P.length
9551
9551
  };
9552
- }, S = f.current;
9553
- if (S) {
9554
- const C = S.selectionStart || 0, j = S.value || "", I = S.selectionEnd || C;
9555
- if (I > C) {
9556
- const R = `{{${y}}}`, { text: M } = B(j, C, R), $ = j.slice(0, C) + M + j.slice(I);
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);
9557
9557
  p($);
9558
9558
  return;
9559
9559
  }
9560
- const P = `{{${y}}}`, { text: L } = B(j, C, P), D = j.slice(0, C) + L + j.slice(C);
9560
+ const P = `{{${S}}}`, { text: L } = j(B, v, P), D = B.slice(0, v) + L + B.slice(v);
9561
9561
  p(D);
9562
9562
  }
9563
9563
  }, []);
@@ -9565,8 +9565,8 @@ const AiAssistant = () => {
9565
9565
  /* @__PURE__ */ jsxs(
9566
9566
  "form",
9567
9567
  {
9568
- onSubmit: (y) => {
9569
- y.preventDefault(), u !== null ? _() : b();
9568
+ onSubmit: (S) => {
9569
+ S.preventDefault(), u !== null ? E() : b();
9570
9570
  },
9571
9571
  className: "space-y-3",
9572
9572
  children: [
@@ -9582,7 +9582,7 @@ const AiAssistant = () => {
9582
9582
  id: "attrKey",
9583
9583
  ref: x,
9584
9584
  value: i,
9585
- onChange: (y) => c(y.target.value),
9585
+ onChange: (S) => c(S.target.value),
9586
9586
  placeholder: "Enter Key",
9587
9587
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
9588
9588
  }
@@ -9591,7 +9591,7 @@ const AiAssistant = () => {
9591
9591
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
9592
9592
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
9593
9593
  /* @__PURE__ */ jsx(Label, { htmlFor: "attrValue", className: "text-[11px] font-normal text-slate-600", children: "Value" }),
9594
- !isEmpty(k) && /* @__PURE__ */ jsx(NestedPathSelector, { data: k, onSelect: w })
9594
+ !isEmpty(y) && /* @__PURE__ */ jsx(NestedPathSelector, { data: y, onSelect: w })
9595
9595
  ] }),
9596
9596
  /* @__PURE__ */ jsx(
9597
9597
  Textarea,
@@ -9603,7 +9603,7 @@ const AiAssistant = () => {
9603
9603
  rows: 2,
9604
9604
  ref: f,
9605
9605
  value: d,
9606
- onChange: (y) => p(y.target.value),
9606
+ onChange: (S) => p(S.target.value),
9607
9607
  onKeyDown: N,
9608
9608
  placeholder: "Enter Value",
9609
9609
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -9616,16 +9616,16 @@ const AiAssistant = () => {
9616
9616
  ]
9617
9617
  }
9618
9618
  ),
9619
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((y, v) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
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: [
9620
9620
  /* @__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: y.key }),
9622
- /* @__PURE__ */ jsx("span", { className: "max-w-[200px] text-wrap font-normal", children: y.value.toString() })
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() })
9623
9623
  ] }),
9624
9624
  /* @__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: () => E(v), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9626
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(v), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
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" }) })
9627
9627
  ] })
9628
- ] }, v)) })
9628
+ ] }, k)) })
9629
9629
  ] });
9630
9630
  }), BlockAttributesEditor = React.memo(() => {
9631
9631
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9787,70 +9787,70 @@ const RootLayout = () => {
9787
9787
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9788
9788
  n("outline");
9789
9789
  });
9790
- const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = useCallback((y) => {
9791
- y.preventDefault();
9792
- }, []), m = useCallback(
9793
- (y) => {
9794
- n(r === y ? null : y);
9790
+ const p = useSidebarDefaultPanels(), u = useChaiSidebarPanels("top"), g = useChaiSidebarPanels("bottom"), h = reverse([...g ?? []]), m = useCallback((k) => {
9791
+ k.preventDefault();
9792
+ }, []), x = useCallback(
9793
+ (k) => {
9794
+ n(r === k ? null : k);
9795
9795
  },
9796
9796
  [r]
9797
- ), { t: x } = useTranslation(), f = useMemo(
9797
+ ), { t: f } = useTranslation(), y = useMemo(
9798
9798
  () => [...p, ...u, ...g],
9799
9799
  [p, u, g]
9800
- ), k = useBuilderProp("htmlDir", "ltr"), b = find(f, { id: r }) ?? first(f), A = get(b, "width", DEFAULT_PANEL_WIDTH);
9800
+ ), b = useBuilderProp("htmlDir", "ltr"), A = find(y, { id: r }) ?? first(y), _ = get(A, "width", DEFAULT_PANEL_WIDTH);
9801
9801
  useEffect(() => {
9802
9802
  if (r !== null) {
9803
- const y = find(f, { id: r });
9804
- y && get(y, "view", "standard") === "standard" && (a.current = r, i(get(y, "width", DEFAULT_PANEL_WIDTH)));
9803
+ const k = find(y, { id: r });
9804
+ k && get(k, "view", "standard") === "standard" && (a.current = r, i(get(k, "width", DEFAULT_PANEL_WIDTH)));
9805
9805
  }
9806
- }, [r, f]);
9806
+ }, [r, y]);
9807
9807
  const E = useMemo(() => {
9808
9808
  if (r === null) return 0;
9809
- const y = find(f, { id: r });
9810
- return get(y, "view", "standard") === "standard" ? A : l;
9811
- }, [r, A, l, f]), _ = useCallback(() => {
9809
+ const k = find(y, { id: r });
9810
+ return get(k, "view", "standard") === "standard" ? _ : l;
9811
+ }, [r, _, l, y]), N = useCallback(() => {
9812
9812
  n(a.current);
9813
- }, [n]), N = useCallback(() => {
9813
+ }, [n]), w = useCallback(() => {
9814
9814
  n("outline");
9815
9815
  }, [n]);
9816
9816
  useEffect(() => {
9817
- find(f, { id: r }) || n("outline");
9818
- }, [r, f]);
9819
- const w = useCallback(
9820
- (y) => {
9821
- m(y);
9817
+ find(y, { id: r }) || n("outline");
9818
+ }, [r, y]);
9819
+ const S = useCallback(
9820
+ (k) => {
9821
+ x(k);
9822
9822
  },
9823
- [m]
9823
+ [x]
9824
9824
  );
9825
- return /* @__PURE__ */ jsx("div", { dir: k, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9825
+ return /* @__PURE__ */ jsx("div", { dir: b, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9826
9826
  /* @__PURE__ */ jsxs(
9827
9827
  "div",
9828
9828
  {
9829
- onContextMenu: h,
9829
+ onContextMenu: m,
9830
9830
  className: "flex h-screen max-h-full flex-col bg-background text-foreground",
9831
9831
  children: [
9832
9832
  /* @__PURE__ */ jsx("div", { className: "flex h-[50px] w-screen items-center border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
9833
9833
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9834
9834
  /* @__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((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9836
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
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), {
9837
9837
  position: "top",
9838
- panelId: y.id,
9839
- isActive: r === y.id,
9840
- show: () => w(y.id)
9838
+ panelId: k.id,
9839
+ isActive: r === k.id,
9840
+ show: () => S(k.id)
9841
9841
  }) }),
9842
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
9843
- ] }, "button-top-" + v)) }),
9842
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9843
+ ] }, "button-top-" + j)) }),
9844
9844
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9845
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: g == null ? void 0 : g.map((y, v) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9846
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: createElement(get(y, "button", NoopComponent), {
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), {
9847
9847
  position: "bottom",
9848
- panelId: y.id,
9849
- isActive: r === y.id,
9850
- show: () => w(y.id)
9848
+ panelId: k.id,
9849
+ isActive: r === k.id,
9850
+ show: () => S(k.id)
9851
9851
  }) }),
9852
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: x(y.label) }) })
9853
- ] }, "button-bottom-" + v)) })
9852
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(k.label) }) })
9853
+ ] }, "button-bottom-" + j)) })
9854
9854
  ] }),
9855
9855
  /* @__PURE__ */ jsx(
9856
9856
  motion.div,
@@ -9860,15 +9860,15 @@ const RootLayout = () => {
9860
9860
  initial: { width: E },
9861
9861
  animate: { width: E },
9862
9862
  transition: { duration: 0.3, ease: "easeInOut" },
9863
- children: r !== null && get(b, "view", "standard") === "standard" && /* @__PURE__ */ jsxs("div", { className: "no-scrollbar flex h-full flex-col overflow-hidden px-3 py-2", children: [
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: [
9864
9864
  /* @__PURE__ */ jsx(
9865
9865
  "div",
9866
9866
  {
9867
- className: `absolute top-2 flex h-10 items-center space-x-1 py-2 text-base font-bold ${get(b, "isInternal", !1) ? "" : "w-64"}`,
9868
- children: /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
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", "")) })
9869
9869
  }
9870
9870
  ),
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(b, "panel", NoopComponent), {}) }) })
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), {}) }) })
9872
9872
  ] })
9873
9873
  }
9874
9874
  ),
@@ -9888,11 +9888,11 @@ const RootLayout = () => {
9888
9888
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: c === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9889
9889
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9890
9890
  " ",
9891
- x("AI Assistant")
9891
+ f("AI Assistant")
9892
9892
  ] }) }) : c === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9893
9893
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9894
- /* @__PURE__ */ jsx(Palette, { className: "w-4 h-4 text-gray-600" }),
9895
- x("Theme Settings")
9894
+ /* @__PURE__ */ jsx(Palette, { className: "h-4 w-4 text-gray-600" }),
9895
+ f("Theme Settings")
9896
9896
  ] }),
9897
9897
  /* @__PURE__ */ jsx(
9898
9898
  Button,
@@ -9914,34 +9914,34 @@ const RootLayout = () => {
9914
9914
  }
9915
9915
  ),
9916
9916
  /* @__PURE__ */ jsx(AddBlocksDialog, {}),
9917
- r !== null && get(b, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(
9917
+ r !== null && get(A, "view") === "drawer" && /* @__PURE__ */ jsx(Sheet, { open: !0, onOpenChange: () => N(), children: /* @__PURE__ */ jsxs(
9918
9918
  SheetContent,
9919
9919
  {
9920
9920
  side: "left",
9921
9921
  className: "flex flex-col gap-0 p-0 sm:max-w-full",
9922
- style: { width: `${A}px` },
9922
+ style: { width: `${_}px` },
9923
9923
  children: [
9924
9924
  /* @__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(b, "icon", null) }),
9926
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9925
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(A, "icon", null) }),
9926
+ /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9927
9927
  ] }) }),
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(b, "panel", NoopComponent), {
9929
- close: N
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
9930
9930
  }) }) })
9931
9931
  ]
9932
9932
  }
9933
9933
  ) }),
9934
9934
  " ",
9935
- r !== null && get(b, "view") === "modal" && /* @__PURE__ */ jsx(Dialog, { open: !0, onOpenChange: () => _(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "gap-0 p-0", style: { maxWidth: `${A}px` }, children: [
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: [
9936
9936
  /* @__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(b, "icon", null) }),
9938
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
9937
+ /* @__PURE__ */ jsx("span", { className: "inline-block", children: get(A, "icon", null) }),
9938
+ /* @__PURE__ */ jsx("span", { children: f(get(A, "label", "")) })
9939
9939
  ] }) }),
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(b, "panel", NoopComponent), {
9941
- close: N
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
9942
9942
  }) }) })
9943
9943
  ] }) }),
9944
- r !== null && get(b, "view") === "overlay" && /* @__PURE__ */ jsx(
9944
+ r !== null && get(A, "view") === "overlay" && /* @__PURE__ */ jsx(
9945
9945
  motion.div,
9946
9946
  {
9947
9947
  className: "absolute bottom-0 left-12 right-0 top-0 z-50",
@@ -9960,13 +9960,13 @@ const RootLayout = () => {
9960
9960
  children: [
9961
9961
  /* @__PURE__ */ jsxs("div", { className: "flex h-[50px] items-center justify-between border-b border-border p-4", children: [
9962
9962
  /* @__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(b, "icon", null) }),
9964
- /* @__PURE__ */ jsx("span", { children: x(get(b, "label", "")) })
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", "")) })
9965
9965
  ] }),
9966
- /* @__PURE__ */ jsx(Button, { onClick: () => _(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9966
+ /* @__PURE__ */ jsx(Button, { onClick: () => N(), variant: "ghost", size: "icon", className: "", children: /* @__PURE__ */ jsx(X, { className: "h-5 w-5" }) })
9967
9967
  ] }),
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(b, "panel", NoopComponent), {
9969
- close: N
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
9970
9970
  }) }) })
9971
9971
  ]
9972
9972
  }
@@ -10007,9 +10007,9 @@ const RootLayout = () => {
10007
10007
  if (!l.trim()) return a;
10008
10008
  const f = l.toLowerCase();
10009
10009
  return Object.fromEntries(
10010
- Object.entries(a).filter(([k, b]) => {
10010
+ Object.entries(a).filter(([y, b]) => {
10011
10011
  var A;
10012
- return (k == null ? void 0 : k.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
10012
+ return (y == null ? void 0 : y.toLowerCase().includes(f)) || ((A = b == null ? void 0 : b.description) == null ? void 0 : A.toLowerCase().includes(f));
10013
10013
  })
10014
10014
  );
10015
10015
  }, [a, l]), h = (f) => {
@@ -10019,8 +10019,8 @@ const RootLayout = () => {
10019
10019
  });
10020
10020
  }, m = (f) => {
10021
10021
  if (!c) return;
10022
- const k = f.clientX - p.x, b = f.clientY - p.y, A = f.currentTarget, E = A.offsetWidth, _ = A.offsetHeight, N = window.innerWidth - E, w = window.innerHeight - _, y = Math.max(0, Math.min(k, N)), v = Math.max(0, Math.min(b, w));
10023
- n(y, v);
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);
10024
10024
  }, x = () => {
10025
10025
  d(!1);
10026
10026
  };
@@ -10082,7 +10082,7 @@ const RootLayout = () => {
10082
10082
  )
10083
10083
  ] })
10084
10084
  ] }),
10085
- /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, k]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: k }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
10085
+ /* @__PURE__ */ jsx("div", { className: "max-h-96 overflow-y-auto py-2", children: Object.keys(g).length > 0 ? /* @__PURE__ */ jsx("div", { className: "space-y-1", children: Object.entries(g).map(([f, y]) => /* @__PURE__ */ jsx(FeatureToggle, { featureKey: f, options: y }, f)) }) : /* @__PURE__ */ jsx("div", { className: "py-8 text-center", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
10086
10086
  'No features found matching "',
10087
10087
  l,
10088
10088
  '"'
@@ -10197,71 +10197,71 @@ const RootLayout = () => {
10197
10197
  var f;
10198
10198
  return (f = m.onMount) == null ? void 0 : f.call(m, x);
10199
10199
  }, ...h) => {
10200
- const m = h[0] || ((v) => {
10201
- let B = o.get(v);
10202
- return B || (B = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(v, B), u == null || u(v, y)), B;
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;
10203
10203
  }), x = h[1] || (() => {
10204
- const v = [], B = (S) => {
10204
+ const k = [], j = (C) => {
10205
10205
  try {
10206
- S();
10207
- } catch (C) {
10208
- v.push(C);
10206
+ C();
10207
+ } catch (v) {
10208
+ k.push(v);
10209
10209
  }
10210
10210
  };
10211
10211
  do {
10212
- c.f && B(c.f);
10213
- const S = /* @__PURE__ */ new Set(), C = S.add.bind(S);
10214
- a.forEach((j) => {
10212
+ c.f && j(c.f);
10213
+ const C = /* @__PURE__ */ new Set(), v = C.add.bind(C);
10214
+ a.forEach((B) => {
10215
10215
  var I;
10216
- return (I = r.get(j)) == null ? void 0 : I.l.forEach(C);
10217
- }), a.clear(), i.forEach(C), i.clear(), l.forEach(C), l.clear(), S.forEach(B), a.size && f();
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();
10218
10218
  } while (a.size || i.size || l.size);
10219
- if (v.length)
10220
- throw new AggregateError(v);
10219
+ if (k.length)
10220
+ throw new AggregateError(k);
10221
10221
  }), f = h[2] || (() => {
10222
- const v = [], B = /* @__PURE__ */ new WeakSet(), S = /* @__PURE__ */ new WeakSet(), C = Array.from(a);
10223
- for (; C.length; ) {
10224
- const j = C[C.length - 1], I = m(j);
10225
- if (S.has(j)) {
10226
- C.pop();
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();
10227
10227
  continue;
10228
10228
  }
10229
- if (B.has(j)) {
10230
- n.get(j) === I.n && v.push([j, I]), S.add(j), C.pop();
10229
+ if (j.has(B)) {
10230
+ n.get(B) === I.n && k.push([B, I]), C.add(B), v.pop();
10231
10231
  continue;
10232
10232
  }
10233
- B.add(j);
10234
- for (const T of getMountedOrPendingDependents(j, I, r))
10235
- B.has(T) || C.push(T);
10233
+ j.add(B);
10234
+ for (const T of getMountedOrPendingDependents(B, I, r))
10235
+ j.has(T) || v.push(T);
10236
10236
  }
10237
- for (let j = v.length - 1; j >= 0; --j) {
10238
- const [I, T] = v[j];
10237
+ for (let B = k.length - 1; B >= 0; --B) {
10238
+ const [I, T] = k[B];
10239
10239
  let P = !1;
10240
10240
  for (const L of T.d.keys())
10241
10241
  if (L !== I && a.has(L)) {
10242
10242
  P = !0;
10243
10243
  break;
10244
10244
  }
10245
- P && (k(I), E(I)), n.delete(I);
10245
+ P && (y(I), _(I)), n.delete(I);
10246
10246
  }
10247
- }), k = h[3] || ((v) => {
10248
- var B;
10249
- const S = m(v);
10250
- if (isAtomStateInitialized(S) && (r.has(v) && n.get(v) !== S.n || Array.from(S.d).every(
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(
10251
10251
  ([R, M]) => (
10252
10252
  // Recursively, read the atom state of the dependency, and
10253
10253
  // check if the atom epoch number is unchanged
10254
- k(R).n === M
10254
+ y(R).n === M
10255
10255
  )
10256
10256
  )))
10257
- return S;
10258
- S.d.clear();
10259
- let C = !0;
10260
- const j = () => {
10261
- r.has(v) && (E(v), f(), x());
10257
+ return C;
10258
+ C.d.clear();
10259
+ let v = !0;
10260
+ const B = () => {
10261
+ r.has(k) && (_(k), f(), x());
10262
10262
  }, I = (R) => {
10263
10263
  var M;
10264
- if (isSelfAtom(v, R)) {
10264
+ if (isSelfAtom(k, R)) {
10265
10265
  const O = m(R);
10266
10266
  if (!isAtomStateInitialized(O))
10267
10267
  if (hasInitialValue(R))
@@ -10270,11 +10270,11 @@ const RootLayout = () => {
10270
10270
  throw new Error("no atom init");
10271
10271
  return returnAtomValue(O);
10272
10272
  }
10273
- const $ = k(R);
10273
+ const $ = y(R);
10274
10274
  try {
10275
10275
  return returnAtomValue($);
10276
10276
  } finally {
10277
- S.d.set(R, $.n), isPendingPromise(S.v) && addPendingPromiseToDependency(v, S.v, $), (M = r.get(R)) == null || M.t.add(v), C || j();
10277
+ C.d.set(R, $.n), isPendingPromise(C.v) && addPendingPromiseToDependency(k, C.v, $), (M = r.get(R)) == null || M.t.add(k), v || B();
10278
10278
  }
10279
10279
  };
10280
10280
  let T, P;
@@ -10283,100 +10283,100 @@ const RootLayout = () => {
10283
10283
  return T || (T = new AbortController()), T.signal;
10284
10284
  },
10285
10285
  get setSelf() {
10286
- return !P && isActuallyWritableAtom(v) && (P = (...R) => {
10287
- if (!C)
10286
+ return !P && isActuallyWritableAtom(k) && (P = (...R) => {
10287
+ if (!v)
10288
10288
  try {
10289
- return A(v, ...R);
10289
+ return A(k, ...R);
10290
10290
  } finally {
10291
10291
  f(), x();
10292
10292
  }
10293
10293
  }), P;
10294
10294
  }
10295
- }, D = S.n;
10295
+ }, D = C.n;
10296
10296
  try {
10297
- const R = d(v, I, L);
10298
- return setAtomStateValueOrPromise(v, R, m), isPromiseLike$1(R) && (registerAbortHandler(R, () => T == null ? void 0 : T.abort()), R.then(
10299
- j,
10300
- j
10301
- )), S;
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;
10302
10302
  } catch (R) {
10303
- return delete S.v, S.e = R, ++S.n, S;
10303
+ return delete C.v, C.e = R, ++C.n, C;
10304
10304
  } finally {
10305
- C = !1, D !== S.n && n.get(v) === D && (n.set(v, S.n), a.add(v), (B = c.c) == null || B.call(c, v));
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));
10306
10306
  }
10307
- }), b = h[4] || ((v) => {
10308
- const B = [v];
10309
- for (; B.length; ) {
10310
- const S = B.pop(), C = m(S);
10311
- for (const j of getMountedOrPendingDependents(S, C, r)) {
10312
- const I = m(j);
10313
- n.set(j, I.n), B.push(j);
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);
10314
10314
  }
10315
10315
  }
10316
- }), A = h[5] || ((v, ...B) => {
10317
- let S = !0;
10318
- const C = (I) => returnAtomValue(k(I)), j = (I, ...T) => {
10316
+ }), A = h[5] || ((k, ...j) => {
10317
+ let C = !0;
10318
+ const v = (I) => returnAtomValue(y(I)), B = (I, ...T) => {
10319
10319
  var P;
10320
10320
  const L = m(I);
10321
10321
  try {
10322
- if (isSelfAtom(v, I)) {
10322
+ if (isSelfAtom(k, I)) {
10323
10323
  if (!hasInitialValue(I))
10324
10324
  throw new Error("atom not writable");
10325
10325
  const D = L.n, R = T[0];
10326
- setAtomStateValueOrPromise(I, R, m), E(I), D !== L.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
10326
+ setAtomStateValueOrPromise(I, R, m), _(I), D !== L.n && (a.add(I), (P = c.c) == null || P.call(c, I), b(I));
10327
10327
  return;
10328
10328
  } else
10329
10329
  return A(I, ...T);
10330
10330
  } finally {
10331
- S || (f(), x());
10331
+ C || (f(), x());
10332
10332
  }
10333
10333
  };
10334
10334
  try {
10335
- return p(v, C, j, ...B);
10335
+ return p(k, v, B, ...j);
10336
10336
  } finally {
10337
- S = !1;
10337
+ C = !1;
10338
10338
  }
10339
- }), E = h[6] || ((v) => {
10340
- var B;
10341
- const S = m(v), C = r.get(v);
10342
- if (C && !isPendingPromise(S.v)) {
10343
- for (const [j, I] of S.d)
10344
- if (!C.d.has(j)) {
10345
- const T = m(j);
10346
- _(j).t.add(v), C.d.add(j), I !== T.n && (a.add(j), (B = c.c) == null || B.call(c, j), b(j));
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));
10347
10347
  }
10348
- for (const j of C.d || [])
10349
- if (!S.d.has(j)) {
10350
- C.d.delete(j);
10351
- const I = N(j);
10352
- I == null || I.t.delete(v);
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);
10353
10353
  }
10354
10354
  }
10355
- }), _ = h[7] || ((v) => {
10356
- var B;
10357
- const S = m(v);
10358
- let C = r.get(v);
10359
- if (!C) {
10360
- k(v);
10361
- for (const j of S.d.keys())
10362
- _(j).t.add(v);
10363
- if (C = {
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 = {
10364
10364
  l: /* @__PURE__ */ new Set(),
10365
- d: new Set(S.d.keys()),
10365
+ d: new Set(C.d.keys()),
10366
10366
  t: /* @__PURE__ */ new Set()
10367
- }, r.set(v, C), (B = c.m) == null || B.call(c, v), isActuallyWritableAtom(v)) {
10368
- const j = () => {
10367
+ }, r.set(k, v), (j = c.m) == null || j.call(c, k), isActuallyWritableAtom(k)) {
10368
+ const B = () => {
10369
10369
  let I = !0;
10370
10370
  const T = (...P) => {
10371
10371
  try {
10372
- return A(v, ...P);
10372
+ return A(k, ...P);
10373
10373
  } finally {
10374
10374
  I || (f(), x());
10375
10375
  }
10376
10376
  };
10377
10377
  try {
10378
- const P = g(v, T);
10379
- P && (C.u = () => {
10378
+ const P = g(k, T);
10379
+ P && (v.u = () => {
10380
10380
  I = !0;
10381
10381
  try {
10382
10382
  P();
@@ -10388,26 +10388,26 @@ const RootLayout = () => {
10388
10388
  I = !1;
10389
10389
  }
10390
10390
  };
10391
- l.add(j);
10391
+ l.add(B);
10392
10392
  }
10393
10393
  }
10394
- return C;
10395
- }), N = h[8] || ((v) => {
10396
- var B;
10397
- const S = m(v);
10398
- let C = r.get(v);
10399
- if (C && !C.l.size && !Array.from(C.t).some((j) => {
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) => {
10400
10400
  var I;
10401
- return (I = r.get(j)) == null ? void 0 : I.d.has(v);
10401
+ return (I = r.get(B)) == null ? void 0 : I.d.has(k);
10402
10402
  })) {
10403
- C.u && i.add(C.u), C = void 0, r.delete(v), (B = c.u) == null || B.call(c, v);
10404
- for (const j of S.d.keys()) {
10405
- const I = N(j);
10406
- I == null || I.t.delete(v);
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);
10407
10407
  }
10408
10408
  return;
10409
10409
  }
10410
- return C;
10410
+ return v;
10411
10411
  }), w = [
10412
10412
  // store state
10413
10413
  o,
@@ -10426,29 +10426,29 @@ const RootLayout = () => {
10426
10426
  m,
10427
10427
  x,
10428
10428
  f,
10429
- k,
10429
+ y,
10430
10430
  b,
10431
10431
  A,
10432
- E,
10433
10432
  _,
10433
+ E,
10434
10434
  N
10435
- ], y = {
10436
- get: (v) => returnAtomValue(k(v)),
10437
- set: (v, ...B) => {
10435
+ ], S = {
10436
+ get: (k) => returnAtomValue(y(k)),
10437
+ set: (k, ...j) => {
10438
10438
  try {
10439
- return A(v, ...B);
10439
+ return A(k, ...j);
10440
10440
  } finally {
10441
10441
  f(), x();
10442
10442
  }
10443
10443
  },
10444
- sub: (v, B) => {
10445
- const C = _(v).l;
10446
- return C.add(B), x(), () => {
10447
- C.delete(B), N(v), x();
10444
+ sub: (k, j) => {
10445
+ const v = E(k).l;
10446
+ return v.add(j), x(), () => {
10447
+ v.delete(j), N(k), x();
10448
10448
  };
10449
10449
  }
10450
10450
  };
10451
- return Object.defineProperty(y, BUILDING_BLOCKS, { value: w }), y;
10451
+ return Object.defineProperty(S, BUILDING_BLOCKS, { value: w }), S;
10452
10452
  }, INTERNAL_buildStoreRev1 = buildStore, INTERNAL_registerAbortHandler = registerAbortHandler;
10453
10453
  function createStore() {
10454
10454
  return INTERNAL_buildStoreRev1();