@chaibuilder/sdk 2.0.0-beta.107 → 2.0.0-beta.109

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
@@ -13,7 +13,7 @@ import { useTranslation as Ve } from "react-i18next";
13
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
- 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";
16
+ import { ArrowUpIcon, PlusIcon, CopyIcon, TrashIcon, DragHandleDots2Icon, BoxModelIcon, DotsVerticalIcon, MobileIcon, LaptopIcon, DesktopIcon, Cross2Icon, EyeOpenIcon, EyeClosedIcon, BorderAllIcon, WidthIcon, HeightIcon, ArrowRightIcon, ArrowDownIcon, ArrowLeftIcon, ArrowTopLeftIcon, ArrowTopRightIcon, ArrowBottomRightIcon, ArrowBottomLeftIcon, AlignLeftIcon, AlignCenterHorizontallyIcon, AlignRightIcon, StretchHorizontallyIcon, FontItalicIcon, UnderlineIcon, OverlineIcon, LetterCaseUppercaseIcon, Cross1Icon, InfoCircledIcon, BoxIcon, 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";
@@ -22,7 +22,7 @@ import { e as getDefaultExportFromCjs, d as defaultThemeOptions, g as getChaiThe
22
22
  import TreeModel from "tree-model";
23
23
  import { useHotkeys } from "react-hotkeys-hook";
24
24
  import { toast } from "sonner";
25
- import { PlusIcon as PlusIcon$1, PanelRightClose, PanelRightOpen, AppWindowIcon, AlignHorizontalJustifyStart, UnfoldHorizontal, DatabaseIcon, Columns, Rows, GlobeIcon, ChevronRight, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, 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";
25
+ import { PlusIcon as PlusIcon$1, ChevronRight, DatabaseIcon, ChevronLeft, Bold, Italic, Underline as Underline$1, Strikethrough, 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
26
  import { useEditor, EditorContent } from "@tiptap/react";
27
27
  import StarterKit from "@tiptap/starter-kit";
28
28
  import typography from "@tailwindcss/typography";
@@ -94,226 +94,226 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
94
94
  for (const i of n.p)
95
95
  l.add(i);
96
96
  return l;
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);
103
- }, ...m) => {
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;
109
- const k = (v) => {
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 = (m, ...h) => m.read(...h), p = (m, ...h) => m.write(...h), u = (m, h) => {
98
+ var x;
99
+ return (x = m.unstable_onInit) == null ? void 0 : x.call(m, h);
100
+ }, g = (m, h) => {
101
+ var x;
102
+ return (x = m.onMount) == null ? void 0 : x.call(m, h);
103
+ }, ...f) => {
104
+ const m = f[0] || ((w) => {
105
+ let L = o.get(w);
106
+ return L || (L = { d: /* @__PURE__ */ new Map(), p: /* @__PURE__ */ new Set(), n: 0 }, o.set(w, L), u == null || u(w, _)), L;
107
+ }), h = f[1] || (() => {
108
+ let w, L;
109
+ const v = (k) => {
110
110
  try {
111
- v();
112
- } catch (N) {
113
- w || (w = !0, T = N);
111
+ k();
112
+ } catch (E) {
113
+ w || (w = !0, L = E);
114
114
  }
115
115
  };
116
116
  do {
117
- c.f && k(c.f);
118
- const v = /* @__PURE__ */ new Set(), N = v.add.bind(v);
119
- a.forEach((I) => {
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();
117
+ c.f && v(c.f);
118
+ const k = /* @__PURE__ */ new Set(), E = k.add.bind(k);
119
+ a.forEach((T) => {
120
+ var I;
121
+ return (I = n.get(T)) == null ? void 0 : I.l.forEach(E);
122
+ }), a.clear(), i.forEach(E), i.clear(), l.forEach(E), l.clear(), k.forEach(v), a.size && x();
123
123
  } while (a.size || i.size || l.size);
124
124
  if (w)
125
- throw T;
126
- }), b = m[2] || (() => {
127
- const w = [], T = /* @__PURE__ */ new WeakSet(), k = /* @__PURE__ */ new WeakSet(), v = Array.from(a);
128
- for (; v.length; ) {
129
- const N = v[v.length - 1], I = f(N);
130
- if (k.has(N)) {
131
- v.pop();
125
+ throw L;
126
+ }), x = f[2] || (() => {
127
+ const w = [], L = /* @__PURE__ */ new WeakSet(), v = /* @__PURE__ */ new WeakSet(), k = Array.from(a);
128
+ for (; k.length; ) {
129
+ const E = k[k.length - 1], T = m(E);
130
+ if (v.has(E)) {
131
+ k.pop();
132
132
  continue;
133
133
  }
134
- if (T.has(N)) {
135
- r.get(N) === I.n && w.push([N, I]), k.add(N), v.pop();
134
+ if (L.has(E)) {
135
+ r.get(E) === T.n && w.push([E, T]), v.add(E), k.pop();
136
136
  continue;
137
137
  }
138
- T.add(N);
139
- for (const L of getMountedOrPendingDependents(N, I, n))
140
- T.has(L) || v.push(L);
138
+ L.add(E);
139
+ for (const I of getMountedOrPendingDependents(E, T, n))
140
+ L.has(I) || k.push(I);
141
141
  }
142
- for (let N = w.length - 1; N >= 0; --N) {
143
- const [I, L] = w[N];
144
- let P = !1;
145
- for (const E of L.d.keys())
146
- if (E !== I && a.has(E)) {
147
- P = !0;
142
+ for (let E = w.length - 1; E >= 0; --E) {
143
+ const [T, I] = w[E];
144
+ let R = !1;
145
+ for (const N of I.d.keys())
146
+ if (N !== T && a.has(N)) {
147
+ R = !0;
148
148
  break;
149
149
  }
150
- P && (x(I), j(I)), r.delete(I);
150
+ R && (b(T), j(T)), r.delete(T);
151
151
  }
152
- }), x = m[3] || ((w) => {
153
- var T, k;
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
+ }), b = f[3] || ((w) => {
153
+ var L, v;
154
+ const k = m(w);
155
+ if (isAtomStateInitialized(k) && (n.has(w) && r.get(w) !== k.n || Array.from(k.d).every(
156
+ ([P, O]) => (
157
157
  // Recursively, read the atom state of the dependency, and
158
158
  // check if the atom epoch number is unchanged
159
- x(R).n === O
159
+ b(P).n === O
160
160
  )
161
161
  )))
162
- return v;
163
- v.d.clear();
164
- let N = !0;
165
- const I = () => {
166
- n.has(w) && (j(w), b(), h());
167
- }, L = (R) => {
162
+ return k;
163
+ k.d.clear();
164
+ let E = !0;
165
+ const T = () => {
166
+ n.has(w) && (j(w), x(), h());
167
+ }, I = (P) => {
168
168
  var O;
169
- if (isSelfAtom(w, R)) {
170
- const H = f(R);
169
+ if (isSelfAtom(w, P)) {
170
+ const H = m(P);
171
171
  if (!isAtomStateInitialized(H))
172
- if (hasInitialValue(R))
173
- setAtomStateValueOrPromise(R, R.init, f);
172
+ if (hasInitialValue(P))
173
+ setAtomStateValueOrPromise(P, P.init, m);
174
174
  else
175
175
  throw new Error("no atom init");
176
176
  return returnAtomValue(H);
177
177
  }
178
- const $ = x(R);
178
+ const $ = b(P);
179
179
  try {
180
180
  return returnAtomValue($);
181
181
  } finally {
182
- v.d.set(R, $.n), isPendingPromise(v.v) && addPendingPromiseToDependency(w, v.v, $), (O = n.get(R)) == null || O.t.add(w), N || I();
182
+ k.d.set(P, $.n), isPendingPromise(k.v) && addPendingPromiseToDependency(w, k.v, $), (O = n.get(P)) == null || O.t.add(w), E || T();
183
183
  }
184
184
  };
185
- let P, E;
185
+ let R, N;
186
186
  const D = {
187
187
  get signal() {
188
- return P || (P = new AbortController()), P.signal;
188
+ return R || (R = new AbortController()), R.signal;
189
189
  },
190
190
  get setSelf() {
191
- return !E && isActuallyWritableAtom(w) && (E = (...R) => {
192
- if (!N)
191
+ return !N && isActuallyWritableAtom(w) && (N = (...P) => {
192
+ if (!E)
193
193
  try {
194
- return A(w, ...R);
194
+ return B(w, ...P);
195
195
  } finally {
196
- b(), h();
196
+ x(), h();
197
197
  }
198
- }), E;
198
+ }), N;
199
199
  }
200
- }, M = v.n;
200
+ }, M = k.n;
201
201
  try {
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(
204
- I,
205
- I
206
- )), v;
207
- } catch (R) {
208
- return delete v.v, v.e = R, ++v.n, v;
202
+ const P = d(w, I, D);
203
+ return setAtomStateValueOrPromise(w, P, m), isPromiseLike$2(P) && ((L = P.onCancel) == null || L.call(P, () => R == null ? void 0 : R.abort()), P.then(
204
+ T,
205
+ T
206
+ )), k;
207
+ } catch (P) {
208
+ return delete k.v, k.e = P, ++k.n, k;
209
209
  } finally {
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));
210
+ E = !1, M !== k.n && r.get(w) === M && (r.set(w, k.n), a.add(w), (v = c.c) == null || v.call(c, w));
211
211
  }
212
- }), y = m[4] || ((w) => {
213
- const T = [w];
214
- for (; T.length; ) {
215
- const k = T.pop(), v = f(k);
216
- for (const N of getMountedOrPendingDependents(k, v, n)) {
217
- const I = f(N);
218
- r.set(N, I.n), T.push(N);
212
+ }), y = f[4] || ((w) => {
213
+ const L = [w];
214
+ for (; L.length; ) {
215
+ const v = L.pop(), k = m(v);
216
+ for (const E of getMountedOrPendingDependents(v, k, n)) {
217
+ const T = m(E);
218
+ r.set(E, T.n), L.push(E);
219
219
  }
220
220
  }
221
- }), A = m[5] || ((w, ...T) => {
222
- let k = !0;
223
- const v = (I) => returnAtomValue(x(I)), N = (I, ...L) => {
224
- var P;
225
- const E = f(I);
221
+ }), B = f[5] || ((w, ...L) => {
222
+ let v = !0;
223
+ const k = (T) => returnAtomValue(b(T)), E = (T, ...I) => {
224
+ var R;
225
+ const N = m(T);
226
226
  try {
227
- if (isSelfAtom(w, I)) {
228
- if (!hasInitialValue(I))
227
+ if (isSelfAtom(w, T)) {
228
+ if (!hasInitialValue(T))
229
229
  throw new Error("atom not writable");
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));
230
+ const D = N.n, M = I[0];
231
+ setAtomStateValueOrPromise(T, M, m), j(T), D !== N.n && (a.add(T), (R = c.c) == null || R.call(c, T), y(T));
232
232
  return;
233
233
  } else
234
- return A(I, ...L);
234
+ return B(T, ...I);
235
235
  } finally {
236
- k || (b(), h());
236
+ v || (x(), h());
237
237
  }
238
238
  };
239
239
  try {
240
- return p(w, v, N, ...T);
240
+ return p(w, k, E, ...L);
241
241
  } finally {
242
- k = !1;
242
+ v = !1;
243
243
  }
244
- }), j = m[6] || ((w) => {
245
- var T;
246
- const k = f(w), v = n.get(w);
247
- if (v && !isPendingPromise(k.v)) {
248
- for (const [N, I] of k.d)
249
- if (!v.d.has(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));
244
+ }), j = f[6] || ((w) => {
245
+ var L;
246
+ const v = m(w), k = n.get(w);
247
+ if (k && !isPendingPromise(v.v)) {
248
+ for (const [E, T] of v.d)
249
+ if (!k.d.has(E)) {
250
+ const I = m(E);
251
+ C(E).t.add(w), k.d.add(E), T !== I.n && (a.add(E), (L = c.c) == null || L.call(c, E), y(E));
252
252
  }
253
- for (const N of v.d || [])
254
- if (!k.d.has(N)) {
255
- v.d.delete(N);
256
- const I = S(N);
257
- I == null || I.t.delete(w);
253
+ for (const E of k.d || [])
254
+ if (!v.d.has(E)) {
255
+ k.d.delete(E);
256
+ const T = S(E);
257
+ T == null || T.t.delete(w);
258
258
  }
259
259
  }
260
- }), C = m[7] || ((w) => {
261
- var T;
262
- const k = f(w);
263
- let v = n.get(w);
264
- if (!v) {
265
- x(w);
266
- for (const N of k.d.keys())
267
- C(N).t.add(w);
268
- if (v = {
260
+ }), C = f[7] || ((w) => {
261
+ var L;
262
+ const v = m(w);
263
+ let k = n.get(w);
264
+ if (!k) {
265
+ b(w);
266
+ for (const E of v.d.keys())
267
+ C(E).t.add(w);
268
+ if (k = {
269
269
  l: /* @__PURE__ */ new Set(),
270
- d: new Set(k.d.keys()),
270
+ d: new Set(v.d.keys()),
271
271
  t: /* @__PURE__ */ new Set()
272
- }, n.set(w, v), (T = c.m) == null || T.call(c, w), isActuallyWritableAtom(w)) {
273
- const N = () => {
274
- let I = !0;
275
- const L = (...P) => {
272
+ }, n.set(w, k), (L = c.m) == null || L.call(c, w), isActuallyWritableAtom(w)) {
273
+ const E = () => {
274
+ let T = !0;
275
+ const I = (...R) => {
276
276
  try {
277
- return A(w, ...P);
277
+ return B(w, ...R);
278
278
  } finally {
279
- I || (b(), h());
279
+ T || (x(), h());
280
280
  }
281
281
  };
282
282
  try {
283
- const P = g(w, L);
284
- P && (v.u = () => {
285
- I = !0;
283
+ const R = g(w, I);
284
+ R && (k.u = () => {
285
+ T = !0;
286
286
  try {
287
- P();
287
+ R();
288
288
  } finally {
289
- I = !1;
289
+ T = !1;
290
290
  }
291
291
  });
292
292
  } finally {
293
- I = !1;
293
+ T = !1;
294
294
  }
295
295
  };
296
- l.add(N);
296
+ l.add(E);
297
297
  }
298
298
  }
299
- return v;
300
- }), S = m[8] || ((w) => {
301
- var T;
302
- const k = f(w);
303
- let v = n.get(w);
304
- if (v && !v.l.size && !Array.from(v.t).some((N) => {
305
- var I;
306
- return (I = n.get(N)) == null ? void 0 : I.d.has(w);
299
+ return k;
300
+ }), S = f[8] || ((w) => {
301
+ var L;
302
+ const v = m(w);
303
+ let k = n.get(w);
304
+ if (k && !k.l.size && !Array.from(k.t).some((E) => {
305
+ var T;
306
+ return (T = n.get(E)) == null ? void 0 : T.d.has(w);
307
307
  })) {
308
- v.u && i.add(v.u), v = void 0, n.delete(w), (T = c.u) == null || T.call(c, w);
309
- for (const N of k.d.keys()) {
310
- const I = S(N);
311
- I == null || I.t.delete(w);
308
+ k.u && i.add(k.u), k = void 0, n.delete(w), (L = c.u) == null || L.call(c, w);
309
+ for (const E of v.d.keys()) {
310
+ const T = S(E);
311
+ T == null || T.t.delete(w);
312
312
  }
313
313
  return;
314
314
  }
315
- return v;
316
- }), B = [
315
+ return k;
316
+ }), A = [
317
317
  // store state
318
318
  o,
319
319
  n,
@@ -328,32 +328,32 @@ const isSelfAtom = (o, n) => o.unstable_is ? o.unstable_is(n) : n === o, hasInit
328
328
  u,
329
329
  g,
330
330
  // building-block functions
331
- f,
331
+ m,
332
332
  h,
333
- b,
334
333
  x,
334
+ b,
335
335
  y,
336
- A,
336
+ B,
337
337
  j,
338
338
  C,
339
339
  S
340
340
  ], _ = {
341
- get: (w) => returnAtomValue(x(w)),
342
- set: (w, ...T) => {
341
+ get: (w) => returnAtomValue(b(w)),
342
+ set: (w, ...L) => {
343
343
  try {
344
- return A(w, ...T);
344
+ return B(w, ...L);
345
345
  } finally {
346
- b(), h();
346
+ x(), h();
347
347
  }
348
348
  },
349
- sub: (w, T) => {
350
- const v = C(w).l;
351
- return v.add(T), h(), () => {
352
- v.delete(T), S(w), h();
349
+ sub: (w, L) => {
350
+ const k = C(w).l;
351
+ return k.add(L), h(), () => {
352
+ k.delete(L), S(w), h();
353
353
  };
354
354
  }
355
355
  };
356
- return Object.defineProperty(_, BUILDING_BLOCKS, { value: B }), _;
356
+ return Object.defineProperty(_, BUILDING_BLOCKS, { value: A }), _;
357
357
  }, INTERNAL_buildStoreRev1 = buildStore;
358
358
  let keyCount = 0;
359
359
  function atom(o, n) {
@@ -388,37 +388,37 @@ function splitAtom(o, n) {
388
388
  let p = r.get(c);
389
389
  if (p)
390
390
  return p;
391
- const u = d && r.get(d), g = [], m = [];
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;
391
+ const u = d && r.get(d), g = [], f = [];
392
+ return c.forEach((m, h) => {
393
+ const x = h;
394
+ f[h] = x;
395
+ const b = u && u.atomList[u.keyList.indexOf(x)];
396
+ if (b) {
397
+ g[h] = b;
398
398
  return;
399
399
  }
400
400
  const y = (j) => {
401
- const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(b);
401
+ const C = j(l), S = j(o), _ = a(S, C == null ? void 0 : C.arr).keyList.indexOf(x);
402
402
  if (_ < 0 || _ >= S.length) {
403
- const w = c[a(c).keyList.indexOf(b)];
403
+ const w = c[a(c).keyList.indexOf(x)];
404
404
  if (w)
405
405
  return w;
406
406
  throw new Error("splitAtom: index out of bounds for read");
407
407
  }
408
408
  return S[_];
409
- }, A = (j, C, S) => {
410
- const B = j(l), _ = j(o), T = a(_, B == null ? void 0 : B.arr).keyList.indexOf(b);
411
- if (T < 0 || T >= _.length)
409
+ }, B = (j, C, S) => {
410
+ const A = j(l), _ = j(o), L = a(_, A == null ? void 0 : A.arr).keyList.indexOf(x);
411
+ if (L < 0 || L >= _.length)
412
412
  throw new Error("splitAtom: index out of bounds for write");
413
- const k = isFunction(S) ? S(_[T]) : S;
414
- Object.is(_[T], k) || C(o, [
415
- ..._.slice(0, T),
416
- k,
417
- ..._.slice(T + 1)
413
+ const v = isFunction(S) ? S(_[L]) : S;
414
+ Object.is(_[L], v) || C(o, [
415
+ ..._.slice(0, L),
416
+ v,
417
+ ..._.slice(L + 1)
418
418
  ]);
419
419
  };
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;
420
+ g[h] = isWritable(o) ? atom(y, B) : atom(y);
421
+ }), u && u.keyList.length === f.length && u.keyList.every((m, h) => m === f[h]) ? p = u : p = { arr: c, atomList: g, keyList: f }, r.set(c, p), p;
422
422
  }, l = atom((c) => {
423
423
  const d = c(l), p = c(o);
424
424
  return a(p, d == null ? void 0 : d.arr);
@@ -454,17 +454,17 @@ function splitAtom(o, n) {
454
454
  case "move": {
455
455
  const u = c(i).indexOf(p.atom), g = p.before ? c(i).indexOf(p.before) : c(i).length;
456
456
  if (u >= 0 && g >= 0) {
457
- const m = c(o);
457
+ const f = c(o);
458
458
  u < g ? d(o, [
459
- ...m.slice(0, u),
460
- ...m.slice(u + 1, g),
461
- m[u],
462
- ...m.slice(g)
459
+ ...f.slice(0, u),
460
+ ...f.slice(u + 1, g),
461
+ f[u],
462
+ ...f.slice(g)
463
463
  ]) : d(o, [
464
- ...m.slice(0, g),
465
- m[u],
466
- ...m.slice(g, u),
467
- ...m.slice(u + 1)
464
+ ...f.slice(0, g),
465
+ f[u],
466
+ ...f.slice(g, u),
467
+ ...f.slice(u + 1)
468
468
  ]);
469
469
  }
470
470
  break;
@@ -490,19 +490,19 @@ function createJSONStorage(o = () => {
490
490
  let a, l;
491
491
  const i = {
492
492
  getItem: (p, u) => {
493
- var g, m;
494
- const f = (b) => {
495
- if (b = b || "", a !== b) {
493
+ var g, f;
494
+ const m = (x) => {
495
+ if (x = x || "", a !== x) {
496
496
  try {
497
- l = JSON.parse(b, n == null ? void 0 : n.reviver);
497
+ l = JSON.parse(x, n == null ? void 0 : n.reviver);
498
498
  } catch {
499
499
  return u;
500
500
  }
501
- a = b;
501
+ a = x;
502
502
  }
503
503
  return l;
504
- }, h = (m = (g = o()) == null ? void 0 : g.getItem(p)) != null ? m : null;
505
- return isPromiseLike$1(h) ? h.then(f) : f(h);
504
+ }, h = (f = (g = o()) == null ? void 0 : g.getItem(p)) != null ? f : null;
505
+ return isPromiseLike$1(h) ? h.then(m) : m(h);
506
506
  },
507
507
  setItem: (p, u) => {
508
508
  var g;
@@ -515,12 +515,12 @@ function createJSONStorage(o = () => {
515
515
  var u;
516
516
  return (u = o()) == null ? void 0 : u.removeItem(p);
517
517
  }
518
- }, c = (p) => (u, g, m) => p(u, (f) => {
518
+ }, c = (p) => (u, g, f) => p(u, (m) => {
519
519
  let h;
520
520
  try {
521
- h = JSON.parse(f || "");
521
+ h = JSON.parse(m || "");
522
522
  } catch {
523
- h = m;
523
+ h = f;
524
524
  }
525
525
  g(h);
526
526
  });
@@ -533,8 +533,8 @@ function createJSONStorage(o = () => {
533
533
  if (!(o() instanceof window.Storage))
534
534
  return () => {
535
535
  };
536
- const g = (m) => {
537
- m.storageArea === o() && m.key === p && u(m.newValue);
536
+ const g = (f) => {
537
+ f.storageArea === o() && f.key === p && u(f.newValue);
538
538
  };
539
539
  return window.addEventListener("storage", g), () => {
540
540
  window.removeEventListener("storage", g);
@@ -1200,8 +1200,29 @@ const useSelectedBlocksDisplayChild = () => ({
1200
1200
  );
1201
1201
  return [o, n, r];
1202
1202
  }, removeNestedBlocks = (o, n) => {
1203
- const r = [], a = filter(o, (l) => includes(n, l._id) || includes(n, l._parent) ? (r.push(l._id), !1) : !0);
1204
- return isEmpty(r) ? a : removeNestedBlocks(a, r);
1203
+ let r = [...o], a = [];
1204
+ n.forEach((d) => {
1205
+ const p = r.find((f) => f._id === d);
1206
+ if (!p || !p._parent) return;
1207
+ const u = p._parent, g = r.filter((f) => f._parent === u);
1208
+ if (g.length === 2) {
1209
+ const f = g.find((m) => m._id !== d);
1210
+ if (f && f._type === "Text") {
1211
+ const m = r.find((h) => h._id === u);
1212
+ m && "content" in m && (r = r.map((h) => {
1213
+ if (h._id === u) {
1214
+ const x = { ...h, content: f.content };
1215
+ return Object.keys(f).forEach((b) => {
1216
+ b.startsWith("content-") && (x[b] = f[b]);
1217
+ }), x;
1218
+ }
1219
+ return h;
1220
+ }), a.push(f._id));
1221
+ }
1222
+ }
1223
+ });
1224
+ const l = [...n, ...a], i = [], c = filter(r, (d) => includes(l, d._id) || includes(l, d._parent) ? (i.push(d._id), !1) : !0);
1225
+ return isEmpty(i) ? c : removeNestedBlocks(c, i);
1205
1226
  }, useRemoveBlocks = () => {
1206
1227
  const [o] = useBlocksStore(), [n, r] = useSelectedBlockIds(), { setNewBlocks: a } = useBlocksStoreUndoableActions();
1207
1228
  return useCallback(
@@ -1255,19 +1276,43 @@ const useSelectedBlocksDisplayChild = () => ({
1255
1276
  { store: builderStore }
1256
1277
  );
1257
1278
  function insertBlocksAtPosition(o, n, r, a) {
1258
- let l = o.filter((d) => !d._parent);
1259
- r && (l = o.filter((d) => d._parent === r));
1260
- const i = !isNaN(a) || a > -1 ? Math.min(a, l.length) : l.length;
1261
- let c = o.length;
1262
- for (let d = 0, p = 0; d < o.length; d++)
1263
- if (o[d]._parent === r) {
1264
- if (p === i) {
1265
- c = d;
1279
+ const l = [...n];
1280
+ let i = [...o];
1281
+ if (r) {
1282
+ const u = o.find((g) => g._id === r);
1283
+ if (u && u.content !== void 0 && u.content !== "" && !o.some((f) => f._parent === r)) {
1284
+ const m = {
1285
+ _id: generateUUID(),
1286
+ _parent: r,
1287
+ _type: "Text",
1288
+ content: u.content
1289
+ };
1290
+ Object.keys(u).forEach((h) => {
1291
+ h.startsWith("content-") && (m[h] = u[h]);
1292
+ }), l.unshift(m), i = i.map((h) => {
1293
+ if (h._id === r) {
1294
+ const x = { ...h, content: "" };
1295
+ return Object.keys(x).forEach((b) => {
1296
+ b.startsWith("content-") && (x[b] = "");
1297
+ }), x;
1298
+ }
1299
+ return h;
1300
+ });
1301
+ }
1302
+ }
1303
+ let c = i.filter((u) => !u._parent);
1304
+ r && (c = i.filter((u) => u._parent === r));
1305
+ const d = !isNaN(a) || a > -1 ? Math.min(a, c.length) : c.length;
1306
+ let p = i.length;
1307
+ for (let u = 0, g = 0; u < i.length; u++)
1308
+ if (i[u]._parent === r) {
1309
+ if (g === d) {
1310
+ p = u;
1266
1311
  break;
1267
1312
  }
1268
- p++;
1313
+ g++;
1269
1314
  }
1270
- return !r && a !== void 0 && a >= l.length && (c = o.length), [...o.slice(0, c), ...n, ...o.slice(c)];
1315
+ return !r && a !== void 0 && a >= c.length && (p = i.length), [...i.slice(0, p), ...l, ...i.slice(p)];
1271
1316
  }
1272
1317
  function flattenTree(o) {
1273
1318
  let n = [];
@@ -1289,15 +1334,65 @@ function moveNode(o, n, r, a) {
1289
1334
  }
1290
1335
  return !1;
1291
1336
  }
1337
+ function handleOldParentTextBlock(o, n) {
1338
+ if (!n || !n._parent) return o;
1339
+ const r = n._parent, a = o.find((i) => i._id === r);
1340
+ if (!a) return o;
1341
+ const l = o.filter((i) => i._parent === r);
1342
+ if (l.length === 2) {
1343
+ const i = l.find((c) => c._id !== n._id);
1344
+ if (i && i._type === "Text" && "content" in a)
1345
+ return o.map((d) => {
1346
+ if (d._id === r) {
1347
+ const p = { ...d, content: i.content };
1348
+ return Object.keys(i).forEach((u) => {
1349
+ u.startsWith("content-") && (p[u] = i[u]);
1350
+ }), p;
1351
+ }
1352
+ return d;
1353
+ }).filter((d) => d._id !== i._id);
1354
+ }
1355
+ return o;
1356
+ }
1357
+ function handleNewParentTextBlock(o, n, r) {
1358
+ if (!r || r === "root") return o;
1359
+ const a = o.find((l) => l._id === r);
1360
+ if (!a) return o;
1361
+ if (a.content !== void 0 && a.content !== "" && !o.some((i) => i._parent === r && i._id !== n._id)) {
1362
+ const c = {
1363
+ _id: generateUUID(),
1364
+ _parent: r,
1365
+ _type: "Text",
1366
+ content: a.content
1367
+ };
1368
+ Object.keys(a).forEach((u) => {
1369
+ u.startsWith("content-") && (c[u] = a[u]);
1370
+ });
1371
+ const d = o.map((u) => {
1372
+ if (u._id === r) {
1373
+ const g = { ...u, content: "" };
1374
+ return Object.keys(g).forEach((f) => {
1375
+ f.startsWith("content-") && (g[f] = "");
1376
+ }), g;
1377
+ }
1378
+ return u;
1379
+ }), p = d.findIndex((u) => u._id === n._id);
1380
+ return p !== -1 ? [...d.slice(0, p), c, ...d.slice(p)] : [c, ...d];
1381
+ }
1382
+ return o;
1383
+ }
1292
1384
  function moveBlocksWithChildren(o, n, r, a) {
1293
1385
  if (!n) return o;
1294
- r = r || "root";
1295
- const i = new TreeModel().parse({ _id: "root", children: getBlocksTree(o) });
1296
- if (moveNode(i, n, r, a)) {
1297
- const c = flattenTree(i), d = c.find((p) => p._id === n);
1298
- return d && (d._parent = r === "root" ? null : r), c.shift(), c;
1386
+ const l = o.find((u) => u._id === n);
1387
+ if (!l) return o;
1388
+ let i = handleOldParentTextBlock(o, l);
1389
+ const c = r || "root", p = new TreeModel().parse({ _id: "root", children: getBlocksTree(i) });
1390
+ if (moveNode(p, n, c, a)) {
1391
+ let u = flattenTree(p);
1392
+ const g = u.find((f) => f._id === n);
1393
+ return g && (g._parent = c === "root" ? null : c), u.shift(), r && (u = handleNewParentTextBlock(u, l, r)), u;
1299
1394
  }
1300
- return o;
1395
+ return i;
1301
1396
  }
1302
1397
  const useBlocksStoreManager = () => {
1303
1398
  const [, o] = useBlocksStore(), { postMessage: n } = useBroadcastChannel(), r = useUpdateBlockAtom();
@@ -1344,65 +1439,65 @@ const useBlocksStoreManager = () => {
1344
1439
  updateBlocksProps: c
1345
1440
  } = useBlocksStoreManager();
1346
1441
  return {
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);
1442
+ moveBlocks: (x, b, y) => {
1443
+ const B = map(x, (C) => {
1444
+ const A = n.find((L) => L._id === C)._parent || null, w = n.filter((L) => A ? L._parent === A : !L._parent).map((L) => L._id).indexOf(C);
1445
+ return { _id: C, oldParent: A, oldPosition: w };
1446
+ }), j = B.find(({ _id: C }) => C === x[0]);
1447
+ j && j.oldParent === b && j.oldPosition === y || (i(x, b, y), o({
1448
+ undo: () => each(B, ({ _id: C, oldParent: S, oldPosition: A }) => {
1449
+ i([C], S, A);
1355
1450
  }),
1356
- redo: () => i(b, x, y)
1451
+ redo: () => i(x, b, y)
1357
1452
  }));
1358
1453
  },
1359
- addBlocks: (b, x, y) => {
1360
- a(b, x, y), o({
1361
- undo: () => l(map(b, "_id")),
1362
- redo: () => a(b, x, y)
1454
+ addBlocks: (x, b, y) => {
1455
+ a(x, b, y), o({
1456
+ undo: () => l(map(x, "_id")),
1457
+ redo: () => a(x, b, y)
1363
1458
  });
1364
1459
  },
1365
- removeBlocks: (b) => {
1460
+ removeBlocks: (x) => {
1366
1461
  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"))
1462
+ const b = (j = first(x)) == null ? void 0 : j._parent, B = n.filter((C) => b ? C._parent === b : !C._parent).indexOf(first(x));
1463
+ l(map(x, "_id")), o({
1464
+ undo: () => a(x, b, B),
1465
+ redo: () => l(map(x, "_id"))
1371
1466
  });
1372
1467
  },
1373
- updateBlocks: (b, x, y) => {
1374
- let A = [];
1468
+ updateBlocks: (x, b, y) => {
1469
+ let B = [];
1375
1470
  if (y)
1376
- A = map(b, (j) => ({ _id: j, ...y }));
1471
+ B = map(x, (j) => ({ _id: j, ...y }));
1377
1472
  else {
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;
1473
+ const j = keys(b);
1474
+ B = map(x, (C) => {
1475
+ const S = n.find((_) => _._id === C), A = { _id: C };
1476
+ return each(j, (_) => A[_] = S[_]), A;
1382
1477
  });
1383
1478
  }
1384
- c(map(b, (j) => ({ _id: j, ...x }))), o({
1385
- undo: () => c(A),
1386
- redo: () => c(map(b, (j) => ({ _id: j, ...x })))
1479
+ c(map(x, (j) => ({ _id: j, ...b }))), o({
1480
+ undo: () => c(B),
1481
+ redo: () => c(map(x, (j) => ({ _id: j, ...b })))
1387
1482
  });
1388
1483
  },
1389
- updateBlocksRuntime: (b, x) => {
1390
- c(map(b, (y) => ({ _id: y, ...x })));
1484
+ updateBlocksRuntime: (x, b) => {
1485
+ c(map(x, (y) => ({ _id: y, ...b })));
1391
1486
  },
1392
- setNewBlocks: (b) => {
1393
- r(b), o({
1487
+ setNewBlocks: (x) => {
1488
+ r(x), o({
1394
1489
  undo: () => r(n),
1395
- redo: () => r(b)
1490
+ redo: () => r(x)
1396
1491
  });
1397
1492
  },
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)
1493
+ updateMultipleBlocksProps: (x) => {
1494
+ let b = [];
1495
+ b = map(x, (y) => {
1496
+ const B = keys(y), j = n.find((S) => S._id === y._id), C = {};
1497
+ return each(B, (S) => C[S] = j[S]), C;
1498
+ }), c(x), o({
1499
+ undo: () => c(b),
1500
+ redo: () => c(x)
1406
1501
  });
1407
1502
  }
1408
1503
  };
@@ -1438,33 +1533,35 @@ import.meta.vitest && describe("canDropBlock Function", () => {
1438
1533
  const useAddBlock = () => {
1439
1534
  const [o] = useBlocksStore(), [, n] = useSelectedBlockIds(), { addBlocks: r } = useBlocksStoreUndoableActions(), a = useCallback(
1440
1535
  (i, c, d) => {
1441
- var f;
1536
+ var m;
1442
1537
  for (let h = 0; h < i.length; h++) {
1443
- const { _id: b } = i[h];
1538
+ const { _id: x } = i[h];
1444
1539
  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;
1540
+ const b = filter(i, { _parent: x });
1541
+ for (let y = 0; y < b.length; y++)
1542
+ b[y]._parent = i[h]._id;
1448
1543
  }
1449
1544
  const p = first(i);
1450
1545
  let u, g;
1451
- return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(f = first(i)) == null ? void 0 : f._id]), first(i);
1546
+ return c && (u = find(o, { _id: c }), i[0]._parent = c, g = c), !(u ? canAcceptChildBlock(u == null ? void 0 : u._type, p._type) : !0) && u && (i[0]._parent = u._parent, g = u._parent), r(i, g, d), n([(m = first(i)) == null ? void 0 : m._id]), first(i);
1452
1547
  },
1453
1548
  [r, o, n]
1454
1549
  );
1455
1550
  return { addCoreBlock: useCallback(
1456
1551
  (i, c, d) => {
1457
1552
  if (has(i, "blocks")) {
1458
- const x = i.blocks;
1459
- return a(x, c, d);
1553
+ const b = i.blocks;
1554
+ return a(b, c, d);
1460
1555
  }
1461
1556
  const p = generateUUID(), u = getDefaultBlockProps(i.type), g = {
1462
1557
  _type: i.type,
1463
1558
  _id: p,
1464
- ...u
1559
+ ...u,
1560
+ ...has(i, "_name") && { _name: i._name },
1561
+ ...has(i, "partialBlockId") && { partialBlockId: i.partialBlockId }
1465
1562
  };
1466
- let m, f;
1467
- return c && (m = find(o, { _id: c }), g._parent = c, f = c), !canAcceptChildBlock(m == null ? void 0 : m._type, g._type) && m && (g._parent = m._parent, f = m._parent), r([g], f, d), n([g._id]), g;
1563
+ let f, m;
1564
+ return c && (f = find(o, { _id: c }), g._parent = c, m = c), !canAcceptChildBlock(f == null ? void 0 : f._type, g._type) && f && (g._parent = f._parent, m = f._parent), r([g], m, d), n([g._id]), g;
1468
1565
  },
1469
1566
  [r, a, o, n]
1470
1567
  ), addPredefinedBlock: a };
@@ -2910,43 +3007,43 @@ const getBlockWithChildren = (o, n) => {
2910
3007
  return isEmpty(c) ? !1 : (has(l, "_parent") && isEmpty(l._parent) && delete l._parent, { ...l, ...c });
2911
3008
  })
2912
3009
  ), addLangToPrompt = (o, n, r) => !n || r !== "content" ? o : `${o}. Generate content in ${get(LANGUAGES, n, n)} language.`, askAiProcessingAtom = atom$1(!1), useAskAi = () => {
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];
3010
+ 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, f = (m, h) => {
3011
+ const x = cloneDeep(h.find((b) => b._id === m));
3012
+ for (const b in x) {
3013
+ const y = x[b];
2917
3014
  if (typeof y == "string" && startsWith(y, STYLES_KEY)) {
2918
- const { baseClasses: A, classes: j } = getSplitChaiClasses(y);
2919
- b[x] = compact(flattenDeep([A, j])).join(" ");
3015
+ const { baseClasses: B, classes: j } = getSplitChaiClasses(y);
3016
+ x[b] = compact(flattenDeep([B, j])).join(" ");
2920
3017
  } else
2921
- x !== "_id" && delete b[x];
3018
+ b !== "_id" && delete x[b];
2922
3019
  }
2923
- return b;
3020
+ return x;
2924
3021
  };
2925
3022
  return {
2926
3023
  askAi: useCallback(
2927
- async (f, h, b, x) => {
3024
+ async (m, h, x, b) => {
2928
3025
  if (l) {
2929
3026
  n(!0), a(null);
2930
3027
  try {
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;
3028
+ const y = p === u ? "" : p, B = m === "content" ? pickOnlyAIProps(cloneDeep(getBlockWithChildren(h, d)), p) : [f(h, d)], j = await l(m, addLangToPrompt(x, g, m), B, y), { blocks: C, error: S } = j;
2932
3029
  if (S) {
2933
3030
  a(S);
2934
3031
  return;
2935
3032
  }
2936
- if (f === "styles") {
2937
- const B = C.map((_) => {
3033
+ if (m === "styles") {
3034
+ const A = C.map((_) => {
2938
3035
  for (const w in _)
2939
3036
  w !== "_id" && (_[w] = `${STYLES_KEY},${_[w]}`);
2940
3037
  return _;
2941
3038
  });
2942
- c(B);
3039
+ c(A);
2943
3040
  } else
2944
3041
  i(C);
2945
- x && x(j);
3042
+ b && b(j);
2946
3043
  } catch (y) {
2947
3044
  a(y);
2948
3045
  } finally {
2949
- n(!1), x && x();
3046
+ n(!1), b && b();
2950
3047
  }
2951
3048
  }
2952
3049
  },
@@ -2994,11 +3091,11 @@ const useBlockHighlight = () => {
2994
3091
  ), clearHighlight: () => {
2995
3092
  lastHighlighted && (lastHighlighted.removeAttribute("data-highlighted"), lastHighlighted = null);
2996
3093
  }, lastHighlighted };
2997
- }, globalBlocksStoreAtom = atom({}), globalBlocksLoadingStateAtom = atom({}), useGlobalBlocksStore = () => {
2998
- const [o, n] = useAtom(globalBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
2999
- return { getGlobalBlocks: r, reset: a };
3000
- }, useWatchGlobalBlocks = () => {
3001
- const [o] = useBlocksStore(), [n, r] = useAtom(globalBlocksStoreAtom), [a, l] = useAtom(globalBlocksLoadingStateAtom), i = useBuilderProp("getGlobalBlockBlocks", async (d) => []), c = useMemo(() => o.filter((p) => p._type === "GlobalBlock").filter((p) => p._type === "GlobalBlock").map((p) => p.globalBlock), [o]);
3094
+ }, partialBlocksStoreAtom = atom({}), partialBlocksLoadingStateAtom = atom({}), usePartailBlocksStore = () => {
3095
+ const [o, n] = useAtom(partialBlocksStoreAtom), r = useCallback((l) => get(o, l, []), [o]), a = useCallback(() => n({}), [n]);
3096
+ return { getPartailBlocks: r, reset: a };
3097
+ }, useWatchPartailBlocks = () => {
3098
+ const [o] = useBlocksStore(), [n, r] = useAtom(partialBlocksStoreAtom), [a, l] = useAtom(partialBlocksLoadingStateAtom), i = useBuilderProp("getPartialBlockBlocks", async (d) => []), c = useMemo(() => o.filter((d) => d._type === "PartialBlock").map((d) => d.partialBlockId), [o]);
3002
3099
  useEffect(() => {
3003
3100
  forEach(c, (d) => {
3004
3101
  has(n, d) || get(a, `${d}.loading`, !1) || (l((p) => ({ ...p, [d]: { loading: !0, error: null } })), i(d).then((p) => {
@@ -3016,22 +3113,26 @@ const useBlockHighlight = () => {
3016
3113
  }, [
3017
3114
  i,
3018
3115
  n,
3019
- c,
3020
3116
  a,
3021
3117
  r,
3022
- l
3118
+ l,
3119
+ c
3023
3120
  ]);
3024
- }, globalBlocksListAtom = atom({}), useGlobalBlocksList = () => {
3025
- const [o, n] = useState(!1), [r, a] = useAtom(globalBlocksListAtom), l = useBuilderProp("getGlobalBlocks", async () => []), i = useCallback(async () => {
3026
- n(!0);
3027
- const c = await l();
3028
- a(c), n(!1);
3029
- }, [l, a]);
3121
+ }, partialBlocksListAtom = atom({}), usePartialBlocksList = () => {
3122
+ const [o, n] = useState(!1), [r, a] = useState(null), [l, i] = useAtom(partialBlocksListAtom), c = useBuilderProp("getPartialBlocks", async () => []), d = useCallback(async () => {
3123
+ n(!0), a(null);
3124
+ try {
3125
+ const p = await c();
3126
+ i(p), n(!1);
3127
+ } catch (p) {
3128
+ a(p instanceof Error ? p.message : "Failed to fetch partial blocks"), n(!1);
3129
+ }
3130
+ }, [c, i]);
3030
3131
  return useEffect(() => {
3031
- i();
3032
- }, []), { data: r, isLoading: o, refetch: i };
3132
+ d();
3133
+ }, []), { data: l, isLoading: o, refetch: d, error: r };
3033
3134
  }, useBuilderReset = () => {
3034
- const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = useGlobalBlocksStore();
3135
+ const o = useSetAtom$1(historyStatesAtom), { clear: n } = useUndoManager(), [, r] = useSelectedBlockIds(), { clearHighlight: a } = useBlockHighlight(), [, l] = useSelectedStylingBlocks(), [, i] = useAtom(aiAssistantActiveAtom), { reset: c } = usePartailBlocksStore();
3035
3136
  return () => {
3036
3137
  r([]), l([]), a(), n(), i(!1), o({ undoCount: 0, redoCount: 0 }), c();
3037
3138
  };
@@ -3079,13 +3180,13 @@ const useBlockHighlight = () => {
3079
3180
  (a, l = null) => {
3080
3181
  const i = [];
3081
3182
  each(a, (c) => {
3082
- const d = o.find((f) => f._id === c);
3183
+ const d = o.find((m) => m._id === c);
3083
3184
  l ? l === "root" && (l = null) : l = d._parent;
3084
3185
  const g = filter(
3085
3186
  o,
3086
- (f) => isString(l) ? f._parent === l : !f._parent
3087
- ).indexOf(d) + 1, m = getDuplicatedBlocks(o, c, l);
3088
- r(m, l, g), i.push(get(m, "0._id", ""));
3187
+ (m) => isString(l) ? m._parent === l : !m._parent
3188
+ ).indexOf(d) + 1, f = getDuplicatedBlocks(o, c, l);
3189
+ r(f, l, g), i.push(get(f, "0._id", ""));
3089
3190
  }), n(i);
3090
3191
  },
3091
3192
  [o, n]
@@ -3178,13 +3279,13 @@ const useBlockHighlight = () => {
3178
3279
  return map(i, (c) => {
3179
3280
  const d = o(c), p = a;
3180
3281
  let { classes: u, baseClasses: g } = getSplitChaiClasses(get(d, l.prop, `${STYLES_KEY},`));
3181
- return each(p, (m) => {
3182
- const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3282
+ return each(p, (f) => {
3283
+ const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3183
3284
  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());
3186
- }), each(p, (m) => {
3187
- const f = m.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${f}(?=\\s|$)`, "g");
3285
+ const x = first(f.split(":"));
3286
+ includes(["2xl", "xl", "lg", "md", "sm"], x) && p.push(f.split(":").pop().trim());
3287
+ }), each(p, (f) => {
3288
+ const m = f.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = new RegExp(`(^|\\s)${m}(?=\\s|$)`, "g");
3188
3289
  g = g.replace(h, " ").replace(/\s+/g, " ").trim();
3189
3290
  }), {
3190
3291
  ids: [d._id],
@@ -3318,7 +3419,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3318
3419
  }
3319
3420
  });
3320
3421
  useResizeObserver(o, () => g(), o !== null);
3321
- const m = get(n, "_parent", null), f = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3422
+ const f = get(n, "_parent", null), m = isEmpty(get(n, "_name", "")) ? get(n, "_type", "") : get(n, "_name", "");
3322
3423
  return !o || !n || d ? null : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
3323
3424
  "div",
3324
3425
  {
@@ -3335,16 +3436,16 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3335
3436
  onKeyDown: (h) => h.stopPropagation(),
3336
3437
  className: "isolate z-[999] flex h-6 items-center bg-blue-500 py-2 text-xs text-white",
3337
3438
  children: [
3338
- m && /* @__PURE__ */ jsx(
3439
+ f && /* @__PURE__ */ jsx(
3339
3440
  ArrowUpIcon,
3340
3441
  {
3341
3442
  className: "hover:scale-105",
3342
3443
  onClick: () => {
3343
- c([]), l([m]);
3444
+ c([]), l([f]);
3344
3445
  }
3345
3446
  }
3346
3447
  ),
3347
- /* @__PURE__ */ jsx(BlockActionLabel, { label: f, block: n }),
3448
+ /* @__PURE__ */ jsx(BlockActionLabel, { label: m, block: n }),
3348
3449
  /* @__PURE__ */ jsxs("div", { className: "flex gap-2 px-1", children: [
3349
3450
  canAddChildBlock(get(n, "_type", "")) && /* @__PURE__ */ jsx(
3350
3451
  PlusIcon,
@@ -3415,15 +3516,15 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3415
3516
  <div class="frame-root h-full"></div>
3416
3517
  </body>
3417
3518
  </html>`, useKeyEventWatcher = (o) => {
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 } : {};
3519
+ const [n, r] = useSelectedBlockIds(), a = useSelectedBlock(), l = useRemoveBlocks(), i = useDuplicateBlocks(), { undo: c, redo: d } = useUndoManager(), [, p] = useCutBlockIds(), [, u] = useCopyBlockIds(), { canPaste: g, pasteBlocks: f } = usePasteBlocks(), m = o ? { document: o } : {};
3419
3520
  useHotkeys("ctrl+z,command+z", () => c(), {}, [c]), useHotkeys("ctrl+y,command+y", () => d(), {}, [d]), useHotkeys("ctrl+x,command+x", () => p(n), {}, [n, p]), useHotkeys("ctrl+c,command+c", () => u(n), {}, [n, u]), useHotkeys(
3420
3521
  "ctrl+v,command+v",
3421
3522
  () => {
3422
- g(n[0]) && m(n);
3523
+ g(n[0]) && f(n);
3423
3524
  },
3424
- { ...f, preventDefault: !0 },
3425
- [n, g, m]
3426
- ), useHotkeys("esc", () => r([]), f, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...f, preventDefault: !0 }, [
3525
+ { ...m, preventDefault: !0 },
3526
+ [n, g, f]
3527
+ ), useHotkeys("esc", () => r([]), m, [r]), useHotkeys("ctrl+d,command+d", () => i(n), { ...m, preventDefault: !0 }, [
3427
3528
  n,
3428
3529
  i
3429
3530
  ]), useHotkeys(
@@ -3431,7 +3532,7 @@ const pubsub = new PubSub(), draggedBlockAtom = atom$1(null), dropTargetBlockIdA
3431
3532
  (h) => {
3432
3533
  h.preventDefault(), canDeleteBlock(get(a, "_type", "")) && l(n);
3433
3534
  },
3434
- f,
3535
+ m,
3435
3536
  [n, l]
3436
3537
  );
3437
3538
  }, KeyboardHandler = () => {
@@ -3517,38 +3618,38 @@ function removeDataDrop() {
3517
3618
  const useDnd = () => {
3518
3619
  const { document: o } = useFrame(), [n, r] = useAtom$1(draggingFlagAtom), { addCoreBlock: a } = useAddBlock(), [, l] = useHighlightBlockId(), [, i] = useSelectedBlockIds(), { moveBlocks: c } = useBlocksStoreUndoableActions(), [d, p] = useAtom$1(draggedBlockAtom), [, u] = useAtom$1(dropTargetBlockIdAtom);
3519
3620
  if (!useFeature("dnd")) return {};
3520
- const m = () => {
3621
+ const f = () => {
3521
3622
  removePlaceholder(), r(!1), p(null), u(null), possiblePositions = [];
3522
3623
  };
3523
3624
  return iframeDocument = o, {
3524
3625
  isDragging: n,
3525
- onDragOver: (f) => {
3526
- f.preventDefault(), f.stopPropagation(), throttledDragOver(f);
3626
+ onDragOver: (m) => {
3627
+ m.preventDefault(), m.stopPropagation(), throttledDragOver(m);
3527
3628
  },
3528
- onDrop: (f) => {
3629
+ onDrop: (m) => {
3529
3630
  var S;
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) {
3534
- m();
3631
+ const h = dropTarget, b = getOrientation(h) === "vertical" ? m.clientY + ((S = iframeDocument == null ? void 0 : iframeDocument.defaultView) == null ? void 0 : S.scrollY) : m.clientX;
3632
+ dropIndex = calculateDropIndex(b, possiblePositions);
3633
+ const y = d, B = h.getAttribute("data-block-id"), j = dropTarget.getAttribute("data-dnd-dragged") !== "yes";
3634
+ if ((y == null ? void 0 : y._id) === B || !j) {
3635
+ f();
3535
3636
  return;
3536
3637
  }
3537
3638
  if (!has(y, "_id")) {
3538
- a(y, A === "canvas" ? null : A, dropIndex), setTimeout(m, 300);
3639
+ a(y, B === "canvas" ? null : B, dropIndex), setTimeout(f, 300);
3539
3640
  return;
3540
3641
  }
3541
3642
  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);
3643
+ C === null && (C = m.target.parentElement.getAttribute("data-block-id")), c([y._id], C === "canvas" ? null : C, dropIndex), f(), setTimeout(removePlaceholder, 300);
3543
3644
  },
3544
- onDragEnter: (f) => {
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([]);
3645
+ onDragEnter: (m) => {
3646
+ const h = m, x = h.target;
3647
+ dropTarget = x;
3648
+ const b = x.getAttribute("data-block-id"), y = x.getAttribute("data-dnd-dragged") !== "yes";
3649
+ u(b), h.stopPropagation(), h.preventDefault(), possiblePositions = [], y && calculatePossiblePositions(x), r(!0), l(""), i([]);
3549
3650
  },
3550
- onDragLeave: (f) => {
3551
- f.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3651
+ onDragLeave: (m) => {
3652
+ m.target.getAttribute("data-block-id") === "canvas" && (u(null), r(!1), removePlaceholder(), possiblePositions = []);
3552
3653
  }
3553
3654
  };
3554
3655
  };
@@ -3570,17 +3671,17 @@ const useHandleCanvasDblClick = (o, n) => {
3570
3671
  const g = u.getAttribute("data-block-type");
3571
3672
  if (!g || !r.includes(g))
3572
3673
  return;
3573
- const m = u.getAttribute("data-block-id");
3574
- if (!m) return;
3674
+ const f = u.getAttribute("data-block-id");
3675
+ if (!f) return;
3575
3676
  o.on("update", ({ editor: h }) => {
3576
3677
  console.log(h.getHTML());
3577
3678
  }), o.on("blur", () => {
3578
3679
  console.log("blur");
3579
3680
  const h = o.getHTML();
3580
- a([m], { content: h }), n.style.display = "none", u.style.visibility = "visible";
3581
- }), i(m);
3582
- const f = d(m).content;
3583
- 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);
3681
+ a([f], { content: h }), n.style.display = "none", u.style.visibility = "visible";
3682
+ }), i(f);
3683
+ const m = d(f).content;
3684
+ o.commands.setContent(m), 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);
3584
3685
  },
3585
3686
  [l, c, d, i, a, o, n]
3586
3687
  );
@@ -3621,17 +3722,17 @@ const useHandleCanvasDblClick = (o, n) => {
3621
3722
  return;
3622
3723
  const h = getElementByDataBlockId(n, first(r));
3623
3724
  if (h) {
3624
- const b = h.getAttribute("data-style-prop");
3625
- if (b) {
3626
- const x = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3627
- l([{ id: x, prop: b, blockId: y }]);
3725
+ const x = h.getAttribute("data-style-prop");
3726
+ if (x) {
3727
+ const b = h.getAttribute("data-style-id"), y = h.getAttribute("data-block-parent");
3728
+ l([{ id: b, prop: x, blockId: y }]);
3628
3729
  }
3629
3730
  }
3630
3731
  }, 100);
3631
3732
  }, [n, r, l, a]);
3632
3733
  const c = useEditor({
3633
3734
  extensions: [StarterKit]
3634
- }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), m = useHandleMouseLeave(), f = useDnd();
3735
+ }), d = useRef(null), p = useHandleCanvasDblClick(c, d.current), u = useHandleCanvasClick(), g = useHandleMouseMove(), f = useHandleMouseLeave(), m = useDnd();
3635
3736
  return /* @__PURE__ */ jsx(
3636
3737
  "div",
3637
3738
  {
@@ -3640,18 +3741,18 @@ const useHandleCanvasDblClick = (o, n) => {
3640
3741
  onClick: u,
3641
3742
  onDoubleClick: p,
3642
3743
  onMouseMove: g,
3643
- onMouseLeave: m,
3644
- ...omit(f, "isDragging"),
3645
- className: "relative h-full max-w-full p-px " + (f.isDragging ? "dragging" : ""),
3744
+ onMouseLeave: f,
3745
+ ...omit(m, "isDragging"),
3746
+ className: "relative h-full max-w-full p-px " + (m.isDragging ? "dragging" : ""),
3646
3747
  children: o
3647
3748
  }
3648
3749
  );
3649
3750
  }, getElementByDataBlockId = (o, n) => o.querySelector(`[data-block-id="${n}"]`), HeadTags = () => {
3650
3751
  const [o] = useTheme(), n = useThemeOptions(), [r] = useSelectedBlockIds(), [a] = useDarkMode(), [l] = useSelectedStylingBlocks(), [i] = useAtom$1(draggedBlockAtom), [c] = useAtom$1(dropTargetBlockIdAtom), { document: d, window: p } = useFrame(), [u] = useState(d == null ? void 0 : d.getElementById("highlighted-block")), [g] = useState(
3651
3752
  d == null ? void 0 : d.getElementById("selected-block")
3652
- ), [m] = useState(
3653
- d == null ? void 0 : d.getElementById("selected-styling-block")
3654
3753
  ), [f] = useState(
3754
+ d == null ? void 0 : d.getElementById("selected-styling-block")
3755
+ ), [m] = useState(
3655
3756
  d == null ? void 0 : d.getElementById("dragged-block")
3656
3757
  );
3657
3758
  useEffect(() => {
@@ -3676,8 +3777,8 @@ const useHandleCanvasDblClick = (o, n) => {
3676
3777
  forms,
3677
3778
  aspectRatio,
3678
3779
  containerQueries,
3679
- plugin(function({ addBase: x, theme: y }) {
3680
- x({
3780
+ plugin(function({ addBase: b, theme: y }) {
3781
+ b({
3681
3782
  "h1,h2,h3,h4,h5,h6": {
3682
3783
  fontFamily: y("fontFamily.heading")
3683
3784
  },
@@ -3691,27 +3792,27 @@ const useHandleCanvasDblClick = (o, n) => {
3691
3792
  ]
3692
3793
  });
3693
3794
  }, [o, n, p]), useEffect(() => {
3694
- g && (g.textContent = `${map(r, (x) => `[data-block-id="${x}"]`).join(",")}{
3795
+ g && (g.textContent = `${map(r, (b) => `[data-block-id="${b}"]`).join(",")}{
3695
3796
  outline: 1px solid ${r.length === 1 ? "#42a1fc !important" : "orange !important"}; outline-offset: -1px;
3696
3797
  }`);
3697
3798
  }, [r, g]), useEffect(() => {
3698
- f.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3699
- }, [i, f]), useEffect(() => {
3799
+ m.textContent = i ? `[data-block-id="${i._id}"], [data-block-id="${i._id}"] > * { pointer-events: none !important; opacity: 0.6 !important}` : "";
3800
+ }, [i, m]), useEffect(() => {
3700
3801
  u && (u.textContent = '[data-highlighted="true"]{ outline: 1px solid #42a1fc !important; outline-offset: -1px;}');
3701
3802
  }, [u]), useEffect(() => {
3702
- m && (m.textContent = `${map(l, ({ id: x }) => `[data-style-id="${x}"]`).join(",")}{
3803
+ f && (f.textContent = `${map(l, ({ id: b }) => `[data-style-id="${b}"]`).join(",")}{
3703
3804
  outline: 1px solid orange !important; outline-offset: -1px;
3704
3805
  }`);
3705
- }, [l, m]), useEffect(() => {
3806
+ }, [l, f]), useEffect(() => {
3706
3807
  d.querySelector("#drop-target-block").innerHTML = c ? `[data-block-id="${c}"]{ outline: 1px dashed orange !important; outline-offset: -1px;}` : "";
3707
3808
  }, [c, d]);
3708
3809
  const h = useMemo(
3709
3810
  () => getChaiThemeCssVariables(o),
3710
3811
  [o]
3711
- ), b = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3812
+ ), x = useMemo(() => getThemeFontsLinkMarkup(pick(o, ["fontFamily"])), [o]);
3712
3813
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3713
3814
  /* @__PURE__ */ jsx("style", { id: "chai-theme", children: h }),
3714
- /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: b } })
3815
+ /* @__PURE__ */ jsx("span", { id: "chai-fonts", dangerouslySetInnerHTML: { __html: x } })
3715
3816
  ] });
3716
3817
  }, ResizableCanvasWrapper = ({ children: o, onMount: n, onResize: r }) => {
3717
3818
  const [, a] = useSelectedBlockIds(), [, l] = useSelectedStylingBlocks(), i = useRef(null), c = useDebouncedCallback(
@@ -3788,10 +3889,13 @@ const getBlockRuntimeProps = memoize((o) => {
3788
3889
  [o]
3789
3890
  );
3790
3891
  }, BlockRenderer = ({ blockAtom: o, children: n }) => {
3791
- 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(
3892
+ 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), f = useMemo(
3792
3893
  () => u ? applyBinding(applyLanguage(r, l, a), d) : applyLanguage(r, l, a),
3793
3894
  [r, l, a, d, u]
3794
- ), 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(
3895
+ ), m = useMemo(() => getBlockTagAttributes(r), [r, getBlockTagAttributes]), h = useMemo(
3896
+ () => c(r._id, getBlockRuntimeProps(r._type)),
3897
+ [r._id, r._type, c, getBlockRuntimeProps]
3898
+ ), x = useMemo(() => !has(a, "dataProvider") || !isFunction$1(a.dataProvider) ? {} : a.dataProvider(r, l), [r, l, a]), b = useMemo(
3795
3899
  () => ({
3796
3900
  blockProps: {
3797
3901
  "data-block-id": r._id,
@@ -3799,16 +3903,25 @@ const getBlockRuntimeProps = memoize((o) => {
3799
3903
  },
3800
3904
  inBuilder: !0,
3801
3905
  lang: l || i,
3802
- ...m,
3803
3906
  ...f,
3907
+ ...m,
3804
3908
  ...h,
3805
- ...b
3909
+ ...x
3806
3910
  }),
3807
- [r, l, i, m, f, h, b]
3911
+ [
3912
+ r._id,
3913
+ r._type,
3914
+ l,
3915
+ i,
3916
+ f,
3917
+ m,
3918
+ h,
3919
+ x
3920
+ ]
3808
3921
  );
3809
- return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...x, children: n }) });
3810
- }, GlobalBlocksRenderer = ({ globalBlockId: o }) => {
3811
- const { getGlobalBlocks: n } = useGlobalBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3922
+ return isNull(g) || p.includes(r._id) ? null : /* @__PURE__ */ jsx(Suspense, { children: createElement(g, { ...b, children: n }) });
3923
+ }, PartialBlocksRenderer = ({ partialBlockId: o }) => {
3924
+ const { getPartailBlocks: n } = usePartailBlocksStore(), r = useMemo(() => n(o), [n, o]), a = useMemo(() => splitAtom(atom$1(r)), [r]);
3812
3925
  return isEmpty(r) ? null : /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: a, blocks: r });
3813
3926
  }, BlocksRenderer = ({
3814
3927
  blocks: o,
@@ -3821,7 +3934,7 @@ const getBlockRuntimeProps = memoize((o) => {
3821
3934
  ), i = useCallback((c) => filter(o, (d) => d._parent === c._id).length > 0, [o]);
3822
3935
  return map(l, (c) => {
3823
3936
  const d = a(c._id);
3824
- return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(GlobalBlocksRenderer, { globalBlockId: get(c, "globalBlock", "") }) }) : i(c) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }, c._id) : null;
3937
+ return d ? /* @__PURE__ */ jsx(BlockRenderer, { blockAtom: d, children: c._type === "GlobalBlock" || c._type === "PartialBlock" ? /* @__PURE__ */ jsx(Provider, { store: builderStore, children: /* @__PURE__ */ jsx(PartialBlocksRenderer, { partialBlockId: get(c, "partialBlockId", get(c, "globalBlock", "")) }) }) : i(c) ? /* @__PURE__ */ jsx(BlocksRenderer, { splitAtoms: r, blocks: o, parent: c._id }) : null }, c._id) : null;
3825
3938
  });
3826
3939
  }, PageBlocksRenderer = () => {
3827
3940
  const [o] = useBlocksStore();
@@ -3835,11 +3948,11 @@ const getBlockRuntimeProps = memoize((o) => {
3835
3948
  if (d < n) {
3836
3949
  const u = parseFloat((d / n).toFixed(2).toString());
3837
3950
  let g = {};
3838
- const m = p * u, f = d * u;
3951
+ const f = p * u, m = d * u;
3839
3952
  p && (g = {
3840
3953
  // Eureka! This is the formula to calculate the height of the scaled element. Thank you ChatGPT 4
3841
- height: 100 + (p - m) / m * 100 + "%",
3842
- width: 100 + (d - f) / f * 100 + "%"
3954
+ height: 100 + (p - f) / f * 100 + "%",
3955
+ width: 100 + (d - m) / m * 100 + "%"
3843
3956
  }), i({
3844
3957
  position: "relative",
3845
3958
  top: 0,
@@ -3856,43 +3969,43 @@ const getBlockRuntimeProps = memoize((o) => {
3856
3969
  c();
3857
3970
  }, [n, o, r, c]), l;
3858
3971
  }, getElementByStyleId = (o, n) => o.querySelector(`[data-style-id="${n}"]`), StaticCanvas = () => {
3859
- 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) => {
3860
- p((_) => ({ ..._, width: B }));
3972
+ 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, f] = useState([]), [, m] = useState([]), [, h] = useAtom$1(canvasIframeAtom), [x, b] = useSelectedStylingBlocks(), y = useBuilderProp("loading", !1), B = useBuilderProp("htmlDir", "ltr"), j = (A) => {
3973
+ p((_) => ({ ..._, width: A }));
3861
3974
  };
3862
3975
  useEffect(() => {
3863
3976
  if (!c.current) return;
3864
- const { clientWidth: B, clientHeight: _ } = c.current;
3865
- p({ width: B, height: _ });
3977
+ const { clientWidth: A, clientHeight: _ } = c.current;
3978
+ p({ width: A, height: _ });
3866
3979
  }, [c, n]);
3867
- const C = (B, _ = 0) => {
3868
- const { top: w } = B.getBoundingClientRect();
3980
+ const C = (A, _ = 0) => {
3981
+ const { top: w } = A.getBoundingClientRect();
3869
3982
  return w + _ >= 0 && w - _ <= window.innerHeight;
3870
3983
  };
3871
3984
  useEffect(() => {
3872
- var B, _;
3985
+ var A, _;
3873
3986
  if (a && a.type !== "Multiple" && i.current) {
3874
3987
  const w = getElementByDataBlockId(i.current.contentDocument, a._id);
3875
- w && (C(w) || (_ = (B = i.current) == null ? void 0 : B.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), m([w]));
3988
+ w && (C(w) || (_ = (A = i.current) == null ? void 0 : A.contentWindow) == null || _.scrollTo({ top: w.offsetTop, behavior: "smooth" }), f([w]));
3876
3989
  }
3877
3990
  }, [a]), useEffect(() => {
3878
- if (!isEmpty(b) && i.current) {
3879
- const B = getElementByStyleId(
3991
+ if (!isEmpty(x) && i.current) {
3992
+ const A = getElementByStyleId(
3880
3993
  i.current.contentDocument,
3881
- first(b).id
3994
+ first(x).id
3882
3995
  );
3883
- f(B ? [B] : [null]);
3996
+ m(A ? [A] : [null]);
3884
3997
  } else
3885
- f([null]);
3886
- }, [b]);
3998
+ m([null]);
3999
+ }, [x]);
3887
4000
  const S = useMemo(() => {
3888
- let B = IframeInitialContent;
3889
- return B = B.replace("__HTML_DIR__", A), o === "offline" && (B = B.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), B;
3890
- }, [o, A]);
4001
+ let A = IframeInitialContent;
4002
+ return A = A.replace("__HTML_DIR__", B), o === "offline" && (A = A.replace("https://chaibuilder.com/offline/tailwind.cdn.js", "/offline/tailwind.cdn.js")), A;
4003
+ }, [o, B]);
3891
4004
  return /* @__PURE__ */ jsx(ResizableCanvasWrapper, { onMount: j, onResize: j, children: /* @__PURE__ */ jsx(
3892
4005
  "div",
3893
4006
  {
3894
4007
  onClick: () => {
3895
- r([]), x([]);
4008
+ r([]), b([]);
3896
4009
  },
3897
4010
  onMouseLeave: () => setTimeout(() => l(""), 300),
3898
4011
  className: "relative mx-auto h-full w-full overflow-hidden",
@@ -3938,87 +4051,9 @@ const getBlockRuntimeProps = memoize((o) => {
3938
4051
  }, FallbackError = () => /* @__PURE__ */ jsx("div", { className: "h-full w-full rounded-md bg-red-200 p-4 text-red-500", children: /* @__PURE__ */ jsxs("div", { className: "flex h-full w-full flex-col items-center justify-center", children: [
3939
4052
  /* @__PURE__ */ jsx("p", { className: "font-semibold", children: "Oops! Something went wrong." }),
3940
4053
  /* @__PURE__ */ jsx("p", { children: "Please try again." })
3941
- ] }) }), TypeIcon = (o) => {
3942
- switch (o.type) {
3943
- case "GlobalBlock":
3944
- return /* @__PURE__ */ jsx(GlobeIcon, { className: "h-3 w-3 stroke-[2]" });
3945
- case "Image":
3946
- return /* @__PURE__ */ jsx(ImageIcon, { className: "h-3 w-3 stroke-[2]" });
3947
- case "Heading":
3948
- return /* @__PURE__ */ jsx(HeadingIcon, { className: "h-3 w-3 stroke-[2]" });
3949
- case "Text":
3950
- return /* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 stroke-[2]" });
3951
- case "Link":
3952
- return /* @__PURE__ */ jsx(Link1Icon, { className: "h-3 w-3 stroke-[2]" });
3953
- case "Video":
3954
- return /* @__PURE__ */ jsx(VideoIcon, { className: "h-3 w-3 stroke-[2]" });
3955
- case "RichText":
3956
- return /* @__PURE__ */ jsx(CursorTextIcon, { className: "h-3 w-3 stroke-[2]" });
3957
- case "Button":
3958
- case "DropdownButton":
3959
- return /* @__PURE__ */ jsx(ButtonIcon, { className: "h-3 w-3 stroke-[2]" });
3960
- case "CustomHTML":
3961
- return /* @__PURE__ */ jsx(CodeIcon, { className: "h-3 w-3 stroke-[2]" });
3962
- case "Divider":
3963
- return /* @__PURE__ */ jsx(DividerHorizontalIcon, { className: "h-3 w-3 stroke-[2]" });
3964
- case "Icon":
3965
- return /* @__PURE__ */ jsx(SketchLogoIcon, { className: "h-3 w-3 stroke-[2]" });
3966
- case "List":
3967
- return /* @__PURE__ */ jsx(RowsIcon, { className: "h-3 w-3 stroke-[2]" });
3968
- case "Paragraph":
3969
- return /* @__PURE__ */ jsx(TextIcon, { className: "h-3 w-3 stroke-[2]" });
3970
- case "Row":
3971
- return /* @__PURE__ */ jsx(Rows, { className: "h-3 w-3 stroke-[2]" });
3972
- case "Column":
3973
- return /* @__PURE__ */ jsx(Columns, { className: "h-3 w-3 stroke-[2]" });
3974
- case "ListItem":
3975
- return /* @__PURE__ */ jsx(ColumnsIcon, { className: "h-3 w-3 stroke-[2]" });
3976
- case "LineBreak":
3977
- return /* @__PURE__ */ jsx(SpaceBetweenVerticallyIcon, { className: "h-3 w-3 stroke-[2]" });
3978
- case "Form":
3979
- return /* @__PURE__ */ jsx(GroupIcon, { className: "h-3 w-3 stroke-[2]" });
3980
- case "Checkbox":
3981
- return /* @__PURE__ */ jsx(CheckboxIcon, { className: "h-3 w-3 stroke-[2]" });
3982
- case "FormButton":
3983
- return /* @__PURE__ */ jsx(ButtonIcon, { className: "h-3 w-3 stroke-[2]" });
3984
- case "Input":
3985
- case "TextArea":
3986
- return /* @__PURE__ */ jsx(InputIcon, { className: "h-3 w-3 stroke-[2]" });
3987
- case "Radio":
3988
- return /* @__PURE__ */ jsx(RadiobuttonIcon, { className: "h-3 w-3 stroke-[2]" });
3989
- case "Select":
3990
- return /* @__PURE__ */ jsx(DropdownMenuIcon, { className: "h-3 w-3 stroke-[2]" });
3991
- case "Table":
3992
- return /* @__PURE__ */ jsx(TableIcon, { className: "h-3 w-3 stroke-[2]" });
3993
- case "TableHead":
3994
- return /* @__PURE__ */ jsx(BorderTopIcon, { className: "h-3 w-3 stroke-[2]" });
3995
- case "TableBody":
3996
- return /* @__PURE__ */ jsx(BorderAllIcon, { className: "h-3 w-3 stroke-[2]" });
3997
- case "TableRow":
3998
- return /* @__PURE__ */ jsx(ViewHorizontalIcon, { className: "h-3 w-3 stroke-[2]" });
3999
- case "TableCell":
4000
- return /* @__PURE__ */ jsx(DragHandleHorizontalIcon, { className: "h-3 w-3 stroke-[2]" });
4001
- case "DataProvider":
4002
- return /* @__PURE__ */ jsx(DatabaseIcon, { className: "h-3 w-3 stroke-[2]" });
4003
- case "Box":
4004
- return /* @__PURE__ */ jsx(BoxIcon, { className: "h-3 w-3 stroke-[2]" });
4005
- case "Dropdown":
4006
- return /* @__PURE__ */ jsx(DropdownMenuIcon, { className: "h-3 w-3 stroke-[2]" });
4007
- case "DropdownContent":
4008
- return /* @__PURE__ */ jsx(ReaderIcon, { className: "h-3 w-3 stroke-[2]" });
4009
- case "Slider":
4010
- return /* @__PURE__ */ jsx(UnfoldHorizontal, { className: "h-3 w-3 stroke-[2]" });
4011
- case "Slides":
4012
- return /* @__PURE__ */ jsx(AlignHorizontalJustifyStart, { className: "h-3 w-3 stroke-[2]" });
4013
- case "Slide":
4014
- return /* @__PURE__ */ jsx(AppWindowIcon, { className: "h-3 w-3 stroke-[2]" });
4015
- case "SlidePreviousButton":
4016
- return /* @__PURE__ */ jsx(PanelRightOpen, { className: "h-3 w-3 stroke-[2]" });
4017
- case "SlideNextButton":
4018
- return /* @__PURE__ */ jsx(PanelRightClose, { className: "h-3 w-3 stroke-[2]" });
4019
- default:
4020
- return /* @__PURE__ */ jsx(BoxModelIcon, { className: "h-3 w-3 stroke-[2]" });
4021
- }
4054
+ ] }) }), ICON_CLASS = "h-3 w-3 stroke-[2]", TypeIcon = (o) => {
4055
+ const n = useRegisteredChaiBlocks(), r = get(n, [o == null ? void 0 : o.type, "icon"]);
4056
+ return r ? React__default.createElement(r, { className: ICON_CLASS }) : /* @__PURE__ */ jsx(BoxModelIcon, { className: ICON_CLASS });
4022
4057
  }, Breadcrumb = () => {
4023
4058
  const o = useSelectedBlockHierarchy(), [, n] = useSelectedBlockIds(), { highlightBlock: r } = useBlockHighlight();
4024
4059
  return /* @__PURE__ */ jsx("div", { className: "-mx-2 border-t border-border bg-background px-2 py-1 text-xs text-muted-foreground", children: /* @__PURE__ */ jsxs("ol", { className: "flex items-center whitespace-nowrap", children: [
@@ -4158,20 +4193,20 @@ const getBlockRuntimeProps = memoize((o) => {
4158
4193
  }, ThemeConfigPanel = React.memo(({ className: o = "" }) => {
4159
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) => {
4160
4195
  a(y);
4161
- }, m = () => {
4162
- const y = l.find((A) => Object.keys(A)[0] === r);
4196
+ }, f = () => {
4197
+ const y = l.find((B) => Object.keys(B)[0] === r);
4163
4198
  if (y) {
4164
- const A = Object.values(y)[0];
4165
- A && typeof A == "object" && "fontFamily" in A && "borderRadius" in A && "colors" in A ? d(A) : console.error("Invalid preset structure:", A);
4199
+ const B = Object.values(y)[0];
4200
+ B && typeof B == "object" && "fontFamily" in B && "borderRadius" in B && "colors" in B ? d(B) : console.error("Invalid preset structure:", B);
4166
4201
  } else
4167
4202
  console.error("Preset not found:", r);
4168
- }, f = useDebouncedCallback(
4169
- (y, A) => {
4203
+ }, m = useDebouncedCallback(
4204
+ (y, B) => {
4170
4205
  d(() => ({
4171
4206
  ...c,
4172
4207
  fontFamily: {
4173
4208
  ...c.fontFamily,
4174
- [y.replace(/font-/g, "")]: A
4209
+ [y.replace(/font-/g, "")]: B
4175
4210
  }
4176
4211
  }));
4177
4212
  },
@@ -4186,11 +4221,11 @@ const getBlockRuntimeProps = memoize((o) => {
4186
4221
  },
4187
4222
  [c],
4188
4223
  200
4189
- ), b = useDebouncedCallback(
4190
- (y, A) => {
4224
+ ), x = useDebouncedCallback(
4225
+ (y, B) => {
4191
4226
  d(() => {
4192
4227
  const j = get(c, `colors.${y}`);
4193
- return n ? set(j, 1, A) : set(j, 0, A), {
4228
+ return n ? set(j, 1, B) : set(j, 0, B), {
4194
4229
  ...c,
4195
4230
  colors: {
4196
4231
  ...c.colors,
@@ -4201,18 +4236,18 @@ const getBlockRuntimeProps = memoize((o) => {
4201
4236
  },
4202
4237
  [c],
4203
4238
  200
4204
- ), x = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([A]) => {
4205
- const j = get(c, `colors.${A}.${n ? 1 : 0}`);
4239
+ ), b = (y) => /* @__PURE__ */ jsx("div", { className: "grid grid-cols-1", children: Object.entries(y.items).map(([B]) => {
4240
+ const j = get(c, `colors.${B}.${n ? 1 : 0}`);
4206
4241
  return /* @__PURE__ */ jsxs("div", { className: "mt-1 flex items-center gap-x-2", children: [
4207
4242
  /* @__PURE__ */ jsx(
4208
4243
  ColorPickerInput,
4209
4244
  {
4210
4245
  value: j,
4211
- onChange: (C) => b(A, C)
4246
+ onChange: (C) => x(B, C)
4212
4247
  }
4213
4248
  ),
4214
- /* @__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" : "") })
4215
- ] }, A);
4249
+ /* @__PURE__ */ jsx(Label, { className: "text-xs font-normal leading-tight text-slate-600", children: B.split(/(?=[A-Z])/).join(" ").replace(/-/g, " ").split(" ").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ") + (!B.toLowerCase().includes("foreground") && !B.toLowerCase().includes("border") && !B.toLowerCase().includes("input") && !B.toLowerCase().includes("ring") && !B.toLowerCase().includes("background") ? " Background" : "") })
4250
+ ] }, B);
4216
4251
  }) });
4217
4252
  return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
4218
4253
  /* @__PURE__ */ jsxs("div", { className: cn$1("no-scrollbar h-full w-full overflow-y-auto", o), children: [
@@ -4238,18 +4273,18 @@ const getBlockRuntimeProps = memoize((o) => {
4238
4273
  className: "w-full text-sm",
4239
4274
  disabled: r === "",
4240
4275
  variant: "default",
4241
- onClick: m,
4276
+ onClick: f,
4242
4277
  children: u("Apply")
4243
4278
  }
4244
4279
  ) })
4245
4280
  ] }),
4246
4281
  /* @__PURE__ */ jsxs("div", { className: cn$1("space-y-2", o), children: [
4247
- (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, A]) => /* @__PURE__ */ jsx(
4282
+ (p == null ? void 0 : p.fontFamily) && /* @__PURE__ */ jsx("div", { className: "grid gap-4", children: Object.entries(p.fontFamily).map(([y, B]) => /* @__PURE__ */ jsx(
4248
4283
  FontSelector,
4249
4284
  {
4250
4285
  label: y,
4251
- value: c.fontFamily[y.replace(/font-/g, "")] || A[Object.keys(A)[0]],
4252
- onChange: (j) => f(y, j)
4286
+ value: c.fontFamily[y.replace(/font-/g, "")] || B[Object.keys(B)[0]],
4287
+ onChange: (j) => m(y, j)
4253
4288
  },
4254
4289
  y
4255
4290
  )) }),
@@ -4262,7 +4297,7 @@ const getBlockRuntimeProps = memoize((o) => {
4262
4297
  ] }),
4263
4298
  (p == null ? void 0 : p.colors) && /* @__PURE__ */ jsxs("div", { className: "mt-4 space-y-0.5", children: [
4264
4299
  /* @__PURE__ */ jsx(Label, { className: "text-sm text-slate-800", children: u("Colors") }),
4265
- /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => x(y)) }, n ? "dark" : "light")
4300
+ /* @__PURE__ */ jsx("div", { className: "w-full space-y-4 pt-2", children: p.colors.map((y) => b(y)) }, n ? "dark" : "light")
4266
4301
  ] })
4267
4302
  ] }),
4268
4303
  /* @__PURE__ */ jsx("br", {}),
@@ -4272,38 +4307,7 @@ const getBlockRuntimeProps = memoize((o) => {
4272
4307
  ] }),
4273
4308
  i && /* @__PURE__ */ jsx("div", { className: "absolute bottom-4 w-full", children: React.createElement(i) })
4274
4309
  ] });
4275
- }), GlobalBlockSettings = () => {
4276
- const o = useSelectedBlock(), { data: n, refetch: r, isLoading: a } = useGlobalBlocksList(), l = useUpdateBlocksProps();
4277
- return /* @__PURE__ */ jsxs("div", { children: [
4278
- /* @__PURE__ */ jsx("label", { className: "text-sm", children: "Choose a global block" }),
4279
- /* @__PURE__ */ jsxs(
4280
- "select",
4281
- {
4282
- className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
4283
- value: (o == null ? void 0 : o.globalBlock) || "",
4284
- onChange: (i) => {
4285
- var c;
4286
- l([o._id], {
4287
- globalBlock: i.target.value,
4288
- _name: `Global: ${startCase((c = get(n, i.target.value, "")) == null ? void 0 : c.name)}`
4289
- });
4290
- },
4291
- children: [
4292
- /* @__PURE__ */ jsx("option", { value: "", children: "Select a global block" }),
4293
- Object.keys(n).map((i) => /* @__PURE__ */ jsx("option", { value: i, children: n[i].name || i }, i))
4294
- ]
4295
- }
4296
- ),
4297
- /* @__PURE__ */ jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsx(
4298
- "button",
4299
- {
4300
- onClick: r,
4301
- className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
4302
- children: a ? "Loading..." : "Refresh List"
4303
- }
4304
- ) })
4305
- ] });
4306
- }, ICON_PICKER_CONTAINER_ID = "icon-picker-item-container", removeSizeAttributes = (o) => {
4310
+ }), ICON_PICKER_CONTAINER_ID = "icon-picker-item-container", removeSizeAttributes = (o) => {
4307
4311
  try {
4308
4312
  return o.replace(/<svg([^>]*)\sheight="[^"]*"([^>]*)>/gi, "<svg$1$2>").replace(/<svg([^>]*)\swidth="[^"]*"([^>]*)>/gi, "<svg$1$2>");
4309
4313
  } catch {
@@ -4436,19 +4440,19 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4436
4440
  }, [a, o]);
4437
4441
  const u = (h) => Array.isArray(h) ? "array" : typeof h == "object" && h !== null ? "object" : "value", g = React.useCallback(
4438
4442
  (h) => {
4439
- const b = (x) => r === "value" ? x === "value" || x === "object" : r === "array" ? x === "array" : x === r;
4440
- h.type === "object" ? (c((x) => [...x, h.key]), p(h.value)) : b(h.type) && (n([...i, h.key].join(".")), l(!1));
4443
+ const x = (b) => r === "value" ? b === "value" || b === "object" : r === "array" ? b === "array" : b === r;
4444
+ h.type === "object" ? (c((b) => [...b, h.key]), p(h.value)) : x(h.type) && (n([...i, h.key].join(".")), l(!1));
4441
4445
  },
4442
4446
  [i, n, r]
4443
- ), m = React.useCallback(() => {
4447
+ ), f = React.useCallback(() => {
4444
4448
  if (i.length > 0) {
4445
4449
  const h = i.slice(0, -1);
4446
- c(h), p(h.reduce((b, x) => b[x], o));
4450
+ c(h), p(h.reduce((x, b) => x[b], o));
4447
4451
  }
4448
- }, [i, o]), f = React.useMemo(() => Object.entries(d).map(([h, b]) => ({
4452
+ }, [i, o]), m = React.useMemo(() => Object.entries(d).map(([h, x]) => ({
4449
4453
  key: h,
4450
- value: b,
4451
- type: u(b)
4454
+ value: x,
4455
+ type: u(x)
4452
4456
  })).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]);
4453
4457
  return /* @__PURE__ */ jsxs(Popover, { open: a, onOpenChange: l, children: [
4454
4458
  /* @__PURE__ */ jsxs(Tooltip, { children: [
@@ -4470,11 +4474,11 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4470
4474
  /* @__PURE__ */ jsxs(CommandList, { children: [
4471
4475
  /* @__PURE__ */ jsx(CommandEmpty, { children: "No option found." }),
4472
4476
  /* @__PURE__ */ jsxs(CommandGroup, { children: [
4473
- i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: m, className: "flex items-center text-sm", children: [
4477
+ i.length > 0 && /* @__PURE__ */ jsxs(CommandItem, { onSelect: f, className: "flex items-center text-sm", children: [
4474
4478
  /* @__PURE__ */ jsx(ChevronLeft, { className: "mr-2 h-4 w-4" }),
4475
4479
  "Back"
4476
4480
  ] }),
4477
- f.map((h) => /* @__PURE__ */ jsxs(
4481
+ m.map((h) => /* @__PURE__ */ jsxs(
4478
4482
  CommandItem,
4479
4483
  {
4480
4484
  value: h.key,
@@ -4490,8 +4494,8 @@ function NestedPathSelector({ data: o, onSelect: n, dataType: r = "value" }) {
4490
4494
  size: "sm",
4491
4495
  variant: "ghost",
4492
4496
  className: "h-6 px-2 hover:bg-primary hover:text-primary-foreground",
4493
- onClick: (b) => {
4494
- b.stopPropagation(), n([...i, h.key].join(".")), l(!1);
4497
+ onClick: (x) => {
4498
+ x.stopPropagation(), n([...i, h.key].join(".")), l(!1);
4495
4499
  },
4496
4500
  children: "Select"
4497
4501
  }
@@ -4659,16 +4663,16 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4659
4663
  const c = useRef(null), d = useRef(a || ""), p = usePageExternalData();
4660
4664
  useEffect(() => {
4661
4665
  if (o) {
4662
- const m = document.createElement("style");
4663
- return m.id = "rte-modal-styles", m.innerHTML = `
4666
+ const f = document.createElement("style");
4667
+ return f.id = "rte-modal-styles", f.innerHTML = `
4664
4668
  /* Ensure the NestedPathSelector popover appears above the dialog */
4665
4669
  .rte-path-selector + [data-radix-popper-content-wrapper],
4666
4670
  [data-radix-popper-content-wrapper] {
4667
4671
  z-index: 9999 !important;
4668
4672
  }
4669
- `, document.head.appendChild(m), () => {
4670
- const f = document.getElementById("rte-modal-styles");
4671
- f && f.remove();
4673
+ `, document.head.appendChild(f), () => {
4674
+ const m = document.getElementById("rte-modal-styles");
4675
+ m && m.remove();
4672
4676
  };
4673
4677
  }
4674
4678
  }, [o]);
@@ -4689,13 +4693,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4689
4693
  Underline
4690
4694
  ],
4691
4695
  content: a || "",
4692
- onUpdate: ({ editor: m }) => {
4693
- const f = m.getHTML();
4694
- l(f);
4696
+ onUpdate: ({ editor: f }) => {
4697
+ const m = f.getHTML();
4698
+ l(m);
4695
4699
  },
4696
- onBlur: ({ editor: m }) => {
4697
- const f = m.getHTML();
4698
- i(r, f);
4700
+ onBlur: ({ editor: f }) => {
4701
+ const m = f.getHTML();
4702
+ i(r, m);
4699
4703
  },
4700
4704
  editorProps: {
4701
4705
  attributes: {
@@ -4710,22 +4714,22 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4710
4714
  }, [o, u]), useEffect(() => {
4711
4715
  c.current && u && (c.current.__chaiRTE = u);
4712
4716
  }, [u, o]);
4713
- const g = (m) => {
4717
+ const g = (f) => {
4714
4718
  if (!u) return;
4715
- const f = `{{${m}}}`;
4719
+ const m = `{{${f}}}`;
4716
4720
  u.commands.focus();
4717
- const { from: h, to: b } = u.state.selection;
4718
- if (h !== b)
4719
- u.chain().deleteSelection().insertContent(f).run();
4721
+ const { from: h, to: x } = u.state.selection;
4722
+ if (h !== x)
4723
+ u.chain().deleteSelection().insertContent(m).run();
4720
4724
  else {
4721
- 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));
4725
+ const { state: y } = u, B = y.selection.from, j = y.doc.textBetween(Math.max(0, B - 1), B), C = y.doc.textBetween(B, Math.min(B + 1, y.doc.content.size));
4722
4726
  let S = "";
4723
- A > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
4724
- let B = "";
4725
- C && C !== " " && !/[.,!?;:]/.test(C) && (B = " "), u.chain().insertContent(S + f + B).run();
4727
+ B > 0 && j !== " " && !/[.,!?;:]/.test(j) && (S = " ");
4728
+ let A = "";
4729
+ C && C !== " " && !/[.,!?;:]/.test(C) && (A = " "), u.chain().insertContent(S + m + A).run();
4726
4730
  }
4727
4731
  };
4728
- 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: [
4732
+ return /* @__PURE__ */ jsx(Dialog, { open: o, onOpenChange: (f) => !f && n(), children: /* @__PURE__ */ jsxs(DialogContent, { className: "max-h-[90vh] overflow-y-auto sm:max-w-[800px]", children: [
4729
4733
  /* @__PURE__ */ jsx(DialogHeader, { children: /* @__PURE__ */ jsxs(DialogTitle, { className: "flex items-center justify-between pr-8", children: [
4730
4734
  /* @__PURE__ */ jsx("span", { children: "Rich Text Editor" }),
4731
4735
  p && Object.keys(p).length > 0 && /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -4758,12 +4762,12 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4758
4762
  ],
4759
4763
  content: r || "",
4760
4764
  onUpdate: ({ editor: h }) => {
4761
- const b = h.getHTML();
4762
- a(b), c || u(b);
4765
+ const x = h.getHTML();
4766
+ a(x), c || u(x);
4763
4767
  },
4764
4768
  onBlur: ({ editor: h }) => {
4765
- const b = h.getHTML();
4766
- l(o, b);
4769
+ const x = h.getHTML();
4770
+ l(o, x);
4767
4771
  },
4768
4772
  editorProps: {
4769
4773
  attributes: {
@@ -4776,9 +4780,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4776
4780
  }, [g]), useEffect(() => {
4777
4781
  u(r || "");
4778
4782
  }, [r]);
4779
- const m = (h) => {
4783
+ const f = (h) => {
4780
4784
  a(h);
4781
- }, f = () => {
4785
+ }, m = () => {
4782
4786
  d(!1), g && g.commands.setContent(p);
4783
4787
  };
4784
4788
  return /* @__PURE__ */ jsxs(Fragment, { children: [
@@ -4790,10 +4794,10 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4790
4794
  RTEModal,
4791
4795
  {
4792
4796
  isOpen: c,
4793
- onClose: f,
4797
+ onClose: m,
4794
4798
  id: o,
4795
4799
  value: p,
4796
- onChange: m,
4800
+ onChange: f,
4797
4801
  onBlur: l
4798
4802
  }
4799
4803
  )
@@ -4803,74 +4807,74 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4803
4807
  pageTypes: n,
4804
4808
  onChange: r
4805
4809
  }) => {
4806
- var T;
4807
- 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;
4810
+ var L;
4811
+ const { t: a } = useTranslation(), l = useBuilderProp("searchPageTypeItems", (v, k) => []), [i, c] = useState(!1), [d, p] = useState(!1), [u, g] = useState("page"), [f, m] = useState(""), [h, x] = useState([]), [b, y] = useState(-1), B = useRef(null), j = (L = n == null ? void 0 : n.find((v) => v.key === u)) == null ? void 0 : L.name;
4808
4812
  useEffect(() => {
4809
- if (f(""), b([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4810
- const k = split(o, ":"), v = get(k, 1, "page") || "page";
4811
- g(v), (async () => {
4812
- const N = await l(v, [get(k, 2, "page")]);
4813
- N && Array.isArray(N) && f(get(N, [0, "name"], ""));
4813
+ if (m(""), x([]), y(-1), p(!1), !o || i || !startsWith(o, "pageType:")) return;
4814
+ const v = split(o, ":"), k = get(v, 1, "page") || "page";
4815
+ g(k), (async () => {
4816
+ const E = await l(k, [get(v, 2, "page")]);
4817
+ E && Array.isArray(E) && m(get(E, [0, "name"], ""));
4814
4818
  })();
4815
4819
  }, [o]);
4816
4820
  const C = useDebouncedCallback(
4817
- async (k) => {
4818
- if (isEmpty(k))
4819
- b([]);
4821
+ async (v) => {
4822
+ if (isEmpty(v))
4823
+ x([]);
4820
4824
  else {
4821
- const v = await l(u, k);
4822
- b(v);
4825
+ const k = await l(u, v);
4826
+ x(k);
4823
4827
  }
4824
4828
  c(!1), y(-1);
4825
4829
  },
4826
4830
  [u],
4827
4831
  300
4828
- ), S = (k) => {
4829
- const v = ["pageType", u, k.id];
4830
- v[1] && (r(v.join(":")), f(k.name), p(!1), b([]), y(-1));
4831
- }, B = (k) => {
4832
- switch (k.key) {
4832
+ ), S = (v) => {
4833
+ const k = ["pageType", u, v.id];
4834
+ k[1] && (r(k.join(":")), m(v.name), p(!1), x([]), y(-1));
4835
+ }, A = (v) => {
4836
+ switch (v.key) {
4833
4837
  case "ArrowDown":
4834
- k.preventDefault(), y((v) => v < h.length - 1 ? v + 1 : v);
4838
+ v.preventDefault(), y((k) => k < h.length - 1 ? k + 1 : k);
4835
4839
  break;
4836
4840
  case "ArrowUp":
4837
- k.preventDefault(), y((v) => v > 0 ? v - 1 : v);
4841
+ v.preventDefault(), y((k) => k > 0 ? k - 1 : k);
4838
4842
  break;
4839
4843
  case "Enter":
4840
- if (k.preventDefault(), h.length === 0) return;
4841
- x >= 0 && S(h[x]);
4844
+ if (v.preventDefault(), h.length === 0) return;
4845
+ b >= 0 && S(h[b]);
4842
4846
  break;
4843
4847
  case "Escape":
4844
- k.preventDefault(), _();
4848
+ v.preventDefault(), _();
4845
4849
  break;
4846
4850
  }
4847
4851
  };
4848
4852
  useEffect(() => {
4849
- if (x >= 0 && A.current) {
4850
- const k = A.current.children[x];
4851
- k == null || k.scrollIntoView({ block: "nearest" });
4853
+ if (b >= 0 && B.current) {
4854
+ const v = B.current.children[b];
4855
+ v == null || v.scrollIntoView({ block: "nearest" });
4852
4856
  }
4853
- }, [x]);
4857
+ }, [b]);
4854
4858
  const _ = () => {
4855
- f(""), b([]), y(-1), p(!1), r("");
4856
- }, w = (k) => {
4857
- f(k), p(!isEmpty(k)), c(!0), C(k);
4859
+ m(""), x([]), y(-1), p(!1), r("");
4860
+ }, w = (v) => {
4861
+ m(v), p(!isEmpty(v)), c(!0), C(v);
4858
4862
  };
4859
4863
  return /* @__PURE__ */ jsxs("div", { children: [
4860
- /* @__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)) }),
4864
+ /* @__PURE__ */ jsx("select", { name: "pageType", value: u, onChange: (v) => g(v.target.value), children: map(n, (v) => /* @__PURE__ */ jsx("option", { value: v.key, children: v.name }, v.key)) }),
4861
4865
  u && /* @__PURE__ */ jsxs("div", { className: "group relative mt-2 flex items-center", children: [
4862
4866
  /* @__PURE__ */ jsx(
4863
4867
  "input",
4864
4868
  {
4865
4869
  type: "text",
4866
- value: m,
4867
- onChange: (k) => w(k.target.value),
4868
- onKeyDown: B,
4870
+ value: f,
4871
+ onChange: (v) => w(v.target.value),
4872
+ onKeyDown: A,
4869
4873
  placeholder: a(`Search ${j ?? ""}`),
4870
4874
  className: "w-full rounded-md border border-gray-300 p-2 pr-16"
4871
4875
  }
4872
4876
  ),
4873
- /* @__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" }) }) })
4877
+ /* @__PURE__ */ jsx("div", { className: "absolute bottom-2 right-2 top-3 flex items-center gap-1.5", children: f && /* @__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" }) }) })
4874
4878
  ] }),
4875
4879
  (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: [
4876
4880
  /* @__PURE__ */ jsx("div", { className: "h-6 w-full animate-pulse rounded bg-gray-200" }),
@@ -4878,24 +4882,24 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4878
4882
  ] }) : d && isEmpty(h) ? /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-center p-4 text-sm text-gray-500", children: [
4879
4883
  a("No results found for"),
4880
4884
  ' "',
4881
- m,
4885
+ f,
4882
4886
  '"'
4883
- ] }) : /* @__PURE__ */ jsx("ul", { ref: A, children: map(h == null ? void 0 : h.slice(0, 20), (k, v) => /* @__PURE__ */ jsxs(
4887
+ ] }) : /* @__PURE__ */ jsx("ul", { ref: B, children: map(h == null ? void 0 : h.slice(0, 20), (v, k) => /* @__PURE__ */ jsxs(
4884
4888
  "li",
4885
4889
  {
4886
- onClick: () => S(k),
4887
- 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"}`,
4890
+ onClick: () => S(v),
4891
+ className: `cursor-pointer p-2 text-xs ${o != null && o.includes(v.id) ? "bg-blue-200" : k === b ? "bg-gray-100" : "hover:bg-gray-100"}`,
4888
4892
  children: [
4889
- k.name,
4893
+ v.name,
4890
4894
  " ",
4891
- k.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4895
+ v.slug && /* @__PURE__ */ jsxs("small", { className: "font-light text-gray-500", children: [
4892
4896
  "( ",
4893
- k.slug,
4897
+ v.slug,
4894
4898
  " )"
4895
4899
  ] })
4896
4900
  ]
4897
4901
  },
4898
- k.id
4902
+ v.id
4899
4903
  )) }) })
4900
4904
  ] });
4901
4905
  }, LinkField = ({ schema: o, formData: n, onChange: r }) => {
@@ -4977,30 +4981,30 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
4977
4981
  }, [a]), useEffect(() => {
4978
4982
  u != null && u.length && !find(u, { _id: o == null ? void 0 : o.currentSlide }) && n({ ...o, currentSlide: get(u, "0._id") });
4979
4983
  }, [o, u]);
4980
- const m = () => {
4981
- const b = findIndex(u, { _id: g });
4982
- if (b > -1) {
4983
- const x = (b + 1) % u.length, y = get(u, [x, "_id"]);
4984
+ const f = () => {
4985
+ const x = findIndex(u, { _id: g });
4986
+ if (x > -1) {
4987
+ const b = (x + 1) % u.length, y = get(u, [b, "_id"]);
4984
4988
  if (!y) return;
4985
4989
  n({ ...o, currentSlide: y }), c([y]);
4986
4990
  }
4987
- }, f = () => {
4988
- const b = findIndex(u, { _id: g });
4989
- if (b > -1) {
4990
- const x = (b - 1 + u.length) % u.length, y = get(u, [x, "_id"]);
4991
+ }, m = () => {
4992
+ const x = findIndex(u, { _id: g });
4993
+ if (x > -1) {
4994
+ const b = (x - 1 + u.length) % u.length, y = get(u, [b, "_id"]);
4991
4995
  if (!y) return;
4992
4996
  n({ ...o, currentSlide: y }), c([y]);
4993
4997
  }
4994
4998
  }, h = () => {
4995
- const b = i(
4999
+ const x = i(
4996
5000
  { styles: "#styles:,h-full w-full min-w-full", type: "Slide" },
4997
5001
  p == null ? void 0 : p._id
4998
- ), x = b == null ? void 0 : b._id;
4999
- x && (n({ ...o, currentSlide: x }), c([x]));
5002
+ ), b = x == null ? void 0 : x._id;
5003
+ b && (n({ ...o, currentSlide: b }), c([b]));
5000
5004
  };
5001
5005
  return /* @__PURE__ */ jsxs("div", { className: "space-y-1.5 px-2", children: [
5002
5006
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 pb-2 text-[12px]", children: [
5003
- /* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
5007
+ /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronLeft, { className: "h-3 w-3 stroke-[3]" }) }),
5004
5008
  /* @__PURE__ */ jsx("div", { className: "whitespace-nowrap text-center text-[10px] text-slate-500", children: g ? /* @__PURE__ */ jsxs("span", { className: "", children: [
5005
5009
  /* @__PURE__ */ jsxs("b", { className: "text-[12px]", children: [
5006
5010
  " ",
@@ -5009,7 +5013,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5009
5013
  "/",
5010
5014
  u.length
5011
5015
  ] }) : "-" }),
5012
- /* @__PURE__ */ jsx("button", { onClick: m, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
5016
+ /* @__PURE__ */ jsx("button", { onClick: f, className: "rounded bg-gray-200 p-1.5 hover:opacity-80", children: /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3 stroke-[3]" }) }),
5013
5017
  /* @__PURE__ */ jsxs(
5014
5018
  "button",
5015
5019
  {
@@ -5074,9 +5078,9 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5074
5078
  value: o == null ? void 0 : o.autoplayInterval,
5075
5079
  className: "text-xs",
5076
5080
  pattern: "[0-9]*",
5077
- onChange: (b) => {
5078
- let x = b.target.value;
5079
- x.length && (x = x.replace("-", "")), n({ ...o, autoplayInterval: x });
5081
+ onChange: (x) => {
5082
+ let b = x.target.value;
5083
+ b.length && (b = b.replace("-", "")), n({ ...o, autoplayInterval: b });
5080
5084
  }
5081
5085
  }
5082
5086
  )
@@ -5113,67 +5117,67 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5113
5117
  required: p,
5114
5118
  schema: u,
5115
5119
  formData: g,
5116
- onChange: m
5120
+ onChange: f
5117
5121
  }) => {
5118
- 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(
5119
- (v) => {
5120
- const N = (E) => /[.,!?;:]/.test(E), I = (E, D, M) => {
5121
- let R = "", O = "";
5122
- const $ = D > 0 ? E[D - 1] : "", H = D < E.length ? E[D] : "";
5123
- return D > 0 && ($ === "." || !N($) && $ !== " ") && (R = " "), D < E.length && !N(H) && H !== " " && (O = " "), {
5124
- text: R + M + O,
5125
- prefixLength: R.length,
5122
+ const { selectedLang: m, fallbackLang: h, languages: x } = useLanguages(), b = isEmpty(x) ? "" : isEmpty(m) ? h : m, y = get(LANGUAGES, b, b), B = usePageExternalData(), j = useSelectedBlock(), C = useRegisteredChaiBlocks(), S = get(C, [j == null ? void 0 : j._type, "i18nProps"], []) || [], [A, _] = useState(null), w = useCallback(
5123
+ (k) => {
5124
+ const E = (N) => /[.,!?;:]/.test(N), T = (N, D, M) => {
5125
+ let P = "", O = "";
5126
+ const $ = D > 0 ? N[D - 1] : "", H = D < N.length ? N[D] : "";
5127
+ return D > 0 && ($ === "." || !E($) && $ !== " ") && (P = " "), D < N.length && !E(H) && H !== " " && (O = " "), {
5128
+ text: P + M + O,
5129
+ prefixLength: P.length,
5126
5130
  suffixLength: O.length
5127
5131
  };
5128
- }, L = document.getElementById(o);
5129
- if (!L) return;
5130
- const P = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5131
- if (P && (P.querySelector(".ProseMirror") || P.__chaiRTE)) {
5132
- const E = P.__chaiRTE;
5133
- if (E) {
5134
- const D = `{{${v}}}`;
5135
- E.commands.focus();
5136
- const { from: M, to: R } = E.state.selection;
5137
- if (M !== R)
5138
- E.chain().deleteSelection().insertContent(D).run();
5132
+ }, I = document.getElementById(o);
5133
+ if (!I) return;
5134
+ const R = document.getElementById(`chai-rte-${o}`) || document.getElementById(`chai-rte-modal-${o}`);
5135
+ if (R && (R.querySelector(".ProseMirror") || R.__chaiRTE)) {
5136
+ const N = R.__chaiRTE;
5137
+ if (N) {
5138
+ const D = `{{${k}}}`;
5139
+ N.commands.focus();
5140
+ const { from: M, to: P } = N.state.selection;
5141
+ if (M !== P)
5142
+ N.chain().deleteSelection().insertContent(D).run();
5139
5143
  else {
5140
- 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));
5144
+ const { state: $ } = N, H = $.selection.from, F = $.doc.textBetween(Math.max(0, H - 1), H), U = $.doc.textBetween(H, Math.min(H + 1, $.doc.content.size));
5141
5145
  let z = "";
5142
- H > 0 && F !== " " && !N(F) && (z = " ");
5146
+ H > 0 && F !== " " && !E(F) && (z = " ");
5143
5147
  let W = "";
5144
- U && U !== " " && !N(U) && (W = " "), E.chain().insertContent(z + D + W).run();
5148
+ U && U !== " " && !E(U) && (W = " "), N.chain().insertContent(z + D + W).run();
5145
5149
  }
5146
- setTimeout(() => m(E.getHTML(), {}, o), 100);
5150
+ setTimeout(() => f(N.getHTML(), {}, o), 100);
5147
5151
  return;
5148
5152
  }
5149
5153
  } else {
5150
- const E = L, D = E.selectionStart || 0, M = E.value || "", R = E.selectionEnd || D;
5151
- if (R > D) {
5152
- const U = `{{${v}}}`, { text: z } = I(M, D, U), W = M.slice(0, D) + z + M.slice(R);
5153
- m(W, {}, o);
5154
+ const N = I, D = N.selectionStart || 0, M = N.value || "", P = N.selectionEnd || D;
5155
+ if (P > D) {
5156
+ const U = `{{${k}}}`, { text: z } = T(M, D, U), W = M.slice(0, D) + z + M.slice(P);
5157
+ f(W, {}, o);
5154
5158
  return;
5155
5159
  }
5156
- const $ = `{{${v}}}`, { text: H } = I(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5157
- m(F, {}, o);
5160
+ const $ = `{{${k}}}`, { text: H } = T(M, D, $), F = M.slice(0, D) + H + M.slice(D);
5161
+ f(F, {}, o);
5158
5162
  }
5159
5163
  },
5160
- [o, m, g, j == null ? void 0 : j._id]
5164
+ [o, f, g, j == null ? void 0 : j._id]
5161
5165
  );
5162
5166
  if (d)
5163
5167
  return null;
5164
5168
  if (u.type === "boolean") return /* @__PURE__ */ jsx("div", { className: n, children: a });
5165
- const k = S == null ? void 0 : S.includes(o.replace("root.", ""));
5169
+ const v = S == null ? void 0 : S.includes(o.replace("root.", ""));
5166
5170
  if (u.type === "array") {
5167
- const v = B === o;
5171
+ const k = A === o;
5168
5172
  return /* @__PURE__ */ jsxs("div", { className: `${n} relative`, children: [
5169
5173
  u.title && /* @__PURE__ */ jsxs(
5170
5174
  "label",
5171
5175
  {
5172
5176
  htmlFor: o,
5173
- onClick: () => _(v ? null : o),
5177
+ onClick: () => _(k ? null : o),
5174
5178
  className: "flex cursor-pointer items-center gap-x-1 py-1 leading-tight duration-200 hover:bg-slate-100",
5175
5179
  children: [
5176
- v ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5180
+ k ? /* @__PURE__ */ jsx(ChevronDown, { className: "h-3 w-3" }) : /* @__PURE__ */ jsx(ChevronRight, { className: "h-3 w-3" }),
5177
5181
  /* @__PURE__ */ jsx(List, { className: "h-3 w-3" }),
5178
5182
  /* @__PURE__ */ jsx("span", { className: "leading-tight", children: r }),
5179
5183
  " ",
@@ -5181,7 +5185,7 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5181
5185
  ]
5182
5186
  }
5183
5187
  ),
5184
- (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${v ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5188
+ (g == null ? void 0 : g.length) === 0 ? /* @__PURE__ */ jsx("div", { className: "h-0 overflow-hidden", children: a }) : /* @__PURE__ */ jsxs("div", { className: `${k ? "pt-0.5" : "h-0 overflow-hidden"}`, children: [
5185
5189
  c,
5186
5190
  a,
5187
5191
  l,
@@ -5194,13 +5198,13 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5194
5198
  /* @__PURE__ */ jsxs("label", { htmlFor: o, className: u.type === "object" ? "pb-2" : "", children: [
5195
5199
  r,
5196
5200
  " ",
5197
- k && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5201
+ v && /* @__PURE__ */ jsxs("small", { className: "text-[9px] text-zinc-400", children: [
5198
5202
  " ",
5199
5203
  y
5200
5204
  ] }),
5201
5205
  p && u.type !== "object" ? " *" : null
5202
5206
  ] }),
5203
- u.type === "string" && !u.enum && !u.oneOf && A && /* @__PURE__ */ jsx(NestedPathSelector, { data: A, onSelect: w, dataType: "value" })
5207
+ u.type === "string" && !u.enum && !u.oneOf && B && /* @__PURE__ */ jsx(NestedPathSelector, { data: B, onSelect: w, dataType: "value" })
5204
5208
  ] }),
5205
5209
  c,
5206
5210
  a,
@@ -5213,8 +5217,8 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5213
5217
  /* @__PURE__ */ jsx("span", { children: "Add" })
5214
5218
  ] }) }), JSONForm = memo(({ blockId: o, schema: n, uiSchema: r, formData: a, onChange: l }) => {
5215
5219
  const { selectedLang: i } = useLanguages(), [c] = useAtom$1(chaiRjsfWidgetsAtom), [d] = useAtom$1(chaiRjsfFieldsAtom), [p] = useAtom$1(chaiRjsfTemplatesAtom), u = useThrottledCallback(
5216
- async ({ formData: g }, m) => {
5217
- l({ formData: g }, m);
5220
+ async ({ formData: g }, f) => {
5221
+ l({ formData: g }, f);
5218
5222
  },
5219
5223
  [l, i],
5220
5224
  400
@@ -5253,42 +5257,73 @@ const MenuBar = ({ editor: o, onExpand: n }) => {
5253
5257
  uiSchema: r,
5254
5258
  schema: n,
5255
5259
  formData: a,
5256
- onChange: ({ formData: g }, m) => {
5257
- if (console.log(g, m), !m || o !== (g == null ? void 0 : g._id)) return;
5258
- const f = take(m.split("."), 2).join(".").replace("root.", "");
5259
- u({ formData: g }, f);
5260
+ onChange: ({ formData: g }, f) => {
5261
+ if (!f || o !== (g == null ? void 0 : g._id)) return;
5262
+ const m = take(f.split("."), 2).join(".").replace("root.", "");
5263
+ u({ formData: g }, m);
5260
5264
  }
5261
5265
  },
5262
5266
  i
5263
5267
  );
5264
- }), formDataWithSelectedLang = (o, n, r) => {
5268
+ }), GlobalBlockSettings = () => {
5269
+ const o = useSelectedBlock(), { data: n, refetch: r, isLoading: a } = usePartialBlocksList(), l = useUpdateBlocksProps();
5270
+ return /* @__PURE__ */ jsxs("div", { children: [
5271
+ /* @__PURE__ */ jsx("label", { className: "text-sm", children: "Choose a global block" }),
5272
+ /* @__PURE__ */ jsxs(
5273
+ "select",
5274
+ {
5275
+ className: "h-8 w-full rounded-md border border-border bg-gray-50 p-0 px-2 text-xs dark:bg-gray-800",
5276
+ value: (o == null ? void 0 : o.globalBlock) || "",
5277
+ onChange: (i) => {
5278
+ var c;
5279
+ l([o._id], {
5280
+ globalBlock: i.target.value,
5281
+ _name: `Global Block: ${startCase((c = get(n, i.target.value, "")) == null ? void 0 : c.name)}`
5282
+ });
5283
+ },
5284
+ children: [
5285
+ /* @__PURE__ */ jsx("option", { value: "", children: "Select a global block" }),
5286
+ Object.keys(n).map((i) => /* @__PURE__ */ jsx("option", { value: i, children: n[i].name || i }, i))
5287
+ ]
5288
+ }
5289
+ ),
5290
+ /* @__PURE__ */ jsx("div", { className: "mt-2 text-xs", children: /* @__PURE__ */ jsx(
5291
+ "button",
5292
+ {
5293
+ onClick: r,
5294
+ className: "rounded-md bg-gray-100 p-1 px-2 text-xs hover:bg-gray-200 dark:bg-gray-800 dark:hover:bg-gray-700",
5295
+ children: a ? "Loading..." : "Refresh List"
5296
+ }
5297
+ ) })
5298
+ ] });
5299
+ }, formDataWithSelectedLang = (o, n, r) => {
5265
5300
  const a = cloneDeep(o);
5266
5301
  return forEach(keys(o), (l) => {
5267
5302
  includes(get(r, "i18nProps", []), l) && !isEmpty(n) && (a[l] = get(o, `${l}-${n}`));
5268
5303
  }), a;
5269
5304
  };
5270
5305
  function BlockSettings() {
5271
- 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) => {
5272
- _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(B, _) }, w);
5273
- }, b = useCallback(
5274
- debounce(({ formData: B }, _, w) => {
5275
- h({ formData: B }, _, w), d(B);
5306
+ 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(), f = getRegisteredChaiBlock(g == null ? void 0 : g._type), m = formDataWithSelectedLang(g, o, f), h = ({ formData: A }, _, w) => {
5307
+ _ && (c == null ? void 0 : c._id) === n._id && a([n._id], { [_]: get(A, _) }, w);
5308
+ }, x = useCallback(
5309
+ debounce(({ formData: A }, _, w) => {
5310
+ h({ formData: A }, _, w), d(A);
5276
5311
  }, 1500),
5277
5312
  [n == null ? void 0 : n._id, o]
5278
- ), x = ({ formData: B }, _) => {
5279
- _ && (r([n._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
5280
- }, y = ({ formData: B }, _) => {
5281
- _ && (r([g._id], { [_]: get(B, _) }), b({ formData: B }, _, { [_]: get(c, _) }));
5313
+ ), b = ({ formData: A }, _) => {
5314
+ _ && (r([n._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5315
+ }, y = ({ formData: A }, _) => {
5316
+ _ && (r([g._id], { [_]: get(A, _) }), x({ formData: A }, _, { [_]: get(c, _) }));
5282
5317
  };
5283
5318
  keys(get(i, "_bindings", {}));
5284
- const { schema: A, uiSchema: j } = useMemo(() => {
5285
- const B = n == null ? void 0 : n._type;
5286
- if (B)
5287
- return getBlockFormSchemas(B);
5319
+ const { schema: B, uiSchema: j } = useMemo(() => {
5320
+ const A = n == null ? void 0 : n._type;
5321
+ if (A)
5322
+ return getBlockFormSchemas(A);
5288
5323
  }, [n]), { wrapperSchema: C, wrapperUiSchema: S } = useMemo(() => {
5289
5324
  if (!g || !(g != null && g._type))
5290
5325
  return { wrapperSchema: {}, wrapperUiSchema: {} };
5291
- const B = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(B);
5326
+ const A = g == null ? void 0 : g._type, { schema: _ = {}, uiSchema: w = {} } = getBlockFormSchemas(A);
5292
5327
  return { wrapperSchema: _, wrapperUiSchema: w };
5293
5328
  }, [g]);
5294
5329
  return /* @__PURE__ */ jsxs("div", { className: "no-scrollbar overflow-x-hidden px-px", children: [
@@ -5296,7 +5331,7 @@ function BlockSettings() {
5296
5331
  /* @__PURE__ */ jsxs(
5297
5332
  "div",
5298
5333
  {
5299
- onClick: () => u((B) => !B),
5334
+ onClick: () => u((A) => !A),
5300
5335
  className: "flex cursor-pointer items-center gap-x-1 py-2 text-xs font-medium leading-tight hover:bg-slate-100",
5301
5336
  children: [
5302
5337
  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" }),
@@ -5316,19 +5351,19 @@ function BlockSettings() {
5316
5351
  {
5317
5352
  blockId: g == null ? void 0 : g._id,
5318
5353
  onChange: y,
5319
- formData: f,
5354
+ formData: m,
5320
5355
  schema: C,
5321
5356
  uiSchema: S
5322
5357
  }
5323
5358
  ) })
5324
5359
  ] }),
5325
- isEmpty(A) ? null : /* @__PURE__ */ jsx(
5360
+ isEmpty(B) ? null : /* @__PURE__ */ jsx(
5326
5361
  JSONForm,
5327
5362
  {
5328
5363
  blockId: n == null ? void 0 : n._id,
5329
- onChange: x,
5364
+ onChange: b,
5330
5365
  formData: i,
5331
- schema: A,
5366
+ schema: B,
5332
5367
  uiSchema: j
5333
5368
  }
5334
5369
  ),
@@ -5394,57 +5429,72 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5394
5429
  ], BreakpointCard = ({
5395
5430
  canvas: o = !1,
5396
5431
  openDelay: n = 400,
5397
- title: r,
5398
- content: a,
5399
- currentBreakpoint: l,
5400
- breakpoint: i,
5401
- width: c,
5402
- icon: d,
5403
- onClick: p
5432
+ tooltip: r = !0,
5433
+ title: a,
5434
+ content: l,
5435
+ currentBreakpoint: i,
5436
+ breakpoint: c,
5437
+ width: d,
5438
+ icon: p,
5439
+ onClick: u
5404
5440
  }) => {
5405
- const { t: u } = useTranslation();
5406
- return /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
5441
+ const { t: g } = useTranslation();
5442
+ return r ? /* @__PURE__ */ jsxs(HoverCard, { openDelay: n, children: [
5407
5443
  /* @__PURE__ */ jsx(HoverCardTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
5408
5444
  Button,
5409
5445
  {
5410
- onClick: () => p(c),
5446
+ onClick: () => u(d),
5411
5447
  size: "sm",
5412
5448
  className: "h-7 w-7 rounded-md p-1",
5413
- variant: i === l ? "outline" : "ghost",
5414
- children: d
5449
+ variant: c === i ? "outline" : "ghost",
5450
+ children: p
5415
5451
  }
5416
5452
  ) }),
5417
5453
  /* @__PURE__ */ jsx(HoverCardContent, { className: "w-fit max-w-52 border-border", children: /* @__PURE__ */ jsx("div", { className: "flex justify-between space-x-4", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1", children: [
5418
- /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: u(r) }),
5419
- o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: u(a) })
5454
+ /* @__PURE__ */ jsx("h4", { className: "text-sm font-semibold", children: g(a) }),
5455
+ o && /* @__PURE__ */ jsx("p", { className: "text-xs", children: g(l) })
5420
5456
  ] }) }) })
5421
- ] });
5422
- }, Breakpoints$1 = ({ openDelay: o = 400, canvas: n = !1 }) => {
5423
- const [r, , a] = useScreenSizeWidth(), [l, i] = useCanvasDisplayWidth(), [c, d] = useSelectedBreakpoints(), p = c, u = d, { t: g } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), f = (x) => {
5424
- p.includes(x) ? p.length > 2 && u(p.filter((y) => y !== x)) : u((y) => [...y, x]);
5425
- }, h = (x) => {
5426
- n || a(x), i(x);
5427
- }, b = getBreakpointValue(n ? l : r).toLowerCase();
5428
- return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (x) => /* @__PURE__ */ createElement(
5457
+ ] }) : /* @__PURE__ */ jsx(
5458
+ Button,
5459
+ {
5460
+ onClick: () => u(d),
5461
+ size: "sm",
5462
+ className: "h-7 w-7 rounded-md p-1",
5463
+ variant: c === i ? "outline" : "ghost",
5464
+ children: p
5465
+ }
5466
+ );
5467
+ }, Breakpoints$1 = ({
5468
+ openDelay: o = 400,
5469
+ canvas: n = !1,
5470
+ tooltip: r = !0
5471
+ }) => {
5472
+ const [a, , l] = useScreenSizeWidth(), [i, c] = useCanvasDisplayWidth(), [d, p] = useSelectedBreakpoints(), u = d, g = p, { t: f } = useTranslation(), m = useBuilderProp("breakpoints", WEB_BREAKPOINTS), h = (y) => {
5473
+ u.includes(y) ? u.length > 2 && g(u.filter((B) => B !== y)) : g((B) => [...B, y]);
5474
+ }, x = (y) => {
5475
+ n || l(y), c(y);
5476
+ }, b = getBreakpointValue(n ? i : a).toLowerCase();
5477
+ return m.length < 4 ? /* @__PURE__ */ jsx("div", { className: "flex items-center rounded-md", children: map(m, (y) => /* @__PURE__ */ createElement(
5429
5478
  BreakpointCard,
5430
5479
  {
5431
5480
  canvas: n,
5432
- ...x,
5433
- onClick: h,
5434
- key: x.breakpoint,
5481
+ ...y,
5482
+ onClick: x,
5483
+ key: y.breakpoint,
5435
5484
  currentBreakpoint: b
5436
5485
  }
5437
5486
  )) }) : /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between rounded-md", children: [
5438
5487
  /* @__PURE__ */ jsx("div", { className: "flex items-center", children: map(
5439
- m.filter((x) => includes(p, toUpper(x.breakpoint))),
5440
- (x) => /* @__PURE__ */ createElement(
5488
+ m.filter((y) => includes(u, toUpper(y.breakpoint))),
5489
+ (y) => /* @__PURE__ */ createElement(
5441
5490
  BreakpointCard,
5442
5491
  {
5443
5492
  canvas: n,
5444
5493
  openDelay: o,
5445
- ...x,
5446
- onClick: h,
5447
- key: x.breakpoint,
5494
+ tooltip: r,
5495
+ ...y,
5496
+ onClick: x,
5497
+ key: y.breakpoint,
5448
5498
  currentBreakpoint: b
5449
5499
  }
5450
5500
  )
@@ -5452,17 +5502,17 @@ const TabletIcon = ({ landscape: o = !1 }) => /* @__PURE__ */ jsx(
5452
5502
  /* @__PURE__ */ jsxs(DropdownMenu, { children: [
5453
5503
  /* @__PURE__ */ jsx(DropdownMenuTrigger, { asChild: !0, children: /* @__PURE__ */ jsx("span", { className: "cursor-pointer px-2.5 hover:opacity-80", children: /* @__PURE__ */ jsx(DotsVerticalIcon, { className: "scale-90 transform" }) }) }),
5454
5504
  /* @__PURE__ */ jsxs(DropdownMenuContent, { className: "w-56 border-border text-xs", children: [
5455
- /* @__PURE__ */ jsx(DropdownMenuLabel, { children: g("Screen sizes") }),
5505
+ /* @__PURE__ */ jsx(DropdownMenuLabel, { children: f("Screen sizes") }),
5456
5506
  /* @__PURE__ */ jsx(DropdownMenuSeparator, {}),
5457
- map(m, (x) => /* @__PURE__ */ jsx(
5507
+ map(m, (y) => /* @__PURE__ */ jsx(
5458
5508
  DropdownMenuCheckboxItem,
5459
5509
  {
5460
- disabled: x.breakpoint === "xs",
5461
- onCheckedChange: () => f(toUpper(x.breakpoint)),
5462
- checked: includes(p, toUpper(x.breakpoint)),
5463
- children: g(x.title)
5510
+ disabled: y.breakpoint === "xs",
5511
+ onCheckedChange: () => h(toUpper(y.breakpoint)),
5512
+ checked: includes(u, toUpper(y.breakpoint)),
5513
+ children: f(y.title)
5464
5514
  },
5465
- x.breakpoint
5515
+ y.breakpoint
5466
5516
  ))
5467
5517
  ] })
5468
5518
  ] })
@@ -5476,9 +5526,13 @@ function BreakpointSelector() {
5476
5526
  return /* @__PURE__ */ jsxs(Fragment, { children: [
5477
5527
  /* @__PURE__ */ jsxs("div", { className: "sticky top-0 z-10 flex items-center justify-start bg-muted px-2 py-1 shadow-sm", children: [
5478
5528
  /* @__PURE__ */ jsx("p", { className: "text-xs text-muted-foreground", children: "Screen: " }),
5479
- /* @__PURE__ */ jsx(Breakpoints$1, { openDelay: 500 })
5529
+ /* @__PURE__ */ jsx(Breakpoints$1, { openDelay: 1e3, tooltip: !1 })
5480
5530
  ] }),
5481
- /* @__PURE__ */ jsx("div", { className: "flex items-center justify-between rounded-md rounded-t-none border border-border p-1", children: /* @__PURE__ */ jsx("p", { className: "flex-1 text-[10px] text-muted-foreground", children: n }) })
5531
+ /* @__PURE__ */ jsx("div", { className: "mb-2 flex items-center justify-between rounded-md rounded-t-none border border-border p-1", children: /* @__PURE__ */ jsx("p", { className: "flex flex-1 items-center space-x-2 text-[10px] text-foreground", children: /* @__PURE__ */ jsxs("span", { className: "text-xs text-foreground", children: [
5532
+ /* @__PURE__ */ jsx("span", { className: "rounded-md bg-muted px-1 py-px text-xs font-bold uppercase text-muted-foreground", children: o === "xs" ? "Base" : o }),
5533
+ "  ",
5534
+ n
5535
+ ] }) }) })
5482
5536
  ] });
5483
5537
  }
5484
5538
  function FaLanguage(o) {
@@ -5547,11 +5601,11 @@ function Countdown() {
5547
5601
  const AskAIStyles = ({ blockId: o }) => {
5548
5602
  const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), d = useRef(null), p = useRef(null), [u, g] = useState();
5549
5603
  useEffect(() => {
5550
- var f;
5551
- (f = d.current) == null || f.focus();
5604
+ var m;
5605
+ (m = d.current) == null || m.focus();
5552
5606
  }, []);
5553
- const m = (f) => {
5554
- const { usage: h } = f || {};
5607
+ const f = (m) => {
5608
+ const { usage: h } = m || {};
5555
5609
  !l && h && g(h), p.current = setTimeout(() => g(void 0), 1e4), l || c("");
5556
5610
  };
5557
5611
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
@@ -5561,12 +5615,12 @@ const AskAIStyles = ({ blockId: o }) => {
5561
5615
  {
5562
5616
  ref: d,
5563
5617
  value: i,
5564
- onChange: (f) => c(f.target.value),
5618
+ onChange: (m) => c(m.target.value),
5565
5619
  placeholder: n("Ask AI to edit styles"),
5566
5620
  className: "no-scrollbar my-2 w-full border border-border p-2 text-xs",
5567
5621
  rows: 4,
5568
- onKeyDown: (f) => {
5569
- f.key === "Enter" && (f.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m));
5622
+ onKeyDown: (m) => {
5623
+ m.key === "Enter" && (m.preventDefault(), p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, f));
5570
5624
  }
5571
5625
  }
5572
5626
  ),
@@ -5576,7 +5630,7 @@ const AskAIStyles = ({ blockId: o }) => {
5576
5630
  {
5577
5631
  disabled: i.trim().length < 5 || a,
5578
5632
  onClick: () => {
5579
- p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, m);
5633
+ p.current && clearTimeout(p.current), g(void 0), r("styles", o, i, f);
5580
5634
  },
5581
5635
  variant: "default",
5582
5636
  className: "w-fit",
@@ -5607,25 +5661,25 @@ const AskAIStyles = ({ blockId: o }) => {
5607
5661
  ] });
5608
5662
  };
5609
5663
  function ManualClasses() {
5610
- var I;
5611
- 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 = () => {
5612
- const L = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5613
- u(m, L, !0), b("");
5614
- }, [C, S] = useState([]), B = ({ value: L }) => {
5615
- const P = L.trim().toLowerCase(), E = P.match(/.+:/g);
5664
+ var T;
5665
+ const o = useRef(null), [n, r] = useState(""), [a, l] = useState(-1), i = useFuseSearch(), { t: c } = useTranslation(), [d] = useSelectedStylingBlocks(), p = useSelectedBlock(), u = useAddClassesToBlocks(), g = useRemoveClassesFromBlocks(), [f] = useSelectedBlockIds(), m = useBuilderProp("askAiCallBack", null), [h, x] = useState(""), b = (T = first(d)) == null ? void 0 : T.prop, { classes: y } = getSplitChaiClasses(get(p, b, "")), B = y.split(" ").filter((I) => !isEmpty(I)), j = () => {
5666
+ const I = h.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5667
+ u(f, I, !0), x("");
5668
+ }, [C, S] = useState([]), A = ({ value: I }) => {
5669
+ const R = I.trim().toLowerCase(), N = R.match(/.+:/g);
5616
5670
  let D = [];
5617
- if (E && E.length > 0) {
5618
- const [M] = E, R = P.replace(M, "");
5619
- D = i.search(R).map(($) => ({
5671
+ if (N && N.length > 0) {
5672
+ const [M] = N, P = R.replace(M, "");
5673
+ D = i.search(P).map(($) => ({
5620
5674
  ...$,
5621
5675
  item: { ...$.item, name: M + $.item.name }
5622
5676
  }));
5623
5677
  } else
5624
- D = i.search(P);
5678
+ D = i.search(R);
5625
5679
  return S(map(D, "item"));
5626
5680
  }, _ = () => {
5627
5681
  S([]);
5628
- }, w = (L) => L.name, T = (L) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: L.name }), k = useMemo(
5682
+ }, w = (I) => I.name, L = (I) => /* @__PURE__ */ jsx("div", { className: "rounded-md p-1", children: I.name }), v = useMemo(
5629
5683
  () => ({
5630
5684
  ref: o,
5631
5685
  autoComplete: "off",
@@ -5634,34 +5688,34 @@ function ManualClasses() {
5634
5688
  spellCheck: !1,
5635
5689
  placeholder: c("Enter classes separated by space"),
5636
5690
  value: h,
5637
- onKeyDown: (L) => {
5638
- L.key === "Enter" && h.trim() !== "" && j();
5691
+ onKeyDown: (I) => {
5692
+ I.key === "Enter" && h.trim() !== "" && j();
5639
5693
  },
5640
- onChange: (L, { newValue: P }) => b(P),
5694
+ onChange: (I, { newValue: R }) => x(R),
5641
5695
  className: "w-full rounded-md text-xs px-2 hover:outline-0 bg-background border-border py-1"
5642
5696
  }),
5643
5697
  [h, c, o]
5644
- ), v = (L) => {
5698
+ ), k = (I) => {
5645
5699
  debugger;
5646
- const P = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5647
- g(m, [L]), u(m, P, !0), r(""), l(-1);
5648
- }, N = () => {
5700
+ const R = n.trim().toLowerCase().replace(/ +(?= )/g, "").split(" ");
5701
+ g(f, [I]), u(f, R, !0), r(""), l(-1);
5702
+ }, E = () => {
5649
5703
  if (navigator.clipboard === void 0) {
5650
5704
  toast.error(c("Clipboard not supported"));
5651
5705
  return;
5652
5706
  }
5653
- navigator.clipboard.writeText(A.join(" ")), toast.success(c("Classes copied to clipboard"));
5707
+ navigator.clipboard.writeText(B.join(" ")), toast.success(c("Classes copied to clipboard"));
5654
5708
  };
5655
5709
  return /* @__PURE__ */ jsxs("div", { className: "flex w-full flex-col gap-y-1.5 border-b border-border pb-4", children: [
5656
5710
  /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-x-2", children: [
5657
5711
  /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-x-2 text-muted-foreground", children: [
5658
5712
  /* @__PURE__ */ jsx("span", { children: c("Classes") }),
5659
5713
  /* @__PURE__ */ jsxs(Tooltip, { children: [
5660
- /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: N, className: "cursor-pointer" }) }),
5714
+ /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(CopyIcon, { onClick: E, className: "cursor-pointer" }) }),
5661
5715
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: c("Copy classes to clipboard") }) })
5662
5716
  ] })
5663
5717
  ] }),
5664
- f ? /* @__PURE__ */ jsxs(Popover, { children: [
5718
+ m ? /* @__PURE__ */ jsxs(Popover, { children: [
5665
5719
  /* @__PURE__ */ jsx(PopoverTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(Button, { variant: "default", className: "h-6 w-fit", size: "sm", children: [
5666
5720
  /* @__PURE__ */ jsx(SparklesIcon, { className: "h-4 w-4" }),
5667
5721
  /* @__PURE__ */ jsx("span", { className: "ml-2", children: c("Ask AI") })
@@ -5674,11 +5728,11 @@ function ManualClasses() {
5674
5728
  Autosuggest,
5675
5729
  {
5676
5730
  suggestions: C,
5677
- onSuggestionsFetchRequested: B,
5731
+ onSuggestionsFetchRequested: A,
5678
5732
  onSuggestionsClearRequested: _,
5679
5733
  getSuggestionValue: w,
5680
- renderSuggestion: T,
5681
- inputProps: k,
5734
+ renderSuggestion: L,
5735
+ inputProps: v,
5682
5736
  containerProps: {
5683
5737
  className: "relative h-8 w-full gap-y-1 py-1 border-border text-xs"
5684
5738
  },
@@ -5701,38 +5755,38 @@ function ManualClasses() {
5701
5755
  }
5702
5756
  )
5703
5757
  ] }),
5704
- /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: A.map(
5705
- (L, P) => a === P ? /* @__PURE__ */ jsx(
5758
+ /* @__PURE__ */ jsx("div", { className: "flex w-full flex-wrap gap-2 overflow-x-hidden", children: B.map(
5759
+ (I, R) => a === R ? /* @__PURE__ */ jsx(
5706
5760
  "input",
5707
5761
  {
5708
5762
  ref: o,
5709
5763
  value: n,
5710
- onChange: (E) => r(E.target.value),
5764
+ onChange: (N) => r(N.target.value),
5711
5765
  onBlur: () => {
5712
- v(L);
5766
+ k(I);
5713
5767
  },
5714
- onKeyDown: (E) => {
5715
- E.key === "Enter" && v(L);
5768
+ onKeyDown: (N) => {
5769
+ N.key === "Enter" && k(I);
5716
5770
  },
5717
5771
  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"
5718
5772
  },
5719
- L
5773
+ I
5720
5774
  ) : /* @__PURE__ */ jsxs(
5721
5775
  "button",
5722
5776
  {
5723
5777
  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",
5724
5778
  children: [
5725
- L,
5726
- n !== L && /* @__PURE__ */ jsx(
5779
+ I,
5780
+ n !== I && /* @__PURE__ */ jsx(
5727
5781
  Cross2Icon,
5728
5782
  {
5729
- onClick: () => g(m, [L], !0),
5783
+ onClick: () => g(f, [I], !0),
5730
5784
  className: "invisible absolute right-1 rounded-full bg-red-400 hover:text-white group-hover:visible group-hover:cursor-pointer"
5731
5785
  }
5732
5786
  )
5733
5787
  ]
5734
5788
  },
5735
- L
5789
+ I
5736
5790
  )
5737
5791
  ) })
5738
5792
  ] });
@@ -6072,10 +6126,10 @@ const COLOR_PROP = {
6072
6126
  ringColor: "ring",
6073
6127
  ringOffsetColor: "ring-offset"
6074
6128
  }, ColorChoice = ({ property: o, onChange: n }) => {
6075
- 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(
6129
+ 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", ""), f = get(u, "2", ""), m = useCallback(
6076
6130
  // eslint-disable-next-line no-shadow
6077
- (x) => {
6078
- ["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" })));
6131
+ (b) => {
6132
+ ["current", "inherit", "transparent", "black", "white"].includes(b) ? (c([]), p({ color: b })) : (c(["50", "100", "200", "300", "400", "500", "600", "700", "800", "900"]), p((y) => ({ ...y, color: b, shade: y.shade ? y.shade : "500" })));
6079
6133
  },
6080
6134
  [c, p]
6081
6135
  );
@@ -6086,26 +6140,26 @@ const COLOR_PROP = {
6086
6140
  }, [g]);
6087
6141
  const h = useCallback(
6088
6142
  // eslint-disable-next-line no-shadow
6089
- (x) => {
6090
- p({ color: g, shade: x });
6143
+ (b) => {
6144
+ p({ color: g, shade: b });
6091
6145
  },
6092
6146
  [g]
6093
6147
  );
6094
6148
  useEffect(() => {
6095
6149
  p({ color: "", shade: "" });
6096
6150
  }, [r]);
6097
- const { match: b } = useTailwindClassList();
6151
+ const { match: x } = useTailwindClassList();
6098
6152
  return useEffect(() => {
6099
6153
  const y = `${get(COLOR_PROP, o, "")}-${d.color}${d.shade ? `-${d.shade}` : ""}`;
6100
- b(o, y) && n(y, o);
6101
- }, [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: [
6154
+ x(o, y) && n(y, o);
6155
+ }, [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: [
6102
6156
  /* @__PURE__ */ jsx("div", { className: "grow text-center", children: /* @__PURE__ */ jsx(
6103
6157
  DropDown,
6104
6158
  {
6105
6159
  disabled: !l,
6106
6160
  rounded: !0,
6107
6161
  selected: g,
6108
- onChange: f,
6162
+ onChange: m,
6109
6163
  options: [
6110
6164
  "current",
6111
6165
  "transparent",
@@ -6138,7 +6192,7 @@ const COLOR_PROP = {
6138
6192
  ]
6139
6193
  }
6140
6194
  ) }),
6141
- /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: m, disabled: !g || !l, onChange: h, options: i }) })
6195
+ /* @__PURE__ */ jsx("button", { type: "button", className: "grow text-center", children: /* @__PURE__ */ jsx(DropDown, { rounded: !0, selected: f, disabled: !g || !l, onChange: h, options: i }) })
6142
6196
  ] });
6143
6197
  }, IconChoices = ({ property: o, onChange: n }) => {
6144
6198
  const { getClasses: r } = useTailwindClassList(), a = r(o), { canChange: l } = useContext(StyleContext), i = useCurrentClassByProperty(o), c = useMemo(() => get(i, "cls", ""), [i]);
@@ -6335,52 +6389,52 @@ const COLOR_PROP = {
6335
6389
  },
6336
6390
  a
6337
6391
  )) }), THROTTLE_TIME = 50, AdvanceChoices = (o) => {
6338
- 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);
6392
+ const [n, r] = useState(!1), [a, l] = useState(""), { currentClass: i, onChange: c, classPrefix: d, cssProperty: p, units: u, negative: g } = o, [f, m] = useState(p != null && p.toLowerCase().includes("width") ? "%" : u[0]), [h, x] = useState(!1), [b, y] = useState(""), [B, j] = useState(!1), [C, S] = useState(!1);
6339
6393
  useEffect(() => {
6340
- const { value: k, unit: v } = getClassValueAndUnit(i);
6341
- if (v === "") {
6342
- l(k), f(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6394
+ const { value: v, unit: k } = getClassValueAndUnit(i);
6395
+ if (k === "") {
6396
+ l(v), m(p != null && p.toLowerCase().includes("width") ? "%" : first(u));
6343
6397
  return;
6344
6398
  }
6345
- f(v), l(v === "class" || isEmpty(k) ? "" : k);
6399
+ m(k), l(k === "class" || isEmpty(v) ? "" : v);
6346
6400
  }, [i, p, u]);
6347
- const B = useThrottledCallback((k) => c(k), [c], THROTTLE_TIME), _ = useThrottledCallback((k) => c(k, !1), [c], THROTTLE_TIME), w = useCallback(
6348
- (k = !1) => {
6349
- const v = getUserInputValues(`${a}`, u);
6350
- if (get(v, "error", !1)) {
6351
- b(!0);
6401
+ const A = useThrottledCallback((v) => c(v), [c], THROTTLE_TIME), _ = useThrottledCallback((v) => c(v, !1), [c], THROTTLE_TIME), w = useCallback(
6402
+ (v = !1) => {
6403
+ const k = getUserInputValues(`${a}`, u);
6404
+ if (get(k, "error", !1)) {
6405
+ x(!0);
6352
6406
  return;
6353
6407
  }
6354
- const N = get(v, "unit") !== "" ? get(v, "unit") : m;
6355
- if (N === "auto" || N === "none") {
6356
- B(`${d}${N}`);
6408
+ const E = get(k, "unit") !== "" ? get(k, "unit") : f;
6409
+ if (E === "auto" || E === "none") {
6410
+ A(`${d}${E}`);
6357
6411
  return;
6358
6412
  }
6359
- if (get(v, "value") === "")
6413
+ if (get(k, "value") === "")
6360
6414
  return;
6361
- const L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6362
- k ? _(L) : B(L);
6415
+ const I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6416
+ v ? _(I) : A(I);
6363
6417
  },
6364
- [B, _, a, m, d, u]
6365
- ), T = useCallback(
6366
- (k) => {
6367
- const v = getUserInputValues(`${a}`, u);
6368
- if (get(v, "error", !1)) {
6369
- b(!0);
6418
+ [A, _, a, f, d, u]
6419
+ ), L = useCallback(
6420
+ (v) => {
6421
+ const k = getUserInputValues(`${a}`, u);
6422
+ if (get(k, "error", !1)) {
6423
+ x(!0);
6370
6424
  return;
6371
6425
  }
6372
- if (k === "auto" || k === "none") {
6373
- B(`${d}${k}`);
6426
+ if (v === "auto" || v === "none") {
6427
+ A(`${d}${v}`);
6374
6428
  return;
6375
6429
  }
6376
- if (get(v, "value") === "")
6430
+ if (get(k, "value") === "")
6377
6431
  return;
6378
- const N = get(v, "unit") !== "" ? get(v, "unit") : k, L = `${get(v, "value", "").startsWith("-") ? "-" : ""}${d}[${get(v, "value", "").replace("-", "")}${N === "-" ? "" : N}]`;
6379
- B(L);
6432
+ const E = get(k, "unit") !== "" ? get(k, "unit") : v, I = `${get(k, "value", "").startsWith("-") ? "-" : ""}${d}[${get(k, "value", "").replace("-", "")}${E === "-" ? "" : E}]`;
6433
+ A(I);
6380
6434
  },
6381
- [B, a, d, u]
6435
+ [A, a, d, u]
6382
6436
  );
6383
- 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: [
6437
+ return /* @__PURE__ */ jsx("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ jsx("div", { className: "flex items-center justify-start", children: f === "class" ? /* @__PURE__ */ jsxs(Fragment, { children: [
6384
6438
  /* @__PURE__ */ jsx(
6385
6439
  "input",
6386
6440
  {
@@ -6393,37 +6447,37 @@ const COLOR_PROP = {
6393
6447
  /* @__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, {}) }) }),
6394
6448
  /* @__PURE__ */ jsx(TooltipContent, { children: "Current value is using a Tailwind preset class." })
6395
6449
  ] })
6396
- ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${A ? "z-auto" : ""}`, children: [
6450
+ ] }) : /* @__PURE__ */ jsxs("div", { className: `group relative flex items-center ${B ? "z-auto" : ""}`, children: [
6397
6451
  /* @__PURE__ */ jsxs("div", { className: "flex items-center rounded-md border border-border", children: [
6398
- ["none", "auto"].indexOf(m) !== -1 ? null : /* @__PURE__ */ jsx(
6452
+ ["none", "auto"].indexOf(f) !== -1 ? null : /* @__PURE__ */ jsx(
6399
6453
  "input",
6400
6454
  {
6401
- readOnly: m === "class",
6402
- onKeyPress: (k) => {
6403
- k.key === "Enter" && w();
6455
+ readOnly: f === "class",
6456
+ onKeyPress: (v) => {
6457
+ v.key === "Enter" && w();
6404
6458
  },
6405
- onKeyDown: (k) => {
6406
- if (k.keyCode !== 38 && k.keyCode !== 40)
6459
+ onKeyDown: (v) => {
6460
+ if (v.keyCode !== 38 && v.keyCode !== 40)
6407
6461
  return;
6408
- k.preventDefault(), S(!0);
6409
- const v = parseInt$1(k.target.value);
6410
- let N = isNaN$1(v) ? 0 : v;
6411
- k.keyCode === 38 && (N += 1), k.keyCode === 40 && (N -= 1);
6412
- const I = `${N}`, P = `${I.startsWith("-") ? "-" : ""}${d}[${I.replace("-", "")}${m === "-" ? "" : m}]`;
6413
- _(P);
6462
+ v.preventDefault(), S(!0);
6463
+ const k = parseInt$1(v.target.value);
6464
+ let E = isNaN$1(k) ? 0 : k;
6465
+ v.keyCode === 38 && (E += 1), v.keyCode === 40 && (E -= 1);
6466
+ const T = `${E}`, R = `${T.startsWith("-") ? "-" : ""}${d}[${T.replace("-", "")}${f === "-" ? "" : f}]`;
6467
+ _(R);
6414
6468
  },
6415
- onKeyUp: (k) => {
6416
- C && (k.preventDefault(), S(!1));
6469
+ onKeyUp: (v) => {
6470
+ C && (v.preventDefault(), S(!1));
6417
6471
  },
6418
6472
  onBlur: () => w(),
6419
- onChange: (k) => {
6420
- b(!1), l(k.target.value);
6473
+ onChange: (v) => {
6474
+ x(!1), l(v.target.value);
6421
6475
  },
6422
- onClick: (k) => {
6423
- var v;
6424
- (v = k == null ? void 0 : k.target) == null || v.select(), r(!1);
6476
+ onClick: (v) => {
6477
+ var k;
6478
+ (k = v == null ? void 0 : v.target) == null || k.select(), r(!1);
6425
6479
  },
6426
- value: A ? x : a,
6480
+ value: B ? b : a,
6427
6481
  className: "h-6 w-14 rounded rounded-r-none border border-transparent bg-background pl-2 text-sm focus-visible:outline-0".concat(
6428
6482
  " ",
6429
6483
  h ? "border-red-500 text-red-500" : "border-foreground/20"
@@ -6438,7 +6492,7 @@ const COLOR_PROP = {
6438
6492
  onClick: () => r(!n),
6439
6493
  className: "flex h-6 cursor-pointer items-center gap-x-1 rounded rounded-l-none bg-background p-px px-1 text-[11px] uppercase",
6440
6494
  children: [
6441
- /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: m }),
6495
+ /* @__PURE__ */ jsx("span", { className: `inline-block ${u.length === 1 ? "px-2 font-semibold" : ""}`, children: f }),
6442
6496
  u.length > 1 ? /* @__PURE__ */ jsx(TriangleDownIcon, {}) : null
6443
6497
  ]
6444
6498
  }
@@ -6447,33 +6501,33 @@ const COLOR_PROP = {
6447
6501
  UnitSelection,
6448
6502
  {
6449
6503
  units: u,
6450
- current: m,
6451
- onSelect: (k) => {
6452
- r(!1), f(k), T(k);
6504
+ current: f,
6505
+ onSelect: (v) => {
6506
+ r(!1), m(v), L(v);
6453
6507
  }
6454
6508
  }
6455
6509
  ) }) })
6456
6510
  ] })
6457
6511
  ] }),
6458
- ["none", "auto"].indexOf(m) !== -1 || A ? null : /* @__PURE__ */ jsx(
6512
+ ["none", "auto"].indexOf(f) !== -1 || B ? null : /* @__PURE__ */ jsx(
6459
6513
  DragStyleButton,
6460
6514
  {
6461
6515
  onDragStart: () => j(!0),
6462
- onDragEnd: (k) => {
6463
- if (y(() => ""), j(!1), isEmpty(k))
6516
+ onDragEnd: (v) => {
6517
+ if (y(() => ""), j(!1), isEmpty(v))
6464
6518
  return;
6465
- const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
6466
- B(I);
6519
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6520
+ A(T);
6467
6521
  },
6468
- onDrag: (k) => {
6469
- if (isEmpty(k))
6522
+ onDrag: (v) => {
6523
+ if (isEmpty(v))
6470
6524
  return;
6471
- y(k);
6472
- const v = `${k}`, I = `${v.startsWith("-") ? "-" : ""}${d}[${v.replace("-", "")}${m === "-" ? "" : m}]`;
6473
- _(I);
6525
+ y(v);
6526
+ const k = `${v}`, T = `${k.startsWith("-") ? "-" : ""}${d}[${k.replace("-", "")}${f === "-" ? "" : f}]`;
6527
+ _(T);
6474
6528
  },
6475
6529
  currentValue: a,
6476
- unit: m,
6530
+ unit: f,
6477
6531
  negative: g,
6478
6532
  cssProperty: p
6479
6533
  }
@@ -6567,20 +6621,20 @@ const COLOR_PROP = {
6567
6621
  "2xl": "1536px"
6568
6622
  }, getBreakpoint = (o) => `${o.toUpperCase()} ${BREAKPOINTS[o] ? `(${BREAKPOINTS[o]} & up)` : ""}`, BlockStyle = (o) => {
6569
6623
  const { t: n } = useTranslation(), { type: r = "icons", label: a, property: l, onEmitChange: i = () => {
6570
- }, 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(
6624
+ }, units: c, negative: d = !1 } = o, [p] = useDarkMode(), [u] = useStylingState(), [, g] = useScreenSizeWidth(), f = useCurrentClassByProperty(l), m = useAddClassesToBlocks(), h = useRemoveClassesFromBlocks(), [x] = useSelectedBlockIds(), b = useMemo(() => get(f, "fullCls", ""), [f]), y = useCallback(
6571
6625
  (_, w = !0) => {
6572
- const T = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
6573
- (p || u !== "") && (T.mq = "xs");
6574
- const k = generateFullClsName(T);
6575
- f(b, [k], w);
6626
+ const L = { dark: p, mq: g, mod: u, cls: _, property: l, fullCls: "" };
6627
+ (p || u !== "") && (L.mq = "xs");
6628
+ const v = generateFullClsName(L);
6629
+ m(x, [v], w);
6576
6630
  },
6577
- [b, p, g, u, l, f]
6578
- ), A = useCallback(() => {
6579
- h(b, [x], !0);
6580
- }, [b, x, h]), j = useMemo(() => canChangeClass(m, g), [m, g]);
6631
+ [x, p, g, u, l, m]
6632
+ ), B = useCallback(() => {
6633
+ h(x, [b], !0);
6634
+ }, [x, b, h]), j = useMemo(() => canChangeClass(f, g), [f, g]);
6581
6635
  useEffect(() => {
6582
- i(j, m);
6583
- }, [j, i, m]);
6636
+ i(j, f);
6637
+ }, [j, i, f]);
6584
6638
  const [, , C] = useScreenSizeWidth(), S = useCallback(
6585
6639
  (_) => {
6586
6640
  C({
@@ -6593,15 +6647,15 @@ const COLOR_PROP = {
6593
6647
  }[_]);
6594
6648
  },
6595
6649
  [C]
6596
- ), B = get(m, "dark", null) === p && get(m, "mod", null) === u && get(m, "mq", null) === g;
6597
- 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: [
6598
- /* @__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) }) }),
6650
+ ), A = get(f, "dark", null) === p && get(f, "mod", null) === u && get(f, "mq", null) === g;
6651
+ return /* @__PURE__ */ jsx(BlockStyleProvider, { canChange: j, canReset: f && A, children: /* @__PURE__ */ jsxs("div", { className: "group flex flex-row items-center py-2 first:pt-0 last:pb-0", children: [
6652
+ /* @__PURE__ */ jsx("div", { className: "relative w-[70px] truncate text-xs text-foreground", children: /* @__PURE__ */ jsx("span", { className: `text-[11px] ${f && !A ? "text-foreground" : ""}`, children: n(a) }) }),
6599
6653
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row items-center", children: [
6600
6654
  /* @__PURE__ */ jsxs("div", { className: "w-[150px]", children: [
6601
6655
  r === "arbitrary" ? /* @__PURE__ */ jsx(
6602
6656
  AdvanceChoices,
6603
6657
  {
6604
- currentClass: get(m, "cls", ""),
6658
+ currentClass: get(f, "cls", ""),
6605
6659
  classPrefix: get(CLASS_PREFIXES, l, ""),
6606
6660
  units: c || [],
6607
6661
  onChange: y,
@@ -6614,7 +6668,7 @@ const COLOR_PROP = {
6614
6668
  r === "color" && /* @__PURE__ */ jsx(ColorChoice, { property: l, onChange: y }),
6615
6669
  r === "dropdown" && /* @__PURE__ */ jsx(DropDownChoices, { label: a, property: l, onChange: y })
6616
6670
  ] }),
6617
- /* @__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: [
6671
+ /* @__PURE__ */ jsx("div", { className: `w-[30px] cursor-pointer ${b ? "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" }) }) : j && f ? /* @__PURE__ */ jsxs(Tooltip, { delayDuration: 100, children: [
6618
6672
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
6619
6673
  "button",
6620
6674
  {
@@ -6626,19 +6680,19 @@ const COLOR_PROP = {
6626
6680
  /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("div", { className: "text-right", children: /* @__PURE__ */ jsxs("div", { children: [
6627
6681
  "Current style is set at  ",
6628
6682
  /* @__PURE__ */ jsxs("span", { className: "font-bold", children: [
6629
- getBreakpoint(get(m, "mq")),
6630
- p && !m.dark ? "(Light mode)" : ""
6683
+ getBreakpoint(get(f, "mq")),
6684
+ p && !f.dark ? "(Light mode)" : ""
6631
6685
  ] }),
6632
6686
  /* @__PURE__ */ jsx("br", {}),
6633
6687
  /* @__PURE__ */ jsxs(
6634
6688
  "button",
6635
6689
  {
6636
6690
  type: "button",
6637
- onClick: () => S(get(m, "mq")),
6691
+ onClick: () => S(get(f, "mq")),
6638
6692
  className: "block w-full cursor-default text-right font-semibold text-blue-500",
6639
6693
  children: [
6640
6694
  "Switch to ",
6641
- get(m, "mq").toUpperCase()
6695
+ get(f, "mq").toUpperCase()
6642
6696
  ]
6643
6697
  }
6644
6698
  )
@@ -6655,7 +6709,7 @@ const COLOR_PROP = {
6655
6709
  units: i = basicUnits,
6656
6710
  negative: c = !1
6657
6711
  }) => {
6658
- const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), m = useCallback((f) => map(g, "property").includes(f), [g]);
6712
+ const { t: d } = useTranslation(), [p, u] = useState(n[0].key), g = useSelectedBlockCurrentClasses(), f = useCallback((m) => map(g, "property").includes(m), [g]);
6659
6713
  return /* @__PURE__ */ jsxs(
6660
6714
  "div",
6661
6715
  {
@@ -6664,7 +6718,7 @@ const COLOR_PROP = {
6664
6718
  /* @__PURE__ */ jsxs("div", { className: "flex flex-row text-xs", children: [
6665
6719
  o && /* @__PURE__ */ jsx("span", { className: "relative w-[70px] flex-none text-xs text-foreground", children: d(o) }),
6666
6720
  /* @__PURE__ */ jsx("div", { className: "mb-3 flex grow flex-row flex-wrap gap-x-px", children: React__default.Children.toArray(
6667
- n.map(({ label: f, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6721
+ n.map(({ label: m, key: h }) => /* @__PURE__ */ jsx("div", { className: "first:rounded-l last:rounded-r", children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6668
6722
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6669
6723
  "button",
6670
6724
  {
@@ -6673,13 +6727,13 @@ const COLOR_PROP = {
6673
6727
  className: `relative cursor-pointer rounded-full p-1 text-[8px] ${h === p ? "bg-[#3E57F0] text-white" : "text-gray-600 dark:text-gray-300"}`,
6674
6728
  children: [
6675
6729
  React__default.createElement("div", {
6676
- className: m(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6730
+ className: f(h) ? "-bottom-1.5 absolute bg-[#3E57F0] h-[2px] left-0 w-full" : ""
6677
6731
  }),
6678
6732
  React__default.createElement(get(EDITOR_ICONS, h, BoxIcon), { className: "text-inherit w-3 h-3" })
6679
6733
  ]
6680
6734
  }
6681
6735
  ) }),
6682
- /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(f)) })
6736
+ /* @__PURE__ */ jsx(TooltipContent, { children: startCase(toLower(m)) })
6683
6737
  ] }) }))
6684
6738
  ) })
6685
6739
  ] }),
@@ -6818,13 +6872,13 @@ function BlockStyling() {
6818
6872
  cssProperty: ""
6819
6873
  }), d = useThrottledCallback(
6820
6874
  (u) => {
6821
- const g = !get(i, "negative", !1), m = get(i, "cssProperty", "");
6822
- let f = parseFloat(i.dragStartValue);
6823
- f = isNaN(f) ? 0 : f;
6875
+ const g = !get(i, "negative", !1), f = get(i, "cssProperty", "");
6876
+ let m = parseFloat(i.dragStartValue);
6877
+ m = isNaN(m) ? 0 : m;
6824
6878
  let h = MAPPER[i.dragUnit];
6825
- (startsWith(m, "scale") || m === "opacity") && (h = 10);
6826
- let x = (i.dragStartY - u.pageY) / h + f;
6827
- g && x < 0 && (x = 0), m === "opacity" && x > 1 && (x = 1), i.onDrag(`${x}`), l(`${x}`);
6879
+ (startsWith(f, "scale") || f === "opacity") && (h = 10);
6880
+ let b = (i.dragStartY - u.pageY) / h + m;
6881
+ g && b < 0 && (b = 0), f === "opacity" && b > 1 && (b = 1), i.onDrag(`${b}`), l(`${b}`);
6828
6882
  },
6829
6883
  [i],
6830
6884
  50
@@ -6866,35 +6920,35 @@ const CoreBlock = ({
6866
6920
  parentId: r,
6867
6921
  position: a
6868
6922
  }) => {
6869
- const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: m } = useBlockHighlight(), f = () => {
6870
- if (has(o, "blocks")) {
6871
- const x = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6872
- u(syncBlocksWithDefaults(x), r || null, a);
6923
+ const [, l] = useAtom$1(draggedBlockAtom), { type: i, icon: c, label: d } = o, { addCoreBlock: p, addPredefinedBlock: u } = useAddBlock(), [, g] = useSelectedBlockIds(), { clearHighlight: f } = useBlockHighlight(), m = () => {
6924
+ if (console.log("addBlockToPage", o), has(o, "blocks")) {
6925
+ const b = isFunction$1(o.blocks) ? o.blocks() : o.blocks;
6926
+ u(syncBlocksWithDefaults(b), r || null, a);
6873
6927
  } else
6874
6928
  p(o, r || null, a);
6875
6929
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
6876
- }, h = useFeature("dnd"), { t: b } = useTranslation();
6930
+ }, h = useFeature("dnd"), { t: x } = useTranslation();
6877
6931
  return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(Tooltip, { children: [
6878
6932
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsxs(
6879
6933
  "button",
6880
6934
  {
6881
6935
  disabled: n,
6882
- onClick: f,
6936
+ onClick: m,
6883
6937
  type: "button",
6884
- onDragStart: (x) => {
6885
- x.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), x.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6886
- g([]), m();
6938
+ onDragStart: (b) => {
6939
+ b.dataTransfer.setData("text/plain", JSON.stringify(omit(o, ["component", "icon"]))), b.dataTransfer.setDragImage(new Image(), 0, 0), l(omit(o, ["component", "icon"])), setTimeout(() => {
6940
+ g([]), f();
6887
6941
  }, 200);
6888
6942
  },
6889
6943
  draggable: h ? "true" : "false",
6890
6944
  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",
6891
6945
  children: [
6892
6946
  createElement(c || BoxIcon, { className: "w-4 h-4 mx-auto" }),
6893
- /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(b(d || i)) })
6947
+ /* @__PURE__ */ jsx("p", { className: "truncate text-xs", children: capitalize(x(d || i)) })
6894
6948
  ]
6895
6949
  }
6896
6950
  ) }),
6897
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: b(d || i) }) })
6951
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: x(d || i) }) })
6898
6952
  ] }) });
6899
6953
  }, DefaultChaiBlocks = ({
6900
6954
  parentId: o,
@@ -6951,6 +7005,9 @@ const CoreBlock = ({
6951
7005
  required: "required",
6952
7006
  multiple: "multiple",
6953
7007
  name: "fieldName"
7008
+ },
7009
+ form: {
7010
+ action: "action"
6954
7011
  }
6955
7012
  }, shouldAddText = (o, n) => o.children.length === 1 && includes(
6956
7013
  ["Heading", "Paragraph", "Span", "ListItem", "Button", "Label", "TableCell", "Link", "RichText"],
@@ -7079,7 +7136,7 @@ const CoreBlock = ({
7079
7136
  }
7080
7137
  }
7081
7138
  }, traverseNodes = (o, n = null) => flatMapDeep(o, (r) => {
7082
- var m, f, h, b, x, y, A, j;
7139
+ var f, m, h, x, b, y, B, j;
7083
7140
  if (r.type === "comment") return [];
7084
7141
  console.log("node ===>", r);
7085
7142
  let a = { _id: generateUUID() };
@@ -7120,29 +7177,29 @@ const CoreBlock = ({
7120
7177
  ];
7121
7178
  a = {
7122
7179
  ...a,
7123
- href: ((m = l.find((S) => S.key === "href")) == null ? void 0 : m.value) || "",
7124
- hrefType: ((f = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : f.value) || "video",
7180
+ href: ((f = l.find((S) => S.key === "href")) == null ? void 0 : f.value) || "",
7181
+ hrefType: ((m = l.find((S) => S.key === "data-vbtype")) == null ? void 0 : m.value) || "video",
7125
7182
  autoplay: ((h = l.find((S) => S.key === "data-autoplay")) == null ? void 0 : h.value) === "true" ? "true" : "false",
7126
- maxWidth: ((x = (b = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : b.value) == null ? void 0 : x.replace("px", "")) || "",
7183
+ maxWidth: ((b = (x = l.find((S) => S.key === "data-maxwidth")) == null ? void 0 : x.value) == null ? void 0 : b.replace("px", "")) || "",
7127
7184
  backdropColor: ((y = l.find((S) => S.key === "data-overlay")) == null ? void 0 : y.value) || "",
7128
- galleryName: ((A = l.find((S) => S.key === "data-gall")) == null ? void 0 : A.value) || ""
7185
+ galleryName: ((B = l.find((S) => S.key === "data-gall")) == null ? void 0 : B.value) || ""
7129
7186
  }, forEach(C, (S) => {
7130
7187
  has(a, `styles_attrs.${S}`) && delete a.styles_attrs[S];
7131
7188
  });
7132
7189
  }
7133
7190
  if (d && (delete a.styles_attrs, a.showDropdown = !1), u && delete a.styles_attrs, p) {
7134
7191
  delete a.styles_attrs;
7135
- const C = filter(r.children || [], (B) => (B == null ? void 0 : B.tagName) !== "span");
7192
+ const C = filter(r.children || [], (A) => (A == null ? void 0 : A.tagName) !== "span");
7136
7193
  a.content = getTextContent(C);
7137
7194
  const S = find(
7138
7195
  r.children || [],
7139
- (B) => (B == null ? void 0 : B.tagName) === "span" && some(B.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
7196
+ (A) => (A == null ? void 0 : A.tagName) === "span" && some(A.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg")
7140
7197
  );
7141
7198
  if (S) {
7142
- const B = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
7143
- if (B) {
7144
- a.icon = stringify([B]);
7145
- const { height: _, width: w } = getSvgDimensions(B, "16px", "16px");
7199
+ const A = find(S.children || [], (_) => (_ == null ? void 0 : _.tagName) === "svg");
7200
+ if (A) {
7201
+ a.icon = stringify([A]);
7202
+ const { height: _, width: w } = getSvgDimensions(A, "16px", "16px");
7146
7203
  a.iconHeight = _, a.iconWidth = w;
7147
7204
  }
7148
7205
  }
@@ -7155,8 +7212,8 @@ const CoreBlock = ({
7155
7212
  const C = stringify([r]);
7156
7213
  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];
7157
7214
  } else if (r.tagName === "svg") {
7158
- 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");
7159
- 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];
7215
+ const C = find(r.attributes, { key: "height" }), S = find(r.attributes, { key: "width" }), A = 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");
7216
+ return a.styles = `${STYLES_KEY}, ${cn$1(`w-${_} h-${A}`, w)}`.trim(), r.attributes = filter(r.attributes, (L) => !includes(["style", "width", "height", "class"], L.key)), a.icon = stringify([r]), [a];
7160
7217
  } else if (r.tagName == "option" && n && ((j = n.block) == null ? void 0 : j._type) === "Select")
7161
7218
  return n.block.options.push({
7162
7219
  label: getTextContent(r.children),
@@ -7205,23 +7262,129 @@ const CoreBlock = ({
7205
7262
  ] }) }),
7206
7263
  /* @__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") }) })
7207
7264
  ] });
7265
+ }, partialBlocksDataAtom = atom$1({
7266
+ blocks: [],
7267
+ groups: [],
7268
+ isLoading: !0,
7269
+ error: null
7270
+ }), hasInitializedPartialBlocksAtom = atom$1(!1), formatReadableName = (o) => {
7271
+ if (!o) return "";
7272
+ let n = o.replace(/[-_]/g, " ");
7273
+ return n = n.replace(/([a-z])([A-Z])/g, "$1 $2"), n.split(" ").map((r) => r.charAt(0).toUpperCase() + r.slice(1).toLowerCase()).join(" ");
7274
+ }, PartialBlocks = ({
7275
+ parentId: o,
7276
+ position: n,
7277
+ gridCols: r = "grid-cols-2"
7278
+ }) => {
7279
+ const { data: a, isLoading: l, refetch: i, error: c } = usePartialBlocksList(), [d, p] = useAtom$1(partialBlocksDataAtom), [u, g] = useAtom$1(hasInitializedPartialBlocksAtom);
7280
+ useEffect(() => {
7281
+ if (!u || Object.keys(d.blocks).length === 0)
7282
+ if (c)
7283
+ p({
7284
+ blocks: [],
7285
+ groups: [],
7286
+ isLoading: !1,
7287
+ error: c
7288
+ }), g(!0);
7289
+ else if (!l && Object.keys(a || {}).length > 0) {
7290
+ const m = Object.entries(a).map(([x, b]) => {
7291
+ const y = b, B = y.type || "partial", j = formatReadableName(B);
7292
+ return {
7293
+ type: "PartialBlock",
7294
+ // Set the type to PartialBlock
7295
+ label: formatReadableName(y.name || x),
7296
+ description: y.description || "",
7297
+ group: j,
7298
+ // Use formatted type as group
7299
+ category: "partial",
7300
+ partialBlockId: x
7301
+ // Store the original ID as partialBlockId
7302
+ };
7303
+ }), h = uniq(map(m, "group"));
7304
+ p({
7305
+ blocks: m,
7306
+ groups: h,
7307
+ isLoading: !1,
7308
+ error: null
7309
+ }), g(!0);
7310
+ } else l ? p((m) => ({ ...m, isLoading: !0, error: null })) : !l && Object.keys(a || {}).length === 0 && (p({
7311
+ blocks: [],
7312
+ groups: [],
7313
+ isLoading: !1,
7314
+ error: "No partial blocks available"
7315
+ }), g(!0));
7316
+ }, [
7317
+ l,
7318
+ a,
7319
+ u,
7320
+ g,
7321
+ p,
7322
+ d.blocks,
7323
+ c
7324
+ ]);
7325
+ const f = () => {
7326
+ p((m) => ({ ...m, isLoading: !0, error: null })), g(!1), i();
7327
+ };
7328
+ return d.isLoading ? /* @__PURE__ */ jsx("div", { className: "flex items-center justify-center p-8 text-center text-muted-foreground", children: "Loading partial blocks..." }) : d.error || d.blocks.length === 0 ? /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center justify-center gap-4 p-8 text-center text-muted-foreground", children: [
7329
+ /* @__PURE__ */ jsx("p", { children: d.error || "No partial blocks available" }),
7330
+ /* @__PURE__ */ jsx(
7331
+ "button",
7332
+ {
7333
+ onClick: f,
7334
+ className: "rounded-md bg-primary px-3 py-1 text-sm text-primary-foreground hover:bg-primary/90",
7335
+ children: "Refresh"
7336
+ }
7337
+ )
7338
+ ] }) : /* @__PURE__ */ jsx(
7339
+ ChaiBuilderBlocks,
7340
+ {
7341
+ gridCols: r,
7342
+ parentId: o,
7343
+ position: n,
7344
+ groups: d.groups,
7345
+ blocks: d.blocks
7346
+ }
7347
+ );
7208
7348
  }, CORE_GROUPS = ["basic", "typography", "media", "layout", "form", "advanced", "other"], ChaiBuilderBlocks = ({ groups: o, blocks: n, parentId: r, position: a, gridCols: l = "grid-cols-4" }) => {
7209
- var b;
7210
- 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;
7349
+ var v;
7350
+ const { t: i } = useTranslation(), [c] = useBlocksStore(), [d, p] = useState(""), u = useRef(null), [g] = useAtom$1(addBlockTabAtom), f = (v = find(c, (k) => k._id === r)) == null ? void 0 : v._type, [m, h] = useState("all"), [x, b] = useState(null), y = useRef(null);
7211
7351
  useEffect(() => {
7212
- const x = setTimeout(() => {
7213
- var y;
7214
- (y = u.current) == null || y.focus();
7352
+ const k = setTimeout(() => {
7353
+ var E;
7354
+ (E = u.current) == null || E.focus();
7215
7355
  }, 0);
7216
- return () => clearTimeout(x);
7217
- }, [g]);
7218
- const f = d ? values(n).filter(
7219
- (x) => {
7220
- var y, A;
7221
- return (((y = x.label) == null ? void 0 : y.toLowerCase()) + " " + ((A = x.type) == null ? void 0 : A.toLowerCase())).includes(d.toLowerCase());
7222
- }
7223
- ) : 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);
7224
- return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-2xl flex-col", children: [
7356
+ return () => clearTimeout(k);
7357
+ }, [g]), useEffect(() => {
7358
+ d && (h("all"), b(null));
7359
+ }, [d]), useEffect(() => (y.current = debounce((k) => {
7360
+ h(k);
7361
+ }, 500), () => {
7362
+ y.current && y.current.cancel();
7363
+ }), []);
7364
+ const B = useCallback((k) => {
7365
+ b(k), y.current && y.current(k);
7366
+ }, []), j = useCallback(() => {
7367
+ b(null), y.current && y.current.cancel();
7368
+ }, []), C = useCallback((k) => {
7369
+ y.current && y.current.cancel(), h(k), b(null);
7370
+ }, []), S = useMemo(
7371
+ () => d ? values(n).filter(
7372
+ (k) => {
7373
+ var E, T;
7374
+ return (((E = k.label) == null ? void 0 : E.toLowerCase()) + " " + ((T = k.type) == null ? void 0 : T.toLowerCase())).includes(d.toLowerCase());
7375
+ }
7376
+ ) : n,
7377
+ [n, d]
7378
+ ), A = useMemo(
7379
+ () => d ? o.filter(
7380
+ (k) => reject(filter(values(S), { group: k }), { hidden: !0 }).length > 0
7381
+ ) : o.filter((k) => reject(filter(values(n), { group: k }), { hidden: !0 }).length > 0),
7382
+ [n, S, o, d]
7383
+ ), _ = useMemo(
7384
+ () => sortBy(A, (k) => CORE_GROUPS.indexOf(k) === -1 ? 99 : CORE_GROUPS.indexOf(k)),
7385
+ [A]
7386
+ ), w = useMemo(() => m === "all" ? S : filter(values(S), { group: m }), [S, m]), L = useMemo(() => m === "all" ? _ : [m], [_, m]);
7387
+ return /* @__PURE__ */ jsxs("div", { className: "mx-auto flex h-full w-full max-w-3xl flex-col", children: [
7225
7388
  /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 bg-background/80 px-4 py-2 backdrop-blur-sm", children: /* @__PURE__ */ jsx(
7226
7389
  Input$1,
7227
7390
  {
@@ -7229,32 +7392,59 @@ const CoreBlock = ({
7229
7392
  type: "search",
7230
7393
  placeholder: i("Search blocks..."),
7231
7394
  value: d,
7232
- onChange: (x) => p(x.target.value)
7395
+ className: "-ml-2",
7396
+ onChange: (k) => p(k.target.value)
7233
7397
  }
7234
7398
  ) }),
7235
- /* @__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: [
7236
- i("No blocks found matching"),
7237
- ' "',
7238
- d,
7239
- '"'
7240
- ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: sortBy(
7241
- h,
7242
- (x) => CORE_GROUPS.indexOf(x) === -1 ? 99 : CORE_GROUPS.indexOf(x)
7243
- ).map((x) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7244
- /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(x.toLowerCase())) }),
7245
- /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7246
- reject(filter(values(f), { group: x }), { hidden: !0 }).map((y) => /* @__PURE__ */ jsx(
7247
- CoreBlock,
7399
+ /* @__PURE__ */ jsxs("div", { className: "sticky top-10 flex h-[calc(100%-48px)] overflow-hidden", children: [
7400
+ _.length > 0 && /* @__PURE__ */ jsx("div", { className: "w-1/4 min-w-[120px] border-r", children: /* @__PURE__ */ jsx(ScrollArea, { className: "h-full", children: /* @__PURE__ */ jsxs("div", { className: "space-y-1 p-2", children: [
7401
+ /* @__PURE__ */ jsx(
7402
+ "button",
7248
7403
  {
7249
- parentId: r,
7250
- position: a,
7251
- block: y,
7252
- disabled: !canAcceptChildBlock(m, y.type) || !canBeNestedInside(m, y.type)
7404
+ onClick: () => C("all"),
7405
+ onMouseEnter: () => B("all"),
7406
+ onMouseLeave: j,
7407
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm font-medium ${m === "all" || x === "all" ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7408
+ children: i("All")
7253
7409
  },
7254
- y.type
7410
+ "sidebar-all"
7411
+ ),
7412
+ _.map((k) => /* @__PURE__ */ jsx(
7413
+ "button",
7414
+ {
7415
+ onClick: () => C(k),
7416
+ onMouseEnter: () => B(k),
7417
+ onMouseLeave: j,
7418
+ className: `w-full rounded-md px-2 py-1.5 text-left text-sm ${m === k || x === k ? "bg-accent text-accent-foreground" : "hover:bg-accent/50 hover:text-accent-foreground"}`,
7419
+ children: capitalize(i(k.toLowerCase()))
7420
+ },
7421
+ `sidebar-${k}`
7255
7422
  ))
7256
- ) })
7257
- ] }, x)) }) })
7423
+ ] }) }) }),
7424
+ /* @__PURE__ */ jsx("div", { className: "h-full w-3/4 flex-1 overflow-hidden", children: /* @__PURE__ */ jsx(ScrollArea, { id: "add-blocks-scroll-area", className: "no-scrollbar mr-4 h-full", children: A.length === 0 && d ? /* @__PURE__ */ jsx("div", { className: "flex flex-col items-center justify-center p-8 text-center text-muted-foreground", children: /* @__PURE__ */ jsxs("p", { children: [
7425
+ i("No blocks found matching"),
7426
+ ' "',
7427
+ d,
7428
+ '"'
7429
+ ] }) }) : /* @__PURE__ */ jsx("div", { className: "space-y-6 p-4", children: L.map((k) => /* @__PURE__ */ jsxs("div", { className: "space-y-3", children: [
7430
+ /* @__PURE__ */ jsx("h3", { className: "px-1 text-sm font-medium", children: capitalize(i(k.toLowerCase())) }),
7431
+ /* @__PURE__ */ jsx("div", { className: "grid gap-2 " + l, children: React__default.Children.toArray(
7432
+ reject(
7433
+ m === "all" ? filter(values(w), { group: k }) : values(w),
7434
+ { hidden: !0 }
7435
+ ).map((E) => /* @__PURE__ */ jsx(
7436
+ CoreBlock,
7437
+ {
7438
+ parentId: r,
7439
+ position: a,
7440
+ block: E,
7441
+ disabled: !canAcceptChildBlock(f, E.type) || !canBeNestedInside(f, E.type)
7442
+ },
7443
+ E.type
7444
+ ))
7445
+ ) })
7446
+ ] }, k)) }) }) })
7447
+ ] })
7258
7448
  ] });
7259
7449
  }, addBlockTabAtom = atomWithStorage("__add_block_tab", "library"), AddBlocksPanel = ({
7260
7450
  className: o,
@@ -7262,7 +7452,11 @@ const CoreBlock = ({
7262
7452
  parentId: r = void 0,
7263
7453
  position: a = -1
7264
7454
  }) => {
7265
- const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), g = useCallback(() => {
7455
+ const { t: l } = useTranslation(), [i, c] = useAtom$1(addBlockTabAtom), [, d] = useAtom$1(showPredefinedBlockCategoryAtom), p = useBuilderProp("importHTMLSupport", !0), u = useBuilderProp("addBlocksDialogTabs", []), { data: g } = usePartialBlocksList(), f = Object.keys(g || {}).length > 0;
7456
+ useEffect(() => {
7457
+ i === "partials" && !f && c("library");
7458
+ }, [i, f, c]);
7459
+ const m = useCallback(() => {
7266
7460
  pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7267
7461
  }, []);
7268
7462
  return /* @__PURE__ */ jsxs("div", { className: cn$1("flex h-full w-full flex-col overflow-hidden", o), children: [
@@ -7273,8 +7467,8 @@ const CoreBlock = ({
7273
7467
  /* @__PURE__ */ jsxs(
7274
7468
  Tabs,
7275
7469
  {
7276
- onValueChange: (m) => {
7277
- d(""), c(m);
7470
+ onValueChange: (h) => {
7471
+ d(""), c(h);
7278
7472
  },
7279
7473
  value: i,
7280
7474
  className: "flex h-full max-h-full flex-col overflow-hidden",
@@ -7282,13 +7476,15 @@ const CoreBlock = ({
7282
7476
  /* @__PURE__ */ jsxs(TabsList, { className: "flex w-full items-center", children: [
7283
7477
  /* @__PURE__ */ jsx(TabsTrigger, { value: "library", children: l("Library") }),
7284
7478
  /* @__PURE__ */ jsx(TabsTrigger, { value: "core", children: l("Blocks") }),
7479
+ f && /* @__PURE__ */ jsx(TabsTrigger, { value: "partials", children: l("Partials") }),
7285
7480
  p ? /* @__PURE__ */ jsx(TabsTrigger, { value: "html", children: l("Import") }) : null,
7286
- map(u, (m) => /* @__PURE__ */ jsx(TabsTrigger, { value: m.key, children: React__default.createElement(m.tab) }))
7481
+ map(u, (h) => /* @__PURE__ */ jsx(TabsTrigger, { value: h.key, children: React__default.createElement(h.tab) }))
7287
7482
  ] }),
7288
- /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ScrollArea, { className: "-mx-1.5 h-full max-h-full overflow-y-auto", children: /* @__PURE__ */ jsx("div", { className: "mt-2 w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7483
+ /* @__PURE__ */ jsx(TabsContent, { value: "core", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(DefaultChaiBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7289
7484
  /* @__PURE__ */ jsx(TabsContent, { value: "library", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(UILibrariesPanel, { parentId: r, position: a }) }),
7485
+ f && /* @__PURE__ */ jsx(TabsContent, { value: "partials", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx("div", { className: "-mx-1.5 h-full max-h-full overflow-hidden", children: /* @__PURE__ */ jsx("div", { className: "mt-2 h-full w-full", children: /* @__PURE__ */ jsx(PartialBlocks, { gridCols: "grid-cols-4", parentId: r, position: a }) }) }) }),
7290
7486
  p ? /* @__PURE__ */ jsx(TabsContent, { value: "html", className: "h-full max-h-full flex-1 pb-20", children: /* @__PURE__ */ jsx(ImportHTML, { parentId: r, position: a }) }) : null,
7291
- map(u, (m) => /* @__PURE__ */ jsx(TabsContent, { value: m.key, children: React__default.createElement(m.tabContent, { close: g, parentId: r, position: a }) }))
7487
+ map(u, (h) => /* @__PURE__ */ jsx(TabsContent, { value: h.key, children: React__default.createElement(h.tabContent, { close: m, parentId: r, position: a }) }))
7292
7488
  ]
7293
7489
  }
7294
7490
  )
@@ -7345,12 +7541,12 @@ const BlockCard = ({
7345
7541
  parentId: r = void 0,
7346
7542
  position: a = -1
7347
7543
  }) => {
7348
- 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) => {
7349
- const j = has(A, "styles_attrs.data-page-section");
7350
- return A._type === "Box" && j;
7351
- }, x = useCallback(
7352
- async (A) => {
7353
- if (A.stopPropagation(), has(o, "component")) {
7544
+ const [l, i] = useState(!1), c = useBuilderProp("getUILibraryBlock", noop), { addCoreBlock: d, addPredefinedBlock: p } = useAddBlock(), [, u] = useSelectedBlockIds(), { clearHighlight: g } = useBlockHighlight(), f = get(o, "name", get(o, "label")), m = useFeature("dnd"), [, h] = useAtom$1(draggedBlockAtom), x = (B) => {
7545
+ const j = has(B, "styles_attrs.data-page-section");
7546
+ return B._type === "Box" && j;
7547
+ }, b = useCallback(
7548
+ async (B) => {
7549
+ if (B.stopPropagation(), has(o, "component")) {
7354
7550
  d(o, r, a), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7355
7551
  return;
7356
7552
  }
@@ -7365,20 +7561,20 @@ const BlockCard = ({
7365
7561
  "div",
7366
7562
  {
7367
7563
  onClick: l ? () => {
7368
- } : x,
7369
- draggable: f ? "true" : "false",
7370
- onDragStart: async (A) => {
7564
+ } : b,
7565
+ draggable: m ? "true" : "false",
7566
+ onDragStart: async (B) => {
7371
7567
  const j = await c(n, o);
7372
7568
  let C = r;
7373
- if (b(first(j)) && (C = null), !isEmpty(j)) {
7569
+ if (x(first(j)) && (C = null), !isEmpty(j)) {
7374
7570
  const S = { blocks: j, uiLibrary: !0, parent: C };
7375
- if (A.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7376
- const B = new Image();
7377
- B.src = o.preview, B.onload = () => {
7378
- A.dataTransfer.setDragImage(B, 0, 0);
7571
+ if (B.dataTransfer.setData("text/plain", JSON.stringify(S)), o.preview) {
7572
+ const A = new Image();
7573
+ A.src = o.preview, A.onload = () => {
7574
+ B.dataTransfer.setDragImage(A, 0, 0);
7379
7575
  };
7380
7576
  } else
7381
- A.dataTransfer.setDragImage(new Image(), 0, 0);
7577
+ B.dataTransfer.setDragImage(new Image(), 0, 0);
7382
7578
  h(S), setTimeout(() => {
7383
7579
  u([]), g(), pubsub.publish(CHAI_BUILDER_EVENTS.CLOSE_ADD_BLOCK);
7384
7580
  }, 200);
@@ -7392,11 +7588,11 @@ const BlockCard = ({
7392
7588
  /* @__PURE__ */ jsx(Loader, { className: "animate-spin", size: 15, color: "white" }),
7393
7589
  /* @__PURE__ */ jsx("span", { className: "pl-2 text-sm text-white", children: "Adding..." })
7394
7590
  ] }),
7395
- o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: m }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: m }) })
7591
+ o.preview ? /* @__PURE__ */ jsx("img", { src: o.preview, className: "min-h-[45px] w-full rounded-md", alt: f }) : /* @__PURE__ */ jsx("div", { className: "flex h-20 items-center justify-center rounded-md border border-border bg-gray-200", children: /* @__PURE__ */ jsx("p", { className: "max-w-xs text-center text-sm text-gray-700", children: f }) })
7396
7592
  ]
7397
7593
  }
7398
7594
  ) }),
7399
- /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: m }) })
7595
+ /* @__PURE__ */ jsx(TooltipContent, { children: /* @__PURE__ */ jsx("p", { children: f }) })
7400
7596
  ] });
7401
7597
  }, libraryBlocksAtom = atom$1(
7402
7598
  {}
@@ -7411,9 +7607,9 @@ const BlockCard = ({
7411
7607
  })();
7412
7608
  }, [o, l, i, c, r, a]), { data: l || [], isLoading: i === "loading" };
7413
7609
  }, UILibrarySection = ({ parentId: o, position: n }) => {
7414
- 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) => {
7415
- b.current && (clearTimeout(b.current), b.current = null), b.current = setTimeout(() => {
7416
- b.current && f(C);
7610
+ 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"), [f, m] = useState("Hero"), h = get(g, f, []), x = useRef(null), { t: b } = useTranslation(), y = (C) => {
7611
+ x.current && (clearTimeout(x.current), x.current = null), x.current = setTimeout(() => {
7612
+ x.current && m(C);
7417
7613
  }, 300);
7418
7614
  };
7419
7615
  if (u)
@@ -7421,26 +7617,26 @@ const BlockCard = ({
7421
7617
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-3 h-full" }),
7422
7618
  /* @__PURE__ */ jsx(Skeleton, { className: "col-span-9 h-full" })
7423
7619
  ] });
7424
- const A = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
7620
+ const B = filter(h, (C, S) => S % 2 === 0), j = filter(h, (C, S) => S % 2 === 1);
7425
7621
  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: [
7426
7622
  /* @__PURE__ */ jsxs("div", { className: "flex h-full max-h-full w-60 flex-col gap-1 px-1 pr-2", children: [
7427
7623
  /* @__PURE__ */ jsx(UILibrariesSelect, { library: d == null ? void 0 : d.uuid, setLibrary: a, uiLibraries: l }),
7428
7624
  /* @__PURE__ */ jsxs("div", { className: "mt-2 flex h-full max-h-full w-full flex-1 flex-col", children: [
7429
- /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: x("Groups") }),
7625
+ /* @__PURE__ */ jsx("span", { className: "text-xs font-bold text-gray-500", children: b("Groups") }),
7430
7626
  /* @__PURE__ */ jsx("hr", { className: "mt-1 border-border" }),
7431
7627
  /* @__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(
7432
7628
  map(g, (C, S) => /* @__PURE__ */ jsxs(
7433
7629
  "div",
7434
7630
  {
7435
7631
  onMouseEnter: () => y(S),
7436
- onMouseLeave: () => clearTimeout(b.current),
7437
- onClick: () => f(S),
7632
+ onMouseLeave: () => clearTimeout(x.current),
7633
+ onClick: () => m(S),
7438
7634
  className: cn$1(
7439
7635
  "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",
7440
- S === m ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7636
+ S === f ? "bg-blue-500 text-white hover:bg-blue-600" : ""
7441
7637
  ),
7442
7638
  children: [
7443
- /* @__PURE__ */ jsx("span", { children: capitalize(x(S.toLowerCase())) }),
7639
+ /* @__PURE__ */ jsx("span", { children: capitalize(b(S.toLowerCase())) }),
7444
7640
  /* @__PURE__ */ jsx(CaretRightIcon, { className: "ml-2 h-5 w-5" })
7445
7641
  ]
7446
7642
  },
@@ -7452,12 +7648,12 @@ const BlockCard = ({
7452
7648
  /* @__PURE__ */ jsxs(
7453
7649
  ScrollArea,
7454
7650
  {
7455
- onMouseEnter: () => b.current ? clearTimeout(b.current) : null,
7651
+ onMouseEnter: () => x.current ? clearTimeout(x.current) : null,
7456
7652
  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",
7457
7653
  children: [
7458
7654
  /* @__PURE__ */ jsxs("div", { className: "grid grid-cols-2 gap-2 px-2", children: [
7459
7655
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7460
- A.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7656
+ B.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
7461
7657
  ) }),
7462
7658
  /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1", children: React__default.Children.toArray(
7463
7659
  j.map((C) => /* @__PURE__ */ jsx(BlockCard, { parentId: o, position: n, block: C, library: d }))
@@ -7680,53 +7876,53 @@ function BiExpandVertical(o) {
7680
7876
  return GenIcon({ tag: "svg", attr: { viewBox: "0 0 24 24" }, child: [{ tag: "path", attr: { d: "m12 19.24-4.95-4.95-1.41 1.42L12 22.07l6.36-6.36-1.41-1.42L12 19.24zM5.64 8.29l1.41 1.42L12 4.76l4.95 4.95 1.41-1.42L12 1.93 5.64 8.29z" }, child: [] }] })(o);
7681
7877
  }
7682
7878
  const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, dragHandle: r }) => {
7683
- var P;
7879
+ var R;
7684
7880
  const a = useBuilderProp("outlineMenuItems", []), { t: l } = useTranslation(), [i, , c] = useHiddenBlockIds(), [d] = useAtom$1(canvasIframeAtom);
7685
7881
  let p = null;
7686
- 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) => {
7687
- E.stopPropagation(), !i.includes(f) && o.toggle();
7688
- }, S = (E) => {
7689
- E.isInternal && (p = E.isOpen, E.isOpen && E.close());
7690
- }, B = (E) => {
7691
- E.isInternal && p !== null && (p ? E.open() : E.close(), p = null);
7692
- }, [_, w] = useAtom$1(currentAddSelection), T = () => {
7693
- var E;
7694
- k(), o.parent.isSelected || w((E = o == null ? void 0 : o.parent) == null ? void 0 : E.id);
7695
- }, k = () => {
7882
+ const u = o.children.length > 0, { highlightBlock: g, clearHighlight: f } = useBlockHighlight(), { id: m, data: h, isSelected: x, willReceiveDrop: b, isDragging: y, isEditing: B, handleClick: j } = o, C = (N) => {
7883
+ N.stopPropagation(), !i.includes(m) && o.toggle();
7884
+ }, S = (N) => {
7885
+ N.isInternal && (p = N.isOpen, N.isOpen && N.close());
7886
+ }, A = (N) => {
7887
+ N.isInternal && p !== null && (p ? N.open() : N.close(), p = null);
7888
+ }, [_, w] = useAtom$1(currentAddSelection), L = () => {
7889
+ var N;
7890
+ v(), o.parent.isSelected || w((N = o == null ? void 0 : o.parent) == null ? void 0 : N.id);
7891
+ }, v = () => {
7696
7892
  w(null);
7697
- }, v = (E) => {
7698
- k(), E.stopPropagation(), !o.isOpen && !i.includes(f) && o.toggle(), j(E);
7893
+ }, k = (N) => {
7894
+ v(), N.stopPropagation(), !o.isOpen && !i.includes(m) && o.toggle(), j(N);
7699
7895
  };
7700
7896
  useEffect(() => {
7701
- const E = setTimeout(() => {
7702
- x && !o.isOpen && !y && !i.includes(f) && o.toggle();
7897
+ const N = setTimeout(() => {
7898
+ b && !o.isOpen && !y && !i.includes(m) && o.toggle();
7703
7899
  }, 500);
7704
- return () => clearTimeout(E);
7705
- }, [x, o, y]);
7706
- const N = useMemo(() => {
7707
- const E = Object.keys(h), D = [];
7708
- for (let M = 0; M < E.length; M++)
7709
- if (E[M].endsWith("_attrs")) {
7710
- const R = h[E[M]], O = Object.keys(R).join("|");
7900
+ return () => clearTimeout(N);
7901
+ }, [b, o, y]);
7902
+ const E = useMemo(() => {
7903
+ const N = Object.keys(h), D = [];
7904
+ for (let M = 0; M < N.length; M++)
7905
+ if (N[M].endsWith("_attrs")) {
7906
+ const P = h[N[M]], O = Object.keys(P).join("|");
7711
7907
  O.match(/x-data/) && D.push("data"), O.match(/x-on/) && D.push("event"), O.match(/x-show|x-if/) && D.push("show");
7712
7908
  }
7713
7909
  return D;
7714
- }, [h]), I = (E, D) => {
7715
- const M = d.contentDocument || d.contentWindow.document, R = M.querySelector(`[data-block-id=${E}]`);
7716
- R && R.setAttribute("data-drop", D);
7717
- const O = R.getBoundingClientRect(), $ = d.getBoundingClientRect();
7718
- O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = R.offsetTop - $.top);
7719
- }, L = (E) => {
7720
- k();
7910
+ }, [h]), T = (N, D) => {
7911
+ const M = d.contentDocument || d.contentWindow.document, P = M.querySelector(`[data-block-id=${N}]`);
7912
+ P && P.setAttribute("data-drop", D);
7913
+ const O = P.getBoundingClientRect(), $ = d.getBoundingClientRect();
7914
+ O.top >= $.top && O.left >= $.left && O.bottom <= $.bottom && O.right <= $.right || (M.documentElement.scrollTop = P.offsetTop - $.top);
7915
+ }, I = (N) => {
7916
+ v();
7721
7917
  const D = get(o, "parent.id");
7722
- 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 });
7918
+ D !== "__REACT_ARBORIST_INTERNAL_ROOT__" ? pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: D, position: N }) : pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { position: N });
7723
7919
  };
7724
- return f === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7920
+ return m === ROOT_TEMP_KEY ? /* @__PURE__ */ jsxs("div", { className: "group relative w-full cursor-pointer", children: [
7725
7921
  /* @__PURE__ */ jsx("br", {}),
7726
7922
  /* @__PURE__ */ jsx(
7727
7923
  "div",
7728
7924
  {
7729
- onClick: () => L(-1),
7925
+ onClick: () => I(-1),
7730
7926
  className: "h-1 rounded bg-purple-500 opacity-0 duration-200 group-hover:opacity-100",
7731
7927
  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: [
7732
7928
  /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-2 w-2 stroke-[3]" }),
@@ -7736,35 +7932,35 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7736
7932
  }
7737
7933
  ),
7738
7934
  /* @__PURE__ */ jsx("br", {})
7739
- ] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id: f, children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7935
+ ] }) : /* @__PURE__ */ jsx(BlockContextMenu, { id: m, children: /* @__PURE__ */ jsx("div", { className: "w-full", children: /* @__PURE__ */ jsxs(
7740
7936
  "div",
7741
7937
  {
7742
- onMouseEnter: () => g(f),
7743
- onMouseLeave: () => m(),
7744
- onClick: v,
7938
+ onMouseEnter: () => g(m),
7939
+ onMouseLeave: () => f(),
7940
+ onClick: k,
7745
7941
  style: n,
7746
- "data-node-id": f,
7747
- ref: i.includes(f) ? null : r,
7942
+ "data-node-id": m,
7943
+ ref: i.includes(m) ? null : r,
7748
7944
  onDragStart: () => S(o),
7749
- onDragEnd: () => B(o),
7750
- onDragOver: (E) => {
7751
- E.preventDefault(), I(f, "yes");
7945
+ onDragEnd: () => A(o),
7946
+ onDragOver: (N) => {
7947
+ N.preventDefault(), T(m, "yes");
7752
7948
  },
7753
- onDragLeave: (E) => {
7754
- E.preventDefault(), I(f, "no");
7949
+ onDragLeave: (N) => {
7950
+ N.preventDefault(), T(m, "no");
7755
7951
  },
7756
- onDrop: (E) => {
7757
- E.preventDefault(), I(f, "no");
7952
+ onDrop: (N) => {
7953
+ N.preventDefault(), T(m, "no");
7758
7954
  },
7759
7955
  children: [
7760
- (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(
7956
+ (o == null ? void 0 : o.rowIndex) > 0 && (o.parent.isOpen && canAddChildBlock(get(o, "parent.data._type")) || ((R = o == null ? void 0 : o.parent) == null ? void 0 : R.id) === "__REACT_ARBORIST_INTERNAL_ROOT__") && /* @__PURE__ */ jsx("div", { className: "group relative ml-5 h-full w-full cursor-pointer", children: /* @__PURE__ */ jsx(
7761
7957
  "div",
7762
7958
  {
7763
- onClick: (E) => {
7764
- E.stopPropagation(), L(o.childIndex);
7959
+ onClick: (N) => {
7960
+ N.stopPropagation(), I(o.childIndex);
7765
7961
  },
7766
- onMouseEnter: T,
7767
- onMouseLeave: k,
7962
+ onMouseEnter: L,
7963
+ onMouseLeave: v,
7768
7964
  className: "absolute -top-0.5 h-1 w-[90%] rounded bg-purple-500 opacity-0 delay-200 duration-200 group-hover:opacity-100",
7769
7965
  children: /* @__PURE__ */ jsx("div", { className: "absolute left-1/2 top-1/2 flex h-4 w-4 -translate-x-1/2 -translate-y-1/2 transform items-center justify-center rounded-full bg-purple-500 p-1 outline outline-2 outline-white hover:bg-purple-500", children: /* @__PURE__ */ jsx(PlusIcon$1, { className: "h-3 w-3 stroke-[4] text-white" }) })
7770
7966
  }
@@ -7774,11 +7970,11 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7774
7970
  {
7775
7971
  className: cn$1(
7776
7972
  "group flex w-full cursor-pointer items-center justify-between space-x-px !rounded p-1 text-foreground/80 outline-none",
7777
- b ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7778
- x && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7973
+ x ? "bg-blue-500 text-white" : "hover:bg-slate-200 dark:hover:bg-gray-800",
7974
+ b && canAcceptChildBlock(h._type, "Icon") ? "bg-green-200" : "",
7779
7975
  (o == null ? void 0 : o.id) === _ ? "bg-purple-100" : "",
7780
7976
  y && "opacity-20",
7781
- i.includes(f) ? "opacity-50" : ""
7977
+ i.includes(m) ? "opacity-50" : ""
7782
7978
  ),
7783
7979
  children: [
7784
7980
  /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
@@ -7789,47 +7985,47 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7789
7985
  children: u && /* @__PURE__ */ jsx("button", { onClick: C, type: "button", children: /* @__PURE__ */ jsx(
7790
7986
  ChevronRight,
7791
7987
  {
7792
- className: `h-3 w-3 stroke-[3] ${b ? "text-slate-200" : "text-slate-400"}`
7988
+ className: `h-3 w-3 stroke-[3] ${x ? "text-slate-200" : "text-slate-400"}`
7793
7989
  }
7794
7990
  ) })
7795
7991
  }
7796
7992
  ),
7797
7993
  /* @__PURE__ */ jsxs("div", { className: "leading-1 flex items-center", children: [
7798
7994
  /* @__PURE__ */ jsx(TypeIcon, { type: h == null ? void 0 : h._type }),
7799
- A ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7995
+ B ? /* @__PURE__ */ jsx(Input, { node: o }) : /* @__PURE__ */ jsxs(
7800
7996
  "div",
7801
7997
  {
7802
7998
  className: "ml-1.5 flex items-center gap-x-1 truncate text-[13px]",
7803
- onDoubleClick: (E) => {
7804
- E.stopPropagation(), o.edit(), o.deselect();
7999
+ onDoubleClick: (N) => {
8000
+ N.stopPropagation(), o.edit(), o.deselect();
7805
8001
  },
7806
8002
  children: [
7807
8003
  /* @__PURE__ */ jsx("span", { children: (h == null ? void 0 : h._name) || (h == null ? void 0 : h._type.split("/").pop()) }),
7808
- N.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
7809
- N.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
7810
- N.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
8004
+ E.includes("data") && /* @__PURE__ */ jsx(VscJson, { className: "h-3 w-3 text-orange-600" }),
8005
+ E.includes("event") && /* @__PURE__ */ jsx(BsLightningFill, { className: "h-3 w-3 text-yellow-500" }),
8006
+ E.includes("show") && /* @__PURE__ */ jsx(TbEyeDown, { className: "h-3 w-3 text-orange-600" })
7811
8007
  ]
7812
8008
  }
7813
8009
  )
7814
8010
  ] })
7815
8011
  ] }),
7816
8012
  /* @__PURE__ */ jsxs("div", { className: "invisible flex items-center space-x-1.5 pr-2 group-hover:visible", children: [
7817
- !i.includes(f) && a.map((E) => /* @__PURE__ */ jsxs(Tooltip, { children: [
8013
+ !i.includes(m) && a.map((N) => /* @__PURE__ */ jsxs(Tooltip, { children: [
7818
8014
  /* @__PURE__ */ jsx(
7819
8015
  TooltipTrigger,
7820
8016
  {
7821
8017
  className: "cursor-pointer rounded bg-transparent hover:bg-white hover:text-blue-500",
7822
8018
  asChild: !0,
7823
- children: React__default.createElement(E.item, { blockId: f })
8019
+ children: React__default.createElement(N.item, { blockId: m })
7824
8020
  }
7825
8021
  ),
7826
- /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: E.tooltip })
8022
+ /* @__PURE__ */ jsx(TooltipContent, { className: "isolate z-10", children: N.tooltip })
7827
8023
  ] })),
7828
- canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(f) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
8024
+ canAddChildBlock(h == null ? void 0 : h._type) && !i.includes(m) ? /* @__PURE__ */ jsxs(Tooltip, { children: [
7829
8025
  /* @__PURE__ */ jsx(
7830
8026
  TooltipTrigger,
7831
8027
  {
7832
- onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: f }),
8028
+ onClick: () => pubsub.publish(CHAI_BUILDER_EVENTS.OPEN_ADD_BLOCK, { _id: m }),
7833
8029
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7834
8030
  asChild: !0,
7835
8031
  children: /* @__PURE__ */ jsx(PlusIcon$1, { size: "15" })
@@ -7841,8 +8037,8 @@ const currentAddSelection = atom$1(null), Node = memo(({ node: o, style: n, drag
7841
8037
  /* @__PURE__ */ jsx(
7842
8038
  TooltipTrigger,
7843
8039
  {
7844
- onClick: (E) => {
7845
- E.stopPropagation(), c(f), o.isOpen && o.toggle();
8040
+ onClick: (N) => {
8041
+ N.stopPropagation(), c(m), o.isOpen && o.toggle();
7846
8042
  },
7847
8043
  className: "cursor-pointer rounded bg-transparent hover:text-black",
7848
8044
  asChild: !0,
@@ -8502,14 +8698,14 @@ function QuickPrompts({ onClick: o }) {
8502
8698
  ) }) });
8503
8699
  }
8504
8700
  const AIUserPrompt = ({ blockId: o }) => {
8505
- 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);
8701
+ const { t: n } = useTranslation(), { askAi: r, loading: a, error: l } = useAskAi(), [i, c] = useState(""), [d, p] = useState(!0), [u, g] = useState(), f = useRef(null), m = useRef(null);
8506
8702
  useEffect(() => {
8507
- var b;
8508
- (b = m.current) == null || b.focus();
8703
+ var x;
8704
+ (x = f.current) == null || x.focus();
8509
8705
  }, []);
8510
- const h = (b) => {
8511
- const { usage: x } = b || {};
8512
- !l && x && g(x), f.current = setTimeout(() => g(void 0), 1e4), l || c("");
8706
+ const h = (x) => {
8707
+ const { usage: b } = x || {};
8708
+ !l && b && g(b), m.current = setTimeout(() => g(void 0), 1e4), l || c("");
8513
8709
  };
8514
8710
  return /* @__PURE__ */ jsxs("div", { className: "", children: [
8515
8711
  /* @__PURE__ */ jsxs(
@@ -8527,14 +8723,14 @@ const AIUserPrompt = ({ blockId: o }) => {
8527
8723
  /* @__PURE__ */ jsx(
8528
8724
  Textarea,
8529
8725
  {
8530
- ref: m,
8726
+ ref: f,
8531
8727
  value: i,
8532
- onChange: (b) => c(b.target.value),
8728
+ onChange: (x) => c(x.target.value),
8533
8729
  placeholder: n("Ask AI to edit content"),
8534
8730
  className: "w-full",
8535
8731
  rows: 3,
8536
- onKeyDown: (b) => {
8537
- b.key === "Enter" && (b.preventDefault(), f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h));
8732
+ onKeyDown: (x) => {
8733
+ x.key === "Enter" && (x.preventDefault(), m.current && clearTimeout(m.current), g(void 0), r("content", o, i, h));
8538
8734
  }
8539
8735
  }
8540
8736
  ),
@@ -8544,7 +8740,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8544
8740
  {
8545
8741
  disabled: i.trim().length < 5 || a,
8546
8742
  onClick: () => {
8547
- f.current && clearTimeout(f.current), g(void 0), r("content", o, i, h);
8743
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, i, h);
8548
8744
  },
8549
8745
  variant: "default",
8550
8746
  className: "w-fit",
@@ -8576,8 +8772,8 @@ const AIUserPrompt = ({ blockId: o }) => {
8576
8772
  /* @__PURE__ */ jsx(
8577
8773
  QuickPrompts,
8578
8774
  {
8579
- onClick: (b) => {
8580
- f.current && clearTimeout(f.current), g(void 0), r("content", o, b, h);
8775
+ onClick: (x) => {
8776
+ m.current && clearTimeout(m.current), g(void 0), r("content", o, x, h);
8581
8777
  }
8582
8778
  }
8583
8779
  )
@@ -8587,13 +8783,13 @@ const AIUserPrompt = ({ blockId: o }) => {
8587
8783
  ] }) }) : null
8588
8784
  ] });
8589
8785
  }, AISetContext = () => {
8590
- 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);
8786
+ 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), f = useRef(null);
8591
8787
  useEffect(() => {
8592
8788
  n && a(n);
8593
8789
  }, [n]);
8594
- const f = async () => {
8790
+ const m = async () => {
8595
8791
  try {
8596
- d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), m.current.click();
8792
+ d(!0), u(null), await i(r), toast.success(o("Updated AI Context")), f.current.click();
8597
8793
  } catch (h) {
8598
8794
  u(h);
8599
8795
  } finally {
@@ -8609,7 +8805,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8609
8805
  type: "single",
8610
8806
  collapsible: !0,
8611
8807
  children: /* @__PURE__ */ jsxs(AccordionItem, { value: "set-context", className: "border-none", children: [
8612
- /* @__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") }) }) }),
8808
+ /* @__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") }) }) }),
8613
8809
  /* @__PURE__ */ jsxs(AccordionContent, { children: [
8614
8810
  /* @__PURE__ */ jsx(
8615
8811
  Textarea,
@@ -8621,7 +8817,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8621
8817
  className: "mt-1 w-full",
8622
8818
  rows: 10,
8623
8819
  onKeyDown: (h) => {
8624
- h.key === "Enter" && (h.preventDefault(), f());
8820
+ h.key === "Enter" && (h.preventDefault(), m());
8625
8821
  }
8626
8822
  }
8627
8823
  ),
@@ -8633,7 +8829,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8633
8829
  Button,
8634
8830
  {
8635
8831
  disabled: r.trim().length < 5,
8636
- onClick: () => f(),
8832
+ onClick: () => m(),
8637
8833
  variant: "default",
8638
8834
  className: "w-fit",
8639
8835
  size: "sm",
@@ -8662,7 +8858,7 @@ const AIUserPrompt = ({ blockId: o }) => {
8662
8858
  AlertDialogAction,
8663
8859
  {
8664
8860
  onClick: () => {
8665
- a(""), f();
8861
+ a(""), m();
8666
8862
  },
8667
8863
  children: o("Yes, Delete")
8668
8864
  }
@@ -8816,32 +9012,32 @@ const AiAssistant = () => {
8816
9012
  ] })
8817
9013
  ] });
8818
9014
  }, AttrsEditor = React__default.memo(function o({ preloadedAttributes: n = [], onAttributesChange: r }) {
8819
- const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [m, f] = useState(""), h = useRef(null), b = useRef(null);
9015
+ const [a, l] = useState([]), [i, c] = useState(""), [d, p] = useState(""), [u, g] = useState(null), [f, m] = useState(""), h = useRef(null), x = useRef(null);
8820
9016
  useEffect(() => {
8821
9017
  l(n);
8822
9018
  }, [n]);
8823
- const x = () => {
9019
+ const b = () => {
8824
9020
  if (i.startsWith("@")) {
8825
- f("Attribute keys cannot start with '@'");
9021
+ m("Attribute keys cannot start with '@'");
8826
9022
  return;
8827
9023
  }
8828
9024
  if (i) {
8829
9025
  const S = [...a, { key: i, value: d }];
8830
- r(S), l(a), c(""), p(""), f("");
9026
+ r(S), l(a), c(""), p(""), m("");
8831
9027
  }
8832
9028
  }, y = (S) => {
8833
- const B = a.filter((_, w) => w !== S);
8834
- r(B), l(B);
8835
- }, A = (S) => {
9029
+ const A = a.filter((_, w) => w !== S);
9030
+ r(A), l(A);
9031
+ }, B = (S) => {
8836
9032
  g(S), c(a[S].key), p(a[S].value);
8837
9033
  }, j = () => {
8838
9034
  if (i.startsWith("@")) {
8839
- f("Attribute keys cannot start with '@'");
9035
+ m("Attribute keys cannot start with '@'");
8840
9036
  return;
8841
9037
  }
8842
9038
  if (u !== null && i) {
8843
9039
  const S = [...a];
8844
- S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), f("");
9040
+ S[u] = { key: i, value: d }, r(S), l(S), g(null), c(""), p(""), m("");
8845
9041
  }
8846
9042
  };
8847
9043
  return /* @__PURE__ */ jsxs("div", { className: "flex max-h-full flex-1 flex-col", children: [
@@ -8849,7 +9045,7 @@ const AiAssistant = () => {
8849
9045
  "form",
8850
9046
  {
8851
9047
  onSubmit: (S) => {
8852
- S.preventDefault(), u !== null ? j() : x();
9048
+ S.preventDefault(), u !== null ? j() : b();
8853
9049
  },
8854
9050
  className: "space-y-3",
8855
9051
  children: [
@@ -8881,11 +9077,11 @@ const AiAssistant = () => {
8881
9077
  spellCheck: "false",
8882
9078
  id: "attrValue",
8883
9079
  rows: 2,
8884
- ref: b,
9080
+ ref: x,
8885
9081
  value: d,
8886
9082
  onChange: (S) => p(S.target.value),
8887
9083
  onKeyDown: (S) => {
8888
- S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : x());
9084
+ S.key === "Enter" && !S.shiftKey && (S.preventDefault(), u !== null ? j() : b());
8889
9085
  },
8890
9086
  placeholder: "Enter Value",
8891
9087
  className: "text-xs font-normal leading-tight placeholder:text-slate-400"
@@ -8894,20 +9090,20 @@ const AiAssistant = () => {
8894
9090
  ] })
8895
9091
  ] }),
8896
9092
  /* @__PURE__ */ jsx("div", { className: "flex justify-end", children: /* @__PURE__ */ jsx(Button, { type: "submit", disabled: !i.length, variant: "default", size: "sm", className: "h-8 w-24 text-xs", children: u !== null ? "Save" : "Add" }) }),
8897
- m && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: m })
9093
+ f && /* @__PURE__ */ jsx("p", { className: "text-xs text-red-500", children: f })
8898
9094
  ]
8899
9095
  }
8900
9096
  ),
8901
- /* @__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: [
9097
+ /* @__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: [
8902
9098
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col text-xs leading-tight", children: [
8903
9099
  /* @__PURE__ */ jsx("span", { className: "truncate text-[12px] font-light text-muted-foreground", children: S.key }),
8904
9100
  /* @__PURE__ */ jsx("span", { className: "text-wrap max-w-[200px] font-normal", children: S.value.toString() })
8905
9101
  ] }),
8906
9102
  /* @__PURE__ */ jsxs("div", { className: "flex-shrink-0 text-slate-400", children: [
8907
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => A(B), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
8908
- /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(B), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
9103
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => B(A), children: /* @__PURE__ */ jsx(Edit2, { className: "h-3 w-3" }) }),
9104
+ /* @__PURE__ */ jsx(Button, { variant: "ghost", size: "icon", className: "h-6 w-6", onClick: () => y(A), children: /* @__PURE__ */ jsx(X, { className: "h-3 w-3" }) })
8909
9105
  ] })
8910
- ] }, B)) })
9106
+ ] }, A)) })
8911
9107
  ] });
8912
9108
  }), BlockAttributesEditor = React.memo(() => {
8913
9109
  const o = useSelectedBlock(), [n, r] = useState([]), [a] = useSelectedStylingBlocks(), l = useUpdateBlocksProps(), i = `${get(a, "0.prop")}_attrs`;
@@ -9101,11 +9297,11 @@ const RootLayout = () => {
9101
9297
  usePubSub(CHAI_BUILDER_EVENTS.SHOW_BLOCK_SETTINGS, () => {
9102
9298
  n(1);
9103
9299
  });
9104
- const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (b) => {
9105
- b.preventDefault();
9106
- }, u = (b) => {
9107
- n(o === b ? null : b);
9108
- }, g = useSidebarMenuItems(), { t: m } = useTranslation(), f = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
9300
+ const c = useBuilderProp("sideBarComponents.top", []), d = useBuilderProp("sideBarComponents.bottom", []), p = (x) => {
9301
+ x.preventDefault();
9302
+ }, u = (x) => {
9303
+ n(o === x ? null : x);
9304
+ }, g = useSidebarMenuItems(), { t: f } = useTranslation(), m = [...g, ...c], h = useBuilderProp("htmlDir", "ltr");
9109
9305
  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: [
9110
9306
  /* @__PURE__ */ jsxs(
9111
9307
  "div",
@@ -9116,21 +9312,21 @@ const RootLayout = () => {
9116
9312
  /* @__PURE__ */ jsx("div", { className: "h-14 w-screen shrink-0 border-b border-border", children: /* @__PURE__ */ jsx(Suspense, { children: /* @__PURE__ */ jsx(TopBar, {}) }) }),
9117
9313
  /* @__PURE__ */ jsxs("main", { className: "relative flex h-[calc(100vh-56px)] max-w-full flex-1 flex-row", children: [
9118
9314
  /* @__PURE__ */ jsxs("div", { className: "flex w-12 flex-col items-center justify-between border-r border-border py-2", children: [
9119
- /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: f.map((b, x) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9315
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: m.map((x, b) => /* @__PURE__ */ jsxs(Tooltip, { children: [
9120
9316
  /* @__PURE__ */ jsx(TooltipTrigger, { asChild: !0, children: /* @__PURE__ */ jsx(
9121
9317
  Button,
9122
9318
  {
9123
- variant: o === x ? "default" : "ghost",
9319
+ variant: o === b ? "default" : "ghost",
9124
9320
  className: "mb-2 rounded-lg p-2 transition-colors",
9125
- onClick: () => u(x),
9126
- children: get(b, "icon", null)
9321
+ onClick: () => u(b),
9322
+ children: get(x, "icon", null)
9127
9323
  },
9128
- x
9324
+ b
9129
9325
  ) }),
9130
- /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: m(b.label) }) })
9131
- ] }, "button" + x)) }),
9326
+ /* @__PURE__ */ jsx(TooltipContent, { side: "right", children: /* @__PURE__ */ jsx("p", { children: f(x.label) }) })
9327
+ ] }, "button" + b)) }),
9132
9328
  /* @__PURE__ */ jsx("div", { className: "flex flex-col space-y-1" }),
9133
- /* @__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}`)) })
9329
+ /* @__PURE__ */ jsx("div", { className: "flex flex-col", children: d == null ? void 0 : d.map((x, b) => /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", {}), children: React__default.createElement(x, {}) }, `sidebar-component-${b}`)) })
9134
9330
  ] }),
9135
9331
  /* @__PURE__ */ jsx(
9136
9332
  motion.div,
@@ -9143,14 +9339,14 @@ const RootLayout = () => {
9143
9339
  /* @__PURE__ */ jsxs(
9144
9340
  "div",
9145
9341
  {
9146
- className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(f, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9342
+ className: `absolute top-2 flex h-10 items-center space-x-1 bg-white py-2 text-base font-bold ${get(m, `${o}.isInternal`, !1) ? "" : "w-64"}`,
9147
9343
  children: [
9148
- /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(f, `${o}.icon`, null) }),
9149
- /* @__PURE__ */ jsx("span", { children: m(f[o].label) })
9344
+ /* @__PURE__ */ jsx("span", { className: "rtl:ml-2 rtl:inline-block", children: get(m, `${o}.icon`, null) }),
9345
+ /* @__PURE__ */ jsx("span", { children: f(m[o].label) })
9150
9346
  ]
9151
9347
  }
9152
9348
  ),
9153
- /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(f, `${o}.component`, null), {}) }) })
9349
+ /* @__PURE__ */ jsx("div", { className: "no-scrollbar max-h-full overflow-y-auto pt-10", children: /* @__PURE__ */ jsx(Suspense, { fallback: /* @__PURE__ */ jsx("div", { children: "Loading..." }), children: React__default.createElement(get(m, `${o}.component`, null), {}) }) })
9154
9350
  ] })
9155
9351
  }
9156
9352
  ),
@@ -9169,11 +9365,11 @@ const RootLayout = () => {
9169
9365
  /* @__PURE__ */ jsx("h2", { className: "-mt-1 flex items-center space-x-1 text-base font-bold", children: /* @__PURE__ */ jsx("div", { className: "flex grow items-center gap-2", children: /* @__PURE__ */ jsx("div", { className: "flex w-full items-center justify-between gap-2", children: l === "ai" ? /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-2", children: [
9170
9366
  /* @__PURE__ */ jsx(LightningBoltIcon, { className: "rtl:ml-2" }),
9171
9367
  " ",
9172
- m("AI Assistant")
9368
+ f("AI Assistant")
9173
9369
  ] }) }) : l === "theme" ? /* @__PURE__ */ jsxs("div", { className: "flex w-full items-center justify-between gap-2", children: [
9174
9370
  /* @__PURE__ */ jsxs("span", { className: "flex items-center gap-2", children: [
9175
9371
  /* @__PURE__ */ jsx(Paintbrush, { className: "h-4 w-4 rtl:ml-2" }),
9176
- m("Theme Settings")
9372
+ f("Theme Settings")
9177
9373
  ] }),
9178
9374
  /* @__PURE__ */ jsx(
9179
9375
  Button,
@@ -9225,7 +9421,7 @@ const RootLayout = () => {
9225
9421
  }, r * 1e3);
9226
9422
  }, ChaiBuilderComponent = (o) => {
9227
9423
  const [, n] = useBlocksStore(), r = useBuilderReset(), [a] = useAtom(builderSaveStateAtom), l = useMemo(() => o.layout || RootLayout, [o.layout]);
9228
- useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchGlobalBlocks(), useUnmountBroadcastChannel();
9424
+ useAtom(selectedLibraryAtom), useKeyEventWatcher(), useExpandTree(), useAutoSave(), useWatchPartailBlocks(), useUnmountBroadcastChannel();
9229
9425
  const { postMessage: i } = useBroadcastChannel();
9230
9426
  return useEffect(() => {
9231
9427
  builderStore.set(
@@ -9316,12 +9512,12 @@ export {
9316
9512
  useCutBlockIds,
9317
9513
  useDarkMode,
9318
9514
  useDuplicateBlocks,
9319
- useGlobalBlocksList,
9320
- useGlobalBlocksStore,
9321
9515
  useHiddenBlockIds,
9322
9516
  useHighlightBlockId,
9323
9517
  useLanguages,
9324
9518
  useLayoutVariant,
9519
+ usePartailBlocksStore,
9520
+ usePartialBlocksList,
9325
9521
  usePasteBlocks,
9326
9522
  usePreviewMode,
9327
9523
  useRemoveBlocks,