@chaibuilder/sdk 2.2.24 → 2.2.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,17 +1,17 @@
1
1
  var V = Object.defineProperty;
2
2
  var F = (o, r, n) => r in o ? V(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
- var U = (o, r, n) => F(o, typeof r != "symbol" ? r + "" : r, n);
3
+ var H = (o, r, n) => F(o, typeof r != "symbol" ? r + "" : r, n);
4
4
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
5
5
  import { useRegisteredChaiBlocks, getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredFonts, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
6
6
  import { BoxModelIcon, PinTopIcon, PinBottomIcon, PinLeftIcon, PinRightIcon, ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, FontBoldIcon, FontItalicIcon, UnderlineIcon, StrikethroughIcon, CodeIcon, Link1Icon, ListBulletIcon, HeadingIcon, QuoteIcon, TextAlignLeftIcon, TextAlignCenterIcon, TextAlignRightIcon, LoopIcon, InfoCircledIcon, TriangleDownIcon, RowSpacingIcon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross2Icon, Cross1Icon, BoxIcon, MinusIcon, CrossCircledIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, CaretRightIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, CheckIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
7
- import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isUndefined, isFunction, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
7
+ import { get, find, filter, flatten, has, map, includes, without, compact, reverse, findIndex, isEmpty, isString, each, omit, values, pick, startsWith, isFunction, isArray, isObject as isObject$1, memoize, noop, first, keys, range, flattenDeep, set, forEach, unset, chunk, cloneDeep, isNull, split, reject, take, debounce, startCase, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, toLower, nth, findLast, intersection, toUpper, capitalize, groupBy, uniq, flatMapDeep, some, sortBy, round } from "lodash-es";
8
8
  import * as React from "react";
9
9
  import React__default, { useMemo, useCallback, useEffect, useState, useRef, Component, Children, memo, createElement, createContext, useContext, Suspense, useReducer, useDebugValue } from "react";
10
10
  import { atom, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
11
11
  import { atomWithStorage, splitAtom, useAtomCallback } from "jotai/utils";
12
12
  import { g as generateUUID, a as getBreakpointValue, c as cn$2 } from "./common-functions-BGzDsf1z.js";
13
13
  import { B as Button, Z as DropdownMenu, ab as DropdownMenuTrigger, $ as DropdownMenuContent, a1 as DropdownMenuItem, c as cn$1, ay as Skeleton, e as Alert, f as AlertDescription, af as Input$1, P as Dialog, Y as DialogTrigger, R as DialogContent, ah as Popover, aG as Tooltip, aJ as TooltipTrigger, ak as PopoverTrigger, aH as TooltipContent, aj as PopoverContent, G as Command, I as CommandInput, J as CommandList, K as CommandEmpty, L as CommandGroup, M as CommandItem, U as DialogHeader, X as DialogTitle, v as Badge, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, a2 as DropdownMenuLabel, a6 as DropdownMenuSeparator, _ as DropdownMenuCheckboxItem, ac as HoverCard, ae as HoverCardTrigger, ad as HoverCardContent, aF as Textarea, A as Accordion, C as Card, E as CardHeader, z as CardDescription, y as CardContent, ag as Label, D as CardFooter, al as ScrollArea, aB as Tabs, aD as TabsList, aE as TabsTrigger, aC as TabsContent, h as AlertDialog, r as AlertDialogTrigger, k as AlertDialogContent, n as AlertDialogHeader, q as AlertDialogTitle, l as AlertDialogDescription, m as AlertDialogFooter, j as AlertDialogCancel, i as AlertDialogAction, aA as Switch, s as Avatar, an as Separator, aI as TooltipProvider, ao as Sheet, aq as SheetContent, at as SheetHeader, aw as SheetTitle, az as Toaster } from "./sooner-H65duPYc.js";
14
- import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
14
+ import { ChevronRight, PlusIcon as PlusIcon$1, AlertCircle, X, ChevronLeft, DatabaseIcon, Plus, Bold, Italic, Underline as Underline$1, Strikethrough, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, PlusCircle, ChevronDown, File, Database, Loader, SparklesIcon, Search, RefreshCw, Globe, SaveIcon, UnlinkIcon, PencilIcon, EyeOffIcon, MoreVertical, Eye, ChevronsDown, ChevronsUp, Languages, FileEdit, Recycle, SmileIcon, ShuffleIcon, SunIcon, Moon, Sparkles, Loader2, Image as Image$1, Send, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
15
15
  import clsx$1, { clsx } from "clsx";
16
16
  import { twMerge } from "tailwind-merge";
17
17
  import TreeModel from "tree-model";
@@ -285,7 +285,7 @@ import.meta.vitest && describe("canDropBlock Function", () => {
285
285
  });
286
286
  class PubSub {
287
287
  constructor() {
288
- U(this, "subscribers", /* @__PURE__ */ new Map());
288
+ H(this, "subscribers", /* @__PURE__ */ new Map());
289
289
  }
290
290
  subscribe(r, n) {
291
291
  return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
@@ -299,20 +299,20 @@ class PubSub {
299
299
  }
300
300
  }
301
301
  const pubsub = new PubSub(), AddBlockDropdown = ({ block: o, children: r }) => {
302
- const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (g) => c ? get(g, "_parent") === c : !get(g, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), m = (g) => {
303
- if (g === "CHILD")
302
+ const { t: n } = useTranslation(), [a] = useBlocksStore(), { hasPermission: l } = usePermissions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(a, (h) => c ? get(h, "_parent") === c : !get(h, "_parent")), p = canAddChildBlock(get(o, "_type", "")), u = findIndex(d, { _id: i }), g = (h) => {
303
+ if (h === "CHILD")
304
304
  pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, o);
305
305
  else {
306
- const h = { _id: c || "", position: d == null ? void 0 : d.length };
307
- g === "BEFORE" ? h.position = Math.max(u, 0) : g === "AFTER" && (h.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, h);
306
+ const m = { _id: c || "", position: d == null ? void 0 : d.length };
307
+ h === "BEFORE" ? m.position = Math.max(u, 0) : h === "AFTER" && (m.position = u + 1), pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, m);
308
308
  }
309
309
  };
310
310
  return l(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(DropdownMenu, { children: [
311
311
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { children: r }),
312
312
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "border border-blue-500 bg-primary text-white shadow-2xl", children: [
313
- p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("CHILD"), children: n("Add inside") }),
314
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("BEFORE"), children: n("Add before") }),
315
- /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => m("AFTER"), children: n("Add after") })
313
+ p && /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("CHILD"), children: n("Add inside") }),
314
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("BEFORE"), children: n("Add before") }),
315
+ /* @__PURE__ */ jsx(DropdownMenuItem, { className: "cursor-pointer text-xs", onClick: () => g("AFTER"), children: n("Add after") })
316
316
  ] })
317
317
  ] }) : null;
318
318
  }, draggedBlockAtom = atom(null);
@@ -338,17 +338,17 @@ function insertBlocksAtPosition(o, r, n, a) {
338
338
  const l = [...r];
339
339
  let i = [...o];
340
340
  if (n) {
341
- const u = o.find((m) => m._id === n);
342
- if (u && u.content !== void 0 && u.content !== "" && !o.some((g) => g._parent === n)) {
343
- const h = {
341
+ const u = o.find((g) => g._id === n);
342
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((h) => h._parent === n)) {
343
+ const m = {
344
344
  _id: generateUUID(),
345
345
  _parent: n,
346
346
  _type: "Text",
347
347
  content: u.content
348
348
  };
349
349
  Object.keys(u).forEach((f) => {
350
- f.startsWith("content-") && (h[f] = u[f]);
351
- }), l.unshift(h), i = i.map((f) => {
350
+ f.startsWith("content-") && (m[f] = u[f]);
351
+ }), l.unshift(m), i = i.map((f) => {
352
352
  if (f._id === n) {
353
353
  const x = { ...f, content: "" };
354
354
  return Object.keys(x).forEach((y) => {
@@ -363,13 +363,13 @@ function insertBlocksAtPosition(o, r, n, a) {
363
363
  n && (c = i.filter((u) => u._parent === n));
364
364
  const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
365
365
  let p = i.length;
366
- for (let u = 0, m = 0; u < i.length; u++)
366
+ for (let u = 0, g = 0; u < i.length; u++)
367
367
  if (n !== void 0 ? i[u]._parent === n : !i[u]._parent) {
368
- if (m === d) {
368
+ if (g === d) {
369
369
  p = u;
370
370
  break;
371
371
  }
372
- m++;
372
+ g++;
373
373
  }
374
374
  return !n && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
375
375
  }
@@ -384,17 +384,17 @@ function findNodeById(o, r) {
384
384
  return o.first((n) => n.model._id === r) || null;
385
385
  }
386
386
  function moveNode(o, r, n, a) {
387
- var u, m;
387
+ var u, g;
388
388
  const l = findNodeById(o, r), i = findNodeById(o, n);
389
389
  if (!l || !i) return !1;
390
390
  i.children || (i.model.children = []);
391
- let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((g) => g.model._id === r);
391
+ let c = (u = i == null ? void 0 : i.children) == null ? void 0 : u.findIndex((h) => h.model._id === r);
392
392
  l.drop(), c = Math.max(c, 0);
393
- const p = (((m = l == null ? void 0 : l.model) == null ? void 0 : m._parent) || "root") === n && c <= a ? a - 1 : a;
393
+ const p = (((g = l == null ? void 0 : l.model) == null ? void 0 : g._parent) || "root") === n && c <= a ? a - 1 : a;
394
394
  try {
395
395
  i.addChildAtIndex(l, p);
396
- } catch (g) {
397
- return console.error("Error adding child to parent:", g), !1;
396
+ } catch (h) {
397
+ return console.error("Error adding child to parent:", h), !1;
398
398
  }
399
399
  return !0;
400
400
  }
@@ -434,10 +434,10 @@ function handleNewParentTextBlock(o, r, n) {
434
434
  });
435
435
  const d = o.map((u) => {
436
436
  if (u._id === n) {
437
- const m = { ...u, content: "" };
438
- return Object.keys(m).forEach((g) => {
439
- g.startsWith("content-") && (m[g] = "");
440
- }), m;
437
+ const g = { ...u, content: "" };
438
+ return Object.keys(g).forEach((h) => {
439
+ h.startsWith("content-") && (g[h] = "");
440
+ }), g;
441
441
  }
442
442
  return u;
443
443
  }), p = d.findIndex((u) => u._id === r._id);
@@ -453,8 +453,8 @@ function moveBlocksWithChildren(o, r, n, a) {
453
453
  const c = n || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
454
454
  if (moveNode(p, r, c, a)) {
455
455
  let u = flattenTree(p);
456
- const m = u.find((g) => g._id === r);
457
- return m && (m._parent = c === "root" ? null : c), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
456
+ const g = u.find((h) => h._id === r);
457
+ return g && (g._parent = c === "root" ? null : c), u.shift(), n && (u = handleNewParentTextBlock(u, l, n)), u;
458
458
  }
459
459
  return i;
460
460
  }
@@ -477,22 +477,22 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
477
477
  }, removeNestedBlocks = (o, r) => {
478
478
  let n = [...o], a = [];
479
479
  r.forEach((d) => {
480
- const p = n.find((g) => g._id === d);
480
+ const p = n.find((h) => h._id === d);
481
481
  if (!p || !p._parent) return;
482
- const u = p._parent, m = n.filter((g) => g._parent === u);
483
- if (m.length === 2) {
484
- const g = m.find((h) => h._id !== d);
485
- if (g && g._type === "Text") {
486
- const h = n.find((f) => f._id === u);
487
- h && "content" in h && (n = n.map((f) => {
482
+ const u = p._parent, g = n.filter((h) => h._parent === u);
483
+ if (g.length === 2) {
484
+ const h = g.find((m) => m._id !== d);
485
+ if (h && h._type === "Text") {
486
+ const m = n.find((f) => f._id === u);
487
+ m && "content" in m && (n = n.map((f) => {
488
488
  if (f._id === u) {
489
- const x = { ...f, content: g.content };
490
- return Object.keys(g).forEach((y) => {
491
- y.startsWith("content-") && (x[y] = g[y]);
489
+ const x = { ...f, content: h.content };
490
+ return Object.keys(h).forEach((y) => {
491
+ y.startsWith("content-") && (x[y] = h[y]);
492
492
  }), x;
493
493
  }
494
494
  return f;
495
- }), a.push(g._id));
495
+ }), a.push(h._id));
496
496
  }
497
497
  }
498
498
  });
@@ -555,7 +555,7 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
555
555
  for (let p = 0; p < a.length; p++)
556
556
  d = moveBlocksWithChildren(d, a[p], l, i);
557
557
  return each(a, (p) => {
558
- const u = find(d, (m) => m._id === p);
558
+ const u = find(d, (g) => g._id === p);
559
559
  u && n({ id: p, props: { _parent: u._parent || null } });
560
560
  }), r({ type: "blocks-updated", blocks: d }), d;
561
561
  });
@@ -569,37 +569,37 @@ const broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChanne
569
569
  };
570
570
  }, blockRepeaterDataAtom = atom({});
571
571
  blockRepeaterDataAtom.debugLabel = "blockRepeaterDataAtom";
572
- const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyncProps = (o, r, n) => {
573
- const [a, l] = useState({
572
+ const useBlockRepeaterDataAtom = () => useAtom$1(blockRepeaterDataAtom), useAsyncProps = (o, r, n, a) => {
573
+ const [l, i] = useState({
574
574
  status: "idle",
575
575
  props: {},
576
576
  error: void 0
577
- }), i = useBuilderProp("getBlockAsyncProps", async (g) => ({})), c = useSetAtom$1(blockRepeaterDataAtom), d = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, r ?? []))]), p = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), u = (o == null ? void 0 : o._type) !== "Repeater" && !isUndefined(r);
577
+ }), c = useBuilderProp("getBlockAsyncProps", async (m) => ({})), d = useSetAtom$1(blockRepeaterDataAtom), p = JSON.stringify([o == null ? void 0 : o._id, ...values(pick(o, n ?? []))]), u = (o == null ? void 0 : o._type) === "Repeater" && startsWith(o.repeaterItems, `{{${COLLECTION_PREFIX}`), g = (o == null ? void 0 : o._type) !== "Repeater" && r === "live";
578
578
  return useEffect(() => {
579
- if (o) {
580
- if (isFunction(n)) {
581
- l((h) => ({ ...h, status: "loading", props: {} }));
582
- const g = n({ block: o });
583
- if (!isObject(g))
579
+ if (r === "mock") {
580
+ if (isFunction(a)) {
581
+ i((f) => ({ ...f, status: "loading", props: {} }));
582
+ const m = a({ block: o });
583
+ if (!isObject(m))
584
584
  throw new Error("mockDataProvider should return an object");
585
- l((h) => ({ ...h, status: "loaded", props: g }));
586
- return;
585
+ i((f) => ({ ...f, status: "loaded", props: m }));
587
586
  }
588
- !p && !u || (l((g) => ({ ...g, status: "loading", props: {} })), i({ block: o }).then((g = {}) => {
589
- p ? (c((h) => ({
590
- ...h,
591
- [o._id]: { status: "loaded", props: isArray(g) ? g : [], repeaterItems: o.repeaterItems }
592
- })), l((h) => ({ ...h, status: "loaded" }))) : l((h) => ({ ...h, status: "loaded", props: isObject(g) ? g : {} }));
593
- }).catch((g) => {
594
- p ? (c((h) => ({
595
- ...h,
596
- [o._id]: { status: "error", error: g, props: [] }
597
- })), l((h) => ({ ...h, status: "error", error: g }))) : l((h) => ({ ...h, status: "error", error: g, props: {} }));
598
- }));
587
+ return;
599
588
  }
600
- }, [o == null ? void 0 : o._id, d, p, u, n]), {
601
- $loading: get(a, "status") === "loading",
602
- ...o ? get(a, "props", {}) : {}
589
+ r === "live" && (!u && !g || (i((m) => ({ ...m, status: "loading", props: {} })), c({ block: o }).then((m = {}) => {
590
+ u ? (d((f) => ({
591
+ ...f,
592
+ [o._id]: { status: "loaded", props: isArray(m) ? m : [], repeaterItems: o.repeaterItems }
593
+ })), i((f) => ({ ...f, status: "loaded" }))) : i((f) => ({ ...f, status: "loaded", props: isObject(m) ? m : {} }));
594
+ }).catch((m) => {
595
+ u ? (d((f) => ({
596
+ ...f,
597
+ [o._id]: { status: "error", error: m, props: [] }
598
+ })), i((f) => ({ ...f, status: "error", error: m }))) : i((f) => ({ ...f, status: "error", error: m, props: {} }));
599
+ })));
600
+ }, [o == null ? void 0 : o._id, p, u, g, a, r]), {
601
+ $loading: get(l, "status") === "loading",
602
+ ...o ? get(l, "props", {}) : {}
603
603
  };
604
604
  }, chaiBuilderPropsAtom = atom(null);
605
605
  chaiBuilderPropsAtom.debugLabel = "chaiBuilderPropsAtom";
@@ -862,7 +862,7 @@ const undoRedoStateAtom = atom({
862
862
  }, useAddBlock = () => {
863
863
  const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
864
864
  (i, c, d) => {
865
- var h;
865
+ var m;
866
866
  for (let f = 0; f < i.length; f++) {
867
867
  const { _id: x } = i[f];
868
868
  i[f]._id = generateUUID();
@@ -871,8 +871,8 @@ const undoRedoStateAtom = atom({
871
871
  y[b]._parent = i[f]._id;
872
872
  }
873
873
  const p = first(i);
874
- let u, m;
875
- return c && (u = find(o, { _id: c }), i[0]._parent = c, m = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, m = u._parent), n(i, m, d), r([(h = first(i)) == null ? void 0 : h._id]), first(i);
874
+ let u, g;
875
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), n(i, g, d), r([(m = first(i)) == null ? void 0 : m._id]), first(i);
876
876
  },
877
877
  [n, o, r]
878
878
  );
@@ -882,15 +882,15 @@ const undoRedoStateAtom = atom({
882
882
  const y = i.blocks;
883
883
  return a(y, c, d);
884
884
  }
885
- const p = generateUUID(), u = getDefaultBlockProps(i.type), m = {
885
+ const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
886
886
  _type: i.type,
887
887
  _id: p,
888
888
  ...u,
889
889
  ...has(i, "_name") && { _name: i._name },
890
890
  ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
891
891
  };
892
- let g, h;
893
- return c && (g = find(o, { _id: c }), m._parent = c, h = c), !canAcceptChildBlock(g == null ? void 0 : g._type, m._type) && g && (m._parent = g._parent, h = g._parent), n([m], h, d), r([m._id]), m;
892
+ let h, m;
893
+ return c && (h = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, g._type) && h && (g._parent = h._parent, m = h._parent), n([g], m, d), r([g._id]), g;
894
894
  },
895
895
  [n, a, o, r]
896
896
  ), addPredefinedBlock: a };
@@ -2007,7 +2007,7 @@ function removeDuplicateClasses(o) {
2007
2007
  for (const l of n) {
2008
2008
  const i = l.property, c = r.indexOf(l.mq);
2009
2009
  for (let d = c + 1; d < r.length; d++) {
2010
- const p = r[d], u = n.find((m) => m.property === i && m.mq === p);
2010
+ const p = r[d], u = n.find((g) => g.property === i && g.mq === p);
2011
2011
  if (u && u.cls === l.cls)
2012
2012
  a = a.replace(u.fullCls, "");
2013
2013
  else if (u && u.cls !== l.cls)
@@ -2292,7 +2292,7 @@ const useLanguages = () => {
2292
2292
  let p = "";
2293
2293
  o([r], { [i]: "" });
2294
2294
  for (let u = 0; u < d.length; u++)
2295
- p += d[u].join(""), o([r], { [i]: p }), await new Promise((m) => setTimeout(m, a));
2295
+ p += d[u].join(""), o([r], { [i]: p }), await new Promise((g) => setTimeout(g, a));
2296
2296
  }
2297
2297
  }
2298
2298
  },
@@ -2336,8 +2336,8 @@ const getBlockWithChildren = (o, r) => {
2336
2336
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2337
2337
  })
2338
2338
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom(!1), useAskAi = () => {
2339
- 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(), m = p.length ? p : u, g = (h, f) => {
2340
- const x = cloneDeep(f.find((y) => y._id === h));
2339
+ 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, f) => {
2340
+ const x = cloneDeep(f.find((y) => y._id === m));
2341
2341
  for (const y in x) {
2342
2342
  const b = x[y];
2343
2343
  if (typeof b == "string" && startsWith(b, STYLES_KEY)) {
@@ -2350,16 +2350,16 @@ const getBlockWithChildren = (o, r) => {
2350
2350
  };
2351
2351
  return {
2352
2352
  askAi: useCallback(
2353
- async (h, f, x, y) => {
2353
+ async (m, f, x, y) => {
2354
2354
  if (l) {
2355
2355
  r(!0), a(null);
2356
2356
  try {
2357
- const b = p === u ? "" : p, v = h === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [g(f, d)], B = await l(h, addLangToPrompt(x, m, h), v, b), { blocks: w, error: E } = B;
2357
+ const b = p === u ? "" : p, v = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(f, d)), p) : [h(f, d)], B = await l(m, addLangToPrompt(x, g, m), v, b), { blocks: w, error: E } = B;
2358
2358
  if (E) {
2359
2359
  a(E);
2360
2360
  return;
2361
2361
  }
2362
- if (h === "styles") {
2362
+ if (m === "styles") {
2363
2363
  const _ = w.map((S) => {
2364
2364
  for (const A in S)
2365
2365
  A !== "_id" && (S[A] = `${STYLES_KEY},${S[A]}`);
@@ -2382,7 +2382,7 @@ const getBlockWithChildren = (o, r) => {
2382
2382
  p,
2383
2383
  u,
2384
2384
  d,
2385
- m,
2385
+ g,
2386
2386
  c,
2387
2387
  i
2388
2388
  ]
@@ -2453,25 +2453,25 @@ const getBlockWithChildren = (o, r) => {
2453
2453
  return [o, a];
2454
2454
  }, copiedBlockIdsAtom = atom([]), useCopyBlocks = () => {
2455
2455
  const [o] = useBlocksStore(), [r, n] = useAtom$1(copiedBlockIdsAtom), a = useSetAtom$1(cutBlockIdsAtom), { getPartailBlocks: l } = usePartialBlocksStore(), i = useCallback(
2456
- (d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((m) => m._type === "PartialBlock" || m._type === "GlobalBlock")),
2456
+ (d) => d.some((p) => getDuplicatedBlocks(o, p, null).some((g) => g._type === "PartialBlock" || g._type === "GlobalBlock")),
2457
2457
  [o]
2458
2458
  ), c = useCallback(
2459
2459
  async (d, p = !1) => {
2460
2460
  try {
2461
2461
  n(d), a([]);
2462
2462
  const u = {
2463
- _chai_copied_blocks: d.flatMap((m) => {
2464
- const g = getDuplicatedBlocks(o, m, null);
2463
+ _chai_copied_blocks: d.flatMap((g) => {
2464
+ const h = getDuplicatedBlocks(o, g, null);
2465
2465
  if (!p)
2466
- return g;
2467
- let h = [];
2468
- for (const f of g)
2466
+ return h;
2467
+ let m = [];
2468
+ for (const f of h)
2469
2469
  if (f._type === "PartialBlock" || f._type === "GlobalBlock") {
2470
2470
  let x = l(f.partialBlockId);
2471
- f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), h = [...h, ...x];
2471
+ f._parent && (x == null ? void 0 : x.length) > 0 && (x = x.map((y) => (isEmpty(y._parent) && set(y, "_parent", f._parent), y))), m = [...m, ...x];
2472
2472
  } else
2473
- h.push(f);
2474
- return h;
2473
+ m.push(f);
2474
+ return m;
2475
2475
  })
2476
2476
  };
2477
2477
  if (!navigator.clipboard) {
@@ -2509,13 +2509,13 @@ const getBlockWithChildren = (o, r) => {
2509
2509
  (a, l = null) => {
2510
2510
  const i = [];
2511
2511
  each(a, (c) => {
2512
- const d = o.find((h) => h._id === c);
2512
+ const d = o.find((m) => m._id === c);
2513
2513
  l ? l === "root" && (l = null) : l = d._parent;
2514
- const m = filter(
2514
+ const g = filter(
2515
2515
  o,
2516
- (h) => isString(l) ? h._parent === l : !h._parent
2517
- ).indexOf(d) + 1, g = getDuplicatedBlocks(o, c, l);
2518
- n(g, l, m), i.push(get(g, "0._id", ""));
2516
+ (m) => isString(l) ? m._parent === l : !m._parent
2517
+ ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
2518
+ n(h, l, g), i.push(get(h, "0._id", ""));
2519
2519
  }), r(i);
2520
2520
  },
2521
2521
  [o, r]
@@ -2651,19 +2651,19 @@ const getBlockWithChildren = (o, r) => {
2651
2651
  );
2652
2652
  return map(i, (c) => {
2653
2653
  const d = o(c), p = a;
2654
- let { classes: u, baseClasses: m } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2655
- return each(p, (g) => {
2656
- const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2654
+ let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
2655
+ return each(p, (h) => {
2656
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2657
2657
  u = u.replace(f, " ").replace(/\s+/g, " ").trim();
2658
- const x = first(g.split(":"));
2659
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(g.split(":").pop().trim());
2660
- }), each(p, (g) => {
2661
- const h = g.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${h}(?=\\s|$)`, "g");
2662
- m = m.replace(f, " ").replace(/\s+/g, " ").trim();
2658
+ const x = first(h.split(":"));
2659
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(h.split(":").pop().trim());
2660
+ }), each(p, (h) => {
2661
+ const m = h.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), f = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
2662
+ g = g.replace(f, " ").replace(/\s+/g, " ").trim();
2663
2663
  }), {
2664
2664
  ids: [d._id],
2665
2665
  props: {
2666
- [l.prop]: `${STYLES_KEY}${m},${u}`
2666
+ [l.prop]: `${STYLES_KEY}${g},${u}`
2667
2667
  }
2668
2668
  };
2669
2669
  });
@@ -2762,11 +2762,11 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2762
2762
  return "VERTICAL";
2763
2763
  }
2764
2764
  }, isDisabledControl = (o, r, n) => !!(o && (n === "UP" || n === "LEFT") || r && (n === "DOWN" || n === "RIGHT")), useBlockController = (o, r) => {
2765
- const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), m = u <= 0, g = u + 1 === (d == null ? void 0 : d.length), h = getParentBlockOrientation(c, i, a), f = useCallback(
2765
+ const [n] = useBlocksStore(), { document: a } = useFrame(), { moveBlocks: l } = useBlocksStoreUndoableActions(), i = get(o, "_id"), c = get(o, "_parent"), d = filter(n, (x) => c ? get(x, "_parent") === c : !get(x, "_parent")), p = (d == null ? void 0 : d.length) <= 1, u = findIndex(d, { _id: i }), g = u <= 0, h = u + 1 === (d == null ? void 0 : d.length), m = getParentBlockOrientation(c, i, a), f = useCallback(
2766
2766
  (x) => {
2767
- isDisabledControl(m, g, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
2767
+ isDisabledControl(g, h, x) || p || (x === "UP" || x === "LEFT" ? l([i], c || null, u - 1) : (x === "DOWN" || x === "RIGHT") && l([i], c || null, u + 2), r());
2768
2768
  },
2769
- [m, g, p, u, i, c, r]
2769
+ [g, h, p, u, i, c, r]
2770
2770
  );
2771
2771
  return useHotkeys(
2772
2772
  "shift+up, shift+down, shift+left, shift+right",
@@ -2776,7 +2776,7 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2776
2776
  },
2777
2777
  { document: a == null ? void 0 : a.contentDocument },
2778
2778
  [f]
2779
- ), { isOnlyChild: p, isFirstBlock: m, isLastBlock: g, moveBlock: f, orientation: h };
2779
+ ), { isOnlyChild: p, isFirstBlock: g, isLastBlock: h, moveBlock: f, orientation: m };
2780
2780
  }, BlockController = ({ block: o, updateFloatingBar: r }) => {
2781
2781
  const { isOnlyChild: n, isFirstBlock: a, isLastBlock: l, moveBlock: i, orientation: c } = useBlockController(
2782
2782
  o,
@@ -2784,12 +2784,12 @@ const useSidebarActivePanel = () => useAtom$1(sidebarActivePanelAtom), CONTROLS
2784
2784
  );
2785
2785
  return n ? null : /* @__PURE__ */ jsx(Fragment, { children: CONTROLS.map(({ ControlIcon: d, dir: p, key: u }) => {
2786
2786
  if (c !== p) return null;
2787
- const m = isDisabledControl(a, l, u);
2788
- return m ? null : /* @__PURE__ */ jsx(
2787
+ const g = isDisabledControl(a, l, u);
2788
+ return g ? null : /* @__PURE__ */ jsx(
2789
2789
  d,
2790
2790
  {
2791
2791
  onClick: () => i(u),
2792
- className: `${m ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
2792
+ className: `${g ? "pointer-events-none cursor-not-allowed opacity-50" : "duration-300 hover:scale-95 hover:opacity-80"}`
2793
2793
  },
2794
2794
  u
2795
2795
  );
@@ -2911,20 +2911,20 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2911
2911
  i([null]);
2912
2912
  }, [n, r]), /* @__PURE__ */ jsx(BlockFloatingSelector, { block: o, selectedBlockElement: a[0] });
2913
2913
  }, BlockFloatingSelector = ({ block: o, selectedBlockElement: r }) => {
2914
- const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: m, refs: g, update: h } = useFloating({
2914
+ const n = useRemoveBlocks(), a = useDuplicateBlocks(), [, l] = useSelectedBlockIds(), [, i] = useHighlightBlockId(), [, c] = useSelectedStylingBlocks(), { hasPermission: d } = usePermissions(), [p] = useAtom$1(inlineEditingActiveAtom), { document: u } = useFrame(), { floatingStyles: g, refs: h, update: m } = useFloating({
2915
2915
  placement: "top-start",
2916
2916
  middleware: [shift(), flip()],
2917
2917
  elements: { reference: r }
2918
2918
  });
2919
- useResizeObserver(r, () => h(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => h(), (u == null ? void 0 : u.body) !== null);
2919
+ useResizeObserver(r, () => m(), r !== null), useResizeObserver(u == null ? void 0 : u.body, () => m(), (u == null ? void 0 : u.body) !== null);
2920
2920
  const f = get(o, "_parent", null), x = isEmpty(get(o, "_name", "")) ? get(o, "_type", "") : get(o, "_name", "");
2921
2921
  return !r || !o || p ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
2922
2922
  "div",
2923
2923
  {
2924
2924
  role: "button",
2925
2925
  tabIndex: 0,
2926
- ref: g.setFloating,
2927
- style: m,
2926
+ ref: h.setFloating,
2927
+ style: g,
2928
2928
  onClick: (y) => {
2929
2929
  y.stopPropagation(), y.preventDefault();
2930
2930
  },
@@ -2948,7 +2948,7 @@ const INLINE_EDITABLE_BLOCKS = ["Heading", "Paragraph", "Text", "Link", "Span"],
2948
2948
  /* @__PURE__ */ jsx(AddBlockDropdown, { block: o, children: /* @__PURE__ */ jsx(PlusIcon, { className: "hover:scale-105" }) }),
2949
2949
  canDuplicateBlock(get(o, "_type", "")) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsx(CopyIcon, { className: "hover:scale-105", onClick: () => a([o == null ? void 0 : o._id]) }) : null,
2950
2950
  canDeleteBlock(get(o, "_type", "")) && d(PERMISSIONS.DELETE_BLOCK) ? /* @__PURE__ */ jsx(TrashIcon, { className: "hover:scale-105", onClick: () => n([o == null ? void 0 : o._id]) }) : null,
2951
- d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: h })
2951
+ d(PERMISSIONS.MOVE_BLOCK) && /* @__PURE__ */ jsx(BlockController, { block: o, updateFloatingBar: m })
2952
2952
  ] })
2953
2953
  ]
2954
2954
  }
@@ -3022,17 +3022,17 @@ class Content extends Component {
3022
3022
  class Frame extends Component {
3023
3023
  constructor(n, a) {
3024
3024
  super(n, a);
3025
- U(this, "setRef", (n) => {
3025
+ H(this, "setRef", (n) => {
3026
3026
  this.nodeRef.current = n;
3027
3027
  const { forwardedRef: a } = this.props;
3028
3028
  typeof a == "function" ? a(n) : a && (a.current = n);
3029
3029
  });
3030
- U(this, "handleLoad", () => {
3030
+ H(this, "handleLoad", () => {
3031
3031
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3032
3032
  });
3033
3033
  // In certain situations on a cold cache DOMContentLoaded never gets called
3034
3034
  // fallback to an interval to check if that's the case
3035
- U(this, "loadCheck", () => setInterval(() => {
3035
+ H(this, "loadCheck", () => setInterval(() => {
3036
3036
  this.handleLoad();
3037
3037
  }, 500));
3038
3038
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -3069,7 +3069,7 @@ class Frame extends Component {
3069
3069
  return delete n.head, delete n.initialContent, delete n.mountTarget, delete n.contentDidMount, delete n.contentDidUpdate, delete n.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...n, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
3070
3070
  }
3071
3071
  }
3072
- U(Frame, "defaultProps", {
3072
+ H(Frame, "defaultProps", {
3073
3073
  style: {},
3074
3074
  head: null,
3075
3075
  children: void 0,
@@ -3081,15 +3081,15 @@ U(Frame, "defaultProps", {
3081
3081
  initialContent: '<!DOCTYPE html><html><head></head><body><div class="frame-root"></div></body></html>'
3082
3082
  });
3083
3083
  const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame, { ...o, forwardedRef: r })), useKeyEventWatcher = (o) => {
3084
- const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: m, pasteBlocks: g } = usePasteBlocks(), h = o ? { document: o } : {};
3084
+ const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlocks(), { canPaste: g, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
3085
3085
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(r), {}, [r, p]), useHotkeys("ctrl+c,command+c", () => u(r), {}, [r, u]), useHotkeys(
3086
3086
  "ctrl+v,command+v",
3087
3087
  () => {
3088
- m(r[0]) && g(r);
3088
+ g(r[0]) && h(r);
3089
3089
  },
3090
- { ...h, preventDefault: !0 },
3091
- [r, m, g]
3092
- ), useHotkeys("esc", () => n([]), h, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...h, preventDefault: !0 }, [
3090
+ { ...m, preventDefault: !0 },
3091
+ [r, g, h]
3092
+ ), useHotkeys("esc", () => n([]), m, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...m, preventDefault: !0 }, [
3093
3093
  r,
3094
3094
  i
3095
3095
  ]), useHotkeys(
@@ -3097,7 +3097,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3097
3097
  (f) => {
3098
3098
  f.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3099
3099
  },
3100
- h,
3100
+ m,
3101
3101
  [r, l]
3102
3102
  );
3103
3103
  }, KeyboardHandler = () => {
@@ -3212,12 +3212,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3212
3212
  }, [a, l]);
3213
3213
  return /* @__PURE__ */ jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
3214
3214
  }, MayBeAsyncPropsWrapper = ({ children: o, block: r }) => {
3215
- const n = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), a = has(n, "dataProviderDependencies"), l = get(n, "dataProvider"), i = useAsyncProps(
3216
- a || l ? r : void 0,
3217
- get(n, "dataProviderDependencies"),
3218
- l ?? void 0
3219
- );
3220
- return o(i);
3215
+ const n = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), a = get(n, "dataProviderDependencies"), l = get(n, "dataProvider"), i = get(n, "dataProviderMode", "mock"), c = useAsyncProps(r, i, a, l);
3216
+ return o(c);
3221
3217
  }, ErrorFallback = () => /* @__PURE__ */ jsx("div", { className: "flex min-h-[100px] items-center justify-center bg-red-50 p-2 text-center text-red-500", children: "Something went wrong." }), useBlockRuntimeProps = () => {
3222
3218
  const [o] = useBlocksStore();
3223
3219
  return useCallback(
@@ -3391,8 +3387,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3391
3387
  })
3392
3388
  ],
3393
3389
  onUpdate: ({ editor: u }) => a((u == null ? void 0 : u.getHTML()) || ""),
3394
- onBlur: ({ editor: u, event: m }) => {
3395
- const g = m.relatedTarget, h = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = h == null ? void 0 : h.contains(g), y = f == null ? void 0 : f.contains(g);
3390
+ onBlur: ({ editor: u, event: g }) => {
3391
+ const h = g.relatedTarget, m = i.querySelector(".ProseMirror"), f = i.querySelector(".tippy-box"), x = m == null ? void 0 : m.contains(h), y = f == null ? void 0 : f.contains(h);
3396
3392
  if (!x && !y) {
3397
3393
  const b = (u == null ? void 0 : u.getHTML()) || "";
3398
3394
  n(b);
@@ -3410,11 +3406,11 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3410
3406
  });
3411
3407
  }, [c]);
3412
3408
  const d = useMemo(() => {
3413
- var g;
3409
+ var h;
3414
3410
  const u = "max-w-none shadow-none outline outline-[2px] outline-green-500 [&_*]:shadow-none";
3415
3411
  if (!r) return u;
3416
- const m = ((g = r == null ? void 0 : r.className) == null ? void 0 : g.replace("sr-only", "")) || "";
3417
- return `${u} ${m}`;
3412
+ const g = ((h = r == null ? void 0 : r.className) == null ? void 0 : h.replace("sr-only", "")) || "";
3413
+ return `${u} ${g}`;
3418
3414
  }, [r]), p = useCallback(
3419
3415
  (u) => {
3420
3416
  u.key === "Escape" && l(u);
@@ -3448,28 +3444,28 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3448
3444
  useEffect(() => {
3449
3445
  if (a.current) {
3450
3446
  a.current.innerText = r, a.current.focus();
3451
- const h = c.createRange(), f = d.getSelection();
3452
- h.selectNodeContents(a.current), h.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(h), a.current.focus();
3447
+ const m = c.createRange(), f = d.getSelection();
3448
+ m.selectNodeContents(a.current), m.collapse(!1), f == null || f.removeAllRanges(), f == null || f.addRange(m), a.current.focus();
3453
3449
  } else
3454
3450
  n();
3455
3451
  }, [c, d]);
3456
3452
  const p = useMemo(() => {
3457
3453
  var f;
3458
- const h = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
3459
- return h === "button" ? "div" : h;
3454
+ const m = ((f = o == null ? void 0 : o.tagName) == null ? void 0 : f.toLowerCase()) || "div";
3455
+ return m === "button" ? "div" : m;
3460
3456
  }, [o]), u = useCallback(
3461
- (h) => {
3462
- (h.key === "Enter" || h.key === "Escape") && i(h);
3457
+ (m) => {
3458
+ (m.key === "Enter" || m.key === "Escape") && i(m);
3463
3459
  },
3464
3460
  [i]
3465
- ), m = useCallback(() => {
3461
+ ), g = useCallback(() => {
3466
3462
  n();
3467
- }, [n]), g = useMemo(() => {
3468
- var h;
3463
+ }, [n]), h = useMemo(() => {
3464
+ var m;
3469
3465
  return {
3470
3466
  id: "active-inline-editing-element",
3471
3467
  contentEditable: !0,
3472
- className: `${((h = o == null ? void 0 : o.className) == null ? void 0 : h.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
3468
+ className: `${((m = o == null ? void 0 : o.className) == null ? void 0 : m.replace("sr-only", "")) || ""} outline outline-[2px] outline-green-500 shadow-none empty:before:content-[attr(data-placeholder)] empty:before:text-gray-400 empty:before:absolute empty:before:pointer-events-none empty:before:select-none empty:before:inset-0 empty:before:z-0 relative min-h-[1em]`,
3473
3469
  style: cloneDeep(o == null ? void 0 : o.style) || {},
3474
3470
  onInput: (f) => {
3475
3471
  const x = f.target;
@@ -3482,40 +3478,40 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3482
3478
  }, [o == null ? void 0 : o.className, o == null ? void 0 : o.style]);
3483
3479
  return /* @__PURE__ */ jsx(Fragment, { children: createElement(p, {
3484
3480
  ref: a,
3485
- onBlur: m,
3481
+ onBlur: g,
3486
3482
  onKeyDown: u,
3487
- ...g
3483
+ ...h
3488
3484
  }) });
3489
3485
  }
3490
3486
  ), WithBlockTextEditor = memo(
3491
3487
  ({ block: o, children: r }) => {
3492
- const n = "content", { document: a } = useFrame(), [l, i] = useAtom$1(inlineEditingActiveAtom), [c, d] = useState(null), p = useRef(null), { clearHighlight: u } = useBlockHighlight(), m = useUpdateBlocksProps(), { selectedLang: g } = useLanguages(), [, h] = useSelectedBlockIds(), f = useRef(null), x = l, { blockContent: y, blockType: b } = useMemo(() => {
3488
+ const n = "content", { document: a } = useFrame(), [l, i] = useAtom$1(inlineEditingActiveAtom), [c, d] = useState(null), p = useRef(null), { clearHighlight: u } = useBlockHighlight(), g = useUpdateBlocksProps(), { selectedLang: h } = useLanguages(), [, m] = useSelectedBlockIds(), f = useRef(null), x = l, { blockContent: y, blockType: b } = useMemo(() => {
3493
3489
  var C;
3494
3490
  const _ = o._type;
3495
3491
  let S = o[n];
3496
3492
  const A = getRegisteredChaiBlock(o._type);
3497
- return g && ((C = A == null ? void 0 : A.i18nProps) == null ? void 0 : C.includes(n)) && has(o, `${n}-${g}`) && (S = get(o, `${n}-${g}`)), { blockContent: S, blockType: _ };
3498
- }, [o, g]), v = useCallback(
3493
+ return h && ((C = A == null ? void 0 : A.i18nProps) == null ? void 0 : C.includes(n)) && has(o, `${n}-${h}`) && (S = get(o, `${n}-${h}`)), { blockContent: S, blockType: _ };
3494
+ }, [o, h]), v = useCallback(
3499
3495
  (_) => {
3500
3496
  var A;
3501
3497
  const S = _ || ((A = p.current) == null ? void 0 : A.innerText);
3502
- m([x], { [n]: S }), d(null), i(null), h([]);
3498
+ g([x], { [n]: S }), d(null), i(null), m([]);
3503
3499
  },
3504
- [x, m, i, h, g]
3500
+ [x, g, i, m, h]
3505
3501
  ), B = useDebouncedCallback(
3506
3502
  (_) => {
3507
- m([x], { [n]: _ });
3503
+ g([x], { [n]: _ });
3508
3504
  },
3509
- [x, o, m, g],
3505
+ [x, o, g, h],
3510
3506
  1e3
3511
3507
  ), w = useCallback(
3512
3508
  (_) => {
3513
3509
  _.preventDefault(), x && (f.current = x), v(), setTimeout(() => {
3514
3510
  const S = f.current;
3515
- f.current = null, h([S]);
3511
+ f.current = null, m([S]);
3516
3512
  }, 100);
3517
3513
  },
3518
- [h, x, g]
3514
+ [m, x, h]
3519
3515
  );
3520
3516
  useEffect(() => {
3521
3517
  var S;
@@ -3542,7 +3538,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3542
3538
  onChange: B,
3543
3539
  onEscape: w
3544
3540
  }
3545
- )) : null, [c, x, b, y, v, g]);
3541
+ )) : null, [c, x, b, y, v, h]);
3546
3542
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3547
3543
  E,
3548
3544
  r
@@ -3577,12 +3573,12 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3577
3573
  blockAtom: r,
3578
3574
  children: n
3579
3575
  }) => {
3580
- const [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(r), i = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: c, fallbackLang: d } = useLanguages(), p = useBlockRuntimeProps(), u = usePageExternalData(), [m] = useHiddenBlockIds(), [g] = useAtom$1(dataBindingActiveAtom), h = get(i, "component", null), { index: f, key: x } = useContext(RepeaterContext), y = useMemo(
3581
- () => g ? applyBindingToBlockProps(applyLanguage(l, c, i), u, {
3576
+ const [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(r), i = useMemo(() => getRegisteredChaiBlock(l._type), [l._type]), { selectedLang: c, fallbackLang: d } = useLanguages(), p = useBlockRuntimeProps(), u = usePageExternalData(), [g] = useHiddenBlockIds(), [h] = useAtom$1(dataBindingActiveAtom), m = get(i, "component", null), { index: f, key: x } = useContext(RepeaterContext), y = useMemo(
3577
+ () => h ? applyBindingToBlockProps(applyLanguage(l, c, i), u, {
3582
3578
  index: f,
3583
3579
  key: x
3584
3580
  }) : applyLanguage(l, c, i),
3585
- [l, c, i, u, g, f, x]
3581
+ [l, c, i, u, h, f, x]
3586
3582
  ), b = useMemo(() => getBlockTagAttributes(l), [l, getBlockTagAttributes]), v = useMemo(
3587
3583
  () => p(l._id, getBlockRuntimeProps(l._type)),
3588
3584
  [l._id, l._type, p, getBlockRuntimeProps]
@@ -3607,8 +3603,8 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3607
3603
  o
3608
3604
  ]
3609
3605
  ), w = useMemo(() => !CORE_BLOCKS.includes(l._type), [l._type]);
3610
- if (isNull(h) || m.includes(l._id)) return null;
3611
- let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(h, {
3606
+ if (isNull(m) || g.includes(l._id)) return null;
3607
+ let E = /* @__PURE__ */ jsx(Suspense, { children: createElement(m, {
3612
3608
  ...B,
3613
3609
  children: n({
3614
3610
  _id: l._id,
@@ -3640,7 +3636,7 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3640
3636
  );
3641
3637
  return map(l, (c) => {
3642
3638
  const d = a(c._id);
3643
- return d ? /* @__PURE__ */ jsx(MayBeAsyncPropsWrapper, { block: c, children: (p) => /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, asyncProps: p, children: ({ _id: u, _type: m, partialBlockId: g, repeaterItems: h, $repeaterItemsKey: f }) => m === "Repeater" ? isArray(h) && h.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : m === "GlobalBlock" || m === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: g }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3639
+ 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: f }) => g === "Repeater" ? isArray(m) && m.map((x, y) => /* @__PURE__ */ jsx(RepeaterContext.Provider, { value: { index: y, key: f }, children: /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) }, `${u}-${y}`)) : g === "GlobalBlock" || g === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: h }) }) : i(u) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: n, blocks: o, parent: c._id }) : null }) }, c._id) : null;
3644
3640
  });
3645
3641
  }, PageBlocksRenderer = () => {
3646
3642
  const [o] = useBlocksStore();
@@ -3653,18 +3649,18 @@ const ChaiFrame = React__default.forwardRef((o, r) => /* @__PURE__ */ jsx(Frame,
3653
3649
  const { width: d, height: p } = o;
3654
3650
  if (d < r) {
3655
3651
  const u = parseFloat((d / r).toFixed(2).toString());
3656
- let m = {};
3657
- const g = p * u, h = d * u;
3658
- p && (m = {
3652
+ let g = {};
3653
+ const h = p * u, m = d * u;
3654
+ p && (g = {
3659
3655
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3660
- height: 100 + (p - g) / g * 100 + "%",
3661
- width: 100 + (d - h) / h * 100 + "%"
3656
+ height: 100 + (p - h) / h * 100 + "%",
3657
+ width: 100 + (d - m) / m * 100 + "%"
3662
3658
  }), i({
3663
3659
  position: "relative",
3664
3660
  top: 0,
3665
3661
  transform: `scale(${u})`,
3666
3662
  transformOrigin: a === "rtl" ? "top right" : "top left",
3667
- ...m,
3663
+ ...g,
3668
3664
  maxWidth: "none"
3669
3665
  // TODO: Add max-width to the wrapper
3670
3666
  }), n(u * 100);
@@ -3691,8 +3687,8 @@ const CanvasEventsWatcher = () => {
3691
3687
  if (d) {
3692
3688
  const p = d.getAttribute("data-style-prop");
3693
3689
  if (p) {
3694
- const u = d.getAttribute("data-style-id"), m = d.getAttribute("data-block-parent");
3695
- n([{ id: u, prop: p, blockId: m }]);
3690
+ const u = d.getAttribute("data-style-id"), g = d.getAttribute("data-block-parent");
3691
+ n([{ id: u, prop: p, blockId: g }]);
3696
3692
  }
3697
3693
  }
3698
3694
  }, 100);
@@ -3700,28 +3696,28 @@ const CanvasEventsWatcher = () => {
3700
3696
  d && (!isEmpty(d) && !includes(i, first(d)) && (c == null || c.closeAll()), o(d));
3701
3697
  }), usePubSub(CHAI_BUILDER_EVENTS.CANVAS_BLOCK_STYLE_SELECTED, (d) => {
3702
3698
  if (!d) return;
3703
- const { blockId: p, styleId: u, styleProp: m } = d;
3704
- p && (includes(i, p) || c == null || c.closeAll(), n([{ id: u, prop: m, blockId: p }]), o([p]));
3699
+ const { blockId: p, styleId: u, styleProp: g } = d;
3700
+ p && (includes(i, p) || c == null || c.closeAll(), n([{ id: u, prop: g, blockId: p }]), o([p]));
3705
3701
  }), usePubSub(CHAI_BUILDER_EVENTS.CLEAR_CANVAS_SELECTION, () => {
3706
3702
  l(), o([]), n([]);
3707
3703
  }), null;
3708
3704
  }, StaticCanvas = () => {
3709
- const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), m = useCallback(
3710
- (h) => {
3711
- i((f) => ({ ...f, width: h }));
3705
+ const [o] = useCanvasDisplayWidth(), [, r] = useHighlightBlockId(), n = useRef(null), a = useRef(null), [l, i] = useState({ width: 0, height: 0 }), c = useCanvasScale(l), [, d] = useAtom$1(canvasIframeAtom), p = useBuilderProp("loading", !1), u = useBuilderProp("htmlDir", "ltr"), g = useCallback(
3706
+ (m) => {
3707
+ i((f) => ({ ...f, width: m }));
3712
3708
  },
3713
3709
  [i]
3714
3710
  );
3715
3711
  useEffect(() => {
3716
3712
  if (!a.current) return;
3717
- const { clientWidth: h, clientHeight: f } = a.current;
3718
- i({ width: h, height: f });
3713
+ const { clientWidth: m, clientHeight: f } = a.current;
3714
+ i({ width: m, height: f });
3719
3715
  }, [a, o]);
3720
- const g = useMemo(() => {
3721
- let h = IframeInitialContent;
3722
- return h = h.replace("__HTML_DIR__", u), h;
3716
+ const h = useMemo(() => {
3717
+ let m = IframeInitialContent;
3718
+ return m = m.replace("__HTML_DIR__", u), m;
3723
3719
  }, [u]);
3724
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: m, onResize: m, children: /* @__PURE__ */ jsx(
3720
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: g, onResize: g, children: /* @__PURE__ */ jsx(
3725
3721
  "div",
3726
3722
  {
3727
3723
  onMouseLeave: () => setTimeout(() => r(""), 300),
@@ -3735,7 +3731,7 @@ const CanvasEventsWatcher = () => {
3735
3731
  id: "canvas-iframe",
3736
3732
  style: { ...c, ...isEmpty(c) ? { width: `${o}px` } : {} },
3737
3733
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
3738
- initialContent: g,
3734
+ initialContent: h,
3739
3735
  children: [
3740
3736
  /* @__PURE__ */ jsx(KeyboardHandler, {}),
3741
3737
  /* @__PURE__ */ jsx(BlockSelectionHighlighter, {}),
@@ -3830,21 +3826,21 @@ const CanvasEventsWatcher = () => {
3830
3826
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: a("Paste SVG code to use as an icon") })
3831
3827
  ] });
3832
3828
  }, DefaultMediaManager = ({ close: o, onSelect: r, mode: n = "image" }) => {
3833
- const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState(null), g = async (f) => {
3829
+ const [a, l] = useState(""), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState(null), h = async (f) => {
3834
3830
  if (!f.trim()) {
3835
- p(!1), m("Please enter a URL");
3831
+ p(!1), g("Please enter a URL");
3836
3832
  return;
3837
3833
  }
3838
3834
  try {
3839
- c(!0), m(null), p(!0), m(null);
3835
+ c(!0), g(null), p(!0), g(null);
3840
3836
  } catch {
3841
- p(!1), m("Error validating URL");
3837
+ p(!1), g("Error validating URL");
3842
3838
  } finally {
3843
3839
  c(!1);
3844
3840
  }
3845
- }, { t: h } = useTranslation();
3841
+ }, { t: m } = useTranslation();
3846
3842
  return /* @__PURE__ */ jsxs("div", { className: "flex w-96 flex-col gap-4 p-4", children: [
3847
- /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: h(`${n.charAt(0).toUpperCase() + n.slice(1)} Manager`) }),
3843
+ /* @__PURE__ */ jsx("h2", { className: "text-xl font-semibold", children: m(`${n.charAt(0).toUpperCase() + n.slice(1)} Manager`) }),
3848
3844
  u && /* @__PURE__ */ jsxs(Alert, { variant: "destructive", children: [
3849
3845
  /* @__PURE__ */ jsx(AlertCircle, { className: "h-4 w-4" }),
3850
3846
  /* @__PURE__ */ jsx(AlertDescription, { children: u })
@@ -3853,20 +3849,20 @@ const CanvasEventsWatcher = () => {
3853
3849
  /* @__PURE__ */ jsx(
3854
3850
  Input$1,
3855
3851
  {
3856
- placeholder: h(`Enter ${n} URL`),
3852
+ placeholder: m(`Enter ${n} URL`),
3857
3853
  value: a,
3858
3854
  onChange: (f) => l(f.target.value),
3859
- onKeyUp: () => g(a)
3855
+ onKeyUp: () => h(a)
3860
3856
  }
3861
3857
  ),
3862
3858
  /* @__PURE__ */ jsxs("div", { className: "flex justify-end gap-2", children: [
3863
- /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: h("Cancel") }),
3859
+ /* @__PURE__ */ jsx(Button, { variant: "outline", onClick: o, children: m("Cancel") }),
3864
3860
  /* @__PURE__ */ jsx(
3865
3861
  Button,
3866
3862
  {
3867
3863
  onClick: () => r({ id: "dam-id", url: a, width: 600, height: 400, description: "This is image description" }),
3868
3864
  disabled: !d || i,
3869
- children: h("Insert")
3865
+ children: m("Insert")
3870
3866
  }
3871
3867
  )
3872
3868
  ] })
@@ -3892,17 +3888,17 @@ const CanvasEventsWatcher = () => {
3892
3888
  };
3893
3889
  MediaManagerModal.displayName = "MediaManagerModal";
3894
3890
  const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3895
- const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (m) => {
3896
- const g = isArray(m) ? first(m) : m;
3897
- if (g) {
3898
- r(g == null ? void 0 : g.url);
3899
- const h = g == null ? void 0 : g.width, f = g == null ? void 0 : g.height;
3891
+ const { t: l } = useTranslation(), i = useSelectedBlock(), c = useUpdateBlocksProps(), d = (g) => {
3892
+ const h = isArray(g) ? first(g) : g;
3893
+ if (h) {
3894
+ r(h == null ? void 0 : h.url);
3895
+ const m = h == null ? void 0 : h.width, f = h == null ? void 0 : h.height;
3900
3896
  if (i != null && i._id) {
3901
3897
  const x = {
3902
- ...h && { width: h },
3898
+ ...m && { width: m },
3903
3899
  ...f && { height: f },
3904
- ...g.description && { alt: g.description },
3905
- ...g.id && { assetId: g.id }
3900
+ ...h.description && { alt: h.description },
3901
+ ...h.id && { assetId: h.id }
3906
3902
  };
3907
3903
  if (isEmpty(x)) return;
3908
3904
  c([i._id], x);
@@ -3940,25 +3936,25 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3940
3936
  className: "text-xs",
3941
3937
  placeholder: l("Enter image URL"),
3942
3938
  value: o,
3943
- onBlur: ({ target: { value: m } }) => a(n, m),
3944
- onChange: (m) => r(m.target.value)
3939
+ onBlur: ({ target: { value: g } }) => a(n, g),
3940
+ onChange: (g) => r(g.target.value)
3945
3941
  }
3946
3942
  )
3947
3943
  ] })
3948
3944
  ] });
3949
3945
  }, PathDropdown = ({ data: o, onSelect: r, dataType: n }) => {
3950
- const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (g) => Array.isArray(g) ? "array" : typeof g == "object" && g !== null ? "object" : "value", p = React__default.useCallback(
3951
- (g) => {
3952
- const h = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
3953
- g.type === "object" ? (l((f) => [...f, g.key]), c(g.value)) : h(g.type) && r([...a, g.key].join("."), n);
3946
+ const [a, l] = React__default.useState([]), [i, c] = React__default.useState(o), d = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", p = React__default.useCallback(
3947
+ (h) => {
3948
+ const m = (f) => n === "value" ? f === "value" || f === "object" : n === "array" ? f === "array" : f === n;
3949
+ h.type === "object" ? (l((f) => [...f, h.key]), c(h.value)) : m(h.type) && r([...a, h.key].join("."), n);
3954
3950
  },
3955
3951
  [a, r, n]
3956
3952
  ), u = React__default.useCallback(() => {
3957
3953
  if (a.length > 0) {
3958
- const g = a.slice(0, -1);
3959
- l(g), c(g.reduce((h, f) => h[f], o));
3954
+ const h = a.slice(0, -1);
3955
+ l(h), c(h.reduce((m, f) => m[f], o));
3960
3956
  }
3961
- }, [a, o]), m = React__default.useMemo(() => i ? Object.entries(i).map(([g, h]) => ({ key: g, value: h, type: d(h) })).filter((g) => !startsWith(g.key, REPEATER_PREFIX) && g.key.includes("/") ? !1 : n === "value" ? g.type === "value" || g.type === "object" : n === "array" ? g.type === "array" || g.type === "object" : n === "object" ? g.type === "object" : !0) : [], [i, n]);
3957
+ }, [a, o]), g = React__default.useMemo(() => i ? Object.entries(i).map(([h, m]) => ({ key: h, value: m, type: d(m) })).filter((h) => !startsWith(h.key, REPEATER_PREFIX) && h.key.includes("/") ? !1 : n === "value" ? h.type === "value" || h.type === "object" : n === "array" ? h.type === "array" || h.type === "object" : n === "object" ? h.type === "object" : !0) : [], [i, n]);
3962
3958
  return /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
3963
3959
  /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
3964
3960
  /* @__PURE__ */ jsxs(CommandList, { children: [
@@ -3968,36 +3964,36 @@ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
3968
3964
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
3969
3965
  "Back"
3970
3966
  ] }),
3971
- m.map((g) => /* @__PURE__ */ jsxs(
3967
+ g.map((h) => /* @__PURE__ */ jsxs(
3972
3968
  CommandItem,
3973
3969
  {
3974
- value: g.key,
3970
+ value: h.key,
3975
3971
  disabled: !1,
3976
- onSelect: () => p(g),
3972
+ onSelect: () => p(h),
3977
3973
  className: "flex items-center justify-between",
3978
3974
  children: [
3979
3975
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-x-2", children: [
3980
- startsWith(g.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(g.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
3981
- startsWith(g.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(g.key, COLLECTION_PREFIX) ? g.key.replace(COLLECTION_PREFIX, "") : g.key
3976
+ startsWith(h.key, REPEATER_PREFIX) ? /* @__PURE__ */ jsx(LoopIcon, {}) : startsWith(h.key, COLLECTION_PREFIX) ? /* @__PURE__ */ jsx(DatabaseIcon, {}) : null,
3977
+ startsWith(h.key, REPEATER_PREFIX) ? "Repeater Data" : startsWith(h.key, COLLECTION_PREFIX) ? h.key.replace(COLLECTION_PREFIX, "") : h.key
3982
3978
  ] }),
3983
3979
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
3984
- n === "object" && g.type === "object" && /* @__PURE__ */ jsx(
3980
+ n === "object" && h.type === "object" && /* @__PURE__ */ jsx(
3985
3981
  Button,
3986
3982
  {
3987
3983
  size: "sm",
3988
3984
  variant: "ghost",
3989
3985
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
3990
- onClick: (h) => {
3991
- h.stopPropagation(), r([...a, g.key].join("."), n);
3986
+ onClick: (m) => {
3987
+ m.stopPropagation(), r([...a, h.key].join("."), n);
3992
3988
  },
3993
3989
  children: "Select"
3994
3990
  }
3995
3991
  ),
3996
- g.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
3992
+ h.type === "object" && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
3997
3993
  ] })
3998
3994
  ]
3999
3995
  },
4000
- g.key
3996
+ h.key
4001
3997
  ))
4002
3998
  ] })
4003
3999
  ] })
@@ -4049,18 +4045,18 @@ const DataBindingSelector = ({
4049
4045
  }) => {
4050
4046
  const l = usePageExternalData(), i = useSelectedBlockHierarchy(), c = useSelectedBlock(), d = useMemo(() => {
4051
4047
  if (i.length === 1) return "";
4052
- const m = i.find((f) => f._type === "Repeater"), h = get(m, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4053
- return `${REPEATER_PREFIX}${startsWith(h, COLLECTION_PREFIX) ? `${h}/${m._id}` : h}`;
4048
+ const g = i.find((f) => f._type === "Repeater"), m = get(g, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1");
4049
+ return `${REPEATER_PREFIX}${startsWith(m, COLLECTION_PREFIX) ? `${m}/${g._id}` : m}`;
4054
4050
  }, [i]), p = useMemo(() => first(get(l, d.replace(REPEATER_PREFIX, ""), [])), [d, l]), u = useCallback(
4055
- (m, g) => {
4056
- if (m = isEmpty(d) ? m : m.replace(`${d}`, "$index"), g === "array" || g === "object") {
4057
- r(`{{${m}}}`, {}, n);
4051
+ (g, h) => {
4052
+ if (g = isEmpty(d) ? g : g.replace(`${d}`, "$index"), h === "array" || h === "object") {
4053
+ r(`{{${g}}}`, {}, n);
4058
4054
  return;
4059
4055
  }
4060
- const h = (b) => /[.,!?;:]/.test(b), f = (b, v, B) => {
4056
+ const m = (b) => /[.,!?;:]/.test(b), f = (b, v, B) => {
4061
4057
  let w = "", E = "";
4062
4058
  const _ = v > 0 ? b[v - 1] : "", S = v < b.length ? b[v] : "";
4063
- return v > 0 && (_ === "." || !h(_) && _ !== " ") && (w = " "), v < b.length && !h(S) && S !== " " && (E = " "), {
4059
+ return v > 0 && (_ === "." || !m(_) && _ !== " ") && (w = " "), v < b.length && !m(S) && S !== " " && (E = " "), {
4064
4060
  text: w + B + E,
4065
4061
  prefixLength: w.length,
4066
4062
  suffixLength: E.length
@@ -4071,7 +4067,7 @@ const DataBindingSelector = ({
4071
4067
  if (y && (y.querySelector(".ProseMirror") || y.__chaiRTE)) {
4072
4068
  const b = y.__chaiRTE;
4073
4069
  if (b) {
4074
- const v = `{{${m}}}`;
4070
+ const v = `{{${g}}}`;
4075
4071
  b.commands.focus();
4076
4072
  const { from: B, to: w } = b.state.selection;
4077
4073
  if (B !== w)
@@ -4079,9 +4075,9 @@ const DataBindingSelector = ({
4079
4075
  else {
4080
4076
  const { state: _ } = b, S = _.selection.from, A = _.doc.textBetween(Math.max(0, S - 1), S), N = _.doc.textBetween(S, Math.min(S + 1, _.doc.content.size));
4081
4077
  let C = "";
4082
- S > 0 && A !== " " && !h(A) && (C = " ");
4078
+ S > 0 && A !== " " && !m(A) && (C = " ");
4083
4079
  let k = "";
4084
- N && N !== " " && !h(N) && (k = " "), b.chain().insertContent(C + v + k).run();
4080
+ N && N !== " " && !m(N) && (k = " "), b.chain().insertContent(C + v + k).run();
4085
4081
  }
4086
4082
  setTimeout(() => r(b.getHTML(), {}, n), 100);
4087
4083
  return;
@@ -4089,11 +4085,11 @@ const DataBindingSelector = ({
4089
4085
  } else {
4090
4086
  const b = x, v = b.selectionStart || 0, B = b.value || "", w = b.selectionEnd || v;
4091
4087
  if (w > v) {
4092
- const N = `{{${m}}}`, { text: C } = f(B, v, N), k = B.slice(0, v) + C + B.slice(w);
4088
+ const N = `{{${g}}}`, { text: C } = f(B, v, N), k = B.slice(0, v) + C + B.slice(w);
4093
4089
  r(k, {}, n);
4094
4090
  return;
4095
4091
  }
4096
- const _ = `{{${m}}}`, { text: S } = f(B, v, _), A = B.slice(0, v) + S + B.slice(v);
4092
+ const _ = `{{${g}}}`, { text: S } = f(B, v, _), A = B.slice(0, v) + S + B.slice(v);
4097
4093
  r(A, {}, n);
4098
4094
  }
4099
4095
  },
@@ -4116,13 +4112,13 @@ const DataBindingSelector = ({
4116
4112
  onChange: n
4117
4113
  }) => {
4118
4114
  var N;
4119
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, m] = useState("page"), [g, h] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), B = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
4115
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (C, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [h, m] = useState(""), [f, x] = useState([]), [y, b] = useState(-1), v = useRef(null), B = (N = r == null ? void 0 : r.find((C) => C.key === u)) == null ? void 0 : N.name;
4120
4116
  useEffect(() => {
4121
- if (h(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4117
+ if (m(""), x([]), b(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4122
4118
  const C = split(o, ":"), k = get(C, 1, "page") || "page";
4123
- m(k), (async () => {
4119
+ g(k), (async () => {
4124
4120
  const j = await l(k, [get(C, 2, "page")]);
4125
- j && Array.isArray(j) && h(get(j, [0, "name"], ""));
4121
+ j && Array.isArray(j) && m(get(j, [0, "name"], ""));
4126
4122
  })();
4127
4123
  }, [o]);
4128
4124
  const w = useDebouncedCallback(
@@ -4139,7 +4135,7 @@ const DataBindingSelector = ({
4139
4135
  300
4140
4136
  ), E = (C) => {
4141
4137
  const k = ["pageType", u, C.id];
4142
- k[1] && (n(k.join(":")), h(C.name), p(!1), x([]), b(-1));
4138
+ k[1] && (n(k.join(":")), m(C.name), p(!1), x([]), b(-1));
4143
4139
  }, _ = (C) => {
4144
4140
  switch (C.key) {
4145
4141
  case "ArrowDown":
@@ -4164,25 +4160,25 @@ const DataBindingSelector = ({
4164
4160
  }
4165
4161
  }, [y]);
4166
4162
  const S = () => {
4167
- h(""), x([]), b(-1), p(!1), n("");
4163
+ m(""), x([]), b(-1), p(!1), n("");
4168
4164
  }, A = (C) => {
4169
- h(C), p(!isEmpty(C)), c(!0), w(C);
4165
+ m(C), p(!isEmpty(C)), c(!0), w(C);
4170
4166
  };
4171
4167
  return /* @__PURE__ */ jsxs("div", { children: [
4172
- /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (C) => m(C.target.value), children: map(r, (C) => /* @__PURE__ */ jsx("option", { value: C.key, children: C.name }, C.key)) }),
4168
+ /* @__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)) }),
4173
4169
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4174
4170
  /* @__PURE__ */ jsx(
4175
4171
  "input",
4176
4172
  {
4177
4173
  type: "text",
4178
- value: g,
4174
+ value: h,
4179
4175
  onChange: (C) => A(C.target.value),
4180
4176
  onKeyDown: _,
4181
4177
  placeholder: a(`Search ${B ?? ""}`),
4182
4178
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4183
4179
  }
4184
4180
  ),
4185
- /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: g && /* @__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" }) }) })
4181
+ /* @__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" }) }) })
4186
4182
  ] }),
4187
4183
  (i || !isEmpty(f) || d && isEmpty(f)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4188
4184
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4190,7 +4186,7 @@ const DataBindingSelector = ({
4190
4186
  ] }) : d && isEmpty(f) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4191
4187
  a("No results found for"),
4192
4188
  ' "',
4193
- g,
4189
+ h,
4194
4190
  '"'
4195
4191
  ] }) : /* @__PURE__ */ jsx("ul", { ref: v, children: map(f == null ? void 0 : f.slice(0, 20), (C, k) => /* @__PURE__ */ jsxs(
4196
4192
  "li",
@@ -4219,8 +4215,8 @@ const DataBindingSelector = ({
4219
4215
  DataBindingSelector,
4220
4216
  {
4221
4217
  schema: o,
4222
- onChange: (m) => {
4223
- console.log("value", r, m), n({ ...r, href: m, ...u === "pageType" ? { type: "url" } : {} });
4218
+ onChange: (g) => {
4219
+ console.log("value", r, g), n({ ...r, href: g, ...u === "pageType" ? { type: "url" } : {} });
4224
4220
  },
4225
4221
  id: `root.${a}.href`,
4226
4222
  formData: r
@@ -4228,7 +4224,7 @@ const DataBindingSelector = ({
4228
4224
  )
4229
4225
  ] }),
4230
4226
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-y-1.5", children: [
4231
- /* @__PURE__ */ jsx("select", { name: "type", value: i, onChange: (m) => n({ ...r, type: m.target.value }), children: map(
4227
+ /* @__PURE__ */ jsx("select", { name: "type", value: i, onChange: (g) => n({ ...r, type: g.target.value }), children: map(
4232
4228
  [
4233
4229
  ...isEmpty(p) ? [] : [{ const: "pageType", title: l("Goto Page") }],
4234
4230
  { const: "url", title: l("Open URL") },
@@ -4236,14 +4232,14 @@ const DataBindingSelector = ({
4236
4232
  { const: "telephone", title: l("Call Phone") },
4237
4233
  { const: "scroll", title: l("Scroll to element") }
4238
4234
  ],
4239
- (m) => /* @__PURE__ */ jsx("option", { value: m.const, children: m.title }, m.const)
4235
+ (g) => /* @__PURE__ */ jsx("option", { value: g.const, children: g.title }, g.const)
4240
4236
  ) }),
4241
4237
  u === "pageType" && !isEmpty(p) ? /* @__PURE__ */ jsx(
4242
4238
  PageTypeField,
4243
4239
  {
4244
4240
  href: c,
4245
4241
  pageTypes: p,
4246
- onChange: (m) => n({ ...r, href: m })
4242
+ onChange: (g) => n({ ...r, href: g })
4247
4243
  }
4248
4244
  ) : null,
4249
4245
  /* @__PURE__ */ jsx(
@@ -4257,7 +4253,7 @@ const DataBindingSelector = ({
4257
4253
  type: "text",
4258
4254
  className: u === "pageType" ? "!hidden" : "",
4259
4255
  value: c,
4260
- onChange: (m) => n({ ...r, href: m.target.value }),
4256
+ onChange: (g) => n({ ...r, href: g.target.value }),
4261
4257
  placeholder: l(i === "url" ? "Enter URL" : i === "scroll" ? "#ElementID" : "Enter details")
4262
4258
  }
4263
4259
  ),
@@ -4448,16 +4444,16 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4448
4444
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4449
4445
  useEffect(() => {
4450
4446
  if (o) {
4451
- const g = document.createElement("style");
4452
- return g.id = "rte-modal-styles", g.innerHTML = `
4447
+ const h = document.createElement("style");
4448
+ return h.id = "rte-modal-styles", h.innerHTML = `
4453
4449
  /* Ensure the NestedPathSelector popover appears above the dialog */
4454
4450
  .rte-path-selector + [data-radix-popper-content-wrapper],
4455
4451
  [data-radix-popper-content-wrapper] {
4456
4452
  z-index: 9999 !important;
4457
4453
  }
4458
- `, document.head.appendChild(g), () => {
4459
- const h = document.getElementById("rte-modal-styles");
4460
- h && h.remove();
4454
+ `, document.head.appendChild(h), () => {
4455
+ const m = document.getElementById("rte-modal-styles");
4456
+ m && m.remove();
4461
4457
  };
4462
4458
  }
4463
4459
  }, [o]);
@@ -4482,13 +4478,13 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4482
4478
  })
4483
4479
  ],
4484
4480
  content: a || "",
4485
- onUpdate: ({ editor: g }) => {
4486
- const h = g.getHTML();
4487
- l(h);
4481
+ onUpdate: ({ editor: h }) => {
4482
+ const m = h.getHTML();
4483
+ l(m);
4488
4484
  },
4489
- onBlur: ({ editor: g }) => {
4490
- const h = g.getHTML();
4491
- i(n, h);
4485
+ onBlur: ({ editor: h }) => {
4486
+ const m = h.getHTML();
4487
+ i(n, m);
4492
4488
  },
4493
4489
  editorProps: {
4494
4490
  attributes: {
@@ -4503,27 +4499,27 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4503
4499
  }, [o, u]), useEffect(() => {
4504
4500
  c.current && u && (c.current.__chaiRTE = u);
4505
4501
  }, [u, o]);
4506
- const m = (g) => {
4502
+ const g = (h) => {
4507
4503
  if (!u) return;
4508
- const h = `{{${g}}}`;
4504
+ const m = `{{${h}}}`;
4509
4505
  u.commands.focus();
4510
4506
  const { from: f, to: x } = u.state.selection;
4511
4507
  if (f !== x)
4512
- u.chain().deleteSelection().insertContent(h).run();
4508
+ u.chain().deleteSelection().insertContent(m).run();
4513
4509
  else {
4514
4510
  const { state: b } = u, v = b.selection.from, B = b.doc.textBetween(Math.max(0, v - 1), v), w = b.doc.textBetween(v, Math.min(v + 1, b.doc.content.size));
4515
4511
  let E = "";
4516
4512
  v > 0 && B !== " " && !/[.,!?;:]/.test(B) && (E = " ");
4517
4513
  let _ = "";
4518
- w && w !== " " && !/[.,!?;:]/.test(w) && (_ = " "), u.chain().insertContent(E + h + _).run();
4514
+ w && w !== " " && !/[.,!?;:]/.test(w) && (_ = " "), u.chain().insertContent(E + m + _).run();
4519
4515
  }
4520
4516
  };
4521
- return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (g) => !g && r(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4517
+ 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: [
4522
4518
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4523
4519
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4524
4520
  Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
4525
4521
  /* @__PURE__ */ jsx("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
4526
- /* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: m }) })
4522
+ /* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: g }) })
4527
4523
  ] })
4528
4524
  ] }) }),
4529
4525
  /* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${n}`, ref: c, className: "rounded-md border border-input", children: [
@@ -4533,7 +4529,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4533
4529
  /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: r, children: "Done" }) })
4534
4530
  ] }) });
4535
4531
  }, RichTextEditorField = ({ id: o, placeholder: r, value: n, onChange: a, onBlur: l }) => {
4536
- const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), m = useEditor({
4532
+ const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), g = useEditor({
4537
4533
  extensions: [
4538
4534
  StarterKit,
4539
4535
  Link.configure({
@@ -4569,28 +4565,28 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4569
4565
  }
4570
4566
  });
4571
4567
  useEffect(() => {
4572
- i.current.__chaiRTE = m;
4573
- }, [m]), useEffect(() => {
4568
+ i.current.__chaiRTE = g;
4569
+ }, [g]), useEffect(() => {
4574
4570
  u(n || "");
4575
4571
  }, [n]);
4576
- const g = (f) => {
4572
+ const h = (f) => {
4577
4573
  a(f);
4578
- }, h = () => {
4579
- d(!1), m && m.commands.setContent(p);
4574
+ }, m = () => {
4575
+ d(!1), g && g.commands.setContent(p);
4580
4576
  };
4581
4577
  return /* @__PURE__ */ jsxs(Fragment, { children: [
4582
4578
  /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs("div", { id: `chai-rte-${o}`, ref: i, className: "mt-1 rounded-md border border-input", children: [
4583
- /* @__PURE__ */ jsx(MenuBar, { editor: m, onExpand: () => d(!0) }),
4584
- /* @__PURE__ */ jsx(EditorContent, { editor: m, id: o, placeholder: r })
4579
+ /* @__PURE__ */ jsx(MenuBar, { editor: g, onExpand: () => d(!0) }),
4580
+ /* @__PURE__ */ jsx(EditorContent, { editor: g, id: o, placeholder: r })
4585
4581
  ] }) }),
4586
4582
  c && /* @__PURE__ */ jsx(
4587
4583
  RTEModal,
4588
4584
  {
4589
4585
  isOpen: c,
4590
- onClose: h,
4586
+ onClose: m,
4591
4587
  id: o,
4592
4588
  value: p,
4593
- onChange: g,
4589
+ onChange: h,
4594
4590
  onBlur: l
4595
4591
  }
4596
4592
  )
@@ -4600,21 +4596,21 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4600
4596
  if (!a && !l) return null;
4601
4597
  const d = (a == null ? void 0 : a._type) === "Slider" ? a : l, p = find(n, { _parent: d == null ? void 0 : d._id, _type: "Slides" });
4602
4598
  if (!p) return null;
4603
- const u = filter(n, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), m = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
4599
+ const u = filter(n, { _parent: p == null ? void 0 : p._id, _type: "Slide" }), g = (o == null ? void 0 : o.currentSlide) || get(u, "0._id");
4604
4600
  useEffect(() => {
4605
4601
  (a == null ? void 0 : a._type) === "Slide" && (o == null ? void 0 : o.currentSlide) !== (a == null ? void 0 : a._id) && r({ ...o, currentSlide: a == null ? void 0 : a._id });
4606
4602
  }, [a]), useEffect(() => {
4607
4603
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && r({ ...o, currentSlide: get(u, "0._id") });
4608
4604
  }, [o, u]);
4609
- const g = () => {
4610
- const x = findIndex(u, { _id: m });
4605
+ const h = () => {
4606
+ const x = findIndex(u, { _id: g });
4611
4607
  if (x > -1) {
4612
4608
  const y = (x + 1) % u.length, b = get(u, [y, "_id"]);
4613
4609
  if (!b) return;
4614
4610
  r({ ...o, currentSlide: b }), c([b]);
4615
4611
  }
4616
- }, h = () => {
4617
- const x = findIndex(u, { _id: m });
4612
+ }, m = () => {
4613
+ const x = findIndex(u, { _id: g });
4618
4614
  if (x > -1) {
4619
4615
  const y = (x - 1 + u.length) % u.length, b = get(u, [y, "_id"]);
4620
4616
  if (!b) return;
@@ -4629,16 +4625,16 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4629
4625
  };
4630
4626
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4631
4627
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
4632
- /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4633
- /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: m ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4628
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
4629
+ /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
4634
4630
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
4635
4631
  " ",
4636
- findIndex(u, { _id: m }) + 1
4632
+ findIndex(u, { _id: g }) + 1
4637
4633
  ] }),
4638
4634
  "/",
4639
4635
  u.length
4640
4636
  ] }) : "-" }),
4641
- /* @__PURE__ */ jsx("button", { onClick: g, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4637
+ /* @__PURE__ */ jsx("button", { onClick: h, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
4642
4638
  /* @__PURE__ */ jsxs(
4643
4639
  "button",
4644
4640
  {
@@ -4716,7 +4712,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4716
4712
  const n = get(o, "srcsets", []) || [], a = (c, d) => {
4717
4713
  const p = c.target.name, u = c.target.value;
4718
4714
  r({
4719
- srcsets: map(n, (m, g) => g === d ? { ...m, [p]: u } : m)
4715
+ srcsets: map(n, (g, h) => h === d ? { ...g, [p]: u } : g)
4720
4716
  });
4721
4717
  }, l = () => {
4722
4718
  r({ srcsets: [...n, {}] });
@@ -4795,9 +4791,9 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4795
4791
  ] });
4796
4792
  }, CollectionFilterSortField = ({ id: o, value: r, onChange: n, onBlur: a }) => {
4797
4793
  const l = useBuilderProp("collections", []), i = useSelectedBlock(), c = get(i, "repeaterItems", "").replace(/\{\{(.*)\}\}/g, "$1").replace(COLLECTION_PREFIX, ""), d = find(l, { id: c }), u = get(d, o === "root.filter" ? "filters" : "sorts", []);
4798
- return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: r, onChange: (m) => n(m.target.value), onBlur: (m) => a(o, m.target.value), children: [
4794
+ return /* @__PURE__ */ jsx("div", { children: /* @__PURE__ */ jsxs("select", { value: r, onChange: (g) => n(g.target.value), onBlur: (g) => a(o, g.target.value), children: [
4799
4795
  /* @__PURE__ */ jsx("option", { value: "", children: "Select" }),
4800
- u.map((m) => /* @__PURE__ */ jsx("option", { value: m.id, children: m.name }, m.id))
4796
+ u.map((g) => /* @__PURE__ */ jsx("option", { value: g.id, children: g.name }, g.id))
4801
4797
  ] }) });
4802
4798
  }, JSONFormFieldTemplate = ({
4803
4799
  id: o,
@@ -4810,12 +4806,12 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4810
4806
  hidden: d,
4811
4807
  required: p,
4812
4808
  schema: u,
4813
- formData: m,
4814
- onChange: g
4809
+ formData: g,
4810
+ onChange: h
4815
4811
  }) => {
4816
- const { selectedLang: h, fallbackLang: f, languages: x } = useLanguages(), y = useMemo(
4817
- () => isEmpty(x) ? "" : isEmpty(h) ? f : h,
4818
- [x, h, f]
4812
+ const { selectedLang: m, fallbackLang: f, languages: x } = useLanguages(), y = useMemo(
4813
+ () => isEmpty(x) ? "" : isEmpty(m) ? f : m,
4814
+ [x, m, f]
4819
4815
  ), b = useMemo(() => get(LANGUAGES, y, y), [y]), v = usePageExternalData(), B = useSelectedBlock(), w = useRegisteredChaiBlocks(), E = useMemo(
4820
4816
  () => get(w, [B == null ? void 0 : B._type, "i18nProps"], []),
4821
4817
  [w, B == null ? void 0 : B._type]
@@ -4838,11 +4834,11 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4838
4834
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
4839
4835
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: n }),
4840
4836
  " ",
4841
- /* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: m == null ? void 0 : m.length }) })
4837
+ /* @__PURE__ */ jsx(Badge, { className: "m-0 bg-gray-200 px-2 leading-tight text-gray-500 hover:bg-gray-200 hover:text-gray-500", children: /* @__PURE__ */ jsx("span", { className: "text-[9px] font-medium text-slate-600", children: g == null ? void 0 : g.length }) })
4842
4838
  ]
4843
4839
  }
4844
4840
  ),
4845
- (m == null ? void 0 : m.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${C ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4841
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${C ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
4846
4842
  c,
4847
4843
  a,
4848
4844
  l,
@@ -4866,10 +4862,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4866
4862
  {
4867
4863
  schema: u,
4868
4864
  onChange: (C) => {
4869
- g(C, m, o);
4865
+ h(C, g, o);
4870
4866
  },
4871
4867
  id: o,
4872
- formData: m
4868
+ formData: g
4873
4869
  }
4874
4870
  ) })
4875
4871
  ] }),
@@ -4878,14 +4874,43 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4878
4874
  l,
4879
4875
  i
4880
4876
  ] });
4877
+ }, RepeaterBindingWidget = ({ value: o, onChange: r }) => {
4878
+ var i;
4879
+ if (!o)
4880
+ return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-2 rounded-md border border-gray-200 bg-gray-50 px-2 py-1.5 text-xs text-gray-500 text-gray-600", children: [
4881
+ /* @__PURE__ */ jsx(File, { className: "h-4 w-4" }),
4882
+ " Choose a collection"
4883
+ ] });
4884
+ const n = `{{${COLLECTION_PREFIX}`, a = o == null ? void 0 : o.startsWith(n);
4885
+ let l = o;
4886
+ return a && (l = (i = o == null ? void 0 : o.replace(n, "")) == null ? void 0 : i.replace("}}", "")), /* @__PURE__ */ jsx("div", { className: "mt-1 flex flex-col gap-1", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-2 rounded-md border border-blue-200 bg-blue-50 px-2 py-1 text-xs text-blue-600", children: [
4887
+ /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2 truncate", children: [
4888
+ " ",
4889
+ a ? /* @__PURE__ */ jsx(Database, { className: "h-4 w-4" }) : null,
4890
+ l
4891
+ ] }),
4892
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
4893
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
4894
+ Button,
4895
+ {
4896
+ variant: "ghost",
4897
+ size: "icon",
4898
+ className: "h-5 w-5 rounded-full bg-gray-200 text-gray-900 hover:bg-gray-300",
4899
+ onClick: () => r(""),
4900
+ children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" })
4901
+ }
4902
+ ) }),
4903
+ /* @__PURE__ */ jsx(TooltipContent, { side: "left", children: "Remove binding" })
4904
+ ] })
4905
+ ] }) });
4881
4906
  }, CustomAddButton = (o) => /* @__PURE__ */ jsx("button", { ...o, className: "duration absolute right-2 top-2 cursor-pointer text-blue-400 hover:text-blue-500", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-0.5 text-[11px] leading-tight", children: [
4882
4907
  /* @__PURE__ */ jsx(Plus, { className: "h-3 w-3" }),
4883
4908
  " ",
4884
4909
  /* @__PURE__ */ jsx("span", { children: "Add" })
4885
4910
  ] }) }), JSONForm = memo(({ blockId: o, schema: r, uiSchema: n, formData: a, onChange: l }) => {
4886
4911
  const { selectedLang: i } = useLanguages(), c = useBlockSettingComponents("widget"), d = useBlockSettingComponents("field"), p = useBlockSettingComponents("template"), u = useThrottledCallback(
4887
- async ({ formData: m }, g) => {
4888
- l({ formData: m }, g);
4912
+ async ({ formData: g }, h) => {
4913
+ l({ formData: g }, h);
4889
4914
  },
4890
4915
  [l, i],
4891
4916
  400
@@ -4901,6 +4926,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4901
4926
  code: CodeEditor,
4902
4927
  colCount: RowColField,
4903
4928
  collectionSelect: CollectionFilterSortField,
4929
+ repeaterBinding: RepeaterBindingWidget,
4904
4930
  ...c
4905
4931
  },
4906
4932
  fields: {
@@ -4925,10 +4951,10 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4925
4951
  uiSchema: n,
4926
4952
  schema: r,
4927
4953
  formData: a,
4928
- onChange: ({ formData: m }, g) => {
4929
- if (!g || o !== (m == null ? void 0 : m._id)) return;
4930
- const h = take(g.split("."), 2).join(".").replace("root.", "");
4931
- u({ formData: m }, h);
4954
+ onChange: ({ formData: g }, h) => {
4955
+ if (!h || o !== (g == null ? void 0 : g._id)) return;
4956
+ const m = take(h.split("."), 2).join(".").replace("root.", "");
4957
+ u({ formData: g }, m);
4932
4958
  }
4933
4959
  },
4934
4960
  i
@@ -4940,7 +4966,7 @@ const MenuBar = ({ editor: o, onExpand: r }) => {
4940
4966
  }), a;
4941
4967
  };
4942
4968
  function BlockSettings() {
4943
- 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), m = useWrapperBlock(), g = getRegisteredChaiBlock(m == null ? void 0 : m._type), h = formDataWithSelectedLang(m, o, g), f = ({ formData: _ }, S, A) => {
4969
+ 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), f = ({ formData: _ }, S, A) => {
4944
4970
  S && (c == null ? void 0 : c._id) === r._id && a([r._id], { [S]: get(_, S) }, A);
4945
4971
  }, x = useCallback(
4946
4972
  debounce(({ formData: _ }, S, A) => {
@@ -4950,7 +4976,7 @@ function BlockSettings() {
4950
4976
  ), y = ({ formData: _ }, S) => {
4951
4977
  S && (n([r._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4952
4978
  }, b = ({ formData: _ }, S) => {
4953
- S && (n([m._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4979
+ S && (n([g._id], { [S]: get(_, S) }), x({ formData: _ }, S, { [S]: get(c, S) }));
4954
4980
  }, { schema: v, uiSchema: B } = useMemo(() => {
4955
4981
  const _ = r == null ? void 0 : r._type;
4956
4982
  if (!_)
@@ -4966,13 +4992,13 @@ function BlockSettings() {
4966
4992
  return { schema: {}, uiSchema: {} };
4967
4993
  }
4968
4994
  }, [r]), { wrapperSchema: w, wrapperUiSchema: E } = useMemo(() => {
4969
- if (!m || !(m != null && m._type))
4995
+ if (!g || !(g != null && g._type))
4970
4996
  return { wrapperSchema: {}, wrapperUiSchema: {} };
4971
- const _ = m == null ? void 0 : m._type, { schema: S = {}, uiSchema: A = {} } = getBlockFormSchemas(_);
4997
+ const _ = g == null ? void 0 : g._type, { schema: S = {}, uiSchema: A = {} } = getBlockFormSchemas(_);
4972
4998
  return { wrapperSchema: S, wrapperUiSchema: A };
4973
- }, [m]);
4999
+ }, [g]);
4974
5000
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
4975
- !isEmpty(m) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5001
+ !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
4976
5002
  /* @__PURE__ */ jsxs(
4977
5003
  "div",
4978
5004
  {
@@ -4980,12 +5006,12 @@ function BlockSettings() {
4980
5006
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
4981
5007
  children: [
4982
5008
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
4983
- startCase(m._type),
5009
+ startCase(g._type),
4984
5010
  " settings",
4985
5011
  " ",
4986
- m._name && /* @__PURE__ */ jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
5012
+ g._name && /* @__PURE__ */ jsxs("span", { className: "text-[11px] font-light text-slate-400", children: [
4987
5013
  "(",
4988
- m._name,
5014
+ g._name,
4989
5015
  ")"
4990
5016
  ] })
4991
5017
  ]
@@ -4994,9 +5020,9 @@ function BlockSettings() {
4994
5020
  /* @__PURE__ */ jsx("div", { className: p ? "h-auto" : "invisible h-0", children: /* @__PURE__ */ jsx(
4995
5021
  JSONForm,
4996
5022
  {
4997
- blockId: m == null ? void 0 : m._id,
5023
+ blockId: g == null ? void 0 : g._id,
4998
5024
  onChange: b,
4999
- formData: h,
5025
+ formData: m,
5000
5026
  schema: w,
5001
5027
  uiSchema: E
5002
5028
  }
@@ -5186,14 +5212,14 @@ const BlockStylingProps = () => {
5186
5212
  },
5187
5213
  a
5188
5214
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
5189
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: m } = o, [g, h] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [f, x] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, E] = useState(!1);
5215
+ 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]), [f, x] = useState(!1), [y, b] = useState(""), [v, B] = useState(!1), [w, E] = useState(!1);
5190
5216
  useEffect(() => {
5191
5217
  const { value: C, unit: k } = getClassValueAndUnit(i);
5192
5218
  if (k === "") {
5193
- l(C), h(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5219
+ l(C), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
5194
5220
  return;
5195
5221
  }
5196
- h(k), l(k === "class" || isEmpty(C) ? "" : C);
5222
+ m(k), l(k === "class" || isEmpty(C) ? "" : C);
5197
5223
  }, [i, p, u]);
5198
5224
  const _ = useThrottledCallback((C) => c(C), [c], THROTTLE_TIME), S = useThrottledCallback((C) => c(C, !1), [c], THROTTLE_TIME), A = useCallback(
5199
5225
  (C = !1) => {
@@ -5202,7 +5228,7 @@ const BlockStylingProps = () => {
5202
5228
  x(!0);
5203
5229
  return;
5204
5230
  }
5205
- const j = get(k, "unit") !== "" ? get(k, "unit") : g;
5231
+ const j = get(k, "unit") !== "" ? get(k, "unit") : h;
5206
5232
  if (j === "auto" || j === "none") {
5207
5233
  _(`${d}${j}`);
5208
5234
  return;
@@ -5212,7 +5238,7 @@ const BlockStylingProps = () => {
5212
5238
  const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${j === "-" ? "" : j}]`;
5213
5239
  C ? S(I) : _(I);
5214
5240
  },
5215
- [_, S, a, g, d, u]
5241
+ [_, S, a, h, d, u]
5216
5242
  ), N = useCallback(
5217
5243
  (C) => {
5218
5244
  const k = getUserInputValues(`${a}`, u);
@@ -5231,7 +5257,7 @@ const BlockStylingProps = () => {
5231
5257
  },
5232
5258
  [_, a, d, u]
5233
5259
  );
5234
- return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: g === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5260
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
5235
5261
  /* @__PURE__ */ jsx(
5236
5262
  "input",
5237
5263
  {
@@ -5246,10 +5272,10 @@ const BlockStylingProps = () => {
5246
5272
  ] })
5247
5273
  ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
5248
5274
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
5249
- ["none", "auto"].indexOf(g) !== -1 ? null : /* @__PURE__ */ jsx(
5275
+ ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsx(
5250
5276
  "input",
5251
5277
  {
5252
- readOnly: g === "class",
5278
+ readOnly: h === "class",
5253
5279
  onKeyPress: (C) => {
5254
5280
  C.key === "Enter" && A();
5255
5281
  },
@@ -5260,7 +5286,7 @@ const BlockStylingProps = () => {
5260
5286
  const k = parseInt$1(C.target.value);
5261
5287
  let j = isNaN$1(k) ? 0 : k;
5262
5288
  C.keyCode === 38 && (j += 1), C.keyCode === 40 && (j -= 1);
5263
- const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${g === "-" ? "" : g}]`;
5289
+ const T = `${j}`, P = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${h === "-" ? "" : h}]`;
5264
5290
  S(P);
5265
5291
  },
5266
5292
  onKeyUp: (C) => {
@@ -5289,7 +5315,7 @@ const BlockStylingProps = () => {
5289
5315
  onClick: () => n(!r),
5290
5316
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
5291
5317
  children: [
5292
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: g }),
5318
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: h }),
5293
5319
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
5294
5320
  ]
5295
5321
  }
@@ -5298,34 +5324,34 @@ const BlockStylingProps = () => {
5298
5324
  UnitSelection,
5299
5325
  {
5300
5326
  units: u,
5301
- current: g,
5327
+ current: h,
5302
5328
  onSelect: (C) => {
5303
- n(!1), h(C), N(C);
5329
+ n(!1), m(C), N(C);
5304
5330
  }
5305
5331
  }
5306
5332
  ) })
5307
5333
  ] })
5308
5334
  ] }),
5309
- ["none", "auto"].indexOf(g) !== -1 || v ? null : /* @__PURE__ */ jsx(
5335
+ ["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsx(
5310
5336
  DragStyleButton,
5311
5337
  {
5312
5338
  onDragStart: () => B(!0),
5313
5339
  onDragEnd: (C) => {
5314
5340
  if (b(() => ""), B(!1), isEmpty(C))
5315
5341
  return;
5316
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${g === "-" ? "" : g}]`;
5342
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5317
5343
  _(T);
5318
5344
  },
5319
5345
  onDrag: (C) => {
5320
5346
  if (isEmpty(C))
5321
5347
  return;
5322
5348
  b(C);
5323
- const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${g === "-" ? "" : g}]`;
5349
+ const k = `${C}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${h === "-" ? "" : h}]`;
5324
5350
  S(T);
5325
5351
  },
5326
5352
  currentValue: a,
5327
- unit: g,
5328
- negative: m,
5353
+ unit: h,
5354
+ negative: g,
5329
5355
  cssProperty: p
5330
5356
  }
5331
5357
  )
@@ -5384,7 +5410,7 @@ const COLOR_PROP = {
5384
5410
  ringColor: "ring",
5385
5411
  ringOffsetColor: "ring-offset"
5386
5412
  }, ColorChoice = ({ property: o, onChange: r }) => {
5387
- 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("-"), m = get(u, "1", ""), g = get(u, "2", ""), h = useCallback(
5413
+ 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(
5388
5414
  // eslint-disable-next-line no-shadow
5389
5415
  (y) => {
5390
5416
  ["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" })));
@@ -5392,16 +5418,16 @@ const COLOR_PROP = {
5392
5418
  [c, p]
5393
5419
  );
5394
5420
  useEffect(() => {
5395
- if (["current", "inherit", "transparent", "black", "white"].includes(m))
5421
+ if (["current", "inherit", "transparent", "black", "white"].includes(g))
5396
5422
  return c([]);
5397
5423
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5398
- }, [m]);
5424
+ }, [g]);
5399
5425
  const f = useCallback(
5400
5426
  // eslint-disable-next-line no-shadow
5401
5427
  (y) => {
5402
- p({ color: m, shade: y });
5428
+ p({ color: g, shade: y });
5403
5429
  },
5404
- [m]
5430
+ [g]
5405
5431
  );
5406
5432
  useEffect(() => {
5407
5433
  p({ color: "", shade: "" });
@@ -5416,8 +5442,8 @@ const COLOR_PROP = {
5416
5442
  {
5417
5443
  disabled: !l,
5418
5444
  rounded: !0,
5419
- selected: m,
5420
- onChange: h,
5445
+ selected: g,
5446
+ onChange: m,
5421
5447
  options: [
5422
5448
  "current",
5423
5449
  "transparent",
@@ -5450,7 +5476,7 @@ const COLOR_PROP = {
5450
5476
  ]
5451
5477
  }
5452
5478
  ) }),
5453
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: g, disabled: !m || !l, onChange: f, options: i }) })
5479
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: h, disabled: !g || !l, onChange: f, options: i }) })
5454
5480
  ] });
5455
5481
  }, EDITOR_ICONS = {
5456
5482
  "not-italic": () => /* @__PURE__ */ jsx("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ jsx("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M9 3H11V5H9V11H11V13H5V11H7V5H5V3H9Z", fill: "white" }) }),
@@ -5784,20 +5810,20 @@ const COLOR_PROP = {
5784
5810
  "2xl": "1536px"
5785
5811
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
5786
5812
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
5787
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, m] = useScreenSizeWidth(), g = useCurrentClassByProperty(l), h = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(g, "fullCls", ""), [g]), b = useCallback(
5813
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), f = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), y = useMemo(() => get(h, "fullCls", ""), [h]), b = useCallback(
5788
5814
  (S, A = !0) => {
5789
- const N = { dark: p, mq: m, mod: u, cls: S, property: l, fullCls: "" };
5815
+ const N = { dark: p, mq: g, mod: u, cls: S, property: l, fullCls: "" };
5790
5816
  (p || u !== "") && (N.mq = "xs");
5791
5817
  const C = generateFullClsName(N);
5792
- h(x, [C], A);
5818
+ m(x, [C], A);
5793
5819
  },
5794
- [x, p, m, u, l, h]
5820
+ [x, p, g, u, l, m]
5795
5821
  ), v = useCallback(() => {
5796
5822
  f(x, [y], !0);
5797
- }, [x, y, f]), B = useMemo(() => canChangeClass(g, m), [g, m]);
5823
+ }, [x, y, f]), B = useMemo(() => canChangeClass(h, g), [h, g]);
5798
5824
  useEffect(() => {
5799
- i(B, g);
5800
- }, [B, i, g]);
5825
+ i(B, h);
5826
+ }, [B, i, h]);
5801
5827
  const [, , w] = useScreenSizeWidth(), E = useCallback(
5802
5828
  (S) => {
5803
5829
  w({
@@ -5810,15 +5836,15 @@ const COLOR_PROP = {
5810
5836
  }[S]);
5811
5837
  },
5812
5838
  [w]
5813
- ), _ = get(g, "dark", null) === p && get(g, "mod", null) === u && get(g, "mq", null) === m;
5814
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: g && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5815
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${g && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
5839
+ ), _ = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === g;
5840
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: B, canReset: h && _, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
5841
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${h && !_ ? "text-foreground" : ""}`, children: r(a) }) }),
5816
5842
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
5817
5843
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
5818
5844
  n === "arbitrary" ? /* @__PURE__ */ jsx(
5819
5845
  AdvanceChoices,
5820
5846
  {
5821
- currentClass: get(g, "cls", ""),
5847
+ currentClass: get(h, "cls", ""),
5822
5848
  classPrefix: get(CLASS_PREFIXES, l, ""),
5823
5849
  units: c || [],
5824
5850
  onChange: b,
@@ -5831,7 +5857,7 @@ const COLOR_PROP = {
5831
5857
  n === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: b }),
5832
5858
  n === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: b })
5833
5859
  ] }),
5834
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && g ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5860
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${y ? "visible" : "invisible"}`, children: _ ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
5835
5861
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5836
5862
  "button",
5837
5863
  {
@@ -5843,19 +5869,19 @@ const COLOR_PROP = {
5843
5869
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
5844
5870
  "Current style is set at  ",
5845
5871
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
5846
- getBreakpoint(get(g, "mq")),
5847
- p && !g.dark ? "(Light mode)" : ""
5872
+ getBreakpoint(get(h, "mq")),
5873
+ p && !h.dark ? "(Light mode)" : ""
5848
5874
  ] }),
5849
5875
  /* @__PURE__ */ jsx("br", {}),
5850
5876
  /* @__PURE__ */ jsxs(
5851
5877
  "button",
5852
5878
  {
5853
5879
  type: "button",
5854
- onClick: () => E(get(g, "mq")),
5880
+ onClick: () => E(get(h, "mq")),
5855
5881
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
5856
5882
  children: [
5857
5883
  "Switch to ",
5858
- get(g, "mq").toUpperCase()
5884
+ get(h, "mq").toUpperCase()
5859
5885
  ]
5860
5886
  }
5861
5887
  )
@@ -5872,7 +5898,7 @@ const COLOR_PROP = {
5872
5898
  units: i = basicUnits,
5873
5899
  negative: c = !1
5874
5900
  }) => {
5875
- const { t: d } = useTranslation(), [p, u] = useState(r[0].key), m = useSelectedBlockCurrentClasses(), g = useCallback((h) => map(m, "property").includes(h), [m]);
5901
+ const { t: d } = useTranslation(), [p, u] = useState(r[0].key), g = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(g, "property").includes(m), [g]);
5876
5902
  return /* @__PURE__ */ jsxs(
5877
5903
  "div",
5878
5904
  {
@@ -5880,7 +5906,7 @@ const COLOR_PROP = {
5880
5906
  children: [
5881
5907
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
5882
5908
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
5883
- /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: h, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5909
+ /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: r.map(({ label: m, key: f }, x) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
5884
5910
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
5885
5911
  "button",
5886
5912
  {
@@ -5889,13 +5915,13 @@ const COLOR_PROP = {
5889
5915
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${f === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
5890
5916
  children: [
5891
5917
  React__default.createElement("div", {
5892
- className: g(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
5918
+ className: h(f) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
5893
5919
  }),
5894
5920
  React__default.createElement(get(EDITOR_ICONS, f, BoxIcon), { className: "text-inherit w-3 h-3" })
5895
5921
  ]
5896
5922
  }
5897
5923
  ) }),
5898
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(h)) })
5924
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
5899
5925
  ] }) }, `option-${x}`)) })
5900
5926
  ] }),
5901
5927
  /* @__PURE__ */ jsx("div", { className: "mt-0 flex items-center", children: /* @__PURE__ */ jsx(
@@ -6020,7 +6046,7 @@ const COLOR_PROP = {
6020
6046
  icon: p,
6021
6047
  onClick: u
6022
6048
  }) => {
6023
- const { t: m } = useTranslation();
6049
+ const { t: g } = useTranslation();
6024
6050
  return n ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: r, children: [
6025
6051
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6026
6052
  Button,
@@ -6033,8 +6059,8 @@ const COLOR_PROP = {
6033
6059
  }
6034
6060
  ) }),
6035
6061
  /* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
6036
- /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: m(a) }),
6037
- o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: m(l) })
6062
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: g(a) }),
6063
+ o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: g(l) })
6038
6064
  ] }) }) })
6039
6065
  ] }) : /* @__PURE__ */ jsx(
6040
6066
  Button,
@@ -6051,12 +6077,12 @@ const COLOR_PROP = {
6051
6077
  canvas: r = !1,
6052
6078
  tooltip: n = !0
6053
6079
  }) => {
6054
- const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, m = p, { t: g } = useTranslation(), h = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
6055
- u.includes(b) ? u.length > 2 && m(u.filter((v) => v !== b)) : m((v) => [...v, b]);
6080
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: h } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (b) => {
6081
+ u.includes(b) ? u.length > 2 && g(u.filter((v) => v !== b)) : g((v) => [...v, b]);
6056
6082
  }, x = (b) => {
6057
6083
  r || l(b), c(b);
6058
6084
  }, y = getBreakpointValue(r ? i : a).toLowerCase();
6059
- return h.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(h, (b) => /* @__PURE__ */ createElement(
6085
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (b) => /* @__PURE__ */ createElement(
6060
6086
  BreakpointCard,
6061
6087
  {
6062
6088
  canvas: r,
@@ -6067,7 +6093,7 @@ const COLOR_PROP = {
6067
6093
  }
6068
6094
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
6069
6095
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
6070
- h.filter((b) => includes(u, toUpper(b.breakpoint))),
6096
+ m.filter((b) => includes(u, toUpper(b.breakpoint))),
6071
6097
  (b) => /* @__PURE__ */ createElement(
6072
6098
  BreakpointCard,
6073
6099
  {
@@ -6084,15 +6110,15 @@ const COLOR_PROP = {
6084
6110
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
6085
6111
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
6086
6112
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
6087
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
6113
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: h("Screen sizes") }),
6088
6114
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
6089
- map(h, (b) => /* @__PURE__ */ jsx(
6115
+ map(m, (b) => /* @__PURE__ */ jsx(
6090
6116
  DropdownMenuCheckboxItem,
6091
6117
  {
6092
6118
  disabled: b.breakpoint === "xs",
6093
6119
  onCheckedChange: () => f(toUpper(b.breakpoint)),
6094
6120
  checked: includes(u, toUpper(b.breakpoint)),
6095
- children: g(b.title)
6121
+ children: h(b.title)
6096
6122
  },
6097
6123
  b.breakpoint
6098
6124
  ))
@@ -6169,14 +6195,14 @@ function Countdown() {
6169
6195
  ] });
6170
6196
  }
6171
6197
  const AskAIStyles = ({ blockId: o }) => {
6172
- const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, m] = useState();
6198
+ const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
6173
6199
  useEffect(() => {
6174
- var h;
6175
- (h = d.current) == null || h.focus();
6200
+ var m;
6201
+ (m = d.current) == null || m.focus();
6176
6202
  }, []);
6177
- const g = (h) => {
6178
- const { usage: f } = h || {};
6179
- !l && f && m(f), p.current = setTimeout(() => m(void 0), 1e4), l || c("");
6203
+ const h = (m) => {
6204
+ const { usage: f } = m || {};
6205
+ !l && f && g(f), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
6180
6206
  };
6181
6207
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
6182
6208
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
@@ -6185,12 +6211,12 @@ const AskAIStyles = ({ blockId: o }) => {
6185
6211
  {
6186
6212
  ref: d,
6187
6213
  value: i,
6188
- onChange: (h) => c(h.target.value),
6214
+ onChange: (m) => c(m.target.value),
6189
6215
  placeholder: r("Ask AI to edit styles"),
6190
6216
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
6191
6217
  rows: 4,
6192
- onKeyDown: (h) => {
6193
- h.key === "Enter" && (h.preventDefault(), p.current && clearTimeout(p.current), m(void 0), n("styles", o, i, g));
6218
+ onKeyDown: (m) => {
6219
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, h));
6194
6220
  }
6195
6221
  }
6196
6222
  ),
@@ -6200,7 +6226,7 @@ const AskAIStyles = ({ blockId: o }) => {
6200
6226
  {
6201
6227
  disabled: i.trim().length < 5 || a,
6202
6228
  onClick: () => {
6203
- p.current && clearTimeout(p.current), m(void 0), n("styles", o, i, g);
6229
+ p.current && clearTimeout(p.current), g(void 0), n("styles", o, i, h);
6204
6230
  },
6205
6231
  variant: "default",
6206
6232
  className: "w-fit",
@@ -6232,9 +6258,9 @@ const AskAIStyles = ({ blockId: o }) => {
6232
6258
  };
6233
6259
  function ManualClasses() {
6234
6260
  var T;
6235
- const o = useRef(null), [r, n] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), m = useRemoveClassesFromBlocks(), [g] = useSelectedBlockIds(), h = useBuilderProp("askAiCallBack", null), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), B = () => {
6261
+ 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), [f, x] = useState(""), y = (T = first(d)) == null ? void 0 : T.prop, { classes: b } = getSplitChaiClasses(get(p, y, "")), v = b.split(" ").filter((I) => !isEmpty(I)), B = () => {
6236
6262
  const I = f.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6237
- u(g, I, !0), x("");
6263
+ u(h, I, !0), x("");
6238
6264
  }, [w, E] = useState([]), _ = ({ value: I }) => {
6239
6265
  const P = I.trim().toLowerCase(), L = P.match(/.+:/g);
6240
6266
  let D = [];
@@ -6273,7 +6299,7 @@ function ManualClasses() {
6273
6299
  ), k = (I) => {
6274
6300
  debugger;
6275
6301
  const P = r.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
6276
- m(g, [I]), u(g, P, !0), n(""), l(-1);
6302
+ g(h, [I]), u(h, P, !0), n(""), l(-1);
6277
6303
  }, j = () => {
6278
6304
  if (navigator.clipboard === void 0) {
6279
6305
  toast.error(c("Clipboard not supported"));
@@ -6290,7 +6316,7 @@ function ManualClasses() {
6290
6316
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
6291
6317
  ] })
6292
6318
  ] }),
6293
- h ? /* @__PURE__ */ jsxs(Popover, { children: [
6319
+ m ? /* @__PURE__ */ jsxs(Popover, { children: [
6294
6320
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
6295
6321
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
6296
6322
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -6355,7 +6381,7 @@ function ManualClasses() {
6355
6381
  "button",
6356
6382
  {
6357
6383
  onDoubleClick: () => {
6358
- x(I), m(g, [I]), setTimeout(() => {
6384
+ x(I), g(h, [I]), setTimeout(() => {
6359
6385
  o.current && o.current.focus();
6360
6386
  }, 10);
6361
6387
  },
@@ -6365,7 +6391,7 @@ function ManualClasses() {
6365
6391
  r !== I && /* @__PURE__ */ jsx(
6366
6392
  Cross2Icon,
6367
6393
  {
6368
- onClick: () => m(g, [I], !0),
6394
+ onClick: () => g(h, [I], !0),
6369
6395
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
6370
6396
  }
6371
6397
  )
@@ -6485,13 +6511,13 @@ function BlockStyling() {
6485
6511
  cssProperty: ""
6486
6512
  }), d = useThrottledCallback(
6487
6513
  (u) => {
6488
- const m = !get(i, "negative", !1), g = get(i, "cssProperty", "");
6489
- let h = parseFloat(i.dragStartValue);
6490
- h = isNaN(h) ? 0 : h;
6514
+ const g = !get(i, "negative", !1), h = get(i, "cssProperty", "");
6515
+ let m = parseFloat(i.dragStartValue);
6516
+ m = isNaN(m) ? 0 : m;
6491
6517
  let f = MAPPER[i.dragUnit];
6492
- (startsWith(g, "scale") || g === "opacity") && (f = 10);
6493
- let y = (i.dragStartY - u.pageY) / f + h;
6494
- m && y < 0 && (y = 0), g === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6518
+ (startsWith(h, "scale") || h === "opacity") && (f = 10);
6519
+ let y = (i.dragStartY - u.pageY) / f + m;
6520
+ g && y < 0 && (y = 0), h === "opacity" && y > 1 && (y = 1), i.onDrag(`${y}`), l(`${y}`);
6495
6521
  },
6496
6522
  [i],
6497
6523
  50
@@ -6532,7 +6558,7 @@ const CoreBlock = ({
6532
6558
  parentId: n,
6533
6559
  position: a
6534
6560
  }) => {
6535
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, m] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = () => {
6561
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
6536
6562
  if (has(o, "blocks")) {
6537
6563
  const y = isFunction(o.blocks) ? o.blocks() : o.blocks;
6538
6564
  u(syncBlocksWithDefaults(y), n || null, a);
@@ -6545,11 +6571,11 @@ const CoreBlock = ({
6545
6571
  "button",
6546
6572
  {
6547
6573
  disabled: r,
6548
- onClick: h,
6574
+ onClick: m,
6549
6575
  type: "button",
6550
6576
  onDragStart: (y) => {
6551
6577
  y.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), y.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6552
- m([]), g();
6578
+ g([]), h();
6553
6579
  }, 200);
6554
6580
  },
6555
6581
  draggable: f ? "true" : "false",
@@ -6748,7 +6774,7 @@ const CoreBlock = ({
6748
6774
  }
6749
6775
  }
6750
6776
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
6751
- var g, h, f, x, y, b, v, B;
6777
+ var h, m, f, x, y, b, v, B;
6752
6778
  if (n.type === "comment") return [];
6753
6779
  console.log("node ===>", n);
6754
6780
  let a = { _id: generateUUID() };
@@ -6789,8 +6815,8 @@ const CoreBlock = ({
6789
6815
  ];
6790
6816
  a = {
6791
6817
  ...a,
6792
- href: ((g = l.find((E) => E.key === "href")) == null ? void 0 : g.value) || "",
6793
- hrefType: ((h = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : h.value) || "video",
6818
+ href: ((h = l.find((E) => E.key === "href")) == null ? void 0 : h.value) || "",
6819
+ hrefType: ((m = l.find((E) => E.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
6794
6820
  autoplay: ((f = l.find((E) => E.key === "data-autoplay")) == null ? void 0 : f.value) === "true" ? "true" : "false",
6795
6821
  maxWidth: ((y = (x = l.find((E) => E.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : y.replace("px", "")) || "",
6796
6822
  backdropColor: ((b = l.find((E) => E.key === "data-overlay")) == null ? void 0 : b.value) || "",
@@ -6831,8 +6857,8 @@ const CoreBlock = ({
6831
6857
  label: getTextContent(n.children),
6832
6858
  ...getAttrs(n)
6833
6859
  }), [];
6834
- const m = traverseNodes(n.children, { block: a, node: n });
6835
- return [a, ...m];
6860
+ const g = traverseNodes(n.children, { block: a, node: n });
6861
+ return [a, ...g];
6836
6862
  }), getSvgDimensions = (o, r, n) => {
6837
6863
  const a = get(o, "attributes", []), l = find(a, { key: "height" }), i = find(a, { key: "width" });
6838
6864
  return {
@@ -6883,8 +6909,8 @@ const CoreBlock = ({
6883
6909
  height: i = ""
6884
6910
  }) => {
6885
6911
  const [c, d] = useState(o), p = (u) => {
6886
- const m = u.target.value;
6887
- d(m), r(m);
6912
+ const g = u.target.value;
6913
+ d(g), r(g);
6888
6914
  };
6889
6915
  return /* @__PURE__ */ jsx("div", { className: cn$2("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
6890
6916
  "select",
@@ -6930,7 +6956,7 @@ const BlockCard = ({
6930
6956
  parentId: n = void 0,
6931
6957
  position: a = -1
6932
6958
  }) => {
6933
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), g = get(o, "name", get(o, "label")), h = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (B) => {
6959
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = get(o, "description", ""), f = useFeature("dnd"), [, x] = useAtom$1(draggedBlockAtom), y = (B) => {
6934
6960
  const w = has(B, "styles_attrs.data-page-section");
6935
6961
  return B._type === "Box" && w;
6936
6962
  }, b = useCallback(
@@ -6965,7 +6991,7 @@ const BlockCard = ({
6965
6991
  } else
6966
6992
  B.dataTransfer.setDragImage(new Image(), 0, 0);
6967
6993
  x(_), setTimeout(() => {
6968
- u([]), m(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6994
+ u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6969
6995
  }, 200);
6970
6996
  }
6971
6997
  },
@@ -6977,20 +7003,20 @@ const BlockCard = ({
6977
7003
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
6978
7004
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
6979
7005
  ] }),
6980
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: g }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
6981
- /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: g }),
6982
- h && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: h })
7006
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: h }) : /* @__PURE__ */ jsxs("div", { className: "flex h-fit w-full flex-col items-center justify-center gap-1 rounded-md border border-border p-6 py-10 text-center", children: [
7007
+ /* @__PURE__ */ jsx("p", { className: "font-medium text-gray-800", children: h }),
7008
+ m && /* @__PURE__ */ jsx("p", { className: "text-sm text-gray-600", children: m })
6983
7009
  ] })
6984
7010
  ]
6985
7011
  }
6986
7012
  ) }),
6987
7013
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsxs("div", { className: "max-w-xs", children: [
6988
- /* @__PURE__ */ jsx("p", { className: "font-medium", children: g }),
6989
- h && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: h })
7014
+ /* @__PURE__ */ jsx("p", { className: "font-medium", children: h }),
7015
+ m && o.preview && /* @__PURE__ */ jsx("p", { className: "mt-1 text-xs text-primary-foreground", children: m })
6990
7016
  ] }) })
6991
7017
  ] });
6992
7018
  }, UILibrarySection = ({ parentId: o, position: r }) => {
6993
- const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, m] = useState(""), [g, h] = useState([]), f = useRef(null);
7019
+ const [n, a] = useSelectedLibrary(), l = useBuilderProp("uiLibraries", []), i = l.find((k) => k.id === n) || first(l), { data: c, isLoading: d, resetLibrary: p } = useLibraryBlocks(i), [u, g] = useState(""), [h, m] = useState([]), f = useRef(null);
6994
7020
  useEffect(() => {
6995
7021
  c && c.length > 0 && (f.current = new Fuse(c, {
6996
7022
  keys: ["name", "label", "description", "group"],
@@ -6999,13 +7025,13 @@ const BlockCard = ({
6999
7025
  }));
7000
7026
  }, [c]), useEffect(() => {
7001
7027
  if (!u.trim() || !f.current) {
7002
- h([]);
7028
+ m([]);
7003
7029
  return;
7004
7030
  }
7005
7031
  const k = f.current.search(u).map((j) => j.item);
7006
- h(k);
7032
+ m(k);
7007
7033
  }, [u]);
7008
- const x = u.trim() && !isEmpty(g) ? g : c, y = groupBy(x, "group"), [b, v] = useState(null);
7034
+ const x = u.trim() && !isEmpty(h) ? h : c, y = groupBy(x, "group"), [b, v] = useState(null);
7009
7035
  useEffect(() => {
7010
7036
  if (isEmpty(keys(y))) {
7011
7037
  v(null);
@@ -7023,7 +7049,7 @@ const BlockCard = ({
7023
7049
  }, S = () => {
7024
7050
  i != null && i.id && p(i.id);
7025
7051
  }, A = () => {
7026
- m("");
7052
+ g("");
7027
7053
  };
7028
7054
  if (d)
7029
7055
  return /* @__PURE__ */ jsxs("div", { className: "mt-4 grid h-full w-full grid-cols-12 gap-2", children: [
@@ -7039,7 +7065,7 @@ const BlockCard = ({
7039
7065
  {
7040
7066
  placeholder: E("Search blocks..."),
7041
7067
  value: u,
7042
- onChange: (k) => m(k.target.value),
7068
+ onChange: (k) => g(k.target.value),
7043
7069
  className: "w-full pl-8 pr-8"
7044
7070
  }
7045
7071
  ),
@@ -7134,7 +7160,7 @@ const BlockCard = ({
7134
7160
  position: r,
7135
7161
  gridCols: n = "grid-cols-2"
7136
7162
  }) => {
7137
- const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, m] = useAtom$1(hasInitializedPartialBlocksAtom);
7163
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7138
7164
  useEffect(() => {
7139
7165
  if (!u || Object.keys(d.blocks).length === 0)
7140
7166
  if (c)
@@ -7143,9 +7169,9 @@ const BlockCard = ({
7143
7169
  groups: [],
7144
7170
  isLoading: !1,
7145
7171
  error: c
7146
- }), m(!0);
7172
+ }), g(!0);
7147
7173
  else if (!l && Object.keys(a || {}).length > 0) {
7148
- const h = Object.entries(a).map(([x, y]) => {
7174
+ const m = Object.entries(a).map(([x, y]) => {
7149
7175
  const b = y, v = b.type || "partial", B = formatReadableName(v);
7150
7176
  return {
7151
7177
  type: "PartialBlock",
@@ -7160,37 +7186,37 @@ const BlockCard = ({
7160
7186
  // Store the original ID as partialBlockId
7161
7187
  _name: b.name
7162
7188
  };
7163
- }), f = uniq(map(h, "group"));
7189
+ }), f = uniq(map(m, "group"));
7164
7190
  p({
7165
- blocks: h,
7191
+ blocks: m,
7166
7192
  groups: f,
7167
7193
  isLoading: !1,
7168
7194
  error: null
7169
- }), m(!0);
7170
- } else l ? p((h) => ({ ...h, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7195
+ }), g(!0);
7196
+ } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7171
7197
  blocks: [],
7172
7198
  groups: [],
7173
7199
  isLoading: !1,
7174
7200
  error: "No partial blocks available"
7175
- }), m(!0));
7201
+ }), g(!0));
7176
7202
  }, [
7177
7203
  l,
7178
7204
  a,
7179
7205
  u,
7180
- m,
7206
+ g,
7181
7207
  p,
7182
7208
  d.blocks,
7183
7209
  c
7184
7210
  ]);
7185
- const g = () => {
7186
- p((h) => ({ ...h, isLoading: !0, error: null })), m(!1), i();
7211
+ const h = () => {
7212
+ p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7187
7213
  };
7188
7214
  return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7189
7215
  /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7190
7216
  /* @__PURE__ */ jsx(
7191
7217
  "button",
7192
7218
  {
7193
- onClick: g,
7219
+ onClick: h,
7194
7220
  className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7195
7221
  children: "Refresh"
7196
7222
  }
@@ -7209,14 +7235,14 @@ const BlockCard = ({
7209
7235
  has(ADD_BLOCK_TABS, o) && console.warn(`Add block tab with id ${o} already registered`), set(ADD_BLOCK_TABS, o, { id: o, ...r });
7210
7236
  }, 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" }) => {
7211
7237
  var C;
7212
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [m] = useAtom$1(addBlockTabAtom), g = (C = find(c, (k) => k._id === n)) == null ? void 0 : C._type, [h, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
7238
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), h = (C = find(c, (k) => k._id === n)) == null ? void 0 : C._type, [m, f] = useState("all"), [x, y] = useState(null), b = useRef(null);
7213
7239
  useEffect(() => {
7214
7240
  const k = setTimeout(() => {
7215
7241
  var j;
7216
7242
  (j = u.current) == null || j.focus();
7217
7243
  }, 0);
7218
7244
  return () => clearTimeout(k);
7219
- }, [m]), useEffect(() => {
7245
+ }, [g]), useEffect(() => {
7220
7246
  d && (f("all"), y(null));
7221
7247
  }, [d]), useEffect(() => (b.current = debounce((k) => {
7222
7248
  f(k);
@@ -7245,7 +7271,7 @@ const BlockCard = ({
7245
7271
  ), S = useMemo(
7246
7272
  () => sortBy(_, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7247
7273
  [_]
7248
- ), A = useMemo(() => h === "all" ? E : filter(values(E), { group: h }), [E, h]), N = useMemo(() => h === "all" ? S : [h], [S, h]);
7274
+ ), A = useMemo(() => m === "all" ? E : filter(values(E), { group: m }), [E, m]), N = useMemo(() => m === "all" ? S : [m], [S, m]);
7249
7275
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7250
7276
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7251
7277
  Input$1,
@@ -7266,7 +7292,7 @@ const BlockCard = ({
7266
7292
  onClick: () => w("all"),
7267
7293
  onMouseEnter: () => v("all"),
7268
7294
  onMouseLeave: B,
7269
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${h === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7295
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7270
7296
  children: i("All")
7271
7297
  },
7272
7298
  "sidebar-all"
@@ -7277,7 +7303,7 @@ const BlockCard = ({
7277
7303
  onClick: () => w(k),
7278
7304
  onMouseEnter: () => v(k),
7279
7305
  onMouseLeave: B,
7280
- className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${h === k || x === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7306
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-primary text-primary-foreground" : "hover:bg-primary/50 hover:text-primary-foreground"}`,
7281
7307
  children: capitalize(i(k.toLowerCase()))
7282
7308
  },
7283
7309
  `sidebar-${k}`
@@ -7291,7 +7317,7 @@ const BlockCard = ({
7291
7317
  ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: N.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7292
7318
  /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7293
7319
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: reject(
7294
- h === "all" ? filter(values(A), { group: k }) : values(A),
7320
+ m === "all" ? filter(values(A), { group: k }) : values(A),
7295
7321
  { hidden: !0 }
7296
7322
  ).map((j) => /* @__PURE__ */ jsx(
7297
7323
  CoreBlock,
@@ -7299,7 +7325,7 @@ const BlockCard = ({
7299
7325
  parentId: n,
7300
7326
  position: a,
7301
7327
  block: j,
7302
- disabled: !canAcceptChildBlock(g, j.type) || !canBeNestedInside(g, j.type)
7328
+ disabled: !canAcceptChildBlock(h, j.type) || !canBeNestedInside(h, j.type)
7303
7329
  },
7304
7330
  j.type
7305
7331
  )) })
@@ -7312,13 +7338,13 @@ const BlockCard = ({
7312
7338
  parentId: n = void 0,
7313
7339
  position: a = -1
7314
7340
  }) => {
7315
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), m = Object.keys(u || {}).length > 0, { hasPermission: g } = usePermissions();
7341
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), { data: u } = usePartialBlocksList(), g = Object.keys(u || {}).length > 0, { hasPermission: h } = usePermissions();
7316
7342
  useEffect(() => {
7317
- i === "partials" && !m && c("library");
7318
- }, [i, m, c]);
7319
- const h = useCallback(() => {
7343
+ i === "partials" && !g && c("library");
7344
+ }, [i, g, c]);
7345
+ const m = useCallback(() => {
7320
7346
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7321
- }, []), f = useChaiAddBlockTabs(), x = p && g(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
7347
+ }, []), f = useChaiAddBlockTabs(), x = p && h(PERMISSIONS.IMPORT_HTML), b = useBuilderProp("uiLibraries", []).length > 0;
7322
7348
  return useEffect(() => {
7323
7349
  i === "library" && !b && c("core");
7324
7350
  }, [i, b, c]), /* @__PURE__ */ jsxs("div", { className: cn$2("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7338,15 +7364,15 @@ const BlockCard = ({
7338
7364
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7339
7365
  b && /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7340
7366
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7341
- m && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7367
+ g && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7342
7368
  x ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7343
7369
  map(f, (v) => /* @__PURE__ */ jsx(TabsTrigger, { value: v.id, children: React__default.createElement(v.tab) }, `tab-add-block-${v.id}`))
7344
7370
  ] }),
7345
7371
  /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
7346
7372
  b && /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: n, position: a }) }),
7347
- m && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
7373
+ g && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
7348
7374
  x ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: n, position: a }) }) : null,
7349
- map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: h, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
7375
+ map(f, (v) => /* @__PURE__ */ jsx(TabsContent, { value: v.id, children: React__default.createElement(v.tabContent, { close: m, parentId: n, position: a }) }, `panel-add-block-${v.id}`))
7350
7376
  ]
7351
7377
  }
7352
7378
  )
@@ -7468,10 +7494,10 @@ const registerChaiSaveToLibrary = (o) => {
7468
7494
  }, CANNOT_COPY_BLOCKS = !navigator.clipboard, CopyPasteBlocks = () => {
7469
7495
  const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a, l] = useCopyBlocks(), { t: i } = useTranslation(), c = useSelectedBlock(), d = useCallback(() => {
7470
7496
  const p = r.map((u) => {
7471
- const m = o.find((g) => g._id === u);
7497
+ const g = o.find((h) => h._id === u);
7472
7498
  return {
7473
7499
  id: u,
7474
- data: m
7500
+ data: g
7475
7501
  };
7476
7502
  });
7477
7503
  l(p.map((u) => u.id)) ? toast.warning("Partial blocks detected. Clone partial blocks?", {
@@ -7653,8 +7679,8 @@ const Input = ({ node: o }) => {
7653
7679
  var P;
7654
7680
  const { t: a } = useTranslation(), [l, , i] = useHiddenBlockIds(), [c] = useAtom$1(canvasIframeAtom), { hasPermission: d } = usePermissions();
7655
7681
  let p = null;
7656
- const u = o.children.length > 0, { highlightBlock: m, clearHighlight: g } = useBlockHighlight(), { id: h, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (L) => {
7657
- L.stopPropagation(), !l.includes(h) && o.toggle();
7682
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: h } = useBlockHighlight(), { id: m, data: f, isSelected: x, willReceiveDrop: y, isDragging: b, isEditing: v, handleClick: B } = o, w = (L) => {
7683
+ L.stopPropagation(), !l.includes(m) && o.toggle();
7658
7684
  }, E = (L) => {
7659
7685
  L.isInternal && (p = L.isOpen, L.isOpen && L.close());
7660
7686
  }, _ = (L) => {
@@ -7665,11 +7691,11 @@ const Input = ({ node: o }) => {
7665
7691
  }, C = () => {
7666
7692
  A(null);
7667
7693
  }, k = (L) => {
7668
- C(), L.stopPropagation(), !o.isOpen && !l.includes(h) && o.toggle(), B(L);
7694
+ C(), L.stopPropagation(), !o.isOpen && !l.includes(m) && o.toggle(), B(L);
7669
7695
  };
7670
7696
  useEffect(() => {
7671
7697
  const L = setTimeout(() => {
7672
- y && !o.isOpen && !b && !l.includes(h) && o.toggle();
7698
+ y && !o.isOpen && !b && !l.includes(m) && o.toggle();
7673
7699
  }, 500);
7674
7700
  return () => clearTimeout(L);
7675
7701
  }, [y, o, b]);
@@ -7683,7 +7709,7 @@ const Input = ({ node: o }) => {
7683
7709
  const D = get(o, "parent.id");
7684
7710
  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 });
7685
7711
  };
7686
- if (h === ROOT_TEMP_KEY)
7712
+ if (m === ROOT_TEMP_KEY)
7687
7713
  return /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7688
7714
  /* @__PURE__ */ jsx("br", {}),
7689
7715
  d(PERMISSIONS.ADD_BLOCK) && /* @__PURE__ */ jsx(
@@ -7705,22 +7731,22 @@ const Input = ({ node: o }) => {
7705
7731
  return /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7706
7732
  "div",
7707
7733
  {
7708
- onMouseEnter: () => m(h),
7709
- onMouseLeave: () => g(),
7734
+ onMouseEnter: () => g(m),
7735
+ onMouseLeave: () => h(),
7710
7736
  onClick: k,
7711
7737
  style: r,
7712
- "data-node-id": h,
7713
- ref: l.includes(h) ? null : n,
7738
+ "data-node-id": m,
7739
+ ref: l.includes(m) ? null : n,
7714
7740
  onDragStart: () => E(o),
7715
7741
  onDragEnd: () => _(o),
7716
7742
  onDragOver: (L) => {
7717
- L.preventDefault(), j(h, "yes");
7743
+ L.preventDefault(), j(m, "yes");
7718
7744
  },
7719
7745
  onDragLeave: (L) => {
7720
- L.preventDefault(), j(h, "no");
7746
+ L.preventDefault(), j(m, "no");
7721
7747
  },
7722
7748
  onDrop: (L) => {
7723
- L.preventDefault(), j(h, "no");
7749
+ L.preventDefault(), j(m, "no");
7724
7750
  },
7725
7751
  children: [
7726
7752
  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(
@@ -7744,7 +7770,7 @@ const Input = ({ node: o }) => {
7744
7770
  y && canAcceptChildBlock(f._type, "Icon") ? "bg-green-200" : "",
7745
7771
  (o == null ? void 0 : o.id) === S ? "bg-primary/10" : "",
7746
7772
  b && "opacity-20",
7747
- l.includes(h) ? "opacity-50" : "",
7773
+ l.includes(m) ? "opacity-50" : "",
7748
7774
  I && x && "bg-primary/20 text-primary"
7749
7775
  ),
7750
7776
  children: [
@@ -7781,11 +7807,11 @@ const Input = ({ node: o }) => {
7781
7807
  )
7782
7808
  ] }),
7783
7809
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7784
- canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(h) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7810
+ canAddChildBlock(f == null ? void 0 : f._type) && !l.includes(m) && d(PERMISSIONS.ADD_BLOCK) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7785
7811
  /* @__PURE__ */ jsx(
7786
7812
  TooltipTrigger,
7787
7813
  {
7788
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: h }),
7814
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
7789
7815
  className: "cursor-pointer rounded bg-transparent",
7790
7816
  asChild: !0,
7791
7817
  children: /* @__PURE__ */ jsx(PlusIcon, { className: "h-3 w-3" })
@@ -7798,7 +7824,7 @@ const Input = ({ node: o }) => {
7798
7824
  TooltipTrigger,
7799
7825
  {
7800
7826
  onClick: (L) => {
7801
- L.stopPropagation(), i(h), o.isOpen && o.toggle();
7827
+ L.stopPropagation(), i(m), o.isOpen && o.toggle();
7802
7828
  },
7803
7829
  className: "cursor-pointer rounded bg-transparent",
7804
7830
  asChild: !0,
@@ -7807,7 +7833,7 @@ const Input = ({ node: o }) => {
7807
7833
  ),
7808
7834
  /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-[9999]", side: "bottom", children: a("Hide block") })
7809
7835
  ] }),
7810
- /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: h, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
7836
+ /* @__PURE__ */ jsx(BlockMoreOptions, { node: o, id: m, children: /* @__PURE__ */ jsx(MoreVertical, { size: "15" }) })
7811
7837
  ] })
7812
7838
  ]
7813
7839
  }
@@ -8072,9 +8098,9 @@ const Input = ({ node: o }) => {
8072
8098
  )
8073
8099
  ] });
8074
8100
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
8075
- const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: m } = useTranslation(), g = (v) => {
8101
+ const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), { hasPermission: c } = usePermissions(), [d, p] = useTheme(), u = useThemeOptions(), { t: g } = useTranslation(), h = (v) => {
8076
8102
  a(v);
8077
- }, h = () => {
8103
+ }, m = () => {
8078
8104
  const v = l.find((B) => Object.keys(B)[0] === n);
8079
8105
  if (v) {
8080
8106
  const B = Object.values(v)[0];
@@ -8134,12 +8160,12 @@ const Input = ({ node: o }) => {
8134
8160
  /* @__PURE__ */ jsxs("div", { className: cn$2("no-scrollbar h-full w-full overflow-y-auto", o), children: [
8135
8161
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
8136
8162
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
8137
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Presets") }),
8163
+ /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Presets") }),
8138
8164
  /* @__PURE__ */ jsxs(
8139
8165
  "select",
8140
8166
  {
8141
8167
  value: n,
8142
- onChange: (v) => g(v.target.value),
8168
+ onChange: (v) => h(v.target.value),
8143
8169
  className: "w-full space-y-0.5 rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2",
8144
8170
  children: [
8145
8171
  /* @__PURE__ */ jsx("option", { value: "", children: "Select preset" }),
@@ -8154,8 +8180,8 @@ const Input = ({ node: o }) => {
8154
8180
  className: "w-full text-sm",
8155
8181
  disabled: n === "",
8156
8182
  variant: "default",
8157
- onClick: h,
8158
- children: m("Apply")
8183
+ onClick: m,
8184
+ children: g("Apply")
8159
8185
  }
8160
8186
  ) })
8161
8187
  ] }),
@@ -8170,14 +8196,14 @@ const Input = ({ node: o }) => {
8170
8196
  v
8171
8197
  )) }),
8172
8198
  (u == null ? void 0 : u.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
8173
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Border Radius") }),
8199
+ /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Border Radius") }),
8174
8200
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
8175
8201
  /* @__PURE__ */ jsx(BorderRadiusInput, { value: d.borderRadius, onChange: x }),
8176
8202
  /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: d.borderRadius })
8177
8203
  ] })
8178
8204
  ] }),
8179
8205
  (u == null ? void 0 : u.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
8180
- /* @__PURE__ */ jsx(Label, { className: "text-sm", children: m("Colors") }),
8206
+ /* @__PURE__ */ jsx(Label, { className: "text-sm", children: g("Colors") }),
8181
8207
  /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: u.colors.map((v) => b(v)) }, r ? "dark" : "light")
8182
8208
  ] })
8183
8209
  ] }),
@@ -8648,14 +8674,14 @@ function QuickPrompts({ onClick: o }) {
8648
8674
  ) }) });
8649
8675
  }
8650
8676
  const AIUserPrompt = ({ blockId: o }) => {
8651
- const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, m] = useState(), g = useRef(null), h = useRef(null);
8677
+ const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), h = useRef(null), m = useRef(null);
8652
8678
  useEffect(() => {
8653
8679
  var x;
8654
- (x = g.current) == null || x.focus();
8680
+ (x = h.current) == null || x.focus();
8655
8681
  }, []);
8656
8682
  const f = (x) => {
8657
8683
  const { usage: y } = x || {};
8658
- !l && y && m(y), h.current = setTimeout(() => m(void 0), 1e4), l || c("");
8684
+ !l && y && g(y), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8659
8685
  };
8660
8686
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8661
8687
  /* @__PURE__ */ jsxs(
@@ -8673,14 +8699,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8673
8699
  /* @__PURE__ */ jsx(
8674
8700
  Textarea,
8675
8701
  {
8676
- ref: g,
8702
+ ref: h,
8677
8703
  value: i,
8678
8704
  onChange: (x) => c(x.target.value),
8679
8705
  placeholder: r("Ask AI to edit content"),
8680
8706
  className: "w-full",
8681
8707
  rows: 3,
8682
8708
  onKeyDown: (x) => {
8683
- x.key === "Enter" && (x.preventDefault(), h.current && clearTimeout(h.current), m(void 0), n("content", o, i, f));
8709
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f));
8684
8710
  }
8685
8711
  }
8686
8712
  ),
@@ -8690,7 +8716,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8690
8716
  {
8691
8717
  disabled: i.trim().length < 5 || a,
8692
8718
  onClick: () => {
8693
- h.current && clearTimeout(h.current), m(void 0), n("content", o, i, f);
8719
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, i, f);
8694
8720
  },
8695
8721
  variant: "default",
8696
8722
  className: "w-fit",
@@ -8723,7 +8749,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8723
8749
  QuickPrompts,
8724
8750
  {
8725
8751
  onClick: (x) => {
8726
- h.current && clearTimeout(h.current), m(void 0), n("content", o, x, f);
8752
+ m.current && clearTimeout(m.current), g(void 0), n("content", o, x, f);
8727
8753
  }
8728
8754
  }
8729
8755
  )
@@ -8733,13 +8759,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8733
8759
  ] }) }) : null
8734
8760
  ] });
8735
8761
  }, AISetContext = () => {
8736
- const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, m] = useState(!1), g = useRef(null);
8762
+ const { t: o } = useTranslation(), r = useBuilderProp("aiContext", ""), [n, a] = useState(r), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), h = useRef(null);
8737
8763
  useEffect(() => {
8738
8764
  r && a(r);
8739
8765
  }, [r]);
8740
- const h = async () => {
8766
+ const m = async () => {
8741
8767
  try {
8742
- d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), g.current.click();
8768
+ d(!0), u(null), await i(n), toast.success(o("Updated AI Context")), h.current.click();
8743
8769
  } catch (f) {
8744
8770
  u(f);
8745
8771
  } finally {
@@ -8750,12 +8776,12 @@ const AIUserPrompt = ({ blockId: o }) => {
8750
8776
  Accordion,
8751
8777
  {
8752
8778
  onValueChange: (f) => {
8753
- m(f !== "");
8779
+ g(f !== "");
8754
8780
  },
8755
8781
  type: "single",
8756
8782
  collapsible: !0,
8757
8783
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8758
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: g, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8784
+ /* @__PURE__ */ jsx(AccordionTrigger, { ref: h, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8759
8785
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8760
8786
  /* @__PURE__ */ jsx(
8761
8787
  Textarea,
@@ -8767,7 +8793,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8767
8793
  className: "mt-1 w-full",
8768
8794
  rows: 10,
8769
8795
  onKeyDown: (f) => {
8770
- f.key === "Enter" && (f.preventDefault(), h());
8796
+ f.key === "Enter" && (f.preventDefault(), m());
8771
8797
  }
8772
8798
  }
8773
8799
  ),
@@ -8779,7 +8805,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8779
8805
  Button,
8780
8806
  {
8781
8807
  disabled: n.trim().length < 5,
8782
- onClick: () => h(),
8808
+ onClick: () => m(),
8783
8809
  variant: "default",
8784
8810
  className: "w-fit",
8785
8811
  size: "sm",
@@ -8808,7 +8834,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8808
8834
  AlertDialogAction,
8809
8835
  {
8810
8836
  onClick: () => {
8811
- a(""), h();
8837
+ a(""), m();
8812
8838
  },
8813
8839
  children: o("Yes, Delete")
8814
8840
  }
@@ -8862,14 +8888,14 @@ const UndoRedo = () => {
8862
8888
  ] });
8863
8889
  };
8864
8890
  function AIChatPanel() {
8865
- const [o, r] = useState([]), [n, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), m = useRef(null);
8891
+ const [o, r] = useState([]), [n, a] = useState(""), [l, i] = useState(!1), [c, d] = useState(null), p = useRef(null), u = useRef(null), g = useRef(null);
8866
8892
  useEffect(() => {
8867
8893
  var b;
8868
8894
  (b = u.current) == null || b.scrollIntoView({ behavior: "smooth" });
8869
8895
  }, [o]), useEffect(() => {
8870
- m.current && (m.current.style.height = "auto", m.current.style.height = `${Math.min(m.current.scrollHeight, 120)}px`);
8896
+ g.current && (g.current.style.height = "auto", g.current.style.height = `${Math.min(g.current.scrollHeight, 120)}px`);
8871
8897
  }, [n]);
8872
- const g = async () => {
8898
+ const h = async () => {
8873
8899
  if (!n.trim() && !c) return;
8874
8900
  const b = {
8875
8901
  id: Date.now().toString(),
@@ -8886,8 +8912,8 @@ function AIChatPanel() {
8886
8912
  };
8887
8913
  r((B) => [...B, v]), i(!1), d(null);
8888
8914
  }, 1500);
8889
- }, h = (b) => {
8890
- b.key === "Enter" && !b.shiftKey && (b.preventDefault(), g());
8915
+ }, m = (b) => {
8916
+ b.key === "Enter" && !b.shiftKey && (b.preventDefault(), h());
8891
8917
  }, f = (b) => {
8892
8918
  var B;
8893
8919
  const v = (B = b.target.files) == null ? void 0 : B[0];
@@ -8957,10 +8983,10 @@ function AIChatPanel() {
8957
8983
  /* @__PURE__ */ jsx(
8958
8984
  Textarea,
8959
8985
  {
8960
- ref: m,
8986
+ ref: g,
8961
8987
  value: n,
8962
8988
  onChange: (b) => a(b.target.value),
8963
- onKeyDown: h,
8989
+ onKeyDown: m,
8964
8990
  placeholder: "Ask something...",
8965
8991
  className: "max-h-[120px] min-h-[40px] resize-none border-0 bg-muted/50 py-2.5 pr-10 focus-visible:ring-1"
8966
8992
  }
@@ -8982,7 +9008,7 @@ function AIChatPanel() {
8982
9008
  {
8983
9009
  size: "sm",
8984
9010
  className: "h-10 px-3",
8985
- onClick: g,
9011
+ onClick: h,
8986
9012
  disabled: l || !n.trim() && !c,
8987
9013
  children: [
8988
9014
  /* @__PURE__ */ jsx(Send, { className: "mr-1 h-4 w-4" }),
@@ -9090,32 +9116,32 @@ const AiAssistant = () => {
9090
9116
  preloadedAttributes: r = [],
9091
9117
  onAttributesChange: n
9092
9118
  }) {
9093
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, m] = useState(null), [g, h] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
9119
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [h, m] = useState(""), f = useRef(null), x = useRef(null), y = usePageExternalData();
9094
9120
  useEffect(() => {
9095
9121
  l(r);
9096
9122
  }, [r]);
9097
9123
  const b = () => {
9098
9124
  if (i.startsWith("@")) {
9099
- h("Attribute keys cannot start with '@'");
9125
+ m("Attribute keys cannot start with '@'");
9100
9126
  return;
9101
9127
  }
9102
9128
  if (i) {
9103
9129
  const S = [...a, { key: i, value: d }];
9104
- n(S), l(a), c(""), p(""), h("");
9130
+ n(S), l(a), c(""), p(""), m("");
9105
9131
  }
9106
9132
  }, v = (S) => {
9107
9133
  const A = a.filter((N, C) => C !== S);
9108
9134
  n(A), l(A);
9109
9135
  }, B = (S) => {
9110
- m(S), c(a[S].key), p(a[S].value);
9136
+ g(S), c(a[S].key), p(a[S].value);
9111
9137
  }, w = () => {
9112
9138
  if (i.startsWith("@")) {
9113
- h("Attribute keys cannot start with '@'");
9139
+ m("Attribute keys cannot start with '@'");
9114
9140
  return;
9115
9141
  }
9116
9142
  if (u !== null && i) {
9117
9143
  const S = [...a];
9118
- S[u] = { key: i, value: d }, n(S), l(S), m(null), c(""), p(""), h("");
9144
+ S[u] = { key: i, value: d }, n(S), l(S), g(null), c(""), p(""), m("");
9119
9145
  }
9120
9146
  }, E = (S) => {
9121
9147
  S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? w() : b());
@@ -9191,7 +9217,7 @@ const AiAssistant = () => {
9191
9217
  ] })
9192
9218
  ] }),
9193
9219
  /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
9194
- g && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: g })
9220
+ h && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: h })
9195
9221
  ]
9196
9222
  }
9197
9223
  ),
@@ -9322,11 +9348,11 @@ const RootLayout = () => {
9322
9348
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9323
9349
  n("outline");
9324
9350
  });
9325
- const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), m = useCallback((S) => {
9351
+ const p = useChaiSidebarPanels("top"), u = useChaiSidebarPanels("bottom"), g = useCallback((S) => {
9326
9352
  S.preventDefault();
9327
- }, []), g = useCallback((S) => {
9353
+ }, []), h = useCallback((S) => {
9328
9354
  n(r === S ? null : S);
9329
- }, []), h = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...h, ...p], [h, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9355
+ }, []), m = useSidebarMenuItems(), { t: f } = useTranslation(), x = useMemo(() => [...m, ...p], [m, p]), y = useBuilderProp("htmlDir", "ltr"), b = find(x, { id: r }) ?? first(x), v = get(b, "width", DEFAULT_PANEL_WIDTH);
9330
9356
  useEffect(() => {
9331
9357
  if (r !== null) {
9332
9358
  const S = find(x, { id: r });
@@ -9347,15 +9373,15 @@ const RootLayout = () => {
9347
9373
  }, [r, x]);
9348
9374
  const _ = useCallback(
9349
9375
  (S) => {
9350
- g(S);
9376
+ h(S);
9351
9377
  },
9352
- [g]
9378
+ [h]
9353
9379
  );
9354
9380
  return /* @__PURE__ */ jsx("div", { dir: y, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9355
9381
  /* @__PURE__ */ jsxs(
9356
9382
  "div",
9357
9383
  {
9358
- onContextMenu: m,
9384
+ onContextMenu: g,
9359
9385
  className: "flex h-screen max-h-full flex-col bg-background text-foreground",
9360
9386
  children: [
9361
9387
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(o, {}) }) }),
@@ -9584,17 +9610,17 @@ const FEATURE_TOGGLES = {
9584
9610
  for (const i of r.p)
9585
9611
  l.add(i);
9586
9612
  return l;
9587
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (h, ...f) => h.read(...f), p = (h, ...f) => h.write(...f), u = (h, f) => {
9613
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (m, ...f) => m.read(...f), p = (m, ...f) => m.write(...f), u = (m, f) => {
9588
9614
  var x;
9589
- return (x = h.unstable_onInit) == null ? void 0 : x.call(h, f);
9590
- }, m = (h, f) => {
9615
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, f);
9616
+ }, g = (m, f) => {
9591
9617
  var x;
9592
- return (x = h.onMount) == null ? void 0 : x.call(h, f);
9593
- }, ...g) => {
9594
- const h = g[0] || ((A) => {
9618
+ return (x = m.onMount) == null ? void 0 : x.call(m, f);
9619
+ }, ...h) => {
9620
+ const m = h[0] || ((A) => {
9595
9621
  let N = o.get(A);
9596
9622
  return N || (N = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(A, N), u == null || u(A, S)), N;
9597
- }), f = g[1] || (() => {
9623
+ }), f = h[1] || (() => {
9598
9624
  let A, N;
9599
9625
  const C = (k) => {
9600
9626
  try {
@@ -9613,10 +9639,10 @@ const FEATURE_TOGGLES = {
9613
9639
  } while (a.size || i.size || l.size);
9614
9640
  if (A)
9615
9641
  throw N;
9616
- }), x = g[2] || (() => {
9642
+ }), x = h[2] || (() => {
9617
9643
  const A = [], N = /* @__PURE__ */ new WeakSet(), C = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
9618
9644
  for (; k.length; ) {
9619
- const j = k[k.length - 1], T = h(j);
9645
+ const j = k[k.length - 1], T = m(j);
9620
9646
  if (C.has(j)) {
9621
9647
  k.pop();
9622
9648
  continue;
@@ -9639,9 +9665,9 @@ const FEATURE_TOGGLES = {
9639
9665
  }
9640
9666
  P && (y(T), B(T)), n.delete(T);
9641
9667
  }
9642
- }), y = g[3] || ((A) => {
9668
+ }), y = h[3] || ((A) => {
9643
9669
  var N, C;
9644
- const k = h(A);
9670
+ const k = m(A);
9645
9671
  if (isAtomStateInitialized(k) && (r.has(A) && n.get(A) !== k.n || Array.from(k.d).every(
9646
9672
  ([R, $]) => (
9647
9673
  // Recursively, read the atom state of the dependency, and
@@ -9657,13 +9683,13 @@ const FEATURE_TOGGLES = {
9657
9683
  }, I = (R) => {
9658
9684
  var $;
9659
9685
  if (isSelfAtom(A, R)) {
9660
- const H = h(R);
9661
- if (!isAtomStateInitialized(H))
9686
+ const U = m(R);
9687
+ if (!isAtomStateInitialized(U))
9662
9688
  if (hasInitialValue(R))
9663
- setAtomStateValueOrPromise(R, R.init, h);
9689
+ setAtomStateValueOrPromise(R, R.init, m);
9664
9690
  else
9665
9691
  throw new Error("no atom init");
9666
- return returnAtomValue(H);
9692
+ return returnAtomValue(U);
9667
9693
  }
9668
9694
  const M = y(R);
9669
9695
  try {
@@ -9690,7 +9716,7 @@ const FEATURE_TOGGLES = {
9690
9716
  }, O = k.n;
9691
9717
  try {
9692
9718
  const R = d(A, I, D);
9693
- return setAtomStateValueOrPromise(A, R, h), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
9719
+ return setAtomStateValueOrPromise(A, R, m), isPromiseLike$1(R) && ((N = R.onCancel) == null || N.call(R, () => P == null ? void 0 : P.abort()), R.then(
9694
9720
  T,
9695
9721
  T
9696
9722
  )), k;
@@ -9699,26 +9725,26 @@ const FEATURE_TOGGLES = {
9699
9725
  } finally {
9700
9726
  j = !1, O !== k.n && n.get(A) === O && (n.set(A, k.n), a.add(A), (C = c.c) == null || C.call(c, A));
9701
9727
  }
9702
- }), b = g[4] || ((A) => {
9728
+ }), b = h[4] || ((A) => {
9703
9729
  const N = [A];
9704
9730
  for (; N.length; ) {
9705
- const C = N.pop(), k = h(C);
9731
+ const C = N.pop(), k = m(C);
9706
9732
  for (const j of getMountedOrPendingDependents(C, k, r)) {
9707
- const T = h(j);
9733
+ const T = m(j);
9708
9734
  n.set(j, T.n), N.push(j);
9709
9735
  }
9710
9736
  }
9711
- }), v = g[5] || ((A, ...N) => {
9737
+ }), v = h[5] || ((A, ...N) => {
9712
9738
  let C = !0;
9713
9739
  const k = (T) => returnAtomValue(y(T)), j = (T, ...I) => {
9714
9740
  var P;
9715
- const L = h(T);
9741
+ const L = m(T);
9716
9742
  try {
9717
9743
  if (isSelfAtom(A, T)) {
9718
9744
  if (!hasInitialValue(T))
9719
9745
  throw new Error("atom not writable");
9720
9746
  const D = L.n, O = I[0];
9721
- setAtomStateValueOrPromise(T, O, h), B(T), D !== L.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
9747
+ setAtomStateValueOrPromise(T, O, m), B(T), D !== L.n && (a.add(T), (P = c.c) == null || P.call(c, T), b(T));
9722
9748
  return;
9723
9749
  } else
9724
9750
  return v(T, ...I);
@@ -9731,13 +9757,13 @@ const FEATURE_TOGGLES = {
9731
9757
  } finally {
9732
9758
  C = !1;
9733
9759
  }
9734
- }), B = g[6] || ((A) => {
9760
+ }), B = h[6] || ((A) => {
9735
9761
  var N;
9736
- const C = h(A), k = r.get(A);
9762
+ const C = m(A), k = r.get(A);
9737
9763
  if (k && !isPendingPromise(C.v)) {
9738
9764
  for (const [j, T] of C.d)
9739
9765
  if (!k.d.has(j)) {
9740
- const I = h(j);
9766
+ const I = m(j);
9741
9767
  w(j).t.add(A), k.d.add(j), T !== I.n && (a.add(j), (N = c.c) == null || N.call(c, j), b(j));
9742
9768
  }
9743
9769
  for (const j of k.d || [])
@@ -9747,9 +9773,9 @@ const FEATURE_TOGGLES = {
9747
9773
  T == null || T.t.delete(A);
9748
9774
  }
9749
9775
  }
9750
- }), w = g[7] || ((A) => {
9776
+ }), w = h[7] || ((A) => {
9751
9777
  var N;
9752
- const C = h(A);
9778
+ const C = m(A);
9753
9779
  let k = r.get(A);
9754
9780
  if (!k) {
9755
9781
  y(A);
@@ -9770,7 +9796,7 @@ const FEATURE_TOGGLES = {
9770
9796
  }
9771
9797
  };
9772
9798
  try {
9773
- const P = m(A, I);
9799
+ const P = g(A, I);
9774
9800
  P && (k.u = () => {
9775
9801
  T = !0;
9776
9802
  try {
@@ -9787,9 +9813,9 @@ const FEATURE_TOGGLES = {
9787
9813
  }
9788
9814
  }
9789
9815
  return k;
9790
- }), E = g[8] || ((A) => {
9816
+ }), E = h[8] || ((A) => {
9791
9817
  var N;
9792
- const C = h(A);
9818
+ const C = m(A);
9793
9819
  let k = r.get(A);
9794
9820
  if (k && !k.l.size && !Array.from(k.t).some((j) => {
9795
9821
  var T;
@@ -9816,9 +9842,9 @@ const FEATURE_TOGGLES = {
9816
9842
  d,
9817
9843
  p,
9818
9844
  u,
9819
- m,
9845
+ g,
9820
9846
  // building-block functions
9821
- h,
9847
+ m,
9822
9848
  f,
9823
9849
  x,
9824
9850
  y,
@@ -9882,8 +9908,8 @@ const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), d
9882
9908
  function useAtomValue(o, r) {
9883
9909
  const n = useStore(), [[a, l, i], c] = useReducer(
9884
9910
  (u) => {
9885
- const m = n.get(o);
9886
- return Object.is(u[0], m) && u[1] === n && u[2] === o ? u : [m, n, o];
9911
+ const g = n.get(o);
9912
+ return Object.is(u[0], g) && u[1] === n && u[2] === o ? u : [g, n, o];
9887
9913
  },
9888
9914
  void 0,
9889
9915
  () => [n.get(o), n, o]