@chaibuilder/sdk 2.0.0-beta.104 → 2.0.0-beta.106

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.js CHANGED
@@ -1,47 +1,52 @@
1
1
  var G = Object.defineProperty;
2
2
  var K = (o, n, r) => n in o ? G(o, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : o[n] = r;
3
- var U = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
3
+ var V = (o, n, r) => K(o, typeof n != "symbol" ? n + "" : n, r);
4
4
  import { jsx, Fragment, jsxs } from "react/jsx-runtime";
5
5
  import * as React from "react";
6
6
  import React__default, { createContext, useReducer, useEffect, useDebugValue, useCallback, useContext, useMemo, Component, Children, useState, useRef, Suspense, createElement, memo, lazy } from "react";
7
- import { ag as useToast, S as Skeleton, B as Button, L as Label, D as Dialog, r as DialogTrigger, s as DialogContent, V as Popover, O as Tooltip, P as TooltipTrigger, W as PopoverTrigger, Q as TooltipContent, X as PopoverContent, aj as Command, al as CommandInput, am as CommandList, an as CommandEmpty, ao as CommandGroup, ap as CommandItem, g as Badge, $ as DropdownMenu, a0 as DropdownMenuTrigger, a1 as DropdownMenuContent, a5 as DropdownMenuLabel, a6 as DropdownMenuSeparator, a3 as DropdownMenuCheckboxItem, Y as HoverCard, Z as HoverCardTrigger, _ as HoverCardContent, T as Textarea, I as Input$1, U as TooltipPortal, d as AccordionItem, e as AccordionTrigger, f as AccordionContent, G as ScrollArea, a8 as DropdownMenuGroup, a2 as DropdownMenuItem, a7 as DropdownMenuShortcut, A as Accordion, C as Card, x as CardHeader, E as CardDescription, F as CardContent, y as CardFooter, J as Tabs, K as TabsList, M as TabsTrigger, N as TabsContent, as as ContextMenu, at as ContextMenuTrigger, au as ContextMenuContent, av as ContextMenuItem, i as AlertDialog, j as AlertDialogTrigger, k as AlertDialogContent, l as AlertDialogHeader, n as AlertDialogTitle, o as AlertDialogDescription, m as AlertDialogFooter, q as AlertDialogCancel, p as AlertDialogAction, a as Switch, ae as Separator, R as TooltipProvider, ai as Toaster } from "./context-menu-iqXuo9Yt.js";
7
+ import { S as Skeleton, B as Button, al as Label, X as Dialog, Y as DialogTrigger, Z as DialogContent, am as Popover, az as Tooltip, aA as TooltipTrigger, an as PopoverTrigger, aB as TooltipContent, ao as PopoverContent, v as Command, x as CommandInput, y as CommandList, z as CommandEmpty, D as CommandGroup, E as CommandItem, _ as DialogHeader, a0 as DialogTitle, n as Badge, a2 as DropdownMenu, a3 as DropdownMenuTrigger, a4 as DropdownMenuContent, a8 as DropdownMenuLabel, a9 as DropdownMenuSeparator, a6 as DropdownMenuCheckboxItem, ah as HoverCard, ai as HoverCardTrigger, aj as HoverCardContent, ay as Textarea, ak as Input$1, aD as TooltipPortal, a as AccordionItem, b as AccordionTrigger, d as AccordionContent, ap as ScrollArea, ab as DropdownMenuGroup, a5 as DropdownMenuItem, aa as DropdownMenuShortcut, A as Accordion, C as Card, q as CardHeader, t as CardDescription, u as CardContent, r as CardFooter, au as Tabs, av as TabsList, aw as TabsTrigger, ax as TabsContent, H as ContextMenu, I as ContextMenuTrigger, J as ContextMenuContent, K as ContextMenuItem, e as AlertDialog, f as AlertDialogTrigger, g as AlertDialogContent, h as AlertDialogHeader, j as AlertDialogTitle, k as AlertDialogDescription, i as AlertDialogFooter, m as AlertDialogCancel, l as AlertDialogAction, at as Switch, ar as Separator, aC as TooltipProvider, as as Toaster } from "./tooltip-CuxBhGWF.js";
8
8
  import { atom as atom$1, useAtom as useAtom$1, useAtomValue as useAtomValue$1, getDefaultStore as getDefaultStore$1, useSetAtom as useSetAtom$1, Provider } from "jotai";
9
9
  import { find, filter, flatten, map, omit, isString, has, each, set, first, get, isObject, memoize, compact, isEmpty, noop, includes, without, keys, range, values, flattenDeep, startsWith, forEach, unset, chunk, cloneDeep, pick, isNull, throttle, isFunction as isFunction$1, reverse, startCase, debounce, capitalize, split, findIndex, take, toUpper, toLower, nth, isNumber, parseInt as parseInt$1, isNaN as isNaN$1, findLast, intersection, groupBy, uniq, flatMapDeep, some, reject, sortBy, round } from "lodash-es";
10
10
  import { Provider as Provider$1 } from "react-wrap-balancer";
11
11
  import { useTranslation, initReactI18next } from "react-i18next";
12
- import { useTranslation as De } from "react-i18next";
13
- import { g as generateUUID, a as getBreakpointValue, c as cn, G as GenIcon } from "./iconBase-DHfFLkem.js";
12
+ import { useTranslation as Ve } from "react-i18next";
13
+ import { g as generateUUID, a as getBreakpointValue, c as cn$1, G as GenIcon } from "./iconBase-DHfFLkem.js";
14
14
  import { flip } from "@floating-ui/dom";
15
15
  import { useFloating, shift } from "@floating-ui/react-dom";
16
16
  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, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, 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, CardStackIcon, CardStackPlusIcon, ScissorsIcon, CheckIcon, SunIcon, ResetIcon, EraserIcon, ZoomInIcon, MixerHorizontalIcon, LightningBoltIcon } from "@radix-ui/react-icons";
17
17
  import { useThrottledCallback, useDebouncedCallback, useResizeObserver, useIntervalEffect } from "@react-hookz/web";
18
18
  import { useFeature, FlagsProvider } from "flagged";
19
19
  import { getRegisteredChaiBlock, getDefaultBlockProps, useRegisteredChaiBlocks, getBlockFormSchemas, syncBlocksWithDefaults } from "@chaibuilder/runtime";
20
- import { registerChaiBlock as $e } from "@chaibuilder/runtime";
20
+ import { registerChaiBlock as Fe } from "@chaibuilder/runtime";
21
21
  import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThemeOptions, p as plugin, a as getChaiThemeCssVariables, c as getThemeFontsLinkMarkup } from "./ChaiThemeFn-Cort9tch.js";
22
22
  import TreeModel from "tree-model";
23
23
  import { useHotkeys } from "react-hotkeys-hook";
24
- import { PlusIcon as PlusIcon$1, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, X, Plus, ChevronLeft, PlusCircle, ChevronDown, List, Loader, SparklesIcon, EyeOff, Eye, SmileIcon, ShuffleIcon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
25
- import ReactQuill, { Quill } from "react-quill";
24
+ import { toast } from "sonner";
25
+ import { PlusIcon as PlusIcon$1, Bold, Italic, Strikethrough, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, ChevronLeft, Underline as Underline$1, List, ListOrdered, AlignLeft, AlignCenter, AlignRight, Link as Link$1, Unlink, Maximize2, X, Plus, PlusCircle, ChevronDown, Loader, SparklesIcon, EyeOff, Eye, SmileIcon, ShuffleIcon, DatabaseZapIcon, Edit2, Paintbrush, Layers } from "lucide-react";
26
+ import { BubbleMenu, EditorContent, useEditor } from "@tiptap/react";
27
+ import StarterKit from "@tiptap/starter-kit";
28
+ import clsx$1, { clsx } from "clsx";
29
+ import { twMerge } from "tailwind-merge";
26
30
  import typography from "@tailwindcss/typography";
27
31
  import forms from "@tailwindcss/forms";
28
32
  import aspectRatio from "@tailwindcss/aspect-ratio";
29
33
  import containerQueries from "@tailwindcss/container-queries";
30
- import { twMerge } from "tailwind-merge";
31
34
  import { S as STYLES_KEY, g as getSplitChaiClasses, R as ROOT_TEMP_KEY } from "./getSplitClasses-DphwgQiE.js";
32
35
  import ReactDOM from "react-dom";
33
36
  import { ErrorBoundary } from "react-error-boundary";
34
37
  import { Resizable } from "re-resizable";
35
38
  import RjForm from "@rjsf/core";
36
39
  import validator from "@rjsf/validator-ajv8";
40
+ import Link from "@tiptap/extension-link";
41
+ import TextAlign from "@tiptap/extension-text-align";
42
+ import Underline from "@tiptap/extension-underline";
37
43
  import IconPicker, { IconPickerItem } from "react-icons-picker";
38
44
  import Autosuggest from "react-autosuggest";
39
45
  import Fuse from "fuse.js";
40
46
  import { parse, stringify } from "himalaya";
41
- import clsx from "clsx";
42
47
  import { Tree } from "react-arborist";
43
48
  import i18n from "i18next";
44
- import { default as He } from "i18next";
49
+ import { default as We } from "i18next";
45
50
  import { motion } from "framer-motion";
46
51
  const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInitialValue = (o) => "init" in o, isActuallyWritableAtom = (o) => !!o.write, isAtomStateInitialized = (o) => "v" in o || "e" in o, returnAtomValue = (o) => {
47
52
  if ("e" in o)
@@ -89,37 +94,37 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
89
94
  for (const i of n.p)
90
95
  l.add(i);
91
96
  return l;
92
- }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (f, ...b) => f.read(...b), p = (f, ...b) => f.write(...b), u = (f, b) => {
93
- var x;
94
- return (x = f.unstable_onInit) == null ? void 0 : x.call(f, b);
95
- }, g = (f, b) => {
96
- var x;
97
- return (x = f.onMount) == null ? void 0 : x.call(f, b);
97
+ }, BUILDING_BLOCKS = Symbol(), buildStore = (o = /* @__PURE__ */ new WeakMap(), n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), l = /* @__PURE__ */ new Set(), i = /* @__PURE__ */ new Set(), c = {}, d = (f, ...h) => f.read(...h), p = (f, ...h) => f.write(...h), u = (f, h) => {
98
+ var b;
99
+ return (b = f.unstable_onInit) == null ? void 0 : b.call(f, h);
100
+ }, g = (f, h) => {
101
+ var b;
102
+ return (b = f.onMount) == null ? void 0 : b.call(f, h);
98
103
  }, ...m) => {
99
- const f = m[0] || ((C) => {
100
- let T = o.get(C);
101
- return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(C, T), u == null || u(C, _)), T;
102
- }), b = m[1] || (() => {
103
- let C, T;
104
+ const f = m[0] || ((w) => {
105
+ let T = o.get(w);
106
+ return T || (T = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, T), u == null || u(w, _)), T;
107
+ }), h = m[1] || (() => {
108
+ let w, T;
104
109
  const k = (v) => {
105
110
  try {
106
111
  v();
107
112
  } catch (N) {
108
- C || (C = !0, T = N);
113
+ w || (w = !0, T = N);
109
114
  }
110
115
  };
111
116
  do {
112
117
  c.f && k(c.f);
113
118
  const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
114
119
  a.forEach((I) => {
115
- var M;
116
- return (M = n.get(I)) == null ? void 0 : M.l.forEach(N);
117
- }), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && x();
120
+ var L;
121
+ return (L = n.get(I)) == null ? void 0 : L.l.forEach(N);
122
+ }), a.clear(), i.forEach(N), i.clear(), l.forEach(N), l.clear(), v.forEach(k), a.size && b();
118
123
  } while (a.size || i.size || l.size);
119
- if (C)
124
+ if (w)
120
125
  throw T;
121
- }), x = m[2] || (() => {
122
- const C = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
126
+ }), b = m[2] || (() => {
127
+ const w = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
123
128
  for (; v.length; ) {
124
129
  const N = v[v.length - 1], I = f(N);
125
130
  if (k.has(N)) {
@@ -127,85 +132,85 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
127
132
  continue;
128
133
  }
129
134
  if (T.has(N)) {
130
- r.get(N) === I.n && C.push([N, I]), k.add(N), v.pop();
135
+ r.get(N) === I.n && w.push([N, I]), k.add(N), v.pop();
131
136
  continue;
132
137
  }
133
138
  T.add(N);
134
- for (const M of getMountedOrPendingDependents(N, I, n))
135
- T.has(M) || v.push(M);
139
+ for (const L of getMountedOrPendingDependents(N, I, n))
140
+ T.has(L) || v.push(L);
136
141
  }
137
- for (let N = C.length - 1; N >= 0; --N) {
138
- const [I, M] = C[N];
142
+ for (let N = w.length - 1; N >= 0; --N) {
143
+ const [I, L] = w[N];
139
144
  let P = !1;
140
- for (const j of M.d.keys())
141
- if (j !== I && a.has(j)) {
145
+ for (const E of L.d.keys())
146
+ if (E !== I && a.has(E)) {
142
147
  P = !0;
143
148
  break;
144
149
  }
145
- P && (h(I), E(I)), r.delete(I);
150
+ P && (x(I), j(I)), r.delete(I);
146
151
  }
147
- }), h = m[3] || ((C) => {
152
+ }), x = m[3] || ((w) => {
148
153
  var T, k;
149
- const v = f(C);
150
- if (isAtomStateInitialized(v) && (n.has(C) && r.get(C) !== v.n || Array.from(v.d).every(
151
- ([L, $]) => (
154
+ const v = f(w);
155
+ if (isAtomStateInitialized(v) && (n.has(w) && r.get(w) !== v.n || Array.from(v.d).every(
156
+ ([R, O]) => (
152
157
  // Recursively, read the atom state of the dependency, and
153
158
  // check if the atom epoch number is unchanged
154
- h(L).n === $
159
+ x(R).n === O
155
160
  )
156
161
  )))
157
162
  return v;
158
163
  v.d.clear();
159
164
  let N = !0;
160
165
  const I = () => {
161
- n.has(C) && (E(C), x(), b());
162
- }, M = (L) => {
163
- var $;
164
- if (isSelfAtom(C, L)) {
165
- const H = f(L);
166
+ n.has(w) && (j(w), b(), h());
167
+ }, L = (R) => {
168
+ var O;
169
+ if (isSelfAtom(w, R)) {
170
+ const H = f(R);
166
171
  if (!isAtomStateInitialized(H))
167
- if (hasInitialValue(L))
168
- setAtomStateValueOrPromise(L, L.init, f);
172
+ if (hasInitialValue(R))
173
+ setAtomStateValueOrPromise(R, R.init, f);
169
174
  else
170
175
  throw new Error("no atom init");
171
176
  return returnAtomValue(H);
172
177
  }
173
- const O = h(L);
178
+ const $ = x(R);
174
179
  try {
175
- return returnAtomValue(O);
180
+ return returnAtomValue($);
176
181
  } finally {
177
- v.d.set(L, O.n), isPendingPromise(v.v) && addPendingPromiseToDependency(C, v.v, O), ($ = n.get(L)) == null || $.t.add(C), N || I();
182
+ v.d.set(R, $.n), isPendingPromise(v.v) && addPendingPromiseToDependency(w, v.v, $), (O = n.get(R)) == null || O.t.add(w), N || I();
178
183
  }
179
184
  };
180
- let P, j;
181
- const R = {
185
+ let P, E;
186
+ const D = {
182
187
  get signal() {
183
188
  return P || (P = new AbortController()), P.signal;
184
189
  },
185
190
  get setSelf() {
186
- return !j && isActuallyWritableAtom(C) && (j = (...L) => {
191
+ return !E && isActuallyWritableAtom(w) && (E = (...R) => {
187
192
  if (!N)
188
193
  try {
189
- return B(C, ...L);
194
+ return A(w, ...R);
190
195
  } finally {
191
- x(), b();
196
+ b(), h();
192
197
  }
193
- }), j;
198
+ }), E;
194
199
  }
195
- }, D = v.n;
200
+ }, M = v.n;
196
201
  try {
197
- const L = d(C, M, R);
198
- return setAtomStateValueOrPromise(C, L, f), isPromiseLike$2(L) && ((T = L.onCancel) == null || T.call(L, () => P == null ? void 0 : P.abort()), L.then(
202
+ const R = d(w, L, D);
203
+ return setAtomStateValueOrPromise(w, R, f), isPromiseLike$2(R) && ((T = R.onCancel) == null || T.call(R, () => P == null ? void 0 : P.abort()), R.then(
199
204
  I,
200
205
  I
201
206
  )), v;
202
- } catch (L) {
203
- return delete v.v, v.e = L, ++v.n, v;
207
+ } catch (R) {
208
+ return delete v.v, v.e = R, ++v.n, v;
204
209
  } finally {
205
- N = !1, D !== v.n && r.get(C) === D && (r.set(C, v.n), a.add(C), (k = c.c) == null || k.call(c, C));
210
+ N = !1, M !== v.n && r.get(w) === M && (r.set(w, v.n), a.add(w), (k = c.c) == null || k.call(c, w));
206
211
  }
207
- }), y = m[4] || ((C) => {
208
- const T = [C];
212
+ }), y = m[4] || ((w) => {
213
+ const T = [w];
209
214
  for (; T.length; ) {
210
215
  const k = T.pop(), v = f(k);
211
216
  for (const N of getMountedOrPendingDependents(k, v, n)) {
@@ -213,69 +218,69 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
213
218
  r.set(N, I.n), T.push(N);
214
219
  }
215
220
  }
216
- }), B = m[5] || ((C, ...T) => {
221
+ }), A = m[5] || ((w, ...T) => {
217
222
  let k = !0;
218
- const v = (I) => returnAtomValue(h(I)), N = (I, ...M) => {
223
+ const v = (I) => returnAtomValue(x(I)), N = (I, ...L) => {
219
224
  var P;
220
- const j = f(I);
225
+ const E = f(I);
221
226
  try {
222
- if (isSelfAtom(C, I)) {
227
+ if (isSelfAtom(w, I)) {
223
228
  if (!hasInitialValue(I))
224
229
  throw new Error("atom not writable");
225
- const R = j.n, D = M[0];
226
- setAtomStateValueOrPromise(I, D, f), E(I), R !== j.n && (a.add(I), (P = c.c) == null || P.call(c, I), y(I));
230
+ const D = E.n, M = L[0];
231
+ setAtomStateValueOrPromise(I, M, f), j(I), D !== E.n && (a.add(I), (P = c.c) == null || P.call(c, I), y(I));
227
232
  return;
228
233
  } else
229
- return B(I, ...M);
234
+ return A(I, ...L);
230
235
  } finally {
231
- k || (x(), b());
236
+ k || (b(), h());
232
237
  }
233
238
  };
234
239
  try {
235
- return p(C, v, N, ...T);
240
+ return p(w, v, N, ...T);
236
241
  } finally {
237
242
  k = !1;
238
243
  }
239
- }), E = m[6] || ((C) => {
244
+ }), j = m[6] || ((w) => {
240
245
  var T;
241
- const k = f(C), v = n.get(C);
246
+ const k = f(w), v = n.get(w);
242
247
  if (v && !isPendingPromise(k.v)) {
243
248
  for (const [N, I] of k.d)
244
249
  if (!v.d.has(N)) {
245
- const M = f(N);
246
- w(N).t.add(C), v.d.add(N), I !== M.n && (a.add(N), (T = c.c) == null || T.call(c, N), y(N));
250
+ const L = f(N);
251
+ C(N).t.add(w), v.d.add(N), I !== L.n && (a.add(N), (T = c.c) == null || T.call(c, N), y(N));
247
252
  }
248
253
  for (const N of v.d || [])
249
254
  if (!k.d.has(N)) {
250
255
  v.d.delete(N);
251
256
  const I = S(N);
252
- I == null || I.t.delete(C);
257
+ I == null || I.t.delete(w);
253
258
  }
254
259
  }
255
- }), w = m[7] || ((C) => {
260
+ }), C = m[7] || ((w) => {
256
261
  var T;
257
- const k = f(C);
258
- let v = n.get(C);
262
+ const k = f(w);
263
+ let v = n.get(w);
259
264
  if (!v) {
260
- h(C);
265
+ x(w);
261
266
  for (const N of k.d.keys())
262
- w(N).t.add(C);
267
+ C(N).t.add(w);
263
268
  if (v = {
264
269
  l: /* @__PURE__ */ new Set(),
265
270
  d: new Set(k.d.keys()),
266
271
  t: /* @__PURE__ */ new Set()
267
- }, n.set(C, v), (T = c.m) == null || T.call(c, C), isActuallyWritableAtom(C)) {
272
+ }, n.set(w, v), (T = c.m) == null || T.call(c, w), isActuallyWritableAtom(w)) {
268
273
  const N = () => {
269
274
  let I = !0;
270
- const M = (...P) => {
275
+ const L = (...P) => {
271
276
  try {
272
- return B(C, ...P);
277
+ return A(w, ...P);
273
278
  } finally {
274
- I || (x(), b());
279
+ I || (b(), h());
275
280
  }
276
281
  };
277
282
  try {
278
- const P = g(C, M);
283
+ const P = g(w, L);
279
284
  P && (v.u = () => {
280
285
  I = !0;
281
286
  try {
@@ -292,23 +297,23 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
292
297
  }
293
298
  }
294
299
  return v;
295
- }), S = m[8] || ((C) => {
300
+ }), S = m[8] || ((w) => {
296
301
  var T;
297
- const k = f(C);
298
- let v = n.get(C);
302
+ const k = f(w);
303
+ let v = n.get(w);
299
304
  if (v && !v.l.size && !Array.from(v.t).some((N) => {
300
305
  var I;
301
- return (I = n.get(N)) == null ? void 0 : I.d.has(C);
306
+ return (I = n.get(N)) == null ? void 0 : I.d.has(w);
302
307
  })) {
303
- v.u && i.add(v.u), v = void 0, n.delete(C), (T = c.u) == null || T.call(c, C);
308
+ v.u && i.add(v.u), v = void 0, n.delete(w), (T = c.u) == null || T.call(c, w);
304
309
  for (const N of k.d.keys()) {
305
310
  const I = S(N);
306
- I == null || I.t.delete(C);
311
+ I == null || I.t.delete(w);
307
312
  }
308
313
  return;
309
314
  }
310
315
  return v;
311
- }), A = [
316
+ }), B = [
312
317
  // store state
313
318
  o,
314
319
  n,
@@ -324,31 +329,31 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
324
329
  g,
325
330
  // building-block functions
326
331
  f,
332
+ h,
327
333
  b,
328
334
  x,
329
- h,
330
335
  y,
331
- B,
332
- E,
333
- w,
336
+ A,
337
+ j,
338
+ C,
334
339
  S
335
340
  ], _ = {
336
- get: (C) => returnAtomValue(h(C)),
337
- set: (C, ...T) => {
341
+ get: (w) => returnAtomValue(x(w)),
342
+ set: (w, ...T) => {
338
343
  try {
339
- return B(C, ...T);
344
+ return A(w, ...T);
340
345
  } finally {
341
- x(), b();
346
+ b(), h();
342
347
  }
343
348
  },
344
- sub: (C, T) => {
345
- const v = w(C).l;
346
- return v.add(T), b(), () => {
347
- v.delete(T), S(C), b();
349
+ sub: (w, T) => {
350
+ const v = C(w).l;
351
+ return v.add(T), h(), () => {
352
+ v.delete(T), S(w), h();
348
353
  };
349
354
  }
350
355
  };
351
- return Object.defineProperty(_, BUILDING_BLOCKS, { value: A }), _;
356
+ return Object.defineProperty(_, BUILDING_BLOCKS, { value: B }), _;
352
357
  }, INTERNAL_buildStoreRev1 = buildStore;
353
358
  let keyCount = 0;
354
359
  function atom(o, n) {
@@ -384,36 +389,36 @@ function splitAtom(o, n) {
384
389
  if (p)
385
390
  return p;
386
391
  const u = d && r.get(d), g = [], m = [];
387
- return c.forEach((f, b) => {
388
- const x = b;
389
- m[b] = x;
390
- const h = u && u.atomList[u.keyList.indexOf(x)];
391
- if (h) {
392
- g[b] = h;
392
+ return c.forEach((f, h) => {
393
+ const b = h;
394
+ m[h] = b;
395
+ const x = u && u.atomList[u.keyList.indexOf(b)];
396
+ if (x) {
397
+ g[h] = x;
393
398
  return;
394
399
  }
395
- const y = (E) => {
396
- const w = E(l), S = E(o), _ = a(S, w == null ? void 0 : w.arr).keyList.indexOf(x);
400
+ const y = (j) => {
401
+ const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(b);
397
402
  if (_ < 0 || _ >= S.length) {
398
- const C = c[a(c).keyList.indexOf(x)];
399
- if (C)
400
- return C;
403
+ const w = c[a(c).keyList.indexOf(b)];
404
+ if (w)
405
+ return w;
401
406
  throw new Error("splitAtom: index out of bounds for read");
402
407
  }
403
408
  return S[_];
404
- }, B = (E, w, S) => {
405
- const A = E(l), _ = E(o), T = a(_, A == null ? void 0 : A.arr).keyList.indexOf(x);
409
+ }, A = (j, C, S) => {
410
+ const B = j(l), _ = j(o), T = a(_, B == null ? void 0 : B.arr).keyList.indexOf(b);
406
411
  if (T < 0 || T >= _.length)
407
412
  throw new Error("splitAtom: index out of bounds for write");
408
413
  const k = isFunction(S) ? S(_[T]) : S;
409
- Object.is(_[T], k) || w(o, [
414
+ Object.is(_[T], k) || C(o, [
410
415
  ..._.slice(0, T),
411
416
  k,
412
417
  ..._.slice(T + 1)
413
418
  ]);
414
419
  };
415
- g[b] = isWritable(o) ? atom(y, B) : atom(y);
416
- }), u && u.keyList.length === m.length && u.keyList.every((f, b) => f === m[b]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
420
+ g[h] = isWritable(o) ? atom(y, A) : atom(y);
421
+ }), u && u.keyList.length === m.length && u.keyList.every((f, h) => f === m[h]) ? p = u : p = { arr: c, atomList: g, keyList: m }, r.set(c, p), p;
417
422
  }, l = atom((c) => {
418
423
  const d = c(l), p = c(o);
419
424
  return a(p, d == null ? void 0 : d.arr);
@@ -486,18 +491,18 @@ function createJSONStorage(o = () => {
486
491
  const i = {
487
492
  getItem: (p, u) => {
488
493
  var g, m;
489
- const f = (x) => {
490
- if (x = x || "", a !== x) {
494
+ const f = (b) => {
495
+ if (b = b || "", a !== b) {
491
496
  try {
492
- l = JSON.parse(x, n == null ? void 0 : n.reviver);
497
+ l = JSON.parse(b, n == null ? void 0 : n.reviver);
493
498
  } catch {
494
499
  return u;
495
500
  }
496
- a = x;
501
+ a = b;
497
502
  }
498
503
  return l;
499
- }, b = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
500
- return isPromiseLike$1(b) ? b.then(f) : f(b);
504
+ }, h = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
+ return isPromiseLike$1(h) ? h.then(f) : f(h);
501
506
  },
502
507
  setItem: (p, u) => {
503
508
  var g;
@@ -511,13 +516,13 @@ function createJSONStorage(o = () => {
511
516
  return (u = o()) == null ? void 0 : u.removeItem(p);
512
517
  }
513
518
  }, c = (p) => (u, g, m) => p(u, (f) => {
514
- let b;
519
+ let h;
515
520
  try {
516
- b = JSON.parse(f || "");
521
+ h = JSON.parse(f || "");
517
522
  } catch {
518
- b = m;
523
+ h = m;
519
524
  }
520
- g(b);
525
+ g(h);
521
526
  });
522
527
  let d;
523
528
  try {
@@ -688,17 +693,17 @@ class Content extends Component {
688
693
  class Frame extends Component {
689
694
  constructor(r, a) {
690
695
  super(r, a);
691
- U(this, "setRef", (r) => {
696
+ V(this, "setRef", (r) => {
692
697
  this.nodeRef.current = r;
693
698
  const { forwardedRef: a } = this.props;
694
699
  typeof a == "function" ? a(r) : a && (a.current = r);
695
700
  });
696
- U(this, "handleLoad", () => {
701
+ V(this, "handleLoad", () => {
697
702
  clearInterval(this.loadCheck), this.state.iframeLoaded || this.setState({ iframeLoaded: !0 });
698
703
  });
699
704
  // In certain situations on a cold cache DOMContentLoaded never gets called
700
705
  // fallback to an interval to check if that's the case
701
- U(this, "loadCheck", () => setInterval(() => {
706
+ V(this, "loadCheck", () => setInterval(() => {
702
707
  this.handleLoad();
703
708
  }, 500));
704
709
  this._isMounted = !1, this.nodeRef = React__default.createRef(), this.state = { iframeLoaded: !1 };
@@ -735,7 +740,7 @@ class Frame extends Component {
735
740
  return delete r.head, delete r.initialContent, delete r.mountTarget, delete r.contentDidMount, delete r.contentDidUpdate, delete r.forwardedRef, /* @__PURE__ */ jsx("iframe", { ...r, ref: this.setRef, onLoad: this.handleLoad, children: this.state.iframeLoaded && this.renderFrameContents() });
736
741
  }
737
742
  }
738
- U(Frame, "defaultProps", {
743
+ V(Frame, "defaultProps", {
739
744
  style: {},
740
745
  head: null,
741
746
  children: void 0,
@@ -1339,65 +1344,65 @@ const useBlocksStoreManager = () => {
1339
1344
  updateBlocksProps: c
1340
1345
  } = useBlocksStoreManager();
1341
1346
  return {
1342
- moveBlocks: (x, h, y) => {
1343
- const B = map(x, (w) => {
1344
- const A = n.find((T) => T._id === w)._parent || null, C = n.filter((T) => A ? T._parent === A : !T._parent).map((T) => T._id).indexOf(w);
1345
- return { _id: w, oldParent: A, oldPosition: C };
1346
- }), E = B.find(({ _id: w }) => w === x[0]);
1347
- E && E.oldParent === h && E.oldPosition === y || (i(x, h, y), o({
1348
- undo: () => each(B, ({ _id: w, oldParent: S, oldPosition: A }) => {
1349
- i([w], S, A);
1347
+ moveBlocks: (b, x, y) => {
1348
+ const A = map(b, (C) => {
1349
+ const B = n.find((T) => T._id === C)._parent || null, w = n.filter((T) => B ? T._parent === B : !T._parent).map((T) => T._id).indexOf(C);
1350
+ return { _id: C, oldParent: B, oldPosition: w };
1351
+ }), j = A.find(({ _id: C }) => C === b[0]);
1352
+ j && j.oldParent === x && j.oldPosition === y || (i(b, x, y), o({
1353
+ undo: () => each(A, ({ _id: C, oldParent: S, oldPosition: B }) => {
1354
+ i([C], S, B);
1350
1355
  }),
1351
- redo: () => i(x, h, y)
1356
+ redo: () => i(b, x, y)
1352
1357
  }));
1353
1358
  },
1354
- addBlocks: (x, h, y) => {
1355
- a(x, h, y), o({
1356
- undo: () => l(map(x, "_id")),
1357
- redo: () => a(x, h, y)
1359
+ addBlocks: (b, x, y) => {
1360
+ a(b, x, y), o({
1361
+ undo: () => l(map(b, "_id")),
1362
+ redo: () => a(b, x, y)
1358
1363
  });
1359
1364
  },
1360
- removeBlocks: (x) => {
1361
- var E;
1362
- const h = (E = first(x)) == null ? void 0 : E._parent, B = n.filter((w) => h ? w._parent === h : !w._parent).indexOf(first(x));
1363
- l(map(x, "_id")), o({
1364
- undo: () => a(x, h, B),
1365
- redo: () => l(map(x, "_id"))
1365
+ removeBlocks: (b) => {
1366
+ var j;
1367
+ const x = (j = first(b)) == null ? void 0 : j._parent, A = n.filter((C) => x ? C._parent === x : !C._parent).indexOf(first(b));
1368
+ l(map(b, "_id")), o({
1369
+ undo: () => a(b, x, A),
1370
+ redo: () => l(map(b, "_id"))
1366
1371
  });
1367
1372
  },
1368
- updateBlocks: (x, h, y) => {
1369
- let B = [];
1373
+ updateBlocks: (b, x, y) => {
1374
+ let A = [];
1370
1375
  if (y)
1371
- B = map(x, (E) => ({ _id: E, ...y }));
1376
+ A = map(b, (j) => ({ _id: j, ...y }));
1372
1377
  else {
1373
- const E = keys(h);
1374
- B = map(x, (w) => {
1375
- const S = n.find((_) => _._id === w), A = { _id: w };
1376
- return each(E, (_) => A[_] = S[_]), A;
1378
+ const j = keys(x);
1379
+ A = map(b, (C) => {
1380
+ const S = n.find((_) => _._id === C), B = { _id: C };
1381
+ return each(j, (_) => B[_] = S[_]), B;
1377
1382
  });
1378
1383
  }
1379
- c(map(x, (E) => ({ _id: E, ...h }))), o({
1380
- undo: () => c(B),
1381
- redo: () => c(map(x, (E) => ({ _id: E, ...h })))
1384
+ c(map(b, (j) => ({ _id: j, ...x }))), o({
1385
+ undo: () => c(A),
1386
+ redo: () => c(map(b, (j) => ({ _id: j, ...x })))
1382
1387
  });
1383
1388
  },
1384
- updateBlocksRuntime: (x, h) => {
1385
- c(map(x, (y) => ({ _id: y, ...h })));
1389
+ updateBlocksRuntime: (b, x) => {
1390
+ c(map(b, (y) => ({ _id: y, ...x })));
1386
1391
  },
1387
- setNewBlocks: (x) => {
1388
- r(x), o({
1392
+ setNewBlocks: (b) => {
1393
+ r(b), o({
1389
1394
  undo: () => r(n),
1390
- redo: () => r(x)
1395
+ redo: () => r(b)
1391
1396
  });
1392
1397
  },
1393
- updateMultipleBlocksProps: (x) => {
1394
- let h = [];
1395
- h = map(x, (y) => {
1396
- const B = keys(y), E = n.find((S) => S._id === y._id), w = {};
1397
- return each(B, (S) => w[S] = E[S]), w;
1398
- }), c(x), o({
1399
- undo: () => c(h),
1400
- redo: () => c(x)
1398
+ updateMultipleBlocksProps: (b) => {
1399
+ let x = [];
1400
+ x = map(b, (y) => {
1401
+ const A = keys(y), j = n.find((S) => S._id === y._id), C = {};
1402
+ return each(A, (S) => C[S] = j[S]), C;
1403
+ }), c(b), o({
1404
+ undo: () => c(x),
1405
+ redo: () => c(b)
1401
1406
  });
1402
1407
  }
1403
1408
  };
@@ -1434,12 +1439,12 @@ const useAddBlock = () => {
1434
1439
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1435
1440
  (i, c, d) => {
1436
1441
  var f;
1437
- for (let b = 0; b < i.length; b++) {
1438
- const { _id: x } = i[b];
1439
- i[b]._id = generateUUID();
1440
- const h = filter(i, { _parent: x });
1441
- for (let y = 0; y < h.length; y++)
1442
- h[y]._parent = i[b]._id;
1442
+ for (let h = 0; h < i.length; h++) {
1443
+ const { _id: b } = i[h];
1444
+ i[h]._id = generateUUID();
1445
+ const x = filter(i, { _parent: b });
1446
+ for (let y = 0; y < x.length; y++)
1447
+ x[y]._parent = i[h]._id;
1443
1448
  }
1444
1449
  const p = first(i);
1445
1450
  let u, g;
@@ -1450,8 +1455,8 @@ const useAddBlock = () => {
1450
1455
  return { addCoreBlock: useCallback(
1451
1456
  (i, c, d) => {
1452
1457
  if (has(i, "blocks")) {
1453
- const h = i.blocks;
1454
- return a(h, c, d);
1458
+ const x = i.blocks;
1459
+ return a(x, c, d);
1455
1460
  }
1456
1461
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
1457
1462
  _type: i.type,
@@ -2905,43 +2910,43 @@ const getBlockWithChildren = (o, n) => {
2905
2910
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2906
2911
  })
2907
2912
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
2908
- const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, b) => {
2909
- const x = cloneDeep(b.find((h) => h._id === f));
2910
- for (const h in x) {
2911
- const y = x[h];
2913
+ const [o, n] = useAtom$1(askAiProcessingAtom), [r, a] = useState(null), l = useBuilderProp("askAiCallBack", null), i = useStreamMultipleBlocksProps(), c = useUpdateMultipleBlocksProps(), [d] = useBlocksStore(), { selectedLang: p, fallbackLang: u } = useLanguages(), g = p.length ? p : u, m = (f, h) => {
2914
+ const b = cloneDeep(h.find((x) => x._id === f));
2915
+ for (const x in b) {
2916
+ const y = b[x];
2912
2917
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2913
- const { baseClasses: B, classes: E } = getSplitChaiClasses(y);
2914
- x[h] = compact(flattenDeep([B, E])).join(" ");
2918
+ const { baseClasses: A, classes: j } = getSplitChaiClasses(y);
2919
+ b[x] = compact(flattenDeep([A, j])).join(" ");
2915
2920
  } else
2916
- h !== "_id" && delete x[h];
2921
+ x !== "_id" && delete b[x];
2917
2922
  }
2918
- return x;
2923
+ return b;
2919
2924
  };
2920
2925
  return {
2921
2926
  askAi: useCallback(
2922
- async (f, b, x, h) => {
2927
+ async (f, h, b, x) => {
2923
2928
  if (l) {
2924
2929
  n(!0), a(null);
2925
2930
  try {
2926
- const y = p === u ? "" : p, B = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(b, d)), p) : [m(b, d)], E = await l(f, addLangToPrompt(x, g, f), B, y), { blocks: w, error: S } = E;
2931
+ const y = p === u ? "" : p, A = f === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [m(h, d)], j = await l(f, addLangToPrompt(b, g, f), A, y), { blocks: C, error: S } = j;
2927
2932
  if (S) {
2928
2933
  a(S);
2929
2934
  return;
2930
2935
  }
2931
2936
  if (f === "styles") {
2932
- const A = w.map((_) => {
2933
- for (const C in _)
2934
- C !== "_id" && (_[C] = `${STYLES_KEY},${_[C]}`);
2937
+ const B = C.map((_) => {
2938
+ for (const w in _)
2939
+ w !== "_id" && (_[w] = `${STYLES_KEY},${_[w]}`);
2935
2940
  return _;
2936
2941
  });
2937
- c(A);
2942
+ c(B);
2938
2943
  } else
2939
- i(w);
2940
- h && h(E);
2944
+ i(C);
2945
+ x && x(j);
2941
2946
  } catch (y) {
2942
2947
  a(y);
2943
2948
  } finally {
2944
- n(!1), h && h();
2949
+ n(!1), x && x();
2945
2950
  }
2946
2951
  }
2947
2952
  },
@@ -3119,17 +3124,17 @@ const useBlockHighlight = () => {
3119
3124
  [n, o]
3120
3125
  );
3121
3126
  }, usePasteBlocks = () => {
3122
- const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), { toast: l } = useToast(), { addPredefinedBlock: i } = useAddBlock();
3127
+ const [o, n] = useCutBlockIds(), r = useMoveCutBlocks(), a = useCanPaste(), { addPredefinedBlock: l } = useAddBlock();
3123
3128
  return {
3124
3129
  canPaste: useCallback(
3125
- async (d) => {
3130
+ async (c) => {
3126
3131
  if (o.length > 0)
3127
- return a(o, d);
3132
+ return a(o, c);
3128
3133
  try {
3129
- const p = await navigator.clipboard.readText();
3130
- if (p) {
3131
- const u = JSON.parse(p);
3132
- return has(u, "_chai_copied_blocks");
3134
+ const d = await navigator.clipboard.readText();
3135
+ if (d) {
3136
+ const p = JSON.parse(d);
3137
+ return has(p, "_chai_copied_blocks");
3133
3138
  }
3134
3139
  } catch {
3135
3140
  return !1;
@@ -3139,24 +3144,24 @@ const useBlockHighlight = () => {
3139
3144
  [a, o]
3140
3145
  ),
3141
3146
  pasteBlocks: useCallback(
3142
- async (d) => {
3143
- const p = Array.isArray(d) ? d[0] : d;
3147
+ async (c) => {
3148
+ const d = Array.isArray(c) ? c[0] : c;
3144
3149
  if (!isEmpty(o)) {
3145
- r(o, d), n([]), await navigator.clipboard.writeText("");
3150
+ r(o, c), n([]), await navigator.clipboard.writeText("");
3146
3151
  return;
3147
3152
  }
3148
3153
  try {
3149
- const u = await navigator.clipboard.readText();
3150
- if (u) {
3151
- const g = JSON.parse(u);
3152
- has(g, "_chai_copied_blocks") ? i(g._chai_copied_blocks, p === "root" ? null : p) : l({ title: "Error", description: "Nothing to paste" });
3154
+ const p = await navigator.clipboard.readText();
3155
+ if (p) {
3156
+ const u = JSON.parse(p);
3157
+ has(u, "_chai_copied_blocks") ? l(u._chai_copied_blocks, d === "root" ? null : d) : toast.error("Nothing to paste");
3153
3158
  } else
3154
- l({ title: "Error", description: "Nothing to paste" });
3159
+ toast.error("Nothing to paste");
3155
3160
  } catch {
3156
- l({ title: "Error", description: "Failed to paste blocks from clipboard" });
3161
+ toast.error("Failed to paste blocks from clipboard");
3157
3162
  }
3158
3163
  },
3159
- [o, i, r, n, l]
3164
+ [o, l, r, n]
3160
3165
  )
3161
3166
  };
3162
3167
  }, previewModeAtom = atom$1(!1), usePreviewMode = () => {
@@ -3174,13 +3179,13 @@ const useBlockHighlight = () => {
3174
3179
  const d = o(c), p = a;
3175
3180
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3176
3181
  return each(p, (m) => {
3177
- const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3178
- u = u.replace(b, " ").replace(/\s+/g, " ").trim();
3179
- const x = first(m.split(":"));
3180
- includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(m.split(":").pop().trim());
3182
+ const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3183
+ u = u.replace(h, " ").replace(/\s+/g, " ").trim();
3184
+ const b = first(m.split(":"));
3185
+ includes(["2xl", "xl", "lg", "md", "sm"], b) && p.push(m.split(":").pop().trim());
3181
3186
  }), each(p, (m) => {
3182
- const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), b = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3183
- g = g.replace(b, " ").replace(/\s+/g, " ").trim();
3187
+ const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3188
+ g = g.replace(h, " ").replace(/\s+/g, " ").trim();
3184
3189
  }), {
3185
3190
  ids: [d._id],
3186
3191
  props: {
@@ -3212,7 +3217,7 @@ const useBlockHighlight = () => {
3212
3217
  const n = first(o(selectedStylingBlocksAtom)), r = o(selectedBlockAtom);
3213
3218
  if (!n || n.blockId !== get(r, "_id", null)) return [];
3214
3219
  const a = get(r, n.prop, `${STYLES_KEY},`), { classes: l } = getSplitChaiClasses(a);
3215
- return console.log("classes", l), filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
3220
+ return filter(map(l.trim().split(" "), constructClassObject), (i) => !isNull(i));
3216
3221
  }), useSelectedBlockAllClasses = () => useAtomValue$1(selectedBlockAllClassesAtom), MQ = { xs: 0, sm: 1, md: 2, lg: 3, xl: 4, "2xl": 5 }, selectedBlockCurrentClassesAtom = atom$1((o) => {
3217
3222
  const n = o(canvasBreakpointAtom), r = o(styleStateAtom), a = o(darkModeAtom), l = getQueries(n);
3218
3223
  let i = filter(o(selectedBlockAllClassesAtom), { mod: r });
@@ -3273,7 +3278,7 @@ const useWrapperBlock = () => useAtomValue$1(wrapperBlockAtom), layoutVariantAto
3273
3278
  };
3274
3279
  class PubSub {
3275
3280
  constructor() {
3276
- U(this, "subscribers", /* @__PURE__ */ new Map());
3281
+ V(this, "subscribers", /* @__PURE__ */ new Map());
3277
3282
  }
3278
3283
  subscribe(n, r) {
3279
3284
  return this.subscribers.has(n) || this.subscribers.set(n, /* @__PURE__ */ new Set()), this.subscribers.get(n).add(r), () => {
@@ -3321,13 +3326,13 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3321
3326
  tabIndex: 0,
3322
3327
  ref: u.setFloating,
3323
3328
  style: p,
3324
- onClick: (b) => {
3325
- b.stopPropagation(), b.preventDefault();
3329
+ onClick: (h) => {
3330
+ h.stopPropagation(), h.preventDefault();
3326
3331
  },
3327
- onMouseEnter: (b) => {
3328
- b.stopPropagation(), i(null);
3332
+ onMouseEnter: (h) => {
3333
+ h.stopPropagation(), i(null);
3329
3334
  },
3330
- onKeyDown: (b) => b.stopPropagation(),
3335
+ onKeyDown: (h) => h.stopPropagation(),
3331
3336
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3332
3337
  children: [
3333
3338
  m && /* @__PURE__ */ jsx(
@@ -3408,7 +3413,6 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3408
3413
  </head>
3409
3414
  <body class="font-body antialiased h-full">
3410
3415
  <div class="frame-root h-full"></div>
3411
- <script src="https://cdn.jsdelivr.net/npm/quill@2.0.0/dist/quill.js"><\/script>
3412
3416
  </body>
3413
3417
  </html>`, useKeyEventWatcher = (o) => {
3414
3418
  const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: m } = usePasteBlocks(), f = o ? { document: o } : {};
@@ -3424,8 +3428,8 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3424
3428
  i
3425
3429
  ]), useHotkeys(
3426
3430
  "del, backspace",
3427
- (b) => {
3428
- b.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3431
+ (h) => {
3432
+ h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3429
3433
  },
3430
3434
  f,
3431
3435
  [n, l]
@@ -3523,31 +3527,63 @@ const useDnd = () => {
3523
3527
  },
3524
3528
  onDrop: (f) => {
3525
3529
  var S;
3526
- const b = dropTarget, h = getOrientation(b) === "vertical" ? f.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : f.clientX;
3527
- dropIndex = calculateDropIndex(h, possiblePositions);
3528
- const y = d, B = b.getAttribute("data-block-id"), E = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3529
- if ((y == null ? void 0 : y._id) === B || !E) {
3530
+ const h = dropTarget, x = getOrientation(h) === "vertical" ? f.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : f.clientX;
3531
+ dropIndex = calculateDropIndex(x, possiblePositions);
3532
+ const y = d, A = h.getAttribute("data-block-id"), j = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3533
+ if ((y == null ? void 0 : y._id) === A || !j) {
3530
3534
  m();
3531
3535
  return;
3532
3536
  }
3533
3537
  if (!has(y, "_id")) {
3534
- a(y, B === "canvas" ? null : B, dropIndex), setTimeout(m, 300);
3538
+ a(y, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
3535
3539
  return;
3536
3540
  }
3537
- let w = b.getAttribute("data-block-id");
3538
- w === null && (w = f.target.parentElement.getAttribute("data-block-id")), c([y._id], w === "canvas" ? null : w, dropIndex), m(), setTimeout(removePlaceholder, 300);
3541
+ let C = h.getAttribute("data-block-id");
3542
+ C === null && (C = f.target.parentElement.getAttribute("data-block-id")), c([y._id], C === "canvas" ? null : C, dropIndex), m(), setTimeout(removePlaceholder, 300);
3539
3543
  },
3540
3544
  onDragEnter: (f) => {
3541
- const b = f, x = b.target;
3542
- dropTarget = x;
3543
- const h = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3544
- u(h), b.stopPropagation(), b.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3545
+ const h = f, b = h.target;
3546
+ dropTarget = b;
3547
+ const x = b.getAttribute("data-block-id"), y = b.getAttribute("data-dnd-dragged") !== "yes";
3548
+ u(x), h.stopPropagation(), h.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(b), r(!0), l(""), i([]);
3545
3549
  },
3546
3550
  onDragLeave: (f) => {
3547
3551
  f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3548
3552
  }
3549
3553
  };
3550
3554
  };
3555
+ function cn(...o) {
3556
+ return twMerge(clsx(o));
3557
+ }
3558
+ const TiptapBubbleMenu = ({ editor: o }) => /* @__PURE__ */ jsxs(Fragment, { children: [
3559
+ /* @__PURE__ */ jsx(BubbleMenu, { editor: o, tippyOptions: { duration: 100 }, children: /* @__PURE__ */ jsxs("div", { className: "bubble-menu space-x-2", children: [
3560
+ /* @__PURE__ */ jsx(
3561
+ "button",
3562
+ {
3563
+ onClick: () => o.chain().focus().toggleBold().run(),
3564
+ className: cn(o.isActive("bold") ? "bg-gray-100" : "", "h-3 w-3"),
3565
+ children: /* @__PURE__ */ jsx(Bold, {})
3566
+ }
3567
+ ),
3568
+ /* @__PURE__ */ jsx(
3569
+ "button",
3570
+ {
3571
+ onClick: () => o.chain().focus().toggleItalic().run(),
3572
+ className: cn(o.isActive("italic") ? "bg-gray-100" : "", "h-3 w-3"),
3573
+ children: /* @__PURE__ */ jsx(Italic, {})
3574
+ }
3575
+ ),
3576
+ /* @__PURE__ */ jsx(
3577
+ "button",
3578
+ {
3579
+ onClick: () => o.chain().focus().toggleStrike().run(),
3580
+ className: cn(o.isActive("strike") ? "bg-gray-100" : "", "h-3 w-3"),
3581
+ children: /* @__PURE__ */ jsx(Strikethrough, {})
3582
+ }
3583
+ )
3584
+ ] }) }),
3585
+ /* @__PURE__ */ jsx(EditorContent, { editor: o })
3586
+ ] });
3551
3587
  function getTargetedBlock(o) {
3552
3588
  if (o.getAttribute("data-block-id") === "canvas")
3553
3589
  return null;
@@ -3556,36 +3592,29 @@ function getTargetedBlock(o) {
3556
3592
  const n = o.closest("[data-block-id]");
3557
3593
  return (n == null ? void 0 : n.getAttribute("data-block-id")) === "canvas" ? null : n;
3558
3594
  }
3559
- function destroyQuill(o) {
3560
- o.container.innerHTML = "", o.container.parentNode.removeChild(o.container);
3561
- const n = document.querySelector(".ql-toolbar");
3562
- n && n.parentNode.removeChild(n), o = null;
3563
- }
3564
- const useHandleCanvasDblClick = () => {
3565
- const o = ["Heading", "Paragraph", "Text", "Link", "Span", "Button"], n = useUpdateBlocksProps(), [r, a] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: l } = useBlockHighlight(), i = useGetBlockAtomValue(pageBlocksAtomsAtom);
3595
+ const useHandleCanvasDblClick = (o, n) => {
3596
+ const r = [], a = useUpdateBlocksProps(), [l, i] = useAtom$1(inlineEditingActiveAtom), { clearHighlight: c } = useBlockHighlight(), d = useGetBlockAtomValue(pageBlocksAtomsAtom);
3566
3597
  return useCallback(
3567
- (c) => {
3568
- var x;
3569
- if (r) return;
3570
- const d = getTargetedBlock(c.target), p = d.getAttribute("data-block-type");
3571
- if (!p || !o.includes(p))
3598
+ (p) => {
3599
+ if (l) return;
3600
+ const u = getTargetedBlock(p.target);
3601
+ if (!u) return;
3602
+ const g = u.getAttribute("data-block-type");
3603
+ if (!g || !r.includes(g))
3572
3604
  return;
3573
- const u = d.getAttribute("data-block-id"), g = i(u).content, m = d.cloneNode(!0);
3574
- m.innerHTML = g, d.style.display = "none", Array.from(m.attributes).forEach((h) => {
3575
- h.name !== "class" && m.removeAttribute(h.name);
3576
- }), p === "Text" && (m.style.display = "inline-block"), d.parentNode.insertBefore(m, d.nextSibling);
3577
- const f = new Quill(m, { placeholder: "Type here..." });
3578
- function b() {
3579
- const h = f.getText(0, f.getLength());
3580
- n([u], { content: h }), d.removeAttribute("style"), m.removeEventListener("blur", b, !0), destroyQuill(f), a(""), l(), m.remove();
3581
- }
3582
- m.addEventListener("blur", b, !0), m.addEventListener("click", (h) => {
3583
- h.stopPropagation();
3584
- }), m.addEventListener("keydown", (h) => {
3585
- (h.key === "Enter" || h.key === "Escape") && b();
3586
- }), f.focus(), (x = m.querySelector(".ql-clipboard")) == null || x.remove(), a(d.getAttribute("data-block-id"));
3605
+ const m = u.getAttribute("data-block-id");
3606
+ if (!m) return;
3607
+ o.on("update", ({ editor: h }) => {
3608
+ console.log(h.getHTML());
3609
+ }), o.on("blur", () => {
3610
+ console.log("blur");
3611
+ const h = o.getHTML();
3612
+ a([m], { content: h }), n.style.display = "none", u.style.visibility = "visible";
3613
+ }), i(m);
3614
+ const f = d(m).content;
3615
+ o.commands.setContent(f), n.style.display = "block", u.style.visibility = "hidden", n.style.position = "absolute", n.style.top = `${u.offsetTop}px`, n.style.left = `${u.offsetLeft}px`, n.style.width = `${u.offsetWidth}px`, n.style.height = `${u.offsetHeight}px`, n.classList.add(...u.classList);
3587
3616
  },
3588
- [r, a, n, l]
3617
+ [l, c, d, i, a, o, n]
3589
3618
  );
3590
3619
  }, useHandleCanvasClick = () => {
3591
3620
  const [, o] = useSelectedStylingBlocks(), [n, r] = useSelectedBlockIds(), [a] = useAtom$1(inlineEditingActiveAtom), [l] = useAtom$1(treeRefAtom), { clearHighlight: i } = useBlockHighlight();
@@ -3622,29 +3651,34 @@ const useHandleCanvasDblClick = () => {
3622
3651
  setTimeout(() => {
3623
3652
  if (!isEmpty(a))
3624
3653
  return;
3625
- const m = getElementByDataBlockId(n, first(r));
3626
- if (m) {
3627
- const f = m.getAttribute("data-style-prop");
3628
- if (f) {
3629
- const b = m.getAttribute("data-style-id"), x = m.getAttribute("data-block-parent");
3630
- l([{ id: b, prop: f, blockId: x }]);
3654
+ const h = getElementByDataBlockId(n, first(r));
3655
+ if (h) {
3656
+ const b = h.getAttribute("data-style-prop");
3657
+ if (b) {
3658
+ const x = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3659
+ l([{ id: x, prop: b, blockId: y }]);
3631
3660
  }
3632
3661
  }
3633
3662
  }, 100);
3634
3663
  }, [n, r, l, a]);
3635
- const c = useHandleCanvasDblClick(), d = useHandleCanvasClick(), p = useHandleMouseMove(), u = useHandleMouseLeave(), g = useDnd();
3636
- return /* @__PURE__ */ jsx(
3664
+ const c = useEditor({
3665
+ extensions: [StarterKit]
3666
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), f = useDnd();
3667
+ return /* @__PURE__ */ jsxs(
3637
3668
  "div",
3638
3669
  {
3639
3670
  "data-block-id": "canvas",
3640
3671
  id: "canvas",
3641
- onClick: d,
3642
- onDoubleClick: c,
3643
- onMouseMove: p,
3644
- onMouseLeave: u,
3645
- ...omit(g, "isDragging"),
3646
- className: "relative h-full max-w-full p-px " + (g.isDragging ? "dragging" : ""),
3647
- children: o
3672
+ onClick: u,
3673
+ onDoubleClick: p,
3674
+ onMouseMove: g,
3675
+ onMouseLeave: m,
3676
+ ...omit(f, "isDragging"),
3677
+ className: "relative h-full max-w-full p-px " + (f.isDragging ? "dragging" : ""),
3678
+ children: [
3679
+ o,
3680
+ /* @__PURE__ */ jsx("div", { ref: d, style: { display: "none" }, children: /* @__PURE__ */ jsx(TiptapBubbleMenu, { editor: c }) })
3681
+ ]
3648
3682
  }
3649
3683
  );
3650
3684
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
@@ -3677,8 +3711,8 @@ const useHandleCanvasDblClick = () => {
3677
3711
  forms,
3678
3712
  aspectRatio,
3679
3713
  containerQueries,
3680
- plugin(function({ addBase: h, theme: y }) {
3681
- h({
3714
+ plugin(function({ addBase: x, theme: y }) {
3715
+ x({
3682
3716
  "h1,h2,h3,h4,h5,h6": {
3683
3717
  fontFamily: y("fontFamily.heading")
3684
3718
  },
@@ -3692,7 +3726,7 @@ const useHandleCanvasDblClick = () => {
3692
3726
  ]
3693
3727
  });
3694
3728
  }, [o, n, p]), useEffect(() => {
3695
- g && (g.textContent = `${map(r, (h) => `[data-block-id="${h}"]`).join(",")}{
3729
+ g && (g.textContent = `${map(r, (x) => `[data-block-id="${x}"]`).join(",")}{
3696
3730
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3697
3731
  }`);
3698
3732
  }, [r, g]), useEffect(() => {
@@ -3700,19 +3734,19 @@ const useHandleCanvasDblClick = () => {
3700
3734
  }, [i, f]), useEffect(() => {
3701
3735
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3702
3736
  }, [u]), useEffect(() => {
3703
- m && (m.textContent = `${map(l, ({ id: h }) => `[data-style-id="${h}"]`).join(",")}{
3737
+ m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
3704
3738
  outline: 1px solid orange !important; outline-offset: -1px;
3705
3739
  }`);
3706
3740
  }, [l, m]), useEffect(() => {
3707
3741
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3708
3742
  }, [c, d]);
3709
- const b = useMemo(
3743
+ const h = useMemo(
3710
3744
  () => getChaiThemeCssVariables(o),
3711
3745
  [o]
3712
- ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3746
+ ), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3713
3747
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3714
- /* @__PURE__ */ jsx("style", { id: "chai-theme", children: b }),
3715
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3748
+ /* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
3749
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
3716
3750
  ] });
3717
3751
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
3718
3752
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3789,10 +3823,10 @@ const getBlockRuntimeProps = memoize((o) => {
3789
3823
  [o]
3790
3824
  );
3791
3825
  }, BlockRenderer = ({ blockAtom: o, children: n }) => {
3792
- const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(inlineEditingActiveAtom), [g] = useAtom$1(dataBindingActiveAtom), m = get(a, "component", null), f = useMemo(
3793
- () => g ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3794
- [r, l, a, d, g]
3795
- ), b = useMemo(() => getBlockTagAttributes(r), [r]), x = useMemo(() => c(r._id, getBlockRuntimeProps(r._type)), [r]), h = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), y = useMemo(
3826
+ const [r] = useAtom$1(o), a = useMemo(() => getRegisteredChaiBlock(r._type), [r._type]), { selectedLang: l, fallbackLang: i } = useLanguages(), c = useBlockRuntimeProps(), d = usePageExternalData(), [p] = useHiddenBlockIds(), [u] = useAtom$1(dataBindingActiveAtom), g = get(a, "component", null), m = useMemo(
3827
+ () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3828
+ [r, l, a, d, u]
3829
+ ), f = useMemo(() => getBlockTagAttributes(r), [r]), h = useMemo(() => c(r._id, getBlockRuntimeProps(r._type)), [r]), b = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), x = useMemo(
3796
3830
  () => ({
3797
3831
  blockProps: {
3798
3832
  "data-block-id": r._id,
@@ -3800,14 +3834,14 @@ const getBlockRuntimeProps = memoize((o) => {
3800
3834
  },
3801
3835
  inBuilder: !0,
3802
3836
  lang: l || i,
3837
+ ...m,
3803
3838
  ...f,
3804
- ...b,
3805
- ...x,
3806
- ...h
3839
+ ...h,
3840
+ ...b
3807
3841
  }),
3808
- [r, l, i, f, b, x, h]
3842
+ [r, l, i, m, f, h, b]
3809
3843
  );
3810
- return isNull(m) || p.includes(r._id) || u === r._id ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(m, { ...y, children: n }) });
3844
+ return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
3811
3845
  }, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
3812
3846
  const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3813
3847
  return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
@@ -3857,43 +3891,43 @@ const getBlockRuntimeProps = memoize((o) => {
3857
3891
  c();
3858
3892
  }, [n, o, r, c]), l;
3859
3893
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3860
- const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [, b] = useAtom$1(canvasIframeAtom), [x, h] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), E = (A) => {
3861
- p((_) => ({ ..._, width: A }));
3894
+ const [o] = useAtom$1(networkModeAtom), [n] = useCanvasDisplayWidth(), [, r] = useSelectedBlockIds(), a = useSelectedBlock(), [, l] = useHighlightBlockId(), i = useRef(null), c = useRef(null), [d, p] = useState({ width: 0, height: 0 }), u = useCanvasScale(d), [g, m] = useState([]), [, f] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [b, x] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), A = useBuilderProp("htmlDir", "ltr"), j = (B) => {
3895
+ p((_) => ({ ..._, width: B }));
3862
3896
  };
3863
- console.log("width", n), useEffect(() => {
3897
+ useEffect(() => {
3864
3898
  if (!c.current) return;
3865
- const { clientWidth: A, clientHeight: _ } = c.current;
3866
- p({ width: A, height: _ });
3899
+ const { clientWidth: B, clientHeight: _ } = c.current;
3900
+ p({ width: B, height: _ });
3867
3901
  }, [c, n]);
3868
- const w = (A, _ = 0) => {
3869
- const { top: C } = A.getBoundingClientRect();
3870
- return C + _ >= 0 && C - _ <= window.innerHeight;
3902
+ const C = (B, _ = 0) => {
3903
+ const { top: w } = B.getBoundingClientRect();
3904
+ return w + _ >= 0 && w - _ <= window.innerHeight;
3871
3905
  };
3872
3906
  useEffect(() => {
3873
- var A, _;
3907
+ var B, _;
3874
3908
  if (a && a.type !== "Multiple" && i.current) {
3875
- const C = getElementByDataBlockId(i.current.contentDocument, a._id);
3876
- C && (w(C) || (_ = (A = i.current) == null ? void 0 : A.contentWindow) == null || _.scrollTo({ top: C.offsetTop, behavior: "smooth" }), m([C]));
3909
+ const w = getElementByDataBlockId(i.current.contentDocument, a._id);
3910
+ w && (C(w) || (_ = (B = i.current) == null ? void 0 : B.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
3877
3911
  }
3878
3912
  }, [a]), useEffect(() => {
3879
- if (!isEmpty(x) && i.current) {
3880
- const A = getElementByStyleId(
3913
+ if (!isEmpty(b) && i.current) {
3914
+ const B = getElementByStyleId(
3881
3915
  i.current.contentDocument,
3882
- first(x).id
3916
+ first(b).id
3883
3917
  );
3884
- f(A ? [A] : [null]);
3918
+ f(B ? [B] : [null]);
3885
3919
  } else
3886
3920
  f([null]);
3887
- }, [x]);
3921
+ }, [b]);
3888
3922
  const S = useMemo(() => {
3889
- let A = IframeInitialContent;
3890
- return A = A.replace("__HTML_DIR__", B), o === "offline" && (A = A.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), A;
3891
- }, [o, B]);
3892
- return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: E, onResize: E, children: /* @__PURE__ */ jsx(
3923
+ let B = IframeInitialContent;
3924
+ return B = B.replace("__HTML_DIR__", A), o === "offline" && (B = B.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), B;
3925
+ }, [o, A]);
3926
+ return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: j, onResize: j, children: /* @__PURE__ */ jsx(
3893
3927
  "div",
3894
3928
  {
3895
3929
  onClick: () => {
3896
- r([]), h([]);
3930
+ r([]), x([]);
3897
3931
  },
3898
3932
  onMouseLeave: () => setTimeout(() => l(""), 300),
3899
3933
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3901,7 +3935,7 @@ const getBlockRuntimeProps = memoize((o) => {
3901
3935
  children: /* @__PURE__ */ jsxs(
3902
3936
  ChaiFrame,
3903
3937
  {
3904
- contentDidMount: () => b(i.current),
3938
+ contentDidMount: () => h(i.current),
3905
3939
  ref: i,
3906
3940
  id: "canvas-iframe",
3907
3941
  style: { ...u, ...isEmpty(u) ? { width: `${n}px` } : {} },
@@ -4046,7 +4080,7 @@ const getBlockRuntimeProps = memoize((o) => {
4046
4080
  l !== o.length - 1 && /* @__PURE__ */ jsx(ChevronRight, { className: "rtl:rotate-180", size: 16 })
4047
4081
  ] }, l))
4048
4082
  ] }) });
4049
- }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-DyWk02_x.js")), CanvasArea = () => {
4083
+ }, CodeEditor$1 = React__default.lazy(() => import("./CodeEditor-Bv7cAp6l.js")), CanvasArea = () => {
4050
4084
  const [o] = useCodeEditor(), n = useBuilderProp("onError", noop);
4051
4085
  return /* @__PURE__ */ jsx("div", { className: "flex h-full max-h-full w-full flex-1 flex-col", children: /* @__PURE__ */ jsxs("div", { className: "relative flex h-full max-h-full flex-col overflow-hidden bg-gray-100/40 px-2", children: [
4052
4086
  /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx(Skeleton, { className: "h-full" }), children: /* @__PURE__ */ jsx(ErrorBoundary, { fallback: /* @__PURE__ */ jsx(FallbackError, {}), onError: n, children: /* @__PURE__ */ jsx(StaticCanvas, {}) }) }),
@@ -4160,25 +4194,25 @@ const getBlockRuntimeProps = memoize((o) => {
4160
4194
  const [n] = useDarkMode(), [r, a] = React.useState(""), l = useBuilderProp("themePresets", []), i = useBuilderProp("themePanelComponent", null), [c, d] = useTheme(), p = useThemeOptions(), { t: u } = useTranslation(), g = (y) => {
4161
4195
  a(y);
4162
4196
  }, m = () => {
4163
- const y = l.find((B) => Object.keys(B)[0] === r);
4197
+ const y = l.find((A) => Object.keys(A)[0] === r);
4164
4198
  if (y) {
4165
- const B = Object.values(y)[0];
4166
- B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
4199
+ const A = Object.values(y)[0];
4200
+ A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
4167
4201
  } else
4168
4202
  console.error("Preset not found:", r);
4169
4203
  }, f = useDebouncedCallback(
4170
- (y, B) => {
4204
+ (y, A) => {
4171
4205
  d(() => ({
4172
4206
  ...c,
4173
4207
  fontFamily: {
4174
4208
  ...c.fontFamily,
4175
- [y.replace(/font-/g, "")]: B
4209
+ [y.replace(/font-/g, "")]: A
4176
4210
  }
4177
4211
  }));
4178
4212
  },
4179
4213
  [c],
4180
4214
  200
4181
- ), b = useDebouncedCallback(
4215
+ ), h = useDebouncedCallback(
4182
4216
  (y) => {
4183
4217
  d(() => ({
4184
4218
  ...c,
@@ -4187,36 +4221,36 @@ const getBlockRuntimeProps = memoize((o) => {
4187
4221
  },
4188
4222
  [c],
4189
4223
  200
4190
- ), x = useDebouncedCallback(
4191
- (y, B) => {
4224
+ ), b = useDebouncedCallback(
4225
+ (y, A) => {
4192
4226
  d(() => {
4193
- const E = get(c, `colors.${y}`);
4194
- return n ? set(E, 1, B) : set(E, 0, B), {
4227
+ const j = get(c, `colors.${y}`);
4228
+ return n ? set(j, 1, A) : set(j, 0, A), {
4195
4229
  ...c,
4196
4230
  colors: {
4197
4231
  ...c.colors,
4198
- [y]: E
4232
+ [y]: j
4199
4233
  }
4200
4234
  };
4201
4235
  });
4202
4236
  },
4203
4237
  [c],
4204
4238
  200
4205
- ), h = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4206
- const E = get(c, `colors.${B}.${n ? 1 : 0}`);
4239
+ ), x = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
4240
+ const j = get(c, `colors.${A}.${n ? 1 : 0}`);
4207
4241
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4208
4242
  /* @__PURE__ */ jsx(
4209
4243
  ColorPickerInput,
4210
4244
  {
4211
- value: E,
4212
- onChange: (w) => x(B, w)
4245
+ value: j,
4246
+ onChange: (C) => b(A, C)
4213
4247
  }
4214
4248
  ),
4215
- /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((w) => w.charAt(0).toUpperCase() + w.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4216
- ] }, B);
4249
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: A.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ") + (!A.toLowerCase().includes("foreground") && !A.toLowerCase().includes("border") && !A.toLowerCase().includes("input") && !A.toLowerCase().includes("ring") && !A.toLowerCase().includes("background") ? " Background" : "") })
4250
+ ] }, A);
4217
4251
  }) });
4218
4252
  return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4219
- /* @__PURE__ */ jsxs("div", { className: cn("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4253
+ /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
4220
4254
  l.length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex gap-2 py-2", children: [
4221
4255
  /* @__PURE__ */ jsxs("div", { className: "w-full", children: [
4222
4256
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Presets") }),
@@ -4244,26 +4278,26 @@ const getBlockRuntimeProps = memoize((o) => {
4244
4278
  }
4245
4279
  ) })
4246
4280
  ] }),
4247
- /* @__PURE__ */ jsxs("div", { className: cn("space-y-2", o), children: [
4248
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
4281
+ /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4282
+ (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
4249
4283
  FontSelector,
4250
4284
  {
4251
4285
  label: y,
4252
- value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4253
- onChange: (E) => f(y, E)
4286
+ value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4287
+ onChange: (j) => f(y, j)
4254
4288
  },
4255
4289
  y
4256
4290
  )) }),
4257
4291
  (p == null ? void 0 : p.borderRadius) && /* @__PURE__ */ jsxs("div", { className: "space-y-0.5 py-3", children: [
4258
4292
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Border Radius") }),
4259
4293
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-4 py-2", children: [
4260
- /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: b }),
4294
+ /* @__PURE__ */ jsx(BorderRadiusInput, { value: c.borderRadius, onChange: h }),
4261
4295
  /* @__PURE__ */ jsx("span", { className: "w-12 text-sm", children: c.borderRadius })
4262
4296
  ] })
4263
4297
  ] }),
4264
4298
  (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4265
4299
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4266
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => h(y)) }, n ? "dark" : "light")
4300
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => x(y)) }, n ? "dark" : "light")
4267
4301
  ] })
4268
4302
  ] }),
4269
4303
  /* @__PURE__ */ jsx("br", {}),
@@ -4429,70 +4463,395 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4429
4463
  )
4430
4464
  ] })
4431
4465
  ] });
4432
- }, RichTextEditorField = ({ id: o, placeholder: n, value: r, onChange: a, onBlur: l }) => {
4433
- const i = {
4434
- toolbar: [
4435
- ["bold", "italic", "underline", "strike", "blockquote"],
4436
- [{ list: "ordered" }, { list: "bullet" }],
4437
- [{ color: [] }, { background: [] }, { align: [] }],
4438
- ["link", "clean"]
4439
- ]
4440
- }, c = [
4441
- "header",
4442
- "font",
4443
- "list",
4444
- "bold",
4445
- "italic",
4446
- "underline",
4447
- "strike",
4448
- "blockquote",
4449
- "color",
4450
- "background",
4451
- "align",
4452
- "link",
4453
- "image"
4454
- ], d = useRef(null), p = useRef(null);
4455
- return useEffect(() => {
4456
- if (d.current) {
4457
- const u = d.current.getEditor();
4458
- p.current.__quill = u;
4466
+ };
4467
+ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4468
+ const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
4469
+ useEffect(() => {
4470
+ a || c([]), p(o);
4471
+ }, [a, o]);
4472
+ const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
4473
+ (h) => {
4474
+ const b = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
4475
+ h.type === "object" ? (c((x) => [...x, h.key]), p(h.value)) : b(h.type) && (n([...i, h.key].join(".")), l(!1));
4476
+ },
4477
+ [i, n, r]
4478
+ ), m = React.useCallback(() => {
4479
+ if (i.length > 0) {
4480
+ const h = i.slice(0, -1);
4481
+ c(h), p(h.reduce((b, x) => b[x], o));
4459
4482
  }
4460
- }, []), typeof window > "u" ? null : (console.log(r), /* @__PURE__ */ jsx("div", { id: `quill.${o}`, ref: p, children: /* @__PURE__ */ jsx(
4461
- ReactQuill,
4462
- {
4463
- ref: d,
4464
- id: o,
4465
- value: r,
4466
- onBlur: (u) => l(o, u),
4467
- onChange: (u) => a(u),
4468
- modules: i,
4469
- formats: c,
4470
- placeholder: n,
4471
- className: "mt-1 rounded-md"
4483
+ }, [i, o]), f = React.useMemo(() => Object.entries(d).map(([h, b]) => ({
4484
+ key: h,
4485
+ value: b,
4486
+ type: u(b)
4487
+ })).filter((h) => r === "value" ? h.type === "value" || h.type === "object" : r === "array" ? h.type === "array" || h.type === "object" : r === "object" ? h.type === "object" : !0), [d, r]);
4488
+ return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4489
+ /* @__PURE__ */ jsxs(Tooltip, { children: [
4490
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
4491
+ Button,
4492
+ {
4493
+ size: "sm",
4494
+ variant: "outline",
4495
+ className: "h-5 px-1 py-0 text-[9px] text-muted-foreground",
4496
+ role: "combobox",
4497
+ "aria-expanded": a,
4498
+ children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3" })
4499
+ }
4500
+ ) }) }),
4501
+ /* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
4502
+ ] }),
4503
+ /* @__PURE__ */ jsx(PopoverContent, { className: "z-[1000]! relative mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4504
+ /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4505
+ /* @__PURE__ */ jsxs(CommandList, { children: [
4506
+ /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4507
+ /* @__PURE__ */ jsxs(CommandGroup, { children: [
4508
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
4509
+ /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4510
+ "Back"
4511
+ ] }),
4512
+ f.map((h) => /* @__PURE__ */ jsxs(
4513
+ CommandItem,
4514
+ {
4515
+ value: h.key,
4516
+ disabled: !1,
4517
+ onSelect: () => g(h),
4518
+ className: "flex items-center justify-between",
4519
+ children: [
4520
+ /* @__PURE__ */ jsx("span", { children: h.key }),
4521
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4522
+ r === "object" && h.type === "object" && /* @__PURE__ */ jsx(
4523
+ Button,
4524
+ {
4525
+ size: "sm",
4526
+ variant: "ghost",
4527
+ className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4528
+ onClick: (b) => {
4529
+ b.stopPropagation(), n([...i, h.key].join(".")), l(!1);
4530
+ },
4531
+ children: "Select"
4532
+ }
4533
+ ),
4534
+ (h.type === "object" || h.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
4535
+ ] })
4536
+ ]
4537
+ },
4538
+ h.key
4539
+ ))
4540
+ ] })
4541
+ ] })
4542
+ ] }) })
4543
+ ] });
4544
+ }
4545
+ const MenuBar = ({ editor: o, onExpand: n }) => {
4546
+ if (!o)
4547
+ return null;
4548
+ const r = () => {
4549
+ const l = window.prompt("URL");
4550
+ l && o.chain().focus().extendMarkRange("link").setLink({ href: l }).run();
4551
+ }, a = () => {
4552
+ o.chain().focus().unsetLink().run();
4553
+ };
4554
+ return /* @__PURE__ */ jsxs("div", { className: "mb-1 flex flex-wrap gap-1 rounded-md border border-border p-1", children: [
4555
+ /* @__PURE__ */ jsx(
4556
+ "button",
4557
+ {
4558
+ type: "button",
4559
+ onClick: () => o.chain().focus().toggleBold().run(),
4560
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("bold") }),
4561
+ title: "Bold",
4562
+ children: /* @__PURE__ */ jsx(Bold, { className: "h-4 w-4" })
4563
+ }
4564
+ ),
4565
+ /* @__PURE__ */ jsx(
4566
+ "button",
4567
+ {
4568
+ type: "button",
4569
+ onClick: () => o.chain().focus().toggleItalic().run(),
4570
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("italic") }),
4571
+ title: "Italic",
4572
+ children: /* @__PURE__ */ jsx(Italic, { className: "h-4 w-4" })
4573
+ }
4574
+ ),
4575
+ /* @__PURE__ */ jsx(
4576
+ "button",
4577
+ {
4578
+ type: "button",
4579
+ onClick: () => o.chain().focus().toggleUnderline().run(),
4580
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("underline") }),
4581
+ title: "Underline",
4582
+ children: /* @__PURE__ */ jsx(Underline$1, { className: "h-4 w-4" })
4583
+ }
4584
+ ),
4585
+ /* @__PURE__ */ jsx(
4586
+ "button",
4587
+ {
4588
+ type: "button",
4589
+ onClick: () => o.chain().focus().toggleStrike().run(),
4590
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("strike") }),
4591
+ title: "Strike",
4592
+ children: /* @__PURE__ */ jsx(Strikethrough, { className: "h-4 w-4" })
4593
+ }
4594
+ ),
4595
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
4596
+ /* @__PURE__ */ jsx(
4597
+ "button",
4598
+ {
4599
+ type: "button",
4600
+ onClick: () => o.chain().focus().toggleBulletList().run(),
4601
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("bulletList") }),
4602
+ title: "Bullet List",
4603
+ children: /* @__PURE__ */ jsx(List, { className: "h-4 w-4" })
4604
+ }
4605
+ ),
4606
+ /* @__PURE__ */ jsx(
4607
+ "button",
4608
+ {
4609
+ type: "button",
4610
+ onClick: () => o.chain().focus().toggleOrderedList().run(),
4611
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("orderedList") }),
4612
+ title: "Ordered List",
4613
+ children: /* @__PURE__ */ jsx(ListOrdered, { className: "h-4 w-4" })
4614
+ }
4615
+ ),
4616
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
4617
+ /* @__PURE__ */ jsx(
4618
+ "button",
4619
+ {
4620
+ type: "button",
4621
+ onClick: () => o.chain().focus().setTextAlign("left").run(),
4622
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "left" }) }),
4623
+ title: "Align Left",
4624
+ children: /* @__PURE__ */ jsx(AlignLeft, { className: "h-4 w-4" })
4625
+ }
4626
+ ),
4627
+ /* @__PURE__ */ jsx(
4628
+ "button",
4629
+ {
4630
+ type: "button",
4631
+ onClick: () => o.chain().focus().setTextAlign("center").run(),
4632
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "center" }) }),
4633
+ title: "Align Center",
4634
+ children: /* @__PURE__ */ jsx(AlignCenter, { className: "h-4 w-4" })
4635
+ }
4636
+ ),
4637
+ /* @__PURE__ */ jsx(
4638
+ "button",
4639
+ {
4640
+ type: "button",
4641
+ onClick: () => o.chain().focus().setTextAlign("right").run(),
4642
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive({ textAlign: "right" }) }),
4643
+ title: "Align Right",
4644
+ children: /* @__PURE__ */ jsx(AlignRight, { className: "h-4 w-4" })
4645
+ }
4646
+ ),
4647
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
4648
+ /* @__PURE__ */ jsx(
4649
+ "button",
4650
+ {
4651
+ type: "button",
4652
+ onClick: r,
4653
+ className: cn("rounded p-1 hover:bg-muted", { "bg-muted": o.isActive("link") }),
4654
+ title: "Add Link",
4655
+ children: /* @__PURE__ */ jsx(Link$1, { className: "h-4 w-4" })
4656
+ }
4657
+ ),
4658
+ /* @__PURE__ */ jsx(
4659
+ "button",
4660
+ {
4661
+ type: "button",
4662
+ onClick: a,
4663
+ className: cn("rounded p-1 hover:bg-muted"),
4664
+ title: "Remove Link",
4665
+ disabled: !o.isActive("link"),
4666
+ children: /* @__PURE__ */ jsx(Unlink, { className: "h-4 w-4" })
4667
+ }
4668
+ ),
4669
+ n && /* @__PURE__ */ jsxs(Fragment, { children: [
4670
+ /* @__PURE__ */ jsx("div", { className: "mx-1 h-6 w-px self-center bg-border" }),
4671
+ /* @__PURE__ */ jsx(
4672
+ "button",
4673
+ {
4674
+ type: "button",
4675
+ onClick: n,
4676
+ className: "rounded p-1 hover:bg-muted",
4677
+ title: "Open in full screen mode",
4678
+ children: /* @__PURE__ */ jsx(Maximize2, { className: "h-4 w-4" })
4679
+ }
4680
+ )
4681
+ ] })
4682
+ ] });
4683
+ }, RTEModal = ({
4684
+ isOpen: o,
4685
+ onClose: n,
4686
+ id: r,
4687
+ value: a,
4688
+ onChange: l,
4689
+ onBlur: i
4690
+ }) => {
4691
+ const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4692
+ useEffect(() => {
4693
+ if (o) {
4694
+ const m = document.createElement("style");
4695
+ return m.id = "rte-modal-styles", m.innerHTML = `
4696
+ /* Ensure the NestedPathSelector popover appears above the dialog */
4697
+ .rte-path-selector + [data-radix-popper-content-wrapper],
4698
+ [data-radix-popper-content-wrapper] {
4699
+ z-index: 9999 !important;
4700
+ }
4701
+ `, document.head.appendChild(m), () => {
4702
+ const f = document.getElementById("rte-modal-styles");
4703
+ f && f.remove();
4704
+ };
4705
+ }
4706
+ }, [o]);
4707
+ const u = useEditor({
4708
+ extensions: [
4709
+ StarterKit,
4710
+ Link.configure({
4711
+ openOnClick: !1,
4712
+ HTMLAttributes: {
4713
+ class: "text-primary underline"
4714
+ }
4715
+ }),
4716
+ TextAlign.configure({
4717
+ types: ["heading", "paragraph"],
4718
+ alignments: ["left", "center", "right"],
4719
+ defaultAlignment: "left"
4720
+ }),
4721
+ Underline
4722
+ ],
4723
+ content: a || "",
4724
+ onUpdate: ({ editor: m }) => {
4725
+ const f = m.getHTML();
4726
+ l(f);
4727
+ },
4728
+ onBlur: ({ editor: m }) => {
4729
+ const f = m.getHTML();
4730
+ i(r, f);
4731
+ },
4732
+ editorProps: {
4733
+ attributes: {
4734
+ class: "prose prose-sm focus:outline-none min-h-[300px] p-2 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"
4735
+ }
4736
+ }
4737
+ });
4738
+ useEffect(() => {
4739
+ o && u && (d.current !== a && (d.current = a || "", u.commands.setContent(a || "")), setTimeout(() => {
4740
+ u.commands.focus();
4741
+ }, 100));
4742
+ }, [o, u]), useEffect(() => {
4743
+ c.current && u && (c.current.__chaiRTE = u);
4744
+ }, [u, o]);
4745
+ const g = (m) => {
4746
+ if (!u) return;
4747
+ const f = `{{${m}}}`;
4748
+ u.commands.focus();
4749
+ const { from: h, to: b } = u.state.selection;
4750
+ if (h !== b)
4751
+ u.chain().deleteSelection().insertContent(f).run();
4752
+ else {
4753
+ const { state: y } = u, A = y.selection.from, j = y.doc.textBetween(Math.max(0, A - 1), A), C = y.doc.textBetween(A, Math.min(A + 1, y.doc.content.size));
4754
+ let S = "";
4755
+ A > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
4756
+ let B = "";
4757
+ C && C !== " " && !/[.,!?;:]/.test(C) && (B = " "), u.chain().insertContent(S + f + B).run();
4758
+ }
4759
+ };
4760
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (m) => !m && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4761
+ /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4762
+ /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4763
+ p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
4764
+ /* @__PURE__ */ jsx("span", { className: "mr-2 text-sm text-muted-foreground", children: "Add field:" }),
4765
+ /* @__PURE__ */ jsx("div", { className: "rte-path-selector", children: /* @__PURE__ */ jsx(NestedPathSelector, { data: p, onSelect: g }) })
4766
+ ] })
4767
+ ] }) }),
4768
+ /* @__PURE__ */ jsxs("div", { id: `chai-rte-modal-${r}`, ref: c, className: "rounded-md border border-input", children: [
4769
+ /* @__PURE__ */ jsx(MenuBar, { editor: u }),
4770
+ /* @__PURE__ */ jsx(EditorContent, { editor: u, id: `modal-${r}`, className: "p-2" })
4771
+ ] }),
4772
+ /* @__PURE__ */ jsx("div", { className: "mt-4 flex justify-end", children: /* @__PURE__ */ jsx(Button, { onClick: n, children: "Done" }) })
4773
+ ] }) });
4774
+ }, RichTextEditorField = ({ id: o, placeholder: n, value: r, onChange: a, onBlur: l }) => {
4775
+ const i = useRef(null), [c, d] = useState(!1), [p, u] = useState(""), g = useEditor({
4776
+ extensions: [
4777
+ StarterKit,
4778
+ Link.configure({
4779
+ openOnClick: !1,
4780
+ HTMLAttributes: {
4781
+ class: "text-primary underline"
4782
+ }
4783
+ }),
4784
+ TextAlign.configure({
4785
+ types: ["heading", "paragraph"],
4786
+ alignments: ["left", "center", "right"],
4787
+ defaultAlignment: "left"
4788
+ }),
4789
+ Underline
4790
+ ],
4791
+ content: r || "",
4792
+ onUpdate: ({ editor: h }) => {
4793
+ const b = h.getHTML();
4794
+ a(b), c || u(b);
4795
+ },
4796
+ onBlur: ({ editor: h }) => {
4797
+ const b = h.getHTML();
4798
+ l(o, b);
4799
+ },
4800
+ editorProps: {
4801
+ attributes: {
4802
+ class: "prose prose-sm focus:outline-none min-h-[100px] p-1 dark:prose-invert prose-p:m-0 prose-blockquote:m-2 prose-blockquote:ml-4 prose-ul:m-0 prose-ol:m-0 prose-li:m-0"
4803
+ }
4472
4804
  }
4473
- ) }));
4805
+ });
4806
+ useEffect(() => {
4807
+ i.current.__chaiRTE = g;
4808
+ }, [g]), useEffect(() => {
4809
+ u(r || "");
4810
+ }, [r]);
4811
+ const m = (h) => {
4812
+ a(h);
4813
+ }, f = () => {
4814
+ d(!1), g && g.commands.setContent(p);
4815
+ };
4816
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
4817
+ /* @__PURE__ */ jsx("div", { className: "relative", children: /* @__PURE__ */ jsxs("div", { id: `chai-rte-${o}`, ref: i, className: "mt-1 rounded-md border border-input", children: [
4818
+ /* @__PURE__ */ jsx(MenuBar, { editor: g, onExpand: () => d(!0) }),
4819
+ /* @__PURE__ */ jsx(EditorContent, { editor: g, id: o, placeholder: n })
4820
+ ] }) }),
4821
+ c && /* @__PURE__ */ jsx(
4822
+ RTEModal,
4823
+ {
4824
+ isOpen: c,
4825
+ onClose: f,
4826
+ id: o,
4827
+ value: p,
4828
+ onChange: m,
4829
+ onBlur: l
4830
+ }
4831
+ )
4832
+ ] });
4474
4833
  }, PageTypeField = ({
4475
4834
  href: o,
4476
4835
  pageTypes: n,
4477
4836
  onChange: r
4478
4837
  }) => {
4479
4838
  var T;
4480
- const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [b, x] = useState([]), [h, y] = useState(-1), B = useRef(null), E = (T = n == null ? void 0 : n.find((k) => k.key === u)) == null ? void 0 : T.name;
4839
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (k, v) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [m, f] = useState(""), [h, b] = useState([]), [x, y] = useState(-1), A = useRef(null), j = (T = n == null ? void 0 : n.find((k) => k.key === u)) == null ? void 0 : T.name;
4481
4840
  useEffect(() => {
4482
- if (f(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4841
+ if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4483
4842
  const k = split(o, ":"), v = get(k, 1, "page") || "page";
4484
4843
  g(v), (async () => {
4485
4844
  const N = await l(v, [get(k, 2, "page")]);
4486
4845
  N && Array.isArray(N) && f(get(N, [0, "name"], ""));
4487
4846
  })();
4488
4847
  }, [o]);
4489
- const w = useDebouncedCallback(
4848
+ const C = useDebouncedCallback(
4490
4849
  async (k) => {
4491
4850
  if (isEmpty(k))
4492
- x([]);
4851
+ b([]);
4493
4852
  else {
4494
4853
  const v = await l(u, k);
4495
- x(v);
4854
+ b(v);
4496
4855
  }
4497
4856
  c(!1), y(-1);
4498
4857
  },
@@ -4500,18 +4859,18 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4500
4859
  300
4501
4860
  ), S = (k) => {
4502
4861
  const v = ["pageType", u, k.id];
4503
- v[1] && (r(v.join(":")), f(k.name), p(!1), x([]), y(-1));
4504
- }, A = (k) => {
4862
+ v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
4863
+ }, B = (k) => {
4505
4864
  switch (k.key) {
4506
4865
  case "ArrowDown":
4507
- k.preventDefault(), y((v) => v < b.length - 1 ? v + 1 : v);
4866
+ k.preventDefault(), y((v) => v < h.length - 1 ? v + 1 : v);
4508
4867
  break;
4509
4868
  case "ArrowUp":
4510
4869
  k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
4511
4870
  break;
4512
4871
  case "Enter":
4513
- if (k.preventDefault(), b.length === 0) return;
4514
- h >= 0 && S(b[h]);
4872
+ if (k.preventDefault(), h.length === 0) return;
4873
+ x >= 0 && S(h[x]);
4515
4874
  break;
4516
4875
  case "Escape":
4517
4876
  k.preventDefault(), _();
@@ -4519,15 +4878,15 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4519
4878
  }
4520
4879
  };
4521
4880
  useEffect(() => {
4522
- if (h >= 0 && B.current) {
4523
- const k = B.current.children[h];
4881
+ if (x >= 0 && A.current) {
4882
+ const k = A.current.children[x];
4524
4883
  k == null || k.scrollIntoView({ block: "nearest" });
4525
4884
  }
4526
- }, [h]);
4885
+ }, [x]);
4527
4886
  const _ = () => {
4528
- f(""), x([]), y(-1), p(!1), r("");
4529
- }, C = (k) => {
4530
- f(k), p(!isEmpty(k)), c(!0), w(k);
4887
+ f(""), b([]), y(-1), p(!1), r("");
4888
+ }, w = (k) => {
4889
+ f(k), p(!isEmpty(k)), c(!0), C(k);
4531
4890
  };
4532
4891
  return /* @__PURE__ */ jsxs("div", { children: [
4533
4892
  /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (k) => g(k.target.value), children: map(n, (k) => /* @__PURE__ */ jsx("option", { value: k.key, children: k.name }, k.key)) }),
@@ -4537,27 +4896,27 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4537
4896
  {
4538
4897
  type: "text",
4539
4898
  value: m,
4540
- onChange: (k) => C(k.target.value),
4541
- onKeyDown: A,
4542
- placeholder: a(`Search ${E ?? ""}`),
4899
+ onChange: (k) => w(k.target.value),
4900
+ onKeyDown: B,
4901
+ placeholder: a(`Search ${j ?? ""}`),
4543
4902
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4544
4903
  }
4545
4904
  ),
4546
4905
  /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: m && /* @__PURE__ */ jsx("button", { onClick: _, className: "text-gray-400 hover:text-gray-600", title: a("Clear search"), children: /* @__PURE__ */ jsx(X, { className: "h-4 w-4" }) }) })
4547
4906
  ] }),
4548
- (i || !isEmpty(b) || d && isEmpty(b)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4907
+ (i || !isEmpty(h) || d && isEmpty(h)) && /* @__PURE__ */ jsx("div", { className: "absolute z-40 mt-2 max-h-40 w-full max-w-[250px] overflow-y-auto rounded-md border border-border bg-background shadow-lg", children: i ? /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
4549
4908
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
4550
4909
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" })
4551
- ] }) : d && isEmpty(b) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4910
+ ] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4552
4911
  a("No results found for"),
4553
4912
  ' "',
4554
4913
  m,
4555
4914
  '"'
4556
- ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(b == null ? void 0 : b.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
4915
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
4557
4916
  "li",
4558
4917
  {
4559
4918
  onClick: () => S(k),
4560
- className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v === h ? "bg-gray-100" : "hover:bg-gray-100"}`,
4919
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(k.id) ? "bg-blue-200" : v === x ? "bg-gray-100" : "hover:bg-gray-100"}`,
4561
4920
  children: [
4562
4921
  k.name,
4563
4922
  " ",
@@ -4651,25 +5010,25 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4651
5010
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4652
5011
  }, [o, u]);
4653
5012
  const m = () => {
4654
- const x = findIndex(u, { _id: g });
4655
- if (x > -1) {
4656
- const h = (x + 1) % u.length, y = get(u, [h, "_id"]);
5013
+ const b = findIndex(u, { _id: g });
5014
+ if (b > -1) {
5015
+ const x = (b + 1) % u.length, y = get(u, [x, "_id"]);
4657
5016
  if (!y) return;
4658
5017
  n({ ...o, currentSlide: y }), c([y]);
4659
5018
  }
4660
5019
  }, f = () => {
4661
- const x = findIndex(u, { _id: g });
4662
- if (x > -1) {
4663
- const h = (x - 1 + u.length) % u.length, y = get(u, [h, "_id"]);
5020
+ const b = findIndex(u, { _id: g });
5021
+ if (b > -1) {
5022
+ const x = (b - 1 + u.length) % u.length, y = get(u, [x, "_id"]);
4664
5023
  if (!y) return;
4665
5024
  n({ ...o, currentSlide: y }), c([y]);
4666
5025
  }
4667
- }, b = () => {
4668
- const x = i(
5026
+ }, h = () => {
5027
+ const b = i(
4669
5028
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4670
5029
  p == null ? void 0 : p._id
4671
- ), h = x == null ? void 0 : x._id;
4672
- h && (n({ ...o, currentSlide: h }), c([h]));
5030
+ ), x = b == null ? void 0 : b._id;
5031
+ x && (n({ ...o, currentSlide: x }), c([x]));
4673
5032
  };
4674
5033
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
4675
5034
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
@@ -4686,7 +5045,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4686
5045
  /* @__PURE__ */ jsxs(
4687
5046
  "button",
4688
5047
  {
4689
- onClick: b,
5048
+ onClick: h,
4690
5049
  className: "flex w-full items-center justify-center gap-x-1 rounded bg-gray-200 p-1.5 text-xs font-medium leading-tight hover:opacity-80",
4691
5050
  children: [
4692
5051
  /* @__PURE__ */ jsx(PlusCircle, { className: "h-3 w-3 stroke-[2]" }),
@@ -4747,9 +5106,9 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4747
5106
  value: o == null ? void 0 : o.autoplayInterval,
4748
5107
  className: "text-xs",
4749
5108
  pattern: "[0-9]*",
4750
- onChange: (x) => {
4751
- let h = x.target.value;
4752
- h.length && (h = h.replace("-", "")), n({ ...o, autoplayInterval: h });
5109
+ onChange: (b) => {
5110
+ let x = b.target.value;
5111
+ x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
4753
5112
  }
4754
5113
  }
4755
5114
  )
@@ -4774,86 +5133,7 @@ const ImagePickerField = ({ value: o, onChange: n, id: r, onBlur: a }) => {
4774
5133
  ),
4775
5134
  /* @__PURE__ */ jsx(Button, { onClick: d, size: "sm", variant: "outline", className: "w-fit", children: r("Open code editor") })
4776
5135
  ] });
4777
- };
4778
- function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4779
- const [a, l] = React.useState(!1), [i, c] = React.useState([]), [d, p] = React.useState(o);
4780
- useEffect(() => {
4781
- a || c([]), p(o);
4782
- }, [a, o]);
4783
- const u = (b) => Array.isArray(b) ? "array" : typeof b == "object" && b !== null ? "object" : "value", g = React.useCallback(
4784
- (b) => {
4785
- const x = (h) => r === "value" ? h === "value" || h === "object" : r === "array" ? h === "array" : h === r;
4786
- b.type === "object" ? (c((h) => [...h, b.key]), p(b.value)) : x(b.type) && (n([...i, b.key].join(".")), l(!1));
4787
- },
4788
- [i, n, r]
4789
- ), m = React.useCallback(() => {
4790
- if (i.length > 0) {
4791
- const b = i.slice(0, -1);
4792
- c(b), p(b.reduce((x, h) => x[h], o));
4793
- }
4794
- }, [i, o]), f = React.useMemo(() => Object.entries(d).map(([b, x]) => ({
4795
- key: b,
4796
- value: x,
4797
- type: u(x)
4798
- })).filter((b) => r === "value" ? b.type === "value" || b.type === "object" : r === "array" ? b.type === "array" || b.type === "object" : r === "object" ? b.type === "object" : !0), [d, r]);
4799
- return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4800
- /* @__PURE__ */ jsxs(Tooltip, { children: [
4801
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
4802
- Button,
4803
- {
4804
- size: "sm",
4805
- variant: "outline",
4806
- className: "h-5 px-1 py-0 text-[9px] text-muted-foreground",
4807
- role: "combobox",
4808
- "aria-expanded": a,
4809
- children: /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3" })
4810
- }
4811
- ) }) }),
4812
- /* @__PURE__ */ jsx(TooltipContent, { children: "Add field" })
4813
- ] }),
4814
- /* @__PURE__ */ jsx(PopoverContent, { className: "mr-3 w-[300px] p-0", children: /* @__PURE__ */ jsxs(Command, { className: "fields-command", children: [
4815
- /* @__PURE__ */ jsx(CommandInput, { className: "border-none", placeholder: "Search..." }),
4816
- /* @__PURE__ */ jsxs(CommandList, { children: [
4817
- /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4818
- /* @__PURE__ */ jsxs(CommandGroup, { children: [
4819
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
4820
- /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4821
- "Back"
4822
- ] }),
4823
- f.map((b) => /* @__PURE__ */ jsxs(
4824
- CommandItem,
4825
- {
4826
- value: b.key,
4827
- disabled: !1,
4828
- onSelect: () => g(b),
4829
- className: "flex items-center justify-between",
4830
- children: [
4831
- /* @__PURE__ */ jsx("span", { children: b.key }),
4832
- /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
4833
- r === "object" && b.type === "object" && /* @__PURE__ */ jsx(
4834
- Button,
4835
- {
4836
- size: "sm",
4837
- variant: "ghost",
4838
- className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4839
- onClick: (x) => {
4840
- x.stopPropagation(), n([...i, b.key].join(".")), l(!1);
4841
- },
4842
- children: "Select"
4843
- }
4844
- ),
4845
- (b.type === "object" || b.type === "array") && /* @__PURE__ */ jsx("div", { className: "cursor-pointer rounded p-1 hover:bg-muted", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 opacity-50" }) })
4846
- ] })
4847
- ]
4848
- },
4849
- b.key
4850
- ))
4851
- ] })
4852
- ] })
4853
- ] }) })
4854
- ] });
4855
- }
4856
- const CustomFieldTemplate = ({
5136
+ }, CustomFieldTemplate = ({
4857
5137
  id: o,
4858
5138
  classNames: n,
4859
5139
  label: r,
@@ -4867,77 +5147,56 @@ const CustomFieldTemplate = ({
4867
5147
  formData: g,
4868
5148
  onChange: m
4869
5149
  }) => {
4870
- const { selectedLang: f, fallbackLang: b, languages: x } = useLanguages(), h = isEmpty(x) ? "" : isEmpty(f) ? b : f, y = get(LANGUAGES, h, h), B = usePageExternalData(), E = useSelectedBlock(), w = useRegisteredChaiBlocks(), S = get(w, [E == null ? void 0 : E._type, "i18nProps"], []) || [], [A, _] = useState(null), C = useCallback(
5150
+ const { selectedLang: f, fallbackLang: h, languages: b } = useLanguages(), x = isEmpty(b) ? "" : isEmpty(f) ? h : f, y = get(LANGUAGES, x, x), A = usePageExternalData(), j = useSelectedBlock(), C = useRegisteredChaiBlocks(), S = get(C, [j == null ? void 0 : j._type, "i18nProps"], []) || [], [B, _] = useState(null), w = useCallback(
4871
5151
  (v) => {
4872
- const N = (j) => /[.,!?;:]/.test(j), I = (j, R, D) => {
4873
- let L = "", $ = "";
4874
- const O = R > 0 ? j[R - 1] : "", H = R < j.length ? j[R] : "";
4875
- return R > 0 && (O === "." || !N(O) && O !== " ") && (L = " "), R < j.length && !N(H) && H !== " " && ($ = " "), {
4876
- text: L + D + $,
4877
- prefixLength: L.length,
4878
- suffixLength: $.length
5152
+ const N = (E) => /[.,!?;:]/.test(E), I = (E, D, M) => {
5153
+ let R = "", O = "";
5154
+ const $ = D > 0 ? E[D - 1] : "", H = D < E.length ? E[D] : "";
5155
+ return D > 0 && ($ === "." || !N($) && $ !== " ") && (R = " "), D < E.length && !N(H) && H !== " " && (O = " "), {
5156
+ text: R + M + O,
5157
+ prefixLength: R.length,
5158
+ suffixLength: O.length
4879
5159
  };
4880
- }, M = document.getElementById(o);
4881
- if (!M) return;
4882
- const P = document.getElementById(`quill.${o}`);
4883
- if (P && "__quill" in P) {
4884
- const j = P.__quill;
4885
- if (j) {
4886
- const R = `{{${v}}}`;
4887
- j.focus();
4888
- let D = j.getSelection();
4889
- if (D || (D = j.getSelection(!0)), D)
4890
- if (D.length > 0) {
4891
- const L = D.index;
4892
- j.deleteText(D.index, D.length), j.setSelection(L, 0);
4893
- const $ = j.getText(), {
4894
- text: O,
4895
- prefixLength: H,
4896
- suffixLength: V
4897
- } = I($, L, R);
4898
- j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
4899
- } else {
4900
- const L = D.index;
4901
- j.setSelection(L, 0);
4902
- const $ = j.getText(), {
4903
- text: O,
4904
- prefixLength: H,
4905
- suffixLength: V
4906
- } = I($, L, R);
4907
- j.insertText(L, O), j.setSelection(L + H + R.length + V, 0);
4908
- }
5160
+ }, L = document.getElementById(o);
5161
+ if (!L) return;
5162
+ const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5163
+ if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
5164
+ const E = P.__chaiRTE;
5165
+ if (E) {
5166
+ const D = `{{${v}}}`;
5167
+ E.commands.focus();
5168
+ const { from: M, to: R } = E.state.selection;
5169
+ if (M !== R)
5170
+ E.chain().deleteSelection().insertContent(D).run();
4909
5171
  else {
4910
- const L = j.getLength();
4911
- j.setSelection(L - 1, 0);
4912
- const $ = j.getText(), {
4913
- text: O,
4914
- prefixLength: H,
4915
- suffixLength: V
4916
- } = I($, L - 1, R);
4917
- j.insertText(L - 1, O), j.setSelection(L - 1 + H + R.length + V, 0);
5172
+ const { state: $ } = E, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5173
+ let z = "";
5174
+ H > 0 && F !== " " && !N(F) && (z = " ");
5175
+ let W = "";
5176
+ U && U !== " " && !N(U) && (W = " "), E.chain().insertContent(z + D + W).run();
4918
5177
  }
4919
- setTimeout(() => m(j.root.innerHTML, {}, o), 200);
5178
+ setTimeout(() => m(E.getHTML(), {}, o), 100);
4920
5179
  return;
4921
5180
  }
4922
5181
  } else {
4923
- const j = M, R = j.selectionStart || 0, D = j.value || "", L = j.selectionEnd || R;
4924
- if (L > R) {
4925
- const F = `{{${v}}}`, { text: z } = I(D, R, F), W = D.slice(0, R) + z + D.slice(L);
5182
+ const E = L, D = E.selectionStart || 0, M = E.value || "", R = E.selectionEnd || D;
5183
+ if (R > D) {
5184
+ const U = `{{${v}}}`, { text: z } = I(M, D, U), W = M.slice(0, D) + z + M.slice(R);
4926
5185
  m(W, {}, o);
4927
5186
  return;
4928
5187
  }
4929
- const O = `{{${v}}}`, { text: H } = I(D, R, O), V = D.slice(0, R) + H + D.slice(R);
4930
- m(V, {}, o);
5188
+ const $ = `{{${v}}}`, { text: H } = I(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5189
+ m(F, {}, o);
4931
5190
  }
4932
5191
  },
4933
- [o, m, g, E == null ? void 0 : E._id]
5192
+ [o, m, g, j == null ? void 0 : j._id]
4934
5193
  );
4935
5194
  if (d)
4936
5195
  return null;
4937
5196
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
4938
5197
  const k = S == null ? void 0 : S.includes(o.replace("root.", ""));
4939
5198
  if (u.type === "array") {
4940
- const v = A === o;
5199
+ const v = B === o;
4941
5200
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
4942
5201
  u.title && /* @__PURE__ */ jsxs(
4943
5202
  "label",
@@ -4973,7 +5232,7 @@ const CustomFieldTemplate = ({
4973
5232
  ] }),
4974
5233
  p && u.type !== "object" ? " *" : null
4975
5234
  ] }),
4976
- u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: C, dataType: "value" })
5235
+ u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
4977
5236
  ] }),
4978
5237
  c,
4979
5238
  a,
@@ -5041,35 +5300,35 @@ const CustomFieldTemplate = ({
5041
5300
  }), a;
5042
5301
  };
5043
5302
  function BlockSettings() {
5044
- const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), b = ({ formData: A }, _, C) => {
5045
- _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(A, _) }, C);
5046
- }, x = useCallback(
5047
- debounce(({ formData: A }, _, C) => {
5048
- b({ formData: A }, _, C), d(A);
5303
+ const { selectedLang: o } = useLanguages(), n = useSelectedBlock(), r = useUpdateBlocksPropsRealtime(), a = useUpdateBlocksProps(), l = getRegisteredChaiBlock(n == null ? void 0 : n._type), i = formDataWithSelectedLang(n, o, l), [c, d] = useState(i), [p, u] = useState(!1), g = useWrapperBlock(), m = getRegisteredChaiBlock(g == null ? void 0 : g._type), f = formDataWithSelectedLang(g, o, m), h = ({ formData: B }, _, w) => {
5304
+ _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(B, _) }, w);
5305
+ }, b = useCallback(
5306
+ debounce(({ formData: B }, _, w) => {
5307
+ h({ formData: B }, _, w), d(B);
5049
5308
  }, 1500),
5050
5309
  [n == null ? void 0 : n._id, o]
5051
- ), h = ({ formData: A }, _) => {
5052
- _ && (r([n._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5053
- }, y = ({ formData: A }, _) => {
5054
- _ && (r([g._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5310
+ ), x = ({ formData: B }, _) => {
5311
+ _ && (r([n._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
5312
+ }, y = ({ formData: B }, _) => {
5313
+ _ && (r([g._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
5055
5314
  };
5056
5315
  keys(get(i, "_bindings", {}));
5057
- const { schema: B, uiSchema: E } = useMemo(() => {
5058
- const A = n == null ? void 0 : n._type;
5059
- if (A)
5060
- return getBlockFormSchemas(A);
5061
- }, [n]), { wrapperSchema: w, wrapperUiSchema: S } = useMemo(() => {
5316
+ const { schema: A, uiSchema: j } = useMemo(() => {
5317
+ const B = n == null ? void 0 : n._type;
5318
+ if (B)
5319
+ return getBlockFormSchemas(B);
5320
+ }, [n]), { wrapperSchema: C, wrapperUiSchema: S } = useMemo(() => {
5062
5321
  if (!g || !(g != null && g._type))
5063
5322
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5064
- const A = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: C = {} } = getBlockFormSchemas(A);
5065
- return { wrapperSchema: _, wrapperUiSchema: C };
5323
+ const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
5324
+ return { wrapperSchema: _, wrapperUiSchema: w };
5066
5325
  }, [g]);
5067
5326
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
5068
5327
  !isEmpty(g) && /* @__PURE__ */ jsxs("div", { className: "mb-4 rounded border bg-zinc-100 px-1", children: [
5069
5328
  /* @__PURE__ */ jsxs(
5070
5329
  "div",
5071
5330
  {
5072
- onClick: () => u((A) => !A),
5331
+ onClick: () => u((B) => !B),
5073
5332
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5074
5333
  children: [
5075
5334
  p ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-4 w-4 stroke-[3] text-slate-400" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-4 w-4 stroke-[3] text-slate-400" }),
@@ -5090,19 +5349,19 @@ function BlockSettings() {
5090
5349
  blockId: g == null ? void 0 : g._id,
5091
5350
  onChange: y,
5092
5351
  formData: f,
5093
- schema: w,
5352
+ schema: C,
5094
5353
  uiSchema: S
5095
5354
  }
5096
5355
  ) })
5097
5356
  ] }),
5098
- isEmpty(B) ? null : /* @__PURE__ */ jsx(
5357
+ isEmpty(A) ? null : /* @__PURE__ */ jsx(
5099
5358
  JSONForm,
5100
5359
  {
5101
5360
  blockId: n == null ? void 0 : n._id,
5102
- onChange: h,
5361
+ onChange: x,
5103
5362
  formData: i,
5104
- schema: B,
5105
- uiSchema: E
5363
+ schema: A,
5364
+ uiSchema: j
5106
5365
  }
5107
5366
  ),
5108
5367
  (n == null ? void 0 : n._type) === "GlobalBlock" ? /* @__PURE__ */ jsx(GlobalBlockSettings, {}) : null
@@ -5193,32 +5452,32 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5193
5452
  ] }) }) })
5194
5453
  ] });
5195
5454
  }, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
5196
- const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (h) => {
5197
- p.includes(h) ? p.length > 2 && u(p.filter((y) => y !== h)) : u((y) => [...y, h]);
5198
- }, b = (h) => {
5199
- n || a(h), i(h);
5200
- }, x = getBreakpointValue(n ? l : r).toLowerCase();
5201
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (h) => /* @__PURE__ */ createElement(
5455
+ const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (x) => {
5456
+ p.includes(x) ? p.length > 2 && u(p.filter((y) => y !== x)) : u((y) => [...y, x]);
5457
+ }, h = (x) => {
5458
+ n || a(x), i(x);
5459
+ }, b = getBreakpointValue(n ? l : r).toLowerCase();
5460
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (x) => /* @__PURE__ */ createElement(
5202
5461
  BreakpointCard,
5203
5462
  {
5204
5463
  canvas: n,
5205
- ...h,
5206
- onClick: b,
5207
- key: h.breakpoint,
5208
- currentBreakpoint: x
5464
+ ...x,
5465
+ onClick: h,
5466
+ key: x.breakpoint,
5467
+ currentBreakpoint: b
5209
5468
  }
5210
5469
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5211
5470
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5212
- m.filter((h) => includes(p, toUpper(h.breakpoint))),
5213
- (h) => /* @__PURE__ */ createElement(
5471
+ m.filter((x) => includes(p, toUpper(x.breakpoint))),
5472
+ (x) => /* @__PURE__ */ createElement(
5214
5473
  BreakpointCard,
5215
5474
  {
5216
5475
  canvas: n,
5217
5476
  openDelay: o,
5218
- ...h,
5219
- onClick: b,
5220
- key: h.breakpoint,
5221
- currentBreakpoint: x
5477
+ ...x,
5478
+ onClick: h,
5479
+ key: x.breakpoint,
5480
+ currentBreakpoint: b
5222
5481
  }
5223
5482
  )
5224
5483
  ) }),
@@ -5227,15 +5486,15 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5227
5486
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5228
5487
  /* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
5229
5488
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5230
- map(m, (h) => /* @__PURE__ */ jsx(
5489
+ map(m, (x) => /* @__PURE__ */ jsx(
5231
5490
  DropdownMenuCheckboxItem,
5232
5491
  {
5233
- disabled: h.breakpoint === "xs",
5234
- onCheckedChange: () => f(toUpper(h.breakpoint)),
5235
- checked: includes(p, toUpper(h.breakpoint)),
5236
- children: g(h.title)
5492
+ disabled: x.breakpoint === "xs",
5493
+ onCheckedChange: () => f(toUpper(x.breakpoint)),
5494
+ checked: includes(p, toUpper(x.breakpoint)),
5495
+ children: g(x.title)
5237
5496
  },
5238
- h.breakpoint
5497
+ x.breakpoint
5239
5498
  ))
5240
5499
  ] })
5241
5500
  ] })
@@ -5324,8 +5583,8 @@ const AskAIStyles = ({ blockId: o }) => {
5324
5583
  (f = d.current) == null || f.focus();
5325
5584
  }, []);
5326
5585
  const m = (f) => {
5327
- const { usage: b } = f || {};
5328
- !l && b && g(b), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5586
+ const { usage: h } = f || {};
5587
+ !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5329
5588
  };
5330
5589
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
5331
5590
  /* @__PURE__ */ jsx("h2", { className: "mb-1 text-sm font-semibold leading-none tracking-tight", children: n("Ask AI") }),
@@ -5380,25 +5639,25 @@ const AskAIStyles = ({ blockId: o }) => {
5380
5639
  ] });
5381
5640
  };
5382
5641
  function ManualClasses() {
5383
- var M;
5384
- const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [b, x] = useState(""), { toast: h } = useToast(), y = (M = first(d)) == null ? void 0 : M.prop, { classes: B } = getSplitChaiClasses(get(p, y, "")), E = B.split(" ").filter((P) => !isEmpty(P)), w = () => {
5385
- const P = b.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5386
- u(m, P, !0), x("");
5387
- }, [S, A] = useState([]), _ = ({ value: P }) => {
5388
- const j = P.trim().toLowerCase(), R = j.match(/.+:/g);
5642
+ var I;
5643
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [m] = useSelectedBlockIds(), f = useBuilderProp("askAiCallBack", null), [h, b] = useState(""), x = (I = first(d)) == null ? void 0 : I.prop, { classes: y } = getSplitChaiClasses(get(p, x, "")), A = y.split(" ").filter((L) => !isEmpty(L)), j = () => {
5644
+ const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5645
+ u(m, L, !0), b("");
5646
+ }, [C, S] = useState([]), B = ({ value: L }) => {
5647
+ const P = L.trim().toLowerCase(), E = P.match(/.+:/g);
5389
5648
  let D = [];
5390
- if (R && R.length > 0) {
5391
- const [L] = R, $ = j.replace(L, "");
5392
- D = i.search($).map((H) => ({
5393
- ...H,
5394
- item: { ...H.item, name: L + H.item.name }
5649
+ if (E && E.length > 0) {
5650
+ const [M] = E, R = P.replace(M, "");
5651
+ D = i.search(R).map(($) => ({
5652
+ ...$,
5653
+ item: { ...$.item, name: M + $.item.name }
5395
5654
  }));
5396
5655
  } else
5397
- D = i.search(j);
5398
- return A(map(D, "item"));
5399
- }, C = () => {
5400
- A([]);
5401
- }, T = (P) => P.name, k = (P) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: P.name }), v = useMemo(
5656
+ D = i.search(P);
5657
+ return S(map(D, "item"));
5658
+ }, _ = () => {
5659
+ S([]);
5660
+ }, w = (L) => L.name, T = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), k = useMemo(
5402
5661
  () => ({
5403
5662
  ref: o,
5404
5663
  autoComplete: "off",
@@ -5406,38 +5665,31 @@ function ManualClasses() {
5406
5665
  autoCapitalize: "off",
5407
5666
  spellCheck: !1,
5408
5667
  placeholder: c("Enter classes separated by space"),
5409
- value: b,
5410
- onKeyDown: (P) => {
5411
- P.key === "Enter" && b.trim() !== "" && w();
5668
+ value: h,
5669
+ onKeyDown: (L) => {
5670
+ L.key === "Enter" && h.trim() !== "" && j();
5412
5671
  },
5413
- onChange: (P, { newValue: j }) => x(j),
5672
+ onChange: (L, { newValue: P }) => b(P),
5414
5673
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5415
5674
  }),
5416
- [b, c, o]
5417
- ), N = (P) => {
5675
+ [h, c, o]
5676
+ ), v = (L) => {
5418
5677
  debugger;
5419
- const j = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5420
- g(m, [P]), u(m, j, !0), r(""), l(-1);
5421
- }, I = () => {
5678
+ const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5679
+ g(m, [L]), u(m, P, !0), r(""), l(-1);
5680
+ }, N = () => {
5422
5681
  if (navigator.clipboard === void 0) {
5423
- h({
5424
- title: c("Clipboard not supported"),
5425
- description: c("Please use Chrome, Firefox or Safari"),
5426
- variant: "destructive"
5427
- });
5682
+ toast.error(c("Clipboard not supported"));
5428
5683
  return;
5429
5684
  }
5430
- navigator.clipboard.writeText(E.join(" ")), h({
5431
- title: c("Copied"),
5432
- description: c("Classes copied to clipboard")
5433
- });
5685
+ navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
5434
5686
  };
5435
5687
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5436
5688
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5437
5689
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5438
5690
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5439
5691
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5440
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: I, className: "cursor-pointer" }) }),
5692
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: N, className: "cursor-pointer" }) }),
5441
5693
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5442
5694
  ] })
5443
5695
  ] }),
@@ -5453,12 +5705,12 @@ function ManualClasses() {
5453
5705
  /* @__PURE__ */ jsx("div", { className: "relative flex w-full items-center gap-x-3", children: /* @__PURE__ */ jsx(
5454
5706
  Autosuggest,
5455
5707
  {
5456
- suggestions: S,
5457
- onSuggestionsFetchRequested: _,
5458
- onSuggestionsClearRequested: C,
5459
- getSuggestionValue: T,
5460
- renderSuggestion: k,
5461
- inputProps: v,
5708
+ suggestions: C,
5709
+ onSuggestionsFetchRequested: B,
5710
+ onSuggestionsClearRequested: _,
5711
+ getSuggestionValue: w,
5712
+ renderSuggestion: T,
5713
+ inputProps: k,
5462
5714
  containerProps: {
5463
5715
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
5464
5716
  },
@@ -5474,45 +5726,45 @@ function ManualClasses() {
5474
5726
  {
5475
5727
  variant: "outline",
5476
5728
  className: "h-6 border-border",
5477
- onClick: w,
5478
- disabled: b.trim() === "",
5729
+ onClick: j,
5730
+ disabled: h.trim() === "",
5479
5731
  size: "sm",
5480
5732
  children: /* @__PURE__ */ jsx(PlusIcon, {})
5481
5733
  }
5482
5734
  )
5483
5735
  ] }),
5484
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: E.map(
5485
- (P, j) => a === j ? /* @__PURE__ */ jsx(
5736
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5737
+ (L, P) => a === P ? /* @__PURE__ */ jsx(
5486
5738
  "input",
5487
5739
  {
5488
5740
  ref: o,
5489
5741
  value: n,
5490
- onChange: (R) => r(R.target.value),
5742
+ onChange: (E) => r(E.target.value),
5491
5743
  onBlur: () => {
5492
- N(P);
5744
+ v(L);
5493
5745
  },
5494
- onKeyDown: (R) => {
5495
- R.key === "Enter" && N(P);
5746
+ onKeyDown: (E) => {
5747
+ E.key === "Enter" && v(L);
5496
5748
  },
5497
5749
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300"
5498
5750
  },
5499
- P
5751
+ L
5500
5752
  ) : /* @__PURE__ */ jsxs(
5501
5753
  "button",
5502
5754
  {
5503
5755
  className: "group relative flex max-w-[260px] cursor-default items-center gap-x-1 truncate break-words rounded border border-border bg-gray-200 p-px px-1.5 pr-2 text-[11px] text-gray-600 hover:border-gray-300 dark:border-gray-700 dark:bg-gray-800 dark:text-gray-300",
5504
5756
  children: [
5505
- P,
5506
- n !== P && /* @__PURE__ */ jsx(
5757
+ L,
5758
+ n !== L && /* @__PURE__ */ jsx(
5507
5759
  Cross2Icon,
5508
5760
  {
5509
- onClick: () => g(m, [P], !0),
5761
+ onClick: () => g(m, [L], !0),
5510
5762
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5511
5763
  }
5512
5764
  )
5513
5765
  ]
5514
5766
  },
5515
- P
5767
+ L
5516
5768
  )
5517
5769
  ) })
5518
5770
  ] });
@@ -5854,8 +6106,8 @@ const COLOR_PROP = {
5854
6106
  }, ColorChoice = ({ property: o, onChange: n }) => {
5855
6107
  const r = useCurrentClassByProperty(o), a = useMemo(() => get(r, "cls", ""), [r]), { canChange: l } = useContext(StyleContext), [i, c] = useState([]), [d, p] = useState({ color: "", shade: "" }), u = a.split("-"), g = get(u, "1", ""), m = get(u, "2", ""), f = useCallback(
5856
6108
  // eslint-disable-next-line no-shadow
5857
- (h) => {
5858
- ["current", "inherit", "transparent", "black", "white"].includes(h) ? (c([]), p({ color: h })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: h, shade: y.shade ? y.shade : "500" })));
6109
+ (x) => {
6110
+ ["current", "inherit", "transparent", "black", "white"].includes(x) ? (c([]), p({ color: x })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: x, shade: y.shade ? y.shade : "500" })));
5859
6111
  },
5860
6112
  [c, p]
5861
6113
  );
@@ -5864,21 +6116,21 @@ const COLOR_PROP = {
5864
6116
  return c([]);
5865
6117
  c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]);
5866
6118
  }, [g]);
5867
- const b = useCallback(
6119
+ const h = useCallback(
5868
6120
  // eslint-disable-next-line no-shadow
5869
- (h) => {
5870
- p({ color: g, shade: h });
6121
+ (x) => {
6122
+ p({ color: g, shade: x });
5871
6123
  },
5872
6124
  [g]
5873
6125
  );
5874
6126
  useEffect(() => {
5875
6127
  p({ color: "", shade: "" });
5876
6128
  }, [r]);
5877
- const { match: x } = useTailwindClassList();
6129
+ const { match: b } = useTailwindClassList();
5878
6130
  return useEffect(() => {
5879
6131
  const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
5880
- x(o, y) && n(y, o);
5881
- }, [x, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
6132
+ b(o, y) && n(y, o);
6133
+ }, [b, d, n, o]), /* @__PURE__ */ jsxs("div", { className: "flex flex-row divide-x divide-solid divide-border rounded-lg border border-transparent text-xs", children: [
5882
6134
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
5883
6135
  DropDown,
5884
6136
  {
@@ -5918,7 +6170,7 @@ const COLOR_PROP = {
5918
6170
  ]
5919
6171
  }
5920
6172
  ) }),
5921
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: b, options: i }) })
6173
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: h, options: i }) })
5922
6174
  ] });
5923
6175
  }, IconChoices = ({ property: o, onChange: n }) => {
5924
6176
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
@@ -6115,7 +6367,7 @@ const COLOR_PROP = {
6115
6367
  },
6116
6368
  a
6117
6369
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6118
- const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [b, x] = useState(!1), [h, y] = useState(""), [B, E] = useState(!1), [w, S] = useState(!1);
6370
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [m, f] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, b] = useState(!1), [x, y] = useState(""), [A, j] = useState(!1), [C, S] = useState(!1);
6119
6371
  useEffect(() => {
6120
6372
  const { value: k, unit: v } = getClassValueAndUnit(i);
6121
6373
  if (v === "") {
@@ -6124,41 +6376,41 @@ const COLOR_PROP = {
6124
6376
  }
6125
6377
  f(v), l(v === "class" || isEmpty(k) ? "" : k);
6126
6378
  }, [i, p, u]);
6127
- const A = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), C = useCallback(
6379
+ const B = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), w = useCallback(
6128
6380
  (k = !1) => {
6129
6381
  const v = getUserInputValues(`${a}`, u);
6130
6382
  if (get(v, "error", !1)) {
6131
- x(!0);
6383
+ b(!0);
6132
6384
  return;
6133
6385
  }
6134
6386
  const N = get(v, "unit") !== "" ? get(v, "unit") : m;
6135
6387
  if (N === "auto" || N === "none") {
6136
- A(`${d}${N}`);
6388
+ B(`${d}${N}`);
6137
6389
  return;
6138
6390
  }
6139
6391
  if (get(v, "value") === "")
6140
6392
  return;
6141
- const M = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6142
- k ? _(M) : A(M);
6393
+ const L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6394
+ k ? _(L) : B(L);
6143
6395
  },
6144
- [A, _, a, m, d, u]
6396
+ [B, _, a, m, d, u]
6145
6397
  ), T = useCallback(
6146
6398
  (k) => {
6147
6399
  const v = getUserInputValues(`${a}`, u);
6148
6400
  if (get(v, "error", !1)) {
6149
- x(!0);
6401
+ b(!0);
6150
6402
  return;
6151
6403
  }
6152
6404
  if (k === "auto" || k === "none") {
6153
- A(`${d}${k}`);
6405
+ B(`${d}${k}`);
6154
6406
  return;
6155
6407
  }
6156
6408
  if (get(v, "value") === "")
6157
6409
  return;
6158
- const N = get(v, "unit") !== "" ? get(v, "unit") : k, M = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6159
- A(M);
6410
+ const N = get(v, "unit") !== "" ? get(v, "unit") : k, L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6411
+ B(L);
6160
6412
  },
6161
- [A, a, d, u]
6413
+ [B, a, d, u]
6162
6414
  );
6163
6415
  return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: m === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6164
6416
  /* @__PURE__ */ jsx(
@@ -6173,14 +6425,14 @@ const COLOR_PROP = {
6173
6425
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("button", { type: "button", className: "invisible ml-3 mt-1 text-blue-600 group-hover:visible", children: /* @__PURE__ */ jsx(InfoCircledIcon, {}) }) }),
6174
6426
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6175
6427
  ] })
6176
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
6428
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6177
6429
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6178
6430
  ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6179
6431
  "input",
6180
6432
  {
6181
6433
  readOnly: m === "class",
6182
6434
  onKeyPress: (k) => {
6183
- k.key === "Enter" && C();
6435
+ k.key === "Enter" && w();
6184
6436
  },
6185
6437
  onKeyDown: (k) => {
6186
6438
  if (k.keyCode !== 38 && k.keyCode !== 40)
@@ -6193,20 +6445,20 @@ const COLOR_PROP = {
6193
6445
  _(P);
6194
6446
  },
6195
6447
  onKeyUp: (k) => {
6196
- w && (k.preventDefault(), S(!1));
6448
+ C && (k.preventDefault(), S(!1));
6197
6449
  },
6198
- onBlur: () => C(),
6450
+ onBlur: () => w(),
6199
6451
  onChange: (k) => {
6200
- x(!1), l(k.target.value);
6452
+ b(!1), l(k.target.value);
6201
6453
  },
6202
6454
  onClick: (k) => {
6203
6455
  var v;
6204
6456
  (v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
6205
6457
  },
6206
- value: B ? h : a,
6458
+ value: A ? x : a,
6207
6459
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6208
6460
  " ",
6209
- b ? "border-red-500 text-red-500" : "border-foreground/20"
6461
+ h ? "border-red-500 text-red-500" : "border-foreground/20"
6210
6462
  )
6211
6463
  }
6212
6464
  ),
@@ -6235,15 +6487,15 @@ const COLOR_PROP = {
6235
6487
  ) }) })
6236
6488
  ] })
6237
6489
  ] }),
6238
- ["none", "auto"].indexOf(m) !== -1 || B ? null : /* @__PURE__ */ jsx(
6490
+ ["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
6239
6491
  DragStyleButton,
6240
6492
  {
6241
- onDragStart: () => E(!0),
6493
+ onDragStart: () => j(!0),
6242
6494
  onDragEnd: (k) => {
6243
- if (y(() => ""), E(!1), isEmpty(k))
6495
+ if (y(() => ""), j(!1), isEmpty(k))
6244
6496
  return;
6245
6497
  const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
6246
- A(I);
6498
+ B(I);
6247
6499
  },
6248
6500
  onDrag: (k) => {
6249
6501
  if (isEmpty(k))
@@ -6347,23 +6599,23 @@ const COLOR_PROP = {
6347
6599
  "2xl": "1536px"
6348
6600
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6349
6601
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6350
- }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), b = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), h = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6351
- (_, C = !0) => {
6602
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), m = useCurrentClassByProperty(l), f = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [b] = useSelectedBlockIds(), x = useMemo(() => get(m, "fullCls", ""), [m]), y = useCallback(
6603
+ (_, w = !0) => {
6352
6604
  const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
6353
6605
  (p || u !== "") && (T.mq = "xs");
6354
6606
  const k = generateFullClsName(T);
6355
- f(x, [k], C);
6607
+ f(b, [k], w);
6356
6608
  },
6357
- [x, p, g, u, l, f]
6358
- ), B = useCallback(() => {
6359
- b(x, [h], !0);
6360
- }, [x, h, b]), E = useMemo(() => canChangeClass(m, g), [m, g]);
6609
+ [b, p, g, u, l, f]
6610
+ ), A = useCallback(() => {
6611
+ h(b, [x], !0);
6612
+ }, [b, x, h]), j = useMemo(() => canChangeClass(m, g), [m, g]);
6361
6613
  useEffect(() => {
6362
- i(E, m);
6363
- }, [E, i, m]);
6364
- const [, , w] = useScreenSizeWidth(), S = useCallback(
6614
+ i(j, m);
6615
+ }, [j, i, m]);
6616
+ const [, , C] = useScreenSizeWidth(), S = useCallback(
6365
6617
  (_) => {
6366
- w({
6618
+ C({
6367
6619
  xs: 400,
6368
6620
  sm: 640,
6369
6621
  md: 800,
@@ -6372,10 +6624,10 @@ const COLOR_PROP = {
6372
6624
  "2xl": 1920
6373
6625
  }[_]);
6374
6626
  },
6375
- [w]
6376
- ), A = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6377
- return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: E, canReset: m && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6378
- /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !A ? "text-foreground" : ""}`, children: n(a) }) }),
6627
+ [C]
6628
+ ), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6629
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: j, canReset: m && B, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6630
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${m && !B ? "text-foreground" : ""}`, children: n(a) }) }),
6379
6631
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6380
6632
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6381
6633
  r === "arbitrary" ? /* @__PURE__ */ jsx(
@@ -6394,7 +6646,7 @@ const COLOR_PROP = {
6394
6646
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6395
6647
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6396
6648
  ] }),
6397
- /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${h ? "visible" : "invisible"}`, children: A ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => B(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : E && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6649
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${x ? "visible" : "invisible"}`, children: B ? /* @__PURE__ */ jsx("button", { type: "button", onClick: () => A(), title: "Reset", className: "flex px-1.5 text-xs", children: /* @__PURE__ */ jsx(CrossCircledIcon, { className: "h-5 w-5 text-blue-500 hover:opacity-80" }) }) : j && m ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6398
6650
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6399
6651
  "button",
6400
6652
  {
@@ -6444,18 +6696,18 @@ const COLOR_PROP = {
6444
6696
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6445
6697
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6446
6698
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6447
- n.map(({ label: f, key: b }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6699
+ n.map(({ label: f, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6448
6700
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6449
6701
  "button",
6450
6702
  {
6451
6703
  type: "button",
6452
- onClick: () => u(b),
6453
- className: `relative cursor-pointer rounded-full p-1 text-[8px] ${b === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6704
+ onClick: () => u(h),
6705
+ className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6454
6706
  children: [
6455
6707
  React__default.createElement("div", {
6456
- className: m(b) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6708
+ className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6457
6709
  }),
6458
- React__default.createElement(get(EDITOR_ICONS, b, BoxIcon), { className: "text-inherit w-3 h-3" })
6710
+ React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
6459
6711
  ]
6460
6712
  }
6461
6713
  ) }),
@@ -6601,10 +6853,10 @@ function BlockStyling() {
6601
6853
  const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6602
6854
  let f = parseFloat(i.dragStartValue);
6603
6855
  f = isNaN(f) ? 0 : f;
6604
- let b = MAPPER[i.dragUnit];
6605
- (startsWith(m, "scale") || m === "opacity") && (b = 10);
6606
- let h = (i.dragStartY - u.pageY) / b + f;
6607
- g && h < 0 && (h = 0), m === "opacity" && h > 1 && (h = 1), i.onDrag(`${h}`), l(`${h}`);
6856
+ let h = MAPPER[i.dragUnit];
6857
+ (startsWith(m, "scale") || m === "opacity") && (h = 10);
6858
+ let x = (i.dragStartY - u.pageY) / h + f;
6859
+ g && x < 0 && (x = 0), m === "opacity" && x > 1 && (x = 1), i.onDrag(`${x}`), l(`${x}`);
6608
6860
  },
6609
6861
  [i],
6610
6862
  50
@@ -6648,12 +6900,12 @@ const CoreBlock = ({
6648
6900
  }) => {
6649
6901
  const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
6650
6902
  if (has(o, "blocks")) {
6651
- const h = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6652
- u(syncBlocksWithDefaults(h), r || null, a);
6903
+ const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6904
+ u(syncBlocksWithDefaults(x), r || null, a);
6653
6905
  } else
6654
6906
  p(o, r || null, a);
6655
6907
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6656
- }, b = useFeature("dnd"), { t: x } = useTranslation();
6908
+ }, h = useFeature("dnd"), { t: b } = useTranslation();
6657
6909
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6658
6910
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6659
6911
  "button",
@@ -6661,20 +6913,20 @@ const CoreBlock = ({
6661
6913
  disabled: n,
6662
6914
  onClick: f,
6663
6915
  type: "button",
6664
- onDragStart: (h) => {
6665
- h.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), h.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6916
+ onDragStart: (x) => {
6917
+ x.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), x.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6666
6918
  g([]), m();
6667
6919
  }, 200);
6668
6920
  },
6669
- draggable: b ? "true" : "false",
6921
+ draggable: h ? "true" : "false",
6670
6922
  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",
6671
6923
  children: [
6672
6924
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6673
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6925
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(b(d || i)) })
6674
6926
  ]
6675
6927
  }
6676
6928
  ) }),
6677
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6929
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: b(d || i) }) })
6678
6930
  ] }) });
6679
6931
  }, DefaultChaiBlocks = ({
6680
6932
  parentId: o,
@@ -6859,22 +7111,22 @@ const CoreBlock = ({
6859
7111
  }
6860
7112
  }
6861
7113
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
6862
- var m, f, b, x, h, y, B, E;
7114
+ var m, f, h, b, x, y, A, j;
6863
7115
  if (r.type === "comment") return [];
6864
7116
  console.log("node ===>", r);
6865
7117
  let a = { _id: generateUUID() };
6866
7118
  if (n && (a._parent = n.block._id), r.type === "text")
6867
7119
  return isEmpty(get(r, "content", "")) ? [] : n && shouldAddText(n.node, n.block) ? (set(n, "block.content", get(r, "content", "")), []) : { ...a, _type: "Text", content: get(r, "content", "") };
6868
7120
  const l = get(r, "attributes", []), i = l.find(
6869
- (w) => w.key === "data-chai-richtext" || w.key === "chai-richtext"
7121
+ (C) => C.key === "data-chai-richtext" || C.key === "chai-richtext"
6870
7122
  ), c = l.find(
6871
- (w) => w.key === "data-chai-lightbox" || w.key === "chai-lightbox"
7123
+ (C) => C.key === "data-chai-lightbox" || C.key === "chai-lightbox"
6872
7124
  ), d = l.find(
6873
- (w) => w.key === "data-chai-dropdown" || w.key === "chai-dropdown"
7125
+ (C) => C.key === "data-chai-dropdown" || C.key === "chai-dropdown"
6874
7126
  ), p = l.find(
6875
- (w) => w.key === "data-chai-dropdown-button" || w.key === "chai-dropdown-button"
7127
+ (C) => C.key === "data-chai-dropdown-button" || C.key === "chai-dropdown-button"
6876
7128
  ), u = l.find(
6877
- (w) => w.key === "data-chai-dropdown-content" || w.key === "chai-dropdown-content"
7129
+ (C) => C.key === "data-chai-dropdown-content" || C.key === "chai-dropdown-content"
6878
7130
  );
6879
7131
  if (a = {
6880
7132
  ...a,
@@ -6882,13 +7134,13 @@ const CoreBlock = ({
6882
7134
  ...getAttrs(r),
6883
7135
  ...getStyles(r)
6884
7136
  }, r.attributes) {
6885
- const w = r.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
6886
- w && (a._name = w.value);
7137
+ const C = r.attributes.find((S) => includes(NAME_ATTRIBUTES, S.key));
7138
+ C && (a._name = C.value);
6887
7139
  }
6888
7140
  if (i)
6889
7141
  return a.content = stringify(r.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];
6890
7142
  if (c) {
6891
- const w = [
7143
+ const C = [
6892
7144
  "data-chai-lightbox",
6893
7145
  "chai-lightbox",
6894
7146
  "data-vbtype",
@@ -6902,42 +7154,42 @@ const CoreBlock = ({
6902
7154
  ...a,
6903
7155
  href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
6904
7156
  hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
6905
- autoplay: ((b = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : b.value) === "true" ? "true" : "false",
6906
- maxWidth: ((h = (x = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : h.replace("px", "")) || "",
7157
+ autoplay: ((h = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
7158
+ maxWidth: ((x = (b = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : b.value) == null ? void 0 : x.replace("px", "")) || "",
6907
7159
  backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
6908
- galleryName: ((B = l.find((S) => S.key === "data-gall")) == null ? void 0 : B.value) || ""
6909
- }, forEach(w, (S) => {
7160
+ galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
7161
+ }, forEach(C, (S) => {
6910
7162
  has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
6911
7163
  });
6912
7164
  }
6913
7165
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
6914
7166
  delete a.styles_attrs;
6915
- const w = filter(r.children || [], (A) => (A == null ? void 0 : A.tagName) !== "span");
6916
- a.content = getTextContent(w);
7167
+ const C = filter(r.children || [], (B) => (B == null ? void 0 : B.tagName) !== "span");
7168
+ a.content = getTextContent(C);
6917
7169
  const S = find(
6918
7170
  r.children || [],
6919
- (A) => (A == null ? void 0 : A.tagName) === "span" && some(A.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
7171
+ (B) => (B == null ? void 0 : B.tagName) === "span" && some(B.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
6920
7172
  );
6921
7173
  if (S) {
6922
- const A = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
6923
- if (A) {
6924
- a.icon = stringify([A]);
6925
- const { height: _, width: C } = getSvgDimensions(A, "16px", "16px");
6926
- a.iconHeight = _, a.iconWidth = C;
7174
+ const B = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
7175
+ if (B) {
7176
+ a.icon = stringify([B]);
7177
+ const { height: _, width: w } = getSvgDimensions(B, "16px", "16px");
7178
+ a.iconHeight = _, a.iconWidth = w;
6927
7179
  }
6928
7180
  }
6929
7181
  return [a];
6930
7182
  }
6931
7183
  if (a._type === "Input") {
6932
- const w = a.inputType || "text";
6933
- w === "checkbox" ? set(a, "_type", "Checkbox") : w === "radio" && set(a, "_type", "Radio");
7184
+ const C = a.inputType || "text";
7185
+ C === "checkbox" ? set(a, "_type", "Checkbox") : C === "radio" && set(a, "_type", "Radio");
6934
7186
  } else if (r.tagName === "video" || r.tagName === "iframe") {
6935
- const w = stringify([r]);
6936
- return hasVideoEmbed(w) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(w)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = w, [a];
7187
+ const C = stringify([r]);
7188
+ return hasVideoEmbed(C) && (set(a, "_type", "Video"), set(a, "url", getVideoURLFromHTML(C)), set(a, "styles", `${STYLES_KEY},`), set(a, "controls", { autoPlay: !1, muted: !0, loop: !1, controls: !1 })), a.content = C, [a];
6937
7189
  } else if (r.tagName === "svg") {
6938
- const w = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), A = get(w, "value") ? `[${get(w, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", C = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
6939
- return a.styles = `${STYLES_KEY}, ${cn(`w-${_} h-${A}`, C)}`.trim(), r.attributes = filter(r.attributes, (T) => !includes(["style", "width", "height", "class"], T.key)), a.icon = stringify([r]), [a];
6940
- } else if (r.tagName == "option" && n && ((E = n.block) == null ? void 0 : E._type) === "Select")
7190
+ const C = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), B = get(C, "value") ? `[${get(C, "value")}px]` : "24px", _ = get(S, "value") ? `[${get(S, "value")}px]` : "24px", w = get(find(r.attributes, { key: "class" }), "value", "w-full h-full");
7191
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${_} h-${B}`, w)}`.trim(), r.attributes = filter(r.attributes, (T) => !includes(["style", "width", "height", "class"], T.key)), a.icon = stringify([r]), [a];
7192
+ } else if (r.tagName == "option" && n && ((j = n.block) == null ? void 0 : j._type) === "Select")
6941
7193
  return n.block.options.push({
6942
7194
  label: getTextContent(r.children),
6943
7195
  ...getAttrs(r)
@@ -6986,21 +7238,21 @@ const CoreBlock = ({
6986
7238
  /* @__PURE__ */ jsx(CardFooter, { className: "flex flex-col justify-end p-3", children: /* @__PURE__ */ jsx(Button, { disabled: a.trim() === "", onClick: () => c(), size: "sm", className: "w-fit", children: r("Import HTML") }) })
6987
7239
  ] });
6988
7240
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
6989
- var x;
6990
- const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (x = find(c, (h) => h._id === r)) == null ? void 0 : x._type;
7241
+ var b;
7242
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), m = (b = find(c, (x) => x._id === r)) == null ? void 0 : b._type;
6991
7243
  useEffect(() => {
6992
- const h = setTimeout(() => {
7244
+ const x = setTimeout(() => {
6993
7245
  var y;
6994
7246
  (y = u.current) == null || y.focus();
6995
7247
  }, 0);
6996
- return () => clearTimeout(h);
7248
+ return () => clearTimeout(x);
6997
7249
  }, [g]);
6998
7250
  const f = d ? values(n).filter(
6999
- (h) => {
7000
- var y, B;
7001
- return (((y = h.label) == null ? void 0 : y.toLowerCase()) + " " + ((B = h.type) == null ? void 0 : B.toLowerCase())).includes(d.toLowerCase());
7251
+ (x) => {
7252
+ var y, A;
7253
+ return (((y = x.label) == null ? void 0 : y.toLowerCase()) + " " + ((A = x.type) == null ? void 0 : A.toLowerCase())).includes(d.toLowerCase());
7002
7254
  }
7003
- ) : n, b = d ? o.filter((h) => reject(filter(values(f), { group: h }), { hidden: !0 }).length > 0) : o.filter((h) => reject(filter(values(n), { group: h }), { hidden: !0 }).length > 0);
7255
+ ) : n, h = d ? o.filter((x) => reject(filter(values(f), { group: x }), { hidden: !0 }).length > 0) : o.filter((x) => reject(filter(values(n), { group: x }), { hidden: !0 }).length > 0);
7004
7256
  return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
7005
7257
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7006
7258
  Input$1,
@@ -7009,21 +7261,21 @@ const CoreBlock = ({
7009
7261
  type: "search",
7010
7262
  placeholder: i("Search blocks..."),
7011
7263
  value: d,
7012
- onChange: (h) => p(h.target.value)
7264
+ onChange: (x) => p(x.target.value)
7013
7265
  }
7014
7266
  ) }),
7015
- /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: b.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7267
+ /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: h.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7016
7268
  i("No blocks found matching"),
7017
7269
  ' "',
7018
7270
  d,
7019
7271
  '"'
7020
7272
  ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
7021
- b,
7022
- (h) => CORE_GROUPS.indexOf(h) === -1 ? 99 : CORE_GROUPS.indexOf(h)
7023
- ).map((h) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7024
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(h.toLowerCase())) }),
7273
+ h,
7274
+ (x) => CORE_GROUPS.indexOf(x) === -1 ? 99 : CORE_GROUPS.indexOf(x)
7275
+ ).map((x) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7276
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(x.toLowerCase())) }),
7025
7277
  /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7026
- reject(filter(values(f), { group: h }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
7278
+ reject(filter(values(f), { group: x }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
7027
7279
  CoreBlock,
7028
7280
  {
7029
7281
  parentId: r,
@@ -7034,7 +7286,7 @@ const CoreBlock = ({
7034
7286
  y.type
7035
7287
  ))
7036
7288
  ) })
7037
- ] }, h)) }) })
7289
+ ] }, x)) }) })
7038
7290
  ] });
7039
7291
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
7040
7292
  className: o,
@@ -7045,7 +7297,7 @@ const CoreBlock = ({
7045
7297
  const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), g = useCallback(() => {
7046
7298
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7047
7299
  }, []);
7048
- return /* @__PURE__ */ jsxs("div", { className: cn("flex h-full w-full flex-col overflow-hidden", o), children: [
7300
+ return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
7049
7301
  n ? /* @__PURE__ */ jsxs("div", { className: "mb-2 flex flex-col justify-between rounded-md bg-background/30 p-1", children: [
7050
7302
  /* @__PURE__ */ jsx("h1", { className: "flex flex-col items-baseline px-1 text-xl font-semibold xl:flex-col", children: l("Add block") }),
7051
7303
  /* @__PURE__ */ jsx("span", { className: "p-0 text-xs font-light leading-3 opacity-80 xl:pl-1", children: l(i === "html" ? "Enter or paste TailwindCSS HTML snippet" : "Click to add block to page") })
@@ -7084,7 +7336,7 @@ const CoreBlock = ({
7084
7336
  const u = p.target.value;
7085
7337
  c(u), n(u);
7086
7338
  };
7087
- return /* @__PURE__ */ jsx("div", { className: cn("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
7339
+ return /* @__PURE__ */ jsx("div", { className: cn$1("relative inline-block w-full", l), children: /* @__PURE__ */ jsxs(
7088
7340
  "select",
7089
7341
  {
7090
7342
  className: "mt-1 flex w-full rounded-md border border-border bg-background px-3 py-1 text-sm text-foreground shadow-sm transition-colors file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50",
@@ -7125,18 +7377,18 @@ const BlockCard = ({
7125
7377
  parentId: r = void 0,
7126
7378
  position: a = -1
7127
7379
  }) => {
7128
- const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, b] = useAtom$1(draggedBlockAtom), x = (B) => {
7129
- const E = has(B, "styles_attrs.data-page-section");
7130
- return B._type === "Box" && E;
7131
- }, h = useCallback(
7132
- async (B) => {
7133
- if (B.stopPropagation(), has(o, "component")) {
7380
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), m = get(o, "name", get(o, "label")), f = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), b = (A) => {
7381
+ const j = has(A, "styles_attrs.data-page-section");
7382
+ return A._type === "Box" && j;
7383
+ }, x = useCallback(
7384
+ async (A) => {
7385
+ if (A.stopPropagation(), has(o, "component")) {
7134
7386
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7135
7387
  return;
7136
7388
  }
7137
7389
  i(!0);
7138
- const E = await c(n, o);
7139
- isEmpty(E) || p(syncBlocksWithDefaults(E), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7390
+ const j = await c(n, o);
7391
+ isEmpty(j) || p(syncBlocksWithDefaults(j), r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7140
7392
  },
7141
7393
  [d, p, o, c, n, r, a]
7142
7394
  );
@@ -7145,26 +7397,26 @@ const BlockCard = ({
7145
7397
  "div",
7146
7398
  {
7147
7399
  onClick: l ? () => {
7148
- } : h,
7400
+ } : x,
7149
7401
  draggable: f ? "true" : "false",
7150
- onDragStart: async (B) => {
7151
- const E = await c(n, o);
7152
- let w = r;
7153
- if (x(first(E)) && (w = null), !isEmpty(E)) {
7154
- const S = { blocks: E, uiLibrary: !0, parent: w };
7155
- if (B.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7156
- const A = new Image();
7157
- A.src = o.preview, A.onload = () => {
7158
- B.dataTransfer.setDragImage(A, 0, 0);
7402
+ onDragStart: async (A) => {
7403
+ const j = await c(n, o);
7404
+ let C = r;
7405
+ if (b(first(j)) && (C = null), !isEmpty(j)) {
7406
+ const S = { blocks: j, uiLibrary: !0, parent: C };
7407
+ if (A.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7408
+ const B = new Image();
7409
+ B.src = o.preview, B.onload = () => {
7410
+ A.dataTransfer.setDragImage(B, 0, 0);
7159
7411
  };
7160
7412
  } else
7161
- B.dataTransfer.setDragImage(new Image(), 0, 0);
7162
- b(S), setTimeout(() => {
7413
+ A.dataTransfer.setDragImage(new Image(), 0, 0);
7414
+ h(S), setTimeout(() => {
7163
7415
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7164
7416
  }, 200);
7165
7417
  }
7166
7418
  },
7167
- className: clsx(
7419
+ className: clsx$1(
7168
7420
  "relative mt-2 cursor-pointer overflow-hidden rounded-md border border-border bg-white duration-200 hover:border-blue-500 hover:shadow-xl"
7169
7421
  ),
7170
7422
  children: [
@@ -7191,9 +7443,9 @@ const BlockCard = ({
7191
7443
  })();
7192
7444
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7193
7445
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7194
- const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((w) => w.category === "custom"), d = l.find((w) => w.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"), b = get(g, m, []), x = useRef(null), { t: h } = useTranslation(), y = (w) => {
7195
- x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7196
- x.current && f(w);
7446
+ const [r, a] = useAtom$1(selectedLibraryAtom), l = useBuilderProp("uiLibraries", []), i = useRegisteredChaiBlocks(), c = values(i).filter((C) => C.category === "custom"), d = l.find((C) => C.uuid === r) || first(l), { data: p, isLoading: u } = useLibraryBlocks(d), g = groupBy([...p, ...c], "group"), [m, f] = useState("Hero"), h = get(g, m, []), b = useRef(null), { t: x } = useTranslation(), y = (C) => {
7447
+ b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
7448
+ b.current && f(C);
7197
7449
  }, 300);
7198
7450
  };
7199
7451
  if (u)
@@ -7201,26 +7453,26 @@ const BlockCard = ({
7201
7453
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7202
7454
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7203
7455
  ] });
7204
- const B = filter(b, (w, S) => S % 2 === 0), E = filter(b, (w, S) => S % 2 === 1);
7456
+ const A = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
7205
7457
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsx("div", { className: "relative mt-2 flex h-full max-h-full overflow-hidden bg-background", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full pt-2", children: [
7206
7458
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7207
7459
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
7208
7460
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7209
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: h("Groups") }),
7461
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: x("Groups") }),
7210
7462
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7211
7463
  /* @__PURE__ */ jsx("div", { className: "no-scrollbar mt-2 h-full max-h-full flex-1 overflow-y-auto pb-20", children: React__default.Children.toArray(
7212
- map(g, (w, S) => /* @__PURE__ */ jsxs(
7464
+ map(g, (C, S) => /* @__PURE__ */ jsxs(
7213
7465
  "div",
7214
7466
  {
7215
7467
  onMouseEnter: () => y(S),
7216
- onMouseLeave: () => clearTimeout(x.current),
7468
+ onMouseLeave: () => clearTimeout(b.current),
7217
7469
  onClick: () => f(S),
7218
- className: cn(
7470
+ className: cn$1(
7219
7471
  "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",
7220
7472
  S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7221
7473
  ),
7222
7474
  children: [
7223
- /* @__PURE__ */ jsx("span", { children: capitalize(h(S.toLowerCase())) }),
7475
+ /* @__PURE__ */ jsx("span", { children: capitalize(x(S.toLowerCase())) }),
7224
7476
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7225
7477
  ]
7226
7478
  },
@@ -7232,15 +7484,15 @@ const BlockCard = ({
7232
7484
  /* @__PURE__ */ jsxs(
7233
7485
  ScrollArea,
7234
7486
  {
7235
- onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
7487
+ onMouseEnter: () => b.current ? clearTimeout(b.current) : null,
7236
7488
  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",
7237
7489
  children: [
7238
7490
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7239
7491
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7240
- B.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7492
+ A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7241
7493
  ) }),
7242
7494
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7243
- E.map((w) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: w, library: d }))
7495
+ j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7244
7496
  ) })
7245
7497
  ] }),
7246
7498
  /* @__PURE__ */ jsx("br", {}),
@@ -7463,50 +7715,50 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7463
7715
  var P;
7464
7716
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7465
7717
  let p = null;
7466
- const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: b, isSelected: x, willReceiveDrop: h, isDragging: y, isEditing: B, handleClick: E } = o, w = (j) => {
7467
- j.stopPropagation(), !i.includes(f) && o.toggle();
7468
- }, S = (j) => {
7469
- j.isInternal && (p = j.isOpen, j.isOpen && j.close());
7470
- }, A = (j) => {
7471
- j.isInternal && p !== null && (p ? j.open() : j.close(), p = null);
7472
- }, [_, C] = useAtom$1(currentAddSelection), T = () => {
7473
- var j;
7474
- k(), o.parent.isSelected || C((j = o == null ? void 0 : o.parent) == null ? void 0 : j.id);
7718
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: m } = useBlockHighlight(), { id: f, data: h, isSelected: b, willReceiveDrop: x, isDragging: y, isEditing: A, handleClick: j } = o, C = (E) => {
7719
+ E.stopPropagation(), !i.includes(f) && o.toggle();
7720
+ }, S = (E) => {
7721
+ E.isInternal && (p = E.isOpen, E.isOpen && E.close());
7722
+ }, B = (E) => {
7723
+ E.isInternal && p !== null && (p ? E.open() : E.close(), p = null);
7724
+ }, [_, w] = useAtom$1(currentAddSelection), T = () => {
7725
+ var E;
7726
+ k(), o.parent.isSelected || w((E = o == null ? void 0 : o.parent) == null ? void 0 : E.id);
7475
7727
  }, k = () => {
7476
- C(null);
7477
- }, v = (j) => {
7478
- k(), j.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), E(j);
7728
+ w(null);
7729
+ }, v = (E) => {
7730
+ k(), E.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), j(E);
7479
7731
  };
7480
7732
  useEffect(() => {
7481
- const j = setTimeout(() => {
7482
- h && !o.isOpen && !y && !i.includes(f) && o.toggle();
7733
+ const E = setTimeout(() => {
7734
+ x && !o.isOpen && !y && !i.includes(f) && o.toggle();
7483
7735
  }, 500);
7484
- return () => clearTimeout(j);
7485
- }, [h, o, y]);
7736
+ return () => clearTimeout(E);
7737
+ }, [x, o, y]);
7486
7738
  const N = useMemo(() => {
7487
- const j = Object.keys(b), R = [];
7488
- for (let D = 0; D < j.length; D++)
7489
- if (j[D].endsWith("_attrs")) {
7490
- const L = b[j[D]], $ = Object.keys(L).join("|");
7491
- $.match(/x-data/) && R.push("data"), $.match(/x-on/) && R.push("event"), $.match(/x-show|x-if/) && R.push("show");
7739
+ const E = Object.keys(h), D = [];
7740
+ for (let M = 0; M < E.length; M++)
7741
+ if (E[M].endsWith("_attrs")) {
7742
+ const R = h[E[M]], O = Object.keys(R).join("|");
7743
+ O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7492
7744
  }
7493
- return R;
7494
- }, [b]), I = (j, R) => {
7495
- const D = d.contentDocument || d.contentWindow.document, L = D.querySelector(`[data-block-id=${j}]`);
7496
- L && L.setAttribute("data-drop", R);
7497
- const $ = L.getBoundingClientRect(), O = d.getBoundingClientRect();
7498
- $.top >= O.top && $.left >= O.left && $.bottom <= O.bottom && $.right <= O.right || (D.documentElement.scrollTop = L.offsetTop - O.top);
7499
- }, M = (j) => {
7745
+ return D;
7746
+ }, [h]), I = (E, D) => {
7747
+ const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${E}]`);
7748
+ R && R.setAttribute("data-drop", D);
7749
+ const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
7750
+ O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
7751
+ }, L = (E) => {
7500
7752
  k();
7501
- const R = get(o, "parent.id");
7502
- R !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: R, position: j }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: j });
7753
+ const D = get(o, "parent.id");
7754
+ D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: E }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: E });
7503
7755
  };
7504
7756
  return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7505
7757
  /* @__PURE__ */ jsx("br", {}),
7506
7758
  /* @__PURE__ */ jsx(
7507
7759
  "div",
7508
7760
  {
7509
- onClick: () => M(-1),
7761
+ onClick: () => L(-1),
7510
7762
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
7511
7763
  children: /* @__PURE__ */ 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: [
7512
7764
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -7526,22 +7778,22 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7526
7778
  "data-node-id": f,
7527
7779
  ref: i.includes(f) ? null : r,
7528
7780
  onDragStart: () => S(o),
7529
- onDragEnd: () => A(o),
7530
- onDragOver: (j) => {
7531
- j.preventDefault(), I(f, "yes");
7781
+ onDragEnd: () => B(o),
7782
+ onDragOver: (E) => {
7783
+ E.preventDefault(), I(f, "yes");
7532
7784
  },
7533
- onDragLeave: (j) => {
7534
- j.preventDefault(), I(f, "no");
7785
+ onDragLeave: (E) => {
7786
+ E.preventDefault(), I(f, "no");
7535
7787
  },
7536
- onDrop: (j) => {
7537
- j.preventDefault(), I(f, "no");
7788
+ onDrop: (E) => {
7789
+ E.preventDefault(), I(f, "no");
7538
7790
  },
7539
7791
  children: [
7540
7792
  (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((P = o == null ? void 0 : o.parent) == null ? void 0 : P.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7541
7793
  "div",
7542
7794
  {
7543
- onClick: (j) => {
7544
- j.stopPropagation(), M(o.childIndex);
7795
+ onClick: (E) => {
7796
+ E.stopPropagation(), L(o.childIndex);
7545
7797
  },
7546
7798
  onMouseEnter: T,
7547
7799
  onMouseLeave: k,
@@ -7552,10 +7804,10 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7552
7804
  /* @__PURE__ */ jsxs(
7553
7805
  "div",
7554
7806
  {
7555
- className: cn(
7807
+ className: cn$1(
7556
7808
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7557
- x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7558
- h && canAcceptChildBlock(b._type, "Icon") ? "bg-green-200" : "",
7809
+ b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7810
+ x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7559
7811
  (o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
7560
7812
  y && "opacity-20",
7561
7813
  i.includes(f) ? "opacity-50" : ""
@@ -7566,25 +7818,25 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7566
7818
  "div",
7567
7819
  {
7568
7820
  className: `flex h-4 w-4 rotate-0 transform cursor-pointer items-center justify-center transition-transform duration-100 ${o.isOpen ? "rotate-90" : ""}`,
7569
- children: u && /* @__PURE__ */ jsx("button", { onClick: w, type: "button", children: /* @__PURE__ */ jsx(
7821
+ children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(
7570
7822
  ChevronRight,
7571
7823
  {
7572
- className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}`
7824
+ className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
7573
7825
  }
7574
7826
  ) })
7575
7827
  }
7576
7828
  ),
7577
7829
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
7578
- /* @__PURE__ */ jsx(TypeIcon, { type: b == null ? void 0 : b._type }),
7579
- B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7830
+ /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7831
+ A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7580
7832
  "div",
7581
7833
  {
7582
7834
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
7583
- onDoubleClick: (j) => {
7584
- j.stopPropagation(), o.edit(), o.deselect();
7835
+ onDoubleClick: (E) => {
7836
+ E.stopPropagation(), o.edit(), o.deselect();
7585
7837
  },
7586
7838
  children: [
7587
- /* @__PURE__ */ jsx("span", { children: (b == null ? void 0 : b._name) || (b == null ? void 0 : b._type.split("/").pop()) }),
7839
+ /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7588
7840
  N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
7589
7841
  N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
7590
7842
  N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
@@ -7594,18 +7846,18 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7594
7846
  ] })
7595
7847
  ] }),
7596
7848
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7597
- !i.includes(f) && a.map((j) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7849
+ !i.includes(f) && a.map((E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7598
7850
  /* @__PURE__ */ jsx(
7599
7851
  TooltipTrigger,
7600
7852
  {
7601
7853
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
7602
7854
  asChild: !0,
7603
- children: React__default.createElement(j.item, { blockId: f })
7855
+ children: React__default.createElement(E.item, { blockId: f })
7604
7856
  }
7605
7857
  ),
7606
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: j.tooltip })
7858
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: E.tooltip })
7607
7859
  ] })),
7608
- canAddChildBlock(b == null ? void 0 : b._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7860
+ canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7609
7861
  /* @__PURE__ */ jsx(
7610
7862
  TooltipTrigger,
7611
7863
  {
@@ -7621,8 +7873,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7621
7873
  /* @__PURE__ */ jsx(
7622
7874
  TooltipTrigger,
7623
7875
  {
7624
- onClick: (j) => {
7625
- j.stopPropagation(), c(f), o.isOpen && o.toggle();
7876
+ onClick: (E) => {
7877
+ E.stopPropagation(), c(f), o.isOpen && o.toggle();
7626
7878
  },
7627
7879
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7628
7880
  asChild: !0,
@@ -7644,7 +7896,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7644
7896
  "input",
7645
7897
  {
7646
7898
  autoFocus: !0,
7647
- className: cn(
7899
+ className: cn$1(
7648
7900
  "ml-2 !h-4 w-full rounded-sm border border-border bg-background px-1 text-[11px] leading-tight outline-none",
7649
7901
  o.isSelected ? "text-black dark:text-white" : ""
7650
7902
  ),
@@ -7743,7 +7995,7 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7743
7995
  t("Add Block")
7744
7996
  ] })
7745
7997
  ] }) }) }) : /* @__PURE__ */ jsxs(Fragment, { children: [
7746
- /* @__PURE__ */ jsx("div", { className: cn("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
7998
+ /* @__PURE__ */ jsx("div", { className: cn$1("flex h-full select-none flex-col space-y-1"), onClick: () => clearSelection(), children: /* @__PURE__ */ jsxs(
7747
7999
  "div",
7748
8000
  {
7749
8001
  id: "outline-view",
@@ -8284,12 +8536,12 @@ function QuickPrompts({ onClick: o }) {
8284
8536
  const AIUserPrompt = ({ blockId: o }) => {
8285
8537
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), m = useRef(null), f = useRef(null);
8286
8538
  useEffect(() => {
8287
- var x;
8288
- (x = m.current) == null || x.focus();
8539
+ var b;
8540
+ (b = m.current) == null || b.focus();
8289
8541
  }, []);
8290
- const b = (x) => {
8291
- const { usage: h } = x || {};
8292
- !l && h && g(h), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
8542
+ const h = (b) => {
8543
+ const { usage: x } = b || {};
8544
+ !l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
8293
8545
  };
8294
8546
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8295
8547
  /* @__PURE__ */ jsxs(
@@ -8309,12 +8561,12 @@ const AIUserPrompt = ({ blockId: o }) => {
8309
8561
  {
8310
8562
  ref: m,
8311
8563
  value: i,
8312
- onChange: (x) => c(x.target.value),
8564
+ onChange: (b) => c(b.target.value),
8313
8565
  placeholder: n("Ask AI to edit content"),
8314
8566
  className: "w-full",
8315
8567
  rows: 3,
8316
- onKeyDown: (x) => {
8317
- x.key === "Enter" && (x.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, b));
8568
+ onKeyDown: (b) => {
8569
+ b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h));
8318
8570
  }
8319
8571
  }
8320
8572
  ),
@@ -8324,7 +8576,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8324
8576
  {
8325
8577
  disabled: i.trim().length < 5 || a,
8326
8578
  onClick: () => {
8327
- f.current && clearTimeout(f.current), g(void 0), r("content", o, i, b);
8579
+ f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h);
8328
8580
  },
8329
8581
  variant: "default",
8330
8582
  className: "w-fit",
@@ -8356,8 +8608,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8356
8608
  /* @__PURE__ */ jsx(
8357
8609
  QuickPrompts,
8358
8610
  {
8359
- onClick: (x) => {
8360
- f.current && clearTimeout(f.current), g(void 0), r("content", o, x, b);
8611
+ onClick: (b) => {
8612
+ f.current && clearTimeout(f.current), g(void 0), r("content", o, b, h);
8361
8613
  }
8362
8614
  }
8363
8615
  )
@@ -8367,19 +8619,15 @@ const AIUserPrompt = ({ blockId: o }) => {
8367
8619
  ] }) }) : null
8368
8620
  ] });
8369
8621
  }, AISetContext = () => {
8370
- const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), { toast: m } = useToast(), f = useRef(null);
8622
+ const { t: o } = useTranslation(), n = useBuilderProp("aiContext", ""), [r, a] = useState(n), l = useRef(null), i = useBuilderProp("saveAiContextCallback", noop), [c, d] = useState(!1), [p, u] = useState(null), [, g] = useState(!1), m = useRef(null);
8371
8623
  useEffect(() => {
8372
8624
  n && a(n);
8373
8625
  }, [n]);
8374
- const b = async () => {
8626
+ const f = async () => {
8375
8627
  try {
8376
- d(!0), u(null), await i(r), m({
8377
- title: o("Updated AI Context"),
8378
- description: o("You can now Ask AI to edit your content"),
8379
- variant: "default"
8380
- }), f.current.click();
8381
- } catch (x) {
8382
- u(x);
8628
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8629
+ } catch (h) {
8630
+ u(h);
8383
8631
  } finally {
8384
8632
  d(!1);
8385
8633
  }
@@ -8387,25 +8635,25 @@ const AIUserPrompt = ({ blockId: o }) => {
8387
8635
  return /* @__PURE__ */ jsx(
8388
8636
  Accordion,
8389
8637
  {
8390
- onValueChange: (x) => {
8391
- g(x !== "");
8638
+ onValueChange: (h) => {
8639
+ g(h !== "");
8392
8640
  },
8393
8641
  type: "single",
8394
8642
  collapsible: !0,
8395
8643
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8396
- /* @__PURE__ */ jsx(AccordionTrigger, { ref: f, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8644
+ /* @__PURE__ */ jsx(AccordionTrigger, { ref: m, className: "border-0 border-border py-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between", children: /* @__PURE__ */ jsx("span", { className: "font-medium", children: o("AI Context") }) }) }),
8397
8645
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8398
8646
  /* @__PURE__ */ jsx(
8399
8647
  Textarea,
8400
8648
  {
8401
8649
  ref: l,
8402
8650
  value: r,
8403
- onChange: (x) => a(x.target.value),
8651
+ onChange: (h) => a(h.target.value),
8404
8652
  placeholder: o("Tell about this page eg this page is about"),
8405
8653
  className: "mt-1 w-full",
8406
8654
  rows: 10,
8407
- onKeyDown: (x) => {
8408
- x.key === "Enter" && (x.preventDefault(), b());
8655
+ onKeyDown: (h) => {
8656
+ h.key === "Enter" && (h.preventDefault(), f());
8409
8657
  }
8410
8658
  }
8411
8659
  ),
@@ -8417,7 +8665,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8417
8665
  Button,
8418
8666
  {
8419
8667
  disabled: r.trim().length < 5,
8420
- onClick: () => b(),
8668
+ onClick: () => f(),
8421
8669
  variant: "default",
8422
8670
  className: "w-fit",
8423
8671
  size: "sm",
@@ -8446,7 +8694,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8446
8694
  AlertDialogAction,
8447
8695
  {
8448
8696
  onClick: () => {
8449
- a(""), b();
8697
+ a(""), f();
8450
8698
  },
8451
8699
  children: o("Yes, Delete")
8452
8700
  }
@@ -8569,7 +8817,7 @@ const AiAssistant = () => {
8569
8817
  }, DataBinding = () => {
8570
8818
  const o = usePageExternalData(), [n, r] = useAtom$1(dataBindingActiveAtom), { t: a } = useTranslation();
8571
8819
  return isEmpty(o) ? null : /* @__PURE__ */ jsx("div", { className: "flex items-center", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
8572
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "rounded-full", variant: "ghost", onClick: () => r(!n), children: /* @__PURE__ */ jsx(DatabaseZapIcon, { className: cn("h-4 w-4", n ? "text-green-500" : "text-gray-500") }) }) }),
8820
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(Button, { className: "rounded-full", variant: "ghost", onClick: () => r(!n), children: /* @__PURE__ */ jsx(DatabaseZapIcon, { className: cn$1("h-4 w-4", n ? "text-green-500" : "text-gray-500") }) }) }),
8573
8821
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: a("Toggle Data Binding") }) })
8574
8822
  ] }) });
8575
8823
  }, CanvasTopBar = () => {
@@ -8600,11 +8848,11 @@ const AiAssistant = () => {
8600
8848
  ] })
8601
8849
  ] });
8602
8850
  }, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
8603
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), b = useRef(null), x = useRef(null);
8851
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), b = useRef(null);
8604
8852
  useEffect(() => {
8605
8853
  l(n);
8606
8854
  }, [n]);
8607
- const h = () => {
8855
+ const x = () => {
8608
8856
  if (i.startsWith("@")) {
8609
8857
  f("Attribute keys cannot start with '@'");
8610
8858
  return;
@@ -8614,11 +8862,11 @@ const AiAssistant = () => {
8614
8862
  r(S), l(a), c(""), p(""), f("");
8615
8863
  }
8616
8864
  }, y = (S) => {
8617
- const A = a.filter((_, C) => C !== S);
8618
- r(A), l(A);
8619
- }, B = (S) => {
8865
+ const B = a.filter((_, w) => w !== S);
8866
+ r(B), l(B);
8867
+ }, A = (S) => {
8620
8868
  g(S), c(a[S].key), p(a[S].value);
8621
- }, E = () => {
8869
+ }, j = () => {
8622
8870
  if (i.startsWith("@")) {
8623
8871
  f("Attribute keys cannot start with '@'");
8624
8872
  return;
@@ -8633,7 +8881,7 @@ const AiAssistant = () => {
8633
8881
  "form",
8634
8882
  {
8635
8883
  onSubmit: (S) => {
8636
- S.preventDefault(), u !== null ? E() : h();
8884
+ S.preventDefault(), u !== null ? j() : x();
8637
8885
  },
8638
8886
  className: "space-y-3",
8639
8887
  children: [
@@ -8647,7 +8895,7 @@ const AiAssistant = () => {
8647
8895
  autoCorrect: "off",
8648
8896
  spellCheck: "false",
8649
8897
  id: "attrKey",
8650
- ref: b,
8898
+ ref: h,
8651
8899
  value: i,
8652
8900
  onChange: (S) => c(S.target.value),
8653
8901
  placeholder: "Enter Key",
@@ -8665,11 +8913,11 @@ const AiAssistant = () => {
8665
8913
  spellCheck: "false",
8666
8914
  id: "attrValue",
8667
8915
  rows: 2,
8668
- ref: x,
8916
+ ref: b,
8669
8917
  value: d,
8670
8918
  onChange: (S) => p(S.target.value),
8671
8919
  onKeyDown: (S) => {
8672
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? E() : h());
8920
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : x());
8673
8921
  },
8674
8922
  placeholder: "Enter Value",
8675
8923
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -8682,16 +8930,16 @@ const AiAssistant = () => {
8682
8930
  ]
8683
8931
  }
8684
8932
  ),
8685
- /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, A) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8933
+ /* @__PURE__ */ jsx("div", { className: "space-y-1 py-4", children: a.map((S, B) => /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between rounded border p-2 text-sm", children: [
8686
8934
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
8687
8935
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
8688
8936
  /* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
8689
8937
  ] }),
8690
8938
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
8691
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
8692
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
8939
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
8940
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
8693
8941
  ] })
8694
- ] }, A)) })
8942
+ ] }, B)) })
8695
8943
  ] });
8696
8944
  }), BlockAttributesEditor = React.memo(() => {
8697
8945
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -8869,7 +9117,7 @@ const ChooseLayout = ({ open: o, close: n }) => {
8869
9117
  )
8870
9118
  ] }) })
8871
9119
  ] }) });
8872
- }, TopBar = lazy(() => import("./Topbar-BuWEmzZG.js"));
9120
+ }, TopBar = lazy(() => import("./Topbar-DutZ_viX.js"));
8873
9121
  function useSidebarMenuItems() {
8874
9122
  return useMemo(() => compact([
8875
9123
  {
@@ -8885,12 +9133,12 @@ const RootLayout = () => {
8885
9133
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
8886
9134
  n(1);
8887
9135
  });
8888
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
8889
- x.preventDefault();
8890
- }, u = (x) => {
8891
- n(o === x ? null : x);
8892
- }, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], b = useBuilderProp("htmlDir", "ltr");
8893
- return /* @__PURE__ */ jsx("div", { dir: b, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
9136
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (b) => {
9137
+ b.preventDefault();
9138
+ }, u = (b) => {
9139
+ n(o === b ? null : b);
9140
+ }, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
9141
+ return /* @__PURE__ */ jsx("div", { dir: h, className: "h-screen max-h-full w-screen overflow-x-hidden bg-background text-foreground", children: /* @__PURE__ */ jsxs(TooltipProvider, { children: [
8894
9142
  /* @__PURE__ */ jsxs(
8895
9143
  "div",
8896
9144
  {
@@ -8900,21 +9148,21 @@ const RootLayout = () => {
8900
9148
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
8901
9149
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
8902
9150
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
8903
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((x, h) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9151
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8904
9152
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
8905
9153
  Button,
8906
9154
  {
8907
- variant: o === h ? "default" : "ghost",
9155
+ variant: o === x ? "default" : "ghost",
8908
9156
  className: "mb-2 rounded-lg p-2 transition-colors",
8909
- onClick: () => u(h),
8910
- children: get(x, "icon", null)
9157
+ onClick: () => u(x),
9158
+ children: get(b, "icon", null)
8911
9159
  },
8912
- h
9160
+ x
8913
9161
  ) }),
8914
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(x.label) }) })
8915
- ] }, "button" + h)) }),
9162
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
9163
+ ] }, "button" + x)) }),
8916
9164
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
8917
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, h) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${h}`)) })
9165
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((b, x) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(b, {}) }, `sidebar-component-${x}`)) })
8918
9166
  ] }),
8919
9167
  /* @__PURE__ */ jsx(
8920
9168
  motion.div,
@@ -8983,7 +9231,7 @@ const RootLayout = () => {
8983
9231
  ] }) });
8984
9232
  }, PreviewScreen = () => {
8985
9233
  const [o, n] = usePreviewMode(), { t: r } = useTranslation(), a = useBuilderProp("previewComponent", null);
8986
- return o ? /* @__PURE__ */ jsxs("div", { className: cn("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
9234
+ return o ? /* @__PURE__ */ jsxs("div", { className: cn$1("fixed inset-0 z-[999] bg-background", o ? "block" : "hidden"), children: [
8987
9235
  /* @__PURE__ */ jsxs(Button, { size: "sm", className: "absolute right-0 top-0 m-4 space-x-2", onClick: () => n(!1), children: [
8988
9236
  /* @__PURE__ */ jsx(EyeClosedIcon, {}),
8989
9237
  /* @__PURE__ */ jsx("span", { children: r("Close Preview") })
@@ -9079,9 +9327,9 @@ export {
9079
9327
  generateUUID as generateBlockId,
9080
9328
  getBlocksFromHTML,
9081
9329
  getClassValueAndUnit,
9082
- He as i18n,
9083
- cn as mergeClasses,
9084
- $e as registerChaiBlock,
9330
+ We as i18n,
9331
+ cn$1 as mergeClasses,
9332
+ Fe as registerChaiBlock,
9085
9333
  useAddBlock,
9086
9334
  useAddClassesToBlocks,
9087
9335
  useAskAi,
@@ -9124,7 +9372,7 @@ export {
9124
9372
  useStylingState,
9125
9373
  useTheme,
9126
9374
  useThemeOptions,
9127
- De as useTranslation,
9375
+ Ve as useTranslation,
9128
9376
  useUILibraryBlocks,
9129
9377
  useUndoManager,
9130
9378
  useUpdateBlocksProps,