@chaibuilder/sdk 2.0.0-beta.35 → 2.0.0-beta.37

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. package/dist/{ChaiThemeFn--DgGggh_.js → ChaiThemeFn-BUgkaTMi.js} +1 -1
  2. package/dist/{ChaiThemeFn-bugxb1Cl.cjs → ChaiThemeFn-B_ATMTMa.cjs} +3 -3
  3. package/dist/CodeEditor-DCZWTNZX.cjs +1 -0
  4. package/dist/CodeEditor-iLT-zqjH.js +77 -0
  5. package/dist/Topbar-Bk4vqKpP.cjs +1 -0
  6. package/dist/Topbar-DMCtQiUj.js +22 -0
  7. package/dist/{context-menu-EDKTnqIV.js → context-menu-CxioWiWD.js} +1 -1
  8. package/dist/{context-menu-0lRey9QY.cjs → context-menu-t34dYg4a.cjs} +1 -1
  9. package/dist/core.cjs +4 -4
  10. package/dist/core.d.ts +18 -14
  11. package/dist/core.js +1322 -1380
  12. package/dist/{iconBase-Ief2hJUZ.js → iconBase-DHfFLkem.js} +6 -12
  13. package/dist/jsx-runtime-BYECrxsp.cjs +30 -0
  14. package/dist/{jsx-runtime-Sp0orL4X.js → jsx-runtime-DGlMoOmv.js} +241 -242
  15. package/dist/mockServiceWorker.js +39 -24
  16. package/dist/{plugin-GuIj4Ul0.js → plugin-OOaLfdkf.js} +1 -1
  17. package/dist/{plugin-4xaTkTNB.cjs → plugin-fWX0IMr4.cjs} +1 -1
  18. package/dist/render.cjs +1 -1
  19. package/dist/render.js +8 -11
  20. package/dist/style.css +1 -1
  21. package/dist/tailwind.cjs +1 -1
  22. package/dist/tailwind.js +5 -7
  23. package/dist/ui.cjs +1 -1
  24. package/dist/ui.d.ts +2 -47
  25. package/dist/ui.js +199 -356
  26. package/dist/web-blocks.cjs +2 -2
  27. package/dist/web-blocks.js +78 -81
  28. package/package.json +4 -1
  29. package/dist/CodeEditor-50B_qMvG.cjs +0 -1
  30. package/dist/CodeEditor-f8Ud0q2D.js +0 -126
  31. package/dist/Topbar-9IbTAO2f.js +0 -73
  32. package/dist/Topbar-eQjJCLWI.cjs +0 -1
  33. package/dist/jsx-runtime-JYMCiFoE.cjs +0 -27
  34. /package/dist/{STRINGS-BnWT5XcX.js → STRINGS-DtEft2kY.js} +0 -0
  35. /package/dist/{STRINGS-26RPxXyi.cjs → STRINGS-n7COZtKr.cjs} +0 -0
  36. /package/dist/{iconBase-aZzpqff_.cjs → iconBase-Cn2BsTrq.cjs} +0 -0
package/dist/core.js CHANGED
@@ -1,32 +1,32 @@
1
- var U = Object.defineProperty;
2
- var F = (o, r, n) => r in o ? U(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
- var H = (o, r, n) => (F(o, typeof r != "symbol" ? r + "" : r, n), n);
4
- import { j as jsxRuntimeExports } from "./jsx-runtime-Sp0orL4X.js";
1
+ var V = Object.defineProperty;
2
+ var U = (o, r, n) => r in o ? V(o, r, { enumerable: !0, configurable: !0, writable: !0, value: n }) : o[r] = n;
3
+ var O = (o, r, n) => U(o, typeof r != "symbol" ? r + "" : r, n);
4
+ import { j as jsxRuntimeExports } from "./jsx-runtime-DGlMoOmv.js";
5
5
  import * as React from "react";
6
6
  import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, useState, Component, Children, Suspense, useRef, memo, createElement, lazy } from "react";
7
- import { ag as useToast, S as Skeleton, B as Button, L as Label, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, C as Card, x as CardHeader, E as CardDescription, F as CardContent, T as Textarea, y as CardFooter, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, b as Switch, V as Popover, W as PopoverTrigger, X as PopoverContent, I as Input$1, U as TooltipPortal, e as AccordionItem, f as AccordionTrigger, g as AccordionContent, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, G as ScrollArea, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, j as AlertDialog, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, k as AlertDialogTrigger, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-EDKTnqIV.js";
8
- import { has, find, filter, flatten, map, omit, isString, includes, without, get, compact, isObject, each, set, first, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, pick, sortBy, memoize, forEach, unset, chunk, cloneDeep, throttle, reverse, startCase, debounce, capitalize, flatMapDeep, split, reject, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, isFunction as isFunction$1, uniq, toUpper, round } from "lodash-es";
7
+ import { ag as useToast, S as Skeleton, B as Button, L as Label, aj as ContextMenu, ak as ContextMenuTrigger, al as ContextMenuContent, am as ContextMenuItem, O as Tooltip, P as TooltipTrigger, Q as TooltipContent, C as Card, x as CardHeader, E as CardDescription, F as CardContent, T as Textarea, y as CardFooter, D as Dialog, s as DialogTrigger, a as DialogContent, h as Badge, b as Switch, V as Popover, W as PopoverTrigger, X as PopoverContent, I as Input$1, U as TooltipPortal, e as AccordionItem, f as AccordionTrigger, g as AccordionContent, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, G as ScrollArea, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, j as AlertDialog, l as AlertDialogContent, m as AlertDialogHeader, o as AlertDialogTitle, k as AlertDialogTrigger, p as AlertDialogDescription, n as AlertDialogFooter, r as AlertDialogCancel, q as AlertDialogAction, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-CxioWiWD.js";
8
+ import { has, find, filter, flatten, map, omit, isString, includes, without, get, compact, isObject, each, set, first, isEmpty, noop, keys, range, values, flattenDeep, startsWith, isNull, pick, sortBy, memoize, forEach, unset, chunk, cloneDeep, throttle, reverse, startCase, debounce, capitalize, flatMapDeep, some, split, reject, nth, toLower, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, isFunction as isFunction$1, uniq, toUpper, round } from "lodash-es";
9
9
  import { atom as atom$1, useAtomValue as useAtomValue$1, useAtom as useAtom$1, useSetAtom as useSetAtom$1, getDefaultStore as getDefaultStore$1 } from "jotai";
10
- import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-Ief2hJUZ.js";
10
+ import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
- import { useTranslation as Xe } from "react-i18next";
13
- import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, b as getChaiThemeCssVariables, a as getThemeFontsLinkMarkup } from "./ChaiThemeFn--DgGggh_.js";
14
- import { useThrottledCallback, useResizeObserver, useDebouncedCallback, useIntervalEffect } from "@react-hookz/web";
12
+ import { useTranslation as Ie } from "react-i18next";
13
+ import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, b as getChaiThemeCssVariables, a as getThemeFontsLinkMarkup } from "./ChaiThemeFn-BUgkaTMi.js";
14
+ import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
15
15
  import TreeModel from "tree-model";
16
16
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
17
- import { registerChaiBlock as Ze } from "@chaibuilder/runtime";
17
+ import { registerChaiBlock as De } from "@chaibuilder/runtime";
18
18
  import ReactQuill, { Quill } from "react-quill";
19
19
  import { useFeature, FlagsProvider } from "flagged";
20
20
  import { useHotkeys } from "react-hotkeys-hook";
21
21
  import { flip } from "@floating-ui/dom";
22
22
  import { useFloating, shift } from "@floating-ui/react-dom";
23
- import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, CardStackPlusIcon, CardStackIcon, ScissorsIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CheckIcon, ResetIcon, SunIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
23
+ import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, ReaderIcon, DropdownMenuIcon, BoxIcon, DragHandleHorizontalIcon, ViewHorizontalIcon, BorderAllIcon, BorderTopIcon, TableIcon, RadiobuttonIcon, InputIcon, ButtonIcon, CheckboxIcon, GroupIcon, SpaceBetweenVerticallyIcon, ColumnsIcon, TextIcon, RowsIcon, SketchLogoIcon, DividerHorizontalIcon, CodeIcon, CursorTextIcon, VideoIcon, Link1Icon, HeadingIcon, ImageIcon, CardStackIcon, CardStackPlusIcon, ScissorsIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, MinusIcon, TriangleDownIcon, RowSpacingIcon, CrossCircledIcon, CaretDownIcon, CaretRightIcon, CheckIcon, ResetIcon, SunIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
24
24
  import typography from "@tailwindcss/typography";
25
25
  import forms from "@tailwindcss/forms";
26
26
  import aspectRatio from "@tailwindcss/aspect-ratio";
27
27
  import containerQueries from "@tailwindcss/container-queries";
28
28
  import { twMerge } from "tailwind-merge";
29
- import { S as STYLES_KEY, R as ROOT_TEMP_KEY } from "./STRINGS-BnWT5XcX.js";
29
+ import { S as STYLES_KEY, R as ROOT_TEMP_KEY } from "./STRINGS-DtEft2kY.js";
30
30
  import { Provider } from "react-wrap-balancer";
31
31
  import { PlusIcon as PlusIcon$1, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, EyeOff, Eye, X, Plus, ChevronDown, List, Loader, SparklesIcon, SmileIcon, ShuffleIcon, Edit2, Paintbrush, Layers } from "lucide-react";
32
32
  import ReactDOM from "react-dom";
@@ -42,27 +42,10 @@ import Autosuggest from "react-autosuggest";
42
42
  import Fuse from "fuse.js";
43
43
  import clsx from "clsx";
44
44
  import i18n from "i18next";
45
- import { default as Qe } from "i18next";
45
+ import { default as Me } from "i18next";
46
46
  import { motion } from "framer-motion";
47
- import "@radix-ui/react-switch";
48
- import "@radix-ui/react-accordion";
49
- import "class-variance-authority";
50
- import "@radix-ui/react-alert-dialog";
51
- import "@radix-ui/react-slot";
52
- import "@radix-ui/react-dialog";
53
- import "@radix-ui/react-label";
54
- import "@radix-ui/react-scroll-area";
55
- import "@radix-ui/react-tabs";
56
- import "@radix-ui/react-tooltip";
57
- import "@radix-ui/react-popover";
58
- import "@radix-ui/react-hover-card";
59
- import "@radix-ui/react-dropdown-menu";
60
- import "@radix-ui/react-separator";
61
- import "@radix-ui/react-toast";
62
- import "@radix-ui/react-context-menu";
63
47
  const canAcceptChildBlock = (o, r) => {
64
- if (!o)
65
- return !0;
48
+ if (!o) return !0;
66
49
  const n = getRegisteredChaiBlock(o);
67
50
  return n && has(n, "canAcceptBlock") ? n.canAcceptBlock(r) : !1;
68
51
  }, canAddChildBlock = (o) => {
@@ -78,7 +61,6 @@ const canAcceptChildBlock = (o, r) => {
78
61
  const r = getRegisteredChaiBlock(o);
79
62
  return r && has(r, "canDelete") ? r.canDelete() : !0;
80
63
  };
81
- var define_import_meta_env_default$2 = { VITE_OPENAI_API_KEY: "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", VITE_UNSPASH_ACCESS_KEY: "XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA", VITE_JOTAI_DEVTOOL_ENABLED: "true", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
82
64
  let keyCount = 0;
83
65
  function atom(o, r) {
84
66
  const n = `atom${++keyCount}`, a = {
@@ -104,287 +86,246 @@ const hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.
104
86
  throw o.e;
105
87
  return o.v;
106
88
  }, createStore = () => {
107
- const o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map();
108
- let a, l, i;
109
- (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set());
110
- const c = (m) => o.get(m), d = (m, E) => {
111
- (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && Object.freeze(E);
112
- const R = o.get(m);
113
- if (o.set(m, E), n.has(m) || n.set(m, R), R && hasPromiseAtomValue(R)) {
114
- const C = "v" in E ? E.v instanceof Promise ? E.v : Promise.resolve(E.v) : Promise.reject(E.e);
115
- cancelPromise(R.v, C);
89
+ const o = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new Map(), a = (f) => o.get(f), l = (f, j) => {
90
+ const w = o.get(f);
91
+ if (o.set(f, j), n.has(f) || n.set(f, w), w && hasPromiseAtomValue(w)) {
92
+ const b = "v" in j ? j.v instanceof Promise ? j.v : Promise.resolve(j.v) : Promise.reject(j.e);
93
+ cancelPromise(w.v, b);
116
94
  }
117
- }, p = (m, E, R) => {
118
- const C = /* @__PURE__ */ new Map();
119
- let N = !1;
120
- R.forEach((I, w) => {
121
- !I && w === m && (I = E), I ? (C.set(w, I), E.d.get(w) !== I && (N = !0)) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] atom state not found");
122
- }), (N || E.d.size !== C.size) && (E.d = C);
123
- }, u = (m, E, R) => {
124
- const C = c(m), N = {
125
- d: (C == null ? void 0 : C.d) || /* @__PURE__ */ new Map(),
126
- v: E
95
+ }, i = (f, j, w) => {
96
+ const b = /* @__PURE__ */ new Map();
97
+ let C = !1;
98
+ w.forEach((B, N) => {
99
+ !B && N === f && (B = j), B && (b.set(N, B), j.d.get(N) !== B && (C = !0));
100
+ }), (C || j.d.size !== b.size) && (j.d = b);
101
+ }, c = (f, j, w) => {
102
+ const b = a(f), C = {
103
+ d: (b == null ? void 0 : b.d) || /* @__PURE__ */ new Map(),
104
+ v: j
127
105
  };
128
- if (R && p(m, N, R), C && isEqualAtomValue(C, N) && C.d === N.d)
129
- return C;
130
- if (C && hasPromiseAtomValue(C) && hasPromiseAtomValue(N) && isEqualPromiseAtomValue(C, N)) {
131
- if (C.d === N.d)
132
- return C;
133
- N.v = C.v;
106
+ if (w && i(f, C, w), b && isEqualAtomValue(b, C) && b.d === C.d)
107
+ return b;
108
+ if (b && hasPromiseAtomValue(b) && hasPromiseAtomValue(C) && isEqualPromiseAtomValue(b, C)) {
109
+ if (b.d === C.d)
110
+ return b;
111
+ C.v = b.v;
134
112
  }
135
- return d(m, N), N;
136
- }, x = (m, E, R, C) => {
137
- if (isPromiseLike$2(E)) {
138
- let N;
139
- const I = new Promise((w, $) => {
140
- let L = !1;
141
- E.then(
142
- (M) => {
143
- if (!L) {
144
- L = !0;
145
- const D = c(m), O = u(
146
- m,
147
- I,
148
- R
113
+ return l(f, C), C;
114
+ }, d = (f, j, w, b) => {
115
+ if (isPromiseLike$2(j)) {
116
+ let C;
117
+ const B = new Promise((N, D) => {
118
+ let I = !1;
119
+ j.then(
120
+ (T) => {
121
+ if (!I) {
122
+ I = !0;
123
+ const L = a(f), P = c(
124
+ f,
125
+ B,
126
+ w
149
127
  );
150
- resolvePromise(I, M), w(M), (D == null ? void 0 : D.d) !== O.d && T(m, O, D == null ? void 0 : D.d);
128
+ resolvePromise(B, T), N(T), (L == null ? void 0 : L.d) !== P.d && S(f, P, L == null ? void 0 : L.d);
151
129
  }
152
130
  },
153
- (M) => {
154
- if (!L) {
155
- L = !0;
156
- const D = c(m), O = u(
157
- m,
158
- I,
159
- R
131
+ (T) => {
132
+ if (!I) {
133
+ I = !0;
134
+ const L = a(f), P = c(
135
+ f,
136
+ B,
137
+ w
160
138
  );
161
- rejectPromise(I, M), $(M), (D == null ? void 0 : D.d) !== O.d && T(m, O, D == null ? void 0 : D.d);
139
+ rejectPromise(B, T), D(T), (L == null ? void 0 : L.d) !== P.d && S(f, P, L == null ? void 0 : L.d);
162
140
  }
163
141
  }
164
- ), N = (M) => {
165
- L || (L = !0, M.then(
166
- (D) => resolvePromise(I, D),
167
- (D) => rejectPromise(I, D)
168
- ), w(M));
142
+ ), C = (T) => {
143
+ I || (I = !0, T.then(
144
+ (L) => resolvePromise(B, L),
145
+ (L) => rejectPromise(B, L)
146
+ ), N(T));
169
147
  };
170
148
  });
171
- return I.orig = E, I.status = "pending", registerCancelPromise(I, (w) => {
172
- w && N(w), C == null || C();
173
- }), u(m, I, R);
149
+ return B.orig = j, B.status = "pending", registerCancelPromise(B, (N) => {
150
+ N && C(N), b == null || b();
151
+ }), c(f, B, w);
174
152
  }
175
- return u(m, E, R);
176
- }, h = (m, E, R) => {
177
- const C = c(m), N = {
178
- d: (C == null ? void 0 : C.d) || /* @__PURE__ */ new Map(),
179
- e: E
153
+ return c(f, j, w);
154
+ }, p = (f, j, w) => {
155
+ const b = a(f), C = {
156
+ d: (b == null ? void 0 : b.d) || /* @__PURE__ */ new Map(),
157
+ e: j
180
158
  };
181
- return R && p(m, N, R), C && isEqualAtomError(C, N) && C.d === N.d ? C : (d(m, N), N);
182
- }, g = (m) => {
183
- const E = c(m);
184
- if (E && (E.d.forEach((L, M) => {
185
- M !== m && !r.has(M) && g(M);
186
- }), Array.from(E.d).every(([L, M]) => {
187
- const D = c(L);
188
- return L === m || D === M || // TODO This is a hack, we should find a better solution.
189
- D && !hasPromiseAtomValue(D) && isEqualAtomValue(D, M);
159
+ return w && i(f, C, w), b && isEqualAtomError(b, C) && b.d === C.d ? b : (l(f, C), C);
160
+ }, u = (f) => {
161
+ const j = a(f);
162
+ if (j && (j.d.forEach((I, T) => {
163
+ T !== f && !r.has(T) && u(T);
164
+ }), Array.from(j.d).every(([I, T]) => {
165
+ const L = a(I);
166
+ return I === f || L === T || // TODO This is a hack, we should find a better solution.
167
+ L && !hasPromiseAtomValue(L) && isEqualAtomValue(L, T);
190
168
  })))
191
- return E;
192
- const R = /* @__PURE__ */ new Map();
193
- let C = !0;
194
- const N = (L) => {
195
- if (L === m) {
196
- const D = c(L);
197
- if (D)
198
- return R.set(L, D), returnAtomValue(D);
199
- if (hasInitialValue(L))
200
- return R.set(L, void 0), L.init;
169
+ return j;
170
+ const w = /* @__PURE__ */ new Map();
171
+ let b = !0;
172
+ const C = (I) => {
173
+ if (I === f) {
174
+ const L = a(I);
175
+ if (L)
176
+ return w.set(I, L), returnAtomValue(L);
177
+ if (hasInitialValue(I))
178
+ return w.set(I, void 0), I.init;
201
179
  throw new Error("no atom init");
202
180
  }
203
- const M = g(L);
204
- return R.set(L, M), returnAtomValue(M);
181
+ const T = u(I);
182
+ return w.set(I, T), returnAtomValue(T);
205
183
  };
206
- let I, w;
207
- const $ = {
184
+ let B, N;
185
+ const D = {
208
186
  get signal() {
209
- return I || (I = new AbortController()), I.signal;
187
+ return B || (B = new AbortController()), B.signal;
210
188
  },
211
189
  get setSelf() {
212
- return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && !isActuallyWritableAtom(m) && console.warn("setSelf function cannot be used with read-only atom"), !w && isActuallyWritableAtom(m) && (w = (...L) => {
213
- if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && C && console.warn("setSelf function cannot be called in sync"), !C)
214
- return A(m, ...L);
215
- }), w;
190
+ return !N && isActuallyWritableAtom(f) && (N = (...I) => {
191
+ if (!b)
192
+ return k(f, ...I);
193
+ }), N;
216
194
  }
217
195
  };
218
196
  try {
219
- const L = m.read(N, $);
220
- return x(
221
- m,
222
- L,
223
- R,
224
- () => I == null ? void 0 : I.abort()
197
+ const I = f.read(C, D);
198
+ return d(
199
+ f,
200
+ I,
201
+ w,
202
+ () => B == null ? void 0 : B.abort()
225
203
  );
226
- } catch (L) {
227
- return h(m, L, R);
204
+ } catch (I) {
205
+ return p(f, I, w);
228
206
  } finally {
229
- C = !1;
207
+ b = !1;
230
208
  }
231
- }, j = (m) => returnAtomValue(g(m)), b = (m) => {
232
- let E = r.get(m);
233
- return E || (E = S(m)), E;
234
- }, f = (m, E) => !E.l.size && (!E.t.size || E.t.size === 1 && E.t.has(m)), y = (m) => {
235
- const E = r.get(m);
236
- E && f(m, E) && k(m);
237
- }, v = (m) => {
238
- const E = /* @__PURE__ */ new Map(), R = /* @__PURE__ */ new WeakMap(), C = (I) => {
239
- const w = r.get(I);
240
- w == null || w.t.forEach(($) => {
241
- $ !== I && (E.set(
242
- $,
243
- (E.get($) || /* @__PURE__ */ new Set()).add(I)
244
- ), R.set($, (R.get($) || 0) + 1), C($));
209
+ }, x = (f) => returnAtomValue(u(f)), h = (f) => {
210
+ let j = r.get(f);
211
+ return j || (j = _(f)), j;
212
+ }, m = (f, j) => !j.l.size && (!j.t.size || j.t.size === 1 && j.t.has(f)), E = (f) => {
213
+ const j = r.get(f);
214
+ j && m(f, j) && A(f);
215
+ }, y = (f) => {
216
+ const j = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new WeakMap(), b = (B) => {
217
+ const N = r.get(B);
218
+ N == null || N.t.forEach((D) => {
219
+ D !== B && (j.set(
220
+ D,
221
+ (j.get(D) || /* @__PURE__ */ new Set()).add(B)
222
+ ), w.set(D, (w.get(D) || 0) + 1), b(D));
245
223
  });
246
224
  };
247
- C(m);
248
- const N = (I) => {
249
- const w = r.get(I);
250
- w == null || w.t.forEach(($) => {
251
- var L;
252
- if ($ !== I) {
253
- let M = R.get($);
254
- if (M && R.set($, --M), !M) {
255
- let D = !!((L = E.get($)) != null && L.size);
256
- if (D) {
257
- const O = c($), V = g($);
258
- D = !O || !isEqualAtomValue(O, V);
225
+ b(f);
226
+ const C = (B) => {
227
+ const N = r.get(B);
228
+ N == null || N.t.forEach((D) => {
229
+ var I;
230
+ if (D !== B) {
231
+ let T = w.get(D);
232
+ if (T && w.set(D, --T), !T) {
233
+ let L = !!((I = j.get(D)) != null && I.size);
234
+ if (L) {
235
+ const P = a(D), M = u(D);
236
+ L = !P || !isEqualAtomValue(P, M);
259
237
  }
260
- D || E.forEach((O) => O.delete($));
238
+ L || j.forEach((P) => P.delete(D));
261
239
  }
262
- N($);
240
+ C(D);
263
241
  }
264
242
  });
265
243
  };
266
- N(m);
267
- }, B = (m, ...E) => {
268
- let R = !0;
269
- const C = (w) => returnAtomValue(g(w)), N = (w, ...$) => {
270
- let L;
271
- if (w === m) {
272
- if (!hasInitialValue(w))
244
+ C(f);
245
+ }, g = (f, ...j) => {
246
+ let w = !0;
247
+ const b = (N) => returnAtomValue(u(N)), C = (N, ...D) => {
248
+ let I;
249
+ if (N === f) {
250
+ if (!hasInitialValue(N))
273
251
  throw new Error("atom not writable");
274
- const M = c(w), D = x(w, $[0]);
275
- (!M || !isEqualAtomValue(M, D)) && v(w);
252
+ const T = a(N), L = d(N, D[0]);
253
+ (!T || !isEqualAtomValue(T, L)) && y(N);
276
254
  } else
277
- L = B(w, ...$);
278
- if (!R) {
279
- const M = _();
280
- (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
281
- (D) => D({ type: "async-write", flushed: M })
282
- );
283
- }
284
- return L;
285
- }, I = m.write(C, N, ...E);
286
- return R = !1, I;
287
- }, A = (m, ...E) => {
288
- const R = B(m, ...E), C = _();
289
- return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && l.forEach(
290
- (N) => N({ type: "write", flushed: C })
291
- ), R;
292
- }, S = (m, E) => {
293
- const R = {
294
- t: new Set(E && [E]),
255
+ I = g(N, ...D);
256
+ return w || v(), I;
257
+ }, B = f.write(b, C, ...j);
258
+ return w = !1, B;
259
+ }, k = (f, ...j) => {
260
+ const w = g(f, ...j);
261
+ return v(), w;
262
+ }, _ = (f, j) => {
263
+ const w = {
264
+ t: new Set(j && [j]),
295
265
  l: /* @__PURE__ */ new Set()
296
266
  };
297
- if (r.set(m, R), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.add(m), g(m).d.forEach((C, N) => {
298
- const I = r.get(N);
299
- I ? I.t.add(m) : N !== m && S(N, m);
300
- }), g(m), isActuallyWritableAtom(m) && m.onMount) {
301
- const C = m.onMount((...N) => A(m, ...N));
302
- C && (R.u = C);
267
+ if (r.set(f, w), u(f).d.forEach((b, C) => {
268
+ const B = r.get(C);
269
+ B ? B.t.add(f) : C !== f && _(C, f);
270
+ }), u(f), isActuallyWritableAtom(f) && f.onMount) {
271
+ const b = f.onMount((...C) => k(f, ...C));
272
+ b && (w.u = b);
303
273
  }
304
- return R;
305
- }, k = (m) => {
306
- var E;
307
- const R = (E = r.get(m)) == null ? void 0 : E.u;
308
- R && R(), r.delete(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && i.delete(m);
309
- const C = c(m);
310
- C ? (hasPromiseAtomValue(C) && cancelPromise(C.v), C.d.forEach((N, I) => {
311
- if (I !== m) {
312
- const w = r.get(I);
313
- w && (w.t.delete(m), f(I, w) && k(I));
274
+ return w;
275
+ }, A = (f) => {
276
+ var j;
277
+ const w = (j = r.get(f)) == null ? void 0 : j.u;
278
+ w && w(), r.delete(f);
279
+ const b = a(f);
280
+ b && (hasPromiseAtomValue(b) && cancelPromise(b.v), b.d.forEach((C, B) => {
281
+ if (B !== f) {
282
+ const N = r.get(B);
283
+ N && (N.t.delete(f), m(B, N) && A(B));
314
284
  }
315
- })) : (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] could not find atom state to unmount", m);
316
- }, T = (m, E, R) => {
317
- const C = new Set(E.d.keys());
318
- R == null || R.forEach((N, I) => {
319
- if (C.has(I)) {
320
- C.delete(I);
285
+ }));
286
+ }, S = (f, j, w) => {
287
+ const b = new Set(j.d.keys());
288
+ w == null || w.forEach((C, B) => {
289
+ if (b.has(B)) {
290
+ b.delete(B);
321
291
  return;
322
292
  }
323
- const w = r.get(I);
324
- w && (w.t.delete(m), f(I, w) && k(I));
325
- }), C.forEach((N) => {
326
- const I = r.get(N);
327
- I ? I.t.add(m) : r.has(m) && S(N, m);
293
+ const N = r.get(B);
294
+ N && (N.t.delete(f), m(B, N) && A(B));
295
+ }), b.forEach((C) => {
296
+ const B = r.get(C);
297
+ B ? B.t.add(f) : r.has(f) && _(C, f);
328
298
  });
329
- }, _ = () => {
330
- let m;
331
- for ((define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (m = /* @__PURE__ */ new Set()); n.size; ) {
332
- const E = Array.from(n);
333
- n.clear(), E.forEach(([R, C]) => {
334
- const N = c(R);
335
- if (N) {
336
- N.d !== (C == null ? void 0 : C.d) && T(R, N, C == null ? void 0 : C.d);
337
- const I = r.get(R);
338
- I && !// TODO This seems pretty hacky. Hope to fix it.
299
+ }, v = () => {
300
+ for (; n.size; ) {
301
+ const f = Array.from(n);
302
+ n.clear(), f.forEach(([j, w]) => {
303
+ const b = a(j);
304
+ if (b) {
305
+ b.d !== (w == null ? void 0 : w.d) && S(j, b, w == null ? void 0 : w.d);
306
+ const C = r.get(j);
307
+ C && !// TODO This seems pretty hacky. Hope to fix it.
339
308
  // Maybe we could `mountDependencies` in `setAtomState`?
340
- (C && !hasPromiseAtomValue(C) && (isEqualAtomValue(C, N) || isEqualAtomError(C, N))) && (I.l.forEach((w) => w()), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && m.add(R));
341
- } else
342
- (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && console.warn("[Bug] no atom state to flush");
309
+ (w && !hasPromiseAtomValue(w) && (isEqualAtomValue(w, b) || isEqualAtomError(w, b))) && C.l.forEach((B) => B());
310
+ }
343
311
  });
344
312
  }
345
- if ((define_import_meta_env_default$2 ? "production" : void 0) !== "production")
346
- return a.forEach((E) => E("state")), m;
347
- }, P = (m, E) => {
348
- const R = b(m), C = _(), N = R.l;
349
- return N.add(E), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((I) => I("sub")), l.forEach(
350
- (I) => I({ type: "sub", flushed: C })
351
- )), () => {
352
- N.delete(E), y(m), (define_import_meta_env_default$2 ? "production" : void 0) !== "production" && (a.forEach((I) => I("unsub")), l.forEach((I) => I({ type: "unsub" })));
353
- };
354
313
  };
355
- return (define_import_meta_env_default$2 ? "production" : void 0) !== "production" ? {
356
- get: j,
357
- set: A,
358
- sub: P,
359
- // store dev methods (these are tentative and subject to change without notice)
360
- dev_subscribe_store: (m, E) => E !== 2 ? (console.warn(
361
- "The current StoreListener revision is 2. The older ones are deprecated."
362
- ), a.add(m), () => {
363
- a.delete(m);
364
- }) : (l.add(m), () => {
365
- l.delete(m);
366
- }),
367
- dev_get_mounted_atoms: () => i.values(),
368
- dev_get_atom_state: (m) => o.get(m),
369
- dev_get_mounted: (m) => r.get(m),
370
- dev_restore_atoms: (m) => {
371
- for (const [R, C] of m)
372
- hasInitialValue(R) && (x(R, C), v(R));
373
- const E = _();
374
- l.forEach(
375
- (R) => R({ type: "restore", flushed: E })
376
- );
314
+ return {
315
+ get: x,
316
+ set: k,
317
+ sub: (f, j) => {
318
+ const w = h(f);
319
+ v();
320
+ const b = w.l;
321
+ return b.add(j), () => {
322
+ b.delete(j), E(f);
323
+ };
377
324
  }
378
- } : {
379
- get: j,
380
- set: A,
381
- sub: P
382
325
  };
383
326
  };
384
327
  let defaultStore;
385
- const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore);
386
- var define_import_meta_env_default$1 = { VITE_OPENAI_API_KEY: "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", VITE_UNSPASH_ACCESS_KEY: "XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA", VITE_JOTAI_DEVTOOL_ENABLED: "true", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
387
- const RESET = Symbol(), getCached$1 = (o, r, n) => (r.has(n) ? r : r.set(n, o())).get(n), cache1$2 = /* @__PURE__ */ new WeakMap(), memo2$1 = (o, r, n) => {
328
+ const getDefaultStore = () => (defaultStore || (defaultStore = createStore()), defaultStore), RESET = Symbol(), getCached$1 = (o, r, n) => (r.has(n) ? r : r.set(n, o())).get(n), cache1$2 = /* @__PURE__ */ new WeakMap(), memo2$1 = (o, r, n) => {
388
329
  const a = getCached$1(() => /* @__PURE__ */ new WeakMap(), cache1$2, r);
389
330
  return getCached$1(o, a, n);
390
331
  }, cacheKeyForEmptyKeyExtractor = {}, isWritable = (o) => !!o.write, isFunction = (o) => typeof o == "function";
@@ -396,41 +337,41 @@ function splitAtom(o, r) {
396
337
  if (p)
397
338
  return p;
398
339
  const u = d && n.get(d), x = [], h = [];
399
- return c.forEach((g, j) => {
400
- const b = r ? r(g) : j;
401
- h[j] = b;
402
- const f = u && u.atomList[u.keyList.indexOf(b)];
403
- if (f) {
404
- x[j] = f;
340
+ return c.forEach((m, E) => {
341
+ const y = E;
342
+ h[E] = y;
343
+ const g = u && u.atomList[u.keyList.indexOf(y)];
344
+ if (g) {
345
+ x[E] = g;
405
346
  return;
406
347
  }
407
- const y = (B) => {
408
- const A = B(l), S = B(o), T = a(S, A == null ? void 0 : A.arr).keyList.indexOf(b);
409
- if (T < 0 || T >= S.length) {
410
- const _ = c[a(c).keyList.indexOf(b)];
411
- if (_)
412
- return _;
348
+ const k = (A) => {
349
+ const S = A(l), v = A(o), f = a(v, S == null ? void 0 : S.arr).keyList.indexOf(y);
350
+ if (f < 0 || f >= v.length) {
351
+ const j = c[a(c).keyList.indexOf(y)];
352
+ if (j)
353
+ return j;
413
354
  throw new Error("splitAtom: index out of bounds for read");
414
355
  }
415
- return S[T];
416
- }, v = (B, A, S) => {
417
- const k = B(l), T = B(o), P = a(T, k == null ? void 0 : k.arr).keyList.indexOf(b);
418
- if (P < 0 || P >= T.length)
356
+ return v[f];
357
+ }, _ = (A, S, v) => {
358
+ const R = A(l), f = A(o), w = a(f, R == null ? void 0 : R.arr).keyList.indexOf(y);
359
+ if (w < 0 || w >= f.length)
419
360
  throw new Error("splitAtom: index out of bounds for write");
420
- const m = isFunction(S) ? S(T[P]) : S;
421
- A(o, [
422
- ...T.slice(0, P),
423
- m,
424
- ...T.slice(P + 1)
361
+ const b = isFunction(v) ? v(f[w]) : v;
362
+ S(o, [
363
+ ...f.slice(0, w),
364
+ b,
365
+ ...f.slice(w + 1)
425
366
  ]);
426
367
  };
427
- x[j] = isWritable(o) ? atom(y, v) : atom(y);
428
- }), u && u.keyList.length === h.length && u.keyList.every((g, j) => g === h[j]) ? p = u : p = { arr: c, atomList: x, keyList: h }, n.set(c, p), p;
368
+ x[E] = isWritable(o) ? atom(k, _) : atom(k);
369
+ }), u && u.keyList.length === h.length && u.keyList.every((m, E) => m === h[E]) ? p = u : p = { arr: c, atomList: x, keyList: h }, n.set(c, p), p;
429
370
  }, l = atom((c) => {
430
371
  const d = c(l), p = c(o);
431
372
  return a(p, d == null ? void 0 : d.arr);
432
373
  });
433
- (define_import_meta_env_default$1 ? "production" : void 0) !== "production" && (l.debugPrivate = !0), l.init = void 0;
374
+ l.init = void 0;
434
375
  const i = isWritable(o) ? atom(
435
376
  (c) => c(l).atomList,
436
377
  (c, d, p) => {
@@ -482,7 +423,7 @@ function splitAtom(o, r) {
482
423
  return i;
483
424
  },
484
425
  o,
485
- r || cacheKeyForEmptyKeyExtractor
426
+ cacheKeyForEmptyKeyExtractor
486
427
  );
487
428
  }
488
429
  const isPromiseLike$1 = (o) => typeof (o == null ? void 0 : o.then) == "function";
@@ -537,26 +478,22 @@ const defaultStorage = createJSONStorage(
537
478
  () => typeof window < "u" ? window.localStorage : void 0
538
479
  );
539
480
  function atomWithStorage(o, r, n = defaultStorage, a) {
540
- const l = a == null ? void 0 : a.unstable_getOnInit, i = atom(
541
- l ? n.getItem(o, r) : r
481
+ const l = atom(
482
+ r
542
483
  );
543
- return (define_import_meta_env_default$1 ? "production" : void 0) !== "production" && (i.debugPrivate = !0), i.onMount = (d) => {
544
- l || d(n.getItem(o, r));
545
- let p;
546
- return n.subscribe && (p = n.subscribe(o, d, r)), p;
484
+ return l.onMount = (c) => {
485
+ c(n.getItem(o, r));
486
+ let d;
487
+ return n.subscribe && (d = n.subscribe(o, c, r)), d;
547
488
  }, atom(
548
- (d) => d(i),
549
- (d, p, u) => {
550
- const x = typeof u == "function" ? u(d(i)) : u;
551
- return x === RESET ? (p(i, r), n.removeItem(o)) : x instanceof Promise ? x.then((h) => (p(i, h), n.setItem(o, h))) : (p(i, x), n.setItem(o, x));
489
+ (c) => c(l),
490
+ (c, d, p) => {
491
+ const u = typeof p == "function" ? p(c(l)) : p;
492
+ return u === RESET ? (d(l, r), n.removeItem(o)) : u instanceof Promise ? u.then((x) => (d(l, x), n.setItem(o, x))) : (d(l, u), n.setItem(o, u));
552
493
  }
553
494
  );
554
495
  }
555
- var define_import_meta_env_default = { VITE_OPENAI_API_KEY: "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", VITE_UNSPASH_ACCESS_KEY: "XgYBCm-XCHecRMsbfhw6oZWGkltco1U5TYMEd0LXZeA", VITE_JOTAI_DEVTOOL_ENABLED: "true", BASE_URL: "/", MODE: "production", DEV: !1, PROD: !0, SSR: !1 };
556
- const StoreContext = createContext(void 0), useStore = (o) => {
557
- const r = useContext(StoreContext);
558
- return (o == null ? void 0 : o.store) || r || getDefaultStore();
559
- }, isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function", use = React__default.use || ((o) => {
496
+ const StoreContext = createContext(void 0), useStore = (o) => useContext(StoreContext) || getDefaultStore(), isPromiseLike = (o) => typeof (o == null ? void 0 : o.then) == "function", use = React__default.use || ((o) => {
560
497
  if (o.status === "pending")
561
498
  throw o;
562
499
  if (o.status === "fulfilled")
@@ -571,7 +508,7 @@ const StoreContext = createContext(void 0), useStore = (o) => {
571
508
  ), o);
572
509
  });
573
510
  function useAtomValue(o, r) {
574
- const n = useStore(r), [[a, l, i], c] = useReducer(
511
+ const n = useStore(), [[a, l, i], c] = useReducer(
575
512
  (u) => {
576
513
  const x = n.get(o);
577
514
  return Object.is(u[0], x) && u[1] === n && u[2] === o ? u : [x, n, o];
@@ -580,35 +517,25 @@ function useAtomValue(o, r) {
580
517
  () => [n.get(o), n, o]
581
518
  );
582
519
  let d = a;
583
- (l !== n || i !== o) && (c(), d = n.get(o));
584
- const p = r == null ? void 0 : r.delay;
585
- return useEffect(() => {
520
+ return (l !== n || i !== o) && (c(), d = n.get(o)), useEffect(() => {
586
521
  const u = n.sub(o, () => {
587
- if (typeof p == "number") {
588
- setTimeout(c, p);
589
- return;
590
- }
591
522
  c();
592
523
  });
593
524
  return c(), u;
594
- }, [n, o, p]), useDebugValue(d), isPromiseLike(d) ? use(d) : d;
525
+ }, [n, o, void 0]), useDebugValue(d), isPromiseLike(d) ? use(d) : d;
595
526
  }
596
527
  function useSetAtom(o, r) {
597
- const n = useStore(r);
528
+ const n = useStore();
598
529
  return useCallback(
599
- (...l) => {
600
- if ((define_import_meta_env_default ? "production" : void 0) !== "production" && !("write" in o))
601
- throw new Error("not writable atom");
602
- return n.set(o, ...l);
603
- },
530
+ (...l) => n.set(o, ...l),
604
531
  [n, o]
605
532
  );
606
533
  }
607
534
  function useAtom(o, r) {
608
535
  return [
609
- useAtomValue(o, r),
536
+ useAtomValue(o),
610
537
  // We do wrong type assertion here, which results in throwing an error.
611
- useSetAtom(o, r)
538
+ useSetAtom(o)
612
539
  ];
613
540
  }
614
541
  function duplicateBlocks(o, r, n) {
@@ -651,7 +578,7 @@ const getSlots = (o) => {
651
578
  }), r;
652
579
  }, getDuplicatedBlocks = (o, r, n = null) => {
653
580
  let a = find(o, { _id: r });
654
- a = { ...a, oldId: a._id, _id: generateUUID() }, n && (a = { ...a, _parent: n });
581
+ a = { ...a, oldId: a._id, _id: generateUUID() }, n !== (a == null ? void 0 : a._parent) && (a = { ...a, _parent: n });
655
582
  const l = [a];
656
583
  filter(o, { _parent: r }).length > 0 && l.push(flatten(duplicateBlocks(o, r, a._id)));
657
584
  const i = flatten(l);
@@ -940,8 +867,7 @@ function getSingleBlock(o) {
940
867
  }
941
868
  function getPBlocks(o) {
942
869
  const r = find(FLAT_ARRAY, { _id: o._id });
943
- if (!r)
944
- return [];
870
+ if (!r) return [];
945
871
  const n = [r], a = filter(FLAT_ARRAY, { _parent: o._id });
946
872
  return a.length ? flatten([...n, ...flatten(map(a, getPBlocks))]) : flatten(n);
947
873
  }
@@ -1033,6 +959,22 @@ const useUndoManager = () => {
1033
959
  hasUndo: undoManager.hasUndo,
1034
960
  clear: undoManager.clear
1035
961
  };
962
+ }, broadcastChannel = new BroadcastChannel("chaibuilder"), useBroadcastChannel = () => {
963
+ const o = useBuilderProp("pageId", "chaibuilder_page");
964
+ return { postMessage: useDebouncedCallback(
965
+ (n) => broadcastChannel.postMessage({ ...n, pageId: o }),
966
+ [o],
967
+ 200
968
+ ) };
969
+ }, useUnmountBroadcastChannel = () => {
970
+ const [, o] = useBlocksStore(), r = useBuilderProp("pageId", "chaibuilder_page");
971
+ useEffect(() => (broadcastChannel.onmessageerror = (n) => {
972
+ console.log("error", n);
973
+ }, broadcastChannel.onmessage = (n) => {
974
+ n.data.type === "blocks-updated" && n.data.pageId === r && o(n.data.blocks);
975
+ }, () => {
976
+ broadcastChannel.onmessage = null, broadcastChannel.onmessageerror = null;
977
+ }), [o, r]);
1036
978
  }, removeNestedBlocks = (o, r) => {
1037
979
  const n = [], a = filter(o, (l) => includes(r, l._id) || includes(r, l._parent) ? (n.push(l._id), !1) : !0);
1038
980
  return isEmpty(n) ? a : removeNestedBlocks(a, n);
@@ -1083,8 +1025,7 @@ function moveNode(o, r, n, a) {
1083
1025
  return !1;
1084
1026
  }
1085
1027
  function moveBlocksWithChildren(o, r, n, a) {
1086
- if (!r)
1087
- return o;
1028
+ if (!r) return o;
1088
1029
  n = n || "root";
1089
1030
  const i = new TreeModel().parse({ _id: "root", children: getBlocksTree(o) });
1090
1031
  if (moveNode(i, r, n, a)) {
@@ -1094,35 +1035,41 @@ function moveBlocksWithChildren(o, r, n, a) {
1094
1035
  return o;
1095
1036
  }
1096
1037
  const useBlocksStoreManager = () => {
1097
- const [, o] = useBlocksStore();
1038
+ const [, o] = useBlocksStore(), { postMessage: r } = useBroadcastChannel();
1098
1039
  return {
1099
- setNewBlocks: (r) => {
1100
- o(r);
1040
+ setNewBlocks: (n) => {
1041
+ o(n), r({ type: "blocks-updated", blocks: n });
1101
1042
  },
1102
- addBlocks: (r, n, a) => {
1103
- o((l) => insertBlocksAtPosition(l, r, n, a));
1043
+ addBlocks: (n, a, l) => {
1044
+ o((i) => {
1045
+ const c = insertBlocksAtPosition(i, n, a, l);
1046
+ return r({ type: "blocks-updated", blocks: c }), c;
1047
+ });
1104
1048
  },
1105
- removeBlocks: (r) => {
1106
- o((n) => removeNestedBlocks(n, r));
1049
+ removeBlocks: (n) => {
1050
+ o((a) => {
1051
+ const l = removeNestedBlocks(a, n);
1052
+ return r({ type: "blocks-updated", blocks: l }), l;
1053
+ });
1107
1054
  },
1108
- moveBlocks: (r, n, a) => {
1109
- o((l) => {
1110
- let i = l;
1111
- for (let c = 0; c < r.length; c++)
1112
- i = moveBlocksWithChildren(i, r[c], n, a);
1113
- return i;
1055
+ moveBlocks: (n, a, l) => {
1056
+ o((i) => {
1057
+ let c = i;
1058
+ for (let d = 0; d < n.length; d++)
1059
+ c = moveBlocksWithChildren(c, n[d], a, l);
1060
+ return r({ type: "blocks-updated", blocks: c }), c;
1114
1061
  });
1115
1062
  },
1116
- updateBlocksProps: (r) => {
1117
- o((n) => {
1118
- const a = r.map((l) => l._id);
1119
- return n.map((l) => {
1120
- if (a.includes(l._id)) {
1121
- const i = find(r, { _id: l._id });
1122
- return { ...l, ...omit(i, "_id") };
1063
+ updateBlocksProps: (n) => {
1064
+ o((a) => {
1065
+ const l = n.map((c) => c._id), i = a.map((c) => {
1066
+ if (l.includes(c._id)) {
1067
+ const d = find(n, { _id: c._id });
1068
+ return { ...c, ...omit(d, "_id") };
1123
1069
  }
1124
- return l;
1070
+ return c;
1125
1071
  });
1072
+ return r({ type: "blocks-updated", blocks: i }), i;
1126
1073
  });
1127
1074
  }
1128
1075
  };
@@ -1135,98 +1082,98 @@ const useBlocksStoreManager = () => {
1135
1082
  updateBlocksProps: c
1136
1083
  } = useBlocksStoreManager();
1137
1084
  return {
1138
- moveBlocks: (b, f, y) => {
1139
- const v = map(b, (A) => {
1140
- const k = r.find((P) => P._id === A)._parent || null, _ = r.filter((P) => k ? P._parent === k : !P._parent).map((P) => P._id).indexOf(A);
1141
- return { _id: A, oldParent: k, oldPosition: _ };
1142
- }), B = v.find(({ _id: A }) => A === b[0]);
1143
- B && B.oldParent === f && B.oldPosition === y || (i(b, f, y), o({
1144
- undo: () => each(v, ({ _id: A, oldParent: S, oldPosition: k }) => {
1145
- i([A], S, k);
1085
+ moveBlocks: (y, g, k) => {
1086
+ const _ = map(y, (S) => {
1087
+ const R = r.find((w) => w._id === S)._parent || null, j = r.filter((w) => R ? w._parent === R : !w._parent).map((w) => w._id).indexOf(S);
1088
+ return { _id: S, oldParent: R, oldPosition: j };
1089
+ }), A = _.find(({ _id: S }) => S === y[0]);
1090
+ A && A.oldParent === g && A.oldPosition === k || (i(y, g, k), o({
1091
+ undo: () => each(_, ({ _id: S, oldParent: v, oldPosition: R }) => {
1092
+ i([S], v, R);
1146
1093
  }),
1147
- redo: () => i(b, f, y)
1094
+ redo: () => i(y, g, k)
1148
1095
  }));
1149
1096
  },
1150
- addBlocks: (b, f, y) => {
1151
- a(b, f, y), o({
1152
- undo: () => l(map(b, "_id")),
1153
- redo: () => a(b, f, y)
1097
+ addBlocks: (y, g, k) => {
1098
+ a(y, g, k), o({
1099
+ undo: () => l(map(y, "_id")),
1100
+ redo: () => a(y, g, k)
1154
1101
  });
1155
1102
  },
1156
- removeBlocks: (b) => {
1157
- var B;
1158
- const f = (B = first(b)) == null ? void 0 : B._parent, v = r.filter((A) => f ? A._parent === f : !A._parent).indexOf(first(b));
1159
- l(map(b, "_id")), o({
1160
- undo: () => a(b, f, v),
1161
- redo: () => l(map(b, "_id"))
1103
+ removeBlocks: (y) => {
1104
+ var A;
1105
+ const g = (A = first(y)) == null ? void 0 : A._parent, _ = r.filter((S) => g ? S._parent === g : !S._parent).indexOf(first(y));
1106
+ l(map(y, "_id")), o({
1107
+ undo: () => a(y, g, _),
1108
+ redo: () => l(map(y, "_id"))
1162
1109
  });
1163
1110
  },
1164
- updateBlocks: (b, f, y) => {
1165
- let v = [];
1166
- if (y)
1167
- v = map(b, (B) => ({ _id: B, ...y }));
1111
+ updateBlocks: (y, g, k) => {
1112
+ let _ = [];
1113
+ if (k)
1114
+ _ = map(y, (A) => ({ _id: A, ...k }));
1168
1115
  else {
1169
- const B = keys(f);
1170
- v = map(b, (A) => {
1171
- const S = r.find((T) => T._id === A), k = { _id: A };
1172
- return each(B, (T) => k[T] = S[T]), k;
1116
+ const A = keys(g);
1117
+ _ = map(y, (S) => {
1118
+ const v = r.find((f) => f._id === S), R = { _id: S };
1119
+ return each(A, (f) => R[f] = v[f]), R;
1173
1120
  });
1174
1121
  }
1175
- c(map(b, (B) => ({ _id: B, ...f }))), o({
1176
- undo: () => c(v),
1177
- redo: () => c(map(b, (B) => ({ _id: B, ...f })))
1122
+ c(map(y, (A) => ({ _id: A, ...g }))), o({
1123
+ undo: () => c(_),
1124
+ redo: () => c(map(y, (A) => ({ _id: A, ...g })))
1178
1125
  });
1179
1126
  },
1180
- updateBlocksRuntime: (b, f) => {
1181
- c(map(b, (y) => ({ _id: y, ...f })));
1127
+ updateBlocksRuntime: (y, g) => {
1128
+ c(map(y, (k) => ({ _id: k, ...g })));
1182
1129
  },
1183
- setNewBlocks: (b) => {
1184
- n(b), o({
1130
+ setNewBlocks: (y) => {
1131
+ n(y), o({
1185
1132
  undo: () => n(r),
1186
- redo: () => n(b)
1133
+ redo: () => n(y)
1187
1134
  });
1188
1135
  },
1189
- updateMultipleBlocksProps: (b) => {
1190
- let f = [];
1191
- f = map(b, (y) => {
1192
- const v = keys(y), B = r.find((S) => S._id === y._id), A = {};
1193
- return each(v, (S) => A[S] = B[S]), A;
1194
- }), c(b), o({
1195
- undo: () => c(f),
1196
- redo: () => c(b)
1136
+ updateMultipleBlocksProps: (y) => {
1137
+ let g = [];
1138
+ g = map(y, (k) => {
1139
+ const _ = keys(k), A = r.find((v) => v._id === k._id), S = {};
1140
+ return each(_, (v) => S[v] = A[v]), S;
1141
+ }), c(y), o({
1142
+ undo: () => c(g),
1143
+ redo: () => c(y)
1197
1144
  });
1198
1145
  }
1199
1146
  };
1200
1147
  }, useAddBlock = () => {
1201
1148
  const [o] = useBlocksStore(), [, r] = useSelectedBlockIds(), { addBlocks: n } = useBlocksStoreUndoableActions(), a = useCallback(
1202
1149
  (i, c, d) => {
1203
- var g;
1204
- for (let j = 0; j < i.length; j++) {
1205
- const { _id: b } = i[j];
1206
- i[j]._id = generateUUID();
1207
- const f = filter(i, { _parent: b });
1208
- for (let y = 0; y < f.length; y++)
1209
- f[y]._parent = i[j]._id;
1150
+ var m;
1151
+ for (let E = 0; E < i.length; E++) {
1152
+ const { _id: y } = i[E];
1153
+ i[E]._id = generateUUID();
1154
+ const g = filter(i, { _parent: y });
1155
+ for (let k = 0; k < g.length; k++)
1156
+ g[k]._parent = i[E]._id;
1210
1157
  }
1211
1158
  const p = first(i);
1212
1159
  let u, x;
1213
- return c && (u = find(o, { _id: c }), i[0]._parent = c, x = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, x = u._parent), n(i, x, d), r([(g = first(i)) == null ? void 0 : g._id]), first(i);
1160
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, x = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, x = u._parent), n(i, x, d), r([(m = first(i)) == null ? void 0 : m._id]), first(i);
1214
1161
  },
1215
1162
  [n, o, r]
1216
1163
  );
1217
1164
  return { addCoreBlock: useCallback(
1218
1165
  (i, c, d) => {
1219
1166
  if (has(i, "blocks")) {
1220
- const f = i.blocks;
1221
- return a(f, c, d);
1167
+ const g = i.blocks;
1168
+ return a(g, c, d);
1222
1169
  }
1223
1170
  const p = generateUUID(), u = getDefaultBlockProps(i.type), x = {
1224
1171
  _type: i.type,
1225
1172
  _id: p,
1226
1173
  ...u
1227
1174
  };
1228
- let h, g;
1229
- return c && (h = find(o, { _id: c }), x._parent = c, g = c), !canAcceptChildBlock(h == null ? void 0 : h._type, x._type) && h && (x._parent = h._parent, g = h._parent), n([x], g, d), r([x._id]), x;
1175
+ let h, m;
1176
+ return c && (h = find(o, { _id: c }), x._parent = c, m = c), !canAcceptChildBlock(h == null ? void 0 : h._type, x._type) && h && (x._parent = h._parent, m = h._parent), n([x], m, d), r([x._id]), x;
1230
1177
  },
1231
1178
  [n, a, o, r]
1232
1179
  ), addPredefinedBlock: a };
@@ -2285,8 +2232,7 @@ const useBlocksStoreManager = () => {
2285
2232
  return { match: n, getClasses: a };
2286
2233
  };
2287
2234
  function getMqForCls(o) {
2288
- if (isEmpty(o.trim()))
2289
- return "";
2235
+ if (isEmpty(o.trim())) return "";
2290
2236
  const r = o.match(/sm:|md:|lg:|xl:|2xl:/g);
2291
2237
  return get(r, 0, "xs").replace(":", "");
2292
2238
  }
@@ -2299,8 +2245,7 @@ function getPureClsName(o) {
2299
2245
  }
2300
2246
  const memoizedProps = {};
2301
2247
  function getPropertyForClass(o) {
2302
- if (isEmpty(o))
2303
- return "";
2248
+ if (isEmpty(o)) return "";
2304
2249
  if (memoizedProps[o])
2305
2250
  return memoizedProps[o];
2306
2251
  let r = "";
@@ -2371,12 +2316,12 @@ function getNewClasses(o = "", r = "", n = []) {
2371
2316
  const x = constructClassObject(u), h = find(a, pick(x, ["dark", "mq", "mod", "property"]));
2372
2317
  if (h && (a = filter(
2373
2318
  a,
2374
- (g) => g.fullCls !== (h == null ? void 0 : h.fullCls)
2375
- )), i.push(x), x.mq === "xs" && !x.dark && x.mod === "" && (l = filter(l, (g) => g.property !== x.property)), getBelongsToForClass(a, x) === "baseClasses" && !includes(IGNORED_BASES_CLASSES_PROPERTIES, x.property)) {
2376
- const g = find(l, pick(x, ["property"]));
2319
+ (m) => m.fullCls !== (h == null ? void 0 : h.fullCls)
2320
+ )), i.push(x), x.mq === "xs" && !x.dark && x.mod === "" && (l = filter(l, (m) => m.property !== x.property)), getBelongsToForClass(a, x) === "baseClasses" && !includes(IGNORED_BASES_CLASSES_PROPERTIES, x.property)) {
2321
+ const m = find(l, pick(x, ["property"]));
2377
2322
  h && (l = filter(
2378
2323
  l,
2379
- (j) => j.fullCls !== (g == null ? void 0 : g.fullCls)
2324
+ (E) => E.fullCls !== (m == null ? void 0 : m.fullCls)
2380
2325
  )), c.push({
2381
2326
  ...x,
2382
2327
  fullCls: x.cls,
@@ -2424,7 +2369,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2424
2369
  }
2425
2370
  r(a, c[0].props);
2426
2371
  },
2427
- [o]
2372
+ [o, r, n]
2428
2373
  );
2429
2374
  }, useStylingBreakpoint = () => useAtom$1(styleBreakpointAtom), canvasWidthAtom = atomWithStorage("canvasWidth", 800), canvasBreakpointAtom = atom$1((o) => {
2430
2375
  const r = o(canvasWidthAtom);
@@ -2467,11 +2412,11 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2467
2412
  (a, l = null) => {
2468
2413
  const i = [];
2469
2414
  each(a, (c) => {
2470
- const d = o.find((g) => g._id === c);
2471
- l || (l = d._parent);
2415
+ const d = o.find((m) => m._id === c);
2416
+ l ? l === "root" && (l = null) : l = d._parent;
2472
2417
  const x = filter(
2473
2418
  o,
2474
- (g) => isString(l) ? g._parent === l : !d._parent
2419
+ (m) => isString(l) ? m._parent === l : !m._parent
2475
2420
  ).indexOf(d) + 1, h = getDuplicatedBlocks(o, c, l);
2476
2421
  n(h, l, x), i.push(get(h, "0._id", ""));
2477
2422
  }), r(i);
@@ -2490,7 +2435,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2490
2435
  const [o] = useBlocksStore();
2491
2436
  return (r, n) => {
2492
2437
  var i;
2493
- const a = (i = find(o, { _id: n })) == null ? void 0 : i._type, l = first(r.map((c) => {
2438
+ const a = ((i = find(o, { _id: n })) == null ? void 0 : i._type) || null, l = first(r.map((c) => {
2494
2439
  var d;
2495
2440
  return (d = find(o, { _id: c })) == null ? void 0 : d._type;
2496
2441
  }));
@@ -2500,9 +2445,14 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2500
2445
  const o = useAtomValue$1(presentBlocksAtom), { moveBlocks: r } = useBlocksStoreUndoableActions();
2501
2446
  return useCallback(
2502
2447
  (n, a) => {
2503
- var d;
2504
- const l = Array.isArray(a) ? a[0] : a, i = o.find((p) => p._id === l), c = i && ((d = i.children) == null ? void 0 : d.length) || 0;
2505
- r(n, l, c);
2448
+ const l = Array.isArray(a) ? a[0] : a;
2449
+ if (a === "root") {
2450
+ const i = o == null ? void 0 : o.filter((c) => !c._parent);
2451
+ r(n, null, (i == null ? void 0 : i.length) || 0);
2452
+ } else {
2453
+ const i = o == null ? void 0 : o.filter((c) => c._parent === l);
2454
+ r(n, l, (i == null ? void 0 : i.length) || 0);
2455
+ }
2506
2456
  },
2507
2457
  [r, o]
2508
2458
  );
@@ -2537,7 +2487,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2537
2487
  const u = await navigator.clipboard.readText();
2538
2488
  if (u) {
2539
2489
  const x = JSON.parse(u);
2540
- has(x, "_chai_copied_blocks") ? i(x._chai_copied_blocks, p) : l({ title: "Error", description: "Nothing to paste" });
2490
+ has(x, "_chai_copied_blocks") ? i(x._chai_copied_blocks, p === "root" ? null : p) : l({ title: "Error", description: "Nothing to paste" });
2541
2491
  } else
2542
2492
  l({ title: "Error", description: "Nothing to paste" });
2543
2493
  } catch {
@@ -2565,13 +2515,13 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2565
2515
  const d = o(c), p = a;
2566
2516
  let { classes: u, baseClasses: x } = getSplitClasses(get(d, l.prop, "styles:,"));
2567
2517
  return each(p, (h) => {
2568
- const g = h.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), j = new RegExp(`(^| )${g}($| )`, "g");
2569
- u = u.replace(j, " ").replace(/ +/g, " ").trim();
2570
- const b = first(h.split(":"));
2571
- includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(h.split(":").pop().trim());
2518
+ const m = h.replace(/[\[\]\/\\{}()*+?.^$|]/g, "\\$&"), E = new RegExp(`(^| )${m}($| )`, "g");
2519
+ u = u.replace(E, " ").replace(/ +/g, " ").trim();
2520
+ const y = first(h.split(":"));
2521
+ includes(["2xl", "xl", "lg", "md", "sm"], y) && p.push(h.split(":").pop().trim());
2572
2522
  }), each(p, (h) => {
2573
- const g = new RegExp(`(^| )${h.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
2574
- x = x.replace(g, " ").replace(/ +/g, " ").trim();
2523
+ const m = new RegExp(`(^| )${h.replace("[", "\\[").replace("]", "\\]")}($| )`, "g");
2524
+ x = x.replace(m, " ").replace(/ +/g, " ").trim();
2575
2525
  }), {
2576
2526
  ids: [d._id],
2577
2527
  props: {
@@ -2590,8 +2540,7 @@ const useSelectedStylingBlocks = () => useAtom$1(selectedStylingBlocksAtom), get
2590
2540
  );
2591
2541
  }, selectedBlockAllClassesAtom = atom$1((o) => {
2592
2542
  const r = first(o(selectedStylingBlocksAtom)), n = o(selectedBlockAtom);
2593
- if (!r || r.blockId !== get(n, "_id", null))
2594
- return [];
2543
+ if (!r || r.blockId !== get(n, "_id", null)) return [];
2595
2544
  const l = get(n, r.prop, `${STYLES_KEY},`).replace(STYLES_KEY, "").split(",").join(" ");
2596
2545
  return filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
2597
2546
  }), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom$1((o) => {
@@ -2638,8 +2587,7 @@ const useLanguages = () => {
2638
2587
  };
2639
2588
  }, updatePropsForLanguage = memoize((o, r, n) => {
2640
2589
  const a = getRegisteredChaiBlock(get(n, "_type"));
2641
- if (!a)
2642
- return o;
2590
+ if (!a) return o;
2643
2591
  const l = { ...o };
2644
2592
  return forEach(keys(o), (i) => {
2645
2593
  if (includes(get(a, "i18nProps", []), i) && !isEmpty(r)) {
@@ -3022,39 +2970,39 @@ const getBlockWithChildren = (o, r) => {
3022
2970
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
3023
2971
  })
3024
2972
  ), addLangToPrompt = (o, r, n) => !r || n !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, r, r)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
3025
- 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(), x = p.length ? p : u, h = (g, j) => {
3026
- const b = cloneDeep(j.find((f) => f._id === g));
3027
- for (const f in b) {
3028
- const y = b[f];
3029
- typeof y == "string" && startsWith(y, STYLES_KEY) ? b[f] = compact(flattenDeep(y.replace(STYLES_KEY, "").split(","))).join(" ") : f !== "_id" && delete b[f];
2973
+ 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(), x = p.length ? p : u, h = (m, E) => {
2974
+ const y = cloneDeep(E.find((g) => g._id === m));
2975
+ for (const g in y) {
2976
+ const k = y[g];
2977
+ typeof k == "string" && startsWith(k, STYLES_KEY) ? y[g] = compact(flattenDeep(k.replace(STYLES_KEY, "").split(","))).join(" ") : g !== "_id" && delete y[g];
3030
2978
  }
3031
- return b;
2979
+ return y;
3032
2980
  };
3033
2981
  return {
3034
2982
  askAi: useCallback(
3035
- async (g, j, b, f) => {
2983
+ async (m, E, y, g) => {
3036
2984
  if (l) {
3037
2985
  r(!0), a(null);
3038
2986
  try {
3039
- const y = p === u ? "" : p, v = g === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(j, d)), p) : [h(j, d)], B = await l(g, addLangToPrompt(b, x, g), v, y), { blocks: A, error: S } = B;
3040
- if (S) {
3041
- a(S);
2987
+ const k = p === u ? "" : p, _ = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(E, d)), p) : [h(E, d)], A = await l(m, addLangToPrompt(y, x, m), _, k), { blocks: S, error: v } = A;
2988
+ if (v) {
2989
+ a(v);
3042
2990
  return;
3043
2991
  }
3044
- if (g === "styles") {
3045
- const k = A.map((T) => {
3046
- for (const _ in T)
3047
- _ !== "_id" && (T[_] = `${STYLES_KEY},${T[_]}`);
3048
- return T;
2992
+ if (m === "styles") {
2993
+ const R = S.map((f) => {
2994
+ for (const j in f)
2995
+ j !== "_id" && (f[j] = `${STYLES_KEY},${f[j]}`);
2996
+ return f;
3049
2997
  });
3050
- c(k);
2998
+ c(R);
3051
2999
  } else
3052
- i(A);
3053
- f && f(B);
3054
- } catch (y) {
3055
- a(y);
3000
+ i(S);
3001
+ g && g(A);
3002
+ } catch (k) {
3003
+ a(k);
3056
3004
  } finally {
3057
- r(!1), f && f();
3005
+ r(!1), g && g();
3058
3006
  }
3059
3007
  }
3060
3008
  },
@@ -3083,16 +3031,13 @@ const getBlockWithChildren = (o, r) => {
3083
3031
  }, wrapperBlockAtom = atom$1((o) => {
3084
3032
  var c;
3085
3033
  const r = o(presentBlocksAtom), n = o(selectedBlockIdsAtom), a = n.length === 1 ? n[0] : null;
3086
- if (!a)
3087
- return null;
3034
+ if (!a) return null;
3088
3035
  const l = find(r, { _id: a });
3089
- if (!l)
3090
- return null;
3036
+ if (!l) return null;
3091
3037
  let i = l._parent;
3092
3038
  for (; i; ) {
3093
3039
  const d = find(r, { _id: i });
3094
- if (!d)
3095
- return null;
3040
+ if (!d) return null;
3096
3041
  if ((c = getRegisteredChaiBlock(d._type)) != null && c.wrapper)
3097
3042
  return d;
3098
3043
  i = d._parent;
@@ -3165,11 +3110,11 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAto
3165
3110
  if (d < r) {
3166
3111
  const u = parseFloat((d / r).toFixed(2).toString());
3167
3112
  let x = {};
3168
- const h = p * u, g = d * u;
3113
+ const h = p * u, m = d * u;
3169
3114
  p && (x = {
3170
3115
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3171
3116
  height: 100 + (p - h) / h * 100 + "%",
3172
- width: 100 + (d - g) / g * 100 + "%"
3117
+ width: 100 + (d - m) / m * 100 + "%"
3173
3118
  }), i({
3174
3119
  position: "relative",
3175
3120
  top: 0,
@@ -3201,7 +3146,7 @@ class Content extends Component {
3201
3146
  return Children.only(this.props.children);
3202
3147
  }
3203
3148
  }
3204
- H(Content, "propTypes", {
3149
+ O(Content, "propTypes", {
3205
3150
  children: PropTypes.element.isRequired,
3206
3151
  contentDidMount: PropTypes.func.isRequired,
3207
3152
  contentDidUpdate: PropTypes.func.isRequired
@@ -3209,17 +3154,17 @@ H(Content, "propTypes", {
3209
3154
  class Frame extends Component {
3210
3155
  constructor(n, a) {
3211
3156
  super(n, a);
3212
- H(this, "setRef", (n) => {
3157
+ O(this, "setRef", (n) => {
3213
3158
  this.nodeRef.current = n;
3214
3159
  const { forwardedRef: a } = this.props;
3215
3160
  typeof a == "function" ? a(n) : a && (a.current = n);
3216
3161
  });
3217
- H(this, "handleLoad", () => {
3162
+ O(this, "handleLoad", () => {
3218
3163
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
3219
3164
  });
3220
3165
  // In certain situations on a cold cache DOMContentLoaded never gets called
3221
3166
  // fallback to an interval to check if that's the case
3222
- H(this, "loadCheck", () => setInterval(() => {
3167
+ O(this, "loadCheck", () => setInterval(() => {
3223
3168
  this.handleLoad();
3224
3169
  }, 500));
3225
3170
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -3260,7 +3205,7 @@ class Frame extends Component {
3260
3205
  // also inject into the body and can mess up React. For this reason
3261
3206
  // initialContent is expected to have a div inside of the body
3262
3207
  // element that we render react into.
3263
- H(Frame, "propTypes", {
3208
+ O(Frame, "propTypes", {
3264
3209
  style: PropTypes.object,
3265
3210
  // eslint-disable-line
3266
3211
  head: PropTypes.node,
@@ -3270,7 +3215,7 @@ H(Frame, "propTypes", {
3270
3215
  contentDidMount: PropTypes.func,
3271
3216
  contentDidUpdate: PropTypes.func,
3272
3217
  children: PropTypes.oneOfType([PropTypes.element, PropTypes.arrayOf(PropTypes.element)])
3273
- }), H(Frame, "defaultProps", {
3218
+ }), O(Frame, "defaultProps", {
3274
3219
  style: {},
3275
3220
  head: null,
3276
3221
  children: void 0,
@@ -3297,14 +3242,12 @@ function getOrientation(o) {
3297
3242
  const draggedBlockAtom = atom$1(null), dropTargetBlockIdAtom = atom$1(null);
3298
3243
  let iframeDocument = null, possiblePositions = [], dropTarget = null, dropIndex = null;
3299
3244
  const positionPlaceholder = (o, r, n) => {
3300
- if (!iframeDocument || !o)
3301
- return;
3245
+ if (!iframeDocument || !o) return;
3302
3246
  const a = iframeDocument == null ? void 0 : iframeDocument.getElementById("placeholder"), l = possiblePositions.map(([p]) => p), i = l.reduce(
3303
3247
  (p, u) => Math.abs(u - n) < Math.abs(p - n) ? u : p,
3304
3248
  0
3305
3249
  ), c = l.indexOf(i);
3306
- if (!possiblePositions[c])
3307
- return;
3250
+ if (!possiblePositions[c]) return;
3308
3251
  const d = possiblePositions[c];
3309
3252
  a.style.width = r === "vertical" ? d[2] + "px" : "2px", a.style.height = r === "vertical" ? "2px" : d[2] + "px", a.style.display = "block", r === "vertical" ? (a.style.top = d[0] + "px", a.style.left = d[1] + "px") : (a.style.top = d[1] + "px", a.style.left = d[0] + "px");
3310
3253
  };
@@ -3318,8 +3261,7 @@ function calculateDropIndex(o, r) {
3318
3261
  const calculatePossiblePositions = (o) => {
3319
3262
  const n = getOrientation(o) === "horizontal";
3320
3263
  possiblePositions = [], Array.from(o.children).forEach((a, l) => {
3321
- if (a.classList.contains("pointer-events-none"))
3322
- return;
3264
+ if (a.classList.contains("pointer-events-none")) return;
3323
3265
  const i = n ? a.offsetLeft : a.offsetTop, c = n ? [a.offsetTop, a.clientHeight] : [a.offsetLeft, a.clientWidth];
3324
3266
  if (possiblePositions.push([i, c[0], c[1]]), l === o.children.length - 1) {
3325
3267
  const d = n ? a.offsetLeft + a.clientWidth : a.offsetTop + a.clientHeight;
@@ -3346,40 +3288,39 @@ function removeDataDrop() {
3346
3288
  }
3347
3289
  const useDnd = () => {
3348
3290
  const { document: o } = useFrame(), [r, n] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
3349
- if (!useFeature("dnd"))
3350
- return {};
3291
+ if (!useFeature("dnd")) return {};
3351
3292
  const h = () => {
3352
3293
  removePlaceholder(), n(!1), p(null), u(null), possiblePositions = [];
3353
3294
  };
3354
3295
  return iframeDocument = o, {
3355
3296
  isDragging: r,
3356
- onDragOver: (g) => {
3357
- g.preventDefault(), g.stopPropagation(), throttledDragOver(g);
3297
+ onDragOver: (m) => {
3298
+ m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
3358
3299
  },
3359
- onDrop: (g) => {
3360
- var S;
3361
- const j = dropTarget, f = getOrientation(j) === "vertical" ? g.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : g.clientX;
3362
- dropIndex = calculateDropIndex(f, possiblePositions);
3363
- const y = d, v = j.getAttribute("data-block-id"), B = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3364
- if ((y == null ? void 0 : y._id) === v || !B) {
3300
+ onDrop: (m) => {
3301
+ var v;
3302
+ const E = dropTarget, g = getOrientation(E) === "vertical" ? m.clientY + ((v = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : v.scrollY) : m.clientX;
3303
+ dropIndex = calculateDropIndex(g, possiblePositions);
3304
+ const k = d, _ = E.getAttribute("data-block-id"), A = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3305
+ if ((k == null ? void 0 : k._id) === _ || !A) {
3365
3306
  h();
3366
3307
  return;
3367
3308
  }
3368
- if (!has(y, "_id")) {
3369
- a(y, v === "canvas" ? null : v, dropIndex), setTimeout(h, 300);
3309
+ if (!has(k, "_id")) {
3310
+ a(k, _ === "canvas" ? null : _, dropIndex), setTimeout(h, 300);
3370
3311
  return;
3371
3312
  }
3372
- let A = j.getAttribute("data-block-id");
3373
- A === null && (A = g.target.parentElement.getAttribute("data-block-id")), c([y._id], A === "canvas" ? null : A, dropIndex), h(), setTimeout(removePlaceholder, 300);
3313
+ let S = E.getAttribute("data-block-id");
3314
+ S === null && (S = m.target.parentElement.getAttribute("data-block-id")), c([k._id], S === "canvas" ? null : S, dropIndex), h(), setTimeout(removePlaceholder, 300);
3374
3315
  },
3375
- onDragEnter: (g) => {
3376
- const j = g, b = j.target;
3377
- dropTarget = b;
3378
- const f = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
3379
- u(f), j.stopPropagation(), j.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), n(!0), l(""), i([]);
3316
+ onDragEnter: (m) => {
3317
+ const E = m, y = E.target;
3318
+ dropTarget = y;
3319
+ const g = y.getAttribute("data-block-id"), k = y.getAttribute("data-dnd-dragged") !== "yes";
3320
+ u(g), E.stopPropagation(), E.preventDefault(), possiblePositions = [], k && calculatePossiblePositions(y), n(!0), l(""), i([]);
3380
3321
  },
3381
- onDragLeave: (g) => {
3382
- g.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
3322
+ onDragLeave: (m) => {
3323
+ m.target.getAttribute("data-block-id") === "canvas" && (u(null), n(!1), removePlaceholder(), possiblePositions = []);
3383
3324
  }
3384
3325
  };
3385
3326
  };
@@ -3400,31 +3341,29 @@ const useHandleCanvasDblClick = () => {
3400
3341
  const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], r = useUpdateBlocksProps(), [n, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight();
3401
3342
  return (i) => {
3402
3343
  var h;
3403
- if (n)
3404
- return;
3344
+ if (n) return;
3405
3345
  const c = getTargetedBlock(i.target), d = c.getAttribute("data-block-type");
3406
3346
  if (!d || !o.includes(d))
3407
3347
  return;
3408
3348
  const p = c.cloneNode(!0);
3409
- c.style.display = "none", Array.from(p.attributes).forEach((g) => {
3410
- g.name !== "class" && p.removeAttribute(g.name);
3349
+ c.style.display = "none", Array.from(p.attributes).forEach((m) => {
3350
+ m.name !== "class" && p.removeAttribute(m.name);
3411
3351
  }), d === "Text" && (p.style.display = "inline-block"), c.parentNode.insertBefore(p, c.nextSibling);
3412
3352
  const u = new Quill(p, { placeholder: "Type here..." });
3413
3353
  function x() {
3414
- const g = u.getText(0, u.getLength());
3415
- r([c.getAttribute("data-block-id")], { content: g }), c.removeAttribute("style"), p.removeEventListener("blur", x, !0), destroyQuill(u), a(""), l(), p.remove();
3354
+ const m = u.getText(0, u.getLength());
3355
+ r([c.getAttribute("data-block-id")], { content: m }), c.removeAttribute("style"), p.removeEventListener("blur", x, !0), destroyQuill(u), a(""), l(), p.remove();
3416
3356
  }
3417
- p.addEventListener("blur", x, !0), p.addEventListener("click", (g) => {
3418
- g.stopPropagation();
3419
- }), p.addEventListener("keydown", (g) => {
3420
- (g.key === "Enter" || g.key === "Escape") && x();
3357
+ p.addEventListener("blur", x, !0), p.addEventListener("click", (m) => {
3358
+ m.stopPropagation();
3359
+ }), p.addEventListener("keydown", (m) => {
3360
+ (m.key === "Enter" || m.key === "Escape") && x();
3421
3361
  }), u.focus(), (h = p.querySelector(".ql-clipboard")) == null || h.remove(), a(c.getAttribute("data-block-id"));
3422
3362
  };
3423
3363
  }, useHandleCanvasClick = () => {
3424
3364
  const [, o] = useSelectedStylingBlocks(), [r, n] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
3425
3365
  return (c) => {
3426
- if (a)
3427
- return;
3366
+ if (a) return;
3428
3367
  c.stopPropagation();
3429
3368
  const d = getTargetedBlock(c.target);
3430
3369
  if (d != null && d.getAttribute("data-block-id") && (d == null ? void 0 : d.getAttribute("data-block-id")) === "container") {
@@ -3443,8 +3382,7 @@ const useHandleCanvasDblClick = () => {
3443
3382
  }, useHandleMouseMove = () => {
3444
3383
  const [o] = useAtom$1(inlineEditingActiveAtom), { highlightBlock: r } = useBlockHighlight();
3445
3384
  return throttle((n) => {
3446
- if (o)
3447
- return;
3385
+ if (o) return;
3448
3386
  const a = getTargetedBlock(n.target);
3449
3387
  a && r(a);
3450
3388
  }, 20);
@@ -3459,10 +3397,10 @@ const useHandleCanvasDblClick = () => {
3459
3397
  return;
3460
3398
  const h = getElementByDataBlockId(r, first(n));
3461
3399
  if (h) {
3462
- const g = h.getAttribute("data-style-prop");
3463
- if (g) {
3464
- const j = h.getAttribute("data-style-id"), b = h.getAttribute("data-block-parent");
3465
- l([{ id: j, prop: g, blockId: b }]);
3400
+ const m = h.getAttribute("data-style-prop");
3401
+ if (m) {
3402
+ const E = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3403
+ l([{ id: E, prop: m, blockId: y }]);
3466
3404
  }
3467
3405
  }
3468
3406
  }, 100);
@@ -3483,23 +3421,23 @@ const useHandleCanvasDblClick = () => {
3483
3421
  }
3484
3422
  );
3485
3423
  }, getElementByDataBlockId = (o, r) => o.querySelector(`[data-block-id="${r}"]`), useKeyEventWatcher = (o) => {
3486
- const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: x, pasteBlocks: h } = usePasteBlocks(), g = o ? { document: o } : {};
3424
+ const [r, n] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: x, pasteBlocks: h } = usePasteBlocks(), m = o ? { document: o } : {};
3487
3425
  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(
3488
3426
  "ctrl+v,command+v",
3489
3427
  () => {
3490
3428
  x(r[0]) && h(r);
3491
3429
  },
3492
- { ...g, preventDefault: !0 },
3430
+ { ...m, preventDefault: !0 },
3493
3431
  [r, x, h]
3494
- ), useHotkeys("esc", () => n([]), g, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...g, preventDefault: !0 }, [
3432
+ ), useHotkeys("esc", () => n([]), m, [n]), useHotkeys("ctrl+d,command+d", () => i(r), { ...m, preventDefault: !0 }, [
3495
3433
  r,
3496
3434
  i
3497
3435
  ]), useHotkeys(
3498
3436
  "del, backspace",
3499
- (j) => {
3500
- j.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3437
+ (E) => {
3438
+ E.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(r);
3501
3439
  },
3502
- g,
3440
+ m,
3503
3441
  [r, l]
3504
3442
  );
3505
3443
  }, KeyboardHandler = () => {
@@ -3512,7 +3450,7 @@ const useHandleCanvasDblClick = () => {
3512
3450
  };
3513
3451
  class PubSub {
3514
3452
  constructor() {
3515
- H(this, "subscribers", /* @__PURE__ */ new Map());
3453
+ O(this, "subscribers", /* @__PURE__ */ new Map());
3516
3454
  }
3517
3455
  subscribe(r, n) {
3518
3456
  return this.subscribers.has(r) || this.subscribers.set(r, /* @__PURE__ */ new Set()), this.subscribers.get(r).add(n), () => {
@@ -3552,7 +3490,7 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3552
3490
  }
3553
3491
  });
3554
3492
  useResizeObserver(o, () => x(), o !== null);
3555
- const h = get(r, "_parent", null), g = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
3493
+ const h = get(r, "_parent", null), m = isEmpty(get(r, "_name", "")) ? get(r, "_type", "") : get(r, "_name", "");
3556
3494
  return !o || !r || d ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3557
3495
  "div",
3558
3496
  {
@@ -3560,13 +3498,13 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3560
3498
  tabIndex: 0,
3561
3499
  ref: u.setFloating,
3562
3500
  style: p,
3563
- onClick: (j) => {
3564
- j.stopPropagation(), j.preventDefault();
3501
+ onClick: (E) => {
3502
+ E.stopPropagation(), E.preventDefault();
3565
3503
  },
3566
- onMouseEnter: (j) => {
3567
- j.stopPropagation(), i(null);
3504
+ onMouseEnter: (E) => {
3505
+ E.stopPropagation(), i(null);
3568
3506
  },
3569
- onKeyDown: (j) => j.stopPropagation(),
3507
+ onKeyDown: (E) => E.stopPropagation(),
3570
3508
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3571
3509
  children: [
3572
3510
  h && /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3578,7 +3516,7 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3578
3516
  }
3579
3517
  }
3580
3518
  ),
3581
- /* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label: g, block: r }),
3519
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BlockActionLabel, { label: m, block: r }),
3582
3520
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 px-1", children: [
3583
3521
  canAddChildBlock(get(r, "_type", "")) && /* @__PURE__ */ jsxRuntimeExports.jsx(
3584
3522
  PlusIcon,
@@ -3598,7 +3536,7 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3598
3536
  d == null ? void 0 : d.getElementById("selected-block")
3599
3537
  ), [h] = useState(
3600
3538
  d == null ? void 0 : d.getElementById("selected-styling-block")
3601
- ), [g] = useState(
3539
+ ), [m] = useState(
3602
3540
  d == null ? void 0 : d.getElementById("dragged-block")
3603
3541
  );
3604
3542
  useEffect(() => {
@@ -3623,42 +3561,42 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3623
3561
  forms,
3624
3562
  aspectRatio,
3625
3563
  containerQueries,
3626
- plugin(function({ addBase: f, theme: y }) {
3627
- f({
3564
+ plugin(function({ addBase: g, theme: k }) {
3565
+ g({
3628
3566
  "h1,h2,h3,h4,h5,h6": {
3629
- fontFamily: y("fontFamily.heading")
3567
+ fontFamily: k("fontFamily.heading")
3630
3568
  },
3631
3569
  body: {
3632
- fontFamily: y("fontFamily.body"),
3633
- color: y("colors.foreground"),
3634
- backgroundColor: y("colors.background")
3570
+ fontFamily: k("fontFamily.body"),
3571
+ color: k("colors.foreground"),
3572
+ backgroundColor: k("colors.background")
3635
3573
  }
3636
3574
  });
3637
3575
  })
3638
3576
  ]
3639
3577
  });
3640
3578
  }, [o, r, p]), useEffect(() => {
3641
- x && (x.textContent = `${map(n, (f) => `[data-block-id="${f}"]`).join(",")}{
3579
+ x && (x.textContent = `${map(n, (g) => `[data-block-id="${g}"]`).join(",")}{
3642
3580
  outline: 1px solid ${n.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3643
3581
  }`);
3644
3582
  }, [n, x]), useEffect(() => {
3645
- g.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3646
- }, [i, g]), useEffect(() => {
3583
+ m.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3584
+ }, [i, m]), useEffect(() => {
3647
3585
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3648
3586
  }, [u]), useEffect(() => {
3649
- h && (h.textContent = `${map(l, ({ id: f }) => `[data-style-id="${f}"]`).join(",")}{
3587
+ h && (h.textContent = `${map(l, ({ id: g }) => `[data-style-id="${g}"]`).join(",")}{
3650
3588
  outline: 1px solid orange !important; outline-offset: -1px;
3651
3589
  }`);
3652
3590
  }, [l, h]), useEffect(() => {
3653
3591
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3654
3592
  }, [c, d]);
3655
- const j = useMemo(
3593
+ const E = useMemo(
3656
3594
  () => getChaiThemeCssVariables(o),
3657
3595
  [o]
3658
- ), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3596
+ ), y = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3659
3597
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
3660
- /* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children: j }),
3661
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
3598
+ /* @__PURE__ */ jsxRuntimeExports.jsx("style", { id: "chai-theme", children: E }),
3599
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: y } })
3662
3600
  ] });
3663
3601
  }, useChaiExternalData = () => useAtom$1(chaiExternalDataAtom), useCanvasSettings = () => useAtom$1(canvasSettingsAtom), isVisibleAtBreakpoint = (o, r) => {
3664
3602
  const n = ["xs", "sm", "md", "lg", "xl", "2xl"], a = n.indexOf(r), l = o.split(" ");
@@ -3670,11 +3608,11 @@ const pubsub = new PubSub(), BlockActionLabel = ({ block: o, label: r }) => {
3670
3608
  if (u <= a) {
3671
3609
  const x = ["block", "flex", "inline", "inline-block", "inline-flex", "grid", "table"], h = ["hidden"];
3672
3610
  if (x.includes(p))
3673
- for (let g = u; g < n.length; g++)
3674
- i[g] = !0;
3611
+ for (let m = u; m < n.length; m++)
3612
+ i[m] = !0;
3675
3613
  else if (h.includes(p))
3676
- for (let g = u; g < n.length; g++)
3677
- i[g] = !1;
3614
+ for (let m = u; m < n.length; m++)
3615
+ i[m] = !1;
3678
3616
  }
3679
3617
  }
3680
3618
  return i[a];
@@ -3725,79 +3663,75 @@ const getRuntimeProps = memoize((o) => {
3725
3663
  return Object.fromEntries(Object.entries(n).filter(([, a]) => get(a, "runtime", !1)));
3726
3664
  });
3727
3665
  function isDescendant(o, r, n) {
3728
- if (!find(n, { _id: o }))
3729
- return !1;
3666
+ if (!find(n, { _id: o })) return !1;
3730
3667
  const l = filter(n, { _parent: o });
3731
3668
  return l.some((i) => i._id === r) ? !0 : l.some((i) => isDescendant(i._id, r, n));
3732
3669
  }
3733
3670
  const RenderGlobalBlock = ({ blocks: o, allBlocks: r }) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: o });
3734
3671
  function applyLanguage(o, r, n) {
3735
- if (isEmpty(r))
3736
- return o;
3672
+ if (isEmpty(r)) return o;
3737
3673
  const a = cloneDeep(o);
3738
3674
  return forEach(keys(a), (l) => {
3739
3675
  includes(get(n, "i18nProps", []), l) && !isEmpty(r) && (a[l] = get(a, `${l}-${r}`, a[l]));
3740
3676
  }), a;
3741
3677
  }
3742
3678
  function BlocksRendererStatic({ blocks: o, allBlocks: r }) {
3743
- const { selectedLang: n } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: x } = useGlobalBlocksStore(), h = useCallback((f) => getStyleAttrs(f, d), [d]), [g] = useChaiExternalData(), [j] = useAtom$1(inlineEditingActiveAtom), b = useCallback(
3744
- (f) => f.reduce((y, v) => {
3745
- const B = get(p, v, {});
3746
- return { ...y, ...B };
3679
+ const { selectedLang: n } = useLanguages(), [a] = useAtom$1(xShowBlocksAtom), [l] = useCutBlockIds(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), [, d] = useCanvasWidth(), [p] = useCanvasSettings(), [u] = useHiddenBlockIds(), { getGlobalBlocks: x } = useGlobalBlocksStore(), h = useCallback((g) => getStyleAttrs(g, d), [d]), [m] = useChaiExternalData(), [E] = useAtom$1(inlineEditingActiveAtom), y = useCallback(
3680
+ (g) => g.reduce((k, _) => {
3681
+ const A = get(p, _, {});
3682
+ return { ...k, ...A };
3747
3683
  }, {}),
3748
3684
  [p]
3749
3685
  );
3750
3686
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: React__default.Children.toArray(
3751
- o.map((f, y) => {
3752
- if (j === f._id || u.includes(f._id))
3753
- return null;
3754
- const v = {}, B = filter(r, { _parent: f._id });
3755
- if (v.children = B.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: B }) : null, f._type === "GlobalBlock") {
3756
- const C = x(f);
3757
- v.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(C, (N) => !N._parent), allBlocks: C });
3687
+ o.map((g, k) => {
3688
+ if (E === g._id || u.includes(g._id)) return null;
3689
+ const _ = {}, A = filter(r, { _parent: g._id });
3690
+ if (_.children = A.length > 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx(BlocksRendererStatic, { allBlocks: r, blocks: A }) : null, g._type === "GlobalBlock") {
3691
+ const N = x(g);
3692
+ _.children = /* @__PURE__ */ jsxRuntimeExports.jsx(RenderGlobalBlock, { blocks: filter(N, (D) => !D._parent), allBlocks: N });
3758
3693
  }
3759
- const A = getRegisteredChaiBlock(f._type), S = get(A, "component", null);
3760
- if (isNull(S))
3761
- return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${f == null ? void 0 : f._type} not registered -->` });
3762
- const k = has(A, "getBlockStateFrom") ? A == null ? void 0 : A.getBlockStateFrom(f, r) : [], T = b(k), _ = h(f);
3763
- if (get(_, "__isHidden", !1) && !includes(a, f._id))
3694
+ const S = getRegisteredChaiBlock(g._type), v = get(S, "component", null);
3695
+ if (isNull(v)) return /* @__PURE__ */ jsxRuntimeExports.jsx("noscript", { children: `<!-- ${g == null ? void 0 : g._type} not registered -->` });
3696
+ const R = has(S, "getBlockStateFrom") ? S == null ? void 0 : S.getBlockStateFrom(g, r) : [], f = y(R), j = h(g);
3697
+ if (get(j, "__isHidden", !1) && !includes(a, g._id))
3764
3698
  return null;
3765
- const P = i && isDescendant(i._id, f._id, r), E = {
3699
+ const w = i && isDescendant(i._id, g._id, r), C = {
3766
3700
  blockProps: {
3767
- ...includes(a, f._id) ? { "force-show": "" } : {},
3768
- "data-block-id": f._id,
3769
- "data-block-type": f._type,
3701
+ ...includes(a, g._id) ? { "force-show": "" } : {},
3702
+ "data-block-id": g._id,
3703
+ "data-block-type": g._type,
3770
3704
  ...i ? (
3771
3705
  // @ts-ignore
3772
3706
  {
3773
- "data-dnd": canAcceptChildBlock(f._type, i == null ? void 0 : i._type) ? "yes" : "no",
3774
- "data-dnd-dragged": i._id === f._id || P ? "yes" : "no"
3707
+ "data-dnd": canAcceptChildBlock(g._type, i == null ? void 0 : i._type) ? "yes" : "no",
3708
+ "data-dnd-dragged": i._id === g._id || w ? "yes" : "no"
3775
3709
  }
3776
3710
  ) : {},
3777
- ...c === f._id && !P ? { "data-drop": "yes" } : {},
3778
- ...includes(l, f._id) ? { "data-cut-block": "yes" } : {}
3711
+ ...c === g._id && !w ? { "data-drop": "yes" } : {},
3712
+ ...includes(l, g._id) ? { "data-cut-block": "yes" } : {}
3779
3713
  },
3780
- index: y,
3781
- ...applyBindings(applyLanguage(f, n, A), g),
3782
- ...omit(_, ["__isHidden"]),
3783
- ...v,
3714
+ index: k,
3715
+ ...applyBindings(applyLanguage(g, n, S), m),
3716
+ ...omit(j, ["__isHidden"]),
3717
+ ..._,
3784
3718
  inBuilder: !0,
3785
- blockState: T,
3719
+ blockState: f,
3786
3720
  lang: n
3787
3721
  };
3788
- if (has(A, "dataProvider"))
3722
+ if (has(S, "dataProvider"))
3789
3723
  return /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3790
3724
  AsyncPropsBlock,
3791
3725
  {
3792
3726
  lang: n,
3793
- dataProvider: A.dataProvider,
3794
- block: f,
3795
- component: S,
3796
- props: E
3727
+ dataProvider: S.dataProvider,
3728
+ block: g,
3729
+ component: v,
3730
+ props: C
3797
3731
  }
3798
3732
  ) });
3799
- const R = getRuntimeProps(f._type);
3800
- return R ? /* @__PURE__ */ jsxRuntimeExports.jsx(RuntimePropsBlock, { runtimeProps: R, block: f, component: S, props: E }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(S, E) });
3733
+ const B = getRuntimeProps(g._type);
3734
+ return B ? /* @__PURE__ */ jsxRuntimeExports.jsx(RuntimePropsBlock, { runtimeProps: B, block: g, component: v, props: C }) : /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: React__default.createElement(v, C) });
3801
3735
  })
3802
3736
  ) });
3803
3737
  }
@@ -3857,47 +3791,46 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3857
3791
  };
3858
3792
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { id: "main-content", onClick: d, className: "h-full w-full p-8 pb-0", ref: i, children: o });
3859
3793
  }, getElementByStyleId = (o, r) => o.querySelector(`[data-style-id="${r}"]`), StaticCanvas = () => {
3860
- const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, h] = useState([]), [, g] = useState([]), [, j] = useAtom$1(canvasIframeAtom), [b, f] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), v = useBuilderProp("htmlDir", "ltr"), B = (k) => {
3861
- p((T) => ({ ...T, width: k }));
3794
+ const [o] = useAtom$1(networkModeAtom), [r] = useCanvasWidth(), [, n] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [x, h] = useState([]), [, m] = useState([]), [, E] = useAtom$1(canvasIframeAtom), [y, g] = useSelectedStylingBlocks(), k = useBuilderProp("loading", !1), _ = useBuilderProp("htmlDir", "ltr"), A = (R) => {
3795
+ p((f) => ({ ...f, width: R }));
3862
3796
  };
3863
3797
  useEffect(() => {
3864
- if (!c.current)
3865
- return;
3866
- const { clientWidth: k, clientHeight: T } = c.current;
3867
- p({ width: k, height: T });
3798
+ if (!c.current) return;
3799
+ const { clientWidth: R, clientHeight: f } = c.current;
3800
+ p({ width: R, height: f });
3868
3801
  }, [c, r]);
3869
- const A = (k, T = 0) => {
3870
- const { top: _ } = k.getBoundingClientRect();
3871
- return _ + T >= 0 && _ - T <= window.innerHeight;
3802
+ const S = (R, f = 0) => {
3803
+ const { top: j } = R.getBoundingClientRect();
3804
+ return j + f >= 0 && j - f <= window.innerHeight;
3872
3805
  };
3873
3806
  useEffect(() => {
3874
- var k, T;
3807
+ var R, f;
3875
3808
  if (a && a.type !== "Multiple" && i.current) {
3876
- const _ = getElementByDataBlockId(i.current.contentDocument, a._id);
3877
- _ && (A(_) || (T = (k = i.current) == null ? void 0 : k.contentWindow) == null || T.scrollTo({ top: _.offsetTop, behavior: "smooth" }), h([_]));
3809
+ const j = getElementByDataBlockId(i.current.contentDocument, a._id);
3810
+ j && (S(j) || (f = (R = i.current) == null ? void 0 : R.contentWindow) == null || f.scrollTo({ top: j.offsetTop, behavior: "smooth" }), h([j]));
3878
3811
  }
3879
3812
  }, [a]), useEffect(() => {
3880
- if (!isEmpty(b) && i.current) {
3881
- const k = getElementByStyleId(
3813
+ if (!isEmpty(y) && i.current) {
3814
+ const R = getElementByStyleId(
3882
3815
  i.current.contentDocument,
3883
- first(b).id
3816
+ first(y).id
3884
3817
  );
3885
- g(k ? [k] : [null]);
3818
+ m(R ? [R] : [null]);
3886
3819
  } else
3887
- g([null]);
3888
- }, [b]);
3889
- const S = useMemo(() => {
3890
- let k = IframeInitialContent;
3891
- return k = k.replace("__HTML_DIR__", v), o === "offline" && (k = k.replace(
3820
+ m([null]);
3821
+ }, [y]);
3822
+ const v = useMemo(() => {
3823
+ let R = IframeInitialContent;
3824
+ return R = R.replace("__HTML_DIR__", _), o === "offline" && (R = R.replace(
3892
3825
  "https://old.chaibuilder.com/offline/tailwind.cdn.js",
3893
3826
  "/offline/tailwind.cdn.js"
3894
- ), k = k.replace("https://unpkg.com/aos@next/dist/aos.css", "/offline/aos.css"), k = k.replace("https://unpkg.com/aos@next/dist/aos.js", "/offline/aos.js")), k;
3895
- }, [o, v]);
3896
- return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: B, onResize: B, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3827
+ ), R = R.replace("https://unpkg.com/aos@next/dist/aos.css", "/offline/aos.css"), R = R.replace("https://unpkg.com/aos@next/dist/aos.js", "/offline/aos.js")), R;
3828
+ }, [o, _]);
3829
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(ResizableCanvasWrapper, { onMount: A, onResize: A, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
3897
3830
  "div",
3898
3831
  {
3899
3832
  onClick: () => {
3900
- n([]), f([]);
3833
+ n([]), g([]);
3901
3834
  },
3902
3835
  onMouseLeave: () => setTimeout(() => l(""), 300),
3903
3836
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3905,12 +3838,12 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3905
3838
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
3906
3839
  ChaiFrame,
3907
3840
  {
3908
- contentDidMount: () => j(i.current),
3841
+ contentDidMount: () => E(i.current),
3909
3842
  ref: i,
3910
3843
  id: "canvas-iframe",
3911
3844
  style: { ...u, ...isEmpty(u) ? { width: `${r}px` } : {} },
3912
3845
  className: "relative mx-auto box-content h-full w-full max-w-full shadow-lg transition-all duration-300 ease-linear",
3913
- initialContent: S,
3846
+ initialContent: v,
3914
3847
  children: [
3915
3848
  /* @__PURE__ */ jsxRuntimeExports.jsx(KeyboardHandler, {}),
3916
3849
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -3922,7 +3855,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3922
3855
  ),
3923
3856
  /* @__PURE__ */ jsxRuntimeExports.jsx(HeadTags, {}),
3924
3857
  /* @__PURE__ */ jsxRuntimeExports.jsx(Provider, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Canvas, { children: [
3925
- y ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
3858
+ k ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full p-4", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx(StaticBlocksRenderer, {}),
3926
3859
  /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlockAtBottom, {}),
3927
3860
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
3928
3861
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
@@ -3940,7 +3873,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
3940
3873
  )
3941
3874
  }
3942
3875
  ) });
3943
- }, StaticCanvas$1 = StaticCanvas, FallbackError = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3876
+ }, FallbackError = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3944
3877
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3945
3878
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: "Please try again." })
3946
3879
  ] }) }), TypeIcon = (o) => {
@@ -4040,14 +3973,14 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4040
3973
  l !== o.length - 1 && /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
4041
3974
  ] }, l))
4042
3975
  ] }) });
4043
- }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-f8Ud0q2D.js")), CanvasArea = () => {
3976
+ }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-iLT-zqjH.js")), CanvasArea = () => {
4044
3977
  const [o] = useCodeEditor(), r = useBuilderProp("onError", noop);
4045
3978
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
4046
- /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx(StaticCanvas$1, {}) }) }),
3979
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(FallbackError, {}), onError: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx(StaticCanvas, {}) }) }),
4047
3980
  o ? /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Resizable, { enable: { top: !0, bottom: !1 }, className: "max-h-[400px] min-h-[200px]", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CodeEditor$1, {}) }) }) : null,
4048
3981
  /* @__PURE__ */ jsxRuntimeExports.jsx(Breadcrumb, {})
4049
3982
  ] }) });
4050
- }, CanvasArea$1 = CanvasArea, FONTS = [
3983
+ }, FONTS = [
4051
3984
  { title: "Roboto", value: "Roboto" },
4052
3985
  { title: "Open Sans", value: "Open Sans" },
4053
3986
  { title: "Montserrat", value: "Montserrat" },
@@ -4114,7 +4047,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4114
4047
  children: FONTS.map((a) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: a.value, children: a.title }, a.value))
4115
4048
  }
4116
4049
  )
4117
- ] }), FontSelector$1 = FontSelector, ColorPickerInput = ({ value: o, onChange: r }) => {
4050
+ ] }), ColorPickerInput = ({ value: o, onChange: r }) => {
4118
4051
  const n = debounce((a) => r(a), 200);
4119
4052
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
4120
4053
  "div",
@@ -4135,7 +4068,7 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4135
4068
  )
4136
4069
  }
4137
4070
  );
4138
- }, ColorPickerInput$1 = ColorPickerInput, BorderRadiusInput = ({ value: o, onChange: r, disabled: n }) => {
4071
+ }, BorderRadiusInput = ({ value: o, onChange: r, disabled: n }) => {
4139
4072
  const a = debounce((l) => r(l), 200);
4140
4073
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
4141
4074
  "input",
@@ -4150,64 +4083,64 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4150
4083
  className: "flex-1 cursor-pointer"
4151
4084
  }
4152
4085
  );
4153
- }, BorderRadiusInput$1 = BorderRadiusInput, ThemeConfigPanel$1 = React.memo(({ className: o = "" }) => {
4154
- const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), [i, c] = useTheme(), d = useThemeOptions(), { t: p } = useTranslation(), u = (f) => {
4155
- a(f);
4086
+ }, ThemeConfigPanel$1 = React.memo(({ className: o = "" }) => {
4087
+ const [r] = useDarkMode(), [n, a] = React.useState(""), l = useBuilderProp("themePresets", []), [i, c] = useTheme(), d = useThemeOptions(), { t: p } = useTranslation(), u = (g) => {
4088
+ a(g);
4156
4089
  }, x = () => {
4157
- const f = l.find((y) => Object.keys(y)[0] === n);
4158
- if (f) {
4159
- const y = Object.values(f)[0];
4160
- y && typeof y == "object" && "fontFamily" in y && "borderRadius" in y && "colors" in y ? c(y) : console.error("Invalid preset structure:", y);
4090
+ const g = l.find((k) => Object.keys(k)[0] === n);
4091
+ if (g) {
4092
+ const k = Object.values(g)[0];
4093
+ k && typeof k == "object" && "fontFamily" in k && "borderRadius" in k && "colors" in k ? c(k) : console.error("Invalid preset structure:", k);
4161
4094
  } else
4162
4095
  console.error("Preset not found:", n);
4163
4096
  }, h = useDebouncedCallback(
4164
- (f, y) => {
4097
+ (g, k) => {
4165
4098
  c(() => ({
4166
4099
  ...i,
4167
4100
  fontFamily: {
4168
4101
  ...i.fontFamily,
4169
- [f.replace(/font-/g, "")]: y
4102
+ [g.replace(/font-/g, "")]: k
4170
4103
  }
4171
4104
  }));
4172
4105
  },
4173
4106
  [i],
4174
4107
  200
4175
- ), g = useDebouncedCallback(
4176
- (f) => {
4108
+ ), m = useDebouncedCallback(
4109
+ (g) => {
4177
4110
  c(() => ({
4178
4111
  ...i,
4179
- borderRadius: `${f}px`
4112
+ borderRadius: `${g}px`
4180
4113
  }));
4181
4114
  },
4182
4115
  [i],
4183
4116
  200
4184
- ), j = useDebouncedCallback(
4185
- (f, y) => {
4117
+ ), E = useDebouncedCallback(
4118
+ (g, k) => {
4186
4119
  c(() => {
4187
- const v = get(i, `colors.${f}`);
4188
- return r ? set(v, 1, y) : set(v, 0, y), {
4120
+ const _ = get(i, `colors.${g}`);
4121
+ return r ? set(_, 1, k) : set(_, 0, k), {
4189
4122
  ...i,
4190
4123
  colors: {
4191
4124
  ...i.colors,
4192
- [f]: v
4125
+ [g]: _
4193
4126
  }
4194
4127
  };
4195
4128
  });
4196
4129
  },
4197
4130
  [i],
4198
4131
  200
4199
- ), b = (f) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(f.items).map(([y]) => {
4200
- const v = get(i, `colors.${y}.${r ? 1 : 0}`);
4132
+ ), y = (g) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid grid-cols-1", children: Object.entries(g.items).map(([k]) => {
4133
+ const _ = get(i, `colors.${k}.${r ? 1 : 0}`);
4201
4134
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4202
4135
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4203
- ColorPickerInput$1,
4136
+ ColorPickerInput,
4204
4137
  {
4205
- value: v,
4206
- onChange: (B) => j(y, B)
4138
+ value: _,
4139
+ onChange: (A) => E(k, A)
4207
4140
  }
4208
4141
  ),
4209
- /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: y.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((B) => B.charAt(0).toUpperCase() + B.slice(1)).join(" ") + (!y.toLowerCase().includes("foreground") && !y.toLowerCase().includes("border") && !y.toLowerCase().includes("input") && !y.toLowerCase().includes("ring") && !y.toLowerCase().includes("background") ? " Background" : "") })
4210
- ] }, y);
4142
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: k.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((A) => A.charAt(0).toUpperCase() + A.slice(1)).join(" ") + (!k.toLowerCase().includes("foreground") && !k.toLowerCase().includes("border") && !k.toLowerCase().includes("input") && !k.toLowerCase().includes("ring") && !k.toLowerCase().includes("background") ? " Background" : "") })
4143
+ ] }, k);
4211
4144
  }) });
4212
4145
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4213
4146
  l.length > 0 && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex gap-2 py-2", children: [
@@ -4217,11 +4150,11 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4217
4150
  "select",
4218
4151
  {
4219
4152
  value: n,
4220
- onChange: (f) => u(f.target.value),
4153
+ onChange: (g) => u(g.target.value),
4221
4154
  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",
4222
4155
  children: [
4223
4156
  /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: "", children: "Select preset" }),
4224
- Array.isArray(l) && l.map((f) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: Object.keys(f)[0], children: capitalize(Object.keys(f)[0]) }, Object.keys(f)[0]))
4157
+ Array.isArray(l) && l.map((g) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: Object.keys(g)[0], children: capitalize(Object.keys(g)[0]) }, Object.keys(g)[0]))
4225
4158
  ]
4226
4159
  }
4227
4160
  )
@@ -4229,25 +4162,25 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4229
4162
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-[30%] items-end", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "w-full text-sm", disabled: n === "", variant: "default", onClick: x, children: p("Apply") }) })
4230
4163
  ] }),
4231
4164
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("space-y-2", o), children: [
4232
- (d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([f, y]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4233
- FontSelector$1,
4165
+ (d == null ? void 0 : d.fontFamily) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grid gap-4", children: Object.entries(d.fontFamily).map(([g, k]) => /* @__PURE__ */ jsxRuntimeExports.jsx(
4166
+ FontSelector,
4234
4167
  {
4235
- label: f,
4236
- value: i.fontFamily[f.replace(/font-/g, "")] || y[Object.keys(y)[0]],
4237
- onChange: (v) => h(f, v)
4168
+ label: g,
4169
+ value: i.fontFamily[g.replace(/font-/g, "")] || k[Object.keys(k)[0]],
4170
+ onChange: (_) => h(g, _)
4238
4171
  },
4239
- f
4172
+ g
4240
4173
  )) }),
4241
4174
  (d == null ? void 0 : d.borderRadius) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-0.5 py-3", children: [
4242
4175
  /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-sm text-slate-800", children: p("Border Radius") }),
4243
4176
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-4 py-2", children: [
4244
- /* @__PURE__ */ jsxRuntimeExports.jsx(BorderRadiusInput$1, { value: i.borderRadius, onChange: g }),
4177
+ /* @__PURE__ */ jsxRuntimeExports.jsx(BorderRadiusInput, { value: i.borderRadius, onChange: m }),
4245
4178
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "w-12 text-sm", children: i.borderRadius })
4246
4179
  ] })
4247
4180
  ] }),
4248
4181
  (d == null ? void 0 : d.colors) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-4 space-y-0.5", children: [
4249
4182
  /* @__PURE__ */ jsxRuntimeExports.jsx(Label, { className: "text-sm text-slate-800", children: p("Colors") }),
4250
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full space-y-4 pt-2", children: d.colors.map((f) => b(f)) }, r ? "dark" : "light")
4183
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full space-y-4 pt-2", children: d.colors.map((g) => y(g)) }, r ? "dark" : "light")
4251
4184
  ] })
4252
4185
  ] }),
4253
4186
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
@@ -4255,9 +4188,9 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4255
4188
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
4256
4189
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
4257
4190
  ] });
4258
- }), ThemeConfigPanel$2 = ThemeConfigPanel$1, ThemeConfigPanel$3 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4191
+ }), ThemeConfigPanel$2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
4259
4192
  __proto__: null,
4260
- default: ThemeConfigPanel$2
4193
+ default: ThemeConfigPanel$1
4261
4194
  }, Symbol.toStringTag, { value: "Module" })), placeholderStyle = {
4262
4195
  display: "flex",
4263
4196
  alignItems: "center",
@@ -4291,7 +4224,33 @@ const usePageDataProviders = () => useAtom$1(dataProvidersAtom), useAllDataProvi
4291
4224
  ] })
4292
4225
  }
4293
4226
  ) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "hidden" });
4294
- }), CopyPasteBlocks = () => {
4227
+ }), PasteAtRootContextMenu = ({ parentContext: o, setParentContext: r }) => {
4228
+ const { t: n } = useTranslation(), { canPaste: a, pasteBlocks: l } = usePasteBlocks();
4229
+ return useEffect(() => {
4230
+ a("root") || r(null);
4231
+ }, [a("root")]), o && a("root") && /* @__PURE__ */ jsxRuntimeExports.jsx(
4232
+ "div",
4233
+ {
4234
+ style: { position: "absolute", top: o.y - 75, left: o.x - 56 },
4235
+ onMouseLeave: () => r(null),
4236
+ className: "w-28 rounded-md border bg-white p-1 shadow-xl",
4237
+ children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4238
+ "div",
4239
+ {
4240
+ className: "flex cursor-pointer items-center gap-x-4 rounded px-2 py-1 text-xs hover:bg-blue-50",
4241
+ onClick: () => {
4242
+ l("root"), r(null);
4243
+ },
4244
+ children: [
4245
+ /* @__PURE__ */ jsxRuntimeExports.jsx(CardStackIcon, {}),
4246
+ " ",
4247
+ n("Paste")
4248
+ ]
4249
+ }
4250
+ )
4251
+ }
4252
+ );
4253
+ }, CopyPasteBlocks = () => {
4295
4254
  const [o] = useBlocksStore(), [r] = useSelectedBlockIds(), { pasteBlocks: n } = usePasteBlocks(), [, a] = useCopyBlockIds(), { t: l } = useTranslation(), i = useSelectedBlock(), c = useCallback(() => {
4296
4255
  const d = r.map((p) => {
4297
4256
  const u = o.find((x) => x._id === p);
@@ -4445,50 +4404,50 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4445
4404
  var I;
4446
4405
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
4447
4406
  let p = null;
4448
- const u = o.children.length > 0, { highlightBlock: x, clearHighlight: h } = useBlockHighlight(), { id: g, data: j, isSelected: b, willReceiveDrop: f, isDragging: y, isEditing: v, handleClick: B } = o, A = (w) => {
4449
- w.stopPropagation(), !i.includes(g) && o.toggle();
4450
- }, S = (w) => {
4451
- w.isInternal && (p = w.isOpen, w.isOpen && w.close());
4452
- }, k = (w) => {
4453
- w.isInternal && p !== null && (p ? w.open() : w.close(), p = null);
4454
- }, [T, _] = useAtom$1(currentAddSelection), P = () => {
4455
- var w;
4456
- m(), o.parent.isSelected || _((w = o == null ? void 0 : o.parent) == null ? void 0 : w.id);
4457
- }, m = () => {
4458
- _(null);
4459
- }, E = (w) => {
4460
- m(), w.stopPropagation(), !o.isOpen && !i.includes(g) && o.toggle(), B(w);
4407
+ const u = o.children.length > 0, { highlightBlock: x, clearHighlight: h } = useBlockHighlight(), { id: m, data: E, isSelected: y, willReceiveDrop: g, isDragging: k, isEditing: _, handleClick: A } = o, S = (T) => {
4408
+ T.stopPropagation(), !i.includes(m) && o.toggle();
4409
+ }, v = (T) => {
4410
+ T.isInternal && (p = T.isOpen, T.isOpen && T.close());
4411
+ }, R = (T) => {
4412
+ T.isInternal && p !== null && (p ? T.open() : T.close(), p = null);
4413
+ }, [f, j] = useAtom$1(currentAddSelection), w = () => {
4414
+ var T;
4415
+ b(), o.parent.isSelected || j((T = o == null ? void 0 : o.parent) == null ? void 0 : T.id);
4416
+ }, b = () => {
4417
+ j(null);
4418
+ }, C = (T) => {
4419
+ b(), T.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), A(T);
4461
4420
  };
4462
4421
  useEffect(() => {
4463
- const w = setTimeout(() => {
4464
- f && !o.isOpen && !y && !i.includes(g) && o.toggle();
4422
+ const T = setTimeout(() => {
4423
+ g && !o.isOpen && !k && !i.includes(m) && o.toggle();
4465
4424
  }, 500);
4466
- return () => clearTimeout(w);
4467
- }, [f, o, y]);
4468
- const R = useMemo(() => {
4469
- const w = Object.keys(j), $ = [];
4470
- for (let L = 0; L < w.length; L++)
4471
- if (w[L].endsWith("_attrs")) {
4472
- const M = j[w[L]], D = Object.keys(M).join("|");
4473
- D.match(/x-data/) && $.push("data"), D.match(/x-on/) && $.push("event"), D.match(/x-show|x-if/) && $.push("show");
4425
+ return () => clearTimeout(T);
4426
+ }, [g, o, k]);
4427
+ const B = useMemo(() => {
4428
+ const T = Object.keys(E), L = [];
4429
+ for (let P = 0; P < T.length; P++)
4430
+ if (T[P].endsWith("_attrs")) {
4431
+ const M = E[T[P]], $ = Object.keys(M).join("|");
4432
+ $.match(/x-data/) && L.push("data"), $.match(/x-on/) && L.push("event"), $.match(/x-show|x-if/) && L.push("show");
4474
4433
  }
4475
- return $;
4476
- }, [j]), C = (w, $) => {
4477
- const L = d.contentDocument || d.contentWindow.document, M = L.querySelector(`[data-block-id=${w}]`);
4478
- M && M.setAttribute("data-drop", $);
4479
- const D = M.getBoundingClientRect(), O = d.getBoundingClientRect();
4480
- D.top >= O.top && D.left >= O.left && D.bottom <= O.bottom && D.right <= O.right || (L.documentElement.scrollTop = M.offsetTop - O.top);
4481
- }, N = (w) => {
4482
- m();
4483
- const $ = get(o, "parent.id");
4484
- $ !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: $, position: w }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: w });
4434
+ return L;
4435
+ }, [E]), N = (T, L) => {
4436
+ const P = d.contentDocument || d.contentWindow.document, M = P.querySelector(`[data-block-id=${T}]`);
4437
+ M && M.setAttribute("data-drop", L);
4438
+ const $ = M.getBoundingClientRect(), H = d.getBoundingClientRect();
4439
+ $.top >= H.top && $.left >= H.left && $.bottom <= H.bottom && $.right <= H.right || (P.documentElement.scrollTop = M.offsetTop - H.top);
4440
+ }, D = (T) => {
4441
+ b();
4442
+ const L = get(o, "parent.id");
4443
+ L !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: L, position: T }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: T });
4485
4444
  };
4486
- return g === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative w-full cursor-pointer", children: [
4445
+ return m === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative w-full cursor-pointer", children: [
4487
4446
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
4488
4447
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4489
4448
  "div",
4490
4449
  {
4491
- onClick: () => N(-1),
4450
+ onClick: () => D(-1),
4492
4451
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
4493
4452
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "absolute left-1/2 top-1/2 flex -translate-x-1/2 -translate-y-1/2 transform items-center gap-x-1 rounded-full bg-purple-500 px-3 py-1 text-[9px] leading-tight text-white hover:bg-purple-500", children: [
4494
4453
  /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -4498,35 +4457,35 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4498
4457
  }
4499
4458
  ),
4500
4459
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {})
4501
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: g, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4460
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx(BlockContextMenu, { id: m, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4502
4461
  "div",
4503
4462
  {
4504
- onMouseEnter: () => x(g),
4463
+ onMouseEnter: () => x(m),
4505
4464
  onMouseLeave: () => h(),
4506
- onClick: E,
4465
+ onClick: C,
4507
4466
  style: r,
4508
- "data-node-id": g,
4509
- ref: i.includes(g) ? null : n,
4510
- onDragStart: () => S(o),
4511
- onDragEnd: () => k(o),
4512
- onDragOver: (w) => {
4513
- w.preventDefault(), C(g, "yes");
4467
+ "data-node-id": m,
4468
+ ref: i.includes(m) ? null : n,
4469
+ onDragStart: () => v(o),
4470
+ onDragEnd: () => R(o),
4471
+ onDragOver: (T) => {
4472
+ T.preventDefault(), N(m, "yes");
4514
4473
  },
4515
- onDragLeave: (w) => {
4516
- w.preventDefault(), C(g, "no");
4474
+ onDragLeave: (T) => {
4475
+ T.preventDefault(), N(m, "no");
4517
4476
  },
4518
- onDrop: (w) => {
4519
- w.preventDefault(), C(g, "no");
4477
+ onDrop: (T) => {
4478
+ T.preventDefault(), N(m, "no");
4520
4479
  },
4521
4480
  children: [
4522
4481
  (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((I = o == null ? void 0 : o.parent) == null ? void 0 : I.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4523
4482
  "div",
4524
4483
  {
4525
- onClick: (w) => {
4526
- w.stopPropagation(), N(o.childIndex);
4484
+ onClick: (T) => {
4485
+ T.stopPropagation(), D(o.childIndex);
4527
4486
  },
4528
- onMouseEnter: P,
4529
- onMouseLeave: m,
4487
+ onMouseEnter: w,
4488
+ onMouseLeave: b,
4530
4489
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
4531
4490
  children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
4532
4491
  }
@@ -4536,11 +4495,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4536
4495
  {
4537
4496
  className: cn(
4538
4497
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
4539
- b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
4540
- f && canAcceptChildBlock(j._type, "Icon") ? "bg-green-200" : "",
4541
- (o == null ? void 0 : o.id) === T ? "bg-purple-100" : "",
4542
- y && "opacity-20",
4543
- i.includes(g) ? "opacity-50" : ""
4498
+ y ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
4499
+ g && canAcceptChildBlock(E._type, "Icon") ? "bg-green-200" : "",
4500
+ (o == null ? void 0 : o.id) === f ? "bg-purple-100" : "",
4501
+ k && "opacity-20",
4502
+ i.includes(m) ? "opacity-50" : ""
4544
4503
  ),
4545
4504
  children: [
4546
4505
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
@@ -4548,50 +4507,50 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4548
4507
  "div",
4549
4508
  {
4550
4509
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
4551
- children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: A, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4510
+ children: u && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: S, type: "button", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4552
4511
  ChevronRight,
4553
4512
  {
4554
- className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
4513
+ className: `h-3 w-3 stroke-[3] ${y ? "text-slate-200" : "text-slate-400"}`
4555
4514
  }
4556
4515
  ) })
4557
4516
  }
4558
4517
  ),
4559
4518
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "leading-1 flex items-center", children: [
4560
- /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: j == null ? void 0 : j._type }),
4561
- v ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4519
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TypeIcon, { type: E == null ? void 0 : E._type }),
4520
+ _ ? /* @__PURE__ */ jsxRuntimeExports.jsx(Input, { node: o }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(
4562
4521
  "div",
4563
4522
  {
4564
4523
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
4565
- onDoubleClick: (w) => {
4566
- w.stopPropagation(), o.edit(), o.deselect();
4524
+ onDoubleClick: (T) => {
4525
+ T.stopPropagation(), o.edit(), o.deselect();
4567
4526
  },
4568
4527
  children: [
4569
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (j == null ? void 0 : j._name) || (j == null ? void 0 : j._type.split("/").pop()) }),
4570
- R.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
4571
- R.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
4572
- R.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
4528
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: (E == null ? void 0 : E._name) || (E == null ? void 0 : E._type.split("/").pop()) }),
4529
+ B.includes("data") && /* @__PURE__ */ jsxRuntimeExports.jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
4530
+ B.includes("event") && /* @__PURE__ */ jsxRuntimeExports.jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
4531
+ B.includes("show") && /* @__PURE__ */ jsxRuntimeExports.jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
4573
4532
  ]
4574
4533
  }
4575
4534
  )
4576
4535
  ] })
4577
4536
  ] }),
4578
4537
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
4579
- !i.includes(g) && a.map((w) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4538
+ !i.includes(m) && a.map((T) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4580
4539
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4581
4540
  TooltipTrigger,
4582
4541
  {
4583
4542
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
4584
4543
  asChild: !0,
4585
- children: React__default.createElement(w.item, { blockId: g })
4544
+ children: React__default.createElement(T.item, { blockId: m })
4586
4545
  }
4587
4546
  ),
4588
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: w.tooltip })
4547
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-10", children: T.tooltip })
4589
4548
  ] })),
4590
- canAddChildBlock(j == null ? void 0 : j._type) && !i.includes(g) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4549
+ canAddChildBlock(E == null ? void 0 : E._type) && !i.includes(m) ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4591
4550
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4592
4551
  TooltipTrigger,
4593
4552
  {
4594
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: g }),
4553
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
4595
4554
  className: "cursor-pointer rounded bg-transparent hover:text-black",
4596
4555
  asChild: !0,
4597
4556
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { size: "15" })
@@ -4603,8 +4562,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4603
4562
  /* @__PURE__ */ jsxRuntimeExports.jsx(
4604
4563
  TooltipTrigger,
4605
4564
  {
4606
- onClick: (w) => {
4607
- w.stopPropagation(), c(g), o.isOpen && o.toggle();
4565
+ onClick: (T) => {
4566
+ T.stopPropagation(), c(m), o.isOpen && o.toggle();
4608
4567
  },
4609
4568
  className: "cursor-pointer rounded bg-transparent hover:text-black",
4610
4569
  asChild: !0,
@@ -4650,7 +4609,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4650
4609
  return canAcceptChildBlock(a, l);
4651
4610
  };
4652
4611
  }, ListTree = () => {
4653
- const [treeData] = useAtom$1(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), [cutBlocksIds] = useCutBlockIds(), [, setHiddenBlocks] = useHiddenBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom$1(treeRefAtom), { t } = useTranslation(), clearSelection = () => {
4612
+ const [treeData] = useAtom$1(treeDSBlocks), [ids, setIds] = useSelectedBlockIds(), [cutBlocksIds] = useCutBlockIds(), [, setHiddenBlocks] = useHiddenBlockIds(), updateBlockProps = useUpdateBlocksProps(), [, setStyleBlocks] = useSelectedStylingBlocks(), { moveBlocks } = useBlocksStoreUndoableActions(), canMove = useCanMove(), treeRef = useRef(null), [, setTreeRef] = useAtom$1(treeRefAtom), { t } = useTranslation(), [parentContext, setParentContext] = useState(null), clearSelection = () => {
4654
4613
  setIds([]), setStyleBlocks([]);
4655
4614
  }, filteredTreeData = useMemo(() => {
4656
4615
  const o = (n, a) => n.filter((l) => !a.includes(l._id)).map((l) => ({
@@ -4663,15 +4622,14 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4663
4622
  }, onMove = ({ dragIds: o, parentId: r, index: n }) => {
4664
4623
  canMove(o, r) && moveBlocks(o, r, n);
4665
4624
  }, onSelect = (o) => {
4666
- if (o.length === 0)
4667
- return;
4625
+ if (o.length === 0) return;
4668
4626
  const r = o[0] ? o[0].id : "";
4669
4627
  setStyleBlocks([]), setIds([r]);
4670
4628
  }, onContextMenu = (o) => {
4671
4629
  var a;
4672
- o.preventDefault();
4630
+ o.preventDefault(), parentContext && setParentContext(null);
4673
4631
  const r = o.target, n = r.getAttribute("data-node-id") || ((a = r.closest("[data-node-id]")) == null ? void 0 : a.getAttribute("data-node-id"));
4674
- n && (setStyleBlocks([]), setIds([n]));
4632
+ n ? (setStyleBlocks([]), setIds([n])) : (setStyleBlocks([]), setIds([]), setParentContext({ x: o.clientX, y: o.clientY }));
4675
4633
  }, debouncedDisableDrop = useDebouncedCallback(
4676
4634
  ({ parentNode: o, dragNodes: r }) => {
4677
4635
  var n;
@@ -4680,11 +4638,9 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4680
4638
  [],
4681
4639
  300
4682
4640
  ), handleKeyDown = (e) => {
4683
- if (!treeRef.current)
4684
- return;
4641
+ if (!treeRef.current) return;
4685
4642
  const tree = treeRef.current, selectedNode = tree.selectedNodes[0];
4686
- if (!selectedNode)
4687
- return;
4643
+ if (!selectedNode) return;
4688
4644
  setIds[selectedNode.id], setStyleBlocks([]);
4689
4645
  const isLeaf = !selectedNode.isInternal, isClosed = !selectedNode.isOpen, isOpen = selectedNode.isOpen, shortcut = defaultShortcuts.find((s) => s.key === e.key && (!s.when || eval(s.when)));
4690
4646
  if (shortcut)
@@ -4727,86 +4683,88 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4727
4683
  "+ ",
4728
4684
  t("Add Block")
4729
4685
  ] })
4730
- ] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4731
- "div",
4732
- {
4733
- id: "outline-view",
4734
- className: "no-scrollbar h-full overflow-y-auto text-sm",
4735
- onKeyDown: (o) => {
4736
- treeRef.current.isEditing || handleKeyDown(o);
4737
- },
4738
- children: [
4739
- /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2 flex items-center justify-end gap-x-2 pb-2 text-sm text-muted-foreground", children: [
4740
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4741
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4742
- Button,
4743
- {
4744
- onClick: () => setHiddenBlocks([]),
4745
- variant: "outline",
4746
- className: "h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",
4747
- size: "sm",
4748
- children: /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })
4749
- }
4750
- ) }),
4751
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Show hidden blocks") })
4752
- ] }),
4753
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4754
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
4755
- var o;
4756
- return (o = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : o.openAll();
4757
- }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiExpandVertical, { size: "14" }) }) }),
4758
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Expand all") })
4686
+ ] }) }) }) : /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
4687
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: cn("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
4688
+ "div",
4689
+ {
4690
+ id: "outline-view",
4691
+ className: "no-scrollbar h-full overflow-y-auto text-sm",
4692
+ onKeyDown: (o) => {
4693
+ treeRef.current.isEditing || handleKeyDown(o);
4694
+ },
4695
+ children: [
4696
+ /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-2 flex items-center justify-end gap-x-2 pb-2 text-sm text-muted-foreground", children: [
4697
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4698
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4699
+ Button,
4700
+ {
4701
+ onClick: () => setHiddenBlocks([]),
4702
+ variant: "outline",
4703
+ className: "h-fit p-1 disabled:cursor-not-allowed disabled:opacity-50",
4704
+ size: "sm",
4705
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx(Eye, { className: "h-4 w-4" })
4706
+ }
4707
+ ) }),
4708
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Show hidden blocks") })
4709
+ ] }),
4710
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4711
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
4712
+ var o;
4713
+ return (o = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : o.openAll();
4714
+ }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiExpandVertical, { size: "14" }) }) }),
4715
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Expand all") })
4716
+ ] }),
4717
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4718
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
4719
+ var o;
4720
+ return (o = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : o.closeAll();
4721
+ }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiCollapseVertical, { size: "14" }) }) }),
4722
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Collapse all") })
4723
+ ] })
4759
4724
  ] }),
4760
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
4761
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { className: "h-fit p-1", onClick: () => {
4762
- var o;
4763
- return (o = treeRef == null ? void 0 : treeRef.current) == null ? void 0 : o.closeAll();
4764
- }, variant: "outline", size: "sm", children: /* @__PURE__ */ jsxRuntimeExports.jsx(BiCollapseVertical, { size: "14" }) }) }),
4765
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { className: "isolate z-[9999]", children: t("Collapse all") })
4766
- ] })
4767
- ] }),
4768
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative z-[9999] ml-5 w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4769
- "div",
4770
- {
4771
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: 0 }),
4772
- className: "h-1 w-[90%] rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
4773
- children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[3] text-white" }) })
4774
- }
4775
- ) }),
4776
- /* @__PURE__ */ jsxRuntimeExports.jsx(
4777
- Tree,
4778
- {
4779
- ref: treeRef,
4780
- height: window.innerHeight - 160,
4781
- className: "no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",
4782
- rowClassName: "flex items-center h-full border-b border-transparent",
4783
- selection: ids[0] || "",
4784
- onRename,
4785
- openByDefault: !1,
4786
- onMove,
4787
- data: [...filteredTreeData],
4788
- renderCursor: DefaultCursor,
4789
- onSelect,
4790
- childrenAccessor: (o) => o.children,
4791
- width: "100%",
4792
- rowHeight: 28,
4793
- renderDragPreview: DefaultDragPreview,
4794
- indent: 10,
4795
- onContextMenu,
4796
- disableDrop: debouncedDisableDrop,
4797
- idAccessor: "_id",
4798
- children: Node
4799
- }
4800
- )
4801
- ]
4802
- }
4803
- ) });
4804
- }, Outline$1 = ListTree, hasVideoEmbed = (o) => {
4725
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "group relative z-[9999] ml-5 w-full cursor-pointer", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
4726
+ "div",
4727
+ {
4728
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: 0 }),
4729
+ className: "h-1 w-[90%] rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
4730
+ children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute left-[45%] top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[3] text-white" }) })
4731
+ }
4732
+ ) }),
4733
+ /* @__PURE__ */ jsxRuntimeExports.jsx(
4734
+ Tree,
4735
+ {
4736
+ ref: treeRef,
4737
+ height: window.innerHeight - 160,
4738
+ className: "no-scrollbar !h-full max-w-full space-y-1 !overflow-y-auto !overflow-x-hidden",
4739
+ rowClassName: "flex items-center h-full border-b border-transparent",
4740
+ selection: ids[0] || "",
4741
+ onRename,
4742
+ openByDefault: !1,
4743
+ onMove,
4744
+ data: [...filteredTreeData],
4745
+ renderCursor: DefaultCursor,
4746
+ onSelect,
4747
+ childrenAccessor: (o) => o.children,
4748
+ width: "100%",
4749
+ rowHeight: 28,
4750
+ renderDragPreview: DefaultDragPreview,
4751
+ indent: 10,
4752
+ onContextMenu,
4753
+ disableDrop: debouncedDisableDrop,
4754
+ idAccessor: "_id",
4755
+ children: Node
4756
+ }
4757
+ )
4758
+ ]
4759
+ }
4760
+ ) }),
4761
+ /* @__PURE__ */ jsxRuntimeExports.jsx(PasteAtRootContextMenu, { parentContext, setParentContext })
4762
+ ] });
4763
+ }, hasVideoEmbed = (o) => {
4805
4764
  const r = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, n = /(?:https?:\/\/)?(?:www\.)?(player)?.vimeo\.com/;
4806
4765
  return r.test(o) || n.test(o);
4807
4766
  }, getVideoURLFromHTML = (o) => {
4808
- if (isEmpty(o))
4809
- return o;
4767
+ if (isEmpty(o)) return o;
4810
4768
  const r = /<video[^>]+src=['"]([^'">]+)['"]/, n = /<iframe[^>]+src=['"]([^'">]+)['"]/, a = o.match(r), l = o.match(n), i = a ? a[1] : l ? l[1] : null, c = /(?:https?:\/\/)?(?:www\.)?(?:youtube\.com\/(?:[^\/\n\s]+\/\S+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/, d = /(?:https?:\/\/)?(?:www\.)?player.vimeo\.com/;
4811
4769
  return i && (c.test(i) || d.test(i)) ? i : o;
4812
4770
  }, NAME_ATTRIBUTES = ["chai-name", "data-chai-name"], ATTRIBUTE_MAP = {
@@ -4846,8 +4804,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4846
4804
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
4847
4805
  r._type
4848
4806
  ), getTextContent = (o) => o.map((r) => r.type === "text" ? get(r, "content", "") : isEmpty(r.children) ? "" : getTextContent(r.children)).join(""), getSanitizedValue = (o) => o === null ? "" : o, getAttrs = (o) => {
4849
- if (o.tagName === "svg")
4850
- return {};
4807
+ if (o.tagName === "svg") return {};
4851
4808
  const r = {}, n = ATTRIBUTE_MAP[o.tagName] || {}, a = o.attributes;
4852
4809
  return forEach(a, ({ key: l, value: i }) => {
4853
4810
  if (!includes(NAME_ATTRIBUTES, l))
@@ -4857,12 +4814,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4857
4814
  c && d ? i = `https://via.placeholder.com/${c == null ? void 0 : c.value}x${d == null ? void 0 : d.value}` : i = "https://via.placeholder.com/150x150";
4858
4815
  }
4859
4816
  set(r, n[l], getSanitizedValue(i));
4860
- } else
4861
- includes(["style", "class", "srcset"], l) || (has(r, "styles_attrs") || (r.styles_attrs = {}), startsWith(l, "@") && (l = l.replace("@", "x-on:")), r.styles_attrs[`${l}`] = getSanitizedValue(i));
4817
+ } else includes(["style", "class", "srcset"], l) || (has(r, "styles_attrs") || (r.styles_attrs = {}), startsWith(l, "@") && (l = l.replace("@", "x-on:")), r.styles_attrs[`${l}`] = getSanitizedValue(i));
4862
4818
  }), delete r.class, r;
4863
4819
  }, getStyles = (o, r = "styles") => {
4864
- if (!o.attributes)
4865
- return { [r]: `${STYLES_KEY},` };
4820
+ if (!o.attributes) return { [r]: `${STYLES_KEY},` };
4866
4821
  const n = find(o.attributes, { key: "class" });
4867
4822
  if (n) {
4868
4823
  const a = n.value;
@@ -4870,7 +4825,17 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4870
4825
  }
4871
4826
  return { [r]: `${STYLES_KEY},` };
4872
4827
  }, getBlockProps = (o) => {
4873
- const r = get(o, "attributes", []), n = r.find((l) => l.key === "data-chai-richtext" || l.key === "chai-richtext"), a = r.find((l) => l.key === "data-chai-lightbox" || l.key === "chai-lightbox");
4828
+ const r = get(o, "attributes", []), n = r.find((d) => d.key === "data-chai-richtext" || d.key === "chai-richtext"), a = r.find((d) => d.key === "data-chai-lightbox" || d.key === "chai-lightbox"), l = r.find((d) => d.key === "data-chai-dropdown" || d.key === "chai-dropdown"), i = r.find(
4829
+ (d) => d.key === "data-chai-dropdown-button" || d.key === "chai-dropdown-button"
4830
+ ), c = r.find(
4831
+ (d) => d.key === "data-chai-dropdown-content" || d.key === "chai-dropdown-content"
4832
+ );
4833
+ if (l)
4834
+ return { _type: "Dropdown" };
4835
+ if (i)
4836
+ return { _type: "DropdownButton" };
4837
+ if (c)
4838
+ return { _type: "DropdownContent" };
4874
4839
  if (n)
4875
4840
  return { _type: "RichText" };
4876
4841
  if (a)
@@ -4947,25 +4912,31 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4947
4912
  case "tfoot":
4948
4913
  return { _type: "TableFooter" };
4949
4914
  default: {
4950
- const l = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
4915
+ const d = get(o, "children", []).length > 0 ? "Box" : "EmptyBox";
4951
4916
  return {
4952
- _type: l,
4917
+ _type: d,
4953
4918
  tag: o.tagName,
4954
- _name: l == "EmptyBox" || o.tagName === "div" ? l : capitalize(o.tagName)
4919
+ _name: d == "EmptyBox" || o.tagName === "div" ? d : capitalize(o.tagName)
4955
4920
  };
4956
4921
  }
4957
4922
  }
4958
4923
  }, traverseNodes = (o, r = null) => flatMapDeep(o, (n) => {
4959
- var p, u, x, h, g, j, b, f;
4960
- if (n.type === "comment")
4961
- return [];
4924
+ var h, m, E, y, g, k, _, A;
4925
+ if (n.type === "comment") return [];
4926
+ console.log("node ===>", n);
4962
4927
  let a = { _id: generateUUID() };
4963
4928
  if (r && (a._parent = r.block._id), n.type === "text")
4964
4929
  return isEmpty(get(n, "content", "")) ? [] : r && shouldAddText(r.node, r.block) ? (set(r, "block.content", get(n, "content", "")), []) : { ...a, _type: "Text", content: get(n, "content", "") };
4965
4930
  const l = get(n, "attributes", []), i = l.find(
4966
- (y) => y.key === "data-chai-richtext" || y.key === "chai-richtext"
4931
+ (S) => S.key === "data-chai-richtext" || S.key === "chai-richtext"
4967
4932
  ), c = l.find(
4968
- (y) => y.key === "data-chai-lightbox" || y.key === "chai-lightbox"
4933
+ (S) => S.key === "data-chai-lightbox" || S.key === "chai-lightbox"
4934
+ ), d = l.find(
4935
+ (S) => S.key === "data-chai-dropdown" || S.key === "chai-dropdown"
4936
+ ), p = l.find(
4937
+ (S) => S.key === "data-chai-dropdown-button" || S.key === "chai-dropdown-button"
4938
+ ), u = l.find(
4939
+ (S) => S.key === "data-chai-dropdown-content" || S.key === "chai-dropdown-content"
4969
4940
  );
4970
4941
  if (a = {
4971
4942
  ...a,
@@ -4973,13 +4944,13 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4973
4944
  ...getAttrs(n),
4974
4945
  ...getStyles(n)
4975
4946
  }, n.attributes) {
4976
- const y = n.attributes.find((v) => includes(NAME_ATTRIBUTES, v.key));
4977
- y && (a._name = y.value);
4947
+ const S = n.attributes.find((v) => includes(NAME_ATTRIBUTES, v.key));
4948
+ S && (a._name = S.value);
4978
4949
  }
4979
4950
  if (i)
4980
4951
  return a.content = stringify(n.children), has(a, "styles_attrs.data-chai-richtext") && delete a.styles_attrs["data-chai-richtext"], has(a, "styles_attrs.chai-richtext") && delete a.styles_attrs["chai-richtext"], [a];
4981
4952
  if (c) {
4982
- const y = [
4953
+ const S = [
4983
4954
  "data-chai-lightbox",
4984
4955
  "chai-lightbox",
4985
4956
  "data-vbtype",
@@ -4991,33 +4962,57 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
4991
4962
  ];
4992
4963
  a = {
4993
4964
  ...a,
4994
- href: ((p = l.find((v) => v.key === "href")) == null ? void 0 : p.value) || "",
4995
- hrefType: ((u = l.find((v) => v.key === "data-vbtype")) == null ? void 0 : u.value) || "video",
4996
- autoplay: ((x = l.find((v) => v.key === "data-autoplay")) == null ? void 0 : x.value) === "true" ? "true" : "false",
4997
- maxWidth: ((g = (h = l.find((v) => v.key === "data-maxwidth")) == null ? void 0 : h.value) == null ? void 0 : g.replace("px", "")) || "",
4998
- backdropColor: ((j = l.find((v) => v.key === "data-overlay")) == null ? void 0 : j.value) || "",
4999
- galleryName: ((b = l.find((v) => v.key === "data-gall")) == null ? void 0 : b.value) || ""
5000
- }, forEach(y, (v) => {
4965
+ href: ((h = l.find((v) => v.key === "href")) == null ? void 0 : h.value) || "",
4966
+ hrefType: ((m = l.find((v) => v.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
4967
+ autoplay: ((E = l.find((v) => v.key === "data-autoplay")) == null ? void 0 : E.value) === "true" ? "true" : "false",
4968
+ maxWidth: ((g = (y = l.find((v) => v.key === "data-maxwidth")) == null ? void 0 : y.value) == null ? void 0 : g.replace("px", "")) || "",
4969
+ backdropColor: ((k = l.find((v) => v.key === "data-overlay")) == null ? void 0 : k.value) || "",
4970
+ galleryName: ((_ = l.find((v) => v.key === "data-gall")) == null ? void 0 : _.value) || ""
4971
+ }, forEach(S, (v) => {
5001
4972
  has(a, `styles_attrs.${v}`) && delete a.styles_attrs[v];
5002
4973
  });
5003
4974
  }
4975
+ if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
4976
+ delete a.styles_attrs;
4977
+ const S = filter(n.children || [], (R) => (R == null ? void 0 : R.tagName) !== "span");
4978
+ a.content = getTextContent(S);
4979
+ const v = find(
4980
+ n.children || [],
4981
+ (R) => (R == null ? void 0 : R.tagName) === "span" && some(R.children || [], (f) => (f == null ? void 0 : f.tagName) === "svg")
4982
+ );
4983
+ if (v) {
4984
+ const R = find(v.children || [], (f) => (f == null ? void 0 : f.tagName) === "svg");
4985
+ if (R) {
4986
+ a.icon = stringify([R]);
4987
+ const { height: f, width: j } = getSvgDimensions(R, "16px", "16px");
4988
+ a.iconHeight = f, a.iconWidth = j;
4989
+ }
4990
+ }
4991
+ return [a];
4992
+ }
5004
4993
  if (a._type === "Input") {
5005
- const y = a.inputType || "text";
5006
- y === "checkbox" ? set(a, "_type", "Checkbox") : y === "radio" && set(a, "_type", "Radio");
4994
+ const S = a.inputType || "text";
4995
+ S === "checkbox" ? set(a, "_type", "Checkbox") : S === "radio" && set(a, "_type", "Radio");
5007
4996
  } else if (n.tagName === "video" || n.tagName === "iframe") {
5008
- const y = stringify([n]);
5009
- return hasVideoEmbed(y) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(y)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = y, [a];
4997
+ const S = stringify([n]);
4998
+ return hasVideoEmbed(S) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(S)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = S, [a];
5010
4999
  } else if (n.tagName === "svg") {
5011
- const y = find(n.attributes, { key: "height" }), v = find(n.attributes, { key: "width" }), B = get(y, "value") ? `[${get(y, "value")}px]` : "24px", A = get(v, "value") ? `[${get(v, "value")}px]` : "24px", S = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
5012
- return a.styles = `${STYLES_KEY}, ${cn(`w-${A} h-${B}`, S)}`.trim(), n.attributes = filter(n.attributes, (k) => !includes(["style", "width", "height", "class"], k.key)), a.icon = stringify([n]), [a];
5013
- } else if (n.tagName == "option" && r && ((f = r.block) == null ? void 0 : f._type) === "Select")
5000
+ const S = find(n.attributes, { key: "height" }), v = find(n.attributes, { key: "width" }), R = get(S, "value") ? `[${get(S, "value")}px]` : "24px", f = get(v, "value") ? `[${get(v, "value")}px]` : "24px", j = get(find(n.attributes, { key: "class" }), "value", "w-full h-full");
5001
+ return a.styles = `${STYLES_KEY}, ${cn(`w-${f} h-${R}`, j)}`.trim(), n.attributes = filter(n.attributes, (w) => !includes(["style", "width", "height", "class"], w.key)), a.icon = stringify([n]), [a];
5002
+ } else if (n.tagName == "option" && r && ((A = r.block) == null ? void 0 : A._type) === "Select")
5014
5003
  return r.block.options.push({
5015
5004
  label: getTextContent(n.children),
5016
5005
  ...getAttrs(n)
5017
5006
  }), [];
5018
- const d = traverseNodes(n.children, { block: a, node: n });
5019
- return [a, ...d];
5020
- }), getSanitizedHTML = (o) => {
5007
+ const x = traverseNodes(n.children, { block: a, node: n });
5008
+ return [a, ...x];
5009
+ }), getSvgDimensions = (o, r, n) => {
5010
+ const a = get(o, "attributes", []), l = find(a, { key: "height" }), i = find(a, { key: "width" });
5011
+ return {
5012
+ height: get(l, "value") ? `[${get(l, "value")}px]` : n,
5013
+ width: get(i, "value") ? `[${get(i, "value")}px]` : r
5014
+ };
5015
+ }, getSanitizedHTML = (o) => {
5021
5016
  o = o.replace(/(\w+)=\\?"(.*?)\\?"/g, (a, l, i) => {
5022
5017
  let c = i.replace(/\\"/g, '"');
5023
5018
  return c = c.replace(/{([^}]+)}/g, (d) => d.replace(/"/g, '\\"')), `${l}="${c.replace(/\\"/g, '"')}"`;
@@ -5052,7 +5047,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
5052
5047
  ] }) }),
5053
5048
  /* @__PURE__ */ jsxRuntimeExports.jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: n("Import HTML") }) })
5054
5049
  ] });
5055
- }, ImportHTML$1 = ImportHTML, BindingWidget = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100", children: "Data binding is set for this field" }), getSvgMarkup = (o) => {
5050
+ }, BindingWidget = () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "text-xs border rounded-sm p-1 mt-1 border-orange-500 text-orange-500 bg-orange-100", children: "Data binding is set for this field" }), getSvgMarkup = (o) => {
5056
5051
  try {
5057
5052
  const r = document.getElementById("icon-picker-field"), n = document.createElement("div");
5058
5053
  ReactDOM.render(/* @__PURE__ */ jsxRuntimeExports.jsx(IconPickerItem, { value: o }), n), r.appendChild(n), n.hidden = !0;
@@ -5133,13 +5128,13 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: r, drag
5133
5128
  ] });
5134
5129
  };
5135
5130
  MediaManagerModal.displayName = "MediaManagerModal";
5136
- const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
5131
+ const ImagePickerField = ({ value: o, onChange: r, id: n, onBlur: a }) => {
5137
5132
  const l = useBuilderProp("mediaManagerComponent", null), { t: i } = useTranslation(), c = l !== null;
5138
5133
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-1.5 flex items-center gap-x-3", children: [
5139
- o ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: o, className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover", alt: "" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MediaManagerModal$1, { onSelect: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
5134
+ o ? /* @__PURE__ */ jsxRuntimeExports.jsx("img", { src: o, className: "h-20 w-20 overflow-hidden rounded-md border border-border object-cover", alt: "" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(MediaManagerModal, { onSelect: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-20 w-20 cursor-pointer rounded-md border border-border bg-[radial-gradient(#AAA,transparent_1px)] duration-300 [background-size:10px_10px]" }) }),
5140
5135
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-3/5 flex-col", children: [
5141
5136
  c && /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
5142
- /* @__PURE__ */ jsxRuntimeExports.jsx(MediaManagerModal$1, { onSelect: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx("small", { className: "h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700", children: o || !isEmpty(o) ? i("Replace image") : i("Choose image") }) }),
5137
+ /* @__PURE__ */ jsxRuntimeExports.jsx(MediaManagerModal, { onSelect: r, children: /* @__PURE__ */ jsxRuntimeExports.jsx("small", { className: "h-6 cursor-pointer rounded-md bg-primary px-2 py-1 text-center text-xs text-white hover:bg-gray-500 dark:bg-gray-700", children: o || !isEmpty(o) ? i("Replace image") : i("Choose image") }) }),
5143
5138
  /* @__PURE__ */ jsxRuntimeExports.jsx("small", { className: "-pl-4 pt-2 text-center text-xs text-gray-600", children: "OR" })
5144
5139
  ] }),
5145
5140
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -5199,101 +5194,99 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5199
5194
  pageTypes: r,
5200
5195
  onChange: n
5201
5196
  }) => {
5202
- var P;
5203
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (m, E) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [h, g] = useState(""), [j, b] = useState([]), [f, y] = useState(-1), v = useRef(null), B = (P = r == null ? void 0 : r.find((m) => m.key === u)) == null ? void 0 : P.name;
5197
+ var w;
5198
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (b, C) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, x] = useState("page"), [h, m] = useState(""), [E, y] = useState([]), [g, k] = useState(-1), _ = useRef(null), A = (w = r == null ? void 0 : r.find((b) => b.key === u)) == null ? void 0 : w.name;
5204
5199
  useEffect(() => {
5205
- if (g(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:"))
5206
- return;
5207
- const m = split(o, ":"), E = get(m, 1, "page") || "page";
5208
- x(E), (async () => {
5209
- const R = await l(E, [get(m, 2, "page")]);
5210
- R && Array.isArray(R) && g(get(R, [0, "name"], ""));
5200
+ if (m(""), y([]), k(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
5201
+ const b = split(o, ":"), C = get(b, 1, "page") || "page";
5202
+ x(C), (async () => {
5203
+ const B = await l(C, [get(b, 2, "page")]);
5204
+ B && Array.isArray(B) && m(get(B, [0, "name"], ""));
5211
5205
  })();
5212
5206
  }, [o]);
5213
- const A = useDebouncedCallback(
5214
- async (m) => {
5215
- if (isEmpty(m))
5216
- b([]);
5207
+ const S = useDebouncedCallback(
5208
+ async (b) => {
5209
+ if (isEmpty(b))
5210
+ y([]);
5217
5211
  else {
5218
- const E = await l(u, m);
5219
- b(E);
5212
+ const C = await l(u, b);
5213
+ y(C);
5220
5214
  }
5221
- c(!1), y(-1);
5215
+ c(!1), k(-1);
5222
5216
  },
5223
5217
  [u],
5224
5218
  300
5225
- ), S = (m) => {
5226
- const E = ["pageType", u, m.id];
5227
- E[1] && (n(E.join(":")), g(m.name), p(!1), b([]), y(-1));
5228
- }, k = (m) => {
5229
- switch (m.key) {
5219
+ ), v = (b) => {
5220
+ const C = ["pageType", u, b.id];
5221
+ C[1] && (n(C.join(":")), m(b.name), p(!1), y([]), k(-1));
5222
+ }, R = (b) => {
5223
+ switch (b.key) {
5230
5224
  case "ArrowDown":
5231
- m.preventDefault(), y((E) => E < j.length - 1 ? E + 1 : E);
5225
+ b.preventDefault(), k((C) => C < E.length - 1 ? C + 1 : C);
5232
5226
  break;
5233
5227
  case "ArrowUp":
5234
- m.preventDefault(), y((E) => E > 0 ? E - 1 : E);
5228
+ b.preventDefault(), k((C) => C > 0 ? C - 1 : C);
5235
5229
  break;
5236
5230
  case "Enter":
5237
- if (m.preventDefault(), j.length === 0)
5238
- return;
5239
- f >= 0 && S(j[f]);
5231
+ if (b.preventDefault(), E.length === 0) return;
5232
+ g >= 0 && v(E[g]);
5240
5233
  break;
5241
5234
  case "Escape":
5242
- m.preventDefault(), T();
5235
+ b.preventDefault(), f();
5243
5236
  break;
5244
5237
  }
5245
5238
  };
5246
5239
  useEffect(() => {
5247
- if (f >= 0 && v.current) {
5248
- const m = v.current.children[f];
5249
- m == null || m.scrollIntoView({ block: "nearest" });
5240
+ if (g >= 0 && _.current) {
5241
+ const b = _.current.children[g];
5242
+ b == null || b.scrollIntoView({ block: "nearest" });
5250
5243
  }
5251
- }, [f]);
5252
- const T = () => {
5253
- g(""), b([]), y(-1), p(!1), n("");
5254
- }, _ = (m) => {
5255
- g(m), p(!isEmpty(m)), c(!0), A(m);
5244
+ }, [g]);
5245
+ const f = () => {
5246
+ m(""), y([]), k(-1), p(!1), n("");
5247
+ }, j = (b) => {
5248
+ m(b), p(!isEmpty(b)), c(!0), S(b);
5256
5249
  };
5257
5250
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { children: [
5258
- /* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "pageType", value: u, onChange: (m) => x(m.target.value), children: map(r, (m) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: m.key, children: m.name }, m.key)) }),
5251
+ /* @__PURE__ */ jsxRuntimeExports.jsx("select", { name: "pageType", value: u, onChange: (b) => x(b.target.value), children: map(r, (b) => /* @__PURE__ */ jsxRuntimeExports.jsx("option", { value: b.key, children: b.name }, b.key)) }),
5259
5252
  u && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group relative mt-2 flex items-center", children: [
5260
5253
  /* @__PURE__ */ jsxRuntimeExports.jsx(
5261
5254
  "input",
5262
5255
  {
5263
5256
  type: "text",
5264
5257
  value: h,
5265
- onChange: (m) => _(m.target.value),
5266
- onKeyDown: k,
5267
- placeholder: a(`Search ${B ?? ""}`),
5258
+ onChange: (b) => j(b.target.value),
5259
+ onKeyDown: R,
5260
+ placeholder: a(`Search ${A ?? ""}`),
5268
5261
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
5269
5262
  }
5270
5263
  ),
5271
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: T, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
5264
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: h && /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: f, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-4 w-4" }) }) })
5272
5265
  ] }),
5273
- (i || !isEmpty(j) || d && isEmpty(j)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
5266
+ (i || !isEmpty(E) || d && isEmpty(E)) && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "space-y-1 p-2", children: [
5274
5267
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
5275
5268
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
5276
- ] }) : d && isEmpty(j) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5269
+ ] }) : d && isEmpty(E) ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
5277
5270
  a("No results found for"),
5278
5271
  ' "',
5279
5272
  h,
5280
5273
  '"'
5281
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: v, children: map(j == null ? void 0 : j.slice(0, 20), (m, E) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5274
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { ref: _, children: map(E == null ? void 0 : E.slice(0, 20), (b, C) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5282
5275
  "li",
5283
5276
  {
5284
- onClick: () => S(m),
5285
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(m.id) ? "bg-blue-200" : E === f ? "bg-gray-100" : "hover:bg-gray-100"}`,
5277
+ onClick: () => v(b),
5278
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(b.id) ? "bg-blue-200" : C === g ? "bg-gray-100" : "hover:bg-gray-100"}`,
5286
5279
  children: [
5287
- m.name,
5280
+ b.name,
5288
5281
  " ",
5289
- m.slug && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "font-light text-gray-500", children: [
5282
+ b.slug && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "font-light text-gray-500", children: [
5290
5283
  "( ",
5291
- m.slug,
5284
+ b.slug,
5292
5285
  " )"
5293
5286
  ] })
5294
5287
  ]
5295
5288
  },
5296
- m.id
5289
+ b.id
5297
5290
  )) }) })
5298
5291
  ] });
5299
5292
  }, LinkField = ({ schema: o, formData: r, onChange: n }) => {
@@ -5350,8 +5343,7 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5350
5343
  ] });
5351
5344
  }, RowColField = () => {
5352
5345
  const o = useSelectedBlock(), r = useWrapperBlock(), { addCoreBlock: n } = useAddBlock();
5353
- if (!o && !r)
5354
- return null;
5346
+ if (!o && !r) return null;
5355
5347
  const a = (o == null ? void 0 : o._type) === "Row" ? o : r;
5356
5348
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "pt-1", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
5357
5349
  "button",
@@ -5367,8 +5359,7 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5367
5359
  ) });
5368
5360
  }, CodeEditor = ({ id: o, placeholder: r }) => {
5369
5361
  const { t: n } = useTranslation(), [, a] = useCodeEditor(), l = useSelectedBlock();
5370
- if (typeof window > "u")
5371
- return null;
5362
+ if (typeof window > "u") return null;
5372
5363
  const i = o.replace("root.", ""), c = get(l, i, ""), d = () => {
5373
5364
  const p = l == null ? void 0 : l._id;
5374
5365
  a({ blockId: p, blockProp: i, placeholder: r, initialCode: get(l, i, c) });
@@ -5397,23 +5388,22 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5397
5388
  schema: u,
5398
5389
  formData: x
5399
5390
  }) => {
5400
- const { selectedLang: h, fallbackLang: g, languages: j } = useLanguages(), b = isEmpty(j) ? "" : isEmpty(h) ? g : h, f = get(LANGUAGES, b, b), y = useSelectedBlock(), v = useRegisteredChaiBlocks(), B = get(v, [y == null ? void 0 : y._type, "i18nProps"], []) || [], [A, S] = useState(null);
5391
+ const { selectedLang: h, fallbackLang: m, languages: E } = useLanguages(), y = isEmpty(E) ? "" : isEmpty(h) ? m : h, g = get(LANGUAGES, y, y), k = useSelectedBlock(), _ = useRegisteredChaiBlocks(), A = get(_, [k == null ? void 0 : k._type, "i18nProps"], []) || [], [S, v] = useState(null);
5401
5392
  if (d)
5402
5393
  return null;
5403
- if (u.type === "boolean")
5404
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r, children: a });
5405
- const T = B == null ? void 0 : B.includes(o.replace("root.", ""));
5394
+ if (u.type === "boolean") return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: r, children: a });
5395
+ const f = A == null ? void 0 : A.includes(o.replace("root.", ""));
5406
5396
  if (u.type === "array") {
5407
- const _ = A === o;
5397
+ const j = S === o;
5408
5398
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${r} relative`, children: [
5409
5399
  u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs(
5410
5400
  "label",
5411
5401
  {
5412
5402
  htmlFor: o,
5413
- onClick: () => S(_ ? null : o),
5403
+ onClick: () => v(j ? null : o),
5414
5404
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5415
5405
  children: [
5416
- _ ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3" }),
5406
+ j ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-3 w-3" }),
5417
5407
  /* @__PURE__ */ jsxRuntimeExports.jsx(List, { className: "h-3 w-3" }),
5418
5408
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "leading-tight", children: n }),
5419
5409
  " ",
@@ -5421,7 +5411,7 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5421
5411
  ]
5422
5412
  }
5423
5413
  ),
5424
- (x == null ? void 0 : x.length) === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${_ ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5414
+ (x == null ? void 0 : x.length) === 0 ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `${j ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5425
5415
  c,
5426
5416
  a,
5427
5417
  l,
@@ -5433,9 +5423,9 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5433
5423
  u.title && /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
5434
5424
  n,
5435
5425
  " ",
5436
- T && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5426
+ f && /* @__PURE__ */ jsxRuntimeExports.jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5437
5427
  " ",
5438
- f
5428
+ g
5439
5429
  ] }),
5440
5430
  p && u.type !== "object" ? " *" : null
5441
5431
  ] }),
@@ -5498,8 +5488,7 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5498
5488
  );
5499
5489
  }), CanvasSettings = () => {
5500
5490
  const [o, r] = useAtom$1(xShowBlocksAtom), n = useSelectedBlock(), [, a] = useSelectedBlockIds(), { t: l } = useTranslation(), i = useMemo(() => (n ? JSON.stringify(n) : "").includes('"x-show"'), [n]);
5501
- if (!n || !i)
5502
- return null;
5491
+ if (!n || !i) return null;
5503
5492
  const c = o.includes(n._id);
5504
5493
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "py-2 text-xs hover:no-underline", children: [
5505
5494
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 border-b border-border bg-background py-2 font-normal text-muted-foreground", children: [
@@ -5562,50 +5551,50 @@ const MediaManagerModal$1 = MediaManagerModal, ImagePickerField = ({ value: o, o
5562
5551
  return set(n, o, r), n;
5563
5552
  };
5564
5553
  function BlockSettings() {
5565
- 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), x = useWrapperBlock(), h = getRegisteredChaiBlock(x == null ? void 0 : x._type), g = formDataWithSelectedLang(x, o, h), j = ({ formData: k }, T, _) => {
5566
- if (T && (c == null ? void 0 : c._id) === r._id) {
5567
- const P = T.replace("root.", "");
5568
- a([r._id], { [P]: get(k, P) }, _);
5554
+ 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), x = useWrapperBlock(), h = getRegisteredChaiBlock(x == null ? void 0 : x._type), m = formDataWithSelectedLang(x, o, h), E = ({ formData: R }, f, j) => {
5555
+ if (f && (c == null ? void 0 : c._id) === r._id) {
5556
+ const w = f.replace("root.", "");
5557
+ a([r._id], { [w]: get(R, w) }, j);
5569
5558
  }
5570
- }, b = useCallback(
5571
- debounce(({ formData: k }, T, _) => {
5572
- j({ formData: k }, T, _), d(k);
5559
+ }, y = useCallback(
5560
+ debounce(({ formData: R }, f, j) => {
5561
+ E({ formData: R }, f, j), d(R);
5573
5562
  }, 1500),
5574
5563
  [r == null ? void 0 : r._id, o]
5575
- ), f = ({ formData: k }, T) => {
5576
- if (T) {
5577
- const _ = T.replace("root.", "");
5564
+ ), g = ({ formData: R }, f) => {
5565
+ if (f) {
5566
+ const j = f.replace("root.", "");
5578
5567
  n(
5579
5568
  [r._id],
5580
- convertDotNotationToObject(_, get(k, _.split(".")))
5581
- ), b({ formData: k }, T, { [_]: get(c, _) });
5569
+ convertDotNotationToObject(j, get(R, j.split(".")))
5570
+ ), y({ formData: R }, f, { [j]: get(c, j) });
5582
5571
  }
5583
- }, y = ({ formData: k }, T) => {
5584
- if (T) {
5585
- const _ = T.replace("root.", "");
5572
+ }, k = ({ formData: R }, f) => {
5573
+ if (f) {
5574
+ const j = f.replace("root.", "");
5586
5575
  n(
5587
5576
  [x._id],
5588
- convertDotNotationToObject(_, get(k, _.split(".")))
5589
- ), b({ formData: k }, T, { [_]: get(c, _) });
5577
+ convertDotNotationToObject(j, get(R, j.split(".")))
5578
+ ), y({ formData: R }, f, { [j]: get(c, j) });
5590
5579
  }
5591
5580
  };
5592
5581
  keys(get(i, "_bindings", {}));
5593
- const { schema: v, uiSchema: B } = useMemo(() => {
5594
- const k = r == null ? void 0 : r._type;
5595
- if (k)
5596
- return getBlockFormSchemas(k);
5597
- }, [r]), { wrapperSchema: A, wrapperUiSchema: S } = useMemo(() => {
5582
+ const { schema: _, uiSchema: A } = useMemo(() => {
5583
+ const R = r == null ? void 0 : r._type;
5584
+ if (R)
5585
+ return getBlockFormSchemas(R);
5586
+ }, [r]), { wrapperSchema: S, wrapperUiSchema: v } = useMemo(() => {
5598
5587
  if (!x || !(x != null && x._type))
5599
5588
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5600
- const k = x == null ? void 0 : x._type, { schema: T = {}, uiSchema: _ = {} } = getBlockFormSchemas(k);
5601
- return { wrapperSchema: T, wrapperUiSchema: _ };
5589
+ const R = x == null ? void 0 : x._type, { schema: f = {}, uiSchema: j = {} } = getBlockFormSchemas(R);
5590
+ return { wrapperSchema: f, wrapperUiSchema: j };
5602
5591
  }, [x]);
5603
5592
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5604
5593
  !isEmpty(x) && /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5605
5594
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
5606
5595
  "div",
5607
5596
  {
5608
- onClick: () => u((k) => !k),
5597
+ onClick: () => u((R) => !R),
5609
5598
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5610
5599
  children: [
5611
5600
  p ? /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsxRuntimeExports.jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5624,21 +5613,21 @@ function BlockSettings() {
5624
5613
  JSONForm,
5625
5614
  {
5626
5615
  id: x == null ? void 0 : x._id,
5627
- onChange: y,
5628
- formData: g,
5629
- schema: A,
5630
- uiSchema: S
5616
+ onChange: k,
5617
+ formData: m,
5618
+ schema: S,
5619
+ uiSchema: v
5631
5620
  }
5632
5621
  )
5633
5622
  ] }),
5634
- isEmpty(v) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
5623
+ isEmpty(_) ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
5635
5624
  JSONForm,
5636
5625
  {
5637
5626
  id: r == null ? void 0 : r._id,
5638
- onChange: f,
5627
+ onChange: g,
5639
5628
  formData: i,
5640
- schema: v,
5641
- uiSchema: B
5629
+ schema: _,
5630
+ uiSchema: A
5642
5631
  }
5643
5632
  ),
5644
5633
  (r == null ? void 0 : r._type) === "GlobalBlock" ? /* @__PURE__ */ jsxRuntimeExports.jsx(GlobalBlockSettings, {}) : null,
@@ -5666,8 +5655,7 @@ function Countdown() {
5666
5655
  r(o - 0.1);
5667
5656
  }, 100);
5668
5657
  return () => clearTimeout(p);
5669
- } else
5670
- o <= 0 && (a(!1), r(SECONDS));
5658
+ } else o <= 0 && (a(!1), r(SECONDS));
5671
5659
  }, [n, o]);
5672
5660
  const l = () => {
5673
5661
  a(!0), r(SECONDS);
@@ -5712,12 +5700,12 @@ function Countdown() {
5712
5700
  const AskAIStyles = ({ blockId: o }) => {
5713
5701
  const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, x] = useState();
5714
5702
  useEffect(() => {
5715
- var g;
5716
- (g = d.current) == null || g.focus();
5703
+ var m;
5704
+ (m = d.current) == null || m.focus();
5717
5705
  }, []);
5718
- const h = (g) => {
5719
- const { usage: j } = g || {};
5720
- !l && j && x(j), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
5706
+ const h = (m) => {
5707
+ const { usage: E } = m || {};
5708
+ !l && E && x(E), p.current = setTimeout(() => x(void 0), 1e4), l || c("");
5721
5709
  };
5722
5710
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
5723
5711
  /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: r("Ask AI") }),
@@ -5726,12 +5714,12 @@ const AskAIStyles = ({ blockId: o }) => {
5726
5714
  {
5727
5715
  ref: d,
5728
5716
  value: i,
5729
- onChange: (g) => c(g.target.value),
5717
+ onChange: (m) => c(m.target.value),
5730
5718
  placeholder: r("Ask AI to edit styles"),
5731
5719
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5732
5720
  rows: 4,
5733
- onKeyDown: (g) => {
5734
- g.key === "Enter" && (g.preventDefault(), p.current && clearTimeout(p.current), x(void 0), n("styles", o, i, h));
5721
+ onKeyDown: (m) => {
5722
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), x(void 0), n("styles", o, i, h));
5735
5723
  }
5736
5724
  }
5737
5725
  ),
@@ -5772,37 +5760,37 @@ const AskAIStyles = ({ blockId: o }) => {
5772
5760
  ] });
5773
5761
  };
5774
5762
  function ManualClasses() {
5775
- var T;
5776
- const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), h = (T = first(n)) == null ? void 0 : T.prop, g = reject((get(a, h, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), j = () => {
5777
- const _ = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5778
- l(c, _, !0), u("");
5779
- }, [b, f] = useState([]), y = ({ value: _ }) => {
5780
- const P = _.trim().toLowerCase(), m = P.match(/.+:/g);
5781
- let E = [];
5782
- if (m && m.length > 0) {
5783
- const [R] = m, C = P.replace(R, "");
5784
- E = o.search(C).map((I) => ({
5763
+ var f;
5764
+ const o = useFuseSearch(), { t: r } = useTranslation(), [n] = useSelectedStylingBlocks(), a = useSelectedBlock(), l = useAddClassesToBlocks(), i = useRemoveClassesFromBlocks(), [c] = useSelectedBlockIds(), d = useBuilderProp("askAiCallBack", null), [p, u] = useState(""), { toast: x } = useToast(), h = (f = first(n)) == null ? void 0 : f.prop, m = reject((get(a, h, "").replace(STYLES_KEY, "").split(",").pop() || "").split(" "), isEmpty), E = () => {
5765
+ const j = p.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5766
+ l(c, j, !0), u("");
5767
+ }, [y, g] = useState([]), k = ({ value: j }) => {
5768
+ const w = j.trim().toLowerCase(), b = w.match(/.+:/g);
5769
+ let C = [];
5770
+ if (b && b.length > 0) {
5771
+ const [B] = b, N = w.replace(B, "");
5772
+ C = o.search(N).map((I) => ({
5785
5773
  ...I,
5786
- item: { ...I.item, name: R + I.item.name }
5774
+ item: { ...I.item, name: B + I.item.name }
5787
5775
  }));
5788
5776
  } else
5789
- E = o.search(P);
5790
- return f(map(E, "item"));
5791
- }, v = () => {
5792
- f([]);
5793
- }, B = (_) => _.name, A = (_) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: _.name }), S = {
5777
+ C = o.search(w);
5778
+ return g(map(C, "item"));
5779
+ }, _ = () => {
5780
+ g([]);
5781
+ }, A = (j) => j.name, S = (j) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "rounded-md p-1", children: j.name }), v = {
5794
5782
  autoComplete: "off",
5795
5783
  autoCorrect: "off",
5796
5784
  autoCapitalize: "off",
5797
5785
  spellCheck: !1,
5798
5786
  placeholder: r("Enter classes separated by space"),
5799
5787
  value: p,
5800
- onKeyDown: (_) => {
5801
- _.key === "Enter" && p.trim() !== "" && j();
5788
+ onKeyDown: (j) => {
5789
+ j.key === "Enter" && p.trim() !== "" && E();
5802
5790
  },
5803
- onChange: (_, { newValue: P }) => u(P),
5791
+ onChange: (j, { newValue: w }) => u(w),
5804
5792
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5805
- }, k = () => {
5793
+ }, R = () => {
5806
5794
  if (navigator.clipboard === void 0) {
5807
5795
  x({
5808
5796
  title: r("Clipboard not supported"),
@@ -5811,7 +5799,7 @@ function ManualClasses() {
5811
5799
  });
5812
5800
  return;
5813
5801
  }
5814
- navigator.clipboard.writeText(g.join(" ")), x({
5802
+ navigator.clipboard.writeText(m.join(" ")), x({
5815
5803
  title: r("Copied"),
5816
5804
  description: r("Classes copied to clipboard")
5817
5805
  });
@@ -5819,13 +5807,13 @@ function ManualClasses() {
5819
5807
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
5820
5808
  "div",
5821
5809
  {
5822
- className: `flex ${b.length > 0 ? "min-h-[300px]" : "min-h-max"} w-full flex-col gap-y-1.5 overflow-y-auto pb-4`,
5810
+ className: `flex ${y.length > 0 ? "min-h-[300px]" : "min-h-max"} w-full flex-col gap-y-1.5 overflow-y-auto pb-4`,
5823
5811
  children: [
5824
5812
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5825
5813
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5826
5814
  /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: r("Classes") }),
5827
5815
  /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
5828
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: k, className: "cursor-pointer" }) }),
5816
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(CopyIcon, { onClick: R, className: "cursor-pointer" }) }),
5829
5817
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: r("Copy classes to clipboard") }) })
5830
5818
  ] })
5831
5819
  ] }),
@@ -5841,12 +5829,12 @@ function ManualClasses() {
5841
5829
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
5842
5830
  Autosuggest,
5843
5831
  {
5844
- suggestions: b,
5845
- onSuggestionsFetchRequested: y,
5846
- onSuggestionsClearRequested: v,
5847
- getSuggestionValue: B,
5848
- renderSuggestion: A,
5849
- inputProps: S,
5832
+ suggestions: y,
5833
+ onSuggestionsFetchRequested: k,
5834
+ onSuggestionsClearRequested: _,
5835
+ getSuggestionValue: A,
5836
+ renderSuggestion: S,
5837
+ inputProps: v,
5850
5838
  containerProps: {
5851
5839
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
5852
5840
  },
@@ -5862,7 +5850,7 @@ function ManualClasses() {
5862
5850
  {
5863
5851
  variant: "outline",
5864
5852
  className: "h-6 border-border",
5865
- onClick: j,
5853
+ onClick: E,
5866
5854
  disabled: p.trim() === "",
5867
5855
  size: "sm",
5868
5856
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(PlusIcon, {})
@@ -5870,22 +5858,22 @@ function ManualClasses() {
5870
5858
  )
5871
5859
  ] }),
5872
5860
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: React.Children.toArray(
5873
- g.map((_) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5861
+ m.map((j) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
5874
5862
  "div",
5875
5863
  {
5876
5864
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate rounded border border-border bg-gray-200 p-px px-1.5 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
5877
5865
  children: [
5878
- _,
5866
+ j,
5879
5867
  /* @__PURE__ */ jsxRuntimeExports.jsx(
5880
5868
  Cross2Icon,
5881
5869
  {
5882
- onClick: () => i(c, [_]),
5870
+ onClick: () => i(c, [j]),
5883
5871
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5884
5872
  }
5885
5873
  )
5886
5874
  ]
5887
5875
  },
5888
- _
5876
+ j
5889
5877
  ))
5890
5878
  ) })
5891
5879
  ]
@@ -6276,10 +6264,10 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6276
6264
  ringColor: "ring",
6277
6265
  ringOffsetColor: "ring-offset"
6278
6266
  }, ColorChoice = ({ property: o, onChange: r }) => {
6279
- 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("-"), x = get(u, "1", ""), h = get(u, "2", ""), g = useCallback(
6267
+ 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("-"), x = get(u, "1", ""), h = get(u, "2", ""), m = useCallback(
6280
6268
  // eslint-disable-next-line no-shadow
6281
- (f) => {
6282
- ["current", "inherit", "transparent", "black", "white"].includes(f) ? (c([]), p({ color: f })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: f, shade: y.shade ? y.shade : "500" })));
6269
+ (g) => {
6270
+ ["current", "inherit", "transparent", "black", "white"].includes(g) ? (c([]), p({ color: g })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((k) => ({ ...k, color: g, shade: k.shade ? k.shade : "500" })));
6283
6271
  },
6284
6272
  [c, p]
6285
6273
  );
@@ -6288,28 +6276,28 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6288
6276
  return c([]);
6289
6277
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
6290
6278
  }, [x]);
6291
- const j = useCallback(
6279
+ const E = useCallback(
6292
6280
  // eslint-disable-next-line no-shadow
6293
- (f) => {
6294
- p({ color: x, shade: f });
6281
+ (g) => {
6282
+ p({ color: x, shade: g });
6295
6283
  },
6296
6284
  [x]
6297
6285
  );
6298
6286
  useEffect(() => {
6299
6287
  p({ color: "", shade: "" });
6300
6288
  }, [n]);
6301
- const { match: b } = useTailwindClassList();
6289
+ const { match: y } = useTailwindClassList();
6302
6290
  return useEffect(() => {
6303
- const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6304
- b(o, y) && r(y, o);
6305
- }, [b, d, r, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6291
+ const k = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6292
+ y(o, k) && r(k, o);
6293
+ }, [y, d, r, o]), /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6306
6294
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6307
6295
  DropDown,
6308
6296
  {
6309
6297
  disabled: !l,
6310
6298
  rounded: !0,
6311
6299
  selected: x,
6312
- onChange: g,
6300
+ onChange: m,
6313
6301
  options: [
6314
6302
  "current",
6315
6303
  "transparent",
@@ -6342,7 +6330,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6342
6330
  ]
6343
6331
  }
6344
6332
  ) }),
6345
- /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: h, disabled: !x || !l, onChange: j, options: i }) })
6333
+ /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DropDown, { rounded: !0, selected: h, disabled: !x || !l, onChange: E, options: i }) })
6346
6334
  ] });
6347
6335
  }, getUserInputValues = (o, r) => {
6348
6336
  o = o.toLowerCase();
@@ -6357,12 +6345,9 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6357
6345
  const r = o.startsWith("-") ? "-" : "", n = o.split("-").pop();
6358
6346
  if (["auto", "none"].includes(n))
6359
6347
  return { value: "", unit: n };
6360
- if (n === "px")
6361
- return { value: "1", unit: "px" };
6362
- if (n === "screen")
6363
- return { value: "100", unit: o.indexOf("w-") !== -1 ? "vw" : "vh" };
6364
- if (n === "full")
6365
- return { value: "100", unit: "%" };
6348
+ if (n === "px") return { value: "1", unit: "px" };
6349
+ if (n === "screen") return { value: "100", unit: o.indexOf("w-") !== -1 ? "vw" : "vh" };
6350
+ if (n === "full") return { value: "100", unit: "%" };
6366
6351
  if (includes(o, "skew-"))
6367
6352
  return { value: `${r}${n}`, unit: "deg" };
6368
6353
  if (includes(o, "rotate-"))
@@ -6377,105 +6362,60 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6377
6362
  return { value: `${r}${`${n / 100}`}`, unit: "-" };
6378
6363
  if (startsWith(o, "border")) {
6379
6364
  const a = o.match(/border-?(x|y|t|r|b|l)?\d+/g);
6380
- if (a)
6381
- return { value: a[0].split("-").pop(), unit: "px" };
6382
- if (o.match(/border-?(x|y|t|r|b|l)?/g))
6383
- return { value: "1", unit: "px" };
6365
+ if (a) return { value: a[0].split("-").pop(), unit: "px" };
6366
+ if (o.match(/border-?(x|y|t|r|b|l)?/g)) return { value: "1", unit: "px" };
6384
6367
  }
6385
6368
  if (startsWith(o, "max-w-")) {
6386
- if (o === "max-w-screen-sm")
6387
- return { value: "640", unit: "px" };
6388
- if (o === "max-w-screen-md")
6389
- return { value: "768", unit: "px" };
6390
- if (o === "max-w-screen-lg")
6391
- return { value: "1024", unit: "px" };
6392
- if (o === "max-w-screen-xl")
6393
- return { value: "1280", unit: "px" };
6394
- if (o === "max-w-screen-2xl")
6395
- return { value: "1536", unit: "px" };
6396
- if (n === "xs")
6397
- return { value: "320", unit: "px" };
6398
- if (n === "sm")
6399
- return { value: "384", unit: "px" };
6400
- if (n === "md")
6401
- return { value: "448", unit: "px" };
6402
- if (n === "lg")
6403
- return { value: "512", unit: "px" };
6404
- if (n === "xl")
6405
- return { value: "576", unit: "px" };
6406
- if (n === "2xl")
6407
- return { value: "672", unit: "px" };
6408
- if (n === "3xl")
6409
- return { value: "768", unit: "px" };
6410
- if (n === "4xl")
6411
- return { value: "896", unit: "px" };
6412
- if (n === "5xl")
6413
- return { value: "1024", unit: "px" };
6414
- if (n === "6xl")
6415
- return { value: "1152", unit: "px" };
6416
- if (n === "7xl")
6417
- return { value: "1280", unit: "px" };
6418
- if (n === "prose")
6419
- return { value: "65", unit: "ch" };
6369
+ if (o === "max-w-screen-sm") return { value: "640", unit: "px" };
6370
+ if (o === "max-w-screen-md") return { value: "768", unit: "px" };
6371
+ if (o === "max-w-screen-lg") return { value: "1024", unit: "px" };
6372
+ if (o === "max-w-screen-xl") return { value: "1280", unit: "px" };
6373
+ if (o === "max-w-screen-2xl") return { value: "1536", unit: "px" };
6374
+ if (n === "xs") return { value: "320", unit: "px" };
6375
+ if (n === "sm") return { value: "384", unit: "px" };
6376
+ if (n === "md") return { value: "448", unit: "px" };
6377
+ if (n === "lg") return { value: "512", unit: "px" };
6378
+ if (n === "xl") return { value: "576", unit: "px" };
6379
+ if (n === "2xl") return { value: "672", unit: "px" };
6380
+ if (n === "3xl") return { value: "768", unit: "px" };
6381
+ if (n === "4xl") return { value: "896", unit: "px" };
6382
+ if (n === "5xl") return { value: "1024", unit: "px" };
6383
+ if (n === "6xl") return { value: "1152", unit: "px" };
6384
+ if (n === "7xl") return { value: "1280", unit: "px" };
6385
+ if (n === "prose") return { value: "65", unit: "ch" };
6420
6386
  }
6421
6387
  if (startsWith(o, "text-")) {
6422
- if (n === "xs")
6423
- return { value: "12", unit: "px" };
6424
- if (n === "sm")
6425
- return { value: "14", unit: "px" };
6426
- if (n === "base")
6427
- return { value: "16", unit: "px" };
6428
- if (n === "lg")
6429
- return { value: "18", unit: "px" };
6430
- if (n === "xl")
6431
- return { value: "20", unit: "px" };
6432
- if (n === "2xl")
6433
- return { value: "24", unit: "px" };
6434
- if (n === "3xl")
6435
- return { value: "30", unit: "px" };
6436
- if (n === "4xl")
6437
- return { value: "36", unit: "px" };
6438
- if (n === "5xl")
6439
- return { value: "48", unit: "px" };
6440
- if (n === "6xl")
6441
- return { value: "60", unit: "px" };
6442
- if (n === "7xl")
6443
- return { value: "72", unit: "px" };
6444
- if (n === "8xl")
6445
- return { value: "96", unit: "px" };
6446
- if (n === "9xl")
6447
- return { value: "128", unit: "px" };
6388
+ if (n === "xs") return { value: "12", unit: "px" };
6389
+ if (n === "sm") return { value: "14", unit: "px" };
6390
+ if (n === "base") return { value: "16", unit: "px" };
6391
+ if (n === "lg") return { value: "18", unit: "px" };
6392
+ if (n === "xl") return { value: "20", unit: "px" };
6393
+ if (n === "2xl") return { value: "24", unit: "px" };
6394
+ if (n === "3xl") return { value: "30", unit: "px" };
6395
+ if (n === "4xl") return { value: "36", unit: "px" };
6396
+ if (n === "5xl") return { value: "48", unit: "px" };
6397
+ if (n === "6xl") return { value: "60", unit: "px" };
6398
+ if (n === "7xl") return { value: "72", unit: "px" };
6399
+ if (n === "8xl") return { value: "96", unit: "px" };
6400
+ if (n === "9xl") return { value: "128", unit: "px" };
6448
6401
  }
6449
6402
  if (startsWith(o, "leading-")) {
6450
- if (n === "none")
6451
- return { value: "1", unit: "-" };
6452
- if (n === "tight")
6453
- return { value: "1.25", unit: "-" };
6454
- if (n === "snug")
6455
- return { value: "1.375", unit: "-" };
6456
- if (n === "normal")
6457
- return { value: "1.5", unit: "-" };
6458
- if (n === "relaxed")
6459
- return { value: "1.625", unit: "-" };
6460
- if (n === "loose")
6461
- return { value: "2", unit: "-" };
6403
+ if (n === "none") return { value: "1", unit: "-" };
6404
+ if (n === "tight") return { value: "1.25", unit: "-" };
6405
+ if (n === "snug") return { value: "1.375", unit: "-" };
6406
+ if (n === "normal") return { value: "1.5", unit: "-" };
6407
+ if (n === "relaxed") return { value: "1.625", unit: "-" };
6408
+ if (n === "loose") return { value: "2", unit: "-" };
6462
6409
  }
6463
6410
  if (startsWith(o, "tracking-")) {
6464
- if (n === "tighter")
6465
- return { value: "-0.05", unit: "em" };
6466
- if (n === "tight")
6467
- return { value: "-0.025", unit: "em" };
6468
- if (n === "normal")
6469
- return { value: "0", unit: "em" };
6470
- if (n === "wide")
6471
- return { value: "0.025", unit: "em" };
6472
- if (n === "wider")
6473
- return { value: "0.05", unit: "em" };
6474
- if (n === "widest")
6475
- return { value: "0.1", unit: "em" };
6411
+ if (n === "tighter") return { value: "-0.05", unit: "em" };
6412
+ if (n === "tight") return { value: "-0.025", unit: "em" };
6413
+ if (n === "normal") return { value: "0", unit: "em" };
6414
+ if (n === "wide") return { value: "0.025", unit: "em" };
6415
+ if (n === "wider") return { value: "0.05", unit: "em" };
6416
+ if (n === "widest") return { value: "0.1", unit: "em" };
6476
6417
  }
6477
- if (["max", "min", "fit"].includes(n))
6478
- return { value: o, unit: "class" };
6418
+ if (["max", "min", "fit"].includes(n)) return { value: o, unit: "class" };
6479
6419
  if (n.includes("/")) {
6480
6420
  const [a, l] = map(n.split("/"), (i) => parseInt(i, 10));
6481
6421
  return { value: r + (a / l * 100).toFixed(2).replace(".00", ""), unit: "%" };
@@ -6537,50 +6477,50 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6537
6477
  },
6538
6478
  a
6539
6479
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6540
- const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [h, g] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [j, b] = useState(!1), [f, y] = useState(""), [v, B] = useState(!1), [A, S] = useState(!1);
6480
+ const [r, n] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: x } = o, [h, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [E, y] = useState(!1), [g, k] = useState(""), [_, A] = useState(!1), [S, v] = useState(!1);
6541
6481
  useEffect(() => {
6542
- const { value: m, unit: E } = getClassValueAndUnit(i);
6543
- if (E === "") {
6544
- l(m), g(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6482
+ const { value: b, unit: C } = getClassValueAndUnit(i);
6483
+ if (C === "") {
6484
+ l(b), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6545
6485
  return;
6546
6486
  }
6547
- g(E), l(E === "class" || isEmpty(m) ? "" : m);
6487
+ m(C), l(C === "class" || isEmpty(b) ? "" : b);
6548
6488
  }, [i, p, u]);
6549
- const k = useThrottledCallback((m) => c(m), [c], THROTTLE_TIME), T = useThrottledCallback((m) => c(m, !1), [c], THROTTLE_TIME), _ = useCallback(
6550
- (m = !1) => {
6551
- const E = getUserInputValues(`${a}`, u);
6552
- if (get(E, "error", !1)) {
6553
- b(!0);
6489
+ const R = useThrottledCallback((b) => c(b), [c], THROTTLE_TIME), f = useThrottledCallback((b) => c(b, !1), [c], THROTTLE_TIME), j = useCallback(
6490
+ (b = !1) => {
6491
+ const C = getUserInputValues(`${a}`, u);
6492
+ if (get(C, "error", !1)) {
6493
+ y(!0);
6554
6494
  return;
6555
6495
  }
6556
- const R = get(E, "unit") !== "" ? get(E, "unit") : h;
6557
- if (R === "auto" || R === "none") {
6558
- k(`${d}${R}`);
6496
+ const B = get(C, "unit") !== "" ? get(C, "unit") : h;
6497
+ if (B === "auto" || B === "none") {
6498
+ R(`${d}${B}`);
6559
6499
  return;
6560
6500
  }
6561
- if (get(E, "value") === "")
6501
+ if (get(C, "value") === "")
6562
6502
  return;
6563
- const N = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${R === "-" ? "" : R}]`;
6564
- m ? T(N) : k(N);
6503
+ const D = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6504
+ b ? f(D) : R(D);
6565
6505
  },
6566
- [k, T, a, h, d, u]
6567
- ), P = useCallback(
6568
- (m) => {
6569
- const E = getUserInputValues(`${a}`, u);
6570
- if (get(E, "error", !1)) {
6571
- b(!0);
6506
+ [R, f, a, h, d, u]
6507
+ ), w = useCallback(
6508
+ (b) => {
6509
+ const C = getUserInputValues(`${a}`, u);
6510
+ if (get(C, "error", !1)) {
6511
+ y(!0);
6572
6512
  return;
6573
6513
  }
6574
- if (m === "auto" || m === "none") {
6575
- k(`${d}${m}`);
6514
+ if (b === "auto" || b === "none") {
6515
+ R(`${d}${b}`);
6576
6516
  return;
6577
6517
  }
6578
- if (get(E, "value") === "")
6518
+ if (get(C, "value") === "")
6579
6519
  return;
6580
- const R = get(E, "unit") !== "" ? get(E, "unit") : m, N = `${get(E, "value", "").startsWith("-") ? "-" : ""}${d}[${get(E, "value", "").replace("-", "")}${R === "-" ? "" : R}]`;
6581
- k(N);
6520
+ const B = get(C, "unit") !== "" ? get(C, "unit") : b, D = `${get(C, "value", "").startsWith("-") ? "-" : ""}${d}[${get(C, "value", "").replace("-", "")}${B === "-" ? "" : B}]`;
6521
+ R(D);
6582
6522
  },
6583
- [k, a, d, u]
6523
+ [R, a, d, u]
6584
6524
  );
6585
6525
  return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex items-center justify-start", children: h === "class" ? /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
6586
6526
  /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -6595,40 +6535,40 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6595
6535
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsxRuntimeExports.jsx(InfoCircledIcon, {}) }) }),
6596
6536
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6597
6537
  ] })
6598
- ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${v ? "z-auto" : ""}`, children: [
6538
+ ] }) : /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: `group relative flex items-center ${_ ? "z-auto" : ""}`, children: [
6599
6539
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6600
6540
  ["none", "auto"].indexOf(h) !== -1 ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
6601
6541
  "input",
6602
6542
  {
6603
6543
  readOnly: h === "class",
6604
- onKeyPress: (m) => {
6605
- m.key === "Enter" && _();
6544
+ onKeyPress: (b) => {
6545
+ b.key === "Enter" && j();
6606
6546
  },
6607
- onKeyDown: (m) => {
6608
- if (m.keyCode !== 38 && m.keyCode !== 40)
6547
+ onKeyDown: (b) => {
6548
+ if (b.keyCode !== 38 && b.keyCode !== 40)
6609
6549
  return;
6610
- m.preventDefault(), S(!0);
6611
- const E = parseInt$1(m.target.value);
6612
- let R = isNaN$1(E) ? 0 : E;
6613
- m.keyCode === 38 && (R += 1), m.keyCode === 40 && (R -= 1);
6614
- const C = `${R}`, I = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
6615
- T(I);
6550
+ b.preventDefault(), v(!0);
6551
+ const C = parseInt$1(b.target.value);
6552
+ let B = isNaN$1(C) ? 0 : C;
6553
+ b.keyCode === 38 && (B += 1), b.keyCode === 40 && (B -= 1);
6554
+ const N = `${B}`, I = `${N.startsWith("-") ? "-" : ""}${d}[${N.replace("-", "")}${h === "-" ? "" : h}]`;
6555
+ f(I);
6616
6556
  },
6617
- onKeyUp: (m) => {
6618
- A && (m.preventDefault(), S(!1));
6557
+ onKeyUp: (b) => {
6558
+ S && (b.preventDefault(), v(!1));
6619
6559
  },
6620
- onBlur: () => _(),
6621
- onChange: (m) => {
6622
- b(!1), l(m.target.value);
6560
+ onBlur: () => j(),
6561
+ onChange: (b) => {
6562
+ y(!1), l(b.target.value);
6623
6563
  },
6624
- onClick: (m) => {
6625
- var E;
6626
- (E = m == null ? void 0 : m.target) == null || E.select(), n(!1);
6564
+ onClick: (b) => {
6565
+ var C;
6566
+ (C = b == null ? void 0 : b.target) == null || C.select(), n(!1);
6627
6567
  },
6628
- value: v ? f : a,
6568
+ value: _ ? g : a,
6629
6569
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6630
6570
  " ",
6631
- j ? "border-red-500 text-red-500" : "border-foreground/20"
6571
+ E ? "border-red-500 text-red-500" : "border-foreground/20"
6632
6572
  )
6633
6573
  }
6634
6574
  ),
@@ -6650,29 +6590,29 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6650
6590
  {
6651
6591
  units: u,
6652
6592
  current: h,
6653
- onSelect: (m) => {
6654
- n(!1), g(m), P(m);
6593
+ onSelect: (b) => {
6594
+ n(!1), m(b), w(b);
6655
6595
  }
6656
6596
  }
6657
6597
  ) }) })
6658
6598
  ] })
6659
6599
  ] }),
6660
- ["none", "auto"].indexOf(h) !== -1 || v ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
6600
+ ["none", "auto"].indexOf(h) !== -1 || _ ? null : /* @__PURE__ */ jsxRuntimeExports.jsx(
6661
6601
  DragStyleButton,
6662
6602
  {
6663
- onDragStart: () => B(!0),
6664
- onDragEnd: (m) => {
6665
- if (y(() => ""), B(!1), isEmpty(m))
6603
+ onDragStart: () => A(!0),
6604
+ onDragEnd: (b) => {
6605
+ if (k(() => ""), A(!1), isEmpty(b))
6666
6606
  return;
6667
- const E = `${m}`, C = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${h === "-" ? "" : h}]`;
6668
- k(C);
6607
+ const C = `${b}`, N = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
6608
+ R(N);
6669
6609
  },
6670
- onDrag: (m) => {
6671
- if (isEmpty(m))
6610
+ onDrag: (b) => {
6611
+ if (isEmpty(b))
6672
6612
  return;
6673
- y(m);
6674
- const E = `${m}`, C = `${E.startsWith("-") ? "-" : ""}${d}[${E.replace("-", "")}${h === "-" ? "" : h}]`;
6675
- T(C);
6613
+ k(b);
6614
+ const C = `${b}`, N = `${C.startsWith("-") ? "-" : ""}${d}[${C.replace("-", "")}${h === "-" ? "" : h}]`;
6615
+ f(N);
6676
6616
  },
6677
6617
  currentValue: a,
6678
6618
  unit: h,
@@ -6769,35 +6709,35 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6769
6709
  "2xl": "1536px"
6770
6710
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6771
6711
  const { t: r } = useTranslation(), { type: n = "icons", label: a, property: l, onEmitChange: i = () => {
6772
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), h = useCurrentClassByProperty(l), g = useAddClassesToBlocks(), j = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), f = useMemo(() => get(h, "fullCls", ""), [h]), y = useCallback(
6773
- (T, _ = !0) => {
6774
- const P = { dark: p, mq: x, mod: u, cls: T, property: l, fullCls: "" };
6775
- (p || u !== "") && (P.mq = "xs");
6776
- const m = generateFullClsName(P);
6777
- g(b, [m], _);
6712
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, x] = useCanvasWidth(), h = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), E = useRemoveClassesFromBlocks(), [y] = useSelectedBlockIds(), g = useMemo(() => get(h, "fullCls", ""), [h]), k = useCallback(
6713
+ (f, j = !0) => {
6714
+ const w = { dark: p, mq: x, mod: u, cls: f, property: l, fullCls: "" };
6715
+ (p || u !== "") && (w.mq = "xs");
6716
+ const b = generateFullClsName(w);
6717
+ m(y, [b], j);
6778
6718
  },
6779
- [b, p, x, u, l, g]
6780
- ), v = useCallback(() => {
6781
- j(b, [f]);
6782
- }, [b, f, j]), B = useMemo(() => canChangeClass(h, x), [h, x]);
6719
+ [y, p, x, u, l, m]
6720
+ ), _ = useCallback(() => {
6721
+ E(y, [g]);
6722
+ }, [y, g, E]), A = useMemo(() => canChangeClass(h, x), [h, x]);
6783
6723
  useEffect(() => {
6784
- i(B, h);
6785
- }, [B, i, h]);
6786
- const [, , A] = useCanvasWidth(), S = useCallback(
6787
- (T) => {
6788
- A({
6724
+ i(A, h);
6725
+ }, [A, i, h]);
6726
+ const [, , S] = useCanvasWidth(), v = useCallback(
6727
+ (f) => {
6728
+ S({
6789
6729
  xs: 400,
6790
6730
  sm: 640,
6791
6731
  md: 800,
6792
6732
  lg: 1024,
6793
6733
  xl: 1420,
6794
6734
  "2xl": 1920
6795
- }[T]);
6735
+ }[f]);
6796
6736
  },
6797
- [A]
6798
- ), k = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === x;
6799
- return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: B, canReset: h && k, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6800
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${h && !k ? "text-foreground" : ""}`, children: r(a) }) }),
6737
+ [S]
6738
+ ), R = get(h, "dark", null) === p && get(h, "mod", null) === u && get(h, "mq", null) === x;
6739
+ return /* @__PURE__ */ jsxRuntimeExports.jsx(BlockStyleProvider, { canChange: A, canReset: h && R, children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6740
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: `text-[11px] ${h && !R ? "text-foreground" : ""}`, children: r(a) }) }),
6801
6741
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row items-center", children: [
6802
6742
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "w-[150px]", children: [
6803
6743
  n === "arbitrary" ? /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -6806,17 +6746,17 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6806
6746
  currentClass: get(h, "cls", ""),
6807
6747
  classPrefix: get(CLASS_PREFIXES, l, ""),
6808
6748
  units: c || [],
6809
- onChange: y,
6749
+ onChange: k,
6810
6750
  negative: d,
6811
6751
  cssProperty: l
6812
6752
  }
6813
6753
  ) : null,
6814
- n === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: y }),
6815
- n === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: y }),
6816
- n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: y }),
6817
- n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: y })
6754
+ n === "icons" && /* @__PURE__ */ jsxRuntimeExports.jsx(IconChoices, { property: l, onChange: k }),
6755
+ n === "range" && /* @__PURE__ */ jsxRuntimeExports.jsx(RangeChoices, { property: l, onChange: k }),
6756
+ n === "color" && /* @__PURE__ */ jsxRuntimeExports.jsx(ColorChoice, { property: l, onChange: k }),
6757
+ n === "dropdown" && /* @__PURE__ */ jsxRuntimeExports.jsx(DropDownChoices, { label: a, property: l, onChange: k })
6818
6758
  ] }),
6819
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${f ? "visible" : "invisible"}`, children: k ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => v(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : B && h ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
6759
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: `w-[30px] cursor-pointer ${g ? "visible" : "invisible"}`, children: R ? /* @__PURE__ */ jsxRuntimeExports.jsx("button", { type: "button", onClick: () => _(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : A && h ? /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { delayDuration: 100, children: [
6820
6760
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
6821
6761
  "button",
6822
6762
  {
@@ -6836,7 +6776,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6836
6776
  "button",
6837
6777
  {
6838
6778
  type: "button",
6839
- onClick: () => S(get(h, "mq")),
6779
+ onClick: () => v(get(h, "mq")),
6840
6780
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6841
6781
  children: [
6842
6782
  "Switch to ",
@@ -6857,7 +6797,7 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6857
6797
  units: i = basicUnits,
6858
6798
  negative: c = !1
6859
6799
  }) => {
6860
- const { t: d } = useTranslation(), [p, u] = useState(r[0].key), x = useSelectedBlockCurrentClasses(), h = useCallback((g) => map(x, "property").includes(g), [x]);
6800
+ const { t: d } = useTranslation(), [p, u] = useState(r[0].key), x = useSelectedBlockCurrentClasses(), h = useCallback((m) => map(x, "property").includes(m), [x]);
6861
6801
  return /* @__PURE__ */ jsxRuntimeExports.jsxs(
6862
6802
  "div",
6863
6803
  {
@@ -6866,22 +6806,22 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6866
6806
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-row text-xs", children: [
6867
6807
  o && /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6868
6808
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6869
- r.map(({ label: g, key: j }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
6809
+ r.map(({ label: m, key: E }) => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
6870
6810
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
6871
6811
  "button",
6872
6812
  {
6873
6813
  type: "button",
6874
- onClick: () => u(j),
6875
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${j === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6814
+ onClick: () => u(E),
6815
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${E === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6876
6816
  children: [
6877
6817
  React__default.createElement("div", {
6878
- className: h(j) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6818
+ className: h(E) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6879
6819
  }),
6880
- React__default.createElement(get(EDITOR_ICONS, j, BoxIcon), { className: "text-inherit w-3 h-3" })
6820
+ React__default.createElement(get(EDITOR_ICONS, E, BoxIcon), { className: "text-inherit w-3 h-3" })
6881
6821
  ]
6882
6822
  }
6883
6823
  ) }),
6884
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(g)) })
6824
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: startCase(toLower(m)) })
6885
6825
  ] }) }))
6886
6826
  ) })
6887
6827
  ] }),
@@ -6971,13 +6911,11 @@ const RangeChoices = ({ property: o, onChange: r }) => {
6971
6911
  ] }) });
6972
6912
  }, BlockStylingProps = () => {
6973
6913
  const o = useSelectedBlock(), [r, n] = useSelectedStylingBlocks(), { t: a } = useTranslation();
6974
- if (!o)
6975
- return null;
6914
+ if (!o) return null;
6976
6915
  const l = Object.keys(o).filter(
6977
6916
  (c) => typeof o[c] == "string" && o[c].startsWith("#styles:")
6978
6917
  );
6979
- if (isEmpty(l) || l.length <= 1)
6980
- return null;
6918
+ if (isEmpty(l) || l.length <= 1) return null;
6981
6919
  const i = (c) => find(r, (d) => d.prop === c);
6982
6920
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-wrap gap-1", children: [
6983
6921
  /* @__PURE__ */ jsxRuntimeExports.jsxs("label", { htmlFor: "block-styling-props", className: "py-1 text-xs", children: [
@@ -7023,12 +6961,12 @@ function BlockStyling() {
7023
6961
  }), d = useThrottledCallback(
7024
6962
  (u) => {
7025
6963
  const x = !get(i, "negative", !1), h = get(i, "cssProperty", "");
7026
- let g = parseFloat(i.dragStartValue);
7027
- g = isNaN(g) ? 0 : g;
7028
- let j = MAPPER[i.dragUnit];
7029
- (startsWith(h, "scale") || h === "opacity") && (j = 10);
7030
- let f = (i.dragStartY - u.pageY) / j + g;
7031
- x && f < 0 && (f = 0), h === "opacity" && f > 1 && (f = 1), i.onDrag(`${f}`), l(`${f}`);
6964
+ let m = parseFloat(i.dragStartValue);
6965
+ m = isNaN(m) ? 0 : m;
6966
+ let E = MAPPER[i.dragUnit];
6967
+ (startsWith(h, "scale") || h === "opacity") && (E = 10);
6968
+ let g = (i.dragStartY - u.pageY) / E + m;
6969
+ x && g < 0 && (g = 0), h === "opacity" && g > 1 && (g = 1), i.onDrag(`${g}`), l(`${g}`);
7032
6970
  },
7033
6971
  [i],
7034
6972
  50
@@ -7087,7 +7025,7 @@ const ChaiSelect = ({
7087
7025
  ]
7088
7026
  }
7089
7027
  ) });
7090
- }, ChaiSelect$1 = ChaiSelect;
7028
+ };
7091
7029
  function UILibrariesSelect({
7092
7030
  uiLibraries: o,
7093
7031
  library: r,
@@ -7097,7 +7035,7 @@ function UILibrariesSelect({
7097
7035
  return r ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "h-12", children: [
7098
7036
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "text-xs font-bold text-gray-500", children: a("Choose library") }),
7099
7037
  /* @__PURE__ */ jsxRuntimeExports.jsx(
7100
- ChaiSelect$1,
7038
+ ChaiSelect,
7101
7039
  {
7102
7040
  className: "mt-1",
7103
7041
  options: o.map((l) => ({
@@ -7116,33 +7054,33 @@ const BlockCard = ({
7116
7054
  parentId: n = void 0,
7117
7055
  position: a = -1
7118
7056
  }) => {
7119
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), h = get(o, "name", get(o, "label")), g = useFeature("dnd"), [, j] = useAtom$1(draggedBlockAtom), b = (v) => {
7120
- const B = has(v, "styles_attrs.data-page-section");
7121
- return v._type === "Box" && B;
7122
- }, f = useCallback(
7123
- async (v) => {
7124
- if (v.stopPropagation(), has(o, "component")) {
7057
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: x } = useBlockHighlight(), h = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, E] = useAtom$1(draggedBlockAtom), y = (_) => {
7058
+ const A = has(_, "styles_attrs.data-page-section");
7059
+ return _._type === "Box" && A;
7060
+ }, g = useCallback(
7061
+ async (_) => {
7062
+ if (_.stopPropagation(), has(o, "component")) {
7125
7063
  d(o, n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7126
7064
  return;
7127
7065
  }
7128
7066
  i(!0);
7129
- const B = await c(r, o);
7130
- isEmpty(B) || p(syncBlocksWithDefaults(B), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7067
+ const A = await c(r, o);
7068
+ isEmpty(A) || p(syncBlocksWithDefaults(A), n, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7131
7069
  },
7132
7070
  [d, p, o, c, r, n, a]
7133
- ), y = async (v) => {
7134
- const B = await c(r, o);
7135
- let A = n;
7136
- if (b(first(B)) && (A = null), !isEmpty(B)) {
7137
- const S = { blocks: B, uiLibrary: !0, parent: A };
7138
- if (v.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7139
- const k = new Image();
7140
- k.src = o.preview, k.onload = () => {
7141
- v.dataTransfer.setDragImage(k, 0, 0);
7071
+ ), k = async (_) => {
7072
+ const A = await c(r, o);
7073
+ let S = n;
7074
+ if (y(first(A)) && (S = null), !isEmpty(A)) {
7075
+ const v = { blocks: A, uiLibrary: !0, parent: S };
7076
+ if (_.dataTransfer.setData("text/plain", JSON.stringify(v)), o.preview) {
7077
+ const R = new Image();
7078
+ R.src = o.preview, R.onload = () => {
7079
+ _.dataTransfer.setDragImage(R, 0, 0);
7142
7080
  };
7143
7081
  } else
7144
- v.dataTransfer.setDragImage(new Image(), 0, 0);
7145
- j(S), setTimeout(() => {
7082
+ _.dataTransfer.setDragImage(new Image(), 0, 0);
7083
+ E(v), setTimeout(() => {
7146
7084
  u([]), x(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7147
7085
  }, 200);
7148
7086
  }
@@ -7152,9 +7090,9 @@ const BlockCard = ({
7152
7090
  "div",
7153
7091
  {
7154
7092
  onClick: l ? () => {
7155
- } : f,
7156
- draggable: g ? "true" : "false",
7157
- onDragStart: y,
7093
+ } : g,
7094
+ draggable: m ? "true" : "false",
7095
+ onDragStart: k,
7158
7096
  className: clsx(
7159
7097
  "relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
7160
7098
  ),
@@ -7175,17 +7113,16 @@ const BlockCard = ({
7175
7113
  const [r, n] = useAtom$1(libraryBlocksAtom), a = useBuilderProp("getUILibraryBlocks", noop), l = get(r, `${o == null ? void 0 : o.uuid}.blocks`, null), i = get(r, `${o == null ? void 0 : o.uuid}.loading`, "idle"), c = useRef("idle");
7176
7114
  return useEffect(() => {
7177
7115
  (async () => {
7178
- if (i === "complete" || c.current === "loading")
7179
- return;
7116
+ if (i === "complete" || c.current === "loading") return;
7180
7117
  c.current = "loading", n((p) => ({ ...p, [o == null ? void 0 : o.uuid]: { loading: "loading", blocks: [] } }));
7181
7118
  const d = await a(o);
7182
7119
  c.current = "idle", n((p) => ({ ...p, [o == null ? void 0 : o.uuid]: { loading: "complete", blocks: d || [] } }));
7183
7120
  })();
7184
7121
  }, [o, l, i, c, n, a]), { data: l || [], isLoading: i === "loading" };
7185
7122
  }, UILibrarySection = ({ parentId: o, position: r }) => {
7186
- const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((A) => A.category === "custom"), d = l.find((A) => A.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [h, g] = useState("Hero"), j = get(x, h, []), b = useRef(null), { t: f } = useTranslation(), y = (A) => {
7187
- b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
7188
- b.current && g(A);
7123
+ const [n, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((S) => S.category === "custom"), d = l.find((S) => S.uuid === n) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), x = groupBy([...p, ...c], "group"), [h, m] = useState("Hero"), E = get(x, h, []), y = useRef(null), { t: g } = useTranslation(), k = (S) => {
7124
+ y.current && (clearTimeout(y.current), y.current = null), y.current = setTimeout(() => {
7125
+ y.current && m(S);
7189
7126
  }, 300);
7190
7127
  };
7191
7128
  if (u)
@@ -7193,30 +7130,30 @@ const BlockCard = ({
7193
7130
  /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-3 h-full" }),
7194
7131
  /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "col-span-9 h-full" })
7195
7132
  ] });
7196
- const v = filter(j, (A, S) => S % 2 === 0), B = filter(j, (A, S) => S % 2 === 1);
7133
+ const _ = filter(E, (S, v) => v % 2 === 0), A = filter(E, (S, v) => v % 2 === 1);
7197
7134
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full pt-2", children: [
7198
7135
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7199
7136
  /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
7200
7137
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7201
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: f("Groups") }),
7138
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-xs font-bold text-gray-500", children: g("Groups") }),
7202
7139
  /* @__PURE__ */ jsxRuntimeExports.jsx("hr", { className: "mt-1 border-border" }),
7203
7140
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
7204
- map(x, (A, S) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
7141
+ map(x, (S, v) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
7205
7142
  "div",
7206
7143
  {
7207
- onMouseEnter: () => y(S),
7208
- onMouseLeave: () => clearTimeout(b.current),
7209
- onClick: () => g(S),
7144
+ onMouseEnter: () => k(v),
7145
+ onMouseLeave: () => clearTimeout(y.current),
7146
+ onClick: () => m(v),
7210
7147
  className: cn(
7211
7148
  "flex w-full cursor-pointer items-center justify-between rounded-md p-2 text-sm text-foreground transition-all ease-in-out hover:bg-gray-200 dark:hover:bg-gray-800",
7212
- S === h ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7149
+ v === h ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7213
7150
  ),
7214
7151
  children: [
7215
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(f(S.toLowerCase())) }),
7152
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: capitalize(g(v.toLowerCase())) }),
7216
7153
  /* @__PURE__ */ jsxRuntimeExports.jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7217
7154
  ]
7218
7155
  },
7219
- S
7156
+ v
7220
7157
  ))
7221
7158
  ) })
7222
7159
  ] })
@@ -7224,15 +7161,15 @@ const BlockCard = ({
7224
7161
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
7225
7162
  ScrollArea,
7226
7163
  {
7227
- onMouseEnter: () => b.current ? clearTimeout(b.current) : null,
7164
+ onMouseEnter: () => y.current ? clearTimeout(y.current) : null,
7228
7165
  className: "z-10 -mt-2 flex h-full max-h-full w-full flex-col gap-2 border-l border-border transition-all ease-linear",
7229
7166
  children: [
7230
7167
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7231
7168
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7232
- v.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: A, library: d }))
7169
+ _.map((S) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: S, library: d }))
7233
7170
  ) }),
7234
7171
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7235
- B.map((A) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: A, library: d }))
7172
+ A.map((S) => /* @__PURE__ */ jsxRuntimeExports.jsx(BlockCard, { parentId: o, position: r, block: S, library: d }))
7236
7173
  ) })
7237
7174
  ] }),
7238
7175
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
@@ -7242,7 +7179,7 @@ const BlockCard = ({
7242
7179
  }
7243
7180
  )
7244
7181
  ] }) }) });
7245
- }, UILibrariesPanel = ({ parentId: o, position: r }) => /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrarySection, { parentId: o, position: r }), UILibraries = UILibrariesPanel, Core = "Core", Import = "Import", Breakpoints$1 = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = {
7182
+ }, UILibrariesPanel = ({ parentId: o, position: r }) => /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrarySection, { parentId: o, position: r }), Core = "Core", Import = "Import", Breakpoints$1 = "Breakpoints", Clear = "Clear", Cancel = "Cancel", Yes = "Yes", Preview = "Preview", Settings = "Settings", Styling = "Styling", Remove = "Remove", Choose = "Choose", Cut = "Cut", Copy = "Copy", Paste = "Paste", Delete = "Delete", classes = "classes", Theme = "Theme", Outline = "Outline", Copied = "Copied", Stop = "Stop", Edit = "Edit", Tag = "Tag", Value = "Value", Images = "Images", Library = "Library", Blocks = "Blocks", Basic = "Basic", Media = "Media", Advanced = "Advanced", Form = "Form", Groups = "Groups", Accordions = "Accordions", Buttons = "Buttons", Layouts = "Layouts", FAQ = "FAQ", Hero = "Hero", Features = "Features", Footer = "Footer", Navbar = "Navbar", Icons = "Icons", Testimonials = "Testimonials", Blog = "Blog", Saved = "Saved", Unsaved = "Unsaved", Randomize = "Randomize", theme_config = {
7246
7183
  heading_font: "Heading Font",
7247
7184
  body_font: "Body Font",
7248
7185
  rounded_corner: "Rounded Corners",
@@ -7741,35 +7678,35 @@ const CoreBlock = ({
7741
7678
  parentId: n,
7742
7679
  position: a
7743
7680
  }) => {
7744
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, x] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), g = () => {
7681
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, x] = useSelectedBlockIds(), { clearHighlight: h } = useBlockHighlight(), m = () => {
7745
7682
  if (has(o, "blocks")) {
7746
- const f = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
7747
- u(syncBlocksWithDefaults(f), n || null, a);
7683
+ const g = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
7684
+ u(syncBlocksWithDefaults(g), n || null, a);
7748
7685
  } else
7749
7686
  p(o, n || null, a);
7750
7687
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7751
- }, j = useFeature("dnd"), { t: b } = useTranslation();
7688
+ }, E = useFeature("dnd"), { t: y } = useTranslation();
7752
7689
  return /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
7753
7690
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(
7754
7691
  "button",
7755
7692
  {
7756
7693
  disabled: r,
7757
- onClick: g,
7694
+ onClick: m,
7758
7695
  type: "button",
7759
- onDragStart: (f) => {
7760
- f.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), f.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
7696
+ onDragStart: (g) => {
7697
+ g.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), g.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
7761
7698
  x([]), h();
7762
7699
  }, 200);
7763
7700
  },
7764
- draggable: j ? "true" : "false",
7701
+ draggable: E ? "true" : "false",
7765
7702
  className: "cursor-pointer space-y-2 rounded-lg border border-border p-3 text-center hover:bg-slate-300/50 disabled:cursor-not-allowed disabled:bg-gray-100 disabled:text-gray-400 dark:border-gray-700 dark:text-white dark:hover:bg-slate-800/50 dark:disabled:bg-gray-900 dark:disabled:text-foreground",
7766
7703
  children: [
7767
7704
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
7768
- /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs", children: capitalize(b(d || i)) })
7705
+ /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "truncate text-xs", children: capitalize(y(d || i)) })
7769
7706
  ]
7770
7707
  }
7771
7708
  ) }),
7772
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: b(d || i) }) })
7709
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: y(d || i) }) })
7773
7710
  ] }) });
7774
7711
  }, DefaultChaiBlocks = ({
7775
7712
  parentId: o,
@@ -7839,14 +7776,14 @@ const CoreBlock = ({
7839
7776
  map(u, (h) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsTrigger, { value: h.key, children: React__default.createElement(h.tab) }))
7840
7777
  ] }),
7841
7778
  /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: n, position: a }) }) }) }),
7842
- /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(UILibraries, { parentId: n, position: a }) }),
7843
- p ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImportHTML$1, { parentId: n, position: a }) }) : null,
7779
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(UILibrariesPanel, { parentId: n, position: a }) }),
7780
+ p ? /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ImportHTML, { parentId: n, position: a }) }) : null,
7844
7781
  map(u, (h) => /* @__PURE__ */ jsxRuntimeExports.jsx(TabsContent, { value: h.key, children: React__default.createElement(h.tabContent, { close: x, parentId: n, position: a }) }))
7845
7782
  ]
7846
7783
  }
7847
7784
  )
7848
7785
  ] });
7849
- }, AddBlocksPanel$1 = AddBlocksPanel;
7786
+ };
7850
7787
  function usePubSub(o, r) {
7851
7788
  useEffect(() => {
7852
7789
  const n = pubsub.subscribe(o, r);
@@ -7871,7 +7808,7 @@ const AddBlocksDialog = () => {
7871
7808
  }
7872
7809
  )
7873
7810
  ] }),
7874
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar h-[500px] max-h-full overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlocksPanel$1, { parentId: r, position: a, showHeading: !1 }) })
7811
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar h-[500px] max-h-full overflow-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlocksPanel, { parentId: r, position: a, showHeading: !1 }) })
7875
7812
  ] }) });
7876
7813
  };
7877
7814
  function FaFilePen(o) {
@@ -7956,14 +7893,14 @@ function QuickPrompts({ onClick: o }) {
7956
7893
  ) }) });
7957
7894
  }
7958
7895
  const AIUserPrompt = ({ blockId: o }) => {
7959
- const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, x] = useState(), h = useRef(null), g = useRef(null);
7896
+ const { t: r } = useTranslation(), { askAi: n, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, x] = useState(), h = useRef(null), m = useRef(null);
7960
7897
  useEffect(() => {
7961
- var b;
7962
- (b = h.current) == null || b.focus();
7898
+ var y;
7899
+ (y = h.current) == null || y.focus();
7963
7900
  }, []);
7964
- const j = (b) => {
7965
- const { usage: f } = b || {};
7966
- !l && f && x(f), g.current = setTimeout(() => x(void 0), 1e4), l || c("");
7901
+ const E = (y) => {
7902
+ const { usage: g } = y || {};
7903
+ !l && g && x(g), m.current = setTimeout(() => x(void 0), 1e4), l || c("");
7967
7904
  };
7968
7905
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "", children: [
7969
7906
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
@@ -7983,12 +7920,12 @@ const AIUserPrompt = ({ blockId: o }) => {
7983
7920
  {
7984
7921
  ref: h,
7985
7922
  value: i,
7986
- onChange: (b) => c(b.target.value),
7923
+ onChange: (y) => c(y.target.value),
7987
7924
  placeholder: r("Ask AI to edit content"),
7988
7925
  className: "w-full",
7989
7926
  rows: 3,
7990
- onKeyDown: (b) => {
7991
- b.key === "Enter" && (b.preventDefault(), g.current && clearTimeout(g.current), x(void 0), n("content", o, i, j));
7927
+ onKeyDown: (y) => {
7928
+ y.key === "Enter" && (y.preventDefault(), m.current && clearTimeout(m.current), x(void 0), n("content", o, i, E));
7992
7929
  }
7993
7930
  }
7994
7931
  ),
@@ -7998,7 +7935,7 @@ const AIUserPrompt = ({ blockId: o }) => {
7998
7935
  {
7999
7936
  disabled: i.trim().length < 5 || a,
8000
7937
  onClick: () => {
8001
- g.current && clearTimeout(g.current), x(void 0), n("content", o, i, j);
7938
+ m.current && clearTimeout(m.current), x(void 0), n("content", o, i, E);
8002
7939
  },
8003
7940
  variant: "default",
8004
7941
  className: "w-fit",
@@ -8030,8 +7967,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8030
7967
  /* @__PURE__ */ jsxRuntimeExports.jsx(
8031
7968
  QuickPrompts,
8032
7969
  {
8033
- onClick: (b) => {
8034
- g.current && clearTimeout(g.current), x(void 0), n("content", o, b, j);
7970
+ onClick: (y) => {
7971
+ m.current && clearTimeout(m.current), x(void 0), n("content", o, y, E);
8035
7972
  }
8036
7973
  }
8037
7974
  )
@@ -8041,19 +7978,19 @@ const AIUserPrompt = ({ blockId: o }) => {
8041
7978
  ] }) }) : null
8042
7979
  ] });
8043
7980
  }, AISetContext = () => {
8044
- 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), [, x] = useState(!1), { toast: h } = useToast(), g = useRef(null);
7981
+ 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), [, x] = useState(!1), { toast: h } = useToast(), m = useRef(null);
8045
7982
  useEffect(() => {
8046
7983
  r && a(r);
8047
7984
  }, [r]);
8048
- const j = async () => {
7985
+ const E = async () => {
8049
7986
  try {
8050
7987
  d(!0), u(null), await i(n), h({
8051
7988
  title: o("Updated AI Context"),
8052
7989
  description: o("You can now Ask AI to edit your content"),
8053
7990
  variant: "default"
8054
- }), g.current.click();
8055
- } catch (b) {
8056
- u(b);
7991
+ }), m.current.click();
7992
+ } catch (y) {
7993
+ u(y);
8057
7994
  } finally {
8058
7995
  d(!1);
8059
7996
  }
@@ -8061,25 +7998,25 @@ const AIUserPrompt = ({ blockId: o }) => {
8061
7998
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
8062
7999
  Accordion,
8063
8000
  {
8064
- onValueChange: (b) => {
8065
- x(b !== "");
8001
+ onValueChange: (y) => {
8002
+ x(y !== "");
8066
8003
  },
8067
8004
  type: "single",
8068
8005
  collapsible: !0,
8069
8006
  children: /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8070
- /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref: g, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8007
+ /* @__PURE__ */ jsxRuntimeExports.jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8071
8008
  /* @__PURE__ */ jsxRuntimeExports.jsxs(AccordionContent, { children: [
8072
8009
  /* @__PURE__ */ jsxRuntimeExports.jsx(
8073
8010
  Textarea,
8074
8011
  {
8075
8012
  ref: l,
8076
8013
  value: n,
8077
- onChange: (b) => a(b.target.value),
8014
+ onChange: (y) => a(y.target.value),
8078
8015
  placeholder: o("Tell about this page eg this page is about"),
8079
8016
  className: "mt-1 w-full",
8080
8017
  rows: 10,
8081
- onKeyDown: (b) => {
8082
- b.key === "Enter" && (b.preventDefault(), j());
8018
+ onKeyDown: (y) => {
8019
+ y.key === "Enter" && (y.preventDefault(), E());
8083
8020
  }
8084
8021
  }
8085
8022
  ),
@@ -8091,7 +8028,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8091
8028
  Button,
8092
8029
  {
8093
8030
  disabled: n.trim().length < 5,
8094
- onClick: () => j(),
8031
+ onClick: () => E(),
8095
8032
  variant: "default",
8096
8033
  className: "w-fit",
8097
8034
  size: "sm",
@@ -8120,7 +8057,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8120
8057
  AlertDialogAction,
8121
8058
  {
8122
8059
  onClick: () => {
8123
- a(""), j();
8060
+ a(""), E();
8124
8061
  },
8125
8062
  children: o("Yes, Delete")
8126
8063
  }
@@ -8141,42 +8078,42 @@ const AIUserPrompt = ({ blockId: o }) => {
8141
8078
  /* @__PURE__ */ jsxRuntimeExports.jsx(AIUserPrompt, { blockId: first(o) })
8142
8079
  ] });
8143
8080
  }, AttrsEditor = React__default.memo(function o({ preloadedAttributes: r = [], onAttributesChange: n }) {
8144
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [h, g] = useState(""), j = useRef(null), b = useRef(null);
8081
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, x] = useState(null), [h, m] = useState(""), E = useRef(null), y = useRef(null);
8145
8082
  useEffect(() => {
8146
8083
  l(r);
8147
8084
  }, [r]);
8148
- const f = () => {
8085
+ const g = () => {
8149
8086
  if (i.startsWith("@")) {
8150
- g("Attribute keys cannot start with '@'");
8087
+ m("Attribute keys cannot start with '@'");
8151
8088
  return;
8152
8089
  }
8153
8090
  if (i) {
8154
- const S = [...a, { key: i, value: d }];
8155
- n(S), l(a), c(""), p(""), g("");
8091
+ const v = [...a, { key: i, value: d }];
8092
+ n(v), l(a), c(""), p(""), m("");
8156
8093
  }
8157
- }, y = (S) => {
8158
- const k = a.filter((T, _) => _ !== S);
8159
- n(k), l(k);
8160
- }, v = (S) => {
8161
- x(S), c(a[S].key), p(a[S].value);
8162
- }, B = () => {
8094
+ }, k = (v) => {
8095
+ const R = a.filter((f, j) => j !== v);
8096
+ n(R), l(R);
8097
+ }, _ = (v) => {
8098
+ x(v), c(a[v].key), p(a[v].value);
8099
+ }, A = () => {
8163
8100
  if (i.startsWith("@")) {
8164
- g("Attribute keys cannot start with '@'");
8101
+ m("Attribute keys cannot start with '@'");
8165
8102
  return;
8166
8103
  }
8167
8104
  if (u !== null && i) {
8168
- const S = [...a];
8169
- S[u] = { key: i, value: d }, n(S), l(S), x(null), c(""), p(""), g("");
8105
+ const v = [...a];
8106
+ v[u] = { key: i, value: d }, n(v), l(v), x(null), c(""), p(""), m("");
8170
8107
  }
8171
- }, A = (S) => {
8172
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? B() : f());
8108
+ }, S = (v) => {
8109
+ v.key === "Enter" && !v.shiftKey && (v.preventDefault(), u !== null ? A() : g());
8173
8110
  };
8174
8111
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
8175
8112
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
8176
8113
  "form",
8177
8114
  {
8178
- onSubmit: (S) => {
8179
- S.preventDefault(), u !== null ? B() : f();
8115
+ onSubmit: (v) => {
8116
+ v.preventDefault(), u !== null ? A() : g();
8180
8117
  },
8181
8118
  className: "space-y-3",
8182
8119
  children: [
@@ -8190,9 +8127,9 @@ const AIUserPrompt = ({ blockId: o }) => {
8190
8127
  autoCorrect: "off",
8191
8128
  spellCheck: "false",
8192
8129
  id: "attrKey",
8193
- ref: j,
8130
+ ref: E,
8194
8131
  value: i,
8195
- onChange: (S) => c(S.target.value),
8132
+ onChange: (v) => c(v.target.value),
8196
8133
  placeholder: "Enter Key",
8197
8134
  className: "py-0 text-xs font-normal leading-tight placeholder:text-slate-400"
8198
8135
  }
@@ -8208,10 +8145,10 @@ const AIUserPrompt = ({ blockId: o }) => {
8208
8145
  spellCheck: "false",
8209
8146
  id: "attrValue",
8210
8147
  rows: 2,
8211
- ref: b,
8148
+ ref: y,
8212
8149
  value: d,
8213
- onChange: (S) => p(S.target.value),
8214
- onKeyDown: A,
8150
+ onChange: (v) => p(v.target.value),
8151
+ onKeyDown: S,
8215
8152
  placeholder: "Enter Value",
8216
8153
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
8217
8154
  }
@@ -8223,16 +8160,16 @@ const AIUserPrompt = ({ blockId: o }) => {
8223
8160
  ]
8224
8161
  }
8225
8162
  ),
8226
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((S, k) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8163
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "space-y-1 py-4", children: a.map((v, R) => /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8227
8164
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
8228
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
8229
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
8165
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: v.key }),
8166
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: v.value.toString() })
8230
8167
  ] }),
8231
8168
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
8232
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => v(k), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
8233
- /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(k), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
8169
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => _(R), children: /* @__PURE__ */ jsxRuntimeExports.jsx(Edit2, { className: "h-3 w-3" }) }),
8170
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => k(R), children: /* @__PURE__ */ jsxRuntimeExports.jsx(X, { className: "h-3 w-3" }) })
8234
8171
  ] })
8235
- ] }, k)) })
8172
+ ] }, R)) })
8236
8173
  ] });
8237
8174
  }), BlockAttributesEditor = React.memo(() => {
8238
8175
  const o = useSelectedBlock(), [r, n] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -8256,6 +8193,20 @@ function getDNDSupport() {
8256
8193
  }
8257
8194
  const FEATURE_TOGGLES = {
8258
8195
  dnd: getDNDSupport()
8196
+ }, builderStore = getDefaultStore$1(), setDebugLogs = (o) => {
8197
+ }, getParentNodeIds = (o, r) => {
8198
+ const n = [];
8199
+ let a = find(o, { _id: r }), l = get(a, "_parent", "");
8200
+ for (; isString(l) && !isEmpty(l); )
8201
+ n.push(a == null ? void 0 : a._parent), a = find(o, { _id: l }), l = a == null ? void 0 : a._parent;
8202
+ return flatten(n);
8203
+ }, expandedIdsAtom = atom$1([]), useExpandTree = () => {
8204
+ const [o] = useSelectedBlockIds(), r = useAtomValue$1(presentBlocksAtom), [, n] = useAtom$1(expandedIdsAtom);
8205
+ useEffect(() => {
8206
+ let a = [];
8207
+ const l = first(o);
8208
+ isString(l) && (a = [l, ...getParentNodeIds(r, l)]), n(a);
8209
+ }, [o, r, n]);
8259
8210
  }, UndoRedo = () => {
8260
8211
  const { hasUndo: o, hasRedo: r, undo: n, redo: a } = useUndoManager();
8261
8212
  return /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center", children: [
@@ -8510,7 +8461,7 @@ const SettingsPanel = () => {
8510
8461
  }
8511
8462
  )
8512
8463
  ] }) });
8513
- }, SettingsPanel$1 = SettingsPanel;
8464
+ };
8514
8465
  function LayoutCard({ disabled: o = !1, description: r, title: n, selected: a, onSelect: l, children: i }) {
8515
8466
  const { t: c } = useTranslation();
8516
8467
  return /* @__PURE__ */ jsxRuntimeExports.jsx(
@@ -8602,13 +8553,13 @@ const ChooseLayout = ({ open: o, close: r }) => {
8602
8553
  )
8603
8554
  ] }) })
8604
8555
  ] }) });
8605
- }, TopBar = lazy(() => import("./Topbar-9IbTAO2f.js")), ThemeConfigPanel = lazy(() => Promise.resolve().then(() => ThemeConfigPanel$3));
8556
+ }, TopBar = lazy(() => import("./Topbar-DMCtQiUj.js")), ThemeConfigPanel = lazy(() => Promise.resolve().then(() => ThemeConfigPanel$2));
8606
8557
  function useSidebarMenuItems() {
8607
8558
  return useMemo(() => compact([
8608
8559
  {
8609
8560
  icon: /* @__PURE__ */ jsxRuntimeExports.jsx(Layers, { size: 20 }),
8610
8561
  label: "Outline",
8611
- component: () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Outline$1, {}) })
8562
+ component: () => /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "-mt-8", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ListTree, {}) })
8612
8563
  }
8613
8564
  ]), []);
8614
8565
  }
@@ -8617,35 +8568,36 @@ const RootLayout = () => {
8617
8568
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
8618
8569
  r(1);
8619
8570
  });
8620
- const c = useBuilderProp("sideBarComponents.top", []), d = (j) => {
8621
- j.preventDefault();
8622
- }, p = (j) => {
8623
- r(o === j ? null : j);
8624
- }, u = useSidebarMenuItems(), { t: x } = useTranslation(), h = [...u, ...c], g = useBuilderProp("htmlDir", "ltr");
8625
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: g, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
8571
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (y) => {
8572
+ y.preventDefault();
8573
+ }, u = (y) => {
8574
+ r(o === y ? null : y);
8575
+ }, x = useSidebarMenuItems(), { t: h } = useTranslation(), m = [...x, ...c], E = useBuilderProp("htmlDir", "ltr");
8576
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dir: E, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxRuntimeExports.jsxs(TooltipProvider, { children: [
8626
8577
  /* @__PURE__ */ jsxRuntimeExports.jsxs(
8627
8578
  "div",
8628
8579
  {
8629
- onContextMenu: d,
8580
+ onContextMenu: p,
8630
8581
  className: "flex h-screen max-h-full flex-col bg-background text-foreground",
8631
8582
  children: [
8632
8583
  /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(TopBar, {}) }) }),
8633
8584
  /* @__PURE__ */ jsxRuntimeExports.jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
8634
8585
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
8635
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: h.map((j, b) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
8586
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: m.map((y, g) => /* @__PURE__ */ jsxRuntimeExports.jsxs(Tooltip, { children: [
8636
8587
  /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxRuntimeExports.jsx(
8637
8588
  Button,
8638
8589
  {
8639
- variant: o === b ? "default" : "ghost",
8590
+ variant: o === g ? "default" : "ghost",
8640
8591
  className: "mb-2 rounded-lg p-2 transition-colors",
8641
- onClick: () => p(b),
8642
- children: get(j, "icon", null)
8592
+ onClick: () => u(g),
8593
+ children: get(y, "icon", null)
8643
8594
  },
8644
- b
8595
+ g
8645
8596
  ) }),
8646
- /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: x(j.label) }) })
8647
- ] }, "button" + b)) }),
8648
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1" })
8597
+ /* @__PURE__ */ jsxRuntimeExports.jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsxRuntimeExports.jsx("p", { children: h(y.label) }) })
8598
+ ] }, "button" + g)) }),
8599
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col space-y-1" }),
8600
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((y, g) => /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", {}), children: React__default.createElement(y, { key: g }) })) })
8649
8601
  ] }),
8650
8602
  /* @__PURE__ */ jsxRuntimeExports.jsx(
8651
8603
  motion.div,
@@ -8656,16 +8608,16 @@ const RootLayout = () => {
8656
8608
  transition: { duration: 0.3, ease: "easeInOut" },
8657
8609
  children: o !== null && /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "no-scrollbar overflow h-full overflow-x-hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex flex-col p-3", children: [
8658
8610
  /* @__PURE__ */ jsxRuntimeExports.jsxs("h2", { className: "-mt-1 flex h-10 items-center space-x-1 text-base font-bold", children: [
8659
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(h, `${o}.icon`, null) }),
8660
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: x(h[o].label) })
8611
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
8612
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: h(m[o].label) })
8661
8613
  ] }),
8662
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(h, `${o}.component`, null), {}) }) })
8614
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex-1", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
8663
8615
  ] }) })
8664
8616
  }
8665
8617
  ),
8666
8618
  /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex h-full max-h-full flex-1 flex-col bg-slate-800/20", children: [
8667
8619
  /* @__PURE__ */ jsxRuntimeExports.jsx(CanvasTopBar, {}),
8668
- /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CanvasArea$1, {}) })
8620
+ /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(CanvasArea, {}) })
8669
8621
  ] }),
8670
8622
  /* @__PURE__ */ jsxRuntimeExports.jsx(
8671
8623
  motion.div,
@@ -8678,11 +8630,11 @@ const RootLayout = () => {
8678
8630
  /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment, { children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex items-center gap-2", children: [
8679
8631
  /* @__PURE__ */ jsxRuntimeExports.jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
8680
8632
  " ",
8681
- x("AI Assistant")
8633
+ h("AI Assistant")
8682
8634
  ] }) }) : l === "theme" ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
8683
8635
  /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { className: "flex items-center gap-2", children: [
8684
8636
  /* @__PURE__ */ jsxRuntimeExports.jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
8685
- x("Theme Settings")
8637
+ h("Theme Settings")
8686
8638
  ] }),
8687
8639
  /* @__PURE__ */ jsxRuntimeExports.jsx(
8688
8640
  Button,
@@ -8695,7 +8647,7 @@ const RootLayout = () => {
8695
8647
  }
8696
8648
  )
8697
8649
  ] }) : null }) }) }),
8698
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex max-h-full w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: l === "ai" ? /* @__PURE__ */ jsxRuntimeExports.jsx(AskAI, {}) : l === "theme" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(SettingsPanel$1, {}) }) })
8650
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "flex max-h-full w-full", children: /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: "Loading..." }), children: l === "ai" ? /* @__PURE__ */ jsxRuntimeExports.jsx(AskAI, {}) : l === "theme" ? /* @__PURE__ */ jsxRuntimeExports.jsx(ThemeConfigPanel, {}) : /* @__PURE__ */ jsxRuntimeExports.jsx(SettingsPanel, {}) }) })
8699
8651
  ] }) })
8700
8652
  }
8701
8653
  )
@@ -8706,7 +8658,16 @@ const RootLayout = () => {
8706
8658
  /* @__PURE__ */ jsxRuntimeExports.jsx(AddBlocksDialog, {}),
8707
8659
  /* @__PURE__ */ jsxRuntimeExports.jsx(ChooseLayout, { open: n, close: () => a(!1) })
8708
8660
  ] }) });
8709
- }, builderStore = getDefaultStore$1(), SmallScreenMessage = () => /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: "h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mx-auto max-w-md text-center", children: [
8661
+ }, PreviewScreen = () => {
8662
+ const [o, r] = usePreviewMode(), { t: n } = useTranslation(), a = useBuilderProp("previewComponent", null);
8663
+ return o ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
8664
+ /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => r(!1), children: [
8665
+ /* @__PURE__ */ jsxRuntimeExports.jsx(EyeClosedIcon, {}),
8666
+ /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: n("Close Preview") })
8667
+ ] }),
8668
+ /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: a ? /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-96 w-full" }), children: React__default.createElement(a) }) : null })
8669
+ ] }) : null;
8670
+ }, SmallScreenMessage = () => /* @__PURE__ */ jsxRuntimeExports.jsx("section", { className: "h-screen w-screen bg-gray-900 py-12 sm:py-16 lg:py-20 xl:hidden", children: /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "mx-auto max-w-7xl px-4 sm:px-6 lg:px-8", children: /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "mx-auto max-w-md text-center", children: [
8710
8671
  /* @__PURE__ */ jsxRuntimeExports.jsx(
8711
8672
  "img",
8712
8673
  {
@@ -8718,58 +8679,39 @@ const RootLayout = () => {
8718
8679
  /* @__PURE__ */ jsxRuntimeExports.jsx("br", {}),
8719
8680
  /* @__PURE__ */ jsxRuntimeExports.jsx("h2", { className: "text-4xl font-bold text-white", children: "Screen too small" }),
8720
8681
  /* @__PURE__ */ jsxRuntimeExports.jsx("p", { className: "mt-6 text-sm font-medium leading-6 text-white text-opacity-70", children: "Please view this page on greater than 1280px screen width." })
8721
- ] }) }) }), setDebugLogs = (o) => {
8722
- }, PreviewScreen = () => {
8723
- const [o, r] = usePreviewMode(), { t: n } = useTranslation(), a = useBuilderProp("previewComponent", null);
8724
- return o ? /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: cn("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
8725
- /* @__PURE__ */ jsxRuntimeExports.jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => r(!1), children: [
8726
- /* @__PURE__ */ jsxRuntimeExports.jsx(EyeClosedIcon, {}),
8727
- /* @__PURE__ */ jsxRuntimeExports.jsx("span", { children: n("Close Preview") })
8728
- ] }),
8729
- /* @__PURE__ */ jsxRuntimeExports.jsx("div", { children: a ? /* @__PURE__ */ jsxRuntimeExports.jsx(Suspense, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(Skeleton, { className: "h-96 w-full" }), children: React__default.createElement(a) }) : null })
8730
- ] }) : null;
8731
- }, getParentNodeIds = (o, r) => {
8732
- const n = [];
8733
- let a = find(o, { _id: r }), l = get(a, "_parent", "");
8734
- for (; isString(l) && !isEmpty(l); )
8735
- n.push(a == null ? void 0 : a._parent), a = find(o, { _id: l }), l = a == null ? void 0 : a._parent;
8736
- return flatten(n);
8737
- }, expandedIdsAtom = atom$1([]), useExpandTree = () => {
8738
- const [o] = useSelectedBlockIds(), r = useAtomValue$1(presentBlocksAtom), [, n] = useAtom$1(expandedIdsAtom);
8739
- useEffect(() => {
8740
- let a = [];
8741
- const l = first(o);
8742
- isString(l) && (a = [l, ...getParentNodeIds(r, l)]), n(a);
8743
- }, [o, r, n]);
8744
- }, useAutoSave = () => {
8682
+ ] }) }) }), useAutoSave = () => {
8745
8683
  const { savePage: o } = useSavePage(), r = useBuilderProp("autoSaveSupport", !0), n = useBuilderProp("autoSaveInterval", 60);
8746
8684
  useIntervalEffect(() => {
8747
8685
  r && o(!0);
8748
8686
  }, n * 1e3);
8749
8687
  }, ChaiBuilderComponent = (o) => {
8750
8688
  const [, r] = useBlocksStore(), n = useBuilderReset(), [a] = useAtom(builderSaveStateAtom), l = useMemo(() => o.layout || RootLayout, [o.layout]);
8751
- return useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchGlobalBlocks(), useEffect(() => {
8689
+ useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchGlobalBlocks(), useUnmountBroadcastChannel();
8690
+ const { postMessage: i } = useBroadcastChannel();
8691
+ return useEffect(() => {
8752
8692
  builderStore.set(
8753
8693
  // @ts-ignore
8754
8694
  chaiBuilderPropsAtom,
8755
8695
  omit(o, ["blocks", "subPages", "brandingOptions", "dataProviders", "customRootLayout", "translations"])
8756
8696
  );
8757
8697
  }, [o]), useEffect(() => {
8758
- r(o.blocks || []), n();
8698
+ setTimeout(() => {
8699
+ r(o.blocks || []), i({ type: "blocks-updated", blocks: o.blocks || [] }), n();
8700
+ }, 400);
8759
8701
  }, [o.blocks]), useEffect(() => {
8760
8702
  i18n.changeLanguage(o.locale || "en");
8761
8703
  }, [o.locale]), useEffect(() => {
8762
8704
  setDebugLogs(o.showDebugLogs);
8763
8705
  }, [o.showDebugLogs]), useEffect(() => {
8764
- o.translations && each(o.translations, (i, c) => {
8765
- i18n.addResourceBundle(c, "translation", i, !0, !0);
8706
+ o.translations && each(o.translations, (c, d) => {
8707
+ i18n.addResourceBundle(d, "translation", c, !0, !0);
8766
8708
  });
8767
8709
  }, [o.translations]), useEffect(() => (a !== "SAVED" ? window.onbeforeunload = () => "" : window.onbeforeunload = null, () => {
8768
8710
  window.onbeforeunload = null;
8769
8711
  }), [a]), /* @__PURE__ */ jsxRuntimeExports.jsx(l, {});
8770
8712
  }, ChaiBuilderEditor = (o) => {
8771
8713
  const r = o._flags || {}, n = o.onError || noop;
8772
- return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "h-screen w-screen", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(FlagsProvider, { features: { ...FEATURE_TOGGLES, ...r }, children: [
8714
+ return /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "w-screen h-screen", children: /* @__PURE__ */ jsxRuntimeExports.jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsxRuntimeExports.jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsxRuntimeExports.jsxs(FlagsProvider, { features: { ...FEATURE_TOGGLES, ...r }, children: [
8773
8715
  /* @__PURE__ */ jsxRuntimeExports.jsx(SmallScreenMessage, {}),
8774
8716
  /* @__PURE__ */ jsxRuntimeExports.jsx(ChaiBuilderComponent, { ...o }),
8775
8717
  /* @__PURE__ */ jsxRuntimeExports.jsx(PreviewScreen, {}),
@@ -8780,27 +8722,27 @@ export {
8780
8722
  AISetContext,
8781
8723
  AIUserPrompt,
8782
8724
  AddBlocksDialog,
8783
- AddBlocksPanel$1 as AddBlocksPanel,
8725
+ AddBlocksPanel,
8784
8726
  BlockAttributesEditor,
8785
8727
  BlockSettings as BlockPropsEditor,
8786
8728
  BlockStyling as BlockStyleEditor,
8787
8729
  CHAI_BUILDER_EVENTS,
8788
- CanvasArea$1 as ChaiBuilderCanvas,
8730
+ CanvasArea as ChaiBuilderCanvas,
8789
8731
  ChaiBuilderEditor,
8790
8732
  DarkMode as DarkModeSwitcher,
8791
8733
  DefaultChaiBlocks,
8792
- ImportHTML$1 as ImportHTML,
8793
- Outline$1 as Outline,
8734
+ ImportHTML,
8735
+ ListTree as Outline,
8794
8736
  Breakpoints as ScreenSizes,
8795
- ThemeConfigPanel$2 as ThemeOptions,
8796
- UILibraries,
8737
+ ThemeConfigPanel$1 as ThemeOptions,
8738
+ UILibrariesPanel as UILibraries,
8797
8739
  UndoRedo,
8798
8740
  generateUUID as generateBlockId,
8799
8741
  getBlocksFromHTML,
8800
8742
  getClassValueAndUnit,
8801
- Qe as i18n,
8743
+ Me as i18n,
8802
8744
  cn as mergeClasses,
8803
- Ze as registerChaiBlock,
8745
+ De as registerChaiBlock,
8804
8746
  useAddBlock,
8805
8747
  useAddClassesToBlocks,
8806
8748
  useAskAi,
@@ -8842,7 +8784,7 @@ export {
8842
8784
  useStylingState,
8843
8785
  useTheme,
8844
8786
  useThemeOptions,
8845
- Xe as useTranslation,
8787
+ Ie as useTranslation,
8846
8788
  useUILibraryBlocks,
8847
8789
  useUndoManager,
8848
8790
  useUpdateBlocksProps,